@bonfida/spl-name-service 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +16 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +21 -21
- package/dist/index.mjs.map +1 -1
- package/dist/record.d.ts +1 -0
- package/dist/utils.d.ts +7 -0
- package/package.json +25 -18
package/dist/index.cjs
CHANGED
|
@@ -6,22 +6,22 @@
|
|
|
6
6
|
* @author Feross Aboukhadijeh <https://feross.org>
|
|
7
7
|
* @license MIT
|
|
8
8
|
*/
|
|
9
|
-
function(t){const e=i,r=p,n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=a,t.SlowBuffer=function(t){+t!=t&&(t=0);return a.alloc(+t)},t.INSPECT_MAX_BYTES=50;const o=2147483647;function s(t){if(t>o)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,a.prototype),e}function a(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return h(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!a.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=s(r);const i=n.write(t,e);i!==r&&(n=n.slice(0,i));return n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(Z(t,Uint8Array)){const e=new Uint8Array(t);return f(e.buffer,e.byteOffset,e.byteLength)}return l(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(Z(t,ArrayBuffer)||t&&Z(t.buffer,ArrayBuffer))return f(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(Z(t,SharedArrayBuffer)||t&&Z(t.buffer,SharedArrayBuffer)))return f(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return a.from(n,e,r);const i=function(t){if(a.isBuffer(t)){const e=0|d(t.length),r=s(e);return 0===r.length||t.copy(r,0,0,e),r}if(void 0!==t.length)return"number"!=typeof t.length||Y(t.length)?s(0):l(t);if("Buffer"===t.type&&Array.isArray(t.data))return l(t.data)}(t);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return a.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function c(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function h(t){return c(t),s(t<0?0:0|d(t))}function l(t){const e=t.length<0?0:0|d(t.length),r=s(e);for(let n=0;n<e;n+=1)r[n]=255&t[n];return r}function f(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,a.prototype),n}function d(t){if(t>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|t}function y(t,e){if(a.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Z(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return H(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return $(t).length;default:if(i)return n?-1:H(t).length;e=(""+e).toLowerCase(),i=!0}}function g(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return R(this,e,r);case"utf8":case"utf-8":return A(this,e,r);case"ascii":return B(this,e,r);case"latin1":case"binary":return M(this,e,r);case"base64":return S(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function m(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function w(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),Y(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=a.from(e,n)),a.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,i){let o,s=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,r/=2}function c(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){let n=-1;for(o=r;o<a;o++)if(c(t,o)===c(e,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===u)return n*s}else-1!==n&&(o-=o-n),n=-1}else for(r+u>a&&(r=a-u),o=r;o>=0;o--){let r=!0;for(let n=0;n<u;n++)if(c(t,o+n)!==c(e,n)){r=!1;break}if(r)return o}return-1}function v(t,e,r,n){r=Number(r)||0;const i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;const o=e.length;let s;for(n>o/2&&(n=o/2),s=0;s<n;++s){const n=parseInt(e.substr(2*s,2),16);if(Y(n))return s;t[r+s]=n}return s}function _(t,e,r,n){return G(H(e,t.length-r),t,r,n)}function k(t,e,r,n){return G(function(t){const e=[];for(let r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function E(t,e,r,n){return G($(e),t,r,n)}function x(t,e,r,n){return G(function(t,e){let r,n,i;const o=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function S(t,r,n){return 0===r&&n===t.length?e.fromByteArray(t):e.fromByteArray(t.slice(r,n))}function A(t,e,r){r=Math.min(t.length,r);const n=[];let i=e;for(;i<r;){const e=t[i];let o=null,s=e>239?4:e>223?3:e>191?2:1;if(i+s<=r){let r,n,a,u;switch(s){case 1:e<128&&(o=e);break;case 2:r=t[i+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(o=u));break;case 3:r=t[i+1],n=t[i+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(o=u));break;case 4:r=t[i+1],n=t[i+2],a=t[i+3],128==(192&r)&&128==(192&n)&&128==(192&a)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&a,u>65535&&u<1114112&&(o=u))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=s}return function(t){const e=t.length;if(e<=I)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=I));return r}(n)}t.kMaxLength=o,a.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),a.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}}),a.poolSize=8192,a.from=function(t,e,r){return u(t,e,r)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array),a.alloc=function(t,e,r){return function(t,e,r){return c(t),t<=0?s(t):void 0!==e?"string"==typeof r?s(t).fill(e,r):s(t).fill(e):s(t)}(t,e,r)},a.allocUnsafe=function(t){return h(t)},a.allocUnsafeSlow=function(t){return h(t)},a.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==a.prototype},a.compare=function(t,e){if(Z(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),Z(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(t)||!a.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,n=e.length;for(let i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},a.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return a.alloc(0);let r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;const n=a.allocUnsafe(e);let i=0;for(r=0;r<t.length;++r){let e=t[r];if(Z(e,Uint8Array))i+e.length>n.length?(a.isBuffer(e)||(e=a.from(e)),e.copy(n,i)):Uint8Array.prototype.set.call(n,e,i);else{if(!a.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,i)}i+=e.length}return n},a.byteLength=y,a.prototype._isBuffer=!0,a.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)m(this,e,e+1);return this},a.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)m(this,e,e+3),m(this,e+1,e+2);return this},a.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)m(this,e,e+7),m(this,e+1,e+6),m(this,e+2,e+5),m(this,e+3,e+4);return this},a.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?A(this,0,t):g.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(t){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===a.compare(this,t)},a.prototype.inspect=function(){let e="";const r=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},n&&(a.prototype[n]=a.prototype.inspect),a.prototype.compare=function(t,e,r,n,i){if(Z(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;let o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0);const u=Math.min(o,s),c=this.slice(n,i),h=t.slice(e,r);for(let t=0;t<u;++t)if(c[t]!==h[t]){o=c[t],s=h[t];break}return o<s?-1:s<o?1:0},a.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},a.prototype.indexOf=function(t,e,r){return w(this,t,e,r,!0)},a.prototype.lastIndexOf=function(t,e,r){return w(this,t,e,r,!1)},a.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let o=!1;for(;;)switch(n){case"hex":return v(this,t,e,r);case"utf8":case"utf-8":return _(this,t,e,r);case"ascii":case"latin1":case"binary":return k(this,t,e,r);case"base64":return E(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const I=4096;function B(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function M(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function R(t,e,r){const n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let n=e;n<r;++n)i+=J[t[n]];return i}function P(t,e,r){const n=t.slice(e,r);let i="";for(let t=0;t<n.length-1;t+=2)i+=String.fromCharCode(n[t]+256*n[t+1]);return i}function T(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function O(t,e,r,n,i,o){if(!a.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function L(t,e,r,n,i){K(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,r}function U(t,e,r,n,i){K(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o>>=8,t[r+6]=o,o>>=8,t[r+5]=o,o>>=8,t[r+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=s,s>>=8,t[r+2]=s,s>>=8,t[r+1]=s,s>>=8,t[r]=s,r+8}function C(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function N(t,e,n,i,o){return e=+e,n>>>=0,o||C(t,0,n,4),r.write(t,e,n,i,23,4),n+4}function z(t,e,n,i,o){return e=+e,n>>>=0,o||C(t,0,n,8),r.write(t,e,n,i,52,8),n+8}a.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);const n=this.subarray(t,e);return Object.setPrototypeOf(n,a.prototype),n},a.prototype.readUintLE=a.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return n},a.prototype.readUintBE=a.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);let n=this[t+--e],i=1;for(;e>0&&(i*=256);)n+=this[t+--e]*i;return n},a.prototype.readUint8=a.prototype.readUInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),this[t]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},a.prototype.readBigUInt64LE=X((function(t){F(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||q(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(i)<<BigInt(32))})),a.prototype.readBigUInt64BE=X((function(t){F(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||q(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<<BigInt(32))+BigInt(i)})),a.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*e)),n},a.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);let n=e,i=1,o=this[t+--n];for(;n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},a.prototype.readInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},a.prototype.readInt16LE=function(t,e){t>>>=0,e||T(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt16BE=function(t,e){t>>>=0,e||T(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},a.prototype.readInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},a.prototype.readBigInt64LE=X((function(t){F(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||q(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)})),a.prototype.readBigInt64BE=X((function(t){F(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||q(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+r)})),a.prototype.readFloatLE=function(t,e){return t>>>=0,e||T(t,4,this.length),r.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,e){return t>>>=0,e||T(t,4,this.length),r.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,e){return t>>>=0,e||T(t,8,this.length),r.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,e){return t>>>=0,e||T(t,8,this.length),r.read(this,t,!1,52,8)},a.prototype.writeUintLE=a.prototype.writeUIntLE=function(t,e,r,n){if(t=+t,e>>>=0,r>>>=0,!n){O(this,t,e,r,Math.pow(2,8*r)-1,0)}let i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(t,e,r,n){if(t=+t,e>>>=0,r>>>=0,!n){O(this,t,e,r,Math.pow(2,8*r)-1,0)}let i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},a.prototype.writeUint8=a.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,255,0),this[e]=255&t,e+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},a.prototype.writeBigUInt64LE=X((function(t,e=0){return L(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),a.prototype.writeBigUInt64BE=X((function(t,e=0){return U(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),a.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);O(this,t,e,r,n-1,-n)}let i=0,o=1,s=0;for(this[e]=255&t;++i<r&&(o*=256);)t<0&&0===s&&0!==this[e+i-1]&&(s=1),this[e+i]=(t/o>>0)-s&255;return e+r},a.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);O(this,t,e,r,n-1,-n)}let i=r-1,o=1,s=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/o>>0)-s&255;return e+r},a.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},a.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},a.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},a.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},a.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||O(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},a.prototype.writeBigInt64LE=X((function(t,e=0){return L(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),a.prototype.writeBigInt64BE=X((function(t,e=0){return U(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),a.prototype.writeFloatLE=function(t,e,r){return N(this,t,e,!0,r)},a.prototype.writeFloatBE=function(t,e,r){return N(this,t,e,!1,r)},a.prototype.writeDoubleLE=function(t,e,r){return z(this,t,e,!0,r)},a.prototype.writeDoubleBE=function(t,e,r){return z(this,t,e,!1,r)},a.prototype.copy=function(t,e,r,n){if(!a.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);const i=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),i},a.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!a.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){const e=t.charCodeAt(0);("utf8"===n&&e<128||"latin1"===n)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;let i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else{const o=a.isBuffer(t)?t:a.from(t,n),s=o.length;if(0===s)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<r-e;++i)this[i+e]=o[i%s]}return this};const D={};function j(t,e,r){D[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function W(t){let e="",r=t.length;const n="-"===t[0]?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function K(t,e,r,n,i,o){if(t>r||t<e){const n="bigint"==typeof e?"n":"";let i;throw i=o>3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(o+1)}${n}`:`>= -(2${n} ** ${8*(o+1)-1}${n}) and < 2 ** ${8*(o+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new D.ERR_OUT_OF_RANGE("value",i,t)}!function(t,e,r){F(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||q(e,t.length-(r+1))}(n,i,o)}function F(t,e){if("number"!=typeof t)throw new D.ERR_INVALID_ARG_TYPE(e,"number",t)}function q(t,e,r){if(Math.floor(t)!==t)throw F(t,r),new D.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new D.ERR_BUFFER_OUT_OF_BOUNDS;throw new D.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}j("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),j("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),j("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=W(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=W(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n}),RangeError);const V=/[^+/0-9A-Za-z-_]/g;function H(t,e){let r;e=e||1/0;const n=t.length;let i=null;const o=[];for(let s=0;s<n;++s){if(r=t.charCodeAt(s),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=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((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function $(t){return e.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(V,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function G(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function Z(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function Y(t){return t!=t}const J=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function X(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}}(n);const b="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,v=t=>t instanceof Uint8Array,_=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),k=(t,e)=>t<<32-e|t>>>e;
|
|
10
|
-
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */if(!(68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]))throw new Error("Non little-endian hardware is not supported");function E(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}function x(t){if("string"==typeof t&&(t=E(t)),!v(t))throw new Error("expected Uint8Array, got "+typeof t);return t}function S(...t){const e=new Uint8Array(t.reduce(((t,e)=>t+e.length),0));let r=0;return t.forEach((t=>{if(!v(t))throw new Error("Uint8Array expected");e.set(t,r),r+=t.length})),e}class A{clone(){return this._cloneInto()}}function I(t){const e=e=>t().update(x(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function B(t=32){if(b&&"function"==typeof b.getRandomValues)return b.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}class M extends A{constructor(t,e,r,n){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=_(this.buffer)}update(t){m(this);const{view:e,buffer:r,blockLen:n}=this,i=(t=x(t)).length;for(let o=0;o<i;){const s=Math.min(n-this.pos,i-o);if(s!==n)r.set(t.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===n&&(this.process(e,0),this.pos=0);else{const e=_(t);for(;n<=i-o;o+=n)this.process(e,o)}}return this.length+=t.length,this.roundClean(),this}digestInto(t){m(this),w(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:n,isLE:i}=this;let{pos:o}=this;e[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>n-o&&(this.process(r,0),o=0);for(let t=o;t<n;t++)e[t]=0;!function(t,e,r,n){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,r,n);const i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),a=Number(r&o),u=n?4:0,c=n?0:4;t.setUint32(e+u,s,n),t.setUint32(e+c,a,n)}(r,n-8,BigInt(8*this.length),i),this.process(r,0);const s=_(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=a/4,c=this.get();if(u>c.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<u;t++)s.setUint32(4*t,c[t],i)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:r,length:n,finished:i,destroyed:o,pos:s}=this;return t.length=n,t.pos=s,t.finished=i,t.destroyed=o,n%e&&t.buffer.set(r),t}}const R=BigInt(2**32-1),P=BigInt(32);function T(t,e=!1){return e?{h:Number(t&R),l:Number(t>>P&R)}:{h:0|Number(t>>P&R),l:0|Number(t&R)}}function
|
|
9
|
+
function(t){const e=i,r=p,n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=a,t.SlowBuffer=function(t){+t!=t&&(t=0);return a.alloc(+t)},t.INSPECT_MAX_BYTES=50;const o=2147483647;function s(t){if(t>o)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,a.prototype),e}function a(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return h(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!a.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=s(r);const i=n.write(t,e);i!==r&&(n=n.slice(0,i));return n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(Z(t,Uint8Array)){const e=new Uint8Array(t);return f(e.buffer,e.byteOffset,e.byteLength)}return l(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(Z(t,ArrayBuffer)||t&&Z(t.buffer,ArrayBuffer))return f(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(Z(t,SharedArrayBuffer)||t&&Z(t.buffer,SharedArrayBuffer)))return f(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return a.from(n,e,r);const i=function(t){if(a.isBuffer(t)){const e=0|d(t.length),r=s(e);return 0===r.length||t.copy(r,0,0,e),r}if(void 0!==t.length)return"number"!=typeof t.length||Y(t.length)?s(0):l(t);if("Buffer"===t.type&&Array.isArray(t.data))return l(t.data)}(t);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return a.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function c(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function h(t){return c(t),s(t<0?0:0|d(t))}function l(t){const e=t.length<0?0:0|d(t.length),r=s(e);for(let n=0;n<e;n+=1)r[n]=255&t[n];return r}function f(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,a.prototype),n}function d(t){if(t>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|t}function y(t,e){if(a.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Z(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return H(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return $(t).length;default:if(i)return n?-1:H(t).length;e=(""+e).toLowerCase(),i=!0}}function g(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return R(this,e,r);case"utf8":case"utf-8":return A(this,e,r);case"ascii":return B(this,e,r);case"latin1":case"binary":return M(this,e,r);case"base64":return S(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function m(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function w(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),Y(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=a.from(e,n)),a.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,i){let o,s=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,r/=2}function c(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){let n=-1;for(o=r;o<a;o++)if(c(t,o)===c(e,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===u)return n*s}else-1!==n&&(o-=o-n),n=-1}else for(r+u>a&&(r=a-u),o=r;o>=0;o--){let r=!0;for(let n=0;n<u;n++)if(c(t,o+n)!==c(e,n)){r=!1;break}if(r)return o}return-1}function v(t,e,r,n){r=Number(r)||0;const i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;const o=e.length;let s;for(n>o/2&&(n=o/2),s=0;s<n;++s){const n=parseInt(e.substr(2*s,2),16);if(Y(n))return s;t[r+s]=n}return s}function _(t,e,r,n){return G(H(e,t.length-r),t,r,n)}function k(t,e,r,n){return G(function(t){const e=[];for(let r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function E(t,e,r,n){return G($(e),t,r,n)}function x(t,e,r,n){return G(function(t,e){let r,n,i;const o=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function S(t,r,n){return 0===r&&n===t.length?e.fromByteArray(t):e.fromByteArray(t.slice(r,n))}function A(t,e,r){r=Math.min(t.length,r);const n=[];let i=e;for(;i<r;){const e=t[i];let o=null,s=e>239?4:e>223?3:e>191?2:1;if(i+s<=r){let r,n,a,u;switch(s){case 1:e<128&&(o=e);break;case 2:r=t[i+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(o=u));break;case 3:r=t[i+1],n=t[i+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(o=u));break;case 4:r=t[i+1],n=t[i+2],a=t[i+3],128==(192&r)&&128==(192&n)&&128==(192&a)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&a,u>65535&&u<1114112&&(o=u))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=s}return function(t){const e=t.length;if(e<=I)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=I));return r}(n)}t.kMaxLength=o,a.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),a.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}}),a.poolSize=8192,a.from=function(t,e,r){return u(t,e,r)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array),a.alloc=function(t,e,r){return function(t,e,r){return c(t),t<=0?s(t):void 0!==e?"string"==typeof r?s(t).fill(e,r):s(t).fill(e):s(t)}(t,e,r)},a.allocUnsafe=function(t){return h(t)},a.allocUnsafeSlow=function(t){return h(t)},a.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==a.prototype},a.compare=function(t,e){if(Z(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),Z(e,Uint8Array)&&(e=a.from(e,e.offset,e.byteLength)),!a.isBuffer(t)||!a.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,n=e.length;for(let i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},a.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return a.alloc(0);let r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;const n=a.allocUnsafe(e);let i=0;for(r=0;r<t.length;++r){let e=t[r];if(Z(e,Uint8Array))i+e.length>n.length?(a.isBuffer(e)||(e=a.from(e)),e.copy(n,i)):Uint8Array.prototype.set.call(n,e,i);else{if(!a.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,i)}i+=e.length}return n},a.byteLength=y,a.prototype._isBuffer=!0,a.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)m(this,e,e+1);return this},a.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)m(this,e,e+3),m(this,e+1,e+2);return this},a.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)m(this,e,e+7),m(this,e+1,e+6),m(this,e+2,e+5),m(this,e+3,e+4);return this},a.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?A(this,0,t):g.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(t){if(!a.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===a.compare(this,t)},a.prototype.inspect=function(){let e="";const r=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},n&&(a.prototype[n]=a.prototype.inspect),a.prototype.compare=function(t,e,r,n,i){if(Z(t,Uint8Array)&&(t=a.from(t,t.offset,t.byteLength)),!a.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;let o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0);const u=Math.min(o,s),c=this.slice(n,i),h=t.slice(e,r);for(let t=0;t<u;++t)if(c[t]!==h[t]){o=c[t],s=h[t];break}return o<s?-1:s<o?1:0},a.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},a.prototype.indexOf=function(t,e,r){return w(this,t,e,r,!0)},a.prototype.lastIndexOf=function(t,e,r){return w(this,t,e,r,!1)},a.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let o=!1;for(;;)switch(n){case"hex":return v(this,t,e,r);case"utf8":case"utf-8":return _(this,t,e,r);case"ascii":case"latin1":case"binary":return k(this,t,e,r);case"base64":return E(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const I=4096;function B(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function M(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function R(t,e,r){const n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let n=e;n<r;++n)i+=J[t[n]];return i}function P(t,e,r){const n=t.slice(e,r);let i="";for(let t=0;t<n.length-1;t+=2)i+=String.fromCharCode(n[t]+256*n[t+1]);return i}function T(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function L(t,e,r,n,i,o){if(!a.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function O(t,e,r,n,i){F(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,r}function U(t,e,r,n,i){F(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o>>=8,t[r+6]=o,o>>=8,t[r+5]=o,o>>=8,t[r+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=s,s>>=8,t[r+2]=s,s>>=8,t[r+1]=s,s>>=8,t[r]=s,r+8}function C(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function N(t,e,n,i,o){return e=+e,n>>>=0,o||C(t,0,n,4),r.write(t,e,n,i,23,4),n+4}function z(t,e,n,i,o){return e=+e,n>>>=0,o||C(t,0,n,8),r.write(t,e,n,i,52,8),n+8}a.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);const n=this.subarray(t,e);return Object.setPrototypeOf(n,a.prototype),n},a.prototype.readUintLE=a.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return n},a.prototype.readUintBE=a.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);let n=this[t+--e],i=1;for(;e>0&&(i*=256);)n+=this[t+--e]*i;return n},a.prototype.readUint8=a.prototype.readUInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),this[t]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]|this[t+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]<<8|this[t+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},a.prototype.readBigUInt64LE=X((function(t){K(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||V(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(i)<<BigInt(32))})),a.prototype.readBigUInt64BE=X((function(t){K(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||V(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<<BigInt(32))+BigInt(i)})),a.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*e)),n},a.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||T(t,e,this.length);let n=e,i=1,o=this[t+--n];for(;n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},a.prototype.readInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},a.prototype.readInt16LE=function(t,e){t>>>=0,e||T(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt16BE=function(t,e){t>>>=0,e||T(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},a.prototype.readInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},a.prototype.readBigInt64LE=X((function(t){K(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||V(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)})),a.prototype.readBigInt64BE=X((function(t){K(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||V(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+r)})),a.prototype.readFloatLE=function(t,e){return t>>>=0,e||T(t,4,this.length),r.read(this,t,!0,23,4)},a.prototype.readFloatBE=function(t,e){return t>>>=0,e||T(t,4,this.length),r.read(this,t,!1,23,4)},a.prototype.readDoubleLE=function(t,e){return t>>>=0,e||T(t,8,this.length),r.read(this,t,!0,52,8)},a.prototype.readDoubleBE=function(t,e){return t>>>=0,e||T(t,8,this.length),r.read(this,t,!1,52,8)},a.prototype.writeUintLE=a.prototype.writeUIntLE=function(t,e,r,n){if(t=+t,e>>>=0,r>>>=0,!n){L(this,t,e,r,Math.pow(2,8*r)-1,0)}let i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(t,e,r,n){if(t=+t,e>>>=0,r>>>=0,!n){L(this,t,e,r,Math.pow(2,8*r)-1,0)}let i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},a.prototype.writeUint8=a.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,1,255,0),this[e]=255&t,e+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},a.prototype.writeBigUInt64LE=X((function(t,e=0){return O(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),a.prototype.writeBigUInt64BE=X((function(t,e=0){return U(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),a.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);L(this,t,e,r,n-1,-n)}let i=0,o=1,s=0;for(this[e]=255&t;++i<r&&(o*=256);)t<0&&0===s&&0!==this[e+i-1]&&(s=1),this[e+i]=(t/o>>0)-s&255;return e+r},a.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);L(this,t,e,r,n-1,-n)}let i=r-1,o=1,s=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/o>>0)-s&255;return e+r},a.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},a.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},a.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},a.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},a.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||L(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},a.prototype.writeBigInt64LE=X((function(t,e=0){return O(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),a.prototype.writeBigInt64BE=X((function(t,e=0){return U(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),a.prototype.writeFloatLE=function(t,e,r){return N(this,t,e,!0,r)},a.prototype.writeFloatBE=function(t,e,r){return N(this,t,e,!1,r)},a.prototype.writeDoubleLE=function(t,e,r){return z(this,t,e,!0,r)},a.prototype.writeDoubleBE=function(t,e,r){return z(this,t,e,!1,r)},a.prototype.copy=function(t,e,r,n){if(!a.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);const i=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),i},a.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!a.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){const e=t.charCodeAt(0);("utf8"===n&&e<128||"latin1"===n)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;let i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else{const o=a.isBuffer(t)?t:a.from(t,n),s=o.length;if(0===s)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<r-e;++i)this[i+e]=o[i%s]}return this};const D={};function j(t,e,r){D[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function W(t){let e="",r=t.length;const n="-"===t[0]?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function F(t,e,r,n,i,o){if(t>r||t<e){const n="bigint"==typeof e?"n":"";let i;throw i=o>3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(o+1)}${n}`:`>= -(2${n} ** ${8*(o+1)-1}${n}) and < 2 ** ${8*(o+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new D.ERR_OUT_OF_RANGE("value",i,t)}!function(t,e,r){K(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||V(e,t.length-(r+1))}(n,i,o)}function K(t,e){if("number"!=typeof t)throw new D.ERR_INVALID_ARG_TYPE(e,"number",t)}function V(t,e,r){if(Math.floor(t)!==t)throw K(t,r),new D.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new D.ERR_BUFFER_OUT_OF_BOUNDS;throw new D.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}j("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),j("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),j("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=W(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=W(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n}),RangeError);const q=/[^+/0-9A-Za-z-_]/g;function H(t,e){let r;e=e||1/0;const n=t.length;let i=null;const o=[];for(let s=0;s<n;++s){if(r=t.charCodeAt(s),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=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((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function $(t){return e.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(q,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function G(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function Z(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function Y(t){return t!=t}const J=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function X(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}}(n);const b="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,v=t=>t instanceof Uint8Array,_=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),k=(t,e)=>t<<32-e|t>>>e;
|
|
10
|
+
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */if(!(68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]))throw new Error("Non little-endian hardware is not supported");function E(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}function x(t){if("string"==typeof t&&(t=E(t)),!v(t))throw new Error("expected Uint8Array, got "+typeof t);return t}function S(...t){const e=new Uint8Array(t.reduce(((t,e)=>t+e.length),0));let r=0;return t.forEach((t=>{if(!v(t))throw new Error("Uint8Array expected");e.set(t,r),r+=t.length})),e}class A{clone(){return this._cloneInto()}}function I(t){const e=e=>t().update(x(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function B(t=32){if(b&&"function"==typeof b.getRandomValues)return b.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}class M extends A{constructor(t,e,r,n){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=_(this.buffer)}update(t){m(this);const{view:e,buffer:r,blockLen:n}=this,i=(t=x(t)).length;for(let o=0;o<i;){const s=Math.min(n-this.pos,i-o);if(s!==n)r.set(t.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===n&&(this.process(e,0),this.pos=0);else{const e=_(t);for(;n<=i-o;o+=n)this.process(e,o)}}return this.length+=t.length,this.roundClean(),this}digestInto(t){m(this),w(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:n,isLE:i}=this;let{pos:o}=this;e[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>n-o&&(this.process(r,0),o=0);for(let t=o;t<n;t++)e[t]=0;!function(t,e,r,n){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,r,n);const i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),a=Number(r&o),u=n?4:0,c=n?0:4;t.setUint32(e+u,s,n),t.setUint32(e+c,a,n)}(r,n-8,BigInt(8*this.length),i),this.process(r,0);const s=_(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=a/4,c=this.get();if(u>c.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<u;t++)s.setUint32(4*t,c[t],i)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:r,length:n,finished:i,destroyed:o,pos:s}=this;return t.length=n,t.pos=s,t.finished=i,t.destroyed=o,n%e&&t.buffer.set(r),t}}const R=BigInt(2**32-1),P=BigInt(32);function T(t,e=!1){return e?{h:Number(t&R),l:Number(t>>P&R)}:{h:0|Number(t>>P&R),l:0|Number(t&R)}}function L(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;i<t.length;i++){const{h:o,l:s}=T(t[i],e);[r[i],n[i]]=[o,s]}return[r,n]}const O=(t,e,r)=>t<<r|e>>>32-r,U=(t,e,r)=>e<<r|t>>>32-r,C=(t,e,r)=>e<<r-32|t>>>64-r,N=(t,e,r)=>t<<r-32|e>>>64-r;const z={fromBig:T,split:L,toBig:(t,e)=>BigInt(t>>>0)<<P|BigInt(e>>>0),shrSH:(t,e,r)=>t>>>r,shrSL:(t,e,r)=>t<<32-r|e>>>r,rotrSH:(t,e,r)=>t>>>r|e<<32-r,rotrSL:(t,e,r)=>t<<32-r|e>>>r,rotrBH:(t,e,r)=>t<<64-r|e>>>r-32,rotrBL:(t,e,r)=>t>>>r-32|e<<64-r,rotr32H:(t,e)=>e,rotr32L:(t,e)=>t,rotlSH:O,rotlSL:U,rotlBH:C,rotlBL:N,add:function(t,e,r,n){const i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:0|i}},add3L:(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),add3H:(t,e,r,n)=>e+r+n+(t/2**32|0)|0,add4L:(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),add4H:(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0,add5H:(t,e,r,n,i,o)=>e+r+n+i+o+(t/2**32|0)|0,add5L:(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0)};var D=z;const[j,W]=(()=>D.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((t=>BigInt(t)))))(),F=new Uint32Array(80),K=new Uint32Array(80);class V extends M{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:t,Al:e,Bh:r,Bl:n,Ch:i,Cl:o,Dh:s,Dl:a,Eh:u,El:c,Fh:h,Fl:l,Gh:f,Gl:d,Hh:p,Hl:y}=this;return[t,e,r,n,i,o,s,a,u,c,h,l,f,d,p,y]}set(t,e,r,n,i,o,s,a,u,c,h,l,f,d,p,y){this.Ah=0|t,this.Al=0|e,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|u,this.El=0|c,this.Fh=0|h,this.Fl=0|l,this.Gh=0|f,this.Gl=0|d,this.Hh=0|p,this.Hl=0|y}process(t,e){for(let r=0;r<16;r++,e+=4)F[r]=t.getUint32(e),K[r]=t.getUint32(e+=4);for(let t=16;t<80;t++){const e=0|F[t-15],r=0|K[t-15],n=D.rotrSH(e,r,1)^D.rotrSH(e,r,8)^D.shrSH(e,r,7),i=D.rotrSL(e,r,1)^D.rotrSL(e,r,8)^D.shrSL(e,r,7),o=0|F[t-2],s=0|K[t-2],a=D.rotrSH(o,s,19)^D.rotrBH(o,s,61)^D.shrSH(o,s,6),u=D.rotrSL(o,s,19)^D.rotrBL(o,s,61)^D.shrSL(o,s,6),c=D.add4L(i,u,K[t-7],K[t-16]),h=D.add4H(c,n,a,F[t-7],F[t-16]);F[t]=0|h,K[t]=0|c}let{Ah:r,Al:n,Bh:i,Bl:o,Ch:s,Cl:a,Dh:u,Dl:c,Eh:h,El:l,Fh:f,Fl:d,Gh:p,Gl:y,Hh:g,Hl:m}=this;for(let t=0;t<80;t++){const e=D.rotrSH(h,l,14)^D.rotrSH(h,l,18)^D.rotrBH(h,l,41),w=D.rotrSL(h,l,14)^D.rotrSL(h,l,18)^D.rotrBL(h,l,41),b=h&f^~h&p,v=l&d^~l&y,_=D.add5L(m,w,v,W[t],K[t]),k=D.add5H(_,g,e,b,j[t],F[t]),E=0|_,x=D.rotrSH(r,n,28)^D.rotrBH(r,n,34)^D.rotrBH(r,n,39),S=D.rotrSL(r,n,28)^D.rotrBL(r,n,34)^D.rotrBL(r,n,39),A=r&i^r&s^i&s,I=n&o^n&a^o&a;g=0|p,m=0|y,p=0|f,y=0|d,f=0|h,d=0|l,({h:h,l:l}=D.add(0|u,0|c,0|k,0|E)),u=0|s,c=0|a,s=0|i,a=0|o,i=0|r,o=0|n;const B=D.add3L(E,S,I);r=D.add3H(B,k,x,A),n=0|B}({h:r,l:n}=D.add(0|this.Ah,0|this.Al,0|r,0|n)),({h:i,l:o}=D.add(0|this.Bh,0|this.Bl,0|i,0|o)),({h:s,l:a}=D.add(0|this.Ch,0|this.Cl,0|s,0|a)),({h:u,l:c}=D.add(0|this.Dh,0|this.Dl,0|u,0|c)),({h:h,l:l}=D.add(0|this.Eh,0|this.El,0|h,0|l)),({h:f,l:d}=D.add(0|this.Fh,0|this.Fl,0|f,0|d)),({h:p,l:y}=D.add(0|this.Gh,0|this.Gl,0|p,0|y)),({h:g,l:m}=D.add(0|this.Hh,0|this.Hl,0|g,0|m)),this.set(r,n,i,o,s,a,u,c,h,l,f,d,p,y,g,m)}roundClean(){F.fill(0),K.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 q=I((()=>new V)),H=BigInt(0),$=BigInt(1),G=BigInt(2),Z=t=>t instanceof Uint8Array,Y=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));
|
|
11
11
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function J(t){if(!Z(t))throw new Error("Uint8Array expected");let e="";for(let r=0;r<t.length;r++)e+=Y[t[r]];return e}function X(t){const e=t.toString(16);return 1&e.length?`0${e}`:e}function Q(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);return BigInt(""===t?"0":`0x${t}`)}function tt(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);const e=t.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(e/2);for(let e=0;e<r.length;e++){const n=2*e,i=t.slice(n,n+2),o=Number.parseInt(i,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");r[e]=o}return r}function et(t){return Q(J(t))}function rt(t){if(!Z(t))throw new Error("Uint8Array expected");return Q(J(Uint8Array.from(t).reverse()))}function nt(t,e){return tt(t.toString(16).padStart(2*e,"0"))}function it(t,e){return nt(t,e).reverse()}function ot(t,e,r){let n;if("string"==typeof e)try{n=tt(e)}catch(r){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${r}`)}else{if(!Z(e))throw new Error(`${t} must be hex string or Uint8Array`);n=Uint8Array.from(e)}const i=n.length;if("number"==typeof r&&i!==r)throw new Error(`${t} expected ${r} bytes, got ${i}`);return n}function st(...t){const e=new Uint8Array(t.reduce(((t,e)=>t+e.length),0));let r=0;return t.forEach((t=>{if(!Z(t))throw new Error("Uint8Array expected");e.set(t,r),r+=t.length})),e}const at=t=>(G<<BigInt(t-1))-$,ut=t=>new Uint8Array(t),ct=t=>Uint8Array.from(t);function ht(t,e,r){if("number"!=typeof t||t<2)throw new Error("hashLen must be a number");if("number"!=typeof e||e<2)throw new Error("qByteLen must be a number");if("function"!=typeof r)throw new Error("hmacFn must be a function");let n=ut(t),i=ut(t),o=0;const s=()=>{n.fill(1),i.fill(0),o=0},a=(...t)=>r(i,n,...t),u=(t=ut())=>{i=a(ct([0]),t),n=a(),0!==t.length&&(i=a(ct([1]),t),n=a())},c=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let t=0;const r=[];for(;t<e;){n=a();const e=n.slice();r.push(e),t+=n.length}return st(...r)};return(t,e)=>{let r;for(s(),u(t);!(r=e(c()));)u();return s(),r}}const lt={bigint:t=>"bigint"==typeof t,function:t=>"function"==typeof t,boolean:t=>"boolean"==typeof t,string:t=>"string"==typeof t,stringOrUint8Array:t=>"string"==typeof t||t instanceof Uint8Array,isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>"function"==typeof t&&Number.isSafeInteger(t.outputLen)};function ft(t,e,r={}){const n=(e,r,n)=>{const i=lt[r];if("function"!=typeof i)throw new Error(`Invalid validator "${r}", expected function`);const o=t[e];if(!(n&&void 0===o||i(o,t)))throw new Error(`Invalid param ${String(e)}=${o} (${typeof o}), expected ${r}`)};for(const[t,r]of Object.entries(e))n(t,r,!1);for(const[t,e]of Object.entries(r))n(t,e,!0);return t}var dt=Object.freeze({__proto__:null,bytesToHex:J,numberToHexUnpadded:X,hexToNumber:Q,hexToBytes:tt,bytesToNumberBE:et,bytesToNumberLE:rt,numberToBytesBE:nt,numberToBytesLE:it,numberToVarBytesBE:function(t){return tt(X(t))},ensureBytes:ot,concatBytes:st,equalBytes:function(t,e){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0},utf8ToBytes:function(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))},bitLen:function(t){let e;for(e=0;t>H;t>>=$,e+=1);return e},bitGet:function(t,e){return t>>BigInt(e)&$},bitSet:(t,e,r)=>t|(r?$:H)<<BigInt(e),bitMask:at,createHmacDrbg:ht,validateObject:ft});
|
|
12
12
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const pt=BigInt(0),yt=BigInt(1),gt=BigInt(2),mt=BigInt(3),wt=BigInt(4),bt=BigInt(5),vt=BigInt(8);function _t(t,e){const r=t%e;return r>=pt?r:e+r}function kt(t,e,r){if(r<=pt||e<pt)throw new Error("Expected power/modulo > 0");if(r===yt)return pt;let n=yt;for(;e>pt;)e&yt&&(n=n*t%r),t=t*t%r,e>>=yt;return n}function Et(t,e,r){let n=t;for(;e-- >pt;)n*=n,n%=r;return n}function xt(t,e){if(t===pt||e<=pt)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=_t(t,e),n=e,i=pt,o=yt;for(;r!==pt;){const t=n%r,e=i-o*(n/r);n=r,r=t,i=o,o=e}if(n!==yt)throw new Error("invert: does not exist");return _t(i,e)}function St(t){if(t%wt===mt){const e=(t+yt)/wt;return function(t,r){const n=t.pow(r,e);if(!t.eql(t.sqr(n),r))throw new Error("Cannot find square root");return n}}if(t%vt===bt){const e=(t-bt)/vt;return function(t,r){const n=t.mul(r,gt),i=t.pow(n,e),o=t.mul(r,i),s=t.mul(t.mul(o,gt),i),a=t.mul(o,t.sub(s,t.ONE));if(!t.eql(t.sqr(a),r))throw new Error("Cannot find square root");return a}}return function(t){const e=(t-yt)/gt;let r,n,i;for(r=t-yt,n=0;r%gt===pt;r/=gt,n++);for(i=gt;i<t&&kt(i,e,t)!==t-yt;i++);if(1===n){const e=(t+yt)/wt;return function(t,r){const n=t.pow(r,e);if(!t.eql(t.sqr(n),r))throw new Error("Cannot find square root");return n}}const o=(r+yt)/gt;return function(t,s){if(t.pow(s,e)===t.neg(t.ONE))throw new Error("Cannot find square root");let a=n,u=t.pow(t.mul(t.ONE,i),r),c=t.pow(s,o),h=t.pow(s,r);for(;!t.eql(h,t.ONE);){if(t.eql(h,t.ZERO))return t.ZERO;let e=1;for(let r=t.sqr(h);e<a&&!t.eql(r,t.ONE);e++)r=t.sqr(r);const r=t.pow(u,yt<<BigInt(a-e-1));u=t.sqr(r),c=t.mul(c,r),h=t.mul(h,u),a=e}return c}}(t)}BigInt(9),BigInt(16);const At=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function It(t,e){const r=void 0!==e?e:t.toString(2).length;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}function Bt(t,e,r=!1,n={}){if(t<=pt)throw new Error(`Expected Field ORDER > 0, got ${t}`);const{nBitLength:i,nByteLength:o}=It(t,e);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");const s=St(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:o,MASK:at(i),ZERO:pt,ONE:yt,create:e=>_t(e,t),isValid:e=>{if("bigint"!=typeof e)throw new Error("Invalid field element: expected bigint, got "+typeof e);return pt<=e&&e<t},is0:t=>t===pt,isOdd:t=>(t&yt)===yt,neg:e=>_t(-e,t),eql:(t,e)=>t===e,sqr:e=>_t(e*e,t),add:(e,r)=>_t(e+r,t),sub:(e,r)=>_t(e-r,t),mul:(e,r)=>_t(e*r,t),pow:(t,e)=>function(t,e,r){if(r<pt)throw new Error("Expected power > 0");if(r===pt)return t.ONE;if(r===yt)return e;let n=t.ONE,i=e;for(;r>pt;)r&yt&&(n=t.mul(n,i)),i=t.sqr(i),r>>=yt;return n}(a,t,e),div:(e,r)=>_t(e*xt(r,t),t),sqrN:t=>t*t,addN:(t,e)=>t+e,subN:(t,e)=>t-e,mulN:(t,e)=>t*e,inv:e=>xt(e,t),sqrt:n.sqrt||(t=>s(a,t)),invertBatch:t=>function(t,e){const r=new Array(e.length),n=e.reduce(((e,n,i)=>t.is0(n)?e:(r[i]=e,t.mul(e,n))),t.ONE),i=t.inv(n);return e.reduceRight(((e,n,i)=>t.is0(n)?e:(r[i]=t.mul(e,r[i]),t.mul(e,n))),i),r}(a,t),cmov:(t,e,r)=>r?e:t,toBytes:t=>r?it(t,o):nt(t,o),fromBytes:t=>{if(t.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${t.length}`);return r?rt(t):et(t)}});return Object.freeze(a)}function Mt(t){if("bigint"!=typeof t)throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function Rt(t){const e=Mt(t);return e+Math.ceil(e/2)}
|
|
13
13
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
14
|
-
const Pt=BigInt(0),Tt=BigInt(1);function
|
|
15
|
-
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ut=BigInt(0),Ct=BigInt(1),Nt=BigInt(2),zt=BigInt(8),Dt={zip215:!0};function jt(t){const e=function(t){const e=
|
|
16
|
-
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Wt=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Kt=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const Ft=BigInt(1),qt=BigInt(2),Vt=BigInt(5),Ht=BigInt(10),$t=BigInt(20),Gt=BigInt(40),Zt=BigInt(80);const Yt=Bt(Wt,void 0,!0),Jt={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Yt,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:V,randomBytes:B,adjustScalarBytes:function(t){return t[0]&=248,t[31]&=127,t[31]|=64,t},uvRatio:function(t,e){const r=Wt,n=_t(e*e*e,r),i=function(t){const e=Wt,r=t*t%e*t%e,n=Et(r,qt,e)*r%e,i=Et(n,Ft,e)*t%e,o=Et(i,Vt,e)*i%e,s=Et(o,Ht,e)*o%e,a=Et(s,$t,e)*s%e,u=Et(a,Gt,e)*a%e,c=Et(u,Zt,e)*u%e,h=Et(c,Zt,e)*u%e,l=Et(h,Ht,e)*o%e;return{pow_p_5_8:Et(l,qt,e)*t%e,b2:r}}(t*_t(n*n*e,r)).pow_p_5_8;let o=_t(t*n*i,r);const s=_t(e*o*o,r),a=o,u=_t(o*Kt,r),c=s===t,h=s===_t(-t,r),l=s===_t(-t*Kt,r);return c&&(o=a),(h||l)&&(o=u),(_t(o,r)&yt)===yt&&(o=_t(-o,r)),{isValid:c||h,value:o}}},Xt=jt(Jt);const Qt=(Yt.ORDER+BigInt(3))/BigInt(8);Yt.pow(qt,Qt),Yt.sqrt(Yt.neg(Yt.ONE)),Yt.ORDER,BigInt(5),BigInt(8),BigInt(486662),function(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");const r=t.sqrt(e);t.isOdd(r)&&t.neg(r)}(Yt,Yt.neg(BigInt(486664))),BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");var te={exports:{}},ee=r(Object.freeze({__proto__:null,default:{}}));!function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function n(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function i(t,e,r){if(i.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var o;"object"==typeof t?t.exports=i:e.BN=i,i.BN=i,i.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:ee.Buffer}catch(t){}function s(t,e){var n=t.charCodeAt(e);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 "+t)}function a(t,e,r){var n=s(t,r);return r-1>=e&&(n|=s(t,r-1)<<4),n}function u(t,e,n,i){for(var o=0,s=0,a=Math.min(t.length,n),u=e;u<a;u++){var c=t.charCodeAt(u)-48;o*=i,s=c>=49?c-49+10:c>=17?c-17+10:c,r(c>=0&&s<i,"Invalid character"),o+=s}return o}function c(t,e){t.words=e.words,t.length=e.length,t.negative=e.negative,t.red=e.red}if(i.isBN=function(t){return t instanceof i||null!==t&&"object"==typeof t&&t.constructor.wordSize===i.wordSize&&Array.isArray(t.words)},i.max=function(t,e){return t.cmp(e)>0?t:e},i.min=function(t,e){return t.cmp(e)<0?t:e},i.prototype._init=function(t,e,n){if("number"==typeof t)return this._initNumber(t,e,n);if("object"==typeof t)return this._initArray(t,e,n);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var i=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(i++,this.negative=1),i<t.length&&(16===e?this._parseHex(t,i,n):(this._parseBase(t,e,i),"le"===n&&this._initArray(this.toArray(),e,n)))},i.prototype._initNumber=function(t,e,n){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),e,n)},i.prototype._initArray=function(t,e,n){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var o,s,a=0;if("be"===n)for(i=t.length-1,o=0;i>=0;i-=3)s=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===n)for(i=0,o=0;i<t.length;i+=3)s=t[i]|t[i+1]<<8|t[i+2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this._strip()},i.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var i,o=0,s=0;if("be"===r)for(n=t.length-1;n>=e;n-=2)i=a(t,e,n)<<o,this.words[s]|=67108863&i,o>=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;else for(n=(t.length-e)%2==0?e+1:e;n<t.length;n+=2)i=a(t,e,n)<<o,this.words[s]|=67108863&i,o>=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;this._strip()},i.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=e)n++;n--,i=i/e|0;for(var o=t.length-r,s=o%n,a=Math.min(o,o-s)+r,c=0,h=r;h<a;h+=n)c=u(t,h,h+n,e),this.imuln(i),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(0!==s){var l=1;for(c=u(t,h,t.length,e),h=0;h<s;h++)l*=e;this.imuln(l),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}this._strip()},i.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},i.prototype._move=function(t){c(t,this)},i.prototype.clone=function(){var t=new i(null);return this.copy(t),t},i.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},i.prototype._strip=function(){for(;this.length>1&&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(t){i.prototype.inspect=h}else i.prototype.inspect=h;function h(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}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(t,e,r){r.negative=e.negative^t.negative;var n=t.length+e.length|0;r.length=n,n=n-1|0;var i=0|t.words[0],o=0|e.words[0],s=i*o,a=67108863&s,u=s/67108864|0;r.words[0]=a;for(var c=1;c<n;c++){for(var h=u>>>26,l=67108863&u,f=Math.min(c,e.length-1),d=Math.max(0,c-t.length+1);d<=f;d++){var p=c-d|0;h+=(s=(i=0|t.words[p])*(o=0|e.words[d])+l)/67108864|0,l=67108863&s}r.words[c]=0|l,u=0|h}return 0!==u?r.words[c]=0|u:r.length--,r._strip()}i.prototype.toString=function(t,e){var n;if(e=0|e||1,16===(t=t||10)||"hex"===t){n="";for(var i=0,o=0,s=0;s<this.length;s++){var a=this.words[s],u=(16777215&(a<<i|o)).toString(16);o=a>>>24-i&16777215,(i+=2)>=26&&(i-=26,s--),n=0!==o||s!==this.length-1?l[6-u.length]+u+n:u+n}for(0!==o&&(n=o.toString(16)+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(t===(0|t)&&t>=2&&t<=36){var c=f[t],h=d[t];n="";var p=this.clone();for(p.negative=0;!p.isZero();){var y=p.modrn(h).toString(t);n=(p=p.idivn(h)).isZero()?y+n:l[c-y.length]+y+n}for(this.isZero()&&(n="0"+n);n.length%e!=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 t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},i.prototype.toJSON=function(){return this.toString(16,2)},o&&(i.prototype.toBuffer=function(t,e){return this.toArrayLike(o,t,e)}),i.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},i.prototype.toArrayLike=function(t,e,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(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,o);return this["_toArrayLike"+("le"===e?"LE":"BE")](s,i),s},i.prototype._toArrayLikeLE=function(t,e){for(var r=0,n=0,i=0,o=0;i<this.length;i++){var s=this.words[i]<<o|n;t[r++]=255&s,r<t.length&&(t[r++]=s>>8&255),r<t.length&&(t[r++]=s>>16&255),6===o?(r<t.length&&(t[r++]=s>>24&255),n=0,o=0):(n=s>>>24,o+=2)}if(r<t.length)for(t[r++]=n;r<t.length;)t[r++]=0},i.prototype._toArrayLikeBE=function(t,e){for(var r=t.length-1,n=0,i=0,o=0;i<this.length;i++){var s=this.words[i]<<o|n;t[r--]=255&s,r>=0&&(t[r--]=s>>8&255),r>=0&&(t[r--]=s>>16&255),6===o?(r>=0&&(t[r--]=s>>24&255),n=0,o=0):(n=s>>>24,o+=2)}if(r>=0)for(t[r--]=n;r>=0;)t[r--]=0},Math.clz32?i.prototype._countBits=function(t){return 32-Math.clz32(t)}:i.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},i.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},i.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},i.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return 0!==this.negative},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this._strip()},i.prototype.ior=function(t){return r(0==(this.negative|t.negative)),this.iuor(t)},i.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},i.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},i.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this._strip()},i.prototype.iand=function(t){return r(0==(this.negative|t.negative)),this.iuand(t)},i.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},i.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},i.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;n<r.length;n++)this.words[n]=e.words[n]^r.words[n];if(this!==e)for(;n<e.length;n++)this.words[n]=e.words[n];return this.length=e.length,this._strip()},i.prototype.ixor=function(t){return r(0==(this.negative|t.negative)),this.iuxor(t)},i.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},i.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},i.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),n=t%26;this._expand(e),n>0&&e--;for(var i=0;i<e;i++)this.words[i]=67108863&~this.words[i];return n>0&&(this.words[i]=~this.words[i]&67108863>>26-n),this._strip()},i.prototype.notn=function(t){return this.clone().inotn(t)},i.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);var n=t/26|0,i=t%26;return this._expand(n+1),this.words[n]=e?this.words[n]|1<<i:this.words[n]&~(1<<i),this._strip()},i.prototype.iadd=function(t){var e,r,n;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,n=t):(r=t,n=this);for(var i=0,o=0;o<n.length;o++)e=(0|r.words[o])+(0|n.words[o])+i,this.words[o]=67108863&e,i=e>>>26;for(;0!==i&&o<r.length;o++)e=(0|r.words[o])+i,this.words[o]=67108863&e,i=e>>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},i.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},i.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,n,i=this.cmp(t);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=t):(r=t,n=this);for(var o=0,s=0;s<n.length;s++)o=(e=(0|r.words[s])-(0|n.words[s])+o)>>26,this.words[s]=67108863&e;for(;0!==o&&s<r.length;s++)o=(e=(0|r.words[s])+o)>>26,this.words[s]=67108863&e;if(0===o&&s<r.length&&r!==this)for(;s<r.length;s++)this.words[s]=r.words[s];return this.length=Math.max(this.length,s),r!==this&&(this.negative=1),this._strip()},i.prototype.sub=function(t){return this.clone().isub(t)};var y=function(t,e,r){var n,i,o,s=t.words,a=e.words,u=r.words,c=0,h=0|s[0],l=8191&h,f=h>>>13,d=0|s[1],p=8191&d,y=d>>>13,g=0|s[2],m=8191&g,w=g>>>13,b=0|s[3],v=8191&b,_=b>>>13,k=0|s[4],E=8191&k,x=k>>>13,S=0|s[5],A=8191&S,I=S>>>13,B=0|s[6],M=8191&B,R=B>>>13,P=0|s[7],T=8191&P,O=P>>>13,L=0|s[8],U=8191&L,C=L>>>13,N=0|s[9],z=8191&N,D=N>>>13,j=0|a[0],W=8191&j,K=j>>>13,F=0|a[1],q=8191&F,V=F>>>13,H=0|a[2],$=8191&H,G=H>>>13,Z=0|a[3],Y=8191&Z,J=Z>>>13,X=0|a[4],Q=8191&X,tt=X>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],ot=8191&it,st=it>>>13,at=0|a[7],ut=8191&at,ct=at>>>13,ht=0|a[8],lt=8191&ht,ft=ht>>>13,dt=0|a[9],pt=8191&dt,yt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(c+(n=Math.imul(l,W))|0)+((8191&(i=(i=Math.imul(l,K))+Math.imul(f,W)|0))<<13)|0;c=((o=Math.imul(f,K))+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(p,W),i=(i=Math.imul(p,K))+Math.imul(y,W)|0,o=Math.imul(y,K);var mt=(c+(n=n+Math.imul(l,q)|0)|0)+((8191&(i=(i=i+Math.imul(l,V)|0)+Math.imul(f,q)|0))<<13)|0;c=((o=o+Math.imul(f,V)|0)+(i>>>13)|0)+(mt>>>26)|0,mt&=67108863,n=Math.imul(m,W),i=(i=Math.imul(m,K))+Math.imul(w,W)|0,o=Math.imul(w,K),n=n+Math.imul(p,q)|0,i=(i=i+Math.imul(p,V)|0)+Math.imul(y,q)|0,o=o+Math.imul(y,V)|0;var wt=(c+(n=n+Math.imul(l,$)|0)|0)+((8191&(i=(i=i+Math.imul(l,G)|0)+Math.imul(f,$)|0))<<13)|0;c=((o=o+Math.imul(f,G)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(v,W),i=(i=Math.imul(v,K))+Math.imul(_,W)|0,o=Math.imul(_,K),n=n+Math.imul(m,q)|0,i=(i=i+Math.imul(m,V)|0)+Math.imul(w,q)|0,o=o+Math.imul(w,V)|0,n=n+Math.imul(p,$)|0,i=(i=i+Math.imul(p,G)|0)+Math.imul(y,$)|0,o=o+Math.imul(y,G)|0;var bt=(c+(n=n+Math.imul(l,Y)|0)|0)+((8191&(i=(i=i+Math.imul(l,J)|0)+Math.imul(f,Y)|0))<<13)|0;c=((o=o+Math.imul(f,J)|0)+(i>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(E,W),i=(i=Math.imul(E,K))+Math.imul(x,W)|0,o=Math.imul(x,K),n=n+Math.imul(v,q)|0,i=(i=i+Math.imul(v,V)|0)+Math.imul(_,q)|0,o=o+Math.imul(_,V)|0,n=n+Math.imul(m,$)|0,i=(i=i+Math.imul(m,G)|0)+Math.imul(w,$)|0,o=o+Math.imul(w,G)|0,n=n+Math.imul(p,Y)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(y,Y)|0,o=o+Math.imul(y,J)|0;var vt=(c+(n=n+Math.imul(l,Q)|0)|0)+((8191&(i=(i=i+Math.imul(l,tt)|0)+Math.imul(f,Q)|0))<<13)|0;c=((o=o+Math.imul(f,tt)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(A,W),i=(i=Math.imul(A,K))+Math.imul(I,W)|0,o=Math.imul(I,K),n=n+Math.imul(E,q)|0,i=(i=i+Math.imul(E,V)|0)+Math.imul(x,q)|0,o=o+Math.imul(x,V)|0,n=n+Math.imul(v,$)|0,i=(i=i+Math.imul(v,G)|0)+Math.imul(_,$)|0,o=o+Math.imul(_,G)|0,n=n+Math.imul(m,Y)|0,i=(i=i+Math.imul(m,J)|0)+Math.imul(w,Y)|0,o=o+Math.imul(w,J)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(y,Q)|0,o=o+Math.imul(y,tt)|0;var _t=(c+(n=n+Math.imul(l,rt)|0)|0)+((8191&(i=(i=i+Math.imul(l,nt)|0)+Math.imul(f,rt)|0))<<13)|0;c=((o=o+Math.imul(f,nt)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(M,W),i=(i=Math.imul(M,K))+Math.imul(R,W)|0,o=Math.imul(R,K),n=n+Math.imul(A,q)|0,i=(i=i+Math.imul(A,V)|0)+Math.imul(I,q)|0,o=o+Math.imul(I,V)|0,n=n+Math.imul(E,$)|0,i=(i=i+Math.imul(E,G)|0)+Math.imul(x,$)|0,o=o+Math.imul(x,G)|0,n=n+Math.imul(v,Y)|0,i=(i=i+Math.imul(v,J)|0)+Math.imul(_,Y)|0,o=o+Math.imul(_,J)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,tt)|0)+Math.imul(w,Q)|0,o=o+Math.imul(w,tt)|0,n=n+Math.imul(p,rt)|0,i=(i=i+Math.imul(p,nt)|0)+Math.imul(y,rt)|0,o=o+Math.imul(y,nt)|0;var kt=(c+(n=n+Math.imul(l,ot)|0)|0)+((8191&(i=(i=i+Math.imul(l,st)|0)+Math.imul(f,ot)|0))<<13)|0;c=((o=o+Math.imul(f,st)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(T,W),i=(i=Math.imul(T,K))+Math.imul(O,W)|0,o=Math.imul(O,K),n=n+Math.imul(M,q)|0,i=(i=i+Math.imul(M,V)|0)+Math.imul(R,q)|0,o=o+Math.imul(R,V)|0,n=n+Math.imul(A,$)|0,i=(i=i+Math.imul(A,G)|0)+Math.imul(I,$)|0,o=o+Math.imul(I,G)|0,n=n+Math.imul(E,Y)|0,i=(i=i+Math.imul(E,J)|0)+Math.imul(x,Y)|0,o=o+Math.imul(x,J)|0,n=n+Math.imul(v,Q)|0,i=(i=i+Math.imul(v,tt)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,tt)|0,n=n+Math.imul(m,rt)|0,i=(i=i+Math.imul(m,nt)|0)+Math.imul(w,rt)|0,o=o+Math.imul(w,nt)|0,n=n+Math.imul(p,ot)|0,i=(i=i+Math.imul(p,st)|0)+Math.imul(y,ot)|0,o=o+Math.imul(y,st)|0;var Et=(c+(n=n+Math.imul(l,ut)|0)|0)+((8191&(i=(i=i+Math.imul(l,ct)|0)+Math.imul(f,ut)|0))<<13)|0;c=((o=o+Math.imul(f,ct)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(U,W),i=(i=Math.imul(U,K))+Math.imul(C,W)|0,o=Math.imul(C,K),n=n+Math.imul(T,q)|0,i=(i=i+Math.imul(T,V)|0)+Math.imul(O,q)|0,o=o+Math.imul(O,V)|0,n=n+Math.imul(M,$)|0,i=(i=i+Math.imul(M,G)|0)+Math.imul(R,$)|0,o=o+Math.imul(R,G)|0,n=n+Math.imul(A,Y)|0,i=(i=i+Math.imul(A,J)|0)+Math.imul(I,Y)|0,o=o+Math.imul(I,J)|0,n=n+Math.imul(E,Q)|0,i=(i=i+Math.imul(E,tt)|0)+Math.imul(x,Q)|0,o=o+Math.imul(x,tt)|0,n=n+Math.imul(v,rt)|0,i=(i=i+Math.imul(v,nt)|0)+Math.imul(_,rt)|0,o=o+Math.imul(_,nt)|0,n=n+Math.imul(m,ot)|0,i=(i=i+Math.imul(m,st)|0)+Math.imul(w,ot)|0,o=o+Math.imul(w,st)|0,n=n+Math.imul(p,ut)|0,i=(i=i+Math.imul(p,ct)|0)+Math.imul(y,ut)|0,o=o+Math.imul(y,ct)|0;var xt=(c+(n=n+Math.imul(l,lt)|0)|0)+((8191&(i=(i=i+Math.imul(l,ft)|0)+Math.imul(f,lt)|0))<<13)|0;c=((o=o+Math.imul(f,ft)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(z,W),i=(i=Math.imul(z,K))+Math.imul(D,W)|0,o=Math.imul(D,K),n=n+Math.imul(U,q)|0,i=(i=i+Math.imul(U,V)|0)+Math.imul(C,q)|0,o=o+Math.imul(C,V)|0,n=n+Math.imul(T,$)|0,i=(i=i+Math.imul(T,G)|0)+Math.imul(O,$)|0,o=o+Math.imul(O,G)|0,n=n+Math.imul(M,Y)|0,i=(i=i+Math.imul(M,J)|0)+Math.imul(R,Y)|0,o=o+Math.imul(R,J)|0,n=n+Math.imul(A,Q)|0,i=(i=i+Math.imul(A,tt)|0)+Math.imul(I,Q)|0,o=o+Math.imul(I,tt)|0,n=n+Math.imul(E,rt)|0,i=(i=i+Math.imul(E,nt)|0)+Math.imul(x,rt)|0,o=o+Math.imul(x,nt)|0,n=n+Math.imul(v,ot)|0,i=(i=i+Math.imul(v,st)|0)+Math.imul(_,ot)|0,o=o+Math.imul(_,st)|0,n=n+Math.imul(m,ut)|0,i=(i=i+Math.imul(m,ct)|0)+Math.imul(w,ut)|0,o=o+Math.imul(w,ct)|0,n=n+Math.imul(p,lt)|0,i=(i=i+Math.imul(p,ft)|0)+Math.imul(y,lt)|0,o=o+Math.imul(y,ft)|0;var St=(c+(n=n+Math.imul(l,pt)|0)|0)+((8191&(i=(i=i+Math.imul(l,yt)|0)+Math.imul(f,pt)|0))<<13)|0;c=((o=o+Math.imul(f,yt)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(z,q),i=(i=Math.imul(z,V))+Math.imul(D,q)|0,o=Math.imul(D,V),n=n+Math.imul(U,$)|0,i=(i=i+Math.imul(U,G)|0)+Math.imul(C,$)|0,o=o+Math.imul(C,G)|0,n=n+Math.imul(T,Y)|0,i=(i=i+Math.imul(T,J)|0)+Math.imul(O,Y)|0,o=o+Math.imul(O,J)|0,n=n+Math.imul(M,Q)|0,i=(i=i+Math.imul(M,tt)|0)+Math.imul(R,Q)|0,o=o+Math.imul(R,tt)|0,n=n+Math.imul(A,rt)|0,i=(i=i+Math.imul(A,nt)|0)+Math.imul(I,rt)|0,o=o+Math.imul(I,nt)|0,n=n+Math.imul(E,ot)|0,i=(i=i+Math.imul(E,st)|0)+Math.imul(x,ot)|0,o=o+Math.imul(x,st)|0,n=n+Math.imul(v,ut)|0,i=(i=i+Math.imul(v,ct)|0)+Math.imul(_,ut)|0,o=o+Math.imul(_,ct)|0,n=n+Math.imul(m,lt)|0,i=(i=i+Math.imul(m,ft)|0)+Math.imul(w,lt)|0,o=o+Math.imul(w,ft)|0;var At=(c+(n=n+Math.imul(p,pt)|0)|0)+((8191&(i=(i=i+Math.imul(p,yt)|0)+Math.imul(y,pt)|0))<<13)|0;c=((o=o+Math.imul(y,yt)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(z,$),i=(i=Math.imul(z,G))+Math.imul(D,$)|0,o=Math.imul(D,G),n=n+Math.imul(U,Y)|0,i=(i=i+Math.imul(U,J)|0)+Math.imul(C,Y)|0,o=o+Math.imul(C,J)|0,n=n+Math.imul(T,Q)|0,i=(i=i+Math.imul(T,tt)|0)+Math.imul(O,Q)|0,o=o+Math.imul(O,tt)|0,n=n+Math.imul(M,rt)|0,i=(i=i+Math.imul(M,nt)|0)+Math.imul(R,rt)|0,o=o+Math.imul(R,nt)|0,n=n+Math.imul(A,ot)|0,i=(i=i+Math.imul(A,st)|0)+Math.imul(I,ot)|0,o=o+Math.imul(I,st)|0,n=n+Math.imul(E,ut)|0,i=(i=i+Math.imul(E,ct)|0)+Math.imul(x,ut)|0,o=o+Math.imul(x,ct)|0,n=n+Math.imul(v,lt)|0,i=(i=i+Math.imul(v,ft)|0)+Math.imul(_,lt)|0,o=o+Math.imul(_,ft)|0;var It=(c+(n=n+Math.imul(m,pt)|0)|0)+((8191&(i=(i=i+Math.imul(m,yt)|0)+Math.imul(w,pt)|0))<<13)|0;c=((o=o+Math.imul(w,yt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(z,Y),i=(i=Math.imul(z,J))+Math.imul(D,Y)|0,o=Math.imul(D,J),n=n+Math.imul(U,Q)|0,i=(i=i+Math.imul(U,tt)|0)+Math.imul(C,Q)|0,o=o+Math.imul(C,tt)|0,n=n+Math.imul(T,rt)|0,i=(i=i+Math.imul(T,nt)|0)+Math.imul(O,rt)|0,o=o+Math.imul(O,nt)|0,n=n+Math.imul(M,ot)|0,i=(i=i+Math.imul(M,st)|0)+Math.imul(R,ot)|0,o=o+Math.imul(R,st)|0,n=n+Math.imul(A,ut)|0,i=(i=i+Math.imul(A,ct)|0)+Math.imul(I,ut)|0,o=o+Math.imul(I,ct)|0,n=n+Math.imul(E,lt)|0,i=(i=i+Math.imul(E,ft)|0)+Math.imul(x,lt)|0,o=o+Math.imul(x,ft)|0;var Bt=(c+(n=n+Math.imul(v,pt)|0)|0)+((8191&(i=(i=i+Math.imul(v,yt)|0)+Math.imul(_,pt)|0))<<13)|0;c=((o=o+Math.imul(_,yt)|0)+(i>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,n=Math.imul(z,Q),i=(i=Math.imul(z,tt))+Math.imul(D,Q)|0,o=Math.imul(D,tt),n=n+Math.imul(U,rt)|0,i=(i=i+Math.imul(U,nt)|0)+Math.imul(C,rt)|0,o=o+Math.imul(C,nt)|0,n=n+Math.imul(T,ot)|0,i=(i=i+Math.imul(T,st)|0)+Math.imul(O,ot)|0,o=o+Math.imul(O,st)|0,n=n+Math.imul(M,ut)|0,i=(i=i+Math.imul(M,ct)|0)+Math.imul(R,ut)|0,o=o+Math.imul(R,ct)|0,n=n+Math.imul(A,lt)|0,i=(i=i+Math.imul(A,ft)|0)+Math.imul(I,lt)|0,o=o+Math.imul(I,ft)|0;var Mt=(c+(n=n+Math.imul(E,pt)|0)|0)+((8191&(i=(i=i+Math.imul(E,yt)|0)+Math.imul(x,pt)|0))<<13)|0;c=((o=o+Math.imul(x,yt)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(z,rt),i=(i=Math.imul(z,nt))+Math.imul(D,rt)|0,o=Math.imul(D,nt),n=n+Math.imul(U,ot)|0,i=(i=i+Math.imul(U,st)|0)+Math.imul(C,ot)|0,o=o+Math.imul(C,st)|0,n=n+Math.imul(T,ut)|0,i=(i=i+Math.imul(T,ct)|0)+Math.imul(O,ut)|0,o=o+Math.imul(O,ct)|0,n=n+Math.imul(M,lt)|0,i=(i=i+Math.imul(M,ft)|0)+Math.imul(R,lt)|0,o=o+Math.imul(R,ft)|0;var Rt=(c+(n=n+Math.imul(A,pt)|0)|0)+((8191&(i=(i=i+Math.imul(A,yt)|0)+Math.imul(I,pt)|0))<<13)|0;c=((o=o+Math.imul(I,yt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,n=Math.imul(z,ot),i=(i=Math.imul(z,st))+Math.imul(D,ot)|0,o=Math.imul(D,st),n=n+Math.imul(U,ut)|0,i=(i=i+Math.imul(U,ct)|0)+Math.imul(C,ut)|0,o=o+Math.imul(C,ct)|0,n=n+Math.imul(T,lt)|0,i=(i=i+Math.imul(T,ft)|0)+Math.imul(O,lt)|0,o=o+Math.imul(O,ft)|0;var Pt=(c+(n=n+Math.imul(M,pt)|0)|0)+((8191&(i=(i=i+Math.imul(M,yt)|0)+Math.imul(R,pt)|0))<<13)|0;c=((o=o+Math.imul(R,yt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(z,ut),i=(i=Math.imul(z,ct))+Math.imul(D,ut)|0,o=Math.imul(D,ct),n=n+Math.imul(U,lt)|0,i=(i=i+Math.imul(U,ft)|0)+Math.imul(C,lt)|0,o=o+Math.imul(C,ft)|0;var Tt=(c+(n=n+Math.imul(T,pt)|0)|0)+((8191&(i=(i=i+Math.imul(T,yt)|0)+Math.imul(O,pt)|0))<<13)|0;c=((o=o+Math.imul(O,yt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(z,lt),i=(i=Math.imul(z,ft))+Math.imul(D,lt)|0,o=Math.imul(D,ft);var Ot=(c+(n=n+Math.imul(U,pt)|0)|0)+((8191&(i=(i=i+Math.imul(U,yt)|0)+Math.imul(C,pt)|0))<<13)|0;c=((o=o+Math.imul(C,yt)|0)+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863;var Lt=(c+(n=Math.imul(z,pt))|0)+((8191&(i=(i=Math.imul(z,yt))+Math.imul(D,pt)|0))<<13)|0;return c=((o=Math.imul(D,yt))+(i>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,u[0]=gt,u[1]=mt,u[2]=wt,u[3]=bt,u[4]=vt,u[5]=_t,u[6]=kt,u[7]=Et,u[8]=xt,u[9]=St,u[10]=At,u[11]=It,u[12]=Bt,u[13]=Mt,u[14]=Rt,u[15]=Pt,u[16]=Tt,u[17]=Ot,u[18]=Lt,0!==c&&(u[19]=c,r.length++),r};function g(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,o=0;o<r.length-1;o++){var s=i;i=0;for(var a=67108863&n,u=Math.min(o,e.length-1),c=Math.max(0,o-t.length+1);c<=u;c++){var h=o-c,l=(0|t.words[h])*(0|e.words[c]),f=67108863&l;a=67108863&(f=f+a|0),i+=(s=(s=s+(l/67108864|0)|0)+(f>>>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(t,e,r){return g(t,e,r)}Math.imul||(y=p),i.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?y(this,t,e):r<63?p(this,t,e):r<1024?g(this,t,e):m(this,t,e)},i.prototype.mul=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},i.prototype.mulf=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),m(this,t,e)},i.prototype.imul=function(t){return this.clone().mulTo(t,this)},i.prototype.imuln=function(t){var e=t<0;e&&(t=-t),r("number"==typeof t),r(t<67108864);for(var n=0,i=0;i<this.length;i++){var o=(0|this.words[i])*t,s=(67108863&o)+(67108863&n);n>>=26,n+=o/67108864|0,n+=s>>>26,this.words[i]=67108863&s}return 0!==n&&(this.words[i]=n,this.length++),e?this.ineg():this},i.prototype.muln=function(t){return this.clone().imuln(t)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var n=r/26|0,i=r%26;e[r]=t.words[n]>>>i&1}return e}(t);if(0===e.length)return new i(1);for(var r=this,n=0;n<e.length&&0===e[n];n++,r=r.sqr());if(++n<e.length)for(var o=r.sqr();n<e.length;n++,o=o.sqr())0!==e[n]&&(r=r.mul(o));return r},i.prototype.iushln=function(t){r("number"==typeof t&&t>=0);var e,n=t%26,i=(t-n)/26,o=67108863>>>26-n<<26-n;if(0!==n){var s=0;for(e=0;e<this.length;e++){var a=this.words[e]&o,u=(0|this.words[e])-a<<n;this.words[e]=u|s,s=a>>>26-n}s&&(this.words[e]=s,this.length++)}if(0!==i){for(e=this.length-1;e>=0;e--)this.words[e+i]=this.words[e];for(e=0;e<i;e++)this.words[e]=0;this.length+=i}return this._strip()},i.prototype.ishln=function(t){return r(0===this.negative),this.iushln(t)},i.prototype.iushrn=function(t,e,n){var i;r("number"==typeof t&&t>=0),i=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<<o,u=n;if(i-=s,i=Math.max(0,i),u){for(var c=0;c<s;c++)u.words[c]=this.words[c];u.length=s}if(0===s);else if(this.length>s)for(this.length-=s,c=0;c<this.length;c++)this.words[c]=this.words[c+s];else this.words[0]=0,this.length=1;var h=0;for(c=this.length-1;c>=0&&(0!==h||c>=i);c--){var l=0|this.words[c];this.words[c]=h<<26-o|l>>>o,h=l&a}return u&&0!==h&&(u.words[u.length++]=h),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.ishrn=function(t,e,n){return r(0===this.negative),this.iushrn(t,e,n)},i.prototype.shln=function(t){return this.clone().ishln(t)},i.prototype.ushln=function(t){return this.clone().iushln(t)},i.prototype.shrn=function(t){return this.clone().ishrn(t)},i.prototype.ushrn=function(t){return this.clone().iushrn(t)},i.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26,i=1<<e;return!(this.length<=n||!(this.words[n]&i))},i.prototype.imaskn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==e&&n++,this.length=Math.min(n,this.length),0!==e){var i=67108863^67108863>>>e<<e;this.words[this.length-1]&=i}return this._strip()},i.prototype.maskn=function(t){return this.clone().imaskn(t)},i.prototype.iaddn=function(t){return r("number"==typeof t),r(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},i.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},i.prototype.isubn=function(t){if(r("number"==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this._strip()},i.prototype.addn=function(t){return this.clone().iaddn(t)},i.prototype.subn=function(t){return this.clone().isubn(t)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(t,e,n){var i,o,s=t.length+n;this._expand(s);var a=0;for(i=0;i<t.length;i++){o=(0|this.words[i+n])+a;var u=(0|t.words[i])*e;a=((o-=67108863&u)>>26)-(u/67108864|0),this.words[i+n]=67108863&o}for(;i<this.length-n;i++)a=(o=(0|this.words[i+n])+a)>>26,this.words[i+n]=67108863&o;if(0===a)return this._strip();for(r(-1===a),a=0,i=0;i<this.length;i++)a=(o=-(0|this.words[i])+a)>>26,this.words[i]=67108863&o;return this.negative=1,this._strip()},i.prototype._wordDiv=function(t,e){var r=(this.length,t.length),n=this.clone(),o=t,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,u=n.length-o.length;if("mod"!==e){(a=new i(null)).length=u+1,a.words=new Array(a.length);for(var c=0;c<a.length;c++)a.words[c]=0}var h=n.clone()._ishlnsubmul(o,1,u);0===h.negative&&(n=h,a&&(a.words[u]=1));for(var l=u-1;l>=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"!==e&&0!==r&&n.iushrn(r),{div:a||null,mod:n}},i.prototype.divmod=function(t,e,n){return r(!t.isZero()),this.isZero()?{div:new i(0),mod:new i(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(o=a.div.neg()),"div"!==e&&(s=a.mod.neg(),n&&0!==s.negative&&s.iadd(t)),{div:o,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(o=a.div.neg()),{div:o,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),n&&0!==s.negative&&s.isub(t)),{div:a.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new i(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new i(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new i(this.modrn(t.words[0]))}:this._wordDiv(t,e);var o,s,a},i.prototype.div=function(t){return this.divmod(t,"div",!1).div},i.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},i.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},i.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,n=t.ushrn(1),i=t.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},i.prototype.modrn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var n=(1<<26)%t,i=0,o=this.length-1;o>=0;o--)i=(n*i+(0|this.words[o]))%t;return e?-i:i},i.prototype.modn=function(t){return this.modrn(t)},i.prototype.idivn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var n=0,i=this.length-1;i>=0;i--){var o=(0|this.words[i])+67108864*n;this.words[i]=o/t|0,n=o%t}return this._strip(),e?this.ineg():this},i.prototype.divn=function(t){return this.clone().idivn(t)},i.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o=new i(1),s=new i(0),a=new i(0),u=new i(1),c=0;e.isEven()&&n.isEven();)e.iushrn(1),n.iushrn(1),++c;for(var h=n.clone(),l=e.clone();!e.isZero();){for(var f=0,d=1;0==(e.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(e.iushrn(f);f-- >0;)(o.isOdd()||s.isOdd())&&(o.iadd(h),s.isub(l)),o.iushrn(1),s.iushrn(1);for(var p=0,y=1;0==(n.words[0]&y)&&p<26;++p,y<<=1);if(p>0)for(n.iushrn(p);p-- >0;)(a.isOdd()||u.isOdd())&&(a.iadd(h),u.isub(l)),a.iushrn(1),u.iushrn(1);e.cmp(n)>=0?(e.isub(n),o.isub(a),s.isub(u)):(n.isub(e),a.isub(o),u.isub(s))}return{a:a,b:u,gcd:n.iushln(c)}},i.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o,s=new i(1),a=new i(0),u=n.clone();e.cmpn(1)>0&&n.cmpn(1)>0;){for(var c=0,h=1;0==(e.words[0]&h)&&c<26;++c,h<<=1);if(c>0)for(e.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);for(var l=0,f=1;0==(n.words[0]&f)&&l<26;++l,f<<=1);if(l>0)for(n.iushrn(l);l-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);e.cmp(n)>=0?(e.isub(n),s.isub(a)):(n.isub(e),a.isub(s))}return(o=0===e.cmpn(1)?s:a).cmpn(0)<0&&o.iadd(t),o},i.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var n=0;e.isEven()&&r.isEven();n++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=e.cmp(r);if(i<0){var o=e;e=r,r=o}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.iushln(n)},i.prototype.invm=function(t){return this.egcd(t).a.umod(t)},i.prototype.isEven=function(){return 0==(1&this.words[0])},i.prototype.isOdd=function(){return 1==(1&this.words[0])},i.prototype.andln=function(t){return this.words[0]&t},i.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,n=(t-e)/26,i=1<<e;if(this.length<=n)return this._expand(n+1),this.words[n]|=i,this;for(var o=i,s=n;0!==o&&s<this.length;s++){var a=0|this.words[s];o=(a+=o)>>>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(t){var e,n=t<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this._strip(),this.length>1)e=1;else{n&&(t=-t),r(t<=67108863,"Number is too big");var i=0|this.words[0];e=i===t?0:i<t?-1:1}return 0!==this.negative?0|-e:e},i.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},i.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){n<i?e=-1:n>i&&(e=1);break}}return e},i.prototype.gtn=function(t){return 1===this.cmpn(t)},i.prototype.gt=function(t){return 1===this.cmp(t)},i.prototype.gten=function(t){return this.cmpn(t)>=0},i.prototype.gte=function(t){return this.cmp(t)>=0},i.prototype.ltn=function(t){return-1===this.cmpn(t)},i.prototype.lt=function(t){return-1===this.cmp(t)},i.prototype.lten=function(t){return this.cmpn(t)<=0},i.prototype.lte=function(t){return this.cmp(t)<=0},i.prototype.eqn=function(t){return 0===this.cmpn(t)},i.prototype.eq=function(t){return 0===this.cmp(t)},i.red=function(t){return new x(t)},i.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(t){return this.red=t,this},i.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},i.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},i.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},i.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},i.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},i.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},i.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},i.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},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(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var w={k256:null,p224:null,p192:null,p25519:null};function b(t,e){this.name=t,this.p=new i(e,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 k(){b.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function E(){b.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function x(t){if("string"==typeof t){var e=i._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function S(t){x.call(this,t),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 t=new i(null);return t.words=new Array(Math.ceil(this.n/13)),t},b.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e<this.n?-1:r.ucmp(this.p);return 0===n?(r.words[0]=0,r.length=1):n>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},b.prototype.split=function(t,e){t.iushrn(this.n,0,e)},b.prototype.imulK=function(t){return t.imul(this.k)},n(v,b),v.prototype.split=function(t,e){for(var r=4194303,n=Math.min(t.length,9),i=0;i<n;i++)e.words[i]=t.words[i];if(e.length=n,t.length<=9)return t.words[0]=0,void(t.length=1);var o=t.words[9];for(e.words[e.length++]=o&r,i=10;i<t.length;i++){var s=0|t.words[i];t.words[i-10]=(s&r)<<4|o>>>22,o=s}o>>>=22,t.words[i-10]=o,0===o&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var n=0|t.words[r];e+=977*n,t.words[r]=67108863&e,e=64*n+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},n(_,b),n(k,b),n(E,b),E.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var n=19*(0|t.words[r])+e,i=67108863&n;n>>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},i._prime=function(t){if(w[t])return w[t];var e;if("k256"===t)e=new v;else if("p224"===t)e=new _;else if("p192"===t)e=new k;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new E}return w[t]=e,e},x.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},x.prototype._verify2=function(t,e){r(0==(t.negative|e.negative),"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},x.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(c(t,t.umod(this.m)._forceRed(this)),t)},x.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},x.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},x.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},x.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},x.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},x.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},x.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},x.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},x.prototype.isqr=function(t){return this.imul(t,t.clone())},x.prototype.sqr=function(t){return this.mul(t,t)},x.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var n=this.m.add(new i(1)).iushrn(2);return this.pow(t,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),u=a.redNeg(),c=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new i(2*h*h).toRed(this);0!==this.pow(h,c).cmp(u);)h.redIAdd(u);for(var l=this.pow(h,o),f=this.pow(t,o.addn(1).iushrn(1)),d=this.pow(t,o),p=s;0!==d.cmp(a);){for(var y=d,g=0;0!==y.cmp(a);g++)y=y.redSqr();r(g<p);var m=this.pow(l,new i(1).iushln(p-g-1));f=f.redMul(m),l=m.redSqr(),d=d.redMul(l),p=g}return f},x.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},x.prototype.pow=function(t,e){if(e.isZero())return new i(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new i(1).toRed(this),r[1]=t;for(var n=2;n<r.length;n++)r[n]=this.mul(r[n-1],t);var o=r[0],s=0,a=0,u=e.bitLength()%26;for(0===u&&(u=26),n=e.length-1;n>=0;n--){for(var c=e.words[n],h=u-1;h>=0;h--){var l=c>>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}u=26}return o},x.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},x.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},i.mont=function(t){return new S(t)},n(S,x),S.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},S.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},S.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),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)},S.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new i(0)._forceRed(this);var r=t.mul(e),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)},S.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(te,t);var re=te.exports,ne=e(re),ie={exports:{}};!function(t,e){var r=n,i=r.Buffer;function o(t,e){for(var r in t)e[r]=t[r]}function s(t,e,r){return i(t,e,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=r:(o(r,e),e.Buffer=s),s.prototype=Object.create(i.prototype),o(i,s),s.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return i(t,e,r)},s.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var n=i(t);return void 0!==e?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},s.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return i(t)},s.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return r.SlowBuffer(t)}}(ie,ie.exports);var oe=ie.exports.Buffer;var se=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r<e.length;r++)e[r]=255;for(var n=0;n<t.length;n++){var i=t.charAt(n),o=i.charCodeAt(0);if(255!==e[o])throw new TypeError(i+" is ambiguous");e[o]=n}var s=t.length,a=t.charAt(0),u=Math.log(s)/Math.log(256),c=Math.log(256)/Math.log(s);function h(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return oe.alloc(0);for(var r=0,n=0,i=0;t[r]===a;)n++,r++;for(var o=(t.length-r)*u+1>>>0,c=new Uint8Array(o);t[r];){var h=e[t.charCodeAt(r)];if(255===h)return;for(var l=0,f=o-1;(0!==h||l<i)&&-1!==f;f--,l++)h+=s*c[f]>>>0,c[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===c[d];)d++;var p=oe.allocUnsafe(n+(o-d));p.fill(0,0,n);for(var y=n;d!==o;)p[y++]=c[d++];return p}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=oe.from(e)),!oe.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,n=0,i=0,o=e.length;i!==o&&0===e[i];)i++,r++;for(var u=(o-i)*c+1>>>0,h=new Uint8Array(u);i!==o;){for(var l=e[i],f=0,d=u-1;(0!==l||f<n)&&-1!==d;d--,f++)l+=256*h[d]>>>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=u-n;p!==u&&0===h[p];)p++;for(var y=a.repeat(r);p<u;++p)y+=t.charAt(h[p]);return y},decodeUnsafe:h,decode:function(t){var e=h(t);if(e)return e;throw new Error("Non-base"+s+" character")}}},ae=e(se("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"));const ue=(t,e,r)=>t&e^~t&r,ce=(t,e,r)=>t&e^t&r^e&r,he=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]),le=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),fe=new Uint32Array(64);class de extends M{constructor(){super(64,32,8,!1),this.A=0|le[0],this.B=0|le[1],this.C=0|le[2],this.D=0|le[3],this.E=0|le[4],this.F=0|le[5],this.G=0|le[6],this.H=0|le[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:o,G:s,H:a}=this;return[t,e,r,n,i,o,s,a]}set(t,e,r,n,i,o,s,a){this.A=0|t,this.B=0|e,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(t,e){for(let r=0;r<16;r++,e+=4)fe[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=fe[t-15],r=fe[t-2],n=k(e,7)^k(e,18)^e>>>3,i=k(r,17)^k(r,19)^r>>>10;fe[t]=i+fe[t-7]+n+fe[t-16]|0}let{A:r,B:n,C:i,D:o,E:s,F:a,G:u,H:c}=this;for(let t=0;t<64;t++){const e=c+(k(s,6)^k(s,11)^k(s,25))+ue(s,a,u)+he[t]+fe[t]|0,h=(k(r,2)^k(r,13)^k(r,22))+ce(r,n,i)|0;c=u,u=a,a=s,s=o+e|0,o=i,i=n,n=r,r=e+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,u=u+this.G|0,c=c+this.H|0,this.set(r,n,i,o,s,a,u,c)}roundClean(){fe.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const pe=I((()=>new de));var ye={},ge=se("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");function me(t,e,r){return e<=t&&t<=r}function we(t){if(void 0===t)return{};if(t===Object(t))return t;throw TypeError("Could not convert argument to dictionary")}function be(t){this.tokens=[].slice.call(t)}be.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():-1},prepend:function(t){if(Array.isArray(t))for(var e=t;e.length;)this.tokens.unshift(e.pop());else this.tokens.unshift(t)},push:function(t){if(Array.isArray(t))for(var e=t;e.length;)this.tokens.push(e.shift());else this.tokens.push(t)}};var ve=-1;function _e(t,e){if(t)throw TypeError("Decoder error");return e||65533}var ke="utf-8";function Ee(t,e){if(!(this instanceof Ee))return new Ee(t,e);if((t=void 0!==t?String(t).toLowerCase():ke)!==ke)throw new Error("Encoding not supported. Only utf-8 is supported");e=we(e),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=Boolean(e.fatal),this._ignoreBOM=Boolean(e.ignoreBOM),Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}function xe(t,e){if(!(this instanceof xe))return new xe(t,e);if((t=void 0!==t?String(t).toLowerCase():ke)!==ke)throw new Error("Encoding not supported. Only utf-8 is supported");e=we(e),this._streaming=!1,this._encoder=null,this._options={fatal:Boolean(e.fatal)},Object.defineProperty(this,"encoding",{value:"utf-8"})}function Se(t){var e=t.fatal,r=0,n=0,i=0,o=128,s=191;this.handler=function(t,a){if(-1===a&&0!==i)return i=0,_e(e);if(-1===a)return ve;if(0===i){if(me(a,0,127))return a;if(me(a,194,223))i=1,r=a-192;else if(me(a,224,239))224===a&&(o=160),237===a&&(s=159),i=2,r=a-224;else{if(!me(a,240,244))return _e(e);240===a&&(o=144),244===a&&(s=143),i=3,r=a-240}return r<<=6*i,null}if(!me(a,o,s))return r=i=n=0,o=128,s=191,t.prepend(a),_e(e);if(o=128,s=191,r+=a-128<<6*(i-(n+=1)),n!==i)return null;var u=r;return r=i=n=0,u}}function Ae(t){t.fatal,this.handler=function(t,e){if(-1===e)return ve;if(me(e,0,127))return e;var r,n;me(e,128,2047)?(r=1,n=192):me(e,2048,65535)?(r=2,n=224):me(e,65536,1114111)&&(r=3,n=240);for(var i=[(e>>6*r)+n];r>0;){var o=e>>6*(r-1);i.push(128|63&o),r-=1}return i}}Ee.prototype={decode:function(t,e){var r;r="object"==typeof t&&t instanceof ArrayBuffer?new Uint8Array(t):"object"==typeof t&&"buffer"in t&&t.buffer instanceof ArrayBuffer?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(0),e=we(e),this._streaming||(this._decoder=new Se({fatal:this._fatal}),this._BOMseen=!1),this._streaming=Boolean(e.stream);for(var n,i=new be(r),o=[];!i.endOfStream()&&(n=this._decoder.handler(i,i.read()))!==ve;)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()))===ve)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(t){for(var e="",r=0;r<t.length;++r){var n=t[r];n<=65535?e+=String.fromCharCode(n):(n-=65536,e+=String.fromCharCode(55296+(n>>10),56320+(1023&n)))}return e}(o)}},xe.prototype={encode:function(t,e){t=t?String(t):"",e=we(e),this._streaming||(this._encoder=new Ae(this._options)),this._streaming=Boolean(e.stream);for(var r,n=[],i=new be(function(t){for(var e=String(t),r=e.length,n=0,i=[];n<r;){var o=e.charCodeAt(n);if(o<55296||o>57343)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=t.charCodeAt(n+1);if(56320<=s&&s<=57343){var a=1023&o,u=1023&s;i.push(65536+(a<<10)+u),n+=1}else i.push(65533)}n+=1}return i}(t));!i.endOfStream()&&(r=this._encoder.handler(i,i.read()))!==ve;)Array.isArray(r)?n.push.apply(n,r):n.push(r);if(!this._streaming){for(;(r=this._encoder.handler(i,i.read()))!==ve;)Array.isArray(r)?n.push.apply(n,r):n.push(r);this._encoder=null}return new Uint8Array(n)}};var Ie=r(Object.freeze({__proto__:null,TextEncoder:xe,TextDecoder:Ee})),Be=t&&t.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),Me=t&&t.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Re=t&&t.__decorate||function(t,e,r,n){var i,o=arguments.length,s=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s},Pe=t&&t.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)"default"!==r&&Object.hasOwnProperty.call(t,r)&&Be(e,t,r);return Me(e,t),e},Te=t&&t.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(ye,"__esModule",{value:!0});var Oe=ye.deserializeUnchecked=Ze=ye.deserialize=He=ye.serialize=ye.BinaryReader=ye.BinaryWriter=ye.BorshError=ye.baseDecode=ye.baseEncode=void 0;const Le=Te(re),Ue=Te(ge),Ce=Pe(Ie),Ne=new("function"!=typeof TextDecoder?Ce.TextDecoder:TextDecoder)("utf-8",{fatal:!0});ye.baseEncode=function(t){return"string"==typeof t&&(t=Buffer.from(t,"utf8")),Ue.default.encode(Buffer.from(t))},ye.baseDecode=function(t){return Buffer.from(Ue.default.decode(t))};const ze=1024;class De extends Error{constructor(t){super(t),this.fieldPath=[],this.originalMessage=t}addToFieldPath(t){this.fieldPath.splice(0,0,t),this.message=this.originalMessage+": "+this.fieldPath.join(".")}}ye.BorshError=De;class je{constructor(){this.buf=Buffer.alloc(ze),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(ze)]))}writeU8(t){this.maybeResize(),this.buf.writeUInt8(t,this.length),this.length+=1}writeU16(t){this.maybeResize(),this.buf.writeUInt16LE(t,this.length),this.length+=2}writeU32(t){this.maybeResize(),this.buf.writeUInt32LE(t,this.length),this.length+=4}writeU64(t){this.maybeResize(),this.writeBuffer(Buffer.from(new Le.default(t).toArray("le",8)))}writeU128(t){this.maybeResize(),this.writeBuffer(Buffer.from(new Le.default(t).toArray("le",16)))}writeU256(t){this.maybeResize(),this.writeBuffer(Buffer.from(new Le.default(t).toArray("le",32)))}writeU512(t){this.maybeResize(),this.writeBuffer(Buffer.from(new Le.default(t).toArray("le",64)))}writeBuffer(t){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),t,Buffer.alloc(ze)]),this.length+=t.length}writeString(t){this.maybeResize();const e=Buffer.from(t,"utf8");this.writeU32(e.length),this.writeBuffer(e)}writeFixedArray(t){this.writeBuffer(Buffer.from(t))}writeArray(t,e){this.maybeResize(),this.writeU32(t.length);for(const r of t)this.maybeResize(),e(r)}toArray(){return this.buf.subarray(0,this.length)}}function We(t,e,r){const n=r.value;r.value=function(...t){try{return n.apply(this,t)}catch(t){if(t instanceof RangeError){const e=t.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(e)>=0)throw new De("Reached the end of buffer when deserializing")}throw t}}}ye.BinaryWriter=je;class Ke{constructor(t){this.buf=t,this.offset=0}readU8(){const t=this.buf.readUInt8(this.offset);return this.offset+=1,t}readU16(){const t=this.buf.readUInt16LE(this.offset);return this.offset+=2,t}readU32(){const t=this.buf.readUInt32LE(this.offset);return this.offset+=4,t}readU64(){const t=this.readBuffer(8);return new Le.default(t,"le")}readU128(){const t=this.readBuffer(16);return new Le.default(t,"le")}readU256(){const t=this.readBuffer(32);return new Le.default(t,"le")}readU512(){const t=this.readBuffer(64);return new Le.default(t,"le")}readBuffer(t){if(this.offset+t>this.buf.length)throw new De(`Expected buffer length ${t} isn't within bounds`);const e=this.buf.slice(this.offset,this.offset+t);return this.offset+=t,e}readString(){const t=this.readU32(),e=this.readBuffer(t);try{return Ne.decode(e)}catch(t){throw new De(`Error decoding UTF-8 string: ${t}`)}}readFixedArray(t){return new Uint8Array(this.readBuffer(t))}readArray(t){const e=this.readU32(),r=Array();for(let n=0;n<e;++n)r.push(t());return r}}function Fe(t){return t.charAt(0).toUpperCase()+t.slice(1)}function qe(t,e,r,n,i){try{if("string"==typeof n)i[`write${Fe(n)}`](r);else if(n instanceof Array)if("number"==typeof n[0]){if(r.length!==n[0])throw new De(`Expecting byte array of length ${n[0]}, but got ${r.length} bytes`);i.writeFixedArray(r)}else if(2===n.length&&"number"==typeof n[1]){if(r.length!==n[1])throw new De(`Expecting byte array of length ${n[1]}, but got ${r.length} bytes`);for(let e=0;e<n[1];e++)qe(t,null,r[e],n[0],i)}else i.writeArray(r,(r=>{qe(t,e,r,n[0],i)}));else if(void 0!==n.kind)switch(n.kind){case"option":null==r?i.writeU8(0):(i.writeU8(1),qe(t,e,r,n.type,i));break;case"map":i.writeU32(r.size),r.forEach(((r,o)=>{qe(t,e,o,n.key,i),qe(t,e,r,n.value,i)}));break;default:throw new De(`FieldType ${n} unrecognized`)}else Ve(t,r,i)}catch(t){throw t instanceof De&&t.addToFieldPath(e),t}}function Ve(t,e,r){if("function"==typeof e.borshSerialize)return void e.borshSerialize(r);const n=t.get(e.constructor);if(!n)throw new De(`Class ${e.constructor.name} is missing in schema`);if("struct"===n.kind)n.fields.map((([n,i])=>{qe(t,n,e[n],i,r)}));else{if("enum"!==n.kind)throw new De(`Unexpected schema kind: ${n.kind} for ${e.constructor.name}`);{const i=e[n.field];for(let o=0;o<n.values.length;++o){const[s,a]=n.values[o];if(s===i){r.writeU8(o),qe(t,s,e[s],a,r);break}}}}}Re([We],Ke.prototype,"readU8",null),Re([We],Ke.prototype,"readU16",null),Re([We],Ke.prototype,"readU32",null),Re([We],Ke.prototype,"readU64",null),Re([We],Ke.prototype,"readU128",null),Re([We],Ke.prototype,"readU256",null),Re([We],Ke.prototype,"readU512",null),Re([We],Ke.prototype,"readString",null),Re([We],Ke.prototype,"readFixedArray",null),Re([We],Ke.prototype,"readArray",null),ye.BinaryReader=Ke;var He=ye.serialize=function(t,e,r=je){const n=new r;return Ve(t,e,n),n.toArray()};function $e(t,e,r,n){try{if("string"==typeof r)return n[`read${Fe(r)}`]();if(r instanceof Array){if("number"==typeof r[0])return n.readFixedArray(r[0]);if("number"==typeof r[1]){const e=[];for(let i=0;i<r[1];i++)e.push($e(t,null,r[0],n));return e}return n.readArray((()=>$e(t,e,r[0],n)))}if("option"===r.kind){return n.readU8()?$e(t,e,r.type,n):void 0}if("map"===r.kind){let i=new Map;const o=n.readU32();for(let s=0;s<o;s++){const o=$e(t,e,r.key,n),s=$e(t,e,r.value,n);i.set(o,s)}return i}return Ge(t,r,n)}catch(t){throw t instanceof De&&t.addToFieldPath(e),t}}function Ge(t,e,r){if("function"==typeof e.borshDeserialize)return e.borshDeserialize(r);const n=t.get(e);if(!n)throw new De(`Class ${e.name} is missing in schema`);if("struct"===n.kind){const n={};for(const[i,o]of t.get(e).fields)n[i]=$e(t,i,o,r);return new e(n)}if("enum"===n.kind){const i=r.readU8();if(i>=n.values.length)throw new De(`Enum index: ${i} is out of range`);const[o,s]=n.values[i];return new e({[o]:$e(t,o,s,r)})}throw new De(`Unexpected schema kind: ${n.kind} for ${e.constructor.name}`)}var Ze=ye.deserialize=function(t,e,r,n=Ke){const i=new n(r),o=Ge(t,e,i);if(i.offset<r.length)throw new De(`Unexpected ${r.length-i.offset} bytes after deserialized data`);return o};Oe=ye.deserializeUnchecked=function(t,e,r,n=Ke){return Ge(t,e,new n(r))};var Ye={};Object.defineProperty(Ye,"__esModule",{value:!0}),Ye.s16=Ye.s8=Ye.nu64be=Ye.u48be=Ye.u40be=Ye.u32be=Ye.u24be=Ye.u16be=zr=Ye.nu64=Ye.u48=Ye.u40=Nr=Ye.u32=Ye.u24=Cr=Ye.u16=Ur=Ye.u8=Lr=Ye.offset=Ye.greedy=Ye.Constant=Ye.UTF8=Ye.CString=Ye.Blob=Ye.Boolean=Ye.BitField=Ye.BitStructure=Ye.VariantLayout=Ye.Union=Ye.UnionLayoutDiscriminator=Ye.UnionDiscriminator=Ye.Structure=Ye.Sequence=Ye.DoubleBE=Ye.Double=Ye.FloatBE=Ye.Float=Ye.NearInt64BE=Ye.NearInt64=Ye.NearUInt64BE=Ye.NearUInt64=Ye.IntBE=Ye.Int=Ye.UIntBE=Ye.UInt=Ye.OffsetLayout=Ye.GreedyCount=Ye.ExternalLayout=Ye.bindConstructorLayout=Ye.nameWithProperty=Ye.Layout=Ye.uint8ArrayToBuffer=Ye.checkUint8Array=void 0,Ye.constant=Ye.utf8=Ye.cstr=Kr=Ye.blob=Ye.unionLayoutDiscriminator=Ye.union=Wr=Ye.seq=Ye.bits=jr=Ye.struct=Ye.f64be=Ye.f64=Ye.f32be=Ye.f32=Ye.ns64be=Ye.s48be=Ye.s40be=Ye.s32be=Ye.s24be=Ye.s16be=Dr=Ye.ns64=Ye.s48=Ye.s40=Ye.s32=Ye.s24=void 0;const Je=n;function Xe(t){if(!(t instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}function Qe(t){return Xe(t),Je.Buffer.from(t.buffer,t.byteOffset,t.length)}Ye.checkUint8Array=Xe,Ye.uint8ArrayToBuffer=Qe;class tr{constructor(t,e){if(!Number.isInteger(t))throw new TypeError("span must be an integer");this.span=t,this.property=e}makeDestinationObject(){return{}}getSpan(t,e){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(t){const e=Object.create(this.constructor.prototype);return Object.assign(e,this),e.property=t,e}fromArray(t){}}function er(t,e){return e.property?t+"["+e.property+"]":t}Ye.Layout=tr,Ye.nameWithProperty=er,Ye.bindConstructorLayout=function(t,e){if("function"!=typeof t)throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(t,"layout_"))throw new Error("Class is already bound to a layout");if(!(e&&e instanceof tr))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(e,"boundConstructor_"))throw new Error("layout is already bound to a constructor");t.layout_=e,e.boundConstructor_=t,e.makeDestinationObject=()=>new t,Object.defineProperty(t.prototype,"encode",{value(t,r){return e.encode(this,t,r)},writable:!0}),Object.defineProperty(t,"decode",{value:(t,r)=>e.decode(t,r),writable:!0})};class rr extends tr{isCount(){throw new Error("ExternalLayout is abstract")}}Ye.ExternalLayout=rr;class nr extends rr{constructor(t=1,e){if(!Number.isInteger(t)||0>=t)throw new TypeError("elementSpan must be a (positive) integer");super(-1,e),this.elementSpan=t}isCount(){return!0}decode(t,e=0){Xe(t);const r=t.length-e;return Math.floor(r/this.elementSpan)}encode(t,e,r){return 0}}Ye.GreedyCount=nr;class ir extends rr{constructor(t,e=0,r){if(!(t instanceof tr))throw new TypeError("layout must be a Layout");if(!Number.isInteger(e))throw new TypeError("offset must be integer or undefined");super(t.span,r||t.property),this.layout=t,this.offset=e}isCount(){return this.layout instanceof or||this.layout instanceof sr}decode(t,e=0){return this.layout.decode(t,e+this.offset)}encode(t,e,r=0){return this.layout.encode(t,e,r+this.offset)}}Ye.OffsetLayout=ir;class or extends tr{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return Qe(t).readUIntLE(e,this.span)}encode(t,e,r=0){return Qe(e).writeUIntLE(t,r,this.span),this.span}}Ye.UInt=or;class sr extends tr{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return Qe(t).readUIntBE(e,this.span)}encode(t,e,r=0){return Qe(e).writeUIntBE(t,r,this.span),this.span}}Ye.UIntBE=sr;class ar extends tr{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return Qe(t).readIntLE(e,this.span)}encode(t,e,r=0){return Qe(e).writeIntLE(t,r,this.span),this.span}}Ye.Int=ar;class ur extends tr{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return Qe(t).readIntBE(e,this.span)}encode(t,e,r=0){return Qe(e).writeIntBE(t,r,this.span),this.span}}Ye.IntBE=ur;const cr=Math.pow(2,32);function hr(t){const e=Math.floor(t/cr);return{hi32:e,lo32:t-e*cr}}function lr(t,e){return t*cr+e}class fr extends tr{constructor(t){super(8,t)}decode(t,e=0){const r=Qe(t),n=r.readUInt32LE(e);return lr(r.readUInt32LE(e+4),n)}encode(t,e,r=0){const n=hr(t),i=Qe(e);return i.writeUInt32LE(n.lo32,r),i.writeUInt32LE(n.hi32,r+4),8}}Ye.NearUInt64=fr;class dr extends tr{constructor(t){super(8,t)}decode(t,e=0){const r=Qe(t);return lr(r.readUInt32BE(e),r.readUInt32BE(e+4))}encode(t,e,r=0){const n=hr(t),i=Qe(e);return i.writeUInt32BE(n.hi32,r),i.writeUInt32BE(n.lo32,r+4),8}}Ye.NearUInt64BE=dr;class pr extends tr{constructor(t){super(8,t)}decode(t,e=0){const r=Qe(t),n=r.readUInt32LE(e);return lr(r.readInt32LE(e+4),n)}encode(t,e,r=0){const n=hr(t),i=Qe(e);return i.writeUInt32LE(n.lo32,r),i.writeInt32LE(n.hi32,r+4),8}}Ye.NearInt64=pr;class yr extends tr{constructor(t){super(8,t)}decode(t,e=0){const r=Qe(t);return lr(r.readInt32BE(e),r.readUInt32BE(e+4))}encode(t,e,r=0){const n=hr(t),i=Qe(e);return i.writeInt32BE(n.hi32,r),i.writeUInt32BE(n.lo32,r+4),8}}Ye.NearInt64BE=yr;class gr extends tr{constructor(t){super(4,t)}decode(t,e=0){return Qe(t).readFloatLE(e)}encode(t,e,r=0){return Qe(e).writeFloatLE(t,r),4}}Ye.Float=gr;class mr extends tr{constructor(t){super(4,t)}decode(t,e=0){return Qe(t).readFloatBE(e)}encode(t,e,r=0){return Qe(e).writeFloatBE(t,r),4}}Ye.FloatBE=mr;class wr extends tr{constructor(t){super(8,t)}decode(t,e=0){return Qe(t).readDoubleLE(e)}encode(t,e,r=0){return Qe(e).writeDoubleLE(t,r),8}}Ye.Double=wr;class br extends tr{constructor(t){super(8,t)}decode(t,e=0){return Qe(t).readDoubleBE(e)}encode(t,e,r=0){return Qe(e).writeDoubleBE(t,r),8}}Ye.DoubleBE=br;class vr extends tr{constructor(t,e,r){if(!(t instanceof tr))throw new TypeError("elementLayout must be a Layout");if(!(e instanceof rr&&e.isCount()||Number.isInteger(e)&&0<=e))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let n=-1;!(e instanceof rr)&&0<t.span&&(n=e*t.span),super(n,r),this.elementLayout=t,this.count=e}getSpan(t,e=0){if(0<=this.span)return this.span;let r=0,n=this.count;if(n instanceof rr&&(n=n.decode(t,e)),0<this.elementLayout.span)r=n*this.elementLayout.span;else{let i=0;for(;i<n;)r+=this.elementLayout.getSpan(t,e+r),++i}return r}decode(t,e=0){const r=[];let n=0,i=this.count;for(i instanceof rr&&(i=i.decode(t,e));n<i;)r.push(this.elementLayout.decode(t,e)),e+=this.elementLayout.getSpan(t,e),n+=1;return r}encode(t,e,r=0){const n=this.elementLayout,i=t.reduce(((t,i)=>t+n.encode(i,e,r+t)),0);return this.count instanceof rr&&this.count.encode(t.length,e,r),i}}Ye.Sequence=vr;class _r extends tr{constructor(t,e,r){if(!Array.isArray(t)||!t.reduce(((t,e)=>t&&e instanceof tr),!0))throw new TypeError("fields must be array of Layout instances");"boolean"==typeof e&&void 0===r&&(r=e,e=void 0);for(const e of t)if(0>e.span&&void 0===e.property)throw new Error("fields cannot contain unnamed variable-length layout");let n=-1;try{n=t.reduce(((t,e)=>t+e.getSpan()),0)}catch(t){}super(n,e),this.fields=t,this.decodePrefixes=!!r}getSpan(t,e=0){if(0<=this.span)return this.span;let r=0;try{r=this.fields.reduce(((r,n)=>{const i=n.getSpan(t,e);return e+=i,r+i}),0)}catch(t){throw new RangeError("indeterminate span")}return r}decode(t,e=0){Xe(t);const r=this.makeDestinationObject();for(const n of this.fields)if(void 0!==n.property&&(r[n.property]=n.decode(t,e)),e+=n.getSpan(t,e),this.decodePrefixes&&t.length===e)break;return r}encode(t,e,r=0){const n=r;let i=0,o=0;for(const n of this.fields){let s=n.span;if(o=0<s?s:0,void 0!==n.property){const i=t[n.property];void 0!==i&&(o=n.encode(i,e,r),0>s&&(s=n.getSpan(e,r)))}i=r,r+=s}return i+o-n}fromArray(t){const e=this.makeDestinationObject();for(const r of this.fields)void 0!==r.property&&0<t.length&&(e[r.property]=t.shift());return e}layoutFor(t){if("string"!=typeof t)throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}offsetOf(t){if("string"!=typeof t)throw new TypeError("property must be string");let e=0;for(const r of this.fields){if(r.property===t)return e;0>r.span?e=-1:0<=e&&(e+=r.span)}}}Ye.Structure=_r;class kr{constructor(t){this.property=t}decode(t,e){throw new Error("UnionDiscriminator is abstract")}encode(t,e,r){throw new Error("UnionDiscriminator is abstract")}}Ye.UnionDiscriminator=kr;class Er extends kr{constructor(t,e){if(!(t instanceof rr&&t.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(e||t.property||"variant"),this.layout=t}decode(t,e){return this.layout.decode(t,e)}encode(t,e,r){return this.layout.encode(t,e,r)}}Ye.UnionLayoutDiscriminator=Er;class xr extends tr{constructor(t,e,r){let n;if(t instanceof or||t instanceof sr)n=new Er(new ir(t));else if(t instanceof rr&&t.isCount())n=new Er(t);else{if(!(t instanceof kr))throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");n=t}if(void 0===e&&(e=null),!(null===e||e instanceof tr))throw new TypeError("defaultLayout must be null or a Layout");if(null!==e){if(0>e.span)throw new Error("defaultLayout must have constant span");void 0===e.property&&(e=e.replicate("content"))}let i=-1;e&&(i=e.span,0<=i&&(t instanceof or||t instanceof sr)&&(i+=n.layout.span)),super(i,r),this.discriminator=n,this.usesPrefixDiscriminator=t instanceof or||t instanceof sr,this.defaultLayout=e,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(t){return o(t)},this.configGetSourceVariant=function(t){o=t.bind(this)}}getSpan(t,e=0){if(0<=this.span)return this.span;const r=this.getVariant(t,e);if(!r)throw new Error("unable to determine span for unrecognized variant");return r.getSpan(t,e)}defaultGetSourceVariant(t){if(Object.prototype.hasOwnProperty.call(t,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(t,this.defaultLayout.property))return;const e=this.registry[t[this.discriminator.property]];if(e&&(!e.layout||e.property&&Object.prototype.hasOwnProperty.call(t,e.property)))return e}else for(const e in this.registry){const r=this.registry[e];if(r.property&&Object.prototype.hasOwnProperty.call(t,r.property))return r}throw new Error("unable to infer src variant")}decode(t,e=0){let r;const n=this.discriminator,i=n.decode(t,e),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(t,e+s)}else r=o.decode(t,e);return r}encode(t,e,r=0){const n=this.getSourceVariant(t);if(void 0===n){const n=this.discriminator,i=this.defaultLayout;let o=0;return this.usesPrefixDiscriminator&&(o=n.layout.span),n.encode(t[n.property],e,r),o+i.encode(t[i.property],e,r+o)}return n.encode(t,e,r)}addVariant(t,e,r){const n=new Sr(this,t,e,r);return this.registry[t]=n,n}getVariant(t,e=0){let r;return r=t instanceof Uint8Array?this.discriminator.decode(t,e):t,this.registry[r]}}Ye.Union=xr;class Sr extends tr{constructor(t,e,r,n){if(!(t instanceof xr))throw new TypeError("union must be a Union");if(!Number.isInteger(e)||0>e)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 tr))throw new TypeError("layout must be a Layout");if(null!==t.defaultLayout&&0<=r.span&&r.span>t.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=t.span;0>t.span&&(i=r?r.span:0,0<=i&&t.usesPrefixDiscriminator&&(i+=t.discriminator.layout.span)),super(i,n),this.union=t,this.variant=e,this.layout=r||null}getSpan(t,e=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(t,e+r)),r+n}decode(t,e=0){const r=this.makeDestinationObject();if(this!==this.union.getVariant(t,e))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(t,e+n):this.property?r[this.property]=!0:this.union.usesPrefixDiscriminator&&(r[this.union.discriminator.property]=this.variant),r}encode(t,e,r=0){let n=0;if(this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(t,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,e,r);let i=n;if(this.layout&&(this.layout.encode(t[this.property],e,r+n),i+=this.layout.getSpan(e,r+n),0<=this.union.span&&i>this.union.span))throw new Error("encoded variant overruns containing union");return i}fromArray(t){if(this.layout)return this.layout.fromArray(t)}}function Ar(t){return 0>t&&(t+=4294967296),t}Ye.VariantLayout=Sr;class Ir extends tr{constructor(t,e,r){if(!(t instanceof or||t instanceof sr))throw new TypeError("word must be a UInt or UIntBE layout");if("string"==typeof e&&void 0===r&&(r=e,e=!1),4<t.span)throw new RangeError("word cannot exceed 32 bits");super(t.span,r),this.word=t,this.msb=!!e,this.fields=[];let n=0;this._packedSetValue=function(t){return n=Ar(t),this},this._packedGetValue=function(){return n}}decode(t,e=0){const r=this.makeDestinationObject(),n=this.word.decode(t,e);this._packedSetValue(n);for(const e of this.fields)void 0!==e.property&&(r[e.property]=e.decode(t));return r}encode(t,e,r=0){const n=this.word.decode(e,r);this._packedSetValue(n);for(const e of this.fields)if(void 0!==e.property){const r=t[e.property];void 0!==r&&e.encode(r)}return this.word.encode(this._packedGetValue(),e,r)}addField(t,e){const r=new Br(this,t,e);return this.fields.push(r),r}addBoolean(t){const e=new Mr(this,t);return this.fields.push(e),e}fieldFor(t){if("string"!=typeof t)throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}}Ye.BitStructure=Ir;class Br{constructor(t,e,r){if(!(t instanceof Ir))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(e)||0>=e)throw new TypeError("bits must be positive integer");const n=8*t.span,i=t.fields.reduce(((t,e)=>t+e.bits),0);if(e+i>n)throw new Error("bits too long for span remainder ("+(n-i)+" of "+n+" remain)");this.container=t,this.bits=e,this.valueMask=(1<<e)-1,32===e&&(this.valueMask=4294967295),this.start=i,this.container.msb&&(this.start=n-i-e),this.wordMask=Ar(this.valueMask<<this.start),this.property=r}decode(t,e){return Ar(this.container._packedGetValue()&this.wordMask)>>>this.start}encode(t){if("number"!=typeof t||!Number.isInteger(t)||t!==Ar(t&this.valueMask))throw new TypeError(er("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const e=this.container._packedGetValue(),r=Ar(t<<this.start);this.container._packedSetValue(Ar(e&~this.wordMask)|r)}}Ye.BitField=Br;class Mr extends Br{constructor(t,e){super(t,1,e)}decode(t,e){return!!super.decode(t,e)}encode(t){"boolean"==typeof t&&(t=+t),super.encode(t)}}Ye.Boolean=Mr;class Rr extends tr{constructor(t,e){if(!(t instanceof rr&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let r=-1;t instanceof rr||(r=t),super(r,e),this.length=t}getSpan(t,e){let r=this.span;return 0>r&&(r=this.length.decode(t,e)),r}decode(t,e=0){let r=this.span;return 0>r&&(r=this.length.decode(t,e)),Qe(t).slice(e,e+r)}encode(t,e,r){let n=this.length;if(this.length instanceof rr&&(n=t.length),!(t instanceof Uint8Array&&n===t.length))throw new TypeError(er("Blob.encode",this)+" requires (length "+n+") Uint8Array as src");if(r+n>e.length)throw new RangeError("encoding overruns Uint8Array");const i=Qe(t);return Qe(e).write(i.toString("hex"),r,n,"hex"),this.length instanceof rr&&this.length.encode(n,e,r),n}}Ye.Blob=Rr;class Pr extends tr{constructor(t){super(-1,t)}getSpan(t,e=0){Xe(t);let r=e;for(;r<t.length&&0!==t[r];)r+=1;return 1+r-e}decode(t,e=0){const r=this.getSpan(t,e);return Qe(t).slice(e,e+r-1).toString("utf-8")}encode(t,e,r=0){"string"!=typeof t&&(t=String(t));const n=Je.Buffer.from(t,"utf8"),i=n.length;if(r+i>e.length)throw new RangeError("encoding overruns Buffer");const o=Qe(e);return n.copy(o,r),o[r+i]=0,i+1}}Ye.CString=Pr;class Tr extends tr{constructor(t,e){if("string"==typeof t&&void 0===e&&(e=t,t=void 0),void 0===t)t=-1;else if(!Number.isInteger(t))throw new TypeError("maxSpan must be an integer");super(-1,e),this.maxSpan=t}getSpan(t,e=0){return Xe(t),t.length-e}decode(t,e=0){const r=this.getSpan(t,e);if(0<=this.maxSpan&&this.maxSpan<r)throw new RangeError("text length exceeds maxSpan");return Qe(t).slice(e,e+r).toString("utf-8")}encode(t,e,r=0){"string"!=typeof t&&(t=String(t));const n=Je.Buffer.from(t,"utf8"),i=n.length;if(0<=this.maxSpan&&this.maxSpan<i)throw new RangeError("text length exceeds maxSpan");if(r+i>e.length)throw new RangeError("encoding overruns Buffer");return n.copy(Qe(e),r),i}}Ye.UTF8=Tr;class Or extends tr{constructor(t,e){super(0,e),this.value=t}decode(t,e){return this.value}encode(t,e,r){return 0}}Ye.Constant=Or,Ye.greedy=(t,e)=>new nr(t,e);var Lr=Ye.offset=(t,e,r)=>new ir(t,e,r),Ur=Ye.u8=t=>new or(1,t),Cr=Ye.u16=t=>new or(2,t);Ye.u24=t=>new or(3,t);var Nr=Ye.u32=t=>new or(4,t);Ye.u40=t=>new or(5,t),Ye.u48=t=>new or(6,t);var zr=Ye.nu64=t=>new fr(t);Ye.u16be=t=>new sr(2,t),Ye.u24be=t=>new sr(3,t),Ye.u32be=t=>new sr(4,t),Ye.u40be=t=>new sr(5,t),Ye.u48be=t=>new sr(6,t),Ye.nu64be=t=>new dr(t),Ye.s8=t=>new ar(1,t),Ye.s16=t=>new ar(2,t),Ye.s24=t=>new ar(3,t),Ye.s32=t=>new ar(4,t),Ye.s40=t=>new ar(5,t),Ye.s48=t=>new ar(6,t);var Dr=Ye.ns64=t=>new pr(t);Ye.s16be=t=>new ur(2,t),Ye.s24be=t=>new ur(3,t),Ye.s32be=t=>new ur(4,t),Ye.s40be=t=>new ur(5,t),Ye.s48be=t=>new ur(6,t),Ye.ns64be=t=>new yr(t),Ye.f32=t=>new gr(t),Ye.f32be=t=>new mr(t),Ye.f64=t=>new wr(t),Ye.f64be=t=>new br(t);var jr=Ye.struct=(t,e,r)=>new _r(t,e,r);Ye.bits=(t,e,r)=>new Ir(t,e,r);var Wr=Ye.seq=(t,e,r)=>new vr(t,e,r);Ye.union=(t,e,r)=>new xr(t,e,r),Ye.unionLayoutDiscriminator=(t,e)=>new Er(t,e);var Kr=Ye.blob=(t,e)=>new Rr(t,e);Ye.cstr=t=>new Pr(t),Ye.utf8=(t,e)=>new Tr(t,e),Ye.constant=(t,e)=>new Or(t,e);var Fr={};Object.defineProperty(Fr,"__esModule",{value:!0});var qr=Fr.toBigIntLE=function(t){{const e=Buffer.from(t);e.reverse();const r=e.toString("hex");return 0===r.length?BigInt(0):BigInt(`0x${r}`)}};Fr.toBigIntBE=function(t){{const e=t.toString("hex");return 0===e.length?BigInt(0):BigInt(`0x${e}`)}};var Vr,Hr=Fr.toBufferLE=function(t,e){{const r=t.toString(16),n=Buffer.from(r.padStart(2*e,"0").slice(0,2*e),"hex");return n.reverse(),n}};Fr.toBufferBE=function(t,e){{const r=t.toString(16);return Buffer.from(r.padStart(2*e,"0").slice(0,2*e),"hex")}};class $r extends TypeError{constructor(t,e){let r;const{message:n,...i}=t,{path:o}=t;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=[t,...e()]}}}function Gr(t){return"object"==typeof t&&null!=t}function Zr(t){return"string"==typeof t?JSON.stringify(t):""+t}function Yr(t,e,r,n){if(!0===t)return;!1===t?t={}:"string"==typeof t&&(t={message:t});const{path:i,branch:o}=e,{type:s}=r,{refinement:a,message:u="Expected a value of type `"+s+"`"+(a?" with refinement `"+a+"`":"")+", but received: `"+Zr(n)+"`"}=t;return{value:n,type:s,refinement:a,key:i[i.length-1],path:i,branch:o,...t,message:u}}function*Jr(t,e,r,n){(function(t){return Gr(t)&&"function"==typeof t[Symbol.iterator]})(t)||(t=[t]);for(const i of t){const t=Yr(i,e,r,n);t&&(yield t)}}function*Xr(t,e,r={}){const{path:n=[],branch:i=[t],coerce:o=!1,mask:s=!1}=r,a={path:n,branch:i};if(o&&(t=e.coercer(t,a),s&&"type"!==e.type&&Gr(e.schema)&&Gr(t)&&!Array.isArray(t)))for(const r in t)void 0===e.schema[r]&&delete t[r];let u=!0;for(const r of e.validator(t,a))u=!1,yield[r,void 0];for(let[r,c,h]of e.entries(t,a)){const e=Xr(c,h,{path:void 0===r?n:[...n,r],branch:void 0===r?i:[...i,c],coerce:o,mask:s});for(const n of e)n[0]?(u=!1,yield[n[0],void 0]):o&&(c=n[1],void 0===r?t=c:t instanceof Map?t.set(r,c):t instanceof Set?t.add(c):Gr(t)&&(t[r]=c))}if(u)for(const r of e.refiner(t,a))u=!1,yield[r,void 0];u&&(yield[void 0,t])}class Qr{constructor(t){const{type:e,schema:r,validator:n,refiner:i,coercer:o=(t=>t),entries:s=function*(){}}=t;this.type=e,this.schema=r,this.entries=s,this.coercer=o,this.validator=n?(t,e)=>Jr(n(t,e),e,this,t):()=>[],this.refiner=i?(t,e)=>Jr(i(t,e),e,this,t):()=>[]}assert(t){return tn(t,this)}create(t){return en(t,this)}is(t){return rn(t,this)}mask(t){return function(t,e){const r=nn(t,e,{coerce:!0,mask:!0});if(r[0])throw r[0];return r[1]}(t,this)}validate(t,e={}){return nn(t,this,e)}}function tn(t,e){const r=nn(t,e);if(r[0])throw r[0]}function en(t,e){const r=nn(t,e,{coerce:!0});if(r[0])throw r[0];return r[1]}function rn(t,e){return!nn(t,e)[0]}function nn(t,e,r={}){const n=Xr(t,e,r),i=function(t){const{done:e,value:r}=t.next();return e?void 0:r}(n);if(i[0]){const t=new $r(i[0],(function*(){for(const t of n)t[0]&&(yield t[0])}));return[t,void 0]}return[void 0,i[1]]}function on(t,e){return new Qr({type:t,schema:null,validator:e})}function sn(t){return new Qr({type:"array",schema:t,*entries(e){if(t&&Array.isArray(e))for(const[r,n]of e.entries())yield[r,n,t]},coercer:t=>Array.isArray(t)?t.slice():t,validator:t=>Array.isArray(t)||"Expected an array value, but received: "+Zr(t)})}function an(){return on("boolean",(t=>"boolean"==typeof t))}function un(t){return on("instance",(e=>e instanceof t||"Expected a `"+t.name+"` instance, but received: "+Zr(e)))}function cn(t){const e=Zr(t),r=typeof t;return new Qr({type:"literal",schema:"string"===r||"number"===r||"boolean"===r?t:null,validator:r=>r===t||"Expected the literal `"+e+"`, but received: "+Zr(r)})}function hn(t){return new Qr({...t,validator:(e,r)=>null===e||t.validator(e,r),refiner:(e,r)=>null===e||t.refiner(e,r)})}function ln(){return on("number",(t=>"number"==typeof t&&!isNaN(t)||"Expected a number, but received: "+Zr(t)))}function fn(t){return new Qr({...t,validator:(e,r)=>void 0===e||t.validator(e,r),refiner:(e,r)=>void 0===e||t.refiner(e,r)})}function dn(t,e){return new Qr({type:"record",schema:null,*entries(r){if(Gr(r))for(const n in r){const i=r[n];yield[n,n,t],yield[n,i,e]}},validator:t=>Gr(t)||"Expected an object, but received: "+Zr(t)})}function pn(){return on("string",(t=>"string"==typeof t||"Expected a string, but received: "+Zr(t)))}function yn(t){const e=on("never",(()=>!1));return new Qr({type:"tuple",schema:null,*entries(r){if(Array.isArray(r)){const n=Math.max(t.length,r.length);for(let i=0;i<n;i++)yield[i,r[i],t[i]||e]}},validator:t=>Array.isArray(t)||"Expected an array, but received: "+Zr(t)})}function gn(t){const e=Object.keys(t);return new Qr({type:"type",schema:t,*entries(r){if(Gr(r))for(const n of e)yield[n,r[n],t[n]]},validator:t=>Gr(t)||"Expected an object, but received: "+Zr(t)})}function mn(t){const e=t.map((t=>t.type)).join(" | ");return new Qr({type:"union",schema:null,validator(r,n){const i=[];for(const e of t){const[...t]=Xr(r,e,n),[o]=t;if(!o[0])return[];for(const[e]of t)e&&i.push(e)}return["Expected the value to satisfy a union of `"+e+"`, but received: "+Zr(r),...i]}})}function wn(){return on("unknown",(()=>!0))}function bn(t,e,r){return new Qr({...t,coercer:(n,i)=>rn(n,e)?t.coercer(r(n,i),i):t.coercer(n,i)})}var vn=new Uint8Array(16);function _n(){if(!Vr&&!(Vr="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 Vr(vn)}var kn=/^(?:[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 En(t){return"string"==typeof t&&kn.test(t)}for(var xn,Sn,An=[],In=0;In<256;++In)An.push((In+256).toString(16).substr(1));function Bn(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(An[t[e+0]]+An[t[e+1]]+An[t[e+2]]+An[t[e+3]]+"-"+An[t[e+4]]+An[t[e+5]]+"-"+An[t[e+6]]+An[t[e+7]]+"-"+An[t[e+8]]+An[t[e+9]]+"-"+An[t[e+10]]+An[t[e+11]]+An[t[e+12]]+An[t[e+13]]+An[t[e+14]]+An[t[e+15]]).toLowerCase();if(!En(r))throw TypeError("Stringified UUID is invalid");return r}var Mn=0,Rn=0;function Pn(t){if(!En(t))throw TypeError("Invalid UUID");var e,r=new Uint8Array(16);return r[0]=(e=parseInt(t.slice(0,8),16))>>>24,r[1]=e>>>16&255,r[2]=e>>>8&255,r[3]=255&e,r[4]=(e=parseInt(t.slice(9,13),16))>>>8,r[5]=255&e,r[6]=(e=parseInt(t.slice(14,18),16))>>>8,r[7]=255&e,r[8]=(e=parseInt(t.slice(19,23),16))>>>8,r[9]=255&e,r[10]=(e=parseInt(t.slice(24,36),16))/1099511627776&255,r[11]=e/4294967296&255,r[12]=e>>>24&255,r[13]=e>>>16&255,r[14]=e>>>8&255,r[15]=255&e,r}function Tn(t,e,r){function n(t,n,i,o){if("string"==typeof t&&(t=function(t){t=unescape(encodeURIComponent(t));for(var e=[],r=0;r<t.length;++r)e.push(t.charCodeAt(r));return e}(t)),"string"==typeof n&&(n=Pn(n)),16!==n.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var s=new Uint8Array(16+t.length);if(s.set(n),s.set(t,n.length),(s=r(s))[6]=15&s[6]|e,s[8]=63&s[8]|128,i){o=o||0;for(var a=0;a<16;++a)i[o+a]=s[a];return i}return Bn(s)}try{n.name=t}catch(t){}return n.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",n.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",n}function On(t){return 14+(t+64>>>9<<4)+1}function Ln(t,e){var r=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(r>>16)<<16|65535&r}function Un(t,e,r,n,i,o){return Ln((s=Ln(Ln(e,t),Ln(n,o)))<<(a=i)|s>>>32-a,r);var s,a}function Cn(t,e,r,n,i,o,s){return Un(e&r|~e&n,t,e,i,o,s)}function Nn(t,e,r,n,i,o,s){return Un(e&n|r&~n,t,e,i,o,s)}function zn(t,e,r,n,i,o,s){return Un(e^r^n,t,e,i,o,s)}function Dn(t,e,r,n,i,o,s){return Un(r^(e|~n),t,e,i,o,s)}var jn=Tn("v3",48,(function(t){if("string"==typeof t){var e=unescape(encodeURIComponent(t));t=new Uint8Array(e.length);for(var r=0;r<e.length;++r)t[r]=e.charCodeAt(r)}return function(t){for(var e=[],r=32*t.length,n="0123456789abcdef",i=0;i<r;i+=8){var o=t[i>>5]>>>i%32&255,s=parseInt(n.charAt(o>>>4&15)+n.charAt(15&o),16);e.push(s)}return e}(function(t,e){t[e>>5]|=128<<e%32,t[On(e)-1]=e;for(var r=1732584193,n=-271733879,i=-1732584194,o=271733878,s=0;s<t.length;s+=16){var a=r,u=n,c=i,h=o;r=Cn(r,n,i,o,t[s],7,-680876936),o=Cn(o,r,n,i,t[s+1],12,-389564586),i=Cn(i,o,r,n,t[s+2],17,606105819),n=Cn(n,i,o,r,t[s+3],22,-1044525330),r=Cn(r,n,i,o,t[s+4],7,-176418897),o=Cn(o,r,n,i,t[s+5],12,1200080426),i=Cn(i,o,r,n,t[s+6],17,-1473231341),n=Cn(n,i,o,r,t[s+7],22,-45705983),r=Cn(r,n,i,o,t[s+8],7,1770035416),o=Cn(o,r,n,i,t[s+9],12,-1958414417),i=Cn(i,o,r,n,t[s+10],17,-42063),n=Cn(n,i,o,r,t[s+11],22,-1990404162),r=Cn(r,n,i,o,t[s+12],7,1804603682),o=Cn(o,r,n,i,t[s+13],12,-40341101),i=Cn(i,o,r,n,t[s+14],17,-1502002290),r=Nn(r,n=Cn(n,i,o,r,t[s+15],22,1236535329),i,o,t[s+1],5,-165796510),o=Nn(o,r,n,i,t[s+6],9,-1069501632),i=Nn(i,o,r,n,t[s+11],14,643717713),n=Nn(n,i,o,r,t[s],20,-373897302),r=Nn(r,n,i,o,t[s+5],5,-701558691),o=Nn(o,r,n,i,t[s+10],9,38016083),i=Nn(i,o,r,n,t[s+15],14,-660478335),n=Nn(n,i,o,r,t[s+4],20,-405537848),r=Nn(r,n,i,o,t[s+9],5,568446438),o=Nn(o,r,n,i,t[s+14],9,-1019803690),i=Nn(i,o,r,n,t[s+3],14,-187363961),n=Nn(n,i,o,r,t[s+8],20,1163531501),r=Nn(r,n,i,o,t[s+13],5,-1444681467),o=Nn(o,r,n,i,t[s+2],9,-51403784),i=Nn(i,o,r,n,t[s+7],14,1735328473),r=zn(r,n=Nn(n,i,o,r,t[s+12],20,-1926607734),i,o,t[s+5],4,-378558),o=zn(o,r,n,i,t[s+8],11,-2022574463),i=zn(i,o,r,n,t[s+11],16,1839030562),n=zn(n,i,o,r,t[s+14],23,-35309556),r=zn(r,n,i,o,t[s+1],4,-1530992060),o=zn(o,r,n,i,t[s+4],11,1272893353),i=zn(i,o,r,n,t[s+7],16,-155497632),n=zn(n,i,o,r,t[s+10],23,-1094730640),r=zn(r,n,i,o,t[s+13],4,681279174),o=zn(o,r,n,i,t[s],11,-358537222),i=zn(i,o,r,n,t[s+3],16,-722521979),n=zn(n,i,o,r,t[s+6],23,76029189),r=zn(r,n,i,o,t[s+9],4,-640364487),o=zn(o,r,n,i,t[s+12],11,-421815835),i=zn(i,o,r,n,t[s+15],16,530742520),r=Dn(r,n=zn(n,i,o,r,t[s+2],23,-995338651),i,o,t[s],6,-198630844),o=Dn(o,r,n,i,t[s+7],10,1126891415),i=Dn(i,o,r,n,t[s+14],15,-1416354905),n=Dn(n,i,o,r,t[s+5],21,-57434055),r=Dn(r,n,i,o,t[s+12],6,1700485571),o=Dn(o,r,n,i,t[s+3],10,-1894986606),i=Dn(i,o,r,n,t[s+10],15,-1051523),n=Dn(n,i,o,r,t[s+1],21,-2054922799),r=Dn(r,n,i,o,t[s+8],6,1873313359),o=Dn(o,r,n,i,t[s+15],10,-30611744),i=Dn(i,o,r,n,t[s+6],15,-1560198380),n=Dn(n,i,o,r,t[s+13],21,1309151649),r=Dn(r,n,i,o,t[s+4],6,-145523070),o=Dn(o,r,n,i,t[s+11],10,-1120210379),i=Dn(i,o,r,n,t[s+2],15,718787259),n=Dn(n,i,o,r,t[s+9],21,-343485551),r=Ln(r,a),n=Ln(n,u),i=Ln(i,c),o=Ln(o,h)}return[r,n,i,o]}(function(t){if(0===t.length)return[];for(var e=8*t.length,r=new Uint32Array(On(e)),n=0;n<e;n+=8)r[n>>5]|=(255&t[n/8])<<n%32;return r}(t),8*t.length))})),Wn=jn;function Kn(t,e,r,n){switch(t){case 0:return e&r^~e&n;case 1:case 3:return e^r^n;case 2:return e&r^e&n^r&n}}function Fn(t,e){return t<<e|t>>>32-e}var qn=Tn("v5",80,(function(t){var e=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof t){var n=unescape(encodeURIComponent(t));t=[];for(var i=0;i<n.length;++i)t.push(n.charCodeAt(i))}else Array.isArray(t)||(t=Array.prototype.slice.call(t));t.push(128);for(var o=t.length/4+2,s=Math.ceil(o/16),a=new Array(s),u=0;u<s;++u){for(var c=new Uint32Array(16),h=0;h<16;++h)c[h]=t[64*u+4*h]<<24|t[64*u+4*h+1]<<16|t[64*u+4*h+2]<<8|t[64*u+4*h+3];a[u]=c}a[s-1][14]=8*(t.length-1)/Math.pow(2,32),a[s-1][14]=Math.floor(a[s-1][14]),a[s-1][15]=8*(t.length-1)&4294967295;for(var l=0;l<s;++l){for(var f=new Uint32Array(80),d=0;d<16;++d)f[d]=a[l][d];for(var p=16;p<80;++p)f[p]=Fn(f[p-3]^f[p-8]^f[p-14]^f[p-16],1);for(var y=r[0],g=r[1],m=r[2],w=r[3],b=r[4],v=0;v<80;++v){var _=Math.floor(v/20),k=Fn(y,5)+Kn(_,g,m,w)+b+e[_]+f[v]>>>0;b=w,w=m,m=Fn(g,30)>>>0,g=y,y=k}r[0]=r[0]+y>>>0,r[1]=r[1]+g>>>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]]})),Vn=qn;var Hn=Object.freeze({__proto__:null,v1:function(t,e,r){var n=e&&r||0,i=e||new Array(16),o=(t=t||{}).node||xn,s=void 0!==t.clockseq?t.clockseq:Sn;if(null==o||null==s){var a=t.random||(t.rng||_n)();null==o&&(o=xn=[1|a[0],a[1],a[2],a[3],a[4],a[5]]),null==s&&(s=Sn=16383&(a[6]<<8|a[7]))}var u=void 0!==t.msecs?t.msecs:Date.now(),c=void 0!==t.nsecs?t.nsecs:Rn+1,h=u-Mn+(c-Rn)/1e4;if(h<0&&void 0===t.clockseq&&(s=s+1&16383),(h<0||u>Mn)&&void 0===t.nsecs&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Mn=u,Rn=c,Sn=s;var l=(1e4*(268435455&(u+=122192928e5))+c)%4294967296;i[n++]=l>>>24&255,i[n++]=l>>>16&255,i[n++]=l>>>8&255,i[n++]=255&l;var f=u/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 e||Bn(i)},v3:Wn,v4:function(t,e,r){var n=(t=t||{}).random||(t.rng||_n)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,e){r=r||0;for(var i=0;i<16;++i)e[r+i]=n[i];return e}return Bn(n)},v5:Vn,NIL:"00000000-0000-0000-0000-000000000000",version:function(t){if(!En(t))throw TypeError("Invalid UUID");return parseInt(t.substr(14,1),16)},validate:En,stringify:Bn,parse:Pn}),$n=r(Hn);const Gn=$n.v4;var Zn=function(t,e,r,n){if("string"!=typeof t)throw new TypeError(t+" 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:t};if(2===i&&(o.jsonrpc="2.0"),e){if("object"!=typeof e&&!Array.isArray(e))throw new TypeError(e+" must be an object, array or omitted");o.params=e}if(void 0===r){const t="function"==typeof n.generator?n.generator:function(){return Gn()};o.id=t(o,n)}else 2===i&&null===r?n.notificationIdNull&&(o.id=null):o.id=r;return o};const Yn=$n.v4,Jn=Zn,Xn=function(t,e){if(!(this instanceof Xn))return new Xn(t,e);e||(e={}),this.options={reviver:void 0!==e.reviver?e.reviver:null,replacer:void 0!==e.replacer?e.replacer:null,generator:void 0!==e.generator?e.generator:function(){return Yn()},version:void 0!==e.version?e.version:2,notificationIdNull:"boolean"==typeof e.notificationIdNull&&e.notificationIdNull},this.callServer=t};var Qn=Xn;Xn.prototype.request=function(t,e,r,n){const i=this;let o=null;const s=Array.isArray(t)&&"function"==typeof e;if(1===this.options.version&&s)throw new TypeError("JSON-RPC 1.0 does not support batching");if(s||!s&&t&&"object"==typeof t&&"function"==typeof e)n=e,o=t;else{"function"==typeof r&&(n=r,r=void 0);const i="function"==typeof n;try{o=Jn(t,e,r,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(t){if(i)return n(t);throw t}if(!i)return o}let a;try{a=JSON.stringify(o,this.options.replacer)}catch(t){return n(t)}return this.callServer(a,(function(t,e){i._parseResponse(t,e,n)})),o},Xn.prototype._parseResponse=function(t,e,r){if(t)return void r(t);if(!e)return r();let n;try{n=JSON.parse(e,this.options.reviver)}catch(t){return r(t)}if(3===r.length){if(Array.isArray(n)){const t=function(t){return void 0!==t.error},e=function(e){return!t(e)};return r(null,n.filter(t),n.filter(e))}return r(null,n.error,n.result)}r(null,n)};var ti,ei=e(Qn),ri={},ni={exports:{}};(ti=ni).exports=function(t){return t&&t.__esModule?t:{default:t}},ti.exports.__esModule=!0,ti.exports.default=ti.exports;var ii,oi,si,ai,ui=ni.exports,ci={exports:{}},hi={exports:{}};function li(){return ii||(ii=1,function(t){function e(r){return t.exports=e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.__esModule=!0,t.exports.default=t.exports,e(r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports}(hi)),hi.exports}function fi(){if(ai)return si;ai=1;var t=(oi||(oi=1,function(t){var e=li().default;function r(){
|
|
14
|
+
const Pt=BigInt(0),Tt=BigInt(1);function Lt(t,e){const r=(t,e)=>{const r=e.negate();return t?r:e},n=t=>({windows:Math.ceil(e/t)+1,windowSize:2**(t-1)});return{constTimeNegate:r,unsafeLadder(e,r){let n=t.ZERO,i=e;for(;r>Pt;)r&Tt&&(n=n.add(i)),i=i.double(),r>>=Tt;return n},precomputeWindow(t,e){const{windows:r,windowSize:i}=n(e),o=[];let s=t,a=s;for(let t=0;t<r;t++){a=s,o.push(a);for(let t=1;t<i;t++)a=a.add(s),o.push(a);s=a.double()}return o},wNAF(e,i,o){const{windows:s,windowSize:a}=n(e);let u=t.ZERO,c=t.BASE;const h=BigInt(2**e-1),l=2**e,f=BigInt(e);for(let t=0;t<s;t++){const e=t*a;let n=Number(o&h);o>>=f,n>a&&(n-=l,o+=Tt);const s=e,d=e+Math.abs(n)-1,p=t%2!=0,y=n<0;0===n?c=c.add(r(p,i[s])):u=u.add(r(y,i[d]))}return{p:u,f:c}},wNAFCached(t,e,r,n){const i=t._WINDOW_SIZE||1;let o=e.get(t);return o||(o=this.precomputeWindow(t,i),1!==i&&e.set(t,n(o))),this.wNAF(i,o,r)}}}function Ot(t){return ft(t.Fp,At.reduce(((t,e)=>(t[e]="function",t)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"})),ft(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...It(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}
|
|
15
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ut=BigInt(0),Ct=BigInt(1),Nt=BigInt(2),zt=BigInt(8),Dt={zip215:!0};function jt(t){const e=function(t){const e=Ot(t);return ft(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}(t),{Fp:r,n:n,prehash:i,hash:o,randomBytes:s,nByteLength:a,h:u}=e,c=Nt<<BigInt(8*a)-Ct,h=r.create,l=e.uvRatio||((t,e)=>{try{return{isValid:!0,value:r.sqrt(t*r.inv(e))}}catch(t){return{isValid:!1,value:Ut}}}),f=e.adjustScalarBytes||(t=>t),d=e.domain||((t,e,r)=>{if(e.length||r)throw new Error("Contexts/pre-hash are not supported");return t}),p=t=>"bigint"==typeof t&&Ut<t,y=(t,e)=>p(t)&&p(e)&&t<e,g=t=>t===Ut||y(t,c);function m(t,e){if(y(t,e))return t;throw new Error(`Expected valid scalar < ${e}, got ${typeof t} ${t}`)}function w(t){return t===Ut?t:m(t,n)}const b=new Map;function v(t){if(!(t instanceof _))throw new Error("ExtendedPoint expected")}class _{constructor(t,e,r,n){if(this.ex=t,this.ey=e,this.ez=r,this.et=n,!g(t))throw new Error("x required");if(!g(e))throw new Error("y required");if(!g(r))throw new Error("z required");if(!g(n))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(t){if(t instanceof _)throw new Error("extended point not allowed");const{x:e,y:r}=t||{};if(!g(e)||!g(r))throw new Error("invalid affine point");return new _(e,r,Ct,h(e*r))}static normalizeZ(t){const e=r.invertBatch(t.map((t=>t.ez)));return t.map(((t,r)=>t.toAffine(e[r]))).map(_.fromAffine)}_setWindowSize(t){this._WINDOW_SIZE=t,b.delete(this)}assertValidity(){const{a:t,d:r}=e;if(this.is0())throw new Error("bad point: ZERO");const{ex:n,ey:i,ez:o,et:s}=this,a=h(n*n),u=h(i*i),c=h(o*o),l=h(c*c),f=h(a*t);if(h(c*h(f+u))!==h(l+h(r*h(a*u))))throw new Error("bad point: equation left != right (1)");if(h(n*i)!==h(o*s))throw new Error("bad point: equation left != right (2)")}equals(t){v(t);const{ex:e,ey:r,ez:n}=this,{ex:i,ey:o,ez:s}=t,a=h(e*s),u=h(i*n),c=h(r*s),l=h(o*n);return a===u&&c===l}is0(){return this.equals(_.ZERO)}negate(){return new _(h(-this.ex),this.ey,this.ez,h(-this.et))}double(){const{a:t}=e,{ex:r,ey:n,ez:i}=this,o=h(r*r),s=h(n*n),a=h(Nt*h(i*i)),u=h(t*o),c=r+n,l=h(h(c*c)-o-s),f=u+s,d=f-a,p=u-s,y=h(l*d),g=h(f*p),m=h(l*p),w=h(d*f);return new _(y,g,w,m)}add(t){v(t);const{a:r,d:n}=e,{ex:i,ey:o,ez:s,et:a}=this,{ex:u,ey:c,ez:l,et:f}=t;if(r===BigInt(-1)){const t=h((o-i)*(c+u)),e=h((o+i)*(c-u)),r=h(e-t);if(r===Ut)return this.double();const n=h(s*Nt*f),d=h(a*Nt*l),p=d+n,y=e+t,g=d-n,m=h(p*r),w=h(y*g),b=h(p*g),v=h(r*y);return new _(m,w,v,b)}const d=h(i*u),p=h(o*c),y=h(a*n*f),g=h(s*l),m=h((i+o)*(u+c)-d-p),w=g-y,b=g+y,k=h(p-r*d),E=h(m*w),x=h(b*k),S=h(m*k),A=h(w*b);return new _(E,x,A,S)}subtract(t){return this.add(t.negate())}wNAF(t){return x.wNAFCached(this,b,t,_.normalizeZ)}multiply(t){const{p:e,f:r}=this.wNAF(m(t,n));return _.normalizeZ([e,r])[0]}multiplyUnsafe(t){let e=w(t);return e===Ut?E:this.equals(E)||e===Ct?this:this.equals(k)?this.wNAF(e).p:x.unsafeLadder(this,e)}isSmallOrder(){return this.multiplyUnsafe(u).is0()}isTorsionFree(){return x.unsafeLadder(this,n).is0()}toAffine(t){const{ex:e,ey:n,ez:i}=this,o=this.is0();null==t&&(t=o?zt:r.inv(i));const s=h(e*t),a=h(n*t),u=h(i*t);if(o)return{x:Ut,y:Ct};if(u!==Ct)throw new Error("invZ was invalid");return{x:s,y:a}}clearCofactor(){const{h:t}=e;return t===Ct?this:this.multiplyUnsafe(t)}static fromHex(t,n=!1){const{d:i,a:o}=e,s=r.BYTES,a=(t=ot("pointHex",t,s)).slice(),u=t[s-1];a[s-1]=-129&u;const f=rt(a);f===Ut||m(f,n?c:r.ORDER);const d=h(f*f),p=h(d-Ct),y=h(i*d-o);let{isValid:g,value:w}=l(p,y);if(!g)throw new Error("Point.fromHex: invalid y coordinate");const b=(w&Ct)===Ct,v=0!=(128&u);if(!n&&w===Ut&&v)throw new Error("Point.fromHex: x=0 and x_0=1");return v!==b&&(w=h(-w)),_.fromAffine({x:w,y:f})}static fromPrivateKey(t){return I(t).point}toRawBytes(){const{x:t,y:e}=this.toAffine(),n=it(e,r.BYTES);return n[n.length-1]|=t&Ct?128:0,n}toHex(){return J(this.toRawBytes())}}_.BASE=new _(e.Gx,e.Gy,Ct,h(e.Gx*e.Gy)),_.ZERO=new _(Ut,Ct,Ct,Ut);const{BASE:k,ZERO:E}=_,x=Lt(_,8*a);function S(t){return _t(t,n)}function A(t){return S(rt(t))}function I(t){const e=a;t=ot("private key",t,e);const r=ot("hashed private key",o(t),2*e),n=f(r.slice(0,e)),i=r.slice(e,2*e),s=A(n),u=k.multiply(s),c=u.toRawBytes();return{head:n,prefix:i,scalar:s,point:u,pointBytes:c}}function B(t=new Uint8Array,...e){const r=st(...e);return A(o(d(r,ot("context",t),!!i)))}const M=Dt;k._setWindowSize(8);return{CURVE:e,getPublicKey:function(t){return I(t).pointBytes},sign:function(t,e,n={}){t=ot("message",t),i&&(t=i(t));const{prefix:o,scalar:s,pointBytes:u}=I(e),c=B(n.context,o,t),h=k.multiply(c).toRawBytes(),l=S(c+B(n.context,h,u,t)*s);return w(l),ot("result",st(h,it(l,r.BYTES)),2*a)},verify:function(t,e,n,o=M){const{context:s,zip215:a}=o,u=r.BYTES;t=ot("signature",t,2*u),e=ot("message",e),i&&(e=i(e));const c=rt(t.slice(u,2*u));let h,l,f;try{h=_.fromHex(n,a),l=_.fromHex(t.slice(0,u),a),f=k.multiplyUnsafe(c)}catch(t){return!1}if(!a&&h.isSmallOrder())return!1;const d=B(s,l.toRawBytes(),h.toRawBytes(),e);return l.add(h.multiplyUnsafe(d)).subtract(f).clearCofactor().equals(_.ZERO)},ExtendedPoint:_,utils:{getExtendedPublicKey:I,randomPrivateKey:()=>s(r.BYTES),precompute:(t=8,e=_.BASE)=>(e._setWindowSize(t),e.multiply(BigInt(3)),e)}}}
|
|
16
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Wt=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Ft=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const Kt=BigInt(1),Vt=BigInt(2),qt=BigInt(5),Ht=BigInt(10),$t=BigInt(20),Gt=BigInt(40),Zt=BigInt(80);const Yt=Bt(Wt,void 0,!0),Jt={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Yt,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:q,randomBytes:B,adjustScalarBytes:function(t){return t[0]&=248,t[31]&=127,t[31]|=64,t},uvRatio:function(t,e){const r=Wt,n=_t(e*e*e,r),i=function(t){const e=Wt,r=t*t%e*t%e,n=Et(r,Vt,e)*r%e,i=Et(n,Kt,e)*t%e,o=Et(i,qt,e)*i%e,s=Et(o,Ht,e)*o%e,a=Et(s,$t,e)*s%e,u=Et(a,Gt,e)*a%e,c=Et(u,Zt,e)*u%e,h=Et(c,Zt,e)*u%e,l=Et(h,Ht,e)*o%e;return{pow_p_5_8:Et(l,Vt,e)*t%e,b2:r}}(t*_t(n*n*e,r)).pow_p_5_8;let o=_t(t*n*i,r);const s=_t(e*o*o,r),a=o,u=_t(o*Ft,r),c=s===t,h=s===_t(-t,r),l=s===_t(-t*Ft,r);return c&&(o=a),(h||l)&&(o=u),(_t(o,r)&yt)===yt&&(o=_t(-o,r)),{isValid:c||h,value:o}}},Xt=jt(Jt);const Qt=(Yt.ORDER+BigInt(3))/BigInt(8);Yt.pow(Vt,Qt),Yt.sqrt(Yt.neg(Yt.ONE)),Yt.ORDER,BigInt(5),BigInt(8),BigInt(486662),function(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");const r=t.sqrt(e);t.isOdd(r)&&t.neg(r)}(Yt,Yt.neg(BigInt(486664))),BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");var te={exports:{}},ee=r(Object.freeze({__proto__:null,default:{}}));!function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function n(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function i(t,e,r){if(i.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var o;"object"==typeof t?t.exports=i:e.BN=i,i.BN=i,i.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:ee.Buffer}catch(t){}function s(t,e){var n=t.charCodeAt(e);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 "+t)}function a(t,e,r){var n=s(t,r);return r-1>=e&&(n|=s(t,r-1)<<4),n}function u(t,e,n,i){for(var o=0,s=0,a=Math.min(t.length,n),u=e;u<a;u++){var c=t.charCodeAt(u)-48;o*=i,s=c>=49?c-49+10:c>=17?c-17+10:c,r(c>=0&&s<i,"Invalid character"),o+=s}return o}function c(t,e){t.words=e.words,t.length=e.length,t.negative=e.negative,t.red=e.red}if(i.isBN=function(t){return t instanceof i||null!==t&&"object"==typeof t&&t.constructor.wordSize===i.wordSize&&Array.isArray(t.words)},i.max=function(t,e){return t.cmp(e)>0?t:e},i.min=function(t,e){return t.cmp(e)<0?t:e},i.prototype._init=function(t,e,n){if("number"==typeof t)return this._initNumber(t,e,n);if("object"==typeof t)return this._initArray(t,e,n);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var i=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(i++,this.negative=1),i<t.length&&(16===e?this._parseHex(t,i,n):(this._parseBase(t,e,i),"le"===n&&this._initArray(this.toArray(),e,n)))},i.prototype._initNumber=function(t,e,n){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),e,n)},i.prototype._initArray=function(t,e,n){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var o,s,a=0;if("be"===n)for(i=t.length-1,o=0;i>=0;i-=3)s=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===n)for(i=0,o=0;i<t.length;i+=3)s=t[i]|t[i+1]<<8|t[i+2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this._strip()},i.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var i,o=0,s=0;if("be"===r)for(n=t.length-1;n>=e;n-=2)i=a(t,e,n)<<o,this.words[s]|=67108863&i,o>=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;else for(n=(t.length-e)%2==0?e+1:e;n<t.length;n+=2)i=a(t,e,n)<<o,this.words[s]|=67108863&i,o>=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;this._strip()},i.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=e)n++;n--,i=i/e|0;for(var o=t.length-r,s=o%n,a=Math.min(o,o-s)+r,c=0,h=r;h<a;h+=n)c=u(t,h,h+n,e),this.imuln(i),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(0!==s){var l=1;for(c=u(t,h,t.length,e),h=0;h<s;h++)l*=e;this.imuln(l),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}this._strip()},i.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},i.prototype._move=function(t){c(t,this)},i.prototype.clone=function(){var t=new i(null);return this.copy(t),t},i.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},i.prototype._strip=function(){for(;this.length>1&&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(t){i.prototype.inspect=h}else i.prototype.inspect=h;function h(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}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(t,e,r){r.negative=e.negative^t.negative;var n=t.length+e.length|0;r.length=n,n=n-1|0;var i=0|t.words[0],o=0|e.words[0],s=i*o,a=67108863&s,u=s/67108864|0;r.words[0]=a;for(var c=1;c<n;c++){for(var h=u>>>26,l=67108863&u,f=Math.min(c,e.length-1),d=Math.max(0,c-t.length+1);d<=f;d++){var p=c-d|0;h+=(s=(i=0|t.words[p])*(o=0|e.words[d])+l)/67108864|0,l=67108863&s}r.words[c]=0|l,u=0|h}return 0!==u?r.words[c]=0|u:r.length--,r._strip()}i.prototype.toString=function(t,e){var n;if(e=0|e||1,16===(t=t||10)||"hex"===t){n="";for(var i=0,o=0,s=0;s<this.length;s++){var a=this.words[s],u=(16777215&(a<<i|o)).toString(16);o=a>>>24-i&16777215,(i+=2)>=26&&(i-=26,s--),n=0!==o||s!==this.length-1?l[6-u.length]+u+n:u+n}for(0!==o&&(n=o.toString(16)+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(t===(0|t)&&t>=2&&t<=36){var c=f[t],h=d[t];n="";var p=this.clone();for(p.negative=0;!p.isZero();){var y=p.modrn(h).toString(t);n=(p=p.idivn(h)).isZero()?y+n:l[c-y.length]+y+n}for(this.isZero()&&(n="0"+n);n.length%e!=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 t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},i.prototype.toJSON=function(){return this.toString(16,2)},o&&(i.prototype.toBuffer=function(t,e){return this.toArrayLike(o,t,e)}),i.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},i.prototype.toArrayLike=function(t,e,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(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,o);return this["_toArrayLike"+("le"===e?"LE":"BE")](s,i),s},i.prototype._toArrayLikeLE=function(t,e){for(var r=0,n=0,i=0,o=0;i<this.length;i++){var s=this.words[i]<<o|n;t[r++]=255&s,r<t.length&&(t[r++]=s>>8&255),r<t.length&&(t[r++]=s>>16&255),6===o?(r<t.length&&(t[r++]=s>>24&255),n=0,o=0):(n=s>>>24,o+=2)}if(r<t.length)for(t[r++]=n;r<t.length;)t[r++]=0},i.prototype._toArrayLikeBE=function(t,e){for(var r=t.length-1,n=0,i=0,o=0;i<this.length;i++){var s=this.words[i]<<o|n;t[r--]=255&s,r>=0&&(t[r--]=s>>8&255),r>=0&&(t[r--]=s>>16&255),6===o?(r>=0&&(t[r--]=s>>24&255),n=0,o=0):(n=s>>>24,o+=2)}if(r>=0)for(t[r--]=n;r>=0;)t[r--]=0},Math.clz32?i.prototype._countBits=function(t){return 32-Math.clz32(t)}:i.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},i.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},i.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},i.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return 0!==this.negative},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this._strip()},i.prototype.ior=function(t){return r(0==(this.negative|t.negative)),this.iuor(t)},i.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},i.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},i.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this._strip()},i.prototype.iand=function(t){return r(0==(this.negative|t.negative)),this.iuand(t)},i.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},i.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},i.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;n<r.length;n++)this.words[n]=e.words[n]^r.words[n];if(this!==e)for(;n<e.length;n++)this.words[n]=e.words[n];return this.length=e.length,this._strip()},i.prototype.ixor=function(t){return r(0==(this.negative|t.negative)),this.iuxor(t)},i.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},i.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},i.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),n=t%26;this._expand(e),n>0&&e--;for(var i=0;i<e;i++)this.words[i]=67108863&~this.words[i];return n>0&&(this.words[i]=~this.words[i]&67108863>>26-n),this._strip()},i.prototype.notn=function(t){return this.clone().inotn(t)},i.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);var n=t/26|0,i=t%26;return this._expand(n+1),this.words[n]=e?this.words[n]|1<<i:this.words[n]&~(1<<i),this._strip()},i.prototype.iadd=function(t){var e,r,n;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,n=t):(r=t,n=this);for(var i=0,o=0;o<n.length;o++)e=(0|r.words[o])+(0|n.words[o])+i,this.words[o]=67108863&e,i=e>>>26;for(;0!==i&&o<r.length;o++)e=(0|r.words[o])+i,this.words[o]=67108863&e,i=e>>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},i.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},i.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,n,i=this.cmp(t);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=t):(r=t,n=this);for(var o=0,s=0;s<n.length;s++)o=(e=(0|r.words[s])-(0|n.words[s])+o)>>26,this.words[s]=67108863&e;for(;0!==o&&s<r.length;s++)o=(e=(0|r.words[s])+o)>>26,this.words[s]=67108863&e;if(0===o&&s<r.length&&r!==this)for(;s<r.length;s++)this.words[s]=r.words[s];return this.length=Math.max(this.length,s),r!==this&&(this.negative=1),this._strip()},i.prototype.sub=function(t){return this.clone().isub(t)};var y=function(t,e,r){var n,i,o,s=t.words,a=e.words,u=r.words,c=0,h=0|s[0],l=8191&h,f=h>>>13,d=0|s[1],p=8191&d,y=d>>>13,g=0|s[2],m=8191&g,w=g>>>13,b=0|s[3],v=8191&b,_=b>>>13,k=0|s[4],E=8191&k,x=k>>>13,S=0|s[5],A=8191&S,I=S>>>13,B=0|s[6],M=8191&B,R=B>>>13,P=0|s[7],T=8191&P,L=P>>>13,O=0|s[8],U=8191&O,C=O>>>13,N=0|s[9],z=8191&N,D=N>>>13,j=0|a[0],W=8191&j,F=j>>>13,K=0|a[1],V=8191&K,q=K>>>13,H=0|a[2],$=8191&H,G=H>>>13,Z=0|a[3],Y=8191&Z,J=Z>>>13,X=0|a[4],Q=8191&X,tt=X>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],ot=8191&it,st=it>>>13,at=0|a[7],ut=8191&at,ct=at>>>13,ht=0|a[8],lt=8191&ht,ft=ht>>>13,dt=0|a[9],pt=8191&dt,yt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(c+(n=Math.imul(l,W))|0)+((8191&(i=(i=Math.imul(l,F))+Math.imul(f,W)|0))<<13)|0;c=((o=Math.imul(f,F))+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(p,W),i=(i=Math.imul(p,F))+Math.imul(y,W)|0,o=Math.imul(y,F);var mt=(c+(n=n+Math.imul(l,V)|0)|0)+((8191&(i=(i=i+Math.imul(l,q)|0)+Math.imul(f,V)|0))<<13)|0;c=((o=o+Math.imul(f,q)|0)+(i>>>13)|0)+(mt>>>26)|0,mt&=67108863,n=Math.imul(m,W),i=(i=Math.imul(m,F))+Math.imul(w,W)|0,o=Math.imul(w,F),n=n+Math.imul(p,V)|0,i=(i=i+Math.imul(p,q)|0)+Math.imul(y,V)|0,o=o+Math.imul(y,q)|0;var wt=(c+(n=n+Math.imul(l,$)|0)|0)+((8191&(i=(i=i+Math.imul(l,G)|0)+Math.imul(f,$)|0))<<13)|0;c=((o=o+Math.imul(f,G)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(v,W),i=(i=Math.imul(v,F))+Math.imul(_,W)|0,o=Math.imul(_,F),n=n+Math.imul(m,V)|0,i=(i=i+Math.imul(m,q)|0)+Math.imul(w,V)|0,o=o+Math.imul(w,q)|0,n=n+Math.imul(p,$)|0,i=(i=i+Math.imul(p,G)|0)+Math.imul(y,$)|0,o=o+Math.imul(y,G)|0;var bt=(c+(n=n+Math.imul(l,Y)|0)|0)+((8191&(i=(i=i+Math.imul(l,J)|0)+Math.imul(f,Y)|0))<<13)|0;c=((o=o+Math.imul(f,J)|0)+(i>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(E,W),i=(i=Math.imul(E,F))+Math.imul(x,W)|0,o=Math.imul(x,F),n=n+Math.imul(v,V)|0,i=(i=i+Math.imul(v,q)|0)+Math.imul(_,V)|0,o=o+Math.imul(_,q)|0,n=n+Math.imul(m,$)|0,i=(i=i+Math.imul(m,G)|0)+Math.imul(w,$)|0,o=o+Math.imul(w,G)|0,n=n+Math.imul(p,Y)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(y,Y)|0,o=o+Math.imul(y,J)|0;var vt=(c+(n=n+Math.imul(l,Q)|0)|0)+((8191&(i=(i=i+Math.imul(l,tt)|0)+Math.imul(f,Q)|0))<<13)|0;c=((o=o+Math.imul(f,tt)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(A,W),i=(i=Math.imul(A,F))+Math.imul(I,W)|0,o=Math.imul(I,F),n=n+Math.imul(E,V)|0,i=(i=i+Math.imul(E,q)|0)+Math.imul(x,V)|0,o=o+Math.imul(x,q)|0,n=n+Math.imul(v,$)|0,i=(i=i+Math.imul(v,G)|0)+Math.imul(_,$)|0,o=o+Math.imul(_,G)|0,n=n+Math.imul(m,Y)|0,i=(i=i+Math.imul(m,J)|0)+Math.imul(w,Y)|0,o=o+Math.imul(w,J)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(y,Q)|0,o=o+Math.imul(y,tt)|0;var _t=(c+(n=n+Math.imul(l,rt)|0)|0)+((8191&(i=(i=i+Math.imul(l,nt)|0)+Math.imul(f,rt)|0))<<13)|0;c=((o=o+Math.imul(f,nt)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(M,W),i=(i=Math.imul(M,F))+Math.imul(R,W)|0,o=Math.imul(R,F),n=n+Math.imul(A,V)|0,i=(i=i+Math.imul(A,q)|0)+Math.imul(I,V)|0,o=o+Math.imul(I,q)|0,n=n+Math.imul(E,$)|0,i=(i=i+Math.imul(E,G)|0)+Math.imul(x,$)|0,o=o+Math.imul(x,G)|0,n=n+Math.imul(v,Y)|0,i=(i=i+Math.imul(v,J)|0)+Math.imul(_,Y)|0,o=o+Math.imul(_,J)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,tt)|0)+Math.imul(w,Q)|0,o=o+Math.imul(w,tt)|0,n=n+Math.imul(p,rt)|0,i=(i=i+Math.imul(p,nt)|0)+Math.imul(y,rt)|0,o=o+Math.imul(y,nt)|0;var kt=(c+(n=n+Math.imul(l,ot)|0)|0)+((8191&(i=(i=i+Math.imul(l,st)|0)+Math.imul(f,ot)|0))<<13)|0;c=((o=o+Math.imul(f,st)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(T,W),i=(i=Math.imul(T,F))+Math.imul(L,W)|0,o=Math.imul(L,F),n=n+Math.imul(M,V)|0,i=(i=i+Math.imul(M,q)|0)+Math.imul(R,V)|0,o=o+Math.imul(R,q)|0,n=n+Math.imul(A,$)|0,i=(i=i+Math.imul(A,G)|0)+Math.imul(I,$)|0,o=o+Math.imul(I,G)|0,n=n+Math.imul(E,Y)|0,i=(i=i+Math.imul(E,J)|0)+Math.imul(x,Y)|0,o=o+Math.imul(x,J)|0,n=n+Math.imul(v,Q)|0,i=(i=i+Math.imul(v,tt)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,tt)|0,n=n+Math.imul(m,rt)|0,i=(i=i+Math.imul(m,nt)|0)+Math.imul(w,rt)|0,o=o+Math.imul(w,nt)|0,n=n+Math.imul(p,ot)|0,i=(i=i+Math.imul(p,st)|0)+Math.imul(y,ot)|0,o=o+Math.imul(y,st)|0;var Et=(c+(n=n+Math.imul(l,ut)|0)|0)+((8191&(i=(i=i+Math.imul(l,ct)|0)+Math.imul(f,ut)|0))<<13)|0;c=((o=o+Math.imul(f,ct)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(U,W),i=(i=Math.imul(U,F))+Math.imul(C,W)|0,o=Math.imul(C,F),n=n+Math.imul(T,V)|0,i=(i=i+Math.imul(T,q)|0)+Math.imul(L,V)|0,o=o+Math.imul(L,q)|0,n=n+Math.imul(M,$)|0,i=(i=i+Math.imul(M,G)|0)+Math.imul(R,$)|0,o=o+Math.imul(R,G)|0,n=n+Math.imul(A,Y)|0,i=(i=i+Math.imul(A,J)|0)+Math.imul(I,Y)|0,o=o+Math.imul(I,J)|0,n=n+Math.imul(E,Q)|0,i=(i=i+Math.imul(E,tt)|0)+Math.imul(x,Q)|0,o=o+Math.imul(x,tt)|0,n=n+Math.imul(v,rt)|0,i=(i=i+Math.imul(v,nt)|0)+Math.imul(_,rt)|0,o=o+Math.imul(_,nt)|0,n=n+Math.imul(m,ot)|0,i=(i=i+Math.imul(m,st)|0)+Math.imul(w,ot)|0,o=o+Math.imul(w,st)|0,n=n+Math.imul(p,ut)|0,i=(i=i+Math.imul(p,ct)|0)+Math.imul(y,ut)|0,o=o+Math.imul(y,ct)|0;var xt=(c+(n=n+Math.imul(l,lt)|0)|0)+((8191&(i=(i=i+Math.imul(l,ft)|0)+Math.imul(f,lt)|0))<<13)|0;c=((o=o+Math.imul(f,ft)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(z,W),i=(i=Math.imul(z,F))+Math.imul(D,W)|0,o=Math.imul(D,F),n=n+Math.imul(U,V)|0,i=(i=i+Math.imul(U,q)|0)+Math.imul(C,V)|0,o=o+Math.imul(C,q)|0,n=n+Math.imul(T,$)|0,i=(i=i+Math.imul(T,G)|0)+Math.imul(L,$)|0,o=o+Math.imul(L,G)|0,n=n+Math.imul(M,Y)|0,i=(i=i+Math.imul(M,J)|0)+Math.imul(R,Y)|0,o=o+Math.imul(R,J)|0,n=n+Math.imul(A,Q)|0,i=(i=i+Math.imul(A,tt)|0)+Math.imul(I,Q)|0,o=o+Math.imul(I,tt)|0,n=n+Math.imul(E,rt)|0,i=(i=i+Math.imul(E,nt)|0)+Math.imul(x,rt)|0,o=o+Math.imul(x,nt)|0,n=n+Math.imul(v,ot)|0,i=(i=i+Math.imul(v,st)|0)+Math.imul(_,ot)|0,o=o+Math.imul(_,st)|0,n=n+Math.imul(m,ut)|0,i=(i=i+Math.imul(m,ct)|0)+Math.imul(w,ut)|0,o=o+Math.imul(w,ct)|0,n=n+Math.imul(p,lt)|0,i=(i=i+Math.imul(p,ft)|0)+Math.imul(y,lt)|0,o=o+Math.imul(y,ft)|0;var St=(c+(n=n+Math.imul(l,pt)|0)|0)+((8191&(i=(i=i+Math.imul(l,yt)|0)+Math.imul(f,pt)|0))<<13)|0;c=((o=o+Math.imul(f,yt)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(z,V),i=(i=Math.imul(z,q))+Math.imul(D,V)|0,o=Math.imul(D,q),n=n+Math.imul(U,$)|0,i=(i=i+Math.imul(U,G)|0)+Math.imul(C,$)|0,o=o+Math.imul(C,G)|0,n=n+Math.imul(T,Y)|0,i=(i=i+Math.imul(T,J)|0)+Math.imul(L,Y)|0,o=o+Math.imul(L,J)|0,n=n+Math.imul(M,Q)|0,i=(i=i+Math.imul(M,tt)|0)+Math.imul(R,Q)|0,o=o+Math.imul(R,tt)|0,n=n+Math.imul(A,rt)|0,i=(i=i+Math.imul(A,nt)|0)+Math.imul(I,rt)|0,o=o+Math.imul(I,nt)|0,n=n+Math.imul(E,ot)|0,i=(i=i+Math.imul(E,st)|0)+Math.imul(x,ot)|0,o=o+Math.imul(x,st)|0,n=n+Math.imul(v,ut)|0,i=(i=i+Math.imul(v,ct)|0)+Math.imul(_,ut)|0,o=o+Math.imul(_,ct)|0,n=n+Math.imul(m,lt)|0,i=(i=i+Math.imul(m,ft)|0)+Math.imul(w,lt)|0,o=o+Math.imul(w,ft)|0;var At=(c+(n=n+Math.imul(p,pt)|0)|0)+((8191&(i=(i=i+Math.imul(p,yt)|0)+Math.imul(y,pt)|0))<<13)|0;c=((o=o+Math.imul(y,yt)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(z,$),i=(i=Math.imul(z,G))+Math.imul(D,$)|0,o=Math.imul(D,G),n=n+Math.imul(U,Y)|0,i=(i=i+Math.imul(U,J)|0)+Math.imul(C,Y)|0,o=o+Math.imul(C,J)|0,n=n+Math.imul(T,Q)|0,i=(i=i+Math.imul(T,tt)|0)+Math.imul(L,Q)|0,o=o+Math.imul(L,tt)|0,n=n+Math.imul(M,rt)|0,i=(i=i+Math.imul(M,nt)|0)+Math.imul(R,rt)|0,o=o+Math.imul(R,nt)|0,n=n+Math.imul(A,ot)|0,i=(i=i+Math.imul(A,st)|0)+Math.imul(I,ot)|0,o=o+Math.imul(I,st)|0,n=n+Math.imul(E,ut)|0,i=(i=i+Math.imul(E,ct)|0)+Math.imul(x,ut)|0,o=o+Math.imul(x,ct)|0,n=n+Math.imul(v,lt)|0,i=(i=i+Math.imul(v,ft)|0)+Math.imul(_,lt)|0,o=o+Math.imul(_,ft)|0;var It=(c+(n=n+Math.imul(m,pt)|0)|0)+((8191&(i=(i=i+Math.imul(m,yt)|0)+Math.imul(w,pt)|0))<<13)|0;c=((o=o+Math.imul(w,yt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(z,Y),i=(i=Math.imul(z,J))+Math.imul(D,Y)|0,o=Math.imul(D,J),n=n+Math.imul(U,Q)|0,i=(i=i+Math.imul(U,tt)|0)+Math.imul(C,Q)|0,o=o+Math.imul(C,tt)|0,n=n+Math.imul(T,rt)|0,i=(i=i+Math.imul(T,nt)|0)+Math.imul(L,rt)|0,o=o+Math.imul(L,nt)|0,n=n+Math.imul(M,ot)|0,i=(i=i+Math.imul(M,st)|0)+Math.imul(R,ot)|0,o=o+Math.imul(R,st)|0,n=n+Math.imul(A,ut)|0,i=(i=i+Math.imul(A,ct)|0)+Math.imul(I,ut)|0,o=o+Math.imul(I,ct)|0,n=n+Math.imul(E,lt)|0,i=(i=i+Math.imul(E,ft)|0)+Math.imul(x,lt)|0,o=o+Math.imul(x,ft)|0;var Bt=(c+(n=n+Math.imul(v,pt)|0)|0)+((8191&(i=(i=i+Math.imul(v,yt)|0)+Math.imul(_,pt)|0))<<13)|0;c=((o=o+Math.imul(_,yt)|0)+(i>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,n=Math.imul(z,Q),i=(i=Math.imul(z,tt))+Math.imul(D,Q)|0,o=Math.imul(D,tt),n=n+Math.imul(U,rt)|0,i=(i=i+Math.imul(U,nt)|0)+Math.imul(C,rt)|0,o=o+Math.imul(C,nt)|0,n=n+Math.imul(T,ot)|0,i=(i=i+Math.imul(T,st)|0)+Math.imul(L,ot)|0,o=o+Math.imul(L,st)|0,n=n+Math.imul(M,ut)|0,i=(i=i+Math.imul(M,ct)|0)+Math.imul(R,ut)|0,o=o+Math.imul(R,ct)|0,n=n+Math.imul(A,lt)|0,i=(i=i+Math.imul(A,ft)|0)+Math.imul(I,lt)|0,o=o+Math.imul(I,ft)|0;var Mt=(c+(n=n+Math.imul(E,pt)|0)|0)+((8191&(i=(i=i+Math.imul(E,yt)|0)+Math.imul(x,pt)|0))<<13)|0;c=((o=o+Math.imul(x,yt)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(z,rt),i=(i=Math.imul(z,nt))+Math.imul(D,rt)|0,o=Math.imul(D,nt),n=n+Math.imul(U,ot)|0,i=(i=i+Math.imul(U,st)|0)+Math.imul(C,ot)|0,o=o+Math.imul(C,st)|0,n=n+Math.imul(T,ut)|0,i=(i=i+Math.imul(T,ct)|0)+Math.imul(L,ut)|0,o=o+Math.imul(L,ct)|0,n=n+Math.imul(M,lt)|0,i=(i=i+Math.imul(M,ft)|0)+Math.imul(R,lt)|0,o=o+Math.imul(R,ft)|0;var Rt=(c+(n=n+Math.imul(A,pt)|0)|0)+((8191&(i=(i=i+Math.imul(A,yt)|0)+Math.imul(I,pt)|0))<<13)|0;c=((o=o+Math.imul(I,yt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,n=Math.imul(z,ot),i=(i=Math.imul(z,st))+Math.imul(D,ot)|0,o=Math.imul(D,st),n=n+Math.imul(U,ut)|0,i=(i=i+Math.imul(U,ct)|0)+Math.imul(C,ut)|0,o=o+Math.imul(C,ct)|0,n=n+Math.imul(T,lt)|0,i=(i=i+Math.imul(T,ft)|0)+Math.imul(L,lt)|0,o=o+Math.imul(L,ft)|0;var Pt=(c+(n=n+Math.imul(M,pt)|0)|0)+((8191&(i=(i=i+Math.imul(M,yt)|0)+Math.imul(R,pt)|0))<<13)|0;c=((o=o+Math.imul(R,yt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(z,ut),i=(i=Math.imul(z,ct))+Math.imul(D,ut)|0,o=Math.imul(D,ct),n=n+Math.imul(U,lt)|0,i=(i=i+Math.imul(U,ft)|0)+Math.imul(C,lt)|0,o=o+Math.imul(C,ft)|0;var Tt=(c+(n=n+Math.imul(T,pt)|0)|0)+((8191&(i=(i=i+Math.imul(T,yt)|0)+Math.imul(L,pt)|0))<<13)|0;c=((o=o+Math.imul(L,yt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(z,lt),i=(i=Math.imul(z,ft))+Math.imul(D,lt)|0,o=Math.imul(D,ft);var Lt=(c+(n=n+Math.imul(U,pt)|0)|0)+((8191&(i=(i=i+Math.imul(U,yt)|0)+Math.imul(C,pt)|0))<<13)|0;c=((o=o+Math.imul(C,yt)|0)+(i>>>13)|0)+(Lt>>>26)|0,Lt&=67108863;var Ot=(c+(n=Math.imul(z,pt))|0)+((8191&(i=(i=Math.imul(z,yt))+Math.imul(D,pt)|0))<<13)|0;return c=((o=Math.imul(D,yt))+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,u[0]=gt,u[1]=mt,u[2]=wt,u[3]=bt,u[4]=vt,u[5]=_t,u[6]=kt,u[7]=Et,u[8]=xt,u[9]=St,u[10]=At,u[11]=It,u[12]=Bt,u[13]=Mt,u[14]=Rt,u[15]=Pt,u[16]=Tt,u[17]=Lt,u[18]=Ot,0!==c&&(u[19]=c,r.length++),r};function g(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,o=0;o<r.length-1;o++){var s=i;i=0;for(var a=67108863&n,u=Math.min(o,e.length-1),c=Math.max(0,o-t.length+1);c<=u;c++){var h=o-c,l=(0|t.words[h])*(0|e.words[c]),f=67108863&l;a=67108863&(f=f+a|0),i+=(s=(s=s+(l/67108864|0)|0)+(f>>>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(t,e,r){return g(t,e,r)}Math.imul||(y=p),i.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?y(this,t,e):r<63?p(this,t,e):r<1024?g(this,t,e):m(this,t,e)},i.prototype.mul=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},i.prototype.mulf=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),m(this,t,e)},i.prototype.imul=function(t){return this.clone().mulTo(t,this)},i.prototype.imuln=function(t){var e=t<0;e&&(t=-t),r("number"==typeof t),r(t<67108864);for(var n=0,i=0;i<this.length;i++){var o=(0|this.words[i])*t,s=(67108863&o)+(67108863&n);n>>=26,n+=o/67108864|0,n+=s>>>26,this.words[i]=67108863&s}return 0!==n&&(this.words[i]=n,this.length++),e?this.ineg():this},i.prototype.muln=function(t){return this.clone().imuln(t)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var n=r/26|0,i=r%26;e[r]=t.words[n]>>>i&1}return e}(t);if(0===e.length)return new i(1);for(var r=this,n=0;n<e.length&&0===e[n];n++,r=r.sqr());if(++n<e.length)for(var o=r.sqr();n<e.length;n++,o=o.sqr())0!==e[n]&&(r=r.mul(o));return r},i.prototype.iushln=function(t){r("number"==typeof t&&t>=0);var e,n=t%26,i=(t-n)/26,o=67108863>>>26-n<<26-n;if(0!==n){var s=0;for(e=0;e<this.length;e++){var a=this.words[e]&o,u=(0|this.words[e])-a<<n;this.words[e]=u|s,s=a>>>26-n}s&&(this.words[e]=s,this.length++)}if(0!==i){for(e=this.length-1;e>=0;e--)this.words[e+i]=this.words[e];for(e=0;e<i;e++)this.words[e]=0;this.length+=i}return this._strip()},i.prototype.ishln=function(t){return r(0===this.negative),this.iushln(t)},i.prototype.iushrn=function(t,e,n){var i;r("number"==typeof t&&t>=0),i=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<<o,u=n;if(i-=s,i=Math.max(0,i),u){for(var c=0;c<s;c++)u.words[c]=this.words[c];u.length=s}if(0===s);else if(this.length>s)for(this.length-=s,c=0;c<this.length;c++)this.words[c]=this.words[c+s];else this.words[0]=0,this.length=1;var h=0;for(c=this.length-1;c>=0&&(0!==h||c>=i);c--){var l=0|this.words[c];this.words[c]=h<<26-o|l>>>o,h=l&a}return u&&0!==h&&(u.words[u.length++]=h),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.ishrn=function(t,e,n){return r(0===this.negative),this.iushrn(t,e,n)},i.prototype.shln=function(t){return this.clone().ishln(t)},i.prototype.ushln=function(t){return this.clone().iushln(t)},i.prototype.shrn=function(t){return this.clone().ishrn(t)},i.prototype.ushrn=function(t){return this.clone().iushrn(t)},i.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26,i=1<<e;return!(this.length<=n||!(this.words[n]&i))},i.prototype.imaskn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==e&&n++,this.length=Math.min(n,this.length),0!==e){var i=67108863^67108863>>>e<<e;this.words[this.length-1]&=i}return this._strip()},i.prototype.maskn=function(t){return this.clone().imaskn(t)},i.prototype.iaddn=function(t){return r("number"==typeof t),r(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},i.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},i.prototype.isubn=function(t){if(r("number"==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this._strip()},i.prototype.addn=function(t){return this.clone().iaddn(t)},i.prototype.subn=function(t){return this.clone().isubn(t)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(t,e,n){var i,o,s=t.length+n;this._expand(s);var a=0;for(i=0;i<t.length;i++){o=(0|this.words[i+n])+a;var u=(0|t.words[i])*e;a=((o-=67108863&u)>>26)-(u/67108864|0),this.words[i+n]=67108863&o}for(;i<this.length-n;i++)a=(o=(0|this.words[i+n])+a)>>26,this.words[i+n]=67108863&o;if(0===a)return this._strip();for(r(-1===a),a=0,i=0;i<this.length;i++)a=(o=-(0|this.words[i])+a)>>26,this.words[i]=67108863&o;return this.negative=1,this._strip()},i.prototype._wordDiv=function(t,e){var r=(this.length,t.length),n=this.clone(),o=t,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,u=n.length-o.length;if("mod"!==e){(a=new i(null)).length=u+1,a.words=new Array(a.length);for(var c=0;c<a.length;c++)a.words[c]=0}var h=n.clone()._ishlnsubmul(o,1,u);0===h.negative&&(n=h,a&&(a.words[u]=1));for(var l=u-1;l>=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"!==e&&0!==r&&n.iushrn(r),{div:a||null,mod:n}},i.prototype.divmod=function(t,e,n){return r(!t.isZero()),this.isZero()?{div:new i(0),mod:new i(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(o=a.div.neg()),"div"!==e&&(s=a.mod.neg(),n&&0!==s.negative&&s.iadd(t)),{div:o,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(o=a.div.neg()),{div:o,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),n&&0!==s.negative&&s.isub(t)),{div:a.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new i(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new i(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new i(this.modrn(t.words[0]))}:this._wordDiv(t,e);var o,s,a},i.prototype.div=function(t){return this.divmod(t,"div",!1).div},i.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},i.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},i.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,n=t.ushrn(1),i=t.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},i.prototype.modrn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var n=(1<<26)%t,i=0,o=this.length-1;o>=0;o--)i=(n*i+(0|this.words[o]))%t;return e?-i:i},i.prototype.modn=function(t){return this.modrn(t)},i.prototype.idivn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var n=0,i=this.length-1;i>=0;i--){var o=(0|this.words[i])+67108864*n;this.words[i]=o/t|0,n=o%t}return this._strip(),e?this.ineg():this},i.prototype.divn=function(t){return this.clone().idivn(t)},i.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o=new i(1),s=new i(0),a=new i(0),u=new i(1),c=0;e.isEven()&&n.isEven();)e.iushrn(1),n.iushrn(1),++c;for(var h=n.clone(),l=e.clone();!e.isZero();){for(var f=0,d=1;0==(e.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(e.iushrn(f);f-- >0;)(o.isOdd()||s.isOdd())&&(o.iadd(h),s.isub(l)),o.iushrn(1),s.iushrn(1);for(var p=0,y=1;0==(n.words[0]&y)&&p<26;++p,y<<=1);if(p>0)for(n.iushrn(p);p-- >0;)(a.isOdd()||u.isOdd())&&(a.iadd(h),u.isub(l)),a.iushrn(1),u.iushrn(1);e.cmp(n)>=0?(e.isub(n),o.isub(a),s.isub(u)):(n.isub(e),a.isub(o),u.isub(s))}return{a:a,b:u,gcd:n.iushln(c)}},i.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o,s=new i(1),a=new i(0),u=n.clone();e.cmpn(1)>0&&n.cmpn(1)>0;){for(var c=0,h=1;0==(e.words[0]&h)&&c<26;++c,h<<=1);if(c>0)for(e.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);for(var l=0,f=1;0==(n.words[0]&f)&&l<26;++l,f<<=1);if(l>0)for(n.iushrn(l);l-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);e.cmp(n)>=0?(e.isub(n),s.isub(a)):(n.isub(e),a.isub(s))}return(o=0===e.cmpn(1)?s:a).cmpn(0)<0&&o.iadd(t),o},i.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var n=0;e.isEven()&&r.isEven();n++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=e.cmp(r);if(i<0){var o=e;e=r,r=o}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.iushln(n)},i.prototype.invm=function(t){return this.egcd(t).a.umod(t)},i.prototype.isEven=function(){return 0==(1&this.words[0])},i.prototype.isOdd=function(){return 1==(1&this.words[0])},i.prototype.andln=function(t){return this.words[0]&t},i.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,n=(t-e)/26,i=1<<e;if(this.length<=n)return this._expand(n+1),this.words[n]|=i,this;for(var o=i,s=n;0!==o&&s<this.length;s++){var a=0|this.words[s];o=(a+=o)>>>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(t){var e,n=t<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this._strip(),this.length>1)e=1;else{n&&(t=-t),r(t<=67108863,"Number is too big");var i=0|this.words[0];e=i===t?0:i<t?-1:1}return 0!==this.negative?0|-e:e},i.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},i.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){n<i?e=-1:n>i&&(e=1);break}}return e},i.prototype.gtn=function(t){return 1===this.cmpn(t)},i.prototype.gt=function(t){return 1===this.cmp(t)},i.prototype.gten=function(t){return this.cmpn(t)>=0},i.prototype.gte=function(t){return this.cmp(t)>=0},i.prototype.ltn=function(t){return-1===this.cmpn(t)},i.prototype.lt=function(t){return-1===this.cmp(t)},i.prototype.lten=function(t){return this.cmpn(t)<=0},i.prototype.lte=function(t){return this.cmp(t)<=0},i.prototype.eqn=function(t){return 0===this.cmpn(t)},i.prototype.eq=function(t){return 0===this.cmp(t)},i.red=function(t){return new x(t)},i.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(t){return this.red=t,this},i.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},i.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},i.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},i.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},i.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},i.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},i.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},i.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},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(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var w={k256:null,p224:null,p192:null,p25519:null};function b(t,e){this.name=t,this.p=new i(e,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 k(){b.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function E(){b.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function x(t){if("string"==typeof t){var e=i._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function S(t){x.call(this,t),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 t=new i(null);return t.words=new Array(Math.ceil(this.n/13)),t},b.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e<this.n?-1:r.ucmp(this.p);return 0===n?(r.words[0]=0,r.length=1):n>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},b.prototype.split=function(t,e){t.iushrn(this.n,0,e)},b.prototype.imulK=function(t){return t.imul(this.k)},n(v,b),v.prototype.split=function(t,e){for(var r=4194303,n=Math.min(t.length,9),i=0;i<n;i++)e.words[i]=t.words[i];if(e.length=n,t.length<=9)return t.words[0]=0,void(t.length=1);var o=t.words[9];for(e.words[e.length++]=o&r,i=10;i<t.length;i++){var s=0|t.words[i];t.words[i-10]=(s&r)<<4|o>>>22,o=s}o>>>=22,t.words[i-10]=o,0===o&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var n=0|t.words[r];e+=977*n,t.words[r]=67108863&e,e=64*n+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},n(_,b),n(k,b),n(E,b),E.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var n=19*(0|t.words[r])+e,i=67108863&n;n>>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},i._prime=function(t){if(w[t])return w[t];var e;if("k256"===t)e=new v;else if("p224"===t)e=new _;else if("p192"===t)e=new k;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new E}return w[t]=e,e},x.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},x.prototype._verify2=function(t,e){r(0==(t.negative|e.negative),"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},x.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(c(t,t.umod(this.m)._forceRed(this)),t)},x.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},x.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},x.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},x.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},x.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},x.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},x.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},x.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},x.prototype.isqr=function(t){return this.imul(t,t.clone())},x.prototype.sqr=function(t){return this.mul(t,t)},x.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var n=this.m.add(new i(1)).iushrn(2);return this.pow(t,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),u=a.redNeg(),c=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new i(2*h*h).toRed(this);0!==this.pow(h,c).cmp(u);)h.redIAdd(u);for(var l=this.pow(h,o),f=this.pow(t,o.addn(1).iushrn(1)),d=this.pow(t,o),p=s;0!==d.cmp(a);){for(var y=d,g=0;0!==y.cmp(a);g++)y=y.redSqr();r(g<p);var m=this.pow(l,new i(1).iushln(p-g-1));f=f.redMul(m),l=m.redSqr(),d=d.redMul(l),p=g}return f},x.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},x.prototype.pow=function(t,e){if(e.isZero())return new i(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new i(1).toRed(this),r[1]=t;for(var n=2;n<r.length;n++)r[n]=this.mul(r[n-1],t);var o=r[0],s=0,a=0,u=e.bitLength()%26;for(0===u&&(u=26),n=e.length-1;n>=0;n--){for(var c=e.words[n],h=u-1;h>=0;h--){var l=c>>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}u=26}return o},x.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},x.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},i.mont=function(t){return new S(t)},n(S,x),S.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},S.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},S.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),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)},S.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new i(0)._forceRed(this);var r=t.mul(e),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)},S.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(te,t);var re=te.exports,ne=e(re),ie={exports:{}};!function(t,e){var r=n,i=r.Buffer;function o(t,e){for(var r in t)e[r]=t[r]}function s(t,e,r){return i(t,e,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=r:(o(r,e),e.Buffer=s),s.prototype=Object.create(i.prototype),o(i,s),s.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return i(t,e,r)},s.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var n=i(t);return void 0!==e?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},s.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return i(t)},s.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return r.SlowBuffer(t)}}(ie,ie.exports);var oe=ie.exports.Buffer;var se=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r<e.length;r++)e[r]=255;for(var n=0;n<t.length;n++){var i=t.charAt(n),o=i.charCodeAt(0);if(255!==e[o])throw new TypeError(i+" is ambiguous");e[o]=n}var s=t.length,a=t.charAt(0),u=Math.log(s)/Math.log(256),c=Math.log(256)/Math.log(s);function h(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return oe.alloc(0);for(var r=0,n=0,i=0;t[r]===a;)n++,r++;for(var o=(t.length-r)*u+1>>>0,c=new Uint8Array(o);t[r];){var h=e[t.charCodeAt(r)];if(255===h)return;for(var l=0,f=o-1;(0!==h||l<i)&&-1!==f;f--,l++)h+=s*c[f]>>>0,c[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===c[d];)d++;var p=oe.allocUnsafe(n+(o-d));p.fill(0,0,n);for(var y=n;d!==o;)p[y++]=c[d++];return p}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=oe.from(e)),!oe.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,n=0,i=0,o=e.length;i!==o&&0===e[i];)i++,r++;for(var u=(o-i)*c+1>>>0,h=new Uint8Array(u);i!==o;){for(var l=e[i],f=0,d=u-1;(0!==l||f<n)&&-1!==d;d--,f++)l+=256*h[d]>>>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=u-n;p!==u&&0===h[p];)p++;for(var y=a.repeat(r);p<u;++p)y+=t.charAt(h[p]);return y},decodeUnsafe:h,decode:function(t){var e=h(t);if(e)return e;throw new Error("Non-base"+s+" character")}}},ae=e(se("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"));const ue=(t,e,r)=>t&e^~t&r,ce=(t,e,r)=>t&e^t&r^e&r,he=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]),le=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),fe=new Uint32Array(64);class de extends M{constructor(){super(64,32,8,!1),this.A=0|le[0],this.B=0|le[1],this.C=0|le[2],this.D=0|le[3],this.E=0|le[4],this.F=0|le[5],this.G=0|le[6],this.H=0|le[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:o,G:s,H:a}=this;return[t,e,r,n,i,o,s,a]}set(t,e,r,n,i,o,s,a){this.A=0|t,this.B=0|e,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(t,e){for(let r=0;r<16;r++,e+=4)fe[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=fe[t-15],r=fe[t-2],n=k(e,7)^k(e,18)^e>>>3,i=k(r,17)^k(r,19)^r>>>10;fe[t]=i+fe[t-7]+n+fe[t-16]|0}let{A:r,B:n,C:i,D:o,E:s,F:a,G:u,H:c}=this;for(let t=0;t<64;t++){const e=c+(k(s,6)^k(s,11)^k(s,25))+ue(s,a,u)+he[t]+fe[t]|0,h=(k(r,2)^k(r,13)^k(r,22))+ce(r,n,i)|0;c=u,u=a,a=s,s=o+e|0,o=i,i=n,n=r,r=e+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,u=u+this.G|0,c=c+this.H|0,this.set(r,n,i,o,s,a,u,c)}roundClean(){fe.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const pe=I((()=>new de));var ye={},ge=se("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");function me(t,e,r){return e<=t&&t<=r}function we(t){if(void 0===t)return{};if(t===Object(t))return t;throw TypeError("Could not convert argument to dictionary")}function be(t){this.tokens=[].slice.call(t)}be.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():-1},prepend:function(t){if(Array.isArray(t))for(var e=t;e.length;)this.tokens.unshift(e.pop());else this.tokens.unshift(t)},push:function(t){if(Array.isArray(t))for(var e=t;e.length;)this.tokens.push(e.shift());else this.tokens.push(t)}};var ve=-1;function _e(t,e){if(t)throw TypeError("Decoder error");return e||65533}var ke="utf-8";function Ee(t,e){if(!(this instanceof Ee))return new Ee(t,e);if((t=void 0!==t?String(t).toLowerCase():ke)!==ke)throw new Error("Encoding not supported. Only utf-8 is supported");e=we(e),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=Boolean(e.fatal),this._ignoreBOM=Boolean(e.ignoreBOM),Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}function xe(t,e){if(!(this instanceof xe))return new xe(t,e);if((t=void 0!==t?String(t).toLowerCase():ke)!==ke)throw new Error("Encoding not supported. Only utf-8 is supported");e=we(e),this._streaming=!1,this._encoder=null,this._options={fatal:Boolean(e.fatal)},Object.defineProperty(this,"encoding",{value:"utf-8"})}function Se(t){var e=t.fatal,r=0,n=0,i=0,o=128,s=191;this.handler=function(t,a){if(-1===a&&0!==i)return i=0,_e(e);if(-1===a)return ve;if(0===i){if(me(a,0,127))return a;if(me(a,194,223))i=1,r=a-192;else if(me(a,224,239))224===a&&(o=160),237===a&&(s=159),i=2,r=a-224;else{if(!me(a,240,244))return _e(e);240===a&&(o=144),244===a&&(s=143),i=3,r=a-240}return r<<=6*i,null}if(!me(a,o,s))return r=i=n=0,o=128,s=191,t.prepend(a),_e(e);if(o=128,s=191,r+=a-128<<6*(i-(n+=1)),n!==i)return null;var u=r;return r=i=n=0,u}}function Ae(t){t.fatal,this.handler=function(t,e){if(-1===e)return ve;if(me(e,0,127))return e;var r,n;me(e,128,2047)?(r=1,n=192):me(e,2048,65535)?(r=2,n=224):me(e,65536,1114111)&&(r=3,n=240);for(var i=[(e>>6*r)+n];r>0;){var o=e>>6*(r-1);i.push(128|63&o),r-=1}return i}}Ee.prototype={decode:function(t,e){var r;r="object"==typeof t&&t instanceof ArrayBuffer?new Uint8Array(t):"object"==typeof t&&"buffer"in t&&t.buffer instanceof ArrayBuffer?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(0),e=we(e),this._streaming||(this._decoder=new Se({fatal:this._fatal}),this._BOMseen=!1),this._streaming=Boolean(e.stream);for(var n,i=new be(r),o=[];!i.endOfStream()&&(n=this._decoder.handler(i,i.read()))!==ve;)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()))===ve)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(t){for(var e="",r=0;r<t.length;++r){var n=t[r];n<=65535?e+=String.fromCharCode(n):(n-=65536,e+=String.fromCharCode(55296+(n>>10),56320+(1023&n)))}return e}(o)}},xe.prototype={encode:function(t,e){t=t?String(t):"",e=we(e),this._streaming||(this._encoder=new Ae(this._options)),this._streaming=Boolean(e.stream);for(var r,n=[],i=new be(function(t){for(var e=String(t),r=e.length,n=0,i=[];n<r;){var o=e.charCodeAt(n);if(o<55296||o>57343)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=t.charCodeAt(n+1);if(56320<=s&&s<=57343){var a=1023&o,u=1023&s;i.push(65536+(a<<10)+u),n+=1}else i.push(65533)}n+=1}return i}(t));!i.endOfStream()&&(r=this._encoder.handler(i,i.read()))!==ve;)Array.isArray(r)?n.push.apply(n,r):n.push(r);if(!this._streaming){for(;(r=this._encoder.handler(i,i.read()))!==ve;)Array.isArray(r)?n.push.apply(n,r):n.push(r);this._encoder=null}return new Uint8Array(n)}};var Ie=r(Object.freeze({__proto__:null,TextEncoder:xe,TextDecoder:Ee})),Be=t&&t.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),Me=t&&t.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),Re=t&&t.__decorate||function(t,e,r,n){var i,o=arguments.length,s=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s},Pe=t&&t.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)"default"!==r&&Object.hasOwnProperty.call(t,r)&&Be(e,t,r);return Me(e,t),e},Te=t&&t.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(ye,"__esModule",{value:!0});var Le=ye.deserializeUnchecked=Ze=ye.deserialize=He=ye.serialize=ye.BinaryReader=ye.BinaryWriter=ye.BorshError=ye.baseDecode=ye.baseEncode=void 0;const Oe=Te(re),Ue=Te(ge),Ce=Pe(Ie),Ne=new("function"!=typeof TextDecoder?Ce.TextDecoder:TextDecoder)("utf-8",{fatal:!0});ye.baseEncode=function(t){return"string"==typeof t&&(t=Buffer.from(t,"utf8")),Ue.default.encode(Buffer.from(t))},ye.baseDecode=function(t){return Buffer.from(Ue.default.decode(t))};const ze=1024;class De extends Error{constructor(t){super(t),this.fieldPath=[],this.originalMessage=t}addToFieldPath(t){this.fieldPath.splice(0,0,t),this.message=this.originalMessage+": "+this.fieldPath.join(".")}}ye.BorshError=De;class je{constructor(){this.buf=Buffer.alloc(ze),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(ze)]))}writeU8(t){this.maybeResize(),this.buf.writeUInt8(t,this.length),this.length+=1}writeU16(t){this.maybeResize(),this.buf.writeUInt16LE(t,this.length),this.length+=2}writeU32(t){this.maybeResize(),this.buf.writeUInt32LE(t,this.length),this.length+=4}writeU64(t){this.maybeResize(),this.writeBuffer(Buffer.from(new Oe.default(t).toArray("le",8)))}writeU128(t){this.maybeResize(),this.writeBuffer(Buffer.from(new Oe.default(t).toArray("le",16)))}writeU256(t){this.maybeResize(),this.writeBuffer(Buffer.from(new Oe.default(t).toArray("le",32)))}writeU512(t){this.maybeResize(),this.writeBuffer(Buffer.from(new Oe.default(t).toArray("le",64)))}writeBuffer(t){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),t,Buffer.alloc(ze)]),this.length+=t.length}writeString(t){this.maybeResize();const e=Buffer.from(t,"utf8");this.writeU32(e.length),this.writeBuffer(e)}writeFixedArray(t){this.writeBuffer(Buffer.from(t))}writeArray(t,e){this.maybeResize(),this.writeU32(t.length);for(const r of t)this.maybeResize(),e(r)}toArray(){return this.buf.subarray(0,this.length)}}function We(t,e,r){const n=r.value;r.value=function(...t){try{return n.apply(this,t)}catch(t){if(t instanceof RangeError){const e=t.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(e)>=0)throw new De("Reached the end of buffer when deserializing")}throw t}}}ye.BinaryWriter=je;class Fe{constructor(t){this.buf=t,this.offset=0}readU8(){const t=this.buf.readUInt8(this.offset);return this.offset+=1,t}readU16(){const t=this.buf.readUInt16LE(this.offset);return this.offset+=2,t}readU32(){const t=this.buf.readUInt32LE(this.offset);return this.offset+=4,t}readU64(){const t=this.readBuffer(8);return new Oe.default(t,"le")}readU128(){const t=this.readBuffer(16);return new Oe.default(t,"le")}readU256(){const t=this.readBuffer(32);return new Oe.default(t,"le")}readU512(){const t=this.readBuffer(64);return new Oe.default(t,"le")}readBuffer(t){if(this.offset+t>this.buf.length)throw new De(`Expected buffer length ${t} isn't within bounds`);const e=this.buf.slice(this.offset,this.offset+t);return this.offset+=t,e}readString(){const t=this.readU32(),e=this.readBuffer(t);try{return Ne.decode(e)}catch(t){throw new De(`Error decoding UTF-8 string: ${t}`)}}readFixedArray(t){return new Uint8Array(this.readBuffer(t))}readArray(t){const e=this.readU32(),r=Array();for(let n=0;n<e;++n)r.push(t());return r}}function Ke(t){return t.charAt(0).toUpperCase()+t.slice(1)}function Ve(t,e,r,n,i){try{if("string"==typeof n)i[`write${Ke(n)}`](r);else if(n instanceof Array)if("number"==typeof n[0]){if(r.length!==n[0])throw new De(`Expecting byte array of length ${n[0]}, but got ${r.length} bytes`);i.writeFixedArray(r)}else if(2===n.length&&"number"==typeof n[1]){if(r.length!==n[1])throw new De(`Expecting byte array of length ${n[1]}, but got ${r.length} bytes`);for(let e=0;e<n[1];e++)Ve(t,null,r[e],n[0],i)}else i.writeArray(r,(r=>{Ve(t,e,r,n[0],i)}));else if(void 0!==n.kind)switch(n.kind){case"option":null==r?i.writeU8(0):(i.writeU8(1),Ve(t,e,r,n.type,i));break;case"map":i.writeU32(r.size),r.forEach(((r,o)=>{Ve(t,e,o,n.key,i),Ve(t,e,r,n.value,i)}));break;default:throw new De(`FieldType ${n} unrecognized`)}else qe(t,r,i)}catch(t){throw t instanceof De&&t.addToFieldPath(e),t}}function qe(t,e,r){if("function"==typeof e.borshSerialize)return void e.borshSerialize(r);const n=t.get(e.constructor);if(!n)throw new De(`Class ${e.constructor.name} is missing in schema`);if("struct"===n.kind)n.fields.map((([n,i])=>{Ve(t,n,e[n],i,r)}));else{if("enum"!==n.kind)throw new De(`Unexpected schema kind: ${n.kind} for ${e.constructor.name}`);{const i=e[n.field];for(let o=0;o<n.values.length;++o){const[s,a]=n.values[o];if(s===i){r.writeU8(o),Ve(t,s,e[s],a,r);break}}}}}Re([We],Fe.prototype,"readU8",null),Re([We],Fe.prototype,"readU16",null),Re([We],Fe.prototype,"readU32",null),Re([We],Fe.prototype,"readU64",null),Re([We],Fe.prototype,"readU128",null),Re([We],Fe.prototype,"readU256",null),Re([We],Fe.prototype,"readU512",null),Re([We],Fe.prototype,"readString",null),Re([We],Fe.prototype,"readFixedArray",null),Re([We],Fe.prototype,"readArray",null),ye.BinaryReader=Fe;var He=ye.serialize=function(t,e,r=je){const n=new r;return qe(t,e,n),n.toArray()};function $e(t,e,r,n){try{if("string"==typeof r)return n[`read${Ke(r)}`]();if(r instanceof Array){if("number"==typeof r[0])return n.readFixedArray(r[0]);if("number"==typeof r[1]){const e=[];for(let i=0;i<r[1];i++)e.push($e(t,null,r[0],n));return e}return n.readArray((()=>$e(t,e,r[0],n)))}if("option"===r.kind){return n.readU8()?$e(t,e,r.type,n):void 0}if("map"===r.kind){let i=new Map;const o=n.readU32();for(let s=0;s<o;s++){const o=$e(t,e,r.key,n),s=$e(t,e,r.value,n);i.set(o,s)}return i}return Ge(t,r,n)}catch(t){throw t instanceof De&&t.addToFieldPath(e),t}}function Ge(t,e,r){if("function"==typeof e.borshDeserialize)return e.borshDeserialize(r);const n=t.get(e);if(!n)throw new De(`Class ${e.name} is missing in schema`);if("struct"===n.kind){const n={};for(const[i,o]of t.get(e).fields)n[i]=$e(t,i,o,r);return new e(n)}if("enum"===n.kind){const i=r.readU8();if(i>=n.values.length)throw new De(`Enum index: ${i} is out of range`);const[o,s]=n.values[i];return new e({[o]:$e(t,o,s,r)})}throw new De(`Unexpected schema kind: ${n.kind} for ${e.constructor.name}`)}var Ze=ye.deserialize=function(t,e,r,n=Fe){const i=new n(r),o=Ge(t,e,i);if(i.offset<r.length)throw new De(`Unexpected ${r.length-i.offset} bytes after deserialized data`);return o};Le=ye.deserializeUnchecked=function(t,e,r,n=Fe){return Ge(t,e,new n(r))};var Ye={};Object.defineProperty(Ye,"__esModule",{value:!0}),Ye.s16=Ye.s8=Ye.nu64be=Ye.u48be=Ye.u40be=Ye.u32be=Ye.u24be=Ye.u16be=zr=Ye.nu64=Ye.u48=Ye.u40=Nr=Ye.u32=Ye.u24=Cr=Ye.u16=Ur=Ye.u8=Or=Ye.offset=Ye.greedy=Ye.Constant=Ye.UTF8=Ye.CString=Ye.Blob=Ye.Boolean=Ye.BitField=Ye.BitStructure=Ye.VariantLayout=Ye.Union=Ye.UnionLayoutDiscriminator=Ye.UnionDiscriminator=Ye.Structure=Ye.Sequence=Ye.DoubleBE=Ye.Double=Ye.FloatBE=Ye.Float=Ye.NearInt64BE=Ye.NearInt64=Ye.NearUInt64BE=Ye.NearUInt64=Ye.IntBE=Ye.Int=Ye.UIntBE=Ye.UInt=Ye.OffsetLayout=Ye.GreedyCount=Ye.ExternalLayout=Ye.bindConstructorLayout=Ye.nameWithProperty=Ye.Layout=Ye.uint8ArrayToBuffer=Ye.checkUint8Array=void 0,Ye.constant=Ye.utf8=Ye.cstr=Fr=Ye.blob=Ye.unionLayoutDiscriminator=Ye.union=Wr=Ye.seq=Ye.bits=jr=Ye.struct=Ye.f64be=Ye.f64=Ye.f32be=Ye.f32=Ye.ns64be=Ye.s48be=Ye.s40be=Ye.s32be=Ye.s24be=Ye.s16be=Dr=Ye.ns64=Ye.s48=Ye.s40=Ye.s32=Ye.s24=void 0;const Je=n;function Xe(t){if(!(t instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}function Qe(t){return Xe(t),Je.Buffer.from(t.buffer,t.byteOffset,t.length)}Ye.checkUint8Array=Xe,Ye.uint8ArrayToBuffer=Qe;class tr{constructor(t,e){if(!Number.isInteger(t))throw new TypeError("span must be an integer");this.span=t,this.property=e}makeDestinationObject(){return{}}getSpan(t,e){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(t){const e=Object.create(this.constructor.prototype);return Object.assign(e,this),e.property=t,e}fromArray(t){}}function er(t,e){return e.property?t+"["+e.property+"]":t}Ye.Layout=tr,Ye.nameWithProperty=er,Ye.bindConstructorLayout=function(t,e){if("function"!=typeof t)throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(t,"layout_"))throw new Error("Class is already bound to a layout");if(!(e&&e instanceof tr))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(e,"boundConstructor_"))throw new Error("layout is already bound to a constructor");t.layout_=e,e.boundConstructor_=t,e.makeDestinationObject=()=>new t,Object.defineProperty(t.prototype,"encode",{value(t,r){return e.encode(this,t,r)},writable:!0}),Object.defineProperty(t,"decode",{value:(t,r)=>e.decode(t,r),writable:!0})};class rr extends tr{isCount(){throw new Error("ExternalLayout is abstract")}}Ye.ExternalLayout=rr;class nr extends rr{constructor(t=1,e){if(!Number.isInteger(t)||0>=t)throw new TypeError("elementSpan must be a (positive) integer");super(-1,e),this.elementSpan=t}isCount(){return!0}decode(t,e=0){Xe(t);const r=t.length-e;return Math.floor(r/this.elementSpan)}encode(t,e,r){return 0}}Ye.GreedyCount=nr;class ir extends rr{constructor(t,e=0,r){if(!(t instanceof tr))throw new TypeError("layout must be a Layout");if(!Number.isInteger(e))throw new TypeError("offset must be integer or undefined");super(t.span,r||t.property),this.layout=t,this.offset=e}isCount(){return this.layout instanceof or||this.layout instanceof sr}decode(t,e=0){return this.layout.decode(t,e+this.offset)}encode(t,e,r=0){return this.layout.encode(t,e,r+this.offset)}}Ye.OffsetLayout=ir;class or extends tr{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return Qe(t).readUIntLE(e,this.span)}encode(t,e,r=0){return Qe(e).writeUIntLE(t,r,this.span),this.span}}Ye.UInt=or;class sr extends tr{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return Qe(t).readUIntBE(e,this.span)}encode(t,e,r=0){return Qe(e).writeUIntBE(t,r,this.span),this.span}}Ye.UIntBE=sr;class ar extends tr{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return Qe(t).readIntLE(e,this.span)}encode(t,e,r=0){return Qe(e).writeIntLE(t,r,this.span),this.span}}Ye.Int=ar;class ur extends tr{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return Qe(t).readIntBE(e,this.span)}encode(t,e,r=0){return Qe(e).writeIntBE(t,r,this.span),this.span}}Ye.IntBE=ur;const cr=Math.pow(2,32);function hr(t){const e=Math.floor(t/cr);return{hi32:e,lo32:t-e*cr}}function lr(t,e){return t*cr+e}class fr extends tr{constructor(t){super(8,t)}decode(t,e=0){const r=Qe(t),n=r.readUInt32LE(e);return lr(r.readUInt32LE(e+4),n)}encode(t,e,r=0){const n=hr(t),i=Qe(e);return i.writeUInt32LE(n.lo32,r),i.writeUInt32LE(n.hi32,r+4),8}}Ye.NearUInt64=fr;class dr extends tr{constructor(t){super(8,t)}decode(t,e=0){const r=Qe(t);return lr(r.readUInt32BE(e),r.readUInt32BE(e+4))}encode(t,e,r=0){const n=hr(t),i=Qe(e);return i.writeUInt32BE(n.hi32,r),i.writeUInt32BE(n.lo32,r+4),8}}Ye.NearUInt64BE=dr;class pr extends tr{constructor(t){super(8,t)}decode(t,e=0){const r=Qe(t),n=r.readUInt32LE(e);return lr(r.readInt32LE(e+4),n)}encode(t,e,r=0){const n=hr(t),i=Qe(e);return i.writeUInt32LE(n.lo32,r),i.writeInt32LE(n.hi32,r+4),8}}Ye.NearInt64=pr;class yr extends tr{constructor(t){super(8,t)}decode(t,e=0){const r=Qe(t);return lr(r.readInt32BE(e),r.readUInt32BE(e+4))}encode(t,e,r=0){const n=hr(t),i=Qe(e);return i.writeInt32BE(n.hi32,r),i.writeUInt32BE(n.lo32,r+4),8}}Ye.NearInt64BE=yr;class gr extends tr{constructor(t){super(4,t)}decode(t,e=0){return Qe(t).readFloatLE(e)}encode(t,e,r=0){return Qe(e).writeFloatLE(t,r),4}}Ye.Float=gr;class mr extends tr{constructor(t){super(4,t)}decode(t,e=0){return Qe(t).readFloatBE(e)}encode(t,e,r=0){return Qe(e).writeFloatBE(t,r),4}}Ye.FloatBE=mr;class wr extends tr{constructor(t){super(8,t)}decode(t,e=0){return Qe(t).readDoubleLE(e)}encode(t,e,r=0){return Qe(e).writeDoubleLE(t,r),8}}Ye.Double=wr;class br extends tr{constructor(t){super(8,t)}decode(t,e=0){return Qe(t).readDoubleBE(e)}encode(t,e,r=0){return Qe(e).writeDoubleBE(t,r),8}}Ye.DoubleBE=br;class vr extends tr{constructor(t,e,r){if(!(t instanceof tr))throw new TypeError("elementLayout must be a Layout");if(!(e instanceof rr&&e.isCount()||Number.isInteger(e)&&0<=e))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let n=-1;!(e instanceof rr)&&0<t.span&&(n=e*t.span),super(n,r),this.elementLayout=t,this.count=e}getSpan(t,e=0){if(0<=this.span)return this.span;let r=0,n=this.count;if(n instanceof rr&&(n=n.decode(t,e)),0<this.elementLayout.span)r=n*this.elementLayout.span;else{let i=0;for(;i<n;)r+=this.elementLayout.getSpan(t,e+r),++i}return r}decode(t,e=0){const r=[];let n=0,i=this.count;for(i instanceof rr&&(i=i.decode(t,e));n<i;)r.push(this.elementLayout.decode(t,e)),e+=this.elementLayout.getSpan(t,e),n+=1;return r}encode(t,e,r=0){const n=this.elementLayout,i=t.reduce(((t,i)=>t+n.encode(i,e,r+t)),0);return this.count instanceof rr&&this.count.encode(t.length,e,r),i}}Ye.Sequence=vr;class _r extends tr{constructor(t,e,r){if(!Array.isArray(t)||!t.reduce(((t,e)=>t&&e instanceof tr),!0))throw new TypeError("fields must be array of Layout instances");"boolean"==typeof e&&void 0===r&&(r=e,e=void 0);for(const e of t)if(0>e.span&&void 0===e.property)throw new Error("fields cannot contain unnamed variable-length layout");let n=-1;try{n=t.reduce(((t,e)=>t+e.getSpan()),0)}catch(t){}super(n,e),this.fields=t,this.decodePrefixes=!!r}getSpan(t,e=0){if(0<=this.span)return this.span;let r=0;try{r=this.fields.reduce(((r,n)=>{const i=n.getSpan(t,e);return e+=i,r+i}),0)}catch(t){throw new RangeError("indeterminate span")}return r}decode(t,e=0){Xe(t);const r=this.makeDestinationObject();for(const n of this.fields)if(void 0!==n.property&&(r[n.property]=n.decode(t,e)),e+=n.getSpan(t,e),this.decodePrefixes&&t.length===e)break;return r}encode(t,e,r=0){const n=r;let i=0,o=0;for(const n of this.fields){let s=n.span;if(o=0<s?s:0,void 0!==n.property){const i=t[n.property];void 0!==i&&(o=n.encode(i,e,r),0>s&&(s=n.getSpan(e,r)))}i=r,r+=s}return i+o-n}fromArray(t){const e=this.makeDestinationObject();for(const r of this.fields)void 0!==r.property&&0<t.length&&(e[r.property]=t.shift());return e}layoutFor(t){if("string"!=typeof t)throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}offsetOf(t){if("string"!=typeof t)throw new TypeError("property must be string");let e=0;for(const r of this.fields){if(r.property===t)return e;0>r.span?e=-1:0<=e&&(e+=r.span)}}}Ye.Structure=_r;class kr{constructor(t){this.property=t}decode(t,e){throw new Error("UnionDiscriminator is abstract")}encode(t,e,r){throw new Error("UnionDiscriminator is abstract")}}Ye.UnionDiscriminator=kr;class Er extends kr{constructor(t,e){if(!(t instanceof rr&&t.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(e||t.property||"variant"),this.layout=t}decode(t,e){return this.layout.decode(t,e)}encode(t,e,r){return this.layout.encode(t,e,r)}}Ye.UnionLayoutDiscriminator=Er;class xr extends tr{constructor(t,e,r){let n;if(t instanceof or||t instanceof sr)n=new Er(new ir(t));else if(t instanceof rr&&t.isCount())n=new Er(t);else{if(!(t instanceof kr))throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");n=t}if(void 0===e&&(e=null),!(null===e||e instanceof tr))throw new TypeError("defaultLayout must be null or a Layout");if(null!==e){if(0>e.span)throw new Error("defaultLayout must have constant span");void 0===e.property&&(e=e.replicate("content"))}let i=-1;e&&(i=e.span,0<=i&&(t instanceof or||t instanceof sr)&&(i+=n.layout.span)),super(i,r),this.discriminator=n,this.usesPrefixDiscriminator=t instanceof or||t instanceof sr,this.defaultLayout=e,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(t){return o(t)},this.configGetSourceVariant=function(t){o=t.bind(this)}}getSpan(t,e=0){if(0<=this.span)return this.span;const r=this.getVariant(t,e);if(!r)throw new Error("unable to determine span for unrecognized variant");return r.getSpan(t,e)}defaultGetSourceVariant(t){if(Object.prototype.hasOwnProperty.call(t,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(t,this.defaultLayout.property))return;const e=this.registry[t[this.discriminator.property]];if(e&&(!e.layout||e.property&&Object.prototype.hasOwnProperty.call(t,e.property)))return e}else for(const e in this.registry){const r=this.registry[e];if(r.property&&Object.prototype.hasOwnProperty.call(t,r.property))return r}throw new Error("unable to infer src variant")}decode(t,e=0){let r;const n=this.discriminator,i=n.decode(t,e),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(t,e+s)}else r=o.decode(t,e);return r}encode(t,e,r=0){const n=this.getSourceVariant(t);if(void 0===n){const n=this.discriminator,i=this.defaultLayout;let o=0;return this.usesPrefixDiscriminator&&(o=n.layout.span),n.encode(t[n.property],e,r),o+i.encode(t[i.property],e,r+o)}return n.encode(t,e,r)}addVariant(t,e,r){const n=new Sr(this,t,e,r);return this.registry[t]=n,n}getVariant(t,e=0){let r;return r=t instanceof Uint8Array?this.discriminator.decode(t,e):t,this.registry[r]}}Ye.Union=xr;class Sr extends tr{constructor(t,e,r,n){if(!(t instanceof xr))throw new TypeError("union must be a Union");if(!Number.isInteger(e)||0>e)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 tr))throw new TypeError("layout must be a Layout");if(null!==t.defaultLayout&&0<=r.span&&r.span>t.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=t.span;0>t.span&&(i=r?r.span:0,0<=i&&t.usesPrefixDiscriminator&&(i+=t.discriminator.layout.span)),super(i,n),this.union=t,this.variant=e,this.layout=r||null}getSpan(t,e=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(t,e+r)),r+n}decode(t,e=0){const r=this.makeDestinationObject();if(this!==this.union.getVariant(t,e))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(t,e+n):this.property?r[this.property]=!0:this.union.usesPrefixDiscriminator&&(r[this.union.discriminator.property]=this.variant),r}encode(t,e,r=0){let n=0;if(this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(t,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,e,r);let i=n;if(this.layout&&(this.layout.encode(t[this.property],e,r+n),i+=this.layout.getSpan(e,r+n),0<=this.union.span&&i>this.union.span))throw new Error("encoded variant overruns containing union");return i}fromArray(t){if(this.layout)return this.layout.fromArray(t)}}function Ar(t){return 0>t&&(t+=4294967296),t}Ye.VariantLayout=Sr;class Ir extends tr{constructor(t,e,r){if(!(t instanceof or||t instanceof sr))throw new TypeError("word must be a UInt or UIntBE layout");if("string"==typeof e&&void 0===r&&(r=e,e=!1),4<t.span)throw new RangeError("word cannot exceed 32 bits");super(t.span,r),this.word=t,this.msb=!!e,this.fields=[];let n=0;this._packedSetValue=function(t){return n=Ar(t),this},this._packedGetValue=function(){return n}}decode(t,e=0){const r=this.makeDestinationObject(),n=this.word.decode(t,e);this._packedSetValue(n);for(const e of this.fields)void 0!==e.property&&(r[e.property]=e.decode(t));return r}encode(t,e,r=0){const n=this.word.decode(e,r);this._packedSetValue(n);for(const e of this.fields)if(void 0!==e.property){const r=t[e.property];void 0!==r&&e.encode(r)}return this.word.encode(this._packedGetValue(),e,r)}addField(t,e){const r=new Br(this,t,e);return this.fields.push(r),r}addBoolean(t){const e=new Mr(this,t);return this.fields.push(e),e}fieldFor(t){if("string"!=typeof t)throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}}Ye.BitStructure=Ir;class Br{constructor(t,e,r){if(!(t instanceof Ir))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(e)||0>=e)throw new TypeError("bits must be positive integer");const n=8*t.span,i=t.fields.reduce(((t,e)=>t+e.bits),0);if(e+i>n)throw new Error("bits too long for span remainder ("+(n-i)+" of "+n+" remain)");this.container=t,this.bits=e,this.valueMask=(1<<e)-1,32===e&&(this.valueMask=4294967295),this.start=i,this.container.msb&&(this.start=n-i-e),this.wordMask=Ar(this.valueMask<<this.start),this.property=r}decode(t,e){return Ar(this.container._packedGetValue()&this.wordMask)>>>this.start}encode(t){if("number"!=typeof t||!Number.isInteger(t)||t!==Ar(t&this.valueMask))throw new TypeError(er("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const e=this.container._packedGetValue(),r=Ar(t<<this.start);this.container._packedSetValue(Ar(e&~this.wordMask)|r)}}Ye.BitField=Br;class Mr extends Br{constructor(t,e){super(t,1,e)}decode(t,e){return!!super.decode(t,e)}encode(t){"boolean"==typeof t&&(t=+t),super.encode(t)}}Ye.Boolean=Mr;class Rr extends tr{constructor(t,e){if(!(t instanceof rr&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let r=-1;t instanceof rr||(r=t),super(r,e),this.length=t}getSpan(t,e){let r=this.span;return 0>r&&(r=this.length.decode(t,e)),r}decode(t,e=0){let r=this.span;return 0>r&&(r=this.length.decode(t,e)),Qe(t).slice(e,e+r)}encode(t,e,r){let n=this.length;if(this.length instanceof rr&&(n=t.length),!(t instanceof Uint8Array&&n===t.length))throw new TypeError(er("Blob.encode",this)+" requires (length "+n+") Uint8Array as src");if(r+n>e.length)throw new RangeError("encoding overruns Uint8Array");const i=Qe(t);return Qe(e).write(i.toString("hex"),r,n,"hex"),this.length instanceof rr&&this.length.encode(n,e,r),n}}Ye.Blob=Rr;class Pr extends tr{constructor(t){super(-1,t)}getSpan(t,e=0){Xe(t);let r=e;for(;r<t.length&&0!==t[r];)r+=1;return 1+r-e}decode(t,e=0){const r=this.getSpan(t,e);return Qe(t).slice(e,e+r-1).toString("utf-8")}encode(t,e,r=0){"string"!=typeof t&&(t=String(t));const n=Je.Buffer.from(t,"utf8"),i=n.length;if(r+i>e.length)throw new RangeError("encoding overruns Buffer");const o=Qe(e);return n.copy(o,r),o[r+i]=0,i+1}}Ye.CString=Pr;class Tr extends tr{constructor(t,e){if("string"==typeof t&&void 0===e&&(e=t,t=void 0),void 0===t)t=-1;else if(!Number.isInteger(t))throw new TypeError("maxSpan must be an integer");super(-1,e),this.maxSpan=t}getSpan(t,e=0){return Xe(t),t.length-e}decode(t,e=0){const r=this.getSpan(t,e);if(0<=this.maxSpan&&this.maxSpan<r)throw new RangeError("text length exceeds maxSpan");return Qe(t).slice(e,e+r).toString("utf-8")}encode(t,e,r=0){"string"!=typeof t&&(t=String(t));const n=Je.Buffer.from(t,"utf8"),i=n.length;if(0<=this.maxSpan&&this.maxSpan<i)throw new RangeError("text length exceeds maxSpan");if(r+i>e.length)throw new RangeError("encoding overruns Buffer");return n.copy(Qe(e),r),i}}Ye.UTF8=Tr;class Lr extends tr{constructor(t,e){super(0,e),this.value=t}decode(t,e){return this.value}encode(t,e,r){return 0}}Ye.Constant=Lr,Ye.greedy=(t,e)=>new nr(t,e);var Or=Ye.offset=(t,e,r)=>new ir(t,e,r),Ur=Ye.u8=t=>new or(1,t),Cr=Ye.u16=t=>new or(2,t);Ye.u24=t=>new or(3,t);var Nr=Ye.u32=t=>new or(4,t);Ye.u40=t=>new or(5,t),Ye.u48=t=>new or(6,t);var zr=Ye.nu64=t=>new fr(t);Ye.u16be=t=>new sr(2,t),Ye.u24be=t=>new sr(3,t),Ye.u32be=t=>new sr(4,t),Ye.u40be=t=>new sr(5,t),Ye.u48be=t=>new sr(6,t),Ye.nu64be=t=>new dr(t),Ye.s8=t=>new ar(1,t),Ye.s16=t=>new ar(2,t),Ye.s24=t=>new ar(3,t),Ye.s32=t=>new ar(4,t),Ye.s40=t=>new ar(5,t),Ye.s48=t=>new ar(6,t);var Dr=Ye.ns64=t=>new pr(t);Ye.s16be=t=>new ur(2,t),Ye.s24be=t=>new ur(3,t),Ye.s32be=t=>new ur(4,t),Ye.s40be=t=>new ur(5,t),Ye.s48be=t=>new ur(6,t),Ye.ns64be=t=>new yr(t),Ye.f32=t=>new gr(t),Ye.f32be=t=>new mr(t),Ye.f64=t=>new wr(t),Ye.f64be=t=>new br(t);var jr=Ye.struct=(t,e,r)=>new _r(t,e,r);Ye.bits=(t,e,r)=>new Ir(t,e,r);var Wr=Ye.seq=(t,e,r)=>new vr(t,e,r);Ye.union=(t,e,r)=>new xr(t,e,r),Ye.unionLayoutDiscriminator=(t,e)=>new Er(t,e);var Fr=Ye.blob=(t,e)=>new Rr(t,e);Ye.cstr=t=>new Pr(t),Ye.utf8=(t,e)=>new Tr(t,e),Ye.constant=(t,e)=>new Lr(t,e);var Kr={};Object.defineProperty(Kr,"__esModule",{value:!0});var Vr=Kr.toBigIntLE=function(t){{const e=Buffer.from(t);e.reverse();const r=e.toString("hex");return 0===r.length?BigInt(0):BigInt(`0x${r}`)}};Kr.toBigIntBE=function(t){{const e=t.toString("hex");return 0===e.length?BigInt(0):BigInt(`0x${e}`)}};var qr,Hr=Kr.toBufferLE=function(t,e){{const r=t.toString(16),n=Buffer.from(r.padStart(2*e,"0").slice(0,2*e),"hex");return n.reverse(),n}};Kr.toBufferBE=function(t,e){{const r=t.toString(16);return Buffer.from(r.padStart(2*e,"0").slice(0,2*e),"hex")}};class $r extends TypeError{constructor(t,e){let r;const{message:n,...i}=t,{path:o}=t;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=[t,...e()]}}}function Gr(t){return"object"==typeof t&&null!=t}function Zr(t){return"string"==typeof t?JSON.stringify(t):""+t}function Yr(t,e,r,n){if(!0===t)return;!1===t?t={}:"string"==typeof t&&(t={message:t});const{path:i,branch:o}=e,{type:s}=r,{refinement:a,message:u="Expected a value of type `"+s+"`"+(a?" with refinement `"+a+"`":"")+", but received: `"+Zr(n)+"`"}=t;return{value:n,type:s,refinement:a,key:i[i.length-1],path:i,branch:o,...t,message:u}}function*Jr(t,e,r,n){(function(t){return Gr(t)&&"function"==typeof t[Symbol.iterator]})(t)||(t=[t]);for(const i of t){const t=Yr(i,e,r,n);t&&(yield t)}}function*Xr(t,e,r={}){const{path:n=[],branch:i=[t],coerce:o=!1,mask:s=!1}=r,a={path:n,branch:i};if(o&&(t=e.coercer(t,a),s&&"type"!==e.type&&Gr(e.schema)&&Gr(t)&&!Array.isArray(t)))for(const r in t)void 0===e.schema[r]&&delete t[r];let u=!0;for(const r of e.validator(t,a))u=!1,yield[r,void 0];for(let[r,c,h]of e.entries(t,a)){const e=Xr(c,h,{path:void 0===r?n:[...n,r],branch:void 0===r?i:[...i,c],coerce:o,mask:s});for(const n of e)n[0]?(u=!1,yield[n[0],void 0]):o&&(c=n[1],void 0===r?t=c:t instanceof Map?t.set(r,c):t instanceof Set?t.add(c):Gr(t)&&(t[r]=c))}if(u)for(const r of e.refiner(t,a))u=!1,yield[r,void 0];u&&(yield[void 0,t])}class Qr{constructor(t){const{type:e,schema:r,validator:n,refiner:i,coercer:o=(t=>t),entries:s=function*(){}}=t;this.type=e,this.schema=r,this.entries=s,this.coercer=o,this.validator=n?(t,e)=>Jr(n(t,e),e,this,t):()=>[],this.refiner=i?(t,e)=>Jr(i(t,e),e,this,t):()=>[]}assert(t){return tn(t,this)}create(t){return en(t,this)}is(t){return rn(t,this)}mask(t){return function(t,e){const r=nn(t,e,{coerce:!0,mask:!0});if(r[0])throw r[0];return r[1]}(t,this)}validate(t,e={}){return nn(t,this,e)}}function tn(t,e){const r=nn(t,e);if(r[0])throw r[0]}function en(t,e){const r=nn(t,e,{coerce:!0});if(r[0])throw r[0];return r[1]}function rn(t,e){return!nn(t,e)[0]}function nn(t,e,r={}){const n=Xr(t,e,r),i=function(t){const{done:e,value:r}=t.next();return e?void 0:r}(n);if(i[0]){const t=new $r(i[0],(function*(){for(const t of n)t[0]&&(yield t[0])}));return[t,void 0]}return[void 0,i[1]]}function on(t,e){return new Qr({type:t,schema:null,validator:e})}function sn(t){return new Qr({type:"array",schema:t,*entries(e){if(t&&Array.isArray(e))for(const[r,n]of e.entries())yield[r,n,t]},coercer:t=>Array.isArray(t)?t.slice():t,validator:t=>Array.isArray(t)||"Expected an array value, but received: "+Zr(t)})}function an(){return on("boolean",(t=>"boolean"==typeof t))}function un(t){return on("instance",(e=>e instanceof t||"Expected a `"+t.name+"` instance, but received: "+Zr(e)))}function cn(t){const e=Zr(t),r=typeof t;return new Qr({type:"literal",schema:"string"===r||"number"===r||"boolean"===r?t:null,validator:r=>r===t||"Expected the literal `"+e+"`, but received: "+Zr(r)})}function hn(t){return new Qr({...t,validator:(e,r)=>null===e||t.validator(e,r),refiner:(e,r)=>null===e||t.refiner(e,r)})}function ln(){return on("number",(t=>"number"==typeof t&&!isNaN(t)||"Expected a number, but received: "+Zr(t)))}function fn(t){return new Qr({...t,validator:(e,r)=>void 0===e||t.validator(e,r),refiner:(e,r)=>void 0===e||t.refiner(e,r)})}function dn(t,e){return new Qr({type:"record",schema:null,*entries(r){if(Gr(r))for(const n in r){const i=r[n];yield[n,n,t],yield[n,i,e]}},validator:t=>Gr(t)||"Expected an object, but received: "+Zr(t)})}function pn(){return on("string",(t=>"string"==typeof t||"Expected a string, but received: "+Zr(t)))}function yn(t){const e=on("never",(()=>!1));return new Qr({type:"tuple",schema:null,*entries(r){if(Array.isArray(r)){const n=Math.max(t.length,r.length);for(let i=0;i<n;i++)yield[i,r[i],t[i]||e]}},validator:t=>Array.isArray(t)||"Expected an array, but received: "+Zr(t)})}function gn(t){const e=Object.keys(t);return new Qr({type:"type",schema:t,*entries(r){if(Gr(r))for(const n of e)yield[n,r[n],t[n]]},validator:t=>Gr(t)||"Expected an object, but received: "+Zr(t)})}function mn(t){const e=t.map((t=>t.type)).join(" | ");return new Qr({type:"union",schema:null,validator(r,n){const i=[];for(const e of t){const[...t]=Xr(r,e,n),[o]=t;if(!o[0])return[];for(const[e]of t)e&&i.push(e)}return["Expected the value to satisfy a union of `"+e+"`, but received: "+Zr(r),...i]}})}function wn(){return on("unknown",(()=>!0))}function bn(t,e,r){return new Qr({...t,coercer:(n,i)=>rn(n,e)?t.coercer(r(n,i),i):t.coercer(n,i)})}var vn=new Uint8Array(16);function _n(){if(!qr&&!(qr="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 qr(vn)}var kn=/^(?:[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 En(t){return"string"==typeof t&&kn.test(t)}for(var xn,Sn,An=[],In=0;In<256;++In)An.push((In+256).toString(16).substr(1));function Bn(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(An[t[e+0]]+An[t[e+1]]+An[t[e+2]]+An[t[e+3]]+"-"+An[t[e+4]]+An[t[e+5]]+"-"+An[t[e+6]]+An[t[e+7]]+"-"+An[t[e+8]]+An[t[e+9]]+"-"+An[t[e+10]]+An[t[e+11]]+An[t[e+12]]+An[t[e+13]]+An[t[e+14]]+An[t[e+15]]).toLowerCase();if(!En(r))throw TypeError("Stringified UUID is invalid");return r}var Mn=0,Rn=0;function Pn(t){if(!En(t))throw TypeError("Invalid UUID");var e,r=new Uint8Array(16);return r[0]=(e=parseInt(t.slice(0,8),16))>>>24,r[1]=e>>>16&255,r[2]=e>>>8&255,r[3]=255&e,r[4]=(e=parseInt(t.slice(9,13),16))>>>8,r[5]=255&e,r[6]=(e=parseInt(t.slice(14,18),16))>>>8,r[7]=255&e,r[8]=(e=parseInt(t.slice(19,23),16))>>>8,r[9]=255&e,r[10]=(e=parseInt(t.slice(24,36),16))/1099511627776&255,r[11]=e/4294967296&255,r[12]=e>>>24&255,r[13]=e>>>16&255,r[14]=e>>>8&255,r[15]=255&e,r}function Tn(t,e,r){function n(t,n,i,o){if("string"==typeof t&&(t=function(t){t=unescape(encodeURIComponent(t));for(var e=[],r=0;r<t.length;++r)e.push(t.charCodeAt(r));return e}(t)),"string"==typeof n&&(n=Pn(n)),16!==n.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var s=new Uint8Array(16+t.length);if(s.set(n),s.set(t,n.length),(s=r(s))[6]=15&s[6]|e,s[8]=63&s[8]|128,i){o=o||0;for(var a=0;a<16;++a)i[o+a]=s[a];return i}return Bn(s)}try{n.name=t}catch(t){}return n.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",n.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",n}function Ln(t){return 14+(t+64>>>9<<4)+1}function On(t,e){var r=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(r>>16)<<16|65535&r}function Un(t,e,r,n,i,o){return On((s=On(On(e,t),On(n,o)))<<(a=i)|s>>>32-a,r);var s,a}function Cn(t,e,r,n,i,o,s){return Un(e&r|~e&n,t,e,i,o,s)}function Nn(t,e,r,n,i,o,s){return Un(e&n|r&~n,t,e,i,o,s)}function zn(t,e,r,n,i,o,s){return Un(e^r^n,t,e,i,o,s)}function Dn(t,e,r,n,i,o,s){return Un(r^(e|~n),t,e,i,o,s)}var jn=Tn("v3",48,(function(t){if("string"==typeof t){var e=unescape(encodeURIComponent(t));t=new Uint8Array(e.length);for(var r=0;r<e.length;++r)t[r]=e.charCodeAt(r)}return function(t){for(var e=[],r=32*t.length,n="0123456789abcdef",i=0;i<r;i+=8){var o=t[i>>5]>>>i%32&255,s=parseInt(n.charAt(o>>>4&15)+n.charAt(15&o),16);e.push(s)}return e}(function(t,e){t[e>>5]|=128<<e%32,t[Ln(e)-1]=e;for(var r=1732584193,n=-271733879,i=-1732584194,o=271733878,s=0;s<t.length;s+=16){var a=r,u=n,c=i,h=o;r=Cn(r,n,i,o,t[s],7,-680876936),o=Cn(o,r,n,i,t[s+1],12,-389564586),i=Cn(i,o,r,n,t[s+2],17,606105819),n=Cn(n,i,o,r,t[s+3],22,-1044525330),r=Cn(r,n,i,o,t[s+4],7,-176418897),o=Cn(o,r,n,i,t[s+5],12,1200080426),i=Cn(i,o,r,n,t[s+6],17,-1473231341),n=Cn(n,i,o,r,t[s+7],22,-45705983),r=Cn(r,n,i,o,t[s+8],7,1770035416),o=Cn(o,r,n,i,t[s+9],12,-1958414417),i=Cn(i,o,r,n,t[s+10],17,-42063),n=Cn(n,i,o,r,t[s+11],22,-1990404162),r=Cn(r,n,i,o,t[s+12],7,1804603682),o=Cn(o,r,n,i,t[s+13],12,-40341101),i=Cn(i,o,r,n,t[s+14],17,-1502002290),r=Nn(r,n=Cn(n,i,o,r,t[s+15],22,1236535329),i,o,t[s+1],5,-165796510),o=Nn(o,r,n,i,t[s+6],9,-1069501632),i=Nn(i,o,r,n,t[s+11],14,643717713),n=Nn(n,i,o,r,t[s],20,-373897302),r=Nn(r,n,i,o,t[s+5],5,-701558691),o=Nn(o,r,n,i,t[s+10],9,38016083),i=Nn(i,o,r,n,t[s+15],14,-660478335),n=Nn(n,i,o,r,t[s+4],20,-405537848),r=Nn(r,n,i,o,t[s+9],5,568446438),o=Nn(o,r,n,i,t[s+14],9,-1019803690),i=Nn(i,o,r,n,t[s+3],14,-187363961),n=Nn(n,i,o,r,t[s+8],20,1163531501),r=Nn(r,n,i,o,t[s+13],5,-1444681467),o=Nn(o,r,n,i,t[s+2],9,-51403784),i=Nn(i,o,r,n,t[s+7],14,1735328473),r=zn(r,n=Nn(n,i,o,r,t[s+12],20,-1926607734),i,o,t[s+5],4,-378558),o=zn(o,r,n,i,t[s+8],11,-2022574463),i=zn(i,o,r,n,t[s+11],16,1839030562),n=zn(n,i,o,r,t[s+14],23,-35309556),r=zn(r,n,i,o,t[s+1],4,-1530992060),o=zn(o,r,n,i,t[s+4],11,1272893353),i=zn(i,o,r,n,t[s+7],16,-155497632),n=zn(n,i,o,r,t[s+10],23,-1094730640),r=zn(r,n,i,o,t[s+13],4,681279174),o=zn(o,r,n,i,t[s],11,-358537222),i=zn(i,o,r,n,t[s+3],16,-722521979),n=zn(n,i,o,r,t[s+6],23,76029189),r=zn(r,n,i,o,t[s+9],4,-640364487),o=zn(o,r,n,i,t[s+12],11,-421815835),i=zn(i,o,r,n,t[s+15],16,530742520),r=Dn(r,n=zn(n,i,o,r,t[s+2],23,-995338651),i,o,t[s],6,-198630844),o=Dn(o,r,n,i,t[s+7],10,1126891415),i=Dn(i,o,r,n,t[s+14],15,-1416354905),n=Dn(n,i,o,r,t[s+5],21,-57434055),r=Dn(r,n,i,o,t[s+12],6,1700485571),o=Dn(o,r,n,i,t[s+3],10,-1894986606),i=Dn(i,o,r,n,t[s+10],15,-1051523),n=Dn(n,i,o,r,t[s+1],21,-2054922799),r=Dn(r,n,i,o,t[s+8],6,1873313359),o=Dn(o,r,n,i,t[s+15],10,-30611744),i=Dn(i,o,r,n,t[s+6],15,-1560198380),n=Dn(n,i,o,r,t[s+13],21,1309151649),r=Dn(r,n,i,o,t[s+4],6,-145523070),o=Dn(o,r,n,i,t[s+11],10,-1120210379),i=Dn(i,o,r,n,t[s+2],15,718787259),n=Dn(n,i,o,r,t[s+9],21,-343485551),r=On(r,a),n=On(n,u),i=On(i,c),o=On(o,h)}return[r,n,i,o]}(function(t){if(0===t.length)return[];for(var e=8*t.length,r=new Uint32Array(Ln(e)),n=0;n<e;n+=8)r[n>>5]|=(255&t[n/8])<<n%32;return r}(t),8*t.length))})),Wn=jn;function Fn(t,e,r,n){switch(t){case 0:return e&r^~e&n;case 1:case 3:return e^r^n;case 2:return e&r^e&n^r&n}}function Kn(t,e){return t<<e|t>>>32-e}var Vn=Tn("v5",80,(function(t){var e=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof t){var n=unescape(encodeURIComponent(t));t=[];for(var i=0;i<n.length;++i)t.push(n.charCodeAt(i))}else Array.isArray(t)||(t=Array.prototype.slice.call(t));t.push(128);for(var o=t.length/4+2,s=Math.ceil(o/16),a=new Array(s),u=0;u<s;++u){for(var c=new Uint32Array(16),h=0;h<16;++h)c[h]=t[64*u+4*h]<<24|t[64*u+4*h+1]<<16|t[64*u+4*h+2]<<8|t[64*u+4*h+3];a[u]=c}a[s-1][14]=8*(t.length-1)/Math.pow(2,32),a[s-1][14]=Math.floor(a[s-1][14]),a[s-1][15]=8*(t.length-1)&4294967295;for(var l=0;l<s;++l){for(var f=new Uint32Array(80),d=0;d<16;++d)f[d]=a[l][d];for(var p=16;p<80;++p)f[p]=Kn(f[p-3]^f[p-8]^f[p-14]^f[p-16],1);for(var y=r[0],g=r[1],m=r[2],w=r[3],b=r[4],v=0;v<80;++v){var _=Math.floor(v/20),k=Kn(y,5)+Fn(_,g,m,w)+b+e[_]+f[v]>>>0;b=w,w=m,m=Kn(g,30)>>>0,g=y,y=k}r[0]=r[0]+y>>>0,r[1]=r[1]+g>>>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]]})),qn=Vn;var Hn=Object.freeze({__proto__:null,v1:function(t,e,r){var n=e&&r||0,i=e||new Array(16),o=(t=t||{}).node||xn,s=void 0!==t.clockseq?t.clockseq:Sn;if(null==o||null==s){var a=t.random||(t.rng||_n)();null==o&&(o=xn=[1|a[0],a[1],a[2],a[3],a[4],a[5]]),null==s&&(s=Sn=16383&(a[6]<<8|a[7]))}var u=void 0!==t.msecs?t.msecs:Date.now(),c=void 0!==t.nsecs?t.nsecs:Rn+1,h=u-Mn+(c-Rn)/1e4;if(h<0&&void 0===t.clockseq&&(s=s+1&16383),(h<0||u>Mn)&&void 0===t.nsecs&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Mn=u,Rn=c,Sn=s;var l=(1e4*(268435455&(u+=122192928e5))+c)%4294967296;i[n++]=l>>>24&255,i[n++]=l>>>16&255,i[n++]=l>>>8&255,i[n++]=255&l;var f=u/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 e||Bn(i)},v3:Wn,v4:function(t,e,r){var n=(t=t||{}).random||(t.rng||_n)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,e){r=r||0;for(var i=0;i<16;++i)e[r+i]=n[i];return e}return Bn(n)},v5:qn,NIL:"00000000-0000-0000-0000-000000000000",version:function(t){if(!En(t))throw TypeError("Invalid UUID");return parseInt(t.substr(14,1),16)},validate:En,stringify:Bn,parse:Pn}),$n=r(Hn);const Gn=$n.v4;var Zn=function(t,e,r,n){if("string"!=typeof t)throw new TypeError(t+" 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:t};if(2===i&&(o.jsonrpc="2.0"),e){if("object"!=typeof e&&!Array.isArray(e))throw new TypeError(e+" must be an object, array or omitted");o.params=e}if(void 0===r){const t="function"==typeof n.generator?n.generator:function(){return Gn()};o.id=t(o,n)}else 2===i&&null===r?n.notificationIdNull&&(o.id=null):o.id=r;return o};const Yn=$n.v4,Jn=Zn,Xn=function(t,e){if(!(this instanceof Xn))return new Xn(t,e);e||(e={}),this.options={reviver:void 0!==e.reviver?e.reviver:null,replacer:void 0!==e.replacer?e.replacer:null,generator:void 0!==e.generator?e.generator:function(){return Yn()},version:void 0!==e.version?e.version:2,notificationIdNull:"boolean"==typeof e.notificationIdNull&&e.notificationIdNull},this.callServer=t};var Qn=Xn;Xn.prototype.request=function(t,e,r,n){const i=this;let o=null;const s=Array.isArray(t)&&"function"==typeof e;if(1===this.options.version&&s)throw new TypeError("JSON-RPC 1.0 does not support batching");if(s||!s&&t&&"object"==typeof t&&"function"==typeof e)n=e,o=t;else{"function"==typeof r&&(n=r,r=void 0);const i="function"==typeof n;try{o=Jn(t,e,r,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(t){if(i)return n(t);throw t}if(!i)return o}let a;try{a=JSON.stringify(o,this.options.replacer)}catch(t){return n(t)}return this.callServer(a,(function(t,e){i._parseResponse(t,e,n)})),o},Xn.prototype._parseResponse=function(t,e,r){if(t)return void r(t);if(!e)return r();let n;try{n=JSON.parse(e,this.options.reviver)}catch(t){return r(t)}if(3===r.length){if(Array.isArray(n)){const t=function(t){return void 0!==t.error},e=function(e){return!t(e)};return r(null,n.filter(t),n.filter(e))}return r(null,n.error,n.result)}r(null,n)};var ti,ei=e(Qn),ri={},ni={exports:{}};(ti=ni).exports=function(t){return t&&t.__esModule?t:{default:t}},ti.exports.__esModule=!0,ti.exports.default=ti.exports;var ii,oi,si,ai,ui=ni.exports,ci={exports:{}},hi={exports:{}};function li(){return ii||(ii=1,function(t){function e(r){return t.exports=e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.__esModule=!0,t.exports.default=t.exports,e(r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports}(hi)),hi.exports}function fi(){if(ai)return si;ai=1;var t=(oi||(oi=1,function(t){var e=li().default;function r(){
|
|
17
17
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
18
|
-
t.exports=r=function(){return i},t.exports.__esModule=!0,t.exports.default=t.exports;var n,i={},o=Object.prototype,s=o.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},u="function"==typeof Symbol?Symbol:{},c=u.iterator||"@@iterator",h=u.asyncIterator||"@@asyncIterator",l=u.toStringTag||"@@toStringTag";function f(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{f({},"")}catch(n){f=function(t,e,r){return t[e]=r}}function d(t,e,r,n){var i=e&&e.prototype instanceof v?e:v,o=Object.create(i.prototype),s=new O(n||[]);return a(o,"_invoke",{value:M(t,r,s)}),o}function p(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}i.wrap=d;var y="suspendedStart",g="suspendedYield",m="executing",w="completed",b={};function v(){}function _(){}function k(){}var E={};f(E,c,(function(){return this}));var x=Object.getPrototypeOf,S=x&&x(x(L([])));S&&S!==o&&s.call(S,c)&&(E=S);var A=k.prototype=v.prototype=Object.create(E);function I(t){["next","throw","return"].forEach((function(e){f(t,e,(function(t){return this._invoke(e,t)}))}))}function B(t,r){function n(i,o,a,u){var c=p(t[i],t,o);if("throw"!==c.type){var h=c.arg,l=h.value;return l&&"object"==e(l)&&s.call(l,"__await")?r.resolve(l.__await).then((function(t){n("next",t,a,u)}),(function(t){n("throw",t,a,u)})):r.resolve(l).then((function(t){h.value=t,a(h)}),(function(t){return n("throw",t,a,u)}))}u(c.arg)}var i;a(this,"_invoke",{value:function(t,e){function o(){return new r((function(r,i){n(t,e,r,i)}))}return i=i?i.then(o,o):o()}})}function M(t,e,r){var i=y;return function(o,s){if(i===m)throw new Error("Generator is already running");if(i===w){if("throw"===o)throw s;return{value:n,done:!0}}for(r.method=o,r.arg=s;;){var a=r.delegate;if(a){var u=R(a,r);if(u){if(u===b)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===y)throw i=w,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=m;var c=p(t,e,r);if("normal"===c.type){if(i=r.done?w:g,c.arg===b)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(i=w,r.method="throw",r.arg=c.arg)}}}function R(t,e){var r=e.method,i=t.iterator[r];if(i===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=n,R(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),b;var o=p(i,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,b;var s=o.arg;return s?s.done?(e[t.resultName]=s.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=n),e.delegate=null,b):s:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,b)}function P(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(P,this),this.reset(!0)}function L(t){if(t||""===t){var r=t[c];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function e(){for(;++i<t.length;)if(s.call(t,i))return e.value=t[i],e.done=!1,e;return e.value=n,e.done=!0,e};return o.next=o}}throw new TypeError(e(t)+" is not iterable")}return _.prototype=k,a(A,"constructor",{value:k,configurable:!0}),a(k,"constructor",{value:_,configurable:!0}),_.displayName=f(k,l,"GeneratorFunction"),i.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===_||"GeneratorFunction"===(e.displayName||e.name))},i.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,k):(t.__proto__=k,f(t,l,"GeneratorFunction")),t.prototype=Object.create(A),t},i.awrap=function(t){return{__await:t}},I(B.prototype),f(B.prototype,h,(function(){return this})),i.AsyncIterator=B,i.async=function(t,e,r,n,o){void 0===o&&(o=Promise);var s=new B(d(t,e,r,n),o);return i.isGeneratorFunction(e)?s:s.next().then((function(t){return t.done?t.value:s.next()}))},I(A),f(A,l,"Generator"),f(A,c,(function(){return this})),f(A,"toString",(function(){return"[object Generator]"})),i.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},i.values=L,O.prototype={constructor:O,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=n,this.done=!1,this.delegate=null,this.method="next",this.arg=n,this.tryEntries.forEach(T),!t)for(var e in this)"t"===e.charAt(0)&&s.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=n)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,i){return a.type="throw",a.arg=t,e.next=r,i&&(e.method="next",e.arg=n),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var u=s.call(o,"catchLoc"),c=s.call(o,"finallyLoc");if(u&&c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&s.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=t,o.arg=e,i?(this.method="next",this.next=i.finallyLoc,b):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),b},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),b}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:L(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=n),b}},i}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}(ci)),ci.exports)();si=t;try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}return si}hi.exports,ci.exports;var di,pi={exports:{}};var yi,gi={exports:{}};function mi(){return yi||(yi=1,function(t){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},t.exports.__esModule=!0,t.exports.default=t.exports}(gi)),gi.exports}var wi,bi,vi,_i={exports:{}},ki={exports:{}},Ei={exports:{}};function xi(){return wi||(wi=1,function(t){var e=li().default;t.exports=function(t,r){if("object"!==e(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,r||"default");if("object"!==e(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)},t.exports.__esModule=!0,t.exports.default=t.exports}(Ei)),Ei.exports}function Si(){return bi||(bi=1,function(t){var e=li().default,r=xi();t.exports=function(t){var n=r(t,"string");return"symbol"===e(n)?n:String(n)},t.exports.__esModule=!0,t.exports.default=t.exports}(ki)),ki.exports}function Ai(){return vi||(vi=1,function(t){var e=Si();function r(t,r){for(var n=0;n<r.length;n++){var i=r[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,e(i.key),i)}}t.exports=function(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t},t.exports.__esModule=!0,t.exports.default=t.exports}(_i)),_i.exports}Ei.exports,ki.exports;var Ii,Bi,Mi={exports:{}},Ri={exports:{}};function Pi(){return Ii||(Ii=1,function(t){function e(r,n){return t.exports=e=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},t.exports.__esModule=!0,t.exports.default=t.exports,e(r,n)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports}(Ri)),Ri.exports}function Ti(){return Bi||(Bi=1,function(t){var e=Pi();t.exports=function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&e(t,r)},t.exports.__esModule=!0,t.exports.default=t.exports}(Mi)),Mi.exports}Ri.exports;var Oi,Li,Ui={exports:{}},Ci={exports:{}};function Ni(){return Oi||(Oi=1,function(t){t.exports=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t},t.exports.__esModule=!0,t.exports.default=t.exports}(Ci)),Ci.exports}function zi(){return Li||(Li=1,function(t){var e=li().default,r=Ni();t.exports=function(t,n){if(n&&("object"===e(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return r(t)},t.exports.__esModule=!0,t.exports.default=t.exports}(Ui)),Ui.exports}Ci.exports;var Di,ji={exports:{}};function Wi(){return Di||(Di=1,function(t){function e(r){return t.exports=e=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},t.exports.__esModule=!0,t.exports.default=t.exports,e(r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports}(ji)),ji.exports}var Ki,Fi={exports:{}};function qi(){return Ki||(Ki=1,function(t){var e=Object.prototype.hasOwnProperty,r="~";function n(){}function i(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function o(t,e,n,o,s){if("function"!=typeof n)throw new TypeError("The listener must be a function");var a=new i(n,o||t,s),u=r?r+e:e;return t._events[u]?t._events[u].fn?t._events[u]=[t._events[u],a]:t._events[u].push(a):(t._events[u]=a,t._eventsCount++),t}function s(t,e){0==--t._eventsCount?t._events=new n:delete t._events[e]}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 t,n,i=[];if(0===this._eventsCount)return i;for(n in t=this._events)e.call(t,n)&&i.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(t)):i},a.prototype.listeners=function(t){var e=r?r+t:t,n=this._events[e];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,o=n.length,s=new Array(o);i<o;i++)s[i]=n[i].fn;return s},a.prototype.listenerCount=function(t){var e=r?r+t:t,n=this._events[e];return n?n.fn?1:n.length:0},a.prototype.emit=function(t,e,n,i,o,s){var a=r?r+t:t;if(!this._events[a])return!1;var u,c,h=this._events[a],l=arguments.length;if(h.fn){switch(h.once&&this.removeListener(t,h.fn,void 0,!0),l){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,e),!0;case 3:return h.fn.call(h.context,e,n),!0;case 4:return h.fn.call(h.context,e,n,i),!0;case 5:return h.fn.call(h.context,e,n,i,o),!0;case 6:return h.fn.call(h.context,e,n,i,o,s),!0}for(c=1,u=new Array(l-1);c<l;c++)u[c-1]=arguments[c];h.fn.apply(h.context,u)}else{var f,d=h.length;for(c=0;c<d;c++)switch(h[c].once&&this.removeListener(t,h[c].fn,void 0,!0),l){case 1:h[c].fn.call(h[c].context);break;case 2:h[c].fn.call(h[c].context,e);break;case 3:h[c].fn.call(h[c].context,e,n);break;case 4:h[c].fn.call(h[c].context,e,n,i);break;default:if(!u)for(f=1,u=new Array(l-1);f<l;f++)u[f-1]=arguments[f];h[c].fn.apply(h[c].context,u)}}return!0},a.prototype.on=function(t,e,r){return o(this,t,e,r,!1)},a.prototype.once=function(t,e,r){return o(this,t,e,r,!0)},a.prototype.removeListener=function(t,e,n,i){var o=r?r+t:t;if(!this._events[o])return this;if(!e)return s(this,o),this;var a=this._events[o];if(a.fn)a.fn!==e||i&&!a.once||n&&a.context!==n||s(this,o);else{for(var u=0,c=[],h=a.length;u<h;u++)(a[u].fn!==e||i&&!a[u].once||n&&a[u].context!==n)&&c.push(a[u]);c.length?this._events[o]=1===c.length?c[0]:c:s(this,o)}return this},a.prototype.removeAllListeners=function(t){var e;return t?(e=r?r+t:t,this._events[e]&&s(this,e)):(this._events=new n,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=r,a.EventEmitter=a,t.exports=a}(Fi)),Fi.exports}!function(t){var e=ui;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=e(fi()),n=e((di||(di=1,function(t){function e(t,e,r,n,i,o,s){try{var a=t[o](s),u=a.value}catch(t){return void r(t)}a.done?e(u):Promise.resolve(u).then(n,i)}t.exports=function(t){return function(){var r=this,n=arguments;return new Promise((function(i,o){var s=t.apply(r,n);function a(t){e(s,i,o,a,u,"next",t)}function u(t){e(s,i,o,a,u,"throw",t)}a(void 0)}))}},t.exports.__esModule=!0,t.exports.default=t.exports}(pi)),pi.exports)),i=e(li()),o=e(mi()),s=e(Ai()),a=e(Ti()),u=e(zi()),c=e(Wi()),h=qi();function l(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=(0,c.default)(t);if(e){var i=(0,c.default)(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return(0,u.default)(this,r)}}var f=function(t){(0,a.default)(d,t);var e,u,c,h,f=l(d);function d(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"ws://localhost:8080",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3?arguments[3]:void 0;(0,o.default)(this,d);var s=n.autoconnect,a=void 0===s||s,u=n.reconnect,c=void 0===u||u,h=n.reconnect_interval,l=void 0===h?1e3:h,p=n.max_reconnects,y=void 0===p?5:p,g=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]])}return r}(n,["autoconnect","reconnect","reconnect_interval","max_reconnects"]);return(e=f.call(this)).webSocketFactory=t,e.queue={},e.rpc_id=0,e.address=r,e.autoconnect=a,e.ready=!1,e.reconnect=c,e.reconnect_timer_id=void 0,e.reconnect_interval=l,e.max_reconnects=y,e.rest_options=g,e.current_reconnects=0,e.generate_request_id=i||function(){return++e.rpc_id},e.autoconnect&&e._connect(e.address,Object.assign({autoconnect:e.autoconnect,reconnect:e.reconnect,reconnect_interval:e.reconnect_interval,max_reconnects:e.max_reconnects},e.rest_options)),e}return(0,s.default)(d,[{key:"connect",value:function(){this.socket||this._connect(this.address,Object.assign({autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects},this.rest_options))}},{key:"call",value:function(t,e,r,n){var o=this;return n||"object"!==(0,i.default)(r)||(n=r,r=null),new Promise((function(i,s){if(!o.ready)return s(new Error("socket not ready"));var a=o.generate_request_id(t,e),u={jsonrpc:"2.0",method:t,params:e||null,id:a};o.socket.send(JSON.stringify(u),n,(function(t){if(t)return s(t);o.queue[a]={promise:[i,s]},r&&(o.queue[a].timeout=setTimeout((function(){delete o.queue[a],s(new Error("reply timeout"))}),r))}))}))}},{key:"login",value:(h=(0,n.default)(r.default.mark((function t(e){var n;return r.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.call("rpc.login",e);case 2:if(n=t.sent){t.next=5;break}throw new Error("authentication failed");case 5:return t.abrupt("return",n);case 6:case"end":return t.stop()}}),t,this)}))),function(t){return h.apply(this,arguments)})},{key:"listMethods",value:(c=(0,n.default)(r.default.mark((function t(){return r.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.call("__listMethods");case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)}))),function(){return c.apply(this,arguments)})},{key:"notify",value:function(t,e){var r=this;return new Promise((function(n,i){if(!r.ready)return i(new Error("socket not ready"));var o={jsonrpc:"2.0",method:t,params:e||null};r.socket.send(JSON.stringify(o),(function(t){if(t)return i(t);n()}))}))}},{key:"subscribe",value:(u=(0,n.default)(r.default.mark((function t(e){var n;return r.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return"string"==typeof e&&(e=[e]),t.next=3,this.call("rpc.on",e);case 3:if(n=t.sent,"string"!=typeof e||"ok"===n[e]){t.next=6;break}throw new Error("Failed subscribing to an event '"+e+"' with: "+n[e]);case 6:return t.abrupt("return",n);case 7:case"end":return t.stop()}}),t,this)}))),function(t){return u.apply(this,arguments)})},{key:"unsubscribe",value:(e=(0,n.default)(r.default.mark((function t(e){var n;return r.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return"string"==typeof e&&(e=[e]),t.next=3,this.call("rpc.off",e);case 3:if(n=t.sent,"string"!=typeof e||"ok"===n[e]){t.next=6;break}throw new Error("Failed unsubscribing from an event with: "+n);case 6:return t.abrupt("return",n);case 7:case"end":return t.stop()}}),t,this)}))),function(t){return e.apply(this,arguments)})},{key:"close",value:function(t,e){this.socket.close(t||1e3,e)}},{key:"_connect",value:function(t,e){var r=this;clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(t,e),this.socket.addEventListener("open",(function(){r.ready=!0,r.emit("open"),r.current_reconnects=0})),this.socket.addEventListener("message",(function(t){var e=t.data;e instanceof ArrayBuffer&&(e=Buffer.from(e).toString());try{e=JSON.parse(e)}catch(t){return}if(e.notification&&r.listeners(e.notification).length){if(!Object.keys(e.params).length)return r.emit(e.notification);var n=[e.notification];if(e.params.constructor===Object)n.push(e.params);else for(var i=0;i<e.params.length;i++)n.push(e.params[i]);return Promise.resolve().then((function(){r.emit.apply(r,n)}))}if(!r.queue[e.id])return e.method&&e.params?Promise.resolve().then((function(){r.emit(e.method,e.params)})):void 0;"error"in e=="result"in e&&r.queue[e.id].promise[1](new Error('Server response malformed. Response must include either "result" or "error", but not both.')),r.queue[e.id].timeout&&clearTimeout(r.queue[e.id].timeout),e.error?r.queue[e.id].promise[1](e.error):r.queue[e.id].promise[0](e.result),delete r.queue[e.id]})),this.socket.addEventListener("error",(function(t){return r.emit("error",t)})),this.socket.addEventListener("close",(function(n){var i=n.code,o=n.reason;r.ready&&setTimeout((function(){return r.emit("close",i,o)}),0),r.ready=!1,r.socket=void 0,1e3!==i&&(r.current_reconnects++,r.reconnect&&(r.max_reconnects>r.current_reconnects||0===r.max_reconnects)&&(r.reconnect_timer_id=setTimeout((function(){return r._connect(t,e)}),r.reconnect_interval)))}))}}]),d}(h.EventEmitter);t.default=f}(ri);var Vi=e(ri),Hi={};!function(t){var e=ui;Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(t,e){return new u(t,e)};var r=e(mi()),n=e(Ai()),i=e(Ti()),o=e(zi()),s=e(Wi());function a(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=(0,s.default)(t);if(e){var i=(0,s.default)(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return(0,o.default)(this,r)}}var u=function(t){(0,i.default)(o,t);var e=a(o);function o(t,n,i){var s;return(0,r.default)(this,o),(s=e.call(this)).socket=new window.WebSocket(t,i),s.socket.onopen=function(){return s.emit("open")},s.socket.onmessage=function(t){return s.emit("message",t.data)},s.socket.onerror=function(t){return s.emit("error",t)},s.socket.onclose=function(t){s.emit("close",t.code,t.reason)},s}return(0,n.default)(o,[{key:"send",value:function(t,e,r){var n=r||e;try{this.socket.send(t),n()}catch(t){n(t)}}},{key:"close",value:function(t,e){this.socket.close(t,e)}},{key:"addEventListener",value:function(t,e,r){this.socket.addEventListener(t,e,r)}}]),o}(qi().EventEmitter)}(Hi);var $i=e(Hi);const[Gi,Zi,Yi]=[[],[],[]],Ji=BigInt(0),Xi=BigInt(1),Qi=BigInt(2),to=BigInt(7),eo=BigInt(256),ro=BigInt(113);for(let t=0,e=Xi,r=1,n=0;t<24;t++){[r,n]=[n,(2*r+3*n)%5],Gi.push(2*(5*n+r)),Zi.push((t+1)*(t+2)/2%64);let i=Ji;for(let t=0;t<7;t++)e=(e<<Xi^(e>>to)*ro)%eo,e&Qi&&(i^=Xi<<(Xi<<BigInt(t))-Xi);Yi.push(i)}const[no,io]=O(Yi,!0),oo=(t,e,r)=>r>32?C(t,e,r):L(t,e,r),so=(t,e,r)=>r>32?N(t,e,r):U(t,e,r);class ao extends A{constructor(t,e,r,n=!1,i=24){if(super(),this.blockLen=t,this.suffix=e,this.outputLen=r,this.enableXOF=n,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,y(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");var o;this.state=new Uint8Array(200),this.state32=(o=this.state,new Uint32Array(o.buffer,o.byteOffset,Math.floor(o.byteLength/4)))}keccak(){!function(t,e=24){const r=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let e=0;e<10;e++)r[e]=t[e]^t[e+10]^t[e+20]^t[e+30]^t[e+40];for(let e=0;e<10;e+=2){const n=(e+8)%10,i=(e+2)%10,o=r[i],s=r[i+1],a=oo(o,s,1)^r[n],u=so(o,s,1)^r[n+1];for(let r=0;r<50;r+=10)t[e+r]^=a,t[e+r+1]^=u}let e=t[2],i=t[3];for(let r=0;r<24;r++){const n=Zi[r],o=oo(e,i,n),s=so(e,i,n),a=Gi[r];e=t[a],i=t[a+1],t[a]=o,t[a+1]=s}for(let e=0;e<50;e+=10){for(let n=0;n<10;n++)r[n]=t[e+n];for(let n=0;n<10;n++)t[e+n]^=~r[(n+2)%10]&r[(n+4)%10]}t[0]^=no[n],t[1]^=io[n]}r.fill(0)}(this.state32,this.rounds),this.posOut=0,this.pos=0}update(t){m(this);const{blockLen:e,state:r}=this,n=(t=x(t)).length;for(let i=0;i<n;){const o=Math.min(e-this.pos,n-i);for(let e=0;e<o;e++)r[this.pos++]^=t[i++];this.pos===e&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:e,pos:r,blockLen:n}=this;t[r]^=e,0!=(128&e)&&r===n-1&&this.keccak(),t[n-1]^=128,this.keccak()}writeInto(t){m(this,!1),g(t),this.finish();const e=this.state,{blockLen:r}=this;for(let n=0,i=t.length;n<i;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,i-n);t.set(e.subarray(this.posOut,this.posOut+o),n),this.posOut+=o,n+=o}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return y(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(w(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:e,suffix:r,outputLen:n,rounds:i,enableXOF:o}=this;return t||(t=new ao(e,r,n,o,i)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=i,t.suffix=r,t.outputLen=n,t.enableXOF=o,t.destroyed=this.destroyed,t}}const uo=((t,e,r)=>I((()=>new ao(e,t,r))))(1,136,32);const{bytesToNumberBE:co,hexToBytes:ho}=dt,lo={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(t){const{Err:e}=lo;if(t.length<2||2!==t[0])throw new e("Invalid signature integer tag");const r=t[1],n=t.subarray(2,r+2);if(!r||n.length!==r)throw new e("Invalid signature integer: wrong length");if(128&n[0])throw new e("Invalid signature integer: negative");if(0===n[0]&&!(128&n[1]))throw new e("Invalid signature integer: unnecessary leading zero");return{d:co(n),l:t.subarray(r+2)}},toSig(t){const{Err:e}=lo,r="string"==typeof t?ho(t):t;if(!(r instanceof Uint8Array))throw new Error("ui8a expected");let n=r.length;if(n<2||48!=r[0])throw new e("Invalid signature tag");if(r[1]!==n-2)throw new e("Invalid signature: incorrect length");const{d:i,l:o}=lo._parseInt(r.subarray(2)),{d:s,l:a}=lo._parseInt(o);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:i,s:s}},hexFromSig(t){const e=t=>8&Number.parseInt(t[0],16)?"00"+t:t,r=t=>{const e=t.toString(16);return 1&e.length?`0${e}`:e},n=e(r(t.s)),i=e(r(t.r)),o=n.length/2,s=i.length/2,a=r(o),u=r(s);return`30${r(s+o+4)}02${u}${i}02${a}${n}`}},fo=BigInt(0),po=BigInt(1);BigInt(2);const yo=BigInt(3);function go(t){const e=
|
|
18
|
+
t.exports=r=function(){return i},t.exports.__esModule=!0,t.exports.default=t.exports;var n,i={},o=Object.prototype,s=o.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},u="function"==typeof Symbol?Symbol:{},c=u.iterator||"@@iterator",h=u.asyncIterator||"@@asyncIterator",l=u.toStringTag||"@@toStringTag";function f(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{f({},"")}catch(n){f=function(t,e,r){return t[e]=r}}function d(t,e,r,n){var i=e&&e.prototype instanceof v?e:v,o=Object.create(i.prototype),s=new L(n||[]);return a(o,"_invoke",{value:M(t,r,s)}),o}function p(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}i.wrap=d;var y="suspendedStart",g="suspendedYield",m="executing",w="completed",b={};function v(){}function _(){}function k(){}var E={};f(E,c,(function(){return this}));var x=Object.getPrototypeOf,S=x&&x(x(O([])));S&&S!==o&&s.call(S,c)&&(E=S);var A=k.prototype=v.prototype=Object.create(E);function I(t){["next","throw","return"].forEach((function(e){f(t,e,(function(t){return this._invoke(e,t)}))}))}function B(t,r){function n(i,o,a,u){var c=p(t[i],t,o);if("throw"!==c.type){var h=c.arg,l=h.value;return l&&"object"==e(l)&&s.call(l,"__await")?r.resolve(l.__await).then((function(t){n("next",t,a,u)}),(function(t){n("throw",t,a,u)})):r.resolve(l).then((function(t){h.value=t,a(h)}),(function(t){return n("throw",t,a,u)}))}u(c.arg)}var i;a(this,"_invoke",{value:function(t,e){function o(){return new r((function(r,i){n(t,e,r,i)}))}return i=i?i.then(o,o):o()}})}function M(t,e,r){var i=y;return function(o,s){if(i===m)throw new Error("Generator is already running");if(i===w){if("throw"===o)throw s;return{value:n,done:!0}}for(r.method=o,r.arg=s;;){var a=r.delegate;if(a){var u=R(a,r);if(u){if(u===b)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===y)throw i=w,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=m;var c=p(t,e,r);if("normal"===c.type){if(i=r.done?w:g,c.arg===b)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(i=w,r.method="throw",r.arg=c.arg)}}}function R(t,e){var r=e.method,i=t.iterator[r];if(i===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=n,R(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),b;var o=p(i,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,b;var s=o.arg;return s?s.done?(e[t.resultName]=s.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=n),e.delegate=null,b):s:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,b)}function P(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function L(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(P,this),this.reset(!0)}function O(t){if(t||""===t){var r=t[c];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function e(){for(;++i<t.length;)if(s.call(t,i))return e.value=t[i],e.done=!1,e;return e.value=n,e.done=!0,e};return o.next=o}}throw new TypeError(e(t)+" is not iterable")}return _.prototype=k,a(A,"constructor",{value:k,configurable:!0}),a(k,"constructor",{value:_,configurable:!0}),_.displayName=f(k,l,"GeneratorFunction"),i.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===_||"GeneratorFunction"===(e.displayName||e.name))},i.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,k):(t.__proto__=k,f(t,l,"GeneratorFunction")),t.prototype=Object.create(A),t},i.awrap=function(t){return{__await:t}},I(B.prototype),f(B.prototype,h,(function(){return this})),i.AsyncIterator=B,i.async=function(t,e,r,n,o){void 0===o&&(o=Promise);var s=new B(d(t,e,r,n),o);return i.isGeneratorFunction(e)?s:s.next().then((function(t){return t.done?t.value:s.next()}))},I(A),f(A,l,"Generator"),f(A,c,(function(){return this})),f(A,"toString",(function(){return"[object Generator]"})),i.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},i.values=O,L.prototype={constructor:L,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=n,this.done=!1,this.delegate=null,this.method="next",this.arg=n,this.tryEntries.forEach(T),!t)for(var e in this)"t"===e.charAt(0)&&s.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=n)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,i){return a.type="throw",a.arg=t,e.next=r,i&&(e.method="next",e.arg=n),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var u=s.call(o,"catchLoc"),c=s.call(o,"finallyLoc");if(u&&c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&s.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=t,o.arg=e,i?(this.method="next",this.next=i.finallyLoc,b):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),b},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),b}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:O(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=n),b}},i}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}(ci)),ci.exports)();si=t;try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}return si}hi.exports,ci.exports;var di,pi={exports:{}};var yi,gi={exports:{}};function mi(){return yi||(yi=1,function(t){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},t.exports.__esModule=!0,t.exports.default=t.exports}(gi)),gi.exports}var wi,bi,vi,_i={exports:{}},ki={exports:{}},Ei={exports:{}};function xi(){return wi||(wi=1,function(t){var e=li().default;t.exports=function(t,r){if("object"!==e(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,r||"default");if("object"!==e(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)},t.exports.__esModule=!0,t.exports.default=t.exports}(Ei)),Ei.exports}function Si(){return bi||(bi=1,function(t){var e=li().default,r=xi();t.exports=function(t){var n=r(t,"string");return"symbol"===e(n)?n:String(n)},t.exports.__esModule=!0,t.exports.default=t.exports}(ki)),ki.exports}function Ai(){return vi||(vi=1,function(t){var e=Si();function r(t,r){for(var n=0;n<r.length;n++){var i=r[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,e(i.key),i)}}t.exports=function(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t},t.exports.__esModule=!0,t.exports.default=t.exports}(_i)),_i.exports}Ei.exports,ki.exports;var Ii,Bi,Mi={exports:{}},Ri={exports:{}};function Pi(){return Ii||(Ii=1,function(t){function e(r,n){return t.exports=e=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},t.exports.__esModule=!0,t.exports.default=t.exports,e(r,n)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports}(Ri)),Ri.exports}function Ti(){return Bi||(Bi=1,function(t){var e=Pi();t.exports=function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&e(t,r)},t.exports.__esModule=!0,t.exports.default=t.exports}(Mi)),Mi.exports}Ri.exports;var Li,Oi,Ui={exports:{}},Ci={exports:{}};function Ni(){return Li||(Li=1,function(t){t.exports=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t},t.exports.__esModule=!0,t.exports.default=t.exports}(Ci)),Ci.exports}function zi(){return Oi||(Oi=1,function(t){var e=li().default,r=Ni();t.exports=function(t,n){if(n&&("object"===e(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return r(t)},t.exports.__esModule=!0,t.exports.default=t.exports}(Ui)),Ui.exports}Ci.exports;var Di,ji={exports:{}};function Wi(){return Di||(Di=1,function(t){function e(r){return t.exports=e=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},t.exports.__esModule=!0,t.exports.default=t.exports,e(r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports}(ji)),ji.exports}var Fi,Ki={exports:{}};function Vi(){return Fi||(Fi=1,function(t){var e=Object.prototype.hasOwnProperty,r="~";function n(){}function i(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function o(t,e,n,o,s){if("function"!=typeof n)throw new TypeError("The listener must be a function");var a=new i(n,o||t,s),u=r?r+e:e;return t._events[u]?t._events[u].fn?t._events[u]=[t._events[u],a]:t._events[u].push(a):(t._events[u]=a,t._eventsCount++),t}function s(t,e){0==--t._eventsCount?t._events=new n:delete t._events[e]}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 t,n,i=[];if(0===this._eventsCount)return i;for(n in t=this._events)e.call(t,n)&&i.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(t)):i},a.prototype.listeners=function(t){var e=r?r+t:t,n=this._events[e];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,o=n.length,s=new Array(o);i<o;i++)s[i]=n[i].fn;return s},a.prototype.listenerCount=function(t){var e=r?r+t:t,n=this._events[e];return n?n.fn?1:n.length:0},a.prototype.emit=function(t,e,n,i,o,s){var a=r?r+t:t;if(!this._events[a])return!1;var u,c,h=this._events[a],l=arguments.length;if(h.fn){switch(h.once&&this.removeListener(t,h.fn,void 0,!0),l){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,e),!0;case 3:return h.fn.call(h.context,e,n),!0;case 4:return h.fn.call(h.context,e,n,i),!0;case 5:return h.fn.call(h.context,e,n,i,o),!0;case 6:return h.fn.call(h.context,e,n,i,o,s),!0}for(c=1,u=new Array(l-1);c<l;c++)u[c-1]=arguments[c];h.fn.apply(h.context,u)}else{var f,d=h.length;for(c=0;c<d;c++)switch(h[c].once&&this.removeListener(t,h[c].fn,void 0,!0),l){case 1:h[c].fn.call(h[c].context);break;case 2:h[c].fn.call(h[c].context,e);break;case 3:h[c].fn.call(h[c].context,e,n);break;case 4:h[c].fn.call(h[c].context,e,n,i);break;default:if(!u)for(f=1,u=new Array(l-1);f<l;f++)u[f-1]=arguments[f];h[c].fn.apply(h[c].context,u)}}return!0},a.prototype.on=function(t,e,r){return o(this,t,e,r,!1)},a.prototype.once=function(t,e,r){return o(this,t,e,r,!0)},a.prototype.removeListener=function(t,e,n,i){var o=r?r+t:t;if(!this._events[o])return this;if(!e)return s(this,o),this;var a=this._events[o];if(a.fn)a.fn!==e||i&&!a.once||n&&a.context!==n||s(this,o);else{for(var u=0,c=[],h=a.length;u<h;u++)(a[u].fn!==e||i&&!a[u].once||n&&a[u].context!==n)&&c.push(a[u]);c.length?this._events[o]=1===c.length?c[0]:c:s(this,o)}return this},a.prototype.removeAllListeners=function(t){var e;return t?(e=r?r+t:t,this._events[e]&&s(this,e)):(this._events=new n,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=r,a.EventEmitter=a,t.exports=a}(Ki)),Ki.exports}!function(t){var e=ui;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=e(fi()),n=e((di||(di=1,function(t){function e(t,e,r,n,i,o,s){try{var a=t[o](s),u=a.value}catch(t){return void r(t)}a.done?e(u):Promise.resolve(u).then(n,i)}t.exports=function(t){return function(){var r=this,n=arguments;return new Promise((function(i,o){var s=t.apply(r,n);function a(t){e(s,i,o,a,u,"next",t)}function u(t){e(s,i,o,a,u,"throw",t)}a(void 0)}))}},t.exports.__esModule=!0,t.exports.default=t.exports}(pi)),pi.exports)),i=e(li()),o=e(mi()),s=e(Ai()),a=e(Ti()),u=e(zi()),c=e(Wi()),h=Vi();function l(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=(0,c.default)(t);if(e){var i=(0,c.default)(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return(0,u.default)(this,r)}}var f=function(t){(0,a.default)(d,t);var e,u,c,h,f=l(d);function d(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"ws://localhost:8080",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3?arguments[3]:void 0;(0,o.default)(this,d);var s=n.autoconnect,a=void 0===s||s,u=n.reconnect,c=void 0===u||u,h=n.reconnect_interval,l=void 0===h?1e3:h,p=n.max_reconnects,y=void 0===p?5:p,g=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]])}return r}(n,["autoconnect","reconnect","reconnect_interval","max_reconnects"]);return(e=f.call(this)).webSocketFactory=t,e.queue={},e.rpc_id=0,e.address=r,e.autoconnect=a,e.ready=!1,e.reconnect=c,e.reconnect_timer_id=void 0,e.reconnect_interval=l,e.max_reconnects=y,e.rest_options=g,e.current_reconnects=0,e.generate_request_id=i||function(){return++e.rpc_id},e.autoconnect&&e._connect(e.address,Object.assign({autoconnect:e.autoconnect,reconnect:e.reconnect,reconnect_interval:e.reconnect_interval,max_reconnects:e.max_reconnects},e.rest_options)),e}return(0,s.default)(d,[{key:"connect",value:function(){this.socket||this._connect(this.address,Object.assign({autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects},this.rest_options))}},{key:"call",value:function(t,e,r,n){var o=this;return n||"object"!==(0,i.default)(r)||(n=r,r=null),new Promise((function(i,s){if(!o.ready)return s(new Error("socket not ready"));var a=o.generate_request_id(t,e),u={jsonrpc:"2.0",method:t,params:e||null,id:a};o.socket.send(JSON.stringify(u),n,(function(t){if(t)return s(t);o.queue[a]={promise:[i,s]},r&&(o.queue[a].timeout=setTimeout((function(){delete o.queue[a],s(new Error("reply timeout"))}),r))}))}))}},{key:"login",value:(h=(0,n.default)(r.default.mark((function t(e){var n;return r.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.call("rpc.login",e);case 2:if(n=t.sent){t.next=5;break}throw new Error("authentication failed");case 5:return t.abrupt("return",n);case 6:case"end":return t.stop()}}),t,this)}))),function(t){return h.apply(this,arguments)})},{key:"listMethods",value:(c=(0,n.default)(r.default.mark((function t(){return r.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.call("__listMethods");case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)}))),function(){return c.apply(this,arguments)})},{key:"notify",value:function(t,e){var r=this;return new Promise((function(n,i){if(!r.ready)return i(new Error("socket not ready"));var o={jsonrpc:"2.0",method:t,params:e||null};r.socket.send(JSON.stringify(o),(function(t){if(t)return i(t);n()}))}))}},{key:"subscribe",value:(u=(0,n.default)(r.default.mark((function t(e){var n;return r.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return"string"==typeof e&&(e=[e]),t.next=3,this.call("rpc.on",e);case 3:if(n=t.sent,"string"!=typeof e||"ok"===n[e]){t.next=6;break}throw new Error("Failed subscribing to an event '"+e+"' with: "+n[e]);case 6:return t.abrupt("return",n);case 7:case"end":return t.stop()}}),t,this)}))),function(t){return u.apply(this,arguments)})},{key:"unsubscribe",value:(e=(0,n.default)(r.default.mark((function t(e){var n;return r.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return"string"==typeof e&&(e=[e]),t.next=3,this.call("rpc.off",e);case 3:if(n=t.sent,"string"!=typeof e||"ok"===n[e]){t.next=6;break}throw new Error("Failed unsubscribing from an event with: "+n);case 6:return t.abrupt("return",n);case 7:case"end":return t.stop()}}),t,this)}))),function(t){return e.apply(this,arguments)})},{key:"close",value:function(t,e){this.socket.close(t||1e3,e)}},{key:"_connect",value:function(t,e){var r=this;clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(t,e),this.socket.addEventListener("open",(function(){r.ready=!0,r.emit("open"),r.current_reconnects=0})),this.socket.addEventListener("message",(function(t){var e=t.data;e instanceof ArrayBuffer&&(e=Buffer.from(e).toString());try{e=JSON.parse(e)}catch(t){return}if(e.notification&&r.listeners(e.notification).length){if(!Object.keys(e.params).length)return r.emit(e.notification);var n=[e.notification];if(e.params.constructor===Object)n.push(e.params);else for(var i=0;i<e.params.length;i++)n.push(e.params[i]);return Promise.resolve().then((function(){r.emit.apply(r,n)}))}if(!r.queue[e.id])return e.method&&e.params?Promise.resolve().then((function(){r.emit(e.method,e.params)})):void 0;"error"in e=="result"in e&&r.queue[e.id].promise[1](new Error('Server response malformed. Response must include either "result" or "error", but not both.')),r.queue[e.id].timeout&&clearTimeout(r.queue[e.id].timeout),e.error?r.queue[e.id].promise[1](e.error):r.queue[e.id].promise[0](e.result),delete r.queue[e.id]})),this.socket.addEventListener("error",(function(t){return r.emit("error",t)})),this.socket.addEventListener("close",(function(n){var i=n.code,o=n.reason;r.ready&&setTimeout((function(){return r.emit("close",i,o)}),0),r.ready=!1,r.socket=void 0,1e3!==i&&(r.current_reconnects++,r.reconnect&&(r.max_reconnects>r.current_reconnects||0===r.max_reconnects)&&(r.reconnect_timer_id=setTimeout((function(){return r._connect(t,e)}),r.reconnect_interval)))}))}}]),d}(h.EventEmitter);t.default=f}(ri);var qi=e(ri),Hi={};!function(t){var e=ui;Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(t,e){return new u(t,e)};var r=e(mi()),n=e(Ai()),i=e(Ti()),o=e(zi()),s=e(Wi());function a(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=(0,s.default)(t);if(e){var i=(0,s.default)(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return(0,o.default)(this,r)}}var u=function(t){(0,i.default)(o,t);var e=a(o);function o(t,n,i){var s;return(0,r.default)(this,o),(s=e.call(this)).socket=new window.WebSocket(t,i),s.socket.onopen=function(){return s.emit("open")},s.socket.onmessage=function(t){return s.emit("message",t.data)},s.socket.onerror=function(t){return s.emit("error",t)},s.socket.onclose=function(t){s.emit("close",t.code,t.reason)},s}return(0,n.default)(o,[{key:"send",value:function(t,e,r){var n=r||e;try{this.socket.send(t),n()}catch(t){n(t)}}},{key:"close",value:function(t,e){this.socket.close(t,e)}},{key:"addEventListener",value:function(t,e,r){this.socket.addEventListener(t,e,r)}}]),o}(Vi().EventEmitter)}(Hi);var $i=e(Hi);const[Gi,Zi,Yi]=[[],[],[]],Ji=BigInt(0),Xi=BigInt(1),Qi=BigInt(2),to=BigInt(7),eo=BigInt(256),ro=BigInt(113);for(let t=0,e=Xi,r=1,n=0;t<24;t++){[r,n]=[n,(2*r+3*n)%5],Gi.push(2*(5*n+r)),Zi.push((t+1)*(t+2)/2%64);let i=Ji;for(let t=0;t<7;t++)e=(e<<Xi^(e>>to)*ro)%eo,e&Qi&&(i^=Xi<<(Xi<<BigInt(t))-Xi);Yi.push(i)}const[no,io]=L(Yi,!0),oo=(t,e,r)=>r>32?C(t,e,r):O(t,e,r),so=(t,e,r)=>r>32?N(t,e,r):U(t,e,r);class ao extends A{constructor(t,e,r,n=!1,i=24){if(super(),this.blockLen=t,this.suffix=e,this.outputLen=r,this.enableXOF=n,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,y(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");var o;this.state=new Uint8Array(200),this.state32=(o=this.state,new Uint32Array(o.buffer,o.byteOffset,Math.floor(o.byteLength/4)))}keccak(){!function(t,e=24){const r=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let e=0;e<10;e++)r[e]=t[e]^t[e+10]^t[e+20]^t[e+30]^t[e+40];for(let e=0;e<10;e+=2){const n=(e+8)%10,i=(e+2)%10,o=r[i],s=r[i+1],a=oo(o,s,1)^r[n],u=so(o,s,1)^r[n+1];for(let r=0;r<50;r+=10)t[e+r]^=a,t[e+r+1]^=u}let e=t[2],i=t[3];for(let r=0;r<24;r++){const n=Zi[r],o=oo(e,i,n),s=so(e,i,n),a=Gi[r];e=t[a],i=t[a+1],t[a]=o,t[a+1]=s}for(let e=0;e<50;e+=10){for(let n=0;n<10;n++)r[n]=t[e+n];for(let n=0;n<10;n++)t[e+n]^=~r[(n+2)%10]&r[(n+4)%10]}t[0]^=no[n],t[1]^=io[n]}r.fill(0)}(this.state32,this.rounds),this.posOut=0,this.pos=0}update(t){m(this);const{blockLen:e,state:r}=this,n=(t=x(t)).length;for(let i=0;i<n;){const o=Math.min(e-this.pos,n-i);for(let e=0;e<o;e++)r[this.pos++]^=t[i++];this.pos===e&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:e,pos:r,blockLen:n}=this;t[r]^=e,0!=(128&e)&&r===n-1&&this.keccak(),t[n-1]^=128,this.keccak()}writeInto(t){m(this,!1),g(t),this.finish();const e=this.state,{blockLen:r}=this;for(let n=0,i=t.length;n<i;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,i-n);t.set(e.subarray(this.posOut,this.posOut+o),n),this.posOut+=o,n+=o}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return y(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(w(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:e,suffix:r,outputLen:n,rounds:i,enableXOF:o}=this;return t||(t=new ao(e,r,n,o,i)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=i,t.suffix=r,t.outputLen=n,t.enableXOF=o,t.destroyed=this.destroyed,t}}const uo=((t,e,r)=>I((()=>new ao(e,t,r))))(1,136,32);const{bytesToNumberBE:co,hexToBytes:ho}=dt,lo={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(t){const{Err:e}=lo;if(t.length<2||2!==t[0])throw new e("Invalid signature integer tag");const r=t[1],n=t.subarray(2,r+2);if(!r||n.length!==r)throw new e("Invalid signature integer: wrong length");if(128&n[0])throw new e("Invalid signature integer: negative");if(0===n[0]&&!(128&n[1]))throw new e("Invalid signature integer: unnecessary leading zero");return{d:co(n),l:t.subarray(r+2)}},toSig(t){const{Err:e}=lo,r="string"==typeof t?ho(t):t;if(!(r instanceof Uint8Array))throw new Error("ui8a expected");let n=r.length;if(n<2||48!=r[0])throw new e("Invalid signature tag");if(r[1]!==n-2)throw new e("Invalid signature: incorrect length");const{d:i,l:o}=lo._parseInt(r.subarray(2)),{d:s,l:a}=lo._parseInt(o);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:i,s:s}},hexFromSig(t){const e=t=>8&Number.parseInt(t[0],16)?"00"+t:t,r=t=>{const e=t.toString(16);return 1&e.length?`0${e}`:e},n=e(r(t.s)),i=e(r(t.r)),o=n.length/2,s=i.length/2,a=r(o),u=r(s);return`30${r(s+o+4)}02${u}${i}02${a}${n}`}},fo=BigInt(0),po=BigInt(1);BigInt(2);const yo=BigInt(3);function go(t){const e=
|
|
19
19
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
20
|
-
function(t){const e=Lt(t);ft(e,{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}=e;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({...e})}(t),{Fp:r}=e,n=e.toBytes||((t,e,n)=>{const i=e.toAffine();return st(Uint8Array.from([4]),r.toBytes(i.x),r.toBytes(i.y))}),i=e.fromBytes||(t=>{const e=t.subarray(1);return{x:r.fromBytes(e.subarray(0,r.BYTES)),y:r.fromBytes(e.subarray(r.BYTES,2*r.BYTES))}});function o(t){const{a:n,b:i}=e,o=r.sqr(t),s=r.mul(o,t);return r.add(r.add(s,r.mul(t,n)),i)}if(!r.eql(r.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function s(t){return"bigint"==typeof t&&fo<t&&t<e.n}function a(t){if(!s(t))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function u(t){const{allowedPrivateKeyLengths:r,nByteLength:n,wrapPrivateKey:i,n:o}=e;if(r&&"bigint"!=typeof t){if(t instanceof Uint8Array&&(t=J(t)),"string"!=typeof t||!r.includes(t.length))throw new Error("Invalid key");t=t.padStart(2*n,"0")}let s;try{s="bigint"==typeof t?t:et(ot("private key",t,n))}catch(e){throw new Error(`private key must be ${n} bytes, hex or bigint, not ${typeof t}`)}return i&&(s=_t(s,o)),a(s),s}const c=new Map;function h(t){if(!(t instanceof l))throw new Error("ProjectivePoint expected")}class l{constructor(t,e,n){if(this.px=t,this.py=e,this.pz=n,null==t||!r.isValid(t))throw new Error("x required");if(null==e||!r.isValid(e))throw new Error("y required");if(null==n||!r.isValid(n))throw new Error("z required")}static fromAffine(t){const{x:e,y:n}=t||{};if(!t||!r.isValid(e)||!r.isValid(n))throw new Error("invalid affine point");if(t instanceof l)throw new Error("projective point not allowed");const i=t=>r.eql(t,r.ZERO);return i(e)&&i(n)?l.ZERO:new l(e,n,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(t){const e=r.invertBatch(t.map((t=>t.pz)));return t.map(((t,r)=>t.toAffine(e[r]))).map(l.fromAffine)}static fromHex(t){const e=l.fromAffine(i(ot("pointHex",t)));return e.assertValidity(),e}static fromPrivateKey(t){return l.BASE.multiply(u(t))}_setWindowSize(t){this._WINDOW_SIZE=t,c.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!r.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:t,y:n}=this.toAffine();if(!r.isValid(t)||!r.isValid(n))throw new Error("bad point: x or y not FE");const i=r.sqr(n),s=o(t);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:t}=this.toAffine();if(r.isOdd)return!r.isOdd(t);throw new Error("Field doesn't support isOdd")}equals(t){h(t);const{px:e,py:n,pz:i}=this,{px:o,py:s,pz:a}=t,u=r.eql(r.mul(e,a),r.mul(o,i)),c=r.eql(r.mul(n,a),r.mul(s,i));return u&&c}negate(){return new l(this.px,r.neg(this.py),this.pz)}double(){const{a:t,b:n}=e,i=r.mul(n,yo),{px:o,py:s,pz:a}=this;let u=r.ZERO,c=r.ZERO,h=r.ZERO,f=r.mul(o,o),d=r.mul(s,s),p=r.mul(a,a),y=r.mul(o,s);return y=r.add(y,y),h=r.mul(o,a),h=r.add(h,h),u=r.mul(t,h),c=r.mul(i,p),c=r.add(u,c),u=r.sub(d,c),c=r.add(d,c),c=r.mul(u,c),u=r.mul(y,u),h=r.mul(i,h),p=r.mul(t,p),y=r.sub(f,p),y=r.mul(t,y),y=r.add(y,h),h=r.add(f,f),f=r.add(h,f),f=r.add(f,p),f=r.mul(f,y),c=r.add(c,f),p=r.mul(s,a),p=r.add(p,p),f=r.mul(p,y),u=r.sub(u,f),h=r.mul(p,d),h=r.add(h,h),h=r.add(h,h),new l(u,c,h)}add(t){h(t);const{px:n,py:i,pz:o}=this,{px:s,py:a,pz:u}=t;let c=r.ZERO,f=r.ZERO,d=r.ZERO;const p=e.a,y=r.mul(e.b,yo);let g=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(g,m),b=r.sub(b,v),v=r.add(n,o);let _=r.add(s,u);return v=r.mul(v,_),_=r.add(g,w),v=r.sub(v,_),_=r.add(i,o),c=r.add(a,u),_=r.mul(_,c),c=r.add(m,w),_=r.sub(_,c),d=r.mul(p,v),c=r.mul(y,w),d=r.add(c,d),c=r.sub(m,d),d=r.add(m,d),f=r.mul(c,d),m=r.add(g,g),m=r.add(m,g),w=r.mul(p,w),v=r.mul(y,v),m=r.add(m,w),w=r.sub(g,w),w=r.mul(p,w),v=r.add(v,w),g=r.mul(m,v),f=r.add(f,g),g=r.mul(_,v),c=r.mul(b,c),c=r.sub(c,g),g=r.mul(b,m),d=r.mul(_,d),d=r.add(d,g),new l(c,f,d)}subtract(t){return this.add(t.negate())}is0(){return this.equals(l.ZERO)}wNAF(t){return d.wNAFCached(this,c,t,(t=>{const e=r.invertBatch(t.map((t=>t.pz)));return t.map(((t,r)=>t.toAffine(e[r]))).map(l.fromAffine)}))}multiplyUnsafe(t){const n=l.ZERO;if(t===fo)return n;if(a(t),t===po)return this;const{endo:i}=e;if(!i)return d.unsafeLadder(this,t);let{k1neg:o,k1:s,k2neg:u,k2:c}=i.splitScalar(t),h=n,f=n,p=this;for(;s>fo||c>fo;)s&po&&(h=h.add(p)),c&po&&(f=f.add(p)),p=p.double(),s>>=po,c>>=po;return o&&(h=h.negate()),u&&(f=f.negate()),f=new l(r.mul(f.px,i.beta),f.py,f.pz),h.add(f)}multiply(t){a(t);let n,i,o=t;const{endo:s}=e;if(s){const{k1neg:t,k1:e,k2neg:a,k2:u}=s.splitScalar(o);let{p:c,f:h}=this.wNAF(e),{p:f,f:p}=this.wNAF(u);c=d.constTimeNegate(t,c),f=d.constTimeNegate(a,f),f=new l(r.mul(f.px,s.beta),f.py,f.pz),n=c.add(f),i=h.add(p)}else{const{p:t,f:e}=this.wNAF(o);n=t,i=e}return l.normalizeZ([n,i])[0]}multiplyAndAddUnsafe(t,e,r){const n=l.BASE,i=(t,e)=>e!==fo&&e!==po&&t.equals(n)?t.multiply(e):t.multiplyUnsafe(e),o=i(this,e).add(i(t,r));return o.is0()?void 0:o}toAffine(t){const{px:e,py:n,pz:i}=this,o=this.is0();null==t&&(t=o?r.ONE:r.inv(i));const s=r.mul(e,t),a=r.mul(n,t),u=r.mul(i,t);if(o)return{x:r.ZERO,y:r.ZERO};if(!r.eql(u,r.ONE))throw new Error("invZ was invalid");return{x:s,y:a}}isTorsionFree(){const{h:t,isTorsionFree:r}=e;if(t===po)return!0;if(r)return r(l,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:t,clearCofactor:r}=e;return t===po?this:r?r(l,this):this.multiplyUnsafe(e.h)}toRawBytes(t=!0){return this.assertValidity(),n(l,this,t)}toHex(t=!0){return J(this.toRawBytes(t))}}l.BASE=new l(e.Gx,e.Gy,r.ONE),l.ZERO=new l(r.ZERO,r.ONE,r.ZERO);const f=e.nBitLength,d=Ot(l,e.endo?Math.ceil(f/2):f);return{CURVE:e,ProjectivePoint:l,normPrivateKeyToScalar:u,weierstrassEquation:o,isWithinCurveOrder:s}}function mo(t){const e=function(t){const e=Lt(t);return ft(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}(t),{Fp:r,n:n}=e,i=r.BYTES+1,o=2*r.BYTES+1;function s(t){return _t(t,n)}function a(t){return xt(t,n)}const{ProjectivePoint:u,normPrivateKeyToScalar:c,weierstrassEquation:h,isWithinCurveOrder:l}=go({...e,toBytes(t,e,n){const i=e.toAffine(),o=r.toBytes(i.x),s=st;return n?s(Uint8Array.from([e.hasEvenY()?2:3]),o):s(Uint8Array.from([4]),o,r.toBytes(i.y))},fromBytes(t){const e=t.length,n=t[0],s=t.subarray(1);if(e!==i||2!==n&&3!==n){if(e===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 ${e} was invalid. Expected ${i} compressed bytes or ${o} uncompressed bytes`)}{const t=et(s);if(!(fo<(a=t)&&a<r.ORDER))throw new Error("Point is not on curve");const e=h(t);let i=r.sqrt(e);return 1==(1&n)!==((i&po)===po)&&(i=r.neg(i)),{x:t,y:i}}var a}}),f=t=>J(nt(t,e.nByteLength));function d(t){return t>n>>po}const p=(t,e,r)=>et(t.slice(e,r));class y{constructor(t,e,r){this.r=t,this.s=e,this.recovery=r,this.assertValidity()}static fromCompact(t){const r=e.nByteLength;return t=ot("compactSignature",t,2*r),new y(p(t,0,r),p(t,r,2*r))}static fromDER(t){const{r:e,s:r}=lo.toSig(ot("DER",t));return new y(e,r)}assertValidity(){if(!l(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!l(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(t){return new y(this.r,this.s,t)}recoverPublicKey(t){const{r:n,s:i,recovery:o}=this,c=b(ot("msgHash",t));if(null==o||![0,1,2,3].includes(o))throw new Error("recovery id invalid");const h=2===o||3===o?n+e.n:n;if(h>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");const l=0==(1&o)?"02":"03",d=u.fromHex(l+f(h)),p=a(h),y=s(-c*p),g=s(i*p),m=u.BASE.multiplyAndAddUnsafe(d,y,g);if(!m)throw new Error("point at infinify");return m.assertValidity(),m}hasHighS(){return d(this.s)}normalizeS(){return this.hasHighS()?new y(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return tt(this.toDERHex())}toDERHex(){return lo.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return tt(this.toCompactHex())}toCompactHex(){return f(this.r)+f(this.s)}}const g={isValidPrivateKey(t){try{return c(t),!0}catch(t){return!1}},normPrivateKeyToScalar:c,randomPrivateKey:()=>{const t=Rt(e.n);return function(t,e,r=!1){const n=t.length,i=Mt(e),o=Rt(e);if(n<16||n<o||n>1024)throw new Error(`expected ${o}-1024 bytes of input, got ${n}`);const s=_t(r?et(t):rt(t),e-yt)+yt;return r?it(s,i):nt(s,i)}(e.randomBytes(t),e.n)},precompute:(t=8,e=u.BASE)=>(e._setWindowSize(t),e.multiply(BigInt(3)),e)};function m(t){const e=t instanceof Uint8Array,r="string"==typeof t,n=(e||r)&&t.length;return e?n===i||n===o:r?n===2*i||n===2*o:t instanceof u}const w=e.bits2int||function(t){const r=et(t),n=8*t.length-e.nBitLength;return n>0?r>>BigInt(n):r},b=e.bits2int_modN||function(t){return s(w(t))},v=at(e.nBitLength);function _(t){if("bigint"!=typeof t)throw new Error("bigint expected");if(!(fo<=t&&t<v))throw new Error(`bigint expected < 2^${e.nBitLength}`);return nt(t,e.nByteLength)}function k(t,n,i=E){if(["recovered","canonical"].some((t=>t in i)))throw new Error("sign() legacy options not supported");const{hash:o,randomBytes:h}=e;let{lowS:f,prehash:p,extraEntropy:g}=i;null==f&&(f=!0),t=ot("msgHash",t),p&&(t=ot("prehashed msgHash",o(t)));const m=b(t),v=c(n),k=[_(v),_(m)];if(null!=g){const t=!0===g?h(r.BYTES):g;k.push(ot("extraEntropy",t))}const x=st(...k),S=m;return{seed:x,k2sig:function(t){const e=w(t);if(!l(e))return;const r=a(e),n=u.BASE.multiply(e).toAffine(),i=s(n.x);if(i===fo)return;const o=s(r*s(S+i*v));if(o===fo)return;let c=(n.x===i?0:2)|Number(n.y&po),h=o;return f&&d(o)&&(h=function(t){return d(t)?s(-t):t}(o),c^=1),new y(i,h,c)}}}const E={lowS:e.lowS,prehash:!1},x={lowS:e.lowS,prehash:!1};return u.BASE._setWindowSize(8),{CURVE:e,getPublicKey:function(t,e=!0){return u.fromPrivateKey(t).toRawBytes(e)},getSharedSecret:function(t,e,r=!0){if(m(t))throw new Error("first arg must be private key");if(!m(e))throw new Error("second arg must be public key");return u.fromHex(e).multiply(c(t)).toRawBytes(r)},sign:function(t,r,n=E){const{seed:i,k2sig:o}=k(t,r,n),s=e;return ht(s.hash.outputLen,s.nByteLength,s.hmac)(i,o)},verify:function(t,r,n,i=x){const o=t;if(r=ot("msgHash",r),n=ot("publicKey",n),"strict"in i)throw new Error("options.strict was renamed to lowS");const{lowS:c,prehash:h}=i;let l,f;try{if("string"==typeof o||o instanceof Uint8Array)try{l=y.fromDER(o)}catch(t){if(!(t instanceof lo.Err))throw t;l=y.fromCompact(o)}else{if("object"!=typeof o||"bigint"!=typeof o.r||"bigint"!=typeof o.s)throw new Error("PARSE");{const{r:t,s:e}=o;l=new y(t,e)}}f=u.fromHex(n)}catch(t){if("PARSE"===t.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(c&&l.hasHighS())return!1;h&&(r=e.hash(r));const{r:d,s:p}=l,g=b(r),m=a(p),w=s(g*m),v=s(d*m),_=u.BASE.multiplyAndAddUnsafe(f,w,v)?.toAffine();return!!_&&s(_.x)===d},ProjectivePoint:u,Signature:y,utils:g}}BigInt(4);class wo extends A{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,function(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");y(t.outputLen),y(t.blockLen)}(t);const r=x(e);if(this.iHash=t.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?t.create().update(r).digest():r);for(let t=0;t<i.length;t++)i[t]^=54;this.iHash.update(i),this.oHash=t.create();for(let t=0;t<i.length;t++)i[t]^=106;this.oHash.update(i),i.fill(0)}update(t){return m(this),this.iHash.update(t),this}digestInto(t){m(this),g(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:r,finished:n,destroyed:i,blockLen:o,outputLen:s}=this;return t.finished=n,t.destroyed=i,t.blockLen=o,t.outputLen=s,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const bo=(t,e,r)=>new wo(t,e).update(r).digest();
|
|
20
|
+
function(t){const e=Ot(t);ft(e,{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}=e;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({...e})}(t),{Fp:r}=e,n=e.toBytes||((t,e,n)=>{const i=e.toAffine();return st(Uint8Array.from([4]),r.toBytes(i.x),r.toBytes(i.y))}),i=e.fromBytes||(t=>{const e=t.subarray(1);return{x:r.fromBytes(e.subarray(0,r.BYTES)),y:r.fromBytes(e.subarray(r.BYTES,2*r.BYTES))}});function o(t){const{a:n,b:i}=e,o=r.sqr(t),s=r.mul(o,t);return r.add(r.add(s,r.mul(t,n)),i)}if(!r.eql(r.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function s(t){return"bigint"==typeof t&&fo<t&&t<e.n}function a(t){if(!s(t))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function u(t){const{allowedPrivateKeyLengths:r,nByteLength:n,wrapPrivateKey:i,n:o}=e;if(r&&"bigint"!=typeof t){if(t instanceof Uint8Array&&(t=J(t)),"string"!=typeof t||!r.includes(t.length))throw new Error("Invalid key");t=t.padStart(2*n,"0")}let s;try{s="bigint"==typeof t?t:et(ot("private key",t,n))}catch(e){throw new Error(`private key must be ${n} bytes, hex or bigint, not ${typeof t}`)}return i&&(s=_t(s,o)),a(s),s}const c=new Map;function h(t){if(!(t instanceof l))throw new Error("ProjectivePoint expected")}class l{constructor(t,e,n){if(this.px=t,this.py=e,this.pz=n,null==t||!r.isValid(t))throw new Error("x required");if(null==e||!r.isValid(e))throw new Error("y required");if(null==n||!r.isValid(n))throw new Error("z required")}static fromAffine(t){const{x:e,y:n}=t||{};if(!t||!r.isValid(e)||!r.isValid(n))throw new Error("invalid affine point");if(t instanceof l)throw new Error("projective point not allowed");const i=t=>r.eql(t,r.ZERO);return i(e)&&i(n)?l.ZERO:new l(e,n,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(t){const e=r.invertBatch(t.map((t=>t.pz)));return t.map(((t,r)=>t.toAffine(e[r]))).map(l.fromAffine)}static fromHex(t){const e=l.fromAffine(i(ot("pointHex",t)));return e.assertValidity(),e}static fromPrivateKey(t){return l.BASE.multiply(u(t))}_setWindowSize(t){this._WINDOW_SIZE=t,c.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!r.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:t,y:n}=this.toAffine();if(!r.isValid(t)||!r.isValid(n))throw new Error("bad point: x or y not FE");const i=r.sqr(n),s=o(t);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:t}=this.toAffine();if(r.isOdd)return!r.isOdd(t);throw new Error("Field doesn't support isOdd")}equals(t){h(t);const{px:e,py:n,pz:i}=this,{px:o,py:s,pz:a}=t,u=r.eql(r.mul(e,a),r.mul(o,i)),c=r.eql(r.mul(n,a),r.mul(s,i));return u&&c}negate(){return new l(this.px,r.neg(this.py),this.pz)}double(){const{a:t,b:n}=e,i=r.mul(n,yo),{px:o,py:s,pz:a}=this;let u=r.ZERO,c=r.ZERO,h=r.ZERO,f=r.mul(o,o),d=r.mul(s,s),p=r.mul(a,a),y=r.mul(o,s);return y=r.add(y,y),h=r.mul(o,a),h=r.add(h,h),u=r.mul(t,h),c=r.mul(i,p),c=r.add(u,c),u=r.sub(d,c),c=r.add(d,c),c=r.mul(u,c),u=r.mul(y,u),h=r.mul(i,h),p=r.mul(t,p),y=r.sub(f,p),y=r.mul(t,y),y=r.add(y,h),h=r.add(f,f),f=r.add(h,f),f=r.add(f,p),f=r.mul(f,y),c=r.add(c,f),p=r.mul(s,a),p=r.add(p,p),f=r.mul(p,y),u=r.sub(u,f),h=r.mul(p,d),h=r.add(h,h),h=r.add(h,h),new l(u,c,h)}add(t){h(t);const{px:n,py:i,pz:o}=this,{px:s,py:a,pz:u}=t;let c=r.ZERO,f=r.ZERO,d=r.ZERO;const p=e.a,y=r.mul(e.b,yo);let g=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(g,m),b=r.sub(b,v),v=r.add(n,o);let _=r.add(s,u);return v=r.mul(v,_),_=r.add(g,w),v=r.sub(v,_),_=r.add(i,o),c=r.add(a,u),_=r.mul(_,c),c=r.add(m,w),_=r.sub(_,c),d=r.mul(p,v),c=r.mul(y,w),d=r.add(c,d),c=r.sub(m,d),d=r.add(m,d),f=r.mul(c,d),m=r.add(g,g),m=r.add(m,g),w=r.mul(p,w),v=r.mul(y,v),m=r.add(m,w),w=r.sub(g,w),w=r.mul(p,w),v=r.add(v,w),g=r.mul(m,v),f=r.add(f,g),g=r.mul(_,v),c=r.mul(b,c),c=r.sub(c,g),g=r.mul(b,m),d=r.mul(_,d),d=r.add(d,g),new l(c,f,d)}subtract(t){return this.add(t.negate())}is0(){return this.equals(l.ZERO)}wNAF(t){return d.wNAFCached(this,c,t,(t=>{const e=r.invertBatch(t.map((t=>t.pz)));return t.map(((t,r)=>t.toAffine(e[r]))).map(l.fromAffine)}))}multiplyUnsafe(t){const n=l.ZERO;if(t===fo)return n;if(a(t),t===po)return this;const{endo:i}=e;if(!i)return d.unsafeLadder(this,t);let{k1neg:o,k1:s,k2neg:u,k2:c}=i.splitScalar(t),h=n,f=n,p=this;for(;s>fo||c>fo;)s&po&&(h=h.add(p)),c&po&&(f=f.add(p)),p=p.double(),s>>=po,c>>=po;return o&&(h=h.negate()),u&&(f=f.negate()),f=new l(r.mul(f.px,i.beta),f.py,f.pz),h.add(f)}multiply(t){a(t);let n,i,o=t;const{endo:s}=e;if(s){const{k1neg:t,k1:e,k2neg:a,k2:u}=s.splitScalar(o);let{p:c,f:h}=this.wNAF(e),{p:f,f:p}=this.wNAF(u);c=d.constTimeNegate(t,c),f=d.constTimeNegate(a,f),f=new l(r.mul(f.px,s.beta),f.py,f.pz),n=c.add(f),i=h.add(p)}else{const{p:t,f:e}=this.wNAF(o);n=t,i=e}return l.normalizeZ([n,i])[0]}multiplyAndAddUnsafe(t,e,r){const n=l.BASE,i=(t,e)=>e!==fo&&e!==po&&t.equals(n)?t.multiply(e):t.multiplyUnsafe(e),o=i(this,e).add(i(t,r));return o.is0()?void 0:o}toAffine(t){const{px:e,py:n,pz:i}=this,o=this.is0();null==t&&(t=o?r.ONE:r.inv(i));const s=r.mul(e,t),a=r.mul(n,t),u=r.mul(i,t);if(o)return{x:r.ZERO,y:r.ZERO};if(!r.eql(u,r.ONE))throw new Error("invZ was invalid");return{x:s,y:a}}isTorsionFree(){const{h:t,isTorsionFree:r}=e;if(t===po)return!0;if(r)return r(l,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:t,clearCofactor:r}=e;return t===po?this:r?r(l,this):this.multiplyUnsafe(e.h)}toRawBytes(t=!0){return this.assertValidity(),n(l,this,t)}toHex(t=!0){return J(this.toRawBytes(t))}}l.BASE=new l(e.Gx,e.Gy,r.ONE),l.ZERO=new l(r.ZERO,r.ONE,r.ZERO);const f=e.nBitLength,d=Lt(l,e.endo?Math.ceil(f/2):f);return{CURVE:e,ProjectivePoint:l,normPrivateKeyToScalar:u,weierstrassEquation:o,isWithinCurveOrder:s}}function mo(t){const e=function(t){const e=Ot(t);return ft(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}(t),{Fp:r,n:n}=e,i=r.BYTES+1,o=2*r.BYTES+1;function s(t){return _t(t,n)}function a(t){return xt(t,n)}const{ProjectivePoint:u,normPrivateKeyToScalar:c,weierstrassEquation:h,isWithinCurveOrder:l}=go({...e,toBytes(t,e,n){const i=e.toAffine(),o=r.toBytes(i.x),s=st;return n?s(Uint8Array.from([e.hasEvenY()?2:3]),o):s(Uint8Array.from([4]),o,r.toBytes(i.y))},fromBytes(t){const e=t.length,n=t[0],s=t.subarray(1);if(e!==i||2!==n&&3!==n){if(e===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 ${e} was invalid. Expected ${i} compressed bytes or ${o} uncompressed bytes`)}{const t=et(s);if(!(fo<(a=t)&&a<r.ORDER))throw new Error("Point is not on curve");const e=h(t);let i=r.sqrt(e);return 1==(1&n)!==((i&po)===po)&&(i=r.neg(i)),{x:t,y:i}}var a}}),f=t=>J(nt(t,e.nByteLength));function d(t){return t>n>>po}const p=(t,e,r)=>et(t.slice(e,r));class y{constructor(t,e,r){this.r=t,this.s=e,this.recovery=r,this.assertValidity()}static fromCompact(t){const r=e.nByteLength;return t=ot("compactSignature",t,2*r),new y(p(t,0,r),p(t,r,2*r))}static fromDER(t){const{r:e,s:r}=lo.toSig(ot("DER",t));return new y(e,r)}assertValidity(){if(!l(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!l(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(t){return new y(this.r,this.s,t)}recoverPublicKey(t){const{r:n,s:i,recovery:o}=this,c=b(ot("msgHash",t));if(null==o||![0,1,2,3].includes(o))throw new Error("recovery id invalid");const h=2===o||3===o?n+e.n:n;if(h>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");const l=0==(1&o)?"02":"03",d=u.fromHex(l+f(h)),p=a(h),y=s(-c*p),g=s(i*p),m=u.BASE.multiplyAndAddUnsafe(d,y,g);if(!m)throw new Error("point at infinify");return m.assertValidity(),m}hasHighS(){return d(this.s)}normalizeS(){return this.hasHighS()?new y(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return tt(this.toDERHex())}toDERHex(){return lo.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return tt(this.toCompactHex())}toCompactHex(){return f(this.r)+f(this.s)}}const g={isValidPrivateKey(t){try{return c(t),!0}catch(t){return!1}},normPrivateKeyToScalar:c,randomPrivateKey:()=>{const t=Rt(e.n);return function(t,e,r=!1){const n=t.length,i=Mt(e),o=Rt(e);if(n<16||n<o||n>1024)throw new Error(`expected ${o}-1024 bytes of input, got ${n}`);const s=_t(r?et(t):rt(t),e-yt)+yt;return r?it(s,i):nt(s,i)}(e.randomBytes(t),e.n)},precompute:(t=8,e=u.BASE)=>(e._setWindowSize(t),e.multiply(BigInt(3)),e)};function m(t){const e=t instanceof Uint8Array,r="string"==typeof t,n=(e||r)&&t.length;return e?n===i||n===o:r?n===2*i||n===2*o:t instanceof u}const w=e.bits2int||function(t){const r=et(t),n=8*t.length-e.nBitLength;return n>0?r>>BigInt(n):r},b=e.bits2int_modN||function(t){return s(w(t))},v=at(e.nBitLength);function _(t){if("bigint"!=typeof t)throw new Error("bigint expected");if(!(fo<=t&&t<v))throw new Error(`bigint expected < 2^${e.nBitLength}`);return nt(t,e.nByteLength)}function k(t,n,i=E){if(["recovered","canonical"].some((t=>t in i)))throw new Error("sign() legacy options not supported");const{hash:o,randomBytes:h}=e;let{lowS:f,prehash:p,extraEntropy:g}=i;null==f&&(f=!0),t=ot("msgHash",t),p&&(t=ot("prehashed msgHash",o(t)));const m=b(t),v=c(n),k=[_(v),_(m)];if(null!=g){const t=!0===g?h(r.BYTES):g;k.push(ot("extraEntropy",t))}const x=st(...k),S=m;return{seed:x,k2sig:function(t){const e=w(t);if(!l(e))return;const r=a(e),n=u.BASE.multiply(e).toAffine(),i=s(n.x);if(i===fo)return;const o=s(r*s(S+i*v));if(o===fo)return;let c=(n.x===i?0:2)|Number(n.y&po),h=o;return f&&d(o)&&(h=function(t){return d(t)?s(-t):t}(o),c^=1),new y(i,h,c)}}}const E={lowS:e.lowS,prehash:!1},x={lowS:e.lowS,prehash:!1};return u.BASE._setWindowSize(8),{CURVE:e,getPublicKey:function(t,e=!0){return u.fromPrivateKey(t).toRawBytes(e)},getSharedSecret:function(t,e,r=!0){if(m(t))throw new Error("first arg must be private key");if(!m(e))throw new Error("second arg must be public key");return u.fromHex(e).multiply(c(t)).toRawBytes(r)},sign:function(t,r,n=E){const{seed:i,k2sig:o}=k(t,r,n),s=e;return ht(s.hash.outputLen,s.nByteLength,s.hmac)(i,o)},verify:function(t,r,n,i=x){const o=t;if(r=ot("msgHash",r),n=ot("publicKey",n),"strict"in i)throw new Error("options.strict was renamed to lowS");const{lowS:c,prehash:h}=i;let l,f;try{if("string"==typeof o||o instanceof Uint8Array)try{l=y.fromDER(o)}catch(t){if(!(t instanceof lo.Err))throw t;l=y.fromCompact(o)}else{if("object"!=typeof o||"bigint"!=typeof o.r||"bigint"!=typeof o.s)throw new Error("PARSE");{const{r:t,s:e}=o;l=new y(t,e)}}f=u.fromHex(n)}catch(t){if("PARSE"===t.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(c&&l.hasHighS())return!1;h&&(r=e.hash(r));const{r:d,s:p}=l,g=b(r),m=a(p),w=s(g*m),v=s(d*m),_=u.BASE.multiplyAndAddUnsafe(f,w,v)?.toAffine();return!!_&&s(_.x)===d},ProjectivePoint:u,Signature:y,utils:g}}BigInt(4);class wo extends A{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,function(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");y(t.outputLen),y(t.blockLen)}(t);const r=x(e);if(this.iHash=t.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?t.create().update(r).digest():r);for(let t=0;t<i.length;t++)i[t]^=54;this.iHash.update(i),this.oHash=t.create();for(let t=0;t<i.length;t++)i[t]^=106;this.oHash.update(i),i.fill(0)}update(t){return m(this),this.iHash.update(t),this}digestInto(t){m(this),g(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:r,finished:n,destroyed:i,blockLen:o,outputLen:s}=this;return t.finished=n,t.destroyed=i,t.blockLen=o,t.outputLen=s,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const bo=(t,e,r)=>new wo(t,e).update(r).digest();
|
|
21
21
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
22
22
|
function vo(t){return{hash:t,hmac:(e,...r)=>bo(t,e,S(...r)),randomBytes:B}}bo.create=(t,e)=>new wo(t,e);
|
|
23
23
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
24
|
-
const _o=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),ko=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Eo=BigInt(1),xo=BigInt(2),So=(t,e)=>(t+e/xo)/e;const Ao=Bt(_o,void 0,void 0,{sqrt:function(t){const e=_o,r=BigInt(3),n=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),a=BigInt(44),u=BigInt(88),c=t*t*t%e,h=c*c*t%e,l=Et(h,r,e)*h%e,f=Et(l,r,e)*h%e,d=Et(f,xo,e)*c%e,p=Et(d,i,e)*d%e,y=Et(p,o,e)*p%e,g=Et(y,a,e)*y%e,m=Et(g,u,e)*g%e,w=Et(m,a,e)*y%e,b=Et(w,r,e)*h%e,v=Et(b,s,e)*p%e,_=Et(v,n,e)*c%e,k=Et(_,xo,e);if(!Ao.eql(Ao.sqr(k),t))throw new Error("Cannot find square root");return k}}),Io=function(t,e){const r=e=>mo({...t,...vo(e)});return Object.freeze({...r(e),create:r})}({a:BigInt(0),b:BigInt(7),Fp:Ao,n:ko,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=ko,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Eo*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=r,s=BigInt("0x100000000000000000000000000000000"),a=So(o*t,e),u=So(-n*t,e);let c=_t(t-a*r-u*i,e),h=_t(-a*n-u*o,e);const l=c>s,f=h>s;if(l&&(c=e-c),f&&(h=e-h),c>s||h>s)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:l,k1:c,k2neg:f,k2:h}}}},pe);BigInt(0),Io.ProjectivePoint;const Bo=Xt.utils.randomPrivateKey,Mo=()=>{const t=Xt.utils.randomPrivateKey(),e=Ro(t),r=new Uint8Array(64);return r.set(t),r.set(e,32),{publicKey:e,secretKey:r}},Ro=Xt.getPublicKey;function Po(t){try{return Xt.ExtendedPoint.fromHex(t),!0}catch{return!1}}const To=(t,e)=>Xt.sign(t,e.slice(0,32)),Oo=Xt.verify,Lo=t=>n.Buffer.isBuffer(t)?t:t instanceof Uint8Array?n.Buffer.from(t.buffer,t.byteOffset,t.byteLength):n.Buffer.from(t);class Uo{constructor(t){Object.assign(this,t)}encode(){return n.Buffer.from(He(Co,this))}static decode(t){return Ze(Co,this,t)}static decodeUnchecked(t){return Oe(Co,this,t)}}const Co=new Map;var No;let zo;const Do=32;let jo=1;zo=Symbol.toStringTag;class Wo extends Uo{constructor(t){if(super({}),this._bn=void 0,function(t){return void 0!==t._bn}(t))this._bn=t._bn;else{if("string"==typeof t){const e=ae.decode(t);if(e.length!=Do)throw new Error("Invalid public key input");this._bn=new ne(e)}else this._bn=new ne(t);if(this._bn.byteLength()>Do)throw new Error("Invalid public key input")}}static unique(){const t=new Wo(jo);return jo+=1,new Wo(t.toBuffer())}equals(t){return this._bn.eq(t._bn)}toBase58(){return ae.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){const t=this.toBuffer();return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}toBuffer(){const t=this._bn.toArrayLike(n.Buffer);if(t.length===Do)return t;const e=n.Buffer.alloc(32);return t.copy(e,32-t.length),e}get[zo](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(t,e,r){const i=n.Buffer.concat([t.toBuffer(),n.Buffer.from(e),r.toBuffer()]),o=pe(i);return new Wo(o)}static createProgramAddressSync(t,e){let r=n.Buffer.alloc(0);t.forEach((function(t){if(t.length>32)throw new TypeError("Max seed length exceeded");r=n.Buffer.concat([r,Lo(t)])})),r=n.Buffer.concat([r,e.toBuffer(),n.Buffer.from("ProgramDerivedAddress")]);const i=pe(r);if(Po(i))throw new Error("Invalid seeds, address must fall off the curve");return new Wo(i)}static async createProgramAddress(t,e){return this.createProgramAddressSync(t,e)}static findProgramAddressSync(t,e){let r,i=255;for(;0!=i;){try{const o=t.concat(n.Buffer.from([i]));r=this.createProgramAddressSync(o,e)}catch(t){if(t instanceof TypeError)throw t;i--;continue}return[r,i]}throw new Error("Unable to find a viable program address nonce")}static async findProgramAddress(t,e){return this.findProgramAddressSync(t,e)}static isOnCurve(t){return Po(new Wo(t).toBytes())}}No=Wo,Wo.default=new No("11111111111111111111111111111111"),Co.set(Wo,{kind:"struct",fields:[["_bn","u256"]]});const Ko=new Wo("BPFLoader1111111111111111111111111111111111"),Fo=1232,qo=127,Vo=64;class Ho extends Error{constructor(t){super(`Signature ${t} has expired: block height exceeded.`),this.signature=void 0,this.signature=t}}Object.defineProperty(Ho.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});class $o extends Error{constructor(t,e){super(`Transaction was not confirmed in ${e.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${t} using the Solana Explorer or CLI tools.`),this.signature=void 0,this.signature=t}}Object.defineProperty($o.prototype,"name",{value:"TransactionExpiredTimeoutError"});class Go extends Error{constructor(t){super(`Signature ${t} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=t}}Object.defineProperty(Go.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});class Zo{constructor(t,e){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=t,this.accountKeysFromLookups=e}keySegments(){const t=[this.staticAccountKeys];return this.accountKeysFromLookups&&(t.push(this.accountKeysFromLookups.writable),t.push(this.accountKeysFromLookups.readonly)),t}get(t){for(const e of this.keySegments()){if(t<e.length)return e[t];t-=e.length}}get length(){return this.keySegments().flat().length}compileInstructions(t){if(this.length>256)throw new Error("Account index overflow encountered during compilation");const e=new Map;this.keySegments().flat().forEach(((t,r)=>{e.set(t.toBase58(),r)}));const r=t=>{const r=e.get(t.toBase58());if(void 0===r)throw new Error("Encountered an unknown instruction account key during compilation");return r};return t.map((t=>({programIdIndex:r(t.programId),accountKeyIndexes:t.keys.map((t=>r(t.pubkey))),data:t.data})))}}const Yo=(t="publicKey")=>Kr(32,t),Jo=(t="signature")=>Kr(64,t),Xo=(t="string")=>{const e=jr([Nr("length"),Nr("lengthPadding"),Kr(Lr(Nr(),-8),"chars")],t),r=e.decode.bind(e),i=e.encode.bind(e),o=e;return o.decode=(t,e)=>r(t,e).chars.toString(),o.encode=(t,e,r)=>{const o={chars:n.Buffer.from(t,"utf8")};return i(o,e,r)},o.alloc=t=>Nr().span+Nr().span+n.Buffer.from(t,"utf8").length,o};function Qo(t,e){const r=t=>{if(t.span>=0)return t.span;if("function"==typeof t.alloc)return t.alloc(e[t.property]);if("count"in t&&"elementLayout"in t){const n=e[t.property];if(Array.isArray(n))return n.length*r(t.elementLayout)}else if("fields"in t)return Qo({layout:t},e[t.property]);return 0};let n=0;return t.layout.fields.forEach((t=>{n+=r(t)})),n}function ts(t){let e=0,r=0;for(;;){let n=t.shift();if(e|=(127&n)<<7*r,r+=1,0==(128&n))break}return e}function es(t,e){let r=e;for(;;){let e=127&r;if(r>>=7,0==r){t.push(e);break}e|=128,t.push(e)}}function rs(t,e){if(!t)throw new Error(e||"Assertion failed")}class ns{constructor(t,e){this.payer=void 0,this.keyMetaMap=void 0,this.payer=t,this.keyMetaMap=e}static compile(t,e){const r=new Map,n=t=>{const e=t.toBase58();let n=r.get(e);return void 0===n&&(n={isSigner:!1,isWritable:!1,isInvoked:!1},r.set(e,n)),n},i=n(e);i.isSigner=!0,i.isWritable=!0;for(const e of t){n(e.programId).isInvoked=!0;for(const t of e.keys){const e=n(t.pubkey);e.isSigner||=t.isSigner,e.isWritable||=t.isWritable}}return new ns(e,r)}getMessageComponents(){const t=[...this.keyMetaMap.entries()];rs(t.length<=256,"Max static account keys length exceeded");const e=t.filter((([,t])=>t.isSigner&&t.isWritable)),r=t.filter((([,t])=>t.isSigner&&!t.isWritable)),n=t.filter((([,t])=>!t.isSigner&&t.isWritable)),i=t.filter((([,t])=>!t.isSigner&&!t.isWritable)),o={numRequiredSignatures:e.length+r.length,numReadonlySignedAccounts:r.length,numReadonlyUnsignedAccounts:i.length};{rs(e.length>0,"Expected at least one writable signer key");const[t]=e[0];rs(t===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}return[o,[...e.map((([t])=>new Wo(t))),...r.map((([t])=>new Wo(t))),...n.map((([t])=>new Wo(t))),...i.map((([t])=>new Wo(t)))]]}extractTableLookup(t){const[e,r]=this.drainKeysFoundInLookupTable(t.state.addresses,(t=>!t.isSigner&&!t.isInvoked&&t.isWritable)),[n,i]=this.drainKeysFoundInLookupTable(t.state.addresses,(t=>!t.isSigner&&!t.isInvoked&&!t.isWritable));if(0!==e.length||0!==n.length)return[{accountKey:t.key,writableIndexes:e,readonlyIndexes:n},{writable:r,readonly:i}]}drainKeysFoundInLookupTable(t,e){const r=new Array,n=new Array;for(const[i,o]of this.keyMetaMap.entries())if(e(o)){const e=new Wo(i),o=t.findIndex((t=>t.equals(e)));o>=0&&(rs(o<256,"Max lookup table index exceeded"),r.push(o),n.push(e),this.keyMetaMap.delete(i))}return[r,n]}}class is{constructor(t){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=t.header,this.accountKeys=t.accountKeys.map((t=>new Wo(t))),this.recentBlockhash=t.recentBlockhash,this.instructions=t.instructions,this.instructions.forEach((t=>this.indexToProgramIds.set(t.programIdIndex,this.accountKeys[t.programIdIndex])))}get version(){return"legacy"}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map((t=>({programIdIndex:t.programIdIndex,accountKeyIndexes:t.accounts,data:ae.decode(t.data)})))}get addressTableLookups(){return[]}getAccountKeys(){return new Zo(this.staticAccountKeys)}static compile(t){const e=ns.compile(t.instructions,t.payerKey),[r,n]=e.getMessageComponents(),i=new Zo(n).compileInstructions(t.instructions).map((t=>({programIdIndex:t.programIdIndex,accounts:t.accountKeyIndexes,data:ae.encode(t.data)})));return new is({header:r,accountKeys:n,recentBlockhash:t.recentBlockhash,instructions:i})}isAccountSigner(t){return t<this.header.numRequiredSignatures}isAccountWritable(t){const e=this.header.numRequiredSignatures;if(t>=this.header.numRequiredSignatures){return t-e<this.accountKeys.length-e-this.header.numReadonlyUnsignedAccounts}return t<e-this.header.numReadonlySignedAccounts}isProgramId(t){return this.indexToProgramIds.has(t)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter(((t,e)=>!this.isProgramId(e)))}serialize(){const t=this.accountKeys.length;let e=[];es(e,t);const r=this.instructions.map((t=>{const{accounts:e,programIdIndex:r}=t,i=Array.from(ae.decode(t.data));let o=[];es(o,e.length);let s=[];return es(s,i.length),{programIdIndex:r,keyIndicesCount:n.Buffer.from(o),keyIndices:e,dataLength:n.Buffer.from(s),data:i}}));let i=[];es(i,r.length);let o=n.Buffer.alloc(Fo);n.Buffer.from(i).copy(o);let s=i.length;r.forEach((t=>{const e=jr([Ur("programIdIndex"),Kr(t.keyIndicesCount.length,"keyIndicesCount"),Wr(Ur("keyIndex"),t.keyIndices.length,"keyIndices"),Kr(t.dataLength.length,"dataLength"),Wr(Ur("userdatum"),t.data.length,"data")]).encode(t,o,s);s+=e})),o=o.slice(0,s);const a=jr([Kr(1,"numRequiredSignatures"),Kr(1,"numReadonlySignedAccounts"),Kr(1,"numReadonlyUnsignedAccounts"),Kr(e.length,"keyCount"),Wr(Yo("key"),t,"keys"),Yo("recentBlockhash")]),u={numRequiredSignatures:n.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:n.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:n.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:n.Buffer.from(e),keys:this.accountKeys.map((t=>Lo(t.toBytes()))),recentBlockhash:ae.decode(this.recentBlockhash)};let c=n.Buffer.alloc(2048);const h=a.encode(u,c);return o.copy(c,h),c.slice(0,h+o.length)}static from(t){let e=[...t];const r=e.shift();if(r!==(r&qo))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const i=e.shift(),o=e.shift(),s=ts(e);let a=[];for(let t=0;t<s;t++){const t=e.slice(0,Do);e=e.slice(Do),a.push(new Wo(n.Buffer.from(t)))}const u=e.slice(0,Do);e=e.slice(Do);const c=ts(e);let h=[];for(let t=0;t<c;t++){const t=e.shift(),r=ts(e),i=e.slice(0,r);e=e.slice(r);const o=ts(e),s=e.slice(0,o),a=ae.encode(n.Buffer.from(s));e=e.slice(o),h.push({programIdIndex:t,accounts:i,data:a})}const l={header:{numRequiredSignatures:r,numReadonlySignedAccounts:i,numReadonlyUnsignedAccounts:o},recentBlockhash:ae.encode(n.Buffer.from(u)),accountKeys:a,instructions:h};return new is(l)}}class os{constructor(t){this.header=void 0,this.staticAccountKeys=void 0,this.recentBlockhash=void 0,this.compiledInstructions=void 0,this.addressTableLookups=void 0,this.header=t.header,this.staticAccountKeys=t.staticAccountKeys,this.recentBlockhash=t.recentBlockhash,this.compiledInstructions=t.compiledInstructions,this.addressTableLookups=t.addressTableLookups}get version(){return 0}get numAccountKeysFromLookups(){let t=0;for(const e of this.addressTableLookups)t+=e.readonlyIndexes.length+e.writableIndexes.length;return t}getAccountKeys(t){let e;if(t&&"accountKeysFromLookups"in t&&t.accountKeysFromLookups){if(this.numAccountKeysFromLookups!=t.accountKeysFromLookups.writable.length+t.accountKeysFromLookups.readonly.length)throw new Error("Failed to get account keys because of a mismatch in the number of account keys from lookups");e=t.accountKeysFromLookups}else if(t&&"addressLookupTableAccounts"in t&&t.addressLookupTableAccounts)e=this.resolveAddressTableLookups(t.addressLookupTableAccounts);else if(this.addressTableLookups.length>0)throw new Error("Failed to get account keys because address table lookups were not resolved");return new Zo(this.staticAccountKeys,e)}isAccountSigner(t){return t<this.header.numRequiredSignatures}isAccountWritable(t){const e=this.header.numRequiredSignatures,r=this.staticAccountKeys.length;if(t>=r){const e=t-r,n=this.addressTableLookups.reduce(((t,e)=>t+e.writableIndexes.length),0);return e<n}if(t>=this.header.numRequiredSignatures){return t-e<r-e-this.header.numReadonlyUnsignedAccounts}return t<e-this.header.numReadonlySignedAccounts}resolveAddressTableLookups(t){const e={writable:[],readonly:[]};for(const r of this.addressTableLookups){const n=t.find((t=>t.key.equals(r.accountKey)));if(!n)throw new Error(`Failed to find address lookup table account for table key ${r.accountKey.toBase58()}`);for(const t of r.writableIndexes){if(!(t<n.state.addresses.length))throw new Error(`Failed to find address for index ${t} in address lookup table ${r.accountKey.toBase58()}`);e.writable.push(n.state.addresses[t])}for(const t of r.readonlyIndexes){if(!(t<n.state.addresses.length))throw new Error(`Failed to find address for index ${t} in address lookup table ${r.accountKey.toBase58()}`);e.readonly.push(n.state.addresses[t])}}return e}static compile(t){const e=ns.compile(t.instructions,t.payerKey),r=new Array,n={writable:new Array,readonly:new Array},i=t.addressLookupTableAccounts||[];for(const t of i){const i=e.extractTableLookup(t);if(void 0!==i){const[t,{writable:e,readonly:o}]=i;r.push(t),n.writable.push(...e),n.readonly.push(...o)}}const[o,s]=e.getMessageComponents(),a=new Zo(s,n).compileInstructions(t.instructions);return new os({header:o,staticAccountKeys:s,recentBlockhash:t.recentBlockhash,compiledInstructions:a,addressTableLookups:r})}serialize(){const t=Array();es(t,this.staticAccountKeys.length);const e=this.serializeInstructions(),r=Array();es(r,this.compiledInstructions.length);const n=this.serializeAddressTableLookups(),i=Array();es(i,this.addressTableLookups.length);const o=jr([Ur("prefix"),jr([Ur("numRequiredSignatures"),Ur("numReadonlySignedAccounts"),Ur("numReadonlyUnsignedAccounts")],"header"),Kr(t.length,"staticAccountKeysLength"),Wr(Yo(),this.staticAccountKeys.length,"staticAccountKeys"),Yo("recentBlockhash"),Kr(r.length,"instructionsLength"),Kr(e.length,"serializedInstructions"),Kr(i.length,"addressTableLookupsLength"),Kr(n.length,"serializedAddressTableLookups")]),s=new Uint8Array(Fo),a=o.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(t),staticAccountKeys:this.staticAccountKeys.map((t=>t.toBytes())),recentBlockhash:ae.decode(this.recentBlockhash),instructionsLength:new Uint8Array(r),serializedInstructions:e,addressTableLookupsLength:new Uint8Array(i),serializedAddressTableLookups:n},s);return s.slice(0,a)}serializeInstructions(){let t=0;const e=new Uint8Array(Fo);for(const r of this.compiledInstructions){const n=Array();es(n,r.accountKeyIndexes.length);const i=Array();es(i,r.data.length);t+=jr([Ur("programIdIndex"),Kr(n.length,"encodedAccountKeyIndexesLength"),Wr(Ur(),r.accountKeyIndexes.length,"accountKeyIndexes"),Kr(i.length,"encodedDataLength"),Kr(r.data.length,"data")]).encode({programIdIndex:r.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(n),accountKeyIndexes:r.accountKeyIndexes,encodedDataLength:new Uint8Array(i),data:r.data},e,t)}return e.slice(0,t)}serializeAddressTableLookups(){let t=0;const e=new Uint8Array(Fo);for(const r of this.addressTableLookups){const n=Array();es(n,r.writableIndexes.length);const i=Array();es(i,r.readonlyIndexes.length);t+=jr([Yo("accountKey"),Kr(n.length,"encodedWritableIndexesLength"),Wr(Ur(),r.writableIndexes.length,"writableIndexes"),Kr(i.length,"encodedReadonlyIndexesLength"),Wr(Ur(),r.readonlyIndexes.length,"readonlyIndexes")]).encode({accountKey:r.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(n),writableIndexes:r.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(i),readonlyIndexes:r.readonlyIndexes},e,t)}return e.slice(0,t)}static deserialize(t){let e=[...t];const r=e.shift(),n=r&qo;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:e.shift(),numReadonlySignedAccounts:e.shift(),numReadonlyUnsignedAccounts:e.shift()},o=[],s=ts(e);for(let t=0;t<s;t++)o.push(new Wo(e.splice(0,Do)));const a=ae.encode(e.splice(0,Do)),u=ts(e),c=[];for(let t=0;t<u;t++){const t=e.shift(),r=ts(e),n=e.splice(0,r),i=ts(e),o=new Uint8Array(e.splice(0,i));c.push({programIdIndex:t,accountKeyIndexes:n,data:o})}const h=ts(e),l=[];for(let t=0;t<h;t++){const t=new Wo(e.splice(0,Do)),r=ts(e),n=e.splice(0,r),i=ts(e),o=e.splice(0,i);l.push({accountKey:t,writableIndexes:n,readonlyIndexes:o})}return new os({header:i,staticAccountKeys:o,recentBlockhash:a,compiledInstructions:c,addressTableLookups:l})}}const ss={deserializeMessageVersion(t){const e=t[0],r=e&qo;return r===e?"legacy":r},deserialize:t=>{const e=ss.deserializeMessageVersion(t);if("legacy"===e)return is.from(t);if(0===e)return os.deserialize(t);throw new Error(`Transaction message version ${e} deserialization is not supported`)}};let as=function(t){return t[t.BLOCKHEIGHT_EXCEEDED=0]="BLOCKHEIGHT_EXCEEDED",t[t.PROCESSED=1]="PROCESSED",t[t.TIMED_OUT=2]="TIMED_OUT",t[t.NONCE_INVALID=3]="NONCE_INVALID",t}({});const us=n.Buffer.alloc(Vo).fill(0);class cs{constructor(t){this.keys=void 0,this.programId=void 0,this.data=n.Buffer.alloc(0),this.programId=t.programId,this.keys=t.keys,t.data&&(this.data=t.data)}toJSON(){return{keys:this.keys.map((({pubkey:t,isSigner:e,isWritable:r})=>({pubkey:t.toJSON(),isSigner:e,isWritable:r}))),programId:this.programId.toJSON(),data:[...this.data]}}}class hs{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(t){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,t)if(t.feePayer&&(this.feePayer=t.feePayer),t.signatures&&(this.signatures=t.signatures),Object.prototype.hasOwnProperty.call(t,"nonceInfo")){const{minContextSlot:e,nonceInfo:r}=t;this.minNonceContextSlot=e,this.nonceInfo=r}else if(Object.prototype.hasOwnProperty.call(t,"lastValidBlockHeight")){const{blockhash:e,lastValidBlockHeight:r}=t;this.recentBlockhash=e,this.lastValidBlockHeight=r}else{const{recentBlockhash:e,nonceInfo:r}=t;r&&(this.nonceInfo=r),this.recentBlockhash=e}}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((t=>t.toJSON())),signers:this.signatures.map((({publicKey:t})=>t.toJSON()))}}add(...t){if(0===t.length)throw new Error("No instructions");return t.forEach((t=>{"instructions"in t?this.instructions=this.instructions.concat(t.instructions):"data"in t&&"programId"in t&&"keys"in t?this.instructions.push(t):this.instructions.push(new cs(t))})),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let t,e,r;if(this.nonceInfo?(t=this.nonceInfo.nonce,e=this.instructions[0]!=this.nonceInfo.nonceInstruction?[this.nonceInfo.nonceInstruction,...this.instructions]:this.instructions):(t=this.recentBlockhash,e=this.instructions),!t)throw new Error("Transaction recentBlockhash required");if(e.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 t=0;t<e.length;t++)if(void 0===e[t].programId)throw new Error(`Transaction instruction index ${t} has undefined program id`);const n=[],i=[];e.forEach((t=>{t.keys.forEach((t=>{i.push({...t})}));const e=t.programId.toString();n.includes(e)||n.push(e)})),n.forEach((t=>{i.push({pubkey:new Wo(t),isSigner:!1,isWritable:!1})}));const o=[];i.forEach((t=>{const e=t.pubkey.toString(),r=o.findIndex((t=>t.pubkey.toString()===e));r>-1?(o[r].isWritable=o[r].isWritable||t.isWritable,o[r].isSigner=o[r].isSigner||t.isSigner):o.push(t)})),o.sort((function(t,e){if(t.isSigner!==e.isSigner)return t.isSigner?-1:1;if(t.isWritable!==e.isWritable)return t.isWritable?-1:1;return t.pubkey.toBase58().localeCompare(e.pubkey.toBase58(),"en",{localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"})}));const s=o.findIndex((t=>t.pubkey.equals(r)));if(s>-1){const[t]=o.splice(s,1);t.isSigner=!0,t.isWritable=!0,o.unshift(t)}else o.unshift({pubkey:r,isSigner:!0,isWritable:!0});for(const t of this.signatures){const e=o.findIndex((e=>e.pubkey.equals(t.publicKey)));if(!(e>-1))throw new Error(`unknown signer: ${t.publicKey.toString()}`);o[e].isSigner||(o[e].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,u=0,c=0;const h=[],l=[];o.forEach((({pubkey:t,isSigner:e,isWritable:r})=>{e?(h.push(t.toString()),a+=1,r||(u+=1)):(l.push(t.toString()),r||(c+=1))}));const f=h.concat(l),d=e.map((t=>{const{data:e,programId:r}=t;return{programIdIndex:f.indexOf(r.toString()),accounts:t.keys.map((t=>f.indexOf(t.pubkey.toString()))),data:ae.encode(e)}}));return d.forEach((t=>{rs(t.programIdIndex>=0),t.accounts.forEach((t=>rs(t>=0)))})),new is({header:{numRequiredSignatures:a,numReadonlySignedAccounts:u,numReadonlyUnsignedAccounts:c},accountKeys:f,recentBlockhash:t,instructions:d})}_compile(){const t=this.compileMessage(),e=t.accountKeys.slice(0,t.header.numRequiredSignatures);if(this.signatures.length===e.length){const r=this.signatures.every(((t,r)=>e[r].equals(t.publicKey)));if(r)return t}return this.signatures=e.map((t=>({signature:null,publicKey:t}))),t}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(t){return(await t.getFeeForMessage(this.compileMessage())).value}setSigners(...t){if(0===t.length)throw new Error("No signers");const e=new Set;this.signatures=t.filter((t=>{const r=t.toString();return!e.has(r)&&(e.add(r),!0)})).map((t=>({signature:null,publicKey:t})))}sign(...t){if(0===t.length)throw new Error("No signers");const e=new Set,r=[];for(const n of t){const t=n.publicKey.toString();e.has(t)||(e.add(t),r.push(n))}this.signatures=r.map((t=>({signature:null,publicKey:t.publicKey})));const n=this._compile();this._partialSign(n,...r)}partialSign(...t){if(0===t.length)throw new Error("No signers");const e=new Set,r=[];for(const n of t){const t=n.publicKey.toString();e.has(t)||(e.add(t),r.push(n))}const n=this._compile();this._partialSign(n,...r)}_partialSign(t,...e){const r=t.serialize();e.forEach((t=>{const e=To(r,t.secretKey);this._addSignature(t.publicKey,Lo(e))}))}addSignature(t,e){this._compile(),this._addSignature(t,e)}_addSignature(t,e){rs(64===e.length);const r=this.signatures.findIndex((e=>t.equals(e.publicKey)));if(r<0)throw new Error(`unknown signer: ${t.toString()}`);this.signatures[r].signature=n.Buffer.from(e)}verifySignatures(t){return this._verifySignatures(this.serializeMessage(),void 0===t||t)}_verifySignatures(t,e){for(const{signature:r,publicKey:n}of this.signatures)if(null===r){if(e)return!1}else if(!Oo(r,t,n.toBytes()))return!1;return!0}serialize(t){const{requireAllSignatures:e,verifySignatures:r}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},t),n=this.serializeMessage();if(r&&!this._verifySignatures(n,e))throw new Error("Signature verification failed");return this._serialize(n)}_serialize(t){const{signatures:e}=this,r=[];es(r,e.length);const i=r.length+64*e.length+t.length,o=n.Buffer.alloc(i);return rs(e.length<256),n.Buffer.from(r).copy(o,0),e.forEach((({signature:t},e)=>{null!==t&&(rs(64===t.length,"signature has invalid length"),n.Buffer.from(t).copy(o,r.length+64*e))})),t.copy(o,r.length+64*e.length),rs(o.length<=Fo,`Transaction too large: ${o.length} > 1232`),o}get keys(){return rs(1===this.instructions.length),this.instructions[0].keys.map((t=>t.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(t){let e=[...t];const r=ts(e);let i=[];for(let t=0;t<r;t++){const t=e.slice(0,Vo);e=e.slice(Vo),i.push(ae.encode(n.Buffer.from(t)))}return hs.populate(is.from(e),i)}static populate(t,e=[]){const r=new hs;return r.recentBlockhash=t.recentBlockhash,t.header.numRequiredSignatures>0&&(r.feePayer=t.accountKeys[0]),e.forEach(((e,n)=>{const i={signature:e==ae.encode(us)?null:ae.decode(e),publicKey:t.accountKeys[n]};r.signatures.push(i)})),t.instructions.forEach((e=>{const n=e.accounts.map((e=>{const n=t.accountKeys[e];return{pubkey:n,isSigner:r.signatures.some((t=>t.publicKey.toString()===n.toString()))||t.isAccountSigner(e),isWritable:t.isAccountWritable(e)}}));r.instructions.push(new cs({keys:n,programId:t.accountKeys[e.programIdIndex],data:ae.decode(e.data)}))})),r._message=t,r._json=r.toJSON(),r}}class ls{constructor(t){this.payerKey=void 0,this.instructions=void 0,this.recentBlockhash=void 0,this.payerKey=t.payerKey,this.instructions=t.instructions,this.recentBlockhash=t.recentBlockhash}static decompile(t,e){const{header:r,compiledInstructions:n,recentBlockhash:i}=t,{numRequiredSignatures:o,numReadonlySignedAccounts:s,numReadonlyUnsignedAccounts:a}=r,u=o-s;rs(u>0,"Message header is invalid");const c=t.staticAccountKeys.length-o-a;rs(c>=0,"Message header is invalid");const h=t.getAccountKeys(e),l=h.get(0);if(void 0===l)throw new Error("Failed to decompile message because no account keys were found");const f=[];for(const t of n){const e=[];for(const n of t.accountKeyIndexes){const t=h.get(n);if(void 0===t)throw new Error(`Failed to find key for account key index ${n}`);let i;i=n<o?n<u:n<h.staticAccountKeys.length?n-o<c:n-h.staticAccountKeys.length<h.accountKeysFromLookups.writable.length,e.push({pubkey:t,isSigner:n<r.numRequiredSignatures,isWritable:i})}const n=h.get(t.programIdIndex);if(void 0===n)throw new Error(`Failed to find program id for program id index ${t.programIdIndex}`);f.push(new cs({programId:n,data:Lo(t.data),keys:e}))}return new ls({payerKey:l,instructions:f,recentBlockhash:i})}compileToLegacyMessage(){return is.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions})}compileToV0Message(t){return os.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions,addressLookupTableAccounts:t})}}class fs{get version(){return this.message.version}constructor(t,e){if(this.signatures=void 0,this.message=void 0,void 0!==e)rs(e.length===t.header.numRequiredSignatures,"Expected signatures length to be equal to the number of required signatures"),this.signatures=e;else{const e=[];for(let r=0;r<t.header.numRequiredSignatures;r++)e.push(new Uint8Array(Vo));this.signatures=e}this.message=t}serialize(){const t=this.message.serialize(),e=Array();es(e,this.signatures.length);const r=jr([Kr(e.length,"encodedSignaturesLength"),Wr(Jo(),this.signatures.length,"signatures"),Kr(t.length,"serializedMessage")]),n=new Uint8Array(2048),i=r.encode({encodedSignaturesLength:new Uint8Array(e),signatures:this.signatures,serializedMessage:t},n);return n.slice(0,i)}static deserialize(t){let e=[...t];const r=[],n=ts(e);for(let t=0;t<n;t++)r.push(new Uint8Array(e.splice(0,Vo)));const i=ss.deserialize(new Uint8Array(e));return new fs(i,r)}sign(t){const e=this.message.serialize(),r=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures);for(const n of t){const t=r.findIndex((t=>t.equals(n.publicKey)));rs(t>=0,`Cannot sign with non signer key ${n.publicKey.toBase58()}`),this.signatures[t]=To(e,n.secretKey)}}addSignature(t,e){rs(64===e.byteLength,"Signature must be 64 bytes long");const r=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex((e=>e.equals(t)));rs(r>=0,`Can not add signature; \`${t.toBase58()}\` is not required to sign this transaction`),this.signatures[r]=e}}const ds=new Wo("SysvarC1ock11111111111111111111111111111111"),ps=new Wo("SysvarEpochSchedu1e111111111111111111111111"),ys=new Wo("Sysvar1nstructions1111111111111111111111111"),gs=new Wo("SysvarRecentB1ockHashes11111111111111111111"),ms=new Wo("SysvarRent111111111111111111111111111111111"),ws=new Wo("SysvarRewards111111111111111111111111111111"),bs=new Wo("SysvarS1otHashes111111111111111111111111111"),vs=new Wo("SysvarS1otHistory11111111111111111111111111"),_s=new Wo("SysvarStakeHistory1111111111111111111111111");async function ks(t,e,r,n){const i=n&&{skipPreflight:n.skipPreflight,preflightCommitment:n.preflightCommitment||n.commitment,maxRetries:n.maxRetries,minContextSlot:n.minContextSlot},o=await t.sendTransaction(e,r,i);let s;if(null!=e.recentBlockhash&&null!=e.lastValidBlockHeight)s=(await t.confirmTransaction({abortSignal:n?.abortSignal,signature:o,blockhash:e.recentBlockhash,lastValidBlockHeight:e.lastValidBlockHeight},n&&n.commitment)).value;else if(null!=e.minNonceContextSlot&&null!=e.nonceInfo){const{nonceInstruction:r}=e.nonceInfo,i=r.keys[0].pubkey;s=(await t.confirmTransaction({abortSignal:n?.abortSignal,minContextSlot:e.minNonceContextSlot,nonceAccountPubkey:i,nonceValue:e.nonceInfo.nonce,signature:o},n&&n.commitment)).value}else null!=n?.abortSignal&&console.warn("sendAndConfirmTransaction(): A transaction with a deprecated confirmation strategy was supplied along with an `abortSignal`. Only transactions having `lastValidBlockHeight` or a combination of `nonceInfo` and `minNonceContextSlot` are abortable."),s=(await t.confirmTransaction(o,n&&n.commitment)).value;if(s.err)throw new Error(`Transaction ${o} failed (${JSON.stringify(s)})`);return o}function Es(t){return new Promise((e=>setTimeout(e,t)))}function xs(t,e){const r=t.layout.span>=0?t.layout.span:Qo(t,e),i=n.Buffer.alloc(r),o=Object.assign({instruction:t.index},e);return t.layout.encode(o,i),i}function Ss(t,e){let r;try{r=t.layout.decode(e)}catch(t){throw new Error("invalid instruction; "+t)}if(r.instruction!==t.index)throw new Error(`invalid instruction; instruction index mismatch ${r.instruction} != ${t.index}`);return r}const As=zr("lamportsPerSignature"),Is=jr([Nr("version"),Nr("state"),Yo("authorizedPubkey"),Yo("nonce"),jr([As],"feeCalculator")]),Bs=Is.span;class Ms{constructor(t){this.authorizedPubkey=void 0,this.nonce=void 0,this.feeCalculator=void 0,this.authorizedPubkey=t.authorizedPubkey,this.nonce=t.nonce,this.feeCalculator=t.feeCalculator}static fromAccountData(t){const e=Is.decode(Lo(t),0);return new Ms({authorizedPubkey:new Wo(e.authorizedPubkey),nonce:new Wo(e.nonce).toString(),feeCalculator:e.feeCalculator})}}const Rs=(Ps=8,t=>{const e=Kr(Ps,t),{encode:r,decode:i}=(t=>({decode:t.decode.bind(t),encode:t.encode.bind(t)}))(e),o=e;return o.decode=(t,e)=>{const r=i(t,e);return qr(n.Buffer.from(r))},o.encode=(t,e,n)=>{const i=Hr(t,Ps);return r(i,e,n)},o});var Ps;const Ts=Object.freeze({Create:{index:0,layout:jr([Nr("instruction"),Dr("lamports"),Dr("space"),Yo("programId")])},Assign:{index:1,layout:jr([Nr("instruction"),Yo("programId")])},Transfer:{index:2,layout:jr([Nr("instruction"),Rs("lamports")])},CreateWithSeed:{index:3,layout:jr([Nr("instruction"),Yo("base"),Xo("seed"),Dr("lamports"),Dr("space"),Yo("programId")])},AdvanceNonceAccount:{index:4,layout:jr([Nr("instruction")])},WithdrawNonceAccount:{index:5,layout:jr([Nr("instruction"),Dr("lamports")])},InitializeNonceAccount:{index:6,layout:jr([Nr("instruction"),Yo("authorized")])},AuthorizeNonceAccount:{index:7,layout:jr([Nr("instruction"),Yo("authorized")])},Allocate:{index:8,layout:jr([Nr("instruction"),Dr("space")])},AllocateWithSeed:{index:9,layout:jr([Nr("instruction"),Yo("base"),Xo("seed"),Dr("space"),Yo("programId")])},AssignWithSeed:{index:10,layout:jr([Nr("instruction"),Yo("base"),Xo("seed"),Yo("programId")])},TransferWithSeed:{index:11,layout:jr([Nr("instruction"),Rs("lamports"),Xo("seed"),Yo("programId")])},UpgradeNonceAccount:{index:12,layout:jr([Nr("instruction")])}});class Os{constructor(){}static createAccount(t){const e=xs(Ts.Create,{lamports:t.lamports,space:t.space,programId:Lo(t.programId.toBuffer())});return new cs({keys:[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:e})}static transfer(t){let e,r;if("basePubkey"in t){e=xs(Ts.TransferWithSeed,{lamports:BigInt(t.lamports),seed:t.seed,programId:Lo(t.programId.toBuffer())}),r=[{pubkey:t.fromPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0}]}else{e=xs(Ts.Transfer,{lamports:BigInt(t.lamports)}),r=[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0}]}return new cs({keys:r,programId:this.programId,data:e})}static assign(t){let e,r;if("basePubkey"in t){e=xs(Ts.AssignWithSeed,{base:Lo(t.basePubkey.toBuffer()),seed:t.seed,programId:Lo(t.programId.toBuffer())}),r=[{pubkey:t.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1}]}else{e=xs(Ts.Assign,{programId:Lo(t.programId.toBuffer())}),r=[{pubkey:t.accountPubkey,isSigner:!0,isWritable:!0}]}return new cs({keys:r,programId:this.programId,data:e})}static createAccountWithSeed(t){const e=xs(Ts.CreateWithSeed,{base:Lo(t.basePubkey.toBuffer()),seed:t.seed,lamports:t.lamports,space:t.space,programId:Lo(t.programId.toBuffer())});let r=[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.newAccountPubkey,isSigner:!1,isWritable:!0}];return t.basePubkey!=t.fromPubkey&&r.push({pubkey:t.basePubkey,isSigner:!0,isWritable:!1}),new cs({keys:r,programId:this.programId,data:e})}static createNonceAccount(t){const e=new hs;"basePubkey"in t&&"seed"in t?e.add(Os.createAccountWithSeed({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,basePubkey:t.basePubkey,seed:t.seed,lamports:t.lamports,space:Bs,programId:this.programId})):e.add(Os.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,lamports:t.lamports,space:Bs,programId:this.programId}));const r={noncePubkey:t.noncePubkey,authorizedPubkey:t.authorizedPubkey};return e.add(this.nonceInitialize(r)),e}static nonceInitialize(t){const e=xs(Ts.InitializeNonceAccount,{authorized:Lo(t.authorizedPubkey.toBuffer())}),r={keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:gs,isSigner:!1,isWritable:!1},{pubkey:ms,isSigner:!1,isWritable:!1}],programId:this.programId,data:e};return new cs(r)}static nonceAdvance(t){const e=xs(Ts.AdvanceNonceAccount),r={keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:gs,isSigner:!1,isWritable:!1},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:e};return new cs(r)}static nonceWithdraw(t){const e=xs(Ts.WithdrawNonceAccount,{lamports:t.lamports});return new cs({keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0},{pubkey:gs,isSigner:!1,isWritable:!1},{pubkey:ms,isSigner:!1,isWritable:!1},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:e})}static nonceAuthorize(t){const e=xs(Ts.AuthorizeNonceAccount,{authorized:Lo(t.newAuthorizedPubkey.toBuffer())});return new cs({keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:e})}static allocate(t){let e,r;if("basePubkey"in t){e=xs(Ts.AllocateWithSeed,{base:Lo(t.basePubkey.toBuffer()),seed:t.seed,space:t.space,programId:Lo(t.programId.toBuffer())}),r=[{pubkey:t.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1}]}else{e=xs(Ts.Allocate,{space:t.space}),r=[{pubkey:t.accountPubkey,isSigner:!0,isWritable:!0}]}return new cs({keys:r,programId:this.programId,data:e})}}Os.programId=new Wo("11111111111111111111111111111111");class Ls{constructor(){}static getMinNumSignatures(t){return 2*(Math.ceil(t/Ls.chunkSize)+1+1)}static async load(t,e,r,i,o){{const n=await t.getMinimumBalanceForRentExemption(o.length),s=await t.getAccountInfo(r.publicKey,"confirmed");let a=null;if(null!==s){if(s.executable)return console.error("Program load failed, account is already executable"),!1;s.data.length!==o.length&&(a=a||new hs,a.add(Os.allocate({accountPubkey:r.publicKey,space:o.length}))),s.owner.equals(i)||(a=a||new hs,a.add(Os.assign({accountPubkey:r.publicKey,programId:i}))),s.lamports<n&&(a=a||new hs,a.add(Os.transfer({fromPubkey:e.publicKey,toPubkey:r.publicKey,lamports:n-s.lamports})))}else a=(new hs).add(Os.createAccount({fromPubkey:e.publicKey,newAccountPubkey:r.publicKey,lamports:n>0?n:1,space:o.length,programId:i}));null!==a&&await ks(t,a,[e,r],{commitment:"confirmed"})}const s=jr([Nr("instruction"),Nr("offset"),Nr("bytesLength"),Nr("bytesLengthPadding"),Wr(Ur("byte"),Lr(Nr(),-8),"bytes")]),a=Ls.chunkSize;let u=0,c=o,h=[];for(;c.length>0;){const o=c.slice(0,a),l=n.Buffer.alloc(a+16);s.encode({instruction:0,offset:u,bytes:o,bytesLength:0,bytesLengthPadding:0},l);const f=(new hs).add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0}],programId:i,data:l});if(h.push(ks(t,f,[e,r],{commitment:"confirmed"})),t._rpcEndpoint.includes("solana.com")){const t=4;await Es(1e3/t)}u+=a,c=c.slice(a)}await Promise.all(h);{const o=jr([Nr("instruction")]),s=n.Buffer.alloc(o.span);o.encode({instruction:1},s);const a=(new hs).add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0},{pubkey:ms,isSigner:!1,isWritable:!1}],programId:i,data:s}),u="processed",c=await t.sendTransaction(a,[e,r],{preflightCommitment:u}),{context:h,value:l}=await t.confirmTransaction({signature:c,lastValidBlockHeight:a.lastValidBlockHeight,blockhash:a.recentBlockhash},u);if(l.err)throw new Error(`Transaction ${c} failed (${JSON.stringify(l)})`);for(;;){try{if(await t.getSlot({commitment:u})>h.slot)break}catch{}await new Promise((t=>setTimeout(t,Math.round(200))))}}return!0}}Ls.chunkSize=932;const Us=new Wo("BPFLoader2111111111111111111111111111111111");function Cs(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Ns=Object.prototype.toString,zs=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};function Ds(t,e){var r,n,i,o,s,a,u;if(!0===t)return"true";if(!1===t)return"false";switch(typeof t){case"object":if(null===t)return null;if(t.toJSON&&"function"==typeof t.toJSON)return Ds(t.toJSON(),e);if("[object Array]"===(u=Ns.call(t))){for(i="[",n=t.length-1,r=0;r<n;r++)i+=Ds(t[r],!0)+",";return n>-1&&(i+=Ds(t[r],!0)),i+"]"}if("[object Object]"===u){for(n=(o=zs(t).sort()).length,i="",r=0;r<n;)void 0!==(a=Ds(t[s=o[r]],!1))&&(i&&(i+=","),i+=JSON.stringify(s)+":"+a),r++;return"{"+i+"}"}return JSON.stringify(t);case"function":case"undefined":return e?null:void 0;case"string":return JSON.stringify(t);default:return isFinite(t)?t:null}}var js=Cs((function(t){var e=Ds(t,!1);if(void 0!==e)return""+e}));function Ws(t){let e=0;for(;t>1;)t/=2,e++;return e}class Ks{constructor(t,e,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=t,this.leaderScheduleSlotOffset=e,this.warmup=r,this.firstNormalEpoch=n,this.firstNormalSlot=i}getEpoch(t){return this.getEpochAndSlotIndex(t)[0]}getEpochAndSlotIndex(t){if(t<this.firstNormalSlot){const e=Ws(function(t){return 0===t?1:(t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,1+(t|=t>>32))}(t+32+1))-Ws(32)-1;return[e,t-(this.getSlotsInEpoch(e)-32)]}{const e=t-this.firstNormalSlot,r=Math.floor(e/this.slotsPerEpoch);return[this.firstNormalEpoch+r,e%this.slotsPerEpoch]}}getFirstSlotInEpoch(t){return t<=this.firstNormalEpoch?32*(Math.pow(2,t)-1):(t-this.firstNormalEpoch)*this.slotsPerEpoch+this.firstNormalSlot}getLastSlotInEpoch(t){return this.getFirstSlotInEpoch(t)+this.getSlotsInEpoch(t)-1}getSlotsInEpoch(t){return t<this.firstNormalEpoch?Math.pow(2,t+Ws(32)):this.slotsPerEpoch}}class Fs extends Error{constructor(t,e){super(t),this.logs=void 0,this.logs=e}}class qs extends Error{constructor({code:t,message:e,data:r},n){super(null!=n?`${n}: ${e}`:e),this.code=void 0,this.data=void 0,this.code=t,this.data=r,this.name="SolanaJSONRPCError"}}var Vs=globalThis.fetch;class Hs extends Vi{constructor(t,e,r){super((t=>{const r=$i(t,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...e});return this.underlyingSocket="socket"in r?r.socket:r,r}),t,e,r),this.underlyingSocket=void 0}call(...t){const e=this.underlyingSocket?.readyState;return 1===e?super.call(...t):Promise.reject(new Error("Tried to call a JSON-RPC method `"+t[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+e+")"))}notify(...t){const e=this.underlyingSocket?.readyState;return 1===e?super.notify(...t):Promise.reject(new Error("Tried to send a JSON-RPC notification `"+t[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+e+")"))}}class $s{constructor(t){this.key=void 0,this.state=void 0,this.key=t.key,this.state=t.state}isActive(){const t=BigInt("0xffffffffffffffff");return this.state.deactivationSlot===t}static deserialize(t){const e=function(t,e){let r;try{r=t.layout.decode(e)}catch(t){throw new Error("invalid instruction; "+t)}if(r.typeIndex!==t.index)throw new Error(`invalid account data; account type mismatch ${r.typeIndex} != ${t.index}`);return r}(Gs,t),r=t.length-56;rs(r>=0,"lookup table is invalid"),rs(r%32==0,"lookup table is invalid");const n=r/32,{addresses:i}=jr([Wr(Yo(),n,"addresses")]).decode(t.slice(56));return{deactivationSlot:e.deactivationSlot,lastExtendedSlot:e.lastExtendedSlot,lastExtendedSlotStartIndex:e.lastExtendedStartIndex,authority:0!==e.authority.length?new Wo(e.authority[0]):void 0,addresses:i.map((t=>new Wo(t)))}}}const Gs={index:1,layout:jr([Nr("typeIndex"),Rs("deactivationSlot"),zr("lastExtendedSlot"),Ur("lastExtendedStartIndex"),Ur(),Wr(Yo(),Lr(Ur(),-1),"authority")])},Zs=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;const Ys=bn(un(Wo),pn(),(t=>new Wo(t))),Js=yn([pn(),cn("base64")]),Xs=bn(un(n.Buffer),Js,(t=>n.Buffer.from(t[0],"base64")));function Qs(t){let e,r;if("string"==typeof t)e=t;else if(t){const{commitment:n,...i}=t;e=n,r=i}return{commitment:e,config:r}}function ta(t){return mn([gn({jsonrpc:cn("2.0"),id:pn(),result:t}),gn({jsonrpc:cn("2.0"),id:pn(),error:gn({code:wn(),message:pn(),data:fn(on("any",(()=>!0)))})})])}const ea=ta(wn());function ra(t){return bn(ta(t),ea,(e=>"error"in e?e:{...e,result:en(e.result,t)}))}function na(t){return ra(gn({context:gn({slot:ln()}),value:t}))}function ia(t){return gn({context:gn({slot:ln()}),value:t})}function oa(t,e){return 0===t?new os({header:e.header,staticAccountKeys:e.accountKeys.map((t=>new Wo(t))),recentBlockhash:e.recentBlockhash,compiledInstructions:e.instructions.map((t=>({programIdIndex:t.programIdIndex,accountKeyIndexes:t.accounts,data:ae.decode(t.data)}))),addressTableLookups:e.addressTableLookups}):new is(e)}const sa=gn({foundation:ln(),foundationTerm:ln(),initial:ln(),taper:ln(),terminal:ln()}),aa=ra(sn(hn(gn({epoch:ln(),effectiveSlot:ln(),amount:ln(),postBalance:ln(),commission:fn(hn(ln()))})))),ua=sn(gn({slot:ln(),prioritizationFee:ln()})),ca=gn({total:ln(),validator:ln(),foundation:ln(),epoch:ln()}),ha=gn({epoch:ln(),slotIndex:ln(),slotsInEpoch:ln(),absoluteSlot:ln(),blockHeight:fn(ln()),transactionCount:fn(ln())}),la=gn({slotsPerEpoch:ln(),leaderScheduleSlotOffset:ln(),warmup:an(),firstNormalEpoch:ln(),firstNormalSlot:ln()}),fa=dn(pn(),sn(ln())),da=hn(mn([gn({}),pn()])),pa=gn({err:da}),ya=cn("receivedSignature"),ga=gn({"solana-core":pn(),"feature-set":fn(ln())}),ma=na(gn({err:hn(mn([gn({}),pn()])),logs:hn(sn(pn())),accounts:fn(hn(sn(hn(gn({executable:an(),owner:pn(),lamports:ln(),data:sn(pn()),rentEpoch:fn(ln())}))))),unitsConsumed:fn(ln()),returnData:fn(hn(gn({programId:pn(),data:yn([pn(),cn("base64")])})))})),wa=na(gn({byIdentity:dn(pn(),sn(ln())),range:gn({firstSlot:ln(),lastSlot:ln()})}));const ba=ra(sa),va=ra(ca),_a=ra(ua),ka=ra(ha),Ea=ra(la),xa=ra(fa),Sa=ra(ln()),Aa=na(gn({total:ln(),circulating:ln(),nonCirculating:ln(),nonCirculatingAccounts:sn(Ys)})),Ia=gn({amount:pn(),uiAmount:hn(ln()),decimals:ln(),uiAmountString:fn(pn())}),Ba=na(sn(gn({address:Ys,amount:pn(),uiAmount:hn(ln()),decimals:ln(),uiAmountString:fn(pn())}))),Ma=na(sn(gn({pubkey:Ys,account:gn({executable:an(),owner:Ys,lamports:ln(),data:Xs,rentEpoch:ln()})}))),Ra=gn({program:pn(),parsed:wn(),space:ln()}),Pa=na(sn(gn({pubkey:Ys,account:gn({executable:an(),owner:Ys,lamports:ln(),data:Ra,rentEpoch:ln()})}))),Ta=na(sn(gn({lamports:ln(),address:Ys}))),Oa=gn({executable:an(),owner:Ys,lamports:ln(),data:Xs,rentEpoch:ln()}),La=gn({pubkey:Ys,account:Oa}),Ua=bn(mn([un(n.Buffer),Ra]),mn([Js,Ra]),(t=>Array.isArray(t)?en(t,Xs):t)),Ca=gn({executable:an(),owner:Ys,lamports:ln(),data:Ua,rentEpoch:ln()}),Na=gn({pubkey:Ys,account:Ca}),za=gn({state:mn([cn("active"),cn("inactive"),cn("activating"),cn("deactivating")]),active:ln(),inactive:ln()}),Da=ra(sn(gn({signature:pn(),slot:ln(),err:da,memo:hn(pn()),blockTime:fn(hn(ln()))}))),ja=ra(sn(gn({signature:pn(),slot:ln(),err:da,memo:hn(pn()),blockTime:fn(hn(ln()))}))),Wa=gn({subscription:ln(),result:ia(Oa)}),Ka=gn({pubkey:Ys,account:Oa}),Fa=gn({subscription:ln(),result:ia(Ka)}),qa=gn({parent:ln(),slot:ln(),root:ln()}),Va=gn({subscription:ln(),result:qa}),Ha=mn([gn({type:mn([cn("firstShredReceived"),cn("completed"),cn("optimisticConfirmation"),cn("root")]),slot:ln(),timestamp:ln()}),gn({type:cn("createdBank"),parent:ln(),slot:ln(),timestamp:ln()}),gn({type:cn("frozen"),slot:ln(),timestamp:ln(),stats:gn({numTransactionEntries:ln(),numSuccessfulTransactions:ln(),numFailedTransactions:ln(),maxTransactionsPerEntry:ln()})}),gn({type:cn("dead"),slot:ln(),timestamp:ln(),err:pn()})]),$a=gn({subscription:ln(),result:Ha}),Ga=gn({subscription:ln(),result:ia(mn([pa,ya]))}),Za=gn({subscription:ln(),result:ln()}),Ya=gn({pubkey:pn(),gossip:hn(pn()),tpu:hn(pn()),rpc:hn(pn()),version:hn(pn())}),Ja=gn({votePubkey:pn(),nodePubkey:pn(),activatedStake:ln(),epochVoteAccount:an(),epochCredits:sn(yn([ln(),ln(),ln()])),commission:ln(),lastVote:ln(),rootSlot:hn(ln())}),Xa=ra(gn({current:sn(Ja),delinquent:sn(Ja)})),Qa=mn([cn("processed"),cn("confirmed"),cn("finalized")]),tu=gn({slot:ln(),confirmations:hn(ln()),err:da,confirmationStatus:fn(Qa)}),eu=na(sn(hn(tu))),ru=ra(ln()),nu=gn({accountKey:Ys,writableIndexes:sn(ln()),readonlyIndexes:sn(ln())}),iu=gn({signatures:sn(pn()),message:gn({accountKeys:sn(pn()),header:gn({numRequiredSignatures:ln(),numReadonlySignedAccounts:ln(),numReadonlyUnsignedAccounts:ln()}),instructions:sn(gn({accounts:sn(ln()),data:pn(),programIdIndex:ln()})),recentBlockhash:pn(),addressTableLookups:fn(sn(nu))})}),ou=gn({pubkey:Ys,signer:an(),writable:an(),source:fn(mn([cn("transaction"),cn("lookupTable")]))}),su=gn({accountKeys:sn(ou),signatures:sn(pn())}),au=gn({parsed:wn(),program:pn(),programId:Ys}),uu=gn({accounts:sn(Ys),data:pn(),programId:Ys}),cu=bn(mn([uu,au]),mn([gn({parsed:wn(),program:pn(),programId:pn()}),gn({accounts:sn(pn()),data:pn(),programId:pn()})]),(t=>en(t,"accounts"in t?uu:au))),hu=gn({signatures:sn(pn()),message:gn({accountKeys:sn(ou),instructions:sn(cu),recentBlockhash:pn(),addressTableLookups:fn(hn(sn(nu)))})}),lu=gn({accountIndex:ln(),mint:pn(),owner:fn(pn()),uiTokenAmount:Ia}),fu=gn({writable:sn(Ys),readonly:sn(Ys)}),du=gn({err:da,fee:ln(),innerInstructions:fn(hn(sn(gn({index:ln(),instructions:sn(gn({accounts:sn(ln()),data:pn(),programIdIndex:ln()}))})))),preBalances:sn(ln()),postBalances:sn(ln()),logMessages:fn(hn(sn(pn()))),preTokenBalances:fn(hn(sn(lu))),postTokenBalances:fn(hn(sn(lu))),loadedAddresses:fn(fu),computeUnitsConsumed:fn(ln())}),pu=gn({err:da,fee:ln(),innerInstructions:fn(hn(sn(gn({index:ln(),instructions:sn(cu)})))),preBalances:sn(ln()),postBalances:sn(ln()),logMessages:fn(hn(sn(pn()))),preTokenBalances:fn(hn(sn(lu))),postTokenBalances:fn(hn(sn(lu))),loadedAddresses:fn(fu),computeUnitsConsumed:fn(ln())}),yu=mn([cn(0),cn("legacy")]),gu=gn({pubkey:pn(),lamports:ln(),postBalance:hn(ln()),rewardType:hn(pn()),commission:fn(hn(ln()))}),mu=ra(hn(gn({blockhash:pn(),previousBlockhash:pn(),parentSlot:ln(),transactions:sn(gn({transaction:iu,meta:hn(du),version:fn(yu)})),rewards:fn(sn(gu)),blockTime:hn(ln()),blockHeight:hn(ln())}))),wu=ra(hn(gn({blockhash:pn(),previousBlockhash:pn(),parentSlot:ln(),rewards:fn(sn(gu)),blockTime:hn(ln()),blockHeight:hn(ln())}))),bu=ra(hn(gn({blockhash:pn(),previousBlockhash:pn(),parentSlot:ln(),transactions:sn(gn({transaction:su,meta:hn(du),version:fn(yu)})),rewards:fn(sn(gu)),blockTime:hn(ln()),blockHeight:hn(ln())}))),vu=ra(hn(gn({blockhash:pn(),previousBlockhash:pn(),parentSlot:ln(),transactions:sn(gn({transaction:hu,meta:hn(pu),version:fn(yu)})),rewards:fn(sn(gu)),blockTime:hn(ln()),blockHeight:hn(ln())}))),_u=ra(hn(gn({blockhash:pn(),previousBlockhash:pn(),parentSlot:ln(),transactions:sn(gn({transaction:su,meta:hn(pu),version:fn(yu)})),rewards:fn(sn(gu)),blockTime:hn(ln()),blockHeight:hn(ln())}))),ku=ra(hn(gn({blockhash:pn(),previousBlockhash:pn(),parentSlot:ln(),rewards:fn(sn(gu)),blockTime:hn(ln()),blockHeight:hn(ln())}))),Eu=ra(hn(gn({blockhash:pn(),previousBlockhash:pn(),parentSlot:ln(),transactions:sn(gn({transaction:iu,meta:hn(du)})),rewards:fn(sn(gu)),blockTime:hn(ln())}))),xu=ra(hn(gn({blockhash:pn(),previousBlockhash:pn(),parentSlot:ln(),signatures:sn(pn()),blockTime:hn(ln())}))),Su=ra(hn(gn({slot:ln(),meta:du,blockTime:fn(hn(ln())),transaction:iu,version:fn(yu)}))),Au=ra(hn(gn({slot:ln(),transaction:hu,meta:hn(pu),blockTime:fn(hn(ln())),version:fn(yu)}))),Iu=na(gn({blockhash:pn(),feeCalculator:gn({lamportsPerSignature:ln()})})),Bu=na(gn({blockhash:pn(),lastValidBlockHeight:ln()})),Mu=na(an()),Ru=ra(sn(gn({slot:ln(),numTransactions:ln(),numSlots:ln(),samplePeriodSecs:ln()}))),Pu=na(hn(gn({feeCalculator:gn({lamportsPerSignature:ln()})}))),Tu=ra(pn()),Ou=ra(pn()),Lu=gn({err:da,logs:sn(pn()),signature:pn()}),Uu=gn({result:ia(Lu),subscription:ln()}),Cu={"solana-client":"js/0.0.0-development"};class Nu{constructor(t){this._keypair=void 0,this._keypair=t??Mo()}static generate(){return new Nu(Mo())}static fromSecretKey(t,e){if(64!==t.byteLength)throw new Error("bad secret key size");const r=t.slice(32,64);if(!e||!e.skipValidation){const e=t.slice(0,32),n=Ro(e);for(let t=0;t<32;t++)if(r[t]!==n[t])throw new Error("provided secretKey is invalid")}return new Nu({publicKey:r,secretKey:t})}static fromSeed(t){const e=Ro(t),r=new Uint8Array(64);return r.set(t),r.set(e,32),new Nu({publicKey:e,secretKey:r})}get publicKey(){return new Wo(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}}const zu=Object.freeze({CreateLookupTable:{index:0,layout:jr([Nr("instruction"),Rs("recentSlot"),Ur("bumpSeed")])},FreezeLookupTable:{index:1,layout:jr([Nr("instruction")])},ExtendLookupTable:{index:2,layout:jr([Nr("instruction"),Rs(),Wr(Yo(),Lr(Nr(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:jr([Nr("instruction")])},CloseLookupTable:{index:4,layout:jr([Nr("instruction")])}});class Du{constructor(){}static createLookupTable(t){const[e,r]=Wo.findProgramAddressSync([t.authority.toBuffer(),Hr(BigInt(t.recentSlot),8)],this.programId),n=xs(zu.CreateLookupTable,{recentSlot:BigInt(t.recentSlot),bumpSeed:r}),i=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1},{pubkey:t.payer,isSigner:!0,isWritable:!0},{pubkey:Os.programId,isSigner:!1,isWritable:!1}];return[new cs({programId:this.programId,keys:i,data:n}),e]}static freezeLookupTable(t){const e=xs(zu.FreezeLookupTable),r=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return new cs({programId:this.programId,keys:r,data:e})}static extendLookupTable(t){const e=xs(zu.ExtendLookupTable,{addresses:t.addresses.map((t=>t.toBytes()))}),r=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return t.payer&&r.push({pubkey:t.payer,isSigner:!0,isWritable:!0},{pubkey:Os.programId,isSigner:!1,isWritable:!1}),new cs({programId:this.programId,keys:r,data:e})}static deactivateLookupTable(t){const e=xs(zu.DeactivateLookupTable),r=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return new cs({programId:this.programId,keys:r,data:e})}static closeLookupTable(t){const e=xs(zu.CloseLookupTable),r=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1},{pubkey:t.recipient,isSigner:!1,isWritable:!0}];return new cs({programId:this.programId,keys:r,data:e})}}Du.programId=new Wo("AddressLookupTab1e1111111111111111111111111");const ju=Object.freeze({RequestUnits:{index:0,layout:jr([Ur("instruction"),Nr("units"),Nr("additionalFee")])},RequestHeapFrame:{index:1,layout:jr([Ur("instruction"),Nr("bytes")])},SetComputeUnitLimit:{index:2,layout:jr([Ur("instruction"),Nr("units")])},SetComputeUnitPrice:{index:3,layout:jr([Ur("instruction"),Rs("microLamports")])}});class Wu{constructor(){}static requestUnits(t){const e=xs(ju.RequestUnits,t);return new cs({keys:[],programId:this.programId,data:e})}static requestHeapFrame(t){const e=xs(ju.RequestHeapFrame,t);return new cs({keys:[],programId:this.programId,data:e})}static setComputeUnitLimit(t){const e=xs(ju.SetComputeUnitLimit,t);return new cs({keys:[],programId:this.programId,data:e})}static setComputeUnitPrice(t){const e=xs(ju.SetComputeUnitPrice,{microLamports:BigInt(t.microLamports)});return new cs({keys:[],programId:this.programId,data:e})}}Wu.programId=new Wo("ComputeBudget111111111111111111111111111111");const Ku=jr([Ur("numSignatures"),Ur("padding"),Cr("signatureOffset"),Cr("signatureInstructionIndex"),Cr("publicKeyOffset"),Cr("publicKeyInstructionIndex"),Cr("messageDataOffset"),Cr("messageDataSize"),Cr("messageInstructionIndex")]);class Fu{constructor(){}static createInstructionWithPublicKey(t){const{publicKey:e,message:r,signature:i,instructionIndex:o}=t;rs(32===e.length,`Public Key must be 32 bytes but received ${e.length} bytes`),rs(64===i.length,`Signature must be 64 bytes but received ${i.length} bytes`);const s=Ku.span,a=s+e.length,u=a+i.length,c=n.Buffer.alloc(u+r.length),h=null==o?65535:o;return Ku.encode({numSignatures:1,padding:0,signatureOffset:a,signatureInstructionIndex:h,publicKeyOffset:s,publicKeyInstructionIndex:h,messageDataOffset:u,messageDataSize:r.length,messageInstructionIndex:h},c),c.fill(e,s),c.fill(i,a),c.fill(r,u),new cs({keys:[],programId:Fu.programId,data:c})}static createInstructionWithPrivateKey(t){const{privateKey:e,message:r,instructionIndex:n}=t;rs(64===e.length,`Private key must be 64 bytes but received ${e.length} bytes`);try{const t=Nu.fromSecretKey(e),i=t.publicKey.toBytes(),o=To(r,t.secretKey);return this.createInstructionWithPublicKey({publicKey:i,message:r,signature:o,instructionIndex:n})}catch(t){throw new Error(`Error creating instruction; ${t}`)}}}Fu.programId=new Wo("Ed25519SigVerify111111111111111111111111111");Io.utils.isValidPrivateKey;const qu=Io.getPublicKey,Vu=jr([Ur("numSignatures"),Cr("signatureOffset"),Ur("signatureInstructionIndex"),Cr("ethAddressOffset"),Ur("ethAddressInstructionIndex"),Cr("messageDataOffset"),Cr("messageDataSize"),Ur("messageInstructionIndex"),Kr(20,"ethAddress"),Kr(64,"signature"),Ur("recoveryId")]);class Hu{constructor(){}static publicKeyToEthAddress(t){rs(64===t.length,`Public key must be 64 bytes but received ${t.length} bytes`);try{return n.Buffer.from(uo(Lo(t))).slice(-20)}catch(t){throw new Error(`Error constructing Ethereum address: ${t}`)}}static createInstructionWithPublicKey(t){const{publicKey:e,message:r,signature:n,recoveryId:i,instructionIndex:o}=t;return Hu.createInstructionWithEthAddress({ethAddress:Hu.publicKeyToEthAddress(e),message:r,signature:n,recoveryId:i,instructionIndex:o})}static createInstructionWithEthAddress(t){const{ethAddress:e,message:r,signature:i,recoveryId:o,instructionIndex:s=0}=t;let a;a="string"==typeof e?e.startsWith("0x")?n.Buffer.from(e.substr(2),"hex"):n.Buffer.from(e,"hex"):e,rs(20===a.length,`Address must be 20 bytes but received ${a.length} bytes`);const u=12+a.length,c=u+i.length+1,h=n.Buffer.alloc(Vu.span+r.length);return Vu.encode({numSignatures:1,signatureOffset:u,signatureInstructionIndex:s,ethAddressOffset:12,ethAddressInstructionIndex:s,messageDataOffset:c,messageDataSize:r.length,messageInstructionIndex:s,signature:Lo(i),ethAddress:Lo(a),recoveryId:o},h),h.fill(Lo(r),Vu.span),new cs({keys:[],programId:Hu.programId,data:h})}static createInstructionWithPrivateKey(t){const{privateKey:e,message:r,instructionIndex:i}=t;rs(32===e.length,`Private key must be 32 bytes but received ${e.length} bytes`);try{const t=Lo(e),o=qu(t,!1).slice(1),s=n.Buffer.from(uo(Lo(r))),[a,u]=((t,e)=>{const r=Io.sign(t,e);return[r.toCompactRawBytes(),r.recovery]})(s,t);return this.createInstructionWithPublicKey({publicKey:o,message:r,signature:a,recoveryId:u,instructionIndex:i})}catch(t){throw new Error(`Error creating instruction; ${t}`)}}}var $u;Hu.programId=new Wo("KeccakSecp256k11111111111111111111111111111");const Gu=new Wo("StakeConfig11111111111111111111111111111111");class Zu{constructor(t,e){this.staker=void 0,this.withdrawer=void 0,this.staker=t,this.withdrawer=e}}class Yu{constructor(t,e,r){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=t,this.epoch=e,this.custodian=r}}$u=Yu,Yu.default=new $u(0,0,Wo.default);const Ju=Object.freeze({Initialize:{index:0,layout:jr([Nr("instruction"),((t="authorized")=>jr([Yo("staker"),Yo("withdrawer")],t))(),((t="lockup")=>jr([Dr("unixTimestamp"),Dr("epoch"),Yo("custodian")],t))()])},Authorize:{index:1,layout:jr([Nr("instruction"),Yo("newAuthorized"),Nr("stakeAuthorizationType")])},Delegate:{index:2,layout:jr([Nr("instruction")])},Split:{index:3,layout:jr([Nr("instruction"),Dr("lamports")])},Withdraw:{index:4,layout:jr([Nr("instruction"),Dr("lamports")])},Deactivate:{index:5,layout:jr([Nr("instruction")])},Merge:{index:7,layout:jr([Nr("instruction")])},AuthorizeWithSeed:{index:8,layout:jr([Nr("instruction"),Yo("newAuthorized"),Nr("stakeAuthorizationType"),Xo("authoritySeed"),Yo("authorityOwner")])}}),Xu=Object.freeze({Staker:{index:0},Withdrawer:{index:1}});class Qu{constructor(){}static initialize(t){const{stakePubkey:e,authorized:r,lockup:n}=t,i=n||Yu.default,o=xs(Ju.Initialize,{authorized:{staker:Lo(r.staker.toBuffer()),withdrawer:Lo(r.withdrawer.toBuffer())},lockup:{unixTimestamp:i.unixTimestamp,epoch:i.epoch,custodian:Lo(i.custodian.toBuffer())}}),s={keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:ms,isSigner:!1,isWritable:!1}],programId:this.programId,data:o};return new cs(s)}static createAccountWithSeed(t){const e=new hs;e.add(Os.createAccountWithSeed({fromPubkey:t.fromPubkey,newAccountPubkey:t.stakePubkey,basePubkey:t.basePubkey,seed:t.seed,lamports:t.lamports,space:this.space,programId:this.programId}));const{stakePubkey:r,authorized:n,lockup:i}=t;return e.add(this.initialize({stakePubkey:r,authorized:n,lockup:i}))}static createAccount(t){const e=new hs;e.add(Os.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.stakePubkey,lamports:t.lamports,space:this.space,programId:this.programId}));const{stakePubkey:r,authorized:n,lockup:i}=t;return e.add(this.initialize({stakePubkey:r,authorized:n,lockup:i}))}static delegate(t){const{stakePubkey:e,authorizedPubkey:r,votePubkey:n}=t,i=xs(Ju.Delegate);return(new hs).add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!1},{pubkey:ds,isSigner:!1,isWritable:!1},{pubkey:_s,isSigner:!1,isWritable:!1},{pubkey:Gu,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:i})}static authorize(t){const{stakePubkey:e,authorizedPubkey:r,newAuthorizedPubkey:n,stakeAuthorizationType:i,custodianPubkey:o}=t,s=xs(Ju.Authorize,{newAuthorized:Lo(n.toBuffer()),stakeAuthorizationType:i.index}),a=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:ds,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}];return o&&a.push({pubkey:o,isSigner:!1,isWritable:!1}),(new hs).add({keys:a,programId:this.programId,data:s})}static authorizeWithSeed(t){const{stakePubkey:e,authorityBase:r,authoritySeed:n,authorityOwner:i,newAuthorizedPubkey:o,stakeAuthorizationType:s,custodianPubkey:a}=t,u=xs(Ju.AuthorizeWithSeed,{newAuthorized:Lo(o.toBuffer()),stakeAuthorizationType:s.index,authoritySeed:n,authorityOwner:Lo(i.toBuffer())}),c=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1},{pubkey:ds,isSigner:!1,isWritable:!1}];return a&&c.push({pubkey:a,isSigner:!1,isWritable:!1}),(new hs).add({keys:c,programId:this.programId,data:u})}static splitInstruction(t){const{stakePubkey:e,authorizedPubkey:r,splitStakePubkey:n,lamports:i}=t,o=xs(Ju.Split,{lamports:i});return new cs({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static split(t){const e=new hs;return e.add(Os.createAccount({fromPubkey:t.authorizedPubkey,newAccountPubkey:t.splitStakePubkey,lamports:0,space:this.space,programId:this.programId})),e.add(this.splitInstruction(t))}static splitWithSeed(t){const{stakePubkey:e,authorizedPubkey:r,splitStakePubkey:n,basePubkey:i,seed:o,lamports:s}=t,a=new hs;return a.add(Os.allocate({accountPubkey:n,basePubkey:i,seed:o,space:this.space,programId:this.programId})),a.add(this.splitInstruction({stakePubkey:e,authorizedPubkey:r,splitStakePubkey:n,lamports:s}))}static merge(t){const{stakePubkey:e,sourceStakePubKey:r,authorizedPubkey:n}=t,i=xs(Ju.Merge);return(new hs).add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:ds,isSigner:!1,isWritable:!1},{pubkey:_s,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:i})}static withdraw(t){const{stakePubkey:e,authorizedPubkey:r,toPubkey:n,lamports:i,custodianPubkey:o}=t,s=xs(Ju.Withdraw,{lamports:i}),a=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!0},{pubkey:ds,isSigner:!1,isWritable:!1},{pubkey:_s,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return o&&a.push({pubkey:o,isSigner:!1,isWritable:!1}),(new hs).add({keys:a,programId:this.programId,data:s})}static deactivate(t){const{stakePubkey:e,authorizedPubkey:r}=t,n=xs(Ju.Deactivate);return(new hs).add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:ds,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}}Qu.programId=new Wo("Stake11111111111111111111111111111111111111"),Qu.space=200;class tc{constructor(t,e,r,n){this.nodePubkey=void 0,this.authorizedVoter=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.nodePubkey=t,this.authorizedVoter=e,this.authorizedWithdrawer=r,this.commission=n}}const ec=Object.freeze({InitializeAccount:{index:0,layout:jr([Nr("instruction"),((t="voteInit")=>jr([Yo("nodePubkey"),Yo("authorizedVoter"),Yo("authorizedWithdrawer"),Ur("commission")],t))()])},Authorize:{index:1,layout:jr([Nr("instruction"),Yo("newAuthorized"),Nr("voteAuthorizationType")])},Withdraw:{index:3,layout:jr([Nr("instruction"),Dr("lamports")])},AuthorizeWithSeed:{index:10,layout:jr([Nr("instruction"),((t="voteAuthorizeWithSeedArgs")=>jr([Nr("voteAuthorizationType"),Yo("currentAuthorityDerivedKeyOwnerPubkey"),Xo("currentAuthorityDerivedKeySeed"),Yo("newAuthorized")],t))()])}}),rc=Object.freeze({Voter:{index:0},Withdrawer:{index:1}});class nc{constructor(){}static initializeAccount(t){const{votePubkey:e,nodePubkey:r,voteInit:n}=t,i=xs(ec.InitializeAccount,{voteInit:{nodePubkey:Lo(n.nodePubkey.toBuffer()),authorizedVoter:Lo(n.authorizedVoter.toBuffer()),authorizedWithdrawer:Lo(n.authorizedWithdrawer.toBuffer()),commission:n.commission}}),o={keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:ms,isSigner:!1,isWritable:!1},{pubkey:ds,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:i};return new cs(o)}static createAccount(t){const e=new hs;return e.add(Os.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.votePubkey,lamports:t.lamports,space:this.space,programId:this.programId})),e.add(this.initializeAccount({votePubkey:t.votePubkey,nodePubkey:t.voteInit.nodePubkey,voteInit:t.voteInit}))}static authorize(t){const{votePubkey:e,authorizedPubkey:r,newAuthorizedPubkey:n,voteAuthorizationType:i}=t,o=xs(ec.Authorize,{newAuthorized:Lo(n.toBuffer()),voteAuthorizationType:i.index}),s=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:ds,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return(new hs).add({keys:s,programId:this.programId,data:o})}static authorizeWithSeed(t){const{currentAuthorityDerivedKeyBasePubkey:e,currentAuthorityDerivedKeyOwnerPubkey:r,currentAuthorityDerivedKeySeed:n,newAuthorizedPubkey:i,voteAuthorizationType:o,votePubkey:s}=t,a=xs(ec.AuthorizeWithSeed,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:Lo(r.toBuffer()),currentAuthorityDerivedKeySeed:n,newAuthorized:Lo(i.toBuffer()),voteAuthorizationType:o.index}}),u=[{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:ds,isSigner:!1,isWritable:!1},{pubkey:e,isSigner:!0,isWritable:!1}];return(new hs).add({keys:u,programId:this.programId,data:a})}static withdraw(t){const{votePubkey:e,authorizedWithdrawerPubkey:r,lamports:n,toPubkey:i}=t,o=xs(ec.Withdraw,{lamports:n}),s=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}];return(new hs).add({keys:s,programId:this.programId,data:o})}static safeWithdraw(t,e,r){if(t.lamports>e-r)throw new Error("Withdraw will leave vote account with insuffcient funds.");return nc.withdraw(t)}}nc.programId=new Wo("Vote111111111111111111111111111111111111111"),nc.space=3731;const ic=new Wo("Va1idator1nfo111111111111111111111111111111"),oc=gn({name:pn(),website:fn(pn()),details:fn(pn()),keybaseUsername:fn(pn())});class sc{constructor(t,e){this.key=void 0,this.info=void 0,this.key=t,this.info=e}static fromConfigData(t){let e=[...t];if(2!==ts(e))return null;const r=[];for(let t=0;t<2;t++){const t=new Wo(e.slice(0,Do));e=e.slice(Do);const n=1===e.slice(0,1)[0];e=e.slice(1),r.push({publicKey:t,isSigner:n})}if(r[0].publicKey.equals(ic)&&r[1].isSigner){const t=Xo().decode(n.Buffer.from(e)),i=JSON.parse(t);return tn(i,oc),new sc(r[1].publicKey,i)}return null}}const ac=new Wo("Vote111111111111111111111111111111111111111"),uc=jr([Yo("nodePubkey"),Yo("authorizedWithdrawer"),Ur("commission"),zr(),Wr(jr([zr("slot"),Nr("confirmationCount")]),Lr(Nr(),-8),"votes"),Ur("rootSlotValid"),zr("rootSlot"),zr(),Wr(jr([zr("epoch"),Yo("authorizedVoter")]),Lr(Nr(),-8),"authorizedVoters"),jr([Wr(jr([Yo("authorizedPubkey"),zr("epochOfLastAuthorizedSwitch"),zr("targetEpoch")]),32,"buf"),zr("idx"),Ur("isEmpty")],"priorVoters"),zr(),Wr(jr([zr("epoch"),zr("credits"),zr("prevCredits")]),Lr(Nr(),-8),"epochCredits"),jr([zr("slot"),zr("timestamp")],"lastTimestamp")]);class cc{constructor(t){this.nodePubkey=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.rootSlot=void 0,this.votes=void 0,this.authorizedVoters=void 0,this.priorVoters=void 0,this.epochCredits=void 0,this.lastTimestamp=void 0,this.nodePubkey=t.nodePubkey,this.authorizedWithdrawer=t.authorizedWithdrawer,this.commission=t.commission,this.rootSlot=t.rootSlot,this.votes=t.votes,this.authorizedVoters=t.authorizedVoters,this.priorVoters=t.priorVoters,this.epochCredits=t.epochCredits,this.lastTimestamp=t.lastTimestamp}static fromAccountData(t){const e=uc.decode(Lo(t),4);let r=e.rootSlot;return e.rootSlotValid||(r=null),new cc({nodePubkey:new Wo(e.nodePubkey),authorizedWithdrawer:new Wo(e.authorizedWithdrawer),commission:e.commission,votes:e.votes,rootSlot:r,authorizedVoters:e.authorizedVoters.map(hc),priorVoters:fc(e.priorVoters),epochCredits:e.epochCredits,lastTimestamp:e.lastTimestamp})}}function hc({authorizedVoter:t,epoch:e}){return{epoch:e,authorizedVoter:new Wo(t)}}function lc({authorizedPubkey:t,epochOfLastAuthorizedSwitch:e,targetEpoch:r}){return{authorizedPubkey:new Wo(t),epochOfLastAuthorizedSwitch:e,targetEpoch:r}}function fc({buf:t,idx:e,isEmpty:r}){return r?[]:[...t.slice(e+1).map(lc),...t.slice(0,e).map(lc)]}const dc={http:{devnet:"http://api.devnet.solana.com",testnet:"http://api.testnet.solana.com","mainnet-beta":"http://api.mainnet-beta.solana.com/"},https:{devnet:"https://api.devnet.solana.com",testnet:"https://api.testnet.solana.com","mainnet-beta":"https://api.mainnet-beta.solana.com/"}};var pc=Object.freeze({__proto__:null,Account:class{constructor(t){if(this._publicKey=void 0,this._secretKey=void 0,t){const e=Lo(t);if(64!==t.length)throw new Error("bad secret key size");this._publicKey=e.slice(32,64),this._secretKey=e.slice(0,32)}else this._secretKey=Lo(Bo()),this._publicKey=Lo(Ro(this._secretKey))}get publicKey(){return new Wo(this._publicKey)}get secretKey(){return n.Buffer.concat([this._secretKey,this._publicKey],64)}},AddressLookupTableAccount:$s,AddressLookupTableInstruction:class{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const e=Nr("instruction").decode(t.data);let r;for(const[t,n]of Object.entries(zu))if(n.index==e){r=t;break}if(!r)throw new Error("Invalid Instruction. Should be a LookupTable Instruction");return r}static decodeCreateLookupTable(t){this.checkProgramId(t.programId),this.checkKeysLength(t.keys,4);const{recentSlot:e}=Ss(zu.CreateLookupTable,t.data);return{authority:t.keys[1].pubkey,payer:t.keys[2].pubkey,recentSlot:Number(e)}}static decodeExtendLookupTable(t){if(this.checkProgramId(t.programId),t.keys.length<2)throw new Error(`invalid instruction; found ${t.keys.length} keys, expected at least 2`);const{addresses:e}=Ss(zu.ExtendLookupTable,t.data);return{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey,payer:t.keys.length>2?t.keys[2].pubkey:void 0,addresses:e.map((t=>new Wo(t)))}}static decodeCloseLookupTable(t){return this.checkProgramId(t.programId),this.checkKeysLength(t.keys,3),{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey,recipient:t.keys[2].pubkey}}static decodeFreezeLookupTable(t){return this.checkProgramId(t.programId),this.checkKeysLength(t.keys,2),{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey}}static decodeDeactivateLookupTable(t){return this.checkProgramId(t.programId),this.checkKeysLength(t.keys,2),{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey}}static checkProgramId(t){if(!t.equals(Du.programId))throw new Error("invalid instruction; programId is not AddressLookupTable Program")}static checkKeysLength(t,e){if(t.length<e)throw new Error(`invalid instruction; found ${t.length} keys, expected at least ${e}`)}},AddressLookupTableProgram:Du,Authorized:Zu,BLOCKHASH_CACHE_TIMEOUT_MS:3e4,BPF_LOADER_DEPRECATED_PROGRAM_ID:Ko,BPF_LOADER_PROGRAM_ID:Us,BpfLoader:class{static getMinNumSignatures(t){return Ls.getMinNumSignatures(t)}static load(t,e,r,n,i){return Ls.load(t,e,r,i,n)}},COMPUTE_BUDGET_INSTRUCTION_LAYOUTS:ju,ComputeBudgetInstruction:class{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const e=Ur("instruction").decode(t.data);let r;for(const[t,n]of Object.entries(ju))if(n.index==e){r=t;break}if(!r)throw new Error("Instruction type incorrect; not a ComputeBudgetInstruction");return r}static decodeRequestUnits(t){this.checkProgramId(t.programId);const{units:e,additionalFee:r}=Ss(ju.RequestUnits,t.data);return{units:e,additionalFee:r}}static decodeRequestHeapFrame(t){this.checkProgramId(t.programId);const{bytes:e}=Ss(ju.RequestHeapFrame,t.data);return{bytes:e}}static decodeSetComputeUnitLimit(t){this.checkProgramId(t.programId);const{units:e}=Ss(ju.SetComputeUnitLimit,t.data);return{units:e}}static decodeSetComputeUnitPrice(t){this.checkProgramId(t.programId);const{microLamports:e}=Ss(ju.SetComputeUnitPrice,t.data);return{microLamports:e}}static checkProgramId(t){if(!t.equals(Wu.programId))throw new Error("invalid instruction; programId is not ComputeBudgetProgram")}},ComputeBudgetProgram:Wu,Connection:class{constructor(t,e){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 t={};return async e=>{const{commitment:r,config:n}=Qs(e),i=this._buildArgs([],r,void 0,n),o=js(i);return t[o]=t[o]??(async()=>{try{const t=en(await this._rpcRequest("getBlockHeight",i),ra(ln()));if("error"in t)throw new qs(t.error,"failed to get block height information");return t.result}finally{delete t[o]}})(),await t[o]}})(),e&&"string"==typeof e?this._commitment=e:e&&(this._commitment=e.commitment,this._confirmTransactionInitialTimeout=e.confirmTransactionInitialTimeout,r=e.wsEndpoint,n=e.httpHeaders,i=e.fetch,o=e.fetchMiddleware,s=e.disableRetryOnRateLimit,a=e.httpAgent),this._rpcEndpoint=function(t){if(!1===/^https?:/.test(t))throw new TypeError("Endpoint URL must start with `http:` or `https:`.");return t}(t),this._rpcWsEndpoint=r||function(t){const e=t.match(Zs);if(null==e)throw TypeError(`Failed to validate endpoint URL \`${t}\``);const[r,n,i,o]=e,s=t.startsWith("https:")?"wss:":"ws:",a=null==i?null:parseInt(i.slice(1),10);return`${s}//${n}${null==a?"":`:${a+1}`}${o}`}(t),this._rpcClient=function(t,e,r,n,i,o){const s=r||Vs;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(t,e)=>{const r=await new Promise(((r,i)=>{try{n(t,e,((t,e)=>r([t,e])))}catch(t){i(t)}}));return await s(...r)});const u=new ei((async(r,n)=>{const o={method:"POST",body:r,agent:void 0,headers:Object.assign({"Content-Type":"application/json"},e||{},Cu)};try{let e,r=5,u=500;for(;e=a?await a(t,o):await s(t,o),429===e.status&&!0!==i&&(r-=1,0!==r);)console.log(`Server responded with ${e.status} ${e.statusText}. Retrying after ${u}ms delay...`),await Es(u),u*=2;const c=await e.text();e.ok?n(null,c):n(new Error(`${e.status} ${e.statusText}: ${c}`))}catch(t){t instanceof Error&&n(t)}}),{});return u}(t,n,i,o,s,a),this._rpcRequest=function(t){return(e,r)=>new Promise(((n,i)=>{t.request(e,r,((t,e)=>{t?i(t):n(e)}))}))}(this._rpcClient),this._rpcBatchRequest=function(t){return e=>new Promise(((r,n)=>{0===e.length&&r([]);const i=e.map((e=>t.request(e.methodName,e.args)));t.request(i,((t,e)=>{t?n(t):r(e)}))}))}(this._rpcClient),this._rpcWebSocket=new Hs(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(t,e){const{commitment:r,config:n}=Qs(e),i=this._buildArgs([t.toBase58()],r,void 0,n),o=en(await this._rpcRequest("getBalance",i),na(ln()));if("error"in o)throw new qs(o.error,`failed to get balance for ${t.toBase58()}`);return o.result}async getBalance(t,e){return await this.getBalanceAndContext(t,e).then((t=>t.value)).catch((e=>{throw new Error("failed to get balance of account "+t.toBase58()+": "+e)}))}async getBlockTime(t){const e=en(await this._rpcRequest("getBlockTime",[t]),ra(hn(ln())));if("error"in e)throw new qs(e.error,`failed to get block time for slot ${t}`);return e.result}async getMinimumLedgerSlot(){const t=en(await this._rpcRequest("minimumLedgerSlot",[]),ra(ln()));if("error"in t)throw new qs(t.error,"failed to get minimum ledger slot");return t.result}async getFirstAvailableBlock(){const t=en(await this._rpcRequest("getFirstAvailableBlock",[]),Sa);if("error"in t)throw new qs(t.error,"failed to get first available block");return t.result}async getSupply(t){let e={};e="string"==typeof t?{commitment:t}:t?{...t,commitment:t&&t.commitment||this.commitment}:{commitment:this.commitment};const r=en(await this._rpcRequest("getSupply",[e]),Aa);if("error"in r)throw new qs(r.error,"failed to get supply");return r.result}async getTokenSupply(t,e){const r=this._buildArgs([t.toBase58()],e),n=en(await this._rpcRequest("getTokenSupply",r),na(Ia));if("error"in n)throw new qs(n.error,"failed to get token supply");return n.result}async getTokenAccountBalance(t,e){const r=this._buildArgs([t.toBase58()],e),n=en(await this._rpcRequest("getTokenAccountBalance",r),na(Ia));if("error"in n)throw new qs(n.error,"failed to get token account balance");return n.result}async getTokenAccountsByOwner(t,e,r){const{commitment:n,config:i}=Qs(r);let o=[t.toBase58()];"mint"in e?o.push({mint:e.mint.toBase58()}):o.push({programId:e.programId.toBase58()});const s=this._buildArgs(o,n,"base64",i),a=en(await this._rpcRequest("getTokenAccountsByOwner",s),Ma);if("error"in a)throw new qs(a.error,`failed to get token accounts owned by account ${t.toBase58()}`);return a.result}async getParsedTokenAccountsByOwner(t,e,r){let n=[t.toBase58()];"mint"in e?n.push({mint:e.mint.toBase58()}):n.push({programId:e.programId.toBase58()});const i=this._buildArgs(n,r,"jsonParsed"),o=en(await this._rpcRequest("getTokenAccountsByOwner",i),Pa);if("error"in o)throw new qs(o.error,`failed to get token accounts owned by account ${t.toBase58()}`);return o.result}async getLargestAccounts(t){const e={...t,commitment:t&&t.commitment||this.commitment},r=e.filter||e.commitment?[e]:[],n=en(await this._rpcRequest("getLargestAccounts",r),Ta);if("error"in n)throw new qs(n.error,"failed to get largest accounts");return n.result}async getTokenLargestAccounts(t,e){const r=this._buildArgs([t.toBase58()],e),n=en(await this._rpcRequest("getTokenLargestAccounts",r),Ba);if("error"in n)throw new qs(n.error,"failed to get token largest accounts");return n.result}async getAccountInfoAndContext(t,e){const{commitment:r,config:n}=Qs(e),i=this._buildArgs([t.toBase58()],r,"base64",n),o=en(await this._rpcRequest("getAccountInfo",i),na(hn(Oa)));if("error"in o)throw new qs(o.error,`failed to get info about account ${t.toBase58()}`);return o.result}async getParsedAccountInfo(t,e){const{commitment:r,config:n}=Qs(e),i=this._buildArgs([t.toBase58()],r,"jsonParsed",n),o=en(await this._rpcRequest("getAccountInfo",i),na(hn(Ca)));if("error"in o)throw new qs(o.error,`failed to get info about account ${t.toBase58()}`);return o.result}async getAccountInfo(t,e){try{return(await this.getAccountInfoAndContext(t,e)).value}catch(e){throw new Error("failed to get info about account "+t.toBase58()+": "+e)}}async getMultipleParsedAccounts(t,e){const{commitment:r,config:n}=Qs(e),i=t.map((t=>t.toBase58())),o=this._buildArgs([i],r,"jsonParsed",n),s=en(await this._rpcRequest("getMultipleAccounts",o),na(sn(hn(Ca))));if("error"in s)throw new qs(s.error,`failed to get info for accounts ${i}`);return s.result}async getMultipleAccountsInfoAndContext(t,e){const{commitment:r,config:n}=Qs(e),i=t.map((t=>t.toBase58())),o=this._buildArgs([i],r,"base64",n),s=en(await this._rpcRequest("getMultipleAccounts",o),na(sn(hn(Oa))));if("error"in s)throw new qs(s.error,`failed to get info for accounts ${i}`);return s.result}async getMultipleAccountsInfo(t,e){return(await this.getMultipleAccountsInfoAndContext(t,e)).value}async getStakeActivation(t,e,r){const{commitment:n,config:i}=Qs(e),o=this._buildArgs([t.toBase58()],n,void 0,{...i,epoch:null!=r?r:i?.epoch}),s=en(await this._rpcRequest("getStakeActivation",o),ra(za));if("error"in s)throw new qs(s.error,`failed to get Stake Activation ${t.toBase58()}`);return s.result}async getProgramAccounts(t,e){const{commitment:r,config:n}=Qs(e),{encoding:i,...o}=n||{},s=this._buildArgs([t.toBase58()],r,i||"base64",o),a=await this._rpcRequest("getProgramAccounts",s),u=sn(La),c=!0===o.withContext?en(a,na(u)):en(a,ra(u));if("error"in c)throw new qs(c.error,`failed to get accounts owned by program ${t.toBase58()}`);return c.result}async getParsedProgramAccounts(t,e){const{commitment:r,config:n}=Qs(e),i=this._buildArgs([t.toBase58()],r,"jsonParsed",n),o=en(await this._rpcRequest("getProgramAccounts",i),ra(sn(Na)));if("error"in o)throw new qs(o.error,`failed to get accounts owned by program ${t.toBase58()}`);return o.result}async confirmTransaction(t,e){let r,n;if("string"==typeof t)r=t;else{const e=t;if(e.abortSignal?.aborted)return Promise.reject(e.abortSignal.reason);r=e.signature}try{n=ae.decode(r)}catch(t){throw new Error("signature must be base58 encoded: "+r)}return rs(64===n.length,"signature has invalid length"),"string"==typeof t?await this.confirmTransactionUsingLegacyTimeoutStrategy({commitment:e||this.commitment,signature:r}):"lastValidBlockHeight"in t?await this.confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:e||this.commitment,strategy:t}):await this.confirmTransactionUsingDurableNonceStrategy({commitment:e||this.commitment,strategy:t})}getCancellationPromise(t){return new Promise(((e,r)=>{null!=t&&(t.aborted?r(t.reason):t.addEventListener("abort",(()=>{r(t.reason)})))}))}getTransactionConfirmationPromise({commitment:t,signature:e}){let r,n,i=!1;const o=new Promise(((o,s)=>{try{r=this.onSignature(e,((t,e)=>{r=void 0;const n={context:e,value:t};o({__type:as.PROCESSED,response:n})}),t);const a=new Promise((t=>{null==r?t():n=this._onSubscriptionStateChange(r,(e=>{"subscribed"===e&&t()}))}));(async()=>{if(await a,i)return;const r=await this.getSignatureStatus(e);if(i)return;if(null==r)return;const{context:n,value:u}=r;if(null!=u)if(u?.err)s(u.err);else{switch(t){case"confirmed":case"single":case"singleGossip":if("processed"===u.confirmationStatus)return;break;case"finalized":case"max":case"root":if("processed"===u.confirmationStatus||"confirmed"===u.confirmationStatus)return}i=!0,o({__type:as.PROCESSED,response:{context:n,value:u}})}})()}catch(t){s(t)}}));return{abortConfirmation:()=>{n&&(n(),n=void 0),null!=r&&(this.removeSignatureListener(r),r=void 0)},confirmationPromise:o}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:t,strategy:{abortSignal:e,lastValidBlockHeight:r,signature:n}}){let i=!1;const o=new Promise((e=>{const n=async()=>{try{return await this.getBlockHeight(t)}catch(t){return-1}};(async()=>{let t=await n();if(!i){for(;t<=r;){if(await Es(1e3),i)return;if(t=await n(),i)return}e({__type:as.BLOCKHEIGHT_EXCEEDED})}})()})),{abortConfirmation:s,confirmationPromise:a}=this.getTransactionConfirmationPromise({commitment:t,signature:n}),u=this.getCancellationPromise(e);let c;try{const t=await Promise.race([u,a,o]);if(t.__type!==as.PROCESSED)throw new Ho(n);c=t.response}finally{i=!0,s()}return c}async confirmTransactionUsingDurableNonceStrategy({commitment:t,strategy:{abortSignal:e,minContextSlot:r,nonceAccountPubkey:n,nonceValue:i,signature:o}}){let s=!1;const a=new Promise((e=>{let o=i,a=null;const u=async()=>{try{const{context:e,value:i}=await this.getNonceAndContext(n,{commitment:t,minContextSlot:r});return a=e.slot,i?.nonce}catch(t){return o}};(async()=>{if(o=await u(),!s)for(;;){if(i!==o)return void e({__type:as.NONCE_INVALID,slotInWhichNonceDidAdvance:a});if(await Es(2e3),s)return;if(o=await u(),s)return}})()})),{abortConfirmation:u,confirmationPromise:c}=this.getTransactionConfirmationPromise({commitment:t,signature:o}),h=this.getCancellationPromise(e);let l;try{const e=await Promise.race([h,c,a]);if(e.__type===as.PROCESSED)l=e.response;else{let n;for(;;){const t=await this.getSignatureStatus(o);if(null==t)break;if(!(t.context.slot<(e.slotInWhichNonceDidAdvance??r))){n=t;break}await Es(400)}if(!n?.value)throw new Go(o);{const e=t||"finalized",{confirmationStatus:r}=n.value;switch(e){case"processed":case"recent":if("processed"!==r&&"confirmed"!==r&&"finalized"!==r)throw new Go(o);break;case"confirmed":case"single":case"singleGossip":if("confirmed"!==r&&"finalized"!==r)throw new Go(o);break;case"finalized":case"max":case"root":if("finalized"!==r)throw new Go(o)}l={context:n.context,value:{err:n.value.err}}}}}finally{s=!0,u()}return l}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:t,signature:e}){let r;const n=new Promise((e=>{let n=this._confirmTransactionInitialTimeout||6e4;switch(t){case"processed":case"recent":case"single":case"confirmed":case"singleGossip":n=this._confirmTransactionInitialTimeout||3e4}r=setTimeout((()=>e({__type:as.TIMED_OUT,timeoutMs:n})),n)})),{abortConfirmation:i,confirmationPromise:o}=this.getTransactionConfirmationPromise({commitment:t,signature:e});let s;try{const t=await Promise.race([o,n]);if(t.__type!==as.PROCESSED)throw new $o(e,t.timeoutMs/1e3);s=t.response}finally{clearTimeout(r),i()}return s}async getClusterNodes(){const t=en(await this._rpcRequest("getClusterNodes",[]),ra(sn(Ya)));if("error"in t)throw new qs(t.error,"failed to get cluster nodes");return t.result}async getVoteAccounts(t){const e=this._buildArgs([],t),r=en(await this._rpcRequest("getVoteAccounts",e),Xa);if("error"in r)throw new qs(r.error,"failed to get vote accounts");return r.result}async getSlot(t){const{commitment:e,config:r}=Qs(t),n=this._buildArgs([],e,void 0,r),i=en(await this._rpcRequest("getSlot",n),ra(ln()));if("error"in i)throw new qs(i.error,"failed to get slot");return i.result}async getSlotLeader(t){const{commitment:e,config:r}=Qs(t),n=this._buildArgs([],e,void 0,r),i=en(await this._rpcRequest("getSlotLeader",n),ra(pn()));if("error"in i)throw new qs(i.error,"failed to get slot leader");return i.result}async getSlotLeaders(t,e){const r=[t,e],n=en(await this._rpcRequest("getSlotLeaders",r),ra(sn(Ys)));if("error"in n)throw new qs(n.error,"failed to get slot leaders");return n.result}async getSignatureStatus(t,e){const{context:r,value:n}=await this.getSignatureStatuses([t],e);rs(1===n.length);return{context:r,value:n[0]}}async getSignatureStatuses(t,e){const r=[t];e&&r.push(e);const n=en(await this._rpcRequest("getSignatureStatuses",r),eu);if("error"in n)throw new qs(n.error,"failed to get signature status");return n.result}async getTransactionCount(t){const{commitment:e,config:r}=Qs(t),n=this._buildArgs([],e,void 0,r),i=en(await this._rpcRequest("getTransactionCount",n),ra(ln()));if("error"in i)throw new qs(i.error,"failed to get transaction count");return i.result}async getTotalSupply(t){return(await this.getSupply({commitment:t,excludeNonCirculatingAccountsList:!0})).value.total}async getInflationGovernor(t){const e=this._buildArgs([],t),r=en(await this._rpcRequest("getInflationGovernor",e),ba);if("error"in r)throw new qs(r.error,"failed to get inflation");return r.result}async getInflationReward(t,e,r){const{commitment:n,config:i}=Qs(r),o=this._buildArgs([t.map((t=>t.toBase58()))],n,void 0,{...i,epoch:null!=e?e:i?.epoch}),s=en(await this._rpcRequest("getInflationReward",o),aa);if("error"in s)throw new qs(s.error,"failed to get inflation reward");return s.result}async getInflationRate(){const t=en(await this._rpcRequest("getInflationRate",[]),va);if("error"in t)throw new qs(t.error,"failed to get inflation rate");return t.result}async getEpochInfo(t){const{commitment:e,config:r}=Qs(t),n=this._buildArgs([],e,void 0,r),i=en(await this._rpcRequest("getEpochInfo",n),ka);if("error"in i)throw new qs(i.error,"failed to get epoch info");return i.result}async getEpochSchedule(){const t=en(await this._rpcRequest("getEpochSchedule",[]),Ea);if("error"in t)throw new qs(t.error,"failed to get epoch schedule");const e=t.result;return new Ks(e.slotsPerEpoch,e.leaderScheduleSlotOffset,e.warmup,e.firstNormalEpoch,e.firstNormalSlot)}async getLeaderSchedule(){const t=en(await this._rpcRequest("getLeaderSchedule",[]),xa);if("error"in t)throw new qs(t.error,"failed to get leader schedule");return t.result}async getMinimumBalanceForRentExemption(t,e){const r=this._buildArgs([t],e),n=en(await this._rpcRequest("getMinimumBalanceForRentExemption",r),ru);return"error"in n?(console.warn("Unable to fetch minimum balance for rent exemption"),0):n.result}async getRecentBlockhashAndContext(t){const e=this._buildArgs([],t),r=en(await this._rpcRequest("getRecentBlockhash",e),Iu);if("error"in r)throw new qs(r.error,"failed to get recent blockhash");return r.result}async getRecentPerformanceSamples(t){const e=en(await this._rpcRequest("getRecentPerformanceSamples",t?[t]:[]),Ru);if("error"in e)throw new qs(e.error,"failed to get recent performance samples");return e.result}async getFeeCalculatorForBlockhash(t,e){const r=this._buildArgs([t],e),n=en(await this._rpcRequest("getFeeCalculatorForBlockhash",r),Pu);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(t,e){const r=Lo(t.serialize()).toString("base64"),n=this._buildArgs([r],e),i=en(await this._rpcRequest("getFeeForMessage",n),na(hn(ln())));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(t){const e=t?.lockedWritableAccounts?.map((t=>t.toBase58())),r=e?.length?[e]:[],n=en(await this._rpcRequest("getRecentPrioritizationFees",r),_a);if("error"in n)throw new qs(n.error,"failed to get recent prioritization fees");return n.result}async getRecentBlockhash(t){try{return(await this.getRecentBlockhashAndContext(t)).value}catch(t){throw new Error("failed to get recent blockhash: "+t)}}async getLatestBlockhash(t){try{return(await this.getLatestBlockhashAndContext(t)).value}catch(t){throw new Error("failed to get recent blockhash: "+t)}}async getLatestBlockhashAndContext(t){const{commitment:e,config:r}=Qs(t),n=this._buildArgs([],e,void 0,r),i=en(await this._rpcRequest("getLatestBlockhash",n),Bu);if("error"in i)throw new qs(i.error,"failed to get latest blockhash");return i.result}async isBlockhashValid(t,e){const{commitment:r,config:n}=Qs(e),i=this._buildArgs([t],r,void 0,n),o=en(await this._rpcRequest("isBlockhashValid",i),Mu);if("error"in o)throw new qs(o.error,"failed to determine if the blockhash `"+t+"`is valid");return o.result}async getVersion(){const t=en(await this._rpcRequest("getVersion",[]),ra(ga));if("error"in t)throw new qs(t.error,"failed to get version");return t.result}async getGenesisHash(){const t=en(await this._rpcRequest("getGenesisHash",[]),ra(pn()));if("error"in t)throw new qs(t.error,"failed to get genesis hash");return t.result}async getBlock(t,e){const{commitment:r,config:n}=Qs(e),i=this._buildArgsAtLeastConfirmed([t],r,void 0,n),o=await this._rpcRequest("getBlock",i);try{switch(n?.transactionDetails){case"accounts":{const t=en(o,bu);if("error"in t)throw t.error;return t.result}case"none":{const t=en(o,wu);if("error"in t)throw t.error;return t.result}default:{const t=en(o,mu);if("error"in t)throw t.error;const{result:e}=t;return e?{...e,transactions:e.transactions.map((({transaction:t,meta:e,version:r})=>({meta:e,transaction:{...t,message:oa(r,t.message)},version:r})))}:null}}}catch(t){throw new qs(t,"failed to get confirmed block")}}async getParsedBlock(t,e){const{commitment:r,config:n}=Qs(e),i=this._buildArgsAtLeastConfirmed([t],r,"jsonParsed",n),o=await this._rpcRequest("getBlock",i);try{switch(n?.transactionDetails){case"accounts":{const t=en(o,_u);if("error"in t)throw t.error;return t.result}case"none":{const t=en(o,ku);if("error"in t)throw t.error;return t.result}default:{const t=en(o,vu);if("error"in t)throw t.error;return t.result}}}catch(t){throw new qs(t,"failed to get block")}}async getBlockProduction(t){let e,r;if("string"==typeof t)r=t;else if(t){const{commitment:n,...i}=t;r=n,e=i}const n=this._buildArgs([],r,"base64",e),i=en(await this._rpcRequest("getBlockProduction",n),wa);if("error"in i)throw new qs(i.error,"failed to get block production information");return i.result}async getTransaction(t,e){const{commitment:r,config:n}=Qs(e),i=this._buildArgsAtLeastConfirmed([t],r,void 0,n),o=en(await this._rpcRequest("getTransaction",i),Su);if("error"in o)throw new qs(o.error,"failed to get transaction");const s=o.result;return s?{...s,transaction:{...s.transaction,message:oa(s.version,s.transaction.message)}}:s}async getParsedTransaction(t,e){const{commitment:r,config:n}=Qs(e),i=this._buildArgsAtLeastConfirmed([t],r,"jsonParsed",n),o=en(await this._rpcRequest("getTransaction",i),Au);if("error"in o)throw new qs(o.error,"failed to get transaction");return o.result}async getParsedTransactions(t,e){const{commitment:r,config:n}=Qs(e),i=t.map((t=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([t],r,"jsonParsed",n)})));return(await this._rpcBatchRequest(i)).map((t=>{const e=en(t,Au);if("error"in e)throw new qs(e.error,"failed to get transactions");return e.result}))}async getTransactions(t,e){const{commitment:r,config:n}=Qs(e),i=t.map((t=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([t],r,void 0,n)})));return(await this._rpcBatchRequest(i)).map((t=>{const e=en(t,Su);if("error"in e)throw new qs(e.error,"failed to get transactions");const r=e.result;return r?{...r,transaction:{...r.transaction,message:oa(r.version,r.transaction.message)}}:r}))}async getConfirmedBlock(t,e){const r=this._buildArgsAtLeastConfirmed([t],e),n=en(await this._rpcRequest("getConfirmedBlock",r),Eu);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 "+t+" not found");const o={...i,transactions:i.transactions.map((({transaction:t,meta:e})=>{const r=new is(t.message);return{meta:e,transaction:{...t,message:r}}}))};return{...o,transactions:o.transactions.map((({transaction:t,meta:e})=>({meta:e,transaction:hs.populate(t.message,t.signatures)})))}}async getBlocks(t,e,r){const n=this._buildArgsAtLeastConfirmed(void 0!==e?[t,e]:[t],r),i=en(await this._rpcRequest("getBlocks",n),ra(sn(ln())));if("error"in i)throw new qs(i.error,"failed to get blocks");return i.result}async getBlockSignatures(t,e){const r=this._buildArgsAtLeastConfirmed([t],e,void 0,{transactionDetails:"signatures",rewards:!1}),n=en(await this._rpcRequest("getBlock",r),xu);if("error"in n)throw new qs(n.error,"failed to get block");const i=n.result;if(!i)throw new Error("Block "+t+" not found");return i}async getConfirmedBlockSignatures(t,e){const r=this._buildArgsAtLeastConfirmed([t],e,void 0,{transactionDetails:"signatures",rewards:!1}),n=en(await this._rpcRequest("getConfirmedBlock",r),xu);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 "+t+" not found");return i}async getConfirmedTransaction(t,e){const r=this._buildArgsAtLeastConfirmed([t],e),n=en(await this._rpcRequest("getConfirmedTransaction",r),Su);if("error"in n)throw new qs(n.error,"failed to get transaction");const i=n.result;if(!i)return i;const o=new is(i.transaction.message),s=i.transaction.signatures;return{...i,transaction:hs.populate(o,s)}}async getParsedConfirmedTransaction(t,e){const r=this._buildArgsAtLeastConfirmed([t],e,"jsonParsed"),n=en(await this._rpcRequest("getConfirmedTransaction",r),Au);if("error"in n)throw new qs(n.error,"failed to get confirmed transaction");return n.result}async getParsedConfirmedTransactions(t,e){const r=t.map((t=>({methodName:"getConfirmedTransaction",args:this._buildArgsAtLeastConfirmed([t],e,"jsonParsed")})));return(await this._rpcBatchRequest(r)).map((t=>{const e=en(t,Au);if("error"in e)throw new qs(e.error,"failed to get confirmed transactions");return e.result}))}async getConfirmedSignaturesForAddress(t,e,r){let n={},i=await this.getFirstAvailableBlock();for(;!("until"in n)&&!(--e<=0||e<i);)try{const t=await this.getConfirmedBlockSignatures(e,"finalized");t.signatures.length>0&&(n.until=t.signatures[t.signatures.length-1].toString())}catch(t){if(t instanceof Error&&t.message.includes("skipped"))continue;throw t}let o=await this.getSlot("finalized");for(;!("before"in n||++r>o);)try{const t=await this.getConfirmedBlockSignatures(r);t.signatures.length>0&&(n.before=t.signatures[t.signatures.length-1].toString())}catch(t){if(t instanceof Error&&t.message.includes("skipped"))continue;throw t}return(await this.getConfirmedSignaturesForAddress2(t,n)).map((t=>t.signature))}async getConfirmedSignaturesForAddress2(t,e,r){const n=this._buildArgsAtLeastConfirmed([t.toBase58()],r,void 0,e),i=en(await this._rpcRequest("getConfirmedSignaturesForAddress2",n),Da);if("error"in i)throw new qs(i.error,"failed to get confirmed signatures for address");return i.result}async getSignaturesForAddress(t,e,r){const n=this._buildArgsAtLeastConfirmed([t.toBase58()],r,void 0,e),i=en(await this._rpcRequest("getSignaturesForAddress",n),ja);if("error"in i)throw new qs(i.error,"failed to get signatures for address");return i.result}async getAddressLookupTable(t,e){const{context:r,value:n}=await this.getAccountInfoAndContext(t,e);let i=null;return null!==n&&(i=new $s({key:t,state:$s.deserialize(n.data)})),{context:r,value:i}}async getNonceAndContext(t,e){const{context:r,value:n}=await this.getAccountInfoAndContext(t,e);let i=null;return null!==n&&(i=Ms.fromAccountData(n.data)),{context:r,value:i}}async getNonce(t,e){return await this.getNonceAndContext(t,e).then((t=>t.value)).catch((e=>{throw new Error("failed to get nonce for account "+t.toBase58()+": "+e)}))}async requestAirdrop(t,e){const r=en(await this._rpcRequest("requestAirdrop",[t.toBase58(),e]),Tu);if("error"in r)throw new qs(r.error,`airdrop to ${t.toBase58()} failed`);return r.result}async _blockhashWithExpiryBlockHeight(t){if(!t){for(;this._pollingBlockhash;)await Es(100);const t=Date.now()-this._blockhashInfo.lastFetch>=3e4;if(null!==this._blockhashInfo.latestBlockhash&&!t)return this._blockhashInfo.latestBlockhash}return await this._pollNewBlockhash()}async _pollNewBlockhash(){this._pollingBlockhash=!0;try{const t=Date.now(),e=this._blockhashInfo.latestBlockhash,r=e?e.blockhash:null;for(let t=0;t<50;t++){const t=await this.getLatestBlockhash("finalized");if(r!==t.blockhash)return this._blockhashInfo={latestBlockhash:t,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},t;await Es(200)}throw new Error(`Unable to obtain a new blockhash after ${Date.now()-t}ms`)}finally{this._pollingBlockhash=!1}}async getStakeMinimumDelegation(t){const{commitment:e,config:r}=Qs(t),n=this._buildArgs([],e,"base64",r),i=en(await this._rpcRequest("getStakeMinimumDelegation",n),na(ln()));if("error"in i)throw new qs(i.error,"failed to get stake minimum delegation");return i.result}async simulateTransaction(t,e,r){if("message"in t){const i=t.serialize(),o=n.Buffer.from(i).toString("base64");if(Array.isArray(e)||void 0!==r)throw new Error("Invalid arguments");const s=e||{};s.encoding="base64","commitment"in s||(s.commitment=this.commitment);const a=[o,s],u=en(await this._rpcRequest("simulateTransaction",a),ma);if("error"in u)throw new Error("failed to simulate transaction: "+u.error.message);return u.result}let i;if(t instanceof hs){let e=t;i=new hs,i.feePayer=e.feePayer,i.instructions=t.instructions,i.nonceInfo=e.nonceInfo,i.signatures=e.signatures}else i=hs.populate(t),i._message=i._json=void 0;if(void 0!==e&&!Array.isArray(e))throw new Error("Invalid arguments");const o=e;if(i.nonceInfo&&o)i.sign(...o);else{let t=this._disableBlockhashCaching;for(;;){const e=await this._blockhashWithExpiryBlockHeight(t);if(i.lastValidBlockHeight=e.lastValidBlockHeight,i.recentBlockhash=e.blockhash,!o)break;if(i.sign(...o),!i.signature)throw new Error("!signature");const r=i.signature.toString("base64");if(!this._blockhashInfo.simulatedSignatures.includes(r)&&!this._blockhashInfo.transactionSignatures.includes(r)){this._blockhashInfo.simulatedSignatures.push(r);break}t=!0}}const s=i._compile(),a=s.serialize(),u=i._serialize(a).toString("base64"),c={encoding:"base64",commitment:this.commitment};if(r){const t=(Array.isArray(r)?r:s.nonProgramIds()).map((t=>t.toBase58()));c.accounts={encoding:"base64",addresses:t}}o&&(c.sigVerify=!0);const h=[u,c],l=en(await this._rpcRequest("simulateTransaction",h),ma);if("error"in l){let t;if("data"in l.error&&(t=l.error.data.logs,t&&Array.isArray(t))){const e="\n ",r=e+t.join(e);console.error(l.error.message,r)}throw new Fs("failed to simulate transaction: "+l.error.message,t)}return l.result}async sendTransaction(t,e,r){if("version"in t){if(e&&Array.isArray(e))throw new Error("Invalid arguments");const r=t.serialize();return await this.sendRawTransaction(r,e)}if(void 0===e||!Array.isArray(e))throw new Error("Invalid arguments");const n=e;if(t.nonceInfo)t.sign(...n);else{let e=this._disableBlockhashCaching;for(;;){const r=await this._blockhashWithExpiryBlockHeight(e);if(t.lastValidBlockHeight=r.lastValidBlockHeight,t.recentBlockhash=r.blockhash,t.sign(...n),!t.signature)throw new Error("!signature");const i=t.signature.toString("base64");if(!this._blockhashInfo.transactionSignatures.includes(i)){this._blockhashInfo.transactionSignatures.push(i);break}e=!0}}const i=t.serialize();return await this.sendRawTransaction(i,r)}async sendRawTransaction(t,e){const r=Lo(t).toString("base64");return await this.sendEncodedTransaction(r,e)}async sendEncodedTransaction(t,e){const r={encoding:"base64"},n=e&&e.skipPreflight,i=e&&e.preflightCommitment||this.commitment;e&&null!=e.maxRetries&&(r.maxRetries=e.maxRetries),e&&null!=e.minContextSlot&&(r.minContextSlot=e.minContextSlot),n&&(r.skipPreflight=n),i&&(r.preflightCommitment=i);const o=[t,r],s=en(await this._rpcRequest("sendTransaction",o),Ou);if("error"in s){let t;throw"data"in s.error&&(t=s.error.data.logs),new Fs("failed to send transaction: "+s.error.message,t)}return s.result}_wsOnOpen(){this._rpcWebSocketConnected=!0,this._rpcWebSocketHeartbeat=setInterval((()=>{(async()=>{try{await this._rpcWebSocket.notify("ping")}catch{}})()}),5e3),this._updateSubscriptions()}_wsOnError(t){this._rpcWebSocketConnected=!1,console.error("ws error:",t.message)}_wsOnClose(t){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!==t?(this._subscriptionCallbacksByServerSubscriptionId={},Object.entries(this._subscriptionsByHash).forEach((([t,e])=>{this._setSubscription(t,{...e,state:"pending"})}))):this._updateSubscriptions()}_setSubscription(t,e){const r=this._subscriptionsByHash[t]?.state;if(this._subscriptionsByHash[t]=e,r!==e.state){const r=this._subscriptionStateChangeCallbacksByHash[t];r&&r.forEach((t=>{try{t(e.state)}catch{}}))}}_onSubscriptionStateChange(t,e){const r=this._subscriptionHashByClientSubscriptionId[t];if(null==r)return()=>{};const n=this._subscriptionStateChangeCallbacksByHash[r]||=new Set;return n.add(e),()=>{n.delete(e),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(t){t instanceof Error&&console.log(`Error when closing socket connection: ${t.message}`)}}),500)));if(null!==this._rpcWebSocketIdleTimeout&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketConnected=!0),!this._rpcWebSocketConnected)return void this._rpcWebSocket.connect();const t=this._rpcWebSocketGeneration,e=()=>t===this._rpcWebSocketGeneration;await Promise.all(Object.keys(this._subscriptionsByHash).map((async t=>{const r=this._subscriptionsByHash[t];if(void 0!==r)switch(r.state){case"pending":case"unsubscribed":if(0===r.callbacks.size)return delete this._subscriptionsByHash[t],"unsubscribed"===r.state&&delete this._subscriptionCallbacksByServerSubscriptionId[r.serverSubscriptionId],void await this._updateSubscriptions();await(async()=>{const{args:n,method:i}=r;try{this._setSubscription(t,{...r,state:"subscribing"});const e=await this._rpcWebSocket.call(i,n);this._setSubscription(t,{...r,serverSubscriptionId:e,state:"subscribed"}),this._subscriptionCallbacksByServerSubscriptionId[e]=r.callbacks,await this._updateSubscriptions()}catch(o){if(o instanceof Error&&console.error(`${i} error for argument`,n,o.message),!e())return;this._setSubscription(t,{...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(t,{...r,state:"unsubscribing"}),this._setSubscription(t,{...r,state:"unsubscribing"});try{await this._rpcWebSocket.call(i,[n])}catch(n){if(n instanceof Error&&console.error(`${i} error:`,n.message),!e())return;return this._setSubscription(t,{...r,state:"subscribed"}),void await this._updateSubscriptions()}}this._setSubscription(t,{...r,state:"unsubscribed"}),await this._updateSubscriptions()})()}})))}_handleServerNotification(t,e){const r=this._subscriptionCallbacksByServerSubscriptionId[t];void 0!==r&&r.forEach((t=>{try{t(...e)}catch(t){console.error(t)}}))}_wsOnAccountNotification(t){const{result:e,subscription:r}=en(t,Wa);this._handleServerNotification(r,[e.value,e.context])}_makeSubscription(t,e){const r=this._nextClientSubscriptionId++,n=js([t.method,e],!0),i=this._subscriptionsByHash[n];return void 0===i?this._subscriptionsByHash[n]={...t,args:e,callbacks:new Set([t.callback]),state:"pending"}:i.callbacks.add(t.callback),this._subscriptionHashByClientSubscriptionId[r]=n,this._subscriptionDisposeFunctionsByClientSubscriptionId[r]=async()=>{delete this._subscriptionDisposeFunctionsByClientSubscriptionId[r],delete this._subscriptionHashByClientSubscriptionId[r];const e=this._subscriptionsByHash[n];rs(void 0!==e,`Could not find a \`Subscription\` when tearing down client subscription #${r}`),e.callbacks.delete(t.callback),await this._updateSubscriptions()},this._updateSubscriptions(),r}onAccountChange(t,e,r){const n=this._buildArgs([t.toBase58()],r||this._commitment||"finalized","base64");return this._makeSubscription({callback:e,method:"accountSubscribe",unsubscribeMethod:"accountUnsubscribe"},n)}async removeAccountChangeListener(t){await this._unsubscribeClientSubscription(t,"account change")}_wsOnProgramAccountNotification(t){const{result:e,subscription:r}=en(t,Fa);this._handleServerNotification(r,[{accountId:e.value.pubkey,accountInfo:e.value.account},e.context])}onProgramAccountChange(t,e,r,n){const i=this._buildArgs([t.toBase58()],r||this._commitment||"finalized","base64",n?{filters:n}:void 0);return this._makeSubscription({callback:e,method:"programSubscribe",unsubscribeMethod:"programUnsubscribe"},i)}async removeProgramAccountChangeListener(t){await this._unsubscribeClientSubscription(t,"program account change")}onLogs(t,e,r){const n=this._buildArgs(["object"==typeof t?{mentions:[t.toString()]}:t],r||this._commitment||"finalized");return this._makeSubscription({callback:e,method:"logsSubscribe",unsubscribeMethod:"logsUnsubscribe"},n)}async removeOnLogsListener(t){await this._unsubscribeClientSubscription(t,"logs")}_wsOnLogsNotification(t){const{result:e,subscription:r}=en(t,Uu);this._handleServerNotification(r,[e.value,e.context])}_wsOnSlotNotification(t){const{result:e,subscription:r}=en(t,Va);this._handleServerNotification(r,[e])}onSlotChange(t){return this._makeSubscription({callback:t,method:"slotSubscribe",unsubscribeMethod:"slotUnsubscribe"},[])}async removeSlotChangeListener(t){await this._unsubscribeClientSubscription(t,"slot change")}_wsOnSlotUpdatesNotification(t){const{result:e,subscription:r}=en(t,$a);this._handleServerNotification(r,[e])}onSlotUpdate(t){return this._makeSubscription({callback:t,method:"slotsUpdatesSubscribe",unsubscribeMethod:"slotsUpdatesUnsubscribe"},[])}async removeSlotUpdateListener(t){await this._unsubscribeClientSubscription(t,"slot update")}async _unsubscribeClientSubscription(t,e){const r=this._subscriptionDisposeFunctionsByClientSubscriptionId[t];r?await r():console.warn(`Ignored unsubscribe request because an active subscription with id \`${t}\` for '${e}' events could not be found.`)}_buildArgs(t,e,r,n){const i=e||this._commitment;if(i||r||n){let e={};r&&(e.encoding=r),i&&(e.commitment=i),n&&(e=Object.assign(e,n)),t.push(e)}return t}_buildArgsAtLeastConfirmed(t,e,r,n){const i=e||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(t,e,r,n)}_wsOnSignatureNotification(t){const{result:e,subscription:r}=en(t,Ga);"receivedSignature"!==e.value&&this._subscriptionsAutoDisposedByRpc.add(r),this._handleServerNotification(r,"receivedSignature"===e.value?[{type:"received"},e.context]:[{type:"status",result:e.value},e.context])}onSignature(t,e,r){const n=this._buildArgs([t],r||this._commitment||"finalized"),i=this._makeSubscription({callback:(t,r)=>{if("status"===t.type){e(t.result,r);try{this.removeSignatureListener(i)}catch(t){}}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},n);return i}onSignatureWithOptions(t,e,r){const{commitment:n,...i}={...r,commitment:r&&r.commitment||this._commitment||"finalized"},o=this._buildArgs([t],n,void 0,i),s=this._makeSubscription({callback:(t,r)=>{e(t,r);try{this.removeSignatureListener(s)}catch(t){}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},o);return s}async removeSignatureListener(t){await this._unsubscribeClientSubscription(t,"signature result")}_wsOnRootNotification(t){const{result:e,subscription:r}=en(t,Za);this._handleServerNotification(r,[e])}onRootChange(t){return this._makeSubscription({callback:t,method:"rootSubscribe",unsubscribeMethod:"rootUnsubscribe"},[])}async removeRootChangeListener(t){await this._unsubscribeClientSubscription(t,"root change")}},Ed25519Program:Fu,Enum:class extends Uo{constructor(t){if(super(t),this.enum="",1!==Object.keys(t).length)throw new Error("Enum can only take single value");Object.keys(t).map((t=>{this.enum=t}))}},EpochSchedule:Ks,FeeCalculatorLayout:As,Keypair:Nu,LAMPORTS_PER_SOL:1e9,LOOKUP_TABLE_INSTRUCTION_LAYOUTS:zu,Loader:Ls,Lockup:Yu,MAX_SEED_LENGTH:32,Message:is,MessageAccountKeys:Zo,MessageV0:os,NONCE_ACCOUNT_LENGTH:Bs,NonceAccount:Ms,PACKET_DATA_SIZE:Fo,PUBLIC_KEY_LENGTH:Do,PublicKey:Wo,SIGNATURE_LENGTH_IN_BYTES:Vo,SOLANA_SCHEMA:Co,STAKE_CONFIG_ID:Gu,STAKE_INSTRUCTION_LAYOUTS:Ju,SYSTEM_INSTRUCTION_LAYOUTS:Ts,SYSVAR_CLOCK_PUBKEY:ds,SYSVAR_EPOCH_SCHEDULE_PUBKEY:ps,SYSVAR_INSTRUCTIONS_PUBKEY:ys,SYSVAR_RECENT_BLOCKHASHES_PUBKEY:gs,SYSVAR_RENT_PUBKEY:ms,SYSVAR_REWARDS_PUBKEY:ws,SYSVAR_SLOT_HASHES_PUBKEY:bs,SYSVAR_SLOT_HISTORY_PUBKEY:vs,SYSVAR_STAKE_HISTORY_PUBKEY:_s,Secp256k1Program:Hu,SendTransactionError:Fs,SolanaJSONRPCError:qs,SolanaJSONRPCErrorCode:{JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP:-32001,JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE:-32002,JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE:-32003,JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE:-32004,JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY:-32005,JSON_RPC_SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE:-32006,JSON_RPC_SERVER_ERROR_SLOT_SKIPPED:-32007,JSON_RPC_SERVER_ERROR_NO_SNAPSHOT:-32008,JSON_RPC_SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED:-32009,JSON_RPC_SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX:-32010,JSON_RPC_SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE:-32011,JSON_RPC_SCAN_ERROR:-32012,JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH:-32013,JSON_RPC_SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET:-32014,JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION:-32015,JSON_RPC_SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED:-32016},StakeAuthorizationLayout:Xu,StakeInstruction:class{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const e=Nr("instruction").decode(t.data);let r;for(const[t,n]of Object.entries(Ju))if(n.index==e){r=t;break}if(!r)throw new Error("Instruction type incorrect; not a StakeInstruction");return r}static decodeInitialize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{authorized:e,lockup:r}=Ss(Ju.Initialize,t.data);return{stakePubkey:t.keys[0].pubkey,authorized:new Zu(new Wo(e.staker),new Wo(e.withdrawer)),lockup:new Yu(r.unixTimestamp,r.epoch,new Wo(r.custodian))}}static decodeDelegate(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,6),Ss(Ju.Delegate,t.data),{stakePubkey:t.keys[0].pubkey,votePubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[5].pubkey}}static decodeAuthorize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{newAuthorized:e,stakeAuthorizationType:r}=Ss(Ju.Authorize,t.data),n={stakePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey,newAuthorizedPubkey:new Wo(e),stakeAuthorizationType:{index:r}};return t.keys.length>3&&(n.custodianPubkey=t.keys[3].pubkey),n}static decodeAuthorizeWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{newAuthorized:e,stakeAuthorizationType:r,authoritySeed:n,authorityOwner:i}=Ss(Ju.AuthorizeWithSeed,t.data),o={stakePubkey:t.keys[0].pubkey,authorityBase:t.keys[1].pubkey,authoritySeed:n,authorityOwner:new Wo(i),newAuthorizedPubkey:new Wo(e),stakeAuthorizationType:{index:r}};return t.keys.length>3&&(o.custodianPubkey=t.keys[3].pubkey),o}static decodeSplit(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{lamports:e}=Ss(Ju.Split,t.data);return{stakePubkey:t.keys[0].pubkey,splitStakePubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[2].pubkey,lamports:e}}static decodeMerge(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3),Ss(Ju.Merge,t.data),{stakePubkey:t.keys[0].pubkey,sourceStakePubKey:t.keys[1].pubkey,authorizedPubkey:t.keys[4].pubkey}}static decodeWithdraw(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,5);const{lamports:e}=Ss(Ju.Withdraw,t.data),r={stakePubkey:t.keys[0].pubkey,toPubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[4].pubkey,lamports:e};return t.keys.length>5&&(r.custodianPubkey=t.keys[5].pubkey),r}static decodeDeactivate(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3),Ss(Ju.Deactivate,t.data),{stakePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey}}static checkProgramId(t){if(!t.equals(Qu.programId))throw new Error("invalid instruction; programId is not StakeProgram")}static checkKeyLength(t,e){if(t.length<e)throw new Error(`invalid instruction; found ${t.length} keys, expected at least ${e}`)}},StakeProgram:Qu,Struct:Uo,SystemInstruction:class{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const e=Nr("instruction").decode(t.data);let r;for(const[t,n]of Object.entries(Ts))if(n.index==e){r=t;break}if(!r)throw new Error("Instruction type incorrect; not a SystemInstruction");return r}static decodeCreateAccount(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{lamports:e,space:r,programId:n}=Ss(Ts.Create,t.data);return{fromPubkey:t.keys[0].pubkey,newAccountPubkey:t.keys[1].pubkey,lamports:e,space:r,programId:new Wo(n)}}static decodeTransfer(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{lamports:e}=Ss(Ts.Transfer,t.data);return{fromPubkey:t.keys[0].pubkey,toPubkey:t.keys[1].pubkey,lamports:e}}static decodeTransferWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{lamports:e,seed:r,programId:n}=Ss(Ts.TransferWithSeed,t.data);return{fromPubkey:t.keys[0].pubkey,basePubkey:t.keys[1].pubkey,toPubkey:t.keys[2].pubkey,lamports:e,seed:r,programId:new Wo(n)}}static decodeAllocate(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{space:e}=Ss(Ts.Allocate,t.data);return{accountPubkey:t.keys[0].pubkey,space:e}}static decodeAllocateWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{base:e,seed:r,space:n,programId:i}=Ss(Ts.AllocateWithSeed,t.data);return{accountPubkey:t.keys[0].pubkey,basePubkey:new Wo(e),seed:r,space:n,programId:new Wo(i)}}static decodeAssign(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{programId:e}=Ss(Ts.Assign,t.data);return{accountPubkey:t.keys[0].pubkey,programId:new Wo(e)}}static decodeAssignWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{base:e,seed:r,programId:n}=Ss(Ts.AssignWithSeed,t.data);return{accountPubkey:t.keys[0].pubkey,basePubkey:new Wo(e),seed:r,programId:new Wo(n)}}static decodeCreateWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{base:e,seed:r,lamports:n,space:i,programId:o}=Ss(Ts.CreateWithSeed,t.data);return{fromPubkey:t.keys[0].pubkey,newAccountPubkey:t.keys[1].pubkey,basePubkey:new Wo(e),seed:r,lamports:n,space:i,programId:new Wo(o)}}static decodeNonceInitialize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{authorized:e}=Ss(Ts.InitializeNonceAccount,t.data);return{noncePubkey:t.keys[0].pubkey,authorizedPubkey:new Wo(e)}}static decodeNonceAdvance(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3),Ss(Ts.AdvanceNonceAccount,t.data),{noncePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey}}static decodeNonceWithdraw(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,5);const{lamports:e}=Ss(Ts.WithdrawNonceAccount,t.data);return{noncePubkey:t.keys[0].pubkey,toPubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[4].pubkey,lamports:e}}static decodeNonceAuthorize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{authorized:e}=Ss(Ts.AuthorizeNonceAccount,t.data);return{noncePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[1].pubkey,newAuthorizedPubkey:new Wo(e)}}static checkProgramId(t){if(!t.equals(Os.programId))throw new Error("invalid instruction; programId is not SystemProgram")}static checkKeyLength(t,e){if(t.length<e)throw new Error(`invalid instruction; found ${t.length} keys, expected at least ${e}`)}},SystemProgram:Os,Transaction:hs,TransactionExpiredBlockheightExceededError:Ho,TransactionExpiredNonceInvalidError:Go,TransactionExpiredTimeoutError:$o,TransactionInstruction:cs,TransactionMessage:ls,TransactionStatus:as,VALIDATOR_INFO_KEY:ic,VERSION_PREFIX_MASK:qo,VOTE_PROGRAM_ID:ac,ValidatorInfo:sc,VersionedMessage:ss,VersionedTransaction:fs,VoteAccount:cc,VoteAuthorizationLayout:rc,VoteInit:tc,VoteInstruction:class{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const e=Nr("instruction").decode(t.data);let r;for(const[t,n]of Object.entries(ec))if(n.index==e){r=t;break}if(!r)throw new Error("Instruction type incorrect; not a VoteInstruction");return r}static decodeInitializeAccount(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,4);const{voteInit:e}=Ss(ec.InitializeAccount,t.data);return{votePubkey:t.keys[0].pubkey,nodePubkey:t.keys[3].pubkey,voteInit:new tc(new Wo(e.nodePubkey),new Wo(e.authorizedVoter),new Wo(e.authorizedWithdrawer),e.commission)}}static decodeAuthorize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{newAuthorized:e,voteAuthorizationType:r}=Ss(ec.Authorize,t.data);return{votePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey,newAuthorizedPubkey:new Wo(e),voteAuthorizationType:{index:r}}}static decodeAuthorizeWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:e,currentAuthorityDerivedKeySeed:r,newAuthorized:n,voteAuthorizationType:i}}=Ss(ec.AuthorizeWithSeed,t.data);return{currentAuthorityDerivedKeyBasePubkey:t.keys[2].pubkey,currentAuthorityDerivedKeyOwnerPubkey:new Wo(e),currentAuthorityDerivedKeySeed:r,newAuthorizedPubkey:new Wo(n),voteAuthorizationType:{index:i},votePubkey:t.keys[0].pubkey}}static decodeWithdraw(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{lamports:e}=Ss(ec.Withdraw,t.data);return{votePubkey:t.keys[0].pubkey,authorizedWithdrawerPubkey:t.keys[2].pubkey,lamports:e,toPubkey:t.keys[1].pubkey}}static checkProgramId(t){if(!t.equals(nc.programId))throw new Error("invalid instruction; programId is not VoteProgram")}static checkKeyLength(t,e){if(t.length<e)throw new Error(`invalid instruction; found ${t.length} keys, expected at least ${e}`)}},VoteProgram:nc,clusterApiUrl:function(t,e){const r=!1===e?"http":"https";if(!t)return dc[r].devnet;const n=dc[r][t];if(!n)throw new Error(`Unknown ${r} cluster: ${t}`);return n},sendAndConfirmRawTransaction:async function(t,e,r,n){let i,o;r&&Object.prototype.hasOwnProperty.call(r,"lastValidBlockHeight")||r&&Object.prototype.hasOwnProperty.call(r,"nonceValue")?(i=r,o=n):o=r;const s=o&&{skipPreflight:o.skipPreflight,preflightCommitment:o.preflightCommitment||o.commitment,minContextSlot:o.minContextSlot},a=await t.sendRawTransaction(e,s),u=o&&o.commitment,c=i?t.confirmTransaction(i,u):t.confirmTransaction(a,u),h=(await c).value;if(h.err)throw new Error(`Raw transaction ${a} failed (${JSON.stringify(h)})`);return a},sendAndConfirmTransaction:ks});const yc=new Wo("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");new Wo("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb");const gc=new Wo("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");new Wo("So11111111111111111111111111111111111111112"),new Wo("9pan9bMn5HatX4EJdBwg9VgCa7Uz5HL8N1m5D3NdXejP");const mc=t=>({decode:t.decode.bind(t),encode:t.encode.bind(t)}),wc=(t=>e=>{const r=Kr(t,e),{encode:n,decode:i}=mc(r),o=r;return o.decode=(t,e)=>{const r=i(t,e);return qr(Buffer.from(r))},o.encode=(e,r,i)=>{const o=Hr(e,t);return n(o,r,i)},o})(8),bc=t=>{const e=Ur(t),{encode:r,decode:n}=mc(e),i=e;return i.decode=(t,e)=>!!n(t,e),i.encode=(t,e,n)=>{const i=Number(t);return r(i,e,n)},i},vc=t=>{const e=Kr(32,t),{encode:r,decode:n}=mc(e),i=e;return i.decode=(t,e)=>{const r=n(t,e);return new Wo(r)},i.encode=(t,e,n)=>{const i=t.toBuffer();return r(i,e,n)},i};class _c extends Error{constructor(t){super(t)}}class kc extends _c{constructor(){super(...arguments),this.name="TokenAccountNotFoundError"}}class Ec extends _c{constructor(){super(...arguments),this.name="TokenInvalidAccountOwnerError"}}class xc extends _c{constructor(){super(...arguments),this.name="TokenInvalidAccountSizeError"}}class Sc extends _c{constructor(){super(...arguments),this.name="TokenInvalidMintError"}}class Ac extends _c{constructor(){super(...arguments),this.name="TokenOwnerOffCurveError"}}var Ic;!function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Mint=1]="Mint",t[t.Account=2]="Account"}(Ic||(Ic={}));const Bc=1,Mc=jr([Ur("m"),Ur("n"),bc("isInitialized"),vc("signer1"),vc("signer2"),vc("signer3"),vc("signer4"),vc("signer5"),vc("signer6"),vc("signer7"),vc("signer8"),vc("signer9"),vc("signer10"),vc("signer11")]).span;var Rc;!function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initialized=1]="Initialized",t[t.Frozen=2]="Frozen"}(Rc||(Rc={}));const Pc=jr([vc("mint"),vc("owner"),wc("amount"),Nr("delegateOption"),vc("delegate"),Ur("state"),Nr("isNativeOption"),wc("isNative"),wc("delegatedAmount"),Nr("closeAuthorityOption"),vc("closeAuthority")]),Tc=Pc.span,Oc=jr([Nr("mintAuthorityOption"),vc("mintAuthority"),wc("supply"),Ur("decimals"),bc("isInitialized"),Nr("freezeAuthorityOption"),vc("freezeAuthority")]),Lc=Oc.span;async function Uc(t,e,r,n=yc){return function(t,e,r=yc){if(!e)throw new kc;if(!e.owner.equals(r))throw new Ec;if(e.data.length<Lc)throw new xc;const n=Oc.decode(e.data.slice(0,Lc));let i=Buffer.alloc(0);if(e.data.length>Lc){if(e.data.length<=Tc)throw new xc;if(e.data.length===Mc)throw new xc;if(e.data[Tc]!=Ic.Mint)throw new Sc;i=e.data.slice(Tc+Bc)}return{address:t,mintAuthority:n.mintAuthorityOption?n.mintAuthority:null,supply:n.supply,decimals:n.decimals,isInitialized:n.isInitialized,freezeAuthority:n.freezeAuthorityOption?n.freezeAuthority:null,tlvData:i}}(e,await t.getAccountInfo(e,r),n)}function Cc(t,e,r=!1,n=yc,i=gc){if(!r&&!Wo.isOnCurve(e.toBuffer()))throw new Ac;const[o]=Wo.findProgramAddressSync([e.toBuffer(),n.toBuffer(),t.toBuffer()],i);return o}function Nc(t,e,r,n,i=yc,o=gc){return function(t,e,r,n,i,o=yc,s=gc){const a=[{pubkey:t,isSigner:!0,isWritable:!0},{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!1,isWritable:!1},{pubkey:Os.programId,isSigner:!1,isWritable:!1},{pubkey:o,isSigner:!1,isWritable:!1}];return new cs({keys:a,programId:s,data:i})}(t,e,r,n,Buffer.alloc(0),i,o)}var zc;exports.ErrorType=void 0,(zc=exports.ErrorType||(exports.ErrorType={})).SymbolNotFound="SymbolNotFound",zc.InvalidSubdomain="InvalidSubdomain",zc.FavouriteDomainNotFound="FavouriteDomainNotFound",zc.MissingParentOwner="MissingParentOwner",zc.U32Overflow="U32Overflow",zc.InvalidBufferLength="InvalidBufferLength",zc.U64Overflow="U64Overflow",zc.NoRecordData="NoRecordData",zc.InvalidRecordData="InvalidRecordData",zc.UnsupportedRecord="UnsupportedRecord",zc.InvalidEvmAddress="InvalidEvmAddress",zc.InvalidInjectiveAddress="InvalidInjectiveAddress",zc.InvalidARecord="InvalidARecord",zc.InvalidAAAARecord="InvalidAAAARecord",zc.InvalidRecordInput="InvalidRecordInput",zc.InvalidSignature="InvalidSignature",zc.AccountDoesNotExist="AccountDoesNotExist",zc.MultipleRegistries="MultipleRegistries",zc.InvalidReverseTwitter="InvalidReverseTwitter",zc.NoAccountData="NoAccountData",zc.InvalidInput="InvalidInput",zc.InvalidDomain="InvalidDomain",zc.InvalidCustomBg="InvalidCustomBackground",zc.UnsupportedSignature="UnsupportedSignature",zc.RecordDoestNotSupportGuardianSig="RecordDoestNotSupportGuardianSig",zc.RecordIsNotSigned="RecordIsNotSigned",zc.UnsupportedSignatureType="UnsupportedSignatureType",zc.InvalidSolRecordV2="InvalidSolRecordV2",zc.MissingVerifier="MissingVerifier";class Dc extends Error{constructor(t,e){super(e),this.name="SNSError",this.type=t,Error.captureStackTrace&&Error.captureStackTrace(this,Dc)}}class jc extends ne{toBuffer(){const t=super.toArray().reverse(),e=n.Buffer.from(t);if(4===e.length)return e;if(e.length>4)throw new Dc(exports.ErrorType.U32Overflow);const r=n.Buffer.alloc(4);return e.copy(r),r}static fromBuffer(t){if(4!==t.length)throw new Dc(exports.ErrorType.InvalidBufferLength,`Invalid buffer length: ${t.length}`);return new ne([...t].reverse().map((t=>`00${t.toString(16)}`.slice(-2))).join(""),16)}}class Wc extends ne{toBuffer(){const t=super.toArray().reverse(),e=n.Buffer.from(t);if(8===e.length)return e;if(e.length>8)throw new Dc(exports.ErrorType.U64Overflow);const r=n.Buffer.alloc(8);return e.copy(r),r}static fromBuffer(t){if(8!==t.length)throw new Dc(exports.ErrorType.U64Overflow,`Invalid buffer length: ${t.length}`);return new ne([...t].reverse().map((t=>`00${t.toString(16)}`.slice(-2))).join(""),16)}}function Kc(t,e,r,i,o,s,a,u,c,h,l){const f=[n.Buffer.from(Int8Array.from([0])),new jc(s.length).toBuffer(),s,a.toBuffer(),u.toBuffer()],d=n.Buffer.concat(f),p=[{pubkey:e,isSigner:!1,isWritable:!1},{pubkey:o,isSigner:!0,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!1}];return c?p.push({pubkey:c,isSigner:!0,isWritable:!1}):p.push({pubkey:new Wo(n.Buffer.alloc(32)),isSigner:!1,isWritable:!1}),h?p.push({pubkey:h,isSigner:!1,isWritable:!1}):p.push({pubkey:new Wo(n.Buffer.alloc(32)),isSigner:!1,isWritable:!1}),l&&p.push({pubkey:l,isSigner:!0,isWritable:!1}),new cs({keys:p,programId:t,data:d})}function Fc(t,e,r,i,o){const s=[n.Buffer.from(Int8Array.from([1])),r.toBuffer(),new jc(i.length).toBuffer(),i],a=n.Buffer.concat(s);return new cs({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:o,isSigner:!0,isWritable:!1}],programId:t,data:a})}function qc(t,e,r,i,o,s,a){const u=[n.Buffer.from(Int8Array.from([2])),r.toBuffer()],c=n.Buffer.concat(u),h=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:a||i,isSigner:!0,isWritable:!1}];return o&&h.push({pubkey:o,isSigner:!0,isWritable:!1}),a&&s&&(o||h.push({pubkey:Wo.default,isSigner:!1,isWritable:!1}),h.push({pubkey:s,isSigner:!1,isWritable:!1})),new cs({keys:h,programId:t,data:c})}function Vc(t,e,r,i){const o=[n.Buffer.from(Int8Array.from([3]))],s=n.Buffer.concat(o);return new cs({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!0,isWritable:!1},{pubkey:r,isSigner:!1,isWritable:!0}],programId:t,data:s})}class Hc{constructor(t){this.tag=9,this.name=t.name,this.space=t.space}serialize(){return He(Hc.schema,this)}getInstruction(t,e,r,i,o,s,a,u,c,h,l){const f=n.Buffer.from(this.serialize()),d=[{pubkey:e,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!1,isWritable:!1},{pubkey:i,isSigner:!1,isWritable:!1},{pubkey:o,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:Os.programId,isSigner:!1,isWritable:!1},{pubkey:a,isSigner:!1,isWritable:!1},{pubkey:u,isSigner:!0,isWritable:!0},{pubkey:c,isSigner:!1,isWritable:!0},{pubkey:h,isSigner:!1,isWritable:!0},{pubkey:yc,isSigner:!1,isWritable:!1},{pubkey:l,isSigner:!1,isWritable:!1}];return new cs({keys:d,programId:t,data:f})}}Hc.schema=new Map([[Hc,{kind:"struct",fields:[["tag","u8"],["name","string"],["space","u32"]]}]]);class $c{constructor(t){this.tag=12,this.name=t.name}serialize(){return He($c.schema,this)}getInstruction(t,e,r,i,o,s,a,u,c,h){const l=n.Buffer.from(this.serialize());let f=[];return f.push({pubkey:e,isSigner:!1,isWritable:!1}),f.push({pubkey:r,isSigner:!1,isWritable:!1}),f.push({pubkey:i,isSigner:!1,isWritable:!0}),f.push({pubkey:o,isSigner:!1,isWritable:!1}),f.push({pubkey:s,isSigner:!1,isWritable:!1}),f.push({pubkey:a,isSigner:!0,isWritable:!0}),f.push({pubkey:u,isSigner:!1,isWritable:!1}),c&&f.push({pubkey:c,isSigner:!1,isWritable:!0}),h&&f.push({pubkey:h,isSigner:!0,isWritable:!0}),new cs({keys:f,programId:t,data:l})}}$c.schema=new Map([[$c,{kind:"struct",fields:[["tag","u8"],["name","string"]]}]]);class Gc{constructor(t){this.tag=13,this.name=t.name,this.space=t.space,this.referrerIdxOpt=t.referrerIdxOpt}serialize(){return He(Gc.schema,this)}getInstruction(t,e,r,i,o,s,a,u,c,h,l,f,d,p,y,g,m){const w=n.Buffer.from(this.serialize());let b=[];return b.push({pubkey:e,isSigner:!1,isWritable:!1}),b.push({pubkey:r,isSigner:!1,isWritable:!1}),b.push({pubkey:i,isSigner:!1,isWritable:!0}),b.push({pubkey:o,isSigner:!1,isWritable:!0}),b.push({pubkey:s,isSigner:!1,isWritable:!1}),b.push({pubkey:a,isSigner:!1,isWritable:!1}),b.push({pubkey:u,isSigner:!0,isWritable:!0}),b.push({pubkey:c,isSigner:!1,isWritable:!0}),b.push({pubkey:h,isSigner:!1,isWritable:!1}),b.push({pubkey:l,isSigner:!1,isWritable:!1}),b.push({pubkey:f,isSigner:!1,isWritable:!1}),b.push({pubkey:d,isSigner:!1,isWritable:!0}),b.push({pubkey:p,isSigner:!1,isWritable:!1}),b.push({pubkey:y,isSigner:!1,isWritable:!1}),b.push({pubkey:g,isSigner:!1,isWritable:!1}),m&&b.push({pubkey:m,isSigner:!1,isWritable:!0}),new cs({keys:b,programId:t,data:w})}}Gc.schema=new Map([[Gc,{kind:"struct",fields:[["tag","u8"],["name","string"],["space","u32"],["referrerIdxOpt",{kind:"option",type:"u16"}]]}]]);class Zc{constructor(t){this.tag=17,this.name=t.name,this.space=t.space}serialize(){return He(Zc.schema,this)}getInstruction(t,e,r,i,o,s,a,u,c,h,l,f,d,p,y,g,m){const w=n.Buffer.from(this.serialize());let b=[];return b.push({pubkey:e,isSigner:!1,isWritable:!1}),b.push({pubkey:r,isSigner:!1,isWritable:!1}),b.push({pubkey:i,isSigner:!1,isWritable:!0}),b.push({pubkey:o,isSigner:!1,isWritable:!0}),b.push({pubkey:s,isSigner:!1,isWritable:!1}),b.push({pubkey:a,isSigner:!1,isWritable:!1}),b.push({pubkey:u,isSigner:!0,isWritable:!0}),b.push({pubkey:c,isSigner:!1,isWritable:!0}),b.push({pubkey:h,isSigner:!1,isWritable:!0}),b.push({pubkey:l,isSigner:!1,isWritable:!0}),b.push({pubkey:f,isSigner:!1,isWritable:!0}),b.push({pubkey:d,isSigner:!1,isWritable:!0}),b.push({pubkey:p,isSigner:!1,isWritable:!1}),b.push({pubkey:y,isSigner:!1,isWritable:!1}),b.push({pubkey:g,isSigner:!1,isWritable:!1}),b.push({pubkey:m,isSigner:!1,isWritable:!1}),new cs({keys:b,programId:t,data:w})}}Zc.schema=new Map([[Zc,{kind:"struct",fields:[["tag","u8"],["name","string"],["space","u32"]]}]]);class Yc{constructor(){this.tag=16}serialize(){return He(Yc.schema,this)}getInstruction(t,e,r,i,o,s,a,u,c,h){const l=n.Buffer.from(this.serialize());let f=[];return f.push({pubkey:e,isSigner:!1,isWritable:!1}),f.push({pubkey:r,isSigner:!1,isWritable:!1}),f.push({pubkey:i,isSigner:!1,isWritable:!0}),f.push({pubkey:o,isSigner:!1,isWritable:!0}),f.push({pubkey:s,isSigner:!1,isWritable:!0}),f.push({pubkey:a,isSigner:!1,isWritable:!0}),f.push({pubkey:u,isSigner:!1,isWritable:!1}),f.push({pubkey:c,isSigner:!0,isWritable:!1}),f.push({pubkey:h,isSigner:!1,isWritable:!0}),new cs({keys:f,programId:t,data:l})}}Yc.schema=new Map([[Yc,{kind:"struct",fields:[["tag","u8"]]}]]);const Jc=new Wo("nftD3vbNkNqfj2Sd3HZwbpw4BxxKWr4AjGb9X38JeZk"),Xc=n.Buffer.from("tokenized_name");var Qc;!function(t){t[t.Uninitialized=0]="Uninitialized",t[t.CentralState=1]="CentralState",t[t.ActiveRecord=2]="ActiveRecord",t[t.InactiveRecord=3]="InactiveRecord"}(Qc||(Qc={}));class th{constructor(t){this.tag=t.tag,this.nonce=t.nonce,this.nameAccount=new Wo(t.nameAccount),this.owner=new Wo(t.owner),this.nftMint=new Wo(t.nftMint)}static deserialize(t){return Ze(this.schema,th,t)}static async retrieve(t,e){const r=await t.getAccountInfo(e);if(!r||!r.data)throw new Error("NFT record not found");return this.deserialize(r.data)}static async findKey(t,e){return await Wo.findProgramAddress([n.Buffer.from("nft_record"),t.toBuffer()],e)}}th.schema=new Map([[th,{kind:"struct",fields:[["tag","u8"],["nonce","u8"],["nameAccount",[32]],["owner",[32]],["nftMint",[32]]]}]]);const eh=async(t,e)=>{try{const[r]=await Wo.findProgramAddress([Xc,e.toBuffer()],Jc);if("0"===(await Uc(t,r)).supply.toString())return;const n=[{memcmp:{offset:0,bytes:r.toBase58()}},{memcmp:{offset:64,bytes:"2"}},{dataSize:165}],i=await t.getProgramAccounts(yc,{filters:n});if(1!=i.length)return;return new Wo(i[0].account.data.slice(32,64))}catch{return}},rh=t=>[{memcmp:{offset:32,bytes:t}},{memcmp:{offset:64,bytes:"2"}}],nh=async(t,e)=>{const r=await(async(t,e)=>{const r=[{memcmp:{offset:0,bytes:"3"}},{memcmp:{offset:66,bytes:e.toBase58()}}];return await t.getProgramAccounts(Jc,{filters:r})})(t,e.mint);if(1===r.length)return th.deserialize(r[0].account.data)},ih=async(t,e)=>{const r=[...rh(e.toBase58()),{dataSize:165}],n=(await t.getProgramAccounts(yc,{filters:r})).map((t=>Pc.decode(t.account.data))),i=n.map((e=>nh(t,e)));return(await Promise.all(i)).filter((t=>void 0!==t))};class oh{constructor(t){this.parentName=new Wo(t.parentName),this.owner=new Wo(t.owner),this.class=new Wo(t.class)}static async retrieve(t,e){var r;const n=await t.getAccountInfo(e);if(!n)throw new Dc(exports.ErrorType.AccountDoesNotExist);let i=Oe(this.schema,oh,n.data);i.data=null===(r=n.data)||void 0===r?void 0:r.slice(this.HEADER_LEN);return{registry:i,nftOwner:await eh(t,e)}}static async _retrieveBatch(t,e){const r=await t.getMultipleAccountsInfo(e),n=t=>{if(!t)return;const e=Oe(this.schema,oh,t);return e.data=null==t?void 0:t.slice(this.HEADER_LEN),e};return r.map((t=>n(null==t?void 0:t.data)))}static async retrieveBatch(t,e){let r=[];const n=[...e];for(;n.length>0;)r.push(...await this._retrieveBatch(t,n.splice(0,100)));return r}}oh.HEADER_LEN=96,oh.schema=new Map([[oh,{kind:"struct",fields:[["parentName",[32]],["owner",[32]],["class",[32]]]}]]);var sh={},ah={},uh=ch;function ch(t,e){if(!t)throw new Error(e||"Assertion failed")}ch.equal=function(t,e,r){if(t!=e)throw new Error(r||"Assertion failed: "+t+" != "+e)};var hh={exports:{}};"function"==typeof Object.create?hh.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:hh.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}};var lh=hh.exports,fh=uh,dh=lh;function ph(t,e){return 55296==(64512&t.charCodeAt(e))&&(!(e<0||e+1>=t.length)&&56320==(64512&t.charCodeAt(e+1)))}function yh(t){return(t>>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24)>>>0}function gh(t){return 1===t.length?"0"+t:t}function mh(t){return 7===t.length?"0"+t:6===t.length?"00"+t:5===t.length?"000"+t:4===t.length?"0000"+t:3===t.length?"00000"+t:2===t.length?"000000"+t:1===t.length?"0000000"+t:t}ah.inherits=dh,ah.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"==typeof t)if(e){if("hex"===e)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),i=0;i<t.length;i+=2)r.push(parseInt(t[i]+t[i+1],16))}else for(var n=0,i=0;i<t.length;i++){var o=t.charCodeAt(i);o<128?r[n++]=o:o<2048?(r[n++]=o>>6|192,r[n++]=63&o|128):ph(t,i)?(o=65536+((1023&o)<<10)+(1023&t.charCodeAt(++i)),r[n++]=o>>18|240,r[n++]=o>>12&63|128,r[n++]=o>>6&63|128,r[n++]=63&o|128):(r[n++]=o>>12|224,r[n++]=o>>6&63|128,r[n++]=63&o|128)}else for(i=0;i<t.length;i++)r[i]=0|t[i];return r},ah.toHex=function(t){for(var e="",r=0;r<t.length;r++)e+=gh(t[r].toString(16));return e},ah.htonl=yh,ah.toHex32=function(t,e){for(var r="",n=0;n<t.length;n++){var i=t[n];"little"===e&&(i=yh(i)),r+=mh(i.toString(16))}return r},ah.zero2=gh,ah.zero8=mh,ah.join32=function(t,e,r,n){var i=r-e;fh(i%4==0);for(var o=new Array(i/4),s=0,a=e;s<o.length;s++,a+=4){var u;u="big"===n?t[a]<<24|t[a+1]<<16|t[a+2]<<8|t[a+3]:t[a+3]<<24|t[a+2]<<16|t[a+1]<<8|t[a],o[s]=u>>>0}return o},ah.split32=function(t,e){for(var r=new Array(4*t.length),n=0,i=0;n<t.length;n++,i+=4){var o=t[n];"big"===e?(r[i]=o>>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},ah.rotr32=function(t,e){return t>>>e|t<<32-e},ah.rotl32=function(t,e){return t<<e|t>>>32-e},ah.sum32=function(t,e){return t+e>>>0},ah.sum32_3=function(t,e,r){return t+e+r>>>0},ah.sum32_4=function(t,e,r,n){return t+e+r+n>>>0},ah.sum32_5=function(t,e,r,n,i){return t+e+r+n+i>>>0},ah.sum64=function(t,e,r,n){var i=t[e],o=n+t[e+1]>>>0,s=(o<n?1:0)+r+i;t[e]=s>>>0,t[e+1]=o},ah.sum64_hi=function(t,e,r,n){return(e+n>>>0<e?1:0)+t+r>>>0},ah.sum64_lo=function(t,e,r,n){return e+n>>>0},ah.sum64_4_hi=function(t,e,r,n,i,o,s,a){var u=0,c=e;return u+=(c=c+n>>>0)<e?1:0,u+=(c=c+o>>>0)<o?1:0,t+r+i+s+(u+=(c=c+a>>>0)<a?1:0)>>>0},ah.sum64_4_lo=function(t,e,r,n,i,o,s,a){return e+n+o+a>>>0},ah.sum64_5_hi=function(t,e,r,n,i,o,s,a,u,c){var h=0,l=e;return h+=(l=l+n>>>0)<e?1:0,h+=(l=l+o>>>0)<o?1:0,h+=(l=l+a>>>0)<a?1:0,t+r+i+s+u+(h+=(l=l+c>>>0)<c?1:0)>>>0},ah.sum64_5_lo=function(t,e,r,n,i,o,s,a,u,c){return e+n+o+a+c>>>0},ah.rotr64_hi=function(t,e,r){return(e<<32-r|t>>>r)>>>0},ah.rotr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0},ah.shr64_hi=function(t,e,r){return t>>>r},ah.shr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0};var wh={},bh=ah,vh=uh;function _h(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}wh.BlockHash=_h,_h.prototype.update=function(t,e){if(t=bh.toArray(t,e),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var r=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-r,t.length),0===this.pending.length&&(this.pending=null),t=bh.join32(t,0,t.length-r,this.endian);for(var n=0;n<t.length;n+=this._delta32)this._update(t,n,n+this._delta32)}return this},_h.prototype.digest=function(t){return this.update(this._pad()),vh(null===this.pending),this._digest(t)},_h.prototype._pad=function(){var t=this.pendingTotal,e=this._delta8,r=e-(t+this.padLength)%e,n=new Array(r+this.padLength);n[0]=128;for(var i=1;i<r;i++)n[i]=0;if(t<<=3,"big"===this.endian){for(var o=8;o<this.padLength;o++)n[i++]=0;n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=t>>>24&255,n[i++]=t>>>16&255,n[i++]=t>>>8&255,n[i++]=255&t}else for(n[i++]=255&t,n[i++]=t>>>8&255,n[i++]=t>>>16&255,n[i++]=t>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;o<this.padLength;o++)n[i++]=0;return n};var kh={},Eh={},xh=ah.rotr32;function Sh(t,e,r){return t&e^~t&r}function Ah(t,e,r){return t&e^t&r^e&r}function Ih(t,e,r){return t^e^r}Eh.ft_1=function(t,e,r,n){return 0===t?Sh(e,r,n):1===t||3===t?Ih(e,r,n):2===t?Ah(e,r,n):void 0},Eh.ch32=Sh,Eh.maj32=Ah,Eh.p32=Ih,Eh.s0_256=function(t){return xh(t,2)^xh(t,13)^xh(t,22)},Eh.s1_256=function(t){return xh(t,6)^xh(t,11)^xh(t,25)},Eh.g0_256=function(t){return xh(t,7)^xh(t,18)^t>>>3},Eh.g1_256=function(t){return xh(t,17)^xh(t,19)^t>>>10};var Bh=ah,Mh=wh,Rh=Eh,Ph=Bh.rotl32,Th=Bh.sum32,Oh=Bh.sum32_5,Lh=Rh.ft_1,Uh=Mh.BlockHash,Ch=[1518500249,1859775393,2400959708,3395469782];function Nh(){if(!(this instanceof Nh))return new Nh;Uh.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}Bh.inherits(Nh,Uh);var zh=Nh;Nh.blockSize=512,Nh.outSize=160,Nh.hmacStrength=80,Nh.padLength=64,Nh.prototype._update=function(t,e){for(var r=this.W,n=0;n<16;n++)r[n]=t[e+n];for(;n<r.length;n++)r[n]=Ph(r[n-3]^r[n-8]^r[n-14]^r[n-16],1);var i=this.h[0],o=this.h[1],s=this.h[2],a=this.h[3],u=this.h[4];for(n=0;n<r.length;n++){var c=~~(n/20),h=Oh(Ph(i,5),Lh(c,o,s,a),u,r[n],Ch[c]);u=a,a=s,s=Ph(o,30),o=i,i=h}this.h[0]=Th(this.h[0],i),this.h[1]=Th(this.h[1],o),this.h[2]=Th(this.h[2],s),this.h[3]=Th(this.h[3],a),this.h[4]=Th(this.h[4],u)},Nh.prototype._digest=function(t){return"hex"===t?Bh.toHex32(this.h,"big"):Bh.split32(this.h,"big")};var Dh=ah,jh=wh,Wh=Eh,Kh=uh,Fh=Dh.sum32,qh=Dh.sum32_4,Vh=Dh.sum32_5,Hh=Wh.ch32,$h=Wh.maj32,Gh=Wh.s0_256,Zh=Wh.s1_256,Yh=Wh.g0_256,Jh=Wh.g1_256,Xh=jh.BlockHash,Qh=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function tl(){if(!(this instanceof tl))return new tl;Xh.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=Qh,this.W=new Array(64)}Dh.inherits(tl,Xh);var el=tl;tl.blockSize=512,tl.outSize=256,tl.hmacStrength=192,tl.padLength=64,tl.prototype._update=function(t,e){for(var r=this.W,n=0;n<16;n++)r[n]=t[e+n];for(;n<r.length;n++)r[n]=qh(Jh(r[n-2]),r[n-7],Yh(r[n-15]),r[n-16]);var i=this.h[0],o=this.h[1],s=this.h[2],a=this.h[3],u=this.h[4],c=this.h[5],h=this.h[6],l=this.h[7];for(Kh(this.k.length===r.length),n=0;n<r.length;n++){var f=Vh(l,Zh(u),Hh(u,c,h),this.k[n],r[n]),d=Fh(Gh(i),$h(i,o,s));l=h,h=c,c=u,u=Fh(a,f),a=s,s=o,o=i,i=Fh(f,d)}this.h[0]=Fh(this.h[0],i),this.h[1]=Fh(this.h[1],o),this.h[2]=Fh(this.h[2],s),this.h[3]=Fh(this.h[3],a),this.h[4]=Fh(this.h[4],u),this.h[5]=Fh(this.h[5],c),this.h[6]=Fh(this.h[6],h),this.h[7]=Fh(this.h[7],l)},tl.prototype._digest=function(t){return"hex"===t?Dh.toHex32(this.h,"big"):Dh.split32(this.h,"big")};var rl=ah,nl=el;function il(){if(!(this instanceof il))return new il;nl.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}rl.inherits(il,nl);var ol=il;il.blockSize=512,il.outSize=224,il.hmacStrength=192,il.padLength=64,il.prototype._digest=function(t){return"hex"===t?rl.toHex32(this.h.slice(0,7),"big"):rl.split32(this.h.slice(0,7),"big")};var sl=ah,al=wh,ul=uh,cl=sl.rotr64_hi,hl=sl.rotr64_lo,ll=sl.shr64_hi,fl=sl.shr64_lo,dl=sl.sum64,pl=sl.sum64_hi,yl=sl.sum64_lo,gl=sl.sum64_4_hi,ml=sl.sum64_4_lo,wl=sl.sum64_5_hi,bl=sl.sum64_5_lo,vl=al.BlockHash,_l=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function kl(){if(!(this instanceof kl))return new kl;vl.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=_l,this.W=new Array(160)}sl.inherits(kl,vl);var El=kl;function xl(t,e,r,n,i){var o=t&r^~t&i;return o<0&&(o+=4294967296),o}function Sl(t,e,r,n,i,o){var s=e&n^~e&o;return s<0&&(s+=4294967296),s}function Al(t,e,r,n,i){var o=t&r^t&i^r&i;return o<0&&(o+=4294967296),o}function Il(t,e,r,n,i,o){var s=e&n^e&o^n&o;return s<0&&(s+=4294967296),s}function Bl(t,e){var r=cl(t,e,28)^cl(e,t,2)^cl(e,t,7);return r<0&&(r+=4294967296),r}function Ml(t,e){var r=hl(t,e,28)^hl(e,t,2)^hl(e,t,7);return r<0&&(r+=4294967296),r}function Rl(t,e){var r=cl(t,e,14)^cl(t,e,18)^cl(e,t,9);return r<0&&(r+=4294967296),r}function Pl(t,e){var r=hl(t,e,14)^hl(t,e,18)^hl(e,t,9);return r<0&&(r+=4294967296),r}function Tl(t,e){var r=cl(t,e,1)^cl(t,e,8)^ll(t,e,7);return r<0&&(r+=4294967296),r}function Ol(t,e){var r=hl(t,e,1)^hl(t,e,8)^fl(t,e,7);return r<0&&(r+=4294967296),r}function Ll(t,e){var r=cl(t,e,19)^cl(e,t,29)^ll(t,e,6);return r<0&&(r+=4294967296),r}function Ul(t,e){var r=hl(t,e,19)^hl(e,t,29)^fl(t,e,6);return r<0&&(r+=4294967296),r}kl.blockSize=1024,kl.outSize=512,kl.hmacStrength=192,kl.padLength=128,kl.prototype._prepareBlock=function(t,e){for(var r=this.W,n=0;n<32;n++)r[n]=t[e+n];for(;n<r.length;n+=2){var i=Ll(r[n-4],r[n-3]),o=Ul(r[n-4],r[n-3]),s=r[n-14],a=r[n-13],u=Tl(r[n-30],r[n-29]),c=Ol(r[n-30],r[n-29]),h=r[n-32],l=r[n-31];r[n]=gl(i,o,s,a,u,c,h,l),r[n+1]=ml(i,o,s,a,u,c,h,l)}},kl.prototype._update=function(t,e){this._prepareBlock(t,e);var r=this.W,n=this.h[0],i=this.h[1],o=this.h[2],s=this.h[3],a=this.h[4],u=this.h[5],c=this.h[6],h=this.h[7],l=this.h[8],f=this.h[9],d=this.h[10],p=this.h[11],y=this.h[12],g=this.h[13],m=this.h[14],w=this.h[15];ul(this.k.length===r.length);for(var b=0;b<r.length;b+=2){var v=m,_=w,k=Rl(l,f),E=Pl(l,f),x=xl(l,f,d,p,y),S=Sl(l,f,d,p,y,g),A=this.k[b],I=this.k[b+1],B=r[b],M=r[b+1],R=wl(v,_,k,E,x,S,A,I,B,M),P=bl(v,_,k,E,x,S,A,I,B,M);v=Bl(n,i),_=Ml(n,i),k=Al(n,i,o,s,a),E=Il(n,i,o,s,a,u);var T=pl(v,_,k,E),O=yl(v,_,k,E);m=y,w=g,y=d,g=p,d=l,p=f,l=pl(c,h,R,P),f=yl(h,h,R,P),c=a,h=u,a=o,u=s,o=n,s=i,n=pl(R,P,T,O),i=yl(R,P,T,O)}dl(this.h,0,n,i),dl(this.h,2,o,s),dl(this.h,4,a,u),dl(this.h,6,c,h),dl(this.h,8,l,f),dl(this.h,10,d,p),dl(this.h,12,y,g),dl(this.h,14,m,w)},kl.prototype._digest=function(t){return"hex"===t?sl.toHex32(this.h,"big"):sl.split32(this.h,"big")};var Cl=ah,Nl=El;function zl(){if(!(this instanceof zl))return new zl;Nl.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}Cl.inherits(zl,Nl);var Dl=zl;zl.blockSize=1024,zl.outSize=384,zl.hmacStrength=192,zl.padLength=128,zl.prototype._digest=function(t){return"hex"===t?Cl.toHex32(this.h.slice(0,12),"big"):Cl.split32(this.h.slice(0,12),"big")},kh.sha1=zh,kh.sha224=ol,kh.sha256=el,kh.sha384=Dl,kh.sha512=El;var jl={},Wl=ah,Kl=wh,Fl=Wl.rotl32,ql=Wl.sum32,Vl=Wl.sum32_3,Hl=Wl.sum32_4,$l=Kl.BlockHash;function Gl(){if(!(this instanceof Gl))return new Gl;$l.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}function Zl(t,e,r,n){return t<=15?e^r^n:t<=31?e&r|~e&n:t<=47?(e|~r)^n:t<=63?e&n|r&~n:e^(r|~n)}function Yl(t){return t<=15?0:t<=31?1518500249:t<=47?1859775393:t<=63?2400959708:2840853838}function Jl(t){return t<=15?1352829926:t<=31?1548603684:t<=47?1836072691:t<=63?2053994217:0}Wl.inherits(Gl,$l),jl.ripemd160=Gl,Gl.blockSize=512,Gl.outSize=160,Gl.hmacStrength=192,Gl.padLength=64,Gl.prototype._update=function(t,e){for(var r=this.h[0],n=this.h[1],i=this.h[2],o=this.h[3],s=this.h[4],a=r,u=n,c=i,h=o,l=s,f=0;f<80;f++){var d=ql(Fl(Hl(r,Zl(f,n,i,o),t[Xl[f]+e],Yl(f)),tf[f]),s);r=s,s=o,o=Fl(i,10),i=n,n=d,d=ql(Fl(Hl(a,Zl(79-f,u,c,h),t[Ql[f]+e],Jl(f)),ef[f]),l),a=l,l=h,h=Fl(c,10),c=u,u=d}d=Vl(this.h[1],i,h),this.h[1]=Vl(this.h[2],o,l),this.h[2]=Vl(this.h[3],s,a),this.h[3]=Vl(this.h[4],r,u),this.h[4]=Vl(this.h[0],n,c),this.h[0]=d},Gl.prototype._digest=function(t){return"hex"===t?Wl.toHex32(this.h,"little"):Wl.split32(this.h,"little")};var Xl=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],Ql=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],tf=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],ef=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],rf=ah,nf=uh;function of(t,e,r){if(!(this instanceof of))return new of(t,e,r);this.Hash=t,this.blockSize=t.blockSize/8,this.outSize=t.outSize/8,this.inner=null,this.outer=null,this._init(rf.toArray(e,r))}var sf=of;of.prototype._init=function(t){t.length>this.blockSize&&(t=(new this.Hash).update(t).digest()),nf(t.length<=this.blockSize);for(var e=t.length;e<this.blockSize;e++)t.push(0);for(e=0;e<t.length;e++)t[e]^=54;for(this.inner=(new this.Hash).update(t),e=0;e<t.length;e++)t[e]^=106;this.outer=(new this.Hash).update(t)},of.prototype.update=function(t,e){return this.inner.update(t,e),this},of.prototype.digest=function(t){return this.outer.update(this.inner.digest()),this.outer.digest(t)},function(t){var e=sh;e.utils=ah,e.common=wh,e.sha=kh,e.ripemd=jl,e.hmac=sf,e.sha1=e.sha.sha1,e.sha256=e.sha.sha256,e.sha224=e.sha.sha224,e.sha384=e.sha.sha384,e.sha512=e.sha.sha512,e.ripemd160=e.ripemd.ripemd160}();var af=e(sh);let uf=!1,cf=!1;const hf={debug:1,default:2,info:2,warning:3,error:4,off:5};let lf=hf.default,ff=null;const df=function(){try{const t=[];if(["NFD","NFC","NFKD","NFKC"].forEach((e=>{try{if("test"!=="test".normalize(e))throw new Error("bad normalize")}catch(r){t.push(e)}})),t.length)throw new Error("missing "+t.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(t){return t.message}return null}();var pf,yf;!function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"}(pf||(pf={})),function(t){t.UNKNOWN_ERROR="UNKNOWN_ERROR",t.NOT_IMPLEMENTED="NOT_IMPLEMENTED",t.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",t.NETWORK_ERROR="NETWORK_ERROR",t.SERVER_ERROR="SERVER_ERROR",t.TIMEOUT="TIMEOUT",t.BUFFER_OVERRUN="BUFFER_OVERRUN",t.NUMERIC_FAULT="NUMERIC_FAULT",t.MISSING_NEW="MISSING_NEW",t.INVALID_ARGUMENT="INVALID_ARGUMENT",t.MISSING_ARGUMENT="MISSING_ARGUMENT",t.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",t.CALL_EXCEPTION="CALL_EXCEPTION",t.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",t.NONCE_EXPIRED="NONCE_EXPIRED",t.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",t.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",t.TRANSACTION_REPLACED="TRANSACTION_REPLACED",t.ACTION_REJECTED="ACTION_REJECTED"}(yf||(yf={}));const gf="0123456789abcdef";class mf{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,e){const r=t.toLowerCase();null==hf[r]&&this.throwArgumentError("invalid log level name","logLevel",t),lf>hf[r]||console.log.apply(console,e)}debug(...t){this._log(mf.levels.DEBUG,t)}info(...t){this._log(mf.levels.INFO,t)}warn(...t){this._log(mf.levels.WARNING,t)}makeError(t,e,r){if(cf)return this.makeError("censored error",e,{});e||(e=mf.errors.UNKNOWN_ERROR),r||(r={});const n=[];Object.keys(r).forEach((t=>{const e=r[t];try{if(e instanceof Uint8Array){let r="";for(let t=0;t<e.length;t++)r+=gf[e[t]>>4],r+=gf[15&e[t]];n.push(t+"=Uint8Array(0x"+r+")")}else n.push(t+"="+JSON.stringify(e))}catch(e){n.push(t+"="+JSON.stringify(r[t].toString()))}})),n.push(`code=${e}`),n.push(`version=${this.version}`);const i=t;let o="";switch(e){case yf.NUMERIC_FAULT:{o="NUMERIC_FAULT";const e=t;switch(e){case"overflow":case"underflow":case"division-by-zero":o+="-"+e;break;case"negative-power":case"negative-width":o+="-unsupported";break;case"unbound-bitwise-result":o+="-unbound-result"}break}case yf.CALL_EXCEPTION:case yf.INSUFFICIENT_FUNDS:case yf.MISSING_NEW:case yf.NONCE_EXPIRED:case yf.REPLACEMENT_UNDERPRICED:case yf.TRANSACTION_REPLACED:case yf.UNPREDICTABLE_GAS_LIMIT:o=e}o&&(t+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),n.length&&(t+=" ("+n.join(", ")+")");const s=new Error(t);return s.reason=i,s.code=e,Object.keys(r).forEach((function(t){s[t]=r[t]})),s}throwError(t,e,r){throw this.makeError(t,e,r)}throwArgumentError(t,e,r){return this.throwError(t,mf.errors.INVALID_ARGUMENT,{argument:e,value:r})}assert(t,e,r,n){t||this.throwError(e,r,n)}assertArgument(t,e,r,n){t||this.throwArgumentError(e,r,n)}checkNormalize(t){df&&this.throwError("platform missing String.prototype.normalize",mf.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:df})}checkSafeUint53(t,e){"number"==typeof t&&(null==e&&(e="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(e,mf.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,mf.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,e,r){r=r?": "+r:"",t<e&&this.throwError("missing argument"+r,mf.errors.MISSING_ARGUMENT,{count:t,expectedCount:e}),t>e&&this.throwError("too many arguments"+r,mf.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:e})}checkNew(t,e){t!==Object&&null!=t||this.throwError("missing new",mf.errors.MISSING_NEW,{name:e.name})}checkAbstract(t,e){t===e?this.throwError("cannot instantiate abstract class "+JSON.stringify(e.name)+" directly; use a sub-class",mf.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",mf.errors.MISSING_NEW,{name:e.name})}static globalLogger(){return ff||(ff=new mf("logger/5.7.0")),ff}static setCensorship(t,e){if(!t&&e&&this.globalLogger().throwError("cannot permanently disable censorship",mf.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),uf){if(!t)return;this.globalLogger().throwError("error censorship permanent",mf.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}cf=!!t,uf=!!e}static setLogLevel(t){const e=hf[t.toLowerCase()];null!=e?lf=e:mf.globalLogger().warn("invalid log level - "+t)}static from(t){return new mf(t)}}mf.errors=yf,mf.levels=pf;const wf=new mf("bytes/5.7.0");function bf(t){return t.slice||(t.slice=function(){const e=Array.prototype.slice.call(arguments);return bf(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function vf(t){return"number"==typeof t&&t==t&&t%1==0}function _f(t,e){if(e||(e={}),"number"==typeof t){wf.checkSafeUint53(t,"invalid arrayify value");const e=[];for(;t;)e.unshift(255&t),t=parseInt(String(t/256));return 0===e.length&&e.push(0),bf(new Uint8Array(e))}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),function(t){return!!t.toHexString}(t)&&(t=t.toHexString()),function(t,e){if("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))return!1;if(e&&t.length!==2+2*e)return!1;return!0}(t)){let r=t.substring(2);r.length%2&&("left"===e.hexPad?r="0"+r:"right"===e.hexPad?r+="0":wf.throwArgumentError("hex data is odd-length","value",t));const n=[];for(let t=0;t<r.length;t+=2)n.push(parseInt(r.substring(t,t+2),16));return bf(new Uint8Array(n))}return function(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t)return!1;if(!vf(t.length)||t.length<0)return!1;for(let e=0;e<t.length;e++){const r=t[e];if(!vf(r)||r<0||r>=256)return!1}return!0}(t)?bf(new Uint8Array(t)):wf.throwArgumentError("invalid arrayify value","value",t)}function kf(t){return"0x"+af.sha256().update(_f(t)).digest("hex")}new mf("sha2/5.7.0");const Ef=new Wo("namesLPneVptA9Z5rqUDD9tMTWEJwofgaYwp8cawRkX"),xf="SPL Name Service",Sf=new Wo("58PwtjSDuFHuUkYjH9BYnnQKHfwo9reZhC2zMJv9JPkx"),Af=new Wo("jCebN34bUfdeUYJT13J1yG16XWQpt5PDx6Mse9GUqhR"),If=new Wo("ETp9eKXVv1dWwHSpsXRUuXHmw24PwRkttCGVgpZEY9zF"),Bf=new Wo("AUoZ3YAhV3b2rZeEH93UMZHXUZcTramBvb4d9YEVySkc"),Mf=new Wo("33m47vH6Eav6jr5Ry86XjhRft2jRBLDnDgPSHoquXi2Z"),Rf=new Wo("FvPH7PrVrLGKPfqaf3xJodFTjZriqrAXXLTVWEorTFBi"),Pf=new Wo("4YcexoW3r78zz16J2aqmukBLRwGq6rAvWzJpkYAXqebv"),Tf=new Wo("DmSyHDSM9eSLyvoLsPvDr5fRRFZ7Bfr3h3ULvWpgQaq7"),Of=new Wo("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),Lf=[new Wo("3ogYncmMM5CmytsGCqKHydmXmKUZ6sGWvizkzqwT7zb1"),new Wo("DM1jJCkZZEwY5tmWbgvKRxsDFzXCdbfrYCCH1CtwguEs"),new Wo("ADCp4QXFajHrhy4f43pD6GJFtQLkdBY2mjS9DfCk7tNW"),new Wo("2XTgjw8yi1E3Etgj4CUyRD7Zk49gynH2U9gA5N2MY4NP"),new Wo("5oDWj8vr3vbcq9JZTtwXqrkCMZggMsDzNietvbr1BNfe"),new Wo("8kJqxAbqbPLGLMgB6FhLcnw2SiUEavx2aEGM3WQGhtJF"),new Wo("HemvJzwxvVpWBjPETpaseAH395WAxb2G73MeUfjVkK1u")],Uf=new Map([["EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v","USDC"],["Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB","USDT"],["So11111111111111111111111111111111111111112","SOL"],["EchesyfXePKdLtoiZSL8pBe8Myagyy8ZRqsACNCFGnvp","FIDA"],["FeGn77dhg1KXRRFeSwwMiykZnZPw5JXW6naf2aQgZDQf","ETH"],["7i5KKsX2weiTkry7jA4ZwSuXGhs5eJBEjY8vVxR4pfRx","GMT"],["AFbX8oGjGpmVFywbVouvhQSRmiW2aR1mohfahi4Y2AdB","GST"],["mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So","MSOL"],["DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263","BONK"],["EPeUFDgHRxs9xxEPVaL6kfGQvCon7jmAWKVUHuux1Tpz","BAT"],["HZ1JovNiVvGrGNiiYvEozEVgZ58xaU3RKwX8eACQBCt3","PYTH"]]),Cf=new Wo("AHtgzX45WTKfkPG53L6WYhGEXwQkN1BVknET3sVsLL8J"),Nf=new Wo("GcWEQ9K78FV7LEHteFVciYApERk5YvQuFDQPk1yYJVXi"),zf=new Wo("BPeXUQDqGbzxeK1LJby6ugvCBuo7kRSEUkjD726mUVsz"),Df=new Wo("72aLKvXeV4aansAQtxKymeXDevT5ed6sCuz9iN62ugPT"),jf=new Wo("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s");async function Wf(t,e){if(!await t.getAccountInfo(e))throw new Dc(exports.ErrorType.AccountDoesNotExist);return oh.retrieve(t,e)}async function Kf(t){const e=xf+t,r=kf(n.Buffer.from(e,"utf8")).slice(2);return n.Buffer.from(r,"hex")}async function Ff(t,e,r){const i=[t];e?i.push(e.toBuffer()):i.push(n.Buffer.alloc(32)),r?i.push(r.toBuffer()):i.push(n.Buffer.alloc(32));const[o]=await Wo.findProgramAddress(i,Ef);return o}const qf=async(t,e=Sf)=>{let r=await Kf(t);return{pubkey:await Ff(r,void 0,e),hashed:r}},Vf=async(t,e=!1)=>{t.endsWith(".sol")&&(t=t.slice(0,-4));const r=t.split(".");if(2===r.length){const t=n.Buffer.from([e?1:0]).toString().concat(r[0]),{pubkey:i}=await qf(r[1]);return{...await qf(t,i),isSub:!0,parent:i}}if(3===r.length&&e){const{pubkey:t}=await qf(r[2]),{pubkey:e}=await qf("\0".concat(r[1]),t),i=n.Buffer.from([1]).toString();return{...await qf(i.concat(r[0]),e),isSub:!0,parent:t,isSubRecord:!0}}if(r.length>=3)throw new Dc(exports.ErrorType.InvalidInput);return{...await qf(t,Sf),isSub:!1,parent:void 0}};var Hf={},$f=r(pc),Gf={};Object.defineProperty(Gf,"__esModule",{value:!0}),Gf.readBigUInt64LE=Gf.readBigInt64LE=void 0;var Zf=function(){return new Error("Attempt to access memory outside buffer bounds")},Yf=function(t,e,r){return new Error('The "'+t+'" argument must be of type '+e+". Received "+r)},Jf=function(t,e,r){return new Error('The value of "'+t+" is out of range. It must be "+e+". Received "+r)};function Xf(t,e){if("number"!=typeof t)throw Yf(e,"number",t)}function Qf(t,e){if(Math.floor(t)!==t)throw Xf(t,"offset"),Jf("offset","an integer",t);if(e<0)throw Zf();throw Jf("offset",">= 0 and <= "+e,t)}Gf.readBigInt64LE=function(t,e){void 0===e&&(e=0),Xf(e,"offset");var r=t[e],n=t[e+7];void 0!==r&&void 0!==n||Qf(e,t.length-8);var i=t[e+4]+t[e+5]*Math.pow(2,8)+t[e+6]*Math.pow(2,16)+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(r+t[++e]*Math.pow(2,8)+t[++e]*Math.pow(2,16)+t[++e]*Math.pow(2,24))},Gf.readBigUInt64LE=function(t,e){void 0===e&&(e=0),Xf(e,"offset");var r=t[e],n=t[e+7];void 0!==r&&void 0!==n||Qf(e,t.length-8);var i=r+t[++e]*Math.pow(2,8)+t[++e]*Math.pow(2,16)+t[++e]*Math.pow(2,24),o=t[++e]+t[++e]*Math.pow(2,8)+t[++e]*Math.pow(2,16)+n*Math.pow(2,24);return BigInt(i)+(BigInt(o)<<BigInt(32))};var td,ed={};function rd(){if(td)return ed;td=1;var e=t&&t.__assign||function(){return e=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},e.apply(this,arguments)},r=t&&t.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},n=t&&t.__generator||function(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}};Object.defineProperty(ed,"__esModule",{value:!0}),ed.PythConnection=void 0;var i=Zv(),o=function(){function t(t,e,r,n){void 0===r&&(r="finalized"),this.productAccountKeyToProduct={},this.priceAccountKeyToProductAccountKey={},this.callbacks=[],this.connection=t,this.pythProgramKey=e,this.commitment=r,this.feedIds=n}return t.prototype.handleProductAccount=function(t,r,n){var o=i.parseProductData(r.data);this.productAccountKeyToProduct[t.toString()]={key:t,slot:n,accountInfo:e(e({},r),{data:o})},o.priceAccountKey&&(this.priceAccountKeyToProductAccountKey[o.priceAccountKey.toString()]=t.toString())},t.prototype.handlePriceAccount=function(t,r,n){var o=this.productAccountKeyToProduct[this.priceAccountKeyToProductAccountKey[t.toString()]];if(void 0===o)throw new Error("Got a price update for an unknown product. This is a bug in the library, please report it to the developers.");for(var s=i.parsePriceData(r.data,n),a={key:t,slot:n,accountInfo:e(e({},r),{data:s})},u=0,c=this.callbacks;u<c.length;u++){(0,c[u])(o,a)}},t.prototype.handleAccount=function(t,e,r,n){var o=i.parseBaseData(e.data);if(o)switch(o.type){case i.AccountType.Mapping:break;case i.AccountType.Product:this.handleProductAccount(t,e,n);break;case i.AccountType.Price:r||this.handlePriceAccount(t,e,n);break;case i.AccountType.Test:case i.AccountType.Permission:break;default:throw new Error("Unknown account type: "+o.type+". Try upgrading pyth-client.")}},t.prototype.start=function(){return r(this,void 0,void 0,(function(){var t,e,r,i,o,s,a,u,c,h,l,f=this;return n(this,(function(n){switch(n.label){case 0:return[4,Promise.all([this.connection.getProgramAccounts(this.pythProgramKey,this.commitment),this.connection.getSlot(this.commitment)])];case 1:for(t=n.sent(),e=t[0],r=t[1],i=0,o=e;i<o.length;i++)l=o[i],this.handleAccount(l.pubkey,l.account,!0,r);if(this.feedIds)for(s=this.feedIds.map((function(t){return t.toString()})),e=e.filter((function(t){return s.includes(t.pubkey.toString())})),a=function(t){u.connection.onAccountChange(t.pubkey,(function(e,r){f.handleAccount(t.pubkey,e,!1,r.slot)}),u.commitment)},u=this,c=0,h=e;c<h.length;c++)l=h[c],a(l);else this.connection.onProgramAccountChange(this.pythProgramKey,(function(t,e){f.handleAccount(t.accountId,t.accountInfo,!1,e.slot)}),this.commitment);return[2]}}))}))},t.prototype.onPriceChange=function(t){this.callbacks.push((function(e,r){return t(e.accountInfo.data.product,r.accountInfo.data)}))},t.prototype.onPriceChangeVerbose=function(t){this.callbacks.push(t)},t.prototype.stop=function(){return r(this,void 0,void 0,(function(){return n(this,(function(t){return this.callbacks=[],[2]}))}))},t}();return ed.PythConnection=o,ed}var nd,id={};function od(){if(nd)return id;nd=1;var e=t&&t.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},r=t&&t.__generator||function(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}};Object.defineProperty(id,"__esModule",{value:!0}),id.PythHttpClient=void 0;var n=Zv(),i=function(){function t(t,e,r){void 0===r&&(r="finalized"),this.connection=t,this.pythProgramKey=e,this.commitment=r}return t.prototype.getData=function(){return e(this,void 0,void 0,(function(){var t,e,i,o,s,a,u,c,h,l,f,d;return r(this,(function(r){switch(r.label){case 0:return t=new Set,e=new Set,i=new Set,o=new Map,s=new Map,a=new Array,[4,Promise.all([this.connection.getProgramAccounts(this.pythProgramKey,this.commitment),this.connection.getSlot(this.commitment)])];case 1:return u=r.sent(),c=u[0],h=u[1],l=new Array,f=new Map,c.forEach((function(r){var s=n.parseBaseData(r.account.data);if(s)switch(s.type){case n.AccountType.Mapping:break;case n.AccountType.Product:var a=n.parseProductData(r.account.data);f.set(r.pubkey.toBase58(),a.product),t.add(a.product.asset_type),e.add(a.product.symbol),i.add(a.product),o.set(a.product.symbol,a.product);break;case n.AccountType.Price:var u=n.parsePriceData(r.account.data,h);l.push(u);break;case n.AccountType.Test:break;case n.AccountType.Permission:d=n.parsePermissionData(r.account.data);break;default:throw new Error("Unknown account type: "+s.type+". Try upgrading pyth-client.")}})),l.forEach((function(t){var e=f.get(t.productAccountKey.toBase58());e&&(s.set(e.symbol,t),a.push(t))})),[2,{assetTypes:Array.from(t),symbols:Array.from(e),products:Array.from(i),productFromSymbol:o,productPrice:s,prices:a,permissionData:d}]}}))}))},t.prototype.getAssetPricesFromAccounts=function(t){return e(this,void 0,void 0,(function(){var e,i,o,s,a,u,c,h;return r(this,(function(r){switch(r.label){case 0:return e=[],[4,Promise.all([this.connection.getMultipleAccountsInfo(t,this.commitment),this.connection.getSlot(this.commitment)])];case 1:for(i=r.sent(),o=i[0],s=i[1],a=0;a<t.length;a++){if(!(u=o[a]))throw new Error("Could not get account info for account "+t[a].toBase58());if(void 0===(c=n.parseBaseData(u.data))||c.type!==n.AccountType.Price)throw new Error("Account "+t[a].toBase58()+" is not a price account");h=n.parsePriceData(u.data,s),e.push(h)}return[2,e]}}))}))},t}();return id.PythHttpClient=i,id}var sd,ad={};var ud,cd={},hd={},ld=e(se("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")),fd={exports:{}};function dd(){if(ud)return fd.exports;ud=1;const t=/[\p{Lu}]/u,e=/[\p{Ll}]/u,r=/^[\p{Lu}](?![\p{Lu}])/gu,n=/([\p{Alpha}\p{N}_]|$)/u,i=/[_.\- ]+/,o=new RegExp("^"+i.source),s=new RegExp(i.source+n.source,"gu"),a=new RegExp("\\d+"+n.source,"gu"),u=(n,i)=>{if("string"!=typeof n&&!Array.isArray(n))throw new TypeError("Expected the input to be `string | string[]`");if(i={pascalCase:!1,preserveConsecutiveUppercase:!1,...i},n=Array.isArray(n)?n.map((t=>t.trim())).filter((t=>t.length)).join("-"):n.trim(),0===n.length)return"";const u=!1===i.locale?t=>t.toLowerCase():t=>t.toLocaleLowerCase(i.locale),c=!1===i.locale?t=>t.toUpperCase():t=>t.toLocaleUpperCase(i.locale);if(1===n.length)return i.pascalCase?c(n):u(n);return n!==u(n)&&(n=((r,n,i)=>{let o=!1,s=!1,a=!1;for(let u=0;u<r.length;u++){const c=r[u];o&&t.test(c)?(r=r.slice(0,u)+"-"+r.slice(u),o=!1,a=s,s=!0,u++):s&&a&&e.test(c)?(r=r.slice(0,u-1)+"-"+r.slice(u-1),a=s,s=!1,o=!0):(o=n(c)===c&&i(c)!==c,a=s,s=i(c)===c&&n(c)!==c)}return r})(n,u,c)),n=n.replace(o,""),n=i.preserveConsecutiveUppercase?((t,e)=>(r.lastIndex=0,t.replace(r,(t=>e(t)))))(n,u):u(n),i.pascalCase&&(n=c(n.charAt(0))+n.slice(1)),((t,e)=>(s.lastIndex=0,a.lastIndex=0,t.replace(s,((t,r)=>e(r))).replace(a,(t=>e(t)))))(n,c)};return fd.exports=u,fd.exports.default=u,fd.exports}var pd=e(dd()),yd={},gd={};class md{constructor(t,e){if(!Number.isInteger(t))throw new TypeError("span must be an integer");this.span=t,this.property=e}makeDestinationObject(){return{}}decode(t,e){throw new Error("Layout is abstract")}encode(t,e,r){throw new Error("Layout is abstract")}getSpan(t,e){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(t){const e=Object.create(this.constructor.prototype);return Object.assign(e,this),e.property=t,e}fromArray(t){}}function wd(t,e){return e.property?t+"["+e.property+"]":t}gd.Layout=md,gd.nameWithProperty=wd,gd.bindConstructorLayout=function(t,e){if("function"!=typeof t)throw new TypeError("Class must be constructor");if(t.hasOwnProperty("layout_"))throw new Error("Class is already bound to a layout");if(!(e&&e instanceof md))throw new TypeError("layout must be a Layout");if(e.hasOwnProperty("boundConstructor_"))throw new Error("layout is already bound to a constructor");t.layout_=e,e.boundConstructor_=t,e.makeDestinationObject=()=>new t,Object.defineProperty(t.prototype,"encode",{value:function(t,r){return e.encode(this,t,r)},writable:!0}),Object.defineProperty(t,"decode",{value:function(t,r){return e.decode(t,r)},writable:!0})};class bd extends md{isCount(){throw new Error("ExternalLayout is abstract")}}class vd extends bd{constructor(t,e){if(void 0===t&&(t=1),!Number.isInteger(t)||0>=t)throw new TypeError("elementSpan must be a (positive) integer");super(-1,e),this.elementSpan=t}isCount(){return!0}decode(t,e){void 0===e&&(e=0);const r=t.length-e;return Math.floor(r/this.elementSpan)}encode(t,e,r){return 0}}class _d extends bd{constructor(t,e,r){if(!(t instanceof md))throw new TypeError("layout must be a Layout");if(void 0===e)e=0;else if(!Number.isInteger(e))throw new TypeError("offset must be integer or undefined");super(t.span,r||t.property),this.layout=t,this.offset=e}isCount(){return this.layout instanceof kd||this.layout instanceof Ed}decode(t,e){return void 0===e&&(e=0),this.layout.decode(t,e+this.offset)}encode(t,e,r){return void 0===r&&(r=0),this.layout.encode(t,e,r+this.offset)}}class kd extends md{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return void 0===e&&(e=0),t.readUIntLE(e,this.span)}encode(t,e,r){return void 0===r&&(r=0),e.writeUIntLE(t,r,this.span),this.span}}class Ed extends md{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return void 0===e&&(e=0),t.readUIntBE(e,this.span)}encode(t,e,r){return void 0===r&&(r=0),e.writeUIntBE(t,r,this.span),this.span}}class xd extends md{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return void 0===e&&(e=0),t.readIntLE(e,this.span)}encode(t,e,r){return void 0===r&&(r=0),e.writeIntLE(t,r,this.span),this.span}}class Sd extends md{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return void 0===e&&(e=0),t.readIntBE(e,this.span)}encode(t,e,r){return void 0===r&&(r=0),e.writeIntBE(t,r,this.span),this.span}}const Ad=Math.pow(2,32);function Id(t){const e=Math.floor(t/Ad);return{hi32:e,lo32:t-e*Ad}}function Bd(t,e){return t*Ad+e}class Md extends md{constructor(t){super(8,t)}decode(t,e){void 0===e&&(e=0);const r=t.readUInt32LE(e);return Bd(t.readUInt32LE(e+4),r)}encode(t,e,r){void 0===r&&(r=0);const n=Id(t);return e.writeUInt32LE(n.lo32,r),e.writeUInt32LE(n.hi32,r+4),8}}class Rd extends md{constructor(t){super(8,t)}decode(t,e){void 0===e&&(e=0);return Bd(t.readUInt32BE(e),t.readUInt32BE(e+4))}encode(t,e,r){void 0===r&&(r=0);const n=Id(t);return e.writeUInt32BE(n.hi32,r),e.writeUInt32BE(n.lo32,r+4),8}}class Pd extends md{constructor(t){super(8,t)}decode(t,e){void 0===e&&(e=0);const r=t.readUInt32LE(e);return Bd(t.readInt32LE(e+4),r)}encode(t,e,r){void 0===r&&(r=0);const n=Id(t);return e.writeUInt32LE(n.lo32,r),e.writeInt32LE(n.hi32,r+4),8}}class Td extends md{constructor(t){super(8,t)}decode(t,e){void 0===e&&(e=0);return Bd(t.readInt32BE(e),t.readUInt32BE(e+4))}encode(t,e,r){void 0===r&&(r=0);const n=Id(t);return e.writeInt32BE(n.hi32,r),e.writeUInt32BE(n.lo32,r+4),8}}class Od extends md{constructor(t){super(4,t)}decode(t,e){return void 0===e&&(e=0),t.readFloatLE(e)}encode(t,e,r){return void 0===r&&(r=0),e.writeFloatLE(t,r),4}}class Ld extends md{constructor(t){super(4,t)}decode(t,e){return void 0===e&&(e=0),t.readFloatBE(e)}encode(t,e,r){return void 0===r&&(r=0),e.writeFloatBE(t,r),4}}class Ud extends md{constructor(t){super(8,t)}decode(t,e){return void 0===e&&(e=0),t.readDoubleLE(e)}encode(t,e,r){return void 0===r&&(r=0),e.writeDoubleLE(t,r),8}}class Cd extends md{constructor(t){super(8,t)}decode(t,e){return void 0===e&&(e=0),t.readDoubleBE(e)}encode(t,e,r){return void 0===r&&(r=0),e.writeDoubleBE(t,r),8}}class Nd extends md{constructor(t,e,r){if(!(t instanceof md))throw new TypeError("elementLayout must be a Layout");if(!(e instanceof bd&&e.isCount()||Number.isInteger(e)&&0<=e))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let n=-1;!(e instanceof bd)&&0<t.span&&(n=e*t.span),super(n,r),this.elementLayout=t,this.count=e}getSpan(t,e){if(0<=this.span)return this.span;void 0===e&&(e=0);let r=0,n=this.count;if(n instanceof bd&&(n=n.decode(t,e)),0<this.elementLayout.span)r=n*this.elementLayout.span;else{let i=0;for(;i<n;)r+=this.elementLayout.getSpan(t,e+r),++i}return r}decode(t,e){void 0===e&&(e=0);const r=[];let n=0,i=this.count;for(i instanceof bd&&(i=i.decode(t,e));n<i;)r.push(this.elementLayout.decode(t,e)),e+=this.elementLayout.getSpan(t,e),n+=1;return r}encode(t,e,r){void 0===r&&(r=0);const n=this.elementLayout,i=t.reduce(((t,i)=>t+n.encode(i,e,r+t)),0);return this.count instanceof bd&&this.count.encode(t.length,e,r),i}}class zd extends md{constructor(t,e,r){if(!Array.isArray(t)||!t.reduce(((t,e)=>t&&e instanceof md),!0))throw new TypeError("fields must be array of Layout instances");"boolean"==typeof e&&void 0===r&&(r=e,e=void 0);for(const e of t)if(0>e.span&&void 0===e.property)throw new Error("fields cannot contain unnamed variable-length layout");let n=-1;try{n=t.reduce(((t,e)=>t+e.getSpan()),0)}catch(t){}super(n,e),this.fields=t,this.decodePrefixes=!!r}getSpan(t,e){if(0<=this.span)return this.span;void 0===e&&(e=0);let r=0;try{r=this.fields.reduce(((r,n)=>{const i=n.getSpan(t,e);return e+=i,r+i}),0)}catch(t){throw new RangeError("indeterminate span")}return r}decode(t,e){void 0===e&&(e=0);const r=this.makeDestinationObject();for(const n of this.fields)if(void 0!==n.property&&(r[n.property]=n.decode(t,e)),e+=n.getSpan(t,e),this.decodePrefixes&&t.length===e)break;return r}encode(t,e,r){void 0===r&&(r=0);const n=r;let i=0,o=0;for(const n of this.fields){let s=n.span;if(o=0<s?s:0,void 0!==n.property){const i=t[n.property];void 0!==i&&(o=n.encode(i,e,r),0>s&&(s=n.getSpan(e,r)))}i=r,r+=s}return i+o-n}fromArray(t){const e=this.makeDestinationObject();for(const r of this.fields)void 0!==r.property&&0<t.length&&(e[r.property]=t.shift());return e}layoutFor(t){if("string"!=typeof t)throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}offsetOf(t){if("string"!=typeof t)throw new TypeError("property must be string");let e=0;for(const r of this.fields){if(r.property===t)return e;0>r.span?e=-1:0<=e&&(e+=r.span)}}}class Dd{constructor(t){this.property=t}decode(){throw new Error("UnionDiscriminator is abstract")}encode(){throw new Error("UnionDiscriminator is abstract")}}class jd extends Dd{constructor(t,e){if(!(t instanceof bd&&t.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(e||t.property||"variant"),this.layout=t}decode(t,e){return this.layout.decode(t,e)}encode(t,e,r){return this.layout.encode(t,e,r)}}class Wd extends md{constructor(t,e,r){const n=t instanceof kd||t instanceof Ed;if(n)t=new jd(new _d(t));else if(t instanceof bd&&t.isCount())t=new jd(t);else if(!(t instanceof Dd))throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(void 0===e&&(e=null),!(null===e||e instanceof md))throw new TypeError("defaultLayout must be null or a Layout");if(null!==e){if(0>e.span)throw new Error("defaultLayout must have constant span");void 0===e.property&&(e=e.replicate("content"))}let i=-1;e&&(i=e.span,0<=i&&n&&(i+=t.layout.span)),super(i,r),this.discriminator=t,this.usesPrefixDiscriminator=n,this.defaultLayout=e,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(t){return o(t)},this.configGetSourceVariant=function(t){o=t.bind(this)}}getSpan(t,e){if(0<=this.span)return this.span;void 0===e&&(e=0);const r=this.getVariant(t,e);if(!r)throw new Error("unable to determine span for unrecognized variant");return r.getSpan(t,e)}defaultGetSourceVariant(t){if(t.hasOwnProperty(this.discriminator.property)){if(this.defaultLayout&&t.hasOwnProperty(this.defaultLayout.property))return;const e=this.registry[t[this.discriminator.property]];if(e&&(!e.layout||t.hasOwnProperty(e.property)))return e}else for(const e in this.registry){const r=this.registry[e];if(t.hasOwnProperty(r.property))return r}throw new Error("unable to infer src variant")}decode(t,e){let r;void 0===e&&(e=0);const n=this.discriminator,i=n.decode(t,e);let o=this.registry[i];if(void 0===o){let s=0;o=this.defaultLayout,this.usesPrefixDiscriminator&&(s=n.layout.span),r=this.makeDestinationObject(),r[n.property]=i,r[o.property]=this.defaultLayout.decode(t,e+s)}else r=o.decode(t,e);return r}encode(t,e,r){void 0===r&&(r=0);const n=this.getSourceVariant(t);if(void 0===n){const n=this.discriminator,i=this.defaultLayout;let o=0;return this.usesPrefixDiscriminator&&(o=n.layout.span),n.encode(t[n.property],e,r),o+i.encode(t[i.property],e,r+o)}return n.encode(t,e,r)}addVariant(t,e,r){const n=new Kd(this,t,e,r);return this.registry[t]=n,n}getVariant(t,e){let r=t;return Buffer.isBuffer(t)&&(void 0===e&&(e=0),r=this.discriminator.decode(t,e)),this.registry[r]}}class Kd extends md{constructor(t,e,r,n){if(!(t instanceof Wd))throw new TypeError("union must be a Union");if(!Number.isInteger(e)||0>e)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 md))throw new TypeError("layout must be a Layout");if(null!==t.defaultLayout&&0<=r.span&&r.span>t.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=t.span;0>t.span&&(i=r?r.span:0,0<=i&&t.usesPrefixDiscriminator&&(i+=t.discriminator.layout.span)),super(i,n),this.union=t,this.variant=e,this.layout=r||null}getSpan(t,e){if(0<=this.span)return this.span;void 0===e&&(e=0);let r=0;return this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span),r+this.layout.getSpan(t,e+r)}decode(t,e){const r=this.makeDestinationObject();if(void 0===e&&(e=0),this!==this.union.getVariant(t,e))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(t,e+n):this.property?r[this.property]=!0:this.union.usesPrefixDiscriminator&&(r[this.union.discriminator.property]=this.variant),r}encode(t,e,r){void 0===r&&(r=0);let n=0;if(this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span),this.layout&&!t.hasOwnProperty(this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,e,r);let i=n;if(this.layout&&(this.layout.encode(t[this.property],e,r+n),i+=this.layout.getSpan(e,r+n),0<=this.union.span&&i>this.union.span))throw new Error("encoded variant overruns containing union");return i}fromArray(t){if(this.layout)return this.layout.fromArray(t)}}function Fd(t){return 0>t&&(t+=4294967296),t}class qd extends md{constructor(t,e,r){if(!(t instanceof kd||t instanceof Ed))throw new TypeError("word must be a UInt or UIntBE layout");if("string"==typeof e&&void 0===r&&(r=e,e=void 0),4<t.span)throw new RangeError("word cannot exceed 32 bits");super(t.span,r),this.word=t,this.msb=!!e,this.fields=[];let n=0;this._packedSetValue=function(t){return n=Fd(t),this},this._packedGetValue=function(){return n}}decode(t,e){const r=this.makeDestinationObject();void 0===e&&(e=0);const n=this.word.decode(t,e);this._packedSetValue(n);for(const t of this.fields)void 0!==t.property&&(r[t.property]=t.decode(n));return r}encode(t,e,r){void 0===r&&(r=0);const n=this.word.decode(e,r);this._packedSetValue(n);for(const e of this.fields)if(void 0!==e.property){const r=t[e.property];void 0!==r&&e.encode(r)}return this.word.encode(this._packedGetValue(),e,r)}addField(t,e){const r=new Vd(this,t,e);return this.fields.push(r),r}addBoolean(t){const e=new Hd(this,t);return this.fields.push(e),e}fieldFor(t){if("string"!=typeof t)throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}}class Vd{constructor(t,e,r){if(!(t instanceof qd))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(e)||0>=e)throw new TypeError("bits must be positive integer");const n=8*t.span,i=t.fields.reduce(((t,e)=>t+e.bits),0);if(e+i>n)throw new Error("bits too long for span remainder ("+(n-i)+" of "+n+" remain)");this.container=t,this.bits=e,this.valueMask=(1<<e)-1,32===e&&(this.valueMask=4294967295),this.start=i,this.container.msb&&(this.start=n-i-e),this.wordMask=Fd(this.valueMask<<this.start),this.property=r}decode(){return Fd(this.container._packedGetValue()&this.wordMask)>>>this.start}encode(t){if(!Number.isInteger(t)||t!==Fd(t&this.valueMask))throw new TypeError(wd("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const e=this.container._packedGetValue(),r=Fd(t<<this.start);this.container._packedSetValue(Fd(e&~this.wordMask)|r)}}class Hd extends Vd{constructor(t,e){super(t,1,e)}decode(t,e){return!!Vd.prototype.decode.call(this,t,e)}encode(t){return"boolean"==typeof t&&(t=+t),Vd.prototype.encode.call(this,t)}}class $d extends md{constructor(t,e){if(!(t instanceof bd&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let r=-1;t instanceof bd||(r=t),super(r,e),this.length=t}getSpan(t,e){let r=this.span;return 0>r&&(r=this.length.decode(t,e)),r}decode(t,e){void 0===e&&(e=0);let r=this.span;return 0>r&&(r=this.length.decode(t,e)),t.slice(e,e+r)}encode(t,e,r){let n=this.length;if(this.length instanceof bd&&(n=t.length),!Buffer.isBuffer(t)||n!==t.length)throw new TypeError(wd("Blob.encode",this)+" requires (length "+n+") Buffer as src");if(r+n>e.length)throw new RangeError("encoding overruns Buffer");return e.write(t.toString("hex"),r,n,"hex"),this.length instanceof bd&&this.length.encode(n,e,r),n}}class Gd extends md{constructor(t){super(-1,t)}getSpan(t,e){if(!Buffer.isBuffer(t))throw new TypeError("b must be a Buffer");void 0===e&&(e=0);let r=e;for(;r<t.length&&0!==t[r];)r+=1;return 1+r-e}decode(t,e,r){void 0===e&&(e=0);let n=this.getSpan(t,e);return t.slice(e,e+n-1).toString("utf-8")}encode(t,e,r){void 0===r&&(r=0),"string"!=typeof t&&(t=t.toString());const n=new Buffer(t,"utf8"),i=n.length;if(r+i>e.length)throw new RangeError("encoding overruns Buffer");return n.copy(e,r),e[r+i]=0,i+1}}class Zd extends md{constructor(t,e){if("string"==typeof t&&void 0===e&&(e=t,t=void 0),void 0===t)t=-1;else if(!Number.isInteger(t))throw new TypeError("maxSpan must be an integer");super(-1,e),this.maxSpan=t}getSpan(t,e){if(!Buffer.isBuffer(t))throw new TypeError("b must be a Buffer");return void 0===e&&(e=0),t.length-e}decode(t,e,r){void 0===e&&(e=0);let n=this.getSpan(t,e);if(0<=this.maxSpan&&this.maxSpan<n)throw new RangeError("text length exceeds maxSpan");return t.slice(e,e+n).toString("utf-8")}encode(t,e,r){void 0===r&&(r=0),"string"!=typeof t&&(t=t.toString());const n=new Buffer(t,"utf8"),i=n.length;if(0<=this.maxSpan&&this.maxSpan<i)throw new RangeError("text length exceeds maxSpan");if(r+i>e.length)throw new RangeError("encoding overruns Buffer");return n.copy(e,r),i}}class Yd extends md{constructor(t,e){super(0,e),this.value=t}decode(t,e,r){return this.value}encode(t,e,r){return 0}}gd.ExternalLayout=bd,gd.GreedyCount=vd,gd.OffsetLayout=_d,gd.UInt=kd,gd.UIntBE=Ed,gd.Int=xd,gd.IntBE=Sd,gd.Float=Od,gd.FloatBE=Ld,gd.Double=Ud,gd.DoubleBE=Cd,gd.Sequence=Nd,gd.Structure=zd,gd.UnionDiscriminator=Dd,gd.UnionLayoutDiscriminator=jd,gd.Union=Wd,gd.VariantLayout=Kd,gd.BitStructure=qd,gd.BitField=Vd,gd.Boolean=Hd,gd.Blob=$d,gd.CString=Gd,gd.UTF8=Zd,gd.Constant=Yd,gd.greedy=(t,e)=>new vd(t,e),gd.offset=(t,e,r)=>new _d(t,e,r),gd.u8=t=>new kd(1,t),gd.u16=t=>new kd(2,t),gd.u24=t=>new kd(3,t),gd.u32=t=>new kd(4,t),gd.u40=t=>new kd(5,t),gd.u48=t=>new kd(6,t),gd.nu64=t=>new Md(t),gd.u16be=t=>new Ed(2,t),gd.u24be=t=>new Ed(3,t),gd.u32be=t=>new Ed(4,t),gd.u40be=t=>new Ed(5,t),gd.u48be=t=>new Ed(6,t),gd.nu64be=t=>new Rd(t),gd.s8=t=>new xd(1,t),gd.s16=t=>new xd(2,t),gd.s24=t=>new xd(3,t),gd.s32=t=>new xd(4,t),gd.s40=t=>new xd(5,t),gd.s48=t=>new xd(6,t),gd.ns64=t=>new Pd(t),gd.s16be=t=>new Sd(2,t),gd.s24be=t=>new Sd(3,t),gd.s32be=t=>new Sd(4,t),gd.s40be=t=>new Sd(5,t),gd.s48be=t=>new Sd(6,t),gd.ns64be=t=>new Td(t),gd.f32=t=>new Od(t),gd.f32be=t=>new Ld(t),gd.f64=t=>new Ud(t),gd.f64be=t=>new Cd(t),gd.struct=(t,e,r)=>new zd(t,e,r),gd.bits=(t,e,r)=>new qd(t,e,r),gd.seq=(t,e,r)=>new Nd(t,e,r),gd.union=(t,e,r)=>new Wd(t,e,r),gd.unionLayoutDiscriminator=(t,e)=>new jd(t,e),gd.blob=(t,e)=>new $d(t,e),gd.cstr=t=>new Gd(t),gd.utf8=(t,e)=>new Zd(t,e),gd.const=(t,e)=>new Yd(t,e),function(e){var r=t&&t.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.map=e.array=e.rustEnum=e.str=e.vecU8=e.tagged=e.vec=e.bool=e.option=e.publicKey=e.i256=e.u256=e.i128=e.u128=e.i64=e.u64=e.struct=e.f64=e.f32=e.i32=e.u32=e.i16=e.u16=e.i8=e.u8=void 0;const n=gd,i=$f,o=r(re);var s=gd;Object.defineProperty(e,"u8",{enumerable:!0,get:function(){return s.u8}}),Object.defineProperty(e,"i8",{enumerable:!0,get:function(){return s.s8}}),Object.defineProperty(e,"u16",{enumerable:!0,get:function(){return s.u16}}),Object.defineProperty(e,"i16",{enumerable:!0,get:function(){return s.s16}}),Object.defineProperty(e,"u32",{enumerable:!0,get:function(){return s.u32}}),Object.defineProperty(e,"i32",{enumerable:!0,get:function(){return s.s32}}),Object.defineProperty(e,"f32",{enumerable:!0,get:function(){return s.f32}}),Object.defineProperty(e,"f64",{enumerable:!0,get:function(){return s.f64}}),Object.defineProperty(e,"struct",{enumerable:!0,get:function(){return s.struct}});class a extends n.Layout{constructor(t,e,r){super(t,r),this.blob=(0,n.blob)(t),this.signed=e}decode(t,e=0){const r=new o.default(this.blob.decode(t,e),10,"le");return this.signed?r.fromTwos(8*this.span).clone():r}encode(t,e,r=0){return this.signed&&(t=t.toTwos(8*this.span)),this.blob.encode(t.toArrayLike(Buffer,"le",this.span),e,r)}}function u(t){return new a(8,!1,t)}e.u64=u,e.i64=function(t){return new a(8,!0,t)},e.u128=function(t){return new a(16,!1,t)},e.i128=function(t){return new a(16,!0,t)},e.u256=function(t){return new a(32,!1,t)},e.i256=function(t){return new a(32,!0,t)};class c extends n.Layout{constructor(t,e,r,n){super(t.span,n),this.layout=t,this.decoder=e,this.encoder=r}decode(t,e){return this.decoder(this.layout.decode(t,e))}encode(t,e,r){return this.layout.encode(this.encoder(t),e,r)}getSpan(t,e){return this.layout.getSpan(t,e)}}e.publicKey=function(t){return new c((0,n.blob)(32),(t=>new i.PublicKey(t)),(t=>t.toBuffer()),t)};class h extends n.Layout{constructor(t,e){super(-1,e),this.layout=t,this.discriminator=(0,n.u8)()}encode(t,e,r=0){return null==t?this.discriminator.encode(0,e,r):(this.discriminator.encode(1,e,r),this.layout.encode(t,e,r+1)+1)}decode(t,e=0){const r=this.discriminator.decode(t,e);if(0===r)return null;if(1===r)return this.layout.decode(t,e+1);throw new Error("Invalid option "+this.property)}getSpan(t,e=0){const r=this.discriminator.decode(t,e);if(0===r)return 1;if(1===r)return this.layout.getSpan(t,e+1)+1;throw new Error("Invalid option "+this.property)}}function l(t){if(0===t)return!1;if(1===t)return!0;throw new Error("Invalid bool: "+t)}function f(t){return t?1:0}function d(t){const e=(0,n.u32)("length"),r=(0,n.struct)([e,(0,n.blob)((0,n.offset)(e,-e.span),"data")]);return new c(r,(({data:t})=>t),(t=>({data:t})),t)}e.option=function(t,e){return new h(t,e)},e.bool=function(t){return new c((0,n.u8)(),l,f,t)},e.vec=function(t,e){const r=(0,n.u32)("length"),i=(0,n.struct)([r,(0,n.seq)(t,(0,n.offset)(r,-r.span),"values")]);return new c(i,(({values:t})=>t),(t=>({values:t})),e)},e.tagged=function(t,e,r){const i=(0,n.struct)([u("tag"),e.replicate("data")]);return new c(i,(function({tag:e,data:r}){if(!e.eq(t))throw new Error("Invalid tag, expected: "+t.toString("hex")+", got: "+e.toString("hex"));return r}),(e=>({tag:t,data:e})),r)},e.vecU8=d,e.str=function(t){return new c(d(),(t=>t.toString("utf-8")),(t=>Buffer.from(t,"utf-8")),t)},e.rustEnum=function(t,e,r){const i=(0,n.union)(null!=r?r:(0,n.u8)(),e);return t.forEach(((t,e)=>i.addVariant(e,t,t.property))),i},e.array=function(t,e,r){const i=(0,n.struct)([(0,n.seq)(t,e,"values")]);return new c(i,(({values:t})=>t),(t=>({values:t})),r)};class p extends n.Layout{constructor(t,e,r){super(t.span+e.span,r),this.keyLayout=t,this.valueLayout=e}decode(t,e){e=e||0;return[this.keyLayout.decode(t,e),this.valueLayout.decode(t,e+this.keyLayout.getSpan(t,e))]}encode(t,e,r){r=r||0;const n=this.keyLayout.encode(t[0],e,r);return n+this.valueLayout.encode(t[1],e,r+n)}getSpan(t,e){return this.keyLayout.getSpan(t,e)+this.valueLayout.getSpan(t,e)}}e.map=function(t,e,r){const i=(0,n.u32)("length"),o=(0,n.struct)([i,(0,n.seq)(new p(t,e),(0,n.offset)(i,-i.span),"values")]);return new c(o,(({values:t})=>new Map(t)),(t=>({values:Array.from(t.entries())})),r)}}(yd);function Jd(t){let e=t.length;for(;--e>=0;)t[e]=0}const Xd=256,Qd=286,tp=30,ep=15,rp=new Uint8Array([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]),np=new Uint8Array([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]),ip=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),op=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),sp=new Array(576);Jd(sp);const ap=new Array(60);Jd(ap);const up=new Array(512);Jd(up);const cp=new Array(256);Jd(cp);const hp=new Array(29);Jd(hp);const lp=new Array(tp);function fp(t,e,r,n,i){this.static_tree=t,this.extra_bits=e,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=t&&t.length}let dp,pp,yp;function gp(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}Jd(lp);const mp=t=>t<256?up[t]:up[256+(t>>>7)],wp=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},bp=(t,e,r)=>{t.bi_valid>16-r?(t.bi_buf|=e<<t.bi_valid&65535,wp(t,t.bi_buf),t.bi_buf=e>>16-t.bi_valid,t.bi_valid+=r-16):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=r)},vp=(t,e,r)=>{bp(t,r[2*e],r[2*e+1])},_p=(t,e)=>{let r=0;do{r|=1&t,t>>>=1,r<<=1}while(--e>0);return r>>>1},kp=(t,e,r)=>{const n=new Array(16);let i,o,s=0;for(i=1;i<=ep;i++)s=s+r[i-1]<<1,n[i]=s;for(o=0;o<=e;o++){let e=t[2*o+1];0!==e&&(t[2*o]=_p(n[e]++,e))}},Ep=t=>{let e;for(e=0;e<Qd;e++)t.dyn_ltree[2*e]=0;for(e=0;e<tp;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.sym_next=t.matches=0},xp=t=>{t.bi_valid>8?wp(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},Sp=(t,e,r,n)=>{const i=2*e,o=2*r;return t[i]<t[o]||t[i]===t[o]&&n[e]<=n[r]},Ap=(t,e,r)=>{const n=t.heap[r];let i=r<<1;for(;i<=t.heap_len&&(i<t.heap_len&&Sp(e,t.heap[i+1],t.heap[i],t.depth)&&i++,!Sp(e,n,t.heap[i],t.depth));)t.heap[r]=t.heap[i],r=i,i<<=1;t.heap[r]=n},Ip=(t,e,r)=>{let n,i,o,s,a=0;if(0!==t.sym_next)do{n=255&t.pending_buf[t.sym_buf+a++],n+=(255&t.pending_buf[t.sym_buf+a++])<<8,i=t.pending_buf[t.sym_buf+a++],0===n?vp(t,i,e):(o=cp[i],vp(t,o+Xd+1,e),s=rp[o],0!==s&&(i-=hp[o],bp(t,i,s)),n--,o=mp(n),vp(t,o,r),s=np[o],0!==s&&(n-=lp[o],bp(t,n,s)))}while(a<t.sym_next);vp(t,256,e)},Bp=(t,e)=>{const r=e.dyn_tree,n=e.stat_desc.static_tree,i=e.stat_desc.has_stree,o=e.stat_desc.elems;let s,a,u,c=-1;for(t.heap_len=0,t.heap_max=573,s=0;s<o;s++)0!==r[2*s]?(t.heap[++t.heap_len]=c=s,t.depth[s]=0):r[2*s+1]=0;for(;t.heap_len<2;)u=t.heap[++t.heap_len]=c<2?++c:0,r[2*u]=1,t.depth[u]=0,t.opt_len--,i&&(t.static_len-=n[2*u+1]);for(e.max_code=c,s=t.heap_len>>1;s>=1;s--)Ap(t,r,s);u=o;do{s=t.heap[1],t.heap[1]=t.heap[t.heap_len--],Ap(t,r,1),a=t.heap[1],t.heap[--t.heap_max]=s,t.heap[--t.heap_max]=a,r[2*u]=r[2*s]+r[2*a],t.depth[u]=(t.depth[s]>=t.depth[a]?t.depth[s]:t.depth[a])+1,r[2*s+1]=r[2*a+1]=u,t.heap[1]=u++,Ap(t,r,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],((t,e)=>{const r=e.dyn_tree,n=e.max_code,i=e.stat_desc.static_tree,o=e.stat_desc.has_stree,s=e.stat_desc.extra_bits,a=e.stat_desc.extra_base,u=e.stat_desc.max_length;let c,h,l,f,d,p,y=0;for(f=0;f<=ep;f++)t.bl_count[f]=0;for(r[2*t.heap[t.heap_max]+1]=0,c=t.heap_max+1;c<573;c++)h=t.heap[c],f=r[2*r[2*h+1]+1]+1,f>u&&(f=u,y++),r[2*h+1]=f,h>n||(t.bl_count[f]++,d=0,h>=a&&(d=s[h-a]),p=r[2*h],t.opt_len+=p*(f+d),o&&(t.static_len+=p*(i[2*h+1]+d)));if(0!==y){do{for(f=u-1;0===t.bl_count[f];)f--;t.bl_count[f]--,t.bl_count[f+1]+=2,t.bl_count[u]--,y-=2}while(y>0);for(f=u;0!==f;f--)for(h=t.bl_count[f];0!==h;)l=t.heap[--c],l>n||(r[2*l+1]!==f&&(t.opt_len+=(f-r[2*l+1])*r[2*l],r[2*l+1]=f),h--)}})(t,e),kp(r,c,t.bl_count)},Mp=(t,e,r)=>{let n,i,o=-1,s=e[1],a=0,u=7,c=4;for(0===s&&(u=138,c=3),e[2*(r+1)+1]=65535,n=0;n<=r;n++)i=s,s=e[2*(n+1)+1],++a<u&&i===s||(a<c?t.bl_tree[2*i]+=a:0!==i?(i!==o&&t.bl_tree[2*i]++,t.bl_tree[32]++):a<=10?t.bl_tree[34]++:t.bl_tree[36]++,a=0,o=i,0===s?(u=138,c=3):i===s?(u=6,c=3):(u=7,c=4))},Rp=(t,e,r)=>{let n,i,o=-1,s=e[1],a=0,u=7,c=4;for(0===s&&(u=138,c=3),n=0;n<=r;n++)if(i=s,s=e[2*(n+1)+1],!(++a<u&&i===s)){if(a<c)do{vp(t,i,t.bl_tree)}while(0!=--a);else 0!==i?(i!==o&&(vp(t,i,t.bl_tree),a--),vp(t,16,t.bl_tree),bp(t,a-3,2)):a<=10?(vp(t,17,t.bl_tree),bp(t,a-3,3)):(vp(t,18,t.bl_tree),bp(t,a-11,7));a=0,o=i,0===s?(u=138,c=3):i===s?(u=6,c=3):(u=7,c=4)}};let Pp=!1;const Tp=(t,e,r,n)=>{bp(t,0+(n?1:0),3),xp(t),wp(t,r),wp(t,~r),r&&t.pending_buf.set(t.window.subarray(e,e+r),t.pending),t.pending+=r};var Op=t=>{Pp||((()=>{let t,e,r,n,i;const o=new Array(16);for(r=0,n=0;n<28;n++)for(hp[n]=r,t=0;t<1<<rp[n];t++)cp[r++]=n;for(cp[r-1]=n,i=0,n=0;n<16;n++)for(lp[n]=i,t=0;t<1<<np[n];t++)up[i++]=n;for(i>>=7;n<tp;n++)for(lp[n]=i<<7,t=0;t<1<<np[n]-7;t++)up[256+i++]=n;for(e=0;e<=ep;e++)o[e]=0;for(t=0;t<=143;)sp[2*t+1]=8,t++,o[8]++;for(;t<=255;)sp[2*t+1]=9,t++,o[9]++;for(;t<=279;)sp[2*t+1]=7,t++,o[7]++;for(;t<=287;)sp[2*t+1]=8,t++,o[8]++;for(kp(sp,287,o),t=0;t<tp;t++)ap[2*t+1]=5,ap[2*t]=_p(t,5);dp=new fp(sp,rp,257,Qd,ep),pp=new fp(ap,np,0,tp,ep),yp=new fp(new Array(0),ip,0,19,7)})(),Pp=!0),t.l_desc=new gp(t.dyn_ltree,dp),t.d_desc=new gp(t.dyn_dtree,pp),t.bl_desc=new gp(t.bl_tree,yp),t.bi_buf=0,t.bi_valid=0,Ep(t)},Lp=(t,e,r,n)=>{let i,o,s=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=(t=>{let e,r=4093624447;for(e=0;e<=31;e++,r>>>=1)if(1&r&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<Xd;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0})(t)),Bp(t,t.l_desc),Bp(t,t.d_desc),s=(t=>{let e;for(Mp(t,t.dyn_ltree,t.l_desc.max_code),Mp(t,t.dyn_dtree,t.d_desc.max_code),Bp(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*op[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e})(t),i=t.opt_len+3+7>>>3,o=t.static_len+3+7>>>3,o<=i&&(i=o)):i=o=r+5,r+4<=i&&-1!==e?Tp(t,e,r,n):4===t.strategy||o===i?(bp(t,2+(n?1:0),3),Ip(t,sp,ap)):(bp(t,4+(n?1:0),3),((t,e,r,n)=>{let i;for(bp(t,e-257,5),bp(t,r-1,5),bp(t,n-4,4),i=0;i<n;i++)bp(t,t.bl_tree[2*op[i]+1],3);Rp(t,t.dyn_ltree,e-1),Rp(t,t.dyn_dtree,r-1)})(t,t.l_desc.max_code+1,t.d_desc.max_code+1,s+1),Ip(t,t.dyn_ltree,t.dyn_dtree)),Ep(t),n&&xp(t)},Up=(t,e,r)=>(t.pending_buf[t.sym_buf+t.sym_next++]=e,t.pending_buf[t.sym_buf+t.sym_next++]=e>>8,t.pending_buf[t.sym_buf+t.sym_next++]=r,0===e?t.dyn_ltree[2*r]++:(t.matches++,e--,t.dyn_ltree[2*(cp[r]+Xd+1)]++,t.dyn_dtree[2*mp(e)]++),t.sym_next===t.sym_end),Cp=t=>{bp(t,2,3),vp(t,256,sp),(t=>{16===t.bi_valid?(wp(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)})(t)},Np={_tr_init:Op,_tr_stored_block:Tp,_tr_flush_block:Lp,_tr_tally:Up,_tr_align:Cp};var zp=(t,e,r,n)=>{let i=65535&t|0,o=t>>>16&65535|0,s=0;for(;0!==r;){s=r>2e3?2e3:r,r-=s;do{i=i+e[n++]|0,o=o+i|0}while(--s);i%=65521,o%=65521}return i|o<<16|0};const Dp=new Uint32Array((()=>{let t,e=[];for(var r=0;r<256;r++){t=r;for(var n=0;n<8;n++)t=1&t?3988292384^t>>>1:t>>>1;e[r]=t}return e})());var jp=(t,e,r,n)=>{const i=Dp,o=n+r;t^=-1;for(let r=n;r<o;r++)t=t>>>8^i[255&(t^e[r])];return-1^t},Wp={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"},Kp={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:Fp,_tr_stored_block:qp,_tr_flush_block:Vp,_tr_tally:Hp,_tr_align:$p}=Np,{Z_NO_FLUSH:Gp,Z_PARTIAL_FLUSH:Zp,Z_FULL_FLUSH:Yp,Z_FINISH:Jp,Z_BLOCK:Xp,Z_OK:Qp,Z_STREAM_END:ty,Z_STREAM_ERROR:ey,Z_DATA_ERROR:ry,Z_BUF_ERROR:ny,Z_DEFAULT_COMPRESSION:iy,Z_FILTERED:oy,Z_HUFFMAN_ONLY:sy,Z_RLE:ay,Z_FIXED:uy,Z_DEFAULT_STRATEGY:cy,Z_UNKNOWN:hy,Z_DEFLATED:ly}=Kp,fy=258,dy=262,py=42,yy=113,gy=666,my=(t,e)=>(t.msg=Wp[e],e),wy=t=>2*t-(t>4?9:0),by=t=>{let e=t.length;for(;--e>=0;)t[e]=0},vy=t=>{let e,r,n,i=t.w_size;e=t.hash_size,n=e;do{r=t.head[--n],t.head[n]=r>=i?r-i:0}while(--e);e=i,n=e;do{r=t.prev[--n],t.prev[n]=r>=i?r-i:0}while(--e)};let _y=(t,e,r)=>(e<<t.hash_shift^r)&t.hash_mask;const ky=t=>{const e=t.state;let r=e.pending;r>t.avail_out&&(r=t.avail_out),0!==r&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+r),t.next_out),t.next_out+=r,e.pending_out+=r,t.total_out+=r,t.avail_out-=r,e.pending-=r,0===e.pending&&(e.pending_out=0))},Ey=(t,e)=>{Vp(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,ky(t.strm)},xy=(t,e)=>{t.pending_buf[t.pending++]=e},Sy=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},Ay=(t,e,r,n)=>{let i=t.avail_in;return i>n&&(i=n),0===i?0:(t.avail_in-=i,e.set(t.input.subarray(t.next_in,t.next_in+i),r),1===t.state.wrap?t.adler=zp(t.adler,e,i,r):2===t.state.wrap&&(t.adler=jp(t.adler,e,i,r)),t.next_in+=i,t.total_in+=i,i)},Iy=(t,e)=>{let r,n,i=t.max_chain_length,o=t.strstart,s=t.prev_length,a=t.nice_match;const u=t.strstart>t.w_size-dy?t.strstart-(t.w_size-dy):0,c=t.window,h=t.w_mask,l=t.prev,f=t.strstart+fy;let d=c[o+s-1],p=c[o+s];t.prev_length>=t.good_match&&(i>>=2),a>t.lookahead&&(a=t.lookahead);do{if(r=e,c[r+s]===p&&c[r+s-1]===d&&c[r]===c[o]&&c[++r]===c[o+1]){o+=2,r++;do{}while(c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&o<f);if(n=fy-(f-o),o=f-fy,n>s){if(t.match_start=e,s=n,n>=a)break;d=c[o+s-1],p=c[o+s]}}}while((e=l[e&h])>u&&0!=--i);return s<=t.lookahead?s:t.lookahead},By=t=>{const e=t.w_size;let r,n,i;do{if(n=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-dy)&&(t.window.set(t.window.subarray(e,e+e-n),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,t.insert>t.strstart&&(t.insert=t.strstart),vy(t),n+=e),0===t.strm.avail_in)break;if(r=Ay(t.strm,t.window,t.strstart+t.lookahead,n),t.lookahead+=r,t.lookahead+t.insert>=3)for(i=t.strstart-t.insert,t.ins_h=t.window[i],t.ins_h=_y(t,t.ins_h,t.window[i+1]);t.insert&&(t.ins_h=_y(t,t.ins_h,t.window[i+3-1]),t.prev[i&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=i,i++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<dy&&0!==t.strm.avail_in)},My=(t,e)=>{let r,n,i,o=t.pending_buf_size-5>t.w_size?t.w_size:t.pending_buf_size-5,s=0,a=t.strm.avail_in;do{if(r=65535,i=t.bi_valid+42>>3,t.strm.avail_out<i)break;if(i=t.strm.avail_out-i,n=t.strstart-t.block_start,r>n+t.strm.avail_in&&(r=n+t.strm.avail_in),r>i&&(r=i),r<o&&(0===r&&e!==Jp||e===Gp||r!==n+t.strm.avail_in))break;s=e===Jp&&r===n+t.strm.avail_in?1:0,qp(t,0,0,s),t.pending_buf[t.pending-4]=r,t.pending_buf[t.pending-3]=r>>8,t.pending_buf[t.pending-2]=~r,t.pending_buf[t.pending-1]=~r>>8,ky(t.strm),n&&(n>r&&(n=r),t.strm.output.set(t.window.subarray(t.block_start,t.block_start+n),t.strm.next_out),t.strm.next_out+=n,t.strm.avail_out-=n,t.strm.total_out+=n,t.block_start+=n,r-=n),r&&(Ay(t.strm,t.strm.output,t.strm.next_out,r),t.strm.next_out+=r,t.strm.avail_out-=r,t.strm.total_out+=r)}while(0===s);return a-=t.strm.avail_in,a&&(a>=t.w_size?(t.matches=2,t.window.set(t.strm.input.subarray(t.strm.next_in-t.w_size,t.strm.next_in),0),t.strstart=t.w_size,t.insert=t.strstart):(t.window_size-t.strstart<=a&&(t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,t.insert>t.strstart&&(t.insert=t.strstart)),t.window.set(t.strm.input.subarray(t.strm.next_in-a,t.strm.next_in),t.strstart),t.strstart+=a,t.insert+=a>t.w_size-t.insert?t.w_size-t.insert:a),t.block_start=t.strstart),t.high_water<t.strstart&&(t.high_water=t.strstart),s?4:e!==Gp&&e!==Jp&&0===t.strm.avail_in&&t.strstart===t.block_start?2:(i=t.window_size-t.strstart,t.strm.avail_in>i&&t.block_start>=t.w_size&&(t.block_start-=t.w_size,t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,i+=t.w_size,t.insert>t.strstart&&(t.insert=t.strstart)),i>t.strm.avail_in&&(i=t.strm.avail_in),i&&(Ay(t.strm,t.window,t.strstart,i),t.strstart+=i,t.insert+=i>t.w_size-t.insert?t.w_size-t.insert:i),t.high_water<t.strstart&&(t.high_water=t.strstart),i=t.bi_valid+42>>3,i=t.pending_buf_size-i>65535?65535:t.pending_buf_size-i,o=i>t.w_size?t.w_size:i,n=t.strstart-t.block_start,(n>=o||(n||e===Jp)&&e!==Gp&&0===t.strm.avail_in&&n<=i)&&(r=n>i?i:n,s=e===Jp&&0===t.strm.avail_in&&r===n?1:0,qp(t,t.block_start,r,s),t.block_start+=r,ky(t.strm)),s?3:1)},Ry=(t,e)=>{let r,n;for(;;){if(t.lookahead<dy){if(By(t),t.lookahead<dy&&e===Gp)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=_y(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==r&&t.strstart-r<=t.w_size-dy&&(t.match_length=Iy(t,r)),t.match_length>=3)if(n=Hp(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=_y(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=_y(t,t.ins_h,t.window[t.strstart+1]);else n=Hp(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(n&&(Ey(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===Jp?(Ey(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(Ey(t,!1),0===t.strm.avail_out)?1:2},Py=(t,e)=>{let r,n,i;for(;;){if(t.lookahead<dy){if(By(t),t.lookahead<dy&&e===Gp)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=_y(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==r&&t.prev_length<t.max_lazy_match&&t.strstart-r<=t.w_size-dy&&(t.match_length=Iy(t,r),t.match_length<=5&&(t.strategy===oy||3===t.match_length&&t.strstart-t.match_start>4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){i=t.strstart+t.lookahead-3,n=Hp(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=i&&(t.ins_h=_y(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!=--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,n&&(Ey(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if(n=Hp(t,0,t.window[t.strstart-1]),n&&Ey(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(n=Hp(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===Jp?(Ey(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(Ey(t,!1),0===t.strm.avail_out)?1:2};function Ty(t,e,r,n,i){this.good_length=t,this.max_lazy=e,this.nice_length=r,this.max_chain=n,this.func=i}const Oy=[new Ty(0,0,0,0,My),new Ty(4,4,8,4,Ry),new Ty(4,5,16,8,Ry),new Ty(4,6,32,32,Ry),new Ty(4,4,16,16,Py),new Ty(8,16,32,32,Py),new Ty(8,16,128,128,Py),new Ty(8,32,128,256,Py),new Ty(32,128,258,1024,Py),new Ty(32,258,258,4096,Py)];function Ly(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=ly,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),by(this.dyn_ltree),by(this.dyn_dtree),by(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),by(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),by(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const Uy=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.status!==py&&57!==e.status&&69!==e.status&&73!==e.status&&91!==e.status&&103!==e.status&&e.status!==yy&&e.status!==gy?1:0},Cy=t=>{if(Uy(t))return my(t,ey);t.total_in=t.total_out=0,t.data_type=hy;const e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=2===e.wrap?57:e.wrap?py:yy,t.adler=2===e.wrap?0:1,e.last_flush=-2,Fp(e),Qp},Ny=t=>{const e=Cy(t);return e===Qp&&(t=>{t.window_size=2*t.w_size,by(t.head),t.max_lazy_match=Oy[t.level].max_lazy,t.good_match=Oy[t.level].good_length,t.nice_match=Oy[t.level].nice_length,t.max_chain_length=Oy[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=2,t.match_available=0,t.ins_h=0})(t.state),e},zy=(t,e,r,n,i,o)=>{if(!t)return ey;let s=1;if(e===iy&&(e=6),n<0?(s=0,n=-n):n>15&&(s=2,n-=16),i<1||i>9||r!==ly||n<8||n>15||e<0||e>9||o<0||o>uy||8===n&&1!==s)return my(t,ey);8===n&&(n=9);const a=new Ly;return t.state=a,a.strm=t,a.status=py,a.wrap=s,a.gzhead=null,a.w_bits=n,a.w_size=1<<a.w_bits,a.w_mask=a.w_size-1,a.hash_bits=i+7,a.hash_size=1<<a.hash_bits,a.hash_mask=a.hash_size-1,a.hash_shift=~~((a.hash_bits+3-1)/3),a.window=new Uint8Array(2*a.w_size),a.head=new Uint16Array(a.hash_size),a.prev=new Uint16Array(a.w_size),a.lit_bufsize=1<<i+6,a.pending_buf_size=4*a.lit_bufsize,a.pending_buf=new Uint8Array(a.pending_buf_size),a.sym_buf=a.lit_bufsize,a.sym_end=3*(a.lit_bufsize-1),a.level=e,a.strategy=o,a.method=r,Ny(t)};var Dy=(t,e)=>{if(Uy(t)||e>Xp||e<0)return t?my(t,ey):ey;const r=t.state;if(!t.output||0!==t.avail_in&&!t.input||r.status===gy&&e!==Jp)return my(t,0===t.avail_out?ny:ey);const n=r.last_flush;if(r.last_flush=e,0!==r.pending){if(ky(t),0===t.avail_out)return r.last_flush=-1,Qp}else if(0===t.avail_in&&wy(e)<=wy(n)&&e!==Jp)return my(t,ny);if(r.status===gy&&0!==t.avail_in)return my(t,ny);if(r.status===py&&0===r.wrap&&(r.status=yy),r.status===py){let e=ly+(r.w_bits-8<<4)<<8,n=-1;if(n=r.strategy>=sy||r.level<2?0:r.level<6?1:6===r.level?2:3,e|=n<<6,0!==r.strstart&&(e|=32),e+=31-e%31,Sy(r,e),0!==r.strstart&&(Sy(r,t.adler>>>16),Sy(r,65535&t.adler)),t.adler=1,r.status=yy,ky(t),0!==r.pending)return r.last_flush=-1,Qp}if(57===r.status)if(t.adler=0,xy(r,31),xy(r,139),xy(r,8),r.gzhead)xy(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),xy(r,255&r.gzhead.time),xy(r,r.gzhead.time>>8&255),xy(r,r.gzhead.time>>16&255),xy(r,r.gzhead.time>>24&255),xy(r,9===r.level?2:r.strategy>=sy||r.level<2?4:0),xy(r,255&r.gzhead.os),r.gzhead.extra&&r.gzhead.extra.length&&(xy(r,255&r.gzhead.extra.length),xy(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(t.adler=jp(t.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=69;else if(xy(r,0),xy(r,0),xy(r,0),xy(r,0),xy(r,0),xy(r,9===r.level?2:r.strategy>=sy||r.level<2?4:0),xy(r,3),r.status=yy,ky(t),0!==r.pending)return r.last_flush=-1,Qp;if(69===r.status){if(r.gzhead.extra){let e=r.pending,n=(65535&r.gzhead.extra.length)-r.gzindex;for(;r.pending+n>r.pending_buf_size;){let i=r.pending_buf_size-r.pending;if(r.pending_buf.set(r.gzhead.extra.subarray(r.gzindex,r.gzindex+i),r.pending),r.pending=r.pending_buf_size,r.gzhead.hcrc&&r.pending>e&&(t.adler=jp(t.adler,r.pending_buf,r.pending-e,e)),r.gzindex+=i,ky(t),0!==r.pending)return r.last_flush=-1,Qp;e=0,n-=i}let i=new Uint8Array(r.gzhead.extra);r.pending_buf.set(i.subarray(r.gzindex,r.gzindex+n),r.pending),r.pending+=n,r.gzhead.hcrc&&r.pending>e&&(t.adler=jp(t.adler,r.pending_buf,r.pending-e,e)),r.gzindex=0}r.status=73}if(73===r.status){if(r.gzhead.name){let e,n=r.pending;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>n&&(t.adler=jp(t.adler,r.pending_buf,r.pending-n,n)),ky(t),0!==r.pending)return r.last_flush=-1,Qp;n=0}e=r.gzindex<r.gzhead.name.length?255&r.gzhead.name.charCodeAt(r.gzindex++):0,xy(r,e)}while(0!==e);r.gzhead.hcrc&&r.pending>n&&(t.adler=jp(t.adler,r.pending_buf,r.pending-n,n)),r.gzindex=0}r.status=91}if(91===r.status){if(r.gzhead.comment){let e,n=r.pending;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>n&&(t.adler=jp(t.adler,r.pending_buf,r.pending-n,n)),ky(t),0!==r.pending)return r.last_flush=-1,Qp;n=0}e=r.gzindex<r.gzhead.comment.length?255&r.gzhead.comment.charCodeAt(r.gzindex++):0,xy(r,e)}while(0!==e);r.gzhead.hcrc&&r.pending>n&&(t.adler=jp(t.adler,r.pending_buf,r.pending-n,n))}r.status=103}if(103===r.status){if(r.gzhead.hcrc){if(r.pending+2>r.pending_buf_size&&(ky(t),0!==r.pending))return r.last_flush=-1,Qp;xy(r,255&t.adler),xy(r,t.adler>>8&255),t.adler=0}if(r.status=yy,ky(t),0!==r.pending)return r.last_flush=-1,Qp}if(0!==t.avail_in||0!==r.lookahead||e!==Gp&&r.status!==gy){let n=0===r.level?My(r,e):r.strategy===sy?((t,e)=>{let r;for(;;){if(0===t.lookahead&&(By(t),0===t.lookahead)){if(e===Gp)return 1;break}if(t.match_length=0,r=Hp(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,r&&(Ey(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===Jp?(Ey(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(Ey(t,!1),0===t.strm.avail_out)?1:2})(r,e):r.strategy===ay?((t,e)=>{let r,n,i,o;const s=t.window;for(;;){if(t.lookahead<=fy){if(By(t),t.lookahead<=fy&&e===Gp)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(i=t.strstart-1,n=s[i],n===s[++i]&&n===s[++i]&&n===s[++i])){o=t.strstart+fy;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]&&i<o);t.match_length=fy-(o-i),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(r=Hp(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(r=Hp(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),r&&(Ey(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===Jp?(Ey(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(Ey(t,!1),0===t.strm.avail_out)?1:2})(r,e):Oy[r.level].func(r,e);if(3!==n&&4!==n||(r.status=gy),1===n||3===n)return 0===t.avail_out&&(r.last_flush=-1),Qp;if(2===n&&(e===Zp?$p(r):e!==Xp&&(qp(r,0,0,!1),e===Yp&&(by(r.head),0===r.lookahead&&(r.strstart=0,r.block_start=0,r.insert=0))),ky(t),0===t.avail_out))return r.last_flush=-1,Qp}return e!==Jp?Qp:r.wrap<=0?ty:(2===r.wrap?(xy(r,255&t.adler),xy(r,t.adler>>8&255),xy(r,t.adler>>16&255),xy(r,t.adler>>24&255),xy(r,255&t.total_in),xy(r,t.total_in>>8&255),xy(r,t.total_in>>16&255),xy(r,t.total_in>>24&255)):(Sy(r,t.adler>>>16),Sy(r,65535&t.adler)),ky(t),r.wrap>0&&(r.wrap=-r.wrap),0!==r.pending?Qp:ty)},jy=(t,e)=>{let r=e.length;if(Uy(t))return ey;const n=t.state,i=n.wrap;if(2===i||1===i&&n.status!==py||n.lookahead)return ey;if(1===i&&(t.adler=zp(t.adler,e,r,0)),n.wrap=0,r>=n.w_size){0===i&&(by(n.head),n.strstart=0,n.block_start=0,n.insert=0);let t=new Uint8Array(n.w_size);t.set(e.subarray(r-n.w_size,r),0),e=t,r=n.w_size}const o=t.avail_in,s=t.next_in,a=t.input;for(t.avail_in=r,t.next_in=0,t.input=e,By(n);n.lookahead>=3;){let t=n.strstart,e=n.lookahead-2;do{n.ins_h=_y(n,n.ins_h,n.window[t+3-1]),n.prev[t&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=t,t++}while(--e);n.strstart=t,n.lookahead=2,By(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,t.next_in=s,t.input=a,t.avail_in=o,n.wrap=i,Qp},Wy={deflateInit:(t,e)=>zy(t,e,ly,15,8,cy),deflateInit2:zy,deflateReset:Ny,deflateResetKeep:Cy,deflateSetHeader:(t,e)=>Uy(t)||2!==t.state.wrap?ey:(t.state.gzhead=e,Qp),deflate:Dy,deflateEnd:t=>{if(Uy(t))return ey;const e=t.state.status;return t.state=null,e===yy?my(t,ry):Qp},deflateSetDictionary:jy,deflateInfo:"pako deflate (from Nodeca project)"};const Ky=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var Fy={assign:function(t){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const r=e.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(const e in r)Ky(r,e)&&(t[e]=r[e])}}return t},flattenChunks:t=>{let e=0;for(let r=0,n=t.length;r<n;r++)e+=t[r].length;const r=new Uint8Array(e);for(let e=0,n=0,i=t.length;e<i;e++){let i=t[e];r.set(i,n),n+=i.length}return r}};let qy=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){qy=!1}const Vy=new Uint8Array(256);for(let t=0;t<256;t++)Vy[t]=t>=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;Vy[254]=Vy[254]=1;var Hy={string2buf:t=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);let e,r,n,i,o,s=t.length,a=0;for(i=0;i<s;i++)r=t.charCodeAt(i),55296==(64512&r)&&i+1<s&&(n=t.charCodeAt(i+1),56320==(64512&n)&&(r=65536+(r-55296<<10)+(n-56320),i++)),a+=r<128?1:r<2048?2:r<65536?3:4;for(e=new Uint8Array(a),o=0,i=0;o<a;i++)r=t.charCodeAt(i),55296==(64512&r)&&i+1<s&&(n=t.charCodeAt(i+1),56320==(64512&n)&&(r=65536+(r-55296<<10)+(n-56320),i++)),r<128?e[o++]=r:r<2048?(e[o++]=192|r>>>6,e[o++]=128|63&r):r<65536?(e[o++]=224|r>>>12,e[o++]=128|r>>>6&63,e[o++]=128|63&r):(e[o++]=240|r>>>18,e[o++]=128|r>>>12&63,e[o++]=128|r>>>6&63,e[o++]=128|63&r);return e},buf2string:(t,e)=>{const r=e||t.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(t.subarray(0,e));let n,i;const o=new Array(2*r);for(i=0,n=0;n<r;){let e=t[n++];if(e<128){o[i++]=e;continue}let s=Vy[e];if(s>4)o[i++]=65533,n+=s-1;else{for(e&=2===s?31:3===s?15:7;s>1&&n<r;)e=e<<6|63&t[n++],s--;s>1?o[i++]=65533:e<65536?o[i++]=e:(e-=65536,o[i++]=55296|e>>10&1023,o[i++]=56320|1023&e)}}return((t,e)=>{if(e<65534&&t.subarray&&qy)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let r="";for(let n=0;n<e;n++)r+=String.fromCharCode(t[n]);return r})(o,i)},utf8border:(t,e)=>{(e=e||t.length)>t.length&&(e=t.length);let r=e-1;for(;r>=0&&128==(192&t[r]);)r--;return r<0||0===r?e:r+Vy[t[r]]>e?r:e}};var $y=function(){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};const Gy=Object.prototype.toString,{Z_NO_FLUSH:Zy,Z_SYNC_FLUSH:Yy,Z_FULL_FLUSH:Jy,Z_FINISH:Xy,Z_OK:Qy,Z_STREAM_END:tg,Z_DEFAULT_COMPRESSION:eg,Z_DEFAULT_STRATEGY:rg,Z_DEFLATED:ng}=Kp;function ig(t){this.options=Fy.assign({level:eg,method:ng,chunkSize:16384,windowBits:15,memLevel:8,strategy:rg},t||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new $y,this.strm.avail_out=0;let r=Wy.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(r!==Qy)throw new Error(Wp[r]);if(e.header&&Wy.deflateSetHeader(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?Hy.string2buf(e.dictionary):"[object ArrayBuffer]"===Gy.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,r=Wy.deflateSetDictionary(this.strm,t),r!==Qy)throw new Error(Wp[r]);this._dict_set=!0}}ig.prototype.push=function(t,e){const r=this.strm,n=this.options.chunkSize;let i,o;if(this.ended)return!1;for(o=e===~~e?e:!0===e?Xy:Zy,"string"==typeof t?r.input=Hy.string2buf(t):"[object ArrayBuffer]"===Gy.call(t)?r.input=new Uint8Array(t):r.input=t,r.next_in=0,r.avail_in=r.input.length;;)if(0===r.avail_out&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),(o===Yy||o===Jy)&&r.avail_out<=6)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else{if(i=Wy.deflate(r,o),i===tg)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),i=Wy.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===Qy;if(0!==r.avail_out){if(o>0&&r.next_out>0)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else if(0===r.avail_in)break}else this.onData(r.output)}return!0},ig.prototype.onData=function(t){this.chunks.push(t)},ig.prototype.onEnd=function(t){t===Qy&&(this.result=Fy.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};const og=16209;var sg=function(t,e){let r,n,i,o,s,a,u,c,h,l,f,d,p,y,g,m,w,b,v,_,k,E,x,S;const A=t.state;r=t.next_in,x=t.input,n=r+(t.avail_in-5),i=t.next_out,S=t.output,o=i-(e-t.avail_out),s=i+(t.avail_out-257),a=A.dmax,u=A.wsize,c=A.whave,h=A.wnext,l=A.window,f=A.hold,d=A.bits,p=A.lencode,y=A.distcode,g=(1<<A.lenbits)-1,m=(1<<A.distbits)-1;t:do{d<15&&(f+=x[r++]<<d,d+=8,f+=x[r++]<<d,d+=8),w=p[f&g];e:for(;;){if(b=w>>>24,f>>>=b,d-=b,b=w>>>16&255,0===b)S[i++]=65535&w;else{if(!(16&b)){if(0==(64&b)){w=p[(65535&w)+(f&(1<<b)-1)];continue e}if(32&b){A.mode=16191;break t}t.msg="invalid literal/length code",A.mode=og;break t}v=65535&w,b&=15,b&&(d<b&&(f+=x[r++]<<d,d+=8),v+=f&(1<<b)-1,f>>>=b,d-=b),d<15&&(f+=x[r++]<<d,d+=8,f+=x[r++]<<d,d+=8),w=y[f&m];r:for(;;){if(b=w>>>24,f>>>=b,d-=b,b=w>>>16&255,!(16&b)){if(0==(64&b)){w=y[(65535&w)+(f&(1<<b)-1)];continue r}t.msg="invalid distance code",A.mode=og;break t}if(_=65535&w,b&=15,d<b&&(f+=x[r++]<<d,d+=8,d<b&&(f+=x[r++]<<d,d+=8)),_+=f&(1<<b)-1,_>a){t.msg="invalid distance too far back",A.mode=og;break t}if(f>>>=b,d-=b,b=i-o,_>b){if(b=_-b,b>c&&A.sane){t.msg="invalid distance too far back",A.mode=og;break t}if(k=0,E=l,0===h){if(k+=u-b,b<v){v-=b;do{S[i++]=l[k++]}while(--b);k=i-_,E=S}}else if(h<b){if(k+=u+h-b,b-=h,b<v){v-=b;do{S[i++]=l[k++]}while(--b);if(k=0,h<v){b=h,v-=b;do{S[i++]=l[k++]}while(--b);k=i-_,E=S}}}else if(k+=h-b,b<v){v-=b;do{S[i++]=l[k++]}while(--b);k=i-_,E=S}for(;v>2;)S[i++]=E[k++],S[i++]=E[k++],S[i++]=E[k++],v-=3;v&&(S[i++]=E[k++],v>1&&(S[i++]=E[k++]))}else{k=i-_;do{S[i++]=S[k++],S[i++]=S[k++],S[i++]=S[k++],v-=3}while(v>2);v&&(S[i++]=S[k++],v>1&&(S[i++]=S[k++]))}break}}break}}while(r<n&&i<s);v=d>>3,r-=v,d-=v<<3,f&=(1<<d)-1,t.next_in=r,t.next_out=i,t.avail_in=r<n?n-r+5:5-(r-n),t.avail_out=i<s?s-i+257:257-(i-s),A.hold=f,A.bits=d};const ag=15,ug=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),cg=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),hg=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),lg=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var fg=(t,e,r,n,i,o,s,a)=>{const u=a.bits;let c,h,l,f,d,p,y=0,g=0,m=0,w=0,b=0,v=0,_=0,k=0,E=0,x=0,S=null;const A=new Uint16Array(16),I=new Uint16Array(16);let B,M,R,P=null;for(y=0;y<=ag;y++)A[y]=0;for(g=0;g<n;g++)A[e[r+g]]++;for(b=u,w=ag;w>=1&&0===A[w];w--);if(b>w&&(b=w),0===w)return i[o++]=20971520,i[o++]=20971520,a.bits=1,0;for(m=1;m<w&&0===A[m];m++);for(b<m&&(b=m),k=1,y=1;y<=ag;y++)if(k<<=1,k-=A[y],k<0)return-1;if(k>0&&(0===t||1!==w))return-1;for(I[1]=0,y=1;y<ag;y++)I[y+1]=I[y]+A[y];for(g=0;g<n;g++)0!==e[r+g]&&(s[I[e[r+g]]++]=g);if(0===t?(S=P=s,p=20):1===t?(S=ug,P=cg,p=257):(S=hg,P=lg,p=0),x=0,g=0,y=m,d=o,v=b,_=0,l=-1,E=1<<b,f=E-1,1===t&&E>852||2===t&&E>592)return 1;for(;;){B=y-_,s[g]+1<p?(M=0,R=s[g]):s[g]>=p?(M=P[s[g]-p],R=S[s[g]-p]):(M=96,R=0),c=1<<y-_,h=1<<v,m=h;do{h-=c,i[d+(x>>_)+h]=B<<24|M<<16|R|0}while(0!==h);for(c=1<<y-1;x&c;)c>>=1;if(0!==c?(x&=c-1,x+=c):x=0,g++,0==--A[y]){if(y===w)break;y=e[r+s[g]]}if(y>b&&(x&f)!==l){for(0===_&&(_=b),d+=m,v=y-_,k=1<<v;v+_<w&&(k-=A[v+_],!(k<=0));)v++,k<<=1;if(E+=1<<v,1===t&&E>852||2===t&&E>592)return 1;l=x&f,i[l]=b<<24|v<<16|d-o|0}}return 0!==x&&(i[d+x]=y-_<<24|64<<16|0),a.bits=b,0};const{Z_FINISH:dg,Z_BLOCK:pg,Z_TREES:yg,Z_OK:gg,Z_STREAM_END:mg,Z_NEED_DICT:wg,Z_STREAM_ERROR:bg,Z_DATA_ERROR:vg,Z_MEM_ERROR:_g,Z_BUF_ERROR:kg,Z_DEFLATED:Eg}=Kp,xg=16180,Sg=16190,Ag=16191,Ig=16192,Bg=16194,Mg=16199,Rg=16200,Pg=16206,Tg=16209,Og=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function Lg(){this.strm=null,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 Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Ug=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.mode<xg||e.mode>16211?1:0},Cg=t=>{if(Ug(t))return bg;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=xg,e.last=0,e.havedict=0,e.flags=-1,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,gg},Ng=t=>{if(Ug(t))return bg;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,Cg(t)},zg=(t,e)=>{let r;if(Ug(t))return bg;const n=t.state;return e<0?(r=0,e=-e):(r=5+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?bg:(null!==n.window&&n.wbits!==e&&(n.window=null),n.wrap=r,n.wbits=e,Ng(t))},Dg=(t,e)=>{if(!t)return bg;const r=new Lg;t.state=r,r.strm=t,r.window=null,r.mode=xg;const n=zg(t,e);return n!==gg&&(t.state=null),n};let jg,Wg,Kg=!0;const Fg=t=>{if(Kg){jg=new Int32Array(512),Wg=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(fg(1,t.lens,0,288,jg,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;fg(2,t.lens,0,32,Wg,0,t.work,{bits:5}),Kg=!1}t.lencode=jg,t.lenbits=9,t.distcode=Wg,t.distbits=5},qg=(t,e,r,n)=>{let i;const o=t.state;return null===o.window&&(o.wsize=1<<o.wbits,o.wnext=0,o.whave=0,o.window=new Uint8Array(o.wsize)),n>=o.wsize?(o.window.set(e.subarray(r-o.wsize,r),0),o.wnext=0,o.whave=o.wsize):(i=o.wsize-o.wnext,i>n&&(i=n),o.window.set(e.subarray(r-n,r-n+i),o.wnext),(n-=i)?(o.window.set(e.subarray(r-n,r),0),o.wnext=n,o.whave=o.wsize):(o.wnext+=i,o.wnext===o.wsize&&(o.wnext=0),o.whave<o.wsize&&(o.whave+=i))),0};var Vg=(t,e)=>{let r,n,i,o,s,a,u,c,h,l,f,d,p,y,g,m,w,b,v,_,k,E,x=0;const S=new Uint8Array(4);let A,I;const B=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Ug(t)||!t.output||!t.input&&0!==t.avail_in)return bg;r=t.state,r.mode===Ag&&(r.mode=Ig),s=t.next_out,i=t.output,u=t.avail_out,o=t.next_in,n=t.input,a=t.avail_in,c=r.hold,h=r.bits,l=a,f=u,E=gg;t:for(;;)switch(r.mode){case xg:if(0===r.wrap){r.mode=Ig;break}for(;h<16;){if(0===a)break t;a--,c+=n[o++]<<h,h+=8}if(2&r.wrap&&35615===c){0===r.wbits&&(r.wbits=15),r.check=0,S[0]=255&c,S[1]=c>>>8&255,r.check=jp(r.check,S,2,0),c=0,h=0,r.mode=16181;break}if(r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&c)<<8)+(c>>8))%31){t.msg="incorrect header check",r.mode=Tg;break}if((15&c)!==Eg){t.msg="unknown compression method",r.mode=Tg;break}if(c>>>=4,h-=4,k=8+(15&c),0===r.wbits&&(r.wbits=k),k>15||k>r.wbits){t.msg="invalid window size",r.mode=Tg;break}r.dmax=1<<r.wbits,r.flags=0,t.adler=r.check=1,r.mode=512&c?16189:Ag,c=0,h=0;break;case 16181:for(;h<16;){if(0===a)break t;a--,c+=n[o++]<<h,h+=8}if(r.flags=c,(255&r.flags)!==Eg){t.msg="unknown compression method",r.mode=Tg;break}if(57344&r.flags){t.msg="unknown header flags set",r.mode=Tg;break}r.head&&(r.head.text=c>>8&1),512&r.flags&&4&r.wrap&&(S[0]=255&c,S[1]=c>>>8&255,r.check=jp(r.check,S,2,0)),c=0,h=0,r.mode=16182;case 16182:for(;h<32;){if(0===a)break t;a--,c+=n[o++]<<h,h+=8}r.head&&(r.head.time=c),512&r.flags&&4&r.wrap&&(S[0]=255&c,S[1]=c>>>8&255,S[2]=c>>>16&255,S[3]=c>>>24&255,r.check=jp(r.check,S,4,0)),c=0,h=0,r.mode=16183;case 16183:for(;h<16;){if(0===a)break t;a--,c+=n[o++]<<h,h+=8}r.head&&(r.head.xflags=255&c,r.head.os=c>>8),512&r.flags&&4&r.wrap&&(S[0]=255&c,S[1]=c>>>8&255,r.check=jp(r.check,S,2,0)),c=0,h=0,r.mode=16184;case 16184:if(1024&r.flags){for(;h<16;){if(0===a)break t;a--,c+=n[o++]<<h,h+=8}r.length=c,r.head&&(r.head.extra_len=c),512&r.flags&&4&r.wrap&&(S[0]=255&c,S[1]=c>>>8&255,r.check=jp(r.check,S,2,0)),c=0,h=0}else r.head&&(r.head.extra=null);r.mode=16185;case 16185:if(1024&r.flags&&(d=r.length,d>a&&(d=a),d&&(r.head&&(k=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(n.subarray(o,o+d),k)),512&r.flags&&4&r.wrap&&(r.check=jp(r.check,n,d,o)),a-=d,o+=d,r.length-=d),r.length))break t;r.length=0,r.mode=16186;case 16186:if(2048&r.flags){if(0===a)break t;d=0;do{k=n[o+d++],r.head&&k&&r.length<65536&&(r.head.name+=String.fromCharCode(k))}while(k&&d<a);if(512&r.flags&&4&r.wrap&&(r.check=jp(r.check,n,d,o)),a-=d,o+=d,k)break t}else r.head&&(r.head.name=null);r.length=0,r.mode=16187;case 16187:if(4096&r.flags){if(0===a)break t;d=0;do{k=n[o+d++],r.head&&k&&r.length<65536&&(r.head.comment+=String.fromCharCode(k))}while(k&&d<a);if(512&r.flags&&4&r.wrap&&(r.check=jp(r.check,n,d,o)),a-=d,o+=d,k)break t}else r.head&&(r.head.comment=null);r.mode=16188;case 16188:if(512&r.flags){for(;h<16;){if(0===a)break t;a--,c+=n[o++]<<h,h+=8}if(4&r.wrap&&c!==(65535&r.check)){t.msg="header crc mismatch",r.mode=Tg;break}c=0,h=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),t.adler=r.check=0,r.mode=Ag;break;case 16189:for(;h<32;){if(0===a)break t;a--,c+=n[o++]<<h,h+=8}t.adler=r.check=Og(c),c=0,h=0,r.mode=Sg;case Sg:if(0===r.havedict)return t.next_out=s,t.avail_out=u,t.next_in=o,t.avail_in=a,r.hold=c,r.bits=h,wg;t.adler=r.check=1,r.mode=Ag;case Ag:if(e===pg||e===yg)break t;case Ig:if(r.last){c>>>=7&h,h-=7&h,r.mode=Pg;break}for(;h<3;){if(0===a)break t;a--,c+=n[o++]<<h,h+=8}switch(r.last=1&c,c>>>=1,h-=1,3&c){case 0:r.mode=16193;break;case 1:if(Fg(r),r.mode=Mg,e===yg){c>>>=2,h-=2;break t}break;case 2:r.mode=16196;break;case 3:t.msg="invalid block type",r.mode=Tg}c>>>=2,h-=2;break;case 16193:for(c>>>=7&h,h-=7&h;h<32;){if(0===a)break t;a--,c+=n[o++]<<h,h+=8}if((65535&c)!=(c>>>16^65535)){t.msg="invalid stored block lengths",r.mode=Tg;break}if(r.length=65535&c,c=0,h=0,r.mode=Bg,e===yg)break t;case Bg:r.mode=16195;case 16195:if(d=r.length,d){if(d>a&&(d=a),d>u&&(d=u),0===d)break t;i.set(n.subarray(o,o+d),s),a-=d,o+=d,u-=d,s+=d,r.length-=d;break}r.mode=Ag;break;case 16196:for(;h<14;){if(0===a)break t;a--,c+=n[o++]<<h,h+=8}if(r.nlen=257+(31&c),c>>>=5,h-=5,r.ndist=1+(31&c),c>>>=5,h-=5,r.ncode=4+(15&c),c>>>=4,h-=4,r.nlen>286||r.ndist>30){t.msg="too many length or distance symbols",r.mode=Tg;break}r.have=0,r.mode=16197;case 16197:for(;r.have<r.ncode;){for(;h<3;){if(0===a)break t;a--,c+=n[o++]<<h,h+=8}r.lens[B[r.have++]]=7&c,c>>>=3,h-=3}for(;r.have<19;)r.lens[B[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,A={bits:r.lenbits},E=fg(0,r.lens,0,19,r.lencode,0,r.work,A),r.lenbits=A.bits,E){t.msg="invalid code lengths set",r.mode=Tg;break}r.have=0,r.mode=16198;case 16198:for(;r.have<r.nlen+r.ndist;){for(;x=r.lencode[c&(1<<r.lenbits)-1],g=x>>>24,m=x>>>16&255,w=65535&x,!(g<=h);){if(0===a)break t;a--,c+=n[o++]<<h,h+=8}if(w<16)c>>>=g,h-=g,r.lens[r.have++]=w;else{if(16===w){for(I=g+2;h<I;){if(0===a)break t;a--,c+=n[o++]<<h,h+=8}if(c>>>=g,h-=g,0===r.have){t.msg="invalid bit length repeat",r.mode=Tg;break}k=r.lens[r.have-1],d=3+(3&c),c>>>=2,h-=2}else if(17===w){for(I=g+3;h<I;){if(0===a)break t;a--,c+=n[o++]<<h,h+=8}c>>>=g,h-=g,k=0,d=3+(7&c),c>>>=3,h-=3}else{for(I=g+7;h<I;){if(0===a)break t;a--,c+=n[o++]<<h,h+=8}c>>>=g,h-=g,k=0,d=11+(127&c),c>>>=7,h-=7}if(r.have+d>r.nlen+r.ndist){t.msg="invalid bit length repeat",r.mode=Tg;break}for(;d--;)r.lens[r.have++]=k}}if(r.mode===Tg)break;if(0===r.lens[256]){t.msg="invalid code -- missing end-of-block",r.mode=Tg;break}if(r.lenbits=9,A={bits:r.lenbits},E=fg(1,r.lens,0,r.nlen,r.lencode,0,r.work,A),r.lenbits=A.bits,E){t.msg="invalid literal/lengths set",r.mode=Tg;break}if(r.distbits=6,r.distcode=r.distdyn,A={bits:r.distbits},E=fg(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,A),r.distbits=A.bits,E){t.msg="invalid distances set",r.mode=Tg;break}if(r.mode=Mg,e===yg)break t;case Mg:r.mode=Rg;case Rg:if(a>=6&&u>=258){t.next_out=s,t.avail_out=u,t.next_in=o,t.avail_in=a,r.hold=c,r.bits=h,sg(t,f),s=t.next_out,i=t.output,u=t.avail_out,o=t.next_in,n=t.input,a=t.avail_in,c=r.hold,h=r.bits,r.mode===Ag&&(r.back=-1);break}for(r.back=0;x=r.lencode[c&(1<<r.lenbits)-1],g=x>>>24,m=x>>>16&255,w=65535&x,!(g<=h);){if(0===a)break t;a--,c+=n[o++]<<h,h+=8}if(m&&0==(240&m)){for(b=g,v=m,_=w;x=r.lencode[_+((c&(1<<b+v)-1)>>b)],g=x>>>24,m=x>>>16&255,w=65535&x,!(b+g<=h);){if(0===a)break t;a--,c+=n[o++]<<h,h+=8}c>>>=b,h-=b,r.back+=b}if(c>>>=g,h-=g,r.back+=g,r.length=w,0===m){r.mode=16205;break}if(32&m){r.back=-1,r.mode=Ag;break}if(64&m){t.msg="invalid literal/length code",r.mode=Tg;break}r.extra=15&m,r.mode=16201;case 16201:if(r.extra){for(I=r.extra;h<I;){if(0===a)break t;a--,c+=n[o++]<<h,h+=8}r.length+=c&(1<<r.extra)-1,c>>>=r.extra,h-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=16202;case 16202:for(;x=r.distcode[c&(1<<r.distbits)-1],g=x>>>24,m=x>>>16&255,w=65535&x,!(g<=h);){if(0===a)break t;a--,c+=n[o++]<<h,h+=8}if(0==(240&m)){for(b=g,v=m,_=w;x=r.distcode[_+((c&(1<<b+v)-1)>>b)],g=x>>>24,m=x>>>16&255,w=65535&x,!(b+g<=h);){if(0===a)break t;a--,c+=n[o++]<<h,h+=8}c>>>=b,h-=b,r.back+=b}if(c>>>=g,h-=g,r.back+=g,64&m){t.msg="invalid distance code",r.mode=Tg;break}r.offset=w,r.extra=15&m,r.mode=16203;case 16203:if(r.extra){for(I=r.extra;h<I;){if(0===a)break t;a--,c+=n[o++]<<h,h+=8}r.offset+=c&(1<<r.extra)-1,c>>>=r.extra,h-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){t.msg="invalid distance too far back",r.mode=Tg;break}r.mode=16204;case 16204:if(0===u)break t;if(d=f-u,r.offset>d){if(d=r.offset-d,d>r.whave&&r.sane){t.msg="invalid distance too far back",r.mode=Tg;break}d>r.wnext?(d-=r.wnext,p=r.wsize-d):p=r.wnext-d,d>r.length&&(d=r.length),y=r.window}else y=i,p=s-r.offset,d=r.length;d>u&&(d=u),u-=d,r.length-=d;do{i[s++]=y[p++]}while(--d);0===r.length&&(r.mode=Rg);break;case 16205:if(0===u)break t;i[s++]=r.length,u--,r.mode=Rg;break;case Pg:if(r.wrap){for(;h<32;){if(0===a)break t;a--,c|=n[o++]<<h,h+=8}if(f-=u,t.total_out+=f,r.total+=f,4&r.wrap&&f&&(t.adler=r.check=r.flags?jp(r.check,i,f,s-f):zp(r.check,i,f,s-f)),f=u,4&r.wrap&&(r.flags?c:Og(c))!==r.check){t.msg="incorrect data check",r.mode=Tg;break}c=0,h=0}r.mode=16207;case 16207:if(r.wrap&&r.flags){for(;h<32;){if(0===a)break t;a--,c+=n[o++]<<h,h+=8}if(4&r.wrap&&c!==(4294967295&r.total)){t.msg="incorrect length check",r.mode=Tg;break}c=0,h=0}r.mode=16208;case 16208:E=mg;break t;case Tg:E=vg;break t;case 16210:return _g;default:return bg}return t.next_out=s,t.avail_out=u,t.next_in=o,t.avail_in=a,r.hold=c,r.bits=h,(r.wsize||f!==t.avail_out&&r.mode<Tg&&(r.mode<Pg||e!==dg))&&qg(t,t.output,t.next_out,f-t.avail_out),l-=t.avail_in,f-=t.avail_out,t.total_in+=l,t.total_out+=f,r.total+=f,4&r.wrap&&f&&(t.adler=r.check=r.flags?jp(r.check,i,f,t.next_out-f):zp(r.check,i,f,t.next_out-f)),t.data_type=r.bits+(r.last?64:0)+(r.mode===Ag?128:0)+(r.mode===Mg||r.mode===Bg?256:0),(0===l&&0===f||e===dg)&&E===gg&&(E=kg),E},Hg=t=>{if(Ug(t))return bg;let e=t.state;return e.window&&(e.window=null),t.state=null,gg},$g=(t,e)=>{if(Ug(t))return bg;const r=t.state;return 0==(2&r.wrap)?bg:(r.head=e,e.done=!1,gg)},Gg=(t,e)=>{const r=e.length;let n,i,o;return Ug(t)?bg:(n=t.state,0!==n.wrap&&n.mode!==Sg?bg:n.mode===Sg&&(i=1,i=zp(i,e,r,0),i!==n.check)?vg:(o=qg(t,e,r,r),o?(n.mode=16210,_g):(n.havedict=1,gg)))},Zg={inflateReset:Ng,inflateReset2:zg,inflateResetKeep:Cg,inflateInit:t=>Dg(t,15),inflateInit2:Dg,inflate:Vg,inflateEnd:Hg,inflateGetHeader:$g,inflateSetDictionary:Gg,inflateInfo:"pako inflate (from Nodeca project)"};var Yg=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const Jg=Object.prototype.toString,{Z_NO_FLUSH:Xg,Z_FINISH:Qg,Z_OK:tm,Z_STREAM_END:em,Z_NEED_DICT:rm,Z_STREAM_ERROR:nm,Z_DATA_ERROR:im,Z_MEM_ERROR:om}=Kp;function sm(t){this.options=Fy.assign({chunkSize:65536,windowBits:15,to:""},t||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new $y,this.strm.avail_out=0;let r=Zg.inflateInit2(this.strm,e.windowBits);if(r!==tm)throw new Error(Wp[r]);if(this.header=new Yg,Zg.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=Hy.string2buf(e.dictionary):"[object ArrayBuffer]"===Jg.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(r=Zg.inflateSetDictionary(this.strm,e.dictionary),r!==tm)))throw new Error(Wp[r])}function am(t,e){const r=new sm(e);if(r.push(t),r.err)throw r.msg||Wp[r.err];return r.result}sm.prototype.push=function(t,e){const r=this.strm,n=this.options.chunkSize,i=this.options.dictionary;let o,s,a;if(this.ended)return!1;for(s=e===~~e?e:!0===e?Qg:Xg,"[object ArrayBuffer]"===Jg.call(t)?r.input=new Uint8Array(t):r.input=t,r.next_in=0,r.avail_in=r.input.length;;){for(0===r.avail_out&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),o=Zg.inflate(r,s),o===rm&&i&&(o=Zg.inflateSetDictionary(r,i),o===tm?o=Zg.inflate(r,s):o===im&&(o=rm));r.avail_in>0&&o===em&&r.state.wrap>0&&0!==t[r.next_in];)Zg.inflateReset(r),o=Zg.inflate(r,s);switch(o){case nm:case im:case rm:case om:return this.onEnd(o),this.ended=!0,!1}if(a=r.avail_out,r.next_out&&(0===r.avail_out||o===em))if("string"===this.options.to){let t=Hy.utf8border(r.output,r.next_out),e=r.next_out-t,i=Hy.buf2string(r.output,t);r.next_out=e,r.avail_out=n-e,e&&r.output.set(r.output.subarray(t,t+e),0),this.onData(i)}else this.onData(r.output.length===r.next_out?r.output:r.output.subarray(0,r.next_out));if(o!==tm||0!==a){if(o===em)return o=Zg.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,!0;if(0===r.avail_in)break}}return!0},sm.prototype.onData=function(t){this.chunks.push(t)},sm.prototype.onEnd=function(t){t===tm&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Fy.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var um={Inflate:sm,inflate:am,inflateRaw:function(t,e){return(e=e||{}).raw=!0,am(t,e)},ungzip:am,constants:Kp};const{Inflate:cm,inflate:hm,inflateRaw:lm,ungzip:fm}=um;var dm=hm,pm=e(qi());const ym=t=>"version"in t;var gm=Object.freeze({__proto__:null,encode:function(t){return t.reduce(((t,e)=>t+e.toString(16).padStart(2,"0")),"0x")},decode:function(t){0===t.indexOf("0x")&&(t=t.substr(2)),t.length%2==1&&(t="0"+t);let e=t.match(/.{2}/g);return null===e?n.Buffer.from([]):n.Buffer.from(e.map((t=>parseInt(t,16))))}});function mm(t){return new TextDecoder("utf-8").decode(t)}function wm(t){return(new TextEncoder).encode(t)}var bm=Object.freeze({__proto__:null,decode:mm,encode:wm});function vm(t){return ld.encode(t)}var _m=Object.freeze({__proto__:null,encode:vm,decode:function(t){return ld.decode(t)}});function km(t){return n.Buffer.from(o(t))}var Em=Object.freeze({__proto__:null,encode:function(t){return s(t)},decode:km}),xm=Object.freeze({__proto__:null,hex:gm,utf8:bm,bs58:_m,base64:Em});function Sm(t){const e=new Map;return t.errors&&t.errors.forEach((t=>{var r;let n=null!==(r=t.msg)&&void 0!==r?r:t.name;e.set(t.code,n)})),e}function Am(t,...e){if(t.args.length!=e.length)throw new Error("Invalid argument length");const r={};let n=0;return t.args.forEach((t=>{r[t.name]=e[n],n+=1})),r}function Im(t,e={}){t.forEach((t=>{if("accounts"in t)Im(t.accounts,e[t.name]);else if(void 0===e[t.name])throw new Error(`Invalid arguments: ${t.name} not provided.`)}))}function Bm(t){return t instanceof Wo?t:new Wo(t)}class Mm extends TypeError{constructor(t,e){let r;const{message:n,...i}=t,{path:o}=t;super(0===o.length?n:"At path: "+o.join(".")+" -- "+n),this.value=void 0,this.key=void 0,this.type=void 0,this.refinement=void 0,this.path=void 0,this.branch=void 0,this.failures=void 0,Object.assign(this,i),this.name=this.constructor.name,this.failures=()=>{var n;return null!=(n=r)?n:r=[t,...e()]}}}function Rm(t){return"object"==typeof t&&null!=t}function Pm(t){return"string"==typeof t?JSON.stringify(t):""+t}function Tm(t,e,r,n){if(!0===t)return;!1===t?t={}:"string"==typeof t&&(t={message:t});const{path:i,branch:o}=e,{type:s}=r,{refinement:a,message:u="Expected a value of type `"+s+"`"+(a?" with refinement `"+a+"`":"")+", but received: `"+Pm(n)+"`"}=t;return{value:n,type:s,refinement:a,key:i[i.length-1],path:i,branch:o,...t,message:u}}function*Om(t,e,r,n){(function(t){return Rm(t)&&"function"==typeof t[Symbol.iterator]})(t)||(t=[t]);for(const i of t){const t=Tm(i,e,r,n);t&&(yield t)}}function*Lm(t,e,r){void 0===r&&(r={});const{path:n=[],branch:i=[t],coerce:o=!1,mask:s=!1}=r,a={path:n,branch:i};if(o&&(t=e.coercer(t,a),s&&"type"!==e.type&&Rm(e.schema)&&Rm(t)&&!Array.isArray(t)))for(const r in t)void 0===e.schema[r]&&delete t[r];let u=!0;for(const r of e.validator(t,a))u=!1,yield[r,void 0];for(let[r,c,h]of e.entries(t,a)){const e=Lm(c,h,{path:void 0===r?n:[...n,r],branch:void 0===r?i:[...i,c],coerce:o,mask:s});for(const n of e)n[0]?(u=!1,yield[n[0],void 0]):o&&(c=n[1],void 0===r?t=c:t instanceof Map?t.set(r,c):t instanceof Set?t.add(c):Rm(t)&&(t[r]=c))}if(u)for(const r of e.refiner(t,a))u=!1,yield[r,void 0];u&&(yield[void 0,t])}class Um{constructor(t){this.TYPE=void 0,this.type=void 0,this.schema=void 0,this.coercer=void 0,this.validator=void 0,this.refiner=void 0,this.entries=void 0;const{type:e,schema:r,validator:n,refiner:i,coercer:o=(t=>t),entries:s=function*(){}}=t;this.type=e,this.schema=r,this.entries=s,this.coercer=o,this.validator=n?(t,e)=>Om(n(t,e),e,this,t):()=>[],this.refiner=i?(t,e)=>Om(i(t,e),e,this,t):()=>[]}assert(t){return function(t,e){const r=zm(t,e);if(r[0])throw r[0]}(t,this)}create(t){return Cm(t,this)}is(t){return Nm(t,this)}mask(t){return function(t,e){const r=zm(t,e,{coerce:!0,mask:!0});if(r[0])throw r[0];return r[1]}(t,this)}validate(t,e){return void 0===e&&(e={}),zm(t,this,e)}}function Cm(t,e){const r=zm(t,e,{coerce:!0});if(r[0])throw r[0];return r[1]}function Nm(t,e){return!zm(t,e)[0]}function zm(t,e,r){void 0===r&&(r={});const n=Lm(t,e,r),i=function(t){const{done:e,value:r}=t.next();return e?void 0:r}(n);if(i[0]){const t=new Mm(i[0],(function*(){for(const t of n)t[0]&&(yield t[0])}));return[t,void 0]}return[void 0,i[1]]}function Dm(t,e){return new Um({type:t,schema:null,validator:e})}function jm(t){return new Um({type:"array",schema:t,*entries(e){if(t&&Array.isArray(e))for(const[r,n]of e.entries())yield[r,n,t]},coercer:t=>Array.isArray(t)?t.slice():t,validator:t=>Array.isArray(t)||"Expected an array value, but received: "+Pm(t)})}function Wm(t){const e=Pm(t),r=typeof t;return new Um({type:"literal",schema:"string"===r||"number"===r||"boolean"===r?t:null,validator:r=>r===t||"Expected the literal `"+e+"`, but received: "+Pm(r)})}function Km(t){return new Um({...t,validator:(e,r)=>null===e||t.validator(e,r),refiner:(e,r)=>null===e||t.refiner(e,r)})}function Fm(){return Dm("number",(t=>"number"==typeof t&&!isNaN(t)||"Expected a number, but received: "+Pm(t)))}function qm(t){return new Um({...t,validator:(e,r)=>void 0===e||t.validator(e,r),refiner:(e,r)=>void 0===e||t.refiner(e,r)})}function Vm(){return Dm("string",(t=>"string"==typeof t||"Expected a string, but received: "+Pm(t)))}function Hm(t){const e=Object.keys(t);return new Um({type:"type",schema:t,*entries(r){if(Rm(r))for(const n of e)yield[n,r[n],t[n]]},validator:t=>Rm(t)||"Expected an object, but received: "+Pm(t)})}function $m(t){const e=t.map((t=>t.type)).join(" | ");return new Um({type:"union",schema:null,coercer(e,r){const n=t.find((t=>{const[r]=t.validate(e,{coerce:!0});return!r}))||Gm();return n.coercer(e,r)},validator(r,n){const i=[];for(const e of t){const[...t]=Lm(r,e,n),[o]=t;if(!o[0])return[];for(const[e]of t)e&&i.push(e)}return["Expected the value to satisfy a union of `"+e+"`, but received: "+Pm(r),...i]}})}function Gm(){return Dm("unknown",(()=>!0))}const Zm=99;async function Ym(t,e,r){if(e.length<=Zm)return await Jm(t,e,r);{const n=function(t,e){return Array.apply(0,new Array(Math.ceil(t.length/e))).map(((r,n)=>t.slice(n*e,(n+1)*e)))}(e,Zm);return(await Promise.all(n.map((e=>Jm(t,e,r))))).flat()}}async function Jm(t,e,r){const n=null!=r?r:t.commitment,{value:i,context:o}=await t.getMultipleAccountsInfoAndContext(e,n);return i.map(((t,r)=>null===t?null:{publicKey:e[r],account:t,context:o}))}async function Xm(t,e,r,n,i){var o;r&&r.length>0&&e.sign(...r);const s=e._compile(),a=s.serialize(),u=e._serialize(a).toString("base64"),c={encoding:"base64",commitment:null!=n?n:t.commitment};if(i){const t=(Array.isArray(i)?i:s.nonProgramIds()).map((t=>t.toBase58()));c.accounts={encoding:"base64",addresses:t}}r&&(c.sigVerify=!0);const h=[u,c],l=Cm(await t._rpcRequest("simulateTransaction",h),rw);if("error"in l){let t;if("data"in l.error&&(t=null===(o=l.error.data)||void 0===o?void 0:o.logs,t&&Array.isArray(t))){const e="\n ",r=e+t.join(e);console.error(l.error.message,r)}throw new Fs("failed to simulate transaction: "+l.error.message,t)}return l.result}function Qm(t){return function(t,e,r){return new Um({...t,coercer:(n,i)=>Nm(n,e)?t.coercer(r(n,i),i):t.coercer(n,i)})}(ew(t),tw,(e=>"error"in e?e:{...e,result:Cm(e.result,t)}))}const tw=ew(Gm());function ew(t){return $m([Hm({jsonrpc:Wm("2.0"),id:Vm(),result:t}),Hm({jsonrpc:Wm("2.0"),id:Vm(),error:Hm({code:Gm(),message:Vm(),data:qm(Dm("any",(()=>!0)))})})])}const rw=(nw=Hm({err:Km($m([Hm({}),Vm()])),logs:Km(jm(Vm())),accounts:qm(Km(jm(Km(Hm({executable:Dm("boolean",(t=>"boolean"==typeof t)),owner:Vm(),lamports:Fm(),data:jm(Vm()),rentEpoch:qm(Fm())}))))),unitsConsumed:qm(Fm())}),Qm(Hm({context:Hm({slot:Fm()}),value:nw})));var nw,iw=Object.freeze({__proto__:null,invoke:async function(t,e,r,n){t=Bm(t),n||(n=cw());const i=new hs;if(i.add(new cs({programId:t,keys:null!=e?e:[],data:r})),void 0===n.sendAndConfirm)throw new Error("This function requires 'Provider.sendAndConfirm' to be implemented.");return await n.sendAndConfirm(i,[])},getMultipleAccounts:async function(t,e,r){return(await Ym(t,e,r)).map((t=>t?{publicKey:t.publicKey,account:t.account}:null))},getMultipleAccountsAndContext:Ym,simulateTransaction:Xm});class ow{constructor(t,e,r){this.connection=t,this.wallet=e,this.opts=r,this.publicKey=null==e?void 0:e.publicKey}static defaultOptions(){return{preflightCommitment:"processed",commitment:"processed"}}static local(t,e){throw new Error("Provider local is not available on browser.")}static env(){throw new Error("Provider env is not available on browser.")}async sendAndConfirm(t,e,r){var n,i,o,s;if(void 0===r&&(r=this.opts),ym(t))e&&t.sign(e);else if(t.feePayer=null!==(n=t.feePayer)&&void 0!==n?n:this.wallet.publicKey,t.recentBlockhash=(await this.connection.getLatestBlockhash(r.preflightCommitment)).blockhash,e)for(const r of e)t.partialSign(r);const a=(t=await this.wallet.signTransaction(t)).serialize();try{return await aw(this.connection,a,r)}catch(e){if(e instanceof uw){const r=vm(ym(t)?(null===(i=t.signatures)||void 0===i?void 0:i[0])||new Uint8Array:null!==(o=t.signature)&&void 0!==o?o:new Uint8Array),n=await this.connection.getTransaction(r,{commitment:"confirmed"});if(n){const t=null===(s=n.meta)||void 0===s?void 0:s.logMessages;throw t?new Fs(e.message,t):e}throw e}throw e}}async sendAll(t,e){var r,n,i;void 0===e&&(e=this.opts);const o=(await this.connection.getLatestBlockhash(e.preflightCommitment)).blockhash;let s=t.map((t=>{var e,r;if(ym(t.tx)){let e=t.tx;return t.signers&&e.sign(t.signers),e}{let n=t.tx,i=null!==(e=t.signers)&&void 0!==e?e:[];return n.feePayer=null!==(r=n.feePayer)&&void 0!==r?r:this.wallet.publicKey,n.recentBlockhash=o,i.forEach((t=>{n.partialSign(t)})),n}}));const a=await this.wallet.signAllTransactions(s),u=[];for(let t=0;t<s.length;t+=1){const o=a[t],s=o.serialize();try{u.push(await aw(this.connection,s,e))}catch(t){if(t instanceof uw){const e=vm(ym(o)?(null===(r=o.signatures)||void 0===r?void 0:r[0])||new Uint8Array:null!==(n=o.signature)&&void 0!==n?n:new Uint8Array),s=await this.connection.getTransaction(e,{commitment:"confirmed"});if(s){const e=null===(i=s.meta)||void 0===i?void 0:i.logMessages;throw e?new Fs(t.message,e):t}throw t}throw t}}return u}async simulate(t,e,r,n){let i,o=(await this.connection.getLatestBlockhash(null!=r?r:this.connection.commitment)).blockhash;if(ym(t)?(e&&(t.sign(e),t=await this.wallet.signTransaction(t)),i=await this.connection.simulateTransaction(t,{commitment:r})):(t.feePayer=t.feePayer||this.wallet.publicKey,t.recentBlockhash=o,e&&(t=await this.wallet.signTransaction(t)),i=await Xm(this.connection,t,e,r,n)),i.value.err)throw new sw(i.value);return i.value}}class sw extends Error{constructor(t,e){super(e),this.simulationResponse=t}}async function aw(t,e,r){const n=r&&{skipPreflight:r.skipPreflight,preflightCommitment:r.preflightCommitment||r.commitment},i=await t.sendRawTransaction(e,n),o=(await t.confirmTransaction(i,r&&r.commitment)).value;if(o.err)throw new uw(`Raw transaction ${i} failed (${JSON.stringify(o)})`);return i}class uw extends Error{constructor(t){super(t)}}function cw(){return null===hw?ow.local():hw}let hw=null;const lw=new Set(["anchor-deprecated-state","debug-logs"]),fw=new Map;function dw(t){return void 0!==fw.get(t)}var pw=Object.freeze({__proto__:null,set:function(t){if(!lw.has(t))throw new Error("Invalid feature");fw.set(t,!0)},isSet:dw});class yw extends Error{constructor(t){super(t),this.name="IdlError"}}class gw{constructor(t){this.stack=t}static parse(t){var e;const r=/^Program (\w*) invoke/,n=/^Program \w* success/,i=[];for(let o=0;o<t.length;o++){if(n.exec(t[o])){i.pop();continue}const s=null===(e=r.exec(t[o]))||void 0===e?void 0:e[1];s&&i.push(new Wo(s))}return new gw(i)}}class mw extends Error{constructor(t,e,r,n,i,o){super(r.join("\n").replace("Program log: ","")),this.errorLogs=r,this.logs=n,this.error={errorCode:t,errorMessage:e,comparedValues:o,origin:i},this._programErrorStack=gw.parse(n)}static parse(t){if(!t)return null;const e=t.findIndex((t=>t.startsWith("Program log: AnchorError")));if(-1===e)return null;const r=t[e],n=[r];let i;if(e+1<t.length)if("Program log: Left:"===t[e+1]){const r=/^Program log: (.*)$/,o=r.exec(t[e+2])[1],s=r.exec(t[e+4])[1];i=[new Wo(o),new Wo(s)],n.push(...t.slice(e+1,e+5))}else if(t[e+1].startsWith("Program log: Left:")){const r=/^Program log: (Left|Right): (.*)$/,o=r.exec(t[e+1])[2],s=r.exec(t[e+2])[2];n.push(...t.slice(e+1,e+3)),i=[o,s]}const o=/^Program log: AnchorError occurred\. Error Code: (.*)\. Error Number: (\d*)\. Error Message: (.*)\./.exec(r),s=/^Program log: AnchorError thrown in (.*):(\d*)\. Error Code: (.*)\. Error Number: (\d*)\. Error Message: (.*)\./.exec(r),a=/^Program log: AnchorError caused by account: (.*)\. Error Code: (.*)\. Error Number: (\d*)\. Error Message: (.*)\./.exec(r);if(o){const[e,r,s]=o.slice(1,4),a={code:e,number:parseInt(r)};return new mw(a,s,n,t,void 0,i)}if(s){const[e,r,o,a,u]=s.slice(1,6),c={code:o,number:parseInt(a)},h={file:e,line:parseInt(r)};return new mw(c,u,n,t,h,i)}if(a){const[e,r,o,s]=a.slice(1,5),u=e,c={code:r,number:parseInt(o)};return new mw(c,s,n,t,u,i)}return null}get program(){return this._programErrorStack.stack[this._programErrorStack.stack.length-1]}get programErrorStack(){return this._programErrorStack.stack}toString(){return this.message}}class ww extends Error{constructor(t,e,r){super(),this.code=t,this.msg=e,this.logs=r,r&&(this._programErrorStack=gw.parse(r))}static parse(t,e){const r=t.toString();let n,i;if(r.includes("custom program error:")){let t=r.split("custom program error: ");if(2!==t.length)return null;n=t[1]}else{const t=r.match(/"Custom":([0-9]+)}/g);if(!t||t.length>1)return null;n=t[0].match(/([0-9]+)/g)[0]}try{i=parseInt(n)}catch(t){return null}let o=e.get(i);return void 0!==o?new ww(i,o,t.logs):(o=_w.get(i),void 0!==o?new ww(i,o,t.logs):null)}get program(){var t;return null===(t=this._programErrorStack)||void 0===t?void 0:t.stack[this._programErrorStack.stack.length-1]}get programErrorStack(){var t;return null===(t=this._programErrorStack)||void 0===t?void 0:t.stack}toString(){return this.msg}}function bw(t,e){dw("debug-logs")&&console.log("Translating error:",t);const r=mw.parse(t.logs);if(r)return r;const n=ww.parse(t,e);if(n)return n;if(t.logs){const e={get:function(e,r){return"programErrorStack"===r?e.programErrorStack.stack:"program"===r?e.programErrorStack.stack[t.programErrorStack.stack.length-1]:Reflect.get(...arguments)}};return t.programErrorStack=gw.parse(t.logs),new Proxy(t,e)}return t}const vw={InstructionMissing:100,InstructionFallbackNotFound:101,InstructionDidNotDeserialize:102,InstructionDidNotSerialize:103,IdlInstructionStub:1e3,IdlInstructionInvalidProgram:1001,ConstraintMut:2e3,ConstraintHasOne:2001,ConstraintSigner:2002,ConstraintRaw:2003,ConstraintOwner:2004,ConstraintRentExempt:2005,ConstraintSeeds:2006,ConstraintExecutable:2007,ConstraintState:2008,ConstraintAssociated:2009,ConstraintAssociatedInit:2010,ConstraintClose:2011,ConstraintAddress:2012,ConstraintZero:2013,ConstraintTokenMint:2014,ConstraintTokenOwner:2015,ConstraintMintMintAuthority:2016,ConstraintMintFreezeAuthority:2017,ConstraintMintDecimals:2018,ConstraintSpace:2019,ConstraintAccountIsNone:2020,RequireViolated:2500,RequireEqViolated:2501,RequireKeysEqViolated:2502,RequireNeqViolated:2503,RequireKeysNeqViolated:2504,RequireGtViolated:2505,RequireGteViolated:2506,AccountDiscriminatorAlreadySet:3e3,AccountDiscriminatorNotFound:3001,AccountDiscriminatorMismatch:3002,AccountDidNotDeserialize:3003,AccountDidNotSerialize:3004,AccountNotEnoughKeys:3005,AccountNotMutable:3006,AccountOwnedByWrongProgram:3007,InvalidProgramId:3008,InvalidProgramExecutable:3009,AccountNotSigner:3010,AccountNotSystemOwned:3011,AccountNotInitialized:3012,AccountNotProgramData:3013,AccountNotAssociatedTokenAccount:3014,AccountSysvarMismatch:3015,AccountReallocExceedsLimit:3016,AccountDuplicateReallocs:3017,DeclaredProgramIdMismatch:4100,Deprecated:5e3},_w=new Map([[vw.InstructionMissing,"8 byte instruction identifier not provided"],[vw.InstructionFallbackNotFound,"Fallback functions are not supported"],[vw.InstructionDidNotDeserialize,"The program could not deserialize the given instruction"],[vw.InstructionDidNotSerialize,"The program could not serialize the given instruction"],[vw.IdlInstructionStub,"The program was compiled without idl instructions"],[vw.IdlInstructionInvalidProgram,"The transaction was given an invalid program for the IDL instruction"],[vw.ConstraintMut,"A mut constraint was violated"],[vw.ConstraintHasOne,"A has one constraint was violated"],[vw.ConstraintSigner,"A signer constraint was violated"],[vw.ConstraintRaw,"A raw constraint was violated"],[vw.ConstraintOwner,"An owner constraint was violated"],[vw.ConstraintRentExempt,"A rent exemption constraint was violated"],[vw.ConstraintSeeds,"A seeds constraint was violated"],[vw.ConstraintExecutable,"An executable constraint was violated"],[vw.ConstraintState,"Deprecated Error, feel free to replace with something else"],[vw.ConstraintAssociated,"An associated constraint was violated"],[vw.ConstraintAssociatedInit,"An associated init constraint was violated"],[vw.ConstraintClose,"A close constraint was violated"],[vw.ConstraintAddress,"An address constraint was violated"],[vw.ConstraintZero,"Expected zero account discriminant"],[vw.ConstraintTokenMint,"A token mint constraint was violated"],[vw.ConstraintTokenOwner,"A token owner constraint was violated"],[vw.ConstraintMintMintAuthority,"A mint mint authority constraint was violated"],[vw.ConstraintMintFreezeAuthority,"A mint freeze authority constraint was violated"],[vw.ConstraintMintDecimals,"A mint decimals constraint was violated"],[vw.ConstraintSpace,"A space constraint was violated"],[vw.ConstraintAccountIsNone,"A required account for the constraint is None"],[vw.RequireViolated,"A require expression was violated"],[vw.RequireEqViolated,"A require_eq expression was violated"],[vw.RequireKeysEqViolated,"A require_keys_eq expression was violated"],[vw.RequireNeqViolated,"A require_neq expression was violated"],[vw.RequireKeysNeqViolated,"A require_keys_neq expression was violated"],[vw.RequireGtViolated,"A require_gt expression was violated"],[vw.RequireGteViolated,"A require_gte expression was violated"],[vw.AccountDiscriminatorAlreadySet,"The account discriminator was already set on this account"],[vw.AccountDiscriminatorNotFound,"No 8 byte discriminator was found on the account"],[vw.AccountDiscriminatorMismatch,"8 byte discriminator did not match what was expected"],[vw.AccountDidNotDeserialize,"Failed to deserialize the account"],[vw.AccountDidNotSerialize,"Failed to serialize the account"],[vw.AccountNotEnoughKeys,"Not enough account keys given to the instruction"],[vw.AccountNotMutable,"The given account is not mutable"],[vw.AccountOwnedByWrongProgram,"The given account is owned by a different program than expected"],[vw.InvalidProgramId,"Program ID was not as expected"],[vw.InvalidProgramExecutable,"Program account is not executable"],[vw.AccountNotSigner,"The given account did not sign"],[vw.AccountNotSystemOwned,"The given account is not owned by the system program"],[vw.AccountNotInitialized,"The program expected this account to be already initialized"],[vw.AccountNotProgramData,"The given account is not a program data account"],[vw.AccountNotAssociatedTokenAccount,"The given account is not the associated token account"],[vw.AccountSysvarMismatch,"The given public key does not match the required sysvar"],[vw.AccountReallocExceedsLimit,"The account reallocation exceeds the MAX_PERMITTED_DATA_INCREASE limit"],[vw.AccountDuplicateReallocs,"The account was duplicated for more than one reallocation"],[vw.DeclaredProgramIdMismatch,"The declared program id does not match the actual program id"],[vw.Deprecated,"The API being used is deprecated and should no longer be used"]]);var kw=function(){return kw=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},kw.apply(this,arguments)},Ew=function(){return Ew=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},Ew.apply(this,arguments)};function xw(t){return t.toLowerCase()}var Sw=[/([a-z0-9])([A-Z])/g,/([A-Z])([A-Z][a-z])/g],Aw=/[^A-Z0-9]+/gi;function Iw(t,e,r){return e instanceof RegExp?t.replace(e,r):e.reduce((function(t,e){return t.replace(e,r)}),t)}function Bw(t,e){return void 0===e&&(e={}),function(t,e){void 0===e&&(e={});for(var r=e.splitRegexp,n=void 0===r?Sw:r,i=e.stripRegexp,o=void 0===i?Aw:i,s=e.transform,a=void 0===s?xw:s,u=e.delimiter,c=void 0===u?" ":u,h=Iw(Iw(t,n,"$1\0$2"),o,"\0"),l=0,f=h.length;"\0"===h.charAt(l);)l++;for(;"\0"===h.charAt(f-1);)f--;return h.slice(l,f).split("\0").map(a).join(c)}(t,Ew({delimiter:"."},e))}class Mw{static fieldLayout(t,e){const r=void 0!==t.name?pd(t.name):void 0;switch(t.type){case"bool":return yd.bool(r);case"u8":return yd.u8(r);case"i8":return yd.i8(r);case"u16":return yd.u16(r);case"i16":return yd.i16(r);case"u32":return yd.u32(r);case"i32":return yd.i32(r);case"f32":return yd.f32(r);case"u64":return yd.u64(r);case"i64":return yd.i64(r);case"f64":return yd.f64(r);case"u128":return yd.u128(r);case"i128":return yd.i128(r);case"u256":return yd.u256(r);case"i256":return yd.i256(r);case"bytes":return yd.vecU8(r);case"string":return yd.str(r);case"publicKey":return yd.publicKey(r);default:if("vec"in t.type)return yd.vec(Mw.fieldLayout({name:void 0,type:t.type.vec},e),r);if("option"in t.type)return yd.option(Mw.fieldLayout({name:void 0,type:t.type.option},e),r);if("defined"in t.type){const n=t.type.defined;if(void 0===e)throw new yw("User defined types not provided");const i=e.filter((t=>t.name===n));if(1!==i.length)throw new yw(`Type not found: ${JSON.stringify(t)}`);return Mw.typeDefLayout(i[0],e,r)}if("array"in t.type){let n=t.type.array[0],i=t.type.array[1],o=Mw.fieldLayout({name:void 0,type:n},e);return yd.array(o,i,r)}throw new Error(`Not yet implemented: ${t}`)}}static typeDefLayout(t,e=[],r){if("struct"===t.type.kind){const n=t.type.fields.map((t=>Mw.fieldLayout(t,e)));return yd.struct(n,r)}if("enum"===t.type.kind){let n=t.type.variants.map((t=>{const r=pd(t.name);if(void 0===t.fields)return yd.struct([],r);const n=t.fields.map(((t,r)=>t.hasOwnProperty("name")?Mw.fieldLayout(t,e):Mw.fieldLayout({type:t,name:r.toString()},e)));return yd.struct(n,r)}));return void 0!==r?yd.rustEnum(n).replicate(r):yd.rustEnum(n,r)}throw new Error(`Unknown type kint: ${t}`)}}const Rw="global";class Pw{constructor(t){this.idl=t,this.ixLayout=Pw.parseIxLayout(t);const e=new Map;t.instructions.forEach((t=>{const r=Ow(Rw,t.name);e.set(ld.encode(r),{layout:this.ixLayout.get(t.name),name:t.name})})),this.sighashLayouts=e}encode(t,e){return this._encode(Rw,t,e)}_encode(t,e,r){const i=n.Buffer.alloc(1e3),o=pd(e),s=this.ixLayout.get(o);if(!s)throw new Error(`Unknown method: ${o}`);const a=s.encode(r,i),u=i.slice(0,a);return n.Buffer.concat([Ow(t,e),u])}static parseIxLayout(t){const e=t.instructions.map((e=>{let r=e.args.map((e=>{var r,n;return Mw.fieldLayout(e,Array.from([...null!==(r=t.accounts)&&void 0!==r?r:[],...null!==(n=t.types)&&void 0!==n?n:[]]))}));const n=pd(e.name);return[n,yd.struct(r,n)]}));return new Map(e)}decode(t,e="hex"){"string"==typeof t&&(t="hex"===e?n.Buffer.from(t,"hex"):ld.decode(t));let r=ld.encode(t.slice(0,8)),i=t.slice(8);const o=this.sighashLayouts.get(r);return o?{data:o.layout.decode(i),name:o.name}:null}format(t,e){return Tw.format(t,e,this.idl)}}class Tw{static format(t,e,r){const n=r.instructions.filter((e=>t.name===e.name))[0];if(void 0===n)return console.error("Invalid instruction given"),null;const i=n.args.map((e=>({name:e.name,type:Tw.formatIdlType(e.type),data:Tw.formatIdlData(e,t.data[e.name],r.types)}))),o=Tw.flattenIdlAccounts(n.accounts);return{args:i,accounts:e.map(((t,e)=>e<o.length?{name:o[e].name,...t}:{name:void 0,...t}))}}static formatIdlType(t){if("string"==typeof t)return t;if("vec"in t)return`Vec<${this.formatIdlType(t.vec)}>`;if("option"in t)return`Option<${this.formatIdlType(t.option)}>`;if("defined"in t)return t.defined;if("array"in t)return`Array<${t.array[0]}; ${t.array[1]}>`;throw new Error(`Unknown IDL type: ${t}`)}static formatIdlData(t,e,r){if("string"==typeof t.type)return e.toString();if(t.type.hasOwnProperty("vec"))return"["+e.map((e=>this.formatIdlData({name:"",type:t.type.vec},e))).join(", ")+"]";if(t.type.hasOwnProperty("option"))return null===e?"null":this.formatIdlData({name:"",type:t.type.option},e,r);if(t.type.hasOwnProperty("defined")){if(void 0===r)throw new Error("User defined types not provided");const n=r.filter((e=>e.name===t.type.defined));if(1!==n.length)throw new Error(`Type not found: ${t.type.defined}`);return Tw.formatIdlDataDefined(n[0],e,r)}return"unknown"}static formatIdlDataDefined(t,e,r){if("struct"===t.type.kind){const n=t.type,i=Object.keys(e).map((t=>{const i=n.fields.filter((e=>e.name===t))[0];if(void 0===i)throw new Error("Unable to find type");return t+": "+Tw.formatIdlData(i,e[t],r)})).join(", ");return"{ "+i+" }"}if(0===t.type.variants.length)return"{}";if(t.type.variants[0].name){const n=t.type.variants,i=Object.keys(e)[0],o=e[i],s=Object.keys(o).map((t=>{var e;const s=o[t],a=null===(e=n[i])||void 0===e?void 0:e.filter((e=>e.name===t))[0];if(void 0===a)throw new Error("Unable to find variant");return t+": "+Tw.formatIdlData(a,s,r)})).join(", "),a=pd(i,{pascalCase:!0});return 0===s.length?a:`${a} { ${s} }`}return"Tuple formatting not yet implemented"}static flattenIdlAccounts(t,e){return t.map((t=>{const r=function(t){const e=t.replace(/([A-Z])/g," $1");return e.charAt(0).toUpperCase()+e.slice(1)}(t.name);if(t.hasOwnProperty("accounts")){const n=e?`${e} > ${r}`:r;return Tw.flattenIdlAccounts(t.accounts,n)}return{...t,name:e?`${e} > ${r}`:r}})).flat()}}function Ow(t,e){var r;let i=`${t}:${void 0===r&&(r={}),Bw(e,kw({delimiter:"_"},r))}`;return n.Buffer.from(pe(i).slice(0,8))}function Lw(t,e){if("enum"===e.type.kind){const r=e.type.variants.map((e=>e.fields?e.fields.map((e=>Uw(t,"object"==typeof e&&"name"in e?e.type:e))).reduce(((t,e)=>t+e),0):0));return Math.max(...r)+1}return e.type.fields.map((e=>Uw(t,e.type))).reduce(((t,e)=>t+e),0)}function Uw(t,e){var r,n;switch(e){case"bool":case"u8":case"i8":case"bytes":case"string":return 1;case"i16":case"u16":return 2;case"u32":case"i32":case"f32":return 4;case"u64":case"i64":case"f64":return 8;case"u128":case"i128":return 16;case"u256":case"i256":case"publicKey":return 32;default:if("vec"in e)return 1;if("option"in e)return 1+Uw(t,e.option);if("coption"in e)return 4+Uw(t,e.coption);if("defined"in e){const i=null!==(n=null===(r=t.types)||void 0===r?void 0:r.filter((t=>t.name===e.defined)))&&void 0!==n?n:[];if(1!==i.length)throw new yw(`Type not found: ${JSON.stringify(e)}`);return Lw(t,i[0])}if("array"in e){let r=e.array[0],n=e.array[1];return Uw(t,r)*n}throw new Error(`Invalid type ${JSON.stringify(e)}`)}}const Cw=8;function Nw(t){return Buffer.from(pe(t).slice(0,Cw))}class zw{constructor(t){if(void 0===t.accounts)return void(this.accountLayouts=new Map);const e=t.accounts.map((e=>[e.name,Mw.typeDefLayout(e,t.types)]));this.accountLayouts=new Map(e),this.idl=t}async encode(t,e){const r=n.Buffer.alloc(1e3),i=this.accountLayouts.get(t);if(!i)throw new Error(`Unknown account: ${t}`);const o=i.encode(e,r);let s=r.slice(0,o),a=zw.accountDiscriminator(t);return n.Buffer.concat([a,s])}decode(t,e){if(zw.accountDiscriminator(t).compare(e.slice(0,8)))throw new Error("Invalid account discriminator");return this.decodeUnchecked(t,e)}decodeAny(t){const e=t.slice(0,8),r=Array.from(this.accountLayouts.keys()).find((t=>zw.accountDiscriminator(t).equals(e)));if(!r)throw new Error("Account descriminator not found");return this.decodeUnchecked(r,t)}decodeUnchecked(t,e){const r=e.subarray(Cw),n=this.accountLayouts.get(t);if(!n)throw new Error(`Unknown account: ${t}`);return n.decode(r)}memcmp(t,e){const r=zw.accountDiscriminator(t);return{offset:0,bytes:ld.encode(e?n.Buffer.concat([r,e]):r)}}size(t){var e;return Cw+(null!==(e=Lw(this.idl,t))&&void 0!==e?e:0)}static accountDiscriminator(t){return Nw(`account:${pd(t,{pascalCase:!0,preserveConsecutiveUppercase:!0})}`)}}class Dw{constructor(t){if(void 0===t.events)return void(this.layouts=new Map);const e=t.events.map((e=>{let r={name:e.name,type:{kind:"struct",fields:e.fields.map((t=>({name:t.name,type:t.type})))}};return[e.name,Mw.typeDefLayout(r,t.types)]}));this.layouts=new Map(e),this.discriminators=new Map(void 0===t.events?[]:t.events.map((t=>[s(jw(t.name)),t.name])))}decode(t){let e;try{e=n.Buffer.from(o(t))}catch(t){return null}const r=s(e.slice(0,8)),i=this.discriminators.get(r);if(void 0===i)return null;const a=this.layouts.get(i);if(!a)throw new Error(`Unknown event: ${i}`);return{data:a.decode(e.slice(8)),name:i}}}function jw(t){return Nw(`event:${t}`)}class Ww{constructor(t){if(void 0===t.types)return void(this.typeLayouts=new Map);const e=t.types.map((e=>[e.name,Mw.typeDefLayout(e,t.types)]));this.typeLayouts=new Map(e),this.idl=t}encode(t,e){const r=n.Buffer.alloc(1e3),i=this.typeLayouts.get(t);if(!i)throw new Error(`Unknown type: ${t}`);const o=i.encode(e,r);return r.slice(0,o)}decode(t,e){const r=this.typeLayouts.get(t);if(!r)throw new Error(`Unknown type: ${t}`);return r.decode(e)}}class Kw{constructor(t){this.instruction=new Pw(t),this.accounts=new zw(t),this.events=new Dw(t),this.types=new Ww(t)}}var Fw="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function qw(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}class Vw{constructor(t,e){if(!Number.isInteger(t))throw new TypeError("span must be an integer");this.span=t,this.property=e}makeDestinationObject(){return{}}decode(t,e){throw new Error("Layout is abstract")}encode(t,e,r){throw new Error("Layout is abstract")}getSpan(t,e){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(t){const e=Object.create(this.constructor.prototype);return Object.assign(e,this),e.property=t,e}fromArray(t){}}var Hw=Vw;class $w extends Vw{isCount(){throw new Error("ExternalLayout is abstract")}}class Gw extends $w{constructor(t,e,r){if(!(t instanceof Vw))throw new TypeError("layout must be a Layout");if(void 0===e)e=0;else if(!Number.isInteger(e))throw new TypeError("offset must be integer or undefined");super(t.span,r||t.property),this.layout=t,this.offset=e}isCount(){return this.layout instanceof Zw||this.layout instanceof Yw}decode(t,e){return void 0===e&&(e=0),this.layout.decode(t,e+this.offset)}encode(t,e,r){return void 0===r&&(r=0),this.layout.encode(t,e,r+this.offset)}}class Zw extends Vw{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return void 0===e&&(e=0),t.readUIntLE(e,this.span)}encode(t,e,r){return void 0===r&&(r=0),e.writeUIntLE(t,r,this.span),this.span}}class Yw extends Vw{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return void 0===e&&(e=0),t.readUIntBE(e,this.span)}encode(t,e,r){return void 0===r&&(r=0),e.writeUIntBE(t,r,this.span),this.span}}const Jw=Math.pow(2,32);function Xw(t){const e=Math.floor(t/Jw);return{hi32:e,lo32:t-e*Jw}}function Qw(t,e){return t*Jw+e}class tb extends Vw{constructor(t){super(8,t)}decode(t,e){void 0===e&&(e=0);const r=t.readUInt32LE(e);return Qw(t.readUInt32LE(e+4),r)}encode(t,e,r){void 0===r&&(r=0);const n=Xw(t);return e.writeUInt32LE(n.lo32,r),e.writeUInt32LE(n.hi32,r+4),8}}class eb extends Vw{constructor(t){super(8,t)}decode(t,e){void 0===e&&(e=0);const r=t.readUInt32LE(e);return Qw(t.readInt32LE(e+4),r)}encode(t,e,r){void 0===r&&(r=0);const n=Xw(t);return e.writeUInt32LE(n.lo32,r),e.writeInt32LE(n.hi32,r+4),8}}class rb extends Vw{constructor(t,e,r){if(!Array.isArray(t)||!t.reduce(((t,e)=>t&&e instanceof Vw),!0))throw new TypeError("fields must be array of Layout instances");"boolean"==typeof e&&void 0===r&&(r=e,e=void 0);for(const e of t)if(0>e.span&&void 0===e.property)throw new Error("fields cannot contain unnamed variable-length layout");let n=-1;try{n=t.reduce(((t,e)=>t+e.getSpan()),0)}catch(t){}super(n,e),this.fields=t,this.decodePrefixes=!!r}getSpan(t,e){if(0<=this.span)return this.span;void 0===e&&(e=0);let r=0;try{r=this.fields.reduce(((r,n)=>{const i=n.getSpan(t,e);return e+=i,r+i}),0)}catch(t){throw new RangeError("indeterminate span")}return r}decode(t,e){void 0===e&&(e=0);const r=this.makeDestinationObject();for(const n of this.fields)if(void 0!==n.property&&(r[n.property]=n.decode(t,e)),e+=n.getSpan(t,e),this.decodePrefixes&&t.length===e)break;return r}encode(t,e,r){void 0===r&&(r=0);const n=r;let i=0,o=0;for(const n of this.fields){let s=n.span;if(o=0<s?s:0,void 0!==n.property){const i=t[n.property];void 0!==i&&(o=n.encode(i,e,r),0>s&&(s=n.getSpan(e,r)))}i=r,r+=s}return i+o-n}fromArray(t){const e=this.makeDestinationObject();for(const r of this.fields)void 0!==r.property&&0<t.length&&(e[r.property]=t.shift());return e}layoutFor(t){if("string"!=typeof t)throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}offsetOf(t){if("string"!=typeof t)throw new TypeError("property must be string");let e=0;for(const r of this.fields){if(r.property===t)return e;0>r.span?e=-1:0<=e&&(e+=r.span)}}}class nb{constructor(t){this.property=t}decode(){throw new Error("UnionDiscriminator is abstract")}encode(){throw new Error("UnionDiscriminator is abstract")}}class ib extends nb{constructor(t,e){if(!(t instanceof $w&&t.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(e||t.property||"variant"),this.layout=t}decode(t,e){return this.layout.decode(t,e)}encode(t,e,r){return this.layout.encode(t,e,r)}}class ob extends Vw{constructor(t,e,r){const n=t instanceof Zw||t instanceof Yw;if(n)t=new ib(new Gw(t));else if(t instanceof $w&&t.isCount())t=new ib(t);else if(!(t instanceof nb))throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(void 0===e&&(e=null),!(null===e||e instanceof Vw))throw new TypeError("defaultLayout must be null or a Layout");if(null!==e){if(0>e.span)throw new Error("defaultLayout must have constant span");void 0===e.property&&(e=e.replicate("content"))}let i=-1;e&&(i=e.span,0<=i&&n&&(i+=t.layout.span)),super(i,r),this.discriminator=t,this.usesPrefixDiscriminator=n,this.defaultLayout=e,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(t){return o(t)},this.configGetSourceVariant=function(t){o=t.bind(this)}}getSpan(t,e){if(0<=this.span)return this.span;void 0===e&&(e=0);const r=this.getVariant(t,e);if(!r)throw new Error("unable to determine span for unrecognized variant");return r.getSpan(t,e)}defaultGetSourceVariant(t){if(t.hasOwnProperty(this.discriminator.property)){if(this.defaultLayout&&t.hasOwnProperty(this.defaultLayout.property))return;const e=this.registry[t[this.discriminator.property]];if(e&&(!e.layout||t.hasOwnProperty(e.property)))return e}else for(const e in this.registry){const r=this.registry[e];if(t.hasOwnProperty(r.property))return r}throw new Error("unable to infer src variant")}decode(t,e){let r;void 0===e&&(e=0);const n=this.discriminator,i=n.decode(t,e);let o=this.registry[i];if(void 0===o){let s=0;o=this.defaultLayout,this.usesPrefixDiscriminator&&(s=n.layout.span),r=this.makeDestinationObject(),r[n.property]=i,r[o.property]=this.defaultLayout.decode(t,e+s)}else r=o.decode(t,e);return r}encode(t,e,r){void 0===r&&(r=0);const n=this.getSourceVariant(t);if(void 0===n){const n=this.discriminator,i=this.defaultLayout;let o=0;return this.usesPrefixDiscriminator&&(o=n.layout.span),n.encode(t[n.property],e,r),o+i.encode(t[i.property],e,r+o)}return n.encode(t,e,r)}addVariant(t,e,r){const n=new sb(this,t,e,r);return this.registry[t]=n,n}getVariant(t,e){let r=t;return Buffer.isBuffer(t)&&(void 0===e&&(e=0),r=this.discriminator.decode(t,e)),this.registry[r]}}class sb extends Vw{constructor(t,e,r,n){if(!(t instanceof ob))throw new TypeError("union must be a Union");if(!Number.isInteger(e)||0>e)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 Vw))throw new TypeError("layout must be a Layout");if(null!==t.defaultLayout&&0<=r.span&&r.span>t.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=t.span;0>t.span&&(i=r?r.span:0,0<=i&&t.usesPrefixDiscriminator&&(i+=t.discriminator.layout.span)),super(i,n),this.union=t,this.variant=e,this.layout=r||null}getSpan(t,e){if(0<=this.span)return this.span;void 0===e&&(e=0);let r=0;return this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span),r+this.layout.getSpan(t,e+r)}decode(t,e){const r=this.makeDestinationObject();if(void 0===e&&(e=0),this!==this.union.getVariant(t,e))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(t,e+n):this.property?r[this.property]=!0:this.union.usesPrefixDiscriminator&&(r[this.union.discriminator.property]=this.variant),r}encode(t,e,r){void 0===r&&(r=0);let n=0;if(this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span),this.layout&&!t.hasOwnProperty(this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,e,r);let i=n;if(this.layout&&(this.layout.encode(t[this.property],e,r+n),i+=this.layout.getSpan(e,r+n),0<=this.union.span&&i>this.union.span))throw new Error("encoded variant overruns containing union");return i}fromArray(t){if(this.layout)return this.layout.fromArray(t)}}class ab extends Vw{constructor(t,e){if(!(t instanceof $w&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let r=-1;t instanceof $w||(r=t),super(r,e),this.length=t}getSpan(t,e){let r=this.span;return 0>r&&(r=this.length.decode(t,e)),r}decode(t,e){void 0===e&&(e=0);let r=this.span;return 0>r&&(r=this.length.decode(t,e)),t.slice(e,e+r)}encode(t,e,r){let n=this.length;if(this.length instanceof $w&&(n=t.length),!Buffer.isBuffer(t)||n!==t.length)throw new TypeError(function(t,e){return e.property?t+"["+e.property+"]":t}("Blob.encode",this)+" requires (length "+n+") Buffer as src");if(r+n>e.length)throw new RangeError("encoding overruns Buffer");return e.write(t.toString("hex"),r,n,"hex"),this.length instanceof $w&&this.length.encode(n,e,r),n}}var ub=(t,e,r)=>new Gw(t,e,r),cb=t=>new Zw(4,t),hb=t=>new eb(t),lb=(t,e,r)=>new rb(t,e,r),fb=(t,e,r)=>new ob(t,e,r),db=(t,e)=>new ab(t,e);class pb{constructor(t){}encode(t,e){switch(pd(t)){case"createAccount":return function({lamports:t,space:e,owner:r}){return bb({createAccount:{lamports:t,space:e,owner:r.toBuffer()}})}(e);case"assign":return function({owner:t}){return bb({assign:{owner:t.toBuffer()}})}(e);case"transfer":return function({lamports:t}){return bb({transfer:{lamports:t}})}(e);case"createAccountWithSeed":return function({base:t,seed:e,lamports:r,space:n,owner:i}){return bb({createAccountWithSeed:{base:t.toBuffer(),seed:e,lamports:r,space:n,owner:i.toBuffer()}},wb.getVariant(3).span+e.length)}(e);case"advanceNonceAccount":return function({authorized:t}){return bb({advanceNonceAccount:{authorized:t.toBuffer()}})}(e);case"withdrawNonceAccount":return function({lamports:t}){return bb({withdrawNonceAccount:{lamports:t}})}(e);case"initializeNonceAccount":return function({authorized:t}){return bb({initializeNonceAccount:{authorized:t.toBuffer()}})}(e);case"authorizeNonceAccount":return function({authorized:t}){return bb({authorizeNonceAccount:{authorized:t.toBuffer()}})}(e);case"allocate":return function({space:t}){return bb({allocate:{space:t}})}(e);case"allocateWithSeed":return function({base:t,seed:e,space:r,owner:n}){return bb({allocateWithSeed:{base:t.toBuffer(),seed:e,space:r,owner:n.toBuffer()}},wb.getVariant(9).span+e.length)}(e);case"assignWithSeed":return function({base:t,seed:e,owner:r}){return bb({assignWithSeed:{base:t.toBuffer(),seed:e,owner:r.toBuffer()}},wb.getVariant(10).span+e.length)}(e);case"transferWithSeed":return function({lamports:t,seed:e,owner:r}){return bb({transferWithSeed:{lamports:t,seed:e,owner:r.toBuffer()}},wb.getVariant(11).span+e.length)}(e);default:throw new Error(`Invalid instruction: ${t}`)}}encodeState(t,e){throw new Error("System does not have state")}}class yb extends Hw{constructor(t){super(-1,t),this.property=t,this.layout=lb([cb("length"),cb("lengthPadding"),db(ub(cb(),-8),"chars")],this.property)}encode(t,e,r=0){if(null==t)return this.layout.span;const n={chars:Buffer.from(t,"utf8")};return this.layout.encode(n,e,r)}decode(t,e=0){return this.layout.decode(t,e).chars.toString()}getSpan(t,e=0){return cb().span+cb().span+new ne(new Uint8Array(t).slice(e,e+4),10,"le").toNumber()}}function gb(t){return new yb(t)}function mb(t){return db(32,t)}const wb=fb(cb("instruction"));function bb(t,e){const r=Buffer.alloc(null!=e?e:vb),n=wb.encode(t,r);return void 0===e?r.slice(0,n):r}wb.addVariant(0,lb([hb("lamports"),hb("space"),mb("owner")]),"createAccount"),wb.addVariant(1,lb([mb("owner")]),"assign"),wb.addVariant(2,lb([hb("lamports")]),"transfer"),wb.addVariant(3,lb([mb("base"),gb("seed"),hb("lamports"),hb("space"),mb("owner")]),"createAccountWithSeed"),wb.addVariant(4,lb([mb("authorized")]),"advanceNonceAccount"),wb.addVariant(5,lb([hb("lamports")]),"withdrawNonceAccount"),wb.addVariant(6,lb([mb("authorized")]),"initializeNonceAccount"),wb.addVariant(7,lb([mb("authorized")]),"authorizeNonceAccount"),wb.addVariant(8,lb([hb("space")]),"allocate"),wb.addVariant(9,lb([mb("base"),gb("seed"),hb("space"),mb("owner")]),"allocateWithSeed"),wb.addVariant(10,lb([mb("base"),gb("seed"),mb("owner")]),"assignWithSeed"),wb.addVariant(11,lb([hb("lamports"),gb("seed"),mb("owner")]),"transferWithSeed");const vb=Math.max(...Object.values(wb.registry).map((t=>t.span)));class _b{constructor(t){this.idl=t}async encode(t,e){if("nonce"===t){const t=Buffer.alloc(Bs),r=xb.encode(e,t);return t.slice(0,r)}throw new Error(`Invalid account name: ${t}`)}decode(t,e){return this.decodeUnchecked(t,e)}decodeUnchecked(t,e){if("nonce"===t)return function(t){return xb.decode(t)}(e);throw new Error(`Invalid account name: ${t}`)}memcmp(t,e){if("nonce"===t)return{dataSize:Bs};throw new Error(`Invalid account name: ${t}`)}size(t){var e;return null!==(e=Lw(this.idl,t))&&void 0!==e?e:0}}class kb extends Hw{constructor(t,e,r,n){super(t.span,n),this.layout=t,this.decoder=e,this.encoder=r}decode(t,e){return this.decoder(this.layout.decode(t,e))}encode(t,e,r){return this.layout.encode(this.encoder(t),e,r)}getSpan(t,e){return this.layout.getSpan(t,e)}}function Eb(t){return new kb(db(32),(t=>new Wo(t)),(t=>t.toBuffer()),t)}const xb=lb([cb("version"),cb("state"),Eb("authorizedPubkey"),Eb("nonce"),lb([(Sb="lamportsPerSignature",new tb(Sb))],"feeCalculator")]);var Sb;class Ab{constructor(t){}decode(t){throw new Error("System program does not have events")}}class Ib{constructor(t){}encode(t,e){throw new Error("System does not have user-defined types")}decode(t,e){throw new Error("System does not have user-defined types")}}class Bb{constructor(t){this.instruction=new pb(t),this.accounts=new _b(t),this.events=new Ab(t),this.types=new Ib(t)}}var Mb=Object.freeze({__proto__:null,hash:function(t){return(new TextDecoder).decode(pe(t))}});function Rb(t,...e){let r=[n.Buffer.from([97,110,99,104,111,114])];e.forEach((t=>{r.push(t instanceof n.Buffer?t:Bm(t).toBuffer())}));const[i]=Wo.findProgramAddressSync(r,Bm(t));return i}var Pb=Object.freeze({__proto__:null,createWithSeedSync:function(t,e,r){const i=n.Buffer.concat([t.toBuffer(),n.Buffer.from(e),r.toBuffer()]);return new Wo(pe(i))},associated:Rb});const Tb=new Wo("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"),Ob=new Wo("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");var Lb=Object.freeze({__proto__:null,TOKEN_PROGRAM_ID:Tb,ASSOCIATED_PROGRAM_ID:Ob,associatedAddress:function({mint:t,owner:e}){return Wo.findProgramAddressSync([e.toBuffer(),Tb.toBuffer(),t.toBuffer()],Ob)[0]}}),Ub={exports:{}};!function(t,e){var r="undefined"!=typeof self?self:Fw,n=function(){function t(){this.fetch=!1,this.DOMException=r.DOMException}return t.prototype=r,new t}();!function(t){!function(e){var r="URLSearchParams"in t,n="Symbol"in t&&"iterator"in Symbol,i="FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),o="FormData"in t,s="ArrayBuffer"in t;if(s)var a=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],u=ArrayBuffer.isView||function(t){return t&&a.indexOf(Object.prototype.toString.call(t))>-1};function c(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function h(t){return"string"!=typeof t&&(t=String(t)),t}function l(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return n&&(e[Symbol.iterator]=function(){return e}),e}function f(t){this.map={},t instanceof f?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function d(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function p(t){return new Promise((function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}}))}function y(t){var e=new FileReader,r=p(e);return e.readAsArrayBuffer(t),r}function g(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function m(){return this.bodyUsed=!1,this._initBody=function(t){var e;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:i&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:o&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:r&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():s&&i&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=g(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):s&&(ArrayBuffer.prototype.isPrototypeOf(t)||u(t))?this._bodyArrayBuffer=g(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},i&&(this.blob=function(){var t=d(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?d(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(y)}),this.text=function(){var t=d(this);if(t)return t;if(this._bodyBlob)return function(t){var e=new FileReader,r=p(e);return e.readAsText(t),r}(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n<e.length;n++)r[n]=String.fromCharCode(e[n]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},o&&(this.formData=function(){return this.text().then(v)}),this.json=function(){return this.text().then(JSON.parse)},this}f.prototype.append=function(t,e){t=c(t),e=h(e);var r=this.map[t];this.map[t]=r?r+", "+e:e},f.prototype.delete=function(t){delete this.map[c(t)]},f.prototype.get=function(t){return t=c(t),this.has(t)?this.map[t]:null},f.prototype.has=function(t){return this.map.hasOwnProperty(c(t))},f.prototype.set=function(t,e){this.map[c(t)]=h(e)},f.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},f.prototype.keys=function(){var t=[];return this.forEach((function(e,r){t.push(r)})),l(t)},f.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),l(t)},f.prototype.entries=function(){var t=[];return this.forEach((function(e,r){t.push([r,e])})),l(t)},n&&(f.prototype[Symbol.iterator]=f.prototype.entries);var w=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function b(t,e){var r,n,i=(e=e||{}).body;if(t instanceof b){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new f(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,i||null==t._bodyInit||(i=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new f(e.headers)),this.method=(r=e.method||this.method||"GET",n=r.toUpperCase(),w.indexOf(n)>-1?n:r),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function v(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(i))}})),e}function _(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new f(e.headers),this.url=e.url||"",this._initBody(t)}b.prototype.clone=function(){return new b(this,{body:this._bodyInit})},m.call(b.prototype),m.call(_.prototype),_.prototype.clone=function(){return new _(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},_.error=function(){var t=new _(null,{status:0,statusText:""});return t.type="error",t};var k=[301,302,303,307,308];_.redirect=function(t,e){if(-1===k.indexOf(e))throw new RangeError("Invalid status code");return new _(null,{status:e,headers:{location:t}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function E(t,r){return new Promise((function(n,o){var s=new b(t,r);if(s.signal&&s.signal.aborted)return o(new e.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function u(){a.abort()}a.onload=function(){var t,e,r={status:a.status,statusText:a.statusText,headers:(t=a.getAllResponseHeaders()||"",e=new f,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var r=t.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();e.append(n,i)}})),e)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var i="response"in a?a.response:a.responseText;n(new _(i,r))},a.onerror=function(){o(new TypeError("Network request failed"))},a.ontimeout=function(){o(new TypeError("Network request failed"))},a.onabort=function(){o(new e.DOMException("Aborted","AbortError"))},a.open(s.method,s.url,!0),"include"===s.credentials?a.withCredentials=!0:"omit"===s.credentials&&(a.withCredentials=!1),"responseType"in a&&i&&(a.responseType="blob"),s.headers.forEach((function(t,e){a.setRequestHeader(e,t)})),s.signal&&(s.signal.addEventListener("abort",u),a.onreadystatechange=function(){4===a.readyState&&s.signal.removeEventListener("abort",u)}),a.send(void 0===s._bodyInit?null:s._bodyInit)}))}E.polyfill=!0,t.fetch||(t.fetch=E,t.Headers=f,t.Request=b,t.Response=_),e.Headers=f,e.Request=b,e.Response=_,e.fetch=E,Object.defineProperty(e,"__esModule",{value:!0})}({})}(n),n.fetch.ponyfill=!0,delete n.fetch.polyfill;var i=n;(e=i.fetch).default=i.fetch,e.fetch=i.fetch,e.Headers=i.Headers,e.Request=i.Request,e.Response=i.Response,t.exports=e}(Ub,Ub.exports);var Cb=qw(Ub.exports);async function Nb(t,e){const r=await t.getAccountInfo(e);if(null===r)throw new Error("program account not found");const{program:n}=Db(r.data),i=await t.getAccountInfo(n.programdataAddress);if(null===i)throw new Error("program data account not found");const{programData:o}=Db(i.data);return o}const zb=yd.rustEnum([yd.struct([],"uninitialized"),yd.struct([yd.option(yd.publicKey(),"authorityAddress")],"buffer"),yd.struct([yd.publicKey("programdataAddress")],"program"),yd.struct([yd.u64("slot"),yd.option(yd.publicKey(),"upgradeAuthorityAddress")],"programData")],void 0,yd.u32());function Db(t){return zb.decode(t)}var jb=Object.freeze({__proto__:null,verifiedBuild:async function(t,e,r=5){const n=`https://api.apr.dev/api/v0/program/${e.toString()}/latest?limit=${r}`,[i,o]=await Promise.all([Nb(t,e),Cb(n)]),s=(await o.json()).filter((t=>!t.aborted&&"Built"===t.state&&"Verified"===t.verified));if(0===s.length)return null;const a=s[0];return i.slot.toNumber()!==a.verified_slot?null:a},fetchData:Nb,decodeUpgradeableLoaderState:Db}),Wb=Object.freeze({__proto__:null,sha256:Mb,rpc:iw,publicKey:Pb,bytes:xm,token:Lb,features:pw,registry:jb});function Kb(t){return"accounts"in t}const Fb=yd.struct([yd.publicKey("authority"),yd.vecU8("data")]);function qb(t,e){var r,n;let i={};const o=t.args?t.args.length:0;if(e.length>o){if(e.length!==o+1)throw new Error(`provided too many arguments ${e} to instruction ${null==t?void 0:t.name} expecting: ${null!==(n=null===(r=t.args)||void 0===r?void 0:r.map((t=>t.name)))&&void 0!==n?n:[]}`);i=e.pop()}return[e,i]}class Vb{static build(t,e,r){if("_inner"===t.name)throw new yw("the _inner name is reserved");const n=(...i)=>{const[o,s]=qb(t,[...i]);Im(t.accounts,s.accounts);const a=n.accounts(s.accounts);return void 0!==s.remainingAccounts&&a.push(...s.remainingAccounts),dw("debug-logs")&&console.log("Outgoing account metas:",a),new cs({keys:a,programId:r,data:e(t.name,Am(t,...o))})};return n.accounts=e=>Vb.accountsArray(e,t.accounts,r,t.name),n}static accountsArray(t,e,r,n){return t?e.map((e=>{if(void 0!==("accounts"in e?e.accounts:void 0)){const i=t[e.name];return Vb.accountsArray(i,e.accounts,r,n).flat()}{const i=e;let o;try{o=Bm(t[e.name])}catch(t){throw new Error(`Wrong input type for account "${e.name}" in the instruction accounts object${void 0!==n?' for instruction "'+n+'"':""}. Expected PublicKey or string.`)}const s=i.isOptional&&o.equals(r);return{pubkey:o,isWritable:i.isMut&&!s,isSigner:i.isSigner&&!s}}})).flat():[]}}class Hb{static build(t,e){return(...r)=>{var n,i,o;const[,s]=qb(t,[...r]),a=new hs;if(s.preInstructions&&s.instructions)throw new Error("instructions is deprecated, use preInstructions");return null===(n=s.preInstructions)||void 0===n||n.forEach((t=>a.add(t))),null===(i=s.instructions)||void 0===i||i.forEach((t=>a.add(t))),a.add(e(...r)),null===(o=s.postInstructions)||void 0===o||o.forEach((t=>a.add(t))),a}}}class $b{static build(t,e,r,n){return async(...i)=>{var o;const s=e(...i),[,a]=qb(t,[...i]);if(void 0===n.sendAndConfirm)throw new Error("This function requires 'Provider.sendAndConfirm' to be implemented.");try{return await n.sendAndConfirm(s,null!==(o=a.signers)&&void 0!==o?o:[],a.options)}catch(t){throw bw(t,r)}}}}class Gb{static build(t,e,r,n){var i;const o={};return null===(i=t.accounts)||void 0===i||i.forEach((i=>{const s=pd(i.name);o[s]=new Zb(t,i,r,n,e)})),o}}class Zb{get size(){return this._size}get programId(){return this._programId}get provider(){return this._provider}get coder(){return this._coder}get idlAccount(){return this._idlAccount}constructor(t,e,r,n,i){this._idlAccount=e,this._programId=r,this._provider=null!=n?n:cw(),this._coder=null!=i?i:new Kw(t),this._size=this._coder.accounts.size(e)}async fetchNullable(t,e){const{data:r}=await this.fetchNullableAndContext(t,e);return r}async fetchNullableAndContext(t,e){const r=await this.getAccountInfoAndContext(t,e),{value:n,context:i}=r;return{data:n&&0!==n.data.length?this._coder.accounts.decode(this._idlAccount.name,n.data):null,context:i}}async fetch(t,e){const{data:r}=await this.fetchNullableAndContext(t,e);if(null===r)throw new Error(`Account does not exist or has no data ${t.toString()}`);return r}async fetchAndContext(t,e){const{data:r,context:n}=await this.fetchNullableAndContext(t,e);if(null===r)throw new Error(`Account does not exist ${t.toString()}`);return{data:r,context:n}}async fetchMultiple(t,e){return(await this.fetchMultipleAndContext(t,e)).map((t=>t?t.data:null))}async fetchMultipleAndContext(t,e){return(await Ym(this._provider.connection,t.map((t=>Bm(t))),e)).map((t=>{if(null==t)return null;const{account:e,context:r}=t;return{data:this._coder.accounts.decode(this._idlAccount.name,e.data),context:r}}))}async all(t){const e=this.coder.accounts.memcmp(this._idlAccount.name,t instanceof Buffer?t:void 0),r=[];return null!=(null==e?void 0:e.offset)&&null!=(null==e?void 0:e.bytes)&&r.push({memcmp:{offset:e.offset,bytes:e.bytes}}),null!=(null==e?void 0:e.dataSize)&&r.push({dataSize:e.dataSize}),(await this._provider.connection.getProgramAccounts(this._programId,{commitment:this._provider.connection.commitment,filters:[...r,...Array.isArray(t)?t:[]]})).map((({pubkey:t,account:e})=>({publicKey:t,account:this._coder.accounts.decode(this._idlAccount.name,e.data)})))}subscribe(t,e){const r=Yb.get(t.toString());if(r)return r.ee;const n=new pm;t=Bm(t);const i=this._provider.connection.onAccountChange(t,(t=>{const e=this._coder.accounts.decode(this._idlAccount.name,t.data);n.emit("change",e)}),e);return Yb.set(t.toString(),{ee:n,listener:i}),n}async unsubscribe(t){let e=Yb.get(t.toString());e?Yb&&await this._provider.connection.removeAccountChangeListener(e.listener).then((()=>{Yb.delete(t.toString())})).catch(console.error):console.warn("Address is not subscribed")}async createInstruction(t,e){const r=this.size;if(void 0===this._provider.publicKey)throw new Error("This function requires the Provider interface implementor to have a 'publicKey' field.");return Os.createAccount({fromPubkey:this._provider.publicKey,newAccountPubkey:t.publicKey,space:null!=e?e:r,lamports:await this._provider.connection.getMinimumBalanceForRentExemption(null!=e?e:r),programId:this._programId})}async associated(...t){const e=await this.associatedAddress(...t);return await this.fetch(e)}async associatedAddress(...t){return await Rb(this._programId,...t)}async getAccountInfo(t,e){return await this._provider.connection.getAccountInfo(Bm(t),e)}async getAccountInfoAndContext(t,e){return await this._provider.connection.getAccountInfoAndContext(Bm(t),e)}}const Yb=new Map,Jb="Program log: ",Xb="Program data: ";class Qb{constructor(t,e,r){this._programId=t,this._provider=e,this._eventParser=new tv(t,r),this._eventCallbacks=new Map,this._eventListeners=new Map,this._listenerIdCount=0}addEventListener(t,e){var r;let n=this._listenerIdCount;return this._listenerIdCount+=1,this._eventListeners.has(t)||this._eventListeners.set(t,[]),this._eventListeners.set(t,(null!==(r=this._eventListeners.get(t))&&void 0!==r?r:[]).concat(n)),this._eventCallbacks.set(n,[t,e]),void 0!==this._onLogsSubscriptionId||(this._onLogsSubscriptionId=this._provider.connection.onLogs(this._programId,((t,e)=>{if(!t.err)for(const r of this._eventParser.parseLogs(t.logs)){const n=this._eventListeners.get(r.name);n&&n.forEach((n=>{const i=this._eventCallbacks.get(n);if(i){const[,n]=i;n(r.data,e.slot,t.signature)}}))}}))),n}async removeEventListener(t){const e=this._eventCallbacks.get(t);if(!e)throw new Error(`Event listener ${t} doesn't exist!`);const[r]=e;let n=this._eventListeners.get(r);if(!n)throw new Error(`Event listeners don't exist for ${r}!`);if(this._eventCallbacks.delete(t),n=n.filter((e=>e!==t)),this._eventListeners.set(r,n),0===n.length&&this._eventListeners.delete(r),0===this._eventCallbacks.size){if(0!==this._eventListeners.size)throw new Error(`Expected event listeners size to be 0 but got ${this._eventListeners.size}`);void 0!==this._onLogsSubscriptionId&&(await this._provider.connection.removeOnLogsListener(this._onLogsSubscriptionId),this._onLogsSubscriptionId=void 0)}}}class tv{constructor(t,e){this.coder=e,this.programId=t}*parseLogs(t,e=!1){const r=new rv(t),n=new ev;let i=r.next();for(;null!==i;){let[t,o,s]=this.handleLog(n,i,e);t&&(yield t),o&&n.push(o),s&&n.pop(),i=r.next()}}handleLog(t,e,r){return t.stack.length>0&&t.program()===this.programId.toString()?this.handleProgramLog(e,r):[null,...this.handleSystemLog(e)]}handleProgramLog(t,e){if(t.startsWith(Jb)||t.startsWith(Xb)){const r=t.startsWith(Jb)?t.slice(13):t.slice(14),n=this.coder.events.decode(r);if(e&&null===n)throw new Error(`Unable to decode event ${r}`);return[n,null,!1]}return[null,...this.handleSystemLog(t)]}handleSystemLog(t){const e=t.split(":")[0];return null!==e.match(/^Program (.*) success/g)?[null,!0]:e.startsWith(`Program ${this.programId.toString()} invoke`)?[this.programId.toString(),!1]:e.includes("invoke")?["cpi",!1]:[null,!1]}}class ev{constructor(){this.stack=[]}program(){if(!this.stack.length)throw new Error("Expected the stack to have elements");return this.stack[this.stack.length-1]}push(t){this.stack.push(t)}pop(){if(!this.stack.length)throw new Error("Expected the stack to have elements");this.stack.pop()}}class rv{constructor(t){this.logs=t}next(){if(0===this.logs.length)return null;let t=this.logs[0];return this.logs=this.logs.slice(1),t}}class nv{static build(t,e,r,n,i,o,s){return async(...a)=>{var u;const c=e(...a),[,h]=qb(t,[...a]);let l;if(void 0===n.simulate)throw new Error("This function requires 'Provider.simulate' to be implemented.");try{l=await n.simulate(c,h.signers,null===(u=h.options)||void 0===u?void 0:u.commitment)}catch(t){throw bw(t,r)}if(void 0===l)throw new Error("Unable to simulate transaction");const f=l.logs;if(!f)throw new Error("Simulated logs not found");const d=[];if(s.events){let t=new tv(o,i);for(const e of t.parseLogs(f))d.push(e)}return{events:d,raw:f}}}}function iv(t){return new av(db(8),(t=>cv.fromBuffer(t)),(t=>t.toBuffer()),t)}function ov(t){return new av(db(32),(t=>new Wo(t)),(t=>t.toBuffer()),t)}function sv(t,e){return new uv(t,e)}class av extends Hw{constructor(t,e,r,n){super(t.span,n),this.layout=t,this.decoder=e,this.encoder=r}decode(t,e){return this.decoder(this.layout.decode(t,e))}encode(t,e,r){return this.layout.encode(this.encoder(t),e,r)}getSpan(t,e){return this.layout.getSpan(t,e)}}class uv extends Hw{constructor(t,e){super(-1,e),this.layout=t,this.discriminator=cb()}encode(t,e,r=0){return null==t?this.layout.span+this.discriminator.encode(0,e,r):(this.discriminator.encode(1,e,r),this.layout.encode(t,e,r+4)+4)}decode(t,e=0){const r=this.discriminator.decode(t,e);if(0===r)return null;if(1===r)return this.layout.decode(t,e+4);throw new Error("Invalid coption "+this.layout.property)}getSpan(t,e=0){return this.layout.getSpan(t,e+4)+4}}class cv extends ne{toBuffer(){const t=super.toArray().reverse(),e=Buffer.from(t);if(8===e.length)return e;if(e.length>=8)throw new Error("u64 too large");const r=Buffer.alloc(8);return e.copy(r),r}static fromBuffer(t){if(8!==t.length)throw new Error(`Invalid buffer length: ${t.length}`);return new cv([...t].reverse().map((t=>`00${t.toString(16)}`.slice(-2))).join(""),16)}}const hv=lb([ov("mint"),ov("owner"),iv("amount"),sv(ov(),"delegate"),(t=>{const e=fb((t=>new Zw(1,t))("discriminator"),null,"state");return e.addVariant(0,lb([]),"uninitialized"),e.addVariant(1,lb([]),"initialized"),e.addVariant(2,lb([]),"frozen"),e})(),sv(iv(),"isNative"),iv("delegatedAmount"),sv(ov(),"closeAuthority")]);class lv{constructor(t,e,r,n,i,o,s,a){this._accounts=e,this._provider=r,this._programId=n,this._idlIx=i,this._idlTypes=s,this._customResolver=a,this._args=t,this._accountStore=new fv(r,o,this._programId)}args(t){this._args=t}async resolve(){for(await this.resolveConst(this._idlIx.accounts),this._resolveEventCpi(this._idlIx.accounts);await this.resolvePdas(this._idlIx.accounts)+await this.resolveRelations(this._idlIx.accounts)+await this.resolveCustom()>0;);}async resolveCustom(){if(this._customResolver){const{accounts:t,resolved:e}=await this._customResolver({args:this._args,accounts:this._accounts,provider:this._provider,programId:this._programId,idlIx:this._idlIx});return this._accounts=t,e}return 0}resolveOptionalsHelper(t,e){const r={};for(const n of e){const e=n.name,i=t[e];void 0!==i&&(pv(i)?Kb(n)?r[e]=this.resolveOptionalsHelper(i,n.accounts):r[e]=yv(i,!0):null!==i?r[e]=Bm(i):n.isOptional&&(r[e]=this._programId))}return r}resolveOptionals(t){Object.assign(this._accounts,this.resolveOptionalsHelper(t,this._idlIx.accounts))}get(t){const e=t.reduce(((t,e)=>t&&t[e]),this._accounts);if(e&&e.toBase58)return e}set(t,e){let r=this._accounts;t.forEach(((n,i)=>{i==t.length-1&&(r[n]=e),r[n]=r[n]||{},r=r[n]}))}async resolveConst(t,e=[]){for(let r=0;r<t.length;r+=1){const n=t[r],i=n.accounts;i&&await this.resolveConst(i,[...e,pd(n.name)]);const o=n,s=pd(n.name);if(o.isSigner&&!this.get([...e,s])){if(void 0===this._provider.wallet)throw new Error("This function requires the Provider interface implementor to have a 'wallet' field.");this.set([...e,s],this._provider.wallet.publicKey)}Reflect.has(lv.CONST_ACCOUNTS,s)&&!this.get([...e,s])&&this.set([...e,s],lv.CONST_ACCOUNTS[s])}}_resolveEventCpi(t,e=[]){for(const r in t){const n=t[r],i=n.accounts;i&&this._resolveEventCpi(i,[...e,pd(n.name)]);const o=+r+1;if(o===t.length)return;const s=pd(t[r].name),a=pd(t[o].name);if("eventAuthority"===s&&"program"===a){const t=[...e,s],r=[...e,a];return this.get(t)||this.set(t,Wo.findProgramAddressSync([Buffer.from("__event_authority")],this._programId)[0]),void(this.get(r)||this.set(r,this._programId))}}}async resolvePdas(t,e=[]){let r=0;for(let n=0;n<t.length;n+=1){const i=t[n],o=i.accounts;o&&(r+=await this.resolvePdas(o,[...e,pd(i.name)]));const s=i,a=pd(i.name);s.pda&&s.pda.seeds.length>0&&!this.get([...e,a])&&Boolean(await this.autoPopulatePda(s,e))&&(r+=1)}return r}async resolveRelations(t,e=[]){let r=0;for(let n=0;n<t.length;n+=1){const i=t[n],o=i.accounts;o&&(r+=await this.resolveRelations(o,[...e,pd(i.name)]));const s=i.relations||[],a=pd(i.name),u=[...e,a],c=this.get(u);if(c){const t=s.filter((t=>!this.get([...e,pd(t)])));if(r+=t.length,t.length>0){const r=await this._accountStore.fetchAccount({publicKey:c});await Promise.all(t.map((async t=>{const n=pd(t);return this.set([...e,n],r[n]),r[n]})))}}}return r}async autoPopulatePda(t,e=[]){if(!t.pda||!t.pda.seeds)throw new Error("Must have seeds");const r=await Promise.all(t.pda.seeds.map((t=>this.toBuffer(t,e))));if(r.some((t=>void 0===t)))return;const n=await this.parseProgramId(t,e);if(!n)return;const[i]=await Wo.findProgramAddress(r,n);this.set([...e,pd(t.name)],i)}async parseProgramId(t,e=[]){var r;if(!(null===(r=t.pda)||void 0===r?void 0:r.programId))return this._programId;switch(t.pda.programId.kind){case"const":return new Wo(this.toBufferConst(t.pda.programId.value));case"arg":return this.argValue(t.pda.programId);case"account":return await this.accountValue(t.pda.programId,e);default:throw new Error(`Unexpected program seed kind: ${t.pda.programId.kind}`)}}async toBuffer(t,e=[]){switch(t.kind){case"const":return this.toBufferConst(t);case"arg":return await this.toBufferArg(t);case"account":return await this.toBufferAccount(t,e);default:throw new Error(`Unexpected seed kind: ${t.kind}`)}}getType(t,e=[]){if(e.length>0&&t.defined){const r=this._idlTypes.find((e=>e.name===t.defined));if(!r)throw new Error(`Cannot find type ${t.defined}`);const n=r.type.fields.find((t=>t.name===e[0]));return this.getType(n.type,e.slice(1))}return t}toBufferConst(t){return this.toBufferValue(this.getType(t.type,(t.path||"").split(".").slice(1)),t.value)}async toBufferArg(t){const e=this.argValue(t);if(void 0!==e)return this.toBufferValue(this.getType(t.type,(t.path||"").split(".").slice(1)),e)}argValue(t){const e=t.path.split("."),r=pd(e[0]),n=this._idlIx.args.findIndex((t=>t.name===r));if(-1===n)throw new Error(`Unable to find argument for seed: ${r}`);return e.slice(1).reduce(((t,e)=>(t||{})[e]),this._args[n])}async toBufferAccount(t,e=[]){const r=await this.accountValue(t,e);if(r)return this.toBufferValue(t.type,r)}async accountValue(t,e=[]){const r=t.path.split("."),n=r[0],i=this.get([...e,pd(n)]);if(null===i)throw new Error("fieldPubkey is null");if(1===r.length)return i;const o=await this._accountStore.fetchAccount({publicKey:i,name:t.account});return this.parseAccountValue(o,r.slice(1))}parseAccountValue(t,e){let r;for(;e.length>0;)r=t[pd(e[0])],e=e.slice(1);return r}toBufferValue(t,e){switch(t){case"u8":return Buffer.from([e]);case"u16":let r=Buffer.alloc(2);return r.writeUInt16LE(e),r;case"u32":let n=Buffer.alloc(4);return n.writeUInt32LE(e),n;case"u64":let i=Buffer.alloc(8);return i.writeBigUInt64LE(BigInt(e)),i;case"string":return Buffer.from(wm(e));case"publicKey":return e.toBuffer();default:if(t.array)return Buffer.from(e);throw new Error(`Unexpected seed type: ${t}`)}}}lv.CONST_ACCOUNTS={associatedTokenProgram:Ob,rent:ms,systemProgram:Os.programId,tokenProgram:Tb,clock:ds};class fv{constructor(t,e,r){this._provider=t,this._programId=r,this._cache=new Map,this._idls={},this._idls[r.toBase58()]=e}async ensureIdl(t){if(!this._idls[t.toBase58()]){const e=await bv.fetchIdl(t,this._provider);if(e){const r=new bv(e,t,this._provider);this._idls[t.toBase58()]=r.account}}return this._idls[t.toBase58()]}async fetchAccount({publicKey:t,name:e,programId:r=this._programId}){const n=t.toString();if(!this._cache.has(n))if("TokenAccount"===e){const e=await this._provider.connection.getAccountInfo(t);if(null===e)throw new Error(`invalid account info for ${n}`);const r=function(t){return hv.decode(t)}(e.data);this._cache.set(n,r)}else if(e){const i=await this.ensureIdl(r);if(i){const r=i[pd(e)];if(r){const e=await r.fetch(t);this._cache.set(n,e)}}}else{const e=await this._provider.connection.getAccountInfo(t);if(null===e)throw new Error(`invalid account info for ${n}`);const r=e.data,i=await this.ensureIdl(e.owner);if(i){const t=Object.values(i)[0];if(!t)throw new Error("No accounts for this program");const e=t.coder.accounts.decodeAny(r);this._cache.set(n,e)}}return this._cache.get(n)}}class dv{static build(t,e,r,n,i,o,s,a,u,c,h){return(...l)=>new gv(l,n,i,o,s,a,t,e,r,u,c,h)}}function pv(t){return"object"==typeof t&&null!==t&&!("_bn"in t)}function yv(t,e){const r={};for(const n in t){const i=t[n];if(null!==i)r[n]=pv(i)?yv(i,!0):Bm(i);else if(e)throw new Error("Failed to resolve optionals due to IDL type mismatch with input accounts!")}return r}class gv{constructor(t,e,r,n,i,o,s,a,u,c,h,l){this._ixFn=e,this._txFn=r,this._rpcFn=n,this._simulateFn=i,this._viewFn=o,this._programId=a,this._accounts={},this._remainingAccounts=[],this._signers=[],this._preInstructions=[],this._postInstructions=[],this._autoResolveAccounts=!0,this._args=t,this._accountsResolver=new lv(t,this._accounts,s,a,u,c,h,l)}args(t){this._args=t,this._accountsResolver.args(t)}async pubkeys(){return this._autoResolveAccounts&&await this._accountsResolver.resolve(),this._accounts}accounts(t){return this._autoResolveAccounts=!0,this._accountsResolver.resolveOptionals(t),this}accountsStrict(t){return this._autoResolveAccounts=!1,this._accountsResolver.resolveOptionals(t),this}signers(t){return this._signers=this._signers.concat(t),this}remainingAccounts(t){return this._remainingAccounts=this._remainingAccounts.concat(t),this}preInstructions(t){return this._preInstructions=this._preInstructions.concat(t),this}postInstructions(t){return this._postInstructions=this._postInstructions.concat(t),this}async rpc(t){return this._autoResolveAccounts&&await this._accountsResolver.resolve(),this._rpcFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions,options:t})}async rpcAndKeys(t){return{pubkeys:await this.pubkeys(),signature:await this.rpc(t)}}async view(t){if(this._autoResolveAccounts&&await this._accountsResolver.resolve(),!this._viewFn)throw new Error("Method does not support views");return this._viewFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions,options:t})}async simulate(t){return this._autoResolveAccounts&&await this._accountsResolver.resolve(),this._simulateFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions,options:t})}async instruction(){return this._autoResolveAccounts&&await this._accountsResolver.resolve(),this._ixFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions})}async prepare(){return{instruction:await this.instruction(),pubkeys:await this.pubkeys(),signers:await this._signers}}async transaction(){return this._autoResolveAccounts&&await this._accountsResolver.resolve(),this._txFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions})}}class mv{static build(t,e,r,n){const i=e.accounts.find((t=>t.isMut)),o=!!e.returns;if(i||!o)return;return async(...i)=>{var o,s;let a=await r(...i);const u=`Program return: ${t} `;let c=a.raw.find((t=>t.startsWith(u)));if(!c)throw new Error("View expected return log");let h=km(c.slice(u.length)),l=e.returns;if(!l)throw new Error("View expected return type");return Mw.fieldLayout({type:l},Array.from([...null!==(o=n.accounts)&&void 0!==o?o:[],...null!==(s=n.types)&&void 0!==s?s:[]])).decode(h)}}}class wv{static build(t,e,r,n,i){const o={},s={},a={},u={},c={},h={},l=Sm(t),f=t.accounts?Gb.build(t,e,r,n):{};return t.instructions.forEach((d=>{const p=Vb.build(d,((t,r)=>e.instruction.encode(t,r)),r),y=Hb.build(d,p),g=$b.build(d,y,l,n),m=nv.build(d,y,l,n,e,r,t),w=mv.build(r,d,m,t),b=dv.build(n,r,d,p,y,g,m,w,f,t.types||[],i&&i(d)),v=pd(d.name);s[v]=p,a[v]=y,o[v]=g,u[v]=m,c[v]=b,w&&(h[v]=w)})),[o,s,a,f,u,c,h]}}class bv{get programId(){return this._programId}get idl(){return this._idl}get coder(){return this._coder}get provider(){return this._provider}constructor(t,e,r,n,i){e=Bm(e),r||(r=cw()),this._idl=t,this._provider=r,this._programId=e,this._coder=null!=n?n:new Kw(t),this._events=new Qb(this._programId,r,this._coder);const[o,s,a,u,c,h,l]=wv.build(t,this._coder,e,r,null!=i?i:()=>{});this.rpc=o,this.instruction=s,this.transaction=a,this.account=u,this.simulate=c,this.methods=h,this.views=l}static async at(t,e){const r=Bm(t),n=await bv.fetchIdl(r,e);if(!n)throw new Error(`IDL not found for program: ${t.toString()}`);return new bv(n,r,e)}static async fetchIdl(t,e){e=null!=e?e:cw();const r=Bm(t),n=await async function(t){const e=(await Wo.findProgramAddress([],t))[0];return await Wo.createWithSeed(e,"anchor:idl",t)}(r),i=await e.connection.getAccountInfo(n);if(!i)return null;let o=(s=i.data.slice(8),Fb.decode(s));var s;const a=dm(o.data);return JSON.parse(mm(a))}addEventListener(t,e){return this._events.addEventListener(t,e)}async removeEventListener(t){return await this._events.removeEventListener(t)}}const vv=new Wo("11111111111111111111111111111111");function _v(t){return new bv(kv,vv,t,new Bb(kv))}const kv={version:"0.1.0",name:"system_program",instructions:[{name:"createAccount",accounts:[{name:"from",isMut:!0,isSigner:!0},{name:"to",isMut:!0,isSigner:!0}],args:[{name:"lamports",type:"u64"},{name:"space",type:"u64"},{name:"owner",type:"publicKey"}]},{name:"assign",accounts:[{name:"pubkey",isMut:!0,isSigner:!0}],args:[{name:"owner",type:"publicKey"}]},{name:"transfer",accounts:[{name:"from",isMut:!0,isSigner:!0},{name:"to",isMut:!0,isSigner:!1}],args:[{name:"lamports",type:"u64"}]},{name:"createAccountWithSeed",accounts:[{name:"from",isMut:!0,isSigner:!0},{name:"to",isMut:!0,isSigner:!1},{name:"base",isMut:!1,isSigner:!0}],args:[{name:"base",type:"publicKey"},{name:"seed",type:"string"},{name:"lamports",type:"u64"},{name:"space",type:"u64"},{name:"owner",type:"publicKey"}]},{name:"advanceNonceAccount",accounts:[{name:"nonce",isMut:!0,isSigner:!1},{name:"recentBlockhashes",isMut:!1,isSigner:!1},{name:"authorized",isMut:!1,isSigner:!0}],args:[{name:"authorized",type:"publicKey"}]},{name:"withdrawNonceAccount",accounts:[{name:"nonce",isMut:!0,isSigner:!1},{name:"to",isMut:!0,isSigner:!1},{name:"recentBlockhashes",isMut:!1,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"authorized",isMut:!1,isSigner:!0}],args:[{name:"lamports",type:"u64"}]},{name:"initializeNonceAccount",accounts:[{name:"nonce",isMut:!0,isSigner:!0},{name:"recentBlockhashes",isMut:!1,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1}],args:[{name:"authorized",type:"publicKey"}]},{name:"authorizeNonceAccount",accounts:[{name:"nonce",isMut:!0,isSigner:!1},{name:"authorized",isMut:!1,isSigner:!0}],args:[{name:"authorized",type:"publicKey"}]},{name:"allocate",accounts:[{name:"pubkey",isMut:!0,isSigner:!0}],args:[{name:"space",type:"u64"}]},{name:"allocateWithSeed",accounts:[{name:"account",isMut:!0,isSigner:!1},{name:"base",isMut:!1,isSigner:!0}],args:[{name:"base",type:"publicKey"},{name:"seed",type:"string"},{name:"space",type:"u64"},{name:"owner",type:"publicKey"}]},{name:"assignWithSeed",accounts:[{name:"account",isMut:!0,isSigner:!1},{name:"base",isMut:!1,isSigner:!0}],args:[{name:"base",type:"publicKey"},{name:"seed",type:"string"},{name:"owner",type:"publicKey"}]},{name:"transferWithSeed",accounts:[{name:"from",isMut:!0,isSigner:!1},{name:"base",isMut:!1,isSigner:!0},{name:"to",isMut:!0,isSigner:!1}],args:[{name:"lamports",type:"u64"},{name:"seed",type:"string"},{name:"owner",type:"publicKey"}]}],accounts:[{name:"nonce",type:{kind:"struct",fields:[{name:"version",type:"u32"},{name:"state",type:"u32"},{name:"authorizedPubkey",type:"publicKey"},{name:"nonce",type:"publicKey"},{name:"feeCalculator",type:{defined:"FeeCalculator"}}]}}],types:[{name:"FeeCalculator",type:{kind:"struct",fields:[{name:"lamportsPerSignature",type:"u64"}]}}]};var Ev,xv=r(Object.freeze({__proto__:null,web3:pc,AccountClient:Zb,AnchorError:mw,AnchorProvider:ow,BorshAccountsCoder:zw,BorshCoder:Kw,BorshEventCoder:Dw,BorshInstructionCoder:Pw,DISCRIMINATOR_SIZE:Cw,EventManager:Qb,EventParser:tv,IdlError:yw,LangErrorCode:vw,LangErrorMessage:_w,MethodsBuilderFactory:dv,Native:class{static system(t){return _v(t)}},Program:bv,ProgramError:ww,ProgramErrorStack:gw,SystemCoder:Bb,eventDiscriminator:jw,getProvider:cw,parseIdlErrors:Sm,setProvider:function(t){hw=t},splitArgsAndCtx:qb,toInstruction:Am,translateAddress:Bm,translateError:bw,utils:Wb,validateAccounts:Im,BN:ne})),Sv={},Av={};var Iv,Bv={};function Mv(){if(Iv)return Bv;Iv=1;var e=t&&t.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){t.done?i(t.value):function(t){return t instanceof r?t:new r((function(e){e(t)}))}(t.value).then(s,a)}u((n=n.apply(t,e||[])).next())}))},r=t&&t.__generator||function(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}};Object.defineProperty(Bv,"__esModule",{value:!0}),Bv.PythOracleAccountCoder=void 0;var n=function(){function t(t){this.idl=t}return t.prototype.encode=function(t,n){return e(this,void 0,void 0,(function(){return r(this,(function(t){throw new Error("Not implemented")}))}))},t.prototype.decode=function(t,e){throw new Error("Not implemented")},t.prototype.decodeUnchecked=function(t,e){throw new Error("Not implemented")},t.prototype.memcmp=function(t,e){throw new Error("Not implemented")},t.prototype.size=function(t){return 0},t}();return Bv.PythOracleAccountCoder=n,Bv}var Rv={};var Pv=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r<e.length;r++)e[r]=255;for(var n=0;n<t.length;n++){var i=t.charAt(n),o=i.charCodeAt(0);if(255!==e[o])throw new TypeError(i+" is ambiguous");e[o]=n}var s=t.length,a=t.charAt(0),u=Math.log(s)/Math.log(256),c=Math.log(256)/Math.log(s);function h(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return new Uint8Array;for(var r=0,n=0,i=0;t[r]===a;)n++,r++;for(var o=(t.length-r)*u+1>>>0,c=new Uint8Array(o);t[r];){var h=e[t.charCodeAt(r)];if(255===h)return;for(var l=0,f=o-1;(0!==h||l<i)&&-1!==f;f--,l++)h+=s*c[f]>>>0,c[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===c[d];)d++;for(var p=new Uint8Array(n+(o-d)),y=n;d!==o;)p[y++]=c[d++];return p}return{encode:function(e){if(e instanceof Uint8Array||(ArrayBuffer.isView(e)?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Array.isArray(e)&&(e=Uint8Array.from(e))),!(e instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===e.length)return"";for(var r=0,n=0,i=0,o=e.length;i!==o&&0===e[i];)i++,r++;for(var u=(o-i)*c+1>>>0,h=new Uint8Array(u);i!==o;){for(var l=e[i],f=0,d=u-1;(0!==l||f<n)&&-1!==d;d--,f++)l+=256*h[d]>>>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=u-n;p!==u&&0===h[p];)p++;for(var y=a.repeat(r);p<u;++p)y+=t.charAt(h[p]);return y},decodeUnsafe:h,decode:function(t){var e=h(t);if(e)return e;throw new Error("Non-base"+s+" character")}}};var Tv,Ov,Lv=Pv("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),Uv=e(Lv),Cv={};function Nv(){if(Ov)return Rv;Ov=1;var e=t&&t.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),r=t&&t.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),i=t&&t.__importStar||function(t){if(t&&t.__esModule)return t;var n={};if(null!=t)for(var i in t)"default"!==i&&Object.prototype.hasOwnProperty.call(t,i)&&e(n,t,i);return r(n,t),n},o=t&&t.__spreadArray||function(t,e){for(var r=0,n=e.length,i=t.length;r<n;r++,i++)t[i]=e[r];return t},s=t&&t.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Rv,"__esModule",{value:!0}),Rv.PythOracleInstructionCoder=void 0;var a=s(Lv),u=n,c=s(dd()),h=i(yd),l=function(){if(Tv)return Cv;Tv=1;var e=t&&t.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),r=t&&t.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),n=t&&t.__importStar||function(t){if(t&&t.__esModule)return t;var n={};if(null!=t)for(var i in t)"default"!==i&&Object.prototype.hasOwnProperty.call(t,i)&&e(n,t,i);return r(n,t),n},i=t&&t.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Cv,"__esModule",{value:!0}),Cv.IdlCoder=void 0;var o=i(dd()),s=n(yd),a=xv,u=function(){function t(){}return t.fieldLayout=function(e,r){var n=void 0!==e.name?o.default(e.name):void 0;switch(e.type){case"bool":return s.bool(n);case"u8":return s.u8(n);case"i8":return s.i8(n);case"u16":return s.u16(n);case"i16":return s.i16(n);case"u32":return s.u32(n);case"i32":return s.i32(n);case"f32":return s.f32(n);case"u64":return s.u64(n);case"i64":return s.i64(n);case"f64":return s.f64(n);case"u128":return s.u128(n);case"i128":return s.i128(n);case"u256":return s.u256(n);case"i256":return s.i256(n);case"bytes":return s.vecU8(n);case"string":return s.str(n);case"publicKey":return s.publicKey(n);default:if("vec"in e.type)return s.vec(t.fieldLayout({name:void 0,type:e.type.vec},r),n);if("option"in e.type)return s.option(t.fieldLayout({name:void 0,type:e.type.option},r),n);if("defined"in e.type){var i=e.type.defined;if(void 0===r)throw new a.IdlError("User defined types not provided");var u=r.filter((function(t){return t.name===i}));if(1!==u.length)throw new a.IdlError("Type not found: "+JSON.stringify(e));return t.typeDefLayout(u[0],r,n)}if("array"in e.type){var c=e.type.array[0],h=e.type.array[1],l=t.fieldLayout({name:void 0,type:c},r);return s.array(l,h,n)}throw new Error("Not yet implemented: "+e)}},t.typeDefLayout=function(e,r,n){if(void 0===r&&(r=[]),"struct"===e.type.kind){var i=e.type.fields.map((function(e){return t.fieldLayout(e,r)}));return s.struct(i,n)}if("enum"===e.type.kind){var a=e.type.variants.map((function(e){var n=o.default(e.name);if(void 0===e.fields)return s.struct([],n);var i=e.fields.map((function(e,n){return e.hasOwnProperty("name")?t.fieldLayout(e,r):t.fieldLayout({type:e,name:n.toString()},r)}));return s.struct(i,n)}));return void 0!==n?s.rustEnum(a).replicate(n):s.rustEnum(a,n)}throw new Error("Unknown type kint: "+e)},t}();return Cv.IdlCoder=u,Cv}(),f=function(){function t(e){var r=this;this.idl=e,this.ixLayout=t.parseIxLayout(e);var n=new Map,i=new Map;e.instructions.forEach((function(t){var e,o=t;if(!o.discriminant)throw new Error("All instructions must have a discriminator");if(n.set(a.default.encode(u.Buffer.from(o.discriminant.value)),{layout:r.ixLayout.get(o.name),name:o.name}),i.set(o.name,u.Buffer.from(o.discriminant.value)),e=o.discriminant.value.length,r.discriminatorLength&&r.discriminatorLength!==e)throw new Error("All instructions must have the same discriminator length");r.discriminatorLength=e})),this.discriminatorLayouts=n,this.ixDiscriminator=i}return t.prototype.encodeState=function(t,e){return this.encode(t,e)},t.prototype.encode=function(t,e){var r=u.Buffer.alloc(1e3),n=c.default(t),i=this.ixLayout.get(n),o=this.ixDiscriminator.get(n);if(!i||!o)throw new Error("Unknown method: "+n);if("updProduct"===n||"addProduct"===n){for(var s=0,a=0,h=Object.keys(e.productMetadata);a<h.length;a++){var l=h[a];s+=r.subarray(s).writeInt8(l.length),s+=r.subarray(s).write(l),s+=r.subarray(s).writeInt8(e.productMetadata[l].length),s+=r.subarray(s).write(e.productMetadata[l])}if(s>464)throw new Error("The metadata is too long");var f=r.subarray(0,s);return u.Buffer.concat([o,f])}var d=i.encode(e,r);f=r.subarray(0,d);return u.Buffer.concat([o,f])},t.parseIxLayout=function(t){var e=t.instructions.map((function(e){var r=e.args.map((function(e){var r,n;return l.IdlCoder.fieldLayout(e,Array.from(o(o([],null!==(r=t.accounts)&&void 0!==r?r:[]),null!==(n=t.types)&&void 0!==n?n:[])))})),n=c.default(e.name);return[n,h.struct(r,n)]}));return new Map(e)},t.prototype.decode=function(t,e){void 0===e&&(e="hex"),"string"==typeof t&&(t="hex"===e?u.Buffer.from(t,"hex"):u.Buffer.from(a.default.decode(t)));var r=a.default.encode(t.subarray(0,this.discriminatorLength)),n=t.subarray(this.discriminatorLength),i=this.discriminatorLayouts.get(r);if(!i)return null;if("updProduct"===i.name||"addProduct"===i.name){for(var o={},s=0;s<n.length;){var c=n[s];if(s++,c){var h=n.slice(s,s+c).toString(),l=n[s+=c];s++;var f=n.slice(s,s+l).toString();s+=l,o[h]=f}}return{data:o,name:i.name}}return{data:i.layout.decode(n),name:i.name}},t}();return Rv.PythOracleInstructionCoder=f,Rv}var zv,Dv={};var jv,Wv,Kv={};function Fv(){if(Wv)return Sv;Wv=1,Object.defineProperty(Sv,"__esModule",{value:!0}),Sv.PythOracleCoder=void 0;var t=function(){if(Ev)return Av;Ev=1,Object.defineProperty(Av,"__esModule",{value:!0}),Av.PythOracleEventCoder=void 0;var t=function(){function t(){}return t.prototype.decode=function(t){throw new Error("Pyth oracle program does not have events")},t}();return Av.PythOracleEventCoder=t,Av}(),e=Mv(),r=Nv(),n=function(){if(zv)return Dv;zv=1,Object.defineProperty(Dv,"__esModule",{value:!0}),Dv.PythOracleStateCoder=void 0;var t=function(){function t(){}return t.prototype.encode=function(t,e){throw new Error("Not implemented")},t.prototype.decode=function(t){throw new Error("Not implemented")},t}();return Dv.PythOracleStateCoder=t,Dv}(),i=function(){if(jv)return Kv;jv=1,Object.defineProperty(Kv,"__esModule",{value:!0}),Kv.PythOracleTypesCoder=void 0;var t=function(){function t(){}return t.prototype.encode=function(t,e){throw new Error("Not implemented")},t.prototype.decode=function(t,e){throw new Error("Not implemented")},t}();return Kv.PythOracleTypesCoder=t,Kv}(),o=function(o){this.accounts=new e.PythOracleAccountCoder(o),this.events=new t.PythOracleEventCoder,this.instruction=new r.PythOracleInstructionCoder(o),this.state=new n.PythOracleStateCoder,this.types=new i.PythOracleTypesCoder};return Sv.PythOracleCoder=o,Sv}var qv,Vv,Hv,$v={version:"2.20.0",name:"pyth_oracle",instructions:[{name:"initMapping",discriminant:{value:[2,0,0,0,0,0,0,0]},accounts:[{name:"fundingAccount",isMut:!0,isSigner:!0},{name:"freshMappingAccount",isMut:!0,isSigner:!1},{name:"permissionsAccount",isMut:!1,isSigner:!1,pda:{seeds:[{kind:"const",type:"string",value:"permissions"}]}}],args:[]},{name:"addMapping",discriminant:{value:[2,0,0,0,1,0,0,0]},accounts:[{name:"fundingAccount",isMut:!0,isSigner:!0},{name:"curMapping",isMut:!0,isSigner:!1},{name:"nextMapping",isMut:!0,isSigner:!1},{name:"permissionsAccount",isMut:!1,isSigner:!1,pda:{seeds:[{kind:"const",type:"string",value:"permissions"}]}}],args:[]},{name:"addProduct",discriminant:{value:[2,0,0,0,2,0,0,0]},accounts:[{name:"fundingAccount",isMut:!0,isSigner:!0},{name:"tailMappingAccount",isMut:!0,isSigner:!1},{name:"productAccount",isMut:!0,isSigner:!1},{name:"permissionsAccount",isMut:!1,isSigner:!1,pda:{seeds:[{kind:"const",type:"string",value:"permissions"}]}}],args:[{name:"productMetadata",type:{defined:"ProductMetadata"}}]},{name:"updProduct",discriminant:{value:[2,0,0,0,3,0,0,0]},accounts:[{name:"fundingAccount",isMut:!0,isSigner:!0},{name:"productAccount",isMut:!0,isSigner:!1},{name:"permissionsAccount",isMut:!1,isSigner:!1,pda:{seeds:[{kind:"const",type:"string",value:"permissions"}]}}],args:[{name:"productMetadata",type:{defined:"ProductMetadata"}}]},{name:"addPrice",discriminant:{value:[2,0,0,0,4,0,0,0]},accounts:[{name:"fundingAccount",isMut:!0,isSigner:!0},{name:"productAccount",isMut:!0,isSigner:!1},{name:"priceAccount",isMut:!0,isSigner:!1},{name:"permissionsAccount",isMut:!1,isSigner:!1,pda:{seeds:[{kind:"const",type:"string",value:"permissions"}]}}],args:[{name:"expo",type:"i32"},{name:"pType",type:"u32"}]},{name:"addPublisher",discriminant:{value:[2,0,0,0,5,0,0,0]},accounts:[{name:"fundingAccount",isMut:!0,isSigner:!0},{name:"priceAccount",isMut:!0,isSigner:!1},{name:"permissionsAccount",isMut:!1,isSigner:!1,pda:{seeds:[{kind:"const",type:"string",value:"permissions"}]}}],args:[{name:"pub",type:"publicKey"}]},{name:"delPublisher",discriminant:{value:[2,0,0,0,6,0,0,0]},accounts:[{name:"fundingAccount",isMut:!0,isSigner:!0},{name:"priceAccount",isMut:!0,isSigner:!1},{name:"permissionsAccount",isMut:!1,isSigner:!1,pda:{seeds:[{kind:"const",type:"string",value:"permissions"}]}}],args:[{name:"pub",type:"publicKey"}]},{name:"updPrice",discriminant:{value:[2,0,0,0,7,0,0,0]},accounts:[{name:"fundingAccount",isMut:!0,isSigner:!0},{name:"priceAccount",isMut:!0,isSigner:!1},{name:"clock",isMut:!1,isSigner:!1}],args:[{name:"status",type:"u32"},{name:"unused",type:"u32"},{name:"price",type:"i64"},{name:"conf",type:"u64"},{name:"pubSlot",type:"u64"}]},{name:"aggPrice",discriminant:{value:[2,0,0,0,8,0,0,0]},accounts:[{name:"fundingAccount",isMut:!0,isSigner:!0},{name:"priceAccount",isMut:!0,isSigner:!1},{name:"clock",isMut:!1,isSigner:!1}],args:[{name:"status",type:"u32"},{name:"unused",type:"u32"},{name:"price",type:"i64"},{name:"conf",type:"u64"},{name:"pubSlot",type:"u64"}]},{name:"setExponent",discriminant:{value:[2,0,0,0,9,0,0,0]},accounts:[{name:"fundingAccount",isMut:!0,isSigner:!0},{name:"priceAccount",isMut:!0,isSigner:!1},{name:"permissionsAccount",isMut:!1,isSigner:!1,pda:{seeds:[{kind:"const",type:"string",value:"permissions"}]}}],args:[{name:"expo",type:"i32"},{name:"pType",type:"u32"}]},{name:"setMinPub",discriminant:{value:[2,0,0,0,12,0,0,0]},accounts:[{name:"fundingAccount",isMut:!0,isSigner:!0},{name:"priceAccount",isMut:!0,isSigner:!1},{name:"permissionsAccount",isMut:!1,isSigner:!1,pda:{seeds:[{kind:"const",type:"string",value:"permissions"}]}}],args:[{name:"minPub",type:"u8"},{name:"unused",type:{array:["u8",3]}}]},{name:"updPriceNoFailOnError",discriminant:{value:[2,0,0,0,13,0,0,0]},accounts:[{name:"fundingAccount",isMut:!0,isSigner:!0},{name:"priceAccount",isMut:!0,isSigner:!1},{name:"clock",isMut:!1,isSigner:!1}],args:[{name:"status",type:"u32"},{name:"unused",type:"u32"},{name:"price",type:"i64"},{name:"conf",type:"u64"},{name:"pubSlot",type:"u64"}]},{name:"delPrice",discriminant:{value:[2,0,0,0,15,0,0,0]},accounts:[{name:"fundingAccount",isMut:!0,isSigner:!0},{name:"productAccount",isMut:!0,isSigner:!1},{name:"priceAccount",isMut:!0,isSigner:!1},{name:"permissionsAccount",isMut:!1,isSigner:!1,pda:{seeds:[{kind:"const",type:"string",value:"permissions"}]}}],args:[]},{name:"delProduct",discriminant:{value:[2,0,0,0,16,0,0,0]},accounts:[{name:"fundingAccount",isMut:!0,isSigner:!0},{name:"mappingAccount",isMut:!0,isSigner:!1},{name:"productAccount",isMut:!0,isSigner:!1},{name:"permissionsAccount",isMut:!1,isSigner:!1,pda:{seeds:[{kind:"const",type:"string",value:"permissions"}]}}],args:[]},{name:"updPermissions",discriminant:{value:[2,0,0,0,17,0,0,0]},accounts:[{name:"upgradeAuthority",isMut:!0,isSigner:!0},{name:"programDataAccount",isMut:!1,isSigner:!1},{name:"permissionsAccount",isMut:!0,isSigner:!1,pda:{seeds:[{kind:"const",type:"string",value:"permissions"}]}},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[{name:"masterAuthority",type:"publicKey"},{name:"dataCurationAuthority",type:"publicKey"},{name:"securityAuthority",type:"publicKey"}]}],types:[{name:"ProductMetadata",type:{kind:"struct",fields:[]}}]};function Gv(){return Vv||(Vv=1,function(e){var r=t&&t.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),n=t&&t.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||r(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),n((qv||(qv=1,function(e){var r=t&&t.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.pythIdl=e.pythOracleCoder=e.pythOracleProgram=void 0;var n=xv,i=Fv(),o=r($v);e.pythOracleProgram=function(t,e){return new n.Program(o.default,t,e,new i.PythOracleCoder(o.default))},e.pythOracleCoder=function(){return new i.PythOracleCoder(o.default)};var s=$v;Object.defineProperty(e,"pythIdl",{enumerable:!0,get:function(){return r(s).default}})}(hd)),hd),e)}(cd)),cd}function Zv(){return Hv||(Hv=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.pythIdl=t.pythOracleCoder=t.pythOracleProgram=t.getPythClusterApiUrl=t.getPythProgramKeyForCluster=t.PythHttpClient=t.PythConnection=t.parsePermissionData=t.parsePriceData=t.parseProductData=t.parseMappingData=t.parseBaseData=t.AccountType=t.DeriveType=t.PriceType=t.CorpAction=t.PriceStatus=t.MAX_SLOT_DIFFERENCE=t.Version=t.Version2=t.Magic=void 0;var e,r,i,o,s=$f,a=n,u=Gf;t.Magic=2712847316,t.Version2=2,t.Version=t.Version2,t.MAX_SLOT_DIFFERENCE=25,function(t){t[t.Unknown=0]="Unknown",t[t.Trading=1]="Trading",t[t.Halted=2]="Halted",t[t.Auction=3]="Auction",t[t.Ignored=4]="Ignored"}(e=t.PriceStatus||(t.PriceStatus={})),(r=t.CorpAction||(t.CorpAction={}))[r.NoCorpAct=0]="NoCorpAct",(i=t.PriceType||(t.PriceType={}))[i.Unknown=0]="Unknown",i[i.Price=1]="Price",(o=t.DeriveType||(t.DeriveType={}))[o.Unknown=0]="Unknown",o[o.Volatility=1]="Volatility",function(t){t[t.Unknown=0]="Unknown",t[t.Mapping=1]="Mapping",t[t.Product=2]="Product",t[t.Price=3]="Price",t[t.Test=4]="Test",t[t.Permission=5]="Permission"}(t.AccountType||(t.AccountType={}));var c=a.Buffer.alloc(32),h=function(t){return t.equals(c)?null:new s.PublicKey(t)};t.parseBaseData=function(e){if(!(e.byteLength<4)){var r=e.readUInt32LE(0);return r===t.Magic?{magic:r,version:e.readUInt32LE(4),type:e.readUInt32LE(8),size:e.readUInt32LE(12)}:void 0}};t.parseMappingData=function(t){for(var e=t.readUInt32LE(0),r=t.readUInt32LE(4),n=t.readUInt32LE(8),i=t.readUInt32LE(12),o=t.readUInt32LE(16),a=h(t.slice(24,56)),u=56,c=[],l=0;l<o;l++){var f=t.slice(u,u+32),d=new s.PublicKey(f);u+=32,c.push(d)}return{magic:e,version:r,type:n,size:i,nextMappingAccount:a,productAccountKeys:c}};t.parseProductData=function(t){var e=t.readUInt32LE(0),r=t.readUInt32LE(4),n=t.readUInt32LE(8),i=t.readUInt32LE(12),o=t.slice(16,48),s=h(o),a={};s&&(a.price_account=s.toBase58());for(var u=48;u<i;){var c=t[u];if(u++,c){var l=t.slice(u,u+c).toString(),f=t[u+=c];u++;var d=t.slice(u,u+f).toString();u+=f,a[l]=d}}return{magic:e,version:r,type:n,size:i,priceAccountKey:s,product:a}};var l=function(t,e){var r=u.readBigInt64LE(t,0);return{valueComponent:r,value:Number(r)*Math.pow(10,e),numerator:u.readBigInt64LE(t,8),denominator:u.readBigInt64LE(t,16)}},f=function(t,e){var r=u.readBigInt64LE(t,0),n=Number(r)*Math.pow(10,e),i=u.readBigUInt64LE(t,8);return{priceComponent:r,price:n,confidenceComponent:i,confidence:Number(i)*Math.pow(10,e),status:t.readUInt32LE(16),corporateAction:t.readUInt32LE(20),publishSlot:Number(u.readBigUInt64LE(t,24))}};t.parsePriceData=function(r,n){var i,o,a=r.readUInt32LE(0),c=r.readUInt32LE(4),d=r.readUInt32LE(8),p=r.readUInt32LE(12),y=r.readUInt32LE(16),g=r.readInt32LE(20),m=r.readUInt32LE(24),w=r.readUInt32LE(28),b=u.readBigUInt64LE(r,32),v=u.readBigUInt64LE(r,40),_=l(r.slice(48,72),g),k=l(r.slice(72,96),g),E=u.readBigInt64LE(r,96),x=r.readUInt8(104),S=r.readInt8(105),A=r.readInt16LE(106),I=r.readInt32LE(108),B=new s.PublicKey(r.slice(112,144)),M=h(r.slice(144,176)),R=u.readBigUInt64LE(r,176),P=u.readBigInt64LE(r,184),T=Number(P)*Math.pow(10,g),O=u.readBigUInt64LE(r,192),L=Number(O)*Math.pow(10,g),U=u.readBigInt64LE(r,200),C=f(r.slice(208,240),g),N=C.status;n&&N===e.Trading&&n-C.publishSlot>t.MAX_SLOT_DIFFERENCE&&(N=e.Unknown),N===e.Trading&&(i=C.price,o=C.confidence);for(var z=[],D=240;z.length<m;){var j=new s.PublicKey(r.slice(D,D+32));D+=32;var W=f(r.slice(D,D+32),g);D+=32;var K=f(r.slice(D,D+32),g);D+=32,z.push({publisher:j,aggregate:W,latest:K})}return{magic:a,version:c,type:d,size:p,priceType:y,exponent:g,numComponentPrices:m,numQuoters:w,lastSlot:b,validSlot:v,emaPrice:_,emaConfidence:k,timestamp:E,minPublishers:x,drv2:S,drv3:A,drv4:I,productAccountKey:B,nextPriceAccountKey:M,previousSlot:R,previousPriceComponent:P,previousPrice:T,previousConfidenceComponent:O,previousConfidence:L,previousTimestamp:U,aggregate:C,priceComponents:z,price:i,confidence:o,status:N}};t.parsePermissionData=function(t){return{magic:t.readUInt32LE(0),version:t.readUInt32LE(4),type:t.readUInt32LE(8),size:t.readUInt32LE(12),masterAuthority:new s.PublicKey(t.slice(16,48)),dataCurationAuthority:new s.PublicKey(t.slice(48,80)),securityAuthority:new s.PublicKey(t.slice(80,112))}};var d=rd();Object.defineProperty(t,"PythConnection",{enumerable:!0,get:function(){return d.PythConnection}});var p=od();Object.defineProperty(t,"PythHttpClient",{enumerable:!0,get:function(){return p.PythHttpClient}});var y=function(){if(sd)return ad;sd=1,Object.defineProperty(ad,"__esModule",{value:!0}),ad.getPythClusterApiUrl=ad.getPythProgramKeyForCluster=void 0;var t=$f,e={"mainnet-beta":"FsJ3A3u2vn5cTVofAjvy6y5kwABJAqYWpe4975bi2epH",devnet:"gSbePebfvPy7tRqimPoVecS2UsBvYv46ynrzWocc92s","pythtest-crosschain":"gSbePebfvPy7tRqimPoVecS2UsBvYv46ynrzWocc92s",testnet:"8tfDNiaEyrV6Q1U4DEXrEigs9DoDtkugzFbybENEbCDz","pythtest-conformance":"8tfDNiaEyrV6Q1U4DEXrEigs9DoDtkugzFbybENEbCDz",pythnet:"FsJ3A3u2vn5cTVofAjvy6y5kwABJAqYWpe4975bi2epH",localnet:"gMYYig2utAxVoXnM9UhtTWrt8e7x2SVBZqsWZJeT5Gw"};return ad.getPythProgramKeyForCluster=function(r){if(void 0!==e[r])return new t.PublicKey(e[r]);throw new Error("Invalid Solana cluster name: "+r+". Valid options are: "+JSON.stringify(Object.keys(e)))},ad.getPythClusterApiUrl=function(e){return"pythtest-conformance"===e||"pythtest-crosschain"===e?"https://api.pythtest.pyth.network":"pythnet"===e?"https://pythnet.rpcpool.com":"localnet"===e?"http://localhost:8899":t.clusterApiUrl(e)},ad}();Object.defineProperty(t,"getPythProgramKeyForCluster",{enumerable:!0,get:function(){return y.getPythProgramKeyForCluster}}),Object.defineProperty(t,"getPythClusterApiUrl",{enumerable:!0,get:function(){return y.getPythClusterApiUrl}});var g=Gv();Object.defineProperty(t,"pythOracleProgram",{enumerable:!0,get:function(){return g.pythOracleProgram}}),Object.defineProperty(t,"pythOracleCoder",{enumerable:!0,get:function(){return g.pythOracleCoder}}),Object.defineProperty(t,"pythIdl",{enumerable:!0,get:function(){return g.pythIdl}})}(Hf)),Hf}var Yv=Zv(),Jv="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Xv(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Qv(t){if(t.__esModule)return t;var e=t.default;if("function"==typeof e){var r=function t(){return this instanceof t?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach((function(e){var n=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(r,e,n.get?n:{enumerable:!0,get:function(){return t[e]}})})),r}for(var t_={},e_={byteLength:function(t){var e=a_(t),r=e[0],n=e[1];return 3*(r+n)/4-n},toByteArray:function(t){var e,r,n=a_(t),i=n[0],o=n[1],s=new i_(function(t,e,r){return 3*(e+r)/4-r}(0,i,o)),a=0,u=o>0?i-4:i;for(r=0;r<u;r+=4)e=n_[t.charCodeAt(r)]<<18|n_[t.charCodeAt(r+1)]<<12|n_[t.charCodeAt(r+2)]<<6|n_[t.charCodeAt(r+3)],s[a++]=e>>16&255,s[a++]=e>>8&255,s[a++]=255&e;return 2===o&&(e=n_[t.charCodeAt(r)]<<2|n_[t.charCodeAt(r+1)]>>4,s[a++]=255&e),1===o&&(e=n_[t.charCodeAt(r)]<<10|n_[t.charCodeAt(r+1)]<<4|n_[t.charCodeAt(r+2)]>>2,s[a++]=e>>8&255,s[a++]=255&e),s},fromByteArray:function(t){for(var e,r=t.length,n=r%3,i=[],o=16383,s=0,a=r-n;s<a;s+=o)i.push(u_(t,s,s+o>a?a:s+o));return 1===n?(e=t[r-1],i.push(r_[e>>2]+r_[e<<4&63]+"==")):2===n&&(e=(t[r-2]<<8)+t[r-1],i.push(r_[e>>10]+r_[e>>4&63]+r_[e<<2&63]+"=")),i.join("")}},r_=[],n_=[],i_="undefined"!=typeof Uint8Array?Uint8Array:Array,o_="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s_=0;s_<64;++s_)r_[s_]=o_[s_],n_[o_.charCodeAt(s_)]=s_;function a_(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function u_(t,e,r){for(var n,i,o=[],s=e;s<r;s+=3)n=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]),o.push(r_[(i=n)>>18&63]+r_[i>>12&63]+r_[i>>6&63]+r_[63&i]);return o.join("")}n_["-".charCodeAt(0)]=62,n_["_".charCodeAt(0)]=63;var c_={};
|
|
24
|
+
const _o=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),ko=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Eo=BigInt(1),xo=BigInt(2),So=(t,e)=>(t+e/xo)/e;const Ao=Bt(_o,void 0,void 0,{sqrt:function(t){const e=_o,r=BigInt(3),n=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),a=BigInt(44),u=BigInt(88),c=t*t*t%e,h=c*c*t%e,l=Et(h,r,e)*h%e,f=Et(l,r,e)*h%e,d=Et(f,xo,e)*c%e,p=Et(d,i,e)*d%e,y=Et(p,o,e)*p%e,g=Et(y,a,e)*y%e,m=Et(g,u,e)*g%e,w=Et(m,a,e)*y%e,b=Et(w,r,e)*h%e,v=Et(b,s,e)*p%e,_=Et(v,n,e)*c%e,k=Et(_,xo,e);if(!Ao.eql(Ao.sqr(k),t))throw new Error("Cannot find square root");return k}}),Io=function(t,e){const r=e=>mo({...t,...vo(e)});return Object.freeze({...r(e),create:r})}({a:BigInt(0),b:BigInt(7),Fp:Ao,n:ko,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=ko,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Eo*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=r,s=BigInt("0x100000000000000000000000000000000"),a=So(o*t,e),u=So(-n*t,e);let c=_t(t-a*r-u*i,e),h=_t(-a*n-u*o,e);const l=c>s,f=h>s;if(l&&(c=e-c),f&&(h=e-h),c>s||h>s)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:l,k1:c,k2neg:f,k2:h}}}},pe);BigInt(0),Io.ProjectivePoint;const Bo=Xt.utils.randomPrivateKey,Mo=()=>{const t=Xt.utils.randomPrivateKey(),e=Ro(t),r=new Uint8Array(64);return r.set(t),r.set(e,32),{publicKey:e,secretKey:r}},Ro=Xt.getPublicKey;function Po(t){try{return Xt.ExtendedPoint.fromHex(t),!0}catch{return!1}}const To=(t,e)=>Xt.sign(t,e.slice(0,32)),Lo=Xt.verify,Oo=t=>n.Buffer.isBuffer(t)?t:t instanceof Uint8Array?n.Buffer.from(t.buffer,t.byteOffset,t.byteLength):n.Buffer.from(t);class Uo{constructor(t){Object.assign(this,t)}encode(){return n.Buffer.from(He(Co,this))}static decode(t){return Ze(Co,this,t)}static decodeUnchecked(t){return Le(Co,this,t)}}const Co=new Map;var No;let zo;const Do=32;let jo=1;zo=Symbol.toStringTag;class Wo extends Uo{constructor(t){if(super({}),this._bn=void 0,function(t){return void 0!==t._bn}(t))this._bn=t._bn;else{if("string"==typeof t){const e=ae.decode(t);if(e.length!=Do)throw new Error("Invalid public key input");this._bn=new ne(e)}else this._bn=new ne(t);if(this._bn.byteLength()>Do)throw new Error("Invalid public key input")}}static unique(){const t=new Wo(jo);return jo+=1,new Wo(t.toBuffer())}equals(t){return this._bn.eq(t._bn)}toBase58(){return ae.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){const t=this.toBuffer();return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}toBuffer(){const t=this._bn.toArrayLike(n.Buffer);if(t.length===Do)return t;const e=n.Buffer.alloc(32);return t.copy(e,32-t.length),e}get[zo](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(t,e,r){const i=n.Buffer.concat([t.toBuffer(),n.Buffer.from(e),r.toBuffer()]),o=pe(i);return new Wo(o)}static createProgramAddressSync(t,e){let r=n.Buffer.alloc(0);t.forEach((function(t){if(t.length>32)throw new TypeError("Max seed length exceeded");r=n.Buffer.concat([r,Oo(t)])})),r=n.Buffer.concat([r,e.toBuffer(),n.Buffer.from("ProgramDerivedAddress")]);const i=pe(r);if(Po(i))throw new Error("Invalid seeds, address must fall off the curve");return new Wo(i)}static async createProgramAddress(t,e){return this.createProgramAddressSync(t,e)}static findProgramAddressSync(t,e){let r,i=255;for(;0!=i;){try{const o=t.concat(n.Buffer.from([i]));r=this.createProgramAddressSync(o,e)}catch(t){if(t instanceof TypeError)throw t;i--;continue}return[r,i]}throw new Error("Unable to find a viable program address nonce")}static async findProgramAddress(t,e){return this.findProgramAddressSync(t,e)}static isOnCurve(t){return Po(new Wo(t).toBytes())}}No=Wo,Wo.default=new No("11111111111111111111111111111111"),Co.set(Wo,{kind:"struct",fields:[["_bn","u256"]]});const Fo=new Wo("BPFLoader1111111111111111111111111111111111"),Ko=1232,Vo=127,qo=64;class Ho extends Error{constructor(t){super(`Signature ${t} has expired: block height exceeded.`),this.signature=void 0,this.signature=t}}Object.defineProperty(Ho.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});class $o extends Error{constructor(t,e){super(`Transaction was not confirmed in ${e.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${t} using the Solana Explorer or CLI tools.`),this.signature=void 0,this.signature=t}}Object.defineProperty($o.prototype,"name",{value:"TransactionExpiredTimeoutError"});class Go extends Error{constructor(t){super(`Signature ${t} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=t}}Object.defineProperty(Go.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});class Zo{constructor(t,e){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=t,this.accountKeysFromLookups=e}keySegments(){const t=[this.staticAccountKeys];return this.accountKeysFromLookups&&(t.push(this.accountKeysFromLookups.writable),t.push(this.accountKeysFromLookups.readonly)),t}get(t){for(const e of this.keySegments()){if(t<e.length)return e[t];t-=e.length}}get length(){return this.keySegments().flat().length}compileInstructions(t){if(this.length>256)throw new Error("Account index overflow encountered during compilation");const e=new Map;this.keySegments().flat().forEach(((t,r)=>{e.set(t.toBase58(),r)}));const r=t=>{const r=e.get(t.toBase58());if(void 0===r)throw new Error("Encountered an unknown instruction account key during compilation");return r};return t.map((t=>({programIdIndex:r(t.programId),accountKeyIndexes:t.keys.map((t=>r(t.pubkey))),data:t.data})))}}const Yo=(t="publicKey")=>Fr(32,t),Jo=(t="signature")=>Fr(64,t),Xo=(t="string")=>{const e=jr([Nr("length"),Nr("lengthPadding"),Fr(Or(Nr(),-8),"chars")],t),r=e.decode.bind(e),i=e.encode.bind(e),o=e;return o.decode=(t,e)=>r(t,e).chars.toString(),o.encode=(t,e,r)=>{const o={chars:n.Buffer.from(t,"utf8")};return i(o,e,r)},o.alloc=t=>Nr().span+Nr().span+n.Buffer.from(t,"utf8").length,o};function Qo(t,e){const r=t=>{if(t.span>=0)return t.span;if("function"==typeof t.alloc)return t.alloc(e[t.property]);if("count"in t&&"elementLayout"in t){const n=e[t.property];if(Array.isArray(n))return n.length*r(t.elementLayout)}else if("fields"in t)return Qo({layout:t},e[t.property]);return 0};let n=0;return t.layout.fields.forEach((t=>{n+=r(t)})),n}function ts(t){let e=0,r=0;for(;;){let n=t.shift();if(e|=(127&n)<<7*r,r+=1,0==(128&n))break}return e}function es(t,e){let r=e;for(;;){let e=127&r;if(r>>=7,0==r){t.push(e);break}e|=128,t.push(e)}}function rs(t,e){if(!t)throw new Error(e||"Assertion failed")}class ns{constructor(t,e){this.payer=void 0,this.keyMetaMap=void 0,this.payer=t,this.keyMetaMap=e}static compile(t,e){const r=new Map,n=t=>{const e=t.toBase58();let n=r.get(e);return void 0===n&&(n={isSigner:!1,isWritable:!1,isInvoked:!1},r.set(e,n)),n},i=n(e);i.isSigner=!0,i.isWritable=!0;for(const e of t){n(e.programId).isInvoked=!0;for(const t of e.keys){const e=n(t.pubkey);e.isSigner||=t.isSigner,e.isWritable||=t.isWritable}}return new ns(e,r)}getMessageComponents(){const t=[...this.keyMetaMap.entries()];rs(t.length<=256,"Max static account keys length exceeded");const e=t.filter((([,t])=>t.isSigner&&t.isWritable)),r=t.filter((([,t])=>t.isSigner&&!t.isWritable)),n=t.filter((([,t])=>!t.isSigner&&t.isWritable)),i=t.filter((([,t])=>!t.isSigner&&!t.isWritable)),o={numRequiredSignatures:e.length+r.length,numReadonlySignedAccounts:r.length,numReadonlyUnsignedAccounts:i.length};{rs(e.length>0,"Expected at least one writable signer key");const[t]=e[0];rs(t===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}return[o,[...e.map((([t])=>new Wo(t))),...r.map((([t])=>new Wo(t))),...n.map((([t])=>new Wo(t))),...i.map((([t])=>new Wo(t)))]]}extractTableLookup(t){const[e,r]=this.drainKeysFoundInLookupTable(t.state.addresses,(t=>!t.isSigner&&!t.isInvoked&&t.isWritable)),[n,i]=this.drainKeysFoundInLookupTable(t.state.addresses,(t=>!t.isSigner&&!t.isInvoked&&!t.isWritable));if(0!==e.length||0!==n.length)return[{accountKey:t.key,writableIndexes:e,readonlyIndexes:n},{writable:r,readonly:i}]}drainKeysFoundInLookupTable(t,e){const r=new Array,n=new Array;for(const[i,o]of this.keyMetaMap.entries())if(e(o)){const e=new Wo(i),o=t.findIndex((t=>t.equals(e)));o>=0&&(rs(o<256,"Max lookup table index exceeded"),r.push(o),n.push(e),this.keyMetaMap.delete(i))}return[r,n]}}class is{constructor(t){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=t.header,this.accountKeys=t.accountKeys.map((t=>new Wo(t))),this.recentBlockhash=t.recentBlockhash,this.instructions=t.instructions,this.instructions.forEach((t=>this.indexToProgramIds.set(t.programIdIndex,this.accountKeys[t.programIdIndex])))}get version(){return"legacy"}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map((t=>({programIdIndex:t.programIdIndex,accountKeyIndexes:t.accounts,data:ae.decode(t.data)})))}get addressTableLookups(){return[]}getAccountKeys(){return new Zo(this.staticAccountKeys)}static compile(t){const e=ns.compile(t.instructions,t.payerKey),[r,n]=e.getMessageComponents(),i=new Zo(n).compileInstructions(t.instructions).map((t=>({programIdIndex:t.programIdIndex,accounts:t.accountKeyIndexes,data:ae.encode(t.data)})));return new is({header:r,accountKeys:n,recentBlockhash:t.recentBlockhash,instructions:i})}isAccountSigner(t){return t<this.header.numRequiredSignatures}isAccountWritable(t){const e=this.header.numRequiredSignatures;if(t>=this.header.numRequiredSignatures){return t-e<this.accountKeys.length-e-this.header.numReadonlyUnsignedAccounts}return t<e-this.header.numReadonlySignedAccounts}isProgramId(t){return this.indexToProgramIds.has(t)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter(((t,e)=>!this.isProgramId(e)))}serialize(){const t=this.accountKeys.length;let e=[];es(e,t);const r=this.instructions.map((t=>{const{accounts:e,programIdIndex:r}=t,i=Array.from(ae.decode(t.data));let o=[];es(o,e.length);let s=[];return es(s,i.length),{programIdIndex:r,keyIndicesCount:n.Buffer.from(o),keyIndices:e,dataLength:n.Buffer.from(s),data:i}}));let i=[];es(i,r.length);let o=n.Buffer.alloc(Ko);n.Buffer.from(i).copy(o);let s=i.length;r.forEach((t=>{const e=jr([Ur("programIdIndex"),Fr(t.keyIndicesCount.length,"keyIndicesCount"),Wr(Ur("keyIndex"),t.keyIndices.length,"keyIndices"),Fr(t.dataLength.length,"dataLength"),Wr(Ur("userdatum"),t.data.length,"data")]).encode(t,o,s);s+=e})),o=o.slice(0,s);const a=jr([Fr(1,"numRequiredSignatures"),Fr(1,"numReadonlySignedAccounts"),Fr(1,"numReadonlyUnsignedAccounts"),Fr(e.length,"keyCount"),Wr(Yo("key"),t,"keys"),Yo("recentBlockhash")]),u={numRequiredSignatures:n.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:n.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:n.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:n.Buffer.from(e),keys:this.accountKeys.map((t=>Oo(t.toBytes()))),recentBlockhash:ae.decode(this.recentBlockhash)};let c=n.Buffer.alloc(2048);const h=a.encode(u,c);return o.copy(c,h),c.slice(0,h+o.length)}static from(t){let e=[...t];const r=e.shift();if(r!==(r&Vo))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const i=e.shift(),o=e.shift(),s=ts(e);let a=[];for(let t=0;t<s;t++){const t=e.slice(0,Do);e=e.slice(Do),a.push(new Wo(n.Buffer.from(t)))}const u=e.slice(0,Do);e=e.slice(Do);const c=ts(e);let h=[];for(let t=0;t<c;t++){const t=e.shift(),r=ts(e),i=e.slice(0,r);e=e.slice(r);const o=ts(e),s=e.slice(0,o),a=ae.encode(n.Buffer.from(s));e=e.slice(o),h.push({programIdIndex:t,accounts:i,data:a})}const l={header:{numRequiredSignatures:r,numReadonlySignedAccounts:i,numReadonlyUnsignedAccounts:o},recentBlockhash:ae.encode(n.Buffer.from(u)),accountKeys:a,instructions:h};return new is(l)}}class os{constructor(t){this.header=void 0,this.staticAccountKeys=void 0,this.recentBlockhash=void 0,this.compiledInstructions=void 0,this.addressTableLookups=void 0,this.header=t.header,this.staticAccountKeys=t.staticAccountKeys,this.recentBlockhash=t.recentBlockhash,this.compiledInstructions=t.compiledInstructions,this.addressTableLookups=t.addressTableLookups}get version(){return 0}get numAccountKeysFromLookups(){let t=0;for(const e of this.addressTableLookups)t+=e.readonlyIndexes.length+e.writableIndexes.length;return t}getAccountKeys(t){let e;if(t&&"accountKeysFromLookups"in t&&t.accountKeysFromLookups){if(this.numAccountKeysFromLookups!=t.accountKeysFromLookups.writable.length+t.accountKeysFromLookups.readonly.length)throw new Error("Failed to get account keys because of a mismatch in the number of account keys from lookups");e=t.accountKeysFromLookups}else if(t&&"addressLookupTableAccounts"in t&&t.addressLookupTableAccounts)e=this.resolveAddressTableLookups(t.addressLookupTableAccounts);else if(this.addressTableLookups.length>0)throw new Error("Failed to get account keys because address table lookups were not resolved");return new Zo(this.staticAccountKeys,e)}isAccountSigner(t){return t<this.header.numRequiredSignatures}isAccountWritable(t){const e=this.header.numRequiredSignatures,r=this.staticAccountKeys.length;if(t>=r){const e=t-r,n=this.addressTableLookups.reduce(((t,e)=>t+e.writableIndexes.length),0);return e<n}if(t>=this.header.numRequiredSignatures){return t-e<r-e-this.header.numReadonlyUnsignedAccounts}return t<e-this.header.numReadonlySignedAccounts}resolveAddressTableLookups(t){const e={writable:[],readonly:[]};for(const r of this.addressTableLookups){const n=t.find((t=>t.key.equals(r.accountKey)));if(!n)throw new Error(`Failed to find address lookup table account for table key ${r.accountKey.toBase58()}`);for(const t of r.writableIndexes){if(!(t<n.state.addresses.length))throw new Error(`Failed to find address for index ${t} in address lookup table ${r.accountKey.toBase58()}`);e.writable.push(n.state.addresses[t])}for(const t of r.readonlyIndexes){if(!(t<n.state.addresses.length))throw new Error(`Failed to find address for index ${t} in address lookup table ${r.accountKey.toBase58()}`);e.readonly.push(n.state.addresses[t])}}return e}static compile(t){const e=ns.compile(t.instructions,t.payerKey),r=new Array,n={writable:new Array,readonly:new Array},i=t.addressLookupTableAccounts||[];for(const t of i){const i=e.extractTableLookup(t);if(void 0!==i){const[t,{writable:e,readonly:o}]=i;r.push(t),n.writable.push(...e),n.readonly.push(...o)}}const[o,s]=e.getMessageComponents(),a=new Zo(s,n).compileInstructions(t.instructions);return new os({header:o,staticAccountKeys:s,recentBlockhash:t.recentBlockhash,compiledInstructions:a,addressTableLookups:r})}serialize(){const t=Array();es(t,this.staticAccountKeys.length);const e=this.serializeInstructions(),r=Array();es(r,this.compiledInstructions.length);const n=this.serializeAddressTableLookups(),i=Array();es(i,this.addressTableLookups.length);const o=jr([Ur("prefix"),jr([Ur("numRequiredSignatures"),Ur("numReadonlySignedAccounts"),Ur("numReadonlyUnsignedAccounts")],"header"),Fr(t.length,"staticAccountKeysLength"),Wr(Yo(),this.staticAccountKeys.length,"staticAccountKeys"),Yo("recentBlockhash"),Fr(r.length,"instructionsLength"),Fr(e.length,"serializedInstructions"),Fr(i.length,"addressTableLookupsLength"),Fr(n.length,"serializedAddressTableLookups")]),s=new Uint8Array(Ko),a=o.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(t),staticAccountKeys:this.staticAccountKeys.map((t=>t.toBytes())),recentBlockhash:ae.decode(this.recentBlockhash),instructionsLength:new Uint8Array(r),serializedInstructions:e,addressTableLookupsLength:new Uint8Array(i),serializedAddressTableLookups:n},s);return s.slice(0,a)}serializeInstructions(){let t=0;const e=new Uint8Array(Ko);for(const r of this.compiledInstructions){const n=Array();es(n,r.accountKeyIndexes.length);const i=Array();es(i,r.data.length);t+=jr([Ur("programIdIndex"),Fr(n.length,"encodedAccountKeyIndexesLength"),Wr(Ur(),r.accountKeyIndexes.length,"accountKeyIndexes"),Fr(i.length,"encodedDataLength"),Fr(r.data.length,"data")]).encode({programIdIndex:r.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(n),accountKeyIndexes:r.accountKeyIndexes,encodedDataLength:new Uint8Array(i),data:r.data},e,t)}return e.slice(0,t)}serializeAddressTableLookups(){let t=0;const e=new Uint8Array(Ko);for(const r of this.addressTableLookups){const n=Array();es(n,r.writableIndexes.length);const i=Array();es(i,r.readonlyIndexes.length);t+=jr([Yo("accountKey"),Fr(n.length,"encodedWritableIndexesLength"),Wr(Ur(),r.writableIndexes.length,"writableIndexes"),Fr(i.length,"encodedReadonlyIndexesLength"),Wr(Ur(),r.readonlyIndexes.length,"readonlyIndexes")]).encode({accountKey:r.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(n),writableIndexes:r.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(i),readonlyIndexes:r.readonlyIndexes},e,t)}return e.slice(0,t)}static deserialize(t){let e=[...t];const r=e.shift(),n=r&Vo;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:e.shift(),numReadonlySignedAccounts:e.shift(),numReadonlyUnsignedAccounts:e.shift()},o=[],s=ts(e);for(let t=0;t<s;t++)o.push(new Wo(e.splice(0,Do)));const a=ae.encode(e.splice(0,Do)),u=ts(e),c=[];for(let t=0;t<u;t++){const t=e.shift(),r=ts(e),n=e.splice(0,r),i=ts(e),o=new Uint8Array(e.splice(0,i));c.push({programIdIndex:t,accountKeyIndexes:n,data:o})}const h=ts(e),l=[];for(let t=0;t<h;t++){const t=new Wo(e.splice(0,Do)),r=ts(e),n=e.splice(0,r),i=ts(e),o=e.splice(0,i);l.push({accountKey:t,writableIndexes:n,readonlyIndexes:o})}return new os({header:i,staticAccountKeys:o,recentBlockhash:a,compiledInstructions:c,addressTableLookups:l})}}const ss={deserializeMessageVersion(t){const e=t[0],r=e&Vo;return r===e?"legacy":r},deserialize:t=>{const e=ss.deserializeMessageVersion(t);if("legacy"===e)return is.from(t);if(0===e)return os.deserialize(t);throw new Error(`Transaction message version ${e} deserialization is not supported`)}};let as=function(t){return t[t.BLOCKHEIGHT_EXCEEDED=0]="BLOCKHEIGHT_EXCEEDED",t[t.PROCESSED=1]="PROCESSED",t[t.TIMED_OUT=2]="TIMED_OUT",t[t.NONCE_INVALID=3]="NONCE_INVALID",t}({});const us=n.Buffer.alloc(qo).fill(0);class cs{constructor(t){this.keys=void 0,this.programId=void 0,this.data=n.Buffer.alloc(0),this.programId=t.programId,this.keys=t.keys,t.data&&(this.data=t.data)}toJSON(){return{keys:this.keys.map((({pubkey:t,isSigner:e,isWritable:r})=>({pubkey:t.toJSON(),isSigner:e,isWritable:r}))),programId:this.programId.toJSON(),data:[...this.data]}}}class hs{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(t){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,t)if(t.feePayer&&(this.feePayer=t.feePayer),t.signatures&&(this.signatures=t.signatures),Object.prototype.hasOwnProperty.call(t,"nonceInfo")){const{minContextSlot:e,nonceInfo:r}=t;this.minNonceContextSlot=e,this.nonceInfo=r}else if(Object.prototype.hasOwnProperty.call(t,"lastValidBlockHeight")){const{blockhash:e,lastValidBlockHeight:r}=t;this.recentBlockhash=e,this.lastValidBlockHeight=r}else{const{recentBlockhash:e,nonceInfo:r}=t;r&&(this.nonceInfo=r),this.recentBlockhash=e}}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((t=>t.toJSON())),signers:this.signatures.map((({publicKey:t})=>t.toJSON()))}}add(...t){if(0===t.length)throw new Error("No instructions");return t.forEach((t=>{"instructions"in t?this.instructions=this.instructions.concat(t.instructions):"data"in t&&"programId"in t&&"keys"in t?this.instructions.push(t):this.instructions.push(new cs(t))})),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let t,e,r;if(this.nonceInfo?(t=this.nonceInfo.nonce,e=this.instructions[0]!=this.nonceInfo.nonceInstruction?[this.nonceInfo.nonceInstruction,...this.instructions]:this.instructions):(t=this.recentBlockhash,e=this.instructions),!t)throw new Error("Transaction recentBlockhash required");if(e.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 t=0;t<e.length;t++)if(void 0===e[t].programId)throw new Error(`Transaction instruction index ${t} has undefined program id`);const n=[],i=[];e.forEach((t=>{t.keys.forEach((t=>{i.push({...t})}));const e=t.programId.toString();n.includes(e)||n.push(e)})),n.forEach((t=>{i.push({pubkey:new Wo(t),isSigner:!1,isWritable:!1})}));const o=[];i.forEach((t=>{const e=t.pubkey.toString(),r=o.findIndex((t=>t.pubkey.toString()===e));r>-1?(o[r].isWritable=o[r].isWritable||t.isWritable,o[r].isSigner=o[r].isSigner||t.isSigner):o.push(t)})),o.sort((function(t,e){if(t.isSigner!==e.isSigner)return t.isSigner?-1:1;if(t.isWritable!==e.isWritable)return t.isWritable?-1:1;return t.pubkey.toBase58().localeCompare(e.pubkey.toBase58(),"en",{localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"})}));const s=o.findIndex((t=>t.pubkey.equals(r)));if(s>-1){const[t]=o.splice(s,1);t.isSigner=!0,t.isWritable=!0,o.unshift(t)}else o.unshift({pubkey:r,isSigner:!0,isWritable:!0});for(const t of this.signatures){const e=o.findIndex((e=>e.pubkey.equals(t.publicKey)));if(!(e>-1))throw new Error(`unknown signer: ${t.publicKey.toString()}`);o[e].isSigner||(o[e].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,u=0,c=0;const h=[],l=[];o.forEach((({pubkey:t,isSigner:e,isWritable:r})=>{e?(h.push(t.toString()),a+=1,r||(u+=1)):(l.push(t.toString()),r||(c+=1))}));const f=h.concat(l),d=e.map((t=>{const{data:e,programId:r}=t;return{programIdIndex:f.indexOf(r.toString()),accounts:t.keys.map((t=>f.indexOf(t.pubkey.toString()))),data:ae.encode(e)}}));return d.forEach((t=>{rs(t.programIdIndex>=0),t.accounts.forEach((t=>rs(t>=0)))})),new is({header:{numRequiredSignatures:a,numReadonlySignedAccounts:u,numReadonlyUnsignedAccounts:c},accountKeys:f,recentBlockhash:t,instructions:d})}_compile(){const t=this.compileMessage(),e=t.accountKeys.slice(0,t.header.numRequiredSignatures);if(this.signatures.length===e.length){const r=this.signatures.every(((t,r)=>e[r].equals(t.publicKey)));if(r)return t}return this.signatures=e.map((t=>({signature:null,publicKey:t}))),t}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(t){return(await t.getFeeForMessage(this.compileMessage())).value}setSigners(...t){if(0===t.length)throw new Error("No signers");const e=new Set;this.signatures=t.filter((t=>{const r=t.toString();return!e.has(r)&&(e.add(r),!0)})).map((t=>({signature:null,publicKey:t})))}sign(...t){if(0===t.length)throw new Error("No signers");const e=new Set,r=[];for(const n of t){const t=n.publicKey.toString();e.has(t)||(e.add(t),r.push(n))}this.signatures=r.map((t=>({signature:null,publicKey:t.publicKey})));const n=this._compile();this._partialSign(n,...r)}partialSign(...t){if(0===t.length)throw new Error("No signers");const e=new Set,r=[];for(const n of t){const t=n.publicKey.toString();e.has(t)||(e.add(t),r.push(n))}const n=this._compile();this._partialSign(n,...r)}_partialSign(t,...e){const r=t.serialize();e.forEach((t=>{const e=To(r,t.secretKey);this._addSignature(t.publicKey,Oo(e))}))}addSignature(t,e){this._compile(),this._addSignature(t,e)}_addSignature(t,e){rs(64===e.length);const r=this.signatures.findIndex((e=>t.equals(e.publicKey)));if(r<0)throw new Error(`unknown signer: ${t.toString()}`);this.signatures[r].signature=n.Buffer.from(e)}verifySignatures(t){return this._verifySignatures(this.serializeMessage(),void 0===t||t)}_verifySignatures(t,e){for(const{signature:r,publicKey:n}of this.signatures)if(null===r){if(e)return!1}else if(!Lo(r,t,n.toBytes()))return!1;return!0}serialize(t){const{requireAllSignatures:e,verifySignatures:r}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},t),n=this.serializeMessage();if(r&&!this._verifySignatures(n,e))throw new Error("Signature verification failed");return this._serialize(n)}_serialize(t){const{signatures:e}=this,r=[];es(r,e.length);const i=r.length+64*e.length+t.length,o=n.Buffer.alloc(i);return rs(e.length<256),n.Buffer.from(r).copy(o,0),e.forEach((({signature:t},e)=>{null!==t&&(rs(64===t.length,"signature has invalid length"),n.Buffer.from(t).copy(o,r.length+64*e))})),t.copy(o,r.length+64*e.length),rs(o.length<=Ko,`Transaction too large: ${o.length} > 1232`),o}get keys(){return rs(1===this.instructions.length),this.instructions[0].keys.map((t=>t.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(t){let e=[...t];const r=ts(e);let i=[];for(let t=0;t<r;t++){const t=e.slice(0,qo);e=e.slice(qo),i.push(ae.encode(n.Buffer.from(t)))}return hs.populate(is.from(e),i)}static populate(t,e=[]){const r=new hs;return r.recentBlockhash=t.recentBlockhash,t.header.numRequiredSignatures>0&&(r.feePayer=t.accountKeys[0]),e.forEach(((e,n)=>{const i={signature:e==ae.encode(us)?null:ae.decode(e),publicKey:t.accountKeys[n]};r.signatures.push(i)})),t.instructions.forEach((e=>{const n=e.accounts.map((e=>{const n=t.accountKeys[e];return{pubkey:n,isSigner:r.signatures.some((t=>t.publicKey.toString()===n.toString()))||t.isAccountSigner(e),isWritable:t.isAccountWritable(e)}}));r.instructions.push(new cs({keys:n,programId:t.accountKeys[e.programIdIndex],data:ae.decode(e.data)}))})),r._message=t,r._json=r.toJSON(),r}}class ls{constructor(t){this.payerKey=void 0,this.instructions=void 0,this.recentBlockhash=void 0,this.payerKey=t.payerKey,this.instructions=t.instructions,this.recentBlockhash=t.recentBlockhash}static decompile(t,e){const{header:r,compiledInstructions:n,recentBlockhash:i}=t,{numRequiredSignatures:o,numReadonlySignedAccounts:s,numReadonlyUnsignedAccounts:a}=r,u=o-s;rs(u>0,"Message header is invalid");const c=t.staticAccountKeys.length-o-a;rs(c>=0,"Message header is invalid");const h=t.getAccountKeys(e),l=h.get(0);if(void 0===l)throw new Error("Failed to decompile message because no account keys were found");const f=[];for(const t of n){const e=[];for(const n of t.accountKeyIndexes){const t=h.get(n);if(void 0===t)throw new Error(`Failed to find key for account key index ${n}`);let i;i=n<o?n<u:n<h.staticAccountKeys.length?n-o<c:n-h.staticAccountKeys.length<h.accountKeysFromLookups.writable.length,e.push({pubkey:t,isSigner:n<r.numRequiredSignatures,isWritable:i})}const n=h.get(t.programIdIndex);if(void 0===n)throw new Error(`Failed to find program id for program id index ${t.programIdIndex}`);f.push(new cs({programId:n,data:Oo(t.data),keys:e}))}return new ls({payerKey:l,instructions:f,recentBlockhash:i})}compileToLegacyMessage(){return is.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions})}compileToV0Message(t){return os.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions,addressLookupTableAccounts:t})}}class fs{get version(){return this.message.version}constructor(t,e){if(this.signatures=void 0,this.message=void 0,void 0!==e)rs(e.length===t.header.numRequiredSignatures,"Expected signatures length to be equal to the number of required signatures"),this.signatures=e;else{const e=[];for(let r=0;r<t.header.numRequiredSignatures;r++)e.push(new Uint8Array(qo));this.signatures=e}this.message=t}serialize(){const t=this.message.serialize(),e=Array();es(e,this.signatures.length);const r=jr([Fr(e.length,"encodedSignaturesLength"),Wr(Jo(),this.signatures.length,"signatures"),Fr(t.length,"serializedMessage")]),n=new Uint8Array(2048),i=r.encode({encodedSignaturesLength:new Uint8Array(e),signatures:this.signatures,serializedMessage:t},n);return n.slice(0,i)}static deserialize(t){let e=[...t];const r=[],n=ts(e);for(let t=0;t<n;t++)r.push(new Uint8Array(e.splice(0,qo)));const i=ss.deserialize(new Uint8Array(e));return new fs(i,r)}sign(t){const e=this.message.serialize(),r=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures);for(const n of t){const t=r.findIndex((t=>t.equals(n.publicKey)));rs(t>=0,`Cannot sign with non signer key ${n.publicKey.toBase58()}`),this.signatures[t]=To(e,n.secretKey)}}addSignature(t,e){rs(64===e.byteLength,"Signature must be 64 bytes long");const r=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex((e=>e.equals(t)));rs(r>=0,`Can not add signature; \`${t.toBase58()}\` is not required to sign this transaction`),this.signatures[r]=e}}const ds=new Wo("SysvarC1ock11111111111111111111111111111111"),ps=new Wo("SysvarEpochSchedu1e111111111111111111111111"),ys=new Wo("Sysvar1nstructions1111111111111111111111111"),gs=new Wo("SysvarRecentB1ockHashes11111111111111111111"),ms=new Wo("SysvarRent111111111111111111111111111111111"),ws=new Wo("SysvarRewards111111111111111111111111111111"),bs=new Wo("SysvarS1otHashes111111111111111111111111111"),vs=new Wo("SysvarS1otHistory11111111111111111111111111"),_s=new Wo("SysvarStakeHistory1111111111111111111111111");async function ks(t,e,r,n){const i=n&&{skipPreflight:n.skipPreflight,preflightCommitment:n.preflightCommitment||n.commitment,maxRetries:n.maxRetries,minContextSlot:n.minContextSlot},o=await t.sendTransaction(e,r,i);let s;if(null!=e.recentBlockhash&&null!=e.lastValidBlockHeight)s=(await t.confirmTransaction({abortSignal:n?.abortSignal,signature:o,blockhash:e.recentBlockhash,lastValidBlockHeight:e.lastValidBlockHeight},n&&n.commitment)).value;else if(null!=e.minNonceContextSlot&&null!=e.nonceInfo){const{nonceInstruction:r}=e.nonceInfo,i=r.keys[0].pubkey;s=(await t.confirmTransaction({abortSignal:n?.abortSignal,minContextSlot:e.minNonceContextSlot,nonceAccountPubkey:i,nonceValue:e.nonceInfo.nonce,signature:o},n&&n.commitment)).value}else null!=n?.abortSignal&&console.warn("sendAndConfirmTransaction(): A transaction with a deprecated confirmation strategy was supplied along with an `abortSignal`. Only transactions having `lastValidBlockHeight` or a combination of `nonceInfo` and `minNonceContextSlot` are abortable."),s=(await t.confirmTransaction(o,n&&n.commitment)).value;if(s.err)throw new Error(`Transaction ${o} failed (${JSON.stringify(s)})`);return o}function Es(t){return new Promise((e=>setTimeout(e,t)))}function xs(t,e){const r=t.layout.span>=0?t.layout.span:Qo(t,e),i=n.Buffer.alloc(r),o=Object.assign({instruction:t.index},e);return t.layout.encode(o,i),i}function Ss(t,e){let r;try{r=t.layout.decode(e)}catch(t){throw new Error("invalid instruction; "+t)}if(r.instruction!==t.index)throw new Error(`invalid instruction; instruction index mismatch ${r.instruction} != ${t.index}`);return r}const As=zr("lamportsPerSignature"),Is=jr([Nr("version"),Nr("state"),Yo("authorizedPubkey"),Yo("nonce"),jr([As],"feeCalculator")]),Bs=Is.span;class Ms{constructor(t){this.authorizedPubkey=void 0,this.nonce=void 0,this.feeCalculator=void 0,this.authorizedPubkey=t.authorizedPubkey,this.nonce=t.nonce,this.feeCalculator=t.feeCalculator}static fromAccountData(t){const e=Is.decode(Oo(t),0);return new Ms({authorizedPubkey:new Wo(e.authorizedPubkey),nonce:new Wo(e.nonce).toString(),feeCalculator:e.feeCalculator})}}const Rs=(Ps=8,t=>{const e=Fr(Ps,t),{encode:r,decode:i}=(t=>({decode:t.decode.bind(t),encode:t.encode.bind(t)}))(e),o=e;return o.decode=(t,e)=>{const r=i(t,e);return Vr(n.Buffer.from(r))},o.encode=(t,e,n)=>{const i=Hr(t,Ps);return r(i,e,n)},o});var Ps;const Ts=Object.freeze({Create:{index:0,layout:jr([Nr("instruction"),Dr("lamports"),Dr("space"),Yo("programId")])},Assign:{index:1,layout:jr([Nr("instruction"),Yo("programId")])},Transfer:{index:2,layout:jr([Nr("instruction"),Rs("lamports")])},CreateWithSeed:{index:3,layout:jr([Nr("instruction"),Yo("base"),Xo("seed"),Dr("lamports"),Dr("space"),Yo("programId")])},AdvanceNonceAccount:{index:4,layout:jr([Nr("instruction")])},WithdrawNonceAccount:{index:5,layout:jr([Nr("instruction"),Dr("lamports")])},InitializeNonceAccount:{index:6,layout:jr([Nr("instruction"),Yo("authorized")])},AuthorizeNonceAccount:{index:7,layout:jr([Nr("instruction"),Yo("authorized")])},Allocate:{index:8,layout:jr([Nr("instruction"),Dr("space")])},AllocateWithSeed:{index:9,layout:jr([Nr("instruction"),Yo("base"),Xo("seed"),Dr("space"),Yo("programId")])},AssignWithSeed:{index:10,layout:jr([Nr("instruction"),Yo("base"),Xo("seed"),Yo("programId")])},TransferWithSeed:{index:11,layout:jr([Nr("instruction"),Rs("lamports"),Xo("seed"),Yo("programId")])},UpgradeNonceAccount:{index:12,layout:jr([Nr("instruction")])}});class Ls{constructor(){}static createAccount(t){const e=xs(Ts.Create,{lamports:t.lamports,space:t.space,programId:Oo(t.programId.toBuffer())});return new cs({keys:[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:e})}static transfer(t){let e,r;if("basePubkey"in t){e=xs(Ts.TransferWithSeed,{lamports:BigInt(t.lamports),seed:t.seed,programId:Oo(t.programId.toBuffer())}),r=[{pubkey:t.fromPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0}]}else{e=xs(Ts.Transfer,{lamports:BigInt(t.lamports)}),r=[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0}]}return new cs({keys:r,programId:this.programId,data:e})}static assign(t){let e,r;if("basePubkey"in t){e=xs(Ts.AssignWithSeed,{base:Oo(t.basePubkey.toBuffer()),seed:t.seed,programId:Oo(t.programId.toBuffer())}),r=[{pubkey:t.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1}]}else{e=xs(Ts.Assign,{programId:Oo(t.programId.toBuffer())}),r=[{pubkey:t.accountPubkey,isSigner:!0,isWritable:!0}]}return new cs({keys:r,programId:this.programId,data:e})}static createAccountWithSeed(t){const e=xs(Ts.CreateWithSeed,{base:Oo(t.basePubkey.toBuffer()),seed:t.seed,lamports:t.lamports,space:t.space,programId:Oo(t.programId.toBuffer())});let r=[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.newAccountPubkey,isSigner:!1,isWritable:!0}];return t.basePubkey!=t.fromPubkey&&r.push({pubkey:t.basePubkey,isSigner:!0,isWritable:!1}),new cs({keys:r,programId:this.programId,data:e})}static createNonceAccount(t){const e=new hs;"basePubkey"in t&&"seed"in t?e.add(Ls.createAccountWithSeed({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,basePubkey:t.basePubkey,seed:t.seed,lamports:t.lamports,space:Bs,programId:this.programId})):e.add(Ls.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,lamports:t.lamports,space:Bs,programId:this.programId}));const r={noncePubkey:t.noncePubkey,authorizedPubkey:t.authorizedPubkey};return e.add(this.nonceInitialize(r)),e}static nonceInitialize(t){const e=xs(Ts.InitializeNonceAccount,{authorized:Oo(t.authorizedPubkey.toBuffer())}),r={keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:gs,isSigner:!1,isWritable:!1},{pubkey:ms,isSigner:!1,isWritable:!1}],programId:this.programId,data:e};return new cs(r)}static nonceAdvance(t){const e=xs(Ts.AdvanceNonceAccount),r={keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:gs,isSigner:!1,isWritable:!1},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:e};return new cs(r)}static nonceWithdraw(t){const e=xs(Ts.WithdrawNonceAccount,{lamports:t.lamports});return new cs({keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0},{pubkey:gs,isSigner:!1,isWritable:!1},{pubkey:ms,isSigner:!1,isWritable:!1},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:e})}static nonceAuthorize(t){const e=xs(Ts.AuthorizeNonceAccount,{authorized:Oo(t.newAuthorizedPubkey.toBuffer())});return new cs({keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:e})}static allocate(t){let e,r;if("basePubkey"in t){e=xs(Ts.AllocateWithSeed,{base:Oo(t.basePubkey.toBuffer()),seed:t.seed,space:t.space,programId:Oo(t.programId.toBuffer())}),r=[{pubkey:t.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1}]}else{e=xs(Ts.Allocate,{space:t.space}),r=[{pubkey:t.accountPubkey,isSigner:!0,isWritable:!0}]}return new cs({keys:r,programId:this.programId,data:e})}}Ls.programId=new Wo("11111111111111111111111111111111");class Os{constructor(){}static getMinNumSignatures(t){return 2*(Math.ceil(t/Os.chunkSize)+1+1)}static async load(t,e,r,i,o){{const n=await t.getMinimumBalanceForRentExemption(o.length),s=await t.getAccountInfo(r.publicKey,"confirmed");let a=null;if(null!==s){if(s.executable)return console.error("Program load failed, account is already executable"),!1;s.data.length!==o.length&&(a=a||new hs,a.add(Ls.allocate({accountPubkey:r.publicKey,space:o.length}))),s.owner.equals(i)||(a=a||new hs,a.add(Ls.assign({accountPubkey:r.publicKey,programId:i}))),s.lamports<n&&(a=a||new hs,a.add(Ls.transfer({fromPubkey:e.publicKey,toPubkey:r.publicKey,lamports:n-s.lamports})))}else a=(new hs).add(Ls.createAccount({fromPubkey:e.publicKey,newAccountPubkey:r.publicKey,lamports:n>0?n:1,space:o.length,programId:i}));null!==a&&await ks(t,a,[e,r],{commitment:"confirmed"})}const s=jr([Nr("instruction"),Nr("offset"),Nr("bytesLength"),Nr("bytesLengthPadding"),Wr(Ur("byte"),Or(Nr(),-8),"bytes")]),a=Os.chunkSize;let u=0,c=o,h=[];for(;c.length>0;){const o=c.slice(0,a),l=n.Buffer.alloc(a+16);s.encode({instruction:0,offset:u,bytes:o,bytesLength:0,bytesLengthPadding:0},l);const f=(new hs).add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0}],programId:i,data:l});if(h.push(ks(t,f,[e,r],{commitment:"confirmed"})),t._rpcEndpoint.includes("solana.com")){const t=4;await Es(1e3/t)}u+=a,c=c.slice(a)}await Promise.all(h);{const o=jr([Nr("instruction")]),s=n.Buffer.alloc(o.span);o.encode({instruction:1},s);const a=(new hs).add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0},{pubkey:ms,isSigner:!1,isWritable:!1}],programId:i,data:s}),u="processed",c=await t.sendTransaction(a,[e,r],{preflightCommitment:u}),{context:h,value:l}=await t.confirmTransaction({signature:c,lastValidBlockHeight:a.lastValidBlockHeight,blockhash:a.recentBlockhash},u);if(l.err)throw new Error(`Transaction ${c} failed (${JSON.stringify(l)})`);for(;;){try{if(await t.getSlot({commitment:u})>h.slot)break}catch{}await new Promise((t=>setTimeout(t,Math.round(200))))}}return!0}}Os.chunkSize=932;const Us=new Wo("BPFLoader2111111111111111111111111111111111");function Cs(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Ns=Object.prototype.toString,zs=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};function Ds(t,e){var r,n,i,o,s,a,u;if(!0===t)return"true";if(!1===t)return"false";switch(typeof t){case"object":if(null===t)return null;if(t.toJSON&&"function"==typeof t.toJSON)return Ds(t.toJSON(),e);if("[object Array]"===(u=Ns.call(t))){for(i="[",n=t.length-1,r=0;r<n;r++)i+=Ds(t[r],!0)+",";return n>-1&&(i+=Ds(t[r],!0)),i+"]"}if("[object Object]"===u){for(n=(o=zs(t).sort()).length,i="",r=0;r<n;)void 0!==(a=Ds(t[s=o[r]],!1))&&(i&&(i+=","),i+=JSON.stringify(s)+":"+a),r++;return"{"+i+"}"}return JSON.stringify(t);case"function":case"undefined":return e?null:void 0;case"string":return JSON.stringify(t);default:return isFinite(t)?t:null}}var js=Cs((function(t){var e=Ds(t,!1);if(void 0!==e)return""+e}));function Ws(t){let e=0;for(;t>1;)t/=2,e++;return e}class Fs{constructor(t,e,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=t,this.leaderScheduleSlotOffset=e,this.warmup=r,this.firstNormalEpoch=n,this.firstNormalSlot=i}getEpoch(t){return this.getEpochAndSlotIndex(t)[0]}getEpochAndSlotIndex(t){if(t<this.firstNormalSlot){const e=Ws(function(t){return 0===t?1:(t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,1+(t|=t>>32))}(t+32+1))-Ws(32)-1;return[e,t-(this.getSlotsInEpoch(e)-32)]}{const e=t-this.firstNormalSlot,r=Math.floor(e/this.slotsPerEpoch);return[this.firstNormalEpoch+r,e%this.slotsPerEpoch]}}getFirstSlotInEpoch(t){return t<=this.firstNormalEpoch?32*(Math.pow(2,t)-1):(t-this.firstNormalEpoch)*this.slotsPerEpoch+this.firstNormalSlot}getLastSlotInEpoch(t){return this.getFirstSlotInEpoch(t)+this.getSlotsInEpoch(t)-1}getSlotsInEpoch(t){return t<this.firstNormalEpoch?Math.pow(2,t+Ws(32)):this.slotsPerEpoch}}class Ks extends Error{constructor(t,e){super(t),this.logs=void 0,this.logs=e}}class Vs extends Error{constructor({code:t,message:e,data:r},n){super(null!=n?`${n}: ${e}`:e),this.code=void 0,this.data=void 0,this.code=t,this.data=r,this.name="SolanaJSONRPCError"}}var qs=globalThis.fetch;class Hs extends qi{constructor(t,e,r){super((t=>{const r=$i(t,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...e});return this.underlyingSocket="socket"in r?r.socket:r,r}),t,e,r),this.underlyingSocket=void 0}call(...t){const e=this.underlyingSocket?.readyState;return 1===e?super.call(...t):Promise.reject(new Error("Tried to call a JSON-RPC method `"+t[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+e+")"))}notify(...t){const e=this.underlyingSocket?.readyState;return 1===e?super.notify(...t):Promise.reject(new Error("Tried to send a JSON-RPC notification `"+t[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+e+")"))}}class $s{constructor(t){this.key=void 0,this.state=void 0,this.key=t.key,this.state=t.state}isActive(){const t=BigInt("0xffffffffffffffff");return this.state.deactivationSlot===t}static deserialize(t){const e=function(t,e){let r;try{r=t.layout.decode(e)}catch(t){throw new Error("invalid instruction; "+t)}if(r.typeIndex!==t.index)throw new Error(`invalid account data; account type mismatch ${r.typeIndex} != ${t.index}`);return r}(Gs,t),r=t.length-56;rs(r>=0,"lookup table is invalid"),rs(r%32==0,"lookup table is invalid");const n=r/32,{addresses:i}=jr([Wr(Yo(),n,"addresses")]).decode(t.slice(56));return{deactivationSlot:e.deactivationSlot,lastExtendedSlot:e.lastExtendedSlot,lastExtendedSlotStartIndex:e.lastExtendedStartIndex,authority:0!==e.authority.length?new Wo(e.authority[0]):void 0,addresses:i.map((t=>new Wo(t)))}}}const Gs={index:1,layout:jr([Nr("typeIndex"),Rs("deactivationSlot"),zr("lastExtendedSlot"),Ur("lastExtendedStartIndex"),Ur(),Wr(Yo(),Or(Ur(),-1),"authority")])},Zs=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;const Ys=bn(un(Wo),pn(),(t=>new Wo(t))),Js=yn([pn(),cn("base64")]),Xs=bn(un(n.Buffer),Js,(t=>n.Buffer.from(t[0],"base64")));function Qs(t){let e,r;if("string"==typeof t)e=t;else if(t){const{commitment:n,...i}=t;e=n,r=i}return{commitment:e,config:r}}function ta(t){return mn([gn({jsonrpc:cn("2.0"),id:pn(),result:t}),gn({jsonrpc:cn("2.0"),id:pn(),error:gn({code:wn(),message:pn(),data:fn(on("any",(()=>!0)))})})])}const ea=ta(wn());function ra(t){return bn(ta(t),ea,(e=>"error"in e?e:{...e,result:en(e.result,t)}))}function na(t){return ra(gn({context:gn({slot:ln()}),value:t}))}function ia(t){return gn({context:gn({slot:ln()}),value:t})}function oa(t,e){return 0===t?new os({header:e.header,staticAccountKeys:e.accountKeys.map((t=>new Wo(t))),recentBlockhash:e.recentBlockhash,compiledInstructions:e.instructions.map((t=>({programIdIndex:t.programIdIndex,accountKeyIndexes:t.accounts,data:ae.decode(t.data)}))),addressTableLookups:e.addressTableLookups}):new is(e)}const sa=gn({foundation:ln(),foundationTerm:ln(),initial:ln(),taper:ln(),terminal:ln()}),aa=ra(sn(hn(gn({epoch:ln(),effectiveSlot:ln(),amount:ln(),postBalance:ln(),commission:fn(hn(ln()))})))),ua=sn(gn({slot:ln(),prioritizationFee:ln()})),ca=gn({total:ln(),validator:ln(),foundation:ln(),epoch:ln()}),ha=gn({epoch:ln(),slotIndex:ln(),slotsInEpoch:ln(),absoluteSlot:ln(),blockHeight:fn(ln()),transactionCount:fn(ln())}),la=gn({slotsPerEpoch:ln(),leaderScheduleSlotOffset:ln(),warmup:an(),firstNormalEpoch:ln(),firstNormalSlot:ln()}),fa=dn(pn(),sn(ln())),da=hn(mn([gn({}),pn()])),pa=gn({err:da}),ya=cn("receivedSignature"),ga=gn({"solana-core":pn(),"feature-set":fn(ln())}),ma=na(gn({err:hn(mn([gn({}),pn()])),logs:hn(sn(pn())),accounts:fn(hn(sn(hn(gn({executable:an(),owner:pn(),lamports:ln(),data:sn(pn()),rentEpoch:fn(ln())}))))),unitsConsumed:fn(ln()),returnData:fn(hn(gn({programId:pn(),data:yn([pn(),cn("base64")])})))})),wa=na(gn({byIdentity:dn(pn(),sn(ln())),range:gn({firstSlot:ln(),lastSlot:ln()})}));const ba=ra(sa),va=ra(ca),_a=ra(ua),ka=ra(ha),Ea=ra(la),xa=ra(fa),Sa=ra(ln()),Aa=na(gn({total:ln(),circulating:ln(),nonCirculating:ln(),nonCirculatingAccounts:sn(Ys)})),Ia=gn({amount:pn(),uiAmount:hn(ln()),decimals:ln(),uiAmountString:fn(pn())}),Ba=na(sn(gn({address:Ys,amount:pn(),uiAmount:hn(ln()),decimals:ln(),uiAmountString:fn(pn())}))),Ma=na(sn(gn({pubkey:Ys,account:gn({executable:an(),owner:Ys,lamports:ln(),data:Xs,rentEpoch:ln()})}))),Ra=gn({program:pn(),parsed:wn(),space:ln()}),Pa=na(sn(gn({pubkey:Ys,account:gn({executable:an(),owner:Ys,lamports:ln(),data:Ra,rentEpoch:ln()})}))),Ta=na(sn(gn({lamports:ln(),address:Ys}))),La=gn({executable:an(),owner:Ys,lamports:ln(),data:Xs,rentEpoch:ln()}),Oa=gn({pubkey:Ys,account:La}),Ua=bn(mn([un(n.Buffer),Ra]),mn([Js,Ra]),(t=>Array.isArray(t)?en(t,Xs):t)),Ca=gn({executable:an(),owner:Ys,lamports:ln(),data:Ua,rentEpoch:ln()}),Na=gn({pubkey:Ys,account:Ca}),za=gn({state:mn([cn("active"),cn("inactive"),cn("activating"),cn("deactivating")]),active:ln(),inactive:ln()}),Da=ra(sn(gn({signature:pn(),slot:ln(),err:da,memo:hn(pn()),blockTime:fn(hn(ln()))}))),ja=ra(sn(gn({signature:pn(),slot:ln(),err:da,memo:hn(pn()),blockTime:fn(hn(ln()))}))),Wa=gn({subscription:ln(),result:ia(La)}),Fa=gn({pubkey:Ys,account:La}),Ka=gn({subscription:ln(),result:ia(Fa)}),Va=gn({parent:ln(),slot:ln(),root:ln()}),qa=gn({subscription:ln(),result:Va}),Ha=mn([gn({type:mn([cn("firstShredReceived"),cn("completed"),cn("optimisticConfirmation"),cn("root")]),slot:ln(),timestamp:ln()}),gn({type:cn("createdBank"),parent:ln(),slot:ln(),timestamp:ln()}),gn({type:cn("frozen"),slot:ln(),timestamp:ln(),stats:gn({numTransactionEntries:ln(),numSuccessfulTransactions:ln(),numFailedTransactions:ln(),maxTransactionsPerEntry:ln()})}),gn({type:cn("dead"),slot:ln(),timestamp:ln(),err:pn()})]),$a=gn({subscription:ln(),result:Ha}),Ga=gn({subscription:ln(),result:ia(mn([pa,ya]))}),Za=gn({subscription:ln(),result:ln()}),Ya=gn({pubkey:pn(),gossip:hn(pn()),tpu:hn(pn()),rpc:hn(pn()),version:hn(pn())}),Ja=gn({votePubkey:pn(),nodePubkey:pn(),activatedStake:ln(),epochVoteAccount:an(),epochCredits:sn(yn([ln(),ln(),ln()])),commission:ln(),lastVote:ln(),rootSlot:hn(ln())}),Xa=ra(gn({current:sn(Ja),delinquent:sn(Ja)})),Qa=mn([cn("processed"),cn("confirmed"),cn("finalized")]),tu=gn({slot:ln(),confirmations:hn(ln()),err:da,confirmationStatus:fn(Qa)}),eu=na(sn(hn(tu))),ru=ra(ln()),nu=gn({accountKey:Ys,writableIndexes:sn(ln()),readonlyIndexes:sn(ln())}),iu=gn({signatures:sn(pn()),message:gn({accountKeys:sn(pn()),header:gn({numRequiredSignatures:ln(),numReadonlySignedAccounts:ln(),numReadonlyUnsignedAccounts:ln()}),instructions:sn(gn({accounts:sn(ln()),data:pn(),programIdIndex:ln()})),recentBlockhash:pn(),addressTableLookups:fn(sn(nu))})}),ou=gn({pubkey:Ys,signer:an(),writable:an(),source:fn(mn([cn("transaction"),cn("lookupTable")]))}),su=gn({accountKeys:sn(ou),signatures:sn(pn())}),au=gn({parsed:wn(),program:pn(),programId:Ys}),uu=gn({accounts:sn(Ys),data:pn(),programId:Ys}),cu=bn(mn([uu,au]),mn([gn({parsed:wn(),program:pn(),programId:pn()}),gn({accounts:sn(pn()),data:pn(),programId:pn()})]),(t=>en(t,"accounts"in t?uu:au))),hu=gn({signatures:sn(pn()),message:gn({accountKeys:sn(ou),instructions:sn(cu),recentBlockhash:pn(),addressTableLookups:fn(hn(sn(nu)))})}),lu=gn({accountIndex:ln(),mint:pn(),owner:fn(pn()),uiTokenAmount:Ia}),fu=gn({writable:sn(Ys),readonly:sn(Ys)}),du=gn({err:da,fee:ln(),innerInstructions:fn(hn(sn(gn({index:ln(),instructions:sn(gn({accounts:sn(ln()),data:pn(),programIdIndex:ln()}))})))),preBalances:sn(ln()),postBalances:sn(ln()),logMessages:fn(hn(sn(pn()))),preTokenBalances:fn(hn(sn(lu))),postTokenBalances:fn(hn(sn(lu))),loadedAddresses:fn(fu),computeUnitsConsumed:fn(ln())}),pu=gn({err:da,fee:ln(),innerInstructions:fn(hn(sn(gn({index:ln(),instructions:sn(cu)})))),preBalances:sn(ln()),postBalances:sn(ln()),logMessages:fn(hn(sn(pn()))),preTokenBalances:fn(hn(sn(lu))),postTokenBalances:fn(hn(sn(lu))),loadedAddresses:fn(fu),computeUnitsConsumed:fn(ln())}),yu=mn([cn(0),cn("legacy")]),gu=gn({pubkey:pn(),lamports:ln(),postBalance:hn(ln()),rewardType:hn(pn()),commission:fn(hn(ln()))}),mu=ra(hn(gn({blockhash:pn(),previousBlockhash:pn(),parentSlot:ln(),transactions:sn(gn({transaction:iu,meta:hn(du),version:fn(yu)})),rewards:fn(sn(gu)),blockTime:hn(ln()),blockHeight:hn(ln())}))),wu=ra(hn(gn({blockhash:pn(),previousBlockhash:pn(),parentSlot:ln(),rewards:fn(sn(gu)),blockTime:hn(ln()),blockHeight:hn(ln())}))),bu=ra(hn(gn({blockhash:pn(),previousBlockhash:pn(),parentSlot:ln(),transactions:sn(gn({transaction:su,meta:hn(du),version:fn(yu)})),rewards:fn(sn(gu)),blockTime:hn(ln()),blockHeight:hn(ln())}))),vu=ra(hn(gn({blockhash:pn(),previousBlockhash:pn(),parentSlot:ln(),transactions:sn(gn({transaction:hu,meta:hn(pu),version:fn(yu)})),rewards:fn(sn(gu)),blockTime:hn(ln()),blockHeight:hn(ln())}))),_u=ra(hn(gn({blockhash:pn(),previousBlockhash:pn(),parentSlot:ln(),transactions:sn(gn({transaction:su,meta:hn(pu),version:fn(yu)})),rewards:fn(sn(gu)),blockTime:hn(ln()),blockHeight:hn(ln())}))),ku=ra(hn(gn({blockhash:pn(),previousBlockhash:pn(),parentSlot:ln(),rewards:fn(sn(gu)),blockTime:hn(ln()),blockHeight:hn(ln())}))),Eu=ra(hn(gn({blockhash:pn(),previousBlockhash:pn(),parentSlot:ln(),transactions:sn(gn({transaction:iu,meta:hn(du)})),rewards:fn(sn(gu)),blockTime:hn(ln())}))),xu=ra(hn(gn({blockhash:pn(),previousBlockhash:pn(),parentSlot:ln(),signatures:sn(pn()),blockTime:hn(ln())}))),Su=ra(hn(gn({slot:ln(),meta:hn(du),blockTime:fn(hn(ln())),transaction:iu,version:fn(yu)}))),Au=ra(hn(gn({slot:ln(),transaction:hu,meta:hn(pu),blockTime:fn(hn(ln())),version:fn(yu)}))),Iu=na(gn({blockhash:pn(),feeCalculator:gn({lamportsPerSignature:ln()})})),Bu=na(gn({blockhash:pn(),lastValidBlockHeight:ln()})),Mu=na(an()),Ru=ra(sn(gn({slot:ln(),numTransactions:ln(),numSlots:ln(),samplePeriodSecs:ln()}))),Pu=na(hn(gn({feeCalculator:gn({lamportsPerSignature:ln()})}))),Tu=ra(pn()),Lu=ra(pn()),Ou=gn({err:da,logs:sn(pn()),signature:pn()}),Uu=gn({result:ia(Ou),subscription:ln()}),Cu={"solana-client":"js/0.0.0-development"};class Nu{constructor(t){this._keypair=void 0,this._keypair=t??Mo()}static generate(){return new Nu(Mo())}static fromSecretKey(t,e){if(64!==t.byteLength)throw new Error("bad secret key size");const r=t.slice(32,64);if(!e||!e.skipValidation){const e=t.slice(0,32),n=Ro(e);for(let t=0;t<32;t++)if(r[t]!==n[t])throw new Error("provided secretKey is invalid")}return new Nu({publicKey:r,secretKey:t})}static fromSeed(t){const e=Ro(t),r=new Uint8Array(64);return r.set(t),r.set(e,32),new Nu({publicKey:e,secretKey:r})}get publicKey(){return new Wo(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}}const zu=Object.freeze({CreateLookupTable:{index:0,layout:jr([Nr("instruction"),Rs("recentSlot"),Ur("bumpSeed")])},FreezeLookupTable:{index:1,layout:jr([Nr("instruction")])},ExtendLookupTable:{index:2,layout:jr([Nr("instruction"),Rs(),Wr(Yo(),Or(Nr(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:jr([Nr("instruction")])},CloseLookupTable:{index:4,layout:jr([Nr("instruction")])}});class Du{constructor(){}static createLookupTable(t){const[e,r]=Wo.findProgramAddressSync([t.authority.toBuffer(),Hr(BigInt(t.recentSlot),8)],this.programId),n=xs(zu.CreateLookupTable,{recentSlot:BigInt(t.recentSlot),bumpSeed:r}),i=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1},{pubkey:t.payer,isSigner:!0,isWritable:!0},{pubkey:Ls.programId,isSigner:!1,isWritable:!1}];return[new cs({programId:this.programId,keys:i,data:n}),e]}static freezeLookupTable(t){const e=xs(zu.FreezeLookupTable),r=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return new cs({programId:this.programId,keys:r,data:e})}static extendLookupTable(t){const e=xs(zu.ExtendLookupTable,{addresses:t.addresses.map((t=>t.toBytes()))}),r=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return t.payer&&r.push({pubkey:t.payer,isSigner:!0,isWritable:!0},{pubkey:Ls.programId,isSigner:!1,isWritable:!1}),new cs({programId:this.programId,keys:r,data:e})}static deactivateLookupTable(t){const e=xs(zu.DeactivateLookupTable),r=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1}];return new cs({programId:this.programId,keys:r,data:e})}static closeLookupTable(t){const e=xs(zu.CloseLookupTable),r=[{pubkey:t.lookupTable,isSigner:!1,isWritable:!0},{pubkey:t.authority,isSigner:!0,isWritable:!1},{pubkey:t.recipient,isSigner:!1,isWritable:!0}];return new cs({programId:this.programId,keys:r,data:e})}}Du.programId=new Wo("AddressLookupTab1e1111111111111111111111111");const ju=Object.freeze({RequestUnits:{index:0,layout:jr([Ur("instruction"),Nr("units"),Nr("additionalFee")])},RequestHeapFrame:{index:1,layout:jr([Ur("instruction"),Nr("bytes")])},SetComputeUnitLimit:{index:2,layout:jr([Ur("instruction"),Nr("units")])},SetComputeUnitPrice:{index:3,layout:jr([Ur("instruction"),Rs("microLamports")])}});class Wu{constructor(){}static requestUnits(t){const e=xs(ju.RequestUnits,t);return new cs({keys:[],programId:this.programId,data:e})}static requestHeapFrame(t){const e=xs(ju.RequestHeapFrame,t);return new cs({keys:[],programId:this.programId,data:e})}static setComputeUnitLimit(t){const e=xs(ju.SetComputeUnitLimit,t);return new cs({keys:[],programId:this.programId,data:e})}static setComputeUnitPrice(t){const e=xs(ju.SetComputeUnitPrice,{microLamports:BigInt(t.microLamports)});return new cs({keys:[],programId:this.programId,data:e})}}Wu.programId=new Wo("ComputeBudget111111111111111111111111111111");const Fu=jr([Ur("numSignatures"),Ur("padding"),Cr("signatureOffset"),Cr("signatureInstructionIndex"),Cr("publicKeyOffset"),Cr("publicKeyInstructionIndex"),Cr("messageDataOffset"),Cr("messageDataSize"),Cr("messageInstructionIndex")]);class Ku{constructor(){}static createInstructionWithPublicKey(t){const{publicKey:e,message:r,signature:i,instructionIndex:o}=t;rs(32===e.length,`Public Key must be 32 bytes but received ${e.length} bytes`),rs(64===i.length,`Signature must be 64 bytes but received ${i.length} bytes`);const s=Fu.span,a=s+e.length,u=a+i.length,c=n.Buffer.alloc(u+r.length),h=null==o?65535:o;return Fu.encode({numSignatures:1,padding:0,signatureOffset:a,signatureInstructionIndex:h,publicKeyOffset:s,publicKeyInstructionIndex:h,messageDataOffset:u,messageDataSize:r.length,messageInstructionIndex:h},c),c.fill(e,s),c.fill(i,a),c.fill(r,u),new cs({keys:[],programId:Ku.programId,data:c})}static createInstructionWithPrivateKey(t){const{privateKey:e,message:r,instructionIndex:n}=t;rs(64===e.length,`Private key must be 64 bytes but received ${e.length} bytes`);try{const t=Nu.fromSecretKey(e),i=t.publicKey.toBytes(),o=To(r,t.secretKey);return this.createInstructionWithPublicKey({publicKey:i,message:r,signature:o,instructionIndex:n})}catch(t){throw new Error(`Error creating instruction; ${t}`)}}}Ku.programId=new Wo("Ed25519SigVerify111111111111111111111111111");Io.utils.isValidPrivateKey;const Vu=Io.getPublicKey,qu=jr([Ur("numSignatures"),Cr("signatureOffset"),Ur("signatureInstructionIndex"),Cr("ethAddressOffset"),Ur("ethAddressInstructionIndex"),Cr("messageDataOffset"),Cr("messageDataSize"),Ur("messageInstructionIndex"),Fr(20,"ethAddress"),Fr(64,"signature"),Ur("recoveryId")]);class Hu{constructor(){}static publicKeyToEthAddress(t){rs(64===t.length,`Public key must be 64 bytes but received ${t.length} bytes`);try{return n.Buffer.from(uo(Oo(t))).slice(-20)}catch(t){throw new Error(`Error constructing Ethereum address: ${t}`)}}static createInstructionWithPublicKey(t){const{publicKey:e,message:r,signature:n,recoveryId:i,instructionIndex:o}=t;return Hu.createInstructionWithEthAddress({ethAddress:Hu.publicKeyToEthAddress(e),message:r,signature:n,recoveryId:i,instructionIndex:o})}static createInstructionWithEthAddress(t){const{ethAddress:e,message:r,signature:i,recoveryId:o,instructionIndex:s=0}=t;let a;a="string"==typeof e?e.startsWith("0x")?n.Buffer.from(e.substr(2),"hex"):n.Buffer.from(e,"hex"):e,rs(20===a.length,`Address must be 20 bytes but received ${a.length} bytes`);const u=12+a.length,c=u+i.length+1,h=n.Buffer.alloc(qu.span+r.length);return qu.encode({numSignatures:1,signatureOffset:u,signatureInstructionIndex:s,ethAddressOffset:12,ethAddressInstructionIndex:s,messageDataOffset:c,messageDataSize:r.length,messageInstructionIndex:s,signature:Oo(i),ethAddress:Oo(a),recoveryId:o},h),h.fill(Oo(r),qu.span),new cs({keys:[],programId:Hu.programId,data:h})}static createInstructionWithPrivateKey(t){const{privateKey:e,message:r,instructionIndex:i}=t;rs(32===e.length,`Private key must be 32 bytes but received ${e.length} bytes`);try{const t=Oo(e),o=Vu(t,!1).slice(1),s=n.Buffer.from(uo(Oo(r))),[a,u]=((t,e)=>{const r=Io.sign(t,e);return[r.toCompactRawBytes(),r.recovery]})(s,t);return this.createInstructionWithPublicKey({publicKey:o,message:r,signature:a,recoveryId:u,instructionIndex:i})}catch(t){throw new Error(`Error creating instruction; ${t}`)}}}var $u;Hu.programId=new Wo("KeccakSecp256k11111111111111111111111111111");const Gu=new Wo("StakeConfig11111111111111111111111111111111");class Zu{constructor(t,e){this.staker=void 0,this.withdrawer=void 0,this.staker=t,this.withdrawer=e}}class Yu{constructor(t,e,r){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=t,this.epoch=e,this.custodian=r}}$u=Yu,Yu.default=new $u(0,0,Wo.default);const Ju=Object.freeze({Initialize:{index:0,layout:jr([Nr("instruction"),((t="authorized")=>jr([Yo("staker"),Yo("withdrawer")],t))(),((t="lockup")=>jr([Dr("unixTimestamp"),Dr("epoch"),Yo("custodian")],t))()])},Authorize:{index:1,layout:jr([Nr("instruction"),Yo("newAuthorized"),Nr("stakeAuthorizationType")])},Delegate:{index:2,layout:jr([Nr("instruction")])},Split:{index:3,layout:jr([Nr("instruction"),Dr("lamports")])},Withdraw:{index:4,layout:jr([Nr("instruction"),Dr("lamports")])},Deactivate:{index:5,layout:jr([Nr("instruction")])},Merge:{index:7,layout:jr([Nr("instruction")])},AuthorizeWithSeed:{index:8,layout:jr([Nr("instruction"),Yo("newAuthorized"),Nr("stakeAuthorizationType"),Xo("authoritySeed"),Yo("authorityOwner")])}}),Xu=Object.freeze({Staker:{index:0},Withdrawer:{index:1}});class Qu{constructor(){}static initialize(t){const{stakePubkey:e,authorized:r,lockup:n}=t,i=n||Yu.default,o=xs(Ju.Initialize,{authorized:{staker:Oo(r.staker.toBuffer()),withdrawer:Oo(r.withdrawer.toBuffer())},lockup:{unixTimestamp:i.unixTimestamp,epoch:i.epoch,custodian:Oo(i.custodian.toBuffer())}}),s={keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:ms,isSigner:!1,isWritable:!1}],programId:this.programId,data:o};return new cs(s)}static createAccountWithSeed(t){const e=new hs;e.add(Ls.createAccountWithSeed({fromPubkey:t.fromPubkey,newAccountPubkey:t.stakePubkey,basePubkey:t.basePubkey,seed:t.seed,lamports:t.lamports,space:this.space,programId:this.programId}));const{stakePubkey:r,authorized:n,lockup:i}=t;return e.add(this.initialize({stakePubkey:r,authorized:n,lockup:i}))}static createAccount(t){const e=new hs;e.add(Ls.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.stakePubkey,lamports:t.lamports,space:this.space,programId:this.programId}));const{stakePubkey:r,authorized:n,lockup:i}=t;return e.add(this.initialize({stakePubkey:r,authorized:n,lockup:i}))}static delegate(t){const{stakePubkey:e,authorizedPubkey:r,votePubkey:n}=t,i=xs(Ju.Delegate);return(new hs).add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!1},{pubkey:ds,isSigner:!1,isWritable:!1},{pubkey:_s,isSigner:!1,isWritable:!1},{pubkey:Gu,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:i})}static authorize(t){const{stakePubkey:e,authorizedPubkey:r,newAuthorizedPubkey:n,stakeAuthorizationType:i,custodianPubkey:o}=t,s=xs(Ju.Authorize,{newAuthorized:Oo(n.toBuffer()),stakeAuthorizationType:i.index}),a=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:ds,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}];return o&&a.push({pubkey:o,isSigner:!1,isWritable:!1}),(new hs).add({keys:a,programId:this.programId,data:s})}static authorizeWithSeed(t){const{stakePubkey:e,authorityBase:r,authoritySeed:n,authorityOwner:i,newAuthorizedPubkey:o,stakeAuthorizationType:s,custodianPubkey:a}=t,u=xs(Ju.AuthorizeWithSeed,{newAuthorized:Oo(o.toBuffer()),stakeAuthorizationType:s.index,authoritySeed:n,authorityOwner:Oo(i.toBuffer())}),c=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1},{pubkey:ds,isSigner:!1,isWritable:!1}];return a&&c.push({pubkey:a,isSigner:!1,isWritable:!1}),(new hs).add({keys:c,programId:this.programId,data:u})}static splitInstruction(t){const{stakePubkey:e,authorizedPubkey:r,splitStakePubkey:n,lamports:i}=t,o=xs(Ju.Split,{lamports:i});return new cs({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static split(t){const e=new hs;return e.add(Ls.createAccount({fromPubkey:t.authorizedPubkey,newAccountPubkey:t.splitStakePubkey,lamports:0,space:this.space,programId:this.programId})),e.add(this.splitInstruction(t))}static splitWithSeed(t){const{stakePubkey:e,authorizedPubkey:r,splitStakePubkey:n,basePubkey:i,seed:o,lamports:s}=t,a=new hs;return a.add(Ls.allocate({accountPubkey:n,basePubkey:i,seed:o,space:this.space,programId:this.programId})),a.add(this.splitInstruction({stakePubkey:e,authorizedPubkey:r,splitStakePubkey:n,lamports:s}))}static merge(t){const{stakePubkey:e,sourceStakePubKey:r,authorizedPubkey:n}=t,i=xs(Ju.Merge);return(new hs).add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:ds,isSigner:!1,isWritable:!1},{pubkey:_s,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:i})}static withdraw(t){const{stakePubkey:e,authorizedPubkey:r,toPubkey:n,lamports:i,custodianPubkey:o}=t,s=xs(Ju.Withdraw,{lamports:i}),a=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!0},{pubkey:ds,isSigner:!1,isWritable:!1},{pubkey:_s,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return o&&a.push({pubkey:o,isSigner:!1,isWritable:!1}),(new hs).add({keys:a,programId:this.programId,data:s})}static deactivate(t){const{stakePubkey:e,authorizedPubkey:r}=t,n=xs(Ju.Deactivate);return(new hs).add({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:ds,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}}Qu.programId=new Wo("Stake11111111111111111111111111111111111111"),Qu.space=200;class tc{constructor(t,e,r,n){this.nodePubkey=void 0,this.authorizedVoter=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.nodePubkey=t,this.authorizedVoter=e,this.authorizedWithdrawer=r,this.commission=n}}const ec=Object.freeze({InitializeAccount:{index:0,layout:jr([Nr("instruction"),((t="voteInit")=>jr([Yo("nodePubkey"),Yo("authorizedVoter"),Yo("authorizedWithdrawer"),Ur("commission")],t))()])},Authorize:{index:1,layout:jr([Nr("instruction"),Yo("newAuthorized"),Nr("voteAuthorizationType")])},Withdraw:{index:3,layout:jr([Nr("instruction"),Dr("lamports")])},AuthorizeWithSeed:{index:10,layout:jr([Nr("instruction"),((t="voteAuthorizeWithSeedArgs")=>jr([Nr("voteAuthorizationType"),Yo("currentAuthorityDerivedKeyOwnerPubkey"),Xo("currentAuthorityDerivedKeySeed"),Yo("newAuthorized")],t))()])}}),rc=Object.freeze({Voter:{index:0},Withdrawer:{index:1}});class nc{constructor(){}static initializeAccount(t){const{votePubkey:e,nodePubkey:r,voteInit:n}=t,i=xs(ec.InitializeAccount,{voteInit:{nodePubkey:Oo(n.nodePubkey.toBuffer()),authorizedVoter:Oo(n.authorizedVoter.toBuffer()),authorizedWithdrawer:Oo(n.authorizedWithdrawer.toBuffer()),commission:n.commission}}),o={keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:ms,isSigner:!1,isWritable:!1},{pubkey:ds,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:i};return new cs(o)}static createAccount(t){const e=new hs;return e.add(Ls.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.votePubkey,lamports:t.lamports,space:this.space,programId:this.programId})),e.add(this.initializeAccount({votePubkey:t.votePubkey,nodePubkey:t.voteInit.nodePubkey,voteInit:t.voteInit}))}static authorize(t){const{votePubkey:e,authorizedPubkey:r,newAuthorizedPubkey:n,voteAuthorizationType:i}=t,o=xs(ec.Authorize,{newAuthorized:Oo(n.toBuffer()),voteAuthorizationType:i.index}),s=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:ds,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return(new hs).add({keys:s,programId:this.programId,data:o})}static authorizeWithSeed(t){const{currentAuthorityDerivedKeyBasePubkey:e,currentAuthorityDerivedKeyOwnerPubkey:r,currentAuthorityDerivedKeySeed:n,newAuthorizedPubkey:i,voteAuthorizationType:o,votePubkey:s}=t,a=xs(ec.AuthorizeWithSeed,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:Oo(r.toBuffer()),currentAuthorityDerivedKeySeed:n,newAuthorized:Oo(i.toBuffer()),voteAuthorizationType:o.index}}),u=[{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:ds,isSigner:!1,isWritable:!1},{pubkey:e,isSigner:!0,isWritable:!1}];return(new hs).add({keys:u,programId:this.programId,data:a})}static withdraw(t){const{votePubkey:e,authorizedWithdrawerPubkey:r,lamports:n,toPubkey:i}=t,o=xs(ec.Withdraw,{lamports:n}),s=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}];return(new hs).add({keys:s,programId:this.programId,data:o})}static safeWithdraw(t,e,r){if(t.lamports>e-r)throw new Error("Withdraw will leave vote account with insuffcient funds.");return nc.withdraw(t)}}nc.programId=new Wo("Vote111111111111111111111111111111111111111"),nc.space=3731;const ic=new Wo("Va1idator1nfo111111111111111111111111111111"),oc=gn({name:pn(),website:fn(pn()),details:fn(pn()),keybaseUsername:fn(pn())});class sc{constructor(t,e){this.key=void 0,this.info=void 0,this.key=t,this.info=e}static fromConfigData(t){let e=[...t];if(2!==ts(e))return null;const r=[];for(let t=0;t<2;t++){const t=new Wo(e.slice(0,Do));e=e.slice(Do);const n=1===e.slice(0,1)[0];e=e.slice(1),r.push({publicKey:t,isSigner:n})}if(r[0].publicKey.equals(ic)&&r[1].isSigner){const t=Xo().decode(n.Buffer.from(e)),i=JSON.parse(t);return tn(i,oc),new sc(r[1].publicKey,i)}return null}}const ac=new Wo("Vote111111111111111111111111111111111111111"),uc=jr([Yo("nodePubkey"),Yo("authorizedWithdrawer"),Ur("commission"),zr(),Wr(jr([zr("slot"),Nr("confirmationCount")]),Or(Nr(),-8),"votes"),Ur("rootSlotValid"),zr("rootSlot"),zr(),Wr(jr([zr("epoch"),Yo("authorizedVoter")]),Or(Nr(),-8),"authorizedVoters"),jr([Wr(jr([Yo("authorizedPubkey"),zr("epochOfLastAuthorizedSwitch"),zr("targetEpoch")]),32,"buf"),zr("idx"),Ur("isEmpty")],"priorVoters"),zr(),Wr(jr([zr("epoch"),zr("credits"),zr("prevCredits")]),Or(Nr(),-8),"epochCredits"),jr([zr("slot"),zr("timestamp")],"lastTimestamp")]);class cc{constructor(t){this.nodePubkey=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.rootSlot=void 0,this.votes=void 0,this.authorizedVoters=void 0,this.priorVoters=void 0,this.epochCredits=void 0,this.lastTimestamp=void 0,this.nodePubkey=t.nodePubkey,this.authorizedWithdrawer=t.authorizedWithdrawer,this.commission=t.commission,this.rootSlot=t.rootSlot,this.votes=t.votes,this.authorizedVoters=t.authorizedVoters,this.priorVoters=t.priorVoters,this.epochCredits=t.epochCredits,this.lastTimestamp=t.lastTimestamp}static fromAccountData(t){const e=uc.decode(Oo(t),4);let r=e.rootSlot;return e.rootSlotValid||(r=null),new cc({nodePubkey:new Wo(e.nodePubkey),authorizedWithdrawer:new Wo(e.authorizedWithdrawer),commission:e.commission,votes:e.votes,rootSlot:r,authorizedVoters:e.authorizedVoters.map(hc),priorVoters:fc(e.priorVoters),epochCredits:e.epochCredits,lastTimestamp:e.lastTimestamp})}}function hc({authorizedVoter:t,epoch:e}){return{epoch:e,authorizedVoter:new Wo(t)}}function lc({authorizedPubkey:t,epochOfLastAuthorizedSwitch:e,targetEpoch:r}){return{authorizedPubkey:new Wo(t),epochOfLastAuthorizedSwitch:e,targetEpoch:r}}function fc({buf:t,idx:e,isEmpty:r}){return r?[]:[...t.slice(e+1).map(lc),...t.slice(0,e).map(lc)]}const dc={http:{devnet:"http://api.devnet.solana.com",testnet:"http://api.testnet.solana.com","mainnet-beta":"http://api.mainnet-beta.solana.com/"},https:{devnet:"https://api.devnet.solana.com",testnet:"https://api.testnet.solana.com","mainnet-beta":"https://api.mainnet-beta.solana.com/"}};var pc=Object.freeze({__proto__:null,Account:class{constructor(t){if(this._publicKey=void 0,this._secretKey=void 0,t){const e=Oo(t);if(64!==t.length)throw new Error("bad secret key size");this._publicKey=e.slice(32,64),this._secretKey=e.slice(0,32)}else this._secretKey=Oo(Bo()),this._publicKey=Oo(Ro(this._secretKey))}get publicKey(){return new Wo(this._publicKey)}get secretKey(){return n.Buffer.concat([this._secretKey,this._publicKey],64)}},AddressLookupTableAccount:$s,AddressLookupTableInstruction:class{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const e=Nr("instruction").decode(t.data);let r;for(const[t,n]of Object.entries(zu))if(n.index==e){r=t;break}if(!r)throw new Error("Invalid Instruction. Should be a LookupTable Instruction");return r}static decodeCreateLookupTable(t){this.checkProgramId(t.programId),this.checkKeysLength(t.keys,4);const{recentSlot:e}=Ss(zu.CreateLookupTable,t.data);return{authority:t.keys[1].pubkey,payer:t.keys[2].pubkey,recentSlot:Number(e)}}static decodeExtendLookupTable(t){if(this.checkProgramId(t.programId),t.keys.length<2)throw new Error(`invalid instruction; found ${t.keys.length} keys, expected at least 2`);const{addresses:e}=Ss(zu.ExtendLookupTable,t.data);return{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey,payer:t.keys.length>2?t.keys[2].pubkey:void 0,addresses:e.map((t=>new Wo(t)))}}static decodeCloseLookupTable(t){return this.checkProgramId(t.programId),this.checkKeysLength(t.keys,3),{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey,recipient:t.keys[2].pubkey}}static decodeFreezeLookupTable(t){return this.checkProgramId(t.programId),this.checkKeysLength(t.keys,2),{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey}}static decodeDeactivateLookupTable(t){return this.checkProgramId(t.programId),this.checkKeysLength(t.keys,2),{lookupTable:t.keys[0].pubkey,authority:t.keys[1].pubkey}}static checkProgramId(t){if(!t.equals(Du.programId))throw new Error("invalid instruction; programId is not AddressLookupTable Program")}static checkKeysLength(t,e){if(t.length<e)throw new Error(`invalid instruction; found ${t.length} keys, expected at least ${e}`)}},AddressLookupTableProgram:Du,Authorized:Zu,BLOCKHASH_CACHE_TIMEOUT_MS:3e4,BPF_LOADER_DEPRECATED_PROGRAM_ID:Fo,BPF_LOADER_PROGRAM_ID:Us,BpfLoader:class{static getMinNumSignatures(t){return Os.getMinNumSignatures(t)}static load(t,e,r,n,i){return Os.load(t,e,r,i,n)}},COMPUTE_BUDGET_INSTRUCTION_LAYOUTS:ju,ComputeBudgetInstruction:class{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const e=Ur("instruction").decode(t.data);let r;for(const[t,n]of Object.entries(ju))if(n.index==e){r=t;break}if(!r)throw new Error("Instruction type incorrect; not a ComputeBudgetInstruction");return r}static decodeRequestUnits(t){this.checkProgramId(t.programId);const{units:e,additionalFee:r}=Ss(ju.RequestUnits,t.data);return{units:e,additionalFee:r}}static decodeRequestHeapFrame(t){this.checkProgramId(t.programId);const{bytes:e}=Ss(ju.RequestHeapFrame,t.data);return{bytes:e}}static decodeSetComputeUnitLimit(t){this.checkProgramId(t.programId);const{units:e}=Ss(ju.SetComputeUnitLimit,t.data);return{units:e}}static decodeSetComputeUnitPrice(t){this.checkProgramId(t.programId);const{microLamports:e}=Ss(ju.SetComputeUnitPrice,t.data);return{microLamports:e}}static checkProgramId(t){if(!t.equals(Wu.programId))throw new Error("invalid instruction; programId is not ComputeBudgetProgram")}},ComputeBudgetProgram:Wu,Connection:class{constructor(t,e){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 t={};return async e=>{const{commitment:r,config:n}=Qs(e),i=this._buildArgs([],r,void 0,n),o=js(i);return t[o]=t[o]??(async()=>{try{const t=en(await this._rpcRequest("getBlockHeight",i),ra(ln()));if("error"in t)throw new Vs(t.error,"failed to get block height information");return t.result}finally{delete t[o]}})(),await t[o]}})(),e&&"string"==typeof e?this._commitment=e:e&&(this._commitment=e.commitment,this._confirmTransactionInitialTimeout=e.confirmTransactionInitialTimeout,r=e.wsEndpoint,n=e.httpHeaders,i=e.fetch,o=e.fetchMiddleware,s=e.disableRetryOnRateLimit,a=e.httpAgent),this._rpcEndpoint=function(t){if(!1===/^https?:/.test(t))throw new TypeError("Endpoint URL must start with `http:` or `https:`.");return t}(t),this._rpcWsEndpoint=r||function(t){const e=t.match(Zs);if(null==e)throw TypeError(`Failed to validate endpoint URL \`${t}\``);const[r,n,i,o]=e,s=t.startsWith("https:")?"wss:":"ws:",a=null==i?null:parseInt(i.slice(1),10);return`${s}//${n}${null==a?"":`:${a+1}`}${o}`}(t),this._rpcClient=function(t,e,r,n,i,o){const s=r||qs;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(t,e)=>{const r=await new Promise(((r,i)=>{try{n(t,e,((t,e)=>r([t,e])))}catch(t){i(t)}}));return await s(...r)});const u=new ei((async(r,n)=>{const o={method:"POST",body:r,agent:void 0,headers:Object.assign({"Content-Type":"application/json"},e||{},Cu)};try{let e,r=5,u=500;for(;e=a?await a(t,o):await s(t,o),429===e.status&&!0!==i&&(r-=1,0!==r);)console.log(`Server responded with ${e.status} ${e.statusText}. Retrying after ${u}ms delay...`),await Es(u),u*=2;const c=await e.text();e.ok?n(null,c):n(new Error(`${e.status} ${e.statusText}: ${c}`))}catch(t){t instanceof Error&&n(t)}}),{});return u}(t,n,i,o,s,a),this._rpcRequest=function(t){return(e,r)=>new Promise(((n,i)=>{t.request(e,r,((t,e)=>{t?i(t):n(e)}))}))}(this._rpcClient),this._rpcBatchRequest=function(t){return e=>new Promise(((r,n)=>{0===e.length&&r([]);const i=e.map((e=>t.request(e.methodName,e.args)));t.request(i,((t,e)=>{t?n(t):r(e)}))}))}(this._rpcClient),this._rpcWebSocket=new Hs(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(t,e){const{commitment:r,config:n}=Qs(e),i=this._buildArgs([t.toBase58()],r,void 0,n),o=en(await this._rpcRequest("getBalance",i),na(ln()));if("error"in o)throw new Vs(o.error,`failed to get balance for ${t.toBase58()}`);return o.result}async getBalance(t,e){return await this.getBalanceAndContext(t,e).then((t=>t.value)).catch((e=>{throw new Error("failed to get balance of account "+t.toBase58()+": "+e)}))}async getBlockTime(t){const e=en(await this._rpcRequest("getBlockTime",[t]),ra(hn(ln())));if("error"in e)throw new Vs(e.error,`failed to get block time for slot ${t}`);return e.result}async getMinimumLedgerSlot(){const t=en(await this._rpcRequest("minimumLedgerSlot",[]),ra(ln()));if("error"in t)throw new Vs(t.error,"failed to get minimum ledger slot");return t.result}async getFirstAvailableBlock(){const t=en(await this._rpcRequest("getFirstAvailableBlock",[]),Sa);if("error"in t)throw new Vs(t.error,"failed to get first available block");return t.result}async getSupply(t){let e={};e="string"==typeof t?{commitment:t}:t?{...t,commitment:t&&t.commitment||this.commitment}:{commitment:this.commitment};const r=en(await this._rpcRequest("getSupply",[e]),Aa);if("error"in r)throw new Vs(r.error,"failed to get supply");return r.result}async getTokenSupply(t,e){const r=this._buildArgs([t.toBase58()],e),n=en(await this._rpcRequest("getTokenSupply",r),na(Ia));if("error"in n)throw new Vs(n.error,"failed to get token supply");return n.result}async getTokenAccountBalance(t,e){const r=this._buildArgs([t.toBase58()],e),n=en(await this._rpcRequest("getTokenAccountBalance",r),na(Ia));if("error"in n)throw new Vs(n.error,"failed to get token account balance");return n.result}async getTokenAccountsByOwner(t,e,r){const{commitment:n,config:i}=Qs(r);let o=[t.toBase58()];"mint"in e?o.push({mint:e.mint.toBase58()}):o.push({programId:e.programId.toBase58()});const s=this._buildArgs(o,n,"base64",i),a=en(await this._rpcRequest("getTokenAccountsByOwner",s),Ma);if("error"in a)throw new Vs(a.error,`failed to get token accounts owned by account ${t.toBase58()}`);return a.result}async getParsedTokenAccountsByOwner(t,e,r){let n=[t.toBase58()];"mint"in e?n.push({mint:e.mint.toBase58()}):n.push({programId:e.programId.toBase58()});const i=this._buildArgs(n,r,"jsonParsed"),o=en(await this._rpcRequest("getTokenAccountsByOwner",i),Pa);if("error"in o)throw new Vs(o.error,`failed to get token accounts owned by account ${t.toBase58()}`);return o.result}async getLargestAccounts(t){const e={...t,commitment:t&&t.commitment||this.commitment},r=e.filter||e.commitment?[e]:[],n=en(await this._rpcRequest("getLargestAccounts",r),Ta);if("error"in n)throw new Vs(n.error,"failed to get largest accounts");return n.result}async getTokenLargestAccounts(t,e){const r=this._buildArgs([t.toBase58()],e),n=en(await this._rpcRequest("getTokenLargestAccounts",r),Ba);if("error"in n)throw new Vs(n.error,"failed to get token largest accounts");return n.result}async getAccountInfoAndContext(t,e){const{commitment:r,config:n}=Qs(e),i=this._buildArgs([t.toBase58()],r,"base64",n),o=en(await this._rpcRequest("getAccountInfo",i),na(hn(La)));if("error"in o)throw new Vs(o.error,`failed to get info about account ${t.toBase58()}`);return o.result}async getParsedAccountInfo(t,e){const{commitment:r,config:n}=Qs(e),i=this._buildArgs([t.toBase58()],r,"jsonParsed",n),o=en(await this._rpcRequest("getAccountInfo",i),na(hn(Ca)));if("error"in o)throw new Vs(o.error,`failed to get info about account ${t.toBase58()}`);return o.result}async getAccountInfo(t,e){try{return(await this.getAccountInfoAndContext(t,e)).value}catch(e){throw new Error("failed to get info about account "+t.toBase58()+": "+e)}}async getMultipleParsedAccounts(t,e){const{commitment:r,config:n}=Qs(e),i=t.map((t=>t.toBase58())),o=this._buildArgs([i],r,"jsonParsed",n),s=en(await this._rpcRequest("getMultipleAccounts",o),na(sn(hn(Ca))));if("error"in s)throw new Vs(s.error,`failed to get info for accounts ${i}`);return s.result}async getMultipleAccountsInfoAndContext(t,e){const{commitment:r,config:n}=Qs(e),i=t.map((t=>t.toBase58())),o=this._buildArgs([i],r,"base64",n),s=en(await this._rpcRequest("getMultipleAccounts",o),na(sn(hn(La))));if("error"in s)throw new Vs(s.error,`failed to get info for accounts ${i}`);return s.result}async getMultipleAccountsInfo(t,e){return(await this.getMultipleAccountsInfoAndContext(t,e)).value}async getStakeActivation(t,e,r){const{commitment:n,config:i}=Qs(e),o=this._buildArgs([t.toBase58()],n,void 0,{...i,epoch:null!=r?r:i?.epoch}),s=en(await this._rpcRequest("getStakeActivation",o),ra(za));if("error"in s)throw new Vs(s.error,`failed to get Stake Activation ${t.toBase58()}`);return s.result}async getProgramAccounts(t,e){const{commitment:r,config:n}=Qs(e),{encoding:i,...o}=n||{},s=this._buildArgs([t.toBase58()],r,i||"base64",o),a=await this._rpcRequest("getProgramAccounts",s),u=sn(Oa),c=!0===o.withContext?en(a,na(u)):en(a,ra(u));if("error"in c)throw new Vs(c.error,`failed to get accounts owned by program ${t.toBase58()}`);return c.result}async getParsedProgramAccounts(t,e){const{commitment:r,config:n}=Qs(e),i=this._buildArgs([t.toBase58()],r,"jsonParsed",n),o=en(await this._rpcRequest("getProgramAccounts",i),ra(sn(Na)));if("error"in o)throw new Vs(o.error,`failed to get accounts owned by program ${t.toBase58()}`);return o.result}async confirmTransaction(t,e){let r,n;if("string"==typeof t)r=t;else{const e=t;if(e.abortSignal?.aborted)return Promise.reject(e.abortSignal.reason);r=e.signature}try{n=ae.decode(r)}catch(t){throw new Error("signature must be base58 encoded: "+r)}return rs(64===n.length,"signature has invalid length"),"string"==typeof t?await this.confirmTransactionUsingLegacyTimeoutStrategy({commitment:e||this.commitment,signature:r}):"lastValidBlockHeight"in t?await this.confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:e||this.commitment,strategy:t}):await this.confirmTransactionUsingDurableNonceStrategy({commitment:e||this.commitment,strategy:t})}getCancellationPromise(t){return new Promise(((e,r)=>{null!=t&&(t.aborted?r(t.reason):t.addEventListener("abort",(()=>{r(t.reason)})))}))}getTransactionConfirmationPromise({commitment:t,signature:e}){let r,n,i=!1;const o=new Promise(((o,s)=>{try{r=this.onSignature(e,((t,e)=>{r=void 0;const n={context:e,value:t};o({__type:as.PROCESSED,response:n})}),t);const a=new Promise((t=>{null==r?t():n=this._onSubscriptionStateChange(r,(e=>{"subscribed"===e&&t()}))}));(async()=>{if(await a,i)return;const r=await this.getSignatureStatus(e);if(i)return;if(null==r)return;const{context:n,value:u}=r;if(null!=u)if(u?.err)s(u.err);else{switch(t){case"confirmed":case"single":case"singleGossip":if("processed"===u.confirmationStatus)return;break;case"finalized":case"max":case"root":if("processed"===u.confirmationStatus||"confirmed"===u.confirmationStatus)return}i=!0,o({__type:as.PROCESSED,response:{context:n,value:u}})}})()}catch(t){s(t)}}));return{abortConfirmation:()=>{n&&(n(),n=void 0),null!=r&&(this.removeSignatureListener(r),r=void 0)},confirmationPromise:o}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:t,strategy:{abortSignal:e,lastValidBlockHeight:r,signature:n}}){let i=!1;const o=new Promise((e=>{const n=async()=>{try{return await this.getBlockHeight(t)}catch(t){return-1}};(async()=>{let t=await n();if(!i){for(;t<=r;){if(await Es(1e3),i)return;if(t=await n(),i)return}e({__type:as.BLOCKHEIGHT_EXCEEDED})}})()})),{abortConfirmation:s,confirmationPromise:a}=this.getTransactionConfirmationPromise({commitment:t,signature:n}),u=this.getCancellationPromise(e);let c;try{const t=await Promise.race([u,a,o]);if(t.__type!==as.PROCESSED)throw new Ho(n);c=t.response}finally{i=!0,s()}return c}async confirmTransactionUsingDurableNonceStrategy({commitment:t,strategy:{abortSignal:e,minContextSlot:r,nonceAccountPubkey:n,nonceValue:i,signature:o}}){let s=!1;const a=new Promise((e=>{let o=i,a=null;const u=async()=>{try{const{context:e,value:i}=await this.getNonceAndContext(n,{commitment:t,minContextSlot:r});return a=e.slot,i?.nonce}catch(t){return o}};(async()=>{if(o=await u(),!s)for(;;){if(i!==o)return void e({__type:as.NONCE_INVALID,slotInWhichNonceDidAdvance:a});if(await Es(2e3),s)return;if(o=await u(),s)return}})()})),{abortConfirmation:u,confirmationPromise:c}=this.getTransactionConfirmationPromise({commitment:t,signature:o}),h=this.getCancellationPromise(e);let l;try{const e=await Promise.race([h,c,a]);if(e.__type===as.PROCESSED)l=e.response;else{let n;for(;;){const t=await this.getSignatureStatus(o);if(null==t)break;if(!(t.context.slot<(e.slotInWhichNonceDidAdvance??r))){n=t;break}await Es(400)}if(!n?.value)throw new Go(o);{const e=t||"finalized",{confirmationStatus:r}=n.value;switch(e){case"processed":case"recent":if("processed"!==r&&"confirmed"!==r&&"finalized"!==r)throw new Go(o);break;case"confirmed":case"single":case"singleGossip":if("confirmed"!==r&&"finalized"!==r)throw new Go(o);break;case"finalized":case"max":case"root":if("finalized"!==r)throw new Go(o)}l={context:n.context,value:{err:n.value.err}}}}}finally{s=!0,u()}return l}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:t,signature:e}){let r;const n=new Promise((e=>{let n=this._confirmTransactionInitialTimeout||6e4;switch(t){case"processed":case"recent":case"single":case"confirmed":case"singleGossip":n=this._confirmTransactionInitialTimeout||3e4}r=setTimeout((()=>e({__type:as.TIMED_OUT,timeoutMs:n})),n)})),{abortConfirmation:i,confirmationPromise:o}=this.getTransactionConfirmationPromise({commitment:t,signature:e});let s;try{const t=await Promise.race([o,n]);if(t.__type!==as.PROCESSED)throw new $o(e,t.timeoutMs/1e3);s=t.response}finally{clearTimeout(r),i()}return s}async getClusterNodes(){const t=en(await this._rpcRequest("getClusterNodes",[]),ra(sn(Ya)));if("error"in t)throw new Vs(t.error,"failed to get cluster nodes");return t.result}async getVoteAccounts(t){const e=this._buildArgs([],t),r=en(await this._rpcRequest("getVoteAccounts",e),Xa);if("error"in r)throw new Vs(r.error,"failed to get vote accounts");return r.result}async getSlot(t){const{commitment:e,config:r}=Qs(t),n=this._buildArgs([],e,void 0,r),i=en(await this._rpcRequest("getSlot",n),ra(ln()));if("error"in i)throw new Vs(i.error,"failed to get slot");return i.result}async getSlotLeader(t){const{commitment:e,config:r}=Qs(t),n=this._buildArgs([],e,void 0,r),i=en(await this._rpcRequest("getSlotLeader",n),ra(pn()));if("error"in i)throw new Vs(i.error,"failed to get slot leader");return i.result}async getSlotLeaders(t,e){const r=[t,e],n=en(await this._rpcRequest("getSlotLeaders",r),ra(sn(Ys)));if("error"in n)throw new Vs(n.error,"failed to get slot leaders");return n.result}async getSignatureStatus(t,e){const{context:r,value:n}=await this.getSignatureStatuses([t],e);rs(1===n.length);return{context:r,value:n[0]}}async getSignatureStatuses(t,e){const r=[t];e&&r.push(e);const n=en(await this._rpcRequest("getSignatureStatuses",r),eu);if("error"in n)throw new Vs(n.error,"failed to get signature status");return n.result}async getTransactionCount(t){const{commitment:e,config:r}=Qs(t),n=this._buildArgs([],e,void 0,r),i=en(await this._rpcRequest("getTransactionCount",n),ra(ln()));if("error"in i)throw new Vs(i.error,"failed to get transaction count");return i.result}async getTotalSupply(t){return(await this.getSupply({commitment:t,excludeNonCirculatingAccountsList:!0})).value.total}async getInflationGovernor(t){const e=this._buildArgs([],t),r=en(await this._rpcRequest("getInflationGovernor",e),ba);if("error"in r)throw new Vs(r.error,"failed to get inflation");return r.result}async getInflationReward(t,e,r){const{commitment:n,config:i}=Qs(r),o=this._buildArgs([t.map((t=>t.toBase58()))],n,void 0,{...i,epoch:null!=e?e:i?.epoch}),s=en(await this._rpcRequest("getInflationReward",o),aa);if("error"in s)throw new Vs(s.error,"failed to get inflation reward");return s.result}async getInflationRate(){const t=en(await this._rpcRequest("getInflationRate",[]),va);if("error"in t)throw new Vs(t.error,"failed to get inflation rate");return t.result}async getEpochInfo(t){const{commitment:e,config:r}=Qs(t),n=this._buildArgs([],e,void 0,r),i=en(await this._rpcRequest("getEpochInfo",n),ka);if("error"in i)throw new Vs(i.error,"failed to get epoch info");return i.result}async getEpochSchedule(){const t=en(await this._rpcRequest("getEpochSchedule",[]),Ea);if("error"in t)throw new Vs(t.error,"failed to get epoch schedule");const e=t.result;return new Fs(e.slotsPerEpoch,e.leaderScheduleSlotOffset,e.warmup,e.firstNormalEpoch,e.firstNormalSlot)}async getLeaderSchedule(){const t=en(await this._rpcRequest("getLeaderSchedule",[]),xa);if("error"in t)throw new Vs(t.error,"failed to get leader schedule");return t.result}async getMinimumBalanceForRentExemption(t,e){const r=this._buildArgs([t],e),n=en(await this._rpcRequest("getMinimumBalanceForRentExemption",r),ru);return"error"in n?(console.warn("Unable to fetch minimum balance for rent exemption"),0):n.result}async getRecentBlockhashAndContext(t){const e=this._buildArgs([],t),r=en(await this._rpcRequest("getRecentBlockhash",e),Iu);if("error"in r)throw new Vs(r.error,"failed to get recent blockhash");return r.result}async getRecentPerformanceSamples(t){const e=en(await this._rpcRequest("getRecentPerformanceSamples",t?[t]:[]),Ru);if("error"in e)throw new Vs(e.error,"failed to get recent performance samples");return e.result}async getFeeCalculatorForBlockhash(t,e){const r=this._buildArgs([t],e),n=en(await this._rpcRequest("getFeeCalculatorForBlockhash",r),Pu);if("error"in n)throw new Vs(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(t,e){const r=Oo(t.serialize()).toString("base64"),n=this._buildArgs([r],e),i=en(await this._rpcRequest("getFeeForMessage",n),na(hn(ln())));if("error"in i)throw new Vs(i.error,"failed to get fee for message");if(null===i.result)throw new Error("invalid blockhash");return i.result}async getRecentPrioritizationFees(t){const e=t?.lockedWritableAccounts?.map((t=>t.toBase58())),r=e?.length?[e]:[],n=en(await this._rpcRequest("getRecentPrioritizationFees",r),_a);if("error"in n)throw new Vs(n.error,"failed to get recent prioritization fees");return n.result}async getRecentBlockhash(t){try{return(await this.getRecentBlockhashAndContext(t)).value}catch(t){throw new Error("failed to get recent blockhash: "+t)}}async getLatestBlockhash(t){try{return(await this.getLatestBlockhashAndContext(t)).value}catch(t){throw new Error("failed to get recent blockhash: "+t)}}async getLatestBlockhashAndContext(t){const{commitment:e,config:r}=Qs(t),n=this._buildArgs([],e,void 0,r),i=en(await this._rpcRequest("getLatestBlockhash",n),Bu);if("error"in i)throw new Vs(i.error,"failed to get latest blockhash");return i.result}async isBlockhashValid(t,e){const{commitment:r,config:n}=Qs(e),i=this._buildArgs([t],r,void 0,n),o=en(await this._rpcRequest("isBlockhashValid",i),Mu);if("error"in o)throw new Vs(o.error,"failed to determine if the blockhash `"+t+"`is valid");return o.result}async getVersion(){const t=en(await this._rpcRequest("getVersion",[]),ra(ga));if("error"in t)throw new Vs(t.error,"failed to get version");return t.result}async getGenesisHash(){const t=en(await this._rpcRequest("getGenesisHash",[]),ra(pn()));if("error"in t)throw new Vs(t.error,"failed to get genesis hash");return t.result}async getBlock(t,e){const{commitment:r,config:n}=Qs(e),i=this._buildArgsAtLeastConfirmed([t],r,void 0,n),o=await this._rpcRequest("getBlock",i);try{switch(n?.transactionDetails){case"accounts":{const t=en(o,bu);if("error"in t)throw t.error;return t.result}case"none":{const t=en(o,wu);if("error"in t)throw t.error;return t.result}default:{const t=en(o,mu);if("error"in t)throw t.error;const{result:e}=t;return e?{...e,transactions:e.transactions.map((({transaction:t,meta:e,version:r})=>({meta:e,transaction:{...t,message:oa(r,t.message)},version:r})))}:null}}}catch(t){throw new Vs(t,"failed to get confirmed block")}}async getParsedBlock(t,e){const{commitment:r,config:n}=Qs(e),i=this._buildArgsAtLeastConfirmed([t],r,"jsonParsed",n),o=await this._rpcRequest("getBlock",i);try{switch(n?.transactionDetails){case"accounts":{const t=en(o,_u);if("error"in t)throw t.error;return t.result}case"none":{const t=en(o,ku);if("error"in t)throw t.error;return t.result}default:{const t=en(o,vu);if("error"in t)throw t.error;return t.result}}}catch(t){throw new Vs(t,"failed to get block")}}async getBlockProduction(t){let e,r;if("string"==typeof t)r=t;else if(t){const{commitment:n,...i}=t;r=n,e=i}const n=this._buildArgs([],r,"base64",e),i=en(await this._rpcRequest("getBlockProduction",n),wa);if("error"in i)throw new Vs(i.error,"failed to get block production information");return i.result}async getTransaction(t,e){const{commitment:r,config:n}=Qs(e),i=this._buildArgsAtLeastConfirmed([t],r,void 0,n),o=en(await this._rpcRequest("getTransaction",i),Su);if("error"in o)throw new Vs(o.error,"failed to get transaction");const s=o.result;return s?{...s,transaction:{...s.transaction,message:oa(s.version,s.transaction.message)}}:s}async getParsedTransaction(t,e){const{commitment:r,config:n}=Qs(e),i=this._buildArgsAtLeastConfirmed([t],r,"jsonParsed",n),o=en(await this._rpcRequest("getTransaction",i),Au);if("error"in o)throw new Vs(o.error,"failed to get transaction");return o.result}async getParsedTransactions(t,e){const{commitment:r,config:n}=Qs(e),i=t.map((t=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([t],r,"jsonParsed",n)})));return(await this._rpcBatchRequest(i)).map((t=>{const e=en(t,Au);if("error"in e)throw new Vs(e.error,"failed to get transactions");return e.result}))}async getTransactions(t,e){const{commitment:r,config:n}=Qs(e),i=t.map((t=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([t],r,void 0,n)})));return(await this._rpcBatchRequest(i)).map((t=>{const e=en(t,Su);if("error"in e)throw new Vs(e.error,"failed to get transactions");const r=e.result;return r?{...r,transaction:{...r.transaction,message:oa(r.version,r.transaction.message)}}:r}))}async getConfirmedBlock(t,e){const r=this._buildArgsAtLeastConfirmed([t],e),n=en(await this._rpcRequest("getConfirmedBlock",r),Eu);if("error"in n)throw new Vs(n.error,"failed to get confirmed block");const i=n.result;if(!i)throw new Error("Confirmed block "+t+" not found");const o={...i,transactions:i.transactions.map((({transaction:t,meta:e})=>{const r=new is(t.message);return{meta:e,transaction:{...t,message:r}}}))};return{...o,transactions:o.transactions.map((({transaction:t,meta:e})=>({meta:e,transaction:hs.populate(t.message,t.signatures)})))}}async getBlocks(t,e,r){const n=this._buildArgsAtLeastConfirmed(void 0!==e?[t,e]:[t],r),i=en(await this._rpcRequest("getBlocks",n),ra(sn(ln())));if("error"in i)throw new Vs(i.error,"failed to get blocks");return i.result}async getBlockSignatures(t,e){const r=this._buildArgsAtLeastConfirmed([t],e,void 0,{transactionDetails:"signatures",rewards:!1}),n=en(await this._rpcRequest("getBlock",r),xu);if("error"in n)throw new Vs(n.error,"failed to get block");const i=n.result;if(!i)throw new Error("Block "+t+" not found");return i}async getConfirmedBlockSignatures(t,e){const r=this._buildArgsAtLeastConfirmed([t],e,void 0,{transactionDetails:"signatures",rewards:!1}),n=en(await this._rpcRequest("getConfirmedBlock",r),xu);if("error"in n)throw new Vs(n.error,"failed to get confirmed block");const i=n.result;if(!i)throw new Error("Confirmed block "+t+" not found");return i}async getConfirmedTransaction(t,e){const r=this._buildArgsAtLeastConfirmed([t],e),n=en(await this._rpcRequest("getConfirmedTransaction",r),Su);if("error"in n)throw new Vs(n.error,"failed to get transaction");const i=n.result;if(!i)return i;const o=new is(i.transaction.message),s=i.transaction.signatures;return{...i,transaction:hs.populate(o,s)}}async getParsedConfirmedTransaction(t,e){const r=this._buildArgsAtLeastConfirmed([t],e,"jsonParsed"),n=en(await this._rpcRequest("getConfirmedTransaction",r),Au);if("error"in n)throw new Vs(n.error,"failed to get confirmed transaction");return n.result}async getParsedConfirmedTransactions(t,e){const r=t.map((t=>({methodName:"getConfirmedTransaction",args:this._buildArgsAtLeastConfirmed([t],e,"jsonParsed")})));return(await this._rpcBatchRequest(r)).map((t=>{const e=en(t,Au);if("error"in e)throw new Vs(e.error,"failed to get confirmed transactions");return e.result}))}async getConfirmedSignaturesForAddress(t,e,r){let n={},i=await this.getFirstAvailableBlock();for(;!("until"in n)&&!(--e<=0||e<i);)try{const t=await this.getConfirmedBlockSignatures(e,"finalized");t.signatures.length>0&&(n.until=t.signatures[t.signatures.length-1].toString())}catch(t){if(t instanceof Error&&t.message.includes("skipped"))continue;throw t}let o=await this.getSlot("finalized");for(;!("before"in n||++r>o);)try{const t=await this.getConfirmedBlockSignatures(r);t.signatures.length>0&&(n.before=t.signatures[t.signatures.length-1].toString())}catch(t){if(t instanceof Error&&t.message.includes("skipped"))continue;throw t}return(await this.getConfirmedSignaturesForAddress2(t,n)).map((t=>t.signature))}async getConfirmedSignaturesForAddress2(t,e,r){const n=this._buildArgsAtLeastConfirmed([t.toBase58()],r,void 0,e),i=en(await this._rpcRequest("getConfirmedSignaturesForAddress2",n),Da);if("error"in i)throw new Vs(i.error,"failed to get confirmed signatures for address");return i.result}async getSignaturesForAddress(t,e,r){const n=this._buildArgsAtLeastConfirmed([t.toBase58()],r,void 0,e),i=en(await this._rpcRequest("getSignaturesForAddress",n),ja);if("error"in i)throw new Vs(i.error,"failed to get signatures for address");return i.result}async getAddressLookupTable(t,e){const{context:r,value:n}=await this.getAccountInfoAndContext(t,e);let i=null;return null!==n&&(i=new $s({key:t,state:$s.deserialize(n.data)})),{context:r,value:i}}async getNonceAndContext(t,e){const{context:r,value:n}=await this.getAccountInfoAndContext(t,e);let i=null;return null!==n&&(i=Ms.fromAccountData(n.data)),{context:r,value:i}}async getNonce(t,e){return await this.getNonceAndContext(t,e).then((t=>t.value)).catch((e=>{throw new Error("failed to get nonce for account "+t.toBase58()+": "+e)}))}async requestAirdrop(t,e){const r=en(await this._rpcRequest("requestAirdrop",[t.toBase58(),e]),Tu);if("error"in r)throw new Vs(r.error,`airdrop to ${t.toBase58()} failed`);return r.result}async _blockhashWithExpiryBlockHeight(t){if(!t){for(;this._pollingBlockhash;)await Es(100);const t=Date.now()-this._blockhashInfo.lastFetch>=3e4;if(null!==this._blockhashInfo.latestBlockhash&&!t)return this._blockhashInfo.latestBlockhash}return await this._pollNewBlockhash()}async _pollNewBlockhash(){this._pollingBlockhash=!0;try{const t=Date.now(),e=this._blockhashInfo.latestBlockhash,r=e?e.blockhash:null;for(let t=0;t<50;t++){const t=await this.getLatestBlockhash("finalized");if(r!==t.blockhash)return this._blockhashInfo={latestBlockhash:t,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},t;await Es(200)}throw new Error(`Unable to obtain a new blockhash after ${Date.now()-t}ms`)}finally{this._pollingBlockhash=!1}}async getStakeMinimumDelegation(t){const{commitment:e,config:r}=Qs(t),n=this._buildArgs([],e,"base64",r),i=en(await this._rpcRequest("getStakeMinimumDelegation",n),na(ln()));if("error"in i)throw new Vs(i.error,"failed to get stake minimum delegation");return i.result}async simulateTransaction(t,e,r){if("message"in t){const i=t.serialize(),o=n.Buffer.from(i).toString("base64");if(Array.isArray(e)||void 0!==r)throw new Error("Invalid arguments");const s=e||{};s.encoding="base64","commitment"in s||(s.commitment=this.commitment);const a=[o,s],u=en(await this._rpcRequest("simulateTransaction",a),ma);if("error"in u)throw new Error("failed to simulate transaction: "+u.error.message);return u.result}let i;if(t instanceof hs){let e=t;i=new hs,i.feePayer=e.feePayer,i.instructions=t.instructions,i.nonceInfo=e.nonceInfo,i.signatures=e.signatures}else i=hs.populate(t),i._message=i._json=void 0;if(void 0!==e&&!Array.isArray(e))throw new Error("Invalid arguments");const o=e;if(i.nonceInfo&&o)i.sign(...o);else{let t=this._disableBlockhashCaching;for(;;){const e=await this._blockhashWithExpiryBlockHeight(t);if(i.lastValidBlockHeight=e.lastValidBlockHeight,i.recentBlockhash=e.blockhash,!o)break;if(i.sign(...o),!i.signature)throw new Error("!signature");const r=i.signature.toString("base64");if(!this._blockhashInfo.simulatedSignatures.includes(r)&&!this._blockhashInfo.transactionSignatures.includes(r)){this._blockhashInfo.simulatedSignatures.push(r);break}t=!0}}const s=i._compile(),a=s.serialize(),u=i._serialize(a).toString("base64"),c={encoding:"base64",commitment:this.commitment};if(r){const t=(Array.isArray(r)?r:s.nonProgramIds()).map((t=>t.toBase58()));c.accounts={encoding:"base64",addresses:t}}o&&(c.sigVerify=!0);const h=[u,c],l=en(await this._rpcRequest("simulateTransaction",h),ma);if("error"in l){let t;if("data"in l.error&&(t=l.error.data.logs,t&&Array.isArray(t))){const e="\n ",r=e+t.join(e);console.error(l.error.message,r)}throw new Ks("failed to simulate transaction: "+l.error.message,t)}return l.result}async sendTransaction(t,e,r){if("version"in t){if(e&&Array.isArray(e))throw new Error("Invalid arguments");const r=t.serialize();return await this.sendRawTransaction(r,e)}if(void 0===e||!Array.isArray(e))throw new Error("Invalid arguments");const n=e;if(t.nonceInfo)t.sign(...n);else{let e=this._disableBlockhashCaching;for(;;){const r=await this._blockhashWithExpiryBlockHeight(e);if(t.lastValidBlockHeight=r.lastValidBlockHeight,t.recentBlockhash=r.blockhash,t.sign(...n),!t.signature)throw new Error("!signature");const i=t.signature.toString("base64");if(!this._blockhashInfo.transactionSignatures.includes(i)){this._blockhashInfo.transactionSignatures.push(i);break}e=!0}}const i=t.serialize();return await this.sendRawTransaction(i,r)}async sendRawTransaction(t,e){const r=Oo(t).toString("base64");return await this.sendEncodedTransaction(r,e)}async sendEncodedTransaction(t,e){const r={encoding:"base64"},n=e&&e.skipPreflight,i=e&&e.preflightCommitment||this.commitment;e&&null!=e.maxRetries&&(r.maxRetries=e.maxRetries),e&&null!=e.minContextSlot&&(r.minContextSlot=e.minContextSlot),n&&(r.skipPreflight=n),i&&(r.preflightCommitment=i);const o=[t,r],s=en(await this._rpcRequest("sendTransaction",o),Lu);if("error"in s){let t;throw"data"in s.error&&(t=s.error.data.logs),new Ks("failed to send transaction: "+s.error.message,t)}return s.result}_wsOnOpen(){this._rpcWebSocketConnected=!0,this._rpcWebSocketHeartbeat=setInterval((()=>{(async()=>{try{await this._rpcWebSocket.notify("ping")}catch{}})()}),5e3),this._updateSubscriptions()}_wsOnError(t){this._rpcWebSocketConnected=!1,console.error("ws error:",t.message)}_wsOnClose(t){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!==t?(this._subscriptionCallbacksByServerSubscriptionId={},Object.entries(this._subscriptionsByHash).forEach((([t,e])=>{this._setSubscription(t,{...e,state:"pending"})}))):this._updateSubscriptions()}_setSubscription(t,e){const r=this._subscriptionsByHash[t]?.state;if(this._subscriptionsByHash[t]=e,r!==e.state){const r=this._subscriptionStateChangeCallbacksByHash[t];r&&r.forEach((t=>{try{t(e.state)}catch{}}))}}_onSubscriptionStateChange(t,e){const r=this._subscriptionHashByClientSubscriptionId[t];if(null==r)return()=>{};const n=this._subscriptionStateChangeCallbacksByHash[r]||=new Set;return n.add(e),()=>{n.delete(e),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(t){t instanceof Error&&console.log(`Error when closing socket connection: ${t.message}`)}}),500)));if(null!==this._rpcWebSocketIdleTimeout&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketConnected=!0),!this._rpcWebSocketConnected)return void this._rpcWebSocket.connect();const t=this._rpcWebSocketGeneration,e=()=>t===this._rpcWebSocketGeneration;await Promise.all(Object.keys(this._subscriptionsByHash).map((async t=>{const r=this._subscriptionsByHash[t];if(void 0!==r)switch(r.state){case"pending":case"unsubscribed":if(0===r.callbacks.size)return delete this._subscriptionsByHash[t],"unsubscribed"===r.state&&delete this._subscriptionCallbacksByServerSubscriptionId[r.serverSubscriptionId],void await this._updateSubscriptions();await(async()=>{const{args:n,method:i}=r;try{this._setSubscription(t,{...r,state:"subscribing"});const e=await this._rpcWebSocket.call(i,n);this._setSubscription(t,{...r,serverSubscriptionId:e,state:"subscribed"}),this._subscriptionCallbacksByServerSubscriptionId[e]=r.callbacks,await this._updateSubscriptions()}catch(o){if(o instanceof Error&&console.error(`${i} error for argument`,n,o.message),!e())return;this._setSubscription(t,{...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(t,{...r,state:"unsubscribing"}),this._setSubscription(t,{...r,state:"unsubscribing"});try{await this._rpcWebSocket.call(i,[n])}catch(n){if(n instanceof Error&&console.error(`${i} error:`,n.message),!e())return;return this._setSubscription(t,{...r,state:"subscribed"}),void await this._updateSubscriptions()}}this._setSubscription(t,{...r,state:"unsubscribed"}),await this._updateSubscriptions()})()}})))}_handleServerNotification(t,e){const r=this._subscriptionCallbacksByServerSubscriptionId[t];void 0!==r&&r.forEach((t=>{try{t(...e)}catch(t){console.error(t)}}))}_wsOnAccountNotification(t){const{result:e,subscription:r}=en(t,Wa);this._handleServerNotification(r,[e.value,e.context])}_makeSubscription(t,e){const r=this._nextClientSubscriptionId++,n=js([t.method,e],!0),i=this._subscriptionsByHash[n];return void 0===i?this._subscriptionsByHash[n]={...t,args:e,callbacks:new Set([t.callback]),state:"pending"}:i.callbacks.add(t.callback),this._subscriptionHashByClientSubscriptionId[r]=n,this._subscriptionDisposeFunctionsByClientSubscriptionId[r]=async()=>{delete this._subscriptionDisposeFunctionsByClientSubscriptionId[r],delete this._subscriptionHashByClientSubscriptionId[r];const e=this._subscriptionsByHash[n];rs(void 0!==e,`Could not find a \`Subscription\` when tearing down client subscription #${r}`),e.callbacks.delete(t.callback),await this._updateSubscriptions()},this._updateSubscriptions(),r}onAccountChange(t,e,r){const n=this._buildArgs([t.toBase58()],r||this._commitment||"finalized","base64");return this._makeSubscription({callback:e,method:"accountSubscribe",unsubscribeMethod:"accountUnsubscribe"},n)}async removeAccountChangeListener(t){await this._unsubscribeClientSubscription(t,"account change")}_wsOnProgramAccountNotification(t){const{result:e,subscription:r}=en(t,Ka);this._handleServerNotification(r,[{accountId:e.value.pubkey,accountInfo:e.value.account},e.context])}onProgramAccountChange(t,e,r,n){const i=this._buildArgs([t.toBase58()],r||this._commitment||"finalized","base64",n?{filters:n}:void 0);return this._makeSubscription({callback:e,method:"programSubscribe",unsubscribeMethod:"programUnsubscribe"},i)}async removeProgramAccountChangeListener(t){await this._unsubscribeClientSubscription(t,"program account change")}onLogs(t,e,r){const n=this._buildArgs(["object"==typeof t?{mentions:[t.toString()]}:t],r||this._commitment||"finalized");return this._makeSubscription({callback:e,method:"logsSubscribe",unsubscribeMethod:"logsUnsubscribe"},n)}async removeOnLogsListener(t){await this._unsubscribeClientSubscription(t,"logs")}_wsOnLogsNotification(t){const{result:e,subscription:r}=en(t,Uu);this._handleServerNotification(r,[e.value,e.context])}_wsOnSlotNotification(t){const{result:e,subscription:r}=en(t,qa);this._handleServerNotification(r,[e])}onSlotChange(t){return this._makeSubscription({callback:t,method:"slotSubscribe",unsubscribeMethod:"slotUnsubscribe"},[])}async removeSlotChangeListener(t){await this._unsubscribeClientSubscription(t,"slot change")}_wsOnSlotUpdatesNotification(t){const{result:e,subscription:r}=en(t,$a);this._handleServerNotification(r,[e])}onSlotUpdate(t){return this._makeSubscription({callback:t,method:"slotsUpdatesSubscribe",unsubscribeMethod:"slotsUpdatesUnsubscribe"},[])}async removeSlotUpdateListener(t){await this._unsubscribeClientSubscription(t,"slot update")}async _unsubscribeClientSubscription(t,e){const r=this._subscriptionDisposeFunctionsByClientSubscriptionId[t];r?await r():console.warn(`Ignored unsubscribe request because an active subscription with id \`${t}\` for '${e}' events could not be found.`)}_buildArgs(t,e,r,n){const i=e||this._commitment;if(i||r||n){let e={};r&&(e.encoding=r),i&&(e.commitment=i),n&&(e=Object.assign(e,n)),t.push(e)}return t}_buildArgsAtLeastConfirmed(t,e,r,n){const i=e||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(t,e,r,n)}_wsOnSignatureNotification(t){const{result:e,subscription:r}=en(t,Ga);"receivedSignature"!==e.value&&this._subscriptionsAutoDisposedByRpc.add(r),this._handleServerNotification(r,"receivedSignature"===e.value?[{type:"received"},e.context]:[{type:"status",result:e.value},e.context])}onSignature(t,e,r){const n=this._buildArgs([t],r||this._commitment||"finalized"),i=this._makeSubscription({callback:(t,r)=>{if("status"===t.type){e(t.result,r);try{this.removeSignatureListener(i)}catch(t){}}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},n);return i}onSignatureWithOptions(t,e,r){const{commitment:n,...i}={...r,commitment:r&&r.commitment||this._commitment||"finalized"},o=this._buildArgs([t],n,void 0,i),s=this._makeSubscription({callback:(t,r)=>{e(t,r);try{this.removeSignatureListener(s)}catch(t){}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},o);return s}async removeSignatureListener(t){await this._unsubscribeClientSubscription(t,"signature result")}_wsOnRootNotification(t){const{result:e,subscription:r}=en(t,Za);this._handleServerNotification(r,[e])}onRootChange(t){return this._makeSubscription({callback:t,method:"rootSubscribe",unsubscribeMethod:"rootUnsubscribe"},[])}async removeRootChangeListener(t){await this._unsubscribeClientSubscription(t,"root change")}},Ed25519Program:Ku,Enum:class extends Uo{constructor(t){if(super(t),this.enum="",1!==Object.keys(t).length)throw new Error("Enum can only take single value");Object.keys(t).map((t=>{this.enum=t}))}},EpochSchedule:Fs,FeeCalculatorLayout:As,Keypair:Nu,LAMPORTS_PER_SOL:1e9,LOOKUP_TABLE_INSTRUCTION_LAYOUTS:zu,Loader:Os,Lockup:Yu,MAX_SEED_LENGTH:32,Message:is,MessageAccountKeys:Zo,MessageV0:os,NONCE_ACCOUNT_LENGTH:Bs,NonceAccount:Ms,PACKET_DATA_SIZE:Ko,PUBLIC_KEY_LENGTH:Do,PublicKey:Wo,SIGNATURE_LENGTH_IN_BYTES:qo,SOLANA_SCHEMA:Co,STAKE_CONFIG_ID:Gu,STAKE_INSTRUCTION_LAYOUTS:Ju,SYSTEM_INSTRUCTION_LAYOUTS:Ts,SYSVAR_CLOCK_PUBKEY:ds,SYSVAR_EPOCH_SCHEDULE_PUBKEY:ps,SYSVAR_INSTRUCTIONS_PUBKEY:ys,SYSVAR_RECENT_BLOCKHASHES_PUBKEY:gs,SYSVAR_RENT_PUBKEY:ms,SYSVAR_REWARDS_PUBKEY:ws,SYSVAR_SLOT_HASHES_PUBKEY:bs,SYSVAR_SLOT_HISTORY_PUBKEY:vs,SYSVAR_STAKE_HISTORY_PUBKEY:_s,Secp256k1Program:Hu,SendTransactionError:Ks,SolanaJSONRPCError:Vs,SolanaJSONRPCErrorCode:{JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP:-32001,JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE:-32002,JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE:-32003,JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE:-32004,JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY:-32005,JSON_RPC_SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE:-32006,JSON_RPC_SERVER_ERROR_SLOT_SKIPPED:-32007,JSON_RPC_SERVER_ERROR_NO_SNAPSHOT:-32008,JSON_RPC_SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED:-32009,JSON_RPC_SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX:-32010,JSON_RPC_SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE:-32011,JSON_RPC_SCAN_ERROR:-32012,JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH:-32013,JSON_RPC_SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET:-32014,JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION:-32015,JSON_RPC_SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED:-32016},StakeAuthorizationLayout:Xu,StakeInstruction:class{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const e=Nr("instruction").decode(t.data);let r;for(const[t,n]of Object.entries(Ju))if(n.index==e){r=t;break}if(!r)throw new Error("Instruction type incorrect; not a StakeInstruction");return r}static decodeInitialize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{authorized:e,lockup:r}=Ss(Ju.Initialize,t.data);return{stakePubkey:t.keys[0].pubkey,authorized:new Zu(new Wo(e.staker),new Wo(e.withdrawer)),lockup:new Yu(r.unixTimestamp,r.epoch,new Wo(r.custodian))}}static decodeDelegate(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,6),Ss(Ju.Delegate,t.data),{stakePubkey:t.keys[0].pubkey,votePubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[5].pubkey}}static decodeAuthorize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{newAuthorized:e,stakeAuthorizationType:r}=Ss(Ju.Authorize,t.data),n={stakePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey,newAuthorizedPubkey:new Wo(e),stakeAuthorizationType:{index:r}};return t.keys.length>3&&(n.custodianPubkey=t.keys[3].pubkey),n}static decodeAuthorizeWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{newAuthorized:e,stakeAuthorizationType:r,authoritySeed:n,authorityOwner:i}=Ss(Ju.AuthorizeWithSeed,t.data),o={stakePubkey:t.keys[0].pubkey,authorityBase:t.keys[1].pubkey,authoritySeed:n,authorityOwner:new Wo(i),newAuthorizedPubkey:new Wo(e),stakeAuthorizationType:{index:r}};return t.keys.length>3&&(o.custodianPubkey=t.keys[3].pubkey),o}static decodeSplit(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{lamports:e}=Ss(Ju.Split,t.data);return{stakePubkey:t.keys[0].pubkey,splitStakePubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[2].pubkey,lamports:e}}static decodeMerge(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3),Ss(Ju.Merge,t.data),{stakePubkey:t.keys[0].pubkey,sourceStakePubKey:t.keys[1].pubkey,authorizedPubkey:t.keys[4].pubkey}}static decodeWithdraw(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,5);const{lamports:e}=Ss(Ju.Withdraw,t.data),r={stakePubkey:t.keys[0].pubkey,toPubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[4].pubkey,lamports:e};return t.keys.length>5&&(r.custodianPubkey=t.keys[5].pubkey),r}static decodeDeactivate(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3),Ss(Ju.Deactivate,t.data),{stakePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey}}static checkProgramId(t){if(!t.equals(Qu.programId))throw new Error("invalid instruction; programId is not StakeProgram")}static checkKeyLength(t,e){if(t.length<e)throw new Error(`invalid instruction; found ${t.length} keys, expected at least ${e}`)}},StakeProgram:Qu,Struct:Uo,SystemInstruction:class{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const e=Nr("instruction").decode(t.data);let r;for(const[t,n]of Object.entries(Ts))if(n.index==e){r=t;break}if(!r)throw new Error("Instruction type incorrect; not a SystemInstruction");return r}static decodeCreateAccount(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{lamports:e,space:r,programId:n}=Ss(Ts.Create,t.data);return{fromPubkey:t.keys[0].pubkey,newAccountPubkey:t.keys[1].pubkey,lamports:e,space:r,programId:new Wo(n)}}static decodeTransfer(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{lamports:e}=Ss(Ts.Transfer,t.data);return{fromPubkey:t.keys[0].pubkey,toPubkey:t.keys[1].pubkey,lamports:e}}static decodeTransferWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{lamports:e,seed:r,programId:n}=Ss(Ts.TransferWithSeed,t.data);return{fromPubkey:t.keys[0].pubkey,basePubkey:t.keys[1].pubkey,toPubkey:t.keys[2].pubkey,lamports:e,seed:r,programId:new Wo(n)}}static decodeAllocate(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{space:e}=Ss(Ts.Allocate,t.data);return{accountPubkey:t.keys[0].pubkey,space:e}}static decodeAllocateWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{base:e,seed:r,space:n,programId:i}=Ss(Ts.AllocateWithSeed,t.data);return{accountPubkey:t.keys[0].pubkey,basePubkey:new Wo(e),seed:r,space:n,programId:new Wo(i)}}static decodeAssign(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{programId:e}=Ss(Ts.Assign,t.data);return{accountPubkey:t.keys[0].pubkey,programId:new Wo(e)}}static decodeAssignWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,1);const{base:e,seed:r,programId:n}=Ss(Ts.AssignWithSeed,t.data);return{accountPubkey:t.keys[0].pubkey,basePubkey:new Wo(e),seed:r,programId:new Wo(n)}}static decodeCreateWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{base:e,seed:r,lamports:n,space:i,programId:o}=Ss(Ts.CreateWithSeed,t.data);return{fromPubkey:t.keys[0].pubkey,newAccountPubkey:t.keys[1].pubkey,basePubkey:new Wo(e),seed:r,lamports:n,space:i,programId:new Wo(o)}}static decodeNonceInitialize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{authorized:e}=Ss(Ts.InitializeNonceAccount,t.data);return{noncePubkey:t.keys[0].pubkey,authorizedPubkey:new Wo(e)}}static decodeNonceAdvance(t){return this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3),Ss(Ts.AdvanceNonceAccount,t.data),{noncePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey}}static decodeNonceWithdraw(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,5);const{lamports:e}=Ss(Ts.WithdrawNonceAccount,t.data);return{noncePubkey:t.keys[0].pubkey,toPubkey:t.keys[1].pubkey,authorizedPubkey:t.keys[4].pubkey,lamports:e}}static decodeNonceAuthorize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,2);const{authorized:e}=Ss(Ts.AuthorizeNonceAccount,t.data);return{noncePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[1].pubkey,newAuthorizedPubkey:new Wo(e)}}static checkProgramId(t){if(!t.equals(Ls.programId))throw new Error("invalid instruction; programId is not SystemProgram")}static checkKeyLength(t,e){if(t.length<e)throw new Error(`invalid instruction; found ${t.length} keys, expected at least ${e}`)}},SystemProgram:Ls,Transaction:hs,TransactionExpiredBlockheightExceededError:Ho,TransactionExpiredNonceInvalidError:Go,TransactionExpiredTimeoutError:$o,TransactionInstruction:cs,TransactionMessage:ls,TransactionStatus:as,VALIDATOR_INFO_KEY:ic,VERSION_PREFIX_MASK:Vo,VOTE_PROGRAM_ID:ac,ValidatorInfo:sc,VersionedMessage:ss,VersionedTransaction:fs,VoteAccount:cc,VoteAuthorizationLayout:rc,VoteInit:tc,VoteInstruction:class{constructor(){}static decodeInstructionType(t){this.checkProgramId(t.programId);const e=Nr("instruction").decode(t.data);let r;for(const[t,n]of Object.entries(ec))if(n.index==e){r=t;break}if(!r)throw new Error("Instruction type incorrect; not a VoteInstruction");return r}static decodeInitializeAccount(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,4);const{voteInit:e}=Ss(ec.InitializeAccount,t.data);return{votePubkey:t.keys[0].pubkey,nodePubkey:t.keys[3].pubkey,voteInit:new tc(new Wo(e.nodePubkey),new Wo(e.authorizedVoter),new Wo(e.authorizedWithdrawer),e.commission)}}static decodeAuthorize(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{newAuthorized:e,voteAuthorizationType:r}=Ss(ec.Authorize,t.data);return{votePubkey:t.keys[0].pubkey,authorizedPubkey:t.keys[2].pubkey,newAuthorizedPubkey:new Wo(e),voteAuthorizationType:{index:r}}}static decodeAuthorizeWithSeed(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:e,currentAuthorityDerivedKeySeed:r,newAuthorized:n,voteAuthorizationType:i}}=Ss(ec.AuthorizeWithSeed,t.data);return{currentAuthorityDerivedKeyBasePubkey:t.keys[2].pubkey,currentAuthorityDerivedKeyOwnerPubkey:new Wo(e),currentAuthorityDerivedKeySeed:r,newAuthorizedPubkey:new Wo(n),voteAuthorizationType:{index:i},votePubkey:t.keys[0].pubkey}}static decodeWithdraw(t){this.checkProgramId(t.programId),this.checkKeyLength(t.keys,3);const{lamports:e}=Ss(ec.Withdraw,t.data);return{votePubkey:t.keys[0].pubkey,authorizedWithdrawerPubkey:t.keys[2].pubkey,lamports:e,toPubkey:t.keys[1].pubkey}}static checkProgramId(t){if(!t.equals(nc.programId))throw new Error("invalid instruction; programId is not VoteProgram")}static checkKeyLength(t,e){if(t.length<e)throw new Error(`invalid instruction; found ${t.length} keys, expected at least ${e}`)}},VoteProgram:nc,clusterApiUrl:function(t,e){const r=!1===e?"http":"https";if(!t)return dc[r].devnet;const n=dc[r][t];if(!n)throw new Error(`Unknown ${r} cluster: ${t}`);return n},sendAndConfirmRawTransaction:async function(t,e,r,n){let i,o;r&&Object.prototype.hasOwnProperty.call(r,"lastValidBlockHeight")||r&&Object.prototype.hasOwnProperty.call(r,"nonceValue")?(i=r,o=n):o=r;const s=o&&{skipPreflight:o.skipPreflight,preflightCommitment:o.preflightCommitment||o.commitment,minContextSlot:o.minContextSlot},a=await t.sendRawTransaction(e,s),u=o&&o.commitment,c=i?t.confirmTransaction(i,u):t.confirmTransaction(a,u),h=(await c).value;if(h.err)throw new Error(`Raw transaction ${a} failed (${JSON.stringify(h)})`);return a},sendAndConfirmTransaction:ks});const yc=new Wo("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");new Wo("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb");const gc=new Wo("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");new Wo("So11111111111111111111111111111111111111112"),new Wo("9pan9bMn5HatX4EJdBwg9VgCa7Uz5HL8N1m5D3NdXejP");const mc=t=>({decode:t.decode.bind(t),encode:t.encode.bind(t)}),wc=(t=>e=>{const r=Fr(t,e),{encode:n,decode:i}=mc(r),o=r;return o.decode=(t,e)=>{const r=i(t,e);return Vr(Buffer.from(r))},o.encode=(e,r,i)=>{const o=Hr(e,t);return n(o,r,i)},o})(8),bc=t=>{const e=Ur(t),{encode:r,decode:n}=mc(e),i=e;return i.decode=(t,e)=>!!n(t,e),i.encode=(t,e,n)=>{const i=Number(t);return r(i,e,n)},i},vc=t=>{const e=Fr(32,t),{encode:r,decode:n}=mc(e),i=e;return i.decode=(t,e)=>{const r=n(t,e);return new Wo(r)},i.encode=(t,e,n)=>{const i=t.toBuffer();return r(i,e,n)},i};class _c extends Error{constructor(t){super(t)}}class kc extends _c{constructor(){super(...arguments),this.name="TokenAccountNotFoundError"}}class Ec extends _c{constructor(){super(...arguments),this.name="TokenInvalidAccountOwnerError"}}class xc extends _c{constructor(){super(...arguments),this.name="TokenInvalidAccountSizeError"}}class Sc extends _c{constructor(){super(...arguments),this.name="TokenInvalidMintError"}}class Ac extends _c{constructor(){super(...arguments),this.name="TokenOwnerOffCurveError"}}var Ic;!function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Mint=1]="Mint",t[t.Account=2]="Account"}(Ic||(Ic={}));const Bc=1,Mc=jr([Ur("m"),Ur("n"),bc("isInitialized"),vc("signer1"),vc("signer2"),vc("signer3"),vc("signer4"),vc("signer5"),vc("signer6"),vc("signer7"),vc("signer8"),vc("signer9"),vc("signer10"),vc("signer11")]).span;var Rc;!function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initialized=1]="Initialized",t[t.Frozen=2]="Frozen"}(Rc||(Rc={}));const Pc=jr([vc("mint"),vc("owner"),wc("amount"),Nr("delegateOption"),vc("delegate"),Ur("state"),Nr("isNativeOption"),wc("isNative"),wc("delegatedAmount"),Nr("closeAuthorityOption"),vc("closeAuthority")]),Tc=Pc.span,Lc=jr([Nr("mintAuthorityOption"),vc("mintAuthority"),wc("supply"),Ur("decimals"),bc("isInitialized"),Nr("freezeAuthorityOption"),vc("freezeAuthority")]),Oc=Lc.span;async function Uc(t,e,r,n=yc){return function(t,e,r=yc){if(!e)throw new kc;if(!e.owner.equals(r))throw new Ec;if(e.data.length<Oc)throw new xc;const n=Lc.decode(e.data.slice(0,Oc));let i=Buffer.alloc(0);if(e.data.length>Oc){if(e.data.length<=Tc)throw new xc;if(e.data.length===Mc)throw new xc;if(e.data[Tc]!=Ic.Mint)throw new Sc;i=e.data.slice(Tc+Bc)}return{address:t,mintAuthority:n.mintAuthorityOption?n.mintAuthority:null,supply:n.supply,decimals:n.decimals,isInitialized:n.isInitialized,freezeAuthority:n.freezeAuthorityOption?n.freezeAuthority:null,tlvData:i}}(e,await t.getAccountInfo(e,r),n)}function Cc(t,e,r=!1,n=yc,i=gc){if(!r&&!Wo.isOnCurve(e.toBuffer()))throw new Ac;const[o]=Wo.findProgramAddressSync([e.toBuffer(),n.toBuffer(),t.toBuffer()],i);return o}function Nc(t,e,r,n,i=yc,o=gc){return function(t,e,r,n,i,o=yc,s=gc){const a=[{pubkey:t,isSigner:!0,isWritable:!0},{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!1,isWritable:!1},{pubkey:Ls.programId,isSigner:!1,isWritable:!1},{pubkey:o,isSigner:!1,isWritable:!1}];return new cs({keys:a,programId:s,data:i})}(t,e,r,n,Buffer.alloc(0),i,o)}var zc;exports.ErrorType=void 0,(zc=exports.ErrorType||(exports.ErrorType={})).SymbolNotFound="SymbolNotFound",zc.InvalidSubdomain="InvalidSubdomain",zc.FavouriteDomainNotFound="FavouriteDomainNotFound",zc.MissingParentOwner="MissingParentOwner",zc.U32Overflow="U32Overflow",zc.InvalidBufferLength="InvalidBufferLength",zc.U64Overflow="U64Overflow",zc.NoRecordData="NoRecordData",zc.InvalidRecordData="InvalidRecordData",zc.UnsupportedRecord="UnsupportedRecord",zc.InvalidEvmAddress="InvalidEvmAddress",zc.InvalidInjectiveAddress="InvalidInjectiveAddress",zc.InvalidARecord="InvalidARecord",zc.InvalidAAAARecord="InvalidAAAARecord",zc.InvalidRecordInput="InvalidRecordInput",zc.InvalidSignature="InvalidSignature",zc.AccountDoesNotExist="AccountDoesNotExist",zc.MultipleRegistries="MultipleRegistries",zc.InvalidReverseTwitter="InvalidReverseTwitter",zc.NoAccountData="NoAccountData",zc.InvalidInput="InvalidInput",zc.InvalidDomain="InvalidDomain",zc.InvalidCustomBg="InvalidCustomBackground",zc.UnsupportedSignature="UnsupportedSignature",zc.RecordDoestNotSupportGuardianSig="RecordDoestNotSupportGuardianSig",zc.RecordIsNotSigned="RecordIsNotSigned",zc.UnsupportedSignatureType="UnsupportedSignatureType",zc.InvalidSolRecordV2="InvalidSolRecordV2",zc.MissingVerifier="MissingVerifier";class Dc extends Error{constructor(t,e){super(e),this.name="SNSError",this.type=t,Error.captureStackTrace&&Error.captureStackTrace(this,Dc)}}class jc extends ne{toBuffer(){const t=super.toArray().reverse(),e=n.Buffer.from(t);if(4===e.length)return e;if(e.length>4)throw new Dc(exports.ErrorType.U32Overflow);const r=n.Buffer.alloc(4);return e.copy(r),r}static fromBuffer(t){if(4!==t.length)throw new Dc(exports.ErrorType.InvalidBufferLength,`Invalid buffer length: ${t.length}`);return new ne([...t].reverse().map((t=>`00${t.toString(16)}`.slice(-2))).join(""),16)}}class Wc extends ne{toBuffer(){const t=super.toArray().reverse(),e=n.Buffer.from(t);if(8===e.length)return e;if(e.length>8)throw new Dc(exports.ErrorType.U64Overflow);const r=n.Buffer.alloc(8);return e.copy(r),r}static fromBuffer(t){if(8!==t.length)throw new Dc(exports.ErrorType.U64Overflow,`Invalid buffer length: ${t.length}`);return new ne([...t].reverse().map((t=>`00${t.toString(16)}`.slice(-2))).join(""),16)}}function Fc(t,e,r,i,o,s,a,u,c,h,l){const f=[n.Buffer.from(Int8Array.from([0])),new jc(s.length).toBuffer(),s,a.toBuffer(),u.toBuffer()],d=n.Buffer.concat(f),p=[{pubkey:e,isSigner:!1,isWritable:!1},{pubkey:o,isSigner:!0,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!1}];return c?p.push({pubkey:c,isSigner:!0,isWritable:!1}):p.push({pubkey:new Wo(n.Buffer.alloc(32)),isSigner:!1,isWritable:!1}),h?p.push({pubkey:h,isSigner:!1,isWritable:!1}):p.push({pubkey:new Wo(n.Buffer.alloc(32)),isSigner:!1,isWritable:!1}),l&&p.push({pubkey:l,isSigner:!0,isWritable:!1}),new cs({keys:p,programId:t,data:d})}function Kc(t,e,r,i,o){const s=[n.Buffer.from(Int8Array.from([1])),r.toBuffer(),new jc(i.length).toBuffer(),i],a=n.Buffer.concat(s);return new cs({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:o,isSigner:!0,isWritable:!1}],programId:t,data:a})}function Vc(t,e,r,i,o,s,a){const u=[n.Buffer.from(Int8Array.from([2])),r.toBuffer()],c=n.Buffer.concat(u),h=[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:a||i,isSigner:!0,isWritable:!1}];return o&&h.push({pubkey:o,isSigner:!0,isWritable:!1}),a&&s&&(o||h.push({pubkey:Wo.default,isSigner:!1,isWritable:!1}),h.push({pubkey:s,isSigner:!1,isWritable:!1})),new cs({keys:h,programId:t,data:c})}function qc(t,e,r,i){const o=[n.Buffer.from(Int8Array.from([3]))],s=n.Buffer.concat(o);return new cs({keys:[{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!0,isWritable:!1},{pubkey:r,isSigner:!1,isWritable:!0}],programId:t,data:s})}class Hc{constructor(t){this.tag=9,this.name=t.name,this.space=t.space}serialize(){return He(Hc.schema,this)}getInstruction(t,e,r,i,o,s,a,u,c,h,l){const f=n.Buffer.from(this.serialize()),d=[{pubkey:e,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!1,isWritable:!1},{pubkey:i,isSigner:!1,isWritable:!1},{pubkey:o,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:Ls.programId,isSigner:!1,isWritable:!1},{pubkey:a,isSigner:!1,isWritable:!1},{pubkey:u,isSigner:!0,isWritable:!0},{pubkey:c,isSigner:!1,isWritable:!0},{pubkey:h,isSigner:!1,isWritable:!0},{pubkey:yc,isSigner:!1,isWritable:!1},{pubkey:l,isSigner:!1,isWritable:!1}];return new cs({keys:d,programId:t,data:f})}}Hc.schema=new Map([[Hc,{kind:"struct",fields:[["tag","u8"],["name","string"],["space","u32"]]}]]);class $c{constructor(t){this.tag=12,this.name=t.name}serialize(){return He($c.schema,this)}getInstruction(t,e,r,i,o,s,a,u,c,h){const l=n.Buffer.from(this.serialize());let f=[];return f.push({pubkey:e,isSigner:!1,isWritable:!1}),f.push({pubkey:r,isSigner:!1,isWritable:!1}),f.push({pubkey:i,isSigner:!1,isWritable:!0}),f.push({pubkey:o,isSigner:!1,isWritable:!1}),f.push({pubkey:s,isSigner:!1,isWritable:!1}),f.push({pubkey:a,isSigner:!0,isWritable:!0}),f.push({pubkey:u,isSigner:!1,isWritable:!1}),c&&f.push({pubkey:c,isSigner:!1,isWritable:!0}),h&&f.push({pubkey:h,isSigner:!0,isWritable:!0}),new cs({keys:f,programId:t,data:l})}}$c.schema=new Map([[$c,{kind:"struct",fields:[["tag","u8"],["name","string"]]}]]);class Gc{constructor(t){this.tag=13,this.name=t.name,this.space=t.space,this.referrerIdxOpt=t.referrerIdxOpt}serialize(){return He(Gc.schema,this)}getInstruction(t,e,r,i,o,s,a,u,c,h,l,f,d,p,y,g,m){const w=n.Buffer.from(this.serialize());let b=[];return b.push({pubkey:e,isSigner:!1,isWritable:!1}),b.push({pubkey:r,isSigner:!1,isWritable:!1}),b.push({pubkey:i,isSigner:!1,isWritable:!0}),b.push({pubkey:o,isSigner:!1,isWritable:!0}),b.push({pubkey:s,isSigner:!1,isWritable:!1}),b.push({pubkey:a,isSigner:!1,isWritable:!1}),b.push({pubkey:u,isSigner:!0,isWritable:!0}),b.push({pubkey:c,isSigner:!1,isWritable:!0}),b.push({pubkey:h,isSigner:!1,isWritable:!1}),b.push({pubkey:l,isSigner:!1,isWritable:!1}),b.push({pubkey:f,isSigner:!1,isWritable:!1}),b.push({pubkey:d,isSigner:!1,isWritable:!0}),b.push({pubkey:p,isSigner:!1,isWritable:!1}),b.push({pubkey:y,isSigner:!1,isWritable:!1}),b.push({pubkey:g,isSigner:!1,isWritable:!1}),m&&b.push({pubkey:m,isSigner:!1,isWritable:!0}),new cs({keys:b,programId:t,data:w})}}Gc.schema=new Map([[Gc,{kind:"struct",fields:[["tag","u8"],["name","string"],["space","u32"],["referrerIdxOpt",{kind:"option",type:"u16"}]]}]]);class Zc{constructor(t){this.tag=17,this.name=t.name,this.space=t.space}serialize(){return He(Zc.schema,this)}getInstruction(t,e,r,i,o,s,a,u,c,h,l,f,d,p,y,g,m){const w=n.Buffer.from(this.serialize());let b=[];return b.push({pubkey:e,isSigner:!1,isWritable:!1}),b.push({pubkey:r,isSigner:!1,isWritable:!1}),b.push({pubkey:i,isSigner:!1,isWritable:!0}),b.push({pubkey:o,isSigner:!1,isWritable:!0}),b.push({pubkey:s,isSigner:!1,isWritable:!1}),b.push({pubkey:a,isSigner:!1,isWritable:!1}),b.push({pubkey:u,isSigner:!0,isWritable:!0}),b.push({pubkey:c,isSigner:!1,isWritable:!0}),b.push({pubkey:h,isSigner:!1,isWritable:!0}),b.push({pubkey:l,isSigner:!1,isWritable:!0}),b.push({pubkey:f,isSigner:!1,isWritable:!0}),b.push({pubkey:d,isSigner:!1,isWritable:!0}),b.push({pubkey:p,isSigner:!1,isWritable:!1}),b.push({pubkey:y,isSigner:!1,isWritable:!1}),b.push({pubkey:g,isSigner:!1,isWritable:!1}),b.push({pubkey:m,isSigner:!1,isWritable:!1}),new cs({keys:b,programId:t,data:w})}}Zc.schema=new Map([[Zc,{kind:"struct",fields:[["tag","u8"],["name","string"],["space","u32"]]}]]);class Yc{constructor(){this.tag=16}serialize(){return He(Yc.schema,this)}getInstruction(t,e,r,i,o,s,a,u,c,h){const l=n.Buffer.from(this.serialize());let f=[];return f.push({pubkey:e,isSigner:!1,isWritable:!1}),f.push({pubkey:r,isSigner:!1,isWritable:!1}),f.push({pubkey:i,isSigner:!1,isWritable:!0}),f.push({pubkey:o,isSigner:!1,isWritable:!0}),f.push({pubkey:s,isSigner:!1,isWritable:!0}),f.push({pubkey:a,isSigner:!1,isWritable:!0}),f.push({pubkey:u,isSigner:!1,isWritable:!1}),f.push({pubkey:c,isSigner:!0,isWritable:!1}),f.push({pubkey:h,isSigner:!1,isWritable:!0}),new cs({keys:f,programId:t,data:l})}}Yc.schema=new Map([[Yc,{kind:"struct",fields:[["tag","u8"]]}]]);const Jc=new Wo("nftD3vbNkNqfj2Sd3HZwbpw4BxxKWr4AjGb9X38JeZk"),Xc=n.Buffer.from("tokenized_name");var Qc;!function(t){t[t.Uninitialized=0]="Uninitialized",t[t.CentralState=1]="CentralState",t[t.ActiveRecord=2]="ActiveRecord",t[t.InactiveRecord=3]="InactiveRecord"}(Qc||(Qc={}));class th{constructor(t){this.tag=t.tag,this.nonce=t.nonce,this.nameAccount=new Wo(t.nameAccount),this.owner=new Wo(t.owner),this.nftMint=new Wo(t.nftMint)}static deserialize(t){return Ze(this.schema,th,t)}static async retrieve(t,e){const r=await t.getAccountInfo(e);if(!r||!r.data)throw new Error("NFT record not found");return this.deserialize(r.data)}static async findKey(t,e){return await Wo.findProgramAddress([n.Buffer.from("nft_record"),t.toBuffer()],e)}}th.schema=new Map([[th,{kind:"struct",fields:[["tag","u8"],["nonce","u8"],["nameAccount",[32]],["owner",[32]],["nftMint",[32]]]}]]);const eh=async(t,e)=>{try{const[r]=await Wo.findProgramAddress([Xc,e.toBuffer()],Jc);if("0"===(await Uc(t,r)).supply.toString())return;const n=[{memcmp:{offset:0,bytes:r.toBase58()}},{memcmp:{offset:64,bytes:"2"}},{dataSize:165}],i=await t.getProgramAccounts(yc,{filters:n});if(1!=i.length)return;return new Wo(i[0].account.data.slice(32,64))}catch{return}},rh=t=>[{memcmp:{offset:32,bytes:t}},{memcmp:{offset:64,bytes:"2"}}],nh=async(t,e)=>{const r=await(async(t,e)=>{const r=[{memcmp:{offset:0,bytes:"3"}},{memcmp:{offset:66,bytes:e.toBase58()}}];return await t.getProgramAccounts(Jc,{filters:r})})(t,e.mint);if(1===r.length)return th.deserialize(r[0].account.data)},ih=async(t,e)=>{const r=[...rh(e.toBase58()),{dataSize:165}],n=(await t.getProgramAccounts(yc,{filters:r})).map((t=>Pc.decode(t.account.data))),i=n.map((e=>nh(t,e)));return(await Promise.all(i)).filter((t=>void 0!==t))};class oh{constructor(t){this.parentName=new Wo(t.parentName),this.owner=new Wo(t.owner),this.class=new Wo(t.class)}static async retrieve(t,e){var r;const n=await t.getAccountInfo(e);if(!n)throw new Dc(exports.ErrorType.AccountDoesNotExist);let i=Le(this.schema,oh,n.data);i.data=null===(r=n.data)||void 0===r?void 0:r.slice(this.HEADER_LEN);return{registry:i,nftOwner:await eh(t,e)}}static async _retrieveBatch(t,e){const r=await t.getMultipleAccountsInfo(e),n=t=>{if(!t)return;const e=Le(this.schema,oh,t);return e.data=null==t?void 0:t.slice(this.HEADER_LEN),e};return r.map((t=>n(null==t?void 0:t.data)))}static async retrieveBatch(t,e){let r=[];const n=[...e];for(;n.length>0;)r.push(...await this._retrieveBatch(t,n.splice(0,100)));return r}}oh.HEADER_LEN=96,oh.schema=new Map([[oh,{kind:"struct",fields:[["parentName",[32]],["owner",[32]],["class",[32]]]}]]);var sh={},ah={},uh=ch;function ch(t,e){if(!t)throw new Error(e||"Assertion failed")}ch.equal=function(t,e,r){if(t!=e)throw new Error(r||"Assertion failed: "+t+" != "+e)};var hh={exports:{}};"function"==typeof Object.create?hh.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:hh.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}};var lh=hh.exports,fh=uh,dh=lh;function ph(t,e){return 55296==(64512&t.charCodeAt(e))&&(!(e<0||e+1>=t.length)&&56320==(64512&t.charCodeAt(e+1)))}function yh(t){return(t>>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24)>>>0}function gh(t){return 1===t.length?"0"+t:t}function mh(t){return 7===t.length?"0"+t:6===t.length?"00"+t:5===t.length?"000"+t:4===t.length?"0000"+t:3===t.length?"00000"+t:2===t.length?"000000"+t:1===t.length?"0000000"+t:t}ah.inherits=dh,ah.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"==typeof t)if(e){if("hex"===e)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),i=0;i<t.length;i+=2)r.push(parseInt(t[i]+t[i+1],16))}else for(var n=0,i=0;i<t.length;i++){var o=t.charCodeAt(i);o<128?r[n++]=o:o<2048?(r[n++]=o>>6|192,r[n++]=63&o|128):ph(t,i)?(o=65536+((1023&o)<<10)+(1023&t.charCodeAt(++i)),r[n++]=o>>18|240,r[n++]=o>>12&63|128,r[n++]=o>>6&63|128,r[n++]=63&o|128):(r[n++]=o>>12|224,r[n++]=o>>6&63|128,r[n++]=63&o|128)}else for(i=0;i<t.length;i++)r[i]=0|t[i];return r},ah.toHex=function(t){for(var e="",r=0;r<t.length;r++)e+=gh(t[r].toString(16));return e},ah.htonl=yh,ah.toHex32=function(t,e){for(var r="",n=0;n<t.length;n++){var i=t[n];"little"===e&&(i=yh(i)),r+=mh(i.toString(16))}return r},ah.zero2=gh,ah.zero8=mh,ah.join32=function(t,e,r,n){var i=r-e;fh(i%4==0);for(var o=new Array(i/4),s=0,a=e;s<o.length;s++,a+=4){var u;u="big"===n?t[a]<<24|t[a+1]<<16|t[a+2]<<8|t[a+3]:t[a+3]<<24|t[a+2]<<16|t[a+1]<<8|t[a],o[s]=u>>>0}return o},ah.split32=function(t,e){for(var r=new Array(4*t.length),n=0,i=0;n<t.length;n++,i+=4){var o=t[n];"big"===e?(r[i]=o>>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},ah.rotr32=function(t,e){return t>>>e|t<<32-e},ah.rotl32=function(t,e){return t<<e|t>>>32-e},ah.sum32=function(t,e){return t+e>>>0},ah.sum32_3=function(t,e,r){return t+e+r>>>0},ah.sum32_4=function(t,e,r,n){return t+e+r+n>>>0},ah.sum32_5=function(t,e,r,n,i){return t+e+r+n+i>>>0},ah.sum64=function(t,e,r,n){var i=t[e],o=n+t[e+1]>>>0,s=(o<n?1:0)+r+i;t[e]=s>>>0,t[e+1]=o},ah.sum64_hi=function(t,e,r,n){return(e+n>>>0<e?1:0)+t+r>>>0},ah.sum64_lo=function(t,e,r,n){return e+n>>>0},ah.sum64_4_hi=function(t,e,r,n,i,o,s,a){var u=0,c=e;return u+=(c=c+n>>>0)<e?1:0,u+=(c=c+o>>>0)<o?1:0,t+r+i+s+(u+=(c=c+a>>>0)<a?1:0)>>>0},ah.sum64_4_lo=function(t,e,r,n,i,o,s,a){return e+n+o+a>>>0},ah.sum64_5_hi=function(t,e,r,n,i,o,s,a,u,c){var h=0,l=e;return h+=(l=l+n>>>0)<e?1:0,h+=(l=l+o>>>0)<o?1:0,h+=(l=l+a>>>0)<a?1:0,t+r+i+s+u+(h+=(l=l+c>>>0)<c?1:0)>>>0},ah.sum64_5_lo=function(t,e,r,n,i,o,s,a,u,c){return e+n+o+a+c>>>0},ah.rotr64_hi=function(t,e,r){return(e<<32-r|t>>>r)>>>0},ah.rotr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0},ah.shr64_hi=function(t,e,r){return t>>>r},ah.shr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0};var wh={},bh=ah,vh=uh;function _h(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}wh.BlockHash=_h,_h.prototype.update=function(t,e){if(t=bh.toArray(t,e),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var r=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-r,t.length),0===this.pending.length&&(this.pending=null),t=bh.join32(t,0,t.length-r,this.endian);for(var n=0;n<t.length;n+=this._delta32)this._update(t,n,n+this._delta32)}return this},_h.prototype.digest=function(t){return this.update(this._pad()),vh(null===this.pending),this._digest(t)},_h.prototype._pad=function(){var t=this.pendingTotal,e=this._delta8,r=e-(t+this.padLength)%e,n=new Array(r+this.padLength);n[0]=128;for(var i=1;i<r;i++)n[i]=0;if(t<<=3,"big"===this.endian){for(var o=8;o<this.padLength;o++)n[i++]=0;n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=t>>>24&255,n[i++]=t>>>16&255,n[i++]=t>>>8&255,n[i++]=255&t}else for(n[i++]=255&t,n[i++]=t>>>8&255,n[i++]=t>>>16&255,n[i++]=t>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;o<this.padLength;o++)n[i++]=0;return n};var kh={},Eh={},xh=ah.rotr32;function Sh(t,e,r){return t&e^~t&r}function Ah(t,e,r){return t&e^t&r^e&r}function Ih(t,e,r){return t^e^r}Eh.ft_1=function(t,e,r,n){return 0===t?Sh(e,r,n):1===t||3===t?Ih(e,r,n):2===t?Ah(e,r,n):void 0},Eh.ch32=Sh,Eh.maj32=Ah,Eh.p32=Ih,Eh.s0_256=function(t){return xh(t,2)^xh(t,13)^xh(t,22)},Eh.s1_256=function(t){return xh(t,6)^xh(t,11)^xh(t,25)},Eh.g0_256=function(t){return xh(t,7)^xh(t,18)^t>>>3},Eh.g1_256=function(t){return xh(t,17)^xh(t,19)^t>>>10};var Bh=ah,Mh=wh,Rh=Eh,Ph=Bh.rotl32,Th=Bh.sum32,Lh=Bh.sum32_5,Oh=Rh.ft_1,Uh=Mh.BlockHash,Ch=[1518500249,1859775393,2400959708,3395469782];function Nh(){if(!(this instanceof Nh))return new Nh;Uh.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}Bh.inherits(Nh,Uh);var zh=Nh;Nh.blockSize=512,Nh.outSize=160,Nh.hmacStrength=80,Nh.padLength=64,Nh.prototype._update=function(t,e){for(var r=this.W,n=0;n<16;n++)r[n]=t[e+n];for(;n<r.length;n++)r[n]=Ph(r[n-3]^r[n-8]^r[n-14]^r[n-16],1);var i=this.h[0],o=this.h[1],s=this.h[2],a=this.h[3],u=this.h[4];for(n=0;n<r.length;n++){var c=~~(n/20),h=Lh(Ph(i,5),Oh(c,o,s,a),u,r[n],Ch[c]);u=a,a=s,s=Ph(o,30),o=i,i=h}this.h[0]=Th(this.h[0],i),this.h[1]=Th(this.h[1],o),this.h[2]=Th(this.h[2],s),this.h[3]=Th(this.h[3],a),this.h[4]=Th(this.h[4],u)},Nh.prototype._digest=function(t){return"hex"===t?Bh.toHex32(this.h,"big"):Bh.split32(this.h,"big")};var Dh=ah,jh=wh,Wh=Eh,Fh=uh,Kh=Dh.sum32,Vh=Dh.sum32_4,qh=Dh.sum32_5,Hh=Wh.ch32,$h=Wh.maj32,Gh=Wh.s0_256,Zh=Wh.s1_256,Yh=Wh.g0_256,Jh=Wh.g1_256,Xh=jh.BlockHash,Qh=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function tl(){if(!(this instanceof tl))return new tl;Xh.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=Qh,this.W=new Array(64)}Dh.inherits(tl,Xh);var el=tl;tl.blockSize=512,tl.outSize=256,tl.hmacStrength=192,tl.padLength=64,tl.prototype._update=function(t,e){for(var r=this.W,n=0;n<16;n++)r[n]=t[e+n];for(;n<r.length;n++)r[n]=Vh(Jh(r[n-2]),r[n-7],Yh(r[n-15]),r[n-16]);var i=this.h[0],o=this.h[1],s=this.h[2],a=this.h[3],u=this.h[4],c=this.h[5],h=this.h[6],l=this.h[7];for(Fh(this.k.length===r.length),n=0;n<r.length;n++){var f=qh(l,Zh(u),Hh(u,c,h),this.k[n],r[n]),d=Kh(Gh(i),$h(i,o,s));l=h,h=c,c=u,u=Kh(a,f),a=s,s=o,o=i,i=Kh(f,d)}this.h[0]=Kh(this.h[0],i),this.h[1]=Kh(this.h[1],o),this.h[2]=Kh(this.h[2],s),this.h[3]=Kh(this.h[3],a),this.h[4]=Kh(this.h[4],u),this.h[5]=Kh(this.h[5],c),this.h[6]=Kh(this.h[6],h),this.h[7]=Kh(this.h[7],l)},tl.prototype._digest=function(t){return"hex"===t?Dh.toHex32(this.h,"big"):Dh.split32(this.h,"big")};var rl=ah,nl=el;function il(){if(!(this instanceof il))return new il;nl.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}rl.inherits(il,nl);var ol=il;il.blockSize=512,il.outSize=224,il.hmacStrength=192,il.padLength=64,il.prototype._digest=function(t){return"hex"===t?rl.toHex32(this.h.slice(0,7),"big"):rl.split32(this.h.slice(0,7),"big")};var sl=ah,al=wh,ul=uh,cl=sl.rotr64_hi,hl=sl.rotr64_lo,ll=sl.shr64_hi,fl=sl.shr64_lo,dl=sl.sum64,pl=sl.sum64_hi,yl=sl.sum64_lo,gl=sl.sum64_4_hi,ml=sl.sum64_4_lo,wl=sl.sum64_5_hi,bl=sl.sum64_5_lo,vl=al.BlockHash,_l=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function kl(){if(!(this instanceof kl))return new kl;vl.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=_l,this.W=new Array(160)}sl.inherits(kl,vl);var El=kl;function xl(t,e,r,n,i){var o=t&r^~t&i;return o<0&&(o+=4294967296),o}function Sl(t,e,r,n,i,o){var s=e&n^~e&o;return s<0&&(s+=4294967296),s}function Al(t,e,r,n,i){var o=t&r^t&i^r&i;return o<0&&(o+=4294967296),o}function Il(t,e,r,n,i,o){var s=e&n^e&o^n&o;return s<0&&(s+=4294967296),s}function Bl(t,e){var r=cl(t,e,28)^cl(e,t,2)^cl(e,t,7);return r<0&&(r+=4294967296),r}function Ml(t,e){var r=hl(t,e,28)^hl(e,t,2)^hl(e,t,7);return r<0&&(r+=4294967296),r}function Rl(t,e){var r=cl(t,e,14)^cl(t,e,18)^cl(e,t,9);return r<0&&(r+=4294967296),r}function Pl(t,e){var r=hl(t,e,14)^hl(t,e,18)^hl(e,t,9);return r<0&&(r+=4294967296),r}function Tl(t,e){var r=cl(t,e,1)^cl(t,e,8)^ll(t,e,7);return r<0&&(r+=4294967296),r}function Ll(t,e){var r=hl(t,e,1)^hl(t,e,8)^fl(t,e,7);return r<0&&(r+=4294967296),r}function Ol(t,e){var r=cl(t,e,19)^cl(e,t,29)^ll(t,e,6);return r<0&&(r+=4294967296),r}function Ul(t,e){var r=hl(t,e,19)^hl(e,t,29)^fl(t,e,6);return r<0&&(r+=4294967296),r}kl.blockSize=1024,kl.outSize=512,kl.hmacStrength=192,kl.padLength=128,kl.prototype._prepareBlock=function(t,e){for(var r=this.W,n=0;n<32;n++)r[n]=t[e+n];for(;n<r.length;n+=2){var i=Ol(r[n-4],r[n-3]),o=Ul(r[n-4],r[n-3]),s=r[n-14],a=r[n-13],u=Tl(r[n-30],r[n-29]),c=Ll(r[n-30],r[n-29]),h=r[n-32],l=r[n-31];r[n]=gl(i,o,s,a,u,c,h,l),r[n+1]=ml(i,o,s,a,u,c,h,l)}},kl.prototype._update=function(t,e){this._prepareBlock(t,e);var r=this.W,n=this.h[0],i=this.h[1],o=this.h[2],s=this.h[3],a=this.h[4],u=this.h[5],c=this.h[6],h=this.h[7],l=this.h[8],f=this.h[9],d=this.h[10],p=this.h[11],y=this.h[12],g=this.h[13],m=this.h[14],w=this.h[15];ul(this.k.length===r.length);for(var b=0;b<r.length;b+=2){var v=m,_=w,k=Rl(l,f),E=Pl(l,f),x=xl(l,f,d,p,y),S=Sl(l,f,d,p,y,g),A=this.k[b],I=this.k[b+1],B=r[b],M=r[b+1],R=wl(v,_,k,E,x,S,A,I,B,M),P=bl(v,_,k,E,x,S,A,I,B,M);v=Bl(n,i),_=Ml(n,i),k=Al(n,i,o,s,a),E=Il(n,i,o,s,a,u);var T=pl(v,_,k,E),L=yl(v,_,k,E);m=y,w=g,y=d,g=p,d=l,p=f,l=pl(c,h,R,P),f=yl(h,h,R,P),c=a,h=u,a=o,u=s,o=n,s=i,n=pl(R,P,T,L),i=yl(R,P,T,L)}dl(this.h,0,n,i),dl(this.h,2,o,s),dl(this.h,4,a,u),dl(this.h,6,c,h),dl(this.h,8,l,f),dl(this.h,10,d,p),dl(this.h,12,y,g),dl(this.h,14,m,w)},kl.prototype._digest=function(t){return"hex"===t?sl.toHex32(this.h,"big"):sl.split32(this.h,"big")};var Cl=ah,Nl=El;function zl(){if(!(this instanceof zl))return new zl;Nl.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}Cl.inherits(zl,Nl);var Dl=zl;zl.blockSize=1024,zl.outSize=384,zl.hmacStrength=192,zl.padLength=128,zl.prototype._digest=function(t){return"hex"===t?Cl.toHex32(this.h.slice(0,12),"big"):Cl.split32(this.h.slice(0,12),"big")},kh.sha1=zh,kh.sha224=ol,kh.sha256=el,kh.sha384=Dl,kh.sha512=El;var jl={},Wl=ah,Fl=wh,Kl=Wl.rotl32,Vl=Wl.sum32,ql=Wl.sum32_3,Hl=Wl.sum32_4,$l=Fl.BlockHash;function Gl(){if(!(this instanceof Gl))return new Gl;$l.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}function Zl(t,e,r,n){return t<=15?e^r^n:t<=31?e&r|~e&n:t<=47?(e|~r)^n:t<=63?e&n|r&~n:e^(r|~n)}function Yl(t){return t<=15?0:t<=31?1518500249:t<=47?1859775393:t<=63?2400959708:2840853838}function Jl(t){return t<=15?1352829926:t<=31?1548603684:t<=47?1836072691:t<=63?2053994217:0}Wl.inherits(Gl,$l),jl.ripemd160=Gl,Gl.blockSize=512,Gl.outSize=160,Gl.hmacStrength=192,Gl.padLength=64,Gl.prototype._update=function(t,e){for(var r=this.h[0],n=this.h[1],i=this.h[2],o=this.h[3],s=this.h[4],a=r,u=n,c=i,h=o,l=s,f=0;f<80;f++){var d=Vl(Kl(Hl(r,Zl(f,n,i,o),t[Xl[f]+e],Yl(f)),tf[f]),s);r=s,s=o,o=Kl(i,10),i=n,n=d,d=Vl(Kl(Hl(a,Zl(79-f,u,c,h),t[Ql[f]+e],Jl(f)),ef[f]),l),a=l,l=h,h=Kl(c,10),c=u,u=d}d=ql(this.h[1],i,h),this.h[1]=ql(this.h[2],o,l),this.h[2]=ql(this.h[3],s,a),this.h[3]=ql(this.h[4],r,u),this.h[4]=ql(this.h[0],n,c),this.h[0]=d},Gl.prototype._digest=function(t){return"hex"===t?Wl.toHex32(this.h,"little"):Wl.split32(this.h,"little")};var Xl=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],Ql=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],tf=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],ef=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],rf=ah,nf=uh;function of(t,e,r){if(!(this instanceof of))return new of(t,e,r);this.Hash=t,this.blockSize=t.blockSize/8,this.outSize=t.outSize/8,this.inner=null,this.outer=null,this._init(rf.toArray(e,r))}var sf=of;of.prototype._init=function(t){t.length>this.blockSize&&(t=(new this.Hash).update(t).digest()),nf(t.length<=this.blockSize);for(var e=t.length;e<this.blockSize;e++)t.push(0);for(e=0;e<t.length;e++)t[e]^=54;for(this.inner=(new this.Hash).update(t),e=0;e<t.length;e++)t[e]^=106;this.outer=(new this.Hash).update(t)},of.prototype.update=function(t,e){return this.inner.update(t,e),this},of.prototype.digest=function(t){return this.outer.update(this.inner.digest()),this.outer.digest(t)},function(t){var e=sh;e.utils=ah,e.common=wh,e.sha=kh,e.ripemd=jl,e.hmac=sf,e.sha1=e.sha.sha1,e.sha256=e.sha.sha256,e.sha224=e.sha.sha224,e.sha384=e.sha.sha384,e.sha512=e.sha.sha512,e.ripemd160=e.ripemd.ripemd160}();var af=e(sh);let uf=!1,cf=!1;const hf={debug:1,default:2,info:2,warning:3,error:4,off:5};let lf=hf.default,ff=null;const df=function(){try{const t=[];if(["NFD","NFC","NFKD","NFKC"].forEach((e=>{try{if("test"!=="test".normalize(e))throw new Error("bad normalize")}catch(r){t.push(e)}})),t.length)throw new Error("missing "+t.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(t){return t.message}return null}();var pf,yf;!function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"}(pf||(pf={})),function(t){t.UNKNOWN_ERROR="UNKNOWN_ERROR",t.NOT_IMPLEMENTED="NOT_IMPLEMENTED",t.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",t.NETWORK_ERROR="NETWORK_ERROR",t.SERVER_ERROR="SERVER_ERROR",t.TIMEOUT="TIMEOUT",t.BUFFER_OVERRUN="BUFFER_OVERRUN",t.NUMERIC_FAULT="NUMERIC_FAULT",t.MISSING_NEW="MISSING_NEW",t.INVALID_ARGUMENT="INVALID_ARGUMENT",t.MISSING_ARGUMENT="MISSING_ARGUMENT",t.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",t.CALL_EXCEPTION="CALL_EXCEPTION",t.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",t.NONCE_EXPIRED="NONCE_EXPIRED",t.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",t.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",t.TRANSACTION_REPLACED="TRANSACTION_REPLACED",t.ACTION_REJECTED="ACTION_REJECTED"}(yf||(yf={}));const gf="0123456789abcdef";class mf{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,e){const r=t.toLowerCase();null==hf[r]&&this.throwArgumentError("invalid log level name","logLevel",t),lf>hf[r]||console.log.apply(console,e)}debug(...t){this._log(mf.levels.DEBUG,t)}info(...t){this._log(mf.levels.INFO,t)}warn(...t){this._log(mf.levels.WARNING,t)}makeError(t,e,r){if(cf)return this.makeError("censored error",e,{});e||(e=mf.errors.UNKNOWN_ERROR),r||(r={});const n=[];Object.keys(r).forEach((t=>{const e=r[t];try{if(e instanceof Uint8Array){let r="";for(let t=0;t<e.length;t++)r+=gf[e[t]>>4],r+=gf[15&e[t]];n.push(t+"=Uint8Array(0x"+r+")")}else n.push(t+"="+JSON.stringify(e))}catch(e){n.push(t+"="+JSON.stringify(r[t].toString()))}})),n.push(`code=${e}`),n.push(`version=${this.version}`);const i=t;let o="";switch(e){case yf.NUMERIC_FAULT:{o="NUMERIC_FAULT";const e=t;switch(e){case"overflow":case"underflow":case"division-by-zero":o+="-"+e;break;case"negative-power":case"negative-width":o+="-unsupported";break;case"unbound-bitwise-result":o+="-unbound-result"}break}case yf.CALL_EXCEPTION:case yf.INSUFFICIENT_FUNDS:case yf.MISSING_NEW:case yf.NONCE_EXPIRED:case yf.REPLACEMENT_UNDERPRICED:case yf.TRANSACTION_REPLACED:case yf.UNPREDICTABLE_GAS_LIMIT:o=e}o&&(t+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),n.length&&(t+=" ("+n.join(", ")+")");const s=new Error(t);return s.reason=i,s.code=e,Object.keys(r).forEach((function(t){s[t]=r[t]})),s}throwError(t,e,r){throw this.makeError(t,e,r)}throwArgumentError(t,e,r){return this.throwError(t,mf.errors.INVALID_ARGUMENT,{argument:e,value:r})}assert(t,e,r,n){t||this.throwError(e,r,n)}assertArgument(t,e,r,n){t||this.throwArgumentError(e,r,n)}checkNormalize(t){df&&this.throwError("platform missing String.prototype.normalize",mf.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:df})}checkSafeUint53(t,e){"number"==typeof t&&(null==e&&(e="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(e,mf.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,mf.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,e,r){r=r?": "+r:"",t<e&&this.throwError("missing argument"+r,mf.errors.MISSING_ARGUMENT,{count:t,expectedCount:e}),t>e&&this.throwError("too many arguments"+r,mf.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:e})}checkNew(t,e){t!==Object&&null!=t||this.throwError("missing new",mf.errors.MISSING_NEW,{name:e.name})}checkAbstract(t,e){t===e?this.throwError("cannot instantiate abstract class "+JSON.stringify(e.name)+" directly; use a sub-class",mf.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",mf.errors.MISSING_NEW,{name:e.name})}static globalLogger(){return ff||(ff=new mf("logger/5.7.0")),ff}static setCensorship(t,e){if(!t&&e&&this.globalLogger().throwError("cannot permanently disable censorship",mf.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),uf){if(!t)return;this.globalLogger().throwError("error censorship permanent",mf.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}cf=!!t,uf=!!e}static setLogLevel(t){const e=hf[t.toLowerCase()];null!=e?lf=e:mf.globalLogger().warn("invalid log level - "+t)}static from(t){return new mf(t)}}mf.errors=yf,mf.levels=pf;const wf=new mf("bytes/5.7.0");function bf(t){return t.slice||(t.slice=function(){const e=Array.prototype.slice.call(arguments);return bf(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function vf(t){return"number"==typeof t&&t==t&&t%1==0}function _f(t,e){if(e||(e={}),"number"==typeof t){wf.checkSafeUint53(t,"invalid arrayify value");const e=[];for(;t;)e.unshift(255&t),t=parseInt(String(t/256));return 0===e.length&&e.push(0),bf(new Uint8Array(e))}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),function(t){return!!t.toHexString}(t)&&(t=t.toHexString()),function(t,e){if("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))return!1;if(e&&t.length!==2+2*e)return!1;return!0}(t)){let r=t.substring(2);r.length%2&&("left"===e.hexPad?r="0"+r:"right"===e.hexPad?r+="0":wf.throwArgumentError("hex data is odd-length","value",t));const n=[];for(let t=0;t<r.length;t+=2)n.push(parseInt(r.substring(t,t+2),16));return bf(new Uint8Array(n))}return function(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t)return!1;if(!vf(t.length)||t.length<0)return!1;for(let e=0;e<t.length;e++){const r=t[e];if(!vf(r)||r<0||r>=256)return!1}return!0}(t)?bf(new Uint8Array(t)):wf.throwArgumentError("invalid arrayify value","value",t)}function kf(t){return"0x"+af.sha256().update(_f(t)).digest("hex")}new mf("sha2/5.7.0");const Ef=new Wo("namesLPneVptA9Z5rqUDD9tMTWEJwofgaYwp8cawRkX"),xf="SPL Name Service",Sf=new Wo("58PwtjSDuFHuUkYjH9BYnnQKHfwo9reZhC2zMJv9JPkx"),Af=new Wo("jCebN34bUfdeUYJT13J1yG16XWQpt5PDx6Mse9GUqhR"),If=new Wo("ETp9eKXVv1dWwHSpsXRUuXHmw24PwRkttCGVgpZEY9zF"),Bf=new Wo("AUoZ3YAhV3b2rZeEH93UMZHXUZcTramBvb4d9YEVySkc"),Mf=new Wo("33m47vH6Eav6jr5Ry86XjhRft2jRBLDnDgPSHoquXi2Z"),Rf=new Wo("FvPH7PrVrLGKPfqaf3xJodFTjZriqrAXXLTVWEorTFBi"),Pf=new Wo("4YcexoW3r78zz16J2aqmukBLRwGq6rAvWzJpkYAXqebv"),Tf=new Wo("DmSyHDSM9eSLyvoLsPvDr5fRRFZ7Bfr3h3ULvWpgQaq7"),Lf=new Wo("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),Of=[new Wo("3ogYncmMM5CmytsGCqKHydmXmKUZ6sGWvizkzqwT7zb1"),new Wo("DM1jJCkZZEwY5tmWbgvKRxsDFzXCdbfrYCCH1CtwguEs"),new Wo("ADCp4QXFajHrhy4f43pD6GJFtQLkdBY2mjS9DfCk7tNW"),new Wo("2XTgjw8yi1E3Etgj4CUyRD7Zk49gynH2U9gA5N2MY4NP"),new Wo("5oDWj8vr3vbcq9JZTtwXqrkCMZggMsDzNietvbr1BNfe"),new Wo("8kJqxAbqbPLGLMgB6FhLcnw2SiUEavx2aEGM3WQGhtJF"),new Wo("HemvJzwxvVpWBjPETpaseAH395WAxb2G73MeUfjVkK1u")],Uf=new Map([["EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v","USDC"],["Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB","USDT"],["So11111111111111111111111111111111111111112","SOL"],["EchesyfXePKdLtoiZSL8pBe8Myagyy8ZRqsACNCFGnvp","FIDA"],["FeGn77dhg1KXRRFeSwwMiykZnZPw5JXW6naf2aQgZDQf","ETH"],["7i5KKsX2weiTkry7jA4ZwSuXGhs5eJBEjY8vVxR4pfRx","GMT"],["AFbX8oGjGpmVFywbVouvhQSRmiW2aR1mohfahi4Y2AdB","GST"],["mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So","MSOL"],["DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263","BONK"],["EPeUFDgHRxs9xxEPVaL6kfGQvCon7jmAWKVUHuux1Tpz","BAT"],["HZ1JovNiVvGrGNiiYvEozEVgZ58xaU3RKwX8eACQBCt3","PYTH"]]),Cf=new Wo("AHtgzX45WTKfkPG53L6WYhGEXwQkN1BVknET3sVsLL8J"),Nf=new Wo("GcWEQ9K78FV7LEHteFVciYApERk5YvQuFDQPk1yYJVXi"),zf=new Wo("BPeXUQDqGbzxeK1LJby6ugvCBuo7kRSEUkjD726mUVsz"),Df=new Wo("72aLKvXeV4aansAQtxKymeXDevT5ed6sCuz9iN62ugPT"),jf=new Wo("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s");async function Wf(t,e){if(!await t.getAccountInfo(e))throw new Dc(exports.ErrorType.AccountDoesNotExist);return oh.retrieve(t,e)}async function Ff(t){const e=xf+t,r=kf(n.Buffer.from(e,"utf8")).slice(2);return n.Buffer.from(r,"hex")}async function Kf(t,e,r){const i=[t];e?i.push(e.toBuffer()):i.push(n.Buffer.alloc(32)),r?i.push(r.toBuffer()):i.push(n.Buffer.alloc(32));const[o]=await Wo.findProgramAddress(i,Ef);return o}const Vf=async(t,e=Sf)=>{let r=await Ff(t);return{pubkey:await Kf(r,void 0,e),hashed:r}},qf=async(t,e=!1)=>{t.endsWith(".sol")&&(t=t.slice(0,-4));const r=t.split(".");if(2===r.length){const t=n.Buffer.from([e?1:0]).toString().concat(r[0]),{pubkey:i}=await Vf(r[1]);return{...await Vf(t,i),isSub:!0,parent:i}}if(3===r.length&&e){const{pubkey:t}=await Vf(r[2]),{pubkey:e}=await Vf("\0".concat(r[1]),t),i=n.Buffer.from([1]).toString();return{...await Vf(i.concat(r[0]),e),isSub:!0,parent:t,isSubRecord:!0}}if(r.length>=3)throw new Dc(exports.ErrorType.InvalidInput);return{...await Vf(t,Sf),isSub:!1,parent:void 0}};var Hf={},$f=r(pc),Gf={};Object.defineProperty(Gf,"__esModule",{value:!0}),Gf.readBigUInt64LE=Gf.readBigInt64LE=void 0;var Zf=function(){return new Error("Attempt to access memory outside buffer bounds")},Yf=function(t,e,r){return new Error('The "'+t+'" argument must be of type '+e+". Received "+r)},Jf=function(t,e,r){return new Error('The value of "'+t+" is out of range. It must be "+e+". Received "+r)};function Xf(t,e){if("number"!=typeof t)throw Yf(e,"number",t)}function Qf(t,e){if(Math.floor(t)!==t)throw Xf(t,"offset"),Jf("offset","an integer",t);if(e<0)throw Zf();throw Jf("offset",">= 0 and <= "+e,t)}Gf.readBigInt64LE=function(t,e){void 0===e&&(e=0),Xf(e,"offset");var r=t[e],n=t[e+7];void 0!==r&&void 0!==n||Qf(e,t.length-8);var i=t[e+4]+t[e+5]*Math.pow(2,8)+t[e+6]*Math.pow(2,16)+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(r+t[++e]*Math.pow(2,8)+t[++e]*Math.pow(2,16)+t[++e]*Math.pow(2,24))},Gf.readBigUInt64LE=function(t,e){void 0===e&&(e=0),Xf(e,"offset");var r=t[e],n=t[e+7];void 0!==r&&void 0!==n||Qf(e,t.length-8);var i=r+t[++e]*Math.pow(2,8)+t[++e]*Math.pow(2,16)+t[++e]*Math.pow(2,24),o=t[++e]+t[++e]*Math.pow(2,8)+t[++e]*Math.pow(2,16)+n*Math.pow(2,24);return BigInt(i)+(BigInt(o)<<BigInt(32))};var td,ed={};function rd(){if(td)return ed;td=1;var e=t&&t.__assign||function(){return e=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},e.apply(this,arguments)},r=t&&t.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},n=t&&t.__generator||function(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}};Object.defineProperty(ed,"__esModule",{value:!0}),ed.PythConnection=void 0;var i=Zv(),o=function(){function t(t,e,r,n){void 0===r&&(r="finalized"),this.productAccountKeyToProduct={},this.priceAccountKeyToProductAccountKey={},this.callbacks=[],this.connection=t,this.pythProgramKey=e,this.commitment=r,this.feedIds=n}return t.prototype.handleProductAccount=function(t,r,n){var o=i.parseProductData(r.data);this.productAccountKeyToProduct[t.toString()]={key:t,slot:n,accountInfo:e(e({},r),{data:o})},o.priceAccountKey&&(this.priceAccountKeyToProductAccountKey[o.priceAccountKey.toString()]=t.toString())},t.prototype.handlePriceAccount=function(t,r,n){var o=this.productAccountKeyToProduct[this.priceAccountKeyToProductAccountKey[t.toString()]];if(void 0===o)throw new Error("Got a price update for an unknown product. This is a bug in the library, please report it to the developers.");for(var s=i.parsePriceData(r.data,n),a={key:t,slot:n,accountInfo:e(e({},r),{data:s})},u=0,c=this.callbacks;u<c.length;u++){(0,c[u])(o,a)}},t.prototype.handleAccount=function(t,e,r,n){var o=i.parseBaseData(e.data);if(o)switch(o.type){case i.AccountType.Mapping:break;case i.AccountType.Product:this.handleProductAccount(t,e,n);break;case i.AccountType.Price:r||this.handlePriceAccount(t,e,n);break;case i.AccountType.Test:case i.AccountType.Permission:break;default:throw new Error("Unknown account type: "+o.type+". Try upgrading pyth-client.")}},t.prototype.start=function(){return r(this,void 0,void 0,(function(){var t,e,r,i,o,s,a,u,c,h,l,f=this;return n(this,(function(n){switch(n.label){case 0:return[4,Promise.all([this.connection.getProgramAccounts(this.pythProgramKey,this.commitment),this.connection.getSlot(this.commitment)])];case 1:for(t=n.sent(),e=t[0],r=t[1],i=0,o=e;i<o.length;i++)l=o[i],this.handleAccount(l.pubkey,l.account,!0,r);if(this.feedIds)for(s=this.feedIds.map((function(t){return t.toString()})),e=e.filter((function(t){return s.includes(t.pubkey.toString())})),a=function(t){u.connection.onAccountChange(t.pubkey,(function(e,r){f.handleAccount(t.pubkey,e,!1,r.slot)}),u.commitment)},u=this,c=0,h=e;c<h.length;c++)l=h[c],a(l);else this.connection.onProgramAccountChange(this.pythProgramKey,(function(t,e){f.handleAccount(t.accountId,t.accountInfo,!1,e.slot)}),this.commitment);return[2]}}))}))},t.prototype.onPriceChange=function(t){this.callbacks.push((function(e,r){return t(e.accountInfo.data.product,r.accountInfo.data)}))},t.prototype.onPriceChangeVerbose=function(t){this.callbacks.push(t)},t.prototype.stop=function(){return r(this,void 0,void 0,(function(){return n(this,(function(t){return this.callbacks=[],[2]}))}))},t}();return ed.PythConnection=o,ed}var nd,id={};function od(){if(nd)return id;nd=1;var e=t&&t.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))},r=t&&t.__generator||function(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}};Object.defineProperty(id,"__esModule",{value:!0}),id.PythHttpClient=void 0;var n=Zv(),i=function(){function t(t,e,r){void 0===r&&(r="finalized"),this.connection=t,this.pythProgramKey=e,this.commitment=r}return t.prototype.getData=function(){return e(this,void 0,void 0,(function(){var t,e,i,o,s,a,u,c,h,l,f,d;return r(this,(function(r){switch(r.label){case 0:return t=new Set,e=new Set,i=new Set,o=new Map,s=new Map,a=new Array,[4,Promise.all([this.connection.getProgramAccounts(this.pythProgramKey,this.commitment),this.connection.getSlot(this.commitment)])];case 1:return u=r.sent(),c=u[0],h=u[1],l=new Array,f=new Map,c.forEach((function(r){var s=n.parseBaseData(r.account.data);if(s)switch(s.type){case n.AccountType.Mapping:break;case n.AccountType.Product:var a=n.parseProductData(r.account.data);f.set(r.pubkey.toBase58(),a.product),t.add(a.product.asset_type),e.add(a.product.symbol),i.add(a.product),o.set(a.product.symbol,a.product);break;case n.AccountType.Price:var u=n.parsePriceData(r.account.data,h);l.push(u);break;case n.AccountType.Test:break;case n.AccountType.Permission:d=n.parsePermissionData(r.account.data);break;default:throw new Error("Unknown account type: "+s.type+". Try upgrading pyth-client.")}})),l.forEach((function(t){var e=f.get(t.productAccountKey.toBase58());e&&(s.set(e.symbol,t),a.push(t))})),[2,{assetTypes:Array.from(t),symbols:Array.from(e),products:Array.from(i),productFromSymbol:o,productPrice:s,prices:a,permissionData:d}]}}))}))},t.prototype.getAssetPricesFromAccounts=function(t){return e(this,void 0,void 0,(function(){var e,i,o,s,a,u,c,h;return r(this,(function(r){switch(r.label){case 0:return e=[],[4,Promise.all([this.connection.getMultipleAccountsInfo(t,this.commitment),this.connection.getSlot(this.commitment)])];case 1:for(i=r.sent(),o=i[0],s=i[1],a=0;a<t.length;a++){if(!(u=o[a]))throw new Error("Could not get account info for account "+t[a].toBase58());if(void 0===(c=n.parseBaseData(u.data))||c.type!==n.AccountType.Price)throw new Error("Account "+t[a].toBase58()+" is not a price account");h=n.parsePriceData(u.data,s),e.push(h)}return[2,e]}}))}))},t}();return id.PythHttpClient=i,id}var sd,ad={};var ud,cd={},hd={},ld=e(se("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")),fd={exports:{}};function dd(){if(ud)return fd.exports;ud=1;const t=/[\p{Lu}]/u,e=/[\p{Ll}]/u,r=/^[\p{Lu}](?![\p{Lu}])/gu,n=/([\p{Alpha}\p{N}_]|$)/u,i=/[_.\- ]+/,o=new RegExp("^"+i.source),s=new RegExp(i.source+n.source,"gu"),a=new RegExp("\\d+"+n.source,"gu"),u=(n,i)=>{if("string"!=typeof n&&!Array.isArray(n))throw new TypeError("Expected the input to be `string | string[]`");if(i={pascalCase:!1,preserveConsecutiveUppercase:!1,...i},n=Array.isArray(n)?n.map((t=>t.trim())).filter((t=>t.length)).join("-"):n.trim(),0===n.length)return"";const u=!1===i.locale?t=>t.toLowerCase():t=>t.toLocaleLowerCase(i.locale),c=!1===i.locale?t=>t.toUpperCase():t=>t.toLocaleUpperCase(i.locale);if(1===n.length)return i.pascalCase?c(n):u(n);return n!==u(n)&&(n=((r,n,i)=>{let o=!1,s=!1,a=!1;for(let u=0;u<r.length;u++){const c=r[u];o&&t.test(c)?(r=r.slice(0,u)+"-"+r.slice(u),o=!1,a=s,s=!0,u++):s&&a&&e.test(c)?(r=r.slice(0,u-1)+"-"+r.slice(u-1),a=s,s=!1,o=!0):(o=n(c)===c&&i(c)!==c,a=s,s=i(c)===c&&n(c)!==c)}return r})(n,u,c)),n=n.replace(o,""),n=i.preserveConsecutiveUppercase?((t,e)=>(r.lastIndex=0,t.replace(r,(t=>e(t)))))(n,u):u(n),i.pascalCase&&(n=c(n.charAt(0))+n.slice(1)),((t,e)=>(s.lastIndex=0,a.lastIndex=0,t.replace(s,((t,r)=>e(r))).replace(a,(t=>e(t)))))(n,c)};return fd.exports=u,fd.exports.default=u,fd.exports}var pd=e(dd()),yd={},gd={};class md{constructor(t,e){if(!Number.isInteger(t))throw new TypeError("span must be an integer");this.span=t,this.property=e}makeDestinationObject(){return{}}decode(t,e){throw new Error("Layout is abstract")}encode(t,e,r){throw new Error("Layout is abstract")}getSpan(t,e){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(t){const e=Object.create(this.constructor.prototype);return Object.assign(e,this),e.property=t,e}fromArray(t){}}function wd(t,e){return e.property?t+"["+e.property+"]":t}gd.Layout=md,gd.nameWithProperty=wd,gd.bindConstructorLayout=function(t,e){if("function"!=typeof t)throw new TypeError("Class must be constructor");if(t.hasOwnProperty("layout_"))throw new Error("Class is already bound to a layout");if(!(e&&e instanceof md))throw new TypeError("layout must be a Layout");if(e.hasOwnProperty("boundConstructor_"))throw new Error("layout is already bound to a constructor");t.layout_=e,e.boundConstructor_=t,e.makeDestinationObject=()=>new t,Object.defineProperty(t.prototype,"encode",{value:function(t,r){return e.encode(this,t,r)},writable:!0}),Object.defineProperty(t,"decode",{value:function(t,r){return e.decode(t,r)},writable:!0})};class bd extends md{isCount(){throw new Error("ExternalLayout is abstract")}}class vd extends bd{constructor(t,e){if(void 0===t&&(t=1),!Number.isInteger(t)||0>=t)throw new TypeError("elementSpan must be a (positive) integer");super(-1,e),this.elementSpan=t}isCount(){return!0}decode(t,e){void 0===e&&(e=0);const r=t.length-e;return Math.floor(r/this.elementSpan)}encode(t,e,r){return 0}}class _d extends bd{constructor(t,e,r){if(!(t instanceof md))throw new TypeError("layout must be a Layout");if(void 0===e)e=0;else if(!Number.isInteger(e))throw new TypeError("offset must be integer or undefined");super(t.span,r||t.property),this.layout=t,this.offset=e}isCount(){return this.layout instanceof kd||this.layout instanceof Ed}decode(t,e){return void 0===e&&(e=0),this.layout.decode(t,e+this.offset)}encode(t,e,r){return void 0===r&&(r=0),this.layout.encode(t,e,r+this.offset)}}class kd extends md{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return void 0===e&&(e=0),t.readUIntLE(e,this.span)}encode(t,e,r){return void 0===r&&(r=0),e.writeUIntLE(t,r,this.span),this.span}}class Ed extends md{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return void 0===e&&(e=0),t.readUIntBE(e,this.span)}encode(t,e,r){return void 0===r&&(r=0),e.writeUIntBE(t,r,this.span),this.span}}class xd extends md{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return void 0===e&&(e=0),t.readIntLE(e,this.span)}encode(t,e,r){return void 0===r&&(r=0),e.writeIntLE(t,r,this.span),this.span}}class Sd extends md{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return void 0===e&&(e=0),t.readIntBE(e,this.span)}encode(t,e,r){return void 0===r&&(r=0),e.writeIntBE(t,r,this.span),this.span}}const Ad=Math.pow(2,32);function Id(t){const e=Math.floor(t/Ad);return{hi32:e,lo32:t-e*Ad}}function Bd(t,e){return t*Ad+e}class Md extends md{constructor(t){super(8,t)}decode(t,e){void 0===e&&(e=0);const r=t.readUInt32LE(e);return Bd(t.readUInt32LE(e+4),r)}encode(t,e,r){void 0===r&&(r=0);const n=Id(t);return e.writeUInt32LE(n.lo32,r),e.writeUInt32LE(n.hi32,r+4),8}}class Rd extends md{constructor(t){super(8,t)}decode(t,e){void 0===e&&(e=0);return Bd(t.readUInt32BE(e),t.readUInt32BE(e+4))}encode(t,e,r){void 0===r&&(r=0);const n=Id(t);return e.writeUInt32BE(n.hi32,r),e.writeUInt32BE(n.lo32,r+4),8}}class Pd extends md{constructor(t){super(8,t)}decode(t,e){void 0===e&&(e=0);const r=t.readUInt32LE(e);return Bd(t.readInt32LE(e+4),r)}encode(t,e,r){void 0===r&&(r=0);const n=Id(t);return e.writeUInt32LE(n.lo32,r),e.writeInt32LE(n.hi32,r+4),8}}class Td extends md{constructor(t){super(8,t)}decode(t,e){void 0===e&&(e=0);return Bd(t.readInt32BE(e),t.readUInt32BE(e+4))}encode(t,e,r){void 0===r&&(r=0);const n=Id(t);return e.writeInt32BE(n.hi32,r),e.writeUInt32BE(n.lo32,r+4),8}}class Ld extends md{constructor(t){super(4,t)}decode(t,e){return void 0===e&&(e=0),t.readFloatLE(e)}encode(t,e,r){return void 0===r&&(r=0),e.writeFloatLE(t,r),4}}class Od extends md{constructor(t){super(4,t)}decode(t,e){return void 0===e&&(e=0),t.readFloatBE(e)}encode(t,e,r){return void 0===r&&(r=0),e.writeFloatBE(t,r),4}}class Ud extends md{constructor(t){super(8,t)}decode(t,e){return void 0===e&&(e=0),t.readDoubleLE(e)}encode(t,e,r){return void 0===r&&(r=0),e.writeDoubleLE(t,r),8}}class Cd extends md{constructor(t){super(8,t)}decode(t,e){return void 0===e&&(e=0),t.readDoubleBE(e)}encode(t,e,r){return void 0===r&&(r=0),e.writeDoubleBE(t,r),8}}class Nd extends md{constructor(t,e,r){if(!(t instanceof md))throw new TypeError("elementLayout must be a Layout");if(!(e instanceof bd&&e.isCount()||Number.isInteger(e)&&0<=e))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let n=-1;!(e instanceof bd)&&0<t.span&&(n=e*t.span),super(n,r),this.elementLayout=t,this.count=e}getSpan(t,e){if(0<=this.span)return this.span;void 0===e&&(e=0);let r=0,n=this.count;if(n instanceof bd&&(n=n.decode(t,e)),0<this.elementLayout.span)r=n*this.elementLayout.span;else{let i=0;for(;i<n;)r+=this.elementLayout.getSpan(t,e+r),++i}return r}decode(t,e){void 0===e&&(e=0);const r=[];let n=0,i=this.count;for(i instanceof bd&&(i=i.decode(t,e));n<i;)r.push(this.elementLayout.decode(t,e)),e+=this.elementLayout.getSpan(t,e),n+=1;return r}encode(t,e,r){void 0===r&&(r=0);const n=this.elementLayout,i=t.reduce(((t,i)=>t+n.encode(i,e,r+t)),0);return this.count instanceof bd&&this.count.encode(t.length,e,r),i}}class zd extends md{constructor(t,e,r){if(!Array.isArray(t)||!t.reduce(((t,e)=>t&&e instanceof md),!0))throw new TypeError("fields must be array of Layout instances");"boolean"==typeof e&&void 0===r&&(r=e,e=void 0);for(const e of t)if(0>e.span&&void 0===e.property)throw new Error("fields cannot contain unnamed variable-length layout");let n=-1;try{n=t.reduce(((t,e)=>t+e.getSpan()),0)}catch(t){}super(n,e),this.fields=t,this.decodePrefixes=!!r}getSpan(t,e){if(0<=this.span)return this.span;void 0===e&&(e=0);let r=0;try{r=this.fields.reduce(((r,n)=>{const i=n.getSpan(t,e);return e+=i,r+i}),0)}catch(t){throw new RangeError("indeterminate span")}return r}decode(t,e){void 0===e&&(e=0);const r=this.makeDestinationObject();for(const n of this.fields)if(void 0!==n.property&&(r[n.property]=n.decode(t,e)),e+=n.getSpan(t,e),this.decodePrefixes&&t.length===e)break;return r}encode(t,e,r){void 0===r&&(r=0);const n=r;let i=0,o=0;for(const n of this.fields){let s=n.span;if(o=0<s?s:0,void 0!==n.property){const i=t[n.property];void 0!==i&&(o=n.encode(i,e,r),0>s&&(s=n.getSpan(e,r)))}i=r,r+=s}return i+o-n}fromArray(t){const e=this.makeDestinationObject();for(const r of this.fields)void 0!==r.property&&0<t.length&&(e[r.property]=t.shift());return e}layoutFor(t){if("string"!=typeof t)throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}offsetOf(t){if("string"!=typeof t)throw new TypeError("property must be string");let e=0;for(const r of this.fields){if(r.property===t)return e;0>r.span?e=-1:0<=e&&(e+=r.span)}}}class Dd{constructor(t){this.property=t}decode(){throw new Error("UnionDiscriminator is abstract")}encode(){throw new Error("UnionDiscriminator is abstract")}}class jd extends Dd{constructor(t,e){if(!(t instanceof bd&&t.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(e||t.property||"variant"),this.layout=t}decode(t,e){return this.layout.decode(t,e)}encode(t,e,r){return this.layout.encode(t,e,r)}}class Wd extends md{constructor(t,e,r){const n=t instanceof kd||t instanceof Ed;if(n)t=new jd(new _d(t));else if(t instanceof bd&&t.isCount())t=new jd(t);else if(!(t instanceof Dd))throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(void 0===e&&(e=null),!(null===e||e instanceof md))throw new TypeError("defaultLayout must be null or a Layout");if(null!==e){if(0>e.span)throw new Error("defaultLayout must have constant span");void 0===e.property&&(e=e.replicate("content"))}let i=-1;e&&(i=e.span,0<=i&&n&&(i+=t.layout.span)),super(i,r),this.discriminator=t,this.usesPrefixDiscriminator=n,this.defaultLayout=e,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(t){return o(t)},this.configGetSourceVariant=function(t){o=t.bind(this)}}getSpan(t,e){if(0<=this.span)return this.span;void 0===e&&(e=0);const r=this.getVariant(t,e);if(!r)throw new Error("unable to determine span for unrecognized variant");return r.getSpan(t,e)}defaultGetSourceVariant(t){if(t.hasOwnProperty(this.discriminator.property)){if(this.defaultLayout&&t.hasOwnProperty(this.defaultLayout.property))return;const e=this.registry[t[this.discriminator.property]];if(e&&(!e.layout||t.hasOwnProperty(e.property)))return e}else for(const e in this.registry){const r=this.registry[e];if(t.hasOwnProperty(r.property))return r}throw new Error("unable to infer src variant")}decode(t,e){let r;void 0===e&&(e=0);const n=this.discriminator,i=n.decode(t,e);let o=this.registry[i];if(void 0===o){let s=0;o=this.defaultLayout,this.usesPrefixDiscriminator&&(s=n.layout.span),r=this.makeDestinationObject(),r[n.property]=i,r[o.property]=this.defaultLayout.decode(t,e+s)}else r=o.decode(t,e);return r}encode(t,e,r){void 0===r&&(r=0);const n=this.getSourceVariant(t);if(void 0===n){const n=this.discriminator,i=this.defaultLayout;let o=0;return this.usesPrefixDiscriminator&&(o=n.layout.span),n.encode(t[n.property],e,r),o+i.encode(t[i.property],e,r+o)}return n.encode(t,e,r)}addVariant(t,e,r){const n=new Fd(this,t,e,r);return this.registry[t]=n,n}getVariant(t,e){let r=t;return Buffer.isBuffer(t)&&(void 0===e&&(e=0),r=this.discriminator.decode(t,e)),this.registry[r]}}class Fd extends md{constructor(t,e,r,n){if(!(t instanceof Wd))throw new TypeError("union must be a Union");if(!Number.isInteger(e)||0>e)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 md))throw new TypeError("layout must be a Layout");if(null!==t.defaultLayout&&0<=r.span&&r.span>t.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=t.span;0>t.span&&(i=r?r.span:0,0<=i&&t.usesPrefixDiscriminator&&(i+=t.discriminator.layout.span)),super(i,n),this.union=t,this.variant=e,this.layout=r||null}getSpan(t,e){if(0<=this.span)return this.span;void 0===e&&(e=0);let r=0;return this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span),r+this.layout.getSpan(t,e+r)}decode(t,e){const r=this.makeDestinationObject();if(void 0===e&&(e=0),this!==this.union.getVariant(t,e))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(t,e+n):this.property?r[this.property]=!0:this.union.usesPrefixDiscriminator&&(r[this.union.discriminator.property]=this.variant),r}encode(t,e,r){void 0===r&&(r=0);let n=0;if(this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span),this.layout&&!t.hasOwnProperty(this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,e,r);let i=n;if(this.layout&&(this.layout.encode(t[this.property],e,r+n),i+=this.layout.getSpan(e,r+n),0<=this.union.span&&i>this.union.span))throw new Error("encoded variant overruns containing union");return i}fromArray(t){if(this.layout)return this.layout.fromArray(t)}}function Kd(t){return 0>t&&(t+=4294967296),t}class Vd extends md{constructor(t,e,r){if(!(t instanceof kd||t instanceof Ed))throw new TypeError("word must be a UInt or UIntBE layout");if("string"==typeof e&&void 0===r&&(r=e,e=void 0),4<t.span)throw new RangeError("word cannot exceed 32 bits");super(t.span,r),this.word=t,this.msb=!!e,this.fields=[];let n=0;this._packedSetValue=function(t){return n=Kd(t),this},this._packedGetValue=function(){return n}}decode(t,e){const r=this.makeDestinationObject();void 0===e&&(e=0);const n=this.word.decode(t,e);this._packedSetValue(n);for(const t of this.fields)void 0!==t.property&&(r[t.property]=t.decode(n));return r}encode(t,e,r){void 0===r&&(r=0);const n=this.word.decode(e,r);this._packedSetValue(n);for(const e of this.fields)if(void 0!==e.property){const r=t[e.property];void 0!==r&&e.encode(r)}return this.word.encode(this._packedGetValue(),e,r)}addField(t,e){const r=new qd(this,t,e);return this.fields.push(r),r}addBoolean(t){const e=new Hd(this,t);return this.fields.push(e),e}fieldFor(t){if("string"!=typeof t)throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}}class qd{constructor(t,e,r){if(!(t instanceof Vd))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(e)||0>=e)throw new TypeError("bits must be positive integer");const n=8*t.span,i=t.fields.reduce(((t,e)=>t+e.bits),0);if(e+i>n)throw new Error("bits too long for span remainder ("+(n-i)+" of "+n+" remain)");this.container=t,this.bits=e,this.valueMask=(1<<e)-1,32===e&&(this.valueMask=4294967295),this.start=i,this.container.msb&&(this.start=n-i-e),this.wordMask=Kd(this.valueMask<<this.start),this.property=r}decode(){return Kd(this.container._packedGetValue()&this.wordMask)>>>this.start}encode(t){if(!Number.isInteger(t)||t!==Kd(t&this.valueMask))throw new TypeError(wd("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const e=this.container._packedGetValue(),r=Kd(t<<this.start);this.container._packedSetValue(Kd(e&~this.wordMask)|r)}}class Hd extends qd{constructor(t,e){super(t,1,e)}decode(t,e){return!!qd.prototype.decode.call(this,t,e)}encode(t){return"boolean"==typeof t&&(t=+t),qd.prototype.encode.call(this,t)}}class $d extends md{constructor(t,e){if(!(t instanceof bd&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let r=-1;t instanceof bd||(r=t),super(r,e),this.length=t}getSpan(t,e){let r=this.span;return 0>r&&(r=this.length.decode(t,e)),r}decode(t,e){void 0===e&&(e=0);let r=this.span;return 0>r&&(r=this.length.decode(t,e)),t.slice(e,e+r)}encode(t,e,r){let n=this.length;if(this.length instanceof bd&&(n=t.length),!Buffer.isBuffer(t)||n!==t.length)throw new TypeError(wd("Blob.encode",this)+" requires (length "+n+") Buffer as src");if(r+n>e.length)throw new RangeError("encoding overruns Buffer");return e.write(t.toString("hex"),r,n,"hex"),this.length instanceof bd&&this.length.encode(n,e,r),n}}class Gd extends md{constructor(t){super(-1,t)}getSpan(t,e){if(!Buffer.isBuffer(t))throw new TypeError("b must be a Buffer");void 0===e&&(e=0);let r=e;for(;r<t.length&&0!==t[r];)r+=1;return 1+r-e}decode(t,e,r){void 0===e&&(e=0);let n=this.getSpan(t,e);return t.slice(e,e+n-1).toString("utf-8")}encode(t,e,r){void 0===r&&(r=0),"string"!=typeof t&&(t=t.toString());const n=new Buffer(t,"utf8"),i=n.length;if(r+i>e.length)throw new RangeError("encoding overruns Buffer");return n.copy(e,r),e[r+i]=0,i+1}}class Zd extends md{constructor(t,e){if("string"==typeof t&&void 0===e&&(e=t,t=void 0),void 0===t)t=-1;else if(!Number.isInteger(t))throw new TypeError("maxSpan must be an integer");super(-1,e),this.maxSpan=t}getSpan(t,e){if(!Buffer.isBuffer(t))throw new TypeError("b must be a Buffer");return void 0===e&&(e=0),t.length-e}decode(t,e,r){void 0===e&&(e=0);let n=this.getSpan(t,e);if(0<=this.maxSpan&&this.maxSpan<n)throw new RangeError("text length exceeds maxSpan");return t.slice(e,e+n).toString("utf-8")}encode(t,e,r){void 0===r&&(r=0),"string"!=typeof t&&(t=t.toString());const n=new Buffer(t,"utf8"),i=n.length;if(0<=this.maxSpan&&this.maxSpan<i)throw new RangeError("text length exceeds maxSpan");if(r+i>e.length)throw new RangeError("encoding overruns Buffer");return n.copy(e,r),i}}class Yd extends md{constructor(t,e){super(0,e),this.value=t}decode(t,e,r){return this.value}encode(t,e,r){return 0}}gd.ExternalLayout=bd,gd.GreedyCount=vd,gd.OffsetLayout=_d,gd.UInt=kd,gd.UIntBE=Ed,gd.Int=xd,gd.IntBE=Sd,gd.Float=Ld,gd.FloatBE=Od,gd.Double=Ud,gd.DoubleBE=Cd,gd.Sequence=Nd,gd.Structure=zd,gd.UnionDiscriminator=Dd,gd.UnionLayoutDiscriminator=jd,gd.Union=Wd,gd.VariantLayout=Fd,gd.BitStructure=Vd,gd.BitField=qd,gd.Boolean=Hd,gd.Blob=$d,gd.CString=Gd,gd.UTF8=Zd,gd.Constant=Yd,gd.greedy=(t,e)=>new vd(t,e),gd.offset=(t,e,r)=>new _d(t,e,r),gd.u8=t=>new kd(1,t),gd.u16=t=>new kd(2,t),gd.u24=t=>new kd(3,t),gd.u32=t=>new kd(4,t),gd.u40=t=>new kd(5,t),gd.u48=t=>new kd(6,t),gd.nu64=t=>new Md(t),gd.u16be=t=>new Ed(2,t),gd.u24be=t=>new Ed(3,t),gd.u32be=t=>new Ed(4,t),gd.u40be=t=>new Ed(5,t),gd.u48be=t=>new Ed(6,t),gd.nu64be=t=>new Rd(t),gd.s8=t=>new xd(1,t),gd.s16=t=>new xd(2,t),gd.s24=t=>new xd(3,t),gd.s32=t=>new xd(4,t),gd.s40=t=>new xd(5,t),gd.s48=t=>new xd(6,t),gd.ns64=t=>new Pd(t),gd.s16be=t=>new Sd(2,t),gd.s24be=t=>new Sd(3,t),gd.s32be=t=>new Sd(4,t),gd.s40be=t=>new Sd(5,t),gd.s48be=t=>new Sd(6,t),gd.ns64be=t=>new Td(t),gd.f32=t=>new Ld(t),gd.f32be=t=>new Od(t),gd.f64=t=>new Ud(t),gd.f64be=t=>new Cd(t),gd.struct=(t,e,r)=>new zd(t,e,r),gd.bits=(t,e,r)=>new Vd(t,e,r),gd.seq=(t,e,r)=>new Nd(t,e,r),gd.union=(t,e,r)=>new Wd(t,e,r),gd.unionLayoutDiscriminator=(t,e)=>new jd(t,e),gd.blob=(t,e)=>new $d(t,e),gd.cstr=t=>new Gd(t),gd.utf8=(t,e)=>new Zd(t,e),gd.const=(t,e)=>new Yd(t,e),function(e){var r=t&&t.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.map=e.array=e.rustEnum=e.str=e.vecU8=e.tagged=e.vec=e.bool=e.option=e.publicKey=e.i256=e.u256=e.i128=e.u128=e.i64=e.u64=e.struct=e.f64=e.f32=e.i32=e.u32=e.i16=e.u16=e.i8=e.u8=void 0;const n=gd,i=$f,o=r(re);var s=gd;Object.defineProperty(e,"u8",{enumerable:!0,get:function(){return s.u8}}),Object.defineProperty(e,"i8",{enumerable:!0,get:function(){return s.s8}}),Object.defineProperty(e,"u16",{enumerable:!0,get:function(){return s.u16}}),Object.defineProperty(e,"i16",{enumerable:!0,get:function(){return s.s16}}),Object.defineProperty(e,"u32",{enumerable:!0,get:function(){return s.u32}}),Object.defineProperty(e,"i32",{enumerable:!0,get:function(){return s.s32}}),Object.defineProperty(e,"f32",{enumerable:!0,get:function(){return s.f32}}),Object.defineProperty(e,"f64",{enumerable:!0,get:function(){return s.f64}}),Object.defineProperty(e,"struct",{enumerable:!0,get:function(){return s.struct}});class a extends n.Layout{constructor(t,e,r){super(t,r),this.blob=(0,n.blob)(t),this.signed=e}decode(t,e=0){const r=new o.default(this.blob.decode(t,e),10,"le");return this.signed?r.fromTwos(8*this.span).clone():r}encode(t,e,r=0){return this.signed&&(t=t.toTwos(8*this.span)),this.blob.encode(t.toArrayLike(Buffer,"le",this.span),e,r)}}function u(t){return new a(8,!1,t)}e.u64=u,e.i64=function(t){return new a(8,!0,t)},e.u128=function(t){return new a(16,!1,t)},e.i128=function(t){return new a(16,!0,t)},e.u256=function(t){return new a(32,!1,t)},e.i256=function(t){return new a(32,!0,t)};class c extends n.Layout{constructor(t,e,r,n){super(t.span,n),this.layout=t,this.decoder=e,this.encoder=r}decode(t,e){return this.decoder(this.layout.decode(t,e))}encode(t,e,r){return this.layout.encode(this.encoder(t),e,r)}getSpan(t,e){return this.layout.getSpan(t,e)}}e.publicKey=function(t){return new c((0,n.blob)(32),(t=>new i.PublicKey(t)),(t=>t.toBuffer()),t)};class h extends n.Layout{constructor(t,e){super(-1,e),this.layout=t,this.discriminator=(0,n.u8)()}encode(t,e,r=0){return null==t?this.discriminator.encode(0,e,r):(this.discriminator.encode(1,e,r),this.layout.encode(t,e,r+1)+1)}decode(t,e=0){const r=this.discriminator.decode(t,e);if(0===r)return null;if(1===r)return this.layout.decode(t,e+1);throw new Error("Invalid option "+this.property)}getSpan(t,e=0){const r=this.discriminator.decode(t,e);if(0===r)return 1;if(1===r)return this.layout.getSpan(t,e+1)+1;throw new Error("Invalid option "+this.property)}}function l(t){if(0===t)return!1;if(1===t)return!0;throw new Error("Invalid bool: "+t)}function f(t){return t?1:0}function d(t){const e=(0,n.u32)("length"),r=(0,n.struct)([e,(0,n.blob)((0,n.offset)(e,-e.span),"data")]);return new c(r,(({data:t})=>t),(t=>({data:t})),t)}e.option=function(t,e){return new h(t,e)},e.bool=function(t){return new c((0,n.u8)(),l,f,t)},e.vec=function(t,e){const r=(0,n.u32)("length"),i=(0,n.struct)([r,(0,n.seq)(t,(0,n.offset)(r,-r.span),"values")]);return new c(i,(({values:t})=>t),(t=>({values:t})),e)},e.tagged=function(t,e,r){const i=(0,n.struct)([u("tag"),e.replicate("data")]);return new c(i,(function({tag:e,data:r}){if(!e.eq(t))throw new Error("Invalid tag, expected: "+t.toString("hex")+", got: "+e.toString("hex"));return r}),(e=>({tag:t,data:e})),r)},e.vecU8=d,e.str=function(t){return new c(d(),(t=>t.toString("utf-8")),(t=>Buffer.from(t,"utf-8")),t)},e.rustEnum=function(t,e,r){const i=(0,n.union)(null!=r?r:(0,n.u8)(),e);return t.forEach(((t,e)=>i.addVariant(e,t,t.property))),i},e.array=function(t,e,r){const i=(0,n.struct)([(0,n.seq)(t,e,"values")]);return new c(i,(({values:t})=>t),(t=>({values:t})),r)};class p extends n.Layout{constructor(t,e,r){super(t.span+e.span,r),this.keyLayout=t,this.valueLayout=e}decode(t,e){e=e||0;return[this.keyLayout.decode(t,e),this.valueLayout.decode(t,e+this.keyLayout.getSpan(t,e))]}encode(t,e,r){r=r||0;const n=this.keyLayout.encode(t[0],e,r);return n+this.valueLayout.encode(t[1],e,r+n)}getSpan(t,e){return this.keyLayout.getSpan(t,e)+this.valueLayout.getSpan(t,e)}}e.map=function(t,e,r){const i=(0,n.u32)("length"),o=(0,n.struct)([i,(0,n.seq)(new p(t,e),(0,n.offset)(i,-i.span),"values")]);return new c(o,(({values:t})=>new Map(t)),(t=>({values:Array.from(t.entries())})),r)}}(yd);function Jd(t){let e=t.length;for(;--e>=0;)t[e]=0}const Xd=256,Qd=286,tp=30,ep=15,rp=new Uint8Array([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]),np=new Uint8Array([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]),ip=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),op=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),sp=new Array(576);Jd(sp);const ap=new Array(60);Jd(ap);const up=new Array(512);Jd(up);const cp=new Array(256);Jd(cp);const hp=new Array(29);Jd(hp);const lp=new Array(tp);function fp(t,e,r,n,i){this.static_tree=t,this.extra_bits=e,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=t&&t.length}let dp,pp,yp;function gp(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}Jd(lp);const mp=t=>t<256?up[t]:up[256+(t>>>7)],wp=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},bp=(t,e,r)=>{t.bi_valid>16-r?(t.bi_buf|=e<<t.bi_valid&65535,wp(t,t.bi_buf),t.bi_buf=e>>16-t.bi_valid,t.bi_valid+=r-16):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=r)},vp=(t,e,r)=>{bp(t,r[2*e],r[2*e+1])},_p=(t,e)=>{let r=0;do{r|=1&t,t>>>=1,r<<=1}while(--e>0);return r>>>1},kp=(t,e,r)=>{const n=new Array(16);let i,o,s=0;for(i=1;i<=ep;i++)s=s+r[i-1]<<1,n[i]=s;for(o=0;o<=e;o++){let e=t[2*o+1];0!==e&&(t[2*o]=_p(n[e]++,e))}},Ep=t=>{let e;for(e=0;e<Qd;e++)t.dyn_ltree[2*e]=0;for(e=0;e<tp;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.sym_next=t.matches=0},xp=t=>{t.bi_valid>8?wp(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},Sp=(t,e,r,n)=>{const i=2*e,o=2*r;return t[i]<t[o]||t[i]===t[o]&&n[e]<=n[r]},Ap=(t,e,r)=>{const n=t.heap[r];let i=r<<1;for(;i<=t.heap_len&&(i<t.heap_len&&Sp(e,t.heap[i+1],t.heap[i],t.depth)&&i++,!Sp(e,n,t.heap[i],t.depth));)t.heap[r]=t.heap[i],r=i,i<<=1;t.heap[r]=n},Ip=(t,e,r)=>{let n,i,o,s,a=0;if(0!==t.sym_next)do{n=255&t.pending_buf[t.sym_buf+a++],n+=(255&t.pending_buf[t.sym_buf+a++])<<8,i=t.pending_buf[t.sym_buf+a++],0===n?vp(t,i,e):(o=cp[i],vp(t,o+Xd+1,e),s=rp[o],0!==s&&(i-=hp[o],bp(t,i,s)),n--,o=mp(n),vp(t,o,r),s=np[o],0!==s&&(n-=lp[o],bp(t,n,s)))}while(a<t.sym_next);vp(t,256,e)},Bp=(t,e)=>{const r=e.dyn_tree,n=e.stat_desc.static_tree,i=e.stat_desc.has_stree,o=e.stat_desc.elems;let s,a,u,c=-1;for(t.heap_len=0,t.heap_max=573,s=0;s<o;s++)0!==r[2*s]?(t.heap[++t.heap_len]=c=s,t.depth[s]=0):r[2*s+1]=0;for(;t.heap_len<2;)u=t.heap[++t.heap_len]=c<2?++c:0,r[2*u]=1,t.depth[u]=0,t.opt_len--,i&&(t.static_len-=n[2*u+1]);for(e.max_code=c,s=t.heap_len>>1;s>=1;s--)Ap(t,r,s);u=o;do{s=t.heap[1],t.heap[1]=t.heap[t.heap_len--],Ap(t,r,1),a=t.heap[1],t.heap[--t.heap_max]=s,t.heap[--t.heap_max]=a,r[2*u]=r[2*s]+r[2*a],t.depth[u]=(t.depth[s]>=t.depth[a]?t.depth[s]:t.depth[a])+1,r[2*s+1]=r[2*a+1]=u,t.heap[1]=u++,Ap(t,r,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],((t,e)=>{const r=e.dyn_tree,n=e.max_code,i=e.stat_desc.static_tree,o=e.stat_desc.has_stree,s=e.stat_desc.extra_bits,a=e.stat_desc.extra_base,u=e.stat_desc.max_length;let c,h,l,f,d,p,y=0;for(f=0;f<=ep;f++)t.bl_count[f]=0;for(r[2*t.heap[t.heap_max]+1]=0,c=t.heap_max+1;c<573;c++)h=t.heap[c],f=r[2*r[2*h+1]+1]+1,f>u&&(f=u,y++),r[2*h+1]=f,h>n||(t.bl_count[f]++,d=0,h>=a&&(d=s[h-a]),p=r[2*h],t.opt_len+=p*(f+d),o&&(t.static_len+=p*(i[2*h+1]+d)));if(0!==y){do{for(f=u-1;0===t.bl_count[f];)f--;t.bl_count[f]--,t.bl_count[f+1]+=2,t.bl_count[u]--,y-=2}while(y>0);for(f=u;0!==f;f--)for(h=t.bl_count[f];0!==h;)l=t.heap[--c],l>n||(r[2*l+1]!==f&&(t.opt_len+=(f-r[2*l+1])*r[2*l],r[2*l+1]=f),h--)}})(t,e),kp(r,c,t.bl_count)},Mp=(t,e,r)=>{let n,i,o=-1,s=e[1],a=0,u=7,c=4;for(0===s&&(u=138,c=3),e[2*(r+1)+1]=65535,n=0;n<=r;n++)i=s,s=e[2*(n+1)+1],++a<u&&i===s||(a<c?t.bl_tree[2*i]+=a:0!==i?(i!==o&&t.bl_tree[2*i]++,t.bl_tree[32]++):a<=10?t.bl_tree[34]++:t.bl_tree[36]++,a=0,o=i,0===s?(u=138,c=3):i===s?(u=6,c=3):(u=7,c=4))},Rp=(t,e,r)=>{let n,i,o=-1,s=e[1],a=0,u=7,c=4;for(0===s&&(u=138,c=3),n=0;n<=r;n++)if(i=s,s=e[2*(n+1)+1],!(++a<u&&i===s)){if(a<c)do{vp(t,i,t.bl_tree)}while(0!=--a);else 0!==i?(i!==o&&(vp(t,i,t.bl_tree),a--),vp(t,16,t.bl_tree),bp(t,a-3,2)):a<=10?(vp(t,17,t.bl_tree),bp(t,a-3,3)):(vp(t,18,t.bl_tree),bp(t,a-11,7));a=0,o=i,0===s?(u=138,c=3):i===s?(u=6,c=3):(u=7,c=4)}};let Pp=!1;const Tp=(t,e,r,n)=>{bp(t,0+(n?1:0),3),xp(t),wp(t,r),wp(t,~r),r&&t.pending_buf.set(t.window.subarray(e,e+r),t.pending),t.pending+=r};var Lp=t=>{Pp||((()=>{let t,e,r,n,i;const o=new Array(16);for(r=0,n=0;n<28;n++)for(hp[n]=r,t=0;t<1<<rp[n];t++)cp[r++]=n;for(cp[r-1]=n,i=0,n=0;n<16;n++)for(lp[n]=i,t=0;t<1<<np[n];t++)up[i++]=n;for(i>>=7;n<tp;n++)for(lp[n]=i<<7,t=0;t<1<<np[n]-7;t++)up[256+i++]=n;for(e=0;e<=ep;e++)o[e]=0;for(t=0;t<=143;)sp[2*t+1]=8,t++,o[8]++;for(;t<=255;)sp[2*t+1]=9,t++,o[9]++;for(;t<=279;)sp[2*t+1]=7,t++,o[7]++;for(;t<=287;)sp[2*t+1]=8,t++,o[8]++;for(kp(sp,287,o),t=0;t<tp;t++)ap[2*t+1]=5,ap[2*t]=_p(t,5);dp=new fp(sp,rp,257,Qd,ep),pp=new fp(ap,np,0,tp,ep),yp=new fp(new Array(0),ip,0,19,7)})(),Pp=!0),t.l_desc=new gp(t.dyn_ltree,dp),t.d_desc=new gp(t.dyn_dtree,pp),t.bl_desc=new gp(t.bl_tree,yp),t.bi_buf=0,t.bi_valid=0,Ep(t)},Op=(t,e,r,n)=>{let i,o,s=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=(t=>{let e,r=4093624447;for(e=0;e<=31;e++,r>>>=1)if(1&r&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<Xd;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0})(t)),Bp(t,t.l_desc),Bp(t,t.d_desc),s=(t=>{let e;for(Mp(t,t.dyn_ltree,t.l_desc.max_code),Mp(t,t.dyn_dtree,t.d_desc.max_code),Bp(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*op[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e})(t),i=t.opt_len+3+7>>>3,o=t.static_len+3+7>>>3,o<=i&&(i=o)):i=o=r+5,r+4<=i&&-1!==e?Tp(t,e,r,n):4===t.strategy||o===i?(bp(t,2+(n?1:0),3),Ip(t,sp,ap)):(bp(t,4+(n?1:0),3),((t,e,r,n)=>{let i;for(bp(t,e-257,5),bp(t,r-1,5),bp(t,n-4,4),i=0;i<n;i++)bp(t,t.bl_tree[2*op[i]+1],3);Rp(t,t.dyn_ltree,e-1),Rp(t,t.dyn_dtree,r-1)})(t,t.l_desc.max_code+1,t.d_desc.max_code+1,s+1),Ip(t,t.dyn_ltree,t.dyn_dtree)),Ep(t),n&&xp(t)},Up=(t,e,r)=>(t.pending_buf[t.sym_buf+t.sym_next++]=e,t.pending_buf[t.sym_buf+t.sym_next++]=e>>8,t.pending_buf[t.sym_buf+t.sym_next++]=r,0===e?t.dyn_ltree[2*r]++:(t.matches++,e--,t.dyn_ltree[2*(cp[r]+Xd+1)]++,t.dyn_dtree[2*mp(e)]++),t.sym_next===t.sym_end),Cp=t=>{bp(t,2,3),vp(t,256,sp),(t=>{16===t.bi_valid?(wp(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)})(t)},Np={_tr_init:Lp,_tr_stored_block:Tp,_tr_flush_block:Op,_tr_tally:Up,_tr_align:Cp};var zp=(t,e,r,n)=>{let i=65535&t|0,o=t>>>16&65535|0,s=0;for(;0!==r;){s=r>2e3?2e3:r,r-=s;do{i=i+e[n++]|0,o=o+i|0}while(--s);i%=65521,o%=65521}return i|o<<16|0};const Dp=new Uint32Array((()=>{let t,e=[];for(var r=0;r<256;r++){t=r;for(var n=0;n<8;n++)t=1&t?3988292384^t>>>1:t>>>1;e[r]=t}return e})());var jp=(t,e,r,n)=>{const i=Dp,o=n+r;t^=-1;for(let r=n;r<o;r++)t=t>>>8^i[255&(t^e[r])];return-1^t},Wp={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"},Fp={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:Kp,_tr_stored_block:Vp,_tr_flush_block:qp,_tr_tally:Hp,_tr_align:$p}=Np,{Z_NO_FLUSH:Gp,Z_PARTIAL_FLUSH:Zp,Z_FULL_FLUSH:Yp,Z_FINISH:Jp,Z_BLOCK:Xp,Z_OK:Qp,Z_STREAM_END:ty,Z_STREAM_ERROR:ey,Z_DATA_ERROR:ry,Z_BUF_ERROR:ny,Z_DEFAULT_COMPRESSION:iy,Z_FILTERED:oy,Z_HUFFMAN_ONLY:sy,Z_RLE:ay,Z_FIXED:uy,Z_DEFAULT_STRATEGY:cy,Z_UNKNOWN:hy,Z_DEFLATED:ly}=Fp,fy=258,dy=262,py=42,yy=113,gy=666,my=(t,e)=>(t.msg=Wp[e],e),wy=t=>2*t-(t>4?9:0),by=t=>{let e=t.length;for(;--e>=0;)t[e]=0},vy=t=>{let e,r,n,i=t.w_size;e=t.hash_size,n=e;do{r=t.head[--n],t.head[n]=r>=i?r-i:0}while(--e);e=i,n=e;do{r=t.prev[--n],t.prev[n]=r>=i?r-i:0}while(--e)};let _y=(t,e,r)=>(e<<t.hash_shift^r)&t.hash_mask;const ky=t=>{const e=t.state;let r=e.pending;r>t.avail_out&&(r=t.avail_out),0!==r&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+r),t.next_out),t.next_out+=r,e.pending_out+=r,t.total_out+=r,t.avail_out-=r,e.pending-=r,0===e.pending&&(e.pending_out=0))},Ey=(t,e)=>{qp(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,ky(t.strm)},xy=(t,e)=>{t.pending_buf[t.pending++]=e},Sy=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},Ay=(t,e,r,n)=>{let i=t.avail_in;return i>n&&(i=n),0===i?0:(t.avail_in-=i,e.set(t.input.subarray(t.next_in,t.next_in+i),r),1===t.state.wrap?t.adler=zp(t.adler,e,i,r):2===t.state.wrap&&(t.adler=jp(t.adler,e,i,r)),t.next_in+=i,t.total_in+=i,i)},Iy=(t,e)=>{let r,n,i=t.max_chain_length,o=t.strstart,s=t.prev_length,a=t.nice_match;const u=t.strstart>t.w_size-dy?t.strstart-(t.w_size-dy):0,c=t.window,h=t.w_mask,l=t.prev,f=t.strstart+fy;let d=c[o+s-1],p=c[o+s];t.prev_length>=t.good_match&&(i>>=2),a>t.lookahead&&(a=t.lookahead);do{if(r=e,c[r+s]===p&&c[r+s-1]===d&&c[r]===c[o]&&c[++r]===c[o+1]){o+=2,r++;do{}while(c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&o<f);if(n=fy-(f-o),o=f-fy,n>s){if(t.match_start=e,s=n,n>=a)break;d=c[o+s-1],p=c[o+s]}}}while((e=l[e&h])>u&&0!=--i);return s<=t.lookahead?s:t.lookahead},By=t=>{const e=t.w_size;let r,n,i;do{if(n=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-dy)&&(t.window.set(t.window.subarray(e,e+e-n),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,t.insert>t.strstart&&(t.insert=t.strstart),vy(t),n+=e),0===t.strm.avail_in)break;if(r=Ay(t.strm,t.window,t.strstart+t.lookahead,n),t.lookahead+=r,t.lookahead+t.insert>=3)for(i=t.strstart-t.insert,t.ins_h=t.window[i],t.ins_h=_y(t,t.ins_h,t.window[i+1]);t.insert&&(t.ins_h=_y(t,t.ins_h,t.window[i+3-1]),t.prev[i&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=i,i++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<dy&&0!==t.strm.avail_in)},My=(t,e)=>{let r,n,i,o=t.pending_buf_size-5>t.w_size?t.w_size:t.pending_buf_size-5,s=0,a=t.strm.avail_in;do{if(r=65535,i=t.bi_valid+42>>3,t.strm.avail_out<i)break;if(i=t.strm.avail_out-i,n=t.strstart-t.block_start,r>n+t.strm.avail_in&&(r=n+t.strm.avail_in),r>i&&(r=i),r<o&&(0===r&&e!==Jp||e===Gp||r!==n+t.strm.avail_in))break;s=e===Jp&&r===n+t.strm.avail_in?1:0,Vp(t,0,0,s),t.pending_buf[t.pending-4]=r,t.pending_buf[t.pending-3]=r>>8,t.pending_buf[t.pending-2]=~r,t.pending_buf[t.pending-1]=~r>>8,ky(t.strm),n&&(n>r&&(n=r),t.strm.output.set(t.window.subarray(t.block_start,t.block_start+n),t.strm.next_out),t.strm.next_out+=n,t.strm.avail_out-=n,t.strm.total_out+=n,t.block_start+=n,r-=n),r&&(Ay(t.strm,t.strm.output,t.strm.next_out,r),t.strm.next_out+=r,t.strm.avail_out-=r,t.strm.total_out+=r)}while(0===s);return a-=t.strm.avail_in,a&&(a>=t.w_size?(t.matches=2,t.window.set(t.strm.input.subarray(t.strm.next_in-t.w_size,t.strm.next_in),0),t.strstart=t.w_size,t.insert=t.strstart):(t.window_size-t.strstart<=a&&(t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,t.insert>t.strstart&&(t.insert=t.strstart)),t.window.set(t.strm.input.subarray(t.strm.next_in-a,t.strm.next_in),t.strstart),t.strstart+=a,t.insert+=a>t.w_size-t.insert?t.w_size-t.insert:a),t.block_start=t.strstart),t.high_water<t.strstart&&(t.high_water=t.strstart),s?4:e!==Gp&&e!==Jp&&0===t.strm.avail_in&&t.strstart===t.block_start?2:(i=t.window_size-t.strstart,t.strm.avail_in>i&&t.block_start>=t.w_size&&(t.block_start-=t.w_size,t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,i+=t.w_size,t.insert>t.strstart&&(t.insert=t.strstart)),i>t.strm.avail_in&&(i=t.strm.avail_in),i&&(Ay(t.strm,t.window,t.strstart,i),t.strstart+=i,t.insert+=i>t.w_size-t.insert?t.w_size-t.insert:i),t.high_water<t.strstart&&(t.high_water=t.strstart),i=t.bi_valid+42>>3,i=t.pending_buf_size-i>65535?65535:t.pending_buf_size-i,o=i>t.w_size?t.w_size:i,n=t.strstart-t.block_start,(n>=o||(n||e===Jp)&&e!==Gp&&0===t.strm.avail_in&&n<=i)&&(r=n>i?i:n,s=e===Jp&&0===t.strm.avail_in&&r===n?1:0,Vp(t,t.block_start,r,s),t.block_start+=r,ky(t.strm)),s?3:1)},Ry=(t,e)=>{let r,n;for(;;){if(t.lookahead<dy){if(By(t),t.lookahead<dy&&e===Gp)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=_y(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==r&&t.strstart-r<=t.w_size-dy&&(t.match_length=Iy(t,r)),t.match_length>=3)if(n=Hp(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=_y(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=_y(t,t.ins_h,t.window[t.strstart+1]);else n=Hp(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(n&&(Ey(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===Jp?(Ey(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(Ey(t,!1),0===t.strm.avail_out)?1:2},Py=(t,e)=>{let r,n,i;for(;;){if(t.lookahead<dy){if(By(t),t.lookahead<dy&&e===Gp)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=_y(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==r&&t.prev_length<t.max_lazy_match&&t.strstart-r<=t.w_size-dy&&(t.match_length=Iy(t,r),t.match_length<=5&&(t.strategy===oy||3===t.match_length&&t.strstart-t.match_start>4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){i=t.strstart+t.lookahead-3,n=Hp(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=i&&(t.ins_h=_y(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!=--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,n&&(Ey(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if(n=Hp(t,0,t.window[t.strstart-1]),n&&Ey(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(n=Hp(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===Jp?(Ey(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(Ey(t,!1),0===t.strm.avail_out)?1:2};function Ty(t,e,r,n,i){this.good_length=t,this.max_lazy=e,this.nice_length=r,this.max_chain=n,this.func=i}const Ly=[new Ty(0,0,0,0,My),new Ty(4,4,8,4,Ry),new Ty(4,5,16,8,Ry),new Ty(4,6,32,32,Ry),new Ty(4,4,16,16,Py),new Ty(8,16,32,32,Py),new Ty(8,16,128,128,Py),new Ty(8,32,128,256,Py),new Ty(32,128,258,1024,Py),new Ty(32,258,258,4096,Py)];function Oy(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=ly,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),by(this.dyn_ltree),by(this.dyn_dtree),by(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),by(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),by(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const Uy=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.status!==py&&57!==e.status&&69!==e.status&&73!==e.status&&91!==e.status&&103!==e.status&&e.status!==yy&&e.status!==gy?1:0},Cy=t=>{if(Uy(t))return my(t,ey);t.total_in=t.total_out=0,t.data_type=hy;const e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=2===e.wrap?57:e.wrap?py:yy,t.adler=2===e.wrap?0:1,e.last_flush=-2,Kp(e),Qp},Ny=t=>{const e=Cy(t);return e===Qp&&(t=>{t.window_size=2*t.w_size,by(t.head),t.max_lazy_match=Ly[t.level].max_lazy,t.good_match=Ly[t.level].good_length,t.nice_match=Ly[t.level].nice_length,t.max_chain_length=Ly[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=2,t.match_available=0,t.ins_h=0})(t.state),e},zy=(t,e,r,n,i,o)=>{if(!t)return ey;let s=1;if(e===iy&&(e=6),n<0?(s=0,n=-n):n>15&&(s=2,n-=16),i<1||i>9||r!==ly||n<8||n>15||e<0||e>9||o<0||o>uy||8===n&&1!==s)return my(t,ey);8===n&&(n=9);const a=new Oy;return t.state=a,a.strm=t,a.status=py,a.wrap=s,a.gzhead=null,a.w_bits=n,a.w_size=1<<a.w_bits,a.w_mask=a.w_size-1,a.hash_bits=i+7,a.hash_size=1<<a.hash_bits,a.hash_mask=a.hash_size-1,a.hash_shift=~~((a.hash_bits+3-1)/3),a.window=new Uint8Array(2*a.w_size),a.head=new Uint16Array(a.hash_size),a.prev=new Uint16Array(a.w_size),a.lit_bufsize=1<<i+6,a.pending_buf_size=4*a.lit_bufsize,a.pending_buf=new Uint8Array(a.pending_buf_size),a.sym_buf=a.lit_bufsize,a.sym_end=3*(a.lit_bufsize-1),a.level=e,a.strategy=o,a.method=r,Ny(t)};var Dy=(t,e)=>{if(Uy(t)||e>Xp||e<0)return t?my(t,ey):ey;const r=t.state;if(!t.output||0!==t.avail_in&&!t.input||r.status===gy&&e!==Jp)return my(t,0===t.avail_out?ny:ey);const n=r.last_flush;if(r.last_flush=e,0!==r.pending){if(ky(t),0===t.avail_out)return r.last_flush=-1,Qp}else if(0===t.avail_in&&wy(e)<=wy(n)&&e!==Jp)return my(t,ny);if(r.status===gy&&0!==t.avail_in)return my(t,ny);if(r.status===py&&0===r.wrap&&(r.status=yy),r.status===py){let e=ly+(r.w_bits-8<<4)<<8,n=-1;if(n=r.strategy>=sy||r.level<2?0:r.level<6?1:6===r.level?2:3,e|=n<<6,0!==r.strstart&&(e|=32),e+=31-e%31,Sy(r,e),0!==r.strstart&&(Sy(r,t.adler>>>16),Sy(r,65535&t.adler)),t.adler=1,r.status=yy,ky(t),0!==r.pending)return r.last_flush=-1,Qp}if(57===r.status)if(t.adler=0,xy(r,31),xy(r,139),xy(r,8),r.gzhead)xy(r,(r.gzhead.text?1:0)+(r.gzhead.hcrc?2:0)+(r.gzhead.extra?4:0)+(r.gzhead.name?8:0)+(r.gzhead.comment?16:0)),xy(r,255&r.gzhead.time),xy(r,r.gzhead.time>>8&255),xy(r,r.gzhead.time>>16&255),xy(r,r.gzhead.time>>24&255),xy(r,9===r.level?2:r.strategy>=sy||r.level<2?4:0),xy(r,255&r.gzhead.os),r.gzhead.extra&&r.gzhead.extra.length&&(xy(r,255&r.gzhead.extra.length),xy(r,r.gzhead.extra.length>>8&255)),r.gzhead.hcrc&&(t.adler=jp(t.adler,r.pending_buf,r.pending,0)),r.gzindex=0,r.status=69;else if(xy(r,0),xy(r,0),xy(r,0),xy(r,0),xy(r,0),xy(r,9===r.level?2:r.strategy>=sy||r.level<2?4:0),xy(r,3),r.status=yy,ky(t),0!==r.pending)return r.last_flush=-1,Qp;if(69===r.status){if(r.gzhead.extra){let e=r.pending,n=(65535&r.gzhead.extra.length)-r.gzindex;for(;r.pending+n>r.pending_buf_size;){let i=r.pending_buf_size-r.pending;if(r.pending_buf.set(r.gzhead.extra.subarray(r.gzindex,r.gzindex+i),r.pending),r.pending=r.pending_buf_size,r.gzhead.hcrc&&r.pending>e&&(t.adler=jp(t.adler,r.pending_buf,r.pending-e,e)),r.gzindex+=i,ky(t),0!==r.pending)return r.last_flush=-1,Qp;e=0,n-=i}let i=new Uint8Array(r.gzhead.extra);r.pending_buf.set(i.subarray(r.gzindex,r.gzindex+n),r.pending),r.pending+=n,r.gzhead.hcrc&&r.pending>e&&(t.adler=jp(t.adler,r.pending_buf,r.pending-e,e)),r.gzindex=0}r.status=73}if(73===r.status){if(r.gzhead.name){let e,n=r.pending;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>n&&(t.adler=jp(t.adler,r.pending_buf,r.pending-n,n)),ky(t),0!==r.pending)return r.last_flush=-1,Qp;n=0}e=r.gzindex<r.gzhead.name.length?255&r.gzhead.name.charCodeAt(r.gzindex++):0,xy(r,e)}while(0!==e);r.gzhead.hcrc&&r.pending>n&&(t.adler=jp(t.adler,r.pending_buf,r.pending-n,n)),r.gzindex=0}r.status=91}if(91===r.status){if(r.gzhead.comment){let e,n=r.pending;do{if(r.pending===r.pending_buf_size){if(r.gzhead.hcrc&&r.pending>n&&(t.adler=jp(t.adler,r.pending_buf,r.pending-n,n)),ky(t),0!==r.pending)return r.last_flush=-1,Qp;n=0}e=r.gzindex<r.gzhead.comment.length?255&r.gzhead.comment.charCodeAt(r.gzindex++):0,xy(r,e)}while(0!==e);r.gzhead.hcrc&&r.pending>n&&(t.adler=jp(t.adler,r.pending_buf,r.pending-n,n))}r.status=103}if(103===r.status){if(r.gzhead.hcrc){if(r.pending+2>r.pending_buf_size&&(ky(t),0!==r.pending))return r.last_flush=-1,Qp;xy(r,255&t.adler),xy(r,t.adler>>8&255),t.adler=0}if(r.status=yy,ky(t),0!==r.pending)return r.last_flush=-1,Qp}if(0!==t.avail_in||0!==r.lookahead||e!==Gp&&r.status!==gy){let n=0===r.level?My(r,e):r.strategy===sy?((t,e)=>{let r;for(;;){if(0===t.lookahead&&(By(t),0===t.lookahead)){if(e===Gp)return 1;break}if(t.match_length=0,r=Hp(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,r&&(Ey(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===Jp?(Ey(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(Ey(t,!1),0===t.strm.avail_out)?1:2})(r,e):r.strategy===ay?((t,e)=>{let r,n,i,o;const s=t.window;for(;;){if(t.lookahead<=fy){if(By(t),t.lookahead<=fy&&e===Gp)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(i=t.strstart-1,n=s[i],n===s[++i]&&n===s[++i]&&n===s[++i])){o=t.strstart+fy;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]&&i<o);t.match_length=fy-(o-i),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(r=Hp(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(r=Hp(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),r&&(Ey(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===Jp?(Ey(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(Ey(t,!1),0===t.strm.avail_out)?1:2})(r,e):Ly[r.level].func(r,e);if(3!==n&&4!==n||(r.status=gy),1===n||3===n)return 0===t.avail_out&&(r.last_flush=-1),Qp;if(2===n&&(e===Zp?$p(r):e!==Xp&&(Vp(r,0,0,!1),e===Yp&&(by(r.head),0===r.lookahead&&(r.strstart=0,r.block_start=0,r.insert=0))),ky(t),0===t.avail_out))return r.last_flush=-1,Qp}return e!==Jp?Qp:r.wrap<=0?ty:(2===r.wrap?(xy(r,255&t.adler),xy(r,t.adler>>8&255),xy(r,t.adler>>16&255),xy(r,t.adler>>24&255),xy(r,255&t.total_in),xy(r,t.total_in>>8&255),xy(r,t.total_in>>16&255),xy(r,t.total_in>>24&255)):(Sy(r,t.adler>>>16),Sy(r,65535&t.adler)),ky(t),r.wrap>0&&(r.wrap=-r.wrap),0!==r.pending?Qp:ty)},jy=(t,e)=>{let r=e.length;if(Uy(t))return ey;const n=t.state,i=n.wrap;if(2===i||1===i&&n.status!==py||n.lookahead)return ey;if(1===i&&(t.adler=zp(t.adler,e,r,0)),n.wrap=0,r>=n.w_size){0===i&&(by(n.head),n.strstart=0,n.block_start=0,n.insert=0);let t=new Uint8Array(n.w_size);t.set(e.subarray(r-n.w_size,r),0),e=t,r=n.w_size}const o=t.avail_in,s=t.next_in,a=t.input;for(t.avail_in=r,t.next_in=0,t.input=e,By(n);n.lookahead>=3;){let t=n.strstart,e=n.lookahead-2;do{n.ins_h=_y(n,n.ins_h,n.window[t+3-1]),n.prev[t&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=t,t++}while(--e);n.strstart=t,n.lookahead=2,By(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,t.next_in=s,t.input=a,t.avail_in=o,n.wrap=i,Qp},Wy={deflateInit:(t,e)=>zy(t,e,ly,15,8,cy),deflateInit2:zy,deflateReset:Ny,deflateResetKeep:Cy,deflateSetHeader:(t,e)=>Uy(t)||2!==t.state.wrap?ey:(t.state.gzhead=e,Qp),deflate:Dy,deflateEnd:t=>{if(Uy(t))return ey;const e=t.state.status;return t.state=null,e===yy?my(t,ry):Qp},deflateSetDictionary:jy,deflateInfo:"pako deflate (from Nodeca project)"};const Fy=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var Ky={assign:function(t){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const r=e.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(const e in r)Fy(r,e)&&(t[e]=r[e])}}return t},flattenChunks:t=>{let e=0;for(let r=0,n=t.length;r<n;r++)e+=t[r].length;const r=new Uint8Array(e);for(let e=0,n=0,i=t.length;e<i;e++){let i=t[e];r.set(i,n),n+=i.length}return r}};let Vy=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){Vy=!1}const qy=new Uint8Array(256);for(let t=0;t<256;t++)qy[t]=t>=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;qy[254]=qy[254]=1;var Hy={string2buf:t=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);let e,r,n,i,o,s=t.length,a=0;for(i=0;i<s;i++)r=t.charCodeAt(i),55296==(64512&r)&&i+1<s&&(n=t.charCodeAt(i+1),56320==(64512&n)&&(r=65536+(r-55296<<10)+(n-56320),i++)),a+=r<128?1:r<2048?2:r<65536?3:4;for(e=new Uint8Array(a),o=0,i=0;o<a;i++)r=t.charCodeAt(i),55296==(64512&r)&&i+1<s&&(n=t.charCodeAt(i+1),56320==(64512&n)&&(r=65536+(r-55296<<10)+(n-56320),i++)),r<128?e[o++]=r:r<2048?(e[o++]=192|r>>>6,e[o++]=128|63&r):r<65536?(e[o++]=224|r>>>12,e[o++]=128|r>>>6&63,e[o++]=128|63&r):(e[o++]=240|r>>>18,e[o++]=128|r>>>12&63,e[o++]=128|r>>>6&63,e[o++]=128|63&r);return e},buf2string:(t,e)=>{const r=e||t.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(t.subarray(0,e));let n,i;const o=new Array(2*r);for(i=0,n=0;n<r;){let e=t[n++];if(e<128){o[i++]=e;continue}let s=qy[e];if(s>4)o[i++]=65533,n+=s-1;else{for(e&=2===s?31:3===s?15:7;s>1&&n<r;)e=e<<6|63&t[n++],s--;s>1?o[i++]=65533:e<65536?o[i++]=e:(e-=65536,o[i++]=55296|e>>10&1023,o[i++]=56320|1023&e)}}return((t,e)=>{if(e<65534&&t.subarray&&Vy)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let r="";for(let n=0;n<e;n++)r+=String.fromCharCode(t[n]);return r})(o,i)},utf8border:(t,e)=>{(e=e||t.length)>t.length&&(e=t.length);let r=e-1;for(;r>=0&&128==(192&t[r]);)r--;return r<0||0===r?e:r+qy[t[r]]>e?r:e}};var $y=function(){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};const Gy=Object.prototype.toString,{Z_NO_FLUSH:Zy,Z_SYNC_FLUSH:Yy,Z_FULL_FLUSH:Jy,Z_FINISH:Xy,Z_OK:Qy,Z_STREAM_END:tg,Z_DEFAULT_COMPRESSION:eg,Z_DEFAULT_STRATEGY:rg,Z_DEFLATED:ng}=Fp;function ig(t){this.options=Ky.assign({level:eg,method:ng,chunkSize:16384,windowBits:15,memLevel:8,strategy:rg},t||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new $y,this.strm.avail_out=0;let r=Wy.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(r!==Qy)throw new Error(Wp[r]);if(e.header&&Wy.deflateSetHeader(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?Hy.string2buf(e.dictionary):"[object ArrayBuffer]"===Gy.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,r=Wy.deflateSetDictionary(this.strm,t),r!==Qy)throw new Error(Wp[r]);this._dict_set=!0}}ig.prototype.push=function(t,e){const r=this.strm,n=this.options.chunkSize;let i,o;if(this.ended)return!1;for(o=e===~~e?e:!0===e?Xy:Zy,"string"==typeof t?r.input=Hy.string2buf(t):"[object ArrayBuffer]"===Gy.call(t)?r.input=new Uint8Array(t):r.input=t,r.next_in=0,r.avail_in=r.input.length;;)if(0===r.avail_out&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),(o===Yy||o===Jy)&&r.avail_out<=6)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else{if(i=Wy.deflate(r,o),i===tg)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),i=Wy.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===Qy;if(0!==r.avail_out){if(o>0&&r.next_out>0)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else if(0===r.avail_in)break}else this.onData(r.output)}return!0},ig.prototype.onData=function(t){this.chunks.push(t)},ig.prototype.onEnd=function(t){t===Qy&&(this.result=Ky.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};const og=16209;var sg=function(t,e){let r,n,i,o,s,a,u,c,h,l,f,d,p,y,g,m,w,b,v,_,k,E,x,S;const A=t.state;r=t.next_in,x=t.input,n=r+(t.avail_in-5),i=t.next_out,S=t.output,o=i-(e-t.avail_out),s=i+(t.avail_out-257),a=A.dmax,u=A.wsize,c=A.whave,h=A.wnext,l=A.window,f=A.hold,d=A.bits,p=A.lencode,y=A.distcode,g=(1<<A.lenbits)-1,m=(1<<A.distbits)-1;t:do{d<15&&(f+=x[r++]<<d,d+=8,f+=x[r++]<<d,d+=8),w=p[f&g];e:for(;;){if(b=w>>>24,f>>>=b,d-=b,b=w>>>16&255,0===b)S[i++]=65535&w;else{if(!(16&b)){if(0==(64&b)){w=p[(65535&w)+(f&(1<<b)-1)];continue e}if(32&b){A.mode=16191;break t}t.msg="invalid literal/length code",A.mode=og;break t}v=65535&w,b&=15,b&&(d<b&&(f+=x[r++]<<d,d+=8),v+=f&(1<<b)-1,f>>>=b,d-=b),d<15&&(f+=x[r++]<<d,d+=8,f+=x[r++]<<d,d+=8),w=y[f&m];r:for(;;){if(b=w>>>24,f>>>=b,d-=b,b=w>>>16&255,!(16&b)){if(0==(64&b)){w=y[(65535&w)+(f&(1<<b)-1)];continue r}t.msg="invalid distance code",A.mode=og;break t}if(_=65535&w,b&=15,d<b&&(f+=x[r++]<<d,d+=8,d<b&&(f+=x[r++]<<d,d+=8)),_+=f&(1<<b)-1,_>a){t.msg="invalid distance too far back",A.mode=og;break t}if(f>>>=b,d-=b,b=i-o,_>b){if(b=_-b,b>c&&A.sane){t.msg="invalid distance too far back",A.mode=og;break t}if(k=0,E=l,0===h){if(k+=u-b,b<v){v-=b;do{S[i++]=l[k++]}while(--b);k=i-_,E=S}}else if(h<b){if(k+=u+h-b,b-=h,b<v){v-=b;do{S[i++]=l[k++]}while(--b);if(k=0,h<v){b=h,v-=b;do{S[i++]=l[k++]}while(--b);k=i-_,E=S}}}else if(k+=h-b,b<v){v-=b;do{S[i++]=l[k++]}while(--b);k=i-_,E=S}for(;v>2;)S[i++]=E[k++],S[i++]=E[k++],S[i++]=E[k++],v-=3;v&&(S[i++]=E[k++],v>1&&(S[i++]=E[k++]))}else{k=i-_;do{S[i++]=S[k++],S[i++]=S[k++],S[i++]=S[k++],v-=3}while(v>2);v&&(S[i++]=S[k++],v>1&&(S[i++]=S[k++]))}break}}break}}while(r<n&&i<s);v=d>>3,r-=v,d-=v<<3,f&=(1<<d)-1,t.next_in=r,t.next_out=i,t.avail_in=r<n?n-r+5:5-(r-n),t.avail_out=i<s?s-i+257:257-(i-s),A.hold=f,A.bits=d};const ag=15,ug=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),cg=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),hg=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),lg=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var fg=(t,e,r,n,i,o,s,a)=>{const u=a.bits;let c,h,l,f,d,p,y=0,g=0,m=0,w=0,b=0,v=0,_=0,k=0,E=0,x=0,S=null;const A=new Uint16Array(16),I=new Uint16Array(16);let B,M,R,P=null;for(y=0;y<=ag;y++)A[y]=0;for(g=0;g<n;g++)A[e[r+g]]++;for(b=u,w=ag;w>=1&&0===A[w];w--);if(b>w&&(b=w),0===w)return i[o++]=20971520,i[o++]=20971520,a.bits=1,0;for(m=1;m<w&&0===A[m];m++);for(b<m&&(b=m),k=1,y=1;y<=ag;y++)if(k<<=1,k-=A[y],k<0)return-1;if(k>0&&(0===t||1!==w))return-1;for(I[1]=0,y=1;y<ag;y++)I[y+1]=I[y]+A[y];for(g=0;g<n;g++)0!==e[r+g]&&(s[I[e[r+g]]++]=g);if(0===t?(S=P=s,p=20):1===t?(S=ug,P=cg,p=257):(S=hg,P=lg,p=0),x=0,g=0,y=m,d=o,v=b,_=0,l=-1,E=1<<b,f=E-1,1===t&&E>852||2===t&&E>592)return 1;for(;;){B=y-_,s[g]+1<p?(M=0,R=s[g]):s[g]>=p?(M=P[s[g]-p],R=S[s[g]-p]):(M=96,R=0),c=1<<y-_,h=1<<v,m=h;do{h-=c,i[d+(x>>_)+h]=B<<24|M<<16|R|0}while(0!==h);for(c=1<<y-1;x&c;)c>>=1;if(0!==c?(x&=c-1,x+=c):x=0,g++,0==--A[y]){if(y===w)break;y=e[r+s[g]]}if(y>b&&(x&f)!==l){for(0===_&&(_=b),d+=m,v=y-_,k=1<<v;v+_<w&&(k-=A[v+_],!(k<=0));)v++,k<<=1;if(E+=1<<v,1===t&&E>852||2===t&&E>592)return 1;l=x&f,i[l]=b<<24|v<<16|d-o|0}}return 0!==x&&(i[d+x]=y-_<<24|64<<16|0),a.bits=b,0};const{Z_FINISH:dg,Z_BLOCK:pg,Z_TREES:yg,Z_OK:gg,Z_STREAM_END:mg,Z_NEED_DICT:wg,Z_STREAM_ERROR:bg,Z_DATA_ERROR:vg,Z_MEM_ERROR:_g,Z_BUF_ERROR:kg,Z_DEFLATED:Eg}=Fp,xg=16180,Sg=16190,Ag=16191,Ig=16192,Bg=16194,Mg=16199,Rg=16200,Pg=16206,Tg=16209,Lg=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function Og(){this.strm=null,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 Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Ug=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.mode<xg||e.mode>16211?1:0},Cg=t=>{if(Ug(t))return bg;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=xg,e.last=0,e.havedict=0,e.flags=-1,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,gg},Ng=t=>{if(Ug(t))return bg;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,Cg(t)},zg=(t,e)=>{let r;if(Ug(t))return bg;const n=t.state;return e<0?(r=0,e=-e):(r=5+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?bg:(null!==n.window&&n.wbits!==e&&(n.window=null),n.wrap=r,n.wbits=e,Ng(t))},Dg=(t,e)=>{if(!t)return bg;const r=new Og;t.state=r,r.strm=t,r.window=null,r.mode=xg;const n=zg(t,e);return n!==gg&&(t.state=null),n};let jg,Wg,Fg=!0;const Kg=t=>{if(Fg){jg=new Int32Array(512),Wg=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(fg(1,t.lens,0,288,jg,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;fg(2,t.lens,0,32,Wg,0,t.work,{bits:5}),Fg=!1}t.lencode=jg,t.lenbits=9,t.distcode=Wg,t.distbits=5},Vg=(t,e,r,n)=>{let i;const o=t.state;return null===o.window&&(o.wsize=1<<o.wbits,o.wnext=0,o.whave=0,o.window=new Uint8Array(o.wsize)),n>=o.wsize?(o.window.set(e.subarray(r-o.wsize,r),0),o.wnext=0,o.whave=o.wsize):(i=o.wsize-o.wnext,i>n&&(i=n),o.window.set(e.subarray(r-n,r-n+i),o.wnext),(n-=i)?(o.window.set(e.subarray(r-n,r),0),o.wnext=n,o.whave=o.wsize):(o.wnext+=i,o.wnext===o.wsize&&(o.wnext=0),o.whave<o.wsize&&(o.whave+=i))),0};var qg=(t,e)=>{let r,n,i,o,s,a,u,c,h,l,f,d,p,y,g,m,w,b,v,_,k,E,x=0;const S=new Uint8Array(4);let A,I;const B=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Ug(t)||!t.output||!t.input&&0!==t.avail_in)return bg;r=t.state,r.mode===Ag&&(r.mode=Ig),s=t.next_out,i=t.output,u=t.avail_out,o=t.next_in,n=t.input,a=t.avail_in,c=r.hold,h=r.bits,l=a,f=u,E=gg;t:for(;;)switch(r.mode){case xg:if(0===r.wrap){r.mode=Ig;break}for(;h<16;){if(0===a)break t;a--,c+=n[o++]<<h,h+=8}if(2&r.wrap&&35615===c){0===r.wbits&&(r.wbits=15),r.check=0,S[0]=255&c,S[1]=c>>>8&255,r.check=jp(r.check,S,2,0),c=0,h=0,r.mode=16181;break}if(r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&c)<<8)+(c>>8))%31){t.msg="incorrect header check",r.mode=Tg;break}if((15&c)!==Eg){t.msg="unknown compression method",r.mode=Tg;break}if(c>>>=4,h-=4,k=8+(15&c),0===r.wbits&&(r.wbits=k),k>15||k>r.wbits){t.msg="invalid window size",r.mode=Tg;break}r.dmax=1<<r.wbits,r.flags=0,t.adler=r.check=1,r.mode=512&c?16189:Ag,c=0,h=0;break;case 16181:for(;h<16;){if(0===a)break t;a--,c+=n[o++]<<h,h+=8}if(r.flags=c,(255&r.flags)!==Eg){t.msg="unknown compression method",r.mode=Tg;break}if(57344&r.flags){t.msg="unknown header flags set",r.mode=Tg;break}r.head&&(r.head.text=c>>8&1),512&r.flags&&4&r.wrap&&(S[0]=255&c,S[1]=c>>>8&255,r.check=jp(r.check,S,2,0)),c=0,h=0,r.mode=16182;case 16182:for(;h<32;){if(0===a)break t;a--,c+=n[o++]<<h,h+=8}r.head&&(r.head.time=c),512&r.flags&&4&r.wrap&&(S[0]=255&c,S[1]=c>>>8&255,S[2]=c>>>16&255,S[3]=c>>>24&255,r.check=jp(r.check,S,4,0)),c=0,h=0,r.mode=16183;case 16183:for(;h<16;){if(0===a)break t;a--,c+=n[o++]<<h,h+=8}r.head&&(r.head.xflags=255&c,r.head.os=c>>8),512&r.flags&&4&r.wrap&&(S[0]=255&c,S[1]=c>>>8&255,r.check=jp(r.check,S,2,0)),c=0,h=0,r.mode=16184;case 16184:if(1024&r.flags){for(;h<16;){if(0===a)break t;a--,c+=n[o++]<<h,h+=8}r.length=c,r.head&&(r.head.extra_len=c),512&r.flags&&4&r.wrap&&(S[0]=255&c,S[1]=c>>>8&255,r.check=jp(r.check,S,2,0)),c=0,h=0}else r.head&&(r.head.extra=null);r.mode=16185;case 16185:if(1024&r.flags&&(d=r.length,d>a&&(d=a),d&&(r.head&&(k=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(n.subarray(o,o+d),k)),512&r.flags&&4&r.wrap&&(r.check=jp(r.check,n,d,o)),a-=d,o+=d,r.length-=d),r.length))break t;r.length=0,r.mode=16186;case 16186:if(2048&r.flags){if(0===a)break t;d=0;do{k=n[o+d++],r.head&&k&&r.length<65536&&(r.head.name+=String.fromCharCode(k))}while(k&&d<a);if(512&r.flags&&4&r.wrap&&(r.check=jp(r.check,n,d,o)),a-=d,o+=d,k)break t}else r.head&&(r.head.name=null);r.length=0,r.mode=16187;case 16187:if(4096&r.flags){if(0===a)break t;d=0;do{k=n[o+d++],r.head&&k&&r.length<65536&&(r.head.comment+=String.fromCharCode(k))}while(k&&d<a);if(512&r.flags&&4&r.wrap&&(r.check=jp(r.check,n,d,o)),a-=d,o+=d,k)break t}else r.head&&(r.head.comment=null);r.mode=16188;case 16188:if(512&r.flags){for(;h<16;){if(0===a)break t;a--,c+=n[o++]<<h,h+=8}if(4&r.wrap&&c!==(65535&r.check)){t.msg="header crc mismatch",r.mode=Tg;break}c=0,h=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),t.adler=r.check=0,r.mode=Ag;break;case 16189:for(;h<32;){if(0===a)break t;a--,c+=n[o++]<<h,h+=8}t.adler=r.check=Lg(c),c=0,h=0,r.mode=Sg;case Sg:if(0===r.havedict)return t.next_out=s,t.avail_out=u,t.next_in=o,t.avail_in=a,r.hold=c,r.bits=h,wg;t.adler=r.check=1,r.mode=Ag;case Ag:if(e===pg||e===yg)break t;case Ig:if(r.last){c>>>=7&h,h-=7&h,r.mode=Pg;break}for(;h<3;){if(0===a)break t;a--,c+=n[o++]<<h,h+=8}switch(r.last=1&c,c>>>=1,h-=1,3&c){case 0:r.mode=16193;break;case 1:if(Kg(r),r.mode=Mg,e===yg){c>>>=2,h-=2;break t}break;case 2:r.mode=16196;break;case 3:t.msg="invalid block type",r.mode=Tg}c>>>=2,h-=2;break;case 16193:for(c>>>=7&h,h-=7&h;h<32;){if(0===a)break t;a--,c+=n[o++]<<h,h+=8}if((65535&c)!=(c>>>16^65535)){t.msg="invalid stored block lengths",r.mode=Tg;break}if(r.length=65535&c,c=0,h=0,r.mode=Bg,e===yg)break t;case Bg:r.mode=16195;case 16195:if(d=r.length,d){if(d>a&&(d=a),d>u&&(d=u),0===d)break t;i.set(n.subarray(o,o+d),s),a-=d,o+=d,u-=d,s+=d,r.length-=d;break}r.mode=Ag;break;case 16196:for(;h<14;){if(0===a)break t;a--,c+=n[o++]<<h,h+=8}if(r.nlen=257+(31&c),c>>>=5,h-=5,r.ndist=1+(31&c),c>>>=5,h-=5,r.ncode=4+(15&c),c>>>=4,h-=4,r.nlen>286||r.ndist>30){t.msg="too many length or distance symbols",r.mode=Tg;break}r.have=0,r.mode=16197;case 16197:for(;r.have<r.ncode;){for(;h<3;){if(0===a)break t;a--,c+=n[o++]<<h,h+=8}r.lens[B[r.have++]]=7&c,c>>>=3,h-=3}for(;r.have<19;)r.lens[B[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,A={bits:r.lenbits},E=fg(0,r.lens,0,19,r.lencode,0,r.work,A),r.lenbits=A.bits,E){t.msg="invalid code lengths set",r.mode=Tg;break}r.have=0,r.mode=16198;case 16198:for(;r.have<r.nlen+r.ndist;){for(;x=r.lencode[c&(1<<r.lenbits)-1],g=x>>>24,m=x>>>16&255,w=65535&x,!(g<=h);){if(0===a)break t;a--,c+=n[o++]<<h,h+=8}if(w<16)c>>>=g,h-=g,r.lens[r.have++]=w;else{if(16===w){for(I=g+2;h<I;){if(0===a)break t;a--,c+=n[o++]<<h,h+=8}if(c>>>=g,h-=g,0===r.have){t.msg="invalid bit length repeat",r.mode=Tg;break}k=r.lens[r.have-1],d=3+(3&c),c>>>=2,h-=2}else if(17===w){for(I=g+3;h<I;){if(0===a)break t;a--,c+=n[o++]<<h,h+=8}c>>>=g,h-=g,k=0,d=3+(7&c),c>>>=3,h-=3}else{for(I=g+7;h<I;){if(0===a)break t;a--,c+=n[o++]<<h,h+=8}c>>>=g,h-=g,k=0,d=11+(127&c),c>>>=7,h-=7}if(r.have+d>r.nlen+r.ndist){t.msg="invalid bit length repeat",r.mode=Tg;break}for(;d--;)r.lens[r.have++]=k}}if(r.mode===Tg)break;if(0===r.lens[256]){t.msg="invalid code -- missing end-of-block",r.mode=Tg;break}if(r.lenbits=9,A={bits:r.lenbits},E=fg(1,r.lens,0,r.nlen,r.lencode,0,r.work,A),r.lenbits=A.bits,E){t.msg="invalid literal/lengths set",r.mode=Tg;break}if(r.distbits=6,r.distcode=r.distdyn,A={bits:r.distbits},E=fg(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,A),r.distbits=A.bits,E){t.msg="invalid distances set",r.mode=Tg;break}if(r.mode=Mg,e===yg)break t;case Mg:r.mode=Rg;case Rg:if(a>=6&&u>=258){t.next_out=s,t.avail_out=u,t.next_in=o,t.avail_in=a,r.hold=c,r.bits=h,sg(t,f),s=t.next_out,i=t.output,u=t.avail_out,o=t.next_in,n=t.input,a=t.avail_in,c=r.hold,h=r.bits,r.mode===Ag&&(r.back=-1);break}for(r.back=0;x=r.lencode[c&(1<<r.lenbits)-1],g=x>>>24,m=x>>>16&255,w=65535&x,!(g<=h);){if(0===a)break t;a--,c+=n[o++]<<h,h+=8}if(m&&0==(240&m)){for(b=g,v=m,_=w;x=r.lencode[_+((c&(1<<b+v)-1)>>b)],g=x>>>24,m=x>>>16&255,w=65535&x,!(b+g<=h);){if(0===a)break t;a--,c+=n[o++]<<h,h+=8}c>>>=b,h-=b,r.back+=b}if(c>>>=g,h-=g,r.back+=g,r.length=w,0===m){r.mode=16205;break}if(32&m){r.back=-1,r.mode=Ag;break}if(64&m){t.msg="invalid literal/length code",r.mode=Tg;break}r.extra=15&m,r.mode=16201;case 16201:if(r.extra){for(I=r.extra;h<I;){if(0===a)break t;a--,c+=n[o++]<<h,h+=8}r.length+=c&(1<<r.extra)-1,c>>>=r.extra,h-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=16202;case 16202:for(;x=r.distcode[c&(1<<r.distbits)-1],g=x>>>24,m=x>>>16&255,w=65535&x,!(g<=h);){if(0===a)break t;a--,c+=n[o++]<<h,h+=8}if(0==(240&m)){for(b=g,v=m,_=w;x=r.distcode[_+((c&(1<<b+v)-1)>>b)],g=x>>>24,m=x>>>16&255,w=65535&x,!(b+g<=h);){if(0===a)break t;a--,c+=n[o++]<<h,h+=8}c>>>=b,h-=b,r.back+=b}if(c>>>=g,h-=g,r.back+=g,64&m){t.msg="invalid distance code",r.mode=Tg;break}r.offset=w,r.extra=15&m,r.mode=16203;case 16203:if(r.extra){for(I=r.extra;h<I;){if(0===a)break t;a--,c+=n[o++]<<h,h+=8}r.offset+=c&(1<<r.extra)-1,c>>>=r.extra,h-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){t.msg="invalid distance too far back",r.mode=Tg;break}r.mode=16204;case 16204:if(0===u)break t;if(d=f-u,r.offset>d){if(d=r.offset-d,d>r.whave&&r.sane){t.msg="invalid distance too far back",r.mode=Tg;break}d>r.wnext?(d-=r.wnext,p=r.wsize-d):p=r.wnext-d,d>r.length&&(d=r.length),y=r.window}else y=i,p=s-r.offset,d=r.length;d>u&&(d=u),u-=d,r.length-=d;do{i[s++]=y[p++]}while(--d);0===r.length&&(r.mode=Rg);break;case 16205:if(0===u)break t;i[s++]=r.length,u--,r.mode=Rg;break;case Pg:if(r.wrap){for(;h<32;){if(0===a)break t;a--,c|=n[o++]<<h,h+=8}if(f-=u,t.total_out+=f,r.total+=f,4&r.wrap&&f&&(t.adler=r.check=r.flags?jp(r.check,i,f,s-f):zp(r.check,i,f,s-f)),f=u,4&r.wrap&&(r.flags?c:Lg(c))!==r.check){t.msg="incorrect data check",r.mode=Tg;break}c=0,h=0}r.mode=16207;case 16207:if(r.wrap&&r.flags){for(;h<32;){if(0===a)break t;a--,c+=n[o++]<<h,h+=8}if(4&r.wrap&&c!==(4294967295&r.total)){t.msg="incorrect length check",r.mode=Tg;break}c=0,h=0}r.mode=16208;case 16208:E=mg;break t;case Tg:E=vg;break t;case 16210:return _g;default:return bg}return t.next_out=s,t.avail_out=u,t.next_in=o,t.avail_in=a,r.hold=c,r.bits=h,(r.wsize||f!==t.avail_out&&r.mode<Tg&&(r.mode<Pg||e!==dg))&&Vg(t,t.output,t.next_out,f-t.avail_out),l-=t.avail_in,f-=t.avail_out,t.total_in+=l,t.total_out+=f,r.total+=f,4&r.wrap&&f&&(t.adler=r.check=r.flags?jp(r.check,i,f,t.next_out-f):zp(r.check,i,f,t.next_out-f)),t.data_type=r.bits+(r.last?64:0)+(r.mode===Ag?128:0)+(r.mode===Mg||r.mode===Bg?256:0),(0===l&&0===f||e===dg)&&E===gg&&(E=kg),E},Hg=t=>{if(Ug(t))return bg;let e=t.state;return e.window&&(e.window=null),t.state=null,gg},$g=(t,e)=>{if(Ug(t))return bg;const r=t.state;return 0==(2&r.wrap)?bg:(r.head=e,e.done=!1,gg)},Gg=(t,e)=>{const r=e.length;let n,i,o;return Ug(t)?bg:(n=t.state,0!==n.wrap&&n.mode!==Sg?bg:n.mode===Sg&&(i=1,i=zp(i,e,r,0),i!==n.check)?vg:(o=Vg(t,e,r,r),o?(n.mode=16210,_g):(n.havedict=1,gg)))},Zg={inflateReset:Ng,inflateReset2:zg,inflateResetKeep:Cg,inflateInit:t=>Dg(t,15),inflateInit2:Dg,inflate:qg,inflateEnd:Hg,inflateGetHeader:$g,inflateSetDictionary:Gg,inflateInfo:"pako inflate (from Nodeca project)"};var Yg=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const Jg=Object.prototype.toString,{Z_NO_FLUSH:Xg,Z_FINISH:Qg,Z_OK:tm,Z_STREAM_END:em,Z_NEED_DICT:rm,Z_STREAM_ERROR:nm,Z_DATA_ERROR:im,Z_MEM_ERROR:om}=Fp;function sm(t){this.options=Ky.assign({chunkSize:65536,windowBits:15,to:""},t||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new $y,this.strm.avail_out=0;let r=Zg.inflateInit2(this.strm,e.windowBits);if(r!==tm)throw new Error(Wp[r]);if(this.header=new Yg,Zg.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=Hy.string2buf(e.dictionary):"[object ArrayBuffer]"===Jg.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(r=Zg.inflateSetDictionary(this.strm,e.dictionary),r!==tm)))throw new Error(Wp[r])}function am(t,e){const r=new sm(e);if(r.push(t),r.err)throw r.msg||Wp[r.err];return r.result}sm.prototype.push=function(t,e){const r=this.strm,n=this.options.chunkSize,i=this.options.dictionary;let o,s,a;if(this.ended)return!1;for(s=e===~~e?e:!0===e?Qg:Xg,"[object ArrayBuffer]"===Jg.call(t)?r.input=new Uint8Array(t):r.input=t,r.next_in=0,r.avail_in=r.input.length;;){for(0===r.avail_out&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),o=Zg.inflate(r,s),o===rm&&i&&(o=Zg.inflateSetDictionary(r,i),o===tm?o=Zg.inflate(r,s):o===im&&(o=rm));r.avail_in>0&&o===em&&r.state.wrap>0&&0!==t[r.next_in];)Zg.inflateReset(r),o=Zg.inflate(r,s);switch(o){case nm:case im:case rm:case om:return this.onEnd(o),this.ended=!0,!1}if(a=r.avail_out,r.next_out&&(0===r.avail_out||o===em))if("string"===this.options.to){let t=Hy.utf8border(r.output,r.next_out),e=r.next_out-t,i=Hy.buf2string(r.output,t);r.next_out=e,r.avail_out=n-e,e&&r.output.set(r.output.subarray(t,t+e),0),this.onData(i)}else this.onData(r.output.length===r.next_out?r.output:r.output.subarray(0,r.next_out));if(o!==tm||0!==a){if(o===em)return o=Zg.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,!0;if(0===r.avail_in)break}}return!0},sm.prototype.onData=function(t){this.chunks.push(t)},sm.prototype.onEnd=function(t){t===tm&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Ky.flattenChunks(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var um={Inflate:sm,inflate:am,inflateRaw:function(t,e){return(e=e||{}).raw=!0,am(t,e)},ungzip:am,constants:Fp};const{Inflate:cm,inflate:hm,inflateRaw:lm,ungzip:fm}=um;var dm=hm,pm=e(Vi());const ym=t=>"version"in t;var gm=Object.freeze({__proto__:null,encode:function(t){return t.reduce(((t,e)=>t+e.toString(16).padStart(2,"0")),"0x")},decode:function(t){0===t.indexOf("0x")&&(t=t.substr(2)),t.length%2==1&&(t="0"+t);let e=t.match(/.{2}/g);return null===e?n.Buffer.from([]):n.Buffer.from(e.map((t=>parseInt(t,16))))}});function mm(t){return new TextDecoder("utf-8").decode(t)}function wm(t){return(new TextEncoder).encode(t)}var bm=Object.freeze({__proto__:null,decode:mm,encode:wm});function vm(t){return ld.encode(t)}var _m=Object.freeze({__proto__:null,encode:vm,decode:function(t){return ld.decode(t)}});function km(t){return n.Buffer.from(o(t))}var Em=Object.freeze({__proto__:null,encode:function(t){return s(t)},decode:km}),xm=Object.freeze({__proto__:null,hex:gm,utf8:bm,bs58:_m,base64:Em});function Sm(t){const e=new Map;return t.errors&&t.errors.forEach((t=>{var r;let n=null!==(r=t.msg)&&void 0!==r?r:t.name;e.set(t.code,n)})),e}function Am(t,...e){if(t.args.length!=e.length)throw new Error("Invalid argument length");const r={};let n=0;return t.args.forEach((t=>{r[t.name]=e[n],n+=1})),r}function Im(t,e={}){t.forEach((t=>{if("accounts"in t)Im(t.accounts,e[t.name]);else if(void 0===e[t.name])throw new Error(`Invalid arguments: ${t.name} not provided.`)}))}function Bm(t){return t instanceof Wo?t:new Wo(t)}class Mm extends TypeError{constructor(t,e){let r;const{message:n,...i}=t,{path:o}=t;super(0===o.length?n:"At path: "+o.join(".")+" -- "+n),this.value=void 0,this.key=void 0,this.type=void 0,this.refinement=void 0,this.path=void 0,this.branch=void 0,this.failures=void 0,Object.assign(this,i),this.name=this.constructor.name,this.failures=()=>{var n;return null!=(n=r)?n:r=[t,...e()]}}}function Rm(t){return"object"==typeof t&&null!=t}function Pm(t){return"string"==typeof t?JSON.stringify(t):""+t}function Tm(t,e,r,n){if(!0===t)return;!1===t?t={}:"string"==typeof t&&(t={message:t});const{path:i,branch:o}=e,{type:s}=r,{refinement:a,message:u="Expected a value of type `"+s+"`"+(a?" with refinement `"+a+"`":"")+", but received: `"+Pm(n)+"`"}=t;return{value:n,type:s,refinement:a,key:i[i.length-1],path:i,branch:o,...t,message:u}}function*Lm(t,e,r,n){(function(t){return Rm(t)&&"function"==typeof t[Symbol.iterator]})(t)||(t=[t]);for(const i of t){const t=Tm(i,e,r,n);t&&(yield t)}}function*Om(t,e,r){void 0===r&&(r={});const{path:n=[],branch:i=[t],coerce:o=!1,mask:s=!1}=r,a={path:n,branch:i};if(o&&(t=e.coercer(t,a),s&&"type"!==e.type&&Rm(e.schema)&&Rm(t)&&!Array.isArray(t)))for(const r in t)void 0===e.schema[r]&&delete t[r];let u=!0;for(const r of e.validator(t,a))u=!1,yield[r,void 0];for(let[r,c,h]of e.entries(t,a)){const e=Om(c,h,{path:void 0===r?n:[...n,r],branch:void 0===r?i:[...i,c],coerce:o,mask:s});for(const n of e)n[0]?(u=!1,yield[n[0],void 0]):o&&(c=n[1],void 0===r?t=c:t instanceof Map?t.set(r,c):t instanceof Set?t.add(c):Rm(t)&&(t[r]=c))}if(u)for(const r of e.refiner(t,a))u=!1,yield[r,void 0];u&&(yield[void 0,t])}class Um{constructor(t){this.TYPE=void 0,this.type=void 0,this.schema=void 0,this.coercer=void 0,this.validator=void 0,this.refiner=void 0,this.entries=void 0;const{type:e,schema:r,validator:n,refiner:i,coercer:o=(t=>t),entries:s=function*(){}}=t;this.type=e,this.schema=r,this.entries=s,this.coercer=o,this.validator=n?(t,e)=>Lm(n(t,e),e,this,t):()=>[],this.refiner=i?(t,e)=>Lm(i(t,e),e,this,t):()=>[]}assert(t){return function(t,e){const r=zm(t,e);if(r[0])throw r[0]}(t,this)}create(t){return Cm(t,this)}is(t){return Nm(t,this)}mask(t){return function(t,e){const r=zm(t,e,{coerce:!0,mask:!0});if(r[0])throw r[0];return r[1]}(t,this)}validate(t,e){return void 0===e&&(e={}),zm(t,this,e)}}function Cm(t,e){const r=zm(t,e,{coerce:!0});if(r[0])throw r[0];return r[1]}function Nm(t,e){return!zm(t,e)[0]}function zm(t,e,r){void 0===r&&(r={});const n=Om(t,e,r),i=function(t){const{done:e,value:r}=t.next();return e?void 0:r}(n);if(i[0]){const t=new Mm(i[0],(function*(){for(const t of n)t[0]&&(yield t[0])}));return[t,void 0]}return[void 0,i[1]]}function Dm(t,e){return new Um({type:t,schema:null,validator:e})}function jm(t){return new Um({type:"array",schema:t,*entries(e){if(t&&Array.isArray(e))for(const[r,n]of e.entries())yield[r,n,t]},coercer:t=>Array.isArray(t)?t.slice():t,validator:t=>Array.isArray(t)||"Expected an array value, but received: "+Pm(t)})}function Wm(t){const e=Pm(t),r=typeof t;return new Um({type:"literal",schema:"string"===r||"number"===r||"boolean"===r?t:null,validator:r=>r===t||"Expected the literal `"+e+"`, but received: "+Pm(r)})}function Fm(t){return new Um({...t,validator:(e,r)=>null===e||t.validator(e,r),refiner:(e,r)=>null===e||t.refiner(e,r)})}function Km(){return Dm("number",(t=>"number"==typeof t&&!isNaN(t)||"Expected a number, but received: "+Pm(t)))}function Vm(t){return new Um({...t,validator:(e,r)=>void 0===e||t.validator(e,r),refiner:(e,r)=>void 0===e||t.refiner(e,r)})}function qm(){return Dm("string",(t=>"string"==typeof t||"Expected a string, but received: "+Pm(t)))}function Hm(t){const e=Object.keys(t);return new Um({type:"type",schema:t,*entries(r){if(Rm(r))for(const n of e)yield[n,r[n],t[n]]},validator:t=>Rm(t)||"Expected an object, but received: "+Pm(t)})}function $m(t){const e=t.map((t=>t.type)).join(" | ");return new Um({type:"union",schema:null,coercer(e,r){const n=t.find((t=>{const[r]=t.validate(e,{coerce:!0});return!r}))||Gm();return n.coercer(e,r)},validator(r,n){const i=[];for(const e of t){const[...t]=Om(r,e,n),[o]=t;if(!o[0])return[];for(const[e]of t)e&&i.push(e)}return["Expected the value to satisfy a union of `"+e+"`, but received: "+Pm(r),...i]}})}function Gm(){return Dm("unknown",(()=>!0))}const Zm=99;async function Ym(t,e,r){if(e.length<=Zm)return await Jm(t,e,r);{const n=function(t,e){return Array.apply(0,new Array(Math.ceil(t.length/e))).map(((r,n)=>t.slice(n*e,(n+1)*e)))}(e,Zm);return(await Promise.all(n.map((e=>Jm(t,e,r))))).flat()}}async function Jm(t,e,r){const n=null!=r?r:t.commitment,{value:i,context:o}=await t.getMultipleAccountsInfoAndContext(e,n);return i.map(((t,r)=>null===t?null:{publicKey:e[r],account:t,context:o}))}async function Xm(t,e,r,n,i){var o;r&&r.length>0&&e.sign(...r);const s=e._compile(),a=s.serialize(),u=e._serialize(a).toString("base64"),c={encoding:"base64",commitment:null!=n?n:t.commitment};if(i){const t=(Array.isArray(i)?i:s.nonProgramIds()).map((t=>t.toBase58()));c.accounts={encoding:"base64",addresses:t}}r&&(c.sigVerify=!0);const h=[u,c],l=Cm(await t._rpcRequest("simulateTransaction",h),rw);if("error"in l){let t;if("data"in l.error&&(t=null===(o=l.error.data)||void 0===o?void 0:o.logs,t&&Array.isArray(t))){const e="\n ",r=e+t.join(e);console.error(l.error.message,r)}throw new Ks("failed to simulate transaction: "+l.error.message,t)}return l.result}function Qm(t){return function(t,e,r){return new Um({...t,coercer:(n,i)=>Nm(n,e)?t.coercer(r(n,i),i):t.coercer(n,i)})}(ew(t),tw,(e=>"error"in e?e:{...e,result:Cm(e.result,t)}))}const tw=ew(Gm());function ew(t){return $m([Hm({jsonrpc:Wm("2.0"),id:qm(),result:t}),Hm({jsonrpc:Wm("2.0"),id:qm(),error:Hm({code:Gm(),message:qm(),data:Vm(Dm("any",(()=>!0)))})})])}const rw=(nw=Hm({err:Fm($m([Hm({}),qm()])),logs:Fm(jm(qm())),accounts:Vm(Fm(jm(Fm(Hm({executable:Dm("boolean",(t=>"boolean"==typeof t)),owner:qm(),lamports:Km(),data:jm(qm()),rentEpoch:Vm(Km())}))))),unitsConsumed:Vm(Km())}),Qm(Hm({context:Hm({slot:Km()}),value:nw})));var nw,iw=Object.freeze({__proto__:null,invoke:async function(t,e,r,n){t=Bm(t),n||(n=cw());const i=new hs;if(i.add(new cs({programId:t,keys:null!=e?e:[],data:r})),void 0===n.sendAndConfirm)throw new Error("This function requires 'Provider.sendAndConfirm' to be implemented.");return await n.sendAndConfirm(i,[])},getMultipleAccounts:async function(t,e,r){return(await Ym(t,e,r)).map((t=>t?{publicKey:t.publicKey,account:t.account}:null))},getMultipleAccountsAndContext:Ym,simulateTransaction:Xm});class ow{constructor(t,e,r){this.connection=t,this.wallet=e,this.opts=r,this.publicKey=null==e?void 0:e.publicKey}static defaultOptions(){return{preflightCommitment:"processed",commitment:"processed"}}static local(t,e){throw new Error("Provider local is not available on browser.")}static env(){throw new Error("Provider env is not available on browser.")}async sendAndConfirm(t,e,r){var n,i,o,s;if(void 0===r&&(r=this.opts),ym(t))e&&t.sign(e);else if(t.feePayer=null!==(n=t.feePayer)&&void 0!==n?n:this.wallet.publicKey,t.recentBlockhash=(await this.connection.getLatestBlockhash(r.preflightCommitment)).blockhash,e)for(const r of e)t.partialSign(r);const a=(t=await this.wallet.signTransaction(t)).serialize();try{return await aw(this.connection,a,r)}catch(e){if(e instanceof uw){const r=vm(ym(t)?(null===(i=t.signatures)||void 0===i?void 0:i[0])||new Uint8Array:null!==(o=t.signature)&&void 0!==o?o:new Uint8Array),n=await this.connection.getTransaction(r,{commitment:"confirmed"});if(n){const t=null===(s=n.meta)||void 0===s?void 0:s.logMessages;throw t?new Ks(e.message,t):e}throw e}throw e}}async sendAll(t,e){var r,n,i;void 0===e&&(e=this.opts);const o=(await this.connection.getLatestBlockhash(e.preflightCommitment)).blockhash;let s=t.map((t=>{var e,r;if(ym(t.tx)){let e=t.tx;return t.signers&&e.sign(t.signers),e}{let n=t.tx,i=null!==(e=t.signers)&&void 0!==e?e:[];return n.feePayer=null!==(r=n.feePayer)&&void 0!==r?r:this.wallet.publicKey,n.recentBlockhash=o,i.forEach((t=>{n.partialSign(t)})),n}}));const a=await this.wallet.signAllTransactions(s),u=[];for(let t=0;t<s.length;t+=1){const o=a[t],s=o.serialize();try{u.push(await aw(this.connection,s,e))}catch(t){if(t instanceof uw){const e=vm(ym(o)?(null===(r=o.signatures)||void 0===r?void 0:r[0])||new Uint8Array:null!==(n=o.signature)&&void 0!==n?n:new Uint8Array),s=await this.connection.getTransaction(e,{commitment:"confirmed"});if(s){const e=null===(i=s.meta)||void 0===i?void 0:i.logMessages;throw e?new Ks(t.message,e):t}throw t}throw t}}return u}async simulate(t,e,r,n){let i,o=(await this.connection.getLatestBlockhash(null!=r?r:this.connection.commitment)).blockhash;if(ym(t)?(e&&(t.sign(e),t=await this.wallet.signTransaction(t)),i=await this.connection.simulateTransaction(t,{commitment:r})):(t.feePayer=t.feePayer||this.wallet.publicKey,t.recentBlockhash=o,e&&(t=await this.wallet.signTransaction(t)),i=await Xm(this.connection,t,e,r,n)),i.value.err)throw new sw(i.value);return i.value}}class sw extends Error{constructor(t,e){super(e),this.simulationResponse=t}}async function aw(t,e,r){const n=r&&{skipPreflight:r.skipPreflight,preflightCommitment:r.preflightCommitment||r.commitment},i=await t.sendRawTransaction(e,n),o=(await t.confirmTransaction(i,r&&r.commitment)).value;if(o.err)throw new uw(`Raw transaction ${i} failed (${JSON.stringify(o)})`);return i}class uw extends Error{constructor(t){super(t)}}function cw(){return null===hw?ow.local():hw}let hw=null;const lw=new Set(["anchor-deprecated-state","debug-logs"]),fw=new Map;function dw(t){return void 0!==fw.get(t)}var pw=Object.freeze({__proto__:null,set:function(t){if(!lw.has(t))throw new Error("Invalid feature");fw.set(t,!0)},isSet:dw});class yw extends Error{constructor(t){super(t),this.name="IdlError"}}class gw{constructor(t){this.stack=t}static parse(t){var e;const r=/^Program (\w*) invoke/,n=/^Program \w* success/,i=[];for(let o=0;o<t.length;o++){if(n.exec(t[o])){i.pop();continue}const s=null===(e=r.exec(t[o]))||void 0===e?void 0:e[1];s&&i.push(new Wo(s))}return new gw(i)}}class mw extends Error{constructor(t,e,r,n,i,o){super(r.join("\n").replace("Program log: ","")),this.errorLogs=r,this.logs=n,this.error={errorCode:t,errorMessage:e,comparedValues:o,origin:i},this._programErrorStack=gw.parse(n)}static parse(t){if(!t)return null;const e=t.findIndex((t=>t.startsWith("Program log: AnchorError")));if(-1===e)return null;const r=t[e],n=[r];let i;if(e+1<t.length)if("Program log: Left:"===t[e+1]){const r=/^Program log: (.*)$/,o=r.exec(t[e+2])[1],s=r.exec(t[e+4])[1];i=[new Wo(o),new Wo(s)],n.push(...t.slice(e+1,e+5))}else if(t[e+1].startsWith("Program log: Left:")){const r=/^Program log: (Left|Right): (.*)$/,o=r.exec(t[e+1])[2],s=r.exec(t[e+2])[2];n.push(...t.slice(e+1,e+3)),i=[o,s]}const o=/^Program log: AnchorError occurred\. Error Code: (.*)\. Error Number: (\d*)\. Error Message: (.*)\./.exec(r),s=/^Program log: AnchorError thrown in (.*):(\d*)\. Error Code: (.*)\. Error Number: (\d*)\. Error Message: (.*)\./.exec(r),a=/^Program log: AnchorError caused by account: (.*)\. Error Code: (.*)\. Error Number: (\d*)\. Error Message: (.*)\./.exec(r);if(o){const[e,r,s]=o.slice(1,4),a={code:e,number:parseInt(r)};return new mw(a,s,n,t,void 0,i)}if(s){const[e,r,o,a,u]=s.slice(1,6),c={code:o,number:parseInt(a)},h={file:e,line:parseInt(r)};return new mw(c,u,n,t,h,i)}if(a){const[e,r,o,s]=a.slice(1,5),u=e,c={code:r,number:parseInt(o)};return new mw(c,s,n,t,u,i)}return null}get program(){return this._programErrorStack.stack[this._programErrorStack.stack.length-1]}get programErrorStack(){return this._programErrorStack.stack}toString(){return this.message}}class ww extends Error{constructor(t,e,r){super(),this.code=t,this.msg=e,this.logs=r,r&&(this._programErrorStack=gw.parse(r))}static parse(t,e){const r=t.toString();let n,i;if(r.includes("custom program error:")){let t=r.split("custom program error: ");if(2!==t.length)return null;n=t[1]}else{const t=r.match(/"Custom":([0-9]+)}/g);if(!t||t.length>1)return null;n=t[0].match(/([0-9]+)/g)[0]}try{i=parseInt(n)}catch(t){return null}let o=e.get(i);return void 0!==o?new ww(i,o,t.logs):(o=_w.get(i),void 0!==o?new ww(i,o,t.logs):null)}get program(){var t;return null===(t=this._programErrorStack)||void 0===t?void 0:t.stack[this._programErrorStack.stack.length-1]}get programErrorStack(){var t;return null===(t=this._programErrorStack)||void 0===t?void 0:t.stack}toString(){return this.msg}}function bw(t,e){dw("debug-logs")&&console.log("Translating error:",t);const r=mw.parse(t.logs);if(r)return r;const n=ww.parse(t,e);if(n)return n;if(t.logs){const e={get:function(e,r){return"programErrorStack"===r?e.programErrorStack.stack:"program"===r?e.programErrorStack.stack[t.programErrorStack.stack.length-1]:Reflect.get(...arguments)}};return t.programErrorStack=gw.parse(t.logs),new Proxy(t,e)}return t}const vw={InstructionMissing:100,InstructionFallbackNotFound:101,InstructionDidNotDeserialize:102,InstructionDidNotSerialize:103,IdlInstructionStub:1e3,IdlInstructionInvalidProgram:1001,ConstraintMut:2e3,ConstraintHasOne:2001,ConstraintSigner:2002,ConstraintRaw:2003,ConstraintOwner:2004,ConstraintRentExempt:2005,ConstraintSeeds:2006,ConstraintExecutable:2007,ConstraintState:2008,ConstraintAssociated:2009,ConstraintAssociatedInit:2010,ConstraintClose:2011,ConstraintAddress:2012,ConstraintZero:2013,ConstraintTokenMint:2014,ConstraintTokenOwner:2015,ConstraintMintMintAuthority:2016,ConstraintMintFreezeAuthority:2017,ConstraintMintDecimals:2018,ConstraintSpace:2019,ConstraintAccountIsNone:2020,RequireViolated:2500,RequireEqViolated:2501,RequireKeysEqViolated:2502,RequireNeqViolated:2503,RequireKeysNeqViolated:2504,RequireGtViolated:2505,RequireGteViolated:2506,AccountDiscriminatorAlreadySet:3e3,AccountDiscriminatorNotFound:3001,AccountDiscriminatorMismatch:3002,AccountDidNotDeserialize:3003,AccountDidNotSerialize:3004,AccountNotEnoughKeys:3005,AccountNotMutable:3006,AccountOwnedByWrongProgram:3007,InvalidProgramId:3008,InvalidProgramExecutable:3009,AccountNotSigner:3010,AccountNotSystemOwned:3011,AccountNotInitialized:3012,AccountNotProgramData:3013,AccountNotAssociatedTokenAccount:3014,AccountSysvarMismatch:3015,AccountReallocExceedsLimit:3016,AccountDuplicateReallocs:3017,DeclaredProgramIdMismatch:4100,Deprecated:5e3},_w=new Map([[vw.InstructionMissing,"8 byte instruction identifier not provided"],[vw.InstructionFallbackNotFound,"Fallback functions are not supported"],[vw.InstructionDidNotDeserialize,"The program could not deserialize the given instruction"],[vw.InstructionDidNotSerialize,"The program could not serialize the given instruction"],[vw.IdlInstructionStub,"The program was compiled without idl instructions"],[vw.IdlInstructionInvalidProgram,"The transaction was given an invalid program for the IDL instruction"],[vw.ConstraintMut,"A mut constraint was violated"],[vw.ConstraintHasOne,"A has one constraint was violated"],[vw.ConstraintSigner,"A signer constraint was violated"],[vw.ConstraintRaw,"A raw constraint was violated"],[vw.ConstraintOwner,"An owner constraint was violated"],[vw.ConstraintRentExempt,"A rent exemption constraint was violated"],[vw.ConstraintSeeds,"A seeds constraint was violated"],[vw.ConstraintExecutable,"An executable constraint was violated"],[vw.ConstraintState,"Deprecated Error, feel free to replace with something else"],[vw.ConstraintAssociated,"An associated constraint was violated"],[vw.ConstraintAssociatedInit,"An associated init constraint was violated"],[vw.ConstraintClose,"A close constraint was violated"],[vw.ConstraintAddress,"An address constraint was violated"],[vw.ConstraintZero,"Expected zero account discriminant"],[vw.ConstraintTokenMint,"A token mint constraint was violated"],[vw.ConstraintTokenOwner,"A token owner constraint was violated"],[vw.ConstraintMintMintAuthority,"A mint mint authority constraint was violated"],[vw.ConstraintMintFreezeAuthority,"A mint freeze authority constraint was violated"],[vw.ConstraintMintDecimals,"A mint decimals constraint was violated"],[vw.ConstraintSpace,"A space constraint was violated"],[vw.ConstraintAccountIsNone,"A required account for the constraint is None"],[vw.RequireViolated,"A require expression was violated"],[vw.RequireEqViolated,"A require_eq expression was violated"],[vw.RequireKeysEqViolated,"A require_keys_eq expression was violated"],[vw.RequireNeqViolated,"A require_neq expression was violated"],[vw.RequireKeysNeqViolated,"A require_keys_neq expression was violated"],[vw.RequireGtViolated,"A require_gt expression was violated"],[vw.RequireGteViolated,"A require_gte expression was violated"],[vw.AccountDiscriminatorAlreadySet,"The account discriminator was already set on this account"],[vw.AccountDiscriminatorNotFound,"No 8 byte discriminator was found on the account"],[vw.AccountDiscriminatorMismatch,"8 byte discriminator did not match what was expected"],[vw.AccountDidNotDeserialize,"Failed to deserialize the account"],[vw.AccountDidNotSerialize,"Failed to serialize the account"],[vw.AccountNotEnoughKeys,"Not enough account keys given to the instruction"],[vw.AccountNotMutable,"The given account is not mutable"],[vw.AccountOwnedByWrongProgram,"The given account is owned by a different program than expected"],[vw.InvalidProgramId,"Program ID was not as expected"],[vw.InvalidProgramExecutable,"Program account is not executable"],[vw.AccountNotSigner,"The given account did not sign"],[vw.AccountNotSystemOwned,"The given account is not owned by the system program"],[vw.AccountNotInitialized,"The program expected this account to be already initialized"],[vw.AccountNotProgramData,"The given account is not a program data account"],[vw.AccountNotAssociatedTokenAccount,"The given account is not the associated token account"],[vw.AccountSysvarMismatch,"The given public key does not match the required sysvar"],[vw.AccountReallocExceedsLimit,"The account reallocation exceeds the MAX_PERMITTED_DATA_INCREASE limit"],[vw.AccountDuplicateReallocs,"The account was duplicated for more than one reallocation"],[vw.DeclaredProgramIdMismatch,"The declared program id does not match the actual program id"],[vw.Deprecated,"The API being used is deprecated and should no longer be used"]]);var kw=function(){return kw=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},kw.apply(this,arguments)},Ew=function(){return Ew=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},Ew.apply(this,arguments)};function xw(t){return t.toLowerCase()}var Sw=[/([a-z0-9])([A-Z])/g,/([A-Z])([A-Z][a-z])/g],Aw=/[^A-Z0-9]+/gi;function Iw(t,e,r){return e instanceof RegExp?t.replace(e,r):e.reduce((function(t,e){return t.replace(e,r)}),t)}function Bw(t,e){return void 0===e&&(e={}),function(t,e){void 0===e&&(e={});for(var r=e.splitRegexp,n=void 0===r?Sw:r,i=e.stripRegexp,o=void 0===i?Aw:i,s=e.transform,a=void 0===s?xw:s,u=e.delimiter,c=void 0===u?" ":u,h=Iw(Iw(t,n,"$1\0$2"),o,"\0"),l=0,f=h.length;"\0"===h.charAt(l);)l++;for(;"\0"===h.charAt(f-1);)f--;return h.slice(l,f).split("\0").map(a).join(c)}(t,Ew({delimiter:"."},e))}class Mw{static fieldLayout(t,e){const r=void 0!==t.name?pd(t.name):void 0;switch(t.type){case"bool":return yd.bool(r);case"u8":return yd.u8(r);case"i8":return yd.i8(r);case"u16":return yd.u16(r);case"i16":return yd.i16(r);case"u32":return yd.u32(r);case"i32":return yd.i32(r);case"f32":return yd.f32(r);case"u64":return yd.u64(r);case"i64":return yd.i64(r);case"f64":return yd.f64(r);case"u128":return yd.u128(r);case"i128":return yd.i128(r);case"u256":return yd.u256(r);case"i256":return yd.i256(r);case"bytes":return yd.vecU8(r);case"string":return yd.str(r);case"publicKey":return yd.publicKey(r);default:if("vec"in t.type)return yd.vec(Mw.fieldLayout({name:void 0,type:t.type.vec},e),r);if("option"in t.type)return yd.option(Mw.fieldLayout({name:void 0,type:t.type.option},e),r);if("defined"in t.type){const n=t.type.defined;if(void 0===e)throw new yw("User defined types not provided");const i=e.filter((t=>t.name===n));if(1!==i.length)throw new yw(`Type not found: ${JSON.stringify(t)}`);return Mw.typeDefLayout(i[0],e,r)}if("array"in t.type){let n=t.type.array[0],i=t.type.array[1],o=Mw.fieldLayout({name:void 0,type:n},e);return yd.array(o,i,r)}throw new Error(`Not yet implemented: ${t}`)}}static typeDefLayout(t,e=[],r){if("struct"===t.type.kind){const n=t.type.fields.map((t=>Mw.fieldLayout(t,e)));return yd.struct(n,r)}if("enum"===t.type.kind){let n=t.type.variants.map((t=>{const r=pd(t.name);if(void 0===t.fields)return yd.struct([],r);const n=t.fields.map(((t,r)=>t.hasOwnProperty("name")?Mw.fieldLayout(t,e):Mw.fieldLayout({type:t,name:r.toString()},e)));return yd.struct(n,r)}));return void 0!==r?yd.rustEnum(n).replicate(r):yd.rustEnum(n,r)}throw new Error(`Unknown type kint: ${t}`)}}const Rw="global";class Pw{constructor(t){this.idl=t,this.ixLayout=Pw.parseIxLayout(t);const e=new Map;t.instructions.forEach((t=>{const r=Lw(Rw,t.name);e.set(ld.encode(r),{layout:this.ixLayout.get(t.name),name:t.name})})),this.sighashLayouts=e}encode(t,e){return this._encode(Rw,t,e)}_encode(t,e,r){const i=n.Buffer.alloc(1e3),o=pd(e),s=this.ixLayout.get(o);if(!s)throw new Error(`Unknown method: ${o}`);const a=s.encode(r,i),u=i.slice(0,a);return n.Buffer.concat([Lw(t,e),u])}static parseIxLayout(t){const e=t.instructions.map((e=>{let r=e.args.map((e=>{var r,n;return Mw.fieldLayout(e,Array.from([...null!==(r=t.accounts)&&void 0!==r?r:[],...null!==(n=t.types)&&void 0!==n?n:[]]))}));const n=pd(e.name);return[n,yd.struct(r,n)]}));return new Map(e)}decode(t,e="hex"){"string"==typeof t&&(t="hex"===e?n.Buffer.from(t,"hex"):ld.decode(t));let r=ld.encode(t.slice(0,8)),i=t.slice(8);const o=this.sighashLayouts.get(r);return o?{data:o.layout.decode(i),name:o.name}:null}format(t,e){return Tw.format(t,e,this.idl)}}class Tw{static format(t,e,r){const n=r.instructions.filter((e=>t.name===e.name))[0];if(void 0===n)return console.error("Invalid instruction given"),null;const i=n.args.map((e=>({name:e.name,type:Tw.formatIdlType(e.type),data:Tw.formatIdlData(e,t.data[e.name],r.types)}))),o=Tw.flattenIdlAccounts(n.accounts);return{args:i,accounts:e.map(((t,e)=>e<o.length?{name:o[e].name,...t}:{name:void 0,...t}))}}static formatIdlType(t){if("string"==typeof t)return t;if("vec"in t)return`Vec<${this.formatIdlType(t.vec)}>`;if("option"in t)return`Option<${this.formatIdlType(t.option)}>`;if("defined"in t)return t.defined;if("array"in t)return`Array<${t.array[0]}; ${t.array[1]}>`;throw new Error(`Unknown IDL type: ${t}`)}static formatIdlData(t,e,r){if("string"==typeof t.type)return e.toString();if(t.type.hasOwnProperty("vec"))return"["+e.map((e=>this.formatIdlData({name:"",type:t.type.vec},e))).join(", ")+"]";if(t.type.hasOwnProperty("option"))return null===e?"null":this.formatIdlData({name:"",type:t.type.option},e,r);if(t.type.hasOwnProperty("defined")){if(void 0===r)throw new Error("User defined types not provided");const n=r.filter((e=>e.name===t.type.defined));if(1!==n.length)throw new Error(`Type not found: ${t.type.defined}`);return Tw.formatIdlDataDefined(n[0],e,r)}return"unknown"}static formatIdlDataDefined(t,e,r){if("struct"===t.type.kind){const n=t.type,i=Object.keys(e).map((t=>{const i=n.fields.filter((e=>e.name===t))[0];if(void 0===i)throw new Error("Unable to find type");return t+": "+Tw.formatIdlData(i,e[t],r)})).join(", ");return"{ "+i+" }"}if(0===t.type.variants.length)return"{}";if(t.type.variants[0].name){const n=t.type.variants,i=Object.keys(e)[0],o=e[i],s=Object.keys(o).map((t=>{var e;const s=o[t],a=null===(e=n[i])||void 0===e?void 0:e.filter((e=>e.name===t))[0];if(void 0===a)throw new Error("Unable to find variant");return t+": "+Tw.formatIdlData(a,s,r)})).join(", "),a=pd(i,{pascalCase:!0});return 0===s.length?a:`${a} { ${s} }`}return"Tuple formatting not yet implemented"}static flattenIdlAccounts(t,e){return t.map((t=>{const r=function(t){const e=t.replace(/([A-Z])/g," $1");return e.charAt(0).toUpperCase()+e.slice(1)}(t.name);if(t.hasOwnProperty("accounts")){const n=e?`${e} > ${r}`:r;return Tw.flattenIdlAccounts(t.accounts,n)}return{...t,name:e?`${e} > ${r}`:r}})).flat()}}function Lw(t,e){var r;let i=`${t}:${void 0===r&&(r={}),Bw(e,kw({delimiter:"_"},r))}`;return n.Buffer.from(pe(i).slice(0,8))}function Ow(t,e){if("enum"===e.type.kind){const r=e.type.variants.map((e=>e.fields?e.fields.map((e=>Uw(t,"object"==typeof e&&"name"in e?e.type:e))).reduce(((t,e)=>t+e),0):0));return Math.max(...r)+1}return e.type.fields.map((e=>Uw(t,e.type))).reduce(((t,e)=>t+e),0)}function Uw(t,e){var r,n;switch(e){case"bool":case"u8":case"i8":case"bytes":case"string":return 1;case"i16":case"u16":return 2;case"u32":case"i32":case"f32":return 4;case"u64":case"i64":case"f64":return 8;case"u128":case"i128":return 16;case"u256":case"i256":case"publicKey":return 32;default:if("vec"in e)return 1;if("option"in e)return 1+Uw(t,e.option);if("coption"in e)return 4+Uw(t,e.coption);if("defined"in e){const i=null!==(n=null===(r=t.types)||void 0===r?void 0:r.filter((t=>t.name===e.defined)))&&void 0!==n?n:[];if(1!==i.length)throw new yw(`Type not found: ${JSON.stringify(e)}`);return Ow(t,i[0])}if("array"in e){let r=e.array[0],n=e.array[1];return Uw(t,r)*n}throw new Error(`Invalid type ${JSON.stringify(e)}`)}}const Cw=8;function Nw(t){return Buffer.from(pe(t).slice(0,Cw))}class zw{constructor(t){if(void 0===t.accounts)return void(this.accountLayouts=new Map);const e=t.accounts.map((e=>[e.name,Mw.typeDefLayout(e,t.types)]));this.accountLayouts=new Map(e),this.idl=t}async encode(t,e){const r=n.Buffer.alloc(1e3),i=this.accountLayouts.get(t);if(!i)throw new Error(`Unknown account: ${t}`);const o=i.encode(e,r);let s=r.slice(0,o),a=zw.accountDiscriminator(t);return n.Buffer.concat([a,s])}decode(t,e){if(zw.accountDiscriminator(t).compare(e.slice(0,8)))throw new Error("Invalid account discriminator");return this.decodeUnchecked(t,e)}decodeAny(t){const e=t.slice(0,8),r=Array.from(this.accountLayouts.keys()).find((t=>zw.accountDiscriminator(t).equals(e)));if(!r)throw new Error("Account descriminator not found");return this.decodeUnchecked(r,t)}decodeUnchecked(t,e){const r=e.subarray(Cw),n=this.accountLayouts.get(t);if(!n)throw new Error(`Unknown account: ${t}`);return n.decode(r)}memcmp(t,e){const r=zw.accountDiscriminator(t);return{offset:0,bytes:ld.encode(e?n.Buffer.concat([r,e]):r)}}size(t){var e;return Cw+(null!==(e=Ow(this.idl,t))&&void 0!==e?e:0)}static accountDiscriminator(t){return Nw(`account:${pd(t,{pascalCase:!0,preserveConsecutiveUppercase:!0})}`)}}class Dw{constructor(t){if(void 0===t.events)return void(this.layouts=new Map);const e=t.events.map((e=>{let r={name:e.name,type:{kind:"struct",fields:e.fields.map((t=>({name:t.name,type:t.type})))}};return[e.name,Mw.typeDefLayout(r,t.types)]}));this.layouts=new Map(e),this.discriminators=new Map(void 0===t.events?[]:t.events.map((t=>[s(jw(t.name)),t.name])))}decode(t){let e;try{e=n.Buffer.from(o(t))}catch(t){return null}const r=s(e.slice(0,8)),i=this.discriminators.get(r);if(void 0===i)return null;const a=this.layouts.get(i);if(!a)throw new Error(`Unknown event: ${i}`);return{data:a.decode(e.slice(8)),name:i}}}function jw(t){return Nw(`event:${t}`)}class Ww{constructor(t){if(void 0===t.types)return void(this.typeLayouts=new Map);const e=t.types.map((e=>[e.name,Mw.typeDefLayout(e,t.types)]));this.typeLayouts=new Map(e),this.idl=t}encode(t,e){const r=n.Buffer.alloc(1e3),i=this.typeLayouts.get(t);if(!i)throw new Error(`Unknown type: ${t}`);const o=i.encode(e,r);return r.slice(0,o)}decode(t,e){const r=this.typeLayouts.get(t);if(!r)throw new Error(`Unknown type: ${t}`);return r.decode(e)}}class Fw{constructor(t){this.instruction=new Pw(t),this.accounts=new zw(t),this.events=new Dw(t),this.types=new Ww(t)}}var Kw="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Vw(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}class qw{constructor(t,e){if(!Number.isInteger(t))throw new TypeError("span must be an integer");this.span=t,this.property=e}makeDestinationObject(){return{}}decode(t,e){throw new Error("Layout is abstract")}encode(t,e,r){throw new Error("Layout is abstract")}getSpan(t,e){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(t){const e=Object.create(this.constructor.prototype);return Object.assign(e,this),e.property=t,e}fromArray(t){}}var Hw=qw;class $w extends qw{isCount(){throw new Error("ExternalLayout is abstract")}}class Gw extends $w{constructor(t,e,r){if(!(t instanceof qw))throw new TypeError("layout must be a Layout");if(void 0===e)e=0;else if(!Number.isInteger(e))throw new TypeError("offset must be integer or undefined");super(t.span,r||t.property),this.layout=t,this.offset=e}isCount(){return this.layout instanceof Zw||this.layout instanceof Yw}decode(t,e){return void 0===e&&(e=0),this.layout.decode(t,e+this.offset)}encode(t,e,r){return void 0===r&&(r=0),this.layout.encode(t,e,r+this.offset)}}class Zw extends qw{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return void 0===e&&(e=0),t.readUIntLE(e,this.span)}encode(t,e,r){return void 0===r&&(r=0),e.writeUIntLE(t,r,this.span),this.span}}class Yw extends qw{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return void 0===e&&(e=0),t.readUIntBE(e,this.span)}encode(t,e,r){return void 0===r&&(r=0),e.writeUIntBE(t,r,this.span),this.span}}const Jw=Math.pow(2,32);function Xw(t){const e=Math.floor(t/Jw);return{hi32:e,lo32:t-e*Jw}}function Qw(t,e){return t*Jw+e}class tb extends qw{constructor(t){super(8,t)}decode(t,e){void 0===e&&(e=0);const r=t.readUInt32LE(e);return Qw(t.readUInt32LE(e+4),r)}encode(t,e,r){void 0===r&&(r=0);const n=Xw(t);return e.writeUInt32LE(n.lo32,r),e.writeUInt32LE(n.hi32,r+4),8}}class eb extends qw{constructor(t){super(8,t)}decode(t,e){void 0===e&&(e=0);const r=t.readUInt32LE(e);return Qw(t.readInt32LE(e+4),r)}encode(t,e,r){void 0===r&&(r=0);const n=Xw(t);return e.writeUInt32LE(n.lo32,r),e.writeInt32LE(n.hi32,r+4),8}}class rb extends qw{constructor(t,e,r){if(!Array.isArray(t)||!t.reduce(((t,e)=>t&&e instanceof qw),!0))throw new TypeError("fields must be array of Layout instances");"boolean"==typeof e&&void 0===r&&(r=e,e=void 0);for(const e of t)if(0>e.span&&void 0===e.property)throw new Error("fields cannot contain unnamed variable-length layout");let n=-1;try{n=t.reduce(((t,e)=>t+e.getSpan()),0)}catch(t){}super(n,e),this.fields=t,this.decodePrefixes=!!r}getSpan(t,e){if(0<=this.span)return this.span;void 0===e&&(e=0);let r=0;try{r=this.fields.reduce(((r,n)=>{const i=n.getSpan(t,e);return e+=i,r+i}),0)}catch(t){throw new RangeError("indeterminate span")}return r}decode(t,e){void 0===e&&(e=0);const r=this.makeDestinationObject();for(const n of this.fields)if(void 0!==n.property&&(r[n.property]=n.decode(t,e)),e+=n.getSpan(t,e),this.decodePrefixes&&t.length===e)break;return r}encode(t,e,r){void 0===r&&(r=0);const n=r;let i=0,o=0;for(const n of this.fields){let s=n.span;if(o=0<s?s:0,void 0!==n.property){const i=t[n.property];void 0!==i&&(o=n.encode(i,e,r),0>s&&(s=n.getSpan(e,r)))}i=r,r+=s}return i+o-n}fromArray(t){const e=this.makeDestinationObject();for(const r of this.fields)void 0!==r.property&&0<t.length&&(e[r.property]=t.shift());return e}layoutFor(t){if("string"!=typeof t)throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}offsetOf(t){if("string"!=typeof t)throw new TypeError("property must be string");let e=0;for(const r of this.fields){if(r.property===t)return e;0>r.span?e=-1:0<=e&&(e+=r.span)}}}class nb{constructor(t){this.property=t}decode(){throw new Error("UnionDiscriminator is abstract")}encode(){throw new Error("UnionDiscriminator is abstract")}}class ib extends nb{constructor(t,e){if(!(t instanceof $w&&t.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(e||t.property||"variant"),this.layout=t}decode(t,e){return this.layout.decode(t,e)}encode(t,e,r){return this.layout.encode(t,e,r)}}class ob extends qw{constructor(t,e,r){const n=t instanceof Zw||t instanceof Yw;if(n)t=new ib(new Gw(t));else if(t instanceof $w&&t.isCount())t=new ib(t);else if(!(t instanceof nb))throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(void 0===e&&(e=null),!(null===e||e instanceof qw))throw new TypeError("defaultLayout must be null or a Layout");if(null!==e){if(0>e.span)throw new Error("defaultLayout must have constant span");void 0===e.property&&(e=e.replicate("content"))}let i=-1;e&&(i=e.span,0<=i&&n&&(i+=t.layout.span)),super(i,r),this.discriminator=t,this.usesPrefixDiscriminator=n,this.defaultLayout=e,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(t){return o(t)},this.configGetSourceVariant=function(t){o=t.bind(this)}}getSpan(t,e){if(0<=this.span)return this.span;void 0===e&&(e=0);const r=this.getVariant(t,e);if(!r)throw new Error("unable to determine span for unrecognized variant");return r.getSpan(t,e)}defaultGetSourceVariant(t){if(t.hasOwnProperty(this.discriminator.property)){if(this.defaultLayout&&t.hasOwnProperty(this.defaultLayout.property))return;const e=this.registry[t[this.discriminator.property]];if(e&&(!e.layout||t.hasOwnProperty(e.property)))return e}else for(const e in this.registry){const r=this.registry[e];if(t.hasOwnProperty(r.property))return r}throw new Error("unable to infer src variant")}decode(t,e){let r;void 0===e&&(e=0);const n=this.discriminator,i=n.decode(t,e);let o=this.registry[i];if(void 0===o){let s=0;o=this.defaultLayout,this.usesPrefixDiscriminator&&(s=n.layout.span),r=this.makeDestinationObject(),r[n.property]=i,r[o.property]=this.defaultLayout.decode(t,e+s)}else r=o.decode(t,e);return r}encode(t,e,r){void 0===r&&(r=0);const n=this.getSourceVariant(t);if(void 0===n){const n=this.discriminator,i=this.defaultLayout;let o=0;return this.usesPrefixDiscriminator&&(o=n.layout.span),n.encode(t[n.property],e,r),o+i.encode(t[i.property],e,r+o)}return n.encode(t,e,r)}addVariant(t,e,r){const n=new sb(this,t,e,r);return this.registry[t]=n,n}getVariant(t,e){let r=t;return Buffer.isBuffer(t)&&(void 0===e&&(e=0),r=this.discriminator.decode(t,e)),this.registry[r]}}class sb extends qw{constructor(t,e,r,n){if(!(t instanceof ob))throw new TypeError("union must be a Union");if(!Number.isInteger(e)||0>e)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 qw))throw new TypeError("layout must be a Layout");if(null!==t.defaultLayout&&0<=r.span&&r.span>t.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=t.span;0>t.span&&(i=r?r.span:0,0<=i&&t.usesPrefixDiscriminator&&(i+=t.discriminator.layout.span)),super(i,n),this.union=t,this.variant=e,this.layout=r||null}getSpan(t,e){if(0<=this.span)return this.span;void 0===e&&(e=0);let r=0;return this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span),r+this.layout.getSpan(t,e+r)}decode(t,e){const r=this.makeDestinationObject();if(void 0===e&&(e=0),this!==this.union.getVariant(t,e))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(t,e+n):this.property?r[this.property]=!0:this.union.usesPrefixDiscriminator&&(r[this.union.discriminator.property]=this.variant),r}encode(t,e,r){void 0===r&&(r=0);let n=0;if(this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span),this.layout&&!t.hasOwnProperty(this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,e,r);let i=n;if(this.layout&&(this.layout.encode(t[this.property],e,r+n),i+=this.layout.getSpan(e,r+n),0<=this.union.span&&i>this.union.span))throw new Error("encoded variant overruns containing union");return i}fromArray(t){if(this.layout)return this.layout.fromArray(t)}}class ab extends qw{constructor(t,e){if(!(t instanceof $w&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let r=-1;t instanceof $w||(r=t),super(r,e),this.length=t}getSpan(t,e){let r=this.span;return 0>r&&(r=this.length.decode(t,e)),r}decode(t,e){void 0===e&&(e=0);let r=this.span;return 0>r&&(r=this.length.decode(t,e)),t.slice(e,e+r)}encode(t,e,r){let n=this.length;if(this.length instanceof $w&&(n=t.length),!Buffer.isBuffer(t)||n!==t.length)throw new TypeError(function(t,e){return e.property?t+"["+e.property+"]":t}("Blob.encode",this)+" requires (length "+n+") Buffer as src");if(r+n>e.length)throw new RangeError("encoding overruns Buffer");return e.write(t.toString("hex"),r,n,"hex"),this.length instanceof $w&&this.length.encode(n,e,r),n}}var ub=(t,e,r)=>new Gw(t,e,r),cb=t=>new Zw(4,t),hb=t=>new eb(t),lb=(t,e,r)=>new rb(t,e,r),fb=(t,e,r)=>new ob(t,e,r),db=(t,e)=>new ab(t,e);class pb{constructor(t){}encode(t,e){switch(pd(t)){case"createAccount":return function({lamports:t,space:e,owner:r}){return bb({createAccount:{lamports:t,space:e,owner:r.toBuffer()}})}(e);case"assign":return function({owner:t}){return bb({assign:{owner:t.toBuffer()}})}(e);case"transfer":return function({lamports:t}){return bb({transfer:{lamports:t}})}(e);case"createAccountWithSeed":return function({base:t,seed:e,lamports:r,space:n,owner:i}){return bb({createAccountWithSeed:{base:t.toBuffer(),seed:e,lamports:r,space:n,owner:i.toBuffer()}},wb.getVariant(3).span+e.length)}(e);case"advanceNonceAccount":return function({authorized:t}){return bb({advanceNonceAccount:{authorized:t.toBuffer()}})}(e);case"withdrawNonceAccount":return function({lamports:t}){return bb({withdrawNonceAccount:{lamports:t}})}(e);case"initializeNonceAccount":return function({authorized:t}){return bb({initializeNonceAccount:{authorized:t.toBuffer()}})}(e);case"authorizeNonceAccount":return function({authorized:t}){return bb({authorizeNonceAccount:{authorized:t.toBuffer()}})}(e);case"allocate":return function({space:t}){return bb({allocate:{space:t}})}(e);case"allocateWithSeed":return function({base:t,seed:e,space:r,owner:n}){return bb({allocateWithSeed:{base:t.toBuffer(),seed:e,space:r,owner:n.toBuffer()}},wb.getVariant(9).span+e.length)}(e);case"assignWithSeed":return function({base:t,seed:e,owner:r}){return bb({assignWithSeed:{base:t.toBuffer(),seed:e,owner:r.toBuffer()}},wb.getVariant(10).span+e.length)}(e);case"transferWithSeed":return function({lamports:t,seed:e,owner:r}){return bb({transferWithSeed:{lamports:t,seed:e,owner:r.toBuffer()}},wb.getVariant(11).span+e.length)}(e);default:throw new Error(`Invalid instruction: ${t}`)}}encodeState(t,e){throw new Error("System does not have state")}}class yb extends Hw{constructor(t){super(-1,t),this.property=t,this.layout=lb([cb("length"),cb("lengthPadding"),db(ub(cb(),-8),"chars")],this.property)}encode(t,e,r=0){if(null==t)return this.layout.span;const n={chars:Buffer.from(t,"utf8")};return this.layout.encode(n,e,r)}decode(t,e=0){return this.layout.decode(t,e).chars.toString()}getSpan(t,e=0){return cb().span+cb().span+new ne(new Uint8Array(t).slice(e,e+4),10,"le").toNumber()}}function gb(t){return new yb(t)}function mb(t){return db(32,t)}const wb=fb(cb("instruction"));function bb(t,e){const r=Buffer.alloc(null!=e?e:vb),n=wb.encode(t,r);return void 0===e?r.slice(0,n):r}wb.addVariant(0,lb([hb("lamports"),hb("space"),mb("owner")]),"createAccount"),wb.addVariant(1,lb([mb("owner")]),"assign"),wb.addVariant(2,lb([hb("lamports")]),"transfer"),wb.addVariant(3,lb([mb("base"),gb("seed"),hb("lamports"),hb("space"),mb("owner")]),"createAccountWithSeed"),wb.addVariant(4,lb([mb("authorized")]),"advanceNonceAccount"),wb.addVariant(5,lb([hb("lamports")]),"withdrawNonceAccount"),wb.addVariant(6,lb([mb("authorized")]),"initializeNonceAccount"),wb.addVariant(7,lb([mb("authorized")]),"authorizeNonceAccount"),wb.addVariant(8,lb([hb("space")]),"allocate"),wb.addVariant(9,lb([mb("base"),gb("seed"),hb("space"),mb("owner")]),"allocateWithSeed"),wb.addVariant(10,lb([mb("base"),gb("seed"),mb("owner")]),"assignWithSeed"),wb.addVariant(11,lb([hb("lamports"),gb("seed"),mb("owner")]),"transferWithSeed");const vb=Math.max(...Object.values(wb.registry).map((t=>t.span)));class _b{constructor(t){this.idl=t}async encode(t,e){if("nonce"===t){const t=Buffer.alloc(Bs),r=xb.encode(e,t);return t.slice(0,r)}throw new Error(`Invalid account name: ${t}`)}decode(t,e){return this.decodeUnchecked(t,e)}decodeUnchecked(t,e){if("nonce"===t)return function(t){return xb.decode(t)}(e);throw new Error(`Invalid account name: ${t}`)}memcmp(t,e){if("nonce"===t)return{dataSize:Bs};throw new Error(`Invalid account name: ${t}`)}size(t){var e;return null!==(e=Ow(this.idl,t))&&void 0!==e?e:0}}class kb extends Hw{constructor(t,e,r,n){super(t.span,n),this.layout=t,this.decoder=e,this.encoder=r}decode(t,e){return this.decoder(this.layout.decode(t,e))}encode(t,e,r){return this.layout.encode(this.encoder(t),e,r)}getSpan(t,e){return this.layout.getSpan(t,e)}}function Eb(t){return new kb(db(32),(t=>new Wo(t)),(t=>t.toBuffer()),t)}const xb=lb([cb("version"),cb("state"),Eb("authorizedPubkey"),Eb("nonce"),lb([(Sb="lamportsPerSignature",new tb(Sb))],"feeCalculator")]);var Sb;class Ab{constructor(t){}decode(t){throw new Error("System program does not have events")}}class Ib{constructor(t){}encode(t,e){throw new Error("System does not have user-defined types")}decode(t,e){throw new Error("System does not have user-defined types")}}class Bb{constructor(t){this.instruction=new pb(t),this.accounts=new _b(t),this.events=new Ab(t),this.types=new Ib(t)}}var Mb=Object.freeze({__proto__:null,hash:function(t){return(new TextDecoder).decode(pe(t))}});function Rb(t,...e){let r=[n.Buffer.from([97,110,99,104,111,114])];e.forEach((t=>{r.push(t instanceof n.Buffer?t:Bm(t).toBuffer())}));const[i]=Wo.findProgramAddressSync(r,Bm(t));return i}var Pb=Object.freeze({__proto__:null,createWithSeedSync:function(t,e,r){const i=n.Buffer.concat([t.toBuffer(),n.Buffer.from(e),r.toBuffer()]);return new Wo(pe(i))},associated:Rb});const Tb=new Wo("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"),Lb=new Wo("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");var Ob=Object.freeze({__proto__:null,TOKEN_PROGRAM_ID:Tb,ASSOCIATED_PROGRAM_ID:Lb,associatedAddress:function({mint:t,owner:e}){return Wo.findProgramAddressSync([e.toBuffer(),Tb.toBuffer(),t.toBuffer()],Lb)[0]}}),Ub={exports:{}};!function(t,e){var r="undefined"!=typeof self?self:Kw,n=function(){function t(){this.fetch=!1,this.DOMException=r.DOMException}return t.prototype=r,new t}();!function(t){!function(e){var r="URLSearchParams"in t,n="Symbol"in t&&"iterator"in Symbol,i="FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),o="FormData"in t,s="ArrayBuffer"in t;if(s)var a=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],u=ArrayBuffer.isView||function(t){return t&&a.indexOf(Object.prototype.toString.call(t))>-1};function c(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function h(t){return"string"!=typeof t&&(t=String(t)),t}function l(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return n&&(e[Symbol.iterator]=function(){return e}),e}function f(t){this.map={},t instanceof f?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function d(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function p(t){return new Promise((function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}}))}function y(t){var e=new FileReader,r=p(e);return e.readAsArrayBuffer(t),r}function g(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function m(){return this.bodyUsed=!1,this._initBody=function(t){var e;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:i&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:o&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:r&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():s&&i&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=g(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):s&&(ArrayBuffer.prototype.isPrototypeOf(t)||u(t))?this._bodyArrayBuffer=g(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},i&&(this.blob=function(){var t=d(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?d(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(y)}),this.text=function(){var t=d(this);if(t)return t;if(this._bodyBlob)return function(t){var e=new FileReader,r=p(e);return e.readAsText(t),r}(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n<e.length;n++)r[n]=String.fromCharCode(e[n]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},o&&(this.formData=function(){return this.text().then(v)}),this.json=function(){return this.text().then(JSON.parse)},this}f.prototype.append=function(t,e){t=c(t),e=h(e);var r=this.map[t];this.map[t]=r?r+", "+e:e},f.prototype.delete=function(t){delete this.map[c(t)]},f.prototype.get=function(t){return t=c(t),this.has(t)?this.map[t]:null},f.prototype.has=function(t){return this.map.hasOwnProperty(c(t))},f.prototype.set=function(t,e){this.map[c(t)]=h(e)},f.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},f.prototype.keys=function(){var t=[];return this.forEach((function(e,r){t.push(r)})),l(t)},f.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),l(t)},f.prototype.entries=function(){var t=[];return this.forEach((function(e,r){t.push([r,e])})),l(t)},n&&(f.prototype[Symbol.iterator]=f.prototype.entries);var w=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function b(t,e){var r,n,i=(e=e||{}).body;if(t instanceof b){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new f(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,i||null==t._bodyInit||(i=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new f(e.headers)),this.method=(r=e.method||this.method||"GET",n=r.toUpperCase(),w.indexOf(n)>-1?n:r),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function v(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(i))}})),e}function _(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new f(e.headers),this.url=e.url||"",this._initBody(t)}b.prototype.clone=function(){return new b(this,{body:this._bodyInit})},m.call(b.prototype),m.call(_.prototype),_.prototype.clone=function(){return new _(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},_.error=function(){var t=new _(null,{status:0,statusText:""});return t.type="error",t};var k=[301,302,303,307,308];_.redirect=function(t,e){if(-1===k.indexOf(e))throw new RangeError("Invalid status code");return new _(null,{status:e,headers:{location:t}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function E(t,r){return new Promise((function(n,o){var s=new b(t,r);if(s.signal&&s.signal.aborted)return o(new e.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function u(){a.abort()}a.onload=function(){var t,e,r={status:a.status,statusText:a.statusText,headers:(t=a.getAllResponseHeaders()||"",e=new f,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var r=t.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();e.append(n,i)}})),e)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var i="response"in a?a.response:a.responseText;n(new _(i,r))},a.onerror=function(){o(new TypeError("Network request failed"))},a.ontimeout=function(){o(new TypeError("Network request failed"))},a.onabort=function(){o(new e.DOMException("Aborted","AbortError"))},a.open(s.method,s.url,!0),"include"===s.credentials?a.withCredentials=!0:"omit"===s.credentials&&(a.withCredentials=!1),"responseType"in a&&i&&(a.responseType="blob"),s.headers.forEach((function(t,e){a.setRequestHeader(e,t)})),s.signal&&(s.signal.addEventListener("abort",u),a.onreadystatechange=function(){4===a.readyState&&s.signal.removeEventListener("abort",u)}),a.send(void 0===s._bodyInit?null:s._bodyInit)}))}E.polyfill=!0,t.fetch||(t.fetch=E,t.Headers=f,t.Request=b,t.Response=_),e.Headers=f,e.Request=b,e.Response=_,e.fetch=E,Object.defineProperty(e,"__esModule",{value:!0})}({})}(n),n.fetch.ponyfill=!0,delete n.fetch.polyfill;var i=n;(e=i.fetch).default=i.fetch,e.fetch=i.fetch,e.Headers=i.Headers,e.Request=i.Request,e.Response=i.Response,t.exports=e}(Ub,Ub.exports);var Cb=Vw(Ub.exports);async function Nb(t,e){const r=await t.getAccountInfo(e);if(null===r)throw new Error("program account not found");const{program:n}=Db(r.data),i=await t.getAccountInfo(n.programdataAddress);if(null===i)throw new Error("program data account not found");const{programData:o}=Db(i.data);return o}const zb=yd.rustEnum([yd.struct([],"uninitialized"),yd.struct([yd.option(yd.publicKey(),"authorityAddress")],"buffer"),yd.struct([yd.publicKey("programdataAddress")],"program"),yd.struct([yd.u64("slot"),yd.option(yd.publicKey(),"upgradeAuthorityAddress")],"programData")],void 0,yd.u32());function Db(t){return zb.decode(t)}var jb=Object.freeze({__proto__:null,verifiedBuild:async function(t,e,r=5){const n=`https://api.apr.dev/api/v0/program/${e.toString()}/latest?limit=${r}`,[i,o]=await Promise.all([Nb(t,e),Cb(n)]),s=(await o.json()).filter((t=>!t.aborted&&"Built"===t.state&&"Verified"===t.verified));if(0===s.length)return null;const a=s[0];return i.slot.toNumber()!==a.verified_slot?null:a},fetchData:Nb,decodeUpgradeableLoaderState:Db}),Wb=Object.freeze({__proto__:null,sha256:Mb,rpc:iw,publicKey:Pb,bytes:xm,token:Ob,features:pw,registry:jb});function Fb(t){return"accounts"in t}const Kb=yd.struct([yd.publicKey("authority"),yd.vecU8("data")]);function Vb(t,e){var r,n;let i={};const o=t.args?t.args.length:0;if(e.length>o){if(e.length!==o+1)throw new Error(`provided too many arguments ${e} to instruction ${null==t?void 0:t.name} expecting: ${null!==(n=null===(r=t.args)||void 0===r?void 0:r.map((t=>t.name)))&&void 0!==n?n:[]}`);i=e.pop()}return[e,i]}class qb{static build(t,e,r){if("_inner"===t.name)throw new yw("the _inner name is reserved");const n=(...i)=>{const[o,s]=Vb(t,[...i]);Im(t.accounts,s.accounts);const a=n.accounts(s.accounts);return void 0!==s.remainingAccounts&&a.push(...s.remainingAccounts),dw("debug-logs")&&console.log("Outgoing account metas:",a),new cs({keys:a,programId:r,data:e(t.name,Am(t,...o))})};return n.accounts=e=>qb.accountsArray(e,t.accounts,r,t.name),n}static accountsArray(t,e,r,n){return t?e.map((e=>{if(void 0!==("accounts"in e?e.accounts:void 0)){const i=t[e.name];return qb.accountsArray(i,e.accounts,r,n).flat()}{const i=e;let o;try{o=Bm(t[e.name])}catch(t){throw new Error(`Wrong input type for account "${e.name}" in the instruction accounts object${void 0!==n?' for instruction "'+n+'"':""}. Expected PublicKey or string.`)}const s=i.isOptional&&o.equals(r);return{pubkey:o,isWritable:i.isMut&&!s,isSigner:i.isSigner&&!s}}})).flat():[]}}class Hb{static build(t,e){return(...r)=>{var n,i,o;const[,s]=Vb(t,[...r]),a=new hs;if(s.preInstructions&&s.instructions)throw new Error("instructions is deprecated, use preInstructions");return null===(n=s.preInstructions)||void 0===n||n.forEach((t=>a.add(t))),null===(i=s.instructions)||void 0===i||i.forEach((t=>a.add(t))),a.add(e(...r)),null===(o=s.postInstructions)||void 0===o||o.forEach((t=>a.add(t))),a}}}class $b{static build(t,e,r,n){return async(...i)=>{var o;const s=e(...i),[,a]=Vb(t,[...i]);if(void 0===n.sendAndConfirm)throw new Error("This function requires 'Provider.sendAndConfirm' to be implemented.");try{return await n.sendAndConfirm(s,null!==(o=a.signers)&&void 0!==o?o:[],a.options)}catch(t){throw bw(t,r)}}}}class Gb{static build(t,e,r,n){var i;const o={};return null===(i=t.accounts)||void 0===i||i.forEach((i=>{const s=pd(i.name);o[s]=new Zb(t,i,r,n,e)})),o}}class Zb{get size(){return this._size}get programId(){return this._programId}get provider(){return this._provider}get coder(){return this._coder}get idlAccount(){return this._idlAccount}constructor(t,e,r,n,i){this._idlAccount=e,this._programId=r,this._provider=null!=n?n:cw(),this._coder=null!=i?i:new Fw(t),this._size=this._coder.accounts.size(e)}async fetchNullable(t,e){const{data:r}=await this.fetchNullableAndContext(t,e);return r}async fetchNullableAndContext(t,e){const r=await this.getAccountInfoAndContext(t,e),{value:n,context:i}=r;return{data:n&&0!==n.data.length?this._coder.accounts.decode(this._idlAccount.name,n.data):null,context:i}}async fetch(t,e){const{data:r}=await this.fetchNullableAndContext(t,e);if(null===r)throw new Error(`Account does not exist or has no data ${t.toString()}`);return r}async fetchAndContext(t,e){const{data:r,context:n}=await this.fetchNullableAndContext(t,e);if(null===r)throw new Error(`Account does not exist ${t.toString()}`);return{data:r,context:n}}async fetchMultiple(t,e){return(await this.fetchMultipleAndContext(t,e)).map((t=>t?t.data:null))}async fetchMultipleAndContext(t,e){return(await Ym(this._provider.connection,t.map((t=>Bm(t))),e)).map((t=>{if(null==t)return null;const{account:e,context:r}=t;return{data:this._coder.accounts.decode(this._idlAccount.name,e.data),context:r}}))}async all(t){const e=this.coder.accounts.memcmp(this._idlAccount.name,t instanceof Buffer?t:void 0),r=[];return null!=(null==e?void 0:e.offset)&&null!=(null==e?void 0:e.bytes)&&r.push({memcmp:{offset:e.offset,bytes:e.bytes}}),null!=(null==e?void 0:e.dataSize)&&r.push({dataSize:e.dataSize}),(await this._provider.connection.getProgramAccounts(this._programId,{commitment:this._provider.connection.commitment,filters:[...r,...Array.isArray(t)?t:[]]})).map((({pubkey:t,account:e})=>({publicKey:t,account:this._coder.accounts.decode(this._idlAccount.name,e.data)})))}subscribe(t,e){const r=Yb.get(t.toString());if(r)return r.ee;const n=new pm;t=Bm(t);const i=this._provider.connection.onAccountChange(t,(t=>{const e=this._coder.accounts.decode(this._idlAccount.name,t.data);n.emit("change",e)}),e);return Yb.set(t.toString(),{ee:n,listener:i}),n}async unsubscribe(t){let e=Yb.get(t.toString());e?Yb&&await this._provider.connection.removeAccountChangeListener(e.listener).then((()=>{Yb.delete(t.toString())})).catch(console.error):console.warn("Address is not subscribed")}async createInstruction(t,e){const r=this.size;if(void 0===this._provider.publicKey)throw new Error("This function requires the Provider interface implementor to have a 'publicKey' field.");return Ls.createAccount({fromPubkey:this._provider.publicKey,newAccountPubkey:t.publicKey,space:null!=e?e:r,lamports:await this._provider.connection.getMinimumBalanceForRentExemption(null!=e?e:r),programId:this._programId})}async associated(...t){const e=await this.associatedAddress(...t);return await this.fetch(e)}async associatedAddress(...t){return await Rb(this._programId,...t)}async getAccountInfo(t,e){return await this._provider.connection.getAccountInfo(Bm(t),e)}async getAccountInfoAndContext(t,e){return await this._provider.connection.getAccountInfoAndContext(Bm(t),e)}}const Yb=new Map,Jb="Program log: ",Xb="Program data: ";class Qb{constructor(t,e,r){this._programId=t,this._provider=e,this._eventParser=new tv(t,r),this._eventCallbacks=new Map,this._eventListeners=new Map,this._listenerIdCount=0}addEventListener(t,e){var r;let n=this._listenerIdCount;return this._listenerIdCount+=1,this._eventListeners.has(t)||this._eventListeners.set(t,[]),this._eventListeners.set(t,(null!==(r=this._eventListeners.get(t))&&void 0!==r?r:[]).concat(n)),this._eventCallbacks.set(n,[t,e]),void 0!==this._onLogsSubscriptionId||(this._onLogsSubscriptionId=this._provider.connection.onLogs(this._programId,((t,e)=>{if(!t.err)for(const r of this._eventParser.parseLogs(t.logs)){const n=this._eventListeners.get(r.name);n&&n.forEach((n=>{const i=this._eventCallbacks.get(n);if(i){const[,n]=i;n(r.data,e.slot,t.signature)}}))}}))),n}async removeEventListener(t){const e=this._eventCallbacks.get(t);if(!e)throw new Error(`Event listener ${t} doesn't exist!`);const[r]=e;let n=this._eventListeners.get(r);if(!n)throw new Error(`Event listeners don't exist for ${r}!`);if(this._eventCallbacks.delete(t),n=n.filter((e=>e!==t)),this._eventListeners.set(r,n),0===n.length&&this._eventListeners.delete(r),0===this._eventCallbacks.size){if(0!==this._eventListeners.size)throw new Error(`Expected event listeners size to be 0 but got ${this._eventListeners.size}`);void 0!==this._onLogsSubscriptionId&&(await this._provider.connection.removeOnLogsListener(this._onLogsSubscriptionId),this._onLogsSubscriptionId=void 0)}}}class tv{constructor(t,e){this.coder=e,this.programId=t}*parseLogs(t,e=!1){const r=new rv(t),n=new ev;let i=r.next();for(;null!==i;){let[t,o,s]=this.handleLog(n,i,e);t&&(yield t),o&&n.push(o),s&&n.pop(),i=r.next()}}handleLog(t,e,r){return t.stack.length>0&&t.program()===this.programId.toString()?this.handleProgramLog(e,r):[null,...this.handleSystemLog(e)]}handleProgramLog(t,e){if(t.startsWith(Jb)||t.startsWith(Xb)){const r=t.startsWith(Jb)?t.slice(13):t.slice(14),n=this.coder.events.decode(r);if(e&&null===n)throw new Error(`Unable to decode event ${r}`);return[n,null,!1]}return[null,...this.handleSystemLog(t)]}handleSystemLog(t){const e=t.split(":")[0];return null!==e.match(/^Program (.*) success/g)?[null,!0]:e.startsWith(`Program ${this.programId.toString()} invoke`)?[this.programId.toString(),!1]:e.includes("invoke")?["cpi",!1]:[null,!1]}}class ev{constructor(){this.stack=[]}program(){if(!this.stack.length)throw new Error("Expected the stack to have elements");return this.stack[this.stack.length-1]}push(t){this.stack.push(t)}pop(){if(!this.stack.length)throw new Error("Expected the stack to have elements");this.stack.pop()}}class rv{constructor(t){this.logs=t}next(){if(0===this.logs.length)return null;let t=this.logs[0];return this.logs=this.logs.slice(1),t}}class nv{static build(t,e,r,n,i,o,s){return async(...a)=>{var u;const c=e(...a),[,h]=Vb(t,[...a]);let l;if(void 0===n.simulate)throw new Error("This function requires 'Provider.simulate' to be implemented.");try{l=await n.simulate(c,h.signers,null===(u=h.options)||void 0===u?void 0:u.commitment)}catch(t){throw bw(t,r)}if(void 0===l)throw new Error("Unable to simulate transaction");const f=l.logs;if(!f)throw new Error("Simulated logs not found");const d=[];if(s.events){let t=new tv(o,i);for(const e of t.parseLogs(f))d.push(e)}return{events:d,raw:f}}}}function iv(t){return new av(db(8),(t=>cv.fromBuffer(t)),(t=>t.toBuffer()),t)}function ov(t){return new av(db(32),(t=>new Wo(t)),(t=>t.toBuffer()),t)}function sv(t,e){return new uv(t,e)}class av extends Hw{constructor(t,e,r,n){super(t.span,n),this.layout=t,this.decoder=e,this.encoder=r}decode(t,e){return this.decoder(this.layout.decode(t,e))}encode(t,e,r){return this.layout.encode(this.encoder(t),e,r)}getSpan(t,e){return this.layout.getSpan(t,e)}}class uv extends Hw{constructor(t,e){super(-1,e),this.layout=t,this.discriminator=cb()}encode(t,e,r=0){return null==t?this.layout.span+this.discriminator.encode(0,e,r):(this.discriminator.encode(1,e,r),this.layout.encode(t,e,r+4)+4)}decode(t,e=0){const r=this.discriminator.decode(t,e);if(0===r)return null;if(1===r)return this.layout.decode(t,e+4);throw new Error("Invalid coption "+this.layout.property)}getSpan(t,e=0){return this.layout.getSpan(t,e+4)+4}}class cv extends ne{toBuffer(){const t=super.toArray().reverse(),e=Buffer.from(t);if(8===e.length)return e;if(e.length>=8)throw new Error("u64 too large");const r=Buffer.alloc(8);return e.copy(r),r}static fromBuffer(t){if(8!==t.length)throw new Error(`Invalid buffer length: ${t.length}`);return new cv([...t].reverse().map((t=>`00${t.toString(16)}`.slice(-2))).join(""),16)}}const hv=lb([ov("mint"),ov("owner"),iv("amount"),sv(ov(),"delegate"),(t=>{const e=fb((t=>new Zw(1,t))("discriminator"),null,"state");return e.addVariant(0,lb([]),"uninitialized"),e.addVariant(1,lb([]),"initialized"),e.addVariant(2,lb([]),"frozen"),e})(),sv(iv(),"isNative"),iv("delegatedAmount"),sv(ov(),"closeAuthority")]);class lv{constructor(t,e,r,n,i,o,s,a){this._accounts=e,this._provider=r,this._programId=n,this._idlIx=i,this._idlTypes=s,this._customResolver=a,this._args=t,this._accountStore=new fv(r,o,this._programId)}args(t){this._args=t}async resolve(){for(await this.resolveConst(this._idlIx.accounts),this._resolveEventCpi(this._idlIx.accounts);await this.resolvePdas(this._idlIx.accounts)+await this.resolveRelations(this._idlIx.accounts)+await this.resolveCustom()>0;);}async resolveCustom(){if(this._customResolver){const{accounts:t,resolved:e}=await this._customResolver({args:this._args,accounts:this._accounts,provider:this._provider,programId:this._programId,idlIx:this._idlIx});return this._accounts=t,e}return 0}resolveOptionalsHelper(t,e){const r={};for(const n of e){const e=n.name,i=t[e];void 0!==i&&(pv(i)?Fb(n)?r[e]=this.resolveOptionalsHelper(i,n.accounts):r[e]=yv(i,!0):null!==i?r[e]=Bm(i):n.isOptional&&(r[e]=this._programId))}return r}resolveOptionals(t){Object.assign(this._accounts,this.resolveOptionalsHelper(t,this._idlIx.accounts))}get(t){const e=t.reduce(((t,e)=>t&&t[e]),this._accounts);if(e&&e.toBase58)return e}set(t,e){let r=this._accounts;t.forEach(((n,i)=>{i==t.length-1&&(r[n]=e),r[n]=r[n]||{},r=r[n]}))}async resolveConst(t,e=[]){for(let r=0;r<t.length;r+=1){const n=t[r],i=n.accounts;i&&await this.resolveConst(i,[...e,pd(n.name)]);const o=n,s=pd(n.name);if(o.isSigner&&!this.get([...e,s])){if(void 0===this._provider.wallet)throw new Error("This function requires the Provider interface implementor to have a 'wallet' field.");this.set([...e,s],this._provider.wallet.publicKey)}Reflect.has(lv.CONST_ACCOUNTS,s)&&!this.get([...e,s])&&this.set([...e,s],lv.CONST_ACCOUNTS[s])}}_resolveEventCpi(t,e=[]){for(const r in t){const n=t[r],i=n.accounts;i&&this._resolveEventCpi(i,[...e,pd(n.name)]);const o=+r+1;if(o===t.length)return;const s=pd(t[r].name),a=pd(t[o].name);if("eventAuthority"===s&&"program"===a){const t=[...e,s],r=[...e,a];return this.get(t)||this.set(t,Wo.findProgramAddressSync([Buffer.from("__event_authority")],this._programId)[0]),void(this.get(r)||this.set(r,this._programId))}}}async resolvePdas(t,e=[]){let r=0;for(let n=0;n<t.length;n+=1){const i=t[n],o=i.accounts;o&&(r+=await this.resolvePdas(o,[...e,pd(i.name)]));const s=i,a=pd(i.name);s.pda&&s.pda.seeds.length>0&&!this.get([...e,a])&&Boolean(await this.autoPopulatePda(s,e))&&(r+=1)}return r}async resolveRelations(t,e=[]){let r=0;for(let n=0;n<t.length;n+=1){const i=t[n],o=i.accounts;o&&(r+=await this.resolveRelations(o,[...e,pd(i.name)]));const s=i.relations||[],a=pd(i.name),u=[...e,a],c=this.get(u);if(c){const t=s.filter((t=>!this.get([...e,pd(t)])));if(r+=t.length,t.length>0){const r=await this._accountStore.fetchAccount({publicKey:c});await Promise.all(t.map((async t=>{const n=pd(t);return this.set([...e,n],r[n]),r[n]})))}}}return r}async autoPopulatePda(t,e=[]){if(!t.pda||!t.pda.seeds)throw new Error("Must have seeds");const r=await Promise.all(t.pda.seeds.map((t=>this.toBuffer(t,e))));if(r.some((t=>void 0===t)))return;const n=await this.parseProgramId(t,e);if(!n)return;const[i]=await Wo.findProgramAddress(r,n);this.set([...e,pd(t.name)],i)}async parseProgramId(t,e=[]){var r;if(!(null===(r=t.pda)||void 0===r?void 0:r.programId))return this._programId;switch(t.pda.programId.kind){case"const":return new Wo(this.toBufferConst(t.pda.programId.value));case"arg":return this.argValue(t.pda.programId);case"account":return await this.accountValue(t.pda.programId,e);default:throw new Error(`Unexpected program seed kind: ${t.pda.programId.kind}`)}}async toBuffer(t,e=[]){switch(t.kind){case"const":return this.toBufferConst(t);case"arg":return await this.toBufferArg(t);case"account":return await this.toBufferAccount(t,e);default:throw new Error(`Unexpected seed kind: ${t.kind}`)}}getType(t,e=[]){if(e.length>0&&t.defined){const r=this._idlTypes.find((e=>e.name===t.defined));if(!r)throw new Error(`Cannot find type ${t.defined}`);const n=r.type.fields.find((t=>t.name===e[0]));return this.getType(n.type,e.slice(1))}return t}toBufferConst(t){return this.toBufferValue(this.getType(t.type,(t.path||"").split(".").slice(1)),t.value)}async toBufferArg(t){const e=this.argValue(t);if(void 0!==e)return this.toBufferValue(this.getType(t.type,(t.path||"").split(".").slice(1)),e)}argValue(t){const e=t.path.split("."),r=pd(e[0]),n=this._idlIx.args.findIndex((t=>t.name===r));if(-1===n)throw new Error(`Unable to find argument for seed: ${r}`);return e.slice(1).reduce(((t,e)=>(t||{})[e]),this._args[n])}async toBufferAccount(t,e=[]){const r=await this.accountValue(t,e);if(r)return this.toBufferValue(t.type,r)}async accountValue(t,e=[]){const r=t.path.split("."),n=r[0],i=this.get([...e,pd(n)]);if(null===i)throw new Error("fieldPubkey is null");if(1===r.length)return i;const o=await this._accountStore.fetchAccount({publicKey:i,name:t.account});return this.parseAccountValue(o,r.slice(1))}parseAccountValue(t,e){let r;for(;e.length>0;)r=t[pd(e[0])],e=e.slice(1);return r}toBufferValue(t,e){switch(t){case"u8":return Buffer.from([e]);case"u16":let r=Buffer.alloc(2);return r.writeUInt16LE(e),r;case"u32":let n=Buffer.alloc(4);return n.writeUInt32LE(e),n;case"u64":let i=Buffer.alloc(8);return i.writeBigUInt64LE(BigInt(e)),i;case"string":return Buffer.from(wm(e));case"publicKey":return e.toBuffer();default:if(t.array)return Buffer.from(e);throw new Error(`Unexpected seed type: ${t}`)}}}lv.CONST_ACCOUNTS={associatedTokenProgram:Lb,rent:ms,systemProgram:Ls.programId,tokenProgram:Tb,clock:ds};class fv{constructor(t,e,r){this._provider=t,this._programId=r,this._cache=new Map,this._idls={},this._idls[r.toBase58()]=e}async ensureIdl(t){if(!this._idls[t.toBase58()]){const e=await bv.fetchIdl(t,this._provider);if(e){const r=new bv(e,t,this._provider);this._idls[t.toBase58()]=r.account}}return this._idls[t.toBase58()]}async fetchAccount({publicKey:t,name:e,programId:r=this._programId}){const n=t.toString();if(!this._cache.has(n))if("TokenAccount"===e){const e=await this._provider.connection.getAccountInfo(t);if(null===e)throw new Error(`invalid account info for ${n}`);const r=function(t){return hv.decode(t)}(e.data);this._cache.set(n,r)}else if(e){const i=await this.ensureIdl(r);if(i){const r=i[pd(e)];if(r){const e=await r.fetch(t);this._cache.set(n,e)}}}else{const e=await this._provider.connection.getAccountInfo(t);if(null===e)throw new Error(`invalid account info for ${n}`);const r=e.data,i=await this.ensureIdl(e.owner);if(i){const t=Object.values(i)[0];if(!t)throw new Error("No accounts for this program");const e=t.coder.accounts.decodeAny(r);this._cache.set(n,e)}}return this._cache.get(n)}}class dv{static build(t,e,r,n,i,o,s,a,u,c,h){return(...l)=>new gv(l,n,i,o,s,a,t,e,r,u,c,h)}}function pv(t){return"object"==typeof t&&null!==t&&!("_bn"in t)}function yv(t,e){const r={};for(const n in t){const i=t[n];if(null!==i)r[n]=pv(i)?yv(i,!0):Bm(i);else if(e)throw new Error("Failed to resolve optionals due to IDL type mismatch with input accounts!")}return r}class gv{constructor(t,e,r,n,i,o,s,a,u,c,h,l){this._ixFn=e,this._txFn=r,this._rpcFn=n,this._simulateFn=i,this._viewFn=o,this._programId=a,this._accounts={},this._remainingAccounts=[],this._signers=[],this._preInstructions=[],this._postInstructions=[],this._autoResolveAccounts=!0,this._args=t,this._accountsResolver=new lv(t,this._accounts,s,a,u,c,h,l)}args(t){this._args=t,this._accountsResolver.args(t)}async pubkeys(){return this._autoResolveAccounts&&await this._accountsResolver.resolve(),this._accounts}accounts(t){return this._autoResolveAccounts=!0,this._accountsResolver.resolveOptionals(t),this}accountsStrict(t){return this._autoResolveAccounts=!1,this._accountsResolver.resolveOptionals(t),this}signers(t){return this._signers=this._signers.concat(t),this}remainingAccounts(t){return this._remainingAccounts=this._remainingAccounts.concat(t),this}preInstructions(t){return this._preInstructions=this._preInstructions.concat(t),this}postInstructions(t){return this._postInstructions=this._postInstructions.concat(t),this}async rpc(t){return this._autoResolveAccounts&&await this._accountsResolver.resolve(),this._rpcFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions,options:t})}async rpcAndKeys(t){return{pubkeys:await this.pubkeys(),signature:await this.rpc(t)}}async view(t){if(this._autoResolveAccounts&&await this._accountsResolver.resolve(),!this._viewFn)throw new Error("Method does not support views");return this._viewFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions,options:t})}async simulate(t){return this._autoResolveAccounts&&await this._accountsResolver.resolve(),this._simulateFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions,options:t})}async instruction(){return this._autoResolveAccounts&&await this._accountsResolver.resolve(),this._ixFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions})}async prepare(){return{instruction:await this.instruction(),pubkeys:await this.pubkeys(),signers:await this._signers}}async transaction(){return this._autoResolveAccounts&&await this._accountsResolver.resolve(),this._txFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions})}}class mv{static build(t,e,r,n){const i=e.accounts.find((t=>t.isMut)),o=!!e.returns;if(i||!o)return;return async(...i)=>{var o,s;let a=await r(...i);const u=`Program return: ${t} `;let c=a.raw.find((t=>t.startsWith(u)));if(!c)throw new Error("View expected return log");let h=km(c.slice(u.length)),l=e.returns;if(!l)throw new Error("View expected return type");return Mw.fieldLayout({type:l},Array.from([...null!==(o=n.accounts)&&void 0!==o?o:[],...null!==(s=n.types)&&void 0!==s?s:[]])).decode(h)}}}class wv{static build(t,e,r,n,i){const o={},s={},a={},u={},c={},h={},l=Sm(t),f=t.accounts?Gb.build(t,e,r,n):{};return t.instructions.forEach((d=>{const p=qb.build(d,((t,r)=>e.instruction.encode(t,r)),r),y=Hb.build(d,p),g=$b.build(d,y,l,n),m=nv.build(d,y,l,n,e,r,t),w=mv.build(r,d,m,t),b=dv.build(n,r,d,p,y,g,m,w,f,t.types||[],i&&i(d)),v=pd(d.name);s[v]=p,a[v]=y,o[v]=g,u[v]=m,c[v]=b,w&&(h[v]=w)})),[o,s,a,f,u,c,h]}}class bv{get programId(){return this._programId}get idl(){return this._idl}get coder(){return this._coder}get provider(){return this._provider}constructor(t,e,r,n,i){e=Bm(e),r||(r=cw()),this._idl=t,this._provider=r,this._programId=e,this._coder=null!=n?n:new Fw(t),this._events=new Qb(this._programId,r,this._coder);const[o,s,a,u,c,h,l]=wv.build(t,this._coder,e,r,null!=i?i:()=>{});this.rpc=o,this.instruction=s,this.transaction=a,this.account=u,this.simulate=c,this.methods=h,this.views=l}static async at(t,e){const r=Bm(t),n=await bv.fetchIdl(r,e);if(!n)throw new Error(`IDL not found for program: ${t.toString()}`);return new bv(n,r,e)}static async fetchIdl(t,e){e=null!=e?e:cw();const r=Bm(t),n=await async function(t){const e=(await Wo.findProgramAddress([],t))[0];return await Wo.createWithSeed(e,"anchor:idl",t)}(r),i=await e.connection.getAccountInfo(n);if(!i)return null;let o=function(t){return Kb.decode(t)}(i.data.slice(8));const s=dm(o.data);return JSON.parse(mm(s))}addEventListener(t,e){return this._events.addEventListener(t,e)}async removeEventListener(t){return await this._events.removeEventListener(t)}}const vv=new Wo("11111111111111111111111111111111");function _v(t){return new bv(kv,vv,t,new Bb(kv))}const kv={version:"0.1.0",name:"system_program",instructions:[{name:"createAccount",accounts:[{name:"from",isMut:!0,isSigner:!0},{name:"to",isMut:!0,isSigner:!0}],args:[{name:"lamports",type:"u64"},{name:"space",type:"u64"},{name:"owner",type:"publicKey"}]},{name:"assign",accounts:[{name:"pubkey",isMut:!0,isSigner:!0}],args:[{name:"owner",type:"publicKey"}]},{name:"transfer",accounts:[{name:"from",isMut:!0,isSigner:!0},{name:"to",isMut:!0,isSigner:!1}],args:[{name:"lamports",type:"u64"}]},{name:"createAccountWithSeed",accounts:[{name:"from",isMut:!0,isSigner:!0},{name:"to",isMut:!0,isSigner:!1},{name:"base",isMut:!1,isSigner:!0}],args:[{name:"base",type:"publicKey"},{name:"seed",type:"string"},{name:"lamports",type:"u64"},{name:"space",type:"u64"},{name:"owner",type:"publicKey"}]},{name:"advanceNonceAccount",accounts:[{name:"nonce",isMut:!0,isSigner:!1},{name:"recentBlockhashes",isMut:!1,isSigner:!1},{name:"authorized",isMut:!1,isSigner:!0}],args:[{name:"authorized",type:"publicKey"}]},{name:"withdrawNonceAccount",accounts:[{name:"nonce",isMut:!0,isSigner:!1},{name:"to",isMut:!0,isSigner:!1},{name:"recentBlockhashes",isMut:!1,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1},{name:"authorized",isMut:!1,isSigner:!0}],args:[{name:"lamports",type:"u64"}]},{name:"initializeNonceAccount",accounts:[{name:"nonce",isMut:!0,isSigner:!0},{name:"recentBlockhashes",isMut:!1,isSigner:!1},{name:"rent",isMut:!1,isSigner:!1}],args:[{name:"authorized",type:"publicKey"}]},{name:"authorizeNonceAccount",accounts:[{name:"nonce",isMut:!0,isSigner:!1},{name:"authorized",isMut:!1,isSigner:!0}],args:[{name:"authorized",type:"publicKey"}]},{name:"allocate",accounts:[{name:"pubkey",isMut:!0,isSigner:!0}],args:[{name:"space",type:"u64"}]},{name:"allocateWithSeed",accounts:[{name:"account",isMut:!0,isSigner:!1},{name:"base",isMut:!1,isSigner:!0}],args:[{name:"base",type:"publicKey"},{name:"seed",type:"string"},{name:"space",type:"u64"},{name:"owner",type:"publicKey"}]},{name:"assignWithSeed",accounts:[{name:"account",isMut:!0,isSigner:!1},{name:"base",isMut:!1,isSigner:!0}],args:[{name:"base",type:"publicKey"},{name:"seed",type:"string"},{name:"owner",type:"publicKey"}]},{name:"transferWithSeed",accounts:[{name:"from",isMut:!0,isSigner:!1},{name:"base",isMut:!1,isSigner:!0},{name:"to",isMut:!0,isSigner:!1}],args:[{name:"lamports",type:"u64"},{name:"seed",type:"string"},{name:"owner",type:"publicKey"}]}],accounts:[{name:"nonce",type:{kind:"struct",fields:[{name:"version",type:"u32"},{name:"state",type:"u32"},{name:"authorizedPubkey",type:"publicKey"},{name:"nonce",type:"publicKey"},{name:"feeCalculator",type:{defined:"FeeCalculator"}}]}}],types:[{name:"FeeCalculator",type:{kind:"struct",fields:[{name:"lamportsPerSignature",type:"u64"}]}}]};var Ev,xv=r(Object.freeze({__proto__:null,web3:pc,AccountClient:Zb,AnchorError:mw,AnchorProvider:ow,BorshAccountsCoder:zw,BorshCoder:Fw,BorshEventCoder:Dw,BorshInstructionCoder:Pw,DISCRIMINATOR_SIZE:Cw,EventManager:Qb,EventParser:tv,IdlError:yw,LangErrorCode:vw,LangErrorMessage:_w,MethodsBuilderFactory:dv,Native:class{static system(t){return _v(t)}},Program:bv,ProgramError:ww,ProgramErrorStack:gw,SystemCoder:Bb,eventDiscriminator:jw,getProvider:cw,parseIdlErrors:Sm,setProvider:function(t){hw=t},splitArgsAndCtx:Vb,toInstruction:Am,translateAddress:Bm,translateError:bw,utils:Wb,validateAccounts:Im,BN:ne})),Sv={},Av={};var Iv,Bv={};function Mv(){if(Iv)return Bv;Iv=1;var e=t&&t.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){t.done?i(t.value):function(t){return t instanceof r?t:new r((function(e){e(t)}))}(t.value).then(s,a)}u((n=n.apply(t,e||[])).next())}))},r=t&&t.__generator||function(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}};Object.defineProperty(Bv,"__esModule",{value:!0}),Bv.PythOracleAccountCoder=void 0;var n=function(){function t(t){this.idl=t}return t.prototype.encode=function(t,n){return e(this,void 0,void 0,(function(){return r(this,(function(t){throw new Error("Not implemented")}))}))},t.prototype.decode=function(t,e){throw new Error("Not implemented")},t.prototype.decodeUnchecked=function(t,e){throw new Error("Not implemented")},t.prototype.memcmp=function(t,e){throw new Error("Not implemented")},t.prototype.size=function(t){return 0},t}();return Bv.PythOracleAccountCoder=n,Bv}var Rv={};var Pv=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r<e.length;r++)e[r]=255;for(var n=0;n<t.length;n++){var i=t.charAt(n),o=i.charCodeAt(0);if(255!==e[o])throw new TypeError(i+" is ambiguous");e[o]=n}var s=t.length,a=t.charAt(0),u=Math.log(s)/Math.log(256),c=Math.log(256)/Math.log(s);function h(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return new Uint8Array;for(var r=0,n=0,i=0;t[r]===a;)n++,r++;for(var o=(t.length-r)*u+1>>>0,c=new Uint8Array(o);t[r];){var h=e[t.charCodeAt(r)];if(255===h)return;for(var l=0,f=o-1;(0!==h||l<i)&&-1!==f;f--,l++)h+=s*c[f]>>>0,c[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===c[d];)d++;for(var p=new Uint8Array(n+(o-d)),y=n;d!==o;)p[y++]=c[d++];return p}return{encode:function(e){if(e instanceof Uint8Array||(ArrayBuffer.isView(e)?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Array.isArray(e)&&(e=Uint8Array.from(e))),!(e instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===e.length)return"";for(var r=0,n=0,i=0,o=e.length;i!==o&&0===e[i];)i++,r++;for(var u=(o-i)*c+1>>>0,h=new Uint8Array(u);i!==o;){for(var l=e[i],f=0,d=u-1;(0!==l||f<n)&&-1!==d;d--,f++)l+=256*h[d]>>>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=u-n;p!==u&&0===h[p];)p++;for(var y=a.repeat(r);p<u;++p)y+=t.charAt(h[p]);return y},decodeUnsafe:h,decode:function(t){var e=h(t);if(e)return e;throw new Error("Non-base"+s+" character")}}};var Tv,Lv,Ov=Pv("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),Uv=e(Ov),Cv={};function Nv(){if(Lv)return Rv;Lv=1;var e=t&&t.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),r=t&&t.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),i=t&&t.__importStar||function(t){if(t&&t.__esModule)return t;var n={};if(null!=t)for(var i in t)"default"!==i&&Object.prototype.hasOwnProperty.call(t,i)&&e(n,t,i);return r(n,t),n},o=t&&t.__spreadArray||function(t,e){for(var r=0,n=e.length,i=t.length;r<n;r++,i++)t[i]=e[r];return t},s=t&&t.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Rv,"__esModule",{value:!0}),Rv.PythOracleInstructionCoder=void 0;var a=s(Ov),u=n,c=s(dd()),h=i(yd),l=function(){if(Tv)return Cv;Tv=1;var e=t&&t.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),r=t&&t.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),n=t&&t.__importStar||function(t){if(t&&t.__esModule)return t;var n={};if(null!=t)for(var i in t)"default"!==i&&Object.prototype.hasOwnProperty.call(t,i)&&e(n,t,i);return r(n,t),n},i=t&&t.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Cv,"__esModule",{value:!0}),Cv.IdlCoder=void 0;var o=i(dd()),s=n(yd),a=xv,u=function(){function t(){}return t.fieldLayout=function(e,r){var n=void 0!==e.name?o.default(e.name):void 0;switch(e.type){case"bool":return s.bool(n);case"u8":return s.u8(n);case"i8":return s.i8(n);case"u16":return s.u16(n);case"i16":return s.i16(n);case"u32":return s.u32(n);case"i32":return s.i32(n);case"f32":return s.f32(n);case"u64":return s.u64(n);case"i64":return s.i64(n);case"f64":return s.f64(n);case"u128":return s.u128(n);case"i128":return s.i128(n);case"u256":return s.u256(n);case"i256":return s.i256(n);case"bytes":return s.vecU8(n);case"string":return s.str(n);case"publicKey":return s.publicKey(n);default:if("vec"in e.type)return s.vec(t.fieldLayout({name:void 0,type:e.type.vec},r),n);if("option"in e.type)return s.option(t.fieldLayout({name:void 0,type:e.type.option},r),n);if("defined"in e.type){var i=e.type.defined;if(void 0===r)throw new a.IdlError("User defined types not provided");var u=r.filter((function(t){return t.name===i}));if(1!==u.length)throw new a.IdlError("Type not found: "+JSON.stringify(e));return t.typeDefLayout(u[0],r,n)}if("array"in e.type){var c=e.type.array[0],h=e.type.array[1],l=t.fieldLayout({name:void 0,type:c},r);return s.array(l,h,n)}throw new Error("Not yet implemented: "+e)}},t.typeDefLayout=function(e,r,n){if(void 0===r&&(r=[]),"struct"===e.type.kind){var i=e.type.fields.map((function(e){return t.fieldLayout(e,r)}));return s.struct(i,n)}if("enum"===e.type.kind){var a=e.type.variants.map((function(e){var n=o.default(e.name);if(void 0===e.fields)return s.struct([],n);var i=e.fields.map((function(e,n){return e.hasOwnProperty("name")?t.fieldLayout(e,r):t.fieldLayout({type:e,name:n.toString()},r)}));return s.struct(i,n)}));return void 0!==n?s.rustEnum(a).replicate(n):s.rustEnum(a,n)}throw new Error("Unknown type kint: "+e)},t}();return Cv.IdlCoder=u,Cv}(),f=function(){function t(e){var r=this;this.idl=e,this.ixLayout=t.parseIxLayout(e);var n=new Map,i=new Map;e.instructions.forEach((function(t){var e,o=t;if(!o.discriminant)throw new Error("All instructions must have a discriminator");if(n.set(a.default.encode(u.Buffer.from(o.discriminant.value)),{layout:r.ixLayout.get(o.name),name:o.name}),i.set(o.name,u.Buffer.from(o.discriminant.value)),e=o.discriminant.value.length,r.discriminatorLength&&r.discriminatorLength!==e)throw new Error("All instructions must have the same discriminator length");r.discriminatorLength=e})),this.discriminatorLayouts=n,this.ixDiscriminator=i}return t.prototype.encodeState=function(t,e){return this.encode(t,e)},t.prototype.encode=function(t,e){var r=u.Buffer.alloc(1e3),n=c.default(t),i=this.ixLayout.get(n),o=this.ixDiscriminator.get(n);if(!i||!o)throw new Error("Unknown method: "+n);if("updProduct"===n||"addProduct"===n){for(var s=0,a=0,h=Object.keys(e.productMetadata);a<h.length;a++){var l=h[a];s+=r.subarray(s).writeInt8(l.length),s+=r.subarray(s).write(l),s+=r.subarray(s).writeInt8(e.productMetadata[l].length),s+=r.subarray(s).write(e.productMetadata[l])}if(s>464)throw new Error("The metadata is too long");var f=r.subarray(0,s);return u.Buffer.concat([o,f])}var d=i.encode(e,r);f=r.subarray(0,d);return u.Buffer.concat([o,f])},t.parseIxLayout=function(t){var e=t.instructions.map((function(e){var r=e.args.map((function(e){var r,n;return l.IdlCoder.fieldLayout(e,Array.from(o(o([],null!==(r=t.accounts)&&void 0!==r?r:[]),null!==(n=t.types)&&void 0!==n?n:[])))})),n=c.default(e.name);return[n,h.struct(r,n)]}));return new Map(e)},t.prototype.decode=function(t,e){void 0===e&&(e="hex"),"string"==typeof t&&(t="hex"===e?u.Buffer.from(t,"hex"):u.Buffer.from(a.default.decode(t)));var r=a.default.encode(t.subarray(0,this.discriminatorLength)),n=t.subarray(this.discriminatorLength),i=this.discriminatorLayouts.get(r);if(!i)return null;if("updProduct"===i.name||"addProduct"===i.name){for(var o={},s=0;s<n.length;){var c=n[s];if(s++,c){var h=n.slice(s,s+c).toString(),l=n[s+=c];s++;var f=n.slice(s,s+l).toString();s+=l,o[h]=f}}return{data:o,name:i.name}}return{data:i.layout.decode(n),name:i.name}},t}();return Rv.PythOracleInstructionCoder=f,Rv}var zv,Dv={};var jv,Wv,Fv={};function Kv(){if(Wv)return Sv;Wv=1,Object.defineProperty(Sv,"__esModule",{value:!0}),Sv.PythOracleCoder=void 0;var t=function(){if(Ev)return Av;Ev=1,Object.defineProperty(Av,"__esModule",{value:!0}),Av.PythOracleEventCoder=void 0;var t=function(){function t(){}return t.prototype.decode=function(t){throw new Error("Pyth oracle program does not have events")},t}();return Av.PythOracleEventCoder=t,Av}(),e=Mv(),r=Nv(),n=function(){if(zv)return Dv;zv=1,Object.defineProperty(Dv,"__esModule",{value:!0}),Dv.PythOracleStateCoder=void 0;var t=function(){function t(){}return t.prototype.encode=function(t,e){throw new Error("Not implemented")},t.prototype.decode=function(t){throw new Error("Not implemented")},t}();return Dv.PythOracleStateCoder=t,Dv}(),i=function(){if(jv)return Fv;jv=1,Object.defineProperty(Fv,"__esModule",{value:!0}),Fv.PythOracleTypesCoder=void 0;var t=function(){function t(){}return t.prototype.encode=function(t,e){throw new Error("Not implemented")},t.prototype.decode=function(t,e){throw new Error("Not implemented")},t}();return Fv.PythOracleTypesCoder=t,Fv}(),o=function(o){this.accounts=new e.PythOracleAccountCoder(o),this.events=new t.PythOracleEventCoder,this.instruction=new r.PythOracleInstructionCoder(o),this.state=new n.PythOracleStateCoder,this.types=new i.PythOracleTypesCoder};return Sv.PythOracleCoder=o,Sv}var Vv,qv,Hv,$v={version:"2.20.0",name:"pyth_oracle",instructions:[{name:"initMapping",discriminant:{value:[2,0,0,0,0,0,0,0]},accounts:[{name:"fundingAccount",isMut:!0,isSigner:!0},{name:"freshMappingAccount",isMut:!0,isSigner:!1},{name:"permissionsAccount",isMut:!1,isSigner:!1,pda:{seeds:[{kind:"const",type:"string",value:"permissions"}]}}],args:[]},{name:"addMapping",discriminant:{value:[2,0,0,0,1,0,0,0]},accounts:[{name:"fundingAccount",isMut:!0,isSigner:!0},{name:"curMapping",isMut:!0,isSigner:!1},{name:"nextMapping",isMut:!0,isSigner:!1},{name:"permissionsAccount",isMut:!1,isSigner:!1,pda:{seeds:[{kind:"const",type:"string",value:"permissions"}]}}],args:[]},{name:"addProduct",discriminant:{value:[2,0,0,0,2,0,0,0]},accounts:[{name:"fundingAccount",isMut:!0,isSigner:!0},{name:"tailMappingAccount",isMut:!0,isSigner:!1},{name:"productAccount",isMut:!0,isSigner:!1},{name:"permissionsAccount",isMut:!1,isSigner:!1,pda:{seeds:[{kind:"const",type:"string",value:"permissions"}]}}],args:[{name:"productMetadata",type:{defined:"ProductMetadata"}}]},{name:"updProduct",discriminant:{value:[2,0,0,0,3,0,0,0]},accounts:[{name:"fundingAccount",isMut:!0,isSigner:!0},{name:"productAccount",isMut:!0,isSigner:!1},{name:"permissionsAccount",isMut:!1,isSigner:!1,pda:{seeds:[{kind:"const",type:"string",value:"permissions"}]}}],args:[{name:"productMetadata",type:{defined:"ProductMetadata"}}]},{name:"addPrice",discriminant:{value:[2,0,0,0,4,0,0,0]},accounts:[{name:"fundingAccount",isMut:!0,isSigner:!0},{name:"productAccount",isMut:!0,isSigner:!1},{name:"priceAccount",isMut:!0,isSigner:!1},{name:"permissionsAccount",isMut:!1,isSigner:!1,pda:{seeds:[{kind:"const",type:"string",value:"permissions"}]}}],args:[{name:"expo",type:"i32"},{name:"pType",type:"u32"}]},{name:"addPublisher",discriminant:{value:[2,0,0,0,5,0,0,0]},accounts:[{name:"fundingAccount",isMut:!0,isSigner:!0},{name:"priceAccount",isMut:!0,isSigner:!1},{name:"permissionsAccount",isMut:!1,isSigner:!1,pda:{seeds:[{kind:"const",type:"string",value:"permissions"}]}}],args:[{name:"pub",type:"publicKey"}]},{name:"delPublisher",discriminant:{value:[2,0,0,0,6,0,0,0]},accounts:[{name:"fundingAccount",isMut:!0,isSigner:!0},{name:"priceAccount",isMut:!0,isSigner:!1},{name:"permissionsAccount",isMut:!1,isSigner:!1,pda:{seeds:[{kind:"const",type:"string",value:"permissions"}]}}],args:[{name:"pub",type:"publicKey"}]},{name:"updPrice",discriminant:{value:[2,0,0,0,7,0,0,0]},accounts:[{name:"fundingAccount",isMut:!0,isSigner:!0},{name:"priceAccount",isMut:!0,isSigner:!1},{name:"clock",isMut:!1,isSigner:!1}],args:[{name:"status",type:"u32"},{name:"unused",type:"u32"},{name:"price",type:"i64"},{name:"conf",type:"u64"},{name:"pubSlot",type:"u64"}]},{name:"aggPrice",discriminant:{value:[2,0,0,0,8,0,0,0]},accounts:[{name:"fundingAccount",isMut:!0,isSigner:!0},{name:"priceAccount",isMut:!0,isSigner:!1},{name:"clock",isMut:!1,isSigner:!1}],args:[{name:"status",type:"u32"},{name:"unused",type:"u32"},{name:"price",type:"i64"},{name:"conf",type:"u64"},{name:"pubSlot",type:"u64"}]},{name:"setExponent",discriminant:{value:[2,0,0,0,9,0,0,0]},accounts:[{name:"fundingAccount",isMut:!0,isSigner:!0},{name:"priceAccount",isMut:!0,isSigner:!1},{name:"permissionsAccount",isMut:!1,isSigner:!1,pda:{seeds:[{kind:"const",type:"string",value:"permissions"}]}}],args:[{name:"expo",type:"i32"},{name:"pType",type:"u32"}]},{name:"setMinPub",discriminant:{value:[2,0,0,0,12,0,0,0]},accounts:[{name:"fundingAccount",isMut:!0,isSigner:!0},{name:"priceAccount",isMut:!0,isSigner:!1},{name:"permissionsAccount",isMut:!1,isSigner:!1,pda:{seeds:[{kind:"const",type:"string",value:"permissions"}]}}],args:[{name:"minPub",type:"u8"},{name:"unused",type:{array:["u8",3]}}]},{name:"updPriceNoFailOnError",discriminant:{value:[2,0,0,0,13,0,0,0]},accounts:[{name:"fundingAccount",isMut:!0,isSigner:!0},{name:"priceAccount",isMut:!0,isSigner:!1},{name:"clock",isMut:!1,isSigner:!1}],args:[{name:"status",type:"u32"},{name:"unused",type:"u32"},{name:"price",type:"i64"},{name:"conf",type:"u64"},{name:"pubSlot",type:"u64"}]},{name:"delPrice",discriminant:{value:[2,0,0,0,15,0,0,0]},accounts:[{name:"fundingAccount",isMut:!0,isSigner:!0},{name:"productAccount",isMut:!0,isSigner:!1},{name:"priceAccount",isMut:!0,isSigner:!1},{name:"permissionsAccount",isMut:!1,isSigner:!1,pda:{seeds:[{kind:"const",type:"string",value:"permissions"}]}}],args:[]},{name:"delProduct",discriminant:{value:[2,0,0,0,16,0,0,0]},accounts:[{name:"fundingAccount",isMut:!0,isSigner:!0},{name:"mappingAccount",isMut:!0,isSigner:!1},{name:"productAccount",isMut:!0,isSigner:!1},{name:"permissionsAccount",isMut:!1,isSigner:!1,pda:{seeds:[{kind:"const",type:"string",value:"permissions"}]}}],args:[]},{name:"updPermissions",discriminant:{value:[2,0,0,0,17,0,0,0]},accounts:[{name:"upgradeAuthority",isMut:!0,isSigner:!0},{name:"programDataAccount",isMut:!1,isSigner:!1},{name:"permissionsAccount",isMut:!0,isSigner:!1,pda:{seeds:[{kind:"const",type:"string",value:"permissions"}]}},{name:"systemProgram",isMut:!1,isSigner:!1}],args:[{name:"masterAuthority",type:"publicKey"},{name:"dataCurationAuthority",type:"publicKey"},{name:"securityAuthority",type:"publicKey"}]}],types:[{name:"ProductMetadata",type:{kind:"struct",fields:[]}}]};function Gv(){return qv||(qv=1,function(e){var r=t&&t.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),n=t&&t.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||r(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),n((Vv||(Vv=1,function(e){var r=t&&t.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.pythIdl=e.pythOracleCoder=e.pythOracleProgram=void 0;var n=xv,i=Kv(),o=r($v);e.pythOracleProgram=function(t,e){return new n.Program(o.default,t,e,new i.PythOracleCoder(o.default))},e.pythOracleCoder=function(){return new i.PythOracleCoder(o.default)};var s=$v;Object.defineProperty(e,"pythIdl",{enumerable:!0,get:function(){return r(s).default}})}(hd)),hd),e)}(cd)),cd}function Zv(){return Hv||(Hv=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.pythIdl=t.pythOracleCoder=t.pythOracleProgram=t.getPythClusterApiUrl=t.getPythProgramKeyForCluster=t.PythHttpClient=t.PythConnection=t.parsePermissionData=t.parsePriceData=t.parseProductData=t.parseMappingData=t.parseBaseData=t.AccountType=t.DeriveType=t.PriceType=t.CorpAction=t.PriceStatus=t.MAX_SLOT_DIFFERENCE=t.Version=t.Version2=t.Magic=void 0;var e,r,i,o,s=$f,a=n,u=Gf;t.Magic=2712847316,t.Version2=2,t.Version=t.Version2,t.MAX_SLOT_DIFFERENCE=25,function(t){t[t.Unknown=0]="Unknown",t[t.Trading=1]="Trading",t[t.Halted=2]="Halted",t[t.Auction=3]="Auction",t[t.Ignored=4]="Ignored"}(e=t.PriceStatus||(t.PriceStatus={})),(r=t.CorpAction||(t.CorpAction={}))[r.NoCorpAct=0]="NoCorpAct",(i=t.PriceType||(t.PriceType={}))[i.Unknown=0]="Unknown",i[i.Price=1]="Price",(o=t.DeriveType||(t.DeriveType={}))[o.Unknown=0]="Unknown",o[o.Volatility=1]="Volatility",function(t){t[t.Unknown=0]="Unknown",t[t.Mapping=1]="Mapping",t[t.Product=2]="Product",t[t.Price=3]="Price",t[t.Test=4]="Test",t[t.Permission=5]="Permission"}(t.AccountType||(t.AccountType={}));var c=a.Buffer.alloc(32),h=function(t){return t.equals(c)?null:new s.PublicKey(t)};t.parseBaseData=function(e){if(!(e.byteLength<4)){var r=e.readUInt32LE(0);return r===t.Magic?{magic:r,version:e.readUInt32LE(4),type:e.readUInt32LE(8),size:e.readUInt32LE(12)}:void 0}};t.parseMappingData=function(t){for(var e=t.readUInt32LE(0),r=t.readUInt32LE(4),n=t.readUInt32LE(8),i=t.readUInt32LE(12),o=t.readUInt32LE(16),a=h(t.slice(24,56)),u=56,c=[],l=0;l<o;l++){var f=t.slice(u,u+32),d=new s.PublicKey(f);u+=32,c.push(d)}return{magic:e,version:r,type:n,size:i,nextMappingAccount:a,productAccountKeys:c}};t.parseProductData=function(t){var e=t.readUInt32LE(0),r=t.readUInt32LE(4),n=t.readUInt32LE(8),i=t.readUInt32LE(12),o=t.slice(16,48),s=h(o),a={};s&&(a.price_account=s.toBase58());for(var u=48;u<i;){var c=t[u];if(u++,c){var l=t.slice(u,u+c).toString(),f=t[u+=c];u++;var d=t.slice(u,u+f).toString();u+=f,a[l]=d}}return{magic:e,version:r,type:n,size:i,priceAccountKey:s,product:a}};var l=function(t,e){var r=u.readBigInt64LE(t,0);return{valueComponent:r,value:Number(r)*Math.pow(10,e),numerator:u.readBigInt64LE(t,8),denominator:u.readBigInt64LE(t,16)}},f=function(t,e){var r=u.readBigInt64LE(t,0),n=Number(r)*Math.pow(10,e),i=u.readBigUInt64LE(t,8);return{priceComponent:r,price:n,confidenceComponent:i,confidence:Number(i)*Math.pow(10,e),status:t.readUInt32LE(16),corporateAction:t.readUInt32LE(20),publishSlot:Number(u.readBigUInt64LE(t,24))}};t.parsePriceData=function(r,n){var i,o,a=r.readUInt32LE(0),c=r.readUInt32LE(4),d=r.readUInt32LE(8),p=r.readUInt32LE(12),y=r.readUInt32LE(16),g=r.readInt32LE(20),m=r.readUInt32LE(24),w=r.readUInt32LE(28),b=u.readBigUInt64LE(r,32),v=u.readBigUInt64LE(r,40),_=l(r.slice(48,72),g),k=l(r.slice(72,96),g),E=u.readBigInt64LE(r,96),x=r.readUInt8(104),S=r.readInt8(105),A=r.readInt16LE(106),I=r.readInt32LE(108),B=new s.PublicKey(r.slice(112,144)),M=h(r.slice(144,176)),R=u.readBigUInt64LE(r,176),P=u.readBigInt64LE(r,184),T=Number(P)*Math.pow(10,g),L=u.readBigUInt64LE(r,192),O=Number(L)*Math.pow(10,g),U=u.readBigInt64LE(r,200),C=f(r.slice(208,240),g),N=C.status;n&&N===e.Trading&&n-C.publishSlot>t.MAX_SLOT_DIFFERENCE&&(N=e.Unknown),N===e.Trading&&(i=C.price,o=C.confidence);for(var z=[],D=240;z.length<m;){var j=new s.PublicKey(r.slice(D,D+32));D+=32;var W=f(r.slice(D,D+32),g);D+=32;var F=f(r.slice(D,D+32),g);D+=32,z.push({publisher:j,aggregate:W,latest:F})}return{magic:a,version:c,type:d,size:p,priceType:y,exponent:g,numComponentPrices:m,numQuoters:w,lastSlot:b,validSlot:v,emaPrice:_,emaConfidence:k,timestamp:E,minPublishers:x,drv2:S,drv3:A,drv4:I,productAccountKey:B,nextPriceAccountKey:M,previousSlot:R,previousPriceComponent:P,previousPrice:T,previousConfidenceComponent:L,previousConfidence:O,previousTimestamp:U,aggregate:C,priceComponents:z,price:i,confidence:o,status:N}};t.parsePermissionData=function(t){return{magic:t.readUInt32LE(0),version:t.readUInt32LE(4),type:t.readUInt32LE(8),size:t.readUInt32LE(12),masterAuthority:new s.PublicKey(t.slice(16,48)),dataCurationAuthority:new s.PublicKey(t.slice(48,80)),securityAuthority:new s.PublicKey(t.slice(80,112))}};var d=rd();Object.defineProperty(t,"PythConnection",{enumerable:!0,get:function(){return d.PythConnection}});var p=od();Object.defineProperty(t,"PythHttpClient",{enumerable:!0,get:function(){return p.PythHttpClient}});var y=function(){if(sd)return ad;sd=1,Object.defineProperty(ad,"__esModule",{value:!0}),ad.getPythClusterApiUrl=ad.getPythProgramKeyForCluster=void 0;var t=$f,e={"mainnet-beta":"FsJ3A3u2vn5cTVofAjvy6y5kwABJAqYWpe4975bi2epH",devnet:"gSbePebfvPy7tRqimPoVecS2UsBvYv46ynrzWocc92s","pythtest-crosschain":"gSbePebfvPy7tRqimPoVecS2UsBvYv46ynrzWocc92s",testnet:"8tfDNiaEyrV6Q1U4DEXrEigs9DoDtkugzFbybENEbCDz","pythtest-conformance":"8tfDNiaEyrV6Q1U4DEXrEigs9DoDtkugzFbybENEbCDz",pythnet:"FsJ3A3u2vn5cTVofAjvy6y5kwABJAqYWpe4975bi2epH",localnet:"gMYYig2utAxVoXnM9UhtTWrt8e7x2SVBZqsWZJeT5Gw"};return ad.getPythProgramKeyForCluster=function(r){if(void 0!==e[r])return new t.PublicKey(e[r]);throw new Error("Invalid Solana cluster name: "+r+". Valid options are: "+JSON.stringify(Object.keys(e)))},ad.getPythClusterApiUrl=function(e){return"pythtest-conformance"===e||"pythtest-crosschain"===e?"https://api.pythtest.pyth.network":"pythnet"===e?"https://pythnet.rpcpool.com":"localnet"===e?"http://localhost:8899":t.clusterApiUrl(e)},ad}();Object.defineProperty(t,"getPythProgramKeyForCluster",{enumerable:!0,get:function(){return y.getPythProgramKeyForCluster}}),Object.defineProperty(t,"getPythClusterApiUrl",{enumerable:!0,get:function(){return y.getPythClusterApiUrl}});var g=Gv();Object.defineProperty(t,"pythOracleProgram",{enumerable:!0,get:function(){return g.pythOracleProgram}}),Object.defineProperty(t,"pythOracleCoder",{enumerable:!0,get:function(){return g.pythOracleCoder}}),Object.defineProperty(t,"pythIdl",{enumerable:!0,get:function(){return g.pythIdl}})}(Hf)),Hf}var Yv=Zv(),Jv="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Xv(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Qv(t){if(t.__esModule)return t;var e=t.default;if("function"==typeof e){var r=function t(){return this instanceof t?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach((function(e){var n=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(r,e,n.get?n:{enumerable:!0,get:function(){return t[e]}})})),r}for(var t_={},e_={byteLength:function(t){var e=a_(t),r=e[0],n=e[1];return 3*(r+n)/4-n},toByteArray:function(t){var e,r,n=a_(t),i=n[0],o=n[1],s=new i_(function(t,e,r){return 3*(e+r)/4-r}(0,i,o)),a=0,u=o>0?i-4:i;for(r=0;r<u;r+=4)e=n_[t.charCodeAt(r)]<<18|n_[t.charCodeAt(r+1)]<<12|n_[t.charCodeAt(r+2)]<<6|n_[t.charCodeAt(r+3)],s[a++]=e>>16&255,s[a++]=e>>8&255,s[a++]=255&e;return 2===o&&(e=n_[t.charCodeAt(r)]<<2|n_[t.charCodeAt(r+1)]>>4,s[a++]=255&e),1===o&&(e=n_[t.charCodeAt(r)]<<10|n_[t.charCodeAt(r+1)]<<4|n_[t.charCodeAt(r+2)]>>2,s[a++]=e>>8&255,s[a++]=255&e),s},fromByteArray:function(t){for(var e,r=t.length,n=r%3,i=[],o=16383,s=0,a=r-n;s<a;s+=o)i.push(u_(t,s,s+o>a?a:s+o));return 1===n?(e=t[r-1],i.push(r_[e>>2]+r_[e<<4&63]+"==")):2===n&&(e=(t[r-2]<<8)+t[r-1],i.push(r_[e>>10]+r_[e>>4&63]+r_[e<<2&63]+"=")),i.join("")}},r_=[],n_=[],i_="undefined"!=typeof Uint8Array?Uint8Array:Array,o_="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s_=0;s_<64;++s_)r_[s_]=o_[s_],n_[o_.charCodeAt(s_)]=s_;function a_(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function u_(t,e,r){for(var n,i,o=[],s=e;s<r;s+=3)n=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]),o.push(r_[(i=n)>>18&63]+r_[i>>12&63]+r_[i>>6&63]+r_[63&i]);return o.join("")}n_["-".charCodeAt(0)]=62,n_["_".charCodeAt(0)]=63;var c_={};
|
|
25
25
|
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */function h_(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function l_(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function f_(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}c_.read=function(t,e,r,n,i){var o,s,a=8*i-n-1,u=(1<<a)-1,c=u>>1,h=-7,l=r?i-1:0,f=r?-1:1,d=t[e+l];for(l+=f,o=d&(1<<-h)-1,d>>=-h,h+=a;h>0;o=256*o+t[e+l],l+=f,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=n;h>0;s=256*s+t[e+l],l+=f,h-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=c}return(d?-1:1)*s*Math.pow(2,o-n)},c_.write=function(t,e,r,n,i,o){var s,a,u,c=8*o-i-1,h=(1<<c)-1,l=h>>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=h):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+l>=1?f/u:f*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=h?(a=0,s=h):s+l>=1?(a=(e*u-1)*Math.pow(2,i),s+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;t[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<<i|a,c+=i;c>0;t[r+d]=255&s,d+=p,s/=256,c-=8);t[r+d-p]|=128*y},
|
|
26
26
|
/*!
|
|
27
27
|
* The buffer module from node.js, for the browser.
|
|
@@ -29,17 +29,17 @@ const _o=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff
|
|
|
29
29
|
* @author Feross Aboukhadijeh <https://feross.org>
|
|
30
30
|
* @license MIT
|
|
31
31
|
*/
|
|
32
|
-
function(t){const e=e_,r=c_,n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=s,t.SlowBuffer=function(t){return+t!=t&&(t=0),s.alloc(+t)},t.INSPECT_MAX_BYTES=50;const i=2147483647;function o(t){if(t>i)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,s.prototype),e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return a(t,e,r)}function a(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|d(t,e);let n=o(r);const i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if($(t,Uint8Array)){const e=new Uint8Array(t);return l(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if($(t,ArrayBuffer)||t&&$(t.buffer,ArrayBuffer))return l(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&($(t,SharedArrayBuffer)||t&&$(t.buffer,SharedArrayBuffer)))return l(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return s.from(n,e,r);const i=function(t){if(s.isBuffer(t)){const e=0|f(t.length),r=o(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||G(t.length)?o(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return s.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function u(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function c(t){return u(t),o(t<0?0:0|f(t))}function h(t){const e=t.length<0?0:0|f(t.length),r=o(e);for(let n=0;n<e;n+=1)r[n]=255&t[n];return r}function l(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,s.prototype),n}function f(t){if(t>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function d(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||$(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return q(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return V(t).length;default:if(i)return n?-1:q(t).length;e=(""+e).toLowerCase(),i=!0}}function p(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return B(this,e,r);case"utf8":case"utf-8":return x(this,e,r);case"ascii":return A(this,e,r);case"latin1":case"binary":return I(this,e,r);case"base64":return E(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return M(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function y(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),G(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:m(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):m(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function m(t,e,r,n,i){let o,s=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,r/=2}function c(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){let n=-1;for(o=r;o<a;o++)if(c(t,o)===c(e,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===u)return n*s}else-1!==n&&(o-=o-n),n=-1}else for(r+u>a&&(r=a-u),o=r;o>=0;o--){let r=!0;for(let n=0;n<u;n++)if(c(t,o+n)!==c(e,n)){r=!1;break}if(r)return o}return-1}function w(t,e,r,n){r=Number(r)||0;const i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;const o=e.length;let s;for(n>o/2&&(n=o/2),s=0;s<n;++s){const n=parseInt(e.substr(2*s,2),16);if(G(n))return s;t[r+s]=n}return s}function b(t,e,r,n){return H(q(e,t.length-r),t,r,n)}function v(t,e,r,n){return H(function(t){const e=[];for(let r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function _(t,e,r,n){return H(V(e),t,r,n)}function k(t,e,r,n){return H(function(t,e){let r,n,i;const o=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function E(t,r,n){return 0===r&&n===t.length?e.fromByteArray(t):e.fromByteArray(t.slice(r,n))}function x(t,e,r){r=Math.min(t.length,r);const n=[];let i=e;for(;i<r;){const e=t[i];let o=null,s=e>239?4:e>223?3:e>191?2:1;if(i+s<=r){let r,n,a,u;switch(s){case 1:e<128&&(o=e);break;case 2:r=t[i+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(o=u));break;case 3:r=t[i+1],n=t[i+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(o=u));break;case 4:r=t[i+1],n=t[i+2],a=t[i+3],128==(192&r)&&128==(192&n)&&128==(192&a)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&a,u>65535&&u<1114112&&(o=u))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=s}return function(t){const e=t.length;if(e<=S)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=S));return r}(n)}t.kMaxLength=i,s.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),s.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}}),Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}}),s.poolSize=8192,s.from=function(t,e,r){return a(t,e,r)},Object.setPrototypeOf(s.prototype,Uint8Array.prototype),Object.setPrototypeOf(s,Uint8Array),s.alloc=function(t,e,r){return function(t,e,r){return u(t),t<=0?o(t):void 0!==e?"string"==typeof r?o(t).fill(e,r):o(t).fill(e):o(t)}(t,e,r)},s.allocUnsafe=function(t){return c(t)},s.allocUnsafeSlow=function(t){return c(t)},s.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==s.prototype},s.compare=function(t,e){if($(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),$(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),!s.isBuffer(t)||!s.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,n=e.length;for(let i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},s.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},s.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return s.alloc(0);let r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;const n=s.allocUnsafe(e);let i=0;for(r=0;r<t.length;++r){let e=t[r];if($(e,Uint8Array))i+e.length>n.length?(s.isBuffer(e)||(e=s.from(e)),e.copy(n,i)):Uint8Array.prototype.set.call(n,e,i);else{if(!s.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,i)}i+=e.length}return n},s.byteLength=d,s.prototype._isBuffer=!0,s.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)y(this,e,e+1);return this},s.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)y(this,e,e+3),y(this,e+1,e+2);return this},s.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)y(this,e,e+7),y(this,e+1,e+6),y(this,e+2,e+5),y(this,e+3,e+4);return this},s.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?x(this,0,t):p.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){let e="";const r=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},n&&(s.prototype[n]=s.prototype.inspect),s.prototype.compare=function(t,e,r,n,i){if($(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;let o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const u=Math.min(o,a),c=this.slice(n,i),h=t.slice(e,r);for(let t=0;t<u;++t)if(c[t]!==h[t]){o=c[t],a=h[t];break}return o<a?-1:a<o?1:0},s.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},s.prototype.indexOf=function(t,e,r){return g(this,t,e,r,!0)},s.prototype.lastIndexOf=function(t,e,r){return g(this,t,e,r,!1)},s.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let o=!1;for(;;)switch(n){case"hex":return w(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":case"latin1":case"binary":return v(this,t,e,r);case"base64":return _(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const S=4096;function A(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function I(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function B(t,e,r){const n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let n=e;n<r;++n)i+=Z[t[n]];return i}function M(t,e,r){const n=t.slice(e,r);let i="";for(let t=0;t<n.length-1;t+=2)i+=String.fromCharCode(n[t]+256*n[t+1]);return i}function R(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function P(t,e,r,n,i,o){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function T(t,e,r,n,i){j(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,r}function O(t,e,r,n,i){j(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o>>=8,t[r+6]=o,o>>=8,t[r+5]=o,o>>=8,t[r+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=s,s>>=8,t[r+2]=s,s>>=8,t[r+1]=s,s>>=8,t[r]=s,r+8}function L(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function U(t,e,n,i,o){return e=+e,n>>>=0,o||L(t,0,n,4),r.write(t,e,n,i,23,4),n+4}function C(t,e,n,i,o){return e=+e,n>>>=0,o||L(t,0,n,8),r.write(t,e,n,i,52,8),n+8}s.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);const n=this.subarray(t,e);return Object.setPrototypeOf(n,s.prototype),n},s.prototype.readUintLE=s.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||R(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return n},s.prototype.readUintBE=s.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||R(t,e,this.length);let n=this[t+--e],i=1;for(;e>0&&(i*=256);)n+=this[t+--e]*i;return n},s.prototype.readUint8=s.prototype.readUInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),this[t]},s.prototype.readUint16LE=s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUint16BE=s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUint32LE=s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUint32BE=s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readBigUInt64LE=Y((function(t){W(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||K(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(i)<<BigInt(32))})),s.prototype.readBigUInt64BE=Y((function(t){W(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||K(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<<BigInt(32))+BigInt(i)})),s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||R(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||R(t,e,this.length);let n=e,i=1,o=this[t+--n];for(;n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},s.prototype.readInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||R(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||R(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readBigInt64LE=Y((function(t){W(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||K(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)})),s.prototype.readBigInt64BE=Y((function(t){W(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||K(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+r)})),s.prototype.readFloatLE=function(t,e){return t>>>=0,e||R(t,4,this.length),r.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||R(t,4,this.length),r.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||R(t,8,this.length),r.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||R(t,8,this.length),r.read(this,t,!1,52,8)},s.prototype.writeUintLE=s.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||P(this,t,e,r,Math.pow(2,8*r)-1,0);let i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},s.prototype.writeUintBE=s.prototype.writeUIntBE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||P(this,t,e,r,Math.pow(2,8*r)-1,0);let i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},s.prototype.writeUint8=s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeBigUInt64LE=Y((function(t,e=0){return T(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),s.prototype.writeBigUInt64BE=Y((function(t,e=0){return O(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);P(this,t,e,r,n-1,-n)}let i=0,o=1,s=0;for(this[e]=255&t;++i<r&&(o*=256);)t<0&&0===s&&0!==this[e+i-1]&&(s=1),this[e+i]=(t/o>>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);P(this,t,e,r,n-1,-n)}let i=r-1,o=1,s=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/o>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeBigInt64LE=Y((function(t,e=0){return T(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),s.prototype.writeBigInt64BE=Y((function(t,e=0){return O(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),s.prototype.writeFloatLE=function(t,e,r){return U(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return U(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return C(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return C(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);const i=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),i},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){const e=t.charCodeAt(0);("utf8"===n&&e<128||"latin1"===n)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;let i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else{const o=s.isBuffer(t)?t:s.from(t,n),a=o.length;if(0===a)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<r-e;++i)this[i+e]=o[i%a]}return this};const N={};function z(t,e,r){N[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function D(t){let e="",r=t.length;const n="-"===t[0]?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function j(t,e,r,n,i,o){if(t>r||t<e){const n="bigint"==typeof e?"n":"";let i;throw i=o>3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(o+1)}${n}`:`>= -(2${n} ** ${8*(o+1)-1}${n}) and < 2 ** ${8*(o+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new N.ERR_OUT_OF_RANGE("value",i,t)}!function(t,e,r){W(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||K(e,t.length-(r+1))}(n,i,o)}function W(t,e){if("number"!=typeof t)throw new N.ERR_INVALID_ARG_TYPE(e,"number",t)}function K(t,e,r){if(Math.floor(t)!==t)throw W(t,r),new N.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new N.ERR_BUFFER_OUT_OF_BOUNDS;throw new N.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}z("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),z("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),z("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=D(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=D(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n}),RangeError);const F=/[^+/0-9A-Za-z-_]/g;function q(t,e){let r;e=e||1/0;const n=t.length;let i=null;const o=[];for(let s=0;s<n;++s){if(r=t.charCodeAt(s),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=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((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function V(t){return e.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(F,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function H(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function $(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function G(t){return t!=t}const Z=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function Y(t){return"undefined"==typeof BigInt?J:t}function J(){throw new Error("BigInt not supported")}}(t_);const d_="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,p_=t=>t instanceof Uint8Array,y_=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),g_=(t,e)=>t<<32-e|t>>>e
|
|
33
|
-
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */;if(68!==new Uint8Array(new Uint32Array([287454020]).buffer)[0])throw new Error("Non little-endian hardware is not supported");function m_(t){if("string"==typeof t&&(t=function(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}(t)),!p_(t))throw new Error("expected Uint8Array, got "+typeof t);return t}class w_{clone(){return this._cloneInto()}}function b_(t){const e=e=>t().update(m_(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function v_(t=32){if(d_&&"function"==typeof d_.getRandomValues)return d_.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}class __ extends w_{constructor(t,e,r,n){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=y_(this.buffer)}update(t){f_(this);const{view:e,buffer:r,blockLen:n}=this,i=(t=m_(t)).length;for(let o=0;o<i;){const s=Math.min(n-this.pos,i-o);if(s!==n)r.set(t.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===n&&(this.process(e,0),this.pos=0);else{const e=y_(t);for(;n<=i-o;o+=n)this.process(e,o)}}return this.length+=t.length,this.roundClean(),this}digestInto(t){f_(this),function(t,e){l_(t);const r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:n,isLE:i}=this;let{pos:o}=this;e[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>n-o&&(this.process(r,0),o=0);for(let t=o;t<n;t++)e[t]=0;!function(t,e,r,n){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,r,n);const i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),a=Number(r&o),u=n?4:0,c=n?0:4;t.setUint32(e+u,s,n),t.setUint32(e+c,a,n)}(r,n-8,BigInt(8*this.length),i),this.process(r,0);const s=y_(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=a/4,c=this.get();if(u>c.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<u;t++)s.setUint32(4*t,c[t],i)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:r,length:n,finished:i,destroyed:o,pos:s}=this;return t.length=n,t.pos=s,t.finished=i,t.destroyed=o,n%e&&t.buffer.set(r),t}}const k_=BigInt(2**32-1),E_=BigInt(32);function x_(t,e=!1){return e?{h:Number(t&k_),l:Number(t>>E_&k_)}:{h:0|Number(t>>E_&k_),l:0|Number(t&k_)}}const S_={fromBig:x_,split:function(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;i<t.length;i++){const{h:o,l:s}=x_(t[i],e);[r[i],n[i]]=[o,s]}return[r,n]},toBig:(t,e)=>BigInt(t>>>0)<<E_|BigInt(e>>>0),shrSH:(t,e,r)=>t>>>r,shrSL:(t,e,r)=>t<<32-r|e>>>r,rotrSH:(t,e,r)=>t>>>r|e<<32-r,rotrSL:(t,e,r)=>t<<32-r|e>>>r,rotrBH:(t,e,r)=>t<<64-r|e>>>r-32,rotrBL:(t,e,r)=>t>>>r-32|e<<64-r,rotr32H:(t,e)=>e,rotr32L:(t,e)=>t,rotlSH:(t,e,r)=>t<<r|e>>>32-r,rotlSL:(t,e,r)=>e<<r|t>>>32-r,rotlBH:(t,e,r)=>e<<r-32|t>>>64-r,rotlBL:(t,e,r)=>t<<r-32|e>>>64-r,add:function(t,e,r,n){const i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:0|i}},add3L:(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),add3H:(t,e,r,n)=>e+r+n+(t/2**32|0)|0,add4L:(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),add4H:(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0,add5H:(t,e,r,n,i,o)=>e+r+n+i+o+(t/2**32|0)|0,add5L:(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0)};var A_=S_;const[I_,B_]=A_.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((t=>BigInt(t)))),M_=new Uint32Array(80),R_=new Uint32Array(80);class P_ extends __{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:t,Al:e,Bh:r,Bl:n,Ch:i,Cl:o,Dh:s,Dl:a,Eh:u,El:c,Fh:h,Fl:l,Gh:f,Gl:d,Hh:p,Hl:y}=this;return[t,e,r,n,i,o,s,a,u,c,h,l,f,d,p,y]}set(t,e,r,n,i,o,s,a,u,c,h,l,f,d,p,y){this.Ah=0|t,this.Al=0|e,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|u,this.El=0|c,this.Fh=0|h,this.Fl=0|l,this.Gh=0|f,this.Gl=0|d,this.Hh=0|p,this.Hl=0|y}process(t,e){for(let r=0;r<16;r++,e+=4)M_[r]=t.getUint32(e),R_[r]=t.getUint32(e+=4);for(let t=16;t<80;t++){const e=0|M_[t-15],r=0|R_[t-15],n=A_.rotrSH(e,r,1)^A_.rotrSH(e,r,8)^A_.shrSH(e,r,7),i=A_.rotrSL(e,r,1)^A_.rotrSL(e,r,8)^A_.shrSL(e,r,7),o=0|M_[t-2],s=0|R_[t-2],a=A_.rotrSH(o,s,19)^A_.rotrBH(o,s,61)^A_.shrSH(o,s,6),u=A_.rotrSL(o,s,19)^A_.rotrBL(o,s,61)^A_.shrSL(o,s,6),c=A_.add4L(i,u,R_[t-7],R_[t-16]),h=A_.add4H(c,n,a,M_[t-7],M_[t-16]);M_[t]=0|h,R_[t]=0|c}let{Ah:r,Al:n,Bh:i,Bl:o,Ch:s,Cl:a,Dh:u,Dl:c,Eh:h,El:l,Fh:f,Fl:d,Gh:p,Gl:y,Hh:g,Hl:m}=this;for(let t=0;t<80;t++){const e=A_.rotrSH(h,l,14)^A_.rotrSH(h,l,18)^A_.rotrBH(h,l,41),w=A_.rotrSL(h,l,14)^A_.rotrSL(h,l,18)^A_.rotrBL(h,l,41),b=h&f^~h&p,v=l&d^~l&y,_=A_.add5L(m,w,v,B_[t],R_[t]),k=A_.add5H(_,g,e,b,I_[t],M_[t]),E=0|_,x=A_.rotrSH(r,n,28)^A_.rotrBH(r,n,34)^A_.rotrBH(r,n,39),S=A_.rotrSL(r,n,28)^A_.rotrBL(r,n,34)^A_.rotrBL(r,n,39),A=r&i^r&s^i&s,I=n&o^n&a^o&a;g=0|p,m=0|y,p=0|f,y=0|d,f=0|h,d=0|l,({h:h,l:l}=A_.add(0|u,0|c,0|k,0|E)),u=0|s,c=0|a,s=0|i,a=0|o,i=0|r,o=0|n;const B=A_.add3L(E,S,I);r=A_.add3H(B,k,x,A),n=0|B}({h:r,l:n}=A_.add(0|this.Ah,0|this.Al,0|r,0|n)),({h:i,l:o}=A_.add(0|this.Bh,0|this.Bl,0|i,0|o)),({h:s,l:a}=A_.add(0|this.Ch,0|this.Cl,0|s,0|a)),({h:u,l:c}=A_.add(0|this.Dh,0|this.Dl,0|u,0|c)),({h:h,l:l}=A_.add(0|this.Eh,0|this.El,0|h,0|l)),({h:f,l:d}=A_.add(0|this.Fh,0|this.Fl,0|f,0|d)),({h:p,l:y}=A_.add(0|this.Gh,0|this.Gl,0|p,0|y)),({h:g,l:m}=A_.add(0|this.Hh,0|this.Hl,0|g,0|m)),this.set(r,n,i,o,s,a,u,c,h,l,f,d,p,y,g,m)}roundClean(){M_.fill(0),R_.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 T_=b_((()=>new P_)),
|
|
34
|
-
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function z_(t){if(!C_(t))throw new Error("Uint8Array expected");let e="";for(let r=0;r<t.length;r++)e+=N_[t[r]];return e}function D_(t){const e=t.toString(16);return 1&e.length?`0${e}`:e}function j_(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);return BigInt(""===t?"0":`0x${t}`)}function W_(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);const e=t.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(e/2);for(let e=0;e<r.length;e++){const n=2*e,i=t.slice(n,n+2),o=Number.parseInt(i,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");r[e]=o}return r}function
|
|
35
|
-
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ek=BigInt(0),rk=BigInt(1),nk=BigInt(2),ik=BigInt(3),ok=BigInt(4),sk=BigInt(5),ak=BigInt(8);function uk(t,e){const r=t%e;return r>=ek?r:e+r}function ck(t,e,r){if(r<=ek||e<ek)throw new Error("Expected power/modulo > 0");if(r===rk)return ek;let n=rk;for(;e>ek;)e&rk&&(n=n*t%r),t=t*t%r,e>>=rk;return n}function hk(t,e,r){let n=t;for(;e-- >ek;)n*=n,n%=r;return n}function lk(t,e){if(t===ek||e<=ek)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=uk(t,e),n=e,i=ek,o=rk;for(;r!==ek;){const t=n%r,e=i-o*(n/r);n=r,r=t,i=o,o=e}if(n!==rk)throw new Error("invert: does not exist");return uk(i,e)}BigInt(9),BigInt(16);const fk=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function dk(t,e){const r=void 0!==e?e:t.toString(2).length;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}function pk(t,e,r=!1,n={}){if(t<=ek)throw new Error(`Expected Field ORDER > 0, got ${t}`);const{nBitLength:i,nByteLength:o}=dk(t,e);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");const s=function(t){if(t%ok===ik){const e=(t+rk)/ok;return function(t,r){const n=t.pow(r,e);if(!t.eql(t.sqr(n),r))throw new Error("Cannot find square root");return n}}if(t%ak===sk){const e=(t-sk)/ak;return function(t,r){const n=t.mul(r,nk),i=t.pow(n,e),o=t.mul(r,i),s=t.mul(t.mul(o,nk),i),a=t.mul(o,t.sub(s,t.ONE));if(!t.eql(t.sqr(a),r))throw new Error("Cannot find square root");return a}}return function(t){const e=(t-rk)/nk;let r,n,i;for(r=t-rk,n=0;r%nk===ek;r/=nk,n++);for(i=nk;i<t&&ck(i,e,t)!==t-rk;i++);if(1===n){const e=(t+rk)/ok;return function(t,r){const n=t.pow(r,e);if(!t.eql(t.sqr(n),r))throw new Error("Cannot find square root");return n}}const o=(r+rk)/nk;return function(t,s){if(t.pow(s,e)===t.neg(t.ONE))throw new Error("Cannot find square root");let a=n,u=t.pow(t.mul(t.ONE,i),r),c=t.pow(s,o),h=t.pow(s,r);for(;!t.eql(h,t.ONE);){if(t.eql(h,t.ZERO))return t.ZERO;let e=1;for(let r=t.sqr(h);e<a&&!t.eql(r,t.ONE);e++)r=t.sqr(r);const r=t.pow(u,rk<<BigInt(a-e-1));u=t.sqr(r),c=t.mul(c,r),h=t.mul(h,u),a=e}return c}}(t)}(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:o,MASK:G_(i),ZERO:ek,ONE:rk,create:e=>uk(e,t),isValid:e=>{if("bigint"!=typeof e)throw new Error("Invalid field element: expected bigint, got "+typeof e);return ek<=e&&e<t},is0:t=>t===ek,isOdd:t=>(t&rk)===rk,neg:e=>uk(-e,t),eql:(t,e)=>t===e,sqr:e=>uk(e*e,t),add:(e,r)=>uk(e+r,t),sub:(e,r)=>uk(e-r,t),mul:(e,r)=>uk(e*r,t),pow:(t,e)=>function(t,e,r){if(r<ek)throw new Error("Expected power > 0");if(r===ek)return t.ONE;if(r===rk)return e;let n=t.ONE,i=e;for(;r>ek;)r&rk&&(n=t.mul(n,i)),i=t.sqr(i),r>>=rk;return n}(a,t,e),div:(e,r)=>uk(e*lk(r,t),t),sqrN:t=>t*t,addN:(t,e)=>t+e,subN:(t,e)=>t-e,mulN:(t,e)=>t*e,inv:e=>lk(e,t),sqrt:n.sqrt||(t=>s(a,t)),invertBatch:t=>function(t,e){const r=new Array(e.length),n=e.reduce(((e,n,i)=>t.is0(n)?e:(r[i]=e,t.mul(e,n))),t.ONE),i=t.inv(n);return e.reduceRight(((e,n,i)=>t.is0(n)?e:(r[i]=t.mul(e,r[i]),t.mul(e,n))),i),r}(a,t),cmov:(t,e,r)=>r?e:t,toBytes:t=>r?
|
|
32
|
+
function(t){const e=e_,r=c_,n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=s,t.SlowBuffer=function(t){return+t!=t&&(t=0),s.alloc(+t)},t.INSPECT_MAX_BYTES=50;const i=2147483647;function o(t){if(t>i)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,s.prototype),e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return a(t,e,r)}function a(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|d(t,e);let n=o(r);const i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if($(t,Uint8Array)){const e=new Uint8Array(t);return l(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if($(t,ArrayBuffer)||t&&$(t.buffer,ArrayBuffer))return l(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&($(t,SharedArrayBuffer)||t&&$(t.buffer,SharedArrayBuffer)))return l(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return s.from(n,e,r);const i=function(t){if(s.isBuffer(t)){const e=0|f(t.length),r=o(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||G(t.length)?o(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return s.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function u(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function c(t){return u(t),o(t<0?0:0|f(t))}function h(t){const e=t.length<0?0:0|f(t.length),r=o(e);for(let n=0;n<e;n+=1)r[n]=255&t[n];return r}function l(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,s.prototype),n}function f(t){if(t>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function d(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||$(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return V(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return q(t).length;default:if(i)return n?-1:V(t).length;e=(""+e).toLowerCase(),i=!0}}function p(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return B(this,e,r);case"utf8":case"utf-8":return x(this,e,r);case"ascii":return A(this,e,r);case"latin1":case"binary":return I(this,e,r);case"base64":return E(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return M(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function y(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),G(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:m(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):m(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function m(t,e,r,n,i){let o,s=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,r/=2}function c(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){let n=-1;for(o=r;o<a;o++)if(c(t,o)===c(e,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===u)return n*s}else-1!==n&&(o-=o-n),n=-1}else for(r+u>a&&(r=a-u),o=r;o>=0;o--){let r=!0;for(let n=0;n<u;n++)if(c(t,o+n)!==c(e,n)){r=!1;break}if(r)return o}return-1}function w(t,e,r,n){r=Number(r)||0;const i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;const o=e.length;let s;for(n>o/2&&(n=o/2),s=0;s<n;++s){const n=parseInt(e.substr(2*s,2),16);if(G(n))return s;t[r+s]=n}return s}function b(t,e,r,n){return H(V(e,t.length-r),t,r,n)}function v(t,e,r,n){return H(function(t){const e=[];for(let r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function _(t,e,r,n){return H(q(e),t,r,n)}function k(t,e,r,n){return H(function(t,e){let r,n,i;const o=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function E(t,r,n){return 0===r&&n===t.length?e.fromByteArray(t):e.fromByteArray(t.slice(r,n))}function x(t,e,r){r=Math.min(t.length,r);const n=[];let i=e;for(;i<r;){const e=t[i];let o=null,s=e>239?4:e>223?3:e>191?2:1;if(i+s<=r){let r,n,a,u;switch(s){case 1:e<128&&(o=e);break;case 2:r=t[i+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(o=u));break;case 3:r=t[i+1],n=t[i+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(o=u));break;case 4:r=t[i+1],n=t[i+2],a=t[i+3],128==(192&r)&&128==(192&n)&&128==(192&a)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&a,u>65535&&u<1114112&&(o=u))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=s}return function(t){const e=t.length;if(e<=S)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=S));return r}(n)}t.kMaxLength=i,s.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),s.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(s.prototype,"parent",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.buffer}}),Object.defineProperty(s.prototype,"offset",{enumerable:!0,get:function(){if(s.isBuffer(this))return this.byteOffset}}),s.poolSize=8192,s.from=function(t,e,r){return a(t,e,r)},Object.setPrototypeOf(s.prototype,Uint8Array.prototype),Object.setPrototypeOf(s,Uint8Array),s.alloc=function(t,e,r){return function(t,e,r){return u(t),t<=0?o(t):void 0!==e?"string"==typeof r?o(t).fill(e,r):o(t).fill(e):o(t)}(t,e,r)},s.allocUnsafe=function(t){return c(t)},s.allocUnsafeSlow=function(t){return c(t)},s.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==s.prototype},s.compare=function(t,e){if($(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),$(e,Uint8Array)&&(e=s.from(e,e.offset,e.byteLength)),!s.isBuffer(t)||!s.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,n=e.length;for(let i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},s.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},s.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return s.alloc(0);let r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;const n=s.allocUnsafe(e);let i=0;for(r=0;r<t.length;++r){let e=t[r];if($(e,Uint8Array))i+e.length>n.length?(s.isBuffer(e)||(e=s.from(e)),e.copy(n,i)):Uint8Array.prototype.set.call(n,e,i);else{if(!s.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,i)}i+=e.length}return n},s.byteLength=d,s.prototype._isBuffer=!0,s.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)y(this,e,e+1);return this},s.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)y(this,e,e+3),y(this,e+1,e+2);return this},s.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)y(this,e,e+7),y(this,e+1,e+6),y(this,e+2,e+5),y(this,e+3,e+4);return this},s.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?x(this,0,t):p.apply(this,arguments)},s.prototype.toLocaleString=s.prototype.toString,s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){let e="";const r=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},n&&(s.prototype[n]=s.prototype.inspect),s.prototype.compare=function(t,e,r,n,i){if($(t,Uint8Array)&&(t=s.from(t,t.offset,t.byteLength)),!s.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;let o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0);const u=Math.min(o,a),c=this.slice(n,i),h=t.slice(e,r);for(let t=0;t<u;++t)if(c[t]!==h[t]){o=c[t],a=h[t];break}return o<a?-1:a<o?1:0},s.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},s.prototype.indexOf=function(t,e,r){return g(this,t,e,r,!0)},s.prototype.lastIndexOf=function(t,e,r){return g(this,t,e,r,!1)},s.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let o=!1;for(;;)switch(n){case"hex":return w(this,t,e,r);case"utf8":case"utf-8":return b(this,t,e,r);case"ascii":case"latin1":case"binary":return v(this,t,e,r);case"base64":return _(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const S=4096;function A(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function I(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function B(t,e,r){const n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let n=e;n<r;++n)i+=Z[t[n]];return i}function M(t,e,r){const n=t.slice(e,r);let i="";for(let t=0;t<n.length-1;t+=2)i+=String.fromCharCode(n[t]+256*n[t+1]);return i}function R(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function P(t,e,r,n,i,o){if(!s.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function T(t,e,r,n,i){j(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,r}function L(t,e,r,n,i){j(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o>>=8,t[r+6]=o,o>>=8,t[r+5]=o,o>>=8,t[r+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=s,s>>=8,t[r+2]=s,s>>=8,t[r+1]=s,s>>=8,t[r]=s,r+8}function O(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function U(t,e,n,i,o){return e=+e,n>>>=0,o||O(t,0,n,4),r.write(t,e,n,i,23,4),n+4}function C(t,e,n,i,o){return e=+e,n>>>=0,o||O(t,0,n,8),r.write(t,e,n,i,52,8),n+8}s.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);const n=this.subarray(t,e);return Object.setPrototypeOf(n,s.prototype),n},s.prototype.readUintLE=s.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||R(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return n},s.prototype.readUintBE=s.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||R(t,e,this.length);let n=this[t+--e],i=1;for(;e>0&&(i*=256);)n+=this[t+--e]*i;return n},s.prototype.readUint8=s.prototype.readUInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),this[t]},s.prototype.readUint16LE=s.prototype.readUInt16LE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUint16BE=s.prototype.readUInt16BE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUint32LE=s.prototype.readUInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUint32BE=s.prototype.readUInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readBigUInt64LE=Y((function(t){W(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||F(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(i)<<BigInt(32))})),s.prototype.readBigUInt64BE=Y((function(t){W(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||F(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<<BigInt(32))+BigInt(i)})),s.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||R(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||R(t,e,this.length);let n=e,i=1,o=this[t+--n];for(;n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},s.prototype.readInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){t>>>=0,e||R(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){t>>>=0,e||R(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readBigInt64LE=Y((function(t){W(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||F(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)})),s.prototype.readBigInt64BE=Y((function(t){W(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||F(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+r)})),s.prototype.readFloatLE=function(t,e){return t>>>=0,e||R(t,4,this.length),r.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return t>>>=0,e||R(t,4,this.length),r.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return t>>>=0,e||R(t,8,this.length),r.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return t>>>=0,e||R(t,8,this.length),r.read(this,t,!1,52,8)},s.prototype.writeUintLE=s.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||P(this,t,e,r,Math.pow(2,8*r)-1,0);let i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},s.prototype.writeUintBE=s.prototype.writeUIntBE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||P(this,t,e,r,Math.pow(2,8*r)-1,0);let i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},s.prototype.writeUint8=s.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,1,255,0),this[e]=255&t,e+1},s.prototype.writeUint16LE=s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeUint16BE=s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeUint32LE=s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},s.prototype.writeUint32BE=s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeBigUInt64LE=Y((function(t,e=0){return T(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),s.prototype.writeBigUInt64BE=Y((function(t,e=0){return L(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);P(this,t,e,r,n-1,-n)}let i=0,o=1,s=0;for(this[e]=255&t;++i<r&&(o*=256);)t<0&&0===s&&0!==this[e+i-1]&&(s=1),this[e+i]=(t/o>>0)-s&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);P(this,t,e,r,n-1,-n)}let i=r-1,o=1,s=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/o>>0)-s&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||P(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},s.prototype.writeBigInt64LE=Y((function(t,e=0){return T(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),s.prototype.writeBigInt64BE=Y((function(t,e=0){return L(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),s.prototype.writeFloatLE=function(t,e,r){return U(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return U(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return C(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return C(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(!s.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);const i=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),i},s.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!s.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){const e=t.charCodeAt(0);("utf8"===n&&e<128||"latin1"===n)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;let i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else{const o=s.isBuffer(t)?t:s.from(t,n),a=o.length;if(0===a)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<r-e;++i)this[i+e]=o[i%a]}return this};const N={};function z(t,e,r){N[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function D(t){let e="",r=t.length;const n="-"===t[0]?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function j(t,e,r,n,i,o){if(t>r||t<e){const n="bigint"==typeof e?"n":"";let i;throw i=o>3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(o+1)}${n}`:`>= -(2${n} ** ${8*(o+1)-1}${n}) and < 2 ** ${8*(o+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new N.ERR_OUT_OF_RANGE("value",i,t)}!function(t,e,r){W(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||F(e,t.length-(r+1))}(n,i,o)}function W(t,e){if("number"!=typeof t)throw new N.ERR_INVALID_ARG_TYPE(e,"number",t)}function F(t,e,r){if(Math.floor(t)!==t)throw W(t,r),new N.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new N.ERR_BUFFER_OUT_OF_BOUNDS;throw new N.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}z("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),z("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),z("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=D(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=D(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n}),RangeError);const K=/[^+/0-9A-Za-z-_]/g;function V(t,e){let r;e=e||1/0;const n=t.length;let i=null;const o=[];for(let s=0;s<n;++s){if(r=t.charCodeAt(s),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=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((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function q(t){return e.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(K,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function H(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function $(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function G(t){return t!=t}const Z=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function Y(t){return"undefined"==typeof BigInt?J:t}function J(){throw new Error("BigInt not supported")}}(t_);const d_="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,p_=t=>t instanceof Uint8Array,y_=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),g_=(t,e)=>t<<32-e|t>>>e
|
|
33
|
+
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */;if(68!==new Uint8Array(new Uint32Array([287454020]).buffer)[0])throw new Error("Non little-endian hardware is not supported");function m_(t){if("string"==typeof t&&(t=function(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}(t)),!p_(t))throw new Error("expected Uint8Array, got "+typeof t);return t}class w_{clone(){return this._cloneInto()}}function b_(t){const e=e=>t().update(m_(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function v_(t=32){if(d_&&"function"==typeof d_.getRandomValues)return d_.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}class __ extends w_{constructor(t,e,r,n){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=y_(this.buffer)}update(t){f_(this);const{view:e,buffer:r,blockLen:n}=this,i=(t=m_(t)).length;for(let o=0;o<i;){const s=Math.min(n-this.pos,i-o);if(s!==n)r.set(t.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===n&&(this.process(e,0),this.pos=0);else{const e=y_(t);for(;n<=i-o;o+=n)this.process(e,o)}}return this.length+=t.length,this.roundClean(),this}digestInto(t){f_(this),function(t,e){l_(t);const r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:n,isLE:i}=this;let{pos:o}=this;e[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>n-o&&(this.process(r,0),o=0);for(let t=o;t<n;t++)e[t]=0;!function(t,e,r,n){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,r,n);const i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),a=Number(r&o),u=n?4:0,c=n?0:4;t.setUint32(e+u,s,n),t.setUint32(e+c,a,n)}(r,n-8,BigInt(8*this.length),i),this.process(r,0);const s=y_(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=a/4,c=this.get();if(u>c.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<u;t++)s.setUint32(4*t,c[t],i)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:r,length:n,finished:i,destroyed:o,pos:s}=this;return t.length=n,t.pos=s,t.finished=i,t.destroyed=o,n%e&&t.buffer.set(r),t}}const k_=BigInt(2**32-1),E_=BigInt(32);function x_(t,e=!1){return e?{h:Number(t&k_),l:Number(t>>E_&k_)}:{h:0|Number(t>>E_&k_),l:0|Number(t&k_)}}const S_={fromBig:x_,split:function(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;i<t.length;i++){const{h:o,l:s}=x_(t[i],e);[r[i],n[i]]=[o,s]}return[r,n]},toBig:(t,e)=>BigInt(t>>>0)<<E_|BigInt(e>>>0),shrSH:(t,e,r)=>t>>>r,shrSL:(t,e,r)=>t<<32-r|e>>>r,rotrSH:(t,e,r)=>t>>>r|e<<32-r,rotrSL:(t,e,r)=>t<<32-r|e>>>r,rotrBH:(t,e,r)=>t<<64-r|e>>>r-32,rotrBL:(t,e,r)=>t>>>r-32|e<<64-r,rotr32H:(t,e)=>e,rotr32L:(t,e)=>t,rotlSH:(t,e,r)=>t<<r|e>>>32-r,rotlSL:(t,e,r)=>e<<r|t>>>32-r,rotlBH:(t,e,r)=>e<<r-32|t>>>64-r,rotlBL:(t,e,r)=>t<<r-32|e>>>64-r,add:function(t,e,r,n){const i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:0|i}},add3L:(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),add3H:(t,e,r,n)=>e+r+n+(t/2**32|0)|0,add4L:(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),add4H:(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0,add5H:(t,e,r,n,i,o)=>e+r+n+i+o+(t/2**32|0)|0,add5L:(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0)};var A_=S_;const[I_,B_]=A_.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((t=>BigInt(t)))),M_=new Uint32Array(80),R_=new Uint32Array(80);class P_ extends __{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:t,Al:e,Bh:r,Bl:n,Ch:i,Cl:o,Dh:s,Dl:a,Eh:u,El:c,Fh:h,Fl:l,Gh:f,Gl:d,Hh:p,Hl:y}=this;return[t,e,r,n,i,o,s,a,u,c,h,l,f,d,p,y]}set(t,e,r,n,i,o,s,a,u,c,h,l,f,d,p,y){this.Ah=0|t,this.Al=0|e,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|u,this.El=0|c,this.Fh=0|h,this.Fl=0|l,this.Gh=0|f,this.Gl=0|d,this.Hh=0|p,this.Hl=0|y}process(t,e){for(let r=0;r<16;r++,e+=4)M_[r]=t.getUint32(e),R_[r]=t.getUint32(e+=4);for(let t=16;t<80;t++){const e=0|M_[t-15],r=0|R_[t-15],n=A_.rotrSH(e,r,1)^A_.rotrSH(e,r,8)^A_.shrSH(e,r,7),i=A_.rotrSL(e,r,1)^A_.rotrSL(e,r,8)^A_.shrSL(e,r,7),o=0|M_[t-2],s=0|R_[t-2],a=A_.rotrSH(o,s,19)^A_.rotrBH(o,s,61)^A_.shrSH(o,s,6),u=A_.rotrSL(o,s,19)^A_.rotrBL(o,s,61)^A_.shrSL(o,s,6),c=A_.add4L(i,u,R_[t-7],R_[t-16]),h=A_.add4H(c,n,a,M_[t-7],M_[t-16]);M_[t]=0|h,R_[t]=0|c}let{Ah:r,Al:n,Bh:i,Bl:o,Ch:s,Cl:a,Dh:u,Dl:c,Eh:h,El:l,Fh:f,Fl:d,Gh:p,Gl:y,Hh:g,Hl:m}=this;for(let t=0;t<80;t++){const e=A_.rotrSH(h,l,14)^A_.rotrSH(h,l,18)^A_.rotrBH(h,l,41),w=A_.rotrSL(h,l,14)^A_.rotrSL(h,l,18)^A_.rotrBL(h,l,41),b=h&f^~h&p,v=l&d^~l&y,_=A_.add5L(m,w,v,B_[t],R_[t]),k=A_.add5H(_,g,e,b,I_[t],M_[t]),E=0|_,x=A_.rotrSH(r,n,28)^A_.rotrBH(r,n,34)^A_.rotrBH(r,n,39),S=A_.rotrSL(r,n,28)^A_.rotrBL(r,n,34)^A_.rotrBL(r,n,39),A=r&i^r&s^i&s,I=n&o^n&a^o&a;g=0|p,m=0|y,p=0|f,y=0|d,f=0|h,d=0|l,({h:h,l:l}=A_.add(0|u,0|c,0|k,0|E)),u=0|s,c=0|a,s=0|i,a=0|o,i=0|r,o=0|n;const B=A_.add3L(E,S,I);r=A_.add3H(B,k,x,A),n=0|B}({h:r,l:n}=A_.add(0|this.Ah,0|this.Al,0|r,0|n)),({h:i,l:o}=A_.add(0|this.Bh,0|this.Bl,0|i,0|o)),({h:s,l:a}=A_.add(0|this.Ch,0|this.Cl,0|s,0|a)),({h:u,l:c}=A_.add(0|this.Dh,0|this.Dl,0|u,0|c)),({h:h,l:l}=A_.add(0|this.Eh,0|this.El,0|h,0|l)),({h:f,l:d}=A_.add(0|this.Fh,0|this.Fl,0|f,0|d)),({h:p,l:y}=A_.add(0|this.Gh,0|this.Gl,0|p,0|y)),({h:g,l:m}=A_.add(0|this.Hh,0|this.Hl,0|g,0|m)),this.set(r,n,i,o,s,a,u,c,h,l,f,d,p,y,g,m)}roundClean(){M_.fill(0),R_.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 T_=b_((()=>new P_)),L_=BigInt(0),O_=BigInt(1),U_=BigInt(2),C_=t=>t instanceof Uint8Array,N_=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));
|
|
34
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function z_(t){if(!C_(t))throw new Error("Uint8Array expected");let e="";for(let r=0;r<t.length;r++)e+=N_[t[r]];return e}function D_(t){const e=t.toString(16);return 1&e.length?`0${e}`:e}function j_(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);return BigInt(""===t?"0":`0x${t}`)}function W_(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);const e=t.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(e/2);for(let e=0;e<r.length;e++){const n=2*e,i=t.slice(n,n+2),o=Number.parseInt(i,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");r[e]=o}return r}function F_(t){return j_(z_(t))}function K_(t){if(!C_(t))throw new Error("Uint8Array expected");return j_(z_(Uint8Array.from(t).reverse()))}function V_(t,e){return W_(t.toString(16).padStart(2*e,"0"))}function q_(t,e){return V_(t,e).reverse()}function H_(t,e,r){let n;if("string"==typeof e)try{n=W_(e)}catch(r){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${r}`)}else{if(!C_(e))throw new Error(`${t} must be hex string or Uint8Array`);n=Uint8Array.from(e)}const i=n.length;if("number"==typeof r&&i!==r)throw new Error(`${t} expected ${r} bytes, got ${i}`);return n}function $_(...t){const e=new Uint8Array(t.reduce(((t,e)=>t+e.length),0));let r=0;return t.forEach((t=>{if(!C_(t))throw new Error("Uint8Array expected");e.set(t,r),r+=t.length})),e}const G_=t=>(U_<<BigInt(t-1))-O_,Z_=t=>new Uint8Array(t),Y_=t=>Uint8Array.from(t);function J_(t,e,r){if("number"!=typeof t||t<2)throw new Error("hashLen must be a number");if("number"!=typeof e||e<2)throw new Error("qByteLen must be a number");if("function"!=typeof r)throw new Error("hmacFn must be a function");let n=Z_(t),i=Z_(t),o=0;const s=()=>{n.fill(1),i.fill(0),o=0},a=(...t)=>r(i,n,...t),u=(t=Z_())=>{i=a(Y_([0]),t),n=a(),0!==t.length&&(i=a(Y_([1]),t),n=a())},c=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let t=0;const r=[];for(;t<e;){n=a();const e=n.slice();r.push(e),t+=n.length}return $_(...r)};return(t,e)=>{let r;for(s(),u(t);!(r=e(c()));)u();return s(),r}}const X_={bigint:t=>"bigint"==typeof t,function:t=>"function"==typeof t,boolean:t=>"boolean"==typeof t,string:t=>"string"==typeof t,stringOrUint8Array:t=>"string"==typeof t||t instanceof Uint8Array,isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>"function"==typeof t&&Number.isSafeInteger(t.outputLen)};function Q_(t,e,r={}){const n=(e,r,n)=>{const i=X_[r];if("function"!=typeof i)throw new Error(`Invalid validator "${r}", expected function`);const o=t[e];if(!(n&&void 0===o||i(o,t)))throw new Error(`Invalid param ${String(e)}=${o} (${typeof o}), expected ${r}`)};for(const[t,r]of Object.entries(e))n(t,r,!1);for(const[t,e]of Object.entries(r))n(t,e,!0);return t}var tk=Object.freeze({__proto__:null,bytesToHex:z_,numberToHexUnpadded:D_,hexToNumber:j_,hexToBytes:W_,bytesToNumberBE:F_,bytesToNumberLE:K_,numberToBytesBE:V_,numberToBytesLE:q_,numberToVarBytesBE:function(t){return W_(D_(t))},ensureBytes:H_,concatBytes:$_,equalBytes:function(t,e){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0},utf8ToBytes:function(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))},bitLen:function(t){let e;for(e=0;t>L_;t>>=O_,e+=1);return e},bitGet:function(t,e){return t>>BigInt(e)&O_},bitSet:(t,e,r)=>t|(r?O_:L_)<<BigInt(e),bitMask:G_,createHmacDrbg:J_,validateObject:Q_});
|
|
35
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ek=BigInt(0),rk=BigInt(1),nk=BigInt(2),ik=BigInt(3),ok=BigInt(4),sk=BigInt(5),ak=BigInt(8);function uk(t,e){const r=t%e;return r>=ek?r:e+r}function ck(t,e,r){if(r<=ek||e<ek)throw new Error("Expected power/modulo > 0");if(r===rk)return ek;let n=rk;for(;e>ek;)e&rk&&(n=n*t%r),t=t*t%r,e>>=rk;return n}function hk(t,e,r){let n=t;for(;e-- >ek;)n*=n,n%=r;return n}function lk(t,e){if(t===ek||e<=ek)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=uk(t,e),n=e,i=ek,o=rk;for(;r!==ek;){const t=n%r,e=i-o*(n/r);n=r,r=t,i=o,o=e}if(n!==rk)throw new Error("invert: does not exist");return uk(i,e)}BigInt(9),BigInt(16);const fk=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function dk(t,e){const r=void 0!==e?e:t.toString(2).length;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}function pk(t,e,r=!1,n={}){if(t<=ek)throw new Error(`Expected Field ORDER > 0, got ${t}`);const{nBitLength:i,nByteLength:o}=dk(t,e);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");const s=function(t){if(t%ok===ik){const e=(t+rk)/ok;return function(t,r){const n=t.pow(r,e);if(!t.eql(t.sqr(n),r))throw new Error("Cannot find square root");return n}}if(t%ak===sk){const e=(t-sk)/ak;return function(t,r){const n=t.mul(r,nk),i=t.pow(n,e),o=t.mul(r,i),s=t.mul(t.mul(o,nk),i),a=t.mul(o,t.sub(s,t.ONE));if(!t.eql(t.sqr(a),r))throw new Error("Cannot find square root");return a}}return function(t){const e=(t-rk)/nk;let r,n,i;for(r=t-rk,n=0;r%nk===ek;r/=nk,n++);for(i=nk;i<t&&ck(i,e,t)!==t-rk;i++);if(1===n){const e=(t+rk)/ok;return function(t,r){const n=t.pow(r,e);if(!t.eql(t.sqr(n),r))throw new Error("Cannot find square root");return n}}const o=(r+rk)/nk;return function(t,s){if(t.pow(s,e)===t.neg(t.ONE))throw new Error("Cannot find square root");let a=n,u=t.pow(t.mul(t.ONE,i),r),c=t.pow(s,o),h=t.pow(s,r);for(;!t.eql(h,t.ONE);){if(t.eql(h,t.ZERO))return t.ZERO;let e=1;for(let r=t.sqr(h);e<a&&!t.eql(r,t.ONE);e++)r=t.sqr(r);const r=t.pow(u,rk<<BigInt(a-e-1));u=t.sqr(r),c=t.mul(c,r),h=t.mul(h,u),a=e}return c}}(t)}(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:o,MASK:G_(i),ZERO:ek,ONE:rk,create:e=>uk(e,t),isValid:e=>{if("bigint"!=typeof e)throw new Error("Invalid field element: expected bigint, got "+typeof e);return ek<=e&&e<t},is0:t=>t===ek,isOdd:t=>(t&rk)===rk,neg:e=>uk(-e,t),eql:(t,e)=>t===e,sqr:e=>uk(e*e,t),add:(e,r)=>uk(e+r,t),sub:(e,r)=>uk(e-r,t),mul:(e,r)=>uk(e*r,t),pow:(t,e)=>function(t,e,r){if(r<ek)throw new Error("Expected power > 0");if(r===ek)return t.ONE;if(r===rk)return e;let n=t.ONE,i=e;for(;r>ek;)r&rk&&(n=t.mul(n,i)),i=t.sqr(i),r>>=rk;return n}(a,t,e),div:(e,r)=>uk(e*lk(r,t),t),sqrN:t=>t*t,addN:(t,e)=>t+e,subN:(t,e)=>t-e,mulN:(t,e)=>t*e,inv:e=>lk(e,t),sqrt:n.sqrt||(t=>s(a,t)),invertBatch:t=>function(t,e){const r=new Array(e.length),n=e.reduce(((e,n,i)=>t.is0(n)?e:(r[i]=e,t.mul(e,n))),t.ONE),i=t.inv(n);return e.reduceRight(((e,n,i)=>t.is0(n)?e:(r[i]=t.mul(e,r[i]),t.mul(e,n))),i),r}(a,t),cmov:(t,e,r)=>r?e:t,toBytes:t=>r?q_(t,o):V_(t,o),fromBytes:t=>{if(t.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${t.length}`);return r?K_(t):F_(t)}});return Object.freeze(a)}function yk(t){if("bigint"!=typeof t)throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function gk(t){const e=yk(t);return e+Math.ceil(e/2)}
|
|
36
36
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const mk=BigInt(0),wk=BigInt(1);function bk(t,e){const r=(t,e)=>{const r=e.negate();return t?r:e},n=t=>({windows:Math.ceil(e/t)+1,windowSize:2**(t-1)});return{constTimeNegate:r,unsafeLadder(e,r){let n=t.ZERO,i=e;for(;r>mk;)r&wk&&(n=n.add(i)),i=i.double(),r>>=wk;return n},precomputeWindow(t,e){const{windows:r,windowSize:i}=n(e),o=[];let s=t,a=s;for(let t=0;t<r;t++){a=s,o.push(a);for(let t=1;t<i;t++)a=a.add(s),o.push(a);s=a.double()}return o},wNAF(e,i,o){const{windows:s,windowSize:a}=n(e);let u=t.ZERO,c=t.BASE;const h=BigInt(2**e-1),l=2**e,f=BigInt(e);for(let t=0;t<s;t++){const e=t*a;let n=Number(o&h);o>>=f,n>a&&(n-=l,o+=wk);const s=e,d=e+Math.abs(n)-1,p=t%2!=0,y=n<0;0===n?c=c.add(r(p,i[s])):u=u.add(r(y,i[d]))}return{p:u,f:c}},wNAFCached(t,e,r,n){const i=t._WINDOW_SIZE||1;let o=e.get(t);return o||(o=this.precomputeWindow(t,i),1!==i&&e.set(t,n(o))),this.wNAF(i,o,r)}}}function vk(t){return Q_(t.Fp,fk.reduce(((t,e)=>(t[e]="function",t)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"})),Q_(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...dk(t.n,t.nBitLength),...t,p:t.Fp.ORDER})
|
|
37
37
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */}const _k=BigInt(0),kk=BigInt(1),Ek=BigInt(2),xk=BigInt(8),Sk={zip215:!0};
|
|
38
38
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
39
|
-
const Ak=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Ik=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const Bk=BigInt(1),Mk=BigInt(2),Rk=BigInt(5),Pk=BigInt(10),Tk=BigInt(20),Ok=BigInt(40),Lk=BigInt(80),Uk=pk(Ak,void 0,!0),Ck={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Uk,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:T_,randomBytes:v_,adjustScalarBytes:function(t){return t[0]&=248,t[31]&=127,t[31]|=64,t},uvRatio:function(t,e){const r=Ak,n=uk(e*e*e,r),i=function(t){const e=Ak,r=t*t%e*t%e,n=hk(r,Mk,e)*r%e,i=hk(n,Bk,e)*t%e,o=hk(i,Rk,e)*i%e,s=hk(o,Pk,e)*o%e,a=hk(s,Tk,e)*s%e,u=hk(a,Ok,e)*a%e,c=hk(u,Lk,e)*u%e,h=hk(c,Lk,e)*u%e,l=hk(h,Pk,e)*o%e;return{pow_p_5_8:hk(l,Mk,e)*t%e,b2:r}}(t*uk(n*n*e,r)).pow_p_5_8;let o=uk(t*n*i,r);const s=uk(e*o*o,r),a=o,u=uk(o*Ik,r),c=s===t,h=s===uk(-t,r),l=s===uk(-t*Ik,r);return c&&(o=a),(h||l)&&(o=u),(uk(o,r)&rk)===rk&&(o=uk(-o,r)),{isValid:c||h,value:o}}},Nk=function(t){const e=function(t){const e=vk(t);return Q_(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}(t),{Fp:r,n:n,prehash:i,hash:o,randomBytes:s,nByteLength:a,h:u}=e,c=Ek<<BigInt(8*a)-kk,h=r.create,l=e.uvRatio||((t,e)=>{try{return{isValid:!0,value:r.sqrt(t*r.inv(e))}}catch(t){return{isValid:!1,value:_k}}}),f=e.adjustScalarBytes||(t=>t),d=e.domain||((t,e,r)=>{if(e.length||r)throw new Error("Contexts/pre-hash are not supported");return t}),p=t=>"bigint"==typeof t&&_k<t,y=(t,e)=>p(t)&&p(e)&&t<e,g=t=>t===_k||y(t,c);function m(t,e){if(y(t,e))return t;throw new Error(`Expected valid scalar < ${e}, got ${typeof t} ${t}`)}function w(t){return t===_k?t:m(t,n)}const b=new Map;function v(t){if(!(t instanceof _))throw new Error("ExtendedPoint expected")}class _{constructor(t,e,r,n){if(this.ex=t,this.ey=e,this.ez=r,this.et=n,!g(t))throw new Error("x required");if(!g(e))throw new Error("y required");if(!g(r))throw new Error("z required");if(!g(n))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(t){if(t instanceof _)throw new Error("extended point not allowed");const{x:e,y:r}=t||{};if(!g(e)||!g(r))throw new Error("invalid affine point");return new _(e,r,kk,h(e*r))}static normalizeZ(t){const e=r.invertBatch(t.map((t=>t.ez)));return t.map(((t,r)=>t.toAffine(e[r]))).map(_.fromAffine)}_setWindowSize(t){this._WINDOW_SIZE=t,b.delete(this)}assertValidity(){const{a:t,d:r}=e;if(this.is0())throw new Error("bad point: ZERO");const{ex:n,ey:i,ez:o,et:s}=this,a=h(n*n),u=h(i*i),c=h(o*o),l=h(c*c),f=h(a*t);if(h(c*h(f+u))!==h(l+h(r*h(a*u))))throw new Error("bad point: equation left != right (1)");if(h(n*i)!==h(o*s))throw new Error("bad point: equation left != right (2)")}equals(t){v(t);const{ex:e,ey:r,ez:n}=this,{ex:i,ey:o,ez:s}=t,a=h(e*s),u=h(i*n),c=h(r*s),l=h(o*n);return a===u&&c===l}is0(){return this.equals(_.ZERO)}negate(){return new _(h(-this.ex),this.ey,this.ez,h(-this.et))}double(){const{a:t}=e,{ex:r,ey:n,ez:i}=this,o=h(r*r),s=h(n*n),a=h(Ek*h(i*i)),u=h(t*o),c=r+n,l=h(h(c*c)-o-s),f=u+s,d=f-a,p=u-s,y=h(l*d),g=h(f*p),m=h(l*p),w=h(d*f);return new _(y,g,w,m)}add(t){v(t);const{a:r,d:n}=e,{ex:i,ey:o,ez:s,et:a}=this,{ex:u,ey:c,ez:l,et:f}=t;if(r===BigInt(-1)){const t=h((o-i)*(c+u)),e=h((o+i)*(c-u)),r=h(e-t);if(r===_k)return this.double();const n=h(s*Ek*f),d=h(a*Ek*l),p=d+n,y=e+t,g=d-n,m=h(p*r),w=h(y*g),b=h(p*g),v=h(r*y);return new _(m,w,v,b)}const d=h(i*u),p=h(o*c),y=h(a*n*f),g=h(s*l),m=h((i+o)*(u+c)-d-p),w=g-y,b=g+y,k=h(p-r*d),E=h(m*w),x=h(b*k),S=h(m*k),A=h(w*b);return new _(E,x,A,S)}subtract(t){return this.add(t.negate())}wNAF(t){return x.wNAFCached(this,b,t,_.normalizeZ)}multiply(t){const{p:e,f:r}=this.wNAF(m(t,n));return _.normalizeZ([e,r])[0]}multiplyUnsafe(t){let e=w(t);return e===_k?E:this.equals(E)||e===kk?this:this.equals(k)?this.wNAF(e).p:x.unsafeLadder(this,e)}isSmallOrder(){return this.multiplyUnsafe(u).is0()}isTorsionFree(){return x.unsafeLadder(this,n).is0()}toAffine(t){const{ex:e,ey:n,ez:i}=this,o=this.is0();null==t&&(t=o?xk:r.inv(i));const s=h(e*t),a=h(n*t),u=h(i*t);if(o)return{x:_k,y:kk};if(u!==kk)throw new Error("invZ was invalid");return{x:s,y:a}}clearCofactor(){const{h:t}=e;return t===kk?this:this.multiplyUnsafe(t)}static fromHex(t,n=!1){const{d:i,a:o}=e,s=r.BYTES,a=(t=H_("pointHex",t,s)).slice(),u=t[s-1];a[s-1]=-129&u;const f=F_(a);f===_k||m(f,n?c:r.ORDER);const d=h(f*f),p=h(d-kk),y=h(i*d-o);let{isValid:g,value:w}=l(p,y);if(!g)throw new Error("Point.fromHex: invalid y coordinate");const b=(w&kk)===kk,v=0!=(128&u);if(!n&&w===_k&&v)throw new Error("Point.fromHex: x=0 and x_0=1");return v!==b&&(w=h(-w)),_.fromAffine({x:w,y:f})}static fromPrivateKey(t){return I(t).point}toRawBytes(){const{x:t,y:e}=this.toAffine(),n=V_(e,r.BYTES);return n[n.length-1]|=t&kk?128:0,n}toHex(){return z_(this.toRawBytes())}}_.BASE=new _(e.Gx,e.Gy,kk,h(e.Gx*e.Gy)),_.ZERO=new _(_k,kk,kk,_k);const{BASE:k,ZERO:E}=_,x=bk(_,8*a);function S(t){return uk(t,n)}function A(t){return S(F_(t))}function I(t){const e=a;t=H_("private key",t,e);const r=H_("hashed private key",o(t),2*e),n=f(r.slice(0,e)),i=r.slice(e,2*e),s=A(n),u=k.multiply(s),c=u.toRawBytes();return{head:n,prefix:i,scalar:s,point:u,pointBytes:c}}function B(t=new Uint8Array,...e){const r=$_(...e);return A(o(d(r,H_("context",t),!!i)))}const M=Sk;return k._setWindowSize(8),{CURVE:e,getPublicKey:function(t){return I(t).pointBytes},sign:function(t,e,n={}){t=H_("message",t),i&&(t=i(t));const{prefix:o,scalar:s,pointBytes:u}=I(e),c=B(n.context,o,t),h=k.multiply(c).toRawBytes(),l=S(c+B(n.context,h,u,t)*s);return w(l),H_("result",$_(h,V_(l,r.BYTES)),2*a)},verify:function(t,e,n,o=M){const{context:s,zip215:a}=o,u=r.BYTES;t=H_("signature",t,2*u),e=H_("message",e),i&&(e=i(e));const c=F_(t.slice(u,2*u));let h,l,f;try{h=_.fromHex(n,a),l=_.fromHex(t.slice(0,u),a),f=k.multiplyUnsafe(c)}catch(t){return!1}if(!a&&h.isSmallOrder())return!1;const d=B(s,l.toRawBytes(),h.toRawBytes(),e);return l.add(h.multiplyUnsafe(d)).subtract(f).clearCofactor().equals(_.ZERO)},ExtendedPoint:_,utils:{getExtendedPublicKey:I,randomPrivateKey:()=>s(r.BYTES),precompute:(t=8,e=_.BASE)=>(e._setWindowSize(t),e.multiply(BigInt(3)),e)}}}(Ck),zk=(Uk.ORDER+BigInt(3))/BigInt(8);Uk.pow(Mk,zk),Uk.sqrt(Uk.neg(Uk.ONE)),Uk.ORDER,BigInt(5),BigInt(8),BigInt(486662),function(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");const r=t.sqrt(e);t.isOdd(r)&&t.neg(r)}(Uk,Uk.neg(BigInt(486664))),BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");var Dk={exports:{}},jk=Qv(Object.freeze({__proto__:null,default:{}}));!function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function n(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function i(t,e,r){if(i.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var o;"object"==typeof Dk?Dk.exports=i:e.BN=i,i.BN=i,i.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:jk.Buffer}catch(t){}function s(t,e){var n=t.charCodeAt(e);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 "+t)}function a(t,e,r){var n=s(t,r);return r-1>=e&&(n|=s(t,r-1)<<4),n}function u(t,e,n,i){for(var o=0,s=0,a=Math.min(t.length,n),u=e;u<a;u++){var c=t.charCodeAt(u)-48;o*=i,s=c>=49?c-49+10:c>=17?c-17+10:c,r(c>=0&&s<i,"Invalid character"),o+=s}return o}function c(t,e){t.words=e.words,t.length=e.length,t.negative=e.negative,t.red=e.red}if(i.isBN=function(t){return t instanceof i||null!==t&&"object"==typeof t&&t.constructor.wordSize===i.wordSize&&Array.isArray(t.words)},i.max=function(t,e){return t.cmp(e)>0?t:e},i.min=function(t,e){return t.cmp(e)<0?t:e},i.prototype._init=function(t,e,n){if("number"==typeof t)return this._initNumber(t,e,n);if("object"==typeof t)return this._initArray(t,e,n);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var i=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(i++,this.negative=1),i<t.length&&(16===e?this._parseHex(t,i,n):(this._parseBase(t,e,i),"le"===n&&this._initArray(this.toArray(),e,n)))},i.prototype._initNumber=function(t,e,n){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),e,n)},i.prototype._initArray=function(t,e,n){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var o,s,a=0;if("be"===n)for(i=t.length-1,o=0;i>=0;i-=3)s=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===n)for(i=0,o=0;i<t.length;i+=3)s=t[i]|t[i+1]<<8|t[i+2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this._strip()},i.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var i,o=0,s=0;if("be"===r)for(n=t.length-1;n>=e;n-=2)i=a(t,e,n)<<o,this.words[s]|=67108863&i,o>=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;else for(n=(t.length-e)%2==0?e+1:e;n<t.length;n+=2)i=a(t,e,n)<<o,this.words[s]|=67108863&i,o>=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;this._strip()},i.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=e)n++;n--,i=i/e|0;for(var o=t.length-r,s=o%n,a=Math.min(o,o-s)+r,c=0,h=r;h<a;h+=n)c=u(t,h,h+n,e),this.imuln(i),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(0!==s){var l=1;for(c=u(t,h,t.length,e),h=0;h<s;h++)l*=e;this.imuln(l),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}this._strip()},i.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},i.prototype._move=function(t){c(t,this)},i.prototype.clone=function(){var t=new i(null);return this.copy(t),t},i.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},i.prototype._strip=function(){for(;this.length>1&&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(t){i.prototype.inspect=h}else i.prototype.inspect=h;function h(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}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(t,e,r){r.negative=e.negative^t.negative;var n=t.length+e.length|0;r.length=n,n=n-1|0;var i=0|t.words[0],o=0|e.words[0],s=i*o,a=67108863&s,u=s/67108864|0;r.words[0]=a;for(var c=1;c<n;c++){for(var h=u>>>26,l=67108863&u,f=Math.min(c,e.length-1),d=Math.max(0,c-t.length+1);d<=f;d++){var p=c-d|0;h+=(s=(i=0|t.words[p])*(o=0|e.words[d])+l)/67108864|0,l=67108863&s}r.words[c]=0|l,u=0|h}return 0!==u?r.words[c]=0|u:r.length--,r._strip()}i.prototype.toString=function(t,e){var n;if(e=0|e||1,16===(t=t||10)||"hex"===t){n="";for(var i=0,o=0,s=0;s<this.length;s++){var a=this.words[s],u=(16777215&(a<<i|o)).toString(16);o=a>>>24-i&16777215,(i+=2)>=26&&(i-=26,s--),n=0!==o||s!==this.length-1?l[6-u.length]+u+n:u+n}for(0!==o&&(n=o.toString(16)+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(t===(0|t)&&t>=2&&t<=36){var c=f[t],h=d[t];n="";var p=this.clone();for(p.negative=0;!p.isZero();){var y=p.modrn(h).toString(t);n=(p=p.idivn(h)).isZero()?y+n:l[c-y.length]+y+n}for(this.isZero()&&(n="0"+n);n.length%e!=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 t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},i.prototype.toJSON=function(){return this.toString(16,2)},o&&(i.prototype.toBuffer=function(t,e){return this.toArrayLike(o,t,e)}),i.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},i.prototype.toArrayLike=function(t,e,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(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,o);return this["_toArrayLike"+("le"===e?"LE":"BE")](s,i),s},i.prototype._toArrayLikeLE=function(t,e){for(var r=0,n=0,i=0,o=0;i<this.length;i++){var s=this.words[i]<<o|n;t[r++]=255&s,r<t.length&&(t[r++]=s>>8&255),r<t.length&&(t[r++]=s>>16&255),6===o?(r<t.length&&(t[r++]=s>>24&255),n=0,o=0):(n=s>>>24,o+=2)}if(r<t.length)for(t[r++]=n;r<t.length;)t[r++]=0},i.prototype._toArrayLikeBE=function(t,e){for(var r=t.length-1,n=0,i=0,o=0;i<this.length;i++){var s=this.words[i]<<o|n;t[r--]=255&s,r>=0&&(t[r--]=s>>8&255),r>=0&&(t[r--]=s>>16&255),6===o?(r>=0&&(t[r--]=s>>24&255),n=0,o=0):(n=s>>>24,o+=2)}if(r>=0)for(t[r--]=n;r>=0;)t[r--]=0},Math.clz32?i.prototype._countBits=function(t){return 32-Math.clz32(t)}:i.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},i.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},i.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},i.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return 0!==this.negative},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this._strip()},i.prototype.ior=function(t){return r(0==(this.negative|t.negative)),this.iuor(t)},i.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},i.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},i.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this._strip()},i.prototype.iand=function(t){return r(0==(this.negative|t.negative)),this.iuand(t)},i.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},i.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},i.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;n<r.length;n++)this.words[n]=e.words[n]^r.words[n];if(this!==e)for(;n<e.length;n++)this.words[n]=e.words[n];return this.length=e.length,this._strip()},i.prototype.ixor=function(t){return r(0==(this.negative|t.negative)),this.iuxor(t)},i.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},i.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},i.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),n=t%26;this._expand(e),n>0&&e--;for(var i=0;i<e;i++)this.words[i]=67108863&~this.words[i];return n>0&&(this.words[i]=~this.words[i]&67108863>>26-n),this._strip()},i.prototype.notn=function(t){return this.clone().inotn(t)},i.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);var n=t/26|0,i=t%26;return this._expand(n+1),this.words[n]=e?this.words[n]|1<<i:this.words[n]&~(1<<i),this._strip()},i.prototype.iadd=function(t){var e,r,n;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,n=t):(r=t,n=this);for(var i=0,o=0;o<n.length;o++)e=(0|r.words[o])+(0|n.words[o])+i,this.words[o]=67108863&e,i=e>>>26;for(;0!==i&&o<r.length;o++)e=(0|r.words[o])+i,this.words[o]=67108863&e,i=e>>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},i.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},i.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,n,i=this.cmp(t);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=t):(r=t,n=this);for(var o=0,s=0;s<n.length;s++)o=(e=(0|r.words[s])-(0|n.words[s])+o)>>26,this.words[s]=67108863&e;for(;0!==o&&s<r.length;s++)o=(e=(0|r.words[s])+o)>>26,this.words[s]=67108863&e;if(0===o&&s<r.length&&r!==this)for(;s<r.length;s++)this.words[s]=r.words[s];return this.length=Math.max(this.length,s),r!==this&&(this.negative=1),this._strip()},i.prototype.sub=function(t){return this.clone().isub(t)};var y=function(t,e,r){var n,i,o,s=t.words,a=e.words,u=r.words,c=0,h=0|s[0],l=8191&h,f=h>>>13,d=0|s[1],p=8191&d,y=d>>>13,g=0|s[2],m=8191&g,w=g>>>13,b=0|s[3],v=8191&b,_=b>>>13,k=0|s[4],E=8191&k,x=k>>>13,S=0|s[5],A=8191&S,I=S>>>13,B=0|s[6],M=8191&B,R=B>>>13,P=0|s[7],T=8191&P,O=P>>>13,L=0|s[8],U=8191&L,C=L>>>13,N=0|s[9],z=8191&N,D=N>>>13,j=0|a[0],W=8191&j,K=j>>>13,F=0|a[1],q=8191&F,V=F>>>13,H=0|a[2],$=8191&H,G=H>>>13,Z=0|a[3],Y=8191&Z,J=Z>>>13,X=0|a[4],Q=8191&X,tt=X>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],ot=8191&it,st=it>>>13,at=0|a[7],ut=8191&at,ct=at>>>13,ht=0|a[8],lt=8191&ht,ft=ht>>>13,dt=0|a[9],pt=8191&dt,yt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(c+(n=Math.imul(l,W))|0)+((8191&(i=(i=Math.imul(l,K))+Math.imul(f,W)|0))<<13)|0;c=((o=Math.imul(f,K))+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(p,W),i=(i=Math.imul(p,K))+Math.imul(y,W)|0,o=Math.imul(y,K);var mt=(c+(n=n+Math.imul(l,q)|0)|0)+((8191&(i=(i=i+Math.imul(l,V)|0)+Math.imul(f,q)|0))<<13)|0;c=((o=o+Math.imul(f,V)|0)+(i>>>13)|0)+(mt>>>26)|0,mt&=67108863,n=Math.imul(m,W),i=(i=Math.imul(m,K))+Math.imul(w,W)|0,o=Math.imul(w,K),n=n+Math.imul(p,q)|0,i=(i=i+Math.imul(p,V)|0)+Math.imul(y,q)|0,o=o+Math.imul(y,V)|0;var wt=(c+(n=n+Math.imul(l,$)|0)|0)+((8191&(i=(i=i+Math.imul(l,G)|0)+Math.imul(f,$)|0))<<13)|0;c=((o=o+Math.imul(f,G)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(v,W),i=(i=Math.imul(v,K))+Math.imul(_,W)|0,o=Math.imul(_,K),n=n+Math.imul(m,q)|0,i=(i=i+Math.imul(m,V)|0)+Math.imul(w,q)|0,o=o+Math.imul(w,V)|0,n=n+Math.imul(p,$)|0,i=(i=i+Math.imul(p,G)|0)+Math.imul(y,$)|0,o=o+Math.imul(y,G)|0;var bt=(c+(n=n+Math.imul(l,Y)|0)|0)+((8191&(i=(i=i+Math.imul(l,J)|0)+Math.imul(f,Y)|0))<<13)|0;c=((o=o+Math.imul(f,J)|0)+(i>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(E,W),i=(i=Math.imul(E,K))+Math.imul(x,W)|0,o=Math.imul(x,K),n=n+Math.imul(v,q)|0,i=(i=i+Math.imul(v,V)|0)+Math.imul(_,q)|0,o=o+Math.imul(_,V)|0,n=n+Math.imul(m,$)|0,i=(i=i+Math.imul(m,G)|0)+Math.imul(w,$)|0,o=o+Math.imul(w,G)|0,n=n+Math.imul(p,Y)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(y,Y)|0,o=o+Math.imul(y,J)|0;var vt=(c+(n=n+Math.imul(l,Q)|0)|0)+((8191&(i=(i=i+Math.imul(l,tt)|0)+Math.imul(f,Q)|0))<<13)|0;c=((o=o+Math.imul(f,tt)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(A,W),i=(i=Math.imul(A,K))+Math.imul(I,W)|0,o=Math.imul(I,K),n=n+Math.imul(E,q)|0,i=(i=i+Math.imul(E,V)|0)+Math.imul(x,q)|0,o=o+Math.imul(x,V)|0,n=n+Math.imul(v,$)|0,i=(i=i+Math.imul(v,G)|0)+Math.imul(_,$)|0,o=o+Math.imul(_,G)|0,n=n+Math.imul(m,Y)|0,i=(i=i+Math.imul(m,J)|0)+Math.imul(w,Y)|0,o=o+Math.imul(w,J)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(y,Q)|0,o=o+Math.imul(y,tt)|0;var _t=(c+(n=n+Math.imul(l,rt)|0)|0)+((8191&(i=(i=i+Math.imul(l,nt)|0)+Math.imul(f,rt)|0))<<13)|0;c=((o=o+Math.imul(f,nt)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(M,W),i=(i=Math.imul(M,K))+Math.imul(R,W)|0,o=Math.imul(R,K),n=n+Math.imul(A,q)|0,i=(i=i+Math.imul(A,V)|0)+Math.imul(I,q)|0,o=o+Math.imul(I,V)|0,n=n+Math.imul(E,$)|0,i=(i=i+Math.imul(E,G)|0)+Math.imul(x,$)|0,o=o+Math.imul(x,G)|0,n=n+Math.imul(v,Y)|0,i=(i=i+Math.imul(v,J)|0)+Math.imul(_,Y)|0,o=o+Math.imul(_,J)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,tt)|0)+Math.imul(w,Q)|0,o=o+Math.imul(w,tt)|0,n=n+Math.imul(p,rt)|0,i=(i=i+Math.imul(p,nt)|0)+Math.imul(y,rt)|0,o=o+Math.imul(y,nt)|0;var kt=(c+(n=n+Math.imul(l,ot)|0)|0)+((8191&(i=(i=i+Math.imul(l,st)|0)+Math.imul(f,ot)|0))<<13)|0;c=((o=o+Math.imul(f,st)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(T,W),i=(i=Math.imul(T,K))+Math.imul(O,W)|0,o=Math.imul(O,K),n=n+Math.imul(M,q)|0,i=(i=i+Math.imul(M,V)|0)+Math.imul(R,q)|0,o=o+Math.imul(R,V)|0,n=n+Math.imul(A,$)|0,i=(i=i+Math.imul(A,G)|0)+Math.imul(I,$)|0,o=o+Math.imul(I,G)|0,n=n+Math.imul(E,Y)|0,i=(i=i+Math.imul(E,J)|0)+Math.imul(x,Y)|0,o=o+Math.imul(x,J)|0,n=n+Math.imul(v,Q)|0,i=(i=i+Math.imul(v,tt)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,tt)|0,n=n+Math.imul(m,rt)|0,i=(i=i+Math.imul(m,nt)|0)+Math.imul(w,rt)|0,o=o+Math.imul(w,nt)|0,n=n+Math.imul(p,ot)|0,i=(i=i+Math.imul(p,st)|0)+Math.imul(y,ot)|0,o=o+Math.imul(y,st)|0;var Et=(c+(n=n+Math.imul(l,ut)|0)|0)+((8191&(i=(i=i+Math.imul(l,ct)|0)+Math.imul(f,ut)|0))<<13)|0;c=((o=o+Math.imul(f,ct)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(U,W),i=(i=Math.imul(U,K))+Math.imul(C,W)|0,o=Math.imul(C,K),n=n+Math.imul(T,q)|0,i=(i=i+Math.imul(T,V)|0)+Math.imul(O,q)|0,o=o+Math.imul(O,V)|0,n=n+Math.imul(M,$)|0,i=(i=i+Math.imul(M,G)|0)+Math.imul(R,$)|0,o=o+Math.imul(R,G)|0,n=n+Math.imul(A,Y)|0,i=(i=i+Math.imul(A,J)|0)+Math.imul(I,Y)|0,o=o+Math.imul(I,J)|0,n=n+Math.imul(E,Q)|0,i=(i=i+Math.imul(E,tt)|0)+Math.imul(x,Q)|0,o=o+Math.imul(x,tt)|0,n=n+Math.imul(v,rt)|0,i=(i=i+Math.imul(v,nt)|0)+Math.imul(_,rt)|0,o=o+Math.imul(_,nt)|0,n=n+Math.imul(m,ot)|0,i=(i=i+Math.imul(m,st)|0)+Math.imul(w,ot)|0,o=o+Math.imul(w,st)|0,n=n+Math.imul(p,ut)|0,i=(i=i+Math.imul(p,ct)|0)+Math.imul(y,ut)|0,o=o+Math.imul(y,ct)|0;var xt=(c+(n=n+Math.imul(l,lt)|0)|0)+((8191&(i=(i=i+Math.imul(l,ft)|0)+Math.imul(f,lt)|0))<<13)|0;c=((o=o+Math.imul(f,ft)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(z,W),i=(i=Math.imul(z,K))+Math.imul(D,W)|0,o=Math.imul(D,K),n=n+Math.imul(U,q)|0,i=(i=i+Math.imul(U,V)|0)+Math.imul(C,q)|0,o=o+Math.imul(C,V)|0,n=n+Math.imul(T,$)|0,i=(i=i+Math.imul(T,G)|0)+Math.imul(O,$)|0,o=o+Math.imul(O,G)|0,n=n+Math.imul(M,Y)|0,i=(i=i+Math.imul(M,J)|0)+Math.imul(R,Y)|0,o=o+Math.imul(R,J)|0,n=n+Math.imul(A,Q)|0,i=(i=i+Math.imul(A,tt)|0)+Math.imul(I,Q)|0,o=o+Math.imul(I,tt)|0,n=n+Math.imul(E,rt)|0,i=(i=i+Math.imul(E,nt)|0)+Math.imul(x,rt)|0,o=o+Math.imul(x,nt)|0,n=n+Math.imul(v,ot)|0,i=(i=i+Math.imul(v,st)|0)+Math.imul(_,ot)|0,o=o+Math.imul(_,st)|0,n=n+Math.imul(m,ut)|0,i=(i=i+Math.imul(m,ct)|0)+Math.imul(w,ut)|0,o=o+Math.imul(w,ct)|0,n=n+Math.imul(p,lt)|0,i=(i=i+Math.imul(p,ft)|0)+Math.imul(y,lt)|0,o=o+Math.imul(y,ft)|0;var St=(c+(n=n+Math.imul(l,pt)|0)|0)+((8191&(i=(i=i+Math.imul(l,yt)|0)+Math.imul(f,pt)|0))<<13)|0;c=((o=o+Math.imul(f,yt)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(z,q),i=(i=Math.imul(z,V))+Math.imul(D,q)|0,o=Math.imul(D,V),n=n+Math.imul(U,$)|0,i=(i=i+Math.imul(U,G)|0)+Math.imul(C,$)|0,o=o+Math.imul(C,G)|0,n=n+Math.imul(T,Y)|0,i=(i=i+Math.imul(T,J)|0)+Math.imul(O,Y)|0,o=o+Math.imul(O,J)|0,n=n+Math.imul(M,Q)|0,i=(i=i+Math.imul(M,tt)|0)+Math.imul(R,Q)|0,o=o+Math.imul(R,tt)|0,n=n+Math.imul(A,rt)|0,i=(i=i+Math.imul(A,nt)|0)+Math.imul(I,rt)|0,o=o+Math.imul(I,nt)|0,n=n+Math.imul(E,ot)|0,i=(i=i+Math.imul(E,st)|0)+Math.imul(x,ot)|0,o=o+Math.imul(x,st)|0,n=n+Math.imul(v,ut)|0,i=(i=i+Math.imul(v,ct)|0)+Math.imul(_,ut)|0,o=o+Math.imul(_,ct)|0,n=n+Math.imul(m,lt)|0,i=(i=i+Math.imul(m,ft)|0)+Math.imul(w,lt)|0,o=o+Math.imul(w,ft)|0;var At=(c+(n=n+Math.imul(p,pt)|0)|0)+((8191&(i=(i=i+Math.imul(p,yt)|0)+Math.imul(y,pt)|0))<<13)|0;c=((o=o+Math.imul(y,yt)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(z,$),i=(i=Math.imul(z,G))+Math.imul(D,$)|0,o=Math.imul(D,G),n=n+Math.imul(U,Y)|0,i=(i=i+Math.imul(U,J)|0)+Math.imul(C,Y)|0,o=o+Math.imul(C,J)|0,n=n+Math.imul(T,Q)|0,i=(i=i+Math.imul(T,tt)|0)+Math.imul(O,Q)|0,o=o+Math.imul(O,tt)|0,n=n+Math.imul(M,rt)|0,i=(i=i+Math.imul(M,nt)|0)+Math.imul(R,rt)|0,o=o+Math.imul(R,nt)|0,n=n+Math.imul(A,ot)|0,i=(i=i+Math.imul(A,st)|0)+Math.imul(I,ot)|0,o=o+Math.imul(I,st)|0,n=n+Math.imul(E,ut)|0,i=(i=i+Math.imul(E,ct)|0)+Math.imul(x,ut)|0,o=o+Math.imul(x,ct)|0,n=n+Math.imul(v,lt)|0,i=(i=i+Math.imul(v,ft)|0)+Math.imul(_,lt)|0,o=o+Math.imul(_,ft)|0;var It=(c+(n=n+Math.imul(m,pt)|0)|0)+((8191&(i=(i=i+Math.imul(m,yt)|0)+Math.imul(w,pt)|0))<<13)|0;c=((o=o+Math.imul(w,yt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(z,Y),i=(i=Math.imul(z,J))+Math.imul(D,Y)|0,o=Math.imul(D,J),n=n+Math.imul(U,Q)|0,i=(i=i+Math.imul(U,tt)|0)+Math.imul(C,Q)|0,o=o+Math.imul(C,tt)|0,n=n+Math.imul(T,rt)|0,i=(i=i+Math.imul(T,nt)|0)+Math.imul(O,rt)|0,o=o+Math.imul(O,nt)|0,n=n+Math.imul(M,ot)|0,i=(i=i+Math.imul(M,st)|0)+Math.imul(R,ot)|0,o=o+Math.imul(R,st)|0,n=n+Math.imul(A,ut)|0,i=(i=i+Math.imul(A,ct)|0)+Math.imul(I,ut)|0,o=o+Math.imul(I,ct)|0,n=n+Math.imul(E,lt)|0,i=(i=i+Math.imul(E,ft)|0)+Math.imul(x,lt)|0,o=o+Math.imul(x,ft)|0;var Bt=(c+(n=n+Math.imul(v,pt)|0)|0)+((8191&(i=(i=i+Math.imul(v,yt)|0)+Math.imul(_,pt)|0))<<13)|0;c=((o=o+Math.imul(_,yt)|0)+(i>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,n=Math.imul(z,Q),i=(i=Math.imul(z,tt))+Math.imul(D,Q)|0,o=Math.imul(D,tt),n=n+Math.imul(U,rt)|0,i=(i=i+Math.imul(U,nt)|0)+Math.imul(C,rt)|0,o=o+Math.imul(C,nt)|0,n=n+Math.imul(T,ot)|0,i=(i=i+Math.imul(T,st)|0)+Math.imul(O,ot)|0,o=o+Math.imul(O,st)|0,n=n+Math.imul(M,ut)|0,i=(i=i+Math.imul(M,ct)|0)+Math.imul(R,ut)|0,o=o+Math.imul(R,ct)|0,n=n+Math.imul(A,lt)|0,i=(i=i+Math.imul(A,ft)|0)+Math.imul(I,lt)|0,o=o+Math.imul(I,ft)|0;var Mt=(c+(n=n+Math.imul(E,pt)|0)|0)+((8191&(i=(i=i+Math.imul(E,yt)|0)+Math.imul(x,pt)|0))<<13)|0;c=((o=o+Math.imul(x,yt)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(z,rt),i=(i=Math.imul(z,nt))+Math.imul(D,rt)|0,o=Math.imul(D,nt),n=n+Math.imul(U,ot)|0,i=(i=i+Math.imul(U,st)|0)+Math.imul(C,ot)|0,o=o+Math.imul(C,st)|0,n=n+Math.imul(T,ut)|0,i=(i=i+Math.imul(T,ct)|0)+Math.imul(O,ut)|0,o=o+Math.imul(O,ct)|0,n=n+Math.imul(M,lt)|0,i=(i=i+Math.imul(M,ft)|0)+Math.imul(R,lt)|0,o=o+Math.imul(R,ft)|0;var Rt=(c+(n=n+Math.imul(A,pt)|0)|0)+((8191&(i=(i=i+Math.imul(A,yt)|0)+Math.imul(I,pt)|0))<<13)|0;c=((o=o+Math.imul(I,yt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,n=Math.imul(z,ot),i=(i=Math.imul(z,st))+Math.imul(D,ot)|0,o=Math.imul(D,st),n=n+Math.imul(U,ut)|0,i=(i=i+Math.imul(U,ct)|0)+Math.imul(C,ut)|0,o=o+Math.imul(C,ct)|0,n=n+Math.imul(T,lt)|0,i=(i=i+Math.imul(T,ft)|0)+Math.imul(O,lt)|0,o=o+Math.imul(O,ft)|0;var Pt=(c+(n=n+Math.imul(M,pt)|0)|0)+((8191&(i=(i=i+Math.imul(M,yt)|0)+Math.imul(R,pt)|0))<<13)|0;c=((o=o+Math.imul(R,yt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(z,ut),i=(i=Math.imul(z,ct))+Math.imul(D,ut)|0,o=Math.imul(D,ct),n=n+Math.imul(U,lt)|0,i=(i=i+Math.imul(U,ft)|0)+Math.imul(C,lt)|0,o=o+Math.imul(C,ft)|0;var Tt=(c+(n=n+Math.imul(T,pt)|0)|0)+((8191&(i=(i=i+Math.imul(T,yt)|0)+Math.imul(O,pt)|0))<<13)|0;c=((o=o+Math.imul(O,yt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(z,lt),i=(i=Math.imul(z,ft))+Math.imul(D,lt)|0,o=Math.imul(D,ft);var Ot=(c+(n=n+Math.imul(U,pt)|0)|0)+((8191&(i=(i=i+Math.imul(U,yt)|0)+Math.imul(C,pt)|0))<<13)|0;c=((o=o+Math.imul(C,yt)|0)+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863;var Lt=(c+(n=Math.imul(z,pt))|0)+((8191&(i=(i=Math.imul(z,yt))+Math.imul(D,pt)|0))<<13)|0;return c=((o=Math.imul(D,yt))+(i>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,u[0]=gt,u[1]=mt,u[2]=wt,u[3]=bt,u[4]=vt,u[5]=_t,u[6]=kt,u[7]=Et,u[8]=xt,u[9]=St,u[10]=At,u[11]=It,u[12]=Bt,u[13]=Mt,u[14]=Rt,u[15]=Pt,u[16]=Tt,u[17]=Ot,u[18]=Lt,0!==c&&(u[19]=c,r.length++),r};function g(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,o=0;o<r.length-1;o++){var s=i;i=0;for(var a=67108863&n,u=Math.min(o,e.length-1),c=Math.max(0,o-t.length+1);c<=u;c++){var h=o-c,l=(0|t.words[h])*(0|e.words[c]),f=67108863&l;a=67108863&(f=f+a|0),i+=(s=(s=s+(l/67108864|0)|0)+(f>>>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(t,e,r){return g(t,e,r)}Math.imul||(y=p),i.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?y(this,t,e):r<63?p(this,t,e):r<1024?g(this,t,e):m(this,t,e)},i.prototype.mul=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},i.prototype.mulf=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),m(this,t,e)},i.prototype.imul=function(t){return this.clone().mulTo(t,this)},i.prototype.imuln=function(t){var e=t<0;e&&(t=-t),r("number"==typeof t),r(t<67108864);for(var n=0,i=0;i<this.length;i++){var o=(0|this.words[i])*t,s=(67108863&o)+(67108863&n);n>>=26,n+=o/67108864|0,n+=s>>>26,this.words[i]=67108863&s}return 0!==n&&(this.words[i]=n,this.length++),e?this.ineg():this},i.prototype.muln=function(t){return this.clone().imuln(t)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var n=r/26|0,i=r%26;e[r]=t.words[n]>>>i&1}return e}(t);if(0===e.length)return new i(1);for(var r=this,n=0;n<e.length&&0===e[n];n++,r=r.sqr());if(++n<e.length)for(var o=r.sqr();n<e.length;n++,o=o.sqr())0!==e[n]&&(r=r.mul(o));return r},i.prototype.iushln=function(t){r("number"==typeof t&&t>=0);var e,n=t%26,i=(t-n)/26,o=67108863>>>26-n<<26-n;if(0!==n){var s=0;for(e=0;e<this.length;e++){var a=this.words[e]&o,u=(0|this.words[e])-a<<n;this.words[e]=u|s,s=a>>>26-n}s&&(this.words[e]=s,this.length++)}if(0!==i){for(e=this.length-1;e>=0;e--)this.words[e+i]=this.words[e];for(e=0;e<i;e++)this.words[e]=0;this.length+=i}return this._strip()},i.prototype.ishln=function(t){return r(0===this.negative),this.iushln(t)},i.prototype.iushrn=function(t,e,n){var i;r("number"==typeof t&&t>=0),i=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<<o,u=n;if(i-=s,i=Math.max(0,i),u){for(var c=0;c<s;c++)u.words[c]=this.words[c];u.length=s}if(0===s);else if(this.length>s)for(this.length-=s,c=0;c<this.length;c++)this.words[c]=this.words[c+s];else this.words[0]=0,this.length=1;var h=0;for(c=this.length-1;c>=0&&(0!==h||c>=i);c--){var l=0|this.words[c];this.words[c]=h<<26-o|l>>>o,h=l&a}return u&&0!==h&&(u.words[u.length++]=h),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.ishrn=function(t,e,n){return r(0===this.negative),this.iushrn(t,e,n)},i.prototype.shln=function(t){return this.clone().ishln(t)},i.prototype.ushln=function(t){return this.clone().iushln(t)},i.prototype.shrn=function(t){return this.clone().ishrn(t)},i.prototype.ushrn=function(t){return this.clone().iushrn(t)},i.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26,i=1<<e;return!(this.length<=n||!(this.words[n]&i))},i.prototype.imaskn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==e&&n++,this.length=Math.min(n,this.length),0!==e){var i=67108863^67108863>>>e<<e;this.words[this.length-1]&=i}return this._strip()},i.prototype.maskn=function(t){return this.clone().imaskn(t)},i.prototype.iaddn=function(t){return r("number"==typeof t),r(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},i.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},i.prototype.isubn=function(t){if(r("number"==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this._strip()},i.prototype.addn=function(t){return this.clone().iaddn(t)},i.prototype.subn=function(t){return this.clone().isubn(t)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(t,e,n){var i,o,s=t.length+n;this._expand(s);var a=0;for(i=0;i<t.length;i++){o=(0|this.words[i+n])+a;var u=(0|t.words[i])*e;a=((o-=67108863&u)>>26)-(u/67108864|0),this.words[i+n]=67108863&o}for(;i<this.length-n;i++)a=(o=(0|this.words[i+n])+a)>>26,this.words[i+n]=67108863&o;if(0===a)return this._strip();for(r(-1===a),a=0,i=0;i<this.length;i++)a=(o=-(0|this.words[i])+a)>>26,this.words[i]=67108863&o;return this.negative=1,this._strip()},i.prototype._wordDiv=function(t,e){var r=(this.length,t.length),n=this.clone(),o=t,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,u=n.length-o.length;if("mod"!==e){(a=new i(null)).length=u+1,a.words=new Array(a.length);for(var c=0;c<a.length;c++)a.words[c]=0}var h=n.clone()._ishlnsubmul(o,1,u);0===h.negative&&(n=h,a&&(a.words[u]=1));for(var l=u-1;l>=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"!==e&&0!==r&&n.iushrn(r),{div:a||null,mod:n}},i.prototype.divmod=function(t,e,n){return r(!t.isZero()),this.isZero()?{div:new i(0),mod:new i(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(o=a.div.neg()),"div"!==e&&(s=a.mod.neg(),n&&0!==s.negative&&s.iadd(t)),{div:o,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(o=a.div.neg()),{div:o,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),n&&0!==s.negative&&s.isub(t)),{div:a.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new i(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new i(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new i(this.modrn(t.words[0]))}:this._wordDiv(t,e);var o,s,a},i.prototype.div=function(t){return this.divmod(t,"div",!1).div},i.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},i.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},i.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,n=t.ushrn(1),i=t.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},i.prototype.modrn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var n=(1<<26)%t,i=0,o=this.length-1;o>=0;o--)i=(n*i+(0|this.words[o]))%t;return e?-i:i},i.prototype.modn=function(t){return this.modrn(t)},i.prototype.idivn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var n=0,i=this.length-1;i>=0;i--){var o=(0|this.words[i])+67108864*n;this.words[i]=o/t|0,n=o%t}return this._strip(),e?this.ineg():this},i.prototype.divn=function(t){return this.clone().idivn(t)},i.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o=new i(1),s=new i(0),a=new i(0),u=new i(1),c=0;e.isEven()&&n.isEven();)e.iushrn(1),n.iushrn(1),++c;for(var h=n.clone(),l=e.clone();!e.isZero();){for(var f=0,d=1;0==(e.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(e.iushrn(f);f-- >0;)(o.isOdd()||s.isOdd())&&(o.iadd(h),s.isub(l)),o.iushrn(1),s.iushrn(1);for(var p=0,y=1;0==(n.words[0]&y)&&p<26;++p,y<<=1);if(p>0)for(n.iushrn(p);p-- >0;)(a.isOdd()||u.isOdd())&&(a.iadd(h),u.isub(l)),a.iushrn(1),u.iushrn(1);e.cmp(n)>=0?(e.isub(n),o.isub(a),s.isub(u)):(n.isub(e),a.isub(o),u.isub(s))}return{a:a,b:u,gcd:n.iushln(c)}},i.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o,s=new i(1),a=new i(0),u=n.clone();e.cmpn(1)>0&&n.cmpn(1)>0;){for(var c=0,h=1;0==(e.words[0]&h)&&c<26;++c,h<<=1);if(c>0)for(e.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);for(var l=0,f=1;0==(n.words[0]&f)&&l<26;++l,f<<=1);if(l>0)for(n.iushrn(l);l-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);e.cmp(n)>=0?(e.isub(n),s.isub(a)):(n.isub(e),a.isub(s))}return(o=0===e.cmpn(1)?s:a).cmpn(0)<0&&o.iadd(t),o},i.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var n=0;e.isEven()&&r.isEven();n++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=e.cmp(r);if(i<0){var o=e;e=r,r=o}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.iushln(n)},i.prototype.invm=function(t){return this.egcd(t).a.umod(t)},i.prototype.isEven=function(){return 0==(1&this.words[0])},i.prototype.isOdd=function(){return 1==(1&this.words[0])},i.prototype.andln=function(t){return this.words[0]&t},i.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,n=(t-e)/26,i=1<<e;if(this.length<=n)return this._expand(n+1),this.words[n]|=i,this;for(var o=i,s=n;0!==o&&s<this.length;s++){var a=0|this.words[s];o=(a+=o)>>>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(t){var e,n=t<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this._strip(),this.length>1)e=1;else{n&&(t=-t),r(t<=67108863,"Number is too big");var i=0|this.words[0];e=i===t?0:i<t?-1:1}return 0!==this.negative?0|-e:e},i.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},i.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){n<i?e=-1:n>i&&(e=1);break}}return e},i.prototype.gtn=function(t){return 1===this.cmpn(t)},i.prototype.gt=function(t){return 1===this.cmp(t)},i.prototype.gten=function(t){return this.cmpn(t)>=0},i.prototype.gte=function(t){return this.cmp(t)>=0},i.prototype.ltn=function(t){return-1===this.cmpn(t)},i.prototype.lt=function(t){return-1===this.cmp(t)},i.prototype.lten=function(t){return this.cmpn(t)<=0},i.prototype.lte=function(t){return this.cmp(t)<=0},i.prototype.eqn=function(t){return 0===this.cmpn(t)},i.prototype.eq=function(t){return 0===this.cmp(t)},i.red=function(t){return new x(t)},i.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(t){return this.red=t,this},i.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},i.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},i.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},i.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},i.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},i.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},i.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},i.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},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(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var w={k256:null,p224:null,p192:null,p25519:null};function b(t,e){this.name=t,this.p=new i(e,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 k(){b.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function E(){b.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function x(t){if("string"==typeof t){var e=i._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function S(t){x.call(this,t),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 t=new i(null);return t.words=new Array(Math.ceil(this.n/13)),t},b.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e<this.n?-1:r.ucmp(this.p);return 0===n?(r.words[0]=0,r.length=1):n>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},b.prototype.split=function(t,e){t.iushrn(this.n,0,e)},b.prototype.imulK=function(t){return t.imul(this.k)},n(v,b),v.prototype.split=function(t,e){for(var r=4194303,n=Math.min(t.length,9),i=0;i<n;i++)e.words[i]=t.words[i];if(e.length=n,t.length<=9)return t.words[0]=0,void(t.length=1);var o=t.words[9];for(e.words[e.length++]=o&r,i=10;i<t.length;i++){var s=0|t.words[i];t.words[i-10]=(s&r)<<4|o>>>22,o=s}o>>>=22,t.words[i-10]=o,0===o&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var n=0|t.words[r];e+=977*n,t.words[r]=67108863&e,e=64*n+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},n(_,b),n(k,b),n(E,b),E.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var n=19*(0|t.words[r])+e,i=67108863&n;n>>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},i._prime=function(t){if(w[t])return w[t];var e;if("k256"===t)e=new v;else if("p224"===t)e=new _;else if("p192"===t)e=new k;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new E}return w[t]=e,e},x.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},x.prototype._verify2=function(t,e){r(0==(t.negative|e.negative),"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},x.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(c(t,t.umod(this.m)._forceRed(this)),t)},x.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},x.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},x.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},x.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},x.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},x.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},x.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},x.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},x.prototype.isqr=function(t){return this.imul(t,t.clone())},x.prototype.sqr=function(t){return this.mul(t,t)},x.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var n=this.m.add(new i(1)).iushrn(2);return this.pow(t,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),u=a.redNeg(),c=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new i(2*h*h).toRed(this);0!==this.pow(h,c).cmp(u);)h.redIAdd(u);for(var l=this.pow(h,o),f=this.pow(t,o.addn(1).iushrn(1)),d=this.pow(t,o),p=s;0!==d.cmp(a);){for(var y=d,g=0;0!==y.cmp(a);g++)y=y.redSqr();r(g<p);var m=this.pow(l,new i(1).iushln(p-g-1));f=f.redMul(m),l=m.redSqr(),d=d.redMul(l),p=g}return f},x.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},x.prototype.pow=function(t,e){if(e.isZero())return new i(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new i(1).toRed(this),r[1]=t;for(var n=2;n<r.length;n++)r[n]=this.mul(r[n-1],t);var o=r[0],s=0,a=0,u=e.bitLength()%26;for(0===u&&(u=26),n=e.length-1;n>=0;n--){for(var c=e.words[n],h=u-1;h>=0;h--){var l=c>>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}u=26}return o},x.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},x.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},i.mont=function(t){return new S(t)},n(S,x),S.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},S.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},S.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),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)},S.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new i(0)._forceRed(this);var r=t.mul(e),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)},S.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(0,Jv);var Wk=Dk.exports,Kk=Xv(Wk),Fk={exports:{}};!function(t,e){var r=t_,n=r.Buffer;function i(t,e){for(var r in t)e[r]=t[r]}function o(t,e,r){return n(t,e,r)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?t.exports=r:(i(r,e),e.Buffer=o),o.prototype=Object.create(n.prototype),i(n,o),o.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return n(t,e,r)},o.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var i=n(t);return void 0!==e?"string"==typeof r?i.fill(e,r):i.fill(e):i.fill(0),i},o.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n(t)},o.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return r.SlowBuffer(t)}}(Fk,Fk.exports);var qk=Fk.exports.Buffer,Vk=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r<e.length;r++)e[r]=255;for(var n=0;n<t.length;n++){var i=t.charAt(n),o=i.charCodeAt(0);if(255!==e[o])throw new TypeError(i+" is ambiguous");e[o]=n}var s=t.length,a=t.charAt(0),u=Math.log(s)/Math.log(256),c=Math.log(256)/Math.log(s);function h(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return qk.alloc(0);for(var r=0,n=0,i=0;t[r]===a;)n++,r++;for(var o=(t.length-r)*u+1>>>0,c=new Uint8Array(o);t[r];){var h=e[t.charCodeAt(r)];if(255===h)return;for(var l=0,f=o-1;(0!==h||l<i)&&-1!==f;f--,l++)h+=s*c[f]>>>0,c[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===c[d];)d++;var p=qk.allocUnsafe(n+(o-d));p.fill(0,0,n);for(var y=n;d!==o;)p[y++]=c[d++];return p}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=qk.from(e)),!qk.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,n=0,i=0,o=e.length;i!==o&&0===e[i];)i++,r++;for(var u=(o-i)*c+1>>>0,h=new Uint8Array(u);i!==o;){for(var l=e[i],f=0,d=u-1;(0!==l||f<n)&&-1!==d;d--,f++)l+=256*h[d]>>>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=u-n;p!==u&&0===h[p];)p++;for(var y=a.repeat(r);p<u;++p)y+=t.charAt(h[p]);return y},decodeUnsafe:h,decode:function(t){var e=h(t);if(e)return e;throw new Error("Non-base"+s+" character")}}}("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),Hk=Xv(Vk);const $k=(t,e,r)=>t&e^t&r^e&r,Gk=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]),Zk=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Yk=new Uint32Array(64);class Jk extends __{constructor(){super(64,32,8,!1),this.A=0|Zk[0],this.B=0|Zk[1],this.C=0|Zk[2],this.D=0|Zk[3],this.E=0|Zk[4],this.F=0|Zk[5],this.G=0|Zk[6],this.H=0|Zk[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:o,G:s,H:a}=this;return[t,e,r,n,i,o,s,a]}set(t,e,r,n,i,o,s,a){this.A=0|t,this.B=0|e,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(t,e){for(let r=0;r<16;r++,e+=4)Yk[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=Yk[t-15],r=Yk[t-2],n=g_(e,7)^g_(e,18)^e>>>3,i=g_(r,17)^g_(r,19)^r>>>10;Yk[t]=i+Yk[t-7]+n+Yk[t-16]|0}let{A:r,B:n,C:i,D:o,E:s,F:a,G:u,H:c}=this;for(let t=0;t<64;t++){const e=c+(g_(s,6)^g_(s,11)^g_(s,25))+((h=s)&a^~h&u)+Gk[t]+Yk[t]|0,l=(g_(r,2)^g_(r,13)^g_(r,22))+$k(r,n,i)|0;c=u,u=a,a=s,s=o+e|0,o=i,i=n,n=r,r=e+l|0}var h;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,u=u+this.G|0,c=c+this.H|0,this.set(r,n,i,o,s,a,u,c)}roundClean(){Yk.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Xk=b_((()=>new Jk));var Qk={};function tE(t,e,r){return e<=t&&t<=r}function eE(t){if(void 0===t)return{};if(t===Object(t))return t;throw TypeError("Could not convert argument to dictionary")}function rE(t){this.tokens=[].slice.call(t)}rE.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():-1},prepend:function(t){if(Array.isArray(t))for(var e=t;e.length;)this.tokens.unshift(e.pop());else this.tokens.unshift(t)},push:function(t){if(Array.isArray(t))for(var e=t;e.length;)this.tokens.push(e.shift());else this.tokens.push(t)}};var nE=-1;function iE(t,e){if(t)throw TypeError("Decoder error");return e||65533}var oE="utf-8";function sE(t,e){if(!(this instanceof sE))return new sE(t,e);if((t=void 0!==t?String(t).toLowerCase():oE)!==oE)throw new Error("Encoding not supported. Only utf-8 is supported");e=eE(e),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=Boolean(e.fatal),this._ignoreBOM=Boolean(e.ignoreBOM),Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}function aE(t,e){if(!(this instanceof aE))return new aE(t,e);if((t=void 0!==t?String(t).toLowerCase():oE)!==oE)throw new Error("Encoding not supported. Only utf-8 is supported");e=eE(e),this._streaming=!1,this._encoder=null,this._options={fatal:Boolean(e.fatal)},Object.defineProperty(this,"encoding",{value:"utf-8"})}function uE(t){var e=t.fatal,r=0,n=0,i=0,o=128,s=191;this.handler=function(t,a){if(-1===a&&0!==i)return i=0,iE(e);if(-1===a)return nE;if(0===i){if(tE(a,0,127))return a;if(tE(a,194,223))i=1,r=a-192;else if(tE(a,224,239))224===a&&(o=160),237===a&&(s=159),i=2,r=a-224;else{if(!tE(a,240,244))return iE(e);240===a&&(o=144),244===a&&(s=143),i=3,r=a-240}return r<<=6*i,null}if(!tE(a,o,s))return r=i=n=0,o=128,s=191,t.prepend(a),iE(e);if(o=128,s=191,r+=a-128<<6*(i-(n+=1)),n!==i)return null;var u=r;return r=i=n=0,u}}function cE(t){t.fatal,this.handler=function(t,e){if(-1===e)return nE;if(tE(e,0,127))return e;var r,n;tE(e,128,2047)?(r=1,n=192):tE(e,2048,65535)?(r=2,n=224):tE(e,65536,1114111)&&(r=3,n=240);for(var i=[(e>>6*r)+n];r>0;){var o=e>>6*(r-1);i.push(128|63&o),r-=1}return i}}sE.prototype={decode:function(t,e){var r;r="object"==typeof t&&t instanceof ArrayBuffer?new Uint8Array(t):"object"==typeof t&&"buffer"in t&&t.buffer instanceof ArrayBuffer?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(0),e=eE(e),this._streaming||(this._decoder=new uE({fatal:this._fatal}),this._BOMseen=!1),this._streaming=Boolean(e.stream);for(var n,i=new rE(r),o=[];!i.endOfStream()&&(n=this._decoder.handler(i,i.read()))!==nE;)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()))===nE)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(t){for(var e="",r=0;r<t.length;++r){var n=t[r];n<=65535?e+=String.fromCharCode(n):(n-=65536,e+=String.fromCharCode(55296+(n>>10),56320+(1023&n)))}return e}(o)}},aE.prototype={encode:function(t,e){t=t?String(t):"",e=eE(e),this._streaming||(this._encoder=new cE(this._options)),this._streaming=Boolean(e.stream);for(var r,n=[],i=new rE(function(t){for(var e=String(t),r=e.length,n=0,i=[];n<r;){var o=e.charCodeAt(n);if(o<55296||o>57343)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=t.charCodeAt(n+1);if(56320<=s&&s<=57343){var a=1023&o,u=1023&s;i.push(65536+(a<<10)+u),n+=1}else i.push(65533)}n+=1}return i}(t));!i.endOfStream()&&(r=this._encoder.handler(i,i.read()))!==nE;)Array.isArray(r)?n.push.apply(n,r):n.push(r);if(!this._streaming){for(;(r=this._encoder.handler(i,i.read()))!==nE;)Array.isArray(r)?n.push.apply(n,r):n.push(r);this._encoder=null}return new Uint8Array(n)}};var hE=Qv(Object.freeze({__proto__:null,TextEncoder:aE,TextDecoder:sE})),lE=Jv&&Jv.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),fE=Jv&&Jv.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),dE=Jv&&Jv.__decorate||function(t,e,r,n){var i,o=arguments.length,s=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s},pE=Jv&&Jv.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)"default"!==r&&Object.hasOwnProperty.call(t,r)&&lE(e,t,r);return fE(e,t),e},yE=Jv&&Jv.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Qk,"__esModule",{value:!0});var gE=Qk.deserializeUnchecked=TE=Qk.deserialize=ME=Qk.serialize=Qk.BinaryReader=Qk.BinaryWriter=Qk.BorshError=Qk.baseDecode=Qk.baseEncode=void 0;const mE=yE(Wk),wE=yE(Vk),bE=pE(hE),vE=new("function"!=typeof TextDecoder?bE.TextDecoder:TextDecoder)("utf-8",{fatal:!0});Qk.baseEncode=function(t){return"string"==typeof t&&(t=Buffer.from(t,"utf8")),wE.default.encode(Buffer.from(t))},Qk.baseDecode=function(t){return Buffer.from(wE.default.decode(t))};const _E=1024;class kE extends Error{constructor(t){super(t),this.fieldPath=[],this.originalMessage=t}addToFieldPath(t){this.fieldPath.splice(0,0,t),this.message=this.originalMessage+": "+this.fieldPath.join(".")}}Qk.BorshError=kE;class EE{constructor(){this.buf=Buffer.alloc(_E),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(_E)]))}writeU8(t){this.maybeResize(),this.buf.writeUInt8(t,this.length),this.length+=1}writeU16(t){this.maybeResize(),this.buf.writeUInt16LE(t,this.length),this.length+=2}writeU32(t){this.maybeResize(),this.buf.writeUInt32LE(t,this.length),this.length+=4}writeU64(t){this.maybeResize(),this.writeBuffer(Buffer.from(new mE.default(t).toArray("le",8)))}writeU128(t){this.maybeResize(),this.writeBuffer(Buffer.from(new mE.default(t).toArray("le",16)))}writeU256(t){this.maybeResize(),this.writeBuffer(Buffer.from(new mE.default(t).toArray("le",32)))}writeU512(t){this.maybeResize(),this.writeBuffer(Buffer.from(new mE.default(t).toArray("le",64)))}writeBuffer(t){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),t,Buffer.alloc(_E)]),this.length+=t.length}writeString(t){this.maybeResize();const e=Buffer.from(t,"utf8");this.writeU32(e.length),this.writeBuffer(e)}writeFixedArray(t){this.writeBuffer(Buffer.from(t))}writeArray(t,e){this.maybeResize(),this.writeU32(t.length);for(const r of t)this.maybeResize(),e(r)}toArray(){return this.buf.subarray(0,this.length)}}function xE(t,e,r){const n=r.value;r.value=function(...t){try{return n.apply(this,t)}catch(t){if(t instanceof RangeError){const e=t.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(e)>=0)throw new kE("Reached the end of buffer when deserializing")}throw t}}}Qk.BinaryWriter=EE;class SE{constructor(t){this.buf=t,this.offset=0}readU8(){const t=this.buf.readUInt8(this.offset);return this.offset+=1,t}readU16(){const t=this.buf.readUInt16LE(this.offset);return this.offset+=2,t}readU32(){const t=this.buf.readUInt32LE(this.offset);return this.offset+=4,t}readU64(){const t=this.readBuffer(8);return new mE.default(t,"le")}readU128(){const t=this.readBuffer(16);return new mE.default(t,"le")}readU256(){const t=this.readBuffer(32);return new mE.default(t,"le")}readU512(){const t=this.readBuffer(64);return new mE.default(t,"le")}readBuffer(t){if(this.offset+t>this.buf.length)throw new kE(`Expected buffer length ${t} isn't within bounds`);const e=this.buf.slice(this.offset,this.offset+t);return this.offset+=t,e}readString(){const t=this.readU32(),e=this.readBuffer(t);try{return vE.decode(e)}catch(t){throw new kE(`Error decoding UTF-8 string: ${t}`)}}readFixedArray(t){return new Uint8Array(this.readBuffer(t))}readArray(t){const e=this.readU32(),r=Array();for(let n=0;n<e;++n)r.push(t());return r}}function AE(t){return t.charAt(0).toUpperCase()+t.slice(1)}function IE(t,e,r,n,i){try{if("string"==typeof n)i[`write${AE(n)}`](r);else if(n instanceof Array)if("number"==typeof n[0]){if(r.length!==n[0])throw new kE(`Expecting byte array of length ${n[0]}, but got ${r.length} bytes`);i.writeFixedArray(r)}else if(2===n.length&&"number"==typeof n[1]){if(r.length!==n[1])throw new kE(`Expecting byte array of length ${n[1]}, but got ${r.length} bytes`);for(let e=0;e<n[1];e++)IE(t,null,r[e],n[0],i)}else i.writeArray(r,(r=>{IE(t,e,r,n[0],i)}));else if(void 0!==n.kind)switch(n.kind){case"option":null==r?i.writeU8(0):(i.writeU8(1),IE(t,e,r,n.type,i));break;case"map":i.writeU32(r.size),r.forEach(((r,o)=>{IE(t,e,o,n.key,i),IE(t,e,r,n.value,i)}));break;default:throw new kE(`FieldType ${n} unrecognized`)}else BE(t,r,i)}catch(t){throw t instanceof kE&&t.addToFieldPath(e),t}}function BE(t,e,r){if("function"==typeof e.borshSerialize)return void e.borshSerialize(r);const n=t.get(e.constructor);if(!n)throw new kE(`Class ${e.constructor.name} is missing in schema`);if("struct"===n.kind)n.fields.map((([n,i])=>{IE(t,n,e[n],i,r)}));else{if("enum"!==n.kind)throw new kE(`Unexpected schema kind: ${n.kind} for ${e.constructor.name}`);{const i=e[n.field];for(let o=0;o<n.values.length;++o){const[s,a]=n.values[o];if(s===i){r.writeU8(o),IE(t,s,e[s],a,r);break}}}}}dE([xE],SE.prototype,"readU8",null),dE([xE],SE.prototype,"readU16",null),dE([xE],SE.prototype,"readU32",null),dE([xE],SE.prototype,"readU64",null),dE([xE],SE.prototype,"readU128",null),dE([xE],SE.prototype,"readU256",null),dE([xE],SE.prototype,"readU512",null),dE([xE],SE.prototype,"readString",null),dE([xE],SE.prototype,"readFixedArray",null),dE([xE],SE.prototype,"readArray",null),Qk.BinaryReader=SE;var ME=Qk.serialize=function(t,e,r=EE){const n=new r;return BE(t,e,n),n.toArray()};function RE(t,e,r,n){try{if("string"==typeof r)return n[`read${AE(r)}`]();if(r instanceof Array){if("number"==typeof r[0])return n.readFixedArray(r[0]);if("number"==typeof r[1]){const e=[];for(let i=0;i<r[1];i++)e.push(RE(t,null,r[0],n));return e}return n.readArray((()=>RE(t,e,r[0],n)))}if("option"===r.kind)return n.readU8()?RE(t,e,r.type,n):void 0;if("map"===r.kind){let i=new Map;const o=n.readU32();for(let s=0;s<o;s++){const o=RE(t,e,r.key,n),s=RE(t,e,r.value,n);i.set(o,s)}return i}return PE(t,r,n)}catch(t){throw t instanceof kE&&t.addToFieldPath(e),t}}function PE(t,e,r){if("function"==typeof e.borshDeserialize)return e.borshDeserialize(r);const n=t.get(e);if(!n)throw new kE(`Class ${e.name} is missing in schema`);if("struct"===n.kind){const n={};for(const[i,o]of t.get(e).fields)n[i]=RE(t,i,o,r);return new e(n)}if("enum"===n.kind){const i=r.readU8();if(i>=n.values.length)throw new kE(`Enum index: ${i} is out of range`);const[o,s]=n.values[i];return new e({[o]:RE(t,o,s,r)})}throw new kE(`Unexpected schema kind: ${n.kind} for ${e.constructor.name}`)}var TE=Qk.deserialize=function(t,e,r,n=SE){const i=new n(r),o=PE(t,e,i);if(i.offset<r.length)throw new kE(`Unexpected ${r.length-i.offset} bytes after deserialized data`);return o};gE=Qk.deserializeUnchecked=function(t,e,r,n=SE){return PE(t,e,new n(r))};var OE={};Object.defineProperty(OE,"__esModule",{value:!0}),OE.s16=OE.s8=OE.nu64be=OE.u48be=OE.u40be=OE.u32be=OE.u24be=OE.u16be=_x=OE.nu64=OE.u48=OE.u40=vx=OE.u32=OE.u24=bx=OE.u16=wx=OE.u8=mx=OE.offset=OE.greedy=OE.Constant=OE.UTF8=OE.CString=OE.Blob=OE.Boolean=OE.BitField=OE.BitStructure=OE.VariantLayout=OE.Union=OE.UnionLayoutDiscriminator=OE.UnionDiscriminator=OE.Structure=OE.Sequence=OE.DoubleBE=OE.Double=OE.FloatBE=OE.Float=OE.NearInt64BE=OE.NearInt64=OE.NearUInt64BE=OE.NearUInt64=OE.IntBE=OE.Int=OE.UIntBE=OE.UInt=OE.OffsetLayout=OE.GreedyCount=OE.ExternalLayout=OE.bindConstructorLayout=OE.nameWithProperty=OE.Layout=OE.uint8ArrayToBuffer=OE.checkUint8Array=void 0,OE.constant=OE.utf8=OE.cstr=Sx=OE.blob=OE.unionLayoutDiscriminator=OE.union=xx=OE.seq=OE.bits=Ex=OE.struct=OE.f64be=OE.f64=OE.f32be=OE.f32=OE.ns64be=OE.s48be=OE.s40be=OE.s32be=OE.s24be=OE.s16be=kx=OE.ns64=OE.s48=OE.s40=OE.s32=OE.s24=void 0;const LE=t_;function UE(t){if(!(t instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}function CE(t){return UE(t),LE.Buffer.from(t.buffer,t.byteOffset,t.length)}OE.checkUint8Array=UE,OE.uint8ArrayToBuffer=CE;class NE{constructor(t,e){if(!Number.isInteger(t))throw new TypeError("span must be an integer");this.span=t,this.property=e}makeDestinationObject(){return{}}getSpan(t,e){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(t){const e=Object.create(this.constructor.prototype);return Object.assign(e,this),e.property=t,e}fromArray(t){}}function zE(t,e){return e.property?t+"["+e.property+"]":t}OE.Layout=NE,OE.nameWithProperty=zE,OE.bindConstructorLayout=function(t,e){if("function"!=typeof t)throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(t,"layout_"))throw new Error("Class is already bound to a layout");if(!(e&&e instanceof NE))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(e,"boundConstructor_"))throw new Error("layout is already bound to a constructor");t.layout_=e,e.boundConstructor_=t,e.makeDestinationObject=()=>new t,Object.defineProperty(t.prototype,"encode",{value(t,r){return e.encode(this,t,r)},writable:!0}),Object.defineProperty(t,"decode",{value:(t,r)=>e.decode(t,r),writable:!0})};class DE extends NE{isCount(){throw new Error("ExternalLayout is abstract")}}OE.ExternalLayout=DE;class jE extends DE{constructor(t=1,e){if(!Number.isInteger(t)||0>=t)throw new TypeError("elementSpan must be a (positive) integer");super(-1,e),this.elementSpan=t}isCount(){return!0}decode(t,e=0){UE(t);const r=t.length-e;return Math.floor(r/this.elementSpan)}encode(t,e,r){return 0}}OE.GreedyCount=jE;class WE extends DE{constructor(t,e=0,r){if(!(t instanceof NE))throw new TypeError("layout must be a Layout");if(!Number.isInteger(e))throw new TypeError("offset must be integer or undefined");super(t.span,r||t.property),this.layout=t,this.offset=e}isCount(){return this.layout instanceof KE||this.layout instanceof FE}decode(t,e=0){return this.layout.decode(t,e+this.offset)}encode(t,e,r=0){return this.layout.encode(t,e,r+this.offset)}}OE.OffsetLayout=WE;class KE extends NE{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return CE(t).readUIntLE(e,this.span)}encode(t,e,r=0){return CE(e).writeUIntLE(t,r,this.span),this.span}}OE.UInt=KE;class FE extends NE{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return CE(t).readUIntBE(e,this.span)}encode(t,e,r=0){return CE(e).writeUIntBE(t,r,this.span),this.span}}OE.UIntBE=FE;class qE extends NE{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return CE(t).readIntLE(e,this.span)}encode(t,e,r=0){return CE(e).writeIntLE(t,r,this.span),this.span}}OE.Int=qE;class VE extends NE{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return CE(t).readIntBE(e,this.span)}encode(t,e,r=0){return CE(e).writeIntBE(t,r,this.span),this.span}}OE.IntBE=VE;const HE=Math.pow(2,32);function $E(t){const e=Math.floor(t/HE);return{hi32:e,lo32:t-e*HE}}function GE(t,e){return t*HE+e}class ZE extends NE{constructor(t){super(8,t)}decode(t,e=0){const r=CE(t),n=r.readUInt32LE(e);return GE(r.readUInt32LE(e+4),n)}encode(t,e,r=0){const n=$E(t),i=CE(e);return i.writeUInt32LE(n.lo32,r),i.writeUInt32LE(n.hi32,r+4),8}}OE.NearUInt64=ZE;class YE extends NE{constructor(t){super(8,t)}decode(t,e=0){const r=CE(t);return GE(r.readUInt32BE(e),r.readUInt32BE(e+4))}encode(t,e,r=0){const n=$E(t),i=CE(e);return i.writeUInt32BE(n.hi32,r),i.writeUInt32BE(n.lo32,r+4),8}}OE.NearUInt64BE=YE;class JE extends NE{constructor(t){super(8,t)}decode(t,e=0){const r=CE(t),n=r.readUInt32LE(e);return GE(r.readInt32LE(e+4),n)}encode(t,e,r=0){const n=$E(t),i=CE(e);return i.writeUInt32LE(n.lo32,r),i.writeInt32LE(n.hi32,r+4),8}}OE.NearInt64=JE;class XE extends NE{constructor(t){super(8,t)}decode(t,e=0){const r=CE(t);return GE(r.readInt32BE(e),r.readUInt32BE(e+4))}encode(t,e,r=0){const n=$E(t),i=CE(e);return i.writeInt32BE(n.hi32,r),i.writeUInt32BE(n.lo32,r+4),8}}OE.NearInt64BE=XE;class QE extends NE{constructor(t){super(4,t)}decode(t,e=0){return CE(t).readFloatLE(e)}encode(t,e,r=0){return CE(e).writeFloatLE(t,r),4}}OE.Float=QE;class tx extends NE{constructor(t){super(4,t)}decode(t,e=0){return CE(t).readFloatBE(e)}encode(t,e,r=0){return CE(e).writeFloatBE(t,r),4}}OE.FloatBE=tx;class ex extends NE{constructor(t){super(8,t)}decode(t,e=0){return CE(t).readDoubleLE(e)}encode(t,e,r=0){return CE(e).writeDoubleLE(t,r),8}}OE.Double=ex;class rx extends NE{constructor(t){super(8,t)}decode(t,e=0){return CE(t).readDoubleBE(e)}encode(t,e,r=0){return CE(e).writeDoubleBE(t,r),8}}OE.DoubleBE=rx;class nx extends NE{constructor(t,e,r){if(!(t instanceof NE))throw new TypeError("elementLayout must be a Layout");if(!(e instanceof DE&&e.isCount()||Number.isInteger(e)&&0<=e))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let n=-1;!(e instanceof DE)&&0<t.span&&(n=e*t.span),super(n,r),this.elementLayout=t,this.count=e}getSpan(t,e=0){if(0<=this.span)return this.span;let r=0,n=this.count;if(n instanceof DE&&(n=n.decode(t,e)),0<this.elementLayout.span)r=n*this.elementLayout.span;else{let i=0;for(;i<n;)r+=this.elementLayout.getSpan(t,e+r),++i}return r}decode(t,e=0){const r=[];let n=0,i=this.count;for(i instanceof DE&&(i=i.decode(t,e));n<i;)r.push(this.elementLayout.decode(t,e)),e+=this.elementLayout.getSpan(t,e),n+=1;return r}encode(t,e,r=0){const n=this.elementLayout,i=t.reduce(((t,i)=>t+n.encode(i,e,r+t)),0);return this.count instanceof DE&&this.count.encode(t.length,e,r),i}}OE.Sequence=nx;class ix extends NE{constructor(t,e,r){if(!Array.isArray(t)||!t.reduce(((t,e)=>t&&e instanceof NE),!0))throw new TypeError("fields must be array of Layout instances");"boolean"==typeof e&&void 0===r&&(r=e,e=void 0);for(const e of t)if(0>e.span&&void 0===e.property)throw new Error("fields cannot contain unnamed variable-length layout");let n=-1;try{n=t.reduce(((t,e)=>t+e.getSpan()),0)}catch(t){}super(n,e),this.fields=t,this.decodePrefixes=!!r}getSpan(t,e=0){if(0<=this.span)return this.span;let r=0;try{r=this.fields.reduce(((r,n)=>{const i=n.getSpan(t,e);return e+=i,r+i}),0)}catch(t){throw new RangeError("indeterminate span")}return r}decode(t,e=0){UE(t);const r=this.makeDestinationObject();for(const n of this.fields)if(void 0!==n.property&&(r[n.property]=n.decode(t,e)),e+=n.getSpan(t,e),this.decodePrefixes&&t.length===e)break;return r}encode(t,e,r=0){const n=r;let i=0,o=0;for(const n of this.fields){let s=n.span;if(o=0<s?s:0,void 0!==n.property){const i=t[n.property];void 0!==i&&(o=n.encode(i,e,r),0>s&&(s=n.getSpan(e,r)))}i=r,r+=s}return i+o-n}fromArray(t){const e=this.makeDestinationObject();for(const r of this.fields)void 0!==r.property&&0<t.length&&(e[r.property]=t.shift());return e}layoutFor(t){if("string"!=typeof t)throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}offsetOf(t){if("string"!=typeof t)throw new TypeError("property must be string");let e=0;for(const r of this.fields){if(r.property===t)return e;0>r.span?e=-1:0<=e&&(e+=r.span)}}}OE.Structure=ix;class ox{constructor(t){this.property=t}decode(t,e){throw new Error("UnionDiscriminator is abstract")}encode(t,e,r){throw new Error("UnionDiscriminator is abstract")}}OE.UnionDiscriminator=ox;class sx extends ox{constructor(t,e){if(!(t instanceof DE&&t.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(e||t.property||"variant"),this.layout=t}decode(t,e){return this.layout.decode(t,e)}encode(t,e,r){return this.layout.encode(t,e,r)}}OE.UnionLayoutDiscriminator=sx;class ax extends NE{constructor(t,e,r){let n;if(t instanceof KE||t instanceof FE)n=new sx(new WE(t));else if(t instanceof DE&&t.isCount())n=new sx(t);else{if(!(t instanceof ox))throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");n=t}if(void 0===e&&(e=null),!(null===e||e instanceof NE))throw new TypeError("defaultLayout must be null or a Layout");if(null!==e){if(0>e.span)throw new Error("defaultLayout must have constant span");void 0===e.property&&(e=e.replicate("content"))}let i=-1;e&&(i=e.span,0<=i&&(t instanceof KE||t instanceof FE)&&(i+=n.layout.span)),super(i,r),this.discriminator=n,this.usesPrefixDiscriminator=t instanceof KE||t instanceof FE,this.defaultLayout=e,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(t){return o(t)},this.configGetSourceVariant=function(t){o=t.bind(this)}}getSpan(t,e=0){if(0<=this.span)return this.span;const r=this.getVariant(t,e);if(!r)throw new Error("unable to determine span for unrecognized variant");return r.getSpan(t,e)}defaultGetSourceVariant(t){if(Object.prototype.hasOwnProperty.call(t,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(t,this.defaultLayout.property))return;const e=this.registry[t[this.discriminator.property]];if(e&&(!e.layout||e.property&&Object.prototype.hasOwnProperty.call(t,e.property)))return e}else for(const e in this.registry){const r=this.registry[e];if(r.property&&Object.prototype.hasOwnProperty.call(t,r.property))return r}throw new Error("unable to infer src variant")}decode(t,e=0){let r;const n=this.discriminator,i=n.decode(t,e),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(t,e+s)}else r=o.decode(t,e);return r}encode(t,e,r=0){const n=this.getSourceVariant(t);if(void 0===n){const n=this.discriminator,i=this.defaultLayout;let o=0;return this.usesPrefixDiscriminator&&(o=n.layout.span),n.encode(t[n.property],e,r),o+i.encode(t[i.property],e,r+o)}return n.encode(t,e,r)}addVariant(t,e,r){const n=new ux(this,t,e,r);return this.registry[t]=n,n}getVariant(t,e=0){let r;return r=t instanceof Uint8Array?this.discriminator.decode(t,e):t,this.registry[r]}}OE.Union=ax;class ux extends NE{constructor(t,e,r,n){if(!(t instanceof ax))throw new TypeError("union must be a Union");if(!Number.isInteger(e)||0>e)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 NE))throw new TypeError("layout must be a Layout");if(null!==t.defaultLayout&&0<=r.span&&r.span>t.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=t.span;0>t.span&&(i=r?r.span:0,0<=i&&t.usesPrefixDiscriminator&&(i+=t.discriminator.layout.span)),super(i,n),this.union=t,this.variant=e,this.layout=r||null}getSpan(t,e=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(t,e+r)),r+n}decode(t,e=0){const r=this.makeDestinationObject();if(this!==this.union.getVariant(t,e))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(t,e+n):this.property?r[this.property]=!0:this.union.usesPrefixDiscriminator&&(r[this.union.discriminator.property]=this.variant),r}encode(t,e,r=0){let n=0;if(this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(t,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,e,r);let i=n;if(this.layout&&(this.layout.encode(t[this.property],e,r+n),i+=this.layout.getSpan(e,r+n),0<=this.union.span&&i>this.union.span))throw new Error("encoded variant overruns containing union");return i}fromArray(t){if(this.layout)return this.layout.fromArray(t)}}function cx(t){return 0>t&&(t+=4294967296),t}OE.VariantLayout=ux;class hx extends NE{constructor(t,e,r){if(!(t instanceof KE||t instanceof FE))throw new TypeError("word must be a UInt or UIntBE layout");if("string"==typeof e&&void 0===r&&(r=e,e=!1),4<t.span)throw new RangeError("word cannot exceed 32 bits");super(t.span,r),this.word=t,this.msb=!!e,this.fields=[];let n=0;this._packedSetValue=function(t){return n=cx(t),this},this._packedGetValue=function(){return n}}decode(t,e=0){const r=this.makeDestinationObject(),n=this.word.decode(t,e);this._packedSetValue(n);for(const e of this.fields)void 0!==e.property&&(r[e.property]=e.decode(t));return r}encode(t,e,r=0){const n=this.word.decode(e,r);this._packedSetValue(n);for(const e of this.fields)if(void 0!==e.property){const r=t[e.property];void 0!==r&&e.encode(r)}return this.word.encode(this._packedGetValue(),e,r)}addField(t,e){const r=new lx(this,t,e);return this.fields.push(r),r}addBoolean(t){const e=new fx(this,t);return this.fields.push(e),e}fieldFor(t){if("string"!=typeof t)throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}}OE.BitStructure=hx;class lx{constructor(t,e,r){if(!(t instanceof hx))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(e)||0>=e)throw new TypeError("bits must be positive integer");const n=8*t.span,i=t.fields.reduce(((t,e)=>t+e.bits),0);if(e+i>n)throw new Error("bits too long for span remainder ("+(n-i)+" of "+n+" remain)");this.container=t,this.bits=e,this.valueMask=(1<<e)-1,32===e&&(this.valueMask=4294967295),this.start=i,this.container.msb&&(this.start=n-i-e),this.wordMask=cx(this.valueMask<<this.start),this.property=r}decode(t,e){return cx(this.container._packedGetValue()&this.wordMask)>>>this.start}encode(t){if("number"!=typeof t||!Number.isInteger(t)||t!==cx(t&this.valueMask))throw new TypeError(zE("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const e=this.container._packedGetValue(),r=cx(t<<this.start);this.container._packedSetValue(cx(e&~this.wordMask)|r)}}OE.BitField=lx;class fx extends lx{constructor(t,e){super(t,1,e)}decode(t,e){return!!super.decode(t,e)}encode(t){"boolean"==typeof t&&(t=+t),super.encode(t)}}OE.Boolean=fx;class dx extends NE{constructor(t,e){if(!(t instanceof DE&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let r=-1;t instanceof DE||(r=t),super(r,e),this.length=t}getSpan(t,e){let r=this.span;return 0>r&&(r=this.length.decode(t,e)),r}decode(t,e=0){let r=this.span;return 0>r&&(r=this.length.decode(t,e)),CE(t).slice(e,e+r)}encode(t,e,r){let n=this.length;if(this.length instanceof DE&&(n=t.length),!(t instanceof Uint8Array&&n===t.length))throw new TypeError(zE("Blob.encode",this)+" requires (length "+n+") Uint8Array as src");if(r+n>e.length)throw new RangeError("encoding overruns Uint8Array");const i=CE(t);return CE(e).write(i.toString("hex"),r,n,"hex"),this.length instanceof DE&&this.length.encode(n,e,r),n}}OE.Blob=dx;class px extends NE{constructor(t){super(-1,t)}getSpan(t,e=0){UE(t);let r=e;for(;r<t.length&&0!==t[r];)r+=1;return 1+r-e}decode(t,e=0){const r=this.getSpan(t,e);return CE(t).slice(e,e+r-1).toString("utf-8")}encode(t,e,r=0){"string"!=typeof t&&(t=String(t));const n=LE.Buffer.from(t,"utf8"),i=n.length;if(r+i>e.length)throw new RangeError("encoding overruns Buffer");const o=CE(e);return n.copy(o,r),o[r+i]=0,i+1}}OE.CString=px;class yx extends NE{constructor(t,e){if("string"==typeof t&&void 0===e&&(e=t,t=void 0),void 0===t)t=-1;else if(!Number.isInteger(t))throw new TypeError("maxSpan must be an integer");super(-1,e),this.maxSpan=t}getSpan(t,e=0){return UE(t),t.length-e}decode(t,e=0){const r=this.getSpan(t,e);if(0<=this.maxSpan&&this.maxSpan<r)throw new RangeError("text length exceeds maxSpan");return CE(t).slice(e,e+r).toString("utf-8")}encode(t,e,r=0){"string"!=typeof t&&(t=String(t));const n=LE.Buffer.from(t,"utf8"),i=n.length;if(0<=this.maxSpan&&this.maxSpan<i)throw new RangeError("text length exceeds maxSpan");if(r+i>e.length)throw new RangeError("encoding overruns Buffer");return n.copy(CE(e),r),i}}OE.UTF8=yx;class gx extends NE{constructor(t,e){super(0,e),this.value=t}decode(t,e){return this.value}encode(t,e,r){return 0}}OE.Constant=gx,OE.greedy=(t,e)=>new jE(t,e);var mx=OE.offset=(t,e,r)=>new WE(t,e,r),wx=OE.u8=t=>new KE(1,t),bx=OE.u16=t=>new KE(2,t);OE.u24=t=>new KE(3,t);var vx=OE.u32=t=>new KE(4,t);OE.u40=t=>new KE(5,t),OE.u48=t=>new KE(6,t);var _x=OE.nu64=t=>new ZE(t);OE.u16be=t=>new FE(2,t),OE.u24be=t=>new FE(3,t),OE.u32be=t=>new FE(4,t),OE.u40be=t=>new FE(5,t),OE.u48be=t=>new FE(6,t),OE.nu64be=t=>new YE(t),OE.s8=t=>new qE(1,t),OE.s16=t=>new qE(2,t),OE.s24=t=>new qE(3,t),OE.s32=t=>new qE(4,t),OE.s40=t=>new qE(5,t),OE.s48=t=>new qE(6,t);var kx=OE.ns64=t=>new JE(t);OE.s16be=t=>new VE(2,t),OE.s24be=t=>new VE(3,t),OE.s32be=t=>new VE(4,t),OE.s40be=t=>new VE(5,t),OE.s48be=t=>new VE(6,t),OE.ns64be=t=>new XE(t),OE.f32=t=>new QE(t),OE.f32be=t=>new tx(t),OE.f64=t=>new ex(t),OE.f64be=t=>new rx(t);var Ex=OE.struct=(t,e,r)=>new ix(t,e,r);OE.bits=(t,e,r)=>new hx(t,e,r);var xx=OE.seq=(t,e,r)=>new nx(t,e,r);OE.union=(t,e,r)=>new ax(t,e,r),OE.unionLayoutDiscriminator=(t,e)=>new sx(t,e);var Sx=OE.blob=(t,e)=>new dx(t,e);OE.cstr=t=>new px(t),OE.utf8=(t,e)=>new yx(t,e),OE.constant=(t,e)=>new gx(t,e);var Ax={};Object.defineProperty(Ax,"__esModule",{value:!0});var Ix=Ax.toBigIntLE=function(t){{const e=Buffer.from(t);e.reverse();const r=e.toString("hex");return 0===r.length?BigInt(0):BigInt(`0x${r}`)}};Ax.toBigIntBE=function(t){{const e=t.toString("hex");return 0===e.length?BigInt(0):BigInt(`0x${e}`)}};var Bx,Mx=Ax.toBufferLE=function(t,e){{const r=t.toString(16),n=Buffer.from(r.padStart(2*e,"0").slice(0,2*e),"hex");return n.reverse(),n}};Ax.toBufferBE=function(t,e){{const r=t.toString(16);return Buffer.from(r.padStart(2*e,"0").slice(0,2*e),"hex")}};class Rx extends TypeError{constructor(t,e){let r;const{message:n,...i}=t,{path:o}=t;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=[t,...e()]}}}function Px(t){return"object"==typeof t&&null!=t}function Tx(t){return"string"==typeof t?JSON.stringify(t):""+t}function Ox(t,e,r,n){if(!0===t)return;!1===t?t={}:"string"==typeof t&&(t={message:t});const{path:i,branch:o}=e,{type:s}=r,{refinement:a,message:u="Expected a value of type `"+s+"`"+(a?" with refinement `"+a+"`":"")+", but received: `"+Tx(n)+"`"}=t;return{value:n,type:s,refinement:a,key:i[i.length-1],path:i,branch:o,...t,message:u}}function*Lx(t,e,r,n){var i;Px(i=t)&&"function"==typeof i[Symbol.iterator]||(t=[t]);for(const i of t){const t=Ox(i,e,r,n);t&&(yield t)}}function*Ux(t,e,r={}){const{path:n=[],branch:i=[t],coerce:o=!1,mask:s=!1}=r,a={path:n,branch:i};if(o&&(t=e.coercer(t,a),s&&"type"!==e.type&&Px(e.schema)&&Px(t)&&!Array.isArray(t)))for(const r in t)void 0===e.schema[r]&&delete t[r];let u=!0;for(const r of e.validator(t,a))u=!1,yield[r,void 0];for(let[r,c,h]of e.entries(t,a)){const e=Ux(c,h,{path:void 0===r?n:[...n,r],branch:void 0===r?i:[...i,c],coerce:o,mask:s});for(const n of e)n[0]?(u=!1,yield[n[0],void 0]):o&&(c=n[1],void 0===r?t=c:t instanceof Map?t.set(r,c):t instanceof Set?t.add(c):Px(t)&&(t[r]=c))}if(u)for(const r of e.refiner(t,a))u=!1,yield[r,void 0];u&&(yield[void 0,t])}class Cx{constructor(t){const{type:e,schema:r,validator:n,refiner:i,coercer:o=(t=>t),entries:s=function*(){}}=t;this.type=e,this.schema=r,this.entries=s,this.coercer=o,this.validator=n?(t,e)=>Lx(n(t,e),e,this,t):()=>[],this.refiner=i?(t,e)=>Lx(i(t,e),e,this,t):()=>[]}assert(t){return function(t,e){const r=Dx(t,e);if(r[0])throw r[0]}(t,this)}create(t){return Nx(t,this)}is(t){return zx(t,this)}mask(t){return function(t,e){const r=Dx(t,e,{coerce:!0,mask:!0});if(r[0])throw r[0];return r[1]}(t,this)}validate(t,e={}){return Dx(t,this,e)}}function Nx(t,e){const r=Dx(t,e,{coerce:!0});if(r[0])throw r[0];return r[1]}function zx(t,e){return!Dx(t,e)[0]}function Dx(t,e,r={}){const n=Ux(t,e,r),i=function(t){const{done:e,value:r}=t.next();return e?void 0:r}(n);return i[0]?[new Rx(i[0],(function*(){for(const t of n)t[0]&&(yield t[0])})),void 0]:[void 0,i[1]]}function jx(t,e){return new Cx({type:t,schema:null,validator:e})}function Wx(t){return new Cx({type:"array",schema:t,*entries(e){if(t&&Array.isArray(e))for(const[r,n]of e.entries())yield[r,n,t]},coercer:t=>Array.isArray(t)?t.slice():t,validator:t=>Array.isArray(t)||"Expected an array value, but received: "+Tx(t)})}function Kx(){return jx("boolean",(t=>"boolean"==typeof t))}function Fx(t){return jx("instance",(e=>e instanceof t||"Expected a `"+t.name+"` instance, but received: "+Tx(e)))}function qx(t){const e=Tx(t),r=typeof t;return new Cx({type:"literal",schema:"string"===r||"number"===r||"boolean"===r?t:null,validator:r=>r===t||"Expected the literal `"+e+"`, but received: "+Tx(r)})}function Vx(t){return new Cx({...t,validator:(e,r)=>null===e||t.validator(e,r),refiner:(e,r)=>null===e||t.refiner(e,r)})}function Hx(){return jx("number",(t=>"number"==typeof t&&!isNaN(t)||"Expected a number, but received: "+Tx(t)))}function $x(t){return new Cx({...t,validator:(e,r)=>void 0===e||t.validator(e,r),refiner:(e,r)=>void 0===e||t.refiner(e,r)})}function Gx(t,e){return new Cx({type:"record",schema:null,*entries(r){if(Px(r))for(const n in r){const i=r[n];yield[n,n,t],yield[n,i,e]}},validator:t=>Px(t)||"Expected an object, but received: "+Tx(t)})}function Zx(){return jx("string",(t=>"string"==typeof t||"Expected a string, but received: "+Tx(t)))}function Yx(t){const e=jx("never",(()=>!1));return new Cx({type:"tuple",schema:null,*entries(r){if(Array.isArray(r)){const n=Math.max(t.length,r.length);for(let i=0;i<n;i++)yield[i,r[i],t[i]||e]}},validator:t=>Array.isArray(t)||"Expected an array, but received: "+Tx(t)})}function Jx(t){const e=Object.keys(t);return new Cx({type:"type",schema:t,*entries(r){if(Px(r))for(const n of e)yield[n,r[n],t[n]]},validator:t=>Px(t)||"Expected an object, but received: "+Tx(t)})}function Xx(t){const e=t.map((t=>t.type)).join(" | ");return new Cx({type:"union",schema:null,validator(r,n){const i=[];for(const e of t){const[...t]=Ux(r,e,n),[o]=t;if(!o[0])return[];for(const[e]of t)e&&i.push(e)}return["Expected the value to satisfy a union of `"+e+"`, but received: "+Tx(r),...i]}})}function Qx(){return jx("unknown",(()=>!0))}function tS(t,e,r){return new Cx({...t,coercer:(n,i)=>zx(n,e)?t.coercer(r(n,i),i):t.coercer(n,i)})}var eS=new Uint8Array(16);function rS(){if(!Bx&&!(Bx="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 Bx(eS)}var nS=/^(?:[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 iS(t){return"string"==typeof t&&nS.test(t)}for(var oS,sS,aS=[],uS=0;uS<256;++uS)aS.push((uS+256).toString(16).substr(1));function cS(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(aS[t[e+0]]+aS[t[e+1]]+aS[t[e+2]]+aS[t[e+3]]+"-"+aS[t[e+4]]+aS[t[e+5]]+"-"+aS[t[e+6]]+aS[t[e+7]]+"-"+aS[t[e+8]]+aS[t[e+9]]+"-"+aS[t[e+10]]+aS[t[e+11]]+aS[t[e+12]]+aS[t[e+13]]+aS[t[e+14]]+aS[t[e+15]]).toLowerCase();if(!iS(r))throw TypeError("Stringified UUID is invalid");return r}var hS=0,lS=0;function fS(t){if(!iS(t))throw TypeError("Invalid UUID");var e,r=new Uint8Array(16);return r[0]=(e=parseInt(t.slice(0,8),16))>>>24,r[1]=e>>>16&255,r[2]=e>>>8&255,r[3]=255&e,r[4]=(e=parseInt(t.slice(9,13),16))>>>8,r[5]=255&e,r[6]=(e=parseInt(t.slice(14,18),16))>>>8,r[7]=255&e,r[8]=(e=parseInt(t.slice(19,23),16))>>>8,r[9]=255&e,r[10]=(e=parseInt(t.slice(24,36),16))/1099511627776&255,r[11]=e/4294967296&255,r[12]=e>>>24&255,r[13]=e>>>16&255,r[14]=e>>>8&255,r[15]=255&e,r}function dS(t,e,r){function n(t,n,i,o){if("string"==typeof t&&(t=function(t){t=unescape(encodeURIComponent(t));for(var e=[],r=0;r<t.length;++r)e.push(t.charCodeAt(r));return e}(t)),"string"==typeof n&&(n=fS(n)),16!==n.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var s=new Uint8Array(16+t.length);if(s.set(n),s.set(t,n.length),(s=r(s))[6]=15&s[6]|e,s[8]=63&s[8]|128,i){o=o||0;for(var a=0;a<16;++a)i[o+a]=s[a];return i}return cS(s)}try{n.name=t}catch(t){}return n.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",n.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",n}function pS(t){return 14+(t+64>>>9<<4)+1}function yS(t,e){var r=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(r>>16)<<16|65535&r}function gS(t,e,r,n,i,o){return yS((s=yS(yS(e,t),yS(n,o)))<<(a=i)|s>>>32-a,r);var s,a}function mS(t,e,r,n,i,o,s){return gS(e&r|~e&n,t,e,i,o,s)}function wS(t,e,r,n,i,o,s){return gS(e&n|r&~n,t,e,i,o,s)}function bS(t,e,r,n,i,o,s){return gS(e^r^n,t,e,i,o,s)}function vS(t,e,r,n,i,o,s){return gS(r^(e|~n),t,e,i,o,s)}var _S=dS("v3",48,(function(t){if("string"==typeof t){var e=unescape(encodeURIComponent(t));t=new Uint8Array(e.length);for(var r=0;r<e.length;++r)t[r]=e.charCodeAt(r)}return function(t){for(var e=[],r=32*t.length,n="0123456789abcdef",i=0;i<r;i+=8){var o=t[i>>5]>>>i%32&255,s=parseInt(n.charAt(o>>>4&15)+n.charAt(15&o),16);e.push(s)}return e}(function(t,e){t[e>>5]|=128<<e%32,t[pS(e)-1]=e;for(var r=1732584193,n=-271733879,i=-1732584194,o=271733878,s=0;s<t.length;s+=16){var a=r,u=n,c=i,h=o;r=mS(r,n,i,o,t[s],7,-680876936),o=mS(o,r,n,i,t[s+1],12,-389564586),i=mS(i,o,r,n,t[s+2],17,606105819),n=mS(n,i,o,r,t[s+3],22,-1044525330),r=mS(r,n,i,o,t[s+4],7,-176418897),o=mS(o,r,n,i,t[s+5],12,1200080426),i=mS(i,o,r,n,t[s+6],17,-1473231341),n=mS(n,i,o,r,t[s+7],22,-45705983),r=mS(r,n,i,o,t[s+8],7,1770035416),o=mS(o,r,n,i,t[s+9],12,-1958414417),i=mS(i,o,r,n,t[s+10],17,-42063),n=mS(n,i,o,r,t[s+11],22,-1990404162),r=mS(r,n,i,o,t[s+12],7,1804603682),o=mS(o,r,n,i,t[s+13],12,-40341101),i=mS(i,o,r,n,t[s+14],17,-1502002290),r=wS(r,n=mS(n,i,o,r,t[s+15],22,1236535329),i,o,t[s+1],5,-165796510),o=wS(o,r,n,i,t[s+6],9,-1069501632),i=wS(i,o,r,n,t[s+11],14,643717713),n=wS(n,i,o,r,t[s],20,-373897302),r=wS(r,n,i,o,t[s+5],5,-701558691),o=wS(o,r,n,i,t[s+10],9,38016083),i=wS(i,o,r,n,t[s+15],14,-660478335),n=wS(n,i,o,r,t[s+4],20,-405537848),r=wS(r,n,i,o,t[s+9],5,568446438),o=wS(o,r,n,i,t[s+14],9,-1019803690),i=wS(i,o,r,n,t[s+3],14,-187363961),n=wS(n,i,o,r,t[s+8],20,1163531501),r=wS(r,n,i,o,t[s+13],5,-1444681467),o=wS(o,r,n,i,t[s+2],9,-51403784),i=wS(i,o,r,n,t[s+7],14,1735328473),r=bS(r,n=wS(n,i,o,r,t[s+12],20,-1926607734),i,o,t[s+5],4,-378558),o=bS(o,r,n,i,t[s+8],11,-2022574463),i=bS(i,o,r,n,t[s+11],16,1839030562),n=bS(n,i,o,r,t[s+14],23,-35309556),r=bS(r,n,i,o,t[s+1],4,-1530992060),o=bS(o,r,n,i,t[s+4],11,1272893353),i=bS(i,o,r,n,t[s+7],16,-155497632),n=bS(n,i,o,r,t[s+10],23,-1094730640),r=bS(r,n,i,o,t[s+13],4,681279174),o=bS(o,r,n,i,t[s],11,-358537222),i=bS(i,o,r,n,t[s+3],16,-722521979),n=bS(n,i,o,r,t[s+6],23,76029189),r=bS(r,n,i,o,t[s+9],4,-640364487),o=bS(o,r,n,i,t[s+12],11,-421815835),i=bS(i,o,r,n,t[s+15],16,530742520),r=vS(r,n=bS(n,i,o,r,t[s+2],23,-995338651),i,o,t[s],6,-198630844),o=vS(o,r,n,i,t[s+7],10,1126891415),i=vS(i,o,r,n,t[s+14],15,-1416354905),n=vS(n,i,o,r,t[s+5],21,-57434055),r=vS(r,n,i,o,t[s+12],6,1700485571),o=vS(o,r,n,i,t[s+3],10,-1894986606),i=vS(i,o,r,n,t[s+10],15,-1051523),n=vS(n,i,o,r,t[s+1],21,-2054922799),r=vS(r,n,i,o,t[s+8],6,1873313359),o=vS(o,r,n,i,t[s+15],10,-30611744),i=vS(i,o,r,n,t[s+6],15,-1560198380),n=vS(n,i,o,r,t[s+13],21,1309151649),r=vS(r,n,i,o,t[s+4],6,-145523070),o=vS(o,r,n,i,t[s+11],10,-1120210379),i=vS(i,o,r,n,t[s+2],15,718787259),n=vS(n,i,o,r,t[s+9],21,-343485551),r=yS(r,a),n=yS(n,u),i=yS(i,c),o=yS(o,h)}return[r,n,i,o]}(function(t){if(0===t.length)return[];for(var e=8*t.length,r=new Uint32Array(pS(e)),n=0;n<e;n+=8)r[n>>5]|=(255&t[n/8])<<n%32;return r}(t),8*t.length))})),kS=_S;function ES(t,e,r,n){switch(t){case 0:return e&r^~e&n;case 1:case 3:return e^r^n;case 2:return e&r^e&n^r&n}}function xS(t,e){return t<<e|t>>>32-e}var SS=dS("v5",80,(function(t){var e=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof t){var n=unescape(encodeURIComponent(t));t=[];for(var i=0;i<n.length;++i)t.push(n.charCodeAt(i))}else Array.isArray(t)||(t=Array.prototype.slice.call(t));t.push(128);for(var o=t.length/4+2,s=Math.ceil(o/16),a=new Array(s),u=0;u<s;++u){for(var c=new Uint32Array(16),h=0;h<16;++h)c[h]=t[64*u+4*h]<<24|t[64*u+4*h+1]<<16|t[64*u+4*h+2]<<8|t[64*u+4*h+3];a[u]=c}a[s-1][14]=8*(t.length-1)/Math.pow(2,32),a[s-1][14]=Math.floor(a[s-1][14]),a[s-1][15]=8*(t.length-1)&4294967295;for(var l=0;l<s;++l){for(var f=new Uint32Array(80),d=0;d<16;++d)f[d]=a[l][d];for(var p=16;p<80;++p)f[p]=xS(f[p-3]^f[p-8]^f[p-14]^f[p-16],1);for(var y=r[0],g=r[1],m=r[2],w=r[3],b=r[4],v=0;v<80;++v){var _=Math.floor(v/20),k=xS(y,5)+ES(_,g,m,w)+b+e[_]+f[v]>>>0;b=w,w=m,m=xS(g,30)>>>0,g=y,y=k}r[0]=r[0]+y>>>0,r[1]=r[1]+g>>>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]]})),AS=SS,IS=Object.freeze({__proto__:null,v1:function(t,e,r){var n=e&&r||0,i=e||new Array(16),o=(t=t||{}).node||oS,s=void 0!==t.clockseq?t.clockseq:sS;if(null==o||null==s){var a=t.random||(t.rng||rS)();null==o&&(o=oS=[1|a[0],a[1],a[2],a[3],a[4],a[5]]),null==s&&(s=sS=16383&(a[6]<<8|a[7]))}var u=void 0!==t.msecs?t.msecs:Date.now(),c=void 0!==t.nsecs?t.nsecs:lS+1,h=u-hS+(c-lS)/1e4;if(h<0&&void 0===t.clockseq&&(s=s+1&16383),(h<0||u>hS)&&void 0===t.nsecs&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");hS=u,lS=c,sS=s;var l=(1e4*(268435455&(u+=122192928e5))+c)%4294967296;i[n++]=l>>>24&255,i[n++]=l>>>16&255,i[n++]=l>>>8&255,i[n++]=255&l;var f=u/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 e||cS(i)},v3:kS,v4:function(t,e,r){var n=(t=t||{}).random||(t.rng||rS)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,e){r=r||0;for(var i=0;i<16;++i)e[r+i]=n[i];return e}return cS(n)},v5:AS,NIL:"00000000-0000-0000-0000-000000000000",version:function(t){if(!iS(t))throw TypeError("Invalid UUID");return parseInt(t.substr(14,1),16)},validate:iS,stringify:cS,parse:fS}),BS=Qv(IS);BS.v4,BS.v4;var MS,RS={exports:{}};(MS=RS).exports=function(t){return t&&t.__esModule?t:{default:t}},MS.exports.__esModule=!0,MS.exports.default=MS.exports;var PS,TS,OS,LS,US=RS.exports,CS={exports:{}},NS={exports:{}};function zS(){return PS||(PS=1,function(t){function e(r){return t.exports=e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.__esModule=!0,t.exports.default=t.exports,e(r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports}(NS)),NS.exports}NS.exports;var DS,jS,WS={exports:{}},KS={exports:{}};function FS(){return jS||(jS=1,function(t){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},t.exports.__esModule=!0,t.exports.default=t.exports}(KS)),KS.exports}var qS,VS,HS,$S={exports:{}},GS={exports:{}},ZS={exports:{}};function YS(){return VS||(VS=1,function(t){var e=zS().default,r=(qS||(qS=1,function(t){var e=zS().default;t.exports=function(t,r){if("object"!==e(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,r||"default");if("object"!==e(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)},t.exports.__esModule=!0,t.exports.default=t.exports}(ZS)),ZS.exports);t.exports=function(t){var n=r(t,"string");return"symbol"===e(n)?n:String(n)},t.exports.__esModule=!0,t.exports.default=t.exports}(GS)),GS.exports}function JS(){return HS||(HS=1,function(t){var e=YS();function r(t,r){for(var n=0;n<r.length;n++){var i=r[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,e(i.key),i)}}t.exports=function(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t},t.exports.__esModule=!0,t.exports.default=t.exports}($S)),$S.exports}ZS.exports,GS.exports;var XS,QS,tA={exports:{}},eA={exports:{}};function rA(){return QS||(QS=1,function(t){var e=(XS||(XS=1,function(t){function e(r,n){return t.exports=e=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},t.exports.__esModule=!0,t.exports.default=t.exports,e(r,n)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports}(eA)),eA.exports);t.exports=function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&e(t,r)},t.exports.__esModule=!0,t.exports.default=t.exports}(tA)),tA.exports}eA.exports;var nA,iA,oA={exports:{}},sA={exports:{}};function aA(){return iA||(iA=1,function(t){var e=zS().default,r=(nA||(nA=1,function(t){t.exports=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t},t.exports.__esModule=!0,t.exports.default=t.exports}(sA)),sA.exports);t.exports=function(t,n){if(n&&("object"===e(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return r(t)},t.exports.__esModule=!0,t.exports.default=t.exports}(oA)),oA.exports}sA.exports;var uA,cA={exports:{}};function hA(){return uA||(uA=1,function(t){function e(r){return t.exports=e=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},t.exports.__esModule=!0,t.exports.default=t.exports,e(r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports}(cA)),cA.exports}var lA,fA={exports:{}};function dA(){return lA||(lA=1,function(t){var e=Object.prototype.hasOwnProperty,r="~";function n(){}function i(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function o(t,e,n,o,s){if("function"!=typeof n)throw new TypeError("The listener must be a function");var a=new i(n,o||t,s),u=r?r+e:e;return t._events[u]?t._events[u].fn?t._events[u]=[t._events[u],a]:t._events[u].push(a):(t._events[u]=a,t._eventsCount++),t}function s(t,e){0==--t._eventsCount?t._events=new n:delete t._events[e]}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 t,n,i=[];if(0===this._eventsCount)return i;for(n in t=this._events)e.call(t,n)&&i.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(t)):i},a.prototype.listeners=function(t){var e=r?r+t:t,n=this._events[e];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,o=n.length,s=new Array(o);i<o;i++)s[i]=n[i].fn;return s},a.prototype.listenerCount=function(t){var e=r?r+t:t,n=this._events[e];return n?n.fn?1:n.length:0},a.prototype.emit=function(t,e,n,i,o,s){var a=r?r+t:t;if(!this._events[a])return!1;var u,c,h=this._events[a],l=arguments.length;if(h.fn){switch(h.once&&this.removeListener(t,h.fn,void 0,!0),l){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,e),!0;case 3:return h.fn.call(h.context,e,n),!0;case 4:return h.fn.call(h.context,e,n,i),!0;case 5:return h.fn.call(h.context,e,n,i,o),!0;case 6:return h.fn.call(h.context,e,n,i,o,s),!0}for(c=1,u=new Array(l-1);c<l;c++)u[c-1]=arguments[c];h.fn.apply(h.context,u)}else{var f,d=h.length;for(c=0;c<d;c++)switch(h[c].once&&this.removeListener(t,h[c].fn,void 0,!0),l){case 1:h[c].fn.call(h[c].context);break;case 2:h[c].fn.call(h[c].context,e);break;case 3:h[c].fn.call(h[c].context,e,n);break;case 4:h[c].fn.call(h[c].context,e,n,i);break;default:if(!u)for(f=1,u=new Array(l-1);f<l;f++)u[f-1]=arguments[f];h[c].fn.apply(h[c].context,u)}}return!0},a.prototype.on=function(t,e,r){return o(this,t,e,r,!1)},a.prototype.once=function(t,e,r){return o(this,t,e,r,!0)},a.prototype.removeListener=function(t,e,n,i){var o=r?r+t:t;if(!this._events[o])return this;if(!e)return s(this,o),this;var a=this._events[o];if(a.fn)a.fn!==e||i&&!a.once||n&&a.context!==n||s(this,o);else{for(var u=0,c=[],h=a.length;u<h;u++)(a[u].fn!==e||i&&!a[u].once||n&&a[u].context!==n)&&c.push(a[u]);c.length?this._events[o]=1===c.length?c[0]:c:s(this,o)}return this},a.prototype.removeAllListeners=function(t){var e;return t?(e=r?r+t:t,this._events[e]&&s(this,e)):(this._events=new n,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=r,a.EventEmitter=a,t.exports=a}(fA)),fA.exports}!function(t){var e=US;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=e(function(){if(LS)return OS;LS=1;var t=(TS||(TS=1,function(t){var e=zS().default;function r(){
|
|
39
|
+
const Ak=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Ik=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const Bk=BigInt(1),Mk=BigInt(2),Rk=BigInt(5),Pk=BigInt(10),Tk=BigInt(20),Lk=BigInt(40),Ok=BigInt(80),Uk=pk(Ak,void 0,!0),Ck={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Uk,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:T_,randomBytes:v_,adjustScalarBytes:function(t){return t[0]&=248,t[31]&=127,t[31]|=64,t},uvRatio:function(t,e){const r=Ak,n=uk(e*e*e,r),i=function(t){const e=Ak,r=t*t%e*t%e,n=hk(r,Mk,e)*r%e,i=hk(n,Bk,e)*t%e,o=hk(i,Rk,e)*i%e,s=hk(o,Pk,e)*o%e,a=hk(s,Tk,e)*s%e,u=hk(a,Lk,e)*a%e,c=hk(u,Ok,e)*u%e,h=hk(c,Ok,e)*u%e,l=hk(h,Pk,e)*o%e;return{pow_p_5_8:hk(l,Mk,e)*t%e,b2:r}}(t*uk(n*n*e,r)).pow_p_5_8;let o=uk(t*n*i,r);const s=uk(e*o*o,r),a=o,u=uk(o*Ik,r),c=s===t,h=s===uk(-t,r),l=s===uk(-t*Ik,r);return c&&(o=a),(h||l)&&(o=u),(uk(o,r)&rk)===rk&&(o=uk(-o,r)),{isValid:c||h,value:o}}},Nk=function(t){const e=function(t){const e=vk(t);return Q_(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}(t),{Fp:r,n:n,prehash:i,hash:o,randomBytes:s,nByteLength:a,h:u}=e,c=Ek<<BigInt(8*a)-kk,h=r.create,l=e.uvRatio||((t,e)=>{try{return{isValid:!0,value:r.sqrt(t*r.inv(e))}}catch(t){return{isValid:!1,value:_k}}}),f=e.adjustScalarBytes||(t=>t),d=e.domain||((t,e,r)=>{if(e.length||r)throw new Error("Contexts/pre-hash are not supported");return t}),p=t=>"bigint"==typeof t&&_k<t,y=(t,e)=>p(t)&&p(e)&&t<e,g=t=>t===_k||y(t,c);function m(t,e){if(y(t,e))return t;throw new Error(`Expected valid scalar < ${e}, got ${typeof t} ${t}`)}function w(t){return t===_k?t:m(t,n)}const b=new Map;function v(t){if(!(t instanceof _))throw new Error("ExtendedPoint expected")}class _{constructor(t,e,r,n){if(this.ex=t,this.ey=e,this.ez=r,this.et=n,!g(t))throw new Error("x required");if(!g(e))throw new Error("y required");if(!g(r))throw new Error("z required");if(!g(n))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(t){if(t instanceof _)throw new Error("extended point not allowed");const{x:e,y:r}=t||{};if(!g(e)||!g(r))throw new Error("invalid affine point");return new _(e,r,kk,h(e*r))}static normalizeZ(t){const e=r.invertBatch(t.map((t=>t.ez)));return t.map(((t,r)=>t.toAffine(e[r]))).map(_.fromAffine)}_setWindowSize(t){this._WINDOW_SIZE=t,b.delete(this)}assertValidity(){const{a:t,d:r}=e;if(this.is0())throw new Error("bad point: ZERO");const{ex:n,ey:i,ez:o,et:s}=this,a=h(n*n),u=h(i*i),c=h(o*o),l=h(c*c),f=h(a*t);if(h(c*h(f+u))!==h(l+h(r*h(a*u))))throw new Error("bad point: equation left != right (1)");if(h(n*i)!==h(o*s))throw new Error("bad point: equation left != right (2)")}equals(t){v(t);const{ex:e,ey:r,ez:n}=this,{ex:i,ey:o,ez:s}=t,a=h(e*s),u=h(i*n),c=h(r*s),l=h(o*n);return a===u&&c===l}is0(){return this.equals(_.ZERO)}negate(){return new _(h(-this.ex),this.ey,this.ez,h(-this.et))}double(){const{a:t}=e,{ex:r,ey:n,ez:i}=this,o=h(r*r),s=h(n*n),a=h(Ek*h(i*i)),u=h(t*o),c=r+n,l=h(h(c*c)-o-s),f=u+s,d=f-a,p=u-s,y=h(l*d),g=h(f*p),m=h(l*p),w=h(d*f);return new _(y,g,w,m)}add(t){v(t);const{a:r,d:n}=e,{ex:i,ey:o,ez:s,et:a}=this,{ex:u,ey:c,ez:l,et:f}=t;if(r===BigInt(-1)){const t=h((o-i)*(c+u)),e=h((o+i)*(c-u)),r=h(e-t);if(r===_k)return this.double();const n=h(s*Ek*f),d=h(a*Ek*l),p=d+n,y=e+t,g=d-n,m=h(p*r),w=h(y*g),b=h(p*g),v=h(r*y);return new _(m,w,v,b)}const d=h(i*u),p=h(o*c),y=h(a*n*f),g=h(s*l),m=h((i+o)*(u+c)-d-p),w=g-y,b=g+y,k=h(p-r*d),E=h(m*w),x=h(b*k),S=h(m*k),A=h(w*b);return new _(E,x,A,S)}subtract(t){return this.add(t.negate())}wNAF(t){return x.wNAFCached(this,b,t,_.normalizeZ)}multiply(t){const{p:e,f:r}=this.wNAF(m(t,n));return _.normalizeZ([e,r])[0]}multiplyUnsafe(t){let e=w(t);return e===_k?E:this.equals(E)||e===kk?this:this.equals(k)?this.wNAF(e).p:x.unsafeLadder(this,e)}isSmallOrder(){return this.multiplyUnsafe(u).is0()}isTorsionFree(){return x.unsafeLadder(this,n).is0()}toAffine(t){const{ex:e,ey:n,ez:i}=this,o=this.is0();null==t&&(t=o?xk:r.inv(i));const s=h(e*t),a=h(n*t),u=h(i*t);if(o)return{x:_k,y:kk};if(u!==kk)throw new Error("invZ was invalid");return{x:s,y:a}}clearCofactor(){const{h:t}=e;return t===kk?this:this.multiplyUnsafe(t)}static fromHex(t,n=!1){const{d:i,a:o}=e,s=r.BYTES,a=(t=H_("pointHex",t,s)).slice(),u=t[s-1];a[s-1]=-129&u;const f=K_(a);f===_k||m(f,n?c:r.ORDER);const d=h(f*f),p=h(d-kk),y=h(i*d-o);let{isValid:g,value:w}=l(p,y);if(!g)throw new Error("Point.fromHex: invalid y coordinate");const b=(w&kk)===kk,v=0!=(128&u);if(!n&&w===_k&&v)throw new Error("Point.fromHex: x=0 and x_0=1");return v!==b&&(w=h(-w)),_.fromAffine({x:w,y:f})}static fromPrivateKey(t){return I(t).point}toRawBytes(){const{x:t,y:e}=this.toAffine(),n=q_(e,r.BYTES);return n[n.length-1]|=t&kk?128:0,n}toHex(){return z_(this.toRawBytes())}}_.BASE=new _(e.Gx,e.Gy,kk,h(e.Gx*e.Gy)),_.ZERO=new _(_k,kk,kk,_k);const{BASE:k,ZERO:E}=_,x=bk(_,8*a);function S(t){return uk(t,n)}function A(t){return S(K_(t))}function I(t){const e=a;t=H_("private key",t,e);const r=H_("hashed private key",o(t),2*e),n=f(r.slice(0,e)),i=r.slice(e,2*e),s=A(n),u=k.multiply(s),c=u.toRawBytes();return{head:n,prefix:i,scalar:s,point:u,pointBytes:c}}function B(t=new Uint8Array,...e){const r=$_(...e);return A(o(d(r,H_("context",t),!!i)))}const M=Sk;return k._setWindowSize(8),{CURVE:e,getPublicKey:function(t){return I(t).pointBytes},sign:function(t,e,n={}){t=H_("message",t),i&&(t=i(t));const{prefix:o,scalar:s,pointBytes:u}=I(e),c=B(n.context,o,t),h=k.multiply(c).toRawBytes(),l=S(c+B(n.context,h,u,t)*s);return w(l),H_("result",$_(h,q_(l,r.BYTES)),2*a)},verify:function(t,e,n,o=M){const{context:s,zip215:a}=o,u=r.BYTES;t=H_("signature",t,2*u),e=H_("message",e),i&&(e=i(e));const c=K_(t.slice(u,2*u));let h,l,f;try{h=_.fromHex(n,a),l=_.fromHex(t.slice(0,u),a),f=k.multiplyUnsafe(c)}catch(t){return!1}if(!a&&h.isSmallOrder())return!1;const d=B(s,l.toRawBytes(),h.toRawBytes(),e);return l.add(h.multiplyUnsafe(d)).subtract(f).clearCofactor().equals(_.ZERO)},ExtendedPoint:_,utils:{getExtendedPublicKey:I,randomPrivateKey:()=>s(r.BYTES),precompute:(t=8,e=_.BASE)=>(e._setWindowSize(t),e.multiply(BigInt(3)),e)}}}(Ck),zk=(Uk.ORDER+BigInt(3))/BigInt(8);Uk.pow(Mk,zk),Uk.sqrt(Uk.neg(Uk.ONE)),Uk.ORDER,BigInt(5),BigInt(8),BigInt(486662),function(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");const r=t.sqrt(e);t.isOdd(r)&&t.neg(r)}(Uk,Uk.neg(BigInt(486664))),BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");var Dk={exports:{}},jk=Qv(Object.freeze({__proto__:null,default:{}}));!function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function n(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function i(t,e,r){if(i.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var o;"object"==typeof Dk?Dk.exports=i:e.BN=i,i.BN=i,i.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:jk.Buffer}catch(t){}function s(t,e){var n=t.charCodeAt(e);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 "+t)}function a(t,e,r){var n=s(t,r);return r-1>=e&&(n|=s(t,r-1)<<4),n}function u(t,e,n,i){for(var o=0,s=0,a=Math.min(t.length,n),u=e;u<a;u++){var c=t.charCodeAt(u)-48;o*=i,s=c>=49?c-49+10:c>=17?c-17+10:c,r(c>=0&&s<i,"Invalid character"),o+=s}return o}function c(t,e){t.words=e.words,t.length=e.length,t.negative=e.negative,t.red=e.red}if(i.isBN=function(t){return t instanceof i||null!==t&&"object"==typeof t&&t.constructor.wordSize===i.wordSize&&Array.isArray(t.words)},i.max=function(t,e){return t.cmp(e)>0?t:e},i.min=function(t,e){return t.cmp(e)<0?t:e},i.prototype._init=function(t,e,n){if("number"==typeof t)return this._initNumber(t,e,n);if("object"==typeof t)return this._initArray(t,e,n);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var i=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(i++,this.negative=1),i<t.length&&(16===e?this._parseHex(t,i,n):(this._parseBase(t,e,i),"le"===n&&this._initArray(this.toArray(),e,n)))},i.prototype._initNumber=function(t,e,n){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),e,n)},i.prototype._initArray=function(t,e,n){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var o,s,a=0;if("be"===n)for(i=t.length-1,o=0;i>=0;i-=3)s=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===n)for(i=0,o=0;i<t.length;i+=3)s=t[i]|t[i+1]<<8|t[i+2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this._strip()},i.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var i,o=0,s=0;if("be"===r)for(n=t.length-1;n>=e;n-=2)i=a(t,e,n)<<o,this.words[s]|=67108863&i,o>=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;else for(n=(t.length-e)%2==0?e+1:e;n<t.length;n+=2)i=a(t,e,n)<<o,this.words[s]|=67108863&i,o>=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;this._strip()},i.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=e)n++;n--,i=i/e|0;for(var o=t.length-r,s=o%n,a=Math.min(o,o-s)+r,c=0,h=r;h<a;h+=n)c=u(t,h,h+n,e),this.imuln(i),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(0!==s){var l=1;for(c=u(t,h,t.length,e),h=0;h<s;h++)l*=e;this.imuln(l),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}this._strip()},i.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},i.prototype._move=function(t){c(t,this)},i.prototype.clone=function(){var t=new i(null);return this.copy(t),t},i.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},i.prototype._strip=function(){for(;this.length>1&&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(t){i.prototype.inspect=h}else i.prototype.inspect=h;function h(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}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(t,e,r){r.negative=e.negative^t.negative;var n=t.length+e.length|0;r.length=n,n=n-1|0;var i=0|t.words[0],o=0|e.words[0],s=i*o,a=67108863&s,u=s/67108864|0;r.words[0]=a;for(var c=1;c<n;c++){for(var h=u>>>26,l=67108863&u,f=Math.min(c,e.length-1),d=Math.max(0,c-t.length+1);d<=f;d++){var p=c-d|0;h+=(s=(i=0|t.words[p])*(o=0|e.words[d])+l)/67108864|0,l=67108863&s}r.words[c]=0|l,u=0|h}return 0!==u?r.words[c]=0|u:r.length--,r._strip()}i.prototype.toString=function(t,e){var n;if(e=0|e||1,16===(t=t||10)||"hex"===t){n="";for(var i=0,o=0,s=0;s<this.length;s++){var a=this.words[s],u=(16777215&(a<<i|o)).toString(16);o=a>>>24-i&16777215,(i+=2)>=26&&(i-=26,s--),n=0!==o||s!==this.length-1?l[6-u.length]+u+n:u+n}for(0!==o&&(n=o.toString(16)+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(t===(0|t)&&t>=2&&t<=36){var c=f[t],h=d[t];n="";var p=this.clone();for(p.negative=0;!p.isZero();){var y=p.modrn(h).toString(t);n=(p=p.idivn(h)).isZero()?y+n:l[c-y.length]+y+n}for(this.isZero()&&(n="0"+n);n.length%e!=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 t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},i.prototype.toJSON=function(){return this.toString(16,2)},o&&(i.prototype.toBuffer=function(t,e){return this.toArrayLike(o,t,e)}),i.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},i.prototype.toArrayLike=function(t,e,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(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,o);return this["_toArrayLike"+("le"===e?"LE":"BE")](s,i),s},i.prototype._toArrayLikeLE=function(t,e){for(var r=0,n=0,i=0,o=0;i<this.length;i++){var s=this.words[i]<<o|n;t[r++]=255&s,r<t.length&&(t[r++]=s>>8&255),r<t.length&&(t[r++]=s>>16&255),6===o?(r<t.length&&(t[r++]=s>>24&255),n=0,o=0):(n=s>>>24,o+=2)}if(r<t.length)for(t[r++]=n;r<t.length;)t[r++]=0},i.prototype._toArrayLikeBE=function(t,e){for(var r=t.length-1,n=0,i=0,o=0;i<this.length;i++){var s=this.words[i]<<o|n;t[r--]=255&s,r>=0&&(t[r--]=s>>8&255),r>=0&&(t[r--]=s>>16&255),6===o?(r>=0&&(t[r--]=s>>24&255),n=0,o=0):(n=s>>>24,o+=2)}if(r>=0)for(t[r--]=n;r>=0;)t[r--]=0},Math.clz32?i.prototype._countBits=function(t){return 32-Math.clz32(t)}:i.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},i.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},i.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},i.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return 0!==this.negative},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this._strip()},i.prototype.ior=function(t){return r(0==(this.negative|t.negative)),this.iuor(t)},i.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},i.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},i.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this._strip()},i.prototype.iand=function(t){return r(0==(this.negative|t.negative)),this.iuand(t)},i.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},i.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},i.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;n<r.length;n++)this.words[n]=e.words[n]^r.words[n];if(this!==e)for(;n<e.length;n++)this.words[n]=e.words[n];return this.length=e.length,this._strip()},i.prototype.ixor=function(t){return r(0==(this.negative|t.negative)),this.iuxor(t)},i.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},i.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},i.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),n=t%26;this._expand(e),n>0&&e--;for(var i=0;i<e;i++)this.words[i]=67108863&~this.words[i];return n>0&&(this.words[i]=~this.words[i]&67108863>>26-n),this._strip()},i.prototype.notn=function(t){return this.clone().inotn(t)},i.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);var n=t/26|0,i=t%26;return this._expand(n+1),this.words[n]=e?this.words[n]|1<<i:this.words[n]&~(1<<i),this._strip()},i.prototype.iadd=function(t){var e,r,n;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,n=t):(r=t,n=this);for(var i=0,o=0;o<n.length;o++)e=(0|r.words[o])+(0|n.words[o])+i,this.words[o]=67108863&e,i=e>>>26;for(;0!==i&&o<r.length;o++)e=(0|r.words[o])+i,this.words[o]=67108863&e,i=e>>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},i.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},i.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,n,i=this.cmp(t);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=t):(r=t,n=this);for(var o=0,s=0;s<n.length;s++)o=(e=(0|r.words[s])-(0|n.words[s])+o)>>26,this.words[s]=67108863&e;for(;0!==o&&s<r.length;s++)o=(e=(0|r.words[s])+o)>>26,this.words[s]=67108863&e;if(0===o&&s<r.length&&r!==this)for(;s<r.length;s++)this.words[s]=r.words[s];return this.length=Math.max(this.length,s),r!==this&&(this.negative=1),this._strip()},i.prototype.sub=function(t){return this.clone().isub(t)};var y=function(t,e,r){var n,i,o,s=t.words,a=e.words,u=r.words,c=0,h=0|s[0],l=8191&h,f=h>>>13,d=0|s[1],p=8191&d,y=d>>>13,g=0|s[2],m=8191&g,w=g>>>13,b=0|s[3],v=8191&b,_=b>>>13,k=0|s[4],E=8191&k,x=k>>>13,S=0|s[5],A=8191&S,I=S>>>13,B=0|s[6],M=8191&B,R=B>>>13,P=0|s[7],T=8191&P,L=P>>>13,O=0|s[8],U=8191&O,C=O>>>13,N=0|s[9],z=8191&N,D=N>>>13,j=0|a[0],W=8191&j,F=j>>>13,K=0|a[1],V=8191&K,q=K>>>13,H=0|a[2],$=8191&H,G=H>>>13,Z=0|a[3],Y=8191&Z,J=Z>>>13,X=0|a[4],Q=8191&X,tt=X>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],ot=8191&it,st=it>>>13,at=0|a[7],ut=8191&at,ct=at>>>13,ht=0|a[8],lt=8191&ht,ft=ht>>>13,dt=0|a[9],pt=8191&dt,yt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(c+(n=Math.imul(l,W))|0)+((8191&(i=(i=Math.imul(l,F))+Math.imul(f,W)|0))<<13)|0;c=((o=Math.imul(f,F))+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(p,W),i=(i=Math.imul(p,F))+Math.imul(y,W)|0,o=Math.imul(y,F);var mt=(c+(n=n+Math.imul(l,V)|0)|0)+((8191&(i=(i=i+Math.imul(l,q)|0)+Math.imul(f,V)|0))<<13)|0;c=((o=o+Math.imul(f,q)|0)+(i>>>13)|0)+(mt>>>26)|0,mt&=67108863,n=Math.imul(m,W),i=(i=Math.imul(m,F))+Math.imul(w,W)|0,o=Math.imul(w,F),n=n+Math.imul(p,V)|0,i=(i=i+Math.imul(p,q)|0)+Math.imul(y,V)|0,o=o+Math.imul(y,q)|0;var wt=(c+(n=n+Math.imul(l,$)|0)|0)+((8191&(i=(i=i+Math.imul(l,G)|0)+Math.imul(f,$)|0))<<13)|0;c=((o=o+Math.imul(f,G)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(v,W),i=(i=Math.imul(v,F))+Math.imul(_,W)|0,o=Math.imul(_,F),n=n+Math.imul(m,V)|0,i=(i=i+Math.imul(m,q)|0)+Math.imul(w,V)|0,o=o+Math.imul(w,q)|0,n=n+Math.imul(p,$)|0,i=(i=i+Math.imul(p,G)|0)+Math.imul(y,$)|0,o=o+Math.imul(y,G)|0;var bt=(c+(n=n+Math.imul(l,Y)|0)|0)+((8191&(i=(i=i+Math.imul(l,J)|0)+Math.imul(f,Y)|0))<<13)|0;c=((o=o+Math.imul(f,J)|0)+(i>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(E,W),i=(i=Math.imul(E,F))+Math.imul(x,W)|0,o=Math.imul(x,F),n=n+Math.imul(v,V)|0,i=(i=i+Math.imul(v,q)|0)+Math.imul(_,V)|0,o=o+Math.imul(_,q)|0,n=n+Math.imul(m,$)|0,i=(i=i+Math.imul(m,G)|0)+Math.imul(w,$)|0,o=o+Math.imul(w,G)|0,n=n+Math.imul(p,Y)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(y,Y)|0,o=o+Math.imul(y,J)|0;var vt=(c+(n=n+Math.imul(l,Q)|0)|0)+((8191&(i=(i=i+Math.imul(l,tt)|0)+Math.imul(f,Q)|0))<<13)|0;c=((o=o+Math.imul(f,tt)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(A,W),i=(i=Math.imul(A,F))+Math.imul(I,W)|0,o=Math.imul(I,F),n=n+Math.imul(E,V)|0,i=(i=i+Math.imul(E,q)|0)+Math.imul(x,V)|0,o=o+Math.imul(x,q)|0,n=n+Math.imul(v,$)|0,i=(i=i+Math.imul(v,G)|0)+Math.imul(_,$)|0,o=o+Math.imul(_,G)|0,n=n+Math.imul(m,Y)|0,i=(i=i+Math.imul(m,J)|0)+Math.imul(w,Y)|0,o=o+Math.imul(w,J)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(y,Q)|0,o=o+Math.imul(y,tt)|0;var _t=(c+(n=n+Math.imul(l,rt)|0)|0)+((8191&(i=(i=i+Math.imul(l,nt)|0)+Math.imul(f,rt)|0))<<13)|0;c=((o=o+Math.imul(f,nt)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(M,W),i=(i=Math.imul(M,F))+Math.imul(R,W)|0,o=Math.imul(R,F),n=n+Math.imul(A,V)|0,i=(i=i+Math.imul(A,q)|0)+Math.imul(I,V)|0,o=o+Math.imul(I,q)|0,n=n+Math.imul(E,$)|0,i=(i=i+Math.imul(E,G)|0)+Math.imul(x,$)|0,o=o+Math.imul(x,G)|0,n=n+Math.imul(v,Y)|0,i=(i=i+Math.imul(v,J)|0)+Math.imul(_,Y)|0,o=o+Math.imul(_,J)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,tt)|0)+Math.imul(w,Q)|0,o=o+Math.imul(w,tt)|0,n=n+Math.imul(p,rt)|0,i=(i=i+Math.imul(p,nt)|0)+Math.imul(y,rt)|0,o=o+Math.imul(y,nt)|0;var kt=(c+(n=n+Math.imul(l,ot)|0)|0)+((8191&(i=(i=i+Math.imul(l,st)|0)+Math.imul(f,ot)|0))<<13)|0;c=((o=o+Math.imul(f,st)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(T,W),i=(i=Math.imul(T,F))+Math.imul(L,W)|0,o=Math.imul(L,F),n=n+Math.imul(M,V)|0,i=(i=i+Math.imul(M,q)|0)+Math.imul(R,V)|0,o=o+Math.imul(R,q)|0,n=n+Math.imul(A,$)|0,i=(i=i+Math.imul(A,G)|0)+Math.imul(I,$)|0,o=o+Math.imul(I,G)|0,n=n+Math.imul(E,Y)|0,i=(i=i+Math.imul(E,J)|0)+Math.imul(x,Y)|0,o=o+Math.imul(x,J)|0,n=n+Math.imul(v,Q)|0,i=(i=i+Math.imul(v,tt)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,tt)|0,n=n+Math.imul(m,rt)|0,i=(i=i+Math.imul(m,nt)|0)+Math.imul(w,rt)|0,o=o+Math.imul(w,nt)|0,n=n+Math.imul(p,ot)|0,i=(i=i+Math.imul(p,st)|0)+Math.imul(y,ot)|0,o=o+Math.imul(y,st)|0;var Et=(c+(n=n+Math.imul(l,ut)|0)|0)+((8191&(i=(i=i+Math.imul(l,ct)|0)+Math.imul(f,ut)|0))<<13)|0;c=((o=o+Math.imul(f,ct)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(U,W),i=(i=Math.imul(U,F))+Math.imul(C,W)|0,o=Math.imul(C,F),n=n+Math.imul(T,V)|0,i=(i=i+Math.imul(T,q)|0)+Math.imul(L,V)|0,o=o+Math.imul(L,q)|0,n=n+Math.imul(M,$)|0,i=(i=i+Math.imul(M,G)|0)+Math.imul(R,$)|0,o=o+Math.imul(R,G)|0,n=n+Math.imul(A,Y)|0,i=(i=i+Math.imul(A,J)|0)+Math.imul(I,Y)|0,o=o+Math.imul(I,J)|0,n=n+Math.imul(E,Q)|0,i=(i=i+Math.imul(E,tt)|0)+Math.imul(x,Q)|0,o=o+Math.imul(x,tt)|0,n=n+Math.imul(v,rt)|0,i=(i=i+Math.imul(v,nt)|0)+Math.imul(_,rt)|0,o=o+Math.imul(_,nt)|0,n=n+Math.imul(m,ot)|0,i=(i=i+Math.imul(m,st)|0)+Math.imul(w,ot)|0,o=o+Math.imul(w,st)|0,n=n+Math.imul(p,ut)|0,i=(i=i+Math.imul(p,ct)|0)+Math.imul(y,ut)|0,o=o+Math.imul(y,ct)|0;var xt=(c+(n=n+Math.imul(l,lt)|0)|0)+((8191&(i=(i=i+Math.imul(l,ft)|0)+Math.imul(f,lt)|0))<<13)|0;c=((o=o+Math.imul(f,ft)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(z,W),i=(i=Math.imul(z,F))+Math.imul(D,W)|0,o=Math.imul(D,F),n=n+Math.imul(U,V)|0,i=(i=i+Math.imul(U,q)|0)+Math.imul(C,V)|0,o=o+Math.imul(C,q)|0,n=n+Math.imul(T,$)|0,i=(i=i+Math.imul(T,G)|0)+Math.imul(L,$)|0,o=o+Math.imul(L,G)|0,n=n+Math.imul(M,Y)|0,i=(i=i+Math.imul(M,J)|0)+Math.imul(R,Y)|0,o=o+Math.imul(R,J)|0,n=n+Math.imul(A,Q)|0,i=(i=i+Math.imul(A,tt)|0)+Math.imul(I,Q)|0,o=o+Math.imul(I,tt)|0,n=n+Math.imul(E,rt)|0,i=(i=i+Math.imul(E,nt)|0)+Math.imul(x,rt)|0,o=o+Math.imul(x,nt)|0,n=n+Math.imul(v,ot)|0,i=(i=i+Math.imul(v,st)|0)+Math.imul(_,ot)|0,o=o+Math.imul(_,st)|0,n=n+Math.imul(m,ut)|0,i=(i=i+Math.imul(m,ct)|0)+Math.imul(w,ut)|0,o=o+Math.imul(w,ct)|0,n=n+Math.imul(p,lt)|0,i=(i=i+Math.imul(p,ft)|0)+Math.imul(y,lt)|0,o=o+Math.imul(y,ft)|0;var St=(c+(n=n+Math.imul(l,pt)|0)|0)+((8191&(i=(i=i+Math.imul(l,yt)|0)+Math.imul(f,pt)|0))<<13)|0;c=((o=o+Math.imul(f,yt)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(z,V),i=(i=Math.imul(z,q))+Math.imul(D,V)|0,o=Math.imul(D,q),n=n+Math.imul(U,$)|0,i=(i=i+Math.imul(U,G)|0)+Math.imul(C,$)|0,o=o+Math.imul(C,G)|0,n=n+Math.imul(T,Y)|0,i=(i=i+Math.imul(T,J)|0)+Math.imul(L,Y)|0,o=o+Math.imul(L,J)|0,n=n+Math.imul(M,Q)|0,i=(i=i+Math.imul(M,tt)|0)+Math.imul(R,Q)|0,o=o+Math.imul(R,tt)|0,n=n+Math.imul(A,rt)|0,i=(i=i+Math.imul(A,nt)|0)+Math.imul(I,rt)|0,o=o+Math.imul(I,nt)|0,n=n+Math.imul(E,ot)|0,i=(i=i+Math.imul(E,st)|0)+Math.imul(x,ot)|0,o=o+Math.imul(x,st)|0,n=n+Math.imul(v,ut)|0,i=(i=i+Math.imul(v,ct)|0)+Math.imul(_,ut)|0,o=o+Math.imul(_,ct)|0,n=n+Math.imul(m,lt)|0,i=(i=i+Math.imul(m,ft)|0)+Math.imul(w,lt)|0,o=o+Math.imul(w,ft)|0;var At=(c+(n=n+Math.imul(p,pt)|0)|0)+((8191&(i=(i=i+Math.imul(p,yt)|0)+Math.imul(y,pt)|0))<<13)|0;c=((o=o+Math.imul(y,yt)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(z,$),i=(i=Math.imul(z,G))+Math.imul(D,$)|0,o=Math.imul(D,G),n=n+Math.imul(U,Y)|0,i=(i=i+Math.imul(U,J)|0)+Math.imul(C,Y)|0,o=o+Math.imul(C,J)|0,n=n+Math.imul(T,Q)|0,i=(i=i+Math.imul(T,tt)|0)+Math.imul(L,Q)|0,o=o+Math.imul(L,tt)|0,n=n+Math.imul(M,rt)|0,i=(i=i+Math.imul(M,nt)|0)+Math.imul(R,rt)|0,o=o+Math.imul(R,nt)|0,n=n+Math.imul(A,ot)|0,i=(i=i+Math.imul(A,st)|0)+Math.imul(I,ot)|0,o=o+Math.imul(I,st)|0,n=n+Math.imul(E,ut)|0,i=(i=i+Math.imul(E,ct)|0)+Math.imul(x,ut)|0,o=o+Math.imul(x,ct)|0,n=n+Math.imul(v,lt)|0,i=(i=i+Math.imul(v,ft)|0)+Math.imul(_,lt)|0,o=o+Math.imul(_,ft)|0;var It=(c+(n=n+Math.imul(m,pt)|0)|0)+((8191&(i=(i=i+Math.imul(m,yt)|0)+Math.imul(w,pt)|0))<<13)|0;c=((o=o+Math.imul(w,yt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(z,Y),i=(i=Math.imul(z,J))+Math.imul(D,Y)|0,o=Math.imul(D,J),n=n+Math.imul(U,Q)|0,i=(i=i+Math.imul(U,tt)|0)+Math.imul(C,Q)|0,o=o+Math.imul(C,tt)|0,n=n+Math.imul(T,rt)|0,i=(i=i+Math.imul(T,nt)|0)+Math.imul(L,rt)|0,o=o+Math.imul(L,nt)|0,n=n+Math.imul(M,ot)|0,i=(i=i+Math.imul(M,st)|0)+Math.imul(R,ot)|0,o=o+Math.imul(R,st)|0,n=n+Math.imul(A,ut)|0,i=(i=i+Math.imul(A,ct)|0)+Math.imul(I,ut)|0,o=o+Math.imul(I,ct)|0,n=n+Math.imul(E,lt)|0,i=(i=i+Math.imul(E,ft)|0)+Math.imul(x,lt)|0,o=o+Math.imul(x,ft)|0;var Bt=(c+(n=n+Math.imul(v,pt)|0)|0)+((8191&(i=(i=i+Math.imul(v,yt)|0)+Math.imul(_,pt)|0))<<13)|0;c=((o=o+Math.imul(_,yt)|0)+(i>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,n=Math.imul(z,Q),i=(i=Math.imul(z,tt))+Math.imul(D,Q)|0,o=Math.imul(D,tt),n=n+Math.imul(U,rt)|0,i=(i=i+Math.imul(U,nt)|0)+Math.imul(C,rt)|0,o=o+Math.imul(C,nt)|0,n=n+Math.imul(T,ot)|0,i=(i=i+Math.imul(T,st)|0)+Math.imul(L,ot)|0,o=o+Math.imul(L,st)|0,n=n+Math.imul(M,ut)|0,i=(i=i+Math.imul(M,ct)|0)+Math.imul(R,ut)|0,o=o+Math.imul(R,ct)|0,n=n+Math.imul(A,lt)|0,i=(i=i+Math.imul(A,ft)|0)+Math.imul(I,lt)|0,o=o+Math.imul(I,ft)|0;var Mt=(c+(n=n+Math.imul(E,pt)|0)|0)+((8191&(i=(i=i+Math.imul(E,yt)|0)+Math.imul(x,pt)|0))<<13)|0;c=((o=o+Math.imul(x,yt)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(z,rt),i=(i=Math.imul(z,nt))+Math.imul(D,rt)|0,o=Math.imul(D,nt),n=n+Math.imul(U,ot)|0,i=(i=i+Math.imul(U,st)|0)+Math.imul(C,ot)|0,o=o+Math.imul(C,st)|0,n=n+Math.imul(T,ut)|0,i=(i=i+Math.imul(T,ct)|0)+Math.imul(L,ut)|0,o=o+Math.imul(L,ct)|0,n=n+Math.imul(M,lt)|0,i=(i=i+Math.imul(M,ft)|0)+Math.imul(R,lt)|0,o=o+Math.imul(R,ft)|0;var Rt=(c+(n=n+Math.imul(A,pt)|0)|0)+((8191&(i=(i=i+Math.imul(A,yt)|0)+Math.imul(I,pt)|0))<<13)|0;c=((o=o+Math.imul(I,yt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,n=Math.imul(z,ot),i=(i=Math.imul(z,st))+Math.imul(D,ot)|0,o=Math.imul(D,st),n=n+Math.imul(U,ut)|0,i=(i=i+Math.imul(U,ct)|0)+Math.imul(C,ut)|0,o=o+Math.imul(C,ct)|0,n=n+Math.imul(T,lt)|0,i=(i=i+Math.imul(T,ft)|0)+Math.imul(L,lt)|0,o=o+Math.imul(L,ft)|0;var Pt=(c+(n=n+Math.imul(M,pt)|0)|0)+((8191&(i=(i=i+Math.imul(M,yt)|0)+Math.imul(R,pt)|0))<<13)|0;c=((o=o+Math.imul(R,yt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(z,ut),i=(i=Math.imul(z,ct))+Math.imul(D,ut)|0,o=Math.imul(D,ct),n=n+Math.imul(U,lt)|0,i=(i=i+Math.imul(U,ft)|0)+Math.imul(C,lt)|0,o=o+Math.imul(C,ft)|0;var Tt=(c+(n=n+Math.imul(T,pt)|0)|0)+((8191&(i=(i=i+Math.imul(T,yt)|0)+Math.imul(L,pt)|0))<<13)|0;c=((o=o+Math.imul(L,yt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(z,lt),i=(i=Math.imul(z,ft))+Math.imul(D,lt)|0,o=Math.imul(D,ft);var Lt=(c+(n=n+Math.imul(U,pt)|0)|0)+((8191&(i=(i=i+Math.imul(U,yt)|0)+Math.imul(C,pt)|0))<<13)|0;c=((o=o+Math.imul(C,yt)|0)+(i>>>13)|0)+(Lt>>>26)|0,Lt&=67108863;var Ot=(c+(n=Math.imul(z,pt))|0)+((8191&(i=(i=Math.imul(z,yt))+Math.imul(D,pt)|0))<<13)|0;return c=((o=Math.imul(D,yt))+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,u[0]=gt,u[1]=mt,u[2]=wt,u[3]=bt,u[4]=vt,u[5]=_t,u[6]=kt,u[7]=Et,u[8]=xt,u[9]=St,u[10]=At,u[11]=It,u[12]=Bt,u[13]=Mt,u[14]=Rt,u[15]=Pt,u[16]=Tt,u[17]=Lt,u[18]=Ot,0!==c&&(u[19]=c,r.length++),r};function g(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,o=0;o<r.length-1;o++){var s=i;i=0;for(var a=67108863&n,u=Math.min(o,e.length-1),c=Math.max(0,o-t.length+1);c<=u;c++){var h=o-c,l=(0|t.words[h])*(0|e.words[c]),f=67108863&l;a=67108863&(f=f+a|0),i+=(s=(s=s+(l/67108864|0)|0)+(f>>>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(t,e,r){return g(t,e,r)}Math.imul||(y=p),i.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?y(this,t,e):r<63?p(this,t,e):r<1024?g(this,t,e):m(this,t,e)},i.prototype.mul=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},i.prototype.mulf=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),m(this,t,e)},i.prototype.imul=function(t){return this.clone().mulTo(t,this)},i.prototype.imuln=function(t){var e=t<0;e&&(t=-t),r("number"==typeof t),r(t<67108864);for(var n=0,i=0;i<this.length;i++){var o=(0|this.words[i])*t,s=(67108863&o)+(67108863&n);n>>=26,n+=o/67108864|0,n+=s>>>26,this.words[i]=67108863&s}return 0!==n&&(this.words[i]=n,this.length++),e?this.ineg():this},i.prototype.muln=function(t){return this.clone().imuln(t)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var n=r/26|0,i=r%26;e[r]=t.words[n]>>>i&1}return e}(t);if(0===e.length)return new i(1);for(var r=this,n=0;n<e.length&&0===e[n];n++,r=r.sqr());if(++n<e.length)for(var o=r.sqr();n<e.length;n++,o=o.sqr())0!==e[n]&&(r=r.mul(o));return r},i.prototype.iushln=function(t){r("number"==typeof t&&t>=0);var e,n=t%26,i=(t-n)/26,o=67108863>>>26-n<<26-n;if(0!==n){var s=0;for(e=0;e<this.length;e++){var a=this.words[e]&o,u=(0|this.words[e])-a<<n;this.words[e]=u|s,s=a>>>26-n}s&&(this.words[e]=s,this.length++)}if(0!==i){for(e=this.length-1;e>=0;e--)this.words[e+i]=this.words[e];for(e=0;e<i;e++)this.words[e]=0;this.length+=i}return this._strip()},i.prototype.ishln=function(t){return r(0===this.negative),this.iushln(t)},i.prototype.iushrn=function(t,e,n){var i;r("number"==typeof t&&t>=0),i=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<<o,u=n;if(i-=s,i=Math.max(0,i),u){for(var c=0;c<s;c++)u.words[c]=this.words[c];u.length=s}if(0===s);else if(this.length>s)for(this.length-=s,c=0;c<this.length;c++)this.words[c]=this.words[c+s];else this.words[0]=0,this.length=1;var h=0;for(c=this.length-1;c>=0&&(0!==h||c>=i);c--){var l=0|this.words[c];this.words[c]=h<<26-o|l>>>o,h=l&a}return u&&0!==h&&(u.words[u.length++]=h),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.ishrn=function(t,e,n){return r(0===this.negative),this.iushrn(t,e,n)},i.prototype.shln=function(t){return this.clone().ishln(t)},i.prototype.ushln=function(t){return this.clone().iushln(t)},i.prototype.shrn=function(t){return this.clone().ishrn(t)},i.prototype.ushrn=function(t){return this.clone().iushrn(t)},i.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26,i=1<<e;return!(this.length<=n||!(this.words[n]&i))},i.prototype.imaskn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==e&&n++,this.length=Math.min(n,this.length),0!==e){var i=67108863^67108863>>>e<<e;this.words[this.length-1]&=i}return this._strip()},i.prototype.maskn=function(t){return this.clone().imaskn(t)},i.prototype.iaddn=function(t){return r("number"==typeof t),r(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},i.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},i.prototype.isubn=function(t){if(r("number"==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this._strip()},i.prototype.addn=function(t){return this.clone().iaddn(t)},i.prototype.subn=function(t){return this.clone().isubn(t)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(t,e,n){var i,o,s=t.length+n;this._expand(s);var a=0;for(i=0;i<t.length;i++){o=(0|this.words[i+n])+a;var u=(0|t.words[i])*e;a=((o-=67108863&u)>>26)-(u/67108864|0),this.words[i+n]=67108863&o}for(;i<this.length-n;i++)a=(o=(0|this.words[i+n])+a)>>26,this.words[i+n]=67108863&o;if(0===a)return this._strip();for(r(-1===a),a=0,i=0;i<this.length;i++)a=(o=-(0|this.words[i])+a)>>26,this.words[i]=67108863&o;return this.negative=1,this._strip()},i.prototype._wordDiv=function(t,e){var r=(this.length,t.length),n=this.clone(),o=t,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,u=n.length-o.length;if("mod"!==e){(a=new i(null)).length=u+1,a.words=new Array(a.length);for(var c=0;c<a.length;c++)a.words[c]=0}var h=n.clone()._ishlnsubmul(o,1,u);0===h.negative&&(n=h,a&&(a.words[u]=1));for(var l=u-1;l>=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"!==e&&0!==r&&n.iushrn(r),{div:a||null,mod:n}},i.prototype.divmod=function(t,e,n){return r(!t.isZero()),this.isZero()?{div:new i(0),mod:new i(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(o=a.div.neg()),"div"!==e&&(s=a.mod.neg(),n&&0!==s.negative&&s.iadd(t)),{div:o,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(o=a.div.neg()),{div:o,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),n&&0!==s.negative&&s.isub(t)),{div:a.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new i(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new i(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new i(this.modrn(t.words[0]))}:this._wordDiv(t,e);var o,s,a},i.prototype.div=function(t){return this.divmod(t,"div",!1).div},i.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},i.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},i.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,n=t.ushrn(1),i=t.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},i.prototype.modrn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var n=(1<<26)%t,i=0,o=this.length-1;o>=0;o--)i=(n*i+(0|this.words[o]))%t;return e?-i:i},i.prototype.modn=function(t){return this.modrn(t)},i.prototype.idivn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var n=0,i=this.length-1;i>=0;i--){var o=(0|this.words[i])+67108864*n;this.words[i]=o/t|0,n=o%t}return this._strip(),e?this.ineg():this},i.prototype.divn=function(t){return this.clone().idivn(t)},i.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o=new i(1),s=new i(0),a=new i(0),u=new i(1),c=0;e.isEven()&&n.isEven();)e.iushrn(1),n.iushrn(1),++c;for(var h=n.clone(),l=e.clone();!e.isZero();){for(var f=0,d=1;0==(e.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(e.iushrn(f);f-- >0;)(o.isOdd()||s.isOdd())&&(o.iadd(h),s.isub(l)),o.iushrn(1),s.iushrn(1);for(var p=0,y=1;0==(n.words[0]&y)&&p<26;++p,y<<=1);if(p>0)for(n.iushrn(p);p-- >0;)(a.isOdd()||u.isOdd())&&(a.iadd(h),u.isub(l)),a.iushrn(1),u.iushrn(1);e.cmp(n)>=0?(e.isub(n),o.isub(a),s.isub(u)):(n.isub(e),a.isub(o),u.isub(s))}return{a:a,b:u,gcd:n.iushln(c)}},i.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o,s=new i(1),a=new i(0),u=n.clone();e.cmpn(1)>0&&n.cmpn(1)>0;){for(var c=0,h=1;0==(e.words[0]&h)&&c<26;++c,h<<=1);if(c>0)for(e.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);for(var l=0,f=1;0==(n.words[0]&f)&&l<26;++l,f<<=1);if(l>0)for(n.iushrn(l);l-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);e.cmp(n)>=0?(e.isub(n),s.isub(a)):(n.isub(e),a.isub(s))}return(o=0===e.cmpn(1)?s:a).cmpn(0)<0&&o.iadd(t),o},i.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var n=0;e.isEven()&&r.isEven();n++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=e.cmp(r);if(i<0){var o=e;e=r,r=o}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.iushln(n)},i.prototype.invm=function(t){return this.egcd(t).a.umod(t)},i.prototype.isEven=function(){return 0==(1&this.words[0])},i.prototype.isOdd=function(){return 1==(1&this.words[0])},i.prototype.andln=function(t){return this.words[0]&t},i.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,n=(t-e)/26,i=1<<e;if(this.length<=n)return this._expand(n+1),this.words[n]|=i,this;for(var o=i,s=n;0!==o&&s<this.length;s++){var a=0|this.words[s];o=(a+=o)>>>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(t){var e,n=t<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this._strip(),this.length>1)e=1;else{n&&(t=-t),r(t<=67108863,"Number is too big");var i=0|this.words[0];e=i===t?0:i<t?-1:1}return 0!==this.negative?0|-e:e},i.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},i.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){n<i?e=-1:n>i&&(e=1);break}}return e},i.prototype.gtn=function(t){return 1===this.cmpn(t)},i.prototype.gt=function(t){return 1===this.cmp(t)},i.prototype.gten=function(t){return this.cmpn(t)>=0},i.prototype.gte=function(t){return this.cmp(t)>=0},i.prototype.ltn=function(t){return-1===this.cmpn(t)},i.prototype.lt=function(t){return-1===this.cmp(t)},i.prototype.lten=function(t){return this.cmpn(t)<=0},i.prototype.lte=function(t){return this.cmp(t)<=0},i.prototype.eqn=function(t){return 0===this.cmpn(t)},i.prototype.eq=function(t){return 0===this.cmp(t)},i.red=function(t){return new x(t)},i.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(t){return this.red=t,this},i.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},i.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},i.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},i.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},i.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},i.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},i.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},i.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},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(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var w={k256:null,p224:null,p192:null,p25519:null};function b(t,e){this.name=t,this.p=new i(e,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 k(){b.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function E(){b.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function x(t){if("string"==typeof t){var e=i._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function S(t){x.call(this,t),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 t=new i(null);return t.words=new Array(Math.ceil(this.n/13)),t},b.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e<this.n?-1:r.ucmp(this.p);return 0===n?(r.words[0]=0,r.length=1):n>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},b.prototype.split=function(t,e){t.iushrn(this.n,0,e)},b.prototype.imulK=function(t){return t.imul(this.k)},n(v,b),v.prototype.split=function(t,e){for(var r=4194303,n=Math.min(t.length,9),i=0;i<n;i++)e.words[i]=t.words[i];if(e.length=n,t.length<=9)return t.words[0]=0,void(t.length=1);var o=t.words[9];for(e.words[e.length++]=o&r,i=10;i<t.length;i++){var s=0|t.words[i];t.words[i-10]=(s&r)<<4|o>>>22,o=s}o>>>=22,t.words[i-10]=o,0===o&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var n=0|t.words[r];e+=977*n,t.words[r]=67108863&e,e=64*n+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},n(_,b),n(k,b),n(E,b),E.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var n=19*(0|t.words[r])+e,i=67108863&n;n>>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},i._prime=function(t){if(w[t])return w[t];var e;if("k256"===t)e=new v;else if("p224"===t)e=new _;else if("p192"===t)e=new k;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new E}return w[t]=e,e},x.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},x.prototype._verify2=function(t,e){r(0==(t.negative|e.negative),"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},x.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(c(t,t.umod(this.m)._forceRed(this)),t)},x.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},x.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},x.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},x.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},x.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},x.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},x.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},x.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},x.prototype.isqr=function(t){return this.imul(t,t.clone())},x.prototype.sqr=function(t){return this.mul(t,t)},x.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var n=this.m.add(new i(1)).iushrn(2);return this.pow(t,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),u=a.redNeg(),c=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new i(2*h*h).toRed(this);0!==this.pow(h,c).cmp(u);)h.redIAdd(u);for(var l=this.pow(h,o),f=this.pow(t,o.addn(1).iushrn(1)),d=this.pow(t,o),p=s;0!==d.cmp(a);){for(var y=d,g=0;0!==y.cmp(a);g++)y=y.redSqr();r(g<p);var m=this.pow(l,new i(1).iushln(p-g-1));f=f.redMul(m),l=m.redSqr(),d=d.redMul(l),p=g}return f},x.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},x.prototype.pow=function(t,e){if(e.isZero())return new i(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new i(1).toRed(this),r[1]=t;for(var n=2;n<r.length;n++)r[n]=this.mul(r[n-1],t);var o=r[0],s=0,a=0,u=e.bitLength()%26;for(0===u&&(u=26),n=e.length-1;n>=0;n--){for(var c=e.words[n],h=u-1;h>=0;h--){var l=c>>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}u=26}return o},x.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},x.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},i.mont=function(t){return new S(t)},n(S,x),S.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},S.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},S.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),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)},S.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new i(0)._forceRed(this);var r=t.mul(e),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)},S.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(0,Jv);var Wk=Dk.exports,Fk=Xv(Wk),Kk={exports:{}};!function(t,e){var r=t_,n=r.Buffer;function i(t,e){for(var r in t)e[r]=t[r]}function o(t,e,r){return n(t,e,r)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?t.exports=r:(i(r,e),e.Buffer=o),o.prototype=Object.create(n.prototype),i(n,o),o.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return n(t,e,r)},o.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var i=n(t);return void 0!==e?"string"==typeof r?i.fill(e,r):i.fill(e):i.fill(0),i},o.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n(t)},o.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return r.SlowBuffer(t)}}(Kk,Kk.exports);var Vk=Kk.exports.Buffer,qk=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r<e.length;r++)e[r]=255;for(var n=0;n<t.length;n++){var i=t.charAt(n),o=i.charCodeAt(0);if(255!==e[o])throw new TypeError(i+" is ambiguous");e[o]=n}var s=t.length,a=t.charAt(0),u=Math.log(s)/Math.log(256),c=Math.log(256)/Math.log(s);function h(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return Vk.alloc(0);for(var r=0,n=0,i=0;t[r]===a;)n++,r++;for(var o=(t.length-r)*u+1>>>0,c=new Uint8Array(o);t[r];){var h=e[t.charCodeAt(r)];if(255===h)return;for(var l=0,f=o-1;(0!==h||l<i)&&-1!==f;f--,l++)h+=s*c[f]>>>0,c[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===c[d];)d++;var p=Vk.allocUnsafe(n+(o-d));p.fill(0,0,n);for(var y=n;d!==o;)p[y++]=c[d++];return p}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=Vk.from(e)),!Vk.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,n=0,i=0,o=e.length;i!==o&&0===e[i];)i++,r++;for(var u=(o-i)*c+1>>>0,h=new Uint8Array(u);i!==o;){for(var l=e[i],f=0,d=u-1;(0!==l||f<n)&&-1!==d;d--,f++)l+=256*h[d]>>>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=u-n;p!==u&&0===h[p];)p++;for(var y=a.repeat(r);p<u;++p)y+=t.charAt(h[p]);return y},decodeUnsafe:h,decode:function(t){var e=h(t);if(e)return e;throw new Error("Non-base"+s+" character")}}}("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),Hk=Xv(qk);const $k=(t,e,r)=>t&e^t&r^e&r,Gk=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]),Zk=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Yk=new Uint32Array(64);class Jk extends __{constructor(){super(64,32,8,!1),this.A=0|Zk[0],this.B=0|Zk[1],this.C=0|Zk[2],this.D=0|Zk[3],this.E=0|Zk[4],this.F=0|Zk[5],this.G=0|Zk[6],this.H=0|Zk[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:o,G:s,H:a}=this;return[t,e,r,n,i,o,s,a]}set(t,e,r,n,i,o,s,a){this.A=0|t,this.B=0|e,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(t,e){for(let r=0;r<16;r++,e+=4)Yk[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=Yk[t-15],r=Yk[t-2],n=g_(e,7)^g_(e,18)^e>>>3,i=g_(r,17)^g_(r,19)^r>>>10;Yk[t]=i+Yk[t-7]+n+Yk[t-16]|0}let{A:r,B:n,C:i,D:o,E:s,F:a,G:u,H:c}=this;for(let t=0;t<64;t++){const e=c+(g_(s,6)^g_(s,11)^g_(s,25))+((h=s)&a^~h&u)+Gk[t]+Yk[t]|0,l=(g_(r,2)^g_(r,13)^g_(r,22))+$k(r,n,i)|0;c=u,u=a,a=s,s=o+e|0,o=i,i=n,n=r,r=e+l|0}var h;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,u=u+this.G|0,c=c+this.H|0,this.set(r,n,i,o,s,a,u,c)}roundClean(){Yk.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Xk=b_((()=>new Jk));var Qk={};function tE(t,e,r){return e<=t&&t<=r}function eE(t){if(void 0===t)return{};if(t===Object(t))return t;throw TypeError("Could not convert argument to dictionary")}function rE(t){this.tokens=[].slice.call(t)}rE.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():-1},prepend:function(t){if(Array.isArray(t))for(var e=t;e.length;)this.tokens.unshift(e.pop());else this.tokens.unshift(t)},push:function(t){if(Array.isArray(t))for(var e=t;e.length;)this.tokens.push(e.shift());else this.tokens.push(t)}};var nE=-1;function iE(t,e){if(t)throw TypeError("Decoder error");return e||65533}var oE="utf-8";function sE(t,e){if(!(this instanceof sE))return new sE(t,e);if((t=void 0!==t?String(t).toLowerCase():oE)!==oE)throw new Error("Encoding not supported. Only utf-8 is supported");e=eE(e),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=Boolean(e.fatal),this._ignoreBOM=Boolean(e.ignoreBOM),Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}function aE(t,e){if(!(this instanceof aE))return new aE(t,e);if((t=void 0!==t?String(t).toLowerCase():oE)!==oE)throw new Error("Encoding not supported. Only utf-8 is supported");e=eE(e),this._streaming=!1,this._encoder=null,this._options={fatal:Boolean(e.fatal)},Object.defineProperty(this,"encoding",{value:"utf-8"})}function uE(t){var e=t.fatal,r=0,n=0,i=0,o=128,s=191;this.handler=function(t,a){if(-1===a&&0!==i)return i=0,iE(e);if(-1===a)return nE;if(0===i){if(tE(a,0,127))return a;if(tE(a,194,223))i=1,r=a-192;else if(tE(a,224,239))224===a&&(o=160),237===a&&(s=159),i=2,r=a-224;else{if(!tE(a,240,244))return iE(e);240===a&&(o=144),244===a&&(s=143),i=3,r=a-240}return r<<=6*i,null}if(!tE(a,o,s))return r=i=n=0,o=128,s=191,t.prepend(a),iE(e);if(o=128,s=191,r+=a-128<<6*(i-(n+=1)),n!==i)return null;var u=r;return r=i=n=0,u}}function cE(t){t.fatal,this.handler=function(t,e){if(-1===e)return nE;if(tE(e,0,127))return e;var r,n;tE(e,128,2047)?(r=1,n=192):tE(e,2048,65535)?(r=2,n=224):tE(e,65536,1114111)&&(r=3,n=240);for(var i=[(e>>6*r)+n];r>0;){var o=e>>6*(r-1);i.push(128|63&o),r-=1}return i}}sE.prototype={decode:function(t,e){var r;r="object"==typeof t&&t instanceof ArrayBuffer?new Uint8Array(t):"object"==typeof t&&"buffer"in t&&t.buffer instanceof ArrayBuffer?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(0),e=eE(e),this._streaming||(this._decoder=new uE({fatal:this._fatal}),this._BOMseen=!1),this._streaming=Boolean(e.stream);for(var n,i=new rE(r),o=[];!i.endOfStream()&&(n=this._decoder.handler(i,i.read()))!==nE;)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()))===nE)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(t){for(var e="",r=0;r<t.length;++r){var n=t[r];n<=65535?e+=String.fromCharCode(n):(n-=65536,e+=String.fromCharCode(55296+(n>>10),56320+(1023&n)))}return e}(o)}},aE.prototype={encode:function(t,e){t=t?String(t):"",e=eE(e),this._streaming||(this._encoder=new cE(this._options)),this._streaming=Boolean(e.stream);for(var r,n=[],i=new rE(function(t){for(var e=String(t),r=e.length,n=0,i=[];n<r;){var o=e.charCodeAt(n);if(o<55296||o>57343)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=t.charCodeAt(n+1);if(56320<=s&&s<=57343){var a=1023&o,u=1023&s;i.push(65536+(a<<10)+u),n+=1}else i.push(65533)}n+=1}return i}(t));!i.endOfStream()&&(r=this._encoder.handler(i,i.read()))!==nE;)Array.isArray(r)?n.push.apply(n,r):n.push(r);if(!this._streaming){for(;(r=this._encoder.handler(i,i.read()))!==nE;)Array.isArray(r)?n.push.apply(n,r):n.push(r);this._encoder=null}return new Uint8Array(n)}};var hE=Qv(Object.freeze({__proto__:null,TextEncoder:aE,TextDecoder:sE})),lE=Jv&&Jv.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),fE=Jv&&Jv.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),dE=Jv&&Jv.__decorate||function(t,e,r,n){var i,o=arguments.length,s=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s},pE=Jv&&Jv.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)"default"!==r&&Object.hasOwnProperty.call(t,r)&&lE(e,t,r);return fE(e,t),e},yE=Jv&&Jv.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Qk,"__esModule",{value:!0});var gE=Qk.deserializeUnchecked=TE=Qk.deserialize=ME=Qk.serialize=Qk.BinaryReader=Qk.BinaryWriter=Qk.BorshError=Qk.baseDecode=Qk.baseEncode=void 0;const mE=yE(Wk),wE=yE(qk),bE=pE(hE),vE=new("function"!=typeof TextDecoder?bE.TextDecoder:TextDecoder)("utf-8",{fatal:!0});Qk.baseEncode=function(t){return"string"==typeof t&&(t=Buffer.from(t,"utf8")),wE.default.encode(Buffer.from(t))},Qk.baseDecode=function(t){return Buffer.from(wE.default.decode(t))};const _E=1024;class kE extends Error{constructor(t){super(t),this.fieldPath=[],this.originalMessage=t}addToFieldPath(t){this.fieldPath.splice(0,0,t),this.message=this.originalMessage+": "+this.fieldPath.join(".")}}Qk.BorshError=kE;class EE{constructor(){this.buf=Buffer.alloc(_E),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(_E)]))}writeU8(t){this.maybeResize(),this.buf.writeUInt8(t,this.length),this.length+=1}writeU16(t){this.maybeResize(),this.buf.writeUInt16LE(t,this.length),this.length+=2}writeU32(t){this.maybeResize(),this.buf.writeUInt32LE(t,this.length),this.length+=4}writeU64(t){this.maybeResize(),this.writeBuffer(Buffer.from(new mE.default(t).toArray("le",8)))}writeU128(t){this.maybeResize(),this.writeBuffer(Buffer.from(new mE.default(t).toArray("le",16)))}writeU256(t){this.maybeResize(),this.writeBuffer(Buffer.from(new mE.default(t).toArray("le",32)))}writeU512(t){this.maybeResize(),this.writeBuffer(Buffer.from(new mE.default(t).toArray("le",64)))}writeBuffer(t){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),t,Buffer.alloc(_E)]),this.length+=t.length}writeString(t){this.maybeResize();const e=Buffer.from(t,"utf8");this.writeU32(e.length),this.writeBuffer(e)}writeFixedArray(t){this.writeBuffer(Buffer.from(t))}writeArray(t,e){this.maybeResize(),this.writeU32(t.length);for(const r of t)this.maybeResize(),e(r)}toArray(){return this.buf.subarray(0,this.length)}}function xE(t,e,r){const n=r.value;r.value=function(...t){try{return n.apply(this,t)}catch(t){if(t instanceof RangeError){const e=t.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(e)>=0)throw new kE("Reached the end of buffer when deserializing")}throw t}}}Qk.BinaryWriter=EE;class SE{constructor(t){this.buf=t,this.offset=0}readU8(){const t=this.buf.readUInt8(this.offset);return this.offset+=1,t}readU16(){const t=this.buf.readUInt16LE(this.offset);return this.offset+=2,t}readU32(){const t=this.buf.readUInt32LE(this.offset);return this.offset+=4,t}readU64(){const t=this.readBuffer(8);return new mE.default(t,"le")}readU128(){const t=this.readBuffer(16);return new mE.default(t,"le")}readU256(){const t=this.readBuffer(32);return new mE.default(t,"le")}readU512(){const t=this.readBuffer(64);return new mE.default(t,"le")}readBuffer(t){if(this.offset+t>this.buf.length)throw new kE(`Expected buffer length ${t} isn't within bounds`);const e=this.buf.slice(this.offset,this.offset+t);return this.offset+=t,e}readString(){const t=this.readU32(),e=this.readBuffer(t);try{return vE.decode(e)}catch(t){throw new kE(`Error decoding UTF-8 string: ${t}`)}}readFixedArray(t){return new Uint8Array(this.readBuffer(t))}readArray(t){const e=this.readU32(),r=Array();for(let n=0;n<e;++n)r.push(t());return r}}function AE(t){return t.charAt(0).toUpperCase()+t.slice(1)}function IE(t,e,r,n,i){try{if("string"==typeof n)i[`write${AE(n)}`](r);else if(n instanceof Array)if("number"==typeof n[0]){if(r.length!==n[0])throw new kE(`Expecting byte array of length ${n[0]}, but got ${r.length} bytes`);i.writeFixedArray(r)}else if(2===n.length&&"number"==typeof n[1]){if(r.length!==n[1])throw new kE(`Expecting byte array of length ${n[1]}, but got ${r.length} bytes`);for(let e=0;e<n[1];e++)IE(t,null,r[e],n[0],i)}else i.writeArray(r,(r=>{IE(t,e,r,n[0],i)}));else if(void 0!==n.kind)switch(n.kind){case"option":null==r?i.writeU8(0):(i.writeU8(1),IE(t,e,r,n.type,i));break;case"map":i.writeU32(r.size),r.forEach(((r,o)=>{IE(t,e,o,n.key,i),IE(t,e,r,n.value,i)}));break;default:throw new kE(`FieldType ${n} unrecognized`)}else BE(t,r,i)}catch(t){throw t instanceof kE&&t.addToFieldPath(e),t}}function BE(t,e,r){if("function"==typeof e.borshSerialize)return void e.borshSerialize(r);const n=t.get(e.constructor);if(!n)throw new kE(`Class ${e.constructor.name} is missing in schema`);if("struct"===n.kind)n.fields.map((([n,i])=>{IE(t,n,e[n],i,r)}));else{if("enum"!==n.kind)throw new kE(`Unexpected schema kind: ${n.kind} for ${e.constructor.name}`);{const i=e[n.field];for(let o=0;o<n.values.length;++o){const[s,a]=n.values[o];if(s===i){r.writeU8(o),IE(t,s,e[s],a,r);break}}}}}dE([xE],SE.prototype,"readU8",null),dE([xE],SE.prototype,"readU16",null),dE([xE],SE.prototype,"readU32",null),dE([xE],SE.prototype,"readU64",null),dE([xE],SE.prototype,"readU128",null),dE([xE],SE.prototype,"readU256",null),dE([xE],SE.prototype,"readU512",null),dE([xE],SE.prototype,"readString",null),dE([xE],SE.prototype,"readFixedArray",null),dE([xE],SE.prototype,"readArray",null),Qk.BinaryReader=SE;var ME=Qk.serialize=function(t,e,r=EE){const n=new r;return BE(t,e,n),n.toArray()};function RE(t,e,r,n){try{if("string"==typeof r)return n[`read${AE(r)}`]();if(r instanceof Array){if("number"==typeof r[0])return n.readFixedArray(r[0]);if("number"==typeof r[1]){const e=[];for(let i=0;i<r[1];i++)e.push(RE(t,null,r[0],n));return e}return n.readArray((()=>RE(t,e,r[0],n)))}if("option"===r.kind)return n.readU8()?RE(t,e,r.type,n):void 0;if("map"===r.kind){let i=new Map;const o=n.readU32();for(let s=0;s<o;s++){const o=RE(t,e,r.key,n),s=RE(t,e,r.value,n);i.set(o,s)}return i}return PE(t,r,n)}catch(t){throw t instanceof kE&&t.addToFieldPath(e),t}}function PE(t,e,r){if("function"==typeof e.borshDeserialize)return e.borshDeserialize(r);const n=t.get(e);if(!n)throw new kE(`Class ${e.name} is missing in schema`);if("struct"===n.kind){const n={};for(const[i,o]of t.get(e).fields)n[i]=RE(t,i,o,r);return new e(n)}if("enum"===n.kind){const i=r.readU8();if(i>=n.values.length)throw new kE(`Enum index: ${i} is out of range`);const[o,s]=n.values[i];return new e({[o]:RE(t,o,s,r)})}throw new kE(`Unexpected schema kind: ${n.kind} for ${e.constructor.name}`)}var TE=Qk.deserialize=function(t,e,r,n=SE){const i=new n(r),o=PE(t,e,i);if(i.offset<r.length)throw new kE(`Unexpected ${r.length-i.offset} bytes after deserialized data`);return o};gE=Qk.deserializeUnchecked=function(t,e,r,n=SE){return PE(t,e,new n(r))};var LE={};Object.defineProperty(LE,"__esModule",{value:!0}),LE.s16=LE.s8=LE.nu64be=LE.u48be=LE.u40be=LE.u32be=LE.u24be=LE.u16be=_x=LE.nu64=LE.u48=LE.u40=vx=LE.u32=LE.u24=bx=LE.u16=wx=LE.u8=mx=LE.offset=LE.greedy=LE.Constant=LE.UTF8=LE.CString=LE.Blob=LE.Boolean=LE.BitField=LE.BitStructure=LE.VariantLayout=LE.Union=LE.UnionLayoutDiscriminator=LE.UnionDiscriminator=LE.Structure=LE.Sequence=LE.DoubleBE=LE.Double=LE.FloatBE=LE.Float=LE.NearInt64BE=LE.NearInt64=LE.NearUInt64BE=LE.NearUInt64=LE.IntBE=LE.Int=LE.UIntBE=LE.UInt=LE.OffsetLayout=LE.GreedyCount=LE.ExternalLayout=LE.bindConstructorLayout=LE.nameWithProperty=LE.Layout=LE.uint8ArrayToBuffer=LE.checkUint8Array=void 0,LE.constant=LE.utf8=LE.cstr=Sx=LE.blob=LE.unionLayoutDiscriminator=LE.union=xx=LE.seq=LE.bits=Ex=LE.struct=LE.f64be=LE.f64=LE.f32be=LE.f32=LE.ns64be=LE.s48be=LE.s40be=LE.s32be=LE.s24be=LE.s16be=kx=LE.ns64=LE.s48=LE.s40=LE.s32=LE.s24=void 0;const OE=t_;function UE(t){if(!(t instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}function CE(t){return UE(t),OE.Buffer.from(t.buffer,t.byteOffset,t.length)}LE.checkUint8Array=UE,LE.uint8ArrayToBuffer=CE;class NE{constructor(t,e){if(!Number.isInteger(t))throw new TypeError("span must be an integer");this.span=t,this.property=e}makeDestinationObject(){return{}}getSpan(t,e){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(t){const e=Object.create(this.constructor.prototype);return Object.assign(e,this),e.property=t,e}fromArray(t){}}function zE(t,e){return e.property?t+"["+e.property+"]":t}LE.Layout=NE,LE.nameWithProperty=zE,LE.bindConstructorLayout=function(t,e){if("function"!=typeof t)throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(t,"layout_"))throw new Error("Class is already bound to a layout");if(!(e&&e instanceof NE))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(e,"boundConstructor_"))throw new Error("layout is already bound to a constructor");t.layout_=e,e.boundConstructor_=t,e.makeDestinationObject=()=>new t,Object.defineProperty(t.prototype,"encode",{value(t,r){return e.encode(this,t,r)},writable:!0}),Object.defineProperty(t,"decode",{value:(t,r)=>e.decode(t,r),writable:!0})};class DE extends NE{isCount(){throw new Error("ExternalLayout is abstract")}}LE.ExternalLayout=DE;class jE extends DE{constructor(t=1,e){if(!Number.isInteger(t)||0>=t)throw new TypeError("elementSpan must be a (positive) integer");super(-1,e),this.elementSpan=t}isCount(){return!0}decode(t,e=0){UE(t);const r=t.length-e;return Math.floor(r/this.elementSpan)}encode(t,e,r){return 0}}LE.GreedyCount=jE;class WE extends DE{constructor(t,e=0,r){if(!(t instanceof NE))throw new TypeError("layout must be a Layout");if(!Number.isInteger(e))throw new TypeError("offset must be integer or undefined");super(t.span,r||t.property),this.layout=t,this.offset=e}isCount(){return this.layout instanceof FE||this.layout instanceof KE}decode(t,e=0){return this.layout.decode(t,e+this.offset)}encode(t,e,r=0){return this.layout.encode(t,e,r+this.offset)}}LE.OffsetLayout=WE;class FE extends NE{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return CE(t).readUIntLE(e,this.span)}encode(t,e,r=0){return CE(e).writeUIntLE(t,r,this.span),this.span}}LE.UInt=FE;class KE extends NE{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return CE(t).readUIntBE(e,this.span)}encode(t,e,r=0){return CE(e).writeUIntBE(t,r,this.span),this.span}}LE.UIntBE=KE;class VE extends NE{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return CE(t).readIntLE(e,this.span)}encode(t,e,r=0){return CE(e).writeIntLE(t,r,this.span),this.span}}LE.Int=VE;class qE extends NE{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return CE(t).readIntBE(e,this.span)}encode(t,e,r=0){return CE(e).writeIntBE(t,r,this.span),this.span}}LE.IntBE=qE;const HE=Math.pow(2,32);function $E(t){const e=Math.floor(t/HE);return{hi32:e,lo32:t-e*HE}}function GE(t,e){return t*HE+e}class ZE extends NE{constructor(t){super(8,t)}decode(t,e=0){const r=CE(t),n=r.readUInt32LE(e);return GE(r.readUInt32LE(e+4),n)}encode(t,e,r=0){const n=$E(t),i=CE(e);return i.writeUInt32LE(n.lo32,r),i.writeUInt32LE(n.hi32,r+4),8}}LE.NearUInt64=ZE;class YE extends NE{constructor(t){super(8,t)}decode(t,e=0){const r=CE(t);return GE(r.readUInt32BE(e),r.readUInt32BE(e+4))}encode(t,e,r=0){const n=$E(t),i=CE(e);return i.writeUInt32BE(n.hi32,r),i.writeUInt32BE(n.lo32,r+4),8}}LE.NearUInt64BE=YE;class JE extends NE{constructor(t){super(8,t)}decode(t,e=0){const r=CE(t),n=r.readUInt32LE(e);return GE(r.readInt32LE(e+4),n)}encode(t,e,r=0){const n=$E(t),i=CE(e);return i.writeUInt32LE(n.lo32,r),i.writeInt32LE(n.hi32,r+4),8}}LE.NearInt64=JE;class XE extends NE{constructor(t){super(8,t)}decode(t,e=0){const r=CE(t);return GE(r.readInt32BE(e),r.readUInt32BE(e+4))}encode(t,e,r=0){const n=$E(t),i=CE(e);return i.writeInt32BE(n.hi32,r),i.writeUInt32BE(n.lo32,r+4),8}}LE.NearInt64BE=XE;class QE extends NE{constructor(t){super(4,t)}decode(t,e=0){return CE(t).readFloatLE(e)}encode(t,e,r=0){return CE(e).writeFloatLE(t,r),4}}LE.Float=QE;class tx extends NE{constructor(t){super(4,t)}decode(t,e=0){return CE(t).readFloatBE(e)}encode(t,e,r=0){return CE(e).writeFloatBE(t,r),4}}LE.FloatBE=tx;class ex extends NE{constructor(t){super(8,t)}decode(t,e=0){return CE(t).readDoubleLE(e)}encode(t,e,r=0){return CE(e).writeDoubleLE(t,r),8}}LE.Double=ex;class rx extends NE{constructor(t){super(8,t)}decode(t,e=0){return CE(t).readDoubleBE(e)}encode(t,e,r=0){return CE(e).writeDoubleBE(t,r),8}}LE.DoubleBE=rx;class nx extends NE{constructor(t,e,r){if(!(t instanceof NE))throw new TypeError("elementLayout must be a Layout");if(!(e instanceof DE&&e.isCount()||Number.isInteger(e)&&0<=e))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let n=-1;!(e instanceof DE)&&0<t.span&&(n=e*t.span),super(n,r),this.elementLayout=t,this.count=e}getSpan(t,e=0){if(0<=this.span)return this.span;let r=0,n=this.count;if(n instanceof DE&&(n=n.decode(t,e)),0<this.elementLayout.span)r=n*this.elementLayout.span;else{let i=0;for(;i<n;)r+=this.elementLayout.getSpan(t,e+r),++i}return r}decode(t,e=0){const r=[];let n=0,i=this.count;for(i instanceof DE&&(i=i.decode(t,e));n<i;)r.push(this.elementLayout.decode(t,e)),e+=this.elementLayout.getSpan(t,e),n+=1;return r}encode(t,e,r=0){const n=this.elementLayout,i=t.reduce(((t,i)=>t+n.encode(i,e,r+t)),0);return this.count instanceof DE&&this.count.encode(t.length,e,r),i}}LE.Sequence=nx;class ix extends NE{constructor(t,e,r){if(!Array.isArray(t)||!t.reduce(((t,e)=>t&&e instanceof NE),!0))throw new TypeError("fields must be array of Layout instances");"boolean"==typeof e&&void 0===r&&(r=e,e=void 0);for(const e of t)if(0>e.span&&void 0===e.property)throw new Error("fields cannot contain unnamed variable-length layout");let n=-1;try{n=t.reduce(((t,e)=>t+e.getSpan()),0)}catch(t){}super(n,e),this.fields=t,this.decodePrefixes=!!r}getSpan(t,e=0){if(0<=this.span)return this.span;let r=0;try{r=this.fields.reduce(((r,n)=>{const i=n.getSpan(t,e);return e+=i,r+i}),0)}catch(t){throw new RangeError("indeterminate span")}return r}decode(t,e=0){UE(t);const r=this.makeDestinationObject();for(const n of this.fields)if(void 0!==n.property&&(r[n.property]=n.decode(t,e)),e+=n.getSpan(t,e),this.decodePrefixes&&t.length===e)break;return r}encode(t,e,r=0){const n=r;let i=0,o=0;for(const n of this.fields){let s=n.span;if(o=0<s?s:0,void 0!==n.property){const i=t[n.property];void 0!==i&&(o=n.encode(i,e,r),0>s&&(s=n.getSpan(e,r)))}i=r,r+=s}return i+o-n}fromArray(t){const e=this.makeDestinationObject();for(const r of this.fields)void 0!==r.property&&0<t.length&&(e[r.property]=t.shift());return e}layoutFor(t){if("string"!=typeof t)throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}offsetOf(t){if("string"!=typeof t)throw new TypeError("property must be string");let e=0;for(const r of this.fields){if(r.property===t)return e;0>r.span?e=-1:0<=e&&(e+=r.span)}}}LE.Structure=ix;class ox{constructor(t){this.property=t}decode(t,e){throw new Error("UnionDiscriminator is abstract")}encode(t,e,r){throw new Error("UnionDiscriminator is abstract")}}LE.UnionDiscriminator=ox;class sx extends ox{constructor(t,e){if(!(t instanceof DE&&t.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(e||t.property||"variant"),this.layout=t}decode(t,e){return this.layout.decode(t,e)}encode(t,e,r){return this.layout.encode(t,e,r)}}LE.UnionLayoutDiscriminator=sx;class ax extends NE{constructor(t,e,r){let n;if(t instanceof FE||t instanceof KE)n=new sx(new WE(t));else if(t instanceof DE&&t.isCount())n=new sx(t);else{if(!(t instanceof ox))throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");n=t}if(void 0===e&&(e=null),!(null===e||e instanceof NE))throw new TypeError("defaultLayout must be null or a Layout");if(null!==e){if(0>e.span)throw new Error("defaultLayout must have constant span");void 0===e.property&&(e=e.replicate("content"))}let i=-1;e&&(i=e.span,0<=i&&(t instanceof FE||t instanceof KE)&&(i+=n.layout.span)),super(i,r),this.discriminator=n,this.usesPrefixDiscriminator=t instanceof FE||t instanceof KE,this.defaultLayout=e,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(t){return o(t)},this.configGetSourceVariant=function(t){o=t.bind(this)}}getSpan(t,e=0){if(0<=this.span)return this.span;const r=this.getVariant(t,e);if(!r)throw new Error("unable to determine span for unrecognized variant");return r.getSpan(t,e)}defaultGetSourceVariant(t){if(Object.prototype.hasOwnProperty.call(t,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(t,this.defaultLayout.property))return;const e=this.registry[t[this.discriminator.property]];if(e&&(!e.layout||e.property&&Object.prototype.hasOwnProperty.call(t,e.property)))return e}else for(const e in this.registry){const r=this.registry[e];if(r.property&&Object.prototype.hasOwnProperty.call(t,r.property))return r}throw new Error("unable to infer src variant")}decode(t,e=0){let r;const n=this.discriminator,i=n.decode(t,e),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(t,e+s)}else r=o.decode(t,e);return r}encode(t,e,r=0){const n=this.getSourceVariant(t);if(void 0===n){const n=this.discriminator,i=this.defaultLayout;let o=0;return this.usesPrefixDiscriminator&&(o=n.layout.span),n.encode(t[n.property],e,r),o+i.encode(t[i.property],e,r+o)}return n.encode(t,e,r)}addVariant(t,e,r){const n=new ux(this,t,e,r);return this.registry[t]=n,n}getVariant(t,e=0){let r;return r=t instanceof Uint8Array?this.discriminator.decode(t,e):t,this.registry[r]}}LE.Union=ax;class ux extends NE{constructor(t,e,r,n){if(!(t instanceof ax))throw new TypeError("union must be a Union");if(!Number.isInteger(e)||0>e)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 NE))throw new TypeError("layout must be a Layout");if(null!==t.defaultLayout&&0<=r.span&&r.span>t.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=t.span;0>t.span&&(i=r?r.span:0,0<=i&&t.usesPrefixDiscriminator&&(i+=t.discriminator.layout.span)),super(i,n),this.union=t,this.variant=e,this.layout=r||null}getSpan(t,e=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(t,e+r)),r+n}decode(t,e=0){const r=this.makeDestinationObject();if(this!==this.union.getVariant(t,e))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(t,e+n):this.property?r[this.property]=!0:this.union.usesPrefixDiscriminator&&(r[this.union.discriminator.property]=this.variant),r}encode(t,e,r=0){let n=0;if(this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(t,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,e,r);let i=n;if(this.layout&&(this.layout.encode(t[this.property],e,r+n),i+=this.layout.getSpan(e,r+n),0<=this.union.span&&i>this.union.span))throw new Error("encoded variant overruns containing union");return i}fromArray(t){if(this.layout)return this.layout.fromArray(t)}}function cx(t){return 0>t&&(t+=4294967296),t}LE.VariantLayout=ux;class hx extends NE{constructor(t,e,r){if(!(t instanceof FE||t instanceof KE))throw new TypeError("word must be a UInt or UIntBE layout");if("string"==typeof e&&void 0===r&&(r=e,e=!1),4<t.span)throw new RangeError("word cannot exceed 32 bits");super(t.span,r),this.word=t,this.msb=!!e,this.fields=[];let n=0;this._packedSetValue=function(t){return n=cx(t),this},this._packedGetValue=function(){return n}}decode(t,e=0){const r=this.makeDestinationObject(),n=this.word.decode(t,e);this._packedSetValue(n);for(const e of this.fields)void 0!==e.property&&(r[e.property]=e.decode(t));return r}encode(t,e,r=0){const n=this.word.decode(e,r);this._packedSetValue(n);for(const e of this.fields)if(void 0!==e.property){const r=t[e.property];void 0!==r&&e.encode(r)}return this.word.encode(this._packedGetValue(),e,r)}addField(t,e){const r=new lx(this,t,e);return this.fields.push(r),r}addBoolean(t){const e=new fx(this,t);return this.fields.push(e),e}fieldFor(t){if("string"!=typeof t)throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}}LE.BitStructure=hx;class lx{constructor(t,e,r){if(!(t instanceof hx))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(e)||0>=e)throw new TypeError("bits must be positive integer");const n=8*t.span,i=t.fields.reduce(((t,e)=>t+e.bits),0);if(e+i>n)throw new Error("bits too long for span remainder ("+(n-i)+" of "+n+" remain)");this.container=t,this.bits=e,this.valueMask=(1<<e)-1,32===e&&(this.valueMask=4294967295),this.start=i,this.container.msb&&(this.start=n-i-e),this.wordMask=cx(this.valueMask<<this.start),this.property=r}decode(t,e){return cx(this.container._packedGetValue()&this.wordMask)>>>this.start}encode(t){if("number"!=typeof t||!Number.isInteger(t)||t!==cx(t&this.valueMask))throw new TypeError(zE("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const e=this.container._packedGetValue(),r=cx(t<<this.start);this.container._packedSetValue(cx(e&~this.wordMask)|r)}}LE.BitField=lx;class fx extends lx{constructor(t,e){super(t,1,e)}decode(t,e){return!!super.decode(t,e)}encode(t){"boolean"==typeof t&&(t=+t),super.encode(t)}}LE.Boolean=fx;class dx extends NE{constructor(t,e){if(!(t instanceof DE&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let r=-1;t instanceof DE||(r=t),super(r,e),this.length=t}getSpan(t,e){let r=this.span;return 0>r&&(r=this.length.decode(t,e)),r}decode(t,e=0){let r=this.span;return 0>r&&(r=this.length.decode(t,e)),CE(t).slice(e,e+r)}encode(t,e,r){let n=this.length;if(this.length instanceof DE&&(n=t.length),!(t instanceof Uint8Array&&n===t.length))throw new TypeError(zE("Blob.encode",this)+" requires (length "+n+") Uint8Array as src");if(r+n>e.length)throw new RangeError("encoding overruns Uint8Array");const i=CE(t);return CE(e).write(i.toString("hex"),r,n,"hex"),this.length instanceof DE&&this.length.encode(n,e,r),n}}LE.Blob=dx;class px extends NE{constructor(t){super(-1,t)}getSpan(t,e=0){UE(t);let r=e;for(;r<t.length&&0!==t[r];)r+=1;return 1+r-e}decode(t,e=0){const r=this.getSpan(t,e);return CE(t).slice(e,e+r-1).toString("utf-8")}encode(t,e,r=0){"string"!=typeof t&&(t=String(t));const n=OE.Buffer.from(t,"utf8"),i=n.length;if(r+i>e.length)throw new RangeError("encoding overruns Buffer");const o=CE(e);return n.copy(o,r),o[r+i]=0,i+1}}LE.CString=px;class yx extends NE{constructor(t,e){if("string"==typeof t&&void 0===e&&(e=t,t=void 0),void 0===t)t=-1;else if(!Number.isInteger(t))throw new TypeError("maxSpan must be an integer");super(-1,e),this.maxSpan=t}getSpan(t,e=0){return UE(t),t.length-e}decode(t,e=0){const r=this.getSpan(t,e);if(0<=this.maxSpan&&this.maxSpan<r)throw new RangeError("text length exceeds maxSpan");return CE(t).slice(e,e+r).toString("utf-8")}encode(t,e,r=0){"string"!=typeof t&&(t=String(t));const n=OE.Buffer.from(t,"utf8"),i=n.length;if(0<=this.maxSpan&&this.maxSpan<i)throw new RangeError("text length exceeds maxSpan");if(r+i>e.length)throw new RangeError("encoding overruns Buffer");return n.copy(CE(e),r),i}}LE.UTF8=yx;class gx extends NE{constructor(t,e){super(0,e),this.value=t}decode(t,e){return this.value}encode(t,e,r){return 0}}LE.Constant=gx,LE.greedy=(t,e)=>new jE(t,e);var mx=LE.offset=(t,e,r)=>new WE(t,e,r),wx=LE.u8=t=>new FE(1,t),bx=LE.u16=t=>new FE(2,t);LE.u24=t=>new FE(3,t);var vx=LE.u32=t=>new FE(4,t);LE.u40=t=>new FE(5,t),LE.u48=t=>new FE(6,t);var _x=LE.nu64=t=>new ZE(t);LE.u16be=t=>new KE(2,t),LE.u24be=t=>new KE(3,t),LE.u32be=t=>new KE(4,t),LE.u40be=t=>new KE(5,t),LE.u48be=t=>new KE(6,t),LE.nu64be=t=>new YE(t),LE.s8=t=>new VE(1,t),LE.s16=t=>new VE(2,t),LE.s24=t=>new VE(3,t),LE.s32=t=>new VE(4,t),LE.s40=t=>new VE(5,t),LE.s48=t=>new VE(6,t);var kx=LE.ns64=t=>new JE(t);LE.s16be=t=>new qE(2,t),LE.s24be=t=>new qE(3,t),LE.s32be=t=>new qE(4,t),LE.s40be=t=>new qE(5,t),LE.s48be=t=>new qE(6,t),LE.ns64be=t=>new XE(t),LE.f32=t=>new QE(t),LE.f32be=t=>new tx(t),LE.f64=t=>new ex(t),LE.f64be=t=>new rx(t);var Ex=LE.struct=(t,e,r)=>new ix(t,e,r);LE.bits=(t,e,r)=>new hx(t,e,r);var xx=LE.seq=(t,e,r)=>new nx(t,e,r);LE.union=(t,e,r)=>new ax(t,e,r),LE.unionLayoutDiscriminator=(t,e)=>new sx(t,e);var Sx=LE.blob=(t,e)=>new dx(t,e);LE.cstr=t=>new px(t),LE.utf8=(t,e)=>new yx(t,e),LE.constant=(t,e)=>new gx(t,e);var Ax={};Object.defineProperty(Ax,"__esModule",{value:!0});var Ix=Ax.toBigIntLE=function(t){{const e=Buffer.from(t);e.reverse();const r=e.toString("hex");return 0===r.length?BigInt(0):BigInt(`0x${r}`)}};Ax.toBigIntBE=function(t){{const e=t.toString("hex");return 0===e.length?BigInt(0):BigInt(`0x${e}`)}};var Bx,Mx=Ax.toBufferLE=function(t,e){{const r=t.toString(16),n=Buffer.from(r.padStart(2*e,"0").slice(0,2*e),"hex");return n.reverse(),n}};Ax.toBufferBE=function(t,e){{const r=t.toString(16);return Buffer.from(r.padStart(2*e,"0").slice(0,2*e),"hex")}};class Rx extends TypeError{constructor(t,e){let r;const{message:n,...i}=t,{path:o}=t;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=[t,...e()]}}}function Px(t){return"object"==typeof t&&null!=t}function Tx(t){return"string"==typeof t?JSON.stringify(t):""+t}function Lx(t,e,r,n){if(!0===t)return;!1===t?t={}:"string"==typeof t&&(t={message:t});const{path:i,branch:o}=e,{type:s}=r,{refinement:a,message:u="Expected a value of type `"+s+"`"+(a?" with refinement `"+a+"`":"")+", but received: `"+Tx(n)+"`"}=t;return{value:n,type:s,refinement:a,key:i[i.length-1],path:i,branch:o,...t,message:u}}function*Ox(t,e,r,n){var i;Px(i=t)&&"function"==typeof i[Symbol.iterator]||(t=[t]);for(const i of t){const t=Lx(i,e,r,n);t&&(yield t)}}function*Ux(t,e,r={}){const{path:n=[],branch:i=[t],coerce:o=!1,mask:s=!1}=r,a={path:n,branch:i};if(o&&(t=e.coercer(t,a),s&&"type"!==e.type&&Px(e.schema)&&Px(t)&&!Array.isArray(t)))for(const r in t)void 0===e.schema[r]&&delete t[r];let u=!0;for(const r of e.validator(t,a))u=!1,yield[r,void 0];for(let[r,c,h]of e.entries(t,a)){const e=Ux(c,h,{path:void 0===r?n:[...n,r],branch:void 0===r?i:[...i,c],coerce:o,mask:s});for(const n of e)n[0]?(u=!1,yield[n[0],void 0]):o&&(c=n[1],void 0===r?t=c:t instanceof Map?t.set(r,c):t instanceof Set?t.add(c):Px(t)&&(t[r]=c))}if(u)for(const r of e.refiner(t,a))u=!1,yield[r,void 0];u&&(yield[void 0,t])}class Cx{constructor(t){const{type:e,schema:r,validator:n,refiner:i,coercer:o=(t=>t),entries:s=function*(){}}=t;this.type=e,this.schema=r,this.entries=s,this.coercer=o,this.validator=n?(t,e)=>Ox(n(t,e),e,this,t):()=>[],this.refiner=i?(t,e)=>Ox(i(t,e),e,this,t):()=>[]}assert(t){return function(t,e){const r=Dx(t,e);if(r[0])throw r[0]}(t,this)}create(t){return Nx(t,this)}is(t){return zx(t,this)}mask(t){return function(t,e){const r=Dx(t,e,{coerce:!0,mask:!0});if(r[0])throw r[0];return r[1]}(t,this)}validate(t,e={}){return Dx(t,this,e)}}function Nx(t,e){const r=Dx(t,e,{coerce:!0});if(r[0])throw r[0];return r[1]}function zx(t,e){return!Dx(t,e)[0]}function Dx(t,e,r={}){const n=Ux(t,e,r),i=function(t){const{done:e,value:r}=t.next();return e?void 0:r}(n);return i[0]?[new Rx(i[0],(function*(){for(const t of n)t[0]&&(yield t[0])})),void 0]:[void 0,i[1]]}function jx(t,e){return new Cx({type:t,schema:null,validator:e})}function Wx(t){return new Cx({type:"array",schema:t,*entries(e){if(t&&Array.isArray(e))for(const[r,n]of e.entries())yield[r,n,t]},coercer:t=>Array.isArray(t)?t.slice():t,validator:t=>Array.isArray(t)||"Expected an array value, but received: "+Tx(t)})}function Fx(){return jx("boolean",(t=>"boolean"==typeof t))}function Kx(t){return jx("instance",(e=>e instanceof t||"Expected a `"+t.name+"` instance, but received: "+Tx(e)))}function Vx(t){const e=Tx(t),r=typeof t;return new Cx({type:"literal",schema:"string"===r||"number"===r||"boolean"===r?t:null,validator:r=>r===t||"Expected the literal `"+e+"`, but received: "+Tx(r)})}function qx(t){return new Cx({...t,validator:(e,r)=>null===e||t.validator(e,r),refiner:(e,r)=>null===e||t.refiner(e,r)})}function Hx(){return jx("number",(t=>"number"==typeof t&&!isNaN(t)||"Expected a number, but received: "+Tx(t)))}function $x(t){return new Cx({...t,validator:(e,r)=>void 0===e||t.validator(e,r),refiner:(e,r)=>void 0===e||t.refiner(e,r)})}function Gx(t,e){return new Cx({type:"record",schema:null,*entries(r){if(Px(r))for(const n in r){const i=r[n];yield[n,n,t],yield[n,i,e]}},validator:t=>Px(t)||"Expected an object, but received: "+Tx(t)})}function Zx(){return jx("string",(t=>"string"==typeof t||"Expected a string, but received: "+Tx(t)))}function Yx(t){const e=jx("never",(()=>!1));return new Cx({type:"tuple",schema:null,*entries(r){if(Array.isArray(r)){const n=Math.max(t.length,r.length);for(let i=0;i<n;i++)yield[i,r[i],t[i]||e]}},validator:t=>Array.isArray(t)||"Expected an array, but received: "+Tx(t)})}function Jx(t){const e=Object.keys(t);return new Cx({type:"type",schema:t,*entries(r){if(Px(r))for(const n of e)yield[n,r[n],t[n]]},validator:t=>Px(t)||"Expected an object, but received: "+Tx(t)})}function Xx(t){const e=t.map((t=>t.type)).join(" | ");return new Cx({type:"union",schema:null,validator(r,n){const i=[];for(const e of t){const[...t]=Ux(r,e,n),[o]=t;if(!o[0])return[];for(const[e]of t)e&&i.push(e)}return["Expected the value to satisfy a union of `"+e+"`, but received: "+Tx(r),...i]}})}function Qx(){return jx("unknown",(()=>!0))}function tS(t,e,r){return new Cx({...t,coercer:(n,i)=>zx(n,e)?t.coercer(r(n,i),i):t.coercer(n,i)})}var eS=new Uint8Array(16);function rS(){if(!Bx&&!(Bx="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 Bx(eS)}var nS=/^(?:[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 iS(t){return"string"==typeof t&&nS.test(t)}for(var oS,sS,aS=[],uS=0;uS<256;++uS)aS.push((uS+256).toString(16).substr(1));function cS(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(aS[t[e+0]]+aS[t[e+1]]+aS[t[e+2]]+aS[t[e+3]]+"-"+aS[t[e+4]]+aS[t[e+5]]+"-"+aS[t[e+6]]+aS[t[e+7]]+"-"+aS[t[e+8]]+aS[t[e+9]]+"-"+aS[t[e+10]]+aS[t[e+11]]+aS[t[e+12]]+aS[t[e+13]]+aS[t[e+14]]+aS[t[e+15]]).toLowerCase();if(!iS(r))throw TypeError("Stringified UUID is invalid");return r}var hS=0,lS=0;function fS(t){if(!iS(t))throw TypeError("Invalid UUID");var e,r=new Uint8Array(16);return r[0]=(e=parseInt(t.slice(0,8),16))>>>24,r[1]=e>>>16&255,r[2]=e>>>8&255,r[3]=255&e,r[4]=(e=parseInt(t.slice(9,13),16))>>>8,r[5]=255&e,r[6]=(e=parseInt(t.slice(14,18),16))>>>8,r[7]=255&e,r[8]=(e=parseInt(t.slice(19,23),16))>>>8,r[9]=255&e,r[10]=(e=parseInt(t.slice(24,36),16))/1099511627776&255,r[11]=e/4294967296&255,r[12]=e>>>24&255,r[13]=e>>>16&255,r[14]=e>>>8&255,r[15]=255&e,r}function dS(t,e,r){function n(t,n,i,o){if("string"==typeof t&&(t=function(t){t=unescape(encodeURIComponent(t));for(var e=[],r=0;r<t.length;++r)e.push(t.charCodeAt(r));return e}(t)),"string"==typeof n&&(n=fS(n)),16!==n.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var s=new Uint8Array(16+t.length);if(s.set(n),s.set(t,n.length),(s=r(s))[6]=15&s[6]|e,s[8]=63&s[8]|128,i){o=o||0;for(var a=0;a<16;++a)i[o+a]=s[a];return i}return cS(s)}try{n.name=t}catch(t){}return n.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",n.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",n}function pS(t){return 14+(t+64>>>9<<4)+1}function yS(t,e){var r=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(r>>16)<<16|65535&r}function gS(t,e,r,n,i,o){return yS((s=yS(yS(e,t),yS(n,o)))<<(a=i)|s>>>32-a,r);var s,a}function mS(t,e,r,n,i,o,s){return gS(e&r|~e&n,t,e,i,o,s)}function wS(t,e,r,n,i,o,s){return gS(e&n|r&~n,t,e,i,o,s)}function bS(t,e,r,n,i,o,s){return gS(e^r^n,t,e,i,o,s)}function vS(t,e,r,n,i,o,s){return gS(r^(e|~n),t,e,i,o,s)}var _S=dS("v3",48,(function(t){if("string"==typeof t){var e=unescape(encodeURIComponent(t));t=new Uint8Array(e.length);for(var r=0;r<e.length;++r)t[r]=e.charCodeAt(r)}return function(t){for(var e=[],r=32*t.length,n="0123456789abcdef",i=0;i<r;i+=8){var o=t[i>>5]>>>i%32&255,s=parseInt(n.charAt(o>>>4&15)+n.charAt(15&o),16);e.push(s)}return e}(function(t,e){t[e>>5]|=128<<e%32,t[pS(e)-1]=e;for(var r=1732584193,n=-271733879,i=-1732584194,o=271733878,s=0;s<t.length;s+=16){var a=r,u=n,c=i,h=o;r=mS(r,n,i,o,t[s],7,-680876936),o=mS(o,r,n,i,t[s+1],12,-389564586),i=mS(i,o,r,n,t[s+2],17,606105819),n=mS(n,i,o,r,t[s+3],22,-1044525330),r=mS(r,n,i,o,t[s+4],7,-176418897),o=mS(o,r,n,i,t[s+5],12,1200080426),i=mS(i,o,r,n,t[s+6],17,-1473231341),n=mS(n,i,o,r,t[s+7],22,-45705983),r=mS(r,n,i,o,t[s+8],7,1770035416),o=mS(o,r,n,i,t[s+9],12,-1958414417),i=mS(i,o,r,n,t[s+10],17,-42063),n=mS(n,i,o,r,t[s+11],22,-1990404162),r=mS(r,n,i,o,t[s+12],7,1804603682),o=mS(o,r,n,i,t[s+13],12,-40341101),i=mS(i,o,r,n,t[s+14],17,-1502002290),r=wS(r,n=mS(n,i,o,r,t[s+15],22,1236535329),i,o,t[s+1],5,-165796510),o=wS(o,r,n,i,t[s+6],9,-1069501632),i=wS(i,o,r,n,t[s+11],14,643717713),n=wS(n,i,o,r,t[s],20,-373897302),r=wS(r,n,i,o,t[s+5],5,-701558691),o=wS(o,r,n,i,t[s+10],9,38016083),i=wS(i,o,r,n,t[s+15],14,-660478335),n=wS(n,i,o,r,t[s+4],20,-405537848),r=wS(r,n,i,o,t[s+9],5,568446438),o=wS(o,r,n,i,t[s+14],9,-1019803690),i=wS(i,o,r,n,t[s+3],14,-187363961),n=wS(n,i,o,r,t[s+8],20,1163531501),r=wS(r,n,i,o,t[s+13],5,-1444681467),o=wS(o,r,n,i,t[s+2],9,-51403784),i=wS(i,o,r,n,t[s+7],14,1735328473),r=bS(r,n=wS(n,i,o,r,t[s+12],20,-1926607734),i,o,t[s+5],4,-378558),o=bS(o,r,n,i,t[s+8],11,-2022574463),i=bS(i,o,r,n,t[s+11],16,1839030562),n=bS(n,i,o,r,t[s+14],23,-35309556),r=bS(r,n,i,o,t[s+1],4,-1530992060),o=bS(o,r,n,i,t[s+4],11,1272893353),i=bS(i,o,r,n,t[s+7],16,-155497632),n=bS(n,i,o,r,t[s+10],23,-1094730640),r=bS(r,n,i,o,t[s+13],4,681279174),o=bS(o,r,n,i,t[s],11,-358537222),i=bS(i,o,r,n,t[s+3],16,-722521979),n=bS(n,i,o,r,t[s+6],23,76029189),r=bS(r,n,i,o,t[s+9],4,-640364487),o=bS(o,r,n,i,t[s+12],11,-421815835),i=bS(i,o,r,n,t[s+15],16,530742520),r=vS(r,n=bS(n,i,o,r,t[s+2],23,-995338651),i,o,t[s],6,-198630844),o=vS(o,r,n,i,t[s+7],10,1126891415),i=vS(i,o,r,n,t[s+14],15,-1416354905),n=vS(n,i,o,r,t[s+5],21,-57434055),r=vS(r,n,i,o,t[s+12],6,1700485571),o=vS(o,r,n,i,t[s+3],10,-1894986606),i=vS(i,o,r,n,t[s+10],15,-1051523),n=vS(n,i,o,r,t[s+1],21,-2054922799),r=vS(r,n,i,o,t[s+8],6,1873313359),o=vS(o,r,n,i,t[s+15],10,-30611744),i=vS(i,o,r,n,t[s+6],15,-1560198380),n=vS(n,i,o,r,t[s+13],21,1309151649),r=vS(r,n,i,o,t[s+4],6,-145523070),o=vS(o,r,n,i,t[s+11],10,-1120210379),i=vS(i,o,r,n,t[s+2],15,718787259),n=vS(n,i,o,r,t[s+9],21,-343485551),r=yS(r,a),n=yS(n,u),i=yS(i,c),o=yS(o,h)}return[r,n,i,o]}(function(t){if(0===t.length)return[];for(var e=8*t.length,r=new Uint32Array(pS(e)),n=0;n<e;n+=8)r[n>>5]|=(255&t[n/8])<<n%32;return r}(t),8*t.length))})),kS=_S;function ES(t,e,r,n){switch(t){case 0:return e&r^~e&n;case 1:case 3:return e^r^n;case 2:return e&r^e&n^r&n}}function xS(t,e){return t<<e|t>>>32-e}var SS=dS("v5",80,(function(t){var e=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof t){var n=unescape(encodeURIComponent(t));t=[];for(var i=0;i<n.length;++i)t.push(n.charCodeAt(i))}else Array.isArray(t)||(t=Array.prototype.slice.call(t));t.push(128);for(var o=t.length/4+2,s=Math.ceil(o/16),a=new Array(s),u=0;u<s;++u){for(var c=new Uint32Array(16),h=0;h<16;++h)c[h]=t[64*u+4*h]<<24|t[64*u+4*h+1]<<16|t[64*u+4*h+2]<<8|t[64*u+4*h+3];a[u]=c}a[s-1][14]=8*(t.length-1)/Math.pow(2,32),a[s-1][14]=Math.floor(a[s-1][14]),a[s-1][15]=8*(t.length-1)&4294967295;for(var l=0;l<s;++l){for(var f=new Uint32Array(80),d=0;d<16;++d)f[d]=a[l][d];for(var p=16;p<80;++p)f[p]=xS(f[p-3]^f[p-8]^f[p-14]^f[p-16],1);for(var y=r[0],g=r[1],m=r[2],w=r[3],b=r[4],v=0;v<80;++v){var _=Math.floor(v/20),k=xS(y,5)+ES(_,g,m,w)+b+e[_]+f[v]>>>0;b=w,w=m,m=xS(g,30)>>>0,g=y,y=k}r[0]=r[0]+y>>>0,r[1]=r[1]+g>>>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]]})),AS=SS,IS=Object.freeze({__proto__:null,v1:function(t,e,r){var n=e&&r||0,i=e||new Array(16),o=(t=t||{}).node||oS,s=void 0!==t.clockseq?t.clockseq:sS;if(null==o||null==s){var a=t.random||(t.rng||rS)();null==o&&(o=oS=[1|a[0],a[1],a[2],a[3],a[4],a[5]]),null==s&&(s=sS=16383&(a[6]<<8|a[7]))}var u=void 0!==t.msecs?t.msecs:Date.now(),c=void 0!==t.nsecs?t.nsecs:lS+1,h=u-hS+(c-lS)/1e4;if(h<0&&void 0===t.clockseq&&(s=s+1&16383),(h<0||u>hS)&&void 0===t.nsecs&&(c=0),c>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");hS=u,lS=c,sS=s;var l=(1e4*(268435455&(u+=122192928e5))+c)%4294967296;i[n++]=l>>>24&255,i[n++]=l>>>16&255,i[n++]=l>>>8&255,i[n++]=255&l;var f=u/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 e||cS(i)},v3:kS,v4:function(t,e,r){var n=(t=t||{}).random||(t.rng||rS)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,e){r=r||0;for(var i=0;i<16;++i)e[r+i]=n[i];return e}return cS(n)},v5:AS,NIL:"00000000-0000-0000-0000-000000000000",version:function(t){if(!iS(t))throw TypeError("Invalid UUID");return parseInt(t.substr(14,1),16)},validate:iS,stringify:cS,parse:fS}),BS=Qv(IS);BS.v4,BS.v4;var MS,RS={exports:{}};(MS=RS).exports=function(t){return t&&t.__esModule?t:{default:t}},MS.exports.__esModule=!0,MS.exports.default=MS.exports;var PS,TS,LS,OS,US=RS.exports,CS={exports:{}},NS={exports:{}};function zS(){return PS||(PS=1,function(t){function e(r){return t.exports=e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.__esModule=!0,t.exports.default=t.exports,e(r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports}(NS)),NS.exports}NS.exports;var DS,jS,WS={exports:{}},FS={exports:{}};function KS(){return jS||(jS=1,function(t){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},t.exports.__esModule=!0,t.exports.default=t.exports}(FS)),FS.exports}var VS,qS,HS,$S={exports:{}},GS={exports:{}},ZS={exports:{}};function YS(){return qS||(qS=1,function(t){var e=zS().default,r=(VS||(VS=1,function(t){var e=zS().default;t.exports=function(t,r){if("object"!==e(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,r||"default");if("object"!==e(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)},t.exports.__esModule=!0,t.exports.default=t.exports}(ZS)),ZS.exports);t.exports=function(t){var n=r(t,"string");return"symbol"===e(n)?n:String(n)},t.exports.__esModule=!0,t.exports.default=t.exports}(GS)),GS.exports}function JS(){return HS||(HS=1,function(t){var e=YS();function r(t,r){for(var n=0;n<r.length;n++){var i=r[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,e(i.key),i)}}t.exports=function(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t},t.exports.__esModule=!0,t.exports.default=t.exports}($S)),$S.exports}ZS.exports,GS.exports;var XS,QS,tA={exports:{}},eA={exports:{}};function rA(){return QS||(QS=1,function(t){var e=(XS||(XS=1,function(t){function e(r,n){return t.exports=e=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},t.exports.__esModule=!0,t.exports.default=t.exports,e(r,n)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports}(eA)),eA.exports);t.exports=function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(r&&r.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),r&&e(t,r)},t.exports.__esModule=!0,t.exports.default=t.exports}(tA)),tA.exports}eA.exports;var nA,iA,oA={exports:{}},sA={exports:{}};function aA(){return iA||(iA=1,function(t){var e=zS().default,r=(nA||(nA=1,function(t){t.exports=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t},t.exports.__esModule=!0,t.exports.default=t.exports}(sA)),sA.exports);t.exports=function(t,n){if(n&&("object"===e(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return r(t)},t.exports.__esModule=!0,t.exports.default=t.exports}(oA)),oA.exports}sA.exports;var uA,cA={exports:{}};function hA(){return uA||(uA=1,function(t){function e(r){return t.exports=e=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},t.exports.__esModule=!0,t.exports.default=t.exports,e(r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports}(cA)),cA.exports}var lA,fA={exports:{}};function dA(){return lA||(lA=1,function(t){var e=Object.prototype.hasOwnProperty,r="~";function n(){}function i(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function o(t,e,n,o,s){if("function"!=typeof n)throw new TypeError("The listener must be a function");var a=new i(n,o||t,s),u=r?r+e:e;return t._events[u]?t._events[u].fn?t._events[u]=[t._events[u],a]:t._events[u].push(a):(t._events[u]=a,t._eventsCount++),t}function s(t,e){0==--t._eventsCount?t._events=new n:delete t._events[e]}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 t,n,i=[];if(0===this._eventsCount)return i;for(n in t=this._events)e.call(t,n)&&i.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(t)):i},a.prototype.listeners=function(t){var e=r?r+t:t,n=this._events[e];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,o=n.length,s=new Array(o);i<o;i++)s[i]=n[i].fn;return s},a.prototype.listenerCount=function(t){var e=r?r+t:t,n=this._events[e];return n?n.fn?1:n.length:0},a.prototype.emit=function(t,e,n,i,o,s){var a=r?r+t:t;if(!this._events[a])return!1;var u,c,h=this._events[a],l=arguments.length;if(h.fn){switch(h.once&&this.removeListener(t,h.fn,void 0,!0),l){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,e),!0;case 3:return h.fn.call(h.context,e,n),!0;case 4:return h.fn.call(h.context,e,n,i),!0;case 5:return h.fn.call(h.context,e,n,i,o),!0;case 6:return h.fn.call(h.context,e,n,i,o,s),!0}for(c=1,u=new Array(l-1);c<l;c++)u[c-1]=arguments[c];h.fn.apply(h.context,u)}else{var f,d=h.length;for(c=0;c<d;c++)switch(h[c].once&&this.removeListener(t,h[c].fn,void 0,!0),l){case 1:h[c].fn.call(h[c].context);break;case 2:h[c].fn.call(h[c].context,e);break;case 3:h[c].fn.call(h[c].context,e,n);break;case 4:h[c].fn.call(h[c].context,e,n,i);break;default:if(!u)for(f=1,u=new Array(l-1);f<l;f++)u[f-1]=arguments[f];h[c].fn.apply(h[c].context,u)}}return!0},a.prototype.on=function(t,e,r){return o(this,t,e,r,!1)},a.prototype.once=function(t,e,r){return o(this,t,e,r,!0)},a.prototype.removeListener=function(t,e,n,i){var o=r?r+t:t;if(!this._events[o])return this;if(!e)return s(this,o),this;var a=this._events[o];if(a.fn)a.fn!==e||i&&!a.once||n&&a.context!==n||s(this,o);else{for(var u=0,c=[],h=a.length;u<h;u++)(a[u].fn!==e||i&&!a[u].once||n&&a[u].context!==n)&&c.push(a[u]);c.length?this._events[o]=1===c.length?c[0]:c:s(this,o)}return this},a.prototype.removeAllListeners=function(t){var e;return t?(e=r?r+t:t,this._events[e]&&s(this,e)):(this._events=new n,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=r,a.EventEmitter=a,t.exports=a}(fA)),fA.exports}!function(t){var e=US;Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=e(function(){if(OS)return LS;OS=1;var t=(TS||(TS=1,function(t){var e=zS().default;function r(){
|
|
40
40
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
41
|
-
t.exports=r=function(){return i},t.exports.__esModule=!0,t.exports.default=t.exports;var n,i={},o=Object.prototype,s=o.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},u="function"==typeof Symbol?Symbol:{},c=u.iterator||"@@iterator",h=u.asyncIterator||"@@asyncIterator",l=u.toStringTag||"@@toStringTag";function f(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{f({},"")}catch(n){f=function(t,e,r){return t[e]=r}}function d(t,e,r,n){var i=e&&e.prototype instanceof v?e:v,o=Object.create(i.prototype),s=new O(n||[]);return a(o,"_invoke",{value:M(t,r,s)}),o}function p(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}i.wrap=d;var y="suspendedStart",g="suspendedYield",m="executing",w="completed",b={};function v(){}function _(){}function k(){}var E={};f(E,c,(function(){return this}));var x=Object.getPrototypeOf,S=x&&x(x(L([])));S&&S!==o&&s.call(S,c)&&(E=S);var A=k.prototype=v.prototype=Object.create(E);function I(t){["next","throw","return"].forEach((function(e){f(t,e,(function(t){return this._invoke(e,t)}))}))}function B(t,r){function n(i,o,a,u){var c=p(t[i],t,o);if("throw"!==c.type){var h=c.arg,l=h.value;return l&&"object"==e(l)&&s.call(l,"__await")?r.resolve(l.__await).then((function(t){n("next",t,a,u)}),(function(t){n("throw",t,a,u)})):r.resolve(l).then((function(t){h.value=t,a(h)}),(function(t){return n("throw",t,a,u)}))}u(c.arg)}var i;a(this,"_invoke",{value:function(t,e){function o(){return new r((function(r,i){n(t,e,r,i)}))}return i=i?i.then(o,o):o()}})}function M(t,e,r){var i=y;return function(o,s){if(i===m)throw new Error("Generator is already running");if(i===w){if("throw"===o)throw s;return{value:n,done:!0}}for(r.method=o,r.arg=s;;){var a=r.delegate;if(a){var u=R(a,r);if(u){if(u===b)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===y)throw i=w,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=m;var c=p(t,e,r);if("normal"===c.type){if(i=r.done?w:g,c.arg===b)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(i=w,r.method="throw",r.arg=c.arg)}}}function R(t,e){var r=e.method,i=t.iterator[r];if(i===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=n,R(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),b;var o=p(i,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,b;var s=o.arg;return s?s.done?(e[t.resultName]=s.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=n),e.delegate=null,b):s:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,b)}function P(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(P,this),this.reset(!0)}function L(t){if(t||""===t){var r=t[c];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function e(){for(;++i<t.length;)if(s.call(t,i))return e.value=t[i],e.done=!1,e;return e.value=n,e.done=!0,e};return o.next=o}}throw new TypeError(e(t)+" is not iterable")}return _.prototype=k,a(A,"constructor",{value:k,configurable:!0}),a(k,"constructor",{value:_,configurable:!0}),_.displayName=f(k,l,"GeneratorFunction"),i.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===_||"GeneratorFunction"===(e.displayName||e.name))},i.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,k):(t.__proto__=k,f(t,l,"GeneratorFunction")),t.prototype=Object.create(A),t},i.awrap=function(t){return{__await:t}},I(B.prototype),f(B.prototype,h,(function(){return this})),i.AsyncIterator=B,i.async=function(t,e,r,n,o){void 0===o&&(o=Promise);var s=new B(d(t,e,r,n),o);return i.isGeneratorFunction(e)?s:s.next().then((function(t){return t.done?t.value:s.next()}))},I(A),f(A,l,"Generator"),f(A,c,(function(){return this})),f(A,"toString",(function(){return"[object Generator]"})),i.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},i.values=L,O.prototype={constructor:O,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=n,this.done=!1,this.delegate=null,this.method="next",this.arg=n,this.tryEntries.forEach(T),!t)for(var e in this)"t"===e.charAt(0)&&s.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=n)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,i){return a.type="throw",a.arg=t,e.next=r,i&&(e.method="next",e.arg=n),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var u=s.call(o,"catchLoc"),c=s.call(o,"finallyLoc");if(u&&c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&s.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=t,o.arg=e,i?(this.method="next",this.next=i.finallyLoc,b):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),b},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),b}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:L(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=n),b}},i}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}(CS)),CS.exports)();OS=t;try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}return OS}()),n=e((DS||(DS=1,function(t){function e(t,e,r,n,i,o,s){try{var a=t[o](s),u=a.value}catch(t){return void r(t)}a.done?e(u):Promise.resolve(u).then(n,i)}t.exports=function(t){return function(){var r=this,n=arguments;return new Promise((function(i,o){var s=t.apply(r,n);function a(t){e(s,i,o,a,u,"next",t)}function u(t){e(s,i,o,a,u,"throw",t)}a(void 0)}))}},t.exports.__esModule=!0,t.exports.default=t.exports}(WS)),WS.exports)),i=e(zS()),o=e(FS()),s=e(JS()),a=e(rA()),u=e(aA()),c=e(hA());function h(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=(0,c.default)(t);if(e){var i=(0,c.default)(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return(0,u.default)(this,r)}}var l=function(t){(0,a.default)(d,t);var e,u,c,l,f=h(d);function d(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"ws://localhost:8080",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3?arguments[3]:void 0;(0,o.default)(this,d);var s=n.autoconnect,a=void 0===s||s,u=n.reconnect,c=void 0===u||u,h=n.reconnect_interval,l=void 0===h?1e3:h,p=n.max_reconnects,y=void 0===p?5:p,g=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]])}return r}(n,["autoconnect","reconnect","reconnect_interval","max_reconnects"]);return(e=f.call(this)).webSocketFactory=t,e.queue={},e.rpc_id=0,e.address=r,e.autoconnect=a,e.ready=!1,e.reconnect=c,e.reconnect_timer_id=void 0,e.reconnect_interval=l,e.max_reconnects=y,e.rest_options=g,e.current_reconnects=0,e.generate_request_id=i||function(){return++e.rpc_id},e.autoconnect&&e._connect(e.address,Object.assign({autoconnect:e.autoconnect,reconnect:e.reconnect,reconnect_interval:e.reconnect_interval,max_reconnects:e.max_reconnects},e.rest_options)),e}return(0,s.default)(d,[{key:"connect",value:function(){this.socket||this._connect(this.address,Object.assign({autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects},this.rest_options))}},{key:"call",value:function(t,e,r,n){var o=this;return n||"object"!==(0,i.default)(r)||(n=r,r=null),new Promise((function(i,s){if(!o.ready)return s(new Error("socket not ready"));var a=o.generate_request_id(t,e),u={jsonrpc:"2.0",method:t,params:e||null,id:a};o.socket.send(JSON.stringify(u),n,(function(t){if(t)return s(t);o.queue[a]={promise:[i,s]},r&&(o.queue[a].timeout=setTimeout((function(){delete o.queue[a],s(new Error("reply timeout"))}),r))}))}))}},{key:"login",value:(l=(0,n.default)(r.default.mark((function t(e){var n;return r.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.call("rpc.login",e);case 2:if(n=t.sent){t.next=5;break}throw new Error("authentication failed");case 5:return t.abrupt("return",n);case 6:case"end":return t.stop()}}),t,this)}))),function(t){return l.apply(this,arguments)})},{key:"listMethods",value:(c=(0,n.default)(r.default.mark((function t(){return r.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.call("__listMethods");case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)}))),function(){return c.apply(this,arguments)})},{key:"notify",value:function(t,e){var r=this;return new Promise((function(n,i){if(!r.ready)return i(new Error("socket not ready"));var o={jsonrpc:"2.0",method:t,params:e||null};r.socket.send(JSON.stringify(o),(function(t){if(t)return i(t);n()}))}))}},{key:"subscribe",value:(u=(0,n.default)(r.default.mark((function t(e){var n;return r.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return"string"==typeof e&&(e=[e]),t.next=3,this.call("rpc.on",e);case 3:if(n=t.sent,"string"!=typeof e||"ok"===n[e]){t.next=6;break}throw new Error("Failed subscribing to an event '"+e+"' with: "+n[e]);case 6:return t.abrupt("return",n);case 7:case"end":return t.stop()}}),t,this)}))),function(t){return u.apply(this,arguments)})},{key:"unsubscribe",value:(e=(0,n.default)(r.default.mark((function t(e){var n;return r.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return"string"==typeof e&&(e=[e]),t.next=3,this.call("rpc.off",e);case 3:if(n=t.sent,"string"!=typeof e||"ok"===n[e]){t.next=6;break}throw new Error("Failed unsubscribing from an event with: "+n);case 6:return t.abrupt("return",n);case 7:case"end":return t.stop()}}),t,this)}))),function(t){return e.apply(this,arguments)})},{key:"close",value:function(t,e){this.socket.close(t||1e3,e)}},{key:"_connect",value:function(t,e){var r=this;clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(t,e),this.socket.addEventListener("open",(function(){r.ready=!0,r.emit("open"),r.current_reconnects=0})),this.socket.addEventListener("message",(function(t){var e=t.data;e instanceof ArrayBuffer&&(e=Buffer.from(e).toString());try{e=JSON.parse(e)}catch(t){return}if(e.notification&&r.listeners(e.notification).length){if(!Object.keys(e.params).length)return r.emit(e.notification);var n=[e.notification];if(e.params.constructor===Object)n.push(e.params);else for(var i=0;i<e.params.length;i++)n.push(e.params[i]);return Promise.resolve().then((function(){r.emit.apply(r,n)}))}if(!r.queue[e.id])return e.method&&e.params?Promise.resolve().then((function(){r.emit(e.method,e.params)})):void 0;"error"in e=="result"in e&&r.queue[e.id].promise[1](new Error('Server response malformed. Response must include either "result" or "error", but not both.')),r.queue[e.id].timeout&&clearTimeout(r.queue[e.id].timeout),e.error?r.queue[e.id].promise[1](e.error):r.queue[e.id].promise[0](e.result),delete r.queue[e.id]})),this.socket.addEventListener("error",(function(t){return r.emit("error",t)})),this.socket.addEventListener("close",(function(n){var i=n.code,o=n.reason;r.ready&&setTimeout((function(){return r.emit("close",i,o)}),0),r.ready=!1,r.socket=void 0,1e3!==i&&(r.current_reconnects++,r.reconnect&&(r.max_reconnects>r.current_reconnects||0===r.max_reconnects)&&(r.reconnect_timer_id=setTimeout((function(){return r._connect(t,e)}),r.reconnect_interval)))}))}}]),d}(dA().EventEmitter);t.default=l}({}),function(t){var e=US;Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(t,e){return new u(t,e)};var r=e(FS()),n=e(JS()),i=e(rA()),o=e(aA()),s=e(hA());function a(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=(0,s.default)(t);if(e){var i=(0,s.default)(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return(0,o.default)(this,r)}}var u=function(t){(0,i.default)(o,t);var e=a(o);function o(t,n,i){var s;return(0,r.default)(this,o),(s=e.call(this)).socket=new window.WebSocket(t,i),s.socket.onopen=function(){return s.emit("open")},s.socket.onmessage=function(t){return s.emit("message",t.data)},s.socket.onerror=function(t){return s.emit("error",t)},s.socket.onclose=function(t){s.emit("close",t.code,t.reason)},s}return(0,n.default)(o,[{key:"send",value:function(t,e,r){var n=r||e;try{this.socket.send(t),n()}catch(t){n(t)}}},{key:"close",value:function(t,e){this.socket.close(t,e)}},{key:"addEventListener",value:function(t,e,r){this.socket.addEventListener(t,e,r)}}]),o}(dA().EventEmitter)}({});const{bytesToNumberBE:pA,hexToBytes:yA}=tk,gA={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(t){const{Err:e}=gA;if(t.length<2||2!==t[0])throw new e("Invalid signature integer tag");const r=t[1],n=t.subarray(2,r+2);if(!r||n.length!==r)throw new e("Invalid signature integer: wrong length");if(128&n[0])throw new e("Invalid signature integer: negative");if(0===n[0]&&!(128&n[1]))throw new e("Invalid signature integer: unnecessary leading zero");return{d:pA(n),l:t.subarray(r+2)}},toSig(t){const{Err:e}=gA,r="string"==typeof t?yA(t):t;if(!(r instanceof Uint8Array))throw new Error("ui8a expected");let n=r.length;if(n<2||48!=r[0])throw new e("Invalid signature tag");if(r[1]!==n-2)throw new e("Invalid signature: incorrect length");const{d:i,l:o}=gA._parseInt(r.subarray(2)),{d:s,l:a}=gA._parseInt(o);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:i,s:s}},hexFromSig(t){const e=t=>8&Number.parseInt(t[0],16)?"00"+t:t,r=t=>{const e=t.toString(16);return 1&e.length?`0${e}`:e},n=e(r(t.s)),i=e(r(t.r)),o=n.length/2,s=i.length/2,a=r(o),u=r(s);return`30${r(s+o+4)}02${u}${i}02${a}${n}`}},mA=BigInt(0),wA=BigInt(1);BigInt(2);const bA=BigInt(3);function vA(t){const e=function(t){const e=vk(t);return Q_(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}(t),{Fp:r,n:n}=e,i=r.BYTES+1,o=2*r.BYTES+1;function s(t){return uk(t,n)}function a(t){return lk(t,n)}const{ProjectivePoint:u,normPrivateKeyToScalar:c,weierstrassEquation:h,isWithinCurveOrder:l}=function(t){const e=/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
42
|
-
function(t){const e=vk(t);Q_(e,{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}=e;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({...e})}(t),{Fp:r}=e,n=e.toBytes||((t,e,n)=>{const i=e.toAffine();return $_(Uint8Array.from([4]),r.toBytes(i.x),r.toBytes(i.y))}),i=e.fromBytes||(t=>{const e=t.subarray(1);return{x:r.fromBytes(e.subarray(0,r.BYTES)),y:r.fromBytes(e.subarray(r.BYTES,2*r.BYTES))}});function o(t){const{a:n,b:i}=e,o=r.sqr(t),s=r.mul(o,t);return r.add(r.add(s,r.mul(t,n)),i)}if(!r.eql(r.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function s(t){return"bigint"==typeof t&&mA<t&&t<e.n}function a(t){if(!s(t))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function u(t){const{allowedPrivateKeyLengths:r,nByteLength:n,wrapPrivateKey:i,n:o}=e;if(r&&"bigint"!=typeof t){if(t instanceof Uint8Array&&(t=z_(t)),"string"!=typeof t||!r.includes(t.length))throw new Error("Invalid key");t=t.padStart(2*n,"0")}let s;try{s="bigint"==typeof t?t:K_(H_("private key",t,n))}catch(e){throw new Error(`private key must be ${n} bytes, hex or bigint, not ${typeof t}`)}return i&&(s=uk(s,o)),a(s),s}const c=new Map;function h(t){if(!(t instanceof l))throw new Error("ProjectivePoint expected")}class l{constructor(t,e,n){if(this.px=t,this.py=e,this.pz=n,null==t||!r.isValid(t))throw new Error("x required");if(null==e||!r.isValid(e))throw new Error("y required");if(null==n||!r.isValid(n))throw new Error("z required")}static fromAffine(t){const{x:e,y:n}=t||{};if(!t||!r.isValid(e)||!r.isValid(n))throw new Error("invalid affine point");if(t instanceof l)throw new Error("projective point not allowed");const i=t=>r.eql(t,r.ZERO);return i(e)&&i(n)?l.ZERO:new l(e,n,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(t){const e=r.invertBatch(t.map((t=>t.pz)));return t.map(((t,r)=>t.toAffine(e[r]))).map(l.fromAffine)}static fromHex(t){const e=l.fromAffine(i(H_("pointHex",t)));return e.assertValidity(),e}static fromPrivateKey(t){return l.BASE.multiply(u(t))}_setWindowSize(t){this._WINDOW_SIZE=t,c.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!r.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:t,y:n}=this.toAffine();if(!r.isValid(t)||!r.isValid(n))throw new Error("bad point: x or y not FE");const i=r.sqr(n),s=o(t);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:t}=this.toAffine();if(r.isOdd)return!r.isOdd(t);throw new Error("Field doesn't support isOdd")}equals(t){h(t);const{px:e,py:n,pz:i}=this,{px:o,py:s,pz:a}=t,u=r.eql(r.mul(e,a),r.mul(o,i)),c=r.eql(r.mul(n,a),r.mul(s,i));return u&&c}negate(){return new l(this.px,r.neg(this.py),this.pz)}double(){const{a:t,b:n}=e,i=r.mul(n,bA),{px:o,py:s,pz:a}=this;let u=r.ZERO,c=r.ZERO,h=r.ZERO,f=r.mul(o,o),d=r.mul(s,s),p=r.mul(a,a),y=r.mul(o,s);return y=r.add(y,y),h=r.mul(o,a),h=r.add(h,h),u=r.mul(t,h),c=r.mul(i,p),c=r.add(u,c),u=r.sub(d,c),c=r.add(d,c),c=r.mul(u,c),u=r.mul(y,u),h=r.mul(i,h),p=r.mul(t,p),y=r.sub(f,p),y=r.mul(t,y),y=r.add(y,h),h=r.add(f,f),f=r.add(h,f),f=r.add(f,p),f=r.mul(f,y),c=r.add(c,f),p=r.mul(s,a),p=r.add(p,p),f=r.mul(p,y),u=r.sub(u,f),h=r.mul(p,d),h=r.add(h,h),h=r.add(h,h),new l(u,c,h)}add(t){h(t);const{px:n,py:i,pz:o}=this,{px:s,py:a,pz:u}=t;let c=r.ZERO,f=r.ZERO,d=r.ZERO;const p=e.a,y=r.mul(e.b,bA);let g=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(g,m),b=r.sub(b,v),v=r.add(n,o);let _=r.add(s,u);return v=r.mul(v,_),_=r.add(g,w),v=r.sub(v,_),_=r.add(i,o),c=r.add(a,u),_=r.mul(_,c),c=r.add(m,w),_=r.sub(_,c),d=r.mul(p,v),c=r.mul(y,w),d=r.add(c,d),c=r.sub(m,d),d=r.add(m,d),f=r.mul(c,d),m=r.add(g,g),m=r.add(m,g),w=r.mul(p,w),v=r.mul(y,v),m=r.add(m,w),w=r.sub(g,w),w=r.mul(p,w),v=r.add(v,w),g=r.mul(m,v),f=r.add(f,g),g=r.mul(_,v),c=r.mul(b,c),c=r.sub(c,g),g=r.mul(b,m),d=r.mul(_,d),d=r.add(d,g),new l(c,f,d)}subtract(t){return this.add(t.negate())}is0(){return this.equals(l.ZERO)}wNAF(t){return d.wNAFCached(this,c,t,(t=>{const e=r.invertBatch(t.map((t=>t.pz)));return t.map(((t,r)=>t.toAffine(e[r]))).map(l.fromAffine)}))}multiplyUnsafe(t){const n=l.ZERO;if(t===mA)return n;if(a(t),t===wA)return this;const{endo:i}=e;if(!i)return d.unsafeLadder(this,t);let{k1neg:o,k1:s,k2neg:u,k2:c}=i.splitScalar(t),h=n,f=n,p=this;for(;s>mA||c>mA;)s&wA&&(h=h.add(p)),c&wA&&(f=f.add(p)),p=p.double(),s>>=wA,c>>=wA;return o&&(h=h.negate()),u&&(f=f.negate()),f=new l(r.mul(f.px,i.beta),f.py,f.pz),h.add(f)}multiply(t){a(t);let n,i,o=t;const{endo:s}=e;if(s){const{k1neg:t,k1:e,k2neg:a,k2:u}=s.splitScalar(o);let{p:c,f:h}=this.wNAF(e),{p:f,f:p}=this.wNAF(u);c=d.constTimeNegate(t,c),f=d.constTimeNegate(a,f),f=new l(r.mul(f.px,s.beta),f.py,f.pz),n=c.add(f),i=h.add(p)}else{const{p:t,f:e}=this.wNAF(o);n=t,i=e}return l.normalizeZ([n,i])[0]}multiplyAndAddUnsafe(t,e,r){const n=l.BASE,i=(t,e)=>e!==mA&&e!==wA&&t.equals(n)?t.multiply(e):t.multiplyUnsafe(e),o=i(this,e).add(i(t,r));return o.is0()?void 0:o}toAffine(t){const{px:e,py:n,pz:i}=this,o=this.is0();null==t&&(t=o?r.ONE:r.inv(i));const s=r.mul(e,t),a=r.mul(n,t),u=r.mul(i,t);if(o)return{x:r.ZERO,y:r.ZERO};if(!r.eql(u,r.ONE))throw new Error("invZ was invalid");return{x:s,y:a}}isTorsionFree(){const{h:t,isTorsionFree:r}=e;if(t===wA)return!0;if(r)return r(l,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:t,clearCofactor:r}=e;return t===wA?this:r?r(l,this):this.multiplyUnsafe(e.h)}toRawBytes(t=!0){return this.assertValidity(),n(l,this,t)}toHex(t=!0){return z_(this.toRawBytes(t))}}l.BASE=new l(e.Gx,e.Gy,r.ONE),l.ZERO=new l(r.ZERO,r.ONE,r.ZERO);const f=e.nBitLength,d=bk(l,e.endo?Math.ceil(f/2):f);return{CURVE:e,ProjectivePoint:l,normPrivateKeyToScalar:u,weierstrassEquation:o,isWithinCurveOrder:s}}({...e,toBytes(t,e,n){const i=e.toAffine(),o=r.toBytes(i.x),s=$_;return n?s(Uint8Array.from([e.hasEvenY()?2:3]),o):s(Uint8Array.from([4]),o,r.toBytes(i.y))},fromBytes(t){const e=t.length,n=t[0],s=t.subarray(1);if(e!==i||2!==n&&3!==n){if(e===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 ${e} was invalid. Expected ${i} compressed bytes or ${o} uncompressed bytes`)}{const t=K_(s);if(!(mA<(a=t)&&a<r.ORDER))throw new Error("Point is not on curve");const e=h(t);let i=r.sqrt(e);return 1==(1&n)!=((i&wA)===wA)&&(i=r.neg(i)),{x:t,y:i}}var a}}),f=t=>z_(q_(t,e.nByteLength));function d(t){return t>n>>wA}const p=(t,e,r)=>K_(t.slice(e,r));class y{constructor(t,e,r){this.r=t,this.s=e,this.recovery=r,this.assertValidity()}static fromCompact(t){const r=e.nByteLength;return t=H_("compactSignature",t,2*r),new y(p(t,0,r),p(t,r,2*r))}static fromDER(t){const{r:e,s:r}=gA.toSig(H_("DER",t));return new y(e,r)}assertValidity(){if(!l(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!l(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(t){return new y(this.r,this.s,t)}recoverPublicKey(t){const{r:n,s:i,recovery:o}=this,c=b(H_("msgHash",t));if(null==o||![0,1,2,3].includes(o))throw new Error("recovery id invalid");const h=2===o||3===o?n+e.n:n;if(h>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");const l=0==(1&o)?"02":"03",d=u.fromHex(l+f(h)),p=a(h),y=s(-c*p),g=s(i*p),m=u.BASE.multiplyAndAddUnsafe(d,y,g);if(!m)throw new Error("point at infinify");return m.assertValidity(),m}hasHighS(){return d(this.s)}normalizeS(){return this.hasHighS()?new y(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return W_(this.toDERHex())}toDERHex(){return gA.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return W_(this.toCompactHex())}toCompactHex(){return f(this.r)+f(this.s)}}const g={isValidPrivateKey(t){try{return c(t),!0}catch(t){return!1}},normPrivateKeyToScalar:c,randomPrivateKey:()=>{const t=gk(e.n);return function(t,e,r=!1){const n=t.length,i=yk(e),o=gk(e);if(n<16||n<o||n>1024)throw new Error(`expected ${o}-1024 bytes of input, got ${n}`);const s=uk(r?K_(t):F_(t),e-rk)+rk;return r?V_(s,i):q_(s,i)}(e.randomBytes(t),e.n)},precompute:(t=8,e=u.BASE)=>(e._setWindowSize(t),e.multiply(BigInt(3)),e)};function m(t){const e=t instanceof Uint8Array,r="string"==typeof t,n=(e||r)&&t.length;return e?n===i||n===o:r?n===2*i||n===2*o:t instanceof u}const w=e.bits2int||function(t){const r=K_(t),n=8*t.length-e.nBitLength;return n>0?r>>BigInt(n):r},b=e.bits2int_modN||function(t){return s(w(t))},v=G_(e.nBitLength);function _(t){if("bigint"!=typeof t)throw new Error("bigint expected");if(!(mA<=t&&t<v))throw new Error(`bigint expected < 2^${e.nBitLength}`);return q_(t,e.nByteLength)}function k(t,n,i=E){if(["recovered","canonical"].some((t=>t in i)))throw new Error("sign() legacy options not supported");const{hash:o,randomBytes:h}=e;let{lowS:f,prehash:p,extraEntropy:g}=i;null==f&&(f=!0),t=H_("msgHash",t),p&&(t=H_("prehashed msgHash",o(t)));const m=b(t),v=c(n),k=[_(v),_(m)];if(null!=g){const t=!0===g?h(r.BYTES):g;k.push(H_("extraEntropy",t))}const x=$_(...k),S=m;return{seed:x,k2sig:function(t){const e=w(t);if(!l(e))return;const r=a(e),n=u.BASE.multiply(e).toAffine(),i=s(n.x);if(i===mA)return;const o=s(r*s(S+i*v));if(o===mA)return;let c=(n.x===i?0:2)|Number(n.y&wA),h=o;return f&&d(o)&&(h=function(t){return d(t)?s(-t):t}(o),c^=1),new y(i,h,c)}}}const E={lowS:e.lowS,prehash:!1},x={lowS:e.lowS,prehash:!1};return u.BASE._setWindowSize(8),{CURVE:e,getPublicKey:function(t,e=!0){return u.fromPrivateKey(t).toRawBytes(e)},getSharedSecret:function(t,e,r=!0){if(m(t))throw new Error("first arg must be private key");if(!m(e))throw new Error("second arg must be public key");return u.fromHex(e).multiply(c(t)).toRawBytes(r)},sign:function(t,r,n=E){const{seed:i,k2sig:o}=k(t,r,n),s=e;return J_(s.hash.outputLen,s.nByteLength,s.hmac)(i,o)},verify:function(t,r,n,i=x){const o=t;if(r=H_("msgHash",r),n=H_("publicKey",n),"strict"in i)throw new Error("options.strict was renamed to lowS");const{lowS:c,prehash:h}=i;let l,f;try{if("string"==typeof o||o instanceof Uint8Array)try{l=y.fromDER(o)}catch(t){if(!(t instanceof gA.Err))throw t;l=y.fromCompact(o)}else{if("object"!=typeof o||"bigint"!=typeof o.r||"bigint"!=typeof o.s)throw new Error("PARSE");{const{r:t,s:e}=o;l=new y(t,e)}}f=u.fromHex(n)}catch(t){if("PARSE"===t.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(c&&l.hasHighS())return!1;h&&(r=e.hash(r));const{r:d,s:p}=l,g=b(r),m=a(p),w=s(g*m),v=s(d*m),_=u.BASE.multiplyAndAddUnsafe(f,w,v)?.toAffine();return!!_&&s(_.x)===d},ProjectivePoint:u,Signature:y,utils:g}}BigInt(4);class _A extends w_{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,function(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");h_(t.outputLen),h_(t.blockLen)}(t);const r=m_(e);if(this.iHash=t.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?t.create().update(r).digest():r);for(let t=0;t<i.length;t++)i[t]^=54;this.iHash.update(i),this.oHash=t.create();for(let t=0;t<i.length;t++)i[t]^=106;this.oHash.update(i),i.fill(0)}update(t){return f_(this),this.iHash.update(t),this}digestInto(t){f_(this),l_(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:r,finished:n,destroyed:i,blockLen:o,outputLen:s}=this;return t.finished=n,t.destroyed=i,t.blockLen=o,t.outputLen=s,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const kA=(t,e,r)=>new _A(t,e).update(r).digest()
|
|
41
|
+
t.exports=r=function(){return i},t.exports.__esModule=!0,t.exports.default=t.exports;var n,i={},o=Object.prototype,s=o.hasOwnProperty,a=Object.defineProperty||function(t,e,r){t[e]=r.value},u="function"==typeof Symbol?Symbol:{},c=u.iterator||"@@iterator",h=u.asyncIterator||"@@asyncIterator",l=u.toStringTag||"@@toStringTag";function f(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{f({},"")}catch(n){f=function(t,e,r){return t[e]=r}}function d(t,e,r,n){var i=e&&e.prototype instanceof v?e:v,o=Object.create(i.prototype),s=new L(n||[]);return a(o,"_invoke",{value:M(t,r,s)}),o}function p(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}i.wrap=d;var y="suspendedStart",g="suspendedYield",m="executing",w="completed",b={};function v(){}function _(){}function k(){}var E={};f(E,c,(function(){return this}));var x=Object.getPrototypeOf,S=x&&x(x(O([])));S&&S!==o&&s.call(S,c)&&(E=S);var A=k.prototype=v.prototype=Object.create(E);function I(t){["next","throw","return"].forEach((function(e){f(t,e,(function(t){return this._invoke(e,t)}))}))}function B(t,r){function n(i,o,a,u){var c=p(t[i],t,o);if("throw"!==c.type){var h=c.arg,l=h.value;return l&&"object"==e(l)&&s.call(l,"__await")?r.resolve(l.__await).then((function(t){n("next",t,a,u)}),(function(t){n("throw",t,a,u)})):r.resolve(l).then((function(t){h.value=t,a(h)}),(function(t){return n("throw",t,a,u)}))}u(c.arg)}var i;a(this,"_invoke",{value:function(t,e){function o(){return new r((function(r,i){n(t,e,r,i)}))}return i=i?i.then(o,o):o()}})}function M(t,e,r){var i=y;return function(o,s){if(i===m)throw new Error("Generator is already running");if(i===w){if("throw"===o)throw s;return{value:n,done:!0}}for(r.method=o,r.arg=s;;){var a=r.delegate;if(a){var u=R(a,r);if(u){if(u===b)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===y)throw i=w,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=m;var c=p(t,e,r);if("normal"===c.type){if(i=r.done?w:g,c.arg===b)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(i=w,r.method="throw",r.arg=c.arg)}}}function R(t,e){var r=e.method,i=t.iterator[r];if(i===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=n,R(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),b;var o=p(i,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,b;var s=o.arg;return s?s.done?(e[t.resultName]=s.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=n),e.delegate=null,b):s:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,b)}function P(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function L(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(P,this),this.reset(!0)}function O(t){if(t||""===t){var r=t[c];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function e(){for(;++i<t.length;)if(s.call(t,i))return e.value=t[i],e.done=!1,e;return e.value=n,e.done=!0,e};return o.next=o}}throw new TypeError(e(t)+" is not iterable")}return _.prototype=k,a(A,"constructor",{value:k,configurable:!0}),a(k,"constructor",{value:_,configurable:!0}),_.displayName=f(k,l,"GeneratorFunction"),i.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===_||"GeneratorFunction"===(e.displayName||e.name))},i.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,k):(t.__proto__=k,f(t,l,"GeneratorFunction")),t.prototype=Object.create(A),t},i.awrap=function(t){return{__await:t}},I(B.prototype),f(B.prototype,h,(function(){return this})),i.AsyncIterator=B,i.async=function(t,e,r,n,o){void 0===o&&(o=Promise);var s=new B(d(t,e,r,n),o);return i.isGeneratorFunction(e)?s:s.next().then((function(t){return t.done?t.value:s.next()}))},I(A),f(A,l,"Generator"),f(A,c,(function(){return this})),f(A,"toString",(function(){return"[object Generator]"})),i.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},i.values=O,L.prototype={constructor:L,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=n,this.done=!1,this.delegate=null,this.method="next",this.arg=n,this.tryEntries.forEach(T),!t)for(var e in this)"t"===e.charAt(0)&&s.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=n)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,i){return a.type="throw",a.arg=t,e.next=r,i&&(e.method="next",e.arg=n),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var u=s.call(o,"catchLoc"),c=s.call(o,"finallyLoc");if(u&&c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&s.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=t,o.arg=e,i?(this.method="next",this.next=i.finallyLoc,b):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),b},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),b}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:O(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=n),b}},i}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}(CS)),CS.exports)();LS=t;try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}return LS}()),n=e((DS||(DS=1,function(t){function e(t,e,r,n,i,o,s){try{var a=t[o](s),u=a.value}catch(t){return void r(t)}a.done?e(u):Promise.resolve(u).then(n,i)}t.exports=function(t){return function(){var r=this,n=arguments;return new Promise((function(i,o){var s=t.apply(r,n);function a(t){e(s,i,o,a,u,"next",t)}function u(t){e(s,i,o,a,u,"throw",t)}a(void 0)}))}},t.exports.__esModule=!0,t.exports.default=t.exports}(WS)),WS.exports)),i=e(zS()),o=e(KS()),s=e(JS()),a=e(rA()),u=e(aA()),c=e(hA());function h(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=(0,c.default)(t);if(e){var i=(0,c.default)(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return(0,u.default)(this,r)}}var l=function(t){(0,a.default)(d,t);var e,u,c,l,f=h(d);function d(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"ws://localhost:8080",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3?arguments[3]:void 0;(0,o.default)(this,d);var s=n.autoconnect,a=void 0===s||s,u=n.reconnect,c=void 0===u||u,h=n.reconnect_interval,l=void 0===h?1e3:h,p=n.max_reconnects,y=void 0===p?5:p,g=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]])}return r}(n,["autoconnect","reconnect","reconnect_interval","max_reconnects"]);return(e=f.call(this)).webSocketFactory=t,e.queue={},e.rpc_id=0,e.address=r,e.autoconnect=a,e.ready=!1,e.reconnect=c,e.reconnect_timer_id=void 0,e.reconnect_interval=l,e.max_reconnects=y,e.rest_options=g,e.current_reconnects=0,e.generate_request_id=i||function(){return++e.rpc_id},e.autoconnect&&e._connect(e.address,Object.assign({autoconnect:e.autoconnect,reconnect:e.reconnect,reconnect_interval:e.reconnect_interval,max_reconnects:e.max_reconnects},e.rest_options)),e}return(0,s.default)(d,[{key:"connect",value:function(){this.socket||this._connect(this.address,Object.assign({autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects},this.rest_options))}},{key:"call",value:function(t,e,r,n){var o=this;return n||"object"!==(0,i.default)(r)||(n=r,r=null),new Promise((function(i,s){if(!o.ready)return s(new Error("socket not ready"));var a=o.generate_request_id(t,e),u={jsonrpc:"2.0",method:t,params:e||null,id:a};o.socket.send(JSON.stringify(u),n,(function(t){if(t)return s(t);o.queue[a]={promise:[i,s]},r&&(o.queue[a].timeout=setTimeout((function(){delete o.queue[a],s(new Error("reply timeout"))}),r))}))}))}},{key:"login",value:(l=(0,n.default)(r.default.mark((function t(e){var n;return r.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.call("rpc.login",e);case 2:if(n=t.sent){t.next=5;break}throw new Error("authentication failed");case 5:return t.abrupt("return",n);case 6:case"end":return t.stop()}}),t,this)}))),function(t){return l.apply(this,arguments)})},{key:"listMethods",value:(c=(0,n.default)(r.default.mark((function t(){return r.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.call("__listMethods");case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)}))),function(){return c.apply(this,arguments)})},{key:"notify",value:function(t,e){var r=this;return new Promise((function(n,i){if(!r.ready)return i(new Error("socket not ready"));var o={jsonrpc:"2.0",method:t,params:e||null};r.socket.send(JSON.stringify(o),(function(t){if(t)return i(t);n()}))}))}},{key:"subscribe",value:(u=(0,n.default)(r.default.mark((function t(e){var n;return r.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return"string"==typeof e&&(e=[e]),t.next=3,this.call("rpc.on",e);case 3:if(n=t.sent,"string"!=typeof e||"ok"===n[e]){t.next=6;break}throw new Error("Failed subscribing to an event '"+e+"' with: "+n[e]);case 6:return t.abrupt("return",n);case 7:case"end":return t.stop()}}),t,this)}))),function(t){return u.apply(this,arguments)})},{key:"unsubscribe",value:(e=(0,n.default)(r.default.mark((function t(e){var n;return r.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return"string"==typeof e&&(e=[e]),t.next=3,this.call("rpc.off",e);case 3:if(n=t.sent,"string"!=typeof e||"ok"===n[e]){t.next=6;break}throw new Error("Failed unsubscribing from an event with: "+n);case 6:return t.abrupt("return",n);case 7:case"end":return t.stop()}}),t,this)}))),function(t){return e.apply(this,arguments)})},{key:"close",value:function(t,e){this.socket.close(t||1e3,e)}},{key:"_connect",value:function(t,e){var r=this;clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(t,e),this.socket.addEventListener("open",(function(){r.ready=!0,r.emit("open"),r.current_reconnects=0})),this.socket.addEventListener("message",(function(t){var e=t.data;e instanceof ArrayBuffer&&(e=Buffer.from(e).toString());try{e=JSON.parse(e)}catch(t){return}if(e.notification&&r.listeners(e.notification).length){if(!Object.keys(e.params).length)return r.emit(e.notification);var n=[e.notification];if(e.params.constructor===Object)n.push(e.params);else for(var i=0;i<e.params.length;i++)n.push(e.params[i]);return Promise.resolve().then((function(){r.emit.apply(r,n)}))}if(!r.queue[e.id])return e.method&&e.params?Promise.resolve().then((function(){r.emit(e.method,e.params)})):void 0;"error"in e=="result"in e&&r.queue[e.id].promise[1](new Error('Server response malformed. Response must include either "result" or "error", but not both.')),r.queue[e.id].timeout&&clearTimeout(r.queue[e.id].timeout),e.error?r.queue[e.id].promise[1](e.error):r.queue[e.id].promise[0](e.result),delete r.queue[e.id]})),this.socket.addEventListener("error",(function(t){return r.emit("error",t)})),this.socket.addEventListener("close",(function(n){var i=n.code,o=n.reason;r.ready&&setTimeout((function(){return r.emit("close",i,o)}),0),r.ready=!1,r.socket=void 0,1e3!==i&&(r.current_reconnects++,r.reconnect&&(r.max_reconnects>r.current_reconnects||0===r.max_reconnects)&&(r.reconnect_timer_id=setTimeout((function(){return r._connect(t,e)}),r.reconnect_interval)))}))}}]),d}(dA().EventEmitter);t.default=l}({}),function(t){var e=US;Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(t,e){return new u(t,e)};var r=e(KS()),n=e(JS()),i=e(rA()),o=e(aA()),s=e(hA());function a(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var r,n=(0,s.default)(t);if(e){var i=(0,s.default)(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return(0,o.default)(this,r)}}var u=function(t){(0,i.default)(o,t);var e=a(o);function o(t,n,i){var s;return(0,r.default)(this,o),(s=e.call(this)).socket=new window.WebSocket(t,i),s.socket.onopen=function(){return s.emit("open")},s.socket.onmessage=function(t){return s.emit("message",t.data)},s.socket.onerror=function(t){return s.emit("error",t)},s.socket.onclose=function(t){s.emit("close",t.code,t.reason)},s}return(0,n.default)(o,[{key:"send",value:function(t,e,r){var n=r||e;try{this.socket.send(t),n()}catch(t){n(t)}}},{key:"close",value:function(t,e){this.socket.close(t,e)}},{key:"addEventListener",value:function(t,e,r){this.socket.addEventListener(t,e,r)}}]),o}(dA().EventEmitter)}({});const{bytesToNumberBE:pA,hexToBytes:yA}=tk,gA={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(t){const{Err:e}=gA;if(t.length<2||2!==t[0])throw new e("Invalid signature integer tag");const r=t[1],n=t.subarray(2,r+2);if(!r||n.length!==r)throw new e("Invalid signature integer: wrong length");if(128&n[0])throw new e("Invalid signature integer: negative");if(0===n[0]&&!(128&n[1]))throw new e("Invalid signature integer: unnecessary leading zero");return{d:pA(n),l:t.subarray(r+2)}},toSig(t){const{Err:e}=gA,r="string"==typeof t?yA(t):t;if(!(r instanceof Uint8Array))throw new Error("ui8a expected");let n=r.length;if(n<2||48!=r[0])throw new e("Invalid signature tag");if(r[1]!==n-2)throw new e("Invalid signature: incorrect length");const{d:i,l:o}=gA._parseInt(r.subarray(2)),{d:s,l:a}=gA._parseInt(o);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:i,s:s}},hexFromSig(t){const e=t=>8&Number.parseInt(t[0],16)?"00"+t:t,r=t=>{const e=t.toString(16);return 1&e.length?`0${e}`:e},n=e(r(t.s)),i=e(r(t.r)),o=n.length/2,s=i.length/2,a=r(o),u=r(s);return`30${r(s+o+4)}02${u}${i}02${a}${n}`}},mA=BigInt(0),wA=BigInt(1);BigInt(2);const bA=BigInt(3);function vA(t){const e=function(t){const e=vk(t);return Q_(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}(t),{Fp:r,n:n}=e,i=r.BYTES+1,o=2*r.BYTES+1;function s(t){return uk(t,n)}function a(t){return lk(t,n)}const{ProjectivePoint:u,normPrivateKeyToScalar:c,weierstrassEquation:h,isWithinCurveOrder:l}=function(t){const e=/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
42
|
+
function(t){const e=vk(t);Q_(e,{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}=e;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({...e})}(t),{Fp:r}=e,n=e.toBytes||((t,e,n)=>{const i=e.toAffine();return $_(Uint8Array.from([4]),r.toBytes(i.x),r.toBytes(i.y))}),i=e.fromBytes||(t=>{const e=t.subarray(1);return{x:r.fromBytes(e.subarray(0,r.BYTES)),y:r.fromBytes(e.subarray(r.BYTES,2*r.BYTES))}});function o(t){const{a:n,b:i}=e,o=r.sqr(t),s=r.mul(o,t);return r.add(r.add(s,r.mul(t,n)),i)}if(!r.eql(r.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function s(t){return"bigint"==typeof t&&mA<t&&t<e.n}function a(t){if(!s(t))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function u(t){const{allowedPrivateKeyLengths:r,nByteLength:n,wrapPrivateKey:i,n:o}=e;if(r&&"bigint"!=typeof t){if(t instanceof Uint8Array&&(t=z_(t)),"string"!=typeof t||!r.includes(t.length))throw new Error("Invalid key");t=t.padStart(2*n,"0")}let s;try{s="bigint"==typeof t?t:F_(H_("private key",t,n))}catch(e){throw new Error(`private key must be ${n} bytes, hex or bigint, not ${typeof t}`)}return i&&(s=uk(s,o)),a(s),s}const c=new Map;function h(t){if(!(t instanceof l))throw new Error("ProjectivePoint expected")}class l{constructor(t,e,n){if(this.px=t,this.py=e,this.pz=n,null==t||!r.isValid(t))throw new Error("x required");if(null==e||!r.isValid(e))throw new Error("y required");if(null==n||!r.isValid(n))throw new Error("z required")}static fromAffine(t){const{x:e,y:n}=t||{};if(!t||!r.isValid(e)||!r.isValid(n))throw new Error("invalid affine point");if(t instanceof l)throw new Error("projective point not allowed");const i=t=>r.eql(t,r.ZERO);return i(e)&&i(n)?l.ZERO:new l(e,n,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(t){const e=r.invertBatch(t.map((t=>t.pz)));return t.map(((t,r)=>t.toAffine(e[r]))).map(l.fromAffine)}static fromHex(t){const e=l.fromAffine(i(H_("pointHex",t)));return e.assertValidity(),e}static fromPrivateKey(t){return l.BASE.multiply(u(t))}_setWindowSize(t){this._WINDOW_SIZE=t,c.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!r.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:t,y:n}=this.toAffine();if(!r.isValid(t)||!r.isValid(n))throw new Error("bad point: x or y not FE");const i=r.sqr(n),s=o(t);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:t}=this.toAffine();if(r.isOdd)return!r.isOdd(t);throw new Error("Field doesn't support isOdd")}equals(t){h(t);const{px:e,py:n,pz:i}=this,{px:o,py:s,pz:a}=t,u=r.eql(r.mul(e,a),r.mul(o,i)),c=r.eql(r.mul(n,a),r.mul(s,i));return u&&c}negate(){return new l(this.px,r.neg(this.py),this.pz)}double(){const{a:t,b:n}=e,i=r.mul(n,bA),{px:o,py:s,pz:a}=this;let u=r.ZERO,c=r.ZERO,h=r.ZERO,f=r.mul(o,o),d=r.mul(s,s),p=r.mul(a,a),y=r.mul(o,s);return y=r.add(y,y),h=r.mul(o,a),h=r.add(h,h),u=r.mul(t,h),c=r.mul(i,p),c=r.add(u,c),u=r.sub(d,c),c=r.add(d,c),c=r.mul(u,c),u=r.mul(y,u),h=r.mul(i,h),p=r.mul(t,p),y=r.sub(f,p),y=r.mul(t,y),y=r.add(y,h),h=r.add(f,f),f=r.add(h,f),f=r.add(f,p),f=r.mul(f,y),c=r.add(c,f),p=r.mul(s,a),p=r.add(p,p),f=r.mul(p,y),u=r.sub(u,f),h=r.mul(p,d),h=r.add(h,h),h=r.add(h,h),new l(u,c,h)}add(t){h(t);const{px:n,py:i,pz:o}=this,{px:s,py:a,pz:u}=t;let c=r.ZERO,f=r.ZERO,d=r.ZERO;const p=e.a,y=r.mul(e.b,bA);let g=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(g,m),b=r.sub(b,v),v=r.add(n,o);let _=r.add(s,u);return v=r.mul(v,_),_=r.add(g,w),v=r.sub(v,_),_=r.add(i,o),c=r.add(a,u),_=r.mul(_,c),c=r.add(m,w),_=r.sub(_,c),d=r.mul(p,v),c=r.mul(y,w),d=r.add(c,d),c=r.sub(m,d),d=r.add(m,d),f=r.mul(c,d),m=r.add(g,g),m=r.add(m,g),w=r.mul(p,w),v=r.mul(y,v),m=r.add(m,w),w=r.sub(g,w),w=r.mul(p,w),v=r.add(v,w),g=r.mul(m,v),f=r.add(f,g),g=r.mul(_,v),c=r.mul(b,c),c=r.sub(c,g),g=r.mul(b,m),d=r.mul(_,d),d=r.add(d,g),new l(c,f,d)}subtract(t){return this.add(t.negate())}is0(){return this.equals(l.ZERO)}wNAF(t){return d.wNAFCached(this,c,t,(t=>{const e=r.invertBatch(t.map((t=>t.pz)));return t.map(((t,r)=>t.toAffine(e[r]))).map(l.fromAffine)}))}multiplyUnsafe(t){const n=l.ZERO;if(t===mA)return n;if(a(t),t===wA)return this;const{endo:i}=e;if(!i)return d.unsafeLadder(this,t);let{k1neg:o,k1:s,k2neg:u,k2:c}=i.splitScalar(t),h=n,f=n,p=this;for(;s>mA||c>mA;)s&wA&&(h=h.add(p)),c&wA&&(f=f.add(p)),p=p.double(),s>>=wA,c>>=wA;return o&&(h=h.negate()),u&&(f=f.negate()),f=new l(r.mul(f.px,i.beta),f.py,f.pz),h.add(f)}multiply(t){a(t);let n,i,o=t;const{endo:s}=e;if(s){const{k1neg:t,k1:e,k2neg:a,k2:u}=s.splitScalar(o);let{p:c,f:h}=this.wNAF(e),{p:f,f:p}=this.wNAF(u);c=d.constTimeNegate(t,c),f=d.constTimeNegate(a,f),f=new l(r.mul(f.px,s.beta),f.py,f.pz),n=c.add(f),i=h.add(p)}else{const{p:t,f:e}=this.wNAF(o);n=t,i=e}return l.normalizeZ([n,i])[0]}multiplyAndAddUnsafe(t,e,r){const n=l.BASE,i=(t,e)=>e!==mA&&e!==wA&&t.equals(n)?t.multiply(e):t.multiplyUnsafe(e),o=i(this,e).add(i(t,r));return o.is0()?void 0:o}toAffine(t){const{px:e,py:n,pz:i}=this,o=this.is0();null==t&&(t=o?r.ONE:r.inv(i));const s=r.mul(e,t),a=r.mul(n,t),u=r.mul(i,t);if(o)return{x:r.ZERO,y:r.ZERO};if(!r.eql(u,r.ONE))throw new Error("invZ was invalid");return{x:s,y:a}}isTorsionFree(){const{h:t,isTorsionFree:r}=e;if(t===wA)return!0;if(r)return r(l,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:t,clearCofactor:r}=e;return t===wA?this:r?r(l,this):this.multiplyUnsafe(e.h)}toRawBytes(t=!0){return this.assertValidity(),n(l,this,t)}toHex(t=!0){return z_(this.toRawBytes(t))}}l.BASE=new l(e.Gx,e.Gy,r.ONE),l.ZERO=new l(r.ZERO,r.ONE,r.ZERO);const f=e.nBitLength,d=bk(l,e.endo?Math.ceil(f/2):f);return{CURVE:e,ProjectivePoint:l,normPrivateKeyToScalar:u,weierstrassEquation:o,isWithinCurveOrder:s}}({...e,toBytes(t,e,n){const i=e.toAffine(),o=r.toBytes(i.x),s=$_;return n?s(Uint8Array.from([e.hasEvenY()?2:3]),o):s(Uint8Array.from([4]),o,r.toBytes(i.y))},fromBytes(t){const e=t.length,n=t[0],s=t.subarray(1);if(e!==i||2!==n&&3!==n){if(e===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 ${e} was invalid. Expected ${i} compressed bytes or ${o} uncompressed bytes`)}{const t=F_(s);if(!(mA<(a=t)&&a<r.ORDER))throw new Error("Point is not on curve");const e=h(t);let i=r.sqrt(e);return 1==(1&n)!=((i&wA)===wA)&&(i=r.neg(i)),{x:t,y:i}}var a}}),f=t=>z_(V_(t,e.nByteLength));function d(t){return t>n>>wA}const p=(t,e,r)=>F_(t.slice(e,r));class y{constructor(t,e,r){this.r=t,this.s=e,this.recovery=r,this.assertValidity()}static fromCompact(t){const r=e.nByteLength;return t=H_("compactSignature",t,2*r),new y(p(t,0,r),p(t,r,2*r))}static fromDER(t){const{r:e,s:r}=gA.toSig(H_("DER",t));return new y(e,r)}assertValidity(){if(!l(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!l(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(t){return new y(this.r,this.s,t)}recoverPublicKey(t){const{r:n,s:i,recovery:o}=this,c=b(H_("msgHash",t));if(null==o||![0,1,2,3].includes(o))throw new Error("recovery id invalid");const h=2===o||3===o?n+e.n:n;if(h>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");const l=0==(1&o)?"02":"03",d=u.fromHex(l+f(h)),p=a(h),y=s(-c*p),g=s(i*p),m=u.BASE.multiplyAndAddUnsafe(d,y,g);if(!m)throw new Error("point at infinify");return m.assertValidity(),m}hasHighS(){return d(this.s)}normalizeS(){return this.hasHighS()?new y(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return W_(this.toDERHex())}toDERHex(){return gA.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return W_(this.toCompactHex())}toCompactHex(){return f(this.r)+f(this.s)}}const g={isValidPrivateKey(t){try{return c(t),!0}catch(t){return!1}},normPrivateKeyToScalar:c,randomPrivateKey:()=>{const t=gk(e.n);return function(t,e,r=!1){const n=t.length,i=yk(e),o=gk(e);if(n<16||n<o||n>1024)throw new Error(`expected ${o}-1024 bytes of input, got ${n}`);const s=uk(r?F_(t):K_(t),e-rk)+rk;return r?q_(s,i):V_(s,i)}(e.randomBytes(t),e.n)},precompute:(t=8,e=u.BASE)=>(e._setWindowSize(t),e.multiply(BigInt(3)),e)};function m(t){const e=t instanceof Uint8Array,r="string"==typeof t,n=(e||r)&&t.length;return e?n===i||n===o:r?n===2*i||n===2*o:t instanceof u}const w=e.bits2int||function(t){const r=F_(t),n=8*t.length-e.nBitLength;return n>0?r>>BigInt(n):r},b=e.bits2int_modN||function(t){return s(w(t))},v=G_(e.nBitLength);function _(t){if("bigint"!=typeof t)throw new Error("bigint expected");if(!(mA<=t&&t<v))throw new Error(`bigint expected < 2^${e.nBitLength}`);return V_(t,e.nByteLength)}function k(t,n,i=E){if(["recovered","canonical"].some((t=>t in i)))throw new Error("sign() legacy options not supported");const{hash:o,randomBytes:h}=e;let{lowS:f,prehash:p,extraEntropy:g}=i;null==f&&(f=!0),t=H_("msgHash",t),p&&(t=H_("prehashed msgHash",o(t)));const m=b(t),v=c(n),k=[_(v),_(m)];if(null!=g){const t=!0===g?h(r.BYTES):g;k.push(H_("extraEntropy",t))}const x=$_(...k),S=m;return{seed:x,k2sig:function(t){const e=w(t);if(!l(e))return;const r=a(e),n=u.BASE.multiply(e).toAffine(),i=s(n.x);if(i===mA)return;const o=s(r*s(S+i*v));if(o===mA)return;let c=(n.x===i?0:2)|Number(n.y&wA),h=o;return f&&d(o)&&(h=function(t){return d(t)?s(-t):t}(o),c^=1),new y(i,h,c)}}}const E={lowS:e.lowS,prehash:!1},x={lowS:e.lowS,prehash:!1};return u.BASE._setWindowSize(8),{CURVE:e,getPublicKey:function(t,e=!0){return u.fromPrivateKey(t).toRawBytes(e)},getSharedSecret:function(t,e,r=!0){if(m(t))throw new Error("first arg must be private key");if(!m(e))throw new Error("second arg must be public key");return u.fromHex(e).multiply(c(t)).toRawBytes(r)},sign:function(t,r,n=E){const{seed:i,k2sig:o}=k(t,r,n),s=e;return J_(s.hash.outputLen,s.nByteLength,s.hmac)(i,o)},verify:function(t,r,n,i=x){const o=t;if(r=H_("msgHash",r),n=H_("publicKey",n),"strict"in i)throw new Error("options.strict was renamed to lowS");const{lowS:c,prehash:h}=i;let l,f;try{if("string"==typeof o||o instanceof Uint8Array)try{l=y.fromDER(o)}catch(t){if(!(t instanceof gA.Err))throw t;l=y.fromCompact(o)}else{if("object"!=typeof o||"bigint"!=typeof o.r||"bigint"!=typeof o.s)throw new Error("PARSE");{const{r:t,s:e}=o;l=new y(t,e)}}f=u.fromHex(n)}catch(t){if("PARSE"===t.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(c&&l.hasHighS())return!1;h&&(r=e.hash(r));const{r:d,s:p}=l,g=b(r),m=a(p),w=s(g*m),v=s(d*m),_=u.BASE.multiplyAndAddUnsafe(f,w,v)?.toAffine();return!!_&&s(_.x)===d},ProjectivePoint:u,Signature:y,utils:g}}BigInt(4);class _A extends w_{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,function(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");h_(t.outputLen),h_(t.blockLen)}(t);const r=m_(e);if(this.iHash=t.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?t.create().update(r).digest():r);for(let t=0;t<i.length;t++)i[t]^=54;this.iHash.update(i),this.oHash=t.create();for(let t=0;t<i.length;t++)i[t]^=106;this.oHash.update(i),i.fill(0)}update(t){return f_(this),this.iHash.update(t),this}digestInto(t){f_(this),l_(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:r,finished:n,destroyed:i,blockLen:o,outputLen:s}=this;return t.finished=n,t.destroyed=i,t.blockLen=o,t.outputLen=s,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const kA=(t,e,r)=>new _A(t,e).update(r).digest()
|
|
43
43
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */;function EA(t){return{hash:t,hmac:(e,...r)=>kA(t,e,function(...t){const e=new Uint8Array(t.reduce(((t,e)=>t+e.length),0));let r=0;return t.forEach((t=>{if(!p_(t))throw new Error("Uint8Array expected");e.set(t,r),r+=t.length})),e}(...r)),randomBytes:v_}}kA.create=(t,e)=>new _A(t,e)
|
|
44
|
-
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */;const xA=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),SA=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),AA=BigInt(1),IA=BigInt(2),BA=(t,e)=>(t+e/IA)/e,MA=pk(xA,void 0,void 0,{sqrt:function(t){const e=xA,r=BigInt(3),n=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),a=BigInt(44),u=BigInt(88),c=t*t*t%e,h=c*c*t%e,l=hk(h,r,e)*h%e,f=hk(l,r,e)*h%e,d=hk(f,IA,e)*c%e,p=hk(d,i,e)*d%e,y=hk(p,o,e)*p%e,g=hk(y,a,e)*y%e,m=hk(g,u,e)*g%e,w=hk(m,a,e)*y%e,b=hk(w,r,e)*h%e,v=hk(b,s,e)*p%e,_=hk(v,n,e)*c%e,k=hk(_,IA,e);if(!MA.eql(MA.sqr(k),t))throw new Error("Cannot find square root");return k}}),RA=function(t,e){const r=e=>vA({...t,...EA(e)});return Object.freeze({...r(e),create:r})}({a:BigInt(0),b:BigInt(7),Fp:MA,n:SA,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=SA,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-AA*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=r,s=BigInt("0x100000000000000000000000000000000"),a=BA(o*t,e),u=BA(-n*t,e);let c=uk(t-a*r-u*i,e),h=uk(-a*n-u*o,e);const l=c>s,f=h>s;if(l&&(c=e-c),f&&(h=e-h),c>s||h>s)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:l,k1:c,k2neg:f,k2:h}}}},Xk);function PA(t){try{return Nk.ExtendedPoint.fromHex(t),!0}catch{return!1}}BigInt(0),RA.ProjectivePoint;const TA=Nk.verify,OA=t=>t_.Buffer.isBuffer(t)?t:t instanceof Uint8Array?t_.Buffer.from(t.buffer,t.byteOffset,t.byteLength):t_.Buffer.from(t);class LA{constructor(t){Object.assign(this,t)}encode(){return t_.Buffer.from(ME(UA,this))}static decode(t){return TE(UA,this,t)}static decodeUnchecked(t){return gE(UA,this,t)}}const UA=new Map;var CA;let NA;const zA=32;let DA=1;NA=Symbol.toStringTag;class jA extends LA{constructor(t){if(super({}),this._bn=void 0,function(t){return void 0!==t._bn}(t))this._bn=t._bn;else{if("string"==typeof t){const e=Hk.decode(t);if(e.length!=zA)throw new Error("Invalid public key input");this._bn=new Kk(e)}else this._bn=new Kk(t);if(this._bn.byteLength()>zA)throw new Error("Invalid public key input")}}static unique(){const t=new jA(DA);return DA+=1,new jA(t.toBuffer())}equals(t){return this._bn.eq(t._bn)}toBase58(){return Hk.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){const t=this.toBuffer();return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}toBuffer(){const t=this._bn.toArrayLike(t_.Buffer);if(t.length===zA)return t;const e=t_.Buffer.alloc(32);return t.copy(e,32-t.length),e}get[NA](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(t,e,r){const n=t_.Buffer.concat([t.toBuffer(),t_.Buffer.from(e),r.toBuffer()]),i=Xk(n);return new jA(i)}static createProgramAddressSync(t,e){let r=t_.Buffer.alloc(0);t.forEach((function(t){if(t.length>32)throw new TypeError("Max seed length exceeded");r=t_.Buffer.concat([r,OA(t)])})),r=t_.Buffer.concat([r,e.toBuffer(),t_.Buffer.from("ProgramDerivedAddress")]);const n=Xk(r);if(PA(n))throw new Error("Invalid seeds, address must fall off the curve");return new jA(n)}static async createProgramAddress(t,e){return this.createProgramAddressSync(t,e)}static findProgramAddressSync(t,e){let r,n=255;for(;0!=n;){try{const i=t.concat(t_.Buffer.from([n]));r=this.createProgramAddressSync(i,e)}catch(t){if(t instanceof TypeError)throw t;n--;continue}return[r,n]}throw new Error("Unable to find a viable program address nonce")}static async findProgramAddress(t,e){return this.findProgramAddressSync(t,e)}static isOnCurve(t){return PA(new jA(t).toBytes())}}CA=jA,jA.default=new CA("11111111111111111111111111111111"),UA.set(jA,{kind:"struct",fields:[["_bn","u256"]]}),new jA("BPFLoader1111111111111111111111111111111111");class WA{constructor(t,e){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=t,this.accountKeysFromLookups=e}keySegments(){const t=[this.staticAccountKeys];return this.accountKeysFromLookups&&(t.push(this.accountKeysFromLookups.writable),t.push(this.accountKeysFromLookups.readonly)),t}get(t){for(const e of this.keySegments()){if(t<e.length)return e[t];t-=e.length}}get length(){return this.keySegments().flat().length}compileInstructions(t){if(this.length>256)throw new Error("Account index overflow encountered during compilation");const e=new Map;this.keySegments().flat().forEach(((t,r)=>{e.set(t.toBase58(),r)}));const r=t=>{const r=e.get(t.toBase58());if(void 0===r)throw new Error("Encountered an unknown instruction account key during compilation");return r};return t.map((t=>({programIdIndex:r(t.programId),accountKeyIndexes:t.keys.map((t=>r(t.pubkey))),data:t.data})))}}const KA=(t="publicKey")=>Sx(32,t),FA=(t="string")=>{const e=Ex([vx("length"),vx("lengthPadding"),Sx(mx(vx(),-8),"chars")],t),r=e.decode.bind(e),n=e.encode.bind(e),i=e;return i.decode=(t,e)=>r(t,e).chars.toString(),i.encode=(t,e,r)=>{const i={chars:t_.Buffer.from(t,"utf8")};return n(i,e,r)},i.alloc=t=>vx().span+vx().span+t_.Buffer.from(t,"utf8").length,i};function qA(t,e){const r=t=>{if(t.span>=0)return t.span;if("function"==typeof t.alloc)return t.alloc(e[t.property]);if("count"in t&&"elementLayout"in t){const n=e[t.property];if(Array.isArray(n))return n.length*r(t.elementLayout)}else if("fields"in t)return qA({layout:t},e[t.property]);return 0};let n=0;return t.layout.fields.forEach((t=>{n+=r(t)})),n}function VA(t){let e=0,r=0;for(;;){let n=t.shift();if(e|=(127&n)<<7*r,r+=1,0==(128&n))break}return e}function HA(t,e){let r=e;for(;;){let e=127&r;if(r>>=7,0==r){t.push(e);break}e|=128,t.push(e)}}function $A(t,e){if(!t)throw new Error(e||"Assertion failed")}class GA{constructor(t,e){this.payer=void 0,this.keyMetaMap=void 0,this.payer=t,this.keyMetaMap=e}static compile(t,e){const r=new Map,n=t=>{const e=t.toBase58();let n=r.get(e);return void 0===n&&(n={isSigner:!1,isWritable:!1,isInvoked:!1},r.set(e,n)),n},i=n(e);i.isSigner=!0,i.isWritable=!0;for(const e of t){n(e.programId).isInvoked=!0;for(const t of e.keys){const e=n(t.pubkey);e.isSigner||=t.isSigner,e.isWritable||=t.isWritable}}return new GA(e,r)}getMessageComponents(){const t=[...this.keyMetaMap.entries()];$A(t.length<=256,"Max static account keys length exceeded");const e=t.filter((([,t])=>t.isSigner&&t.isWritable)),r=t.filter((([,t])=>t.isSigner&&!t.isWritable)),n=t.filter((([,t])=>!t.isSigner&&t.isWritable)),i=t.filter((([,t])=>!t.isSigner&&!t.isWritable)),o={numRequiredSignatures:e.length+r.length,numReadonlySignedAccounts:r.length,numReadonlyUnsignedAccounts:i.length};{$A(e.length>0,"Expected at least one writable signer key");const[t]=e[0];$A(t===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}return[o,[...e.map((([t])=>new jA(t))),...r.map((([t])=>new jA(t))),...n.map((([t])=>new jA(t))),...i.map((([t])=>new jA(t)))]]}extractTableLookup(t){const[e,r]=this.drainKeysFoundInLookupTable(t.state.addresses,(t=>!t.isSigner&&!t.isInvoked&&t.isWritable)),[n,i]=this.drainKeysFoundInLookupTable(t.state.addresses,(t=>!t.isSigner&&!t.isInvoked&&!t.isWritable));if(0!==e.length||0!==n.length)return[{accountKey:t.key,writableIndexes:e,readonlyIndexes:n},{writable:r,readonly:i}]}drainKeysFoundInLookupTable(t,e){const r=new Array,n=new Array;for(const[i,o]of this.keyMetaMap.entries())if(e(o)){const e=new jA(i),o=t.findIndex((t=>t.equals(e)));o>=0&&($A(o<256,"Max lookup table index exceeded"),r.push(o),n.push(e),this.keyMetaMap.delete(i))}return[r,n]}}class ZA{constructor(t){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=t.header,this.accountKeys=t.accountKeys.map((t=>new jA(t))),this.recentBlockhash=t.recentBlockhash,this.instructions=t.instructions,this.instructions.forEach((t=>this.indexToProgramIds.set(t.programIdIndex,this.accountKeys[t.programIdIndex])))}get version(){return"legacy"}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map((t=>({programIdIndex:t.programIdIndex,accountKeyIndexes:t.accounts,data:Hk.decode(t.data)})))}get addressTableLookups(){return[]}getAccountKeys(){return new WA(this.staticAccountKeys)}static compile(t){const e=GA.compile(t.instructions,t.payerKey),[r,n]=e.getMessageComponents(),i=new WA(n).compileInstructions(t.instructions).map((t=>({programIdIndex:t.programIdIndex,accounts:t.accountKeyIndexes,data:Hk.encode(t.data)})));return new ZA({header:r,accountKeys:n,recentBlockhash:t.recentBlockhash,instructions:i})}isAccountSigner(t){return t<this.header.numRequiredSignatures}isAccountWritable(t){const e=this.header.numRequiredSignatures;return t>=this.header.numRequiredSignatures?t-e<this.accountKeys.length-e-this.header.numReadonlyUnsignedAccounts:t<e-this.header.numReadonlySignedAccounts}isProgramId(t){return this.indexToProgramIds.has(t)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter(((t,e)=>!this.isProgramId(e)))}serialize(){const t=this.accountKeys.length;let e=[];HA(e,t);const r=this.instructions.map((t=>{const{accounts:e,programIdIndex:r}=t,n=Array.from(Hk.decode(t.data));let i=[];HA(i,e.length);let o=[];return HA(o,n.length),{programIdIndex:r,keyIndicesCount:t_.Buffer.from(i),keyIndices:e,dataLength:t_.Buffer.from(o),data:n}}));let n=[];HA(n,r.length);let i=t_.Buffer.alloc(1232);t_.Buffer.from(n).copy(i);let o=n.length;r.forEach((t=>{const e=Ex([wx("programIdIndex"),Sx(t.keyIndicesCount.length,"keyIndicesCount"),xx(wx("keyIndex"),t.keyIndices.length,"keyIndices"),Sx(t.dataLength.length,"dataLength"),xx(wx("userdatum"),t.data.length,"data")]).encode(t,i,o);o+=e})),i=i.slice(0,o);const s=Ex([Sx(1,"numRequiredSignatures"),Sx(1,"numReadonlySignedAccounts"),Sx(1,"numReadonlyUnsignedAccounts"),Sx(e.length,"keyCount"),xx(KA("key"),t,"keys"),KA("recentBlockhash")]),a={numRequiredSignatures:t_.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:t_.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:t_.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:t_.Buffer.from(e),keys:this.accountKeys.map((t=>OA(t.toBytes()))),recentBlockhash:Hk.decode(this.recentBlockhash)};let u=t_.Buffer.alloc(2048);const c=s.encode(a,u);return i.copy(u,c),u.slice(0,c+i.length)}static from(t){let e=[...t];const r=e.shift();if(r!==(127&r))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const n=e.shift(),i=e.shift(),o=VA(e);let s=[];for(let t=0;t<o;t++){const t=e.slice(0,zA);e=e.slice(zA),s.push(new jA(t_.Buffer.from(t)))}const a=e.slice(0,zA);e=e.slice(zA);const u=VA(e);let c=[];for(let t=0;t<u;t++){const t=e.shift(),r=VA(e),n=e.slice(0,r);e=e.slice(r);const i=VA(e),o=e.slice(0,i),s=Hk.encode(t_.Buffer.from(o));e=e.slice(i),c.push({programIdIndex:t,accounts:n,data:s})}const h={header:{numRequiredSignatures:r,numReadonlySignedAccounts:n,numReadonlyUnsignedAccounts:i},recentBlockhash:Hk.encode(t_.Buffer.from(a)),accountKeys:s,instructions:c};return new ZA(h)}}const YA=t_.Buffer.alloc(64).fill(0);class JA{constructor(t){this.keys=void 0,this.programId=void 0,this.data=t_.Buffer.alloc(0),this.programId=t.programId,this.keys=t.keys,t.data&&(this.data=t.data)}toJSON(){return{keys:this.keys.map((({pubkey:t,isSigner:e,isWritable:r})=>({pubkey:t.toJSON(),isSigner:e,isWritable:r}))),programId:this.programId.toJSON(),data:[...this.data]}}}class XA{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(t){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,t)if(t.feePayer&&(this.feePayer=t.feePayer),t.signatures&&(this.signatures=t.signatures),Object.prototype.hasOwnProperty.call(t,"nonceInfo")){const{minContextSlot:e,nonceInfo:r}=t;this.minNonceContextSlot=e,this.nonceInfo=r}else if(Object.prototype.hasOwnProperty.call(t,"lastValidBlockHeight")){const{blockhash:e,lastValidBlockHeight:r}=t;this.recentBlockhash=e,this.lastValidBlockHeight=r}else{const{recentBlockhash:e,nonceInfo:r}=t;r&&(this.nonceInfo=r),this.recentBlockhash=e}}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((t=>t.toJSON())),signers:this.signatures.map((({publicKey:t})=>t.toJSON()))}}add(...t){if(0===t.length)throw new Error("No instructions");return t.forEach((t=>{"instructions"in t?this.instructions=this.instructions.concat(t.instructions):"data"in t&&"programId"in t&&"keys"in t?this.instructions.push(t):this.instructions.push(new JA(t))})),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let t,e,r;if(this.nonceInfo?(t=this.nonceInfo.nonce,e=this.instructions[0]!=this.nonceInfo.nonceInstruction?[this.nonceInfo.nonceInstruction,...this.instructions]:this.instructions):(t=this.recentBlockhash,e=this.instructions),!t)throw new Error("Transaction recentBlockhash required");if(e.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 t=0;t<e.length;t++)if(void 0===e[t].programId)throw new Error(`Transaction instruction index ${t} has undefined program id`);const n=[],i=[];e.forEach((t=>{t.keys.forEach((t=>{i.push({...t})}));const e=t.programId.toString();n.includes(e)||n.push(e)})),n.forEach((t=>{i.push({pubkey:new jA(t),isSigner:!1,isWritable:!1})}));const o=[];i.forEach((t=>{const e=t.pubkey.toString(),r=o.findIndex((t=>t.pubkey.toString()===e));r>-1?(o[r].isWritable=o[r].isWritable||t.isWritable,o[r].isSigner=o[r].isSigner||t.isSigner):o.push(t)})),o.sort((function(t,e){return t.isSigner!==e.isSigner?t.isSigner?-1:1:t.isWritable!==e.isWritable?t.isWritable?-1:1:t.pubkey.toBase58().localeCompare(e.pubkey.toBase58(),"en",{localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"})}));const s=o.findIndex((t=>t.pubkey.equals(r)));if(s>-1){const[t]=o.splice(s,1);t.isSigner=!0,t.isWritable=!0,o.unshift(t)}else o.unshift({pubkey:r,isSigner:!0,isWritable:!0});for(const t of this.signatures){const e=o.findIndex((e=>e.pubkey.equals(t.publicKey)));if(!(e>-1))throw new Error(`unknown signer: ${t.publicKey.toString()}`);o[e].isSigner||(o[e].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,u=0,c=0;const h=[],l=[];o.forEach((({pubkey:t,isSigner:e,isWritable:r})=>{e?(h.push(t.toString()),a+=1,r||(u+=1)):(l.push(t.toString()),r||(c+=1))}));const f=h.concat(l),d=e.map((t=>{const{data:e,programId:r}=t;return{programIdIndex:f.indexOf(r.toString()),accounts:t.keys.map((t=>f.indexOf(t.pubkey.toString()))),data:Hk.encode(e)}}));return d.forEach((t=>{$A(t.programIdIndex>=0),t.accounts.forEach((t=>$A(t>=0)))})),new ZA({header:{numRequiredSignatures:a,numReadonlySignedAccounts:u,numReadonlyUnsignedAccounts:c},accountKeys:f,recentBlockhash:t,instructions:d})}_compile(){const t=this.compileMessage(),e=t.accountKeys.slice(0,t.header.numRequiredSignatures);return this.signatures.length===e.length&&this.signatures.every(((t,r)=>e[r].equals(t.publicKey)))||(this.signatures=e.map((t=>({signature:null,publicKey:t})))),t}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(t){return(await t.getFeeForMessage(this.compileMessage())).value}setSigners(...t){if(0===t.length)throw new Error("No signers");const e=new Set;this.signatures=t.filter((t=>{const r=t.toString();return!e.has(r)&&(e.add(r),!0)})).map((t=>({signature:null,publicKey:t})))}sign(...t){if(0===t.length)throw new Error("No signers");const e=new Set,r=[];for(const n of t){const t=n.publicKey.toString();e.has(t)||(e.add(t),r.push(n))}this.signatures=r.map((t=>({signature:null,publicKey:t.publicKey})));const n=this._compile();this._partialSign(n,...r)}partialSign(...t){if(0===t.length)throw new Error("No signers");const e=new Set,r=[];for(const n of t){const t=n.publicKey.toString();e.has(t)||(e.add(t),r.push(n))}const n=this._compile();this._partialSign(n,...r)}_partialSign(t,...e){const r=t.serialize();e.forEach((t=>{const e=((t,e)=>Nk.sign(t,e.slice(0,32)))(r,t.secretKey);this._addSignature(t.publicKey,OA(e))}))}addSignature(t,e){this._compile(),this._addSignature(t,e)}_addSignature(t,e){$A(64===e.length);const r=this.signatures.findIndex((e=>t.equals(e.publicKey)));if(r<0)throw new Error(`unknown signer: ${t.toString()}`);this.signatures[r].signature=t_.Buffer.from(e)}verifySignatures(t){return this._verifySignatures(this.serializeMessage(),void 0===t||t)}_verifySignatures(t,e){for(const{signature:r,publicKey:n}of this.signatures)if(null===r){if(e)return!1}else if(!TA(r,t,n.toBytes()))return!1;return!0}serialize(t){const{requireAllSignatures:e,verifySignatures:r}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},t),n=this.serializeMessage();if(r&&!this._verifySignatures(n,e))throw new Error("Signature verification failed");return this._serialize(n)}_serialize(t){const{signatures:e}=this,r=[];HA(r,e.length);const n=r.length+64*e.length+t.length,i=t_.Buffer.alloc(n);return $A(e.length<256),t_.Buffer.from(r).copy(i,0),e.forEach((({signature:t},e)=>{null!==t&&($A(64===t.length,"signature has invalid length"),t_.Buffer.from(t).copy(i,r.length+64*e))})),t.copy(i,r.length+64*e.length),$A(i.length<=1232,`Transaction too large: ${i.length} > 1232`),i}get keys(){return $A(1===this.instructions.length),this.instructions[0].keys.map((t=>t.pubkey))}get programId(){return $A(1===this.instructions.length),this.instructions[0].programId}get data(){return $A(1===this.instructions.length),this.instructions[0].data}static from(t){let e=[...t];const r=VA(e);let n=[];for(let t=0;t<r;t++){const t=e.slice(0,64);e=e.slice(64),n.push(Hk.encode(t_.Buffer.from(t)))}return XA.populate(ZA.from(e),n)}static populate(t,e=[]){const r=new XA;return r.recentBlockhash=t.recentBlockhash,t.header.numRequiredSignatures>0&&(r.feePayer=t.accountKeys[0]),e.forEach(((e,n)=>{const i={signature:e==Hk.encode(YA)?null:Hk.decode(e),publicKey:t.accountKeys[n]};r.signatures.push(i)})),t.instructions.forEach((e=>{const n=e.accounts.map((e=>{const n=t.accountKeys[e];return{pubkey:n,isSigner:r.signatures.some((t=>t.publicKey.toString()===n.toString()))||t.isAccountSigner(e),isWritable:t.isAccountWritable(e)}}));r.instructions.push(new JA({keys:n,programId:t.accountKeys[e.programIdIndex],data:Hk.decode(e.data)}))})),r._message=t,r._json=r.toJSON(),r}}new jA("SysvarC1ock11111111111111111111111111111111"),new jA("SysvarEpochSchedu1e111111111111111111111111"),new jA("Sysvar1nstructions1111111111111111111111111");const QA=new jA("SysvarRecentB1ockHashes11111111111111111111"),tI=new jA("SysvarRent111111111111111111111111111111111");function eI(t,e){const r=t.layout.span>=0?t.layout.span:qA(t,e),n=t_.Buffer.alloc(r),i=Object.assign({instruction:t.index},e);return t.layout.encode(i,n),n}new jA("SysvarRewards111111111111111111111111111111"),new jA("SysvarS1otHashes111111111111111111111111111"),new jA("SysvarS1otHistory11111111111111111111111111"),new jA("SysvarStakeHistory1111111111111111111111111");const rI=_x("lamportsPerSignature"),nI=Ex([vx("version"),vx("state"),KA("authorizedPubkey"),KA("nonce"),Ex([rI],"feeCalculator")]).span,iI=(8,t=>{const e=Sx(8,t),{encode:r,decode:n}=(t=>({decode:t.decode.bind(t),encode:t.encode.bind(t)}))(e),i=e;return i.decode=(t,e)=>{const r=n(t,e);return Ix(t_.Buffer.from(r))},i.encode=(t,e,n)=>{const i=Mx(t,8);return r(i,e,n)},i});const oI=Object.freeze({Create:{index:0,layout:Ex([vx("instruction"),kx("lamports"),kx("space"),KA("programId")])},Assign:{index:1,layout:Ex([vx("instruction"),KA("programId")])},Transfer:{index:2,layout:Ex([vx("instruction"),iI("lamports")])},CreateWithSeed:{index:3,layout:Ex([vx("instruction"),KA("base"),FA("seed"),kx("lamports"),kx("space"),KA("programId")])},AdvanceNonceAccount:{index:4,layout:Ex([vx("instruction")])},WithdrawNonceAccount:{index:5,layout:Ex([vx("instruction"),kx("lamports")])},InitializeNonceAccount:{index:6,layout:Ex([vx("instruction"),KA("authorized")])},AuthorizeNonceAccount:{index:7,layout:Ex([vx("instruction"),KA("authorized")])},Allocate:{index:8,layout:Ex([vx("instruction"),kx("space")])},AllocateWithSeed:{index:9,layout:Ex([vx("instruction"),KA("base"),FA("seed"),kx("space"),KA("programId")])},AssignWithSeed:{index:10,layout:Ex([vx("instruction"),KA("base"),FA("seed"),KA("programId")])},TransferWithSeed:{index:11,layout:Ex([vx("instruction"),iI("lamports"),FA("seed"),KA("programId")])},UpgradeNonceAccount:{index:12,layout:Ex([vx("instruction")])}});class sI{constructor(){}static createAccount(t){const e=eI(oI.Create,{lamports:t.lamports,space:t.space,programId:OA(t.programId.toBuffer())});return new JA({keys:[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:e})}static transfer(t){let e,r;return"basePubkey"in t?(e=eI(oI.TransferWithSeed,{lamports:BigInt(t.lamports),seed:t.seed,programId:OA(t.programId.toBuffer())}),r=[{pubkey:t.fromPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0}]):(e=eI(oI.Transfer,{lamports:BigInt(t.lamports)}),r=[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0}]),new JA({keys:r,programId:this.programId,data:e})}static assign(t){let e,r;return"basePubkey"in t?(e=eI(oI.AssignWithSeed,{base:OA(t.basePubkey.toBuffer()),seed:t.seed,programId:OA(t.programId.toBuffer())}),r=[{pubkey:t.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1}]):(e=eI(oI.Assign,{programId:OA(t.programId.toBuffer())}),r=[{pubkey:t.accountPubkey,isSigner:!0,isWritable:!0}]),new JA({keys:r,programId:this.programId,data:e})}static createAccountWithSeed(t){const e=eI(oI.CreateWithSeed,{base:OA(t.basePubkey.toBuffer()),seed:t.seed,lamports:t.lamports,space:t.space,programId:OA(t.programId.toBuffer())});let r=[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.newAccountPubkey,isSigner:!1,isWritable:!0}];return t.basePubkey!=t.fromPubkey&&r.push({pubkey:t.basePubkey,isSigner:!0,isWritable:!1}),new JA({keys:r,programId:this.programId,data:e})}static createNonceAccount(t){const e=new XA;"basePubkey"in t&&"seed"in t?e.add(sI.createAccountWithSeed({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,basePubkey:t.basePubkey,seed:t.seed,lamports:t.lamports,space:nI,programId:this.programId})):e.add(sI.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,lamports:t.lamports,space:nI,programId:this.programId}));const r={noncePubkey:t.noncePubkey,authorizedPubkey:t.authorizedPubkey};return e.add(this.nonceInitialize(r)),e}static nonceInitialize(t){const e=eI(oI.InitializeNonceAccount,{authorized:OA(t.authorizedPubkey.toBuffer())}),r={keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:QA,isSigner:!1,isWritable:!1},{pubkey:tI,isSigner:!1,isWritable:!1}],programId:this.programId,data:e};return new JA(r)}static nonceAdvance(t){const e=eI(oI.AdvanceNonceAccount),r={keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:QA,isSigner:!1,isWritable:!1},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:e};return new JA(r)}static nonceWithdraw(t){const e=eI(oI.WithdrawNonceAccount,{lamports:t.lamports});return new JA({keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0},{pubkey:QA,isSigner:!1,isWritable:!1},{pubkey:tI,isSigner:!1,isWritable:!1},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:e})}static nonceAuthorize(t){const e=eI(oI.AuthorizeNonceAccount,{authorized:OA(t.newAuthorizedPubkey.toBuffer())});return new JA({keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:e})}static allocate(t){let e,r;return"basePubkey"in t?(e=eI(oI.AllocateWithSeed,{base:OA(t.basePubkey.toBuffer()),seed:t.seed,space:t.space,programId:OA(t.programId.toBuffer())}),r=[{pubkey:t.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1}]):(e=eI(oI.Allocate,{space:t.space}),r=[{pubkey:t.accountPubkey,isSigner:!0,isWritable:!0}]),new JA({keys:r,programId:this.programId,data:e})}}sI.programId=new jA("11111111111111111111111111111111"),new jA("BPFLoader2111111111111111111111111111111111"),Ex([vx("typeIndex"),iI("deactivationSlot"),_x("lastExtendedSlot"),wx("lastExtendedStartIndex"),wx(),xx(KA(),mx(wx(),-1),"authority")]);const aI=tS(Fx(jA),Zx(),(t=>new jA(t))),uI=Yx([Zx(),qx("base64")]),cI=tS(Fx(t_.Buffer),uI,(t=>t_.Buffer.from(t[0],"base64")));function hI(t){return Xx([Jx({jsonrpc:qx("2.0"),id:Zx(),result:t}),Jx({jsonrpc:qx("2.0"),id:Zx(),error:Jx({code:Qx(),message:Zx(),data:$x(jx("any",(()=>!0)))})})])}const lI=hI(Qx());function fI(t){return tS(hI(t),lI,(e=>"error"in e?e:{...e,result:Nx(e.result,t)}))}function dI(t){return fI(Jx({context:Jx({slot:Hx()}),value:t}))}function pI(t){return Jx({context:Jx({slot:Hx()}),value:t})}const yI=Jx({foundation:Hx(),foundationTerm:Hx(),initial:Hx(),taper:Hx(),terminal:Hx()});fI(Wx(Vx(Jx({epoch:Hx(),effectiveSlot:Hx(),amount:Hx(),postBalance:Hx(),commission:$x(Vx(Hx()))}))));const gI=Wx(Jx({slot:Hx(),prioritizationFee:Hx()})),mI=Jx({total:Hx(),validator:Hx(),foundation:Hx(),epoch:Hx()}),wI=Jx({epoch:Hx(),slotIndex:Hx(),slotsInEpoch:Hx(),absoluteSlot:Hx(),blockHeight:$x(Hx()),transactionCount:$x(Hx())}),bI=Jx({slotsPerEpoch:Hx(),leaderScheduleSlotOffset:Hx(),warmup:Kx(),firstNormalEpoch:Hx(),firstNormalSlot:Hx()}),vI=Gx(Zx(),Wx(Hx())),_I=Vx(Xx([Jx({}),Zx()])),kI=Jx({err:_I}),EI=qx("receivedSignature");Jx({"solana-core":Zx(),"feature-set":$x(Hx())}),dI(Jx({err:Vx(Xx([Jx({}),Zx()])),logs:Vx(Wx(Zx())),accounts:$x(Vx(Wx(Vx(Jx({executable:Kx(),owner:Zx(),lamports:Hx(),data:Wx(Zx()),rentEpoch:$x(Hx())}))))),unitsConsumed:$x(Hx()),returnData:$x(Vx(Jx({programId:Zx(),data:Yx([Zx(),qx("base64")])})))})),dI(Jx({byIdentity:Gx(Zx(),Wx(Hx())),range:Jx({firstSlot:Hx(),lastSlot:Hx()})})),fI(yI),fI(mI),fI(gI),fI(wI),fI(bI),fI(vI),fI(Hx()),dI(Jx({total:Hx(),circulating:Hx(),nonCirculating:Hx(),nonCirculatingAccounts:Wx(aI)}));const xI=Jx({amount:Zx(),uiAmount:Vx(Hx()),decimals:Hx(),uiAmountString:$x(Zx())});dI(Wx(Jx({address:aI,amount:Zx(),uiAmount:Vx(Hx()),decimals:Hx(),uiAmountString:$x(Zx())}))),dI(Wx(Jx({pubkey:aI,account:Jx({executable:Kx(),owner:aI,lamports:Hx(),data:cI,rentEpoch:Hx()})})));const SI=Jx({program:Zx(),parsed:Qx(),space:Hx()});dI(Wx(Jx({pubkey:aI,account:Jx({executable:Kx(),owner:aI,lamports:Hx(),data:SI,rentEpoch:Hx()})}))),dI(Wx(Jx({lamports:Hx(),address:aI})));const AI=Jx({executable:Kx(),owner:aI,lamports:Hx(),data:cI,rentEpoch:Hx()});Jx({pubkey:aI,account:AI});const II=tS(Xx([Fx(t_.Buffer),SI]),Xx([uI,SI]),(t=>Array.isArray(t)?Nx(t,cI):t)),BI=Jx({executable:Kx(),owner:aI,lamports:Hx(),data:II,rentEpoch:Hx()});Jx({pubkey:aI,account:BI}),Jx({state:Xx([qx("active"),qx("inactive"),qx("activating"),qx("deactivating")]),active:Hx(),inactive:Hx()}),fI(Wx(Jx({signature:Zx(),slot:Hx(),err:_I,memo:Vx(Zx()),blockTime:$x(Vx(Hx()))}))),fI(Wx(Jx({signature:Zx(),slot:Hx(),err:_I,memo:Vx(Zx()),blockTime:$x(Vx(Hx()))}))),Jx({subscription:Hx(),result:pI(AI)});const MI=Jx({pubkey:aI,account:AI});Jx({subscription:Hx(),result:pI(MI)});const RI=Jx({parent:Hx(),slot:Hx(),root:Hx()});Jx({subscription:Hx(),result:RI});const PI=Xx([Jx({type:Xx([qx("firstShredReceived"),qx("completed"),qx("optimisticConfirmation"),qx("root")]),slot:Hx(),timestamp:Hx()}),Jx({type:qx("createdBank"),parent:Hx(),slot:Hx(),timestamp:Hx()}),Jx({type:qx("frozen"),slot:Hx(),timestamp:Hx(),stats:Jx({numTransactionEntries:Hx(),numSuccessfulTransactions:Hx(),numFailedTransactions:Hx(),maxTransactionsPerEntry:Hx()})}),Jx({type:qx("dead"),slot:Hx(),timestamp:Hx(),err:Zx()})]);Jx({subscription:Hx(),result:PI}),Jx({subscription:Hx(),result:pI(Xx([kI,EI]))}),Jx({subscription:Hx(),result:Hx()}),Jx({pubkey:Zx(),gossip:Vx(Zx()),tpu:Vx(Zx()),rpc:Vx(Zx()),version:Vx(Zx())});const TI=Jx({votePubkey:Zx(),nodePubkey:Zx(),activatedStake:Hx(),epochVoteAccount:Kx(),epochCredits:Wx(Yx([Hx(),Hx(),Hx()])),commission:Hx(),lastVote:Hx(),rootSlot:Vx(Hx())});fI(Jx({current:Wx(TI),delinquent:Wx(TI)}));const OI=Xx([qx("processed"),qx("confirmed"),qx("finalized")]),LI=Jx({slot:Hx(),confirmations:Vx(Hx()),err:_I,confirmationStatus:$x(OI)});dI(Wx(Vx(LI))),fI(Hx());const UI=Jx({accountKey:aI,writableIndexes:Wx(Hx()),readonlyIndexes:Wx(Hx())}),CI=Jx({signatures:Wx(Zx()),message:Jx({accountKeys:Wx(Zx()),header:Jx({numRequiredSignatures:Hx(),numReadonlySignedAccounts:Hx(),numReadonlyUnsignedAccounts:Hx()}),instructions:Wx(Jx({accounts:Wx(Hx()),data:Zx(),programIdIndex:Hx()})),recentBlockhash:Zx(),addressTableLookups:$x(Wx(UI))})}),NI=Jx({pubkey:aI,signer:Kx(),writable:Kx(),source:$x(Xx([qx("transaction"),qx("lookupTable")]))}),zI=Jx({accountKeys:Wx(NI),signatures:Wx(Zx())}),DI=Jx({parsed:Qx(),program:Zx(),programId:aI}),jI=Jx({accounts:Wx(aI),data:Zx(),programId:aI}),WI=tS(Xx([jI,DI]),Xx([Jx({parsed:Qx(),program:Zx(),programId:Zx()}),Jx({accounts:Wx(Zx()),data:Zx(),programId:Zx()})]),(t=>Nx(t,"accounts"in t?jI:DI))),KI=Jx({signatures:Wx(Zx()),message:Jx({accountKeys:Wx(NI),instructions:Wx(WI),recentBlockhash:Zx(),addressTableLookups:$x(Vx(Wx(UI)))})}),FI=Jx({accountIndex:Hx(),mint:Zx(),owner:$x(Zx()),uiTokenAmount:xI}),qI=Jx({writable:Wx(aI),readonly:Wx(aI)}),VI=Jx({err:_I,fee:Hx(),innerInstructions:$x(Vx(Wx(Jx({index:Hx(),instructions:Wx(Jx({accounts:Wx(Hx()),data:Zx(),programIdIndex:Hx()}))})))),preBalances:Wx(Hx()),postBalances:Wx(Hx()),logMessages:$x(Vx(Wx(Zx()))),preTokenBalances:$x(Vx(Wx(FI))),postTokenBalances:$x(Vx(Wx(FI))),loadedAddresses:$x(qI),computeUnitsConsumed:$x(Hx())}),HI=Jx({err:_I,fee:Hx(),innerInstructions:$x(Vx(Wx(Jx({index:Hx(),instructions:Wx(WI)})))),preBalances:Wx(Hx()),postBalances:Wx(Hx()),logMessages:$x(Vx(Wx(Zx()))),preTokenBalances:$x(Vx(Wx(FI))),postTokenBalances:$x(Vx(Wx(FI))),loadedAddresses:$x(qI),computeUnitsConsumed:$x(Hx())}),$I=Xx([qx(0),qx("legacy")]),GI=Jx({pubkey:Zx(),lamports:Hx(),postBalance:Vx(Hx()),rewardType:Vx(Zx()),commission:$x(Vx(Hx()))});fI(Vx(Jx({blockhash:Zx(),previousBlockhash:Zx(),parentSlot:Hx(),transactions:Wx(Jx({transaction:CI,meta:Vx(VI),version:$x($I)})),rewards:$x(Wx(GI)),blockTime:Vx(Hx()),blockHeight:Vx(Hx())}))),fI(Vx(Jx({blockhash:Zx(),previousBlockhash:Zx(),parentSlot:Hx(),rewards:$x(Wx(GI)),blockTime:Vx(Hx()),blockHeight:Vx(Hx())}))),fI(Vx(Jx({blockhash:Zx(),previousBlockhash:Zx(),parentSlot:Hx(),transactions:Wx(Jx({transaction:zI,meta:Vx(VI),version:$x($I)})),rewards:$x(Wx(GI)),blockTime:Vx(Hx()),blockHeight:Vx(Hx())}))),fI(Vx(Jx({blockhash:Zx(),previousBlockhash:Zx(),parentSlot:Hx(),transactions:Wx(Jx({transaction:KI,meta:Vx(HI),version:$x($I)})),rewards:$x(Wx(GI)),blockTime:Vx(Hx()),blockHeight:Vx(Hx())}))),fI(Vx(Jx({blockhash:Zx(),previousBlockhash:Zx(),parentSlot:Hx(),transactions:Wx(Jx({transaction:zI,meta:Vx(HI),version:$x($I)})),rewards:$x(Wx(GI)),blockTime:Vx(Hx()),blockHeight:Vx(Hx())}))),fI(Vx(Jx({blockhash:Zx(),previousBlockhash:Zx(),parentSlot:Hx(),rewards:$x(Wx(GI)),blockTime:Vx(Hx()),blockHeight:Vx(Hx())}))),fI(Vx(Jx({blockhash:Zx(),previousBlockhash:Zx(),parentSlot:Hx(),transactions:Wx(Jx({transaction:CI,meta:Vx(VI)})),rewards:$x(Wx(GI)),blockTime:Vx(Hx())}))),fI(Vx(Jx({blockhash:Zx(),previousBlockhash:Zx(),parentSlot:Hx(),signatures:Wx(Zx()),blockTime:Vx(Hx())}))),fI(Vx(Jx({slot:Hx(),meta:VI,blockTime:$x(Vx(Hx())),transaction:CI,version:$x($I)}))),fI(Vx(Jx({slot:Hx(),transaction:KI,meta:Vx(HI),blockTime:$x(Vx(Hx())),version:$x($I)}))),dI(Jx({blockhash:Zx(),feeCalculator:Jx({lamportsPerSignature:Hx()})})),dI(Jx({blockhash:Zx(),lastValidBlockHeight:Hx()})),dI(Kx()),fI(Wx(Jx({slot:Hx(),numTransactions:Hx(),numSlots:Hx(),samplePeriodSecs:Hx()}))),dI(Vx(Jx({feeCalculator:Jx({lamportsPerSignature:Hx()})}))),fI(Zx()),fI(Zx());const ZI=Jx({err:_I,logs:Wx(Zx()),signature:Zx()});var YI;Jx({result:pI(ZI),subscription:Hx()}),Object.freeze({CreateLookupTable:{index:0,layout:Ex([vx("instruction"),iI("recentSlot"),wx("bumpSeed")])},FreezeLookupTable:{index:1,layout:Ex([vx("instruction")])},ExtendLookupTable:{index:2,layout:Ex([vx("instruction"),iI(),xx(KA(),mx(vx(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:Ex([vx("instruction")])},CloseLookupTable:{index:4,layout:Ex([vx("instruction")])}}),new jA("AddressLookupTab1e1111111111111111111111111"),Object.freeze({RequestUnits:{index:0,layout:Ex([wx("instruction"),vx("units"),vx("additionalFee")])},RequestHeapFrame:{index:1,layout:Ex([wx("instruction"),vx("bytes")])},SetComputeUnitLimit:{index:2,layout:Ex([wx("instruction"),vx("units")])},SetComputeUnitPrice:{index:3,layout:Ex([wx("instruction"),iI("microLamports")])}}),new jA("ComputeBudget111111111111111111111111111111"),Ex([wx("numSignatures"),wx("padding"),bx("signatureOffset"),bx("signatureInstructionIndex"),bx("publicKeyOffset"),bx("publicKeyInstructionIndex"),bx("messageDataOffset"),bx("messageDataSize"),bx("messageInstructionIndex")]),new jA("Ed25519SigVerify111111111111111111111111111"),RA.utils.isValidPrivateKey,RA.getPublicKey,Ex([wx("numSignatures"),bx("signatureOffset"),wx("signatureInstructionIndex"),bx("ethAddressOffset"),wx("ethAddressInstructionIndex"),bx("messageDataOffset"),bx("messageDataSize"),wx("messageInstructionIndex"),Sx(20,"ethAddress"),Sx(64,"signature"),wx("recoveryId")]),new jA("KeccakSecp256k11111111111111111111111111111"),new jA("StakeConfig11111111111111111111111111111111");class JI{constructor(t,e,r){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=t,this.epoch=e,this.custodian=r}}YI=JI,JI.default=new YI(0,0,jA.default),Object.freeze({Initialize:{index:0,layout:Ex([vx("instruction"),((t="authorized")=>Ex([KA("staker"),KA("withdrawer")],t))(),((t="lockup")=>Ex([kx("unixTimestamp"),kx("epoch"),KA("custodian")],t))()])},Authorize:{index:1,layout:Ex([vx("instruction"),KA("newAuthorized"),vx("stakeAuthorizationType")])},Delegate:{index:2,layout:Ex([vx("instruction")])},Split:{index:3,layout:Ex([vx("instruction"),kx("lamports")])},Withdraw:{index:4,layout:Ex([vx("instruction"),kx("lamports")])},Deactivate:{index:5,layout:Ex([vx("instruction")])},Merge:{index:7,layout:Ex([vx("instruction")])},AuthorizeWithSeed:{index:8,layout:Ex([vx("instruction"),KA("newAuthorized"),vx("stakeAuthorizationType"),FA("authoritySeed"),KA("authorityOwner")])}}),Object.freeze({Staker:{index:0},Withdrawer:{index:1}}),new jA("Stake11111111111111111111111111111111111111"),Object.freeze({InitializeAccount:{index:0,layout:Ex([vx("instruction"),((t="voteInit")=>Ex([KA("nodePubkey"),KA("authorizedVoter"),KA("authorizedWithdrawer"),wx("commission")],t))()])},Authorize:{index:1,layout:Ex([vx("instruction"),KA("newAuthorized"),vx("voteAuthorizationType")])},Withdraw:{index:3,layout:Ex([vx("instruction"),kx("lamports")])},AuthorizeWithSeed:{index:10,layout:Ex([vx("instruction"),((t="voteAuthorizeWithSeedArgs")=>Ex([vx("voteAuthorizationType"),KA("currentAuthorityDerivedKeyOwnerPubkey"),FA("currentAuthorityDerivedKeySeed"),KA("newAuthorized")],t))()])}}),Object.freeze({Voter:{index:0},Withdrawer:{index:1}}),new jA("Vote111111111111111111111111111111111111111"),new jA("Va1idator1nfo111111111111111111111111111111"),Jx({name:Zx(),website:$x(Zx()),details:$x(Zx()),keybaseUsername:$x(Zx())}),new jA("Vote111111111111111111111111111111111111111"),Ex([KA("nodePubkey"),KA("authorizedWithdrawer"),wx("commission"),_x(),xx(Ex([_x("slot"),vx("confirmationCount")]),mx(vx(),-8),"votes"),wx("rootSlotValid"),_x("rootSlot"),_x(),xx(Ex([_x("epoch"),KA("authorizedVoter")]),mx(vx(),-8),"authorizedVoters"),Ex([xx(Ex([KA("authorizedPubkey"),_x("epochOfLastAuthorizedSwitch"),_x("targetEpoch")]),32,"buf"),_x("idx"),wx("isEmpty")],"priorVoters"),_x(),xx(Ex([_x("epoch"),_x("credits"),_x("prevCredits")]),mx(vx(),-8),"epochCredits"),Ex([_x("slot"),_x("timestamp")],"lastTimestamp")]);var XI,QI=["u8","u16","u32","u64","u128","i8","i16","i32","i64","i128","f32","f64"],tB=function(){function t(){this.offset=0,this.buffer_size=256,this.buffer=new ArrayBuffer(this.buffer_size),this.view=new DataView(this.buffer)}return t.prototype.resize_if_necessary=function(t){if(this.buffer_size-this.offset<t){this.buffer_size=Math.max(2*this.buffer_size,this.buffer_size+t);var e=new ArrayBuffer(this.buffer_size);new Uint8Array(e).set(new Uint8Array(this.buffer)),this.buffer=e,this.view=new DataView(e)}},t.prototype.get_used_buffer=function(){return new Uint8Array(this.buffer).slice(0,this.offset)},t.prototype.store_value=function(t,e){var r=e.substring(1),n=parseInt(r)/8;this.resize_if_necessary(n);var i="f"===e[0]?"setFloat".concat(r):"i"===e[0]?"setInt".concat(r):"setUint".concat(r);this.view[i](this.offset,t,!0),this.offset+=n},t.prototype.store_bytes=function(t){this.resize_if_necessary(t.length),new Uint8Array(this.buffer).set(new Uint8Array(t),this.offset),this.offset+=t.length},t}(),eB=function(){function t(t){this.offset=0,this.buffer_size=t.length,this.buffer=new ArrayBuffer(t.length),new Uint8Array(this.buffer).set(t),this.view=new DataView(this.buffer)}return t.prototype.assert_enough_buffer=function(t){if(this.offset+t>this.buffer.byteLength)throw new Error("Error in schema, the buffer is smaller than expected")},t.prototype.consume_value=function(t){var e=t.substring(1),r=parseInt(e)/8;this.assert_enough_buffer(r);var n="f"===t[0]?"getFloat".concat(e):"i"===t[0]?"getInt".concat(e):"getUint".concat(e),i=this.view[n](this.offset,!0);return this.offset+=r,i},t.prototype.consume_bytes=function(t){this.assert_enough_buffer(t);var e=this.buffer.slice(this.offset,this.offset+t);return this.offset+=t,e},t}(),rB=(XI=function(t,e){return XI=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},XI(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}XI(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)});function nB(t,e,r){if(typeof t!==e)throw new Error("Expected ".concat(e," not ").concat(typeof t,"(").concat(t,") at ").concat(r.join(".")))}function iB(t,e,r){if(t!==e)throw new Error("Array length ".concat(t," does not match schema length ").concat(e," at ").concat(r.join(".")))}var oB=QI.concat(["bool","string"]),sB=["option","enum","array","set","map","struct"],aB=function(t){function e(e,r){var n="Invalid schema: ".concat(JSON.stringify(e)," expected ").concat(r);return t.call(this,n)||this}return rB(e,t),e}(Error);function uB(t){if("string"!=typeof t||!oB.includes(t)){if(t&&"object"==typeof t){var e=Object.keys(t);if(1===e.length&&sB.includes(e[0])){var r=e[0];if("option"===r)return uB(t[r]);if("enum"===r)return function(t){if(!Array.isArray(t))throw new aB(t,"Array");for(var e=0,r=t;e<r.length;e++){var n=r[e];if("object"!=typeof n||!("struct"in n))throw new Error('Missing "struct" key in enum schema');if("object"!=typeof n.struct||1!==Object.keys(n.struct).length)throw new Error('The "struct" in each enum must have a single key');uB({struct:n.struct})}}(t[r]);if("array"===r)return function(t){if("object"!=typeof t)throw new aB(t,"{ type, len? }");if(t.len&&"number"!=typeof t.len)throw new Error("Invalid schema: ".concat(t));if("type"in t)return uB(t.type);throw new aB(t,"{ type, len? }")}(t[r]);if("set"===r)return uB(t[r]);if("map"===r)return function(t){if("object"!=typeof t||!("key"in t)||!("value"in t))throw new aB(t,"{ key, value }");uB(t.key),uB(t.value)}(t[r]);if("struct"===r)return function(t){if("object"!=typeof t)throw new aB(t,"object");for(var e in t)uB(t[e])}(t[r])}}throw new aB(t,sB.join(", ")+" or "+oB.join(", "))}}var cB=function(){function t(t){this.encoded=new tB,this.fieldPath=["value"],this.checkTypes=t}return t.prototype.encode=function(t,e){return this.encode_value(t,e),this.encoded.get_used_buffer()},t.prototype.encode_value=function(t,e){if("string"==typeof e){if(QI.includes(e))return this.encode_integer(t,e);if("string"===e)return this.encode_string(t);if("bool"===e)return this.encode_boolean(t)}if("object"==typeof e){if("option"in e)return this.encode_option(t,e);if("enum"in e)return this.encode_enum(t,e);if("array"in e)return this.encode_array(t,e);if("set"in e)return this.encode_set(t,e);if("map"in e)return this.encode_map(t,e);if("struct"in e)return this.encode_struct(t,e)}},t.prototype.encode_integer=function(t,e){var r=parseInt(e.substring(1));r<=32||"f64"==e?(this.checkTypes&&nB(t,"number",this.fieldPath),this.encoded.store_value(t,e)):(this.checkTypes&&function(t,e){if(!(["number","string","bigint","boolean"].includes(typeof t)||"object"==typeof t&&null!==t&&"toString"in t))throw new Error("Expected bigint, number, boolean or string not ".concat(typeof t,"(").concat(t,") at ").concat(e.join(".")))}(t,this.fieldPath),this.encode_bigint(BigInt(t),r))},t.prototype.encode_bigint=function(t,e){for(var r=e/8,n=new Uint8Array(r),i=0;i<r;i++)n[i]=Number(t&BigInt(255)),t>>=BigInt(8);this.encoded.store_bytes(new Uint8Array(n))},t.prototype.encode_string=function(t){this.checkTypes&&nB(t,"string",this.fieldPath);var e=t;this.encoded.store_value(e.length,"u32");for(var r=0;r<e.length;r++)this.encoded.store_value(e.charCodeAt(r),"u8")},t.prototype.encode_boolean=function(t){this.checkTypes&&nB(t,"boolean",this.fieldPath),this.encoded.store_value(t?1:0,"u8")},t.prototype.encode_option=function(t,e){null==t?this.encoded.store_value(0,"u8"):(this.encoded.store_value(1,"u8"),this.encode_value(t,e.option))},t.prototype.encode_enum=function(t,e){this.checkTypes&&function(t,e){if("object"!=typeof t||null===t)throw new Error("Expected object not ".concat(typeof t,"(").concat(t,") at ").concat(e.join(".")))}(t,this.fieldPath);for(var r=Object.keys(t)[0],n=0;n<e.enum.length;n++){var i=e.enum[n];if(r===Object.keys(i.struct)[0])return this.encoded.store_value(n,"u8"),this.encode_struct(t,i)}throw new Error("Enum key (".concat(r,") not found in enum schema: ").concat(JSON.stringify(e)," at ").concat(this.fieldPath.join(".")))},t.prototype.encode_array=function(t,e){if(function(t){return Array.isArray(t)||!!t&&"object"==typeof t&&"length"in t&&"number"==typeof t.length&&(0===t.length||t.length>0&&t.length-1 in t)}(t))return this.encode_arraylike(t,e);if(t instanceof ArrayBuffer)return this.encode_buffer(t,e);throw new Error("Expected Array-like not ".concat(typeof t,"(").concat(t,") at ").concat(this.fieldPath.join(".")))},t.prototype.encode_arraylike=function(t,e){e.array.len?iB(t.length,e.array.len,this.fieldPath):this.encoded.store_value(t.length,"u32");for(var r=0;r<t.length;r++)this.encode_value(t[r],e.array.type)},t.prototype.encode_buffer=function(t,e){e.array.len?iB(t.byteLength,e.array.len,this.fieldPath):this.encoded.store_value(t.byteLength,"u32"),this.encoded.store_bytes(new Uint8Array(t))},t.prototype.encode_set=function(t,e){this.checkTypes&&nB(t,"object",this.fieldPath);var r=t instanceof Set?Array.from(t.values()):Object.values(t);this.encoded.store_value(r.length,"u32");for(var n=0,i=r;n<i.length;n++){var o=i[n];this.encode_value(o,e.set)}},t.prototype.encode_map=function(t,e){this.checkTypes&&nB(t,"object",this.fieldPath);var r=t instanceof Map,n=r?Array.from(t.keys()):Object.keys(t);this.encoded.store_value(n.length,"u32");for(var i=0,o=n;i<o.length;i++){var s=o[i];this.encode_value(s,e.map.key),this.encode_value(r?t.get(s):t[s],e.map.value)}},t.prototype.encode_struct=function(t,e){this.checkTypes&&nB(t,"object",this.fieldPath);for(var r=0,n=Object.keys(e.struct);r<n.length;r++){var i=n[r];this.fieldPath.push(i),this.encode_value(t[i],e.struct[i]),this.fieldPath.pop()}},t}(),hB=function(){function t(t){this.buffer=new eB(t)}return t.prototype.decode=function(t){return this.decode_value(t)},t.prototype.decode_value=function(t){if("string"==typeof t){if(QI.includes(t))return this.decode_integer(t);if("string"===t)return this.decode_string();if("bool"===t)return this.decode_boolean()}if("object"==typeof t){if("option"in t)return this.decode_option(t);if("enum"in t)return this.decode_enum(t);if("array"in t)return this.decode_array(t);if("set"in t)return this.decode_set(t);if("map"in t)return this.decode_map(t);if("struct"in t)return this.decode_struct(t)}throw new Error("Unsupported type: ".concat(t))},t.prototype.decode_integer=function(t){var e=parseInt(t.substring(1));return e<=32||"f64"==t?this.buffer.consume_value(t):this.decode_bigint(e,t.startsWith("i"))},t.prototype.decode_bigint=function(t,e){void 0===e&&(e=!1);var r=t/8,n=new Uint8Array(this.buffer.consume_bytes(r)),i=n.reduceRight((function(t,e){return t+e.toString(16).padStart(2,"0")}),"");return e&&n[r-1]?BigInt.asIntN(t,BigInt("0x".concat(i))):BigInt("0x".concat(i))},t.prototype.decode_string=function(){var t=this.decode_integer("u32"),e=new Uint8Array(this.buffer.consume_bytes(t));return String.fromCharCode.apply(null,e)},t.prototype.decode_boolean=function(){return this.buffer.consume_value("u8")>0},t.prototype.decode_option=function(t){var e=this.buffer.consume_value("u8");if(1===e)return this.decode_value(t.option);if(0!==e)throw new Error("Invalid option ".concat(e));return null},t.prototype.decode_enum=function(t){var e,r=this.buffer.consume_value("u8");if(r>t.enum.length)throw new Error("Enum option ".concat(r," is not available"));var n=t.enum[r].struct,i=Object.keys(n)[0];return(e={})[i]=this.decode_value(n[i]),e},t.prototype.decode_array=function(t){for(var e=[],r=t.array.len?t.array.len:this.decode_integer("u32"),n=0;n<r;++n)e.push(this.decode_value(t.array.type));return e},t.prototype.decode_set=function(t){for(var e=this.decode_integer("u32"),r=new Set,n=0;n<e;++n)r.add(this.decode_value(t.set));return r},t.prototype.decode_map=function(t){for(var e=this.decode_integer("u32"),r=new Map,n=0;n<e;++n){var i=this.decode_value(t.map.key),o=this.decode_value(t.map.value);r.set(i,o)}return r},t.prototype.decode_struct=function(t){var e={};for(var r in t.struct)e[r]=this.decode_value(t.struct[r]);return e},t}();function lB(t,e,r){return void 0===r&&(r=!0),r&&uB(t),new cB(r).encode(e,t)}class fB{constructor(t){this.tag=1,this.record=t.record,this.content=t.content}serialize(){return lB(fB.schema,this)}getInstruction(t,e,r,n,i,o,s,a){const u=Buffer.from(this.serialize());let c=[];return c.push({pubkey:e,isSigner:!1,isWritable:!1}),c.push({pubkey:r,isSigner:!1,isWritable:!1}),c.push({pubkey:n,isSigner:!0,isWritable:!0}),c.push({pubkey:i,isSigner:!1,isWritable:!0}),c.push({pubkey:o,isSigner:!1,isWritable:!0}),c.push({pubkey:s,isSigner:!0,isWritable:!0}),c.push({pubkey:a,isSigner:!1,isWritable:!1}),new JA({keys:c,programId:t,data:u})}}fB.schema={struct:{tag:"u8",record:"string",content:{array:{type:"u8"}}}};class dB{constructor(t){this.tag=4,this.validation=t.validation,this.signature=t.signature,this.expectedPubkey=t.expectedPubkey}serialize(){return lB(dB.schema,this)}getInstruction(t,e,r,n,i,o,s,a){const u=Buffer.from(this.serialize());let c=[];return c.push({pubkey:e,isSigner:!1,isWritable:!1}),c.push({pubkey:r,isSigner:!1,isWritable:!1}),c.push({pubkey:n,isSigner:!0,isWritable:!0}),c.push({pubkey:i,isSigner:!1,isWritable:!0}),c.push({pubkey:o,isSigner:!1,isWritable:!0}),c.push({pubkey:s,isSigner:!0,isWritable:!0}),c.push({pubkey:a,isSigner:!1,isWritable:!1}),new JA({keys:c,programId:t,data:u})}}dB.schema={struct:{tag:"u8",validation:"u8",signature:{array:{type:"u8"}},expectedPubkey:{array:{type:"u8"}}}};class pB{constructor(t){this.tag=3,this.staleness=t.staleness}serialize(){return lB(pB.schema,this)}getInstruction(t,e,r,n,i,o,s,a,u){const c=Buffer.from(this.serialize());let h=[];return h.push({pubkey:e,isSigner:!1,isWritable:!1}),h.push({pubkey:r,isSigner:!1,isWritable:!1}),h.push({pubkey:n,isSigner:!0,isWritable:!0}),h.push({pubkey:i,isSigner:!1,isWritable:!0}),h.push({pubkey:o,isSigner:!1,isWritable:!0}),h.push({pubkey:s,isSigner:!1,isWritable:!0}),h.push({pubkey:a,isSigner:!1,isWritable:!1}),h.push({pubkey:u,isSigner:!0,isWritable:!0}),new JA({keys:h,programId:t,data:c})}}pB.schema={struct:{tag:"u8",staleness:"bool"}};class yB{constructor(t){this.tag=2,this.record=t.record,this.content=t.content}serialize(){return lB(yB.schema,this)}getInstruction(t,e,r,n,i,o,s,a){const u=Buffer.from(this.serialize());let c=[];return c.push({pubkey:e,isSigner:!1,isWritable:!1}),c.push({pubkey:r,isSigner:!1,isWritable:!1}),c.push({pubkey:n,isSigner:!0,isWritable:!0}),c.push({pubkey:i,isSigner:!1,isWritable:!0}),c.push({pubkey:o,isSigner:!1,isWritable:!0}),c.push({pubkey:s,isSigner:!0,isWritable:!0}),c.push({pubkey:a,isSigner:!1,isWritable:!1}),new JA({keys:c,programId:t,data:u})}}yB.schema={struct:{tag:"u8",record:"string",content:{array:{type:"u8"}}}};class gB{constructor(){this.tag=5}serialize(){return lB(gB.schema,this)}getInstruction(t,e,r,n,i,o,s,a){const u=Buffer.from(this.serialize());let c=[];return c.push({pubkey:e,isSigner:!1,isWritable:!1}),c.push({pubkey:r,isSigner:!1,isWritable:!1}),c.push({pubkey:n,isSigner:!0,isWritable:!0}),c.push({pubkey:i,isSigner:!1,isWritable:!0}),c.push({pubkey:o,isSigner:!1,isWritable:!0}),c.push({pubkey:s,isSigner:!0,isWritable:!0}),c.push({pubkey:a,isSigner:!1,isWritable:!1}),new JA({keys:c,programId:t,data:u})}}gB.schema={struct:{tag:"u8"}};class mB{constructor(t){this.tag=6,this.roaId=t.roaId}serialize(){return lB(mB.schema,this)}getInstruction(t,e,r,n,i,o,s,a){const u=Buffer.from(this.serialize());let c=[];return c.push({pubkey:e,isSigner:!1,isWritable:!1}),c.push({pubkey:r,isSigner:!1,isWritable:!1}),c.push({pubkey:n,isSigner:!0,isWritable:!0}),c.push({pubkey:i,isSigner:!1,isWritable:!0}),c.push({pubkey:o,isSigner:!1,isWritable:!0}),c.push({pubkey:s,isSigner:!0,isWritable:!0}),c.push({pubkey:a,isSigner:!1,isWritable:!1}),new JA({keys:c,programId:t,data:u})}}mB.schema={struct:{tag:"u8",roaId:{array:{type:"u8"}}}};const wB=new jA("HP3D4D1ZCmohQGFVms2SS4LCANgJyksBf5s1F77FuFjZ"),[bB]=jA.findProgramAddressSync([wB.toBuffer()],wB);var vB;!function(t){t[t.None=0]="None",t[t.Solana=1]="Solana",t[t.Ethereum=2]="Ethereum",t[t.UnverifiedSolana=3]="UnverifiedSolana"}(vB||(vB={}));const _B=t=>{switch(t){case vB.None:return 0;case vB.Ethereum:return 20;case vB.Solana:case vB.UnverifiedSolana:return 32;default:throw new Error("Invalid validation enum")}};class kB{constructor(t){this.stalenessValidation=t.stalenessValidation,this.rightOfAssociationValidation=t.rightOfAssociationValidation,this.contentLength=t.contentLength}static deserialize(t){return new kB(function(t,e,r){return void 0===r&&(r=!0),r&&uB(t),new hB(e).decode(t)}(this.schema,t,!0))}static async retrieve(t,e){const r=await t.getAccountInfo(e);if(!r||!r.data)throw new Error("Record header account not found");return this.deserialize(r.data.slice(96,96+this.LEN))}}kB.LEN=8,kB.schema={struct:{stalenessValidation:"u16",rightOfAssociationValidation:"u16",contentLength:"u32"}};class EB{constructor(t,e){this.data=e,this.header=t}static deserialize(t){const e=kB.deserialize(t.slice(96,96+kB.LEN)),r=t.slice(96+kB.LEN);return new EB(e,r)}static async retrieve(t,e){const r=await t.getAccountInfo(e);if(!r||!r.data)throw new Error("Record header account not found");return this.deserialize(r.data)}static async retrieveBatch(t,e){return(await t.getMultipleAccountsInfo(e)).map((t=>{if(null==t?void 0:t.data)return this.deserialize(t.data)}))}getContent(){let t=_B(this.header.stalenessValidation)+_B(this.header.rightOfAssociationValidation);return this.data.slice(t)}getStalenessId(){let t=_B(this.header.stalenessValidation);return this.data.slice(0,t)}getRoAId(){let t=_B(this.header.stalenessValidation),e=t+_B(this.header.rightOfAssociationValidation);return this.data.slice(t,e)}}var xB;exports.Record=void 0,(xB=exports.Record||(exports.Record={})).IPFS="IPFS",xB.ARWV="ARWV",xB.SOL="SOL",xB.ETH="ETH",xB.BTC="BTC",xB.LTC="LTC",xB.DOGE="DOGE",xB.Email="email",xB.Url="url",xB.Discord="discord",xB.Github="github",xB.Reddit="reddit",xB.Twitter="twitter",xB.Telegram="telegram",xB.Pic="pic",xB.SHDW="SHDW",xB.POINT="POINT",xB.BSC="BSC",xB.Injective="INJ",xB.Backpack="backpack",xB.A="A",xB.AAAA="AAAA",xB.CNAME="CNAME",xB.TXT="TXT",xB.Background="background";const SB=new Map([[exports.Record.SOL,96],[exports.Record.ETH,20],[exports.Record.BSC,20],[exports.Record.Injective,20],[exports.Record.A,4],[exports.Record.AAAA,16],[exports.Record.Background,32]]);var AB;exports.RecordVersion=void 0,(AB=exports.RecordVersion||(exports.RecordVersion={}))[AB.V1=1]="V1",AB[AB.V2=2]="V2";const IB=t=>{const e=xf+t,r=kf(n.Buffer.from(e,"utf8")).slice(2);return n.Buffer.from(r,"hex")},BB=(t,e,r)=>{const i=[t];e?i.push(e.toBuffer()):i.push(n.Buffer.alloc(32)),r?i.push(r.toBuffer()):i.push(n.Buffer.alloc(32));const[o]=Wo.findProgramAddressSync(i,Ef);return o};async function MB(t,e){const r=IB(e.toBase58()),n=BB(r,Mf),{registry:i}=await oh.retrieve(t,n);if(!i.data)throw new Dc(exports.ErrorType.NoAccountData);const o=new ne(i.data.slice(0,4),"le").toNumber();return i.data.slice(4,4+o).toString()}async function RB(t,e){let r=[];for(let t of e){const e=IB(t.toBase58()),n=BB(e,Mf);r.push(n)}return(await oh.retrieveBatch(t,r)).map((t=>{if(void 0===t||void 0===t.data)return;let e=new ne(t.data.slice(0,4),"le").toNumber();return t.data.slice(4,4+e).toString()}))}const PB=(t,e=Sf,r)=>{let n=IB(t);return{pubkey:BB(n,r,e),hashed:n}},TB=(t,e)=>{t.endsWith(".sol")&&(t=t.slice(0,-4));const r=t.split(".");if(2===r.length){const t=n.Buffer.from([e||0]).toString().concat(r[0]),{pubkey:i}=PB(r[1]);return{...PB(t,i,e===exports.RecordVersion.V2?bB:void 0),isSub:!0,parent:i}}if(3===r.length&&e){const{pubkey:t}=PB(r[2]),{pubkey:e}=PB("\0".concat(r[1]),t),i=n.Buffer.from([1]).toString();return{...PB(i.concat(r[0]),e),isSub:!0,parent:t,isSubRecord:!0}}if(r.length>=3)throw new Dc(exports.ErrorType.InvalidInput);return{...PB(t,Sf),isSub:!1,parent:void 0}};async function OB(t,e){const r=[{memcmp:{offset:32,bytes:e.toBase58()}},{memcmp:{offset:0,bytes:Sf.toBase58()}}];return(await t.getProgramAccounts(Ef,{filters:r})).map((t=>t.pubkey))}const LB=(t,e)=>{const{pubkey:r,parent:n}=TB(t),i=IB(r.toBase58());return BB(i,Mf,e?n:void 0)},UB=(t,e)=>{if(!t)throw new Dc(e)};var CB={},NB={};function zB(t,e,r,n,i){var o=(1<<n)-1,s=0,a=0,u=0;if(t.forEach((function(t){for(s=(s<<e)+t,a+=e;a>=n;)a-=n,r[u]=s>>a&o,u+=1})),i)a>0&&(r[u]=s<<n-a&o);else{if(a>=e)throw new Error("Excessive padding: ".concat(a," (max ").concat(e-1," allowed)"));if(s%(1<<a)!=0)throw new Error("Non-zero padding")}}Object.defineProperty(NB,"__esModule",{value:!0}),NB.createBitArray=function(t){return new Uint8Array(t)},NB.fromBits=function(t,e,r){if(e>8||e<1)throw new RangeError("Invalid bits per element; 1 to 8 expected");return zB(t,e,r,8,!1),r},NB.toBits=function(t,e,r){if(e>8||e<1)throw new RangeError("Invalid bits per element; 1 to 8 expected");return zB(t,8,r,e,!0),r};var DB={};Object.defineProperty(DB,"__esModule",{value:!0}),DB.CHECKSUM_LENGTH=void 0,DB.createChecksum=function(t,e){var r;switch(e){case"bech32":r=1;break;case"bech32m":r=KB;break;default:throw Error("Invalid encoding value: ".concat(e,"; expected bech32 or bech32m"))}for(var n=GB(t)^r,i=0;i<VB;i+=1){var o=5*(5-i);t[t.length-VB+i]=n>>o&31}},DB.decode=YB,DB.decodeWithPrefix=function(t,e){var r=e.length+2*t.length+1,n=(0,jB.createBitArray)(r);return ZB(t,n.subarray(0,2*t.length+1)),YB(e,n.subarray(2*t.length+1)),n},DB.detectCase=function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"message",r=!1,n=!1,i=0;i<t.length;i+=1){var o=t.charCodeAt(i);if(o<FB||o>qB)throw new TypeError("Invalid char in ".concat(e,": ").concat(o,"; ")+"should be in ASCII range ".concat(FB,"-").concat(qB));n=n||o>=65&&o<=90,r=r||o>=97&&o<=122}if(r&&n)throw new TypeError("Mixed-case ".concat(e));return n?"upper":r?"lower":null},DB.encode=function(t){return t.reduce((function(t,e){return t+WB[e]}),"")},DB.expandPrefix=ZB,DB.verifyChecksum=function(t){switch(GB(t)){case 1:return"bech32";case KB:return"bech32m";default:return}};var jB=NB,WB="qpzry9x8gf2tvdw0s3jn54khce6mua7l",KB=734539939,FB=33,qB=126,VB=6;DB.CHECKSUM_LENGTH=VB;var HB=function(){for(var t=new Map,e=0;e<WB.length;e+=1)t.set(WB[e],e);return t}(),$B=[996825010,642813549,513874426,1027748829,705979059];function GB(t){return t.reduce((function(t,e){var r=t>>25,n=(33554431&t)<<5^e;return $B.reduce((function(t,e,n){return 0==(r>>n&1)?t:t^e}),n)}),1)}function ZB(t,e){for(var r=0;r<t.length;r+=1){var n=t.charCodeAt(r);e[r]=n>>5,e[r+t.length+1]=31&n}e[t.length]=0}function YB(t,e){for(var r=e||(0,jB.createBitArray)(t.length),n=0;n<t.length;n+=1){var i=HB.get(t[n]);if(void 0===i)throw new Error("Invalid char in message: ".concat(t[n]));r[n]=i}return r}Object.defineProperty(CB,"__esModule",{value:!0}),CB.BitcoinAddress=void 0;var JB=CB.decode=function(t){var e=sM(t),r=e.prefix,n=e.encoding,i=e.data;return{prefix:r,encoding:n,data:iM(i)}};CB.decodeTo5BitArray=sM;var XB=CB.encode=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"bech32";return oM(t,nM(e),r)};CB.encode5BitArray=oM,CB.from5BitArray=iM,CB.to5BitArray=nM;var QB=NB,tM=DB;function eM(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var rM=90;function nM(t,e){var r=Math.ceil(8*t.length/5),n=e||(0,QB.createBitArray)(r);return(0,QB.toBits)(t,5,n)}function iM(t,e){var r=Math.floor(5*t.length/8),n=e||new Uint8Array(r);return(0,QB.fromBits)(t,5,n)}function oM(t,e){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"bech32",i=2*t.length+1+e.length+tM.CHECKSUM_LENGTH;if(i-t.length>rM)throw new Error("Message to be produced is too long (max ".concat(rM," supported)"));var o=null!==(r=(0,tM.detectCase)(t,"prefix"))&&void 0!==r?r:"lower",s=(0,QB.createBitArray)(i);(0,tM.expandPrefix)(t.toLowerCase(),s.subarray(0,2*t.length+1)),s.subarray(2*t.length+1,s.length-tM.CHECKSUM_LENGTH).set(e),(0,tM.createChecksum)(s,n);var a=(0,tM.encode)(s.subarray(2*t.length+1));return"upper"===o&&(a=a.toUpperCase()),"".concat(t,"1").concat(a)}function sM(t){if(t.length>rM)throw new TypeError("Message too long; max ".concat(rM," expected"));(0,tM.detectCase)(t);var e=t.toLowerCase(),r=e.lastIndexOf("1");if(r<0)throw new Error('No separator char ("1") found');if(r>t.length-tM.CHECKSUM_LENGTH-1)throw new Error("Data part of the message too short (at least ".concat(tM.CHECKSUM_LENGTH," chars expected)"));var n=e.substring(0,r),i=(0,tM.decodeWithPrefix)(n,e.substring(r+1)),o=(0,tM.verifyChecksum)(i);if(void 0===o)throw new Error("Invalid checksum");return{prefix:n,encoding:o,data:i.subarray(2*n.length+1,i.length-tM.CHECKSUM_LENGTH)}}var aM=function(){function t(e,r,n){if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),"bc"!==e&&"tb"!==e)throw new Error('Invalid human-readable prefix, "bc" or "tb" expected');if(r<0||r>16)throw new RangeError("Invalid scriptVersion, value in range [0, 16] expected");if(n.length<2||n.length>40)throw new RangeError("Invalid script length: expected 2 to 40 bytes");if(0===r&&20!==n.length&&32!==n.length)throw new Error("Invalid v0 script length: expected 20 or 32 bytes");this.prefix=e,this.scriptVersion=r,this.data=n}var e,r,n;return e=t,r=[{key:"type",value:function(){if(0===this.scriptVersion)switch(this.data.length){case 20:return"p2wpkh";case 32:return"p2wsh";default:return}}},{key:"encode",value:function(){var t=Math.ceil(8*this.data.length/5),e=(0,QB.createBitArray)(t+1);e[0]=this.scriptVersion,nM(this.data,e.subarray(1));var r=0===this.scriptVersion?"bech32":"bech32m";return oM(this.prefix,e,r)}}],n=[{key:"decode",value:function(t){var e=sM(t),r=e.prefix,n=e.data,i=e.encoding;if("bc"!==r&&"tb"!==r)throw new Error('Invalid human-readable prefix, "bc" or "tb" expected');var o=n[0];if(0===o&&"bech32"!==i)throw Error("Unexpected encoding ".concat(i," used for version 0 script"));if(o>0&&"bech32m"!==i)throw Error("Unexpected encoding ".concat(i," used for version ").concat(o," script"));return new this(r,o,iM(n.subarray(1)))}}],r&&eM(e.prototype,r),n&&eM(e,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();CB.BitcoinAddress=aM;var uM={exports:{}};!function(e){!function(t){const r="(0?\\d+|0x[a-f0-9]+)",n={fourOctet:new RegExp(`^${r}\\.${r}\\.${r}\\.${r}$`,"i"),threeOctet:new RegExp(`^${r}\\.${r}\\.${r}$`,"i"),twoOctet:new RegExp(`^${r}\\.${r}$`,"i"),longValue:new RegExp(`^${r}$`,"i")},i=new RegExp("^0[0-7]+$","i"),o=new RegExp("^0x[a-f0-9]+$","i"),s="%[0-9a-z]{1,}",a="(?:[0-9a-f]+::?)+",u={zoneIndex:new RegExp(s,"i"),native:new RegExp(`^(::)?(${a})?([0-9a-f]+)?(::)?(${s})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${r}\\.${r}\\.${r}\\.${r}(${s})?)$`,"i"),transitional:new RegExp(`^((?:${a})|(?:::)(?:${a})?)${r}\\.${r}\\.${r}\\.${r}(${s})?$`,"i")};function c(t,e){if(t.indexOf("::")!==t.lastIndexOf("::"))return null;let r,n,i=0,o=-1,s=(t.match(u.zoneIndex)||[])[0];for(s&&(s=s.substring(1),t=t.replace(/%.+$/,""));(o=t.indexOf(":",o+1))>=0;)i++;if("::"===t.substr(0,2)&&i--,"::"===t.substr(-2,2)&&i--,i>e)return null;for(n=e-i,r=":";n--;)r+="0:";return":"===(t=t.replace("::",r))[0]&&(t=t.slice(1)),":"===t[t.length-1]&&(t=t.slice(0,-1)),e=function(){const e=t.split(":"),r=[];for(let t=0;t<e.length;t++)r.push(parseInt(e[t],16));return r}(),{parts:e,zoneId:s}}function h(t,e,r,n){if(t.length!==e.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let i,o=0;for(;n>0;){if(i=r-n,i<0&&(i=0),t[o]>>i!=e[o]>>i)return!1;n-=r,o+=1}return!0}function l(t){if(o.test(t))return parseInt(t,16);if("0"===t[0]&&!isNaN(parseInt(t[1],10))){if(i.test(t))return parseInt(t,8);throw new Error(`ipaddr: cannot parse ${t} as octal`)}return parseInt(t,10)}function f(t,e){for(;t.length<e;)t=`0${t}`;return t}const d={};d.IPv4=function(){function t(t){if(4!==t.length)throw new Error("ipaddr: ipv4 octet count should be 4");let e,r;for(e=0;e<t.length;e++)if(r=t[e],!(0<=r&&r<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=t}return t.prototype.SpecialRanges={unspecified:[[new t([0,0,0,0]),8]],broadcast:[[new t([255,255,255,255]),32]],multicast:[[new t([224,0,0,0]),4]],linkLocal:[[new t([169,254,0,0]),16]],loopback:[[new t([127,0,0,0]),8]],carrierGradeNat:[[new t([100,64,0,0]),10]],private:[[new t([10,0,0,0]),8],[new t([172,16,0,0]),12],[new t([192,168,0,0]),16]],reserved:[[new t([192,0,0,0]),24],[new t([192,0,2,0]),24],[new t([192,88,99,0]),24],[new t([198,18,0,0]),15],[new t([198,51,100,0]),24],[new t([203,0,113,0]),24],[new t([240,0,0,0]),4]]},t.prototype.kind=function(){return"ipv4"},t.prototype.match=function(t,e){let r;if(void 0===e&&(r=t,t=r[0],e=r[1]),"ipv4"!==t.kind())throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return h(this.octets,t.octets,8,e)},t.prototype.prefixLengthFromSubnetMask=function(){let t=0,e=!1;const r={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0};let n,i,o;for(n=3;n>=0;n-=1){if(i=this.octets[n],!(i in r))return null;if(o=r[i],e&&0!==o)return null;8!==o&&(e=!0),t+=o}return 32-t},t.prototype.range=function(){return d.subnetMatch(this,this.SpecialRanges)},t.prototype.toByteArray=function(){return this.octets.slice(0)},t.prototype.toIPv4MappedAddress=function(){return d.IPv6.parse(`::ffff:${this.toString()}`)},t.prototype.toNormalizedString=function(){return this.toString()},t.prototype.toString=function(){return this.octets.join(".")},t}(),d.IPv4.broadcastAddressFromCIDR=function(t){try{const e=this.parseCIDR(t),r=e[0].toByteArray(),n=this.subnetMaskFromPrefixLength(e[1]).toByteArray(),i=[];let o=0;for(;o<4;)i.push(parseInt(r[o],10)|255^parseInt(n[o],10)),o++;return new this(i)}catch(t){throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},d.IPv4.isIPv4=function(t){return null!==this.parser(t)},d.IPv4.isValid=function(t){try{return new this(this.parser(t)),!0}catch(t){return!1}},d.IPv4.isValidFourPartDecimal=function(t){return!(!d.IPv4.isValid(t)||!t.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},d.IPv4.networkAddressFromCIDR=function(t){let e,r,n,i,o;try{for(e=this.parseCIDR(t),n=e[0].toByteArray(),o=this.subnetMaskFromPrefixLength(e[1]).toByteArray(),i=[],r=0;r<4;)i.push(parseInt(n[r],10)&parseInt(o[r],10)),r++;return new this(i)}catch(t){throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},d.IPv4.parse=function(t){const e=this.parser(t);if(null===e)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(e)},d.IPv4.parseCIDR=function(t){let e;if(e=t.match(/^(.+)\/(\d+)$/)){const t=parseInt(e[2]);if(t>=0&&t<=32){const r=[this.parse(e[1]),t];return Object.defineProperty(r,"toString",{value:function(){return this.join("/")}}),r}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},d.IPv4.parser=function(t){let e,r,i;if(e=t.match(n.fourOctet))return function(){const t=e.slice(1,6),n=[];for(let e=0;e<t.length;e++)r=t[e],n.push(l(r));return n}();if(e=t.match(n.longValue)){if(i=l(e[1]),i>4294967295||i<0)throw new Error("ipaddr: address outside defined range");return function(){const t=[];let e;for(e=0;e<=24;e+=8)t.push(i>>e&255);return t}().reverse()}return(e=t.match(n.twoOctet))?function(){const t=e.slice(1,4),r=[];if(i=l(t[1]),i>16777215||i<0)throw new Error("ipaddr: address outside defined range");return r.push(l(t[0])),r.push(i>>16&255),r.push(i>>8&255),r.push(255&i),r}():(e=t.match(n.threeOctet))?function(){const t=e.slice(1,5),r=[];if(i=l(t[2]),i>65535||i<0)throw new Error("ipaddr: address outside defined range");return r.push(l(t[0])),r.push(l(t[1])),r.push(i>>8&255),r.push(255&i),r}():null},d.IPv4.subnetMaskFromPrefixLength=function(t){if((t=parseInt(t))<0||t>32)throw new Error("ipaddr: invalid IPv4 prefix length");const e=[0,0,0,0];let r=0;const n=Math.floor(t/8);for(;r<n;)e[r]=255,r++;return n<4&&(e[n]=Math.pow(2,t%8)-1<<8-t%8),new this(e)},d.IPv6=function(){function t(t,e){let r,n;if(16===t.length)for(this.parts=[],r=0;r<=14;r+=2)this.parts.push(t[r]<<8|t[r+1]);else{if(8!==t.length)throw new Error("ipaddr: ipv6 part count should be 8 or 16");this.parts=t}for(r=0;r<this.parts.length;r++)if(n=this.parts[r],!(0<=n&&n<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");e&&(this.zoneId=e)}return t.prototype.SpecialRanges={unspecified:[new t([0,0,0,0,0,0,0,0]),128],linkLocal:[new t([65152,0,0,0,0,0,0,0]),10],multicast:[new t([65280,0,0,0,0,0,0,0]),8],loopback:[new t([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new t([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new t([0,0,0,0,0,65535,0,0]),96],rfc6145:[new t([0,0,0,0,65535,0,0,0]),96],rfc6052:[new t([100,65435,0,0,0,0,0,0]),96],"6to4":[new t([8194,0,0,0,0,0,0,0]),16],teredo:[new t([8193,0,0,0,0,0,0,0]),32],reserved:[[new t([8193,3512,0,0,0,0,0,0]),32]],benchmarking:[new t([8193,2,0,0,0,0,0,0]),48],amt:[new t([8193,3,0,0,0,0,0,0]),32],as112v6:[new t([8193,4,274,0,0,0,0,0]),48],deprecated:[new t([8193,16,0,0,0,0,0,0]),28],orchid2:[new t([8193,32,0,0,0,0,0,0]),28]},t.prototype.isIPv4MappedAddress=function(){return"ipv4Mapped"===this.range()},t.prototype.kind=function(){return"ipv6"},t.prototype.match=function(t,e){let r;if(void 0===e&&(r=t,t=r[0],e=r[1]),"ipv6"!==t.kind())throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return h(this.parts,t.parts,16,e)},t.prototype.prefixLengthFromSubnetMask=function(){let t=0,e=!1;const r={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0};let n,i;for(let o=7;o>=0;o-=1){if(n=this.parts[o],!(n in r))return null;if(i=r[n],e&&0!==i)return null;16!==i&&(e=!0),t+=i}return 128-t},t.prototype.range=function(){return d.subnetMatch(this,this.SpecialRanges)},t.prototype.toByteArray=function(){let t;const e=[],r=this.parts;for(let n=0;n<r.length;n++)t=r[n],e.push(t>>8),e.push(255&t);return e},t.prototype.toFixedLengthString=function(){const t=function(){const t=[];for(let e=0;e<this.parts.length;e++)t.push(f(this.parts[e].toString(16),4));return t}.call(this).join(":");let e="";return this.zoneId&&(e=`%${this.zoneId}`),t+e},t.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");const t=this.parts.slice(-2),e=t[0],r=t[1];return new d.IPv4([e>>8,255&e,r>>8,255&r])},t.prototype.toNormalizedString=function(){const t=function(){const t=[];for(let e=0;e<this.parts.length;e++)t.push(this.parts[e].toString(16));return t}.call(this).join(":");let e="";return this.zoneId&&(e=`%${this.zoneId}`),t+e},t.prototype.toRFC5952String=function(){const t=/((^|:)(0(:|$)){2,})/g,e=this.toNormalizedString();let r,n=0,i=-1;for(;r=t.exec(e);)r[0].length>i&&(n=r.index,i=r[0].length);return i<0?e:`${e.substring(0,n)}::${e.substring(n+i)}`},t.prototype.toString=function(){return this.toRFC5952String()},t}(),d.IPv6.broadcastAddressFromCIDR=function(t){try{const e=this.parseCIDR(t),r=e[0].toByteArray(),n=this.subnetMaskFromPrefixLength(e[1]).toByteArray(),i=[];let o=0;for(;o<16;)i.push(parseInt(r[o],10)|255^parseInt(n[o],10)),o++;return new this(i)}catch(t){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${t})`)}},d.IPv6.isIPv6=function(t){return null!==this.parser(t)},d.IPv6.isValid=function(t){if("string"==typeof t&&-1===t.indexOf(":"))return!1;try{const e=this.parser(t);return new this(e.parts,e.zoneId),!0}catch(t){return!1}},d.IPv6.networkAddressFromCIDR=function(t){let e,r,n,i,o;try{for(e=this.parseCIDR(t),n=e[0].toByteArray(),o=this.subnetMaskFromPrefixLength(e[1]).toByteArray(),i=[],r=0;r<16;)i.push(parseInt(n[r],10)&parseInt(o[r],10)),r++;return new this(i)}catch(t){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${t})`)}},d.IPv6.parse=function(t){const e=this.parser(t);if(null===e.parts)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(e.parts,e.zoneId)},d.IPv6.parseCIDR=function(t){let e,r,n;if((r=t.match(/^(.+)\/(\d+)$/))&&(e=parseInt(r[2]),e>=0&&e<=128))return n=[this.parse(r[1]),e],Object.defineProperty(n,"toString",{value:function(){return this.join("/")}}),n;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},d.IPv6.parser=function(t){let e,r,n,i,o,s;if(n=t.match(u.deprecatedTransitional))return this.parser(`::ffff:${n[1]}`);if(u.native.test(t))return c(t,8);if((n=t.match(u.transitional))&&(s=n[6]||"",e=c(n[1].slice(0,-1)+s,6),e.parts)){for(o=[parseInt(n[2]),parseInt(n[3]),parseInt(n[4]),parseInt(n[5])],r=0;r<o.length;r++)if(i=o[r],!(0<=i&&i<=255))return null;return e.parts.push(o[0]<<8|o[1]),e.parts.push(o[2]<<8|o[3]),{parts:e.parts,zoneId:e.zoneId}}return null},d.IPv6.subnetMaskFromPrefixLength=function(t){if((t=parseInt(t))<0||t>128)throw new Error("ipaddr: invalid IPv6 prefix length");const e=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];let r=0;const n=Math.floor(t/8);for(;r<n;)e[r]=255,r++;return n<16&&(e[n]=Math.pow(2,t%8)-1<<8-t%8),new this(e)},d.fromByteArray=function(t){const e=t.length;if(4===e)return new d.IPv4(t);if(16===e)return new d.IPv6(t);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},d.isValid=function(t){return d.IPv6.isValid(t)||d.IPv4.isValid(t)},d.parse=function(t){if(d.IPv6.isValid(t))return d.IPv6.parse(t);if(d.IPv4.isValid(t))return d.IPv4.parse(t);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},d.parseCIDR=function(t){try{return d.IPv6.parseCIDR(t)}catch(e){try{return d.IPv4.parseCIDR(t)}catch(t){throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},d.process=function(t){const e=this.parse(t);return"ipv6"===e.kind()&&e.isIPv4MappedAddress()?e.toIPv4Address():e},d.subnetMatch=function(t,e,r){let n,i,o,s;for(i in null==r&&(r="unicast"),e)if(Object.prototype.hasOwnProperty.call(e,i))for(o=e[i],!o[0]||o[0]instanceof Array||(o=[o]),n=0;n<o.length;n++)if(s=o[n],t.kind()===s[0].kind()&&t.match.apply(t,s))return i;return r},e.exports?e.exports=d:t.ipaddr=d}(t)}(uM);var cM=e(uM.exports);const hM=2147483647,lM=36,fM={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},dM=Math.floor,pM=String.fromCharCode;function yM(t){throw new RangeError(fM[t])}const gM=function(t,e){return t+22+75*(t<26)-((0!=e)<<5)},mM=function(t,e,r){let n=0;for(t=r?dM(t/700):t>>1,t+=dM(t/e);t>455;n+=lM)t=dM(t/35);return dM(n+36*t/(t+38))},wM=function(t){const e=[];t=function(t){const e=[];let r=0;const n=t.length;for(;r<n;){const i=t.charCodeAt(r++);if(i>=55296&&i<=56319&&r<n){const n=t.charCodeAt(r++);56320==(64512&n)?e.push(((1023&i)<<10)+(1023&n)+65536):(e.push(i),r--)}else e.push(i)}return e}(t);const r=t.length;let n=128,i=0,o=72;for(const r of t)r<128&&e.push(pM(r));const s=e.length;let a=s;for(s&&e.push("-");a<r;){let r=hM;for(const e of t)e>=n&&e<r&&(r=e);const u=a+1;r-n>dM((hM-i)/u)&&yM("overflow"),i+=(r-n)*u,n=r;for(const r of t)if(r<n&&++i>hM&&yM("overflow"),r===n){let t=i;for(let r=lM;;r+=lM){const n=r<=o?1:r>=o+26?26:r-o;if(t<n)break;const i=t-n,s=lM-n;e.push(pM(gM(n+i%s,0))),t=dM(i/s)}e.push(pM(gM(t,0))),o=mM(i,u,a===s),i=0,++a}++i,++n}return e.join("")};function bM(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var vM={exports:{}};!function(t){var e=function(t){var e,r=new Float64Array(16);if(t)for(e=0;e<t.length;e++)r[e]=t[e];return r},r=function(){throw new Error("no PRNG")},n=new Uint8Array(16),i=new Uint8Array(32);i[0]=9;var o=e(),s=e([1]),a=e([56129,1]),u=e([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),c=e([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),h=e([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),l=e([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),f=e([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function d(t,e,r,n){t[e]=r>>24&255,t[e+1]=r>>16&255,t[e+2]=r>>8&255,t[e+3]=255&r,t[e+4]=n>>24&255,t[e+5]=n>>16&255,t[e+6]=n>>8&255,t[e+7]=255&n}function p(t,e,r,n,i){var o,s=0;for(o=0;o<i;o++)s|=t[e+o]^r[n+o];return(1&s-1>>>8)-1}function y(t,e,r,n){return p(t,e,r,n,16)}function g(t,e,r,n){return p(t,e,r,n,32)}function m(t,e,r,n){!function(t,e,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,u=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,c=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&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,f=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,d=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,p=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,y=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,g=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,k=s,E=a,x=u,S=c,A=h,I=l,B=f,M=d,R=p,P=y,T=g,O=m,L=w,U=b,C=v,N=0;N<20;N+=2)_^=(i=(O^=(i=(M^=(i=(S^=(i=_+O|0)<<7|i>>>25)+_|0)<<9|i>>>23)+S|0)<<13|i>>>19)+M|0)<<18|i>>>14,A^=(i=(k^=(i=(L^=(i=(R^=(i=A+k|0)<<7|i>>>25)+A|0)<<9|i>>>23)+R|0)<<13|i>>>19)+L|0)<<18|i>>>14,P^=(i=(I^=(i=(E^=(i=(U^=(i=P+I|0)<<7|i>>>25)+P|0)<<9|i>>>23)+U|0)<<13|i>>>19)+E|0)<<18|i>>>14,C^=(i=(T^=(i=(B^=(i=(x^=(i=C+T|0)<<7|i>>>25)+C|0)<<9|i>>>23)+x|0)<<13|i>>>19)+B|0)<<18|i>>>14,_^=(i=(x^=(i=(E^=(i=(k^=(i=_+x|0)<<7|i>>>25)+_|0)<<9|i>>>23)+k|0)<<13|i>>>19)+E|0)<<18|i>>>14,A^=(i=(S^=(i=(B^=(i=(I^=(i=A+S|0)<<7|i>>>25)+A|0)<<9|i>>>23)+I|0)<<13|i>>>19)+B|0)<<18|i>>>14,P^=(i=(R^=(i=(M^=(i=(T^=(i=P+R|0)<<7|i>>>25)+P|0)<<9|i>>>23)+T|0)<<13|i>>>19)+M|0)<<18|i>>>14,C^=(i=(U^=(i=(L^=(i=(O^=(i=C+U|0)<<7|i>>>25)+C|0)<<9|i>>>23)+O|0)<<13|i>>>19)+L|0)<<18|i>>>14;_=_+o|0,k=k+s|0,E=E+a|0,x=x+u|0,S=S+c|0,A=A+h|0,I=I+l|0,B=B+f|0,M=M+d|0,R=R+p|0,P=P+y|0,T=T+g|0,O=O+m|0,L=L+w|0,U=U+b|0,C=C+v|0,t[0]=_>>>0&255,t[1]=_>>>8&255,t[2]=_>>>16&255,t[3]=_>>>24&255,t[4]=k>>>0&255,t[5]=k>>>8&255,t[6]=k>>>16&255,t[7]=k>>>24&255,t[8]=E>>>0&255,t[9]=E>>>8&255,t[10]=E>>>16&255,t[11]=E>>>24&255,t[12]=x>>>0&255,t[13]=x>>>8&255,t[14]=x>>>16&255,t[15]=x>>>24&255,t[16]=S>>>0&255,t[17]=S>>>8&255,t[18]=S>>>16&255,t[19]=S>>>24&255,t[20]=A>>>0&255,t[21]=A>>>8&255,t[22]=A>>>16&255,t[23]=A>>>24&255,t[24]=I>>>0&255,t[25]=I>>>8&255,t[26]=I>>>16&255,t[27]=I>>>24&255,t[28]=B>>>0&255,t[29]=B>>>8&255,t[30]=B>>>16&255,t[31]=B>>>24&255,t[32]=M>>>0&255,t[33]=M>>>8&255,t[34]=M>>>16&255,t[35]=M>>>24&255,t[36]=R>>>0&255,t[37]=R>>>8&255,t[38]=R>>>16&255,t[39]=R>>>24&255,t[40]=P>>>0&255,t[41]=P>>>8&255,t[42]=P>>>16&255,t[43]=P>>>24&255,t[44]=T>>>0&255,t[45]=T>>>8&255,t[46]=T>>>16&255,t[47]=T>>>24&255,t[48]=O>>>0&255,t[49]=O>>>8&255,t[50]=O>>>16&255,t[51]=O>>>24&255,t[52]=L>>>0&255,t[53]=L>>>8&255,t[54]=L>>>16&255,t[55]=L>>>24&255,t[56]=U>>>0&255,t[57]=U>>>8&255,t[58]=U>>>16&255,t[59]=U>>>24&255,t[60]=C>>>0&255,t[61]=C>>>8&255,t[62]=C>>>16&255,t[63]=C>>>24&255}(t,e,r,n)}function w(t,e,r,n){!function(t,e,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,u=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,c=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&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,f=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,d=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,p=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,y=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,g=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=(c^=(i=o+m|0)<<7|i>>>25)+o|0)<<9|i>>>23)+c|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,y^=(i=(l^=(i=(a^=(i=(b^=(i=y+l|0)<<7|i>>>25)+y|0)<<9|i>>>23)+b|0)<<13|i>>>19)+a|0)<<18|i>>>14,v^=(i=(g^=(i=(f^=(i=(u^=(i=v+g|0)<<7|i>>>25)+v|0)<<9|i>>>23)+u|0)<<13|i>>>19)+f|0)<<18|i>>>14,o^=(i=(u^=(i=(a^=(i=(s^=(i=o+u|0)<<7|i>>>25)+o|0)<<9|i>>>23)+s|0)<<13|i>>>19)+a|0)<<18|i>>>14,h^=(i=(c^=(i=(f^=(i=(l^=(i=h+c|0)<<7|i>>>25)+h|0)<<9|i>>>23)+l|0)<<13|i>>>19)+f|0)<<18|i>>>14,y^=(i=(p^=(i=(d^=(i=(g^=(i=y+p|0)<<7|i>>>25)+y|0)<<9|i>>>23)+g|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;t[0]=o>>>0&255,t[1]=o>>>8&255,t[2]=o>>>16&255,t[3]=o>>>24&255,t[4]=h>>>0&255,t[5]=h>>>8&255,t[6]=h>>>16&255,t[7]=h>>>24&255,t[8]=y>>>0&255,t[9]=y>>>8&255,t[10]=y>>>16&255,t[11]=y>>>24&255,t[12]=v>>>0&255,t[13]=v>>>8&255,t[14]=v>>>16&255,t[15]=v>>>24&255,t[16]=l>>>0&255,t[17]=l>>>8&255,t[18]=l>>>16&255,t[19]=l>>>24&255,t[20]=f>>>0&255,t[21]=f>>>8&255,t[22]=f>>>16&255,t[23]=f>>>24&255,t[24]=d>>>0&255,t[25]=d>>>8&255,t[26]=d>>>16&255,t[27]=d>>>24&255,t[28]=p>>>0&255,t[29]=p>>>8&255,t[30]=p>>>16&255,t[31]=p>>>24&255}(t,e,r,n)}var b=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function v(t,e,r,n,i,o,s){var a,u,c=new Uint8Array(16),h=new Uint8Array(64);for(u=0;u<16;u++)c[u]=0;for(u=0;u<8;u++)c[u]=o[u];for(;i>=64;){for(m(h,c,s,b),u=0;u<64;u++)t[e+u]=r[n+u]^h[u];for(a=1,u=8;u<16;u++)a=a+(255&c[u])|0,c[u]=255&a,a>>>=8;i-=64,e+=64,n+=64}if(i>0)for(m(h,c,s,b),u=0;u<i;u++)t[e+u]=r[n+u]^h[u];return 0}function _(t,e,r,n,i){var o,s,a=new Uint8Array(16),u=new Uint8Array(64);for(s=0;s<16;s++)a[s]=0;for(s=0;s<8;s++)a[s]=n[s];for(;r>=64;){for(m(u,a,i,b),s=0;s<64;s++)t[e+s]=u[s];for(o=1,s=8;s<16;s++)o=o+(255&a[s])|0,a[s]=255&o,o>>>=8;r-=64,e+=64}if(r>0)for(m(u,a,i,b),s=0;s<r;s++)t[e+s]=u[s];return 0}function k(t,e,r,n,i){var o=new Uint8Array(32);w(o,n,i,b);for(var s=new Uint8Array(8),a=0;a<8;a++)s[a]=n[a+16];return _(t,e,r,s,o)}function E(t,e,r,n,i,o,s){var a=new Uint8Array(32);w(a,o,s,b);for(var u=new Uint8Array(8),c=0;c<8;c++)u[c]=o[c+16];return v(t,e,r,n,i,u,a)}var x=function(t){var e,r,n,i,o,s,a,u;this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0,e=255&t[0]|(255&t[1])<<8,this.r[0]=8191&e,r=255&t[2]|(255&t[3])<<8,this.r[1]=8191&(e>>>13|r<<3),n=255&t[4]|(255&t[5])<<8,this.r[2]=7939&(r>>>10|n<<6),i=255&t[6]|(255&t[7])<<8,this.r[3]=8191&(n>>>7|i<<9),o=255&t[8]|(255&t[9])<<8,this.r[4]=255&(i>>>4|o<<12),this.r[5]=o>>>1&8190,s=255&t[10]|(255&t[11])<<8,this.r[6]=8191&(o>>>14|s<<2),a=255&t[12]|(255&t[13])<<8,this.r[7]=8065&(s>>>11|a<<5),u=255&t[14]|(255&t[15])<<8,this.r[8]=8191&(a>>>8|u<<8),this.r[9]=u>>>5&127,this.pad[0]=255&t[16]|(255&t[17])<<8,this.pad[1]=255&t[18]|(255&t[19])<<8,this.pad[2]=255&t[20]|(255&t[21])<<8,this.pad[3]=255&t[22]|(255&t[23])<<8,this.pad[4]=255&t[24]|(255&t[25])<<8,this.pad[5]=255&t[26]|(255&t[27])<<8,this.pad[6]=255&t[28]|(255&t[29])<<8,this.pad[7]=255&t[30]|(255&t[31])<<8};function S(t,e,r,n,i,o){var s=new x(o);return s.update(r,n,i),s.finish(t,e),0}function A(t,e,r,n,i,o){var s=new Uint8Array(16);return S(s,0,r,n,i,o),y(t,e,s,0)}function I(t,e,r,n,i){var o;if(r<32)return-1;for(E(t,0,e,0,r,n,i),S(t,16,t,32,r-32,t),o=0;o<16;o++)t[o]=0;return 0}function B(t,e,r,n,i){var o,s=new Uint8Array(32);if(r<32)return-1;if(k(s,0,32,n,i),0!==A(e,16,e,32,r-32,s))return-1;for(E(t,0,e,0,r,n,i),o=0;o<32;o++)t[o]=0;return 0}function M(t,e){var r;for(r=0;r<16;r++)t[r]=0|e[r]}function R(t){var e,r,n=1;for(e=0;e<16;e++)r=t[e]+n+65535,n=Math.floor(r/65536),t[e]=r-65536*n;t[0]+=n-1+37*(n-1)}function P(t,e,r){for(var n,i=~(r-1),o=0;o<16;o++)n=i&(t[o]^e[o]),t[o]^=n,e[o]^=n}function T(t,r){var n,i,o,s=e(),a=e();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,P(a,s,1-o)}for(n=0;n<16;n++)t[2*n]=255&a[n],t[2*n+1]=a[n]>>8}function O(t,e){var r=new Uint8Array(32),n=new Uint8Array(32);return T(r,t),T(n,e),g(r,0,n,0)}function L(t){var e=new Uint8Array(32);return T(e,t),1&e[0]}function U(t,e){var r;for(r=0;r<16;r++)t[r]=e[2*r]+(e[2*r+1]<<8);t[15]&=32767}function C(t,e,r){for(var n=0;n<16;n++)t[n]=e[n]+r[n]}function N(t,e,r){for(var n=0;n<16;n++)t[n]=e[n]-r[n]}function z(t,e,r){var n,i,o=0,s=0,a=0,u=0,c=0,h=0,l=0,f=0,d=0,p=0,y=0,g=0,m=0,w=0,b=0,v=0,_=0,k=0,E=0,x=0,S=0,A=0,I=0,B=0,M=0,R=0,P=0,T=0,O=0,L=0,U=0,C=r[0],N=r[1],z=r[2],D=r[3],j=r[4],W=r[5],K=r[6],F=r[7],q=r[8],V=r[9],H=r[10],$=r[11],G=r[12],Z=r[13],Y=r[14],J=r[15];o+=(n=e[0])*C,s+=n*N,a+=n*z,u+=n*D,c+=n*j,h+=n*W,l+=n*K,f+=n*F,d+=n*q,p+=n*V,y+=n*H,g+=n*$,m+=n*G,w+=n*Z,b+=n*Y,v+=n*J,s+=(n=e[1])*C,a+=n*N,u+=n*z,c+=n*D,h+=n*j,l+=n*W,f+=n*K,d+=n*F,p+=n*q,y+=n*V,g+=n*H,m+=n*$,w+=n*G,b+=n*Z,v+=n*Y,_+=n*J,a+=(n=e[2])*C,u+=n*N,c+=n*z,h+=n*D,l+=n*j,f+=n*W,d+=n*K,p+=n*F,y+=n*q,g+=n*V,m+=n*H,w+=n*$,b+=n*G,v+=n*Z,_+=n*Y,k+=n*J,u+=(n=e[3])*C,c+=n*N,h+=n*z,l+=n*D,f+=n*j,d+=n*W,p+=n*K,y+=n*F,g+=n*q,m+=n*V,w+=n*H,b+=n*$,v+=n*G,_+=n*Z,k+=n*Y,E+=n*J,c+=(n=e[4])*C,h+=n*N,l+=n*z,f+=n*D,d+=n*j,p+=n*W,y+=n*K,g+=n*F,m+=n*q,w+=n*V,b+=n*H,v+=n*$,_+=n*G,k+=n*Z,E+=n*Y,x+=n*J,h+=(n=e[5])*C,l+=n*N,f+=n*z,d+=n*D,p+=n*j,y+=n*W,g+=n*K,m+=n*F,w+=n*q,b+=n*V,v+=n*H,_+=n*$,k+=n*G,E+=n*Z,x+=n*Y,S+=n*J,l+=(n=e[6])*C,f+=n*N,d+=n*z,p+=n*D,y+=n*j,g+=n*W,m+=n*K,w+=n*F,b+=n*q,v+=n*V,_+=n*H,k+=n*$,E+=n*G,x+=n*Z,S+=n*Y,A+=n*J,f+=(n=e[7])*C,d+=n*N,p+=n*z,y+=n*D,g+=n*j,m+=n*W,w+=n*K,b+=n*F,v+=n*q,_+=n*V,k+=n*H,E+=n*$,x+=n*G,S+=n*Z,A+=n*Y,I+=n*J,d+=(n=e[8])*C,p+=n*N,y+=n*z,g+=n*D,m+=n*j,w+=n*W,b+=n*K,v+=n*F,_+=n*q,k+=n*V,E+=n*H,x+=n*$,S+=n*G,A+=n*Z,I+=n*Y,B+=n*J,p+=(n=e[9])*C,y+=n*N,g+=n*z,m+=n*D,w+=n*j,b+=n*W,v+=n*K,_+=n*F,k+=n*q,E+=n*V,x+=n*H,S+=n*$,A+=n*G,I+=n*Z,B+=n*Y,M+=n*J,y+=(n=e[10])*C,g+=n*N,m+=n*z,w+=n*D,b+=n*j,v+=n*W,_+=n*K,k+=n*F,E+=n*q,x+=n*V,S+=n*H,A+=n*$,I+=n*G,B+=n*Z,M+=n*Y,R+=n*J,g+=(n=e[11])*C,m+=n*N,w+=n*z,b+=n*D,v+=n*j,_+=n*W,k+=n*K,E+=n*F,x+=n*q,S+=n*V,A+=n*H,I+=n*$,B+=n*G,M+=n*Z,R+=n*Y,P+=n*J,m+=(n=e[12])*C,w+=n*N,b+=n*z,v+=n*D,_+=n*j,k+=n*W,E+=n*K,x+=n*F,S+=n*q,A+=n*V,I+=n*H,B+=n*$,M+=n*G,R+=n*Z,P+=n*Y,T+=n*J,w+=(n=e[13])*C,b+=n*N,v+=n*z,_+=n*D,k+=n*j,E+=n*W,x+=n*K,S+=n*F,A+=n*q,I+=n*V,B+=n*H,M+=n*$,R+=n*G,P+=n*Z,T+=n*Y,O+=n*J,b+=(n=e[14])*C,v+=n*N,_+=n*z,k+=n*D,E+=n*j,x+=n*W,S+=n*K,A+=n*F,I+=n*q,B+=n*V,M+=n*H,R+=n*$,P+=n*G,T+=n*Z,O+=n*Y,L+=n*J,v+=(n=e[15])*C,s+=38*(k+=n*z),a+=38*(E+=n*D),u+=38*(x+=n*j),c+=38*(S+=n*W),h+=38*(A+=n*K),l+=38*(I+=n*F),f+=38*(B+=n*q),d+=38*(M+=n*V),p+=38*(R+=n*H),y+=38*(P+=n*$),g+=38*(T+=n*G),m+=38*(O+=n*Z),w+=38*(L+=n*Y),b+=38*(U+=n*J),o=(n=(o+=38*(_+=n*N))+(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)),u=(n=u+i+65535)-65536*(i=Math.floor(n/65536)),c=(n=c+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)),y=(n=y+i+65535)-65536*(i=Math.floor(n/65536)),g=(n=g+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)),u=(n=u+i+65535)-65536*(i=Math.floor(n/65536)),c=(n=c+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)),y=(n=y+i+65535)-65536*(i=Math.floor(n/65536)),g=(n=g+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),t[0]=o,t[1]=s,t[2]=a,t[3]=u,t[4]=c,t[5]=h,t[6]=l,t[7]=f,t[8]=d,t[9]=p,t[10]=y,t[11]=g,t[12]=m,t[13]=w,t[14]=b,t[15]=v}function D(t,e){z(t,e,e)}function j(t,r){var n,i=e();for(n=0;n<16;n++)i[n]=r[n];for(n=253;n>=0;n--)D(i,i),2!==n&&4!==n&&z(i,i,r);for(n=0;n<16;n++)t[n]=i[n]}function W(t,r){var n,i=e();for(n=0;n<16;n++)i[n]=r[n];for(n=250;n>=0;n--)D(i,i),1!==n&&z(i,i,r);for(n=0;n<16;n++)t[n]=i[n]}function K(t,r,n){var i,o,s=new Uint8Array(32),u=new Float64Array(80),c=e(),h=e(),l=e(),f=e(),d=e(),p=e();for(o=0;o<31;o++)s[o]=r[o];for(s[31]=127&r[31]|64,s[0]&=248,U(u,n),o=0;o<16;o++)h[o]=u[o],f[o]=c[o]=l[o]=0;for(c[0]=f[0]=1,o=254;o>=0;--o)P(c,h,i=s[o>>>3]>>>(7&o)&1),P(l,f,i),C(d,c,l),N(c,c,l),C(l,h,f),N(h,h,f),D(f,d),D(p,c),z(c,l,c),z(l,h,d),C(d,c,l),N(c,c,l),D(h,c),N(l,f,p),z(c,l,a),C(c,c,f),z(l,l,c),z(c,f,p),z(f,h,u),D(h,d),P(c,h,i),P(l,f,i);for(o=0;o<16;o++)u[o+16]=c[o],u[o+32]=l[o],u[o+48]=h[o],u[o+64]=f[o];var y=u.subarray(32),g=u.subarray(16);return j(y,y),z(g,g,y),T(t,g),0}function F(t,e){return K(t,e,i)}function q(t,e){return r(e,32),F(t,e)}function V(t,e,r){var i=new Uint8Array(32);return K(i,r,e),w(t,n,i,b)}x.prototype.blocks=function(t,e,r){for(var n,i,o,s,a,u,c,h,l,f,d,p,y,g,m,w,b,v,_,k=this.fin?0:2048,E=this.h[0],x=this.h[1],S=this.h[2],A=this.h[3],I=this.h[4],B=this.h[5],M=this.h[6],R=this.h[7],P=this.h[8],T=this.h[9],O=this.r[0],L=this.r[1],U=this.r[2],C=this.r[3],N=this.r[4],z=this.r[5],D=this.r[6],j=this.r[7],W=this.r[8],K=this.r[9];r>=16;)f=l=0,f+=(E+=8191&(n=255&t[e+0]|(255&t[e+1])<<8))*O,f+=(x+=8191&(n>>>13|(i=255&t[e+2]|(255&t[e+3])<<8)<<3))*(5*K),f+=(S+=8191&(i>>>10|(o=255&t[e+4]|(255&t[e+5])<<8)<<6))*(5*W),f+=(A+=8191&(o>>>7|(s=255&t[e+6]|(255&t[e+7])<<8)<<9))*(5*j),l=(f+=(I+=8191&(s>>>4|(a=255&t[e+8]|(255&t[e+9])<<8)<<12))*(5*D))>>>13,f&=8191,f+=(B+=a>>>1&8191)*(5*z),f+=(M+=8191&(a>>>14|(u=255&t[e+10]|(255&t[e+11])<<8)<<2))*(5*N),f+=(R+=8191&(u>>>11|(c=255&t[e+12]|(255&t[e+13])<<8)<<5))*(5*C),f+=(P+=8191&(c>>>8|(h=255&t[e+14]|(255&t[e+15])<<8)<<8))*(5*U),d=l+=(f+=(T+=h>>>5|k)*(5*L))>>>13,d+=E*L,d+=x*O,d+=S*(5*K),d+=A*(5*W),l=(d+=I*(5*j))>>>13,d&=8191,d+=B*(5*D),d+=M*(5*z),d+=R*(5*N),d+=P*(5*C),l+=(d+=T*(5*U))>>>13,d&=8191,p=l,p+=E*U,p+=x*L,p+=S*O,p+=A*(5*K),l=(p+=I*(5*W))>>>13,p&=8191,p+=B*(5*j),p+=M*(5*D),p+=R*(5*z),p+=P*(5*N),y=l+=(p+=T*(5*C))>>>13,y+=E*C,y+=x*U,y+=S*L,y+=A*O,l=(y+=I*(5*K))>>>13,y&=8191,y+=B*(5*W),y+=M*(5*j),y+=R*(5*D),y+=P*(5*z),g=l+=(y+=T*(5*N))>>>13,g+=E*N,g+=x*C,g+=S*U,g+=A*L,l=(g+=I*O)>>>13,g&=8191,g+=B*(5*K),g+=M*(5*W),g+=R*(5*j),g+=P*(5*D),m=l+=(g+=T*(5*z))>>>13,m+=E*z,m+=x*N,m+=S*C,m+=A*U,l=(m+=I*L)>>>13,m&=8191,m+=B*O,m+=M*(5*K),m+=R*(5*W),m+=P*(5*j),w=l+=(m+=T*(5*D))>>>13,w+=E*D,w+=x*z,w+=S*N,w+=A*C,l=(w+=I*U)>>>13,w&=8191,w+=B*L,w+=M*O,w+=R*(5*K),w+=P*(5*W),b=l+=(w+=T*(5*j))>>>13,b+=E*j,b+=x*D,b+=S*z,b+=A*N,l=(b+=I*C)>>>13,b&=8191,b+=B*U,b+=M*L,b+=R*O,b+=P*(5*K),v=l+=(b+=T*(5*W))>>>13,v+=E*W,v+=x*j,v+=S*D,v+=A*z,l=(v+=I*N)>>>13,v&=8191,v+=B*C,v+=M*U,v+=R*L,v+=P*O,_=l+=(v+=T*(5*K))>>>13,_+=E*K,_+=x*W,_+=S*j,_+=A*D,l=(_+=I*z)>>>13,_&=8191,_+=B*N,_+=M*C,_+=R*U,_+=P*L,E=f=8191&(l=(l=((l+=(_+=T*O)>>>13)<<2)+l|0)+(f&=8191)|0),x=d+=l>>>=13,S=p&=8191,A=y&=8191,I=g&=8191,B=m&=8191,M=w&=8191,R=b&=8191,P=v&=8191,T=_&=8191,e+=16,r-=16;this.h[0]=E,this.h[1]=x,this.h[2]=S,this.h[3]=A,this.h[4]=I,this.h[5]=B,this.h[6]=M,this.h[7]=R,this.h[8]=P,this.h[9]=T},x.prototype.finish=function(t,e){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;t[e+0]=this.h[0]>>>0&255,t[e+1]=this.h[0]>>>8&255,t[e+2]=this.h[1]>>>0&255,t[e+3]=this.h[1]>>>8&255,t[e+4]=this.h[2]>>>0&255,t[e+5]=this.h[2]>>>8&255,t[e+6]=this.h[3]>>>0&255,t[e+7]=this.h[3]>>>8&255,t[e+8]=this.h[4]>>>0&255,t[e+9]=this.h[4]>>>8&255,t[e+10]=this.h[5]>>>0&255,t[e+11]=this.h[5]>>>8&255,t[e+12]=this.h[6]>>>0&255,t[e+13]=this.h[6]>>>8&255,t[e+14]=this.h[7]>>>0&255,t[e+15]=this.h[7]>>>8&255},x.prototype.update=function(t,e,r){var n,i;if(this.leftover){for((i=16-this.leftover)>r&&(i=r),n=0;n<i;n++)this.buffer[this.leftover+n]=t[e+n];if(r-=i,e+=i,this.leftover+=i,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(r>=16&&(i=r-r%16,this.blocks(t,e,i),e+=i,r-=i),r){for(n=0;n<r;n++)this.buffer[this.leftover+n]=t[e+n];this.leftover+=r}};var H=I,$=B,G=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function Z(t,e,r,n){for(var i,o,s,a,u,c,h,l,f,d,p,y,g,m,w,b,v,_,k,E,x,S,A,I,B,M,R=new Int32Array(16),P=new Int32Array(16),T=t[0],O=t[1],L=t[2],U=t[3],C=t[4],N=t[5],z=t[6],D=t[7],j=e[0],W=e[1],K=e[2],F=e[3],q=e[4],V=e[5],H=e[6],$=e[7],Z=0;n>=128;){for(k=0;k<16;k++)E=8*k+Z,R[k]=r[E+0]<<24|r[E+1]<<16|r[E+2]<<8|r[E+3],P[k]=r[E+4]<<24|r[E+5]<<16|r[E+6]<<8|r[E+7];for(k=0;k<80;k++)if(i=T,o=O,s=L,a=U,u=C,c=N,h=z,f=j,d=W,p=K,y=F,g=q,m=V,w=H,A=65535&(S=$),I=S>>>16,B=65535&(x=D),M=x>>>16,A+=65535&(S=(q>>>14|C<<18)^(q>>>18|C<<14)^(C>>>9|q<<23)),I+=S>>>16,B+=65535&(x=(C>>>14|q<<18)^(C>>>18|q<<14)^(q>>>9|C<<23)),M+=x>>>16,A+=65535&(S=q&V^~q&H),I+=S>>>16,B+=65535&(x=C&N^~C&z),M+=x>>>16,x=G[2*k],A+=65535&(S=G[2*k+1]),I+=S>>>16,B+=65535&x,M+=x>>>16,x=R[k%16],I+=(S=P[k%16])>>>16,B+=65535&x,M+=x>>>16,B+=(I+=(A+=65535&S)>>>16)>>>16,A=65535&(S=_=65535&A|I<<16),I=S>>>16,B=65535&(x=v=65535&B|(M+=B>>>16)<<16),M=x>>>16,A+=65535&(S=(j>>>28|T<<4)^(T>>>2|j<<30)^(T>>>7|j<<25)),I+=S>>>16,B+=65535&(x=(T>>>28|j<<4)^(j>>>2|T<<30)^(j>>>7|T<<25)),M+=x>>>16,I+=(S=j&W^j&K^W&K)>>>16,B+=65535&(x=T&O^T&L^O&L),M+=x>>>16,l=65535&(B+=(I+=(A+=65535&S)>>>16)>>>16)|(M+=B>>>16)<<16,b=65535&A|I<<16,A=65535&(S=y),I=S>>>16,B=65535&(x=a),M=x>>>16,I+=(S=_)>>>16,B+=65535&(x=v),M+=x>>>16,O=i,L=o,U=s,C=a=65535&(B+=(I+=(A+=65535&S)>>>16)>>>16)|(M+=B>>>16)<<16,N=u,z=c,D=h,T=l,W=f,K=d,F=p,q=y=65535&A|I<<16,V=g,H=m,$=w,j=b,k%16==15)for(E=0;E<16;E++)x=R[E],A=65535&(S=P[E]),I=S>>>16,B=65535&x,M=x>>>16,x=R[(E+9)%16],A+=65535&(S=P[(E+9)%16]),I+=S>>>16,B+=65535&x,M+=x>>>16,v=R[(E+1)%16],A+=65535&(S=((_=P[(E+1)%16])>>>1|v<<31)^(_>>>8|v<<24)^(_>>>7|v<<25)),I+=S>>>16,B+=65535&(x=(v>>>1|_<<31)^(v>>>8|_<<24)^v>>>7),M+=x>>>16,v=R[(E+14)%16],I+=(S=((_=P[(E+14)%16])>>>19|v<<13)^(v>>>29|_<<3)^(_>>>6|v<<26))>>>16,B+=65535&(x=(v>>>19|_<<13)^(_>>>29|v<<3)^v>>>6),M+=x>>>16,M+=(B+=(I+=(A+=65535&S)>>>16)>>>16)>>>16,R[E]=65535&B|M<<16,P[E]=65535&A|I<<16;A=65535&(S=j),I=S>>>16,B=65535&(x=T),M=x>>>16,x=t[0],I+=(S=e[0])>>>16,B+=65535&x,M+=x>>>16,M+=(B+=(I+=(A+=65535&S)>>>16)>>>16)>>>16,t[0]=T=65535&B|M<<16,e[0]=j=65535&A|I<<16,A=65535&(S=W),I=S>>>16,B=65535&(x=O),M=x>>>16,x=t[1],I+=(S=e[1])>>>16,B+=65535&x,M+=x>>>16,M+=(B+=(I+=(A+=65535&S)>>>16)>>>16)>>>16,t[1]=O=65535&B|M<<16,e[1]=W=65535&A|I<<16,A=65535&(S=K),I=S>>>16,B=65535&(x=L),M=x>>>16,x=t[2],I+=(S=e[2])>>>16,B+=65535&x,M+=x>>>16,M+=(B+=(I+=(A+=65535&S)>>>16)>>>16)>>>16,t[2]=L=65535&B|M<<16,e[2]=K=65535&A|I<<16,A=65535&(S=F),I=S>>>16,B=65535&(x=U),M=x>>>16,x=t[3],I+=(S=e[3])>>>16,B+=65535&x,M+=x>>>16,M+=(B+=(I+=(A+=65535&S)>>>16)>>>16)>>>16,t[3]=U=65535&B|M<<16,e[3]=F=65535&A|I<<16,A=65535&(S=q),I=S>>>16,B=65535&(x=C),M=x>>>16,x=t[4],I+=(S=e[4])>>>16,B+=65535&x,M+=x>>>16,M+=(B+=(I+=(A+=65535&S)>>>16)>>>16)>>>16,t[4]=C=65535&B|M<<16,e[4]=q=65535&A|I<<16,A=65535&(S=V),I=S>>>16,B=65535&(x=N),M=x>>>16,x=t[5],I+=(S=e[5])>>>16,B+=65535&x,M+=x>>>16,M+=(B+=(I+=(A+=65535&S)>>>16)>>>16)>>>16,t[5]=N=65535&B|M<<16,e[5]=V=65535&A|I<<16,A=65535&(S=H),I=S>>>16,B=65535&(x=z),M=x>>>16,x=t[6],I+=(S=e[6])>>>16,B+=65535&x,M+=x>>>16,M+=(B+=(I+=(A+=65535&S)>>>16)>>>16)>>>16,t[6]=z=65535&B|M<<16,e[6]=H=65535&A|I<<16,A=65535&(S=$),I=S>>>16,B=65535&(x=D),M=x>>>16,x=t[7],I+=(S=e[7])>>>16,B+=65535&x,M+=x>>>16,M+=(B+=(I+=(A+=65535&S)>>>16)>>>16)>>>16,t[7]=D=65535&B|M<<16,e[7]=$=65535&A|I<<16,Z+=128,n-=128}return n}function Y(t,e,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,Z(i,o,e,r),r%=128,n=0;n<r;n++)s[n]=e[a-r+n];for(s[r]=128,s[(r=256-128*(r<112?1:0))-9]=0,d(s,r-8,a/536870912|0,a<<3),Z(i,o,s,r),n=0;n<8;n++)d(t,8*n,i[n],o[n]);return 0}function J(t,r){var n=e(),i=e(),o=e(),s=e(),a=e(),u=e(),h=e(),l=e(),f=e();N(n,t[1],t[0]),N(f,r[1],r[0]),z(n,n,f),C(i,t[0],t[1]),C(f,r[0],r[1]),z(i,i,f),z(o,t[3],r[3]),z(o,o,c),z(s,t[2],r[2]),C(s,s,s),N(a,i,n),N(u,s,o),C(h,s,o),C(l,i,n),z(t[0],a,u),z(t[1],l,h),z(t[2],h,u),z(t[3],a,l)}function X(t,e,r){var n;for(n=0;n<4;n++)P(t[n],e[n],r)}function Q(t,r){var n=e(),i=e(),o=e();j(o,r[2]),z(n,r[0],o),z(i,r[1],o),T(t,i),t[31]^=L(n)<<7}function tt(t,e,r){var n,i;for(M(t[0],o),M(t[1],s),M(t[2],s),M(t[3],o),i=255;i>=0;--i)X(t,e,n=r[i/8|0]>>(7&i)&1),J(e,t),J(t,t),X(t,e,n)}function et(t,r){var n=[e(),e(),e(),e()];M(n[0],h),M(n[1],l),M(n[2],s),z(n[3],h,l),tt(t,n,r)}function rt(t,n,i){var o,s=new Uint8Array(64),a=[e(),e(),e(),e()];for(i||r(n,32),Y(s,n,32),s[0]&=248,s[31]&=127,s[31]|=64,et(a,s),Q(t,a),o=0;o<32;o++)n[o+32]=t[o];return 0}var nt=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 it(t,e){var r,n,i,o;for(n=63;n>=32;--n){for(r=0,i=n-32,o=n-12;i<o;++i)e[i]+=r-16*e[n]*nt[i-(n-32)],r=Math.floor((e[i]+128)/256),e[i]-=256*r;e[i]+=r,e[n]=0}for(r=0,i=0;i<32;i++)e[i]+=r-(e[31]>>4)*nt[i],r=e[i]>>8,e[i]&=255;for(i=0;i<32;i++)e[i]-=r*nt[i];for(n=0;n<32;n++)e[n+1]+=e[n]>>8,t[n]=255&e[n]}function ot(t){var e,r=new Float64Array(64);for(e=0;e<64;e++)r[e]=t[e];for(e=0;e<64;e++)t[e]=0;it(t,r)}function st(t,r,n,i){var o,s,a=new Uint8Array(64),u=new Uint8Array(64),c=new Uint8Array(64),h=new Float64Array(64),l=[e(),e(),e(),e()];Y(a,i,32),a[0]&=248,a[31]&=127,a[31]|=64;var f=n+64;for(o=0;o<n;o++)t[64+o]=r[o];for(o=0;o<32;o++)t[32+o]=a[32+o];for(Y(c,t.subarray(32),n+32),ot(c),et(l,c),Q(t,l),o=32;o<64;o++)t[o]=i[o];for(Y(u,t,n+64),ot(u),o=0;o<64;o++)h[o]=0;for(o=0;o<32;o++)h[o]=c[o];for(o=0;o<32;o++)for(s=0;s<32;s++)h[o+s]+=u[o]*a[s];return it(t.subarray(32),h),f}function at(t,r,n,i){var a,c=new Uint8Array(32),h=new Uint8Array(64),l=[e(),e(),e(),e()],d=[e(),e(),e(),e()];if(n<64)return-1;if(function(t,r){var n=e(),i=e(),a=e(),c=e(),h=e(),l=e(),d=e();return M(t[2],s),U(t[1],r),D(a,t[1]),z(c,a,u),N(a,a,t[2]),C(c,t[2],c),D(h,c),D(l,h),z(d,l,h),z(n,d,a),z(n,n,c),W(n,n),z(n,n,a),z(n,n,c),z(n,n,c),z(t[0],n,c),D(i,t[0]),z(i,i,c),O(i,a)&&z(t[0],t[0],f),D(i,t[0]),z(i,i,c),O(i,a)?-1:(L(t[0])===r[31]>>7&&N(t[0],o,t[0]),z(t[3],t[0],t[1]),0)}(d,i))return-1;for(a=0;a<n;a++)t[a]=r[a];for(a=0;a<32;a++)t[a+32]=i[a];if(Y(h,t,n),ot(h),tt(l,d,h),et(d,r.subarray(32)),J(l,d),Q(c,l),n-=64,g(r,0,c,0)){for(a=0;a<n;a++)t[a]=0;return-1}for(a=0;a<n;a++)t[a]=r[a+64];return n}var ut=16,ct=64,ht=32,lt=64;function ft(t,e){if(32!==t.length)throw new Error("bad key size");if(24!==e.length)throw new Error("bad nonce size")}function dt(){for(var t=0;t<arguments.length;t++)if(!(arguments[t]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function pt(t){for(var e=0;e<t.length;e++)t[e]=0}t.lowlevel={crypto_core_hsalsa20:w,crypto_stream_xor:E,crypto_stream:k,crypto_stream_salsa20_xor:v,crypto_stream_salsa20:_,crypto_onetimeauth:S,crypto_onetimeauth_verify:A,crypto_verify_16:y,crypto_verify_32:g,crypto_secretbox:I,crypto_secretbox_open:B,crypto_scalarmult:K,crypto_scalarmult_base:F,crypto_box_beforenm:V,crypto_box_afternm:H,crypto_box:function(t,e,r,n,i,o){var s=new Uint8Array(32);return V(s,i,o),H(t,e,r,n,s)},crypto_box_open:function(t,e,r,n,i,o){var s=new Uint8Array(32);return V(s,i,o),$(t,e,r,n,s)},crypto_box_keypair:q,crypto_hash:Y,crypto_sign:st,crypto_sign_keypair:rt,crypto_sign_open:at,crypto_secretbox_KEYBYTES:32,crypto_secretbox_NONCEBYTES:24,crypto_secretbox_ZEROBYTES:32,crypto_secretbox_BOXZEROBYTES:ut,crypto_scalarmult_BYTES:32,crypto_scalarmult_SCALARBYTES:32,crypto_box_PUBLICKEYBYTES:32,crypto_box_SECRETKEYBYTES:32,crypto_box_BEFORENMBYTES:32,crypto_box_NONCEBYTES:24,crypto_box_ZEROBYTES:32,crypto_box_BOXZEROBYTES:16,crypto_sign_BYTES:ct,crypto_sign_PUBLICKEYBYTES:ht,crypto_sign_SECRETKEYBYTES:lt,crypto_sign_SEEDBYTES:32,crypto_hash_BYTES:64,gf:e,D:u,L:nt,pack25519:T,unpack25519:U,M:z,A:C,S:D,Z:N,pow2523:W,add:J,set25519:M,modL:it,scalarmult:tt,scalarbase:et},t.randomBytes=function(t){var e=new Uint8Array(t);return r(e,t),e},t.secretbox=function(t,e,r){dt(t,e,r),ft(r,e);for(var n=new Uint8Array(32+t.length),i=new Uint8Array(n.length),o=0;o<t.length;o++)n[o+32]=t[o];return I(i,n,n.length,e,r),i.subarray(ut)},t.secretbox.open=function(t,e,r){dt(t,e,r),ft(r,e);for(var n=new Uint8Array(ut+t.length),i=new Uint8Array(n.length),o=0;o<t.length;o++)n[o+ut]=t[o];return n.length<32||0!==B(i,n,n.length,e,r)?null:i.subarray(32)},t.secretbox.keyLength=32,t.secretbox.nonceLength=24,t.secretbox.overheadLength=ut,t.scalarMult=function(t,e){if(dt(t,e),32!==t.length)throw new Error("bad n size");if(32!==e.length)throw new Error("bad p size");var r=new Uint8Array(32);return K(r,t,e),r},t.scalarMult.base=function(t){if(dt(t),32!==t.length)throw new Error("bad n size");var e=new Uint8Array(32);return F(e,t),e},t.scalarMult.scalarLength=32,t.scalarMult.groupElementLength=32,t.box=function(e,r,n,i){var o=t.box.before(n,i);return t.secretbox(e,r,o)},t.box.before=function(t,e){dt(t,e),function(t,e){if(32!==t.length)throw new Error("bad public key size");if(32!==e.length)throw new Error("bad secret key size")}(t,e);var r=new Uint8Array(32);return V(r,t,e),r},t.box.after=t.secretbox,t.box.open=function(e,r,n,i){var o=t.box.before(n,i);return t.secretbox.open(e,r,o)},t.box.open.after=t.secretbox.open,t.box.keyPair=function(){var t=new Uint8Array(32),e=new Uint8Array(32);return q(t,e),{publicKey:t,secretKey:e}},t.box.keyPair.fromSecretKey=function(t){if(dt(t),32!==t.length)throw new Error("bad secret key size");var e=new Uint8Array(32);return F(e,t),{publicKey:e,secretKey:new Uint8Array(t)}},t.box.publicKeyLength=32,t.box.secretKeyLength=32,t.box.sharedKeyLength=32,t.box.nonceLength=24,t.box.overheadLength=t.secretbox.overheadLength,t.sign=function(t,e){if(dt(t,e),e.length!==lt)throw new Error("bad secret key size");var r=new Uint8Array(ct+t.length);return st(r,t,t.length,e),r},t.sign.open=function(t,e){if(dt(t,e),e.length!==ht)throw new Error("bad public key size");var r=new Uint8Array(t.length),n=at(r,t,t.length,e);if(n<0)return null;for(var i=new Uint8Array(n),o=0;o<i.length;o++)i[o]=r[o];return i},t.sign.detached=function(e,r){for(var n=t.sign(e,r),i=new Uint8Array(ct),o=0;o<i.length;o++)i[o]=n[o];return i},t.sign.detached.verify=function(t,e,r){if(dt(t,e,r),e.length!==ct)throw new Error("bad signature size");if(r.length!==ht)throw new Error("bad public key size");var n,i=new Uint8Array(ct+t.length),o=new Uint8Array(ct+t.length);for(n=0;n<ct;n++)i[n]=e[n];for(n=0;n<t.length;n++)i[n+ct]=t[n];return at(o,i,i.length,r)>=0},t.sign.keyPair=function(){var t=new Uint8Array(ht),e=new Uint8Array(lt);return rt(t,e),{publicKey:t,secretKey:e}},t.sign.keyPair.fromSecretKey=function(t){if(dt(t),t.length!==lt)throw new Error("bad secret key size");for(var e=new Uint8Array(ht),r=0;r<e.length;r++)e[r]=t[32+r];return{publicKey:e,secretKey:new Uint8Array(t)}},t.sign.keyPair.fromSeed=function(t){if(dt(t),32!==t.length)throw new Error("bad seed size");for(var e=new Uint8Array(ht),r=new Uint8Array(lt),n=0;n<32;n++)r[n]=t[n];return rt(e,r,!0),{publicKey:e,secretKey:r}},t.sign.publicKeyLength=ht,t.sign.secretKeyLength=lt,t.sign.seedLength=32,t.sign.signatureLength=ct,t.hash=function(t){dt(t);var e=new Uint8Array(64);return Y(e,t,t.length),e},t.hash.hashLength=64,t.verify=function(t,e){return dt(t,e),0!==t.length&&0!==e.length&&t.length===e.length&&0===p(t,0,e,0,t.length)},t.setPRNG=function(t){r=t},function(){var e="undefined"!=typeof self?self.crypto||self.msCrypto:null;e&&e.getRandomValues?t.setPRNG((function(t,r){var n,i=new Uint8Array(r);for(n=0;n<r;n+=65536)e.getRandomValues(i.subarray(n,n+Math.min(r-n,65536)));for(n=0;n<r;n++)t[n]=i[n];pt(i)})):void 0!==bM&&(e=ee)&&e.randomBytes&&t.setPRNG((function(t,r){var n,i=e.randomBytes(r);for(n=0;n<r;n++)t[n]=i[n];pt(i)}))}()}(vM.exports?vM.exports:self.nacl=self.nacl||{});var _M=vM.exports;const kM=(t,e,r)=>_M.sign.detached.verify(t,e,r.toBytes()),EM=(t,e)=>{const{pubkey:r}=TB(e+"."+t,exports.RecordVersion.V1);return r};async function xM(t,e,r,n){const i=EM(e,r);let{registry:o}=await oh.retrieve(t,i);if(!o.data)throw new Dc(exports.ErrorType.NoRecordData);if(n)return AM(o,r,i);const s=SB.get(r);return o.data=o.data.slice(0,s),o}const SM=async(t,e)=>await xM(t,e,exports.Record.SOL),AM=(t,e,r)=>{const i=null==t?void 0:t.data;if(!i)return;if(0===i.compare(n.Buffer.alloc(i.length)))return;const o=SB.get(e),s=(t=>{const e=Array.from(t);return e.length-1-e.reverse().findIndex((t=>0!==t))+1})(i);if(!o)return i.slice(0,s).toString("utf-8");if(e===exports.Record.SOL){const e=new TextEncoder,o=n.Buffer.concat([i.slice(0,32),r.toBuffer()]),s=e.encode(o.toString("hex"));if(kM(s,i.slice(32,96),t.owner))return Uv.encode(i.slice(0,32))}if(o&&s!==o){const t=i.slice(0,s).toString("utf-8");if(e===exports.Record.Injective){const e=JB(t);if("inj"===e.prefix&&20===e.data.length)return t}else if(e===exports.Record.BSC||e===exports.Record.ETH){const e=t.slice(0,2),r=t.slice(2);if("0x"===e&&20===n.Buffer.from(r,"hex").length)return t}else if((e===exports.Record.A||e===exports.Record.AAAA)&&cM.isValid(t))return t;throw new Dc(exports.ErrorType.InvalidRecordData)}if(e===exports.Record.ETH||e===exports.Record.BSC)return"0x"+i.slice(0,o).toString("hex");if(e===exports.Record.Injective)return XB("inj",i.slice(0,o),"bech32");if(e===exports.Record.A||e===exports.Record.AAAA)return cM.fromByteArray([...i.slice(0,o)]).toString();if(e===exports.Record.Background)return new Wo(i.slice(0,o)).toString();throw new Dc(exports.ErrorType.InvalidRecordData)},IM=(t,e)=>{if(!SB.get(e))return e!==exports.Record.CNAME&&e!==exports.Record.TXT||(t=wM(t)),n.Buffer.from(t,"utf-8");if(e===exports.Record.SOL)throw new Dc(exports.ErrorType.UnsupportedRecord,"Use `serializeSolRecord` for SOL record");if(e===exports.Record.ETH||e===exports.Record.BSC)return UB("0x"===t.slice(0,2),exports.ErrorType.InvalidEvmAddress),n.Buffer.from(t.slice(2),"hex");if(e===exports.Record.Injective){const e=JB(t);return UB("inj"===e.prefix,exports.ErrorType.InvalidInjectiveAddress),UB(20===e.data.length,exports.ErrorType.InvalidInjectiveAddress),n.Buffer.from(e.data)}if(e===exports.Record.A){const e=cM.parse(t).toByteArray();return UB(4===e.length,exports.ErrorType.InvalidARecord),n.Buffer.from(e)}if(e===exports.Record.AAAA){const e=cM.parse(t).toByteArray();return UB(16===e.length,exports.ErrorType.InvalidAAAARecord),n.Buffer.from(e)}if(e===exports.Record.Background)return new Wo(t).toBuffer();throw new Dc(exports.ErrorType.InvalidRecordInput)},BM=(t,e,r,i)=>{const o=n.Buffer.concat([t.toBuffer(),e.toBuffer()]),s=(new TextEncoder).encode(o.toString("hex")),a=kM(s,i,r);return UB(a,exports.ErrorType.InvalidSignature),n.Buffer.concat([t.toBuffer(),i])},MM=async(t,e)=>{const{pubkey:r}=TB(e),{registry:n,nftOwner:i}=await oh.retrieve(t,r);if(i)return i;try{const r=await PM(t,n.owner,e);if(void 0!==r)return r;return await RM(t,n.owner,e)}catch(t){if(t instanceof Error&&"FetchError"===t.name)throw t}return n.owner},RM=async(t,e,r)=>{const i=EM(r,exports.Record.SOL),o=await SM(t,r);if(!(null==o?void 0:o.data))throw new Dc(exports.ErrorType.NoRecordData);const s=new TextEncoder,a=n.Buffer.concat([o.data.slice(0,32),i.toBuffer()]),u=s.encode(a.toString("hex"));if(!kM(u,o.data.slice(32),e))throw new Dc(exports.ErrorType.InvalidSignature);return new Wo(o.data.slice(0,32))},PM=async(t,e,r)=>{try{const n=NM(r,exports.Record.SOL),i=await EB.retrieve(t,n),o=i.getStalenessId(),s=i.getRoAId(),a=i.getContent();if(0===o.compare(e.toBuffer())&&i.header.stalenessValidation===vB.Solana&&0===s.compare(a)&&i.header.rightOfAssociationValidation===vB.Solana)return new Wo(a)}catch(t){if(t instanceof Error&&"FetchError"===t.name)throw t}},TM=new Map([[exports.Record.Backpack,new Wo("ExXjtfdQe8JacoqP9Z535WzQKjF4CzW1TTRKRgpxvya3")],[exports.Record.Url,new Wo("ExXjtfdQe8JacoqP9Z535WzQKjF4CzW1TTRKRgpxvya3")]]),OM=new Set([exports.Record.ETH,exports.Record.Injective,exports.Record.BSC]),LM=new Set([exports.Record.IPFS,exports.Record.ARWV,exports.Record.LTC,exports.Record.DOGE,exports.Record.Email,exports.Record.Url,exports.Record.Discord,exports.Record.Github,exports.Record.Reddit,exports.Record.Twitter,exports.Record.Telegram,exports.Record.Pic,exports.Record.SHDW,exports.Record.POINT,exports.Record.Backpack,exports.Record.TXT,exports.Record.CNAME,exports.Record.BTC]),UM=new Set([exports.Record.ETH,exports.Record.Injective,exports.Record.SOL]),CM=(t,e)=>{if(LM.has(e))return e!==exports.Record.CNAME&&e!==exports.Record.TXT||(t=wM(t)),Buffer.from(t,"utf-8");if(e===exports.Record.SOL)return new Wo(t).toBuffer();if(e===exports.Record.ETH||e===exports.Record.BSC)return UB("0x"===t.slice(0,2),exports.ErrorType.InvalidEvmAddress),Buffer.from(t.slice(2),"hex");if(e===exports.Record.Injective){const e=JB(t);return UB("inj"===e.prefix,exports.ErrorType.InvalidInjectiveAddress),UB(20===e.data.length,exports.ErrorType.InvalidInjectiveAddress),Buffer.from(e.data)}if(e===exports.Record.A){const e=cM.parse(t).toByteArray();return UB(4===e.length,exports.ErrorType.InvalidARecord),Buffer.from(e)}if(e===exports.Record.AAAA){const e=cM.parse(t).toByteArray();return UB(16===e.length,exports.ErrorType.InvalidAAAARecord),Buffer.from(e)}throw new Dc(exports.ErrorType.InvalidARecord)},NM=(t,e)=>{const{pubkey:r}=TB(t),n=IB("".concat(e));return BB(n,bB,r)};async function zM(t,e,r,n,i,o,s,a){const u=await Kf(e),c=await Ff(u,s,a),h=o||await t.getMinimumBalanceForRentExemption(r);let l;if(a){const{registry:e}=await Wf(t,a);l=e.owner}return Kc(Ef,Os.programId,c,i,n,u,new Wc(h),new jc(r),s,a,l)}async function DM(t,e,r,n,i){const o=await Kf(e),s=await Ff(o,n,i);let a;a=n||(await oh.retrieve(t,s)).registry.owner;return Vc(Ef,s,r,a)}const jM=async(t,e,r,n,i)=>{let[o]=await Wo.findProgramAddress([Af.toBuffer()],Af),s=await Kf(t.toBase58()),a=await Ff(s,o,n);return[[],[new $c({name:e}).getInstruction(Af,Ef,Sf,a,Os.programId,o,r,ms,n,i)]]},WM=async(t,e,r,n,i,o)=>{UB(r!==exports.Record.SOL,exports.ErrorType.UnsupportedRecord);const{pubkey:s,hashed:a,parent:u}=TB(`${r}.${e}`,exports.RecordVersion.V1),c=IM(n,r).length,h=await t.getMinimumBalanceForRentExemption(c+oh.HEADER_LEN);return Kc(Ef,Os.programId,s,i,o,a,new Wc(h),new jc(c),void 0,u,i)},KM=async(t,e,r,n,i,o)=>{const{pubkey:s,hashed:a,parent:u}=TB(`${exports.Record.SOL}.${e}`,exports.RecordVersion.V1),c=BM(r,s,n,i).length,h=await t.getMinimumBalanceForRentExemption(c+oh.HEADER_LEN);return[Kc(Ef,Os.programId,s,n,o,a,new Wc(h),new jc(c),void 0,u,n)]};class FM{constructor(t){this.twitterRegistryKey=t.twitterRegistryKey,this.twitterHandle=t.twitterHandle}static async retrieve(t,e){let r=await t.getAccountInfo(e,"processed");if(!r)throw new Dc(exports.ErrorType.InvalidReverseTwitter);return Oe(this.schema,FM,r.data.slice(oh.HEADER_LEN))}}async function qM(t,e,r,i,o){const s=await Kf(i.toString()),a=await Ff(s,Rf,Pf);let u=He(FM.schema,new FM({twitterRegistryKey:r.toBytes(),twitterHandle:e}));return[Kc(Ef,Os.programId,a,i,o,s,new Wc(await t.getMinimumBalanceForRentExemption(u.length+oh.HEADER_LEN)),new jc(u.length),Rf,Pf,Rf),Fc(Ef,a,new jc(0),n.Buffer.from(u),Rf)]}FM.schema=new Map([[FM,{kind:"struct",fields:[["twitterRegistryKey",[32]],["twitterHandle","string"]]}]]);const VM=new Wo("85iDfUvr3HJyLM2zcq5BXSiDvUWfw6cSE1FfNBo8Ap29");class HM{constructor(t){this.tag=t.tag,this.nameAccount=new Wo(t.nameAccount)}static deserialize(t){return Ze(this.schema,HM,t)}static async retrieve(t,e){const r=await t.getAccountInfo(e);if(!r||!r.data)throw new Dc(exports.ErrorType.FavouriteDomainNotFound);return this.deserialize(r.data)}static async getKey(t,e){return await Wo.findProgramAddress([n.Buffer.from("favourite_domain"),e.toBuffer()],t)}static getKeySync(t,e){return Wo.findProgramAddressSync([n.Buffer.from("favourite_domain"),e.toBuffer()],t)}}HM.schema=new Map([[HM,{kind:"struct",fields:[["tag","u8"],["nameAccount",[32]]]}]]);var $M;exports.CustomBg=void 0,($M=exports.CustomBg||(exports.CustomBg={})).DegenPoet1="DegenPoet#1",$M.Rgb0x001="rgb0x00#1";const GM=new Wo("ART5dr4bDic2sQVZoFheEmUxwQq5VGSx9he7JxHcXNQD"),ZM=new Wo("CSWvuDHXExVGEMR9kP8xYAHuNjXogeRck9Cnr312CC9g");exports.BONFIDA_FIDA_BNB=Bf,exports.BONFIDA_USDC_BNB=Tf,exports.CUSTOM_BG_TLD=zf,exports.ETH_ROA_RECORDS=OM,exports.FavouriteDomain=HM,exports.GUARDIANS=TM,exports.HASH_PREFIX=xf,exports.METAPLEX_ID=jf,exports.NAME_OFFERS_ID=VM,exports.NAME_PROGRAM_ID=Ef,exports.NameRegistryState=oh,exports.Numberu32=jc,exports.Numberu64=Wc,exports.PYTH_FIDA_PRICE_ACC=If,exports.PYTH_MAPPING_ACC=Cf,exports.RECORD_V1_SIZE=SB,exports.REFERRERS=Lf,exports.REGISTER_PROGRAM_ID=Af,exports.REVERSE_LOOKUP_CLASS=Mf,exports.ROOT_DOMAIN_ACCOUNT=Sf,exports.ReverseTwitterRegistryState=FM,exports.SELF_SIGNED=UM,exports.SNSError=Dc,exports.SOL_RECORD_SIG_LEN=96,exports.TOKENS_SYM_MINT=Uf,exports.TWITTER_ROOT_PARENT_REGISTRY_KEY=Pf,exports.TWITTER_VERIFICATION_AUTHORITY=Rf,exports.USDC_MINT=Of,exports.UTF8_ENCODED=LM,exports.VAULT_OWNER=Nf,exports.WOLVES_COLLECTION_METADATA=Df,exports.burnDomain=(t,e,r)=>{const{pubkey:n}=TB(t),[i]=Wo.findProgramAddressSync([n.toBuffer()],Af),[o]=Wo.findProgramAddressSync([n.toBuffer(),Uint8Array.from([1,1])],Af);return(new Yc).getInstruction(Af,Ef,Os.programId,n,LB(t),o,i,Mf,e,r)},exports.burnInstruction=Yc,exports.changeTwitterRegistryData=async function(t,e,r,n){const i=await Kf(t),o=await Ff(i,void 0,Pf);return[Fc(Ef,o,new jc(r),n,e)]},exports.changeVerifiedPubkey=async function(t,e,r,n,i){const o=await Kf(e),s=await Ff(o,void 0,Pf);let a=[qc(Ef,s,n,r,void 0)];const u=await Kf(r.toString());return await Ff(u,Rf,void 0),a.push(await DM(t,r.toString(),i,Rf,Pf)),a=a.concat(await qM(t,e,s,n,i)),a},exports.check=UB,exports.checkSolRecord=kM,exports.createInstruction=Kc,exports.createInstructionV3=Gc,exports.createNameRegistry=zM,exports.createRecordInstruction=WM,exports.createRecordV2Instruction=(t,e,r,n,i)=>{const{pubkey:o,parent:s}=TB(`${e}.${t}`,exports.RecordVersion.V2);if(!s)throw new Error("Invalid parent");const a=((t,e,r,n,i,o,s,a)=>new fB({record:o,content:Array.from(s)}).getInstruction(a,sI.programId,i,t,e,r,n,bB))(i,o,s,n,Ef,"".concat(e),CM(r,e),wB);return a},exports.createReverseInstruction=$c,exports.createReverseName=jM,exports.createReverseTwitterRegistry=qM,exports.createSolRecordInstruction=KM,exports.createSubdomain=async(t,e,r,n=2e3)=>{const i=[],o=e.split(".")[0];if(!o)throw new Dc(exports.ErrorType.InvalidSubdomain);const{parent:s,pubkey:a}=TB(e),u=await t.getMinimumBalanceForRentExemption(n+oh.HEADER_LEN),c=await zM(t,"\0".concat(o),n,r,r,u,void 0,s);i.push(c);const h=LB(e,!0),l=await t.getAccountInfo(h);if(!(null==l?void 0:l.data)){const[,t]=await jM(a,"\0".concat(o),r,s,r);i.push(...t)}return[[],i]},exports.createV2Instruction=Hc,exports.createVerifiedTwitterRegistry=async function(t,e,r,n,i){const o=await Kf(e),s=await Ff(o,void 0,Pf),a=await t.getMinimumBalanceForRentExemption(n+oh.HEADER_LEN);let u=[Kc(Ef,Os.programId,s,r,i,o,new Wc(a),new jc(n),void 0,Pf,Rf)];return u=u.concat(await qM(t,e,s,r,i)),u},exports.createWithNftInstruction=Zc,exports.deleteInstruction=Vc,exports.deleteNameRegistry=DM,exports.deleteRecordV2=(t,e,r,n)=>{const{pubkey:i,parent:o}=TB(`${e}.${t}`,exports.RecordVersion.V2);if(!o)throw new Error("Invalid parent");const s=((t,e,r,n,i,o)=>(new gB).getInstruction(o,sI.programId,i,t,n,e,r,bB))(n,o,r,i,Ef,wB);return s},exports.deleteTwitterRegistry=async function(t,e){const r=await Kf(t),n=await Ff(r,void 0,Pf),i=await Kf(e.toString()),o=await Ff(i,Rf,Pf);return[Vc(Ef,n,e,e),Vc(Ef,o,e,e)]},exports.deserializeRecord=AM,exports.deserializeRecordV2Content=(t,e)=>{if(LM.has(e)){const r=t.toString("utf-8");return e===exports.Record.CNAME||e===exports.Record.TXT?function(t){const e=[],r=t.length;let n=0,i=128,o=72,s=t.lastIndexOf("-");s<0&&(s=0);for(let r=0;r<s;++r)t.charCodeAt(r)>=128&&yM("not-basic"),e.push(t.charCodeAt(r));for(let u=s>0?s+1:0;u<r;){const s=n;for(let e=1,i=lM;;i+=lM){u>=r&&yM("invalid-input");const s=(a=t.charCodeAt(u++))>=48&&a<58?a-48+26:a>=65&&a<91?a-65:a>=97&&a<123?a-97:lM;s>=lM&&yM("invalid-input"),s>dM((hM-n)/e)&&yM("overflow"),n+=s*e;const c=i<=o?1:i>=o+26?26:i-o;if(s<c)break;const h=lM-c;e>dM(hM/h)&&yM("overflow"),e*=h}const c=e.length+1;o=mM(n-s,c,0==s),dM(n/c)>hM-i&&yM("overflow"),i+=dM(n/c),n%=c,e.splice(n++,0,i)}var a;return String.fromCodePoint(...e)}(r):r}if(e===exports.Record.SOL)return new Wo(t).toBase58();if(e===exports.Record.ETH||e===exports.Record.BSC)return"0x"+t.toString("hex");if(e===exports.Record.Injective)return XB("inj",t,"bech32");if(e===exports.Record.A||e===exports.Record.AAAA)return cM.fromByteArray([...t]).toString();throw new Dc(exports.ErrorType.InvalidARecord)},exports.ethValidateRecordV2Content=(t,e,r,n,i,o)=>{const{pubkey:s,parent:a}=TB(`${e}.${t}`,exports.RecordVersion.V2);if(!a)throw new Error("Invalid parent");const u=((t,e,r,n,i,o,s,a,u)=>new dB({validation:o,signature:Array.from(s),expectedPubkey:Array.from(a)}).getInstruction(u,sI.programId,i,t,e,r,n,bB))(n,s,a,r,Ef,vB.Ethereum,i,o,wB);return u},exports.findSubdomains=async(t,e)=>{const r=[{memcmp:{offset:0,bytes:e.toBase58()}},{memcmp:{offset:64,bytes:Mf.toBase58()}}],n=await t.getProgramAccounts(Ef,{filters:r}),i=await MB(t,e),o=n.map((t=>{var e;return null===(e=t.account.data.slice(97).toString("utf-8"))||void 0===e?void 0:e.split("\0").join("")})),s=o.map((t=>TB(t+"."+i).pubkey)),a=await t.getMultipleAccountsInfo(s);return o.filter(((t,e)=>!!a[e]))},exports.getAllDomains=OB,exports.getAllRegisteredDomains=async t=>{const e=[{memcmp:{offset:0,bytes:Sf.toBase58()}}];return await t.getProgramAccounts(Ef,{dataSlice:{offset:32,length:32},filters:e})},exports.getArtistPubkey=t=>{switch(t){case exports.CustomBg.DegenPoet1:return GM;case exports.CustomBg.Rgb0x001:return ZM;default:throw new Dc(exports.ErrorType.InvalidCustomBg)}},exports.getArweaveRecord=async(t,e)=>await xM(t,e,exports.Record.ARWV,!0),exports.getBackgroundRecord=async(t,e)=>await xM(t,e,exports.Record.Background,!0),exports.getBackpackRecord=async(t,e)=>await xM(t,e,exports.Record.Backpack,!0),exports.getBscRecord=async(t,e)=>await xM(t,e,exports.Record.BSC,!0),exports.getBtcRecord=async(t,e)=>await xM(t,e,exports.Record.BTC,!0),exports.getCustomBgKeys=(t,e)=>{const r=IB(e),n=IB(t),i=BB(n,void 0,zf);return{domainKey:i,bgKey:BB(r,void 0,i)}},exports.getDiscordRecord=async(t,e)=>await xM(t,e,exports.Record.Discord,!0),exports.getDogeRecord=async(t,e)=>await xM(t,e,exports.Record.DOGE,!0),exports.getDomainKey=Vf,exports.getDomainKeySync=TB,exports.getDomainKeysWithReverses=async function(t,e){const r=await OB(t,e),n=await RB(t,r);return r.map(((t,e)=>({pubKey:t,domain:n[e]})))},exports.getEmailRecord=async(t,e)=>await xM(t,e,exports.Record.Email,!0),exports.getEthRecord=async(t,e)=>await xM(t,e,exports.Record.ETH,!0),exports.getFavoriteDomain=async(t,e)=>{const[r]=HM.getKeySync(VM,new Wo(e)),n=await HM.retrieve(t,r),i=await MB(t,n.nameAccount);return{domain:n.nameAccount,reverse:i}},exports.getGithubRecord=async(t,e)=>await xM(t,e,exports.Record.Github,!0),exports.getHandleAndRegistryKey=async function(t,e){const r=await Kf(e.toString()),n=await Ff(r,Rf,Pf);let i=await FM.retrieve(t,n);return[i.twitterHandle,new Wo(i.twitterRegistryKey)]},exports.getHashedName=Kf,exports.getHashedNameSync=IB,exports.getInjectiveRecord=async(t,e)=>await xM(t,e,exports.Record.Injective,!0),exports.getIpfsRecord=async(t,e)=>await xM(t,e,exports.Record.IPFS,!0),exports.getLtcRecord=async(t,e)=>await xM(t,e,exports.Record.LTC,!0),exports.getNameAccountKey=Ff,exports.getNameAccountKeySync=BB,exports.getNameOwner=Wf,exports.getPicRecord=async(t,e)=>await xM(t,e,exports.Record.Pic,!0),exports.getPointRecord=async(t,e)=>await xM(t,e,exports.Record.POINT,!0),exports.getRecord=xM,exports.getRecordKeySync=EM,exports.getRecordV2Key=NM,exports.getRecords=async function(t,e,r,n){const i=r.map((t=>EM(e,t))),o=await oh.retrieveBatch(t,i);return n?o.map(((t,n)=>{if(t)return AM(t,r[n],EM(e,r[n]))})):o},exports.getRedditRecord=async(t,e)=>await xM(t,e,exports.Record.Reddit,!0),exports.getReverseKey=async(t,e)=>{const{pubkey:r,parent:n}=await Vf(t),i=await Kf(r.toBase58());return await Ff(i,Mf,e?n:void 0)},exports.getReverseKeySync=LB,exports.getShdwRecord=async(t,e)=>await xM(t,e,exports.Record.SHDW,!0),exports.getSolRecord=SM,exports.getTelegramRecord=async(t,e)=>await xM(t,e,exports.Record.Telegram,!0),exports.getTokenizedDomains=async(t,e)=>{const r=await ih(t,e),n=await RB(t,r.map((t=>t.nameAccount)));return n.map(((t,e)=>({key:r[e].nameAccount,mint:r[e].nftMint,reverse:t}))).filter((t=>!!t.reverse))},exports.getTwitterHandleandRegistryKeyViaFilters=async function(t,e){const r=[{memcmp:{offset:0,bytes:Pf.toBase58()}},{memcmp:{offset:32,bytes:e.toBase58()}},{memcmp:{offset:64,bytes:Rf.toBase58()}}],n=await t.getProgramAccounts(Ef,{filters:r});for(const t of n)if(t.account.data.length>oh.HEADER_LEN+32){let e=t.account.data.slice(oh.HEADER_LEN),r=Oe(FM.schema,FM,e);return[r.twitterHandle,new Wo(r.twitterRegistryKey)]}throw new Dc(exports.ErrorType.AccountDoesNotExist)},exports.getTwitterRecord=async(t,e)=>await xM(t,e,exports.Record.Twitter,!0),exports.getTwitterRegistry=async function(t,e){const r=await Kf(e),n=await Ff(r,void 0,Pf),{registry:i}=await oh.retrieve(t,n);return i},exports.getTwitterRegistryData=async function(t,e){const r=[{memcmp:{offset:0,bytes:Pf.toBase58()}},{memcmp:{offset:32,bytes:e.toBase58()}},{memcmp:{offset:64,bytes:new Wo(n.Buffer.alloc(32,0)).toBase58()}}],i=await t.getProgramAccounts(Ef,{filters:r});if(i.length>1)throw new Dc(exports.ErrorType.MultipleRegistries);return i[0].account.data.slice(oh.HEADER_LEN)},exports.getTwitterRegistryKey=async function(t){const e=await Kf(t);return await Ff(e,void 0,Pf)},exports.getUrlRecord=async(t,e)=>await xM(t,e,exports.Record.Url,!0),exports.performReverseLookup=async function(t,e){const r=await Kf(e.toBase58()),n=await Ff(r,Mf),{registry:i}=await oh.retrieve(t,n);if(!i.data)throw new Dc(exports.ErrorType.NoAccountData);const o=new ne(i.data.slice(0,4),"le").toNumber();return i.data.slice(4,4+o).toString()},exports.performReverseLookupBatch=async function(t,e){let r=[];for(let t of e){const e=await Kf(t.toBase58()),n=await Ff(e,Mf);r.push(n)}return(await oh.retrieveBatch(t,r)).map((t=>{if(void 0===t||void 0===t.data)return;let e=new ne(t.data.slice(0,4),"le").toNumber();return t.data.slice(4,4+e).toString()}))},exports.reallocInstruction=function(t,e,r,i,o,s){const a=[n.Buffer.from(Int8Array.from([4])),s.toBuffer()],u=n.Buffer.concat(a);return new cs({keys:[{pubkey:e,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:o,isSigner:!0,isWritable:!1}],programId:t,data:u})},exports.registerDomainName=async(t,e,r,n,i,o=Of,s)=>{if(e.includes(".")||e.trim().toLowerCase()!==e)throw new Dc(exports.ErrorType.InvalidDomain);const[a]=Wo.findProgramAddressSync([Af.toBuffer()],Af),u=IB(e),c=BB(u,void 0,Sf),h=IB(c.toBase58()),l=BB(h,a),[f]=Wo.findProgramAddressSync([c.toBuffer()],Af),d=Lf.findIndex((t=>null==s?void 0:s.equals(t)));let p;const y=[];if(-1!==d&&s){p=Cc(o,s,!0);const e=await t.getAccountInfo(p);if(!(null==e?void 0:e.data)){const t=Nc(n,p,s,o);y.push(t)}}const g=new Yv.PythHttpClient(t,Yv.getPythProgramKeyForCluster("mainnet-beta")),m=await g.getData(),w=Uf.get(o.toBase58());if(!w)throw new Dc(exports.ErrorType.SymbolNotFound,`No symbol found for mint ${o.toBase58()}`);const b=m.productPrice.get("Crypto."+w+"/USD"),v=m.productFromSymbol.get("Crypto."+w+"/USD"),_=Cc(o,Nf),k=new Gc({name:e,space:r,referrerIdxOpt:-1!=d?d:null}).getInstruction(Af,Ef,Sf,c,l,Os.programId,a,n,i,Cf,b.productAccountKey,new Wo(v.price_account),_,yc,ms,f,p);return y.push(k),[[],y]},exports.registerWithNft=(t,e,r,n,i,o,s,a,u)=>{const[c]=Wo.findProgramAddressSync([r.toBuffer()],Af);return new Zc({space:e,name:t}).getInstruction(Af,Ef,Sf,r,n,Os.programId,Mf,i,o,s,a,u,Df,yc,ms,c,jf)},exports.resolve=MM,exports.retrieveNftOwner=eh,exports.retrieveNfts=async t=>{const e=await t.getProgramAccounts(Jc,{filters:[{memcmp:{offset:0,bytes:"3"}}]});return e.map((t=>new Wo(t.account.data.slice(66,98))))},exports.retrieveRecords=ih,exports.reverseLookup=MB,exports.reverseLookupBatch=RB,exports.serializeRecord=IM,exports.serializeRecordV2Content=CM,exports.serializeSolRecord=BM,exports.transferInstruction=qc,exports.transferNameOwnership=async function(t,e,r,n,i,o){const s=await Kf(e),a=await Ff(s,n,i);let u;return u=n||(await oh.retrieve(t,a)).registry.owner,qc(Ef,a,r,u,n,i,o)},exports.transferSubdomain=async(t,e,r,n,i)=>{const{pubkey:o,isSub:s,parent:a}=TB(e);if(!a||!s)throw new Dc(exports.ErrorType.InvalidSubdomain);if(!i){const{registry:e}=await oh.retrieve(t,o);i=e.owner}let u,c;n&&(u=a,c=(await oh.retrieve(t,a)).registry.owner);return qc(Ef,o,r,i,void 0,u,c)},exports.updateInstruction=Fc,exports.updateNameRegistryData=async function(t,e,r,n,i,o){const s=await Kf(e),a=await Ff(s,i,o);let u;return u=i||(await oh.retrieve(t,a)).registry.owner,Fc(Ef,a,new jc(r),n,u)},exports.updateRecordInstruction=async(t,e,r,n,i,o)=>{UB(r!==exports.Record.SOL,exports.ErrorType.UnsupportedRecord);const{pubkey:s}=TB(`${r}.${e}`,exports.RecordVersion.V1),a=await t.getAccountInfo(s);UB(!!(null==a?void 0:a.data),exports.ErrorType.AccountDoesNotExist);const u=IM(n,r);if((null==a?void 0:a.data.slice(96).length)!==u.length)return[Vc(Ef,s,o,i),await WM(t,e,r,n,i,o)];return[Fc(Ef,s,new jc(0),u,i)]},exports.updateRecordV2Instruction=(t,e,r,n,i)=>{const{pubkey:o,parent:s}=TB(`${e}.${t}`,exports.RecordVersion.V2);if(!s)throw new Error("Invalid parent");const a=((t,e,r,n,i,o,s,a)=>new yB({record:o,content:Array.from(s)}).getInstruction(a,sI.programId,i,t,e,r,n,bB))(i,o,s,n,Ef,"".concat(e),CM(r,e),wB);return a},exports.updateSolRecordInstruction=async(t,e,r,n,i,o)=>{const{pubkey:s}=TB(`${exports.Record.SOL}.${e}`,exports.RecordVersion.V1),a=await t.getAccountInfo(s);if(UB(!!(null==a?void 0:a.data),exports.ErrorType.AccountDoesNotExist),96!==(null==a?void 0:a.data.length))return[Vc(Ef,s,o,n),await KM(t,e,r,n,i,o)];const u=BM(r,s,n,i);return[Fc(Ef,s,new jc(0),u,n)]},exports.validateRecordV2Content=(t,e,r,n,i,o)=>{const{pubkey:s,parent:a}=TB(`${r}.${e}`,exports.RecordVersion.V2);if(!a)throw new Error("Invalid parent");const u=((t,e,r,n,i,o,s,a)=>new pB({staleness:s}).getInstruction(a,sI.programId,o,t,e,r,n,bB,i))(i,s,a,n,o,Ef,t,wB);return u},exports.verifyRightOfAssociation=async(t,e,r,n)=>{var i;const o=NM(r,e),s=await EB.retrieve(t,o),a=s.getRoAId(),u=OM.has(e)?vB.Ethereum:vB.Solana;if(!(n=null!=n?n:null===(i=TM.get(e))||void 0===i?void 0:i.toBuffer()))throw new Dc(exports.ErrorType.MissingVerifier);return 0===n.compare(a)&&s.header.rightOfAssociationValidation===u},exports.verifyStaleness=async(t,e,r)=>{const n=NM(r,e),i=await MM(t,r),o=await EB.retrieve(t,n),s=o.getStalenessId();return i.equals(new Wo(s))&&o.header.stalenessValidation===vB.Solana},exports.writRoaRecordV2=(t,e,r,n,i)=>{const{pubkey:o,parent:s}=TB(`${e}.${t}`,exports.RecordVersion.V2);if(!s)throw new Error("Invalid parent");const a=((t,e,r,n,i,o,s)=>new mB({roaId:Array.from(o.toBuffer())}).getInstruction(s,sI.programId,e,t,r,n,i,bB))(n,Ef,o,s,r,i,wB);return a};
|
|
44
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */;const xA=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),SA=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),AA=BigInt(1),IA=BigInt(2),BA=(t,e)=>(t+e/IA)/e,MA=pk(xA,void 0,void 0,{sqrt:function(t){const e=xA,r=BigInt(3),n=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),a=BigInt(44),u=BigInt(88),c=t*t*t%e,h=c*c*t%e,l=hk(h,r,e)*h%e,f=hk(l,r,e)*h%e,d=hk(f,IA,e)*c%e,p=hk(d,i,e)*d%e,y=hk(p,o,e)*p%e,g=hk(y,a,e)*y%e,m=hk(g,u,e)*g%e,w=hk(m,a,e)*y%e,b=hk(w,r,e)*h%e,v=hk(b,s,e)*p%e,_=hk(v,n,e)*c%e,k=hk(_,IA,e);if(!MA.eql(MA.sqr(k),t))throw new Error("Cannot find square root");return k}}),RA=function(t,e){const r=e=>vA({...t,...EA(e)});return Object.freeze({...r(e),create:r})}({a:BigInt(0),b:BigInt(7),Fp:MA,n:SA,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=SA,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-AA*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=r,s=BigInt("0x100000000000000000000000000000000"),a=BA(o*t,e),u=BA(-n*t,e);let c=uk(t-a*r-u*i,e),h=uk(-a*n-u*o,e);const l=c>s,f=h>s;if(l&&(c=e-c),f&&(h=e-h),c>s||h>s)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:l,k1:c,k2neg:f,k2:h}}}},Xk);function PA(t){try{return Nk.ExtendedPoint.fromHex(t),!0}catch{return!1}}BigInt(0),RA.ProjectivePoint;const TA=Nk.verify,LA=t=>t_.Buffer.isBuffer(t)?t:t instanceof Uint8Array?t_.Buffer.from(t.buffer,t.byteOffset,t.byteLength):t_.Buffer.from(t);class OA{constructor(t){Object.assign(this,t)}encode(){return t_.Buffer.from(ME(UA,this))}static decode(t){return TE(UA,this,t)}static decodeUnchecked(t){return gE(UA,this,t)}}const UA=new Map;var CA;let NA;const zA=32;let DA=1;NA=Symbol.toStringTag;class jA extends OA{constructor(t){if(super({}),this._bn=void 0,function(t){return void 0!==t._bn}(t))this._bn=t._bn;else{if("string"==typeof t){const e=Hk.decode(t);if(e.length!=zA)throw new Error("Invalid public key input");this._bn=new Fk(e)}else this._bn=new Fk(t);if(this._bn.byteLength()>zA)throw new Error("Invalid public key input")}}static unique(){const t=new jA(DA);return DA+=1,new jA(t.toBuffer())}equals(t){return this._bn.eq(t._bn)}toBase58(){return Hk.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){const t=this.toBuffer();return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}toBuffer(){const t=this._bn.toArrayLike(t_.Buffer);if(t.length===zA)return t;const e=t_.Buffer.alloc(32);return t.copy(e,32-t.length),e}get[NA](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(t,e,r){const n=t_.Buffer.concat([t.toBuffer(),t_.Buffer.from(e),r.toBuffer()]),i=Xk(n);return new jA(i)}static createProgramAddressSync(t,e){let r=t_.Buffer.alloc(0);t.forEach((function(t){if(t.length>32)throw new TypeError("Max seed length exceeded");r=t_.Buffer.concat([r,LA(t)])})),r=t_.Buffer.concat([r,e.toBuffer(),t_.Buffer.from("ProgramDerivedAddress")]);const n=Xk(r);if(PA(n))throw new Error("Invalid seeds, address must fall off the curve");return new jA(n)}static async createProgramAddress(t,e){return this.createProgramAddressSync(t,e)}static findProgramAddressSync(t,e){let r,n=255;for(;0!=n;){try{const i=t.concat(t_.Buffer.from([n]));r=this.createProgramAddressSync(i,e)}catch(t){if(t instanceof TypeError)throw t;n--;continue}return[r,n]}throw new Error("Unable to find a viable program address nonce")}static async findProgramAddress(t,e){return this.findProgramAddressSync(t,e)}static isOnCurve(t){return PA(new jA(t).toBytes())}}CA=jA,jA.default=new CA("11111111111111111111111111111111"),UA.set(jA,{kind:"struct",fields:[["_bn","u256"]]}),new jA("BPFLoader1111111111111111111111111111111111");class WA{constructor(t,e){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=t,this.accountKeysFromLookups=e}keySegments(){const t=[this.staticAccountKeys];return this.accountKeysFromLookups&&(t.push(this.accountKeysFromLookups.writable),t.push(this.accountKeysFromLookups.readonly)),t}get(t){for(const e of this.keySegments()){if(t<e.length)return e[t];t-=e.length}}get length(){return this.keySegments().flat().length}compileInstructions(t){if(this.length>256)throw new Error("Account index overflow encountered during compilation");const e=new Map;this.keySegments().flat().forEach(((t,r)=>{e.set(t.toBase58(),r)}));const r=t=>{const r=e.get(t.toBase58());if(void 0===r)throw new Error("Encountered an unknown instruction account key during compilation");return r};return t.map((t=>({programIdIndex:r(t.programId),accountKeyIndexes:t.keys.map((t=>r(t.pubkey))),data:t.data})))}}const FA=(t="publicKey")=>Sx(32,t),KA=(t="string")=>{const e=Ex([vx("length"),vx("lengthPadding"),Sx(mx(vx(),-8),"chars")],t),r=e.decode.bind(e),n=e.encode.bind(e),i=e;return i.decode=(t,e)=>r(t,e).chars.toString(),i.encode=(t,e,r)=>{const i={chars:t_.Buffer.from(t,"utf8")};return n(i,e,r)},i.alloc=t=>vx().span+vx().span+t_.Buffer.from(t,"utf8").length,i};function VA(t,e){const r=t=>{if(t.span>=0)return t.span;if("function"==typeof t.alloc)return t.alloc(e[t.property]);if("count"in t&&"elementLayout"in t){const n=e[t.property];if(Array.isArray(n))return n.length*r(t.elementLayout)}else if("fields"in t)return VA({layout:t},e[t.property]);return 0};let n=0;return t.layout.fields.forEach((t=>{n+=r(t)})),n}function qA(t){let e=0,r=0;for(;;){let n=t.shift();if(e|=(127&n)<<7*r,r+=1,0==(128&n))break}return e}function HA(t,e){let r=e;for(;;){let e=127&r;if(r>>=7,0==r){t.push(e);break}e|=128,t.push(e)}}function $A(t,e){if(!t)throw new Error(e||"Assertion failed")}class GA{constructor(t,e){this.payer=void 0,this.keyMetaMap=void 0,this.payer=t,this.keyMetaMap=e}static compile(t,e){const r=new Map,n=t=>{const e=t.toBase58();let n=r.get(e);return void 0===n&&(n={isSigner:!1,isWritable:!1,isInvoked:!1},r.set(e,n)),n},i=n(e);i.isSigner=!0,i.isWritable=!0;for(const e of t){n(e.programId).isInvoked=!0;for(const t of e.keys){const e=n(t.pubkey);e.isSigner||=t.isSigner,e.isWritable||=t.isWritable}}return new GA(e,r)}getMessageComponents(){const t=[...this.keyMetaMap.entries()];$A(t.length<=256,"Max static account keys length exceeded");const e=t.filter((([,t])=>t.isSigner&&t.isWritable)),r=t.filter((([,t])=>t.isSigner&&!t.isWritable)),n=t.filter((([,t])=>!t.isSigner&&t.isWritable)),i=t.filter((([,t])=>!t.isSigner&&!t.isWritable)),o={numRequiredSignatures:e.length+r.length,numReadonlySignedAccounts:r.length,numReadonlyUnsignedAccounts:i.length};{$A(e.length>0,"Expected at least one writable signer key");const[t]=e[0];$A(t===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}return[o,[...e.map((([t])=>new jA(t))),...r.map((([t])=>new jA(t))),...n.map((([t])=>new jA(t))),...i.map((([t])=>new jA(t)))]]}extractTableLookup(t){const[e,r]=this.drainKeysFoundInLookupTable(t.state.addresses,(t=>!t.isSigner&&!t.isInvoked&&t.isWritable)),[n,i]=this.drainKeysFoundInLookupTable(t.state.addresses,(t=>!t.isSigner&&!t.isInvoked&&!t.isWritable));if(0!==e.length||0!==n.length)return[{accountKey:t.key,writableIndexes:e,readonlyIndexes:n},{writable:r,readonly:i}]}drainKeysFoundInLookupTable(t,e){const r=new Array,n=new Array;for(const[i,o]of this.keyMetaMap.entries())if(e(o)){const e=new jA(i),o=t.findIndex((t=>t.equals(e)));o>=0&&($A(o<256,"Max lookup table index exceeded"),r.push(o),n.push(e),this.keyMetaMap.delete(i))}return[r,n]}}class ZA{constructor(t){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=t.header,this.accountKeys=t.accountKeys.map((t=>new jA(t))),this.recentBlockhash=t.recentBlockhash,this.instructions=t.instructions,this.instructions.forEach((t=>this.indexToProgramIds.set(t.programIdIndex,this.accountKeys[t.programIdIndex])))}get version(){return"legacy"}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map((t=>({programIdIndex:t.programIdIndex,accountKeyIndexes:t.accounts,data:Hk.decode(t.data)})))}get addressTableLookups(){return[]}getAccountKeys(){return new WA(this.staticAccountKeys)}static compile(t){const e=GA.compile(t.instructions,t.payerKey),[r,n]=e.getMessageComponents(),i=new WA(n).compileInstructions(t.instructions).map((t=>({programIdIndex:t.programIdIndex,accounts:t.accountKeyIndexes,data:Hk.encode(t.data)})));return new ZA({header:r,accountKeys:n,recentBlockhash:t.recentBlockhash,instructions:i})}isAccountSigner(t){return t<this.header.numRequiredSignatures}isAccountWritable(t){const e=this.header.numRequiredSignatures;return t>=this.header.numRequiredSignatures?t-e<this.accountKeys.length-e-this.header.numReadonlyUnsignedAccounts:t<e-this.header.numReadonlySignedAccounts}isProgramId(t){return this.indexToProgramIds.has(t)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter(((t,e)=>!this.isProgramId(e)))}serialize(){const t=this.accountKeys.length;let e=[];HA(e,t);const r=this.instructions.map((t=>{const{accounts:e,programIdIndex:r}=t,n=Array.from(Hk.decode(t.data));let i=[];HA(i,e.length);let o=[];return HA(o,n.length),{programIdIndex:r,keyIndicesCount:t_.Buffer.from(i),keyIndices:e,dataLength:t_.Buffer.from(o),data:n}}));let n=[];HA(n,r.length);let i=t_.Buffer.alloc(1232);t_.Buffer.from(n).copy(i);let o=n.length;r.forEach((t=>{const e=Ex([wx("programIdIndex"),Sx(t.keyIndicesCount.length,"keyIndicesCount"),xx(wx("keyIndex"),t.keyIndices.length,"keyIndices"),Sx(t.dataLength.length,"dataLength"),xx(wx("userdatum"),t.data.length,"data")]).encode(t,i,o);o+=e})),i=i.slice(0,o);const s=Ex([Sx(1,"numRequiredSignatures"),Sx(1,"numReadonlySignedAccounts"),Sx(1,"numReadonlyUnsignedAccounts"),Sx(e.length,"keyCount"),xx(FA("key"),t,"keys"),FA("recentBlockhash")]),a={numRequiredSignatures:t_.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:t_.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:t_.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:t_.Buffer.from(e),keys:this.accountKeys.map((t=>LA(t.toBytes()))),recentBlockhash:Hk.decode(this.recentBlockhash)};let u=t_.Buffer.alloc(2048);const c=s.encode(a,u);return i.copy(u,c),u.slice(0,c+i.length)}static from(t){let e=[...t];const r=e.shift();if(r!==(127&r))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const n=e.shift(),i=e.shift(),o=qA(e);let s=[];for(let t=0;t<o;t++){const t=e.slice(0,zA);e=e.slice(zA),s.push(new jA(t_.Buffer.from(t)))}const a=e.slice(0,zA);e=e.slice(zA);const u=qA(e);let c=[];for(let t=0;t<u;t++){const t=e.shift(),r=qA(e),n=e.slice(0,r);e=e.slice(r);const i=qA(e),o=e.slice(0,i),s=Hk.encode(t_.Buffer.from(o));e=e.slice(i),c.push({programIdIndex:t,accounts:n,data:s})}const h={header:{numRequiredSignatures:r,numReadonlySignedAccounts:n,numReadonlyUnsignedAccounts:i},recentBlockhash:Hk.encode(t_.Buffer.from(a)),accountKeys:s,instructions:c};return new ZA(h)}}const YA=t_.Buffer.alloc(64).fill(0);class JA{constructor(t){this.keys=void 0,this.programId=void 0,this.data=t_.Buffer.alloc(0),this.programId=t.programId,this.keys=t.keys,t.data&&(this.data=t.data)}toJSON(){return{keys:this.keys.map((({pubkey:t,isSigner:e,isWritable:r})=>({pubkey:t.toJSON(),isSigner:e,isWritable:r}))),programId:this.programId.toJSON(),data:[...this.data]}}}class XA{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(t){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,t)if(t.feePayer&&(this.feePayer=t.feePayer),t.signatures&&(this.signatures=t.signatures),Object.prototype.hasOwnProperty.call(t,"nonceInfo")){const{minContextSlot:e,nonceInfo:r}=t;this.minNonceContextSlot=e,this.nonceInfo=r}else if(Object.prototype.hasOwnProperty.call(t,"lastValidBlockHeight")){const{blockhash:e,lastValidBlockHeight:r}=t;this.recentBlockhash=e,this.lastValidBlockHeight=r}else{const{recentBlockhash:e,nonceInfo:r}=t;r&&(this.nonceInfo=r),this.recentBlockhash=e}}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((t=>t.toJSON())),signers:this.signatures.map((({publicKey:t})=>t.toJSON()))}}add(...t){if(0===t.length)throw new Error("No instructions");return t.forEach((t=>{"instructions"in t?this.instructions=this.instructions.concat(t.instructions):"data"in t&&"programId"in t&&"keys"in t?this.instructions.push(t):this.instructions.push(new JA(t))})),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let t,e,r;if(this.nonceInfo?(t=this.nonceInfo.nonce,e=this.instructions[0]!=this.nonceInfo.nonceInstruction?[this.nonceInfo.nonceInstruction,...this.instructions]:this.instructions):(t=this.recentBlockhash,e=this.instructions),!t)throw new Error("Transaction recentBlockhash required");if(e.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 t=0;t<e.length;t++)if(void 0===e[t].programId)throw new Error(`Transaction instruction index ${t} has undefined program id`);const n=[],i=[];e.forEach((t=>{t.keys.forEach((t=>{i.push({...t})}));const e=t.programId.toString();n.includes(e)||n.push(e)})),n.forEach((t=>{i.push({pubkey:new jA(t),isSigner:!1,isWritable:!1})}));const o=[];i.forEach((t=>{const e=t.pubkey.toString(),r=o.findIndex((t=>t.pubkey.toString()===e));r>-1?(o[r].isWritable=o[r].isWritable||t.isWritable,o[r].isSigner=o[r].isSigner||t.isSigner):o.push(t)})),o.sort((function(t,e){return t.isSigner!==e.isSigner?t.isSigner?-1:1:t.isWritable!==e.isWritable?t.isWritable?-1:1:t.pubkey.toBase58().localeCompare(e.pubkey.toBase58(),"en",{localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"})}));const s=o.findIndex((t=>t.pubkey.equals(r)));if(s>-1){const[t]=o.splice(s,1);t.isSigner=!0,t.isWritable=!0,o.unshift(t)}else o.unshift({pubkey:r,isSigner:!0,isWritable:!0});for(const t of this.signatures){const e=o.findIndex((e=>e.pubkey.equals(t.publicKey)));if(!(e>-1))throw new Error(`unknown signer: ${t.publicKey.toString()}`);o[e].isSigner||(o[e].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,u=0,c=0;const h=[],l=[];o.forEach((({pubkey:t,isSigner:e,isWritable:r})=>{e?(h.push(t.toString()),a+=1,r||(u+=1)):(l.push(t.toString()),r||(c+=1))}));const f=h.concat(l),d=e.map((t=>{const{data:e,programId:r}=t;return{programIdIndex:f.indexOf(r.toString()),accounts:t.keys.map((t=>f.indexOf(t.pubkey.toString()))),data:Hk.encode(e)}}));return d.forEach((t=>{$A(t.programIdIndex>=0),t.accounts.forEach((t=>$A(t>=0)))})),new ZA({header:{numRequiredSignatures:a,numReadonlySignedAccounts:u,numReadonlyUnsignedAccounts:c},accountKeys:f,recentBlockhash:t,instructions:d})}_compile(){const t=this.compileMessage(),e=t.accountKeys.slice(0,t.header.numRequiredSignatures);return this.signatures.length===e.length&&this.signatures.every(((t,r)=>e[r].equals(t.publicKey)))||(this.signatures=e.map((t=>({signature:null,publicKey:t})))),t}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(t){return(await t.getFeeForMessage(this.compileMessage())).value}setSigners(...t){if(0===t.length)throw new Error("No signers");const e=new Set;this.signatures=t.filter((t=>{const r=t.toString();return!e.has(r)&&(e.add(r),!0)})).map((t=>({signature:null,publicKey:t})))}sign(...t){if(0===t.length)throw new Error("No signers");const e=new Set,r=[];for(const n of t){const t=n.publicKey.toString();e.has(t)||(e.add(t),r.push(n))}this.signatures=r.map((t=>({signature:null,publicKey:t.publicKey})));const n=this._compile();this._partialSign(n,...r)}partialSign(...t){if(0===t.length)throw new Error("No signers");const e=new Set,r=[];for(const n of t){const t=n.publicKey.toString();e.has(t)||(e.add(t),r.push(n))}const n=this._compile();this._partialSign(n,...r)}_partialSign(t,...e){const r=t.serialize();e.forEach((t=>{const e=((t,e)=>Nk.sign(t,e.slice(0,32)))(r,t.secretKey);this._addSignature(t.publicKey,LA(e))}))}addSignature(t,e){this._compile(),this._addSignature(t,e)}_addSignature(t,e){$A(64===e.length);const r=this.signatures.findIndex((e=>t.equals(e.publicKey)));if(r<0)throw new Error(`unknown signer: ${t.toString()}`);this.signatures[r].signature=t_.Buffer.from(e)}verifySignatures(t){return this._verifySignatures(this.serializeMessage(),void 0===t||t)}_verifySignatures(t,e){for(const{signature:r,publicKey:n}of this.signatures)if(null===r){if(e)return!1}else if(!TA(r,t,n.toBytes()))return!1;return!0}serialize(t){const{requireAllSignatures:e,verifySignatures:r}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},t),n=this.serializeMessage();if(r&&!this._verifySignatures(n,e))throw new Error("Signature verification failed");return this._serialize(n)}_serialize(t){const{signatures:e}=this,r=[];HA(r,e.length);const n=r.length+64*e.length+t.length,i=t_.Buffer.alloc(n);return $A(e.length<256),t_.Buffer.from(r).copy(i,0),e.forEach((({signature:t},e)=>{null!==t&&($A(64===t.length,"signature has invalid length"),t_.Buffer.from(t).copy(i,r.length+64*e))})),t.copy(i,r.length+64*e.length),$A(i.length<=1232,`Transaction too large: ${i.length} > 1232`),i}get keys(){return $A(1===this.instructions.length),this.instructions[0].keys.map((t=>t.pubkey))}get programId(){return $A(1===this.instructions.length),this.instructions[0].programId}get data(){return $A(1===this.instructions.length),this.instructions[0].data}static from(t){let e=[...t];const r=qA(e);let n=[];for(let t=0;t<r;t++){const t=e.slice(0,64);e=e.slice(64),n.push(Hk.encode(t_.Buffer.from(t)))}return XA.populate(ZA.from(e),n)}static populate(t,e=[]){const r=new XA;return r.recentBlockhash=t.recentBlockhash,t.header.numRequiredSignatures>0&&(r.feePayer=t.accountKeys[0]),e.forEach(((e,n)=>{const i={signature:e==Hk.encode(YA)?null:Hk.decode(e),publicKey:t.accountKeys[n]};r.signatures.push(i)})),t.instructions.forEach((e=>{const n=e.accounts.map((e=>{const n=t.accountKeys[e];return{pubkey:n,isSigner:r.signatures.some((t=>t.publicKey.toString()===n.toString()))||t.isAccountSigner(e),isWritable:t.isAccountWritable(e)}}));r.instructions.push(new JA({keys:n,programId:t.accountKeys[e.programIdIndex],data:Hk.decode(e.data)}))})),r._message=t,r._json=r.toJSON(),r}}new jA("SysvarC1ock11111111111111111111111111111111"),new jA("SysvarEpochSchedu1e111111111111111111111111"),new jA("Sysvar1nstructions1111111111111111111111111");const QA=new jA("SysvarRecentB1ockHashes11111111111111111111"),tI=new jA("SysvarRent111111111111111111111111111111111");function eI(t,e){const r=t.layout.span>=0?t.layout.span:VA(t,e),n=t_.Buffer.alloc(r),i=Object.assign({instruction:t.index},e);return t.layout.encode(i,n),n}new jA("SysvarRewards111111111111111111111111111111"),new jA("SysvarS1otHashes111111111111111111111111111"),new jA("SysvarS1otHistory11111111111111111111111111"),new jA("SysvarStakeHistory1111111111111111111111111");const rI=_x("lamportsPerSignature"),nI=Ex([vx("version"),vx("state"),FA("authorizedPubkey"),FA("nonce"),Ex([rI],"feeCalculator")]).span,iI=(8,t=>{const e=Sx(8,t),{encode:r,decode:n}=(t=>({decode:t.decode.bind(t),encode:t.encode.bind(t)}))(e),i=e;return i.decode=(t,e)=>{const r=n(t,e);return Ix(t_.Buffer.from(r))},i.encode=(t,e,n)=>{const i=Mx(t,8);return r(i,e,n)},i});const oI=Object.freeze({Create:{index:0,layout:Ex([vx("instruction"),kx("lamports"),kx("space"),FA("programId")])},Assign:{index:1,layout:Ex([vx("instruction"),FA("programId")])},Transfer:{index:2,layout:Ex([vx("instruction"),iI("lamports")])},CreateWithSeed:{index:3,layout:Ex([vx("instruction"),FA("base"),KA("seed"),kx("lamports"),kx("space"),FA("programId")])},AdvanceNonceAccount:{index:4,layout:Ex([vx("instruction")])},WithdrawNonceAccount:{index:5,layout:Ex([vx("instruction"),kx("lamports")])},InitializeNonceAccount:{index:6,layout:Ex([vx("instruction"),FA("authorized")])},AuthorizeNonceAccount:{index:7,layout:Ex([vx("instruction"),FA("authorized")])},Allocate:{index:8,layout:Ex([vx("instruction"),kx("space")])},AllocateWithSeed:{index:9,layout:Ex([vx("instruction"),FA("base"),KA("seed"),kx("space"),FA("programId")])},AssignWithSeed:{index:10,layout:Ex([vx("instruction"),FA("base"),KA("seed"),FA("programId")])},TransferWithSeed:{index:11,layout:Ex([vx("instruction"),iI("lamports"),KA("seed"),FA("programId")])},UpgradeNonceAccount:{index:12,layout:Ex([vx("instruction")])}});class sI{constructor(){}static createAccount(t){const e=eI(oI.Create,{lamports:t.lamports,space:t.space,programId:LA(t.programId.toBuffer())});return new JA({keys:[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:e})}static transfer(t){let e,r;return"basePubkey"in t?(e=eI(oI.TransferWithSeed,{lamports:BigInt(t.lamports),seed:t.seed,programId:LA(t.programId.toBuffer())}),r=[{pubkey:t.fromPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0}]):(e=eI(oI.Transfer,{lamports:BigInt(t.lamports)}),r=[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0}]),new JA({keys:r,programId:this.programId,data:e})}static assign(t){let e,r;return"basePubkey"in t?(e=eI(oI.AssignWithSeed,{base:LA(t.basePubkey.toBuffer()),seed:t.seed,programId:LA(t.programId.toBuffer())}),r=[{pubkey:t.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1}]):(e=eI(oI.Assign,{programId:LA(t.programId.toBuffer())}),r=[{pubkey:t.accountPubkey,isSigner:!0,isWritable:!0}]),new JA({keys:r,programId:this.programId,data:e})}static createAccountWithSeed(t){const e=eI(oI.CreateWithSeed,{base:LA(t.basePubkey.toBuffer()),seed:t.seed,lamports:t.lamports,space:t.space,programId:LA(t.programId.toBuffer())});let r=[{pubkey:t.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:t.newAccountPubkey,isSigner:!1,isWritable:!0}];return t.basePubkey!=t.fromPubkey&&r.push({pubkey:t.basePubkey,isSigner:!0,isWritable:!1}),new JA({keys:r,programId:this.programId,data:e})}static createNonceAccount(t){const e=new XA;"basePubkey"in t&&"seed"in t?e.add(sI.createAccountWithSeed({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,basePubkey:t.basePubkey,seed:t.seed,lamports:t.lamports,space:nI,programId:this.programId})):e.add(sI.createAccount({fromPubkey:t.fromPubkey,newAccountPubkey:t.noncePubkey,lamports:t.lamports,space:nI,programId:this.programId}));const r={noncePubkey:t.noncePubkey,authorizedPubkey:t.authorizedPubkey};return e.add(this.nonceInitialize(r)),e}static nonceInitialize(t){const e=eI(oI.InitializeNonceAccount,{authorized:LA(t.authorizedPubkey.toBuffer())}),r={keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:QA,isSigner:!1,isWritable:!1},{pubkey:tI,isSigner:!1,isWritable:!1}],programId:this.programId,data:e};return new JA(r)}static nonceAdvance(t){const e=eI(oI.AdvanceNonceAccount),r={keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:QA,isSigner:!1,isWritable:!1},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:e};return new JA(r)}static nonceWithdraw(t){const e=eI(oI.WithdrawNonceAccount,{lamports:t.lamports});return new JA({keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:t.toPubkey,isSigner:!1,isWritable:!0},{pubkey:QA,isSigner:!1,isWritable:!1},{pubkey:tI,isSigner:!1,isWritable:!1},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:e})}static nonceAuthorize(t){const e=eI(oI.AuthorizeNonceAccount,{authorized:LA(t.newAuthorizedPubkey.toBuffer())});return new JA({keys:[{pubkey:t.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:t.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:e})}static allocate(t){let e,r;return"basePubkey"in t?(e=eI(oI.AllocateWithSeed,{base:LA(t.basePubkey.toBuffer()),seed:t.seed,space:t.space,programId:LA(t.programId.toBuffer())}),r=[{pubkey:t.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:t.basePubkey,isSigner:!0,isWritable:!1}]):(e=eI(oI.Allocate,{space:t.space}),r=[{pubkey:t.accountPubkey,isSigner:!0,isWritable:!0}]),new JA({keys:r,programId:this.programId,data:e})}}sI.programId=new jA("11111111111111111111111111111111"),new jA("BPFLoader2111111111111111111111111111111111"),Ex([vx("typeIndex"),iI("deactivationSlot"),_x("lastExtendedSlot"),wx("lastExtendedStartIndex"),wx(),xx(FA(),mx(wx(),-1),"authority")]);const aI=tS(Kx(jA),Zx(),(t=>new jA(t))),uI=Yx([Zx(),Vx("base64")]),cI=tS(Kx(t_.Buffer),uI,(t=>t_.Buffer.from(t[0],"base64")));function hI(t){return Xx([Jx({jsonrpc:Vx("2.0"),id:Zx(),result:t}),Jx({jsonrpc:Vx("2.0"),id:Zx(),error:Jx({code:Qx(),message:Zx(),data:$x(jx("any",(()=>!0)))})})])}const lI=hI(Qx());function fI(t){return tS(hI(t),lI,(e=>"error"in e?e:{...e,result:Nx(e.result,t)}))}function dI(t){return fI(Jx({context:Jx({slot:Hx()}),value:t}))}function pI(t){return Jx({context:Jx({slot:Hx()}),value:t})}const yI=Jx({foundation:Hx(),foundationTerm:Hx(),initial:Hx(),taper:Hx(),terminal:Hx()});fI(Wx(qx(Jx({epoch:Hx(),effectiveSlot:Hx(),amount:Hx(),postBalance:Hx(),commission:$x(qx(Hx()))}))));const gI=Wx(Jx({slot:Hx(),prioritizationFee:Hx()})),mI=Jx({total:Hx(),validator:Hx(),foundation:Hx(),epoch:Hx()}),wI=Jx({epoch:Hx(),slotIndex:Hx(),slotsInEpoch:Hx(),absoluteSlot:Hx(),blockHeight:$x(Hx()),transactionCount:$x(Hx())}),bI=Jx({slotsPerEpoch:Hx(),leaderScheduleSlotOffset:Hx(),warmup:Fx(),firstNormalEpoch:Hx(),firstNormalSlot:Hx()}),vI=Gx(Zx(),Wx(Hx())),_I=qx(Xx([Jx({}),Zx()])),kI=Jx({err:_I}),EI=Vx("receivedSignature");Jx({"solana-core":Zx(),"feature-set":$x(Hx())}),dI(Jx({err:qx(Xx([Jx({}),Zx()])),logs:qx(Wx(Zx())),accounts:$x(qx(Wx(qx(Jx({executable:Fx(),owner:Zx(),lamports:Hx(),data:Wx(Zx()),rentEpoch:$x(Hx())}))))),unitsConsumed:$x(Hx()),returnData:$x(qx(Jx({programId:Zx(),data:Yx([Zx(),Vx("base64")])})))})),dI(Jx({byIdentity:Gx(Zx(),Wx(Hx())),range:Jx({firstSlot:Hx(),lastSlot:Hx()})})),fI(yI),fI(mI),fI(gI),fI(wI),fI(bI),fI(vI),fI(Hx()),dI(Jx({total:Hx(),circulating:Hx(),nonCirculating:Hx(),nonCirculatingAccounts:Wx(aI)}));const xI=Jx({amount:Zx(),uiAmount:qx(Hx()),decimals:Hx(),uiAmountString:$x(Zx())});dI(Wx(Jx({address:aI,amount:Zx(),uiAmount:qx(Hx()),decimals:Hx(),uiAmountString:$x(Zx())}))),dI(Wx(Jx({pubkey:aI,account:Jx({executable:Fx(),owner:aI,lamports:Hx(),data:cI,rentEpoch:Hx()})})));const SI=Jx({program:Zx(),parsed:Qx(),space:Hx()});dI(Wx(Jx({pubkey:aI,account:Jx({executable:Fx(),owner:aI,lamports:Hx(),data:SI,rentEpoch:Hx()})}))),dI(Wx(Jx({lamports:Hx(),address:aI})));const AI=Jx({executable:Fx(),owner:aI,lamports:Hx(),data:cI,rentEpoch:Hx()});Jx({pubkey:aI,account:AI});const II=tS(Xx([Kx(t_.Buffer),SI]),Xx([uI,SI]),(t=>Array.isArray(t)?Nx(t,cI):t)),BI=Jx({executable:Fx(),owner:aI,lamports:Hx(),data:II,rentEpoch:Hx()});Jx({pubkey:aI,account:BI}),Jx({state:Xx([Vx("active"),Vx("inactive"),Vx("activating"),Vx("deactivating")]),active:Hx(),inactive:Hx()}),fI(Wx(Jx({signature:Zx(),slot:Hx(),err:_I,memo:qx(Zx()),blockTime:$x(qx(Hx()))}))),fI(Wx(Jx({signature:Zx(),slot:Hx(),err:_I,memo:qx(Zx()),blockTime:$x(qx(Hx()))}))),Jx({subscription:Hx(),result:pI(AI)});const MI=Jx({pubkey:aI,account:AI});Jx({subscription:Hx(),result:pI(MI)});const RI=Jx({parent:Hx(),slot:Hx(),root:Hx()});Jx({subscription:Hx(),result:RI});const PI=Xx([Jx({type:Xx([Vx("firstShredReceived"),Vx("completed"),Vx("optimisticConfirmation"),Vx("root")]),slot:Hx(),timestamp:Hx()}),Jx({type:Vx("createdBank"),parent:Hx(),slot:Hx(),timestamp:Hx()}),Jx({type:Vx("frozen"),slot:Hx(),timestamp:Hx(),stats:Jx({numTransactionEntries:Hx(),numSuccessfulTransactions:Hx(),numFailedTransactions:Hx(),maxTransactionsPerEntry:Hx()})}),Jx({type:Vx("dead"),slot:Hx(),timestamp:Hx(),err:Zx()})]);Jx({subscription:Hx(),result:PI}),Jx({subscription:Hx(),result:pI(Xx([kI,EI]))}),Jx({subscription:Hx(),result:Hx()}),Jx({pubkey:Zx(),gossip:qx(Zx()),tpu:qx(Zx()),rpc:qx(Zx()),version:qx(Zx())});const TI=Jx({votePubkey:Zx(),nodePubkey:Zx(),activatedStake:Hx(),epochVoteAccount:Fx(),epochCredits:Wx(Yx([Hx(),Hx(),Hx()])),commission:Hx(),lastVote:Hx(),rootSlot:qx(Hx())});fI(Jx({current:Wx(TI),delinquent:Wx(TI)}));const LI=Xx([Vx("processed"),Vx("confirmed"),Vx("finalized")]),OI=Jx({slot:Hx(),confirmations:qx(Hx()),err:_I,confirmationStatus:$x(LI)});dI(Wx(qx(OI))),fI(Hx());const UI=Jx({accountKey:aI,writableIndexes:Wx(Hx()),readonlyIndexes:Wx(Hx())}),CI=Jx({signatures:Wx(Zx()),message:Jx({accountKeys:Wx(Zx()),header:Jx({numRequiredSignatures:Hx(),numReadonlySignedAccounts:Hx(),numReadonlyUnsignedAccounts:Hx()}),instructions:Wx(Jx({accounts:Wx(Hx()),data:Zx(),programIdIndex:Hx()})),recentBlockhash:Zx(),addressTableLookups:$x(Wx(UI))})}),NI=Jx({pubkey:aI,signer:Fx(),writable:Fx(),source:$x(Xx([Vx("transaction"),Vx("lookupTable")]))}),zI=Jx({accountKeys:Wx(NI),signatures:Wx(Zx())}),DI=Jx({parsed:Qx(),program:Zx(),programId:aI}),jI=Jx({accounts:Wx(aI),data:Zx(),programId:aI}),WI=tS(Xx([jI,DI]),Xx([Jx({parsed:Qx(),program:Zx(),programId:Zx()}),Jx({accounts:Wx(Zx()),data:Zx(),programId:Zx()})]),(t=>Nx(t,"accounts"in t?jI:DI))),FI=Jx({signatures:Wx(Zx()),message:Jx({accountKeys:Wx(NI),instructions:Wx(WI),recentBlockhash:Zx(),addressTableLookups:$x(qx(Wx(UI)))})}),KI=Jx({accountIndex:Hx(),mint:Zx(),owner:$x(Zx()),uiTokenAmount:xI}),VI=Jx({writable:Wx(aI),readonly:Wx(aI)}),qI=Jx({err:_I,fee:Hx(),innerInstructions:$x(qx(Wx(Jx({index:Hx(),instructions:Wx(Jx({accounts:Wx(Hx()),data:Zx(),programIdIndex:Hx()}))})))),preBalances:Wx(Hx()),postBalances:Wx(Hx()),logMessages:$x(qx(Wx(Zx()))),preTokenBalances:$x(qx(Wx(KI))),postTokenBalances:$x(qx(Wx(KI))),loadedAddresses:$x(VI),computeUnitsConsumed:$x(Hx())}),HI=Jx({err:_I,fee:Hx(),innerInstructions:$x(qx(Wx(Jx({index:Hx(),instructions:Wx(WI)})))),preBalances:Wx(Hx()),postBalances:Wx(Hx()),logMessages:$x(qx(Wx(Zx()))),preTokenBalances:$x(qx(Wx(KI))),postTokenBalances:$x(qx(Wx(KI))),loadedAddresses:$x(VI),computeUnitsConsumed:$x(Hx())}),$I=Xx([Vx(0),Vx("legacy")]),GI=Jx({pubkey:Zx(),lamports:Hx(),postBalance:qx(Hx()),rewardType:qx(Zx()),commission:$x(qx(Hx()))});fI(qx(Jx({blockhash:Zx(),previousBlockhash:Zx(),parentSlot:Hx(),transactions:Wx(Jx({transaction:CI,meta:qx(qI),version:$x($I)})),rewards:$x(Wx(GI)),blockTime:qx(Hx()),blockHeight:qx(Hx())}))),fI(qx(Jx({blockhash:Zx(),previousBlockhash:Zx(),parentSlot:Hx(),rewards:$x(Wx(GI)),blockTime:qx(Hx()),blockHeight:qx(Hx())}))),fI(qx(Jx({blockhash:Zx(),previousBlockhash:Zx(),parentSlot:Hx(),transactions:Wx(Jx({transaction:zI,meta:qx(qI),version:$x($I)})),rewards:$x(Wx(GI)),blockTime:qx(Hx()),blockHeight:qx(Hx())}))),fI(qx(Jx({blockhash:Zx(),previousBlockhash:Zx(),parentSlot:Hx(),transactions:Wx(Jx({transaction:FI,meta:qx(HI),version:$x($I)})),rewards:$x(Wx(GI)),blockTime:qx(Hx()),blockHeight:qx(Hx())}))),fI(qx(Jx({blockhash:Zx(),previousBlockhash:Zx(),parentSlot:Hx(),transactions:Wx(Jx({transaction:zI,meta:qx(HI),version:$x($I)})),rewards:$x(Wx(GI)),blockTime:qx(Hx()),blockHeight:qx(Hx())}))),fI(qx(Jx({blockhash:Zx(),previousBlockhash:Zx(),parentSlot:Hx(),rewards:$x(Wx(GI)),blockTime:qx(Hx()),blockHeight:qx(Hx())}))),fI(qx(Jx({blockhash:Zx(),previousBlockhash:Zx(),parentSlot:Hx(),transactions:Wx(Jx({transaction:CI,meta:qx(qI)})),rewards:$x(Wx(GI)),blockTime:qx(Hx())}))),fI(qx(Jx({blockhash:Zx(),previousBlockhash:Zx(),parentSlot:Hx(),signatures:Wx(Zx()),blockTime:qx(Hx())}))),fI(qx(Jx({slot:Hx(),meta:qI,blockTime:$x(qx(Hx())),transaction:CI,version:$x($I)}))),fI(qx(Jx({slot:Hx(),transaction:FI,meta:qx(HI),blockTime:$x(qx(Hx())),version:$x($I)}))),dI(Jx({blockhash:Zx(),feeCalculator:Jx({lamportsPerSignature:Hx()})})),dI(Jx({blockhash:Zx(),lastValidBlockHeight:Hx()})),dI(Fx()),fI(Wx(Jx({slot:Hx(),numTransactions:Hx(),numSlots:Hx(),samplePeriodSecs:Hx()}))),dI(qx(Jx({feeCalculator:Jx({lamportsPerSignature:Hx()})}))),fI(Zx()),fI(Zx());const ZI=Jx({err:_I,logs:Wx(Zx()),signature:Zx()});var YI;Jx({result:pI(ZI),subscription:Hx()}),Object.freeze({CreateLookupTable:{index:0,layout:Ex([vx("instruction"),iI("recentSlot"),wx("bumpSeed")])},FreezeLookupTable:{index:1,layout:Ex([vx("instruction")])},ExtendLookupTable:{index:2,layout:Ex([vx("instruction"),iI(),xx(FA(),mx(vx(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:Ex([vx("instruction")])},CloseLookupTable:{index:4,layout:Ex([vx("instruction")])}}),new jA("AddressLookupTab1e1111111111111111111111111"),Object.freeze({RequestUnits:{index:0,layout:Ex([wx("instruction"),vx("units"),vx("additionalFee")])},RequestHeapFrame:{index:1,layout:Ex([wx("instruction"),vx("bytes")])},SetComputeUnitLimit:{index:2,layout:Ex([wx("instruction"),vx("units")])},SetComputeUnitPrice:{index:3,layout:Ex([wx("instruction"),iI("microLamports")])}}),new jA("ComputeBudget111111111111111111111111111111"),Ex([wx("numSignatures"),wx("padding"),bx("signatureOffset"),bx("signatureInstructionIndex"),bx("publicKeyOffset"),bx("publicKeyInstructionIndex"),bx("messageDataOffset"),bx("messageDataSize"),bx("messageInstructionIndex")]),new jA("Ed25519SigVerify111111111111111111111111111"),RA.utils.isValidPrivateKey,RA.getPublicKey,Ex([wx("numSignatures"),bx("signatureOffset"),wx("signatureInstructionIndex"),bx("ethAddressOffset"),wx("ethAddressInstructionIndex"),bx("messageDataOffset"),bx("messageDataSize"),wx("messageInstructionIndex"),Sx(20,"ethAddress"),Sx(64,"signature"),wx("recoveryId")]),new jA("KeccakSecp256k11111111111111111111111111111"),new jA("StakeConfig11111111111111111111111111111111");class JI{constructor(t,e,r){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=t,this.epoch=e,this.custodian=r}}YI=JI,JI.default=new YI(0,0,jA.default),Object.freeze({Initialize:{index:0,layout:Ex([vx("instruction"),((t="authorized")=>Ex([FA("staker"),FA("withdrawer")],t))(),((t="lockup")=>Ex([kx("unixTimestamp"),kx("epoch"),FA("custodian")],t))()])},Authorize:{index:1,layout:Ex([vx("instruction"),FA("newAuthorized"),vx("stakeAuthorizationType")])},Delegate:{index:2,layout:Ex([vx("instruction")])},Split:{index:3,layout:Ex([vx("instruction"),kx("lamports")])},Withdraw:{index:4,layout:Ex([vx("instruction"),kx("lamports")])},Deactivate:{index:5,layout:Ex([vx("instruction")])},Merge:{index:7,layout:Ex([vx("instruction")])},AuthorizeWithSeed:{index:8,layout:Ex([vx("instruction"),FA("newAuthorized"),vx("stakeAuthorizationType"),KA("authoritySeed"),FA("authorityOwner")])}}),Object.freeze({Staker:{index:0},Withdrawer:{index:1}}),new jA("Stake11111111111111111111111111111111111111"),Object.freeze({InitializeAccount:{index:0,layout:Ex([vx("instruction"),((t="voteInit")=>Ex([FA("nodePubkey"),FA("authorizedVoter"),FA("authorizedWithdrawer"),wx("commission")],t))()])},Authorize:{index:1,layout:Ex([vx("instruction"),FA("newAuthorized"),vx("voteAuthorizationType")])},Withdraw:{index:3,layout:Ex([vx("instruction"),kx("lamports")])},AuthorizeWithSeed:{index:10,layout:Ex([vx("instruction"),((t="voteAuthorizeWithSeedArgs")=>Ex([vx("voteAuthorizationType"),FA("currentAuthorityDerivedKeyOwnerPubkey"),KA("currentAuthorityDerivedKeySeed"),FA("newAuthorized")],t))()])}}),Object.freeze({Voter:{index:0},Withdrawer:{index:1}}),new jA("Vote111111111111111111111111111111111111111"),new jA("Va1idator1nfo111111111111111111111111111111"),Jx({name:Zx(),website:$x(Zx()),details:$x(Zx()),keybaseUsername:$x(Zx())}),new jA("Vote111111111111111111111111111111111111111"),Ex([FA("nodePubkey"),FA("authorizedWithdrawer"),wx("commission"),_x(),xx(Ex([_x("slot"),vx("confirmationCount")]),mx(vx(),-8),"votes"),wx("rootSlotValid"),_x("rootSlot"),_x(),xx(Ex([_x("epoch"),FA("authorizedVoter")]),mx(vx(),-8),"authorizedVoters"),Ex([xx(Ex([FA("authorizedPubkey"),_x("epochOfLastAuthorizedSwitch"),_x("targetEpoch")]),32,"buf"),_x("idx"),wx("isEmpty")],"priorVoters"),_x(),xx(Ex([_x("epoch"),_x("credits"),_x("prevCredits")]),mx(vx(),-8),"epochCredits"),Ex([_x("slot"),_x("timestamp")],"lastTimestamp")]);var XI,QI=["u8","u16","u32","u64","u128","i8","i16","i32","i64","i128","f32","f64"],tB=function(){function t(){this.offset=0,this.buffer_size=256,this.buffer=new ArrayBuffer(this.buffer_size),this.view=new DataView(this.buffer)}return t.prototype.resize_if_necessary=function(t){if(this.buffer_size-this.offset<t){this.buffer_size=Math.max(2*this.buffer_size,this.buffer_size+t);var e=new ArrayBuffer(this.buffer_size);new Uint8Array(e).set(new Uint8Array(this.buffer)),this.buffer=e,this.view=new DataView(e)}},t.prototype.get_used_buffer=function(){return new Uint8Array(this.buffer).slice(0,this.offset)},t.prototype.store_value=function(t,e){var r=e.substring(1),n=parseInt(r)/8;this.resize_if_necessary(n);var i="f"===e[0]?"setFloat".concat(r):"i"===e[0]?"setInt".concat(r):"setUint".concat(r);this.view[i](this.offset,t,!0),this.offset+=n},t.prototype.store_bytes=function(t){this.resize_if_necessary(t.length),new Uint8Array(this.buffer).set(new Uint8Array(t),this.offset),this.offset+=t.length},t}(),eB=function(){function t(t){this.offset=0,this.buffer_size=t.length,this.buffer=new ArrayBuffer(t.length),new Uint8Array(this.buffer).set(t),this.view=new DataView(this.buffer)}return t.prototype.assert_enough_buffer=function(t){if(this.offset+t>this.buffer.byteLength)throw new Error("Error in schema, the buffer is smaller than expected")},t.prototype.consume_value=function(t){var e=t.substring(1),r=parseInt(e)/8;this.assert_enough_buffer(r);var n="f"===t[0]?"getFloat".concat(e):"i"===t[0]?"getInt".concat(e):"getUint".concat(e),i=this.view[n](this.offset,!0);return this.offset+=r,i},t.prototype.consume_bytes=function(t){this.assert_enough_buffer(t);var e=this.buffer.slice(this.offset,this.offset+t);return this.offset+=t,e},t}(),rB=(XI=function(t,e){return XI=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},XI(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}XI(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)});function nB(t,e,r){if(typeof t!==e)throw new Error("Expected ".concat(e," not ").concat(typeof t,"(").concat(t,") at ").concat(r.join(".")))}function iB(t,e,r){if(t!==e)throw new Error("Array length ".concat(t," does not match schema length ").concat(e," at ").concat(r.join(".")))}var oB=QI.concat(["bool","string"]),sB=["option","enum","array","set","map","struct"],aB=function(t){function e(e,r){var n="Invalid schema: ".concat(JSON.stringify(e)," expected ").concat(r);return t.call(this,n)||this}return rB(e,t),e}(Error);function uB(t){if("string"!=typeof t||!oB.includes(t)){if(t&&"object"==typeof t){var e=Object.keys(t);if(1===e.length&&sB.includes(e[0])){var r=e[0];if("option"===r)return uB(t[r]);if("enum"===r)return function(t){if(!Array.isArray(t))throw new aB(t,"Array");for(var e=0,r=t;e<r.length;e++){var n=r[e];if("object"!=typeof n||!("struct"in n))throw new Error('Missing "struct" key in enum schema');if("object"!=typeof n.struct||1!==Object.keys(n.struct).length)throw new Error('The "struct" in each enum must have a single key');uB({struct:n.struct})}}(t[r]);if("array"===r)return function(t){if("object"!=typeof t)throw new aB(t,"{ type, len? }");if(t.len&&"number"!=typeof t.len)throw new Error("Invalid schema: ".concat(t));if("type"in t)return uB(t.type);throw new aB(t,"{ type, len? }")}(t[r]);if("set"===r)return uB(t[r]);if("map"===r)return function(t){if("object"!=typeof t||!("key"in t)||!("value"in t))throw new aB(t,"{ key, value }");uB(t.key),uB(t.value)}(t[r]);if("struct"===r)return function(t){if("object"!=typeof t)throw new aB(t,"object");for(var e in t)uB(t[e])}(t[r])}}throw new aB(t,sB.join(", ")+" or "+oB.join(", "))}}var cB=function(){function t(t){this.encoded=new tB,this.fieldPath=["value"],this.checkTypes=t}return t.prototype.encode=function(t,e){return this.encode_value(t,e),this.encoded.get_used_buffer()},t.prototype.encode_value=function(t,e){if("string"==typeof e){if(QI.includes(e))return this.encode_integer(t,e);if("string"===e)return this.encode_string(t);if("bool"===e)return this.encode_boolean(t)}if("object"==typeof e){if("option"in e)return this.encode_option(t,e);if("enum"in e)return this.encode_enum(t,e);if("array"in e)return this.encode_array(t,e);if("set"in e)return this.encode_set(t,e);if("map"in e)return this.encode_map(t,e);if("struct"in e)return this.encode_struct(t,e)}},t.prototype.encode_integer=function(t,e){var r=parseInt(e.substring(1));r<=32||"f64"==e?(this.checkTypes&&nB(t,"number",this.fieldPath),this.encoded.store_value(t,e)):(this.checkTypes&&function(t,e){if(!(["number","string","bigint","boolean"].includes(typeof t)||"object"==typeof t&&null!==t&&"toString"in t))throw new Error("Expected bigint, number, boolean or string not ".concat(typeof t,"(").concat(t,") at ").concat(e.join(".")))}(t,this.fieldPath),this.encode_bigint(BigInt(t),r))},t.prototype.encode_bigint=function(t,e){for(var r=e/8,n=new Uint8Array(r),i=0;i<r;i++)n[i]=Number(t&BigInt(255)),t>>=BigInt(8);this.encoded.store_bytes(new Uint8Array(n))},t.prototype.encode_string=function(t){this.checkTypes&&nB(t,"string",this.fieldPath);var e=t;this.encoded.store_value(e.length,"u32");for(var r=0;r<e.length;r++)this.encoded.store_value(e.charCodeAt(r),"u8")},t.prototype.encode_boolean=function(t){this.checkTypes&&nB(t,"boolean",this.fieldPath),this.encoded.store_value(t?1:0,"u8")},t.prototype.encode_option=function(t,e){null==t?this.encoded.store_value(0,"u8"):(this.encoded.store_value(1,"u8"),this.encode_value(t,e.option))},t.prototype.encode_enum=function(t,e){this.checkTypes&&function(t,e){if("object"!=typeof t||null===t)throw new Error("Expected object not ".concat(typeof t,"(").concat(t,") at ").concat(e.join(".")))}(t,this.fieldPath);for(var r=Object.keys(t)[0],n=0;n<e.enum.length;n++){var i=e.enum[n];if(r===Object.keys(i.struct)[0])return this.encoded.store_value(n,"u8"),this.encode_struct(t,i)}throw new Error("Enum key (".concat(r,") not found in enum schema: ").concat(JSON.stringify(e)," at ").concat(this.fieldPath.join(".")))},t.prototype.encode_array=function(t,e){if(function(t){return Array.isArray(t)||!!t&&"object"==typeof t&&"length"in t&&"number"==typeof t.length&&(0===t.length||t.length>0&&t.length-1 in t)}(t))return this.encode_arraylike(t,e);if(t instanceof ArrayBuffer)return this.encode_buffer(t,e);throw new Error("Expected Array-like not ".concat(typeof t,"(").concat(t,") at ").concat(this.fieldPath.join(".")))},t.prototype.encode_arraylike=function(t,e){e.array.len?iB(t.length,e.array.len,this.fieldPath):this.encoded.store_value(t.length,"u32");for(var r=0;r<t.length;r++)this.encode_value(t[r],e.array.type)},t.prototype.encode_buffer=function(t,e){e.array.len?iB(t.byteLength,e.array.len,this.fieldPath):this.encoded.store_value(t.byteLength,"u32"),this.encoded.store_bytes(new Uint8Array(t))},t.prototype.encode_set=function(t,e){this.checkTypes&&nB(t,"object",this.fieldPath);var r=t instanceof Set?Array.from(t.values()):Object.values(t);this.encoded.store_value(r.length,"u32");for(var n=0,i=r;n<i.length;n++){var o=i[n];this.encode_value(o,e.set)}},t.prototype.encode_map=function(t,e){this.checkTypes&&nB(t,"object",this.fieldPath);var r=t instanceof Map,n=r?Array.from(t.keys()):Object.keys(t);this.encoded.store_value(n.length,"u32");for(var i=0,o=n;i<o.length;i++){var s=o[i];this.encode_value(s,e.map.key),this.encode_value(r?t.get(s):t[s],e.map.value)}},t.prototype.encode_struct=function(t,e){this.checkTypes&&nB(t,"object",this.fieldPath);for(var r=0,n=Object.keys(e.struct);r<n.length;r++){var i=n[r];this.fieldPath.push(i),this.encode_value(t[i],e.struct[i]),this.fieldPath.pop()}},t}(),hB=function(){function t(t){this.buffer=new eB(t)}return t.prototype.decode=function(t){return this.decode_value(t)},t.prototype.decode_value=function(t){if("string"==typeof t){if(QI.includes(t))return this.decode_integer(t);if("string"===t)return this.decode_string();if("bool"===t)return this.decode_boolean()}if("object"==typeof t){if("option"in t)return this.decode_option(t);if("enum"in t)return this.decode_enum(t);if("array"in t)return this.decode_array(t);if("set"in t)return this.decode_set(t);if("map"in t)return this.decode_map(t);if("struct"in t)return this.decode_struct(t)}throw new Error("Unsupported type: ".concat(t))},t.prototype.decode_integer=function(t){var e=parseInt(t.substring(1));return e<=32||"f64"==t?this.buffer.consume_value(t):this.decode_bigint(e,t.startsWith("i"))},t.prototype.decode_bigint=function(t,e){void 0===e&&(e=!1);var r=t/8,n=new Uint8Array(this.buffer.consume_bytes(r)),i=n.reduceRight((function(t,e){return t+e.toString(16).padStart(2,"0")}),"");return e&&n[r-1]?BigInt.asIntN(t,BigInt("0x".concat(i))):BigInt("0x".concat(i))},t.prototype.decode_string=function(){var t=this.decode_integer("u32"),e=new Uint8Array(this.buffer.consume_bytes(t));return String.fromCharCode.apply(null,e)},t.prototype.decode_boolean=function(){return this.buffer.consume_value("u8")>0},t.prototype.decode_option=function(t){var e=this.buffer.consume_value("u8");if(1===e)return this.decode_value(t.option);if(0!==e)throw new Error("Invalid option ".concat(e));return null},t.prototype.decode_enum=function(t){var e,r=this.buffer.consume_value("u8");if(r>t.enum.length)throw new Error("Enum option ".concat(r," is not available"));var n=t.enum[r].struct,i=Object.keys(n)[0];return(e={})[i]=this.decode_value(n[i]),e},t.prototype.decode_array=function(t){for(var e=[],r=t.array.len?t.array.len:this.decode_integer("u32"),n=0;n<r;++n)e.push(this.decode_value(t.array.type));return e},t.prototype.decode_set=function(t){for(var e=this.decode_integer("u32"),r=new Set,n=0;n<e;++n)r.add(this.decode_value(t.set));return r},t.prototype.decode_map=function(t){for(var e=this.decode_integer("u32"),r=new Map,n=0;n<e;++n){var i=this.decode_value(t.map.key),o=this.decode_value(t.map.value);r.set(i,o)}return r},t.prototype.decode_struct=function(t){var e={};for(var r in t.struct)e[r]=this.decode_value(t.struct[r]);return e},t}();function lB(t,e,r){return void 0===r&&(r=!0),r&&uB(t),new cB(r).encode(e,t)}class fB{constructor(t){this.tag=1,this.record=t.record,this.content=t.content}serialize(){return lB(fB.schema,this)}getInstruction(t,e,r,n,i,o,s,a){const u=Buffer.from(this.serialize());let c=[];return c.push({pubkey:e,isSigner:!1,isWritable:!1}),c.push({pubkey:r,isSigner:!1,isWritable:!1}),c.push({pubkey:n,isSigner:!0,isWritable:!0}),c.push({pubkey:i,isSigner:!1,isWritable:!0}),c.push({pubkey:o,isSigner:!1,isWritable:!0}),c.push({pubkey:s,isSigner:!0,isWritable:!0}),c.push({pubkey:a,isSigner:!1,isWritable:!1}),new JA({keys:c,programId:t,data:u})}}fB.schema={struct:{tag:"u8",record:"string",content:{array:{type:"u8"}}}};class dB{constructor(t){this.tag=4,this.validation=t.validation,this.signature=t.signature,this.expectedPubkey=t.expectedPubkey}serialize(){return lB(dB.schema,this)}getInstruction(t,e,r,n,i,o,s,a){const u=Buffer.from(this.serialize());let c=[];return c.push({pubkey:e,isSigner:!1,isWritable:!1}),c.push({pubkey:r,isSigner:!1,isWritable:!1}),c.push({pubkey:n,isSigner:!0,isWritable:!0}),c.push({pubkey:i,isSigner:!1,isWritable:!0}),c.push({pubkey:o,isSigner:!1,isWritable:!0}),c.push({pubkey:s,isSigner:!0,isWritable:!0}),c.push({pubkey:a,isSigner:!1,isWritable:!1}),new JA({keys:c,programId:t,data:u})}}dB.schema={struct:{tag:"u8",validation:"u8",signature:{array:{type:"u8"}},expectedPubkey:{array:{type:"u8"}}}};class pB{constructor(t){this.tag=3,this.staleness=t.staleness}serialize(){return lB(pB.schema,this)}getInstruction(t,e,r,n,i,o,s,a,u){const c=Buffer.from(this.serialize());let h=[];return h.push({pubkey:e,isSigner:!1,isWritable:!1}),h.push({pubkey:r,isSigner:!1,isWritable:!1}),h.push({pubkey:n,isSigner:!0,isWritable:!0}),h.push({pubkey:i,isSigner:!1,isWritable:!0}),h.push({pubkey:o,isSigner:!1,isWritable:!0}),h.push({pubkey:s,isSigner:!1,isWritable:!0}),h.push({pubkey:a,isSigner:!1,isWritable:!1}),h.push({pubkey:u,isSigner:!0,isWritable:!0}),new JA({keys:h,programId:t,data:c})}}pB.schema={struct:{tag:"u8",staleness:"bool"}};class yB{constructor(t){this.tag=2,this.record=t.record,this.content=t.content}serialize(){return lB(yB.schema,this)}getInstruction(t,e,r,n,i,o,s,a){const u=Buffer.from(this.serialize());let c=[];return c.push({pubkey:e,isSigner:!1,isWritable:!1}),c.push({pubkey:r,isSigner:!1,isWritable:!1}),c.push({pubkey:n,isSigner:!0,isWritable:!0}),c.push({pubkey:i,isSigner:!1,isWritable:!0}),c.push({pubkey:o,isSigner:!1,isWritable:!0}),c.push({pubkey:s,isSigner:!0,isWritable:!0}),c.push({pubkey:a,isSigner:!1,isWritable:!1}),new JA({keys:c,programId:t,data:u})}}yB.schema={struct:{tag:"u8",record:"string",content:{array:{type:"u8"}}}};class gB{constructor(){this.tag=5}serialize(){return lB(gB.schema,this)}getInstruction(t,e,r,n,i,o,s,a){const u=Buffer.from(this.serialize());let c=[];return c.push({pubkey:e,isSigner:!1,isWritable:!1}),c.push({pubkey:r,isSigner:!1,isWritable:!1}),c.push({pubkey:n,isSigner:!0,isWritable:!0}),c.push({pubkey:i,isSigner:!1,isWritable:!0}),c.push({pubkey:o,isSigner:!1,isWritable:!0}),c.push({pubkey:s,isSigner:!0,isWritable:!0}),c.push({pubkey:a,isSigner:!1,isWritable:!1}),new JA({keys:c,programId:t,data:u})}}gB.schema={struct:{tag:"u8"}};class mB{constructor(t){this.tag=6,this.roaId=t.roaId}serialize(){return lB(mB.schema,this)}getInstruction(t,e,r,n,i,o,s,a){const u=Buffer.from(this.serialize());let c=[];return c.push({pubkey:e,isSigner:!1,isWritable:!1}),c.push({pubkey:r,isSigner:!1,isWritable:!1}),c.push({pubkey:n,isSigner:!0,isWritable:!0}),c.push({pubkey:i,isSigner:!1,isWritable:!0}),c.push({pubkey:o,isSigner:!1,isWritable:!0}),c.push({pubkey:s,isSigner:!0,isWritable:!0}),c.push({pubkey:a,isSigner:!1,isWritable:!1}),new JA({keys:c,programId:t,data:u})}}mB.schema={struct:{tag:"u8",roaId:{array:{type:"u8"}}}};const wB=new jA("HP3D4D1ZCmohQGFVms2SS4LCANgJyksBf5s1F77FuFjZ"),[bB]=jA.findProgramAddressSync([wB.toBuffer()],wB);var vB;!function(t){t[t.None=0]="None",t[t.Solana=1]="Solana",t[t.Ethereum=2]="Ethereum",t[t.UnverifiedSolana=3]="UnverifiedSolana"}(vB||(vB={}));const _B=t=>{switch(t){case vB.None:return 0;case vB.Ethereum:return 20;case vB.Solana:case vB.UnverifiedSolana:return 32;default:throw new Error("Invalid validation enum")}};class kB{constructor(t){this.stalenessValidation=t.stalenessValidation,this.rightOfAssociationValidation=t.rightOfAssociationValidation,this.contentLength=t.contentLength}static deserialize(t){return new kB(function(t,e,r){return void 0===r&&(r=!0),r&&uB(t),new hB(e).decode(t)}(this.schema,t,!0))}static async retrieve(t,e){const r=await t.getAccountInfo(e);if(!r||!r.data)throw new Error("Record header account not found");return this.deserialize(r.data.slice(96,96+this.LEN))}}kB.LEN=8,kB.schema={struct:{stalenessValidation:"u16",rightOfAssociationValidation:"u16",contentLength:"u32"}};class EB{constructor(t,e){this.data=e,this.header=t}static deserialize(t){const e=kB.deserialize(t.slice(96,96+kB.LEN)),r=t.slice(96+kB.LEN);return new EB(e,r)}static async retrieve(t,e){const r=await t.getAccountInfo(e);if(!r||!r.data)throw new Error("Record header account not found");return this.deserialize(r.data)}static async retrieveBatch(t,e){return(await t.getMultipleAccountsInfo(e)).map((t=>{if(null==t?void 0:t.data)return this.deserialize(t.data)}))}getContent(){let t=_B(this.header.stalenessValidation)+_B(this.header.rightOfAssociationValidation);return this.data.slice(t)}getStalenessId(){let t=_B(this.header.stalenessValidation);return this.data.slice(0,t)}getRoAId(){let t=_B(this.header.stalenessValidation),e=t+_B(this.header.rightOfAssociationValidation);return this.data.slice(t,e)}}var xB;exports.Record=void 0,(xB=exports.Record||(exports.Record={})).IPFS="IPFS",xB.ARWV="ARWV",xB.SOL="SOL",xB.ETH="ETH",xB.BTC="BTC",xB.LTC="LTC",xB.DOGE="DOGE",xB.Email="email",xB.Url="url",xB.Discord="discord",xB.Github="github",xB.Reddit="reddit",xB.Twitter="twitter",xB.Telegram="telegram",xB.Pic="pic",xB.SHDW="SHDW",xB.POINT="POINT",xB.BSC="BSC",xB.Injective="INJ",xB.Backpack="backpack",xB.A="A",xB.AAAA="AAAA",xB.CNAME="CNAME",xB.TXT="TXT",xB.Background="background";const SB=new Map([[exports.Record.SOL,96],[exports.Record.ETH,20],[exports.Record.BSC,20],[exports.Record.Injective,20],[exports.Record.A,4],[exports.Record.AAAA,16],[exports.Record.Background,32]]);var AB;exports.RecordVersion=void 0,(AB=exports.RecordVersion||(exports.RecordVersion={}))[AB.V1=1]="V1",AB[AB.V2=2]="V2";var IB="ABAOAAAAAACwiAAAAYkHdvjtnH+IFkUYxx/v3vPe7uw8UkjsD43ChKICDQsT3iIJy4gSiZAjkn5JUFlaiFmjccT9ESkpGBGVIlQgWSkY/QDBoMgrQv0jRJDAfkCXhUmgRX23d4ebnndmd3Z3ZnfVeeDDzM7MPs8zv57Zd2+5hd1Ed4ClYAisBuuUsqLpMHgJjIBNFu1fBW8l1O8AO8Ee8Cn4HIyCg+CI0u4Y+AmMgVPgDOhuEHWBPjAZXAy2gjfA9kb73hlx+i7SK8AHYDf4BOwHB8AoOAyOguPgB/ArOKlcnwHdPe32/Uin9LTvvwTph0gv62nbubKnXT+nZ1z/DcjfFF8vQno7uEaxH923BGVXN9v5Zcgvj/VFPIT8Y/H1k0jXxPn1SEfARjBdab8V+TfB22CXUh5xd3OcZTH3g6di1LZJbLNs55q96M9n4J9Gm6hsfzQvcT8fbfy//TyUf8vG4Lses/5jcd2PSE/IcQan4/o/UXYadE0kaoJBMG1ivNbidNbETr1XoWyuplwyHFN0fFai/8/EY7BIKY/68EpCvwP+mc/m/2vNGnBhp1eZ51bCmgsEAoFAIBAIBAKBQKAO3Irfrg3lfc4qi/cXd+Kee5TfvAd6ieY0ie5D2cNx+eNInwZLmu33gWuRn4/8C3H9CNJNYEt8/TrS35HuSPktvRP1z0LPOvAceB4IsB5saIa6UBfqQl2oc123AjwBVjWrP7MCgcC5y/ue/56yqXv87+qcIU2Z+ny8tuHHpyxsvrDNITDXgqkDRJcPdJY/wMo24/oQmDqZaPHkdplAuhv8ApqDRDeCVj/OAvD9BUSX9qF8Qpt7lTxnZ7+5TmVtrGMM7XchP3sS0SNgGzg4yU5HIBAIBM5NfsO5QDgfjuM54STOw7/Az/F3QtfhfF4Qn9F/gxMouxm/WU7F9afBQuUM7+rtPF+jb0b6ese/I7sI+emadhEzUT5bqbsW+esNbSMWoG6hWo/8gOLPUqUu+v5rKEHX8oS6iEXQexd7XlmBe1aCNWAp6kSsYyjHc82Liv2Xkd/C/HkN1w/Geren+KryToa2PtlQg2c9zijGZnGJ9kaibzZh84jmmfx4TeYpK9H3usMKqxnDCWxsdLY/3ygy9h+l/LYbYHtuXw2/rfsSPo0a/Jrn6PvPrzL2+7CmfV88lkc9j+F7cRzYU4N48DF8uA3n/T7Fly9q4Jdvoth0uLf9LORC11hvO/0D6RnQfRa99+2Hr1NS/M26VvfEe2jaWTAOvG8zzgKf8zCrYL++qUEfbumeQAjTVnQp+QmW99gQpDoJ4+9uHZe5/l3OW/M8x6WUZaduUvUc5p13NTXlz3VpGbCVrGNe5zOnjvGlrDWY1IdWShuuQ9fWh6h+VSV1Wit1lvNhHFz1zeUYtCg5ntvOSStDW5cITRnF5RJ+rcasJHExztwu910tl6LzLYsvuvvzilB0mvSaxt/V+SY0EMurfkjbrTjfInf+FJGkNdzSlOukZaDo3snqs7RZpqj2Gx7sS52D5O79k+93W2W/T3NhQxe3VeF16pwn4eI8qev7Sl1s0PnPy5PalSV57Pp6XuDxrypR9wBR8nOCzm/eXuYp5d4s/lV1XvL+lG2b+2AaQ1nPr23Hrc7z0WT5qvZL0v7QtdX5zdu6HMei+gV1ri8et4XSVpCfdeB7fRWNRy79UP0RCT4Jyre/88bbKsQUawUrV69dxjd+nlXxbCKos79pz1BpOqucz0gEdZ5hMk+aa7Wdy/7xZ5Yqhc+nyHivrkyQ/reM7tziuFojfM7zxtq0505XYutvHrtVnzNl2ONrTGdPkLv9ZjNHOoShnCh5nLLYKOKfK4qK7bjx/gqyj9lFJc2Wz/HIqyMSYaGnqM8+xp6vB1/6feg22UmLFUno1rurvelz7yT1UVfORW3L7+d6fMcAXdzxIVK3TNNioZpSyj2242izpky6y5S0fpr6q5ZXJT7O1qrmQRVB+rkQ1Dk3vvYttyGoc+51/mUVkYLtXvTx7MCvbUnzW2czyR8pql4XUlbcN9l1pSfPfOl0JV2bylyKoM4959sHQfr9Vpbk2V8u4ry0ndcvH5I1xggP9qVem/PHZL+qeGLrc945tLnHtG/LEtdjr4urxMpM92X1RZDd+pLtsorUydeCaiuvbtdSpQ9l2M4SU01nvI1e35L3uS5Jlw8pe1ykCKo2JtrGK9O9ujOlimcD6Y9LEWQ+7019d2VDLVPrTCLrsvjsQ1TfJVJM12pZmm5b4Xptx6HM9SpFkP2c6drJa5/iSr+pD7r+CNLvATVfpST1RYog/fwKTdsyxLVNQfnWrkyziGltJK2hLLptzjHXIsh+/HytmyQfpPA5VNtzXWWLzbiVsc9sbWSJ7UWE69KNh6v9kya2c6TzMa0fwpD37TtvQ6wuiw9CA9cny33Mj2pLte9Kp6996HO/83HPQ5r+ov5mvU9Qte/fIrGJP7axPO/9eXX6kjLPKZNd17iyZdOHLP31JSbfXY6hC59c+ZZ136TZ9SFlj6cvmVkSrkSQn3NG5KBqEVSeH6Ji/vvnhFWjSlfFNDwzyMgqLvvKxXffbeASBWo+Zj4p2x6TfwE=",BB="AAACAAAAAACAOAAAAbYBSf7t2S1IBEEYBuDVDZ7FYrQMNsFiu3hgEYOI0SCXRIUrB8JhEZtgs5gEg1GMFk02m82oGI02m+9xezCOczv/uwv3fvAwc/PzfXOzcdqzWdaBDdiGPdiHdjE+DS3RNDuCfsn8idQ/g3OH3BdwKf0e96/gumTfYcncLdzBPTzAo+RZ+f0Cr/AG7/AJX4738x1wtz9FO5PX/50n6UXMNdfg/0lERERERERERERERETpdedHBvDRql4nq0cXtW9af98qdRby0Vvp8K4W0V+C5Xw0t4J2bfjeBp3cnEu1brnnCTYNa7eKdz91XP7WO9Lb4GqRb7cY6xbtAdqeVOsY/QGcevw/tb6OT85YhvfKYEx9CMuxKsKnrs+eJtVInVvHJ0eVYVvTZk2siFVLOCjb61PTZX3MdVWEyP7fjzpmMxdzTyq2Ebue6x61nXRGnzndWpf1an7dXmGYE4Y1ptqqKsK1nu26Ju0ty+maV2Rpvk+qnDZjKUIobUiesdAQE/jmCTmHmsskpFZsVYbtmXRcaoSGUPomunW2derQhDPFjtT1Q/eb8vnm990fq35oHVt11bU9m89c7DNI8Qs=",MB=0,RB=-3;function PB(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function TB(t,e){this.source=t,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=e,this.destLen=0,this.ltree=new PB,this.dtree=new PB}var LB=new PB,OB=new PB,UB=new Uint8Array(30),CB=new Uint16Array(30),NB=new Uint8Array(30),zB=new Uint16Array(30),DB=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),jB=new PB,WB=new Uint8Array(320);function FB(t,e,r,n){var i,o;for(i=0;i<r;++i)t[i]=0;for(i=0;i<30-r;++i)t[i+r]=i/r|0;for(o=n,i=0;i<30;++i)e[i]=o,o+=1<<t[i]}var KB=new Uint16Array(16);function VB(t,e,r,n){var i,o;for(i=0;i<16;++i)t.table[i]=0;for(i=0;i<n;++i)t.table[e[r+i]]++;for(t.table[0]=0,o=0,i=0;i<16;++i)KB[i]=o,o+=t.table[i];for(i=0;i<n;++i)e[r+i]&&(t.trans[KB[e[r+i]]++]=i)}function qB(t){t.bitcount--||(t.tag=t.source[t.sourceIndex++],t.bitcount=7);var e=1&t.tag;return t.tag>>>=1,e}function HB(t,e,r){if(!e)return r;for(;t.bitcount<24;)t.tag|=t.source[t.sourceIndex++]<<t.bitcount,t.bitcount+=8;var n=t.tag&65535>>>16-e;return t.tag>>>=e,t.bitcount-=e,n+r}function $B(t,e){for(;t.bitcount<24;)t.tag|=t.source[t.sourceIndex++]<<t.bitcount,t.bitcount+=8;var r=0,n=0,i=0,o=t.tag;do{n=2*n+(1&o),o>>>=1,++i,r+=e.table[i],n-=e.table[i]}while(n>=0);return t.tag=o,t.bitcount-=i,e.trans[r+n]}function GB(t,e,r){var n,i,o,s,a,u;for(n=HB(t,5,257),i=HB(t,5,1),o=HB(t,4,4),s=0;s<19;++s)WB[s]=0;for(s=0;s<o;++s){var c=HB(t,3,0);WB[DB[s]]=c}for(VB(jB,WB,0,19),a=0;a<n+i;){var h=$B(t,jB);switch(h){case 16:var l=WB[a-1];for(u=HB(t,2,3);u;--u)WB[a++]=l;break;case 17:for(u=HB(t,3,3);u;--u)WB[a++]=0;break;case 18:for(u=HB(t,7,11);u;--u)WB[a++]=0;break;default:WB[a++]=h}}VB(e,WB,0,n),VB(r,WB,n,i)}function ZB(t,e,r){for(;;){var n,i,o,s,a=$B(t,e);if(256===a)return MB;if(a<256)t.dest[t.destLen++]=a;else for(n=HB(t,UB[a-=257],CB[a]),i=$B(t,r),s=o=t.destLen-HB(t,NB[i],zB[i]);s<o+n;++s)t.dest[t.destLen++]=t.dest[s]}}function YB(t){for(var e,r;t.bitcount>8;)t.sourceIndex--,t.bitcount-=8;if((e=256*(e=t.source[t.sourceIndex+1])+t.source[t.sourceIndex])!==(65535&~(256*t.source[t.sourceIndex+3]+t.source[t.sourceIndex+2])))return RB;for(t.sourceIndex+=4,r=e;r;--r)t.dest[t.destLen++]=t.source[t.sourceIndex++];return t.bitcount=0,MB}!function(t,e){var r;for(r=0;r<7;++r)t.table[r]=0;for(t.table[7]=24,t.table[8]=152,t.table[9]=112,r=0;r<24;++r)t.trans[r]=256+r;for(r=0;r<144;++r)t.trans[24+r]=r;for(r=0;r<8;++r)t.trans[168+r]=280+r;for(r=0;r<112;++r)t.trans[176+r]=144+r;for(r=0;r<5;++r)e.table[r]=0;for(e.table[5]=32,r=0;r<32;++r)e.trans[r]=r}(LB,OB),FB(UB,CB,4,3),FB(NB,zB,2,1),UB[28]=0,CB[28]=258;var JB=function(t,e){var r,n,i=new TB(t,e);do{switch(r=qB(i),HB(i,2,0)){case 0:n=YB(i);break;case 1:n=ZB(i,LB,OB);break;case 2:GB(i,i.ltree,i.dtree),n=ZB(i,i.ltree,i.dtree);break;default:n=RB}if(n!==MB)throw new Error("Data error")}while(!r);return i.destLen<i.dest.length?"function"==typeof i.dest.slice?i.dest.slice(0,i.destLen):i.dest.subarray(0,i.destLen):i.dest};const XB=18===new Uint8Array(new Uint32Array([305419896]).buffer)[0],QB=(t,e,r)=>{let n=t[e];t[e]=t[r],t[r]=n};var tM={swap32LE:t=>{XB&&(t=>{const e=t.length;for(let r=0;r<e;r+=4)QB(t,r,r+3),QB(t,r+1,r+2)})(t)}};const eM=JB,{swap32LE:rM}=tM;var nM=class{constructor(t){const e="function"==typeof t.readUInt32BE&&"function"==typeof t.slice;if(e||t instanceof Uint8Array){let r;if(e)this.highStart=t.readUInt32LE(0),this.errorValue=t.readUInt32LE(4),r=t.readUInt32LE(8),t=t.slice(12);else{const e=new DataView(t.buffer);this.highStart=e.getUint32(0,!0),this.errorValue=e.getUint32(4,!0),r=e.getUint32(8,!0),t=t.subarray(12)}t=eM(t,new Uint8Array(r)),t=eM(t,new Uint8Array(r)),rM(t),this.data=new Uint32Array(t.buffer)}else({data:this.data,highStart:this.highStart,errorValue:this.errorValue}=t)}get(t){let e;return t<0||t>1114111?this.errorValue:t<55296||t>56319&&t<=65535?(e=(this.data[t>>5]<<2)+(31&t),this.data[e]):t<=65535?(e=(this.data[2048+(t-55296>>5)]<<2)+(31&t),this.data[e]):t<this.highStart?(e=this.data[2080+(t>>11)],e=this.data[e+(t>>5&63)],e=(e<<2)+(31&t),this.data[e]):this.data[this.data.length-4]}},iM={exports:{}};"undefined"!=typeof self?self:"undefined"!=typeof window&&window,iM.exports=function(){var t="3.7.5",e=t,r="function"==typeof atob,n="function"==typeof btoa,i="function"==typeof Buffer,o="function"==typeof TextDecoder?new TextDecoder:void 0,s="function"==typeof TextEncoder?new TextEncoder:void 0,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",u=Array.prototype.slice.call(a),c=function(t){var e={};return t.forEach((function(t,r){return e[t]=r})),e}(u),h=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,l=String.fromCharCode.bind(String),f="function"==typeof Uint8Array.from?Uint8Array.from.bind(Uint8Array):function(t){return new Uint8Array(Array.prototype.slice.call(t,0))},d=function(t){return t.replace(/=/g,"").replace(/[+\/]/g,(function(t){return"+"==t?"-":"_"}))},p=function(t){return t.replace(/[^A-Za-z0-9\+\/]/g,"")},y=function(t){for(var e,r,n,i,o="",s=t.length%3,a=0;a<t.length;){if((r=t.charCodeAt(a++))>255||(n=t.charCodeAt(a++))>255||(i=t.charCodeAt(a++))>255)throw new TypeError("invalid character found");o+=u[(e=r<<16|n<<8|i)>>18&63]+u[e>>12&63]+u[e>>6&63]+u[63&e]}return s?o.slice(0,s-3)+"===".substring(s):o},g=n?function(t){return btoa(t)}:i?function(t){return Buffer.from(t,"binary").toString("base64")}:y,m=i?function(t){return Buffer.from(t).toString("base64")}:function(t){for(var e=4096,r=[],n=0,i=t.length;n<i;n+=e)r.push(l.apply(null,t.subarray(n,n+e)));return g(r.join(""))},w=function(t,e){return void 0===e&&(e=!1),e?d(m(t)):m(t)},b=function(t){if(t.length<2)return(e=t.charCodeAt(0))<128?t:e<2048?l(192|e>>>6)+l(128|63&e):l(224|e>>>12&15)+l(128|e>>>6&63)+l(128|63&e);var e=65536+1024*(t.charCodeAt(0)-55296)+(t.charCodeAt(1)-56320);return l(240|e>>>18&7)+l(128|e>>>12&63)+l(128|e>>>6&63)+l(128|63&e)},v=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,_=function(t){return t.replace(v,b)},k=i?function(t){return Buffer.from(t,"utf8").toString("base64")}:s?function(t){return m(s.encode(t))}:function(t){return g(_(t))},E=function(t,e){return void 0===e&&(e=!1),e?d(k(t)):k(t)},x=function(t){return E(t,!0)},S=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,A=function(t){switch(t.length){case 4:var e=((7&t.charCodeAt(0))<<18|(63&t.charCodeAt(1))<<12|(63&t.charCodeAt(2))<<6|63&t.charCodeAt(3))-65536;return l(55296+(e>>>10))+l(56320+(1023&e));case 3:return l((15&t.charCodeAt(0))<<12|(63&t.charCodeAt(1))<<6|63&t.charCodeAt(2));default:return l((31&t.charCodeAt(0))<<6|63&t.charCodeAt(1))}},I=function(t){return t.replace(S,A)},B=function(t){if(t=t.replace(/\s+/g,""),!h.test(t))throw new TypeError("malformed base64.");t+="==".slice(2-(3&t.length));for(var e,r,n,i="",o=0;o<t.length;)e=c[t.charAt(o++)]<<18|c[t.charAt(o++)]<<12|(r=c[t.charAt(o++)])<<6|(n=c[t.charAt(o++)]),i+=64===r?l(e>>16&255):64===n?l(e>>16&255,e>>8&255):l(e>>16&255,e>>8&255,255&e);return i},M=r?function(t){return atob(p(t))}:i?function(t){return Buffer.from(t,"base64").toString("binary")}:B,R=i?function(t){return f(Buffer.from(t,"base64"))}:function(t){return f(M(t).split("").map((function(t){return t.charCodeAt(0)})))},P=function(t){return R(L(t))},T=i?function(t){return Buffer.from(t,"base64").toString("utf8")}:o?function(t){return o.decode(R(t))}:function(t){return I(M(t))},L=function(t){return p(t.replace(/[-_]/g,(function(t){return"-"==t?"+":"/"})))},O=function(t){return T(L(t))},U=function(t){if("string"!=typeof t)return!1;var e=t.replace(/\s+/g,"").replace(/={0,2}$/,"");return!/[^\s0-9a-zA-Z\+/]/.test(e)||!/[^\s0-9a-zA-Z\-_]/.test(e)},C=function(t){return{value:t,enumerable:!1,writable:!0,configurable:!0}},N=function(){var t=function(t,e){return Object.defineProperty(String.prototype,t,C(e))};t("fromBase64",(function(){return O(this)})),t("toBase64",(function(t){return E(this,t)})),t("toBase64URI",(function(){return E(this,!0)})),t("toBase64URL",(function(){return E(this,!0)})),t("toUint8Array",(function(){return P(this)}))},z=function(){var t=function(t,e){return Object.defineProperty(Uint8Array.prototype,t,C(e))};t("toBase64",(function(t){return w(this,t)})),t("toBase64URI",(function(){return w(this,!0)})),t("toBase64URL",(function(){return w(this,!0)}))},D=function(){N(),z()},j={version:t,VERSION:e,atob:M,atobPolyfill:B,btoa:g,btoaPolyfill:y,fromBase64:O,toBase64:E,encode:E,encodeURI:x,encodeURL:x,utob:_,btou:I,decode:O,isValid:U,fromUint8Array:w,toUint8Array:P,extendString:N,extendUint8Array:z,extendBuiltins:D,Base64:{}};return Object.keys(j).forEach((function(t){return j.Base64[t]=j[t]})),j}();const oM={Other:0,CR:1,LF:2,Control:4,Extend:8,ZWJ:16,Regional_Indicator:32,Prepend:64,SpacingMark:128,L:256,V:512,T:1024,LV:2048,LVT:4096,Extended_Pictographic:8192},sM=IB,aM=BB,uM=nM,cM=iM.exports.Base64,hM=new uM(cM.toUint8Array(sM)),lM=new uM(cM.toUint8Array(aM));function fM(t,e){return 0!=(t&e)}const dM=0,pM=1,yM=2;function gM(t,e){const r=t.length;let n=0,i=dM;for(let o=e;o+1<r;o++){const r=t[o+0],s=t[o+1];switch(fM(r,oM.Regional_Indicator)||(n=0),i){case yM:case dM:i=fM(r,oM.Extended_Pictographic)?pM:dM;break;case pM:i=fM(r,oM.Extend)?pM:fM(r,oM.ZWJ)&&fM(s,oM.Extended_Pictographic)?yM:dM}if(!fM(r,oM.CR)||!fM(s,oM.LF)){if(fM(r,oM.Control|oM.CR|oM.LF))return o+1-e;if(fM(s,oM.Control|oM.CR|oM.LF))return o+1-e;if(!(fM(r,oM.L)&&fM(s,oM.L|oM.V|oM.LV|oM.LVT)||fM(r,oM.LV|oM.V)&&fM(s,oM.V|oM.T)||fM(r,oM.LVT|oM.T)&&fM(s,oM.T)||fM(s,oM.Extend|oM.ZWJ)||fM(s,oM.SpacingMark)||fM(r,oM.Prepend)||i===yM)){if(!fM(r,oM.Regional_Indicator)||!fM(s,oM.Regional_Indicator)||n%2!=0)return o+1-e;n++}}}return r-e}var mM=function(t){const e=[],r=[0],n=[];for(let e=0;e<t.length;){const i=t.codePointAt(e);n.push(hM.get(i)|lM.get(i)),e+=i>65535?2:1,r.push(e)}for(let i=0;i<n.length;){const o=gM(n,i),s=r[i],a=r[i+o];e.push(t.slice(s,a)),i+=o}return e},wM=e(mM);const bM=t=>{const e=xf+t,r=kf(n.Buffer.from(e,"utf8")).slice(2);return n.Buffer.from(r,"hex")},vM=(t,e,r)=>{const i=[t];e?i.push(e.toBuffer()):i.push(n.Buffer.alloc(32)),r?i.push(r.toBuffer()):i.push(n.Buffer.alloc(32));const[o]=Wo.findProgramAddressSync(i,Ef);return o};async function _M(t,e){const r=bM(e.toBase58()),n=vM(r,Mf),{registry:i}=await oh.retrieve(t,n);if(!i.data)throw new Dc(exports.ErrorType.NoAccountData);const o=new ne(i.data.slice(0,4),"le").toNumber();return i.data.slice(4,4+o).toString()}async function kM(t,e){let r=[];for(let t of e){const e=bM(t.toBase58()),n=vM(e,Mf);r.push(n)}return(await oh.retrieveBatch(t,r)).map((t=>{if(void 0===t||void 0===t.data)return;let e=new ne(t.data.slice(0,4),"le").toNumber();return t.data.slice(4,4+e).toString()}))}const EM=(t,e=Sf,r)=>{let n=bM(t);return{pubkey:vM(n,r,e),hashed:n}},xM=(t,e)=>{t.endsWith(".sol")&&(t=t.slice(0,-4));const r=e===exports.RecordVersion.V2?bB:void 0,i=t.split(".");if(2===i.length){const t=n.Buffer.from([e||0]).toString().concat(i[0]),{pubkey:o}=EM(i[1]);return{...EM(t,o,r),isSub:!0,parent:o}}if(3===i.length&&e){const{pubkey:t}=EM(i[2]),{pubkey:n}=EM("\0".concat(i[1]),t),o=e===exports.RecordVersion.V2?"":"";return{...EM(o.concat(i[0]),n,r),isSub:!0,parent:t,isSubRecord:!0}}if(i.length>=3)throw new Dc(exports.ErrorType.InvalidInput);return{...EM(t,Sf),isSub:!1,parent:void 0}};async function SM(t,e){const r=[{memcmp:{offset:32,bytes:e.toBase58()}},{memcmp:{offset:0,bytes:Sf.toBase58()}}];return(await t.getProgramAccounts(Ef,{filters:r})).map((t=>t.pubkey))}const AM=(t,e)=>{const{pubkey:r,parent:n}=xM(t),i=bM(r.toBase58());return vM(i,Mf,e?n:void 0)},IM=(t,e)=>{if(!t)throw new Dc(e)};var BM={},MM={};function RM(t,e,r,n,i){var o=(1<<n)-1,s=0,a=0,u=0;if(t.forEach((function(t){for(s=(s<<e)+t,a+=e;a>=n;)a-=n,r[u]=s>>a&o,u+=1})),i)a>0&&(r[u]=s<<n-a&o);else{if(a>=e)throw new Error("Excessive padding: ".concat(a," (max ").concat(e-1," allowed)"));if(s%(1<<a)!=0)throw new Error("Non-zero padding")}}Object.defineProperty(MM,"__esModule",{value:!0}),MM.createBitArray=function(t){return new Uint8Array(t)},MM.fromBits=function(t,e,r){if(e>8||e<1)throw new RangeError("Invalid bits per element; 1 to 8 expected");return RM(t,e,r,8,!1),r},MM.toBits=function(t,e,r){if(e>8||e<1)throw new RangeError("Invalid bits per element; 1 to 8 expected");return RM(t,8,r,e,!0),r};var PM={};Object.defineProperty(PM,"__esModule",{value:!0}),PM.CHECKSUM_LENGTH=void 0,PM.createChecksum=function(t,e){var r;switch(e){case"bech32":r=1;break;case"bech32m":r=OM;break;default:throw Error("Invalid encoding value: ".concat(e,"; expected bech32 or bech32m"))}for(var n=jM(t)^r,i=0;i<NM;i+=1){var o=5*(5-i);t[t.length-NM+i]=n>>o&31}},PM.decode=FM,PM.decodeWithPrefix=function(t,e){var r=e.length+2*t.length+1,n=(0,TM.createBitArray)(r);return WM(t,n.subarray(0,2*t.length+1)),FM(e,n.subarray(2*t.length+1)),n},PM.detectCase=function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"message",r=!1,n=!1,i=0;i<t.length;i+=1){var o=t.charCodeAt(i);if(o<UM||o>CM)throw new TypeError("Invalid char in ".concat(e,": ").concat(o,"; ")+"should be in ASCII range ".concat(UM,"-").concat(CM));n=n||o>=65&&o<=90,r=r||o>=97&&o<=122}if(r&&n)throw new TypeError("Mixed-case ".concat(e));return n?"upper":r?"lower":null},PM.encode=function(t){return t.reduce((function(t,e){return t+LM[e]}),"")},PM.expandPrefix=WM,PM.verifyChecksum=function(t){switch(jM(t)){case 1:return"bech32";case OM:return"bech32m";default:return}};var TM=MM,LM="qpzry9x8gf2tvdw0s3jn54khce6mua7l",OM=734539939,UM=33,CM=126,NM=6;PM.CHECKSUM_LENGTH=NM;var zM=function(){for(var t=new Map,e=0;e<LM.length;e+=1)t.set(LM[e],e);return t}(),DM=[996825010,642813549,513874426,1027748829,705979059];function jM(t){return t.reduce((function(t,e){var r=t>>25,n=(33554431&t)<<5^e;return DM.reduce((function(t,e,n){return 0==(r>>n&1)?t:t^e}),n)}),1)}function WM(t,e){for(var r=0;r<t.length;r+=1){var n=t.charCodeAt(r);e[r]=n>>5,e[r+t.length+1]=31&n}e[t.length]=0}function FM(t,e){for(var r=e||(0,TM.createBitArray)(t.length),n=0;n<t.length;n+=1){var i=zM.get(t[n]);if(void 0===i)throw new Error("Invalid char in message: ".concat(t[n]));r[n]=i}return r}Object.defineProperty(BM,"__esModule",{value:!0}),BM.BitcoinAddress=void 0;var KM=BM.decode=function(t){var e=XM(t),r=e.prefix,n=e.encoding,i=e.data;return{prefix:r,encoding:n,data:YM(i)}};BM.decodeTo5BitArray=XM;var VM=BM.encode=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"bech32";return JM(t,ZM(e),r)};BM.encode5BitArray=JM,BM.from5BitArray=YM,BM.to5BitArray=ZM;var qM=MM,HM=PM;function $M(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var GM=90;function ZM(t,e){var r=Math.ceil(8*t.length/5),n=e||(0,qM.createBitArray)(r);return(0,qM.toBits)(t,5,n)}function YM(t,e){var r=Math.floor(5*t.length/8),n=e||new Uint8Array(r);return(0,qM.fromBits)(t,5,n)}function JM(t,e){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"bech32",i=2*t.length+1+e.length+HM.CHECKSUM_LENGTH;if(i-t.length>GM)throw new Error("Message to be produced is too long (max ".concat(GM," supported)"));var o=null!==(r=(0,HM.detectCase)(t,"prefix"))&&void 0!==r?r:"lower",s=(0,qM.createBitArray)(i);(0,HM.expandPrefix)(t.toLowerCase(),s.subarray(0,2*t.length+1)),s.subarray(2*t.length+1,s.length-HM.CHECKSUM_LENGTH).set(e),(0,HM.createChecksum)(s,n);var a=(0,HM.encode)(s.subarray(2*t.length+1));return"upper"===o&&(a=a.toUpperCase()),"".concat(t,"1").concat(a)}function XM(t){if(t.length>GM)throw new TypeError("Message too long; max ".concat(GM," expected"));(0,HM.detectCase)(t);var e=t.toLowerCase(),r=e.lastIndexOf("1");if(r<0)throw new Error('No separator char ("1") found');if(r>t.length-HM.CHECKSUM_LENGTH-1)throw new Error("Data part of the message too short (at least ".concat(HM.CHECKSUM_LENGTH," chars expected)"));var n=e.substring(0,r),i=(0,HM.decodeWithPrefix)(n,e.substring(r+1)),o=(0,HM.verifyChecksum)(i);if(void 0===o)throw new Error("Invalid checksum");return{prefix:n,encoding:o,data:i.subarray(2*n.length+1,i.length-HM.CHECKSUM_LENGTH)}}var QM=function(){function t(e,r,n){if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),"bc"!==e&&"tb"!==e)throw new Error('Invalid human-readable prefix, "bc" or "tb" expected');if(r<0||r>16)throw new RangeError("Invalid scriptVersion, value in range [0, 16] expected");if(n.length<2||n.length>40)throw new RangeError("Invalid script length: expected 2 to 40 bytes");if(0===r&&20!==n.length&&32!==n.length)throw new Error("Invalid v0 script length: expected 20 or 32 bytes");this.prefix=e,this.scriptVersion=r,this.data=n}var e,r,n;return e=t,r=[{key:"type",value:function(){if(0===this.scriptVersion)switch(this.data.length){case 20:return"p2wpkh";case 32:return"p2wsh";default:return}}},{key:"encode",value:function(){var t=Math.ceil(8*this.data.length/5),e=(0,qM.createBitArray)(t+1);e[0]=this.scriptVersion,ZM(this.data,e.subarray(1));var r=0===this.scriptVersion?"bech32":"bech32m";return JM(this.prefix,e,r)}}],n=[{key:"decode",value:function(t){var e=XM(t),r=e.prefix,n=e.data,i=e.encoding;if("bc"!==r&&"tb"!==r)throw new Error('Invalid human-readable prefix, "bc" or "tb" expected');var o=n[0];if(0===o&&"bech32"!==i)throw Error("Unexpected encoding ".concat(i," used for version 0 script"));if(o>0&&"bech32m"!==i)throw Error("Unexpected encoding ".concat(i," used for version ").concat(o," script"));return new this(r,o,YM(n.subarray(1)))}}],r&&$M(e.prototype,r),n&&$M(e,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();BM.BitcoinAddress=QM;var tR={exports:{}};!function(e){!function(t){const r="(0?\\d+|0x[a-f0-9]+)",n={fourOctet:new RegExp(`^${r}\\.${r}\\.${r}\\.${r}$`,"i"),threeOctet:new RegExp(`^${r}\\.${r}\\.${r}$`,"i"),twoOctet:new RegExp(`^${r}\\.${r}$`,"i"),longValue:new RegExp(`^${r}$`,"i")},i=new RegExp("^0[0-7]+$","i"),o=new RegExp("^0x[a-f0-9]+$","i"),s="%[0-9a-z]{1,}",a="(?:[0-9a-f]+::?)+",u={zoneIndex:new RegExp(s,"i"),native:new RegExp(`^(::)?(${a})?([0-9a-f]+)?(::)?(${s})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${r}\\.${r}\\.${r}\\.${r}(${s})?)$`,"i"),transitional:new RegExp(`^((?:${a})|(?:::)(?:${a})?)${r}\\.${r}\\.${r}\\.${r}(${s})?$`,"i")};function c(t,e){if(t.indexOf("::")!==t.lastIndexOf("::"))return null;let r,n,i=0,o=-1,s=(t.match(u.zoneIndex)||[])[0];for(s&&(s=s.substring(1),t=t.replace(/%.+$/,""));(o=t.indexOf(":",o+1))>=0;)i++;if("::"===t.substr(0,2)&&i--,"::"===t.substr(-2,2)&&i--,i>e)return null;for(n=e-i,r=":";n--;)r+="0:";return":"===(t=t.replace("::",r))[0]&&(t=t.slice(1)),":"===t[t.length-1]&&(t=t.slice(0,-1)),e=function(){const e=t.split(":"),r=[];for(let t=0;t<e.length;t++)r.push(parseInt(e[t],16));return r}(),{parts:e,zoneId:s}}function h(t,e,r,n){if(t.length!==e.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let i,o=0;for(;n>0;){if(i=r-n,i<0&&(i=0),t[o]>>i!=e[o]>>i)return!1;n-=r,o+=1}return!0}function l(t){if(o.test(t))return parseInt(t,16);if("0"===t[0]&&!isNaN(parseInt(t[1],10))){if(i.test(t))return parseInt(t,8);throw new Error(`ipaddr: cannot parse ${t} as octal`)}return parseInt(t,10)}function f(t,e){for(;t.length<e;)t=`0${t}`;return t}const d={};d.IPv4=function(){function t(t){if(4!==t.length)throw new Error("ipaddr: ipv4 octet count should be 4");let e,r;for(e=0;e<t.length;e++)if(r=t[e],!(0<=r&&r<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=t}return t.prototype.SpecialRanges={unspecified:[[new t([0,0,0,0]),8]],broadcast:[[new t([255,255,255,255]),32]],multicast:[[new t([224,0,0,0]),4]],linkLocal:[[new t([169,254,0,0]),16]],loopback:[[new t([127,0,0,0]),8]],carrierGradeNat:[[new t([100,64,0,0]),10]],private:[[new t([10,0,0,0]),8],[new t([172,16,0,0]),12],[new t([192,168,0,0]),16]],reserved:[[new t([192,0,0,0]),24],[new t([192,0,2,0]),24],[new t([192,88,99,0]),24],[new t([198,18,0,0]),15],[new t([198,51,100,0]),24],[new t([203,0,113,0]),24],[new t([240,0,0,0]),4]]},t.prototype.kind=function(){return"ipv4"},t.prototype.match=function(t,e){let r;if(void 0===e&&(r=t,t=r[0],e=r[1]),"ipv4"!==t.kind())throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return h(this.octets,t.octets,8,e)},t.prototype.prefixLengthFromSubnetMask=function(){let t=0,e=!1;const r={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0};let n,i,o;for(n=3;n>=0;n-=1){if(i=this.octets[n],!(i in r))return null;if(o=r[i],e&&0!==o)return null;8!==o&&(e=!0),t+=o}return 32-t},t.prototype.range=function(){return d.subnetMatch(this,this.SpecialRanges)},t.prototype.toByteArray=function(){return this.octets.slice(0)},t.prototype.toIPv4MappedAddress=function(){return d.IPv6.parse(`::ffff:${this.toString()}`)},t.prototype.toNormalizedString=function(){return this.toString()},t.prototype.toString=function(){return this.octets.join(".")},t}(),d.IPv4.broadcastAddressFromCIDR=function(t){try{const e=this.parseCIDR(t),r=e[0].toByteArray(),n=this.subnetMaskFromPrefixLength(e[1]).toByteArray(),i=[];let o=0;for(;o<4;)i.push(parseInt(r[o],10)|255^parseInt(n[o],10)),o++;return new this(i)}catch(t){throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},d.IPv4.isIPv4=function(t){return null!==this.parser(t)},d.IPv4.isValid=function(t){try{return new this(this.parser(t)),!0}catch(t){return!1}},d.IPv4.isValidFourPartDecimal=function(t){return!(!d.IPv4.isValid(t)||!t.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},d.IPv4.networkAddressFromCIDR=function(t){let e,r,n,i,o;try{for(e=this.parseCIDR(t),n=e[0].toByteArray(),o=this.subnetMaskFromPrefixLength(e[1]).toByteArray(),i=[],r=0;r<4;)i.push(parseInt(n[r],10)&parseInt(o[r],10)),r++;return new this(i)}catch(t){throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},d.IPv4.parse=function(t){const e=this.parser(t);if(null===e)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(e)},d.IPv4.parseCIDR=function(t){let e;if(e=t.match(/^(.+)\/(\d+)$/)){const t=parseInt(e[2]);if(t>=0&&t<=32){const r=[this.parse(e[1]),t];return Object.defineProperty(r,"toString",{value:function(){return this.join("/")}}),r}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},d.IPv4.parser=function(t){let e,r,i;if(e=t.match(n.fourOctet))return function(){const t=e.slice(1,6),n=[];for(let e=0;e<t.length;e++)r=t[e],n.push(l(r));return n}();if(e=t.match(n.longValue)){if(i=l(e[1]),i>4294967295||i<0)throw new Error("ipaddr: address outside defined range");return function(){const t=[];let e;for(e=0;e<=24;e+=8)t.push(i>>e&255);return t}().reverse()}return(e=t.match(n.twoOctet))?function(){const t=e.slice(1,4),r=[];if(i=l(t[1]),i>16777215||i<0)throw new Error("ipaddr: address outside defined range");return r.push(l(t[0])),r.push(i>>16&255),r.push(i>>8&255),r.push(255&i),r}():(e=t.match(n.threeOctet))?function(){const t=e.slice(1,5),r=[];if(i=l(t[2]),i>65535||i<0)throw new Error("ipaddr: address outside defined range");return r.push(l(t[0])),r.push(l(t[1])),r.push(i>>8&255),r.push(255&i),r}():null},d.IPv4.subnetMaskFromPrefixLength=function(t){if((t=parseInt(t))<0||t>32)throw new Error("ipaddr: invalid IPv4 prefix length");const e=[0,0,0,0];let r=0;const n=Math.floor(t/8);for(;r<n;)e[r]=255,r++;return n<4&&(e[n]=Math.pow(2,t%8)-1<<8-t%8),new this(e)},d.IPv6=function(){function t(t,e){let r,n;if(16===t.length)for(this.parts=[],r=0;r<=14;r+=2)this.parts.push(t[r]<<8|t[r+1]);else{if(8!==t.length)throw new Error("ipaddr: ipv6 part count should be 8 or 16");this.parts=t}for(r=0;r<this.parts.length;r++)if(n=this.parts[r],!(0<=n&&n<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");e&&(this.zoneId=e)}return t.prototype.SpecialRanges={unspecified:[new t([0,0,0,0,0,0,0,0]),128],linkLocal:[new t([65152,0,0,0,0,0,0,0]),10],multicast:[new t([65280,0,0,0,0,0,0,0]),8],loopback:[new t([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new t([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new t([0,0,0,0,0,65535,0,0]),96],rfc6145:[new t([0,0,0,0,65535,0,0,0]),96],rfc6052:[new t([100,65435,0,0,0,0,0,0]),96],"6to4":[new t([8194,0,0,0,0,0,0,0]),16],teredo:[new t([8193,0,0,0,0,0,0,0]),32],reserved:[[new t([8193,3512,0,0,0,0,0,0]),32]],benchmarking:[new t([8193,2,0,0,0,0,0,0]),48],amt:[new t([8193,3,0,0,0,0,0,0]),32],as112v6:[new t([8193,4,274,0,0,0,0,0]),48],deprecated:[new t([8193,16,0,0,0,0,0,0]),28],orchid2:[new t([8193,32,0,0,0,0,0,0]),28]},t.prototype.isIPv4MappedAddress=function(){return"ipv4Mapped"===this.range()},t.prototype.kind=function(){return"ipv6"},t.prototype.match=function(t,e){let r;if(void 0===e&&(r=t,t=r[0],e=r[1]),"ipv6"!==t.kind())throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return h(this.parts,t.parts,16,e)},t.prototype.prefixLengthFromSubnetMask=function(){let t=0,e=!1;const r={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0};let n,i;for(let o=7;o>=0;o-=1){if(n=this.parts[o],!(n in r))return null;if(i=r[n],e&&0!==i)return null;16!==i&&(e=!0),t+=i}return 128-t},t.prototype.range=function(){return d.subnetMatch(this,this.SpecialRanges)},t.prototype.toByteArray=function(){let t;const e=[],r=this.parts;for(let n=0;n<r.length;n++)t=r[n],e.push(t>>8),e.push(255&t);return e},t.prototype.toFixedLengthString=function(){const t=function(){const t=[];for(let e=0;e<this.parts.length;e++)t.push(f(this.parts[e].toString(16),4));return t}.call(this).join(":");let e="";return this.zoneId&&(e=`%${this.zoneId}`),t+e},t.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");const t=this.parts.slice(-2),e=t[0],r=t[1];return new d.IPv4([e>>8,255&e,r>>8,255&r])},t.prototype.toNormalizedString=function(){const t=function(){const t=[];for(let e=0;e<this.parts.length;e++)t.push(this.parts[e].toString(16));return t}.call(this).join(":");let e="";return this.zoneId&&(e=`%${this.zoneId}`),t+e},t.prototype.toRFC5952String=function(){const t=/((^|:)(0(:|$)){2,})/g,e=this.toNormalizedString();let r,n=0,i=-1;for(;r=t.exec(e);)r[0].length>i&&(n=r.index,i=r[0].length);return i<0?e:`${e.substring(0,n)}::${e.substring(n+i)}`},t.prototype.toString=function(){return this.toRFC5952String()},t}(),d.IPv6.broadcastAddressFromCIDR=function(t){try{const e=this.parseCIDR(t),r=e[0].toByteArray(),n=this.subnetMaskFromPrefixLength(e[1]).toByteArray(),i=[];let o=0;for(;o<16;)i.push(parseInt(r[o],10)|255^parseInt(n[o],10)),o++;return new this(i)}catch(t){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${t})`)}},d.IPv6.isIPv6=function(t){return null!==this.parser(t)},d.IPv6.isValid=function(t){if("string"==typeof t&&-1===t.indexOf(":"))return!1;try{const e=this.parser(t);return new this(e.parts,e.zoneId),!0}catch(t){return!1}},d.IPv6.networkAddressFromCIDR=function(t){let e,r,n,i,o;try{for(e=this.parseCIDR(t),n=e[0].toByteArray(),o=this.subnetMaskFromPrefixLength(e[1]).toByteArray(),i=[],r=0;r<16;)i.push(parseInt(n[r],10)&parseInt(o[r],10)),r++;return new this(i)}catch(t){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${t})`)}},d.IPv6.parse=function(t){const e=this.parser(t);if(null===e.parts)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(e.parts,e.zoneId)},d.IPv6.parseCIDR=function(t){let e,r,n;if((r=t.match(/^(.+)\/(\d+)$/))&&(e=parseInt(r[2]),e>=0&&e<=128))return n=[this.parse(r[1]),e],Object.defineProperty(n,"toString",{value:function(){return this.join("/")}}),n;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},d.IPv6.parser=function(t){let e,r,n,i,o,s;if(n=t.match(u.deprecatedTransitional))return this.parser(`::ffff:${n[1]}`);if(u.native.test(t))return c(t,8);if((n=t.match(u.transitional))&&(s=n[6]||"",e=c(n[1].slice(0,-1)+s,6),e.parts)){for(o=[parseInt(n[2]),parseInt(n[3]),parseInt(n[4]),parseInt(n[5])],r=0;r<o.length;r++)if(i=o[r],!(0<=i&&i<=255))return null;return e.parts.push(o[0]<<8|o[1]),e.parts.push(o[2]<<8|o[3]),{parts:e.parts,zoneId:e.zoneId}}return null},d.IPv6.subnetMaskFromPrefixLength=function(t){if((t=parseInt(t))<0||t>128)throw new Error("ipaddr: invalid IPv6 prefix length");const e=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];let r=0;const n=Math.floor(t/8);for(;r<n;)e[r]=255,r++;return n<16&&(e[n]=Math.pow(2,t%8)-1<<8-t%8),new this(e)},d.fromByteArray=function(t){const e=t.length;if(4===e)return new d.IPv4(t);if(16===e)return new d.IPv6(t);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},d.isValid=function(t){return d.IPv6.isValid(t)||d.IPv4.isValid(t)},d.parse=function(t){if(d.IPv6.isValid(t))return d.IPv6.parse(t);if(d.IPv4.isValid(t))return d.IPv4.parse(t);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},d.parseCIDR=function(t){try{return d.IPv6.parseCIDR(t)}catch(e){try{return d.IPv4.parseCIDR(t)}catch(t){throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},d.process=function(t){const e=this.parse(t);return"ipv6"===e.kind()&&e.isIPv4MappedAddress()?e.toIPv4Address():e},d.subnetMatch=function(t,e,r){let n,i,o,s;for(i in null==r&&(r="unicast"),e)if(Object.prototype.hasOwnProperty.call(e,i))for(o=e[i],!o[0]||o[0]instanceof Array||(o=[o]),n=0;n<o.length;n++)if(s=o[n],t.kind()===s[0].kind()&&t.match.apply(t,s))return i;return r},e.exports?e.exports=d:t.ipaddr=d}(t)}(tR);var eR=e(tR.exports);const rR=2147483647,nR=36,iR={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},oR=Math.floor,sR=String.fromCharCode;function aR(t){throw new RangeError(iR[t])}const uR=function(t,e){return t+22+75*(t<26)-((0!=e)<<5)},cR=function(t,e,r){let n=0;for(t=r?oR(t/700):t>>1,t+=oR(t/e);t>455;n+=nR)t=oR(t/35);return oR(n+36*t/(t+38))},hR=function(t){const e=[];t=function(t){const e=[];let r=0;const n=t.length;for(;r<n;){const i=t.charCodeAt(r++);if(i>=55296&&i<=56319&&r<n){const n=t.charCodeAt(r++);56320==(64512&n)?e.push(((1023&i)<<10)+(1023&n)+65536):(e.push(i),r--)}else e.push(i)}return e}(t);const r=t.length;let n=128,i=0,o=72;for(const r of t)r<128&&e.push(sR(r));const s=e.length;let a=s;for(s&&e.push("-");a<r;){let r=rR;for(const e of t)e>=n&&e<r&&(r=e);const u=a+1;r-n>oR((rR-i)/u)&&aR("overflow"),i+=(r-n)*u,n=r;for(const r of t)if(r<n&&++i>rR&&aR("overflow"),r===n){let t=i;for(let r=nR;;r+=nR){const n=r<=o?1:r>=o+26?26:r-o;if(t<n)break;const i=t-n,s=nR-n;e.push(sR(uR(n+i%s,0))),t=oR(i/s)}e.push(sR(uR(t,0))),o=cR(i,u,a===s),i=0,++a}++i,++n}return e.join("")};function lR(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var fR={exports:{}};!function(t){var e=function(t){var e,r=new Float64Array(16);if(t)for(e=0;e<t.length;e++)r[e]=t[e];return r},r=function(){throw new Error("no PRNG")},n=new Uint8Array(16),i=new Uint8Array(32);i[0]=9;var o=e(),s=e([1]),a=e([56129,1]),u=e([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),c=e([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),h=e([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),l=e([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),f=e([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function d(t,e,r,n){t[e]=r>>24&255,t[e+1]=r>>16&255,t[e+2]=r>>8&255,t[e+3]=255&r,t[e+4]=n>>24&255,t[e+5]=n>>16&255,t[e+6]=n>>8&255,t[e+7]=255&n}function p(t,e,r,n,i){var o,s=0;for(o=0;o<i;o++)s|=t[e+o]^r[n+o];return(1&s-1>>>8)-1}function y(t,e,r,n){return p(t,e,r,n,16)}function g(t,e,r,n){return p(t,e,r,n,32)}function m(t,e,r,n){!function(t,e,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,u=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,c=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&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,f=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,d=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,p=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,y=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,g=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,k=s,E=a,x=u,S=c,A=h,I=l,B=f,M=d,R=p,P=y,T=g,L=m,O=w,U=b,C=v,N=0;N<20;N+=2)_^=(i=(L^=(i=(M^=(i=(S^=(i=_+L|0)<<7|i>>>25)+_|0)<<9|i>>>23)+S|0)<<13|i>>>19)+M|0)<<18|i>>>14,A^=(i=(k^=(i=(O^=(i=(R^=(i=A+k|0)<<7|i>>>25)+A|0)<<9|i>>>23)+R|0)<<13|i>>>19)+O|0)<<18|i>>>14,P^=(i=(I^=(i=(E^=(i=(U^=(i=P+I|0)<<7|i>>>25)+P|0)<<9|i>>>23)+U|0)<<13|i>>>19)+E|0)<<18|i>>>14,C^=(i=(T^=(i=(B^=(i=(x^=(i=C+T|0)<<7|i>>>25)+C|0)<<9|i>>>23)+x|0)<<13|i>>>19)+B|0)<<18|i>>>14,_^=(i=(x^=(i=(E^=(i=(k^=(i=_+x|0)<<7|i>>>25)+_|0)<<9|i>>>23)+k|0)<<13|i>>>19)+E|0)<<18|i>>>14,A^=(i=(S^=(i=(B^=(i=(I^=(i=A+S|0)<<7|i>>>25)+A|0)<<9|i>>>23)+I|0)<<13|i>>>19)+B|0)<<18|i>>>14,P^=(i=(R^=(i=(M^=(i=(T^=(i=P+R|0)<<7|i>>>25)+P|0)<<9|i>>>23)+T|0)<<13|i>>>19)+M|0)<<18|i>>>14,C^=(i=(U^=(i=(O^=(i=(L^=(i=C+U|0)<<7|i>>>25)+C|0)<<9|i>>>23)+L|0)<<13|i>>>19)+O|0)<<18|i>>>14;_=_+o|0,k=k+s|0,E=E+a|0,x=x+u|0,S=S+c|0,A=A+h|0,I=I+l|0,B=B+f|0,M=M+d|0,R=R+p|0,P=P+y|0,T=T+g|0,L=L+m|0,O=O+w|0,U=U+b|0,C=C+v|0,t[0]=_>>>0&255,t[1]=_>>>8&255,t[2]=_>>>16&255,t[3]=_>>>24&255,t[4]=k>>>0&255,t[5]=k>>>8&255,t[6]=k>>>16&255,t[7]=k>>>24&255,t[8]=E>>>0&255,t[9]=E>>>8&255,t[10]=E>>>16&255,t[11]=E>>>24&255,t[12]=x>>>0&255,t[13]=x>>>8&255,t[14]=x>>>16&255,t[15]=x>>>24&255,t[16]=S>>>0&255,t[17]=S>>>8&255,t[18]=S>>>16&255,t[19]=S>>>24&255,t[20]=A>>>0&255,t[21]=A>>>8&255,t[22]=A>>>16&255,t[23]=A>>>24&255,t[24]=I>>>0&255,t[25]=I>>>8&255,t[26]=I>>>16&255,t[27]=I>>>24&255,t[28]=B>>>0&255,t[29]=B>>>8&255,t[30]=B>>>16&255,t[31]=B>>>24&255,t[32]=M>>>0&255,t[33]=M>>>8&255,t[34]=M>>>16&255,t[35]=M>>>24&255,t[36]=R>>>0&255,t[37]=R>>>8&255,t[38]=R>>>16&255,t[39]=R>>>24&255,t[40]=P>>>0&255,t[41]=P>>>8&255,t[42]=P>>>16&255,t[43]=P>>>24&255,t[44]=T>>>0&255,t[45]=T>>>8&255,t[46]=T>>>16&255,t[47]=T>>>24&255,t[48]=L>>>0&255,t[49]=L>>>8&255,t[50]=L>>>16&255,t[51]=L>>>24&255,t[52]=O>>>0&255,t[53]=O>>>8&255,t[54]=O>>>16&255,t[55]=O>>>24&255,t[56]=U>>>0&255,t[57]=U>>>8&255,t[58]=U>>>16&255,t[59]=U>>>24&255,t[60]=C>>>0&255,t[61]=C>>>8&255,t[62]=C>>>16&255,t[63]=C>>>24&255}(t,e,r,n)}function w(t,e,r,n){!function(t,e,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,u=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,c=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&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,f=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,d=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,p=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,y=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,g=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=(c^=(i=o+m|0)<<7|i>>>25)+o|0)<<9|i>>>23)+c|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,y^=(i=(l^=(i=(a^=(i=(b^=(i=y+l|0)<<7|i>>>25)+y|0)<<9|i>>>23)+b|0)<<13|i>>>19)+a|0)<<18|i>>>14,v^=(i=(g^=(i=(f^=(i=(u^=(i=v+g|0)<<7|i>>>25)+v|0)<<9|i>>>23)+u|0)<<13|i>>>19)+f|0)<<18|i>>>14,o^=(i=(u^=(i=(a^=(i=(s^=(i=o+u|0)<<7|i>>>25)+o|0)<<9|i>>>23)+s|0)<<13|i>>>19)+a|0)<<18|i>>>14,h^=(i=(c^=(i=(f^=(i=(l^=(i=h+c|0)<<7|i>>>25)+h|0)<<9|i>>>23)+l|0)<<13|i>>>19)+f|0)<<18|i>>>14,y^=(i=(p^=(i=(d^=(i=(g^=(i=y+p|0)<<7|i>>>25)+y|0)<<9|i>>>23)+g|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;t[0]=o>>>0&255,t[1]=o>>>8&255,t[2]=o>>>16&255,t[3]=o>>>24&255,t[4]=h>>>0&255,t[5]=h>>>8&255,t[6]=h>>>16&255,t[7]=h>>>24&255,t[8]=y>>>0&255,t[9]=y>>>8&255,t[10]=y>>>16&255,t[11]=y>>>24&255,t[12]=v>>>0&255,t[13]=v>>>8&255,t[14]=v>>>16&255,t[15]=v>>>24&255,t[16]=l>>>0&255,t[17]=l>>>8&255,t[18]=l>>>16&255,t[19]=l>>>24&255,t[20]=f>>>0&255,t[21]=f>>>8&255,t[22]=f>>>16&255,t[23]=f>>>24&255,t[24]=d>>>0&255,t[25]=d>>>8&255,t[26]=d>>>16&255,t[27]=d>>>24&255,t[28]=p>>>0&255,t[29]=p>>>8&255,t[30]=p>>>16&255,t[31]=p>>>24&255}(t,e,r,n)}var b=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function v(t,e,r,n,i,o,s){var a,u,c=new Uint8Array(16),h=new Uint8Array(64);for(u=0;u<16;u++)c[u]=0;for(u=0;u<8;u++)c[u]=o[u];for(;i>=64;){for(m(h,c,s,b),u=0;u<64;u++)t[e+u]=r[n+u]^h[u];for(a=1,u=8;u<16;u++)a=a+(255&c[u])|0,c[u]=255&a,a>>>=8;i-=64,e+=64,n+=64}if(i>0)for(m(h,c,s,b),u=0;u<i;u++)t[e+u]=r[n+u]^h[u];return 0}function _(t,e,r,n,i){var o,s,a=new Uint8Array(16),u=new Uint8Array(64);for(s=0;s<16;s++)a[s]=0;for(s=0;s<8;s++)a[s]=n[s];for(;r>=64;){for(m(u,a,i,b),s=0;s<64;s++)t[e+s]=u[s];for(o=1,s=8;s<16;s++)o=o+(255&a[s])|0,a[s]=255&o,o>>>=8;r-=64,e+=64}if(r>0)for(m(u,a,i,b),s=0;s<r;s++)t[e+s]=u[s];return 0}function k(t,e,r,n,i){var o=new Uint8Array(32);w(o,n,i,b);for(var s=new Uint8Array(8),a=0;a<8;a++)s[a]=n[a+16];return _(t,e,r,s,o)}function E(t,e,r,n,i,o,s){var a=new Uint8Array(32);w(a,o,s,b);for(var u=new Uint8Array(8),c=0;c<8;c++)u[c]=o[c+16];return v(t,e,r,n,i,u,a)}var x=function(t){var e,r,n,i,o,s,a,u;this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0,e=255&t[0]|(255&t[1])<<8,this.r[0]=8191&e,r=255&t[2]|(255&t[3])<<8,this.r[1]=8191&(e>>>13|r<<3),n=255&t[4]|(255&t[5])<<8,this.r[2]=7939&(r>>>10|n<<6),i=255&t[6]|(255&t[7])<<8,this.r[3]=8191&(n>>>7|i<<9),o=255&t[8]|(255&t[9])<<8,this.r[4]=255&(i>>>4|o<<12),this.r[5]=o>>>1&8190,s=255&t[10]|(255&t[11])<<8,this.r[6]=8191&(o>>>14|s<<2),a=255&t[12]|(255&t[13])<<8,this.r[7]=8065&(s>>>11|a<<5),u=255&t[14]|(255&t[15])<<8,this.r[8]=8191&(a>>>8|u<<8),this.r[9]=u>>>5&127,this.pad[0]=255&t[16]|(255&t[17])<<8,this.pad[1]=255&t[18]|(255&t[19])<<8,this.pad[2]=255&t[20]|(255&t[21])<<8,this.pad[3]=255&t[22]|(255&t[23])<<8,this.pad[4]=255&t[24]|(255&t[25])<<8,this.pad[5]=255&t[26]|(255&t[27])<<8,this.pad[6]=255&t[28]|(255&t[29])<<8,this.pad[7]=255&t[30]|(255&t[31])<<8};function S(t,e,r,n,i,o){var s=new x(o);return s.update(r,n,i),s.finish(t,e),0}function A(t,e,r,n,i,o){var s=new Uint8Array(16);return S(s,0,r,n,i,o),y(t,e,s,0)}function I(t,e,r,n,i){var o;if(r<32)return-1;for(E(t,0,e,0,r,n,i),S(t,16,t,32,r-32,t),o=0;o<16;o++)t[o]=0;return 0}function B(t,e,r,n,i){var o,s=new Uint8Array(32);if(r<32)return-1;if(k(s,0,32,n,i),0!==A(e,16,e,32,r-32,s))return-1;for(E(t,0,e,0,r,n,i),o=0;o<32;o++)t[o]=0;return 0}function M(t,e){var r;for(r=0;r<16;r++)t[r]=0|e[r]}function R(t){var e,r,n=1;for(e=0;e<16;e++)r=t[e]+n+65535,n=Math.floor(r/65536),t[e]=r-65536*n;t[0]+=n-1+37*(n-1)}function P(t,e,r){for(var n,i=~(r-1),o=0;o<16;o++)n=i&(t[o]^e[o]),t[o]^=n,e[o]^=n}function T(t,r){var n,i,o,s=e(),a=e();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,P(a,s,1-o)}for(n=0;n<16;n++)t[2*n]=255&a[n],t[2*n+1]=a[n]>>8}function L(t,e){var r=new Uint8Array(32),n=new Uint8Array(32);return T(r,t),T(n,e),g(r,0,n,0)}function O(t){var e=new Uint8Array(32);return T(e,t),1&e[0]}function U(t,e){var r;for(r=0;r<16;r++)t[r]=e[2*r]+(e[2*r+1]<<8);t[15]&=32767}function C(t,e,r){for(var n=0;n<16;n++)t[n]=e[n]+r[n]}function N(t,e,r){for(var n=0;n<16;n++)t[n]=e[n]-r[n]}function z(t,e,r){var n,i,o=0,s=0,a=0,u=0,c=0,h=0,l=0,f=0,d=0,p=0,y=0,g=0,m=0,w=0,b=0,v=0,_=0,k=0,E=0,x=0,S=0,A=0,I=0,B=0,M=0,R=0,P=0,T=0,L=0,O=0,U=0,C=r[0],N=r[1],z=r[2],D=r[3],j=r[4],W=r[5],F=r[6],K=r[7],V=r[8],q=r[9],H=r[10],$=r[11],G=r[12],Z=r[13],Y=r[14],J=r[15];o+=(n=e[0])*C,s+=n*N,a+=n*z,u+=n*D,c+=n*j,h+=n*W,l+=n*F,f+=n*K,d+=n*V,p+=n*q,y+=n*H,g+=n*$,m+=n*G,w+=n*Z,b+=n*Y,v+=n*J,s+=(n=e[1])*C,a+=n*N,u+=n*z,c+=n*D,h+=n*j,l+=n*W,f+=n*F,d+=n*K,p+=n*V,y+=n*q,g+=n*H,m+=n*$,w+=n*G,b+=n*Z,v+=n*Y,_+=n*J,a+=(n=e[2])*C,u+=n*N,c+=n*z,h+=n*D,l+=n*j,f+=n*W,d+=n*F,p+=n*K,y+=n*V,g+=n*q,m+=n*H,w+=n*$,b+=n*G,v+=n*Z,_+=n*Y,k+=n*J,u+=(n=e[3])*C,c+=n*N,h+=n*z,l+=n*D,f+=n*j,d+=n*W,p+=n*F,y+=n*K,g+=n*V,m+=n*q,w+=n*H,b+=n*$,v+=n*G,_+=n*Z,k+=n*Y,E+=n*J,c+=(n=e[4])*C,h+=n*N,l+=n*z,f+=n*D,d+=n*j,p+=n*W,y+=n*F,g+=n*K,m+=n*V,w+=n*q,b+=n*H,v+=n*$,_+=n*G,k+=n*Z,E+=n*Y,x+=n*J,h+=(n=e[5])*C,l+=n*N,f+=n*z,d+=n*D,p+=n*j,y+=n*W,g+=n*F,m+=n*K,w+=n*V,b+=n*q,v+=n*H,_+=n*$,k+=n*G,E+=n*Z,x+=n*Y,S+=n*J,l+=(n=e[6])*C,f+=n*N,d+=n*z,p+=n*D,y+=n*j,g+=n*W,m+=n*F,w+=n*K,b+=n*V,v+=n*q,_+=n*H,k+=n*$,E+=n*G,x+=n*Z,S+=n*Y,A+=n*J,f+=(n=e[7])*C,d+=n*N,p+=n*z,y+=n*D,g+=n*j,m+=n*W,w+=n*F,b+=n*K,v+=n*V,_+=n*q,k+=n*H,E+=n*$,x+=n*G,S+=n*Z,A+=n*Y,I+=n*J,d+=(n=e[8])*C,p+=n*N,y+=n*z,g+=n*D,m+=n*j,w+=n*W,b+=n*F,v+=n*K,_+=n*V,k+=n*q,E+=n*H,x+=n*$,S+=n*G,A+=n*Z,I+=n*Y,B+=n*J,p+=(n=e[9])*C,y+=n*N,g+=n*z,m+=n*D,w+=n*j,b+=n*W,v+=n*F,_+=n*K,k+=n*V,E+=n*q,x+=n*H,S+=n*$,A+=n*G,I+=n*Z,B+=n*Y,M+=n*J,y+=(n=e[10])*C,g+=n*N,m+=n*z,w+=n*D,b+=n*j,v+=n*W,_+=n*F,k+=n*K,E+=n*V,x+=n*q,S+=n*H,A+=n*$,I+=n*G,B+=n*Z,M+=n*Y,R+=n*J,g+=(n=e[11])*C,m+=n*N,w+=n*z,b+=n*D,v+=n*j,_+=n*W,k+=n*F,E+=n*K,x+=n*V,S+=n*q,A+=n*H,I+=n*$,B+=n*G,M+=n*Z,R+=n*Y,P+=n*J,m+=(n=e[12])*C,w+=n*N,b+=n*z,v+=n*D,_+=n*j,k+=n*W,E+=n*F,x+=n*K,S+=n*V,A+=n*q,I+=n*H,B+=n*$,M+=n*G,R+=n*Z,P+=n*Y,T+=n*J,w+=(n=e[13])*C,b+=n*N,v+=n*z,_+=n*D,k+=n*j,E+=n*W,x+=n*F,S+=n*K,A+=n*V,I+=n*q,B+=n*H,M+=n*$,R+=n*G,P+=n*Z,T+=n*Y,L+=n*J,b+=(n=e[14])*C,v+=n*N,_+=n*z,k+=n*D,E+=n*j,x+=n*W,S+=n*F,A+=n*K,I+=n*V,B+=n*q,M+=n*H,R+=n*$,P+=n*G,T+=n*Z,L+=n*Y,O+=n*J,v+=(n=e[15])*C,s+=38*(k+=n*z),a+=38*(E+=n*D),u+=38*(x+=n*j),c+=38*(S+=n*W),h+=38*(A+=n*F),l+=38*(I+=n*K),f+=38*(B+=n*V),d+=38*(M+=n*q),p+=38*(R+=n*H),y+=38*(P+=n*$),g+=38*(T+=n*G),m+=38*(L+=n*Z),w+=38*(O+=n*Y),b+=38*(U+=n*J),o=(n=(o+=38*(_+=n*N))+(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)),u=(n=u+i+65535)-65536*(i=Math.floor(n/65536)),c=(n=c+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)),y=(n=y+i+65535)-65536*(i=Math.floor(n/65536)),g=(n=g+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)),u=(n=u+i+65535)-65536*(i=Math.floor(n/65536)),c=(n=c+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)),y=(n=y+i+65535)-65536*(i=Math.floor(n/65536)),g=(n=g+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),t[0]=o,t[1]=s,t[2]=a,t[3]=u,t[4]=c,t[5]=h,t[6]=l,t[7]=f,t[8]=d,t[9]=p,t[10]=y,t[11]=g,t[12]=m,t[13]=w,t[14]=b,t[15]=v}function D(t,e){z(t,e,e)}function j(t,r){var n,i=e();for(n=0;n<16;n++)i[n]=r[n];for(n=253;n>=0;n--)D(i,i),2!==n&&4!==n&&z(i,i,r);for(n=0;n<16;n++)t[n]=i[n]}function W(t,r){var n,i=e();for(n=0;n<16;n++)i[n]=r[n];for(n=250;n>=0;n--)D(i,i),1!==n&&z(i,i,r);for(n=0;n<16;n++)t[n]=i[n]}function F(t,r,n){var i,o,s=new Uint8Array(32),u=new Float64Array(80),c=e(),h=e(),l=e(),f=e(),d=e(),p=e();for(o=0;o<31;o++)s[o]=r[o];for(s[31]=127&r[31]|64,s[0]&=248,U(u,n),o=0;o<16;o++)h[o]=u[o],f[o]=c[o]=l[o]=0;for(c[0]=f[0]=1,o=254;o>=0;--o)P(c,h,i=s[o>>>3]>>>(7&o)&1),P(l,f,i),C(d,c,l),N(c,c,l),C(l,h,f),N(h,h,f),D(f,d),D(p,c),z(c,l,c),z(l,h,d),C(d,c,l),N(c,c,l),D(h,c),N(l,f,p),z(c,l,a),C(c,c,f),z(l,l,c),z(c,f,p),z(f,h,u),D(h,d),P(c,h,i),P(l,f,i);for(o=0;o<16;o++)u[o+16]=c[o],u[o+32]=l[o],u[o+48]=h[o],u[o+64]=f[o];var y=u.subarray(32),g=u.subarray(16);return j(y,y),z(g,g,y),T(t,g),0}function K(t,e){return F(t,e,i)}function V(t,e){return r(e,32),K(t,e)}function q(t,e,r){var i=new Uint8Array(32);return F(i,r,e),w(t,n,i,b)}x.prototype.blocks=function(t,e,r){for(var n,i,o,s,a,u,c,h,l,f,d,p,y,g,m,w,b,v,_,k=this.fin?0:2048,E=this.h[0],x=this.h[1],S=this.h[2],A=this.h[3],I=this.h[4],B=this.h[5],M=this.h[6],R=this.h[7],P=this.h[8],T=this.h[9],L=this.r[0],O=this.r[1],U=this.r[2],C=this.r[3],N=this.r[4],z=this.r[5],D=this.r[6],j=this.r[7],W=this.r[8],F=this.r[9];r>=16;)f=l=0,f+=(E+=8191&(n=255&t[e+0]|(255&t[e+1])<<8))*L,f+=(x+=8191&(n>>>13|(i=255&t[e+2]|(255&t[e+3])<<8)<<3))*(5*F),f+=(S+=8191&(i>>>10|(o=255&t[e+4]|(255&t[e+5])<<8)<<6))*(5*W),f+=(A+=8191&(o>>>7|(s=255&t[e+6]|(255&t[e+7])<<8)<<9))*(5*j),l=(f+=(I+=8191&(s>>>4|(a=255&t[e+8]|(255&t[e+9])<<8)<<12))*(5*D))>>>13,f&=8191,f+=(B+=a>>>1&8191)*(5*z),f+=(M+=8191&(a>>>14|(u=255&t[e+10]|(255&t[e+11])<<8)<<2))*(5*N),f+=(R+=8191&(u>>>11|(c=255&t[e+12]|(255&t[e+13])<<8)<<5))*(5*C),f+=(P+=8191&(c>>>8|(h=255&t[e+14]|(255&t[e+15])<<8)<<8))*(5*U),d=l+=(f+=(T+=h>>>5|k)*(5*O))>>>13,d+=E*O,d+=x*L,d+=S*(5*F),d+=A*(5*W),l=(d+=I*(5*j))>>>13,d&=8191,d+=B*(5*D),d+=M*(5*z),d+=R*(5*N),d+=P*(5*C),l+=(d+=T*(5*U))>>>13,d&=8191,p=l,p+=E*U,p+=x*O,p+=S*L,p+=A*(5*F),l=(p+=I*(5*W))>>>13,p&=8191,p+=B*(5*j),p+=M*(5*D),p+=R*(5*z),p+=P*(5*N),y=l+=(p+=T*(5*C))>>>13,y+=E*C,y+=x*U,y+=S*O,y+=A*L,l=(y+=I*(5*F))>>>13,y&=8191,y+=B*(5*W),y+=M*(5*j),y+=R*(5*D),y+=P*(5*z),g=l+=(y+=T*(5*N))>>>13,g+=E*N,g+=x*C,g+=S*U,g+=A*O,l=(g+=I*L)>>>13,g&=8191,g+=B*(5*F),g+=M*(5*W),g+=R*(5*j),g+=P*(5*D),m=l+=(g+=T*(5*z))>>>13,m+=E*z,m+=x*N,m+=S*C,m+=A*U,l=(m+=I*O)>>>13,m&=8191,m+=B*L,m+=M*(5*F),m+=R*(5*W),m+=P*(5*j),w=l+=(m+=T*(5*D))>>>13,w+=E*D,w+=x*z,w+=S*N,w+=A*C,l=(w+=I*U)>>>13,w&=8191,w+=B*O,w+=M*L,w+=R*(5*F),w+=P*(5*W),b=l+=(w+=T*(5*j))>>>13,b+=E*j,b+=x*D,b+=S*z,b+=A*N,l=(b+=I*C)>>>13,b&=8191,b+=B*U,b+=M*O,b+=R*L,b+=P*(5*F),v=l+=(b+=T*(5*W))>>>13,v+=E*W,v+=x*j,v+=S*D,v+=A*z,l=(v+=I*N)>>>13,v&=8191,v+=B*C,v+=M*U,v+=R*O,v+=P*L,_=l+=(v+=T*(5*F))>>>13,_+=E*F,_+=x*W,_+=S*j,_+=A*D,l=(_+=I*z)>>>13,_&=8191,_+=B*N,_+=M*C,_+=R*U,_+=P*O,E=f=8191&(l=(l=((l+=(_+=T*L)>>>13)<<2)+l|0)+(f&=8191)|0),x=d+=l>>>=13,S=p&=8191,A=y&=8191,I=g&=8191,B=m&=8191,M=w&=8191,R=b&=8191,P=v&=8191,T=_&=8191,e+=16,r-=16;this.h[0]=E,this.h[1]=x,this.h[2]=S,this.h[3]=A,this.h[4]=I,this.h[5]=B,this.h[6]=M,this.h[7]=R,this.h[8]=P,this.h[9]=T},x.prototype.finish=function(t,e){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;t[e+0]=this.h[0]>>>0&255,t[e+1]=this.h[0]>>>8&255,t[e+2]=this.h[1]>>>0&255,t[e+3]=this.h[1]>>>8&255,t[e+4]=this.h[2]>>>0&255,t[e+5]=this.h[2]>>>8&255,t[e+6]=this.h[3]>>>0&255,t[e+7]=this.h[3]>>>8&255,t[e+8]=this.h[4]>>>0&255,t[e+9]=this.h[4]>>>8&255,t[e+10]=this.h[5]>>>0&255,t[e+11]=this.h[5]>>>8&255,t[e+12]=this.h[6]>>>0&255,t[e+13]=this.h[6]>>>8&255,t[e+14]=this.h[7]>>>0&255,t[e+15]=this.h[7]>>>8&255},x.prototype.update=function(t,e,r){var n,i;if(this.leftover){for((i=16-this.leftover)>r&&(i=r),n=0;n<i;n++)this.buffer[this.leftover+n]=t[e+n];if(r-=i,e+=i,this.leftover+=i,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(r>=16&&(i=r-r%16,this.blocks(t,e,i),e+=i,r-=i),r){for(n=0;n<r;n++)this.buffer[this.leftover+n]=t[e+n];this.leftover+=r}};var H=I,$=B,G=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function Z(t,e,r,n){for(var i,o,s,a,u,c,h,l,f,d,p,y,g,m,w,b,v,_,k,E,x,S,A,I,B,M,R=new Int32Array(16),P=new Int32Array(16),T=t[0],L=t[1],O=t[2],U=t[3],C=t[4],N=t[5],z=t[6],D=t[7],j=e[0],W=e[1],F=e[2],K=e[3],V=e[4],q=e[5],H=e[6],$=e[7],Z=0;n>=128;){for(k=0;k<16;k++)E=8*k+Z,R[k]=r[E+0]<<24|r[E+1]<<16|r[E+2]<<8|r[E+3],P[k]=r[E+4]<<24|r[E+5]<<16|r[E+6]<<8|r[E+7];for(k=0;k<80;k++)if(i=T,o=L,s=O,a=U,u=C,c=N,h=z,f=j,d=W,p=F,y=K,g=V,m=q,w=H,A=65535&(S=$),I=S>>>16,B=65535&(x=D),M=x>>>16,A+=65535&(S=(V>>>14|C<<18)^(V>>>18|C<<14)^(C>>>9|V<<23)),I+=S>>>16,B+=65535&(x=(C>>>14|V<<18)^(C>>>18|V<<14)^(V>>>9|C<<23)),M+=x>>>16,A+=65535&(S=V&q^~V&H),I+=S>>>16,B+=65535&(x=C&N^~C&z),M+=x>>>16,x=G[2*k],A+=65535&(S=G[2*k+1]),I+=S>>>16,B+=65535&x,M+=x>>>16,x=R[k%16],I+=(S=P[k%16])>>>16,B+=65535&x,M+=x>>>16,B+=(I+=(A+=65535&S)>>>16)>>>16,A=65535&(S=_=65535&A|I<<16),I=S>>>16,B=65535&(x=v=65535&B|(M+=B>>>16)<<16),M=x>>>16,A+=65535&(S=(j>>>28|T<<4)^(T>>>2|j<<30)^(T>>>7|j<<25)),I+=S>>>16,B+=65535&(x=(T>>>28|j<<4)^(j>>>2|T<<30)^(j>>>7|T<<25)),M+=x>>>16,I+=(S=j&W^j&F^W&F)>>>16,B+=65535&(x=T&L^T&O^L&O),M+=x>>>16,l=65535&(B+=(I+=(A+=65535&S)>>>16)>>>16)|(M+=B>>>16)<<16,b=65535&A|I<<16,A=65535&(S=y),I=S>>>16,B=65535&(x=a),M=x>>>16,I+=(S=_)>>>16,B+=65535&(x=v),M+=x>>>16,L=i,O=o,U=s,C=a=65535&(B+=(I+=(A+=65535&S)>>>16)>>>16)|(M+=B>>>16)<<16,N=u,z=c,D=h,T=l,W=f,F=d,K=p,V=y=65535&A|I<<16,q=g,H=m,$=w,j=b,k%16==15)for(E=0;E<16;E++)x=R[E],A=65535&(S=P[E]),I=S>>>16,B=65535&x,M=x>>>16,x=R[(E+9)%16],A+=65535&(S=P[(E+9)%16]),I+=S>>>16,B+=65535&x,M+=x>>>16,v=R[(E+1)%16],A+=65535&(S=((_=P[(E+1)%16])>>>1|v<<31)^(_>>>8|v<<24)^(_>>>7|v<<25)),I+=S>>>16,B+=65535&(x=(v>>>1|_<<31)^(v>>>8|_<<24)^v>>>7),M+=x>>>16,v=R[(E+14)%16],I+=(S=((_=P[(E+14)%16])>>>19|v<<13)^(v>>>29|_<<3)^(_>>>6|v<<26))>>>16,B+=65535&(x=(v>>>19|_<<13)^(_>>>29|v<<3)^v>>>6),M+=x>>>16,M+=(B+=(I+=(A+=65535&S)>>>16)>>>16)>>>16,R[E]=65535&B|M<<16,P[E]=65535&A|I<<16;A=65535&(S=j),I=S>>>16,B=65535&(x=T),M=x>>>16,x=t[0],I+=(S=e[0])>>>16,B+=65535&x,M+=x>>>16,M+=(B+=(I+=(A+=65535&S)>>>16)>>>16)>>>16,t[0]=T=65535&B|M<<16,e[0]=j=65535&A|I<<16,A=65535&(S=W),I=S>>>16,B=65535&(x=L),M=x>>>16,x=t[1],I+=(S=e[1])>>>16,B+=65535&x,M+=x>>>16,M+=(B+=(I+=(A+=65535&S)>>>16)>>>16)>>>16,t[1]=L=65535&B|M<<16,e[1]=W=65535&A|I<<16,A=65535&(S=F),I=S>>>16,B=65535&(x=O),M=x>>>16,x=t[2],I+=(S=e[2])>>>16,B+=65535&x,M+=x>>>16,M+=(B+=(I+=(A+=65535&S)>>>16)>>>16)>>>16,t[2]=O=65535&B|M<<16,e[2]=F=65535&A|I<<16,A=65535&(S=K),I=S>>>16,B=65535&(x=U),M=x>>>16,x=t[3],I+=(S=e[3])>>>16,B+=65535&x,M+=x>>>16,M+=(B+=(I+=(A+=65535&S)>>>16)>>>16)>>>16,t[3]=U=65535&B|M<<16,e[3]=K=65535&A|I<<16,A=65535&(S=V),I=S>>>16,B=65535&(x=C),M=x>>>16,x=t[4],I+=(S=e[4])>>>16,B+=65535&x,M+=x>>>16,M+=(B+=(I+=(A+=65535&S)>>>16)>>>16)>>>16,t[4]=C=65535&B|M<<16,e[4]=V=65535&A|I<<16,A=65535&(S=q),I=S>>>16,B=65535&(x=N),M=x>>>16,x=t[5],I+=(S=e[5])>>>16,B+=65535&x,M+=x>>>16,M+=(B+=(I+=(A+=65535&S)>>>16)>>>16)>>>16,t[5]=N=65535&B|M<<16,e[5]=q=65535&A|I<<16,A=65535&(S=H),I=S>>>16,B=65535&(x=z),M=x>>>16,x=t[6],I+=(S=e[6])>>>16,B+=65535&x,M+=x>>>16,M+=(B+=(I+=(A+=65535&S)>>>16)>>>16)>>>16,t[6]=z=65535&B|M<<16,e[6]=H=65535&A|I<<16,A=65535&(S=$),I=S>>>16,B=65535&(x=D),M=x>>>16,x=t[7],I+=(S=e[7])>>>16,B+=65535&x,M+=x>>>16,M+=(B+=(I+=(A+=65535&S)>>>16)>>>16)>>>16,t[7]=D=65535&B|M<<16,e[7]=$=65535&A|I<<16,Z+=128,n-=128}return n}function Y(t,e,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,Z(i,o,e,r),r%=128,n=0;n<r;n++)s[n]=e[a-r+n];for(s[r]=128,s[(r=256-128*(r<112?1:0))-9]=0,d(s,r-8,a/536870912|0,a<<3),Z(i,o,s,r),n=0;n<8;n++)d(t,8*n,i[n],o[n]);return 0}function J(t,r){var n=e(),i=e(),o=e(),s=e(),a=e(),u=e(),h=e(),l=e(),f=e();N(n,t[1],t[0]),N(f,r[1],r[0]),z(n,n,f),C(i,t[0],t[1]),C(f,r[0],r[1]),z(i,i,f),z(o,t[3],r[3]),z(o,o,c),z(s,t[2],r[2]),C(s,s,s),N(a,i,n),N(u,s,o),C(h,s,o),C(l,i,n),z(t[0],a,u),z(t[1],l,h),z(t[2],h,u),z(t[3],a,l)}function X(t,e,r){var n;for(n=0;n<4;n++)P(t[n],e[n],r)}function Q(t,r){var n=e(),i=e(),o=e();j(o,r[2]),z(n,r[0],o),z(i,r[1],o),T(t,i),t[31]^=O(n)<<7}function tt(t,e,r){var n,i;for(M(t[0],o),M(t[1],s),M(t[2],s),M(t[3],o),i=255;i>=0;--i)X(t,e,n=r[i/8|0]>>(7&i)&1),J(e,t),J(t,t),X(t,e,n)}function et(t,r){var n=[e(),e(),e(),e()];M(n[0],h),M(n[1],l),M(n[2],s),z(n[3],h,l),tt(t,n,r)}function rt(t,n,i){var o,s=new Uint8Array(64),a=[e(),e(),e(),e()];for(i||r(n,32),Y(s,n,32),s[0]&=248,s[31]&=127,s[31]|=64,et(a,s),Q(t,a),o=0;o<32;o++)n[o+32]=t[o];return 0}var nt=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 it(t,e){var r,n,i,o;for(n=63;n>=32;--n){for(r=0,i=n-32,o=n-12;i<o;++i)e[i]+=r-16*e[n]*nt[i-(n-32)],r=Math.floor((e[i]+128)/256),e[i]-=256*r;e[i]+=r,e[n]=0}for(r=0,i=0;i<32;i++)e[i]+=r-(e[31]>>4)*nt[i],r=e[i]>>8,e[i]&=255;for(i=0;i<32;i++)e[i]-=r*nt[i];for(n=0;n<32;n++)e[n+1]+=e[n]>>8,t[n]=255&e[n]}function ot(t){var e,r=new Float64Array(64);for(e=0;e<64;e++)r[e]=t[e];for(e=0;e<64;e++)t[e]=0;it(t,r)}function st(t,r,n,i){var o,s,a=new Uint8Array(64),u=new Uint8Array(64),c=new Uint8Array(64),h=new Float64Array(64),l=[e(),e(),e(),e()];Y(a,i,32),a[0]&=248,a[31]&=127,a[31]|=64;var f=n+64;for(o=0;o<n;o++)t[64+o]=r[o];for(o=0;o<32;o++)t[32+o]=a[32+o];for(Y(c,t.subarray(32),n+32),ot(c),et(l,c),Q(t,l),o=32;o<64;o++)t[o]=i[o];for(Y(u,t,n+64),ot(u),o=0;o<64;o++)h[o]=0;for(o=0;o<32;o++)h[o]=c[o];for(o=0;o<32;o++)for(s=0;s<32;s++)h[o+s]+=u[o]*a[s];return it(t.subarray(32),h),f}function at(t,r,n,i){var a,c=new Uint8Array(32),h=new Uint8Array(64),l=[e(),e(),e(),e()],d=[e(),e(),e(),e()];if(n<64)return-1;if(function(t,r){var n=e(),i=e(),a=e(),c=e(),h=e(),l=e(),d=e();return M(t[2],s),U(t[1],r),D(a,t[1]),z(c,a,u),N(a,a,t[2]),C(c,t[2],c),D(h,c),D(l,h),z(d,l,h),z(n,d,a),z(n,n,c),W(n,n),z(n,n,a),z(n,n,c),z(n,n,c),z(t[0],n,c),D(i,t[0]),z(i,i,c),L(i,a)&&z(t[0],t[0],f),D(i,t[0]),z(i,i,c),L(i,a)?-1:(O(t[0])===r[31]>>7&&N(t[0],o,t[0]),z(t[3],t[0],t[1]),0)}(d,i))return-1;for(a=0;a<n;a++)t[a]=r[a];for(a=0;a<32;a++)t[a+32]=i[a];if(Y(h,t,n),ot(h),tt(l,d,h),et(d,r.subarray(32)),J(l,d),Q(c,l),n-=64,g(r,0,c,0)){for(a=0;a<n;a++)t[a]=0;return-1}for(a=0;a<n;a++)t[a]=r[a+64];return n}var ut=16,ct=64,ht=32,lt=64;function ft(t,e){if(32!==t.length)throw new Error("bad key size");if(24!==e.length)throw new Error("bad nonce size")}function dt(){for(var t=0;t<arguments.length;t++)if(!(arguments[t]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function pt(t){for(var e=0;e<t.length;e++)t[e]=0}t.lowlevel={crypto_core_hsalsa20:w,crypto_stream_xor:E,crypto_stream:k,crypto_stream_salsa20_xor:v,crypto_stream_salsa20:_,crypto_onetimeauth:S,crypto_onetimeauth_verify:A,crypto_verify_16:y,crypto_verify_32:g,crypto_secretbox:I,crypto_secretbox_open:B,crypto_scalarmult:F,crypto_scalarmult_base:K,crypto_box_beforenm:q,crypto_box_afternm:H,crypto_box:function(t,e,r,n,i,o){var s=new Uint8Array(32);return q(s,i,o),H(t,e,r,n,s)},crypto_box_open:function(t,e,r,n,i,o){var s=new Uint8Array(32);return q(s,i,o),$(t,e,r,n,s)},crypto_box_keypair:V,crypto_hash:Y,crypto_sign:st,crypto_sign_keypair:rt,crypto_sign_open:at,crypto_secretbox_KEYBYTES:32,crypto_secretbox_NONCEBYTES:24,crypto_secretbox_ZEROBYTES:32,crypto_secretbox_BOXZEROBYTES:ut,crypto_scalarmult_BYTES:32,crypto_scalarmult_SCALARBYTES:32,crypto_box_PUBLICKEYBYTES:32,crypto_box_SECRETKEYBYTES:32,crypto_box_BEFORENMBYTES:32,crypto_box_NONCEBYTES:24,crypto_box_ZEROBYTES:32,crypto_box_BOXZEROBYTES:16,crypto_sign_BYTES:ct,crypto_sign_PUBLICKEYBYTES:ht,crypto_sign_SECRETKEYBYTES:lt,crypto_sign_SEEDBYTES:32,crypto_hash_BYTES:64,gf:e,D:u,L:nt,pack25519:T,unpack25519:U,M:z,A:C,S:D,Z:N,pow2523:W,add:J,set25519:M,modL:it,scalarmult:tt,scalarbase:et},t.randomBytes=function(t){var e=new Uint8Array(t);return r(e,t),e},t.secretbox=function(t,e,r){dt(t,e,r),ft(r,e);for(var n=new Uint8Array(32+t.length),i=new Uint8Array(n.length),o=0;o<t.length;o++)n[o+32]=t[o];return I(i,n,n.length,e,r),i.subarray(ut)},t.secretbox.open=function(t,e,r){dt(t,e,r),ft(r,e);for(var n=new Uint8Array(ut+t.length),i=new Uint8Array(n.length),o=0;o<t.length;o++)n[o+ut]=t[o];return n.length<32||0!==B(i,n,n.length,e,r)?null:i.subarray(32)},t.secretbox.keyLength=32,t.secretbox.nonceLength=24,t.secretbox.overheadLength=ut,t.scalarMult=function(t,e){if(dt(t,e),32!==t.length)throw new Error("bad n size");if(32!==e.length)throw new Error("bad p size");var r=new Uint8Array(32);return F(r,t,e),r},t.scalarMult.base=function(t){if(dt(t),32!==t.length)throw new Error("bad n size");var e=new Uint8Array(32);return K(e,t),e},t.scalarMult.scalarLength=32,t.scalarMult.groupElementLength=32,t.box=function(e,r,n,i){var o=t.box.before(n,i);return t.secretbox(e,r,o)},t.box.before=function(t,e){dt(t,e),function(t,e){if(32!==t.length)throw new Error("bad public key size");if(32!==e.length)throw new Error("bad secret key size")}(t,e);var r=new Uint8Array(32);return q(r,t,e),r},t.box.after=t.secretbox,t.box.open=function(e,r,n,i){var o=t.box.before(n,i);return t.secretbox.open(e,r,o)},t.box.open.after=t.secretbox.open,t.box.keyPair=function(){var t=new Uint8Array(32),e=new Uint8Array(32);return V(t,e),{publicKey:t,secretKey:e}},t.box.keyPair.fromSecretKey=function(t){if(dt(t),32!==t.length)throw new Error("bad secret key size");var e=new Uint8Array(32);return K(e,t),{publicKey:e,secretKey:new Uint8Array(t)}},t.box.publicKeyLength=32,t.box.secretKeyLength=32,t.box.sharedKeyLength=32,t.box.nonceLength=24,t.box.overheadLength=t.secretbox.overheadLength,t.sign=function(t,e){if(dt(t,e),e.length!==lt)throw new Error("bad secret key size");var r=new Uint8Array(ct+t.length);return st(r,t,t.length,e),r},t.sign.open=function(t,e){if(dt(t,e),e.length!==ht)throw new Error("bad public key size");var r=new Uint8Array(t.length),n=at(r,t,t.length,e);if(n<0)return null;for(var i=new Uint8Array(n),o=0;o<i.length;o++)i[o]=r[o];return i},t.sign.detached=function(e,r){for(var n=t.sign(e,r),i=new Uint8Array(ct),o=0;o<i.length;o++)i[o]=n[o];return i},t.sign.detached.verify=function(t,e,r){if(dt(t,e,r),e.length!==ct)throw new Error("bad signature size");if(r.length!==ht)throw new Error("bad public key size");var n,i=new Uint8Array(ct+t.length),o=new Uint8Array(ct+t.length);for(n=0;n<ct;n++)i[n]=e[n];for(n=0;n<t.length;n++)i[n+ct]=t[n];return at(o,i,i.length,r)>=0},t.sign.keyPair=function(){var t=new Uint8Array(ht),e=new Uint8Array(lt);return rt(t,e),{publicKey:t,secretKey:e}},t.sign.keyPair.fromSecretKey=function(t){if(dt(t),t.length!==lt)throw new Error("bad secret key size");for(var e=new Uint8Array(ht),r=0;r<e.length;r++)e[r]=t[32+r];return{publicKey:e,secretKey:new Uint8Array(t)}},t.sign.keyPair.fromSeed=function(t){if(dt(t),32!==t.length)throw new Error("bad seed size");for(var e=new Uint8Array(ht),r=new Uint8Array(lt),n=0;n<32;n++)r[n]=t[n];return rt(e,r,!0),{publicKey:e,secretKey:r}},t.sign.publicKeyLength=ht,t.sign.secretKeyLength=lt,t.sign.seedLength=32,t.sign.signatureLength=ct,t.hash=function(t){dt(t);var e=new Uint8Array(64);return Y(e,t,t.length),e},t.hash.hashLength=64,t.verify=function(t,e){return dt(t,e),0!==t.length&&0!==e.length&&t.length===e.length&&0===p(t,0,e,0,t.length)},t.setPRNG=function(t){r=t},function(){var e="undefined"!=typeof self?self.crypto||self.msCrypto:null;e&&e.getRandomValues?t.setPRNG((function(t,r){var n,i=new Uint8Array(r);for(n=0;n<r;n+=65536)e.getRandomValues(i.subarray(n,n+Math.min(r-n,65536)));for(n=0;n<r;n++)t[n]=i[n];pt(i)})):void 0!==lR&&(e=ee)&&e.randomBytes&&t.setPRNG((function(t,r){var n,i=e.randomBytes(r);for(n=0;n<r;n++)t[n]=i[n];pt(i)}))}()}(fR.exports?fR.exports:self.nacl=self.nacl||{});var dR=fR.exports;const pR=(t,e,r)=>dR.sign.detached.verify(t,e,r.toBytes()),yR=(t,e)=>{const{pubkey:r}=xM(e+"."+t,exports.RecordVersion.V1);return r};async function gR(t,e,r,n){const i=yR(e,r);let{registry:o}=await oh.retrieve(t,i);if(!o.data)throw new Dc(exports.ErrorType.NoRecordData);if(n)return wR(o,r,i);const s=SB.get(r);return o.data=o.data.slice(0,s),o}const mR=async(t,e)=>await gR(t,e,exports.Record.SOL),wR=(t,e,r)=>{const i=null==t?void 0:t.data;if(!i)return;if(0===i.compare(n.Buffer.alloc(i.length)))return;const o=SB.get(e),s=(t=>{const e=Array.from(t);return e.length-1-e.reverse().findIndex((t=>0!==t))+1})(i);if(!o)return i.slice(0,s).toString("utf-8");if(e===exports.Record.SOL){const e=new TextEncoder,o=n.Buffer.concat([i.slice(0,32),r.toBuffer()]),s=e.encode(o.toString("hex"));if(pR(s,i.slice(32,96),t.owner))return Uv.encode(i.slice(0,32))}if(o&&s!==o){const t=i.slice(0,s).toString("utf-8");if(e===exports.Record.Injective){const e=KM(t);if("inj"===e.prefix&&20===e.data.length)return t}else if(e===exports.Record.BSC||e===exports.Record.ETH){const e=t.slice(0,2),r=t.slice(2);if("0x"===e&&20===n.Buffer.from(r,"hex").length)return t}else if((e===exports.Record.A||e===exports.Record.AAAA)&&eR.isValid(t))return t;throw new Dc(exports.ErrorType.InvalidRecordData)}if(e===exports.Record.ETH||e===exports.Record.BSC)return"0x"+i.slice(0,o).toString("hex");if(e===exports.Record.Injective)return VM("inj",i.slice(0,o),"bech32");if(e===exports.Record.A||e===exports.Record.AAAA)return eR.fromByteArray([...i.slice(0,o)]).toString();if(e===exports.Record.Background)return new Wo(i.slice(0,o)).toString();throw new Dc(exports.ErrorType.InvalidRecordData)},bR=(t,e)=>{if(!SB.get(e))return e!==exports.Record.CNAME&&e!==exports.Record.TXT||(t=hR(t)),n.Buffer.from(t,"utf-8");if(e===exports.Record.SOL)throw new Dc(exports.ErrorType.UnsupportedRecord,"Use `serializeSolRecord` for SOL record");if(e===exports.Record.ETH||e===exports.Record.BSC)return IM("0x"===t.slice(0,2),exports.ErrorType.InvalidEvmAddress),n.Buffer.from(t.slice(2),"hex");if(e===exports.Record.Injective){const e=KM(t);return IM("inj"===e.prefix,exports.ErrorType.InvalidInjectiveAddress),IM(20===e.data.length,exports.ErrorType.InvalidInjectiveAddress),n.Buffer.from(e.data)}if(e===exports.Record.A){const e=eR.parse(t).toByteArray();return IM(4===e.length,exports.ErrorType.InvalidARecord),n.Buffer.from(e)}if(e===exports.Record.AAAA){const e=eR.parse(t).toByteArray();return IM(16===e.length,exports.ErrorType.InvalidAAAARecord),n.Buffer.from(e)}if(e===exports.Record.Background)return new Wo(t).toBuffer();throw new Dc(exports.ErrorType.InvalidRecordInput)},vR=(t,e,r,i)=>{const o=n.Buffer.concat([t.toBuffer(),e.toBuffer()]),s=(new TextEncoder).encode(o.toString("hex")),a=pR(s,i,r);return IM(a,exports.ErrorType.InvalidSignature),n.Buffer.concat([t.toBuffer(),i])},_R=async(t,e)=>{const{pubkey:r}=xM(e),{registry:n,nftOwner:i}=await oh.retrieve(t,r);if(i)return i;try{const r=await ER(t,n.owner,e);if(void 0!==r)return r;return await kR(t,n.owner,e)}catch(t){if(t instanceof Error&&"FetchError"===t.name)throw t}return n.owner},kR=async(t,e,r)=>{const i=yR(r,exports.Record.SOL),o=await mR(t,r);if(!(null==o?void 0:o.data))throw new Dc(exports.ErrorType.NoRecordData);const s=new TextEncoder,a=n.Buffer.concat([o.data.slice(0,32),i.toBuffer()]),u=s.encode(a.toString("hex"));if(!pR(u,o.data.slice(32),e))throw new Dc(exports.ErrorType.InvalidSignature);return new Wo(o.data.slice(0,32))},ER=async(t,e,r)=>{try{const n=MR(r,exports.Record.SOL),i=await EB.retrieve(t,n),o=i.getStalenessId(),s=i.getRoAId(),a=i.getContent();if(0===o.compare(e.toBuffer())&&i.header.stalenessValidation===vB.Solana&&0===s.compare(a)&&i.header.rightOfAssociationValidation===vB.Solana)return new Wo(a)}catch(t){if(t instanceof Error&&"FetchError"===t.name)throw t}},xR=new Map([[exports.Record.Backpack,new Wo("ExXjtfdQe8JacoqP9Z535WzQKjF4CzW1TTRKRgpxvya3")],[exports.Record.Url,new Wo("ExXjtfdQe8JacoqP9Z535WzQKjF4CzW1TTRKRgpxvya3")]]),SR=new Set([exports.Record.ETH,exports.Record.Injective,exports.Record.BSC]),AR=new Set([exports.Record.IPFS,exports.Record.ARWV,exports.Record.LTC,exports.Record.DOGE,exports.Record.Email,exports.Record.Url,exports.Record.Discord,exports.Record.Github,exports.Record.Reddit,exports.Record.Twitter,exports.Record.Telegram,exports.Record.Pic,exports.Record.SHDW,exports.Record.POINT,exports.Record.Backpack,exports.Record.TXT,exports.Record.CNAME,exports.Record.BTC]),IR=new Set([exports.Record.ETH,exports.Record.Injective,exports.Record.SOL]),BR=(t,e)=>{if(AR.has(e))return e!==exports.Record.CNAME&&e!==exports.Record.TXT||(t=hR(t)),Buffer.from(t,"utf-8");if(e===exports.Record.SOL)return new Wo(t).toBuffer();if(e===exports.Record.ETH||e===exports.Record.BSC)return IM("0x"===t.slice(0,2),exports.ErrorType.InvalidEvmAddress),Buffer.from(t.slice(2),"hex");if(e===exports.Record.Injective){const e=KM(t);return IM("inj"===e.prefix,exports.ErrorType.InvalidInjectiveAddress),IM(20===e.data.length,exports.ErrorType.InvalidInjectiveAddress),Buffer.from(e.data)}if(e===exports.Record.A){const e=eR.parse(t).toByteArray();return IM(4===e.length,exports.ErrorType.InvalidARecord),Buffer.from(e)}if(e===exports.Record.AAAA){const e=eR.parse(t).toByteArray();return IM(16===e.length,exports.ErrorType.InvalidAAAARecord),Buffer.from(e)}throw new Dc(exports.ErrorType.InvalidARecord)},MR=(t,e)=>{const{pubkey:r}=xM(t),n=bM("".concat(e));return vM(n,bB,r)};async function RR(t,e,r,n,i,o,s,a){const u=await Ff(e),c=await Kf(u,s,a),h=o||await t.getMinimumBalanceForRentExemption(r);let l;if(a){const{registry:e}=await Wf(t,a);l=e.owner}return Fc(Ef,Ls.programId,c,i,n,u,new Wc(h),new jc(r),s,a,l)}async function PR(t,e,r,n,i){const o=await Ff(e),s=await Kf(o,n,i);let a;a=n||(await oh.retrieve(t,s)).registry.owner;return qc(Ef,s,r,a)}const TR=async(t,e,r,n,i)=>{let[o]=await Wo.findProgramAddress([Af.toBuffer()],Af),s=await Ff(t.toBase58()),a=await Kf(s,o,n);return[[],[new $c({name:e}).getInstruction(Af,Ef,Sf,a,Ls.programId,o,r,ms,n,i)]]},LR=async(t,e,r,n,i,o)=>{IM(r!==exports.Record.SOL,exports.ErrorType.UnsupportedRecord);const{pubkey:s,hashed:a,parent:u}=xM(`${r}.${e}`,exports.RecordVersion.V1),c=bR(n,r).length,h=await t.getMinimumBalanceForRentExemption(c+oh.HEADER_LEN);return Fc(Ef,Ls.programId,s,i,o,a,new Wc(h),new jc(c),void 0,u,i)},OR=async(t,e,r,n,i,o)=>{const{pubkey:s,hashed:a,parent:u}=xM(`${exports.Record.SOL}.${e}`,exports.RecordVersion.V1),c=vR(r,s,n,i).length,h=await t.getMinimumBalanceForRentExemption(c+oh.HEADER_LEN);return[Fc(Ef,Ls.programId,s,n,o,a,new Wc(h),new jc(c),void 0,u,n)]};class UR{constructor(t){this.twitterRegistryKey=t.twitterRegistryKey,this.twitterHandle=t.twitterHandle}static async retrieve(t,e){let r=await t.getAccountInfo(e,"processed");if(!r)throw new Dc(exports.ErrorType.InvalidReverseTwitter);return Le(this.schema,UR,r.data.slice(oh.HEADER_LEN))}}async function CR(t,e,r,i,o){const s=await Ff(i.toString()),a=await Kf(s,Rf,Pf);let u=He(UR.schema,new UR({twitterRegistryKey:r.toBytes(),twitterHandle:e}));return[Fc(Ef,Ls.programId,a,i,o,s,new Wc(await t.getMinimumBalanceForRentExemption(u.length+oh.HEADER_LEN)),new jc(u.length),Rf,Pf,Rf),Kc(Ef,a,new jc(0),n.Buffer.from(u),Rf)]}UR.schema=new Map([[UR,{kind:"struct",fields:[["twitterRegistryKey",[32]],["twitterHandle","string"]]}]]);const NR=new Wo("85iDfUvr3HJyLM2zcq5BXSiDvUWfw6cSE1FfNBo8Ap29");class zR{constructor(t){this.tag=t.tag,this.nameAccount=new Wo(t.nameAccount)}static deserialize(t){return Ze(this.schema,zR,t)}static async retrieve(t,e){const r=await t.getAccountInfo(e);if(!r||!r.data)throw new Dc(exports.ErrorType.FavouriteDomainNotFound);return this.deserialize(r.data)}static async getKey(t,e){return await Wo.findProgramAddress([n.Buffer.from("favourite_domain"),e.toBuffer()],t)}static getKeySync(t,e){return Wo.findProgramAddressSync([n.Buffer.from("favourite_domain"),e.toBuffer()],t)}}zR.schema=new Map([[zR,{kind:"struct",fields:[["tag","u8"],["nameAccount",[32]]]}]]);var DR;exports.CustomBg=void 0,(DR=exports.CustomBg||(exports.CustomBg={})).DegenPoet1="DegenPoet#1",DR.Rgb0x001="rgb0x00#1";const jR=new Wo("ART5dr4bDic2sQVZoFheEmUxwQq5VGSx9he7JxHcXNQD"),WR=new Wo("CSWvuDHXExVGEMR9kP8xYAHuNjXogeRck9Cnr312CC9g");exports.BONFIDA_FIDA_BNB=Bf,exports.BONFIDA_USDC_BNB=Tf,exports.CUSTOM_BG_TLD=zf,exports.ETH_ROA_RECORDS=SR,exports.FavouriteDomain=zR,exports.GUARDIANS=xR,exports.HASH_PREFIX=xf,exports.METAPLEX_ID=jf,exports.NAME_OFFERS_ID=NR,exports.NAME_PROGRAM_ID=Ef,exports.NameRegistryState=oh,exports.Numberu32=jc,exports.Numberu64=Wc,exports.PYTH_FIDA_PRICE_ACC=If,exports.PYTH_MAPPING_ACC=Cf,exports.RECORD_V1_SIZE=SB,exports.REFERRERS=Of,exports.REGISTER_PROGRAM_ID=Af,exports.REVERSE_LOOKUP_CLASS=Mf,exports.ROOT_DOMAIN_ACCOUNT=Sf,exports.ReverseTwitterRegistryState=UR,exports.SELF_SIGNED=IR,exports.SNSError=Dc,exports.SOL_RECORD_SIG_LEN=96,exports.TOKENS_SYM_MINT=Uf,exports.TWITTER_ROOT_PARENT_REGISTRY_KEY=Pf,exports.TWITTER_VERIFICATION_AUTHORITY=Rf,exports.USDC_MINT=Lf,exports.UTF8_ENCODED=AR,exports.VAULT_OWNER=Nf,exports.WOLVES_COLLECTION_METADATA=Df,exports.burnDomain=(t,e,r)=>{const{pubkey:n}=xM(t),[i]=Wo.findProgramAddressSync([n.toBuffer()],Af),[o]=Wo.findProgramAddressSync([n.toBuffer(),Uint8Array.from([1,1])],Af);return(new Yc).getInstruction(Af,Ef,Ls.programId,n,AM(t),o,i,Mf,e,r)},exports.burnInstruction=Yc,exports.changeTwitterRegistryData=async function(t,e,r,n){const i=await Ff(t),o=await Kf(i,void 0,Pf);return[Kc(Ef,o,new jc(r),n,e)]},exports.changeVerifiedPubkey=async function(t,e,r,n,i){const o=await Ff(e),s=await Kf(o,void 0,Pf);let a=[Vc(Ef,s,n,r,void 0)];const u=await Ff(r.toString());return await Kf(u,Rf,void 0),a.push(await PR(t,r.toString(),i,Rf,Pf)),a=a.concat(await CR(t,e,s,n,i)),a},exports.check=IM,exports.checkSolRecord=pR,exports.createInstruction=Fc,exports.createInstructionV3=Gc,exports.createNameRegistry=RR,exports.createRecordInstruction=LR,exports.createRecordV2Instruction=(t,e,r,n,i)=>{let{pubkey:o,parent:s,isSub:a}=xM(`${e}.${t}`,exports.RecordVersion.V2);if(a&&(s=xM(t).pubkey),!s)throw new Error("Invalid parent");const u=((t,e,r,n,i,o,s,a)=>new fB({record:o,content:Array.from(s)}).getInstruction(a,sI.programId,i,t,e,r,n,bB))(i,o,s,n,Ef,"".concat(e),BR(r,e),wB);return u},exports.createReverseInstruction=$c,exports.createReverseName=TR,exports.createReverseTwitterRegistry=CR,exports.createSolRecordInstruction=OR,exports.createSubdomain=async(t,e,r,n=2e3)=>{const i=[],o=e.split(".")[0];if(!o)throw new Dc(exports.ErrorType.InvalidSubdomain);const{parent:s,pubkey:a}=xM(e),u=await t.getMinimumBalanceForRentExemption(n+oh.HEADER_LEN),c=await RR(t,"\0".concat(o),n,r,r,u,void 0,s);i.push(c);const h=AM(e,!0),l=await t.getAccountInfo(h);if(!(null==l?void 0:l.data)){const[,t]=await TR(a,"\0".concat(o),r,s,r);i.push(...t)}return[[],i]},exports.createV2Instruction=Hc,exports.createVerifiedTwitterRegistry=async function(t,e,r,n,i){const o=await Ff(e),s=await Kf(o,void 0,Pf),a=await t.getMinimumBalanceForRentExemption(n+oh.HEADER_LEN);let u=[Fc(Ef,Ls.programId,s,r,i,o,new Wc(a),new jc(n),void 0,Pf,Rf)];return u=u.concat(await CR(t,e,s,r,i)),u},exports.createWithNftInstruction=Zc,exports.deleteInstruction=qc,exports.deleteNameRegistry=PR,exports.deleteRecordV2=(t,e,r,n)=>{const{pubkey:i,parent:o}=xM(`${e}.${t}`,exports.RecordVersion.V2);if(!o)throw new Error("Invalid parent");const s=((t,e,r,n,i,o)=>(new gB).getInstruction(o,sI.programId,i,t,n,e,r,bB))(n,o,r,i,Ef,wB);return s},exports.deleteTwitterRegistry=async function(t,e){const r=await Ff(t),n=await Kf(r,void 0,Pf),i=await Ff(e.toString()),o=await Kf(i,Rf,Pf);return[qc(Ef,n,e,e),qc(Ef,o,e,e)]},exports.deserializeRecord=wR,exports.deserializeRecordV2Content=(t,e)=>{if(AR.has(e)){const r=t.toString("utf-8");return e===exports.Record.CNAME||e===exports.Record.TXT?function(t){const e=[],r=t.length;let n=0,i=128,o=72,s=t.lastIndexOf("-");s<0&&(s=0);for(let r=0;r<s;++r)t.charCodeAt(r)>=128&&aR("not-basic"),e.push(t.charCodeAt(r));for(let u=s>0?s+1:0;u<r;){const s=n;for(let e=1,i=nR;;i+=nR){u>=r&&aR("invalid-input");const s=(a=t.charCodeAt(u++))>=48&&a<58?a-48+26:a>=65&&a<91?a-65:a>=97&&a<123?a-97:nR;s>=nR&&aR("invalid-input"),s>oR((rR-n)/e)&&aR("overflow"),n+=s*e;const c=i<=o?1:i>=o+26?26:i-o;if(s<c)break;const h=nR-c;e>oR(rR/h)&&aR("overflow"),e*=h}const c=e.length+1;o=cR(n-s,c,0==s),oR(n/c)>rR-i&&aR("overflow"),i+=oR(n/c),n%=c,e.splice(n++,0,i)}var a;return String.fromCodePoint(...e)}(r):r}if(e===exports.Record.SOL)return new Wo(t).toBase58();if(e===exports.Record.ETH||e===exports.Record.BSC)return"0x"+t.toString("hex");if(e===exports.Record.Injective)return VM("inj",t,"bech32");if(e===exports.Record.A||e===exports.Record.AAAA)return eR.fromByteArray([...t]).toString();throw new Dc(exports.ErrorType.InvalidARecord)},exports.ethValidateRecordV2Content=(t,e,r,n,i,o)=>{const{pubkey:s,parent:a}=xM(`${e}.${t}`,exports.RecordVersion.V2);if(!a)throw new Error("Invalid parent");const u=((t,e,r,n,i,o,s,a,u)=>new dB({validation:o,signature:Array.from(s),expectedPubkey:Array.from(a)}).getInstruction(u,sI.programId,i,t,e,r,n,bB))(n,s,a,r,Ef,vB.Ethereum,i,o,wB);return u},exports.findSubdomains=async(t,e)=>{const r=[{memcmp:{offset:0,bytes:e.toBase58()}},{memcmp:{offset:64,bytes:Mf.toBase58()}}],n=await t.getProgramAccounts(Ef,{filters:r}),i=await _M(t,e),o=n.map((t=>{var e;return null===(e=t.account.data.slice(97).toString("utf-8"))||void 0===e?void 0:e.split("\0").join("")})),s=o.map((t=>xM(t+"."+i).pubkey)),a=await t.getMultipleAccountsInfo(s);return o.filter(((t,e)=>!!a[e]))},exports.getAllDomains=SM,exports.getAllRegisteredDomains=async t=>{const e=[{memcmp:{offset:0,bytes:Sf.toBase58()}}];return await t.getProgramAccounts(Ef,{dataSlice:{offset:32,length:32},filters:e})},exports.getArtistPubkey=t=>{switch(t){case exports.CustomBg.DegenPoet1:return jR;case exports.CustomBg.Rgb0x001:return WR;default:throw new Dc(exports.ErrorType.InvalidCustomBg)}},exports.getArweaveRecord=async(t,e)=>await gR(t,e,exports.Record.ARWV,!0),exports.getBackgroundRecord=async(t,e)=>await gR(t,e,exports.Record.Background,!0),exports.getBackpackRecord=async(t,e)=>await gR(t,e,exports.Record.Backpack,!0),exports.getBscRecord=async(t,e)=>await gR(t,e,exports.Record.BSC,!0),exports.getBtcRecord=async(t,e)=>await gR(t,e,exports.Record.BTC,!0),exports.getCustomBgKeys=(t,e)=>{const r=bM(e),n=bM(t),i=vM(n,void 0,zf);return{domainKey:i,bgKey:vM(r,void 0,i)}},exports.getDiscordRecord=async(t,e)=>await gR(t,e,exports.Record.Discord,!0),exports.getDogeRecord=async(t,e)=>await gR(t,e,exports.Record.DOGE,!0),exports.getDomainKey=qf,exports.getDomainKeySync=xM,exports.getDomainKeysWithReverses=async function(t,e){const r=await SM(t,e),n=await kM(t,r);return r.map(((t,e)=>({pubKey:t,domain:n[e]})))},exports.getDomainPriceFromName=t=>{switch(wM(t).length){case 1:return 750;case 2:return 700;case 3:return 640;case 4:return 160;default:return 20}},exports.getEmailRecord=async(t,e)=>await gR(t,e,exports.Record.Email,!0),exports.getEthRecord=async(t,e)=>await gR(t,e,exports.Record.ETH,!0),exports.getFavoriteDomain=async(t,e)=>{const[r]=zR.getKeySync(NR,new Wo(e)),n=await zR.retrieve(t,r),i=await _M(t,n.nameAccount);return{domain:n.nameAccount,reverse:i}},exports.getGithubRecord=async(t,e)=>await gR(t,e,exports.Record.Github,!0),exports.getHandleAndRegistryKey=async function(t,e){const r=await Ff(e.toString()),n=await Kf(r,Rf,Pf);let i=await UR.retrieve(t,n);return[i.twitterHandle,new Wo(i.twitterRegistryKey)]},exports.getHashedName=Ff,exports.getHashedNameSync=bM,exports.getInjectiveRecord=async(t,e)=>await gR(t,e,exports.Record.Injective,!0),exports.getIpfsRecord=async(t,e)=>await gR(t,e,exports.Record.IPFS,!0),exports.getLtcRecord=async(t,e)=>await gR(t,e,exports.Record.LTC,!0),exports.getNameAccountKey=Kf,exports.getNameAccountKeySync=vM,exports.getNameOwner=Wf,exports.getPicRecord=async(t,e)=>await gR(t,e,exports.Record.Pic,!0),exports.getPointRecord=async(t,e)=>await gR(t,e,exports.Record.POINT,!0),exports.getRecord=gR,exports.getRecordKeySync=yR,exports.getRecordV2Key=MR,exports.getRecords=async function(t,e,r,n){const i=r.map((t=>yR(e,t))),o=await oh.retrieveBatch(t,i);return n?o.map(((t,n)=>{if(t)return wR(t,r[n],yR(e,r[n]))})):o},exports.getRedditRecord=async(t,e)=>await gR(t,e,exports.Record.Reddit,!0),exports.getReverseKey=async(t,e)=>{const{pubkey:r,parent:n}=await qf(t),i=await Ff(r.toBase58());return await Kf(i,Mf,e?n:void 0)},exports.getReverseKeySync=AM,exports.getShdwRecord=async(t,e)=>await gR(t,e,exports.Record.SHDW,!0),exports.getSolRecord=mR,exports.getTelegramRecord=async(t,e)=>await gR(t,e,exports.Record.Telegram,!0),exports.getTokenizedDomains=async(t,e)=>{const r=await ih(t,e),n=await kM(t,r.map((t=>t.nameAccount)));return n.map(((t,e)=>({key:r[e].nameAccount,mint:r[e].nftMint,reverse:t}))).filter((t=>!!t.reverse))},exports.getTwitterHandleandRegistryKeyViaFilters=async function(t,e){const r=[{memcmp:{offset:0,bytes:Pf.toBase58()}},{memcmp:{offset:32,bytes:e.toBase58()}},{memcmp:{offset:64,bytes:Rf.toBase58()}}],n=await t.getProgramAccounts(Ef,{filters:r});for(const t of n)if(t.account.data.length>oh.HEADER_LEN+32){let e=t.account.data.slice(oh.HEADER_LEN),r=Le(UR.schema,UR,e);return[r.twitterHandle,new Wo(r.twitterRegistryKey)]}throw new Dc(exports.ErrorType.AccountDoesNotExist)},exports.getTwitterRecord=async(t,e)=>await gR(t,e,exports.Record.Twitter,!0),exports.getTwitterRegistry=async function(t,e){const r=await Ff(e),n=await Kf(r,void 0,Pf),{registry:i}=await oh.retrieve(t,n);return i},exports.getTwitterRegistryData=async function(t,e){const r=[{memcmp:{offset:0,bytes:Pf.toBase58()}},{memcmp:{offset:32,bytes:e.toBase58()}},{memcmp:{offset:64,bytes:new Wo(n.Buffer.alloc(32,0)).toBase58()}}],i=await t.getProgramAccounts(Ef,{filters:r});if(i.length>1)throw new Dc(exports.ErrorType.MultipleRegistries);return i[0].account.data.slice(oh.HEADER_LEN)},exports.getTwitterRegistryKey=async function(t){const e=await Ff(t);return await Kf(e,void 0,Pf)},exports.getUrlRecord=async(t,e)=>await gR(t,e,exports.Record.Url,!0),exports.performReverseLookup=async function(t,e){const r=await Ff(e.toBase58()),n=await Kf(r,Mf),{registry:i}=await oh.retrieve(t,n);if(!i.data)throw new Dc(exports.ErrorType.NoAccountData);const o=new ne(i.data.slice(0,4),"le").toNumber();return i.data.slice(4,4+o).toString()},exports.performReverseLookupBatch=async function(t,e){let r=[];for(let t of e){const e=await Ff(t.toBase58()),n=await Kf(e,Mf);r.push(n)}return(await oh.retrieveBatch(t,r)).map((t=>{if(void 0===t||void 0===t.data)return;let e=new ne(t.data.slice(0,4),"le").toNumber();return t.data.slice(4,4+e).toString()}))},exports.reallocInstruction=function(t,e,r,i,o,s){const a=[n.Buffer.from(Int8Array.from([4])),s.toBuffer()],u=n.Buffer.concat(a);return new cs({keys:[{pubkey:e,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:o,isSigner:!0,isWritable:!1}],programId:t,data:u})},exports.registerDomainName=async(t,e,r,n,i,o=Lf,s)=>{if(e.includes(".")||e.trim().toLowerCase()!==e)throw new Dc(exports.ErrorType.InvalidDomain);const[a]=Wo.findProgramAddressSync([Af.toBuffer()],Af),u=bM(e),c=vM(u,void 0,Sf),h=bM(c.toBase58()),l=vM(h,a),[f]=Wo.findProgramAddressSync([c.toBuffer()],Af),d=Of.findIndex((t=>null==s?void 0:s.equals(t)));let p;const y=[];if(-1!==d&&s){p=Cc(o,s,!0);const e=await t.getAccountInfo(p);if(!(null==e?void 0:e.data)){const t=Nc(n,p,s,o);y.push(t)}}const g=new Yv.PythHttpClient(t,Yv.getPythProgramKeyForCluster("mainnet-beta")),m=await g.getData(),w=Uf.get(o.toBase58());if(!w)throw new Dc(exports.ErrorType.SymbolNotFound,`No symbol found for mint ${o.toBase58()}`);const b=m.productPrice.get("Crypto."+w+"/USD"),v=m.productFromSymbol.get("Crypto."+w+"/USD"),_=Cc(o,Nf),k=new Gc({name:e,space:r,referrerIdxOpt:-1!=d?d:null}).getInstruction(Af,Ef,Sf,c,l,Ls.programId,a,n,i,Cf,b.productAccountKey,new Wo(v.price_account),_,yc,ms,f,p);return y.push(k),[[],y]},exports.registerWithNft=(t,e,r,n,i,o,s,a,u)=>{const[c]=Wo.findProgramAddressSync([r.toBuffer()],Af);return new Zc({space:e,name:t}).getInstruction(Af,Ef,Sf,r,n,Ls.programId,Mf,i,o,s,a,u,Df,yc,ms,c,jf)},exports.resolve=_R,exports.retrieveNftOwner=eh,exports.retrieveNfts=async t=>{const e=await t.getProgramAccounts(Jc,{filters:[{memcmp:{offset:0,bytes:"3"}}]});return e.map((t=>new Wo(t.account.data.slice(66,98))))},exports.retrieveRecords=ih,exports.reverseLookup=_M,exports.reverseLookupBatch=kM,exports.serializeRecord=bR,exports.serializeRecordV2Content=BR,exports.serializeSolRecord=vR,exports.transferInstruction=Vc,exports.transferNameOwnership=async function(t,e,r,n,i,o){const s=await Ff(e),a=await Kf(s,n,i);let u;return u=n||(await oh.retrieve(t,a)).registry.owner,Vc(Ef,a,r,u,n,i,o)},exports.transferSubdomain=async(t,e,r,n,i)=>{const{pubkey:o,isSub:s,parent:a}=xM(e);if(!a||!s)throw new Dc(exports.ErrorType.InvalidSubdomain);if(!i){const{registry:e}=await oh.retrieve(t,o);i=e.owner}let u,c;n&&(u=a,c=(await oh.retrieve(t,a)).registry.owner);return Vc(Ef,o,r,i,void 0,u,c)},exports.updateInstruction=Kc,exports.updateNameRegistryData=async function(t,e,r,n,i,o){const s=await Ff(e),a=await Kf(s,i,o);let u;return u=i||(await oh.retrieve(t,a)).registry.owner,Kc(Ef,a,new jc(r),n,u)},exports.updateRecordInstruction=async(t,e,r,n,i,o)=>{IM(r!==exports.Record.SOL,exports.ErrorType.UnsupportedRecord);const{pubkey:s}=xM(`${r}.${e}`,exports.RecordVersion.V1),a=await t.getAccountInfo(s);IM(!!(null==a?void 0:a.data),exports.ErrorType.AccountDoesNotExist);const u=bR(n,r);if((null==a?void 0:a.data.slice(96).length)!==u.length)return[qc(Ef,s,o,i),await LR(t,e,r,n,i,o)];return[Kc(Ef,s,new jc(0),u,i)]},exports.updateRecordV2Instruction=(t,e,r,n,i)=>{const{pubkey:o,parent:s}=xM(`${e}.${t}`,exports.RecordVersion.V2);if(!s)throw new Error("Invalid parent");const a=((t,e,r,n,i,o,s,a)=>new yB({record:o,content:Array.from(s)}).getInstruction(a,sI.programId,i,t,e,r,n,bB))(i,o,s,n,Ef,"".concat(e),BR(r,e),wB);return a},exports.updateSolRecordInstruction=async(t,e,r,n,i,o)=>{const{pubkey:s}=xM(`${exports.Record.SOL}.${e}`,exports.RecordVersion.V1),a=await t.getAccountInfo(s);if(IM(!!(null==a?void 0:a.data),exports.ErrorType.AccountDoesNotExist),96!==(null==a?void 0:a.data.length))return[qc(Ef,s,o,n),await OR(t,e,r,n,i,o)];const u=vR(r,s,n,i);return[Kc(Ef,s,new jc(0),u,n)]},exports.validateRecordV2Content=(t,e,r,n,i,o)=>{const{pubkey:s,parent:a}=xM(`${r}.${e}`,exports.RecordVersion.V2);if(!a)throw new Error("Invalid parent");const u=((t,e,r,n,i,o,s,a)=>new pB({staleness:s}).getInstruction(a,sI.programId,o,t,e,r,n,bB,i))(i,s,a,n,o,Ef,t,wB);return u},exports.verifyRightOfAssociation=async(t,e,r,n)=>{var i;const o=MR(r,e),s=await EB.retrieve(t,o),a=s.getRoAId(),u=SR.has(e)?vB.Ethereum:vB.Solana;if(!(n=null!=n?n:null===(i=xR.get(e))||void 0===i?void 0:i.toBuffer()))throw new Dc(exports.ErrorType.MissingVerifier);return 0===n.compare(a)&&s.header.rightOfAssociationValidation===u},exports.verifyStaleness=async(t,e,r)=>{const n=MR(r,e),i=await _R(t,r),o=await EB.retrieve(t,n),s=o.getStalenessId();return i.equals(new Wo(s))&&o.header.stalenessValidation===vB.Solana},exports.writRoaRecordV2=(t,e,r,n,i)=>{const{pubkey:o,parent:s}=xM(`${e}.${t}`,exports.RecordVersion.V2);if(!s)throw new Error("Invalid parent");const a=((t,e,r,n,i,o,s)=>new mB({roaId:Array.from(o.toBuffer())}).getInstruction(s,sI.programId,e,t,r,n,i,bB))(n,Ef,o,s,r,i,wB);return a};
|
|
45
45
|
//# sourceMappingURL=index.cjs.map
|