diff --git a/android/lib/src/main/res/raw/trust_min.js b/android/lib/src/main/res/raw/trust_min.js index 446145c2..3539ebb0 100644 --- a/android/lib/src/main/res/raw/trust_min.js +++ b/android/lib/src/main/res/raw/trust_min.js @@ -1,37 +1,39 @@ -!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";let e;const t=new Uint8Array(16);function r(){if(!e&&(e="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!e))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return e(t)}var n=/^(?:[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;const i=[];for(let e=0;e<256;++e)i.push((e+256).toString(16).slice(1));function o(e,t=0){return i[e[t+0]]+i[e[t+1]]+i[e[t+2]]+i[e[t+3]]+"-"+i[e[t+4]]+i[e[t+5]]+"-"+i[e[t+6]]+i[e[t+7]]+"-"+i[e[t+8]]+i[e[t+9]]+"-"+i[e[t+10]]+i[e[t+11]]+i[e[t+12]]+i[e[t+13]]+i[e[t+14]]+i[e[t+15]]}function s(e){if(!function(e){return"string"==typeof e&&n.test(e)}(e))throw TypeError("Invalid UUID");let t;const r=new Uint8Array(16);return r[0]=(t=parseInt(e.slice(0,8),16))>>>24,r[1]=t>>>16&255,r[2]=t>>>8&255,r[3]=255&t,r[4]=(t=parseInt(e.slice(9,13),16))>>>8,r[5]=255&t,r[6]=(t=parseInt(e.slice(14,18),16))>>>8,r[7]=255&t,r[8]=(t=parseInt(e.slice(19,23),16))>>>8,r[9]=255&t,r[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,r[11]=t/4294967296&255,r[12]=t>>>24&255,r[13]=t>>>16&255,r[14]=t>>>8&255,r[15]=255&t,r}function a(e,t,r){function n(e,n,i,a){var c;if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));const t=[];for(let r=0;r>>9<<4)+1}function u(e,t){const r=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(r>>16)<<16|65535&r}function l(e,t,r,n,i,o){return u((s=u(u(t,e),u(n,o)))<<(a=i)|s>>>32-a,r);var s,a}function h(e,t,r,n,i,o,s){return l(t&r|~t&n,e,t,i,o,s)}function f(e,t,r,n,i,o,s){return l(t&n|r&~n,e,t,i,o,s)}function d(e,t,r,n,i,o,s){return l(t^r^n,e,t,i,o,s)}function p(e,t,r,n,i,o,s){return l(r^(t|~n),e,t,i,o,s)}a("v3",48,(function(e){if("string"==typeof e){const t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(let r=0;r>5]>>>i%32&255,o=parseInt(n.charAt(r>>>4&15)+n.charAt(15&r),16);t.push(o)}return t}(function(e,t){e[t>>5]|=128<>5]|=(255&e[n/8])<>>32-t}a("v5",80,(function(e){const t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof e){const t=unescape(encodeURIComponent(e));e=[];for(let r=0;r>>0;u=c,c=a,a=w(s,30)>>>0,s=i,i=o}r[0]=r[0]+i>>>0,r[1]=r[1]+s>>>0,r[2]=r[2]+a>>>0,r[3]=r[3]+c>>>0,r[4]=r[4]+u>>>0}return[r[0]>>24&255,r[0]>>16&255,r[0]>>8&255,255&r[0],r[1]>>24&255,r[1]>>16&255,r[1]>>8&255,255&r[1],r[2]>>24&255,r[2]>>16&255,r[2]>>8&255,255&r[2],r[3]>>24&255,r[3]>>16&255,r[3]>>8&255,255&r[3],r[4]>>24&255,r[4]>>16&255,r[4]>>8&255,255&r[4]]}));var b="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},v=[],_=[],E="undefined"!=typeof Uint8Array?Uint8Array:Array,S=!1;function x(){S=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)v[t]=e[t],_[e.charCodeAt(t)]=t;_["-".charCodeAt(0)]=62,_["_".charCodeAt(0)]=63}function A(e,t,r){for(var n,i,o=[],s=t;s>18&63]+v[i>>12&63]+v[i>>6&63]+v[63&i]);return o.join("")}function k(e){var t;S||x();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,c=r-n;ac?c:a+s));return 1===n?(t=e[r-1],i+=v[t>>2],i+=v[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=v[t>>10],i+=v[t>>4&63],i+=v[t<<2&63],i+="="),o.push(i),o.join("")}function I(e,t,r,n,i){var o,s,a=8*i-n-1,c=(1<>1,l=-7,h=r?i-1:0,f=r?-1:1,d=e[t+h];for(h+=f,o=d&(1<<-l)-1,d>>=-l,l+=a;l>0;o=256*o+e[t+h],h+=f,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=n;l>0;s=256*s+e[t+h],h+=f,l-=8);if(0===o)o=1-u;else{if(o===c)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=u}return(d?-1:1)*s*Math.pow(2,o-n)}function B(e,t,r,n,i,o){var s,a,c,u=8*o-i-1,l=(1<>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+h>=1?f/c:f*Math.pow(2,1-h))*c>=2&&(s++,c/=2),s+h>=l?(a=0,s=l):s+h>=1?(a=(t*c-1)*Math.pow(2,i),s+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,u-=8);e[r+d-p]|=128*g}var T={}.toString,R=Array.isArray||function(e){return"[object Array]"==T.call(e)};C.TYPED_ARRAY_SUPPORT=void 0===b.TYPED_ARRAY_SUPPORT||b.TYPED_ARRAY_SUPPORT;var O=M();function M(){return C.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function L(e,t){if(M()=M())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+M().toString(16)+" bytes");return 0|e}function z(e){return!(null==e||!e._isBuffer)}function D(e,t){if(z(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 r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return pe(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return ge(e).length;default:if(n)return pe(e).length;t=(""+t).toLowerCase(),n=!0}}function H(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return ne(this,t,r);case"utf8":case"utf-8":return Q(this,t,r);case"ascii":return te(this,t,r);case"latin1":case"binary":return re(this,t,r);case"base64":return X(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ie(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function q(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function F(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=C.from(t,n)),z(t))return 0===t.length?-1:K(e,t,r,n,i);if("number"==typeof t)return t&=255,C.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):K(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function K(e,t,r,n,i){var o,s=1,a=e.length,c=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,r/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var l=-1;for(o=r;oa&&(r=a-c),o=r;o>=0;o--){for(var h=!0,f=0;fi&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function X(e,t,r){return 0===t&&r===e.length?k(e):k(e.slice(t,r))}function Q(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:u>223?3:u>191?2:1;if(i+h<=r)switch(h){case 1:u<128&&(l=u);break;case 2:128==(192&(o=e[i+1]))&&(c=(31&u)<<6|63&o)>127&&(l=c);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(c=(15&u)<<12|(63&o)<<6|63&s)>2047&&(c<55296||c>57343)&&(l=c);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(c=(15&u)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(l=c)}null===l?(l=65533,h=1):l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|1023&l),n.push(l),i+=h}return function(e){var t=e.length;if(t<=ee)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},C.prototype.compare=function(e,t,r,n,i){if(!z(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),c=this.slice(n,i),u=e.slice(t,r),l=0;li)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return W(this,e,t,r);case"utf8":case"utf-8":return V(this,e,t,r);case"ascii":return Z(this,e,t,r);case"latin1":case"binary":return G(this,e,t,r);case"base64":return J(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Y(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},C.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var ee=4096;function te(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function se(e,t,r,n,i,o){if(!z(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function ae(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function ce(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function ue(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function le(e,t,r,n,i){return i||ue(e,0,r,4),B(e,t,r,n,23,4),r+4}function he(e,t,r,n,i){return i||ue(e,0,r,8),B(e,t,r,n,52,8),r+8}C.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},C.prototype.readUInt8=function(e,t){return t||oe(e,1,this.length),this[e]},C.prototype.readUInt16LE=function(e,t){return t||oe(e,2,this.length),this[e]|this[e+1]<<8},C.prototype.readUInt16BE=function(e,t){return t||oe(e,2,this.length),this[e]<<8|this[e+1]},C.prototype.readUInt32LE=function(e,t){return t||oe(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},C.prototype.readUInt32BE=function(e,t){return t||oe(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},C.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||oe(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},C.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||oe(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},C.prototype.readInt8=function(e,t){return t||oe(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},C.prototype.readInt16LE=function(e,t){t||oe(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},C.prototype.readInt16BE=function(e,t){t||oe(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},C.prototype.readInt32LE=function(e,t){return t||oe(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},C.prototype.readInt32BE=function(e,t){return t||oe(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},C.prototype.readFloatLE=function(e,t){return t||oe(e,4,this.length),I(this,e,!0,23,4)},C.prototype.readFloatBE=function(e,t){return t||oe(e,4,this.length),I(this,e,!1,23,4)},C.prototype.readDoubleLE=function(e,t){return t||oe(e,8,this.length),I(this,e,!0,52,8)},C.prototype.readDoubleBE=function(e,t){return t||oe(e,8,this.length),I(this,e,!1,52,8)},C.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||se(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},C.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||se(this,e,t,1,255,0),C.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},C.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||se(this,e,t,2,65535,0),C.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ae(this,e,t,!0),t+2},C.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||se(this,e,t,2,65535,0),C.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ae(this,e,t,!1),t+2},C.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||se(this,e,t,4,4294967295,0),C.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):ce(this,e,t,!0),t+4},C.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||se(this,e,t,4,4294967295,0),C.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ce(this,e,t,!1),t+4},C.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);se(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s|0)-a&255;return t+r},C.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||se(this,e,t,1,127,-128),C.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},C.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||se(this,e,t,2,32767,-32768),C.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ae(this,e,t,!0),t+2},C.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||se(this,e,t,2,32767,-32768),C.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ae(this,e,t,!1),t+2},C.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||se(this,e,t,4,2147483647,-2147483648),C.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):ce(this,e,t,!0),t+4},C.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||se(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),C.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ce(this,e,t,!1),t+4},C.prototype.writeFloatLE=function(e,t,r){return le(this,e,t,!0,r)},C.prototype.writeFloatBE=function(e,t,r){return le(this,e,t,!1,r)},C.prototype.writeDoubleLE=function(e,t,r){return he(this,e,t,!0,r)},C.prototype.writeDoubleBE=function(e,t,r){return he(this,e,t,!1,r)},C.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!C.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function ge(e){return function(e){var t,r,n,i,o,s;S||x();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new E(3*a/4-o),n=o>0?a-4:a;var c=0;for(t=0,r=0;t>16&255,s[c++]=i>>8&255,s[c++]=255&i;return 2===o?(i=_[e.charCodeAt(t)]<<2|_[e.charCodeAt(t+1)]>>4,s[c++]=255&i):1===o&&(i=_[e.charCodeAt(t)]<<10|_[e.charCodeAt(t+1)]<<4|_[e.charCodeAt(t+2)]>>2,s[c++]=i>>8&255,s[c++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(fe,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function ye(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function me(e){return null!=e&&(!!e._isBuffer||we(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&we(e.slice(0,0))}(e))}function we(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}var be=Object.freeze({__proto__:null,Buffer:C,INSPECT_MAX_BYTES:50,SlowBuffer:function(e){return+e!=e&&(e=0),C.alloc(+e)},isBuffer:me,kMaxLength:O});function ve(){}function _e(){_e.init.call(this)}function Ee(e){return void 0===e._maxListeners?_e.defaultMaxListeners:e._maxListeners}function Se(e,t,r,n){var i,o,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=e._events)?(o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]):(o=e._events=new ve,e._eventsCount=0),s){if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=Ee(e))&&i>0&&s.length>i){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=s.length,a=c,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function xe(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function Ae(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function ke(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}ve.prototype=Object.create(null),_e.EventEmitter=_e,_e.usingDomains=!1,_e.prototype.domain=void 0,_e.prototype._events=void 0,_e.prototype._maxListeners=void 0,_e.defaultMaxListeners=10,_e.init=function(){this.domain=null,_e.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new ve,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_e.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},_e.prototype.getMaxListeners=function(){return Ee(this)},_e.prototype.emit=function(e){var t,r,n,i,o,s,a,c="error"===e;if(s=this._events)c=c&&null==s.error;else if(!c)return!1;if(a=this.domain,c){if(t=arguments[1],!a){if(t instanceof Error)throw t;var u=new Error('Uncaught, unspecified "error" event. ('+t+")");throw u.context=t,u}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var l="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,i=ke(e,n),o=0;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new ve,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var Ie=Object.freeze({__proto__:null,default:_e,EventEmitter:_e});const Be="PROMISES",Te="CALLBACK";class Re{static isCallbackAdapterRequest(e){return void 0!==e.id}constructor(e){this.setStrategy(e)}setHandler(e){return this.handler=e,this}request(e,t){if(!this.handler)throw new Error("No handler defined for Adapter");return Re.isCallbackAdapterRequest(e)?this.handler({network:t,id:e.id,name:e.method,params:e.params,object:e.params}):this.handler({name:e.method,network:t,params:e.params,object:e.params})}setStrategy(e){return this.strategy=e,this}getStrategy(){return this.strategy}}var Oe=Object.defineProperty,Me=Object.defineProperties,Le=Object.getOwnPropertyDescriptors,Ce=Object.getOwnPropertySymbols,Pe=Object.prototype.hasOwnProperty,Ne=Object.prototype.propertyIsEnumerable,Ue=(e,t,r)=>t in e?Oe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;class je extends Re{constructor(){super(Te),this.callback=new Map}async request(e,t){return new Promise(((r,n)=>{const i=(new Date).getTime()+Math.floor(1e3*Math.random());this.callback.set(i.toString(),{reject:n,resolve:r}),super.request(((e,t)=>Me(e,Le(t)))(((e,t)=>{for(var r in t||(t={}))Pe.call(t,r)&&Ue(e,r,t[r]);if(Ce)for(var r of Ce(t))Ne.call(t,r)&&Ue(e,r,t[r]);return e})({},e),{id:i}),t)}))}sendResponse(e,t){if(this.callback.has(e.toString())){const r=this.callback.get(e.toString());this.callback.delete(e.toString()),r?.resolve(t)}else console.error(`Unable to find callback for requestId: ${e}`)}sendError(e,t){if(this.callback.has(e.toString())){const r=this.callback.get(e.toString());this.callback.delete(e.toString()),r?.reject(t)}else console.error(`Unable to find callback for requestId: ${e}`)}}class $e extends Re{constructor(){super(Be)}request(e,t){return super.request(e,t)}}class ze extends _e{setAdapter(e){return this.adapter=e,this}async request(e){try{if(!this.adapter)throw new Error("No adapter set, maybe you forgot to register the provider?");const t=await this.adapter.request(e,this.getNetwork());return this.emit("onResponseReady",e,t),t}catch(e){throw e}}sendResponse(e,t){if(!this.adapter)throw new Error("Adapter not found");if(this.adapter.getStrategy()!==Te)throw new Error("Trying to send callback request on promisified adapter");this.adapter.sendResponse(e,t)}sendError(e,t){if(!this.adapter)throw new Error("Adapter not found");if(this.adapter.getStrategy()!==Te)throw new Error("Trying to send callback request on promisified adapter");this.adapter.sendError(e,t)}}class De{constructor(e){const t=e.strategy===Te?new je:new $e;e.handler&&t.setHandler(e.handler),this.setAdapter(t)}setHandler(e){this.adapter.setHandler(e)}setAdapter(e){return this.adapter=e,this}registerProvider(e){return e.setAdapter(this.adapter),this}registerProviders(e){return e.forEach((e=>this.registerProvider(e))),this}sendResponse(e,t){"CALLBACK"===this.adapter.getStrategy()&&this.adapter.sendResponse(e,t)}sendError(e,t){"CALLBACK"===this.adapter.getStrategy()&&this.adapter.sendError(e,t)}}function He(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function qe(e,...t){if(!function(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function Fe(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}const Ke="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,We=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),Ve=(e,t)=>e<<32-t|e>>>t; -/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Ze(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}function Ge(e){return"string"==typeof e&&(e=Ze(e)),qe(e),e}function Je(...e){let t=0;for(let r=0;re().update(Ge(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function Qe(e=32){if(Ke&&"function"==typeof Ke.getRandomValues)return Ke.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}const et=(e,t,r)=>e&t^~e&r,tt=(e,t,r)=>e&t^e&r^t&r;class rt extends Ye{constructor(e,t,r,n){super(),this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=We(this.buffer)}update(e){Fe(this);const{view:t,buffer:r,blockLen:n}=this,i=(e=Ge(e)).length;for(let o=0;on-o&&(this.process(r,0),o=0);for(let e=o;e>i&o),a=Number(r&o),c=n?4:0,u=n?0:4;e.setUint32(t+c,s,n),e.setUint32(t+u,a,n)}(r,n-8,BigInt(8*this.length),i),this.process(r,0);const s=We(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,u=this.get();if(c>u.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e>it&nt)}:{h:0|Number(e>>it&nt),l:0|Number(e&nt)}}const st={fromBig:ot,split:function(e,t=!1){let r=new Uint32Array(e.length),n=new Uint32Array(e.length);for(let i=0;iBigInt(e>>>0)<>>0),shrSH:(e,t,r)=>e>>>r,shrSL:(e,t,r)=>e<<32-r|t>>>r,rotrSH:(e,t,r)=>e>>>r|t<<32-r,rotrSL:(e,t,r)=>e<<32-r|t>>>r,rotrBH:(e,t,r)=>e<<64-r|t>>>r-32,rotrBL:(e,t,r)=>e>>>r-32|t<<64-r,rotr32H:(e,t)=>t,rotr32L:(e,t)=>e,rotlSH:(e,t,r)=>e<>>32-r,rotlSL:(e,t,r)=>t<>>32-r,rotlBH:(e,t,r)=>t<>>64-r,rotlBL:(e,t,r)=>e<>>64-r,add:function(e,t,r,n){const i=(t>>>0)+(n>>>0);return{h:e+r+(i/2**32|0)|0,l:0|i}},add3L:(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),add3H:(e,t,r,n)=>t+r+n+(e/2**32|0)|0,add4L:(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),add4H:(e,t,r,n,i)=>t+r+n+i+(e/2**32|0)|0,add5H:(e,t,r,n,i,o)=>t+r+n+i+o+(e/2**32|0)|0,add5L:(e,t,r,n,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(i>>>0)},[at,ct]=(()=>st.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map((e=>BigInt(e)))))(),ut=new Uint32Array(80),lt=new Uint32Array(80);class ht extends rt{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:t,Bh:r,Bl:n,Ch:i,Cl:o,Dh:s,Dl:a,Eh:c,El:u,Fh:l,Fl:h,Gh:f,Gl:d,Hh:p,Hl:g}=this;return[e,t,r,n,i,o,s,a,c,u,l,h,f,d,p,g]}set(e,t,r,n,i,o,s,a,c,u,l,h,f,d,p,g){this.Ah=0|e,this.Al=0|t,this.Bh=0|r,this.Bl=0|n,this.Ch=0|i,this.Cl=0|o,this.Dh=0|s,this.Dl=0|a,this.Eh=0|c,this.El=0|u,this.Fh=0|l,this.Fl=0|h,this.Gh=0|f,this.Gl=0|d,this.Hh=0|p,this.Hl=0|g}process(e,t){for(let r=0;r<16;r++,t+=4)ut[r]=e.getUint32(t),lt[r]=e.getUint32(t+=4);for(let e=16;e<80;e++){const t=0|ut[e-15],r=0|lt[e-15],n=st.rotrSH(t,r,1)^st.rotrSH(t,r,8)^st.shrSH(t,r,7),i=st.rotrSL(t,r,1)^st.rotrSL(t,r,8)^st.shrSL(t,r,7),o=0|ut[e-2],s=0|lt[e-2],a=st.rotrSH(o,s,19)^st.rotrBH(o,s,61)^st.shrSH(o,s,6),c=st.rotrSL(o,s,19)^st.rotrBL(o,s,61)^st.shrSL(o,s,6),u=st.add4L(i,c,lt[e-7],lt[e-16]),l=st.add4H(u,n,a,ut[e-7],ut[e-16]);ut[e]=0|l,lt[e]=0|u}let{Ah:r,Al:n,Bh:i,Bl:o,Ch:s,Cl:a,Dh:c,Dl:u,Eh:l,El:h,Fh:f,Fl:d,Gh:p,Gl:g,Hh:y,Hl:m}=this;for(let e=0;e<80;e++){const t=st.rotrSH(l,h,14)^st.rotrSH(l,h,18)^st.rotrBH(l,h,41),w=st.rotrSL(l,h,14)^st.rotrSL(l,h,18)^st.rotrBL(l,h,41),b=l&f^~l&p,v=h&d^~h&g,_=st.add5L(m,w,v,ct[e],lt[e]),E=st.add5H(_,y,t,b,at[e],ut[e]),S=0|_,x=st.rotrSH(r,n,28)^st.rotrBH(r,n,34)^st.rotrBH(r,n,39),A=st.rotrSL(r,n,28)^st.rotrBL(r,n,34)^st.rotrBL(r,n,39),k=r&i^r&s^i&s,I=n&o^n&a^o&a;y=0|p,m=0|g,p=0|f,g=0|d,f=0|l,d=0|h,({h:l,l:h}=st.add(0|c,0|u,0|E,0|S)),c=0|s,u=0|a,s=0|i,a=0|o,i=0|r,o=0|n;const B=st.add3L(S,A,I);r=st.add3H(B,E,x,k),n=0|B}({h:r,l:n}=st.add(0|this.Ah,0|this.Al,0|r,0|n)),({h:i,l:o}=st.add(0|this.Bh,0|this.Bl,0|i,0|o)),({h:s,l:a}=st.add(0|this.Ch,0|this.Cl,0|s,0|a)),({h:c,l:u}=st.add(0|this.Dh,0|this.Dl,0|c,0|u)),({h:l,l:h}=st.add(0|this.Eh,0|this.El,0|l,0|h)),({h:f,l:d}=st.add(0|this.Fh,0|this.Fl,0|f,0|d)),({h:p,l:g}=st.add(0|this.Gh,0|this.Gl,0|p,0|g)),({h:y,l:m}=st.add(0|this.Hh,0|this.Hl,0|y,0|m)),this.set(r,n,i,o,s,a,c,u,l,h,f,d,p,g,y,m)}roundClean(){ut.fill(0),lt.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const ft=Xe((()=>new ht)),dt=BigInt(0),pt=BigInt(1),gt=BigInt(2); -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function yt(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}function mt(e){if(!yt(e))throw new Error("Uint8Array expected")}const wt=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function bt(e){mt(e);let t="";for(let r=0;r=Et&&e<=St?e-Et:e>=xt&&e<=At?e-(xt-10):e>=kt&&e<=It?e-(kt-10):void 0}function Tt(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,r=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(r);for(let t=0,i=0;t(gt<new Uint8Array(e),jt=e=>Uint8Array.from(e);function $t(e,t,r){if("number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof t||t<2)throw new Error("qByteLen must be a number");if("function"!=typeof r)throw new Error("hmacFn must be a function");let n=Ut(e),i=Ut(e),o=0;const s=()=>{n.fill(1),i.fill(0),o=0},a=(...e)=>r(i,n,...e),c=(e=Ut())=>{i=a(jt([0]),e),n=a(),0!==e.length&&(i=a(jt([1]),e),n=a())},u=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const r=[];for(;e{let r;for(s(),c(e);!(r=t(u()));)c();return s(),r}}const zt={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||yt(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)};function Dt(e,t,r={}){const n=(t,r,n)=>{const i=zt[r];if("function"!=typeof i)throw new Error(`Invalid validator "${r}", expected function`);const o=e[t];if(!(n&&void 0===o||i(o,e)))throw new Error(`Invalid param ${String(t)}=${o} (${typeof o}), expected ${r}`)};for(const[e,r]of Object.entries(t))n(e,r,!1);for(const[e,t]of Object.entries(r))n(e,t,!0);return e}var Ht=Object.freeze({__proto__:null,isBytes:yt,abytes:mt,bytesToHex:bt,numberToHexUnpadded:vt,hexToNumber:_t,hexToBytes:Tt,bytesToNumberBE:Rt,bytesToNumberLE:Ot,numberToBytesBE:Mt,numberToBytesLE:Lt,numberToVarBytesBE:function(e){return Tt(vt(e))},ensureBytes:Ct,concatBytes:Pt,equalBytes:function(e,t){if(e.length!==t.length)return!1;let r=0;for(let n=0;ndt;e>>=pt,t+=1);return t},bitGet:function(e,t){return e>>BigInt(t)&pt},bitSet:function(e,t,r){return e|(r?pt:dt)<=qt?r:t+r}function Yt(e,t,r){if(r<=qt||t 0");if(r===Ft)return qt;let n=Ft;for(;t>qt;)t&Ft&&(n=n*e%r),e=e*e%r,t>>=Ft;return n}function Xt(e,t,r){let n=e;for(;t-- >qt;)n*=n,n%=r;return n}function Qt(e,t){if(e===qt||t<=qt)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let r=Jt(e,t),n=t,i=qt,o=Ft;for(;r!==qt;){const e=n%r,t=i-o*(n/r);n=r,r=e,i=o,o=t}if(n!==Ft)throw new Error("invert: does not exist");return Jt(i,t)}function er(e){if(e%Vt===Wt){const t=(e+Ft)/Vt;return function(e,r){const n=e.pow(r,t);if(!e.eql(e.sqr(n),r))throw new Error("Cannot find square root");return n}}if(e%Gt===Zt){const t=(e-Zt)/Gt;return function(e,r){const n=e.mul(r,Kt),i=e.pow(n,t),o=e.mul(r,i),s=e.mul(e.mul(o,Kt),i),a=e.mul(o,e.sub(s,e.ONE));if(!e.eql(e.sqr(a),r))throw new Error("Cannot find square root");return a}}return function(e){const t=(e-Ft)/Kt;let r,n,i;for(r=e-Ft,n=0;r%Kt===qt;r/=Kt,n++);for(i=Kt;i 0, got ${e}`);const{nBitLength:i,nByteLength:o}=rr(e,t);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");const s=er(e),a=Object.freeze({ORDER:e,BITS:i,BYTES:o,MASK:Nt(i),ZERO:qt,ONE:Ft,create:t=>Jt(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("Invalid field element: expected bigint, got "+typeof t);return qt<=t&&te===qt,isOdd:e=>(e&Ft)===Ft,neg:t=>Jt(-t,e),eql:(e,t)=>e===t,sqr:t=>Jt(t*t,e),add:(t,r)=>Jt(t+r,e),sub:(t,r)=>Jt(t-r,e),mul:(t,r)=>Jt(t*r,e),pow:(e,t)=>function(e,t,r){if(r 0");if(r===qt)return e.ONE;if(r===Ft)return t;let n=e.ONE,i=t;for(;r>qt;)r&Ft&&(n=e.mul(n,i)),i=e.sqr(i),r>>=Ft;return n}(a,e,t),div:(t,r)=>Jt(t*Qt(r,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>Qt(t,e),sqrt:n.sqrt||(e=>s(a,e)),invertBatch:e=>function(e,t){const r=new Array(t.length),n=t.reduce(((t,n,i)=>e.is0(n)?t:(r[i]=t,e.mul(t,n))),e.ONE),i=e.inv(n);return t.reduceRight(((t,n,i)=>e.is0(n)?t:(r[i]=e.mul(t,r[i]),e.mul(t,n))),i),r}(a,e),cmov:(e,t,r)=>r?t:e,toBytes:e=>r?Lt(e,o):Mt(e,o),fromBytes:e=>{if(e.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${e.length}`);return r?Ot(e):Rt(e)}});return Object.freeze(a)}function ir(e){if("bigint"!=typeof e)throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function or(e){const t=ir(e);return t+Math.ceil(t/2)} +!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";let e;const t=new Uint8Array(16);function r(){if(!e&&(e="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!e))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return e(t)}var n=/^(?:[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;const i=[];for(let e=0;e<256;++e)i.push((e+256).toString(16).slice(1));function o(e,t=0){return i[e[t+0]]+i[e[t+1]]+i[e[t+2]]+i[e[t+3]]+"-"+i[e[t+4]]+i[e[t+5]]+"-"+i[e[t+6]]+i[e[t+7]]+"-"+i[e[t+8]]+i[e[t+9]]+"-"+i[e[t+10]]+i[e[t+11]]+i[e[t+12]]+i[e[t+13]]+i[e[t+14]]+i[e[t+15]]}function s(e){if(!function(e){return"string"==typeof e&&n.test(e)}(e))throw TypeError("Invalid UUID");let t;const r=new Uint8Array(16);return r[0]=(t=parseInt(e.slice(0,8),16))>>>24,r[1]=t>>>16&255,r[2]=t>>>8&255,r[3]=255&t,r[4]=(t=parseInt(e.slice(9,13),16))>>>8,r[5]=255&t,r[6]=(t=parseInt(e.slice(14,18),16))>>>8,r[7]=255&t,r[8]=(t=parseInt(e.slice(19,23),16))>>>8,r[9]=255&t,r[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,r[11]=t/4294967296&255,r[12]=t>>>24&255,r[13]=t>>>16&255,r[14]=t>>>8&255,r[15]=255&t,r}function a(e,t,r){function n(e,n,i,a){var c;if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));const t=[];for(let r=0;r>>9<<4)+1}function u(e,t){const r=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(r>>16)<<16|65535&r}function h(e,t,r,n,i,o){return u((s=u(u(t,e),u(n,o)))<<(a=i)|s>>>32-a,r);var s,a}function l(e,t,r,n,i,o,s){return h(t&r|~t&n,e,t,i,o,s)}function f(e,t,r,n,i,o,s){return h(t&n|r&~n,e,t,i,o,s)}function d(e,t,r,n,i,o,s){return h(t^r^n,e,t,i,o,s)}function p(e,t,r,n,i,o,s){return h(r^(t|~n),e,t,i,o,s)}a("v3",48,(function(e){if("string"==typeof e){const t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(let r=0;r>5]>>>i%32&255,o=parseInt(n.charAt(r>>>4&15)+n.charAt(15&r),16);t.push(o)}return t}(function(e,t){e[t>>5]|=128<>5]|=(255&e[n/8])<>>32-t}a("v5",80,(function(e){const t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof e){const t=unescape(encodeURIComponent(e));e=[];for(let r=0;r>>0;u=c,c=a,a=w(s,30)>>>0,s=i,i=o}r[0]=r[0]+i>>>0,r[1]=r[1]+s>>>0,r[2]=r[2]+a>>>0,r[3]=r[3]+c>>>0,r[4]=r[4]+u>>>0}return[r[0]>>24&255,r[0]>>16&255,r[0]>>8&255,255&r[0],r[1]>>24&255,r[1]>>16&255,r[1]>>8&255,255&r[1],r[2]>>24&255,r[2]>>16&255,r[2]>>8&255,255&r[2],r[3]>>24&255,r[3]>>16&255,r[3]>>8&255,255&r[3],r[4]>>24&255,r[4]>>16&255,r[4]>>8&255,255&r[4]]}));var b="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},v=[],_=[],E="undefined"!=typeof Uint8Array?Uint8Array:Array,S=!1;function A(){S=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)v[t]=e[t],_[e.charCodeAt(t)]=t;_["-".charCodeAt(0)]=62,_["_".charCodeAt(0)]=63}function x(e,t,r){for(var n,i,o=[],s=t;s>18&63]+v[i>>12&63]+v[i>>6&63]+v[63&i]);return o.join("")}function k(e){var t;S||A();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,c=r-n;ac?c:a+s));return 1===n?(t=e[r-1],i+=v[t>>2],i+=v[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=v[t>>10],i+=v[t>>4&63],i+=v[t<<2&63],i+="="),o.push(i),o.join("")}function B(e,t,r,n,i){var o,s,a=8*i-n-1,c=(1<>1,h=-7,l=r?i-1:0,f=r?-1:1,d=e[t+l];for(l+=f,o=d&(1<<-h)-1,d>>=-h,h+=a;h>0;o=256*o+e[t+l],l+=f,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=n;h>0;s=256*s+e[t+l],l+=f,h-=8);if(0===o)o=1-u;else{if(o===c)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=u}return(d?-1:1)*s*Math.pow(2,o-n)}function I(e,t,r,n,i,o){var s,a,c,u=8*o-i-1,h=(1<>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=h):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+l>=1?f/c:f*Math.pow(2,1-l))*c>=2&&(s++,c/=2),s+l>=h?(a=0,s=h):s+l>=1?(a=(t*c-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;e[r+d]=255&s,d+=p,s/=256,u-=8);e[r+d-p]|=128*g}var T={}.toString,R=Array.isArray||function(e){return"[object Array]"==T.call(e)};C.TYPED_ARRAY_SUPPORT=void 0===b.TYPED_ARRAY_SUPPORT||b.TYPED_ARRAY_SUPPORT;var O=L();function L(){return C.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function M(e,t){if(L()=L())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+L().toString(16)+" bytes");return 0|e}function H(e){return!(null==e||!e._isBuffer)}function z(e,t){if(H(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 r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return pe(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return ge(e).length;default:if(n)return pe(e).length;t=(""+t).toLowerCase(),n=!0}}function D(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return ne(this,t,r);case"utf8":case"utf-8":return Q(this,t,r);case"ascii":return te(this,t,r);case"latin1":case"binary":return re(this,t,r);case"base64":return X(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ie(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function F(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function q(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=C.from(t,n)),H(t))return 0===t.length?-1:K(e,t,r,n,i);if("number"==typeof t)return t&=255,C.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):K(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function K(e,t,r,n,i){var o,s=1,a=e.length,c=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,r/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var h=-1;for(o=r;oa&&(r=a-c),o=r;o>=0;o--){for(var l=!0,f=0;fi&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function X(e,t,r){return 0===t&&r===e.length?k(e):k(e.slice(t,r))}function Q(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:u>223?3:u>191?2:1;if(i+l<=r)switch(l){case 1:u<128&&(h=u);break;case 2:128==(192&(o=e[i+1]))&&(c=(31&u)<<6|63&o)>127&&(h=c);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(c=(15&u)<<12|(63&o)<<6|63&s)>2047&&(c<55296||c>57343)&&(h=c);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(c=(15&u)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(h=c)}null===h?(h=65533,l=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),i+=l}return function(e){var t=e.length;if(t<=ee)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},C.prototype.compare=function(e,t,r,n,i){if(!H(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),c=this.slice(n,i),u=e.slice(t,r),h=0;hi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return W(this,e,t,r);case"utf8":case"utf-8":return V(this,e,t,r);case"ascii":return Z(this,e,t,r);case"latin1":case"binary":return G(this,e,t,r);case"base64":return J(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Y(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},C.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var ee=4096;function te(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function se(e,t,r,n,i,o){if(!H(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function ae(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function ce(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function ue(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function he(e,t,r,n,i){return i||ue(e,0,r,4),I(e,t,r,n,23,4),r+4}function le(e,t,r,n,i){return i||ue(e,0,r,8),I(e,t,r,n,52,8),r+8}C.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},C.prototype.readUInt8=function(e,t){return t||oe(e,1,this.length),this[e]},C.prototype.readUInt16LE=function(e,t){return t||oe(e,2,this.length),this[e]|this[e+1]<<8},C.prototype.readUInt16BE=function(e,t){return t||oe(e,2,this.length),this[e]<<8|this[e+1]},C.prototype.readUInt32LE=function(e,t){return t||oe(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},C.prototype.readUInt32BE=function(e,t){return t||oe(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},C.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||oe(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},C.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||oe(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},C.prototype.readInt8=function(e,t){return t||oe(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},C.prototype.readInt16LE=function(e,t){t||oe(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},C.prototype.readInt16BE=function(e,t){t||oe(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},C.prototype.readInt32LE=function(e,t){return t||oe(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},C.prototype.readInt32BE=function(e,t){return t||oe(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},C.prototype.readFloatLE=function(e,t){return t||oe(e,4,this.length),B(this,e,!0,23,4)},C.prototype.readFloatBE=function(e,t){return t||oe(e,4,this.length),B(this,e,!1,23,4)},C.prototype.readDoubleLE=function(e,t){return t||oe(e,8,this.length),B(this,e,!0,52,8)},C.prototype.readDoubleBE=function(e,t){return t||oe(e,8,this.length),B(this,e,!1,52,8)},C.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||se(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},C.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||se(this,e,t,1,255,0),C.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},C.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||se(this,e,t,2,65535,0),C.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ae(this,e,t,!0),t+2},C.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||se(this,e,t,2,65535,0),C.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ae(this,e,t,!1),t+2},C.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||se(this,e,t,4,4294967295,0),C.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):ce(this,e,t,!0),t+4},C.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||se(this,e,t,4,4294967295,0),C.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ce(this,e,t,!1),t+4},C.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);se(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s|0)-a&255;return t+r},C.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||se(this,e,t,1,127,-128),C.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},C.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||se(this,e,t,2,32767,-32768),C.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):ae(this,e,t,!0),t+2},C.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||se(this,e,t,2,32767,-32768),C.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):ae(this,e,t,!1),t+2},C.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||se(this,e,t,4,2147483647,-2147483648),C.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):ce(this,e,t,!0),t+4},C.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||se(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),C.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ce(this,e,t,!1),t+4},C.prototype.writeFloatLE=function(e,t,r){return he(this,e,t,!0,r)},C.prototype.writeFloatBE=function(e,t,r){return he(this,e,t,!1,r)},C.prototype.writeDoubleLE=function(e,t,r){return le(this,e,t,!0,r)},C.prototype.writeDoubleBE=function(e,t,r){return le(this,e,t,!1,r)},C.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!C.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function ge(e){return function(e){var t,r,n,i,o,s;S||A();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new E(3*a/4-o),n=o>0?a-4:a;var c=0;for(t=0,r=0;t>16&255,s[c++]=i>>8&255,s[c++]=255&i;return 2===o?(i=_[e.charCodeAt(t)]<<2|_[e.charCodeAt(t+1)]>>4,s[c++]=255&i):1===o&&(i=_[e.charCodeAt(t)]<<10|_[e.charCodeAt(t+1)]<<4|_[e.charCodeAt(t+2)]>>2,s[c++]=i>>8&255,s[c++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(fe,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function ye(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function me(e){return null!=e&&(!!e._isBuffer||we(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&we(e.slice(0,0))}(e))}function we(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}var be=Object.freeze({__proto__:null,Buffer:C,INSPECT_MAX_BYTES:50,SlowBuffer:function(e){return+e!=e&&(e=0),C.alloc(+e)},isBuffer:me,kMaxLength:O});function ve(){}function _e(){_e.init.call(this)}function Ee(e){return void 0===e._maxListeners?_e.defaultMaxListeners:e._maxListeners}function Se(e,t,r,n){var i,o,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=e._events)?(o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]):(o=e._events=new ve,e._eventsCount=0),s){if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=Ee(e))&&i>0&&s.length>i){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=s.length,a=c,"function"==typeof console.warn?console.warn(a):console.log(a)}}else s=o[t]=r,++e._eventsCount;return e}function Ae(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function xe(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function ke(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}ve.prototype=Object.create(null),_e.EventEmitter=_e,_e.usingDomains=!1,_e.prototype.domain=void 0,_e.prototype._events=void 0,_e.prototype._maxListeners=void 0,_e.defaultMaxListeners=10,_e.init=function(){this.domain=null,_e.usingDomains&&undefined.active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new ve,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_e.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},_e.prototype.getMaxListeners=function(){return Ee(this)},_e.prototype.emit=function(e){var t,r,n,i,o,s,a,c="error"===e;if(s=this._events)c=c&&null==s.error;else if(!c)return!1;if(a=this.domain,c){if(t=arguments[1],!a){if(t instanceof Error)throw t;var u=new Error('Uncaught, unspecified "error" event. ('+t+")");throw u.context=t,u}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(r=s[e]))return!1;var h="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,i=ke(e,n),o=0;o0;)if(r[o]===t||r[o].listener&&r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new ve,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n0?Reflect.ownKeys(this._events):[]};var Be=Object.freeze({__proto__:null,default:_e,EventEmitter:_e});const Ie="PROMISES",Te="CALLBACK";class Re{static isCallbackAdapterRequest(e){return void 0!==e.id}constructor(e){this.setStrategy(e)}setHandler(e){return this.handler=e,this}request(e,t){if(!this.handler)throw new Error("No handler defined for Adapter");return Re.isCallbackAdapterRequest(e)?this.handler({network:t,id:e.id,name:e.method,params:e.params,object:e.params}):this.handler({name:e.method,network:t,params:e.params,object:e.params})}setStrategy(e){return this.strategy=e,this}getStrategy(){return this.strategy}}var Oe=Object.defineProperty,Le=Object.defineProperties,Me=Object.getOwnPropertyDescriptors,Ce=Object.getOwnPropertySymbols,Pe=Object.prototype.hasOwnProperty,Ne=Object.prototype.propertyIsEnumerable,Ue=(e,t,r)=>t in e?Oe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;class je extends Re{constructor(){super(Te),this.callback=new Map}async request(e,t){return new Promise(((r,n)=>{const i=(new Date).getTime()+Math.floor(1e3*Math.random());this.callback.set(i.toString(),{reject:n,resolve:r}),super.request(((e,t)=>Le(e,Me(t)))(((e,t)=>{for(var r in t||(t={}))Pe.call(t,r)&&Ue(e,r,t[r]);if(Ce)for(var r of Ce(t))Ne.call(t,r)&&Ue(e,r,t[r]);return e})({},e),{id:i}),t)}))}sendResponse(e,t){if(this.callback.has(e.toString())){const r=this.callback.get(e.toString());this.callback.delete(e.toString()),r?.resolve(t)}else console.error(`Unable to find callback for requestId: ${e}`)}sendError(e,t){if(this.callback.has(e.toString())){const r=this.callback.get(e.toString());this.callback.delete(e.toString()),r?.reject(t)}else console.error(`Unable to find callback for requestId: ${e}`)}}class $e extends Re{constructor(){super(Ie)}request(e,t){return super.request(e,t)}}class He extends _e{setAdapter(e){return this.adapter=e,this}async request(e){try{if(!this.adapter)throw new Error("No adapter set, maybe you forgot to register the provider?");const t=await this.adapter.request(e,this.getNetwork());return this.emit("onResponseReady",e,t),t}catch(e){throw e}}sendResponse(e,t){if(!this.adapter)throw new Error("Adapter not found");if(this.adapter.getStrategy()!==Te)throw new Error("Trying to send callback request on promisified adapter");this.adapter.sendResponse(e,t)}sendError(e,t){if(!this.adapter)throw new Error("Adapter not found");if(this.adapter.getStrategy()!==Te)throw new Error("Trying to send callback request on promisified adapter");this.adapter.sendError(e,t)}}class ze{constructor(e){const t=e.strategy===Te?new je:new $e;e.handler&&t.setHandler(e.handler),this.setAdapter(t)}setHandler(e){this.adapter.setHandler(e)}setAdapter(e){return this.adapter=e,this}registerProvider(e){return e.setAdapter(this.adapter),this}registerProviders(e){return e.forEach((e=>this.registerProvider(e))),this}sendResponse(e,t){"CALLBACK"===this.adapter.getStrategy()&&this.adapter.sendResponse(e,t)}sendError(e,t){"CALLBACK"===this.adapter.getStrategy()&&this.adapter.sendError(e,t)}}function De(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function Fe(e,...t){if(!function(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function qe(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}const Ke="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,We=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),Ve=(e,t)=>e<<32-t|e>>>t; +/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Ze(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(e)),Fe(e),e}new Uint8Array(new Uint32Array([287454020]).buffer)[0];class Ge{clone(){return this._cloneInto()}}function Je(e){const t=t=>e().update(Ze(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function Ye(e=32){if(Ke&&"function"==typeof Ke.getRandomValues)return Ke.getRandomValues(new Uint8Array(e));if(Ke&&"function"==typeof Ke.randomBytes)return Ke.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")}const Xe=(e,t,r)=>e&t^~e&r,Qe=(e,t,r)=>e&t^e&r^t&r;class et extends Ge{constructor(e,t,r,n){super(),this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=We(this.buffer)}update(e){qe(this);const{view:t,buffer:r,blockLen:n}=this,i=(e=Ze(e)).length;for(let o=0;on-o&&(this.process(r,0),o=0);for(let e=o;e>i&o),a=Number(r&o),c=n?4:0,u=n?0:4;e.setUint32(t+c,s,n),e.setUint32(t+u,a,n)}(r,n-8,BigInt(8*this.length),i),this.process(r,0);const s=We(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,u=this.get();if(c>u.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e>rt&tt)}:{h:0|Number(e>>rt&tt),l:0|Number(e&tt)}}const it={fromBig:nt,split:function(e,t=!1){let r=new Uint32Array(e.length),n=new Uint32Array(e.length);for(let i=0;iBigInt(e>>>0)<>>0),shrSH:(e,t,r)=>e>>>r,shrSL:(e,t,r)=>e<<32-r|t>>>r,rotrSH:(e,t,r)=>e>>>r|t<<32-r,rotrSL:(e,t,r)=>e<<32-r|t>>>r,rotrBH:(e,t,r)=>e<<64-r|t>>>r-32,rotrBL:(e,t,r)=>e>>>r-32|t<<64-r,rotr32H:(e,t)=>t,rotr32L:(e,t)=>e,rotlSH:(e,t,r)=>e<>>32-r,rotlSL:(e,t,r)=>t<>>32-r,rotlBH:(e,t,r)=>t<>>64-r,rotlBL:(e,t,r)=>e<>>64-r,add:function(e,t,r,n){const i=(t>>>0)+(n>>>0);return{h:e+r+(i/2**32|0)|0,l:0|i}},add3L:(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),add3H:(e,t,r,n)=>t+r+n+(e/2**32|0)|0,add4L:(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),add4H:(e,t,r,n,i)=>t+r+n+i+(e/2**32|0)|0,add5H:(e,t,r,n,i,o)=>t+r+n+i+o+(e/2**32|0)|0,add5L:(e,t,r,n,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(i>>>0)},[ot,st]=(()=>it.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map((e=>BigInt(e)))))(),at=new Uint32Array(80),ct=new Uint32Array(80);class ut extends et{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:t,Bh:r,Bl:n,Ch:i,Cl:o,Dh:s,Dl:a,Eh:c,El:u,Fh:h,Fl:l,Gh:f,Gl:d,Hh:p,Hl:g}=this;return[e,t,r,n,i,o,s,a,c,u,h,l,f,d,p,g]}set(e,t,r,n,i,o,s,a,c,u,h,l,f,d,p,g){this.Ah=0|e,this.Al=0|t,this.Bh=0|r,this.Bl=0|n,this.Ch=0|i,this.Cl=0|o,this.Dh=0|s,this.Dl=0|a,this.Eh=0|c,this.El=0|u,this.Fh=0|h,this.Fl=0|l,this.Gh=0|f,this.Gl=0|d,this.Hh=0|p,this.Hl=0|g}process(e,t){for(let r=0;r<16;r++,t+=4)at[r]=e.getUint32(t),ct[r]=e.getUint32(t+=4);for(let e=16;e<80;e++){const t=0|at[e-15],r=0|ct[e-15],n=it.rotrSH(t,r,1)^it.rotrSH(t,r,8)^it.shrSH(t,r,7),i=it.rotrSL(t,r,1)^it.rotrSL(t,r,8)^it.shrSL(t,r,7),o=0|at[e-2],s=0|ct[e-2],a=it.rotrSH(o,s,19)^it.rotrBH(o,s,61)^it.shrSH(o,s,6),c=it.rotrSL(o,s,19)^it.rotrBL(o,s,61)^it.shrSL(o,s,6),u=it.add4L(i,c,ct[e-7],ct[e-16]),h=it.add4H(u,n,a,at[e-7],at[e-16]);at[e]=0|h,ct[e]=0|u}let{Ah:r,Al:n,Bh:i,Bl:o,Ch:s,Cl:a,Dh:c,Dl:u,Eh:h,El:l,Fh:f,Fl:d,Gh:p,Gl:g,Hh:y,Hl:m}=this;for(let e=0;e<80;e++){const t=it.rotrSH(h,l,14)^it.rotrSH(h,l,18)^it.rotrBH(h,l,41),w=it.rotrSL(h,l,14)^it.rotrSL(h,l,18)^it.rotrBL(h,l,41),b=h&f^~h&p,v=l&d^~l&g,_=it.add5L(m,w,v,st[e],ct[e]),E=it.add5H(_,y,t,b,ot[e],at[e]),S=0|_,A=it.rotrSH(r,n,28)^it.rotrBH(r,n,34)^it.rotrBH(r,n,39),x=it.rotrSL(r,n,28)^it.rotrBL(r,n,34)^it.rotrBL(r,n,39),k=r&i^r&s^i&s,B=n&o^n&a^o&a;y=0|p,m=0|g,p=0|f,g=0|d,f=0|h,d=0|l,({h:h,l:l}=it.add(0|c,0|u,0|E,0|S)),c=0|s,u=0|a,s=0|i,a=0|o,i=0|r,o=0|n;const I=it.add3L(S,x,B);r=it.add3H(I,E,A,k),n=0|I}({h:r,l:n}=it.add(0|this.Ah,0|this.Al,0|r,0|n)),({h:i,l:o}=it.add(0|this.Bh,0|this.Bl,0|i,0|o)),({h:s,l:a}=it.add(0|this.Ch,0|this.Cl,0|s,0|a)),({h:c,l:u}=it.add(0|this.Dh,0|this.Dl,0|c,0|u)),({h:h,l:l}=it.add(0|this.Eh,0|this.El,0|h,0|l)),({h:f,l:d}=it.add(0|this.Fh,0|this.Fl,0|f,0|d)),({h:p,l:g}=it.add(0|this.Gh,0|this.Gl,0|p,0|g)),({h:y,l:m}=it.add(0|this.Hh,0|this.Hl,0|y,0|m)),this.set(r,n,i,o,s,a,c,u,h,l,f,d,p,g,y,m)}roundClean(){at.fill(0),ct.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const ht=Je((()=>new ut)),lt=BigInt(0),ft=BigInt(1),dt=BigInt(2); +/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function pt(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}function gt(e){if(!pt(e))throw new Error("Uint8Array expected")}function yt(e,t){if("boolean"!=typeof t)throw new Error(`${e} must be valid boolean, got "${t}".`)}const mt=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function wt(e){gt(e);let t="";for(let r=0;r=_t&&e<=Et?e-_t:e>=St&&e<=At?e-(St-10):e>=xt&&e<=kt?e-(xt-10):void 0}function It(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,r=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(r);for(let t=0,i=0;t"bigint"==typeof e&<<=e;function Nt(e,t,r){return Pt(e)&&Pt(t)&&Pt(r)&&t<=e&&elt;e>>=ft,t+=1);return t}const $t=e=>(dt<new Uint8Array(e),zt=e=>Uint8Array.from(e);function Dt(e,t,r){if("number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof t||t<2)throw new Error("qByteLen must be a number");if("function"!=typeof r)throw new Error("hmacFn must be a function");let n=Ht(e),i=Ht(e),o=0;const s=()=>{n.fill(1),i.fill(0),o=0},a=(...e)=>r(i,n,...e),c=(e=Ht())=>{i=a(zt([0]),e),n=a(),0!==e.length&&(i=a(zt([1]),e),n=a())},u=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const r=[];for(;e{let r;for(s(),c(e);!(r=t(u()));)c();return s(),r}}const Ft={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||pt(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)};function qt(e,t,r={}){const n=(t,r,n)=>{const i=Ft[r];if("function"!=typeof i)throw new Error(`Invalid validator "${r}", expected function`);const o=e[t];if(!(n&&void 0===o||i(o,e)))throw new Error(`Invalid param ${String(t)}=${o} (${typeof o}), expected ${r}`)};for(const[e,r]of Object.entries(t))n(e,r,!1);for(const[e,t]of Object.entries(r))n(e,t,!0);return e}function Kt(e){const t=new WeakMap;return(r,...n)=>{const i=t.get(r);if(void 0!==i)return i;const o=e(r,...n);return t.set(r,o),o}}var Wt=Object.freeze({__proto__:null,isBytes:pt,abytes:gt,abool:yt,bytesToHex:wt,numberToHexUnpadded:bt,hexToNumber:vt,hexToBytes:It,bytesToNumberBE:Tt,bytesToNumberLE:Rt,numberToBytesBE:Ot,numberToBytesLE:Lt,numberToVarBytesBE:function(e){return It(bt(e))},ensureBytes:Mt,concatBytes:Ct,equalBytes:function(e,t){if(e.length!==t.length)return!1;let r=0;for(let n=0;n>BigInt(t)&ft},bitSet:function(e,t,r){return e|(r?ft:lt)<{throw new Error("not implemented")},memoized:Kt}); +/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Vt=BigInt(0),Zt=BigInt(1),Gt=BigInt(2),Jt=BigInt(3),Yt=BigInt(4),Xt=BigInt(5),Qt=BigInt(8);function er(e,t){const r=e%t;return r>=Vt?r:t+r}function tr(e,t,r){if(r<=Vt||t 0");if(r===Zt)return Vt;let n=Zt;for(;t>Vt;)t&Zt&&(n=n*e%r),e=e*e%r,t>>=Zt;return n}function rr(e,t,r){let n=e;for(;t-- >Vt;)n*=n,n%=r;return n}function nr(e,t){if(e===Vt||t<=Vt)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let r=er(e,t),n=t,i=Vt,o=Zt;for(;r!==Vt;){const e=n%r,t=i-o*(n/r);n=r,r=e,i=o,o=t}if(n!==Zt)throw new Error("invert: does not exist");return er(i,t)}function ir(e){if(e%Yt===Jt){const t=(e+Zt)/Yt;return function(e,r){const n=e.pow(r,t);if(!e.eql(e.sqr(n),r))throw new Error("Cannot find square root");return n}}if(e%Qt===Xt){const t=(e-Xt)/Qt;return function(e,r){const n=e.mul(r,Gt),i=e.pow(n,t),o=e.mul(r,i),s=e.mul(e.mul(o,Gt),i),a=e.mul(o,e.sub(s,e.ONE));if(!e.eql(e.sqr(a),r))throw new Error("Cannot find square root");return a}}return function(e){const t=(e-Zt)/Gt;let r,n,i;for(r=e-Zt,n=0;r%Gt===Vt;r/=Gt,n++);for(i=Gt;i 0, got ${e}`);const{nBitLength:i,nByteLength:o}=sr(e,t);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");const s=ir(e),a=Object.freeze({ORDER:e,BITS:i,BYTES:o,MASK:$t(i),ZERO:Vt,ONE:Zt,create:t=>er(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("Invalid field element: expected bigint, got "+typeof t);return Vt<=t&&te===Vt,isOdd:e=>(e&Zt)===Zt,neg:t=>er(-t,e),eql:(e,t)=>e===t,sqr:t=>er(t*t,e),add:(t,r)=>er(t+r,e),sub:(t,r)=>er(t-r,e),mul:(t,r)=>er(t*r,e),pow:(e,t)=>function(e,t,r){if(r 0");if(r===Vt)return e.ONE;if(r===Zt)return t;let n=e.ONE,i=t;for(;r>Vt;)r&Zt&&(n=e.mul(n,i)),i=e.sqr(i),r>>=Zt;return n}(a,e,t),div:(t,r)=>er(t*nr(r,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>nr(t,e),sqrt:n.sqrt||(e=>s(a,e)),invertBatch:e=>function(e,t){const r=new Array(t.length),n=t.reduce(((t,n,i)=>e.is0(n)?t:(r[i]=t,e.mul(t,n))),e.ONE),i=e.inv(n);return t.reduceRight(((t,n,i)=>e.is0(n)?t:(r[i]=e.mul(t,r[i]),e.mul(t,n))),i),r}(a,e),cmov:(e,t,r)=>r?t:e,toBytes:e=>r?Lt(e,o):Ot(e,o),fromBytes:e=>{if(e.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${e.length}`);return r?Rt(e):Tt(e)}});return Object.freeze(a)}function cr(e){if("bigint"!=typeof e)throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function ur(e){const t=cr(e);return t+Math.ceil(t/2)} /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -const sr=BigInt(0),ar=BigInt(1);function cr(e,t){const r=(e,t)=>{const r=t.negate();return e?r:t},n=e=>({windows:Math.ceil(t/e)+1,windowSize:2**(e-1)});return{constTimeNegate:r,unsafeLadder(t,r){let n=e.ZERO,i=t;for(;r>sr;)r&ar&&(n=n.add(i)),i=i.double(),r>>=ar;return n},precomputeWindow(e,t){const{windows:r,windowSize:i}=n(t),o=[];let s=e,a=s;for(let e=0;e>=f,n>a&&(n-=h,o+=ar);const s=t,d=t+Math.abs(n)-1,p=e%2!=0,g=n<0;0===n?u=u.add(r(p,i[s])):c=c.add(r(g,i[d]))}return{p:c,f:u}},wNAFCached(e,t,r,n){const i=e._WINDOW_SIZE||1;let o=t.get(e);return o||(o=this.precomputeWindow(e,i),1!==i&&t.set(e,n(o))),this.wNAF(i,o,r)}}}function ur(e){return function(e){const t=tr.reduce(((e,t)=>(e[t]="function",e)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"});Dt(e,t)}(e.Fp),Dt(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...rr(e.n,e.nBitLength),...e,p:e.Fp.ORDER})} -/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const lr=BigInt(0),hr=BigInt(1),fr=BigInt(2),dr=BigInt(8),pr={zip215:!0};function gr(e){const t=function(e){const t=ur(e);return Dt(e,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}(e),{Fp:r,n:n,prehash:i,hash:o,randomBytes:s,nByteLength:a,h:c}=t,u=fr<{try{return{isValid:!0,value:r.sqrt(e*r.inv(t))}}catch(e){return{isValid:!1,value:lr}}}),f=t.adjustScalarBytes||(e=>e),d=t.domain||((e,t,r)=>{if(t.length||r)throw new Error("Contexts/pre-hash are not supported");return e}),p=e=>"bigint"==typeof e&&lrp(e)&&p(t)&&ee===lr||g(e,u);function m(e,t){if(g(e,t))return e;throw new Error(`Expected valid scalar < ${t}, got ${typeof e} ${e}`)}function w(e){return e===lr?e:m(e,n)}const b=new Map;function v(e){if(!(e instanceof _))throw new Error("ExtendedPoint expected")}class _{constructor(e,t,r,n){if(this.ex=e,this.ey=t,this.ez=r,this.et=n,!y(e))throw new Error("x required");if(!y(t))throw new Error("y required");if(!y(r))throw new Error("z required");if(!y(n))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(e){if(e instanceof _)throw new Error("extended point not allowed");const{x:t,y:r}=e||{};if(!y(t)||!y(r))throw new Error("invalid affine point");return new _(t,r,hr,l(t*r))}static normalizeZ(e){const t=r.invertBatch(e.map((e=>e.ez)));return e.map(((e,r)=>e.toAffine(t[r]))).map(_.fromAffine)}_setWindowSize(e){this._WINDOW_SIZE=e,b.delete(this)}assertValidity(){const{a:e,d:r}=t;if(this.is0())throw new Error("bad point: ZERO");const{ex:n,ey:i,ez:o,et:s}=this,a=l(n*n),c=l(i*i),u=l(o*o),h=l(u*u),f=l(a*e);if(l(u*l(f+c))!==l(h+l(r*l(a*c))))throw new Error("bad point: equation left != right (1)");if(l(n*i)!==l(o*s))throw new Error("bad point: equation left != right (2)")}equals(e){v(e);const{ex:t,ey:r,ez:n}=this,{ex:i,ey:o,ez:s}=e,a=l(t*s),c=l(i*n),u=l(r*s),h=l(o*n);return a===c&&u===h}is0(){return this.equals(_.ZERO)}negate(){return new _(l(-this.ex),this.ey,this.ez,l(-this.et))}double(){const{a:e}=t,{ex:r,ey:n,ez:i}=this,o=l(r*r),s=l(n*n),a=l(fr*l(i*i)),c=l(e*o),u=r+n,h=l(l(u*u)-o-s),f=c+s,d=f-a,p=c-s,g=l(h*d),y=l(f*p),m=l(h*p),w=l(d*f);return new _(g,y,w,m)}add(e){v(e);const{a:r,d:n}=t,{ex:i,ey:o,ez:s,et:a}=this,{ex:c,ey:u,ez:h,et:f}=e;if(r===BigInt(-1)){const e=l((o-i)*(u+c)),t=l((o+i)*(u-c)),r=l(t-e);if(r===lr)return this.double();const n=l(s*fr*f),d=l(a*fr*h),p=d+n,g=t+e,y=d-n,m=l(p*r),w=l(g*y),b=l(p*y),v=l(r*g);return new _(m,w,v,b)}const d=l(i*c),p=l(o*u),g=l(a*n*f),y=l(s*h),m=l((i+o)*(c+u)-d-p),w=y-g,b=y+g,E=l(p-r*d),S=l(m*w),x=l(b*E),A=l(m*E),k=l(w*b);return new _(S,x,k,A)}subtract(e){return this.add(e.negate())}wNAF(e){return x.wNAFCached(this,b,e,_.normalizeZ)}multiply(e){const{p:t,f:r}=this.wNAF(m(e,n));return _.normalizeZ([t,r])[0]}multiplyUnsafe(e){let t=w(e);return t===lr?S:this.equals(S)||t===hr?this:this.equals(E)?this.wNAF(t).p:x.unsafeLadder(this,t)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return x.unsafeLadder(this,n).is0()}toAffine(e){const{ex:t,ey:n,ez:i}=this,o=this.is0();null==e&&(e=o?dr:r.inv(i));const s=l(t*e),a=l(n*e),c=l(i*e);if(o)return{x:lr,y:hr};if(c!==hr)throw new Error("invZ was invalid");return{x:s,y:a}}clearCofactor(){const{h:e}=t;return e===hr?this:this.multiplyUnsafe(e)}static fromHex(e,n=!1){const{d:i,a:o}=t,s=r.BYTES,a=(e=Ct("pointHex",e,s)).slice(),c=e[s-1];a[s-1]=-129&c;const f=Ot(a);f===lr||m(f,n?u:r.ORDER);const d=l(f*f),p=l(d-hr),g=l(i*d-o);let{isValid:y,value:w}=h(p,g);if(!y)throw new Error("Point.fromHex: invalid y coordinate");const b=(w&hr)===hr,v=!!(128&c);if(!n&&w===lr&&v)throw new Error("Point.fromHex: x=0 and x_0=1");return v!==b&&(w=l(-w)),_.fromAffine({x:w,y:f})}static fromPrivateKey(e){return I(e).point}toRawBytes(){const{x:e,y:t}=this.toAffine(),n=Lt(t,r.BYTES);return n[n.length-1]|=e&hr?128:0,n}toHex(){return bt(this.toRawBytes())}}_.BASE=new _(t.Gx,t.Gy,hr,l(t.Gx*t.Gy)),_.ZERO=new _(lr,hr,hr,lr);const{BASE:E,ZERO:S}=_,x=cr(_,8*a);function A(e){return Jt(e,n)}function k(e){return A(Ot(e))}function I(e){const t=a;e=Ct("private key",e,t);const r=Ct("hashed private key",o(e),2*t),n=f(r.slice(0,t)),i=r.slice(t,2*t),s=k(n),c=E.multiply(s),u=c.toRawBytes();return{head:n,prefix:i,scalar:s,point:c,pointBytes:u}}function B(e=new Uint8Array,...t){const r=Pt(...t);return k(o(d(r,Ct("context",e),!!i)))}const T=pr;E._setWindowSize(8);return{CURVE:t,getPublicKey:function(e){return I(e).pointBytes},sign:function(e,t,n={}){e=Ct("message",e),i&&(e=i(e));const{prefix:o,scalar:s,pointBytes:c}=I(t),u=B(n.context,o,e),l=E.multiply(u).toRawBytes(),h=A(u+B(n.context,l,c,e)*s);return w(h),Ct("result",Pt(l,Lt(h,r.BYTES)),2*a)},verify:function(e,t,n,o=T){const{context:s,zip215:a}=o,c=r.BYTES;e=Ct("signature",e,2*c),t=Ct("message",t),i&&(t=i(t));const u=Ot(e.slice(c,2*c));let l,h,f;try{l=_.fromHex(n,a),h=_.fromHex(e.slice(0,c),a),f=E.multiplyUnsafe(u)}catch(e){return!1}if(!a&&l.isSmallOrder())return!1;const d=B(s,h.toRawBytes(),l.toRawBytes(),t);return h.add(l.multiplyUnsafe(d)).subtract(f).clearCofactor().equals(_.ZERO)},ExtendedPoint:_,utils:{getExtendedPublicKey:I,randomPrivateKey:()=>s(r.BYTES),precompute:(e=8,t=_.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)}}} +const hr=BigInt(0),lr=BigInt(1),fr=new WeakMap,dr=new WeakMap;function pr(e,t){const r=(e,t)=>{const r=t.negate();return e?r:t},n=e=>{if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error(`Wrong window size=${e}, should be [1..${t}]`)},i=e=>{n(e);return{windows:Math.ceil(t/e)+1,windowSize:2**(e-1)}};return{constTimeNegate:r,unsafeLadder(t,r){let n=e.ZERO,i=t;for(;r>hr;)r&lr&&(n=n.add(i)),i=i.double(),r>>=lr;return n},precomputeWindow(e,t){const{windows:r,windowSize:n}=i(t),o=[];let s=e,a=s;for(let e=0;e>=f,i>a&&(i-=l,o+=lr);const s=t,d=t+Math.abs(i)-1,p=e%2!=0,g=i<0;0===i?u=u.add(r(p,n[s])):c=c.add(r(g,n[d]))}return{p:c,f:u}},wNAFCached(e,t,r){const n=dr.get(e)||1;let i=fr.get(e);return i||(i=this.precomputeWindow(e,n),1!==n&&fr.set(e,r(i))),this.wNAF(n,i,t)},setWindowSize(e,t){n(t),dr.set(e,t),fr.delete(e)}}}function gr(e,t,r,n){if(!Array.isArray(r)||!Array.isArray(n)||n.length!==r.length)throw new Error("arrays of points and scalars must have equal length");n.forEach(((e,r)=>{if(!t.isValid(e))throw new Error(`wrong scalar at index ${r}`)})),r.forEach(((t,r)=>{if(!(t instanceof e))throw new Error(`wrong point at index ${r}`)}));const i=jt(BigInt(r.length)),o=i>12?i-3:i>4?i-2:i?2:1,s=(1<=0;t-=o){a.fill(e.ZERO);for(let e=0;e>BigInt(t)&BigInt(s));a[o]=a[o].add(r[e])}let i=e.ZERO;for(let t=a.length-1,r=e.ZERO;t>0;t--)r=r.add(a[t]),i=i.add(r);if(u=u.add(i),0!==t)for(let e=0;e(e[t]="function",e)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"});qt(e,t)}(e.Fp),qt(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...sr(e.n,e.nBitLength),...e,p:e.Fp.ORDER})} +/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const mr=BigInt(0),wr=BigInt(1),br=BigInt(2),vr=BigInt(8),_r={zip215:!0};function Er(e){const t=function(e){const t=yr(e);return qt(e,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}(e),{Fp:r,n:n,prehash:i,hash:o,randomBytes:s,nByteLength:a,h:c}=t,u=br<{try{return{isValid:!0,value:r.sqrt(e*r.inv(t))}}catch(e){return{isValid:!1,value:mr}}}),d=t.adjustScalarBytes||(e=>e),p=t.domain||((e,t,r)=>{if(yt("phflag",r),t.length||r)throw new Error("Contexts/pre-hash are not supported");return e});function g(e,t){Ut("coordinate "+e,t,mr,u)}function y(e){if(!(e instanceof b))throw new Error("ExtendedPoint expected")}const m=Kt(((e,t)=>{const{ex:n,ey:i,ez:o}=e,s=e.is0();null==t&&(t=s?vr:r.inv(o));const a=h(n*t),c=h(i*t),u=h(o*t);if(s)return{x:mr,y:wr};if(u!==wr)throw new Error("invZ was invalid");return{x:a,y:c}})),w=Kt((e=>{const{a:r,d:n}=t;if(e.is0())throw new Error("bad point: ZERO");const{ex:i,ey:o,ez:s,et:a}=e,c=h(i*i),u=h(o*o),l=h(s*s),f=h(l*l),d=h(c*r);if(h(l*h(d+u))!==h(f+h(n*h(c*u))))throw new Error("bad point: equation left != right (1)");if(h(i*o)!==h(s*a))throw new Error("bad point: equation left != right (2)");return!0}));class b{constructor(e,t,r,n){this.ex=e,this.ey=t,this.ez=r,this.et=n,g("x",e),g("y",t),g("z",r),g("t",n),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(e){if(e instanceof b)throw new Error("extended point not allowed");const{x:t,y:r}=e||{};return g("x",t),g("y",r),new b(t,r,wr,h(t*r))}static normalizeZ(e){const t=r.invertBatch(e.map((e=>e.ez)));return e.map(((e,r)=>e.toAffine(t[r]))).map(b.fromAffine)}static msm(e,t){return gr(b,l,e,t)}_setWindowSize(e){E.setWindowSize(this,e)}assertValidity(){w(this)}equals(e){y(e);const{ex:t,ey:r,ez:n}=this,{ex:i,ey:o,ez:s}=e,a=h(t*s),c=h(i*n),u=h(r*s),l=h(o*n);return a===c&&u===l}is0(){return this.equals(b.ZERO)}negate(){return new b(h(-this.ex),this.ey,this.ez,h(-this.et))}double(){const{a:e}=t,{ex:r,ey:n,ez:i}=this,o=h(r*r),s=h(n*n),a=h(br*h(i*i)),c=h(e*o),u=r+n,l=h(h(u*u)-o-s),f=c+s,d=f-a,p=c-s,g=h(l*d),y=h(f*p),m=h(l*p),w=h(d*f);return new b(g,y,w,m)}add(e){y(e);const{a:r,d:n}=t,{ex:i,ey:o,ez:s,et:a}=this,{ex:c,ey:u,ez:l,et:f}=e;if(r===BigInt(-1)){const e=h((o-i)*(u+c)),t=h((o+i)*(u-c)),r=h(t-e);if(r===mr)return this.double();const n=h(s*br*f),d=h(a*br*l),p=d+n,g=t+e,y=d-n,m=h(p*r),w=h(g*y),v=h(p*y),_=h(r*g);return new b(m,w,_,v)}const d=h(i*c),p=h(o*u),g=h(a*n*f),m=h(s*l),w=h((i+o)*(c+u)-d-p),v=m-g,_=m+g,E=h(p-r*d),S=h(w*v),A=h(_*E),x=h(w*E),k=h(v*_);return new b(S,A,k,x)}subtract(e){return this.add(e.negate())}wNAF(e){return E.wNAFCached(this,e,b.normalizeZ)}multiply(e){const t=e;Ut("scalar",t,wr,n);const{p:r,f:i}=this.wNAF(t);return b.normalizeZ([r,i])[0]}multiplyUnsafe(e){const t=e;return Ut("scalar",t,mr,n),t===mr?_:this.equals(_)||t===wr?this:this.equals(v)?this.wNAF(t).p:E.unsafeLadder(this,t)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return E.unsafeLadder(this,n).is0()}toAffine(e){return m(this,e)}clearCofactor(){const{h:e}=t;return e===wr?this:this.multiplyUnsafe(e)}static fromHex(e,n=!1){const{d:i,a:o}=t,s=r.BYTES;e=Mt("pointHex",e,s),yt("zip215",n);const a=e.slice(),c=e[s-1];a[s-1]=-129&c;const l=Rt(a),d=n?u:r.ORDER;Ut("pointHex.y",l,mr,d);const p=h(l*l),g=h(p-wr),y=h(i*p-o);let{isValid:m,value:w}=f(g,y);if(!m)throw new Error("Point.fromHex: invalid y coordinate");const v=(w&wr)===wr,_=!!(128&c);if(!n&&w===mr&&_)throw new Error("Point.fromHex: x=0 and x_0=1");return _!==v&&(w=h(-w)),b.fromAffine({x:w,y:l})}static fromPrivateKey(e){return x(e).point}toRawBytes(){const{x:e,y:t}=this.toAffine(),n=Lt(t,r.BYTES);return n[n.length-1]|=e&wr?128:0,n}toHex(){return wt(this.toRawBytes())}}b.BASE=new b(t.Gx,t.Gy,wr,h(t.Gx*t.Gy)),b.ZERO=new b(mr,wr,wr,mr);const{BASE:v,ZERO:_}=b,E=pr(b,8*a);function S(e){return er(e,n)}function A(e){return S(Rt(e))}function x(e){const t=a;e=Mt("private key",e,t);const r=Mt("hashed private key",o(e),2*t),n=d(r.slice(0,t)),i=r.slice(t,2*t),s=A(n),c=v.multiply(s),u=c.toRawBytes();return{head:n,prefix:i,scalar:s,point:c,pointBytes:u}}function k(e=new Uint8Array,...t){const r=Ct(...t);return A(o(p(r,Mt("context",e),!!i)))}const B=_r;v._setWindowSize(8);return{CURVE:t,getPublicKey:function(e){return x(e).pointBytes},sign:function(e,t,o={}){e=Mt("message",e),i&&(e=i(e));const{prefix:s,scalar:c,pointBytes:u}=x(t),h=k(o.context,s,e),l=v.multiply(h).toRawBytes(),f=S(h+k(o.context,l,u,e)*c);return Ut("signature.s",f,mr,n),Mt("result",Ct(l,Lt(f,r.BYTES)),2*a)},verify:function(e,t,n,o=B){const{context:s,zip215:a}=o,c=r.BYTES;e=Mt("signature",e,2*c),t=Mt("message",t),void 0!==a&&yt("zip215",a),i&&(t=i(t));const u=Rt(e.slice(c,2*c));let h,l,f;try{h=b.fromHex(n,a),l=b.fromHex(e.slice(0,c),a),f=v.multiplyUnsafe(u)}catch(e){return!1}if(!a&&h.isSmallOrder())return!1;const d=k(s,l.toRawBytes(),h.toRawBytes(),t);return l.add(h.multiplyUnsafe(d)).subtract(f).clearCofactor().equals(b.ZERO)},ExtendedPoint:b,utils:{getExtendedPublicKey:x,randomPrivateKey:()=>s(r.BYTES),precompute:(e=8,t=b.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)}}} /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */BigInt(0),BigInt(1); /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -const yr=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),mr=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const wr=BigInt(1),br=BigInt(2),vr=BigInt(5),_r=BigInt(10),Er=BigInt(20),Sr=BigInt(40),xr=BigInt(80);const Ar=nr(yr,void 0,!0),kr={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Ar,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:ft,randomBytes:Qe,adjustScalarBytes:function(e){return e[0]&=248,e[31]&=127,e[31]|=64,e},uvRatio:function(e,t){const r=yr,n=Jt(t*t*t,r),i=function(e){const t=yr,r=e*e%t*e%t,n=Xt(r,br,t)*r%t,i=Xt(n,wr,t)*e%t,o=Xt(i,vr,t)*i%t,s=Xt(o,_r,t)*o%t,a=Xt(s,Er,t)*s%t,c=Xt(a,Sr,t)*a%t,u=Xt(c,xr,t)*c%t,l=Xt(u,xr,t)*c%t,h=Xt(l,_r,t)*o%t;return{pow_p_5_8:Xt(h,br,t)*e%t,b2:r}}(e*Jt(n*n*t,r)).pow_p_5_8;let o=Jt(e*n*i,r);const s=Jt(t*o*o,r),a=o,c=Jt(o*mr,r),u=s===e,l=s===Jt(-e,r),h=s===Jt(-e*mr,r);return u&&(o=a),(l||h)&&(o=c),(Jt(o,r)&Ft)===Ft&&(o=Jt(-o,r)),{isValid:u||l,value:o}}},Ir=gr(kr);const Br=(Ar.ORDER+BigInt(3))/BigInt(8);Ar.pow(br,Br),Ar.sqrt(Ar.neg(Ar.ONE)),Ar.ORDER,BigInt(5),BigInt(8),BigInt(486662),function(e,t){if(!e.isOdd)throw new Error("Field doesn't have isOdd");const r=e.sqrt(t);e.isOdd(r)&&e.neg(r)}(Ar,Ar.neg(BigInt(486664))),BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");var Tr="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Rr(e){var t=e.default;if("function"==typeof t){var r=function(){return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var Or={exports:{}},Mr=Rr(be);(function(e,t){function r(e,t){if(!e)throw new Error(t||"Assertion failed")}function n(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function i(e,t,r){if(i.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(r=t,t=10),this._init(e||0,t||10,r||"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:Mr.Buffer}catch(e){}function s(e,t){var n=e.charCodeAt(t);return n>=48&&n<=57?n-48:n>=65&&n<=70?n-55:n>=97&&n<=102?n-87:void r(!1,"Invalid character in "+e)}function a(e,t,r){var n=s(e,r);return r-1>=t&&(n|=s(e,r-1)<<4),n}function c(e,t,n,i){for(var o=0,s=0,a=Math.min(e.length,n),c=t;c=49?u-49+10:u>=17?u-17+10:u,r(u>=0&&s0?e:t},i.min=function(e,t){return e.cmp(t)<0?e:t},i.prototype._init=function(e,t,n){if("number"==typeof e)return this._initNumber(e,t,n);if("object"==typeof e)return this._initArray(e,t,n);"hex"===t&&(t=16),r(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)s=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=s<>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===n)for(i=0,o=0;i>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this._strip()},i.prototype._parseHex=function(e,t,r){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var n=0;n=t;n-=2)i=a(e,t,n)<=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;else for(n=(e.length-t)%2==0?t+1:t;n=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;this._strip()},i.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,s=o%n,a=Math.min(o,o-s)+r,u=0,l=r;l1&&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")]=l}catch(e){i.prototype.inspect=l}else i.prototype.inspect=l;function l(){return(this.red?""}var h=["","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],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 p(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],s=i*o,a=67108863&s,c=s/67108864|0;r.words[0]=a;for(var u=1;u>>26,h=67108863&c,f=Math.min(u,t.length-1),d=Math.max(0,u-e.length+1);d<=f;d++){var p=u-d|0;l+=(s=(i=0|e.words[p])*(o=0|t.words[d])+h)/67108864|0,h=67108863&s}r.words[u]=0|h,c=0|l}return 0!==c?r.words[u]=0|c:r.length--,r._strip()}i.prototype.toString=function(e,t){var n;if(t=0|t||1,16===(e=e||10)||"hex"===e){n="";for(var i=0,o=0,s=0;s>>24-i&16777215,(i+=2)>=26&&(i-=26,s--),n=0!==o||s!==this.length-1?h[6-c.length]+c+n:c+n}for(0!==o&&(n=o.toString(16)+n);n.length%t!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(e===(0|e)&&e>=2&&e<=36){var u=f[e],l=d[e];n="";var p=this.clone();for(p.negative=0;!p.isZero();){var g=p.modrn(l).toString(e);n=(p=p.idivn(l)).isZero()?g+n:h[u-g.length]+g+n}for(this.isZero()&&(n="0"+n);n.length%t!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}r(!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&&r(!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)},i.prototype.toArrayLike=function(e,t,n){this._strip();var i=this.byteLength(),o=n||Math.max(1,i);r(i<=o,"byte array longer than desired length"),r(o>0,"Requested array length <= 0");var s=function(e,t){return e.allocUnsafe?e.allocUnsafe(t):new e(t)}(e,o);return this["_toArrayLike"+("le"===t?"LE":"BE")](s,i),s},i.prototype._toArrayLikeLE=function(e,t){for(var r=0,n=0,i=0,o=0;i>8&255),r>16&255),6===o?(r>24&255),n=0,o=0):(n=s>>>24,o+=2)}if(r=0&&(e[r--]=s>>8&255),r>=0&&(e[r--]=s>>16&255),6===o?(r>=0&&(e[r--]=s>>24&255),n=0,o=0):(n=s>>>24,o+=2)}if(r>=0)for(e[r--]=n;r>=0;)e[r--]=0},Math.clz32?i.prototype._countBits=function(e){return 32-Math.clz32(e)}:i.prototype._countBits=function(e){var t=e,r=0;return t>=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},i.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 8191&t||(r+=13,t>>>=13),127&t||(r+=7,t>>>=7),15&t||(r+=4,t>>>=4),3&t||(r+=2,t>>>=2),1&t||r++,r},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 r=0;re.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,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.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){r("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),n=e%26;this._expand(t),n>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-n),this._strip()},i.prototype.notn=function(e){return this.clone().inotn(e)},i.prototype.setn=function(e,t){r("number"==typeof e&&e>=0);var n=e/26|0,i=e%26;return this._expand(n+1),this.words[n]=t?this.words[n]|1<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==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 r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,s=0;s>26,this.words[s]=67108863&t;for(;0!==o&&s>26,this.words[s]=67108863&t;if(0===o&&s>>13,d=0|s[1],p=8191&d,g=d>>>13,y=0|s[2],m=8191&y,w=y>>>13,b=0|s[3],v=8191&b,_=b>>>13,E=0|s[4],S=8191&E,x=E>>>13,A=0|s[5],k=8191&A,I=A>>>13,B=0|s[6],T=8191&B,R=B>>>13,O=0|s[7],M=8191&O,L=O>>>13,C=0|s[8],P=8191&C,N=C>>>13,U=0|s[9],j=8191&U,$=U>>>13,z=0|a[0],D=8191&z,H=z>>>13,q=0|a[1],F=8191&q,K=q>>>13,W=0|a[2],V=8191&W,Z=W>>>13,G=0|a[3],J=8191&G,Y=G>>>13,X=0|a[4],Q=8191&X,ee=X>>>13,te=0|a[5],re=8191&te,ne=te>>>13,ie=0|a[6],oe=8191&ie,se=ie>>>13,ae=0|a[7],ce=8191&ae,ue=ae>>>13,le=0|a[8],he=8191&le,fe=le>>>13,de=0|a[9],pe=8191&de,ge=de>>>13;r.negative=e.negative^t.negative,r.length=19;var ye=(u+(n=Math.imul(h,D))|0)+((8191&(i=(i=Math.imul(h,H))+Math.imul(f,D)|0))<<13)|0;u=((o=Math.imul(f,H))+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,n=Math.imul(p,D),i=(i=Math.imul(p,H))+Math.imul(g,D)|0,o=Math.imul(g,H);var me=(u+(n=n+Math.imul(h,F)|0)|0)+((8191&(i=(i=i+Math.imul(h,K)|0)+Math.imul(f,F)|0))<<13)|0;u=((o=o+Math.imul(f,K)|0)+(i>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(m,D),i=(i=Math.imul(m,H))+Math.imul(w,D)|0,o=Math.imul(w,H),n=n+Math.imul(p,F)|0,i=(i=i+Math.imul(p,K)|0)+Math.imul(g,F)|0,o=o+Math.imul(g,K)|0;var we=(u+(n=n+Math.imul(h,V)|0)|0)+((8191&(i=(i=i+Math.imul(h,Z)|0)+Math.imul(f,V)|0))<<13)|0;u=((o=o+Math.imul(f,Z)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(v,D),i=(i=Math.imul(v,H))+Math.imul(_,D)|0,o=Math.imul(_,H),n=n+Math.imul(m,F)|0,i=(i=i+Math.imul(m,K)|0)+Math.imul(w,F)|0,o=o+Math.imul(w,K)|0,n=n+Math.imul(p,V)|0,i=(i=i+Math.imul(p,Z)|0)+Math.imul(g,V)|0,o=o+Math.imul(g,Z)|0;var be=(u+(n=n+Math.imul(h,J)|0)|0)+((8191&(i=(i=i+Math.imul(h,Y)|0)+Math.imul(f,J)|0))<<13)|0;u=((o=o+Math.imul(f,Y)|0)+(i>>>13)|0)+(be>>>26)|0,be&=67108863,n=Math.imul(S,D),i=(i=Math.imul(S,H))+Math.imul(x,D)|0,o=Math.imul(x,H),n=n+Math.imul(v,F)|0,i=(i=i+Math.imul(v,K)|0)+Math.imul(_,F)|0,o=o+Math.imul(_,K)|0,n=n+Math.imul(m,V)|0,i=(i=i+Math.imul(m,Z)|0)+Math.imul(w,V)|0,o=o+Math.imul(w,Z)|0,n=n+Math.imul(p,J)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(g,J)|0,o=o+Math.imul(g,Y)|0;var ve=(u+(n=n+Math.imul(h,Q)|0)|0)+((8191&(i=(i=i+Math.imul(h,ee)|0)+Math.imul(f,Q)|0))<<13)|0;u=((o=o+Math.imul(f,ee)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(k,D),i=(i=Math.imul(k,H))+Math.imul(I,D)|0,o=Math.imul(I,H),n=n+Math.imul(S,F)|0,i=(i=i+Math.imul(S,K)|0)+Math.imul(x,F)|0,o=o+Math.imul(x,K)|0,n=n+Math.imul(v,V)|0,i=(i=i+Math.imul(v,Z)|0)+Math.imul(_,V)|0,o=o+Math.imul(_,Z)|0,n=n+Math.imul(m,J)|0,i=(i=i+Math.imul(m,Y)|0)+Math.imul(w,J)|0,o=o+Math.imul(w,Y)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(g,Q)|0,o=o+Math.imul(g,ee)|0;var _e=(u+(n=n+Math.imul(h,re)|0)|0)+((8191&(i=(i=i+Math.imul(h,ne)|0)+Math.imul(f,re)|0))<<13)|0;u=((o=o+Math.imul(f,ne)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(T,D),i=(i=Math.imul(T,H))+Math.imul(R,D)|0,o=Math.imul(R,H),n=n+Math.imul(k,F)|0,i=(i=i+Math.imul(k,K)|0)+Math.imul(I,F)|0,o=o+Math.imul(I,K)|0,n=n+Math.imul(S,V)|0,i=(i=i+Math.imul(S,Z)|0)+Math.imul(x,V)|0,o=o+Math.imul(x,Z)|0,n=n+Math.imul(v,J)|0,i=(i=i+Math.imul(v,Y)|0)+Math.imul(_,J)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,ee)|0)+Math.imul(w,Q)|0,o=o+Math.imul(w,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(g,re)|0,o=o+Math.imul(g,ne)|0;var Ee=(u+(n=n+Math.imul(h,oe)|0)|0)+((8191&(i=(i=i+Math.imul(h,se)|0)+Math.imul(f,oe)|0))<<13)|0;u=((o=o+Math.imul(f,se)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(M,D),i=(i=Math.imul(M,H))+Math.imul(L,D)|0,o=Math.imul(L,H),n=n+Math.imul(T,F)|0,i=(i=i+Math.imul(T,K)|0)+Math.imul(R,F)|0,o=o+Math.imul(R,K)|0,n=n+Math.imul(k,V)|0,i=(i=i+Math.imul(k,Z)|0)+Math.imul(I,V)|0,o=o+Math.imul(I,Z)|0,n=n+Math.imul(S,J)|0,i=(i=i+Math.imul(S,Y)|0)+Math.imul(x,J)|0,o=o+Math.imul(x,Y)|0,n=n+Math.imul(v,Q)|0,i=(i=i+Math.imul(v,ee)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,ee)|0,n=n+Math.imul(m,re)|0,i=(i=i+Math.imul(m,ne)|0)+Math.imul(w,re)|0,o=o+Math.imul(w,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,se)|0)+Math.imul(g,oe)|0,o=o+Math.imul(g,se)|0;var Se=(u+(n=n+Math.imul(h,ce)|0)|0)+((8191&(i=(i=i+Math.imul(h,ue)|0)+Math.imul(f,ce)|0))<<13)|0;u=((o=o+Math.imul(f,ue)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(P,D),i=(i=Math.imul(P,H))+Math.imul(N,D)|0,o=Math.imul(N,H),n=n+Math.imul(M,F)|0,i=(i=i+Math.imul(M,K)|0)+Math.imul(L,F)|0,o=o+Math.imul(L,K)|0,n=n+Math.imul(T,V)|0,i=(i=i+Math.imul(T,Z)|0)+Math.imul(R,V)|0,o=o+Math.imul(R,Z)|0,n=n+Math.imul(k,J)|0,i=(i=i+Math.imul(k,Y)|0)+Math.imul(I,J)|0,o=o+Math.imul(I,Y)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,ee)|0)+Math.imul(x,Q)|0,o=o+Math.imul(x,ee)|0,n=n+Math.imul(v,re)|0,i=(i=i+Math.imul(v,ne)|0)+Math.imul(_,re)|0,o=o+Math.imul(_,ne)|0,n=n+Math.imul(m,oe)|0,i=(i=i+Math.imul(m,se)|0)+Math.imul(w,oe)|0,o=o+Math.imul(w,se)|0,n=n+Math.imul(p,ce)|0,i=(i=i+Math.imul(p,ue)|0)+Math.imul(g,ce)|0,o=o+Math.imul(g,ue)|0;var xe=(u+(n=n+Math.imul(h,he)|0)|0)+((8191&(i=(i=i+Math.imul(h,fe)|0)+Math.imul(f,he)|0))<<13)|0;u=((o=o+Math.imul(f,fe)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(j,D),i=(i=Math.imul(j,H))+Math.imul($,D)|0,o=Math.imul($,H),n=n+Math.imul(P,F)|0,i=(i=i+Math.imul(P,K)|0)+Math.imul(N,F)|0,o=o+Math.imul(N,K)|0,n=n+Math.imul(M,V)|0,i=(i=i+Math.imul(M,Z)|0)+Math.imul(L,V)|0,o=o+Math.imul(L,Z)|0,n=n+Math.imul(T,J)|0,i=(i=i+Math.imul(T,Y)|0)+Math.imul(R,J)|0,o=o+Math.imul(R,Y)|0,n=n+Math.imul(k,Q)|0,i=(i=i+Math.imul(k,ee)|0)+Math.imul(I,Q)|0,o=o+Math.imul(I,ee)|0,n=n+Math.imul(S,re)|0,i=(i=i+Math.imul(S,ne)|0)+Math.imul(x,re)|0,o=o+Math.imul(x,ne)|0,n=n+Math.imul(v,oe)|0,i=(i=i+Math.imul(v,se)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,se)|0,n=n+Math.imul(m,ce)|0,i=(i=i+Math.imul(m,ue)|0)+Math.imul(w,ce)|0,o=o+Math.imul(w,ue)|0,n=n+Math.imul(p,he)|0,i=(i=i+Math.imul(p,fe)|0)+Math.imul(g,he)|0,o=o+Math.imul(g,fe)|0;var Ae=(u+(n=n+Math.imul(h,pe)|0)|0)+((8191&(i=(i=i+Math.imul(h,ge)|0)+Math.imul(f,pe)|0))<<13)|0;u=((o=o+Math.imul(f,ge)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(j,F),i=(i=Math.imul(j,K))+Math.imul($,F)|0,o=Math.imul($,K),n=n+Math.imul(P,V)|0,i=(i=i+Math.imul(P,Z)|0)+Math.imul(N,V)|0,o=o+Math.imul(N,Z)|0,n=n+Math.imul(M,J)|0,i=(i=i+Math.imul(M,Y)|0)+Math.imul(L,J)|0,o=o+Math.imul(L,Y)|0,n=n+Math.imul(T,Q)|0,i=(i=i+Math.imul(T,ee)|0)+Math.imul(R,Q)|0,o=o+Math.imul(R,ee)|0,n=n+Math.imul(k,re)|0,i=(i=i+Math.imul(k,ne)|0)+Math.imul(I,re)|0,o=o+Math.imul(I,ne)|0,n=n+Math.imul(S,oe)|0,i=(i=i+Math.imul(S,se)|0)+Math.imul(x,oe)|0,o=o+Math.imul(x,se)|0,n=n+Math.imul(v,ce)|0,i=(i=i+Math.imul(v,ue)|0)+Math.imul(_,ce)|0,o=o+Math.imul(_,ue)|0,n=n+Math.imul(m,he)|0,i=(i=i+Math.imul(m,fe)|0)+Math.imul(w,he)|0,o=o+Math.imul(w,fe)|0;var ke=(u+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,ge)|0)+Math.imul(g,pe)|0))<<13)|0;u=((o=o+Math.imul(g,ge)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(j,V),i=(i=Math.imul(j,Z))+Math.imul($,V)|0,o=Math.imul($,Z),n=n+Math.imul(P,J)|0,i=(i=i+Math.imul(P,Y)|0)+Math.imul(N,J)|0,o=o+Math.imul(N,Y)|0,n=n+Math.imul(M,Q)|0,i=(i=i+Math.imul(M,ee)|0)+Math.imul(L,Q)|0,o=o+Math.imul(L,ee)|0,n=n+Math.imul(T,re)|0,i=(i=i+Math.imul(T,ne)|0)+Math.imul(R,re)|0,o=o+Math.imul(R,ne)|0,n=n+Math.imul(k,oe)|0,i=(i=i+Math.imul(k,se)|0)+Math.imul(I,oe)|0,o=o+Math.imul(I,se)|0,n=n+Math.imul(S,ce)|0,i=(i=i+Math.imul(S,ue)|0)+Math.imul(x,ce)|0,o=o+Math.imul(x,ue)|0,n=n+Math.imul(v,he)|0,i=(i=i+Math.imul(v,fe)|0)+Math.imul(_,he)|0,o=o+Math.imul(_,fe)|0;var Ie=(u+(n=n+Math.imul(m,pe)|0)|0)+((8191&(i=(i=i+Math.imul(m,ge)|0)+Math.imul(w,pe)|0))<<13)|0;u=((o=o+Math.imul(w,ge)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,n=Math.imul(j,J),i=(i=Math.imul(j,Y))+Math.imul($,J)|0,o=Math.imul($,Y),n=n+Math.imul(P,Q)|0,i=(i=i+Math.imul(P,ee)|0)+Math.imul(N,Q)|0,o=o+Math.imul(N,ee)|0,n=n+Math.imul(M,re)|0,i=(i=i+Math.imul(M,ne)|0)+Math.imul(L,re)|0,o=o+Math.imul(L,ne)|0,n=n+Math.imul(T,oe)|0,i=(i=i+Math.imul(T,se)|0)+Math.imul(R,oe)|0,o=o+Math.imul(R,se)|0,n=n+Math.imul(k,ce)|0,i=(i=i+Math.imul(k,ue)|0)+Math.imul(I,ce)|0,o=o+Math.imul(I,ue)|0,n=n+Math.imul(S,he)|0,i=(i=i+Math.imul(S,fe)|0)+Math.imul(x,he)|0,o=o+Math.imul(x,fe)|0;var Be=(u+(n=n+Math.imul(v,pe)|0)|0)+((8191&(i=(i=i+Math.imul(v,ge)|0)+Math.imul(_,pe)|0))<<13)|0;u=((o=o+Math.imul(_,ge)|0)+(i>>>13)|0)+(Be>>>26)|0,Be&=67108863,n=Math.imul(j,Q),i=(i=Math.imul(j,ee))+Math.imul($,Q)|0,o=Math.imul($,ee),n=n+Math.imul(P,re)|0,i=(i=i+Math.imul(P,ne)|0)+Math.imul(N,re)|0,o=o+Math.imul(N,ne)|0,n=n+Math.imul(M,oe)|0,i=(i=i+Math.imul(M,se)|0)+Math.imul(L,oe)|0,o=o+Math.imul(L,se)|0,n=n+Math.imul(T,ce)|0,i=(i=i+Math.imul(T,ue)|0)+Math.imul(R,ce)|0,o=o+Math.imul(R,ue)|0,n=n+Math.imul(k,he)|0,i=(i=i+Math.imul(k,fe)|0)+Math.imul(I,he)|0,o=o+Math.imul(I,fe)|0;var Te=(u+(n=n+Math.imul(S,pe)|0)|0)+((8191&(i=(i=i+Math.imul(S,ge)|0)+Math.imul(x,pe)|0))<<13)|0;u=((o=o+Math.imul(x,ge)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(j,re),i=(i=Math.imul(j,ne))+Math.imul($,re)|0,o=Math.imul($,ne),n=n+Math.imul(P,oe)|0,i=(i=i+Math.imul(P,se)|0)+Math.imul(N,oe)|0,o=o+Math.imul(N,se)|0,n=n+Math.imul(M,ce)|0,i=(i=i+Math.imul(M,ue)|0)+Math.imul(L,ce)|0,o=o+Math.imul(L,ue)|0,n=n+Math.imul(T,he)|0,i=(i=i+Math.imul(T,fe)|0)+Math.imul(R,he)|0,o=o+Math.imul(R,fe)|0;var Re=(u+(n=n+Math.imul(k,pe)|0)|0)+((8191&(i=(i=i+Math.imul(k,ge)|0)+Math.imul(I,pe)|0))<<13)|0;u=((o=o+Math.imul(I,ge)|0)+(i>>>13)|0)+(Re>>>26)|0,Re&=67108863,n=Math.imul(j,oe),i=(i=Math.imul(j,se))+Math.imul($,oe)|0,o=Math.imul($,se),n=n+Math.imul(P,ce)|0,i=(i=i+Math.imul(P,ue)|0)+Math.imul(N,ce)|0,o=o+Math.imul(N,ue)|0,n=n+Math.imul(M,he)|0,i=(i=i+Math.imul(M,fe)|0)+Math.imul(L,he)|0,o=o+Math.imul(L,fe)|0;var Oe=(u+(n=n+Math.imul(T,pe)|0)|0)+((8191&(i=(i=i+Math.imul(T,ge)|0)+Math.imul(R,pe)|0))<<13)|0;u=((o=o+Math.imul(R,ge)|0)+(i>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,n=Math.imul(j,ce),i=(i=Math.imul(j,ue))+Math.imul($,ce)|0,o=Math.imul($,ue),n=n+Math.imul(P,he)|0,i=(i=i+Math.imul(P,fe)|0)+Math.imul(N,he)|0,o=o+Math.imul(N,fe)|0;var Me=(u+(n=n+Math.imul(M,pe)|0)|0)+((8191&(i=(i=i+Math.imul(M,ge)|0)+Math.imul(L,pe)|0))<<13)|0;u=((o=o+Math.imul(L,ge)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(j,he),i=(i=Math.imul(j,fe))+Math.imul($,he)|0,o=Math.imul($,fe);var Le=(u+(n=n+Math.imul(P,pe)|0)|0)+((8191&(i=(i=i+Math.imul(P,ge)|0)+Math.imul(N,pe)|0))<<13)|0;u=((o=o+Math.imul(N,ge)|0)+(i>>>13)|0)+(Le>>>26)|0,Le&=67108863;var Ce=(u+(n=Math.imul(j,pe))|0)+((8191&(i=(i=Math.imul(j,ge))+Math.imul($,pe)|0))<<13)|0;return u=((o=Math.imul($,ge))+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,c[0]=ye,c[1]=me,c[2]=we,c[3]=be,c[4]=ve,c[5]=_e,c[6]=Ee,c[7]=Se,c[8]=xe,c[9]=Ae,c[10]=ke,c[11]=Ie,c[12]=Be,c[13]=Te,c[14]=Re,c[15]=Oe,c[16]=Me,c[17]=Le,c[18]=Ce,0!==u&&(c[19]=u,r.length++),r};function y(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r._strip()}function m(e,t,r){return y(e,t,r)}Math.imul||(g=p),i.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?g(this,e,t):r<63?p(this,e,t):r<1024?y(this,e,t):m(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),m(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),r("number"==typeof e),r(e<67108864);for(var n=0,i=0;i>=26,n+=o/67108864|0,n+=s>>>26,this.words[i]=67108863&s}return 0!==n&&(this.words[i]=n,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()),r=0;r>>i&1}return t}(e);if(0===t.length)return new i(1);for(var r=this,n=0;n=0);var t,n=e%26,i=(e-n)/26,o=67108863>>>26-n<<26-n;if(0!==n){var s=0;for(t=0;t>>26-n}s&&(this.words[t]=s,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,s=Math.min((e-o)/26,this.length),a=67108863^67108863>>>o<s)for(this.length-=s,u=0;u=0&&(0!==l||u>=i);u--){var h=0|this.words[u];this.words[u]=l<<26-o|h>>>o,l=h&a}return c&&0!==l&&(c.words[c.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.ishrn=function(e,t,n){return r(0===this.negative),this.iushrn(e,t,n)},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){r("number"==typeof e&&e>=0);var t=e%26,n=(e-t)/26,i=1<=0);var t=e%26,n=(e-t)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==t&&n++,this.length=Math.min(n,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(r("number"==typeof e),r(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)-(c/67108864|0),this.words[i+n]=67108863&o}for(;i>26,this.words[i+n]=67108863&o;if(0===a)return this._strip();for(r(-1===a),a=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this._strip()},i.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),o=e,s=0|o.words[o.length-1];0!=(r=26-this._countBits(s))&&(o=o.ushln(r),n.iushln(r),s=0|o.words[o.length-1]);var a,c=n.length-o.length;if("mod"!==t){(a=new i(null)).length=c+1,a.words=new Array(a.length);for(var u=0;u=0;h--){var f=67108864*(0|n.words[o.length+h])+(0|n.words[o.length+h-1]);for(f=Math.min(f/s|0,67108863),n._ishlnsubmul(o,f,h);0!==n.negative;)f--,n.negative=0,n._ishlnsubmul(o,1,h),n.isZero()||(n.negative^=1);a&&(a.words[h]=f)}return a&&a._strip(),n._strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:a||null,mod:n}},i.prototype.divmod=function(e,t,n){return r(!e.isZero()),this.isZero()?{div:new i(0),mod:new i(0)}:0!==this.negative&&0===e.negative?(a=this.neg().divmod(e,t),"mod"!==t&&(o=a.div.neg()),"div"!==t&&(s=a.mod.neg(),n&&0!==s.negative&&s.iadd(e)),{div:o,mod:s}):0===this.negative&&0!==e.negative?(a=this.divmod(e.neg(),t),"mod"!==t&&(o=a.div.neg()),{div:o,mod:a.mod}):this.negative&e.negative?(a=this.neg().divmod(e.neg(),t),"div"!==t&&(s=a.mod.neg(),n&&0!==s.negative&&s.isub(e)),{div:a.div,mod:s}):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,s,a},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 r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);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),r(e<=67108863);for(var n=(1<<26)%e,i=0,o=this.length-1;o>=0;o--)i=(n*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),r(e<=67108863);for(var n=0,i=this.length-1;i>=0;i--){var o=(0|this.words[i])+67108864*n;this.words[i]=o/e|0,n=o%e}return this._strip(),t?this.ineg():this},i.prototype.divn=function(e){return this.clone().idivn(e)},i.prototype.egcd=function(e){r(0===e.negative),r(!e.isZero());var t=this,n=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var o=new i(1),s=new i(0),a=new i(0),c=new i(1),u=0;t.isEven()&&n.isEven();)t.iushrn(1),n.iushrn(1),++u;for(var l=n.clone(),h=t.clone();!t.isZero();){for(var f=0,d=1;!(t.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(t.iushrn(f);f-- >0;)(o.isOdd()||s.isOdd())&&(o.iadd(l),s.isub(h)),o.iushrn(1),s.iushrn(1);for(var p=0,g=1;!(n.words[0]&g)&&p<26;++p,g<<=1);if(p>0)for(n.iushrn(p);p-- >0;)(a.isOdd()||c.isOdd())&&(a.iadd(l),c.isub(h)),a.iushrn(1),c.iushrn(1);t.cmp(n)>=0?(t.isub(n),o.isub(a),s.isub(c)):(n.isub(t),a.isub(o),c.isub(s))}return{a:a,b:c,gcd:n.iushln(u)}},i.prototype._invmp=function(e){r(0===e.negative),r(!e.isZero());var t=this,n=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var o,s=new i(1),a=new i(0),c=n.clone();t.cmpn(1)>0&&n.cmpn(1)>0;){for(var u=0,l=1;!(t.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(t.iushrn(u);u-- >0;)s.isOdd()&&s.iadd(c),s.iushrn(1);for(var h=0,f=1;!(n.words[0]&f)&&h<26;++h,f<<=1);if(h>0)for(n.iushrn(h);h-- >0;)a.isOdd()&&a.iadd(c),a.iushrn(1);t.cmp(n)>=0?(t.isub(n),s.isub(a)):(n.isub(t),a.isub(s))}return(o=0===t.cmpn(1)?s:a).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(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},i.prototype.invm=function(e){return this.egcd(e).a.umod(e)},i.prototype.isEven=function(){return!(1&this.words[0])},i.prototype.isOdd=function(){return!(1&~this.words[0])},i.prototype.andln=function(e){return this.words[0]&e},i.prototype.bincn=function(e){r("number"==typeof e);var t=e%26,n=(e-t)/26,i=1<>>26,a&=67108863,this.words[s]=a}return 0!==o&&(this.words[s]=o,this.length++),this},i.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},i.prototype.cmpn=function(e){var t,n=e<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this._strip(),this.length>1)t=1;else{n&&(e=-e),r(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(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 x(e)},i.prototype.toRed=function(e){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},i.prototype.fromRed=function(){return r(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 r(!this.red,"Already a number in reduction context"),this._forceRed(e)},i.prototype.redAdd=function(e){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},i.prototype.redIAdd=function(e){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},i.prototype.redSub=function(e){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},i.prototype.redISub=function(e){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},i.prototype.redShl=function(e){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},i.prototype.redMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},i.prototype.redIMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(e){return r(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var w={k256:null,p224:null,p192:null,p25519:null};function b(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 v(){b.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function _(){b.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function E(){b.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function S(){b.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function x(e){if("string"==typeof e){var t=i._prime(e);this.m=t.p,this.prime=t}else r(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function A(e){x.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)}b.prototype._tmp=function(){var e=new i(null);return e.words=new Array(Math.ceil(this.n/13)),e},b.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},b.prototype.split=function(e,t){e.iushrn(this.n,0,t)},b.prototype.imulK=function(e){return e.imul(this.k)},n(v,b),v.prototype.split=function(e,t){for(var r=4194303,n=Math.min(e.length,9),i=0;i>>22,o=s}o>>>=22,e.words[i-10]=o,0===o&&e.length>10?e.length-=10:e.length-=9},v.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},i._prime=function(e){if(w[e])return w[e];var t;if("k256"===e)t=new v;else if("p224"===e)t=new _;else if("p192"===e)t=new E;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new S}return w[e]=t,t},x.prototype._verify1=function(e){r(0===e.negative,"red works only with positives"),r(e.red,"red works only with red numbers")},x.prototype._verify2=function(e,t){r(!(e.negative|t.negative),"red works only with positives"),r(e.red&&e.red===t.red,"red works only with red numbers")},x.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):(u(e,e.umod(this.m)._forceRed(this)),e)},x.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},x.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},x.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},x.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},x.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},x.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},x.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},x.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},x.prototype.isqr=function(e){return this.imul(e,e.clone())},x.prototype.sqr=function(e){return this.mul(e,e)},x.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(r(t%2==1),3===t){var n=this.m.add(new i(1)).iushrn(2);return this.pow(e,n)}for(var o=this.m.subn(1),s=0;!o.isZero()&&0===o.andln(1);)s++,o.iushrn(1);r(!o.isZero());var a=new i(1).toRed(this),c=a.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new i(2*l*l).toRed(this);0!==this.pow(l,u).cmp(c);)l.redIAdd(c);for(var h=this.pow(l,o),f=this.pow(e,o.addn(1).iushrn(1)),d=this.pow(e,o),p=s;0!==d.cmp(a);){for(var g=d,y=0;0!==g.cmp(a);y++)g=g.redSqr();r(y=0;n--){for(var u=t.words[n],l=c-1;l>=0;l--){var h=u>>l&1;o!==r[0]&&(o=this.sqr(o)),0!==h||0!==s?(s<<=1,s|=h,(4==++a||0===n&&0===l)&&(o=this.mul(o,r[s]),a=0,s=0)):a=0}c=26}return o},x.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},x.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},i.mont=function(e){return new A(e)},n(A,x),A.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},A.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},A.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).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)},A.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new i(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(n).iushrn(this.shift),s=o;return o.cmp(this.m)>=0?s=o.isub(this.m):o.cmpn(0)<0&&(s=o.iadd(this.m)),s._forceRed(this)},A.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}})(Or,Tr);var Lr=Or.exports,Cr={exports:{}}; +const Sr=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Ar=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const xr=BigInt(1),kr=BigInt(2);BigInt(3);const Br=BigInt(5),Ir=BigInt(8);function Tr(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}function Rr(e,t){const r=Sr,n=er(t*t*t,r),i=function(e){const t=BigInt(10),r=BigInt(20),n=BigInt(40),i=BigInt(80),o=Sr,s=e*e%o*e%o,a=rr(s,kr,o)*s%o,c=rr(a,xr,o)*e%o,u=rr(c,Br,o)*c%o,h=rr(u,t,o)*u%o,l=rr(h,r,o)*h%o,f=rr(l,n,o)*l%o,d=rr(f,i,o)*f%o,p=rr(d,i,o)*f%o,g=rr(p,t,o)*u%o;return{pow_p_5_8:rr(g,kr,o)*e%o,b2:s}}(e*er(n*n*t,r)).pow_p_5_8;let o=er(e*n*i,r);const s=er(t*o*o,r),a=o,c=er(o*Ar,r),u=s===e,h=s===er(-e,r),l=s===er(-e*Ar,r);return u&&(o=a),(h||l)&&(o=c),(er(o,r)&Zt)===Zt&&(o=er(-o,r)),{isValid:u||h,value:o}}const Or=(()=>ar(Sr,void 0,!0))(),Lr=(()=>({a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Or,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Ir,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:ht,randomBytes:Ye,adjustScalarBytes:Tr,uvRatio:Rr}))(),Mr=(()=>Er(Lr))();var Cr="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Pr(e){var t=e.default;if("function"==typeof t){var r=function(){return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var Nr={exports:{}},Ur=Pr(be);(function(e,t){function r(e,t){if(!e)throw new Error(t||"Assertion failed")}function n(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function i(e,t,r){if(i.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(r=t,t=10),this._init(e||0,t||10,r||"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:Ur.Buffer}catch(e){}function s(e,t){var n=e.charCodeAt(t);return n>=48&&n<=57?n-48:n>=65&&n<=70?n-55:n>=97&&n<=102?n-87:void r(!1,"Invalid character in "+e)}function a(e,t,r){var n=s(e,r);return r-1>=t&&(n|=s(e,r-1)<<4),n}function c(e,t,n,i){for(var o=0,s=0,a=Math.min(e.length,n),c=t;c=49?u-49+10:u>=17?u-17+10:u,r(u>=0&&s0?e:t},i.min=function(e,t){return e.cmp(t)<0?e:t},i.prototype._init=function(e,t,n){if("number"==typeof e)return this._initNumber(e,t,n);if("object"==typeof e)return this._initArray(e,t,n);"hex"===t&&(t=16),r(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)s=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=s<>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===n)for(i=0,o=0;i>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this._strip()},i.prototype._parseHex=function(e,t,r){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var n=0;n=t;n-=2)i=a(e,t,n)<=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;else for(n=(e.length-t)%2==0?t+1:t;n=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;this._strip()},i.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,s=o%n,a=Math.min(o,o-s)+r,u=0,h=r;h1&&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")]=h}catch(e){i.prototype.inspect=h}else i.prototype.inspect=h;function h(){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"],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],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 p(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],s=i*o,a=67108863&s,c=s/67108864|0;r.words[0]=a;for(var u=1;u>>26,l=67108863&c,f=Math.min(u,t.length-1),d=Math.max(0,u-e.length+1);d<=f;d++){var p=u-d|0;h+=(s=(i=0|e.words[p])*(o=0|t.words[d])+l)/67108864|0,l=67108863&s}r.words[u]=0|l,c=0|h}return 0!==c?r.words[u]=0|c:r.length--,r._strip()}i.prototype.toString=function(e,t){var n;if(t=0|t||1,16===(e=e||10)||"hex"===e){n="";for(var i=0,o=0,s=0;s>>24-i&16777215,(i+=2)>=26&&(i-=26,s--),n=0!==o||s!==this.length-1?l[6-c.length]+c+n:c+n}for(0!==o&&(n=o.toString(16)+n);n.length%t!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(e===(0|e)&&e>=2&&e<=36){var u=f[e],h=d[e];n="";var p=this.clone();for(p.negative=0;!p.isZero();){var g=p.modrn(h).toString(e);n=(p=p.idivn(h)).isZero()?g+n:l[u-g.length]+g+n}for(this.isZero()&&(n="0"+n);n.length%t!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}r(!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&&r(!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)},i.prototype.toArrayLike=function(e,t,n){this._strip();var i=this.byteLength(),o=n||Math.max(1,i);r(i<=o,"byte array longer than desired length"),r(o>0,"Requested array length <= 0");var s=function(e,t){return e.allocUnsafe?e.allocUnsafe(t):new e(t)}(e,o);return this["_toArrayLike"+("le"===t?"LE":"BE")](s,i),s},i.prototype._toArrayLikeLE=function(e,t){for(var r=0,n=0,i=0,o=0;i>8&255),r>16&255),6===o?(r>24&255),n=0,o=0):(n=s>>>24,o+=2)}if(r=0&&(e[r--]=s>>8&255),r>=0&&(e[r--]=s>>16&255),6===o?(r>=0&&(e[r--]=s>>24&255),n=0,o=0):(n=s>>>24,o+=2)}if(r>=0)for(e[r--]=n;r>=0;)e[r--]=0},Math.clz32?i.prototype._countBits=function(e){return 32-Math.clz32(e)}:i.prototype._countBits=function(e){var t=e,r=0;return t>=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},i.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 8191&t||(r+=13,t>>>=13),127&t||(r+=7,t>>>=7),15&t||(r+=4,t>>>=4),3&t||(r+=2,t>>>=2),1&t||r++,r},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 r=0;re.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,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.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){r("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),n=e%26;this._expand(t),n>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-n),this._strip()},i.prototype.notn=function(e){return this.clone().inotn(e)},i.prototype.setn=function(e,t){r("number"==typeof e&&e>=0);var n=e/26|0,i=e%26;return this._expand(n+1),this.words[n]=t?this.words[n]|1<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==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 r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,s=0;s>26,this.words[s]=67108863&t;for(;0!==o&&s>26,this.words[s]=67108863&t;if(0===o&&s>>13,d=0|s[1],p=8191&d,g=d>>>13,y=0|s[2],m=8191&y,w=y>>>13,b=0|s[3],v=8191&b,_=b>>>13,E=0|s[4],S=8191&E,A=E>>>13,x=0|s[5],k=8191&x,B=x>>>13,I=0|s[6],T=8191&I,R=I>>>13,O=0|s[7],L=8191&O,M=O>>>13,C=0|s[8],P=8191&C,N=C>>>13,U=0|s[9],j=8191&U,$=U>>>13,H=0|a[0],z=8191&H,D=H>>>13,F=0|a[1],q=8191&F,K=F>>>13,W=0|a[2],V=8191&W,Z=W>>>13,G=0|a[3],J=8191&G,Y=G>>>13,X=0|a[4],Q=8191&X,ee=X>>>13,te=0|a[5],re=8191&te,ne=te>>>13,ie=0|a[6],oe=8191&ie,se=ie>>>13,ae=0|a[7],ce=8191&ae,ue=ae>>>13,he=0|a[8],le=8191&he,fe=he>>>13,de=0|a[9],pe=8191&de,ge=de>>>13;r.negative=e.negative^t.negative,r.length=19;var ye=(u+(n=Math.imul(l,z))|0)+((8191&(i=(i=Math.imul(l,D))+Math.imul(f,z)|0))<<13)|0;u=((o=Math.imul(f,D))+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,n=Math.imul(p,z),i=(i=Math.imul(p,D))+Math.imul(g,z)|0,o=Math.imul(g,D);var me=(u+(n=n+Math.imul(l,q)|0)|0)+((8191&(i=(i=i+Math.imul(l,K)|0)+Math.imul(f,q)|0))<<13)|0;u=((o=o+Math.imul(f,K)|0)+(i>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(m,z),i=(i=Math.imul(m,D))+Math.imul(w,z)|0,o=Math.imul(w,D),n=n+Math.imul(p,q)|0,i=(i=i+Math.imul(p,K)|0)+Math.imul(g,q)|0,o=o+Math.imul(g,K)|0;var we=(u+(n=n+Math.imul(l,V)|0)|0)+((8191&(i=(i=i+Math.imul(l,Z)|0)+Math.imul(f,V)|0))<<13)|0;u=((o=o+Math.imul(f,Z)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(v,z),i=(i=Math.imul(v,D))+Math.imul(_,z)|0,o=Math.imul(_,D),n=n+Math.imul(m,q)|0,i=(i=i+Math.imul(m,K)|0)+Math.imul(w,q)|0,o=o+Math.imul(w,K)|0,n=n+Math.imul(p,V)|0,i=(i=i+Math.imul(p,Z)|0)+Math.imul(g,V)|0,o=o+Math.imul(g,Z)|0;var be=(u+(n=n+Math.imul(l,J)|0)|0)+((8191&(i=(i=i+Math.imul(l,Y)|0)+Math.imul(f,J)|0))<<13)|0;u=((o=o+Math.imul(f,Y)|0)+(i>>>13)|0)+(be>>>26)|0,be&=67108863,n=Math.imul(S,z),i=(i=Math.imul(S,D))+Math.imul(A,z)|0,o=Math.imul(A,D),n=n+Math.imul(v,q)|0,i=(i=i+Math.imul(v,K)|0)+Math.imul(_,q)|0,o=o+Math.imul(_,K)|0,n=n+Math.imul(m,V)|0,i=(i=i+Math.imul(m,Z)|0)+Math.imul(w,V)|0,o=o+Math.imul(w,Z)|0,n=n+Math.imul(p,J)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(g,J)|0,o=o+Math.imul(g,Y)|0;var ve=(u+(n=n+Math.imul(l,Q)|0)|0)+((8191&(i=(i=i+Math.imul(l,ee)|0)+Math.imul(f,Q)|0))<<13)|0;u=((o=o+Math.imul(f,ee)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(k,z),i=(i=Math.imul(k,D))+Math.imul(B,z)|0,o=Math.imul(B,D),n=n+Math.imul(S,q)|0,i=(i=i+Math.imul(S,K)|0)+Math.imul(A,q)|0,o=o+Math.imul(A,K)|0,n=n+Math.imul(v,V)|0,i=(i=i+Math.imul(v,Z)|0)+Math.imul(_,V)|0,o=o+Math.imul(_,Z)|0,n=n+Math.imul(m,J)|0,i=(i=i+Math.imul(m,Y)|0)+Math.imul(w,J)|0,o=o+Math.imul(w,Y)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(g,Q)|0,o=o+Math.imul(g,ee)|0;var _e=(u+(n=n+Math.imul(l,re)|0)|0)+((8191&(i=(i=i+Math.imul(l,ne)|0)+Math.imul(f,re)|0))<<13)|0;u=((o=o+Math.imul(f,ne)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(T,z),i=(i=Math.imul(T,D))+Math.imul(R,z)|0,o=Math.imul(R,D),n=n+Math.imul(k,q)|0,i=(i=i+Math.imul(k,K)|0)+Math.imul(B,q)|0,o=o+Math.imul(B,K)|0,n=n+Math.imul(S,V)|0,i=(i=i+Math.imul(S,Z)|0)+Math.imul(A,V)|0,o=o+Math.imul(A,Z)|0,n=n+Math.imul(v,J)|0,i=(i=i+Math.imul(v,Y)|0)+Math.imul(_,J)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,ee)|0)+Math.imul(w,Q)|0,o=o+Math.imul(w,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(g,re)|0,o=o+Math.imul(g,ne)|0;var Ee=(u+(n=n+Math.imul(l,oe)|0)|0)+((8191&(i=(i=i+Math.imul(l,se)|0)+Math.imul(f,oe)|0))<<13)|0;u=((o=o+Math.imul(f,se)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(L,z),i=(i=Math.imul(L,D))+Math.imul(M,z)|0,o=Math.imul(M,D),n=n+Math.imul(T,q)|0,i=(i=i+Math.imul(T,K)|0)+Math.imul(R,q)|0,o=o+Math.imul(R,K)|0,n=n+Math.imul(k,V)|0,i=(i=i+Math.imul(k,Z)|0)+Math.imul(B,V)|0,o=o+Math.imul(B,Z)|0,n=n+Math.imul(S,J)|0,i=(i=i+Math.imul(S,Y)|0)+Math.imul(A,J)|0,o=o+Math.imul(A,Y)|0,n=n+Math.imul(v,Q)|0,i=(i=i+Math.imul(v,ee)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,ee)|0,n=n+Math.imul(m,re)|0,i=(i=i+Math.imul(m,ne)|0)+Math.imul(w,re)|0,o=o+Math.imul(w,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,se)|0)+Math.imul(g,oe)|0,o=o+Math.imul(g,se)|0;var Se=(u+(n=n+Math.imul(l,ce)|0)|0)+((8191&(i=(i=i+Math.imul(l,ue)|0)+Math.imul(f,ce)|0))<<13)|0;u=((o=o+Math.imul(f,ue)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(P,z),i=(i=Math.imul(P,D))+Math.imul(N,z)|0,o=Math.imul(N,D),n=n+Math.imul(L,q)|0,i=(i=i+Math.imul(L,K)|0)+Math.imul(M,q)|0,o=o+Math.imul(M,K)|0,n=n+Math.imul(T,V)|0,i=(i=i+Math.imul(T,Z)|0)+Math.imul(R,V)|0,o=o+Math.imul(R,Z)|0,n=n+Math.imul(k,J)|0,i=(i=i+Math.imul(k,Y)|0)+Math.imul(B,J)|0,o=o+Math.imul(B,Y)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,ee)|0)+Math.imul(A,Q)|0,o=o+Math.imul(A,ee)|0,n=n+Math.imul(v,re)|0,i=(i=i+Math.imul(v,ne)|0)+Math.imul(_,re)|0,o=o+Math.imul(_,ne)|0,n=n+Math.imul(m,oe)|0,i=(i=i+Math.imul(m,se)|0)+Math.imul(w,oe)|0,o=o+Math.imul(w,se)|0,n=n+Math.imul(p,ce)|0,i=(i=i+Math.imul(p,ue)|0)+Math.imul(g,ce)|0,o=o+Math.imul(g,ue)|0;var Ae=(u+(n=n+Math.imul(l,le)|0)|0)+((8191&(i=(i=i+Math.imul(l,fe)|0)+Math.imul(f,le)|0))<<13)|0;u=((o=o+Math.imul(f,fe)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(j,z),i=(i=Math.imul(j,D))+Math.imul($,z)|0,o=Math.imul($,D),n=n+Math.imul(P,q)|0,i=(i=i+Math.imul(P,K)|0)+Math.imul(N,q)|0,o=o+Math.imul(N,K)|0,n=n+Math.imul(L,V)|0,i=(i=i+Math.imul(L,Z)|0)+Math.imul(M,V)|0,o=o+Math.imul(M,Z)|0,n=n+Math.imul(T,J)|0,i=(i=i+Math.imul(T,Y)|0)+Math.imul(R,J)|0,o=o+Math.imul(R,Y)|0,n=n+Math.imul(k,Q)|0,i=(i=i+Math.imul(k,ee)|0)+Math.imul(B,Q)|0,o=o+Math.imul(B,ee)|0,n=n+Math.imul(S,re)|0,i=(i=i+Math.imul(S,ne)|0)+Math.imul(A,re)|0,o=o+Math.imul(A,ne)|0,n=n+Math.imul(v,oe)|0,i=(i=i+Math.imul(v,se)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,se)|0,n=n+Math.imul(m,ce)|0,i=(i=i+Math.imul(m,ue)|0)+Math.imul(w,ce)|0,o=o+Math.imul(w,ue)|0,n=n+Math.imul(p,le)|0,i=(i=i+Math.imul(p,fe)|0)+Math.imul(g,le)|0,o=o+Math.imul(g,fe)|0;var xe=(u+(n=n+Math.imul(l,pe)|0)|0)+((8191&(i=(i=i+Math.imul(l,ge)|0)+Math.imul(f,pe)|0))<<13)|0;u=((o=o+Math.imul(f,ge)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(j,q),i=(i=Math.imul(j,K))+Math.imul($,q)|0,o=Math.imul($,K),n=n+Math.imul(P,V)|0,i=(i=i+Math.imul(P,Z)|0)+Math.imul(N,V)|0,o=o+Math.imul(N,Z)|0,n=n+Math.imul(L,J)|0,i=(i=i+Math.imul(L,Y)|0)+Math.imul(M,J)|0,o=o+Math.imul(M,Y)|0,n=n+Math.imul(T,Q)|0,i=(i=i+Math.imul(T,ee)|0)+Math.imul(R,Q)|0,o=o+Math.imul(R,ee)|0,n=n+Math.imul(k,re)|0,i=(i=i+Math.imul(k,ne)|0)+Math.imul(B,re)|0,o=o+Math.imul(B,ne)|0,n=n+Math.imul(S,oe)|0,i=(i=i+Math.imul(S,se)|0)+Math.imul(A,oe)|0,o=o+Math.imul(A,se)|0,n=n+Math.imul(v,ce)|0,i=(i=i+Math.imul(v,ue)|0)+Math.imul(_,ce)|0,o=o+Math.imul(_,ue)|0,n=n+Math.imul(m,le)|0,i=(i=i+Math.imul(m,fe)|0)+Math.imul(w,le)|0,o=o+Math.imul(w,fe)|0;var ke=(u+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,ge)|0)+Math.imul(g,pe)|0))<<13)|0;u=((o=o+Math.imul(g,ge)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(j,V),i=(i=Math.imul(j,Z))+Math.imul($,V)|0,o=Math.imul($,Z),n=n+Math.imul(P,J)|0,i=(i=i+Math.imul(P,Y)|0)+Math.imul(N,J)|0,o=o+Math.imul(N,Y)|0,n=n+Math.imul(L,Q)|0,i=(i=i+Math.imul(L,ee)|0)+Math.imul(M,Q)|0,o=o+Math.imul(M,ee)|0,n=n+Math.imul(T,re)|0,i=(i=i+Math.imul(T,ne)|0)+Math.imul(R,re)|0,o=o+Math.imul(R,ne)|0,n=n+Math.imul(k,oe)|0,i=(i=i+Math.imul(k,se)|0)+Math.imul(B,oe)|0,o=o+Math.imul(B,se)|0,n=n+Math.imul(S,ce)|0,i=(i=i+Math.imul(S,ue)|0)+Math.imul(A,ce)|0,o=o+Math.imul(A,ue)|0,n=n+Math.imul(v,le)|0,i=(i=i+Math.imul(v,fe)|0)+Math.imul(_,le)|0,o=o+Math.imul(_,fe)|0;var Be=(u+(n=n+Math.imul(m,pe)|0)|0)+((8191&(i=(i=i+Math.imul(m,ge)|0)+Math.imul(w,pe)|0))<<13)|0;u=((o=o+Math.imul(w,ge)|0)+(i>>>13)|0)+(Be>>>26)|0,Be&=67108863,n=Math.imul(j,J),i=(i=Math.imul(j,Y))+Math.imul($,J)|0,o=Math.imul($,Y),n=n+Math.imul(P,Q)|0,i=(i=i+Math.imul(P,ee)|0)+Math.imul(N,Q)|0,o=o+Math.imul(N,ee)|0,n=n+Math.imul(L,re)|0,i=(i=i+Math.imul(L,ne)|0)+Math.imul(M,re)|0,o=o+Math.imul(M,ne)|0,n=n+Math.imul(T,oe)|0,i=(i=i+Math.imul(T,se)|0)+Math.imul(R,oe)|0,o=o+Math.imul(R,se)|0,n=n+Math.imul(k,ce)|0,i=(i=i+Math.imul(k,ue)|0)+Math.imul(B,ce)|0,o=o+Math.imul(B,ue)|0,n=n+Math.imul(S,le)|0,i=(i=i+Math.imul(S,fe)|0)+Math.imul(A,le)|0,o=o+Math.imul(A,fe)|0;var Ie=(u+(n=n+Math.imul(v,pe)|0)|0)+((8191&(i=(i=i+Math.imul(v,ge)|0)+Math.imul(_,pe)|0))<<13)|0;u=((o=o+Math.imul(_,ge)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,n=Math.imul(j,Q),i=(i=Math.imul(j,ee))+Math.imul($,Q)|0,o=Math.imul($,ee),n=n+Math.imul(P,re)|0,i=(i=i+Math.imul(P,ne)|0)+Math.imul(N,re)|0,o=o+Math.imul(N,ne)|0,n=n+Math.imul(L,oe)|0,i=(i=i+Math.imul(L,se)|0)+Math.imul(M,oe)|0,o=o+Math.imul(M,se)|0,n=n+Math.imul(T,ce)|0,i=(i=i+Math.imul(T,ue)|0)+Math.imul(R,ce)|0,o=o+Math.imul(R,ue)|0,n=n+Math.imul(k,le)|0,i=(i=i+Math.imul(k,fe)|0)+Math.imul(B,le)|0,o=o+Math.imul(B,fe)|0;var Te=(u+(n=n+Math.imul(S,pe)|0)|0)+((8191&(i=(i=i+Math.imul(S,ge)|0)+Math.imul(A,pe)|0))<<13)|0;u=((o=o+Math.imul(A,ge)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(j,re),i=(i=Math.imul(j,ne))+Math.imul($,re)|0,o=Math.imul($,ne),n=n+Math.imul(P,oe)|0,i=(i=i+Math.imul(P,se)|0)+Math.imul(N,oe)|0,o=o+Math.imul(N,se)|0,n=n+Math.imul(L,ce)|0,i=(i=i+Math.imul(L,ue)|0)+Math.imul(M,ce)|0,o=o+Math.imul(M,ue)|0,n=n+Math.imul(T,le)|0,i=(i=i+Math.imul(T,fe)|0)+Math.imul(R,le)|0,o=o+Math.imul(R,fe)|0;var Re=(u+(n=n+Math.imul(k,pe)|0)|0)+((8191&(i=(i=i+Math.imul(k,ge)|0)+Math.imul(B,pe)|0))<<13)|0;u=((o=o+Math.imul(B,ge)|0)+(i>>>13)|0)+(Re>>>26)|0,Re&=67108863,n=Math.imul(j,oe),i=(i=Math.imul(j,se))+Math.imul($,oe)|0,o=Math.imul($,se),n=n+Math.imul(P,ce)|0,i=(i=i+Math.imul(P,ue)|0)+Math.imul(N,ce)|0,o=o+Math.imul(N,ue)|0,n=n+Math.imul(L,le)|0,i=(i=i+Math.imul(L,fe)|0)+Math.imul(M,le)|0,o=o+Math.imul(M,fe)|0;var Oe=(u+(n=n+Math.imul(T,pe)|0)|0)+((8191&(i=(i=i+Math.imul(T,ge)|0)+Math.imul(R,pe)|0))<<13)|0;u=((o=o+Math.imul(R,ge)|0)+(i>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,n=Math.imul(j,ce),i=(i=Math.imul(j,ue))+Math.imul($,ce)|0,o=Math.imul($,ue),n=n+Math.imul(P,le)|0,i=(i=i+Math.imul(P,fe)|0)+Math.imul(N,le)|0,o=o+Math.imul(N,fe)|0;var Le=(u+(n=n+Math.imul(L,pe)|0)|0)+((8191&(i=(i=i+Math.imul(L,ge)|0)+Math.imul(M,pe)|0))<<13)|0;u=((o=o+Math.imul(M,ge)|0)+(i>>>13)|0)+(Le>>>26)|0,Le&=67108863,n=Math.imul(j,le),i=(i=Math.imul(j,fe))+Math.imul($,le)|0,o=Math.imul($,fe);var Me=(u+(n=n+Math.imul(P,pe)|0)|0)+((8191&(i=(i=i+Math.imul(P,ge)|0)+Math.imul(N,pe)|0))<<13)|0;u=((o=o+Math.imul(N,ge)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863;var Ce=(u+(n=Math.imul(j,pe))|0)+((8191&(i=(i=Math.imul(j,ge))+Math.imul($,pe)|0))<<13)|0;return u=((o=Math.imul($,ge))+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,c[0]=ye,c[1]=me,c[2]=we,c[3]=be,c[4]=ve,c[5]=_e,c[6]=Ee,c[7]=Se,c[8]=Ae,c[9]=xe,c[10]=ke,c[11]=Be,c[12]=Ie,c[13]=Te,c[14]=Re,c[15]=Oe,c[16]=Le,c[17]=Me,c[18]=Ce,0!==u&&(c[19]=u,r.length++),r};function y(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r._strip()}function m(e,t,r){return y(e,t,r)}Math.imul||(g=p),i.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?g(this,e,t):r<63?p(this,e,t):r<1024?y(this,e,t):m(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),m(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),r("number"==typeof e),r(e<67108864);for(var n=0,i=0;i>=26,n+=o/67108864|0,n+=s>>>26,this.words[i]=67108863&s}return 0!==n&&(this.words[i]=n,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()),r=0;r>>i&1}return t}(e);if(0===t.length)return new i(1);for(var r=this,n=0;n=0);var t,n=e%26,i=(e-n)/26,o=67108863>>>26-n<<26-n;if(0!==n){var s=0;for(t=0;t>>26-n}s&&(this.words[t]=s,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,s=Math.min((e-o)/26,this.length),a=67108863^67108863>>>o<s)for(this.length-=s,u=0;u=0&&(0!==h||u>=i);u--){var l=0|this.words[u];this.words[u]=h<<26-o|l>>>o,h=l&a}return c&&0!==h&&(c.words[c.length++]=h),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.ishrn=function(e,t,n){return r(0===this.negative),this.iushrn(e,t,n)},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){r("number"==typeof e&&e>=0);var t=e%26,n=(e-t)/26,i=1<=0);var t=e%26,n=(e-t)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==t&&n++,this.length=Math.min(n,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(r("number"==typeof e),r(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)-(c/67108864|0),this.words[i+n]=67108863&o}for(;i>26,this.words[i+n]=67108863&o;if(0===a)return this._strip();for(r(-1===a),a=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this._strip()},i.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),o=e,s=0|o.words[o.length-1];0!=(r=26-this._countBits(s))&&(o=o.ushln(r),n.iushln(r),s=0|o.words[o.length-1]);var a,c=n.length-o.length;if("mod"!==t){(a=new i(null)).length=c+1,a.words=new Array(a.length);for(var u=0;u=0;l--){var f=67108864*(0|n.words[o.length+l])+(0|n.words[o.length+l-1]);for(f=Math.min(f/s|0,67108863),n._ishlnsubmul(o,f,l);0!==n.negative;)f--,n.negative=0,n._ishlnsubmul(o,1,l),n.isZero()||(n.negative^=1);a&&(a.words[l]=f)}return a&&a._strip(),n._strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:a||null,mod:n}},i.prototype.divmod=function(e,t,n){return r(!e.isZero()),this.isZero()?{div:new i(0),mod:new i(0)}:0!==this.negative&&0===e.negative?(a=this.neg().divmod(e,t),"mod"!==t&&(o=a.div.neg()),"div"!==t&&(s=a.mod.neg(),n&&0!==s.negative&&s.iadd(e)),{div:o,mod:s}):0===this.negative&&0!==e.negative?(a=this.divmod(e.neg(),t),"mod"!==t&&(o=a.div.neg()),{div:o,mod:a.mod}):this.negative&e.negative?(a=this.neg().divmod(e.neg(),t),"div"!==t&&(s=a.mod.neg(),n&&0!==s.negative&&s.isub(e)),{div:a.div,mod:s}):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,s,a},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 r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);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),r(e<=67108863);for(var n=(1<<26)%e,i=0,o=this.length-1;o>=0;o--)i=(n*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),r(e<=67108863);for(var n=0,i=this.length-1;i>=0;i--){var o=(0|this.words[i])+67108864*n;this.words[i]=o/e|0,n=o%e}return this._strip(),t?this.ineg():this},i.prototype.divn=function(e){return this.clone().idivn(e)},i.prototype.egcd=function(e){r(0===e.negative),r(!e.isZero());var t=this,n=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var o=new i(1),s=new i(0),a=new i(0),c=new i(1),u=0;t.isEven()&&n.isEven();)t.iushrn(1),n.iushrn(1),++u;for(var h=n.clone(),l=t.clone();!t.isZero();){for(var f=0,d=1;!(t.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(t.iushrn(f);f-- >0;)(o.isOdd()||s.isOdd())&&(o.iadd(h),s.isub(l)),o.iushrn(1),s.iushrn(1);for(var p=0,g=1;!(n.words[0]&g)&&p<26;++p,g<<=1);if(p>0)for(n.iushrn(p);p-- >0;)(a.isOdd()||c.isOdd())&&(a.iadd(h),c.isub(l)),a.iushrn(1),c.iushrn(1);t.cmp(n)>=0?(t.isub(n),o.isub(a),s.isub(c)):(n.isub(t),a.isub(o),c.isub(s))}return{a:a,b:c,gcd:n.iushln(u)}},i.prototype._invmp=function(e){r(0===e.negative),r(!e.isZero());var t=this,n=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var o,s=new i(1),a=new i(0),c=n.clone();t.cmpn(1)>0&&n.cmpn(1)>0;){for(var u=0,h=1;!(t.words[0]&h)&&u<26;++u,h<<=1);if(u>0)for(t.iushrn(u);u-- >0;)s.isOdd()&&s.iadd(c),s.iushrn(1);for(var l=0,f=1;!(n.words[0]&f)&&l<26;++l,f<<=1);if(l>0)for(n.iushrn(l);l-- >0;)a.isOdd()&&a.iadd(c),a.iushrn(1);t.cmp(n)>=0?(t.isub(n),s.isub(a)):(n.isub(t),a.isub(s))}return(o=0===t.cmpn(1)?s:a).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(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},i.prototype.invm=function(e){return this.egcd(e).a.umod(e)},i.prototype.isEven=function(){return!(1&this.words[0])},i.prototype.isOdd=function(){return!(1&~this.words[0])},i.prototype.andln=function(e){return this.words[0]&e},i.prototype.bincn=function(e){r("number"==typeof e);var t=e%26,n=(e-t)/26,i=1<>>26,a&=67108863,this.words[s]=a}return 0!==o&&(this.words[s]=o,this.length++),this},i.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},i.prototype.cmpn=function(e){var t,n=e<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this._strip(),this.length>1)t=1;else{n&&(e=-e),r(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(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 A(e)},i.prototype.toRed=function(e){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},i.prototype.fromRed=function(){return r(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 r(!this.red,"Already a number in reduction context"),this._forceRed(e)},i.prototype.redAdd=function(e){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},i.prototype.redIAdd=function(e){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},i.prototype.redSub=function(e){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},i.prototype.redISub=function(e){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},i.prototype.redShl=function(e){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},i.prototype.redMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},i.prototype.redIMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(e){return r(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var w={k256:null,p224:null,p192:null,p25519:null};function b(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 v(){b.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function _(){b.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function E(){b.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function S(){b.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function A(e){if("string"==typeof e){var t=i._prime(e);this.m=t.p,this.prime=t}else r(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function x(e){A.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)}b.prototype._tmp=function(){var e=new i(null);return e.words=new Array(Math.ceil(this.n/13)),e},b.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},b.prototype.split=function(e,t){e.iushrn(this.n,0,t)},b.prototype.imulK=function(e){return e.imul(this.k)},n(v,b),v.prototype.split=function(e,t){for(var r=4194303,n=Math.min(e.length,9),i=0;i>>22,o=s}o>>>=22,e.words[i-10]=o,0===o&&e.length>10?e.length-=10:e.length-=9},v.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},i._prime=function(e){if(w[e])return w[e];var t;if("k256"===e)t=new v;else if("p224"===e)t=new _;else if("p192"===e)t=new E;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new S}return w[e]=t,t},A.prototype._verify1=function(e){r(0===e.negative,"red works only with positives"),r(e.red,"red works only with red numbers")},A.prototype._verify2=function(e,t){r(!(e.negative|t.negative),"red works only with positives"),r(e.red&&e.red===t.red,"red works only with red numbers")},A.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):(u(e,e.umod(this.m)._forceRed(this)),e)},A.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},A.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},A.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},A.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},A.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},A.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},A.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},A.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},A.prototype.isqr=function(e){return this.imul(e,e.clone())},A.prototype.sqr=function(e){return this.mul(e,e)},A.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(r(t%2==1),3===t){var n=this.m.add(new i(1)).iushrn(2);return this.pow(e,n)}for(var o=this.m.subn(1),s=0;!o.isZero()&&0===o.andln(1);)s++,o.iushrn(1);r(!o.isZero());var a=new i(1).toRed(this),c=a.redNeg(),u=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new i(2*h*h).toRed(this);0!==this.pow(h,u).cmp(c);)h.redIAdd(c);for(var l=this.pow(h,o),f=this.pow(e,o.addn(1).iushrn(1)),d=this.pow(e,o),p=s;0!==d.cmp(a);){for(var g=d,y=0;0!==g.cmp(a);y++)g=g.redSqr();r(y=0;n--){for(var u=t.words[n],h=c-1;h>=0;h--){var l=u>>h&1;o!==r[0]&&(o=this.sqr(o)),0!==l||0!==s?(s<<=1,s|=l,(4==++a||0===n&&0===h)&&(o=this.mul(o,r[s]),a=0,s=0)):a=0}c=26}return o},A.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},A.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},i.mont=function(e){return new x(e)},n(x,A),x.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},x.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},x.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).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)},x.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new i(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(n).iushrn(this.shift),s=o;return o.cmp(this.m)>=0?s=o.isub(this.m):o.cmpn(0)<0&&(s=o.iadd(this.m)),s._forceRed(this)},x.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}})(Nr,Cr);var jr=Nr.exports,$r={exports:{}}; /*! safe-buffer. MIT License. Feross Aboukhadijeh */ -!function(e,t){var r=Mr,n=r.Buffer;function i(e,t){for(var r in e)t[r]=e[r]}function o(e,t,r){return n(e,t,r)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?e.exports=r:(i(r,t),t.Buffer=o),o.prototype=Object.create(n.prototype),i(n,o),o.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return n(e,t,r)},o.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var i=n(e);return void 0!==t?"string"==typeof r?i.fill(t,r):i.fill(t):i.fill(0),i},o.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n(e)},o.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}}(Cr,Cr.exports);var Pr=Cr.exports.Buffer;var Nr=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r>>0,u=new Uint8Array(o);e[r];){var l=t[e.charCodeAt(r)];if(255===l)return;for(var h=0,f=o-1;(0!==l||h>>0,u[f]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,r++}for(var d=o-i;d!==o&&0===u[d];)d++;var p=Pr.allocUnsafe(n+(o-d));p.fill(0,0,n);for(var g=n;d!==o;)p[g++]=u[d++];return p}return{encode:function(t){if((Array.isArray(t)||t instanceof Uint8Array)&&(t=Pr.from(t)),!Pr.isBuffer(t))throw new TypeError("Expected Buffer");if(0===t.length)return"";for(var r=0,n=0,i=0,o=t.length;i!==o&&0===t[i];)i++,r++;for(var c=(o-i)*u+1>>>0,l=new Uint8Array(c);i!==o;){for(var h=t[i],f=0,d=c-1;(0!==h||f>>0,l[d]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error("Non-zero carry");n=f,i++}for(var p=c-n;p!==c&&0===l[p];)p++;for(var g=a.repeat(r);p>>3,i=Ve(r,17)^Ve(r,19)^r>>>10;zr[e]=i+zr[e-7]+n+zr[e-16]|0}let{A:r,B:n,C:i,D:o,E:s,F:a,G:c,H:u}=this;for(let e=0;e<64;e++){const t=u+(Ve(s,6)^Ve(s,11)^Ve(s,25))+et(s,a,c)+jr[e]+zr[e]|0,l=(Ve(r,2)^Ve(r,13)^Ve(r,22))+tt(r,n,i)|0;u=c,c=a,a=s,s=o+t|0,o=i,i=n,n=r,r=t+l|0}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(r,n,i,o,s,a,c,u)}roundClean(){zr.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Hr=Xe((()=>new Dr));var qr={};function Fr(e,t,r){return t<=e&&e<=r}function Kr(e){if(void 0===e)return{};if(e===Object(e))return e;throw TypeError("Could not convert argument to dictionary")}function Wr(e){this.tokens=[].slice.call(e)}Wr.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():-1},prepend:function(e){if(Array.isArray(e))for(var t=e;t.length;)this.tokens.unshift(t.pop());else this.tokens.unshift(e)},push:function(e){if(Array.isArray(e))for(var t=e;t.length;)this.tokens.push(t.shift());else this.tokens.push(e)}};var Vr=-1;function Zr(e,t){if(e)throw TypeError("Decoder error");return t||65533}var Gr="utf-8";function Jr(e,t){if(!(this instanceof Jr))return new Jr(e,t);if((e=void 0!==e?String(e).toLowerCase():Gr)!==Gr)throw new Error("Encoding not supported. Only utf-8 is supported");t=Kr(t),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=Boolean(t.fatal),this._ignoreBOM=Boolean(t.ignoreBOM),Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}function Yr(e,t){if(!(this instanceof Yr))return new Yr(e,t);if((e=void 0!==e?String(e).toLowerCase():Gr)!==Gr)throw new Error("Encoding not supported. Only utf-8 is supported");t=Kr(t),this._streaming=!1,this._encoder=null,this._options={fatal:Boolean(t.fatal)},Object.defineProperty(this,"encoding",{value:"utf-8"})}function Xr(e){var t=e.fatal,r=0,n=0,i=0,o=128,s=191;this.handler=function(e,a){if(-1===a&&0!==i)return i=0,Zr(t);if(-1===a)return Vr;if(0===i){if(Fr(a,0,127))return a;if(Fr(a,194,223))i=1,r=a-192;else if(Fr(a,224,239))224===a&&(o=160),237===a&&(s=159),i=2,r=a-224;else{if(!Fr(a,240,244))return Zr(t);240===a&&(o=144),244===a&&(s=143),i=3,r=a-240}return r<<=6*i,null}if(!Fr(a,o,s))return r=i=n=0,o=128,s=191,e.prepend(a),Zr(t);if(o=128,s=191,r+=a-128<<6*(i-(n+=1)),n!==i)return null;var c=r;return r=i=n=0,c}}function Qr(e){e.fatal,this.handler=function(e,t){if(-1===t)return Vr;if(Fr(t,0,127))return t;var r,n;Fr(t,128,2047)?(r=1,n=192):Fr(t,2048,65535)?(r=2,n=224):Fr(t,65536,1114111)&&(r=3,n=240);for(var i=[(t>>6*r)+n];r>0;){var o=t>>6*(r-1);i.push(128|63&o),r-=1}return i}}Jr.prototype={decode:function(e,t){var r;r="object"==typeof e&&e instanceof ArrayBuffer?new Uint8Array(e):"object"==typeof e&&"buffer"in e&&e.buffer instanceof ArrayBuffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(0),t=Kr(t),this._streaming||(this._decoder=new Xr({fatal:this._fatal}),this._BOMseen=!1),this._streaming=Boolean(t.stream);for(var n,i=new Wr(r),o=[];!i.endOfStream()&&(n=this._decoder.handler(i,i.read()))!==Vr;)null!==n&&(Array.isArray(n)?o.push.apply(o,n):o.push(n));if(!this._streaming){do{if((n=this._decoder.handler(i,i.read()))===Vr)break;null!==n&&(Array.isArray(n)?o.push.apply(o,n):o.push(n))}while(!i.endOfStream());this._decoder=null}return o.length&&(-1===["utf-8"].indexOf(this.encoding)||this._ignoreBOM||this._BOMseen||(65279===o[0]?(this._BOMseen=!0,o.shift()):this._BOMseen=!0)),function(e){for(var t="",r=0;r>10),56320+(1023&n)))}return t}(o)}},Yr.prototype={encode:function(e,t){e=e?String(e):"",t=Kr(t),this._streaming||(this._encoder=new Qr(this._options)),this._streaming=Boolean(t.stream);for(var r,n=[],i=new Wr(function(e){for(var t=String(e),r=t.length,n=0,i=[];n57343)i.push(o);else if(56320<=o&&o<=57343)i.push(65533);else if(55296<=o&&o<=56319)if(n===r-1)i.push(65533);else{var s=e.charCodeAt(n+1);if(56320<=s&&s<=57343){var a=1023&o,c=1023&s;i.push(65536+(a<<10)+c),n+=1}else i.push(65533)}n+=1}return i}(e));!i.endOfStream()&&(r=this._encoder.handler(i,i.read()))!==Vr;)Array.isArray(r)?n.push.apply(n,r):n.push(r);if(!this._streaming){for(;(r=this._encoder.handler(i,i.read()))!==Vr;)Array.isArray(r)?n.push.apply(n,r):n.push(r);this._encoder=null}return new Uint8Array(n)}};var en=Rr(Object.freeze({__proto__:null,TextEncoder:Yr,TextDecoder:Jr})),tn=Tr&&Tr.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),rn=Tr&&Tr.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),nn=Tr&&Tr.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},on=Tr&&Tr.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.hasOwnProperty.call(e,r)&&tn(t,e,r);return rn(t,e),t},sn=Tr&&Tr.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(qr,"__esModule",{value:!0});var an=qr.deserializeUnchecked=Sn=qr.deserialize=vn=qr.serialize=qr.BinaryReader=qr.BinaryWriter=qr.BorshError=qr.baseDecode=qr.baseEncode=void 0;const cn=sn(Or.exports),un=sn(Ur),ln=on(en),hn=new("function"!=typeof TextDecoder?ln.TextDecoder:TextDecoder)("utf-8",{fatal:!0});qr.baseEncode=function(e){return"string"==typeof e&&(e=C.from(e,"utf8")),un.default.encode(C.from(e))},qr.baseDecode=function(e){return C.from(un.default.decode(e))};const fn=1024;class dn extends Error{constructor(e){super(e),this.fieldPath=[],this.originalMessage=e}addToFieldPath(e){this.fieldPath.splice(0,0,e),this.message=this.originalMessage+": "+this.fieldPath.join(".")}}qr.BorshError=dn;class pn{constructor(){this.buf=C.alloc(fn),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=C.concat([this.buf,C.alloc(fn)]))}writeU8(e){this.maybeResize(),this.buf.writeUInt8(e,this.length),this.length+=1}writeU16(e){this.maybeResize(),this.buf.writeUInt16LE(e,this.length),this.length+=2}writeU32(e){this.maybeResize(),this.buf.writeUInt32LE(e,this.length),this.length+=4}writeU64(e){this.maybeResize(),this.writeBuffer(C.from(new cn.default(e).toArray("le",8)))}writeU128(e){this.maybeResize(),this.writeBuffer(C.from(new cn.default(e).toArray("le",16)))}writeU256(e){this.maybeResize(),this.writeBuffer(C.from(new cn.default(e).toArray("le",32)))}writeU512(e){this.maybeResize(),this.writeBuffer(C.from(new cn.default(e).toArray("le",64)))}writeBuffer(e){this.buf=C.concat([C.from(this.buf.subarray(0,this.length)),e,C.alloc(fn)]),this.length+=e.length}writeString(e){this.maybeResize();const t=C.from(e,"utf8");this.writeU32(t.length),this.writeBuffer(t)}writeFixedArray(e){this.writeBuffer(C.from(e))}writeArray(e,t){this.maybeResize(),this.writeU32(e.length);for(const r of e)this.maybeResize(),t(r)}toArray(){return this.buf.subarray(0,this.length)}}function gn(e,t,r){const n=r.value;r.value=function(...e){try{return n.apply(this,e)}catch(e){if(e instanceof RangeError){const t=e.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(t)>=0)throw new dn("Reached the end of buffer when deserializing")}throw e}}}qr.BinaryWriter=pn;class yn{constructor(e){this.buf=e,this.offset=0}readU8(){const e=this.buf.readUInt8(this.offset);return this.offset+=1,e}readU16(){const e=this.buf.readUInt16LE(this.offset);return this.offset+=2,e}readU32(){const e=this.buf.readUInt32LE(this.offset);return this.offset+=4,e}readU64(){const e=this.readBuffer(8);return new cn.default(e,"le")}readU128(){const e=this.readBuffer(16);return new cn.default(e,"le")}readU256(){const e=this.readBuffer(32);return new cn.default(e,"le")}readU512(){const e=this.readBuffer(64);return new cn.default(e,"le")}readBuffer(e){if(this.offset+e>this.buf.length)throw new dn(`Expected buffer length ${e} isn't within bounds`);const t=this.buf.slice(this.offset,this.offset+e);return this.offset+=e,t}readString(){const e=this.readU32(),t=this.readBuffer(e);try{return hn.decode(t)}catch(e){throw new dn(`Error decoding UTF-8 string: ${e}`)}}readFixedArray(e){return new Uint8Array(this.readBuffer(e))}readArray(e){const t=this.readU32(),r=Array();for(let n=0;n{wn(e,t,r,n[0],i)}));else if(void 0!==n.kind)switch(n.kind){case"option":null==r?i.writeU8(0):(i.writeU8(1),wn(e,t,r,n.type,i));break;case"map":i.writeU32(r.size),r.forEach(((r,o)=>{wn(e,t,o,n.key,i),wn(e,t,r,n.value,i)}));break;default:throw new dn(`FieldType ${n} unrecognized`)}else bn(e,r,i)}catch(e){throw e instanceof dn&&e.addToFieldPath(t),e}}function bn(e,t,r){if("function"==typeof t.borshSerialize)return void t.borshSerialize(r);const n=e.get(t.constructor);if(!n)throw new dn(`Class ${t.constructor.name} is missing in schema`);if("struct"===n.kind)n.fields.map((([n,i])=>{wn(e,n,t[n],i,r)}));else{if("enum"!==n.kind)throw new dn(`Unexpected schema kind: ${n.kind} for ${t.constructor.name}`);{const i=t[n.field];for(let o=0;o_n(e,t,r[0],n)))}if("option"===r.kind){return n.readU8()?_n(e,t,r.type,n):void 0}if("map"===r.kind){let i=new Map;const o=n.readU32();for(let s=0;s=n.values.length)throw new dn(`Enum index: ${i} is out of range`);const[o,s]=n.values[i],a=_n(e,o,s,r);return new t({[o]:a})}throw new dn(`Unexpected schema kind: ${n.kind} for ${t.constructor.name}`)}var Sn=qr.deserialize=function(e,t,r,n=yn){const i=new n(r),o=En(e,t,i);if(i.offsetthis.span)throw new RangeError("indeterminate span");return this.span}replicate(e){const t=Object.create(this.constructor.prototype);return Object.assign(t,this),t.property=e,t}fromArray(e){}}function Tn(e,t){return t.property?e+"["+t.property+"]":e}xn.Layout=Bn,xn.nameWithProperty=Tn,xn.bindConstructorLayout=function(e,t){if("function"!=typeof e)throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(e,"layout_"))throw new Error("Class is already bound to a layout");if(!(t&&t instanceof Bn))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(t,"boundConstructor_"))throw new Error("layout is already bound to a constructor");e.layout_=t,t.boundConstructor_=e,t.makeDestinationObject=()=>new e,Object.defineProperty(e.prototype,"encode",{value(e,r){return t.encode(this,e,r)},writable:!0}),Object.defineProperty(e,"decode",{value:(e,r)=>t.decode(e,r),writable:!0})};class Rn extends Bn{isCount(){throw new Error("ExternalLayout is abstract")}}xn.ExternalLayout=Rn;class On extends Rn{constructor(e=1,t){if(!Number.isInteger(e)||0>=e)throw new TypeError("elementSpan must be a (positive) integer");super(-1,t),this.elementSpan=e}isCount(){return!0}decode(e,t=0){kn(e);const r=e.length-t;return Math.floor(r/this.elementSpan)}encode(e,t,r){return 0}}xn.GreedyCount=On;class Mn extends Rn{constructor(e,t=0,r){if(!(e instanceof Bn))throw new TypeError("layout must be a Layout");if(!Number.isInteger(t))throw new TypeError("offset must be integer or undefined");super(e.span,r||e.property),this.layout=e,this.offset=t}isCount(){return this.layout instanceof Ln||this.layout instanceof Cn}decode(e,t=0){return this.layout.decode(e,t+this.offset)}encode(e,t,r=0){return this.layout.encode(e,t,r+this.offset)}}xn.OffsetLayout=Mn;class Ln extends Bn{constructor(e,t){if(super(e,t),6e+n.encode(i,t,r+e)),0);return this.count instanceof Rn&&this.count.encode(e.length,t,r),i}}xn.Sequence=Zn;class Gn extends Bn{constructor(e,t,r){if(!Array.isArray(e)||!e.reduce(((e,t)=>e&&t instanceof Bn),!0))throw new TypeError("fields must be array of Layout instances");"boolean"==typeof t&&void 0===r&&(r=t,t=void 0);for(const t of e)if(0>t.span&&void 0===t.property)throw new Error("fields cannot contain unnamed variable-length layout");let n=-1;try{n=e.reduce(((e,t)=>e+t.getSpan()),0)}catch(e){}super(n,t),this.fields=e,this.decodePrefixes=!!r}getSpan(e,t=0){if(0<=this.span)return this.span;let r=0;try{r=this.fields.reduce(((r,n)=>{const i=n.getSpan(e,t);return t+=i,r+i}),0)}catch(e){throw new RangeError("indeterminate span")}return r}decode(e,t=0){kn(e);const r=this.makeDestinationObject();for(const n of this.fields)if(void 0!==n.property&&(r[n.property]=n.decode(e,t)),t+=n.getSpan(e,t),this.decodePrefixes&&e.length===t)break;return r}encode(e,t,r=0){const n=r;let i=0,o=0;for(const n of this.fields){let s=n.span;if(o=0s&&(s=n.getSpan(t,r)))}i=r,r+=s}return i+o-n}fromArray(e){const t=this.makeDestinationObject();for(const r of this.fields)void 0!==r.property&&0r.span?t=-1:0<=t&&(t+=r.span)}}}xn.Structure=Gn;class Jn{constructor(e){this.property=e}decode(e,t){throw new Error("UnionDiscriminator is abstract")}encode(e,t,r){throw new Error("UnionDiscriminator is abstract")}}xn.UnionDiscriminator=Jn;class Yn extends Jn{constructor(e,t){if(!(e instanceof Rn&&e.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(t||e.property||"variant"),this.layout=e}decode(e,t){return this.layout.decode(e,t)}encode(e,t,r){return this.layout.encode(e,t,r)}}xn.UnionLayoutDiscriminator=Yn;class Xn extends Bn{constructor(e,t,r){let n;if(e instanceof Ln||e instanceof Cn)n=new Yn(new Mn(e));else if(e instanceof Rn&&e.isCount())n=new Yn(e);else{if(!(e instanceof Jn))throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");n=e}if(void 0===t&&(t=null),!(null===t||t instanceof Bn))throw new TypeError("defaultLayout must be null or a Layout");if(null!==t){if(0>t.span)throw new Error("defaultLayout must have constant span");void 0===t.property&&(t=t.replicate("content"))}let i=-1;t&&(i=t.span,0<=i&&(e instanceof Ln||e instanceof Cn)&&(i+=n.layout.span)),super(i,r),this.discriminator=n,this.usesPrefixDiscriminator=e instanceof Ln||e instanceof Cn,this.defaultLayout=t,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(e){return o(e)},this.configGetSourceVariant=function(e){o=e.bind(this)}}getSpan(e,t=0){if(0<=this.span)return this.span;const r=this.getVariant(e,t);if(!r)throw new Error("unable to determine span for unrecognized variant");return r.getSpan(e,t)}defaultGetSourceVariant(e){if(Object.prototype.hasOwnProperty.call(e,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(e,this.defaultLayout.property))return;const t=this.registry[e[this.discriminator.property]];if(t&&(!t.layout||t.property&&Object.prototype.hasOwnProperty.call(e,t.property)))return t}else for(const t in this.registry){const r=this.registry[t];if(r.property&&Object.prototype.hasOwnProperty.call(e,r.property))return r}throw new Error("unable to infer src variant")}decode(e,t=0){let r;const n=this.discriminator,i=n.decode(e,t),o=this.registry[i];if(void 0===o){const o=this.defaultLayout;let s=0;this.usesPrefixDiscriminator&&(s=n.layout.span),r=this.makeDestinationObject(),r[n.property]=i,r[o.property]=o.decode(e,t+s)}else r=o.decode(e,t);return r}encode(e,t,r=0){const n=this.getSourceVariant(e);if(void 0===n){const n=this.discriminator,i=this.defaultLayout;let o=0;return this.usesPrefixDiscriminator&&(o=n.layout.span),n.encode(e[n.property],t,r),o+i.encode(e[i.property],t,r+o)}return n.encode(e,t,r)}addVariant(e,t,r){const n=new Qn(this,e,t,r);return this.registry[e]=n,n}getVariant(e,t=0){let r;return r=e instanceof Uint8Array?this.discriminator.decode(e,t):e,this.registry[r]}}xn.Union=Xn;class Qn extends Bn{constructor(e,t,r,n){if(!(e instanceof Xn))throw new TypeError("union must be a Union");if(!Number.isInteger(t)||0>t)throw new TypeError("variant must be a (non-negative) integer");if("string"==typeof r&&void 0===n&&(n=r,r=null),r){if(!(r instanceof Bn))throw new TypeError("layout must be a Layout");if(null!==e.defaultLayout&&0<=r.span&&r.span>e.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if("string"!=typeof n)throw new TypeError("variant must have a String property")}let i=e.span;0>e.span&&(i=r?r.span:0,0<=i&&e.usesPrefixDiscriminator&&(i+=e.discriminator.layout.span)),super(i,n),this.union=e,this.variant=t,this.layout=r||null}getSpan(e,t=0){if(0<=this.span)return this.span;let r=0;this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span);let n=0;return this.layout&&(n=this.layout.getSpan(e,t+r)),r+n}decode(e,t=0){const r=this.makeDestinationObject();if(this!==this.union.getVariant(e,t))throw new Error("variant mismatch");let n=0;return this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span),this.layout?r[this.property]=this.layout.decode(e,t+n):this.property?r[this.property]=!0:this.union.usesPrefixDiscriminator&&(r[this.union.discriminator.property]=this.variant),r}encode(e,t,r=0){let n=0;if(this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(e,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,t,r);let i=n;if(this.layout&&(this.layout.encode(e[this.property],t,r+n),i+=this.layout.getSpan(t,r+n),0<=this.union.span&&i>this.union.span))throw new Error("encoded variant overruns containing union");return i}fromArray(e){if(this.layout)return this.layout.fromArray(e)}}function ei(e){return 0>e&&(e+=4294967296),e}xn.VariantLayout=Qn;class ti extends Bn{constructor(e,t,r){if(!(e instanceof Ln||e instanceof Cn))throw new TypeError("word must be a UInt or UIntBE layout");if("string"==typeof t&&void 0===r&&(r=t,t=!1),4=t)throw new TypeError("bits must be positive integer");const n=8*e.span,i=e.fields.reduce(((e,t)=>e+t.bits),0);if(t+i>n)throw new Error("bits too long for span remainder ("+(n-i)+" of "+n+" remain)");this.container=e,this.bits=t,this.valueMask=(1<>>this.start}encode(e){if("number"!=typeof e||!Number.isInteger(e)||e!==ei(e&this.valueMask))throw new TypeError(Tn("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const t=this.container._packedGetValue(),r=ei(e<r&&(r=this.length.decode(e,t)),r}decode(e,t=0){let r=this.span;return 0>r&&(r=this.length.decode(e,t)),In(e).slice(t,t+r)}encode(e,t,r){let n=this.length;if(this.length instanceof Rn&&(n=e.length),!(e instanceof Uint8Array&&n===e.length))throw new TypeError(Tn("Blob.encode",this)+" requires (length "+n+") Uint8Array as src");if(r+n>t.length)throw new RangeError("encoding overruns Uint8Array");const i=In(e);return In(t).write(i.toString("hex"),r,n,"hex"),this.length instanceof Rn&&this.length.encode(n,t,r),n}}xn.Blob=ii;class oi extends Bn{constructor(e){super(-1,e)}getSpan(e,t=0){kn(e);let r=t;for(;rt.length)throw new RangeError("encoding overruns Buffer");const o=In(t);return n.copy(o,r),o[r+i]=0,i+1}}xn.CString=oi;class si extends Bn{constructor(e,t){if("string"==typeof e&&void 0===t&&(t=e,e=void 0),void 0===e)e=-1;else if(!Number.isInteger(e))throw new TypeError("maxSpan must be an integer");super(-1,t),this.maxSpan=e}getSpan(e,t=0){return kn(e),e.length-t}decode(e,t=0){const r=this.getSpan(e,t);if(0<=this.maxSpan&&this.maxSpant.length)throw new RangeError("encoding overruns Buffer");return n.copy(In(t),r),i}}xn.UTF8=si;class ai extends Bn{constructor(e,t){super(0,t),this.value=e}decode(e,t){return this.value}encode(e,t,r){return 0}}xn.Constant=ai,xn.greedy=(e,t)=>new On(e,t);var ci=xn.offset=(e,t,r)=>new Mn(e,t,r),ui=xn.u8=e=>new Ln(1,e),li=xn.u16=e=>new Ln(2,e);xn.u24=e=>new Ln(3,e);var hi=xn.u32=e=>new Ln(4,e);xn.u40=e=>new Ln(5,e),xn.u48=e=>new Ln(6,e);var fi=xn.nu64=e=>new zn(e);xn.u16be=e=>new Cn(2,e),xn.u24be=e=>new Cn(3,e),xn.u32be=e=>new Cn(4,e),xn.u40be=e=>new Cn(5,e),xn.u48be=e=>new Cn(6,e),xn.nu64be=e=>new Dn(e),xn.s8=e=>new Pn(1,e),xn.s16=e=>new Pn(2,e),xn.s24=e=>new Pn(3,e),xn.s32=e=>new Pn(4,e),xn.s40=e=>new Pn(5,e),xn.s48=e=>new Pn(6,e);var di=xn.ns64=e=>new Hn(e);xn.s16be=e=>new Nn(2,e),xn.s24be=e=>new Nn(3,e),xn.s32be=e=>new Nn(4,e),xn.s40be=e=>new Nn(5,e),xn.s48be=e=>new Nn(6,e),xn.ns64be=e=>new qn(e),xn.f32=e=>new Fn(e),xn.f32be=e=>new Kn(e),xn.f64=e=>new Wn(e),xn.f64be=e=>new Vn(e);var pi=xn.struct=(e,t,r)=>new Gn(e,t,r);xn.bits=(e,t,r)=>new ti(e,t,r);var gi=xn.seq=(e,t,r)=>new Zn(e,t,r);xn.union=(e,t,r)=>new Xn(e,t,r),xn.unionLayoutDiscriminator=(e,t)=>new Yn(e,t);var yi=xn.blob=(e,t)=>new ii(e,t);xn.cstr=e=>new oi(e),xn.utf8=(e,t)=>new si(e,t),xn.constant=(e,t)=>new ai(e,t);var mi={};Object.defineProperty(mi,"__esModule",{value:!0});var wi=mi.toBigIntLE=function(e){{const t=C.from(e);t.reverse();const r=t.toString("hex");return 0===r.length?BigInt(0):BigInt(`0x${r}`)}};mi.toBigIntBE=function(e){{const t=e.toString("hex");return 0===t.length?BigInt(0):BigInt(`0x${t}`)}};var bi,vi=mi.toBufferLE=function(e,t){{const r=e.toString(16),n=C.from(r.padStart(2*t,"0").slice(0,2*t),"hex");return n.reverse(),n}};mi.toBufferBE=function(e,t){{const r=e.toString(16);return C.from(r.padStart(2*t,"0").slice(0,2*t),"hex")}};class _i extends TypeError{constructor(e,t){let r;const{message:n,...i}=e,{path:o}=e;super(0===o.length?n:"At path: "+o.join(".")+" -- "+n),Object.assign(this,i),this.name=this.constructor.name,this.failures=()=>{var n;return null!=(n=r)?n:r=[e,...t()]}}}function Ei(e){return"object"==typeof e&&null!=e}function Si(e){return"string"==typeof e?JSON.stringify(e):""+e}function xi(e,t,r,n){if(!0===e)return;!1===e?e={}:"string"==typeof e&&(e={message:e});const{path:i,branch:o}=t,{type:s}=r,{refinement:a,message:c="Expected a value of type `"+s+"`"+(a?" with refinement `"+a+"`":"")+", but received: `"+Si(n)+"`"}=e;return{value:n,type:s,refinement:a,key:i[i.length-1],path:i,branch:o,...e,message:c}}function*Ai(e,t,r,n){(function(e){return Ei(e)&&"function"==typeof e[Symbol.iterator]})(e)||(e=[e]);for(const i of e){const e=xi(i,t,r,n);e&&(yield e)}}function*ki(e,t,r={}){const{path:n=[],branch:i=[e],coerce:o=!1,mask:s=!1}=r,a={path:n,branch:i};if(o&&(e=t.coercer(e,a),s&&"type"!==t.type&&Ei(t.schema)&&Ei(e)&&!Array.isArray(e)))for(const r in e)void 0===t.schema[r]&&delete e[r];let c=!0;for(const r of t.validator(e,a))c=!1,yield[r,void 0];for(let[r,u,l]of t.entries(e,a)){const t=ki(u,l,{path:void 0===r?n:[...n,r],branch:void 0===r?i:[...i,u],coerce:o,mask:s});for(const n of t)n[0]?(c=!1,yield[n[0],void 0]):o&&(u=n[1],void 0===r?e=u:e instanceof Map?e.set(r,u):e instanceof Set?e.add(u):Ei(e)&&(e[r]=u))}if(c)for(const r of t.refiner(e,a))c=!1,yield[r,void 0];c&&(yield[void 0,e])}class Ii{constructor(e){const{type:t,schema:r,validator:n,refiner:i,coercer:o=e=>e,entries:s=function*(){}}=e;this.type=t,this.schema=r,this.entries=s,this.coercer=o,this.validator=n?(e,t)=>Ai(n(e,t),t,this,e):()=>[],this.refiner=i?(e,t)=>Ai(i(e,t),t,this,e):()=>[]}assert(e){return function(e,t){const r=Ri(e,t);if(r[0])throw r[0]}(e,this)}create(e){return Bi(e,this)}is(e){return Ti(e,this)}mask(e){return function(e,t){const r=Ri(e,t,{coerce:!0,mask:!0});if(r[0])throw r[0];return r[1]}(e,this)}validate(e,t={}){return Ri(e,this,t)}}function Bi(e,t){const r=Ri(e,t,{coerce:!0});if(r[0])throw r[0];return r[1]}function Ti(e,t){return!Ri(e,t)[0]}function Ri(e,t,r={}){const n=ki(e,t,r),i=function(e){const{done:t,value:r}=e.next();return t?void 0:r}(n);if(i[0]){const e=new _i(i[0],(function*(){for(const e of n)e[0]&&(yield e[0])}));return[e,void 0]}return[void 0,i[1]]}function Oi(e,t){return new Ii({type:e,schema:null,validator:t})}function Mi(e){return new Ii({type:"array",schema:e,*entries(t){if(e&&Array.isArray(t))for(const[r,n]of t.entries())yield[r,n,e]},coercer:e=>Array.isArray(e)?e.slice():e,validator:e=>Array.isArray(e)||"Expected an array value, but received: "+Si(e)})}function Li(){return Oi("boolean",(e=>"boolean"==typeof e))}function Ci(e){return Oi("instance",(t=>t instanceof e||"Expected a `"+e.name+"` instance, but received: "+Si(t)))}function Pi(e){const t=Si(e),r=typeof e;return new Ii({type:"literal",schema:"string"===r||"number"===r||"boolean"===r?e:null,validator:r=>r===e||"Expected the literal `"+t+"`, but received: "+Si(r)})}function Ni(e){return new Ii({...e,validator:(t,r)=>null===t||e.validator(t,r),refiner:(t,r)=>null===t||e.refiner(t,r)})}function Ui(){return Oi("number",(e=>"number"==typeof e&&!isNaN(e)||"Expected a number, but received: "+Si(e)))}function ji(e){return new Ii({...e,validator:(t,r)=>void 0===t||e.validator(t,r),refiner:(t,r)=>void 0===t||e.refiner(t,r)})}function $i(e,t){return new Ii({type:"record",schema:null,*entries(r){if(Ei(r))for(const n in r){const i=r[n];yield[n,n,e],yield[n,i,t]}},validator:e=>Ei(e)||"Expected an object, but received: "+Si(e)})}function zi(){return Oi("string",(e=>"string"==typeof e||"Expected a string, but received: "+Si(e)))}function Di(e){const t=Oi("never",(()=>!1));return new Ii({type:"tuple",schema:null,*entries(r){if(Array.isArray(r)){const n=Math.max(e.length,r.length);for(let i=0;iArray.isArray(e)||"Expected an array, but received: "+Si(e)})}function Hi(e){const t=Object.keys(e);return new Ii({type:"type",schema:e,*entries(r){if(Ei(r))for(const n of t)yield[n,r[n],e[n]]},validator:e=>Ei(e)||"Expected an object, but received: "+Si(e)})}function qi(e){const t=e.map((e=>e.type)).join(" | ");return new Ii({type:"union",schema:null,validator(r,n){const i=[];for(const t of e){const[...e]=ki(r,t,n),[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: "+Si(r),...i]}})}function Fi(){return Oi("unknown",(()=>!0))}function Ki(e,t,r){return new Ii({...e,coercer:(n,i)=>Ti(n,t)?e.coercer(r(n,i),i):e.coercer(n,i)})}var Wi=new Uint8Array(16);function Vi(){if(!bi&&!(bi="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 bi(Wi)}var Zi=/^(?:[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 Gi(e){return"string"==typeof e&&Zi.test(e)}for(var Ji,Yi,Xi=[],Qi=0;Qi<256;++Qi)Xi.push((Qi+256).toString(16).substr(1));function eo(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(Xi[e[t+0]]+Xi[e[t+1]]+Xi[e[t+2]]+Xi[e[t+3]]+"-"+Xi[e[t+4]]+Xi[e[t+5]]+"-"+Xi[e[t+6]]+Xi[e[t+7]]+"-"+Xi[e[t+8]]+Xi[e[t+9]]+"-"+Xi[e[t+10]]+Xi[e[t+11]]+Xi[e[t+12]]+Xi[e[t+13]]+Xi[e[t+14]]+Xi[e[t+15]]).toLowerCase();if(!Gi(r))throw TypeError("Stringified UUID is invalid");return r}var to=0,ro=0;function no(e){if(!Gi(e))throw TypeError("Invalid UUID");var t,r=new Uint8Array(16);return r[0]=(t=parseInt(e.slice(0,8),16))>>>24,r[1]=t>>>16&255,r[2]=t>>>8&255,r[3]=255&t,r[4]=(t=parseInt(e.slice(9,13),16))>>>8,r[5]=255&t,r[6]=(t=parseInt(e.slice(14,18),16))>>>8,r[7]=255&t,r[8]=(t=parseInt(e.slice(19,23),16))>>>8,r[9]=255&t,r[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,r[11]=t/4294967296&255,r[12]=t>>>24&255,r[13]=t>>>16&255,r[14]=t>>>8&255,r[15]=255&t,r}function io(e,t,r){function n(e,n,i,o){if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));for(var t=[],r=0;r>>9<<4)+1}function so(e,t){var r=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(r>>16)<<16|65535&r}function ao(e,t,r,n,i,o){return so((s=so(so(t,e),so(n,o)))<<(a=i)|s>>>32-a,r);var s,a}function co(e,t,r,n,i,o,s){return ao(t&r|~t&n,e,t,i,o,s)}function uo(e,t,r,n,i,o,s){return ao(t&n|r&~n,e,t,i,o,s)}function lo(e,t,r,n,i,o,s){return ao(t^r^n,e,t,i,o,s)}function ho(e,t,r,n,i,o,s){return ao(r^(t|~n),e,t,i,o,s)}var fo=io("v3",48,(function(e){if("string"==typeof e){var t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(var r=0;r>5]>>>i%32&255,s=parseInt(n.charAt(o>>>4&15)+n.charAt(15&o),16);t.push(s)}return t}(function(e,t){e[t>>5]|=128<>5]|=(255&e[n/8])<>>32-t}var mo=io("v5",80,(function(e){var t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof e){var n=unescape(encodeURIComponent(e));e=[];for(var i=0;i>>0;b=w,w=m,m=yo(y,30)>>>0,y=g,g=E}r[0]=r[0]+g>>>0,r[1]=r[1]+y>>>0,r[2]=r[2]+m>>>0,r[3]=r[3]+w>>>0,r[4]=r[4]+b>>>0}return[r[0]>>24&255,r[0]>>16&255,r[0]>>8&255,255&r[0],r[1]>>24&255,r[1]>>16&255,r[1]>>8&255,255&r[1],r[2]>>24&255,r[2]>>16&255,r[2]>>8&255,255&r[2],r[3]>>24&255,r[3]>>16&255,r[3]>>8&255,255&r[3],r[4]>>24&255,r[4]>>16&255,r[4]>>8&255,255&r[4]]})),wo=mo;var bo=Object.freeze({__proto__:null,v1:function(e,t,r){var n=t&&r||0,i=t||new Array(16),o=(e=e||{}).node||Ji,s=void 0!==e.clockseq?e.clockseq:Yi;if(null==o||null==s){var a=e.random||(e.rng||Vi)();null==o&&(o=Ji=[1|a[0],a[1],a[2],a[3],a[4],a[5]]),null==s&&(s=Yi=16383&(a[6]<<8|a[7]))}var c=void 0!==e.msecs?e.msecs:Date.now(),u=void 0!==e.nsecs?e.nsecs:ro+1,l=c-to+(u-ro)/1e4;if(l<0&&void 0===e.clockseq&&(s=s+1&16383),(l<0||c>to)&&void 0===e.nsecs&&(u=0),u>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");to=c,ro=u,Yi=s;var h=(1e4*(268435455&(c+=122192928e5))+u)%4294967296;i[n++]=h>>>24&255,i[n++]=h>>>16&255,i[n++]=h>>>8&255,i[n++]=255&h;var f=c/4294967296*1e4&268435455;i[n++]=f>>>8&255,i[n++]=255&f,i[n++]=f>>>24&15|16,i[n++]=f>>>16&255,i[n++]=s>>>8|128,i[n++]=255&s;for(var d=0;d<6;++d)i[n+d]=o[d];return t||eo(i)},v3:po,v4:function(e,t,r){var n=(e=e||{}).random||(e.rng||Vi)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){r=r||0;for(var i=0;i<16;++i)t[r+i]=n[i];return t}return eo(n)},v5:wo,NIL:"00000000-0000-0000-0000-000000000000",version:function(e){if(!Gi(e))throw TypeError("Invalid UUID");return parseInt(e.substr(14,1),16)},validate:Gi,stringify:eo,parse:no}),vo=Rr(bo);const _o=vo.v4;var Eo=function(e,t,r,n){if("string"!=typeof e)throw new TypeError(e+" must be a string");const i="number"==typeof(n=n||{}).version?n.version:2;if(1!==i&&2!==i)throw new TypeError(i+" must be 1 or 2");const o={method:e};if(2===i&&(o.jsonrpc="2.0"),t){if("object"!=typeof t&&!Array.isArray(t))throw new TypeError(t+" must be an object, array or omitted");o.params=t}if(void 0===r){const e="function"==typeof n.generator?n.generator:function(){return _o()};o.id=e(o,n)}else 2===i&&null===r?n.notificationIdNull&&(o.id=null):o.id=r;return o};const So=vo.v4,xo=Eo,Ao=function(e,t){if(!(this instanceof Ao))return new Ao(e,t);t||(t={}),this.options={reviver:void 0!==t.reviver?t.reviver:null,replacer:void 0!==t.replacer?t.replacer:null,generator:void 0!==t.generator?t.generator:function(){return So()},version:void 0!==t.version?t.version:2,notificationIdNull:"boolean"==typeof t.notificationIdNull&&t.notificationIdNull},this.callServer=e};var ko=Ao;Ao.prototype.request=function(e,t,r,n){const i=this;let o=null;const s=Array.isArray(e)&&"function"==typeof t;if(1===this.options.version&&s)throw new TypeError("JSON-RPC 1.0 does not support batching");if(s||!s&&e&&"object"==typeof e&&"function"==typeof t)n=t,o=e;else{"function"==typeof r&&(n=r,r=void 0);const i="function"==typeof n;try{o=xo(e,t,r,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(e){if(i)return n(e);throw e}if(!i)return o}let a;try{a=JSON.stringify(o,this.options.replacer)}catch(e){return n(e)}return this.callServer(a,(function(e,t){i._parseResponse(e,t,n)})),o},Ao.prototype._parseResponse=function(e,t,r){if(e)return void r(e);if(!t)return r();let n;try{n=JSON.parse(t,this.options.reviver)}catch(e){return r(e)}if(3===r.length){if(Array.isArray(n)){const e=function(e){return void 0!==e.error},t=function(t){return!e(t)};return r(null,n.filter(e),n.filter(t))}return r(null,n.error,n.result)}r(null,n)};var Io={},Bo={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,r="~";function n(){}function i(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function o(e,t,n,o,s){if("function"!=typeof n)throw new TypeError("The listener must be a function");var a=new i(n,o||e,s),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],a]:e._events[c].push(a):(e._events[c]=a,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function a(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),a.prototype.eventNames=function(){var e,n,i=[];if(0===this._eventsCount)return i;for(n in e=this._events)t.call(e,n)&&i.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},a.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,o=n.length,s=new Array(o);i++this.rpc_id),this.dataPack=c||new Mo.DefaultDataPack,this.autoconnect&&this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}connect(){this.socket||this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}call(e,t,r,n){return n||"object"!=typeof r||(n=r,r=null),new Promise(((i,o)=>{if(!this.ready)return o(new Error("socket not ready"));const s=this.generate_request_id(e,t),a={jsonrpc:"2.0",method:e,params:t||void 0,id:s};this.socket.send(this.dataPack.encode(a),n,(e=>{if(e)return o(e);this.queue[s]={promise:[i,o]},r&&(this.queue[s].timeout=setTimeout((()=>{delete this.queue[s],o(new Error("reply timeout"))}),r))}))}))}async login(e){const t=await this.call("rpc.login",e);if(!t)throw new Error("authentication failed");return t}async listMethods(){return await this.call("__listMethods")}notify(e,t){return new Promise(((r,n)=>{if(!this.ready)return n(new Error("socket not ready"));const i={jsonrpc:"2.0",method:e,params:t};this.socket.send(this.dataPack.encode(i),(e=>{if(e)return n(e);r()}))}))}async subscribe(e){"string"==typeof e&&(e=[e]);const t=await this.call("rpc.on",e);if("string"==typeof e&&"ok"!==t[e])throw new Error("Failed subscribing to an event '"+e+"' with: "+t[e]);return t}async unsubscribe(e){"string"==typeof e&&(e=[e]);const t=await this.call("rpc.off",e);if("string"==typeof e&&"ok"!==t[e])throw new Error("Failed unsubscribing from an event with: "+t);return t}close(e,t){this.socket.close(e||1e3,t)}setAutoReconnect(e){this.reconnect=e}setReconnectInterval(e){this.reconnect_interval=e}setMaxReconnects(e){this.max_reconnects=e}_connect(e,t){clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(e,t),this.socket.addEventListener("open",(()=>{this.ready=!0,this.emit("open"),this.current_reconnects=0})),this.socket.addEventListener("message",(({data:e})=>{e instanceof ArrayBuffer&&(e=C.from(e).toString());try{e=this.dataPack.decode(e)}catch(e){return}if(e.notification&&this.listeners(e.notification).length){if(!Object.keys(e.params).length)return this.emit(e.notification);const t=[e.notification];if(e.params.constructor===Object)t.push(e.params);else for(let r=0;r{this.emit.apply(this,t)}))}if(!this.queue[e.id])return e.method?Promise.resolve().then((()=>{this.emit(e.method,e?.params)})):void 0;"error"in e=="result"in e&&this.queue[e.id].promise[1](new Error('Server response malformed. Response must include either "result" or "error", but not both.')),this.queue[e.id].timeout&&clearTimeout(this.queue[e.id].timeout),e.error?this.queue[e.id].promise[1](e.error):this.queue[e.id].promise[0](e.result),delete this.queue[e.id]})),this.socket.addEventListener("error",(e=>this.emit("error",e))),this.socket.addEventListener("close",(({code:r,reason:n})=>{this.ready&&setTimeout((()=>this.emit("close",r,n)),0),this.ready=!1,this.socket=void 0,1e3!==r&&(this.current_reconnects++,this.reconnect&&(this.max_reconnects>this.current_reconnects||0===this.max_reconnects)&&(this.reconnect_timer_id=setTimeout((()=>this._connect(e,t)),this.reconnect_interval)))}))}}var Co=Io.default=Lo,Po={};Object.defineProperty(Po,"__esModule",{value:!0});const No=Bo.exports;class Uo extends No.EventEmitter{socket;constructor(e,t,r){super(),this.socket=new window.WebSocket(e,r),this.socket.onopen=()=>this.emit("open"),this.socket.onmessage=e=>this.emit("message",e.data),this.socket.onerror=e=>this.emit("error",e),this.socket.onclose=e=>{this.emit("close",e.code,e.reason)}}send(e,t,r){const n=r||t;try{this.socket.send(e),n()}catch(e){n(e)}}close(e,t){this.socket.close(e,t)}addEventListener(e,t,r){this.socket.addEventListener(e,t,r)}}var jo=Po.default=function(e,t){return new Uo(e,t)};const $o=[],zo=BigInt(0),Do=BigInt(1),Ho=BigInt(2),qo=BigInt(7),Fo=BigInt(256),Ko=BigInt(113);for(let e=0,t=Do,r=1,n=0;e<24;e++){[r,n]=[n,(2*r+3*n)%5];let e=zo;for(let r=0;r<7;r++)t=(t<>qo)*Ko)%Fo,t&Ho&&(e^=Do<<(Do<8&Number.parseInt(e[0],16)?"00"+e:e,r=e=>{const t=e.toString(16);return 1&t.length?`0${t}`:t},n=t(r(e.s)),i=t(r(e.r)),o=n.length/2,s=i.length/2,a=r(o),c=r(s);return`30${r(s+o+4)}02${c}${i}02${a}${n}`}},Go=BigInt(0),Jo=BigInt(1);BigInt(2);const Yo=BigInt(3);function Xo(e){const t=function(e){const t=ur(e);Dt(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:r,Fp:n,a:i}=t;if(r){if(!n.eql(i,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!=typeof r||"bigint"!=typeof r.beta||"function"!=typeof r.splitScalar)throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}(e),{Fp:r}=t,n=t.toBytes||((e,t,n)=>{const i=t.toAffine();return Pt(Uint8Array.from([4]),r.toBytes(i.x),r.toBytes(i.y))}),i=t.fromBytes||(e=>{const t=e.subarray(1);return{x:r.fromBytes(t.subarray(0,r.BYTES)),y:r.fromBytes(t.subarray(r.BYTES,2*r.BYTES))}});function o(e){const{a:n,b:i}=t,o=r.sqr(e),s=r.mul(o,e);return r.add(r.add(s,r.mul(e,n)),i)}if(!r.eql(r.sqr(t.Gy),o(t.Gx)))throw new Error("bad generator point: equation left != right");function s(e){return"bigint"==typeof e&&Gor.eql(e,r.ZERO);return i(t)&&i(n)?h.ZERO:new h(t,n,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){const t=r.invertBatch(e.map((e=>e.pz)));return e.map(((e,r)=>e.toAffine(t[r]))).map(h.fromAffine)}static fromHex(e){const t=h.fromAffine(i(Ct("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return h.BASE.multiply(c(e))}_setWindowSize(e){this._WINDOW_SIZE=e,u.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!r.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:e,y:n}=this.toAffine();if(!r.isValid(e)||!r.isValid(n))throw new Error("bad point: x or y not FE");const i=r.sqr(n),s=o(e);if(!r.eql(i,s))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:e}=this.toAffine();if(r.isOdd)return!r.isOdd(e);throw new Error("Field doesn't support isOdd")}equals(e){l(e);const{px:t,py:n,pz:i}=this,{px:o,py:s,pz:a}=e,c=r.eql(r.mul(t,a),r.mul(o,i)),u=r.eql(r.mul(n,a),r.mul(s,i));return c&&u}negate(){return new h(this.px,r.neg(this.py),this.pz)}double(){const{a:e,b:n}=t,i=r.mul(n,Yo),{px:o,py:s,pz:a}=this;let c=r.ZERO,u=r.ZERO,l=r.ZERO,f=r.mul(o,o),d=r.mul(s,s),p=r.mul(a,a),g=r.mul(o,s);return g=r.add(g,g),l=r.mul(o,a),l=r.add(l,l),c=r.mul(e,l),u=r.mul(i,p),u=r.add(c,u),c=r.sub(d,u),u=r.add(d,u),u=r.mul(c,u),c=r.mul(g,c),l=r.mul(i,l),p=r.mul(e,p),g=r.sub(f,p),g=r.mul(e,g),g=r.add(g,l),l=r.add(f,f),f=r.add(l,f),f=r.add(f,p),f=r.mul(f,g),u=r.add(u,f),p=r.mul(s,a),p=r.add(p,p),f=r.mul(p,g),c=r.sub(c,f),l=r.mul(p,d),l=r.add(l,l),l=r.add(l,l),new h(c,u,l)}add(e){l(e);const{px:n,py:i,pz:o}=this,{px:s,py:a,pz:c}=e;let u=r.ZERO,f=r.ZERO,d=r.ZERO;const p=t.a,g=r.mul(t.b,Yo);let y=r.mul(n,s),m=r.mul(i,a),w=r.mul(o,c),b=r.add(n,i),v=r.add(s,a);b=r.mul(b,v),v=r.add(y,m),b=r.sub(b,v),v=r.add(n,o);let _=r.add(s,c);return v=r.mul(v,_),_=r.add(y,w),v=r.sub(v,_),_=r.add(i,o),u=r.add(a,c),_=r.mul(_,u),u=r.add(m,w),_=r.sub(_,u),d=r.mul(p,v),u=r.mul(g,w),d=r.add(u,d),u=r.sub(m,d),d=r.add(m,d),f=r.mul(u,d),m=r.add(y,y),m=r.add(m,y),w=r.mul(p,w),v=r.mul(g,v),m=r.add(m,w),w=r.sub(y,w),w=r.mul(p,w),v=r.add(v,w),y=r.mul(m,v),f=r.add(f,y),y=r.mul(_,v),u=r.mul(b,u),u=r.sub(u,y),y=r.mul(b,m),d=r.mul(_,d),d=r.add(d,y),new h(u,f,d)}subtract(e){return this.add(e.negate())}is0(){return this.equals(h.ZERO)}wNAF(e){return d.wNAFCached(this,u,e,(e=>{const t=r.invertBatch(e.map((e=>e.pz)));return e.map(((e,r)=>e.toAffine(t[r]))).map(h.fromAffine)}))}multiplyUnsafe(e){const n=h.ZERO;if(e===Go)return n;if(a(e),e===Jo)return this;const{endo:i}=t;if(!i)return d.unsafeLadder(this,e);let{k1neg:o,k1:s,k2neg:c,k2:u}=i.splitScalar(e),l=n,f=n,p=this;for(;s>Go||u>Go;)s&Jo&&(l=l.add(p)),u&Jo&&(f=f.add(p)),p=p.double(),s>>=Jo,u>>=Jo;return o&&(l=l.negate()),c&&(f=f.negate()),f=new h(r.mul(f.px,i.beta),f.py,f.pz),l.add(f)}multiply(e){a(e);let n,i,o=e;const{endo:s}=t;if(s){const{k1neg:e,k1:t,k2neg:a,k2:c}=s.splitScalar(o);let{p:u,f:l}=this.wNAF(t),{p:f,f:p}=this.wNAF(c);u=d.constTimeNegate(e,u),f=d.constTimeNegate(a,f),f=new h(r.mul(f.px,s.beta),f.py,f.pz),n=u.add(f),i=l.add(p)}else{const{p:e,f:t}=this.wNAF(o);n=e,i=t}return h.normalizeZ([n,i])[0]}multiplyAndAddUnsafe(e,t,r){const n=h.BASE,i=(e,t)=>t!==Go&&t!==Jo&&e.equals(n)?e.multiply(t):e.multiplyUnsafe(t),o=i(this,t).add(i(e,r));return o.is0()?void 0:o}toAffine(e){const{px:t,py:n,pz:i}=this,o=this.is0();null==e&&(e=o?r.ONE:r.inv(i));const s=r.mul(t,e),a=r.mul(n,e),c=r.mul(i,e);if(o)return{x:r.ZERO,y:r.ZERO};if(!r.eql(c,r.ONE))throw new Error("invZ was invalid");return{x:s,y:a}}isTorsionFree(){const{h:e,isTorsionFree:r}=t;if(e===Jo)return!0;if(r)return r(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:r}=t;return e===Jo?this:r?r(h,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return this.assertValidity(),n(h,this,e)}toHex(e=!0){return bt(this.toRawBytes(e))}}h.BASE=new h(t.Gx,t.Gy,r.ONE),h.ZERO=new h(r.ZERO,r.ONE,r.ZERO);const f=t.nBitLength,d=cr(h,t.endo?Math.ceil(f/2):f);return{CURVE:t,ProjectivePoint:h,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:s}}function Qo(e){const t=function(e){const t=ur(e);return Dt(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}(e),{Fp:r,n:n}=t,i=r.BYTES+1,o=2*r.BYTES+1;function s(e){return Jt(e,n)}function a(e){return Qt(e,n)}const{ProjectivePoint:c,normPrivateKeyToScalar:u,weierstrassEquation:l,isWithinCurveOrder:h}=Xo({...t,toBytes(e,t,n){const i=t.toAffine(),o=r.toBytes(i.x),s=Pt;return n?s(Uint8Array.from([t.hasEvenY()?2:3]),o):s(Uint8Array.from([4]),o,r.toBytes(i.y))},fromBytes(e){const t=e.length,n=e[0],s=e.subarray(1);if(t!==i||2!==n&&3!==n){if(t===o&&4===n){return{x:r.fromBytes(s.subarray(0,r.BYTES)),y:r.fromBytes(s.subarray(r.BYTES,2*r.BYTES))}}throw new Error(`Point of length ${t} was invalid. Expected ${i} compressed bytes or ${o} uncompressed bytes`)}{const e=Rt(s);if(!(Go<(a=e)&&abt(Mt(e,t.nByteLength));function d(e){return e>n>>Jo}const p=(e,t,r)=>Rt(e.slice(t,r));class g{constructor(e,t,r){this.r=e,this.s=t,this.recovery=r,this.assertValidity()}static fromCompact(e){const r=t.nByteLength;return e=Ct("compactSignature",e,2*r),new g(p(e,0,r),p(e,r,2*r))}static fromDER(e){const{r:t,s:r}=Zo.toSig(Ct("DER",e));return new g(t,r)}assertValidity(){if(!h(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!h(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(e){return new g(this.r,this.s,e)}recoverPublicKey(e){const{r:n,s:i,recovery:o}=this,u=b(Ct("msgHash",e));if(null==o||![0,1,2,3].includes(o))throw new Error("recovery id invalid");const l=2===o||3===o?n+t.n:n;if(l>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");const h=1&o?"03":"02",d=c.fromHex(h+f(l)),p=a(l),g=s(-u*p),y=s(i*p),m=c.BASE.multiplyAndAddUnsafe(d,g,y);if(!m)throw new Error("point at infinify");return m.assertValidity(),m}hasHighS(){return d(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return Tt(this.toDERHex())}toDERHex(){return Zo.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Tt(this.toCompactHex())}toCompactHex(){return f(this.r)+f(this.s)}}const y={isValidPrivateKey(e){try{return u(e),!0}catch(e){return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{const e=or(t.n);return function(e,t,r=!1){const n=e.length,i=ir(t),o=or(t);if(n<16||n1024)throw new Error(`expected ${o}-1024 bytes of input, got ${n}`);const s=Jt(r?Rt(e):Ot(e),t-Ft)+Ft;return r?Lt(s,i):Mt(s,i)}(t.randomBytes(e),t.n)},precompute:(e=8,t=c.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)};function m(e){const t=yt(e),r="string"==typeof e,n=(t||r)&&e.length;return t?n===i||n===o:r?n===2*i||n===2*o:e instanceof c}const w=t.bits2int||function(e){const r=Rt(e),n=8*e.length-t.nBitLength;return n>0?r>>BigInt(n):r},b=t.bits2int_modN||function(e){return s(w(e))},v=Nt(t.nBitLength);function _(e){if("bigint"!=typeof e)throw new Error("bigint expected");if(!(Go<=e&&ee in i)))throw new Error("sign() legacy options not supported");const{hash:o,randomBytes:l}=t;let{lowS:f,prehash:p,extraEntropy:y}=i;null==f&&(f=!0),e=Ct("msgHash",e),p&&(e=Ct("prehashed msgHash",o(e)));const m=b(e),v=u(n),E=[_(v),_(m)];if(null!=y&&!1!==y){const e=!0===y?l(r.BYTES):y;E.push(Ct("extraEntropy",e))}const x=Pt(...E),A=m;return{seed:x,k2sig:function(e){const t=w(e);if(!h(t))return;const r=a(t),n=c.BASE.multiply(t).toAffine(),i=s(n.x);if(i===Go)return;const o=s(r*s(A+i*v));if(o===Go)return;let u=(n.x===i?0:2)|Number(n.y&Jo),l=o;return f&&d(o)&&(l=function(e){return d(e)?s(-e):e}(o),u^=1),new g(i,l,u)}}}const S={lowS:t.lowS,prehash:!1},x={lowS:t.lowS,prehash:!1};return c.BASE._setWindowSize(8),{CURVE:t,getPublicKey:function(e,t=!0){return c.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t,r=!0){if(m(e))throw new Error("first arg must be private key");if(!m(t))throw new Error("second arg must be public key");return c.fromHex(t).multiply(u(e)).toRawBytes(r)},sign:function(e,r,n=S){const{seed:i,k2sig:o}=E(e,r,n),s=t;return $t(s.hash.outputLen,s.nByteLength,s.hmac)(i,o)},verify:function(e,r,n,i=x){const o=e;if(r=Ct("msgHash",r),n=Ct("publicKey",n),"strict"in i)throw new Error("options.strict was renamed to lowS");const{lowS:u,prehash:l}=i;let h,f;try{if("string"==typeof o||yt(o))try{h=g.fromDER(o)}catch(e){if(!(e instanceof Zo.Err))throw e;h=g.fromCompact(o)}else{if("object"!=typeof o||"bigint"!=typeof o.r||"bigint"!=typeof o.s)throw new Error("PARSE");{const{r:e,s:t}=o;h=new g(e,t)}}f=c.fromHex(n)}catch(e){if("PARSE"===e.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(u&&h.hasHighS())return!1;l&&(r=t.hash(r));const{r:d,s:p}=h,y=b(r),m=a(p),w=s(y*m),v=s(d*m),_=c.BASE.multiplyAndAddUnsafe(f,w,v)?.toAffine();return!!_&&s(_.x)===d},ProjectivePoint:c,Signature:g,utils:y}}BigInt(4);class es extends Ye{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,function(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");He(e.outputLen),He(e.blockLen)}(e);const r=Ge(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const n=this.blockLen,i=new Uint8Array(n);i.set(r.length>n?e.create().update(r).digest():r);for(let e=0;enew es(e,t).update(r).digest(); +!function(e,t){var r=Ur,n=r.Buffer;function i(e,t){for(var r in e)t[r]=e[r]}function o(e,t,r){return n(e,t,r)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?e.exports=r:(i(r,t),t.Buffer=o),o.prototype=Object.create(n.prototype),i(n,o),o.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return n(e,t,r)},o.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var i=n(e);return void 0!==t?"string"==typeof r?i.fill(t,r):i.fill(t):i.fill(0),i},o.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n(e)},o.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}}($r,$r.exports);var Hr=$r.exports.Buffer;var zr=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r>>0,u=new Uint8Array(o);e[r];){var h=t[e.charCodeAt(r)];if(255===h)return;for(var l=0,f=o-1;(0!==h||l>>0,u[f]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");i=l,r++}for(var d=o-i;d!==o&&0===u[d];)d++;var p=Hr.allocUnsafe(n+(o-d));p.fill(0,0,n);for(var g=n;d!==o;)p[g++]=u[d++];return p}return{encode:function(t){if((Array.isArray(t)||t instanceof Uint8Array)&&(t=Hr.from(t)),!Hr.isBuffer(t))throw new TypeError("Expected Buffer");if(0===t.length)return"";for(var r=0,n=0,i=0,o=t.length;i!==o&&0===t[i];)i++,r++;for(var c=(o-i)*u+1>>>0,h=new Uint8Array(c);i!==o;){for(var l=t[i],f=0,d=c-1;(0!==l||f>>0,h[d]=l%s>>>0,l=l/s>>>0;if(0!==l)throw new Error("Non-zero carry");n=f,i++}for(var p=c-n;p!==c&&0===h[p];)p++;for(var g=a.repeat(r);p>>3,i=Ve(r,17)^Ve(r,19)^r>>>10;Kr[e]=i+Kr[e-7]+n+Kr[e-16]|0}let{A:r,B:n,C:i,D:o,E:s,F:a,G:c,H:u}=this;for(let e=0;e<64;e++){const t=u+(Ve(s,6)^Ve(s,11)^Ve(s,25))+Xe(s,a,c)+Fr[e]+Kr[e]|0,h=(Ve(r,2)^Ve(r,13)^Ve(r,22))+Qe(r,n,i)|0;u=c,c=a,a=s,s=o+t|0,o=i,i=n,n=r,r=t+h|0}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(r,n,i,o,s,a,c,u)}roundClean(){Kr.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Vr=Je((()=>new Wr));var Zr={};function Gr(e,t,r){return t<=e&&e<=r}function Jr(e){if(void 0===e)return{};if(e===Object(e))return e;throw TypeError("Could not convert argument to dictionary")}function Yr(e){this.tokens=[].slice.call(e)}Yr.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():-1},prepend:function(e){if(Array.isArray(e))for(var t=e;t.length;)this.tokens.unshift(t.pop());else this.tokens.unshift(e)},push:function(e){if(Array.isArray(e))for(var t=e;t.length;)this.tokens.push(t.shift());else this.tokens.push(e)}};var Xr=-1;function Qr(e,t){if(e)throw TypeError("Decoder error");return t||65533}var en="utf-8";function tn(e,t){if(!(this instanceof tn))return new tn(e,t);if((e=void 0!==e?String(e).toLowerCase():en)!==en)throw new Error("Encoding not supported. Only utf-8 is supported");t=Jr(t),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=Boolean(t.fatal),this._ignoreBOM=Boolean(t.ignoreBOM),Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}function rn(e,t){if(!(this instanceof rn))return new rn(e,t);if((e=void 0!==e?String(e).toLowerCase():en)!==en)throw new Error("Encoding not supported. Only utf-8 is supported");t=Jr(t),this._streaming=!1,this._encoder=null,this._options={fatal:Boolean(t.fatal)},Object.defineProperty(this,"encoding",{value:"utf-8"})}function nn(e){var t=e.fatal,r=0,n=0,i=0,o=128,s=191;this.handler=function(e,a){if(-1===a&&0!==i)return i=0,Qr(t);if(-1===a)return Xr;if(0===i){if(Gr(a,0,127))return a;if(Gr(a,194,223))i=1,r=a-192;else if(Gr(a,224,239))224===a&&(o=160),237===a&&(s=159),i=2,r=a-224;else{if(!Gr(a,240,244))return Qr(t);240===a&&(o=144),244===a&&(s=143),i=3,r=a-240}return r<<=6*i,null}if(!Gr(a,o,s))return r=i=n=0,o=128,s=191,e.prepend(a),Qr(t);if(o=128,s=191,r+=a-128<<6*(i-(n+=1)),n!==i)return null;var c=r;return r=i=n=0,c}}function on(e){e.fatal,this.handler=function(e,t){if(-1===t)return Xr;if(Gr(t,0,127))return t;var r,n;Gr(t,128,2047)?(r=1,n=192):Gr(t,2048,65535)?(r=2,n=224):Gr(t,65536,1114111)&&(r=3,n=240);for(var i=[(t>>6*r)+n];r>0;){var o=t>>6*(r-1);i.push(128|63&o),r-=1}return i}}tn.prototype={decode:function(e,t){var r;r="object"==typeof e&&e instanceof ArrayBuffer?new Uint8Array(e):"object"==typeof e&&"buffer"in e&&e.buffer instanceof ArrayBuffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(0),t=Jr(t),this._streaming||(this._decoder=new nn({fatal:this._fatal}),this._BOMseen=!1),this._streaming=Boolean(t.stream);for(var n,i=new Yr(r),o=[];!i.endOfStream()&&(n=this._decoder.handler(i,i.read()))!==Xr;)null!==n&&(Array.isArray(n)?o.push.apply(o,n):o.push(n));if(!this._streaming){do{if((n=this._decoder.handler(i,i.read()))===Xr)break;null!==n&&(Array.isArray(n)?o.push.apply(o,n):o.push(n))}while(!i.endOfStream());this._decoder=null}return o.length&&(-1===["utf-8"].indexOf(this.encoding)||this._ignoreBOM||this._BOMseen||(65279===o[0]?(this._BOMseen=!0,o.shift()):this._BOMseen=!0)),function(e){for(var t="",r=0;r>10),56320+(1023&n)))}return t}(o)}},rn.prototype={encode:function(e,t){e=e?String(e):"",t=Jr(t),this._streaming||(this._encoder=new on(this._options)),this._streaming=Boolean(t.stream);for(var r,n=[],i=new Yr(function(e){for(var t=String(e),r=t.length,n=0,i=[];n57343)i.push(o);else if(56320<=o&&o<=57343)i.push(65533);else if(55296<=o&&o<=56319)if(n===r-1)i.push(65533);else{var s=e.charCodeAt(n+1);if(56320<=s&&s<=57343){var a=1023&o,c=1023&s;i.push(65536+(a<<10)+c),n+=1}else i.push(65533)}n+=1}return i}(e));!i.endOfStream()&&(r=this._encoder.handler(i,i.read()))!==Xr;)Array.isArray(r)?n.push.apply(n,r):n.push(r);if(!this._streaming){for(;(r=this._encoder.handler(i,i.read()))!==Xr;)Array.isArray(r)?n.push.apply(n,r):n.push(r);this._encoder=null}return new Uint8Array(n)}};var sn=Pr(Object.freeze({__proto__:null,TextEncoder:rn,TextDecoder:tn})),an=Cr&&Cr.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),cn=Cr&&Cr.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),un=Cr&&Cr.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},hn=Cr&&Cr.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.hasOwnProperty.call(e,r)&&an(t,e,r);return cn(t,e),t},ln=Cr&&Cr.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Zr,"__esModule",{value:!0});var fn=Zr.deserializeUnchecked=In=Zr.deserialize=xn=Zr.serialize=Zr.BinaryReader=Zr.BinaryWriter=Zr.BorshError=Zr.baseDecode=Zr.baseEncode=void 0;const dn=ln(Nr.exports),pn=ln(Dr),gn=hn(sn),yn=new("function"!=typeof TextDecoder?gn.TextDecoder:TextDecoder)("utf-8",{fatal:!0});Zr.baseEncode=function(e){return"string"==typeof e&&(e=C.from(e,"utf8")),pn.default.encode(C.from(e))},Zr.baseDecode=function(e){return C.from(pn.default.decode(e))};const mn=1024;class wn extends Error{constructor(e){super(e),this.fieldPath=[],this.originalMessage=e}addToFieldPath(e){this.fieldPath.splice(0,0,e),this.message=this.originalMessage+": "+this.fieldPath.join(".")}}Zr.BorshError=wn;class bn{constructor(){this.buf=C.alloc(mn),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=C.concat([this.buf,C.alloc(mn)]))}writeU8(e){this.maybeResize(),this.buf.writeUInt8(e,this.length),this.length+=1}writeU16(e){this.maybeResize(),this.buf.writeUInt16LE(e,this.length),this.length+=2}writeU32(e){this.maybeResize(),this.buf.writeUInt32LE(e,this.length),this.length+=4}writeU64(e){this.maybeResize(),this.writeBuffer(C.from(new dn.default(e).toArray("le",8)))}writeU128(e){this.maybeResize(),this.writeBuffer(C.from(new dn.default(e).toArray("le",16)))}writeU256(e){this.maybeResize(),this.writeBuffer(C.from(new dn.default(e).toArray("le",32)))}writeU512(e){this.maybeResize(),this.writeBuffer(C.from(new dn.default(e).toArray("le",64)))}writeBuffer(e){this.buf=C.concat([C.from(this.buf.subarray(0,this.length)),e,C.alloc(mn)]),this.length+=e.length}writeString(e){this.maybeResize();const t=C.from(e,"utf8");this.writeU32(t.length),this.writeBuffer(t)}writeFixedArray(e){this.writeBuffer(C.from(e))}writeArray(e,t){this.maybeResize(),this.writeU32(e.length);for(const r of e)this.maybeResize(),t(r)}toArray(){return this.buf.subarray(0,this.length)}}function vn(e,t,r){const n=r.value;r.value=function(...e){try{return n.apply(this,e)}catch(e){if(e instanceof RangeError){const t=e.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(t)>=0)throw new wn("Reached the end of buffer when deserializing")}throw e}}}Zr.BinaryWriter=bn;class _n{constructor(e){this.buf=e,this.offset=0}readU8(){const e=this.buf.readUInt8(this.offset);return this.offset+=1,e}readU16(){const e=this.buf.readUInt16LE(this.offset);return this.offset+=2,e}readU32(){const e=this.buf.readUInt32LE(this.offset);return this.offset+=4,e}readU64(){const e=this.readBuffer(8);return new dn.default(e,"le")}readU128(){const e=this.readBuffer(16);return new dn.default(e,"le")}readU256(){const e=this.readBuffer(32);return new dn.default(e,"le")}readU512(){const e=this.readBuffer(64);return new dn.default(e,"le")}readBuffer(e){if(this.offset+e>this.buf.length)throw new wn(`Expected buffer length ${e} isn't within bounds`);const t=this.buf.slice(this.offset,this.offset+e);return this.offset+=e,t}readString(){const e=this.readU32(),t=this.readBuffer(e);try{return yn.decode(t)}catch(e){throw new wn(`Error decoding UTF-8 string: ${e}`)}}readFixedArray(e){return new Uint8Array(this.readBuffer(e))}readArray(e){const t=this.readU32(),r=Array();for(let n=0;n{Sn(e,t,r,n[0],i)}));else if(void 0!==n.kind)switch(n.kind){case"option":null==r?i.writeU8(0):(i.writeU8(1),Sn(e,t,r,n.type,i));break;case"map":i.writeU32(r.size),r.forEach(((r,o)=>{Sn(e,t,o,n.key,i),Sn(e,t,r,n.value,i)}));break;default:throw new wn(`FieldType ${n} unrecognized`)}else An(e,r,i)}catch(e){throw e instanceof wn&&e.addToFieldPath(t),e}}function An(e,t,r){if("function"==typeof t.borshSerialize)return void t.borshSerialize(r);const n=e.get(t.constructor);if(!n)throw new wn(`Class ${t.constructor.name} is missing in schema`);if("struct"===n.kind)n.fields.map((([n,i])=>{Sn(e,n,t[n],i,r)}));else{if("enum"!==n.kind)throw new wn(`Unexpected schema kind: ${n.kind} for ${t.constructor.name}`);{const i=t[n.field];for(let o=0;okn(e,t,r[0],n)))}if("option"===r.kind){return n.readU8()?kn(e,t,r.type,n):void 0}if("map"===r.kind){let i=new Map;const o=n.readU32();for(let s=0;s=n.values.length)throw new wn(`Enum index: ${i} is out of range`);const[o,s]=n.values[i],a=kn(e,o,s,r);return new t({[o]:a})}throw new wn(`Unexpected schema kind: ${n.kind} for ${t.constructor.name}`)}var In=Zr.deserialize=function(e,t,r,n=_n){const i=new n(r),o=Bn(e,t,i);if(i.offsetthis.span)throw new RangeError("indeterminate span");return this.span}replicate(e){const t=Object.create(this.constructor.prototype);return Object.assign(t,this),t.property=e,t}fromArray(e){}}function Cn(e,t){return t.property?e+"["+t.property+"]":e}Tn.Layout=Mn,Tn.nameWithProperty=Cn,Tn.bindConstructorLayout=function(e,t){if("function"!=typeof e)throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(e,"layout_"))throw new Error("Class is already bound to a layout");if(!(t&&t instanceof Mn))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(t,"boundConstructor_"))throw new Error("layout is already bound to a constructor");e.layout_=t,t.boundConstructor_=e,t.makeDestinationObject=()=>new e,Object.defineProperty(e.prototype,"encode",{value(e,r){return t.encode(this,e,r)},writable:!0}),Object.defineProperty(e,"decode",{value:(e,r)=>t.decode(e,r),writable:!0})};class Pn extends Mn{isCount(){throw new Error("ExternalLayout is abstract")}}Tn.ExternalLayout=Pn;class Nn extends Pn{constructor(e=1,t){if(!Number.isInteger(e)||0>=e)throw new TypeError("elementSpan must be a (positive) integer");super(-1,t),this.elementSpan=e}isCount(){return!0}decode(e,t=0){On(e);const r=e.length-t;return Math.floor(r/this.elementSpan)}encode(e,t,r){return 0}}Tn.GreedyCount=Nn;class Un extends Pn{constructor(e,t=0,r){if(!(e instanceof Mn))throw new TypeError("layout must be a Layout");if(!Number.isInteger(t))throw new TypeError("offset must be integer or undefined");super(e.span,r||e.property),this.layout=e,this.offset=t}isCount(){return this.layout instanceof jn||this.layout instanceof $n}decode(e,t=0){return this.layout.decode(e,t+this.offset)}encode(e,t,r=0){return this.layout.encode(e,t,r+this.offset)}}Tn.OffsetLayout=Un;class jn extends Mn{constructor(e,t){if(super(e,t),6e+n.encode(i,t,r+e)),0);return this.count instanceof Pn&&this.count.encode(e.length,t,r),i}}Tn.Sequence=Qn;class ei extends Mn{constructor(e,t,r){if(!Array.isArray(e)||!e.reduce(((e,t)=>e&&t instanceof Mn),!0))throw new TypeError("fields must be array of Layout instances");"boolean"==typeof t&&void 0===r&&(r=t,t=void 0);for(const t of e)if(0>t.span&&void 0===t.property)throw new Error("fields cannot contain unnamed variable-length layout");let n=-1;try{n=e.reduce(((e,t)=>e+t.getSpan()),0)}catch(e){}super(n,t),this.fields=e,this.decodePrefixes=!!r}getSpan(e,t=0){if(0<=this.span)return this.span;let r=0;try{r=this.fields.reduce(((r,n)=>{const i=n.getSpan(e,t);return t+=i,r+i}),0)}catch(e){throw new RangeError("indeterminate span")}return r}decode(e,t=0){On(e);const r=this.makeDestinationObject();for(const n of this.fields)if(void 0!==n.property&&(r[n.property]=n.decode(e,t)),t+=n.getSpan(e,t),this.decodePrefixes&&e.length===t)break;return r}encode(e,t,r=0){const n=r;let i=0,o=0;for(const n of this.fields){let s=n.span;if(o=0s&&(s=n.getSpan(t,r)))}i=r,r+=s}return i+o-n}fromArray(e){const t=this.makeDestinationObject();for(const r of this.fields)void 0!==r.property&&0r.span?t=-1:0<=t&&(t+=r.span)}}}Tn.Structure=ei;class ti{constructor(e){this.property=e}decode(e,t){throw new Error("UnionDiscriminator is abstract")}encode(e,t,r){throw new Error("UnionDiscriminator is abstract")}}Tn.UnionDiscriminator=ti;class ri extends ti{constructor(e,t){if(!(e instanceof Pn&&e.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(t||e.property||"variant"),this.layout=e}decode(e,t){return this.layout.decode(e,t)}encode(e,t,r){return this.layout.encode(e,t,r)}}Tn.UnionLayoutDiscriminator=ri;class ni extends Mn{constructor(e,t,r){let n;if(e instanceof jn||e instanceof $n)n=new ri(new Un(e));else if(e instanceof Pn&&e.isCount())n=new ri(e);else{if(!(e instanceof ti))throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");n=e}if(void 0===t&&(t=null),!(null===t||t instanceof Mn))throw new TypeError("defaultLayout must be null or a Layout");if(null!==t){if(0>t.span)throw new Error("defaultLayout must have constant span");void 0===t.property&&(t=t.replicate("content"))}let i=-1;t&&(i=t.span,0<=i&&(e instanceof jn||e instanceof $n)&&(i+=n.layout.span)),super(i,r),this.discriminator=n,this.usesPrefixDiscriminator=e instanceof jn||e instanceof $n,this.defaultLayout=t,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(e){return o(e)},this.configGetSourceVariant=function(e){o=e.bind(this)}}getSpan(e,t=0){if(0<=this.span)return this.span;const r=this.getVariant(e,t);if(!r)throw new Error("unable to determine span for unrecognized variant");return r.getSpan(e,t)}defaultGetSourceVariant(e){if(Object.prototype.hasOwnProperty.call(e,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(e,this.defaultLayout.property))return;const t=this.registry[e[this.discriminator.property]];if(t&&(!t.layout||t.property&&Object.prototype.hasOwnProperty.call(e,t.property)))return t}else for(const t in this.registry){const r=this.registry[t];if(r.property&&Object.prototype.hasOwnProperty.call(e,r.property))return r}throw new Error("unable to infer src variant")}decode(e,t=0){let r;const n=this.discriminator,i=n.decode(e,t),o=this.registry[i];if(void 0===o){const o=this.defaultLayout;let s=0;this.usesPrefixDiscriminator&&(s=n.layout.span),r=this.makeDestinationObject(),r[n.property]=i,r[o.property]=o.decode(e,t+s)}else r=o.decode(e,t);return r}encode(e,t,r=0){const n=this.getSourceVariant(e);if(void 0===n){const n=this.discriminator,i=this.defaultLayout;let o=0;return this.usesPrefixDiscriminator&&(o=n.layout.span),n.encode(e[n.property],t,r),o+i.encode(e[i.property],t,r+o)}return n.encode(e,t,r)}addVariant(e,t,r){const n=new ii(this,e,t,r);return this.registry[e]=n,n}getVariant(e,t=0){let r;return r=e instanceof Uint8Array?this.discriminator.decode(e,t):e,this.registry[r]}}Tn.Union=ni;class ii extends Mn{constructor(e,t,r,n){if(!(e instanceof ni))throw new TypeError("union must be a Union");if(!Number.isInteger(t)||0>t)throw new TypeError("variant must be a (non-negative) integer");if("string"==typeof r&&void 0===n&&(n=r,r=null),r){if(!(r instanceof Mn))throw new TypeError("layout must be a Layout");if(null!==e.defaultLayout&&0<=r.span&&r.span>e.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if("string"!=typeof n)throw new TypeError("variant must have a String property")}let i=e.span;0>e.span&&(i=r?r.span:0,0<=i&&e.usesPrefixDiscriminator&&(i+=e.discriminator.layout.span)),super(i,n),this.union=e,this.variant=t,this.layout=r||null}getSpan(e,t=0){if(0<=this.span)return this.span;let r=0;this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span);let n=0;return this.layout&&(n=this.layout.getSpan(e,t+r)),r+n}decode(e,t=0){const r=this.makeDestinationObject();if(this!==this.union.getVariant(e,t))throw new Error("variant mismatch");let n=0;return this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span),this.layout?r[this.property]=this.layout.decode(e,t+n):this.property?r[this.property]=!0:this.union.usesPrefixDiscriminator&&(r[this.union.discriminator.property]=this.variant),r}encode(e,t,r=0){let n=0;if(this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(e,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,t,r);let i=n;if(this.layout&&(this.layout.encode(e[this.property],t,r+n),i+=this.layout.getSpan(t,r+n),0<=this.union.span&&i>this.union.span))throw new Error("encoded variant overruns containing union");return i}fromArray(e){if(this.layout)return this.layout.fromArray(e)}}function oi(e){return 0>e&&(e+=4294967296),e}Tn.VariantLayout=ii;class si extends Mn{constructor(e,t,r){if(!(e instanceof jn||e instanceof $n))throw new TypeError("word must be a UInt or UIntBE layout");if("string"==typeof t&&void 0===r&&(r=t,t=!1),4=t)throw new TypeError("bits must be positive integer");const n=8*e.span,i=e.fields.reduce(((e,t)=>e+t.bits),0);if(t+i>n)throw new Error("bits too long for span remainder ("+(n-i)+" of "+n+" remain)");this.container=e,this.bits=t,this.valueMask=(1<>>this.start}encode(e){if("number"!=typeof e||!Number.isInteger(e)||e!==oi(e&this.valueMask))throw new TypeError(Cn("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const t=this.container._packedGetValue(),r=oi(e<r&&(r=this.length.decode(e,t)),r}decode(e,t=0){let r=this.span;return 0>r&&(r=this.length.decode(e,t)),Ln(e).slice(t,t+r)}encode(e,t,r){let n=this.length;if(this.length instanceof Pn&&(n=e.length),!(e instanceof Uint8Array&&n===e.length))throw new TypeError(Cn("Blob.encode",this)+" requires (length "+n+") Uint8Array as src");if(r+n>t.length)throw new RangeError("encoding overruns Uint8Array");const i=Ln(e);return Ln(t).write(i.toString("hex"),r,n,"hex"),this.length instanceof Pn&&this.length.encode(n,t,r),n}}Tn.Blob=ui;class hi extends Mn{constructor(e){super(-1,e)}getSpan(e,t=0){On(e);let r=t;for(;rt.length)throw new RangeError("encoding overruns Buffer");const o=Ln(t);return n.copy(o,r),o[r+i]=0,i+1}}Tn.CString=hi;class li extends Mn{constructor(e,t){if("string"==typeof e&&void 0===t&&(t=e,e=void 0),void 0===e)e=-1;else if(!Number.isInteger(e))throw new TypeError("maxSpan must be an integer");super(-1,t),this.maxSpan=e}getSpan(e,t=0){return On(e),e.length-t}decode(e,t=0){const r=this.getSpan(e,t);if(0<=this.maxSpan&&this.maxSpant.length)throw new RangeError("encoding overruns Buffer");return n.copy(Ln(t),r),i}}Tn.UTF8=li;class fi extends Mn{constructor(e,t){super(0,t),this.value=e}decode(e,t){return this.value}encode(e,t,r){return 0}}Tn.Constant=fi,Tn.greedy=(e,t)=>new Nn(e,t);var di=Tn.offset=(e,t,r)=>new Un(e,t,r),pi=Tn.u8=e=>new jn(1,e),gi=Tn.u16=e=>new jn(2,e);Tn.u24=e=>new jn(3,e);var yi=Tn.u32=e=>new jn(4,e);Tn.u40=e=>new jn(5,e),Tn.u48=e=>new jn(6,e);var mi=Tn.nu64=e=>new Kn(e);Tn.u16be=e=>new $n(2,e),Tn.u24be=e=>new $n(3,e),Tn.u32be=e=>new $n(4,e),Tn.u40be=e=>new $n(5,e),Tn.u48be=e=>new $n(6,e),Tn.nu64be=e=>new Wn(e),Tn.s8=e=>new Hn(1,e),Tn.s16=e=>new Hn(2,e),Tn.s24=e=>new Hn(3,e),Tn.s32=e=>new Hn(4,e),Tn.s40=e=>new Hn(5,e),Tn.s48=e=>new Hn(6,e);var wi=Tn.ns64=e=>new Vn(e);Tn.s16be=e=>new zn(2,e),Tn.s24be=e=>new zn(3,e),Tn.s32be=e=>new zn(4,e),Tn.s40be=e=>new zn(5,e),Tn.s48be=e=>new zn(6,e),Tn.ns64be=e=>new Zn(e),Tn.f32=e=>new Gn(e),Tn.f32be=e=>new Jn(e),Tn.f64=e=>new Yn(e),Tn.f64be=e=>new Xn(e);var bi=Tn.struct=(e,t,r)=>new ei(e,t,r);Tn.bits=(e,t,r)=>new si(e,t,r);var vi=Tn.seq=(e,t,r)=>new Qn(e,t,r);Tn.union=(e,t,r)=>new ni(e,t,r),Tn.unionLayoutDiscriminator=(e,t)=>new ri(e,t);var _i=Tn.blob=(e,t)=>new ui(e,t);Tn.cstr=e=>new hi(e),Tn.utf8=(e,t)=>new li(e,t),Tn.constant=(e,t)=>new fi(e,t);var Ei={};Object.defineProperty(Ei,"__esModule",{value:!0});var Si=Ei.toBigIntLE=function(e){{const t=C.from(e);t.reverse();const r=t.toString("hex");return 0===r.length?BigInt(0):BigInt(`0x${r}`)}};Ei.toBigIntBE=function(e){{const t=e.toString("hex");return 0===t.length?BigInt(0):BigInt(`0x${t}`)}};var Ai,xi=Ei.toBufferLE=function(e,t){{const r=e.toString(16),n=C.from(r.padStart(2*t,"0").slice(0,2*t),"hex");return n.reverse(),n}};Ei.toBufferBE=function(e,t){{const r=e.toString(16);return C.from(r.padStart(2*t,"0").slice(0,2*t),"hex")}};class ki extends TypeError{constructor(e,t){let r;const{message:n,explanation:i,...o}=e,{path:s}=e,a=0===s.length?n:`At path: ${s.join(".")} -- ${n}`;super(i??a),null!=i&&(this.cause=a),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>r??(r=[e,...t()])}}function Bi(e){return"object"==typeof e&&null!=e}function Ii(e){return Bi(e)&&!Array.isArray(e)}function Ti(e){return"symbol"==typeof e?e.toString():"string"==typeof e?JSON.stringify(e):`${e}`}function Ri(e,t,r,n){if(!0===e)return;!1===e?e={}:"string"==typeof e&&(e={message:e});const{path:i,branch:o}=t,{type:s}=r,{refinement:a,message:c=`Expected a value of type \`${s}\`${a?` with refinement \`${a}\``:""}, but received: \`${Ti(n)}\``}=e;return{value:n,type:s,refinement:a,key:i[i.length-1],path:i,branch:o,...e,message:c}}function*Oi(e,t,r,n){(function(e){return Bi(e)&&"function"==typeof e[Symbol.iterator]})(e)||(e=[e]);for(const i of e){const e=Ri(i,t,r,n);e&&(yield e)}}function*Li(e,t,r={}){const{path:n=[],branch:i=[e],coerce:o=!1,mask:s=!1}=r,a={path:n,branch:i,mask:s};o&&(e=t.coercer(e,a));let c="valid";for(const n of t.validator(e,a))n.explanation=r.message,c="not_valid",yield[n,void 0];for(let[u,h,l]of t.entries(e,a)){const t=Li(h,l,{path:void 0===u?n:[...n,u],branch:void 0===u?i:[...i,h],coerce:o,mask:s,message:r.message});for(const r of t)r[0]?(c=null!=r[0].refinement?"not_refined":"not_valid",yield[r[0],void 0]):o&&(h=r[1],void 0===u?e=h:e instanceof Map?e.set(u,h):e instanceof Set?e.add(h):Bi(e)&&(void 0!==h||u in e)&&(e[u]=h))}if("not_valid"!==c)for(const n of t.refiner(e,a))n.explanation=r.message,c="not_refined",yield[n,void 0];"valid"===c&&(yield[void 0,e])}class Mi{constructor(e){const{type:t,schema:r,validator:n,refiner:i,coercer:o=e=>e,entries:s=function*(){}}=e;this.type=t,this.schema=r,this.entries=s,this.coercer=o,this.validator=n?(e,t)=>Oi(n(e,t),t,this,e):()=>[],this.refiner=i?(e,t)=>Oi(i(e,t),t,this,e):()=>[]}assert(e,t){return function(e,t,r){const n=Ni(e,t,{message:r});if(n[0])throw n[0]}(e,this,t)}create(e,t){return Ci(e,this,t)}is(e){return Pi(e,this)}mask(e,t){return function(e,t,r){const n=Ni(e,t,{coerce:!0,mask:!0,message:r});if(n[0])throw n[0];return n[1]}(e,this,t)}validate(e,t={}){return Ni(e,this,t)}}function Ci(e,t,r){const n=Ni(e,t,{coerce:!0,message:r});if(n[0])throw n[0];return n[1]}function Pi(e,t){return!Ni(e,t)[0]}function Ni(e,t,r={}){const n=Li(e,t,r),i=function(e){const{done:t,value:r}=e.next();return t?void 0:r}(n);if(i[0]){const e=new ki(i[0],(function*(){for(const e of n)e[0]&&(yield e[0])}));return[e,void 0]}return[void 0,i[1]]}function Ui(e,t){return new Mi({type:e,schema:null,validator:t})}function ji(e){return new Mi({type:"array",schema:e,*entries(t){if(e&&Array.isArray(t))for(const[r,n]of t.entries())yield[r,n,e]},coercer:e=>Array.isArray(e)?e.slice():e,validator:e=>Array.isArray(e)||`Expected an array value, but received: ${Ti(e)}`})}function $i(){return Ui("boolean",(e=>"boolean"==typeof e))}function Hi(e){return Ui("instance",(t=>t instanceof e||`Expected a \`${e.name}\` instance, but received: ${Ti(t)}`))}function zi(e){const t=Ti(e),r=typeof e;return new Mi({type:"literal",schema:"string"===r||"number"===r||"boolean"===r?e:null,validator:r=>r===e||`Expected the literal \`${t}\`, but received: ${Ti(r)}`})}function Di(e){return new Mi({...e,validator:(t,r)=>null===t||e.validator(t,r),refiner:(t,r)=>null===t||e.refiner(t,r)})}function Fi(){return Ui("number",(e=>"number"==typeof e&&!isNaN(e)||`Expected a number, but received: ${Ti(e)}`))}function qi(e){return new Mi({...e,validator:(t,r)=>void 0===t||e.validator(t,r),refiner:(t,r)=>void 0===t||e.refiner(t,r)})}function Ki(e,t){return new Mi({type:"record",schema:null,*entries(r){if(Bi(r))for(const n in r){const i=r[n];yield[n,n,e],yield[n,i,t]}},validator:e=>Ii(e)||`Expected an object, but received: ${Ti(e)}`,coercer:e=>Ii(e)?{...e}:e})}function Wi(){return Ui("string",(e=>"string"==typeof e||`Expected a string, but received: ${Ti(e)}`))}function Vi(e){const t=Ui("never",(()=>!1));return new Mi({type:"tuple",schema:null,*entries(r){if(Array.isArray(r)){const n=Math.max(e.length,r.length);for(let i=0;iArray.isArray(e)||`Expected an array, but received: ${Ti(e)}`,coercer:e=>Array.isArray(e)?e.slice():e})}function Zi(e){const t=Object.keys(e);return new Mi({type:"type",schema:e,*entries(r){if(Bi(r))for(const n of t)yield[n,r[n],e[n]]},validator:e=>Ii(e)||`Expected an object, but received: ${Ti(e)}`,coercer:e=>Ii(e)?{...e}:e})}function Gi(e){const t=e.map((e=>e.type)).join(" | ");return new Mi({type:"union",schema:null,coercer(t,r){for(const n of e){const[e,i]=n.validate(t,{coerce:!0,mask:r.mask});if(!e)return i}return t},validator(r,n){const i=[];for(const t of e){const[...e]=Li(r,t,n),[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: ${Ti(r)}`,...i]}})}function Ji(){return Ui("unknown",(()=>!0))}function Yi(e,t,r){return new Mi({...e,coercer:(n,i)=>Pi(n,t)?e.coercer(r(n,i),i):e.coercer(n,i)})}var Xi=new Uint8Array(16);function Qi(){if(!Ai&&!(Ai="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 Ai(Xi)}var eo=/^(?:[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 to(e){return"string"==typeof e&&eo.test(e)}for(var ro,no,io=[],oo=0;oo<256;++oo)io.push((oo+256).toString(16).substr(1));function so(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(io[e[t+0]]+io[e[t+1]]+io[e[t+2]]+io[e[t+3]]+"-"+io[e[t+4]]+io[e[t+5]]+"-"+io[e[t+6]]+io[e[t+7]]+"-"+io[e[t+8]]+io[e[t+9]]+"-"+io[e[t+10]]+io[e[t+11]]+io[e[t+12]]+io[e[t+13]]+io[e[t+14]]+io[e[t+15]]).toLowerCase();if(!to(r))throw TypeError("Stringified UUID is invalid");return r}var ao=0,co=0;function uo(e){if(!to(e))throw TypeError("Invalid UUID");var t,r=new Uint8Array(16);return r[0]=(t=parseInt(e.slice(0,8),16))>>>24,r[1]=t>>>16&255,r[2]=t>>>8&255,r[3]=255&t,r[4]=(t=parseInt(e.slice(9,13),16))>>>8,r[5]=255&t,r[6]=(t=parseInt(e.slice(14,18),16))>>>8,r[7]=255&t,r[8]=(t=parseInt(e.slice(19,23),16))>>>8,r[9]=255&t,r[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,r[11]=t/4294967296&255,r[12]=t>>>24&255,r[13]=t>>>16&255,r[14]=t>>>8&255,r[15]=255&t,r}function ho(e,t,r){function n(e,n,i,o){if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));for(var t=[],r=0;r>>9<<4)+1}function fo(e,t){var r=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(r>>16)<<16|65535&r}function po(e,t,r,n,i,o){return fo((s=fo(fo(t,e),fo(n,o)))<<(a=i)|s>>>32-a,r);var s,a}function go(e,t,r,n,i,o,s){return po(t&r|~t&n,e,t,i,o,s)}function yo(e,t,r,n,i,o,s){return po(t&n|r&~n,e,t,i,o,s)}function mo(e,t,r,n,i,o,s){return po(t^r^n,e,t,i,o,s)}function wo(e,t,r,n,i,o,s){return po(r^(t|~n),e,t,i,o,s)}var bo=ho("v3",48,(function(e){if("string"==typeof e){var t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(var r=0;r>5]>>>i%32&255,s=parseInt(n.charAt(o>>>4&15)+n.charAt(15&o),16);t.push(s)}return t}(function(e,t){e[t>>5]|=128<>5]|=(255&e[n/8])<>>32-t}var So=ho("v5",80,(function(e){var t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof e){var n=unescape(encodeURIComponent(e));e=[];for(var i=0;i>>0;b=w,w=m,m=Eo(y,30)>>>0,y=g,g=E}r[0]=r[0]+g>>>0,r[1]=r[1]+y>>>0,r[2]=r[2]+m>>>0,r[3]=r[3]+w>>>0,r[4]=r[4]+b>>>0}return[r[0]>>24&255,r[0]>>16&255,r[0]>>8&255,255&r[0],r[1]>>24&255,r[1]>>16&255,r[1]>>8&255,255&r[1],r[2]>>24&255,r[2]>>16&255,r[2]>>8&255,255&r[2],r[3]>>24&255,r[3]>>16&255,r[3]>>8&255,255&r[3],r[4]>>24&255,r[4]>>16&255,r[4]>>8&255,255&r[4]]})),Ao=So;var xo=Object.freeze({__proto__:null,v1:function(e,t,r){var n=t&&r||0,i=t||new Array(16),o=(e=e||{}).node||ro,s=void 0!==e.clockseq?e.clockseq:no;if(null==o||null==s){var a=e.random||(e.rng||Qi)();null==o&&(o=ro=[1|a[0],a[1],a[2],a[3],a[4],a[5]]),null==s&&(s=no=16383&(a[6]<<8|a[7]))}var c=void 0!==e.msecs?e.msecs:Date.now(),u=void 0!==e.nsecs?e.nsecs:co+1,h=c-ao+(u-co)/1e4;if(h<0&&void 0===e.clockseq&&(s=s+1&16383),(h<0||c>ao)&&void 0===e.nsecs&&(u=0),u>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");ao=c,co=u,no=s;var l=(1e4*(268435455&(c+=122192928e5))+u)%4294967296;i[n++]=l>>>24&255,i[n++]=l>>>16&255,i[n++]=l>>>8&255,i[n++]=255&l;var f=c/4294967296*1e4&268435455;i[n++]=f>>>8&255,i[n++]=255&f,i[n++]=f>>>24&15|16,i[n++]=f>>>16&255,i[n++]=s>>>8|128,i[n++]=255&s;for(var d=0;d<6;++d)i[n+d]=o[d];return t||so(i)},v3:vo,v4:function(e,t,r){var n=(e=e||{}).random||(e.rng||Qi)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){r=r||0;for(var i=0;i<16;++i)t[r+i]=n[i];return t}return so(n)},v5:Ao,NIL:"00000000-0000-0000-0000-000000000000",version:function(e){if(!to(e))throw TypeError("Invalid UUID");return parseInt(e.substr(14,1),16)},validate:to,stringify:so,parse:uo}),ko=Pr(xo);const Bo=ko.v4;var Io=function(e,t,r,n){if("string"!=typeof e)throw new TypeError(e+" must be a string");const i="number"==typeof(n=n||{}).version?n.version:2;if(1!==i&&2!==i)throw new TypeError(i+" must be 1 or 2");const o={method:e};if(2===i&&(o.jsonrpc="2.0"),t){if("object"!=typeof t&&!Array.isArray(t))throw new TypeError(t+" must be an object, array or omitted");o.params=t}if(void 0===r){const e="function"==typeof n.generator?n.generator:function(){return Bo()};o.id=e(o,n)}else 2===i&&null===r?n.notificationIdNull&&(o.id=null):o.id=r;return o};const To=ko.v4,Ro=Io,Oo=function(e,t){if(!(this instanceof Oo))return new Oo(e,t);t||(t={}),this.options={reviver:void 0!==t.reviver?t.reviver:null,replacer:void 0!==t.replacer?t.replacer:null,generator:void 0!==t.generator?t.generator:function(){return To()},version:void 0!==t.version?t.version:2,notificationIdNull:"boolean"==typeof t.notificationIdNull&&t.notificationIdNull},this.callServer=e};var Lo=Oo;Oo.prototype.request=function(e,t,r,n){const i=this;let o=null;const s=Array.isArray(e)&&"function"==typeof t;if(1===this.options.version&&s)throw new TypeError("JSON-RPC 1.0 does not support batching");if(s||!s&&e&&"object"==typeof e&&"function"==typeof t)n=t,o=e;else{"function"==typeof r&&(n=r,r=void 0);const i="function"==typeof n;try{o=Ro(e,t,r,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(e){if(i)return n(e);throw e}if(!i)return o}let a;try{a=JSON.stringify(o,this.options.replacer)}catch(e){return n(e)}return this.callServer(a,(function(e,t){i._parseResponse(e,t,n)})),o},Oo.prototype._parseResponse=function(e,t,r){if(e)return void r(e);if(!t)return r();let n;try{n=JSON.parse(t,this.options.reviver)}catch(e){return r(e)}if(3===r.length){if(Array.isArray(n)){const e=function(e){return void 0!==e.error},t=function(t){return!e(t)};return r(null,n.filter(e),n.filter(t))}return r(null,n.error,n.result)}r(null,n)};var Mo={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,r="~";function n(){}function i(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function o(e,t,n,o,s){if("function"!=typeof n)throw new TypeError("The listener must be a function");var a=new i(n,o||e,s),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],a]:e._events[c].push(a):(e._events[c]=a,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function a(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),a.prototype.eventNames=function(){var e,n,i=[];if(0===this._eventsCount)return i;for(n in e=this._events)t.call(e,n)&&i.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},a.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,o=n.length,s=new Array(o);ithis.emit("open"),this.socket.onmessage=e=>this.emit("message",e.data),this.socket.onerror=e=>this.emit("error",e),this.socket.onclose=e=>{this.emit("close",e.code,e.reason)}}send(e,t,r){const n=r||t;try{this.socket.send(e),n()}catch(e){n(e)}}close(e,t){this.socket.close(e,t)}addEventListener(e,t,r){this.socket.addEventListener(e,t,r)}};var No=class{encode(e){return JSON.stringify(e)}decode(e){return JSON.parse(e)}},Uo=class extends Co{address;rpc_id;queue;options;autoconnect;ready;reconnect;reconnect_timer_id;reconnect_interval;max_reconnects;rest_options;current_reconnects;generate_request_id;socket;webSocketFactory;dataPack;constructor(e,t="ws://localhost:8080",{autoconnect:r=!0,reconnect:n=!0,reconnect_interval:i=1e3,max_reconnects:o=5,...s}={},a,c){super(),this.webSocketFactory=e,this.queue={},this.rpc_id=0,this.address=t,this.autoconnect=r,this.ready=!1,this.reconnect=n,this.reconnect_timer_id=void 0,this.reconnect_interval=i,this.max_reconnects=o,this.rest_options=s,this.current_reconnects=0,this.generate_request_id=a||(()=>++this.rpc_id),this.dataPack=c||new No,this.autoconnect&&this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}connect(){this.socket||this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}call(e,t,r,n){return n||"object"!=typeof r||(n=r,r=null),new Promise(((i,o)=>{if(!this.ready)return o(new Error("socket not ready"));const s=this.generate_request_id(e,t),a={jsonrpc:"2.0",method:e,params:t||void 0,id:s};this.socket.send(this.dataPack.encode(a),n,(e=>{if(e)return o(e);this.queue[s]={promise:[i,o]},r&&(this.queue[s].timeout=setTimeout((()=>{delete this.queue[s],o(new Error("reply timeout"))}),r))}))}))}async login(e){const t=await this.call("rpc.login",e);if(!t)throw new Error("authentication failed");return t}async listMethods(){return await this.call("__listMethods")}notify(e,t){return new Promise(((r,n)=>{if(!this.ready)return n(new Error("socket not ready"));const i={jsonrpc:"2.0",method:e,params:t};this.socket.send(this.dataPack.encode(i),(e=>{if(e)return n(e);r()}))}))}async subscribe(e){"string"==typeof e&&(e=[e]);const t=await this.call("rpc.on",e);if("string"==typeof e&&"ok"!==t[e])throw new Error("Failed subscribing to an event '"+e+"' with: "+t[e]);return t}async unsubscribe(e){"string"==typeof e&&(e=[e]);const t=await this.call("rpc.off",e);if("string"==typeof e&&"ok"!==t[e])throw new Error("Failed unsubscribing from an event with: "+t);return t}close(e,t){this.socket.close(e||1e3,t)}setAutoReconnect(e){this.reconnect=e}setReconnectInterval(e){this.reconnect_interval=e}setMaxReconnects(e){this.max_reconnects=e}_connect(e,t){clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(e,t),this.socket.addEventListener("open",(()=>{this.ready=!0,this.emit("open"),this.current_reconnects=0})),this.socket.addEventListener("message",(({data:e})=>{e instanceof ArrayBuffer&&(e=C.from(e).toString());try{e=this.dataPack.decode(e)}catch(e){return}if(e.notification&&this.listeners(e.notification).length){if(!Object.keys(e.params).length)return this.emit(e.notification);const t=[e.notification];if(e.params.constructor===Object)t.push(e.params);else for(let r=0;r{this.emit.apply(this,t)}))}if(!this.queue[e.id])return e.method?Promise.resolve().then((()=>{this.emit(e.method,e?.params)})):void 0;"error"in e=="result"in e&&this.queue[e.id].promise[1](new Error('Server response malformed. Response must include either "result" or "error", but not both.')),this.queue[e.id].timeout&&clearTimeout(this.queue[e.id].timeout),e.error?this.queue[e.id].promise[1](e.error):this.queue[e.id].promise[0](e.result),delete this.queue[e.id]})),this.socket.addEventListener("error",(e=>this.emit("error",e))),this.socket.addEventListener("close",(({code:r,reason:n})=>{this.ready&&setTimeout((()=>this.emit("close",r,n)),0),this.ready=!1,this.socket=void 0,1e3!==r&&(this.current_reconnects++,this.reconnect&&(this.max_reconnects>this.current_reconnects||0===this.max_reconnects)&&(this.reconnect_timer_id=setTimeout((()=>this._connect(e,t)),this.reconnect_interval)))}))}};const jo=[],$o=BigInt(0),Ho=BigInt(1),zo=BigInt(2),Do=BigInt(7),Fo=BigInt(256),qo=BigInt(113);for(let e=0,t=Ho,r=1,n=0;e<24;e++){[r,n]=[n,(2*r+3*n)%5];let e=$o;for(let r=0;r<7;r++)t=(t<>Do)*qo)%Fo,t&zo&&(e^=Ho<<(Ho<n?e.create().update(r).digest():r);for(let e=0;enew Ko(e,t).update(r).digest(); /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -function rs(e){return{hash:e,hmac:(t,...r)=>ts(e,t,Je(...r)),randomBytes:Qe}}ts.create=(e,t)=>new es(e,t); +function Vo(e){void 0!==e.lowS&&yt("lowS",e.lowS),void 0!==e.prehash&&yt("prehash",e.prehash)}Wo.create=(e,t)=>new Ko(e,t);const{bytesToNumberBE:Zo,hexToBytes:Go}=Wt,Jo={Err:class extends Error{constructor(e=""){super(e)}},_tlv:{encode:(e,t)=>{const{Err:r}=Jo;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(1&t.length)throw new r("tlv.encode: unpadded data");const n=t.length/2,i=bt(n);if(i.length/2&128)throw new r("tlv.encode: long form length too big");const o=n>127?bt(i.length/2|128):"";return`${bt(e)}${o}${i}${t}`},decode(e,t){const{Err:r}=Jo;let n=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");const i=t[n++];let o=0;if(!!(128&i)){const e=127&i;if(!e)throw new r("tlv.decode(long): indefinite length not supported");if(e>4)throw new r("tlv.decode(long): byte length is too big");const s=t.subarray(n,n+e);if(s.length!==e)throw new r("tlv.decode: length bytes not complete");if(0===s[0])throw new r("tlv.decode(long): zero leftmost byte");for(const e of s)o=o<<8|e;if(n+=e,o<128)throw new r("tlv.decode(long): not minimal encoding")}else o=i;const s=t.subarray(n,n+o);if(s.length!==o)throw new r("tlv.decode: wrong value length");return{v:s,l:t.subarray(n+o)}}},_int:{encode(e){const{Err:t}=Jo;if(e{const i=t.toAffine();return Ct(Uint8Array.from([4]),r.toBytes(i.x),r.toBytes(i.y))}),o=t.fromBytes||(e=>{const t=e.subarray(1);return{x:r.fromBytes(t.subarray(0,r.BYTES)),y:r.fromBytes(t.subarray(r.BYTES,2*r.BYTES))}});function s(e){const{a:n,b:i}=t,o=r.sqr(e),s=r.mul(o,e);return r.add(r.add(s,r.mul(e,n)),i)}if(!r.eql(r.sqr(t.Gy),s(t.Gx)))throw new Error("bad generator point: equation left != right");function a(e){const{allowedPrivateKeyLengths:r,nByteLength:n,wrapPrivateKey:i,n:o}=t;if(r&&"bigint"!=typeof e){if(pt(e)&&(e=wt(e)),"string"!=typeof e||!r.includes(e.length))throw new Error("Invalid key");e=e.padStart(2*n,"0")}let s;try{s="bigint"==typeof e?e:Tt(Mt("private key",e,n))}catch(t){throw new Error(`private key must be ${n} bytes, hex or bigint, not ${typeof e}`)}return i&&(s=er(s,o)),Ut("private key",s,Xo,o),s}function c(e){if(!(e instanceof l))throw new Error("ProjectivePoint expected")}const u=Kt(((e,t)=>{const{px:n,py:i,pz:o}=e;if(r.eql(o,r.ONE))return{x:n,y:i};const s=e.is0();null==t&&(t=s?r.ONE:r.inv(o));const a=r.mul(n,t),c=r.mul(i,t),u=r.mul(o,t);if(s)return{x:r.ZERO,y:r.ZERO};if(!r.eql(u,r.ONE))throw new Error("invZ was invalid");return{x:a,y:c}})),h=Kt((e=>{if(e.is0()){if(t.allowInfinityPoint&&!r.is0(e.py))return;throw new Error("bad point: ZERO")}const{x:n,y:i}=e.toAffine();if(!r.isValid(n)||!r.isValid(i))throw new Error("bad point: x or y not FE");const o=r.sqr(i),a=s(n);if(!r.eql(o,a))throw new Error("bad point: equation left != right");if(!e.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0}));class l{constructor(e,t,n){if(this.px=e,this.py=t,this.pz=n,null==e||!r.isValid(e))throw new Error("x required");if(null==t||!r.isValid(t))throw new Error("y required");if(null==n||!r.isValid(n))throw new Error("z required");Object.freeze(this)}static fromAffine(e){const{x:t,y:n}=e||{};if(!e||!r.isValid(t)||!r.isValid(n))throw new Error("invalid affine point");if(e instanceof l)throw new Error("projective point not allowed");const i=e=>r.eql(e,r.ZERO);return i(t)&&i(n)?l.ZERO:new l(t,n,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){const t=r.invertBatch(e.map((e=>e.pz)));return e.map(((e,r)=>e.toAffine(t[r]))).map(l.fromAffine)}static fromHex(e){const t=l.fromAffine(o(Mt("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return l.BASE.multiply(a(e))}static msm(e,t){return gr(l,n,e,t)}_setWindowSize(e){d.setWindowSize(this,e)}assertValidity(){h(this)}hasEvenY(){const{y:e}=this.toAffine();if(r.isOdd)return!r.isOdd(e);throw new Error("Field doesn't support isOdd")}equals(e){c(e);const{px:t,py:n,pz:i}=this,{px:o,py:s,pz:a}=e,u=r.eql(r.mul(t,a),r.mul(o,i)),h=r.eql(r.mul(n,a),r.mul(s,i));return u&&h}negate(){return new l(this.px,r.neg(this.py),this.pz)}double(){const{a:e,b:n}=t,i=r.mul(n,Qo),{px:o,py:s,pz:a}=this;let c=r.ZERO,u=r.ZERO,h=r.ZERO,f=r.mul(o,o),d=r.mul(s,s),p=r.mul(a,a),g=r.mul(o,s);return g=r.add(g,g),h=r.mul(o,a),h=r.add(h,h),c=r.mul(e,h),u=r.mul(i,p),u=r.add(c,u),c=r.sub(d,u),u=r.add(d,u),u=r.mul(c,u),c=r.mul(g,c),h=r.mul(i,h),p=r.mul(e,p),g=r.sub(f,p),g=r.mul(e,g),g=r.add(g,h),h=r.add(f,f),f=r.add(h,f),f=r.add(f,p),f=r.mul(f,g),u=r.add(u,f),p=r.mul(s,a),p=r.add(p,p),f=r.mul(p,g),c=r.sub(c,f),h=r.mul(p,d),h=r.add(h,h),h=r.add(h,h),new l(c,u,h)}add(e){c(e);const{px:n,py:i,pz:o}=this,{px:s,py:a,pz:u}=e;let h=r.ZERO,f=r.ZERO,d=r.ZERO;const p=t.a,g=r.mul(t.b,Qo);let y=r.mul(n,s),m=r.mul(i,a),w=r.mul(o,u),b=r.add(n,i),v=r.add(s,a);b=r.mul(b,v),v=r.add(y,m),b=r.sub(b,v),v=r.add(n,o);let _=r.add(s,u);return v=r.mul(v,_),_=r.add(y,w),v=r.sub(v,_),_=r.add(i,o),h=r.add(a,u),_=r.mul(_,h),h=r.add(m,w),_=r.sub(_,h),d=r.mul(p,v),h=r.mul(g,w),d=r.add(h,d),h=r.sub(m,d),d=r.add(m,d),f=r.mul(h,d),m=r.add(y,y),m=r.add(m,y),w=r.mul(p,w),v=r.mul(g,v),m=r.add(m,w),w=r.sub(y,w),w=r.mul(p,w),v=r.add(v,w),y=r.mul(m,v),f=r.add(f,y),y=r.mul(_,v),h=r.mul(b,h),h=r.sub(h,y),y=r.mul(b,m),d=r.mul(_,d),d=r.add(d,y),new l(h,f,d)}subtract(e){return this.add(e.negate())}is0(){return this.equals(l.ZERO)}wNAF(e){return d.wNAFCached(this,e,l.normalizeZ)}multiplyUnsafe(e){Ut("scalar",e,Yo,t.n);const n=l.ZERO;if(e===Yo)return n;if(e===Xo)return this;const{endo:i}=t;if(!i)return d.unsafeLadder(this,e);let{k1neg:o,k1:s,k2neg:a,k2:c}=i.splitScalar(e),u=n,h=n,f=this;for(;s>Yo||c>Yo;)s&Xo&&(u=u.add(f)),c&Xo&&(h=h.add(f)),f=f.double(),s>>=Xo,c>>=Xo;return o&&(u=u.negate()),a&&(h=h.negate()),h=new l(r.mul(h.px,i.beta),h.py,h.pz),u.add(h)}multiply(e){const{endo:n,n:i}=t;let o,s;if(Ut("scalar",e,Xo,i),n){const{k1neg:t,k1:i,k2neg:a,k2:c}=n.splitScalar(e);let{p:u,f:h}=this.wNAF(i),{p:f,f:p}=this.wNAF(c);u=d.constTimeNegate(t,u),f=d.constTimeNegate(a,f),f=new l(r.mul(f.px,n.beta),f.py,f.pz),o=u.add(f),s=h.add(p)}else{const{p:t,f:r}=this.wNAF(e);o=t,s=r}return l.normalizeZ([o,s])[0]}multiplyAndAddUnsafe(e,t,r){const n=l.BASE,i=(e,t)=>t!==Yo&&t!==Xo&&e.equals(n)?e.multiply(t):e.multiplyUnsafe(t),o=i(this,t).add(i(e,r));return o.is0()?void 0:o}toAffine(e){return u(this,e)}isTorsionFree(){const{h:e,isTorsionFree:r}=t;if(e===Xo)return!0;if(r)return r(l,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:r}=t;return e===Xo?this:r?r(l,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return yt("isCompressed",e),this.assertValidity(),i(l,this,e)}toHex(e=!0){return yt("isCompressed",e),wt(this.toRawBytes(e))}}l.BASE=new l(t.Gx,t.Gy,r.ONE),l.ZERO=new l(r.ZERO,r.ONE,r.ZERO);const f=t.nBitLength,d=pr(l,t.endo?Math.ceil(f/2):f);return{CURVE:t,ProjectivePoint:l,normPrivateKeyToScalar:a,weierstrassEquation:s,isWithinCurveOrder:function(e){return Nt(e,Xo,t.n)}}}function ts(e){const t=function(e){const t=yr(e);return qt(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}(e),{Fp:r,n:n}=t,i=r.BYTES+1,o=2*r.BYTES+1;function s(e){return er(e,n)}function a(e){return nr(e,n)}const{ProjectivePoint:c,normPrivateKeyToScalar:u,weierstrassEquation:h,isWithinCurveOrder:l}=es({...t,toBytes(e,t,n){const i=t.toAffine(),o=r.toBytes(i.x),s=Ct;return yt("isCompressed",n),n?s(Uint8Array.from([t.hasEvenY()?2:3]),o):s(Uint8Array.from([4]),o,r.toBytes(i.y))},fromBytes(e){const t=e.length,n=e[0],s=e.subarray(1);if(t!==i||2!==n&&3!==n){if(t===o&&4===n){return{x:r.fromBytes(s.subarray(0,r.BYTES)),y:r.fromBytes(s.subarray(r.BYTES,2*r.BYTES))}}throw new Error(`Point of length ${t} was invalid. Expected ${i} compressed bytes or ${o} uncompressed bytes`)}{const e=Tt(s);if(!Nt(e,Xo,r.ORDER))throw new Error("Point is not on curve");const t=h(e);let i;try{i=r.sqrt(t)}catch(e){const t=e instanceof Error?": "+e.message:"";throw new Error("Point is not on curve"+t)}return!(1&~n)!==((i&Xo)===Xo)&&(i=r.neg(i)),{x:e,y:i}}}}),f=e=>wt(Ot(e,t.nByteLength));function d(e){return e>n>>Xo}const p=(e,t,r)=>Tt(e.slice(t,r));class g{constructor(e,t,r){this.r=e,this.s=t,this.recovery=r,this.assertValidity()}static fromCompact(e){const r=t.nByteLength;return e=Mt("compactSignature",e,2*r),new g(p(e,0,r),p(e,r,2*r))}static fromDER(e){const{r:t,s:r}=Jo.toSig(Mt("DER",e));return new g(t,r)}assertValidity(){Ut("r",this.r,Xo,n),Ut("s",this.s,Xo,n)}addRecoveryBit(e){return new g(this.r,this.s,e)}recoverPublicKey(e){const{r:n,s:i,recovery:o}=this,u=b(Mt("msgHash",e));if(null==o||![0,1,2,3].includes(o))throw new Error("recovery id invalid");const h=2===o||3===o?n+t.n:n;if(h>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");const l=1&o?"03":"02",d=c.fromHex(l+f(h)),p=a(h),g=s(-u*p),y=s(i*p),m=c.BASE.multiplyAndAddUnsafe(d,g,y);if(!m)throw new Error("point at infinify");return m.assertValidity(),m}hasHighS(){return d(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return It(this.toDERHex())}toDERHex(){return Jo.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return It(this.toCompactHex())}toCompactHex(){return f(this.r)+f(this.s)}}const y={isValidPrivateKey(e){try{return u(e),!0}catch(e){return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{const e=ur(t.n);return function(e,t,r=!1){const n=e.length,i=cr(t),o=ur(t);if(n<16||n1024)throw new Error(`expected ${o}-1024 bytes of input, got ${n}`);const s=er(r?Tt(e):Rt(e),t-Zt)+Zt;return r?Lt(s,i):Ot(s,i)}(t.randomBytes(e),t.n)},precompute:(e=8,t=c.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)};function m(e){const t=pt(e),r="string"==typeof e,n=(t||r)&&e.length;return t?n===i||n===o:r?n===2*i||n===2*o:e instanceof c}const w=t.bits2int||function(e){const r=Tt(e),n=8*e.length-t.nBitLength;return n>0?r>>BigInt(n):r},b=t.bits2int_modN||function(e){return s(w(e))},v=$t(t.nBitLength);function _(e){return Ut(`num < 2^${t.nBitLength}`,e,Yo,v),Ot(e,t.nByteLength)}function E(e,n,i=S){if(["recovered","canonical"].some((e=>e in i)))throw new Error("sign() legacy options not supported");const{hash:o,randomBytes:h}=t;let{lowS:f,prehash:p,extraEntropy:y}=i;null==f&&(f=!0),e=Mt("msgHash",e),Vo(i),p&&(e=Mt("prehashed msgHash",o(e)));const m=b(e),v=u(n),E=[_(v),_(m)];if(null!=y&&!1!==y){const e=!0===y?h(r.BYTES):y;E.push(Mt("extraEntropy",e))}const A=Ct(...E),x=m;return{seed:A,k2sig:function(e){const t=w(e);if(!l(t))return;const r=a(t),n=c.BASE.multiply(t).toAffine(),i=s(n.x);if(i===Yo)return;const o=s(r*s(x+i*v));if(o===Yo)return;let u=(n.x===i?0:2)|Number(n.y&Xo),h=o;return f&&d(o)&&(h=function(e){return d(e)?s(-e):e}(o),u^=1),new g(i,h,u)}}}const S={lowS:t.lowS,prehash:!1},A={lowS:t.lowS,prehash:!1};return c.BASE._setWindowSize(8),{CURVE:t,getPublicKey:function(e,t=!0){return c.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t,r=!0){if(m(e))throw new Error("first arg must be private key");if(!m(t))throw new Error("second arg must be public key");return c.fromHex(t).multiply(u(e)).toRawBytes(r)},sign:function(e,r,n=S){const{seed:i,k2sig:o}=E(e,r,n),s=t;return Dt(s.hash.outputLen,s.nByteLength,s.hmac)(i,o)},verify:function(e,r,n,i=A){const o=e;if(r=Mt("msgHash",r),n=Mt("publicKey",n),"strict"in i)throw new Error("options.strict was renamed to lowS");Vo(i);const{lowS:u,prehash:h}=i;let l,f;try{if("string"==typeof o||pt(o))try{l=g.fromDER(o)}catch(e){if(!(e instanceof Jo.Err))throw e;l=g.fromCompact(o)}else{if("object"!=typeof o||"bigint"!=typeof o.r||"bigint"!=typeof o.s)throw new Error("PARSE");{const{r:e,s:t}=o;l=new g(e,t)}}f=c.fromHex(n)}catch(e){if("PARSE"===e.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(u&&l.hasHighS())return!1;h&&(r=t.hash(r));const{r:d,s:p}=l,y=b(r),m=a(p),w=s(y*m),v=s(d*m),_=c.BASE.multiplyAndAddUnsafe(f,w,v)?.toAffine();return!!_&&s(_.x)===d},ProjectivePoint:c,Signature:g,utils:y}} +/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function rs(e){return{hash:e,hmac:(t,...r)=>Wo(e,t,function(...e){let t=0;for(let r=0;r(e+t/ss)/t;const cs=nr(ns,void 0,void 0,{sqrt:function(e){const t=ns,r=BigInt(3),n=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),u=e*e*e%t,l=u*u*e%t,h=Xt(l,r,t)*l%t,f=Xt(h,r,t)*l%t,d=Xt(f,ss,t)*u%t,p=Xt(d,i,t)*d%t,g=Xt(p,o,t)*p%t,y=Xt(g,a,t)*g%t,m=Xt(y,c,t)*y%t,w=Xt(m,a,t)*g%t,b=Xt(w,r,t)*l%t,v=Xt(b,s,t)*p%t,_=Xt(v,n,t)*u%t,E=Xt(_,ss,t);if(!cs.eql(cs.sqr(E),e))throw new Error("Cannot find square root");return E}}),us=function(e,t){const r=t=>Qo({...e,...rs(t)});return Object.freeze({...r(t),create:r})}({a:BigInt(0),b:BigInt(7),Fp:cs,n:is,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=is,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-os*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=r,s=BigInt("0x100000000000000000000000000000000"),a=as(o*e,t),c=as(-n*e,t);let u=Jt(e-a*r-c*i,t),l=Jt(-a*n-c*o,t);const h=u>s,f=l>s;if(h&&(u=t-u),f&&(l=t-l),u>s||l>s)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:h,k1:u,k2neg:f,k2:l}}}},Hr);function ls(e){try{return Ir.ExtendedPoint.fromHex(e),!0}catch{return!1}}BigInt(0),us.ProjectivePoint,Ir.utils.randomPrivateKey;const hs=(e,t)=>Ir.sign(e,t.slice(0,32)),fs=Ir.verify,ds=e=>C.isBuffer(e)?e:e instanceof Uint8Array?C.from(e.buffer,e.byteOffset,e.byteLength):C.from(e);class ps{constructor(e){Object.assign(this,e)}encode(){return C.from(vn(gs,this))}static decode(e){return Sn(gs,this,e)}static decodeUnchecked(e){return an(gs,this,e)}}const gs=new Map;var ys;const ms=32;let ws=1;class bs extends ps{constructor(e){if(super({}),this._bn=void 0,function(e){return void 0!==e._bn}(e))this._bn=e._bn;else{if("string"==typeof e){const t=Ur.decode(e);if(t.length!=ms)throw new Error("Invalid public key input");this._bn=new Lr(t)}else this._bn=new Lr(e);if(this._bn.byteLength()>ms)throw new Error("Invalid public key input")}}static unique(){const e=new bs(ws);return ws+=1,new bs(e.toBuffer())}equals(e){return this._bn.eq(e._bn)}toBase58(){return Ur.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){const e=this.toBuffer();return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}toBuffer(){const e=this._bn.toArrayLike(C);if(e.length===ms)return e;const t=C.alloc(32);return e.copy(t,32-e.length),t}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(e,t,r){const n=C.concat([e.toBuffer(),C.from(t),r.toBuffer()]),i=Hr(n);return new bs(i)}static createProgramAddressSync(e,t){let r=C.alloc(0);e.forEach((function(e){if(e.length>32)throw new TypeError("Max seed length exceeded");r=C.concat([r,ds(e)])})),r=C.concat([r,t.toBuffer(),C.from("ProgramDerivedAddress")]);const n=Hr(r);if(ls(n))throw new Error("Invalid seeds, address must fall off the curve");return new bs(n)}static async createProgramAddress(e,t){return this.createProgramAddressSync(e,t)}static findProgramAddressSync(e,t){let r,n=255;for(;0!=n;){try{const i=e.concat(C.from([n]));r=this.createProgramAddressSync(i,t)}catch(e){if(e instanceof TypeError)throw e;n--;continue}return[r,n]}throw new Error("Unable to find a viable program address nonce")}static async findProgramAddress(e,t){return this.findProgramAddressSync(e,t)}static isOnCurve(e){return ls(new bs(e).toBytes())}}ys=bs,bs.default=new ys("11111111111111111111111111111111"),gs.set(bs,{kind:"struct",fields:[["_bn","u256"]]}),new bs("BPFLoader1111111111111111111111111111111111");const vs=1232;class _s extends Error{constructor(e){super(`Signature ${e} has expired: block height exceeded.`),this.signature=void 0,this.signature=e}}Object.defineProperty(_s.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});class Es extends Error{constructor(e,t){super(`Transaction was not confirmed in ${t.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${e} using the Solana Explorer or CLI tools.`),this.signature=void 0,this.signature=e}}Object.defineProperty(Es.prototype,"name",{value:"TransactionExpiredTimeoutError"});class Ss extends Error{constructor(e){super(`Signature ${e} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=e}}Object.defineProperty(Ss.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});class xs{constructor(e,t){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=e,this.accountKeysFromLookups=t}keySegments(){const e=[this.staticAccountKeys];return this.accountKeysFromLookups&&(e.push(this.accountKeysFromLookups.writable),e.push(this.accountKeysFromLookups.readonly)),e}get(e){for(const t of this.keySegments()){if(e256)throw new Error("Account index overflow encountered during compilation");const t=new Map;this.keySegments().flat().forEach(((e,r)=>{t.set(e.toBase58(),r)}));const r=e=>{const r=t.get(e.toBase58());if(void 0===r)throw new Error("Encountered an unknown instruction account key during compilation");return r};return e.map((e=>({programIdIndex:r(e.programId),accountKeyIndexes:e.keys.map((e=>r(e.pubkey))),data:e.data})))}}const As=(e="publicKey")=>yi(32,e),ks=(e="signature")=>yi(64,e),Is=(e="string")=>{const t=pi([hi("length"),hi("lengthPadding"),yi(ci(hi(),-8),"chars")],e),r=t.decode.bind(t),n=t.encode.bind(t),i=t;return i.decode=(e,t)=>r(e,t).chars.toString(),i.encode=(e,t,r)=>{const i={chars:C.from(e,"utf8")};return n(i,t,r)},i.alloc=e=>hi().span+hi().span+C.from(e,"utf8").length,i};function Bs(e){let t=0,r=0;for(;;){let n=e.shift();if(t|=(127&n)<<7*r,r+=1,!(128&n))break}return t}function Ts(e,t){let r=t;for(;;){let t=127&r;if(r>>=7,0==r){e.push(t);break}t|=128,e.push(t)}}function Rs(e,t){if(!e)throw new Error(t||"Assertion failed")}class Os{constructor(e,t){this.payer=void 0,this.keyMetaMap=void 0,this.payer=e,this.keyMetaMap=t}static compile(e,t){const r=new Map,n=e=>{const t=e.toBase58();let n=r.get(t);return void 0===n&&(n={isSigner:!1,isWritable:!1,isInvoked:!1},r.set(t,n)),n},i=n(t);i.isSigner=!0,i.isWritable=!0;for(const t of e){n(t.programId).isInvoked=!0;for(const e of t.keys){const t=n(e.pubkey);t.isSigner||=e.isSigner,t.isWritable||=e.isWritable}}return new Os(t,r)}getMessageComponents(){const e=[...this.keyMetaMap.entries()];Rs(e.length<=256,"Max static account keys length exceeded");const t=e.filter((([,e])=>e.isSigner&&e.isWritable)),r=e.filter((([,e])=>e.isSigner&&!e.isWritable)),n=e.filter((([,e])=>!e.isSigner&&e.isWritable)),i=e.filter((([,e])=>!e.isSigner&&!e.isWritable)),o={numRequiredSignatures:t.length+r.length,numReadonlySignedAccounts:r.length,numReadonlyUnsignedAccounts:i.length};{Rs(t.length>0,"Expected at least one writable signer key");const[e]=t[0];Rs(e===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}const s=[...t.map((([e])=>new bs(e))),...r.map((([e])=>new bs(e))),...n.map((([e])=>new bs(e))),...i.map((([e])=>new bs(e)))];return[o,s]}extractTableLookup(e){const[t,r]=this.drainKeysFoundInLookupTable(e.state.addresses,(e=>!e.isSigner&&!e.isInvoked&&e.isWritable)),[n,i]=this.drainKeysFoundInLookupTable(e.state.addresses,(e=>!e.isSigner&&!e.isInvoked&&!e.isWritable));if(0!==t.length||0!==n.length)return[{accountKey:e.key,writableIndexes:t,readonlyIndexes:n},{writable:r,readonly:i}]}drainKeysFoundInLookupTable(e,t){const r=new Array,n=new Array;for(const[i,o]of this.keyMetaMap.entries())if(t(o)){const t=new bs(i),o=e.findIndex((e=>e.equals(t)));o>=0&&(Rs(o<256,"Max lookup table index exceeded"),r.push(o),n.push(t),this.keyMetaMap.delete(i))}return[r,n]}}const Ms="Reached end of buffer unexpectedly";function Ls(e){if(0===e.length)throw new Error(Ms);return e.shift()}function Cs(e,...t){const[r]=t;if(2===t.length?r+(t[1]??0)>e.length:r>=e.length)throw new Error(Ms);return e.splice(...t)}class Ps{constructor(e){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=e.header,this.accountKeys=e.accountKeys.map((e=>new bs(e))),this.recentBlockhash=e.recentBlockhash,this.instructions=e.instructions,this.instructions.forEach((e=>this.indexToProgramIds.set(e.programIdIndex,this.accountKeys[e.programIdIndex])))}get version(){return"legacy"}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map((e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:Ur.decode(e.data)})))}get addressTableLookups(){return[]}getAccountKeys(){return new xs(this.staticAccountKeys)}static compile(e){const t=Os.compile(e.instructions,e.payerKey),[r,n]=t.getMessageComponents(),i=new xs(n).compileInstructions(e.instructions).map((e=>({programIdIndex:e.programIdIndex,accounts:e.accountKeyIndexes,data:Ur.encode(e.data)})));return new Ps({header:r,accountKeys:n,recentBlockhash:e.recentBlockhash,instructions:i})}isAccountSigner(e){return e=this.header.numRequiredSignatures){return e-t!this.isProgramId(t)))}serialize(){const e=this.accountKeys.length;let t=[];Ts(t,e);const r=this.instructions.map((e=>{const{accounts:t,programIdIndex:r}=e,n=Array.from(Ur.decode(e.data));let i=[];Ts(i,t.length);let o=[];return Ts(o,n.length),{programIdIndex:r,keyIndicesCount:C.from(i),keyIndices:t,dataLength:C.from(o),data:n}}));let n=[];Ts(n,r.length);let i=C.alloc(vs);C.from(n).copy(i);let o=n.length;r.forEach((e=>{const t=pi([ui("programIdIndex"),yi(e.keyIndicesCount.length,"keyIndicesCount"),gi(ui("keyIndex"),e.keyIndices.length,"keyIndices"),yi(e.dataLength.length,"dataLength"),gi(ui("userdatum"),e.data.length,"data")]).encode(e,i,o);o+=t})),i=i.slice(0,o);const s=pi([yi(1,"numRequiredSignatures"),yi(1,"numReadonlySignedAccounts"),yi(1,"numReadonlyUnsignedAccounts"),yi(t.length,"keyCount"),gi(As("key"),e,"keys"),As("recentBlockhash")]),a={numRequiredSignatures:C.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:C.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:C.from([this.header.numReadonlyUnsignedAccounts]),keyCount:C.from(t),keys:this.accountKeys.map((e=>ds(e.toBytes()))),recentBlockhash:Ur.decode(this.recentBlockhash)};let c=C.alloc(2048);const u=s.encode(a,c);return i.copy(c,u),c.slice(0,u+i.length)}static from(e){let t=[...e];const r=Ls(t);if(r!==(127&r))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const n=Ls(t),i=Ls(t),o=Bs(t);let s=[];for(let e=0;e0)throw new Error("Failed to get account keys because address table lookups were not resolved");return new xs(this.staticAccountKeys,t)}isAccountSigner(e){return e=r){const t=e-r,n=this.addressTableLookups.reduce(((e,t)=>e+t.writableIndexes.length),0);return t=this.header.numRequiredSignatures){return e-te.key.equals(r.accountKey)));if(!n)throw new Error(`Failed to find address lookup table account for table key ${r.accountKey.toBase58()}`);for(const e of r.writableIndexes){if(!(ee.toBytes())),recentBlockhash:Ur.decode(this.recentBlockhash),instructionsLength:new Uint8Array(r),serializedInstructions:t,addressTableLookupsLength:new Uint8Array(i),serializedAddressTableLookups:n},s);return s.slice(0,a)}serializeInstructions(){let e=0;const t=new Uint8Array(vs);for(const r of this.compiledInstructions){const n=Array();Ts(n,r.accountKeyIndexes.length);const i=Array();Ts(i,r.data.length);e+=pi([ui("programIdIndex"),yi(n.length,"encodedAccountKeyIndexesLength"),gi(ui(),r.accountKeyIndexes.length,"accountKeyIndexes"),yi(i.length,"encodedDataLength"),yi(r.data.length,"data")]).encode({programIdIndex:r.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(n),accountKeyIndexes:r.accountKeyIndexes,encodedDataLength:new Uint8Array(i),data:r.data},t,e)}return t.slice(0,e)}serializeAddressTableLookups(){let e=0;const t=new Uint8Array(vs);for(const r of this.addressTableLookups){const n=Array();Ts(n,r.writableIndexes.length);const i=Array();Ts(i,r.readonlyIndexes.length);e+=pi([As("accountKey"),yi(n.length,"encodedWritableIndexesLength"),gi(ui(),r.writableIndexes.length,"writableIndexes"),yi(i.length,"encodedReadonlyIndexesLength"),gi(ui(),r.readonlyIndexes.length,"readonlyIndexes")]).encode({accountKey:r.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(n),writableIndexes:r.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(i),readonlyIndexes:r.readonlyIndexes},t,e)}return t.slice(0,e)}static deserialize(e){let t=[...e];const r=Ls(t),n=127&r;Rs(r!==n,"Expected versioned message but received legacy message");Rs(0===n,`Expected versioned message with version 0 but found version ${n}`);const i={numRequiredSignatures:Ls(t),numReadonlySignedAccounts:Ls(t),numReadonlyUnsignedAccounts:Ls(t)},o=[],s=Bs(t);for(let e=0;e{const t=Us.deserializeMessageVersion(e);if("legacy"===t)return Ps.from(e);if(0===t)return Ns.deserialize(e);throw new Error(`Transaction message version ${t} deserialization is not supported`)}};let js=function(e){return e[e.BLOCKHEIGHT_EXCEEDED=0]="BLOCKHEIGHT_EXCEEDED",e[e.PROCESSED=1]="PROCESSED",e[e.TIMED_OUT=2]="TIMED_OUT",e[e.NONCE_INVALID=3]="NONCE_INVALID",e}({});const $s=C.alloc(64).fill(0);class zs{constructor(e){this.keys=void 0,this.programId=void 0,this.data=C.alloc(0),this.programId=e.programId,this.keys=e.keys,e.data&&(this.data=e.data)}toJSON(){return{keys:this.keys.map((({pubkey:e,isSigner:t,isWritable:r})=>({pubkey:e.toJSON(),isSigner:t,isWritable:r}))),programId:this.programId.toJSON(),data:[...this.data]}}}class Ds{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(e){if(this.signatures=[],this.feePayer=void 0,this.instructions=[],this.recentBlockhash=void 0,this.lastValidBlockHeight=void 0,this.nonceInfo=void 0,this.minNonceContextSlot=void 0,this._message=void 0,this._json=void 0,e)if(e.feePayer&&(this.feePayer=e.feePayer),e.signatures&&(this.signatures=e.signatures),Object.prototype.hasOwnProperty.call(e,"nonceInfo")){const{minContextSlot:t,nonceInfo:r}=e;this.minNonceContextSlot=t,this.nonceInfo=r}else if(Object.prototype.hasOwnProperty.call(e,"lastValidBlockHeight")){const{blockhash:t,lastValidBlockHeight:r}=e;this.recentBlockhash=t,this.lastValidBlockHeight=r}else{const{recentBlockhash:t,nonceInfo:r}=e;r&&(this.nonceInfo=r),this.recentBlockhash=t}}toJSON(){return{recentBlockhash:this.recentBlockhash||null,feePayer:this.feePayer?this.feePayer.toJSON():null,nonceInfo:this.nonceInfo?{nonce:this.nonceInfo.nonce,nonceInstruction:this.nonceInfo.nonceInstruction.toJSON()}:null,instructions:this.instructions.map((e=>e.toJSON())),signers:this.signatures.map((({publicKey:e})=>e.toJSON()))}}add(...e){if(0===e.length)throw new Error("No instructions");return e.forEach((e=>{"instructions"in e?this.instructions=this.instructions.concat(e.instructions):"data"in e&&"programId"in e&&"keys"in e?this.instructions.push(e):this.instructions.push(new zs(e))})),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let e,t,r;if(this.nonceInfo?(e=this.nonceInfo.nonce,t=this.instructions[0]!=this.nonceInfo.nonceInstruction?[this.nonceInfo.nonceInstruction,...this.instructions]:this.instructions):(e=this.recentBlockhash,t=this.instructions),!e)throw new Error("Transaction recentBlockhash required");if(t.length<1&&console.warn("No instructions provided"),this.feePayer)r=this.feePayer;else{if(!(this.signatures.length>0&&this.signatures[0].publicKey))throw new Error("Transaction fee payer required");r=this.signatures[0].publicKey}for(let e=0;e{e.keys.forEach((e=>{i.push({...e})}));const t=e.programId.toString();n.includes(t)||n.push(t)})),n.forEach((e=>{i.push({pubkey:new bs(e),isSigner:!1,isWritable:!1})}));const o=[];i.forEach((e=>{const t=e.pubkey.toString(),r=o.findIndex((e=>e.pubkey.toString()===t));r>-1?(o[r].isWritable=o[r].isWritable||e.isWritable,o[r].isSigner=o[r].isSigner||e.isSigner):o.push(e)})),o.sort((function(e,t){if(e.isSigner!==t.isSigner)return e.isSigner?-1:1;if(e.isWritable!==t.isWritable)return e.isWritable?-1:1;return e.pubkey.toBase58().localeCompare(t.pubkey.toBase58(),"en",{localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"})}));const s=o.findIndex((e=>e.pubkey.equals(r)));if(s>-1){const[e]=o.splice(s,1);e.isSigner=!0,e.isWritable=!0,o.unshift(e)}else o.unshift({pubkey:r,isSigner:!0,isWritable:!0});for(const e of this.signatures){const t=o.findIndex((t=>t.pubkey.equals(e.publicKey)));if(!(t>-1))throw new Error(`unknown signer: ${e.publicKey.toString()}`);o[t].isSigner||(o[t].isSigner=!0,console.warn("Transaction references a signature that is unnecessary, only the fee payer and instruction signer accounts should sign a transaction. This behavior is deprecated and will throw an error in the next major version release."))}let a=0,c=0,u=0;const l=[],h=[];o.forEach((({pubkey:e,isSigner:t,isWritable:r})=>{t?(l.push(e.toString()),a+=1,r||(c+=1)):(h.push(e.toString()),r||(u+=1))}));const f=l.concat(h),d=t.map((e=>{const{data:t,programId:r}=e;return{programIdIndex:f.indexOf(r.toString()),accounts:e.keys.map((e=>f.indexOf(e.pubkey.toString()))),data:Ur.encode(t)}}));return d.forEach((e=>{Rs(e.programIdIndex>=0),e.accounts.forEach((e=>Rs(e>=0)))})),new Ps({header:{numRequiredSignatures:a,numReadonlySignedAccounts:c,numReadonlyUnsignedAccounts:u},accountKeys:f,recentBlockhash:e,instructions:d})}_compile(){const e=this.compileMessage(),t=e.accountKeys.slice(0,e.header.numRequiredSignatures);if(this.signatures.length===t.length){if(this.signatures.every(((e,r)=>t[r].equals(e.publicKey))))return e}return this.signatures=t.map((e=>({signature:null,publicKey:e}))),e}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(e){return(await e.getFeeForMessage(this.compileMessage())).value}setSigners(...e){if(0===e.length)throw new Error("No signers");const t=new Set;this.signatures=e.filter((e=>{const r=e.toString();return!t.has(r)&&(t.add(r),!0)})).map((e=>({signature:null,publicKey:e})))}sign(...e){if(0===e.length)throw new Error("No signers");const t=new Set,r=[];for(const n of e){const e=n.publicKey.toString();t.has(e)||(t.add(e),r.push(n))}this.signatures=r.map((e=>({signature:null,publicKey:e.publicKey})));const n=this._compile();this._partialSign(n,...r)}partialSign(...e){if(0===e.length)throw new Error("No signers");const t=new Set,r=[];for(const n of e){const e=n.publicKey.toString();t.has(e)||(t.add(e),r.push(n))}const n=this._compile();this._partialSign(n,...r)}_partialSign(e,...t){const r=e.serialize();t.forEach((e=>{const t=hs(r,e.secretKey);this._addSignature(e.publicKey,ds(t))}))}addSignature(e,t){this._compile(),this._addSignature(e,t)}_addSignature(e,t){Rs(64===t.length);const r=this.signatures.findIndex((t=>e.equals(t.publicKey)));if(r<0)throw new Error(`unknown signer: ${e.toString()}`);this.signatures[r].signature=C.from(t)}verifySignatures(e=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),e)}_getMessageSignednessErrors(e,t){const r={};for(const{signature:n,publicKey:i}of this.signatures)null===n?t&&(r.missing||=[]).push(i):fs(n,e,i.toBytes())||(r.invalid||=[]).push(i);return r.invalid||r.missing?r:void 0}serialize(e){const{requireAllSignatures:t,verifySignatures:r}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},e),n=this.serializeMessage();if(r){const e=this._getMessageSignednessErrors(n,t);if(e){let t="Signature verification failed.";throw e.invalid&&(t+=`\nInvalid signature for public key${1===e.invalid.length?"":"(s)"} [\`${e.invalid.map((e=>e.toBase58())).join("`, `")}\`].`),e.missing&&(t+=`\nMissing signature for public key${1===e.missing.length?"":"(s)"} [\`${e.missing.map((e=>e.toBase58())).join("`, `")}\`].`),new Error(t)}}return this._serialize(n)}_serialize(e){const{signatures:t}=this,r=[];Ts(r,t.length);const n=r.length+64*t.length+e.length,i=C.alloc(n);return Rs(t.length<256),C.from(r).copy(i,0),t.forEach((({signature:e},t)=>{null!==e&&(Rs(64===e.length,"signature has invalid length"),C.from(e).copy(i,r.length+64*t))})),e.copy(i,r.length+64*t.length),Rs(i.length<=vs,`Transaction too large: ${i.length} > 1232`),i}get keys(){return Rs(1===this.instructions.length),this.instructions[0].keys.map((e=>e.pubkey))}get programId(){return Rs(1===this.instructions.length),this.instructions[0].programId}get data(){return Rs(1===this.instructions.length),this.instructions[0].data}static from(e){let t=[...e];const r=Bs(t);let n=[];for(let e=0;e0&&(r.feePayer=e.accountKeys[0]),t.forEach(((t,n)=>{const i={signature:t==Ur.encode($s)?null:Ur.decode(t),publicKey:e.accountKeys[n]};r.signatures.push(i)})),e.instructions.forEach((t=>{const n=t.accounts.map((t=>{const n=e.accountKeys[t];return{pubkey:n,isSigner:r.signatures.some((e=>e.publicKey.toString()===n.toString()))||e.isAccountSigner(t),isWritable:e.isAccountWritable(t)}}));r.instructions.push(new zs({keys:n,programId:e.accountKeys[t.programIdIndex],data:Ur.decode(t.data)}))})),r._message=e,r._json=r.toJSON(),r}}class Hs{get version(){return this.message.version}constructor(e,t){if(this.signatures=void 0,this.message=void 0,void 0!==t)Rs(t.length===e.header.numRequiredSignatures,"Expected signatures length to be equal to the number of required signatures"),this.signatures=t;else{const t=[];for(let r=0;re.equals(n.publicKey)));Rs(e>=0,`Cannot sign with non signer key ${n.publicKey.toBase58()}`),this.signatures[e]=hs(t,n.secretKey)}}addSignature(e,t){Rs(64===t.byteLength,"Signature must be 64 bytes long");const r=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex((t=>t.equals(e)));Rs(r>=0,`Can not add signature; \`${e.toBase58()}\` is not required to sign this transaction`),this.signatures[r]=t}}function qs(e){return new Promise((t=>setTimeout(t,e)))}new bs("SysvarC1ock11111111111111111111111111111111"),new bs("SysvarEpochSchedu1e111111111111111111111111"),new bs("Sysvar1nstructions1111111111111111111111111"),new bs("SysvarRecentB1ockHashes11111111111111111111"),new bs("SysvarRent111111111111111111111111111111111"),new bs("SysvarRewards111111111111111111111111111111"),new bs("SysvarS1otHashes111111111111111111111111111"),new bs("SysvarS1otHistory11111111111111111111111111"),new bs("SysvarStakeHistory1111111111111111111111111");const Fs=fi("lamportsPerSignature"),Ks=pi([hi("version"),hi("state"),As("authorizedPubkey"),As("nonce"),pi([Fs],"feeCalculator")]);Ks.span;class Ws{constructor(e){this.authorizedPubkey=void 0,this.nonce=void 0,this.feeCalculator=void 0,this.authorizedPubkey=e.authorizedPubkey,this.nonce=e.nonce,this.feeCalculator=e.feeCalculator}static fromAccountData(e){const t=Ks.decode(ds(e),0);return new Ws({authorizedPubkey:new bs(t.authorizedPubkey),nonce:new bs(t.nonce).toString(),feeCalculator:t.feeCalculator})}}const Vs=(Zs=8,e=>{const t=yi(Zs,e),{encode:r,decode:n}=(e=>({decode:e.decode.bind(e),encode:e.encode.bind(e)}))(t),i=t;return i.decode=(e,t)=>{const r=n(e,t);return wi(C.from(r))},i.encode=(e,t,n)=>{const i=vi(e,Zs);return r(i,t,n)},i});var Zs;function Gs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}Object.freeze({Create:{index:0,layout:pi([hi("instruction"),di("lamports"),di("space"),As("programId")])},Assign:{index:1,layout:pi([hi("instruction"),As("programId")])},Transfer:{index:2,layout:pi([hi("instruction"),Vs("lamports")])},CreateWithSeed:{index:3,layout:pi([hi("instruction"),As("base"),Is("seed"),di("lamports"),di("space"),As("programId")])},AdvanceNonceAccount:{index:4,layout:pi([hi("instruction")])},WithdrawNonceAccount:{index:5,layout:pi([hi("instruction"),di("lamports")])},InitializeNonceAccount:{index:6,layout:pi([hi("instruction"),As("authorized")])},AuthorizeNonceAccount:{index:7,layout:pi([hi("instruction"),As("authorized")])},Allocate:{index:8,layout:pi([hi("instruction"),di("space")])},AllocateWithSeed:{index:9,layout:pi([hi("instruction"),As("base"),Is("seed"),di("space"),As("programId")])},AssignWithSeed:{index:10,layout:pi([hi("instruction"),As("base"),Is("seed"),As("programId")])},TransferWithSeed:{index:11,layout:pi([hi("instruction"),Vs("lamports"),Is("seed"),As("programId")])},UpgradeNonceAccount:{index:12,layout:pi([hi("instruction")])}}),new bs("11111111111111111111111111111111"),new bs("BPFLoader2111111111111111111111111111111111");var Js=Object.prototype.toString,Ys=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};function Xs(e,t){var r,n,i,o,s,a,c;if(!0===e)return"true";if(!1===e)return"false";switch(typeof e){case"object":if(null===e)return null;if(e.toJSON&&"function"==typeof e.toJSON)return Xs(e.toJSON(),t);if("[object Array]"===(c=Js.call(e))){for(i="[",n=e.length-1,r=0;r-1&&(i+=Xs(e[r],!0)),i+"]"}if("[object Object]"===c){for(n=(o=Ys(e).sort()).length,i="",r=0;r1;)e/=2,t++;return t}class ta{constructor(e,t,r,n,i){this.slotsPerEpoch=void 0,this.leaderScheduleSlotOffset=void 0,this.warmup=void 0,this.firstNormalEpoch=void 0,this.firstNormalSlot=void 0,this.slotsPerEpoch=e,this.leaderScheduleSlotOffset=t,this.warmup=r,this.firstNormalEpoch=n,this.firstNormalSlot=i}getEpoch(e){return this.getEpochAndSlotIndex(e)[0]}getEpochAndSlotIndex(e){if(e>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,1+(e|=e>>32))}(e+32+1))-ea(32)-1;return[t,e-(this.getSlotsInEpoch(t)-32)]}{const t=e-this.firstNormalSlot,r=Math.floor(t/this.slotsPerEpoch);return[this.firstNormalEpoch+r,t%this.slotsPerEpoch]}}getFirstSlotInEpoch(e){return e<=this.firstNormalEpoch?32*(Math.pow(2,e)-1):(e-this.firstNormalEpoch)*this.slotsPerEpoch+this.firstNormalSlot}getLastSlotInEpoch(e){return this.getFirstSlotInEpoch(e)+this.getSlotsInEpoch(e)-1}getSlotsInEpoch(e){return e{const r=jo(e,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...t});return this.underlyingSocket="socket"in r?r.socket:r,r}),e,t,r),this.underlyingSocket=void 0}call(...e){const t=this.underlyingSocket?.readyState;return 1===t?super.call(...e):Promise.reject(new Error("Tried to call a JSON-RPC method `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+")"))}notify(...e){const t=this.underlyingSocket?.readyState;return 1===t?super.notify(...e):Promise.reject(new Error("Tried to send a JSON-RPC notification `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+")"))}}class sa{constructor(e){this.key=void 0,this.state=void 0,this.key=e.key,this.state=e.state}isActive(){const e=BigInt("0xffffffffffffffff");return this.state.deactivationSlot===e}static deserialize(e){const t=function(e,t){let r;try{r=e.layout.decode(t)}catch(e){throw new Error("invalid instruction; "+e)}if(r.typeIndex!==e.index)throw new Error(`invalid account data; account type mismatch ${r.typeIndex} != ${e.index}`);return r}(aa,e),r=e.length-56;Rs(r>=0,"lookup table is invalid"),Rs(r%32==0,"lookup table is invalid");const n=r/32,{addresses:i}=pi([gi(As(),n,"addresses")]).decode(e.slice(56));return{deactivationSlot:t.deactivationSlot,lastExtendedSlot:t.lastExtendedSlot,lastExtendedSlotStartIndex:t.lastExtendedStartIndex,authority:0!==t.authority.length?new bs(t.authority[0]):void 0,addresses:i.map((e=>new bs(e)))}}}const aa={index:1,layout:pi([hi("typeIndex"),Vs("deactivationSlot"),fi("lastExtendedSlot"),ui("lastExtendedStartIndex"),ui(),gi(As(),ci(ui(),-1),"authority")])},ca=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;const ua=Ki(Ci(bs),zi(),(e=>new bs(e))),la=Di([zi(),Pi("base64")]),ha=Ki(Ci(C),la,(e=>C.from(e[0],"base64")));function fa(e){let t,r;if("string"==typeof e)t=e;else if(e){const{commitment:n,...i}=e;t=n,r=i}return{commitment:t,config:r}}function da(e){return qi([Hi({jsonrpc:Pi("2.0"),id:zi(),result:e}),Hi({jsonrpc:Pi("2.0"),id:zi(),error:Hi({code:Fi(),message:zi(),data:ji(Oi("any",(()=>!0)))})})])}const pa=da(Fi());function ga(e){return Ki(da(e),pa,(t=>"error"in t?t:{...t,result:Bi(t.result,e)}))}function ya(e){return ga(Hi({context:Hi({slot:Ui()}),value:e}))}function ma(e){return Hi({context:Hi({slot:Ui()}),value:e})}function wa(e,t){return 0===e?new Ns({header:t.header,staticAccountKeys:t.accountKeys.map((e=>new bs(e))),recentBlockhash:t.recentBlockhash,compiledInstructions:t.instructions.map((e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:Ur.decode(e.data)}))),addressTableLookups:t.addressTableLookups}):new Ps(t)}const ba=Hi({foundation:Ui(),foundationTerm:Ui(),initial:Ui(),taper:Ui(),terminal:Ui()}),va=ga(Mi(Ni(Hi({epoch:Ui(),effectiveSlot:Ui(),amount:Ui(),postBalance:Ui(),commission:ji(Ni(Ui()))})))),_a=Mi(Hi({slot:Ui(),prioritizationFee:Ui()})),Ea=Hi({total:Ui(),validator:Ui(),foundation:Ui(),epoch:Ui()}),Sa=Hi({epoch:Ui(),slotIndex:Ui(),slotsInEpoch:Ui(),absoluteSlot:Ui(),blockHeight:ji(Ui()),transactionCount:ji(Ui())}),xa=Hi({slotsPerEpoch:Ui(),leaderScheduleSlotOffset:Ui(),warmup:Li(),firstNormalEpoch:Ui(),firstNormalSlot:Ui()}),Aa=$i(zi(),Mi(Ui())),ka=Ni(qi([Hi({}),zi()])),Ia=Hi({err:ka}),Ba=Pi("receivedSignature"),Ta=Hi({"solana-core":zi(),"feature-set":ji(Ui())}),Ra=ya(Hi({err:Ni(qi([Hi({}),zi()])),logs:Ni(Mi(zi())),accounts:ji(Ni(Mi(Ni(Hi({executable:Li(),owner:zi(),lamports:Ui(),data:Mi(zi()),rentEpoch:ji(Ui())}))))),unitsConsumed:ji(Ui()),returnData:ji(Ni(Hi({programId:zi(),data:Di([zi(),Pi("base64")])})))})),Oa=ya(Hi({byIdentity:$i(zi(),Mi(Ui())),range:Hi({firstSlot:Ui(),lastSlot:Ui()})}));const Ma=ga(ba),La=ga(Ea),Ca=ga(_a),Pa=ga(Sa),Na=ga(xa),Ua=ga(Aa),ja=ga(Ui()),$a=ya(Hi({total:Ui(),circulating:Ui(),nonCirculating:Ui(),nonCirculatingAccounts:Mi(ua)})),za=Hi({amount:zi(),uiAmount:Ni(Ui()),decimals:Ui(),uiAmountString:ji(zi())}),Da=ya(Mi(Hi({address:ua,amount:zi(),uiAmount:Ni(Ui()),decimals:Ui(),uiAmountString:ji(zi())}))),Ha=ya(Mi(Hi({pubkey:ua,account:Hi({executable:Li(),owner:ua,lamports:Ui(),data:ha,rentEpoch:Ui()})}))),qa=Hi({program:zi(),parsed:Fi(),space:Ui()}),Fa=ya(Mi(Hi({pubkey:ua,account:Hi({executable:Li(),owner:ua,lamports:Ui(),data:qa,rentEpoch:Ui()})}))),Ka=ya(Mi(Hi({lamports:Ui(),address:ua}))),Wa=Hi({executable:Li(),owner:ua,lamports:Ui(),data:ha,rentEpoch:Ui()}),Va=Hi({pubkey:ua,account:Wa}),Za=Ki(qi([Ci(C),qa]),qi([la,qa]),(e=>Array.isArray(e)?Bi(e,ha):e)),Ga=Hi({executable:Li(),owner:ua,lamports:Ui(),data:Za,rentEpoch:Ui()}),Ja=Hi({pubkey:ua,account:Ga}),Ya=Hi({state:qi([Pi("active"),Pi("inactive"),Pi("activating"),Pi("deactivating")]),active:Ui(),inactive:Ui()}),Xa=ga(Mi(Hi({signature:zi(),slot:Ui(),err:ka,memo:Ni(zi()),blockTime:ji(Ni(Ui()))}))),Qa=ga(Mi(Hi({signature:zi(),slot:Ui(),err:ka,memo:Ni(zi()),blockTime:ji(Ni(Ui()))}))),ec=Hi({subscription:Ui(),result:ma(Wa)}),tc=Hi({pubkey:ua,account:Wa}),rc=Hi({subscription:Ui(),result:ma(tc)}),nc=Hi({parent:Ui(),slot:Ui(),root:Ui()}),ic=Hi({subscription:Ui(),result:nc}),oc=qi([Hi({type:qi([Pi("firstShredReceived"),Pi("completed"),Pi("optimisticConfirmation"),Pi("root")]),slot:Ui(),timestamp:Ui()}),Hi({type:Pi("createdBank"),parent:Ui(),slot:Ui(),timestamp:Ui()}),Hi({type:Pi("frozen"),slot:Ui(),timestamp:Ui(),stats:Hi({numTransactionEntries:Ui(),numSuccessfulTransactions:Ui(),numFailedTransactions:Ui(),maxTransactionsPerEntry:Ui()})}),Hi({type:Pi("dead"),slot:Ui(),timestamp:Ui(),err:zi()})]),sc=Hi({subscription:Ui(),result:oc}),ac=Hi({subscription:Ui(),result:ma(qi([Ia,Ba]))}),cc=Hi({subscription:Ui(),result:Ui()}),uc=Hi({pubkey:zi(),gossip:Ni(zi()),tpu:Ni(zi()),rpc:Ni(zi()),version:Ni(zi())}),lc=Hi({votePubkey:zi(),nodePubkey:zi(),activatedStake:Ui(),epochVoteAccount:Li(),epochCredits:Mi(Di([Ui(),Ui(),Ui()])),commission:Ui(),lastVote:Ui(),rootSlot:Ni(Ui())}),hc=ga(Hi({current:Mi(lc),delinquent:Mi(lc)})),fc=qi([Pi("processed"),Pi("confirmed"),Pi("finalized")]),dc=Hi({slot:Ui(),confirmations:Ni(Ui()),err:ka,confirmationStatus:ji(fc)}),pc=ya(Mi(Ni(dc))),gc=ga(Ui()),yc=Hi({accountKey:ua,writableIndexes:Mi(Ui()),readonlyIndexes:Mi(Ui())}),mc=Hi({signatures:Mi(zi()),message:Hi({accountKeys:Mi(zi()),header:Hi({numRequiredSignatures:Ui(),numReadonlySignedAccounts:Ui(),numReadonlyUnsignedAccounts:Ui()}),instructions:Mi(Hi({accounts:Mi(Ui()),data:zi(),programIdIndex:Ui()})),recentBlockhash:zi(),addressTableLookups:ji(Mi(yc))})}),wc=Hi({pubkey:ua,signer:Li(),writable:Li(),source:ji(qi([Pi("transaction"),Pi("lookupTable")]))}),bc=Hi({accountKeys:Mi(wc),signatures:Mi(zi())}),vc=Hi({parsed:Fi(),program:zi(),programId:ua}),_c=Hi({accounts:Mi(ua),data:zi(),programId:ua}),Ec=Ki(qi([_c,vc]),qi([Hi({parsed:Fi(),program:zi(),programId:zi()}),Hi({accounts:Mi(zi()),data:zi(),programId:zi()})]),(e=>Bi(e,"accounts"in e?_c:vc))),Sc=Hi({signatures:Mi(zi()),message:Hi({accountKeys:Mi(wc),instructions:Mi(Ec),recentBlockhash:zi(),addressTableLookups:ji(Ni(Mi(yc)))})}),xc=Hi({accountIndex:Ui(),mint:zi(),owner:ji(zi()),uiTokenAmount:za}),Ac=Hi({writable:Mi(ua),readonly:Mi(ua)}),kc=Hi({err:ka,fee:Ui(),innerInstructions:ji(Ni(Mi(Hi({index:Ui(),instructions:Mi(Hi({accounts:Mi(Ui()),data:zi(),programIdIndex:Ui()}))})))),preBalances:Mi(Ui()),postBalances:Mi(Ui()),logMessages:ji(Ni(Mi(zi()))),preTokenBalances:ji(Ni(Mi(xc))),postTokenBalances:ji(Ni(Mi(xc))),loadedAddresses:ji(Ac),computeUnitsConsumed:ji(Ui())}),Ic=Hi({err:ka,fee:Ui(),innerInstructions:ji(Ni(Mi(Hi({index:Ui(),instructions:Mi(Ec)})))),preBalances:Mi(Ui()),postBalances:Mi(Ui()),logMessages:ji(Ni(Mi(zi()))),preTokenBalances:ji(Ni(Mi(xc))),postTokenBalances:ji(Ni(Mi(xc))),loadedAddresses:ji(Ac),computeUnitsConsumed:ji(Ui())}),Bc=qi([Pi(0),Pi("legacy")]),Tc=Hi({pubkey:zi(),lamports:Ui(),postBalance:Ni(Ui()),rewardType:Ni(zi()),commission:ji(Ni(Ui()))}),Rc=ga(Ni(Hi({blockhash:zi(),previousBlockhash:zi(),parentSlot:Ui(),transactions:Mi(Hi({transaction:mc,meta:Ni(kc),version:ji(Bc)})),rewards:ji(Mi(Tc)),blockTime:Ni(Ui()),blockHeight:Ni(Ui())}))),Oc=ga(Ni(Hi({blockhash:zi(),previousBlockhash:zi(),parentSlot:Ui(),rewards:ji(Mi(Tc)),blockTime:Ni(Ui()),blockHeight:Ni(Ui())}))),Mc=ga(Ni(Hi({blockhash:zi(),previousBlockhash:zi(),parentSlot:Ui(),transactions:Mi(Hi({transaction:bc,meta:Ni(kc),version:ji(Bc)})),rewards:ji(Mi(Tc)),blockTime:Ni(Ui()),blockHeight:Ni(Ui())}))),Lc=ga(Ni(Hi({blockhash:zi(),previousBlockhash:zi(),parentSlot:Ui(),transactions:Mi(Hi({transaction:Sc,meta:Ni(Ic),version:ji(Bc)})),rewards:ji(Mi(Tc)),blockTime:Ni(Ui()),blockHeight:Ni(Ui())}))),Cc=ga(Ni(Hi({blockhash:zi(),previousBlockhash:zi(),parentSlot:Ui(),transactions:Mi(Hi({transaction:bc,meta:Ni(Ic),version:ji(Bc)})),rewards:ji(Mi(Tc)),blockTime:Ni(Ui()),blockHeight:Ni(Ui())}))),Pc=ga(Ni(Hi({blockhash:zi(),previousBlockhash:zi(),parentSlot:Ui(),rewards:ji(Mi(Tc)),blockTime:Ni(Ui()),blockHeight:Ni(Ui())}))),Nc=ga(Ni(Hi({blockhash:zi(),previousBlockhash:zi(),parentSlot:Ui(),transactions:Mi(Hi({transaction:mc,meta:Ni(kc)})),rewards:ji(Mi(Tc)),blockTime:Ni(Ui())}))),Uc=ga(Ni(Hi({blockhash:zi(),previousBlockhash:zi(),parentSlot:Ui(),signatures:Mi(zi()),blockTime:Ni(Ui())}))),jc=ga(Ni(Hi({slot:Ui(),meta:Ni(kc),blockTime:ji(Ni(Ui())),transaction:mc,version:ji(Bc)}))),$c=ga(Ni(Hi({slot:Ui(),transaction:Sc,meta:Ni(Ic),blockTime:ji(Ni(Ui())),version:ji(Bc)}))),zc=ya(Hi({blockhash:zi(),feeCalculator:Hi({lamportsPerSignature:Ui()})})),Dc=ya(Hi({blockhash:zi(),lastValidBlockHeight:Ui()})),Hc=ya(Li()),qc=ga(Mi(Hi({slot:Ui(),numTransactions:Ui(),numSlots:Ui(),samplePeriodSecs:Ui()}))),Fc=ya(Ni(Hi({feeCalculator:Hi({lamportsPerSignature:Ui()})}))),Kc=ga(zi()),Wc=ga(zi()),Vc=Hi({err:ka,logs:Mi(zi()),signature:zi()}),Zc=Hi({result:ma(Vc),subscription:Ui()}),Gc={"solana-client":"js/0.0.0-development"};class Jc{constructor(e,t){let r,n,i,o,s,a;this._commitment=void 0,this._confirmTransactionInitialTimeout=void 0,this._rpcEndpoint=void 0,this._rpcWsEndpoint=void 0,this._rpcClient=void 0,this._rpcRequest=void 0,this._rpcBatchRequest=void 0,this._rpcWebSocket=void 0,this._rpcWebSocketConnected=!1,this._rpcWebSocketHeartbeat=null,this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketGeneration=0,this._disableBlockhashCaching=!1,this._pollingBlockhash=!1,this._blockhashInfo={latestBlockhash:null,lastFetch:0,transactionSignatures:[],simulatedSignatures:[]},this._nextClientSubscriptionId=0,this._subscriptionDisposeFunctionsByClientSubscriptionId={},this._subscriptionHashByClientSubscriptionId={},this._subscriptionStateChangeCallbacksByHash={},this._subscriptionCallbacksByServerSubscriptionId={},this._subscriptionsByHash={},this._subscriptionsAutoDisposedByRpc=new Set,this.getBlockHeight=(()=>{const e={};return async t=>{const{commitment:r,config:n}=fa(t),i=this._buildArgs([],r,void 0,n),o=Qs(i);return e[o]=e[o]??(async()=>{try{const e=Bi(await this._rpcRequest("getBlockHeight",i),ga(Ui()));if("error"in e)throw new na(e.error,"failed to get block height information");return e.result}finally{delete e[o]}})(),await e[o]}})(),t&&"string"==typeof t?this._commitment=t:t&&(this._commitment=t.commitment,this._confirmTransactionInitialTimeout=t.confirmTransactionInitialTimeout,r=t.wsEndpoint,n=t.httpHeaders,i=t.fetch,o=t.fetchMiddleware,s=t.disableRetryOnRateLimit,a=t.httpAgent),this._rpcEndpoint=function(e){if(!1===/^https?:/.test(e))throw new TypeError("Endpoint URL must start with `http:` or `https:`.");return e}(e),this._rpcWsEndpoint=r||function(e){const t=e.match(ca);if(null==t)throw TypeError(`Failed to validate endpoint URL \`${e}\``);const[r,n,i,o]=t,s=e.startsWith("https:")?"wss:":"ws:",a=null==i?null:parseInt(i.slice(1),10);return`${s}//${n}${null==a?"":`:${a+1}`}${o}`}(e),this._rpcClient=function(e,t,r,n,i,o){const s=r||ia;let a;null!=o&&console.warn("You have supplied an `httpAgent` when creating a `Connection` in a browser environment.It has been ignored; `httpAgent` is only used in Node environments."),n&&(a=async(e,t)=>{const r=await new Promise(((r,i)=>{try{n(e,t,((e,t)=>r([e,t])))}catch(e){i(e)}}));return await s(...r)});const c=new ko((async(r,n)=>{const o={method:"POST",body:r,agent:void 0,headers:Object.assign({"Content-Type":"application/json"},t||{},Gc)};try{let t,r=5,c=500;for(;t=a?await a(e,o):await s(e,o),429===t.status&&!0!==i&&(r-=1,0!==r);)console.error(`Server responded with ${t.status} ${t.statusText}. Retrying after ${c}ms delay...`),await qs(c),c*=2;const u=await t.text();t.ok?n(null,u):n(new Error(`${t.status} ${t.statusText}: ${u}`))}catch(e){e instanceof Error&&n(e)}}),{});return c}(e,n,i,o,s,a),this._rpcRequest=function(e){return(t,r)=>new Promise(((n,i)=>{e.request(t,r,((e,t)=>{e?i(e):n(t)}))}))}(this._rpcClient),this._rpcBatchRequest=function(e){return t=>new Promise(((r,n)=>{0===t.length&&r([]);const i=t.map((t=>e.request(t.methodName,t.args)));e.request(i,((e,t)=>{e?n(e):r(t)}))}))}(this._rpcClient),this._rpcWebSocket=new oa(this._rpcWsEndpoint,{autoconnect:!1,max_reconnects:1/0}),this._rpcWebSocket.on("open",this._wsOnOpen.bind(this)),this._rpcWebSocket.on("error",this._wsOnError.bind(this)),this._rpcWebSocket.on("close",this._wsOnClose.bind(this)),this._rpcWebSocket.on("accountNotification",this._wsOnAccountNotification.bind(this)),this._rpcWebSocket.on("programNotification",this._wsOnProgramAccountNotification.bind(this)),this._rpcWebSocket.on("slotNotification",this._wsOnSlotNotification.bind(this)),this._rpcWebSocket.on("slotsUpdatesNotification",this._wsOnSlotUpdatesNotification.bind(this)),this._rpcWebSocket.on("signatureNotification",this._wsOnSignatureNotification.bind(this)),this._rpcWebSocket.on("rootNotification",this._wsOnRootNotification.bind(this)),this._rpcWebSocket.on("logsNotification",this._wsOnLogsNotification.bind(this))}get commitment(){return this._commitment}get rpcEndpoint(){return this._rpcEndpoint}async getBalanceAndContext(e,t){const{commitment:r,config:n}=fa(t),i=this._buildArgs([e.toBase58()],r,void 0,n),o=Bi(await this._rpcRequest("getBalance",i),ya(Ui()));if("error"in o)throw new na(o.error,`failed to get balance for ${e.toBase58()}`);return o.result}async getBalance(e,t){return await this.getBalanceAndContext(e,t).then((e=>e.value)).catch((t=>{throw new Error("failed to get balance of account "+e.toBase58()+": "+t)}))}async getBlockTime(e){const t=Bi(await this._rpcRequest("getBlockTime",[e]),ga(Ni(Ui())));if("error"in t)throw new na(t.error,`failed to get block time for slot ${e}`);return t.result}async getMinimumLedgerSlot(){const e=Bi(await this._rpcRequest("minimumLedgerSlot",[]),ga(Ui()));if("error"in e)throw new na(e.error,"failed to get minimum ledger slot");return e.result}async getFirstAvailableBlock(){const e=Bi(await this._rpcRequest("getFirstAvailableBlock",[]),ja);if("error"in e)throw new na(e.error,"failed to get first available block");return e.result}async getSupply(e){let t={};t="string"==typeof e?{commitment:e}:e?{...e,commitment:e&&e.commitment||this.commitment}:{commitment:this.commitment};const r=Bi(await this._rpcRequest("getSupply",[t]),$a);if("error"in r)throw new na(r.error,"failed to get supply");return r.result}async getTokenSupply(e,t){const r=this._buildArgs([e.toBase58()],t),n=Bi(await this._rpcRequest("getTokenSupply",r),ya(za));if("error"in n)throw new na(n.error,"failed to get token supply");return n.result}async getTokenAccountBalance(e,t){const r=this._buildArgs([e.toBase58()],t),n=Bi(await this._rpcRequest("getTokenAccountBalance",r),ya(za));if("error"in n)throw new na(n.error,"failed to get token account balance");return n.result}async getTokenAccountsByOwner(e,t,r){const{commitment:n,config:i}=fa(r);let o=[e.toBase58()];"mint"in t?o.push({mint:t.mint.toBase58()}):o.push({programId:t.programId.toBase58()});const s=this._buildArgs(o,n,"base64",i),a=Bi(await this._rpcRequest("getTokenAccountsByOwner",s),Ha);if("error"in a)throw new na(a.error,`failed to get token accounts owned by account ${e.toBase58()}`);return a.result}async getParsedTokenAccountsByOwner(e,t,r){let n=[e.toBase58()];"mint"in t?n.push({mint:t.mint.toBase58()}):n.push({programId:t.programId.toBase58()});const i=this._buildArgs(n,r,"jsonParsed"),o=Bi(await this._rpcRequest("getTokenAccountsByOwner",i),Fa);if("error"in o)throw new na(o.error,`failed to get token accounts owned by account ${e.toBase58()}`);return o.result}async getLargestAccounts(e){const t={...e,commitment:e&&e.commitment||this.commitment},r=t.filter||t.commitment?[t]:[],n=Bi(await this._rpcRequest("getLargestAccounts",r),Ka);if("error"in n)throw new na(n.error,"failed to get largest accounts");return n.result}async getTokenLargestAccounts(e,t){const r=this._buildArgs([e.toBase58()],t),n=Bi(await this._rpcRequest("getTokenLargestAccounts",r),Da);if("error"in n)throw new na(n.error,"failed to get token largest accounts");return n.result}async getAccountInfoAndContext(e,t){const{commitment:r,config:n}=fa(t),i=this._buildArgs([e.toBase58()],r,"base64",n),o=Bi(await this._rpcRequest("getAccountInfo",i),ya(Ni(Wa)));if("error"in o)throw new na(o.error,`failed to get info about account ${e.toBase58()}`);return o.result}async getParsedAccountInfo(e,t){const{commitment:r,config:n}=fa(t),i=this._buildArgs([e.toBase58()],r,"jsonParsed",n),o=Bi(await this._rpcRequest("getAccountInfo",i),ya(Ni(Ga)));if("error"in o)throw new na(o.error,`failed to get info about account ${e.toBase58()}`);return o.result}async getAccountInfo(e,t){try{return(await this.getAccountInfoAndContext(e,t)).value}catch(t){throw new Error("failed to get info about account "+e.toBase58()+": "+t)}}async getMultipleParsedAccounts(e,t){const{commitment:r,config:n}=fa(t),i=e.map((e=>e.toBase58())),o=this._buildArgs([i],r,"jsonParsed",n),s=Bi(await this._rpcRequest("getMultipleAccounts",o),ya(Mi(Ni(Ga))));if("error"in s)throw new na(s.error,`failed to get info for accounts ${i}`);return s.result}async getMultipleAccountsInfoAndContext(e,t){const{commitment:r,config:n}=fa(t),i=e.map((e=>e.toBase58())),o=this._buildArgs([i],r,"base64",n),s=Bi(await this._rpcRequest("getMultipleAccounts",o),ya(Mi(Ni(Wa))));if("error"in s)throw new na(s.error,`failed to get info for accounts ${i}`);return s.result}async getMultipleAccountsInfo(e,t){return(await this.getMultipleAccountsInfoAndContext(e,t)).value}async getStakeActivation(e,t,r){const{commitment:n,config:i}=fa(t),o=this._buildArgs([e.toBase58()],n,void 0,{...i,epoch:null!=r?r:i?.epoch}),s=Bi(await this._rpcRequest("getStakeActivation",o),ga(Ya));if("error"in s)throw new na(s.error,`failed to get Stake Activation ${e.toBase58()}`);return s.result}async getProgramAccounts(e,t){const{commitment:r,config:n}=fa(t),{encoding:i,...o}=n||{},s=this._buildArgs([e.toBase58()],r,i||"base64",o),a=await this._rpcRequest("getProgramAccounts",s),c=Mi(Va),u=!0===o.withContext?Bi(a,ya(c)):Bi(a,ga(c));if("error"in u)throw new na(u.error,`failed to get accounts owned by program ${e.toBase58()}`);return u.result}async getParsedProgramAccounts(e,t){const{commitment:r,config:n}=fa(t),i=this._buildArgs([e.toBase58()],r,"jsonParsed",n),o=Bi(await this._rpcRequest("getProgramAccounts",i),ga(Mi(Ja)));if("error"in o)throw new na(o.error,`failed to get accounts owned by program ${e.toBase58()}`);return o.result}async confirmTransaction(e,t){let r,n;if("string"==typeof e)r=e;else{const t=e;if(t.abortSignal?.aborted)return Promise.reject(t.abortSignal.reason);r=t.signature}try{n=Ur.decode(r)}catch(e){throw new Error("signature must be base58 encoded: "+r)}return Rs(64===n.length,"signature has invalid length"),"string"==typeof e?await this.confirmTransactionUsingLegacyTimeoutStrategy({commitment:t||this.commitment,signature:r}):"lastValidBlockHeight"in e?await this.confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:t||this.commitment,strategy:e}):await this.confirmTransactionUsingDurableNonceStrategy({commitment:t||this.commitment,strategy:e})}getCancellationPromise(e){return new Promise(((t,r)=>{null!=e&&(e.aborted?r(e.reason):e.addEventListener("abort",(()=>{r(e.reason)})))}))}getTransactionConfirmationPromise({commitment:e,signature:t}){let r,n,i=!1;const o=new Promise(((o,s)=>{try{r=this.onSignature(t,((e,t)=>{r=void 0;const n={context:t,value:e};o({__type:js.PROCESSED,response:n})}),e);const a=new Promise((e=>{null==r?e():n=this._onSubscriptionStateChange(r,(t=>{"subscribed"===t&&e()}))}));(async()=>{if(await a,i)return;const r=await this.getSignatureStatus(t);if(i)return;if(null==r)return;const{context:n,value:c}=r;if(null!=c)if(c?.err)s(c.err);else{switch(e){case"confirmed":case"single":case"singleGossip":if("processed"===c.confirmationStatus)return;break;case"finalized":case"max":case"root":if("processed"===c.confirmationStatus||"confirmed"===c.confirmationStatus)return}i=!0,o({__type:js.PROCESSED,response:{context:n,value:c}})}})()}catch(e){s(e)}}));return{abortConfirmation:()=>{n&&(n(),n=void 0),null!=r&&(this.removeSignatureListener(r),r=void 0)},confirmationPromise:o}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:e,strategy:{abortSignal:t,lastValidBlockHeight:r,signature:n}}){let i=!1;const o=new Promise((t=>{const n=async()=>{try{return await this.getBlockHeight(e)}catch(e){return-1}};(async()=>{let e=await n();if(!i){for(;e<=r;){if(await qs(1e3),i)return;if(e=await n(),i)return}t({__type:js.BLOCKHEIGHT_EXCEEDED})}})()})),{abortConfirmation:s,confirmationPromise:a}=this.getTransactionConfirmationPromise({commitment:e,signature:n}),c=this.getCancellationPromise(t);let u;try{const e=await Promise.race([c,a,o]);if(e.__type!==js.PROCESSED)throw new _s(n);u=e.response}finally{i=!0,s()}return u}async confirmTransactionUsingDurableNonceStrategy({commitment:e,strategy:{abortSignal:t,minContextSlot:r,nonceAccountPubkey:n,nonceValue:i,signature:o}}){let s=!1;const a=new Promise((t=>{let o=i,a=null;const c=async()=>{try{const{context:t,value:i}=await this.getNonceAndContext(n,{commitment:e,minContextSlot:r});return a=t.slot,i?.nonce}catch(e){return o}};(async()=>{if(o=await c(),!s)for(;;){if(i!==o)return void t({__type:js.NONCE_INVALID,slotInWhichNonceDidAdvance:a});if(await qs(2e3),s)return;if(o=await c(),s)return}})()})),{abortConfirmation:c,confirmationPromise:u}=this.getTransactionConfirmationPromise({commitment:e,signature:o}),l=this.getCancellationPromise(t);let h;try{const t=await Promise.race([l,u,a]);if(t.__type===js.PROCESSED)h=t.response;else{let n;for(;;){const e=await this.getSignatureStatus(o);if(null==e)break;if(!(e.context.slot<(t.slotInWhichNonceDidAdvance??r))){n=e;break}await qs(400)}if(!n?.value)throw new Ss(o);{const t=e||"finalized",{confirmationStatus:r}=n.value;switch(t){case"processed":case"recent":if("processed"!==r&&"confirmed"!==r&&"finalized"!==r)throw new Ss(o);break;case"confirmed":case"single":case"singleGossip":if("confirmed"!==r&&"finalized"!==r)throw new Ss(o);break;case"finalized":case"max":case"root":if("finalized"!==r)throw new Ss(o)}h={context:n.context,value:{err:n.value.err}}}}}finally{s=!0,c()}return h}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:e,signature:t}){let r;const n=new Promise((t=>{let n=this._confirmTransactionInitialTimeout||6e4;switch(e){case"processed":case"recent":case"single":case"confirmed":case"singleGossip":n=this._confirmTransactionInitialTimeout||3e4}r=setTimeout((()=>t({__type:js.TIMED_OUT,timeoutMs:n})),n)})),{abortConfirmation:i,confirmationPromise:o}=this.getTransactionConfirmationPromise({commitment:e,signature:t});let s;try{const e=await Promise.race([o,n]);if(e.__type!==js.PROCESSED)throw new Es(t,e.timeoutMs/1e3);s=e.response}finally{clearTimeout(r),i()}return s}async getClusterNodes(){const e=Bi(await this._rpcRequest("getClusterNodes",[]),ga(Mi(uc)));if("error"in e)throw new na(e.error,"failed to get cluster nodes");return e.result}async getVoteAccounts(e){const t=this._buildArgs([],e),r=Bi(await this._rpcRequest("getVoteAccounts",t),hc);if("error"in r)throw new na(r.error,"failed to get vote accounts");return r.result}async getSlot(e){const{commitment:t,config:r}=fa(e),n=this._buildArgs([],t,void 0,r),i=Bi(await this._rpcRequest("getSlot",n),ga(Ui()));if("error"in i)throw new na(i.error,"failed to get slot");return i.result}async getSlotLeader(e){const{commitment:t,config:r}=fa(e),n=this._buildArgs([],t,void 0,r),i=Bi(await this._rpcRequest("getSlotLeader",n),ga(zi()));if("error"in i)throw new na(i.error,"failed to get slot leader");return i.result}async getSlotLeaders(e,t){const r=[e,t],n=Bi(await this._rpcRequest("getSlotLeaders",r),ga(Mi(ua)));if("error"in n)throw new na(n.error,"failed to get slot leaders");return n.result}async getSignatureStatus(e,t){const{context:r,value:n}=await this.getSignatureStatuses([e],t);Rs(1===n.length);return{context:r,value:n[0]}}async getSignatureStatuses(e,t){const r=[e];t&&r.push(t);const n=Bi(await this._rpcRequest("getSignatureStatuses",r),pc);if("error"in n)throw new na(n.error,"failed to get signature status");return n.result}async getTransactionCount(e){const{commitment:t,config:r}=fa(e),n=this._buildArgs([],t,void 0,r),i=Bi(await this._rpcRequest("getTransactionCount",n),ga(Ui()));if("error"in i)throw new na(i.error,"failed to get transaction count");return i.result}async getTotalSupply(e){return(await this.getSupply({commitment:e,excludeNonCirculatingAccountsList:!0})).value.total}async getInflationGovernor(e){const t=this._buildArgs([],e),r=Bi(await this._rpcRequest("getInflationGovernor",t),Ma);if("error"in r)throw new na(r.error,"failed to get inflation");return r.result}async getInflationReward(e,t,r){const{commitment:n,config:i}=fa(r),o=this._buildArgs([e.map((e=>e.toBase58()))],n,void 0,{...i,epoch:null!=t?t:i?.epoch}),s=Bi(await this._rpcRequest("getInflationReward",o),va);if("error"in s)throw new na(s.error,"failed to get inflation reward");return s.result}async getInflationRate(){const e=Bi(await this._rpcRequest("getInflationRate",[]),La);if("error"in e)throw new na(e.error,"failed to get inflation rate");return e.result}async getEpochInfo(e){const{commitment:t,config:r}=fa(e),n=this._buildArgs([],t,void 0,r),i=Bi(await this._rpcRequest("getEpochInfo",n),Pa);if("error"in i)throw new na(i.error,"failed to get epoch info");return i.result}async getEpochSchedule(){const e=Bi(await this._rpcRequest("getEpochSchedule",[]),Na);if("error"in e)throw new na(e.error,"failed to get epoch schedule");const t=e.result;return new ta(t.slotsPerEpoch,t.leaderScheduleSlotOffset,t.warmup,t.firstNormalEpoch,t.firstNormalSlot)}async getLeaderSchedule(){const e=Bi(await this._rpcRequest("getLeaderSchedule",[]),Ua);if("error"in e)throw new na(e.error,"failed to get leader schedule");return e.result}async getMinimumBalanceForRentExemption(e,t){const r=this._buildArgs([e],t),n=Bi(await this._rpcRequest("getMinimumBalanceForRentExemption",r),gc);return"error"in n?(console.warn("Unable to fetch minimum balance for rent exemption"),0):n.result}async getRecentBlockhashAndContext(e){const t=this._buildArgs([],e),r=Bi(await this._rpcRequest("getRecentBlockhash",t),zc);if("error"in r)throw new na(r.error,"failed to get recent blockhash");return r.result}async getRecentPerformanceSamples(e){const t=Bi(await this._rpcRequest("getRecentPerformanceSamples",e?[e]:[]),qc);if("error"in t)throw new na(t.error,"failed to get recent performance samples");return t.result}async getFeeCalculatorForBlockhash(e,t){const r=this._buildArgs([e],t),n=Bi(await this._rpcRequest("getFeeCalculatorForBlockhash",r),Fc);if("error"in n)throw new na(n.error,"failed to get fee calculator");const{context:i,value:o}=n.result;return{context:i,value:null!==o?o.feeCalculator:null}}async getFeeForMessage(e,t){const r=ds(e.serialize()).toString("base64"),n=this._buildArgs([r],t),i=Bi(await this._rpcRequest("getFeeForMessage",n),ya(Ni(Ui())));if("error"in i)throw new na(i.error,"failed to get fee for message");if(null===i.result)throw new Error("invalid blockhash");return i.result}async getRecentPrioritizationFees(e){const t=e?.lockedWritableAccounts?.map((e=>e.toBase58())),r=t?.length?[t]:[],n=Bi(await this._rpcRequest("getRecentPrioritizationFees",r),Ca);if("error"in n)throw new na(n.error,"failed to get recent prioritization fees");return n.result}async getRecentBlockhash(e){try{return(await this.getRecentBlockhashAndContext(e)).value}catch(e){throw new Error("failed to get recent blockhash: "+e)}}async getLatestBlockhash(e){try{return(await this.getLatestBlockhashAndContext(e)).value}catch(e){throw new Error("failed to get recent blockhash: "+e)}}async getLatestBlockhashAndContext(e){const{commitment:t,config:r}=fa(e),n=this._buildArgs([],t,void 0,r),i=Bi(await this._rpcRequest("getLatestBlockhash",n),Dc);if("error"in i)throw new na(i.error,"failed to get latest blockhash");return i.result}async isBlockhashValid(e,t){const{commitment:r,config:n}=fa(t),i=this._buildArgs([e],r,void 0,n),o=Bi(await this._rpcRequest("isBlockhashValid",i),Hc);if("error"in o)throw new na(o.error,"failed to determine if the blockhash `"+e+"`is valid");return o.result}async getVersion(){const e=Bi(await this._rpcRequest("getVersion",[]),ga(Ta));if("error"in e)throw new na(e.error,"failed to get version");return e.result}async getGenesisHash(){const e=Bi(await this._rpcRequest("getGenesisHash",[]),ga(zi()));if("error"in e)throw new na(e.error,"failed to get genesis hash");return e.result}async getBlock(e,t){const{commitment:r,config:n}=fa(t),i=this._buildArgsAtLeastConfirmed([e],r,void 0,n),o=await this._rpcRequest("getBlock",i);try{switch(n?.transactionDetails){case"accounts":{const e=Bi(o,Mc);if("error"in e)throw e.error;return e.result}case"none":{const e=Bi(o,Oc);if("error"in e)throw e.error;return e.result}default:{const e=Bi(o,Rc);if("error"in e)throw e.error;const{result:t}=e;return t?{...t,transactions:t.transactions.map((({transaction:e,meta:t,version:r})=>({meta:t,transaction:{...e,message:wa(r,e.message)},version:r})))}:null}}}catch(e){throw new na(e,"failed to get confirmed block")}}async getParsedBlock(e,t){const{commitment:r,config:n}=fa(t),i=this._buildArgsAtLeastConfirmed([e],r,"jsonParsed",n),o=await this._rpcRequest("getBlock",i);try{switch(n?.transactionDetails){case"accounts":{const e=Bi(o,Cc);if("error"in e)throw e.error;return e.result}case"none":{const e=Bi(o,Pc);if("error"in e)throw e.error;return e.result}default:{const e=Bi(o,Lc);if("error"in e)throw e.error;return e.result}}}catch(e){throw new na(e,"failed to get block")}}async getBlockProduction(e){let t,r;if("string"==typeof e)r=e;else if(e){const{commitment:n,...i}=e;r=n,t=i}const n=this._buildArgs([],r,"base64",t),i=Bi(await this._rpcRequest("getBlockProduction",n),Oa);if("error"in i)throw new na(i.error,"failed to get block production information");return i.result}async getTransaction(e,t){const{commitment:r,config:n}=fa(t),i=this._buildArgsAtLeastConfirmed([e],r,void 0,n),o=Bi(await this._rpcRequest("getTransaction",i),jc);if("error"in o)throw new na(o.error,"failed to get transaction");const s=o.result;return s?{...s,transaction:{...s.transaction,message:wa(s.version,s.transaction.message)}}:s}async getParsedTransaction(e,t){const{commitment:r,config:n}=fa(t),i=this._buildArgsAtLeastConfirmed([e],r,"jsonParsed",n),o=Bi(await this._rpcRequest("getTransaction",i),$c);if("error"in o)throw new na(o.error,"failed to get transaction");return o.result}async getParsedTransactions(e,t){const{commitment:r,config:n}=fa(t),i=e.map((e=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([e],r,"jsonParsed",n)})));return(await this._rpcBatchRequest(i)).map((e=>{const t=Bi(e,$c);if("error"in t)throw new na(t.error,"failed to get transactions");return t.result}))}async getTransactions(e,t){const{commitment:r,config:n}=fa(t),i=e.map((e=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([e],r,void 0,n)})));return(await this._rpcBatchRequest(i)).map((e=>{const t=Bi(e,jc);if("error"in t)throw new na(t.error,"failed to get transactions");const r=t.result;return r?{...r,transaction:{...r.transaction,message:wa(r.version,r.transaction.message)}}:r}))}async getConfirmedBlock(e,t){const r=this._buildArgsAtLeastConfirmed([e],t),n=Bi(await this._rpcRequest("getConfirmedBlock",r),Nc);if("error"in n)throw new na(n.error,"failed to get confirmed block");const i=n.result;if(!i)throw new Error("Confirmed block "+e+" not found");const o={...i,transactions:i.transactions.map((({transaction:e,meta:t})=>{const r=new Ps(e.message);return{meta:t,transaction:{...e,message:r}}}))};return{...o,transactions:o.transactions.map((({transaction:e,meta:t})=>({meta:t,transaction:Ds.populate(e.message,e.signatures)})))}}async getBlocks(e,t,r){const n=this._buildArgsAtLeastConfirmed(void 0!==t?[e,t]:[e],r),i=Bi(await this._rpcRequest("getBlocks",n),ga(Mi(Ui())));if("error"in i)throw new na(i.error,"failed to get blocks");return i.result}async getBlockSignatures(e,t){const r=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:"signatures",rewards:!1}),n=Bi(await this._rpcRequest("getBlock",r),Uc);if("error"in n)throw new na(n.error,"failed to get block");const i=n.result;if(!i)throw new Error("Block "+e+" not found");return i}async getConfirmedBlockSignatures(e,t){const r=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:"signatures",rewards:!1}),n=Bi(await this._rpcRequest("getConfirmedBlock",r),Uc);if("error"in n)throw new na(n.error,"failed to get confirmed block");const i=n.result;if(!i)throw new Error("Confirmed block "+e+" not found");return i}async getConfirmedTransaction(e,t){const r=this._buildArgsAtLeastConfirmed([e],t),n=Bi(await this._rpcRequest("getConfirmedTransaction",r),jc);if("error"in n)throw new na(n.error,"failed to get transaction");const i=n.result;if(!i)return i;const o=new Ps(i.transaction.message),s=i.transaction.signatures;return{...i,transaction:Ds.populate(o,s)}}async getParsedConfirmedTransaction(e,t){const r=this._buildArgsAtLeastConfirmed([e],t,"jsonParsed"),n=Bi(await this._rpcRequest("getConfirmedTransaction",r),$c);if("error"in n)throw new na(n.error,"failed to get confirmed transaction");return n.result}async getParsedConfirmedTransactions(e,t){const r=e.map((e=>({methodName:"getConfirmedTransaction",args:this._buildArgsAtLeastConfirmed([e],t,"jsonParsed")})));return(await this._rpcBatchRequest(r)).map((e=>{const t=Bi(e,$c);if("error"in t)throw new na(t.error,"failed to get confirmed transactions");return t.result}))}async getConfirmedSignaturesForAddress(e,t,r){let n={},i=await this.getFirstAvailableBlock();for(;!("until"in n)&&!(--t<=0||t0&&(n.until=e.signatures[e.signatures.length-1].toString())}catch(e){if(e instanceof Error&&e.message.includes("skipped"))continue;throw e}let o=await this.getSlot("finalized");for(;!("before"in n||++r>o);)try{const e=await this.getConfirmedBlockSignatures(r);e.signatures.length>0&&(n.before=e.signatures[e.signatures.length-1].toString())}catch(e){if(e instanceof Error&&e.message.includes("skipped"))continue;throw e}return(await this.getConfirmedSignaturesForAddress2(e,n)).map((e=>e.signature))}async getConfirmedSignaturesForAddress2(e,t,r){const n=this._buildArgsAtLeastConfirmed([e.toBase58()],r,void 0,t),i=Bi(await this._rpcRequest("getConfirmedSignaturesForAddress2",n),Xa);if("error"in i)throw new na(i.error,"failed to get confirmed signatures for address");return i.result}async getSignaturesForAddress(e,t,r){const n=this._buildArgsAtLeastConfirmed([e.toBase58()],r,void 0,t),i=Bi(await this._rpcRequest("getSignaturesForAddress",n),Qa);if("error"in i)throw new na(i.error,"failed to get signatures for address");return i.result}async getAddressLookupTable(e,t){const{context:r,value:n}=await this.getAccountInfoAndContext(e,t);let i=null;return null!==n&&(i=new sa({key:e,state:sa.deserialize(n.data)})),{context:r,value:i}}async getNonceAndContext(e,t){const{context:r,value:n}=await this.getAccountInfoAndContext(e,t);let i=null;return null!==n&&(i=Ws.fromAccountData(n.data)),{context:r,value:i}}async getNonce(e,t){return await this.getNonceAndContext(e,t).then((e=>e.value)).catch((t=>{throw new Error("failed to get nonce for account "+e.toBase58()+": "+t)}))}async requestAirdrop(e,t){const r=Bi(await this._rpcRequest("requestAirdrop",[e.toBase58(),t]),Kc);if("error"in r)throw new na(r.error,`airdrop to ${e.toBase58()} failed`);return r.result}async _blockhashWithExpiryBlockHeight(e){if(!e){for(;this._pollingBlockhash;)await qs(100);const e=Date.now()-this._blockhashInfo.lastFetch>=3e4;if(null!==this._blockhashInfo.latestBlockhash&&!e)return this._blockhashInfo.latestBlockhash}return await this._pollNewBlockhash()}async _pollNewBlockhash(){this._pollingBlockhash=!0;try{const e=Date.now(),t=this._blockhashInfo.latestBlockhash,r=t?t.blockhash:null;for(let e=0;e<50;e++){const e=await this.getLatestBlockhash("finalized");if(r!==e.blockhash)return this._blockhashInfo={latestBlockhash:e,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},e;await qs(200)}throw new Error(`Unable to obtain a new blockhash after ${Date.now()-e}ms`)}finally{this._pollingBlockhash=!1}}async getStakeMinimumDelegation(e){const{commitment:t,config:r}=fa(e),n=this._buildArgs([],t,"base64",r),i=Bi(await this._rpcRequest("getStakeMinimumDelegation",n),ya(Ui()));if("error"in i)throw new na(i.error,"failed to get stake minimum delegation");return i.result}async simulateTransaction(e,t,r){if("message"in e){const n=e.serialize(),i=C.from(n).toString("base64");if(Array.isArray(t)||void 0!==r)throw new Error("Invalid arguments");const o=t||{};o.encoding="base64","commitment"in o||(o.commitment=this.commitment);const s=[i,o],a=Bi(await this._rpcRequest("simulateTransaction",s),Ra);if("error"in a)throw new Error("failed to simulate transaction: "+a.error.message);return a.result}let n;if(e instanceof Ds){let t=e;n=new Ds,n.feePayer=t.feePayer,n.instructions=e.instructions,n.nonceInfo=t.nonceInfo,n.signatures=t.signatures}else n=Ds.populate(e),n._message=n._json=void 0;if(void 0!==t&&!Array.isArray(t))throw new Error("Invalid arguments");const i=t;if(n.nonceInfo&&i)n.sign(...i);else{let e=this._disableBlockhashCaching;for(;;){const t=await this._blockhashWithExpiryBlockHeight(e);if(n.lastValidBlockHeight=t.lastValidBlockHeight,n.recentBlockhash=t.blockhash,!i)break;if(n.sign(...i),!n.signature)throw new Error("!signature");const r=n.signature.toString("base64");if(!this._blockhashInfo.simulatedSignatures.includes(r)&&!this._blockhashInfo.transactionSignatures.includes(r)){this._blockhashInfo.simulatedSignatures.push(r);break}e=!0}}const o=n._compile(),s=o.serialize(),a=n._serialize(s).toString("base64"),c={encoding:"base64",commitment:this.commitment};if(r){const e=(Array.isArray(r)?r:o.nonProgramIds()).map((e=>e.toBase58()));c.accounts={encoding:"base64",addresses:e}}i&&(c.sigVerify=!0);const u=[a,c],l=Bi(await this._rpcRequest("simulateTransaction",u),Ra);if("error"in l){let e;if("data"in l.error&&(e=l.error.data.logs,e&&Array.isArray(e))){const t="\n ",r=t+e.join(t);console.error(l.error.message,r)}throw new ra("failed to simulate transaction: "+l.error.message,e)}return l.result}async sendTransaction(e,t,r){if("version"in e){if(t&&Array.isArray(t))throw new Error("Invalid arguments");const r=e.serialize();return await this.sendRawTransaction(r,t)}if(void 0===t||!Array.isArray(t))throw new Error("Invalid arguments");const n=t;if(e.nonceInfo)e.sign(...n);else{let t=this._disableBlockhashCaching;for(;;){const r=await this._blockhashWithExpiryBlockHeight(t);if(e.lastValidBlockHeight=r.lastValidBlockHeight,e.recentBlockhash=r.blockhash,e.sign(...n),!e.signature)throw new Error("!signature");const i=e.signature.toString("base64");if(!this._blockhashInfo.transactionSignatures.includes(i)){this._blockhashInfo.transactionSignatures.push(i);break}t=!0}}const i=e.serialize();return await this.sendRawTransaction(i,r)}async sendRawTransaction(e,t){const r=ds(e).toString("base64");return await this.sendEncodedTransaction(r,t)}async sendEncodedTransaction(e,t){const r={encoding:"base64"},n=t&&t.skipPreflight,i=!0===n?"processed":t&&t.preflightCommitment||this.commitment;t&&null!=t.maxRetries&&(r.maxRetries=t.maxRetries),t&&null!=t.minContextSlot&&(r.minContextSlot=t.minContextSlot),n&&(r.skipPreflight=n),i&&(r.preflightCommitment=i);const o=[e,r],s=Bi(await this._rpcRequest("sendTransaction",o),Wc);if("error"in s){let e;throw"data"in s.error&&(e=s.error.data.logs),new ra("failed to send transaction: "+s.error.message,e)}return s.result}_wsOnOpen(){this._rpcWebSocketConnected=!0,this._rpcWebSocketHeartbeat=setInterval((()=>{(async()=>{try{await this._rpcWebSocket.notify("ping")}catch{}})()}),5e3),this._updateSubscriptions()}_wsOnError(e){this._rpcWebSocketConnected=!1,console.error("ws error:",e.message)}_wsOnClose(e){this._rpcWebSocketConnected=!1,this._rpcWebSocketGeneration=(this._rpcWebSocketGeneration+1)%Number.MAX_SAFE_INTEGER,this._rpcWebSocketIdleTimeout&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null),this._rpcWebSocketHeartbeat&&(clearInterval(this._rpcWebSocketHeartbeat),this._rpcWebSocketHeartbeat=null),1e3!==e?(this._subscriptionCallbacksByServerSubscriptionId={},Object.entries(this._subscriptionsByHash).forEach((([e,t])=>{this._setSubscription(e,{...t,state:"pending"})}))):this._updateSubscriptions()}_setSubscription(e,t){const r=this._subscriptionsByHash[e]?.state;if(this._subscriptionsByHash[e]=t,r!==t.state){const r=this._subscriptionStateChangeCallbacksByHash[e];r&&r.forEach((e=>{try{e(t.state)}catch{}}))}}_onSubscriptionStateChange(e,t){const r=this._subscriptionHashByClientSubscriptionId[e];if(null==r)return()=>{};const n=this._subscriptionStateChangeCallbacksByHash[r]||=new Set;return n.add(t),()=>{n.delete(t),0===n.size&&delete this._subscriptionStateChangeCallbacksByHash[r]}}async _updateSubscriptions(){if(0===Object.keys(this._subscriptionsByHash).length)return void(this._rpcWebSocketConnected&&(this._rpcWebSocketConnected=!1,this._rpcWebSocketIdleTimeout=setTimeout((()=>{this._rpcWebSocketIdleTimeout=null;try{this._rpcWebSocket.close()}catch(e){e instanceof Error&&console.log(`Error when closing socket connection: ${e.message}`)}}),500)));if(null!==this._rpcWebSocketIdleTimeout&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketConnected=!0),!this._rpcWebSocketConnected)return void this._rpcWebSocket.connect();const e=this._rpcWebSocketGeneration,t=()=>e===this._rpcWebSocketGeneration;await Promise.all(Object.keys(this._subscriptionsByHash).map((async e=>{const r=this._subscriptionsByHash[e];if(void 0!==r)switch(r.state){case"pending":case"unsubscribed":if(0===r.callbacks.size)return delete this._subscriptionsByHash[e],"unsubscribed"===r.state&&delete this._subscriptionCallbacksByServerSubscriptionId[r.serverSubscriptionId],void await this._updateSubscriptions();await(async()=>{const{args:n,method:i}=r;try{this._setSubscription(e,{...r,state:"subscribing"});const t=await this._rpcWebSocket.call(i,n);this._setSubscription(e,{...r,serverSubscriptionId:t,state:"subscribed"}),this._subscriptionCallbacksByServerSubscriptionId[t]=r.callbacks,await this._updateSubscriptions()}catch(o){if(o instanceof Error&&console.error(`${i} error for argument`,n,o.message),!t())return;this._setSubscription(e,{...r,state:"pending"}),await this._updateSubscriptions()}})();break;case"subscribed":0===r.callbacks.size&&await(async()=>{const{serverSubscriptionId:n,unsubscribeMethod:i}=r;if(this._subscriptionsAutoDisposedByRpc.has(n))this._subscriptionsAutoDisposedByRpc.delete(n);else{this._setSubscription(e,{...r,state:"unsubscribing"}),this._setSubscription(e,{...r,state:"unsubscribing"});try{await this._rpcWebSocket.call(i,[n])}catch(n){if(n instanceof Error&&console.error(`${i} error:`,n.message),!t())return;return this._setSubscription(e,{...r,state:"subscribed"}),void await this._updateSubscriptions()}}this._setSubscription(e,{...r,state:"unsubscribed"}),await this._updateSubscriptions()})()}})))}_handleServerNotification(e,t){const r=this._subscriptionCallbacksByServerSubscriptionId[e];void 0!==r&&r.forEach((e=>{try{e(...t)}catch(e){console.error(e)}}))}_wsOnAccountNotification(e){const{result:t,subscription:r}=Bi(e,ec);this._handleServerNotification(r,[t.value,t.context])}_makeSubscription(e,t){const r=this._nextClientSubscriptionId++,n=Qs([e.method,t]),i=this._subscriptionsByHash[n];return void 0===i?this._subscriptionsByHash[n]={...e,args:t,callbacks:new Set([e.callback]),state:"pending"}:i.callbacks.add(e.callback),this._subscriptionHashByClientSubscriptionId[r]=n,this._subscriptionDisposeFunctionsByClientSubscriptionId[r]=async()=>{delete this._subscriptionDisposeFunctionsByClientSubscriptionId[r],delete this._subscriptionHashByClientSubscriptionId[r];const t=this._subscriptionsByHash[n];Rs(void 0!==t,`Could not find a \`Subscription\` when tearing down client subscription #${r}`),t.callbacks.delete(e.callback),await this._updateSubscriptions()},this._updateSubscriptions(),r}onAccountChange(e,t,r){const n=this._buildArgs([e.toBase58()],r||this._commitment||"finalized","base64");return this._makeSubscription({callback:t,method:"accountSubscribe",unsubscribeMethod:"accountUnsubscribe"},n)}async removeAccountChangeListener(e){await this._unsubscribeClientSubscription(e,"account change")}_wsOnProgramAccountNotification(e){const{result:t,subscription:r}=Bi(e,rc);this._handleServerNotification(r,[{accountId:t.value.pubkey,accountInfo:t.value.account},t.context])}onProgramAccountChange(e,t,r,n){const i=this._buildArgs([e.toBase58()],r||this._commitment||"finalized","base64",n?{filters:n}:void 0);return this._makeSubscription({callback:t,method:"programSubscribe",unsubscribeMethod:"programUnsubscribe"},i)}async removeProgramAccountChangeListener(e){await this._unsubscribeClientSubscription(e,"program account change")}onLogs(e,t,r){const n=this._buildArgs(["object"==typeof e?{mentions:[e.toString()]}:e],r||this._commitment||"finalized");return this._makeSubscription({callback:t,method:"logsSubscribe",unsubscribeMethod:"logsUnsubscribe"},n)}async removeOnLogsListener(e){await this._unsubscribeClientSubscription(e,"logs")}_wsOnLogsNotification(e){const{result:t,subscription:r}=Bi(e,Zc);this._handleServerNotification(r,[t.value,t.context])}_wsOnSlotNotification(e){const{result:t,subscription:r}=Bi(e,ic);this._handleServerNotification(r,[t])}onSlotChange(e){return this._makeSubscription({callback:e,method:"slotSubscribe",unsubscribeMethod:"slotUnsubscribe"},[])}async removeSlotChangeListener(e){await this._unsubscribeClientSubscription(e,"slot change")}_wsOnSlotUpdatesNotification(e){const{result:t,subscription:r}=Bi(e,sc);this._handleServerNotification(r,[t])}onSlotUpdate(e){return this._makeSubscription({callback:e,method:"slotsUpdatesSubscribe",unsubscribeMethod:"slotsUpdatesUnsubscribe"},[])}async removeSlotUpdateListener(e){await this._unsubscribeClientSubscription(e,"slot update")}async _unsubscribeClientSubscription(e,t){const r=this._subscriptionDisposeFunctionsByClientSubscriptionId[e];r?await r():console.warn(`Ignored unsubscribe request because an active subscription with id \`${e}\` for '${t}' events could not be found.`)}_buildArgs(e,t,r,n){const i=t||this._commitment;if(i||r||n){let t={};r&&(t.encoding=r),i&&(t.commitment=i),n&&(t=Object.assign(t,n)),e.push(t)}return e}_buildArgsAtLeastConfirmed(e,t,r,n){const i=t||this._commitment;if(i&&!["confirmed","finalized"].includes(i))throw new Error("Using Connection with default commitment: `"+this._commitment+"`, but method requires at least `confirmed`");return this._buildArgs(e,t,r,n)}_wsOnSignatureNotification(e){const{result:t,subscription:r}=Bi(e,ac);"receivedSignature"!==t.value&&this._subscriptionsAutoDisposedByRpc.add(r),this._handleServerNotification(r,"receivedSignature"===t.value?[{type:"received"},t.context]:[{type:"status",result:t.value},t.context])}onSignature(e,t,r){const n=this._buildArgs([e],r||this._commitment||"finalized"),i=this._makeSubscription({callback:(e,r)=>{if("status"===e.type){t(e.result,r);try{this.removeSignatureListener(i)}catch(e){}}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},n);return i}onSignatureWithOptions(e,t,r){const{commitment:n,...i}={...r,commitment:r&&r.commitment||this._commitment||"finalized"},o=this._buildArgs([e],n,void 0,i),s=this._makeSubscription({callback:(e,r)=>{t(e,r);try{this.removeSignatureListener(s)}catch(e){}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},o);return s}async removeSignatureListener(e){await this._unsubscribeClientSubscription(e,"signature result")}_wsOnRootNotification(e){const{result:t,subscription:r}=Bi(e,cc);this._handleServerNotification(r,[t])}onRootChange(e){return this._makeSubscription({callback:e,method:"rootSubscribe",unsubscribeMethod:"rootUnsubscribe"},[])}async removeRootChangeListener(e){await this._unsubscribeClientSubscription(e,"root change")}}var Yc;Object.freeze({CreateLookupTable:{index:0,layout:pi([hi("instruction"),Vs("recentSlot"),ui("bumpSeed")])},FreezeLookupTable:{index:1,layout:pi([hi("instruction")])},ExtendLookupTable:{index:2,layout:pi([hi("instruction"),Vs(),gi(As(),ci(hi(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:pi([hi("instruction")])},CloseLookupTable:{index:4,layout:pi([hi("instruction")])}}),new bs("AddressLookupTab1e1111111111111111111111111"),Object.freeze({RequestUnits:{index:0,layout:pi([ui("instruction"),hi("units"),hi("additionalFee")])},RequestHeapFrame:{index:1,layout:pi([ui("instruction"),hi("bytes")])},SetComputeUnitLimit:{index:2,layout:pi([ui("instruction"),hi("units")])},SetComputeUnitPrice:{index:3,layout:pi([ui("instruction"),Vs("microLamports")])}}),new bs("ComputeBudget111111111111111111111111111111"),pi([ui("numSignatures"),ui("padding"),li("signatureOffset"),li("signatureInstructionIndex"),li("publicKeyOffset"),li("publicKeyInstructionIndex"),li("messageDataOffset"),li("messageDataSize"),li("messageInstructionIndex")]),new bs("Ed25519SigVerify111111111111111111111111111"),us.utils.isValidPrivateKey,us.getPublicKey,pi([ui("numSignatures"),li("signatureOffset"),ui("signatureInstructionIndex"),li("ethAddressOffset"),ui("ethAddressInstructionIndex"),li("messageDataOffset"),li("messageDataSize"),ui("messageInstructionIndex"),yi(20,"ethAddress"),yi(64,"signature"),ui("recoveryId")]),new bs("KeccakSecp256k11111111111111111111111111111"),new bs("StakeConfig11111111111111111111111111111111");class Xc{constructor(e,t,r){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=e,this.epoch=t,this.custodian=r}}Yc=Xc,Xc.default=new Yc(0,0,bs.default),Object.freeze({Initialize:{index:0,layout:pi([hi("instruction"),((e="authorized")=>pi([As("staker"),As("withdrawer")],e))(),((e="lockup")=>pi([di("unixTimestamp"),di("epoch"),As("custodian")],e))()])},Authorize:{index:1,layout:pi([hi("instruction"),As("newAuthorized"),hi("stakeAuthorizationType")])},Delegate:{index:2,layout:pi([hi("instruction")])},Split:{index:3,layout:pi([hi("instruction"),di("lamports")])},Withdraw:{index:4,layout:pi([hi("instruction"),di("lamports")])},Deactivate:{index:5,layout:pi([hi("instruction")])},Merge:{index:7,layout:pi([hi("instruction")])},AuthorizeWithSeed:{index:8,layout:pi([hi("instruction"),As("newAuthorized"),hi("stakeAuthorizationType"),Is("authoritySeed"),As("authorityOwner")])}}),Object.freeze({Staker:{index:0},Withdrawer:{index:1}}),new bs("Stake11111111111111111111111111111111111111"),Object.freeze({InitializeAccount:{index:0,layout:pi([hi("instruction"),((e="voteInit")=>pi([As("nodePubkey"),As("authorizedVoter"),As("authorizedWithdrawer"),ui("commission")],e))()])},Authorize:{index:1,layout:pi([hi("instruction"),As("newAuthorized"),hi("voteAuthorizationType")])},Withdraw:{index:3,layout:pi([hi("instruction"),di("lamports")])},UpdateValidatorIdentity:{index:4,layout:pi([hi("instruction")])},AuthorizeWithSeed:{index:10,layout:pi([hi("instruction"),((e="voteAuthorizeWithSeedArgs")=>pi([hi("voteAuthorizationType"),As("currentAuthorityDerivedKeyOwnerPubkey"),Is("currentAuthorityDerivedKeySeed"),As("newAuthorized")],e))()])}}),Object.freeze({Voter:{index:0},Withdrawer:{index:1}}),new bs("Vote111111111111111111111111111111111111111"),new bs("Va1idator1nfo111111111111111111111111111111"),Hi({name:zi(),website:ji(zi()),details:ji(zi()),keybaseUsername:ji(zi())}),new bs("Vote111111111111111111111111111111111111111"),pi([As("nodePubkey"),As("authorizedWithdrawer"),ui("commission"),fi(),gi(pi([fi("slot"),hi("confirmationCount")]),ci(hi(),-8),"votes"),ui("rootSlotValid"),fi("rootSlot"),fi(),gi(pi([fi("epoch"),As("authorizedVoter")]),ci(hi(),-8),"authorizedVoters"),pi([gi(pi([As("authorizedPubkey"),fi("epochOfLastAuthorizedSwitch"),fi("targetEpoch")]),32,"buf"),fi("idx"),ui("isEmpty")],"priorVoters"),fi(),gi(pi([fi("epoch"),fi("credits"),fi("prevCredits")]),ci(hi(),-8),"epochCredits"),pi([fi("slot"),fi("timestamp")],"lastTimestamp")]);const Qc="solana:signAndSendTransaction",eu="solana:signIn",tu="solana:signMessage",ru="solana:signTransaction",nu="standard:connect",iu="standard:disconnect",ou="standard:events";var su,au=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};class cu extends Event{constructor(e){super("wallet-standard:register-wallet",{bubbles:!1,cancelable:!1,composed:!1}),((e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)})(this,su,void 0),((e,t,r,n)=>{au(e,t,"write to private field"),n?n.call(e,r):t.set(e,r)})(this,su,e)}get detail(){return((e,t,r)=>(au(e,t,"read from private field"),r?r.call(e):t.get(e)))(this,su)}get type(){return"wallet-standard:register-wallet"}preventDefault(){throw new Error("preventDefault cannot be called")}stopImmediatePropagation(){throw new Error("stopImmediatePropagation cannot be called")}stopPropagation(){throw new Error("stopPropagation cannot be called")}}function uu(e){!function(e){const t=({register:t})=>t(e);try{window.dispatchEvent(new cu(t))}catch(e){console.error("wallet-standard:register-wallet event could not be dispatched\n",e)}try{window.addEventListener("wallet-standard:app-ready",(({detail:e})=>t(e)))}catch(e){console.error("wallet-standard:app-ready event listener could not be added\n",e)}}(e.getInstanceWithAdapter())}su=new WeakMap;const lu=["solana:mainnet"];function hu(e){return lu.includes(e)}function fu(e){return"version"in e}var du,pu,gu,yu,mu,wu,bu=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},vu=(e,t,r)=>(bu(e,t,"read from private field"),r?r.call(e):t.get(e)),_u=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Eu=(e,t,r,n)=>(bu(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);const Su=lu,xu=[Qc,ru,tu],Au=class{constructor({address:e,publicKey:t,label:r,icon:n}){_u(this,du,void 0),_u(this,pu,void 0),_u(this,gu,void 0),_u(this,yu,void 0),_u(this,mu,void 0),_u(this,wu,void 0),new.target===Au&&Object.freeze(this),Eu(this,du,e),Eu(this,pu,t),Eu(this,gu,Su),Eu(this,yu,xu),Eu(this,mu,r),Eu(this,wu,n)}get address(){return vu(this,du)}get publicKey(){return vu(this,pu).slice()}get chains(){return vu(this,gu).slice()}get features(){return vu(this,yu).slice()}get label(){return vu(this,mu)}get icon(){return vu(this,wu)}};let ku=Au;du=new WeakMap,pu=new WeakMap,gu=new WeakMap,yu=new WeakMap,mu=new WeakMap,wu=new WeakMap;var Iu,Bu,Tu,Ru,Ou,Mu,Lu,Cu,Pu,Nu,Uu,ju,$u,zu,Du,Hu,qu,Fu,Ku,Wu,Vu=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Zu=(e,t,r)=>(Vu(e,t,"read from private field"),r?r.call(e):t.get(e)),Gu=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Ju=(e,t,r,n)=>(Vu(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r),Yu=(e,t,r)=>(Vu(e,t,"access private method"),r);const Xu="trust:",Qu=class{constructor(e){Gu(this,Cu),Gu(this,Nu),Gu(this,Iu,{}),Gu(this,Bu,"1.0.0"),Gu(this,Tu,"Trust"),Gu(this,Ru,"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTgiIGhlaWdodD0iNjUiIHZpZXdCb3g9IjAgMCA1OCA2NSIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTAgOS4zODk0OUwyOC44OTA3IDBWNjUuMDA0MkM4LjI1NDUgNTYuMzM2OSAwIDM5LjcyNDggMCAzMC4zMzUzVjkuMzg5NDlaIiBmaWxsPSIjMDUwMEZGIi8+CjxwYXRoIGQ9Ik01Ny43ODIyIDkuMzg5NDlMMjguODkxNSAwVjY1LjAwNDJDNDkuNTI3NyA1Ni4zMzY5IDU3Ljc4MjIgMzkuNzI0OCA1Ny43ODIyIDMwLjMzNTNWOS4zODk0OVoiIGZpbGw9InVybCgjcGFpbnQwX2xpbmVhcl8yMjAxXzY5NDIpIi8+CjxkZWZzPgo8bGluZWFyR3JhZGllbnQgaWQ9InBhaW50MF9saW5lYXJfMjIwMV82OTQyIiB4MT0iNTEuMzYxNSIgeTE9Ii00LjE1MjkzIiB4Mj0iMjkuNTM4NCIgeTI9IjY0LjUxNDciIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIj4KPHN0b3Agb2Zmc2V0PSIwLjAyMTEyIiBzdG9wLWNvbG9yPSIjMDAwMEZGIi8+CjxzdG9wIG9mZnNldD0iMC4wNzYyNDIzIiBzdG9wLWNvbG9yPSIjMDA5NEZGIi8+CjxzdG9wIG9mZnNldD0iMC4xNjMwODkiIHN0b3AtY29sb3I9IiM0OEZGOTEiLz4KPHN0b3Agb2Zmc2V0PSIwLjQyMDA0OSIgc3RvcC1jb2xvcj0iIzAwOTRGRiIvPgo8c3RvcCBvZmZzZXQ9IjAuNjgyODg2IiBzdG9wLWNvbG9yPSIjMDAzOEZGIi8+CjxzdG9wIG9mZnNldD0iMC45MDI0NjUiIHN0b3AtY29sb3I9IiMwNTAwRkYiLz4KPC9saW5lYXJHcmFkaWVudD4KPC9kZWZzPgo8L3N2Zz4K"),Gu(this,Ou,null),Gu(this,Mu,void 0),Gu(this,Lu,((e,t)=>{var r;return null!=(r=Zu(this,Iu)[e])&&r.push(t)||(Zu(this,Iu)[e]=[t]),()=>Yu(this,Nu,Uu).call(this,e,t)})),Gu(this,ju,(()=>{var e;const t=null==(e=Zu(this,Mu).publicKey)?void 0:e.toBase58();if(t){const e=Zu(this,Mu).publicKey.toBytes(),r=Zu(this,Ou);(!r||r.address!==t||!function(e,t){return function(e,t){if(e===t)return!0;const r=e.length;if(r!==t.length)return!1;for(let n=0;n{Zu(this,Ou)&&(Ju(this,Ou,null),Yu(this,Cu,Pu).call(this,"change",{accounts:this.accounts}))})),Gu(this,zu,(()=>{Zu(this,Mu).publicKey?Zu(this,ju).call(this):Zu(this,$u).call(this)})),Gu(this,Du,(async({silent:e}={})=>(Zu(this,Ou)||await Zu(this,Mu).connect(e?{onlyIfTrusted:!0}:void 0),Zu(this,ju).call(this),{accounts:this.accounts}))),Gu(this,Hu,(async()=>{await Zu(this,Mu).disconnect()})),Gu(this,qu,(async(...e)=>{if(!Zu(this,Ou))throw new Error("not connected");const t=[];if(1===e.length){const{transaction:r,account:n,chain:i,options:o}=e[0],{minContextSlot:s,preflightCommitment:a,skipPreflight:c,maxRetries:u}=o||{};if(n!==Zu(this,Ou))throw new Error("invalid account");if(!hu(i))throw new Error("invalid chain");const{signature:l}=await Zu(this,Mu).signAndSendTransaction(Hs.deserialize(r),{preflightCommitment:a,minContextSlot:s,maxRetries:u,skipPreflight:c});t.push({signature:Ur.decode(l)})}else if(e.length>1)for(const r of e)t.push(...await Zu(this,qu).call(this,r));return t})),Gu(this,Fu,(async(...e)=>{if(!Zu(this,Ou))throw new Error("not connected");const t=[];if(1===e.length){const{transaction:r,account:n,chain:i}=e[0];if(n!==Zu(this,Ou))throw new Error("invalid account");if(i&&!hu(i))throw new Error("invalid chain");const o=await Zu(this,Mu).signTransaction(Hs.deserialize(r)),s=fu(o)?o.serialize():new Uint8Array(o.serialize({requireAllSignatures:!1,verifySignatures:!1}));t.push({signedTransaction:s})}else if(e.length>1){let r;for(const t of e){if(t.account!==Zu(this,Ou))throw new Error("invalid account");if(t.chain){if(!hu(t.chain))throw new Error("invalid chain");if(r){if(t.chain!==r)throw new Error("conflicting chain")}else r=t.chain}}const n=e.map((({transaction:e})=>Hs.deserialize(e))),i=await Zu(this,Mu).signAllTransactions(n);t.push(...i.map((e=>({signedTransaction:fu(e)?e.serialize():new Uint8Array(e.serialize({requireAllSignatures:!1,verifySignatures:!1}))}))))}return t})),Gu(this,Ku,(async(...e)=>{if(!Zu(this,Ou))throw new Error("not connected");const t=[];if(1===e.length){const{message:r,account:n}=e[0];if(n!==Zu(this,Ou))throw new Error("invalid account");const{signature:i}=await Zu(this,Mu).signMessage(r);t.push({signedMessage:r,signature:i})}else if(e.length>1)for(const r of e)t.push(...await Zu(this,Ku).call(this,r));return t})),Gu(this,Wu,(async(...e)=>{const t=[];if(!(e.length>1))return[await Zu(this,Mu).signIn(e[0])];for(const r of e)t.push(await Zu(this,Mu).signIn(r));return t})),new.target===Qu&&Object.freeze(this),Ju(this,Mu,e),e.on("connect",Zu(this,ju),this),e.on("disconnect",Zu(this,$u),this),e.on("accountChanged",Zu(this,zu),this),Zu(this,ju).call(this)}get version(){return Zu(this,Bu)}get name(){return Zu(this,Tu)}get icon(){return Zu(this,Ru)}get chains(){return lu.slice()}get features(){return{[nu]:{version:"1.0.0",connect:Zu(this,Du)},[iu]:{version:"1.0.0",disconnect:Zu(this,Hu)},[ou]:{version:"1.0.0",on:Zu(this,Lu)},[Qc]:{version:"1.0.0",supportedTransactionVersions:["legacy",0],signAndSendTransaction:Zu(this,qu)},[ru]:{version:"1.0.0",supportedTransactionVersions:["legacy",0],signTransaction:Zu(this,Fu)},[tu]:{version:"1.0.0",signMessage:Zu(this,Ku)},[eu]:{version:"1.0.0",signIn:Zu(this,Wu)},[Xu]:{trust:Zu(this,Mu)}}}get accounts(){return Zu(this,Ou)?[Zu(this,Ou)]:[]}};let el=Qu;Iu=new WeakMap,Bu=new WeakMap,Tu=new WeakMap,Ru=new WeakMap,Ou=new WeakMap,Mu=new WeakMap,Lu=new WeakMap,Cu=new WeakSet,Pu=function(e,...t){var r;null==(r=Zu(this,Iu)[e])||r.forEach((e=>e.apply(null,t)))},Nu=new WeakSet,Uu=function(e,t){var r;Zu(this,Iu)[e]=null==(r=Zu(this,Iu)[e])?void 0:r.filter((e=>t!==e))},ju=new WeakMap,$u=new WeakMap,zu=new WeakMap,Du=new WeakMap,Hu=new WeakMap,qu=new WeakMap,Fu=new WeakMap,Ku=new WeakMap,Wu=new WeakMap;class tl{constructor(e,t=!1){this.useLegacySign=!1,this.provider=e,this.useLegacySign=t}async connect(e){const t=await this.provider.internalRequest({method:"requestAccounts",params:{options:e}});return this.provider.emit("connect"),{publicKey:new bs(t[0])}}async signTransaction(e){if(this.useLegacySign)return await this.legacySign(e);const t=JSON.stringify(e);let r,n="legacy";fu(e)?(n=e.version,r=C.from(e.message.serialize()).toString("base64")):r=C.from(e.serializeMessage()).toString("base64");const i=C.from(e.serialize({requireAllSignatures:!1,verifySignatures:!1})).toString("base64"),o=await this.provider.internalRequest({method:"signRawTransaction",params:{data:t,raw:i,rawMessage:r,version:n}});return this.provider.mapSignedTransaction(e,o)}async legacySign(e){const t=JSON.stringify(e),r="number"!=typeof e.version?"legacy":e.version,n=Ur.encode("legacy"===r?e.serializeMessage():0===r?e.message.serialize():e.serialize());try{const i=await this.provider.internalRequest({method:"signRawTransaction",params:{data:t,raw:n,version:r}});return this.provider.mapSignedTransaction(e,i)}catch(e){console.log(`<== Error: ${e}`)}}async request(e,t){var r;switch(e.method){case"signTransaction":return this.signTransaction(e.params);case"connect":return this.connect(null==(r=e?.params)?void 0:r.options)}return t()}}var rl,nl,il,ol,sl,al=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},cl=(e,t,r)=>(al(e,t,"read from private field"),r?r.call(e):t.get(e)),ul=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},ll=(e,t,r,n)=>(al(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r),hl=(e,t,r)=>(al(e,t,"access private method"),r);const fl=class extends ze{constructor(e){super(),ul(this,ol),ul(this,rl,!1),ul(this,nl,!0),this.isTrust=!0,this.isTrustWallet=!0,ul(this,il,!1),e&&(typeof e.enableAdapter<"u"&&ll(this,nl,e.enableAdapter),typeof e.cluster<"u"&&(this.connection=new Jc(e.cluster,"confirmed")),typeof e.disableMobileAdapter<"u"&&ll(this,rl,e.disableMobileAdapter),typeof e.useLegacySign<"u"&&ll(this,il,e.useLegacySign),typeof e.isTrust<"u"&&(this.isTrust=e.isTrust,this.isTrustWallet=e.isTrust)),cl(this,nl)&&uu(this),cl(this,rl)||(this.mobileAdapter=new tl(this,cl(this,il)))}static bufferToHex(e){return"0x"+C.from(e).toString("hex")}static messageToBuffer(e){let t=C.from([]);try{t="string"==typeof e?C.from(e.replace("0x",""),"hex"):C.from(e)}catch(e){console.log(`messageToBuffer error: ${e}`)}return t}getInstanceWithAdapter(){return new el(this)}async connect(e){const t=await hl(this,ol,sl).call(this,{method:"connect",params:{options:e}});return this.publicKey=t.publicKey,t}disconnect(){return new Promise((e=>{this.publicKey=null,this.emit("disconnect"),e()}))}async signAndSendTransaction(e,t){const r=await this.signTransaction(e);return{signature:await this.connection.sendRawTransaction(r.serialize(),t)}}signTransaction(e){return hl(this,ol,sl).call(this,{method:"signTransaction",params:e})}signAllTransactions(e){return Promise.all(e.map((e=>this.signTransaction(e))))}async signRawTransactionMulti(e){return(await hl(this,ol,sl).call(this,{method:"signRawTransactionMulti",params:{transactions:e.map((e=>{const t=JSON.stringify(e);let r,n="legacy";fu(e)?(n=e.version,r=C.from(e.message.serialize()).toString("base64")):r=C.from(e.serializeMessage()).toString("base64");return{data:t,raw:C.from(e.serialize({requireAllSignatures:!1,verifySignatures:!1})).toString("base64"),rawMessage:r,version:n}}))}})).map(((t,r)=>this.mapSignedTransaction(e[r],t)))}async signMessage(e){var t;const r=fl.bufferToHex(e),n=await hl(this,ol,sl).call(this,{method:"signMessage",params:{data:r}});return{signature:C.from(fl.messageToBuffer(n).buffer),publicKey:null==(t=this.publicKey)?void 0:t.toBase58()}}signIn(e){throw new Error("Method not implemented.")}getNetwork(){return fl.NETWORK}mapSignedTransaction(e,t){return e.addSignature(this.publicKey,Ur.decode(t)),e}request(e){throw new Error("Not implemented")}internalRequest(e){return super.request(e)}};let dl=fl;rl=new WeakMap,nl=new WeakMap,il=new WeakMap,ol=new WeakSet,sl=function(e){const t=()=>this.internalRequest(e);return this.mobileAdapter?this.mobileAdapter.request(e,t):t()},dl.NETWORK="solana";var pl={},gl={},yl={},ml={},wl={},bl={},vl={},_l={},El={};function Sl(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function xl(e){if("boolean"!=typeof e)throw new Error(`Expected boolean, not ${e}`)}function Al(e,...t){if(!function(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}(e))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function kl(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");Sl(e.outputLen),Sl(e.blockLen)}function Il(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Bl(e,t){Al(e);const r=t.outputLen;if(e.length(e+t/ss)/t;const cs=ar(ns,void 0,void 0,{sqrt:function(e){const t=ns,r=BigInt(3),n=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),u=e*e*e%t,h=u*u*e%t,l=rr(h,r,t)*h%t,f=rr(l,r,t)*h%t,d=rr(f,ss,t)*u%t,p=rr(d,i,t)*d%t,g=rr(p,o,t)*p%t,y=rr(g,a,t)*g%t,m=rr(y,c,t)*y%t,w=rr(m,a,t)*g%t,b=rr(w,r,t)*h%t,v=rr(b,s,t)*p%t,_=rr(v,n,t)*u%t,E=rr(_,ss,t);if(!cs.eql(cs.sqr(E),e))throw new Error("Cannot find square root");return E}}),us=function(e,t){const r=t=>ts({...e,...rs(t)});return Object.freeze({...r(t),create:r})}({a:BigInt(0),b:BigInt(7),Fp:cs,n:is,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=is,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-os*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=r,s=BigInt("0x100000000000000000000000000000000"),a=as(o*e,t),c=as(-n*e,t);let u=er(e-a*r-c*i,t),h=er(-a*n-c*o,t);const l=u>s,f=h>s;if(l&&(u=t-u),f&&(h=t-h),u>s||h>s)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:l,k1:u,k2neg:f,k2:h}}}},Vr);function hs(e){try{return Mr.ExtendedPoint.fromHex(e),!0}catch{return!1}}BigInt(0),us.ProjectivePoint,Mr.utils.randomPrivateKey;const ls=(e,t)=>Mr.sign(e,t.slice(0,32)),fs=Mr.verify,ds=e=>C.isBuffer(e)?e:e instanceof Uint8Array?C.from(e.buffer,e.byteOffset,e.byteLength):C.from(e);class ps{constructor(e){Object.assign(this,e)}encode(){return C.from(xn(gs,this))}static decode(e){return In(gs,this,e)}static decodeUnchecked(e){return fn(gs,this,e)}}const gs=new Map;var ys;const ms=32;let ws=1;class bs extends ps{constructor(e){if(super({}),this._bn=void 0,function(e){return void 0!==e._bn}(e))this._bn=e._bn;else{if("string"==typeof e){const t=Dr.decode(e);if(t.length!=ms)throw new Error("Invalid public key input");this._bn=new jr(t)}else this._bn=new jr(e);if(this._bn.byteLength()>ms)throw new Error("Invalid public key input")}}static unique(){const e=new bs(ws);return ws+=1,new bs(e.toBuffer())}equals(e){return this._bn.eq(e._bn)}toBase58(){return Dr.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){const e=this.toBuffer();return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}toBuffer(){const e=this._bn.toArrayLike(C);if(e.length===ms)return e;const t=C.alloc(32);return e.copy(t,32-e.length),t}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(e,t,r){const n=C.concat([e.toBuffer(),C.from(t),r.toBuffer()]),i=Vr(n);return new bs(i)}static createProgramAddressSync(e,t){let r=C.alloc(0);e.forEach((function(e){if(e.length>32)throw new TypeError("Max seed length exceeded");r=C.concat([r,ds(e)])})),r=C.concat([r,t.toBuffer(),C.from("ProgramDerivedAddress")]);const n=Vr(r);if(hs(n))throw new Error("Invalid seeds, address must fall off the curve");return new bs(n)}static async createProgramAddress(e,t){return this.createProgramAddressSync(e,t)}static findProgramAddressSync(e,t){let r,n=255;for(;0!=n;){try{const i=e.concat(C.from([n]));r=this.createProgramAddressSync(i,t)}catch(e){if(e instanceof TypeError)throw e;n--;continue}return[r,n]}throw new Error("Unable to find a viable program address nonce")}static async findProgramAddress(e,t){return this.findProgramAddressSync(e,t)}static isOnCurve(e){return hs(new bs(e).toBytes())}}ys=bs,bs.default=new ys("11111111111111111111111111111111"),gs.set(bs,{kind:"struct",fields:[["_bn","u256"]]}),new bs("BPFLoader1111111111111111111111111111111111");const vs=1232;class _s extends Error{constructor(e){super(`Signature ${e} has expired: block height exceeded.`),this.signature=void 0,this.signature=e}}Object.defineProperty(_s.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});class Es extends Error{constructor(e,t){super(`Transaction was not confirmed in ${t.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${e} using the Solana Explorer or CLI tools.`),this.signature=void 0,this.signature=e}}Object.defineProperty(Es.prototype,"name",{value:"TransactionExpiredTimeoutError"});class Ss extends Error{constructor(e){super(`Signature ${e} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=e}}Object.defineProperty(Ss.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});class As{constructor(e,t){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=e,this.accountKeysFromLookups=t}keySegments(){const e=[this.staticAccountKeys];return this.accountKeysFromLookups&&(e.push(this.accountKeysFromLookups.writable),e.push(this.accountKeysFromLookups.readonly)),e}get(e){for(const t of this.keySegments()){if(e256)throw new Error("Account index overflow encountered during compilation");const t=new Map;this.keySegments().flat().forEach(((e,r)=>{t.set(e.toBase58(),r)}));const r=e=>{const r=t.get(e.toBase58());if(void 0===r)throw new Error("Encountered an unknown instruction account key during compilation");return r};return e.map((e=>({programIdIndex:r(e.programId),accountKeyIndexes:e.keys.map((e=>r(e.pubkey))),data:e.data})))}}const xs=(e="publicKey")=>_i(32,e),ks=(e="signature")=>_i(64,e),Bs=(e="string")=>{const t=bi([yi("length"),yi("lengthPadding"),_i(di(yi(),-8),"chars")],e),r=t.decode.bind(t),n=t.encode.bind(t),i=t;return i.decode=(e,t)=>r(e,t).chars.toString(),i.encode=(e,t,r)=>{const i={chars:C.from(e,"utf8")};return n(i,t,r)},i.alloc=e=>yi().span+yi().span+C.from(e,"utf8").length,i};function Is(e){let t=0,r=0;for(;;){let n=e.shift();if(t|=(127&n)<<7*r,r+=1,!(128&n))break}return t}function Ts(e,t){let r=t;for(;;){let t=127&r;if(r>>=7,0==r){e.push(t);break}t|=128,e.push(t)}}function Rs(e,t){if(!e)throw new Error(t||"Assertion failed")}class Os{constructor(e,t){this.payer=void 0,this.keyMetaMap=void 0,this.payer=e,this.keyMetaMap=t}static compile(e,t){const r=new Map,n=e=>{const t=e.toBase58();let n=r.get(t);return void 0===n&&(n={isSigner:!1,isWritable:!1,isInvoked:!1},r.set(t,n)),n},i=n(t);i.isSigner=!0,i.isWritable=!0;for(const t of e){n(t.programId).isInvoked=!0;for(const e of t.keys){const t=n(e.pubkey);t.isSigner||=e.isSigner,t.isWritable||=e.isWritable}}return new Os(t,r)}getMessageComponents(){const e=[...this.keyMetaMap.entries()];Rs(e.length<=256,"Max static account keys length exceeded");const t=e.filter((([,e])=>e.isSigner&&e.isWritable)),r=e.filter((([,e])=>e.isSigner&&!e.isWritable)),n=e.filter((([,e])=>!e.isSigner&&e.isWritable)),i=e.filter((([,e])=>!e.isSigner&&!e.isWritable)),o={numRequiredSignatures:t.length+r.length,numReadonlySignedAccounts:r.length,numReadonlyUnsignedAccounts:i.length};{Rs(t.length>0,"Expected at least one writable signer key");const[e]=t[0];Rs(e===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}const s=[...t.map((([e])=>new bs(e))),...r.map((([e])=>new bs(e))),...n.map((([e])=>new bs(e))),...i.map((([e])=>new bs(e)))];return[o,s]}extractTableLookup(e){const[t,r]=this.drainKeysFoundInLookupTable(e.state.addresses,(e=>!e.isSigner&&!e.isInvoked&&e.isWritable)),[n,i]=this.drainKeysFoundInLookupTable(e.state.addresses,(e=>!e.isSigner&&!e.isInvoked&&!e.isWritable));if(0!==t.length||0!==n.length)return[{accountKey:e.key,writableIndexes:t,readonlyIndexes:n},{writable:r,readonly:i}]}drainKeysFoundInLookupTable(e,t){const r=new Array,n=new Array;for(const[i,o]of this.keyMetaMap.entries())if(t(o)){const t=new bs(i),o=e.findIndex((e=>e.equals(t)));o>=0&&(Rs(o<256,"Max lookup table index exceeded"),r.push(o),n.push(t),this.keyMetaMap.delete(i))}return[r,n]}}const Ls="Reached end of buffer unexpectedly";function Ms(e){if(0===e.length)throw new Error(Ls);return e.shift()}function Cs(e,...t){const[r]=t;if(2===t.length?r+(t[1]??0)>e.length:r>=e.length)throw new Error(Ls);return e.splice(...t)}class Ps{constructor(e){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=e.header,this.accountKeys=e.accountKeys.map((e=>new bs(e))),this.recentBlockhash=e.recentBlockhash,this.instructions=e.instructions,this.instructions.forEach((e=>this.indexToProgramIds.set(e.programIdIndex,this.accountKeys[e.programIdIndex])))}get version(){return"legacy"}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map((e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:Dr.decode(e.data)})))}get addressTableLookups(){return[]}getAccountKeys(){return new As(this.staticAccountKeys)}static compile(e){const t=Os.compile(e.instructions,e.payerKey),[r,n]=t.getMessageComponents(),i=new As(n).compileInstructions(e.instructions).map((e=>({programIdIndex:e.programIdIndex,accounts:e.accountKeyIndexes,data:Dr.encode(e.data)})));return new Ps({header:r,accountKeys:n,recentBlockhash:e.recentBlockhash,instructions:i})}isAccountSigner(e){return e=this.header.numRequiredSignatures){return e-t!this.isProgramId(t)))}serialize(){const e=this.accountKeys.length;let t=[];Ts(t,e);const r=this.instructions.map((e=>{const{accounts:t,programIdIndex:r}=e,n=Array.from(Dr.decode(e.data));let i=[];Ts(i,t.length);let o=[];return Ts(o,n.length),{programIdIndex:r,keyIndicesCount:C.from(i),keyIndices:t,dataLength:C.from(o),data:n}}));let n=[];Ts(n,r.length);let i=C.alloc(vs);C.from(n).copy(i);let o=n.length;r.forEach((e=>{const t=bi([pi("programIdIndex"),_i(e.keyIndicesCount.length,"keyIndicesCount"),vi(pi("keyIndex"),e.keyIndices.length,"keyIndices"),_i(e.dataLength.length,"dataLength"),vi(pi("userdatum"),e.data.length,"data")]).encode(e,i,o);o+=t})),i=i.slice(0,o);const s=bi([_i(1,"numRequiredSignatures"),_i(1,"numReadonlySignedAccounts"),_i(1,"numReadonlyUnsignedAccounts"),_i(t.length,"keyCount"),vi(xs("key"),e,"keys"),xs("recentBlockhash")]),a={numRequiredSignatures:C.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:C.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:C.from([this.header.numReadonlyUnsignedAccounts]),keyCount:C.from(t),keys:this.accountKeys.map((e=>ds(e.toBytes()))),recentBlockhash:Dr.decode(this.recentBlockhash)};let c=C.alloc(2048);const u=s.encode(a,c);return i.copy(c,u),c.slice(0,u+i.length)}static from(e){let t=[...e];const r=Ms(t);if(r!==(127&r))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const n=Ms(t),i=Ms(t),o=Is(t);let s=[];for(let e=0;e0)throw new Error("Failed to get account keys because address table lookups were not resolved");return new As(this.staticAccountKeys,t)}isAccountSigner(e){return e=r){const t=e-r,n=this.addressTableLookups.reduce(((e,t)=>e+t.writableIndexes.length),0);return t=this.header.numRequiredSignatures){return e-te.key.equals(r.accountKey)));if(!n)throw new Error(`Failed to find address lookup table account for table key ${r.accountKey.toBase58()}`);for(const e of r.writableIndexes){if(!(ee.toBytes())),recentBlockhash:Dr.decode(this.recentBlockhash),instructionsLength:new Uint8Array(r),serializedInstructions:t,addressTableLookupsLength:new Uint8Array(i),serializedAddressTableLookups:n},s);return s.slice(0,a)}serializeInstructions(){let e=0;const t=new Uint8Array(vs);for(const r of this.compiledInstructions){const n=Array();Ts(n,r.accountKeyIndexes.length);const i=Array();Ts(i,r.data.length);e+=bi([pi("programIdIndex"),_i(n.length,"encodedAccountKeyIndexesLength"),vi(pi(),r.accountKeyIndexes.length,"accountKeyIndexes"),_i(i.length,"encodedDataLength"),_i(r.data.length,"data")]).encode({programIdIndex:r.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(n),accountKeyIndexes:r.accountKeyIndexes,encodedDataLength:new Uint8Array(i),data:r.data},t,e)}return t.slice(0,e)}serializeAddressTableLookups(){let e=0;const t=new Uint8Array(vs);for(const r of this.addressTableLookups){const n=Array();Ts(n,r.writableIndexes.length);const i=Array();Ts(i,r.readonlyIndexes.length);e+=bi([xs("accountKey"),_i(n.length,"encodedWritableIndexesLength"),vi(pi(),r.writableIndexes.length,"writableIndexes"),_i(i.length,"encodedReadonlyIndexesLength"),vi(pi(),r.readonlyIndexes.length,"readonlyIndexes")]).encode({accountKey:r.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(n),writableIndexes:r.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(i),readonlyIndexes:r.readonlyIndexes},t,e)}return t.slice(0,e)}static deserialize(e){let t=[...e];const r=Ms(t),n=127&r;Rs(r!==n,"Expected versioned message but received legacy message");Rs(0===n,`Expected versioned message with version 0 but found version ${n}`);const i={numRequiredSignatures:Ms(t),numReadonlySignedAccounts:Ms(t),numReadonlyUnsignedAccounts:Ms(t)},o=[],s=Is(t);for(let e=0;e{const t=Us.deserializeMessageVersion(e);if("legacy"===t)return Ps.from(e);if(0===t)return Ns.deserialize(e);throw new Error(`Transaction message version ${t} deserialization is not supported`)}};let js=function(e){return e[e.BLOCKHEIGHT_EXCEEDED=0]="BLOCKHEIGHT_EXCEEDED",e[e.PROCESSED=1]="PROCESSED",e[e.TIMED_OUT=2]="TIMED_OUT",e[e.NONCE_INVALID=3]="NONCE_INVALID",e}({});const $s=C.alloc(64).fill(0);class Hs{constructor(e){this.keys=void 0,this.programId=void 0,this.data=C.alloc(0),this.programId=e.programId,this.keys=e.keys,e.data&&(this.data=e.data)}toJSON(){return{keys:this.keys.map((({pubkey:e,isSigner:t,isWritable:r})=>({pubkey:e.toJSON(),isSigner:t,isWritable:r}))),programId:this.programId.toJSON(),data:[...this.data]}}}class zs{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(e){if(this.signatures=[],this.feePayer=void 0,this.instructions=[],this.recentBlockhash=void 0,this.lastValidBlockHeight=void 0,this.nonceInfo=void 0,this.minNonceContextSlot=void 0,this._message=void 0,this._json=void 0,e)if(e.feePayer&&(this.feePayer=e.feePayer),e.signatures&&(this.signatures=e.signatures),Object.prototype.hasOwnProperty.call(e,"nonceInfo")){const{minContextSlot:t,nonceInfo:r}=e;this.minNonceContextSlot=t,this.nonceInfo=r}else if(Object.prototype.hasOwnProperty.call(e,"lastValidBlockHeight")){const{blockhash:t,lastValidBlockHeight:r}=e;this.recentBlockhash=t,this.lastValidBlockHeight=r}else{const{recentBlockhash:t,nonceInfo:r}=e;r&&(this.nonceInfo=r),this.recentBlockhash=t}}toJSON(){return{recentBlockhash:this.recentBlockhash||null,feePayer:this.feePayer?this.feePayer.toJSON():null,nonceInfo:this.nonceInfo?{nonce:this.nonceInfo.nonce,nonceInstruction:this.nonceInfo.nonceInstruction.toJSON()}:null,instructions:this.instructions.map((e=>e.toJSON())),signers:this.signatures.map((({publicKey:e})=>e.toJSON()))}}add(...e){if(0===e.length)throw new Error("No instructions");return e.forEach((e=>{"instructions"in e?this.instructions=this.instructions.concat(e.instructions):"data"in e&&"programId"in e&&"keys"in e?this.instructions.push(e):this.instructions.push(new Hs(e))})),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let e,t,r;if(this.nonceInfo?(e=this.nonceInfo.nonce,t=this.instructions[0]!=this.nonceInfo.nonceInstruction?[this.nonceInfo.nonceInstruction,...this.instructions]:this.instructions):(e=this.recentBlockhash,t=this.instructions),!e)throw new Error("Transaction recentBlockhash required");if(t.length<1&&console.warn("No instructions provided"),this.feePayer)r=this.feePayer;else{if(!(this.signatures.length>0&&this.signatures[0].publicKey))throw new Error("Transaction fee payer required");r=this.signatures[0].publicKey}for(let e=0;e{e.keys.forEach((e=>{i.push({...e})}));const t=e.programId.toString();n.includes(t)||n.push(t)})),n.forEach((e=>{i.push({pubkey:new bs(e),isSigner:!1,isWritable:!1})}));const o=[];i.forEach((e=>{const t=e.pubkey.toString(),r=o.findIndex((e=>e.pubkey.toString()===t));r>-1?(o[r].isWritable=o[r].isWritable||e.isWritable,o[r].isSigner=o[r].isSigner||e.isSigner):o.push(e)})),o.sort((function(e,t){if(e.isSigner!==t.isSigner)return e.isSigner?-1:1;if(e.isWritable!==t.isWritable)return e.isWritable?-1:1;return e.pubkey.toBase58().localeCompare(t.pubkey.toBase58(),"en",{localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"})}));const s=o.findIndex((e=>e.pubkey.equals(r)));if(s>-1){const[e]=o.splice(s,1);e.isSigner=!0,e.isWritable=!0,o.unshift(e)}else o.unshift({pubkey:r,isSigner:!0,isWritable:!0});for(const e of this.signatures){const t=o.findIndex((t=>t.pubkey.equals(e.publicKey)));if(!(t>-1))throw new Error(`unknown signer: ${e.publicKey.toString()}`);o[t].isSigner||(o[t].isSigner=!0,console.warn("Transaction references a signature that is unnecessary, only the fee payer and instruction signer accounts should sign a transaction. This behavior is deprecated and will throw an error in the next major version release."))}let a=0,c=0,u=0;const h=[],l=[];o.forEach((({pubkey:e,isSigner:t,isWritable:r})=>{t?(h.push(e.toString()),a+=1,r||(c+=1)):(l.push(e.toString()),r||(u+=1))}));const f=h.concat(l),d=t.map((e=>{const{data:t,programId:r}=e;return{programIdIndex:f.indexOf(r.toString()),accounts:e.keys.map((e=>f.indexOf(e.pubkey.toString()))),data:Dr.encode(t)}}));return d.forEach((e=>{Rs(e.programIdIndex>=0),e.accounts.forEach((e=>Rs(e>=0)))})),new Ps({header:{numRequiredSignatures:a,numReadonlySignedAccounts:c,numReadonlyUnsignedAccounts:u},accountKeys:f,recentBlockhash:e,instructions:d})}_compile(){const e=this.compileMessage(),t=e.accountKeys.slice(0,e.header.numRequiredSignatures);if(this.signatures.length===t.length){if(this.signatures.every(((e,r)=>t[r].equals(e.publicKey))))return e}return this.signatures=t.map((e=>({signature:null,publicKey:e}))),e}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(e){return(await e.getFeeForMessage(this.compileMessage())).value}setSigners(...e){if(0===e.length)throw new Error("No signers");const t=new Set;this.signatures=e.filter((e=>{const r=e.toString();return!t.has(r)&&(t.add(r),!0)})).map((e=>({signature:null,publicKey:e})))}sign(...e){if(0===e.length)throw new Error("No signers");const t=new Set,r=[];for(const n of e){const e=n.publicKey.toString();t.has(e)||(t.add(e),r.push(n))}this.signatures=r.map((e=>({signature:null,publicKey:e.publicKey})));const n=this._compile();this._partialSign(n,...r)}partialSign(...e){if(0===e.length)throw new Error("No signers");const t=new Set,r=[];for(const n of e){const e=n.publicKey.toString();t.has(e)||(t.add(e),r.push(n))}const n=this._compile();this._partialSign(n,...r)}_partialSign(e,...t){const r=e.serialize();t.forEach((e=>{const t=ls(r,e.secretKey);this._addSignature(e.publicKey,ds(t))}))}addSignature(e,t){this._compile(),this._addSignature(e,t)}_addSignature(e,t){Rs(64===t.length);const r=this.signatures.findIndex((t=>e.equals(t.publicKey)));if(r<0)throw new Error(`unknown signer: ${e.toString()}`);this.signatures[r].signature=C.from(t)}verifySignatures(e=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),e)}_getMessageSignednessErrors(e,t){const r={};for(const{signature:n,publicKey:i}of this.signatures)null===n?t&&(r.missing||=[]).push(i):fs(n,e,i.toBytes())||(r.invalid||=[]).push(i);return r.invalid||r.missing?r:void 0}serialize(e){const{requireAllSignatures:t,verifySignatures:r}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},e),n=this.serializeMessage();if(r){const e=this._getMessageSignednessErrors(n,t);if(e){let t="Signature verification failed.";throw e.invalid&&(t+=`\nInvalid signature for public key${1===e.invalid.length?"":"(s)"} [\`${e.invalid.map((e=>e.toBase58())).join("`, `")}\`].`),e.missing&&(t+=`\nMissing signature for public key${1===e.missing.length?"":"(s)"} [\`${e.missing.map((e=>e.toBase58())).join("`, `")}\`].`),new Error(t)}}return this._serialize(n)}_serialize(e){const{signatures:t}=this,r=[];Ts(r,t.length);const n=r.length+64*t.length+e.length,i=C.alloc(n);return Rs(t.length<256),C.from(r).copy(i,0),t.forEach((({signature:e},t)=>{null!==e&&(Rs(64===e.length,"signature has invalid length"),C.from(e).copy(i,r.length+64*t))})),e.copy(i,r.length+64*t.length),Rs(i.length<=vs,`Transaction too large: ${i.length} > 1232`),i}get keys(){return Rs(1===this.instructions.length),this.instructions[0].keys.map((e=>e.pubkey))}get programId(){return Rs(1===this.instructions.length),this.instructions[0].programId}get data(){return Rs(1===this.instructions.length),this.instructions[0].data}static from(e){let t=[...e];const r=Is(t);let n=[];for(let e=0;e0&&(r.feePayer=e.accountKeys[0]),t.forEach(((t,n)=>{const i={signature:t==Dr.encode($s)?null:Dr.decode(t),publicKey:e.accountKeys[n]};r.signatures.push(i)})),e.instructions.forEach((t=>{const n=t.accounts.map((t=>{const n=e.accountKeys[t];return{pubkey:n,isSigner:r.signatures.some((e=>e.publicKey.toString()===n.toString()))||e.isAccountSigner(t),isWritable:e.isAccountWritable(t)}}));r.instructions.push(new Hs({keys:n,programId:e.accountKeys[t.programIdIndex],data:Dr.decode(t.data)}))})),r._message=e,r._json=r.toJSON(),r}}class Ds{get version(){return this.message.version}constructor(e,t){if(this.signatures=void 0,this.message=void 0,void 0!==t)Rs(t.length===e.header.numRequiredSignatures,"Expected signatures length to be equal to the number of required signatures"),this.signatures=t;else{const t=[];for(let r=0;re.equals(n.publicKey)));Rs(e>=0,`Cannot sign with non signer key ${n.publicKey.toBase58()}`),this.signatures[e]=ls(t,n.secretKey)}}addSignature(e,t){Rs(64===t.byteLength,"Signature must be 64 bytes long");const r=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex((t=>t.equals(e)));Rs(r>=0,`Can not add signature; \`${e.toBase58()}\` is not required to sign this transaction`),this.signatures[r]=t}}new bs("SysvarC1ock11111111111111111111111111111111"),new bs("SysvarEpochSchedu1e111111111111111111111111"),new bs("Sysvar1nstructions1111111111111111111111111"),new bs("SysvarRecentB1ockHashes11111111111111111111"),new bs("SysvarRent111111111111111111111111111111111"),new bs("SysvarRewards111111111111111111111111111111"),new bs("SysvarS1otHashes111111111111111111111111111"),new bs("SysvarS1otHistory11111111111111111111111111"),new bs("SysvarStakeHistory1111111111111111111111111");class Fs extends Error{constructor({action:e,signature:t,transactionMessage:r,logs:n}){const i=n?`Logs: \n${JSON.stringify(n.slice(-10),null,2)}. `:"",o="\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.";let s;switch(e){case"send":s=`Transaction ${t} resulted in an error. \n${r}. `+i+o;break;case"simulate":s=`Simulation failed. \nMessage: ${r}. \n`+i+o;break;default:s=`Unknown action '${e}'`}super(s),this.signature=void 0,this.transactionMessage=void 0,this.transactionLogs=void 0,this.signature=t,this.transactionMessage=r,this.transactionLogs=n||void 0}get transactionError(){return{message:this.transactionMessage,logs:Array.isArray(this.transactionLogs)?this.transactionLogs:void 0}}get logs(){const e=this.transactionLogs;if(null==e||"object"!=typeof e||!("then"in e))return e}async getLogs(e){return Array.isArray(this.transactionLogs)||(this.transactionLogs=new Promise(((t,r)=>{e.getTransaction(this.signature).then((e=>{if(e&&e.meta&&e.meta.logMessages){const r=e.meta.logMessages;this.transactionLogs=r,t(r)}else r(new Error("Log messages not found"))})).catch(r)}))),await this.transactionLogs}}class qs extends Error{constructor({code:e,message:t,data:r},n){super(null!=n?`${n}: ${t}`:t),this.code=void 0,this.data=void 0,this.code=e,this.data=r,this.name="SolanaJSONRPCError"}}function Ks(e){return new Promise((t=>setTimeout(t,e)))}const Ws=mi("lamportsPerSignature"),Vs=bi([yi("version"),yi("state"),xs("authorizedPubkey"),xs("nonce"),bi([Ws],"feeCalculator")]);Vs.span;class Zs{constructor(e){this.authorizedPubkey=void 0,this.nonce=void 0,this.feeCalculator=void 0,this.authorizedPubkey=e.authorizedPubkey,this.nonce=e.nonce,this.feeCalculator=e.feeCalculator}static fromAccountData(e){const t=Vs.decode(ds(e),0);return new Zs({authorizedPubkey:new bs(t.authorizedPubkey),nonce:new bs(t.nonce).toString(),feeCalculator:t.feeCalculator})}}const Gs=(Js=8,e=>{const t=_i(Js,e),{encode:r,decode:n}=(e=>({decode:e.decode.bind(e),encode:e.encode.bind(e)}))(t),i=t;return i.decode=(e,t)=>{const r=n(e,t);return Si(C.from(r))},i.encode=(e,t,n)=>{const i=xi(e,Js);return r(i,t,n)},i});var Js,Ys,Xs;function Qs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function ea(){if(Xs)return Ys;Xs=1;var e=Object.prototype.toString,t=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};function r(n,i){var o,s,a,c,u,h,l;if(!0===n)return"true";if(!1===n)return"false";switch(typeof n){case"object":if(null===n)return null;if(n.toJSON&&"function"==typeof n.toJSON)return r(n.toJSON(),i);if("[object Array]"===(l=e.call(n))){for(a="[",s=n.length-1,o=0;o-1&&(a+=r(n[o],!0)),a+"]"}if("[object Object]"===l){for(s=(c=t(n).sort()).length,a="",o=0;o1;)e/=2,t++;return t}class na{constructor(e,t,r,n,i){this.slotsPerEpoch=void 0,this.leaderScheduleSlotOffset=void 0,this.warmup=void 0,this.firstNormalEpoch=void 0,this.firstNormalSlot=void 0,this.slotsPerEpoch=e,this.leaderScheduleSlotOffset=t,this.warmup=r,this.firstNormalEpoch=n,this.firstNormalSlot=i}getEpoch(e){return this.getEpochAndSlotIndex(e)[0]}getEpochAndSlotIndex(e){if(e>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,1+(t|=t>>32)))-ra(32)-1;return[r,e-(this.getSlotsInEpoch(r)-32)]}{const t=e-this.firstNormalSlot,r=Math.floor(t/this.slotsPerEpoch);return[this.firstNormalEpoch+r,t%this.slotsPerEpoch]}var t}getFirstSlotInEpoch(e){return e<=this.firstNormalEpoch?32*(Math.pow(2,e)-1):(e-this.firstNormalEpoch)*this.slotsPerEpoch+this.firstNormalSlot}getLastSlotInEpoch(e){return this.getFirstSlotInEpoch(e)+this.getSlotsInEpoch(e)-1}getSlotsInEpoch(e){return e{const r=function(e,t){return new Po(e,t)}(e,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...t});return this.underlyingSocket="socket"in r?r.socket:r,r}),e,t,r),this.underlyingSocket=void 0}call(...e){const t=this.underlyingSocket?.readyState;return 1===t?super.call(...e):Promise.reject(new Error("Tried to call a JSON-RPC method `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+")"))}notify(...e){const t=this.underlyingSocket?.readyState;return 1===t?super.notify(...e):Promise.reject(new Error("Tried to send a JSON-RPC notification `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+")"))}}class sa{constructor(e){this.key=void 0,this.state=void 0,this.key=e.key,this.state=e.state}isActive(){const e=BigInt("0xffffffffffffffff");return this.state.deactivationSlot===e}static deserialize(e){const t=function(e,t){let r;try{r=e.layout.decode(t)}catch(e){throw new Error("invalid instruction; "+e)}if(r.typeIndex!==e.index)throw new Error(`invalid account data; account type mismatch ${r.typeIndex} != ${e.index}`);return r}(aa,e),r=e.length-56;Rs(r>=0,"lookup table is invalid"),Rs(r%32==0,"lookup table is invalid");const n=r/32,{addresses:i}=bi([vi(xs(),n,"addresses")]).decode(e.slice(56));return{deactivationSlot:t.deactivationSlot,lastExtendedSlot:t.lastExtendedSlot,lastExtendedSlotStartIndex:t.lastExtendedStartIndex,authority:0!==t.authority.length?new bs(t.authority[0]):void 0,addresses:i.map((e=>new bs(e)))}}}const aa={index:1,layout:bi([yi("typeIndex"),Gs("deactivationSlot"),mi("lastExtendedSlot"),pi("lastExtendedStartIndex"),pi(),vi(xs(),di(pi(),-1),"authority")])},ca=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;const ua=Yi(Hi(bs),Wi(),(e=>new bs(e))),ha=Vi([Wi(),zi("base64")]),la=Yi(Hi(C),ha,(e=>C.from(e[0],"base64")));function fa(e){let t,r;if("string"==typeof e)t=e;else if(e){const{commitment:n,...i}=e;t=n,r=i}return{commitment:t,config:r}}function da(e){return e.map((e=>"memcmp"in e?{...e,memcmp:{...e.memcmp,encoding:e.memcmp.encoding??"base58"}}:e))}function pa(e){return Gi([Zi({jsonrpc:zi("2.0"),id:Wi(),result:e}),Zi({jsonrpc:zi("2.0"),id:Wi(),error:Zi({code:Ji(),message:Wi(),data:qi(Ui("any",(()=>!0)))})})])}const ga=pa(Ji());function ya(e){return Yi(pa(e),ga,(t=>"error"in t?t:{...t,result:Ci(t.result,e)}))}function ma(e){return ya(Zi({context:Zi({slot:Fi()}),value:e}))}function wa(e){return Zi({context:Zi({slot:Fi()}),value:e})}function ba(e,t){return 0===e?new Ns({header:t.header,staticAccountKeys:t.accountKeys.map((e=>new bs(e))),recentBlockhash:t.recentBlockhash,compiledInstructions:t.instructions.map((e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:Dr.decode(e.data)}))),addressTableLookups:t.addressTableLookups}):new Ps(t)}const va=Zi({foundation:Fi(),foundationTerm:Fi(),initial:Fi(),taper:Fi(),terminal:Fi()}),_a=ya(ji(Di(Zi({epoch:Fi(),effectiveSlot:Fi(),amount:Fi(),postBalance:Fi(),commission:qi(Di(Fi()))})))),Ea=ji(Zi({slot:Fi(),prioritizationFee:Fi()})),Sa=Zi({total:Fi(),validator:Fi(),foundation:Fi(),epoch:Fi()}),Aa=Zi({epoch:Fi(),slotIndex:Fi(),slotsInEpoch:Fi(),absoluteSlot:Fi(),blockHeight:qi(Fi()),transactionCount:qi(Fi())}),xa=Zi({slotsPerEpoch:Fi(),leaderScheduleSlotOffset:Fi(),warmup:$i(),firstNormalEpoch:Fi(),firstNormalSlot:Fi()}),ka=Ki(Wi(),ji(Fi())),Ba=Di(Gi([Zi({}),Wi()])),Ia=Zi({err:Ba}),Ta=zi("receivedSignature"),Ra=Zi({"solana-core":Wi(),"feature-set":qi(Fi())}),Oa=Zi({program:Wi(),programId:ua,parsed:Ji()}),La=Zi({programId:ua,accounts:ji(ua),data:Wi()}),Ma=ma(Zi({err:Di(Gi([Zi({}),Wi()])),logs:Di(ji(Wi())),accounts:qi(Di(ji(Di(Zi({executable:$i(),owner:Wi(),lamports:Fi(),data:ji(Wi()),rentEpoch:qi(Fi())}))))),unitsConsumed:qi(Fi()),returnData:qi(Di(Zi({programId:Wi(),data:Vi([Wi(),zi("base64")])}))),innerInstructions:qi(Di(ji(Zi({index:Fi(),instructions:ji(Gi([Oa,La]))}))))})),Ca=ma(Zi({byIdentity:Ki(Wi(),ji(Fi())),range:Zi({firstSlot:Fi(),lastSlot:Fi()})}));const Pa=ya(va),Na=ya(Sa),Ua=ya(Ea),ja=ya(Aa),$a=ya(xa),Ha=ya(ka),za=ya(Fi()),Da=ma(Zi({total:Fi(),circulating:Fi(),nonCirculating:Fi(),nonCirculatingAccounts:ji(ua)})),Fa=Zi({amount:Wi(),uiAmount:Di(Fi()),decimals:Fi(),uiAmountString:qi(Wi())}),qa=ma(ji(Zi({address:ua,amount:Wi(),uiAmount:Di(Fi()),decimals:Fi(),uiAmountString:qi(Wi())}))),Ka=ma(ji(Zi({pubkey:ua,account:Zi({executable:$i(),owner:ua,lamports:Fi(),data:la,rentEpoch:Fi()})}))),Wa=Zi({program:Wi(),parsed:Ji(),space:Fi()}),Va=ma(ji(Zi({pubkey:ua,account:Zi({executable:$i(),owner:ua,lamports:Fi(),data:Wa,rentEpoch:Fi()})}))),Za=ma(ji(Zi({lamports:Fi(),address:ua}))),Ga=Zi({executable:$i(),owner:ua,lamports:Fi(),data:la,rentEpoch:Fi()}),Ja=Zi({pubkey:ua,account:Ga}),Ya=Yi(Gi([Hi(C),Wa]),Gi([ha,Wa]),(e=>Array.isArray(e)?Ci(e,la):e)),Xa=Zi({executable:$i(),owner:ua,lamports:Fi(),data:Ya,rentEpoch:Fi()}),Qa=Zi({pubkey:ua,account:Xa}),ec=Zi({state:Gi([zi("active"),zi("inactive"),zi("activating"),zi("deactivating")]),active:Fi(),inactive:Fi()}),tc=ya(ji(Zi({signature:Wi(),slot:Fi(),err:Ba,memo:Di(Wi()),blockTime:qi(Di(Fi()))}))),rc=ya(ji(Zi({signature:Wi(),slot:Fi(),err:Ba,memo:Di(Wi()),blockTime:qi(Di(Fi()))}))),nc=Zi({subscription:Fi(),result:wa(Ga)}),ic=Zi({pubkey:ua,account:Ga}),oc=Zi({subscription:Fi(),result:wa(ic)}),sc=Zi({parent:Fi(),slot:Fi(),root:Fi()}),ac=Zi({subscription:Fi(),result:sc}),cc=Gi([Zi({type:Gi([zi("firstShredReceived"),zi("completed"),zi("optimisticConfirmation"),zi("root")]),slot:Fi(),timestamp:Fi()}),Zi({type:zi("createdBank"),parent:Fi(),slot:Fi(),timestamp:Fi()}),Zi({type:zi("frozen"),slot:Fi(),timestamp:Fi(),stats:Zi({numTransactionEntries:Fi(),numSuccessfulTransactions:Fi(),numFailedTransactions:Fi(),maxTransactionsPerEntry:Fi()})}),Zi({type:zi("dead"),slot:Fi(),timestamp:Fi(),err:Wi()})]),uc=Zi({subscription:Fi(),result:cc}),hc=Zi({subscription:Fi(),result:wa(Gi([Ia,Ta]))}),lc=Zi({subscription:Fi(),result:Fi()}),fc=Zi({pubkey:Wi(),gossip:Di(Wi()),tpu:Di(Wi()),rpc:Di(Wi()),version:Di(Wi())}),dc=Zi({votePubkey:Wi(),nodePubkey:Wi(),activatedStake:Fi(),epochVoteAccount:$i(),epochCredits:ji(Vi([Fi(),Fi(),Fi()])),commission:Fi(),lastVote:Fi(),rootSlot:Di(Fi())}),pc=ya(Zi({current:ji(dc),delinquent:ji(dc)})),gc=Gi([zi("processed"),zi("confirmed"),zi("finalized")]),yc=Zi({slot:Fi(),confirmations:Di(Fi()),err:Ba,confirmationStatus:qi(gc)}),mc=ma(ji(Di(yc))),wc=ya(Fi()),bc=Zi({accountKey:ua,writableIndexes:ji(Fi()),readonlyIndexes:ji(Fi())}),vc=Zi({signatures:ji(Wi()),message:Zi({accountKeys:ji(Wi()),header:Zi({numRequiredSignatures:Fi(),numReadonlySignedAccounts:Fi(),numReadonlyUnsignedAccounts:Fi()}),instructions:ji(Zi({accounts:ji(Fi()),data:Wi(),programIdIndex:Fi()})),recentBlockhash:Wi(),addressTableLookups:qi(ji(bc))})}),_c=Zi({pubkey:ua,signer:$i(),writable:$i(),source:qi(Gi([zi("transaction"),zi("lookupTable")]))}),Ec=Zi({accountKeys:ji(_c),signatures:ji(Wi())}),Sc=Zi({parsed:Ji(),program:Wi(),programId:ua}),Ac=Zi({accounts:ji(ua),data:Wi(),programId:ua}),xc=Yi(Gi([Ac,Sc]),Gi([Zi({parsed:Ji(),program:Wi(),programId:Wi()}),Zi({accounts:ji(Wi()),data:Wi(),programId:Wi()})]),(e=>Ci(e,"accounts"in e?Ac:Sc))),kc=Zi({signatures:ji(Wi()),message:Zi({accountKeys:ji(_c),instructions:ji(xc),recentBlockhash:Wi(),addressTableLookups:qi(Di(ji(bc)))})}),Bc=Zi({accountIndex:Fi(),mint:Wi(),owner:qi(Wi()),uiTokenAmount:Fa}),Ic=Zi({writable:ji(ua),readonly:ji(ua)}),Tc=Zi({err:Ba,fee:Fi(),innerInstructions:qi(Di(ji(Zi({index:Fi(),instructions:ji(Zi({accounts:ji(Fi()),data:Wi(),programIdIndex:Fi()}))})))),preBalances:ji(Fi()),postBalances:ji(Fi()),logMessages:qi(Di(ji(Wi()))),preTokenBalances:qi(Di(ji(Bc))),postTokenBalances:qi(Di(ji(Bc))),loadedAddresses:qi(Ic),computeUnitsConsumed:qi(Fi())}),Rc=Zi({err:Ba,fee:Fi(),innerInstructions:qi(Di(ji(Zi({index:Fi(),instructions:ji(xc)})))),preBalances:ji(Fi()),postBalances:ji(Fi()),logMessages:qi(Di(ji(Wi()))),preTokenBalances:qi(Di(ji(Bc))),postTokenBalances:qi(Di(ji(Bc))),loadedAddresses:qi(Ic),computeUnitsConsumed:qi(Fi())}),Oc=Gi([zi(0),zi("legacy")]),Lc=Zi({pubkey:Wi(),lamports:Fi(),postBalance:Di(Fi()),rewardType:Di(Wi()),commission:qi(Di(Fi()))}),Mc=ya(Di(Zi({blockhash:Wi(),previousBlockhash:Wi(),parentSlot:Fi(),transactions:ji(Zi({transaction:vc,meta:Di(Tc),version:qi(Oc)})),rewards:qi(ji(Lc)),blockTime:Di(Fi()),blockHeight:Di(Fi())}))),Cc=ya(Di(Zi({blockhash:Wi(),previousBlockhash:Wi(),parentSlot:Fi(),rewards:qi(ji(Lc)),blockTime:Di(Fi()),blockHeight:Di(Fi())}))),Pc=ya(Di(Zi({blockhash:Wi(),previousBlockhash:Wi(),parentSlot:Fi(),transactions:ji(Zi({transaction:Ec,meta:Di(Tc),version:qi(Oc)})),rewards:qi(ji(Lc)),blockTime:Di(Fi()),blockHeight:Di(Fi())}))),Nc=ya(Di(Zi({blockhash:Wi(),previousBlockhash:Wi(),parentSlot:Fi(),transactions:ji(Zi({transaction:kc,meta:Di(Rc),version:qi(Oc)})),rewards:qi(ji(Lc)),blockTime:Di(Fi()),blockHeight:Di(Fi())}))),Uc=ya(Di(Zi({blockhash:Wi(),previousBlockhash:Wi(),parentSlot:Fi(),transactions:ji(Zi({transaction:Ec,meta:Di(Rc),version:qi(Oc)})),rewards:qi(ji(Lc)),blockTime:Di(Fi()),blockHeight:Di(Fi())}))),jc=ya(Di(Zi({blockhash:Wi(),previousBlockhash:Wi(),parentSlot:Fi(),rewards:qi(ji(Lc)),blockTime:Di(Fi()),blockHeight:Di(Fi())}))),$c=ya(Di(Zi({blockhash:Wi(),previousBlockhash:Wi(),parentSlot:Fi(),transactions:ji(Zi({transaction:vc,meta:Di(Tc)})),rewards:qi(ji(Lc)),blockTime:Di(Fi())}))),Hc=ya(Di(Zi({blockhash:Wi(),previousBlockhash:Wi(),parentSlot:Fi(),signatures:ji(Wi()),blockTime:Di(Fi())}))),zc=ya(Di(Zi({slot:Fi(),meta:Di(Tc),blockTime:qi(Di(Fi())),transaction:vc,version:qi(Oc)}))),Dc=ya(Di(Zi({slot:Fi(),transaction:kc,meta:Di(Rc),blockTime:qi(Di(Fi())),version:qi(Oc)}))),Fc=ma(Zi({blockhash:Wi(),feeCalculator:Zi({lamportsPerSignature:Fi()})})),qc=ma(Zi({blockhash:Wi(),lastValidBlockHeight:Fi()})),Kc=ma($i()),Wc=ya(ji(Zi({slot:Fi(),numTransactions:Fi(),numSlots:Fi(),samplePeriodSecs:Fi()}))),Vc=ma(Di(Zi({feeCalculator:Zi({lamportsPerSignature:Fi()})}))),Zc=ya(Wi()),Gc=ya(Wi()),Jc=Zi({err:Ba,logs:ji(Wi()),signature:Wi()}),Yc=Zi({result:wa(Jc),subscription:Fi()}),Xc={"solana-client":"js/1.0.0-maintenance"};class Qc{constructor(e,t){let r,n,i,o,s,a;var c;this._commitment=void 0,this._confirmTransactionInitialTimeout=void 0,this._rpcEndpoint=void 0,this._rpcWsEndpoint=void 0,this._rpcClient=void 0,this._rpcRequest=void 0,this._rpcBatchRequest=void 0,this._rpcWebSocket=void 0,this._rpcWebSocketConnected=!1,this._rpcWebSocketHeartbeat=null,this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketGeneration=0,this._disableBlockhashCaching=!1,this._pollingBlockhash=!1,this._blockhashInfo={latestBlockhash:null,lastFetch:0,transactionSignatures:[],simulatedSignatures:[]},this._nextClientSubscriptionId=0,this._subscriptionDisposeFunctionsByClientSubscriptionId={},this._subscriptionHashByClientSubscriptionId={},this._subscriptionStateChangeCallbacksByHash={},this._subscriptionCallbacksByServerSubscriptionId={},this._subscriptionsByHash={},this._subscriptionsAutoDisposedByRpc=new Set,this.getBlockHeight=(()=>{const e={};return async t=>{const{commitment:r,config:n}=fa(t),i=this._buildArgs([],r,void 0,n),o=ta(i);return e[o]=e[o]??(async()=>{try{const e=Ci(await this._rpcRequest("getBlockHeight",i),ya(Fi()));if("error"in e)throw new qs(e.error,"failed to get block height information");return e.result}finally{delete e[o]}})(),await e[o]}})(),t&&"string"==typeof t?this._commitment=t:t&&(this._commitment=t.commitment,this._confirmTransactionInitialTimeout=t.confirmTransactionInitialTimeout,r=t.wsEndpoint,n=t.httpHeaders,i=t.fetch,o=t.fetchMiddleware,s=t.disableRetryOnRateLimit,a=t.httpAgent),this._rpcEndpoint=function(e){if(!1===/^https?:/.test(e))throw new TypeError("Endpoint URL must start with `http:` or `https:`.");return e}(e),this._rpcWsEndpoint=r||function(e){const t=e.match(ca);if(null==t)throw TypeError(`Failed to validate endpoint URL \`${e}\``);const[r,n,i,o]=t,s=e.startsWith("https:")?"wss:":"ws:",a=null==i?null:parseInt(i.slice(1),10);return`${s}//${n}${null==a?"":`:${a+1}`}${o}`}(e),this._rpcClient=function(e,t,r,n,i,o){const s=r||ia;let a;null!=o&&console.warn("You have supplied an `httpAgent` when creating a `Connection` in a browser environment.It has been ignored; `httpAgent` is only used in Node environments."),n&&(a=async(e,t)=>{const r=await new Promise(((r,i)=>{try{n(e,t,((e,t)=>r([e,t])))}catch(e){i(e)}}));return await s(...r)});const c=new Lo((async(r,n)=>{const o={method:"POST",body:r,agent:void 0,headers:Object.assign({"Content-Type":"application/json"},t||{},Xc)};try{let t,r=5,c=500;for(;t=a?await a(e,o):await s(e,o),429===t.status&&!0!==i&&(r-=1,0!==r);)console.error(`Server responded with ${t.status} ${t.statusText}. Retrying after ${c}ms delay...`),await Ks(c),c*=2;const u=await t.text();t.ok?n(null,u):n(new Error(`${t.status} ${t.statusText}: ${u}`))}catch(e){e instanceof Error&&n(e)}}),{});return c}(e,n,i,o,s,a),this._rpcRequest=(c=this._rpcClient,(e,t)=>new Promise(((r,n)=>{c.request(e,t,((e,t)=>{e?n(e):r(t)}))}))),this._rpcBatchRequest=function(e){return t=>new Promise(((r,n)=>{0===t.length&&r([]);const i=t.map((t=>e.request(t.methodName,t.args)));e.request(i,((e,t)=>{e?n(e):r(t)}))}))}(this._rpcClient),this._rpcWebSocket=new oa(this._rpcWsEndpoint,{autoconnect:!1,max_reconnects:1/0}),this._rpcWebSocket.on("open",this._wsOnOpen.bind(this)),this._rpcWebSocket.on("error",this._wsOnError.bind(this)),this._rpcWebSocket.on("close",this._wsOnClose.bind(this)),this._rpcWebSocket.on("accountNotification",this._wsOnAccountNotification.bind(this)),this._rpcWebSocket.on("programNotification",this._wsOnProgramAccountNotification.bind(this)),this._rpcWebSocket.on("slotNotification",this._wsOnSlotNotification.bind(this)),this._rpcWebSocket.on("slotsUpdatesNotification",this._wsOnSlotUpdatesNotification.bind(this)),this._rpcWebSocket.on("signatureNotification",this._wsOnSignatureNotification.bind(this)),this._rpcWebSocket.on("rootNotification",this._wsOnRootNotification.bind(this)),this._rpcWebSocket.on("logsNotification",this._wsOnLogsNotification.bind(this))}get commitment(){return this._commitment}get rpcEndpoint(){return this._rpcEndpoint}async getBalanceAndContext(e,t){const{commitment:r,config:n}=fa(t),i=this._buildArgs([e.toBase58()],r,void 0,n),o=Ci(await this._rpcRequest("getBalance",i),ma(Fi()));if("error"in o)throw new qs(o.error,`failed to get balance for ${e.toBase58()}`);return o.result}async getBalance(e,t){return await this.getBalanceAndContext(e,t).then((e=>e.value)).catch((t=>{throw new Error("failed to get balance of account "+e.toBase58()+": "+t)}))}async getBlockTime(e){const t=Ci(await this._rpcRequest("getBlockTime",[e]),ya(Di(Fi())));if("error"in t)throw new qs(t.error,`failed to get block time for slot ${e}`);return t.result}async getMinimumLedgerSlot(){const e=Ci(await this._rpcRequest("minimumLedgerSlot",[]),ya(Fi()));if("error"in e)throw new qs(e.error,"failed to get minimum ledger slot");return e.result}async getFirstAvailableBlock(){const e=Ci(await this._rpcRequest("getFirstAvailableBlock",[]),za);if("error"in e)throw new qs(e.error,"failed to get first available block");return e.result}async getSupply(e){let t={};t="string"==typeof e?{commitment:e}:e?{...e,commitment:e&&e.commitment||this.commitment}:{commitment:this.commitment};const r=Ci(await this._rpcRequest("getSupply",[t]),Da);if("error"in r)throw new qs(r.error,"failed to get supply");return r.result}async getTokenSupply(e,t){const r=this._buildArgs([e.toBase58()],t),n=Ci(await this._rpcRequest("getTokenSupply",r),ma(Fa));if("error"in n)throw new qs(n.error,"failed to get token supply");return n.result}async getTokenAccountBalance(e,t){const r=this._buildArgs([e.toBase58()],t),n=Ci(await this._rpcRequest("getTokenAccountBalance",r),ma(Fa));if("error"in n)throw new qs(n.error,"failed to get token account balance");return n.result}async getTokenAccountsByOwner(e,t,r){const{commitment:n,config:i}=fa(r);let o=[e.toBase58()];"mint"in t?o.push({mint:t.mint.toBase58()}):o.push({programId:t.programId.toBase58()});const s=this._buildArgs(o,n,"base64",i),a=Ci(await this._rpcRequest("getTokenAccountsByOwner",s),Ka);if("error"in a)throw new qs(a.error,`failed to get token accounts owned by account ${e.toBase58()}`);return a.result}async getParsedTokenAccountsByOwner(e,t,r){let n=[e.toBase58()];"mint"in t?n.push({mint:t.mint.toBase58()}):n.push({programId:t.programId.toBase58()});const i=this._buildArgs(n,r,"jsonParsed"),o=Ci(await this._rpcRequest("getTokenAccountsByOwner",i),Va);if("error"in o)throw new qs(o.error,`failed to get token accounts owned by account ${e.toBase58()}`);return o.result}async getLargestAccounts(e){const t={...e,commitment:e&&e.commitment||this.commitment},r=t.filter||t.commitment?[t]:[],n=Ci(await this._rpcRequest("getLargestAccounts",r),Za);if("error"in n)throw new qs(n.error,"failed to get largest accounts");return n.result}async getTokenLargestAccounts(e,t){const r=this._buildArgs([e.toBase58()],t),n=Ci(await this._rpcRequest("getTokenLargestAccounts",r),qa);if("error"in n)throw new qs(n.error,"failed to get token largest accounts");return n.result}async getAccountInfoAndContext(e,t){const{commitment:r,config:n}=fa(t),i=this._buildArgs([e.toBase58()],r,"base64",n),o=Ci(await this._rpcRequest("getAccountInfo",i),ma(Di(Ga)));if("error"in o)throw new qs(o.error,`failed to get info about account ${e.toBase58()}`);return o.result}async getParsedAccountInfo(e,t){const{commitment:r,config:n}=fa(t),i=this._buildArgs([e.toBase58()],r,"jsonParsed",n),o=Ci(await this._rpcRequest("getAccountInfo",i),ma(Di(Xa)));if("error"in o)throw new qs(o.error,`failed to get info about account ${e.toBase58()}`);return o.result}async getAccountInfo(e,t){try{return(await this.getAccountInfoAndContext(e,t)).value}catch(t){throw new Error("failed to get info about account "+e.toBase58()+": "+t)}}async getMultipleParsedAccounts(e,t){const{commitment:r,config:n}=fa(t),i=e.map((e=>e.toBase58())),o=this._buildArgs([i],r,"jsonParsed",n),s=Ci(await this._rpcRequest("getMultipleAccounts",o),ma(ji(Di(Xa))));if("error"in s)throw new qs(s.error,`failed to get info for accounts ${i}`);return s.result}async getMultipleAccountsInfoAndContext(e,t){const{commitment:r,config:n}=fa(t),i=e.map((e=>e.toBase58())),o=this._buildArgs([i],r,"base64",n),s=Ci(await this._rpcRequest("getMultipleAccounts",o),ma(ji(Di(Ga))));if("error"in s)throw new qs(s.error,`failed to get info for accounts ${i}`);return s.result}async getMultipleAccountsInfo(e,t){return(await this.getMultipleAccountsInfoAndContext(e,t)).value}async getStakeActivation(e,t,r){const{commitment:n,config:i}=fa(t),o=this._buildArgs([e.toBase58()],n,void 0,{...i,epoch:null!=r?r:i?.epoch}),s=Ci(await this._rpcRequest("getStakeActivation",o),ya(ec));if("error"in s)throw new qs(s.error,`failed to get Stake Activation ${e.toBase58()}`);return s.result}async getProgramAccounts(e,t){const{commitment:r,config:n}=fa(t),{encoding:i,...o}=n||{},s=this._buildArgs([e.toBase58()],r,i||"base64",{...o,...o.filters?{filters:da(o.filters)}:null}),a=await this._rpcRequest("getProgramAccounts",s),c=ji(Ja),u=!0===o.withContext?Ci(a,ma(c)):Ci(a,ya(c));if("error"in u)throw new qs(u.error,`failed to get accounts owned by program ${e.toBase58()}`);return u.result}async getParsedProgramAccounts(e,t){const{commitment:r,config:n}=fa(t),i=this._buildArgs([e.toBase58()],r,"jsonParsed",n),o=Ci(await this._rpcRequest("getProgramAccounts",i),ya(ji(Qa)));if("error"in o)throw new qs(o.error,`failed to get accounts owned by program ${e.toBase58()}`);return o.result}async confirmTransaction(e,t){let r,n;if("string"==typeof e)r=e;else{const t=e;if(t.abortSignal?.aborted)return Promise.reject(t.abortSignal.reason);r=t.signature}try{n=Dr.decode(r)}catch(e){throw new Error("signature must be base58 encoded: "+r)}return Rs(64===n.length,"signature has invalid length"),"string"==typeof e?await this.confirmTransactionUsingLegacyTimeoutStrategy({commitment:t||this.commitment,signature:r}):"lastValidBlockHeight"in e?await this.confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:t||this.commitment,strategy:e}):await this.confirmTransactionUsingDurableNonceStrategy({commitment:t||this.commitment,strategy:e})}getCancellationPromise(e){return new Promise(((t,r)=>{null!=e&&(e.aborted?r(e.reason):e.addEventListener("abort",(()=>{r(e.reason)})))}))}getTransactionConfirmationPromise({commitment:e,signature:t}){let r,n,i=!1;const o=new Promise(((o,s)=>{try{r=this.onSignature(t,((e,t)=>{r=void 0;const n={context:t,value:e};o({__type:js.PROCESSED,response:n})}),e);const a=new Promise((e=>{null==r?e():n=this._onSubscriptionStateChange(r,(t=>{"subscribed"===t&&e()}))}));(async()=>{if(await a,i)return;const r=await this.getSignatureStatus(t);if(i)return;if(null==r)return;const{context:n,value:c}=r;if(null!=c)if(c?.err)s(c.err);else{switch(e){case"confirmed":case"single":case"singleGossip":if("processed"===c.confirmationStatus)return;break;case"finalized":case"max":case"root":if("processed"===c.confirmationStatus||"confirmed"===c.confirmationStatus)return}i=!0,o({__type:js.PROCESSED,response:{context:n,value:c}})}})()}catch(e){s(e)}}));return{abortConfirmation:()=>{n&&(n(),n=void 0),null!=r&&(this.removeSignatureListener(r),r=void 0)},confirmationPromise:o}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:e,strategy:{abortSignal:t,lastValidBlockHeight:r,signature:n}}){let i=!1;const o=new Promise((t=>{const n=async()=>{try{return await this.getBlockHeight(e)}catch(e){return-1}};(async()=>{let e=await n();if(!i){for(;e<=r;){if(await Ks(1e3),i)return;if(e=await n(),i)return}t({__type:js.BLOCKHEIGHT_EXCEEDED})}})()})),{abortConfirmation:s,confirmationPromise:a}=this.getTransactionConfirmationPromise({commitment:e,signature:n}),c=this.getCancellationPromise(t);let u;try{const e=await Promise.race([c,a,o]);if(e.__type!==js.PROCESSED)throw new _s(n);u=e.response}finally{i=!0,s()}return u}async confirmTransactionUsingDurableNonceStrategy({commitment:e,strategy:{abortSignal:t,minContextSlot:r,nonceAccountPubkey:n,nonceValue:i,signature:o}}){let s=!1;const a=new Promise((t=>{let o=i,a=null;const c=async()=>{try{const{context:t,value:i}=await this.getNonceAndContext(n,{commitment:e,minContextSlot:r});return a=t.slot,i?.nonce}catch(e){return o}};(async()=>{if(o=await c(),!s)for(;;){if(i!==o)return void t({__type:js.NONCE_INVALID,slotInWhichNonceDidAdvance:a});if(await Ks(2e3),s)return;if(o=await c(),s)return}})()})),{abortConfirmation:c,confirmationPromise:u}=this.getTransactionConfirmationPromise({commitment:e,signature:o}),h=this.getCancellationPromise(t);let l;try{const t=await Promise.race([h,u,a]);if(t.__type===js.PROCESSED)l=t.response;else{let n;for(;;){const e=await this.getSignatureStatus(o);if(null==e)break;if(!(e.context.slot<(t.slotInWhichNonceDidAdvance??r))){n=e;break}await Ks(400)}if(!n?.value)throw new Ss(o);{const t=e||"finalized",{confirmationStatus:r}=n.value;switch(t){case"processed":case"recent":if("processed"!==r&&"confirmed"!==r&&"finalized"!==r)throw new Ss(o);break;case"confirmed":case"single":case"singleGossip":if("confirmed"!==r&&"finalized"!==r)throw new Ss(o);break;case"finalized":case"max":case"root":if("finalized"!==r)throw new Ss(o)}l={context:n.context,value:{err:n.value.err}}}}}finally{s=!0,c()}return l}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:e,signature:t}){let r;const n=new Promise((t=>{let n=this._confirmTransactionInitialTimeout||6e4;switch(e){case"processed":case"recent":case"single":case"confirmed":case"singleGossip":n=this._confirmTransactionInitialTimeout||3e4}r=setTimeout((()=>t({__type:js.TIMED_OUT,timeoutMs:n})),n)})),{abortConfirmation:i,confirmationPromise:o}=this.getTransactionConfirmationPromise({commitment:e,signature:t});let s;try{const e=await Promise.race([o,n]);if(e.__type!==js.PROCESSED)throw new Es(t,e.timeoutMs/1e3);s=e.response}finally{clearTimeout(r),i()}return s}async getClusterNodes(){const e=Ci(await this._rpcRequest("getClusterNodes",[]),ya(ji(fc)));if("error"in e)throw new qs(e.error,"failed to get cluster nodes");return e.result}async getVoteAccounts(e){const t=this._buildArgs([],e),r=Ci(await this._rpcRequest("getVoteAccounts",t),pc);if("error"in r)throw new qs(r.error,"failed to get vote accounts");return r.result}async getSlot(e){const{commitment:t,config:r}=fa(e),n=this._buildArgs([],t,void 0,r),i=Ci(await this._rpcRequest("getSlot",n),ya(Fi()));if("error"in i)throw new qs(i.error,"failed to get slot");return i.result}async getSlotLeader(e){const{commitment:t,config:r}=fa(e),n=this._buildArgs([],t,void 0,r),i=Ci(await this._rpcRequest("getSlotLeader",n),ya(Wi()));if("error"in i)throw new qs(i.error,"failed to get slot leader");return i.result}async getSlotLeaders(e,t){const r=[e,t],n=Ci(await this._rpcRequest("getSlotLeaders",r),ya(ji(ua)));if("error"in n)throw new qs(n.error,"failed to get slot leaders");return n.result}async getSignatureStatus(e,t){const{context:r,value:n}=await this.getSignatureStatuses([e],t);Rs(1===n.length);return{context:r,value:n[0]}}async getSignatureStatuses(e,t){const r=[e];t&&r.push(t);const n=Ci(await this._rpcRequest("getSignatureStatuses",r),mc);if("error"in n)throw new qs(n.error,"failed to get signature status");return n.result}async getTransactionCount(e){const{commitment:t,config:r}=fa(e),n=this._buildArgs([],t,void 0,r),i=Ci(await this._rpcRequest("getTransactionCount",n),ya(Fi()));if("error"in i)throw new qs(i.error,"failed to get transaction count");return i.result}async getTotalSupply(e){return(await this.getSupply({commitment:e,excludeNonCirculatingAccountsList:!0})).value.total}async getInflationGovernor(e){const t=this._buildArgs([],e),r=Ci(await this._rpcRequest("getInflationGovernor",t),Pa);if("error"in r)throw new qs(r.error,"failed to get inflation");return r.result}async getInflationReward(e,t,r){const{commitment:n,config:i}=fa(r),o=this._buildArgs([e.map((e=>e.toBase58()))],n,void 0,{...i,epoch:null!=t?t:i?.epoch}),s=Ci(await this._rpcRequest("getInflationReward",o),_a);if("error"in s)throw new qs(s.error,"failed to get inflation reward");return s.result}async getInflationRate(){const e=Ci(await this._rpcRequest("getInflationRate",[]),Na);if("error"in e)throw new qs(e.error,"failed to get inflation rate");return e.result}async getEpochInfo(e){const{commitment:t,config:r}=fa(e),n=this._buildArgs([],t,void 0,r),i=Ci(await this._rpcRequest("getEpochInfo",n),ja);if("error"in i)throw new qs(i.error,"failed to get epoch info");return i.result}async getEpochSchedule(){const e=Ci(await this._rpcRequest("getEpochSchedule",[]),$a);if("error"in e)throw new qs(e.error,"failed to get epoch schedule");const t=e.result;return new na(t.slotsPerEpoch,t.leaderScheduleSlotOffset,t.warmup,t.firstNormalEpoch,t.firstNormalSlot)}async getLeaderSchedule(){const e=Ci(await this._rpcRequest("getLeaderSchedule",[]),Ha);if("error"in e)throw new qs(e.error,"failed to get leader schedule");return e.result}async getMinimumBalanceForRentExemption(e,t){const r=this._buildArgs([e],t),n=Ci(await this._rpcRequest("getMinimumBalanceForRentExemption",r),wc);return"error"in n?(console.warn("Unable to fetch minimum balance for rent exemption"),0):n.result}async getRecentBlockhashAndContext(e){const t=this._buildArgs([],e),r=Ci(await this._rpcRequest("getRecentBlockhash",t),Fc);if("error"in r)throw new qs(r.error,"failed to get recent blockhash");return r.result}async getRecentPerformanceSamples(e){const t=Ci(await this._rpcRequest("getRecentPerformanceSamples",e?[e]:[]),Wc);if("error"in t)throw new qs(t.error,"failed to get recent performance samples");return t.result}async getFeeCalculatorForBlockhash(e,t){const r=this._buildArgs([e],t),n=Ci(await this._rpcRequest("getFeeCalculatorForBlockhash",r),Vc);if("error"in n)throw new qs(n.error,"failed to get fee calculator");const{context:i,value:o}=n.result;return{context:i,value:null!==o?o.feeCalculator:null}}async getFeeForMessage(e,t){const r=ds(e.serialize()).toString("base64"),n=this._buildArgs([r],t),i=Ci(await this._rpcRequest("getFeeForMessage",n),ma(Di(Fi())));if("error"in i)throw new qs(i.error,"failed to get fee for message");if(null===i.result)throw new Error("invalid blockhash");return i.result}async getRecentPrioritizationFees(e){const t=e?.lockedWritableAccounts?.map((e=>e.toBase58())),r=t?.length?[t]:[],n=Ci(await this._rpcRequest("getRecentPrioritizationFees",r),Ua);if("error"in n)throw new qs(n.error,"failed to get recent prioritization fees");return n.result}async getRecentBlockhash(e){try{return(await this.getRecentBlockhashAndContext(e)).value}catch(e){throw new Error("failed to get recent blockhash: "+e)}}async getLatestBlockhash(e){try{return(await this.getLatestBlockhashAndContext(e)).value}catch(e){throw new Error("failed to get recent blockhash: "+e)}}async getLatestBlockhashAndContext(e){const{commitment:t,config:r}=fa(e),n=this._buildArgs([],t,void 0,r),i=Ci(await this._rpcRequest("getLatestBlockhash",n),qc);if("error"in i)throw new qs(i.error,"failed to get latest blockhash");return i.result}async isBlockhashValid(e,t){const{commitment:r,config:n}=fa(t),i=this._buildArgs([e],r,void 0,n),o=Ci(await this._rpcRequest("isBlockhashValid",i),Kc);if("error"in o)throw new qs(o.error,"failed to determine if the blockhash `"+e+"`is valid");return o.result}async getVersion(){const e=Ci(await this._rpcRequest("getVersion",[]),ya(Ra));if("error"in e)throw new qs(e.error,"failed to get version");return e.result}async getGenesisHash(){const e=Ci(await this._rpcRequest("getGenesisHash",[]),ya(Wi()));if("error"in e)throw new qs(e.error,"failed to get genesis hash");return e.result}async getBlock(e,t){const{commitment:r,config:n}=fa(t),i=this._buildArgsAtLeastConfirmed([e],r,void 0,n),o=await this._rpcRequest("getBlock",i);try{switch(n?.transactionDetails){case"accounts":{const e=Ci(o,Pc);if("error"in e)throw e.error;return e.result}case"none":{const e=Ci(o,Cc);if("error"in e)throw e.error;return e.result}default:{const e=Ci(o,Mc);if("error"in e)throw e.error;const{result:t}=e;return t?{...t,transactions:t.transactions.map((({transaction:e,meta:t,version:r})=>({meta:t,transaction:{...e,message:ba(r,e.message)},version:r})))}:null}}}catch(e){throw new qs(e,"failed to get confirmed block")}}async getParsedBlock(e,t){const{commitment:r,config:n}=fa(t),i=this._buildArgsAtLeastConfirmed([e],r,"jsonParsed",n),o=await this._rpcRequest("getBlock",i);try{switch(n?.transactionDetails){case"accounts":{const e=Ci(o,Uc);if("error"in e)throw e.error;return e.result}case"none":{const e=Ci(o,jc);if("error"in e)throw e.error;return e.result}default:{const e=Ci(o,Nc);if("error"in e)throw e.error;return e.result}}}catch(e){throw new qs(e,"failed to get block")}}async getBlockProduction(e){let t,r;if("string"==typeof e)r=e;else if(e){const{commitment:n,...i}=e;r=n,t=i}const n=this._buildArgs([],r,"base64",t),i=Ci(await this._rpcRequest("getBlockProduction",n),Ca);if("error"in i)throw new qs(i.error,"failed to get block production information");return i.result}async getTransaction(e,t){const{commitment:r,config:n}=fa(t),i=this._buildArgsAtLeastConfirmed([e],r,void 0,n),o=Ci(await this._rpcRequest("getTransaction",i),zc);if("error"in o)throw new qs(o.error,"failed to get transaction");const s=o.result;return s?{...s,transaction:{...s.transaction,message:ba(s.version,s.transaction.message)}}:s}async getParsedTransaction(e,t){const{commitment:r,config:n}=fa(t),i=this._buildArgsAtLeastConfirmed([e],r,"jsonParsed",n),o=Ci(await this._rpcRequest("getTransaction",i),Dc);if("error"in o)throw new qs(o.error,"failed to get transaction");return o.result}async getParsedTransactions(e,t){const{commitment:r,config:n}=fa(t),i=e.map((e=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([e],r,"jsonParsed",n)})));return(await this._rpcBatchRequest(i)).map((e=>{const t=Ci(e,Dc);if("error"in t)throw new qs(t.error,"failed to get transactions");return t.result}))}async getTransactions(e,t){const{commitment:r,config:n}=fa(t),i=e.map((e=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([e],r,void 0,n)})));return(await this._rpcBatchRequest(i)).map((e=>{const t=Ci(e,zc);if("error"in t)throw new qs(t.error,"failed to get transactions");const r=t.result;return r?{...r,transaction:{...r.transaction,message:ba(r.version,r.transaction.message)}}:r}))}async getConfirmedBlock(e,t){const r=this._buildArgsAtLeastConfirmed([e],t),n=Ci(await this._rpcRequest("getConfirmedBlock",r),$c);if("error"in n)throw new qs(n.error,"failed to get confirmed block");const i=n.result;if(!i)throw new Error("Confirmed block "+e+" not found");const o={...i,transactions:i.transactions.map((({transaction:e,meta:t})=>{const r=new Ps(e.message);return{meta:t,transaction:{...e,message:r}}}))};return{...o,transactions:o.transactions.map((({transaction:e,meta:t})=>({meta:t,transaction:zs.populate(e.message,e.signatures)})))}}async getBlocks(e,t,r){const n=this._buildArgsAtLeastConfirmed(void 0!==t?[e,t]:[e],r),i=Ci(await this._rpcRequest("getBlocks",n),ya(ji(Fi())));if("error"in i)throw new qs(i.error,"failed to get blocks");return i.result}async getBlockSignatures(e,t){const r=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:"signatures",rewards:!1}),n=Ci(await this._rpcRequest("getBlock",r),Hc);if("error"in n)throw new qs(n.error,"failed to get block");const i=n.result;if(!i)throw new Error("Block "+e+" not found");return i}async getConfirmedBlockSignatures(e,t){const r=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:"signatures",rewards:!1}),n=Ci(await this._rpcRequest("getConfirmedBlock",r),Hc);if("error"in n)throw new qs(n.error,"failed to get confirmed block");const i=n.result;if(!i)throw new Error("Confirmed block "+e+" not found");return i}async getConfirmedTransaction(e,t){const r=this._buildArgsAtLeastConfirmed([e],t),n=Ci(await this._rpcRequest("getConfirmedTransaction",r),zc);if("error"in n)throw new qs(n.error,"failed to get transaction");const i=n.result;if(!i)return i;const o=new Ps(i.transaction.message),s=i.transaction.signatures;return{...i,transaction:zs.populate(o,s)}}async getParsedConfirmedTransaction(e,t){const r=this._buildArgsAtLeastConfirmed([e],t,"jsonParsed"),n=Ci(await this._rpcRequest("getConfirmedTransaction",r),Dc);if("error"in n)throw new qs(n.error,"failed to get confirmed transaction");return n.result}async getParsedConfirmedTransactions(e,t){const r=e.map((e=>({methodName:"getConfirmedTransaction",args:this._buildArgsAtLeastConfirmed([e],t,"jsonParsed")})));return(await this._rpcBatchRequest(r)).map((e=>{const t=Ci(e,Dc);if("error"in t)throw new qs(t.error,"failed to get confirmed transactions");return t.result}))}async getConfirmedSignaturesForAddress(e,t,r){let n={},i=await this.getFirstAvailableBlock();for(;!("until"in n)&&!(--t<=0||t0&&(n.until=e.signatures[e.signatures.length-1].toString())}catch(e){if(e instanceof Error&&e.message.includes("skipped"))continue;throw e}let o=await this.getSlot("finalized");for(;!("before"in n||++r>o);)try{const e=await this.getConfirmedBlockSignatures(r);e.signatures.length>0&&(n.before=e.signatures[e.signatures.length-1].toString())}catch(e){if(e instanceof Error&&e.message.includes("skipped"))continue;throw e}return(await this.getConfirmedSignaturesForAddress2(e,n)).map((e=>e.signature))}async getConfirmedSignaturesForAddress2(e,t,r){const n=this._buildArgsAtLeastConfirmed([e.toBase58()],r,void 0,t),i=Ci(await this._rpcRequest("getConfirmedSignaturesForAddress2",n),tc);if("error"in i)throw new qs(i.error,"failed to get confirmed signatures for address");return i.result}async getSignaturesForAddress(e,t,r){const n=this._buildArgsAtLeastConfirmed([e.toBase58()],r,void 0,t),i=Ci(await this._rpcRequest("getSignaturesForAddress",n),rc);if("error"in i)throw new qs(i.error,"failed to get signatures for address");return i.result}async getAddressLookupTable(e,t){const{context:r,value:n}=await this.getAccountInfoAndContext(e,t);let i=null;return null!==n&&(i=new sa({key:e,state:sa.deserialize(n.data)})),{context:r,value:i}}async getNonceAndContext(e,t){const{context:r,value:n}=await this.getAccountInfoAndContext(e,t);let i=null;return null!==n&&(i=Zs.fromAccountData(n.data)),{context:r,value:i}}async getNonce(e,t){return await this.getNonceAndContext(e,t).then((e=>e.value)).catch((t=>{throw new Error("failed to get nonce for account "+e.toBase58()+": "+t)}))}async requestAirdrop(e,t){const r=Ci(await this._rpcRequest("requestAirdrop",[e.toBase58(),t]),Zc);if("error"in r)throw new qs(r.error,`airdrop to ${e.toBase58()} failed`);return r.result}async _blockhashWithExpiryBlockHeight(e){if(!e){for(;this._pollingBlockhash;)await Ks(100);const e=Date.now()-this._blockhashInfo.lastFetch>=3e4;if(null!==this._blockhashInfo.latestBlockhash&&!e)return this._blockhashInfo.latestBlockhash}return await this._pollNewBlockhash()}async _pollNewBlockhash(){this._pollingBlockhash=!0;try{const e=Date.now(),t=this._blockhashInfo.latestBlockhash,r=t?t.blockhash:null;for(let e=0;e<50;e++){const e=await this.getLatestBlockhash("finalized");if(r!==e.blockhash)return this._blockhashInfo={latestBlockhash:e,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},e;await Ks(200)}throw new Error(`Unable to obtain a new blockhash after ${Date.now()-e}ms`)}finally{this._pollingBlockhash=!1}}async getStakeMinimumDelegation(e){const{commitment:t,config:r}=fa(e),n=this._buildArgs([],t,"base64",r),i=Ci(await this._rpcRequest("getStakeMinimumDelegation",n),ma(Fi()));if("error"in i)throw new qs(i.error,"failed to get stake minimum delegation");return i.result}async simulateTransaction(e,t,r){if("message"in e){const n=e.serialize(),i=C.from(n).toString("base64");if(Array.isArray(t)||void 0!==r)throw new Error("Invalid arguments");const o=t||{};o.encoding="base64","commitment"in o||(o.commitment=this.commitment),t&&"object"==typeof t&&"innerInstructions"in t&&(o.innerInstructions=t.innerInstructions);const s=[i,o],a=Ci(await this._rpcRequest("simulateTransaction",s),Ma);if("error"in a)throw new Error("failed to simulate transaction: "+a.error.message);return a.result}let n;if(e instanceof zs){let t=e;n=new zs,n.feePayer=t.feePayer,n.instructions=e.instructions,n.nonceInfo=t.nonceInfo,n.signatures=t.signatures}else n=zs.populate(e),n._message=n._json=void 0;if(void 0!==t&&!Array.isArray(t))throw new Error("Invalid arguments");const i=t;if(n.nonceInfo&&i)n.sign(...i);else{let e=this._disableBlockhashCaching;for(;;){const t=await this._blockhashWithExpiryBlockHeight(e);if(n.lastValidBlockHeight=t.lastValidBlockHeight,n.recentBlockhash=t.blockhash,!i)break;if(n.sign(...i),!n.signature)throw new Error("!signature");const r=n.signature.toString("base64");if(!this._blockhashInfo.simulatedSignatures.includes(r)&&!this._blockhashInfo.transactionSignatures.includes(r)){this._blockhashInfo.simulatedSignatures.push(r);break}e=!0}}const o=n._compile(),s=o.serialize(),a=n._serialize(s).toString("base64"),c={encoding:"base64",commitment:this.commitment};if(r){const e=(Array.isArray(r)?r:o.nonProgramIds()).map((e=>e.toBase58()));c.accounts={encoding:"base64",addresses:e}}i&&(c.sigVerify=!0),t&&"object"==typeof t&&"innerInstructions"in t&&(c.innerInstructions=t.innerInstructions);const u=[a,c],h=Ci(await this._rpcRequest("simulateTransaction",u),Ma);if("error"in h){let e;if("data"in h.error&&(e=h.error.data.logs,e&&Array.isArray(e))){const t="\n ",r=t+e.join(t);console.error(h.error.message,r)}throw new Fs({action:"simulate",signature:"",transactionMessage:h.error.message,logs:e})}return h.result}async sendTransaction(e,t,r){if("version"in e){if(t&&Array.isArray(t))throw new Error("Invalid arguments");const r=e.serialize();return await this.sendRawTransaction(r,t)}if(void 0===t||!Array.isArray(t))throw new Error("Invalid arguments");const n=t;if(e.nonceInfo)e.sign(...n);else{let t=this._disableBlockhashCaching;for(;;){const r=await this._blockhashWithExpiryBlockHeight(t);if(e.lastValidBlockHeight=r.lastValidBlockHeight,e.recentBlockhash=r.blockhash,e.sign(...n),!e.signature)throw new Error("!signature");const i=e.signature.toString("base64");if(!this._blockhashInfo.transactionSignatures.includes(i)){this._blockhashInfo.transactionSignatures.push(i);break}t=!0}}const i=e.serialize();return await this.sendRawTransaction(i,r)}async sendRawTransaction(e,t){const r=ds(e).toString("base64");return await this.sendEncodedTransaction(r,t)}async sendEncodedTransaction(e,t){const r={encoding:"base64"},n=t&&t.skipPreflight,i=!0===n?"processed":t&&t.preflightCommitment||this.commitment;t&&null!=t.maxRetries&&(r.maxRetries=t.maxRetries),t&&null!=t.minContextSlot&&(r.minContextSlot=t.minContextSlot),n&&(r.skipPreflight=n),i&&(r.preflightCommitment=i);const o=[e,r],s=Ci(await this._rpcRequest("sendTransaction",o),Gc);if("error"in s){let e;throw"data"in s.error&&(e=s.error.data.logs),new Fs({action:n?"send":"simulate",signature:"",transactionMessage:s.error.message,logs:e})}return s.result}_wsOnOpen(){this._rpcWebSocketConnected=!0,this._rpcWebSocketHeartbeat=setInterval((()=>{(async()=>{try{await this._rpcWebSocket.notify("ping")}catch{}})()}),5e3),this._updateSubscriptions()}_wsOnError(e){this._rpcWebSocketConnected=!1,console.error("ws error:",e.message)}_wsOnClose(e){this._rpcWebSocketConnected=!1,this._rpcWebSocketGeneration=(this._rpcWebSocketGeneration+1)%Number.MAX_SAFE_INTEGER,this._rpcWebSocketIdleTimeout&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null),this._rpcWebSocketHeartbeat&&(clearInterval(this._rpcWebSocketHeartbeat),this._rpcWebSocketHeartbeat=null),1e3!==e?(this._subscriptionCallbacksByServerSubscriptionId={},Object.entries(this._subscriptionsByHash).forEach((([e,t])=>{this._setSubscription(e,{...t,state:"pending"})}))):this._updateSubscriptions()}_setSubscription(e,t){const r=this._subscriptionsByHash[e]?.state;if(this._subscriptionsByHash[e]=t,r!==t.state){const r=this._subscriptionStateChangeCallbacksByHash[e];r&&r.forEach((e=>{try{e(t.state)}catch{}}))}}_onSubscriptionStateChange(e,t){const r=this._subscriptionHashByClientSubscriptionId[e];if(null==r)return()=>{};const n=this._subscriptionStateChangeCallbacksByHash[r]||=new Set;return n.add(t),()=>{n.delete(t),0===n.size&&delete this._subscriptionStateChangeCallbacksByHash[r]}}async _updateSubscriptions(){if(0===Object.keys(this._subscriptionsByHash).length)return void(this._rpcWebSocketConnected&&(this._rpcWebSocketConnected=!1,this._rpcWebSocketIdleTimeout=setTimeout((()=>{this._rpcWebSocketIdleTimeout=null;try{this._rpcWebSocket.close()}catch(e){e instanceof Error&&console.log(`Error when closing socket connection: ${e.message}`)}}),500)));if(null!==this._rpcWebSocketIdleTimeout&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketConnected=!0),!this._rpcWebSocketConnected)return void this._rpcWebSocket.connect();const e=this._rpcWebSocketGeneration,t=()=>e===this._rpcWebSocketGeneration;await Promise.all(Object.keys(this._subscriptionsByHash).map((async e=>{const r=this._subscriptionsByHash[e];if(void 0!==r)switch(r.state){case"pending":case"unsubscribed":if(0===r.callbacks.size)return delete this._subscriptionsByHash[e],"unsubscribed"===r.state&&delete this._subscriptionCallbacksByServerSubscriptionId[r.serverSubscriptionId],void await this._updateSubscriptions();await(async()=>{const{args:n,method:i}=r;try{this._setSubscription(e,{...r,state:"subscribing"});const t=await this._rpcWebSocket.call(i,n);this._setSubscription(e,{...r,serverSubscriptionId:t,state:"subscribed"}),this._subscriptionCallbacksByServerSubscriptionId[t]=r.callbacks,await this._updateSubscriptions()}catch(o){if(console.error(`Received ${o instanceof Error?"":"JSON-RPC "}error calling \`${i}\``,{args:n,error:o}),!t())return;this._setSubscription(e,{...r,state:"pending"}),await this._updateSubscriptions()}})();break;case"subscribed":0===r.callbacks.size&&await(async()=>{const{serverSubscriptionId:n,unsubscribeMethod:i}=r;if(this._subscriptionsAutoDisposedByRpc.has(n))this._subscriptionsAutoDisposedByRpc.delete(n);else{this._setSubscription(e,{...r,state:"unsubscribing"}),this._setSubscription(e,{...r,state:"unsubscribing"});try{await this._rpcWebSocket.call(i,[n])}catch(n){if(n instanceof Error&&console.error(`${i} error:`,n.message),!t())return;return this._setSubscription(e,{...r,state:"subscribed"}),void await this._updateSubscriptions()}}this._setSubscription(e,{...r,state:"unsubscribed"}),await this._updateSubscriptions()})()}})))}_handleServerNotification(e,t){const r=this._subscriptionCallbacksByServerSubscriptionId[e];void 0!==r&&r.forEach((e=>{try{e(...t)}catch(e){console.error(e)}}))}_wsOnAccountNotification(e){const{result:t,subscription:r}=Ci(e,nc);this._handleServerNotification(r,[t.value,t.context])}_makeSubscription(e,t){const r=this._nextClientSubscriptionId++,n=ta([e.method,t]),i=this._subscriptionsByHash[n];return void 0===i?this._subscriptionsByHash[n]={...e,args:t,callbacks:new Set([e.callback]),state:"pending"}:i.callbacks.add(e.callback),this._subscriptionHashByClientSubscriptionId[r]=n,this._subscriptionDisposeFunctionsByClientSubscriptionId[r]=async()=>{delete this._subscriptionDisposeFunctionsByClientSubscriptionId[r],delete this._subscriptionHashByClientSubscriptionId[r];const t=this._subscriptionsByHash[n];Rs(void 0!==t,`Could not find a \`Subscription\` when tearing down client subscription #${r}`),t.callbacks.delete(e.callback),await this._updateSubscriptions()},this._updateSubscriptions(),r}onAccountChange(e,t,r){const{commitment:n,config:i}=fa(r),o=this._buildArgs([e.toBase58()],n||this._commitment||"finalized","base64",i);return this._makeSubscription({callback:t,method:"accountSubscribe",unsubscribeMethod:"accountUnsubscribe"},o)}async removeAccountChangeListener(e){await this._unsubscribeClientSubscription(e,"account change")}_wsOnProgramAccountNotification(e){const{result:t,subscription:r}=Ci(e,oc);this._handleServerNotification(r,[{accountId:t.value.pubkey,accountInfo:t.value.account},t.context])}onProgramAccountChange(e,t,r,n){const{commitment:i,config:o}=fa(r),s=this._buildArgs([e.toBase58()],i||this._commitment||"finalized","base64",o||(n?{filters:da(n)}:void 0));return this._makeSubscription({callback:t,method:"programSubscribe",unsubscribeMethod:"programUnsubscribe"},s)}async removeProgramAccountChangeListener(e){await this._unsubscribeClientSubscription(e,"program account change")}onLogs(e,t,r){const n=this._buildArgs(["object"==typeof e?{mentions:[e.toString()]}:e],r||this._commitment||"finalized");return this._makeSubscription({callback:t,method:"logsSubscribe",unsubscribeMethod:"logsUnsubscribe"},n)}async removeOnLogsListener(e){await this._unsubscribeClientSubscription(e,"logs")}_wsOnLogsNotification(e){const{result:t,subscription:r}=Ci(e,Yc);this._handleServerNotification(r,[t.value,t.context])}_wsOnSlotNotification(e){const{result:t,subscription:r}=Ci(e,ac);this._handleServerNotification(r,[t])}onSlotChange(e){return this._makeSubscription({callback:e,method:"slotSubscribe",unsubscribeMethod:"slotUnsubscribe"},[])}async removeSlotChangeListener(e){await this._unsubscribeClientSubscription(e,"slot change")}_wsOnSlotUpdatesNotification(e){const{result:t,subscription:r}=Ci(e,uc);this._handleServerNotification(r,[t])}onSlotUpdate(e){return this._makeSubscription({callback:e,method:"slotsUpdatesSubscribe",unsubscribeMethod:"slotsUpdatesUnsubscribe"},[])}async removeSlotUpdateListener(e){await this._unsubscribeClientSubscription(e,"slot update")}async _unsubscribeClientSubscription(e,t){const r=this._subscriptionDisposeFunctionsByClientSubscriptionId[e];r?await r():console.warn(`Ignored unsubscribe request because an active subscription with id \`${e}\` for '${t}' events could not be found.`)}_buildArgs(e,t,r,n){const i=t||this._commitment;if(i||r||n){let t={};r&&(t.encoding=r),i&&(t.commitment=i),n&&(t=Object.assign(t,n)),e.push(t)}return e}_buildArgsAtLeastConfirmed(e,t,r,n){const i=t||this._commitment;if(i&&!["confirmed","finalized"].includes(i))throw new Error("Using Connection with default commitment: `"+this._commitment+"`, but method requires at least `confirmed`");return this._buildArgs(e,t,r,n)}_wsOnSignatureNotification(e){const{result:t,subscription:r}=Ci(e,hc);"receivedSignature"!==t.value&&this._subscriptionsAutoDisposedByRpc.add(r),this._handleServerNotification(r,"receivedSignature"===t.value?[{type:"received"},t.context]:[{type:"status",result:t.value},t.context])}onSignature(e,t,r){const n=this._buildArgs([e],r||this._commitment||"finalized"),i=this._makeSubscription({callback:(e,r)=>{if("status"===e.type){t(e.result,r);try{this.removeSignatureListener(i)}catch(e){}}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},n);return i}onSignatureWithOptions(e,t,r){const{commitment:n,...i}={...r,commitment:r&&r.commitment||this._commitment||"finalized"},o=this._buildArgs([e],n,void 0,i),s=this._makeSubscription({callback:(e,r)=>{t(e,r);try{this.removeSignatureListener(s)}catch(e){}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},o);return s}async removeSignatureListener(e){await this._unsubscribeClientSubscription(e,"signature result")}_wsOnRootNotification(e){const{result:t,subscription:r}=Ci(e,lc);this._handleServerNotification(r,[t])}onRootChange(e){return this._makeSubscription({callback:e,method:"rootSubscribe",unsubscribeMethod:"rootUnsubscribe"},[])}async removeRootChangeListener(e){await this._unsubscribeClientSubscription(e,"root change")}}var eu;Object.freeze({CreateLookupTable:{index:0,layout:bi([yi("instruction"),Gs("recentSlot"),pi("bumpSeed")])},FreezeLookupTable:{index:1,layout:bi([yi("instruction")])},ExtendLookupTable:{index:2,layout:bi([yi("instruction"),Gs(),vi(xs(),di(yi(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:bi([yi("instruction")])},CloseLookupTable:{index:4,layout:bi([yi("instruction")])}}),new bs("AddressLookupTab1e1111111111111111111111111"),Object.freeze({RequestUnits:{index:0,layout:bi([pi("instruction"),yi("units"),yi("additionalFee")])},RequestHeapFrame:{index:1,layout:bi([pi("instruction"),yi("bytes")])},SetComputeUnitLimit:{index:2,layout:bi([pi("instruction"),yi("units")])},SetComputeUnitPrice:{index:3,layout:bi([pi("instruction"),Gs("microLamports")])}}),new bs("ComputeBudget111111111111111111111111111111"),bi([pi("numSignatures"),pi("padding"),gi("signatureOffset"),gi("signatureInstructionIndex"),gi("publicKeyOffset"),gi("publicKeyInstructionIndex"),gi("messageDataOffset"),gi("messageDataSize"),gi("messageInstructionIndex")]),new bs("Ed25519SigVerify111111111111111111111111111"),us.utils.isValidPrivateKey,us.getPublicKey,bi([pi("numSignatures"),gi("signatureOffset"),pi("signatureInstructionIndex"),gi("ethAddressOffset"),pi("ethAddressInstructionIndex"),gi("messageDataOffset"),gi("messageDataSize"),pi("messageInstructionIndex"),_i(20,"ethAddress"),_i(64,"signature"),pi("recoveryId")]),new bs("KeccakSecp256k11111111111111111111111111111"),new bs("StakeConfig11111111111111111111111111111111");class tu{constructor(e,t,r){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=e,this.epoch=t,this.custodian=r}}eu=tu,tu.default=new eu(0,0,bs.default),Object.freeze({Initialize:{index:0,layout:bi([yi("instruction"),((e="authorized")=>bi([xs("staker"),xs("withdrawer")],e))(),((e="lockup")=>bi([wi("unixTimestamp"),wi("epoch"),xs("custodian")],e))()])},Authorize:{index:1,layout:bi([yi("instruction"),xs("newAuthorized"),yi("stakeAuthorizationType")])},Delegate:{index:2,layout:bi([yi("instruction")])},Split:{index:3,layout:bi([yi("instruction"),wi("lamports")])},Withdraw:{index:4,layout:bi([yi("instruction"),wi("lamports")])},Deactivate:{index:5,layout:bi([yi("instruction")])},Merge:{index:7,layout:bi([yi("instruction")])},AuthorizeWithSeed:{index:8,layout:bi([yi("instruction"),xs("newAuthorized"),yi("stakeAuthorizationType"),Bs("authoritySeed"),xs("authorityOwner")])}}),Object.freeze({Staker:{index:0},Withdrawer:{index:1}}),new bs("Stake11111111111111111111111111111111111111"),Object.freeze({InitializeAccount:{index:0,layout:bi([yi("instruction"),((e="voteInit")=>bi([xs("nodePubkey"),xs("authorizedVoter"),xs("authorizedWithdrawer"),pi("commission")],e))()])},Authorize:{index:1,layout:bi([yi("instruction"),xs("newAuthorized"),yi("voteAuthorizationType")])},Withdraw:{index:3,layout:bi([yi("instruction"),wi("lamports")])},UpdateValidatorIdentity:{index:4,layout:bi([yi("instruction")])},AuthorizeWithSeed:{index:10,layout:bi([yi("instruction"),((e="voteAuthorizeWithSeedArgs")=>bi([yi("voteAuthorizationType"),xs("currentAuthorityDerivedKeyOwnerPubkey"),Bs("currentAuthorityDerivedKeySeed"),xs("newAuthorized")],e))()])}}),Object.freeze({Voter:{index:0},Withdrawer:{index:1}}),new bs("Vote111111111111111111111111111111111111111"),new bs("Va1idator1nfo111111111111111111111111111111"),Zi({name:Wi(),website:qi(Wi()),details:qi(Wi()),iconUrl:qi(Wi()),keybaseUsername:qi(Wi())}),new bs("Vote111111111111111111111111111111111111111"),bi([xs("nodePubkey"),xs("authorizedWithdrawer"),pi("commission"),mi(),vi(bi([mi("slot"),yi("confirmationCount")]),di(yi(),-8),"votes"),pi("rootSlotValid"),mi("rootSlot"),mi(),vi(bi([mi("epoch"),xs("authorizedVoter")]),di(yi(),-8),"authorizedVoters"),bi([vi(bi([xs("authorizedPubkey"),mi("epochOfLastAuthorizedSwitch"),mi("targetEpoch")]),32,"buf"),mi("idx"),pi("isEmpty")],"priorVoters"),mi(),vi(bi([mi("epoch"),mi("credits"),mi("prevCredits")]),di(yi(),-8),"epochCredits"),bi([mi("slot"),mi("timestamp")],"lastTimestamp")]);const ru="solana:signAndSendTransaction",nu="solana:signIn",iu="solana:signMessage",ou="solana:signTransaction",su="standard:connect",au="standard:disconnect",cu="standard:events";var uu,hu=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};class lu extends Event{constructor(e){super("wallet-standard:register-wallet",{bubbles:!1,cancelable:!1,composed:!1}),((e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)})(this,uu,void 0),((e,t,r,n)=>{hu(e,t,"write to private field"),n?n.call(e,r):t.set(e,r)})(this,uu,e)}get detail(){return((e,t,r)=>(hu(e,t,"read from private field"),r?r.call(e):t.get(e)))(this,uu)}get type(){return"wallet-standard:register-wallet"}preventDefault(){throw new Error("preventDefault cannot be called")}stopImmediatePropagation(){throw new Error("stopImmediatePropagation cannot be called")}stopPropagation(){throw new Error("stopPropagation cannot be called")}}function fu(e){!function(e){const t=({register:t})=>t(e);try{window.dispatchEvent(new lu(t))}catch(e){console.error("wallet-standard:register-wallet event could not be dispatched\n",e)}try{window.addEventListener("wallet-standard:app-ready",(({detail:e})=>t(e)))}catch(e){console.error("wallet-standard:app-ready event listener could not be added\n",e)}}(e.getInstanceWithAdapter())}uu=new WeakMap;const du=["solana:mainnet"];function pu(e){return du.includes(e)}function gu(e){return"version"in e}var yu,mu,wu,bu,vu,_u,Eu=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Su=(e,t,r)=>(Eu(e,t,"read from private field"),r?r.call(e):t.get(e)),Au=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},xu=(e,t,r,n)=>(Eu(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);const ku=du,Bu=[ru,ou,iu],Iu=class{constructor({address:e,publicKey:t,label:r,icon:n}){Au(this,yu,void 0),Au(this,mu,void 0),Au(this,wu,void 0),Au(this,bu,void 0),Au(this,vu,void 0),Au(this,_u,void 0),new.target===Iu&&Object.freeze(this),xu(this,yu,e),xu(this,mu,t),xu(this,wu,ku),xu(this,bu,Bu),xu(this,vu,r),xu(this,_u,n)}get address(){return Su(this,yu)}get publicKey(){return Su(this,mu).slice()}get chains(){return Su(this,wu).slice()}get features(){return Su(this,bu).slice()}get label(){return Su(this,vu)}get icon(){return Su(this,_u)}};let Tu=Iu;yu=new WeakMap,mu=new WeakMap,wu=new WeakMap,bu=new WeakMap,vu=new WeakMap,_u=new WeakMap;var Ru,Ou,Lu,Mu,Cu,Pu,Nu,Uu,ju,$u,Hu,zu,Du,Fu,qu,Ku,Wu,Vu,Zu,Gu,Ju=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},Yu=(e,t,r)=>(Ju(e,t,"read from private field"),r?r.call(e):t.get(e)),Xu=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Qu=(e,t,r,n)=>(Ju(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r),eh=(e,t,r)=>(Ju(e,t,"access private method"),r);const th="trust:",rh=class{constructor(e){Xu(this,Uu),Xu(this,$u),Xu(this,Ru,{}),Xu(this,Ou,"1.0.0"),Xu(this,Lu,"Trust"),Xu(this,Mu,"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTgiIGhlaWdodD0iNjUiIHZpZXdCb3g9IjAgMCA1OCA2NSIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTAgOS4zODk0OUwyOC44OTA3IDBWNjUuMDA0MkM4LjI1NDUgNTYuMzM2OSAwIDM5LjcyNDggMCAzMC4zMzUzVjkuMzg5NDlaIiBmaWxsPSIjMDUwMEZGIi8+CjxwYXRoIGQ9Ik01Ny43ODIyIDkuMzg5NDlMMjguODkxNSAwVjY1LjAwNDJDNDkuNTI3NyA1Ni4zMzY5IDU3Ljc4MjIgMzkuNzI0OCA1Ny43ODIyIDMwLjMzNTNWOS4zODk0OVoiIGZpbGw9InVybCgjcGFpbnQwX2xpbmVhcl8yMjAxXzY5NDIpIi8+CjxkZWZzPgo8bGluZWFyR3JhZGllbnQgaWQ9InBhaW50MF9saW5lYXJfMjIwMV82OTQyIiB4MT0iNTEuMzYxNSIgeTE9Ii00LjE1MjkzIiB4Mj0iMjkuNTM4NCIgeTI9IjY0LjUxNDciIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIj4KPHN0b3Agb2Zmc2V0PSIwLjAyMTEyIiBzdG9wLWNvbG9yPSIjMDAwMEZGIi8+CjxzdG9wIG9mZnNldD0iMC4wNzYyNDIzIiBzdG9wLWNvbG9yPSIjMDA5NEZGIi8+CjxzdG9wIG9mZnNldD0iMC4xNjMwODkiIHN0b3AtY29sb3I9IiM0OEZGOTEiLz4KPHN0b3Agb2Zmc2V0PSIwLjQyMDA0OSIgc3RvcC1jb2xvcj0iIzAwOTRGRiIvPgo8c3RvcCBvZmZzZXQ9IjAuNjgyODg2IiBzdG9wLWNvbG9yPSIjMDAzOEZGIi8+CjxzdG9wIG9mZnNldD0iMC45MDI0NjUiIHN0b3AtY29sb3I9IiMwNTAwRkYiLz4KPC9saW5lYXJHcmFkaWVudD4KPC9kZWZzPgo8L3N2Zz4K"),Xu(this,Cu,null),Xu(this,Pu,void 0),Xu(this,Nu,((e,t)=>{var r;return null!=(r=Yu(this,Ru)[e])&&r.push(t)||(Yu(this,Ru)[e]=[t]),()=>eh(this,$u,Hu).call(this,e,t)})),Xu(this,zu,(()=>{var e;const t=null==(e=Yu(this,Pu).publicKey)?void 0:e.toBase58();if(t){const e=Yu(this,Pu).publicKey.toBytes(),r=Yu(this,Cu);(!r||r.address!==t||!function(e,t){return function(e,t){if(e===t)return!0;const r=e.length;if(r!==t.length)return!1;for(let n=0;n{Yu(this,Cu)&&(Qu(this,Cu,null),eh(this,Uu,ju).call(this,"change",{accounts:this.accounts}))})),Xu(this,Fu,(()=>{Yu(this,Pu).publicKey?Yu(this,zu).call(this):Yu(this,Du).call(this)})),Xu(this,qu,(async({silent:e}={})=>(Yu(this,Cu)||await Yu(this,Pu).connect(e?{onlyIfTrusted:!0}:void 0),Yu(this,zu).call(this),{accounts:this.accounts}))),Xu(this,Ku,(async()=>{await Yu(this,Pu).disconnect()})),Xu(this,Wu,(async(...e)=>{if(!Yu(this,Cu))throw new Error("not connected");const t=[];if(1===e.length){const{transaction:r,account:n,chain:i,options:o}=e[0],{minContextSlot:s,preflightCommitment:a,skipPreflight:c,maxRetries:u}=o||{};if(n!==Yu(this,Cu))throw new Error("invalid account");if(!pu(i))throw new Error("invalid chain");const{signature:h}=await Yu(this,Pu).signAndSendTransaction(Ds.deserialize(r),{preflightCommitment:a,minContextSlot:s,maxRetries:u,skipPreflight:c});t.push({signature:new Uint8Array(Dr.decode(h))})}else if(e.length>1)for(const r of e)t.push(...await Yu(this,Wu).call(this,r));return t})),Xu(this,Vu,(async(...e)=>{if(!Yu(this,Cu))throw new Error("not connected");const t=[];if(1===e.length){const{transaction:r,account:n,chain:i}=e[0];if(n!==Yu(this,Cu))throw new Error("invalid account");if(i&&!pu(i))throw new Error("invalid chain");const o=await Yu(this,Pu).signTransaction(Ds.deserialize(r)),s=gu(o)?o.serialize():new Uint8Array(o.serialize({requireAllSignatures:!1,verifySignatures:!1}));t.push({signedTransaction:s})}else if(e.length>1){let r;for(const t of e){if(t.account!==Yu(this,Cu))throw new Error("invalid account");if(t.chain){if(!pu(t.chain))throw new Error("invalid chain");if(r){if(t.chain!==r)throw new Error("conflicting chain")}else r=t.chain}}const n=e.map((({transaction:e})=>Ds.deserialize(e))),i=await Yu(this,Pu).signAllTransactions(n);t.push(...i.map((e=>({signedTransaction:gu(e)?e.serialize():new Uint8Array(e.serialize({requireAllSignatures:!1,verifySignatures:!1}))}))))}return t})),Xu(this,Zu,(async(...e)=>{if(!Yu(this,Cu))throw new Error("not connected");const t=[];if(1===e.length){const{message:r,account:n}=e[0];if(n!==Yu(this,Cu))throw new Error("invalid account");const{signature:i}=await Yu(this,Pu).signMessage(r);t.push({signedMessage:r,signature:i})}else if(e.length>1)for(const r of e)t.push(...await Yu(this,Zu).call(this,r));return t})),Xu(this,Gu,(async(...e)=>{const t=[];if(!(e.length>1))return[await Yu(this,Pu).signIn(e[0])];for(const r of e)t.push(await Yu(this,Pu).signIn(r));return t})),new.target===rh&&Object.freeze(this),Qu(this,Pu,e),e.on("connect",Yu(this,zu),this),e.on("disconnect",Yu(this,Du),this),e.on("accountChanged",Yu(this,Fu),this),Yu(this,zu).call(this)}get version(){return Yu(this,Ou)}get name(){return Yu(this,Lu)}get icon(){return Yu(this,Mu)}get chains(){return du.slice()}get features(){return{[su]:{version:"1.0.0",connect:Yu(this,qu)},[au]:{version:"1.0.0",disconnect:Yu(this,Ku)},[cu]:{version:"1.0.0",on:Yu(this,Nu)},[ru]:{version:"1.0.0",supportedTransactionVersions:["legacy",0],signAndSendTransaction:Yu(this,Wu)},[ou]:{version:"1.0.0",supportedTransactionVersions:["legacy",0],signTransaction:Yu(this,Vu)},[iu]:{version:"1.0.0",signMessage:Yu(this,Zu)},[nu]:{version:"1.0.0",signIn:Yu(this,Gu)},[th]:{trust:Yu(this,Pu)}}}get accounts(){return Yu(this,Cu)?[Yu(this,Cu)]:[]}};let nh=rh;Ru=new WeakMap,Ou=new WeakMap,Lu=new WeakMap,Mu=new WeakMap,Cu=new WeakMap,Pu=new WeakMap,Nu=new WeakMap,Uu=new WeakSet,ju=function(e,...t){var r;null==(r=Yu(this,Ru)[e])||r.forEach((e=>e.apply(null,t)))},$u=new WeakSet,Hu=function(e,t){var r;Yu(this,Ru)[e]=null==(r=Yu(this,Ru)[e])?void 0:r.filter((e=>t!==e))},zu=new WeakMap,Du=new WeakMap,Fu=new WeakMap,qu=new WeakMap,Ku=new WeakMap,Wu=new WeakMap,Vu=new WeakMap,Zu=new WeakMap,Gu=new WeakMap;class ih{constructor(e,t=!1){this.useLegacySign=!1,this.provider=e,this.useLegacySign=t}async connect(e){const t=await this.provider.internalRequest({method:"requestAccounts",params:{options:e}});return this.provider.emit("connect"),{publicKey:new bs(t[0])}}async signTransaction(e){if(this.useLegacySign)return await this.legacySign(e);const t=JSON.stringify(e);let r,n="legacy";gu(e)?(n=e.version,r=C.from(e.message.serialize()).toString("base64")):r=C.from(e.serializeMessage()).toString("base64");const i=C.from(e.serialize({requireAllSignatures:!1,verifySignatures:!1})).toString("base64"),o=await this.provider.internalRequest({method:"signRawTransaction",params:{data:t,raw:i,rawMessage:r,version:n}});return this.provider.mapSignedTransaction(e,o)}async legacySign(e){const t=JSON.stringify(e),r="number"!=typeof e.version?"legacy":e.version,n=Dr.encode("legacy"===r?e.serializeMessage():0===r?e.message.serialize():e.serialize());try{const i=await this.provider.internalRequest({method:"signRawTransaction",params:{data:t,raw:n,version:r}});return this.provider.mapSignedTransaction(e,i)}catch(e){console.log(`<== Error: ${e}`)}}async request(e,t){var r;switch(e.method){case"signTransaction":return this.signTransaction(e.params);case"connect":return this.connect(null==(r=e?.params)?void 0:r.options)}return t()}}var oh,sh,ah,ch,uh,hh=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},lh=(e,t,r)=>(hh(e,t,"read from private field"),r?r.call(e):t.get(e)),fh=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},dh=(e,t,r,n)=>(hh(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r),ph=(e,t,r)=>(hh(e,t,"access private method"),r);const gh=class extends He{constructor(e){super(),fh(this,ch),fh(this,oh,!1),fh(this,sh,!0),this.isTrust=!0,this.isTrustWallet=!0,fh(this,ah,!1),e&&(typeof e.enableAdapter<"u"&&dh(this,sh,e.enableAdapter),typeof e.cluster<"u"&&(this.connection=new Qc(e.cluster,"confirmed")),typeof e.disableMobileAdapter<"u"&&dh(this,oh,e.disableMobileAdapter),typeof e.useLegacySign<"u"&&dh(this,ah,e.useLegacySign),typeof e.isTrust<"u"&&(this.isTrust=e.isTrust,this.isTrustWallet=e.isTrust)),lh(this,sh)&&fu(this),lh(this,oh)||(this.mobileAdapter=new ih(this,lh(this,ah)))}static bufferToHex(e){return"0x"+C.from(e).toString("hex")}static messageToBuffer(e){let t=C.from([]);try{t="string"==typeof e?C.from(e.replace("0x",""),"hex"):C.from(e)}catch(e){console.log(`messageToBuffer error: ${e}`)}return t}getInstanceWithAdapter(){return new nh(this)}async connect(e){const t=await ph(this,ch,uh).call(this,{method:"connect",params:{options:e}});return this.publicKey=t.publicKey,t}disconnect(){return new Promise((e=>{this.publicKey=null,this.emit("disconnect"),e()}))}async signAndSendTransaction(e,t){const r=await this.signTransaction(e);return{signature:await this.connection.sendRawTransaction(r.serialize(),t)}}signTransaction(e){return ph(this,ch,uh).call(this,{method:"signTransaction",params:e})}signAllTransactions(e){return Promise.all(e.map((e=>this.signTransaction(e))))}async signRawTransactionMulti(e){return(await ph(this,ch,uh).call(this,{method:"signRawTransactionMulti",params:{transactions:e.map((e=>{const t=JSON.stringify(e);let r,n="legacy";gu(e)?(n=e.version,r=C.from(e.message.serialize()).toString("base64")):r=C.from(e.serializeMessage()).toString("base64");return{data:t,raw:C.from(e.serialize({requireAllSignatures:!1,verifySignatures:!1})).toString("base64"),rawMessage:r,version:n}}))}})).map(((t,r)=>this.mapSignedTransaction(e[r],t)))}async signMessage(e){var t;const r=gh.bufferToHex(e),n=await ph(this,ch,uh).call(this,{method:"signMessage",params:{data:r}});return{signature:new Uint8Array(C.from(gh.messageToBuffer(n).buffer)),publicKey:null==(t=this.publicKey)?void 0:t.toBase58()}}signIn(e){throw new Error("Method not implemented.")}getNetwork(){return gh.NETWORK}mapSignedTransaction(e,t){return e.addSignature(this.publicKey,Dr.decode(t)),e}request(e){throw new Error("Not implemented")}internalRequest(e){return super.request(e)}};let yh=gh;oh=new WeakMap,sh=new WeakMap,ah=new WeakMap,ch=new WeakSet,uh=function(e){const t=()=>this.internalRequest(e);return this.mobileAdapter?this.mobileAdapter.request(e,t):t()},yh.NETWORK="solana";var mh={},wh={},bh={},vh={},_h={},Eh={},Sh={},Ah={},xh={};function kh(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function Bh(e){if("boolean"!=typeof e)throw new Error(`Expected boolean, not ${e}`)}function Ih(e,...t){if(!function(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}(e))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}function Th(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");kh(e.outputLen),kh(e.blockLen)}function Rh(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Oh(e,t){Ih(e);const r=t.outputLen;if(e.lengthnew Uint8Array(e.buffer,e.byteOffset,e.byteLength);function r(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}e.u32=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));e.createView=e=>new DataView(e.buffer,e.byteOffset,e.byteLength);if(e.rotr=(e,t)=>e<<32-t|e>>>t,e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],!e.isLE)throw new Error("Non little-endian hardware is not supported");const n=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));e.bytesToHex=function(e){if(!r(e))throw new Error("Uint8Array expected");let t="";for(let r=0;r=i&&e<=o?e-i:e>=s&&e<=a?e-(s-10):e>=c&&e<=u?e-(c-10):void 0}e.hexToBytes=function(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,r=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(r);for(let t=0,i=0;t{},e.asyncLoop=async function(t,r,n){let i=Date.now();for(let o=0;o=0&&te().update(f(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t},e.wrapConstructorWithOpts=function(e){const t=(t,r)=>e(r).update(f(t)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=t=>e(t),t},e.wrapXOFConstructorWithOpts=function(e){const t=(t,r)=>e(r).update(f(t)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=t=>e(t),t},e.randomBytes=function(e=32){if(t.crypto&&"function"==typeof t.crypto.getRandomValues)return t.crypto.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}}(Rl),Object.defineProperty(_l,"__esModule",{value:!0}),_l.SHA2=void 0;const Ml=El,Ll=Rl;_l.SHA2=class extends Ll.Hash{constructor(e,t,r,n){super(),this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=(0,Ll.createView)(this.buffer)}update(e){(0,Ml.exists)(this);const{view:t,buffer:r,blockLen:n}=this,i=(e=(0,Ll.toBytes)(e)).length;for(let o=0;on-o&&(this.process(r,0),o=0);for(let e=o;e>i&o),a=Number(r&o),c=n?4:0,u=n?0:4;e.setUint32(t+c,s,n),e.setUint32(t+u,a,n)}(r,n-8,BigInt(8*this.length),i),this.process(r,0);const s=(0,Ll.createView)(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,u=this.get();if(c>u.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;ee&t^~e&r,Ul=(e,t,r)=>e&t^e&r^t&r,jl=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),$l=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),zl=new Uint32Array(64);class Dl extends Cl.SHA2{constructor(){super(64,32,8,!1),this.A=0|$l[0],this.B=0|$l[1],this.C=0|$l[2],this.D=0|$l[3],this.E=0|$l[4],this.F=0|$l[5],this.G=0|$l[6],this.H=0|$l[7]}get(){const{A:e,B:t,C:r,D:n,E:i,F:o,G:s,H:a}=this;return[e,t,r,n,i,o,s,a]}set(e,t,r,n,i,o,s,a){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(e,t){for(let r=0;r<16;r++,t+=4)zl[r]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=zl[e-15],r=zl[e-2],n=(0,Pl.rotr)(t,7)^(0,Pl.rotr)(t,18)^t>>>3,i=(0,Pl.rotr)(r,17)^(0,Pl.rotr)(r,19)^r>>>10;zl[e]=i+zl[e-7]+n+zl[e-16]|0}let{A:r,B:n,C:i,D:o,E:s,F:a,G:c,H:u}=this;for(let e=0;e<64;e++){const t=u+((0,Pl.rotr)(s,6)^(0,Pl.rotr)(s,11)^(0,Pl.rotr)(s,25))+Nl(s,a,c)+jl[e]+zl[e]|0,l=((0,Pl.rotr)(r,2)^(0,Pl.rotr)(r,13)^(0,Pl.rotr)(r,22))+Ul(r,n,i)|0;u=c,c=a,a=s,s=o+t|0,o=i,i=n,n=r,r=t+l|0}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(r,n,i,o,s,a,c,u)}roundClean(){zl.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class Hl extends Dl{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}vl.sha256=(0,Pl.wrapConstructor)((()=>new Dl)),vl.sha224=(0,Pl.wrapConstructor)((()=>new Hl));var ql={},Fl={};Object.defineProperty(Fl,"__esModule",{value:!0}),Fl.validateObject=Fl.createHmacDrbg=Fl.bitMask=Fl.bitSet=Fl.bitGet=Fl.bitLen=Fl.utf8ToBytes=Fl.equalBytes=Fl.concatBytes=Fl.ensureBytes=Fl.numberToVarBytesBE=Fl.numberToBytesLE=Fl.numberToBytesBE=Fl.bytesToNumberLE=Fl.bytesToNumberBE=Fl.hexToBytes=Fl.hexToNumber=Fl.numberToHexUnpadded=Fl.bytesToHex=Fl.isBytes=void 0; +Object.defineProperty(e,"__esModule",{value:!0}),e.randomBytes=e.wrapXOFConstructorWithOpts=e.wrapConstructorWithOpts=e.wrapConstructor=e.checkOpts=e.Hash=e.concatBytes=e.toBytes=e.utf8ToBytes=e.asyncLoop=e.nextTick=e.hexToBytes=e.bytesToHex=e.isLE=e.rotr=e.createView=e.u32=e.u8=void 0;const t=Ch;e.u8=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength);function r(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}e.u32=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));e.createView=e=>new DataView(e.buffer,e.byteOffset,e.byteLength);if(e.rotr=(e,t)=>e<<32-t|e>>>t,e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],!e.isLE)throw new Error("Non little-endian hardware is not supported");const n=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));e.bytesToHex=function(e){if(!r(e))throw new Error("Uint8Array expected");let t="";for(let r=0;r=i&&e<=o?e-i:e>=s&&e<=a?e-(s-10):e>=c&&e<=u?e-(c-10):void 0}e.hexToBytes=function(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,r=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(r);for(let t=0,i=0;t{},e.asyncLoop=async function(t,r,n){let i=Date.now();for(let o=0;o=0&&te().update(f(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t},e.wrapConstructorWithOpts=function(e){const t=(t,r)=>e(r).update(f(t)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=t=>e(t),t},e.wrapXOFConstructorWithOpts=function(e){const t=(t,r)=>e(r).update(f(t)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=t=>e(t),t},e.randomBytes=function(e=32){if(t.crypto&&"function"==typeof t.crypto.getRandomValues)return t.crypto.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}}(Mh),Object.defineProperty(Ah,"__esModule",{value:!0}),Ah.SHA2=void 0;const Ph=xh,Nh=Mh;Ah.SHA2=class extends Nh.Hash{constructor(e,t,r,n){super(),this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=(0,Nh.createView)(this.buffer)}update(e){(0,Ph.exists)(this);const{view:t,buffer:r,blockLen:n}=this,i=(e=(0,Nh.toBytes)(e)).length;for(let o=0;on-o&&(this.process(r,0),o=0);for(let e=o;e>i&o),a=Number(r&o),c=n?4:0,u=n?0:4;e.setUint32(t+c,s,n),e.setUint32(t+u,a,n)}(r,n-8,BigInt(8*this.length),i),this.process(r,0);const s=(0,Nh.createView)(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,u=this.get();if(c>u.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;ee&t^~e&r,Hh=(e,t,r)=>e&t^e&r^t&r,zh=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Dh=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Fh=new Uint32Array(64);class qh extends Uh.SHA2{constructor(){super(64,32,8,!1),this.A=0|Dh[0],this.B=0|Dh[1],this.C=0|Dh[2],this.D=0|Dh[3],this.E=0|Dh[4],this.F=0|Dh[5],this.G=0|Dh[6],this.H=0|Dh[7]}get(){const{A:e,B:t,C:r,D:n,E:i,F:o,G:s,H:a}=this;return[e,t,r,n,i,o,s,a]}set(e,t,r,n,i,o,s,a){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(e,t){for(let r=0;r<16;r++,t+=4)Fh[r]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=Fh[e-15],r=Fh[e-2],n=(0,jh.rotr)(t,7)^(0,jh.rotr)(t,18)^t>>>3,i=(0,jh.rotr)(r,17)^(0,jh.rotr)(r,19)^r>>>10;Fh[e]=i+Fh[e-7]+n+Fh[e-16]|0}let{A:r,B:n,C:i,D:o,E:s,F:a,G:c,H:u}=this;for(let e=0;e<64;e++){const t=u+((0,jh.rotr)(s,6)^(0,jh.rotr)(s,11)^(0,jh.rotr)(s,25))+$h(s,a,c)+zh[e]+Fh[e]|0,h=((0,jh.rotr)(r,2)^(0,jh.rotr)(r,13)^(0,jh.rotr)(r,22))+Hh(r,n,i)|0;u=c,c=a,a=s,s=o+t|0,o=i,i=n,n=r,r=t+h|0}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(r,n,i,o,s,a,c,u)}roundClean(){Fh.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class Kh extends qh{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}Sh.sha256=(0,jh.wrapConstructor)((()=>new qh)),Sh.sha224=(0,jh.wrapConstructor)((()=>new Kh));var Wh={},Vh={};Object.defineProperty(Vh,"__esModule",{value:!0}),Vh.validateObject=Vh.createHmacDrbg=Vh.bitMask=Vh.bitSet=Vh.bitGet=Vh.bitLen=Vh.utf8ToBytes=Vh.equalBytes=Vh.concatBytes=Vh.ensureBytes=Vh.numberToVarBytesBE=Vh.numberToBytesLE=Vh.numberToBytesBE=Vh.bytesToNumberLE=Vh.bytesToNumberBE=Vh.hexToBytes=Vh.hexToNumber=Vh.numberToHexUnpadded=Vh.bytesToHex=Vh.isBytes=void 0; /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -const Kl=BigInt(0),Wl=BigInt(1),Vl=BigInt(2);function Zl(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}Fl.isBytes=Zl;const Gl=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function Jl(e){if(!Zl(e))throw new Error("Uint8Array expected");let t="";for(let r=0;r=Ql&&e<=eh?e-Ql:e>=th&&e<=rh?e-(th-10):e>=nh&&e<=ih?e-(nh-10):void 0}function sh(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,r=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(r);for(let t=0,i=0;tKl;e>>=Wl,t+=1);return t},Fl.bitGet=function(e,t){return e>>BigInt(t)&Wl};Fl.bitSet=(e,t,r)=>e|(r?Wl:Kl)<(Vl<new Uint8Array(e),lh=e=>Uint8Array.from(e);Fl.createHmacDrbg=function(e,t,r){if("number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof t||t<2)throw new Error("qByteLen must be a number");if("function"!=typeof r)throw new Error("hmacFn must be a function");let n=uh(e),i=uh(e),o=0;const s=()=>{n.fill(1),i.fill(0),o=0},a=(...e)=>r(i,n,...e),c=(e=uh())=>{i=a(lh([0]),e),n=a(),0!==e.length&&(i=a(lh([1]),e),n=a())},u=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const r=[];for(;e{let r;for(s(),c(e);!(r=t(u()));)c();return s(),r}};const hh={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||Zl(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)};Fl.validateObject=function(e,t,r={}){const n=(t,r,n)=>{const i=hh[r];if("function"!=typeof i)throw new Error(`Invalid validator "${r}", expected function`);const o=e[t];if(!(n&&void 0===o||i(o,e)))throw new Error(`Invalid param ${String(t)}=${o} (${typeof o}), expected ${r}`)};for(const[e,r]of Object.entries(t))n(e,r,!1);for(const[e,t]of Object.entries(r))n(e,t,!0);return e},Object.defineProperty(ql,"__esModule",{value:!0}),ql.mapHashToField=ql.getMinHashLength=ql.getFieldBytesLength=ql.hashToPrivateScalar=ql.FpSqrtEven=ql.FpSqrtOdd=ql.Field=ql.nLength=ql.FpIsSquare=ql.FpDiv=ql.FpInvertBatch=ql.FpPow=ql.validateField=ql.isNegativeLE=ql.FpSqrt=ql.tonelliShanks=ql.invert=ql.pow2=ql.pow=ql.mod=void 0; +const Zh=BigInt(0),Gh=BigInt(1),Jh=BigInt(2);function Yh(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}Vh.isBytes=Yh;const Xh=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function Qh(e){if(!Yh(e))throw new Error("Uint8Array expected");let t="";for(let r=0;r=rl&&e<=nl?e-rl:e>=il&&e<=ol?e-(il-10):e>=sl&&e<=al?e-(sl-10):void 0}function ul(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,r=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(r);for(let t=0,i=0;tZh;e>>=Gh,t+=1);return t},Vh.bitGet=function(e,t){return e>>BigInt(t)&Gh};Vh.bitSet=(e,t,r)=>e|(r?Gh:Zh)<(Jh<new Uint8Array(e),dl=e=>Uint8Array.from(e);Vh.createHmacDrbg=function(e,t,r){if("number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof t||t<2)throw new Error("qByteLen must be a number");if("function"!=typeof r)throw new Error("hmacFn must be a function");let n=fl(e),i=fl(e),o=0;const s=()=>{n.fill(1),i.fill(0),o=0},a=(...e)=>r(i,n,...e),c=(e=fl())=>{i=a(dl([0]),e),n=a(),0!==e.length&&(i=a(dl([1]),e),n=a())},u=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const r=[];for(;e{let r;for(s(),c(e);!(r=t(u()));)c();return s(),r}};const pl={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||Yh(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)};Vh.validateObject=function(e,t,r={}){const n=(t,r,n)=>{const i=pl[r];if("function"!=typeof i)throw new Error(`Invalid validator "${r}", expected function`);const o=e[t];if(!(n&&void 0===o||i(o,e)))throw new Error(`Invalid param ${String(t)}=${o} (${typeof o}), expected ${r}`)};for(const[e,r]of Object.entries(t))n(e,r,!1);for(const[e,t]of Object.entries(r))n(e,t,!0);return e},Object.defineProperty(Wh,"__esModule",{value:!0}),Wh.mapHashToField=Wh.getMinHashLength=Wh.getFieldBytesLength=Wh.hashToPrivateScalar=Wh.FpSqrtEven=Wh.FpSqrtOdd=Wh.Field=Wh.nLength=Wh.FpIsSquare=Wh.FpDiv=Wh.FpInvertBatch=Wh.FpPow=Wh.validateField=Wh.isNegativeLE=Wh.FpSqrt=Wh.tonelliShanks=Wh.invert=Wh.pow2=Wh.pow=Wh.mod=void 0; /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -const fh=Fl,dh=BigInt(0),ph=BigInt(1),gh=BigInt(2),yh=BigInt(3),mh=BigInt(4),wh=BigInt(5),bh=BigInt(8);function vh(e,t){const r=e%t;return r>=dh?r:t+r}function _h(e,t,r){if(r<=dh||t 0");if(r===ph)return dh;let n=ph;for(;t>dh;)t&ph&&(n=n*e%r),e=e*e%r,t>>=ph;return n}function Eh(e,t){if(e===dh||t<=dh)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let r=vh(e,t),n=t,i=dh,o=ph;for(;r!==dh;){const e=n%r,t=i-o*(n/r);n=r,r=e,i=o,o=t}if(n!==ph)throw new Error("invert: does not exist");return vh(i,t)}function Sh(e){const t=(e-ph)/gh;let r,n,i;for(r=e-ph,n=0;r%gh===dh;r/=gh,n++);for(i=gh;idh;)n*=n,n%=r;return n},ql.invert=Eh,ql.tonelliShanks=Sh,ql.FpSqrt=xh;ql.isNegativeLE=(e,t)=>(vh(e,t)&ph)===ph;const Ah=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function kh(e,t,r){if(r 0");if(r===dh)return e.ONE;if(r===ph)return t;let n=e.ONE,i=t;for(;r>dh;)r&ph&&(n=e.mul(n,i)),i=e.sqr(i),r>>=ph;return n}function Ih(e,t){const r=new Array(t.length),n=t.reduce(((t,n,i)=>e.is0(n)?t:(r[i]=t,e.mul(t,n))),e.ONE),i=e.inv(n);return t.reduceRight(((t,n,i)=>e.is0(n)?t:(r[i]=e.mul(t,r[i]),e.mul(t,n))),i),r}function Bh(e,t){const r=void 0!==t?t:e.toString(2).length;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}function Th(e){if("bigint"!=typeof e)throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function Rh(e){const t=Th(e);return t+Math.ceil(t/2)}ql.validateField=function(e){const t=Ah.reduce(((e,t)=>(e[t]="function",e)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"});return(0,fh.validateObject)(e,t)},ql.FpPow=kh,ql.FpInvertBatch=Ih,ql.FpDiv=function(e,t,r){return e.mul(t,"bigint"==typeof r?Eh(r,e.ORDER):e.inv(r))},ql.FpIsSquare=function(e){const t=(e.ORDER-ph)/gh;return r=>{const n=e.pow(r,t);return e.eql(n,e.ZERO)||e.eql(n,e.ONE)}},ql.nLength=Bh,ql.Field=function(e,t,r=!1,n={}){if(e<=dh)throw new Error(`Expected Field ORDER > 0, got ${e}`);const{nBitLength:i,nByteLength:o}=Bh(e,t);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");const s=xh(e),a=Object.freeze({ORDER:e,BITS:i,BYTES:o,MASK:(0,fh.bitMask)(i),ZERO:dh,ONE:ph,create:t=>vh(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("Invalid field element: expected bigint, got "+typeof t);return dh<=t&&te===dh,isOdd:e=>(e&ph)===ph,neg:t=>vh(-t,e),eql:(e,t)=>e===t,sqr:t=>vh(t*t,e),add:(t,r)=>vh(t+r,e),sub:(t,r)=>vh(t-r,e),mul:(t,r)=>vh(t*r,e),pow:(e,t)=>kh(a,e,t),div:(t,r)=>vh(t*Eh(r,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>Eh(t,e),sqrt:n.sqrt||(e=>s(a,e)),invertBatch:e=>Ih(a,e),cmov:(e,t,r)=>r?t:e,toBytes:e=>r?(0,fh.numberToBytesLE)(e,o):(0,fh.numberToBytesBE)(e,o),fromBytes:e=>{if(e.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${e.length}`);return r?(0,fh.bytesToNumberLE)(e):(0,fh.bytesToNumberBE)(e)}});return Object.freeze(a)},ql.FpSqrtOdd=function(e,t){if(!e.isOdd)throw new Error("Field doesn't have isOdd");const r=e.sqrt(t);return e.isOdd(r)?r:e.neg(r)},ql.FpSqrtEven=function(e,t){if(!e.isOdd)throw new Error("Field doesn't have isOdd");const r=e.sqrt(t);return e.isOdd(r)?e.neg(r):r},ql.hashToPrivateScalar=function(e,t,r=!1){const n=(e=(0,fh.ensureBytes)("privateHash",e)).length,i=Bh(t).nByteLength+8;if(i<24||n1024)throw new Error(`hashToPrivateScalar: expected ${i}-1024 bytes of input, got ${n}`);return vh(r?(0,fh.bytesToNumberLE)(e):(0,fh.bytesToNumberBE)(e),t-ph)+ph},ql.getFieldBytesLength=Th,ql.getMinHashLength=Rh,ql.mapHashToField=function(e,t,r=!1){const n=e.length,i=Th(t),o=Rh(t);if(n<16||n1024)throw new Error(`expected ${o}-1024 bytes of input, got ${n}`);const s=vh(r?(0,fh.bytesToNumberBE)(e):(0,fh.bytesToNumberLE)(e),t-ph)+ph;return r?(0,fh.numberToBytesLE)(s,i):(0,fh.numberToBytesBE)(s,i)};var Oh={},Mh={};Object.defineProperty(Mh,"__esModule",{value:!0}),Mh.validateBasic=Mh.wNAF=void 0; +const gl=Vh,yl=BigInt(0),ml=BigInt(1),wl=BigInt(2),bl=BigInt(3),vl=BigInt(4),_l=BigInt(5),El=BigInt(8);function Sl(e,t){const r=e%t;return r>=yl?r:t+r}function Al(e,t,r){if(r<=yl||t 0");if(r===ml)return yl;let n=ml;for(;t>yl;)t&ml&&(n=n*e%r),e=e*e%r,t>>=ml;return n}function xl(e,t){if(e===yl||t<=yl)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let r=Sl(e,t),n=t,i=yl,o=ml;for(;r!==yl;){const e=n%r,t=i-o*(n/r);n=r,r=e,i=o,o=t}if(n!==ml)throw new Error("invert: does not exist");return Sl(i,t)}function kl(e){const t=(e-ml)/wl;let r,n,i;for(r=e-ml,n=0;r%wl===yl;r/=wl,n++);for(i=wl;iyl;)n*=n,n%=r;return n},Wh.invert=xl,Wh.tonelliShanks=kl,Wh.FpSqrt=Bl;Wh.isNegativeLE=(e,t)=>(Sl(e,t)&ml)===ml;const Il=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Tl(e,t,r){if(r 0");if(r===yl)return e.ONE;if(r===ml)return t;let n=e.ONE,i=t;for(;r>yl;)r&ml&&(n=e.mul(n,i)),i=e.sqr(i),r>>=ml;return n}function Rl(e,t){const r=new Array(t.length),n=t.reduce(((t,n,i)=>e.is0(n)?t:(r[i]=t,e.mul(t,n))),e.ONE),i=e.inv(n);return t.reduceRight(((t,n,i)=>e.is0(n)?t:(r[i]=e.mul(t,r[i]),e.mul(t,n))),i),r}function Ol(e,t){const r=void 0!==t?t:e.toString(2).length;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}function Ll(e){if("bigint"!=typeof e)throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function Ml(e){const t=Ll(e);return t+Math.ceil(t/2)}Wh.validateField=function(e){const t=Il.reduce(((e,t)=>(e[t]="function",e)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"});return(0,gl.validateObject)(e,t)},Wh.FpPow=Tl,Wh.FpInvertBatch=Rl,Wh.FpDiv=function(e,t,r){return e.mul(t,"bigint"==typeof r?xl(r,e.ORDER):e.inv(r))},Wh.FpIsSquare=function(e){const t=(e.ORDER-ml)/wl;return r=>{const n=e.pow(r,t);return e.eql(n,e.ZERO)||e.eql(n,e.ONE)}},Wh.nLength=Ol,Wh.Field=function(e,t,r=!1,n={}){if(e<=yl)throw new Error(`Expected Field ORDER > 0, got ${e}`);const{nBitLength:i,nByteLength:o}=Ol(e,t);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");const s=Bl(e),a=Object.freeze({ORDER:e,BITS:i,BYTES:o,MASK:(0,gl.bitMask)(i),ZERO:yl,ONE:ml,create:t=>Sl(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("Invalid field element: expected bigint, got "+typeof t);return yl<=t&&te===yl,isOdd:e=>(e&ml)===ml,neg:t=>Sl(-t,e),eql:(e,t)=>e===t,sqr:t=>Sl(t*t,e),add:(t,r)=>Sl(t+r,e),sub:(t,r)=>Sl(t-r,e),mul:(t,r)=>Sl(t*r,e),pow:(e,t)=>Tl(a,e,t),div:(t,r)=>Sl(t*xl(r,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>xl(t,e),sqrt:n.sqrt||(e=>s(a,e)),invertBatch:e=>Rl(a,e),cmov:(e,t,r)=>r?t:e,toBytes:e=>r?(0,gl.numberToBytesLE)(e,o):(0,gl.numberToBytesBE)(e,o),fromBytes:e=>{if(e.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${e.length}`);return r?(0,gl.bytesToNumberLE)(e):(0,gl.bytesToNumberBE)(e)}});return Object.freeze(a)},Wh.FpSqrtOdd=function(e,t){if(!e.isOdd)throw new Error("Field doesn't have isOdd");const r=e.sqrt(t);return e.isOdd(r)?r:e.neg(r)},Wh.FpSqrtEven=function(e,t){if(!e.isOdd)throw new Error("Field doesn't have isOdd");const r=e.sqrt(t);return e.isOdd(r)?e.neg(r):r},Wh.hashToPrivateScalar=function(e,t,r=!1){const n=(e=(0,gl.ensureBytes)("privateHash",e)).length,i=Ol(t).nByteLength+8;if(i<24||n1024)throw new Error(`hashToPrivateScalar: expected ${i}-1024 bytes of input, got ${n}`);return Sl(r?(0,gl.bytesToNumberLE)(e):(0,gl.bytesToNumberBE)(e),t-ml)+ml},Wh.getFieldBytesLength=Ll,Wh.getMinHashLength=Ml,Wh.mapHashToField=function(e,t,r=!1){const n=e.length,i=Ll(t),o=Ml(t);if(n<16||n1024)throw new Error(`expected ${o}-1024 bytes of input, got ${n}`);const s=Sl(r?(0,gl.bytesToNumberBE)(e):(0,gl.bytesToNumberLE)(e),t-ml)+ml;return r?(0,gl.numberToBytesLE)(s,i):(0,gl.numberToBytesBE)(s,i)};var Cl={},Pl={};Object.defineProperty(Pl,"__esModule",{value:!0}),Pl.validateBasic=Pl.wNAF=void 0; /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -const Lh=ql,Ch=Fl,Ph=BigInt(0),Nh=BigInt(1);Mh.wNAF=function(e,t){const r=(e,t)=>{const r=t.negate();return e?r:t},n=e=>({windows:Math.ceil(t/e)+1,windowSize:2**(e-1)});return{constTimeNegate:r,unsafeLadder(t,r){let n=e.ZERO,i=t;for(;r>Ph;)r&Nh&&(n=n.add(i)),i=i.double(),r>>=Nh;return n},precomputeWindow(e,t){const{windows:r,windowSize:i}=n(t),o=[];let s=e,a=s;for(let e=0;e>=f,n>a&&(n-=h,o+=Nh);const s=t,d=t+Math.abs(n)-1,p=e%2!=0,g=n<0;0===n?u=u.add(r(p,i[s])):c=c.add(r(g,i[d]))}return{p:c,f:u}},wNAFCached(e,t,r,n){const i=e._WINDOW_SIZE||1;let o=t.get(e);return o||(o=this.precomputeWindow(e,i),1!==i&&t.set(e,n(o))),this.wNAF(i,o,r)}}},Mh.validateBasic=function(e){return(0,Lh.validateField)(e.Fp),(0,Ch.validateObject)(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,Lh.nLength)(e.n,e.nBitLength),...e,p:e.Fp.ORDER})},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.mapToCurveSimpleSWU=e.SWUFpSqrtRatio=e.weierstrass=e.weierstrassPoints=e.DER=void 0; +const Nl=Wh,Ul=Vh,jl=BigInt(0),$l=BigInt(1);Pl.wNAF=function(e,t){const r=(e,t)=>{const r=t.negate();return e?r:t},n=e=>({windows:Math.ceil(t/e)+1,windowSize:2**(e-1)});return{constTimeNegate:r,unsafeLadder(t,r){let n=e.ZERO,i=t;for(;r>jl;)r&$l&&(n=n.add(i)),i=i.double(),r>>=$l;return n},precomputeWindow(e,t){const{windows:r,windowSize:i}=n(t),o=[];let s=e,a=s;for(let e=0;e>=f,n>a&&(n-=l,o+=$l);const s=t,d=t+Math.abs(n)-1,p=e%2!=0,g=n<0;0===n?u=u.add(r(p,i[s])):c=c.add(r(g,i[d]))}return{p:c,f:u}},wNAFCached(e,t,r,n){const i=e._WINDOW_SIZE||1;let o=t.get(e);return o||(o=this.precomputeWindow(e,i),1!==i&&t.set(e,n(o))),this.wNAF(i,o,r)}}},Pl.validateBasic=function(e){return(0,Nl.validateField)(e.Fp),(0,Ul.validateObject)(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,Nl.nLength)(e.n,e.nBitLength),...e,p:e.Fp.ORDER})},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.mapToCurveSimpleSWU=e.SWUFpSqrtRatio=e.weierstrass=e.weierstrassPoints=e.DER=void 0; /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -const t=ql,r=Fl,n=Fl,i=Mh;const{bytesToNumberBE:o,hexToBytes:s}=r;e.DER={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(t){const{Err:r}=e.DER;if(t.length<2||2!==t[0])throw new r("Invalid signature integer tag");const n=t[1],i=t.subarray(2,n+2);if(!n||i.length!==n)throw new r("Invalid signature integer: wrong length");if(128&i[0])throw new r("Invalid signature integer: negative");if(0===i[0]&&!(128&i[1]))throw new r("Invalid signature integer: unnecessary leading zero");return{d:o(i),l:t.subarray(n+2)}},toSig(t){const{Err:n}=e.DER,i="string"==typeof t?s(t):t;if(!r.isBytes(i))throw new Error("ui8a expected");let o=i.length;if(o<2||48!=i[0])throw new n("Invalid signature tag");if(i[1]!==o-2)throw new n("Invalid signature: incorrect length");const{d:a,l:c}=e.DER._parseInt(i.subarray(2)),{d:u,l:l}=e.DER._parseInt(c);if(l.length)throw new n("Invalid signature: left bytes after parsing");return{r:a,s:u}},hexFromSig(e){const t=e=>8&Number.parseInt(e[0],16)?"00"+e:e,r=e=>{const t=e.toString(16);return 1&t.length?`0${t}`:t},n=t(r(e.s)),i=t(r(e.r)),o=n.length/2,s=i.length/2,a=r(o),c=r(s);return`30${r(s+o+4)}02${c}${i}02${a}${n}`}};const a=BigInt(0),c=BigInt(1),u=BigInt(2),l=BigInt(3),h=BigInt(4);function f(e){const o=function(e){const t=(0,i.validateBasic)(e);r.validateObject(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:o,a:s}=t;if(n){if(!o.eql(s,o.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!=typeof n||"bigint"!=typeof n.beta||"function"!=typeof n.splitScalar)throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}(e),{Fp:s}=o,u=o.toBytes||((e,t,n)=>{const i=t.toAffine();return r.concatBytes(Uint8Array.from([4]),s.toBytes(i.x),s.toBytes(i.y))}),h=o.fromBytes||(e=>{const t=e.subarray(1);return{x:s.fromBytes(t.subarray(0,s.BYTES)),y:s.fromBytes(t.subarray(s.BYTES,2*s.BYTES))}});function f(e){const{a:t,b:r}=o,n=s.sqr(e),i=s.mul(n,e);return s.add(s.add(i,s.mul(e,t)),r)}if(!s.eql(s.sqr(o.Gy),f(o.Gx)))throw new Error("bad generator point: equation left != right");function d(e){return"bigint"==typeof e&&as.eql(e,s.ZERO);return n(t)&&n(r)?w.ZERO:new w(t,r,s.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){const t=s.invertBatch(e.map((e=>e.pz)));return e.map(((e,r)=>e.toAffine(t[r]))).map(w.fromAffine)}static fromHex(e){const t=w.fromAffine(h((0,n.ensureBytes)("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return w.BASE.multiply(g(e))}_setWindowSize(e){this._WINDOW_SIZE=e,y.delete(this)}assertValidity(){if(this.is0()){if(o.allowInfinityPoint&&!s.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:e,y:t}=this.toAffine();if(!s.isValid(e)||!s.isValid(t))throw new Error("bad point: x or y not FE");const r=s.sqr(t),n=f(e);if(!s.eql(r,n))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:e}=this.toAffine();if(s.isOdd)return!s.isOdd(e);throw new Error("Field doesn't support isOdd")}equals(e){m(e);const{px:t,py:r,pz:n}=this,{px:i,py:o,pz:a}=e,c=s.eql(s.mul(t,a),s.mul(i,n)),u=s.eql(s.mul(r,a),s.mul(o,n));return c&&u}negate(){return new w(this.px,s.neg(this.py),this.pz)}double(){const{a:e,b:t}=o,r=s.mul(t,l),{px:n,py:i,pz:a}=this;let c=s.ZERO,u=s.ZERO,h=s.ZERO,f=s.mul(n,n),d=s.mul(i,i),p=s.mul(a,a),g=s.mul(n,i);return g=s.add(g,g),h=s.mul(n,a),h=s.add(h,h),c=s.mul(e,h),u=s.mul(r,p),u=s.add(c,u),c=s.sub(d,u),u=s.add(d,u),u=s.mul(c,u),c=s.mul(g,c),h=s.mul(r,h),p=s.mul(e,p),g=s.sub(f,p),g=s.mul(e,g),g=s.add(g,h),h=s.add(f,f),f=s.add(h,f),f=s.add(f,p),f=s.mul(f,g),u=s.add(u,f),p=s.mul(i,a),p=s.add(p,p),f=s.mul(p,g),c=s.sub(c,f),h=s.mul(p,d),h=s.add(h,h),h=s.add(h,h),new w(c,u,h)}add(e){m(e);const{px:t,py:r,pz:n}=this,{px:i,py:a,pz:c}=e;let u=s.ZERO,h=s.ZERO,f=s.ZERO;const d=o.a,p=s.mul(o.b,l);let g=s.mul(t,i),y=s.mul(r,a),b=s.mul(n,c),v=s.add(t,r),_=s.add(i,a);v=s.mul(v,_),_=s.add(g,y),v=s.sub(v,_),_=s.add(t,n);let E=s.add(i,c);return _=s.mul(_,E),E=s.add(g,b),_=s.sub(_,E),E=s.add(r,n),u=s.add(a,c),E=s.mul(E,u),u=s.add(y,b),E=s.sub(E,u),f=s.mul(d,_),u=s.mul(p,b),f=s.add(u,f),u=s.sub(y,f),f=s.add(y,f),h=s.mul(u,f),y=s.add(g,g),y=s.add(y,g),b=s.mul(d,b),_=s.mul(p,_),y=s.add(y,b),b=s.sub(g,b),b=s.mul(d,b),_=s.add(_,b),g=s.mul(y,_),h=s.add(h,g),g=s.mul(E,_),u=s.mul(v,u),u=s.sub(u,g),g=s.mul(v,y),f=s.mul(E,f),f=s.add(f,g),new w(u,h,f)}subtract(e){return this.add(e.negate())}is0(){return this.equals(w.ZERO)}wNAF(e){return v.wNAFCached(this,y,e,(e=>{const t=s.invertBatch(e.map((e=>e.pz)));return e.map(((e,r)=>e.toAffine(t[r]))).map(w.fromAffine)}))}multiplyUnsafe(e){const t=w.ZERO;if(e===a)return t;if(p(e),e===c)return this;const{endo:r}=o;if(!r)return v.unsafeLadder(this,e);let{k1neg:n,k1:i,k2neg:u,k2:l}=r.splitScalar(e),h=t,f=t,d=this;for(;i>a||l>a;)i&c&&(h=h.add(d)),l&c&&(f=f.add(d)),d=d.double(),i>>=c,l>>=c;return n&&(h=h.negate()),u&&(f=f.negate()),f=new w(s.mul(f.px,r.beta),f.py,f.pz),h.add(f)}multiply(e){p(e);let t,r,n=e;const{endo:i}=o;if(i){const{k1neg:e,k1:o,k2neg:a,k2:c}=i.splitScalar(n);let{p:u,f:l}=this.wNAF(o),{p:h,f:f}=this.wNAF(c);u=v.constTimeNegate(e,u),h=v.constTimeNegate(a,h),h=new w(s.mul(h.px,i.beta),h.py,h.pz),t=u.add(h),r=l.add(f)}else{const{p:e,f:i}=this.wNAF(n);t=e,r=i}return w.normalizeZ([t,r])[0]}multiplyAndAddUnsafe(e,t,r){const n=w.BASE,i=(e,t)=>t!==a&&t!==c&&e.equals(n)?e.multiply(t):e.multiplyUnsafe(t),o=i(this,t).add(i(e,r));return o.is0()?void 0:o}toAffine(e){const{px:t,py:r,pz:n}=this,i=this.is0();null==e&&(e=i?s.ONE:s.inv(n));const o=s.mul(t,e),a=s.mul(r,e),c=s.mul(n,e);if(i)return{x:s.ZERO,y:s.ZERO};if(!s.eql(c,s.ONE))throw new Error("invZ was invalid");return{x:o,y:a}}isTorsionFree(){const{h:e,isTorsionFree:t}=o;if(e===c)return!0;if(t)return t(w,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:t}=o;return e===c?this:t?t(w,this):this.multiplyUnsafe(o.h)}toRawBytes(e=!0){return this.assertValidity(),u(w,this,e)}toHex(e=!0){return r.bytesToHex(this.toRawBytes(e))}}w.BASE=new w(o.Gx,o.Gy,s.ONE),w.ZERO=new w(s.ZERO,s.ONE,s.ZERO);const b=o.nBitLength,v=(0,i.wNAF)(w,o.endo?Math.ceil(b/2):b);return{CURVE:o,ProjectivePoint:w,normPrivateKeyToScalar:g,weierstrassEquation:f,isWithinCurveOrder:d}}function d(e,t){const r=e.ORDER;let n=a;for(let e=r-c;e%u===a;e/=u)n+=c;const i=n,o=u<{let n=y,o=e.pow(r,p),s=e.sqr(o);s=e.mul(s,r);let a=e.mul(t,s);a=e.pow(a,d),a=e.mul(a,o),o=e.mul(a,r),s=e.mul(a,t);let l=e.mul(s,o);a=e.pow(l,g);let h=e.eql(a,e.ONE);o=e.mul(s,m),a=e.mul(l,n),s=e.cmov(o,s,h),l=e.cmov(a,l,h);for(let t=i;t>c;t--){let r=t-u;r=u<{let o=e.sqr(i);const s=e.mul(t,i);o=e.mul(o,s);let a=e.pow(o,r);a=e.mul(a,s);const c=e.mul(a,n),u=e.mul(e.sqr(a),i),l=e.eql(u,t);return{isValid:l,value:e.cmov(c,a,l)}}}return w}e.weierstrassPoints=f,e.weierstrass=function(o){const s=function(e){const t=(0,i.validateBasic)(e);return r.validateObject(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}(o),{Fp:u,n:l}=s,h=u.BYTES+1,d=2*u.BYTES+1;function p(e){return t.mod(e,l)}function g(e){return t.invert(e,l)}const{ProjectivePoint:y,normPrivateKeyToScalar:m,weierstrassEquation:w,isWithinCurveOrder:b}=f({...s,toBytes(e,t,n){const i=t.toAffine(),o=u.toBytes(i.x),s=r.concatBytes;return n?s(Uint8Array.from([t.hasEvenY()?2:3]),o):s(Uint8Array.from([4]),o,u.toBytes(i.y))},fromBytes(e){const t=e.length,n=e[0],i=e.subarray(1);if(t!==h||2!==n&&3!==n){if(t===d&&4===n){return{x:u.fromBytes(i.subarray(0,u.BYTES)),y:u.fromBytes(i.subarray(u.BYTES,2*u.BYTES))}}throw new Error(`Point of length ${t} was invalid. Expected ${h} compressed bytes or ${d} uncompressed bytes`)}{const e=r.bytesToNumberBE(i);if(!(a<(o=e)&&or.bytesToHex(r.numberToBytesBE(e,s.nByteLength));function _(e){return e>l>>c}const E=(e,t,n)=>r.bytesToNumberBE(e.slice(t,n));class S{constructor(e,t,r){this.r=e,this.s=t,this.recovery=r,this.assertValidity()}static fromCompact(e){const t=s.nByteLength;return e=(0,n.ensureBytes)("compactSignature",e,2*t),new S(E(e,0,t),E(e,t,2*t))}static fromDER(t){const{r:r,s:i}=e.DER.toSig((0,n.ensureBytes)("DER",t));return new S(r,i)}assertValidity(){if(!b(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!b(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(e){return new S(this.r,this.s,e)}recoverPublicKey(e){const{r:t,s:r,recovery:i}=this,o=I((0,n.ensureBytes)("msgHash",e));if(null==i||![0,1,2,3].includes(i))throw new Error("recovery id invalid");const a=2===i||3===i?t+s.n:t;if(a>=u.ORDER)throw new Error("recovery id 2 or 3 invalid");const c=1&i?"03":"02",l=y.fromHex(c+v(a)),h=g(a),f=p(-o*h),d=p(r*h),m=y.BASE.multiplyAndAddUnsafe(l,f,d);if(!m)throw new Error("point at infinify");return m.assertValidity(),m}hasHighS(){return _(this.s)}normalizeS(){return this.hasHighS()?new S(this.r,p(-this.s),this.recovery):this}toDERRawBytes(){return r.hexToBytes(this.toDERHex())}toDERHex(){return e.DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return r.hexToBytes(this.toCompactHex())}toCompactHex(){return v(this.r)+v(this.s)}}const x={isValidPrivateKey(e){try{return m(e),!0}catch(e){return!1}},normPrivateKeyToScalar:m,randomPrivateKey:()=>{const e=t.getMinHashLength(s.n);return t.mapHashToField(s.randomBytes(e),s.n)},precompute:(e=8,t=y.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)};function A(e){const t=r.isBytes(e),n="string"==typeof e,i=(t||n)&&e.length;return t?i===h||i===d:n?i===2*h||i===2*d:e instanceof y}const k=s.bits2int||function(e){const t=r.bytesToNumberBE(e),n=8*e.length-s.nBitLength;return n>0?t>>BigInt(n):t},I=s.bits2int_modN||function(e){return p(k(e))},B=r.bitMask(s.nBitLength);function T(e){if("bigint"!=typeof e)throw new Error("bigint expected");if(!(a<=e&&ee in i)))throw new Error("sign() legacy options not supported");const{hash:o,randomBytes:l}=s;let{lowS:h,prehash:f,extraEntropy:d}=i;null==h&&(h=!0),e=(0,n.ensureBytes)("msgHash",e),f&&(e=(0,n.ensureBytes)("prehashed msgHash",o(e)));const w=I(e),v=m(t),E=[T(v),T(w)];if(null!=d){const e=!0===d?l(u.BYTES):d;E.push((0,n.ensureBytes)("extraEntropy",e))}const x=r.concatBytes(...E),A=w;return{seed:x,k2sig:function(e){const t=k(e);if(!b(t))return;const r=g(t),n=y.BASE.multiply(t).toAffine(),i=p(n.x);if(i===a)return;const o=p(r*p(A+i*v));if(o===a)return;let s=(n.x===i?0:2)|Number(n.y&c),u=o;return h&&_(o)&&(u=function(e){return _(e)?p(-e):e}(o),s^=1),new S(i,u,s)}}}const O={lowS:s.lowS,prehash:!1},M={lowS:s.lowS,prehash:!1};return y.BASE._setWindowSize(8),{CURVE:s,getPublicKey:function(e,t=!0){return y.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t,r=!0){if(A(e))throw new Error("first arg must be private key");if(!A(t))throw new Error("second arg must be public key");return y.fromHex(t).multiply(m(e)).toRawBytes(r)},sign:function(e,t,n=O){const{seed:i,k2sig:o}=R(e,t,n),a=s;return r.createHmacDrbg(a.hash.outputLen,a.nByteLength,a.hmac)(i,o)},verify:function(t,i,o,a=M){const c=t;if(i=(0,n.ensureBytes)("msgHash",i),o=(0,n.ensureBytes)("publicKey",o),"strict"in a)throw new Error("options.strict was renamed to lowS");const{lowS:u,prehash:l}=a;let h,f;try{if("string"==typeof c||r.isBytes(c))try{h=S.fromDER(c)}catch(t){if(!(t instanceof e.DER.Err))throw t;h=S.fromCompact(c)}else{if("object"!=typeof c||"bigint"!=typeof c.r||"bigint"!=typeof c.s)throw new Error("PARSE");{const{r:e,s:t}=c;h=new S(e,t)}}f=y.fromHex(o)}catch(e){if("PARSE"===e.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(u&&h.hasHighS())return!1;l&&(i=s.hash(i));const{r:d,s:m}=h,w=I(i),b=g(m),v=p(w*b),_=p(d*b),E=y.BASE.multiplyAndAddUnsafe(f,v,_)?.toAffine();return!!E&&p(E.x)===d},ProjectivePoint:y,Signature:S,utils:x}},e.SWUFpSqrtRatio=d,e.mapToCurveSimpleSWU=function(e,r){if(t.validateField(e),!e.isValid(r.A)||!e.isValid(r.B)||!e.isValid(r.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");const n=d(e,r.Z);if(!e.isOdd)throw new Error("Fp.isOdd is not implemented!");return t=>{let i,o,s,a,c,u,l,h;i=e.sqr(t),i=e.mul(i,r.Z),o=e.sqr(i),o=e.add(o,i),s=e.add(o,e.ONE),s=e.mul(s,r.B),a=e.cmov(r.Z,e.neg(o),!e.eql(o,e.ZERO)),a=e.mul(a,r.A),o=e.sqr(s),u=e.sqr(a),c=e.mul(u,r.A),o=e.add(o,c),o=e.mul(o,s),u=e.mul(u,a),c=e.mul(u,r.B),o=e.add(o,c),l=e.mul(i,s);const{isValid:f,value:d}=n(o,u);h=e.mul(i,t),h=e.mul(h,d),l=e.cmov(l,s,f),h=e.cmov(h,d,f);const p=e.isOdd(t)===e.isOdd(h);return h=e.cmov(e.neg(h),h,p),l=e.div(l,a),{x:l,y:h}}}}(Oh);var Uh={};Object.defineProperty(Uh,"__esModule",{value:!0}),Uh.createHasher=Uh.isogenyMap=Uh.hash_to_field=Uh.expand_message_xof=Uh.expand_message_xmd=void 0;const jh=ql,$h=Fl;const zh=$h.bytesToNumberBE;function Dh(e,t){if(e<0||e>=1<<8*t)throw new Error(`bad I2OSP call: value=${e} length=${t}`);const r=Array.from({length:t}).fill(0);for(let n=t-1;n>=0;n--)r[n]=255&e,e>>>=8;return new Uint8Array(r)}function Hh(e,t){const r=new Uint8Array(e.length);for(let n=0;n255&&(t=n((0,$h.concatBytes)((0,$h.utf8ToBytes)("H2C-OVERSIZE-DST-"),t)));const{outputLen:i,blockLen:o}=n,s=Math.ceil(r/i);if(s>255)throw new Error("Invalid xmd length");const a=(0,$h.concatBytes)(t,Dh(t.length,1)),c=Dh(0,o),u=Dh(r,2),l=new Array(s),h=n((0,$h.concatBytes)(c,e,u,Dh(0,1),a));l[0]=n((0,$h.concatBytes)(h,Dh(1,1),a));for(let e=1;e<=s;e++){const t=[Hh(h,l[e-1]),Dh(e+1,1),a];l[e]=n((0,$h.concatBytes)(...t))}return(0,$h.concatBytes)(...l).slice(0,r)}function Wh(e,t,r,n,i){if(qh(e),qh(t),Fh(r),t.length>255){const e=Math.ceil(2*n/8);t=i.create({dkLen:e}).update((0,$h.utf8ToBytes)("H2C-OVERSIZE-DST-")).update(t).digest()}if(r>65535||t.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return i.create({dkLen:r}).update(e).update(Dh(r,2)).update(t).update(Dh(t.length,1)).digest()}function Vh(e,t,r){(0,$h.validateObject)(r,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});const{p:n,k:i,m:o,hash:s,expand:a,DST:c}=r;qh(e),Fh(t);const u=function(e){if((0,$h.isBytes)(e))return e;if("string"==typeof e)return(0,$h.utf8ToBytes)(e);throw new Error("DST must be Uint8Array or string")}(c),l=n.toString(2).length,h=Math.ceil((l+i)/8),f=t*o*h;let d;if("xmd"===a)d=Kh(e,u,f,s);else if("xof"===a)d=Wh(e,u,f,i,s);else{if("_internal_pass"!==a)throw new Error('expand must be "xmd" or "xof"');d=e}const p=new Array(t);for(let e=0;eArray.from(e).reverse()));return(t,n)=>{const[i,o,s,a]=r.map((r=>r.reduce(((r,n)=>e.add(e.mul(r,t),n)))));return t=e.div(i,o),n=e.mul(n,e.div(s,a)),{x:t,y:n}}},Uh.createHasher=function(e,t,r){if("function"!=typeof t)throw new Error("mapToCurve() must be defined");return{hashToCurve(n,i){const o=Vh(n,2,{...r,DST:r.DST,...i}),s=e.fromAffine(t(o[0])),a=e.fromAffine(t(o[1])),c=s.add(a).clearCofactor();return c.assertValidity(),c},encodeToCurve(n,i){const o=Vh(n,1,{...r,DST:r.encodeDST,...i}),s=e.fromAffine(t(o[0])).clearCofactor();return s.assertValidity(),s}}};var Zh={},Gh={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.hmac=e.HMAC=void 0;const t=El,r=Rl;class n extends r.Hash{constructor(e,n){super(),this.finished=!1,this.destroyed=!1,(0,t.hash)(e);const i=(0,r.toBytes)(n);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,s=new Uint8Array(o);s.set(i.length>o?e.create().update(i).digest():i);for(let e=0;enew n(e,t).update(r).digest(),e.hmac.create=(e,t)=>new n(e,t)}(Gh),Object.defineProperty(Zh,"__esModule",{value:!0}),Zh.createCurve=Zh.getHash=void 0; +const t=Wh,r=Vh,n=Vh,i=Pl;const{bytesToNumberBE:o,hexToBytes:s}=r;e.DER={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(t){const{Err:r}=e.DER;if(t.length<2||2!==t[0])throw new r("Invalid signature integer tag");const n=t[1],i=t.subarray(2,n+2);if(!n||i.length!==n)throw new r("Invalid signature integer: wrong length");if(128&i[0])throw new r("Invalid signature integer: negative");if(0===i[0]&&!(128&i[1]))throw new r("Invalid signature integer: unnecessary leading zero");return{d:o(i),l:t.subarray(n+2)}},toSig(t){const{Err:n}=e.DER,i="string"==typeof t?s(t):t;if(!r.isBytes(i))throw new Error("ui8a expected");let o=i.length;if(o<2||48!=i[0])throw new n("Invalid signature tag");if(i[1]!==o-2)throw new n("Invalid signature: incorrect length");const{d:a,l:c}=e.DER._parseInt(i.subarray(2)),{d:u,l:h}=e.DER._parseInt(c);if(h.length)throw new n("Invalid signature: left bytes after parsing");return{r:a,s:u}},hexFromSig(e){const t=e=>8&Number.parseInt(e[0],16)?"00"+e:e,r=e=>{const t=e.toString(16);return 1&t.length?`0${t}`:t},n=t(r(e.s)),i=t(r(e.r)),o=n.length/2,s=i.length/2,a=r(o),c=r(s);return`30${r(s+o+4)}02${c}${i}02${a}${n}`}};const a=BigInt(0),c=BigInt(1),u=BigInt(2),h=BigInt(3),l=BigInt(4);function f(e){const o=function(e){const t=(0,i.validateBasic)(e);r.validateObject(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:o,a:s}=t;if(n){if(!o.eql(s,o.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!=typeof n||"bigint"!=typeof n.beta||"function"!=typeof n.splitScalar)throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}(e),{Fp:s}=o,u=o.toBytes||((e,t,n)=>{const i=t.toAffine();return r.concatBytes(Uint8Array.from([4]),s.toBytes(i.x),s.toBytes(i.y))}),l=o.fromBytes||(e=>{const t=e.subarray(1);return{x:s.fromBytes(t.subarray(0,s.BYTES)),y:s.fromBytes(t.subarray(s.BYTES,2*s.BYTES))}});function f(e){const{a:t,b:r}=o,n=s.sqr(e),i=s.mul(n,e);return s.add(s.add(i,s.mul(e,t)),r)}if(!s.eql(s.sqr(o.Gy),f(o.Gx)))throw new Error("bad generator point: equation left != right");function d(e){return"bigint"==typeof e&&as.eql(e,s.ZERO);return n(t)&&n(r)?w.ZERO:new w(t,r,s.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){const t=s.invertBatch(e.map((e=>e.pz)));return e.map(((e,r)=>e.toAffine(t[r]))).map(w.fromAffine)}static fromHex(e){const t=w.fromAffine(l((0,n.ensureBytes)("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return w.BASE.multiply(g(e))}_setWindowSize(e){this._WINDOW_SIZE=e,y.delete(this)}assertValidity(){if(this.is0()){if(o.allowInfinityPoint&&!s.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:e,y:t}=this.toAffine();if(!s.isValid(e)||!s.isValid(t))throw new Error("bad point: x or y not FE");const r=s.sqr(t),n=f(e);if(!s.eql(r,n))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:e}=this.toAffine();if(s.isOdd)return!s.isOdd(e);throw new Error("Field doesn't support isOdd")}equals(e){m(e);const{px:t,py:r,pz:n}=this,{px:i,py:o,pz:a}=e,c=s.eql(s.mul(t,a),s.mul(i,n)),u=s.eql(s.mul(r,a),s.mul(o,n));return c&&u}negate(){return new w(this.px,s.neg(this.py),this.pz)}double(){const{a:e,b:t}=o,r=s.mul(t,h),{px:n,py:i,pz:a}=this;let c=s.ZERO,u=s.ZERO,l=s.ZERO,f=s.mul(n,n),d=s.mul(i,i),p=s.mul(a,a),g=s.mul(n,i);return g=s.add(g,g),l=s.mul(n,a),l=s.add(l,l),c=s.mul(e,l),u=s.mul(r,p),u=s.add(c,u),c=s.sub(d,u),u=s.add(d,u),u=s.mul(c,u),c=s.mul(g,c),l=s.mul(r,l),p=s.mul(e,p),g=s.sub(f,p),g=s.mul(e,g),g=s.add(g,l),l=s.add(f,f),f=s.add(l,f),f=s.add(f,p),f=s.mul(f,g),u=s.add(u,f),p=s.mul(i,a),p=s.add(p,p),f=s.mul(p,g),c=s.sub(c,f),l=s.mul(p,d),l=s.add(l,l),l=s.add(l,l),new w(c,u,l)}add(e){m(e);const{px:t,py:r,pz:n}=this,{px:i,py:a,pz:c}=e;let u=s.ZERO,l=s.ZERO,f=s.ZERO;const d=o.a,p=s.mul(o.b,h);let g=s.mul(t,i),y=s.mul(r,a),b=s.mul(n,c),v=s.add(t,r),_=s.add(i,a);v=s.mul(v,_),_=s.add(g,y),v=s.sub(v,_),_=s.add(t,n);let E=s.add(i,c);return _=s.mul(_,E),E=s.add(g,b),_=s.sub(_,E),E=s.add(r,n),u=s.add(a,c),E=s.mul(E,u),u=s.add(y,b),E=s.sub(E,u),f=s.mul(d,_),u=s.mul(p,b),f=s.add(u,f),u=s.sub(y,f),f=s.add(y,f),l=s.mul(u,f),y=s.add(g,g),y=s.add(y,g),b=s.mul(d,b),_=s.mul(p,_),y=s.add(y,b),b=s.sub(g,b),b=s.mul(d,b),_=s.add(_,b),g=s.mul(y,_),l=s.add(l,g),g=s.mul(E,_),u=s.mul(v,u),u=s.sub(u,g),g=s.mul(v,y),f=s.mul(E,f),f=s.add(f,g),new w(u,l,f)}subtract(e){return this.add(e.negate())}is0(){return this.equals(w.ZERO)}wNAF(e){return v.wNAFCached(this,y,e,(e=>{const t=s.invertBatch(e.map((e=>e.pz)));return e.map(((e,r)=>e.toAffine(t[r]))).map(w.fromAffine)}))}multiplyUnsafe(e){const t=w.ZERO;if(e===a)return t;if(p(e),e===c)return this;const{endo:r}=o;if(!r)return v.unsafeLadder(this,e);let{k1neg:n,k1:i,k2neg:u,k2:h}=r.splitScalar(e),l=t,f=t,d=this;for(;i>a||h>a;)i&c&&(l=l.add(d)),h&c&&(f=f.add(d)),d=d.double(),i>>=c,h>>=c;return n&&(l=l.negate()),u&&(f=f.negate()),f=new w(s.mul(f.px,r.beta),f.py,f.pz),l.add(f)}multiply(e){p(e);let t,r,n=e;const{endo:i}=o;if(i){const{k1neg:e,k1:o,k2neg:a,k2:c}=i.splitScalar(n);let{p:u,f:h}=this.wNAF(o),{p:l,f:f}=this.wNAF(c);u=v.constTimeNegate(e,u),l=v.constTimeNegate(a,l),l=new w(s.mul(l.px,i.beta),l.py,l.pz),t=u.add(l),r=h.add(f)}else{const{p:e,f:i}=this.wNAF(n);t=e,r=i}return w.normalizeZ([t,r])[0]}multiplyAndAddUnsafe(e,t,r){const n=w.BASE,i=(e,t)=>t!==a&&t!==c&&e.equals(n)?e.multiply(t):e.multiplyUnsafe(t),o=i(this,t).add(i(e,r));return o.is0()?void 0:o}toAffine(e){const{px:t,py:r,pz:n}=this,i=this.is0();null==e&&(e=i?s.ONE:s.inv(n));const o=s.mul(t,e),a=s.mul(r,e),c=s.mul(n,e);if(i)return{x:s.ZERO,y:s.ZERO};if(!s.eql(c,s.ONE))throw new Error("invZ was invalid");return{x:o,y:a}}isTorsionFree(){const{h:e,isTorsionFree:t}=o;if(e===c)return!0;if(t)return t(w,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:t}=o;return e===c?this:t?t(w,this):this.multiplyUnsafe(o.h)}toRawBytes(e=!0){return this.assertValidity(),u(w,this,e)}toHex(e=!0){return r.bytesToHex(this.toRawBytes(e))}}w.BASE=new w(o.Gx,o.Gy,s.ONE),w.ZERO=new w(s.ZERO,s.ONE,s.ZERO);const b=o.nBitLength,v=(0,i.wNAF)(w,o.endo?Math.ceil(b/2):b);return{CURVE:o,ProjectivePoint:w,normPrivateKeyToScalar:g,weierstrassEquation:f,isWithinCurveOrder:d}}function d(e,t){const r=e.ORDER;let n=a;for(let e=r-c;e%u===a;e/=u)n+=c;const i=n,o=u<{let n=y,o=e.pow(r,p),s=e.sqr(o);s=e.mul(s,r);let a=e.mul(t,s);a=e.pow(a,d),a=e.mul(a,o),o=e.mul(a,r),s=e.mul(a,t);let h=e.mul(s,o);a=e.pow(h,g);let l=e.eql(a,e.ONE);o=e.mul(s,m),a=e.mul(h,n),s=e.cmov(o,s,l),h=e.cmov(a,h,l);for(let t=i;t>c;t--){let r=t-u;r=u<{let o=e.sqr(i);const s=e.mul(t,i);o=e.mul(o,s);let a=e.pow(o,r);a=e.mul(a,s);const c=e.mul(a,n),u=e.mul(e.sqr(a),i),h=e.eql(u,t);return{isValid:h,value:e.cmov(c,a,h)}}}return w}e.weierstrassPoints=f,e.weierstrass=function(o){const s=function(e){const t=(0,i.validateBasic)(e);return r.validateObject(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}(o),{Fp:u,n:h}=s,l=u.BYTES+1,d=2*u.BYTES+1;function p(e){return t.mod(e,h)}function g(e){return t.invert(e,h)}const{ProjectivePoint:y,normPrivateKeyToScalar:m,weierstrassEquation:w,isWithinCurveOrder:b}=f({...s,toBytes(e,t,n){const i=t.toAffine(),o=u.toBytes(i.x),s=r.concatBytes;return n?s(Uint8Array.from([t.hasEvenY()?2:3]),o):s(Uint8Array.from([4]),o,u.toBytes(i.y))},fromBytes(e){const t=e.length,n=e[0],i=e.subarray(1);if(t!==l||2!==n&&3!==n){if(t===d&&4===n){return{x:u.fromBytes(i.subarray(0,u.BYTES)),y:u.fromBytes(i.subarray(u.BYTES,2*u.BYTES))}}throw new Error(`Point of length ${t} was invalid. Expected ${l} compressed bytes or ${d} uncompressed bytes`)}{const e=r.bytesToNumberBE(i);if(!(a<(o=e)&&or.bytesToHex(r.numberToBytesBE(e,s.nByteLength));function _(e){return e>h>>c}const E=(e,t,n)=>r.bytesToNumberBE(e.slice(t,n));class S{constructor(e,t,r){this.r=e,this.s=t,this.recovery=r,this.assertValidity()}static fromCompact(e){const t=s.nByteLength;return e=(0,n.ensureBytes)("compactSignature",e,2*t),new S(E(e,0,t),E(e,t,2*t))}static fromDER(t){const{r:r,s:i}=e.DER.toSig((0,n.ensureBytes)("DER",t));return new S(r,i)}assertValidity(){if(!b(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!b(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(e){return new S(this.r,this.s,e)}recoverPublicKey(e){const{r:t,s:r,recovery:i}=this,o=B((0,n.ensureBytes)("msgHash",e));if(null==i||![0,1,2,3].includes(i))throw new Error("recovery id invalid");const a=2===i||3===i?t+s.n:t;if(a>=u.ORDER)throw new Error("recovery id 2 or 3 invalid");const c=1&i?"03":"02",h=y.fromHex(c+v(a)),l=g(a),f=p(-o*l),d=p(r*l),m=y.BASE.multiplyAndAddUnsafe(h,f,d);if(!m)throw new Error("point at infinify");return m.assertValidity(),m}hasHighS(){return _(this.s)}normalizeS(){return this.hasHighS()?new S(this.r,p(-this.s),this.recovery):this}toDERRawBytes(){return r.hexToBytes(this.toDERHex())}toDERHex(){return e.DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return r.hexToBytes(this.toCompactHex())}toCompactHex(){return v(this.r)+v(this.s)}}const A={isValidPrivateKey(e){try{return m(e),!0}catch(e){return!1}},normPrivateKeyToScalar:m,randomPrivateKey:()=>{const e=t.getMinHashLength(s.n);return t.mapHashToField(s.randomBytes(e),s.n)},precompute:(e=8,t=y.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)};function x(e){const t=r.isBytes(e),n="string"==typeof e,i=(t||n)&&e.length;return t?i===l||i===d:n?i===2*l||i===2*d:e instanceof y}const k=s.bits2int||function(e){const t=r.bytesToNumberBE(e),n=8*e.length-s.nBitLength;return n>0?t>>BigInt(n):t},B=s.bits2int_modN||function(e){return p(k(e))},I=r.bitMask(s.nBitLength);function T(e){if("bigint"!=typeof e)throw new Error("bigint expected");if(!(a<=e&&ee in i)))throw new Error("sign() legacy options not supported");const{hash:o,randomBytes:h}=s;let{lowS:l,prehash:f,extraEntropy:d}=i;null==l&&(l=!0),e=(0,n.ensureBytes)("msgHash",e),f&&(e=(0,n.ensureBytes)("prehashed msgHash",o(e)));const w=B(e),v=m(t),E=[T(v),T(w)];if(null!=d){const e=!0===d?h(u.BYTES):d;E.push((0,n.ensureBytes)("extraEntropy",e))}const A=r.concatBytes(...E),x=w;return{seed:A,k2sig:function(e){const t=k(e);if(!b(t))return;const r=g(t),n=y.BASE.multiply(t).toAffine(),i=p(n.x);if(i===a)return;const o=p(r*p(x+i*v));if(o===a)return;let s=(n.x===i?0:2)|Number(n.y&c),u=o;return l&&_(o)&&(u=function(e){return _(e)?p(-e):e}(o),s^=1),new S(i,u,s)}}}const O={lowS:s.lowS,prehash:!1},L={lowS:s.lowS,prehash:!1};return y.BASE._setWindowSize(8),{CURVE:s,getPublicKey:function(e,t=!0){return y.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t,r=!0){if(x(e))throw new Error("first arg must be private key");if(!x(t))throw new Error("second arg must be public key");return y.fromHex(t).multiply(m(e)).toRawBytes(r)},sign:function(e,t,n=O){const{seed:i,k2sig:o}=R(e,t,n),a=s;return r.createHmacDrbg(a.hash.outputLen,a.nByteLength,a.hmac)(i,o)},verify:function(t,i,o,a=L){const c=t;if(i=(0,n.ensureBytes)("msgHash",i),o=(0,n.ensureBytes)("publicKey",o),"strict"in a)throw new Error("options.strict was renamed to lowS");const{lowS:u,prehash:h}=a;let l,f;try{if("string"==typeof c||r.isBytes(c))try{l=S.fromDER(c)}catch(t){if(!(t instanceof e.DER.Err))throw t;l=S.fromCompact(c)}else{if("object"!=typeof c||"bigint"!=typeof c.r||"bigint"!=typeof c.s)throw new Error("PARSE");{const{r:e,s:t}=c;l=new S(e,t)}}f=y.fromHex(o)}catch(e){if("PARSE"===e.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(u&&l.hasHighS())return!1;h&&(i=s.hash(i));const{r:d,s:m}=l,w=B(i),b=g(m),v=p(w*b),_=p(d*b),E=y.BASE.multiplyAndAddUnsafe(f,v,_)?.toAffine();return!!E&&p(E.x)===d},ProjectivePoint:y,Signature:S,utils:A}},e.SWUFpSqrtRatio=d,e.mapToCurveSimpleSWU=function(e,r){if(t.validateField(e),!e.isValid(r.A)||!e.isValid(r.B)||!e.isValid(r.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");const n=d(e,r.Z);if(!e.isOdd)throw new Error("Fp.isOdd is not implemented!");return t=>{let i,o,s,a,c,u,h,l;i=e.sqr(t),i=e.mul(i,r.Z),o=e.sqr(i),o=e.add(o,i),s=e.add(o,e.ONE),s=e.mul(s,r.B),a=e.cmov(r.Z,e.neg(o),!e.eql(o,e.ZERO)),a=e.mul(a,r.A),o=e.sqr(s),u=e.sqr(a),c=e.mul(u,r.A),o=e.add(o,c),o=e.mul(o,s),u=e.mul(u,a),c=e.mul(u,r.B),o=e.add(o,c),h=e.mul(i,s);const{isValid:f,value:d}=n(o,u);l=e.mul(i,t),l=e.mul(l,d),h=e.cmov(h,s,f),l=e.cmov(l,d,f);const p=e.isOdd(t)===e.isOdd(l);return l=e.cmov(e.neg(l),l,p),h=e.div(h,a),{x:h,y:l}}}}(Cl);var Hl={};Object.defineProperty(Hl,"__esModule",{value:!0}),Hl.createHasher=Hl.isogenyMap=Hl.hash_to_field=Hl.expand_message_xof=Hl.expand_message_xmd=void 0;const zl=Wh,Dl=Vh;const Fl=Dl.bytesToNumberBE;function ql(e,t){if(e<0||e>=1<<8*t)throw new Error(`bad I2OSP call: value=${e} length=${t}`);const r=Array.from({length:t}).fill(0);for(let n=t-1;n>=0;n--)r[n]=255&e,e>>>=8;return new Uint8Array(r)}function Kl(e,t){const r=new Uint8Array(e.length);for(let n=0;n255&&(t=n((0,Dl.concatBytes)((0,Dl.utf8ToBytes)("H2C-OVERSIZE-DST-"),t)));const{outputLen:i,blockLen:o}=n,s=Math.ceil(r/i);if(s>255)throw new Error("Invalid xmd length");const a=(0,Dl.concatBytes)(t,ql(t.length,1)),c=ql(0,o),u=ql(r,2),h=new Array(s),l=n((0,Dl.concatBytes)(c,e,u,ql(0,1),a));h[0]=n((0,Dl.concatBytes)(l,ql(1,1),a));for(let e=1;e<=s;e++){const t=[Kl(l,h[e-1]),ql(e+1,1),a];h[e]=n((0,Dl.concatBytes)(...t))}return(0,Dl.concatBytes)(...h).slice(0,r)}function Gl(e,t,r,n,i){if(Wl(e),Wl(t),Vl(r),t.length>255){const e=Math.ceil(2*n/8);t=i.create({dkLen:e}).update((0,Dl.utf8ToBytes)("H2C-OVERSIZE-DST-")).update(t).digest()}if(r>65535||t.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return i.create({dkLen:r}).update(e).update(ql(r,2)).update(t).update(ql(t.length,1)).digest()}function Jl(e,t,r){(0,Dl.validateObject)(r,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});const{p:n,k:i,m:o,hash:s,expand:a,DST:c}=r;Wl(e),Vl(t);const u=function(e){if((0,Dl.isBytes)(e))return e;if("string"==typeof e)return(0,Dl.utf8ToBytes)(e);throw new Error("DST must be Uint8Array or string")}(c),h=n.toString(2).length,l=Math.ceil((h+i)/8),f=t*o*l;let d;if("xmd"===a)d=Zl(e,u,f,s);else if("xof"===a)d=Gl(e,u,f,i,s);else{if("_internal_pass"!==a)throw new Error('expand must be "xmd" or "xof"');d=e}const p=new Array(t);for(let e=0;eArray.from(e).reverse()));return(t,n)=>{const[i,o,s,a]=r.map((r=>r.reduce(((r,n)=>e.add(e.mul(r,t),n)))));return t=e.div(i,o),n=e.mul(n,e.div(s,a)),{x:t,y:n}}},Hl.createHasher=function(e,t,r){if("function"!=typeof t)throw new Error("mapToCurve() must be defined");return{hashToCurve(n,i){const o=Jl(n,2,{...r,DST:r.DST,...i}),s=e.fromAffine(t(o[0])),a=e.fromAffine(t(o[1])),c=s.add(a).clearCofactor();return c.assertValidity(),c},encodeToCurve(n,i){const o=Jl(n,1,{...r,DST:r.encodeDST,...i}),s=e.fromAffine(t(o[0])).clearCofactor();return s.assertValidity(),s}}};var Yl={},Xl={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.hmac=e.HMAC=void 0;const t=xh,r=Mh;class n extends r.Hash{constructor(e,n){super(),this.finished=!1,this.destroyed=!1,(0,t.hash)(e);const i=(0,r.toBytes)(n);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,s=new Uint8Array(o);s.set(i.length>o?e.create().update(i).digest():i);for(let e=0;enew n(e,t).update(r).digest(),e.hmac.create=(e,t)=>new n(e,t)}(Xl),Object.defineProperty(Yl,"__esModule",{value:!0}),Yl.createCurve=Yl.getHash=void 0; /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -const Jh=Gh,Yh=Rl,Xh=Oh;function Qh(e){return{hash:e,hmac:(t,...r)=>(0,Jh.hmac)(e,t,(0,Yh.concatBytes)(...r)),randomBytes:Yh.randomBytes}}Zh.getHash=Qh,Zh.createCurve=function(e,t){const r=t=>(0,Xh.weierstrass)({...e,...Qh(t)});return Object.freeze({...r(t),create:r})},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.encodeToCurve=e.hashToCurve=e.schnorr=e.secp256k1=void 0; +const Ql=Xl,ef=Mh,tf=Cl;function rf(e){return{hash:e,hmac:(t,...r)=>(0,Ql.hmac)(e,t,(0,ef.concatBytes)(...r)),randomBytes:ef.randomBytes}}Yl.getHash=rf,Yl.createCurve=function(e,t){const r=t=>(0,tf.weierstrass)({...e,...rf(t)});return Object.freeze({...r(t),create:r})},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.encodeToCurve=e.hashToCurve=e.schnorr=e.secp256k1=void 0; /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -const t=vl,r=Rl,n=ql,i=Oh,o=Fl,s=Uh,a=Zh,c=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),u=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),l=BigInt(1),h=BigInt(2),f=(e,t)=>(e+t/h)/t;function d(e){const t=c,r=BigInt(3),i=BigInt(6),o=BigInt(11),s=BigInt(22),a=BigInt(23),u=BigInt(44),l=BigInt(88),f=e*e*e%t,d=f*f*e%t,g=(0,n.pow2)(d,r,t)*d%t,y=(0,n.pow2)(g,r,t)*d%t,m=(0,n.pow2)(y,h,t)*f%t,w=(0,n.pow2)(m,o,t)*m%t,b=(0,n.pow2)(w,s,t)*w%t,v=(0,n.pow2)(b,u,t)*b%t,_=(0,n.pow2)(v,l,t)*v%t,E=(0,n.pow2)(_,u,t)*b%t,S=(0,n.pow2)(E,r,t)*d%t,x=(0,n.pow2)(S,a,t)*w%t,A=(0,n.pow2)(x,i,t)*f%t,k=(0,n.pow2)(A,h,t);if(!p.eql(p.sqr(k),e))throw new Error("Cannot find square root");return k}const p=(0,n.Field)(c,void 0,void 0,{sqrt:d});e.secp256k1=(0,a.createCurve)({a:BigInt(0),b:BigInt(7),Fp:p,n:u,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=u,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),i=-l*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=r,a=BigInt("0x100000000000000000000000000000000"),c=f(s*e,t),h=f(-i*e,t);let d=(0,n.mod)(e-c*r-h*o,t),p=(0,n.mod)(-c*i-h*s,t);const g=d>a,y=p>a;if(g&&(d=t-d),y&&(p=t-p),d>a||p>a)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:g,k1:d,k2neg:y,k2:p}}}},t.sha256);const g=BigInt(0),y=e=>"bigint"==typeof e&&ge.charCodeAt(0))));n=(0,o.concatBytes)(r,r),m[e]=n}return(0,t.sha256)((0,o.concatBytes)(n,...r))}const b=e=>e.toRawBytes(!0).slice(1),v=e=>(0,o.numberToBytesBE)(e,32),_=e=>(0,n.mod)(e,c),E=e=>(0,n.mod)(e,u),S=e.secp256k1.ProjectivePoint;function x(t){let r=e.secp256k1.utils.normPrivateKeyToScalar(t),n=S.fromPrivateKey(r);return{scalar:n.hasEvenY()?r:E(-r),bytes:b(n)}}function A(e){if(!y(e))throw new Error("bad x: need 0 < x < p");const t=_(e*e);let r=d(_(t*e+BigInt(7)));r%h!==g&&(r=_(-r));const n=new S(e,r,l);return n.assertValidity(),n}function k(...e){return E((0,o.bytesToNumberBE)(w("BIP0340/challenge",...e)))}function I(e){return x(e).bytes}function B(e,t,n=(0,r.randomBytes)(32)){const i=(0,o.ensureBytes)("message",e),{bytes:s,scalar:a}=x(t),c=(0,o.ensureBytes)("auxRand",n,32),u=v(a^(0,o.bytesToNumberBE)(w("BIP0340/aux",c))),l=w("BIP0340/nonce",u,s,i),h=E((0,o.bytesToNumberBE)(l));if(h===g)throw new Error("sign failed: k is zero");const{bytes:f,scalar:d}=x(h),p=k(f,s,i),y=new Uint8Array(64);if(y.set(f,0),y.set(v(E(d+p*a)),32),!T(y,i,s))throw new Error("sign: Invalid signature produced");return y}function T(e,t,r){const n=(0,o.ensureBytes)("signature",e,64),i=(0,o.ensureBytes)("message",t),s=(0,o.ensureBytes)("publicKey",r,32);try{const e=A((0,o.bytesToNumberBE)(s)),t=(0,o.bytesToNumberBE)(n.subarray(0,32));if(!y(t))return!1;const r=(0,o.bytesToNumberBE)(n.subarray(32,64));if(!(e=>"bigint"==typeof e&&gS.BASE.multiplyAndAddUnsafe(e,t,r))(e,r,E(-a));return!(!c||!c.hasEvenY()||c.toAffine().x!==t)}catch(e){return!1}}e.schnorr={getPublicKey:I,sign:B,verify:T,utils:{randomPrivateKey:e.secp256k1.utils.randomPrivateKey,lift_x:A,pointToBytes:b,numberToBytesBE:o.numberToBytesBE,bytesToNumberBE:o.bytesToNumberBE,taggedHash:w,mod:n.mod}};const R=(()=>(0,s.isogenyMap)(p,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map((e=>e.map((e=>BigInt(e)))))))(),O=(()=>(0,i.mapToCurveSimpleSWU)(p,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:p.create(BigInt("-11"))}))(),M=(()=>(0,s.createHasher)(e.secp256k1.ProjectivePoint,(e=>{const{x:t,y:r}=O(p.create(e[0]));return R(t,r)}),{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:p.ORDER,m:1,k:128,expand:"xmd",hash:t.sha256}))();e.hashToCurve=M.hashToCurve,e.encodeToCurve=M.encodeToCurve}(bl),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.secp256k1=void 0;var t=bl;Object.defineProperty(e,"secp256k1",{enumerable:!0,get:function(){return t.secp256k1}})}(wl),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.MAX_WITHDRAWALS_PER_PAYLOAD=e.RLP_EMPTY_STRING=e.KECCAK256_RLP=e.KECCAK256_RLP_S=e.KECCAK256_RLP_ARRAY=e.KECCAK256_RLP_ARRAY_S=e.KECCAK256_NULL=e.KECCAK256_NULL_S=e.TWO_POW256=e.SECP256K1_ORDER_DIV_2=e.SECP256K1_ORDER=e.MAX_INTEGER_BIGINT=e.MAX_INTEGER=e.MAX_UINT64=void 0;const t=Mr,r=wl;e.MAX_UINT64=BigInt("0xffffffffffffffff"),e.MAX_INTEGER=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),e.MAX_INTEGER_BIGINT=BigInt("115792089237316195423570985008687907853269984665640564039457584007913129639935"),e.SECP256K1_ORDER=r.secp256k1.CURVE.n,e.SECP256K1_ORDER_DIV_2=r.secp256k1.CURVE.n/BigInt(2),e.TWO_POW256=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000"),e.KECCAK256_NULL_S="c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",e.KECCAK256_NULL=t.Buffer.from(e.KECCAK256_NULL_S,"hex"),e.KECCAK256_RLP_ARRAY_S="1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",e.KECCAK256_RLP_ARRAY=t.Buffer.from(e.KECCAK256_RLP_ARRAY_S,"hex"),e.KECCAK256_RLP_S="56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",e.KECCAK256_RLP=t.Buffer.from(e.KECCAK256_RLP_S,"hex"),e.RLP_EMPTY_STRING=t.Buffer.from([128]),e.MAX_WITHDRAWALS_PER_PAYLOAD=16}(ml);var ef={};Object.defineProperty(ef,"__esModule",{value:!0}),ef.GWEI_TO_WEI=void 0,ef.GWEI_TO_WEI=BigInt(1e9);var tf={},rf={};function nf(e){if(Array.isArray(e)){const t=[];let r=0;for(let n=0;ne.length)throw new Error("invalid RLP (safeSlice): end slice of Uint8Array out-of-bounds");return e.slice(t,r)}function sf(e){if(0===e[0])throw new Error("invalid RLP: extra zeros");return ff(hf(e))}function af(e,t){if(e<56)return Uint8Array.from([e+t]);const r=yf(e),n=yf(t+55+r.length/2);return Uint8Array.from(df(n+r))}function cf(e,t=!1){if(null==e||0===e.length)return Uint8Array.from([]);const r=uf(wf(e));if(t)return r;if(0!==r.remainder.length)throw new Error("invalid RLP: remainder must be zero");return r.data}function uf(e){let t,r,n,i,o;const s=[],a=e[0];if(a<=127)return{data:e.slice(0,1),remainder:e.slice(1)};if(a<=183){if(t=a-127,n=128===a?Uint8Array.from([]):of(e,1,t),2===t&&n[0]<128)throw new Error("invalid RLP encoding: invalid prefix, single byte < 0x80 are not prefixed");return{data:n,remainder:e.slice(t)}}if(a<=191){if(r=a-182,e.length-1e.length)throw new Error("invalid RLP: total length is larger than the data");for(i=of(e,r,n);i.length;)o=uf(i),s.push(o.data),i=o.remainder;return{data:s,remainder:e.slice(n)}}}Object.defineProperty(rf,"__esModule",{value:!0}),rf.RLP=rf.utils=rf.decode=rf.encode=void 0,rf.encode=nf,rf.decode=cf;const lf=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function hf(e){let t="";for(let r=0;re+t.length),0),r=new Uint8Array(t);for(let t=0,n=0;t=2&&"0"===e[0]&&"x"===e[1]}function wf(e){if(e instanceof Uint8Array)return e;if("string"==typeof e)return mf(e)?df(function(e){return e.length%2?`0${e}`:e}("string"!=typeof(t=e)?t:mf(t)?t.slice(2):t)):gf(e);var t;if("number"==typeof e||"bigint"==typeof e)return e?df(yf(e)):Uint8Array.from([]);if(null==e)return Uint8Array.from([]);throw new Error("toBytes: received unsupported type "+typeof e)}rf.utils={bytesToHex:hf,concatBytes:pf,hexToBytes:df,utf8ToBytes:gf},rf.RLP={encode:nf,decode:cf};var bf={},vf={},_f={};Object.defineProperty(_f,"__esModule",{value:!0}),_f.add5L=_f.add5H=_f.add4H=_f.add4L=_f.add3H=_f.add3L=_f.add=_f.rotlBL=_f.rotlBH=_f.rotlSL=_f.rotlSH=_f.rotr32L=_f.rotr32H=_f.rotrBL=_f.rotrBH=_f.rotrSL=_f.rotrSH=_f.shrSL=_f.shrSH=_f.toBig=_f.split=_f.fromBig=void 0;const Ef=BigInt(2**32-1),Sf=BigInt(32);function xf(e,t=!1){return t?{h:Number(e&Ef),l:Number(e>>Sf&Ef)}:{h:0|Number(e>>Sf&Ef),l:0|Number(e&Ef)}}function Af(e,t=!1){let r=new Uint32Array(e.length),n=new Uint32Array(e.length);for(let i=0;iBigInt(e>>>0)<>>0);_f.toBig=kf;const If=(e,t,r)=>e>>>r;_f.shrSH=If;const Bf=(e,t,r)=>e<<32-r|t>>>r;_f.shrSL=Bf;const Tf=(e,t,r)=>e>>>r|t<<32-r;_f.rotrSH=Tf;const Rf=(e,t,r)=>e<<32-r|t>>>r;_f.rotrSL=Rf;const Of=(e,t,r)=>e<<64-r|t>>>r-32;_f.rotrBH=Of;const Mf=(e,t,r)=>e>>>r-32|t<<64-r;_f.rotrBL=Mf;const Lf=(e,t)=>t;_f.rotr32H=Lf;const Cf=(e,t)=>e;_f.rotr32L=Cf;const Pf=(e,t,r)=>e<>>32-r;_f.rotlSH=Pf;const Nf=(e,t,r)=>t<>>32-r;_f.rotlSL=Nf;const Uf=(e,t,r)=>t<>>64-r;_f.rotlBH=Uf;const jf=(e,t,r)=>e<>>64-r;function $f(e,t,r,n){const i=(t>>>0)+(n>>>0);return{h:e+r+(i/2**32|0)|0,l:0|i}}_f.rotlBL=jf,_f.add=$f;const zf=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0);_f.add3L=zf;const Df=(e,t,r,n)=>t+r+n+(e/2**32|0)|0;_f.add3H=Df;const Hf=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0);_f.add4L=Hf;const qf=(e,t,r,n,i)=>t+r+n+i+(e/2**32|0)|0;_f.add4H=qf;const Ff=(e,t,r,n,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(i>>>0);_f.add5L=Ff;const Kf=(e,t,r,n,i,o)=>t+r+n+i+o+(e/2**32|0)|0;_f.add5H=Kf;const Wf={fromBig:xf,split:Af,toBig:kf,shrSH:If,shrSL:Bf,rotrSH:Tf,rotrSL:Rf,rotrBH:Of,rotrBL:Mf,rotr32H:Lf,rotr32L:Cf,rotlSH:Pf,rotlSL:Nf,rotlBH:Uf,rotlBL:jf,add:$f,add3L:zf,add3H:Df,add4L:Hf,add4H:qf,add5H:Kf,add5L:Ff};_f.default=Wf,Object.defineProperty(vf,"__esModule",{value:!0}),vf.shake256=vf.shake128=vf.keccak_512=vf.keccak_384=vf.keccak_256=vf.keccak_224=vf.sha3_512=vf.sha3_384=vf.sha3_256=vf.sha3_224=vf.Keccak=vf.keccakP=void 0;const Vf=El,Zf=_f,Gf=Rl,[Jf,Yf,Xf]=[[],[],[]],Qf=BigInt(0),ed=BigInt(1),td=BigInt(2),rd=BigInt(7),nd=BigInt(256),id=BigInt(113);for(let e=0,t=ed,r=1,n=0;e<24;e++){[r,n]=[n,(2*r+3*n)%5],Jf.push(2*(5*n+r)),Yf.push((e+1)*(e+2)/2%64);let i=Qf;for(let e=0;e<7;e++)t=(t<>rd)*id)%nd,t&td&&(i^=ed<<(ed<r>32?(0,Zf.rotlBH)(e,t,r):(0,Zf.rotlSH)(e,t,r),cd=(e,t,r)=>r>32?(0,Zf.rotlBL)(e,t,r):(0,Zf.rotlSL)(e,t,r);function ud(e,t=24){const r=new Uint32Array(10);for(let n=24-t;n<24;n++){for(let t=0;t<10;t++)r[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){const n=(t+8)%10,i=(t+2)%10,o=r[i],s=r[i+1],a=ad(o,s,1)^r[n],c=cd(o,s,1)^r[n+1];for(let r=0;r<50;r+=10)e[t+r]^=a,e[t+r+1]^=c}let t=e[2],i=e[3];for(let r=0;r<24;r++){const n=Yf[r],o=ad(t,i,n),s=cd(t,i,n),a=Jf[r];t=e[a],i=e[a+1],e[a]=o,e[a+1]=s}for(let t=0;t<50;t+=10){for(let n=0;n<10;n++)r[n]=e[t+n];for(let n=0;n<10;n++)e[t+n]^=~r[(n+2)%10]&r[(n+4)%10]}e[0]^=od[n],e[1]^=sd[n]}r.fill(0)}vf.keccakP=ud;class ld extends Gf.Hash{constructor(e,t,r,n=!1,i=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=n,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,(0,Vf.number)(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=(0,Gf.u32)(this.state)}keccak(){ud(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){(0,Vf.exists)(this);const{blockLen:t,state:r}=this,n=(e=(0,Gf.toBytes)(e)).length;for(let i=0;i=r&&this.keccak();const o=Math.min(r-this.posOut,i-n);e.set(t.subarray(this.posOut,this.posOut+o),n),this.posOut+=o,n+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return(0,Vf.number)(e),this.xofInto(new Uint8Array(e))}digestInto(e){if((0,Vf.output)(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:r,outputLen:n,rounds:i,enableXOF:o}=this;return e||(e=new ld(t,r,n,o,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=r,e.outputLen=n,e.enableXOF=o,e.destroyed=this.destroyed,e}}vf.Keccak=ld;const hd=(e,t,r)=>(0,Gf.wrapConstructor)((()=>new ld(t,e,r)));vf.sha3_224=hd(6,144,28),vf.sha3_256=hd(6,136,32),vf.sha3_384=hd(6,104,48),vf.sha3_512=hd(6,72,64),vf.keccak_224=hd(1,144,28),vf.keccak_256=hd(1,136,32),vf.keccak_384=hd(1,104,48),vf.keccak_512=hd(1,72,64);const fd=(e,t,r)=>(0,Gf.wrapXOFConstructorWithOpts)(((n={})=>new ld(t,e,void 0===n.dkLen?r:n.dkLen,!0)));function dd(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}vf.shake128=fd(31,168,16),vf.shake256=fd(31,136,32);var pd={exports:{}};!function(e,t){var r=Tr&&Tr.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.crypto=t.wrapHash=t.equalsBytes=t.hexToBytes=t.bytesToUtf8=t.utf8ToBytes=t.createView=t.concatBytes=t.toHex=t.bytesToHex=t.assertBytes=t.assertBool=void 0;const n=r(El),i=Rl,o=n.default.bool;t.assertBool=o;const s=n.default.bytes;t.assertBytes=s;var a=Rl;Object.defineProperty(t,"bytesToHex",{enumerable:!0,get:function(){return a.bytesToHex}}),Object.defineProperty(t,"toHex",{enumerable:!0,get:function(){return a.bytesToHex}}),Object.defineProperty(t,"concatBytes",{enumerable:!0,get:function(){return a.concatBytes}}),Object.defineProperty(t,"createView",{enumerable:!0,get:function(){return a.createView}}),Object.defineProperty(t,"utf8ToBytes",{enumerable:!0,get:function(){return a.utf8ToBytes}}),t.bytesToUtf8=function(e){if(!(e instanceof Uint8Array))throw new TypeError("bytesToUtf8 expected Uint8Array, got "+typeof e);return(new TextDecoder).decode(e)},t.hexToBytes=function(e){const t=e.startsWith("0x")?e.substring(2):e;return(0,i.hexToBytes)(t)},t.equalsBytes=function(e,t){if(e.length!==t.length)return!1;for(let r=0;r(n.default.bytes(t),e(t))},t.crypto=(()=>{const t="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,r=dd.bind(e);return{node:r&&!t?r("crypto"):void 0,web:t}})()}(pd,pd.exports),Object.defineProperty(bf,"__esModule",{value:!0}),bf.keccak512=bf.keccak384=bf.keccak256=bf.keccak224=void 0;const gd=vf,yd=pd.exports;bf.keccak224=(0,yd.wrapHash)(gd.keccak_224),bf.keccak256=(()=>{const e=(0,yd.wrapHash)(gd.keccak_256);return e.create=gd.keccak_256.create,e})(),bf.keccak384=(0,yd.wrapHash)(gd.keccak_384),bf.keccak512=(0,yd.wrapHash)(gd.keccak_512);var md={},wd={},bd={};function vd(e){if("string"!=typeof e)throw new Error("[isHexPrefixed] input must be type 'string', received type "+typeof e);return"0"===e[0]&&"x"===e[1]}Object.defineProperty(bd,"__esModule",{value:!0}),bd.isHexString=bd.getKeys=bd.fromAscii=bd.fromUtf8=bd.toAscii=bd.arrayContainsArray=bd.getBinarySize=bd.padToEven=bd.stripHexPrefix=bd.isHexPrefixed=void 0,bd.isHexPrefixed=vd;function _d(e){let t=e;if("string"!=typeof t)throw new Error("[padToEven] value must be type 'string', received "+typeof t);return t.length%2&&(t=`0${t}`),t}bd.stripHexPrefix=e=>{if("string"!=typeof e)throw new Error("[stripHexPrefix] input must be type 'string', received "+typeof e);return vd(e)?e.slice(2):e},bd.padToEven=_d,bd.getBinarySize=function(e){if("string"!=typeof e)throw new Error("[getBinarySize] method requires input type 'string', received "+typeof e);return C.byteLength(e,"utf8")},bd.arrayContainsArray=function(e,t,r){if(!0!==Array.isArray(e))throw new Error(`[arrayContainsArray] method requires input 'superset' to be an array, got type '${typeof e}'`);if(!0!==Array.isArray(t))throw new Error(`[arrayContainsArray] method requires input 'subset' to be an array, got type '${typeof t}'`);return t[!0===r?"some":"every"]((t=>e.indexOf(t)>=0))},bd.toAscii=function(e){let t="",r=0;const n=e.length;for("0x"===e.substring(0,2)&&(r=2);r0&&e.length!==2+2*t)},Object.defineProperty(wd,"__esModule",{value:!0}),wd.assertIsString=wd.assertIsArray=wd.assertIsBuffer=wd.assertIsHexString=void 0;const Ed=bd;wd.assertIsHexString=function(e){if(!(0,Ed.isHexString)(e)){throw new Error(`This method only supports 0x-prefixed hex strings but input was: ${e}`)}};wd.assertIsBuffer=function(e){if(!C.isBuffer(e)){throw new Error(`This method only supports Buffer but input was: ${e}`)}};wd.assertIsArray=function(e){if(!Array.isArray(e)){throw new Error(`This method only supports number arrays but input was: ${e}`)}};wd.assertIsString=function(e){if("string"!=typeof e){throw new Error(`This method only supports strings but input was: ${e}`)}},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.intToUnpaddedBuffer=e.bigIntToUnpaddedBuffer=e.bigIntToHex=e.bufArrToArr=e.arrToBufArr=e.validateNoLeadingZeroes=e.baToJSON=e.toUtf8=e.short=e.addHexPrefix=e.toUnsigned=e.fromSigned=e.bufferToInt=e.bigIntToBuffer=e.bufferToBigInt=e.bufferToHex=e.toBuffer=e.unpadHexString=e.unpadArray=e.unpadBuffer=e.setLengthRight=e.setLengthLeft=e.zeros=e.intToBuffer=e.intToHex=void 0;const t=wd,r=bd;e.intToHex=function(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Received an invalid integer type: ${e}`);return`0x${e.toString(16)}`};e.intToBuffer=function(t){const n=(0,e.intToHex)(t);return C.from((0,r.padToEven)(n.slice(2)),"hex")};e.zeros=function(e){return C.allocUnsafe(e).fill(0)};const n=function(t,r,n){const i=(0,e.zeros)(r);return n?t.length0&&"0"===t.toString();)t=(e=e.slice(1))[0];return e};e.unpadBuffer=function(e){return(0,t.assertIsBuffer)(e),i(e)};e.unpadArray=function(e){return(0,t.assertIsArray)(e),i(e)};e.unpadHexString=function(e){return(0,t.assertIsHexString)(e),e=(0,r.stripHexPrefix)(e),"0x"+i(e)};e.toBuffer=function(t){if(null==t)return C.allocUnsafe(0);if(C.isBuffer(t))return C.from(t);if(Array.isArray(t)||t instanceof Uint8Array)return C.from(t);if("string"==typeof t){if(!(0,r.isHexString)(t))throw new Error(`Cannot convert string to buffer. toBuffer only supports 0x-prefixed hex strings and this string was given: ${t}`);return C.from((0,r.padToEven)((0,r.stripHexPrefix)(t)),"hex")}if("number"==typeof t)return(0,e.intToBuffer)(t);if("bigint"==typeof t){if(t0&&0===r[0])throw new Error(`${t} cannot have leading zeroes, received: ${r.toString("hex")}`)},e.arrToBufArr=function e(t){return Array.isArray(t)?t.map((t=>e(t))):C.from(t)},e.bufArrToArr=function e(t){return Array.isArray(t)?t.map((t=>e(t))):Uint8Array.from(t??[])};e.bigIntToHex=e=>"0x"+e.toString(16),e.bigIntToUnpaddedBuffer=function(t){return(0,e.unpadBuffer)(s(t))},e.intToUnpaddedBuffer=function(t){return(0,e.unpadBuffer)((0,e.intToBuffer)(t))}}(md),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.accountBodyToRLP=e.accountBodyToSlim=e.accountBodyFromSlim=e.isZeroAddress=e.zeroAddress=e.importPublic=e.privateToAddress=e.privateToPublic=e.publicToAddress=e.pubToAddress=e.isValidPublic=e.isValidPrivate=e.generateAddress2=e.generateAddress=e.isValidChecksumAddress=e.toChecksumAddress=e.isValidAddress=e.Account=void 0;const t=rf,r=bf,n=wl,i=pd.exports,o=md,s=ml,a=wd,c=bd,u=BigInt(0);class l{constructor(e=u,t=u,r=s.KECCAK256_RLP,n=s.KECCAK256_NULL){this.nonce=e,this.balance=t,this.storageRoot=r,this.codeHash=n,this._validate()}static fromAccountData(e){const{nonce:t,balance:r,storageRoot:n,codeHash:i}=e;return new l(void 0!==t?(0,o.bufferToBigInt)((0,o.toBuffer)(t)):void 0,void 0!==r?(0,o.bufferToBigInt)((0,o.toBuffer)(r)):void 0,void 0!==n?(0,o.toBuffer)(n):void 0,void 0!==i?(0,o.toBuffer)(i):void 0)}static fromRlpSerializedAccount(e){const r=(0,o.arrToBufArr)(t.RLP.decode(Uint8Array.from(e)));if(!Array.isArray(r))throw new Error("Invalid serialized account input. Must be array");return this.fromValuesArray(r)}static fromValuesArray(e){const[t,r,n,i]=e;return new l((0,o.bufferToBigInt)(t),(0,o.bufferToBigInt)(r),n,i)}_validate(){if(this.nonce=8?h+=n[e].toUpperCase():h+=n[e];return h};e.isValidChecksumAddress=function(t,r){return(0,e.isValidAddress)(t)&&(0,e.toChecksumAddress)(t,r)===t};e.generateAddress=function(e,n){return(0,a.assertIsBuffer)(e),(0,a.assertIsBuffer)(n),(0,o.bufferToBigInt)(n)===BigInt(0)?C.from((0,r.keccak256)(t.RLP.encode((0,o.bufArrToArr)([e,null])))).slice(-20):C.from((0,r.keccak256)(t.RLP.encode((0,o.bufArrToArr)([e,n])))).slice(-20)};e.generateAddress2=function(e,t,n){if((0,a.assertIsBuffer)(e),(0,a.assertIsBuffer)(t),(0,a.assertIsBuffer)(n),20!==e.length)throw new Error("Expected from to be of length 20");if(32!==t.length)throw new Error("Expected salt to be of length 32");const i=(0,r.keccak256)(C.concat([C.from("ff","hex"),e,t,(0,r.keccak256)(n)]));return(0,o.toBuffer)(i).slice(-20)};e.isValidPrivate=function(e){return n.secp256k1.utils.isValidPrivateKey(e)};e.isValidPublic=function(e,t=!1){if((0,a.assertIsBuffer)(e),64===e.length)try{return n.secp256k1.ProjectivePoint.fromHex(C.concat([C.from([4]),e])),!0}catch(e){return!1}if(!t)return!1;try{return n.secp256k1.ProjectivePoint.fromHex(e),!0}catch(e){return!1}};e.pubToAddress=function(e,t=!1){if((0,a.assertIsBuffer)(e),t&&64!==e.length&&(e=C.from(n.secp256k1.ProjectivePoint.fromHex(e).toRawBytes(!1).slice(1))),64!==e.length)throw new Error("Expected pubKey to be of length 64");return C.from((0,r.keccak256)(e)).slice(-20)},e.publicToAddress=e.pubToAddress;e.privateToPublic=function(e){return(0,a.assertIsBuffer)(e),C.from(n.secp256k1.ProjectivePoint.fromPrivateKey(e).toRawBytes(!1).slice(1))};e.privateToAddress=function(t){return(0,e.publicToAddress)((0,e.privateToPublic)(t))};e.importPublic=function(e){return(0,a.assertIsBuffer)(e),64!==e.length&&(e=C.from(n.secp256k1.ProjectivePoint.fromHex(e).toRawBytes(!1).slice(1))),e};e.zeroAddress=function(){const e=(0,o.zeros)(20);return(0,o.bufferToHex)(e)};function h(e){const[t,r,n,i]=e;return[t,r,0===(0,o.arrToBufArr)(n).length?s.KECCAK256_RLP:n,0===(0,o.arrToBufArr)(i).length?s.KECCAK256_NULL:i]}e.isZeroAddress=function(t){try{(0,a.assertIsString)(t)}catch(e){return!1}return(0,e.zeroAddress)()===t},e.accountBodyFromSlim=h;const f=new Uint8Array(0);e.accountBodyToSlim=function(e){const[t,r,n,i]=e;return[t,r,(0,o.arrToBufArr)(n).equals(s.KECCAK256_RLP)?f:n,(0,o.arrToBufArr)(i).equals(s.KECCAK256_NULL)?f:i]},e.accountBodyToRLP=function(e,r=!0){const n=r?h(e):e;return(0,o.arrToBufArr)(t.RLP.encode(n))}}(tf);var Sd={};Object.defineProperty(Sd,"__esModule",{value:!0}),Sd.Address=void 0;const xd=tf,Ad=md;class kd{constructor(e){if(20!==e.length)throw new Error("Invalid address length");this.buf=e}static zero(){return new kd((0,Ad.zeros)(20))}static fromString(e){if(!(0,xd.isValidAddress)(e))throw new Error("Invalid address");return new kd((0,Ad.toBuffer)(e))}static fromPublicKey(e){if(!C.isBuffer(e))throw new Error("Public key should be Buffer");const t=(0,xd.pubToAddress)(e);return new kd(t)}static fromPrivateKey(e){if(!C.isBuffer(e))throw new Error("Private key should be Buffer");const t=(0,xd.privateToAddress)(e);return new kd(t)}static generate(e,t){if("bigint"!=typeof t)throw new Error("Expected nonce to be a bigint");return new kd((0,xd.generateAddress)(e.buf,(0,Ad.bigIntToBuffer)(t)))}static generate2(e,t,r){if(!C.isBuffer(t))throw new Error("Expected salt to be a Buffer");if(!C.isBuffer(r))throw new Error("Expected initCode to be a Buffer");return new kd((0,xd.generateAddress2)(e.buf,t,r))}equals(e){return this.buf.equals(e.buf)}isZero(){return this.equals(kd.zero())}isPrecompileOrSystemAddress(){const e=(0,Ad.bufferToBigInt)(this.buf),t=BigInt(0),r=BigInt("0xffff");return e>=t&&e<=r}toString(){return"0x"+this.buf.toString("hex")}toBuffer(){return C.from(this.buf)}}Sd.Address=kd;var Id={},Bd={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.toType=e.TypeOutput=void 0;const t=md,r=bd;var n;!function(e){e[e.Number=0]="Number",e[e.BigInt=1]="BigInt",e[e.Buffer=2]="Buffer",e[e.PrefixedHexString=3]="PrefixedHexString"}(n=e.TypeOutput||(e.TypeOutput={})),e.toType=function(e,i){if(null===e)return null;if(void 0===e)return;if("string"==typeof e&&!(0,r.isHexString)(e))throw new Error(`A string must be provided with a 0x-prefix, given: ${e}`);if("number"==typeof e&&!Number.isSafeInteger(e))throw new Error("The provided number is greater than MAX_SAFE_INTEGER (please use an alternative input type)");const o=(0,t.toBuffer)(e);switch(i){case n.Buffer:return o;case n.BigInt:return(0,t.bufferToBigInt)(o);case n.Number:{const e=(0,t.bufferToBigInt)(o);if(e>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("The provided number is greater than MAX_SAFE_INTEGER (please use an alternative output type)");return Number(e)}case n.PrefixedHexString:return(0,t.bufferToHex)(o);default:throw new Error("unknown outputType")}}}(Bd),Object.defineProperty(Id,"__esModule",{value:!0}),Id.Withdrawal=void 0;const Td=Sd,Rd=md,Od=Bd;class Md{constructor(e,t,r,n){this.index=e,this.validatorIndex=t,this.address=r,this.amount=n}static fromWithdrawalData(e){const{index:t,validatorIndex:r,address:n,amount:i}=e,o=(0,Od.toType)(t,Od.TypeOutput.BigInt),s=(0,Od.toType)(r,Od.TypeOutput.BigInt),a=new Td.Address((0,Od.toType)(n,Od.TypeOutput.Buffer)),c=(0,Od.toType)(i,Od.TypeOutput.BigInt);return new Md(o,s,a,c)}static fromValuesArray(e){if(4!==e.length)throw Error(`Invalid withdrawalArray length expected=4 actual=${e.length}`);const[t,r,n,i]=e;return Md.fromWithdrawalData({index:t,validatorIndex:r,address:n,amount:i})}static toBufferArray(e){const{index:t,validatorIndex:r,address:n,amount:i}=e,o=(0,Od.toType)(t,Od.TypeOutput.BigInt)===BigInt(0)?C.alloc(0):(0,Od.toType)(t,Od.TypeOutput.Buffer),s=(0,Od.toType)(r,Od.TypeOutput.BigInt)===BigInt(0)?C.alloc(0):(0,Od.toType)(r,Od.TypeOutput.Buffer);let a;a=n instanceof Td.Address?n.buf:(0,Od.toType)(n,Od.TypeOutput.Buffer);return[o,s,a,(0,Od.toType)(i,Od.TypeOutput.BigInt)===BigInt(0)?C.alloc(0):(0,Od.toType)(i,Od.TypeOutput.Buffer)]}raw(){return Md.toBufferArray(this)}toValue(){return{index:this.index,validatorIndex:this.validatorIndex,address:this.address.buf,amount:this.amount}}toJSON(){return{index:(0,Rd.bigIntToHex)(this.index),validatorIndex:(0,Rd.bigIntToHex)(this.validatorIndex),address:"0x"+this.address.buf.toString("hex"),amount:(0,Rd.bigIntToHex)(this.amount)}}}Id.Withdrawal=Md;var Ld={};Object.defineProperty(Ld,"__esModule",{value:!0}),Ld.hashPersonalMessage=Ld.isValidSignature=Ld.fromRpcSig=Ld.toCompactSig=Ld.toRpcSig=Ld.ecrecover=Ld.ecsign=void 0;const Cd=bf,Pd=wl,Nd=md,Ud=ml,jd=wd;function $d(e,t){return e===BigInt(0)||e===BigInt(1)?e:void 0===t?e-BigInt(27):e-(t*BigInt(2)+BigInt(35))}function zd(e){return e===BigInt(0)||e===BigInt(1)}Ld.ecsign=function(e,t,r){const n=Pd.secp256k1.sign(e,t),i=n.toCompactRawBytes();return{r:C.from(i.slice(0,32)),s:C.from(i.slice(32,64)),v:void 0===r?BigInt(n.recovery+27):BigInt(n.recovery+35)+BigInt(r)*BigInt(2)}};Ld.ecrecover=function(e,t,r,n,i){const o=C.concat([(0,Nd.setLengthLeft)(r,32),(0,Nd.setLengthLeft)(n,32)],64),s=$d(t,i);if(!zd(s))throw new Error("Invalid signature v value");const a=Pd.secp256k1.Signature.fromCompact(o).addRecoveryBit(Number(s)).recoverPublicKey(e);return C.from(a.toRawBytes(!1).slice(1))};Ld.toRpcSig=function(e,t,r,n){if(!zd($d(e,n)))throw new Error("Invalid signature v value");return(0,Nd.bufferToHex)(C.concat([(0,Nd.setLengthLeft)(t,32),(0,Nd.setLengthLeft)(r,32),(0,Nd.toBuffer)(e)]))};Ld.toCompactSig=function(e,t,r,n){if(!zd($d(e,n)))throw new Error("Invalid signature v value");let i=r;return(e>BigInt(28)&&e%BigInt(2)===BigInt(1)||e===BigInt(1)||e===BigInt(28))&&(i=C.from(r),i[0]|=128),(0,Nd.bufferToHex)(C.concat([(0,Nd.setLengthLeft)(t,32),(0,Nd.setLengthLeft)(i,32)]))};Ld.fromRpcSig=function(e){const t=(0,Nd.toBuffer)(e);let r,n,i;if(t.length>=65)r=t.slice(0,32),n=t.slice(32,64),i=(0,Nd.bufferToBigInt)(t.slice(64));else{if(64!==t.length)throw new Error("Invalid signature length");r=t.slice(0,32),n=t.slice(32,64),i=BigInt((0,Nd.bufferToInt)(t.slice(32,33))>>7),n[0]&=127}return i<27&&(i+=BigInt(27)),{v:i,r:r,s:n}};Ld.isValidSignature=function(e,t,r,n=!0,i){if(32!==t.length||32!==r.length)return!1;if(!zd($d(e,i)))return!1;const o=(0,Nd.bufferToBigInt)(t),s=(0,Nd.bufferToBigInt)(r);return!(o===BigInt(0)||o>=Ud.SECP256K1_ORDER||s===BigInt(0)||s>=Ud.SECP256K1_ORDER)&&!(n&&s>=Ud.SECP256K1_ORDER_DIV_2)};Ld.hashPersonalMessage=function(e){(0,jd.assertIsBuffer)(e);const t=C.from(`Ethereum Signed Message:\n${e.length}`,"utf-8");return C.from((0,Cd.keccak256)(C.concat([t,e])))};var Dd={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.compactBytesToNibbles=e.bytesToNibbles=e.nibblesToCompactBytes=e.nibblesToBytes=e.hasTerminator=void 0;e.hasTerminator=e=>e.length>0&&16===e[e.length-1];e.nibblesToBytes=(e,t)=>{for(let r=0,n=0;n{let r=0;(0,e.hasTerminator)(t)&&(r=1,t=t.subarray(0,t.length-1));const n=new Uint8Array(t.length/2+1);return n[0]=r<<5,1&~t.length||(n[0]|=16,n[0]|=t[0],t=t.subarray(1)),(0,e.nibblesToBytes)(t,n.subarray(1)),n};e.bytesToNibbles=e=>{const t=2*e.length+1,r=new Uint8Array(t);for(let t=0;t{if(0===t.length)return t;let r=(0,e.bytesToNibbles)(t);r[0]<2&&(r=r.subarray(0,r.length-1));const n=2-(1&r[0]);return r.subarray(n)}}(Dd);var Hd={},qd=Rr(Ie);Object.defineProperty(Hd,"__esModule",{value:!0}),Hd.AsyncEventEmitter=void 0;const Fd=qd;class Kd extends Fd.EventEmitter{emit(e,...t){let[r,n]=t;const i=this;let o=i._events[e]??[];return void 0===n&&"function"==typeof r&&(n=r,r=void 0),"newListener"!==e&&"removeListener"!==e||(r={event:r,fn:n},n=void 0),o=Array.isArray(o)?o:[o],async function(e,t,r){let n;for await(const i of t)try{i.length<2?i.call(e,r):await new Promise(((t,n)=>{i.call(e,r,(e=>{e?n(e):t()}))}))}catch(e){n=e}if(n)throw n}(i,o.slice(),r).then(n).catch(n),i.listenerCount(e)>0}once(e,t){const r=this;let n;if("function"!=typeof t)throw new TypeError("listener must be a function");return n=t.length>=2?function(i,o){r.removeListener(e,n),t(i,o)}:function(i){r.removeListener(e,n),t(i,n)},r.on(e,n),r}first(e,t){let r=this._events[e]??[];if("function"!=typeof t)throw new TypeError("listener must be a function");return Array.isArray(r)||(this._events[e]=r=[r]),r.unshift(t),this}before(e,t,r){return this.beforeOrAfter(e,t,r)}after(e,t,r){return this.beforeOrAfter(e,t,r,"after")}beforeOrAfter(e,t,r,n){let i,o,s=this._events[e]??[];const a="after"===n?1:0;if("function"!=typeof r)throw new TypeError("listener must be a function");if("function"!=typeof t)throw new TypeError("target must be a function");for(Array.isArray(s)||(this._events[e]=s=[s]),o=s.length,i=s.length;i--;)if(s[i]===t){o=i+a;break}return s.splice(o,0,r),this}on(e,t){return super.on(e,t)}addListener(e,t){return super.addListener(e,t)}prependListener(e,t){return super.prependListener(e,t)}prependOnceListener(e,t){return super.prependOnceListener(e,t)}removeAllListeners(e){return super.removeAllListeners(e)}removeListener(e,t){return super.removeListener(e,t)}eventNames(){return super.eventNames()}listeners(e){return super.listeners(e)}listenerCount(e){return super.listenerCount(e)}getMaxListeners(){return super.getMaxListeners()}setMaxListeners(e){return super.setMaxListeners(e)}}Hd.AsyncEventEmitter=Kd;var Wd={};Object.defineProperty(Wd,"__esModule",{value:!0}),Wd.Lock=void 0;Wd.Lock=class{constructor(){this.permits=1,this.promiseResolverQueue=[]}async acquire(){return this.permits>0?(this.permits-=1,Promise.resolve(!0)):new Promise((e=>this.promiseResolverQueue.push(e)))}release(){if(this.permits+=1,this.permits>1&&this.promiseResolverQueue.length>0)console.warn("Lock.permits should never be > 0 when there is someone waiting.");else if(1===this.permits&&this.promiseResolverQueue.length>0){this.permits-=1;const e=this.promiseResolverQueue.shift();e&&e(!0)}}};var Vd={},Zd={};function Gd(){throw new Error("setTimeout has not been defined")}function Jd(){throw new Error("clearTimeout has not been defined")}var Yd=Gd,Xd=Jd;function Qd(e){if(Yd===setTimeout)return setTimeout(e,0);if((Yd===Gd||!Yd)&&setTimeout)return Yd=setTimeout,setTimeout(e,0);try{return Yd(e,0)}catch(t){try{return Yd.call(null,e,0)}catch(t){return Yd.call(this,e,0)}}}"function"==typeof b.setTimeout&&(Yd=setTimeout),"function"==typeof b.clearTimeout&&(Xd=clearTimeout);var ep,tp=[],rp=!1,np=-1;function ip(){rp&&ep&&(rp=!1,ep.length?tp=ep.concat(tp):np=-1,tp.length&&op())}function op(){if(!rp){var e=Qd(ip);rp=!0;for(var t=tp.length;t;){for(ep=tp,tp=[];++np1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),Vp(t)?r.showHidden=t:t&&hg(r,t),Qp(r.showHidden)&&(r.showHidden=!1),Qp(r.depth)&&(r.depth=2),Qp(r.colors)&&(r.colors=!1),Qp(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=Dp),qp(r,e,r.depth)}function Dp(e,t){var r=zp.styles[t];return r?"["+zp.colors[r][0]+"m"+e+"["+zp.colors[r][1]+"m":e}function Hp(e,t){return e}function qp(e,t,r){if(e.customInspect&&t&&ig(t.inspect)&&t.inspect!==zp&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return Yp(n)||(n=qp(e,n,r)),n}var i=function(e,t){if(Qp(t))return e.stylize("undefined","undefined");if(Yp(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(Jp(t))return e.stylize(""+t,"number");if(Vp(t))return e.stylize(""+t,"boolean");if(Zp(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),ng(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return Fp(t);if(0===o.length){if(ig(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(eg(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(rg(t))return e.stylize(Date.prototype.toString.call(t),"date");if(ng(t))return Fp(t)}var c,u="",l=!1,h=["{","}"];(Wp(t)&&(l=!0,h=["[","]"]),ig(t))&&(u=" [Function"+(t.name?": "+t.name:"")+"]");return eg(t)&&(u=" "+RegExp.prototype.toString.call(t)),rg(t)&&(u=" "+Date.prototype.toUTCString.call(t)),ng(t)&&(u=" "+Fp(t)),0!==o.length||l&&0!=t.length?r<0?eg(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),c=l?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(c,u,h)):h[0]+u+h[1]}function Fp(e){return"["+Error.prototype.toString.call(e)+"]"}function Kp(e,t,r,n,i,o){var s,a,c;if((c=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=c.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):c.set&&(a=e.stylize("[Setter]","special")),fg(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(c.value)<0?(a=Zp(r)?qp(e,c.value,null):qp(e,c.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),Qp(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function Wp(e){return Array.isArray(e)}function Vp(e){return"boolean"==typeof e}function Zp(e){return null===e}function Gp(e){return null==e}function Jp(e){return"number"==typeof e}function Yp(e){return"string"==typeof e}function Xp(e){return"symbol"==typeof e}function Qp(e){return void 0===e}function eg(e){return tg(e)&&"[object RegExp]"===ag(e)}function tg(e){return"object"==typeof e&&null!==e}function rg(e){return tg(e)&&"[object Date]"===ag(e)}function ng(e){return tg(e)&&("[object Error]"===ag(e)||e instanceof Error)}function ig(e){return"function"==typeof e}function og(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e}function sg(e){return C.isBuffer(e)}function ag(e){return Object.prototype.toString.call(e)}function cg(e){return e<10?"0"+e.toString(10):e.toString(10)}zp.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]},zp.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};var ug=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function lg(){console.log("%s - %s",function(){var e=new Date,t=[cg(e.getHours()),cg(e.getMinutes()),cg(e.getSeconds())].join(":");return[e.getDate(),ug[e.getMonth()],t].join(" ")}(),Pp.apply(null,arguments))}function hg(e,t){if(!t||!tg(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function fg(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var dg="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function pg(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');if(dg&&e[dg]){var t;if("function"!=typeof(t=e[dg]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(t,dg,{value:t,enumerable:!1,writable:!1,configurable:!0}),t}function t(){for(var t,r,n=new Promise((function(e,n){t=e,r=n})),i=[],o=0;o0?this.tail.next=t:this.head=t,this.tail=t,++this.length},bg.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},bg.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}},bg.prototype.clear=function(){this.head=this.tail=null,this.length=0},bg.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},bg.prototype.concat=function(e){if(0===this.length)return C.alloc(0);if(1===this.length)return this.head.data;for(var t=C.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var vg=C.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 _g(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!vg(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=Sg;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=xg;break;default:return void(this.write=Eg)}this.charBuffer=new C(6),this.charReceived=0,this.charLength=0}function Eg(e){return e.toString(this.encoding)}function Sg(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function xg(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}_g.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,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 n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=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,n)}return t},_g.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},_g.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},Ig.ReadableState=kg;var Ag=$p("stream");function kg(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof ty&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new bg,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 _g(e.encoding),this.encoding=e.encoding)}function Ig(e){if(!(this instanceof Ig))return new Ig(e);this._readableState=new kg(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_e.call(this)}function Bg(e,t,r,n,i){var o=function(e,t){var r=null;C.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,Og(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var c;!t.decoder||i||n||(r=t.decoder.write(r),c=!t.objectMode&&0===r.length),i||(t.reading=!1),c||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&Og(e))),function(e,t){t.readingMore||(t.readingMore=!0,sp(Lg,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>=Tg?e=Tg:(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 Og(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Ag("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?sp(Mg,e):Mg(e))}function Mg(e){Ag("emit readable"),e.emit("readable"),Ng(e)}function Lg(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=C.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function jg(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,sp($g,t,e))}function $g(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function zg(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return Ag("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?jg(this):Og(this),null;if(0===(e=Rg(e,t))&&t.ended)return 0===t.length&&jg(this),null;var n,i=t.needReadable;return Ag("need readable",i),(0===t.length||t.length-e0?Ug(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&jg(this)),null!==n&&this.emit("data",n),n},Ig.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Ig.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,Ag("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:u;function o(e){Ag("onunpipe"),e===r&&u()}function s(){Ag("onend"),e.end()}n.endEmitted?sp(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;Ag("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,Ng(e))}}(r);e.on("drain",a);var c=!1;function u(){Ag("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",f),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",u),r.removeListener("data",h),c=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var l=!1;function h(t){Ag("ondata"),l=!1,!1!==e.write(t)||l||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==zg(n.pipes,e))&&!c&&(Ag("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,l=!0),r.pause())}function f(t){Ag("onerror",t),g(),e.removeListener("error",f),0===function(e,t){return e.listeners(t).length}(e,"error")&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){Ag("onfinish"),e.removeListener("close",d),g()}function g(){Ag("unpipe"),r.unpipe(e)}return r.on("data",h),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",f),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(Ag("pipe resume"),r.resume()),e},Ig.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 r=t.pipes,n=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},Fg.prototype._write=function(e,t,r){r(new Error("not implemented"))},Fg.prototype._writev=null,Fg.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,Jg(e,t),r&&(t.finished?sp(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Mp(ty,Ig);for(var Xg=Object.keys(Fg.prototype),Qg=0;Qge._pos){var n=r.substr(e._pos);if("x-user-defined"===e._charset){for(var i=new C(n.length),o=0;oe._pos&&(e.push(new C(new Uint8Array(s.result.slice(e._pos)))),e._pos=s.result.byteLength)},s.onload=function(){e.push(null)},s.readAsArrayBuffer(r)}e._xhr.readyState===ly&&"ms-stream"!==e._mode&&e.push(null)},Mp(fy,Fg);var dy=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","date","dnt","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","user-agent","via"];fy.prototype.setHeader=function(e,t){var r=e.toLowerCase();-1===dy.indexOf(r)&&(this._headers[r]={name:e,value:t})},fy.prototype.getHeader=function(e){return this._headers[e.toLowerCase()].value},fy.prototype.removeHeader=function(e){delete this._headers[e.toLowerCase()]},fy.prototype._onFinish=function(){var e=this;if(!e._destroyed){var t,r=e._opts,n=e._headers;if("POST"!==r.method&&"PUT"!==r.method&&"PATCH"!==r.method||(t=function(){if(void 0!==bp)return bp;try{new b.Blob([new ArrayBuffer(1)]),bp=!0}catch(e){bp=!1}return bp}()?new b.Blob(e._body.map((function(e){return function(e){if(e instanceof Uint8Array){if(0===e.byteOffset&&e.byteLength===e.buffer.byteLength)return e.buffer;if("function"==typeof e.buffer.slice)return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}if(me(e)){for(var t=new Uint8Array(e.length),r=e.length,n=0;n(e+t/l)/t;function d(e){const t=c,r=BigInt(3),i=BigInt(6),o=BigInt(11),s=BigInt(22),a=BigInt(23),u=BigInt(44),h=BigInt(88),f=e*e*e%t,d=f*f*e%t,g=(0,n.pow2)(d,r,t)*d%t,y=(0,n.pow2)(g,r,t)*d%t,m=(0,n.pow2)(y,l,t)*f%t,w=(0,n.pow2)(m,o,t)*m%t,b=(0,n.pow2)(w,s,t)*w%t,v=(0,n.pow2)(b,u,t)*b%t,_=(0,n.pow2)(v,h,t)*v%t,E=(0,n.pow2)(_,u,t)*b%t,S=(0,n.pow2)(E,r,t)*d%t,A=(0,n.pow2)(S,a,t)*w%t,x=(0,n.pow2)(A,i,t)*f%t,k=(0,n.pow2)(x,l,t);if(!p.eql(p.sqr(k),e))throw new Error("Cannot find square root");return k}const p=(0,n.Field)(c,void 0,void 0,{sqrt:d});e.secp256k1=(0,a.createCurve)({a:BigInt(0),b:BigInt(7),Fp:p,n:u,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=u,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),i=-h*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=r,a=BigInt("0x100000000000000000000000000000000"),c=f(s*e,t),l=f(-i*e,t);let d=(0,n.mod)(e-c*r-l*o,t),p=(0,n.mod)(-c*i-l*s,t);const g=d>a,y=p>a;if(g&&(d=t-d),y&&(p=t-p),d>a||p>a)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:g,k1:d,k2neg:y,k2:p}}}},t.sha256);const g=BigInt(0),y=e=>"bigint"==typeof e&&ge.charCodeAt(0))));n=(0,o.concatBytes)(r,r),m[e]=n}return(0,t.sha256)((0,o.concatBytes)(n,...r))}const b=e=>e.toRawBytes(!0).slice(1),v=e=>(0,o.numberToBytesBE)(e,32),_=e=>(0,n.mod)(e,c),E=e=>(0,n.mod)(e,u),S=e.secp256k1.ProjectivePoint;function A(t){let r=e.secp256k1.utils.normPrivateKeyToScalar(t),n=S.fromPrivateKey(r);return{scalar:n.hasEvenY()?r:E(-r),bytes:b(n)}}function x(e){if(!y(e))throw new Error("bad x: need 0 < x < p");const t=_(e*e);let r=d(_(t*e+BigInt(7)));r%l!==g&&(r=_(-r));const n=new S(e,r,h);return n.assertValidity(),n}function k(...e){return E((0,o.bytesToNumberBE)(w("BIP0340/challenge",...e)))}function B(e){return A(e).bytes}function I(e,t,n=(0,r.randomBytes)(32)){const i=(0,o.ensureBytes)("message",e),{bytes:s,scalar:a}=A(t),c=(0,o.ensureBytes)("auxRand",n,32),u=v(a^(0,o.bytesToNumberBE)(w("BIP0340/aux",c))),h=w("BIP0340/nonce",u,s,i),l=E((0,o.bytesToNumberBE)(h));if(l===g)throw new Error("sign failed: k is zero");const{bytes:f,scalar:d}=A(l),p=k(f,s,i),y=new Uint8Array(64);if(y.set(f,0),y.set(v(E(d+p*a)),32),!T(y,i,s))throw new Error("sign: Invalid signature produced");return y}function T(e,t,r){const n=(0,o.ensureBytes)("signature",e,64),i=(0,o.ensureBytes)("message",t),s=(0,o.ensureBytes)("publicKey",r,32);try{const e=x((0,o.bytesToNumberBE)(s)),t=(0,o.bytesToNumberBE)(n.subarray(0,32));if(!y(t))return!1;const r=(0,o.bytesToNumberBE)(n.subarray(32,64));if(!(e=>"bigint"==typeof e&&gS.BASE.multiplyAndAddUnsafe(e,t,r))(e,r,E(-a));return!(!c||!c.hasEvenY()||c.toAffine().x!==t)}catch(e){return!1}}e.schnorr={getPublicKey:B,sign:I,verify:T,utils:{randomPrivateKey:e.secp256k1.utils.randomPrivateKey,lift_x:x,pointToBytes:b,numberToBytesBE:o.numberToBytesBE,bytesToNumberBE:o.bytesToNumberBE,taggedHash:w,mod:n.mod}};const R=(()=>(0,s.isogenyMap)(p,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map((e=>e.map((e=>BigInt(e)))))))(),O=(()=>(0,i.mapToCurveSimpleSWU)(p,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:p.create(BigInt("-11"))}))(),L=(()=>(0,s.createHasher)(e.secp256k1.ProjectivePoint,(e=>{const{x:t,y:r}=O(p.create(e[0]));return R(t,r)}),{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:p.ORDER,m:1,k:128,expand:"xmd",hash:t.sha256}))();e.hashToCurve=L.hashToCurve,e.encodeToCurve=L.encodeToCurve}(Eh),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.secp256k1=void 0;var t=Eh;Object.defineProperty(e,"secp256k1",{enumerable:!0,get:function(){return t.secp256k1}})}(_h),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.MAX_WITHDRAWALS_PER_PAYLOAD=e.RLP_EMPTY_STRING=e.KECCAK256_RLP=e.KECCAK256_RLP_S=e.KECCAK256_RLP_ARRAY=e.KECCAK256_RLP_ARRAY_S=e.KECCAK256_NULL=e.KECCAK256_NULL_S=e.TWO_POW256=e.SECP256K1_ORDER_DIV_2=e.SECP256K1_ORDER=e.MAX_INTEGER_BIGINT=e.MAX_INTEGER=e.MAX_UINT64=void 0;const t=Ur,r=_h;e.MAX_UINT64=BigInt("0xffffffffffffffff"),e.MAX_INTEGER=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),e.MAX_INTEGER_BIGINT=BigInt("115792089237316195423570985008687907853269984665640564039457584007913129639935"),e.SECP256K1_ORDER=r.secp256k1.CURVE.n,e.SECP256K1_ORDER_DIV_2=r.secp256k1.CURVE.n/BigInt(2),e.TWO_POW256=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000"),e.KECCAK256_NULL_S="c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",e.KECCAK256_NULL=t.Buffer.from(e.KECCAK256_NULL_S,"hex"),e.KECCAK256_RLP_ARRAY_S="1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",e.KECCAK256_RLP_ARRAY=t.Buffer.from(e.KECCAK256_RLP_ARRAY_S,"hex"),e.KECCAK256_RLP_S="56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",e.KECCAK256_RLP=t.Buffer.from(e.KECCAK256_RLP_S,"hex"),e.RLP_EMPTY_STRING=t.Buffer.from([128]),e.MAX_WITHDRAWALS_PER_PAYLOAD=16}(vh);var nf={};Object.defineProperty(nf,"__esModule",{value:!0}),nf.GWEI_TO_WEI=void 0,nf.GWEI_TO_WEI=BigInt(1e9);var of={},sf={};function af(e){if(Array.isArray(e)){const t=[];let r=0;for(let n=0;ne.length)throw new Error("invalid RLP (safeSlice): end slice of Uint8Array out-of-bounds");return e.slice(t,r)}function uf(e){if(0===e[0])throw new Error("invalid RLP: extra zeros");return gf(pf(e))}function hf(e,t){if(e<56)return Uint8Array.from([e+t]);const r=bf(e),n=bf(t+55+r.length/2);return Uint8Array.from(yf(n+r))}function lf(e,t=!1){if(null==e||0===e.length)return Uint8Array.from([]);const r=ff(_f(e));if(t)return r;if(0!==r.remainder.length)throw new Error("invalid RLP: remainder must be zero");return r.data}function ff(e){let t,r,n,i,o;const s=[],a=e[0];if(a<=127)return{data:e.slice(0,1),remainder:e.slice(1)};if(a<=183){if(t=a-127,n=128===a?Uint8Array.from([]):cf(e,1,t),2===t&&n[0]<128)throw new Error("invalid RLP encoding: invalid prefix, single byte < 0x80 are not prefixed");return{data:n,remainder:e.slice(t)}}if(a<=191){if(r=a-182,e.length-1e.length)throw new Error("invalid RLP: total length is larger than the data");for(i=cf(e,r,n);i.length;)o=ff(i),s.push(o.data),i=o.remainder;return{data:s,remainder:e.slice(n)}}}Object.defineProperty(sf,"__esModule",{value:!0}),sf.RLP=sf.utils=sf.decode=sf.encode=void 0,sf.encode=af,sf.decode=lf;const df=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function pf(e){let t="";for(let r=0;re+t.length),0),r=new Uint8Array(t);for(let t=0,n=0;t=2&&"0"===e[0]&&"x"===e[1]}function _f(e){if(e instanceof Uint8Array)return e;if("string"==typeof e)return vf(e)?yf(function(e){return e.length%2?`0${e}`:e}("string"!=typeof(t=e)?t:vf(t)?t.slice(2):t)):wf(e);var t;if("number"==typeof e||"bigint"==typeof e)return e?yf(bf(e)):Uint8Array.from([]);if(null==e)return Uint8Array.from([]);throw new Error("toBytes: received unsupported type "+typeof e)}sf.utils={bytesToHex:pf,concatBytes:mf,hexToBytes:yf,utf8ToBytes:wf},sf.RLP={encode:af,decode:lf};var Ef={},Sf={},Af={};Object.defineProperty(Af,"__esModule",{value:!0}),Af.add5L=Af.add5H=Af.add4H=Af.add4L=Af.add3H=Af.add3L=Af.add=Af.rotlBL=Af.rotlBH=Af.rotlSL=Af.rotlSH=Af.rotr32L=Af.rotr32H=Af.rotrBL=Af.rotrBH=Af.rotrSL=Af.rotrSH=Af.shrSL=Af.shrSH=Af.toBig=Af.split=Af.fromBig=void 0;const xf=BigInt(2**32-1),kf=BigInt(32);function Bf(e,t=!1){return t?{h:Number(e&xf),l:Number(e>>kf&xf)}:{h:0|Number(e>>kf&xf),l:0|Number(e&xf)}}function If(e,t=!1){let r=new Uint32Array(e.length),n=new Uint32Array(e.length);for(let i=0;iBigInt(e>>>0)<>>0);Af.toBig=Tf;const Rf=(e,t,r)=>e>>>r;Af.shrSH=Rf;const Of=(e,t,r)=>e<<32-r|t>>>r;Af.shrSL=Of;const Lf=(e,t,r)=>e>>>r|t<<32-r;Af.rotrSH=Lf;const Mf=(e,t,r)=>e<<32-r|t>>>r;Af.rotrSL=Mf;const Cf=(e,t,r)=>e<<64-r|t>>>r-32;Af.rotrBH=Cf;const Pf=(e,t,r)=>e>>>r-32|t<<64-r;Af.rotrBL=Pf;const Nf=(e,t)=>t;Af.rotr32H=Nf;const Uf=(e,t)=>e;Af.rotr32L=Uf;const jf=(e,t,r)=>e<>>32-r;Af.rotlSH=jf;const $f=(e,t,r)=>t<>>32-r;Af.rotlSL=$f;const Hf=(e,t,r)=>t<>>64-r;Af.rotlBH=Hf;const zf=(e,t,r)=>e<>>64-r;function Df(e,t,r,n){const i=(t>>>0)+(n>>>0);return{h:e+r+(i/2**32|0)|0,l:0|i}}Af.rotlBL=zf,Af.add=Df;const Ff=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0);Af.add3L=Ff;const qf=(e,t,r,n)=>t+r+n+(e/2**32|0)|0;Af.add3H=qf;const Kf=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0);Af.add4L=Kf;const Wf=(e,t,r,n,i)=>t+r+n+i+(e/2**32|0)|0;Af.add4H=Wf;const Vf=(e,t,r,n,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(i>>>0);Af.add5L=Vf;const Zf=(e,t,r,n,i,o)=>t+r+n+i+o+(e/2**32|0)|0;Af.add5H=Zf;const Gf={fromBig:Bf,split:If,toBig:Tf,shrSH:Rf,shrSL:Of,rotrSH:Lf,rotrSL:Mf,rotrBH:Cf,rotrBL:Pf,rotr32H:Nf,rotr32L:Uf,rotlSH:jf,rotlSL:$f,rotlBH:Hf,rotlBL:zf,add:Df,add3L:Ff,add3H:qf,add4L:Kf,add4H:Wf,add5H:Zf,add5L:Vf};Af.default=Gf,Object.defineProperty(Sf,"__esModule",{value:!0}),Sf.shake256=Sf.shake128=Sf.keccak_512=Sf.keccak_384=Sf.keccak_256=Sf.keccak_224=Sf.sha3_512=Sf.sha3_384=Sf.sha3_256=Sf.sha3_224=Sf.Keccak=Sf.keccakP=void 0;const Jf=xh,Yf=Af,Xf=Mh,[Qf,ed,td]=[[],[],[]],rd=BigInt(0),nd=BigInt(1),id=BigInt(2),od=BigInt(7),sd=BigInt(256),ad=BigInt(113);for(let e=0,t=nd,r=1,n=0;e<24;e++){[r,n]=[n,(2*r+3*n)%5],Qf.push(2*(5*n+r)),ed.push((e+1)*(e+2)/2%64);let i=rd;for(let e=0;e<7;e++)t=(t<>od)*ad)%sd,t&id&&(i^=nd<<(nd<r>32?(0,Yf.rotlBH)(e,t,r):(0,Yf.rotlSH)(e,t,r),ld=(e,t,r)=>r>32?(0,Yf.rotlBL)(e,t,r):(0,Yf.rotlSL)(e,t,r);function fd(e,t=24){const r=new Uint32Array(10);for(let n=24-t;n<24;n++){for(let t=0;t<10;t++)r[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){const n=(t+8)%10,i=(t+2)%10,o=r[i],s=r[i+1],a=hd(o,s,1)^r[n],c=ld(o,s,1)^r[n+1];for(let r=0;r<50;r+=10)e[t+r]^=a,e[t+r+1]^=c}let t=e[2],i=e[3];for(let r=0;r<24;r++){const n=ed[r],o=hd(t,i,n),s=ld(t,i,n),a=Qf[r];t=e[a],i=e[a+1],e[a]=o,e[a+1]=s}for(let t=0;t<50;t+=10){for(let n=0;n<10;n++)r[n]=e[t+n];for(let n=0;n<10;n++)e[t+n]^=~r[(n+2)%10]&r[(n+4)%10]}e[0]^=cd[n],e[1]^=ud[n]}r.fill(0)}Sf.keccakP=fd;class dd extends Xf.Hash{constructor(e,t,r,n=!1,i=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=n,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,(0,Jf.number)(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=(0,Xf.u32)(this.state)}keccak(){fd(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){(0,Jf.exists)(this);const{blockLen:t,state:r}=this,n=(e=(0,Xf.toBytes)(e)).length;for(let i=0;i=r&&this.keccak();const o=Math.min(r-this.posOut,i-n);e.set(t.subarray(this.posOut,this.posOut+o),n),this.posOut+=o,n+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return(0,Jf.number)(e),this.xofInto(new Uint8Array(e))}digestInto(e){if((0,Jf.output)(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:r,outputLen:n,rounds:i,enableXOF:o}=this;return e||(e=new dd(t,r,n,o,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=r,e.outputLen=n,e.enableXOF=o,e.destroyed=this.destroyed,e}}Sf.Keccak=dd;const pd=(e,t,r)=>(0,Xf.wrapConstructor)((()=>new dd(t,e,r)));Sf.sha3_224=pd(6,144,28),Sf.sha3_256=pd(6,136,32),Sf.sha3_384=pd(6,104,48),Sf.sha3_512=pd(6,72,64),Sf.keccak_224=pd(1,144,28),Sf.keccak_256=pd(1,136,32),Sf.keccak_384=pd(1,104,48),Sf.keccak_512=pd(1,72,64);const gd=(e,t,r)=>(0,Xf.wrapXOFConstructorWithOpts)(((n={})=>new dd(t,e,void 0===n.dkLen?r:n.dkLen,!0)));function yd(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}Sf.shake128=gd(31,168,16),Sf.shake256=gd(31,136,32);var md={exports:{}};!function(e,t){var r=Cr&&Cr.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.crypto=t.wrapHash=t.equalsBytes=t.hexToBytes=t.bytesToUtf8=t.utf8ToBytes=t.createView=t.concatBytes=t.toHex=t.bytesToHex=t.assertBytes=t.assertBool=void 0;const n=r(xh),i=Mh,o=n.default.bool;t.assertBool=o;const s=n.default.bytes;t.assertBytes=s;var a=Mh;Object.defineProperty(t,"bytesToHex",{enumerable:!0,get:function(){return a.bytesToHex}}),Object.defineProperty(t,"toHex",{enumerable:!0,get:function(){return a.bytesToHex}}),Object.defineProperty(t,"concatBytes",{enumerable:!0,get:function(){return a.concatBytes}}),Object.defineProperty(t,"createView",{enumerable:!0,get:function(){return a.createView}}),Object.defineProperty(t,"utf8ToBytes",{enumerable:!0,get:function(){return a.utf8ToBytes}}),t.bytesToUtf8=function(e){if(!(e instanceof Uint8Array))throw new TypeError("bytesToUtf8 expected Uint8Array, got "+typeof e);return(new TextDecoder).decode(e)},t.hexToBytes=function(e){const t=e.startsWith("0x")?e.substring(2):e;return(0,i.hexToBytes)(t)},t.equalsBytes=function(e,t){if(e.length!==t.length)return!1;for(let r=0;r(n.default.bytes(t),e(t))},t.crypto=(()=>{const t="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,r=yd.bind(e);return{node:r&&!t?r("crypto"):void 0,web:t}})()}(md,md.exports),Object.defineProperty(Ef,"__esModule",{value:!0}),Ef.keccak512=Ef.keccak384=Ef.keccak256=Ef.keccak224=void 0;const wd=Sf,bd=md.exports;Ef.keccak224=(0,bd.wrapHash)(wd.keccak_224),Ef.keccak256=(()=>{const e=(0,bd.wrapHash)(wd.keccak_256);return e.create=wd.keccak_256.create,e})(),Ef.keccak384=(0,bd.wrapHash)(wd.keccak_384),Ef.keccak512=(0,bd.wrapHash)(wd.keccak_512);var vd={},_d={},Ed={};function Sd(e){if("string"!=typeof e)throw new Error("[isHexPrefixed] input must be type 'string', received type "+typeof e);return"0"===e[0]&&"x"===e[1]}Object.defineProperty(Ed,"__esModule",{value:!0}),Ed.isHexString=Ed.getKeys=Ed.fromAscii=Ed.fromUtf8=Ed.toAscii=Ed.arrayContainsArray=Ed.getBinarySize=Ed.padToEven=Ed.stripHexPrefix=Ed.isHexPrefixed=void 0,Ed.isHexPrefixed=Sd;function Ad(e){let t=e;if("string"!=typeof t)throw new Error("[padToEven] value must be type 'string', received "+typeof t);return t.length%2&&(t=`0${t}`),t}Ed.stripHexPrefix=e=>{if("string"!=typeof e)throw new Error("[stripHexPrefix] input must be type 'string', received "+typeof e);return Sd(e)?e.slice(2):e},Ed.padToEven=Ad,Ed.getBinarySize=function(e){if("string"!=typeof e)throw new Error("[getBinarySize] method requires input type 'string', received "+typeof e);return C.byteLength(e,"utf8")},Ed.arrayContainsArray=function(e,t,r){if(!0!==Array.isArray(e))throw new Error(`[arrayContainsArray] method requires input 'superset' to be an array, got type '${typeof e}'`);if(!0!==Array.isArray(t))throw new Error(`[arrayContainsArray] method requires input 'subset' to be an array, got type '${typeof t}'`);return t[!0===r?"some":"every"]((t=>e.indexOf(t)>=0))},Ed.toAscii=function(e){let t="",r=0;const n=e.length;for("0x"===e.substring(0,2)&&(r=2);r0&&e.length!==2+2*t)},Object.defineProperty(_d,"__esModule",{value:!0}),_d.assertIsString=_d.assertIsArray=_d.assertIsBuffer=_d.assertIsHexString=void 0;const xd=Ed;_d.assertIsHexString=function(e){if(!(0,xd.isHexString)(e)){throw new Error(`This method only supports 0x-prefixed hex strings but input was: ${e}`)}};_d.assertIsBuffer=function(e){if(!C.isBuffer(e)){throw new Error(`This method only supports Buffer but input was: ${e}`)}};_d.assertIsArray=function(e){if(!Array.isArray(e)){throw new Error(`This method only supports number arrays but input was: ${e}`)}};_d.assertIsString=function(e){if("string"!=typeof e){throw new Error(`This method only supports strings but input was: ${e}`)}},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.intToUnpaddedBuffer=e.bigIntToUnpaddedBuffer=e.bigIntToHex=e.bufArrToArr=e.arrToBufArr=e.validateNoLeadingZeroes=e.baToJSON=e.toUtf8=e.short=e.addHexPrefix=e.toUnsigned=e.fromSigned=e.bufferToInt=e.bigIntToBuffer=e.bufferToBigInt=e.bufferToHex=e.toBuffer=e.unpadHexString=e.unpadArray=e.unpadBuffer=e.setLengthRight=e.setLengthLeft=e.zeros=e.intToBuffer=e.intToHex=void 0;const t=_d,r=Ed;e.intToHex=function(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Received an invalid integer type: ${e}`);return`0x${e.toString(16)}`};e.intToBuffer=function(t){const n=(0,e.intToHex)(t);return C.from((0,r.padToEven)(n.slice(2)),"hex")};e.zeros=function(e){return C.allocUnsafe(e).fill(0)};const n=function(t,r,n){const i=(0,e.zeros)(r);return n?t.length0&&"0"===t.toString();)t=(e=e.slice(1))[0];return e};e.unpadBuffer=function(e){return(0,t.assertIsBuffer)(e),i(e)};e.unpadArray=function(e){return(0,t.assertIsArray)(e),i(e)};e.unpadHexString=function(e){return(0,t.assertIsHexString)(e),e=(0,r.stripHexPrefix)(e),"0x"+i(e)};e.toBuffer=function(t){if(null==t)return C.allocUnsafe(0);if(C.isBuffer(t))return C.from(t);if(Array.isArray(t)||t instanceof Uint8Array)return C.from(t);if("string"==typeof t){if(!(0,r.isHexString)(t))throw new Error(`Cannot convert string to buffer. toBuffer only supports 0x-prefixed hex strings and this string was given: ${t}`);return C.from((0,r.padToEven)((0,r.stripHexPrefix)(t)),"hex")}if("number"==typeof t)return(0,e.intToBuffer)(t);if("bigint"==typeof t){if(t0&&0===r[0])throw new Error(`${t} cannot have leading zeroes, received: ${r.toString("hex")}`)},e.arrToBufArr=function e(t){return Array.isArray(t)?t.map((t=>e(t))):C.from(t)},e.bufArrToArr=function e(t){return Array.isArray(t)?t.map((t=>e(t))):Uint8Array.from(t??[])};e.bigIntToHex=e=>"0x"+e.toString(16),e.bigIntToUnpaddedBuffer=function(t){return(0,e.unpadBuffer)(s(t))},e.intToUnpaddedBuffer=function(t){return(0,e.unpadBuffer)((0,e.intToBuffer)(t))}}(vd),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.accountBodyToRLP=e.accountBodyToSlim=e.accountBodyFromSlim=e.isZeroAddress=e.zeroAddress=e.importPublic=e.privateToAddress=e.privateToPublic=e.publicToAddress=e.pubToAddress=e.isValidPublic=e.isValidPrivate=e.generateAddress2=e.generateAddress=e.isValidChecksumAddress=e.toChecksumAddress=e.isValidAddress=e.Account=void 0;const t=sf,r=Ef,n=_h,i=md.exports,o=vd,s=vh,a=_d,c=Ed,u=BigInt(0);class h{constructor(e=u,t=u,r=s.KECCAK256_RLP,n=s.KECCAK256_NULL){this.nonce=e,this.balance=t,this.storageRoot=r,this.codeHash=n,this._validate()}static fromAccountData(e){const{nonce:t,balance:r,storageRoot:n,codeHash:i}=e;return new h(void 0!==t?(0,o.bufferToBigInt)((0,o.toBuffer)(t)):void 0,void 0!==r?(0,o.bufferToBigInt)((0,o.toBuffer)(r)):void 0,void 0!==n?(0,o.toBuffer)(n):void 0,void 0!==i?(0,o.toBuffer)(i):void 0)}static fromRlpSerializedAccount(e){const r=(0,o.arrToBufArr)(t.RLP.decode(Uint8Array.from(e)));if(!Array.isArray(r))throw new Error("Invalid serialized account input. Must be array");return this.fromValuesArray(r)}static fromValuesArray(e){const[t,r,n,i]=e;return new h((0,o.bufferToBigInt)(t),(0,o.bufferToBigInt)(r),n,i)}_validate(){if(this.nonce=8?l+=n[e].toUpperCase():l+=n[e];return l};e.isValidChecksumAddress=function(t,r){return(0,e.isValidAddress)(t)&&(0,e.toChecksumAddress)(t,r)===t};e.generateAddress=function(e,n){return(0,a.assertIsBuffer)(e),(0,a.assertIsBuffer)(n),(0,o.bufferToBigInt)(n)===BigInt(0)?C.from((0,r.keccak256)(t.RLP.encode((0,o.bufArrToArr)([e,null])))).slice(-20):C.from((0,r.keccak256)(t.RLP.encode((0,o.bufArrToArr)([e,n])))).slice(-20)};e.generateAddress2=function(e,t,n){if((0,a.assertIsBuffer)(e),(0,a.assertIsBuffer)(t),(0,a.assertIsBuffer)(n),20!==e.length)throw new Error("Expected from to be of length 20");if(32!==t.length)throw new Error("Expected salt to be of length 32");const i=(0,r.keccak256)(C.concat([C.from("ff","hex"),e,t,(0,r.keccak256)(n)]));return(0,o.toBuffer)(i).slice(-20)};e.isValidPrivate=function(e){return n.secp256k1.utils.isValidPrivateKey(e)};e.isValidPublic=function(e,t=!1){if((0,a.assertIsBuffer)(e),64===e.length)try{return n.secp256k1.ProjectivePoint.fromHex(C.concat([C.from([4]),e])),!0}catch(e){return!1}if(!t)return!1;try{return n.secp256k1.ProjectivePoint.fromHex(e),!0}catch(e){return!1}};e.pubToAddress=function(e,t=!1){if((0,a.assertIsBuffer)(e),t&&64!==e.length&&(e=C.from(n.secp256k1.ProjectivePoint.fromHex(e).toRawBytes(!1).slice(1))),64!==e.length)throw new Error("Expected pubKey to be of length 64");return C.from((0,r.keccak256)(e)).slice(-20)},e.publicToAddress=e.pubToAddress;e.privateToPublic=function(e){return(0,a.assertIsBuffer)(e),C.from(n.secp256k1.ProjectivePoint.fromPrivateKey(e).toRawBytes(!1).slice(1))};e.privateToAddress=function(t){return(0,e.publicToAddress)((0,e.privateToPublic)(t))};e.importPublic=function(e){return(0,a.assertIsBuffer)(e),64!==e.length&&(e=C.from(n.secp256k1.ProjectivePoint.fromHex(e).toRawBytes(!1).slice(1))),e};e.zeroAddress=function(){const e=(0,o.zeros)(20);return(0,o.bufferToHex)(e)};function l(e){const[t,r,n,i]=e;return[t,r,0===(0,o.arrToBufArr)(n).length?s.KECCAK256_RLP:n,0===(0,o.arrToBufArr)(i).length?s.KECCAK256_NULL:i]}e.isZeroAddress=function(t){try{(0,a.assertIsString)(t)}catch(e){return!1}return(0,e.zeroAddress)()===t},e.accountBodyFromSlim=l;const f=new Uint8Array(0);e.accountBodyToSlim=function(e){const[t,r,n,i]=e;return[t,r,(0,o.arrToBufArr)(n).equals(s.KECCAK256_RLP)?f:n,(0,o.arrToBufArr)(i).equals(s.KECCAK256_NULL)?f:i]},e.accountBodyToRLP=function(e,r=!0){const n=r?l(e):e;return(0,o.arrToBufArr)(t.RLP.encode(n))}}(of);var kd={};Object.defineProperty(kd,"__esModule",{value:!0}),kd.Address=void 0;const Bd=of,Id=vd;class Td{constructor(e){if(20!==e.length)throw new Error("Invalid address length");this.buf=e}static zero(){return new Td((0,Id.zeros)(20))}static fromString(e){if(!(0,Bd.isValidAddress)(e))throw new Error("Invalid address");return new Td((0,Id.toBuffer)(e))}static fromPublicKey(e){if(!C.isBuffer(e))throw new Error("Public key should be Buffer");const t=(0,Bd.pubToAddress)(e);return new Td(t)}static fromPrivateKey(e){if(!C.isBuffer(e))throw new Error("Private key should be Buffer");const t=(0,Bd.privateToAddress)(e);return new Td(t)}static generate(e,t){if("bigint"!=typeof t)throw new Error("Expected nonce to be a bigint");return new Td((0,Bd.generateAddress)(e.buf,(0,Id.bigIntToBuffer)(t)))}static generate2(e,t,r){if(!C.isBuffer(t))throw new Error("Expected salt to be a Buffer");if(!C.isBuffer(r))throw new Error("Expected initCode to be a Buffer");return new Td((0,Bd.generateAddress2)(e.buf,t,r))}equals(e){return this.buf.equals(e.buf)}isZero(){return this.equals(Td.zero())}isPrecompileOrSystemAddress(){const e=(0,Id.bufferToBigInt)(this.buf),t=BigInt(0),r=BigInt("0xffff");return e>=t&&e<=r}toString(){return"0x"+this.buf.toString("hex")}toBuffer(){return C.from(this.buf)}}kd.Address=Td;var Rd={},Od={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.toType=e.TypeOutput=void 0;const t=vd,r=Ed;var n;!function(e){e[e.Number=0]="Number",e[e.BigInt=1]="BigInt",e[e.Buffer=2]="Buffer",e[e.PrefixedHexString=3]="PrefixedHexString"}(n=e.TypeOutput||(e.TypeOutput={})),e.toType=function(e,i){if(null===e)return null;if(void 0===e)return;if("string"==typeof e&&!(0,r.isHexString)(e))throw new Error(`A string must be provided with a 0x-prefix, given: ${e}`);if("number"==typeof e&&!Number.isSafeInteger(e))throw new Error("The provided number is greater than MAX_SAFE_INTEGER (please use an alternative input type)");const o=(0,t.toBuffer)(e);switch(i){case n.Buffer:return o;case n.BigInt:return(0,t.bufferToBigInt)(o);case n.Number:{const e=(0,t.bufferToBigInt)(o);if(e>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("The provided number is greater than MAX_SAFE_INTEGER (please use an alternative output type)");return Number(e)}case n.PrefixedHexString:return(0,t.bufferToHex)(o);default:throw new Error("unknown outputType")}}}(Od),Object.defineProperty(Rd,"__esModule",{value:!0}),Rd.Withdrawal=void 0;const Ld=kd,Md=vd,Cd=Od;class Pd{constructor(e,t,r,n){this.index=e,this.validatorIndex=t,this.address=r,this.amount=n}static fromWithdrawalData(e){const{index:t,validatorIndex:r,address:n,amount:i}=e,o=(0,Cd.toType)(t,Cd.TypeOutput.BigInt),s=(0,Cd.toType)(r,Cd.TypeOutput.BigInt),a=new Ld.Address((0,Cd.toType)(n,Cd.TypeOutput.Buffer)),c=(0,Cd.toType)(i,Cd.TypeOutput.BigInt);return new Pd(o,s,a,c)}static fromValuesArray(e){if(4!==e.length)throw Error(`Invalid withdrawalArray length expected=4 actual=${e.length}`);const[t,r,n,i]=e;return Pd.fromWithdrawalData({index:t,validatorIndex:r,address:n,amount:i})}static toBufferArray(e){const{index:t,validatorIndex:r,address:n,amount:i}=e,o=(0,Cd.toType)(t,Cd.TypeOutput.BigInt)===BigInt(0)?C.alloc(0):(0,Cd.toType)(t,Cd.TypeOutput.Buffer),s=(0,Cd.toType)(r,Cd.TypeOutput.BigInt)===BigInt(0)?C.alloc(0):(0,Cd.toType)(r,Cd.TypeOutput.Buffer);let a;a=n instanceof Ld.Address?n.buf:(0,Cd.toType)(n,Cd.TypeOutput.Buffer);return[o,s,a,(0,Cd.toType)(i,Cd.TypeOutput.BigInt)===BigInt(0)?C.alloc(0):(0,Cd.toType)(i,Cd.TypeOutput.Buffer)]}raw(){return Pd.toBufferArray(this)}toValue(){return{index:this.index,validatorIndex:this.validatorIndex,address:this.address.buf,amount:this.amount}}toJSON(){return{index:(0,Md.bigIntToHex)(this.index),validatorIndex:(0,Md.bigIntToHex)(this.validatorIndex),address:"0x"+this.address.buf.toString("hex"),amount:(0,Md.bigIntToHex)(this.amount)}}}Rd.Withdrawal=Pd;var Nd={};Object.defineProperty(Nd,"__esModule",{value:!0}),Nd.hashPersonalMessage=Nd.isValidSignature=Nd.fromRpcSig=Nd.toCompactSig=Nd.toRpcSig=Nd.ecrecover=Nd.ecsign=void 0;const Ud=Ef,jd=_h,$d=vd,Hd=vh,zd=_d;function Dd(e,t){return e===BigInt(0)||e===BigInt(1)?e:void 0===t?e-BigInt(27):e-(t*BigInt(2)+BigInt(35))}function Fd(e){return e===BigInt(0)||e===BigInt(1)}Nd.ecsign=function(e,t,r){const n=jd.secp256k1.sign(e,t),i=n.toCompactRawBytes();return{r:C.from(i.slice(0,32)),s:C.from(i.slice(32,64)),v:void 0===r?BigInt(n.recovery+27):BigInt(n.recovery+35)+BigInt(r)*BigInt(2)}};Nd.ecrecover=function(e,t,r,n,i){const o=C.concat([(0,$d.setLengthLeft)(r,32),(0,$d.setLengthLeft)(n,32)],64),s=Dd(t,i);if(!Fd(s))throw new Error("Invalid signature v value");const a=jd.secp256k1.Signature.fromCompact(o).addRecoveryBit(Number(s)).recoverPublicKey(e);return C.from(a.toRawBytes(!1).slice(1))};Nd.toRpcSig=function(e,t,r,n){if(!Fd(Dd(e,n)))throw new Error("Invalid signature v value");return(0,$d.bufferToHex)(C.concat([(0,$d.setLengthLeft)(t,32),(0,$d.setLengthLeft)(r,32),(0,$d.toBuffer)(e)]))};Nd.toCompactSig=function(e,t,r,n){if(!Fd(Dd(e,n)))throw new Error("Invalid signature v value");let i=r;return(e>BigInt(28)&&e%BigInt(2)===BigInt(1)||e===BigInt(1)||e===BigInt(28))&&(i=C.from(r),i[0]|=128),(0,$d.bufferToHex)(C.concat([(0,$d.setLengthLeft)(t,32),(0,$d.setLengthLeft)(i,32)]))};Nd.fromRpcSig=function(e){const t=(0,$d.toBuffer)(e);let r,n,i;if(t.length>=65)r=t.slice(0,32),n=t.slice(32,64),i=(0,$d.bufferToBigInt)(t.slice(64));else{if(64!==t.length)throw new Error("Invalid signature length");r=t.slice(0,32),n=t.slice(32,64),i=BigInt((0,$d.bufferToInt)(t.slice(32,33))>>7),n[0]&=127}return i<27&&(i+=BigInt(27)),{v:i,r:r,s:n}};Nd.isValidSignature=function(e,t,r,n=!0,i){if(32!==t.length||32!==r.length)return!1;if(!Fd(Dd(e,i)))return!1;const o=(0,$d.bufferToBigInt)(t),s=(0,$d.bufferToBigInt)(r);return!(o===BigInt(0)||o>=Hd.SECP256K1_ORDER||s===BigInt(0)||s>=Hd.SECP256K1_ORDER)&&!(n&&s>=Hd.SECP256K1_ORDER_DIV_2)};Nd.hashPersonalMessage=function(e){(0,zd.assertIsBuffer)(e);const t=C.from(`Ethereum Signed Message:\n${e.length}`,"utf-8");return C.from((0,Ud.keccak256)(C.concat([t,e])))};var qd={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.compactBytesToNibbles=e.bytesToNibbles=e.nibblesToCompactBytes=e.nibblesToBytes=e.hasTerminator=void 0;e.hasTerminator=e=>e.length>0&&16===e[e.length-1];e.nibblesToBytes=(e,t)=>{for(let r=0,n=0;n{let r=0;(0,e.hasTerminator)(t)&&(r=1,t=t.subarray(0,t.length-1));const n=new Uint8Array(t.length/2+1);return n[0]=r<<5,1&~t.length||(n[0]|=16,n[0]|=t[0],t=t.subarray(1)),(0,e.nibblesToBytes)(t,n.subarray(1)),n};e.bytesToNibbles=e=>{const t=2*e.length+1,r=new Uint8Array(t);for(let t=0;t{if(0===t.length)return t;let r=(0,e.bytesToNibbles)(t);r[0]<2&&(r=r.subarray(0,r.length-1));const n=2-(1&r[0]);return r.subarray(n)}}(qd);var Kd={},Wd=Pr(Be);Object.defineProperty(Kd,"__esModule",{value:!0}),Kd.AsyncEventEmitter=void 0;const Vd=Wd;class Zd extends Vd.EventEmitter{emit(e,...t){let[r,n]=t;const i=this;let o=i._events[e]??[];return void 0===n&&"function"==typeof r&&(n=r,r=void 0),"newListener"!==e&&"removeListener"!==e||(r={event:r,fn:n},n=void 0),o=Array.isArray(o)?o:[o],async function(e,t,r){let n;for await(const i of t)try{i.length<2?i.call(e,r):await new Promise(((t,n)=>{i.call(e,r,(e=>{e?n(e):t()}))}))}catch(e){n=e}if(n)throw n}(i,o.slice(),r).then(n).catch(n),i.listenerCount(e)>0}once(e,t){const r=this;let n;if("function"!=typeof t)throw new TypeError("listener must be a function");return n=t.length>=2?function(i,o){r.removeListener(e,n),t(i,o)}:function(i){r.removeListener(e,n),t(i,n)},r.on(e,n),r}first(e,t){let r=this._events[e]??[];if("function"!=typeof t)throw new TypeError("listener must be a function");return Array.isArray(r)||(this._events[e]=r=[r]),r.unshift(t),this}before(e,t,r){return this.beforeOrAfter(e,t,r)}after(e,t,r){return this.beforeOrAfter(e,t,r,"after")}beforeOrAfter(e,t,r,n){let i,o,s=this._events[e]??[];const a="after"===n?1:0;if("function"!=typeof r)throw new TypeError("listener must be a function");if("function"!=typeof t)throw new TypeError("target must be a function");for(Array.isArray(s)||(this._events[e]=s=[s]),o=s.length,i=s.length;i--;)if(s[i]===t){o=i+a;break}return s.splice(o,0,r),this}on(e,t){return super.on(e,t)}addListener(e,t){return super.addListener(e,t)}prependListener(e,t){return super.prependListener(e,t)}prependOnceListener(e,t){return super.prependOnceListener(e,t)}removeAllListeners(e){return super.removeAllListeners(e)}removeListener(e,t){return super.removeListener(e,t)}eventNames(){return super.eventNames()}listeners(e){return super.listeners(e)}listenerCount(e){return super.listenerCount(e)}getMaxListeners(){return super.getMaxListeners()}setMaxListeners(e){return super.setMaxListeners(e)}}Kd.AsyncEventEmitter=Zd;var Gd={};Object.defineProperty(Gd,"__esModule",{value:!0}),Gd.Lock=void 0;Gd.Lock=class{constructor(){this.permits=1,this.promiseResolverQueue=[]}async acquire(){return this.permits>0?(this.permits-=1,Promise.resolve(!0)):new Promise((e=>this.promiseResolverQueue.push(e)))}release(){if(this.permits+=1,this.permits>1&&this.promiseResolverQueue.length>0)console.warn("Lock.permits should never be > 0 when there is someone waiting.");else if(1===this.permits&&this.promiseResolverQueue.length>0){this.permits-=1;const e=this.promiseResolverQueue.shift();e&&e(!0)}}};var Jd={},Yd={};function Xd(){throw new Error("setTimeout has not been defined")}function Qd(){throw new Error("clearTimeout has not been defined")}var ep=Xd,tp=Qd;function rp(e){if(ep===setTimeout)return setTimeout(e,0);if((ep===Xd||!ep)&&setTimeout)return ep=setTimeout,setTimeout(e,0);try{return ep(e,0)}catch(t){try{return ep.call(null,e,0)}catch(t){return ep.call(this,e,0)}}}"function"==typeof b.setTimeout&&(ep=setTimeout),"function"==typeof b.clearTimeout&&(tp=clearTimeout);var np,ip=[],op=!1,sp=-1;function ap(){op&&np&&(op=!1,np.length?ip=np.concat(ip):sp=-1,ip.length&&cp())}function cp(){if(!op){var e=rp(ap);op=!0;for(var t=ip.length;t;){for(np=ip,ip=[];++sp1)for(var r=1;r=i)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),Jp(t)?r.showHidden=t:t&&pg(r,t),rg(r.showHidden)&&(r.showHidden=!1),rg(r.depth)&&(r.depth=2),rg(r.colors)&&(r.colors=!1),rg(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=qp),Wp(r,e,r.depth)}function qp(e,t){var r=Fp.styles[t];return r?"["+Fp.colors[r][0]+"m"+e+"["+Fp.colors[r][1]+"m":e}function Kp(e,t){return e}function Wp(e,t,r){if(e.customInspect&&t&&ag(t.inspect)&&t.inspect!==Fp&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return eg(n)||(n=Wp(e,n,r)),n}var i=function(e,t){if(rg(t))return e.stylize("undefined","undefined");if(eg(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(Qp(t))return e.stylize(""+t,"number");if(Jp(t))return e.stylize(""+t,"boolean");if(Yp(t))return e.stylize("null","null")}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),sg(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return Vp(t);if(0===o.length){if(ag(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(ng(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(og(t))return e.stylize(Date.prototype.toString.call(t),"date");if(sg(t))return Vp(t)}var c,u="",h=!1,l=["{","}"];(Gp(t)&&(h=!0,l=["[","]"]),ag(t))&&(u=" [Function"+(t.name?": "+t.name:"")+"]");return ng(t)&&(u=" "+RegExp.prototype.toString.call(t)),og(t)&&(u=" "+Date.prototype.toUTCString.call(t)),sg(t)&&(u=" "+Vp(t)),0!==o.length||h&&0!=t.length?r<0?ng(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),c=h?function(e,t,r,n,i){for(var o=[],s=0,a=t.length;s60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(c,u,l)):l[0]+u+l[1]}function Vp(e){return"["+Error.prototype.toString.call(e)+"]"}function Zp(e,t,r,n,i,o){var s,a,c;if((c=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=c.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):c.set&&(a=e.stylize("[Setter]","special")),gg(n,i)||(s="["+i+"]"),a||(e.seen.indexOf(c.value)<0?(a=Yp(r)?Wp(e,c.value,null):Wp(e,c.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),rg(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function Gp(e){return Array.isArray(e)}function Jp(e){return"boolean"==typeof e}function Yp(e){return null===e}function Xp(e){return null==e}function Qp(e){return"number"==typeof e}function eg(e){return"string"==typeof e}function tg(e){return"symbol"==typeof e}function rg(e){return void 0===e}function ng(e){return ig(e)&&"[object RegExp]"===hg(e)}function ig(e){return"object"==typeof e&&null!==e}function og(e){return ig(e)&&"[object Date]"===hg(e)}function sg(e){return ig(e)&&("[object Error]"===hg(e)||e instanceof Error)}function ag(e){return"function"==typeof e}function cg(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e}function ug(e){return C.isBuffer(e)}function hg(e){return Object.prototype.toString.call(e)}function lg(e){return e<10?"0"+e.toString(10):e.toString(10)}Fp.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]},Fp.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};var fg=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function dg(){console.log("%s - %s",function(){var e=new Date,t=[lg(e.getHours()),lg(e.getMinutes()),lg(e.getSeconds())].join(":");return[e.getDate(),fg[e.getMonth()],t].join(" ")}(),jp.apply(null,arguments))}function pg(e,t){if(!t||!ig(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function gg(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var yg="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function mg(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');if(yg&&e[yg]){var t;if("function"!=typeof(t=e[yg]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(t,yg,{value:t,enumerable:!1,writable:!1,configurable:!0}),t}function t(){for(var t,r,n=new Promise((function(e,n){t=e,r=n})),i=[],o=0;o0?this.tail.next=t:this.head=t,this.tail=t,++this.length},Eg.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},Eg.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}},Eg.prototype.clear=function(){this.head=this.tail=null,this.length=0},Eg.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},Eg.prototype.concat=function(e){if(0===this.length)return C.alloc(0);if(1===this.length)return this.head.data;for(var t=C.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var Sg=C.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 Ag(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!Sg(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=kg;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Bg;break;default:return void(this.write=xg)}this.charBuffer=new C(6),this.charReceived=0,this.charLength=0}function xg(e){return e.toString(this.encoding)}function kg(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Bg(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}Ag.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,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 n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=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,n)}return t},Ag.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},Ag.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t},Rg.ReadableState=Tg;var Ig=Dp("stream");function Tg(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof iy&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new Eg,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 Ag(e.encoding),this.encoding=e.encoding)}function Rg(e){if(!(this instanceof Rg))return new Rg(e);this._readableState=new Tg(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),_e.call(this)}function Og(e,t,r,n,i){var o=function(e,t){var r=null;C.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));return r}(t,r);if(o)e.emit("error",o);else if(null===r)t.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,Cg(e)}(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{var c;!t.decoder||i||n||(r=t.decoder.write(r),c=!t.objectMode&&0===r.length),i||(t.reading=!1),c||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&Cg(e))),function(e,t){t.readingMore||(t.readingMore=!0,up(Ng,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>=Lg?e=Lg:(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 Cg(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Ig("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?up(Pg,e):Pg(e))}function Pg(e){Ig("emit readable"),e.emit("readable"),$g(e)}function Ng(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0===(e-=s)){s===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=C.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,s),0===(e-=s)){s===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function zg(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,up(Dg,t,e))}function Dg(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function Fg(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return Ig("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?zg(this):Cg(this),null;if(0===(e=Mg(e,t))&&t.ended)return 0===t.length&&zg(this),null;var n,i=t.needReadable;return Ig("need readable",i),(0===t.length||t.length-e0?Hg(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&zg(this)),null!==n&&this.emit("data",n),n},Rg.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Rg.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,Ig("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:u;function o(e){Ig("onunpipe"),e===r&&u()}function s(){Ig("onend"),e.end()}n.endEmitted?up(i):r.once("end",i),e.on("unpipe",o);var a=function(e){return function(){var t=e._readableState;Ig("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&e.listeners("data").length&&(t.flowing=!0,$g(e))}}(r);e.on("drain",a);var c=!1;function u(){Ig("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",a),e.removeListener("error",f),e.removeListener("unpipe",o),r.removeListener("end",s),r.removeListener("end",u),r.removeListener("data",l),c=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||a()}var h=!1;function l(t){Ig("ondata"),h=!1,!1!==e.write(t)||h||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==Fg(n.pipes,e))&&!c&&(Ig("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,h=!0),r.pause())}function f(t){Ig("onerror",t),g(),e.removeListener("error",f),0===function(e,t){return e.listeners(t).length}(e,"error")&&e.emit("error",t)}function d(){e.removeListener("finish",p),g()}function p(){Ig("onfinish"),e.removeListener("close",d),g()}function g(){Ig("unpipe"),r.unpipe(e)}return r.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",f),e.once("close",d),e.once("finish",p),e.emit("pipe",r),n.flowing||(Ig("pipe resume"),r.resume()),e},Rg.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 r=t.pipes,n=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},Vg.prototype._write=function(e,t,r){r(new Error("not implemented"))},Vg.prototype._writev=null,Vg.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,Qg(e,t),r&&(t.finished?up(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Pp(iy,Rg);for(var ty=Object.keys(Vg.prototype),ry=0;rye._pos){var n=r.substr(e._pos);if("x-user-defined"===e._charset){for(var i=new C(n.length),o=0;oe._pos&&(e.push(new C(new Uint8Array(s.result.slice(e._pos)))),e._pos=s.result.byteLength)},s.onload=function(){e.push(null)},s.readAsArrayBuffer(r)}e._xhr.readyState===dy&&"ms-stream"!==e._mode&&e.push(null)},Pp(gy,Vg);var yy=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","date","dnt","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","user-agent","via"];gy.prototype.setHeader=function(e,t){var r=e.toLowerCase();-1===yy.indexOf(r)&&(this._headers[r]={name:e,value:t})},gy.prototype.getHeader=function(e){return this._headers[e.toLowerCase()].value},gy.prototype.removeHeader=function(e){delete this._headers[e.toLowerCase()]},gy.prototype._onFinish=function(){var e=this;if(!e._destroyed){var t,r=e._opts,n=e._headers;if("POST"!==r.method&&"PUT"!==r.method&&"PATCH"!==r.method||(t=function(){if(void 0!==Ep)return Ep;try{new b.Blob([new ArrayBuffer(1)]),Ep=!0}catch(e){Ep=!1}return Ep}()?new b.Blob(e._body.map((function(e){return function(e){if(e instanceof Uint8Array){if(0===e.byteOffset&&e.byteLength===e.buffer.byteLength)return e.buffer;if("function"==typeof e.buffer.slice)return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}if(me(e)){for(var t=new Uint8Array(e.length),r=e.length,n=0;n= 0x80 (not a basic code point)","invalid-input":"Invalid input"},wy=Math.floor,by=String.fromCharCode;function vy(e){throw new RangeError(my[e])}function _y(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function Ey(e,t,r){var n=0;for(e=r?wy(e/700):e>>1,e+=wy(e/t);e>455;n+=36)e=wy(e/35);return wy(n+36*e/(e+38))}function Sy(e){return function(e,t){var r=e.split("@"),n="";r.length>1&&(n=r[0]+"@",e=r[1]);var i=function(e,t){for(var r=e.length,n=[];r--;)n[r]=t(e[r]);return n}((e=e.replace(yy,".")).split("."),t).join(".");return n+i}(e,(function(e){return gy.test(e)?"xn--"+function(e){var t,r,n,i,o,s,a,c,u,l,h,f,d,p,g,y=[];for(e=function(e){for(var t,r,n=[],i=0,o=e.length;i=55296&&t<=56319&&i=t&&hwy((py-r)/(d=n+1))&&vy("overflow"),r+=(a-t)*d,t=a,s=0;spy&&vy("overflow"),h==t){for(c=r,u=36;!(c<(l=u<=o?1:u>=o+26?26:u-o));u+=36)g=c-l,p=36-l,y.push(by(_y(l+g%p,0))),c=wy(g/p);y.push(by(_y(c,0))),o=Ey(r,d,n==i),r=0,++n}++r,++t}return y.join("")}(e):e}))}function xy(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var Ay=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function ky(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}}function Iy(e,t){if(e.map)return e.map(t);for(var r=[],n=0;n0&&a>s&&(a=s);for(var c=0;c=0?(u=d.substr(0,p),l=d.substr(p+1)):(u=d,l=""),h=decodeURIComponent(u),f=decodeURIComponent(l),xy(i,h)?Ay(i[h])?i[h].push(f):i[h]=[i[h],f]:i[h]=f}return i}const Ry=b.URL,Oy=b.URLSearchParams;var My={parse:Vy,resolve:Xy,resolveObject:Qy,fileURLToPath:Gy,format:Jy,Url:Ly,URL:Ry,URLSearchParams:Oy};function Ly(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var Cy=/^([a-z0-9.+-]+:)/i,Py=/:[0-9]*$/,Ny=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,Uy=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),jy=["'"].concat(Uy),$y=["%","/","?",";","#"].concat(jy),zy=["/","?","#"],Dy=255,Hy=/^[+a-z0-9A-Z_-]{0,63}$/,qy=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,Fy={javascript:!0,"javascript:":!0},Ky={javascript:!0,"javascript:":!0},Wy={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};function Vy(e,t,r){if(e&&tg(e)&&e instanceof Ly)return e;var n=new Ly;return n.parse(e,t,r),n}function Zy(e,t,r,n){if(!Yp(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var i=t.indexOf("?"),o=-1!==i&&i127?E+="x":E+=_[S];if(!E.match(Hy)){var A=v.slice(0,u),k=v.slice(u+1),I=_.match(qy);I&&(A.push(I[1]),k.unshift(I[2])),k.length&&(a="/"+k.join(".")+a),e.hostname=A.join(".");break}}}}e.hostname.length>Dy?e.hostname="":e.hostname=e.hostname.toLowerCase(),b||(e.hostname=Sy(e.hostname)),f=e.port?":"+e.port:"";var B=e.hostname||"";e.host=B+f,e.href+=e.host,b&&(e.hostname=e.hostname.substr(1,e.hostname.length-2),"/"!==a[0]&&(a="/"+a))}if(!Fy[p])for(u=0,h=jy.length;u0)&&n.host.split("@"))&&(n.auth=g.shift(),n.host=n.hostname=g.shift())),n.search=e.search,n.query=e.query,Zp(n.pathname)&&Zp(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n;if(!v.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var E=v.slice(-1)[0],S=(n.host||e.host||v.length>1)&&("."===E||".."===E)||""===E,x=0,A=v.length;A>=0;A--)"."===(E=v[A])?v.splice(A,1):".."===E?(v.splice(A,1),x++):x&&(v.splice(A,1),x--);if(!w&&!b)for(;x--;x)v.unshift("..");!w||""===v[0]||v[0]&&"/"===v[0].charAt(0)||v.unshift(""),S&&"/"!==v.join("/").substr(-1)&&v.push("");var k=""===v[0]||v[0]&&"/"===v[0].charAt(0);return _&&(n.hostname=n.host=k?"":v.length?v.shift():"",(g=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=g.shift(),n.host=n.hostname=g.shift())),(w=w||n.host&&v.length)&&!k&&v.unshift(""),v.length?n.pathname=v.join("/"):(n.pathname=null,n.path=null),Zp(n.pathname)&&Zp(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.auth=e.auth||n.auth,n.slashes=n.slashes||e.slashes,n.href=n.format(),n},Ly.prototype.parseHost=function(){return em(this)};var tm=Object.freeze({__proto__:null,parse:Vy,resolve:Xy,resolveObject:Qy,fileURLToPath:Gy,format:Jy,URL:Ry,URLSearchParams:Oy,default:My,Url:Ly});function rm(e,t){"string"==typeof e&&(e=Vy(e));var r=-1===b.location.protocol.search(/^https?:$/)?"http:":"",n=e.protocol||r,i=e.hostname||e.host,o=e.port,s=e.path||"/";i&&-1!==i.indexOf(":")&&(i="["+i+"]"),e.url=(i?n+"//"+i:"")+(o?":"+o:"")+s,e.method=(e.method||"GET").toUpperCase(),e.headers=e.headers||{};var a=new fy(e);return t&&a.on("response",t),a}function nm(e,t){var r=rm(e,t);return r.end(),r}function im(){}im.defaultMaxSockets=4;var om=["CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REPORT","SEARCH","SUBSCRIBE","TRACE","UNLOCK","UNSUBSCRIBE"],sm={100:"Continue",101:"Switching Protocols",102:"Processing",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",300:"Multiple Choices",301:"Moved Permanently",302:"Moved Temporarily",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Time-out",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Request Entity Too Large",414:"Request-URI Too Large",415:"Unsupported Media Type",416:"Requested Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Unordered Collection",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Time-out",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"},am={request:rm,get:nm,Agent:im,METHODS:om,STATUS_CODES:sm},cm=Rr(Object.freeze({__proto__:null,request:rm,get:nm,Agent:im,METHODS:om,STATUS_CODES:sm,default:am}));function um(e,t){"string"==typeof e&&(e=Vy(e));var r=-1===b.location.protocol.search(/^https?:$/)?"http:":"",n=e.protocol||r,i=e.hostname||e.host,o=e.port,s=e.path||"/";i&&-1!==i.indexOf(":")&&(i="["+i+"]"),e.url=(i?n+"//"+i:"")+(o?":"+o:"")+s,e.method=(e.method||"GET").toUpperCase(),e.headers=e.headers||{};var a=new fy(e);return t&&a.on("response",t),a}function lm(e,t){var r=um(e,t);return r.end(),r}function hm(){}hm.defaultMaxSockets=4;var fm=["CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REPORT","SEARCH","SUBSCRIBE","TRACE","UNLOCK","UNSUBSCRIBE"],dm={100:"Continue",101:"Switching Protocols",102:"Processing",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",300:"Multiple Choices",301:"Moved Permanently",302:"Moved Temporarily",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Time-out",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Request Entity Too Large",414:"Request-URI Too Large",415:"Unsupported Media Type",416:"Requested Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Unordered Collection",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Time-out",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"},pm={request:um,get:lm,Agent:hm,METHODS:fm,STATUS_CODES:dm},gm=Rr(Object.freeze({__proto__:null,request:um,get:lm,Agent:hm,METHODS:fm,STATUS_CODES:dm,default:pm})),ym={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"};function mm(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}function wm(e,t,r,n,i){if(t.subarray&&e.subarray)e.set(t.subarray(r,r+n),i);else for(var o=0;o=0;)e[t]=0}var Sm=256,xm=286,Am=30,km=15,Im=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],Bm=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],Tm=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],Rm=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],Om=new Array(576);Em(Om);var Mm=new Array(60);Em(Mm);var Lm=new Array(512);Em(Lm);var Cm=new Array(256);Em(Cm);var Pm=new Array(29);Em(Pm);var Nm,Um,jm,$m=new Array(Am);function zm(e,t,r,n,i){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=e&&e.length}function Dm(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function Hm(e){return e<256?Lm[e]:Lm[256+(e>>>7)]}function qm(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function Fm(e,t,r){e.bi_valid>16-r?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=r-16):(e.bi_buf|=t<>>=1,r<<=1}while(--t>0);return r>>>1}function Vm(e,t,r){var n,i,o=new Array(16),s=0;for(n=1;n<=km;n++)o[n]=s=s+r[n-1]<<1;for(i=0;i<=t;i++){var a=e[2*i+1];0!==a&&(e[2*i]=Wm(o[a]++,a))}}function Zm(e){var t;for(t=0;t8?qm(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function Jm(e,t,r,n){var i=2*t,o=2*r;return e[i]>1;r>=1;r--)Ym(e,o,r);i=c;do{r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Ym(e,o,1),n=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=n,o[2*i]=o[2*r]+o[2*n],e.depth[i]=(e.depth[r]>=e.depth[n]?e.depth[r]:e.depth[n])+1,o[2*r+1]=o[2*n+1]=i,e.heap[1]=i++,Ym(e,o,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],function(e,t){var r,n,i,o,s,a,c=t.dyn_tree,u=t.max_code,l=t.stat_desc.static_tree,h=t.stat_desc.has_stree,f=t.stat_desc.extra_bits,d=t.stat_desc.extra_base,p=t.stat_desc.max_length,g=0;for(o=0;o<=km;o++)e.bl_count[o]=0;for(c[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;r<573;r++)(o=c[2*c[2*(n=e.heap[r])+1]+1]+1)>p&&(o=p,g++),c[2*n+1]=o,n>u||(e.bl_count[o]++,s=0,n>=d&&(s=f[n-d]),a=c[2*n],e.opt_len+=a*(o+s),h&&(e.static_len+=a*(l[2*n+1]+s)));if(0!==g){do{for(o=p-1;0===e.bl_count[o];)o--;e.bl_count[o]--,e.bl_count[o+1]+=2,e.bl_count[p]--,g-=2}while(g>0);for(o=p;0!==o;o--)for(n=e.bl_count[o];0!==n;)(i=e.heap[--r])>u||(c[2*i+1]!==o&&(e.opt_len+=(o-c[2*i+1])*c[2*i],c[2*i+1]=o),n--)}}(e,t),Vm(o,u,e.bl_count)}function ew(e,t,r){var n,i,o=-1,s=t[1],a=0,c=7,u=4;for(0===s&&(c=138,u=3),t[2*(r+1)+1]=65535,n=0;n<=r;n++)i=s,s=t[2*(n+1)+1],++a>=7;n=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)}function sw(e,t,r,n){var i,o,s=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=function(e){var t,r=4093624447;for(t=0;t<=31;t++,r>>>=1)if(1&r&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t=3&&0===e.bl_tree[2*Rm[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),i=e.opt_len+3+7>>>3,(o=e.static_len+3+7>>>3)<=i&&(i=o)):i=o=r+5,r+4<=i&&-1!==t?iw(e,t,r,n):4===e.strategy||o===i?(Fm(e,2+(n?1:0),3),Xm(e,Om,Mm)):(Fm(e,4+(n?1:0),3),function(e,t,r,n){var i;for(Fm(e,t-257,5),Fm(e,r-1,5),Fm(e,n-4,4),i=0;i>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&r,e.last_lit++,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(Cm[r]+Sm+1)]++,e.dyn_dtree[2*Hm(t)]++),e.last_lit===e.lit_bufsize-1}function cw(e,t,r,n){for(var i=65535&e,o=e>>>16&65535,s=0;0!==r;){r-=s=r>2e3?2e3:r;do{o=o+(i=i+t[n++]|0)|0}while(--s);i%=65521,o%=65521}return i|o<<16}var uw=function(){for(var e,t=[],r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}();function lw(e,t,r,n){var i=uw,o=n+r;e^=-1;for(var s=n;s>>8^i[255&(e^t[s])];return~e}var hw,fw=-2,dw=258,pw=262,gw=103,yw=113,mw=666;function ww(e,t){return e.msg=ym[t],t}function bw(e){return(e<<1)-(e>4?9:0)}function vw(e){for(var t=e.length;--t>=0;)e[t]=0}function _w(e){var t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(wm(e.output,t.pending_buf,t.pending_out,r,e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))}function Ew(e,t){sw(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,_w(e.strm)}function Sw(e,t){e.pending_buf[e.pending++]=t}function xw(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function Aw(e,t,r,n){var i=e.avail_in;return i>n&&(i=n),0===i?0:(e.avail_in-=i,wm(t,e.input,e.next_in,i,r),1===e.state.wrap?e.adler=cw(e.adler,t,i,r):2===e.state.wrap&&(e.adler=lw(e.adler,t,i,r)),e.next_in+=i,e.total_in+=i,i)}function kw(e,t){var r,n,i=e.max_chain_length,o=e.strstart,s=e.prev_length,a=e.nice_match,c=e.strstart>e.w_size-pw?e.strstart-(e.w_size-pw):0,u=e.window,l=e.w_mask,h=e.prev,f=e.strstart+dw,d=u[o+s-1],p=u[o+s];e.prev_length>=e.good_match&&(i>>=2),a>e.lookahead&&(a=e.lookahead);do{if(u[(r=t)+s]===p&&u[r+s-1]===d&&u[r]===u[o]&&u[++r]===u[o+1]){o+=2,r++;do{}while(u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&os){if(e.match_start=t,s=n,n>=a)break;d=u[o+s-1],p=u[o+s]}}}while((t=h[t&l])>c&&0!=--i);return s<=e.lookahead?s:e.lookahead}function Iw(e){var t,r,n,i,o,s=e.w_size;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=s+(s-pw)){wm(e.window,e.window,s,s,0),e.match_start-=s,e.strstart-=s,e.block_start-=s,t=r=e.hash_size;do{n=e.head[--t],e.head[t]=n>=s?n-s:0}while(--r);t=r=s;do{n=e.prev[--t],e.prev[t]=n>=s?n-s:0}while(--r);i+=s}if(0===e.strm.avail_in)break;if(r=Aw(e.strm,e.window,e.strstart+e.lookahead,i),e.lookahead+=r,e.lookahead+e.insert>=3)for(o=e.strstart-e.insert,e.ins_h=e.window[o],e.ins_h=(e.ins_h<=3&&(e.ins_h=(e.ins_h<=3)if(n=aw(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=(e.ins_h<=3&&(e.ins_h=(e.ins_h<4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-3,n=aw(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=i&&(e.ins_h=(e.ins_h<5||t<0)return e?ww(e,fw):fw;if(n=e.state,!e.output||!e.input&&0!==e.avail_in||n.status===mw&&4!==t)return ww(e,0===e.avail_out?-5:fw);if(n.strm=e,r=n.last_flush,n.last_flush=t,42===n.status)if(2===n.wrap)e.adler=0,Sw(n,31),Sw(n,139),Sw(n,8),n.gzhead?(Sw(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),Sw(n,255&n.gzhead.time),Sw(n,n.gzhead.time>>8&255),Sw(n,n.gzhead.time>>16&255),Sw(n,n.gzhead.time>>24&255),Sw(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),Sw(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(Sw(n,255&n.gzhead.extra.length),Sw(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=lw(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(Sw(n,0),Sw(n,0),Sw(n,0),Sw(n,0),Sw(n,0),Sw(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),Sw(n,3),n.status=yw);else{var s=8+(n.w_bits-8<<4)<<8;s|=(n.strategy>=2||n.level<2?0:n.level<6?1:6===n.level?2:3)<<6,0!==n.strstart&&(s|=32),s+=31-s%31,n.status=yw,xw(n,s),0!==n.strstart&&(xw(n,e.adler>>>16),xw(n,65535&e.adler)),e.adler=1}if(69===n.status)if(n.gzhead.extra){for(i=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>i&&(e.adler=lw(e.adler,n.pending_buf,n.pending-i,i)),_w(e),i=n.pending,n.pending!==n.pending_buf_size));)Sw(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>i&&(e.adler=lw(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=73)}else n.status=73;if(73===n.status)if(n.gzhead.name){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=lw(e.adler,n.pending_buf,n.pending-i,i)),_w(e),i=n.pending,n.pending===n.pending_buf_size)){o=1;break}o=n.gzindexi&&(e.adler=lw(e.adler,n.pending_buf,n.pending-i,i)),0===o&&(n.gzindex=0,n.status=91)}else n.status=91;if(91===n.status)if(n.gzhead.comment){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=lw(e.adler,n.pending_buf,n.pending-i,i)),_w(e),i=n.pending,n.pending===n.pending_buf_size)){o=1;break}o=n.gzindexi&&(e.adler=lw(e.adler,n.pending_buf,n.pending-i,i)),0===o&&(n.status=gw)}else n.status=gw;if(n.status===gw&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&_w(e),n.pending+2<=n.pending_buf_size&&(Sw(n,255&e.adler),Sw(n,e.adler>>8&255),e.adler=0,n.status=yw)):n.status=yw),0!==n.pending){if(_w(e),0===e.avail_out)return n.last_flush=-1,0}else if(0===e.avail_in&&bw(t)<=bw(r)&&4!==t)return ww(e,-5);if(n.status===mw&&0!==e.avail_in)return ww(e,-5);if(0!==e.avail_in||0!==n.lookahead||0!==t&&n.status!==mw){var a=2===n.strategy?function(e,t){for(var r;;){if(0===e.lookahead&&(Iw(e),0===e.lookahead)){if(0===t)return 1;break}if(e.match_length=0,r=aw(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(Ew(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(Ew(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(Ew(e,!1),0===e.strm.avail_out)?1:2}(n,t):3===n.strategy?function(e,t){for(var r,n,i,o,s=e.window;;){if(e.lookahead<=dw){if(Iw(e),e.lookahead<=dw&&0===t)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(n=s[i=e.strstart-1])===s[++i]&&n===s[++i]&&n===s[++i]){o=e.strstart+dw;do{}while(n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&ie.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(r=aw(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=aw(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(Ew(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(Ew(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(Ew(e,!1),0===e.strm.avail_out)?1:2}(n,t):hw[n.level].func(n,t);if(3!==a&&4!==a||(n.status=mw),1===a||3===a)return 0===e.avail_out&&(n.last_flush=-1),0;if(2===a&&(1===t?ow(n):5!==t&&(iw(n,0,0,!1),3===t&&(vw(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),_w(e),0===e.avail_out))return n.last_flush=-1,0}return 4!==t?0:n.wrap<=0?1:(2===n.wrap?(Sw(n,255&e.adler),Sw(n,e.adler>>8&255),Sw(n,e.adler>>16&255),Sw(n,e.adler>>24&255),Sw(n,255&e.total_in),Sw(n,e.total_in>>8&255),Sw(n,e.total_in>>16&255),Sw(n,e.total_in>>24&255)):(xw(n,e.adler>>>16),xw(n,65535&e.adler)),_w(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?0:1)}hw=[new Rw(0,0,0,0,(function(e,t){var r=65535;for(r>e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(Iw(e),0===e.lookahead&&0===t)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var n=e.block_start+r;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,Ew(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-pw&&(Ew(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(Ew(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(Ew(e,!1),e.strm.avail_out),1)})),new Rw(4,4,8,4,Bw),new Rw(4,5,16,8,Bw),new Rw(4,6,32,32,Bw),new Rw(4,4,16,16,Tw),new Rw(8,16,32,32,Tw),new Rw(8,16,128,128,Tw),new Rw(8,32,128,256,Tw),new Rw(32,128,258,1024,Tw),new Rw(32,258,258,4096,Tw)];function Cw(e,t){var r,n,i,o,s,a,c,u,l,h,f,d,p,g,y,m,w,b,v,_,E,S,x,A,k;r=e.state,n=e.next_in,A=e.input,i=n+(e.avail_in-5),o=e.next_out,k=e.output,s=o-(t-e.avail_out),a=o+(e.avail_out-257),c=r.dmax,u=r.wsize,l=r.whave,h=r.wnext,f=r.window,d=r.hold,p=r.bits,g=r.lencode,y=r.distcode,m=(1<>>=v=b>>>24,p-=v,0===(v=b>>>16&255))k[o++]=65535&b;else{if(!(16&v)){if(64&v){if(32&v){r.mode=12;break e}e.msg="invalid literal/length code",r.mode=30;break e}b=g[(65535&b)+(d&(1<>>=v,p-=v),p<15&&(d+=A[n++]<>>=v=b>>>24,p-=v,16&(v=b>>>16&255)){if(E=65535&b,p<(v&=15)&&(d+=A[n++]<c){e.msg="invalid distance too far back",r.mode=30;break e}if(d>>>=v,p-=v,E>(v=o-s)){if((v=E-v)>l&&r.sane){e.msg="invalid distance too far back",r.mode=30;break e}if(S=0,x=f,0===h){if(S+=u-v,v<_){_-=v;do{k[o++]=f[S++]}while(--v);S=o-E,x=k}}else if(h2;)k[o++]=x[S++],k[o++]=x[S++],k[o++]=x[S++],_-=3;_&&(k[o++]=x[S++],_>1&&(k[o++]=x[S++]))}else{S=o-E;do{k[o++]=k[S++],k[o++]=k[S++],k[o++]=k[S++],_-=3}while(_>2);_&&(k[o++]=k[S++],_>1&&(k[o++]=k[S++]))}break}if(64&v){e.msg="invalid distance code",r.mode=30;break e}b=y[(65535&b)+(d&(1<>3,d&=(1<<(p-=_<<3))-1,e.next_in=n,e.next_out=o,e.avail_in=n=1&&0===R[_];_--);if(E>_&&(E=_),0===_)return i[o++]=20971520,i[o++]=20971520,a.bits=1,0;for(v=1;v<_&&0===R[v];v++);for(E0&&(0===e||1!==_))return-1;for(O[1]=0,w=1;w852||2===e&&k>592)return 1;for(;;){p=w-x,s[b]d?(g=M[L+s[b]],y=B[T+s[b]]):(g=96,y=0),c=1<>x)+(u-=c)]=p<<24|g<<16|y}while(0!==u);for(c=1<>=1;if(0!==c?(I&=c-1,I+=c):I=0,b++,0==--R[w]){if(w===_)break;w=t[r+s[b]]}if(w>E&&(I&h)!==l){for(0===x&&(x=E),f+=v,A=1<<(S=w-x);S+x<_&&!((A-=R[S+x])<=0);)S++,A<<=1;if(k+=1<852||2===e&&k>592)return 1;i[l=I&h]=E<<24|S<<16|f-o}}return 0!==I&&(i[f+I]=w-x<<24|64<<16),a.bits=E,0}var Dw=-2,Hw=12,qw=30;function Fw(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function Kw(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new vm(320),this.work=new vm(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function Ww(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,function(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new _m(852),t.distcode=t.distdyn=new _m(592),t.sane=1,t.back=-1,0):Dw}(e)):Dw}function Vw(e,t){var r,n;return e?(n=new Kw,e.state=n,n.window=null,r=function(e,t){var r,n;return e&&e.state?(n=e.state,t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?Dw:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,Ww(e))):Dw}(e,t),0!==r&&(e.state=null),r):Dw}var Zw,Gw,Jw=!0;function Yw(e){if(Jw){var t;for(Zw=new _m(512),Gw=new _m(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(zw(1,e.lens,0,288,Zw,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;zw(2,e.lens,0,32,Gw,0,e.work,{bits:5}),Jw=!1}e.lencode=Zw,e.lenbits=9,e.distcode=Gw,e.distbits=5}function Xw(e,t){var r,n,i,o,s,a,c,u,l,h,f,d,p,g,y,m,w,b,v,_,E,S,x,A,k=0,I=new bm(4),B=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return Dw;(r=e.state).mode===Hw&&(r.mode=13),s=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,n=e.input,a=e.avail_in,u=r.hold,l=r.bits,h=a,f=c,S=0;e:for(;;)switch(r.mode){case 1:if(0===r.wrap){r.mode=13;break}for(;l<16;){if(0===a)break e;a--,u+=n[o++]<>>8&255,r.check=lw(r.check,I,2,0),u=0,l=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&u)<<8)+(u>>8))%31){e.msg="incorrect header check",r.mode=qw;break}if(8!=(15&u)){e.msg="unknown compression method",r.mode=qw;break}if(l-=4,E=8+(15&(u>>>=4)),0===r.wbits)r.wbits=E;else if(E>r.wbits){e.msg="invalid window size",r.mode=qw;break}r.dmax=1<>8&1),512&r.flags&&(I[0]=255&u,I[1]=u>>>8&255,r.check=lw(r.check,I,2,0)),u=0,l=0,r.mode=3;case 3:for(;l<32;){if(0===a)break e;a--,u+=n[o++]<>>8&255,I[2]=u>>>16&255,I[3]=u>>>24&255,r.check=lw(r.check,I,4,0)),u=0,l=0,r.mode=4;case 4:for(;l<16;){if(0===a)break e;a--,u+=n[o++]<>8),512&r.flags&&(I[0]=255&u,I[1]=u>>>8&255,r.check=lw(r.check,I,2,0)),u=0,l=0,r.mode=5;case 5:if(1024&r.flags){for(;l<16;){if(0===a)break e;a--,u+=n[o++]<>>8&255,r.check=lw(r.check,I,2,0)),u=0,l=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&((d=r.length)>a&&(d=a),d&&(r.head&&(E=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),wm(r.head.extra,n,o,d,E)),512&r.flags&&(r.check=lw(r.check,n,d,o)),a-=d,o+=d,r.length-=d),r.length))break e;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===a)break e;d=0;do{E=n[o+d++],r.head&&E&&r.length<65536&&(r.head.name+=String.fromCharCode(E))}while(E&&d>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=Hw;break;case 10:for(;l<32;){if(0===a)break e;a--,u+=n[o++]<>>=7&l,l-=7&l,r.mode=27;break}for(;l<3;){if(0===a)break e;a--,u+=n[o++]<>>=1)){case 0:r.mode=14;break;case 1:if(Yw(r),r.mode=20,6===t){u>>>=2,l-=2;break e}break;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=qw}u>>>=2,l-=2;break;case 14:for(u>>>=7&l,l-=7&l;l<32;){if(0===a)break e;a--,u+=n[o++]<>>16^65535)){e.msg="invalid stored block lengths",r.mode=qw;break}if(r.length=65535&u,u=0,l=0,r.mode=15,6===t)break e;case 15:r.mode=16;case 16:if(d=r.length){if(d>a&&(d=a),d>c&&(d=c),0===d)break e;wm(i,n,o,d,s),a-=d,o+=d,c-=d,s+=d,r.length-=d;break}r.mode=Hw;break;case 17:for(;l<14;){if(0===a)break e;a--,u+=n[o++]<>>=5,l-=5,r.ndist=1+(31&u),u>>>=5,l-=5,r.ncode=4+(15&u),u>>>=4,l-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=qw;break}r.have=0,r.mode=18;case 18:for(;r.have>>=3,l-=3}for(;r.have<19;)r.lens[B[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,x={bits:r.lenbits},S=zw(0,r.lens,0,19,r.lencode,0,r.work,x),r.lenbits=x.bits,S){e.msg="invalid code lengths set",r.mode=qw;break}r.have=0,r.mode=19;case 19:for(;r.have>>16&255,w=65535&k,!((y=k>>>24)<=l);){if(0===a)break e;a--,u+=n[o++]<>>=y,l-=y,r.lens[r.have++]=w;else{if(16===w){for(A=y+2;l>>=y,l-=y,0===r.have){e.msg="invalid bit length repeat",r.mode=qw;break}E=r.lens[r.have-1],d=3+(3&u),u>>>=2,l-=2}else if(17===w){for(A=y+3;l>>=y)),u>>>=3,l-=3}else{for(A=y+7;l>>=y)),u>>>=7,l-=7}if(r.have+d>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=qw;break}for(;d--;)r.lens[r.have++]=E}}if(r.mode===qw)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=qw;break}if(r.lenbits=9,x={bits:r.lenbits},S=zw(1,r.lens,0,r.nlen,r.lencode,0,r.work,x),r.lenbits=x.bits,S){e.msg="invalid literal/lengths set",r.mode=qw;break}if(r.distbits=6,r.distcode=r.distdyn,x={bits:r.distbits},S=zw(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,x),r.distbits=x.bits,S){e.msg="invalid distances set",r.mode=qw;break}if(r.mode=20,6===t)break e;case 20:r.mode=21;case 21:if(a>=6&&c>=258){e.next_out=s,e.avail_out=c,e.next_in=o,e.avail_in=a,r.hold=u,r.bits=l,Cw(e,f),s=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,n=e.input,a=e.avail_in,u=r.hold,l=r.bits,r.mode===Hw&&(r.back=-1);break}for(r.back=0;m=(k=r.lencode[u&(1<>>16&255,w=65535&k,!((y=k>>>24)<=l);){if(0===a)break e;a--,u+=n[o++]<>b)])>>>16&255,w=65535&k,!(b+(y=k>>>24)<=l);){if(0===a)break e;a--,u+=n[o++]<>>=b,l-=b,r.back+=b}if(u>>>=y,l-=y,r.back+=y,r.length=w,0===m){r.mode=26;break}if(32&m){r.back=-1,r.mode=Hw;break}if(64&m){e.msg="invalid literal/length code",r.mode=qw;break}r.extra=15&m,r.mode=22;case 22:if(r.extra){for(A=r.extra;l>>=r.extra,l-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;m=(k=r.distcode[u&(1<>>16&255,w=65535&k,!((y=k>>>24)<=l);){if(0===a)break e;a--,u+=n[o++]<>b)])>>>16&255,w=65535&k,!(b+(y=k>>>24)<=l);){if(0===a)break e;a--,u+=n[o++]<>>=b,l-=b,r.back+=b}if(u>>>=y,l-=y,r.back+=y,64&m){e.msg="invalid distance code",r.mode=qw;break}r.offset=w,r.extra=15&m,r.mode=24;case 24:if(r.extra){for(A=r.extra;l>>=r.extra,l-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=qw;break}r.mode=25;case 25:if(0===c)break e;if(d=f-c,r.offset>d){if((d=r.offset-d)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=qw;break}d>r.wnext?(d-=r.wnext,p=r.wsize-d):p=r.wnext-d,d>r.length&&(d=r.length),g=r.window}else g=i,p=s-r.offset,d=r.length;d>c&&(d=c),c-=d,r.length-=d;do{i[s++]=g[p++]}while(--d);0===r.length&&(r.mode=21);break;case 26:if(0===c)break e;i[s++]=r.length,c--,r.mode=21;break;case 27:if(r.wrap){for(;l<32;){if(0===a)break e;a--,u|=n[o++]<=o.wsize?(wm(o.window,t,r-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):((i=o.wsize-o.wnext)>n&&(i=n),wm(o.window,t,r-n,i,o.wnext),(n-=i)?(wm(o.window,t,r-n,n,0),o.wnext=n,o.whave=o.wsize):(o.wnext+=i,o.wnext===o.wsize&&(o.wnext=0),o.whave7)throw new TypeError("Bad argument");this.mode=e,this.init_done=!1,this.write_in_progress=!1,this.pending_close=!1,this.windowBits=0,this.level=0,this.memLevel=0,this.strategy=0,this.dictionary=null}function tb(e,t){for(var r=0;r15&&(s=2,n-=16),i<1||i>9||8!==r||n<8||n>15||t<0||t>9||o<0||o>4)return ww(e,fw);8===n&&(n=9);var a=new Ow;return e.state=a,a.strm=e,a.wrap=s,a.gzhead=null,a.w_bits=n,a.w_size=1<nb.Z_MAX_CHUNK))throw new Error("Invalid chunk size: "+e.chunkSize);if(e.windowBits&&(e.windowBitsnb.Z_MAX_WINDOWBITS))throw new Error("Invalid windowBits: "+e.windowBits);if(e.level&&(e.levelnb.Z_MAX_LEVEL))throw new Error("Invalid compression level: "+e.level);if(e.memLevel&&(e.memLevelnb.Z_MAX_MEMLEVEL))throw new Error("Invalid memLevel: "+e.memLevel);if(e.strategy&&e.strategy!=nb.Z_FILTERED&&e.strategy!=nb.Z_HUFFMAN_ONLY&&e.strategy!=nb.Z_RLE&&e.strategy!=nb.Z_FIXED&&e.strategy!=nb.Z_DEFAULT_STRATEGY)throw new Error("Invalid strategy: "+e.strategy);if(e.dictionary&&!C.isBuffer(e.dictionary))throw new Error("Invalid dictionary: it should be a Buffer instance");this._binding=new nb.Zlib(t);var r=this;this._hadError=!1,this._binding.onerror=function(e,t){r._binding=null,r._hadError=!0;var n=new Error(e);n.errno=t,n.code=ib[t],r.emit("error",n)};var n=nb.Z_DEFAULT_COMPRESSION;"number"==typeof e.level&&(n=e.level);var i=nb.Z_DEFAULT_STRATEGY;"number"==typeof e.strategy&&(i=e.strategy),this._binding.init(e.windowBits||nb.Z_DEFAULT_WINDOWBITS,n,e.memLevel||nb.Z_DEFAULT_MEMLEVEL,i,e.dictionary),this._buffer=new C(this._chunkSize),this._offset=0,this._closed=!1,this._level=n,this._strategy=i,this.once("end",this.close)}Object.keys(ib).forEach((function(e){ib[ib[e]]=e})),Mp(Pb,oy),Pb.prototype.params=function(e,t,r){if(enb.Z_MAX_LEVEL)throw new RangeError("Invalid compression level: "+e);if(t!=nb.Z_FILTERED&&t!=nb.Z_HUFFMAN_ONLY&&t!=nb.Z_RLE&&t!=nb.Z_FIXED&&t!=nb.Z_DEFAULT_STRATEGY)throw new TypeError("Invalid strategy: "+t);if(this._level!==e||this._strategy!==t){var n=this;this.flush(nb.Z_SYNC_FLUSH,(function(){n._binding.params(e,t),n._hadError||(n._level=e,n._strategy=t,r&&r())}))}else _p.nextTick(r)},Pb.prototype.reset=function(){return this._binding.reset()},Pb.prototype._flush=function(e){this._transform(new C(0),"",e)},Pb.prototype.flush=function(e,t){var r=this._writableState;if(("function"==typeof e||void 0===e&&!t)&&(t=e,e=nb.Z_FULL_FLUSH),r.ended)t&&_p.nextTick(t);else if(r.ending)t&&this.once("end",t);else if(r.needDrain){var n=this;this.once("drain",(function(){n.flush(t)}))}else this._flushFlag=e,this.write(new C(0),"",t)},Pb.prototype.close=function(e){if(e&&_p.nextTick(e),!this._closed){this._closed=!0,this._binding.close();var t=this;_p.nextTick((function(){t.emit("close")}))}},Pb.prototype._transform=function(e,t,r){var n,i=this._writableState,o=(i.ending||i.ended)&&(!e||i.length===e.length);if(null===!e&&!C.isBuffer(e))return r(new Error("invalid input"));o?n=nb.Z_FINISH:(n=this._flushFlag,e.length>=i.length&&(this._flushFlag=this._opts.flush||nb.Z_NO_FLUSH)),this._processChunk(e,n,r)},Pb.prototype._processChunk=function(e,t,r){var n=e&&e.length,i=this._chunkSize-this._offset,o=0,s=this,a="function"==typeof r;if(!a){var c,u=[],l=0;this.on("error",(function(e){c=e}));do{var h=this._binding.writeSync(t,e,o,n,this._buffer,this._offset,i)}while(!this._hadError&&p(h[0],h[1]));if(this._hadError)throw c;var f=C.concat(u,l);return this.close(),f}var d=this._binding.write(t,e,o,n,this._buffer,this._offset,i);function p(c,h){if(!s._hadError){var f=i-h;if(function(e,t){if(!e)throw new Error(t)}(f>=0,"have should not go down"),f>0){var d=s._buffer.slice(s._offset,s._offset+f);s._offset+=f,a?s.push(d):(u.push(d),l+=d.length)}if((0===h||s._offset>=s._chunkSize)&&(i=s._chunkSize,s._offset=0,s._buffer=new C(s._chunkSize)),0===h){if(o+=n-c,n=c,!a)return!0;var g=s._binding.write(t,e,o,n,s._buffer,s._offset,s._chunkSize);return g.callback=p,void(g.buffer=e)}if(!a)return!1;r()}}d.buffer=e,d.callback=p},Mp(Bb,Pb),Mp(Tb,Pb),Mp(Rb,Pb),Mp(Ob,Pb),Mp(Mb,Pb),Mp(Lb,Pb),Mp(Cb,Pb);var Nb={codes:ib,createDeflate:ob,createInflate:sb,createDeflateRaw:ab,createInflateRaw:cb,createGzip:ub,createGunzip:lb,createUnzip:hb,deflate:fb,deflateSync:db,gzip:pb,gzipSync:gb,deflateRaw:yb,deflateRawSync:mb,unzip:wb,unzipSync:bb,inflate:vb,inflateSync:_b,gunzip:Eb,gunzipSync:Sb,inflateRaw:xb,inflateRawSync:Ab,Deflate:Bb,Inflate:Tb,Gzip:Rb,Gunzip:Ob,DeflateRaw:Mb,InflateRaw:Lb,Unzip:Cb,Zlib:Pb},Ub=Rr(Object.freeze({__proto__:null,codes:ib,createDeflate:ob,createInflate:sb,createDeflateRaw:ab,createInflateRaw:cb,createGzip:ub,createGunzip:lb,createUnzip:hb,deflate:fb,deflateSync:db,gzip:pb,gzipSync:gb,deflateRaw:yb,deflateRawSync:mb,unzip:wb,unzipSync:bb,inflate:vb,inflateSync:_b,gunzip:Eb,gunzipSync:Sb,inflateRaw:xb,inflateRawSync:Ab,Deflate:Bb,Inflate:Tb,Gzip:Rb,Gunzip:Ob,DeflateRaw:Mb,InflateRaw:Lb,Unzip:Cb,Zlib:Pb,default:Nb})),jb=Rr(wg),$b=Rr(tm);Object.defineProperty(Zd,"__esModule",{value:!0}),Zd.InvalidStatusCodeError=Zd.InvalidCertError=void 0;const zb=Object.freeze({redirect:!0,expectStatusCode:200,headers:{},full:!1,keepAlive:!0,cors:!1,referrer:!1,sslAllowSelfSigned:!1,_redirectCount:0});class Db extends Error{constructor(e,t){super(e),this.fingerprint256=t}}Zd.InvalidCertError=Db;class Hb extends Error{constructor(e){super(`Request Failed. Status Code: ${e}`),this.statusCode=e}}function qb(e,t){if(!t||"text"===t||"json"===t)try{let r=new TextDecoder("utf8",{fatal:!0}).decode(e);if("text"===t)return r;try{return JSON.parse(r)}catch(e){if("json"===t)throw e;return r}}catch(e){if("text"===t||"json"===t)throw e}return e}Zd.InvalidStatusCodeError=Hb;let Fb={};function Kb(e,t){let r={...zb,...t};const n=cm,i=gm,o=Ub,{promisify:s}=jb,{resolve:a}=$b,c=!!/^https/.test(e);let u={method:r.method||"GET",headers:{"Accept-Encoding":"gzip, deflate, br"}};const l=e=>e.replace(/:| /g,"").toLowerCase();if(r.keepAlive){const e={keepAlive:!0,keepAliveMsecs:3e4,maxFreeSockets:1024,maxCachedSessions:1024},t=[c,c&&r.sslPinnedCertificates?.map((e=>l(e))).sort()].join();u.agent=Fb[t]||(Fb[t]=new(c?i:n).Agent(e))}"json"===r.type&&(u.headers["Content-Type"]="application/json"),r.data&&(r.method||(u.method="POST"),u.body="json"===r.type?JSON.stringify(r.data):r.data),u.headers={...u.headers,...r.headers},r.sslAllowSelfSigned&&(u.rejectUnauthorized=!1);return new Promise(((t,h)=>{const f=async t=>{if(t&&"DEPTH_ZERO_SELF_SIGNED_CERT"===t.code)try{await Kb(e,{...r,sslAllowSelfSigned:!0,sslPinnedCertificates:[]})}catch(e){e&&e.fingerprint256&&(t=new Db(`Self-signed SSL certificate: ${e.fingerprint256}`,e.fingerprint256))}h(t)},d=(c?i:n).request(e,u,(n=>{n.on("error",f),(async()=>{try{t(await(async t=>{const n=t.statusCode;if(r.redirect&&300<=n&&n<400&&t.headers.location){if(10==r._redirectCount)throw new Error("Request failed. Too much redirects.");return r._redirectCount+=1,await Kb(a(e,t.headers.location),r)}if(r.expectStatusCode&&n!==r.expectStatusCode)throw t.resume(),new Hb(n);let i=[];for await(const e of t)i.push(e);let c=C.concat(i);const u=t.headers["content-encoding"];"br"===u&&(c=await s(o.brotliDecompress)(c)),"gzip"!==u&&"deflate"!==u||(c=await s(o.unzip)(c));const l=qb(c,r.type);return r.full?{headers:t.headers,status:n,body:l}:l})(n))}catch(e){h(e)}})()}));d.on("error",f);const p=r.sslPinnedCertificates?.map((e=>l(e))),g=e=>{const t=l(e.getPeerCertificate()?.fingerprint256||"");if((t||!e.isSessionReused())&&!p.includes(t))return d.emit("error",new Db(`Invalid SSL certificate: ${t} Expected: ${p}`,t)),d.abort()};r.sslPinnedCertificates&&d.on("socket",(e=>{const t=e.listeners("secureConnect").map((e=>(e.name||"").replace("bound ",""))).includes("mfetchSecureConnect");t||e.on("secureConnect",g.bind(null,e))})),r.keepAlive&&d.setNoDelay(!0),u.body&&d.write(u.body),d.end()}))}const Wb=new Set(["Accept","Accept-Language","Content-Language","Content-Type"].map((e=>e.toLowerCase()))),Vb=new Set(["Accept-Charset","Accept-Encoding","Access-Control-Request-Headers","Access-Control-Request-Method","Connection","Content-Length","Cookie","Cookie2","Date","DNT","Expect","Host","Keep-Alive","Origin","Referer","TE","Trailer","Transfer-Encoding","Upgrade","Via"].map((e=>e.toLowerCase())));async function Zb(e,t){let r={...zb,...t};const n=new Headers;"json"===r.type&&n.set("Content-Type","application/json");let i=new URL(e);if(i.username){const e=btoa(`${i.username}:${i.password}`);n.set("Authorization",`Basic ${e}`),i.username="",i.password=""}e=""+i;for(let e in r.headers){const t=e.toLowerCase();(Wb.has(t)||r.cors&&!Vb.has(t))&&n.set(e,r.headers[e])}let o={headers:n,redirect:r.redirect?"follow":"manual"};r.referrer||(o.referrerPolicy="no-referrer"),r.cors&&(o.mode="cors"),r.data&&(r.method||(o.method="POST"),o.body="json"===r.type?JSON.stringify(r.data):r.data);const s=await fetch(e,o);if(r.expectStatusCode&&s.status!==r.expectStatusCode)throw new Hb(s.status);const a=qb(new Uint8Array(await s.arrayBuffer()),r.type);return r.full?{headers:Object.fromEntries(s.headers.entries()),status:s.status,body:a}:a}const Gb=!!("object"==typeof process&&process.versions&&process.versions.node&&process.versions.v8);Zd.default=function(e,t){return(Gb?Kb:Zb)(e,t)},Object.defineProperty(Vd,"__esModule",{value:!0}),Vd.getProvider=Vd.fetchFromProvider=void 0;const Jb=Zd;Vd.fetchFromProvider=async(e,t)=>(await(0,Jb.default)(e,{headers:{"content-type":"application/json"},type:"json",data:{method:t.method,params:t.params,jsonrpc:"2.0",id:1}})).result;Vd.getProvider=e=>{if("string"==typeof e)return e;if(void 0!==e?.connection?.url)return e.connection.url;throw new Error("Must provide valid provider URL or Web3Provider")},function(e){var t=Tr&&Tr.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=Tr&&Tr.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.toAscii=e.stripHexPrefix=e.padToEven=e.isHexString=e.isHexPrefixed=e.getKeys=e.getBinarySize=e.fromUtf8=e.fromAscii=e.arrayContainsArray=void 0,r(ml,e),r(ef,e),r(tf,e),r(Sd,e),r(Id,e),r(Ld,e),r(md,e),r(Bd,e),r(Dd,e),r(Hd,e);var n=bd;Object.defineProperty(e,"arrayContainsArray",{enumerable:!0,get:function(){return n.arrayContainsArray}}),Object.defineProperty(e,"fromAscii",{enumerable:!0,get:function(){return n.fromAscii}}),Object.defineProperty(e,"fromUtf8",{enumerable:!0,get:function(){return n.fromUtf8}}),Object.defineProperty(e,"getBinarySize",{enumerable:!0,get:function(){return n.getBinarySize}}),Object.defineProperty(e,"getKeys",{enumerable:!0,get:function(){return n.getKeys}}),Object.defineProperty(e,"isHexPrefixed",{enumerable:!0,get:function(){return n.isHexPrefixed}}),Object.defineProperty(e,"isHexString",{enumerable:!0,get:function(){return n.isHexString}}),Object.defineProperty(e,"padToEven",{enumerable:!0,get:function(){return n.padToEven}}),Object.defineProperty(e,"stripHexPrefix",{enumerable:!0,get:function(){return n.stripHexPrefix}}),Object.defineProperty(e,"toAscii",{enumerable:!0,get:function(){return n.toAscii}}),r(Wd,e),r(Vd,e)}(yl);var Yb={},Xb={},Qb={},ev={},tv={},rv={},nv={};Object.defineProperty(nv,"__esModule",{value:!0});var iv=(e=>(e[e.Null=4]="Null",e[e.Comma=1]="Comma",e[e.Wrapper=1]="Wrapper",e[e.True=4]="True",e[e.False=5]="False",e[e.Quote=1]="Quote",e[e.Colon=1]="Colon",e[e.Date=24]="Date",e))(iv||{}),ov=/"|\\|\n|\r|\t/gu;function sv(e){return e.charCodeAt(0)<=127}nv.isNonEmptyArray=function(e){return Array.isArray(e)&&e.length>0},nv.isNullOrUndefined=function(e){return null==e},nv.isObject=function(e){return Boolean(e)&&"object"==typeof e&&!Array.isArray(e)},nv.hasProperty=(e,t)=>Object.hasOwnProperty.call(e,t),nv.getKnownPropertyNames=function(e){return Object.getOwnPropertyNames(e)},nv.JsonSize=iv,nv.ESCAPE_CHARACTERS_REGEXP=ov,nv.isPlainObject=function(e){if("object"!=typeof e||null===e)return!1;try{let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}catch(e){return!1}},nv.isASCII=sv,nv.calculateStringSize=function(e){return e.split("").reduce(((e,t)=>sv(t)?e+1:e+2),0)+(t=e.match(ov),r=()=>[],null!=t?t:r()).length;var t,r},nv.calculateNumberSize=function(e){return e.toString().length};class av extends Error{constructor(e,{cause:t}={}){super(e),this.name=av.name,t&&(this.cause=t),this.message=e}}var cv=Rr(Object.freeze({__proto__:null,ErrorWithCause:av}));const uv=e=>{if(e&&"object"==typeof e&&"cause"in e){if("function"==typeof e.cause){const t=e.cause();return t instanceof Error?t:void 0}return e.cause instanceof Error?e.cause:void 0}},lv=(e,t)=>{if(!(e instanceof Error))return"";const r=e.stack||"";if(t.has(e))return r+"\ncauses have become circular...";const n=uv(e);return n?(t.add(e),r+"\ncaused by: "+lv(n,t)):r},hv=(e,t,r)=>{if(!(e instanceof Error))return"";const n=r?"":e.message||"";if(t.has(e))return n+": ...";const i=uv(e);if(i){t.add(e);const r="cause"in e&&"function"==typeof e.cause;return n+(r?"":": ")+hv(i,t,r)}return n};var fv=Object.freeze({__proto__:null,findCauseByReference:(e,t)=>{if(!e||!t)return;if(!(e instanceof Error))return;if(!(t.prototype instanceof Error)&&t!==Error)return;const r=new Set;let n=e;for(;n&&!r.has(n);){if(r.add(n),n instanceof t)return n;n=uv(n)}},getErrorCause:uv,stackWithCauses:e=>lv(e,new Set),messageWithCauses:e=>hv(e,new Set)}),dv=Rr(fv);const{ErrorWithCause:pv}=cv,{findCauseByReference:gv,getErrorCause:yv,messageWithCauses:mv,stackWithCauses:wv}=dv;var bv={ErrorWithCause:pv,findCauseByReference:gv,getErrorCause:yv,stackWithCauses:wv,messageWithCauses:mv};Object.defineProperty(rv,"__esModule",{value:!0});var vv=nv,_v=bv;function Ev(e){return"object"==typeof e&&null!==e&&"code"in e}function Sv(e){return"object"==typeof e&&null!==e&&"message"in e}rv.isErrorWithCode=Ev,rv.isErrorWithMessage=Sv,rv.isErrorWithStack=function(e){return"object"==typeof e&&null!==e&&"stack"in e},rv.getErrorMessage=function(e){return Sv(e)&&"string"==typeof e.message?e.message:vv.isNullOrUndefined.call(void 0,e)?"":String(e)},rv.wrapError=function(e,t){if(function(e){return e instanceof Error||vv.isObject.call(void 0,e)&&"Error"===e.constructor.name}(e)){let r;return r=2===Error.length?new Error(t,{cause:e}):new _v.ErrorWithCause(t,{cause:e}),Ev(e)&&(r.code=e.code),r}return t.length>0?new Error(`${String(e)}: ${t}`):new Error(String(e))};class xv extends TypeError{constructor(e,t){let r;const{message:n,explanation:i,...o}=e,{path:s}=e,a=0===s.length?n:`At path: ${s.join(".")} -- ${n}`;super(i??a),null!=i&&(this.cause=a),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>r??(r=[e,...t()])}}function Av(e){return"object"==typeof e&&null!=e}function kv(e){if("[object Object]"!==Object.prototype.toString.call(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function Iv(e){return"symbol"==typeof e?e.toString():"string"==typeof e?JSON.stringify(e):`${e}`}function Bv(e,t,r,n){if(!0===e)return;!1===e?e={}:"string"==typeof e&&(e={message:e});const{path:i,branch:o}=t,{type:s}=r,{refinement:a,message:c=`Expected a value of type \`${s}\`${a?` with refinement \`${a}\``:""}, but received: \`${Iv(n)}\``}=e;return{value:n,type:s,refinement:a,key:i[i.length-1],path:i,branch:o,...e,message:c}}function*Tv(e,t,r,n){(function(e){return Av(e)&&"function"==typeof e[Symbol.iterator]})(e)||(e=[e]);for(const i of e){const e=Bv(i,t,r,n);e&&(yield e)}}function*Rv(e,t,r={}){const{path:n=[],branch:i=[e],coerce:o=!1,mask:s=!1}=r,a={path:n,branch:i};if(o&&(e=t.coercer(e,a),s&&"type"!==t.type&&Av(t.schema)&&Av(e)&&!Array.isArray(e)))for(const r in e)void 0===t.schema[r]&&delete e[r];let c="valid";for(const n of t.validator(e,a))n.explanation=r.message,c="not_valid",yield[n,void 0];for(let[u,l,h]of t.entries(e,a)){const t=Rv(l,h,{path:void 0===u?n:[...n,u],branch:void 0===u?i:[...i,l],coerce:o,mask:s,message:r.message});for(const r of t)r[0]?(c=null!=r[0].refinement?"not_refined":"not_valid",yield[r[0],void 0]):o&&(l=r[1],void 0===u?e=l:e instanceof Map?e.set(u,l):e instanceof Set?e.add(l):Av(e)&&(void 0!==l||u in e)&&(e[u]=l))}if("not_valid"!==c)for(const n of t.refiner(e,a))n.explanation=r.message,c="not_refined",yield[n,void 0];"valid"===c&&(yield[void 0,e])}class Ov{constructor(e){const{type:t,schema:r,validator:n,refiner:i,coercer:o=e=>e,entries:s=function*(){}}=e;this.type=t,this.schema=r,this.entries=s,this.coercer=o,this.validator=n?(e,t)=>Tv(n(e,t),t,this,e):()=>[],this.refiner=i?(e,t)=>Tv(i(e,t),t,this,e):()=>[]}assert(e,t){return Mv(e,this,t)}create(e,t){return Lv(e,this,t)}is(e){return Pv(e,this)}mask(e,t){return Cv(e,this,t)}validate(e,t={}){return Nv(e,this,t)}}function Mv(e,t,r){const n=Nv(e,t,{message:r});if(n[0])throw n[0]}function Lv(e,t,r){const n=Nv(e,t,{coerce:!0,message:r});if(n[0])throw n[0];return n[1]}function Cv(e,t,r){const n=Nv(e,t,{coerce:!0,mask:!0,message:r});if(n[0])throw n[0];return n[1]}function Pv(e,t){return!Nv(e,t)[0]}function Nv(e,t,r={}){const n=Rv(e,t,r),i=function(e){const{done:t,value:r}=e.next();return t?void 0:r}(n);if(i[0]){const e=new xv(i[0],(function*(){for(const e of n)e[0]&&(yield e[0])}));return[e,void 0]}return[void 0,i[1]]}function Uv(e,t){return new Ov({type:e,schema:null,validator:t})}function jv(){return Uv("never",(()=>!1))}function $v(e){const t=e?Object.keys(e):[],r=jv();return new Ov({type:"object",schema:e||null,*entries(n){if(e&&Av(n)){const i=new Set(Object.keys(n));for(const r of t)i.delete(r),yield[r,n[r],e[r]];for(const e of i)yield[e,n[e],r]}},validator:e=>Av(e)||`Expected an object, but received: ${Iv(e)}`,coercer:e=>Av(e)?{...e}:e})}function zv(e){return new Ov({...e,validator:(t,r)=>void 0===t||e.validator(t,r),refiner:(t,r)=>void 0===t||e.refiner(t,r)})}function Dv(){return Uv("string",(e=>"string"==typeof e||`Expected a string, but received: ${Iv(e)}`))}function Hv(e){const t=Object.keys(e);return new Ov({type:"type",schema:e,*entries(r){if(Av(r))for(const n of t)yield[n,r[n],e[n]]},validator:e=>Av(e)||`Expected an object, but received: ${Iv(e)}`,coercer:e=>Av(e)?{...e}:e})}function qv(){return Uv("unknown",(()=>!0))}function Fv(e,t,r){return new Ov({...e,coercer:(n,i)=>Pv(n,t)?e.coercer(r(n,i),i):e.coercer(n,i)})}function Kv(e){return e instanceof Map||e instanceof Set?e.size:e.length}function Wv(e,t,r){return new Ov({...e,*refiner(n,i){yield*e.refiner(n,i);const o=Tv(r(n,i),i,e,n);for(const e of o)yield{...e,refinement:t}}})}var Vv=Object.freeze({__proto__:null,Struct:Ov,StructError:xv,any:function(){return Uv("any",(()=>!0))},array:function(e){return new Ov({type:"array",schema:e,*entries(t){if(e&&Array.isArray(t))for(const[r,n]of t.entries())yield[r,n,e]},coercer:e=>Array.isArray(e)?e.slice():e,validator:e=>Array.isArray(e)||`Expected an array value, but received: ${Iv(e)}`})},assert:Mv,assign:function(...e){const t="type"===e[0].type,r=e.map((e=>e.schema)),n=Object.assign({},...r);return t?Hv(n):$v(n)},bigint:function(){return Uv("bigint",(e=>"bigint"==typeof e))},boolean:function(){return Uv("boolean",(e=>"boolean"==typeof e))},coerce:Fv,create:Lv,date:function(){return Uv("date",(e=>e instanceof Date&&!isNaN(e.getTime())||`Expected a valid \`Date\` object, but received: ${Iv(e)}`))},defaulted:function(e,t,r={}){return Fv(e,qv(),(e=>{const n="function"==typeof t?t():t;if(void 0===e)return n;if(!r.strict&&kv(e)&&kv(n)){const t={...e};let r=!1;for(const e in n)void 0===t[e]&&(t[e]=n[e],r=!0);if(r)return t}return e}))},define:Uv,deprecated:function(e,t){return new Ov({...e,refiner:(t,r)=>void 0===t||e.refiner(t,r),validator:(r,n)=>void 0===r||(t(r,n),e.validator(r,n))})},dynamic:function(e){return new Ov({type:"dynamic",schema:null,*entries(t,r){const n=e(t,r);yield*n.entries(t,r)},validator:(t,r)=>e(t,r).validator(t,r),coercer:(t,r)=>e(t,r).coercer(t,r),refiner:(t,r)=>e(t,r).refiner(t,r)})},empty:function(e){return Wv(e,"empty",(t=>{const r=Kv(t);return 0===r||`Expected an empty ${e.type} but received one with a size of \`${r}\``}))},enums:function(e){const t={},r=e.map((e=>Iv(e))).join();for(const r of e)t[r]=r;return new Ov({type:"enums",schema:t,validator:t=>e.includes(t)||`Expected one of \`${r}\`, but received: ${Iv(t)}`})},func:function(){return Uv("func",(e=>"function"==typeof e||`Expected a function, but received: ${Iv(e)}`))},instance:function(e){return Uv("instance",(t=>t instanceof e||`Expected a \`${e.name}\` instance, but received: ${Iv(t)}`))},integer:function(){return Uv("integer",(e=>"number"==typeof e&&!isNaN(e)&&Number.isInteger(e)||`Expected an integer, but received: ${Iv(e)}`))},intersection:function(e){return new Ov({type:"intersection",schema:null,*entries(t,r){for(const n of e)yield*n.entries(t,r)},*validator(t,r){for(const n of e)yield*n.validator(t,r)},*refiner(t,r){for(const n of e)yield*n.refiner(t,r)}})},is:Pv,lazy:function(e){let t;return new Ov({type:"lazy",schema:null,*entries(r,n){t??(t=e()),yield*t.entries(r,n)},validator:(r,n)=>(t??(t=e()),t.validator(r,n)),coercer:(r,n)=>(t??(t=e()),t.coercer(r,n)),refiner:(r,n)=>(t??(t=e()),t.refiner(r,n))})},literal:function(e){const t=Iv(e),r=typeof e;return new Ov({type:"literal",schema:"string"===r||"number"===r||"boolean"===r?e:null,validator:r=>r===e||`Expected the literal \`${t}\`, but received: ${Iv(r)}`})},map:function(e,t){return new Ov({type:"map",schema:null,*entries(r){if(e&&t&&r instanceof Map)for(const[n,i]of r.entries())yield[n,n,e],yield[n,i,t]},coercer:e=>e instanceof Map?new Map(e):e,validator:e=>e instanceof Map||`Expected a \`Map\` object, but received: ${Iv(e)}`})},mask:Cv,max:function(e,t,r={}){const{exclusive:n}=r;return Wv(e,"max",(r=>n?rn?r>t:r>=t||`Expected a ${e.type} greater than ${n?"":"or equal to "}${t} but received \`${r}\``))},never:jv,nonempty:function(e){return Wv(e,"nonempty",(t=>Kv(t)>0||`Expected a nonempty ${e.type} but received an empty one`))},nullable:function(e){return new Ov({...e,validator:(t,r)=>null===t||e.validator(t,r),refiner:(t,r)=>null===t||e.refiner(t,r)})},number:function(){return Uv("number",(e=>"number"==typeof e&&!isNaN(e)||`Expected a number, but received: ${Iv(e)}`))},object:$v,omit:function(e,t){const{schema:r}=e,n={...r};for(const e of t)delete n[e];return"type"===e.type?Hv(n):$v(n)},optional:zv,partial:function(e){const t=e instanceof Ov,r=t?{...e.schema}:{...e};for(const e in r)r[e]=zv(r[e]);return t&&"type"===e.type?Hv(r):$v(r)},pattern:function(e,t){return Wv(e,"pattern",(r=>t.test(r)||`Expected a ${e.type} matching \`/${t.source}/\` but received "${r}"`))},pick:function(e,t){const{schema:r}=e,n={};for(const e of t)n[e]=r[e];return"type"===e.type?Hv(n):$v(n)},record:function(e,t){return new Ov({type:"record",schema:null,*entries(r){if(Av(r))for(const n in r){const i=r[n];yield[n,n,e],yield[n,i,t]}},validator:e=>Av(e)||`Expected an object, but received: ${Iv(e)}`})},refine:Wv,regexp:function(){return Uv("regexp",(e=>e instanceof RegExp))},set:function(e){return new Ov({type:"set",schema:null,*entries(t){if(e&&t instanceof Set)for(const r of t)yield[r,r,e]},coercer:e=>e instanceof Set?new Set(e):e,validator:e=>e instanceof Set||`Expected a \`Set\` object, but received: ${Iv(e)}`})},size:function(e,t,r=t){const n=`Expected a ${e.type}`,i=t===r?`of \`${t}\``:`between \`${t}\` and \`${r}\``;return Wv(e,"size",(e=>{if("number"==typeof e||e instanceof Date)return t<=e&&e<=r||`${n} ${i} but received \`${e}\``;if(e instanceof Map||e instanceof Set){const{size:o}=e;return t<=o&&o<=r||`${n} with a size ${i} but received one with a size of \`${o}\``}{const{length:o}=e;return t<=o&&o<=r||`${n} with a length ${i} but received one with a length of \`${o}\``}}))},string:Dv,struct:function(e,t){return console.warn("superstruct@0.11 - The `struct` helper has been renamed to `define`."),Uv(e,t)},trimmed:function(e){return Fv(e,Dv(),(e=>e.trim()))},tuple:function(e){const t=jv();return new Ov({type:"tuple",schema:null,*entries(r){if(Array.isArray(r)){const n=Math.max(e.length,r.length);for(let i=0;iArray.isArray(e)||`Expected an array, but received: ${Iv(e)}`})},type:Hv,union:function(e){const t=e.map((e=>e.type)).join(" | ");return new Ov({type:"union",schema:null,coercer(t){for(const r of e){const[e,n]=r.validate(t,{coerce:!0});if(!e)return n}return t},validator(r,n){const i=[];for(const t of e){const[...e]=Rv(r,t,n),[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: ${Iv(r)}`,...i]}})},unknown:qv,validate:Nv}),Zv=Rr(Vv);Object.defineProperty(tv,"__esModule",{value:!0});var Gv=rv,Jv=Zv;function Yv(e,t){return Boolean("string"==typeof function(e){let t,r=e[0],n=1;for(;nr.call(t,...e))),t=void 0)}return r}([e,"optionalAccess",e=>e.prototype,"optionalAccess",e=>e.constructor,"optionalAccess",e=>e.name]))?new e({message:t}):e({message:t})}var Xv=class extends Error{constructor(e){super(e.message),this.code="ERR_ASSERTION"}};tv.AssertionError=Xv,tv.assert=function(e,t="Assertion failed.",r=Xv){if(!e){if(t instanceof Error)throw t;throw Yv(r,t)}},tv.assertStruct=function(e,t,r="Assertion failed",n=Xv){try{Jv.assert.call(void 0,e,t)}catch(e){throw Yv(n,`${r}: ${function(e){return Gv.getErrorMessage.call(void 0,e).replace(/\.$/u,"")}(e)}.`)}},tv.assertExhaustive=function(e){throw new Error("Invalid branch reached. Should be detected during compilation.")};var Qv={},e_={};function t_(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function r_(e){if("boolean"!=typeof e)throw new Error(`boolean expected, not ${e}`)}function n_(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}function i_(e,...t){if(!n_(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function o_(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");t_(e.outputLen),t_(e.blockLen)}function s_(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function a_(e,t){i_(e);const r=t.outputLen;if(e.length>h_&l_)}:{h:0|Number(e>>h_&l_),l:0|Number(e&l_)}}function d_(e,t=!1){let r=new Uint32Array(e.length),n=new Uint32Array(e.length);for(let i=0;iBigInt(e>>>0)<>>0);u_.toBig=p_;const g_=(e,t,r)=>e>>>r;u_.shrSH=g_;const y_=(e,t,r)=>e<<32-r|t>>>r;u_.shrSL=y_;const m_=(e,t,r)=>e>>>r|t<<32-r;u_.rotrSH=m_;const w_=(e,t,r)=>e<<32-r|t>>>r;u_.rotrSL=w_;const b_=(e,t,r)=>e<<64-r|t>>>r-32;u_.rotrBH=b_;const v_=(e,t,r)=>e>>>r-32|t<<64-r;u_.rotrBL=v_;const __=(e,t)=>t;u_.rotr32H=__;const E_=(e,t)=>e;u_.rotr32L=E_;const S_=(e,t,r)=>e<>>32-r;u_.rotlSH=S_;const x_=(e,t,r)=>t<>>32-r;u_.rotlSL=x_;const A_=(e,t,r)=>t<>>64-r;u_.rotlBH=A_;const k_=(e,t,r)=>e<>>64-r;function I_(e,t,r,n){const i=(t>>>0)+(n>>>0);return{h:e+r+(i/2**32|0)|0,l:0|i}}u_.rotlBL=k_,u_.add=I_;const B_=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0);u_.add3L=B_;const T_=(e,t,r,n)=>t+r+n+(e/2**32|0)|0;u_.add3H=T_;const R_=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0);u_.add4L=R_;const O_=(e,t,r,n,i)=>t+r+n+i+(e/2**32|0)|0;u_.add4H=O_;const M_=(e,t,r,n,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(i>>>0);u_.add5L=M_;const L_=(e,t,r,n,i,o)=>t+r+n+i+o+(e/2**32|0)|0;u_.add5H=L_;const C_={fromBig:f_,split:d_,toBig:p_,shrSH:g_,shrSL:y_,rotrSH:m_,rotrSL:w_,rotrBH:b_,rotrBL:v_,rotr32H:__,rotr32L:E_,rotlSH:S_,rotlSL:x_,rotlBH:A_,rotlBL:k_,add:I_,add3L:B_,add3H:T_,add4L:R_,add4H:O_,add5H:L_,add5L:M_};u_.default=C_;var P_={},N_={};Object.defineProperty(N_,"__esModule",{value:!0}),N_.crypto=void 0,N_.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,function(e){ -/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */ -Object.defineProperty(e,"__esModule",{value:!0}),e.randomBytes=e.wrapXOFConstructorWithOpts=e.wrapConstructorWithOpts=e.wrapConstructor=e.checkOpts=e.Hash=e.concatBytes=e.toBytes=e.utf8ToBytes=e.asyncLoop=e.nextTick=e.hexToBytes=e.bytesToHex=e.byteSwap32=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=e.isBytes=void 0;const t=N_,r=e_;e.isBytes=function(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name};e.u8=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength);e.u32=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));e.createView=e=>new DataView(e.buffer,e.byteOffset,e.byteLength);e.rotr=(e,t)=>e<<32-t|e>>>t;e.rotl=(e,t)=>e<>>32-t>>>0,e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];e.byteSwap=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255,e.byteSwapIfBE=e.isLE?e=>e:t=>(0,e.byteSwap)(t),e.byteSwap32=function(t){for(let r=0;rt.toString(16).padStart(2,"0")));e.bytesToHex=function(e){(0,r.bytes)(e);let t="";for(let r=0;r=i&&e<=o?e-i:e>=s&&e<=a?e-(s-10):e>=c&&e<=u?e-(c-10):void 0}e.hexToBytes=function(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,r=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(r);for(let t=0,i=0;t{},e.asyncLoop=async function(t,r,n){let i=Date.now();for(let o=0;o=0&&te().update(f(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t},e.wrapConstructorWithOpts=function(e){const t=(t,r)=>e(r).update(f(t)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=t=>e(t),t},e.wrapXOFConstructorWithOpts=function(e){const t=(t,r)=>e(r).update(f(t)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=t=>e(t),t},e.randomBytes=function(e=32){if(t.crypto&&"function"==typeof t.crypto.getRandomValues)return t.crypto.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}}(P_),Object.defineProperty(Qv,"__esModule",{value:!0}),Qv.shake256=Qv.shake128=Qv.keccak_512=Qv.keccak_384=Qv.keccak_256=Qv.keccak_224=Qv.sha3_512=Qv.sha3_384=Qv.sha3_256=Qv.sha3_224=Qv.Keccak=Qv.keccakP=void 0;const U_=e_,j_=u_,$_=P_,z_=[],D_=[],H_=[],q_=BigInt(0),F_=BigInt(1),K_=BigInt(2),W_=BigInt(7),V_=BigInt(256),Z_=BigInt(113);for(let e=0,t=F_,r=1,n=0;e<24;e++){[r,n]=[n,(2*r+3*n)%5],z_.push(2*(5*n+r)),D_.push((e+1)*(e+2)/2%64);let i=q_;for(let e=0;e<7;e++)t=(t<>W_)*Z_)%V_,t&K_&&(i^=F_<<(F_<r>32?(0,j_.rotlBH)(e,t,r):(0,j_.rotlSH)(e,t,r),X_=(e,t,r)=>r>32?(0,j_.rotlBL)(e,t,r):(0,j_.rotlSL)(e,t,r);function Q_(e,t=24){const r=new Uint32Array(10);for(let n=24-t;n<24;n++){for(let t=0;t<10;t++)r[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){const n=(t+8)%10,i=(t+2)%10,o=r[i],s=r[i+1],a=Y_(o,s,1)^r[n],c=X_(o,s,1)^r[n+1];for(let r=0;r<50;r+=10)e[t+r]^=a,e[t+r+1]^=c}let t=e[2],i=e[3];for(let r=0;r<24;r++){const n=D_[r],o=Y_(t,i,n),s=X_(t,i,n),a=z_[r];t=e[a],i=e[a+1],e[a]=o,e[a+1]=s}for(let t=0;t<50;t+=10){for(let n=0;n<10;n++)r[n]=e[t+n];for(let n=0;n<10;n++)e[t+n]^=~r[(n+2)%10]&r[(n+4)%10]}e[0]^=G_[n],e[1]^=J_[n]}r.fill(0)}Qv.keccakP=Q_;class eE extends $_.Hash{constructor(e,t,r,n=!1,i=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=n,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,(0,U_.number)(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=(0,$_.u32)(this.state)}keccak(){$_.isLE||(0,$_.byteSwap32)(this.state32),Q_(this.state32,this.rounds),$_.isLE||(0,$_.byteSwap32)(this.state32),this.posOut=0,this.pos=0}update(e){(0,U_.exists)(this);const{blockLen:t,state:r}=this,n=(e=(0,$_.toBytes)(e)).length;for(let i=0;i=r&&this.keccak();const o=Math.min(r-this.posOut,i-n);e.set(t.subarray(this.posOut,this.posOut+o),n),this.posOut+=o,n+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return(0,U_.number)(e),this.xofInto(new Uint8Array(e))}digestInto(e){if((0,U_.output)(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:r,outputLen:n,rounds:i,enableXOF:o}=this;return e||(e=new eE(t,r,n,o,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=r,e.outputLen=n,e.enableXOF=o,e.destroyed=this.destroyed,e}}Qv.Keccak=eE;const tE=(e,t,r)=>(0,$_.wrapConstructor)((()=>new eE(t,e,r)));Qv.sha3_224=tE(6,144,28),Qv.sha3_256=tE(6,136,32),Qv.sha3_384=tE(6,104,48),Qv.sha3_512=tE(6,72,64),Qv.keccak_224=tE(1,144,28),Qv.keccak_256=tE(1,136,32),Qv.keccak_384=tE(1,104,48),Qv.keccak_512=tE(1,72,64);const rE=(e,t,r)=>(0,$_.wrapXOFConstructorWithOpts)(((n={})=>new eE(t,e,void 0===n.dkLen?r:n.dkLen,!0)));Qv.shake128=rE(31,168,16),Qv.shake256=rE(31,136,32);var nE={};!function(e){function t(e){if(!Number.isSafeInteger(e))throw new Error(`Wrong integer: ${e}`)}function r(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}function n(...e){const t=e=>e,r=(e,t)=>r=>e(t(r)),n=e.map((e=>e.encode)).reduceRight(r,t),i=e.map((e=>e.decode)).reduce(r,t);return{encode:n,decode:i}}function i(e){return{encode:r=>{if(!Array.isArray(r)||r.length&&"number"!=typeof r[0])throw new Error("alphabet.encode input should be an array of numbers");return r.map((r=>{if(t(r),r<0||r>=e.length)throw new Error(`Digit index outside alphabet: ${r} (alphabet: ${e.length})`);return e[r]}))},decode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("alphabet.decode input should be array of strings");return t.map((t=>{if("string"!=typeof t)throw new Error(`alphabet.decode: not string element=${t}`);const r=e.indexOf(t);if(-1===r)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return r}))}}}function o(e=""){if("string"!=typeof e)throw new Error("join separator should be string");return{encode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("join.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`join.encode: non-string input=${e}`);return t.join(e)},decode:t=>{if("string"!=typeof t)throw new Error("join.decode input should be string");return t.split(e)}}}function s(e,r="="){if(t(e),"string"!=typeof r)throw new Error("padding chr should be string");return{encode(t){if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("padding.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`padding.encode: non-string input=${e}`);for(;t.length*e%8;)t.push(r);return t},decode(t){if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("padding.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`padding.decode: non-string input=${e}`);let n=t.length;if(n*e%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;n>0&&t[n-1]===r;n--)if(!((n-1)*e%8))throw new Error("Invalid padding: string has too much padding");return t.slice(0,n)}}}function a(e){if("function"!=typeof e)throw new Error("normalize fn should be function");return{encode:e=>e,decode:t=>e(t)}}function c(e,r,n){if(r<2)throw new Error(`convertRadix: wrong from=${r}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: wrong to=${n}, base cannot be less than 2`);if(!Array.isArray(e))throw new Error("convertRadix: data should be array");if(!e.length)return[];let i=0;const o=[],s=Array.from(e);for(s.forEach((e=>{if(t(e),e<0||e>=r)throw new Error(`Wrong integer: ${e}`)}));;){let e=0,t=!0;for(let o=i;o= 0x80 (not a basic code point)","invalid-input":"Invalid input"},_y=Math.floor,Ey=String.fromCharCode;function Sy(e){throw new RangeError(vy[e])}function Ay(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function xy(e,t,r){var n=0;for(e=r?_y(e/700):e>>1,e+=_y(e/t);e>455;n+=36)e=_y(e/35);return _y(n+36*e/(e+38))}function ky(e){return function(e,t){var r=e.split("@"),n="";r.length>1&&(n=r[0]+"@",e=r[1]);var i=function(e,t){for(var r=e.length,n=[];r--;)n[r]=t(e[r]);return n}((e=e.replace(by,".")).split("."),t).join(".");return n+i}(e,(function(e){return wy.test(e)?"xn--"+function(e){var t,r,n,i,o,s,a,c,u,h,l,f,d,p,g,y=[];for(e=function(e){for(var t,r,n=[],i=0,o=e.length;i=55296&&t<=56319&&i=t&&l_y((my-r)/(d=n+1))&&Sy("overflow"),r+=(a-t)*d,t=a,s=0;smy&&Sy("overflow"),l==t){for(c=r,u=36;!(c<(h=u<=o?1:u>=o+26?26:u-o));u+=36)g=c-h,p=36-h,y.push(Ey(Ay(h+g%p,0))),c=_y(g/p);y.push(Ey(Ay(c,0))),o=xy(r,d,n==i),r=0,++n}++r,++t}return y.join("")}(e):e}))}function By(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var Iy=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function Ty(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}}function Ry(e,t){if(e.map)return e.map(t);for(var r=[],n=0;n0&&a>s&&(a=s);for(var c=0;c=0?(u=d.substr(0,p),h=d.substr(p+1)):(u=d,h=""),l=decodeURIComponent(u),f=decodeURIComponent(h),By(i,l)?Iy(i[l])?i[l].push(f):i[l]=[i[l],f]:i[l]=f}return i}const My=b.URL,Cy=b.URLSearchParams;var Py={parse:Jy,resolve:tm,resolveObject:rm,fileURLToPath:Xy,format:Qy,Url:Ny,URL:My,URLSearchParams:Cy};function Ny(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var Uy=/^([a-z0-9.+-]+:)/i,jy=/:[0-9]*$/,$y=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,Hy=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),zy=["'"].concat(Hy),Dy=["%","/","?",";","#"].concat(zy),Fy=["/","?","#"],qy=255,Ky=/^[+a-z0-9A-Z_-]{0,63}$/,Wy=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,Vy={javascript:!0,"javascript:":!0},Zy={javascript:!0,"javascript:":!0},Gy={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};function Jy(e,t,r){if(e&&ig(e)&&e instanceof Ny)return e;var n=new Ny;return n.parse(e,t,r),n}function Yy(e,t,r,n){if(!eg(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var i=t.indexOf("?"),o=-1!==i&&i127?E+="x":E+=_[S];if(!E.match(Ky)){var x=v.slice(0,u),k=v.slice(u+1),B=_.match(Wy);B&&(x.push(B[1]),k.unshift(B[2])),k.length&&(a="/"+k.join(".")+a),e.hostname=x.join(".");break}}}}e.hostname.length>qy?e.hostname="":e.hostname=e.hostname.toLowerCase(),b||(e.hostname=ky(e.hostname)),f=e.port?":"+e.port:"";var I=e.hostname||"";e.host=I+f,e.href+=e.host,b&&(e.hostname=e.hostname.substr(1,e.hostname.length-2),"/"!==a[0]&&(a="/"+a))}if(!Vy[p])for(u=0,l=zy.length;u0)&&n.host.split("@"))&&(n.auth=g.shift(),n.host=n.hostname=g.shift())),n.search=e.search,n.query=e.query,Yp(n.pathname)&&Yp(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n;if(!v.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var E=v.slice(-1)[0],S=(n.host||e.host||v.length>1)&&("."===E||".."===E)||""===E,A=0,x=v.length;x>=0;x--)"."===(E=v[x])?v.splice(x,1):".."===E?(v.splice(x,1),A++):A&&(v.splice(x,1),A--);if(!w&&!b)for(;A--;A)v.unshift("..");!w||""===v[0]||v[0]&&"/"===v[0].charAt(0)||v.unshift(""),S&&"/"!==v.join("/").substr(-1)&&v.push("");var k=""===v[0]||v[0]&&"/"===v[0].charAt(0);return _&&(n.hostname=n.host=k?"":v.length?v.shift():"",(g=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=g.shift(),n.host=n.hostname=g.shift())),(w=w||n.host&&v.length)&&!k&&v.unshift(""),v.length?n.pathname=v.join("/"):(n.pathname=null,n.path=null),Yp(n.pathname)&&Yp(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.auth=e.auth||n.auth,n.slashes=n.slashes||e.slashes,n.href=n.format(),n},Ny.prototype.parseHost=function(){return nm(this)};var im=Object.freeze({__proto__:null,parse:Jy,resolve:tm,resolveObject:rm,fileURLToPath:Xy,format:Qy,URL:My,URLSearchParams:Cy,default:Py,Url:Ny});function om(e,t){"string"==typeof e&&(e=Jy(e));var r=-1===b.location.protocol.search(/^https?:$/)?"http:":"",n=e.protocol||r,i=e.hostname||e.host,o=e.port,s=e.path||"/";i&&-1!==i.indexOf(":")&&(i="["+i+"]"),e.url=(i?n+"//"+i:"")+(o?":"+o:"")+s,e.method=(e.method||"GET").toUpperCase(),e.headers=e.headers||{};var a=new gy(e);return t&&a.on("response",t),a}function sm(e,t){var r=om(e,t);return r.end(),r}function am(){}am.defaultMaxSockets=4;var cm=["CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REPORT","SEARCH","SUBSCRIBE","TRACE","UNLOCK","UNSUBSCRIBE"],um={100:"Continue",101:"Switching Protocols",102:"Processing",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",300:"Multiple Choices",301:"Moved Permanently",302:"Moved Temporarily",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Time-out",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Request Entity Too Large",414:"Request-URI Too Large",415:"Unsupported Media Type",416:"Requested Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Unordered Collection",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Time-out",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"},hm={request:om,get:sm,Agent:am,METHODS:cm,STATUS_CODES:um},lm=Pr(Object.freeze({__proto__:null,request:om,get:sm,Agent:am,METHODS:cm,STATUS_CODES:um,default:hm}));function fm(e,t){"string"==typeof e&&(e=Jy(e));var r=-1===b.location.protocol.search(/^https?:$/)?"http:":"",n=e.protocol||r,i=e.hostname||e.host,o=e.port,s=e.path||"/";i&&-1!==i.indexOf(":")&&(i="["+i+"]"),e.url=(i?n+"//"+i:"")+(o?":"+o:"")+s,e.method=(e.method||"GET").toUpperCase(),e.headers=e.headers||{};var a=new gy(e);return t&&a.on("response",t),a}function dm(e,t){var r=fm(e,t);return r.end(),r}function pm(){}pm.defaultMaxSockets=4;var gm=["CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REPORT","SEARCH","SUBSCRIBE","TRACE","UNLOCK","UNSUBSCRIBE"],ym={100:"Continue",101:"Switching Protocols",102:"Processing",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",300:"Multiple Choices",301:"Moved Permanently",302:"Moved Temporarily",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Time-out",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Request Entity Too Large",414:"Request-URI Too Large",415:"Unsupported Media Type",416:"Requested Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Unordered Collection",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Time-out",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"},mm={request:fm,get:dm,Agent:pm,METHODS:gm,STATUS_CODES:ym},wm=Pr(Object.freeze({__proto__:null,request:fm,get:dm,Agent:pm,METHODS:gm,STATUS_CODES:ym,default:mm})),bm={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"};function vm(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}function _m(e,t,r,n,i){if(t.subarray&&e.subarray)e.set(t.subarray(r,r+n),i);else for(var o=0;o=0;)e[t]=0}var km=256,Bm=286,Im=30,Tm=15,Rm=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],Om=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],Lm=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],Mm=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],Cm=new Array(576);xm(Cm);var Pm=new Array(60);xm(Pm);var Nm=new Array(512);xm(Nm);var Um=new Array(256);xm(Um);var jm=new Array(29);xm(jm);var $m,Hm,zm,Dm=new Array(Im);function Fm(e,t,r,n,i){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=e&&e.length}function qm(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function Km(e){return e<256?Nm[e]:Nm[256+(e>>>7)]}function Wm(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function Vm(e,t,r){e.bi_valid>16-r?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=r-16):(e.bi_buf|=t<>>=1,r<<=1}while(--t>0);return r>>>1}function Jm(e,t,r){var n,i,o=new Array(16),s=0;for(n=1;n<=Tm;n++)o[n]=s=s+r[n-1]<<1;for(i=0;i<=t;i++){var a=e[2*i+1];0!==a&&(e[2*i]=Gm(o[a]++,a))}}function Ym(e){var t;for(t=0;t8?Wm(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function Qm(e,t,r,n){var i=2*t,o=2*r;return e[i]>1;r>=1;r--)ew(e,o,r);i=c;do{r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],ew(e,o,1),n=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=n,o[2*i]=o[2*r]+o[2*n],e.depth[i]=(e.depth[r]>=e.depth[n]?e.depth[r]:e.depth[n])+1,o[2*r+1]=o[2*n+1]=i,e.heap[1]=i++,ew(e,o,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],function(e,t){var r,n,i,o,s,a,c=t.dyn_tree,u=t.max_code,h=t.stat_desc.static_tree,l=t.stat_desc.has_stree,f=t.stat_desc.extra_bits,d=t.stat_desc.extra_base,p=t.stat_desc.max_length,g=0;for(o=0;o<=Tm;o++)e.bl_count[o]=0;for(c[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;r<573;r++)(o=c[2*c[2*(n=e.heap[r])+1]+1]+1)>p&&(o=p,g++),c[2*n+1]=o,n>u||(e.bl_count[o]++,s=0,n>=d&&(s=f[n-d]),a=c[2*n],e.opt_len+=a*(o+s),l&&(e.static_len+=a*(h[2*n+1]+s)));if(0!==g){do{for(o=p-1;0===e.bl_count[o];)o--;e.bl_count[o]--,e.bl_count[o+1]+=2,e.bl_count[p]--,g-=2}while(g>0);for(o=p;0!==o;o--)for(n=e.bl_count[o];0!==n;)(i=e.heap[--r])>u||(c[2*i+1]!==o&&(e.opt_len+=(o-c[2*i+1])*c[2*i],c[2*i+1]=o),n--)}}(e,t),Jm(o,u,e.bl_count)}function nw(e,t,r){var n,i,o=-1,s=t[1],a=0,c=7,u=4;for(0===s&&(c=138,u=3),t[2*(r+1)+1]=65535,n=0;n<=r;n++)i=s,s=t[2*(n+1)+1],++a>=7;n=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)}function uw(e,t,r,n){var i,o,s=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=function(e){var t,r=4093624447;for(t=0;t<=31;t++,r>>>=1)if(1&r&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t=3&&0===e.bl_tree[2*Mm[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),i=e.opt_len+3+7>>>3,(o=e.static_len+3+7>>>3)<=i&&(i=o)):i=o=r+5,r+4<=i&&-1!==t?aw(e,t,r,n):4===e.strategy||o===i?(Vm(e,2+(n?1:0),3),tw(e,Cm,Pm)):(Vm(e,4+(n?1:0),3),function(e,t,r,n){var i;for(Vm(e,t-257,5),Vm(e,r-1,5),Vm(e,n-4,4),i=0;i>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&r,e.last_lit++,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(Um[r]+km+1)]++,e.dyn_dtree[2*Km(t)]++),e.last_lit===e.lit_bufsize-1}function lw(e,t,r,n){for(var i=65535&e,o=e>>>16&65535,s=0;0!==r;){r-=s=r>2e3?2e3:r;do{o=o+(i=i+t[n++]|0)|0}while(--s);i%=65521,o%=65521}return i|o<<16}var fw=function(){for(var e,t=[],r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}();function dw(e,t,r,n){var i=fw,o=n+r;e^=-1;for(var s=n;s>>8^i[255&(e^t[s])];return~e}var pw,gw=-2,yw=258,mw=262,ww=103,bw=113,vw=666;function _w(e,t){return e.msg=bm[t],t}function Ew(e){return(e<<1)-(e>4?9:0)}function Sw(e){for(var t=e.length;--t>=0;)e[t]=0}function Aw(e){var t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(_m(e.output,t.pending_buf,t.pending_out,r,e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))}function xw(e,t){uw(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Aw(e.strm)}function kw(e,t){e.pending_buf[e.pending++]=t}function Bw(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function Iw(e,t,r,n){var i=e.avail_in;return i>n&&(i=n),0===i?0:(e.avail_in-=i,_m(t,e.input,e.next_in,i,r),1===e.state.wrap?e.adler=lw(e.adler,t,i,r):2===e.state.wrap&&(e.adler=dw(e.adler,t,i,r)),e.next_in+=i,e.total_in+=i,i)}function Tw(e,t){var r,n,i=e.max_chain_length,o=e.strstart,s=e.prev_length,a=e.nice_match,c=e.strstart>e.w_size-mw?e.strstart-(e.w_size-mw):0,u=e.window,h=e.w_mask,l=e.prev,f=e.strstart+yw,d=u[o+s-1],p=u[o+s];e.prev_length>=e.good_match&&(i>>=2),a>e.lookahead&&(a=e.lookahead);do{if(u[(r=t)+s]===p&&u[r+s-1]===d&&u[r]===u[o]&&u[++r]===u[o+1]){o+=2,r++;do{}while(u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&os){if(e.match_start=t,s=n,n>=a)break;d=u[o+s-1],p=u[o+s]}}}while((t=l[t&h])>c&&0!=--i);return s<=e.lookahead?s:e.lookahead}function Rw(e){var t,r,n,i,o,s=e.w_size;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=s+(s-mw)){_m(e.window,e.window,s,s,0),e.match_start-=s,e.strstart-=s,e.block_start-=s,t=r=e.hash_size;do{n=e.head[--t],e.head[t]=n>=s?n-s:0}while(--r);t=r=s;do{n=e.prev[--t],e.prev[t]=n>=s?n-s:0}while(--r);i+=s}if(0===e.strm.avail_in)break;if(r=Iw(e.strm,e.window,e.strstart+e.lookahead,i),e.lookahead+=r,e.lookahead+e.insert>=3)for(o=e.strstart-e.insert,e.ins_h=e.window[o],e.ins_h=(e.ins_h<=3&&(e.ins_h=(e.ins_h<=3)if(n=hw(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=(e.ins_h<=3&&(e.ins_h=(e.ins_h<4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-3,n=hw(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=i&&(e.ins_h=(e.ins_h<5||t<0)return e?_w(e,gw):gw;if(n=e.state,!e.output||!e.input&&0!==e.avail_in||n.status===vw&&4!==t)return _w(e,0===e.avail_out?-5:gw);if(n.strm=e,r=n.last_flush,n.last_flush=t,42===n.status)if(2===n.wrap)e.adler=0,kw(n,31),kw(n,139),kw(n,8),n.gzhead?(kw(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),kw(n,255&n.gzhead.time),kw(n,n.gzhead.time>>8&255),kw(n,n.gzhead.time>>16&255),kw(n,n.gzhead.time>>24&255),kw(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),kw(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(kw(n,255&n.gzhead.extra.length),kw(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=dw(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(kw(n,0),kw(n,0),kw(n,0),kw(n,0),kw(n,0),kw(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),kw(n,3),n.status=bw);else{var s=8+(n.w_bits-8<<4)<<8;s|=(n.strategy>=2||n.level<2?0:n.level<6?1:6===n.level?2:3)<<6,0!==n.strstart&&(s|=32),s+=31-s%31,n.status=bw,Bw(n,s),0!==n.strstart&&(Bw(n,e.adler>>>16),Bw(n,65535&e.adler)),e.adler=1}if(69===n.status)if(n.gzhead.extra){for(i=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>i&&(e.adler=dw(e.adler,n.pending_buf,n.pending-i,i)),Aw(e),i=n.pending,n.pending!==n.pending_buf_size));)kw(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>i&&(e.adler=dw(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=73)}else n.status=73;if(73===n.status)if(n.gzhead.name){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=dw(e.adler,n.pending_buf,n.pending-i,i)),Aw(e),i=n.pending,n.pending===n.pending_buf_size)){o=1;break}o=n.gzindexi&&(e.adler=dw(e.adler,n.pending_buf,n.pending-i,i)),0===o&&(n.gzindex=0,n.status=91)}else n.status=91;if(91===n.status)if(n.gzhead.comment){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=dw(e.adler,n.pending_buf,n.pending-i,i)),Aw(e),i=n.pending,n.pending===n.pending_buf_size)){o=1;break}o=n.gzindexi&&(e.adler=dw(e.adler,n.pending_buf,n.pending-i,i)),0===o&&(n.status=ww)}else n.status=ww;if(n.status===ww&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&Aw(e),n.pending+2<=n.pending_buf_size&&(kw(n,255&e.adler),kw(n,e.adler>>8&255),e.adler=0,n.status=bw)):n.status=bw),0!==n.pending){if(Aw(e),0===e.avail_out)return n.last_flush=-1,0}else if(0===e.avail_in&&Ew(t)<=Ew(r)&&4!==t)return _w(e,-5);if(n.status===vw&&0!==e.avail_in)return _w(e,-5);if(0!==e.avail_in||0!==n.lookahead||0!==t&&n.status!==vw){var a=2===n.strategy?function(e,t){for(var r;;){if(0===e.lookahead&&(Rw(e),0===e.lookahead)){if(0===t)return 1;break}if(e.match_length=0,r=hw(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(xw(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(xw(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(xw(e,!1),0===e.strm.avail_out)?1:2}(n,t):3===n.strategy?function(e,t){for(var r,n,i,o,s=e.window;;){if(e.lookahead<=yw){if(Rw(e),e.lookahead<=yw&&0===t)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(n=s[i=e.strstart-1])===s[++i]&&n===s[++i]&&n===s[++i]){o=e.strstart+yw;do{}while(n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&ie.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(r=hw(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=hw(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(xw(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(xw(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(xw(e,!1),0===e.strm.avail_out)?1:2}(n,t):pw[n.level].func(n,t);if(3!==a&&4!==a||(n.status=vw),1===a||3===a)return 0===e.avail_out&&(n.last_flush=-1),0;if(2===a&&(1===t?cw(n):5!==t&&(aw(n,0,0,!1),3===t&&(Sw(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),Aw(e),0===e.avail_out))return n.last_flush=-1,0}return 4!==t?0:n.wrap<=0?1:(2===n.wrap?(kw(n,255&e.adler),kw(n,e.adler>>8&255),kw(n,e.adler>>16&255),kw(n,e.adler>>24&255),kw(n,255&e.total_in),kw(n,e.total_in>>8&255),kw(n,e.total_in>>16&255),kw(n,e.total_in>>24&255)):(Bw(n,e.adler>>>16),Bw(n,65535&e.adler)),Aw(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?0:1)}pw=[new Mw(0,0,0,0,(function(e,t){var r=65535;for(r>e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(Rw(e),0===e.lookahead&&0===t)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var n=e.block_start+r;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,xw(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-mw&&(xw(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(xw(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(xw(e,!1),e.strm.avail_out),1)})),new Mw(4,4,8,4,Ow),new Mw(4,5,16,8,Ow),new Mw(4,6,32,32,Ow),new Mw(4,4,16,16,Lw),new Mw(8,16,32,32,Lw),new Mw(8,16,128,128,Lw),new Mw(8,32,128,256,Lw),new Mw(32,128,258,1024,Lw),new Mw(32,258,258,4096,Lw)];function Uw(e,t){var r,n,i,o,s,a,c,u,h,l,f,d,p,g,y,m,w,b,v,_,E,S,A,x,k;r=e.state,n=e.next_in,x=e.input,i=n+(e.avail_in-5),o=e.next_out,k=e.output,s=o-(t-e.avail_out),a=o+(e.avail_out-257),c=r.dmax,u=r.wsize,h=r.whave,l=r.wnext,f=r.window,d=r.hold,p=r.bits,g=r.lencode,y=r.distcode,m=(1<>>=v=b>>>24,p-=v,0===(v=b>>>16&255))k[o++]=65535&b;else{if(!(16&v)){if(64&v){if(32&v){r.mode=12;break e}e.msg="invalid literal/length code",r.mode=30;break e}b=g[(65535&b)+(d&(1<>>=v,p-=v),p<15&&(d+=x[n++]<>>=v=b>>>24,p-=v,16&(v=b>>>16&255)){if(E=65535&b,p<(v&=15)&&(d+=x[n++]<c){e.msg="invalid distance too far back",r.mode=30;break e}if(d>>>=v,p-=v,E>(v=o-s)){if((v=E-v)>h&&r.sane){e.msg="invalid distance too far back",r.mode=30;break e}if(S=0,A=f,0===l){if(S+=u-v,v<_){_-=v;do{k[o++]=f[S++]}while(--v);S=o-E,A=k}}else if(l2;)k[o++]=A[S++],k[o++]=A[S++],k[o++]=A[S++],_-=3;_&&(k[o++]=A[S++],_>1&&(k[o++]=A[S++]))}else{S=o-E;do{k[o++]=k[S++],k[o++]=k[S++],k[o++]=k[S++],_-=3}while(_>2);_&&(k[o++]=k[S++],_>1&&(k[o++]=k[S++]))}break}if(64&v){e.msg="invalid distance code",r.mode=30;break e}b=y[(65535&b)+(d&(1<>3,d&=(1<<(p-=_<<3))-1,e.next_in=n,e.next_out=o,e.avail_in=n=1&&0===R[_];_--);if(E>_&&(E=_),0===_)return i[o++]=20971520,i[o++]=20971520,a.bits=1,0;for(v=1;v<_&&0===R[v];v++);for(E0&&(0===e||1!==_))return-1;for(O[1]=0,w=1;w852||2===e&&k>592)return 1;for(;;){p=w-A,s[b]d?(g=L[M+s[b]],y=I[T+s[b]]):(g=96,y=0),c=1<>A)+(u-=c)]=p<<24|g<<16|y}while(0!==u);for(c=1<>=1;if(0!==c?(B&=c-1,B+=c):B=0,b++,0==--R[w]){if(w===_)break;w=t[r+s[b]]}if(w>E&&(B&l)!==h){for(0===A&&(A=E),f+=v,x=1<<(S=w-A);S+A<_&&!((x-=R[S+A])<=0);)S++,x<<=1;if(k+=1<852||2===e&&k>592)return 1;i[h=B&l]=E<<24|S<<16|f-o}}return 0!==B&&(i[f+B]=w-A<<24|64<<16),a.bits=E,0}var qw=-2,Kw=12,Ww=30;function Vw(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function Zw(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Sm(320),this.work=new Sm(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function Gw(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,function(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Am(852),t.distcode=t.distdyn=new Am(592),t.sane=1,t.back=-1,0):qw}(e)):qw}function Jw(e,t){var r,n;return e?(n=new Zw,e.state=n,n.window=null,r=function(e,t){var r,n;return e&&e.state?(n=e.state,t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?qw:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,Gw(e))):qw}(e,t),0!==r&&(e.state=null),r):qw}var Yw,Xw,Qw=!0;function eb(e){if(Qw){var t;for(Yw=new Am(512),Xw=new Am(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Fw(1,e.lens,0,288,Yw,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Fw(2,e.lens,0,32,Xw,0,e.work,{bits:5}),Qw=!1}e.lencode=Yw,e.lenbits=9,e.distcode=Xw,e.distbits=5}function tb(e,t){var r,n,i,o,s,a,c,u,h,l,f,d,p,g,y,m,w,b,v,_,E,S,A,x,k=0,B=new Em(4),I=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return qw;(r=e.state).mode===Kw&&(r.mode=13),s=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,n=e.input,a=e.avail_in,u=r.hold,h=r.bits,l=a,f=c,S=0;e:for(;;)switch(r.mode){case 1:if(0===r.wrap){r.mode=13;break}for(;h<16;){if(0===a)break e;a--,u+=n[o++]<>>8&255,r.check=dw(r.check,B,2,0),u=0,h=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&u)<<8)+(u>>8))%31){e.msg="incorrect header check",r.mode=Ww;break}if(8!=(15&u)){e.msg="unknown compression method",r.mode=Ww;break}if(h-=4,E=8+(15&(u>>>=4)),0===r.wbits)r.wbits=E;else if(E>r.wbits){e.msg="invalid window size",r.mode=Ww;break}r.dmax=1<>8&1),512&r.flags&&(B[0]=255&u,B[1]=u>>>8&255,r.check=dw(r.check,B,2,0)),u=0,h=0,r.mode=3;case 3:for(;h<32;){if(0===a)break e;a--,u+=n[o++]<>>8&255,B[2]=u>>>16&255,B[3]=u>>>24&255,r.check=dw(r.check,B,4,0)),u=0,h=0,r.mode=4;case 4:for(;h<16;){if(0===a)break e;a--,u+=n[o++]<>8),512&r.flags&&(B[0]=255&u,B[1]=u>>>8&255,r.check=dw(r.check,B,2,0)),u=0,h=0,r.mode=5;case 5:if(1024&r.flags){for(;h<16;){if(0===a)break e;a--,u+=n[o++]<>>8&255,r.check=dw(r.check,B,2,0)),u=0,h=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&((d=r.length)>a&&(d=a),d&&(r.head&&(E=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),_m(r.head.extra,n,o,d,E)),512&r.flags&&(r.check=dw(r.check,n,d,o)),a-=d,o+=d,r.length-=d),r.length))break e;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===a)break e;d=0;do{E=n[o+d++],r.head&&E&&r.length<65536&&(r.head.name+=String.fromCharCode(E))}while(E&&d>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=Kw;break;case 10:for(;h<32;){if(0===a)break e;a--,u+=n[o++]<>>=7&h,h-=7&h,r.mode=27;break}for(;h<3;){if(0===a)break e;a--,u+=n[o++]<>>=1)){case 0:r.mode=14;break;case 1:if(eb(r),r.mode=20,6===t){u>>>=2,h-=2;break e}break;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=Ww}u>>>=2,h-=2;break;case 14:for(u>>>=7&h,h-=7&h;h<32;){if(0===a)break e;a--,u+=n[o++]<>>16^65535)){e.msg="invalid stored block lengths",r.mode=Ww;break}if(r.length=65535&u,u=0,h=0,r.mode=15,6===t)break e;case 15:r.mode=16;case 16:if(d=r.length){if(d>a&&(d=a),d>c&&(d=c),0===d)break e;_m(i,n,o,d,s),a-=d,o+=d,c-=d,s+=d,r.length-=d;break}r.mode=Kw;break;case 17:for(;h<14;){if(0===a)break e;a--,u+=n[o++]<>>=5,h-=5,r.ndist=1+(31&u),u>>>=5,h-=5,r.ncode=4+(15&u),u>>>=4,h-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=Ww;break}r.have=0,r.mode=18;case 18:for(;r.have>>=3,h-=3}for(;r.have<19;)r.lens[I[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,A={bits:r.lenbits},S=Fw(0,r.lens,0,19,r.lencode,0,r.work,A),r.lenbits=A.bits,S){e.msg="invalid code lengths set",r.mode=Ww;break}r.have=0,r.mode=19;case 19:for(;r.have>>16&255,w=65535&k,!((y=k>>>24)<=h);){if(0===a)break e;a--,u+=n[o++]<>>=y,h-=y,r.lens[r.have++]=w;else{if(16===w){for(x=y+2;h>>=y,h-=y,0===r.have){e.msg="invalid bit length repeat",r.mode=Ww;break}E=r.lens[r.have-1],d=3+(3&u),u>>>=2,h-=2}else if(17===w){for(x=y+3;h>>=y)),u>>>=3,h-=3}else{for(x=y+7;h>>=y)),u>>>=7,h-=7}if(r.have+d>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=Ww;break}for(;d--;)r.lens[r.have++]=E}}if(r.mode===Ww)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=Ww;break}if(r.lenbits=9,A={bits:r.lenbits},S=Fw(1,r.lens,0,r.nlen,r.lencode,0,r.work,A),r.lenbits=A.bits,S){e.msg="invalid literal/lengths set",r.mode=Ww;break}if(r.distbits=6,r.distcode=r.distdyn,A={bits:r.distbits},S=Fw(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,A),r.distbits=A.bits,S){e.msg="invalid distances set",r.mode=Ww;break}if(r.mode=20,6===t)break e;case 20:r.mode=21;case 21:if(a>=6&&c>=258){e.next_out=s,e.avail_out=c,e.next_in=o,e.avail_in=a,r.hold=u,r.bits=h,Uw(e,f),s=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,n=e.input,a=e.avail_in,u=r.hold,h=r.bits,r.mode===Kw&&(r.back=-1);break}for(r.back=0;m=(k=r.lencode[u&(1<>>16&255,w=65535&k,!((y=k>>>24)<=h);){if(0===a)break e;a--,u+=n[o++]<>b)])>>>16&255,w=65535&k,!(b+(y=k>>>24)<=h);){if(0===a)break e;a--,u+=n[o++]<>>=b,h-=b,r.back+=b}if(u>>>=y,h-=y,r.back+=y,r.length=w,0===m){r.mode=26;break}if(32&m){r.back=-1,r.mode=Kw;break}if(64&m){e.msg="invalid literal/length code",r.mode=Ww;break}r.extra=15&m,r.mode=22;case 22:if(r.extra){for(x=r.extra;h>>=r.extra,h-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;m=(k=r.distcode[u&(1<>>16&255,w=65535&k,!((y=k>>>24)<=h);){if(0===a)break e;a--,u+=n[o++]<>b)])>>>16&255,w=65535&k,!(b+(y=k>>>24)<=h);){if(0===a)break e;a--,u+=n[o++]<>>=b,h-=b,r.back+=b}if(u>>>=y,h-=y,r.back+=y,64&m){e.msg="invalid distance code",r.mode=Ww;break}r.offset=w,r.extra=15&m,r.mode=24;case 24:if(r.extra){for(x=r.extra;h>>=r.extra,h-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=Ww;break}r.mode=25;case 25:if(0===c)break e;if(d=f-c,r.offset>d){if((d=r.offset-d)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=Ww;break}d>r.wnext?(d-=r.wnext,p=r.wsize-d):p=r.wnext-d,d>r.length&&(d=r.length),g=r.window}else g=i,p=s-r.offset,d=r.length;d>c&&(d=c),c-=d,r.length-=d;do{i[s++]=g[p++]}while(--d);0===r.length&&(r.mode=21);break;case 26:if(0===c)break e;i[s++]=r.length,c--,r.mode=21;break;case 27:if(r.wrap){for(;h<32;){if(0===a)break e;a--,u|=n[o++]<=o.wsize?(_m(o.window,t,r-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):((i=o.wsize-o.wnext)>n&&(i=n),_m(o.window,t,r-n,i,o.wnext),(n-=i)?(_m(o.window,t,r-n,n,0),o.wnext=n,o.whave=o.wsize):(o.wnext+=i,o.wnext===o.wsize&&(o.wnext=0),o.whave7)throw new TypeError("Bad argument");this.mode=e,this.init_done=!1,this.write_in_progress=!1,this.pending_close=!1,this.windowBits=0,this.level=0,this.memLevel=0,this.strategy=0,this.dictionary=null}function ib(e,t){for(var r=0;r15&&(s=2,n-=16),i<1||i>9||8!==r||n<8||n>15||t<0||t>9||o<0||o>4)return _w(e,gw);8===n&&(n=9);var a=new Cw;return e.state=a,a.strm=e,a.wrap=s,a.gzhead=null,a.w_bits=n,a.w_size=1<sb.Z_MAX_CHUNK))throw new Error("Invalid chunk size: "+e.chunkSize);if(e.windowBits&&(e.windowBitssb.Z_MAX_WINDOWBITS))throw new Error("Invalid windowBits: "+e.windowBits);if(e.level&&(e.levelsb.Z_MAX_LEVEL))throw new Error("Invalid compression level: "+e.level);if(e.memLevel&&(e.memLevelsb.Z_MAX_MEMLEVEL))throw new Error("Invalid memLevel: "+e.memLevel);if(e.strategy&&e.strategy!=sb.Z_FILTERED&&e.strategy!=sb.Z_HUFFMAN_ONLY&&e.strategy!=sb.Z_RLE&&e.strategy!=sb.Z_FIXED&&e.strategy!=sb.Z_DEFAULT_STRATEGY)throw new Error("Invalid strategy: "+e.strategy);if(e.dictionary&&!C.isBuffer(e.dictionary))throw new Error("Invalid dictionary: it should be a Buffer instance");this._binding=new sb.Zlib(t);var r=this;this._hadError=!1,this._binding.onerror=function(e,t){r._binding=null,r._hadError=!0;var n=new Error(e);n.errno=t,n.code=ab[t],r.emit("error",n)};var n=sb.Z_DEFAULT_COMPRESSION;"number"==typeof e.level&&(n=e.level);var i=sb.Z_DEFAULT_STRATEGY;"number"==typeof e.strategy&&(i=e.strategy),this._binding.init(e.windowBits||sb.Z_DEFAULT_WINDOWBITS,n,e.memLevel||sb.Z_DEFAULT_MEMLEVEL,i,e.dictionary),this._buffer=new C(this._chunkSize),this._offset=0,this._closed=!1,this._level=n,this._strategy=i,this.once("end",this.close)}Object.keys(ab).forEach((function(e){ab[ab[e]]=e})),Pp(jb,cy),jb.prototype.params=function(e,t,r){if(esb.Z_MAX_LEVEL)throw new RangeError("Invalid compression level: "+e);if(t!=sb.Z_FILTERED&&t!=sb.Z_HUFFMAN_ONLY&&t!=sb.Z_RLE&&t!=sb.Z_FIXED&&t!=sb.Z_DEFAULT_STRATEGY)throw new TypeError("Invalid strategy: "+t);if(this._level!==e||this._strategy!==t){var n=this;this.flush(sb.Z_SYNC_FLUSH,(function(){n._binding.params(e,t),n._hadError||(n._level=e,n._strategy=t,r&&r())}))}else Ap.nextTick(r)},jb.prototype.reset=function(){return this._binding.reset()},jb.prototype._flush=function(e){this._transform(new C(0),"",e)},jb.prototype.flush=function(e,t){var r=this._writableState;if(("function"==typeof e||void 0===e&&!t)&&(t=e,e=sb.Z_FULL_FLUSH),r.ended)t&&Ap.nextTick(t);else if(r.ending)t&&this.once("end",t);else if(r.needDrain){var n=this;this.once("drain",(function(){n.flush(t)}))}else this._flushFlag=e,this.write(new C(0),"",t)},jb.prototype.close=function(e){if(e&&Ap.nextTick(e),!this._closed){this._closed=!0,this._binding.close();var t=this;Ap.nextTick((function(){t.emit("close")}))}},jb.prototype._transform=function(e,t,r){var n,i=this._writableState,o=(i.ending||i.ended)&&(!e||i.length===e.length);if(null===!e&&!C.isBuffer(e))return r(new Error("invalid input"));o?n=sb.Z_FINISH:(n=this._flushFlag,e.length>=i.length&&(this._flushFlag=this._opts.flush||sb.Z_NO_FLUSH)),this._processChunk(e,n,r)},jb.prototype._processChunk=function(e,t,r){var n=e&&e.length,i=this._chunkSize-this._offset,o=0,s=this,a="function"==typeof r;if(!a){var c,u=[],h=0;this.on("error",(function(e){c=e}));do{var l=this._binding.writeSync(t,e,o,n,this._buffer,this._offset,i)}while(!this._hadError&&p(l[0],l[1]));if(this._hadError)throw c;var f=C.concat(u,h);return this.close(),f}var d=this._binding.write(t,e,o,n,this._buffer,this._offset,i);function p(c,l){if(!s._hadError){var f=i-l;if(function(e,t){if(!e)throw new Error(t)}(f>=0,"have should not go down"),f>0){var d=s._buffer.slice(s._offset,s._offset+f);s._offset+=f,a?s.push(d):(u.push(d),h+=d.length)}if((0===l||s._offset>=s._chunkSize)&&(i=s._chunkSize,s._offset=0,s._buffer=new C(s._chunkSize)),0===l){if(o+=n-c,n=c,!a)return!0;var g=s._binding.write(t,e,o,n,s._buffer,s._offset,s._chunkSize);return g.callback=p,void(g.buffer=e)}if(!a)return!1;r()}}d.buffer=e,d.callback=p},Pp(Ob,jb),Pp(Lb,jb),Pp(Mb,jb),Pp(Cb,jb),Pp(Pb,jb),Pp(Nb,jb),Pp(Ub,jb);var $b={codes:ab,createDeflate:cb,createInflate:ub,createDeflateRaw:hb,createInflateRaw:lb,createGzip:fb,createGunzip:db,createUnzip:pb,deflate:gb,deflateSync:yb,gzip:mb,gzipSync:wb,deflateRaw:bb,deflateRawSync:vb,unzip:_b,unzipSync:Eb,inflate:Sb,inflateSync:Ab,gunzip:xb,gunzipSync:kb,inflateRaw:Bb,inflateRawSync:Ib,Deflate:Ob,Inflate:Lb,Gzip:Mb,Gunzip:Cb,DeflateRaw:Pb,InflateRaw:Nb,Unzip:Ub,Zlib:jb},Hb=Pr(Object.freeze({__proto__:null,codes:ab,createDeflate:cb,createInflate:ub,createDeflateRaw:hb,createInflateRaw:lb,createGzip:fb,createGunzip:db,createUnzip:pb,deflate:gb,deflateSync:yb,gzip:mb,gzipSync:wb,deflateRaw:bb,deflateRawSync:vb,unzip:_b,unzipSync:Eb,inflate:Sb,inflateSync:Ab,gunzip:xb,gunzipSync:kb,inflateRaw:Bb,inflateRawSync:Ib,Deflate:Ob,Inflate:Lb,Gzip:Mb,Gunzip:Cb,DeflateRaw:Pb,InflateRaw:Nb,Unzip:Ub,Zlib:jb,default:$b})),zb=Pr(_g),Db=Pr(im);Object.defineProperty(Yd,"__esModule",{value:!0}),Yd.InvalidStatusCodeError=Yd.InvalidCertError=void 0;const Fb=Object.freeze({redirect:!0,expectStatusCode:200,headers:{},full:!1,keepAlive:!0,cors:!1,referrer:!1,sslAllowSelfSigned:!1,_redirectCount:0});class qb extends Error{constructor(e,t){super(e),this.fingerprint256=t}}Yd.InvalidCertError=qb;class Kb extends Error{constructor(e){super(`Request Failed. Status Code: ${e}`),this.statusCode=e}}function Wb(e,t){if(!t||"text"===t||"json"===t)try{let r=new TextDecoder("utf8",{fatal:!0}).decode(e);if("text"===t)return r;try{return JSON.parse(r)}catch(e){if("json"===t)throw e;return r}}catch(e){if("text"===t||"json"===t)throw e}return e}Yd.InvalidStatusCodeError=Kb;let Vb={};function Zb(e,t){let r={...Fb,...t};const n=lm,i=wm,o=Hb,{promisify:s}=zb,{resolve:a}=Db,c=!!/^https/.test(e);let u={method:r.method||"GET",headers:{"Accept-Encoding":"gzip, deflate, br"}};const h=e=>e.replace(/:| /g,"").toLowerCase();if(r.keepAlive){const e={keepAlive:!0,keepAliveMsecs:3e4,maxFreeSockets:1024,maxCachedSessions:1024},t=[c,c&&r.sslPinnedCertificates?.map((e=>h(e))).sort()].join();u.agent=Vb[t]||(Vb[t]=new(c?i:n).Agent(e))}"json"===r.type&&(u.headers["Content-Type"]="application/json"),r.data&&(r.method||(u.method="POST"),u.body="json"===r.type?JSON.stringify(r.data):r.data),u.headers={...u.headers,...r.headers},r.sslAllowSelfSigned&&(u.rejectUnauthorized=!1);return new Promise(((t,l)=>{const f=async t=>{if(t&&"DEPTH_ZERO_SELF_SIGNED_CERT"===t.code)try{await Zb(e,{...r,sslAllowSelfSigned:!0,sslPinnedCertificates:[]})}catch(e){e&&e.fingerprint256&&(t=new qb(`Self-signed SSL certificate: ${e.fingerprint256}`,e.fingerprint256))}l(t)},d=(c?i:n).request(e,u,(n=>{n.on("error",f),(async()=>{try{t(await(async t=>{const n=t.statusCode;if(r.redirect&&300<=n&&n<400&&t.headers.location){if(10==r._redirectCount)throw new Error("Request failed. Too much redirects.");return r._redirectCount+=1,await Zb(a(e,t.headers.location),r)}if(r.expectStatusCode&&n!==r.expectStatusCode)throw t.resume(),new Kb(n);let i=[];for await(const e of t)i.push(e);let c=C.concat(i);const u=t.headers["content-encoding"];"br"===u&&(c=await s(o.brotliDecompress)(c)),"gzip"!==u&&"deflate"!==u||(c=await s(o.unzip)(c));const h=Wb(c,r.type);return r.full?{headers:t.headers,status:n,body:h}:h})(n))}catch(e){l(e)}})()}));d.on("error",f);const p=r.sslPinnedCertificates?.map((e=>h(e))),g=e=>{const t=h(e.getPeerCertificate()?.fingerprint256||"");if((t||!e.isSessionReused())&&!p.includes(t))return d.emit("error",new qb(`Invalid SSL certificate: ${t} Expected: ${p}`,t)),d.abort()};r.sslPinnedCertificates&&d.on("socket",(e=>{const t=e.listeners("secureConnect").map((e=>(e.name||"").replace("bound ",""))).includes("mfetchSecureConnect");t||e.on("secureConnect",g.bind(null,e))})),r.keepAlive&&d.setNoDelay(!0),u.body&&d.write(u.body),d.end()}))}const Gb=new Set(["Accept","Accept-Language","Content-Language","Content-Type"].map((e=>e.toLowerCase()))),Jb=new Set(["Accept-Charset","Accept-Encoding","Access-Control-Request-Headers","Access-Control-Request-Method","Connection","Content-Length","Cookie","Cookie2","Date","DNT","Expect","Host","Keep-Alive","Origin","Referer","TE","Trailer","Transfer-Encoding","Upgrade","Via"].map((e=>e.toLowerCase())));async function Yb(e,t){let r={...Fb,...t};const n=new Headers;"json"===r.type&&n.set("Content-Type","application/json");let i=new URL(e);if(i.username){const e=btoa(`${i.username}:${i.password}`);n.set("Authorization",`Basic ${e}`),i.username="",i.password=""}e=""+i;for(let e in r.headers){const t=e.toLowerCase();(Gb.has(t)||r.cors&&!Jb.has(t))&&n.set(e,r.headers[e])}let o={headers:n,redirect:r.redirect?"follow":"manual"};r.referrer||(o.referrerPolicy="no-referrer"),r.cors&&(o.mode="cors"),r.data&&(r.method||(o.method="POST"),o.body="json"===r.type?JSON.stringify(r.data):r.data);const s=await fetch(e,o);if(r.expectStatusCode&&s.status!==r.expectStatusCode)throw new Kb(s.status);const a=Wb(new Uint8Array(await s.arrayBuffer()),r.type);return r.full?{headers:Object.fromEntries(s.headers.entries()),status:s.status,body:a}:a}const Xb=!!("object"==typeof process&&process.versions&&process.versions.node&&process.versions.v8);Yd.default=function(e,t){return(Xb?Zb:Yb)(e,t)},Object.defineProperty(Jd,"__esModule",{value:!0}),Jd.getProvider=Jd.fetchFromProvider=void 0;const Qb=Yd;Jd.fetchFromProvider=async(e,t)=>(await(0,Qb.default)(e,{headers:{"content-type":"application/json"},type:"json",data:{method:t.method,params:t.params,jsonrpc:"2.0",id:1}})).result;Jd.getProvider=e=>{if("string"==typeof e)return e;if(void 0!==e?.connection?.url)return e.connection.url;throw new Error("Must provide valid provider URL or Web3Provider")},function(e){var t=Cr&&Cr.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=Cr&&Cr.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.toAscii=e.stripHexPrefix=e.padToEven=e.isHexString=e.isHexPrefixed=e.getKeys=e.getBinarySize=e.fromUtf8=e.fromAscii=e.arrayContainsArray=void 0,r(vh,e),r(nf,e),r(of,e),r(kd,e),r(Rd,e),r(Nd,e),r(vd,e),r(Od,e),r(qd,e),r(Kd,e);var n=Ed;Object.defineProperty(e,"arrayContainsArray",{enumerable:!0,get:function(){return n.arrayContainsArray}}),Object.defineProperty(e,"fromAscii",{enumerable:!0,get:function(){return n.fromAscii}}),Object.defineProperty(e,"fromUtf8",{enumerable:!0,get:function(){return n.fromUtf8}}),Object.defineProperty(e,"getBinarySize",{enumerable:!0,get:function(){return n.getBinarySize}}),Object.defineProperty(e,"getKeys",{enumerable:!0,get:function(){return n.getKeys}}),Object.defineProperty(e,"isHexPrefixed",{enumerable:!0,get:function(){return n.isHexPrefixed}}),Object.defineProperty(e,"isHexString",{enumerable:!0,get:function(){return n.isHexString}}),Object.defineProperty(e,"padToEven",{enumerable:!0,get:function(){return n.padToEven}}),Object.defineProperty(e,"stripHexPrefix",{enumerable:!0,get:function(){return n.stripHexPrefix}}),Object.defineProperty(e,"toAscii",{enumerable:!0,get:function(){return n.toAscii}}),r(Gd,e),r(Jd,e)}(bh);var ev={},tv={},rv={},nv={},iv={};Object.defineProperty(iv,"__esModule",{value:!0}),iv.StructError=void 0;class ov extends TypeError{constructor(e,t){let r;const{message:n,explanation:i,...o}=e,{path:s}=e,a=0===s.length?n:`At path: ${s.join(".")} -- ${n}`;super(i??a),null!=i&&(this.cause=a),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>r??(r=[e,...t()])}}iv.StructError=ov;var sv={},av={};function cv(e){return"object"==typeof e&&null!==e}function uv(e){return"symbol"==typeof e?e.toString():"string"==typeof e?JSON.stringify(e):`${e}`}function hv(e,t,r,n){if(!0===e)return;!1===e?e={}:"string"==typeof e&&(e={message:e});const{path:i,branch:o}=t,{type:s}=r,{refinement:a,message:c=`Expected a value of type \`${s}\`${a?` with refinement \`${a}\``:""}, but received: \`${uv(n)}\``}=e;return{value:n,type:s,refinement:a,key:i[i.length-1],path:i,branch:o,...e,message:c}}Object.defineProperty(av,"__esModule",{value:!0}),av.run=av.toFailures=av.toFailure=av.shiftIterator=av.print=av.isPlainObject=av.isObject=void 0,av.isObject=cv,av.isPlainObject=function(e){if("[object Object]"!==Object.prototype.toString.call(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype},av.print=uv,av.shiftIterator=function(e){const{done:t,value:r}=e.next();return t?void 0:r},av.toFailure=hv,av.toFailures=function*(e,t,r,n){(function(e){return cv(e)&&"function"==typeof e[Symbol.iterator]})(e)||(e=[e]);for(const i of e){const e=hv(i,t,r,n);e&&(yield e)}},av.run=function*e(t,r,n={}){const{path:i=[],branch:o=[t],coerce:s=!1,mask:a=!1}=n,c={path:i,branch:o};if(s&&(t=r.coercer(t,c),a&&"type"!==r.type&&cv(r.schema)&&cv(t)&&!Array.isArray(t)))for(const e in t)void 0===r.schema[e]&&delete t[e];let u="valid";for(const e of r.validator(t,c))e.explanation=n.message,u="not_valid",yield[e,void 0];for(let[h,l,f]of r.entries(t,c)){const r=e(l,f,{path:void 0===h?i:[...i,h],branch:void 0===h?o:[...o,l],coerce:s,mask:a,message:n.message});for(const e of r)e[0]?(u=null===e[0].refinement||void 0===e[0].refinement?"not_valid":"not_refined",yield[e[0],void 0]):s&&(l=e[1],void 0===h?t=l:t instanceof Map?t.set(h,l):t instanceof Set?t.add(l):cv(t)&&(void 0!==l||h in t)&&(t[h]=l))}if("not_valid"!==u)for(const e of r.refiner(t,c))e.explanation=n.message,u="not_refined",yield[e,void 0];"valid"===u&&(yield[void 0,t])},Object.defineProperty(sv,"__esModule",{value:!0}),sv.validate=sv.is=sv.mask=sv.create=sv.assert=sv.Struct=void 0;const lv=iv,fv=av;function dv(e,t,r){const n=mv(e,t,{message:r});if(n[0])throw n[0]}function pv(e,t,r){const n=mv(e,t,{coerce:!0,message:r});if(n[0])throw n[0];return n[1]}function gv(e,t,r){const n=mv(e,t,{coerce:!0,mask:!0,message:r});if(n[0])throw n[0];return n[1]}function yv(e,t){return!mv(e,t)[0]}function mv(e,t,r={}){const n=(0,fv.run)(e,t,r),i=(0,fv.shiftIterator)(n);if(i[0]){return[new lv.StructError(i[0],(function*(){for(const e of n)e[0]&&(yield e[0])})),void 0]}return[void 0,i[1]]}sv.Struct=class{constructor(e){const{type:t,schema:r,validator:n,refiner:i,coercer:o=e=>e,entries:s=function*(){}}=e;this.type=t,this.schema=r,this.entries=s,this.coercer=o,this.validator=n?(e,t)=>{const r=n(e,t);return(0,fv.toFailures)(r,t,this,e)}:()=>[],this.refiner=i?(e,t)=>{const r=i(e,t);return(0,fv.toFailures)(r,t,this,e)}:()=>[]}assert(e,t){return dv(e,this,t)}create(e,t){return pv(e,this,t)}is(e){return yv(e,this)}mask(e,t){return gv(e,this,t)}validate(e,t={}){return mv(e,this,t)}},sv.assert=dv,sv.create=pv,sv.mask=gv,sv.is=yv,sv.validate=mv;var wv,bv,vv={},_v={},Ev={};function Sv(){if(wv)return Ev;wv=1,Object.defineProperty(Ev,"__esModule",{value:!0}),Ev.pick=Ev.partial=Ev.omit=Ev.lazy=Ev.dynamic=Ev.deprecated=Ev.define=Ev.assign=void 0;const e=sv,t=Av();return Ev.assign=function(...e){const r="type"===e[0]?.type,n=e.map((({schema:e})=>e)),i=Object.assign({},...n);return r?(0,t.type)(i):(0,t.object)(i)},Ev.define=function(t,r){return new e.Struct({type:t,schema:null,validator:r})},Ev.deprecated=function(t,r){return new e.Struct({...t,refiner:(e,r)=>void 0===e||t.refiner(e,r),validator:(e,n)=>void 0===e||(r(e,n),t.validator(e,n))})},Ev.dynamic=function(t){return new e.Struct({type:"dynamic",schema:null,*entries(e,r){const n=t(e,r);yield*n.entries(e,r)},validator:(e,r)=>t(e,r).validator(e,r),coercer:(e,r)=>t(e,r).coercer(e,r),refiner:(e,r)=>t(e,r).refiner(e,r)})},Ev.lazy=function(t){let r;return new e.Struct({type:"lazy",schema:null,*entries(e,n){r??(r=t()),yield*r.entries(e,n)},validator:(e,n)=>(r??(r=t()),r.validator(e,n)),coercer:(e,n)=>(r??(r=t()),r.coercer(e,n)),refiner:(e,n)=>(r??(r=t()),r.refiner(e,n))})},Ev.omit=function(e,r){const{schema:n}=e,i={...n};for(const e of r)delete i[e];return"type"===e.type?(0,t.type)(i):(0,t.object)(i)},Ev.partial=function(r){const n=r instanceof e.Struct,i=n?{...r.schema}:{...r};for(const e in i)i[e]=(0,t.optional)(i[e]);return n&&"type"===r.type?(0,t.type)(i):(0,t.object)(i)},Ev.pick=function(e,r){const{schema:n}=e,i={};for(const e of r)i[e]=n[e];return"type"===e.type?(0,t.type)(i):(0,t.object)(i)},Ev}function Av(){if(bv)return _v;bv=1,Object.defineProperty(_v,"__esModule",{value:!0}),_v.unknown=_v.union=_v.type=_v.tuple=_v.string=_v.set=_v.regexp=_v.record=_v.optional=_v.object=_v.number=_v.nullable=_v.never=_v.map=_v.literal=_v.intersection=_v.integer=_v.instance=_v.func=_v.enums=_v.date=_v.boolean=_v.bigint=_v.array=_v.any=void 0;const e=sv,t=av,r=Sv();function n(){return(0,r.define)("never",(()=>!1))}return _v.any=function(){return(0,r.define)("any",(()=>!0))},_v.array=function(r){return new e.Struct({type:"array",schema:r,*entries(e){if(r&&Array.isArray(e))for(const[t,n]of e.entries())yield[t,n,r]},coercer:e=>Array.isArray(e)?e.slice():e,validator:e=>Array.isArray(e)||`Expected an array value, but received: ${(0,t.print)(e)}`})},_v.bigint=function(){return(0,r.define)("bigint",(e=>"bigint"==typeof e))},_v.boolean=function(){return(0,r.define)("boolean",(e=>"boolean"==typeof e))},_v.date=function(){return(0,r.define)("date",(e=>e instanceof Date&&!isNaN(e.getTime())||`Expected a valid \`Date\` object, but received: ${(0,t.print)(e)}`))},_v.enums=function(r){const n={},i=r.map((e=>(0,t.print)(e))).join();for(const e of r)n[e]=e;return new e.Struct({type:"enums",schema:n,validator:e=>r.includes(e)||`Expected one of \`${i}\`, but received: ${(0,t.print)(e)}`})},_v.func=function(){return(0,r.define)("func",(e=>"function"==typeof e||`Expected a function, but received: ${(0,t.print)(e)}`))},_v.instance=function(e){return(0,r.define)("instance",(r=>r instanceof e||`Expected a \`${e.name}\` instance, but received: ${(0,t.print)(r)}`))},_v.integer=function(){return(0,r.define)("integer",(e=>"number"==typeof e&&!isNaN(e)&&Number.isInteger(e)||`Expected an integer, but received: ${(0,t.print)(e)}`))},_v.intersection=function(t){return new e.Struct({type:"intersection",schema:null,*entries(e,r){for(const{entries:n}of t)yield*n(e,r)},*validator(e,r){for(const{validator:n}of t)yield*n(e,r)},*refiner(e,r){for(const{refiner:n}of t)yield*n(e,r)}})},_v.literal=function(r){const n=(0,t.print)(r),i=typeof r;return new e.Struct({type:"literal",schema:"string"===i||"number"===i||"boolean"===i?r:null,validator:e=>e===r||`Expected the literal \`${n}\`, but received: ${(0,t.print)(e)}`})},_v.map=function(r,n){return new e.Struct({type:"map",schema:null,*entries(e){if(r&&n&&e instanceof Map)for(const[t,i]of e.entries())yield[t,t,r],yield[t,i,n]},coercer:e=>e instanceof Map?new Map(e):e,validator:e=>e instanceof Map||`Expected a \`Map\` object, but received: ${(0,t.print)(e)}`})},_v.never=n,_v.nullable=function(t){return new e.Struct({...t,validator:(e,r)=>null===e||t.validator(e,r),refiner:(e,r)=>null===e||t.refiner(e,r)})},_v.number=function(){return(0,r.define)("number",(e=>"number"==typeof e&&!isNaN(e)||`Expected a number, but received: ${(0,t.print)(e)}`))},_v.object=function(r){const i=r?Object.keys(r):[],o=n();return new e.Struct({type:"object",schema:r??null,*entries(e){if(r&&(0,t.isObject)(e)){const t=new Set(Object.keys(e));for(const n of i)t.delete(n),yield[n,e[n],r[n]];for(const r of t)yield[r,e[r],o]}},validator:e=>(0,t.isObject)(e)||`Expected an object, but received: ${(0,t.print)(e)}`,coercer:e=>(0,t.isObject)(e)?{...e}:e})},_v.optional=function(t){return new e.Struct({...t,validator:(e,r)=>void 0===e||t.validator(e,r),refiner:(e,r)=>void 0===e||t.refiner(e,r)})},_v.record=function(r,n){return new e.Struct({type:"record",schema:null,*entries(e){if((0,t.isObject)(e))for(const t in e){const i=e[t];yield[t,t,r],yield[t,i,n]}},validator:e=>(0,t.isObject)(e)||`Expected an object, but received: ${(0,t.print)(e)}`})},_v.regexp=function(){return(0,r.define)("regexp",(e=>e instanceof RegExp))},_v.set=function(r){return new e.Struct({type:"set",schema:null,*entries(e){if(r&&e instanceof Set)for(const t of e)yield[t,t,r]},coercer:e=>e instanceof Set?new Set(e):e,validator:e=>e instanceof Set||`Expected a \`Set\` object, but received: ${(0,t.print)(e)}`})},_v.string=function(){return(0,r.define)("string",(e=>"string"==typeof e||`Expected a string, but received: ${(0,t.print)(e)}`))},_v.tuple=function(r){const i=n();return new e.Struct({type:"tuple",schema:null,*entries(e){if(Array.isArray(e)){const t=Math.max(r.length,e.length);for(let n=0;nArray.isArray(e)||`Expected an array, but received: ${(0,t.print)(e)}`})},_v.type=function(r){const n=Object.keys(r);return new e.Struct({type:"type",schema:r,*entries(e){if((0,t.isObject)(e))for(const t of n)yield[t,e[t],r[t]]},validator:e=>(0,t.isObject)(e)||`Expected an object, but received: ${(0,t.print)(e)}`,coercer:e=>(0,t.isObject)(e)?{...e}:e})},_v.union=function(r){const n=r.map((e=>e.type)).join(" | ");return new e.Struct({type:"union",schema:null,coercer(e){for(const t of r){const[r,n]=t.validate(e,{coerce:!0});if(!r)return n}return e},validator(e,i){const o=[];for(const n of r){const[...r]=(0,t.run)(e,n,i),[s]=r;if(!s?.[0])return[];for(const[e]of r)e&&o.push(e)}return[`Expected the value to satisfy a union of \`${n}\`, but received: ${(0,t.print)(e)}`,...o]}})},_v.unknown=function(){return(0,r.define)("unknown",(()=>!0))},_v}Object.defineProperty(vv,"__esModule",{value:!0}),vv.trimmed=vv.defaulted=vv.coerce=void 0;const xv=sv,kv=av,Bv=Av();function Iv(e,t,r){return new xv.Struct({...e,coercer:(n,i)=>(0,xv.is)(n,t)?e.coercer(r(n,i),i):e.coercer(n,i)})}vv.coerce=Iv,vv.defaulted=function(e,t,r={}){return Iv(e,(0,Bv.unknown)(),(e=>{const n="function"==typeof t?t():t;if(void 0===e)return n;if(!r.strict&&(0,kv.isPlainObject)(e)&&(0,kv.isPlainObject)(n)){const t={...e};let r=!1;for(const e in n)void 0===t[e]&&(t[e]=n[e],r=!0);if(r)return t}return e}))},vv.trimmed=function(e){return Iv(e,(0,Bv.string)(),(e=>e.trim()))};var Tv={};Object.defineProperty(Tv,"__esModule",{value:!0}),Tv.refine=Tv.size=Tv.pattern=Tv.nonempty=Tv.min=Tv.max=Tv.empty=void 0;const Rv=sv,Ov=av;function Lv(e){return e instanceof Map||e instanceof Set?e.size:e.length}function Mv(e,t,r){return new Rv.Struct({...e,*refiner(n,i){yield*e.refiner(n,i);const o=r(n,i),s=(0,Ov.toFailures)(o,i,e,n);for(const e of s)yield{...e,refinement:t}}})}Tv.empty=function(e){return Mv(e,"empty",(t=>{const r=Lv(t);return 0===r||`Expected an empty ${e.type} but received one with a size of \`${r}\``}))},Tv.max=function(e,t,r={}){const{exclusive:n}=r;return Mv(e,"max",(r=>n?rn?r>t:r>=t||`Expected a ${e.type} greater than ${n?"":"or equal to "}${t} but received \`${r}\``))},Tv.nonempty=function(e){return Mv(e,"nonempty",(t=>Lv(t)>0||`Expected a nonempty ${e.type} but received an empty one`))},Tv.pattern=function(e,t){return Mv(e,"pattern",(r=>t.test(r)||`Expected a ${e.type} matching \`/${t.source}/\` but received "${r}"`))},Tv.size=function(e,t,r=t){const n=`Expected a ${e.type}`,i=t===r?`of \`${t}\``:`between \`${t}\` and \`${r}\``;return Mv(e,"size",(e=>{if("number"==typeof e||e instanceof Date)return t<=e&&e<=r||`${n} ${i} but received \`${e}\``;if(e instanceof Map||e instanceof Set){const{size:o}=e;return t<=o&&o<=r||`${n} with a size ${i} but received one with a size of \`${o}\``}const{length:o}=e;return t<=o&&o<=r||`${n} with a length ${i} but received one with a length of \`${o}\``}))},Tv.refine=Mv,function(e){var t=Cr&&Cr.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=Cr&&Cr.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(iv,e),r(sv,e),r(vv,e),r(Tv,e),r(Av(),e),r(Sv(),e)}(nv);var Cv={};class Pv extends Error{constructor(e,{cause:t}={}){super(e),this.name=Pv.name,t&&(this.cause=t),this.message=e}}var Nv=Pr(Object.freeze({__proto__:null,ErrorWithCause:Pv}));const Uv=e=>{if(e&&"object"==typeof e&&"cause"in e){if("function"==typeof e.cause){const t=e.cause();return t instanceof Error?t:void 0}return e.cause instanceof Error?e.cause:void 0}},jv=(e,t)=>{if(!(e instanceof Error))return"";const r=e.stack||"";if(t.has(e))return r+"\ncauses have become circular...";const n=Uv(e);return n?(t.add(e),r+"\ncaused by: "+jv(n,t)):r},$v=(e,t,r)=>{if(!(e instanceof Error))return"";const n=r?"":e.message||"";if(t.has(e))return n+": ...";const i=Uv(e);if(i){t.add(e);const r="cause"in e&&"function"==typeof e.cause;return n+(r?"":": ")+$v(i,t,r)}return n};var Hv=Object.freeze({__proto__:null,findCauseByReference:(e,t)=>{if(!e||!t)return;if(!(e instanceof Error))return;if(!(t.prototype instanceof Error)&&t!==Error)return;const r=new Set;let n=e;for(;n&&!r.has(n);){if(r.add(n),n instanceof t)return n;n=Uv(n)}},getErrorCause:Uv,stackWithCauses:e=>jv(e,new Set),messageWithCauses:e=>$v(e,new Set)}),zv=Pr(Hv);const{ErrorWithCause:Dv}=Nv,{findCauseByReference:Fv,getErrorCause:qv,messageWithCauses:Kv,stackWithCauses:Wv}=zv;var Vv={ErrorWithCause:Dv,findCauseByReference:Fv,getErrorCause:qv,stackWithCauses:Wv,messageWithCauses:Kv},Zv={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.calculateNumberSize=e.calculateStringSize=e.isASCII=e.isPlainObject=e.ESCAPE_CHARACTERS_REGEXP=e.JsonSize=e.getKnownPropertyNames=e.hasProperty=e.isObject=e.isNullOrUndefined=e.isNonEmptyArray=void 0,e.isNonEmptyArray=function(e){return Array.isArray(e)&&e.length>0},e.isNullOrUndefined=function(e){return null==e},e.isObject=function(e){return Boolean(e)&&"object"==typeof e&&!Array.isArray(e)};var t;function r(e){return e.charCodeAt(0)<=127}e.hasProperty=(e,t)=>Object.hasOwnProperty.call(e,t),e.getKnownPropertyNames=function(e){return Object.getOwnPropertyNames(e)},(t=e.JsonSize||(e.JsonSize={}))[t.Null=4]="Null",t[t.Comma=1]="Comma",t[t.Wrapper=1]="Wrapper",t[t.True=4]="True",t[t.False=5]="False",t[t.Quote=1]="Quote",t[t.Colon=1]="Colon",t[t.Date=24]="Date",e.ESCAPE_CHARACTERS_REGEXP=/"|\\|\n|\r|\t/gu,e.isPlainObject=function(e){if("object"!=typeof e||null===e)return!1;try{let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}catch(e){return!1}},e.isASCII=r,e.calculateStringSize=function(t){return t.split("").reduce(((e,t)=>r(t)?e+1:e+2),0)+(t.match(e.ESCAPE_CHARACTERS_REGEXP)??[]).length},e.calculateNumberSize=function(e){return e.toString().length}}(Zv),Object.defineProperty(Cv,"__esModule",{value:!0}),Cv.wrapError=Cv.getErrorMessage=Cv.isErrorWithStack=Cv.isErrorWithMessage=Cv.isErrorWithCode=void 0;const Gv=Vv,Jv=Zv;function Yv(e){return"object"==typeof e&&null!==e&&"code"in e}function Xv(e){return"object"==typeof e&&null!==e&&"message"in e}Cv.isErrorWithCode=Yv,Cv.isErrorWithMessage=Xv,Cv.isErrorWithStack=function(e){return"object"==typeof e&&null!==e&&"stack"in e},Cv.getErrorMessage=function(e){return Xv(e)&&"string"==typeof e.message?e.message:(0,Jv.isNullOrUndefined)(e)?"":String(e)},Cv.wrapError=function(e,t){if(function(e){return e instanceof Error||(0,Jv.isObject)(e)&&"Error"===e.constructor.name}(e)){let r;return r=2===Error.length?new Error(t,{cause:e}):new Gv.ErrorWithCause(t,{cause:e}),Yv(e)&&(r.code=e.code),r}return t.length>0?new Error(`${String(e)}: ${t}`):new Error(String(e))},Object.defineProperty(rv,"__esModule",{value:!0}),rv.assertExhaustive=rv.assertStruct=rv.assert=rv.AssertionError=void 0;const Qv=nv,e_=Cv;function t_(e,t){return r=e,Boolean("string"==typeof r?.prototype?.constructor?.name)?new e({message:t}):e({message:t});var r}class r_ extends Error{constructor(e){super(e.message),this.code="ERR_ASSERTION"}}rv.AssertionError=r_,rv.assert=function(e,t="Assertion failed.",r=r_){if(!e){if(t instanceof Error)throw t;throw t_(r,t)}},rv.assertStruct=function(e,t,r="Assertion failed",n=r_){try{(0,Qv.assert)(e,t)}catch(e){throw t_(n,`${r}: ${function(e){return(0,e_.getErrorMessage)(e).replace(/\.$/u,"")}(e)}.`)}},rv.assertExhaustive=function(e){throw new Error("Invalid branch reached. Should be detected during compilation.")};var n_={};Object.defineProperty(n_,"__esModule",{value:!0}),n_.base64=void 0;const i_=nv,o_=rv;n_.base64=(e,t={})=>{const r=t.paddingRequired??!1,n=t.characterSet??"base64";let i,o;return"base64"===n?i=String.raw`[A-Za-z0-9+\/]`:((0,o_.assert)("base64url"===n),i=String.raw`[-_A-Za-z0-9]`),o=r?new RegExp(`^(?:${i}{4})*(?:${i}{3}=|${i}{2}==)?$`,"u"):new RegExp(`^(?:${i}{4})*(?:${i}{2,3}|${i}{3}=|${i}{2}==)?$`,"u"),(0,i_.pattern)(e,o)};var s_={},a_={};!function(e){function t(e){if(!Number.isSafeInteger(e))throw new Error(`Wrong integer: ${e}`)}function r(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}function n(...e){const t=e=>e,r=(e,t)=>r=>e(t(r)),n=e.map((e=>e.encode)).reduceRight(r,t),i=e.map((e=>e.decode)).reduce(r,t);return{encode:n,decode:i}}function i(e){return{encode:r=>{if(!Array.isArray(r)||r.length&&"number"!=typeof r[0])throw new Error("alphabet.encode input should be an array of numbers");return r.map((r=>{if(t(r),r<0||r>=e.length)throw new Error(`Digit index outside alphabet: ${r} (alphabet: ${e.length})`);return e[r]}))},decode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("alphabet.decode input should be array of strings");return t.map((t=>{if("string"!=typeof t)throw new Error(`alphabet.decode: not string element=${t}`);const r=e.indexOf(t);if(-1===r)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return r}))}}}function o(e=""){if("string"!=typeof e)throw new Error("join separator should be string");return{encode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("join.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`join.encode: non-string input=${e}`);return t.join(e)},decode:t=>{if("string"!=typeof t)throw new Error("join.decode input should be string");return t.split(e)}}}function s(e,r="="){if(t(e),"string"!=typeof r)throw new Error("padding chr should be string");return{encode(t){if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("padding.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`padding.encode: non-string input=${e}`);for(;t.length*e%8;)t.push(r);return t},decode(t){if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("padding.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error(`padding.decode: non-string input=${e}`);let n=t.length;if(n*e%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;n>0&&t[n-1]===r;n--)if(!((n-1)*e%8))throw new Error("Invalid padding: string has too much padding");return t.slice(0,n)}}}function a(e){if("function"!=typeof e)throw new Error("normalize fn should be function");return{encode:e=>e,decode:t=>e(t)}}function c(e,r,n){if(r<2)throw new Error(`convertRadix: wrong from=${r}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: wrong to=${n}, base cannot be less than 2`);if(!Array.isArray(e))throw new Error("convertRadix: data should be array");if(!e.length)return[];let i=0;const o=[],s=Array.from(e);for(s.forEach((e=>{if(t(e),e<0||e>=r)throw new Error(`Wrong integer: ${e}`)}));;){let e=0,t=!0;for(let o=i;ot?u(t,e%t):e,l=(e,t)=>e+(t-u(e,t));function h(e,r,n,i){if(!Array.isArray(e))throw new Error("convertRadix2: data should be array");if(r<=0||r>32)throw new Error(`convertRadix2: wrong from=${r}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(l(r,n)>32)throw new Error(`convertRadix2: carry overflow from=${r} to=${n} carryBits=${l(r,n)}`);let o=0,s=0;const a=2**n-1,c=[];for(const i of e){if(t(i),i>=2**r)throw new Error(`convertRadix2: invalid data word=${i} from=${r}`);if(o=o<32)throw new Error(`convertRadix2: carry overflow pos=${s} from=${r}`);for(s+=r;s>=n;s-=n)c.push((o>>s-n&a)>>>0);o&=2**s-1}if(o=o<=r)throw new Error("Excess padding");if(!i&&o)throw new Error(`Non-zero padding: ${o}`);return i&&s>0&&c.push(o>>>0),c}function f(e){return t(e),{encode:t=>{if(!r(t))throw new Error("radix.encode input should be Uint8Array");return c(Array.from(t),256,e)},decode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("radix.decode input should be array of numbers");return Uint8Array.from(c(t,e,256))}}}function d(e,n=!1){if(t(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(l(8,e)>32||l(e,8)>32)throw new Error("radix2: carry overflow");return{encode:t=>{if(!r(t))throw new Error("radix2.encode input should be Uint8Array");return h(Array.from(t),8,e,!n)},decode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("radix2.decode input should be array of numbers");return Uint8Array.from(h(t,e,8,n))}}}function p(e){if("function"!=typeof e)throw new Error("unsafeWrapper fn should be function");return function(...t){try{return e.apply(null,t)}catch(e){}}}function g(e,n){if(t(e),"function"!=typeof n)throw new Error("checksum fn should be function");return{encode(t){if(!r(t))throw new Error("checksum.encode: input should be Uint8Array");const i=n(t).slice(0,e),o=new Uint8Array(t.length+e);return o.set(t),o.set(i,t.length),o},decode(t){if(!r(t))throw new Error("checksum.decode: input should be Uint8Array");const i=t.slice(0,-e),o=n(i).slice(0,e),s=t.slice(-e);for(let t=0;te.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")))),e.base64=n(d(6),i("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),s(6),o("")),e.base64nopad=n(d(6),i("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),o("")),e.base64url=n(d(6),i("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),s(6),o("")),e.base64urlnopad=n(d(6),i("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),o(""));const y=e=>n(f(58),i(e),o(""));e.base58=y("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),e.base58flickr=y("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),e.base58xrp=y("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const m=[0,2,3,5,6,7,9,10,11];e.base58xmr={encode(t){let r="";for(let n=0;nn(g(4,(e=>t(t(e)))),e.base58),e.base58check=e.createBase58check;const w=n(i("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),o("")),b=[996825010,642813549,513874426,1027748829,705979059];function v(e){const t=e>>25;let r=(33554431&e)<<5;for(let e=0;e>e&1)&&(r^=b[e]);return r}function _(e,t,r=1){const n=e.length;let i=1;for(let t=0;t126)throw new Error(`Invalid prefix (${e})`);i=v(i)^r>>5}i=v(i);for(let t=0;tr)throw new TypeError(`Wrong string length: ${e.length} (${e}). Expected (8..${r})`);const n=e.toLowerCase();if(e!==n&&e!==e.toUpperCase())throw new Error("String must be lowercase or uppercase");const i=n.lastIndexOf("1");if(0===i||-1===i)throw new Error('Letter "1" must be present between prefix and data only');const o=n.slice(0,i),s=n.slice(i+1);if(s.length<6)throw new Error("Data must be at least 6 characters long");const a=w.decode(s).slice(0,-6),c=_(o,a,t);if(!s.endsWith(c))throw new Error(`Invalid checksum in ${e}: expected "${c}"`);return{prefix:o,words:a}}return{encode:function(e,r,n=90){if("string"!=typeof e)throw new Error("bech32.encode prefix should be string, not "+typeof e);if(!Array.isArray(r)||r.length&&"number"!=typeof r[0])throw new Error("bech32.encode words should be array of numbers, not "+typeof r);if(0===e.length)throw new TypeError(`Invalid prefix length ${e.length}`);const i=e.length+7+r.length;if(!1!==n&&i>n)throw new TypeError(`Length ${i} exceeds limit ${n}`);const o=e.toLowerCase(),s=_(o,r,t);return`${o}1${w.encode(r)}${s}`},decode:s,decodeToBytes:function(e){const{prefix:t,words:r}=s(e,!1);return{prefix:t,words:r,bytes:n(r)}},decodeUnsafe:p(s),fromWords:n,fromWordsUnsafe:o,toWords:i}}e.bech32=E("bech32"),e.bech32m=E("bech32m"),e.utf8={encode:e=>(new TextDecoder).decode(e),decode:e=>(new TextEncoder).encode(e)},e.hex=n(d(4),i("0123456789abcdef"),o(""),a((e=>{if("string"!=typeof e||e.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()})));const S={utf8:e.utf8,hex:e.hex,base16:e.base16,base32:e.base32,base64:e.base64,base64url:e.base64url,base58:e.base58,base58xmr:e.base58xmr},x="Invalid encoding type. Available types: utf8, hex, base16, base32, base64, base64url, base58, base58xmr";e.bytesToString=(e,t)=>{if("string"!=typeof e||!S.hasOwnProperty(e))throw new TypeError(x);if(!r(t))throw new TypeError("bytesToString() expects Uint8Array");return S[e].encode(t)},e.str=e.bytesToString;e.stringToBytes=(e,t)=>{if(!S.hasOwnProperty(e))throw new TypeError(x);if("string"!=typeof t)throw new TypeError("stringToBytes() expects string");return S[e].decode(t)},e.bytes=e.stringToBytes}(nE),Object.defineProperty(ev,"__esModule",{value:!0});var iE=tv,oE=Qv,sE=Zv,aE=nE;var cE=function(){const e=[];return()=>{if(0===e.length)for(let t=0;t<256;t++)e.push(t.toString(16).padStart(2,"0"));return e}}();function uE(e){return e instanceof Uint8Array}function lE(e){iE.assert.call(void 0,uE(e),"Value must be a Uint8Array.")}function hE(e){if(lE(e),0===e.length)return"0x";const t=cE(),r=new Array(e.length);for(let n=0;nr.call(t,...e))),t=void 0)}return r}([e,"optionalAccess",e=>e.toLowerCase,"optionalCall",e=>e()]))return new Uint8Array;xE(e);const t=BE(e).toLowerCase(),r=t.length%2==0?t:`0${t}`,n=new Uint8Array(r.length/2);for(let e=0;e=BigInt(0),"Value must be a non-negative bigint.");return dE(e.toString(16))}function gE(e){iE.assert.call(void 0,"number"==typeof e,"Value must be a number."),iE.assert.call(void 0,e>=0,"Value must be a non-negative number."),iE.assert.call(void 0,Number.isSafeInteger(e),"Value is not a safe integer. Use `bigIntToBytes` instead.");return dE(e.toString(16))}function yE(e){return iE.assert.call(void 0,"string"==typeof e,"Value must be a string."),(new TextEncoder).encode(e)}function mE(e){if("bigint"==typeof e)return pE(e);if("number"==typeof e)return gE(e);if("string"==typeof e)return e.startsWith("0x")?dE(e):yE(e);if(uE(e))return e;throw new TypeError(`Unsupported value type: "${typeof e}".`)}var wE=sE.pattern.call(void 0,sE.string.call(void 0),/^(?:0x)?[0-9a-f]+$/iu),bE=sE.pattern.call(void 0,sE.string.call(void 0),/^0x[0-9a-f]+$/iu),vE=sE.pattern.call(void 0,sE.string.call(void 0),/^0x[0-9a-f]{40}$/u),_E=sE.pattern.call(void 0,sE.string.call(void 0),/^0x[0-9a-fA-F]{40}$/u);function EE(e){return sE.is.call(void 0,e,wE)}function SE(e){return sE.is.call(void 0,e,bE)}function xE(e){iE.assert.call(void 0,EE(e),"Value must be a hexadecimal string.")}function AE(e){iE.assert.call(void 0,sE.is.call(void 0,e,_E),"Invalid hex address.");const t=BE(e.toLowerCase()),r=BE(hE(oE.keccak_256.call(void 0,t)));return`0x${t.split("").map(((e,t)=>{const n=r[t];return iE.assert.call(void 0,sE.is.call(void 0,n,sE.string.call(void 0)),"Hash shorter than address."),parseInt(n,16)>7?e.toUpperCase():e})).join("")}`}function kE(e){return!!sE.is.call(void 0,e,_E)&&AE(e)===e}function IE(e){return e.startsWith("0x")?e:e.startsWith("0X")?`0x${e.substring(2)}`:`0x${e}`}function BE(e){return e.startsWith("0x")||e.startsWith("0X")?e.substring(2):e}ev.HexStruct=wE,ev.StrictHexStruct=bE,ev.HexAddressStruct=vE,ev.HexChecksumAddressStruct=_E,ev.isHexString=EE,ev.isStrictHexString=SE,ev.assertIsHexString=xE,ev.assertIsStrictHexString=function(e){iE.assert.call(void 0,SE(e),'Value must be a hexadecimal string, starting with "0x".')},ev.isValidHexAddress=function(e){return sE.is.call(void 0,e,vE)||kE(e)},ev.getChecksumAddress=AE,ev.isValidChecksumAddress=kE,ev.add0x=IE,ev.remove0x=BE,ev.isBytes=uE,ev.assertIsBytes=lE,ev.bytesToHex=hE,ev.bytesToBigInt=fE,ev.bytesToSignedBigInt=function(e){lE(e);let t=BigInt(0);for(const r of e)t=(t<0,"Byte length must be greater than 0."),iE.assert.call(void 0,function(e,t){iE.assert.call(void 0,t>0);const r=e>>BigInt(31);return!((~e&r)+(e&~r)>>BigInt(8*t-1))}(e,t),"Byte length is too small to represent the given value.");let r=e;const n=new Uint8Array(t);for(let e=0;e>=BigInt(8);return n.reverse()},ev.numberToBytes=gE,ev.stringToBytes=yE,ev.base64ToBytes=function(e){return iE.assert.call(void 0,"string"==typeof e,"Value must be a string."),aE.base64.decode(e)},ev.valueToBytes=mE,ev.concatBytes=function(e){const t=new Array(e.length);let r=0;for(let n=0;n(RE.assert.call(void 0,"number"==typeof e,"Value must be a number."),RE.assert.call(void 0,e>=0,"Value must be a non-negative number."),RE.assert.call(void 0,Number.isSafeInteger(e),"Value is not a safe integer. Use `bigIntToHex` instead."),TE.add0x.call(void 0,e.toString(16))),Qb.bigIntToHex=e=>(RE.assert.call(void 0,"bigint"==typeof e,"Value must be a bigint."),RE.assert.call(void 0,e>=0,"Value must be a non-negative bigint."),TE.add0x.call(void 0,e.toString(16))),Qb.hexToNumber=e=>{TE.assertIsHexString.call(void 0,e);const t=parseInt(e,16);return RE.assert.call(void 0,Number.isSafeInteger(t),"Value is not a safe integer. Use `hexToBigInt` instead."),t},Qb.hexToBigInt=e=>(TE.assertIsHexString.call(void 0,e),BigInt(TE.add0x.call(void 0,e)));var OE={};Object.defineProperty(OE,"__esModule",{value:!0}),OE.createDeferredPromise=function({suppressUnhandledRejection:e=!1}={}){let t,r;const n=new Promise(((e,n)=>{t=e,r=n}));return e&&n.catch((e=>{})),{promise:n,resolve:t,reject:r}};var ME={};Object.defineProperty(ME,"__esModule",{value:!0});var LE=(e=>(e[e.Millisecond=1]="Millisecond",e[e.Second=1e3]="Second",e[e.Minute=6e4]="Minute",e[e.Hour=36e5]="Hour",e[e.Day=864e5]="Day",e[e.Week=6048e5]="Week",e[e.Year=31536e6]="Year",e))(LE||{}),CE=(e,t)=>{if(!(e=>Number.isInteger(e)&&e>=0)(e))throw new Error(`"${t}" must be a non-negative integer. Received: "${e}".`)};ME.Duration=LE,ME.inMilliseconds=function(e,t){return CE(e,"count"),e*t},ME.timeSince=function(e){return CE(e,"timestamp"),Date.now()-e};var PE={},NE={exports:{}};var UE={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER||9007199254740991,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:"2.0.0",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2};var jE="object"==typeof process&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};!function(e,t){const{MAX_SAFE_COMPONENT_LENGTH:r,MAX_SAFE_BUILD_LENGTH:n,MAX_LENGTH:i}=UE,o=jE,s=(t=e.exports={}).re=[],a=t.safeRe=[],c=t.src=[],u=t.t={};let l=0;const h="[a-zA-Z0-9-]",f=[["\\s",1],["\\d",i],[h,n]],d=(e,t,r)=>{const n=(e=>{for(const[t,r]of f)e=e.split(`${t}*`).join(`${t}{0,${r}}`).split(`${t}+`).join(`${t}{1,${r}}`);return e})(t),i=l++;o(e,i,t),u[e]=i,c[i]=t,s[i]=new RegExp(t,r?"g":void 0),a[i]=new RegExp(n,r?"g":void 0)};d("NUMERICIDENTIFIER","0|[1-9]\\d*"),d("NUMERICIDENTIFIERLOOSE","\\d+"),d("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${h}*`),d("MAINVERSION",`(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})`),d("MAINVERSIONLOOSE",`(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})`),d("PRERELEASEIDENTIFIER",`(?:${c[u.NUMERICIDENTIFIER]}|${c[u.NONNUMERICIDENTIFIER]})`),d("PRERELEASEIDENTIFIERLOOSE",`(?:${c[u.NUMERICIDENTIFIERLOOSE]}|${c[u.NONNUMERICIDENTIFIER]})`),d("PRERELEASE",`(?:-(${c[u.PRERELEASEIDENTIFIER]}(?:\\.${c[u.PRERELEASEIDENTIFIER]})*))`),d("PRERELEASELOOSE",`(?:-?(${c[u.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[u.PRERELEASEIDENTIFIERLOOSE]})*))`),d("BUILDIDENTIFIER",`${h}+`),d("BUILD",`(?:\\+(${c[u.BUILDIDENTIFIER]}(?:\\.${c[u.BUILDIDENTIFIER]})*))`),d("FULLPLAIN",`v?${c[u.MAINVERSION]}${c[u.PRERELEASE]}?${c[u.BUILD]}?`),d("FULL",`^${c[u.FULLPLAIN]}$`),d("LOOSEPLAIN",`[v=\\s]*${c[u.MAINVERSIONLOOSE]}${c[u.PRERELEASELOOSE]}?${c[u.BUILD]}?`),d("LOOSE",`^${c[u.LOOSEPLAIN]}$`),d("GTLT","((?:<|>)?=?)"),d("XRANGEIDENTIFIERLOOSE",`${c[u.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),d("XRANGEIDENTIFIER",`${c[u.NUMERICIDENTIFIER]}|x|X|\\*`),d("XRANGEPLAIN",`[v=\\s]*(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:${c[u.PRERELEASE]})?${c[u.BUILD]}?)?)?`),d("XRANGEPLAINLOOSE",`[v=\\s]*(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:${c[u.PRERELEASELOOSE]})?${c[u.BUILD]}?)?)?`),d("XRANGE",`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAIN]}$`),d("XRANGELOOSE",`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAINLOOSE]}$`),d("COERCEPLAIN",`(^|[^\\d])(\\d{1,${r}})(?:\\.(\\d{1,${r}}))?(?:\\.(\\d{1,${r}}))?`),d("COERCE",`${c[u.COERCEPLAIN]}(?:$|[^\\d])`),d("COERCEFULL",c[u.COERCEPLAIN]+`(?:${c[u.PRERELEASE]})?`+`(?:${c[u.BUILD]})?(?:$|[^\\d])`),d("COERCERTL",c[u.COERCE],!0),d("COERCERTLFULL",c[u.COERCEFULL],!0),d("LONETILDE","(?:~>?)"),d("TILDETRIM",`(\\s*)${c[u.LONETILDE]}\\s+`,!0),t.tildeTrimReplace="$1~",d("TILDE",`^${c[u.LONETILDE]}${c[u.XRANGEPLAIN]}$`),d("TILDELOOSE",`^${c[u.LONETILDE]}${c[u.XRANGEPLAINLOOSE]}$`),d("LONECARET","(?:\\^)"),d("CARETTRIM",`(\\s*)${c[u.LONECARET]}\\s+`,!0),t.caretTrimReplace="$1^",d("CARET",`^${c[u.LONECARET]}${c[u.XRANGEPLAIN]}$`),d("CARETLOOSE",`^${c[u.LONECARET]}${c[u.XRANGEPLAINLOOSE]}$`),d("COMPARATORLOOSE",`^${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]})$|^$`),d("COMPARATOR",`^${c[u.GTLT]}\\s*(${c[u.FULLPLAIN]})$|^$`),d("COMPARATORTRIM",`(\\s*)${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]}|${c[u.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace="$1$2$3",d("HYPHENRANGE",`^\\s*(${c[u.XRANGEPLAIN]})\\s+-\\s+(${c[u.XRANGEPLAIN]})\\s*$`),d("HYPHENRANGELOOSE",`^\\s*(${c[u.XRANGEPLAINLOOSE]})\\s+-\\s+(${c[u.XRANGEPLAINLOOSE]})\\s*$`),d("STAR","(<|>)?=?\\s*\\*"),d("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),d("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")}(NE,NE.exports);const $E=Object.freeze({loose:!0}),zE=Object.freeze({});var DE=e=>e?"object"!=typeof e?$E:e:zE;const HE=/^[0-9]+$/,qE=(e,t)=>{const r=HE.test(e),n=HE.test(t);return r&&n&&(e=+e,t=+t),e===t?0:r&&!n?-1:n&&!r?1:eqE(t,e)};const KE=jE,{MAX_LENGTH:WE,MAX_SAFE_INTEGER:VE}=UE,{safeRe:ZE,t:GE}=NE.exports,JE=DE,{compareIdentifiers:YE}=FE;class XE{constructor(e,t){if(t=JE(t),e instanceof XE){if(e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease)return e;e=e.version}else if("string"!=typeof e)throw new TypeError(`Invalid version. Must be a string. Got type "${typeof e}".`);if(e.length>WE)throw new TypeError(`version is longer than ${WE} characters`);KE("SemVer",e,t),this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease;const r=e.trim().match(t.loose?ZE[GE.LOOSE]:ZE[GE.FULL]);if(!r)throw new TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+r[1],this.minor=+r[2],this.patch=+r[3],this.major>VE||this.major<0)throw new TypeError("Invalid major version");if(this.minor>VE||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>VE||this.patch<0)throw new TypeError("Invalid patch version");r[4]?this.prerelease=r[4].split(".").map((e=>{if(/^[0-9]+$/.test(e)){const t=+e;if(t>=0&&t=0;)"number"==typeof this.prerelease[n]&&(this.prerelease[n]++,n=-2);if(-1===n){if(t===this.prerelease.join(".")&&!1===r)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(e)}}if(t){let n=[t,e];!1===r&&(n=[t]),0===YE(this.prerelease[0],t)?isNaN(this.prerelease[1])&&(this.prerelease=n):this.prerelease=n}break}default:throw new Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}}var QE=XE;const eS=QE;var tS=(e,t,r=!1)=>{if(e instanceof eS)return e;try{return new eS(e,t)}catch(e){if(!r)return null;throw e}};const rS=tS;var nS=(e,t)=>{const r=rS(e,t);return r?r.version:null};const iS=tS;var oS=(e,t)=>{const r=iS(e.trim().replace(/^[=v]+/,""),t);return r?r.version:null};const sS=QE;var aS=(e,t,r,n,i)=>{"string"==typeof r&&(i=n,n=r,r=void 0);try{return new sS(e instanceof sS?e.version:e,r).inc(t,n,i).version}catch(e){return null}};const cS=tS;var uS=(e,t)=>{const r=cS(e,null,!0),n=cS(t,null,!0),i=r.compare(n);if(0===i)return null;const o=i>0,s=o?r:n,a=o?n:r,c=!!s.prerelease.length;if(!!a.prerelease.length&&!c)return a.patch||a.minor?s.patch?"patch":s.minor?"minor":"major":"major";const u=c?"pre":"";return r.major!==n.major?u+"major":r.minor!==n.minor?u+"minor":r.patch!==n.patch?u+"patch":"prerelease"};const lS=QE;var hS=(e,t)=>new lS(e,t).major;const fS=QE;var dS=(e,t)=>new fS(e,t).minor;const pS=QE;var gS=(e,t)=>new pS(e,t).patch;const yS=tS;var mS=(e,t)=>{const r=yS(e,t);return r&&r.prerelease.length?r.prerelease:null};const wS=QE;var bS=(e,t,r)=>new wS(e,r).compare(new wS(t,r));const vS=bS;var _S=(e,t,r)=>vS(t,e,r);const ES=bS;var SS=(e,t)=>ES(e,t,!0);const xS=QE;var AS=(e,t,r)=>{const n=new xS(e,r),i=new xS(t,r);return n.compare(i)||n.compareBuild(i)};const kS=AS;var IS=(e,t)=>e.sort(((e,r)=>kS(e,r,t)));const BS=AS;var TS=(e,t)=>e.sort(((e,r)=>BS(r,e,t)));const RS=bS;var OS=(e,t,r)=>RS(e,t,r)>0;const MS=bS;var LS=(e,t,r)=>MS(e,t,r)<0;const CS=bS;var PS=(e,t,r)=>0===CS(e,t,r);const NS=bS;var US=(e,t,r)=>0!==NS(e,t,r);const jS=bS;var $S=(e,t,r)=>jS(e,t,r)>=0;const zS=bS;var DS=(e,t,r)=>zS(e,t,r)<=0;const HS=PS,qS=US,FS=OS,KS=$S,WS=LS,VS=DS;var ZS=(e,t,r,n)=>{switch(t){case"===":return"object"==typeof e&&(e=e.version),"object"==typeof r&&(r=r.version),e===r;case"!==":return"object"==typeof e&&(e=e.version),"object"==typeof r&&(r=r.version),e!==r;case"":case"=":case"==":return HS(e,r,n);case"!=":return qS(e,r,n);case">":return FS(e,r,n);case">=":return KS(e,r,n);case"<":return WS(e,r,n);case"<=":return VS(e,r,n);default:throw new TypeError(`Invalid operator: ${t}`)}};const GS=QE,JS=tS,{safeRe:YS,t:XS}=NE.exports;var QS=(e,t)=>{if(e instanceof GS)return e;if("number"==typeof e&&(e=String(e)),"string"!=typeof e)return null;let r=null;if((t=t||{}).rtl){const n=t.includePrerelease?YS[XS.COERCERTLFULL]:YS[XS.COERCERTL];let i;for(;(i=n.exec(e))&&(!r||r.index+r[0].length!==e.length);)r&&i.index+i[0].length===r.index+r[0].length||(r=i),n.lastIndex=i.index+i[1].length+i[2].length;n.lastIndex=-1}else r=e.match(t.includePrerelease?YS[XS.COERCEFULL]:YS[XS.COERCE]);if(null===r)return null;const n=r[2],i=r[3]||"0",o=r[4]||"0",s=t.includePrerelease&&r[5]?`-${r[5]}`:"",a=t.includePrerelease&&r[6]?`+${r[6]}`:"";return JS(`${n}.${i}.${o}${s}${a}`,t)};var ex,tx,rx,nx,ix=class{constructor(){this.max=1e3,this.map=new Map}get(e){const t=this.map.get(e);return void 0===t?void 0:(this.map.delete(e),this.map.set(e,t),t)}delete(e){return this.map.delete(e)}set(e,t){if(!this.delete(e)&&void 0!==t){if(this.map.size>=this.max){const e=this.map.keys().next().value;this.delete(e)}this.map.set(e,t)}return this}};function ox(){if(tx)return ex;tx=1;class e{constructor(t,i){if(i=r(i),t instanceof e)return t.loose===!!i.loose&&t.includePrerelease===!!i.includePrerelease?t:new e(t.raw,i);if(t instanceof n)return this.raw=t.value,this.set=[[t]],this.format(),this;if(this.options=i,this.loose=!!i.loose,this.includePrerelease=!!i.includePrerelease,this.raw=t.trim().split(/\s+/).join(" "),this.set=this.raw.split("||").map((e=>this.parseRange(e.trim()))).filter((e=>e.length)),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const e=this.set[0];if(this.set=this.set.filter((e=>!d(e[0]))),0===this.set.length)this.set=[e];else if(this.set.length>1)for(const e of this.set)if(1===e.length&&p(e[0])){this.set=[e];break}}this.format()}format(){return this.range=this.set.map((e=>e.join(" ").trim())).join("||").trim(),this.range}toString(){return this.range}parseRange(e){const r=((this.options.includePrerelease&&h)|(this.options.loose&&f))+":"+e,o=t.get(r);if(o)return o;const p=this.options.loose,g=p?s[a.HYPHENRANGELOOSE]:s[a.HYPHENRANGE];e=e.replace(g,k(this.options.includePrerelease)),i("hyphen replace",e),e=e.replace(s[a.COMPARATORTRIM],c),i("comparator trim",e),e=e.replace(s[a.TILDETRIM],u),i("tilde trim",e),e=e.replace(s[a.CARETTRIM],l),i("caret trim",e);let m=e.split(" ").map((e=>y(e,this.options))).join(" ").split(/\s+/).map((e=>A(e,this.options)));p&&(m=m.filter((e=>(i("loose invalid filter",e,this.options),!!e.match(s[a.COMPARATORLOOSE]))))),i("range list",m);const w=new Map,b=m.map((e=>new n(e,this.options)));for(const e of b){if(d(e))return[e];w.set(e.value,e)}w.size>1&&w.has("")&&w.delete("");const v=[...w.values()];return t.set(r,v),v}intersects(t,r){if(!(t instanceof e))throw new TypeError("a Range is required");return this.set.some((e=>g(e,r)&&t.set.some((t=>g(t,r)&&e.every((e=>t.every((t=>e.intersects(t,r)))))))))}test(e){if(!e)return!1;if("string"==typeof e)try{e=new o(e,this.options)}catch(e){return!1}for(let t=0;t"<0.0.0-0"===e.value,p=e=>""===e.value,g=(e,t)=>{let r=!0;const n=e.slice();let i=n.pop();for(;r&&n.length;)r=n.every((e=>i.intersects(e,t))),i=n.pop();return r},y=(e,t)=>(i("comp",e,t),e=v(e,t),i("caret",e),e=w(e,t),i("tildes",e),e=E(e,t),i("xrange",e),e=x(e,t),i("stars",e),e),m=e=>!e||"x"===e.toLowerCase()||"*"===e,w=(e,t)=>e.trim().split(/\s+/).map((e=>b(e,t))).join(" "),b=(e,t)=>{const r=t.loose?s[a.TILDELOOSE]:s[a.TILDE];return e.replace(r,((t,r,n,o,s)=>{let a;return i("tilde",e,t,r,n,o,s),m(r)?a="":m(n)?a=`>=${r}.0.0 <${+r+1}.0.0-0`:m(o)?a=`>=${r}.${n}.0 <${r}.${+n+1}.0-0`:s?(i("replaceTilde pr",s),a=`>=${r}.${n}.${o}-${s} <${r}.${+n+1}.0-0`):a=`>=${r}.${n}.${o} <${r}.${+n+1}.0-0`,i("tilde return",a),a}))},v=(e,t)=>e.trim().split(/\s+/).map((e=>_(e,t))).join(" "),_=(e,t)=>{i("caret",e,t);const r=t.loose?s[a.CARETLOOSE]:s[a.CARET],n=t.includePrerelease?"-0":"";return e.replace(r,((t,r,o,s,a)=>{let c;return i("caret",e,t,r,o,s,a),m(r)?c="":m(o)?c=`>=${r}.0.0${n} <${+r+1}.0.0-0`:m(s)?c="0"===r?`>=${r}.${o}.0${n} <${r}.${+o+1}.0-0`:`>=${r}.${o}.0${n} <${+r+1}.0.0-0`:a?(i("replaceCaret pr",a),c="0"===r?"0"===o?`>=${r}.${o}.${s}-${a} <${r}.${o}.${+s+1}-0`:`>=${r}.${o}.${s}-${a} <${r}.${+o+1}.0-0`:`>=${r}.${o}.${s}-${a} <${+r+1}.0.0-0`):(i("no pr"),c="0"===r?"0"===o?`>=${r}.${o}.${s}${n} <${r}.${o}.${+s+1}-0`:`>=${r}.${o}.${s}${n} <${r}.${+o+1}.0-0`:`>=${r}.${o}.${s} <${+r+1}.0.0-0`),i("caret return",c),c}))},E=(e,t)=>(i("replaceXRanges",e,t),e.split(/\s+/).map((e=>S(e,t))).join(" ")),S=(e,t)=>{e=e.trim();const r=t.loose?s[a.XRANGELOOSE]:s[a.XRANGE];return e.replace(r,((r,n,o,s,a,c)=>{i("xRange",e,r,n,o,s,a,c);const u=m(o),l=u||m(s),h=l||m(a),f=h;return"="===n&&f&&(n=""),c=t.includePrerelease?"-0":"",u?r=">"===n||"<"===n?"<0.0.0-0":"*":n&&f?(l&&(s=0),a=0,">"===n?(n=">=",l?(o=+o+1,s=0,a=0):(s=+s+1,a=0)):"<="===n&&(n="<",l?o=+o+1:s=+s+1),"<"===n&&(c="-0"),r=`${n+o}.${s}.${a}${c}`):l?r=`>=${o}.0.0${c} <${+o+1}.0.0-0`:h&&(r=`>=${o}.${s}.0${c} <${o}.${+s+1}.0-0`),i("xRange return",r),r}))},x=(e,t)=>(i("replaceStars",e,t),e.trim().replace(s[a.STAR],"")),A=(e,t)=>(i("replaceGTE0",e,t),e.trim().replace(s[t.includePrerelease?a.GTE0PRE:a.GTE0],"")),k=e=>(t,r,n,i,o,s,a,c,u,l,h,f)=>`${r=m(n)?"":m(i)?`>=${n}.0.0${e?"-0":""}`:m(o)?`>=${n}.${i}.0${e?"-0":""}`:s?`>=${r}`:`>=${r}${e?"-0":""}`} ${c=m(u)?"":m(l)?`<${+u+1}.0.0-0`:m(h)?`<${u}.${+l+1}.0-0`:f?`<=${u}.${l}.${h}-${f}`:e?`<${u}.${l}.${+h+1}-0`:`<=${c}`}`.trim(),I=(e,t,r)=>{for(let r=0;r0){const n=e[r].semver;if(n.major===t.major&&n.minor===t.minor&&n.patch===t.patch)return!0}return!1}return!0};return ex}function sx(){if(nx)return rx;nx=1;const e=Symbol("SemVer ANY");class t{static get ANY(){return e}constructor(n,i){if(i=r(i),n instanceof t){if(n.loose===!!i.loose)return n;n=n.value}n=n.trim().split(/\s+/).join(" "),s("comparator",n,i),this.options=i,this.loose=!!i.loose,this.parse(n),this.semver===e?this.value="":this.value=this.operator+this.semver.version,s("comp",this)}parse(t){const r=this.options.loose?n[i.COMPARATORLOOSE]:n[i.COMPARATOR],o=t.match(r);if(!o)throw new TypeError(`Invalid comparator: ${t}`);this.operator=void 0!==o[1]?o[1]:"","="===this.operator&&(this.operator=""),o[2]?this.semver=new a(o[2],this.options.loose):this.semver=e}toString(){return this.value}test(t){if(s("Comparator.test",t,this.options.loose),this.semver===e||t===e)return!0;if("string"==typeof t)try{t=new a(t,this.options)}catch(e){return!1}return o(t,this.operator,this.semver,this.options)}intersects(e,n){if(!(e instanceof t))throw new TypeError("a Comparator is required");return""===this.operator?""===this.value||new c(e.value,n).test(this.value):""===e.operator?""===e.value||new c(this.value,n).test(e.semver):(!(n=r(n)).includePrerelease||"<0.0.0-0"!==this.value&&"<0.0.0-0"!==e.value)&&(!(!n.includePrerelease&&(this.value.startsWith("<0.0.0")||e.value.startsWith("<0.0.0")))&&(!(!this.operator.startsWith(">")||!e.operator.startsWith(">"))||(!(!this.operator.startsWith("<")||!e.operator.startsWith("<"))||(!(this.semver.version!==e.semver.version||!this.operator.includes("=")||!e.operator.includes("="))||(!!(o(this.semver,"<",e.semver,n)&&this.operator.startsWith(">")&&e.operator.startsWith("<"))||!!(o(this.semver,">",e.semver,n)&&this.operator.startsWith("<")&&e.operator.startsWith(">")))))))}}rx=t;const r=DE,{safeRe:n,t:i}=NE.exports,o=ZS,s=jE,a=QE,c=ox();return rx}const ax=ox();var cx=(e,t,r)=>{try{t=new ax(t,r)}catch(e){return!1}return t.test(e)};const ux=ox();var lx=(e,t)=>new ux(e,t).set.map((e=>e.map((e=>e.value)).join(" ").trim().split(" ")));const hx=QE,fx=ox();var dx=(e,t,r)=>{let n=null,i=null,o=null;try{o=new fx(t,r)}catch(e){return null}return e.forEach((e=>{o.test(e)&&(n&&-1!==i.compare(e)||(n=e,i=new hx(n,r)))})),n};const px=QE,gx=ox();var yx=(e,t,r)=>{let n=null,i=null,o=null;try{o=new gx(t,r)}catch(e){return null}return e.forEach((e=>{o.test(e)&&(n&&1!==i.compare(e)||(n=e,i=new px(n,r)))})),n};const mx=QE,wx=ox(),bx=OS;var vx=(e,t)=>{e=new wx(e,t);let r=new mx("0.0.0");if(e.test(r))return r;if(r=new mx("0.0.0-0"),e.test(r))return r;r=null;for(let t=0;t{const t=new mx(e.semver.version);switch(e.operator){case">":0===t.prerelease.length?t.patch++:t.prerelease.push(0),t.raw=t.format();case"":case">=":i&&!bx(t,i)||(i=t);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${e.operator}`)}})),!i||r&&!bx(r,i)||(r=i)}return r&&e.test(r)?r:null};const _x=ox();var Ex=(e,t)=>{try{return new _x(e,t).range||"*"}catch(e){return null}};const Sx=QE,xx=sx(),{ANY:Ax}=xx,kx=ox(),Ix=cx,Bx=OS,Tx=LS,Rx=DS,Ox=$S;var Mx=(e,t,r,n)=>{let i,o,s,a,c;switch(e=new Sx(e,n),t=new kx(t,n),r){case">":i=Bx,o=Rx,s=Tx,a=">",c=">=";break;case"<":i=Tx,o=Ox,s=Bx,a="<",c="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(Ix(e,t,n))return!1;for(let r=0;r{e.semver===Ax&&(e=new xx(">=0.0.0")),l=l||e,h=h||e,i(e.semver,l.semver,n)?l=e:s(e.semver,h.semver,n)&&(h=e)})),l.operator===a||l.operator===c)return!1;if((!h.operator||h.operator===a)&&o(e,h.semver))return!1;if(h.operator===c&&s(e,h.semver))return!1}return!0};const Lx=Mx;var Cx=(e,t,r)=>Lx(e,t,">",r);const Px=Mx;var Nx=(e,t,r)=>Px(e,t,"<",r);const Ux=ox();var jx=(e,t,r)=>(e=new Ux(e,r),t=new Ux(t,r),e.intersects(t,r));const $x=cx,zx=bS;const Dx=ox(),Hx=sx(),{ANY:qx}=Hx,Fx=cx,Kx=bS,Wx=[new Hx(">=0.0.0-0")],Vx=[new Hx(">=0.0.0")],Zx=(e,t,r)=>{if(e===t)return!0;if(1===e.length&&e[0].semver===qx){if(1===t.length&&t[0].semver===qx)return!0;e=r.includePrerelease?Wx:Vx}if(1===t.length&&t[0].semver===qx){if(r.includePrerelease)return!0;t=Vx}const n=new Set;let i,o,s,a,c,u,l;for(const t of e)">"===t.operator||">="===t.operator?i=Gx(i,t,r):"<"===t.operator||"<="===t.operator?o=Jx(o,t,r):n.add(t.semver);if(n.size>1)return null;if(i&&o){if(s=Kx(i.semver,o.semver,r),s>0)return null;if(0===s&&(">="!==i.operator||"<="!==o.operator))return null}for(const e of n){if(i&&!Fx(e,String(i),r))return null;if(o&&!Fx(e,String(o),r))return null;for(const n of t)if(!Fx(e,String(n),r))return!1;return!0}let h=!(!o||r.includePrerelease||!o.semver.prerelease.length)&&o.semver,f=!(!i||r.includePrerelease||!i.semver.prerelease.length)&&i.semver;h&&1===h.prerelease.length&&"<"===o.operator&&0===h.prerelease[0]&&(h=!1);for(const e of t){if(l=l||">"===e.operator||">="===e.operator,u=u||"<"===e.operator||"<="===e.operator,i)if(f&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===f.major&&e.semver.minor===f.minor&&e.semver.patch===f.patch&&(f=!1),">"===e.operator||">="===e.operator){if(a=Gx(i,e,r),a===e&&a!==i)return!1}else if(">="===i.operator&&!Fx(i.semver,String(e),r))return!1;if(o)if(h&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===h.major&&e.semver.minor===h.minor&&e.semver.patch===h.patch&&(h=!1),"<"===e.operator||"<="===e.operator){if(c=Jx(o,e,r),c===e&&c!==o)return!1}else if("<="===o.operator&&!Fx(o.semver,String(e),r))return!1;if(!e.operator&&(o||i)&&0!==s)return!1}return!(i&&u&&!o&&0!==s)&&(!(o&&l&&!i&&0!==s)&&(!f&&!h))},Gx=(e,t,r)=>{if(!e)return t;const n=Kx(e.semver,t.semver,r);return n>0?e:n<0||">"===t.operator&&">="===e.operator?t:e},Jx=(e,t,r)=>{if(!e)return t;const n=Kx(e.semver,t.semver,r);return n<0?e:n>0||"<"===t.operator&&"<="===e.operator?t:e};var Yx=(e,t,r={})=>{if(e===t)return!0;e=new Dx(e,r),t=new Dx(t,r);let n=!1;e:for(const i of e.set){for(const e of t.set){const t=Zx(i,e,r);if(n=n||null!==t,t)continue e}if(n)return!1}return!0};const Xx=NE.exports,Qx=UE,eA=QE,tA=FE,rA=(e,t,r)=>{const n=[];let i=null,o=null;const s=e.sort(((e,t)=>zx(e,t,r)));for(const e of s){$x(e,t,r)?(o=e,i||(i=e)):(o&&n.push([i,o]),o=null,i=null)}i&&n.push([i,null]);const a=[];for(const[e,t]of n)e===t?a.push(e):t||e!==s[0]?t?e===s[0]?a.push(`<=${t}`):a.push(`${e} - ${t}`):a.push(`>=${e}`):a.push("*");const c=a.join(" || "),u="string"==typeof t.raw?t.raw:String(t);return c.lengthnull!==oA.valid.call(void 0,e)||`Expected SemVer version, got "${e}"`)),cA=sA.refine.call(void 0,sA.string.call(void 0),"Version range",(e=>null!==oA.validRange.call(void 0,e)||`Expected SemVer range, got "${e}"`));PE.VersionStruct=aA,PE.VersionRangeStruct=cA,PE.isValidSemVerVersion=function(e){return sA.is.call(void 0,e,aA)},PE.isValidSemVerRange=function(e){return sA.is.call(void 0,e,cA)},PE.assertIsSemVerVersion=function(e){iA.assertStruct.call(void 0,e,aA)},PE.assertIsSemVerRange=function(e){iA.assertStruct.call(void 0,e,cA)},PE.gtVersion=function(e,t){return oA.gt.call(void 0,e,t)},PE.gtRange=function(e,t){return oA.gtr.call(void 0,e,t)},PE.satisfiesVersionRange=function(e,t){return oA.satisfies.call(void 0,e,t,{includePrerelease:!0})};var uA={};Object.defineProperty(uA,"__esModule",{value:!0});var lA=tv,hA=nv,fA=Zv,dA=e=>fA.object.call(void 0,e);function pA({path:e,branch:t}){const r=e[e.length-1];return hA.hasProperty.call(void 0,t[t.length-2],r)}function gA(e){return new fA.Struct({...e,type:`optional ${e.type}`,validator:(t,r)=>!pA(r)||e.validator(t,r),refiner:(t,r)=>!pA(r)||e.refiner(t,r)})}var yA=fA.union.call(void 0,[fA.literal.call(void 0,null),fA.boolean.call(void 0),fA.define.call(void 0,"finite number",(e=>fA.is.call(void 0,e,fA.number.call(void 0))&&Number.isFinite(e))),fA.string.call(void 0),fA.array.call(void 0,fA.lazy.call(void 0,(()=>yA))),fA.record.call(void 0,fA.string.call(void 0),fA.lazy.call(void 0,(()=>yA)))]),mA=fA.coerce.call(void 0,yA,fA.any.call(void 0),(e=>(lA.assertStruct.call(void 0,e,yA),JSON.parse(JSON.stringify(e,((e,t)=>{if("__proto__"!==e&&"constructor"!==e)return t}))))));function wA(e){return fA.create.call(void 0,e,mA)}var bA=fA.literal.call(void 0,"2.0"),vA=fA.nullable.call(void 0,fA.union.call(void 0,[fA.number.call(void 0),fA.string.call(void 0)])),_A=dA({code:fA.integer.call(void 0),message:fA.string.call(void 0),data:gA(mA),stack:gA(fA.string.call(void 0))}),EA=fA.union.call(void 0,[fA.record.call(void 0,fA.string.call(void 0),mA),fA.array.call(void 0,mA)]),SA=dA({id:vA,jsonrpc:bA,method:fA.string.call(void 0),params:gA(EA)}),xA=dA({jsonrpc:bA,method:fA.string.call(void 0),params:gA(EA)});var AA=fA.object.call(void 0,{id:vA,jsonrpc:bA,result:fA.optional.call(void 0,fA.unknown.call(void 0)),error:fA.optional.call(void 0,_A)}),kA=dA({id:vA,jsonrpc:bA,result:mA}),IA=dA({id:vA,jsonrpc:bA,error:_A}),BA=fA.union.call(void 0,[kA,IA]);uA.object=dA,uA.exactOptional=gA,uA.UnsafeJsonStruct=yA,uA.JsonStruct=mA,uA.isValidJson=function(e){try{return wA(e),!0}catch(e){return!1}},uA.getSafeJson=wA,uA.getJsonSize=function(e){lA.assertStruct.call(void 0,e,mA,"Invalid JSON value");const t=JSON.stringify(e);return(new TextEncoder).encode(t).byteLength},uA.jsonrpc2="2.0",uA.JsonRpcVersionStruct=bA,uA.JsonRpcIdStruct=vA,uA.JsonRpcErrorStruct=_A,uA.JsonRpcParamsStruct=EA,uA.JsonRpcRequestStruct=SA,uA.JsonRpcNotificationStruct=xA,uA.isJsonRpcNotification=function(e){return fA.is.call(void 0,e,xA)},uA.assertIsJsonRpcNotification=function(e,t){lA.assertStruct.call(void 0,e,xA,"Invalid JSON-RPC notification",t)},uA.isJsonRpcRequest=function(e){return fA.is.call(void 0,e,SA)},uA.assertIsJsonRpcRequest=function(e,t){lA.assertStruct.call(void 0,e,SA,"Invalid JSON-RPC request",t)},uA.PendingJsonRpcResponseStruct=AA,uA.JsonRpcSuccessStruct=kA,uA.JsonRpcFailureStruct=IA,uA.JsonRpcResponseStruct=BA,uA.isPendingJsonRpcResponse=function(e){return fA.is.call(void 0,e,AA)},uA.assertIsPendingJsonRpcResponse=function(e,t){lA.assertStruct.call(void 0,e,AA,"Invalid pending JSON-RPC response",t)},uA.isJsonRpcResponse=function(e){return fA.is.call(void 0,e,BA)},uA.assertIsJsonRpcResponse=function(e,t){lA.assertStruct.call(void 0,e,BA,"Invalid JSON-RPC response",t)},uA.isJsonRpcSuccess=function(e){return fA.is.call(void 0,e,kA)},uA.assertIsJsonRpcSuccess=function(e,t){lA.assertStruct.call(void 0,e,kA,"Invalid JSON-RPC success response",t)},uA.isJsonRpcFailure=function(e){return fA.is.call(void 0,e,IA)},uA.assertIsJsonRpcFailure=function(e,t){lA.assertStruct.call(void 0,e,IA,"Invalid JSON-RPC failure response",t)},uA.isJsonRpcError=function(e){return fA.is.call(void 0,e,_A)},uA.assertIsJsonRpcError=function(e,t){lA.assertStruct.call(void 0,e,_A,"Invalid JSON-RPC error",t)},uA.getJsonRpcIdValidator=function(e){const{permitEmptyString:t,permitFractions:r,permitNull:n}={permitEmptyString:!0,permitFractions:!1,permitNull:!0,...e};return e=>Boolean("number"==typeof e&&(r||Number.isInteger(e))||"string"==typeof e&&(t||e.length>0)||n&&null===e)};var TA,RA,OA={},MA={exports:{}};function LA(){if(RA)return TA;RA=1;var e=1e3,t=60*e,r=60*t,n=24*r,i=7*n,o=365.25*n;function s(e,t,r,n){var i=t>=1.5*r;return Math.round(e/r)+" "+n+(i?"s":"")}return TA=function(a,c){c=c||{};var u=typeof a;if("string"===u&&a.length>0)return function(s){if((s=String(s)).length>100)return;var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(s);if(!a)return;var c=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*o;case"weeks":case"week":case"w":return c*i;case"days":case"day":case"d":return c*n;case"hours":case"hour":case"hrs":case"hr":case"h":return c*r;case"minutes":case"minute":case"mins":case"min":case"m":return c*t;case"seconds":case"second":case"secs":case"sec":case"s":return c*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(a);if("number"===u&&isFinite(a))return c.long?function(i){var o=Math.abs(i);if(o>=n)return s(i,o,n,"day");if(o>=r)return s(i,o,r,"hour");if(o>=t)return s(i,o,t,"minute");if(o>=e)return s(i,o,e,"second");return i+" ms"}(a):function(i){var o=Math.abs(i);if(o>=n)return Math.round(i/n)+"d";if(o>=r)return Math.round(i/r)+"h";if(o>=t)return Math.round(i/t)+"m";if(o>=e)return Math.round(i/e)+"s";return i+"ms"}(a);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(a))},TA}var CA=function(e){function t(e){let n,i,o,s=null;function a(...e){if(!a.enabled)return;const r=a,i=Number(new Date),o=i-(n||i);r.diff=o,r.prev=n,r.curr=i,n=i,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,i)=>{if("%%"===n)return"%";s++;const o=t.formatters[i];if("function"==typeof o){const t=e[s];n=o.call(r,t),e.splice(s,1),s--}return n})),t.formatArgs.call(r,e);(r.log||t.log).apply(r,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=r,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(i!==t.namespaces&&(i=t.namespaces,o=t.enabled(e)),o),set:e=>{s=e}}),"function"==typeof t.init&&t.init(a),a}function r(e,r){const n=t(this.namespace+(void 0===r?":":r)+e);return n.log=this.log,n}function n(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(n),...t.skips.map(n).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let r;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").split(/[\s,]+/),i=n.length;for(r=0;r{t[r]=e[r]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t{"%%"!==e&&(n++,"%c"===e&&(i=n))})),t.splice(i,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=CA(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(MA,MA.exports),Object.defineProperty(OA,"__esModule",{value:!0});var PA,NA=((PA=MA.exports)&&PA.__esModule?PA:{default:PA}).default.call(void 0,"metamask");OA.createProjectLogger=function(e){return NA.extend(e)},OA.createModuleLogger=function(e,t){return e.extend(t)};var UA={};function jA(e){let t,r=e[0],n=1;for(;nr.call(t,...e))),t=void 0)}return r}Object.defineProperty(UA,"__esModule",{value:!0});var $A=Zv,zA=/^(?[-a-z0-9]{3,8}):(?[-_a-zA-Z0-9]{1,32})$/u,DA=/^[-a-z0-9]{3,8}$/u,HA=/^[-_a-zA-Z0-9]{1,32}$/u,qA=/^(?(?[-a-z0-9]{3,8}):(?[-_a-zA-Z0-9]{1,32})):(?[-.%a-zA-Z0-9]{1,128})$/u,FA=/^[-.%a-zA-Z0-9]{1,128}$/u,KA=$A.pattern.call(void 0,$A.string.call(void 0),zA),WA=$A.pattern.call(void 0,$A.string.call(void 0),DA),VA=$A.pattern.call(void 0,$A.string.call(void 0),HA),ZA=$A.pattern.call(void 0,$A.string.call(void 0),qA),GA=$A.pattern.call(void 0,$A.string.call(void 0),FA),JA=(e=>(e.Eip155="eip155",e))(JA||{});function YA(e){return $A.is.call(void 0,e,WA)}function XA(e){return $A.is.call(void 0,e,VA)}UA.CAIP_CHAIN_ID_REGEX=zA,UA.CAIP_NAMESPACE_REGEX=DA,UA.CAIP_REFERENCE_REGEX=HA,UA.CAIP_ACCOUNT_ID_REGEX=qA,UA.CAIP_ACCOUNT_ADDRESS_REGEX=FA,UA.CaipChainIdStruct=KA,UA.CaipNamespaceStruct=WA,UA.CaipReferenceStruct=VA,UA.CaipAccountIdStruct=ZA,UA.CaipAccountAddressStruct=GA,UA.KnownCaipNamespace=JA,UA.isCaipChainId=function(e){return $A.is.call(void 0,e,KA)},UA.isCaipNamespace=YA,UA.isCaipReference=XA,UA.isCaipAccountId=function(e){return $A.is.call(void 0,e,ZA)},UA.isCaipAccountAddress=function(e){return $A.is.call(void 0,e,GA)},UA.parseCaipChainId=function(e){const t=zA.exec(e);if(!jA([t,"optionalAccess",e=>e.groups]))throw new Error("Invalid CAIP chain ID.");return{namespace:t.groups.namespace,reference:t.groups.reference}},UA.parseCaipAccountId=function(e){const t=qA.exec(e);if(!jA([t,"optionalAccess",e=>e.groups]))throw new Error("Invalid CAIP account ID.");return{address:t.groups.accountAddress,chainId:t.groups.chainId,chain:{namespace:t.groups.namespace,reference:t.groups.reference}}},UA.toCaipChainId=function(e,t){if(!YA(e))throw new Error(`Invalid "namespace", must match: ${DA.toString()}`);if(!XA(t))throw new Error(`Invalid "reference", must match: ${HA.toString()}`);return`${e}:${t}`};var QA={},ek={};function tk(e,t){return null!=e?e:t()}Object.defineProperty(ek,"__esModule",{value:!0});var rk=tv,nk=Zv;ek.base64=(e,t={})=>{const r=tk(t.paddingRequired,(()=>!1)),n=tk(t.characterSet,(()=>"base64"));let i,o;return"base64"===n?i=String.raw`[A-Za-z0-9+\/]`:(rk.assert.call(void 0,"base64url"===n),i=String.raw`[-_A-Za-z0-9]`),o=r?new RegExp(`^(?:${i}{4})*(?:${i}{3}=|${i}{2}==)?$`,"u"):new RegExp(`^(?:${i}{4})*(?:${i}{2,3}|${i}{3}=|${i}{2}==)?$`,"u"),nk.pattern.call(void 0,e,o)},Object.defineProperty(QA,"__esModule",{value:!0});var ik=ek,ok=Zv,sk=ok.size.call(void 0,ik.base64.call(void 0,ok.string.call(void 0),{paddingRequired:!0}),44,44);QA.ChecksumStruct=sk;var ak={};Object.defineProperty(ak,"__esModule",{value:!0});var ck=ev,uk=tv,lk=Zv,hk=lk.union.call(void 0,[lk.number.call(void 0),lk.bigint.call(void 0),lk.string.call(void 0),ck.StrictHexStruct]),fk=lk.coerce.call(void 0,lk.number.call(void 0),hk,Number),dk=lk.coerce.call(void 0,lk.bigint.call(void 0),hk,BigInt);lk.union.call(void 0,[ck.StrictHexStruct,lk.instance.call(void 0,Uint8Array)]);var pk=lk.coerce.call(void 0,lk.instance.call(void 0,Uint8Array),lk.union.call(void 0,[ck.StrictHexStruct]),ck.hexToBytes),gk=lk.coerce.call(void 0,ck.StrictHexStruct,lk.instance.call(void 0,Uint8Array),ck.bytesToHex);ak.createNumber=function(e){try{const t=lk.create.call(void 0,e,fk);return uk.assert.call(void 0,Number.isFinite(t),`Expected a number-like value, got "${e}".`),t}catch(t){if(t instanceof lk.StructError)throw new Error(`Expected a number-like value, got "${e}".`);throw t}},ak.createBigInt=function(e){try{return lk.create.call(void 0,e,dk)}catch(e){if(e instanceof lk.StructError)throw new Error(`Expected a number-like value, got "${String(e.value)}".`);throw e}},ak.createBytes=function(e){if("string"==typeof e&&"0x"===e.toLowerCase())return new Uint8Array;try{return lk.create.call(void 0,e,pk)}catch(e){if(e instanceof lk.StructError)throw new Error(`Expected a bytes-like value, got "${String(e.value)}".`);throw e}},ak.createHex=function(e){if(e instanceof Uint8Array&&0===e.length||"string"==typeof e&&"0x"===e.toLowerCase())return"0x";try{return lk.create.call(void 0,e,gk)}catch(e){if(e instanceof lk.StructError)throw new Error(`Expected a bytes-like value, got "${String(e.value)}".`);throw e}};var yk={},mk={};Object.defineProperty(mk,"__esModule",{value:!0});var wk=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};mk.__privateGet=(e,t,r)=>(wk(e,t,"read from private field"),r?r.call(e):t.get(e)),mk.__privateAdd=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},mk.__privateSet=(e,t,r,n)=>(wk(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r),Object.defineProperty(yk,"__esModule",{value:!0});var bk,vk,_k=mk,Ek=class{constructor(e){_k.__privateAdd.call(void 0,this,bk,void 0),_k.__privateSet.call(void 0,this,bk,new Map(e)),Object.freeze(this)}get size(){return _k.__privateGet.call(void 0,this,bk).size}[Symbol.iterator](){return _k.__privateGet.call(void 0,this,bk)[Symbol.iterator]()}entries(){return _k.__privateGet.call(void 0,this,bk).entries()}forEach(e,t){return _k.__privateGet.call(void 0,this,bk).forEach(((r,n,i)=>e.call(t,r,n,this)))}get(e){return _k.__privateGet.call(void 0,this,bk).get(e)}has(e){return _k.__privateGet.call(void 0,this,bk).has(e)}keys(){return _k.__privateGet.call(void 0,this,bk).keys()}values(){return _k.__privateGet.call(void 0,this,bk).values()}toString(){return`FrozenMap(${this.size}) {${this.size>0?` ${[...this.entries()].map((([e,t])=>`${String(e)} => ${String(t)}`)).join(", ")} `:""}}`}};bk=new WeakMap;var Sk=class{constructor(e){_k.__privateAdd.call(void 0,this,vk,void 0),_k.__privateSet.call(void 0,this,vk,new Set(e)),Object.freeze(this)}get size(){return _k.__privateGet.call(void 0,this,vk).size}[Symbol.iterator](){return _k.__privateGet.call(void 0,this,vk)[Symbol.iterator]()}entries(){return _k.__privateGet.call(void 0,this,vk).entries()}forEach(e,t){return _k.__privateGet.call(void 0,this,vk).forEach(((r,n,i)=>e.call(t,r,n,this)))}has(e){return _k.__privateGet.call(void 0,this,vk).has(e)}keys(){return _k.__privateGet.call(void 0,this,vk).keys()}values(){return _k.__privateGet.call(void 0,this,vk).values()}toString(){return`FrozenSet(${this.size}) {${this.size>0?` ${[...this.values()].map((e=>String(e))).join(", ")} `:""}}`}};vk=new WeakMap,Object.freeze(Ek),Object.freeze(Ek.prototype),Object.freeze(Sk),Object.freeze(Sk.prototype),yk.FrozenMap=Ek,yk.FrozenSet=Sk,Object.defineProperty(Xb,"__esModule",{value:!0});var xk=Qb,Ak=OE,kk=ME,Ik=PE,Bk=uA,Tk=OA,Rk=UA,Ok=QA,Mk=ek,Lk=ak,Ck=ev,Pk=tv,Nk=rv,Uk=nv,jk=yk;Xb.AssertionError=Pk.AssertionError,Xb.CAIP_ACCOUNT_ADDRESS_REGEX=Rk.CAIP_ACCOUNT_ADDRESS_REGEX,Xb.CAIP_ACCOUNT_ID_REGEX=Rk.CAIP_ACCOUNT_ID_REGEX,Xb.CAIP_CHAIN_ID_REGEX=Rk.CAIP_CHAIN_ID_REGEX,Xb.CAIP_NAMESPACE_REGEX=Rk.CAIP_NAMESPACE_REGEX,Xb.CAIP_REFERENCE_REGEX=Rk.CAIP_REFERENCE_REGEX,Xb.CaipAccountAddressStruct=Rk.CaipAccountAddressStruct,Xb.CaipAccountIdStruct=Rk.CaipAccountIdStruct,Xb.CaipChainIdStruct=Rk.CaipChainIdStruct,Xb.CaipNamespaceStruct=Rk.CaipNamespaceStruct,Xb.CaipReferenceStruct=Rk.CaipReferenceStruct,Xb.ChecksumStruct=Ok.ChecksumStruct,Xb.Duration=kk.Duration,Xb.ESCAPE_CHARACTERS_REGEXP=Uk.ESCAPE_CHARACTERS_REGEXP,Xb.FrozenMap=jk.FrozenMap,Xb.FrozenSet=jk.FrozenSet,Xb.HexAddressStruct=Ck.HexAddressStruct,Xb.HexChecksumAddressStruct=Ck.HexChecksumAddressStruct,Xb.HexStruct=Ck.HexStruct,Xb.JsonRpcErrorStruct=Bk.JsonRpcErrorStruct,Xb.JsonRpcFailureStruct=Bk.JsonRpcFailureStruct,Xb.JsonRpcIdStruct=Bk.JsonRpcIdStruct,Xb.JsonRpcNotificationStruct=Bk.JsonRpcNotificationStruct,Xb.JsonRpcParamsStruct=Bk.JsonRpcParamsStruct,Xb.JsonRpcRequestStruct=Bk.JsonRpcRequestStruct,Xb.JsonRpcResponseStruct=Bk.JsonRpcResponseStruct,Xb.JsonRpcSuccessStruct=Bk.JsonRpcSuccessStruct,Xb.JsonRpcVersionStruct=Bk.JsonRpcVersionStruct,Xb.JsonSize=Uk.JsonSize,Xb.JsonStruct=Bk.JsonStruct,Xb.KnownCaipNamespace=Rk.KnownCaipNamespace,Xb.PendingJsonRpcResponseStruct=Bk.PendingJsonRpcResponseStruct,Xb.StrictHexStruct=Ck.StrictHexStruct,Xb.UnsafeJsonStruct=Bk.UnsafeJsonStruct,Xb.VersionRangeStruct=Ik.VersionRangeStruct,Xb.VersionStruct=Ik.VersionStruct,Xb.add0x=Ck.add0x,Xb.assert=Pk.assert,Xb.assertExhaustive=Pk.assertExhaustive,Xb.assertIsBytes=Ck.assertIsBytes,Xb.assertIsHexString=Ck.assertIsHexString,Xb.assertIsJsonRpcError=Bk.assertIsJsonRpcError,Xb.assertIsJsonRpcFailure=Bk.assertIsJsonRpcFailure,Xb.assertIsJsonRpcNotification=Bk.assertIsJsonRpcNotification,Xb.assertIsJsonRpcRequest=Bk.assertIsJsonRpcRequest,Xb.assertIsJsonRpcResponse=Bk.assertIsJsonRpcResponse,Xb.assertIsJsonRpcSuccess=Bk.assertIsJsonRpcSuccess,Xb.assertIsPendingJsonRpcResponse=Bk.assertIsPendingJsonRpcResponse,Xb.assertIsSemVerRange=Ik.assertIsSemVerRange,Xb.assertIsSemVerVersion=Ik.assertIsSemVerVersion,Xb.assertIsStrictHexString=Ck.assertIsStrictHexString,Xb.assertStruct=Pk.assertStruct,Xb.base64=Mk.base64,Xb.base64ToBytes=Ck.base64ToBytes,Xb.bigIntToBytes=Ck.bigIntToBytes,Xb.bigIntToHex=xk.bigIntToHex,Xb.bytesToBase64=Ck.bytesToBase64,Xb.bytesToBigInt=Ck.bytesToBigInt,Xb.bytesToHex=Ck.bytesToHex,Xb.bytesToNumber=Ck.bytesToNumber,Xb.bytesToSignedBigInt=Ck.bytesToSignedBigInt,Xb.bytesToString=Ck.bytesToString,Xb.calculateNumberSize=Uk.calculateNumberSize,Xb.calculateStringSize=Uk.calculateStringSize,Xb.concatBytes=Ck.concatBytes,Xb.createBigInt=Lk.createBigInt,Xb.createBytes=Lk.createBytes,Xb.createDataView=Ck.createDataView,Xb.createDeferredPromise=Ak.createDeferredPromise,Xb.createHex=Lk.createHex,Xb.createModuleLogger=Tk.createModuleLogger,Xb.createNumber=Lk.createNumber,Xb.createProjectLogger=Tk.createProjectLogger,Xb.exactOptional=Bk.exactOptional,Xb.getChecksumAddress=Ck.getChecksumAddress,Xb.getErrorMessage=Nk.getErrorMessage,Xb.getJsonRpcIdValidator=Bk.getJsonRpcIdValidator,Xb.getJsonSize=Bk.getJsonSize,Xb.getKnownPropertyNames=Uk.getKnownPropertyNames,Xb.getSafeJson=Bk.getSafeJson,Xb.gtRange=Ik.gtRange,Xb.gtVersion=Ik.gtVersion,Xb.hasProperty=Uk.hasProperty,Xb.hexToBigInt=xk.hexToBigInt,Xb.hexToBytes=Ck.hexToBytes,Xb.hexToNumber=xk.hexToNumber,Xb.inMilliseconds=kk.inMilliseconds,Xb.isASCII=Uk.isASCII,Xb.isBytes=Ck.isBytes,Xb.isCaipAccountAddress=Rk.isCaipAccountAddress,Xb.isCaipAccountId=Rk.isCaipAccountId,Xb.isCaipChainId=Rk.isCaipChainId,Xb.isCaipNamespace=Rk.isCaipNamespace,Xb.isCaipReference=Rk.isCaipReference,Xb.isErrorWithCode=Nk.isErrorWithCode,Xb.isErrorWithMessage=Nk.isErrorWithMessage,Xb.isErrorWithStack=Nk.isErrorWithStack,Xb.isHexString=Ck.isHexString,Xb.isJsonRpcError=Bk.isJsonRpcError,Xb.isJsonRpcFailure=Bk.isJsonRpcFailure,Xb.isJsonRpcNotification=Bk.isJsonRpcNotification,Xb.isJsonRpcRequest=Bk.isJsonRpcRequest,Xb.isJsonRpcResponse=Bk.isJsonRpcResponse,Xb.isJsonRpcSuccess=Bk.isJsonRpcSuccess,Xb.isNonEmptyArray=Uk.isNonEmptyArray,Xb.isNullOrUndefined=Uk.isNullOrUndefined,Xb.isObject=Uk.isObject,Xb.isPendingJsonRpcResponse=Bk.isPendingJsonRpcResponse,Xb.isPlainObject=Uk.isPlainObject,Xb.isStrictHexString=Ck.isStrictHexString,Xb.isValidChecksumAddress=Ck.isValidChecksumAddress,Xb.isValidHexAddress=Ck.isValidHexAddress,Xb.isValidJson=Bk.isValidJson,Xb.isValidSemVerRange=Ik.isValidSemVerRange,Xb.isValidSemVerVersion=Ik.isValidSemVerVersion,Xb.jsonrpc2=Bk.jsonrpc2,Xb.numberToBytes=Ck.numberToBytes,Xb.numberToHex=xk.numberToHex,Xb.object=Bk.object,Xb.parseCaipAccountId=Rk.parseCaipAccountId,Xb.parseCaipChainId=Rk.parseCaipChainId,Xb.remove0x=Ck.remove0x,Xb.satisfiesVersionRange=Ik.satisfiesVersionRange,Xb.signedBigIntToBytes=Ck.signedBigIntToBytes,Xb.stringToBytes=Ck.stringToBytes,Xb.timeSince=kk.timeSince,Xb.toCaipChainId=Rk.toCaipChainId,Xb.valueToBytes=Ck.valueToBytes,Xb.wrapError=Nk.wrapError,Object.defineProperty(Yb,"__esModule",{value:!0}),Yb.normalize=Yb.recoverPublicKey=Yb.concatSig=Yb.legacyToBuffer=Yb.isNullish=Yb.padWithZeroes=void 0;const $k=yl,zk=Xb;function Dk(e,t){if(""!==e&&!/^[a-f0-9]+$/iu.test(e))throw new Error(`Expected an unprefixed hex string. Received: ${e}`);if(t<0)throw new Error(`Expected a non-negative integer target length. Received: ${t}`);return String.prototype.padStart.call(e,t,"0")}function Hk(e){return null==e}Yb.padWithZeroes=Dk,Yb.isNullish=Hk,Yb.legacyToBuffer=function(e){return"string"!=typeof e||(0,$k.isHexString)(e)?(0,$k.toBuffer)(e):C.from(e)},Yb.concatSig=function(e,t,r){const n=(0,$k.fromSigned)(t),i=(0,$k.fromSigned)(r),o=(0,$k.bufferToInt)(e),s=Dk((0,$k.toUnsigned)(n).toString("hex"),64),a=Dk((0,$k.toUnsigned)(i).toString("hex"),64),c=(0,zk.remove0x)((0,zk.numberToHex)(o));return(0,zk.add0x)(s.concat(a,c))},Yb.recoverPublicKey=function(e,t){const r=(0,$k.fromRpcSig)(t);return(0,$k.ecrecover)(e,r.v,r.r,r.s)},Yb.normalize=function(e){if(!Hk(e)){if("number"==typeof e){if(e<0)return"0x";const t=(0,zk.numberToBytes)(e);e=(0,zk.bytesToHex)(t)}if("string"!=typeof e){let t="eth-sig-util.normalize() requires hex string or integer input.";throw t+=` received ${typeof e}: ${e}`,new Error(t)}return(0,zk.add0x)(e.toLowerCase())}},Object.defineProperty(gl,"__esModule",{value:!0}),gl.extractPublicKey=gl.recoverPersonalSignature=gl.personalSign=void 0;const qk=yl,Fk=Yb;function Kk(e,t){const r=(0,qk.hashPersonalMessage)((0,Fk.legacyToBuffer)(e));return(0,Fk.recoverPublicKey)(r,t)}gl.personalSign=function({privateKey:e,data:t}){if((0,Fk.isNullish)(t))throw new Error("Missing data parameter");if((0,Fk.isNullish)(e))throw new Error("Missing privateKey parameter");const r=(0,Fk.legacyToBuffer)(t),n=(0,qk.hashPersonalMessage)(r),i=(0,qk.ecsign)(n,e);return(0,Fk.concatSig)((0,qk.toBuffer)(i.v),i.r,i.s)},gl.recoverPersonalSignature=function({data:e,signature:t}){if((0,Fk.isNullish)(e))throw new Error("Missing data parameter");if((0,Fk.isNullish)(t))throw new Error("Missing signature parameter");const r=Kk(e,t),n=(0,qk.publicToAddress)(r);return(0,qk.bufferToHex)(n)},gl.extractPublicKey=function({data:e,signature:t}){if((0,Fk.isNullish)(e))throw new Error("Missing data parameter");if((0,Fk.isNullish)(t))throw new Error("Missing signature parameter");return`0x${Kk(e,t).toString("hex")}`};var Wk={},Vk={},Zk={},Gk={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ParserError=e.getErrorStack=e.getErrorMessage=void 0;const t=Xb;e.getErrorMessage=e=>"string"==typeof e?e:e instanceof Error||(0,t.isObject)(e)&&(0,t.hasProperty)(e,"message")&&"string"==typeof e.message?e.message:"Unknown error.";e.getErrorStack=e=>{if(e instanceof Error)return e.stack};class r extends Error{constructor(t,r){super(t),this.name="ParserError";const n=(0,e.getErrorStack)(r);n&&(this.stack=n)}}e.ParserError=r}(Gk);var Jk={},Yk={};Object.defineProperty(Yk,"__esModule",{value:!0}),Yk.iterate=void 0;const Xk=Xb;Yk.iterate=function*(e,t=32){for(let r=0;r{(0,Xk.assert)(e>=0,"Cannot skip a negative number of bytes."),(0,Xk.assert)(e%t==0,"Length must be a multiple of the size."),r+=e},i=e.subarray(r);yield{skip:n,value:i}}return{skip:()=>{},value:new Uint8Array}};var Qk={},eI={},tI={},rI={};Object.defineProperty(rI,"__esModule",{value:!0}),rI.padEnd=rI.padStart=rI.set=void 0;const nI=Xb;rI.set=(e,t,r)=>(0,nI.concatBytes)([e.subarray(0,r),t,e.subarray(r+t.length)]);rI.padStart=(e,t=32)=>{const r=new Uint8Array(Math.max(t-e.length,0)).fill(0);return(0,nI.concatBytes)([r,e])};rI.padEnd=(e,t=32)=>{const r=new Uint8Array(Math.max(t-e.length,0)).fill(0);return(0,nI.concatBytes)([e,r])},function(e){var t=Tr&&Tr.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=Tr&&Tr.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(rI,e)}(tI),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.address=e.getAddress=void 0;const t=Xb,r=Gk,n=tI;e.getAddress=e=>{const i=(0,t.createBytes)(e);return(0,t.assert)(i.length<=20,new r.ParserError(`Invalid address value. Expected address to be 20 bytes long, but received ${i.length} bytes.`)),(0,n.padStart)(i,20)},e.address={isDynamic:!1,isType:e=>"address"===e,getByteLength:()=>32,encode({buffer:r,value:i,packed:o}){const s=(0,e.getAddress)(i);if(o)return(0,t.concatBytes)([r,s]);const a=(0,n.padStart)(s);return(0,t.concatBytes)([r,a])},decode:({value:e})=>(0,t.add0x)((0,t.bytesToHex)(e.slice(12,32)))}}(eI);var iI={},oI={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.fixedBytes=e.getByteLength=void 0;const t=Xb,r=Gk,n=tI,i=/^bytes([0-9]{1,2})$/u;e.getByteLength=e=>{const n=e.match(i)?.[1];(0,t.assert)(n,`Invalid byte length. Expected a number between 1 and 32, but received "${e}".`);const o=Number(n);return(0,t.assert)(o>0&&o<=32,new r.ParserError(`Invalid byte length. Expected a number between 1 and 32, but received "${e}".`)),o},e.fixedBytes={isDynamic:!1,isType:e=>i.test(e),getByteLength:()=>32,encode({type:i,buffer:o,value:s,packed:a}){const c=(0,e.getByteLength)(i),u=(0,t.createBytes)(s);return(0,t.assert)(u.length<=c,new r.ParserError(`Expected a value of length ${c}, but received a value of length ${u.length}.`)),a?(0,t.concatBytes)([o,(0,n.padEnd)(u,c)]):(0,t.concatBytes)([o,(0,n.padEnd)(u)])},decode({type:t,value:r}){const n=(0,e.getByteLength)(t);return r.slice(0,n)}}}(oI);var sI,aI,cI={};function uI(){return sI||(sI=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.tuple=e.getTupleElements=void 0;const t=Xb,r=Gk,n=ZI(),i=/^\((.+)\)$/u;e.getTupleElements=e=>{(0,t.assert)(e.startsWith("(")&&e.endsWith(")"),new r.ParserError(`Invalid tuple type. Expected tuple type, but received "${e}".`));const n=[];let i="",o=0;for(let t=1;t(0,e.getTupleElements)(t).some((e=>{const t=(0,n.getParser)(e);return(0,n.isDynamicParser)(t,e)})),isType:e=>(e=>i.test(e))(e),getByteLength(t){if((0,n.isDynamicParser)(this,t))return 32;return(0,e.getTupleElements)(t).reduce(((e,t)=>e+(0,n.getParser)(t).getByteLength(t)),0)},encode({type:t,buffer:r,value:i,packed:o,tight:s}){const a=(0,e.getTupleElements)(t);return(0,n.pack)({types:a,values:i,byteArray:r,packed:o,tight:s})},decode({type:t,value:r,skip:i}){const o=(0,e.getTupleElements)(t);return i(this.getByteLength(t)-32),(0,n.unpack)(o,r)}}}(cI)),cI}var lI={};class hI extends TypeError{constructor(e,t){let r;const{message:n,explanation:i,...o}=e,{path:s}=e,a=0===s.length?n:`At path: ${s.join(".")} -- ${n}`;super(i??a),null!=i&&(this.cause=a),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>r??(r=[e,...t()])}}function fI(e){return"object"==typeof e&&null!=e}function dI(e){if("[object Object]"!==Object.prototype.toString.call(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function pI(e){return"symbol"==typeof e?e.toString():"string"==typeof e?JSON.stringify(e):`${e}`}function gI(e,t,r,n){if(!0===e)return;!1===e?e={}:"string"==typeof e&&(e={message:e});const{path:i,branch:o}=t,{type:s}=r,{refinement:a,message:c=`Expected a value of type \`${s}\`${a?` with refinement \`${a}\``:""}, but received: \`${pI(n)}\``}=e;return{value:n,type:s,refinement:a,key:i[i.length-1],path:i,branch:o,...e,message:c}}function*yI(e,t,r,n){(function(e){return fI(e)&&"function"==typeof e[Symbol.iterator]})(e)||(e=[e]);for(const i of e){const e=gI(i,t,r,n);e&&(yield e)}}function*mI(e,t,r={}){const{path:n=[],branch:i=[e],coerce:o=!1,mask:s=!1}=r,a={path:n,branch:i};if(o&&(e=t.coercer(e,a),s&&"type"!==t.type&&fI(t.schema)&&fI(e)&&!Array.isArray(e)))for(const r in e)void 0===t.schema[r]&&delete e[r];let c="valid";for(const n of t.validator(e,a))n.explanation=r.message,c="not_valid",yield[n,void 0];for(let[u,l,h]of t.entries(e,a)){const t=mI(l,h,{path:void 0===u?n:[...n,u],branch:void 0===u?i:[...i,l],coerce:o,mask:s,message:r.message});for(const r of t)r[0]?(c=null!=r[0].refinement?"not_refined":"not_valid",yield[r[0],void 0]):o&&(l=r[1],void 0===u?e=l:e instanceof Map?e.set(u,l):e instanceof Set?e.add(l):fI(e)&&(void 0!==l||u in e)&&(e[u]=l))}if("not_valid"!==c)for(const n of t.refiner(e,a))n.explanation=r.message,c="not_refined",yield[n,void 0];"valid"===c&&(yield[void 0,e])}class wI{constructor(e){const{type:t,schema:r,validator:n,refiner:i,coercer:o=e=>e,entries:s=function*(){}}=e;this.type=t,this.schema=r,this.entries=s,this.coercer=o,this.validator=n?(e,t)=>yI(n(e,t),t,this,e):()=>[],this.refiner=i?(e,t)=>yI(i(e,t),t,this,e):()=>[]}assert(e,t){return bI(e,this,t)}create(e,t){return vI(e,this,t)}is(e){return EI(e,this)}mask(e,t){return _I(e,this,t)}validate(e,t={}){return SI(e,this,t)}}function bI(e,t,r){const n=SI(e,t,{message:r});if(n[0])throw n[0]}function vI(e,t,r){const n=SI(e,t,{coerce:!0,message:r});if(n[0])throw n[0];return n[1]}function _I(e,t,r){const n=SI(e,t,{coerce:!0,mask:!0,message:r});if(n[0])throw n[0];return n[1]}function EI(e,t){return!SI(e,t)[0]}function SI(e,t,r={}){const n=mI(e,t,r),i=function(e){const{done:t,value:r}=e.next();return t?void 0:r}(n);if(i[0]){const e=new hI(i[0],(function*(){for(const e of n)e[0]&&(yield e[0])}));return[e,void 0]}return[void 0,i[1]]}function xI(e,t){return new wI({type:e,schema:null,validator:t})}function AI(){return xI("never",(()=>!1))}function kI(e){const t=e?Object.keys(e):[],r=AI();return new wI({type:"object",schema:e||null,*entries(n){if(e&&fI(n)){const i=new Set(Object.keys(n));for(const r of t)i.delete(r),yield[r,n[r],e[r]];for(const e of i)yield[e,n[e],r]}},validator:e=>fI(e)||`Expected an object, but received: ${pI(e)}`,coercer:e=>fI(e)?{...e}:e})}function II(e){return new wI({...e,validator:(t,r)=>void 0===t||e.validator(t,r),refiner:(t,r)=>void 0===t||e.refiner(t,r)})}function BI(){return xI("string",(e=>"string"==typeof e||`Expected a string, but received: ${pI(e)}`))}function TI(e){const t=Object.keys(e);return new wI({type:"type",schema:e,*entries(r){if(fI(r))for(const n of t)yield[n,r[n],e[n]]},validator:e=>fI(e)||`Expected an object, but received: ${pI(e)}`,coercer:e=>fI(e)?{...e}:e})}function RI(){return xI("unknown",(()=>!0))}function OI(e,t,r){return new wI({...e,coercer:(n,i)=>EI(n,t)?e.coercer(r(n,i),i):e.coercer(n,i)})}function MI(e){return e instanceof Map||e instanceof Set?e.size:e.length}function LI(e,t,r){return new wI({...e,*refiner(n,i){yield*e.refiner(n,i);const o=yI(r(n,i),i,e,n);for(const e of o)yield{...e,refinement:t}}})}var CI=Object.freeze({__proto__:null,Struct:wI,StructError:hI,any:function(){return xI("any",(()=>!0))},array:function(e){return new wI({type:"array",schema:e,*entries(t){if(e&&Array.isArray(t))for(const[r,n]of t.entries())yield[r,n,e]},coercer:e=>Array.isArray(e)?e.slice():e,validator:e=>Array.isArray(e)||`Expected an array value, but received: ${pI(e)}`})},assert:bI,assign:function(...e){const t="type"===e[0].type,r=e.map((e=>e.schema)),n=Object.assign({},...r);return t?TI(n):kI(n)},bigint:function(){return xI("bigint",(e=>"bigint"==typeof e))},boolean:function(){return xI("boolean",(e=>"boolean"==typeof e))},coerce:OI,create:vI,date:function(){return xI("date",(e=>e instanceof Date&&!isNaN(e.getTime())||`Expected a valid \`Date\` object, but received: ${pI(e)}`))},defaulted:function(e,t,r={}){return OI(e,RI(),(e=>{const n="function"==typeof t?t():t;if(void 0===e)return n;if(!r.strict&&dI(e)&&dI(n)){const t={...e};let r=!1;for(const e in n)void 0===t[e]&&(t[e]=n[e],r=!0);if(r)return t}return e}))},define:xI,deprecated:function(e,t){return new wI({...e,refiner:(t,r)=>void 0===t||e.refiner(t,r),validator:(r,n)=>void 0===r||(t(r,n),e.validator(r,n))})},dynamic:function(e){return new wI({type:"dynamic",schema:null,*entries(t,r){const n=e(t,r);yield*n.entries(t,r)},validator:(t,r)=>e(t,r).validator(t,r),coercer:(t,r)=>e(t,r).coercer(t,r),refiner:(t,r)=>e(t,r).refiner(t,r)})},empty:function(e){return LI(e,"empty",(t=>{const r=MI(t);return 0===r||`Expected an empty ${e.type} but received one with a size of \`${r}\``}))},enums:function(e){const t={},r=e.map((e=>pI(e))).join();for(const r of e)t[r]=r;return new wI({type:"enums",schema:t,validator:t=>e.includes(t)||`Expected one of \`${r}\`, but received: ${pI(t)}`})},func:function(){return xI("func",(e=>"function"==typeof e||`Expected a function, but received: ${pI(e)}`))},instance:function(e){return xI("instance",(t=>t instanceof e||`Expected a \`${e.name}\` instance, but received: ${pI(t)}`))},integer:function(){return xI("integer",(e=>"number"==typeof e&&!isNaN(e)&&Number.isInteger(e)||`Expected an integer, but received: ${pI(e)}`))},intersection:function(e){return new wI({type:"intersection",schema:null,*entries(t,r){for(const n of e)yield*n.entries(t,r)},*validator(t,r){for(const n of e)yield*n.validator(t,r)},*refiner(t,r){for(const n of e)yield*n.refiner(t,r)}})},is:EI,lazy:function(e){let t;return new wI({type:"lazy",schema:null,*entries(r,n){t??(t=e()),yield*t.entries(r,n)},validator:(r,n)=>(t??(t=e()),t.validator(r,n)),coercer:(r,n)=>(t??(t=e()),t.coercer(r,n)),refiner:(r,n)=>(t??(t=e()),t.refiner(r,n))})},literal:function(e){const t=pI(e),r=typeof e;return new wI({type:"literal",schema:"string"===r||"number"===r||"boolean"===r?e:null,validator:r=>r===e||`Expected the literal \`${t}\`, but received: ${pI(r)}`})},map:function(e,t){return new wI({type:"map",schema:null,*entries(r){if(e&&t&&r instanceof Map)for(const[n,i]of r.entries())yield[n,n,e],yield[n,i,t]},coercer:e=>e instanceof Map?new Map(e):e,validator:e=>e instanceof Map||`Expected a \`Map\` object, but received: ${pI(e)}`})},mask:_I,max:function(e,t,r={}){const{exclusive:n}=r;return LI(e,"max",(r=>n?rn?r>t:r>=t||`Expected a ${e.type} greater than ${n?"":"or equal to "}${t} but received \`${r}\``))},never:AI,nonempty:function(e){return LI(e,"nonempty",(t=>MI(t)>0||`Expected a nonempty ${e.type} but received an empty one`))},nullable:function(e){return new wI({...e,validator:(t,r)=>null===t||e.validator(t,r),refiner:(t,r)=>null===t||e.refiner(t,r)})},number:function(){return xI("number",(e=>"number"==typeof e&&!isNaN(e)||`Expected a number, but received: ${pI(e)}`))},object:kI,omit:function(e,t){const{schema:r}=e,n={...r};for(const e of t)delete n[e];return"type"===e.type?TI(n):kI(n)},optional:II,partial:function(e){const t=e instanceof wI,r=t?{...e.schema}:{...e};for(const e in r)r[e]=II(r[e]);return t&&"type"===e.type?TI(r):kI(r)},pattern:function(e,t){return LI(e,"pattern",(r=>t.test(r)||`Expected a ${e.type} matching \`/${t.source}/\` but received "${r}"`))},pick:function(e,t){const{schema:r}=e,n={};for(const e of t)n[e]=r[e];return"type"===e.type?TI(n):kI(n)},record:function(e,t){return new wI({type:"record",schema:null,*entries(r){if(fI(r))for(const n in r){const i=r[n];yield[n,n,e],yield[n,i,t]}},validator:e=>fI(e)||`Expected an object, but received: ${pI(e)}`})},refine:LI,regexp:function(){return xI("regexp",(e=>e instanceof RegExp))},set:function(e){return new wI({type:"set",schema:null,*entries(t){if(e&&t instanceof Set)for(const r of t)yield[r,r,e]},coercer:e=>e instanceof Set?new Set(e):e,validator:e=>e instanceof Set||`Expected a \`Set\` object, but received: ${pI(e)}`})},size:function(e,t,r=t){const n=`Expected a ${e.type}`,i=t===r?`of \`${t}\``:`between \`${t}\` and \`${r}\``;return LI(e,"size",(e=>{if("number"==typeof e||e instanceof Date)return t<=e&&e<=r||`${n} ${i} but received \`${e}\``;if(e instanceof Map||e instanceof Set){const{size:o}=e;return t<=o&&o<=r||`${n} with a size ${i} but received one with a size of \`${o}\``}{const{length:o}=e;return t<=o&&o<=r||`${n} with a length ${i} but received one with a length of \`${o}\``}}))},string:BI,struct:function(e,t){return console.warn("superstruct@0.11 - The `struct` helper has been renamed to `define`."),xI(e,t)},trimmed:function(e){return OI(e,BI(),(e=>e.trim()))},tuple:function(e){const t=AI();return new wI({type:"tuple",schema:null,*entries(r){if(Array.isArray(r)){const n=Math.max(e.length,r.length);for(let i=0;iArray.isArray(e)||`Expected an array, but received: ${pI(e)}`})},type:TI,union:function(e){const t=e.map((e=>e.type)).join(" | ");return new wI({type:"union",schema:null,coercer(t){for(const r of e){const[e,n]=r.validate(t,{coerce:!0});if(!e)return n}return t},validator(r,n){const i=[];for(const t of e){const[...e]=mI(r,t,n),[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: ${pI(r)}`,...i]}})},unknown:RI,validate:SI}),PI=Rr(CI),NI={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.number=e.getBigInt=e.assertNumberLength=e.getLength=e.isSigned=void 0;const t=Xb,r=Gk,n=tI,i=/^u?int(?[0-9]*)?$/u;e.isSigned=e=>!e.startsWith("u");e.getLength=e=>{if("int"===e||"uint"===e)return 256;const n=e.match(i);(0,t.assert)(n?.groups?.length,new r.ParserError(`Invalid number type. Expected a number type, but received "${e}".`));const o=parseInt(n.groups.length,10);return(0,t.assert)(o>=8&&o<=256,new r.ParserError(`Invalid number length. Expected a number between 8 and 256, but received "${e}".`)),(0,t.assert)(o%8==0,new r.ParserError(`Invalid number length. Expected a multiple of 8, but received "${e}".`)),o};e.assertNumberLength=(n,i)=>{const o=(0,e.getLength)(i),s=BigInt(2)**BigInt(o-((0,e.isSigned)(i)?1:0))-BigInt(1);(0,e.isSigned)(i)?(0,t.assert)(n>=-(s+BigInt(1))&&n<=s,new r.ParserError(`Number "${n}" is out of range for type "${i}".`)):(0,t.assert)(n<=s,new r.ParserError(`Number "${n}" is out of range for type "${i}".`))};e.getBigInt=e=>{try{return(0,t.createBigInt)(e)}catch{throw new r.ParserError(`Invalid number. Expected a valid number value, but received "${e}".`)}},e.number={isDynamic:!1,isType:e=>i.test(e),getByteLength:()=>32,encode({type:r,buffer:i,value:o,packed:s}){const a=(0,e.getBigInt)(o);if((0,e.assertNumberLength)(a,r),(0,e.isSigned)(r)){if(s){const n=(0,e.getLength)(r)/8;return(0,t.concatBytes)([i,(0,t.signedBigIntToBytes)(a,n)])}return(0,t.concatBytes)([i,(0,n.padStart)((0,t.signedBigIntToBytes)(a,32))])}if(s){const o=(0,e.getLength)(r)/8;return(0,t.concatBytes)([i,(0,n.padStart)((0,t.bigIntToBytes)(a),o)])}return(0,t.concatBytes)([i,(0,n.padStart)((0,t.bigIntToBytes)(a))])},decode({type:r,value:n}){const i=n.subarray(0,32);if((0,e.isSigned)(r)){const n=(0,t.bytesToSignedBigInt)(i);return(0,e.assertNumberLength)(n,r),n}const o=(0,t.bytesToBigInt)(i);return(0,e.assertNumberLength)(o,r),o}}}(NI),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.bool=e.getBooleanValue=void 0;const t=Xb,r=PI,n=Gk,i=NI,o=(0,r.coerce)((0,r.boolean)(),(0,r.union)([(0,r.literal)("true"),(0,r.literal)("false")]),(e=>"true"===e));e.getBooleanValue=e=>{try{return(0,r.create)(e,o)?BigInt(1):BigInt(0)}catch{throw new n.ParserError(`Invalid boolean value. Expected a boolean literal, or the string "true" or "false", but received "${e}".`)}},e.bool={isDynamic:!1,isType:e=>"bool"===e,getByteLength:()=>32,encode({buffer:r,value:n,packed:o,tight:s}){const a=(0,e.getBooleanValue)(n);return o?(0,t.concatBytes)([r,(0,t.bigIntToBytes)(a)]):i.number.encode({type:"uint256",buffer:r,value:a,packed:o,tight:s})},decode:e=>i.number.decode({...e,type:"uint256"})===BigInt(1)}}(lI);var UI={};Object.defineProperty(UI,"__esModule",{value:!0}),UI.bytes=void 0;const jI=Xb,$I=tI;UI.bytes={isDynamic:!0,isType:e=>"bytes"===e,getByteLength:()=>32,encode({buffer:e,value:t,packed:r}){const n=(0,jI.createBytes)(t);if(r)return(0,jI.concatBytes)([e,n]);const i=32*Math.ceil(n.byteLength/32);return(0,jI.concatBytes)([e,(0,$I.padStart)((0,jI.numberToBytes)(n.byteLength)),(0,$I.padEnd)(n,i)])},decode({value:e}){const t=e.subarray(0,32),r=(0,jI.bytesToNumber)(t);return e.slice(32,32+r)}};var zI={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.fn=e.getFunction=void 0;const t=Xb,r=PI,n=Gk,i=oI,o=(0,r.coerce)((0,r.object)({address:t.StrictHexStruct,selector:t.StrictHexStruct}),(0,r.union)([t.StrictHexStruct,(0,r.instance)(Uint8Array)]),(e=>{const r=(0,t.createBytes)(e);return(0,t.assert)(24===r.length,new n.ParserError(`Invalid Solidity function. Expected function to be 24 bytes long, but received ${r.length} bytes.`)),{address:(0,t.bytesToHex)(r.subarray(0,20)),selector:(0,t.bytesToHex)(r.subarray(20,24))}}));e.getFunction=e=>{const n=(0,r.create)(e,o);return(0,t.concatBytes)([(0,t.hexToBytes)(n.address),(0,t.hexToBytes)(n.selector)])},e.fn={isDynamic:!1,isType:e=>"function"===e,getByteLength:()=>32,encode({buffer:t,value:r,packed:n,tight:o}){const s=(0,e.getFunction)(r);return i.fixedBytes.encode({type:"bytes24",buffer:t,value:s,packed:n,tight:o})},decode:({value:e})=>({address:(0,t.bytesToHex)(e.slice(0,20)),selector:(0,t.bytesToHex)(e.slice(20,24))})}}(zI);var DI={};Object.defineProperty(DI,"__esModule",{value:!0});var HI={};Object.defineProperty(HI,"__esModule",{value:!0}),HI.string=void 0;const qI=Xb,FI=UI;var KI,WI;function VI(){return KI||(KI=1,function(e){var t=Tr&&Tr.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=Tr&&Tr.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(eI,e),r((aI||(aI=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.array=e.getTupleType=e.getArrayType=e.isArrayType=void 0;const t=Xb,r=Gk,n=ZI(),i=tI,o=oI,s=uI(),a=/^(?.*)\[(?\d*?)\]$/u;e.isArrayType=e=>a.test(e),e.getArrayType=e=>{const n=e.match(a);return(0,t.assert)(n?.groups?.type,new r.ParserError(`Invalid array type. Expected an array type, but received "${e}".`)),[n.groups.type,n.groups.length?parseInt(n.groups.length,10):void 0]},e.getTupleType=(e,t)=>`(${new Array(t).fill(e).join(",")})`,e.array={isDynamic(t){const[r,i]=(0,e.getArrayType)(t);return void 0===i||(0,n.isDynamicParser)((0,n.getParser)(r),r)},isType:t=>(0,e.isArrayType)(t),getByteLength(i){(0,t.assert)((0,e.isArrayType)(i),new r.ParserError(`Expected an array type, but received "${i}".`));const[o,a]=(0,e.getArrayType)(i);return(0,n.isDynamicParser)(this,i)||void 0===a?32:s.tuple.getByteLength((0,e.getTupleType)(o,a))},encode({type:a,buffer:c,value:u,packed:l,tight:h}){const[f,d]=(0,e.getArrayType)(a);if((0,t.assert)(!l||!(0,e.isArrayType)(f),new r.ParserError("Cannot pack nested arrays.")),l&&(0,n.isDynamicParser)((0,n.getParser)(f),f))return(0,n.pack)({types:new Array(u.length).fill(f),values:u,byteArray:c,packed:l,arrayPacked:!0,tight:h});if(d)return(0,t.assert)(d===u.length,new r.ParserError(`Array length does not match type length. Expected a length of ${d}, but received ${u.length}.`)),s.tuple.encode({type:(0,e.getTupleType)(f,d),buffer:c,value:u,packed:o.fixedBytes.isType(f)&&h,tight:h});if(l)return(0,n.pack)({types:new Array(u.length).fill(f),values:u,byteArray:c,packed:o.fixedBytes.isType(f)&&h,arrayPacked:!0,tight:h});const p=(0,i.padStart)((0,t.numberToBytes)(u.length));return(0,n.pack)({types:new Array(u.length).fill(f),values:u,byteArray:(0,t.concatBytes)([c,p]),packed:l,tight:h})},decode({type:i,value:o,...a}){const[c,u]=(0,e.getArrayType)(i);if(u){const n=s.tuple.decode({type:(0,e.getTupleType)(c,u),value:o,...a});return(0,t.assert)(n.length===u,new r.ParserError(`Array length does not match type length. Expected a length of ${u}, but received ${n.length}.`)),n}const l=(0,t.bytesToNumber)(o.subarray(0,32));return(0,n.unpack)(new Array(l).fill(c),o.subarray(32))}}}(iI)),iI),e),r(lI,e),r(UI,e),r(oI,e),r(zI,e),r(NI,e),r(DI,e),r(HI,e),r(uI(),e)}(Qk)),Qk}function ZI(){return WI||(WI=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.unpack=e.pack=e.isDynamicParser=e.getParser=void 0;const t=Xb,r=Gk,n=Yk,i=VI(),o=tI;e.getParser=e=>{const t={address:i.address,array:i.array,bool:i.bool,bytes:i.bytes,fixedBytes:i.fixedBytes,function:i.fn,number:i.number,string:i.string,tuple:i.tuple},n=t[e];if(n)return n;const o=Object.values(t).find((t=>t.isType(e)));if(o)return o;throw new r.ParserError(`The type "${e}" is not supported.`)};e.isDynamicParser=(e,t)=>{const{isDynamic:r}=e;return"function"==typeof r?r(t):r};e.pack=({types:n,values:i,packed:s=!1,tight:a=!1,arrayPacked:c=!1,byteArray:u=new Uint8Array})=>{(0,t.assert)(n.length===i.length,new r.ParserError(`The number of types (${n.length}) does not match the number of values (${i.length}).`));const{staticBuffer:l,dynamicBuffer:h,pointers:f}=n.reduce((({staticBuffer:r,dynamicBuffer:n,pointers:o},u,l)=>{const h=(0,e.getParser)(u),f=i[l];if(s||c||!(0,e.isDynamicParser)(h,u))return{staticBuffer:h.encode({buffer:r,value:f,type:u,packed:s,tight:a}),dynamicBuffer:n,pointers:o};return{staticBuffer:(0,t.concatBytes)([r,new Uint8Array(32)]),dynamicBuffer:h.encode({buffer:n,value:f,type:u,packed:s,tight:a}),pointers:[...o,{position:r.length,pointer:n.length}]}}),{staticBuffer:new Uint8Array,dynamicBuffer:new Uint8Array,pointers:[]});(0,t.assert)(!s&&!c||0===h.length,new r.ParserError("Invalid pack state."));const d=l.length,p=f.reduce(((e,{pointer:r,position:n})=>{const i=(0,o.padStart)((0,t.numberToBytes)(d+r));return(0,o.set)(e,i,n)}),l);return(0,t.concatBytes)([u,p,h])};e.unpack=(i,o)=>{const s=(0,n.iterate)(o);return i.map((n=>{const{value:{value:i,skip:a},done:c}=s.next();(0,t.assert)(!c,new r.ParserError(`The encoded value is invalid for the provided types. Reached end of buffer while attempting to parse "${n}".`));const u=(0,e.getParser)(n);if((0,e.isDynamicParser)(u,n)){const e=(0,t.bytesToNumber)(i.subarray(0,32)),r=o.subarray(e);return u.decode({type:n,value:r,skip:a})}return u.decode({type:n,value:i,skip:a})}))}}(Jk)),Jk}HI.string={isDynamic:!0,isType:e=>"string"===e,getByteLength:()=>32,encode:({buffer:e,value:t,packed:r,tight:n})=>FI.bytes.encode({type:"bytes",buffer:e,value:(0,qI.stringToBytes)(t),packed:r,tight:n}),decode:e=>(0,qI.bytesToString)(FI.bytes.decode(e))},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.decodeSingle=e.decode=e.encodePacked=e.encodeSingle=e.encode=void 0;const t=Xb,r=Gk,n=ZI();e.encode=(e,t,i,o)=>{try{return(0,n.pack)({types:e,values:t,packed:i,tight:o})}catch(e){if(e instanceof r.ParserError)throw new r.ParserError(`Unable to encode value: ${e.message}`,e);throw new r.ParserError(`An unexpected error occurred: ${(0,r.getErrorMessage)(e)}`,e)}};e.encodeSingle=(t,r)=>(0,e.encode)([t],[r]);e.encodePacked=(t,r,n)=>(0,e.encode)(t,r,!0,n);e.decode=(e,i)=>{const o=(0,t.createBytes)(i);try{return(0,n.unpack)(e,o)}catch(e){if(e instanceof r.ParserError)throw new r.ParserError(`Unable to decode value: ${e.message}`,e);throw new r.ParserError(`An unexpected error occurred: ${(0,r.getErrorMessage)(e)}`,e)}};e.decodeSingle=(n,i)=>{const o=(0,e.decode)([n],i);return(0,t.assert)(1===o.length,new r.ParserError("Decoded value array has unexpected length.")),o[0]}}(Zk);var GI={},JI={};Object.defineProperty(JI,"__esModule",{value:!0}),function(e){var t=Tr&&Tr.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=Tr&&Tr.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(JI,e)}(GI),function(e){var t=Tr&&Tr.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=Tr&&Tr.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(Zk,e),r(Gk,e),r(GI,e)}(Vk),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.recoverTypedSignature=e.signTypedData=e.typedSignatureHash=e.TypedDataUtils=e.TYPED_MESSAGE_SCHEMA=e.SignTypedDataVersion=void 0;const t=yl,r=Vk,n=VI(),i=tI,o=Xb,s=bf,a=Yb;var c;function u(e,t){if(!Object.keys(c).includes(e))throw new Error(`Invalid version: '${e}'`);if(t&&!t.includes(e))throw new Error(`SignTypedDataVersion not allowed: '${e}'. Allowed versions are: ${t.join(", ")}`)}function l(e,t){(0,o.assert)(null!==t,`Unable to encode value: Invalid number. Expected a valid number value, but received "${t}".`);const r=BigInt(t),i=(0,n.getLength)(e),s=BigInt(2)**BigInt(i)-BigInt(1);return(0,o.assert)(r>=-s&&r<=s,`Unable to encode value: Number "${t}" is out of range for type "${e}".`),r}function h(e){let t=BigInt(0);for(let r=0;r=49?n-BigInt(49)+BigInt(10):n>=17?n-BigInt(17)+BigInt(10):n}return(0,i.padStart)((0,o.bigIntToBytes)(t),20)}function f(e,n,a,p,g){if(u(g,[c.V3,c.V4]),void 0!==e[a])return["bytes32",g===c.V4&&null==p?"0x0000000000000000000000000000000000000000000000000000000000000000":(0,t.arrToBufArr)((0,s.keccak256)(d(a,p,e,g)))];if("function"===a)throw new Error('Unsupported or invalid type: "function"');if(void 0===p)throw new Error(`missing value for field ${n} of type ${a}`);if("address"===a){if("number"==typeof p)return["address",(0,i.padStart)((0,o.numberToBytes)(p),20)];if((0,o.isStrictHexString)(p))return["address",(0,o.add0x)(p)];if("string"==typeof p)return["address",h(p).subarray(0,20)]}if("bool"===a)return["bool",Boolean(p)];if("bytes"===a)return"number"==typeof p?p=(0,o.numberToBytes)(p):(0,o.isStrictHexString)(p)||"0x"===p?p=(0,o.hexToBytes)(p):"string"==typeof p&&(p=(0,o.stringToBytes)(p)),["bytes32",(0,t.arrToBufArr)((0,s.keccak256)(p))];if(a.startsWith("bytes")&&"bytes"!==a&&!a.includes("["))return"number"==typeof p?p<0?["bytes32",new Uint8Array(32)]:["bytes32",(0,o.bigIntToBytes)(BigInt(p))]:(0,o.isStrictHexString)(p)?["bytes32",(0,o.hexToBytes)(p)]:["bytes32",p];if(a.startsWith("int")&&!a.includes("[")){const e=l(a,p);return e>=BigInt(0)?["uint256",e]:["int256",e]}if("string"===a)return p="number"==typeof p?(0,o.numberToBytes)(p):(0,o.stringToBytes)(null!=p?p:""),["bytes32",(0,t.arrToBufArr)((0,s.keccak256)(p))];if(a.endsWith("]")){if(g===c.V3)throw new Error("Arrays are unimplemented in encodeData; use V4 extension");const i=a.slice(0,a.lastIndexOf("[")),o=p.map((t=>f(e,n,i,t,g)));return["bytes32",(0,t.arrToBufArr)((0,s.keccak256)((0,r.encode)(o.map((([e])=>e)),o.map((([,e])=>e)))))]}return[a,p]}function d(e,n,i,o){u(o,[c.V3,c.V4]);const s=["bytes32"],a=[m(e,i)];for(const t of i[e]){if(o===c.V3&&void 0===n[t.name])continue;const[e,r]=f(i,t.name,t.type,n[t.name],o);s.push(e),a.push(r)}return(0,t.arrToBufArr)((0,r.encode)(s,a))}function p(e,t){let r="";const n=g(e,t);n.delete(e);const i=[e,...Array.from(n).sort()];for(const e of i){if(!t[e])throw new Error(`No type definition specified: ${e}`);r+=`${e}(${t[e].map((({name:e,type:t})=>`${t} ${e}`)).join(",")})`}return r}function g(e,t,r=new Set){if("string"!=typeof e)throw new Error(`Invalid findTypeDependencies input ${JSON.stringify(e)}`);const n=e.match(/^\w*/u);if([e]=n,r.has(e)||void 0===t[e])return r;r.add(e);for(const n of t[e])g(n.type,t,r);return r}function y(e,r,n,i){u(i,[c.V3,c.V4]);const o=d(e,r,n,i),a=(0,s.keccak256)(o);return(0,t.arrToBufArr)(a)}function m(e,r){const n=(0,o.stringToBytes)(p(e,r));return(0,t.arrToBufArr)((0,s.keccak256)(n))}function w(t){const r={};for(const n in e.TYPED_MESSAGE_SCHEMA.properties)t[n]&&(r[n]=t[n]);return"types"in r&&(r.types=Object.assign({EIP712Domain:[]},r.types)),r}function b(e,t){u(t,[c.V3,c.V4]);const r=w(e),{domain:n}=r;return y("EIP712Domain",n,{EIP712Domain:r.types.EIP712Domain},t)}function v(e,t){if((0,n.isArrayType)(e)&&Array.isArray(t)){const[r]=(0,n.getArrayType)(e);return t.map((e=>v(r,e)))}if("address"===e){if("number"==typeof t)return(0,i.padStart)((0,o.numberToBytes)(t),20);if((0,o.isStrictHexString)(t))return(0,i.padStart)((0,o.hexToBytes)(t).subarray(0,20),20);if(t instanceof Uint8Array)return(0,i.padStart)(t.subarray(0,20),20)}if("bool"===e)return Boolean(t);if(e.startsWith("bytes")&&"bytes"!==e){const r=(0,n.getByteLength)(e);if("number"==typeof t)return t<0?new Uint8Array:(0,o.numberToBytes)(t).subarray(0,r);if((0,o.isStrictHexString)(t))return(0,o.hexToBytes)(t).subarray(0,r);if(t instanceof Uint8Array)return t.subarray(0,r)}if(e.startsWith("uint")&&"number"==typeof t)return Math.abs(t);if(e.startsWith("int")&&"number"==typeof t){const r=(0,n.getLength)(e);return BigInt.asIntN(r,BigInt(t))}return t}function _(e,t){return t.map((t=>{if("string"==typeof t||"number"==typeof t||"bigint"==typeof t){const r=l(e,t);if(r>=BigInt(0))return(0,i.padStart)((0,o.bigIntToBytes)(r),32);const s=(0,n.getLength)(e),a=BigInt.asIntN(s,r);return(0,o.signedBigIntToBytes)(a,32)}return t}))}function E(e){const c=new Error("Expect argument to be non-empty array");if("object"!=typeof e||!("length"in e)||!e.length)throw c;const u=e.map((({name:e,type:t,value:r})=>{if("address[]"===t)return{name:e,type:"bytes32[]",value:(s=r,s.map((e=>"number"==typeof e?(0,i.padStart)((0,o.numberToBytes)(e),32):(0,o.isStrictHexString)(e)?(0,i.padStart)((0,o.hexToBytes)(e).subarray(0,32),32):e instanceof Uint8Array?(0,i.padStart)(e.subarray(0,32),32):e)))};var s;if(t.startsWith("int")&&(0,n.isArrayType)(t)){const[i,o]=(0,n.getArrayType)(t);return{name:e,type:`bytes32[${null!=o?o:""}]`,value:_(i,r)}}return{name:e,type:t,value:v(t,r)}})),l=u.map((e=>"bytes"!==e.type?e.value:(0,a.legacyToBuffer)(e.value))),h=u.map((e=>{if("function"===e.type)throw new Error('Unsupported or invalid type: "function"');return e.type})),f=e.map((e=>{if(!e.name)throw c;return`${e.type} ${e.name}`}));return(0,t.arrToBufArr)((0,s.keccak256)((0,r.encodePacked)(["bytes32","bytes32"],[(0,s.keccak256)((0,r.encodePacked)(["string[]"],[f],!0)),(0,s.keccak256)((0,r.encodePacked)(h,l,!0))])))}!function(e){e.V1="V1",e.V3="V3",e.V4="V4"}(c=e.SignTypedDataVersion||(e.SignTypedDataVersion={})),e.TYPED_MESSAGE_SCHEMA={type:"object",properties:{types:{type:"object",additionalProperties:{type:"array",items:{type:"object",properties:{name:{type:"string"},type:{type:"string"}},required:["name","type"]}}},primaryType:{type:"string"},domain:{type:"object"},message:{type:"object"}},required:["types","primaryType","domain","message"]},e.TypedDataUtils={encodeData:d,encodeType:p,findTypeDependencies:g,hashStruct:y,hashType:m,sanitizeData:w,eip712Hash:function(e,r){u(r,[c.V3,c.V4]);const n=w(e),i=[(0,o.hexToBytes)("1901")];return i.push(b(e,r)),"EIP712Domain"!==n.primaryType&&i.push(y(n.primaryType,n.message,n.types,r)),(0,t.arrToBufArr)((0,s.keccak256)((0,o.concatBytes)(i)))},eip712DomainHash:b},e.typedSignatureHash=function(e){const t=E(e);return(0,o.bytesToHex)(t)},e.signTypedData=function({privateKey:r,data:n,version:i}){if(u(i),(0,a.isNullish)(n))throw new Error("Missing data parameter");if((0,a.isNullish)(r))throw new Error("Missing private key parameter");const s=i===c.V1?E(n):e.TypedDataUtils.eip712Hash(n,i),l=(0,t.ecsign)(s,r);return(0,a.concatSig)((0,t.arrToBufArr)((0,o.bigIntToBytes)(l.v)),l.r,l.s)},e.recoverTypedSignature=function({data:r,signature:n,version:i}){if(u(i),(0,a.isNullish)(r))throw new Error("Missing data parameter");if((0,a.isNullish)(n))throw new Error("Missing signature parameter");const s=i===c.V1?E(r):e.TypedDataUtils.eip712Hash(r,i),l=(0,a.recoverPublicKey)(s,n),h=(0,t.publicToAddress)(l);return(0,o.bytesToHex)(h)}}(Wk);var YI={},XI={exports:{}},QI=Rr(Object.freeze({__proto__:null,default:{}}));!function(e){!function(e){var t=function(e){var t,r=new Float64Array(16);if(e)for(t=0;t>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r,e[t+4]=n>>24&255,e[t+5]=n>>16&255,e[t+6]=n>>8&255,e[t+7]=255&n}function p(e,t,r,n,i){var o,s=0;for(o=0;o>>8)-1}function g(e,t,r,n){return p(e,t,r,n,16)}function y(e,t,r,n){return p(e,t,r,n,32)}function m(e,t,r,n){!function(e,t,r,n){for(var i,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,a=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,c=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,u=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,l=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,h=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,f=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,d=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,p=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,g=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,y=255&r[16]|(255&r[17])<<8|(255&r[18])<<16|(255&r[19])<<24,m=255&r[20]|(255&r[21])<<8|(255&r[22])<<16|(255&r[23])<<24,w=255&r[24]|(255&r[25])<<8|(255&r[26])<<16|(255&r[27])<<24,b=255&r[28]|(255&r[29])<<8|(255&r[30])<<16|(255&r[31])<<24,v=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,_=o,E=s,S=a,x=c,A=u,k=l,I=h,B=f,T=d,R=p,O=g,M=y,L=m,C=w,P=b,N=v,U=0;U<20;U+=2)_^=(i=(L^=(i=(T^=(i=(A^=(i=_+L|0)<<7|i>>>25)+_|0)<<9|i>>>23)+A|0)<<13|i>>>19)+T|0)<<18|i>>>14,k^=(i=(E^=(i=(C^=(i=(R^=(i=k+E|0)<<7|i>>>25)+k|0)<<9|i>>>23)+R|0)<<13|i>>>19)+C|0)<<18|i>>>14,O^=(i=(I^=(i=(S^=(i=(P^=(i=O+I|0)<<7|i>>>25)+O|0)<<9|i>>>23)+P|0)<<13|i>>>19)+S|0)<<18|i>>>14,N^=(i=(M^=(i=(B^=(i=(x^=(i=N+M|0)<<7|i>>>25)+N|0)<<9|i>>>23)+x|0)<<13|i>>>19)+B|0)<<18|i>>>14,_^=(i=(x^=(i=(S^=(i=(E^=(i=_+x|0)<<7|i>>>25)+_|0)<<9|i>>>23)+E|0)<<13|i>>>19)+S|0)<<18|i>>>14,k^=(i=(A^=(i=(B^=(i=(I^=(i=k+A|0)<<7|i>>>25)+k|0)<<9|i>>>23)+I|0)<<13|i>>>19)+B|0)<<18|i>>>14,O^=(i=(R^=(i=(T^=(i=(M^=(i=O+R|0)<<7|i>>>25)+O|0)<<9|i>>>23)+M|0)<<13|i>>>19)+T|0)<<18|i>>>14,N^=(i=(P^=(i=(C^=(i=(L^=(i=N+P|0)<<7|i>>>25)+N|0)<<9|i>>>23)+L|0)<<13|i>>>19)+C|0)<<18|i>>>14;_=_+o|0,E=E+s|0,S=S+a|0,x=x+c|0,A=A+u|0,k=k+l|0,I=I+h|0,B=B+f|0,T=T+d|0,R=R+p|0,O=O+g|0,M=M+y|0,L=L+m|0,C=C+w|0,P=P+b|0,N=N+v|0,e[0]=_>>>0&255,e[1]=_>>>8&255,e[2]=_>>>16&255,e[3]=_>>>24&255,e[4]=E>>>0&255,e[5]=E>>>8&255,e[6]=E>>>16&255,e[7]=E>>>24&255,e[8]=S>>>0&255,e[9]=S>>>8&255,e[10]=S>>>16&255,e[11]=S>>>24&255,e[12]=x>>>0&255,e[13]=x>>>8&255,e[14]=x>>>16&255,e[15]=x>>>24&255,e[16]=A>>>0&255,e[17]=A>>>8&255,e[18]=A>>>16&255,e[19]=A>>>24&255,e[20]=k>>>0&255,e[21]=k>>>8&255,e[22]=k>>>16&255,e[23]=k>>>24&255,e[24]=I>>>0&255,e[25]=I>>>8&255,e[26]=I>>>16&255,e[27]=I>>>24&255,e[28]=B>>>0&255,e[29]=B>>>8&255,e[30]=B>>>16&255,e[31]=B>>>24&255,e[32]=T>>>0&255,e[33]=T>>>8&255,e[34]=T>>>16&255,e[35]=T>>>24&255,e[36]=R>>>0&255,e[37]=R>>>8&255,e[38]=R>>>16&255,e[39]=R>>>24&255,e[40]=O>>>0&255,e[41]=O>>>8&255,e[42]=O>>>16&255,e[43]=O>>>24&255,e[44]=M>>>0&255,e[45]=M>>>8&255,e[46]=M>>>16&255,e[47]=M>>>24&255,e[48]=L>>>0&255,e[49]=L>>>8&255,e[50]=L>>>16&255,e[51]=L>>>24&255,e[52]=C>>>0&255,e[53]=C>>>8&255,e[54]=C>>>16&255,e[55]=C>>>24&255,e[56]=P>>>0&255,e[57]=P>>>8&255,e[58]=P>>>16&255,e[59]=P>>>24&255,e[60]=N>>>0&255,e[61]=N>>>8&255,e[62]=N>>>16&255,e[63]=N>>>24&255}(e,t,r,n)}function w(e,t,r,n){!function(e,t,r,n){for(var i,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,a=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,c=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,u=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,l=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,h=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,f=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,d=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,p=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,g=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,y=255&r[16]|(255&r[17])<<8|(255&r[18])<<16|(255&r[19])<<24,m=255&r[20]|(255&r[21])<<8|(255&r[22])<<16|(255&r[23])<<24,w=255&r[24]|(255&r[25])<<8|(255&r[26])<<16|(255&r[27])<<24,b=255&r[28]|(255&r[29])<<8|(255&r[30])<<16|(255&r[31])<<24,v=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,_=0;_<20;_+=2)o^=(i=(m^=(i=(d^=(i=(u^=(i=o+m|0)<<7|i>>>25)+o|0)<<9|i>>>23)+u|0)<<13|i>>>19)+d|0)<<18|i>>>14,l^=(i=(s^=(i=(w^=(i=(p^=(i=l+s|0)<<7|i>>>25)+l|0)<<9|i>>>23)+p|0)<<13|i>>>19)+w|0)<<18|i>>>14,g^=(i=(h^=(i=(a^=(i=(b^=(i=g+h|0)<<7|i>>>25)+g|0)<<9|i>>>23)+b|0)<<13|i>>>19)+a|0)<<18|i>>>14,v^=(i=(y^=(i=(f^=(i=(c^=(i=v+y|0)<<7|i>>>25)+v|0)<<9|i>>>23)+c|0)<<13|i>>>19)+f|0)<<18|i>>>14,o^=(i=(c^=(i=(a^=(i=(s^=(i=o+c|0)<<7|i>>>25)+o|0)<<9|i>>>23)+s|0)<<13|i>>>19)+a|0)<<18|i>>>14,l^=(i=(u^=(i=(f^=(i=(h^=(i=l+u|0)<<7|i>>>25)+l|0)<<9|i>>>23)+h|0)<<13|i>>>19)+f|0)<<18|i>>>14,g^=(i=(p^=(i=(d^=(i=(y^=(i=g+p|0)<<7|i>>>25)+g|0)<<9|i>>>23)+y|0)<<13|i>>>19)+d|0)<<18|i>>>14,v^=(i=(b^=(i=(w^=(i=(m^=(i=v+b|0)<<7|i>>>25)+v|0)<<9|i>>>23)+m|0)<<13|i>>>19)+w|0)<<18|i>>>14;e[0]=o>>>0&255,e[1]=o>>>8&255,e[2]=o>>>16&255,e[3]=o>>>24&255,e[4]=l>>>0&255,e[5]=l>>>8&255,e[6]=l>>>16&255,e[7]=l>>>24&255,e[8]=g>>>0&255,e[9]=g>>>8&255,e[10]=g>>>16&255,e[11]=g>>>24&255,e[12]=v>>>0&255,e[13]=v>>>8&255,e[14]=v>>>16&255,e[15]=v>>>24&255,e[16]=h>>>0&255,e[17]=h>>>8&255,e[18]=h>>>16&255,e[19]=h>>>24&255,e[20]=f>>>0&255,e[21]=f>>>8&255,e[22]=f>>>16&255,e[23]=f>>>24&255,e[24]=d>>>0&255,e[25]=d>>>8&255,e[26]=d>>>16&255,e[27]=d>>>24&255,e[28]=p>>>0&255,e[29]=p>>>8&255,e[30]=p>>>16&255,e[31]=p>>>24&255}(e,t,r,n)}var b=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function v(e,t,r,n,i,o,s){var a,c,u=new Uint8Array(16),l=new Uint8Array(64);for(c=0;c<16;c++)u[c]=0;for(c=0;c<8;c++)u[c]=o[c];for(;i>=64;){for(m(l,u,s,b),c=0;c<64;c++)e[t+c]=r[n+c]^l[c];for(a=1,c=8;c<16;c++)a=a+(255&u[c])|0,u[c]=255&a,a>>>=8;i-=64,t+=64,n+=64}if(i>0)for(m(l,u,s,b),c=0;c=64;){for(m(c,a,i,b),s=0;s<64;s++)e[t+s]=c[s];for(o=1,s=8;s<16;s++)o=o+(255&a[s])|0,a[s]=255&o,o>>>=8;r-=64,t+=64}if(r>0)for(m(c,a,i,b),s=0;s>>13|r<<3),n=255&e[4]|(255&e[5])<<8,this.r[2]=7939&(r>>>10|n<<6),i=255&e[6]|(255&e[7])<<8,this.r[3]=8191&(n>>>7|i<<9),o=255&e[8]|(255&e[9])<<8,this.r[4]=255&(i>>>4|o<<12),this.r[5]=o>>>1&8190,s=255&e[10]|(255&e[11])<<8,this.r[6]=8191&(o>>>14|s<<2),a=255&e[12]|(255&e[13])<<8,this.r[7]=8065&(s>>>11|a<<5),c=255&e[14]|(255&e[15])<<8,this.r[8]=8191&(a>>>8|c<<8),this.r[9]=c>>>5&127,this.pad[0]=255&e[16]|(255&e[17])<<8,this.pad[1]=255&e[18]|(255&e[19])<<8,this.pad[2]=255&e[20]|(255&e[21])<<8,this.pad[3]=255&e[22]|(255&e[23])<<8,this.pad[4]=255&e[24]|(255&e[25])<<8,this.pad[5]=255&e[26]|(255&e[27])<<8,this.pad[6]=255&e[28]|(255&e[29])<<8,this.pad[7]=255&e[30]|(255&e[31])<<8};function A(e,t,r,n,i,o){var s=new x(o);return s.update(r,n,i),s.finish(e,t),0}function k(e,t,r,n,i,o){var s=new Uint8Array(16);return A(s,0,r,n,i,o),g(e,t,s,0)}function I(e,t,r,n,i){var o;if(r<32)return-1;for(S(e,0,t,0,r,n,i),A(e,16,e,32,r-32,e),o=0;o<16;o++)e[o]=0;return 0}function B(e,t,r,n,i){var o,s=new Uint8Array(32);if(r<32)return-1;if(E(s,0,32,n,i),0!==k(t,16,t,32,r-32,s))return-1;for(S(e,0,t,0,r,n,i),o=0;o<32;o++)e[o]=0;return 0}function T(e,t){var r;for(r=0;r<16;r++)e[r]=0|t[r]}function R(e){var t,r,n=1;for(t=0;t<16;t++)r=e[t]+n+65535,n=Math.floor(r/65536),e[t]=r-65536*n;e[0]+=n-1+37*(n-1)}function O(e,t,r){for(var n,i=~(r-1),o=0;o<16;o++)n=i&(e[o]^t[o]),e[o]^=n,t[o]^=n}function M(e,r){var n,i,o,s=t(),a=t();for(n=0;n<16;n++)a[n]=r[n];for(R(a),R(a),R(a),i=0;i<2;i++){for(s[0]=a[0]-65517,n=1;n<15;n++)s[n]=a[n]-65535-(s[n-1]>>16&1),s[n-1]&=65535;s[15]=a[15]-32767-(s[14]>>16&1),o=s[15]>>16&1,s[14]&=65535,O(a,s,1-o)}for(n=0;n<16;n++)e[2*n]=255&a[n],e[2*n+1]=a[n]>>8}function L(e,t){var r=new Uint8Array(32),n=new Uint8Array(32);return M(r,e),M(n,t),y(r,0,n,0)}function C(e){var t=new Uint8Array(32);return M(t,e),1&t[0]}function P(e,t){var r;for(r=0;r<16;r++)e[r]=t[2*r]+(t[2*r+1]<<8);e[15]&=32767}function N(e,t,r){for(var n=0;n<16;n++)e[n]=t[n]+r[n]}function U(e,t,r){for(var n=0;n<16;n++)e[n]=t[n]-r[n]}function j(e,t,r){var n,i,o=0,s=0,a=0,c=0,u=0,l=0,h=0,f=0,d=0,p=0,g=0,y=0,m=0,w=0,b=0,v=0,_=0,E=0,S=0,x=0,A=0,k=0,I=0,B=0,T=0,R=0,O=0,M=0,L=0,C=0,P=0,N=r[0],U=r[1],j=r[2],$=r[3],z=r[4],D=r[5],H=r[6],q=r[7],F=r[8],K=r[9],W=r[10],V=r[11],Z=r[12],G=r[13],J=r[14],Y=r[15];o+=(n=t[0])*N,s+=n*U,a+=n*j,c+=n*$,u+=n*z,l+=n*D,h+=n*H,f+=n*q,d+=n*F,p+=n*K,g+=n*W,y+=n*V,m+=n*Z,w+=n*G,b+=n*J,v+=n*Y,s+=(n=t[1])*N,a+=n*U,c+=n*j,u+=n*$,l+=n*z,h+=n*D,f+=n*H,d+=n*q,p+=n*F,g+=n*K,y+=n*W,m+=n*V,w+=n*Z,b+=n*G,v+=n*J,_+=n*Y,a+=(n=t[2])*N,c+=n*U,u+=n*j,l+=n*$,h+=n*z,f+=n*D,d+=n*H,p+=n*q,g+=n*F,y+=n*K,m+=n*W,w+=n*V,b+=n*Z,v+=n*G,_+=n*J,E+=n*Y,c+=(n=t[3])*N,u+=n*U,l+=n*j,h+=n*$,f+=n*z,d+=n*D,p+=n*H,g+=n*q,y+=n*F,m+=n*K,w+=n*W,b+=n*V,v+=n*Z,_+=n*G,E+=n*J,S+=n*Y,u+=(n=t[4])*N,l+=n*U,h+=n*j,f+=n*$,d+=n*z,p+=n*D,g+=n*H,y+=n*q,m+=n*F,w+=n*K,b+=n*W,v+=n*V,_+=n*Z,E+=n*G,S+=n*J,x+=n*Y,l+=(n=t[5])*N,h+=n*U,f+=n*j,d+=n*$,p+=n*z,g+=n*D,y+=n*H,m+=n*q,w+=n*F,b+=n*K,v+=n*W,_+=n*V,E+=n*Z,S+=n*G,x+=n*J,A+=n*Y,h+=(n=t[6])*N,f+=n*U,d+=n*j,p+=n*$,g+=n*z,y+=n*D,m+=n*H,w+=n*q,b+=n*F,v+=n*K,_+=n*W,E+=n*V,S+=n*Z,x+=n*G,A+=n*J,k+=n*Y,f+=(n=t[7])*N,d+=n*U,p+=n*j,g+=n*$,y+=n*z,m+=n*D,w+=n*H,b+=n*q,v+=n*F,_+=n*K,E+=n*W,S+=n*V,x+=n*Z,A+=n*G,k+=n*J,I+=n*Y,d+=(n=t[8])*N,p+=n*U,g+=n*j,y+=n*$,m+=n*z,w+=n*D,b+=n*H,v+=n*q,_+=n*F,E+=n*K,S+=n*W,x+=n*V,A+=n*Z,k+=n*G,I+=n*J,B+=n*Y,p+=(n=t[9])*N,g+=n*U,y+=n*j,m+=n*$,w+=n*z,b+=n*D,v+=n*H,_+=n*q,E+=n*F,S+=n*K,x+=n*W,A+=n*V,k+=n*Z,I+=n*G,B+=n*J,T+=n*Y,g+=(n=t[10])*N,y+=n*U,m+=n*j,w+=n*$,b+=n*z,v+=n*D,_+=n*H,E+=n*q,S+=n*F,x+=n*K,A+=n*W,k+=n*V,I+=n*Z,B+=n*G,T+=n*J,R+=n*Y,y+=(n=t[11])*N,m+=n*U,w+=n*j,b+=n*$,v+=n*z,_+=n*D,E+=n*H,S+=n*q,x+=n*F,A+=n*K,k+=n*W,I+=n*V,B+=n*Z,T+=n*G,R+=n*J,O+=n*Y,m+=(n=t[12])*N,w+=n*U,b+=n*j,v+=n*$,_+=n*z,E+=n*D,S+=n*H,x+=n*q,A+=n*F,k+=n*K,I+=n*W,B+=n*V,T+=n*Z,R+=n*G,O+=n*J,M+=n*Y,w+=(n=t[13])*N,b+=n*U,v+=n*j,_+=n*$,E+=n*z,S+=n*D,x+=n*H,A+=n*q,k+=n*F,I+=n*K,B+=n*W,T+=n*V,R+=n*Z,O+=n*G,M+=n*J,L+=n*Y,b+=(n=t[14])*N,v+=n*U,_+=n*j,E+=n*$,S+=n*z,x+=n*D,A+=n*H,k+=n*q,I+=n*F,B+=n*K,T+=n*W,R+=n*V,O+=n*Z,M+=n*G,L+=n*J,C+=n*Y,v+=(n=t[15])*N,s+=38*(E+=n*j),a+=38*(S+=n*$),c+=38*(x+=n*z),u+=38*(A+=n*D),l+=38*(k+=n*H),h+=38*(I+=n*q),f+=38*(B+=n*F),d+=38*(T+=n*K),p+=38*(R+=n*W),g+=38*(O+=n*V),y+=38*(M+=n*Z),m+=38*(L+=n*G),w+=38*(C+=n*J),b+=38*(P+=n*Y),o=(n=(o+=38*(_+=n*U))+(i=1)+65535)-65536*(i=Math.floor(n/65536)),s=(n=s+i+65535)-65536*(i=Math.floor(n/65536)),a=(n=a+i+65535)-65536*(i=Math.floor(n/65536)),c=(n=c+i+65535)-65536*(i=Math.floor(n/65536)),u=(n=u+i+65535)-65536*(i=Math.floor(n/65536)),l=(n=l+i+65535)-65536*(i=Math.floor(n/65536)),h=(n=h+i+65535)-65536*(i=Math.floor(n/65536)),f=(n=f+i+65535)-65536*(i=Math.floor(n/65536)),d=(n=d+i+65535)-65536*(i=Math.floor(n/65536)),p=(n=p+i+65535)-65536*(i=Math.floor(n/65536)),g=(n=g+i+65535)-65536*(i=Math.floor(n/65536)),y=(n=y+i+65535)-65536*(i=Math.floor(n/65536)),m=(n=m+i+65535)-65536*(i=Math.floor(n/65536)),w=(n=w+i+65535)-65536*(i=Math.floor(n/65536)),b=(n=b+i+65535)-65536*(i=Math.floor(n/65536)),v=(n=v+i+65535)-65536*(i=Math.floor(n/65536)),o=(n=(o+=i-1+37*(i-1))+(i=1)+65535)-65536*(i=Math.floor(n/65536)),s=(n=s+i+65535)-65536*(i=Math.floor(n/65536)),a=(n=a+i+65535)-65536*(i=Math.floor(n/65536)),c=(n=c+i+65535)-65536*(i=Math.floor(n/65536)),u=(n=u+i+65535)-65536*(i=Math.floor(n/65536)),l=(n=l+i+65535)-65536*(i=Math.floor(n/65536)),h=(n=h+i+65535)-65536*(i=Math.floor(n/65536)),f=(n=f+i+65535)-65536*(i=Math.floor(n/65536)),d=(n=d+i+65535)-65536*(i=Math.floor(n/65536)),p=(n=p+i+65535)-65536*(i=Math.floor(n/65536)),g=(n=g+i+65535)-65536*(i=Math.floor(n/65536)),y=(n=y+i+65535)-65536*(i=Math.floor(n/65536)),m=(n=m+i+65535)-65536*(i=Math.floor(n/65536)),w=(n=w+i+65535)-65536*(i=Math.floor(n/65536)),b=(n=b+i+65535)-65536*(i=Math.floor(n/65536)),v=(n=v+i+65535)-65536*(i=Math.floor(n/65536)),o+=i-1+37*(i-1),e[0]=o,e[1]=s,e[2]=a,e[3]=c,e[4]=u,e[5]=l,e[6]=h,e[7]=f,e[8]=d,e[9]=p,e[10]=g,e[11]=y,e[12]=m,e[13]=w,e[14]=b,e[15]=v}function $(e,t){j(e,t,t)}function z(e,r){var n,i=t();for(n=0;n<16;n++)i[n]=r[n];for(n=253;n>=0;n--)$(i,i),2!==n&&4!==n&&j(i,i,r);for(n=0;n<16;n++)e[n]=i[n]}function D(e,r){var n,i=t();for(n=0;n<16;n++)i[n]=r[n];for(n=250;n>=0;n--)$(i,i),1!==n&&j(i,i,r);for(n=0;n<16;n++)e[n]=i[n]}function H(e,r,n){var i,o,s=new Uint8Array(32),c=new Float64Array(80),u=t(),l=t(),h=t(),f=t(),d=t(),p=t();for(o=0;o<31;o++)s[o]=r[o];for(s[31]=127&r[31]|64,s[0]&=248,P(c,n),o=0;o<16;o++)l[o]=c[o],f[o]=u[o]=h[o]=0;for(u[0]=f[0]=1,o=254;o>=0;--o)O(u,l,i=s[o>>>3]>>>(7&o)&1),O(h,f,i),N(d,u,h),U(u,u,h),N(h,l,f),U(l,l,f),$(f,d),$(p,u),j(u,h,u),j(h,l,d),N(d,u,h),U(u,u,h),$(l,u),U(h,f,p),j(u,h,a),N(u,u,f),j(h,h,u),j(u,f,p),j(f,l,c),$(l,d),O(u,l,i),O(h,f,i);for(o=0;o<16;o++)c[o+16]=u[o],c[o+32]=h[o],c[o+48]=l[o],c[o+64]=f[o];var g=c.subarray(32),y=c.subarray(16);return z(g,g),j(y,y,g),M(e,y),0}function q(e,t){return H(e,t,i)}function F(e,t){return r(t,32),q(e,t)}function K(e,t,r){var i=new Uint8Array(32);return H(i,r,t),w(e,n,i,b)}x.prototype.blocks=function(e,t,r){for(var n,i,o,s,a,c,u,l,h,f,d,p,g,y,m,w,b,v,_,E=this.fin?0:2048,S=this.h[0],x=this.h[1],A=this.h[2],k=this.h[3],I=this.h[4],B=this.h[5],T=this.h[6],R=this.h[7],O=this.h[8],M=this.h[9],L=this.r[0],C=this.r[1],P=this.r[2],N=this.r[3],U=this.r[4],j=this.r[5],$=this.r[6],z=this.r[7],D=this.r[8],H=this.r[9];r>=16;)f=h=0,f+=(S+=8191&(n=255&e[t+0]|(255&e[t+1])<<8))*L,f+=(x+=8191&(n>>>13|(i=255&e[t+2]|(255&e[t+3])<<8)<<3))*(5*H),f+=(A+=8191&(i>>>10|(o=255&e[t+4]|(255&e[t+5])<<8)<<6))*(5*D),f+=(k+=8191&(o>>>7|(s=255&e[t+6]|(255&e[t+7])<<8)<<9))*(5*z),h=(f+=(I+=8191&(s>>>4|(a=255&e[t+8]|(255&e[t+9])<<8)<<12))*(5*$))>>>13,f&=8191,f+=(B+=a>>>1&8191)*(5*j),f+=(T+=8191&(a>>>14|(c=255&e[t+10]|(255&e[t+11])<<8)<<2))*(5*U),f+=(R+=8191&(c>>>11|(u=255&e[t+12]|(255&e[t+13])<<8)<<5))*(5*N),f+=(O+=8191&(u>>>8|(l=255&e[t+14]|(255&e[t+15])<<8)<<8))*(5*P),d=h+=(f+=(M+=l>>>5|E)*(5*C))>>>13,d+=S*C,d+=x*L,d+=A*(5*H),d+=k*(5*D),h=(d+=I*(5*z))>>>13,d&=8191,d+=B*(5*$),d+=T*(5*j),d+=R*(5*U),d+=O*(5*N),h+=(d+=M*(5*P))>>>13,d&=8191,p=h,p+=S*P,p+=x*C,p+=A*L,p+=k*(5*H),h=(p+=I*(5*D))>>>13,p&=8191,p+=B*(5*z),p+=T*(5*$),p+=R*(5*j),p+=O*(5*U),g=h+=(p+=M*(5*N))>>>13,g+=S*N,g+=x*P,g+=A*C,g+=k*L,h=(g+=I*(5*H))>>>13,g&=8191,g+=B*(5*D),g+=T*(5*z),g+=R*(5*$),g+=O*(5*j),y=h+=(g+=M*(5*U))>>>13,y+=S*U,y+=x*N,y+=A*P,y+=k*C,h=(y+=I*L)>>>13,y&=8191,y+=B*(5*H),y+=T*(5*D),y+=R*(5*z),y+=O*(5*$),m=h+=(y+=M*(5*j))>>>13,m+=S*j,m+=x*U,m+=A*N,m+=k*P,h=(m+=I*C)>>>13,m&=8191,m+=B*L,m+=T*(5*H),m+=R*(5*D),m+=O*(5*z),w=h+=(m+=M*(5*$))>>>13,w+=S*$,w+=x*j,w+=A*U,w+=k*N,h=(w+=I*P)>>>13,w&=8191,w+=B*C,w+=T*L,w+=R*(5*H),w+=O*(5*D),b=h+=(w+=M*(5*z))>>>13,b+=S*z,b+=x*$,b+=A*j,b+=k*U,h=(b+=I*N)>>>13,b&=8191,b+=B*P,b+=T*C,b+=R*L,b+=O*(5*H),v=h+=(b+=M*(5*D))>>>13,v+=S*D,v+=x*z,v+=A*$,v+=k*j,h=(v+=I*U)>>>13,v&=8191,v+=B*N,v+=T*P,v+=R*C,v+=O*L,_=h+=(v+=M*(5*H))>>>13,_+=S*H,_+=x*D,_+=A*z,_+=k*$,h=(_+=I*j)>>>13,_&=8191,_+=B*U,_+=T*N,_+=R*P,_+=O*C,S=f=8191&(h=(h=((h+=(_+=M*L)>>>13)<<2)+h|0)+(f&=8191)|0),x=d+=h>>>=13,A=p&=8191,k=g&=8191,I=y&=8191,B=m&=8191,T=w&=8191,R=b&=8191,O=v&=8191,M=_&=8191,t+=16,r-=16;this.h[0]=S,this.h[1]=x,this.h[2]=A,this.h[3]=k,this.h[4]=I,this.h[5]=B,this.h[6]=T,this.h[7]=R,this.h[8]=O,this.h[9]=M},x.prototype.finish=function(e,t){var r,n,i,o,s=new Uint16Array(10);if(this.leftover){for(o=this.leftover,this.buffer[o++]=1;o<16;o++)this.buffer[o]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(r=this.h[1]>>>13,this.h[1]&=8191,o=2;o<10;o++)this.h[o]+=r,r=this.h[o]>>>13,this.h[o]&=8191;for(this.h[0]+=5*r,r=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=r,r=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=r,s[0]=this.h[0]+5,r=s[0]>>>13,s[0]&=8191,o=1;o<10;o++)s[o]=this.h[o]+r,r=s[o]>>>13,s[o]&=8191;for(s[9]-=8192,n=(1^r)-1,o=0;o<10;o++)s[o]&=n;for(n=~n,o=0;o<10;o++)this.h[o]=this.h[o]&n|s[o];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),i=this.h[0]+this.pad[0],this.h[0]=65535&i,o=1;o<8;o++)i=(this.h[o]+this.pad[o]|0)+(i>>>16)|0,this.h[o]=65535&i;e[t+0]=this.h[0]>>>0&255,e[t+1]=this.h[0]>>>8&255,e[t+2]=this.h[1]>>>0&255,e[t+3]=this.h[1]>>>8&255,e[t+4]=this.h[2]>>>0&255,e[t+5]=this.h[2]>>>8&255,e[t+6]=this.h[3]>>>0&255,e[t+7]=this.h[3]>>>8&255,e[t+8]=this.h[4]>>>0&255,e[t+9]=this.h[4]>>>8&255,e[t+10]=this.h[5]>>>0&255,e[t+11]=this.h[5]>>>8&255,e[t+12]=this.h[6]>>>0&255,e[t+13]=this.h[6]>>>8&255,e[t+14]=this.h[7]>>>0&255,e[t+15]=this.h[7]>>>8&255},x.prototype.update=function(e,t,r){var n,i;if(this.leftover){for((i=16-this.leftover)>r&&(i=r),n=0;n=16&&(i=r-r%16,this.blocks(e,t,i),t+=i,r-=i),r){for(n=0;n=128;){for(E=0;E<16;E++)S=8*E+G,R[E]=r[S+0]<<24|r[S+1]<<16|r[S+2]<<8|r[S+3],O[E]=r[S+4]<<24|r[S+5]<<16|r[S+6]<<8|r[S+7];for(E=0;E<80;E++)if(i=M,o=L,s=C,a=P,c=N,u=U,l=j,$,f=z,d=D,p=H,g=q,y=F,m=K,w=W,V,k=65535&(A=V),I=A>>>16,B=65535&(x=$),T=x>>>16,k+=65535&(A=(F>>>14|N<<18)^(F>>>18|N<<14)^(N>>>9|F<<23)),I+=A>>>16,B+=65535&(x=(N>>>14|F<<18)^(N>>>18|F<<14)^(F>>>9|N<<23)),T+=x>>>16,k+=65535&(A=F&K^~F&W),I+=A>>>16,B+=65535&(x=N&U^~N&j),T+=x>>>16,k+=65535&(A=Z[2*E+1]),I+=A>>>16,B+=65535&(x=Z[2*E]),T+=x>>>16,x=R[E%16],I+=(A=O[E%16])>>>16,B+=65535&x,T+=x>>>16,B+=(I+=(k+=65535&A)>>>16)>>>16,k=65535&(A=_=65535&k|I<<16),I=A>>>16,B=65535&(x=v=65535&B|(T+=B>>>16)<<16),T=x>>>16,k+=65535&(A=(z>>>28|M<<4)^(M>>>2|z<<30)^(M>>>7|z<<25)),I+=A>>>16,B+=65535&(x=(M>>>28|z<<4)^(z>>>2|M<<30)^(z>>>7|M<<25)),T+=x>>>16,I+=(A=z&D^z&H^D&H)>>>16,B+=65535&(x=M&L^M&C^L&C),T+=x>>>16,h=65535&(B+=(I+=(k+=65535&A)>>>16)>>>16)|(T+=B>>>16)<<16,b=65535&k|I<<16,k=65535&(A=g),I=A>>>16,B=65535&(x=a),T=x>>>16,I+=(A=_)>>>16,B+=65535&(x=v),T+=x>>>16,L=i,C=o,P=s,N=a=65535&(B+=(I+=(k+=65535&A)>>>16)>>>16)|(T+=B>>>16)<<16,U=c,j=u,$=l,M=h,D=f,H=d,q=p,F=g=65535&k|I<<16,K=y,W=m,V=w,z=b,E%16==15)for(S=0;S<16;S++)x=R[S],k=65535&(A=O[S]),I=A>>>16,B=65535&x,T=x>>>16,x=R[(S+9)%16],k+=65535&(A=O[(S+9)%16]),I+=A>>>16,B+=65535&x,T+=x>>>16,v=R[(S+1)%16],k+=65535&(A=((_=O[(S+1)%16])>>>1|v<<31)^(_>>>8|v<<24)^(_>>>7|v<<25)),I+=A>>>16,B+=65535&(x=(v>>>1|_<<31)^(v>>>8|_<<24)^v>>>7),T+=x>>>16,v=R[(S+14)%16],I+=(A=((_=O[(S+14)%16])>>>19|v<<13)^(v>>>29|_<<3)^(_>>>6|v<<26))>>>16,B+=65535&(x=(v>>>19|_<<13)^(_>>>29|v<<3)^v>>>6),T+=x>>>16,T+=(B+=(I+=(k+=65535&A)>>>16)>>>16)>>>16,R[S]=65535&B|T<<16,O[S]=65535&k|I<<16;k=65535&(A=z),I=A>>>16,B=65535&(x=M),T=x>>>16,x=e[0],I+=(A=t[0])>>>16,B+=65535&x,T+=x>>>16,T+=(B+=(I+=(k+=65535&A)>>>16)>>>16)>>>16,e[0]=M=65535&B|T<<16,t[0]=z=65535&k|I<<16,k=65535&(A=D),I=A>>>16,B=65535&(x=L),T=x>>>16,x=e[1],I+=(A=t[1])>>>16,B+=65535&x,T+=x>>>16,T+=(B+=(I+=(k+=65535&A)>>>16)>>>16)>>>16,e[1]=L=65535&B|T<<16,t[1]=D=65535&k|I<<16,k=65535&(A=H),I=A>>>16,B=65535&(x=C),T=x>>>16,x=e[2],I+=(A=t[2])>>>16,B+=65535&x,T+=x>>>16,T+=(B+=(I+=(k+=65535&A)>>>16)>>>16)>>>16,e[2]=C=65535&B|T<<16,t[2]=H=65535&k|I<<16,k=65535&(A=q),I=A>>>16,B=65535&(x=P),T=x>>>16,x=e[3],I+=(A=t[3])>>>16,B+=65535&x,T+=x>>>16,T+=(B+=(I+=(k+=65535&A)>>>16)>>>16)>>>16,e[3]=P=65535&B|T<<16,t[3]=q=65535&k|I<<16,k=65535&(A=F),I=A>>>16,B=65535&(x=N),T=x>>>16,x=e[4],I+=(A=t[4])>>>16,B+=65535&x,T+=x>>>16,T+=(B+=(I+=(k+=65535&A)>>>16)>>>16)>>>16,e[4]=N=65535&B|T<<16,t[4]=F=65535&k|I<<16,k=65535&(A=K),I=A>>>16,B=65535&(x=U),T=x>>>16,x=e[5],I+=(A=t[5])>>>16,B+=65535&x,T+=x>>>16,T+=(B+=(I+=(k+=65535&A)>>>16)>>>16)>>>16,e[5]=U=65535&B|T<<16,t[5]=K=65535&k|I<<16,k=65535&(A=W),I=A>>>16,B=65535&(x=j),T=x>>>16,x=e[6],I+=(A=t[6])>>>16,B+=65535&x,T+=x>>>16,T+=(B+=(I+=(k+=65535&A)>>>16)>>>16)>>>16,e[6]=j=65535&B|T<<16,t[6]=W=65535&k|I<<16,k=65535&(A=V),I=A>>>16,B=65535&(x=$),T=x>>>16,x=e[7],I+=(A=t[7])>>>16,B+=65535&x,T+=x>>>16,T+=(B+=(I+=(k+=65535&A)>>>16)>>>16)>>>16,e[7]=$=65535&B|T<<16,t[7]=V=65535&k|I<<16,G+=128,n-=128}return n}function J(e,t,r){var n,i=new Int32Array(8),o=new Int32Array(8),s=new Uint8Array(256),a=r;for(i[0]=1779033703,i[1]=3144134277,i[2]=1013904242,i[3]=2773480762,i[4]=1359893119,i[5]=2600822924,i[6]=528734635,i[7]=1541459225,o[0]=4089235720,o[1]=2227873595,o[2]=4271175723,o[3]=1595750129,o[4]=2917565137,o[5]=725511199,o[6]=4215389547,o[7]=327033209,G(i,o,t,r),r%=128,n=0;n=0;--i)X(e,t,n=r[i/8|0]>>(7&i)&1),Y(t,e),Y(e,e),X(e,t,n)}function te(e,r){var n=[t(),t(),t(),t()];T(n[0],l),T(n[1],h),T(n[2],s),j(n[3],l,h),ee(e,n,r)}function re(e,n,i){var o,s=new Uint8Array(64),a=[t(),t(),t(),t()];for(i||r(n,32),J(s,n,32),s[0]&=248,s[31]&=127,s[31]|=64,te(a,s),Q(e,a),o=0;o<32;o++)n[o+32]=e[o];return 0}var ne=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function ie(e,t){var r,n,i,o;for(n=63;n>=32;--n){for(r=0,i=n-32,o=n-12;i>4)*ne[i],r=t[i]>>8,t[i]&=255;for(i=0;i<32;i++)t[i]-=r*ne[i];for(n=0;n<32;n++)t[n+1]+=t[n]>>8,e[n]=255&t[n]}function oe(e){var t,r=new Float64Array(64);for(t=0;t<64;t++)r[t]=e[t];for(t=0;t<64;t++)e[t]=0;ie(e,r)}function se(e,r,n,i){var o,s,a=new Uint8Array(64),c=new Uint8Array(64),u=new Uint8Array(64),l=new Float64Array(64),h=[t(),t(),t(),t()];J(a,i,32),a[0]&=248,a[31]&=127,a[31]|=64;var f=n+64;for(o=0;o>7&&U(e[0],o,e[0]),j(e[3],e[0],e[1]),0)}(d,i))return-1;for(a=0;a=0},e.sign.keyPair=function(){var e=new Uint8Array(le),t=new Uint8Array(he);return re(e,t),{publicKey:e,secretKey:t}},e.sign.keyPair.fromSecretKey=function(e){if(de(e),e.length!==he)throw new Error("bad secret key size");for(var t=new Uint8Array(le),r=0;r0&&(o=2048-i-16),n.padding="0".repeat(o),sB({publicKey:e,data:JSON.stringify(n),version:r})},YI.decrypt=aB,YI.decryptSafely=function({encryptedData:e,privateKey:t}){if((0,oB.isNullish)(e))throw new Error("Missing encryptedData parameter");if((0,oB.isNullish)(t))throw new Error("Missing privateKey parameter");return JSON.parse(aB({encryptedData:e,privateKey:t})).data},YI.getEncryptionPublicKey=function(e){const t=C.from(e,"hex"),r=iB.box.keyPair.fromSecretKey(t).publicKey;return nB.base64.encode(r)},function(e){var t=Tr&&Tr.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=Tr&&Tr.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.normalize=e.concatSig=void 0,r(gl,e),r(Wk,e),r(YI,e);var n=Yb;Object.defineProperty(e,"concatSig",{enumerable:!0,get:function(){return n.concatSig}}),Object.defineProperty(e,"normalize",{enumerable:!0,get:function(){return n.normalize}})}(pl);class cB extends Error{constructor(e,t){super(),this.code=e,this.message=t}toString(){return`${this.message} (${this.code})`}}var uB,lB=(e,t,r)=>(((e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)})(e,t,"read from private field"),r?r.call(e):t.get(e));const hB=class{constructor(e){((e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)})(this,uB,["eth_newFilter","eth_newBlockFilter","eth_newPendingTransactionFilter","eth_uninstallFilter","eth_subscribe"]),this.provider=e}static isUTF8(e){try{return new TextDecoder("utf8",{fatal:!0}).decode(e),!0}catch{return!1}}static bufferToHex(e){return"0x"+C.from(e).toString("hex")}static messageToBuffer(e){let t=C.from([]);try{t="string"==typeof e?C.from(e.replace("0x",""),"hex"):C.from(e)}catch(e){console.log(`messageToBuffer error: ${e}`)}return t}async request(e){if(lB(this,uB).includes(e.method))return Promise.reject(new cB(4200,`EthereumProvider does not support calling ${e.method}`));switch(e.method){case"wallet_requestPermissions":return this.provider.internalRequest({method:"wallet_requestPermissions",params:e.params});case"eth_requestAccounts":return this.provider.internalRequest({method:"requestAccounts",params:{}});case"eth_sign":return this.ethSign(e.params);case"personal_sign":return this.personalSign(e.params);case"personal_ecRecover":return this.personalECRecover(e.params);case"eth_signTypedData_v3":return this.ethSignTypedData(e.params,pl.SignTypedDataVersion.V3);case"eth_signTypedData_v4":return this.ethSignTypedData(e.params,pl.SignTypedDataVersion.V4);case"eth_signTypedData":return this.ethSignTypedData(e.params,pl.SignTypedDataVersion.V1);case"eth_sendTransaction":return this.provider.internalRequest({method:"signTransaction",params:e.params[0]});case"wallet_watchAsset":{const{options:t,type:r}=e.params,{address:n,symbol:i,decimals:o}=t;return this.provider.internalRequest({method:"watchAsset",params:{type:r,contract:n,symbol:i,decimals:o||0}})}case"wallet_addEthereumChain":return this.provider.internalRequest({method:"addEthereumChain",params:e.params[0]});case"wallet_switchEthereumChain":return this.provider.internalRequest({method:"switchEthereumChain",params:e.params[0]});default:return(await this.provider.getRPC().call({method:e.method,jsonrpc:"2.0",params:e.params})).result}}personalECRecover(e){return this.provider.internalRequest({method:"ecRecover",params:{signature:e[1],message:e[0]}})}async personalSign(e){const[t]=await this.provider.request({method:"eth_accounts"});if(!t)throw new Error("Unable to execute personal_sign");let[r,n]=e;"string"==typeof r&&t.toLowerCase()===r.toLowerCase()&&(r=e[1],n=e[0]);const i=hB.messageToBuffer(r);return this.provider.internalRequest({method:"signPersonalMessage",params:{data:0===i.length?hB.bufferToHex(r):r,address:n}})}ethSign(e){if(!e)throw new Error("Missing params");const[t,r]=e,n=hB.messageToBuffer(r),i=hB.bufferToHex(n);return this.provider.internalRequest({method:hB.isUTF8(n)?"signPersonalMessage":"signMessage",params:{data:i,address:t,isEthSign:!0}})}async ethSignTypedData(e,t){const[r]=await this.provider.request({method:"eth_accounts"});if(!r)throw new Error("Unable to execute ethSignTypedData, address is not present");let[n,i]=e;"string"==typeof n&&r.toLowerCase()===n.toLowerCase()&&(n=e[1],i=e[0]);const o="string"==typeof n?JSON.parse(n):n,{chainId:s}=o.domain||{};if(typeof s<"u"&&Number(s)!==Number(this.provider.getChainId()))throw new Error("Provided chainId does not match the currently active chain");const a=t!==pl.SignTypedDataVersion.V1?pl.TypedDataUtils.eip712Hash(o,t):"";return this.provider.internalRequest({method:"signTypedMessage",params:{data:"0x"+a.toString("hex"),raw:"string"==typeof n?n:JSON.stringify(n),address:i,version:t}})}};let fB=hB;uB=new WeakMap;var dB,pB=Object.defineProperty,gB=Object.getOwnPropertySymbols,yB=Object.prototype.hasOwnProperty,mB=Object.prototype.propertyIsEnumerable,wB=(e,t,r)=>t in e?pB(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,bB=(e,t)=>{for(var r in t||(t={}))yB.call(t,r)&&wB(e,r,t[r]);if(gB)for(var r of gB(t))mB.call(t,r)&&wB(e,r,t[r]);return e},vB=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};class _B{constructor(e){((e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)})(this,dB,void 0),((e,t,r,n)=>{vB(e,t,"write to private field"),n?n.call(e,r):t.set(e,r)})(this,dB,e)}async getBlockNumber(){return(await this.call({jsonrpc:"2.0",method:"eth_blockNumber",params:[]})).result}async getBlockByNumber(e){return(await this.call({jsonrpc:"2.0",method:"eth_getBlockByNumber",params:[e,!1]})).result}getFilterLogs(e){return this.call({jsonrpc:"2.0",method:"eth_getLogs",params:[e]})}async call(e){const t=await(await fetch(((e,t,r)=>(vB(e,t,"read from private field"),r?r.call(e):t.get(e)))(this,dB),{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(bB({id:(new Date).getTime()+Math.floor(1e3*Math.random())},e))})).json();if(!t.result&&t.error)throw new Error(t.error.message||"rpc error");return t}}dB=new WeakMap;var EB,SB,xB,AB,kB,IB,BB=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},TB=(e,t,r)=>(BB(e,t,"read from private field"),r?r.call(e):t.get(e)),RB=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},OB=(e,t,r,n)=>(BB(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);const MB=class extends ze{constructor(e){super(),RB(this,EB,void 0),RB(this,SB,void 0),RB(this,xB,!1),RB(this,AB,!1),RB(this,kB,void 0),RB(this,IB,void 0),this.isTrust=!0,this.isTrustWallet=!0,this.request=this.request.bind(this),e&&(e.chainId&&OB(this,EB,e.chainId),(e.rpc||e.rpcUrl)&&OB(this,SB,e.rpc||e.rpcUrl),typeof e.overwriteMetamask<"u"&&OB(this,AB,e.overwriteMetamask),typeof e.disableMobileAdapter<"u"&&OB(this,xB,e.disableMobileAdapter),typeof e.isTrust<"u"&&(this.isTrust=e.isTrust,this.isTrustWallet=e.isTrust),OB(this,IB,new _B(TB(this,SB)))),TB(this,xB)||(this.mobileAdapter=new fB(this)),super.on("onResponseReady",this.onResponseReady.bind(this)),this.connect()}connect(){this.emit("connect",{chainId:TB(this,EB)})}enable(){return this.request({method:"eth_requestAccounts"})}sendAsync(e,t){Array.isArray(e)?Promise.all(e.map((e=>this.request(e)))).then((e=>t(null,e))).catch((e=>t(e,null))):this.request(e).then((e=>t(null,e))).catch((e=>t(e,null)))}_send(e){const t={jsonrpc:"2.0",result:null};switch(e.method){case"eth_accounts":case"eth_coinbase":case"net_version":case"eth_chainId":t.result=this.handleStaticRequests({method:"eth_accounts"});break;default:throw new cB(4200,`Trust does not support calling ${e.method} synchronously without a callback. Please provide a callback parameter to call ${e.method} asynchronously.`)}return t}send(e,t){if("string"==typeof e&&(!t||Array.isArray(t))){const r=this;return new Promise(((n,i)=>{try{const o=r.request({method:e,params:t});o instanceof Promise?o.then(n).catch(i):n(o)}catch(e){i(e)}}))}return e&&"object"==typeof e&&"function"==typeof t?this.request(e).then(t):this._send(e)}internalRequest(e){return super.request(e)}request(e){if(this.mobileAdapter){const t=this.handleStaticRequests(e,(()=>this.mobileAdapter.request(e)));return t instanceof Promise?t:Promise.resolve(t)}return this.handleStaticRequests(e,(()=>this.internalRequest(e)))}handleStaticRequests(e,t){switch(e.method){case"net_version":return TB(this,EB)?parseInt(TB(this,EB)):void 0;case"eth_chainId":return TB(this,EB);case"eth_accounts":case"eth_coinbase":return TB(this,kB)?[TB(this,kB)]:[]}if(t)return t()}onResponseReady(e,t){var r,n,i,o;if(t)switch(e.method){case"eth_requestAccounts":case"requestAccounts":OB(this,kB,t[0]);break;case"wallet_requestPermissions":OB(this,kB,null==(o=null==(i=null==(n=null==(r=t[0])?void 0:r.caveats)?void 0:n[0])?void 0:i.value)?void 0:o[0])}}getNetwork(){return MB.NETWORK}get connected(){return!0}get isMetaMask(){return TB(this,AB)}getChainId(){return TB(this,EB)}getNetworkVersion(){return this.handleStaticRequests({method:"net_version "})}setChainId(e){OB(this,EB,e)}setRPCUrl(e){OB(this,SB,e),OB(this,IB,new _B(TB(this,SB)))}getRPC(){return TB(this,IB)}setOverwriteMetamask(e){OB(this,AB,e)}getAddress(){return TB(this,kB)}setAddress(e){OB(this,kB,e)}setRPC(e){OB(this,IB,e)}};let LB=MB;EB=new WeakMap,SB=new WeakMap,xB=new WeakMap,AB=new WeakMap,kB=new WeakMap,IB=new WeakMap,LB.NETWORK="ethereum";class CB{constructor(e){this.provider=e}async request(e,t){if("getKey"===e.method){const t=await this.provider.internalRequest({method:"requestAccounts",params:e.params}),r=JSON.parse(t);return{algo:"secp256k1",address:r.address,bech32Address:r.address,pubKey:C.from(r.pubKey,"hex")}}const r={signAmino:"signTransaction",signDirect:"signTransaction",signArbitrary:"signMessage",sendTx:"sendTransaction"};return r[e.method]?this.provider.internalRequest({method:r[e.method],params:e.params}):t()}}var PB,NB=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},UB=(e,t,r)=>(NB(e,t,"read from private field"),r?r.call(e):t.get(e));const jB=class extends ze{constructor(e){super(),((e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)})(this,PB,!1),this.isKeplr=!0,this.isTrust=!0,this.isTrustWallet=!0,e&&(typeof e.disableMobileAdapter<"u"&&((e,t,r,n)=>{NB(e,t,"write to private field"),n?n.call(e,r):t.set(e,r)})(this,PB,e.disableMobileAdapter),typeof e.isKeplr<"u"&&(this.isKeplr=e.isKeplr),typeof e.isTrust<"u"&&(this.isTrust=e.isTrust,this.isTrustWallet=e.isTrust)),UB(this,PB)||(this.mobileAdapter=new CB(this))}static bufferToHex(e){return"0x"+C.from(e).toString("hex")}getNetwork(){return jB.NETWORK}isMobileAdapterEnabled(){return!UB(this,PB)}enable(e){return this.request({method:"enable",params:{chainIds:e}})}internalRequest(e){return super.request(e)}request(e){const t=()=>this.internalRequest(e);return this.mobileAdapter?this.mobileAdapter.request(e,t):t()}getKey(e){return this.request({method:"getKey",params:{chainId:e}})}async sendTx(e,t,r){const n=C.from(t).toString("base64"),i=await this.request({method:"sendTx",params:{raw:n,chainId:e,mode:r}});return C.from(i,"hex")}async signArbitrary(e,t,r){const n=C.from(r),i=jB.bufferToHex(n);return await this.request({method:"signArbitrary",params:{chainId:e,data:i,signerAddress:t}})}async signAmino(e,t,r){const n=await this.request({method:"signAmino",params:{chainId:e,sign_doc:r}}),{signed:i,signature:o}=JSON.parse(n);return{signed:i,signature:o}}async signDirect(e,t,r){const n={bodyBytes:jB.bufferToHex(r.bodyBytes),authInfoBytes:jB.bufferToHex(r.authInfoBytes)},i=await this.request({method:"signDirect",params:{signerAddress:t,chainId:e,sign_doc:n}}),{signature:o}=JSON.parse(i);return{signed:r,signature:o}}experimentalSuggestChain(){}getOfflineSignerDirect(e){return{getAccounts:async()=>[await this.getKey(e)],signDirect:async(t,r)=>{if(e!==r.chainId)throw new Error("Unmatched chain id with the offline signer");if((await this.getKey(r.chainId)).address!==t)throw new Error("Unknown signer address");return await this.signDirect(e,t,r)}}}getOfflineSigner(e){return this.getOfflineSignerAmino(e)}getOfflineSignerAuto(e){return this.getOfflineSignerAmino(e)}getOfflineSignerAmino(e){return{getAccounts:async()=>{const t=await this.getKey(e);return[{address:t.bech32Address,algo:"secp256k1",pubkey:t.pubKey}]},sign:(t,r)=>this.signAmino(e,t,r),signAmino:(t,r)=>this.signAmino(e,t,r)}}};let $B=jB;PB=new WeakMap,$B.NETWORK="cosmos";var zB,DB={exports:{}},HB="object"==typeof Reflect?Reflect:null,qB=HB&&"function"==typeof HB.apply?HB.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};zB=HB&&"function"==typeof HB.ownKeys?HB.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var FB=Number.isNaN||function(e){return e!=e};function KB(){KB.init.call(this)}DB.exports=KB,DB.exports.once=function(e,t){return new Promise((function(r,n){function i(r){e.removeListener(t,o),n(r)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",i),r([].slice.call(arguments))}tT(e,t,o,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&tT(e,"error",t,r)}(e,i,{once:!0})}))},KB.EventEmitter=KB,KB.prototype._events=void 0,KB.prototype._eventsCount=0,KB.prototype._maxListeners=void 0;var WB=10;function VB(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function ZB(e){return void 0===e._maxListeners?KB.defaultMaxListeners:e._maxListeners}function GB(e,t,r,n){var i,o,s;if(VB(r),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]),void 0===s)s=o[t]=r,++e._eventsCount;else if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(i=ZB(e))>0&&s.length>i&&!s.warned){s.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=e,a.type=t,a.count=s.length,function(e){console&&console.warn&&console.warn(e)}(a)}return e}function JB(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function YB(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=JB.bind(n);return i.listener=r,n.wrapFn=i,i}function XB(e,t,r){var n=e._events;if(void 0===n)return[];var i=n[t];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(e){for(var t=new Array(e.length),r=0;r0&&(o=t[0]),o instanceof Error)throw o;var s=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw s.context=o,s}var a=i[e];if(void 0===a)return!1;if("function"==typeof a)qB(a,this,t);else{var c=a.length,u=eT(a,c);for(r=0;r=0;o--)if(r[o]===t||r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1=0;n--)this.removeListener(e,t[n]);return this},KB.prototype.listeners=function(e){return XB(this,e,!0)},KB.prototype.rawListeners=function(e){return XB(this,e,!1)},KB.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):QB.call(e,t)},KB.prototype.listenerCount=QB,KB.prototype.eventNames=function(){return this._eventsCount>0?zB(this._events):[]};const rT="CALLBACK";class nT extends DB.exports.EventEmitter{setAdapter(e){return this.adapter=e,this}async request(e){try{if(!this.adapter)throw new Error("No adapter set, maybe you forgot to register the provider?");const t=await this.adapter.request(e,this.getNetwork());return this.emit("onResponseReady",e,t),t}catch(e){throw e}}sendResponse(e,t){if(!this.adapter)throw new Error("Adapter not found");if(this.adapter.getStrategy()!==rT)throw new Error("Trying to send callback request on promisified adapter");this.adapter.sendResponse(e,t)}sendError(e,t){if(!this.adapter)throw new Error("Adapter not found");if(this.adapter.getStrategy()!==rT)throw new Error("Trying to send callback request on promisified adapter");this.adapter.sendError(e,t)}}const iT=class extends nT{constructor(e){super(),this._isConnected=!1,this.chainId=null,this.address=null,e&&e.network&&(this._network=e.network,e.chainId&&(this.chainId=e.chainId))}static bufferToHex(e){return"0x"+C.from(e).toString("hex")}static messageToBuffer(e){let t=C.from([]);try{t="string"==typeof e?C.from(e.replace("0x",""),"hex"):C.from(e)}catch(e){console.log(`messageToBuffer error: ${e}`)}return t}setConfig(e){this._network=e.network,this.address=e.address,this.chainId=e.chainId}async connect(){const e=await this.account();return this._isConnected=!0,this.emit("connect"),e}disconnect(){this._isConnected=!1,this.emit("disconnect")}isConnected(){return this._isConnected}async account(){const e=await this.request({method:"requestAccounts",params:{}});return JSON.parse(e)}network(){return this._network}getNetwork(){return iT.NETWORK}async signMessage(e){const t="APTOS",r=(await this.account()).address;let n=t;const i=window.location.protocol+"//"+window.location.hostname;e.address&&(n+="\naddress: "+r),e.application&&(n+="\napplication: "+i),e.chainId&&(n+="\nchainId: "+this.chainId),n+="\nmessage: "+e.message,n+="\nnonce: "+e.nonce;const o=C.from(n),s=iT.bufferToHex(o);return this.request({method:"signMessage",params:{data:s}}).then((o=>({address:r,application:i,chainId:this.chainId,fullMessage:n,message:e.message,nonce:e.nonce,prefix:t,signature:o})))}async signAndSubmitTransaction(e){const t=await this.signTransaction(e),r=await this.request({method:"sendTransaction",params:{tx:t}});return{hash:iT.messageToBuffer(r).toString()}}async signTransaction(e){const t=await this.request({method:"signTransaction",params:{data:e}});return JSON.parse(iT.messageToBuffer(t).toString())}};let oT=iT;oT.NETWORK="aptos";var sT=Object.defineProperty,aT=Object.defineProperties,cT=Object.getOwnPropertyDescriptors,uT=Object.getOwnPropertySymbols,lT=Object.prototype.hasOwnProperty,hT=Object.prototype.propertyIsEnumerable,fT=(e,t,r)=>t in e?sT(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,dT=(e,t)=>{for(var r in t||(t={}))lT.call(t,r)&&fT(e,r,t[r]);if(uT)for(var r of uT(t))hT.call(t,r)&&fT(e,r,t[r]);return e};class pT{constructor(e){this.provider=e}static mapToCamelCase(e){return dT(dT({},e),null!=e&&e.messages?{messages:(e?.messages||[]).map((e=>{var t=e,{state_init:r}=t,n=((e,t)=>{var r={};for(var n in e)lT.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&uT)for(var n of uT(e))t.indexOf(n)<0&&hT.call(e,n)&&(r[n]=e[n]);return r})(t,["state_init"]);return((e,t)=>aT(e,cT(t)))(dT({},n),{stateInit:r})}))}:{})}async request(e,t){switch(e){case"tonConnect_connect":{const e=await this.provider.internalRequest("requestAccounts",t);return JSON.parse(e)}case"tonConnect_reconnect":{const e=await this.provider.internalRequest("tonConnect_reconnect",t);return JSON.parse(e)}case"ton_rawSign":return this.provider.internalRequest("signMessage",t);case"ton_sendTransaction":case"tonConnect_sendTransaction":{const r=await this.provider.internalRequest("signTransaction",pT.mapToCamelCase(t[0])),{nonce:n,hash:i}=JSON.parse(r);return"ton_sendTransaction"===e?n:i}case"ton_requestAccounts":{const e=await this.provider.internalRequest("requestAccounts",t),[{nonBounceable:r}]=JSON.parse(e);return[r]}case"ton_requestWallets":{const e=await this.provider.internalRequest("requestAccounts",t),[{nonBounceable:r,publicKey:n}]=JSON.parse(e);return[{address:r,publicKey:n,version:this.provider.version}]}default:return this.provider.internalRequest(e,t)}}}const gT=class extends ze{constructor(e){super(),this.version="v4R2",e&&e.version&&(this.version=e.version),null!=e&&e.disableMobileAdapter||(this.mobileAdapter=new pT(this))}disconnect(){return this.send("tonConnect_disconnect",{})}isConnected(){return Promise.resolve(!0)}async send(e,t){return this.mobileAdapter?await this.mobileAdapter.request(e,t):await(()=>this.internalRequest(e,t))()}internalRequest(e,t){return super.request({method:e,params:t})}getNetwork(){return gT.NETWORK}};let yT=gT;yT.NETWORK="ton";class mT extends Error{constructor(e,t){super(e),this.code=t}}const wT=e=>{var t;return{event:"connect_error",payload:{code:null!=(t=e.code)?t:0,message:e.message}}};class bT{constructor(e,t){this.protocolVersion=2,this.isWalletBrowser=!0,this.callbacks=[],this.listen=e=>(this.callbacks.push(e),()=>{this.callbacks=this.callbacks.filter((t=>t!=e))}),e&&(typeof e.isWalletBrowser<"u"&&(this.isWalletBrowser=e.isWalletBrowser),e.walletInfo&&(this.walletInfo=e.walletInfo),e.deviceInfo&&(this.deviceInfo=e.deviceInfo)),this.provider=t}async connect(e,t){e>this.protocolVersion&&new mT("Unsupported protocol version",1);const r=await this.provider.send("tonConnect_connect",t);return"connect_error"===r?.event?this.emit(r):this.emit({event:"connect",payload:{items:r,device:this.deviceInfo}})}async disconnect(){return await this.provider.send("tonConnect_disconnect",{}),this.emit({event:"disconnect",payload:{}})}emit(e){return this.callbacks.forEach((t=>t(e))),e}async restoreConnection(){var e;try{const e=await this.provider.send("tonConnect_reconnect",[{name:"ton_addr"}]);return this.emit({event:"connect",payload:{items:e,device:this.deviceInfo}})}catch(t){return t instanceof mT?this.emit(wT(t)):this.emit(wT(new mT(null!=(e=t.message)?e:"Unknown error")))}}async send(e){try{return{result:await this.provider.send(`tonConnect_${e.method}`,e.params.map((e=>JSON.parse(e)))),id:e.id.toString()}}catch(t){return{error:t,id:String(e.id)}}}}window.trustwallet={core:(e,t)=>new De({strategy:e,handler:t}),solana:e=>new dl(e),cosmos:e=>new $B(e),ethereum:e=>new LB(e),aptos:e=>new oT(e),ton:e=>new yT(e),tonBridge:(e,t)=>new bT(e,t),randomUUID:()=>y()}})); +Object.defineProperty(e,"__esModule",{value:!0}),e.bytes=e.stringToBytes=e.str=e.bytesToString=e.hex=e.utf8=e.bech32m=e.bech32=e.base58check=e.createBase58check=e.base58xmr=e.base58xrp=e.base58flickr=e.base58=e.base64urlnopad=e.base64url=e.base64nopad=e.base64=e.base32crockford=e.base32hexnopad=e.base32hex=e.base32nopad=e.base32=e.base16=e.utils=void 0,e.assertNumber=t;const u=(e,t)=>t?u(t,e%t):e,h=(e,t)=>e+(t-u(e,t));function l(e,r,n,i){if(!Array.isArray(e))throw new Error("convertRadix2: data should be array");if(r<=0||r>32)throw new Error(`convertRadix2: wrong from=${r}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(h(r,n)>32)throw new Error(`convertRadix2: carry overflow from=${r} to=${n} carryBits=${h(r,n)}`);let o=0,s=0;const a=2**n-1,c=[];for(const i of e){if(t(i),i>=2**r)throw new Error(`convertRadix2: invalid data word=${i} from=${r}`);if(o=o<32)throw new Error(`convertRadix2: carry overflow pos=${s} from=${r}`);for(s+=r;s>=n;s-=n)c.push((o>>s-n&a)>>>0);o&=2**s-1}if(o=o<=r)throw new Error("Excess padding");if(!i&&o)throw new Error(`Non-zero padding: ${o}`);return i&&s>0&&c.push(o>>>0),c}function f(e){return t(e),{encode:t=>{if(!r(t))throw new Error("radix.encode input should be Uint8Array");return c(Array.from(t),256,e)},decode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("radix.decode input should be array of numbers");return Uint8Array.from(c(t,e,256))}}}function d(e,n=!1){if(t(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(h(8,e)>32||h(e,8)>32)throw new Error("radix2: carry overflow");return{encode:t=>{if(!r(t))throw new Error("radix2.encode input should be Uint8Array");return l(Array.from(t),8,e,!n)},decode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("radix2.decode input should be array of numbers");return Uint8Array.from(l(t,e,8,n))}}}function p(e){if("function"!=typeof e)throw new Error("unsafeWrapper fn should be function");return function(...t){try{return e.apply(null,t)}catch(e){}}}function g(e,n){if(t(e),"function"!=typeof n)throw new Error("checksum fn should be function");return{encode(t){if(!r(t))throw new Error("checksum.encode: input should be Uint8Array");const i=n(t).slice(0,e),o=new Uint8Array(t.length+e);return o.set(t),o.set(i,t.length),o},decode(t){if(!r(t))throw new Error("checksum.decode: input should be Uint8Array");const i=t.slice(0,-e),o=n(i).slice(0,e),s=t.slice(-e);for(let t=0;te.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")))),e.base64=n(d(6),i("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),s(6),o("")),e.base64nopad=n(d(6),i("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),o("")),e.base64url=n(d(6),i("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),s(6),o("")),e.base64urlnopad=n(d(6),i("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),o(""));const y=e=>n(f(58),i(e),o(""));e.base58=y("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),e.base58flickr=y("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),e.base58xrp=y("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const m=[0,2,3,5,6,7,9,10,11];e.base58xmr={encode(t){let r="";for(let n=0;nn(g(4,(e=>t(t(e)))),e.base58),e.base58check=e.createBase58check;const w=n(i("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),o("")),b=[996825010,642813549,513874426,1027748829,705979059];function v(e){const t=e>>25;let r=(33554431&e)<<5;for(let e=0;e>e&1)&&(r^=b[e]);return r}function _(e,t,r=1){const n=e.length;let i=1;for(let t=0;t126)throw new Error(`Invalid prefix (${e})`);i=v(i)^r>>5}i=v(i);for(let t=0;tn)throw new TypeError(`Length ${i} exceeds limit ${n}`);const o=e.toLowerCase(),s=_(o,r,t);return`${o}1${w.encode(r)}${s}`}function a(e,r=90){if("string"!=typeof e)throw new Error("bech32.decode input should be string, not "+typeof e);if(e.length<8||!1!==r&&e.length>r)throw new TypeError(`Wrong string length: ${e.length} (${e}). Expected (8..${r})`);const n=e.toLowerCase();if(e!==n&&e!==e.toUpperCase())throw new Error("String must be lowercase or uppercase");const i=n.lastIndexOf("1");if(0===i||-1===i)throw new Error('Letter "1" must be present between prefix and data only');const o=n.slice(0,i),s=n.slice(i+1);if(s.length<6)throw new Error("Data must be at least 6 characters long");const a=w.decode(s).slice(0,-6),c=_(o,a,t);if(!s.endsWith(c))throw new Error(`Invalid checksum in ${e}: expected "${c}"`);return{prefix:o,words:a}}return{encode:s,decode:a,encodeFromBytes:function(e,t){return s(e,i(t))},decodeToBytes:function(e){const{prefix:t,words:r}=a(e,!1);return{prefix:t,words:r,bytes:n(r)}},decodeUnsafe:p(a),fromWords:n,fromWordsUnsafe:o,toWords:i}}e.bech32=E("bech32"),e.bech32m=E("bech32m"),e.utf8={encode:e=>(new TextDecoder).decode(e),decode:e=>(new TextEncoder).encode(e)},e.hex=n(d(4),i("0123456789abcdef"),o(""),a((e=>{if("string"!=typeof e||e.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()})));const S={utf8:e.utf8,hex:e.hex,base16:e.base16,base32:e.base32,base64:e.base64,base64url:e.base64url,base58:e.base58,base58xmr:e.base58xmr},A="Invalid encoding type. Available types: utf8, hex, base16, base32, base64, base64url, base58, base58xmr";e.bytesToString=(e,t)=>{if("string"!=typeof e||!S.hasOwnProperty(e))throw new TypeError(A);if(!r(t))throw new TypeError("bytesToString() expects Uint8Array");return S[e].encode(t)},e.str=e.bytesToString;e.stringToBytes=(e,t)=>{if(!S.hasOwnProperty(e))throw new TypeError(A);if("string"!=typeof t)throw new TypeError("stringToBytes() expects string");return S[e].decode(t)},e.bytes=e.stringToBytes}(a_);var c_={},u_={},h_={};function l_(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function f_(e){if("boolean"!=typeof e)throw new Error(`boolean expected, not ${e}`)}function d_(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}function p_(e,...t){if(!d_(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function g_(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");l_(e.outputLen),l_(e.blockLen)}function y_(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function m_(e,t){p_(e);const r=t.outputLen;if(e.length>__&v_)}:{h:0|Number(e>>__&v_),l:0|Number(e&v_)}}function S_(e,t=!1){let r=new Uint32Array(e.length),n=new Uint32Array(e.length);for(let i=0;iBigInt(e>>>0)<<__|BigInt(t>>>0);b_.toBig=A_;const x_=(e,t,r)=>e>>>r;b_.shrSH=x_;const k_=(e,t,r)=>e<<32-r|t>>>r;b_.shrSL=k_;const B_=(e,t,r)=>e>>>r|t<<32-r;b_.rotrSH=B_;const I_=(e,t,r)=>e<<32-r|t>>>r;b_.rotrSL=I_;const T_=(e,t,r)=>e<<64-r|t>>>r-32;b_.rotrBH=T_;const R_=(e,t,r)=>e>>>r-32|t<<64-r;b_.rotrBL=R_;const O_=(e,t)=>t;b_.rotr32H=O_;const L_=(e,t)=>e;b_.rotr32L=L_;const M_=(e,t,r)=>e<>>32-r;b_.rotlSH=M_;const C_=(e,t,r)=>t<>>32-r;b_.rotlSL=C_;const P_=(e,t,r)=>t<>>64-r;b_.rotlBH=P_;const N_=(e,t,r)=>e<>>64-r;function U_(e,t,r,n){const i=(t>>>0)+(n>>>0);return{h:e+r+(i/2**32|0)|0,l:0|i}}b_.rotlBL=N_;const j_=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0);b_.add3L=j_;const $_=(e,t,r,n)=>t+r+n+(e/2**32|0)|0;b_.add3H=$_;const H_=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0);b_.add4L=H_;const z_=(e,t,r,n,i)=>t+r+n+i+(e/2**32|0)|0;b_.add4H=z_;const D_=(e,t,r,n,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(i>>>0);b_.add5L=D_;const F_=(e,t,r,n,i,o)=>t+r+n+i+o+(e/2**32|0)|0;b_.add5H=F_;const q_={fromBig:E_,split:S_,toBig:A_,shrSH:x_,shrSL:k_,rotrSH:B_,rotrSL:I_,rotrBH:T_,rotrBL:R_,rotr32H:O_,rotr32L:L_,rotlSH:M_,rotlSL:C_,rotlBH:P_,rotlBL:N_,add:U_,add3L:j_,add3H:$_,add4L:H_,add4H:z_,add5H:F_,add5L:D_};b_.default=q_;var K_={},W_={};Object.defineProperty(W_,"__esModule",{value:!0}),W_.crypto=void 0,W_.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,function(e){ +/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */ +Object.defineProperty(e,"__esModule",{value:!0}),e.Hash=e.nextTick=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=void 0,e.isBytes=function(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name},e.byteSwap32=function(t){for(let r=0;r=0&&te().update(a(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t},e.wrapConstructorWithOpts=function(e){const t=(t,r)=>e(r).update(a(t)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=t=>e(t),t},e.wrapXOFConstructorWithOpts=function(e){const t=(t,r)=>e(r).update(a(t)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=t=>e(t),t},e.randomBytes=function(e=32){if(t.crypto&&"function"==typeof t.crypto.getRandomValues)return t.crypto.getRandomValues(new Uint8Array(e));if(t.crypto&&"function"==typeof t.crypto.randomBytes)return t.crypto.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")};const t=W_,r=h_;e.u8=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength);e.u32=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));e.createView=e=>new DataView(e.buffer,e.byteOffset,e.byteLength);e.rotr=(e,t)=>e<<32-t|e>>>t;e.rotl=(e,t)=>e<>>32-t>>>0,e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];e.byteSwap=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255,e.byteSwapIfBE=e.isLE?e=>e:t=>(0,e.byteSwap)(t);const n=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));const i={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function o(e){return e>=i._0&&e<=i._9?e-i._0:e>=i._A&&e<=i._F?e-(i._A-10):e>=i._a&&e<=i._f?e-(i._a-10):void 0}function s(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}function a(e){return"string"==typeof e&&(e=s(e)),(0,r.bytes)(e),e}e.nextTick=async()=>{};e.Hash=class{clone(){return this._cloneInto()}};const c={}.toString}(K_),Object.defineProperty(u_,"__esModule",{value:!0}),u_.shake256=u_.shake128=u_.keccak_512=u_.keccak_384=u_.keccak_256=u_.keccak_224=u_.sha3_512=u_.sha3_384=u_.sha3_256=u_.sha3_224=u_.Keccak=void 0,u_.keccakP=uE;const V_=h_,Z_=b_,G_=K_,J_=[],Y_=[],X_=[],Q_=BigInt(0),eE=BigInt(1),tE=BigInt(2),rE=BigInt(7),nE=BigInt(256),iE=BigInt(113);for(let e=0,t=eE,r=1,n=0;e<24;e++){[r,n]=[n,(2*r+3*n)%5],J_.push(2*(5*n+r)),Y_.push((e+1)*(e+2)/2%64);let i=Q_;for(let e=0;e<7;e++)t=(t<>rE)*iE)%nE,t&tE&&(i^=eE<<(eE<r>32?(0,Z_.rotlBH)(e,t,r):(0,Z_.rotlSH)(e,t,r),cE=(e,t,r)=>r>32?(0,Z_.rotlBL)(e,t,r):(0,Z_.rotlSL)(e,t,r);function uE(e,t=24){const r=new Uint32Array(10);for(let n=24-t;n<24;n++){for(let t=0;t<10;t++)r[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){const n=(t+8)%10,i=(t+2)%10,o=r[i],s=r[i+1],a=aE(o,s,1)^r[n],c=cE(o,s,1)^r[n+1];for(let r=0;r<50;r+=10)e[t+r]^=a,e[t+r+1]^=c}let t=e[2],i=e[3];for(let r=0;r<24;r++){const n=Y_[r],o=aE(t,i,n),s=cE(t,i,n),a=J_[r];t=e[a],i=e[a+1],e[a]=o,e[a+1]=s}for(let t=0;t<50;t+=10){for(let n=0;n<10;n++)r[n]=e[t+n];for(let n=0;n<10;n++)e[t+n]^=~r[(n+2)%10]&r[(n+4)%10]}e[0]^=oE[n],e[1]^=sE[n]}r.fill(0)}class hE extends G_.Hash{constructor(e,t,r,n=!1,i=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=n,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,(0,V_.number)(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=(0,G_.u32)(this.state)}keccak(){G_.isLE||(0,G_.byteSwap32)(this.state32),uE(this.state32,this.rounds),G_.isLE||(0,G_.byteSwap32)(this.state32),this.posOut=0,this.pos=0}update(e){(0,V_.exists)(this);const{blockLen:t,state:r}=this,n=(e=(0,G_.toBytes)(e)).length;for(let i=0;i=r&&this.keccak();const o=Math.min(r-this.posOut,i-n);e.set(t.subarray(this.posOut,this.posOut+o),n),this.posOut+=o,n+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return(0,V_.number)(e),this.xofInto(new Uint8Array(e))}digestInto(e){if((0,V_.output)(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:r,outputLen:n,rounds:i,enableXOF:o}=this;return e||(e=new hE(t,r,n,o,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=r,e.outputLen=n,e.enableXOF=o,e.destroyed=this.destroyed,e}}u_.Keccak=hE;const lE=(e,t,r)=>(0,G_.wrapConstructor)((()=>new hE(t,e,r)));u_.sha3_224=lE(6,144,28),u_.sha3_256=lE(6,136,32),u_.sha3_384=lE(6,104,48),u_.sha3_512=lE(6,72,64),u_.keccak_224=lE(1,144,28),u_.keccak_256=lE(1,136,32),u_.keccak_384=lE(1,104,48),u_.keccak_512=lE(1,72,64);const fE=(e,t,r)=>(0,G_.wrapXOFConstructorWithOpts)(((n={})=>new hE(t,e,void 0===n.dkLen?r:n.dkLen,!0)));var dE,pE;function gE(){return dE||(dE=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.remove0x=e.add0x=e.isValidChecksumAddress=e.getChecksumAddress=e.isValidHexAddress=e.assertIsStrictHexString=e.assertIsHexString=e.isStrictHexString=e.isHexString=e.HexChecksumAddressStruct=e.HexAddressStruct=e.StrictHexStruct=e.HexStruct=void 0;const t=nv,r=u_,n=rv,i=yE();function o(r){return(0,t.is)(r,e.HexStruct)}function s(r){return(0,t.is)(r,e.StrictHexStruct)}function a(o){(0,n.assert)((0,t.is)(o,e.HexChecksumAddressStruct),"Invalid hex address.");const s=u(o.toLowerCase()),a=u((0,i.bytesToHex)((0,r.keccak_256)(s)));return`0x${s.split("").map(((e,r)=>{const i=a[r];return(0,n.assert)((0,t.is)(i,(0,t.string)()),"Hash shorter than address."),parseInt(i,16)>7?e.toUpperCase():e})).join("")}`}function c(r){return!!(0,t.is)(r,e.HexChecksumAddressStruct)&&a(r)===r}function u(e){return e.startsWith("0x")||e.startsWith("0X")?e.substring(2):e}e.HexStruct=(0,t.pattern)((0,t.string)(),/^(?:0x)?[0-9a-f]+$/iu),e.StrictHexStruct=(0,t.pattern)((0,t.string)(),/^0x[0-9a-f]+$/iu),e.HexAddressStruct=(0,t.pattern)((0,t.string)(),/^0x[0-9a-f]{40}$/u),e.HexChecksumAddressStruct=(0,t.pattern)((0,t.string)(),/^0x[0-9a-fA-F]{40}$/u),e.isHexString=o,e.isStrictHexString=s,e.assertIsHexString=function(e){(0,n.assert)(o(e),"Value must be a hexadecimal string.")},e.assertIsStrictHexString=function(e){(0,n.assert)(s(e),'Value must be a hexadecimal string, starting with "0x".')},e.isValidHexAddress=function(r){return(0,t.is)(r,e.HexAddressStruct)||c(r)},e.getChecksumAddress=a,e.isValidChecksumAddress=c,e.add0x=function(e){return e.startsWith("0x")?e:e.startsWith("0X")?`0x${e.substring(2)}`:`0x${e}`},e.remove0x=u}(c_)),c_}function yE(){if(pE)return s_;pE=1,Object.defineProperty(s_,"__esModule",{value:!0}),s_.createDataView=s_.concatBytes=s_.valueToBytes=s_.base64ToBytes=s_.stringToBytes=s_.numberToBytes=s_.signedBigIntToBytes=s_.bigIntToBytes=s_.hexToBytes=s_.bytesToBase64=s_.bytesToString=s_.bytesToNumber=s_.bytesToSignedBigInt=s_.bytesToBigInt=s_.bytesToHex=s_.assertIsBytes=s_.isBytes=void 0;const e=a_,t=rv,r=gE();const n=function(){const e=[];return()=>{if(0===e.length)for(let t=0;t<256;t++)e.push(t.toString(16).padStart(2,"0"));return e}}();function i(e){return e instanceof Uint8Array}function o(e){(0,t.assert)(i(e),"Value must be a Uint8Array.")}function s(e){if(o(e),0===e.length)return"0x";const t=n(),i=new Array(e.length);for(let r=0;r=BigInt(0),"Value must be a non-negative bigint.");return c(e.toString(16))}function h(e){(0,t.assert)("number"==typeof e,"Value must be a number."),(0,t.assert)(e>=0,"Value must be a non-negative number."),(0,t.assert)(Number.isSafeInteger(e),"Value is not a safe integer. Use `bigIntToBytes` instead.");return c(e.toString(16))}function l(e){return(0,t.assert)("string"==typeof e,"Value must be a string."),(new TextEncoder).encode(e)}function f(e){if("bigint"==typeof e)return u(e);if("number"==typeof e)return h(e);if("string"==typeof e)return e.startsWith("0x")?c(e):l(e);if(i(e))return e;throw new TypeError(`Unsupported value type: "${typeof e}".`)}return s_.isBytes=i,s_.assertIsBytes=o,s_.bytesToHex=s,s_.bytesToBigInt=a,s_.bytesToSignedBigInt=function(e){o(e);let t=BigInt(0);for(const r of e)t=(t<0,"Byte length must be greater than 0."),(0,t.assert)(function(e,r){(0,t.assert)(r>0);const n=e>>BigInt(31);return!((~e&n)+(e&~n)>>BigInt(8*r-1))}(e,r),"Byte length is too small to represent the given value.");let n=e;const i=new Uint8Array(r);for(let e=0;e>=BigInt(8);return i.reverse()},s_.numberToBytes=h,s_.stringToBytes=l,s_.base64ToBytes=function(r){return(0,t.assert)("string"==typeof r,"Value must be a string."),e.base64.decode(r)},s_.valueToBytes=f,s_.concatBytes=function(e){const t=new Array(e.length);let r=0;for(let n=0;n[-a-z0-9]{3,8}):(?[-_a-zA-Z0-9]{1,32})$/u,e.CAIP_NAMESPACE_REGEX=/^[-a-z0-9]{3,8}$/u,e.CAIP_REFERENCE_REGEX=/^[-_a-zA-Z0-9]{1,32}$/u,e.CAIP_ACCOUNT_ID_REGEX=/^(?(?[-a-z0-9]{3,8}):(?[-_a-zA-Z0-9]{1,32})):(?[-.%a-zA-Z0-9]{1,128})$/u,e.CAIP_ACCOUNT_ADDRESS_REGEX=/^[-.%a-zA-Z0-9]{1,128}$/u,e.CAIP_ASSET_TYPE_REGEX=/^(?(?[-a-z0-9]{3,8}):(?[-_a-zA-Z0-9]{1,32}))\/(?[-a-z0-9]{3,8}):(?[-.%a-zA-Z0-9]{1,128})$/u,e.CAIP_ASSET_ID_REGEX=/^(?(?[-a-z0-9]{3,8}):(?[-_a-zA-Z0-9]{1,32}))\/(?[-a-z0-9]{3,8}):(?[-.%a-zA-Z0-9]{1,128})\/(?[-.%a-zA-Z0-9]{1,78})$/u,e.CaipChainIdStruct=(0,t.pattern)((0,t.string)(),e.CAIP_CHAIN_ID_REGEX),e.CaipNamespaceStruct=(0,t.pattern)((0,t.string)(),e.CAIP_NAMESPACE_REGEX),e.CaipReferenceStruct=(0,t.pattern)((0,t.string)(),e.CAIP_REFERENCE_REGEX),e.CaipAccountIdStruct=(0,t.pattern)((0,t.string)(),e.CAIP_ACCOUNT_ID_REGEX),e.CaipAccountAddressStruct=(0,t.pattern)((0,t.string)(),e.CAIP_ACCOUNT_ADDRESS_REGEX),e.CaipAssetTypeStruct=(0,t.pattern)((0,t.string)(),e.CAIP_ASSET_TYPE_REGEX),e.CaipAssetIdStruct=(0,t.pattern)((0,t.string)(),e.CAIP_ASSET_ID_REGEX),(r=e.KnownCaipNamespace||(e.KnownCaipNamespace={})).Bip122="bip122",r.Eip155="eip155",r.Wallet="wallet",e.isCaipChainId=function(r){return(0,t.is)(r,e.CaipChainIdStruct)},e.isCaipNamespace=n,e.isCaipReference=i,e.isCaipAccountId=function(r){return(0,t.is)(r,e.CaipAccountIdStruct)},e.isCaipAccountAddress=function(r){return(0,t.is)(r,e.CaipAccountAddressStruct)},e.isCaipAssetType=function(r){return(0,t.is)(r,e.CaipAssetTypeStruct)},e.isCaipAssetId=function(r){return(0,t.is)(r,e.CaipAssetIdStruct)},e.parseCaipChainId=function(t){const r=e.CAIP_CHAIN_ID_REGEX.exec(t);if(!r?.groups)throw new Error("Invalid CAIP chain ID.");return{namespace:r.groups.namespace,reference:r.groups.reference}},e.parseCaipAccountId=function(t){const r=e.CAIP_ACCOUNT_ID_REGEX.exec(t);if(!r?.groups)throw new Error("Invalid CAIP account ID.");return{address:r.groups.accountAddress,chainId:r.groups.chainId,chain:{namespace:r.groups.namespace,reference:r.groups.reference}}},e.toCaipChainId=function(t,r){if(!n(t))throw new Error(`Invalid "namespace", must match: ${e.CAIP_NAMESPACE_REGEX.toString()}`);if(!i(r))throw new Error(`Invalid "reference", must match: ${e.CAIP_REFERENCE_REGEX.toString()}`);return`${t}:${r}`}}(mE);var wE={};Object.defineProperty(wE,"__esModule",{value:!0}),wE.ChecksumStruct=void 0;const bE=nv,vE=n_;wE.ChecksumStruct=(0,bE.size)((0,vE.base64)((0,bE.string)(),{paddingRequired:!0}),44,44);var _E={};Object.defineProperty(_E,"__esModule",{value:!0}),_E.createHex=_E.createBytes=_E.createBigInt=_E.createNumber=void 0;const EE=nv,SE=rv,AE=yE(),xE=gE(),kE=(0,EE.union)([(0,EE.number)(),(0,EE.bigint)(),(0,EE.string)(),xE.StrictHexStruct]),BE=(0,EE.coerce)((0,EE.number)(),kE,Number),IE=(0,EE.coerce)((0,EE.bigint)(),kE,BigInt);(0,EE.union)([xE.StrictHexStruct,(0,EE.instance)(Uint8Array)]);const TE=(0,EE.coerce)((0,EE.instance)(Uint8Array),(0,EE.union)([xE.StrictHexStruct]),AE.hexToBytes),RE=(0,EE.coerce)(xE.StrictHexStruct,(0,EE.instance)(Uint8Array),AE.bytesToHex);_E.createNumber=function(e){try{const t=(0,EE.create)(e,BE);return(0,SE.assert)(Number.isFinite(t),`Expected a number-like value, got "${e}".`),t}catch(t){if(t instanceof EE.StructError)throw new Error(`Expected a number-like value, got "${e}".`);throw t}},_E.createBigInt=function(e){try{return(0,EE.create)(e,IE)}catch(e){if(e instanceof EE.StructError)throw new Error(`Expected a number-like value, got "${String(e.value)}".`);throw e}},_E.createBytes=function(e){if("string"==typeof e&&"0x"===e.toLowerCase())return new Uint8Array;try{return(0,EE.create)(e,TE)}catch(e){if(e instanceof EE.StructError)throw new Error(`Expected a bytes-like value, got "${String(e.value)}".`);throw e}},_E.createHex=function(e){if(e instanceof Uint8Array&&0===e.length||"string"==typeof e&&"0x"===e.toLowerCase())return"0x";try{return(0,EE.create)(e,RE)}catch(e){if(e instanceof EE.StructError)throw new Error(`Expected a bytes-like value, got "${String(e.value)}".`);throw e}};var OE,LE,ME={},CE=Cr&&Cr.__classPrivateFieldGet||function(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)},PE=Cr&&Cr.__classPrivateFieldSet||function(e,t,r,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!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"===n?i.call(e,r):i?i.value=r:t.set(e,r),r};Object.defineProperty(ME,"__esModule",{value:!0}),ME.FrozenSet=ME.FrozenMap=void 0;class NE{get size(){return CE(this,OE,"f").size}[(OE=new WeakMap,Symbol.iterator)](){return CE(this,OE,"f")[Symbol.iterator]()}constructor(e){OE.set(this,void 0),PE(this,OE,new Map(e),"f"),Object.freeze(this)}entries(){return CE(this,OE,"f").entries()}forEach(e,t){return CE(this,OE,"f").forEach(((r,n,i)=>e.call(t,r,n,this)))}get(e){return CE(this,OE,"f").get(e)}has(e){return CE(this,OE,"f").has(e)}keys(){return CE(this,OE,"f").keys()}values(){return CE(this,OE,"f").values()}toString(){return`FrozenMap(${this.size}) {${this.size>0?` ${[...this.entries()].map((([e,t])=>`${String(e)} => ${String(t)}`)).join(", ")} `:""}}`}}ME.FrozenMap=NE;class UE{get size(){return CE(this,LE,"f").size}[(LE=new WeakMap,Symbol.iterator)](){return CE(this,LE,"f")[Symbol.iterator]()}constructor(e){LE.set(this,void 0),PE(this,LE,new Set(e),"f"),Object.freeze(this)}entries(){return CE(this,LE,"f").entries()}forEach(e,t){return CE(this,LE,"f").forEach(((r,n,i)=>e.call(t,r,n,this)))}has(e){return CE(this,LE,"f").has(e)}keys(){return CE(this,LE,"f").keys()}values(){return CE(this,LE,"f").values()}toString(){return`FrozenSet(${this.size}) {${this.size>0?` ${[...this.values()].map((e=>String(e))).join(", ")} `:""}}`}}ME.FrozenSet=UE,Object.freeze(NE),Object.freeze(NE.prototype),Object.freeze(UE),Object.freeze(UE.prototype);var jE={};Object.defineProperty(jE,"__esModule",{value:!0});var $E={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.getJsonRpcIdValidator=e.assertIsJsonRpcError=e.isJsonRpcError=e.assertIsJsonRpcFailure=e.isJsonRpcFailure=e.assertIsJsonRpcSuccess=e.isJsonRpcSuccess=e.assertIsJsonRpcResponse=e.isJsonRpcResponse=e.assertIsPendingJsonRpcResponse=e.isPendingJsonRpcResponse=e.JsonRpcResponseStruct=e.JsonRpcFailureStruct=e.JsonRpcSuccessStruct=e.PendingJsonRpcResponseStruct=e.assertIsJsonRpcRequest=e.isJsonRpcRequest=e.assertIsJsonRpcNotification=e.isJsonRpcNotification=e.JsonRpcNotificationStruct=e.JsonRpcRequestStruct=e.JsonRpcParamsStruct=e.JsonRpcErrorStruct=e.JsonRpcIdStruct=e.JsonRpcVersionStruct=e.jsonrpc2=e.getJsonSize=e.getSafeJson=e.isValidJson=e.JsonStruct=e.UnsafeJsonStruct=e.exactOptional=e.object=void 0;const t=nv,r=rv,n=Zv;function i({path:e,branch:t}){const r=e[e.length-1];return(0,n.hasProperty)(t[t.length-2],r)}function o(e){return new t.Struct({...e,type:`optional ${e.type}`,validator:(t,r)=>!i(r)||e.validator(t,r),refiner:(t,r)=>!i(r)||e.refiner(t,r)})}e.object=e=>(0,t.object)(e),e.exactOptional=o;function s(r){return(0,t.create)(r,e.JsonStruct)}e.UnsafeJsonStruct=(0,t.union)([(0,t.literal)(null),(0,t.boolean)(),(0,t.define)("finite number",(e=>(0,t.is)(e,(0,t.number)())&&Number.isFinite(e))),(0,t.string)(),(0,t.array)((0,t.lazy)((()=>e.UnsafeJsonStruct))),(0,t.record)((0,t.string)(),(0,t.lazy)((()=>e.UnsafeJsonStruct)))]),e.JsonStruct=(0,t.coerce)(e.UnsafeJsonStruct,(0,t.any)(),(t=>((0,r.assertStruct)(t,e.UnsafeJsonStruct),JSON.parse(JSON.stringify(t,((e,t)=>{if("__proto__"!==e&&"constructor"!==e)return t})))))),e.isValidJson=function(e){try{return s(e),!0}catch{return!1}},e.getSafeJson=s,e.getJsonSize=function(t){(0,r.assertStruct)(t,e.JsonStruct,"Invalid JSON value");const n=JSON.stringify(t);return(new TextEncoder).encode(n).byteLength},e.jsonrpc2="2.0",e.JsonRpcVersionStruct=(0,t.literal)(e.jsonrpc2),e.JsonRpcIdStruct=(0,t.nullable)((0,t.union)([(0,t.number)(),(0,t.string)()])),e.JsonRpcErrorStruct=(0,e.object)({code:(0,t.integer)(),message:(0,t.string)(),data:o(e.JsonStruct),stack:o((0,t.string)())}),e.JsonRpcParamsStruct=(0,t.union)([(0,t.record)((0,t.string)(),e.JsonStruct),(0,t.array)(e.JsonStruct)]),e.JsonRpcRequestStruct=(0,e.object)({id:e.JsonRpcIdStruct,jsonrpc:e.JsonRpcVersionStruct,method:(0,t.string)(),params:o(e.JsonRpcParamsStruct)}),e.JsonRpcNotificationStruct=(0,e.object)({jsonrpc:e.JsonRpcVersionStruct,method:(0,t.string)(),params:o(e.JsonRpcParamsStruct)}),e.isJsonRpcNotification=function(r){return(0,t.is)(r,e.JsonRpcNotificationStruct)},e.assertIsJsonRpcNotification=function(t,n){(0,r.assertStruct)(t,e.JsonRpcNotificationStruct,"Invalid JSON-RPC notification",n)},e.isJsonRpcRequest=function(r){return(0,t.is)(r,e.JsonRpcRequestStruct)},e.assertIsJsonRpcRequest=function(t,n){(0,r.assertStruct)(t,e.JsonRpcRequestStruct,"Invalid JSON-RPC request",n)},e.PendingJsonRpcResponseStruct=(0,t.object)({id:e.JsonRpcIdStruct,jsonrpc:e.JsonRpcVersionStruct,result:(0,t.optional)((0,t.unknown)()),error:(0,t.optional)(e.JsonRpcErrorStruct)}),e.JsonRpcSuccessStruct=(0,e.object)({id:e.JsonRpcIdStruct,jsonrpc:e.JsonRpcVersionStruct,result:e.JsonStruct}),e.JsonRpcFailureStruct=(0,e.object)({id:e.JsonRpcIdStruct,jsonrpc:e.JsonRpcVersionStruct,error:e.JsonRpcErrorStruct}),e.JsonRpcResponseStruct=(0,t.union)([e.JsonRpcSuccessStruct,e.JsonRpcFailureStruct]),e.isPendingJsonRpcResponse=function(r){return(0,t.is)(r,e.PendingJsonRpcResponseStruct)},e.assertIsPendingJsonRpcResponse=function(t,n){(0,r.assertStruct)(t,e.PendingJsonRpcResponseStruct,"Invalid pending JSON-RPC response",n)},e.isJsonRpcResponse=function(r){return(0,t.is)(r,e.JsonRpcResponseStruct)},e.assertIsJsonRpcResponse=function(t,n){(0,r.assertStruct)(t,e.JsonRpcResponseStruct,"Invalid JSON-RPC response",n)},e.isJsonRpcSuccess=function(r){return(0,t.is)(r,e.JsonRpcSuccessStruct)},e.assertIsJsonRpcSuccess=function(t,n){(0,r.assertStruct)(t,e.JsonRpcSuccessStruct,"Invalid JSON-RPC success response",n)},e.isJsonRpcFailure=function(r){return(0,t.is)(r,e.JsonRpcFailureStruct)},e.assertIsJsonRpcFailure=function(t,n){(0,r.assertStruct)(t,e.JsonRpcFailureStruct,"Invalid JSON-RPC failure response",n)},e.isJsonRpcError=function(r){return(0,t.is)(r,e.JsonRpcErrorStruct)},e.assertIsJsonRpcError=function(t,n){(0,r.assertStruct)(t,e.JsonRpcErrorStruct,"Invalid JSON-RPC error",n)},e.getJsonRpcIdValidator=function(e){const{permitEmptyString:t,permitFractions:r,permitNull:n}={permitEmptyString:!0,permitFractions:!1,permitNull:!0,...e};return e=>Boolean("number"==typeof e&&(r||Number.isInteger(e))||"string"==typeof e&&(t||e.length>0)||n&&null===e)}}($E);var HE={};Object.defineProperty(HE,"__esModule",{value:!0});var zE,DE,FE={},qE={exports:{}};function KE(){if(DE)return zE;DE=1;var e=1e3,t=60*e,r=60*t,n=24*r,i=7*n,o=365.25*n;function s(e,t,r,n){var i=t>=1.5*r;return Math.round(e/r)+" "+n+(i?"s":"")}return zE=function(a,c){c=c||{};var u=typeof a;if("string"===u&&a.length>0)return function(s){if((s=String(s)).length>100)return;var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(s);if(!a)return;var c=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*o;case"weeks":case"week":case"w":return c*i;case"days":case"day":case"d":return c*n;case"hours":case"hour":case"hrs":case"hr":case"h":return c*r;case"minutes":case"minute":case"mins":case"min":case"m":return c*t;case"seconds":case"second":case"secs":case"sec":case"s":return c*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(a);if("number"===u&&isFinite(a))return c.long?function(i){var o=Math.abs(i);if(o>=n)return s(i,o,n,"day");if(o>=r)return s(i,o,r,"hour");if(o>=t)return s(i,o,t,"minute");if(o>=e)return s(i,o,e,"second");return i+" ms"}(a):function(i){var o=Math.abs(i);if(o>=n)return Math.round(i/n)+"d";if(o>=r)return Math.round(i/r)+"h";if(o>=t)return Math.round(i/t)+"m";if(o>=e)return Math.round(i/e)+"s";return i+"ms"}(a);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(a))},zE}var WE=function(e){function t(e){let n,i,o,s=null;function a(...e){if(!a.enabled)return;const r=a,i=Number(new Date),o=i-(n||i);r.diff=o,r.prev=n,r.curr=i,n=i,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,i)=>{if("%%"===n)return"%";s++;const o=t.formatters[i];if("function"==typeof o){const t=e[s];n=o.call(r,t),e.splice(s,1),s--}return n})),t.formatArgs.call(r,e);(r.log||t.log).apply(r,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=r,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(i!==t.namespaces&&(i=t.namespaces,o=t.enabled(e)),o),set:e=>{s=e}}),"function"==typeof t.init&&t.init(a),a}function r(e,r){const n=t(this.namespace+(void 0===r?":":r)+e);return n.log=this.log,n}function n(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(n),...t.skips.map(n).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let r;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").split(/[\s,]+/),i=n.length;for(r=0;r{t[r]=e[r]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t{"%%"!==e&&(n++,"%c"===e&&(i=n))})),t.splice(i,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;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&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[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=WE(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(qE,qE.exports);var VE=Cr&&Cr.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(FE,"__esModule",{value:!0}),FE.createModuleLogger=FE.createProjectLogger=void 0;const ZE=(0,VE(qE.exports).default)("metamask");FE.createProjectLogger=function(e){return ZE.extend(e)},FE.createModuleLogger=function(e,t){return e.extend(t)};var GE={};Object.defineProperty(GE,"__esModule",{value:!0}),GE.hexToBigInt=GE.hexToNumber=GE.bigIntToHex=GE.numberToHex=void 0;const JE=rv,YE=gE();GE.numberToHex=e=>((0,JE.assert)("number"==typeof e,"Value must be a number."),(0,JE.assert)(e>=0,"Value must be a non-negative number."),(0,JE.assert)(Number.isSafeInteger(e),"Value is not a safe integer. Use `bigIntToHex` instead."),(0,YE.add0x)(e.toString(16)));GE.bigIntToHex=e=>((0,JE.assert)("bigint"==typeof e,"Value must be a bigint."),(0,JE.assert)(e>=0,"Value must be a non-negative bigint."),(0,YE.add0x)(e.toString(16)));GE.hexToNumber=e=>{(0,YE.assertIsHexString)(e);const t=parseInt(e,16);return(0,JE.assert)(Number.isSafeInteger(t),"Value is not a safe integer. Use `hexToBigInt` instead."),t};GE.hexToBigInt=e=>((0,YE.assertIsHexString)(e),BigInt((0,YE.add0x)(e)));var XE={};Object.defineProperty(XE,"__esModule",{value:!0});var QE={};Object.defineProperty(QE,"__esModule",{value:!0}),QE.createDeferredPromise=void 0,QE.createDeferredPromise=function({suppressUnhandledRejection:e=!1}={}){let t,r;const n=new Promise(((e,n)=>{t=e,r=n}));return e&&n.catch((e=>{})),{promise:n,resolve:t,reject:r}};var eS={};!function(e){var t;Object.defineProperty(e,"__esModule",{value:!0}),e.timeSince=e.inMilliseconds=e.Duration=void 0,(t=e.Duration||(e.Duration={}))[t.Millisecond=1]="Millisecond",t[t.Second=1e3]="Second",t[t.Minute=6e4]="Minute",t[t.Hour=36e5]="Hour",t[t.Day=864e5]="Day",t[t.Week=6048e5]="Week",t[t.Year=31536e6]="Year";const r=(e,t)=>{if(!(e=>Number.isInteger(e)&&e>=0)(e))throw new Error(`"${t}" must be a non-negative integer. Received: "${e}".`)};e.inMilliseconds=function(e,t){return r(e,"count"),e*t},e.timeSince=function(e){return r(e,"timestamp"),Date.now()-e}}(eS);var tS={};Object.defineProperty(tS,"__esModule",{value:!0});var rS={},nS={exports:{}};var iS={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER||9007199254740991,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:"2.0.0",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2};var oS="object"==typeof process&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};!function(e,t){const{MAX_SAFE_COMPONENT_LENGTH:r,MAX_SAFE_BUILD_LENGTH:n,MAX_LENGTH:i}=iS,o=oS,s=(t=e.exports={}).re=[],a=t.safeRe=[],c=t.src=[],u=t.t={};let h=0;const l="[a-zA-Z0-9-]",f=[["\\s",1],["\\d",i],[l,n]],d=(e,t,r)=>{const n=(e=>{for(const[t,r]of f)e=e.split(`${t}*`).join(`${t}{0,${r}}`).split(`${t}+`).join(`${t}{1,${r}}`);return e})(t),i=h++;o(e,i,t),u[e]=i,c[i]=t,s[i]=new RegExp(t,r?"g":void 0),a[i]=new RegExp(n,r?"g":void 0)};d("NUMERICIDENTIFIER","0|[1-9]\\d*"),d("NUMERICIDENTIFIERLOOSE","\\d+"),d("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${l}*`),d("MAINVERSION",`(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})`),d("MAINVERSIONLOOSE",`(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})`),d("PRERELEASEIDENTIFIER",`(?:${c[u.NUMERICIDENTIFIER]}|${c[u.NONNUMERICIDENTIFIER]})`),d("PRERELEASEIDENTIFIERLOOSE",`(?:${c[u.NUMERICIDENTIFIERLOOSE]}|${c[u.NONNUMERICIDENTIFIER]})`),d("PRERELEASE",`(?:-(${c[u.PRERELEASEIDENTIFIER]}(?:\\.${c[u.PRERELEASEIDENTIFIER]})*))`),d("PRERELEASELOOSE",`(?:-?(${c[u.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[u.PRERELEASEIDENTIFIERLOOSE]})*))`),d("BUILDIDENTIFIER",`${l}+`),d("BUILD",`(?:\\+(${c[u.BUILDIDENTIFIER]}(?:\\.${c[u.BUILDIDENTIFIER]})*))`),d("FULLPLAIN",`v?${c[u.MAINVERSION]}${c[u.PRERELEASE]}?${c[u.BUILD]}?`),d("FULL",`^${c[u.FULLPLAIN]}$`),d("LOOSEPLAIN",`[v=\\s]*${c[u.MAINVERSIONLOOSE]}${c[u.PRERELEASELOOSE]}?${c[u.BUILD]}?`),d("LOOSE",`^${c[u.LOOSEPLAIN]}$`),d("GTLT","((?:<|>)?=?)"),d("XRANGEIDENTIFIERLOOSE",`${c[u.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),d("XRANGEIDENTIFIER",`${c[u.NUMERICIDENTIFIER]}|x|X|\\*`),d("XRANGEPLAIN",`[v=\\s]*(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:${c[u.PRERELEASE]})?${c[u.BUILD]}?)?)?`),d("XRANGEPLAINLOOSE",`[v=\\s]*(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:${c[u.PRERELEASELOOSE]})?${c[u.BUILD]}?)?)?`),d("XRANGE",`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAIN]}$`),d("XRANGELOOSE",`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAINLOOSE]}$`),d("COERCEPLAIN",`(^|[^\\d])(\\d{1,${r}})(?:\\.(\\d{1,${r}}))?(?:\\.(\\d{1,${r}}))?`),d("COERCE",`${c[u.COERCEPLAIN]}(?:$|[^\\d])`),d("COERCEFULL",c[u.COERCEPLAIN]+`(?:${c[u.PRERELEASE]})?`+`(?:${c[u.BUILD]})?(?:$|[^\\d])`),d("COERCERTL",c[u.COERCE],!0),d("COERCERTLFULL",c[u.COERCEFULL],!0),d("LONETILDE","(?:~>?)"),d("TILDETRIM",`(\\s*)${c[u.LONETILDE]}\\s+`,!0),t.tildeTrimReplace="$1~",d("TILDE",`^${c[u.LONETILDE]}${c[u.XRANGEPLAIN]}$`),d("TILDELOOSE",`^${c[u.LONETILDE]}${c[u.XRANGEPLAINLOOSE]}$`),d("LONECARET","(?:\\^)"),d("CARETTRIM",`(\\s*)${c[u.LONECARET]}\\s+`,!0),t.caretTrimReplace="$1^",d("CARET",`^${c[u.LONECARET]}${c[u.XRANGEPLAIN]}$`),d("CARETLOOSE",`^${c[u.LONECARET]}${c[u.XRANGEPLAINLOOSE]}$`),d("COMPARATORLOOSE",`^${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]})$|^$`),d("COMPARATOR",`^${c[u.GTLT]}\\s*(${c[u.FULLPLAIN]})$|^$`),d("COMPARATORTRIM",`(\\s*)${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]}|${c[u.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace="$1$2$3",d("HYPHENRANGE",`^\\s*(${c[u.XRANGEPLAIN]})\\s+-\\s+(${c[u.XRANGEPLAIN]})\\s*$`),d("HYPHENRANGELOOSE",`^\\s*(${c[u.XRANGEPLAINLOOSE]})\\s+-\\s+(${c[u.XRANGEPLAINLOOSE]})\\s*$`),d("STAR","(<|>)?=?\\s*\\*"),d("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),d("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")}(nS,nS.exports);const sS=Object.freeze({loose:!0}),aS=Object.freeze({});var cS=e=>e?"object"!=typeof e?sS:e:aS;const uS=/^[0-9]+$/,hS=(e,t)=>{const r=uS.test(e),n=uS.test(t);return r&&n&&(e=+e,t=+t),e===t?0:r&&!n?-1:n&&!r?1:ehS(t,e)};const fS=oS,{MAX_LENGTH:dS,MAX_SAFE_INTEGER:pS}=iS,{safeRe:gS,t:yS}=nS.exports,mS=cS,{compareIdentifiers:wS}=lS;class bS{constructor(e,t){if(t=mS(t),e instanceof bS){if(e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease)return e;e=e.version}else if("string"!=typeof e)throw new TypeError(`Invalid version. Must be a string. Got type "${typeof e}".`);if(e.length>dS)throw new TypeError(`version is longer than ${dS} characters`);fS("SemVer",e,t),this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease;const r=e.trim().match(t.loose?gS[yS.LOOSE]:gS[yS.FULL]);if(!r)throw new TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+r[1],this.minor=+r[2],this.patch=+r[3],this.major>pS||this.major<0)throw new TypeError("Invalid major version");if(this.minor>pS||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>pS||this.patch<0)throw new TypeError("Invalid patch version");r[4]?this.prerelease=r[4].split(".").map((e=>{if(/^[0-9]+$/.test(e)){const t=+e;if(t>=0&&t=0;)"number"==typeof this.prerelease[n]&&(this.prerelease[n]++,n=-2);if(-1===n){if(t===this.prerelease.join(".")&&!1===r)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(e)}}if(t){let n=[t,e];!1===r&&(n=[t]),0===wS(this.prerelease[0],t)?isNaN(this.prerelease[1])&&(this.prerelease=n):this.prerelease=n}break}default:throw new Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}}var vS=bS;const _S=vS;var ES=(e,t,r=!1)=>{if(e instanceof _S)return e;try{return new _S(e,t)}catch(e){if(!r)return null;throw e}};const SS=ES;var AS=(e,t)=>{const r=SS(e,t);return r?r.version:null};const xS=ES;var kS=(e,t)=>{const r=xS(e.trim().replace(/^[=v]+/,""),t);return r?r.version:null};const BS=vS;var IS=(e,t,r,n,i)=>{"string"==typeof r&&(i=n,n=r,r=void 0);try{return new BS(e instanceof BS?e.version:e,r).inc(t,n,i).version}catch(e){return null}};const TS=ES;var RS=(e,t)=>{const r=TS(e,null,!0),n=TS(t,null,!0),i=r.compare(n);if(0===i)return null;const o=i>0,s=o?r:n,a=o?n:r,c=!!s.prerelease.length;if(!!a.prerelease.length&&!c)return a.patch||a.minor?s.patch?"patch":s.minor?"minor":"major":"major";const u=c?"pre":"";return r.major!==n.major?u+"major":r.minor!==n.minor?u+"minor":r.patch!==n.patch?u+"patch":"prerelease"};const OS=vS;var LS=(e,t)=>new OS(e,t).major;const MS=vS;var CS=(e,t)=>new MS(e,t).minor;const PS=vS;var NS=(e,t)=>new PS(e,t).patch;const US=ES;var jS=(e,t)=>{const r=US(e,t);return r&&r.prerelease.length?r.prerelease:null};const $S=vS;var HS=(e,t,r)=>new $S(e,r).compare(new $S(t,r));const zS=HS;var DS=(e,t,r)=>zS(t,e,r);const FS=HS;var qS=(e,t)=>FS(e,t,!0);const KS=vS;var WS=(e,t,r)=>{const n=new KS(e,r),i=new KS(t,r);return n.compare(i)||n.compareBuild(i)};const VS=WS;var ZS=(e,t)=>e.sort(((e,r)=>VS(e,r,t)));const GS=WS;var JS=(e,t)=>e.sort(((e,r)=>GS(r,e,t)));const YS=HS;var XS=(e,t,r)=>YS(e,t,r)>0;const QS=HS;var eA=(e,t,r)=>QS(e,t,r)<0;const tA=HS;var rA=(e,t,r)=>0===tA(e,t,r);const nA=HS;var iA=(e,t,r)=>0!==nA(e,t,r);const oA=HS;var sA=(e,t,r)=>oA(e,t,r)>=0;const aA=HS;var cA=(e,t,r)=>aA(e,t,r)<=0;const uA=rA,hA=iA,lA=XS,fA=sA,dA=eA,pA=cA;var gA=(e,t,r,n)=>{switch(t){case"===":return"object"==typeof e&&(e=e.version),"object"==typeof r&&(r=r.version),e===r;case"!==":return"object"==typeof e&&(e=e.version),"object"==typeof r&&(r=r.version),e!==r;case"":case"=":case"==":return uA(e,r,n);case"!=":return hA(e,r,n);case">":return lA(e,r,n);case">=":return fA(e,r,n);case"<":return dA(e,r,n);case"<=":return pA(e,r,n);default:throw new TypeError(`Invalid operator: ${t}`)}};const yA=vS,mA=ES,{safeRe:wA,t:bA}=nS.exports;var vA=(e,t)=>{if(e instanceof yA)return e;if("number"==typeof e&&(e=String(e)),"string"!=typeof e)return null;let r=null;if((t=t||{}).rtl){const n=t.includePrerelease?wA[bA.COERCERTLFULL]:wA[bA.COERCERTL];let i;for(;(i=n.exec(e))&&(!r||r.index+r[0].length!==e.length);)r&&i.index+i[0].length===r.index+r[0].length||(r=i),n.lastIndex=i.index+i[1].length+i[2].length;n.lastIndex=-1}else r=e.match(t.includePrerelease?wA[bA.COERCEFULL]:wA[bA.COERCE]);if(null===r)return null;const n=r[2],i=r[3]||"0",o=r[4]||"0",s=t.includePrerelease&&r[5]?`-${r[5]}`:"",a=t.includePrerelease&&r[6]?`+${r[6]}`:"";return mA(`${n}.${i}.${o}${s}${a}`,t)};var _A,EA,SA,AA,xA=class{constructor(){this.max=1e3,this.map=new Map}get(e){const t=this.map.get(e);return void 0===t?void 0:(this.map.delete(e),this.map.set(e,t),t)}delete(e){return this.map.delete(e)}set(e,t){if(!this.delete(e)&&void 0!==t){if(this.map.size>=this.max){const e=this.map.keys().next().value;this.delete(e)}this.map.set(e,t)}return this}};function kA(){if(EA)return _A;EA=1;const e=/\s+/g;class t{constructor(r,o){if(o=n(o),r instanceof t)return r.loose===!!o.loose&&r.includePrerelease===!!o.includePrerelease?r:new t(r.raw,o);if(r instanceof i)return this.raw=r.value,this.set=[[r]],this.formatted=void 0,this;if(this.options=o,this.loose=!!o.loose,this.includePrerelease=!!o.includePrerelease,this.raw=r.trim().replace(e," "),this.set=this.raw.split("||").map((e=>this.parseRange(e.trim()))).filter((e=>e.length)),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const e=this.set[0];if(this.set=this.set.filter((e=>!p(e[0]))),0===this.set.length)this.set=[e];else if(this.set.length>1)for(const e of this.set)if(1===e.length&&g(e[0])){this.set=[e];break}}this.formatted=void 0}get range(){if(void 0===this.formatted){this.formatted="";for(let e=0;e0&&(this.formatted+="||");const t=this.set[e];for(let e=0;e0&&(this.formatted+=" "),this.formatted+=t[e].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(e){const t=((this.options.includePrerelease&&f)|(this.options.loose&&d))+":"+e,n=r.get(t);if(n)return n;const s=this.options.loose,g=s?a[c.HYPHENRANGELOOSE]:a[c.HYPHENRANGE];e=e.replace(g,B(this.options.includePrerelease)),o("hyphen replace",e),e=e.replace(a[c.COMPARATORTRIM],u),o("comparator trim",e),e=e.replace(a[c.TILDETRIM],h),o("tilde trim",e),e=e.replace(a[c.CARETTRIM],l),o("caret trim",e);let y=e.split(" ").map((e=>m(e,this.options))).join(" ").split(/\s+/).map((e=>k(e,this.options)));s&&(y=y.filter((e=>(o("loose invalid filter",e,this.options),!!e.match(a[c.COMPARATORLOOSE]))))),o("range list",y);const w=new Map,b=y.map((e=>new i(e,this.options)));for(const e of b){if(p(e))return[e];w.set(e.value,e)}w.size>1&&w.has("")&&w.delete("");const v=[...w.values()];return r.set(t,v),v}intersects(e,r){if(!(e instanceof t))throw new TypeError("a Range is required");return this.set.some((t=>y(t,r)&&e.set.some((e=>y(e,r)&&t.every((t=>e.every((e=>t.intersects(e,r)))))))))}test(e){if(!e)return!1;if("string"==typeof e)try{e=new s(e,this.options)}catch(e){return!1}for(let t=0;t"<0.0.0-0"===e.value,g=e=>""===e.value,y=(e,t)=>{let r=!0;const n=e.slice();let i=n.pop();for(;r&&n.length;)r=n.every((e=>i.intersects(e,t))),i=n.pop();return r},m=(e,t)=>(o("comp",e,t),e=_(e,t),o("caret",e),e=b(e,t),o("tildes",e),e=S(e,t),o("xrange",e),e=x(e,t),o("stars",e),e),w=e=>!e||"x"===e.toLowerCase()||"*"===e,b=(e,t)=>e.trim().split(/\s+/).map((e=>v(e,t))).join(" "),v=(e,t)=>{const r=t.loose?a[c.TILDELOOSE]:a[c.TILDE];return e.replace(r,((t,r,n,i,s)=>{let a;return o("tilde",e,t,r,n,i,s),w(r)?a="":w(n)?a=`>=${r}.0.0 <${+r+1}.0.0-0`:w(i)?a=`>=${r}.${n}.0 <${r}.${+n+1}.0-0`:s?(o("replaceTilde pr",s),a=`>=${r}.${n}.${i}-${s} <${r}.${+n+1}.0-0`):a=`>=${r}.${n}.${i} <${r}.${+n+1}.0-0`,o("tilde return",a),a}))},_=(e,t)=>e.trim().split(/\s+/).map((e=>E(e,t))).join(" "),E=(e,t)=>{o("caret",e,t);const r=t.loose?a[c.CARETLOOSE]:a[c.CARET],n=t.includePrerelease?"-0":"";return e.replace(r,((t,r,i,s,a)=>{let c;return o("caret",e,t,r,i,s,a),w(r)?c="":w(i)?c=`>=${r}.0.0${n} <${+r+1}.0.0-0`:w(s)?c="0"===r?`>=${r}.${i}.0${n} <${r}.${+i+1}.0-0`:`>=${r}.${i}.0${n} <${+r+1}.0.0-0`:a?(o("replaceCaret pr",a),c="0"===r?"0"===i?`>=${r}.${i}.${s}-${a} <${r}.${i}.${+s+1}-0`:`>=${r}.${i}.${s}-${a} <${r}.${+i+1}.0-0`:`>=${r}.${i}.${s}-${a} <${+r+1}.0.0-0`):(o("no pr"),c="0"===r?"0"===i?`>=${r}.${i}.${s}${n} <${r}.${i}.${+s+1}-0`:`>=${r}.${i}.${s}${n} <${r}.${+i+1}.0-0`:`>=${r}.${i}.${s} <${+r+1}.0.0-0`),o("caret return",c),c}))},S=(e,t)=>(o("replaceXRanges",e,t),e.split(/\s+/).map((e=>A(e,t))).join(" ")),A=(e,t)=>{e=e.trim();const r=t.loose?a[c.XRANGELOOSE]:a[c.XRANGE];return e.replace(r,((r,n,i,s,a,c)=>{o("xRange",e,r,n,i,s,a,c);const u=w(i),h=u||w(s),l=h||w(a),f=l;return"="===n&&f&&(n=""),c=t.includePrerelease?"-0":"",u?r=">"===n||"<"===n?"<0.0.0-0":"*":n&&f?(h&&(s=0),a=0,">"===n?(n=">=",h?(i=+i+1,s=0,a=0):(s=+s+1,a=0)):"<="===n&&(n="<",h?i=+i+1:s=+s+1),"<"===n&&(c="-0"),r=`${n+i}.${s}.${a}${c}`):h?r=`>=${i}.0.0${c} <${+i+1}.0.0-0`:l&&(r=`>=${i}.${s}.0${c} <${i}.${+s+1}.0-0`),o("xRange return",r),r}))},x=(e,t)=>(o("replaceStars",e,t),e.trim().replace(a[c.STAR],"")),k=(e,t)=>(o("replaceGTE0",e,t),e.trim().replace(a[t.includePrerelease?c.GTE0PRE:c.GTE0],"")),B=e=>(t,r,n,i,o,s,a,c,u,h,l,f)=>`${r=w(n)?"":w(i)?`>=${n}.0.0${e?"-0":""}`:w(o)?`>=${n}.${i}.0${e?"-0":""}`:s?`>=${r}`:`>=${r}${e?"-0":""}`} ${c=w(u)?"":w(h)?`<${+u+1}.0.0-0`:w(l)?`<${u}.${+h+1}.0-0`:f?`<=${u}.${h}.${l}-${f}`:e?`<${u}.${h}.${+l+1}-0`:`<=${c}`}`.trim(),I=(e,t,r)=>{for(let r=0;r0){const n=e[r].semver;if(n.major===t.major&&n.minor===t.minor&&n.patch===t.patch)return!0}return!1}return!0};return _A}function BA(){if(AA)return SA;AA=1;const e=Symbol("SemVer ANY");class t{static get ANY(){return e}constructor(n,i){if(i=r(i),n instanceof t){if(n.loose===!!i.loose)return n;n=n.value}n=n.trim().split(/\s+/).join(" "),s("comparator",n,i),this.options=i,this.loose=!!i.loose,this.parse(n),this.semver===e?this.value="":this.value=this.operator+this.semver.version,s("comp",this)}parse(t){const r=this.options.loose?n[i.COMPARATORLOOSE]:n[i.COMPARATOR],o=t.match(r);if(!o)throw new TypeError(`Invalid comparator: ${t}`);this.operator=void 0!==o[1]?o[1]:"","="===this.operator&&(this.operator=""),o[2]?this.semver=new a(o[2],this.options.loose):this.semver=e}toString(){return this.value}test(t){if(s("Comparator.test",t,this.options.loose),this.semver===e||t===e)return!0;if("string"==typeof t)try{t=new a(t,this.options)}catch(e){return!1}return o(t,this.operator,this.semver,this.options)}intersects(e,n){if(!(e instanceof t))throw new TypeError("a Comparator is required");return""===this.operator?""===this.value||new c(e.value,n).test(this.value):""===e.operator?""===e.value||new c(this.value,n).test(e.semver):(!(n=r(n)).includePrerelease||"<0.0.0-0"!==this.value&&"<0.0.0-0"!==e.value)&&(!(!n.includePrerelease&&(this.value.startsWith("<0.0.0")||e.value.startsWith("<0.0.0")))&&(!(!this.operator.startsWith(">")||!e.operator.startsWith(">"))||(!(!this.operator.startsWith("<")||!e.operator.startsWith("<"))||(!(this.semver.version!==e.semver.version||!this.operator.includes("=")||!e.operator.includes("="))||(!!(o(this.semver,"<",e.semver,n)&&this.operator.startsWith(">")&&e.operator.startsWith("<"))||!!(o(this.semver,">",e.semver,n)&&this.operator.startsWith("<")&&e.operator.startsWith(">")))))))}}SA=t;const r=cS,{safeRe:n,t:i}=nS.exports,o=gA,s=oS,a=vS,c=kA();return SA}const IA=kA();var TA=(e,t,r)=>{try{t=new IA(t,r)}catch(e){return!1}return t.test(e)};const RA=kA();var OA=(e,t)=>new RA(e,t).set.map((e=>e.map((e=>e.value)).join(" ").trim().split(" ")));const LA=vS,MA=kA();var CA=(e,t,r)=>{let n=null,i=null,o=null;try{o=new MA(t,r)}catch(e){return null}return e.forEach((e=>{o.test(e)&&(n&&-1!==i.compare(e)||(n=e,i=new LA(n,r)))})),n};const PA=vS,NA=kA();var UA=(e,t,r)=>{let n=null,i=null,o=null;try{o=new NA(t,r)}catch(e){return null}return e.forEach((e=>{o.test(e)&&(n&&1!==i.compare(e)||(n=e,i=new PA(n,r)))})),n};const jA=vS,$A=kA(),HA=XS;var zA=(e,t)=>{e=new $A(e,t);let r=new jA("0.0.0");if(e.test(r))return r;if(r=new jA("0.0.0-0"),e.test(r))return r;r=null;for(let t=0;t{const t=new jA(e.semver.version);switch(e.operator){case">":0===t.prerelease.length?t.patch++:t.prerelease.push(0),t.raw=t.format();case"":case">=":i&&!HA(t,i)||(i=t);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${e.operator}`)}})),!i||r&&!HA(r,i)||(r=i)}return r&&e.test(r)?r:null};const DA=kA();var FA=(e,t)=>{try{return new DA(e,t).range||"*"}catch(e){return null}};const qA=vS,KA=BA(),{ANY:WA}=KA,VA=kA(),ZA=TA,GA=XS,JA=eA,YA=cA,XA=sA;var QA=(e,t,r,n)=>{let i,o,s,a,c;switch(e=new qA(e,n),t=new VA(t,n),r){case">":i=GA,o=YA,s=JA,a=">",c=">=";break;case"<":i=JA,o=XA,s=GA,a="<",c="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(ZA(e,t,n))return!1;for(let r=0;r{e.semver===WA&&(e=new KA(">=0.0.0")),h=h||e,l=l||e,i(e.semver,h.semver,n)?h=e:s(e.semver,l.semver,n)&&(l=e)})),h.operator===a||h.operator===c)return!1;if((!l.operator||l.operator===a)&&o(e,l.semver))return!1;if(l.operator===c&&s(e,l.semver))return!1}return!0};const ex=QA;var tx=(e,t,r)=>ex(e,t,">",r);const rx=QA;var nx=(e,t,r)=>rx(e,t,"<",r);const ix=kA();var ox=(e,t,r)=>(e=new ix(e,r),t=new ix(t,r),e.intersects(t,r));const sx=TA,ax=HS;const cx=kA(),ux=BA(),{ANY:hx}=ux,lx=TA,fx=HS,dx=[new ux(">=0.0.0-0")],px=[new ux(">=0.0.0")],gx=(e,t,r)=>{if(e===t)return!0;if(1===e.length&&e[0].semver===hx){if(1===t.length&&t[0].semver===hx)return!0;e=r.includePrerelease?dx:px}if(1===t.length&&t[0].semver===hx){if(r.includePrerelease)return!0;t=px}const n=new Set;let i,o,s,a,c,u,h;for(const t of e)">"===t.operator||">="===t.operator?i=yx(i,t,r):"<"===t.operator||"<="===t.operator?o=mx(o,t,r):n.add(t.semver);if(n.size>1)return null;if(i&&o){if(s=fx(i.semver,o.semver,r),s>0)return null;if(0===s&&(">="!==i.operator||"<="!==o.operator))return null}for(const e of n){if(i&&!lx(e,String(i),r))return null;if(o&&!lx(e,String(o),r))return null;for(const n of t)if(!lx(e,String(n),r))return!1;return!0}let l=!(!o||r.includePrerelease||!o.semver.prerelease.length)&&o.semver,f=!(!i||r.includePrerelease||!i.semver.prerelease.length)&&i.semver;l&&1===l.prerelease.length&&"<"===o.operator&&0===l.prerelease[0]&&(l=!1);for(const e of t){if(h=h||">"===e.operator||">="===e.operator,u=u||"<"===e.operator||"<="===e.operator,i)if(f&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===f.major&&e.semver.minor===f.minor&&e.semver.patch===f.patch&&(f=!1),">"===e.operator||">="===e.operator){if(a=yx(i,e,r),a===e&&a!==i)return!1}else if(">="===i.operator&&!lx(i.semver,String(e),r))return!1;if(o)if(l&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===l.major&&e.semver.minor===l.minor&&e.semver.patch===l.patch&&(l=!1),"<"===e.operator||"<="===e.operator){if(c=mx(o,e,r),c===e&&c!==o)return!1}else if("<="===o.operator&&!lx(o.semver,String(e),r))return!1;if(!e.operator&&(o||i)&&0!==s)return!1}return!(i&&u&&!o&&0!==s)&&(!(o&&h&&!i&&0!==s)&&(!f&&!l))},yx=(e,t,r)=>{if(!e)return t;const n=fx(e.semver,t.semver,r);return n>0?e:n<0||">"===t.operator&&">="===e.operator?t:e},mx=(e,t,r)=>{if(!e)return t;const n=fx(e.semver,t.semver,r);return n<0?e:n>0||"<"===t.operator&&"<="===e.operator?t:e};var wx=(e,t,r={})=>{if(e===t)return!0;e=new cx(e,r),t=new cx(t,r);let n=!1;e:for(const i of e.set){for(const e of t.set){const t=gx(i,e,r);if(n=n||null!==t,t)continue e}if(n)return!1}return!0};const bx=nS.exports,vx=iS,_x=vS,Ex=lS,Sx=(e,t,r)=>{const n=[];let i=null,o=null;const s=e.sort(((e,t)=>ax(e,t,r)));for(const e of s){sx(e,t,r)?(o=e,i||(i=e)):(o&&n.push([i,o]),o=null,i=null)}i&&n.push([i,null]);const a=[];for(const[e,t]of n)e===t?a.push(e):t||e!==s[0]?t?e===s[0]?a.push(`<=${t}`):a.push(`${e} - ${t}`):a.push(`>=${e}`):a.push("*");const c=a.join(" || "),u="string"==typeof t.raw?t.raw:String(t);return c.lengthnull!==(0,r.valid)(e)||`Expected SemVer version, got "${e}"`)),e.VersionRangeStruct=(0,t.refine)((0,t.string)(),"Version range",(e=>null!==(0,r.validRange)(e)||`Expected SemVer range, got "${e}"`)),e.isValidSemVerVersion=function(r){return(0,t.is)(r,e.VersionStruct)},e.isValidSemVerRange=function(r){return(0,t.is)(r,e.VersionRangeStruct)},e.assertIsSemVerVersion=function(t){(0,n.assertStruct)(t,e.VersionStruct)},e.assertIsSemVerRange=function(t){(0,n.assertStruct)(t,e.VersionRangeStruct)},e.gtVersion=function(e,t){return(0,r.gt)(e,t)},e.gtRange=function(e,t){return(0,r.gtr)(e,t)},e.satisfiesVersionRange=function(e,t){return(0,r.satisfies)(e,t,{includePrerelease:!0})}}(rS),function(e){var t=Cr&&Cr.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=Cr&&Cr.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(rv,e),r(n_,e),r(yE(),e),r(mE,e),r(wE,e),r(_E,e),r(ME,e),r(jE,e),r(Cv,e),r(gE(),e),r($E,e),r(HE,e),r(FE,e),r(Zv,e),r(GE,e),r(XE,e),r(QE,e),r(eS,e),r(tS,e),r(rS,e)}(tv),Object.defineProperty(ev,"__esModule",{value:!0}),ev.normalize=ev.recoverPublicKey=ev.concatSig=ev.legacyToBuffer=ev.isNullish=ev.padWithZeroes=void 0;const xx=bh,kx=tv;function Bx(e,t){if(""!==e&&!/^[a-f0-9]+$/iu.test(e))throw new Error(`Expected an unprefixed hex string. Received: ${e}`);if(t<0)throw new Error(`Expected a non-negative integer target length. Received: ${t}`);return String.prototype.padStart.call(e,t,"0")}function Ix(e){return null==e}ev.padWithZeroes=Bx,ev.isNullish=Ix,ev.legacyToBuffer=function(e){return"string"!=typeof e||(0,xx.isHexString)(e)?(0,xx.toBuffer)(e):C.from(e)},ev.concatSig=function(e,t,r){const n=(0,xx.fromSigned)(t),i=(0,xx.fromSigned)(r),o=(0,xx.bufferToInt)(e),s=Bx((0,xx.toUnsigned)(n).toString("hex"),64),a=Bx((0,xx.toUnsigned)(i).toString("hex"),64),c=(0,kx.remove0x)((0,kx.numberToHex)(o));return(0,kx.add0x)(s.concat(a,c))},ev.recoverPublicKey=function(e,t){const r=(0,xx.fromRpcSig)(t);return(0,xx.ecrecover)(e,r.v,r.r,r.s)},ev.normalize=function(e){if(!Ix(e)){if("number"==typeof e){if(e<0)return"0x";const t=(0,kx.numberToBytes)(e);e=(0,kx.bytesToHex)(t)}if("string"!=typeof e){let t="eth-sig-util.normalize() requires hex string or integer input.";throw t+=` received ${typeof e}: ${e}`,new Error(t)}return(0,kx.add0x)(e.toLowerCase())}},Object.defineProperty(wh,"__esModule",{value:!0}),wh.extractPublicKey=wh.recoverPersonalSignature=wh.personalSign=void 0;const Tx=bh,Rx=ev;function Ox(e,t){const r=(0,Tx.hashPersonalMessage)((0,Rx.legacyToBuffer)(e));return(0,Rx.recoverPublicKey)(r,t)}wh.personalSign=function({privateKey:e,data:t}){if((0,Rx.isNullish)(t))throw new Error("Missing data parameter");if((0,Rx.isNullish)(e))throw new Error("Missing privateKey parameter");const r=(0,Rx.legacyToBuffer)(t),n=(0,Tx.hashPersonalMessage)(r),i=(0,Tx.ecsign)(n,e);return(0,Rx.concatSig)((0,Tx.toBuffer)(i.v),i.r,i.s)},wh.recoverPersonalSignature=function({data:e,signature:t}){if((0,Rx.isNullish)(e))throw new Error("Missing data parameter");if((0,Rx.isNullish)(t))throw new Error("Missing signature parameter");const r=Ox(e,t),n=(0,Tx.publicToAddress)(r);return(0,Tx.bufferToHex)(n)},wh.extractPublicKey=function({data:e,signature:t}){if((0,Rx.isNullish)(e))throw new Error("Missing data parameter");if((0,Rx.isNullish)(t))throw new Error("Missing signature parameter");return`0x${Ox(e,t).toString("hex")}`};var Lx={},Mx={},Cx={},Px={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ParserError=e.getErrorStack=e.getErrorMessage=void 0;const t=tv;e.getErrorMessage=e=>"string"==typeof e?e:e instanceof Error||(0,t.isObject)(e)&&(0,t.hasProperty)(e,"message")&&"string"==typeof e.message?e.message:"Unknown error.";e.getErrorStack=e=>{if(e instanceof Error)return e.stack};class r extends Error{constructor(t,r){super(t),this.name="ParserError";const n=(0,e.getErrorStack)(r);n&&(this.stack=n)}}e.ParserError=r}(Px);var Nx={},Ux={};Object.defineProperty(Ux,"__esModule",{value:!0}),Ux.iterate=void 0;const jx=tv;Ux.iterate=function*(e,t=32){for(let r=0;r{(0,jx.assert)(e>=0,"Cannot skip a negative number of bytes."),(0,jx.assert)(e%t==0,"Length must be a multiple of the size."),r+=e},i=e.subarray(r);yield{skip:n,value:i}}return{skip:()=>{},value:new Uint8Array}};var $x={},Hx={},zx={},Dx={};Object.defineProperty(Dx,"__esModule",{value:!0}),Dx.padEnd=Dx.padStart=Dx.set=void 0;const Fx=tv;Dx.set=(e,t,r)=>(0,Fx.concatBytes)([e.subarray(0,r),t,e.subarray(r+t.length)]);Dx.padStart=(e,t=32)=>{const r=new Uint8Array(Math.max(t-e.length,0)).fill(0);return(0,Fx.concatBytes)([r,e])};Dx.padEnd=(e,t=32)=>{const r=new Uint8Array(Math.max(t-e.length,0)).fill(0);return(0,Fx.concatBytes)([e,r])},function(e){var t=Cr&&Cr.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=Cr&&Cr.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(Dx,e)}(zx),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.address=e.getAddress=void 0;const t=tv,r=Px,n=zx;e.getAddress=e=>{const i=(0,t.createBytes)(e);return(0,t.assert)(i.length<=20,new r.ParserError(`Invalid address value. Expected address to be 20 bytes long, but received ${i.length} bytes.`)),(0,n.padStart)(i,20)},e.address={isDynamic:!1,isType:e=>"address"===e,getByteLength:()=>32,encode({buffer:r,value:i,packed:o}){const s=(0,e.getAddress)(i);if(o)return(0,t.concatBytes)([r,s]);const a=(0,n.padStart)(s);return(0,t.concatBytes)([r,a])},decode:({value:e})=>(0,t.add0x)((0,t.bytesToHex)(e.slice(12,32)))}}(Hx);var qx={},Kx={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.fixedBytes=e.getByteLength=void 0;const t=tv,r=Px,n=zx,i=/^bytes([0-9]{1,2})$/u;e.getByteLength=e=>{const n=e.match(i)?.[1];(0,t.assert)(n,`Invalid byte length. Expected a number between 1 and 32, but received "${e}".`);const o=Number(n);return(0,t.assert)(o>0&&o<=32,new r.ParserError(`Invalid byte length. Expected a number between 1 and 32, but received "${e}".`)),o},e.fixedBytes={isDynamic:!1,isType:e=>i.test(e),getByteLength:()=>32,encode({type:i,buffer:o,value:s,packed:a}){const c=(0,e.getByteLength)(i),u=(0,t.createBytes)(s);return(0,t.assert)(u.length<=c,new r.ParserError(`Expected a value of length ${c}, but received a value of length ${u.length}.`)),(0,t.concatBytes)(a?[o,(0,n.padEnd)(u,c)]:[o,(0,n.padEnd)(u)])},decode({type:t,value:r}){const n=(0,e.getByteLength)(t);return r.slice(0,n)}}}(Kx);var Wx,Vx,Zx={};function Gx(){return Wx||(Wx=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.tuple=e.getTupleElements=void 0;const t=tv,r=Px,n=uk(),i=/^\((.+)\)$/u;e.getTupleElements=e=>{(0,t.assert)(e.startsWith("(")&&e.endsWith(")"),new r.ParserError(`Invalid tuple type. Expected tuple type, but received "${e}".`));const n=[];let i="",o=0;for(let t=1;t(0,e.getTupleElements)(t).some((e=>{const t=(0,n.getParser)(e);return(0,n.isDynamicParser)(t,e)})),isType:e=>(e=>i.test(e))(e),getByteLength(t){if((0,n.isDynamicParser)(this,t))return 32;return(0,e.getTupleElements)(t).reduce(((e,t)=>e+(0,n.getParser)(t).getByteLength(t)),0)},encode({type:t,buffer:r,value:i,packed:o,tight:s}){const a=(0,e.getTupleElements)(t);return(0,n.pack)({types:a,values:i,byteArray:r,packed:o,tight:s})},decode({type:t,value:r,skip:i}){const o=(0,e.getTupleElements)(t);return i(this.getByteLength(t)-32),(0,n.unpack)(o,r)}}}(Zx)),Zx}var Jx={},Yx={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.number=e.getBigInt=e.assertNumberLength=e.getLength=e.isSigned=void 0;const t=tv,r=Px,n=zx,i=/^u?int(?[0-9]*)?$/u;e.isSigned=e=>!e.startsWith("u");e.getLength=e=>{if("int"===e||"uint"===e)return 256;const n=e.match(i);(0,t.assert)(n?.groups?.length,new r.ParserError(`Invalid number type. Expected a number type, but received "${e}".`));const o=parseInt(n.groups.length,10);return(0,t.assert)(o>=8&&o<=256,new r.ParserError(`Invalid number length. Expected a number between 8 and 256, but received "${e}".`)),(0,t.assert)(o%8==0,new r.ParserError(`Invalid number length. Expected a multiple of 8, but received "${e}".`)),o};e.assertNumberLength=(n,i)=>{const o=(0,e.getLength)(i),s=BigInt(2)**BigInt(o-((0,e.isSigned)(i)?1:0))-BigInt(1);(0,e.isSigned)(i)?(0,t.assert)(n>=-(s+BigInt(1))&&n<=s,new r.ParserError(`Number "${n}" is out of range for type "${i}".`)):(0,t.assert)(n<=s,new r.ParserError(`Number "${n}" is out of range for type "${i}".`))};e.getBigInt=e=>{try{return(0,t.createBigInt)(e)}catch{throw new r.ParserError(`Invalid number. Expected a valid number value, but received "${e}".`)}},e.number={isDynamic:!1,isType:e=>i.test(e),getByteLength:()=>32,encode({type:r,buffer:i,value:o,packed:s}){const a=(0,e.getBigInt)(o);if((0,e.assertNumberLength)(a,r),(0,e.isSigned)(r)){if(s){const n=(0,e.getLength)(r)/8;return(0,t.concatBytes)([i,(0,t.signedBigIntToBytes)(a,n)])}return(0,t.concatBytes)([i,(0,n.padStart)((0,t.signedBigIntToBytes)(a,32))])}if(s){const o=(0,e.getLength)(r)/8;return(0,t.concatBytes)([i,(0,n.padStart)((0,t.bigIntToBytes)(a),o)])}return(0,t.concatBytes)([i,(0,n.padStart)((0,t.bigIntToBytes)(a))])},decode({type:r,value:n}){const i=n.subarray(0,32);if((0,e.isSigned)(r)){const n=(0,t.bytesToSignedBigInt)(i);return(0,e.assertNumberLength)(n,r),n}const o=(0,t.bytesToBigInt)(i);return(0,e.assertNumberLength)(o,r),o}}}(Yx),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.bool=e.getBooleanValue=void 0;const t=nv,r=tv,n=Px,i=Yx,o=(0,t.coerce)((0,t.boolean)(),(0,t.union)([(0,t.literal)("true"),(0,t.literal)("false")]),(e=>"true"===e));e.getBooleanValue=e=>{try{return(0,t.create)(e,o)?BigInt(1):BigInt(0)}catch{throw new n.ParserError(`Invalid boolean value. Expected a boolean literal, or the string "true" or "false", but received "${e}".`)}},e.bool={isDynamic:!1,isType:e=>"bool"===e,getByteLength:()=>32,encode({buffer:t,value:n,packed:o,tight:s}){const a=(0,e.getBooleanValue)(n);return o?(0,r.concatBytes)([t,(0,r.bigIntToBytes)(a)]):i.number.encode({type:"uint256",buffer:t,value:a,packed:o,tight:s})},decode:e=>i.number.decode({...e,type:"uint256"})===BigInt(1)}}(Jx);var Xx={};Object.defineProperty(Xx,"__esModule",{value:!0}),Xx.bytes=void 0;const Qx=tv,ek=zx;Xx.bytes={isDynamic:!0,isType:e=>"bytes"===e,getByteLength:()=>32,encode({buffer:e,value:t,packed:r}){const n=(0,Qx.createBytes)(t);if(r)return(0,Qx.concatBytes)([e,n]);const i=32*Math.ceil(n.byteLength/32);return(0,Qx.concatBytes)([e,(0,ek.padStart)((0,Qx.numberToBytes)(n.byteLength)),(0,ek.padEnd)(n,i)])},decode({value:e}){const t=e.subarray(0,32),r=(0,Qx.bytesToNumber)(t);return e.slice(32,32+r)}};var tk={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.fn=e.getFunction=void 0;const t=nv,r=tv,n=Px,i=Kx,o=(0,t.coerce)((0,t.object)({address:r.StrictHexStruct,selector:r.StrictHexStruct}),(0,t.union)([r.StrictHexStruct,(0,t.instance)(Uint8Array)]),(e=>{const t=(0,r.createBytes)(e);return(0,r.assert)(24===t.length,new n.ParserError(`Invalid Solidity function. Expected function to be 24 bytes long, but received ${t.length} bytes.`)),{address:(0,r.bytesToHex)(t.subarray(0,20)),selector:(0,r.bytesToHex)(t.subarray(20,24))}}));e.getFunction=e=>{const n=(0,t.create)(e,o);return(0,r.concatBytes)([(0,r.hexToBytes)(n.address),(0,r.hexToBytes)(n.selector)])},e.fn={isDynamic:!1,isType:e=>"function"===e,getByteLength:()=>32,encode({buffer:t,value:r,packed:n,tight:o}){const s=(0,e.getFunction)(r);return i.fixedBytes.encode({type:"bytes24",buffer:t,value:s,packed:n,tight:o})},decode:({value:e})=>({address:(0,r.bytesToHex)(e.slice(0,20)),selector:(0,r.bytesToHex)(e.slice(20,24))})}}(tk);var rk={};Object.defineProperty(rk,"__esModule",{value:!0});var nk={};Object.defineProperty(nk,"__esModule",{value:!0}),nk.string=void 0;const ik=tv,ok=Xx;var sk,ak;function ck(){return sk||(sk=1,function(e){var t=Cr&&Cr.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=Cr&&Cr.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(Hx,e),r((Vx||(Vx=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.array=e.getTupleType=e.getArrayType=e.isArrayType=void 0;const t=tv,r=Px,n=uk(),i=zx,o=Kx,s=Gx(),a=/^(?.*)\[(?\d*?)\]$/u;e.isArrayType=e=>a.test(e),e.getArrayType=e=>{const n=e.match(a);return(0,t.assert)(n?.groups?.type,new r.ParserError(`Invalid array type. Expected an array type, but received "${e}".`)),[n.groups.type,n.groups.length?parseInt(n.groups.length,10):void 0]},e.getTupleType=(e,t)=>`(${new Array(t).fill(e).join(",")})`,e.array={isDynamic(t){const[r,i]=(0,e.getArrayType)(t);return void 0===i||(0,n.isDynamicParser)((0,n.getParser)(r),r)},isType:t=>(0,e.isArrayType)(t),getByteLength(i){(0,t.assert)((0,e.isArrayType)(i),new r.ParserError(`Expected an array type, but received "${i}".`));const[o,a]=(0,e.getArrayType)(i);return(0,n.isDynamicParser)(this,i)||void 0===a?32:s.tuple.getByteLength((0,e.getTupleType)(o,a))},encode({type:a,buffer:c,value:u,packed:h,tight:l}){const[f,d]=(0,e.getArrayType)(a);if((0,t.assert)(!h||!(0,e.isArrayType)(f),new r.ParserError("Cannot pack nested arrays.")),h&&(0,n.isDynamicParser)((0,n.getParser)(f),f))return(0,n.pack)({types:new Array(u.length).fill(f),values:u,byteArray:c,packed:h,arrayPacked:!0,tight:l});if(d)return(0,t.assert)(d===u.length,new r.ParserError(`Array length does not match type length. Expected a length of ${d}, but received ${u.length}.`)),s.tuple.encode({type:(0,e.getTupleType)(f,d),buffer:c,value:u,packed:o.fixedBytes.isType(f)&&l,tight:l});if(h)return(0,n.pack)({types:new Array(u.length).fill(f),values:u,byteArray:c,packed:o.fixedBytes.isType(f)&&l,arrayPacked:!0,tight:l});const p=(0,i.padStart)((0,t.numberToBytes)(u.length));return(0,n.pack)({types:new Array(u.length).fill(f),values:u,byteArray:(0,t.concatBytes)([c,p]),packed:h,tight:l})},decode({type:i,value:o,...a}){const[c,u]=(0,e.getArrayType)(i);if(u){const n=s.tuple.decode({type:(0,e.getTupleType)(c,u),value:o,...a});return(0,t.assert)(n.length===u,new r.ParserError(`Array length does not match type length. Expected a length of ${u}, but received ${n.length}.`)),n}const h=(0,t.bytesToNumber)(o.subarray(0,32));return(0,n.unpack)(new Array(h).fill(c),o.subarray(32))}}}(qx)),qx),e),r(Jx,e),r(Xx,e),r(Kx,e),r(tk,e),r(Yx,e),r(rk,e),r(nk,e),r(Gx(),e)}($x)),$x}function uk(){return ak||(ak=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.unpack=e.pack=e.isDynamicParser=e.getParser=void 0;const t=tv,r=Px,n=Ux,i=ck(),o=zx;e.getParser=e=>{const t={address:i.address,array:i.array,bool:i.bool,bytes:i.bytes,fixedBytes:i.fixedBytes,function:i.fn,number:i.number,string:i.string,tuple:i.tuple},n=t[e];if(n)return n;const o=Object.values(t).find((t=>t.isType(e)));if(o)return o;throw new r.ParserError(`The type "${e}" is not supported.`)};e.isDynamicParser=(e,t)=>{const{isDynamic:r}=e;return"function"==typeof r?r(t):r};e.pack=({types:n,values:i,packed:s=!1,tight:a=!1,arrayPacked:c=!1,byteArray:u=new Uint8Array})=>{(0,t.assert)(n.length===i.length,new r.ParserError(`The number of types (${n.length}) does not match the number of values (${i.length}).`));const{staticBuffer:h,dynamicBuffer:l,pointers:f}=n.reduce((({staticBuffer:r,dynamicBuffer:n,pointers:o},u,h)=>{const l=(0,e.getParser)(u),f=i[h];if(s||c||!(0,e.isDynamicParser)(l,u))return{staticBuffer:l.encode({buffer:r,value:f,type:u,packed:s,tight:a}),dynamicBuffer:n,pointers:o};return{staticBuffer:(0,t.concatBytes)([r,new Uint8Array(32)]),dynamicBuffer:l.encode({buffer:n,value:f,type:u,packed:s,tight:a}),pointers:[...o,{position:r.length,pointer:n.length}]}}),{staticBuffer:new Uint8Array,dynamicBuffer:new Uint8Array,pointers:[]});(0,t.assert)(!s&&!c||0===l.length,new r.ParserError("Invalid pack state."));const d=h.length,p=f.reduce(((e,{pointer:r,position:n})=>{const i=(0,o.padStart)((0,t.numberToBytes)(d+r));return(0,o.set)(e,i,n)}),h);return(0,t.concatBytes)([u,p,l])};e.unpack=(i,o)=>{const s=(0,n.iterate)(o);return i.map((n=>{const{value:{value:i,skip:a},done:c}=s.next();(0,t.assert)(!c,new r.ParserError(`The encoded value is invalid for the provided types. Reached end of buffer while attempting to parse "${n}".`));const u=(0,e.getParser)(n);if((0,e.isDynamicParser)(u,n)){const e=(0,t.bytesToNumber)(i.subarray(0,32)),r=o.subarray(e);return u.decode({type:n,value:r,skip:a})}return u.decode({type:n,value:i,skip:a})}))}}(Nx)),Nx}nk.string={isDynamic:!0,isType:e=>"string"===e,getByteLength:()=>32,encode:({buffer:e,value:t,packed:r,tight:n})=>ok.bytes.encode({type:"bytes",buffer:e,value:(0,ik.stringToBytes)(t),packed:r,tight:n}),decode:e=>(0,ik.bytesToString)(ok.bytes.decode(e))},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.decodeSingle=e.decode=e.encodePacked=e.encodeSingle=e.encode=void 0;const t=tv,r=Px,n=uk();e.encode=(e,t,i,o)=>{try{return(0,n.pack)({types:e,values:t,packed:i,tight:o})}catch(e){if(e instanceof r.ParserError)throw new r.ParserError(`Unable to encode value: ${e.message}`,e);throw new r.ParserError(`An unexpected error occurred: ${(0,r.getErrorMessage)(e)}`,e)}};e.encodeSingle=(t,r)=>(0,e.encode)([t],[r]);e.encodePacked=(t,r,n)=>(0,e.encode)(t,r,!0,n);e.decode=(e,i)=>{const o=(0,t.createBytes)(i);try{return(0,n.unpack)(e,o)}catch(e){if(e instanceof r.ParserError)throw new r.ParserError(`Unable to decode value: ${e.message}`,e);throw new r.ParserError(`An unexpected error occurred: ${(0,r.getErrorMessage)(e)}`,e)}};e.decodeSingle=(n,i)=>{const o=(0,e.decode)([n],i);return(0,t.assert)(1===o.length,new r.ParserError("Decoded value array has unexpected length.")),o[0]}}(Cx);var hk={},lk={};Object.defineProperty(lk,"__esModule",{value:!0}),function(e){var t=Cr&&Cr.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=Cr&&Cr.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(lk,e)}(hk),function(e){var t=Cr&&Cr.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=Cr&&Cr.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),r(Cx,e),r(Px,e),r(hk,e)}(Mx);var fk={},dk={},pk={};function gk(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function yk(e){if("boolean"!=typeof e)throw new Error(`boolean expected, not ${e}`)}function mk(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}function wk(e,...t){if(!mk(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function bk(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");gk(e.outputLen),gk(e.blockLen)}function vk(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function _k(e,t){wk(e);const r=t.outputLen;if(e.length>xk&Ak)}:{h:0|Number(e>>xk&Ak),l:0|Number(e&Ak)}}function Bk(e,t=!1){let r=new Uint32Array(e.length),n=new Uint32Array(e.length);for(let i=0;iBigInt(e>>>0)<>>0);Sk.toBig=Ik;const Tk=(e,t,r)=>e>>>r;Sk.shrSH=Tk;const Rk=(e,t,r)=>e<<32-r|t>>>r;Sk.shrSL=Rk;const Ok=(e,t,r)=>e>>>r|t<<32-r;Sk.rotrSH=Ok;const Lk=(e,t,r)=>e<<32-r|t>>>r;Sk.rotrSL=Lk;const Mk=(e,t,r)=>e<<64-r|t>>>r-32;Sk.rotrBH=Mk;const Ck=(e,t,r)=>e>>>r-32|t<<64-r;Sk.rotrBL=Ck;const Pk=(e,t)=>t;Sk.rotr32H=Pk;const Nk=(e,t)=>e;Sk.rotr32L=Nk;const Uk=(e,t,r)=>e<>>32-r;Sk.rotlSH=Uk;const jk=(e,t,r)=>t<>>32-r;Sk.rotlSL=jk;const $k=(e,t,r)=>t<>>64-r;Sk.rotlBH=$k;const Hk=(e,t,r)=>e<>>64-r;function zk(e,t,r,n){const i=(t>>>0)+(n>>>0);return{h:e+r+(i/2**32|0)|0,l:0|i}}Sk.rotlBL=Hk,Sk.add=zk;const Dk=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0);Sk.add3L=Dk;const Fk=(e,t,r,n)=>t+r+n+(e/2**32|0)|0;Sk.add3H=Fk;const qk=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0);Sk.add4L=qk;const Kk=(e,t,r,n,i)=>t+r+n+i+(e/2**32|0)|0;Sk.add4H=Kk;const Wk=(e,t,r,n,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(i>>>0);Sk.add5L=Wk;const Vk=(e,t,r,n,i,o)=>t+r+n+i+o+(e/2**32|0)|0;Sk.add5H=Vk;const Zk={fromBig:kk,split:Bk,toBig:Ik,shrSH:Tk,shrSL:Rk,rotrSH:Ok,rotrSL:Lk,rotrBH:Mk,rotrBL:Ck,rotr32H:Pk,rotr32L:Nk,rotlSH:Uk,rotlSL:jk,rotlBH:$k,rotlBL:Hk,add:zk,add3L:Dk,add3H:Fk,add4L:qk,add4H:Kk,add5H:Vk,add5L:Wk};Sk.default=Zk;var Gk={},Jk={};Object.defineProperty(Jk,"__esModule",{value:!0}),Jk.crypto=void 0,Jk.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,function(e){ +/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */ +Object.defineProperty(e,"__esModule",{value:!0}),e.randomBytes=e.wrapXOFConstructorWithOpts=e.wrapConstructorWithOpts=e.wrapConstructor=e.checkOpts=e.Hash=e.concatBytes=e.toBytes=e.utf8ToBytes=e.asyncLoop=e.nextTick=e.hexToBytes=e.bytesToHex=e.byteSwap32=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=e.isBytes=void 0;const t=Jk,r=pk;e.isBytes=function(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name};e.u8=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength);e.u32=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));e.createView=e=>new DataView(e.buffer,e.byteOffset,e.byteLength);e.rotr=(e,t)=>e<<32-t|e>>>t;e.rotl=(e,t)=>e<>>32-t>>>0,e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];e.byteSwap=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255,e.byteSwapIfBE=e.isLE?e=>e:t=>(0,e.byteSwap)(t),e.byteSwap32=function(t){for(let r=0;rt.toString(16).padStart(2,"0")));e.bytesToHex=function(e){(0,r.bytes)(e);let t="";for(let r=0;r=i&&e<=o?e-i:e>=s&&e<=a?e-(s-10):e>=c&&e<=u?e-(c-10):void 0}e.hexToBytes=function(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,r=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(r);for(let t=0,i=0;t{},e.asyncLoop=async function(t,r,n){let i=Date.now();for(let o=0;o=0&&te().update(f(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t},e.wrapConstructorWithOpts=function(e){const t=(t,r)=>e(r).update(f(t)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=t=>e(t),t},e.wrapXOFConstructorWithOpts=function(e){const t=(t,r)=>e(r).update(f(t)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=t=>e(t),t},e.randomBytes=function(e=32){if(t.crypto&&"function"==typeof t.crypto.getRandomValues)return t.crypto.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}}(Gk),Object.defineProperty(dk,"__esModule",{value:!0}),dk.shake256=dk.shake128=dk.keccak_512=dk.keccak_384=dk.keccak_256=dk.keccak_224=dk.sha3_512=dk.sha3_384=dk.sha3_256=dk.sha3_224=dk.Keccak=dk.keccakP=void 0;const Yk=pk,Xk=Sk,Qk=Gk,eB=[],tB=[],rB=[],nB=BigInt(0),iB=BigInt(1),oB=BigInt(2),sB=BigInt(7),aB=BigInt(256),cB=BigInt(113);for(let e=0,t=iB,r=1,n=0;e<24;e++){[r,n]=[n,(2*r+3*n)%5],eB.push(2*(5*n+r)),tB.push((e+1)*(e+2)/2%64);let i=nB;for(let e=0;e<7;e++)t=(t<>sB)*cB)%aB,t&oB&&(i^=iB<<(iB<r>32?(0,Xk.rotlBH)(e,t,r):(0,Xk.rotlSH)(e,t,r),fB=(e,t,r)=>r>32?(0,Xk.rotlBL)(e,t,r):(0,Xk.rotlSL)(e,t,r);function dB(e,t=24){const r=new Uint32Array(10);for(let n=24-t;n<24;n++){for(let t=0;t<10;t++)r[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){const n=(t+8)%10,i=(t+2)%10,o=r[i],s=r[i+1],a=lB(o,s,1)^r[n],c=fB(o,s,1)^r[n+1];for(let r=0;r<50;r+=10)e[t+r]^=a,e[t+r+1]^=c}let t=e[2],i=e[3];for(let r=0;r<24;r++){const n=tB[r],o=lB(t,i,n),s=fB(t,i,n),a=eB[r];t=e[a],i=e[a+1],e[a]=o,e[a+1]=s}for(let t=0;t<50;t+=10){for(let n=0;n<10;n++)r[n]=e[t+n];for(let n=0;n<10;n++)e[t+n]^=~r[(n+2)%10]&r[(n+4)%10]}e[0]^=uB[n],e[1]^=hB[n]}r.fill(0)}dk.keccakP=dB;class pB extends Qk.Hash{constructor(e,t,r,n=!1,i=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=n,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,(0,Yk.number)(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=(0,Qk.u32)(this.state)}keccak(){Qk.isLE||(0,Qk.byteSwap32)(this.state32),dB(this.state32,this.rounds),Qk.isLE||(0,Qk.byteSwap32)(this.state32),this.posOut=0,this.pos=0}update(e){(0,Yk.exists)(this);const{blockLen:t,state:r}=this,n=(e=(0,Qk.toBytes)(e)).length;for(let i=0;i=r&&this.keccak();const o=Math.min(r-this.posOut,i-n);e.set(t.subarray(this.posOut,this.posOut+o),n),this.posOut+=o,n+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return(0,Yk.number)(e),this.xofInto(new Uint8Array(e))}digestInto(e){if((0,Yk.output)(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:r,outputLen:n,rounds:i,enableXOF:o}=this;return e||(e=new pB(t,r,n,o,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=r,e.outputLen=n,e.enableXOF=o,e.destroyed=this.destroyed,e}}dk.Keccak=pB;const gB=(e,t,r)=>(0,Qk.wrapConstructor)((()=>new pB(t,e,r)));dk.sha3_224=gB(6,144,28),dk.sha3_256=gB(6,136,32),dk.sha3_384=gB(6,104,48),dk.sha3_512=gB(6,72,64),dk.keccak_224=gB(1,144,28),dk.keccak_256=gB(1,136,32),dk.keccak_384=gB(1,104,48),dk.keccak_512=gB(1,72,64);const yB=(e,t,r)=>(0,Qk.wrapXOFConstructorWithOpts)(((n={})=>new pB(t,e,void 0===n.dkLen?r:n.dkLen,!0)));dk.shake128=yB(31,168,16),dk.shake256=yB(31,136,32);var mB={exports:{}};!function(e,t){var r=Cr&&Cr.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.crypto=t.utf8ToBytes=t.createView=t.concatBytes=t.toHex=t.bytesToHex=t.assertBytes=t.assertBool=void 0,t.bytesToUtf8=function(e){if(!(e instanceof Uint8Array))throw new TypeError("bytesToUtf8 expected Uint8Array, got "+typeof e);return(new TextDecoder).decode(e)},t.hexToBytes=function(e){const t=e.startsWith("0x")?e.substring(2):e;return(0,i.hexToBytes)(t)},t.equalsBytes=function(e,t){if(e.length!==t.length)return!1;for(let r=0;r(n.default.bytes(t),e(t))};const n=r(pk),i=Gk,o=n.default.bool;t.assertBool=o;const s=n.default.bytes;t.assertBytes=s;var a=Gk;Object.defineProperty(t,"bytesToHex",{enumerable:!0,get:function(){return a.bytesToHex}}),Object.defineProperty(t,"toHex",{enumerable:!0,get:function(){return a.bytesToHex}}),Object.defineProperty(t,"concatBytes",{enumerable:!0,get:function(){return a.concatBytes}}),Object.defineProperty(t,"createView",{enumerable:!0,get:function(){return a.createView}}),Object.defineProperty(t,"utf8ToBytes",{enumerable:!0,get:function(){return a.utf8ToBytes}}),t.crypto=(()=>{const t="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,r=yd.bind(e);return{node:r&&!t?r("crypto"):void 0,web:t}})()}(mB,mB.exports),Object.defineProperty(fk,"__esModule",{value:!0}),fk.keccak512=fk.keccak384=fk.keccak256=fk.keccak224=void 0;const wB=dk,bB=mB.exports;fk.keccak224=(0,bB.wrapHash)(wB.keccak_224),fk.keccak256=(()=>{const e=(0,bB.wrapHash)(wB.keccak_256);return e.create=wB.keccak_256.create,e})(),fk.keccak384=(0,bB.wrapHash)(wB.keccak_384),fk.keccak512=(0,bB.wrapHash)(wB.keccak_512),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.recoverTypedSignature=e.signTypedData=e.typedSignatureHash=e.TypedDataUtils=e.TYPED_MESSAGE_SCHEMA=e.SignTypedDataVersion=void 0;const t=bh,r=Mx,n=ck(),i=zx,o=tv,s=fk,a=ev;var c;function u(e,t){if(!Object.keys(c).includes(e))throw new Error(`Invalid version: '${e}'`);if(t&&!t.includes(e))throw new Error(`SignTypedDataVersion not allowed: '${e}'. Allowed versions are: ${t.join(", ")}`)}function h(e,t){(0,o.assert)(null!==t,`Unable to encode value: Invalid number. Expected a valid number value, but received "${t}".`);const r=BigInt(t),i=(0,n.getLength)(e),s=BigInt(2)**BigInt(i)-BigInt(1);return(0,o.assert)(r>=-s&&r<=s,`Unable to encode value: Number "${t}" is out of range for type "${e}".`),r}function l(e){let t=BigInt(0);for(let r=0;r=49?n-BigInt(49)+BigInt(10):n>=17?n-BigInt(17)+BigInt(10):n}return(0,i.padStart)((0,o.bigIntToBytes)(t),20)}function f(e,n,a,p,g){if(u(g,[c.V3,c.V4]),void 0!==e[a])return["bytes32",g===c.V4&&null==p?"0x0000000000000000000000000000000000000000000000000000000000000000":(0,t.arrToBufArr)((0,s.keccak256)(d(a,p,e,g)))];if("function"===a)throw new Error('Unsupported or invalid type: "function"');if(void 0===p)throw new Error(`missing value for field ${n} of type ${a}`);if("address"===a){if("number"==typeof p)return["address",(0,i.padStart)((0,o.numberToBytes)(p),20)];if((0,o.isStrictHexString)(p))return["address",(0,o.add0x)(p)];if("string"==typeof p)return["address",l(p).subarray(0,20)]}if("bool"===a)return["bool",Boolean(p)];if("bytes"===a)return"number"==typeof p?p=(0,o.numberToBytes)(p):(0,o.isStrictHexString)(p)||"0x"===p?p=(0,o.hexToBytes)(p):"string"==typeof p&&(p=(0,o.stringToBytes)(p)),["bytes32",(0,t.arrToBufArr)((0,s.keccak256)(p))];if(a.startsWith("bytes")&&"bytes"!==a&&!a.includes("["))return"number"==typeof p?p<0?["bytes32",new Uint8Array(32)]:["bytes32",(0,o.bigIntToBytes)(BigInt(p))]:(0,o.isStrictHexString)(p)?["bytes32",(0,o.hexToBytes)(p)]:["bytes32",p];if(a.startsWith("int")&&!a.includes("[")){const e=h(a,p);return e>=BigInt(0)?["uint256",e]:["int256",e]}if("string"===a)return p="number"==typeof p?(0,o.numberToBytes)(p):(0,o.stringToBytes)(null!=p?p:""),["bytes32",(0,t.arrToBufArr)((0,s.keccak256)(p))];if(a.endsWith("]")){if(g===c.V3)throw new Error("Arrays are unimplemented in encodeData; use V4 extension");const i=a.slice(0,a.lastIndexOf("[")),o=p.map((t=>f(e,n,i,t,g)));return["bytes32",(0,t.arrToBufArr)((0,s.keccak256)((0,r.encode)(o.map((([e])=>e)),o.map((([,e])=>e)))))]}return[a,p]}function d(e,n,i,o){u(o,[c.V3,c.V4]);const s=["bytes32"],a=[m(e,i)];for(const t of i[e]){if(o===c.V3&&void 0===n[t.name])continue;const[e,r]=f(i,t.name,t.type,n[t.name],o);s.push(e),a.push(r)}return(0,t.arrToBufArr)((0,r.encode)(s,a))}function p(e,t){let r="";const n=g(e,t);n.delete(e);const i=[e,...Array.from(n).sort()];for(const e of i){if(!t[e])throw new Error(`No type definition specified: ${e}`);r+=`${e}(${t[e].map((({name:e,type:t})=>`${t} ${e}`)).join(",")})`}return r}function g(e,t,r=new Set){if("string"!=typeof e)throw new Error(`Invalid findTypeDependencies input ${JSON.stringify(e)}`);const n=e.match(/^\w*/u);if([e]=n,r.has(e)||void 0===t[e])return r;r.add(e);for(const n of t[e])g(n.type,t,r);return r}function y(e,r,n,i){u(i,[c.V3,c.V4]);const o=d(e,r,n,i),a=(0,s.keccak256)(o);return(0,t.arrToBufArr)(a)}function m(e,r){const n=(0,o.stringToBytes)(p(e,r));return(0,t.arrToBufArr)((0,s.keccak256)(n))}function w(t){const r={};for(const n in e.TYPED_MESSAGE_SCHEMA.properties)t[n]&&(r[n]=t[n]);return"types"in r&&(r.types=Object.assign({EIP712Domain:[]},r.types)),r}function b(e,t){u(t,[c.V3,c.V4]);const r=w(e),{domain:n}=r;return y("EIP712Domain",n,{EIP712Domain:r.types.EIP712Domain},t)}function v(e,t){if((0,n.isArrayType)(e)&&Array.isArray(t)){const[r]=(0,n.getArrayType)(e);return t.map((e=>v(r,e)))}if("address"===e){if("number"==typeof t)return(0,i.padStart)((0,o.numberToBytes)(t),20);if((0,o.isStrictHexString)(t))return(0,i.padStart)((0,o.hexToBytes)(t).subarray(0,20),20);if(t instanceof Uint8Array)return(0,i.padStart)(t.subarray(0,20),20)}if("bool"===e)return Boolean(t);if(e.startsWith("bytes")&&"bytes"!==e){const r=(0,n.getByteLength)(e);if("number"==typeof t)return t<0?new Uint8Array:(0,o.numberToBytes)(t).subarray(0,r);if((0,o.isStrictHexString)(t))return(0,o.hexToBytes)(t).subarray(0,r);if(t instanceof Uint8Array)return t.subarray(0,r)}if(e.startsWith("uint")&&"number"==typeof t)return Math.abs(t);if(e.startsWith("int")&&"number"==typeof t){const r=(0,n.getLength)(e);return BigInt.asIntN(r,BigInt(t))}return t}function _(e,t){return t.map((t=>{if("string"==typeof t||"number"==typeof t||"bigint"==typeof t){const r=h(e,t);if(r>=BigInt(0))return(0,i.padStart)((0,o.bigIntToBytes)(r),32);const s=(0,n.getLength)(e),a=BigInt.asIntN(s,r);return(0,o.signedBigIntToBytes)(a,32)}return t}))}function E(e){const c=new Error("Expect argument to be non-empty array");if("object"!=typeof e||!("length"in e)||!e.length)throw c;const u=e.map((({name:e,type:t,value:r})=>{if("address[]"===t)return{name:e,type:"bytes32[]",value:(s=r,s.map((e=>"number"==typeof e?(0,i.padStart)((0,o.numberToBytes)(e),32):(0,o.isStrictHexString)(e)?(0,i.padStart)((0,o.hexToBytes)(e).subarray(0,32),32):e instanceof Uint8Array?(0,i.padStart)(e.subarray(0,32),32):e)))};var s;if(t.startsWith("int")&&(0,n.isArrayType)(t)){const[i,o]=(0,n.getArrayType)(t);return{name:e,type:`bytes32[${null!=o?o:""}]`,value:_(i,r)}}return{name:e,type:t,value:v(t,r)}})),h=u.map((e=>"bytes"!==e.type?e.value:(0,a.legacyToBuffer)(e.value))),l=u.map((e=>{if("function"===e.type)throw new Error('Unsupported or invalid type: "function"');return e.type})),f=e.map((e=>{if(!e.name)throw c;return`${e.type} ${e.name}`}));return(0,t.arrToBufArr)((0,s.keccak256)((0,r.encodePacked)(["bytes32","bytes32"],[(0,s.keccak256)((0,r.encodePacked)(["string[]"],[f],!0)),(0,s.keccak256)((0,r.encodePacked)(l,h,!0))])))}!function(e){e.V1="V1",e.V3="V3",e.V4="V4"}(c=e.SignTypedDataVersion||(e.SignTypedDataVersion={})),e.TYPED_MESSAGE_SCHEMA={type:"object",properties:{types:{type:"object",additionalProperties:{type:"array",items:{type:"object",properties:{name:{type:"string"},type:{type:"string"}},required:["name","type"]}}},primaryType:{type:"string"},domain:{type:"object"},message:{type:"object"}},required:["types","primaryType","domain","message"]},e.TypedDataUtils={encodeData:d,encodeType:p,findTypeDependencies:g,hashStruct:y,hashType:m,sanitizeData:w,eip712Hash:function(e,r){u(r,[c.V3,c.V4]);const n=w(e),i=[(0,o.hexToBytes)("1901")];return i.push(b(e,r)),"EIP712Domain"!==n.primaryType&&i.push(y(n.primaryType,n.message,n.types,r)),(0,t.arrToBufArr)((0,s.keccak256)((0,o.concatBytes)(i)))},eip712DomainHash:b},e.typedSignatureHash=function(e){const t=E(e);return(0,o.bytesToHex)(t)},e.signTypedData=function({privateKey:r,data:n,version:i}){if(u(i),(0,a.isNullish)(n))throw new Error("Missing data parameter");if((0,a.isNullish)(r))throw new Error("Missing private key parameter");const s=i===c.V1?E(n):e.TypedDataUtils.eip712Hash(n,i),h=(0,t.ecsign)(s,r);return(0,a.concatSig)((0,t.arrToBufArr)((0,o.bigIntToBytes)(h.v)),h.r,h.s)},e.recoverTypedSignature=function({data:r,signature:n,version:i}){if(u(i),(0,a.isNullish)(r))throw new Error("Missing data parameter");if((0,a.isNullish)(n))throw new Error("Missing signature parameter");const s=i===c.V1?E(r):e.TypedDataUtils.eip712Hash(r,i),h=(0,a.recoverPublicKey)(s,n),l=(0,t.publicToAddress)(h);return(0,o.bytesToHex)(l)}}(Lx);var vB={},_B={exports:{}},EB=Pr(Object.freeze({__proto__:null,default:{}}));!function(e){!function(e){var t=function(e){var t,r=new Float64Array(16);if(e)for(t=0;t>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r,e[t+4]=n>>24&255,e[t+5]=n>>16&255,e[t+6]=n>>8&255,e[t+7]=255&n}function p(e,t,r,n,i){var o,s=0;for(o=0;o>>8)-1}function g(e,t,r,n){return p(e,t,r,n,16)}function y(e,t,r,n){return p(e,t,r,n,32)}function m(e,t,r,n){!function(e,t,r,n){for(var i,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,a=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,c=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,u=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,h=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,l=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,f=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,d=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,p=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,g=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,y=255&r[16]|(255&r[17])<<8|(255&r[18])<<16|(255&r[19])<<24,m=255&r[20]|(255&r[21])<<8|(255&r[22])<<16|(255&r[23])<<24,w=255&r[24]|(255&r[25])<<8|(255&r[26])<<16|(255&r[27])<<24,b=255&r[28]|(255&r[29])<<8|(255&r[30])<<16|(255&r[31])<<24,v=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,_=o,E=s,S=a,A=c,x=u,k=h,B=l,I=f,T=d,R=p,O=g,L=y,M=m,C=w,P=b,N=v,U=0;U<20;U+=2)_^=(i=(M^=(i=(T^=(i=(x^=(i=_+M|0)<<7|i>>>25)+_|0)<<9|i>>>23)+x|0)<<13|i>>>19)+T|0)<<18|i>>>14,k^=(i=(E^=(i=(C^=(i=(R^=(i=k+E|0)<<7|i>>>25)+k|0)<<9|i>>>23)+R|0)<<13|i>>>19)+C|0)<<18|i>>>14,O^=(i=(B^=(i=(S^=(i=(P^=(i=O+B|0)<<7|i>>>25)+O|0)<<9|i>>>23)+P|0)<<13|i>>>19)+S|0)<<18|i>>>14,N^=(i=(L^=(i=(I^=(i=(A^=(i=N+L|0)<<7|i>>>25)+N|0)<<9|i>>>23)+A|0)<<13|i>>>19)+I|0)<<18|i>>>14,_^=(i=(A^=(i=(S^=(i=(E^=(i=_+A|0)<<7|i>>>25)+_|0)<<9|i>>>23)+E|0)<<13|i>>>19)+S|0)<<18|i>>>14,k^=(i=(x^=(i=(I^=(i=(B^=(i=k+x|0)<<7|i>>>25)+k|0)<<9|i>>>23)+B|0)<<13|i>>>19)+I|0)<<18|i>>>14,O^=(i=(R^=(i=(T^=(i=(L^=(i=O+R|0)<<7|i>>>25)+O|0)<<9|i>>>23)+L|0)<<13|i>>>19)+T|0)<<18|i>>>14,N^=(i=(P^=(i=(C^=(i=(M^=(i=N+P|0)<<7|i>>>25)+N|0)<<9|i>>>23)+M|0)<<13|i>>>19)+C|0)<<18|i>>>14;_=_+o|0,E=E+s|0,S=S+a|0,A=A+c|0,x=x+u|0,k=k+h|0,B=B+l|0,I=I+f|0,T=T+d|0,R=R+p|0,O=O+g|0,L=L+y|0,M=M+m|0,C=C+w|0,P=P+b|0,N=N+v|0,e[0]=_>>>0&255,e[1]=_>>>8&255,e[2]=_>>>16&255,e[3]=_>>>24&255,e[4]=E>>>0&255,e[5]=E>>>8&255,e[6]=E>>>16&255,e[7]=E>>>24&255,e[8]=S>>>0&255,e[9]=S>>>8&255,e[10]=S>>>16&255,e[11]=S>>>24&255,e[12]=A>>>0&255,e[13]=A>>>8&255,e[14]=A>>>16&255,e[15]=A>>>24&255,e[16]=x>>>0&255,e[17]=x>>>8&255,e[18]=x>>>16&255,e[19]=x>>>24&255,e[20]=k>>>0&255,e[21]=k>>>8&255,e[22]=k>>>16&255,e[23]=k>>>24&255,e[24]=B>>>0&255,e[25]=B>>>8&255,e[26]=B>>>16&255,e[27]=B>>>24&255,e[28]=I>>>0&255,e[29]=I>>>8&255,e[30]=I>>>16&255,e[31]=I>>>24&255,e[32]=T>>>0&255,e[33]=T>>>8&255,e[34]=T>>>16&255,e[35]=T>>>24&255,e[36]=R>>>0&255,e[37]=R>>>8&255,e[38]=R>>>16&255,e[39]=R>>>24&255,e[40]=O>>>0&255,e[41]=O>>>8&255,e[42]=O>>>16&255,e[43]=O>>>24&255,e[44]=L>>>0&255,e[45]=L>>>8&255,e[46]=L>>>16&255,e[47]=L>>>24&255,e[48]=M>>>0&255,e[49]=M>>>8&255,e[50]=M>>>16&255,e[51]=M>>>24&255,e[52]=C>>>0&255,e[53]=C>>>8&255,e[54]=C>>>16&255,e[55]=C>>>24&255,e[56]=P>>>0&255,e[57]=P>>>8&255,e[58]=P>>>16&255,e[59]=P>>>24&255,e[60]=N>>>0&255,e[61]=N>>>8&255,e[62]=N>>>16&255,e[63]=N>>>24&255}(e,t,r,n)}function w(e,t,r,n){!function(e,t,r,n){for(var i,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,a=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,c=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,u=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,h=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,l=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,f=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,d=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,p=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,g=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,y=255&r[16]|(255&r[17])<<8|(255&r[18])<<16|(255&r[19])<<24,m=255&r[20]|(255&r[21])<<8|(255&r[22])<<16|(255&r[23])<<24,w=255&r[24]|(255&r[25])<<8|(255&r[26])<<16|(255&r[27])<<24,b=255&r[28]|(255&r[29])<<8|(255&r[30])<<16|(255&r[31])<<24,v=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,_=0;_<20;_+=2)o^=(i=(m^=(i=(d^=(i=(u^=(i=o+m|0)<<7|i>>>25)+o|0)<<9|i>>>23)+u|0)<<13|i>>>19)+d|0)<<18|i>>>14,h^=(i=(s^=(i=(w^=(i=(p^=(i=h+s|0)<<7|i>>>25)+h|0)<<9|i>>>23)+p|0)<<13|i>>>19)+w|0)<<18|i>>>14,g^=(i=(l^=(i=(a^=(i=(b^=(i=g+l|0)<<7|i>>>25)+g|0)<<9|i>>>23)+b|0)<<13|i>>>19)+a|0)<<18|i>>>14,v^=(i=(y^=(i=(f^=(i=(c^=(i=v+y|0)<<7|i>>>25)+v|0)<<9|i>>>23)+c|0)<<13|i>>>19)+f|0)<<18|i>>>14,o^=(i=(c^=(i=(a^=(i=(s^=(i=o+c|0)<<7|i>>>25)+o|0)<<9|i>>>23)+s|0)<<13|i>>>19)+a|0)<<18|i>>>14,h^=(i=(u^=(i=(f^=(i=(l^=(i=h+u|0)<<7|i>>>25)+h|0)<<9|i>>>23)+l|0)<<13|i>>>19)+f|0)<<18|i>>>14,g^=(i=(p^=(i=(d^=(i=(y^=(i=g+p|0)<<7|i>>>25)+g|0)<<9|i>>>23)+y|0)<<13|i>>>19)+d|0)<<18|i>>>14,v^=(i=(b^=(i=(w^=(i=(m^=(i=v+b|0)<<7|i>>>25)+v|0)<<9|i>>>23)+m|0)<<13|i>>>19)+w|0)<<18|i>>>14;e[0]=o>>>0&255,e[1]=o>>>8&255,e[2]=o>>>16&255,e[3]=o>>>24&255,e[4]=h>>>0&255,e[5]=h>>>8&255,e[6]=h>>>16&255,e[7]=h>>>24&255,e[8]=g>>>0&255,e[9]=g>>>8&255,e[10]=g>>>16&255,e[11]=g>>>24&255,e[12]=v>>>0&255,e[13]=v>>>8&255,e[14]=v>>>16&255,e[15]=v>>>24&255,e[16]=l>>>0&255,e[17]=l>>>8&255,e[18]=l>>>16&255,e[19]=l>>>24&255,e[20]=f>>>0&255,e[21]=f>>>8&255,e[22]=f>>>16&255,e[23]=f>>>24&255,e[24]=d>>>0&255,e[25]=d>>>8&255,e[26]=d>>>16&255,e[27]=d>>>24&255,e[28]=p>>>0&255,e[29]=p>>>8&255,e[30]=p>>>16&255,e[31]=p>>>24&255}(e,t,r,n)}var b=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function v(e,t,r,n,i,o,s){var a,c,u=new Uint8Array(16),h=new Uint8Array(64);for(c=0;c<16;c++)u[c]=0;for(c=0;c<8;c++)u[c]=o[c];for(;i>=64;){for(m(h,u,s,b),c=0;c<64;c++)e[t+c]=r[n+c]^h[c];for(a=1,c=8;c<16;c++)a=a+(255&u[c])|0,u[c]=255&a,a>>>=8;i-=64,t+=64,n+=64}if(i>0)for(m(h,u,s,b),c=0;c=64;){for(m(c,a,i,b),s=0;s<64;s++)e[t+s]=c[s];for(o=1,s=8;s<16;s++)o=o+(255&a[s])|0,a[s]=255&o,o>>>=8;r-=64,t+=64}if(r>0)for(m(c,a,i,b),s=0;s>>13|r<<3),n=255&e[4]|(255&e[5])<<8,this.r[2]=7939&(r>>>10|n<<6),i=255&e[6]|(255&e[7])<<8,this.r[3]=8191&(n>>>7|i<<9),o=255&e[8]|(255&e[9])<<8,this.r[4]=255&(i>>>4|o<<12),this.r[5]=o>>>1&8190,s=255&e[10]|(255&e[11])<<8,this.r[6]=8191&(o>>>14|s<<2),a=255&e[12]|(255&e[13])<<8,this.r[7]=8065&(s>>>11|a<<5),c=255&e[14]|(255&e[15])<<8,this.r[8]=8191&(a>>>8|c<<8),this.r[9]=c>>>5&127,this.pad[0]=255&e[16]|(255&e[17])<<8,this.pad[1]=255&e[18]|(255&e[19])<<8,this.pad[2]=255&e[20]|(255&e[21])<<8,this.pad[3]=255&e[22]|(255&e[23])<<8,this.pad[4]=255&e[24]|(255&e[25])<<8,this.pad[5]=255&e[26]|(255&e[27])<<8,this.pad[6]=255&e[28]|(255&e[29])<<8,this.pad[7]=255&e[30]|(255&e[31])<<8};function x(e,t,r,n,i,o){var s=new A(o);return s.update(r,n,i),s.finish(e,t),0}function k(e,t,r,n,i,o){var s=new Uint8Array(16);return x(s,0,r,n,i,o),g(e,t,s,0)}function B(e,t,r,n,i){var o;if(r<32)return-1;for(S(e,0,t,0,r,n,i),x(e,16,e,32,r-32,e),o=0;o<16;o++)e[o]=0;return 0}function I(e,t,r,n,i){var o,s=new Uint8Array(32);if(r<32)return-1;if(E(s,0,32,n,i),0!==k(t,16,t,32,r-32,s))return-1;for(S(e,0,t,0,r,n,i),o=0;o<32;o++)e[o]=0;return 0}function T(e,t){var r;for(r=0;r<16;r++)e[r]=0|t[r]}function R(e){var t,r,n=1;for(t=0;t<16;t++)r=e[t]+n+65535,n=Math.floor(r/65536),e[t]=r-65536*n;e[0]+=n-1+37*(n-1)}function O(e,t,r){for(var n,i=~(r-1),o=0;o<16;o++)n=i&(e[o]^t[o]),e[o]^=n,t[o]^=n}function L(e,r){var n,i,o,s=t(),a=t();for(n=0;n<16;n++)a[n]=r[n];for(R(a),R(a),R(a),i=0;i<2;i++){for(s[0]=a[0]-65517,n=1;n<15;n++)s[n]=a[n]-65535-(s[n-1]>>16&1),s[n-1]&=65535;s[15]=a[15]-32767-(s[14]>>16&1),o=s[15]>>16&1,s[14]&=65535,O(a,s,1-o)}for(n=0;n<16;n++)e[2*n]=255&a[n],e[2*n+1]=a[n]>>8}function M(e,t){var r=new Uint8Array(32),n=new Uint8Array(32);return L(r,e),L(n,t),y(r,0,n,0)}function C(e){var t=new Uint8Array(32);return L(t,e),1&t[0]}function P(e,t){var r;for(r=0;r<16;r++)e[r]=t[2*r]+(t[2*r+1]<<8);e[15]&=32767}function N(e,t,r){for(var n=0;n<16;n++)e[n]=t[n]+r[n]}function U(e,t,r){for(var n=0;n<16;n++)e[n]=t[n]-r[n]}function j(e,t,r){var n,i,o=0,s=0,a=0,c=0,u=0,h=0,l=0,f=0,d=0,p=0,g=0,y=0,m=0,w=0,b=0,v=0,_=0,E=0,S=0,A=0,x=0,k=0,B=0,I=0,T=0,R=0,O=0,L=0,M=0,C=0,P=0,N=r[0],U=r[1],j=r[2],$=r[3],H=r[4],z=r[5],D=r[6],F=r[7],q=r[8],K=r[9],W=r[10],V=r[11],Z=r[12],G=r[13],J=r[14],Y=r[15];o+=(n=t[0])*N,s+=n*U,a+=n*j,c+=n*$,u+=n*H,h+=n*z,l+=n*D,f+=n*F,d+=n*q,p+=n*K,g+=n*W,y+=n*V,m+=n*Z,w+=n*G,b+=n*J,v+=n*Y,s+=(n=t[1])*N,a+=n*U,c+=n*j,u+=n*$,h+=n*H,l+=n*z,f+=n*D,d+=n*F,p+=n*q,g+=n*K,y+=n*W,m+=n*V,w+=n*Z,b+=n*G,v+=n*J,_+=n*Y,a+=(n=t[2])*N,c+=n*U,u+=n*j,h+=n*$,l+=n*H,f+=n*z,d+=n*D,p+=n*F,g+=n*q,y+=n*K,m+=n*W,w+=n*V,b+=n*Z,v+=n*G,_+=n*J,E+=n*Y,c+=(n=t[3])*N,u+=n*U,h+=n*j,l+=n*$,f+=n*H,d+=n*z,p+=n*D,g+=n*F,y+=n*q,m+=n*K,w+=n*W,b+=n*V,v+=n*Z,_+=n*G,E+=n*J,S+=n*Y,u+=(n=t[4])*N,h+=n*U,l+=n*j,f+=n*$,d+=n*H,p+=n*z,g+=n*D,y+=n*F,m+=n*q,w+=n*K,b+=n*W,v+=n*V,_+=n*Z,E+=n*G,S+=n*J,A+=n*Y,h+=(n=t[5])*N,l+=n*U,f+=n*j,d+=n*$,p+=n*H,g+=n*z,y+=n*D,m+=n*F,w+=n*q,b+=n*K,v+=n*W,_+=n*V,E+=n*Z,S+=n*G,A+=n*J,x+=n*Y,l+=(n=t[6])*N,f+=n*U,d+=n*j,p+=n*$,g+=n*H,y+=n*z,m+=n*D,w+=n*F,b+=n*q,v+=n*K,_+=n*W,E+=n*V,S+=n*Z,A+=n*G,x+=n*J,k+=n*Y,f+=(n=t[7])*N,d+=n*U,p+=n*j,g+=n*$,y+=n*H,m+=n*z,w+=n*D,b+=n*F,v+=n*q,_+=n*K,E+=n*W,S+=n*V,A+=n*Z,x+=n*G,k+=n*J,B+=n*Y,d+=(n=t[8])*N,p+=n*U,g+=n*j,y+=n*$,m+=n*H,w+=n*z,b+=n*D,v+=n*F,_+=n*q,E+=n*K,S+=n*W,A+=n*V,x+=n*Z,k+=n*G,B+=n*J,I+=n*Y,p+=(n=t[9])*N,g+=n*U,y+=n*j,m+=n*$,w+=n*H,b+=n*z,v+=n*D,_+=n*F,E+=n*q,S+=n*K,A+=n*W,x+=n*V,k+=n*Z,B+=n*G,I+=n*J,T+=n*Y,g+=(n=t[10])*N,y+=n*U,m+=n*j,w+=n*$,b+=n*H,v+=n*z,_+=n*D,E+=n*F,S+=n*q,A+=n*K,x+=n*W,k+=n*V,B+=n*Z,I+=n*G,T+=n*J,R+=n*Y,y+=(n=t[11])*N,m+=n*U,w+=n*j,b+=n*$,v+=n*H,_+=n*z,E+=n*D,S+=n*F,A+=n*q,x+=n*K,k+=n*W,B+=n*V,I+=n*Z,T+=n*G,R+=n*J,O+=n*Y,m+=(n=t[12])*N,w+=n*U,b+=n*j,v+=n*$,_+=n*H,E+=n*z,S+=n*D,A+=n*F,x+=n*q,k+=n*K,B+=n*W,I+=n*V,T+=n*Z,R+=n*G,O+=n*J,L+=n*Y,w+=(n=t[13])*N,b+=n*U,v+=n*j,_+=n*$,E+=n*H,S+=n*z,A+=n*D,x+=n*F,k+=n*q,B+=n*K,I+=n*W,T+=n*V,R+=n*Z,O+=n*G,L+=n*J,M+=n*Y,b+=(n=t[14])*N,v+=n*U,_+=n*j,E+=n*$,S+=n*H,A+=n*z,x+=n*D,k+=n*F,B+=n*q,I+=n*K,T+=n*W,R+=n*V,O+=n*Z,L+=n*G,M+=n*J,C+=n*Y,v+=(n=t[15])*N,s+=38*(E+=n*j),a+=38*(S+=n*$),c+=38*(A+=n*H),u+=38*(x+=n*z),h+=38*(k+=n*D),l+=38*(B+=n*F),f+=38*(I+=n*q),d+=38*(T+=n*K),p+=38*(R+=n*W),g+=38*(O+=n*V),y+=38*(L+=n*Z),m+=38*(M+=n*G),w+=38*(C+=n*J),b+=38*(P+=n*Y),o=(n=(o+=38*(_+=n*U))+(i=1)+65535)-65536*(i=Math.floor(n/65536)),s=(n=s+i+65535)-65536*(i=Math.floor(n/65536)),a=(n=a+i+65535)-65536*(i=Math.floor(n/65536)),c=(n=c+i+65535)-65536*(i=Math.floor(n/65536)),u=(n=u+i+65535)-65536*(i=Math.floor(n/65536)),h=(n=h+i+65535)-65536*(i=Math.floor(n/65536)),l=(n=l+i+65535)-65536*(i=Math.floor(n/65536)),f=(n=f+i+65535)-65536*(i=Math.floor(n/65536)),d=(n=d+i+65535)-65536*(i=Math.floor(n/65536)),p=(n=p+i+65535)-65536*(i=Math.floor(n/65536)),g=(n=g+i+65535)-65536*(i=Math.floor(n/65536)),y=(n=y+i+65535)-65536*(i=Math.floor(n/65536)),m=(n=m+i+65535)-65536*(i=Math.floor(n/65536)),w=(n=w+i+65535)-65536*(i=Math.floor(n/65536)),b=(n=b+i+65535)-65536*(i=Math.floor(n/65536)),v=(n=v+i+65535)-65536*(i=Math.floor(n/65536)),o=(n=(o+=i-1+37*(i-1))+(i=1)+65535)-65536*(i=Math.floor(n/65536)),s=(n=s+i+65535)-65536*(i=Math.floor(n/65536)),a=(n=a+i+65535)-65536*(i=Math.floor(n/65536)),c=(n=c+i+65535)-65536*(i=Math.floor(n/65536)),u=(n=u+i+65535)-65536*(i=Math.floor(n/65536)),h=(n=h+i+65535)-65536*(i=Math.floor(n/65536)),l=(n=l+i+65535)-65536*(i=Math.floor(n/65536)),f=(n=f+i+65535)-65536*(i=Math.floor(n/65536)),d=(n=d+i+65535)-65536*(i=Math.floor(n/65536)),p=(n=p+i+65535)-65536*(i=Math.floor(n/65536)),g=(n=g+i+65535)-65536*(i=Math.floor(n/65536)),y=(n=y+i+65535)-65536*(i=Math.floor(n/65536)),m=(n=m+i+65535)-65536*(i=Math.floor(n/65536)),w=(n=w+i+65535)-65536*(i=Math.floor(n/65536)),b=(n=b+i+65535)-65536*(i=Math.floor(n/65536)),v=(n=v+i+65535)-65536*(i=Math.floor(n/65536)),o+=i-1+37*(i-1),e[0]=o,e[1]=s,e[2]=a,e[3]=c,e[4]=u,e[5]=h,e[6]=l,e[7]=f,e[8]=d,e[9]=p,e[10]=g,e[11]=y,e[12]=m,e[13]=w,e[14]=b,e[15]=v}function $(e,t){j(e,t,t)}function H(e,r){var n,i=t();for(n=0;n<16;n++)i[n]=r[n];for(n=253;n>=0;n--)$(i,i),2!==n&&4!==n&&j(i,i,r);for(n=0;n<16;n++)e[n]=i[n]}function z(e,r){var n,i=t();for(n=0;n<16;n++)i[n]=r[n];for(n=250;n>=0;n--)$(i,i),1!==n&&j(i,i,r);for(n=0;n<16;n++)e[n]=i[n]}function D(e,r,n){var i,o,s=new Uint8Array(32),c=new Float64Array(80),u=t(),h=t(),l=t(),f=t(),d=t(),p=t();for(o=0;o<31;o++)s[o]=r[o];for(s[31]=127&r[31]|64,s[0]&=248,P(c,n),o=0;o<16;o++)h[o]=c[o],f[o]=u[o]=l[o]=0;for(u[0]=f[0]=1,o=254;o>=0;--o)O(u,h,i=s[o>>>3]>>>(7&o)&1),O(l,f,i),N(d,u,l),U(u,u,l),N(l,h,f),U(h,h,f),$(f,d),$(p,u),j(u,l,u),j(l,h,d),N(d,u,l),U(u,u,l),$(h,u),U(l,f,p),j(u,l,a),N(u,u,f),j(l,l,u),j(u,f,p),j(f,h,c),$(h,d),O(u,h,i),O(l,f,i);for(o=0;o<16;o++)c[o+16]=u[o],c[o+32]=l[o],c[o+48]=h[o],c[o+64]=f[o];var g=c.subarray(32),y=c.subarray(16);return H(g,g),j(y,y,g),L(e,y),0}function F(e,t){return D(e,t,i)}function q(e,t){return r(t,32),F(e,t)}function K(e,t,r){var i=new Uint8Array(32);return D(i,r,t),w(e,n,i,b)}A.prototype.blocks=function(e,t,r){for(var n,i,o,s,a,c,u,h,l,f,d,p,g,y,m,w,b,v,_,E=this.fin?0:2048,S=this.h[0],A=this.h[1],x=this.h[2],k=this.h[3],B=this.h[4],I=this.h[5],T=this.h[6],R=this.h[7],O=this.h[8],L=this.h[9],M=this.r[0],C=this.r[1],P=this.r[2],N=this.r[3],U=this.r[4],j=this.r[5],$=this.r[6],H=this.r[7],z=this.r[8],D=this.r[9];r>=16;)f=l=0,f+=(S+=8191&(n=255&e[t+0]|(255&e[t+1])<<8))*M,f+=(A+=8191&(n>>>13|(i=255&e[t+2]|(255&e[t+3])<<8)<<3))*(5*D),f+=(x+=8191&(i>>>10|(o=255&e[t+4]|(255&e[t+5])<<8)<<6))*(5*z),f+=(k+=8191&(o>>>7|(s=255&e[t+6]|(255&e[t+7])<<8)<<9))*(5*H),l=(f+=(B+=8191&(s>>>4|(a=255&e[t+8]|(255&e[t+9])<<8)<<12))*(5*$))>>>13,f&=8191,f+=(I+=a>>>1&8191)*(5*j),f+=(T+=8191&(a>>>14|(c=255&e[t+10]|(255&e[t+11])<<8)<<2))*(5*U),f+=(R+=8191&(c>>>11|(u=255&e[t+12]|(255&e[t+13])<<8)<<5))*(5*N),f+=(O+=8191&(u>>>8|(h=255&e[t+14]|(255&e[t+15])<<8)<<8))*(5*P),d=l+=(f+=(L+=h>>>5|E)*(5*C))>>>13,d+=S*C,d+=A*M,d+=x*(5*D),d+=k*(5*z),l=(d+=B*(5*H))>>>13,d&=8191,d+=I*(5*$),d+=T*(5*j),d+=R*(5*U),d+=O*(5*N),l+=(d+=L*(5*P))>>>13,d&=8191,p=l,p+=S*P,p+=A*C,p+=x*M,p+=k*(5*D),l=(p+=B*(5*z))>>>13,p&=8191,p+=I*(5*H),p+=T*(5*$),p+=R*(5*j),p+=O*(5*U),g=l+=(p+=L*(5*N))>>>13,g+=S*N,g+=A*P,g+=x*C,g+=k*M,l=(g+=B*(5*D))>>>13,g&=8191,g+=I*(5*z),g+=T*(5*H),g+=R*(5*$),g+=O*(5*j),y=l+=(g+=L*(5*U))>>>13,y+=S*U,y+=A*N,y+=x*P,y+=k*C,l=(y+=B*M)>>>13,y&=8191,y+=I*(5*D),y+=T*(5*z),y+=R*(5*H),y+=O*(5*$),m=l+=(y+=L*(5*j))>>>13,m+=S*j,m+=A*U,m+=x*N,m+=k*P,l=(m+=B*C)>>>13,m&=8191,m+=I*M,m+=T*(5*D),m+=R*(5*z),m+=O*(5*H),w=l+=(m+=L*(5*$))>>>13,w+=S*$,w+=A*j,w+=x*U,w+=k*N,l=(w+=B*P)>>>13,w&=8191,w+=I*C,w+=T*M,w+=R*(5*D),w+=O*(5*z),b=l+=(w+=L*(5*H))>>>13,b+=S*H,b+=A*$,b+=x*j,b+=k*U,l=(b+=B*N)>>>13,b&=8191,b+=I*P,b+=T*C,b+=R*M,b+=O*(5*D),v=l+=(b+=L*(5*z))>>>13,v+=S*z,v+=A*H,v+=x*$,v+=k*j,l=(v+=B*U)>>>13,v&=8191,v+=I*N,v+=T*P,v+=R*C,v+=O*M,_=l+=(v+=L*(5*D))>>>13,_+=S*D,_+=A*z,_+=x*H,_+=k*$,l=(_+=B*j)>>>13,_&=8191,_+=I*U,_+=T*N,_+=R*P,_+=O*C,S=f=8191&(l=(l=((l+=(_+=L*M)>>>13)<<2)+l|0)+(f&=8191)|0),A=d+=l>>>=13,x=p&=8191,k=g&=8191,B=y&=8191,I=m&=8191,T=w&=8191,R=b&=8191,O=v&=8191,L=_&=8191,t+=16,r-=16;this.h[0]=S,this.h[1]=A,this.h[2]=x,this.h[3]=k,this.h[4]=B,this.h[5]=I,this.h[6]=T,this.h[7]=R,this.h[8]=O,this.h[9]=L},A.prototype.finish=function(e,t){var r,n,i,o,s=new Uint16Array(10);if(this.leftover){for(o=this.leftover,this.buffer[o++]=1;o<16;o++)this.buffer[o]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(r=this.h[1]>>>13,this.h[1]&=8191,o=2;o<10;o++)this.h[o]+=r,r=this.h[o]>>>13,this.h[o]&=8191;for(this.h[0]+=5*r,r=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=r,r=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=r,s[0]=this.h[0]+5,r=s[0]>>>13,s[0]&=8191,o=1;o<10;o++)s[o]=this.h[o]+r,r=s[o]>>>13,s[o]&=8191;for(s[9]-=8192,n=(1^r)-1,o=0;o<10;o++)s[o]&=n;for(n=~n,o=0;o<10;o++)this.h[o]=this.h[o]&n|s[o];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),i=this.h[0]+this.pad[0],this.h[0]=65535&i,o=1;o<8;o++)i=(this.h[o]+this.pad[o]|0)+(i>>>16)|0,this.h[o]=65535&i;e[t+0]=this.h[0]>>>0&255,e[t+1]=this.h[0]>>>8&255,e[t+2]=this.h[1]>>>0&255,e[t+3]=this.h[1]>>>8&255,e[t+4]=this.h[2]>>>0&255,e[t+5]=this.h[2]>>>8&255,e[t+6]=this.h[3]>>>0&255,e[t+7]=this.h[3]>>>8&255,e[t+8]=this.h[4]>>>0&255,e[t+9]=this.h[4]>>>8&255,e[t+10]=this.h[5]>>>0&255,e[t+11]=this.h[5]>>>8&255,e[t+12]=this.h[6]>>>0&255,e[t+13]=this.h[6]>>>8&255,e[t+14]=this.h[7]>>>0&255,e[t+15]=this.h[7]>>>8&255},A.prototype.update=function(e,t,r){var n,i;if(this.leftover){for((i=16-this.leftover)>r&&(i=r),n=0;n=16&&(i=r-r%16,this.blocks(e,t,i),t+=i,r-=i),r){for(n=0;n=128;){for(E=0;E<16;E++)S=8*E+G,R[E]=r[S+0]<<24|r[S+1]<<16|r[S+2]<<8|r[S+3],O[E]=r[S+4]<<24|r[S+5]<<16|r[S+6]<<8|r[S+7];for(E=0;E<80;E++)if(i=L,o=M,s=C,a=P,c=N,u=U,h=j,$,f=H,d=z,p=D,g=F,y=q,m=K,w=W,V,k=65535&(x=V),B=x>>>16,I=65535&(A=$),T=A>>>16,k+=65535&(x=(q>>>14|N<<18)^(q>>>18|N<<14)^(N>>>9|q<<23)),B+=x>>>16,I+=65535&(A=(N>>>14|q<<18)^(N>>>18|q<<14)^(q>>>9|N<<23)),T+=A>>>16,k+=65535&(x=q&K^~q&W),B+=x>>>16,I+=65535&(A=N&U^~N&j),T+=A>>>16,k+=65535&(x=Z[2*E+1]),B+=x>>>16,I+=65535&(A=Z[2*E]),T+=A>>>16,A=R[E%16],B+=(x=O[E%16])>>>16,I+=65535&A,T+=A>>>16,I+=(B+=(k+=65535&x)>>>16)>>>16,k=65535&(x=_=65535&k|B<<16),B=x>>>16,I=65535&(A=v=65535&I|(T+=I>>>16)<<16),T=A>>>16,k+=65535&(x=(H>>>28|L<<4)^(L>>>2|H<<30)^(L>>>7|H<<25)),B+=x>>>16,I+=65535&(A=(L>>>28|H<<4)^(H>>>2|L<<30)^(H>>>7|L<<25)),T+=A>>>16,B+=(x=H&z^H&D^z&D)>>>16,I+=65535&(A=L&M^L&C^M&C),T+=A>>>16,l=65535&(I+=(B+=(k+=65535&x)>>>16)>>>16)|(T+=I>>>16)<<16,b=65535&k|B<<16,k=65535&(x=g),B=x>>>16,I=65535&(A=a),T=A>>>16,B+=(x=_)>>>16,I+=65535&(A=v),T+=A>>>16,M=i,C=o,P=s,N=a=65535&(I+=(B+=(k+=65535&x)>>>16)>>>16)|(T+=I>>>16)<<16,U=c,j=u,$=h,L=l,z=f,D=d,F=p,q=g=65535&k|B<<16,K=y,W=m,V=w,H=b,E%16==15)for(S=0;S<16;S++)A=R[S],k=65535&(x=O[S]),B=x>>>16,I=65535&A,T=A>>>16,A=R[(S+9)%16],k+=65535&(x=O[(S+9)%16]),B+=x>>>16,I+=65535&A,T+=A>>>16,v=R[(S+1)%16],k+=65535&(x=((_=O[(S+1)%16])>>>1|v<<31)^(_>>>8|v<<24)^(_>>>7|v<<25)),B+=x>>>16,I+=65535&(A=(v>>>1|_<<31)^(v>>>8|_<<24)^v>>>7),T+=A>>>16,v=R[(S+14)%16],B+=(x=((_=O[(S+14)%16])>>>19|v<<13)^(v>>>29|_<<3)^(_>>>6|v<<26))>>>16,I+=65535&(A=(v>>>19|_<<13)^(_>>>29|v<<3)^v>>>6),T+=A>>>16,T+=(I+=(B+=(k+=65535&x)>>>16)>>>16)>>>16,R[S]=65535&I|T<<16,O[S]=65535&k|B<<16;k=65535&(x=H),B=x>>>16,I=65535&(A=L),T=A>>>16,A=e[0],B+=(x=t[0])>>>16,I+=65535&A,T+=A>>>16,T+=(I+=(B+=(k+=65535&x)>>>16)>>>16)>>>16,e[0]=L=65535&I|T<<16,t[0]=H=65535&k|B<<16,k=65535&(x=z),B=x>>>16,I=65535&(A=M),T=A>>>16,A=e[1],B+=(x=t[1])>>>16,I+=65535&A,T+=A>>>16,T+=(I+=(B+=(k+=65535&x)>>>16)>>>16)>>>16,e[1]=M=65535&I|T<<16,t[1]=z=65535&k|B<<16,k=65535&(x=D),B=x>>>16,I=65535&(A=C),T=A>>>16,A=e[2],B+=(x=t[2])>>>16,I+=65535&A,T+=A>>>16,T+=(I+=(B+=(k+=65535&x)>>>16)>>>16)>>>16,e[2]=C=65535&I|T<<16,t[2]=D=65535&k|B<<16,k=65535&(x=F),B=x>>>16,I=65535&(A=P),T=A>>>16,A=e[3],B+=(x=t[3])>>>16,I+=65535&A,T+=A>>>16,T+=(I+=(B+=(k+=65535&x)>>>16)>>>16)>>>16,e[3]=P=65535&I|T<<16,t[3]=F=65535&k|B<<16,k=65535&(x=q),B=x>>>16,I=65535&(A=N),T=A>>>16,A=e[4],B+=(x=t[4])>>>16,I+=65535&A,T+=A>>>16,T+=(I+=(B+=(k+=65535&x)>>>16)>>>16)>>>16,e[4]=N=65535&I|T<<16,t[4]=q=65535&k|B<<16,k=65535&(x=K),B=x>>>16,I=65535&(A=U),T=A>>>16,A=e[5],B+=(x=t[5])>>>16,I+=65535&A,T+=A>>>16,T+=(I+=(B+=(k+=65535&x)>>>16)>>>16)>>>16,e[5]=U=65535&I|T<<16,t[5]=K=65535&k|B<<16,k=65535&(x=W),B=x>>>16,I=65535&(A=j),T=A>>>16,A=e[6],B+=(x=t[6])>>>16,I+=65535&A,T+=A>>>16,T+=(I+=(B+=(k+=65535&x)>>>16)>>>16)>>>16,e[6]=j=65535&I|T<<16,t[6]=W=65535&k|B<<16,k=65535&(x=V),B=x>>>16,I=65535&(A=$),T=A>>>16,A=e[7],B+=(x=t[7])>>>16,I+=65535&A,T+=A>>>16,T+=(I+=(B+=(k+=65535&x)>>>16)>>>16)>>>16,e[7]=$=65535&I|T<<16,t[7]=V=65535&k|B<<16,G+=128,n-=128}return n}function J(e,t,r){var n,i=new Int32Array(8),o=new Int32Array(8),s=new Uint8Array(256),a=r;for(i[0]=1779033703,i[1]=3144134277,i[2]=1013904242,i[3]=2773480762,i[4]=1359893119,i[5]=2600822924,i[6]=528734635,i[7]=1541459225,o[0]=4089235720,o[1]=2227873595,o[2]=4271175723,o[3]=1595750129,o[4]=2917565137,o[5]=725511199,o[6]=4215389547,o[7]=327033209,G(i,o,t,r),r%=128,n=0;n=0;--i)X(e,t,n=r[i/8|0]>>(7&i)&1),Y(t,e),Y(e,e),X(e,t,n)}function te(e,r){var n=[t(),t(),t(),t()];T(n[0],h),T(n[1],l),T(n[2],s),j(n[3],h,l),ee(e,n,r)}function re(e,n,i){var o,s=new Uint8Array(64),a=[t(),t(),t(),t()];for(i||r(n,32),J(s,n,32),s[0]&=248,s[31]&=127,s[31]|=64,te(a,s),Q(e,a),o=0;o<32;o++)n[o+32]=e[o];return 0}var ne=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function ie(e,t){var r,n,i,o;for(n=63;n>=32;--n){for(r=0,i=n-32,o=n-12;i>4)*ne[i],r=t[i]>>8,t[i]&=255;for(i=0;i<32;i++)t[i]-=r*ne[i];for(n=0;n<32;n++)t[n+1]+=t[n]>>8,e[n]=255&t[n]}function oe(e){var t,r=new Float64Array(64);for(t=0;t<64;t++)r[t]=e[t];for(t=0;t<64;t++)e[t]=0;ie(e,r)}function se(e,r,n,i){var o,s,a=new Uint8Array(64),c=new Uint8Array(64),u=new Uint8Array(64),h=new Float64Array(64),l=[t(),t(),t(),t()];J(a,i,32),a[0]&=248,a[31]&=127,a[31]|=64;var f=n+64;for(o=0;o>7&&U(e[0],o,e[0]),j(e[3],e[0],e[1]),0)}(d,i))return-1;for(a=0;a=0},e.sign.keyPair=function(){var e=new Uint8Array(he),t=new Uint8Array(le);return re(e,t),{publicKey:e,secretKey:t}},e.sign.keyPair.fromSecretKey=function(e){if(de(e),e.length!==le)throw new Error("bad secret key size");for(var t=new Uint8Array(he),r=0;r0&&(o=2048-i-16),n.padding="0".repeat(o),TB({publicKey:e,data:JSON.stringify(n),version:r})},vB.decrypt=RB,vB.decryptSafely=function({encryptedData:e,privateKey:t}){if((0,IB.isNullish)(e))throw new Error("Missing encryptedData parameter");if((0,IB.isNullish)(t))throw new Error("Missing privateKey parameter");return JSON.parse(RB({encryptedData:e,privateKey:t})).data},vB.getEncryptionPublicKey=function(e){const t=C.from(e,"hex"),r=BB.box.keyPair.fromSecretKey(t).publicKey;return kB.base64.encode(r)},function(e){var t=Cr&&Cr.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),r=Cr&&Cr.__exportStar||function(e,r){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(r,n)||t(r,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.normalize=e.concatSig=void 0,r(wh,e),r(Lx,e),r(vB,e);var n=ev;Object.defineProperty(e,"concatSig",{enumerable:!0,get:function(){return n.concatSig}}),Object.defineProperty(e,"normalize",{enumerable:!0,get:function(){return n.normalize}})}(mh);class OB extends Error{constructor(e,t){super(),this.code=e,this.message=t}toString(){return`${this.message} (${this.code})`}}var LB,MB=(e,t,r)=>(((e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)})(e,t,"read from private field"),r?r.call(e):t.get(e));const CB=class{constructor(e){((e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)})(this,LB,["eth_newFilter","eth_newBlockFilter","eth_newPendingTransactionFilter","eth_uninstallFilter","eth_subscribe"]),this.provider=e}static isUTF8(e){try{return new TextDecoder("utf8",{fatal:!0}).decode(e),!0}catch{return!1}}static bufferToHex(e){return"0x"+C.from(e).toString("hex")}static messageToBuffer(e){let t=C.from([]);try{t="string"==typeof e?C.from(e.replace("0x",""),"hex"):C.from(e)}catch(e){console.log(`messageToBuffer error: ${e}`)}return t}async request(e){if(MB(this,LB).includes(e.method))return Promise.reject(new OB(4200,`EthereumProvider does not support calling ${e.method}`));switch(e.method){case"wallet_requestPermissions":return this.provider.internalRequest({method:"wallet_requestPermissions",params:e.params});case"eth_requestAccounts":return this.provider.internalRequest({method:"requestAccounts",params:{}});case"eth_sign":return this.ethSign(e.params);case"personal_sign":return this.personalSign(e.params);case"personal_ecRecover":return this.personalECRecover(e.params);case"eth_signTypedData_v3":return this.ethSignTypedData(e.params,mh.SignTypedDataVersion.V3);case"eth_signTypedData_v4":return this.ethSignTypedData(e.params,mh.SignTypedDataVersion.V4);case"eth_signTypedData":return this.ethSignTypedData(e.params,mh.SignTypedDataVersion.V1);case"eth_sendTransaction":return this.provider.internalRequest({method:"signTransaction",params:e.params[0]});case"wallet_watchAsset":{const{options:t,type:r}=e.params,{address:n,symbol:i,decimals:o}=t;return this.provider.internalRequest({method:"watchAsset",params:{type:r,contract:n,symbol:i,decimals:o||0}})}case"wallet_addEthereumChain":return this.provider.internalRequest({method:"addEthereumChain",params:e.params[0]});case"wallet_switchEthereumChain":return this.provider.internalRequest({method:"switchEthereumChain",params:e.params[0]});default:return await this.provider.getRPC().call({method:e.method,jsonrpc:"2.0",params:e.params})}}personalECRecover(e){return this.provider.internalRequest({method:"ecRecover",params:{signature:e[1],message:e[0]}})}async personalSign(e){const[t]=await this.provider.request({method:"eth_accounts"});if(!t)throw new Error("Unable to execute personal_sign");let[r,n]=e;"string"==typeof r&&t.toLowerCase()===r.toLowerCase()&&(r=e[1],n=e[0]);const i=CB.messageToBuffer(r);return this.provider.internalRequest({method:"signPersonalMessage",params:{data:0===i.length?CB.bufferToHex(r):r,address:n}})}ethSign(e){if(!e)throw new Error("Missing params");const[t,r]=e,n=CB.messageToBuffer(r),i=CB.bufferToHex(n);return this.provider.internalRequest({method:CB.isUTF8(n)?"signPersonalMessage":"signMessage",params:{data:i,address:t,isEthSign:!0}})}async ethSignTypedData(e,t){const[r]=await this.provider.request({method:"eth_accounts"});if(!r)throw new Error("Unable to execute ethSignTypedData, address is not present");let[n,i]=e;"string"==typeof n&&r.toLowerCase()===n.toLowerCase()&&(n=e[1],i=e[0]);const o="string"==typeof n?JSON.parse(n):n,{chainId:s}=o.domain||{};if(typeof s<"u"&&Number(s)!==Number(this.provider.getChainId()))throw new Error("Provided chainId does not match the currently active chain");const a=t!==mh.SignTypedDataVersion.V1?mh.TypedDataUtils.eip712Hash(o,t):"";return this.provider.internalRequest({method:"signTypedMessage",params:{data:"0x"+a.toString("hex"),raw:"string"==typeof n?n:JSON.stringify(n),address:i,version:t}})}};let PB=CB;LB=new WeakMap;var NB,UB=Object.defineProperty,jB=Object.getOwnPropertySymbols,$B=Object.prototype.hasOwnProperty,HB=Object.prototype.propertyIsEnumerable,zB=(e,t,r)=>t in e?UB(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,DB=(e,t)=>{for(var r in t||(t={}))$B.call(t,r)&&zB(e,r,t[r]);if(jB)for(var r of jB(t))HB.call(t,r)&&zB(e,r,t[r]);return e},FB=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};class qB{constructor(e){((e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)})(this,NB,void 0),((e,t,r,n)=>{FB(e,t,"write to private field"),n?n.call(e,r):t.set(e,r)})(this,NB,e)}async getBlockNumber(){return(await this.call({jsonrpc:"2.0",method:"eth_blockNumber",params:[]})).result}async getBlockByNumber(e){return(await this.call({jsonrpc:"2.0",method:"eth_getBlockByNumber",params:[e,!1]})).result}getFilterLogs(e){return this.call({jsonrpc:"2.0",method:"eth_getLogs",params:[e]})}async call(e){const t=await(await fetch(((e,t,r)=>(FB(e,t,"read from private field"),r?r.call(e):t.get(e)))(this,NB),{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(DB({id:(new Date).getTime()+Math.floor(1e3*Math.random())},e))})).json();if(!t.result&&t.error)throw new Error(t.error.message||"rpc error");return t.result}}NB=new WeakMap;var KB,WB,VB,ZB,GB,JB,YB=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},XB=(e,t,r)=>(YB(e,t,"read from private field"),r?r.call(e):t.get(e)),QB=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},eI=(e,t,r,n)=>(YB(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);const tI=class extends He{constructor(e){super(),QB(this,KB,void 0),QB(this,WB,void 0),QB(this,VB,!1),QB(this,ZB,!1),QB(this,GB,void 0),QB(this,JB,void 0),this.isTrust=!0,this.isTrustWallet=!0,this.request=this.request.bind(this),e&&(e.chainId&&eI(this,KB,e.chainId),(e.rpc||e.rpcUrl)&&eI(this,WB,e.rpc||e.rpcUrl),typeof e.overwriteMetamask<"u"&&eI(this,ZB,e.overwriteMetamask),typeof e.disableMobileAdapter<"u"&&eI(this,VB,e.disableMobileAdapter),typeof e.isTrust<"u"&&(this.isTrust=e.isTrust,this.isTrustWallet=e.isTrust),eI(this,JB,new qB(XB(this,WB)))),XB(this,VB)||(this.mobileAdapter=new PB(this)),super.on("onResponseReady",this.onResponseReady.bind(this)),this.connect()}connect(){this.emit("connect",{chainId:XB(this,KB)})}enable(){return this.request({method:"eth_requestAccounts"})}sendAsync(e,t){Array.isArray(e)?Promise.all(e.map((e=>this.request(e)))).then((e=>t(null,e))).catch((e=>t(e,null))):this.request(e).then((e=>t(null,e))).catch((e=>t(e,null)))}_send(e){const t={jsonrpc:"2.0",result:null};switch(e.method){case"eth_accounts":case"eth_coinbase":case"net_version":case"eth_chainId":t.result=this.handleStaticRequests({method:"eth_accounts"});break;default:throw new OB(4200,`Trust does not support calling ${e.method} synchronously without a callback. Please provide a callback parameter to call ${e.method} asynchronously.`)}return t}send(e,t){if("string"==typeof e&&(!t||Array.isArray(t))){const r=this;return new Promise(((n,i)=>{try{const o=r.request({method:e,params:t});o instanceof Promise?o.then(n).catch(i):n(o)}catch(e){i(e)}}))}return e&&"object"==typeof e&&"function"==typeof t?this.request(e).then(t):this._send(e)}internalRequest(e){return super.request(e)}request(e){if(this.mobileAdapter){const t=this.handleStaticRequests(e,(()=>this.mobileAdapter.request(e)));return t instanceof Promise?t:Promise.resolve(t)}return this.handleStaticRequests(e,(()=>this.internalRequest(e)))}handleStaticRequests(e,t){switch(e.method){case"net_version":return XB(this,KB)?parseInt(XB(this,KB)):void 0;case"eth_chainId":return XB(this,KB);case"eth_accounts":case"eth_coinbase":return XB(this,GB)?[XB(this,GB)]:[]}if(t)return t()}onResponseReady(e,t){var r,n,i,o;if(t)switch(e.method){case"eth_requestAccounts":case"requestAccounts":eI(this,GB,t[0]);break;case"wallet_requestPermissions":eI(this,GB,null==(o=null==(i=null==(n=null==(r=t[0])?void 0:r.caveats)?void 0:n[0])?void 0:i.value)?void 0:o[0])}}getNetwork(){return tI.NETWORK}get connected(){return!0}get isMetaMask(){return XB(this,ZB)}getChainId(){return XB(this,KB)}getNetworkVersion(){return this.handleStaticRequests({method:"net_version "})}setChainId(e){eI(this,KB,e)}setRPCUrl(e){eI(this,WB,e),eI(this,JB,new qB(XB(this,WB)))}getRPC(){return XB(this,JB)}setOverwriteMetamask(e){eI(this,ZB,e)}getAddress(){return XB(this,GB)}setAddress(e){eI(this,GB,e)}setRPC(e){eI(this,JB,e)}};let rI=tI;KB=new WeakMap,WB=new WeakMap,VB=new WeakMap,ZB=new WeakMap,GB=new WeakMap,JB=new WeakMap,rI.NETWORK="ethereum";class nI{constructor(e){this.provider=e}async request(e,t){if("getKey"===e.method){const t=await this.provider.internalRequest({method:"requestAccounts",params:e.params}),r=JSON.parse(t);return{algo:"secp256k1",address:r.address,bech32Address:r.address,pubKey:C.from(r.pubKey,"hex")}}const r={signAmino:"signTransaction",signDirect:"signTransaction",signArbitrary:"signMessage",sendTx:"sendTransaction"};return r[e.method]?this.provider.internalRequest({method:r[e.method],params:e.params}):t()}}var iI,oI=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},sI=(e,t,r)=>(oI(e,t,"read from private field"),r?r.call(e):t.get(e));const aI=class extends He{constructor(e){super(),((e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)})(this,iI,!1),this.isKeplr=!0,this.isTrust=!0,this.isTrustWallet=!0,e&&(typeof e.disableMobileAdapter<"u"&&((e,t,r,n)=>{oI(e,t,"write to private field"),n?n.call(e,r):t.set(e,r)})(this,iI,e.disableMobileAdapter),typeof e.isKeplr<"u"&&(this.isKeplr=e.isKeplr),typeof e.isTrust<"u"&&(this.isTrust=e.isTrust,this.isTrustWallet=e.isTrust)),sI(this,iI)||(this.mobileAdapter=new nI(this))}static bufferToHex(e){return"0x"+C.from(e).toString("hex")}getNetwork(){return aI.NETWORK}isMobileAdapterEnabled(){return!sI(this,iI)}enable(e){return this.request({method:"enable",params:{chainIds:e}})}internalRequest(e){return super.request(e)}request(e){const t=()=>this.internalRequest(e);return this.mobileAdapter?this.mobileAdapter.request(e,t):t()}getKey(e){return this.request({method:"getKey",params:{chainId:e}})}async sendTx(e,t,r){const n=C.from(t).toString("base64"),i=await this.request({method:"sendTx",params:{raw:n,chainId:e,mode:r}});return new Uint8Array(C.from(i,"hex"))}async signArbitrary(e,t,r){const n=C.from(r),i=aI.bufferToHex(n);return await this.request({method:"signArbitrary",params:{chainId:e,data:i,signerAddress:t}})}async signAmino(e,t,r){const n=await this.request({method:"signAmino",params:{chainId:e,sign_doc:r}}),{signed:i,signature:o}=JSON.parse(n);return{signed:i,signature:o}}async signDirect(e,t,r){const n={bodyBytes:aI.bufferToHex(r.bodyBytes),authInfoBytes:aI.bufferToHex(r.authInfoBytes)},i=await this.request({method:"signDirect",params:{signerAddress:t,chainId:e,sign_doc:n}}),{signature:o}=JSON.parse(i);return{signed:r,signature:o}}experimentalSuggestChain(){}getOfflineSignerDirect(e){return{getAccounts:async()=>[await this.getKey(e)],signDirect:async(t,r)=>{if(e!==r.chainId)throw new Error("Unmatched chain id with the offline signer");if((await this.getKey(r.chainId)).address!==t)throw new Error("Unknown signer address");return await this.signDirect(e,t,r)}}}getOfflineSigner(e){return this.getOfflineSignerAmino(e)}getOfflineSignerAuto(e){return this.getOfflineSignerAmino(e)}getOfflineSignerAmino(e){return{getAccounts:async()=>{const t=await this.getKey(e);return[{address:t.bech32Address,algo:"secp256k1",pubkey:t.pubKey}]},sign:(t,r)=>this.signAmino(e,t,r),signAmino:(t,r)=>this.signAmino(e,t,r)}}};let cI=aI;iI=new WeakMap,cI.NETWORK="cosmos";var uI,hI={exports:{}},lI="object"==typeof Reflect?Reflect:null,fI=lI&&"function"==typeof lI.apply?lI.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};uI=lI&&"function"==typeof lI.ownKeys?lI.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var dI=Number.isNaN||function(e){return e!=e};function pI(){pI.init.call(this)}hI.exports=pI,hI.exports.once=function(e,t){return new Promise((function(r,n){function i(r){e.removeListener(t,o),n(r)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",i),r([].slice.call(arguments))}AI(e,t,o,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&AI(e,"error",t,r)}(e,i,{once:!0})}))},pI.EventEmitter=pI,pI.prototype._events=void 0,pI.prototype._eventsCount=0,pI.prototype._maxListeners=void 0;var gI=10;function yI(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function mI(e){return void 0===e._maxListeners?pI.defaultMaxListeners:e._maxListeners}function wI(e,t,r,n){var i,o,s;if(yI(r),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]),void 0===s)s=o[t]=r,++e._eventsCount;else if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(i=mI(e))>0&&s.length>i&&!s.warned){s.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=e,a.type=t,a.count=s.length,function(e){console&&console.warn&&console.warn(e)}(a)}return e}function bI(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function vI(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=bI.bind(n);return i.listener=r,n.wrapFn=i,i}function _I(e,t,r){var n=e._events;if(void 0===n)return[];var i=n[t];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(e){for(var t=new Array(e.length),r=0;r0&&(o=t[0]),o instanceof Error)throw o;var s=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw s.context=o,s}var a=i[e];if(void 0===a)return!1;if("function"==typeof a)fI(a,this,t);else{var c=a.length,u=SI(a,c);for(r=0;r=0;o--)if(r[o]===t||r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1=0;n--)this.removeListener(e,t[n]);return this},pI.prototype.listeners=function(e){return _I(this,e,!0)},pI.prototype.rawListeners=function(e){return _I(this,e,!1)},pI.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):EI.call(e,t)},pI.prototype.listenerCount=EI,pI.prototype.eventNames=function(){return this._eventsCount>0?uI(this._events):[]};const xI="CALLBACK";class kI extends hI.exports.EventEmitter{setAdapter(e){return this.adapter=e,this}async request(e){try{if(!this.adapter)throw new Error("No adapter set, maybe you forgot to register the provider?");const t=await this.adapter.request(e,this.getNetwork());return this.emit("onResponseReady",e,t),t}catch(e){throw e}}sendResponse(e,t){if(!this.adapter)throw new Error("Adapter not found");if(this.adapter.getStrategy()!==xI)throw new Error("Trying to send callback request on promisified adapter");this.adapter.sendResponse(e,t)}sendError(e,t){if(!this.adapter)throw new Error("Adapter not found");if(this.adapter.getStrategy()!==xI)throw new Error("Trying to send callback request on promisified adapter");this.adapter.sendError(e,t)}}const BI=class extends kI{constructor(e){super(),this._isConnected=!1,this.chainId=null,this.address=null,e&&e.network&&(this._network=e.network,e.chainId&&(this.chainId=e.chainId))}static bufferToHex(e){return"0x"+C.from(e).toString("hex")}static messageToBuffer(e){let t=C.from([]);try{t="string"==typeof e?C.from(e.replace("0x",""),"hex"):C.from(e)}catch(e){console.log(`messageToBuffer error: ${e}`)}return t}setConfig(e){this._network=e.network,this.address=e.address,this.chainId=e.chainId}async connect(){const e=await this.account();return this._isConnected=!0,this.emit("connect"),e}disconnect(){this._isConnected=!1,this.emit("disconnect")}isConnected(){return this._isConnected}async account(){const e=await this.request({method:"requestAccounts",params:{}});return JSON.parse(e)}network(){return this._network}getNetwork(){return BI.NETWORK}async signMessage(e){const t="APTOS",r=(await this.account()).address;let n=t;const i=window.location.protocol+"//"+window.location.hostname;e.address&&(n+="\naddress: "+r),e.application&&(n+="\napplication: "+i),e.chainId&&(n+="\nchainId: "+this.chainId),n+="\nmessage: "+e.message,n+="\nnonce: "+e.nonce;const o=C.from(n),s=BI.bufferToHex(o);return this.request({method:"signMessage",params:{data:s}}).then((o=>({address:r,application:i,chainId:this.chainId,fullMessage:n,message:e.message,nonce:e.nonce,prefix:t,signature:o})))}async signAndSubmitTransaction(e){const t=await this.signTransaction(e),r=await this.request({method:"sendTransaction",params:{tx:t}});return{hash:BI.messageToBuffer(r).toString()}}async signTransaction(e){const t=await this.request({method:"signTransaction",params:{data:e}});return JSON.parse(BI.messageToBuffer(t).toString())}};let II=BI;II.NETWORK="aptos";var TI=Object.defineProperty,RI=Object.defineProperties,OI=Object.getOwnPropertyDescriptors,LI=Object.getOwnPropertySymbols,MI=Object.prototype.hasOwnProperty,CI=Object.prototype.propertyIsEnumerable,PI=(e,t,r)=>t in e?TI(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,NI=(e,t)=>{for(var r in t||(t={}))MI.call(t,r)&&PI(e,r,t[r]);if(LI)for(var r of LI(t))CI.call(t,r)&&PI(e,r,t[r]);return e},UI=(e,t)=>{var r={};for(var n in e)MI.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&LI)for(var n of LI(e))t.indexOf(n)<0&&CI.call(e,n)&&(r[n]=e[n]);return r};class jI{constructor(e){this.provider=e}static mapToCamelCase(e){return NI(NI({},e),null!=e&&e.messages?{messages:(e?.messages||[]).map((e=>{var t=e,{state_init:r}=t,n=UI(t,["state_init"]);return((e,t)=>RI(e,OI(t)))(NI({},n),{stateInit:r})}))}:{})}async request(e,t){switch(e){case"tonConnect_connect":{const e=await this.provider.internalRequest("requestAccounts",t);return JSON.parse(e).map((e=>"ton_addr"===e.name?UI(e,["nonBounceable"]):e))}case"tonConnect_reconnect":{const e=await this.provider.internalRequest("tonConnect_reconnect",t);return JSON.parse(e)}case"ton_rawSign":return this.provider.internalRequest("signMessage",t);case"ton_sendTransaction":case"tonConnect_sendTransaction":{const r=await this.provider.internalRequest("signTransaction",jI.mapToCamelCase(t[0])),{nonce:n,hash:i}=JSON.parse(r);return"ton_sendTransaction"===e?n:i}case"ton_requestAccounts":{const e=await this.provider.internalRequest("requestAccounts",t),[{nonBounceable:r}]=JSON.parse(e);return[r]}case"ton_requestWallets":{const e=await this.provider.internalRequest("requestAccounts",t),[{nonBounceable:r,publicKey:n}]=JSON.parse(e);return[{address:r,publicKey:n,version:this.provider.version}]}default:return this.provider.internalRequest(e,t)}}}const $I=class extends He{constructor(e){super(),this.version="v4R2",e&&e.version&&(this.version=e.version),null!=e&&e.disableMobileAdapter||(this.mobileAdapter=new jI(this))}disconnect(){return this.send("tonConnect_disconnect",{})}isConnected(){return Promise.resolve(!0)}async send(e,t){return this.mobileAdapter?await this.mobileAdapter.request(e,t):await(()=>this.internalRequest(e,t))()}internalRequest(e,t){return super.request({method:e,params:t})}getNetwork(){return $I.NETWORK}};let HI=$I;HI.NETWORK="ton";class zI extends Error{constructor(e,t){super(e),this.code=t}}const DI=e=>{var t;return{event:"connect_error",payload:{code:null!=(t=e.code)?t:0,message:e.message}}};class FI{constructor(e,t){this.protocolVersion=2,this.isWalletBrowser=!0,this.callbacks=[],this.listen=e=>(this.callbacks.push(e),()=>{this.callbacks=this.callbacks.filter((t=>t!=e))}),e&&(typeof e.isWalletBrowser<"u"&&(this.isWalletBrowser=e.isWalletBrowser),e.walletInfo&&(this.walletInfo=e.walletInfo),e.deviceInfo&&(this.deviceInfo=e.deviceInfo)),this.provider=t}async connect(e,t){e>this.protocolVersion&&new zI("Unsupported protocol version",1);const r=await this.provider.send("tonConnect_connect",t);return"connect_error"===r?.event?this.emit(r):this.emit({event:"connect",payload:{items:r,device:this.deviceInfo}})}async disconnect(){return await this.provider.send("tonConnect_disconnect",{}),this.emit({event:"disconnect",payload:{}})}emit(e){return this.callbacks.forEach((t=>t(e))),e}async restoreConnection(){var e;try{const e=await this.provider.send("tonConnect_reconnect",[{name:"ton_addr"}]);return this.emit({event:"connect",payload:{items:e,device:this.deviceInfo}})}catch(t){return t instanceof zI?this.emit(DI(t)):this.emit(DI(new zI(null!=(e=t.message)?e:"Unknown error")))}}async send(e){try{return{result:await this.provider.send(`tonConnect_${e.method}`,e.params.map((e=>JSON.parse(e)))),id:e.id.toString()}}catch(t){return{error:t,id:String(e.id)}}}}window.trustwallet={core:(e,t)=>new ze({strategy:e,handler:t}),solana:e=>new yh(e),cosmos:e=>new cI(e),ethereum:e=>new rI(e),aptos:e=>new II(e),ton:e=>new HI(e),tonBridge:(e,t)=>new FI(e,t),randomUUID:()=>y()}})); diff --git a/packages/cosmos/CosmosProvider.ts b/packages/cosmos/CosmosProvider.ts index 8a726f07..dfcd8937 100644 --- a/packages/cosmos/CosmosProvider.ts +++ b/packages/cosmos/CosmosProvider.ts @@ -123,7 +123,7 @@ export class CosmosProvider extends BaseProvider implements ICosmosProvider { }, }); - return Buffer.from(hash, 'hex'); + return new Uint8Array(Buffer.from(hash, 'hex')); } async signArbitrary( diff --git a/packages/ios-web3-provider/swift/trust-min.js b/packages/ios-web3-provider/swift/trust-min.js index 75b6f91f..bfa7640e 100644 --- a/packages/ios-web3-provider/swift/trust-min.js +++ b/packages/ios-web3-provider/swift/trust-min.js @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c78063f16667a5e03fb244b5a39e2c7bcfdf01a168e8f5f0b0dced938d9e7b57 -size 678494 +oid sha256:aeb4921f8c17631b5a15a3e24daa1d325f66890e40927791284e0e74ad0fcabd +size 683705 diff --git a/packages/solana/SolanaProvider.ts b/packages/solana/SolanaProvider.ts index 52e9899a..4d75b17c 100644 --- a/packages/solana/SolanaProvider.ts +++ b/packages/solana/SolanaProvider.ts @@ -192,7 +192,9 @@ export class SolanaProvider extends BaseProvider implements ISolanaProvider { }); return { - signature: Buffer.from(SolanaProvider.messageToBuffer(res).buffer), + signature: new Uint8Array( + Buffer.from(SolanaProvider.messageToBuffer(res).buffer), + ), publicKey: this.publicKey?.toBase58(), }; } @@ -209,7 +211,10 @@ export class SolanaProvider extends BaseProvider implements ISolanaProvider { transaction: T, signatureEncoded: string, ) { - transaction.addSignature(this.publicKey!, bs58.decode(signatureEncoded)); + transaction.addSignature( + this.publicKey!, + bs58.decode(signatureEncoded) as Buffer & Uint8Array, + ); return transaction; } diff --git a/packages/solana/adapter/wallet.ts b/packages/solana/adapter/wallet.ts index ca9d290f..239fc6b4 100644 --- a/packages/solana/adapter/wallet.ts +++ b/packages/solana/adapter/wallet.ts @@ -229,7 +229,7 @@ export class TrustWallet implements Wallet { }, ); - outputs.push({ signature: bs58.decode(signature) }); + outputs.push({ signature: new Uint8Array(bs58.decode(signature)) }); } else if (inputs.length > 1) { for (const input of inputs) { outputs.push(...(await this.#signAndSendTransaction(input))); diff --git a/packages/ton/MobileAdapter.ts b/packages/ton/MobileAdapter.ts index 80071eba..49aba199 100644 --- a/packages/ton/MobileAdapter.ts +++ b/packages/ton/MobileAdapter.ts @@ -1,4 +1,5 @@ import { TonProvider } from './TonProvider'; +import { ConnectItemReply, TonAddressItemReply } from './types/TonBridge'; interface ITransaction { valid_until: number; @@ -41,7 +42,19 @@ export class MobileAdapter { 'requestAccounts', params, ); - return JSON.parse(res); + + // Internally we use nonBounceable value, here we remove it from the response + return JSON.parse(res).map((item: ConnectItemReply) => { + if (item.name === 'ton_addr') { + const { nonBounceable, ...rest } = item as TonAddressItemReply & { + nonBounceable: string; + }; + + return rest; + } + + return item; + }); } case 'tonConnect_reconnect': { diff --git a/packages/ton/types/TonBridge.ts b/packages/ton/types/TonBridge.ts index 2134a609..4b6e3065 100644 --- a/packages/ton/types/TonBridge.ts +++ b/packages/ton/types/TonBridge.ts @@ -41,7 +41,7 @@ type TonProofItem = { // Untrusted data returned by the wallet. // If you need a guarantee that the user owns this address and public key, you need to additionally request a ton_proof. -type TonAddressItemReply = { +export type TonAddressItemReply = { name: 'ton_addr'; address: string; // TON address raw (`0:`) network: NETWORK; // network global_id