@coinflowlabs/vue 1.4.0 → 1.4.1
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.
|
@@ -3,18 +3,18 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @author Feross Aboukhadijeh <https://feross.org>
|
|
5
5
|
* @license MIT
|
|
6
|
-
*/var vs;function zr(){return vs||(vs=1,function(n){const e=ja(),t=Za(),r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;n.Buffer=a,n.SlowBuffer=H,n.INSPECT_MAX_BYTES=50;const s=2147483647;n.kMaxLength=s,a.TYPED_ARRAY_SUPPORT=i(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&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.");function i(){try{const _=new Uint8Array(1),h={foo:function(){return 42}};return Object.setPrototypeOf(h,Uint8Array.prototype),Object.setPrototypeOf(_,h),_.foo()===42}catch{return!1}}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}});function o(_){if(_>s)throw new RangeError('The value "'+_+'" is invalid for option "size"');const h=new Uint8Array(_);return Object.setPrototypeOf(h,a.prototype),h}function a(_,h,d){if(typeof _=="number"){if(typeof h=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return b(_)}return f(_,h,d)}a.poolSize=8192;function f(_,h,d){if(typeof _=="string")return x(_,h);if(ArrayBuffer.isView(_))return L(_);if(_==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof _);if(Et(_,ArrayBuffer)||_&&Et(_.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Et(_,SharedArrayBuffer)||_&&Et(_.buffer,SharedArrayBuffer)))return O(_,h,d);if(typeof _=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const v=_.valueOf&&_.valueOf();if(v!=null&&v!==_)return a.from(v,h,d);const U=N(_);if(U)return U;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof _[Symbol.toPrimitive]=="function")return a.from(_[Symbol.toPrimitive]("string"),h,d);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof _)}a.from=function(_,h,d){return f(_,h,d)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function g(_){if(typeof _!="number")throw new TypeError('"size" argument must be of type number');if(_<0)throw new RangeError('The value "'+_+'" is invalid for option "size"')}function w(_,h,d){return g(_),_<=0?o(_):h!==void 0?typeof d=="string"?o(_).fill(h,d):o(_).fill(h):o(_)}a.alloc=function(_,h,d){return w(_,h,d)};function b(_){return g(_),o(_<0?0:M(_)|0)}a.allocUnsafe=function(_){return b(_)},a.allocUnsafeSlow=function(_){return b(_)};function x(_,h){if((typeof h!="string"||h==="")&&(h="utf8"),!a.isEncoding(h))throw new TypeError("Unknown encoding: "+h);const d=K(_,h)|0;let v=o(d);const U=v.write(_,h);return U!==d&&(v=v.slice(0,U)),v}function T(_){const h=_.length<0?0:M(_.length)|0,d=o(h);for(let v=0;v<h;v+=1)d[v]=_[v]&255;return d}function L(_){if(Et(_,Uint8Array)){const h=new Uint8Array(_);return O(h.buffer,h.byteOffset,h.byteLength)}return T(_)}function O(_,h,d){if(h<0||_.byteLength<h)throw new RangeError('"offset" is outside of buffer bounds');if(_.byteLength<h+(d||0))throw new RangeError('"length" is outside of buffer bounds');let v;return h===void 0&&d===void 0?v=new Uint8Array(_):d===void 0?v=new Uint8Array(_,h):v=new Uint8Array(_,h,d),Object.setPrototypeOf(v,a.prototype),v}function N(_){if(a.isBuffer(_)){const h=M(_.length)|0,d=o(h);return d.length===0||_.copy(d,0,0,h),d}if(_.length!==void 0)return typeof _.length!="number"||Ce(_.length)?o(0):T(_);if(_.type==="Buffer"&&Array.isArray(_.data))return T(_.data)}function M(_){if(_>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return _|0}function H(_){return+_!=_&&(_=0),a.alloc(+_)}a.isBuffer=function(h){return h!=null&&h._isBuffer===!0&&h!==a.prototype},a.compare=function(h,d){if(Et(h,Uint8Array)&&(h=a.from(h,h.offset,h.byteLength)),Et(d,Uint8Array)&&(d=a.from(d,d.offset,d.byteLength)),!a.isBuffer(h)||!a.isBuffer(d))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(h===d)return 0;let v=h.length,U=d.length;for(let F=0,Y=Math.min(v,U);F<Y;++F)if(h[F]!==d[F]){v=h[F],U=d[F];break}return v<U?-1:U<v?1:0},a.isEncoding=function(h){switch(String(h).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(h,d){if(!Array.isArray(h))throw new TypeError('"list" argument must be an Array of Buffers');if(h.length===0)return a.alloc(0);let v;if(d===void 0)for(d=0,v=0;v<h.length;++v)d+=h[v].length;const U=a.allocUnsafe(d);let F=0;for(v=0;v<h.length;++v){let Y=h[v];if(Et(Y,Uint8Array))F+Y.length>U.length?(a.isBuffer(Y)||(Y=a.from(Y)),Y.copy(U,F)):Uint8Array.prototype.set.call(U,Y,F);else if(a.isBuffer(Y))Y.copy(U,F);else throw new TypeError('"list" argument must be an Array of Buffers');F+=Y.length}return U};function K(_,h){if(a.isBuffer(_))return _.length;if(ArrayBuffer.isView(_)||Et(_,ArrayBuffer))return _.byteLength;if(typeof _!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof _);const d=_.length,v=arguments.length>2&&arguments[2]===!0;if(!v&&d===0)return 0;let U=!1;for(;;)switch(h){case"ascii":case"latin1":case"binary":return d;case"utf8":case"utf-8":return Be(_).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return d*2;case"hex":return d>>>1;case"base64":return Fe(_).length;default:if(U)return v?-1:Be(_).length;h=(""+h).toLowerCase(),U=!0}}a.byteLength=K;function Q(_,h,d){let v=!1;if((h===void 0||h<0)&&(h=0),h>this.length||((d===void 0||d>this.length)&&(d=this.length),d<=0)||(d>>>=0,h>>>=0,d<=h))return"";for(_||(_="utf8");;)switch(_){case"hex":return A(this,h,d);case"utf8":case"utf-8":return c(this,h,d);case"ascii":return I(this,h,d);case"latin1":case"binary":return E(this,h,d);case"base64":return S(this,h,d);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,h,d);default:if(v)throw new TypeError("Unknown encoding: "+_);_=(_+"").toLowerCase(),v=!0}}a.prototype._isBuffer=!0;function q(_,h,d){const v=_[h];_[h]=_[d],_[d]=v}a.prototype.swap16=function(){const h=this.length;if(h%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let d=0;d<h;d+=2)q(this,d,d+1);return this},a.prototype.swap32=function(){const h=this.length;if(h%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let d=0;d<h;d+=4)q(this,d,d+3),q(this,d+1,d+2);return this},a.prototype.swap64=function(){const h=this.length;if(h%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let d=0;d<h;d+=8)q(this,d,d+7),q(this,d+1,d+6),q(this,d+2,d+5),q(this,d+3,d+4);return this},a.prototype.toString=function(){const h=this.length;return h===0?"":arguments.length===0?c(this,0,h):Q.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(h){if(!a.isBuffer(h))throw new TypeError("Argument must be a Buffer");return this===h?!0:a.compare(this,h)===0},a.prototype.inspect=function(){let h="";const d=n.INSPECT_MAX_BYTES;return h=this.toString("hex",0,d).replace(/(.{2})/g,"$1 ").trim(),this.length>d&&(h+=" ... "),"<Buffer "+h+">"},r&&(a.prototype[r]=a.prototype.inspect),a.prototype.compare=function(h,d,v,U,F){if(Et(h,Uint8Array)&&(h=a.from(h,h.offset,h.byteLength)),!a.isBuffer(h))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof h);if(d===void 0&&(d=0),v===void 0&&(v=h?h.length:0),U===void 0&&(U=0),F===void 0&&(F=this.length),d<0||v>h.length||U<0||F>this.length)throw new RangeError("out of range index");if(U>=F&&d>=v)return 0;if(U>=F)return-1;if(d>=v)return 1;if(d>>>=0,v>>>=0,U>>>=0,F>>>=0,this===h)return 0;let Y=F-U,Re=v-d;const _e=Math.min(Y,Re),pe=this.slice(U,F),Ke=h.slice(d,v);for(let fe=0;fe<_e;++fe)if(pe[fe]!==Ke[fe]){Y=pe[fe],Re=Ke[fe];break}return Y<Re?-1:Re<Y?1:0};function D(_,h,d,v,U){if(_.length===0)return-1;if(typeof d=="string"?(v=d,d=0):d>2147483647?d=2147483647:d<-2147483648&&(d=-2147483648),d=+d,Ce(d)&&(d=U?0:_.length-1),d<0&&(d=_.length+d),d>=_.length){if(U)return-1;d=_.length-1}else if(d<0)if(U)d=0;else return-1;if(typeof h=="string"&&(h=a.from(h,v)),a.isBuffer(h))return h.length===0?-1:X(_,h,d,v,U);if(typeof h=="number")return h=h&255,typeof Uint8Array.prototype.indexOf=="function"?U?Uint8Array.prototype.indexOf.call(_,h,d):Uint8Array.prototype.lastIndexOf.call(_,h,d):X(_,[h],d,v,U);throw new TypeError("val must be string, number or Buffer")}function X(_,h,d,v,U){let F=1,Y=_.length,Re=h.length;if(v!==void 0&&(v=String(v).toLowerCase(),v==="ucs2"||v==="ucs-2"||v==="utf16le"||v==="utf-16le")){if(_.length<2||h.length<2)return-1;F=2,Y/=2,Re/=2,d/=2}function _e(Ke,fe){return F===1?Ke[fe]:Ke.readUInt16BE(fe*F)}let pe;if(U){let Ke=-1;for(pe=d;pe<Y;pe++)if(_e(_,pe)===_e(h,Ke===-1?0:pe-Ke)){if(Ke===-1&&(Ke=pe),pe-Ke+1===Re)return Ke*F}else Ke!==-1&&(pe-=pe-Ke),Ke=-1}else for(d+Re>Y&&(d=Y-Re),pe=d;pe>=0;pe--){let Ke=!0;for(let fe=0;fe<Re;fe++)if(_e(_,pe+fe)!==_e(h,fe)){Ke=!1;break}if(Ke)return pe}return-1}a.prototype.includes=function(h,d,v){return this.indexOf(h,d,v)!==-1},a.prototype.indexOf=function(h,d,v){return D(this,h,d,v,!0)},a.prototype.lastIndexOf=function(h,d,v){return D(this,h,d,v,!1)};function Z(_,h,d,v){d=Number(d)||0;const U=_.length-d;v?(v=Number(v),v>U&&(v=U)):v=U;const F=h.length;v>F/2&&(v=F/2);let Y;for(Y=0;Y<v;++Y){const Re=parseInt(h.substr(Y*2,2),16);if(Ce(Re))return Y;_[d+Y]=Re}return Y}function J(_,h,d,v){return Le(Be(h,_.length-d),_,d,v)}function z(_,h,d,v){return Le(He(h),_,d,v)}function V(_,h,d,v){return Le(Fe(h),_,d,v)}function ee(_,h,d,v){return Le(Dn(h,_.length-d),_,d,v)}a.prototype.write=function(h,d,v,U){if(d===void 0)U="utf8",v=this.length,d=0;else if(v===void 0&&typeof d=="string")U=d,v=this.length,d=0;else if(isFinite(d))d=d>>>0,isFinite(v)?(v=v>>>0,U===void 0&&(U="utf8")):(U=v,v=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const F=this.length-d;if((v===void 0||v>F)&&(v=F),h.length>0&&(v<0||d<0)||d>this.length)throw new RangeError("Attempt to write outside buffer bounds");U||(U="utf8");let Y=!1;for(;;)switch(U){case"hex":return Z(this,h,d,v);case"utf8":case"utf-8":return J(this,h,d,v);case"ascii":case"latin1":case"binary":return z(this,h,d,v);case"base64":return V(this,h,d,v);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ee(this,h,d,v);default:if(Y)throw new TypeError("Unknown encoding: "+U);U=(""+U).toLowerCase(),Y=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function S(_,h,d){return h===0&&d===_.length?e.fromByteArray(_):e.fromByteArray(_.slice(h,d))}function c(_,h,d){d=Math.min(_.length,d);const v=[];let U=h;for(;U<d;){const F=_[U];let Y=null,Re=F>239?4:F>223?3:F>191?2:1;if(U+Re<=d){let _e,pe,Ke,fe;switch(Re){case 1:F<128&&(Y=F);break;case 2:_e=_[U+1],(_e&192)===128&&(fe=(F&31)<<6|_e&63,fe>127&&(Y=fe));break;case 3:_e=_[U+1],pe=_[U+2],(_e&192)===128&&(pe&192)===128&&(fe=(F&15)<<12|(_e&63)<<6|pe&63,fe>2047&&(fe<55296||fe>57343)&&(Y=fe));break;case 4:_e=_[U+1],pe=_[U+2],Ke=_[U+3],(_e&192)===128&&(pe&192)===128&&(Ke&192)===128&&(fe=(F&15)<<18|(_e&63)<<12|(pe&63)<<6|Ke&63,fe>65535&&fe<1114112&&(Y=fe))}}Y===null?(Y=65533,Re=1):Y>65535&&(Y-=65536,v.push(Y>>>10&1023|55296),Y=56320|Y&1023),v.push(Y),U+=Re}return m(v)}const p=4096;function m(_){const h=_.length;if(h<=p)return String.fromCharCode.apply(String,_);let d="",v=0;for(;v<h;)d+=String.fromCharCode.apply(String,_.slice(v,v+=p));return d}function I(_,h,d){let v="";d=Math.min(_.length,d);for(let U=h;U<d;++U)v+=String.fromCharCode(_[U]&127);return v}function E(_,h,d){let v="";d=Math.min(_.length,d);for(let U=h;U<d;++U)v+=String.fromCharCode(_[U]);return v}function A(_,h,d){const v=_.length;(!h||h<0)&&(h=0),(!d||d<0||d>v)&&(d=v);let U="";for(let F=h;F<d;++F)U+=De[_[F]];return U}function C(_,h,d){const v=_.slice(h,d);let U="";for(let F=0;F<v.length-1;F+=2)U+=String.fromCharCode(v[F]+v[F+1]*256);return U}a.prototype.slice=function(h,d){const v=this.length;h=~~h,d=d===void 0?v:~~d,h<0?(h+=v,h<0&&(h=0)):h>v&&(h=v),d<0?(d+=v,d<0&&(d=0)):d>v&&(d=v),d<h&&(d=h);const U=this.subarray(h,d);return Object.setPrototypeOf(U,a.prototype),U};function R(_,h,d){if(_%1!==0||_<0)throw new RangeError("offset is not uint");if(_+h>d)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(h,d,v){h=h>>>0,d=d>>>0,v||R(h,d,this.length);let U=this[h],F=1,Y=0;for(;++Y<d&&(F*=256);)U+=this[h+Y]*F;return U},a.prototype.readUintBE=a.prototype.readUIntBE=function(h,d,v){h=h>>>0,d=d>>>0,v||R(h,d,this.length);let U=this[h+--d],F=1;for(;d>0&&(F*=256);)U+=this[h+--d]*F;return U},a.prototype.readUint8=a.prototype.readUInt8=function(h,d){return h=h>>>0,d||R(h,1,this.length),this[h]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(h,d){return h=h>>>0,d||R(h,2,this.length),this[h]|this[h+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(h,d){return h=h>>>0,d||R(h,2,this.length),this[h]<<8|this[h+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(h,d){return h=h>>>0,d||R(h,4,this.length),(this[h]|this[h+1]<<8|this[h+2]<<16)+this[h+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(h,d){return h=h>>>0,d||R(h,4,this.length),this[h]*16777216+(this[h+1]<<16|this[h+2]<<8|this[h+3])},a.prototype.readBigUInt64LE=vt(function(h){h=h>>>0,Ue(h,"offset");const d=this[h],v=this[h+7];(d===void 0||v===void 0)&&Se(h,this.length-8);const U=d+this[++h]*2**8+this[++h]*2**16+this[++h]*2**24,F=this[++h]+this[++h]*2**8+this[++h]*2**16+v*2**24;return BigInt(U)+(BigInt(F)<<BigInt(32))}),a.prototype.readBigUInt64BE=vt(function(h){h=h>>>0,Ue(h,"offset");const d=this[h],v=this[h+7];(d===void 0||v===void 0)&&Se(h,this.length-8);const U=d*2**24+this[++h]*2**16+this[++h]*2**8+this[++h],F=this[++h]*2**24+this[++h]*2**16+this[++h]*2**8+v;return(BigInt(U)<<BigInt(32))+BigInt(F)}),a.prototype.readIntLE=function(h,d,v){h=h>>>0,d=d>>>0,v||R(h,d,this.length);let U=this[h],F=1,Y=0;for(;++Y<d&&(F*=256);)U+=this[h+Y]*F;return F*=128,U>=F&&(U-=Math.pow(2,8*d)),U},a.prototype.readIntBE=function(h,d,v){h=h>>>0,d=d>>>0,v||R(h,d,this.length);let U=d,F=1,Y=this[h+--U];for(;U>0&&(F*=256);)Y+=this[h+--U]*F;return F*=128,Y>=F&&(Y-=Math.pow(2,8*d)),Y},a.prototype.readInt8=function(h,d){return h=h>>>0,d||R(h,1,this.length),this[h]&128?(255-this[h]+1)*-1:this[h]},a.prototype.readInt16LE=function(h,d){h=h>>>0,d||R(h,2,this.length);const v=this[h]|this[h+1]<<8;return v&32768?v|4294901760:v},a.prototype.readInt16BE=function(h,d){h=h>>>0,d||R(h,2,this.length);const v=this[h+1]|this[h]<<8;return v&32768?v|4294901760:v},a.prototype.readInt32LE=function(h,d){return h=h>>>0,d||R(h,4,this.length),this[h]|this[h+1]<<8|this[h+2]<<16|this[h+3]<<24},a.prototype.readInt32BE=function(h,d){return h=h>>>0,d||R(h,4,this.length),this[h]<<24|this[h+1]<<16|this[h+2]<<8|this[h+3]},a.prototype.readBigInt64LE=vt(function(h){h=h>>>0,Ue(h,"offset");const d=this[h],v=this[h+7];(d===void 0||v===void 0)&&Se(h,this.length-8);const U=this[h+4]+this[h+5]*2**8+this[h+6]*2**16+(v<<24);return(BigInt(U)<<BigInt(32))+BigInt(d+this[++h]*2**8+this[++h]*2**16+this[++h]*2**24)}),a.prototype.readBigInt64BE=vt(function(h){h=h>>>0,Ue(h,"offset");const d=this[h],v=this[h+7];(d===void 0||v===void 0)&&Se(h,this.length-8);const U=(d<<24)+this[++h]*2**16+this[++h]*2**8+this[++h];return(BigInt(U)<<BigInt(32))+BigInt(this[++h]*2**24+this[++h]*2**16+this[++h]*2**8+v)}),a.prototype.readFloatLE=function(h,d){return h=h>>>0,d||R(h,4,this.length),t.read(this,h,!0,23,4)},a.prototype.readFloatBE=function(h,d){return h=h>>>0,d||R(h,4,this.length),t.read(this,h,!1,23,4)},a.prototype.readDoubleLE=function(h,d){return h=h>>>0,d||R(h,8,this.length),t.read(this,h,!0,52,8)},a.prototype.readDoubleBE=function(h,d){return h=h>>>0,d||R(h,8,this.length),t.read(this,h,!1,52,8)};function u(_,h,d,v,U,F){if(!a.isBuffer(_))throw new TypeError('"buffer" argument must be a Buffer instance');if(h>U||h<F)throw new RangeError('"value" argument is out of bounds');if(d+v>_.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(h,d,v,U){if(h=+h,d=d>>>0,v=v>>>0,!U){const Re=Math.pow(2,8*v)-1;u(this,h,d,v,Re,0)}let F=1,Y=0;for(this[d]=h&255;++Y<v&&(F*=256);)this[d+Y]=h/F&255;return d+v},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(h,d,v,U){if(h=+h,d=d>>>0,v=v>>>0,!U){const Re=Math.pow(2,8*v)-1;u(this,h,d,v,Re,0)}let F=v-1,Y=1;for(this[d+F]=h&255;--F>=0&&(Y*=256);)this[d+F]=h/Y&255;return d+v},a.prototype.writeUint8=a.prototype.writeUInt8=function(h,d,v){return h=+h,d=d>>>0,v||u(this,h,d,1,255,0),this[d]=h&255,d+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(h,d,v){return h=+h,d=d>>>0,v||u(this,h,d,2,65535,0),this[d]=h&255,this[d+1]=h>>>8,d+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(h,d,v){return h=+h,d=d>>>0,v||u(this,h,d,2,65535,0),this[d]=h>>>8,this[d+1]=h&255,d+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(h,d,v){return h=+h,d=d>>>0,v||u(this,h,d,4,4294967295,0),this[d+3]=h>>>24,this[d+2]=h>>>16,this[d+1]=h>>>8,this[d]=h&255,d+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(h,d,v){return h=+h,d=d>>>0,v||u(this,h,d,4,4294967295,0),this[d]=h>>>24,this[d+1]=h>>>16,this[d+2]=h>>>8,this[d+3]=h&255,d+4};function l(_,h,d,v,U){me(h,v,U,_,d,7);let F=Number(h&BigInt(4294967295));_[d++]=F,F=F>>8,_[d++]=F,F=F>>8,_[d++]=F,F=F>>8,_[d++]=F;let Y=Number(h>>BigInt(32)&BigInt(4294967295));return _[d++]=Y,Y=Y>>8,_[d++]=Y,Y=Y>>8,_[d++]=Y,Y=Y>>8,_[d++]=Y,d}function y(_,h,d,v,U){me(h,v,U,_,d,7);let F=Number(h&BigInt(4294967295));_[d+7]=F,F=F>>8,_[d+6]=F,F=F>>8,_[d+5]=F,F=F>>8,_[d+4]=F;let Y=Number(h>>BigInt(32)&BigInt(4294967295));return _[d+3]=Y,Y=Y>>8,_[d+2]=Y,Y=Y>>8,_[d+1]=Y,Y=Y>>8,_[d]=Y,d+8}a.prototype.writeBigUInt64LE=vt(function(h,d=0){return l(this,h,d,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=vt(function(h,d=0){return y(this,h,d,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(h,d,v,U){if(h=+h,d=d>>>0,!U){const _e=Math.pow(2,8*v-1);u(this,h,d,v,_e-1,-_e)}let F=0,Y=1,Re=0;for(this[d]=h&255;++F<v&&(Y*=256);)h<0&&Re===0&&this[d+F-1]!==0&&(Re=1),this[d+F]=(h/Y>>0)-Re&255;return d+v},a.prototype.writeIntBE=function(h,d,v,U){if(h=+h,d=d>>>0,!U){const _e=Math.pow(2,8*v-1);u(this,h,d,v,_e-1,-_e)}let F=v-1,Y=1,Re=0;for(this[d+F]=h&255;--F>=0&&(Y*=256);)h<0&&Re===0&&this[d+F+1]!==0&&(Re=1),this[d+F]=(h/Y>>0)-Re&255;return d+v},a.prototype.writeInt8=function(h,d,v){return h=+h,d=d>>>0,v||u(this,h,d,1,127,-128),h<0&&(h=255+h+1),this[d]=h&255,d+1},a.prototype.writeInt16LE=function(h,d,v){return h=+h,d=d>>>0,v||u(this,h,d,2,32767,-32768),this[d]=h&255,this[d+1]=h>>>8,d+2},a.prototype.writeInt16BE=function(h,d,v){return h=+h,d=d>>>0,v||u(this,h,d,2,32767,-32768),this[d]=h>>>8,this[d+1]=h&255,d+2},a.prototype.writeInt32LE=function(h,d,v){return h=+h,d=d>>>0,v||u(this,h,d,4,2147483647,-2147483648),this[d]=h&255,this[d+1]=h>>>8,this[d+2]=h>>>16,this[d+3]=h>>>24,d+4},a.prototype.writeInt32BE=function(h,d,v){return h=+h,d=d>>>0,v||u(this,h,d,4,2147483647,-2147483648),h<0&&(h=4294967295+h+1),this[d]=h>>>24,this[d+1]=h>>>16,this[d+2]=h>>>8,this[d+3]=h&255,d+4},a.prototype.writeBigInt64LE=vt(function(h,d=0){return l(this,h,d,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=vt(function(h,d=0){return y(this,h,d,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function k(_,h,d,v,U,F){if(d+v>_.length)throw new RangeError("Index out of range");if(d<0)throw new RangeError("Index out of range")}function P(_,h,d,v,U){return h=+h,d=d>>>0,U||k(_,h,d,4),t.write(_,h,d,v,23,4),d+4}a.prototype.writeFloatLE=function(h,d,v){return P(this,h,d,!0,v)},a.prototype.writeFloatBE=function(h,d,v){return P(this,h,d,!1,v)};function G(_,h,d,v,U){return h=+h,d=d>>>0,U||k(_,h,d,8),t.write(_,h,d,v,52,8),d+8}a.prototype.writeDoubleLE=function(h,d,v){return G(this,h,d,!0,v)},a.prototype.writeDoubleBE=function(h,d,v){return G(this,h,d,!1,v)},a.prototype.copy=function(h,d,v,U){if(!a.isBuffer(h))throw new TypeError("argument should be a Buffer");if(v||(v=0),!U&&U!==0&&(U=this.length),d>=h.length&&(d=h.length),d||(d=0),U>0&&U<v&&(U=v),U===v||h.length===0||this.length===0)return 0;if(d<0)throw new RangeError("targetStart out of bounds");if(v<0||v>=this.length)throw new RangeError("Index out of range");if(U<0)throw new RangeError("sourceEnd out of bounds");U>this.length&&(U=this.length),h.length-d<U-v&&(U=h.length-d+v);const F=U-v;return this===h&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(d,v,U):Uint8Array.prototype.set.call(h,this.subarray(v,U),d),F},a.prototype.fill=function(h,d,v,U){if(typeof h=="string"){if(typeof d=="string"?(U=d,d=0,v=this.length):typeof v=="string"&&(U=v,v=this.length),U!==void 0&&typeof U!="string")throw new TypeError("encoding must be a string");if(typeof U=="string"&&!a.isEncoding(U))throw new TypeError("Unknown encoding: "+U);if(h.length===1){const Y=h.charCodeAt(0);(U==="utf8"&&Y<128||U==="latin1")&&(h=Y)}}else typeof h=="number"?h=h&255:typeof h=="boolean"&&(h=Number(h));if(d<0||this.length<d||this.length<v)throw new RangeError("Out of range index");if(v<=d)return this;d=d>>>0,v=v===void 0?this.length:v>>>0,h||(h=0);let F;if(typeof h=="number")for(F=d;F<v;++F)this[F]=h;else{const Y=a.isBuffer(h)?h:a.from(h,U),Re=Y.length;if(Re===0)throw new TypeError('The value "'+h+'" is invalid for argument "value"');for(F=0;F<v-d;++F)this[F+d]=Y[F%Re]}return this};const j={};function ce(_,h,d){j[_]=class extends d{constructor(){super(),Object.defineProperty(this,"message",{value:h.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${_}]`,this.stack,delete this.name}get code(){return _}set code(U){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:U,writable:!0})}toString(){return`${this.name} [${_}]: ${this.message}`}}}ce("ERR_BUFFER_OUT_OF_BOUNDS",function(_){return _?`${_} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),ce("ERR_INVALID_ARG_TYPE",function(_,h){return`The "${_}" argument must be of type number. Received type ${typeof h}`},TypeError),ce("ERR_OUT_OF_RANGE",function(_,h,d){let v=`The value of "${_}" is out of range.`,U=d;return Number.isInteger(d)&&Math.abs(d)>2**32?U=ve(String(d)):typeof d=="bigint"&&(U=String(d),(d>BigInt(2)**BigInt(32)||d<-(BigInt(2)**BigInt(32)))&&(U=ve(U)),U+="n"),v+=` It must be ${h}. Received ${U}`,v},RangeError);function ve(_){let h="",d=_.length;const v=_[0]==="-"?1:0;for(;d>=v+4;d-=3)h=`_${_.slice(d-3,d)}${h}`;return`${_.slice(0,d)}${h}`}function ge(_,h,d){Ue(h,"offset"),(_[h]===void 0||_[h+d]===void 0)&&Se(h,_.length-(d+1))}function me(_,h,d,v,U,F){if(_>d||_<h){const Y=typeof h=="bigint"?"n":"";let Re;throw h===0||h===BigInt(0)?Re=`>= 0${Y} and < 2${Y} ** ${(F+1)*8}${Y}`:Re=`>= -(2${Y} ** ${(F+1)*8-1}${Y}) and < 2 ** ${(F+1)*8-1}${Y}`,new j.ERR_OUT_OF_RANGE("value",Re,_)}ge(v,U,F)}function Ue(_,h){if(typeof _!="number")throw new j.ERR_INVALID_ARG_TYPE(h,"number",_)}function Se(_,h,d){throw Math.floor(_)!==_?(Ue(_,d),new j.ERR_OUT_OF_RANGE("offset","an integer",_)):h<0?new j.ERR_BUFFER_OUT_OF_BOUNDS:new j.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${h}`,_)}const Te=/[^+/0-9A-Za-z-_]/g;function Wt(_){if(_=_.split("=")[0],_=_.trim().replace(Te,""),_.length<2)return"";for(;_.length%4!==0;)_=_+"=";return _}function Be(_,h){h=h||1/0;let d;const v=_.length;let U=null;const F=[];for(let Y=0;Y<v;++Y){if(d=_.charCodeAt(Y),d>55295&&d<57344){if(!U){if(d>56319){(h-=3)>-1&&F.push(239,191,189);continue}else if(Y+1===v){(h-=3)>-1&&F.push(239,191,189);continue}U=d;continue}if(d<56320){(h-=3)>-1&&F.push(239,191,189),U=d;continue}d=(U-55296<<10|d-56320)+65536}else U&&(h-=3)>-1&&F.push(239,191,189);if(U=null,d<128){if((h-=1)<0)break;F.push(d)}else if(d<2048){if((h-=2)<0)break;F.push(d>>6|192,d&63|128)}else if(d<65536){if((h-=3)<0)break;F.push(d>>12|224,d>>6&63|128,d&63|128)}else if(d<1114112){if((h-=4)<0)break;F.push(d>>18|240,d>>12&63|128,d>>6&63|128,d&63|128)}else throw new Error("Invalid code point")}return F}function He(_){const h=[];for(let d=0;d<_.length;++d)h.push(_.charCodeAt(d)&255);return h}function Dn(_,h){let d,v,U;const F=[];for(let Y=0;Y<_.length&&!((h-=2)<0);++Y)d=_.charCodeAt(Y),v=d>>8,U=d%256,F.push(U),F.push(v);return F}function Fe(_){return e.toByteArray(Wt(_))}function Le(_,h,d,v){let U;for(U=0;U<v&&!(U+d>=h.length||U>=_.length);++U)h[U+d]=_[U];return U}function Et(_,h){return _ instanceof h||_!=null&&_.constructor!=null&&_.constructor.name!=null&&_.constructor.name===h.name}function Ce(_){return _!==_}const De=function(){const _="0123456789abcdef",h=new Array(256);for(let d=0;d<16;++d){const v=d*16;for(let U=0;U<16;++U)h[v+U]=_[d]+_[U]}return h}();function vt(_){return typeof BigInt>"u"?ze:_}function ze(){throw new Error("BigInt not supported")}}(Fr)),Fr}var he=zr();function rr(n){if(!Number.isSafeInteger(n)||n<0)throw new Error(`positive integer expected, not ${n}`)}function Xa(n){return n instanceof Uint8Array||n!=null&&typeof n=="object"&&n.constructor.name==="Uint8Array"}function Kn(n,...e){if(!Xa(n))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(n.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${n.length}`)}function Ja(n){if(typeof n!="function"||typeof n.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");rr(n.outputLen),rr(n.blockLen)}function bn(n,e=!0){if(n.destroyed)throw new Error("Hash instance has been destroyed");if(e&&n.finished)throw new Error("Hash#digest() has already been called")}function Os(n,e){Kn(n);const t=e.outputLen;if(n.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}const Kr=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Qa=n=>new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4)),$r=n=>new DataView(n.buffer,n.byteOffset,n.byteLength),Ct=(n,e)=>n<<32-e|n>>>e,ks=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,ec=n=>n<<24&4278190080|n<<8&16711680|n>>>8&65280|n>>>24&255;function Ts(n){for(let e=0;e<n.length;e++)n[e]=ec(n[e])}function tc(n){if(typeof n!="string")throw new Error(`utf8ToBytes expected string, got ${typeof n}`);return new Uint8Array(new TextEncoder().encode(n))}function ir(n){return typeof n=="string"&&(n=tc(n)),Kn(n),n}function nc(...n){let e=0;for(let r=0;r<n.length;r++){const s=n[r];Kn(s),e+=s.length}const t=new Uint8Array(e);for(let r=0,s=0;r<n.length;r++){const i=n[r];t.set(i,s),s+=i.length}return t}class Hr{clone(){return this._cloneInto()}}function Wr(n){const e=r=>n().update(ir(r)).digest(),t=n();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>n(),e}function Ns(n=32){if(Kr&&typeof Kr.getRandomValues=="function")return Kr.getRandomValues(new Uint8Array(n));throw new Error("crypto.getRandomValues must be defined")}function rc(n,e,t,r){if(typeof n.setBigUint64=="function")return n.setBigUint64(e,t,r);const s=BigInt(32),i=BigInt(4294967295),o=Number(t>>s&i),a=Number(t&i),f=r?4:0,g=r?0:4;n.setUint32(e+f,o,r),n.setUint32(e+g,a,r)}const ic=(n,e,t)=>n&e^~n&t,sc=(n,e,t)=>n&e^n&t^e&t;class xs extends Hr{constructor(e,t,r,s){super(),this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=$r(this.buffer)}update(e){bn(this);const{view:t,buffer:r,blockLen:s}=this;e=ir(e);const i=e.length;for(let o=0;o<i;){const a=Math.min(s-this.pos,i-o);if(a===s){const f=$r(e);for(;s<=i-o;o+=s)this.process(f,o);continue}r.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===s&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){bn(this),Os(e,this),this.finished=!0;const{buffer:t,view:r,blockLen:s,isLE:i}=this;let{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>s-o&&(this.process(r,0),o=0);for(let b=o;b<s;b++)t[b]=0;rc(r,s-8,BigInt(this.length*8),i),this.process(r,0);const a=$r(e),f=this.outputLen;if(f%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const g=f/4,w=this.get();if(g>w.length)throw new Error("_sha2: outputLen bigger than state");for(let b=0;b<g;b++)a.setUint32(4*b,w[b],i)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:r,length:s,finished:i,destroyed:o,pos:a}=this;return e.length=s,e.pos=a,e.finished=i,e.destroyed=o,s%t&&e.buffer.set(r),e}}const sr=BigInt(2**32-1),qr=BigInt(32);function Bs(n,e=!1){return e?{h:Number(n&sr),l:Number(n>>qr&sr)}:{h:Number(n>>qr&sr)|0,l:Number(n&sr)|0}}function Ls(n,e=!1){let t=new Uint32Array(n.length),r=new Uint32Array(n.length);for(let s=0;s<n.length;s++){const{h:i,l:o}=Bs(n[s],e);[t[s],r[s]]=[i,o]}return[t,r]}const oc=(n,e)=>BigInt(n>>>0)<<qr|BigInt(e>>>0),ac=(n,e,t)=>n>>>t,cc=(n,e,t)=>n<<32-t|e>>>t,uc=(n,e,t)=>n>>>t|e<<32-t,lc=(n,e,t)=>n<<32-t|e>>>t,hc=(n,e,t)=>n<<64-t|e>>>t-32,fc=(n,e,t)=>n>>>t-32|e<<64-t,dc=(n,e)=>e,pc=(n,e)=>n,Cs=(n,e,t)=>n<<t|e>>>32-t,Ms=(n,e,t)=>e<<t|n>>>32-t,Ps=(n,e,t)=>e<<t-32|n>>>64-t,Us=(n,e,t)=>n<<t-32|e>>>64-t;function gc(n,e,t,r){const s=(e>>>0)+(r>>>0);return{h:n+t+(s/2**32|0)|0,l:s|0}}const ye={fromBig:Bs,split:Ls,toBig:oc,shrSH:ac,shrSL:cc,rotrSH:uc,rotrSL:lc,rotrBH:hc,rotrBL:fc,rotr32H:dc,rotr32L:pc,rotlSH:Cs,rotlSL:Ms,rotlBH:Ps,rotlBL:Us,add:gc,add3L:(n,e,t)=>(n>>>0)+(e>>>0)+(t>>>0),add3H:(n,e,t,r)=>e+t+r+(n/2**32|0)|0,add4L:(n,e,t,r)=>(n>>>0)+(e>>>0)+(t>>>0)+(r>>>0),add4H:(n,e,t,r,s)=>e+t+r+s+(n/2**32|0)|0,add5H:(n,e,t,r,s,i)=>e+t+r+s+i+(n/2**32|0)|0,add5L:(n,e,t,r,s)=>(n>>>0)+(e>>>0)+(t>>>0)+(r>>>0)+(s>>>0)},[mc,_c]=ye.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(n=>BigInt(n))),Xt=new Uint32Array(80),Jt=new Uint32Array(80);class yc extends xs{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:t,Bh:r,Bl:s,Ch:i,Cl:o,Dh:a,Dl:f,Eh:g,El:w,Fh:b,Fl:x,Gh:T,Gl:L,Hh:O,Hl:N}=this;return[e,t,r,s,i,o,a,f,g,w,b,x,T,L,O,N]}set(e,t,r,s,i,o,a,f,g,w,b,x,T,L,O,N){this.Ah=e|0,this.Al=t|0,this.Bh=r|0,this.Bl=s|0,this.Ch=i|0,this.Cl=o|0,this.Dh=a|0,this.Dl=f|0,this.Eh=g|0,this.El=w|0,this.Fh=b|0,this.Fl=x|0,this.Gh=T|0,this.Gl=L|0,this.Hh=O|0,this.Hl=N|0}process(e,t){for(let K=0;K<16;K++,t+=4)Xt[K]=e.getUint32(t),Jt[K]=e.getUint32(t+=4);for(let K=16;K<80;K++){const Q=Xt[K-15]|0,q=Jt[K-15]|0,D=ye.rotrSH(Q,q,1)^ye.rotrSH(Q,q,8)^ye.shrSH(Q,q,7),X=ye.rotrSL(Q,q,1)^ye.rotrSL(Q,q,8)^ye.shrSL(Q,q,7),Z=Xt[K-2]|0,J=Jt[K-2]|0,z=ye.rotrSH(Z,J,19)^ye.rotrBH(Z,J,61)^ye.shrSH(Z,J,6),V=ye.rotrSL(Z,J,19)^ye.rotrBL(Z,J,61)^ye.shrSL(Z,J,6),ee=ye.add4L(X,V,Jt[K-7],Jt[K-16]),S=ye.add4H(ee,D,z,Xt[K-7],Xt[K-16]);Xt[K]=S|0,Jt[K]=ee|0}let{Ah:r,Al:s,Bh:i,Bl:o,Ch:a,Cl:f,Dh:g,Dl:w,Eh:b,El:x,Fh:T,Fl:L,Gh:O,Gl:N,Hh:M,Hl:H}=this;for(let K=0;K<80;K++){const Q=ye.rotrSH(b,x,14)^ye.rotrSH(b,x,18)^ye.rotrBH(b,x,41),q=ye.rotrSL(b,x,14)^ye.rotrSL(b,x,18)^ye.rotrBL(b,x,41),D=b&T^~b&O,X=x&L^~x&N,Z=ye.add5L(H,q,X,_c[K],Jt[K]),J=ye.add5H(Z,M,Q,D,mc[K],Xt[K]),z=Z|0,V=ye.rotrSH(r,s,28)^ye.rotrBH(r,s,34)^ye.rotrBH(r,s,39),ee=ye.rotrSL(r,s,28)^ye.rotrBL(r,s,34)^ye.rotrBL(r,s,39),S=r&i^r&a^i&a,c=s&o^s&f^o&f;M=O|0,H=N|0,O=T|0,N=L|0,T=b|0,L=x|0,{h:b,l:x}=ye.add(g|0,w|0,J|0,z|0),g=a|0,w=f|0,a=i|0,f=o|0,i=r|0,o=s|0;const p=ye.add3L(z,ee,c);r=ye.add3H(p,J,V,S),s=p|0}({h:r,l:s}=ye.add(this.Ah|0,this.Al|0,r|0,s|0)),{h:i,l:o}=ye.add(this.Bh|0,this.Bl|0,i|0,o|0),{h:a,l:f}=ye.add(this.Ch|0,this.Cl|0,a|0,f|0),{h:g,l:w}=ye.add(this.Dh|0,this.Dl|0,g|0,w|0),{h:b,l:x}=ye.add(this.Eh|0,this.El|0,b|0,x|0),{h:T,l:L}=ye.add(this.Fh|0,this.Fl|0,T|0,L|0),{h:O,l:N}=ye.add(this.Gh|0,this.Gl|0,O|0,N|0),{h:M,l:H}=ye.add(this.Hh|0,this.Hl|0,M|0,H|0),this.set(r,s,i,o,a,f,g,w,b,x,T,L,O,N,M,H)}roundClean(){Xt.fill(0),Jt.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 wc=Wr(()=>new yc);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ds=BigInt(0),or=BigInt(1),bc=BigInt(2);function on(n){return n instanceof Uint8Array||n!=null&&typeof n=="object"&&n.constructor.name==="Uint8Array"}function $n(n){if(!on(n))throw new Error("Uint8Array expected")}const Rc=Array.from({length:256},(n,e)=>e.toString(16).padStart(2,"0"));function an(n){$n(n);let e="";for(let t=0;t<n.length;t++)e+=Rc[n[t]];return e}function Fs(n){const e=n.toString(16);return e.length&1?`0${e}`:e}function Vr(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);return BigInt(n===""?"0":`0x${n}`)}const qt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function zs(n){if(n>=qt._0&&n<=qt._9)return n-qt._0;if(n>=qt._A&&n<=qt._F)return n-(qt._A-10);if(n>=qt._a&&n<=qt._f)return n-(qt._a-10)}function Rn(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);const e=n.length,t=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(t);for(let s=0,i=0;s<t;s++,i+=2){const o=zs(n.charCodeAt(i)),a=zs(n.charCodeAt(i+1));if(o===void 0||a===void 0){const f=n[i]+n[i+1];throw new Error('hex string expected, got non-hex character "'+f+'" at index '+i)}r[s]=o*16+a}return r}function cn(n){return Vr(an(n))}function En(n){return $n(n),Vr(an(Uint8Array.from(n).reverse()))}function Sn(n,e){return Rn(n.toString(16).padStart(e*2,"0"))}function Hn(n,e){return Sn(n,e).reverse()}function Ec(n){return Rn(Fs(n))}function ft(n,e,t){let r;if(typeof e=="string")try{r=Rn(e)}catch(i){throw new Error(`${n} must be valid hex string, got "${e}". Cause: ${i}`)}else if(on(e))r=Uint8Array.from(e);else throw new Error(`${n} must be hex string or Uint8Array`);const s=r.length;if(typeof t=="number"&&s!==t)throw new Error(`${n} expected ${t} bytes, got ${s}`);return r}function un(...n){let e=0;for(let r=0;r<n.length;r++){const s=n[r];$n(s),e+=s.length}const t=new Uint8Array(e);for(let r=0,s=0;r<n.length;r++){const i=n[r];t.set(i,s),s+=i.length}return t}function Sc(n,e){if(n.length!==e.length)return!1;let t=0;for(let r=0;r<n.length;r++)t|=n[r]^e[r];return t===0}function Ac(n){if(typeof n!="string")throw new Error(`utf8ToBytes expected string, got ${typeof n}`);return new Uint8Array(new TextEncoder().encode(n))}function Ic(n){let e;for(e=0;n>Ds;n>>=or,e+=1);return e}function vc(n,e){return n>>BigInt(e)&or}function Oc(n,e,t){return n|(t?or:Ds)<<BigInt(e)}const Gr=n=>(bc<<BigInt(n-1))-or,Yr=n=>new Uint8Array(n),Ks=n=>Uint8Array.from(n);function $s(n,e,t){if(typeof n!="number"||n<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");let r=Yr(n),s=Yr(n),i=0;const o=()=>{r.fill(1),s.fill(0),i=0},a=(...b)=>t(s,r,...b),f=(b=Yr())=>{s=a(Ks([0]),b),r=a(),b.length!==0&&(s=a(Ks([1]),b),r=a())},g=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let b=0;const x=[];for(;b<e;){r=a();const T=r.slice();x.push(T),b+=r.length}return un(...x)};return(b,x)=>{o(),f(b);let T;for(;!(T=x(g()));)f();return o(),T}}const kc={bigint:n=>typeof n=="bigint",function:n=>typeof n=="function",boolean:n=>typeof n=="boolean",string:n=>typeof n=="string",stringOrUint8Array:n=>typeof n=="string"||on(n),isSafeInteger:n=>Number.isSafeInteger(n),array:n=>Array.isArray(n),field:(n,e)=>e.Fp.isValid(n),hash:n=>typeof n=="function"&&Number.isSafeInteger(n.outputLen)};function An(n,e,t={}){const r=(s,i,o)=>{const a=kc[i];if(typeof a!="function")throw new Error(`Invalid validator "${i}", expected function`);const f=n[s];if(!(o&&f===void 0)&&!a(f,n))throw new Error(`Invalid param ${String(s)}=${f} (${typeof f}), expected ${i}`)};for(const[s,i]of Object.entries(e))r(s,i,!1);for(const[s,i]of Object.entries(t))r(s,i,!0);return n}const Tc=Object.freeze(Object.defineProperty({__proto__:null,abytes:$n,bitGet:vc,bitLen:Ic,bitMask:Gr,bitSet:Oc,bytesToHex:an,bytesToNumberBE:cn,bytesToNumberLE:En,concatBytes:un,createHmacDrbg:$s,ensureBytes:ft,equalBytes:Sc,hexToBytes:Rn,hexToNumber:Vr,isBytes:on,numberToBytesBE:Sn,numberToBytesLE:Hn,numberToHexUnpadded:Fs,numberToVarBytesBE:Ec,utf8ToBytes:Ac,validateObject:An},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const dt=BigInt(0),We=BigInt(1),ln=BigInt(2),Nc=BigInt(3),jr=BigInt(4),Hs=BigInt(5),Ws=BigInt(8);BigInt(9),BigInt(16);function $e(n,e){const t=n%e;return t>=dt?t:e+t}function xc(n,e,t){if(t<=dt||e<dt)throw new Error("Expected power/modulo > 0");if(t===We)return dt;let r=We;for(;e>dt;)e&We&&(r=r*n%t),n=n*n%t,e>>=We;return r}function Ge(n,e,t){let r=n;for(;e-- >dt;)r*=r,r%=t;return r}function Zr(n,e){if(n===dt||e<=dt)throw new Error(`invert: expected positive integers, got n=${n} mod=${e}`);let t=$e(n,e),r=e,s=dt,i=We;for(;t!==dt;){const a=r/t,f=r%t,g=s-i*a;r=t,t=f,s=i,i=g}if(r!==We)throw new Error("invert: does not exist");return $e(s,e)}function Bc(n){const e=(n-We)/ln;let t,r,s;for(t=n-We,r=0;t%ln===dt;t/=ln,r++);for(s=ln;s<n&&xc(s,e,n)!==n-We;s++);if(r===1){const o=(n+We)/jr;return function(f,g){const w=f.pow(g,o);if(!f.eql(f.sqr(w),g))throw new Error("Cannot find square root");return w}}const i=(t+We)/ln;return function(a,f){if(a.pow(f,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let g=r,w=a.pow(a.mul(a.ONE,s),t),b=a.pow(f,i),x=a.pow(f,t);for(;!a.eql(x,a.ONE);){if(a.eql(x,a.ZERO))return a.ZERO;let T=1;for(let O=a.sqr(x);T<g&&!a.eql(O,a.ONE);T++)O=a.sqr(O);const L=a.pow(w,We<<BigInt(g-T-1));w=a.sqr(L),b=a.mul(b,L),x=a.mul(x,w),g=T}return b}}function Lc(n){if(n%jr===Nc){const e=(n+We)/jr;return function(r,s){const i=r.pow(s,e);if(!r.eql(r.sqr(i),s))throw new Error("Cannot find square root");return i}}if(n%Ws===Hs){const e=(n-Hs)/Ws;return function(r,s){const i=r.mul(s,ln),o=r.pow(i,e),a=r.mul(s,o),f=r.mul(r.mul(a,ln),o),g=r.mul(a,r.sub(f,r.ONE));if(!r.eql(r.sqr(g),s))throw new Error("Cannot find square root");return g}}return Bc(n)}const Cc=(n,e)=>($e(n,e)&We)===We,Mc=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Pc(n){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=Mc.reduce((r,s)=>(r[s]="function",r),e);return An(n,t)}function Uc(n,e,t){if(t<dt)throw new Error("Expected power > 0");if(t===dt)return n.ONE;if(t===We)return e;let r=n.ONE,s=e;for(;t>dt;)t&We&&(r=n.mul(r,s)),s=n.sqr(s),t>>=We;return r}function Dc(n,e){const t=new Array(e.length),r=e.reduce((i,o,a)=>n.is0(o)?i:(t[a]=i,n.mul(i,o)),n.ONE),s=n.inv(r);return e.reduceRight((i,o,a)=>n.is0(o)?i:(t[a]=n.mul(i,t[a]),n.mul(i,o)),s),t}function qs(n,e){const t=e!==void 0?e:n.toString(2).length,r=Math.ceil(t/8);return{nBitLength:t,nByteLength:r}}function Vs(n,e,t=!1,r={}){if(n<=dt)throw new Error(`Expected Field ORDER > 0, got ${n}`);const{nBitLength:s,nByteLength:i}=qs(n,e);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");const o=Lc(n),a=Object.freeze({ORDER:n,BITS:s,BYTES:i,MASK:Gr(s),ZERO:dt,ONE:We,create:f=>$e(f,n),isValid:f=>{if(typeof f!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof f}`);return dt<=f&&f<n},is0:f=>f===dt,isOdd:f=>(f&We)===We,neg:f=>$e(-f,n),eql:(f,g)=>f===g,sqr:f=>$e(f*f,n),add:(f,g)=>$e(f+g,n),sub:(f,g)=>$e(f-g,n),mul:(f,g)=>$e(f*g,n),pow:(f,g)=>Uc(a,f,g),div:(f,g)=>$e(f*Zr(g,n),n),sqrN:f=>f*f,addN:(f,g)=>f+g,subN:(f,g)=>f-g,mulN:(f,g)=>f*g,inv:f=>Zr(f,n),sqrt:r.sqrt||(f=>o(a,f)),invertBatch:f=>Dc(a,f),cmov:(f,g,w)=>w?g:f,toBytes:f=>t?Hn(f,i):Sn(f,i),fromBytes:f=>{if(f.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${f.length}`);return t?En(f):cn(f)}});return Object.freeze(a)}function Gs(n){if(typeof n!="bigint")throw new Error("field order must be bigint");const e=n.toString(2).length;return Math.ceil(e/8)}function Ys(n){const e=Gs(n);return e+Math.ceil(e/2)}function Fc(n,e,t=!1){const r=n.length,s=Gs(e),i=Ys(e);if(r<16||r<i||r>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${r}`);const o=t?cn(n):En(n),a=$e(o,e-We)+We;return t?Hn(a,s):Sn(a,s)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const zc=BigInt(0),Xr=BigInt(1);function js(n,e){const t=(s,i)=>{const o=i.negate();return s?o:i},r=s=>{const i=Math.ceil(e/s)+1,o=2**(s-1);return{windows:i,windowSize:o}};return{constTimeNegate:t,unsafeLadder(s,i){let o=n.ZERO,a=s;for(;i>zc;)i&Xr&&(o=o.add(a)),a=a.double(),i>>=Xr;return o},precomputeWindow(s,i){const{windows:o,windowSize:a}=r(i),f=[];let g=s,w=g;for(let b=0;b<o;b++){w=g,f.push(w);for(let x=1;x<a;x++)w=w.add(g),f.push(w);g=w.double()}return f},wNAF(s,i,o){const{windows:a,windowSize:f}=r(s);let g=n.ZERO,w=n.BASE;const b=BigInt(2**s-1),x=2**s,T=BigInt(s);for(let L=0;L<a;L++){const O=L*f;let N=Number(o&b);o>>=T,N>f&&(N-=x,o+=Xr);const M=O,H=O+Math.abs(N)-1,K=L%2!==0,Q=N<0;N===0?w=w.add(t(K,i[M])):g=g.add(t(Q,i[H]))}return{p:g,f:w}},wNAFCached(s,i,o,a){const f=s._WINDOW_SIZE||1;let g=i.get(s);return g||(g=this.precomputeWindow(s,f),f!==1&&i.set(s,a(g))),this.wNAF(f,g,o)}}}function Jr(n){return Pc(n.Fp),An(n,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...qs(n.n,n.nBitLength),...n,p:n.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Nt=BigInt(0),Ot=BigInt(1),ar=BigInt(2),Kc=BigInt(8),$c={zip215:!0};function Hc(n){const e=Jr(n);return An(n,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function Wc(n){const e=Hc(n),{Fp:t,n:r,prehash:s,hash:i,randomBytes:o,nByteLength:a,h:f}=e,g=ar<<BigInt(a*8)-Ot,w=t.create,b=e.uvRatio||((E,A)=>{try{return{isValid:!0,value:t.sqrt(E*t.inv(A))}}catch{return{isValid:!1,value:Nt}}}),x=e.adjustScalarBytes||(E=>E),T=e.domain||((E,A,C)=>{if(A.length||C)throw new Error("Contexts/pre-hash are not supported");return E}),L=E=>typeof E=="bigint"&&Nt<E,O=(E,A)=>L(E)&&L(A)&&E<A,N=E=>E===Nt||O(E,g);function M(E,A){if(O(E,A))return E;throw new Error(`Expected valid scalar < ${A}, got ${typeof E} ${E}`)}function H(E){return E===Nt?E:M(E,r)}const K=new Map;function Q(E){if(!(E instanceof q))throw new Error("ExtendedPoint expected")}class q{constructor(A,C,R,u){if(this.ex=A,this.ey=C,this.ez=R,this.et=u,!N(A))throw new Error("x required");if(!N(C))throw new Error("y required");if(!N(R))throw new Error("z required");if(!N(u))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(A){if(A instanceof q)throw new Error("extended point not allowed");const{x:C,y:R}=A||{};if(!N(C)||!N(R))throw new Error("invalid affine point");return new q(C,R,Ot,w(C*R))}static normalizeZ(A){const C=t.invertBatch(A.map(R=>R.ez));return A.map((R,u)=>R.toAffine(C[u])).map(q.fromAffine)}_setWindowSize(A){this._WINDOW_SIZE=A,K.delete(this)}assertValidity(){const{a:A,d:C}=e;if(this.is0())throw new Error("bad point: ZERO");const{ex:R,ey:u,ez:l,et:y}=this,k=w(R*R),P=w(u*u),G=w(l*l),j=w(G*G),ce=w(k*A),ve=w(G*w(ce+P)),ge=w(j+w(C*w(k*P)));if(ve!==ge)throw new Error("bad point: equation left != right (1)");const me=w(R*u),Ue=w(l*y);if(me!==Ue)throw new Error("bad point: equation left != right (2)")}equals(A){Q(A);const{ex:C,ey:R,ez:u}=this,{ex:l,ey:y,ez:k}=A,P=w(C*k),G=w(l*u),j=w(R*k),ce=w(y*u);return P===G&&j===ce}is0(){return this.equals(q.ZERO)}negate(){return new q(w(-this.ex),this.ey,this.ez,w(-this.et))}double(){const{a:A}=e,{ex:C,ey:R,ez:u}=this,l=w(C*C),y=w(R*R),k=w(ar*w(u*u)),P=w(A*l),G=C+R,j=w(w(G*G)-l-y),ce=P+y,ve=ce-k,ge=P-y,me=w(j*ve),Ue=w(ce*ge),Se=w(j*ge),Te=w(ve*ce);return new q(me,Ue,Te,Se)}add(A){Q(A);const{a:C,d:R}=e,{ex:u,ey:l,ez:y,et:k}=this,{ex:P,ey:G,ez:j,et:ce}=A;if(C===BigInt(-1)){const Et=w((l-u)*(G+P)),Ce=w((l+u)*(G-P)),De=w(Ce-Et);if(De===Nt)return this.double();const vt=w(y*ar*ce),ze=w(k*ar*j),_=ze+vt,h=Ce+Et,d=ze-vt,v=w(_*De),U=w(h*d),F=w(_*d),Y=w(De*h);return new q(v,U,Y,F)}const ve=w(u*P),ge=w(l*G),me=w(k*R*ce),Ue=w(y*j),Se=w((u+l)*(P+G)-ve-ge),Te=Ue-me,Wt=Ue+me,Be=w(ge-C*ve),He=w(Se*Te),Dn=w(Wt*Be),Fe=w(Se*Be),Le=w(Te*Wt);return new q(He,Dn,Le,Fe)}subtract(A){return this.add(A.negate())}wNAF(A){return Z.wNAFCached(this,K,A,q.normalizeZ)}multiply(A){const{p:C,f:R}=this.wNAF(M(A,r));return q.normalizeZ([C,R])[0]}multiplyUnsafe(A){let C=H(A);return C===Nt?X:this.equals(X)||C===Ot?this:this.equals(D)?this.wNAF(C).p:Z.unsafeLadder(this,C)}isSmallOrder(){return this.multiplyUnsafe(f).is0()}isTorsionFree(){return Z.unsafeLadder(this,r).is0()}toAffine(A){const{ex:C,ey:R,ez:u}=this,l=this.is0();A==null&&(A=l?Kc:t.inv(u));const y=w(C*A),k=w(R*A),P=w(u*A);if(l)return{x:Nt,y:Ot};if(P!==Ot)throw new Error("invZ was invalid");return{x:y,y:k}}clearCofactor(){const{h:A}=e;return A===Ot?this:this.multiplyUnsafe(A)}static fromHex(A,C=!1){const{d:R,a:u}=e,l=t.BYTES;A=ft("pointHex",A,l);const y=A.slice(),k=A[l-1];y[l-1]=k&-129;const P=En(y);P===Nt||(C?M(P,g):M(P,t.ORDER));const G=w(P*P),j=w(G-Ot),ce=w(R*G-u);let{isValid:ve,value:ge}=b(j,ce);if(!ve)throw new Error("Point.fromHex: invalid y coordinate");const me=(ge&Ot)===Ot,Ue=(k&128)!==0;if(!C&&ge===Nt&&Ue)throw new Error("Point.fromHex: x=0 and x_0=1");return Ue!==me&&(ge=w(-ge)),q.fromAffine({x:ge,y:P})}static fromPrivateKey(A){return V(A).point}toRawBytes(){const{x:A,y:C}=this.toAffine(),R=Hn(C,t.BYTES);return R[R.length-1]|=A&Ot?128:0,R}toHex(){return an(this.toRawBytes())}}q.BASE=new q(e.Gx,e.Gy,Ot,w(e.Gx*e.Gy)),q.ZERO=new q(Nt,Ot,Ot,Nt);const{BASE:D,ZERO:X}=q,Z=js(q,a*8);function J(E){return $e(E,r)}function z(E){return J(En(E))}function V(E){const A=a;E=ft("private key",E,A);const C=ft("hashed private key",i(E),2*A),R=x(C.slice(0,A)),u=C.slice(A,2*A),l=z(R),y=D.multiply(l),k=y.toRawBytes();return{head:R,prefix:u,scalar:l,point:y,pointBytes:k}}function ee(E){return V(E).pointBytes}function S(E=new Uint8Array,...A){const C=un(...A);return z(i(T(C,ft("context",E),!!s)))}function c(E,A,C={}){E=ft("message",E),s&&(E=s(E));const{prefix:R,scalar:u,pointBytes:l}=V(A),y=S(C.context,R,E),k=D.multiply(y).toRawBytes(),P=S(C.context,k,l,E),G=J(y+P*u);H(G);const j=un(k,Hn(G,t.BYTES));return ft("result",j,a*2)}const p=$c;function m(E,A,C,R=p){const{context:u,zip215:l}=R,y=t.BYTES;E=ft("signature",E,2*y),A=ft("message",A),s&&(A=s(A));const k=En(E.slice(y,2*y));let P,G,j;try{P=q.fromHex(C,l),G=q.fromHex(E.slice(0,y),l),j=D.multiplyUnsafe(k)}catch{return!1}if(!l&&P.isSmallOrder())return!1;const ce=S(u,G.toRawBytes(),P.toRawBytes(),A);return G.add(P.multiplyUnsafe(ce)).subtract(j).clearCofactor().equals(q.ZERO)}return D._setWindowSize(8),{CURVE:e,getPublicKey:ee,sign:c,verify:m,ExtendedPoint:q,utils:{getExtendedPublicKey:V,randomPrivateKey:()=>o(t.BYTES),precompute(E=8,A=q.BASE){return A._setWindowSize(E),A.multiply(BigInt(3)),A}}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Qr=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Zs=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const qc=BigInt(1),Xs=BigInt(2);BigInt(3);const Vc=BigInt(5),Gc=BigInt(8);function Yc(n){const e=BigInt(10),t=BigInt(20),r=BigInt(40),s=BigInt(80),i=Qr,a=n*n%i*n%i,f=Ge(a,Xs,i)*a%i,g=Ge(f,qc,i)*n%i,w=Ge(g,Vc,i)*g%i,b=Ge(w,e,i)*w%i,x=Ge(b,t,i)*b%i,T=Ge(x,r,i)*x%i,L=Ge(T,s,i)*T%i,O=Ge(L,s,i)*T%i,N=Ge(O,e,i)*w%i;return{pow_p_5_8:Ge(N,Xs,i)*n%i,b2:a}}function jc(n){return n[0]&=248,n[31]&=127,n[31]|=64,n}function Zc(n,e){const t=Qr,r=$e(e*e*e,t),s=$e(r*r*e,t),i=Yc(n*s).pow_p_5_8;let o=$e(n*r*i,t);const a=$e(e*o*o,t),f=o,g=$e(o*Zs,t),w=a===n,b=a===$e(-n,t),x=a===$e(-n*Zs,t);return w&&(o=f),(b||x)&&(o=g),Cc(o,t)&&(o=$e(-o,t)),{isValid:w||b,value:o}}const Xc=Vs(Qr,void 0,!0),Jc={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Xc,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Gc,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:wc,randomBytes:Ns,adjustScalarBytes:jc,uvRatio:Zc},In=Wc(Jc);var cr={exports:{}};const Qc=Dr(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var eu=cr.exports,Js;function Qs(){return Js||(Js=1,function(n){(function(e,t){function r(S,c){if(!S)throw new Error(c||"Assertion failed")}function s(S,c){S.super_=c;var p=function(){};p.prototype=c.prototype,S.prototype=new p,S.prototype.constructor=S}function i(S,c,p){if(i.isBN(S))return S;this.negative=0,this.words=null,this.length=0,this.red=null,S!==null&&((c==="le"||c==="be")&&(p=c,c=10),this._init(S||0,c||10,p||"be"))}typeof e=="object"?e.exports=i:t.BN=i,i.BN=i,i.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=Qc.Buffer}catch{}i.isBN=function(c){return c instanceof i?!0:c!==null&&typeof c=="object"&&c.constructor.wordSize===i.wordSize&&Array.isArray(c.words)},i.max=function(c,p){return c.cmp(p)>0?c:p},i.min=function(c,p){return c.cmp(p)<0?c:p},i.prototype._init=function(c,p,m){if(typeof c=="number")return this._initNumber(c,p,m);if(typeof c=="object")return this._initArray(c,p,m);p==="hex"&&(p=16),r(p===(p|0)&&p>=2&&p<=36),c=c.toString().replace(/\s+/g,"");var I=0;c[0]==="-"&&(I++,this.negative=1),I<c.length&&(p===16?this._parseHex(c,I,m):(this._parseBase(c,p,I),m==="le"&&this._initArray(this.toArray(),p,m)))},i.prototype._initNumber=function(c,p,m){c<0&&(this.negative=1,c=-c),c<67108864?(this.words=[c&67108863],this.length=1):c<4503599627370496?(this.words=[c&67108863,c/67108864&67108863],this.length=2):(r(c<9007199254740992),this.words=[c&67108863,c/67108864&67108863,1],this.length=3),m==="le"&&this._initArray(this.toArray(),p,m)},i.prototype._initArray=function(c,p,m){if(r(typeof c.length=="number"),c.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(c.length/3),this.words=new Array(this.length);for(var I=0;I<this.length;I++)this.words[I]=0;var E,A,C=0;if(m==="be")for(I=c.length-1,E=0;I>=0;I-=3)A=c[I]|c[I-1]<<8|c[I-2]<<16,this.words[E]|=A<<C&67108863,this.words[E+1]=A>>>26-C&67108863,C+=24,C>=26&&(C-=26,E++);else if(m==="le")for(I=0,E=0;I<c.length;I+=3)A=c[I]|c[I+1]<<8|c[I+2]<<16,this.words[E]|=A<<C&67108863,this.words[E+1]=A>>>26-C&67108863,C+=24,C>=26&&(C-=26,E++);return this._strip()};function a(S,c){var p=S.charCodeAt(c);if(p>=48&&p<=57)return p-48;if(p>=65&&p<=70)return p-55;if(p>=97&&p<=102)return p-87;r(!1,"Invalid character in "+S)}function f(S,c,p){var m=a(S,p);return p-1>=c&&(m|=a(S,p-1)<<4),m}i.prototype._parseHex=function(c,p,m){this.length=Math.ceil((c.length-p)/6),this.words=new Array(this.length);for(var I=0;I<this.length;I++)this.words[I]=0;var E=0,A=0,C;if(m==="be")for(I=c.length-1;I>=p;I-=2)C=f(c,p,I)<<E,this.words[A]|=C&67108863,E>=18?(E-=18,A+=1,this.words[A]|=C>>>26):E+=8;else{var R=c.length-p;for(I=R%2===0?p+1:p;I<c.length;I+=2)C=f(c,p,I)<<E,this.words[A]|=C&67108863,E>=18?(E-=18,A+=1,this.words[A]|=C>>>26):E+=8}this._strip()};function g(S,c,p,m){for(var I=0,E=0,A=Math.min(S.length,p),C=c;C<A;C++){var R=S.charCodeAt(C)-48;I*=m,R>=49?E=R-49+10:R>=17?E=R-17+10:E=R,r(R>=0&&E<m,"Invalid character"),I+=E}return I}i.prototype._parseBase=function(c,p,m){this.words=[0],this.length=1;for(var I=0,E=1;E<=67108863;E*=p)I++;I--,E=E/p|0;for(var A=c.length-m,C=A%I,R=Math.min(A,A-C)+m,u=0,l=m;l<R;l+=I)u=g(c,l,l+I,p),this.imuln(E),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(C!==0){var y=1;for(u=g(c,l,c.length,p),l=0;l<C;l++)y*=p;this.imuln(y),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this._strip()},i.prototype.copy=function(c){c.words=new Array(this.length);for(var p=0;p<this.length;p++)c.words[p]=this.words[p];c.length=this.length,c.negative=this.negative,c.red=this.red};function w(S,c){S.words=c.words,S.length=c.length,S.negative=c.negative,S.red=c.red}if(i.prototype._move=function(c){w(c,this)},i.prototype.clone=function(){var c=new i(null);return this.copy(c),c},i.prototype._expand=function(c){for(;this.length<c;)this.words[this.length++]=0;return this},i.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},i.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{i.prototype[Symbol.for("nodejs.util.inspect.custom")]=b}catch{i.prototype.inspect=b}else i.prototype.inspect=b;function b(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var x=["","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"],T=[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],L=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];i.prototype.toString=function(c,p){c=c||10,p=p|0||1;var m;if(c===16||c==="hex"){m="";for(var I=0,E=0,A=0;A<this.length;A++){var C=this.words[A],R=((C<<I|E)&16777215).toString(16);E=C>>>24-I&16777215,I+=2,I>=26&&(I-=26,A--),E!==0||A!==this.length-1?m=x[6-R.length]+R+m:m=R+m}for(E!==0&&(m=E.toString(16)+m);m.length%p!==0;)m="0"+m;return this.negative!==0&&(m="-"+m),m}if(c===(c|0)&&c>=2&&c<=36){var u=T[c],l=L[c];m="";var y=this.clone();for(y.negative=0;!y.isZero();){var k=y.modrn(l).toString(c);y=y.idivn(l),y.isZero()?m=k+m:m=x[u-k.length]+k+m}for(this.isZero()&&(m="0"+m);m.length%p!==0;)m="0"+m;return this.negative!==0&&(m="-"+m),m}r(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var c=this.words[0];return this.length===2?c+=this.words[1]*67108864:this.length===3&&this.words[2]===1?c+=4503599627370496+this.words[1]*67108864:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-c:c},i.prototype.toJSON=function(){return this.toString(16,2)},o&&(i.prototype.toBuffer=function(c,p){return this.toArrayLike(o,c,p)}),i.prototype.toArray=function(c,p){return this.toArrayLike(Array,c,p)};var O=function(c,p){return c.allocUnsafe?c.allocUnsafe(p):new c(p)};i.prototype.toArrayLike=function(c,p,m){this._strip();var I=this.byteLength(),E=m||Math.max(1,I);r(I<=E,"byte array longer than desired length"),r(E>0,"Requested array length <= 0");var A=O(c,E),C=p==="le"?"LE":"BE";return this["_toArrayLike"+C](A,I),A},i.prototype._toArrayLikeLE=function(c,p){for(var m=0,I=0,E=0,A=0;E<this.length;E++){var C=this.words[E]<<A|I;c[m++]=C&255,m<c.length&&(c[m++]=C>>8&255),m<c.length&&(c[m++]=C>>16&255),A===6?(m<c.length&&(c[m++]=C>>24&255),I=0,A=0):(I=C>>>24,A+=2)}if(m<c.length)for(c[m++]=I;m<c.length;)c[m++]=0},i.prototype._toArrayLikeBE=function(c,p){for(var m=c.length-1,I=0,E=0,A=0;E<this.length;E++){var C=this.words[E]<<A|I;c[m--]=C&255,m>=0&&(c[m--]=C>>8&255),m>=0&&(c[m--]=C>>16&255),A===6?(m>=0&&(c[m--]=C>>24&255),I=0,A=0):(I=C>>>24,A+=2)}if(m>=0)for(c[m--]=I;m>=0;)c[m--]=0},Math.clz32?i.prototype._countBits=function(c){return 32-Math.clz32(c)}:i.prototype._countBits=function(c){var p=c,m=0;return p>=4096&&(m+=13,p>>>=13),p>=64&&(m+=7,p>>>=7),p>=8&&(m+=4,p>>>=4),p>=2&&(m+=2,p>>>=2),m+p},i.prototype._zeroBits=function(c){if(c===0)return 26;var p=c,m=0;return(p&8191)===0&&(m+=13,p>>>=13),(p&127)===0&&(m+=7,p>>>=7),(p&15)===0&&(m+=4,p>>>=4),(p&3)===0&&(m+=2,p>>>=2),(p&1)===0&&m++,m},i.prototype.bitLength=function(){var c=this.words[this.length-1],p=this._countBits(c);return(this.length-1)*26+p};function N(S){for(var c=new Array(S.bitLength()),p=0;p<c.length;p++){var m=p/26|0,I=p%26;c[p]=S.words[m]>>>I&1}return c}i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var c=0,p=0;p<this.length;p++){var m=this._zeroBits(this.words[p]);if(c+=m,m!==26)break}return c},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(c){return this.negative!==0?this.abs().inotn(c).iaddn(1):this.clone()},i.prototype.fromTwos=function(c){return this.testn(c-1)?this.notn(c).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return this.negative!==0},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(c){for(;this.length<c.length;)this.words[this.length++]=0;for(var p=0;p<c.length;p++)this.words[p]=this.words[p]|c.words[p];return this._strip()},i.prototype.ior=function(c){return r((this.negative|c.negative)===0),this.iuor(c)},i.prototype.or=function(c){return this.length>c.length?this.clone().ior(c):c.clone().ior(this)},i.prototype.uor=function(c){return this.length>c.length?this.clone().iuor(c):c.clone().iuor(this)},i.prototype.iuand=function(c){var p;this.length>c.length?p=c:p=this;for(var m=0;m<p.length;m++)this.words[m]=this.words[m]&c.words[m];return this.length=p.length,this._strip()},i.prototype.iand=function(c){return r((this.negative|c.negative)===0),this.iuand(c)},i.prototype.and=function(c){return this.length>c.length?this.clone().iand(c):c.clone().iand(this)},i.prototype.uand=function(c){return this.length>c.length?this.clone().iuand(c):c.clone().iuand(this)},i.prototype.iuxor=function(c){var p,m;this.length>c.length?(p=this,m=c):(p=c,m=this);for(var I=0;I<m.length;I++)this.words[I]=p.words[I]^m.words[I];if(this!==p)for(;I<p.length;I++)this.words[I]=p.words[I];return this.length=p.length,this._strip()},i.prototype.ixor=function(c){return r((this.negative|c.negative)===0),this.iuxor(c)},i.prototype.xor=function(c){return this.length>c.length?this.clone().ixor(c):c.clone().ixor(this)},i.prototype.uxor=function(c){return this.length>c.length?this.clone().iuxor(c):c.clone().iuxor(this)},i.prototype.inotn=function(c){r(typeof c=="number"&&c>=0);var p=Math.ceil(c/26)|0,m=c%26;this._expand(p),m>0&&p--;for(var I=0;I<p;I++)this.words[I]=~this.words[I]&67108863;return m>0&&(this.words[I]=~this.words[I]&67108863>>26-m),this._strip()},i.prototype.notn=function(c){return this.clone().inotn(c)},i.prototype.setn=function(c,p){r(typeof c=="number"&&c>=0);var m=c/26|0,I=c%26;return this._expand(m+1),p?this.words[m]=this.words[m]|1<<I:this.words[m]=this.words[m]&~(1<<I),this._strip()},i.prototype.iadd=function(c){var p;if(this.negative!==0&&c.negative===0)return this.negative=0,p=this.isub(c),this.negative^=1,this._normSign();if(this.negative===0&&c.negative!==0)return c.negative=0,p=this.isub(c),c.negative=1,p._normSign();var m,I;this.length>c.length?(m=this,I=c):(m=c,I=this);for(var E=0,A=0;A<I.length;A++)p=(m.words[A]|0)+(I.words[A]|0)+E,this.words[A]=p&67108863,E=p>>>26;for(;E!==0&&A<m.length;A++)p=(m.words[A]|0)+E,this.words[A]=p&67108863,E=p>>>26;if(this.length=m.length,E!==0)this.words[this.length]=E,this.length++;else if(m!==this)for(;A<m.length;A++)this.words[A]=m.words[A];return this},i.prototype.add=function(c){var p;return c.negative!==0&&this.negative===0?(c.negative=0,p=this.sub(c),c.negative^=1,p):c.negative===0&&this.negative!==0?(this.negative=0,p=c.sub(this),this.negative=1,p):this.length>c.length?this.clone().iadd(c):c.clone().iadd(this)},i.prototype.isub=function(c){if(c.negative!==0){c.negative=0;var p=this.iadd(c);return c.negative=1,p._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(c),this.negative=1,this._normSign();var m=this.cmp(c);if(m===0)return this.negative=0,this.length=1,this.words[0]=0,this;var I,E;m>0?(I=this,E=c):(I=c,E=this);for(var A=0,C=0;C<E.length;C++)p=(I.words[C]|0)-(E.words[C]|0)+A,A=p>>26,this.words[C]=p&67108863;for(;A!==0&&C<I.length;C++)p=(I.words[C]|0)+A,A=p>>26,this.words[C]=p&67108863;if(A===0&&C<I.length&&I!==this)for(;C<I.length;C++)this.words[C]=I.words[C];return this.length=Math.max(this.length,C),I!==this&&(this.negative=1),this._strip()},i.prototype.sub=function(c){return this.clone().isub(c)};function M(S,c,p){p.negative=c.negative^S.negative;var m=S.length+c.length|0;p.length=m,m=m-1|0;var I=S.words[0]|0,E=c.words[0]|0,A=I*E,C=A&67108863,R=A/67108864|0;p.words[0]=C;for(var u=1;u<m;u++){for(var l=R>>>26,y=R&67108863,k=Math.min(u,c.length-1),P=Math.max(0,u-S.length+1);P<=k;P++){var G=u-P|0;I=S.words[G]|0,E=c.words[P]|0,A=I*E+y,l+=A/67108864|0,y=A&67108863}p.words[u]=y|0,R=l|0}return R!==0?p.words[u]=R|0:p.length--,p._strip()}var H=function(c,p,m){var I=c.words,E=p.words,A=m.words,C=0,R,u,l,y=I[0]|0,k=y&8191,P=y>>>13,G=I[1]|0,j=G&8191,ce=G>>>13,ve=I[2]|0,ge=ve&8191,me=ve>>>13,Ue=I[3]|0,Se=Ue&8191,Te=Ue>>>13,Wt=I[4]|0,Be=Wt&8191,He=Wt>>>13,Dn=I[5]|0,Fe=Dn&8191,Le=Dn>>>13,Et=I[6]|0,Ce=Et&8191,De=Et>>>13,vt=I[7]|0,ze=vt&8191,_=vt>>>13,h=I[8]|0,d=h&8191,v=h>>>13,U=I[9]|0,F=U&8191,Y=U>>>13,Re=E[0]|0,_e=Re&8191,pe=Re>>>13,Ke=E[1]|0,fe=Ke&8191,je=Ke>>>13,Ka=E[2]|0,Ze=Ka&8191,Xe=Ka>>>13,$a=E[3]|0,Je=$a&8191,Qe=$a>>>13,Ha=E[4]|0,et=Ha&8191,tt=Ha>>>13,Wa=E[5]|0,nt=Wa&8191,rt=Wa>>>13,qa=E[6]|0,it=qa&8191,st=qa>>>13,Va=E[7]|0,ot=Va&8191,at=Va>>>13,Ga=E[8]|0,ct=Ga&8191,ut=Ga>>>13,Ya=E[9]|0,lt=Ya&8191,ht=Ya>>>13;m.negative=c.negative^p.negative,m.length=19,R=Math.imul(k,_e),u=Math.imul(k,pe),u=u+Math.imul(P,_e)|0,l=Math.imul(P,pe);var Qi=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(Qi>>>26)|0,Qi&=67108863,R=Math.imul(j,_e),u=Math.imul(j,pe),u=u+Math.imul(ce,_e)|0,l=Math.imul(ce,pe),R=R+Math.imul(k,fe)|0,u=u+Math.imul(k,je)|0,u=u+Math.imul(P,fe)|0,l=l+Math.imul(P,je)|0;var es=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(es>>>26)|0,es&=67108863,R=Math.imul(ge,_e),u=Math.imul(ge,pe),u=u+Math.imul(me,_e)|0,l=Math.imul(me,pe),R=R+Math.imul(j,fe)|0,u=u+Math.imul(j,je)|0,u=u+Math.imul(ce,fe)|0,l=l+Math.imul(ce,je)|0,R=R+Math.imul(k,Ze)|0,u=u+Math.imul(k,Xe)|0,u=u+Math.imul(P,Ze)|0,l=l+Math.imul(P,Xe)|0;var ts=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(ts>>>26)|0,ts&=67108863,R=Math.imul(Se,_e),u=Math.imul(Se,pe),u=u+Math.imul(Te,_e)|0,l=Math.imul(Te,pe),R=R+Math.imul(ge,fe)|0,u=u+Math.imul(ge,je)|0,u=u+Math.imul(me,fe)|0,l=l+Math.imul(me,je)|0,R=R+Math.imul(j,Ze)|0,u=u+Math.imul(j,Xe)|0,u=u+Math.imul(ce,Ze)|0,l=l+Math.imul(ce,Xe)|0,R=R+Math.imul(k,Je)|0,u=u+Math.imul(k,Qe)|0,u=u+Math.imul(P,Je)|0,l=l+Math.imul(P,Qe)|0;var ns=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(ns>>>26)|0,ns&=67108863,R=Math.imul(Be,_e),u=Math.imul(Be,pe),u=u+Math.imul(He,_e)|0,l=Math.imul(He,pe),R=R+Math.imul(Se,fe)|0,u=u+Math.imul(Se,je)|0,u=u+Math.imul(Te,fe)|0,l=l+Math.imul(Te,je)|0,R=R+Math.imul(ge,Ze)|0,u=u+Math.imul(ge,Xe)|0,u=u+Math.imul(me,Ze)|0,l=l+Math.imul(me,Xe)|0,R=R+Math.imul(j,Je)|0,u=u+Math.imul(j,Qe)|0,u=u+Math.imul(ce,Je)|0,l=l+Math.imul(ce,Qe)|0,R=R+Math.imul(k,et)|0,u=u+Math.imul(k,tt)|0,u=u+Math.imul(P,et)|0,l=l+Math.imul(P,tt)|0;var rs=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(rs>>>26)|0,rs&=67108863,R=Math.imul(Fe,_e),u=Math.imul(Fe,pe),u=u+Math.imul(Le,_e)|0,l=Math.imul(Le,pe),R=R+Math.imul(Be,fe)|0,u=u+Math.imul(Be,je)|0,u=u+Math.imul(He,fe)|0,l=l+Math.imul(He,je)|0,R=R+Math.imul(Se,Ze)|0,u=u+Math.imul(Se,Xe)|0,u=u+Math.imul(Te,Ze)|0,l=l+Math.imul(Te,Xe)|0,R=R+Math.imul(ge,Je)|0,u=u+Math.imul(ge,Qe)|0,u=u+Math.imul(me,Je)|0,l=l+Math.imul(me,Qe)|0,R=R+Math.imul(j,et)|0,u=u+Math.imul(j,tt)|0,u=u+Math.imul(ce,et)|0,l=l+Math.imul(ce,tt)|0,R=R+Math.imul(k,nt)|0,u=u+Math.imul(k,rt)|0,u=u+Math.imul(P,nt)|0,l=l+Math.imul(P,rt)|0;var is=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(is>>>26)|0,is&=67108863,R=Math.imul(Ce,_e),u=Math.imul(Ce,pe),u=u+Math.imul(De,_e)|0,l=Math.imul(De,pe),R=R+Math.imul(Fe,fe)|0,u=u+Math.imul(Fe,je)|0,u=u+Math.imul(Le,fe)|0,l=l+Math.imul(Le,je)|0,R=R+Math.imul(Be,Ze)|0,u=u+Math.imul(Be,Xe)|0,u=u+Math.imul(He,Ze)|0,l=l+Math.imul(He,Xe)|0,R=R+Math.imul(Se,Je)|0,u=u+Math.imul(Se,Qe)|0,u=u+Math.imul(Te,Je)|0,l=l+Math.imul(Te,Qe)|0,R=R+Math.imul(ge,et)|0,u=u+Math.imul(ge,tt)|0,u=u+Math.imul(me,et)|0,l=l+Math.imul(me,tt)|0,R=R+Math.imul(j,nt)|0,u=u+Math.imul(j,rt)|0,u=u+Math.imul(ce,nt)|0,l=l+Math.imul(ce,rt)|0,R=R+Math.imul(k,it)|0,u=u+Math.imul(k,st)|0,u=u+Math.imul(P,it)|0,l=l+Math.imul(P,st)|0;var ss=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(ss>>>26)|0,ss&=67108863,R=Math.imul(ze,_e),u=Math.imul(ze,pe),u=u+Math.imul(_,_e)|0,l=Math.imul(_,pe),R=R+Math.imul(Ce,fe)|0,u=u+Math.imul(Ce,je)|0,u=u+Math.imul(De,fe)|0,l=l+Math.imul(De,je)|0,R=R+Math.imul(Fe,Ze)|0,u=u+Math.imul(Fe,Xe)|0,u=u+Math.imul(Le,Ze)|0,l=l+Math.imul(Le,Xe)|0,R=R+Math.imul(Be,Je)|0,u=u+Math.imul(Be,Qe)|0,u=u+Math.imul(He,Je)|0,l=l+Math.imul(He,Qe)|0,R=R+Math.imul(Se,et)|0,u=u+Math.imul(Se,tt)|0,u=u+Math.imul(Te,et)|0,l=l+Math.imul(Te,tt)|0,R=R+Math.imul(ge,nt)|0,u=u+Math.imul(ge,rt)|0,u=u+Math.imul(me,nt)|0,l=l+Math.imul(me,rt)|0,R=R+Math.imul(j,it)|0,u=u+Math.imul(j,st)|0,u=u+Math.imul(ce,it)|0,l=l+Math.imul(ce,st)|0,R=R+Math.imul(k,ot)|0,u=u+Math.imul(k,at)|0,u=u+Math.imul(P,ot)|0,l=l+Math.imul(P,at)|0;var os=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(os>>>26)|0,os&=67108863,R=Math.imul(d,_e),u=Math.imul(d,pe),u=u+Math.imul(v,_e)|0,l=Math.imul(v,pe),R=R+Math.imul(ze,fe)|0,u=u+Math.imul(ze,je)|0,u=u+Math.imul(_,fe)|0,l=l+Math.imul(_,je)|0,R=R+Math.imul(Ce,Ze)|0,u=u+Math.imul(Ce,Xe)|0,u=u+Math.imul(De,Ze)|0,l=l+Math.imul(De,Xe)|0,R=R+Math.imul(Fe,Je)|0,u=u+Math.imul(Fe,Qe)|0,u=u+Math.imul(Le,Je)|0,l=l+Math.imul(Le,Qe)|0,R=R+Math.imul(Be,et)|0,u=u+Math.imul(Be,tt)|0,u=u+Math.imul(He,et)|0,l=l+Math.imul(He,tt)|0,R=R+Math.imul(Se,nt)|0,u=u+Math.imul(Se,rt)|0,u=u+Math.imul(Te,nt)|0,l=l+Math.imul(Te,rt)|0,R=R+Math.imul(ge,it)|0,u=u+Math.imul(ge,st)|0,u=u+Math.imul(me,it)|0,l=l+Math.imul(me,st)|0,R=R+Math.imul(j,ot)|0,u=u+Math.imul(j,at)|0,u=u+Math.imul(ce,ot)|0,l=l+Math.imul(ce,at)|0,R=R+Math.imul(k,ct)|0,u=u+Math.imul(k,ut)|0,u=u+Math.imul(P,ct)|0,l=l+Math.imul(P,ut)|0;var as=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(as>>>26)|0,as&=67108863,R=Math.imul(F,_e),u=Math.imul(F,pe),u=u+Math.imul(Y,_e)|0,l=Math.imul(Y,pe),R=R+Math.imul(d,fe)|0,u=u+Math.imul(d,je)|0,u=u+Math.imul(v,fe)|0,l=l+Math.imul(v,je)|0,R=R+Math.imul(ze,Ze)|0,u=u+Math.imul(ze,Xe)|0,u=u+Math.imul(_,Ze)|0,l=l+Math.imul(_,Xe)|0,R=R+Math.imul(Ce,Je)|0,u=u+Math.imul(Ce,Qe)|0,u=u+Math.imul(De,Je)|0,l=l+Math.imul(De,Qe)|0,R=R+Math.imul(Fe,et)|0,u=u+Math.imul(Fe,tt)|0,u=u+Math.imul(Le,et)|0,l=l+Math.imul(Le,tt)|0,R=R+Math.imul(Be,nt)|0,u=u+Math.imul(Be,rt)|0,u=u+Math.imul(He,nt)|0,l=l+Math.imul(He,rt)|0,R=R+Math.imul(Se,it)|0,u=u+Math.imul(Se,st)|0,u=u+Math.imul(Te,it)|0,l=l+Math.imul(Te,st)|0,R=R+Math.imul(ge,ot)|0,u=u+Math.imul(ge,at)|0,u=u+Math.imul(me,ot)|0,l=l+Math.imul(me,at)|0,R=R+Math.imul(j,ct)|0,u=u+Math.imul(j,ut)|0,u=u+Math.imul(ce,ct)|0,l=l+Math.imul(ce,ut)|0,R=R+Math.imul(k,lt)|0,u=u+Math.imul(k,ht)|0,u=u+Math.imul(P,lt)|0,l=l+Math.imul(P,ht)|0;var cs=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(cs>>>26)|0,cs&=67108863,R=Math.imul(F,fe),u=Math.imul(F,je),u=u+Math.imul(Y,fe)|0,l=Math.imul(Y,je),R=R+Math.imul(d,Ze)|0,u=u+Math.imul(d,Xe)|0,u=u+Math.imul(v,Ze)|0,l=l+Math.imul(v,Xe)|0,R=R+Math.imul(ze,Je)|0,u=u+Math.imul(ze,Qe)|0,u=u+Math.imul(_,Je)|0,l=l+Math.imul(_,Qe)|0,R=R+Math.imul(Ce,et)|0,u=u+Math.imul(Ce,tt)|0,u=u+Math.imul(De,et)|0,l=l+Math.imul(De,tt)|0,R=R+Math.imul(Fe,nt)|0,u=u+Math.imul(Fe,rt)|0,u=u+Math.imul(Le,nt)|0,l=l+Math.imul(Le,rt)|0,R=R+Math.imul(Be,it)|0,u=u+Math.imul(Be,st)|0,u=u+Math.imul(He,it)|0,l=l+Math.imul(He,st)|0,R=R+Math.imul(Se,ot)|0,u=u+Math.imul(Se,at)|0,u=u+Math.imul(Te,ot)|0,l=l+Math.imul(Te,at)|0,R=R+Math.imul(ge,ct)|0,u=u+Math.imul(ge,ut)|0,u=u+Math.imul(me,ct)|0,l=l+Math.imul(me,ut)|0,R=R+Math.imul(j,lt)|0,u=u+Math.imul(j,ht)|0,u=u+Math.imul(ce,lt)|0,l=l+Math.imul(ce,ht)|0;var us=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(us>>>26)|0,us&=67108863,R=Math.imul(F,Ze),u=Math.imul(F,Xe),u=u+Math.imul(Y,Ze)|0,l=Math.imul(Y,Xe),R=R+Math.imul(d,Je)|0,u=u+Math.imul(d,Qe)|0,u=u+Math.imul(v,Je)|0,l=l+Math.imul(v,Qe)|0,R=R+Math.imul(ze,et)|0,u=u+Math.imul(ze,tt)|0,u=u+Math.imul(_,et)|0,l=l+Math.imul(_,tt)|0,R=R+Math.imul(Ce,nt)|0,u=u+Math.imul(Ce,rt)|0,u=u+Math.imul(De,nt)|0,l=l+Math.imul(De,rt)|0,R=R+Math.imul(Fe,it)|0,u=u+Math.imul(Fe,st)|0,u=u+Math.imul(Le,it)|0,l=l+Math.imul(Le,st)|0,R=R+Math.imul(Be,ot)|0,u=u+Math.imul(Be,at)|0,u=u+Math.imul(He,ot)|0,l=l+Math.imul(He,at)|0,R=R+Math.imul(Se,ct)|0,u=u+Math.imul(Se,ut)|0,u=u+Math.imul(Te,ct)|0,l=l+Math.imul(Te,ut)|0,R=R+Math.imul(ge,lt)|0,u=u+Math.imul(ge,ht)|0,u=u+Math.imul(me,lt)|0,l=l+Math.imul(me,ht)|0;var ls=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(ls>>>26)|0,ls&=67108863,R=Math.imul(F,Je),u=Math.imul(F,Qe),u=u+Math.imul(Y,Je)|0,l=Math.imul(Y,Qe),R=R+Math.imul(d,et)|0,u=u+Math.imul(d,tt)|0,u=u+Math.imul(v,et)|0,l=l+Math.imul(v,tt)|0,R=R+Math.imul(ze,nt)|0,u=u+Math.imul(ze,rt)|0,u=u+Math.imul(_,nt)|0,l=l+Math.imul(_,rt)|0,R=R+Math.imul(Ce,it)|0,u=u+Math.imul(Ce,st)|0,u=u+Math.imul(De,it)|0,l=l+Math.imul(De,st)|0,R=R+Math.imul(Fe,ot)|0,u=u+Math.imul(Fe,at)|0,u=u+Math.imul(Le,ot)|0,l=l+Math.imul(Le,at)|0,R=R+Math.imul(Be,ct)|0,u=u+Math.imul(Be,ut)|0,u=u+Math.imul(He,ct)|0,l=l+Math.imul(He,ut)|0,R=R+Math.imul(Se,lt)|0,u=u+Math.imul(Se,ht)|0,u=u+Math.imul(Te,lt)|0,l=l+Math.imul(Te,ht)|0;var hs=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(hs>>>26)|0,hs&=67108863,R=Math.imul(F,et),u=Math.imul(F,tt),u=u+Math.imul(Y,et)|0,l=Math.imul(Y,tt),R=R+Math.imul(d,nt)|0,u=u+Math.imul(d,rt)|0,u=u+Math.imul(v,nt)|0,l=l+Math.imul(v,rt)|0,R=R+Math.imul(ze,it)|0,u=u+Math.imul(ze,st)|0,u=u+Math.imul(_,it)|0,l=l+Math.imul(_,st)|0,R=R+Math.imul(Ce,ot)|0,u=u+Math.imul(Ce,at)|0,u=u+Math.imul(De,ot)|0,l=l+Math.imul(De,at)|0,R=R+Math.imul(Fe,ct)|0,u=u+Math.imul(Fe,ut)|0,u=u+Math.imul(Le,ct)|0,l=l+Math.imul(Le,ut)|0,R=R+Math.imul(Be,lt)|0,u=u+Math.imul(Be,ht)|0,u=u+Math.imul(He,lt)|0,l=l+Math.imul(He,ht)|0;var fs=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(fs>>>26)|0,fs&=67108863,R=Math.imul(F,nt),u=Math.imul(F,rt),u=u+Math.imul(Y,nt)|0,l=Math.imul(Y,rt),R=R+Math.imul(d,it)|0,u=u+Math.imul(d,st)|0,u=u+Math.imul(v,it)|0,l=l+Math.imul(v,st)|0,R=R+Math.imul(ze,ot)|0,u=u+Math.imul(ze,at)|0,u=u+Math.imul(_,ot)|0,l=l+Math.imul(_,at)|0,R=R+Math.imul(Ce,ct)|0,u=u+Math.imul(Ce,ut)|0,u=u+Math.imul(De,ct)|0,l=l+Math.imul(De,ut)|0,R=R+Math.imul(Fe,lt)|0,u=u+Math.imul(Fe,ht)|0,u=u+Math.imul(Le,lt)|0,l=l+Math.imul(Le,ht)|0;var ds=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(ds>>>26)|0,ds&=67108863,R=Math.imul(F,it),u=Math.imul(F,st),u=u+Math.imul(Y,it)|0,l=Math.imul(Y,st),R=R+Math.imul(d,ot)|0,u=u+Math.imul(d,at)|0,u=u+Math.imul(v,ot)|0,l=l+Math.imul(v,at)|0,R=R+Math.imul(ze,ct)|0,u=u+Math.imul(ze,ut)|0,u=u+Math.imul(_,ct)|0,l=l+Math.imul(_,ut)|0,R=R+Math.imul(Ce,lt)|0,u=u+Math.imul(Ce,ht)|0,u=u+Math.imul(De,lt)|0,l=l+Math.imul(De,ht)|0;var ps=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(ps>>>26)|0,ps&=67108863,R=Math.imul(F,ot),u=Math.imul(F,at),u=u+Math.imul(Y,ot)|0,l=Math.imul(Y,at),R=R+Math.imul(d,ct)|0,u=u+Math.imul(d,ut)|0,u=u+Math.imul(v,ct)|0,l=l+Math.imul(v,ut)|0,R=R+Math.imul(ze,lt)|0,u=u+Math.imul(ze,ht)|0,u=u+Math.imul(_,lt)|0,l=l+Math.imul(_,ht)|0;var gs=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(gs>>>26)|0,gs&=67108863,R=Math.imul(F,ct),u=Math.imul(F,ut),u=u+Math.imul(Y,ct)|0,l=Math.imul(Y,ut),R=R+Math.imul(d,lt)|0,u=u+Math.imul(d,ht)|0,u=u+Math.imul(v,lt)|0,l=l+Math.imul(v,ht)|0;var ms=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(ms>>>26)|0,ms&=67108863,R=Math.imul(F,lt),u=Math.imul(F,ht),u=u+Math.imul(Y,lt)|0,l=Math.imul(Y,ht);var _s=(C+R|0)+((u&8191)<<13)|0;return C=(l+(u>>>13)|0)+(_s>>>26)|0,_s&=67108863,A[0]=Qi,A[1]=es,A[2]=ts,A[3]=ns,A[4]=rs,A[5]=is,A[6]=ss,A[7]=os,A[8]=as,A[9]=cs,A[10]=us,A[11]=ls,A[12]=hs,A[13]=fs,A[14]=ds,A[15]=ps,A[16]=gs,A[17]=ms,A[18]=_s,C!==0&&(A[19]=C,m.length++),m};Math.imul||(H=M);function K(S,c,p){p.negative=c.negative^S.negative,p.length=S.length+c.length;for(var m=0,I=0,E=0;E<p.length-1;E++){var A=I;I=0;for(var C=m&67108863,R=Math.min(E,c.length-1),u=Math.max(0,E-S.length+1);u<=R;u++){var l=E-u,y=S.words[l]|0,k=c.words[u]|0,P=y*k,G=P&67108863;A=A+(P/67108864|0)|0,G=G+C|0,C=G&67108863,A=A+(G>>>26)|0,I+=A>>>26,A&=67108863}p.words[E]=C,m=A,A=I}return m!==0?p.words[E]=m:p.length--,p._strip()}function Q(S,c,p){return K(S,c,p)}i.prototype.mulTo=function(c,p){var m,I=this.length+c.length;return this.length===10&&c.length===10?m=H(this,c,p):I<63?m=M(this,c,p):I<1024?m=K(this,c,p):m=Q(this,c,p),m},i.prototype.mul=function(c){var p=new i(null);return p.words=new Array(this.length+c.length),this.mulTo(c,p)},i.prototype.mulf=function(c){var p=new i(null);return p.words=new Array(this.length+c.length),Q(this,c,p)},i.prototype.imul=function(c){return this.clone().mulTo(c,this)},i.prototype.imuln=function(c){var p=c<0;p&&(c=-c),r(typeof c=="number"),r(c<67108864);for(var m=0,I=0;I<this.length;I++){var E=(this.words[I]|0)*c,A=(E&67108863)+(m&67108863);m>>=26,m+=E/67108864|0,m+=A>>>26,this.words[I]=A&67108863}return m!==0&&(this.words[I]=m,this.length++),this.length=c===0?1:this.length,p?this.ineg():this},i.prototype.muln=function(c){return this.clone().imuln(c)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(c){var p=N(c);if(p.length===0)return new i(1);for(var m=this,I=0;I<p.length&&p[I]===0;I++,m=m.sqr());if(++I<p.length)for(var E=m.sqr();I<p.length;I++,E=E.sqr())p[I]!==0&&(m=m.mul(E));return m},i.prototype.iushln=function(c){r(typeof c=="number"&&c>=0);var p=c%26,m=(c-p)/26,I=67108863>>>26-p<<26-p,E;if(p!==0){var A=0;for(E=0;E<this.length;E++){var C=this.words[E]&I,R=(this.words[E]|0)-C<<p;this.words[E]=R|A,A=C>>>26-p}A&&(this.words[E]=A,this.length++)}if(m!==0){for(E=this.length-1;E>=0;E--)this.words[E+m]=this.words[E];for(E=0;E<m;E++)this.words[E]=0;this.length+=m}return this._strip()},i.prototype.ishln=function(c){return r(this.negative===0),this.iushln(c)},i.prototype.iushrn=function(c,p,m){r(typeof c=="number"&&c>=0);var I;p?I=(p-p%26)/26:I=0;var E=c%26,A=Math.min((c-E)/26,this.length),C=67108863^67108863>>>E<<E,R=m;if(I-=A,I=Math.max(0,I),R){for(var u=0;u<A;u++)R.words[u]=this.words[u];R.length=A}if(A!==0)if(this.length>A)for(this.length-=A,u=0;u<this.length;u++)this.words[u]=this.words[u+A];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(l!==0||u>=I);u--){var y=this.words[u]|0;this.words[u]=l<<26-E|y>>>E,l=y&C}return R&&l!==0&&(R.words[R.length++]=l),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.ishrn=function(c,p,m){return r(this.negative===0),this.iushrn(c,p,m)},i.prototype.shln=function(c){return this.clone().ishln(c)},i.prototype.ushln=function(c){return this.clone().iushln(c)},i.prototype.shrn=function(c){return this.clone().ishrn(c)},i.prototype.ushrn=function(c){return this.clone().iushrn(c)},i.prototype.testn=function(c){r(typeof c=="number"&&c>=0);var p=c%26,m=(c-p)/26,I=1<<p;if(this.length<=m)return!1;var E=this.words[m];return!!(E&I)},i.prototype.imaskn=function(c){r(typeof c=="number"&&c>=0);var p=c%26,m=(c-p)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=m)return this;if(p!==0&&m++,this.length=Math.min(m,this.length),p!==0){var I=67108863^67108863>>>p<<p;this.words[this.length-1]&=I}return this._strip()},i.prototype.maskn=function(c){return this.clone().imaskn(c)},i.prototype.iaddn=function(c){return r(typeof c=="number"),r(c<67108864),c<0?this.isubn(-c):this.negative!==0?this.length===1&&(this.words[0]|0)<=c?(this.words[0]=c-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(c),this.negative=1,this):this._iaddn(c)},i.prototype._iaddn=function(c){this.words[0]+=c;for(var p=0;p<this.length&&this.words[p]>=67108864;p++)this.words[p]-=67108864,p===this.length-1?this.words[p+1]=1:this.words[p+1]++;return this.length=Math.max(this.length,p+1),this},i.prototype.isubn=function(c){if(r(typeof c=="number"),r(c<67108864),c<0)return this.iaddn(-c);if(this.negative!==0)return this.negative=0,this.iaddn(c),this.negative=1,this;if(this.words[0]-=c,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var p=0;p<this.length&&this.words[p]<0;p++)this.words[p]+=67108864,this.words[p+1]-=1;return this._strip()},i.prototype.addn=function(c){return this.clone().iaddn(c)},i.prototype.subn=function(c){return this.clone().isubn(c)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(c,p,m){var I=c.length+m,E;this._expand(I);var A,C=0;for(E=0;E<c.length;E++){A=(this.words[E+m]|0)+C;var R=(c.words[E]|0)*p;A-=R&67108863,C=(A>>26)-(R/67108864|0),this.words[E+m]=A&67108863}for(;E<this.length-m;E++)A=(this.words[E+m]|0)+C,C=A>>26,this.words[E+m]=A&67108863;if(C===0)return this._strip();for(r(C===-1),C=0,E=0;E<this.length;E++)A=-(this.words[E]|0)+C,C=A>>26,this.words[E]=A&67108863;return this.negative=1,this._strip()},i.prototype._wordDiv=function(c,p){var m=this.length-c.length,I=this.clone(),E=c,A=E.words[E.length-1]|0,C=this._countBits(A);m=26-C,m!==0&&(E=E.ushln(m),I.iushln(m),A=E.words[E.length-1]|0);var R=I.length-E.length,u;if(p!=="mod"){u=new i(null),u.length=R+1,u.words=new Array(u.length);for(var l=0;l<u.length;l++)u.words[l]=0}var y=I.clone()._ishlnsubmul(E,1,R);y.negative===0&&(I=y,u&&(u.words[R]=1));for(var k=R-1;k>=0;k--){var P=(I.words[E.length+k]|0)*67108864+(I.words[E.length+k-1]|0);for(P=Math.min(P/A|0,67108863),I._ishlnsubmul(E,P,k);I.negative!==0;)P--,I.negative=0,I._ishlnsubmul(E,1,k),I.isZero()||(I.negative^=1);u&&(u.words[k]=P)}return u&&u._strip(),I._strip(),p!=="div"&&m!==0&&I.iushrn(m),{div:u||null,mod:I}},i.prototype.divmod=function(c,p,m){if(r(!c.isZero()),this.isZero())return{div:new i(0),mod:new i(0)};var I,E,A;return this.negative!==0&&c.negative===0?(A=this.neg().divmod(c,p),p!=="mod"&&(I=A.div.neg()),p!=="div"&&(E=A.mod.neg(),m&&E.negative!==0&&E.iadd(c)),{div:I,mod:E}):this.negative===0&&c.negative!==0?(A=this.divmod(c.neg(),p),p!=="mod"&&(I=A.div.neg()),{div:I,mod:A.mod}):(this.negative&c.negative)!==0?(A=this.neg().divmod(c.neg(),p),p!=="div"&&(E=A.mod.neg(),m&&E.negative!==0&&E.isub(c)),{div:A.div,mod:E}):c.length>this.length||this.cmp(c)<0?{div:new i(0),mod:this}:c.length===1?p==="div"?{div:this.divn(c.words[0]),mod:null}:p==="mod"?{div:null,mod:new i(this.modrn(c.words[0]))}:{div:this.divn(c.words[0]),mod:new i(this.modrn(c.words[0]))}:this._wordDiv(c,p)},i.prototype.div=function(c){return this.divmod(c,"div",!1).div},i.prototype.mod=function(c){return this.divmod(c,"mod",!1).mod},i.prototype.umod=function(c){return this.divmod(c,"mod",!0).mod},i.prototype.divRound=function(c){var p=this.divmod(c);if(p.mod.isZero())return p.div;var m=p.div.negative!==0?p.mod.isub(c):p.mod,I=c.ushrn(1),E=c.andln(1),A=m.cmp(I);return A<0||E===1&&A===0?p.div:p.div.negative!==0?p.div.isubn(1):p.div.iaddn(1)},i.prototype.modrn=function(c){var p=c<0;p&&(c=-c),r(c<=67108863);for(var m=(1<<26)%c,I=0,E=this.length-1;E>=0;E--)I=(m*I+(this.words[E]|0))%c;return p?-I:I},i.prototype.modn=function(c){return this.modrn(c)},i.prototype.idivn=function(c){var p=c<0;p&&(c=-c),r(c<=67108863);for(var m=0,I=this.length-1;I>=0;I--){var E=(this.words[I]|0)+m*67108864;this.words[I]=E/c|0,m=E%c}return this._strip(),p?this.ineg():this},i.prototype.divn=function(c){return this.clone().idivn(c)},i.prototype.egcd=function(c){r(c.negative===0),r(!c.isZero());var p=this,m=c.clone();p.negative!==0?p=p.umod(c):p=p.clone();for(var I=new i(1),E=new i(0),A=new i(0),C=new i(1),R=0;p.isEven()&&m.isEven();)p.iushrn(1),m.iushrn(1),++R;for(var u=m.clone(),l=p.clone();!p.isZero();){for(var y=0,k=1;(p.words[0]&k)===0&&y<26;++y,k<<=1);if(y>0)for(p.iushrn(y);y-- >0;)(I.isOdd()||E.isOdd())&&(I.iadd(u),E.isub(l)),I.iushrn(1),E.iushrn(1);for(var P=0,G=1;(m.words[0]&G)===0&&P<26;++P,G<<=1);if(P>0)for(m.iushrn(P);P-- >0;)(A.isOdd()||C.isOdd())&&(A.iadd(u),C.isub(l)),A.iushrn(1),C.iushrn(1);p.cmp(m)>=0?(p.isub(m),I.isub(A),E.isub(C)):(m.isub(p),A.isub(I),C.isub(E))}return{a:A,b:C,gcd:m.iushln(R)}},i.prototype._invmp=function(c){r(c.negative===0),r(!c.isZero());var p=this,m=c.clone();p.negative!==0?p=p.umod(c):p=p.clone();for(var I=new i(1),E=new i(0),A=m.clone();p.cmpn(1)>0&&m.cmpn(1)>0;){for(var C=0,R=1;(p.words[0]&R)===0&&C<26;++C,R<<=1);if(C>0)for(p.iushrn(C);C-- >0;)I.isOdd()&&I.iadd(A),I.iushrn(1);for(var u=0,l=1;(m.words[0]&l)===0&&u<26;++u,l<<=1);if(u>0)for(m.iushrn(u);u-- >0;)E.isOdd()&&E.iadd(A),E.iushrn(1);p.cmp(m)>=0?(p.isub(m),I.isub(E)):(m.isub(p),E.isub(I))}var y;return p.cmpn(1)===0?y=I:y=E,y.cmpn(0)<0&&y.iadd(c),y},i.prototype.gcd=function(c){if(this.isZero())return c.abs();if(c.isZero())return this.abs();var p=this.clone(),m=c.clone();p.negative=0,m.negative=0;for(var I=0;p.isEven()&&m.isEven();I++)p.iushrn(1),m.iushrn(1);do{for(;p.isEven();)p.iushrn(1);for(;m.isEven();)m.iushrn(1);var E=p.cmp(m);if(E<0){var A=p;p=m,m=A}else if(E===0||m.cmpn(1)===0)break;p.isub(m)}while(!0);return m.iushln(I)},i.prototype.invm=function(c){return this.egcd(c).a.umod(c)},i.prototype.isEven=function(){return(this.words[0]&1)===0},i.prototype.isOdd=function(){return(this.words[0]&1)===1},i.prototype.andln=function(c){return this.words[0]&c},i.prototype.bincn=function(c){r(typeof c=="number");var p=c%26,m=(c-p)/26,I=1<<p;if(this.length<=m)return this._expand(m+1),this.words[m]|=I,this;for(var E=I,A=m;E!==0&&A<this.length;A++){var C=this.words[A]|0;C+=E,E=C>>>26,C&=67108863,this.words[A]=C}return E!==0&&(this.words[A]=E,this.length++),this},i.prototype.isZero=function(){return this.length===1&&this.words[0]===0},i.prototype.cmpn=function(c){var p=c<0;if(this.negative!==0&&!p)return-1;if(this.negative===0&&p)return 1;this._strip();var m;if(this.length>1)m=1;else{p&&(c=-c),r(c<=67108863,"Number is too big");var I=this.words[0]|0;m=I===c?0:I<c?-1:1}return this.negative!==0?-m|0:m},i.prototype.cmp=function(c){if(this.negative!==0&&c.negative===0)return-1;if(this.negative===0&&c.negative!==0)return 1;var p=this.ucmp(c);return this.negative!==0?-p|0:p},i.prototype.ucmp=function(c){if(this.length>c.length)return 1;if(this.length<c.length)return-1;for(var p=0,m=this.length-1;m>=0;m--){var I=this.words[m]|0,E=c.words[m]|0;if(I!==E){I<E?p=-1:I>E&&(p=1);break}}return p},i.prototype.gtn=function(c){return this.cmpn(c)===1},i.prototype.gt=function(c){return this.cmp(c)===1},i.prototype.gten=function(c){return this.cmpn(c)>=0},i.prototype.gte=function(c){return this.cmp(c)>=0},i.prototype.ltn=function(c){return this.cmpn(c)===-1},i.prototype.lt=function(c){return this.cmp(c)===-1},i.prototype.lten=function(c){return this.cmpn(c)<=0},i.prototype.lte=function(c){return this.cmp(c)<=0},i.prototype.eqn=function(c){return this.cmpn(c)===0},i.prototype.eq=function(c){return this.cmp(c)===0},i.red=function(c){return new V(c)},i.prototype.toRed=function(c){return r(!this.red,"Already a number in reduction context"),r(this.negative===0,"red works only with positives"),c.convertTo(this)._forceRed(c)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(c){return this.red=c,this},i.prototype.forceRed=function(c){return r(!this.red,"Already a number in reduction context"),this._forceRed(c)},i.prototype.redAdd=function(c){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,c)},i.prototype.redIAdd=function(c){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,c)},i.prototype.redSub=function(c){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,c)},i.prototype.redISub=function(c){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,c)},i.prototype.redShl=function(c){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,c)},i.prototype.redMul=function(c){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,c),this.red.mul(this,c)},i.prototype.redIMul=function(c){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,c),this.red.imul(this,c)},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(c){return r(this.red&&!c.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,c)};var q={k256:null,p224:null,p192:null,p25519:null};function D(S,c){this.name=S,this.p=new i(c,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}D.prototype._tmp=function(){var c=new i(null);return c.words=new Array(Math.ceil(this.n/13)),c},D.prototype.ireduce=function(c){var p=c,m;do this.split(p,this.tmp),p=this.imulK(p),p=p.iadd(this.tmp),m=p.bitLength();while(m>this.n);var I=m<this.n?-1:p.ucmp(this.p);return I===0?(p.words[0]=0,p.length=1):I>0?p.isub(this.p):p.strip!==void 0?p.strip():p._strip(),p},D.prototype.split=function(c,p){c.iushrn(this.n,0,p)},D.prototype.imulK=function(c){return c.imul(this.k)};function X(){D.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}s(X,D),X.prototype.split=function(c,p){for(var m=4194303,I=Math.min(c.length,9),E=0;E<I;E++)p.words[E]=c.words[E];if(p.length=I,c.length<=9){c.words[0]=0,c.length=1;return}var A=c.words[9];for(p.words[p.length++]=A&m,E=10;E<c.length;E++){var C=c.words[E]|0;c.words[E-10]=(C&m)<<4|A>>>22,A=C}A>>>=22,c.words[E-10]=A,A===0&&c.length>10?c.length-=10:c.length-=9},X.prototype.imulK=function(c){c.words[c.length]=0,c.words[c.length+1]=0,c.length+=2;for(var p=0,m=0;m<c.length;m++){var I=c.words[m]|0;p+=I*977,c.words[m]=p&67108863,p=I*64+(p/67108864|0)}return c.words[c.length-1]===0&&(c.length--,c.words[c.length-1]===0&&c.length--),c};function Z(){D.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}s(Z,D);function J(){D.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}s(J,D);function z(){D.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}s(z,D),z.prototype.imulK=function(c){for(var p=0,m=0;m<c.length;m++){var I=(c.words[m]|0)*19+p,E=I&67108863;I>>>=26,c.words[m]=E,p=I}return p!==0&&(c.words[c.length++]=p),c},i._prime=function(c){if(q[c])return q[c];var p;if(c==="k256")p=new X;else if(c==="p224")p=new Z;else if(c==="p192")p=new J;else if(c==="p25519")p=new z;else throw new Error("Unknown prime "+c);return q[c]=p,p};function V(S){if(typeof S=="string"){var c=i._prime(S);this.m=c.p,this.prime=c}else r(S.gtn(1),"modulus must be greater than 1"),this.m=S,this.prime=null}V.prototype._verify1=function(c){r(c.negative===0,"red works only with positives"),r(c.red,"red works only with red numbers")},V.prototype._verify2=function(c,p){r((c.negative|p.negative)===0,"red works only with positives"),r(c.red&&c.red===p.red,"red works only with red numbers")},V.prototype.imod=function(c){return this.prime?this.prime.ireduce(c)._forceRed(this):(w(c,c.umod(this.m)._forceRed(this)),c)},V.prototype.neg=function(c){return c.isZero()?c.clone():this.m.sub(c)._forceRed(this)},V.prototype.add=function(c,p){this._verify2(c,p);var m=c.add(p);return m.cmp(this.m)>=0&&m.isub(this.m),m._forceRed(this)},V.prototype.iadd=function(c,p){this._verify2(c,p);var m=c.iadd(p);return m.cmp(this.m)>=0&&m.isub(this.m),m},V.prototype.sub=function(c,p){this._verify2(c,p);var m=c.sub(p);return m.cmpn(0)<0&&m.iadd(this.m),m._forceRed(this)},V.prototype.isub=function(c,p){this._verify2(c,p);var m=c.isub(p);return m.cmpn(0)<0&&m.iadd(this.m),m},V.prototype.shl=function(c,p){return this._verify1(c),this.imod(c.ushln(p))},V.prototype.imul=function(c,p){return this._verify2(c,p),this.imod(c.imul(p))},V.prototype.mul=function(c,p){return this._verify2(c,p),this.imod(c.mul(p))},V.prototype.isqr=function(c){return this.imul(c,c.clone())},V.prototype.sqr=function(c){return this.mul(c,c)},V.prototype.sqrt=function(c){if(c.isZero())return c.clone();var p=this.m.andln(3);if(r(p%2===1),p===3){var m=this.m.add(new i(1)).iushrn(2);return this.pow(c,m)}for(var I=this.m.subn(1),E=0;!I.isZero()&&I.andln(1)===0;)E++,I.iushrn(1);r(!I.isZero());var A=new i(1).toRed(this),C=A.redNeg(),R=this.m.subn(1).iushrn(1),u=this.m.bitLength();for(u=new i(2*u*u).toRed(this);this.pow(u,R).cmp(C)!==0;)u.redIAdd(C);for(var l=this.pow(u,I),y=this.pow(c,I.addn(1).iushrn(1)),k=this.pow(c,I),P=E;k.cmp(A)!==0;){for(var G=k,j=0;G.cmp(A)!==0;j++)G=G.redSqr();r(j<P);var ce=this.pow(l,new i(1).iushln(P-j-1));y=y.redMul(ce),l=ce.redSqr(),k=k.redMul(l),P=j}return y},V.prototype.invm=function(c){var p=c._invmp(this.m);return p.negative!==0?(p.negative=0,this.imod(p).redNeg()):this.imod(p)},V.prototype.pow=function(c,p){if(p.isZero())return new i(1).toRed(this);if(p.cmpn(1)===0)return c.clone();var m=4,I=new Array(1<<m);I[0]=new i(1).toRed(this),I[1]=c;for(var E=2;E<I.length;E++)I[E]=this.mul(I[E-1],c);var A=I[0],C=0,R=0,u=p.bitLength()%26;for(u===0&&(u=26),E=p.length-1;E>=0;E--){for(var l=p.words[E],y=u-1;y>=0;y--){var k=l>>y&1;if(A!==I[0]&&(A=this.sqr(A)),k===0&&C===0){R=0;continue}C<<=1,C|=k,R++,!(R!==m&&(E!==0||y!==0))&&(A=this.mul(A,I[C]),R=0,C=0)}u=26}return A},V.prototype.convertTo=function(c){var p=c.umod(this.m);return p===c?p.clone():p},V.prototype.convertFrom=function(c){var p=c.clone();return p.red=null,p},i.mont=function(c){return new ee(c)};function ee(S){V.call(this,S),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)}s(ee,V),ee.prototype.convertTo=function(c){return this.imod(c.ushln(this.shift))},ee.prototype.convertFrom=function(c){var p=this.imod(c.mul(this.rinv));return p.red=null,p},ee.prototype.imul=function(c,p){if(c.isZero()||p.isZero())return c.words[0]=0,c.length=1,c;var m=c.imul(p),I=m.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),E=m.isub(I).iushrn(this.shift),A=E;return E.cmp(this.m)>=0?A=E.isub(this.m):E.cmpn(0)<0&&(A=E.iadd(this.m)),A._forceRed(this)},ee.prototype.mul=function(c,p){if(c.isZero()||p.isZero())return new i(0)._forceRed(this);var m=c.mul(p),I=m.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),E=m.isub(I).iushrn(this.shift),A=E;return E.cmp(this.m)>=0?A=E.isub(this.m):E.cmpn(0)<0&&(A=E.iadd(this.m)),A._forceRed(this)},ee.prototype.invm=function(c){var p=this.imod(c._invmp(this.m).mul(this.r2));return p._forceRed(this)}})(n,eu)}(cr)),cr.exports}var tu=Qs();const eo=Fn(tu);var ur={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var to;function nu(){return to||(to=1,function(n,e){var t=zr(),r=t.Buffer;function s(o,a){for(var f in o)a[f]=o[f]}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?n.exports=t:(s(t,e),e.Buffer=i);function i(o,a,f){return r(o,a,f)}i.prototype=Object.create(r.prototype),s(r,i),i.from=function(o,a,f){if(typeof o=="number")throw new TypeError("Argument must not be a number");return r(o,a,f)},i.alloc=function(o,a,f){if(typeof o!="number")throw new TypeError("Argument must be a number");var g=r(o);return a!==void 0?typeof f=="string"?g.fill(a,f):g.fill(a):g.fill(0),g},i.allocUnsafe=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return r(o)},i.allocUnsafeSlow=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return t.SlowBuffer(o)}}(ur,ur.exports)),ur.exports}var ei,no;function ru(){if(no)return ei;no=1;var n=nu().Buffer;function e(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),s=0;s<r.length;s++)r[s]=255;for(var i=0;i<t.length;i++){var o=t.charAt(i),a=o.charCodeAt(0);if(r[a]!==255)throw new TypeError(o+" is ambiguous");r[a]=i}var f=t.length,g=t.charAt(0),w=Math.log(f)/Math.log(256),b=Math.log(256)/Math.log(f);function x(O){if((Array.isArray(O)||O instanceof Uint8Array)&&(O=n.from(O)),!n.isBuffer(O))throw new TypeError("Expected Buffer");if(O.length===0)return"";for(var N=0,M=0,H=0,K=O.length;H!==K&&O[H]===0;)H++,N++;for(var Q=(K-H)*b+1>>>0,q=new Uint8Array(Q);H!==K;){for(var D=O[H],X=0,Z=Q-1;(D!==0||X<M)&&Z!==-1;Z--,X++)D+=256*q[Z]>>>0,q[Z]=D%f>>>0,D=D/f>>>0;if(D!==0)throw new Error("Non-zero carry");M=X,H++}for(var J=Q-M;J!==Q&&q[J]===0;)J++;for(var z=g.repeat(N);J<Q;++J)z+=t.charAt(q[J]);return z}function T(O){if(typeof O!="string")throw new TypeError("Expected String");if(O.length===0)return n.alloc(0);for(var N=0,M=0,H=0;O[N]===g;)M++,N++;for(var K=(O.length-N)*w+1>>>0,Q=new Uint8Array(K);N<O.length;){var q=O.charCodeAt(N);if(q>255)return;var D=r[q];if(D===255)return;for(var X=0,Z=K-1;(D!==0||X<H)&&Z!==-1;Z--,X++)D+=f*Q[Z]>>>0,Q[Z]=D%256>>>0,D=D/256>>>0;if(D!==0)throw new Error("Non-zero carry");H=X,N++}for(var J=K-H;J!==K&&Q[J]===0;)J++;var z=n.allocUnsafe(M+(K-J));z.fill(0,0,M);for(var V=M;J!==K;)z[V++]=Q[J++];return z}function L(O){var N=T(O);if(N)return N;throw new Error("Non-base"+f+" character")}return{encode:x,decodeUnsafe:T,decode:L}}return ei=e,ei}var ti,ro;function io(){if(ro)return ti;ro=1;var n=ru(),e="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";return ti=n(e),ti}var iu=io();const pt=Fn(iu),su=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]),Qt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),en=new Uint32Array(64);class ou extends xs{constructor(){super(64,32,8,!1),this.A=Qt[0]|0,this.B=Qt[1]|0,this.C=Qt[2]|0,this.D=Qt[3]|0,this.E=Qt[4]|0,this.F=Qt[5]|0,this.G=Qt[6]|0,this.H=Qt[7]|0}get(){const{A:e,B:t,C:r,D:s,E:i,F:o,G:a,H:f}=this;return[e,t,r,s,i,o,a,f]}set(e,t,r,s,i,o,a,f){this.A=e|0,this.B=t|0,this.C=r|0,this.D=s|0,this.E=i|0,this.F=o|0,this.G=a|0,this.H=f|0}process(e,t){for(let b=0;b<16;b++,t+=4)en[b]=e.getUint32(t,!1);for(let b=16;b<64;b++){const x=en[b-15],T=en[b-2],L=Ct(x,7)^Ct(x,18)^x>>>3,O=Ct(T,17)^Ct(T,19)^T>>>10;en[b]=O+en[b-7]+L+en[b-16]|0}let{A:r,B:s,C:i,D:o,E:a,F:f,G:g,H:w}=this;for(let b=0;b<64;b++){const x=Ct(a,6)^Ct(a,11)^Ct(a,25),T=w+x+ic(a,f,g)+su[b]+en[b]|0,O=(Ct(r,2)^Ct(r,13)^Ct(r,22))+sc(r,s,i)|0;w=g,g=f,f=a,a=o+T|0,o=i,i=s,s=r,r=T+O|0}r=r+this.A|0,s=s+this.B|0,i=i+this.C|0,o=o+this.D|0,a=a+this.E|0,f=f+this.F|0,g=g+this.G|0,w=w+this.H|0,this.set(r,s,i,o,a,f,g,w)}roundClean(){en.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const ni=Wr(()=>new ou);var Ne={};function Vt(n,e,t){return e<=n&&n<=t}function lr(n){if(n===void 0)return{};if(n===Object(n))return n;throw TypeError("Could not convert argument to dictionary")}function au(n){for(var e=String(n),t=e.length,r=0,s=[];r<t;){var i=e.charCodeAt(r);if(i<55296||i>57343)s.push(i);else if(56320<=i&&i<=57343)s.push(65533);else if(55296<=i&&i<=56319)if(r===t-1)s.push(65533);else{var o=n.charCodeAt(r+1);if(56320<=o&&o<=57343){var a=i&1023,f=o&1023;s.push(65536+(a<<10)+f),r+=1}else s.push(65533)}r+=1}return s}function cu(n){for(var e="",t=0;t<n.length;++t){var r=n[t];r<=65535?e+=String.fromCharCode(r):(r-=65536,e+=String.fromCharCode((r>>10)+55296,(r&1023)+56320))}return e}var hr=-1;function ri(n){this.tokens=[].slice.call(n)}ri.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():hr},prepend:function(n){if(Array.isArray(n))for(var e=n;e.length;)this.tokens.unshift(e.pop());else this.tokens.unshift(n)},push:function(n){if(Array.isArray(n))for(var e=n;e.length;)this.tokens.push(e.shift());else this.tokens.push(n)}};var vn=-1;function ii(n,e){if(n)throw TypeError("Decoder error");return e||65533}var fr="utf-8";function dr(n,e){if(!(this instanceof dr))return new dr(n,e);if(n=n!==void 0?String(n).toLowerCase():fr,n!==fr)throw new Error("Encoding not supported. Only utf-8 is supported");e=lr(e),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=!!e.fatal,this._ignoreBOM=!!e.ignoreBOM,Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}dr.prototype={decode:function(e,t){var r;typeof e=="object"&&e instanceof ArrayBuffer?r=new Uint8Array(e):typeof e=="object"&&"buffer"in e&&e.buffer instanceof ArrayBuffer?r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):r=new Uint8Array(0),t=lr(t),this._streaming||(this._decoder=new uu({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!t.stream;for(var s=new ri(r),i=[],o;!s.endOfStream()&&(o=this._decoder.handler(s,s.read()),o!==vn);)o!==null&&(Array.isArray(o)?i.push.apply(i,o):i.push(o));if(!this._streaming){do{if(o=this._decoder.handler(s,s.read()),o===vn)break;o!==null&&(Array.isArray(o)?i.push.apply(i,o):i.push(o))}while(!s.endOfStream());this._decoder=null}return i.length&&["utf-8"].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(i[0]===65279?(this._BOMseen=!0,i.shift()):this._BOMseen=!0),cu(i)}};function pr(n,e){if(!(this instanceof pr))return new pr(n,e);if(n=n!==void 0?String(n).toLowerCase():fr,n!==fr)throw new Error("Encoding not supported. Only utf-8 is supported");e=lr(e),this._streaming=!1,this._encoder=null,this._options={fatal:!!e.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}pr.prototype={encode:function(e,t){e=e?String(e):"",t=lr(t),this._streaming||(this._encoder=new lu(this._options)),this._streaming=!!t.stream;for(var r=[],s=new ri(au(e)),i;!s.endOfStream()&&(i=this._encoder.handler(s,s.read()),i!==vn);)Array.isArray(i)?r.push.apply(r,i):r.push(i);if(!this._streaming){for(;i=this._encoder.handler(s,s.read()),i!==vn;)Array.isArray(i)?r.push.apply(r,i):r.push(i);this._encoder=null}return new Uint8Array(r)}};function uu(n){var e=n.fatal,t=0,r=0,s=0,i=128,o=191;this.handler=function(a,f){if(f===hr&&s!==0)return s=0,ii(e);if(f===hr)return vn;if(s===0){if(Vt(f,0,127))return f;if(Vt(f,194,223))s=1,t=f-192;else if(Vt(f,224,239))f===224&&(i=160),f===237&&(o=159),s=2,t=f-224;else if(Vt(f,240,244))f===240&&(i=144),f===244&&(o=143),s=3,t=f-240;else return ii(e);return t=t<<6*s,null}if(!Vt(f,i,o))return t=s=r=0,i=128,o=191,a.prepend(f),ii(e);if(i=128,o=191,r+=1,t+=f-128<<6*(s-r),r!==s)return null;var g=t;return t=s=r=0,g}}function lu(n){n.fatal,this.handler=function(e,t){if(t===hr)return vn;if(Vt(t,0,127))return t;var r,s;Vt(t,128,2047)?(r=1,s=192):Vt(t,2048,65535)?(r=2,s=224):Vt(t,65536,1114111)&&(r=3,s=240);for(var i=[(t>>6*r)+s];r>0;){var o=t>>6*(r-1);i.push(128|o&63),r-=1}return i}}const hu=Dr(Object.freeze(Object.defineProperty({__proto__:null,TextDecoder:dr,TextEncoder:pr},Symbol.toStringTag,{value:"Module"})));var so;function fu(){if(so)return Ne;so=1;var n=Ne&&Ne.__createBinding||(Object.create?function(J,z,V,ee){ee===void 0&&(ee=V),Object.defineProperty(J,ee,{enumerable:!0,get:function(){return z[V]}})}:function(J,z,V,ee){ee===void 0&&(ee=V),J[ee]=z[V]}),e=Ne&&Ne.__setModuleDefault||(Object.create?function(J,z){Object.defineProperty(J,"default",{enumerable:!0,value:z})}:function(J,z){J.default=z}),t=Ne&&Ne.__decorate||function(J,z,V,ee){var S=arguments.length,c=S<3?z:ee===null?ee=Object.getOwnPropertyDescriptor(z,V):ee,p;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")c=Reflect.decorate(J,z,V,ee);else for(var m=J.length-1;m>=0;m--)(p=J[m])&&(c=(S<3?p(c):S>3?p(z,V,c):p(z,V))||c);return S>3&&c&&Object.defineProperty(z,V,c),c},r=Ne&&Ne.__importStar||function(J){if(J&&J.__esModule)return J;var z={};if(J!=null)for(var V in J)V!=="default"&&Object.hasOwnProperty.call(J,V)&&n(z,J,V);return e(z,J),z},s=Ne&&Ne.__importDefault||function(J){return J&&J.__esModule?J:{default:J}};Object.defineProperty(Ne,"__esModule",{value:!0}),Ne.deserializeUnchecked=Ne.deserialize=Ne.serialize=Ne.BinaryReader=Ne.BinaryWriter=Ne.BorshError=Ne.baseDecode=Ne.baseEncode=void 0;const i=s(Qs()),o=s(io()),a=r(hu),f=typeof TextDecoder!="function"?a.TextDecoder:TextDecoder,g=new f("utf-8",{fatal:!0});function w(J){return typeof J=="string"&&(J=Buffer.from(J,"utf8")),o.default.encode(Buffer.from(J))}Ne.baseEncode=w;function b(J){return Buffer.from(o.default.decode(J))}Ne.baseDecode=b;const x=1024;class T extends Error{constructor(z){super(z),this.fieldPath=[],this.originalMessage=z}addToFieldPath(z){this.fieldPath.splice(0,0,z),this.message=this.originalMessage+": "+this.fieldPath.join(".")}}Ne.BorshError=T;class L{constructor(){this.buf=Buffer.alloc(x),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(x)]))}writeU8(z){this.maybeResize(),this.buf.writeUInt8(z,this.length),this.length+=1}writeU16(z){this.maybeResize(),this.buf.writeUInt16LE(z,this.length),this.length+=2}writeU32(z){this.maybeResize(),this.buf.writeUInt32LE(z,this.length),this.length+=4}writeU64(z){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(z).toArray("le",8)))}writeU128(z){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(z).toArray("le",16)))}writeU256(z){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(z).toArray("le",32)))}writeU512(z){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(z).toArray("le",64)))}writeBuffer(z){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),z,Buffer.alloc(x)]),this.length+=z.length}writeString(z){this.maybeResize();const V=Buffer.from(z,"utf8");this.writeU32(V.length),this.writeBuffer(V)}writeFixedArray(z){this.writeBuffer(Buffer.from(z))}writeArray(z,V){this.maybeResize(),this.writeU32(z.length);for(const ee of z)this.maybeResize(),V(ee)}toArray(){return this.buf.subarray(0,this.length)}}Ne.BinaryWriter=L;function O(J,z,V){const ee=V.value;V.value=function(...S){try{return ee.apply(this,S)}catch(c){if(c instanceof RangeError){const p=c.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(p)>=0)throw new T("Reached the end of buffer when deserializing")}throw c}}}class N{constructor(z){this.buf=z,this.offset=0}readU8(){const z=this.buf.readUInt8(this.offset);return this.offset+=1,z}readU16(){const z=this.buf.readUInt16LE(this.offset);return this.offset+=2,z}readU32(){const z=this.buf.readUInt32LE(this.offset);return this.offset+=4,z}readU64(){const z=this.readBuffer(8);return new i.default(z,"le")}readU128(){const z=this.readBuffer(16);return new i.default(z,"le")}readU256(){const z=this.readBuffer(32);return new i.default(z,"le")}readU512(){const z=this.readBuffer(64);return new i.default(z,"le")}readBuffer(z){if(this.offset+z>this.buf.length)throw new T(`Expected buffer length ${z} isn't within bounds`);const V=this.buf.slice(this.offset,this.offset+z);return this.offset+=z,V}readString(){const z=this.readU32(),V=this.readBuffer(z);try{return g.decode(V)}catch(ee){throw new T(`Error decoding UTF-8 string: ${ee}`)}}readFixedArray(z){return new Uint8Array(this.readBuffer(z))}readArray(z){const V=this.readU32(),ee=Array();for(let S=0;S<V;++S)ee.push(z());return ee}}t([O],N.prototype,"readU8",null),t([O],N.prototype,"readU16",null),t([O],N.prototype,"readU32",null),t([O],N.prototype,"readU64",null),t([O],N.prototype,"readU128",null),t([O],N.prototype,"readU256",null),t([O],N.prototype,"readU512",null),t([O],N.prototype,"readString",null),t([O],N.prototype,"readFixedArray",null),t([O],N.prototype,"readArray",null),Ne.BinaryReader=N;function M(J){return J.charAt(0).toUpperCase()+J.slice(1)}function H(J,z,V,ee,S){try{if(typeof ee=="string")S[`write${M(ee)}`](V);else if(ee instanceof Array)if(typeof ee[0]=="number"){if(V.length!==ee[0])throw new T(`Expecting byte array of length ${ee[0]}, but got ${V.length} bytes`);S.writeFixedArray(V)}else if(ee.length===2&&typeof ee[1]=="number"){if(V.length!==ee[1])throw new T(`Expecting byte array of length ${ee[1]}, but got ${V.length} bytes`);for(let c=0;c<ee[1];c++)H(J,null,V[c],ee[0],S)}else S.writeArray(V,c=>{H(J,z,c,ee[0],S)});else if(ee.kind!==void 0)switch(ee.kind){case"option":{V==null?S.writeU8(0):(S.writeU8(1),H(J,z,V,ee.type,S));break}case"map":{S.writeU32(V.size),V.forEach((c,p)=>{H(J,z,p,ee.key,S),H(J,z,c,ee.value,S)});break}default:throw new T(`FieldType ${ee} unrecognized`)}else K(J,V,S)}catch(c){throw c instanceof T&&c.addToFieldPath(z),c}}function K(J,z,V){if(typeof z.borshSerialize=="function"){z.borshSerialize(V);return}const ee=J.get(z.constructor);if(!ee)throw new T(`Class ${z.constructor.name} is missing in schema`);if(ee.kind==="struct")ee.fields.map(([S,c])=>{H(J,S,z[S],c,V)});else if(ee.kind==="enum"){const S=z[ee.field];for(let c=0;c<ee.values.length;++c){const[p,m]=ee.values[c];if(p===S){V.writeU8(c),H(J,p,z[p],m,V);break}}}else throw new T(`Unexpected schema kind: ${ee.kind} for ${z.constructor.name}`)}function Q(J,z,V=L){const ee=new V;return K(J,z,ee),ee.toArray()}Ne.serialize=Q;function q(J,z,V,ee){try{if(typeof V=="string")return ee[`read${M(V)}`]();if(V instanceof Array){if(typeof V[0]=="number")return ee.readFixedArray(V[0]);if(typeof V[1]=="number"){const S=[];for(let c=0;c<V[1];c++)S.push(q(J,null,V[0],ee));return S}else return ee.readArray(()=>q(J,z,V[0],ee))}if(V.kind==="option")return ee.readU8()?q(J,z,V.type,ee):void 0;if(V.kind==="map"){let S=new Map;const c=ee.readU32();for(let p=0;p<c;p++){const m=q(J,z,V.key,ee),I=q(J,z,V.value,ee);S.set(m,I)}return S}return D(J,V,ee)}catch(S){throw S instanceof T&&S.addToFieldPath(z),S}}function D(J,z,V){if(typeof z.borshDeserialize=="function")return z.borshDeserialize(V);const ee=J.get(z);if(!ee)throw new T(`Class ${z.name} is missing in schema`);if(ee.kind==="struct"){const S={};for(const[c,p]of J.get(z).fields)S[c]=q(J,c,p,V);return new z(S)}if(ee.kind==="enum"){const S=V.readU8();if(S>=ee.values.length)throw new T(`Enum index: ${S} is out of range`);const[c,p]=ee.values[S],m=q(J,c,p,V);return new z({[c]:m})}throw new T(`Unexpected schema kind: ${ee.kind} for ${z.constructor.name}`)}function X(J,z,V,ee=N){const S=new ee(V),c=D(J,z,S);if(S.offset<V.length)throw new T(`Unexpected ${V.length-S.offset} bytes after deserialized data`);return c}Ne.deserialize=X;function Z(J,z,V,ee=N){const S=new ee(V);return D(J,z,S)}return Ne.deserializeUnchecked=Z,Ne}var si=fu(),W={},oo;function du(){if(oo)return W;oo=1,Object.defineProperty(W,"__esModule",{value:!0}),W.s16=W.s8=W.nu64be=W.u48be=W.u40be=W.u32be=W.u24be=W.u16be=W.nu64=W.u48=W.u40=W.u32=W.u24=W.u16=W.u8=W.offset=W.greedy=W.Constant=W.UTF8=W.CString=W.Blob=W.Boolean=W.BitField=W.BitStructure=W.VariantLayout=W.Union=W.UnionLayoutDiscriminator=W.UnionDiscriminator=W.Structure=W.Sequence=W.DoubleBE=W.Double=W.FloatBE=W.Float=W.NearInt64BE=W.NearInt64=W.NearUInt64BE=W.NearUInt64=W.IntBE=W.Int=W.UIntBE=W.UInt=W.OffsetLayout=W.GreedyCount=W.ExternalLayout=W.bindConstructorLayout=W.nameWithProperty=W.Layout=W.uint8ArrayToBuffer=W.checkUint8Array=void 0,W.constant=W.utf8=W.cstr=W.blob=W.unionLayoutDiscriminator=W.union=W.seq=W.bits=W.struct=W.f64be=W.f64=W.f32be=W.f32=W.ns64be=W.s48be=W.s40be=W.s32be=W.s24be=W.s16be=W.ns64=W.s48=W.s40=W.s32=W.s24=void 0;const n=zr();function e(u){if(!(u instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}W.checkUint8Array=e;function t(u){return e(u),n.Buffer.from(u.buffer,u.byteOffset,u.length)}W.uint8ArrayToBuffer=t;let r=class{constructor(l,y){if(!Number.isInteger(l))throw new TypeError("span must be an integer");this.span=l,this.property=y}makeDestinationObject(){return{}}getSpan(l,y){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(l){const y=Object.create(this.constructor.prototype);return Object.assign(y,this),y.property=l,y}fromArray(l){}};W.Layout=r;function s(u,l){return l.property?u+"["+l.property+"]":u}W.nameWithProperty=s;function i(u,l){if(typeof u!="function")throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(u,"layout_"))throw new Error("Class is already bound to a layout");if(!(l&&l instanceof r))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(l,"boundConstructor_"))throw new Error("layout is already bound to a constructor");u.layout_=l,l.boundConstructor_=u,l.makeDestinationObject=()=>new u,Object.defineProperty(u.prototype,"encode",{value(y,k){return l.encode(this,y,k)},writable:!0}),Object.defineProperty(u,"decode",{value(y,k){return l.decode(y,k)},writable:!0})}W.bindConstructorLayout=i;class o extends r{isCount(){throw new Error("ExternalLayout is abstract")}}W.ExternalLayout=o;class a extends o{constructor(l=1,y){if(!Number.isInteger(l)||0>=l)throw new TypeError("elementSpan must be a (positive) integer");super(-1,y),this.elementSpan=l}isCount(){return!0}decode(l,y=0){e(l);const k=l.length-y;return Math.floor(k/this.elementSpan)}encode(l,y,k){return 0}}W.GreedyCount=a;class f extends o{constructor(l,y=0,k){if(!(l instanceof r))throw new TypeError("layout must be a Layout");if(!Number.isInteger(y))throw new TypeError("offset must be integer or undefined");super(l.span,k||l.property),this.layout=l,this.offset=y}isCount(){return this.layout instanceof g||this.layout instanceof w}decode(l,y=0){return this.layout.decode(l,y+this.offset)}encode(l,y,k=0){return this.layout.encode(l,y,k+this.offset)}}W.OffsetLayout=f;class g extends r{constructor(l,y){if(super(l,y),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,y=0){return t(l).readUIntLE(y,this.span)}encode(l,y,k=0){return t(y).writeUIntLE(l,k,this.span),this.span}}W.UInt=g;class w extends r{constructor(l,y){if(super(l,y),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,y=0){return t(l).readUIntBE(y,this.span)}encode(l,y,k=0){return t(y).writeUIntBE(l,k,this.span),this.span}}W.UIntBE=w;class b extends r{constructor(l,y){if(super(l,y),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,y=0){return t(l).readIntLE(y,this.span)}encode(l,y,k=0){return t(y).writeIntLE(l,k,this.span),this.span}}W.Int=b;class x extends r{constructor(l,y){if(super(l,y),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,y=0){return t(l).readIntBE(y,this.span)}encode(l,y,k=0){return t(y).writeIntBE(l,k,this.span),this.span}}W.IntBE=x;const T=Math.pow(2,32);function L(u){const l=Math.floor(u/T),y=u-l*T;return{hi32:l,lo32:y}}function O(u,l){return u*T+l}class N extends r{constructor(l){super(8,l)}decode(l,y=0){const k=t(l),P=k.readUInt32LE(y),G=k.readUInt32LE(y+4);return O(G,P)}encode(l,y,k=0){const P=L(l),G=t(y);return G.writeUInt32LE(P.lo32,k),G.writeUInt32LE(P.hi32,k+4),8}}W.NearUInt64=N;class M extends r{constructor(l){super(8,l)}decode(l,y=0){const k=t(l),P=k.readUInt32BE(y),G=k.readUInt32BE(y+4);return O(P,G)}encode(l,y,k=0){const P=L(l),G=t(y);return G.writeUInt32BE(P.hi32,k),G.writeUInt32BE(P.lo32,k+4),8}}W.NearUInt64BE=M;class H extends r{constructor(l){super(8,l)}decode(l,y=0){const k=t(l),P=k.readUInt32LE(y),G=k.readInt32LE(y+4);return O(G,P)}encode(l,y,k=0){const P=L(l),G=t(y);return G.writeUInt32LE(P.lo32,k),G.writeInt32LE(P.hi32,k+4),8}}W.NearInt64=H;class K extends r{constructor(l){super(8,l)}decode(l,y=0){const k=t(l),P=k.readInt32BE(y),G=k.readUInt32BE(y+4);return O(P,G)}encode(l,y,k=0){const P=L(l),G=t(y);return G.writeInt32BE(P.hi32,k),G.writeUInt32BE(P.lo32,k+4),8}}W.NearInt64BE=K;class Q extends r{constructor(l){super(4,l)}decode(l,y=0){return t(l).readFloatLE(y)}encode(l,y,k=0){return t(y).writeFloatLE(l,k),4}}W.Float=Q;class q extends r{constructor(l){super(4,l)}decode(l,y=0){return t(l).readFloatBE(y)}encode(l,y,k=0){return t(y).writeFloatBE(l,k),4}}W.FloatBE=q;class D extends r{constructor(l){super(8,l)}decode(l,y=0){return t(l).readDoubleLE(y)}encode(l,y,k=0){return t(y).writeDoubleLE(l,k),8}}W.Double=D;class X extends r{constructor(l){super(8,l)}decode(l,y=0){return t(l).readDoubleBE(y)}encode(l,y,k=0){return t(y).writeDoubleBE(l,k),8}}W.DoubleBE=X;class Z extends r{constructor(l,y,k){if(!(l instanceof r))throw new TypeError("elementLayout must be a Layout");if(!(y instanceof o&&y.isCount()||Number.isInteger(y)&&0<=y))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let P=-1;!(y instanceof o)&&0<l.span&&(P=y*l.span),super(P,k),this.elementLayout=l,this.count=y}getSpan(l,y=0){if(0<=this.span)return this.span;let k=0,P=this.count;if(P instanceof o&&(P=P.decode(l,y)),0<this.elementLayout.span)k=P*this.elementLayout.span;else{let G=0;for(;G<P;)k+=this.elementLayout.getSpan(l,y+k),++G}return k}decode(l,y=0){const k=[];let P=0,G=this.count;for(G instanceof o&&(G=G.decode(l,y));P<G;)k.push(this.elementLayout.decode(l,y)),y+=this.elementLayout.getSpan(l,y),P+=1;return k}encode(l,y,k=0){const P=this.elementLayout,G=l.reduce((j,ce)=>j+P.encode(ce,y,k+j),0);return this.count instanceof o&&this.count.encode(l.length,y,k),G}}W.Sequence=Z;class J extends r{constructor(l,y,k){if(!(Array.isArray(l)&&l.reduce((G,j)=>G&&j instanceof r,!0)))throw new TypeError("fields must be array of Layout instances");typeof y=="boolean"&&k===void 0&&(k=y,y=void 0);for(const G of l)if(0>G.span&&G.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let P=-1;try{P=l.reduce((G,j)=>G+j.getSpan(),0)}catch{}super(P,y),this.fields=l,this.decodePrefixes=!!k}getSpan(l,y=0){if(0<=this.span)return this.span;let k=0;try{k=this.fields.reduce((P,G)=>{const j=G.getSpan(l,y);return y+=j,P+j},0)}catch{throw new RangeError("indeterminate span")}return k}decode(l,y=0){e(l);const k=this.makeDestinationObject();for(const P of this.fields)if(P.property!==void 0&&(k[P.property]=P.decode(l,y)),y+=P.getSpan(l,y),this.decodePrefixes&&l.length===y)break;return k}encode(l,y,k=0){const P=k;let G=0,j=0;for(const ce of this.fields){let ve=ce.span;if(j=0<ve?ve:0,ce.property!==void 0){const ge=l[ce.property];ge!==void 0&&(j=ce.encode(ge,y,k),0>ve&&(ve=ce.getSpan(y,k)))}G=k,k+=ve}return G+j-P}fromArray(l){const y=this.makeDestinationObject();for(const k of this.fields)k.property!==void 0&&0<l.length&&(y[k.property]=l.shift());return y}layoutFor(l){if(typeof l!="string")throw new TypeError("property must be string");for(const y of this.fields)if(y.property===l)return y}offsetOf(l){if(typeof l!="string")throw new TypeError("property must be string");let y=0;for(const k of this.fields){if(k.property===l)return y;0>k.span?y=-1:0<=y&&(y+=k.span)}}}W.Structure=J;class z{constructor(l){this.property=l}decode(l,y){throw new Error("UnionDiscriminator is abstract")}encode(l,y,k){throw new Error("UnionDiscriminator is abstract")}}W.UnionDiscriminator=z;class V extends z{constructor(l,y){if(!(l instanceof o&&l.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(y||l.property||"variant"),this.layout=l}decode(l,y){return this.layout.decode(l,y)}encode(l,y,k){return this.layout.encode(l,y,k)}}W.UnionLayoutDiscriminator=V;class ee extends r{constructor(l,y,k){let P;if(l instanceof g||l instanceof w)P=new V(new f(l));else if(l instanceof o&&l.isCount())P=new V(l);else if(l instanceof z)P=l;else throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(y===void 0&&(y=null),!(y===null||y instanceof r))throw new TypeError("defaultLayout must be null or a Layout");if(y!==null){if(0>y.span)throw new Error("defaultLayout must have constant span");y.property===void 0&&(y=y.replicate("content"))}let G=-1;y&&(G=y.span,0<=G&&(l instanceof g||l instanceof w)&&(G+=P.layout.span)),super(G,k),this.discriminator=P,this.usesPrefixDiscriminator=l instanceof g||l instanceof w,this.defaultLayout=y,this.registry={};let j=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(ce){return j(ce)},this.configGetSourceVariant=function(ce){j=ce.bind(this)}}getSpan(l,y=0){if(0<=this.span)return this.span;const k=this.getVariant(l,y);if(!k)throw new Error("unable to determine span for unrecognized variant");return k.getSpan(l,y)}defaultGetSourceVariant(l){if(Object.prototype.hasOwnProperty.call(l,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(l,this.defaultLayout.property))return;const y=this.registry[l[this.discriminator.property]];if(y&&(!y.layout||y.property&&Object.prototype.hasOwnProperty.call(l,y.property)))return y}else for(const y in this.registry){const k=this.registry[y];if(k.property&&Object.prototype.hasOwnProperty.call(l,k.property))return k}throw new Error("unable to infer src variant")}decode(l,y=0){let k;const P=this.discriminator,G=P.decode(l,y),j=this.registry[G];if(j===void 0){const ce=this.defaultLayout;let ve=0;this.usesPrefixDiscriminator&&(ve=P.layout.span),k=this.makeDestinationObject(),k[P.property]=G,k[ce.property]=ce.decode(l,y+ve)}else k=j.decode(l,y);return k}encode(l,y,k=0){const P=this.getSourceVariant(l);if(P===void 0){const G=this.discriminator,j=this.defaultLayout;let ce=0;return this.usesPrefixDiscriminator&&(ce=G.layout.span),G.encode(l[G.property],y,k),ce+j.encode(l[j.property],y,k+ce)}return P.encode(l,y,k)}addVariant(l,y,k){const P=new S(this,l,y,k);return this.registry[l]=P,P}getVariant(l,y=0){let k;return l instanceof Uint8Array?k=this.discriminator.decode(l,y):k=l,this.registry[k]}}W.Union=ee;class S extends r{constructor(l,y,k,P){if(!(l instanceof ee))throw new TypeError("union must be a Union");if(!Number.isInteger(y)||0>y)throw new TypeError("variant must be a (non-negative) integer");if(typeof k=="string"&&P===void 0&&(P=k,k=null),k){if(!(k instanceof r))throw new TypeError("layout must be a Layout");if(l.defaultLayout!==null&&0<=k.span&&k.span>l.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof P!="string")throw new TypeError("variant must have a String property")}let G=l.span;0>l.span&&(G=k?k.span:0,0<=G&&l.usesPrefixDiscriminator&&(G+=l.discriminator.layout.span)),super(G,P),this.union=l,this.variant=y,this.layout=k||null}getSpan(l,y=0){if(0<=this.span)return this.span;let k=0;this.union.usesPrefixDiscriminator&&(k=this.union.discriminator.layout.span);let P=0;return this.layout&&(P=this.layout.getSpan(l,y+k)),k+P}decode(l,y=0){const k=this.makeDestinationObject();if(this!==this.union.getVariant(l,y))throw new Error("variant mismatch");let P=0;return this.union.usesPrefixDiscriminator&&(P=this.union.discriminator.layout.span),this.layout?k[this.property]=this.layout.decode(l,y+P):this.property?k[this.property]=!0:this.union.usesPrefixDiscriminator&&(k[this.union.discriminator.property]=this.variant),k}encode(l,y,k=0){let P=0;if(this.union.usesPrefixDiscriminator&&(P=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(l,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,y,k);let G=P;if(this.layout&&(this.layout.encode(l[this.property],y,k+P),G+=this.layout.getSpan(y,k+P),0<=this.union.span&&G>this.union.span))throw new Error("encoded variant overruns containing union");return G}fromArray(l){if(this.layout)return this.layout.fromArray(l)}}W.VariantLayout=S;function c(u){return 0>u&&(u+=4294967296),u}class p extends r{constructor(l,y,k){if(!(l instanceof g||l instanceof w))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof y=="string"&&k===void 0&&(k=y,y=!1),4<l.span)throw new RangeError("word cannot exceed 32 bits");super(l.span,k),this.word=l,this.msb=!!y,this.fields=[];let P=0;this._packedSetValue=function(G){return P=c(G),this},this._packedGetValue=function(){return P}}decode(l,y=0){const k=this.makeDestinationObject(),P=this.word.decode(l,y);this._packedSetValue(P);for(const G of this.fields)G.property!==void 0&&(k[G.property]=G.decode(l));return k}encode(l,y,k=0){const P=this.word.decode(y,k);this._packedSetValue(P);for(const G of this.fields)if(G.property!==void 0){const j=l[G.property];j!==void 0&&G.encode(j)}return this.word.encode(this._packedGetValue(),y,k)}addField(l,y){const k=new m(this,l,y);return this.fields.push(k),k}addBoolean(l){const y=new I(this,l);return this.fields.push(y),y}fieldFor(l){if(typeof l!="string")throw new TypeError("property must be string");for(const y of this.fields)if(y.property===l)return y}}W.BitStructure=p;class m{constructor(l,y,k){if(!(l instanceof p))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(y)||0>=y)throw new TypeError("bits must be positive integer");const P=8*l.span,G=l.fields.reduce((j,ce)=>j+ce.bits,0);if(y+G>P)throw new Error("bits too long for span remainder ("+(P-G)+" of "+P+" remain)");this.container=l,this.bits=y,this.valueMask=(1<<y)-1,y===32&&(this.valueMask=4294967295),this.start=G,this.container.msb&&(this.start=P-G-y),this.wordMask=c(this.valueMask<<this.start),this.property=k}decode(l,y){const k=this.container._packedGetValue();return c(k&this.wordMask)>>>this.start}encode(l){if(typeof l!="number"||!Number.isInteger(l)||l!==c(l&this.valueMask))throw new TypeError(s("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const y=this.container._packedGetValue(),k=c(l<<this.start);this.container._packedSetValue(c(y&~this.wordMask)|k)}}W.BitField=m;class I extends m{constructor(l,y){super(l,1,y)}decode(l,y){return!!super.decode(l,y)}encode(l){typeof l=="boolean"&&(l=+l),super.encode(l)}}W.Boolean=I;class E extends r{constructor(l,y){if(!(l instanceof o&&l.isCount()||Number.isInteger(l)&&0<=l))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let k=-1;l instanceof o||(k=l),super(k,y),this.length=l}getSpan(l,y){let k=this.span;return 0>k&&(k=this.length.decode(l,y)),k}decode(l,y=0){let k=this.span;return 0>k&&(k=this.length.decode(l,y)),t(l).slice(y,y+k)}encode(l,y,k){let P=this.length;if(this.length instanceof o&&(P=l.length),!(l instanceof Uint8Array&&P===l.length))throw new TypeError(s("Blob.encode",this)+" requires (length "+P+") Uint8Array as src");if(k+P>y.length)throw new RangeError("encoding overruns Uint8Array");const G=t(l);return t(y).write(G.toString("hex"),k,P,"hex"),this.length instanceof o&&this.length.encode(P,y,k),P}}W.Blob=E;class A extends r{constructor(l){super(-1,l)}getSpan(l,y=0){e(l);let k=y;for(;k<l.length&&l[k]!==0;)k+=1;return 1+k-y}decode(l,y=0){const k=this.getSpan(l,y);return t(l).slice(y,y+k-1).toString("utf-8")}encode(l,y,k=0){typeof l!="string"&&(l=String(l));const P=n.Buffer.from(l,"utf8"),G=P.length;if(k+G>y.length)throw new RangeError("encoding overruns Buffer");const j=t(y);return P.copy(j,k),j[k+G]=0,G+1}}W.CString=A;class C extends r{constructor(l,y){if(typeof l=="string"&&y===void 0&&(y=l,l=void 0),l===void 0)l=-1;else if(!Number.isInteger(l))throw new TypeError("maxSpan must be an integer");super(-1,y),this.maxSpan=l}getSpan(l,y=0){return e(l),l.length-y}decode(l,y=0){const k=this.getSpan(l,y);if(0<=this.maxSpan&&this.maxSpan<k)throw new RangeError("text length exceeds maxSpan");return t(l).slice(y,y+k).toString("utf-8")}encode(l,y,k=0){typeof l!="string"&&(l=String(l));const P=n.Buffer.from(l,"utf8"),G=P.length;if(0<=this.maxSpan&&this.maxSpan<G)throw new RangeError("text length exceeds maxSpan");if(k+G>y.length)throw new RangeError("encoding overruns Buffer");return P.copy(t(y),k),G}}W.UTF8=C;class R extends r{constructor(l,y){super(0,y),this.value=l}decode(l,y){return this.value}encode(l,y,k){return 0}}return W.Constant=R,W.greedy=(u,l)=>new a(u,l),W.offset=(u,l,y)=>new f(u,l,y),W.u8=u=>new g(1,u),W.u16=u=>new g(2,u),W.u24=u=>new g(3,u),W.u32=u=>new g(4,u),W.u40=u=>new g(5,u),W.u48=u=>new g(6,u),W.nu64=u=>new N(u),W.u16be=u=>new w(2,u),W.u24be=u=>new w(3,u),W.u32be=u=>new w(4,u),W.u40be=u=>new w(5,u),W.u48be=u=>new w(6,u),W.nu64be=u=>new M(u),W.s8=u=>new b(1,u),W.s16=u=>new b(2,u),W.s24=u=>new b(3,u),W.s32=u=>new b(4,u),W.s40=u=>new b(5,u),W.s48=u=>new b(6,u),W.ns64=u=>new H(u),W.s16be=u=>new x(2,u),W.s24be=u=>new x(3,u),W.s32be=u=>new x(4,u),W.s40be=u=>new x(5,u),W.s48be=u=>new x(6,u),W.ns64be=u=>new K(u),W.f32=u=>new Q(u),W.f32be=u=>new q(u),W.f64=u=>new D(u),W.f64be=u=>new X(u),W.struct=(u,l,y)=>new J(u,l,y),W.bits=(u,l,y)=>new p(u,l,y),W.seq=(u,l,y)=>new Z(u,l,y),W.union=(u,l,y)=>new ee(u,l,y),W.unionLayoutDiscriminator=(u,l)=>new V(u,l),W.blob=(u,l)=>new E(u,l),W.cstr=u=>new A(u),W.utf8=(u,l)=>new C(u,l),W.constant=(u,l)=>new R(u,l),W}var B=du(),pu=1,gu=2,mu=3,_u=4,yu=5,wu=6,bu=7,Ru=8,Eu=9,Su=10,Au=-32700,Iu=-32603,vu=-32602,Ou=-32601,ku=-32600,Tu=-32016,Nu=-32015,xu=-32014,Bu=-32013,Lu=-32012,Cu=-32011,Mu=-32010,Pu=-32009,Uu=-32008,Du=-32007,Fu=-32006,zu=-32005,Ku=-32004,$u=-32003,Hu=-32002,Wu=-32001,qu=28e5,Vu=2800001,Gu=2800002,Yu=2800003,ju=2800004,Zu=2800005,Xu=2800006,Ju=2800007,Qu=2800008,el=2800009,tl=2800010,nl=323e4,rl=32300001,il=3230002,sl=3230003,ol=3230004,al=361e4,cl=3610001,ul=3610002,ll=3610003,hl=3610004,fl=3610005,dl=3610006,pl=3610007,gl=3611e3,ml=3704e3,_l=3704001,yl=3704002,wl=3704003,bl=3704004,Rl=4128e3,El=4128001,Sl=4128002,Al=4615e3,Il=4615001,vl=4615002,Ol=4615003,kl=4615004,Tl=4615005,Nl=4615006,xl=4615007,Bl=4615008,Ll=4615009,Cl=4615010,Ml=4615011,Pl=4615012,Ul=4615013,Dl=4615014,Fl=4615015,zl=4615016,Kl=4615017,$l=4615018,Hl=4615019,Wl=4615020,ql=4615021,Vl=4615022,Gl=4615023,Yl=4615024,jl=4615025,Zl=4615026,Xl=4615027,Jl=4615028,Ql=4615029,eh=4615030,th=4615031,nh=4615032,rh=4615033,ih=4615034,sh=4615035,oh=4615036,ah=4615037,ch=4615038,uh=4615039,lh=4615040,hh=4615041,fh=4615042,dh=4615043,ph=4615044,gh=4615045,mh=4615046,_h=4615047,yh=4615048,wh=4615049,bh=4615050,Rh=4615051,Eh=4615052,Sh=4615053,Ah=4615054,Ih=5508e3,vh=5508001,Oh=5508002,kh=5508003,Th=5508004,Nh=5508005,xh=5508006,Bh=5508007,Lh=5508008,Ch=5508009,Mh=5508010,Ph=5508011,Uh=5663e3,Dh=5663001,Fh=5663002,zh=5663003,Kh=5663004,$h=5663005,Hh=5663006,Wh=5663007,qh=5663008,Vh=5663009,Gh=5663010,Yh=5663011,jh=5663012,Zh=5663013,Xh=5663014,Jh=5663015,Qh=5663016,ef=5663017,tf=5663018,nf=5663019,rf=705e4,sf=7050001,of=7050002,af=7050003,cf=7050004,uf=7050005,lf=7050006,hf=7050007,ff=7050008,df=7050009,pf=7050010,gf=7050011,mf=7050012,_f=7050013,yf=7050014,wf=7050015,bf=7050016,Rf=7050017,Ef=7050018,Sf=7050019,Af=7050020,If=7050021,vf=7050022,Of=7050023,kf=7050024,Tf=7050025,Nf=7050026,xf=7050027,Bf=7050028,Lf=7050029,Cf=7050030,Mf=7050031,Pf=7050032,Uf=7050033,Df=7050034,Ff=7050035,zf=7050036,ao=8078e3,co=8078001,Kf=8078002,$f=8078003,uo=8078004,lo=8078005,ho=8078006,Hf=8078007,Wf=8078008,qf=8078009,Vf=8078010,fo=8078011,Gf=8078012,Yf=8078013,jf=8078014,Zf=8078015,Xf=8078016,Jf=8078017,Qf=8078018,ed=8078019,td=8078020,nd=8078021,rd=8078022,id=81e5,sd=8100001,od=8100002,ad=8100003,cd=819e4,ud=8190001,ld=8190002,hd=8190003,fd=8190004,dd=99e5,pd=9900001,gd=9900002,md=9900003,_d=9900004;function po(n){return Array.isArray(n)?"%5B"+n.map(po).join("%2C%20")+"%5D":typeof n=="bigint"?`${n}n`:encodeURIComponent(String(n!=null&&Object.getPrototypeOf(n)===null?{...n}:n))}function yd([n,e]){return`${n}=${po(e)}`}function wd(n){const e=Object.entries(n).map(yd).join("&");return btoa(e)}var bd={[nl]:"Account not found at address: $address",[ol]:"Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",[sl]:"Expected decoded account at address: $address",[il]:"Failed to decode account data at address: $address",[rl]:"Accounts not found at addresses: $addresses",[el]:"Unable to find a viable program address bump seed.",[Gu]:"$putativeAddress is not a base58-encoded address.",[qu]:"Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",[Yu]:"The `CryptoKey` must be an `Ed25519` public key.",[Qu]:"Invalid seeds; point must fall off the Ed25519 curve.",[ju]:"Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",[Xu]:"A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",[Ju]:"The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",[Zu]:"Expected program derived address bump to be in the range [0, 255], got: $bump.",[tl]:"Program address cannot end with PDA marker.",[Vu]:"Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",[_u]:"Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",[pu]:"The network has progressed past the last block for which this transaction could have been committed.",[ao]:"Codec [$codecDescription] cannot decode empty byte arrays.",[rd]:"Enum codec cannot use lexical values [$stringValues] as discriminators. Either remove all lexical values or set `useValuesAsDiscriminators` to `false`.",[td]:"Sentinel [$hexSentinel] must not be present in encoded bytes [$hexEncodedBytes].",[lo]:"Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",[ho]:"Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",[uo]:"Encoder and decoder must either both be fixed-size or variable-size.",[Wf]:"Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",[Kf]:"Expected a fixed-size codec, got a variable-size one.",[Yf]:"Codec [$codecDescription] expected a positive byte length, got $bytesLength.",[$f]:"Expected a variable-size codec, got a fixed-size one.",[ed]:"Codec [$codecDescription] expected zero-value [$hexZeroValue] to have the same size as the provided fixed-size item [$expectedSize bytes].",[co]:"Codec [$codecDescription] expected $expected bytes, got $bytesLength.",[Qf]:"Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",[qf]:"Invalid discriminated union variant. Expected one of [$variants], got $value.",[Vf]:"Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",[Zf]:"Invalid literal union variant. Expected one of [$variants], got $value.",[Hf]:"Expected [$codecDescription] to have $expected items, got $actual.",[Gf]:"Invalid value $value for base $base with alphabet $alphabet.",[Xf]:"Literal union discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",[fo]:"Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",[jf]:"Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",[nd]:"Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",[Jf]:"Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",[gl]:"No random values implementation could be found.",[Ll]:"instruction requires an uninitialized account",[Gl]:"instruction tries to borrow reference for an account which is already borrowed",[Yl]:"instruction left account with an outstanding borrowed reference",[ql]:"program other than the account's owner changed the size of the account data",[Tl]:"account data too small for instruction",[Vl]:"instruction expected an executable account",[mh]:"An account does not have enough lamports to be rent-exempt",[yh]:"Program arithmetic overflowed",[gh]:"Failed to serialize or deserialize account data: $encodedData",[Ah]:"Builtin programs must consume compute units",[nh]:"Cross-program invocation call depth too deep",[ch]:"Computational budget exceeded",[Zl]:"custom program error: #$code",[Kl]:"instruction contains duplicate accounts",[jl]:"instruction modifications of multiply-passed account differ",[eh]:"executable accounts must be rent exempt",[Jl]:"instruction changed executable accounts data",[Ql]:"instruction changed the balance of an executable account",[$l]:"instruction changed executable bit of an account",[Dl]:"instruction modified data of an account it does not own",[Ul]:"instruction spent from the balance of an account it does not own",[Il]:"generic instruction error",[bh]:"Provided owner is not allowed",[dh]:"Account is immutable",[ph]:"Incorrect authority provided",[xl]:"incorrect program id for instruction",[Nl]:"insufficient funds for instruction",[kl]:"invalid account data for instruction",[_h]:"Invalid account owner",[vl]:"invalid program argument",[Xl]:"program returned invalid error code",[Ol]:"invalid instruction data",[ah]:"Failed to reallocate account data",[oh]:"Provided seeds do not result in a valid address",[Rh]:"Accounts data allocations exceeded the maximum allowed per transaction",[Eh]:"Max accounts exceeded",[Sh]:"Max instruction trace length exceeded",[sh]:"Length of the seed is too long for address generation",[rh]:"An account required by the instruction is missing",[Bl]:"missing required signature for instruction",[Pl]:"instruction illegally modified the program id of an account",[Wl]:"insufficient account keys for instruction",[uh]:"Cross-program invocation with unauthorized signer or writable account",[lh]:"Failed to create program execution environment",[fh]:"Program failed to compile",[hh]:"Program failed to complete",[zl]:"instruction modified data of a read-only account",[Fl]:"instruction changed the balance of a read-only account",[ih]:"Cross-program invocation reentrancy not allowed for this instruction",[Hl]:"instruction modified rent epoch of an account",[Ml]:"sum of account balances before and after instruction do not match",[Cl]:"instruction requires an initialized account",[Al]:"",[th]:"Unsupported program id",[wh]:"Unsupported sysvar",[Rl]:"The instruction does not have any accounts.",[El]:"The instruction does not have any data.",[Sl]:"Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",[yu]:"Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",[gu]:"The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",[gd]:"Invariant violation: Found no abortable iterable cache entry for key `$cacheKey`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[_d]:"Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",[pd]:"Invariant violation: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[dd]:"Invariant violation: WebSocket message iterator is missing state storage. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[md]:"Invariant violation: Switch statement non-exhaustive. Received unexpected value `$unexpectedValue`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[Iu]:"JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",[vu]:"JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",[ku]:"JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",[Ou]:"JSON-RPC error: The method does not exist / is not available ($__serverMessage)",[Au]:"JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",[Lu]:"$__serverMessage",[Wu]:"$__serverMessage",[Ku]:"$__serverMessage",[xu]:"$__serverMessage",[Mu]:"$__serverMessage",[Pu]:"$__serverMessage",[Tu]:"Minimum context slot has not been reached",[zu]:"Node is unhealthy; behind by $numSlotsBehind slots",[Uu]:"No snapshot",[Hu]:"Transaction simulation failed",[Du]:"$__serverMessage",[Cu]:"Transaction history is not available from this node",[Fu]:"$__serverMessage",[Bu]:"Transaction signature length mismatch",[$u]:"Transaction signature verification failure",[Nu]:"$__serverMessage",[ml]:"Key pair bytes must be of length 64, got $byteLength.",[_l]:"Expected private key bytes with length 32. Actual length: $actualLength.",[yl]:"Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",[bl]:"The provided private key does not match the provided public key.",[wl]:"Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",[wu]:"Lamports value must be in the range [0, 2e64-1]",[bu]:"`$value` cannot be parsed as a `BigInt`",[Su]:"$message",[Ru]:"`$value` cannot be parsed as a `Number`",[mu]:"No nonce account could be found at address `$nonceAccountAddress`",[cd]:"The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",[ld]:"WebSocket was closed before payload could be added to the send buffer",[hd]:"WebSocket connection closed",[fd]:"WebSocket failed to connect",[ud]:"Failed to obtain a subscription id from the server",[ad]:"Could not find an API plan for RPC method: `$method`",[id]:"The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was `$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds `Number.MAX_SAFE_INTEGER`.",[od]:"HTTP error ($statusCode): $message",[sd]:"HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",[Ih]:"Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",[vh]:"The provided value does not implement the `KeyPairSigner` interface",[kh]:"The provided value does not implement the `MessageModifyingSigner` interface",[Th]:"The provided value does not implement the `MessagePartialSigner` interface",[Oh]:"The provided value does not implement any of the `MessageSigner` interfaces",[xh]:"The provided value does not implement the `TransactionModifyingSigner` interface",[Bh]:"The provided value does not implement the `TransactionPartialSigner` interface",[Lh]:"The provided value does not implement the `TransactionSendingSigner` interface",[Nh]:"The provided value does not implement any of the `TransactionSigner` interfaces",[Ch]:"More than one `TransactionSendingSigner` was identified.",[Mh]:"No `TransactionSendingSigner` was identified. Please provide a valid `ITransactionWithSingleSendingSigner` transaction.",[Ph]:"Wallet account signers do not support signing multiple messages/transactions in a single operation",[pl]:"Cannot export a non-extractable key.",[cl]:"No digest implementation could be found.",[al]:"Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",[ul]:`This runtime does not support the generation of Ed25519 key pairs.
|
|
6
|
+
*/var vs;function zr(){return vs||(vs=1,function(n){const e=ja(),t=Za(),r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;n.Buffer=a,n.SlowBuffer=H,n.INSPECT_MAX_BYTES=50;const s=2147483647;n.kMaxLength=s,a.TYPED_ARRAY_SUPPORT=i(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&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.");function i(){try{const _=new Uint8Array(1),h={foo:function(){return 42}};return Object.setPrototypeOf(h,Uint8Array.prototype),Object.setPrototypeOf(_,h),_.foo()===42}catch{return!1}}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}});function o(_){if(_>s)throw new RangeError('The value "'+_+'" is invalid for option "size"');const h=new Uint8Array(_);return Object.setPrototypeOf(h,a.prototype),h}function a(_,h,d){if(typeof _=="number"){if(typeof h=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return b(_)}return f(_,h,d)}a.poolSize=8192;function f(_,h,d){if(typeof _=="string")return x(_,h);if(ArrayBuffer.isView(_))return L(_);if(_==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof _);if(Et(_,ArrayBuffer)||_&&Et(_.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Et(_,SharedArrayBuffer)||_&&Et(_.buffer,SharedArrayBuffer)))return O(_,h,d);if(typeof _=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const v=_.valueOf&&_.valueOf();if(v!=null&&v!==_)return a.from(v,h,d);const U=N(_);if(U)return U;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof _[Symbol.toPrimitive]=="function")return a.from(_[Symbol.toPrimitive]("string"),h,d);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof _)}a.from=function(_,h,d){return f(_,h,d)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function g(_){if(typeof _!="number")throw new TypeError('"size" argument must be of type number');if(_<0)throw new RangeError('The value "'+_+'" is invalid for option "size"')}function w(_,h,d){return g(_),_<=0?o(_):h!==void 0?typeof d=="string"?o(_).fill(h,d):o(_).fill(h):o(_)}a.alloc=function(_,h,d){return w(_,h,d)};function b(_){return g(_),o(_<0?0:M(_)|0)}a.allocUnsafe=function(_){return b(_)},a.allocUnsafeSlow=function(_){return b(_)};function x(_,h){if((typeof h!="string"||h==="")&&(h="utf8"),!a.isEncoding(h))throw new TypeError("Unknown encoding: "+h);const d=K(_,h)|0;let v=o(d);const U=v.write(_,h);return U!==d&&(v=v.slice(0,U)),v}function T(_){const h=_.length<0?0:M(_.length)|0,d=o(h);for(let v=0;v<h;v+=1)d[v]=_[v]&255;return d}function L(_){if(Et(_,Uint8Array)){const h=new Uint8Array(_);return O(h.buffer,h.byteOffset,h.byteLength)}return T(_)}function O(_,h,d){if(h<0||_.byteLength<h)throw new RangeError('"offset" is outside of buffer bounds');if(_.byteLength<h+(d||0))throw new RangeError('"length" is outside of buffer bounds');let v;return h===void 0&&d===void 0?v=new Uint8Array(_):d===void 0?v=new Uint8Array(_,h):v=new Uint8Array(_,h,d),Object.setPrototypeOf(v,a.prototype),v}function N(_){if(a.isBuffer(_)){const h=M(_.length)|0,d=o(h);return d.length===0||_.copy(d,0,0,h),d}if(_.length!==void 0)return typeof _.length!="number"||Ce(_.length)?o(0):T(_);if(_.type==="Buffer"&&Array.isArray(_.data))return T(_.data)}function M(_){if(_>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return _|0}function H(_){return+_!=_&&(_=0),a.alloc(+_)}a.isBuffer=function(h){return h!=null&&h._isBuffer===!0&&h!==a.prototype},a.compare=function(h,d){if(Et(h,Uint8Array)&&(h=a.from(h,h.offset,h.byteLength)),Et(d,Uint8Array)&&(d=a.from(d,d.offset,d.byteLength)),!a.isBuffer(h)||!a.isBuffer(d))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(h===d)return 0;let v=h.length,U=d.length;for(let F=0,Y=Math.min(v,U);F<Y;++F)if(h[F]!==d[F]){v=h[F],U=d[F];break}return v<U?-1:U<v?1:0},a.isEncoding=function(h){switch(String(h).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(h,d){if(!Array.isArray(h))throw new TypeError('"list" argument must be an Array of Buffers');if(h.length===0)return a.alloc(0);let v;if(d===void 0)for(d=0,v=0;v<h.length;++v)d+=h[v].length;const U=a.allocUnsafe(d);let F=0;for(v=0;v<h.length;++v){let Y=h[v];if(Et(Y,Uint8Array))F+Y.length>U.length?(a.isBuffer(Y)||(Y=a.from(Y)),Y.copy(U,F)):Uint8Array.prototype.set.call(U,Y,F);else if(a.isBuffer(Y))Y.copy(U,F);else throw new TypeError('"list" argument must be an Array of Buffers');F+=Y.length}return U};function K(_,h){if(a.isBuffer(_))return _.length;if(ArrayBuffer.isView(_)||Et(_,ArrayBuffer))return _.byteLength;if(typeof _!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof _);const d=_.length,v=arguments.length>2&&arguments[2]===!0;if(!v&&d===0)return 0;let U=!1;for(;;)switch(h){case"ascii":case"latin1":case"binary":return d;case"utf8":case"utf-8":return Be(_).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return d*2;case"hex":return d>>>1;case"base64":return Fe(_).length;default:if(U)return v?-1:Be(_).length;h=(""+h).toLowerCase(),U=!0}}a.byteLength=K;function Q(_,h,d){let v=!1;if((h===void 0||h<0)&&(h=0),h>this.length||((d===void 0||d>this.length)&&(d=this.length),d<=0)||(d>>>=0,h>>>=0,d<=h))return"";for(_||(_="utf8");;)switch(_){case"hex":return A(this,h,d);case"utf8":case"utf-8":return c(this,h,d);case"ascii":return I(this,h,d);case"latin1":case"binary":return E(this,h,d);case"base64":return S(this,h,d);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,h,d);default:if(v)throw new TypeError("Unknown encoding: "+_);_=(_+"").toLowerCase(),v=!0}}a.prototype._isBuffer=!0;function q(_,h,d){const v=_[h];_[h]=_[d],_[d]=v}a.prototype.swap16=function(){const h=this.length;if(h%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let d=0;d<h;d+=2)q(this,d,d+1);return this},a.prototype.swap32=function(){const h=this.length;if(h%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let d=0;d<h;d+=4)q(this,d,d+3),q(this,d+1,d+2);return this},a.prototype.swap64=function(){const h=this.length;if(h%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let d=0;d<h;d+=8)q(this,d,d+7),q(this,d+1,d+6),q(this,d+2,d+5),q(this,d+3,d+4);return this},a.prototype.toString=function(){const h=this.length;return h===0?"":arguments.length===0?c(this,0,h):Q.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(h){if(!a.isBuffer(h))throw new TypeError("Argument must be a Buffer");return this===h?!0:a.compare(this,h)===0},a.prototype.inspect=function(){let h="";const d=n.INSPECT_MAX_BYTES;return h=this.toString("hex",0,d).replace(/(.{2})/g,"$1 ").trim(),this.length>d&&(h+=" ... "),"<Buffer "+h+">"},r&&(a.prototype[r]=a.prototype.inspect),a.prototype.compare=function(h,d,v,U,F){if(Et(h,Uint8Array)&&(h=a.from(h,h.offset,h.byteLength)),!a.isBuffer(h))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof h);if(d===void 0&&(d=0),v===void 0&&(v=h?h.length:0),U===void 0&&(U=0),F===void 0&&(F=this.length),d<0||v>h.length||U<0||F>this.length)throw new RangeError("out of range index");if(U>=F&&d>=v)return 0;if(U>=F)return-1;if(d>=v)return 1;if(d>>>=0,v>>>=0,U>>>=0,F>>>=0,this===h)return 0;let Y=F-U,Re=v-d;const _e=Math.min(Y,Re),pe=this.slice(U,F),Ke=h.slice(d,v);for(let fe=0;fe<_e;++fe)if(pe[fe]!==Ke[fe]){Y=pe[fe],Re=Ke[fe];break}return Y<Re?-1:Re<Y?1:0};function D(_,h,d,v,U){if(_.length===0)return-1;if(typeof d=="string"?(v=d,d=0):d>2147483647?d=2147483647:d<-2147483648&&(d=-2147483648),d=+d,Ce(d)&&(d=U?0:_.length-1),d<0&&(d=_.length+d),d>=_.length){if(U)return-1;d=_.length-1}else if(d<0)if(U)d=0;else return-1;if(typeof h=="string"&&(h=a.from(h,v)),a.isBuffer(h))return h.length===0?-1:Z(_,h,d,v,U);if(typeof h=="number")return h=h&255,typeof Uint8Array.prototype.indexOf=="function"?U?Uint8Array.prototype.indexOf.call(_,h,d):Uint8Array.prototype.lastIndexOf.call(_,h,d):Z(_,[h],d,v,U);throw new TypeError("val must be string, number or Buffer")}function Z(_,h,d,v,U){let F=1,Y=_.length,Re=h.length;if(v!==void 0&&(v=String(v).toLowerCase(),v==="ucs2"||v==="ucs-2"||v==="utf16le"||v==="utf-16le")){if(_.length<2||h.length<2)return-1;F=2,Y/=2,Re/=2,d/=2}function _e(Ke,fe){return F===1?Ke[fe]:Ke.readUInt16BE(fe*F)}let pe;if(U){let Ke=-1;for(pe=d;pe<Y;pe++)if(_e(_,pe)===_e(h,Ke===-1?0:pe-Ke)){if(Ke===-1&&(Ke=pe),pe-Ke+1===Re)return Ke*F}else Ke!==-1&&(pe-=pe-Ke),Ke=-1}else for(d+Re>Y&&(d=Y-Re),pe=d;pe>=0;pe--){let Ke=!0;for(let fe=0;fe<Re;fe++)if(_e(_,pe+fe)!==_e(h,fe)){Ke=!1;break}if(Ke)return pe}return-1}a.prototype.includes=function(h,d,v){return this.indexOf(h,d,v)!==-1},a.prototype.indexOf=function(h,d,v){return D(this,h,d,v,!0)},a.prototype.lastIndexOf=function(h,d,v){return D(this,h,d,v,!1)};function j(_,h,d,v){d=Number(d)||0;const U=_.length-d;v?(v=Number(v),v>U&&(v=U)):v=U;const F=h.length;v>F/2&&(v=F/2);let Y;for(Y=0;Y<v;++Y){const Re=parseInt(h.substr(Y*2,2),16);if(Ce(Re))return Y;_[d+Y]=Re}return Y}function X(_,h,d,v){return Le(Be(h,_.length-d),_,d,v)}function z(_,h,d,v){return Le(He(h),_,d,v)}function V(_,h,d,v){return Le(Fe(h),_,d,v)}function ee(_,h,d,v){return Le(Dn(h,_.length-d),_,d,v)}a.prototype.write=function(h,d,v,U){if(d===void 0)U="utf8",v=this.length,d=0;else if(v===void 0&&typeof d=="string")U=d,v=this.length,d=0;else if(isFinite(d))d=d>>>0,isFinite(v)?(v=v>>>0,U===void 0&&(U="utf8")):(U=v,v=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const F=this.length-d;if((v===void 0||v>F)&&(v=F),h.length>0&&(v<0||d<0)||d>this.length)throw new RangeError("Attempt to write outside buffer bounds");U||(U="utf8");let Y=!1;for(;;)switch(U){case"hex":return j(this,h,d,v);case"utf8":case"utf-8":return X(this,h,d,v);case"ascii":case"latin1":case"binary":return z(this,h,d,v);case"base64":return V(this,h,d,v);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ee(this,h,d,v);default:if(Y)throw new TypeError("Unknown encoding: "+U);U=(""+U).toLowerCase(),Y=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function S(_,h,d){return h===0&&d===_.length?e.fromByteArray(_):e.fromByteArray(_.slice(h,d))}function c(_,h,d){d=Math.min(_.length,d);const v=[];let U=h;for(;U<d;){const F=_[U];let Y=null,Re=F>239?4:F>223?3:F>191?2:1;if(U+Re<=d){let _e,pe,Ke,fe;switch(Re){case 1:F<128&&(Y=F);break;case 2:_e=_[U+1],(_e&192)===128&&(fe=(F&31)<<6|_e&63,fe>127&&(Y=fe));break;case 3:_e=_[U+1],pe=_[U+2],(_e&192)===128&&(pe&192)===128&&(fe=(F&15)<<12|(_e&63)<<6|pe&63,fe>2047&&(fe<55296||fe>57343)&&(Y=fe));break;case 4:_e=_[U+1],pe=_[U+2],Ke=_[U+3],(_e&192)===128&&(pe&192)===128&&(Ke&192)===128&&(fe=(F&15)<<18|(_e&63)<<12|(pe&63)<<6|Ke&63,fe>65535&&fe<1114112&&(Y=fe))}}Y===null?(Y=65533,Re=1):Y>65535&&(Y-=65536,v.push(Y>>>10&1023|55296),Y=56320|Y&1023),v.push(Y),U+=Re}return m(v)}const p=4096;function m(_){const h=_.length;if(h<=p)return String.fromCharCode.apply(String,_);let d="",v=0;for(;v<h;)d+=String.fromCharCode.apply(String,_.slice(v,v+=p));return d}function I(_,h,d){let v="";d=Math.min(_.length,d);for(let U=h;U<d;++U)v+=String.fromCharCode(_[U]&127);return v}function E(_,h,d){let v="";d=Math.min(_.length,d);for(let U=h;U<d;++U)v+=String.fromCharCode(_[U]);return v}function A(_,h,d){const v=_.length;(!h||h<0)&&(h=0),(!d||d<0||d>v)&&(d=v);let U="";for(let F=h;F<d;++F)U+=De[_[F]];return U}function C(_,h,d){const v=_.slice(h,d);let U="";for(let F=0;F<v.length-1;F+=2)U+=String.fromCharCode(v[F]+v[F+1]*256);return U}a.prototype.slice=function(h,d){const v=this.length;h=~~h,d=d===void 0?v:~~d,h<0?(h+=v,h<0&&(h=0)):h>v&&(h=v),d<0?(d+=v,d<0&&(d=0)):d>v&&(d=v),d<h&&(d=h);const U=this.subarray(h,d);return Object.setPrototypeOf(U,a.prototype),U};function R(_,h,d){if(_%1!==0||_<0)throw new RangeError("offset is not uint");if(_+h>d)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(h,d,v){h=h>>>0,d=d>>>0,v||R(h,d,this.length);let U=this[h],F=1,Y=0;for(;++Y<d&&(F*=256);)U+=this[h+Y]*F;return U},a.prototype.readUintBE=a.prototype.readUIntBE=function(h,d,v){h=h>>>0,d=d>>>0,v||R(h,d,this.length);let U=this[h+--d],F=1;for(;d>0&&(F*=256);)U+=this[h+--d]*F;return U},a.prototype.readUint8=a.prototype.readUInt8=function(h,d){return h=h>>>0,d||R(h,1,this.length),this[h]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(h,d){return h=h>>>0,d||R(h,2,this.length),this[h]|this[h+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(h,d){return h=h>>>0,d||R(h,2,this.length),this[h]<<8|this[h+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(h,d){return h=h>>>0,d||R(h,4,this.length),(this[h]|this[h+1]<<8|this[h+2]<<16)+this[h+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(h,d){return h=h>>>0,d||R(h,4,this.length),this[h]*16777216+(this[h+1]<<16|this[h+2]<<8|this[h+3])},a.prototype.readBigUInt64LE=vt(function(h){h=h>>>0,Ue(h,"offset");const d=this[h],v=this[h+7];(d===void 0||v===void 0)&&Se(h,this.length-8);const U=d+this[++h]*2**8+this[++h]*2**16+this[++h]*2**24,F=this[++h]+this[++h]*2**8+this[++h]*2**16+v*2**24;return BigInt(U)+(BigInt(F)<<BigInt(32))}),a.prototype.readBigUInt64BE=vt(function(h){h=h>>>0,Ue(h,"offset");const d=this[h],v=this[h+7];(d===void 0||v===void 0)&&Se(h,this.length-8);const U=d*2**24+this[++h]*2**16+this[++h]*2**8+this[++h],F=this[++h]*2**24+this[++h]*2**16+this[++h]*2**8+v;return(BigInt(U)<<BigInt(32))+BigInt(F)}),a.prototype.readIntLE=function(h,d,v){h=h>>>0,d=d>>>0,v||R(h,d,this.length);let U=this[h],F=1,Y=0;for(;++Y<d&&(F*=256);)U+=this[h+Y]*F;return F*=128,U>=F&&(U-=Math.pow(2,8*d)),U},a.prototype.readIntBE=function(h,d,v){h=h>>>0,d=d>>>0,v||R(h,d,this.length);let U=d,F=1,Y=this[h+--U];for(;U>0&&(F*=256);)Y+=this[h+--U]*F;return F*=128,Y>=F&&(Y-=Math.pow(2,8*d)),Y},a.prototype.readInt8=function(h,d){return h=h>>>0,d||R(h,1,this.length),this[h]&128?(255-this[h]+1)*-1:this[h]},a.prototype.readInt16LE=function(h,d){h=h>>>0,d||R(h,2,this.length);const v=this[h]|this[h+1]<<8;return v&32768?v|4294901760:v},a.prototype.readInt16BE=function(h,d){h=h>>>0,d||R(h,2,this.length);const v=this[h+1]|this[h]<<8;return v&32768?v|4294901760:v},a.prototype.readInt32LE=function(h,d){return h=h>>>0,d||R(h,4,this.length),this[h]|this[h+1]<<8|this[h+2]<<16|this[h+3]<<24},a.prototype.readInt32BE=function(h,d){return h=h>>>0,d||R(h,4,this.length),this[h]<<24|this[h+1]<<16|this[h+2]<<8|this[h+3]},a.prototype.readBigInt64LE=vt(function(h){h=h>>>0,Ue(h,"offset");const d=this[h],v=this[h+7];(d===void 0||v===void 0)&&Se(h,this.length-8);const U=this[h+4]+this[h+5]*2**8+this[h+6]*2**16+(v<<24);return(BigInt(U)<<BigInt(32))+BigInt(d+this[++h]*2**8+this[++h]*2**16+this[++h]*2**24)}),a.prototype.readBigInt64BE=vt(function(h){h=h>>>0,Ue(h,"offset");const d=this[h],v=this[h+7];(d===void 0||v===void 0)&&Se(h,this.length-8);const U=(d<<24)+this[++h]*2**16+this[++h]*2**8+this[++h];return(BigInt(U)<<BigInt(32))+BigInt(this[++h]*2**24+this[++h]*2**16+this[++h]*2**8+v)}),a.prototype.readFloatLE=function(h,d){return h=h>>>0,d||R(h,4,this.length),t.read(this,h,!0,23,4)},a.prototype.readFloatBE=function(h,d){return h=h>>>0,d||R(h,4,this.length),t.read(this,h,!1,23,4)},a.prototype.readDoubleLE=function(h,d){return h=h>>>0,d||R(h,8,this.length),t.read(this,h,!0,52,8)},a.prototype.readDoubleBE=function(h,d){return h=h>>>0,d||R(h,8,this.length),t.read(this,h,!1,52,8)};function u(_,h,d,v,U,F){if(!a.isBuffer(_))throw new TypeError('"buffer" argument must be a Buffer instance');if(h>U||h<F)throw new RangeError('"value" argument is out of bounds');if(d+v>_.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(h,d,v,U){if(h=+h,d=d>>>0,v=v>>>0,!U){const Re=Math.pow(2,8*v)-1;u(this,h,d,v,Re,0)}let F=1,Y=0;for(this[d]=h&255;++Y<v&&(F*=256);)this[d+Y]=h/F&255;return d+v},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(h,d,v,U){if(h=+h,d=d>>>0,v=v>>>0,!U){const Re=Math.pow(2,8*v)-1;u(this,h,d,v,Re,0)}let F=v-1,Y=1;for(this[d+F]=h&255;--F>=0&&(Y*=256);)this[d+F]=h/Y&255;return d+v},a.prototype.writeUint8=a.prototype.writeUInt8=function(h,d,v){return h=+h,d=d>>>0,v||u(this,h,d,1,255,0),this[d]=h&255,d+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(h,d,v){return h=+h,d=d>>>0,v||u(this,h,d,2,65535,0),this[d]=h&255,this[d+1]=h>>>8,d+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(h,d,v){return h=+h,d=d>>>0,v||u(this,h,d,2,65535,0),this[d]=h>>>8,this[d+1]=h&255,d+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(h,d,v){return h=+h,d=d>>>0,v||u(this,h,d,4,4294967295,0),this[d+3]=h>>>24,this[d+2]=h>>>16,this[d+1]=h>>>8,this[d]=h&255,d+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(h,d,v){return h=+h,d=d>>>0,v||u(this,h,d,4,4294967295,0),this[d]=h>>>24,this[d+1]=h>>>16,this[d+2]=h>>>8,this[d+3]=h&255,d+4};function l(_,h,d,v,U){me(h,v,U,_,d,7);let F=Number(h&BigInt(4294967295));_[d++]=F,F=F>>8,_[d++]=F,F=F>>8,_[d++]=F,F=F>>8,_[d++]=F;let Y=Number(h>>BigInt(32)&BigInt(4294967295));return _[d++]=Y,Y=Y>>8,_[d++]=Y,Y=Y>>8,_[d++]=Y,Y=Y>>8,_[d++]=Y,d}function y(_,h,d,v,U){me(h,v,U,_,d,7);let F=Number(h&BigInt(4294967295));_[d+7]=F,F=F>>8,_[d+6]=F,F=F>>8,_[d+5]=F,F=F>>8,_[d+4]=F;let Y=Number(h>>BigInt(32)&BigInt(4294967295));return _[d+3]=Y,Y=Y>>8,_[d+2]=Y,Y=Y>>8,_[d+1]=Y,Y=Y>>8,_[d]=Y,d+8}a.prototype.writeBigUInt64LE=vt(function(h,d=0){return l(this,h,d,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=vt(function(h,d=0){return y(this,h,d,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(h,d,v,U){if(h=+h,d=d>>>0,!U){const _e=Math.pow(2,8*v-1);u(this,h,d,v,_e-1,-_e)}let F=0,Y=1,Re=0;for(this[d]=h&255;++F<v&&(Y*=256);)h<0&&Re===0&&this[d+F-1]!==0&&(Re=1),this[d+F]=(h/Y>>0)-Re&255;return d+v},a.prototype.writeIntBE=function(h,d,v,U){if(h=+h,d=d>>>0,!U){const _e=Math.pow(2,8*v-1);u(this,h,d,v,_e-1,-_e)}let F=v-1,Y=1,Re=0;for(this[d+F]=h&255;--F>=0&&(Y*=256);)h<0&&Re===0&&this[d+F+1]!==0&&(Re=1),this[d+F]=(h/Y>>0)-Re&255;return d+v},a.prototype.writeInt8=function(h,d,v){return h=+h,d=d>>>0,v||u(this,h,d,1,127,-128),h<0&&(h=255+h+1),this[d]=h&255,d+1},a.prototype.writeInt16LE=function(h,d,v){return h=+h,d=d>>>0,v||u(this,h,d,2,32767,-32768),this[d]=h&255,this[d+1]=h>>>8,d+2},a.prototype.writeInt16BE=function(h,d,v){return h=+h,d=d>>>0,v||u(this,h,d,2,32767,-32768),this[d]=h>>>8,this[d+1]=h&255,d+2},a.prototype.writeInt32LE=function(h,d,v){return h=+h,d=d>>>0,v||u(this,h,d,4,2147483647,-2147483648),this[d]=h&255,this[d+1]=h>>>8,this[d+2]=h>>>16,this[d+3]=h>>>24,d+4},a.prototype.writeInt32BE=function(h,d,v){return h=+h,d=d>>>0,v||u(this,h,d,4,2147483647,-2147483648),h<0&&(h=4294967295+h+1),this[d]=h>>>24,this[d+1]=h>>>16,this[d+2]=h>>>8,this[d+3]=h&255,d+4},a.prototype.writeBigInt64LE=vt(function(h,d=0){return l(this,h,d,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=vt(function(h,d=0){return y(this,h,d,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function k(_,h,d,v,U,F){if(d+v>_.length)throw new RangeError("Index out of range");if(d<0)throw new RangeError("Index out of range")}function P(_,h,d,v,U){return h=+h,d=d>>>0,U||k(_,h,d,4),t.write(_,h,d,v,23,4),d+4}a.prototype.writeFloatLE=function(h,d,v){return P(this,h,d,!0,v)},a.prototype.writeFloatBE=function(h,d,v){return P(this,h,d,!1,v)};function G(_,h,d,v,U){return h=+h,d=d>>>0,U||k(_,h,d,8),t.write(_,h,d,v,52,8),d+8}a.prototype.writeDoubleLE=function(h,d,v){return G(this,h,d,!0,v)},a.prototype.writeDoubleBE=function(h,d,v){return G(this,h,d,!1,v)},a.prototype.copy=function(h,d,v,U){if(!a.isBuffer(h))throw new TypeError("argument should be a Buffer");if(v||(v=0),!U&&U!==0&&(U=this.length),d>=h.length&&(d=h.length),d||(d=0),U>0&&U<v&&(U=v),U===v||h.length===0||this.length===0)return 0;if(d<0)throw new RangeError("targetStart out of bounds");if(v<0||v>=this.length)throw new RangeError("Index out of range");if(U<0)throw new RangeError("sourceEnd out of bounds");U>this.length&&(U=this.length),h.length-d<U-v&&(U=h.length-d+v);const F=U-v;return this===h&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(d,v,U):Uint8Array.prototype.set.call(h,this.subarray(v,U),d),F},a.prototype.fill=function(h,d,v,U){if(typeof h=="string"){if(typeof d=="string"?(U=d,d=0,v=this.length):typeof v=="string"&&(U=v,v=this.length),U!==void 0&&typeof U!="string")throw new TypeError("encoding must be a string");if(typeof U=="string"&&!a.isEncoding(U))throw new TypeError("Unknown encoding: "+U);if(h.length===1){const Y=h.charCodeAt(0);(U==="utf8"&&Y<128||U==="latin1")&&(h=Y)}}else typeof h=="number"?h=h&255:typeof h=="boolean"&&(h=Number(h));if(d<0||this.length<d||this.length<v)throw new RangeError("Out of range index");if(v<=d)return this;d=d>>>0,v=v===void 0?this.length:v>>>0,h||(h=0);let F;if(typeof h=="number")for(F=d;F<v;++F)this[F]=h;else{const Y=a.isBuffer(h)?h:a.from(h,U),Re=Y.length;if(Re===0)throw new TypeError('The value "'+h+'" is invalid for argument "value"');for(F=0;F<v-d;++F)this[F+d]=Y[F%Re]}return this};const re={};function J(_,h,d){re[_]=class extends d{constructor(){super(),Object.defineProperty(this,"message",{value:h.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${_}]`,this.stack,delete this.name}get code(){return _}set code(U){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:U,writable:!0})}toString(){return`${this.name} [${_}]: ${this.message}`}}}J("ERR_BUFFER_OUT_OF_BOUNDS",function(_){return _?`${_} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),J("ERR_INVALID_ARG_TYPE",function(_,h){return`The "${_}" argument must be of type number. Received type ${typeof h}`},TypeError),J("ERR_OUT_OF_RANGE",function(_,h,d){let v=`The value of "${_}" is out of range.`,U=d;return Number.isInteger(d)&&Math.abs(d)>2**32?U=Ae(String(d)):typeof d=="bigint"&&(U=String(d),(d>BigInt(2)**BigInt(32)||d<-(BigInt(2)**BigInt(32)))&&(U=Ae(U)),U+="n"),v+=` It must be ${h}. Received ${U}`,v},RangeError);function Ae(_){let h="",d=_.length;const v=_[0]==="-"?1:0;for(;d>=v+4;d-=3)h=`_${_.slice(d-3,d)}${h}`;return`${_.slice(0,d)}${h}`}function ge(_,h,d){Ue(h,"offset"),(_[h]===void 0||_[h+d]===void 0)&&Se(h,_.length-(d+1))}function me(_,h,d,v,U,F){if(_>d||_<h){const Y=typeof h=="bigint"?"n":"";let Re;throw h===0||h===BigInt(0)?Re=`>= 0${Y} and < 2${Y} ** ${(F+1)*8}${Y}`:Re=`>= -(2${Y} ** ${(F+1)*8-1}${Y}) and < 2 ** ${(F+1)*8-1}${Y}`,new re.ERR_OUT_OF_RANGE("value",Re,_)}ge(v,U,F)}function Ue(_,h){if(typeof _!="number")throw new re.ERR_INVALID_ARG_TYPE(h,"number",_)}function Se(_,h,d){throw Math.floor(_)!==_?(Ue(_,d),new re.ERR_OUT_OF_RANGE("offset","an integer",_)):h<0?new re.ERR_BUFFER_OUT_OF_BOUNDS:new re.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${h}`,_)}const Te=/[^+/0-9A-Za-z-_]/g;function Wt(_){if(_=_.split("=")[0],_=_.trim().replace(Te,""),_.length<2)return"";for(;_.length%4!==0;)_=_+"=";return _}function Be(_,h){h=h||1/0;let d;const v=_.length;let U=null;const F=[];for(let Y=0;Y<v;++Y){if(d=_.charCodeAt(Y),d>55295&&d<57344){if(!U){if(d>56319){(h-=3)>-1&&F.push(239,191,189);continue}else if(Y+1===v){(h-=3)>-1&&F.push(239,191,189);continue}U=d;continue}if(d<56320){(h-=3)>-1&&F.push(239,191,189),U=d;continue}d=(U-55296<<10|d-56320)+65536}else U&&(h-=3)>-1&&F.push(239,191,189);if(U=null,d<128){if((h-=1)<0)break;F.push(d)}else if(d<2048){if((h-=2)<0)break;F.push(d>>6|192,d&63|128)}else if(d<65536){if((h-=3)<0)break;F.push(d>>12|224,d>>6&63|128,d&63|128)}else if(d<1114112){if((h-=4)<0)break;F.push(d>>18|240,d>>12&63|128,d>>6&63|128,d&63|128)}else throw new Error("Invalid code point")}return F}function He(_){const h=[];for(let d=0;d<_.length;++d)h.push(_.charCodeAt(d)&255);return h}function Dn(_,h){let d,v,U;const F=[];for(let Y=0;Y<_.length&&!((h-=2)<0);++Y)d=_.charCodeAt(Y),v=d>>8,U=d%256,F.push(U),F.push(v);return F}function Fe(_){return e.toByteArray(Wt(_))}function Le(_,h,d,v){let U;for(U=0;U<v&&!(U+d>=h.length||U>=_.length);++U)h[U+d]=_[U];return U}function Et(_,h){return _ instanceof h||_!=null&&_.constructor!=null&&_.constructor.name!=null&&_.constructor.name===h.name}function Ce(_){return _!==_}const De=function(){const _="0123456789abcdef",h=new Array(256);for(let d=0;d<16;++d){const v=d*16;for(let U=0;U<16;++U)h[v+U]=_[d]+_[U]}return h}();function vt(_){return typeof BigInt>"u"?ze:_}function ze(){throw new Error("BigInt not supported")}}(Fr)),Fr}var he=zr();function rr(n){if(!Number.isSafeInteger(n)||n<0)throw new Error(`positive integer expected, not ${n}`)}function Xa(n){return n instanceof Uint8Array||n!=null&&typeof n=="object"&&n.constructor.name==="Uint8Array"}function Kn(n,...e){if(!Xa(n))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(n.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${n.length}`)}function Ja(n){if(typeof n!="function"||typeof n.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");rr(n.outputLen),rr(n.blockLen)}function bn(n,e=!0){if(n.destroyed)throw new Error("Hash instance has been destroyed");if(e&&n.finished)throw new Error("Hash#digest() has already been called")}function Os(n,e){Kn(n);const t=e.outputLen;if(n.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}const Kr=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Qa=n=>new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4)),$r=n=>new DataView(n.buffer,n.byteOffset,n.byteLength),Ct=(n,e)=>n<<32-e|n>>>e,ks=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,ec=n=>n<<24&4278190080|n<<8&16711680|n>>>8&65280|n>>>24&255;function Ts(n){for(let e=0;e<n.length;e++)n[e]=ec(n[e])}function tc(n){if(typeof n!="string")throw new Error(`utf8ToBytes expected string, got ${typeof n}`);return new Uint8Array(new TextEncoder().encode(n))}function ir(n){return typeof n=="string"&&(n=tc(n)),Kn(n),n}function nc(...n){let e=0;for(let r=0;r<n.length;r++){const s=n[r];Kn(s),e+=s.length}const t=new Uint8Array(e);for(let r=0,s=0;r<n.length;r++){const i=n[r];t.set(i,s),s+=i.length}return t}class Hr{clone(){return this._cloneInto()}}function Wr(n){const e=r=>n().update(ir(r)).digest(),t=n();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>n(),e}function Ns(n=32){if(Kr&&typeof Kr.getRandomValues=="function")return Kr.getRandomValues(new Uint8Array(n));throw new Error("crypto.getRandomValues must be defined")}function rc(n,e,t,r){if(typeof n.setBigUint64=="function")return n.setBigUint64(e,t,r);const s=BigInt(32),i=BigInt(4294967295),o=Number(t>>s&i),a=Number(t&i),f=r?4:0,g=r?0:4;n.setUint32(e+f,o,r),n.setUint32(e+g,a,r)}const ic=(n,e,t)=>n&e^~n&t,sc=(n,e,t)=>n&e^n&t^e&t;class xs extends Hr{constructor(e,t,r,s){super(),this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=$r(this.buffer)}update(e){bn(this);const{view:t,buffer:r,blockLen:s}=this;e=ir(e);const i=e.length;for(let o=0;o<i;){const a=Math.min(s-this.pos,i-o);if(a===s){const f=$r(e);for(;s<=i-o;o+=s)this.process(f,o);continue}r.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===s&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){bn(this),Os(e,this),this.finished=!0;const{buffer:t,view:r,blockLen:s,isLE:i}=this;let{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>s-o&&(this.process(r,0),o=0);for(let b=o;b<s;b++)t[b]=0;rc(r,s-8,BigInt(this.length*8),i),this.process(r,0);const a=$r(e),f=this.outputLen;if(f%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const g=f/4,w=this.get();if(g>w.length)throw new Error("_sha2: outputLen bigger than state");for(let b=0;b<g;b++)a.setUint32(4*b,w[b],i)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:r,length:s,finished:i,destroyed:o,pos:a}=this;return e.length=s,e.pos=a,e.finished=i,e.destroyed=o,s%t&&e.buffer.set(r),e}}const sr=BigInt(2**32-1),qr=BigInt(32);function Bs(n,e=!1){return e?{h:Number(n&sr),l:Number(n>>qr&sr)}:{h:Number(n>>qr&sr)|0,l:Number(n&sr)|0}}function Ls(n,e=!1){let t=new Uint32Array(n.length),r=new Uint32Array(n.length);for(let s=0;s<n.length;s++){const{h:i,l:o}=Bs(n[s],e);[t[s],r[s]]=[i,o]}return[t,r]}const oc=(n,e)=>BigInt(n>>>0)<<qr|BigInt(e>>>0),ac=(n,e,t)=>n>>>t,cc=(n,e,t)=>n<<32-t|e>>>t,uc=(n,e,t)=>n>>>t|e<<32-t,lc=(n,e,t)=>n<<32-t|e>>>t,hc=(n,e,t)=>n<<64-t|e>>>t-32,fc=(n,e,t)=>n>>>t-32|e<<64-t,dc=(n,e)=>e,pc=(n,e)=>n,Cs=(n,e,t)=>n<<t|e>>>32-t,Ms=(n,e,t)=>e<<t|n>>>32-t,Ps=(n,e,t)=>e<<t-32|n>>>64-t,Us=(n,e,t)=>n<<t-32|e>>>64-t;function gc(n,e,t,r){const s=(e>>>0)+(r>>>0);return{h:n+t+(s/2**32|0)|0,l:s|0}}const ye={fromBig:Bs,split:Ls,toBig:oc,shrSH:ac,shrSL:cc,rotrSH:uc,rotrSL:lc,rotrBH:hc,rotrBL:fc,rotr32H:dc,rotr32L:pc,rotlSH:Cs,rotlSL:Ms,rotlBH:Ps,rotlBL:Us,add:gc,add3L:(n,e,t)=>(n>>>0)+(e>>>0)+(t>>>0),add3H:(n,e,t,r)=>e+t+r+(n/2**32|0)|0,add4L:(n,e,t,r)=>(n>>>0)+(e>>>0)+(t>>>0)+(r>>>0),add4H:(n,e,t,r,s)=>e+t+r+s+(n/2**32|0)|0,add5H:(n,e,t,r,s,i)=>e+t+r+s+i+(n/2**32|0)|0,add5L:(n,e,t,r,s)=>(n>>>0)+(e>>>0)+(t>>>0)+(r>>>0)+(s>>>0)},[mc,_c]=ye.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(n=>BigInt(n))),Xt=new Uint32Array(80),Jt=new Uint32Array(80);class yc extends xs{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:t,Bh:r,Bl:s,Ch:i,Cl:o,Dh:a,Dl:f,Eh:g,El:w,Fh:b,Fl:x,Gh:T,Gl:L,Hh:O,Hl:N}=this;return[e,t,r,s,i,o,a,f,g,w,b,x,T,L,O,N]}set(e,t,r,s,i,o,a,f,g,w,b,x,T,L,O,N){this.Ah=e|0,this.Al=t|0,this.Bh=r|0,this.Bl=s|0,this.Ch=i|0,this.Cl=o|0,this.Dh=a|0,this.Dl=f|0,this.Eh=g|0,this.El=w|0,this.Fh=b|0,this.Fl=x|0,this.Gh=T|0,this.Gl=L|0,this.Hh=O|0,this.Hl=N|0}process(e,t){for(let K=0;K<16;K++,t+=4)Xt[K]=e.getUint32(t),Jt[K]=e.getUint32(t+=4);for(let K=16;K<80;K++){const Q=Xt[K-15]|0,q=Jt[K-15]|0,D=ye.rotrSH(Q,q,1)^ye.rotrSH(Q,q,8)^ye.shrSH(Q,q,7),Z=ye.rotrSL(Q,q,1)^ye.rotrSL(Q,q,8)^ye.shrSL(Q,q,7),j=Xt[K-2]|0,X=Jt[K-2]|0,z=ye.rotrSH(j,X,19)^ye.rotrBH(j,X,61)^ye.shrSH(j,X,6),V=ye.rotrSL(j,X,19)^ye.rotrBL(j,X,61)^ye.shrSL(j,X,6),ee=ye.add4L(Z,V,Jt[K-7],Jt[K-16]),S=ye.add4H(ee,D,z,Xt[K-7],Xt[K-16]);Xt[K]=S|0,Jt[K]=ee|0}let{Ah:r,Al:s,Bh:i,Bl:o,Ch:a,Cl:f,Dh:g,Dl:w,Eh:b,El:x,Fh:T,Fl:L,Gh:O,Gl:N,Hh:M,Hl:H}=this;for(let K=0;K<80;K++){const Q=ye.rotrSH(b,x,14)^ye.rotrSH(b,x,18)^ye.rotrBH(b,x,41),q=ye.rotrSL(b,x,14)^ye.rotrSL(b,x,18)^ye.rotrBL(b,x,41),D=b&T^~b&O,Z=x&L^~x&N,j=ye.add5L(H,q,Z,_c[K],Jt[K]),X=ye.add5H(j,M,Q,D,mc[K],Xt[K]),z=j|0,V=ye.rotrSH(r,s,28)^ye.rotrBH(r,s,34)^ye.rotrBH(r,s,39),ee=ye.rotrSL(r,s,28)^ye.rotrBL(r,s,34)^ye.rotrBL(r,s,39),S=r&i^r&a^i&a,c=s&o^s&f^o&f;M=O|0,H=N|0,O=T|0,N=L|0,T=b|0,L=x|0,{h:b,l:x}=ye.add(g|0,w|0,X|0,z|0),g=a|0,w=f|0,a=i|0,f=o|0,i=r|0,o=s|0;const p=ye.add3L(z,ee,c);r=ye.add3H(p,X,V,S),s=p|0}({h:r,l:s}=ye.add(this.Ah|0,this.Al|0,r|0,s|0)),{h:i,l:o}=ye.add(this.Bh|0,this.Bl|0,i|0,o|0),{h:a,l:f}=ye.add(this.Ch|0,this.Cl|0,a|0,f|0),{h:g,l:w}=ye.add(this.Dh|0,this.Dl|0,g|0,w|0),{h:b,l:x}=ye.add(this.Eh|0,this.El|0,b|0,x|0),{h:T,l:L}=ye.add(this.Fh|0,this.Fl|0,T|0,L|0),{h:O,l:N}=ye.add(this.Gh|0,this.Gl|0,O|0,N|0),{h:M,l:H}=ye.add(this.Hh|0,this.Hl|0,M|0,H|0),this.set(r,s,i,o,a,f,g,w,b,x,T,L,O,N,M,H)}roundClean(){Xt.fill(0),Jt.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 wc=Wr(()=>new yc);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ds=BigInt(0),or=BigInt(1),bc=BigInt(2);function on(n){return n instanceof Uint8Array||n!=null&&typeof n=="object"&&n.constructor.name==="Uint8Array"}function $n(n){if(!on(n))throw new Error("Uint8Array expected")}const Rc=Array.from({length:256},(n,e)=>e.toString(16).padStart(2,"0"));function an(n){$n(n);let e="";for(let t=0;t<n.length;t++)e+=Rc[n[t]];return e}function Fs(n){const e=n.toString(16);return e.length&1?`0${e}`:e}function Vr(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);return BigInt(n===""?"0":`0x${n}`)}const qt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function zs(n){if(n>=qt._0&&n<=qt._9)return n-qt._0;if(n>=qt._A&&n<=qt._F)return n-(qt._A-10);if(n>=qt._a&&n<=qt._f)return n-(qt._a-10)}function Rn(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);const e=n.length,t=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(t);for(let s=0,i=0;s<t;s++,i+=2){const o=zs(n.charCodeAt(i)),a=zs(n.charCodeAt(i+1));if(o===void 0||a===void 0){const f=n[i]+n[i+1];throw new Error('hex string expected, got non-hex character "'+f+'" at index '+i)}r[s]=o*16+a}return r}function cn(n){return Vr(an(n))}function En(n){return $n(n),Vr(an(Uint8Array.from(n).reverse()))}function Sn(n,e){return Rn(n.toString(16).padStart(e*2,"0"))}function Hn(n,e){return Sn(n,e).reverse()}function Ec(n){return Rn(Fs(n))}function ft(n,e,t){let r;if(typeof e=="string")try{r=Rn(e)}catch(i){throw new Error(`${n} must be valid hex string, got "${e}". Cause: ${i}`)}else if(on(e))r=Uint8Array.from(e);else throw new Error(`${n} must be hex string or Uint8Array`);const s=r.length;if(typeof t=="number"&&s!==t)throw new Error(`${n} expected ${t} bytes, got ${s}`);return r}function un(...n){let e=0;for(let r=0;r<n.length;r++){const s=n[r];$n(s),e+=s.length}const t=new Uint8Array(e);for(let r=0,s=0;r<n.length;r++){const i=n[r];t.set(i,s),s+=i.length}return t}function Sc(n,e){if(n.length!==e.length)return!1;let t=0;for(let r=0;r<n.length;r++)t|=n[r]^e[r];return t===0}function Ac(n){if(typeof n!="string")throw new Error(`utf8ToBytes expected string, got ${typeof n}`);return new Uint8Array(new TextEncoder().encode(n))}function Ic(n){let e;for(e=0;n>Ds;n>>=or,e+=1);return e}function vc(n,e){return n>>BigInt(e)&or}function Oc(n,e,t){return n|(t?or:Ds)<<BigInt(e)}const Gr=n=>(bc<<BigInt(n-1))-or,Yr=n=>new Uint8Array(n),Ks=n=>Uint8Array.from(n);function $s(n,e,t){if(typeof n!="number"||n<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");let r=Yr(n),s=Yr(n),i=0;const o=()=>{r.fill(1),s.fill(0),i=0},a=(...b)=>t(s,r,...b),f=(b=Yr())=>{s=a(Ks([0]),b),r=a(),b.length!==0&&(s=a(Ks([1]),b),r=a())},g=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let b=0;const x=[];for(;b<e;){r=a();const T=r.slice();x.push(T),b+=r.length}return un(...x)};return(b,x)=>{o(),f(b);let T;for(;!(T=x(g()));)f();return o(),T}}const kc={bigint:n=>typeof n=="bigint",function:n=>typeof n=="function",boolean:n=>typeof n=="boolean",string:n=>typeof n=="string",stringOrUint8Array:n=>typeof n=="string"||on(n),isSafeInteger:n=>Number.isSafeInteger(n),array:n=>Array.isArray(n),field:(n,e)=>e.Fp.isValid(n),hash:n=>typeof n=="function"&&Number.isSafeInteger(n.outputLen)};function An(n,e,t={}){const r=(s,i,o)=>{const a=kc[i];if(typeof a!="function")throw new Error(`Invalid validator "${i}", expected function`);const f=n[s];if(!(o&&f===void 0)&&!a(f,n))throw new Error(`Invalid param ${String(s)}=${f} (${typeof f}), expected ${i}`)};for(const[s,i]of Object.entries(e))r(s,i,!1);for(const[s,i]of Object.entries(t))r(s,i,!0);return n}const Tc=Object.freeze(Object.defineProperty({__proto__:null,abytes:$n,bitGet:vc,bitLen:Ic,bitMask:Gr,bitSet:Oc,bytesToHex:an,bytesToNumberBE:cn,bytesToNumberLE:En,concatBytes:un,createHmacDrbg:$s,ensureBytes:ft,equalBytes:Sc,hexToBytes:Rn,hexToNumber:Vr,isBytes:on,numberToBytesBE:Sn,numberToBytesLE:Hn,numberToHexUnpadded:Fs,numberToVarBytesBE:Ec,utf8ToBytes:Ac,validateObject:An},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const dt=BigInt(0),We=BigInt(1),ln=BigInt(2),Nc=BigInt(3),jr=BigInt(4),Hs=BigInt(5),Ws=BigInt(8);BigInt(9),BigInt(16);function $e(n,e){const t=n%e;return t>=dt?t:e+t}function xc(n,e,t){if(t<=dt||e<dt)throw new Error("Expected power/modulo > 0");if(t===We)return dt;let r=We;for(;e>dt;)e&We&&(r=r*n%t),n=n*n%t,e>>=We;return r}function Ge(n,e,t){let r=n;for(;e-- >dt;)r*=r,r%=t;return r}function Zr(n,e){if(n===dt||e<=dt)throw new Error(`invert: expected positive integers, got n=${n} mod=${e}`);let t=$e(n,e),r=e,s=dt,i=We;for(;t!==dt;){const a=r/t,f=r%t,g=s-i*a;r=t,t=f,s=i,i=g}if(r!==We)throw new Error("invert: does not exist");return $e(s,e)}function Bc(n){const e=(n-We)/ln;let t,r,s;for(t=n-We,r=0;t%ln===dt;t/=ln,r++);for(s=ln;s<n&&xc(s,e,n)!==n-We;s++);if(r===1){const o=(n+We)/jr;return function(f,g){const w=f.pow(g,o);if(!f.eql(f.sqr(w),g))throw new Error("Cannot find square root");return w}}const i=(t+We)/ln;return function(a,f){if(a.pow(f,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let g=r,w=a.pow(a.mul(a.ONE,s),t),b=a.pow(f,i),x=a.pow(f,t);for(;!a.eql(x,a.ONE);){if(a.eql(x,a.ZERO))return a.ZERO;let T=1;for(let O=a.sqr(x);T<g&&!a.eql(O,a.ONE);T++)O=a.sqr(O);const L=a.pow(w,We<<BigInt(g-T-1));w=a.sqr(L),b=a.mul(b,L),x=a.mul(x,w),g=T}return b}}function Lc(n){if(n%jr===Nc){const e=(n+We)/jr;return function(r,s){const i=r.pow(s,e);if(!r.eql(r.sqr(i),s))throw new Error("Cannot find square root");return i}}if(n%Ws===Hs){const e=(n-Hs)/Ws;return function(r,s){const i=r.mul(s,ln),o=r.pow(i,e),a=r.mul(s,o),f=r.mul(r.mul(a,ln),o),g=r.mul(a,r.sub(f,r.ONE));if(!r.eql(r.sqr(g),s))throw new Error("Cannot find square root");return g}}return Bc(n)}const Cc=(n,e)=>($e(n,e)&We)===We,Mc=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Pc(n){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=Mc.reduce((r,s)=>(r[s]="function",r),e);return An(n,t)}function Uc(n,e,t){if(t<dt)throw new Error("Expected power > 0");if(t===dt)return n.ONE;if(t===We)return e;let r=n.ONE,s=e;for(;t>dt;)t&We&&(r=n.mul(r,s)),s=n.sqr(s),t>>=We;return r}function Dc(n,e){const t=new Array(e.length),r=e.reduce((i,o,a)=>n.is0(o)?i:(t[a]=i,n.mul(i,o)),n.ONE),s=n.inv(r);return e.reduceRight((i,o,a)=>n.is0(o)?i:(t[a]=n.mul(i,t[a]),n.mul(i,o)),s),t}function qs(n,e){const t=e!==void 0?e:n.toString(2).length,r=Math.ceil(t/8);return{nBitLength:t,nByteLength:r}}function Vs(n,e,t=!1,r={}){if(n<=dt)throw new Error(`Expected Field ORDER > 0, got ${n}`);const{nBitLength:s,nByteLength:i}=qs(n,e);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");const o=Lc(n),a=Object.freeze({ORDER:n,BITS:s,BYTES:i,MASK:Gr(s),ZERO:dt,ONE:We,create:f=>$e(f,n),isValid:f=>{if(typeof f!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof f}`);return dt<=f&&f<n},is0:f=>f===dt,isOdd:f=>(f&We)===We,neg:f=>$e(-f,n),eql:(f,g)=>f===g,sqr:f=>$e(f*f,n),add:(f,g)=>$e(f+g,n),sub:(f,g)=>$e(f-g,n),mul:(f,g)=>$e(f*g,n),pow:(f,g)=>Uc(a,f,g),div:(f,g)=>$e(f*Zr(g,n),n),sqrN:f=>f*f,addN:(f,g)=>f+g,subN:(f,g)=>f-g,mulN:(f,g)=>f*g,inv:f=>Zr(f,n),sqrt:r.sqrt||(f=>o(a,f)),invertBatch:f=>Dc(a,f),cmov:(f,g,w)=>w?g:f,toBytes:f=>t?Hn(f,i):Sn(f,i),fromBytes:f=>{if(f.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${f.length}`);return t?En(f):cn(f)}});return Object.freeze(a)}function Gs(n){if(typeof n!="bigint")throw new Error("field order must be bigint");const e=n.toString(2).length;return Math.ceil(e/8)}function Ys(n){const e=Gs(n);return e+Math.ceil(e/2)}function Fc(n,e,t=!1){const r=n.length,s=Gs(e),i=Ys(e);if(r<16||r<i||r>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${r}`);const o=t?cn(n):En(n),a=$e(o,e-We)+We;return t?Hn(a,s):Sn(a,s)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const zc=BigInt(0),Xr=BigInt(1);function js(n,e){const t=(s,i)=>{const o=i.negate();return s?o:i},r=s=>{const i=Math.ceil(e/s)+1,o=2**(s-1);return{windows:i,windowSize:o}};return{constTimeNegate:t,unsafeLadder(s,i){let o=n.ZERO,a=s;for(;i>zc;)i&Xr&&(o=o.add(a)),a=a.double(),i>>=Xr;return o},precomputeWindow(s,i){const{windows:o,windowSize:a}=r(i),f=[];let g=s,w=g;for(let b=0;b<o;b++){w=g,f.push(w);for(let x=1;x<a;x++)w=w.add(g),f.push(w);g=w.double()}return f},wNAF(s,i,o){const{windows:a,windowSize:f}=r(s);let g=n.ZERO,w=n.BASE;const b=BigInt(2**s-1),x=2**s,T=BigInt(s);for(let L=0;L<a;L++){const O=L*f;let N=Number(o&b);o>>=T,N>f&&(N-=x,o+=Xr);const M=O,H=O+Math.abs(N)-1,K=L%2!==0,Q=N<0;N===0?w=w.add(t(K,i[M])):g=g.add(t(Q,i[H]))}return{p:g,f:w}},wNAFCached(s,i,o,a){const f=s._WINDOW_SIZE||1;let g=i.get(s);return g||(g=this.precomputeWindow(s,f),f!==1&&i.set(s,a(g))),this.wNAF(f,g,o)}}}function Jr(n){return Pc(n.Fp),An(n,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...qs(n.n,n.nBitLength),...n,p:n.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Nt=BigInt(0),Ot=BigInt(1),ar=BigInt(2),Kc=BigInt(8),$c={zip215:!0};function Hc(n){const e=Jr(n);return An(n,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function Wc(n){const e=Hc(n),{Fp:t,n:r,prehash:s,hash:i,randomBytes:o,nByteLength:a,h:f}=e,g=ar<<BigInt(a*8)-Ot,w=t.create,b=e.uvRatio||((E,A)=>{try{return{isValid:!0,value:t.sqrt(E*t.inv(A))}}catch{return{isValid:!1,value:Nt}}}),x=e.adjustScalarBytes||(E=>E),T=e.domain||((E,A,C)=>{if(A.length||C)throw new Error("Contexts/pre-hash are not supported");return E}),L=E=>typeof E=="bigint"&&Nt<E,O=(E,A)=>L(E)&&L(A)&&E<A,N=E=>E===Nt||O(E,g);function M(E,A){if(O(E,A))return E;throw new Error(`Expected valid scalar < ${A}, got ${typeof E} ${E}`)}function H(E){return E===Nt?E:M(E,r)}const K=new Map;function Q(E){if(!(E instanceof q))throw new Error("ExtendedPoint expected")}class q{constructor(A,C,R,u){if(this.ex=A,this.ey=C,this.ez=R,this.et=u,!N(A))throw new Error("x required");if(!N(C))throw new Error("y required");if(!N(R))throw new Error("z required");if(!N(u))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(A){if(A instanceof q)throw new Error("extended point not allowed");const{x:C,y:R}=A||{};if(!N(C)||!N(R))throw new Error("invalid affine point");return new q(C,R,Ot,w(C*R))}static normalizeZ(A){const C=t.invertBatch(A.map(R=>R.ez));return A.map((R,u)=>R.toAffine(C[u])).map(q.fromAffine)}_setWindowSize(A){this._WINDOW_SIZE=A,K.delete(this)}assertValidity(){const{a:A,d:C}=e;if(this.is0())throw new Error("bad point: ZERO");const{ex:R,ey:u,ez:l,et:y}=this,k=w(R*R),P=w(u*u),G=w(l*l),re=w(G*G),J=w(k*A),Ae=w(G*w(J+P)),ge=w(re+w(C*w(k*P)));if(Ae!==ge)throw new Error("bad point: equation left != right (1)");const me=w(R*u),Ue=w(l*y);if(me!==Ue)throw new Error("bad point: equation left != right (2)")}equals(A){Q(A);const{ex:C,ey:R,ez:u}=this,{ex:l,ey:y,ez:k}=A,P=w(C*k),G=w(l*u),re=w(R*k),J=w(y*u);return P===G&&re===J}is0(){return this.equals(q.ZERO)}negate(){return new q(w(-this.ex),this.ey,this.ez,w(-this.et))}double(){const{a:A}=e,{ex:C,ey:R,ez:u}=this,l=w(C*C),y=w(R*R),k=w(ar*w(u*u)),P=w(A*l),G=C+R,re=w(w(G*G)-l-y),J=P+y,Ae=J-k,ge=P-y,me=w(re*Ae),Ue=w(J*ge),Se=w(re*ge),Te=w(Ae*J);return new q(me,Ue,Te,Se)}add(A){Q(A);const{a:C,d:R}=e,{ex:u,ey:l,ez:y,et:k}=this,{ex:P,ey:G,ez:re,et:J}=A;if(C===BigInt(-1)){const Et=w((l-u)*(G+P)),Ce=w((l+u)*(G-P)),De=w(Ce-Et);if(De===Nt)return this.double();const vt=w(y*ar*J),ze=w(k*ar*re),_=ze+vt,h=Ce+Et,d=ze-vt,v=w(_*De),U=w(h*d),F=w(_*d),Y=w(De*h);return new q(v,U,Y,F)}const Ae=w(u*P),ge=w(l*G),me=w(k*R*J),Ue=w(y*re),Se=w((u+l)*(P+G)-Ae-ge),Te=Ue-me,Wt=Ue+me,Be=w(ge-C*Ae),He=w(Se*Te),Dn=w(Wt*Be),Fe=w(Se*Be),Le=w(Te*Wt);return new q(He,Dn,Le,Fe)}subtract(A){return this.add(A.negate())}wNAF(A){return j.wNAFCached(this,K,A,q.normalizeZ)}multiply(A){const{p:C,f:R}=this.wNAF(M(A,r));return q.normalizeZ([C,R])[0]}multiplyUnsafe(A){let C=H(A);return C===Nt?Z:this.equals(Z)||C===Ot?this:this.equals(D)?this.wNAF(C).p:j.unsafeLadder(this,C)}isSmallOrder(){return this.multiplyUnsafe(f).is0()}isTorsionFree(){return j.unsafeLadder(this,r).is0()}toAffine(A){const{ex:C,ey:R,ez:u}=this,l=this.is0();A==null&&(A=l?Kc:t.inv(u));const y=w(C*A),k=w(R*A),P=w(u*A);if(l)return{x:Nt,y:Ot};if(P!==Ot)throw new Error("invZ was invalid");return{x:y,y:k}}clearCofactor(){const{h:A}=e;return A===Ot?this:this.multiplyUnsafe(A)}static fromHex(A,C=!1){const{d:R,a:u}=e,l=t.BYTES;A=ft("pointHex",A,l);const y=A.slice(),k=A[l-1];y[l-1]=k&-129;const P=En(y);P===Nt||(C?M(P,g):M(P,t.ORDER));const G=w(P*P),re=w(G-Ot),J=w(R*G-u);let{isValid:Ae,value:ge}=b(re,J);if(!Ae)throw new Error("Point.fromHex: invalid y coordinate");const me=(ge&Ot)===Ot,Ue=(k&128)!==0;if(!C&&ge===Nt&&Ue)throw new Error("Point.fromHex: x=0 and x_0=1");return Ue!==me&&(ge=w(-ge)),q.fromAffine({x:ge,y:P})}static fromPrivateKey(A){return V(A).point}toRawBytes(){const{x:A,y:C}=this.toAffine(),R=Hn(C,t.BYTES);return R[R.length-1]|=A&Ot?128:0,R}toHex(){return an(this.toRawBytes())}}q.BASE=new q(e.Gx,e.Gy,Ot,w(e.Gx*e.Gy)),q.ZERO=new q(Nt,Ot,Ot,Nt);const{BASE:D,ZERO:Z}=q,j=js(q,a*8);function X(E){return $e(E,r)}function z(E){return X(En(E))}function V(E){const A=a;E=ft("private key",E,A);const C=ft("hashed private key",i(E),2*A),R=x(C.slice(0,A)),u=C.slice(A,2*A),l=z(R),y=D.multiply(l),k=y.toRawBytes();return{head:R,prefix:u,scalar:l,point:y,pointBytes:k}}function ee(E){return V(E).pointBytes}function S(E=new Uint8Array,...A){const C=un(...A);return z(i(T(C,ft("context",E),!!s)))}function c(E,A,C={}){E=ft("message",E),s&&(E=s(E));const{prefix:R,scalar:u,pointBytes:l}=V(A),y=S(C.context,R,E),k=D.multiply(y).toRawBytes(),P=S(C.context,k,l,E),G=X(y+P*u);H(G);const re=un(k,Hn(G,t.BYTES));return ft("result",re,a*2)}const p=$c;function m(E,A,C,R=p){const{context:u,zip215:l}=R,y=t.BYTES;E=ft("signature",E,2*y),A=ft("message",A),s&&(A=s(A));const k=En(E.slice(y,2*y));let P,G,re;try{P=q.fromHex(C,l),G=q.fromHex(E.slice(0,y),l),re=D.multiplyUnsafe(k)}catch{return!1}if(!l&&P.isSmallOrder())return!1;const J=S(u,G.toRawBytes(),P.toRawBytes(),A);return G.add(P.multiplyUnsafe(J)).subtract(re).clearCofactor().equals(q.ZERO)}return D._setWindowSize(8),{CURVE:e,getPublicKey:ee,sign:c,verify:m,ExtendedPoint:q,utils:{getExtendedPublicKey:V,randomPrivateKey:()=>o(t.BYTES),precompute(E=8,A=q.BASE){return A._setWindowSize(E),A.multiply(BigInt(3)),A}}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Qr=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Zs=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const qc=BigInt(1),Xs=BigInt(2);BigInt(3);const Vc=BigInt(5),Gc=BigInt(8);function Yc(n){const e=BigInt(10),t=BigInt(20),r=BigInt(40),s=BigInt(80),i=Qr,a=n*n%i*n%i,f=Ge(a,Xs,i)*a%i,g=Ge(f,qc,i)*n%i,w=Ge(g,Vc,i)*g%i,b=Ge(w,e,i)*w%i,x=Ge(b,t,i)*b%i,T=Ge(x,r,i)*x%i,L=Ge(T,s,i)*T%i,O=Ge(L,s,i)*T%i,N=Ge(O,e,i)*w%i;return{pow_p_5_8:Ge(N,Xs,i)*n%i,b2:a}}function jc(n){return n[0]&=248,n[31]&=127,n[31]|=64,n}function Zc(n,e){const t=Qr,r=$e(e*e*e,t),s=$e(r*r*e,t),i=Yc(n*s).pow_p_5_8;let o=$e(n*r*i,t);const a=$e(e*o*o,t),f=o,g=$e(o*Zs,t),w=a===n,b=a===$e(-n,t),x=a===$e(-n*Zs,t);return w&&(o=f),(b||x)&&(o=g),Cc(o,t)&&(o=$e(-o,t)),{isValid:w||b,value:o}}const Xc=Vs(Qr,void 0,!0),Jc={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Xc,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Gc,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:wc,randomBytes:Ns,adjustScalarBytes:jc,uvRatio:Zc},In=Wc(Jc);var cr={exports:{}};const Qc=Dr(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var eu=cr.exports,Js;function Qs(){return Js||(Js=1,function(n){(function(e,t){function r(S,c){if(!S)throw new Error(c||"Assertion failed")}function s(S,c){S.super_=c;var p=function(){};p.prototype=c.prototype,S.prototype=new p,S.prototype.constructor=S}function i(S,c,p){if(i.isBN(S))return S;this.negative=0,this.words=null,this.length=0,this.red=null,S!==null&&((c==="le"||c==="be")&&(p=c,c=10),this._init(S||0,c||10,p||"be"))}typeof e=="object"?e.exports=i:t.BN=i,i.BN=i,i.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=Qc.Buffer}catch{}i.isBN=function(c){return c instanceof i?!0:c!==null&&typeof c=="object"&&c.constructor.wordSize===i.wordSize&&Array.isArray(c.words)},i.max=function(c,p){return c.cmp(p)>0?c:p},i.min=function(c,p){return c.cmp(p)<0?c:p},i.prototype._init=function(c,p,m){if(typeof c=="number")return this._initNumber(c,p,m);if(typeof c=="object")return this._initArray(c,p,m);p==="hex"&&(p=16),r(p===(p|0)&&p>=2&&p<=36),c=c.toString().replace(/\s+/g,"");var I=0;c[0]==="-"&&(I++,this.negative=1),I<c.length&&(p===16?this._parseHex(c,I,m):(this._parseBase(c,p,I),m==="le"&&this._initArray(this.toArray(),p,m)))},i.prototype._initNumber=function(c,p,m){c<0&&(this.negative=1,c=-c),c<67108864?(this.words=[c&67108863],this.length=1):c<4503599627370496?(this.words=[c&67108863,c/67108864&67108863],this.length=2):(r(c<9007199254740992),this.words=[c&67108863,c/67108864&67108863,1],this.length=3),m==="le"&&this._initArray(this.toArray(),p,m)},i.prototype._initArray=function(c,p,m){if(r(typeof c.length=="number"),c.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(c.length/3),this.words=new Array(this.length);for(var I=0;I<this.length;I++)this.words[I]=0;var E,A,C=0;if(m==="be")for(I=c.length-1,E=0;I>=0;I-=3)A=c[I]|c[I-1]<<8|c[I-2]<<16,this.words[E]|=A<<C&67108863,this.words[E+1]=A>>>26-C&67108863,C+=24,C>=26&&(C-=26,E++);else if(m==="le")for(I=0,E=0;I<c.length;I+=3)A=c[I]|c[I+1]<<8|c[I+2]<<16,this.words[E]|=A<<C&67108863,this.words[E+1]=A>>>26-C&67108863,C+=24,C>=26&&(C-=26,E++);return this._strip()};function a(S,c){var p=S.charCodeAt(c);if(p>=48&&p<=57)return p-48;if(p>=65&&p<=70)return p-55;if(p>=97&&p<=102)return p-87;r(!1,"Invalid character in "+S)}function f(S,c,p){var m=a(S,p);return p-1>=c&&(m|=a(S,p-1)<<4),m}i.prototype._parseHex=function(c,p,m){this.length=Math.ceil((c.length-p)/6),this.words=new Array(this.length);for(var I=0;I<this.length;I++)this.words[I]=0;var E=0,A=0,C;if(m==="be")for(I=c.length-1;I>=p;I-=2)C=f(c,p,I)<<E,this.words[A]|=C&67108863,E>=18?(E-=18,A+=1,this.words[A]|=C>>>26):E+=8;else{var R=c.length-p;for(I=R%2===0?p+1:p;I<c.length;I+=2)C=f(c,p,I)<<E,this.words[A]|=C&67108863,E>=18?(E-=18,A+=1,this.words[A]|=C>>>26):E+=8}this._strip()};function g(S,c,p,m){for(var I=0,E=0,A=Math.min(S.length,p),C=c;C<A;C++){var R=S.charCodeAt(C)-48;I*=m,R>=49?E=R-49+10:R>=17?E=R-17+10:E=R,r(R>=0&&E<m,"Invalid character"),I+=E}return I}i.prototype._parseBase=function(c,p,m){this.words=[0],this.length=1;for(var I=0,E=1;E<=67108863;E*=p)I++;I--,E=E/p|0;for(var A=c.length-m,C=A%I,R=Math.min(A,A-C)+m,u=0,l=m;l<R;l+=I)u=g(c,l,l+I,p),this.imuln(E),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(C!==0){var y=1;for(u=g(c,l,c.length,p),l=0;l<C;l++)y*=p;this.imuln(y),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this._strip()},i.prototype.copy=function(c){c.words=new Array(this.length);for(var p=0;p<this.length;p++)c.words[p]=this.words[p];c.length=this.length,c.negative=this.negative,c.red=this.red};function w(S,c){S.words=c.words,S.length=c.length,S.negative=c.negative,S.red=c.red}if(i.prototype._move=function(c){w(c,this)},i.prototype.clone=function(){var c=new i(null);return this.copy(c),c},i.prototype._expand=function(c){for(;this.length<c;)this.words[this.length++]=0;return this},i.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},i.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{i.prototype[Symbol.for("nodejs.util.inspect.custom")]=b}catch{i.prototype.inspect=b}else i.prototype.inspect=b;function b(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var x=["","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"],T=[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],L=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];i.prototype.toString=function(c,p){c=c||10,p=p|0||1;var m;if(c===16||c==="hex"){m="";for(var I=0,E=0,A=0;A<this.length;A++){var C=this.words[A],R=((C<<I|E)&16777215).toString(16);E=C>>>24-I&16777215,I+=2,I>=26&&(I-=26,A--),E!==0||A!==this.length-1?m=x[6-R.length]+R+m:m=R+m}for(E!==0&&(m=E.toString(16)+m);m.length%p!==0;)m="0"+m;return this.negative!==0&&(m="-"+m),m}if(c===(c|0)&&c>=2&&c<=36){var u=T[c],l=L[c];m="";var y=this.clone();for(y.negative=0;!y.isZero();){var k=y.modrn(l).toString(c);y=y.idivn(l),y.isZero()?m=k+m:m=x[u-k.length]+k+m}for(this.isZero()&&(m="0"+m);m.length%p!==0;)m="0"+m;return this.negative!==0&&(m="-"+m),m}r(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var c=this.words[0];return this.length===2?c+=this.words[1]*67108864:this.length===3&&this.words[2]===1?c+=4503599627370496+this.words[1]*67108864:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-c:c},i.prototype.toJSON=function(){return this.toString(16,2)},o&&(i.prototype.toBuffer=function(c,p){return this.toArrayLike(o,c,p)}),i.prototype.toArray=function(c,p){return this.toArrayLike(Array,c,p)};var O=function(c,p){return c.allocUnsafe?c.allocUnsafe(p):new c(p)};i.prototype.toArrayLike=function(c,p,m){this._strip();var I=this.byteLength(),E=m||Math.max(1,I);r(I<=E,"byte array longer than desired length"),r(E>0,"Requested array length <= 0");var A=O(c,E),C=p==="le"?"LE":"BE";return this["_toArrayLike"+C](A,I),A},i.prototype._toArrayLikeLE=function(c,p){for(var m=0,I=0,E=0,A=0;E<this.length;E++){var C=this.words[E]<<A|I;c[m++]=C&255,m<c.length&&(c[m++]=C>>8&255),m<c.length&&(c[m++]=C>>16&255),A===6?(m<c.length&&(c[m++]=C>>24&255),I=0,A=0):(I=C>>>24,A+=2)}if(m<c.length)for(c[m++]=I;m<c.length;)c[m++]=0},i.prototype._toArrayLikeBE=function(c,p){for(var m=c.length-1,I=0,E=0,A=0;E<this.length;E++){var C=this.words[E]<<A|I;c[m--]=C&255,m>=0&&(c[m--]=C>>8&255),m>=0&&(c[m--]=C>>16&255),A===6?(m>=0&&(c[m--]=C>>24&255),I=0,A=0):(I=C>>>24,A+=2)}if(m>=0)for(c[m--]=I;m>=0;)c[m--]=0},Math.clz32?i.prototype._countBits=function(c){return 32-Math.clz32(c)}:i.prototype._countBits=function(c){var p=c,m=0;return p>=4096&&(m+=13,p>>>=13),p>=64&&(m+=7,p>>>=7),p>=8&&(m+=4,p>>>=4),p>=2&&(m+=2,p>>>=2),m+p},i.prototype._zeroBits=function(c){if(c===0)return 26;var p=c,m=0;return(p&8191)===0&&(m+=13,p>>>=13),(p&127)===0&&(m+=7,p>>>=7),(p&15)===0&&(m+=4,p>>>=4),(p&3)===0&&(m+=2,p>>>=2),(p&1)===0&&m++,m},i.prototype.bitLength=function(){var c=this.words[this.length-1],p=this._countBits(c);return(this.length-1)*26+p};function N(S){for(var c=new Array(S.bitLength()),p=0;p<c.length;p++){var m=p/26|0,I=p%26;c[p]=S.words[m]>>>I&1}return c}i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var c=0,p=0;p<this.length;p++){var m=this._zeroBits(this.words[p]);if(c+=m,m!==26)break}return c},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(c){return this.negative!==0?this.abs().inotn(c).iaddn(1):this.clone()},i.prototype.fromTwos=function(c){return this.testn(c-1)?this.notn(c).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return this.negative!==0},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(c){for(;this.length<c.length;)this.words[this.length++]=0;for(var p=0;p<c.length;p++)this.words[p]=this.words[p]|c.words[p];return this._strip()},i.prototype.ior=function(c){return r((this.negative|c.negative)===0),this.iuor(c)},i.prototype.or=function(c){return this.length>c.length?this.clone().ior(c):c.clone().ior(this)},i.prototype.uor=function(c){return this.length>c.length?this.clone().iuor(c):c.clone().iuor(this)},i.prototype.iuand=function(c){var p;this.length>c.length?p=c:p=this;for(var m=0;m<p.length;m++)this.words[m]=this.words[m]&c.words[m];return this.length=p.length,this._strip()},i.prototype.iand=function(c){return r((this.negative|c.negative)===0),this.iuand(c)},i.prototype.and=function(c){return this.length>c.length?this.clone().iand(c):c.clone().iand(this)},i.prototype.uand=function(c){return this.length>c.length?this.clone().iuand(c):c.clone().iuand(this)},i.prototype.iuxor=function(c){var p,m;this.length>c.length?(p=this,m=c):(p=c,m=this);for(var I=0;I<m.length;I++)this.words[I]=p.words[I]^m.words[I];if(this!==p)for(;I<p.length;I++)this.words[I]=p.words[I];return this.length=p.length,this._strip()},i.prototype.ixor=function(c){return r((this.negative|c.negative)===0),this.iuxor(c)},i.prototype.xor=function(c){return this.length>c.length?this.clone().ixor(c):c.clone().ixor(this)},i.prototype.uxor=function(c){return this.length>c.length?this.clone().iuxor(c):c.clone().iuxor(this)},i.prototype.inotn=function(c){r(typeof c=="number"&&c>=0);var p=Math.ceil(c/26)|0,m=c%26;this._expand(p),m>0&&p--;for(var I=0;I<p;I++)this.words[I]=~this.words[I]&67108863;return m>0&&(this.words[I]=~this.words[I]&67108863>>26-m),this._strip()},i.prototype.notn=function(c){return this.clone().inotn(c)},i.prototype.setn=function(c,p){r(typeof c=="number"&&c>=0);var m=c/26|0,I=c%26;return this._expand(m+1),p?this.words[m]=this.words[m]|1<<I:this.words[m]=this.words[m]&~(1<<I),this._strip()},i.prototype.iadd=function(c){var p;if(this.negative!==0&&c.negative===0)return this.negative=0,p=this.isub(c),this.negative^=1,this._normSign();if(this.negative===0&&c.negative!==0)return c.negative=0,p=this.isub(c),c.negative=1,p._normSign();var m,I;this.length>c.length?(m=this,I=c):(m=c,I=this);for(var E=0,A=0;A<I.length;A++)p=(m.words[A]|0)+(I.words[A]|0)+E,this.words[A]=p&67108863,E=p>>>26;for(;E!==0&&A<m.length;A++)p=(m.words[A]|0)+E,this.words[A]=p&67108863,E=p>>>26;if(this.length=m.length,E!==0)this.words[this.length]=E,this.length++;else if(m!==this)for(;A<m.length;A++)this.words[A]=m.words[A];return this},i.prototype.add=function(c){var p;return c.negative!==0&&this.negative===0?(c.negative=0,p=this.sub(c),c.negative^=1,p):c.negative===0&&this.negative!==0?(this.negative=0,p=c.sub(this),this.negative=1,p):this.length>c.length?this.clone().iadd(c):c.clone().iadd(this)},i.prototype.isub=function(c){if(c.negative!==0){c.negative=0;var p=this.iadd(c);return c.negative=1,p._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(c),this.negative=1,this._normSign();var m=this.cmp(c);if(m===0)return this.negative=0,this.length=1,this.words[0]=0,this;var I,E;m>0?(I=this,E=c):(I=c,E=this);for(var A=0,C=0;C<E.length;C++)p=(I.words[C]|0)-(E.words[C]|0)+A,A=p>>26,this.words[C]=p&67108863;for(;A!==0&&C<I.length;C++)p=(I.words[C]|0)+A,A=p>>26,this.words[C]=p&67108863;if(A===0&&C<I.length&&I!==this)for(;C<I.length;C++)this.words[C]=I.words[C];return this.length=Math.max(this.length,C),I!==this&&(this.negative=1),this._strip()},i.prototype.sub=function(c){return this.clone().isub(c)};function M(S,c,p){p.negative=c.negative^S.negative;var m=S.length+c.length|0;p.length=m,m=m-1|0;var I=S.words[0]|0,E=c.words[0]|0,A=I*E,C=A&67108863,R=A/67108864|0;p.words[0]=C;for(var u=1;u<m;u++){for(var l=R>>>26,y=R&67108863,k=Math.min(u,c.length-1),P=Math.max(0,u-S.length+1);P<=k;P++){var G=u-P|0;I=S.words[G]|0,E=c.words[P]|0,A=I*E+y,l+=A/67108864|0,y=A&67108863}p.words[u]=y|0,R=l|0}return R!==0?p.words[u]=R|0:p.length--,p._strip()}var H=function(c,p,m){var I=c.words,E=p.words,A=m.words,C=0,R,u,l,y=I[0]|0,k=y&8191,P=y>>>13,G=I[1]|0,re=G&8191,J=G>>>13,Ae=I[2]|0,ge=Ae&8191,me=Ae>>>13,Ue=I[3]|0,Se=Ue&8191,Te=Ue>>>13,Wt=I[4]|0,Be=Wt&8191,He=Wt>>>13,Dn=I[5]|0,Fe=Dn&8191,Le=Dn>>>13,Et=I[6]|0,Ce=Et&8191,De=Et>>>13,vt=I[7]|0,ze=vt&8191,_=vt>>>13,h=I[8]|0,d=h&8191,v=h>>>13,U=I[9]|0,F=U&8191,Y=U>>>13,Re=E[0]|0,_e=Re&8191,pe=Re>>>13,Ke=E[1]|0,fe=Ke&8191,je=Ke>>>13,Ka=E[2]|0,Ze=Ka&8191,Xe=Ka>>>13,$a=E[3]|0,Je=$a&8191,Qe=$a>>>13,Ha=E[4]|0,et=Ha&8191,tt=Ha>>>13,Wa=E[5]|0,nt=Wa&8191,rt=Wa>>>13,qa=E[6]|0,it=qa&8191,st=qa>>>13,Va=E[7]|0,ot=Va&8191,at=Va>>>13,Ga=E[8]|0,ct=Ga&8191,ut=Ga>>>13,Ya=E[9]|0,lt=Ya&8191,ht=Ya>>>13;m.negative=c.negative^p.negative,m.length=19,R=Math.imul(k,_e),u=Math.imul(k,pe),u=u+Math.imul(P,_e)|0,l=Math.imul(P,pe);var Qi=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(Qi>>>26)|0,Qi&=67108863,R=Math.imul(re,_e),u=Math.imul(re,pe),u=u+Math.imul(J,_e)|0,l=Math.imul(J,pe),R=R+Math.imul(k,fe)|0,u=u+Math.imul(k,je)|0,u=u+Math.imul(P,fe)|0,l=l+Math.imul(P,je)|0;var es=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(es>>>26)|0,es&=67108863,R=Math.imul(ge,_e),u=Math.imul(ge,pe),u=u+Math.imul(me,_e)|0,l=Math.imul(me,pe),R=R+Math.imul(re,fe)|0,u=u+Math.imul(re,je)|0,u=u+Math.imul(J,fe)|0,l=l+Math.imul(J,je)|0,R=R+Math.imul(k,Ze)|0,u=u+Math.imul(k,Xe)|0,u=u+Math.imul(P,Ze)|0,l=l+Math.imul(P,Xe)|0;var ts=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(ts>>>26)|0,ts&=67108863,R=Math.imul(Se,_e),u=Math.imul(Se,pe),u=u+Math.imul(Te,_e)|0,l=Math.imul(Te,pe),R=R+Math.imul(ge,fe)|0,u=u+Math.imul(ge,je)|0,u=u+Math.imul(me,fe)|0,l=l+Math.imul(me,je)|0,R=R+Math.imul(re,Ze)|0,u=u+Math.imul(re,Xe)|0,u=u+Math.imul(J,Ze)|0,l=l+Math.imul(J,Xe)|0,R=R+Math.imul(k,Je)|0,u=u+Math.imul(k,Qe)|0,u=u+Math.imul(P,Je)|0,l=l+Math.imul(P,Qe)|0;var ns=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(ns>>>26)|0,ns&=67108863,R=Math.imul(Be,_e),u=Math.imul(Be,pe),u=u+Math.imul(He,_e)|0,l=Math.imul(He,pe),R=R+Math.imul(Se,fe)|0,u=u+Math.imul(Se,je)|0,u=u+Math.imul(Te,fe)|0,l=l+Math.imul(Te,je)|0,R=R+Math.imul(ge,Ze)|0,u=u+Math.imul(ge,Xe)|0,u=u+Math.imul(me,Ze)|0,l=l+Math.imul(me,Xe)|0,R=R+Math.imul(re,Je)|0,u=u+Math.imul(re,Qe)|0,u=u+Math.imul(J,Je)|0,l=l+Math.imul(J,Qe)|0,R=R+Math.imul(k,et)|0,u=u+Math.imul(k,tt)|0,u=u+Math.imul(P,et)|0,l=l+Math.imul(P,tt)|0;var rs=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(rs>>>26)|0,rs&=67108863,R=Math.imul(Fe,_e),u=Math.imul(Fe,pe),u=u+Math.imul(Le,_e)|0,l=Math.imul(Le,pe),R=R+Math.imul(Be,fe)|0,u=u+Math.imul(Be,je)|0,u=u+Math.imul(He,fe)|0,l=l+Math.imul(He,je)|0,R=R+Math.imul(Se,Ze)|0,u=u+Math.imul(Se,Xe)|0,u=u+Math.imul(Te,Ze)|0,l=l+Math.imul(Te,Xe)|0,R=R+Math.imul(ge,Je)|0,u=u+Math.imul(ge,Qe)|0,u=u+Math.imul(me,Je)|0,l=l+Math.imul(me,Qe)|0,R=R+Math.imul(re,et)|0,u=u+Math.imul(re,tt)|0,u=u+Math.imul(J,et)|0,l=l+Math.imul(J,tt)|0,R=R+Math.imul(k,nt)|0,u=u+Math.imul(k,rt)|0,u=u+Math.imul(P,nt)|0,l=l+Math.imul(P,rt)|0;var is=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(is>>>26)|0,is&=67108863,R=Math.imul(Ce,_e),u=Math.imul(Ce,pe),u=u+Math.imul(De,_e)|0,l=Math.imul(De,pe),R=R+Math.imul(Fe,fe)|0,u=u+Math.imul(Fe,je)|0,u=u+Math.imul(Le,fe)|0,l=l+Math.imul(Le,je)|0,R=R+Math.imul(Be,Ze)|0,u=u+Math.imul(Be,Xe)|0,u=u+Math.imul(He,Ze)|0,l=l+Math.imul(He,Xe)|0,R=R+Math.imul(Se,Je)|0,u=u+Math.imul(Se,Qe)|0,u=u+Math.imul(Te,Je)|0,l=l+Math.imul(Te,Qe)|0,R=R+Math.imul(ge,et)|0,u=u+Math.imul(ge,tt)|0,u=u+Math.imul(me,et)|0,l=l+Math.imul(me,tt)|0,R=R+Math.imul(re,nt)|0,u=u+Math.imul(re,rt)|0,u=u+Math.imul(J,nt)|0,l=l+Math.imul(J,rt)|0,R=R+Math.imul(k,it)|0,u=u+Math.imul(k,st)|0,u=u+Math.imul(P,it)|0,l=l+Math.imul(P,st)|0;var ss=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(ss>>>26)|0,ss&=67108863,R=Math.imul(ze,_e),u=Math.imul(ze,pe),u=u+Math.imul(_,_e)|0,l=Math.imul(_,pe),R=R+Math.imul(Ce,fe)|0,u=u+Math.imul(Ce,je)|0,u=u+Math.imul(De,fe)|0,l=l+Math.imul(De,je)|0,R=R+Math.imul(Fe,Ze)|0,u=u+Math.imul(Fe,Xe)|0,u=u+Math.imul(Le,Ze)|0,l=l+Math.imul(Le,Xe)|0,R=R+Math.imul(Be,Je)|0,u=u+Math.imul(Be,Qe)|0,u=u+Math.imul(He,Je)|0,l=l+Math.imul(He,Qe)|0,R=R+Math.imul(Se,et)|0,u=u+Math.imul(Se,tt)|0,u=u+Math.imul(Te,et)|0,l=l+Math.imul(Te,tt)|0,R=R+Math.imul(ge,nt)|0,u=u+Math.imul(ge,rt)|0,u=u+Math.imul(me,nt)|0,l=l+Math.imul(me,rt)|0,R=R+Math.imul(re,it)|0,u=u+Math.imul(re,st)|0,u=u+Math.imul(J,it)|0,l=l+Math.imul(J,st)|0,R=R+Math.imul(k,ot)|0,u=u+Math.imul(k,at)|0,u=u+Math.imul(P,ot)|0,l=l+Math.imul(P,at)|0;var os=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(os>>>26)|0,os&=67108863,R=Math.imul(d,_e),u=Math.imul(d,pe),u=u+Math.imul(v,_e)|0,l=Math.imul(v,pe),R=R+Math.imul(ze,fe)|0,u=u+Math.imul(ze,je)|0,u=u+Math.imul(_,fe)|0,l=l+Math.imul(_,je)|0,R=R+Math.imul(Ce,Ze)|0,u=u+Math.imul(Ce,Xe)|0,u=u+Math.imul(De,Ze)|0,l=l+Math.imul(De,Xe)|0,R=R+Math.imul(Fe,Je)|0,u=u+Math.imul(Fe,Qe)|0,u=u+Math.imul(Le,Je)|0,l=l+Math.imul(Le,Qe)|0,R=R+Math.imul(Be,et)|0,u=u+Math.imul(Be,tt)|0,u=u+Math.imul(He,et)|0,l=l+Math.imul(He,tt)|0,R=R+Math.imul(Se,nt)|0,u=u+Math.imul(Se,rt)|0,u=u+Math.imul(Te,nt)|0,l=l+Math.imul(Te,rt)|0,R=R+Math.imul(ge,it)|0,u=u+Math.imul(ge,st)|0,u=u+Math.imul(me,it)|0,l=l+Math.imul(me,st)|0,R=R+Math.imul(re,ot)|0,u=u+Math.imul(re,at)|0,u=u+Math.imul(J,ot)|0,l=l+Math.imul(J,at)|0,R=R+Math.imul(k,ct)|0,u=u+Math.imul(k,ut)|0,u=u+Math.imul(P,ct)|0,l=l+Math.imul(P,ut)|0;var as=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(as>>>26)|0,as&=67108863,R=Math.imul(F,_e),u=Math.imul(F,pe),u=u+Math.imul(Y,_e)|0,l=Math.imul(Y,pe),R=R+Math.imul(d,fe)|0,u=u+Math.imul(d,je)|0,u=u+Math.imul(v,fe)|0,l=l+Math.imul(v,je)|0,R=R+Math.imul(ze,Ze)|0,u=u+Math.imul(ze,Xe)|0,u=u+Math.imul(_,Ze)|0,l=l+Math.imul(_,Xe)|0,R=R+Math.imul(Ce,Je)|0,u=u+Math.imul(Ce,Qe)|0,u=u+Math.imul(De,Je)|0,l=l+Math.imul(De,Qe)|0,R=R+Math.imul(Fe,et)|0,u=u+Math.imul(Fe,tt)|0,u=u+Math.imul(Le,et)|0,l=l+Math.imul(Le,tt)|0,R=R+Math.imul(Be,nt)|0,u=u+Math.imul(Be,rt)|0,u=u+Math.imul(He,nt)|0,l=l+Math.imul(He,rt)|0,R=R+Math.imul(Se,it)|0,u=u+Math.imul(Se,st)|0,u=u+Math.imul(Te,it)|0,l=l+Math.imul(Te,st)|0,R=R+Math.imul(ge,ot)|0,u=u+Math.imul(ge,at)|0,u=u+Math.imul(me,ot)|0,l=l+Math.imul(me,at)|0,R=R+Math.imul(re,ct)|0,u=u+Math.imul(re,ut)|0,u=u+Math.imul(J,ct)|0,l=l+Math.imul(J,ut)|0,R=R+Math.imul(k,lt)|0,u=u+Math.imul(k,ht)|0,u=u+Math.imul(P,lt)|0,l=l+Math.imul(P,ht)|0;var cs=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(cs>>>26)|0,cs&=67108863,R=Math.imul(F,fe),u=Math.imul(F,je),u=u+Math.imul(Y,fe)|0,l=Math.imul(Y,je),R=R+Math.imul(d,Ze)|0,u=u+Math.imul(d,Xe)|0,u=u+Math.imul(v,Ze)|0,l=l+Math.imul(v,Xe)|0,R=R+Math.imul(ze,Je)|0,u=u+Math.imul(ze,Qe)|0,u=u+Math.imul(_,Je)|0,l=l+Math.imul(_,Qe)|0,R=R+Math.imul(Ce,et)|0,u=u+Math.imul(Ce,tt)|0,u=u+Math.imul(De,et)|0,l=l+Math.imul(De,tt)|0,R=R+Math.imul(Fe,nt)|0,u=u+Math.imul(Fe,rt)|0,u=u+Math.imul(Le,nt)|0,l=l+Math.imul(Le,rt)|0,R=R+Math.imul(Be,it)|0,u=u+Math.imul(Be,st)|0,u=u+Math.imul(He,it)|0,l=l+Math.imul(He,st)|0,R=R+Math.imul(Se,ot)|0,u=u+Math.imul(Se,at)|0,u=u+Math.imul(Te,ot)|0,l=l+Math.imul(Te,at)|0,R=R+Math.imul(ge,ct)|0,u=u+Math.imul(ge,ut)|0,u=u+Math.imul(me,ct)|0,l=l+Math.imul(me,ut)|0,R=R+Math.imul(re,lt)|0,u=u+Math.imul(re,ht)|0,u=u+Math.imul(J,lt)|0,l=l+Math.imul(J,ht)|0;var us=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(us>>>26)|0,us&=67108863,R=Math.imul(F,Ze),u=Math.imul(F,Xe),u=u+Math.imul(Y,Ze)|0,l=Math.imul(Y,Xe),R=R+Math.imul(d,Je)|0,u=u+Math.imul(d,Qe)|0,u=u+Math.imul(v,Je)|0,l=l+Math.imul(v,Qe)|0,R=R+Math.imul(ze,et)|0,u=u+Math.imul(ze,tt)|0,u=u+Math.imul(_,et)|0,l=l+Math.imul(_,tt)|0,R=R+Math.imul(Ce,nt)|0,u=u+Math.imul(Ce,rt)|0,u=u+Math.imul(De,nt)|0,l=l+Math.imul(De,rt)|0,R=R+Math.imul(Fe,it)|0,u=u+Math.imul(Fe,st)|0,u=u+Math.imul(Le,it)|0,l=l+Math.imul(Le,st)|0,R=R+Math.imul(Be,ot)|0,u=u+Math.imul(Be,at)|0,u=u+Math.imul(He,ot)|0,l=l+Math.imul(He,at)|0,R=R+Math.imul(Se,ct)|0,u=u+Math.imul(Se,ut)|0,u=u+Math.imul(Te,ct)|0,l=l+Math.imul(Te,ut)|0,R=R+Math.imul(ge,lt)|0,u=u+Math.imul(ge,ht)|0,u=u+Math.imul(me,lt)|0,l=l+Math.imul(me,ht)|0;var ls=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(ls>>>26)|0,ls&=67108863,R=Math.imul(F,Je),u=Math.imul(F,Qe),u=u+Math.imul(Y,Je)|0,l=Math.imul(Y,Qe),R=R+Math.imul(d,et)|0,u=u+Math.imul(d,tt)|0,u=u+Math.imul(v,et)|0,l=l+Math.imul(v,tt)|0,R=R+Math.imul(ze,nt)|0,u=u+Math.imul(ze,rt)|0,u=u+Math.imul(_,nt)|0,l=l+Math.imul(_,rt)|0,R=R+Math.imul(Ce,it)|0,u=u+Math.imul(Ce,st)|0,u=u+Math.imul(De,it)|0,l=l+Math.imul(De,st)|0,R=R+Math.imul(Fe,ot)|0,u=u+Math.imul(Fe,at)|0,u=u+Math.imul(Le,ot)|0,l=l+Math.imul(Le,at)|0,R=R+Math.imul(Be,ct)|0,u=u+Math.imul(Be,ut)|0,u=u+Math.imul(He,ct)|0,l=l+Math.imul(He,ut)|0,R=R+Math.imul(Se,lt)|0,u=u+Math.imul(Se,ht)|0,u=u+Math.imul(Te,lt)|0,l=l+Math.imul(Te,ht)|0;var hs=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(hs>>>26)|0,hs&=67108863,R=Math.imul(F,et),u=Math.imul(F,tt),u=u+Math.imul(Y,et)|0,l=Math.imul(Y,tt),R=R+Math.imul(d,nt)|0,u=u+Math.imul(d,rt)|0,u=u+Math.imul(v,nt)|0,l=l+Math.imul(v,rt)|0,R=R+Math.imul(ze,it)|0,u=u+Math.imul(ze,st)|0,u=u+Math.imul(_,it)|0,l=l+Math.imul(_,st)|0,R=R+Math.imul(Ce,ot)|0,u=u+Math.imul(Ce,at)|0,u=u+Math.imul(De,ot)|0,l=l+Math.imul(De,at)|0,R=R+Math.imul(Fe,ct)|0,u=u+Math.imul(Fe,ut)|0,u=u+Math.imul(Le,ct)|0,l=l+Math.imul(Le,ut)|0,R=R+Math.imul(Be,lt)|0,u=u+Math.imul(Be,ht)|0,u=u+Math.imul(He,lt)|0,l=l+Math.imul(He,ht)|0;var fs=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(fs>>>26)|0,fs&=67108863,R=Math.imul(F,nt),u=Math.imul(F,rt),u=u+Math.imul(Y,nt)|0,l=Math.imul(Y,rt),R=R+Math.imul(d,it)|0,u=u+Math.imul(d,st)|0,u=u+Math.imul(v,it)|0,l=l+Math.imul(v,st)|0,R=R+Math.imul(ze,ot)|0,u=u+Math.imul(ze,at)|0,u=u+Math.imul(_,ot)|0,l=l+Math.imul(_,at)|0,R=R+Math.imul(Ce,ct)|0,u=u+Math.imul(Ce,ut)|0,u=u+Math.imul(De,ct)|0,l=l+Math.imul(De,ut)|0,R=R+Math.imul(Fe,lt)|0,u=u+Math.imul(Fe,ht)|0,u=u+Math.imul(Le,lt)|0,l=l+Math.imul(Le,ht)|0;var ds=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(ds>>>26)|0,ds&=67108863,R=Math.imul(F,it),u=Math.imul(F,st),u=u+Math.imul(Y,it)|0,l=Math.imul(Y,st),R=R+Math.imul(d,ot)|0,u=u+Math.imul(d,at)|0,u=u+Math.imul(v,ot)|0,l=l+Math.imul(v,at)|0,R=R+Math.imul(ze,ct)|0,u=u+Math.imul(ze,ut)|0,u=u+Math.imul(_,ct)|0,l=l+Math.imul(_,ut)|0,R=R+Math.imul(Ce,lt)|0,u=u+Math.imul(Ce,ht)|0,u=u+Math.imul(De,lt)|0,l=l+Math.imul(De,ht)|0;var ps=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(ps>>>26)|0,ps&=67108863,R=Math.imul(F,ot),u=Math.imul(F,at),u=u+Math.imul(Y,ot)|0,l=Math.imul(Y,at),R=R+Math.imul(d,ct)|0,u=u+Math.imul(d,ut)|0,u=u+Math.imul(v,ct)|0,l=l+Math.imul(v,ut)|0,R=R+Math.imul(ze,lt)|0,u=u+Math.imul(ze,ht)|0,u=u+Math.imul(_,lt)|0,l=l+Math.imul(_,ht)|0;var gs=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(gs>>>26)|0,gs&=67108863,R=Math.imul(F,ct),u=Math.imul(F,ut),u=u+Math.imul(Y,ct)|0,l=Math.imul(Y,ut),R=R+Math.imul(d,lt)|0,u=u+Math.imul(d,ht)|0,u=u+Math.imul(v,lt)|0,l=l+Math.imul(v,ht)|0;var ms=(C+R|0)+((u&8191)<<13)|0;C=(l+(u>>>13)|0)+(ms>>>26)|0,ms&=67108863,R=Math.imul(F,lt),u=Math.imul(F,ht),u=u+Math.imul(Y,lt)|0,l=Math.imul(Y,ht);var _s=(C+R|0)+((u&8191)<<13)|0;return C=(l+(u>>>13)|0)+(_s>>>26)|0,_s&=67108863,A[0]=Qi,A[1]=es,A[2]=ts,A[3]=ns,A[4]=rs,A[5]=is,A[6]=ss,A[7]=os,A[8]=as,A[9]=cs,A[10]=us,A[11]=ls,A[12]=hs,A[13]=fs,A[14]=ds,A[15]=ps,A[16]=gs,A[17]=ms,A[18]=_s,C!==0&&(A[19]=C,m.length++),m};Math.imul||(H=M);function K(S,c,p){p.negative=c.negative^S.negative,p.length=S.length+c.length;for(var m=0,I=0,E=0;E<p.length-1;E++){var A=I;I=0;for(var C=m&67108863,R=Math.min(E,c.length-1),u=Math.max(0,E-S.length+1);u<=R;u++){var l=E-u,y=S.words[l]|0,k=c.words[u]|0,P=y*k,G=P&67108863;A=A+(P/67108864|0)|0,G=G+C|0,C=G&67108863,A=A+(G>>>26)|0,I+=A>>>26,A&=67108863}p.words[E]=C,m=A,A=I}return m!==0?p.words[E]=m:p.length--,p._strip()}function Q(S,c,p){return K(S,c,p)}i.prototype.mulTo=function(c,p){var m,I=this.length+c.length;return this.length===10&&c.length===10?m=H(this,c,p):I<63?m=M(this,c,p):I<1024?m=K(this,c,p):m=Q(this,c,p),m},i.prototype.mul=function(c){var p=new i(null);return p.words=new Array(this.length+c.length),this.mulTo(c,p)},i.prototype.mulf=function(c){var p=new i(null);return p.words=new Array(this.length+c.length),Q(this,c,p)},i.prototype.imul=function(c){return this.clone().mulTo(c,this)},i.prototype.imuln=function(c){var p=c<0;p&&(c=-c),r(typeof c=="number"),r(c<67108864);for(var m=0,I=0;I<this.length;I++){var E=(this.words[I]|0)*c,A=(E&67108863)+(m&67108863);m>>=26,m+=E/67108864|0,m+=A>>>26,this.words[I]=A&67108863}return m!==0&&(this.words[I]=m,this.length++),this.length=c===0?1:this.length,p?this.ineg():this},i.prototype.muln=function(c){return this.clone().imuln(c)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(c){var p=N(c);if(p.length===0)return new i(1);for(var m=this,I=0;I<p.length&&p[I]===0;I++,m=m.sqr());if(++I<p.length)for(var E=m.sqr();I<p.length;I++,E=E.sqr())p[I]!==0&&(m=m.mul(E));return m},i.prototype.iushln=function(c){r(typeof c=="number"&&c>=0);var p=c%26,m=(c-p)/26,I=67108863>>>26-p<<26-p,E;if(p!==0){var A=0;for(E=0;E<this.length;E++){var C=this.words[E]&I,R=(this.words[E]|0)-C<<p;this.words[E]=R|A,A=C>>>26-p}A&&(this.words[E]=A,this.length++)}if(m!==0){for(E=this.length-1;E>=0;E--)this.words[E+m]=this.words[E];for(E=0;E<m;E++)this.words[E]=0;this.length+=m}return this._strip()},i.prototype.ishln=function(c){return r(this.negative===0),this.iushln(c)},i.prototype.iushrn=function(c,p,m){r(typeof c=="number"&&c>=0);var I;p?I=(p-p%26)/26:I=0;var E=c%26,A=Math.min((c-E)/26,this.length),C=67108863^67108863>>>E<<E,R=m;if(I-=A,I=Math.max(0,I),R){for(var u=0;u<A;u++)R.words[u]=this.words[u];R.length=A}if(A!==0)if(this.length>A)for(this.length-=A,u=0;u<this.length;u++)this.words[u]=this.words[u+A];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(l!==0||u>=I);u--){var y=this.words[u]|0;this.words[u]=l<<26-E|y>>>E,l=y&C}return R&&l!==0&&(R.words[R.length++]=l),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.ishrn=function(c,p,m){return r(this.negative===0),this.iushrn(c,p,m)},i.prototype.shln=function(c){return this.clone().ishln(c)},i.prototype.ushln=function(c){return this.clone().iushln(c)},i.prototype.shrn=function(c){return this.clone().ishrn(c)},i.prototype.ushrn=function(c){return this.clone().iushrn(c)},i.prototype.testn=function(c){r(typeof c=="number"&&c>=0);var p=c%26,m=(c-p)/26,I=1<<p;if(this.length<=m)return!1;var E=this.words[m];return!!(E&I)},i.prototype.imaskn=function(c){r(typeof c=="number"&&c>=0);var p=c%26,m=(c-p)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=m)return this;if(p!==0&&m++,this.length=Math.min(m,this.length),p!==0){var I=67108863^67108863>>>p<<p;this.words[this.length-1]&=I}return this._strip()},i.prototype.maskn=function(c){return this.clone().imaskn(c)},i.prototype.iaddn=function(c){return r(typeof c=="number"),r(c<67108864),c<0?this.isubn(-c):this.negative!==0?this.length===1&&(this.words[0]|0)<=c?(this.words[0]=c-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(c),this.negative=1,this):this._iaddn(c)},i.prototype._iaddn=function(c){this.words[0]+=c;for(var p=0;p<this.length&&this.words[p]>=67108864;p++)this.words[p]-=67108864,p===this.length-1?this.words[p+1]=1:this.words[p+1]++;return this.length=Math.max(this.length,p+1),this},i.prototype.isubn=function(c){if(r(typeof c=="number"),r(c<67108864),c<0)return this.iaddn(-c);if(this.negative!==0)return this.negative=0,this.iaddn(c),this.negative=1,this;if(this.words[0]-=c,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var p=0;p<this.length&&this.words[p]<0;p++)this.words[p]+=67108864,this.words[p+1]-=1;return this._strip()},i.prototype.addn=function(c){return this.clone().iaddn(c)},i.prototype.subn=function(c){return this.clone().isubn(c)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(c,p,m){var I=c.length+m,E;this._expand(I);var A,C=0;for(E=0;E<c.length;E++){A=(this.words[E+m]|0)+C;var R=(c.words[E]|0)*p;A-=R&67108863,C=(A>>26)-(R/67108864|0),this.words[E+m]=A&67108863}for(;E<this.length-m;E++)A=(this.words[E+m]|0)+C,C=A>>26,this.words[E+m]=A&67108863;if(C===0)return this._strip();for(r(C===-1),C=0,E=0;E<this.length;E++)A=-(this.words[E]|0)+C,C=A>>26,this.words[E]=A&67108863;return this.negative=1,this._strip()},i.prototype._wordDiv=function(c,p){var m=this.length-c.length,I=this.clone(),E=c,A=E.words[E.length-1]|0,C=this._countBits(A);m=26-C,m!==0&&(E=E.ushln(m),I.iushln(m),A=E.words[E.length-1]|0);var R=I.length-E.length,u;if(p!=="mod"){u=new i(null),u.length=R+1,u.words=new Array(u.length);for(var l=0;l<u.length;l++)u.words[l]=0}var y=I.clone()._ishlnsubmul(E,1,R);y.negative===0&&(I=y,u&&(u.words[R]=1));for(var k=R-1;k>=0;k--){var P=(I.words[E.length+k]|0)*67108864+(I.words[E.length+k-1]|0);for(P=Math.min(P/A|0,67108863),I._ishlnsubmul(E,P,k);I.negative!==0;)P--,I.negative=0,I._ishlnsubmul(E,1,k),I.isZero()||(I.negative^=1);u&&(u.words[k]=P)}return u&&u._strip(),I._strip(),p!=="div"&&m!==0&&I.iushrn(m),{div:u||null,mod:I}},i.prototype.divmod=function(c,p,m){if(r(!c.isZero()),this.isZero())return{div:new i(0),mod:new i(0)};var I,E,A;return this.negative!==0&&c.negative===0?(A=this.neg().divmod(c,p),p!=="mod"&&(I=A.div.neg()),p!=="div"&&(E=A.mod.neg(),m&&E.negative!==0&&E.iadd(c)),{div:I,mod:E}):this.negative===0&&c.negative!==0?(A=this.divmod(c.neg(),p),p!=="mod"&&(I=A.div.neg()),{div:I,mod:A.mod}):(this.negative&c.negative)!==0?(A=this.neg().divmod(c.neg(),p),p!=="div"&&(E=A.mod.neg(),m&&E.negative!==0&&E.isub(c)),{div:A.div,mod:E}):c.length>this.length||this.cmp(c)<0?{div:new i(0),mod:this}:c.length===1?p==="div"?{div:this.divn(c.words[0]),mod:null}:p==="mod"?{div:null,mod:new i(this.modrn(c.words[0]))}:{div:this.divn(c.words[0]),mod:new i(this.modrn(c.words[0]))}:this._wordDiv(c,p)},i.prototype.div=function(c){return this.divmod(c,"div",!1).div},i.prototype.mod=function(c){return this.divmod(c,"mod",!1).mod},i.prototype.umod=function(c){return this.divmod(c,"mod",!0).mod},i.prototype.divRound=function(c){var p=this.divmod(c);if(p.mod.isZero())return p.div;var m=p.div.negative!==0?p.mod.isub(c):p.mod,I=c.ushrn(1),E=c.andln(1),A=m.cmp(I);return A<0||E===1&&A===0?p.div:p.div.negative!==0?p.div.isubn(1):p.div.iaddn(1)},i.prototype.modrn=function(c){var p=c<0;p&&(c=-c),r(c<=67108863);for(var m=(1<<26)%c,I=0,E=this.length-1;E>=0;E--)I=(m*I+(this.words[E]|0))%c;return p?-I:I},i.prototype.modn=function(c){return this.modrn(c)},i.prototype.idivn=function(c){var p=c<0;p&&(c=-c),r(c<=67108863);for(var m=0,I=this.length-1;I>=0;I--){var E=(this.words[I]|0)+m*67108864;this.words[I]=E/c|0,m=E%c}return this._strip(),p?this.ineg():this},i.prototype.divn=function(c){return this.clone().idivn(c)},i.prototype.egcd=function(c){r(c.negative===0),r(!c.isZero());var p=this,m=c.clone();p.negative!==0?p=p.umod(c):p=p.clone();for(var I=new i(1),E=new i(0),A=new i(0),C=new i(1),R=0;p.isEven()&&m.isEven();)p.iushrn(1),m.iushrn(1),++R;for(var u=m.clone(),l=p.clone();!p.isZero();){for(var y=0,k=1;(p.words[0]&k)===0&&y<26;++y,k<<=1);if(y>0)for(p.iushrn(y);y-- >0;)(I.isOdd()||E.isOdd())&&(I.iadd(u),E.isub(l)),I.iushrn(1),E.iushrn(1);for(var P=0,G=1;(m.words[0]&G)===0&&P<26;++P,G<<=1);if(P>0)for(m.iushrn(P);P-- >0;)(A.isOdd()||C.isOdd())&&(A.iadd(u),C.isub(l)),A.iushrn(1),C.iushrn(1);p.cmp(m)>=0?(p.isub(m),I.isub(A),E.isub(C)):(m.isub(p),A.isub(I),C.isub(E))}return{a:A,b:C,gcd:m.iushln(R)}},i.prototype._invmp=function(c){r(c.negative===0),r(!c.isZero());var p=this,m=c.clone();p.negative!==0?p=p.umod(c):p=p.clone();for(var I=new i(1),E=new i(0),A=m.clone();p.cmpn(1)>0&&m.cmpn(1)>0;){for(var C=0,R=1;(p.words[0]&R)===0&&C<26;++C,R<<=1);if(C>0)for(p.iushrn(C);C-- >0;)I.isOdd()&&I.iadd(A),I.iushrn(1);for(var u=0,l=1;(m.words[0]&l)===0&&u<26;++u,l<<=1);if(u>0)for(m.iushrn(u);u-- >0;)E.isOdd()&&E.iadd(A),E.iushrn(1);p.cmp(m)>=0?(p.isub(m),I.isub(E)):(m.isub(p),E.isub(I))}var y;return p.cmpn(1)===0?y=I:y=E,y.cmpn(0)<0&&y.iadd(c),y},i.prototype.gcd=function(c){if(this.isZero())return c.abs();if(c.isZero())return this.abs();var p=this.clone(),m=c.clone();p.negative=0,m.negative=0;for(var I=0;p.isEven()&&m.isEven();I++)p.iushrn(1),m.iushrn(1);do{for(;p.isEven();)p.iushrn(1);for(;m.isEven();)m.iushrn(1);var E=p.cmp(m);if(E<0){var A=p;p=m,m=A}else if(E===0||m.cmpn(1)===0)break;p.isub(m)}while(!0);return m.iushln(I)},i.prototype.invm=function(c){return this.egcd(c).a.umod(c)},i.prototype.isEven=function(){return(this.words[0]&1)===0},i.prototype.isOdd=function(){return(this.words[0]&1)===1},i.prototype.andln=function(c){return this.words[0]&c},i.prototype.bincn=function(c){r(typeof c=="number");var p=c%26,m=(c-p)/26,I=1<<p;if(this.length<=m)return this._expand(m+1),this.words[m]|=I,this;for(var E=I,A=m;E!==0&&A<this.length;A++){var C=this.words[A]|0;C+=E,E=C>>>26,C&=67108863,this.words[A]=C}return E!==0&&(this.words[A]=E,this.length++),this},i.prototype.isZero=function(){return this.length===1&&this.words[0]===0},i.prototype.cmpn=function(c){var p=c<0;if(this.negative!==0&&!p)return-1;if(this.negative===0&&p)return 1;this._strip();var m;if(this.length>1)m=1;else{p&&(c=-c),r(c<=67108863,"Number is too big");var I=this.words[0]|0;m=I===c?0:I<c?-1:1}return this.negative!==0?-m|0:m},i.prototype.cmp=function(c){if(this.negative!==0&&c.negative===0)return-1;if(this.negative===0&&c.negative!==0)return 1;var p=this.ucmp(c);return this.negative!==0?-p|0:p},i.prototype.ucmp=function(c){if(this.length>c.length)return 1;if(this.length<c.length)return-1;for(var p=0,m=this.length-1;m>=0;m--){var I=this.words[m]|0,E=c.words[m]|0;if(I!==E){I<E?p=-1:I>E&&(p=1);break}}return p},i.prototype.gtn=function(c){return this.cmpn(c)===1},i.prototype.gt=function(c){return this.cmp(c)===1},i.prototype.gten=function(c){return this.cmpn(c)>=0},i.prototype.gte=function(c){return this.cmp(c)>=0},i.prototype.ltn=function(c){return this.cmpn(c)===-1},i.prototype.lt=function(c){return this.cmp(c)===-1},i.prototype.lten=function(c){return this.cmpn(c)<=0},i.prototype.lte=function(c){return this.cmp(c)<=0},i.prototype.eqn=function(c){return this.cmpn(c)===0},i.prototype.eq=function(c){return this.cmp(c)===0},i.red=function(c){return new V(c)},i.prototype.toRed=function(c){return r(!this.red,"Already a number in reduction context"),r(this.negative===0,"red works only with positives"),c.convertTo(this)._forceRed(c)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(c){return this.red=c,this},i.prototype.forceRed=function(c){return r(!this.red,"Already a number in reduction context"),this._forceRed(c)},i.prototype.redAdd=function(c){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,c)},i.prototype.redIAdd=function(c){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,c)},i.prototype.redSub=function(c){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,c)},i.prototype.redISub=function(c){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,c)},i.prototype.redShl=function(c){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,c)},i.prototype.redMul=function(c){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,c),this.red.mul(this,c)},i.prototype.redIMul=function(c){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,c),this.red.imul(this,c)},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(c){return r(this.red&&!c.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,c)};var q={k256:null,p224:null,p192:null,p25519:null};function D(S,c){this.name=S,this.p=new i(c,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}D.prototype._tmp=function(){var c=new i(null);return c.words=new Array(Math.ceil(this.n/13)),c},D.prototype.ireduce=function(c){var p=c,m;do this.split(p,this.tmp),p=this.imulK(p),p=p.iadd(this.tmp),m=p.bitLength();while(m>this.n);var I=m<this.n?-1:p.ucmp(this.p);return I===0?(p.words[0]=0,p.length=1):I>0?p.isub(this.p):p.strip!==void 0?p.strip():p._strip(),p},D.prototype.split=function(c,p){c.iushrn(this.n,0,p)},D.prototype.imulK=function(c){return c.imul(this.k)};function Z(){D.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}s(Z,D),Z.prototype.split=function(c,p){for(var m=4194303,I=Math.min(c.length,9),E=0;E<I;E++)p.words[E]=c.words[E];if(p.length=I,c.length<=9){c.words[0]=0,c.length=1;return}var A=c.words[9];for(p.words[p.length++]=A&m,E=10;E<c.length;E++){var C=c.words[E]|0;c.words[E-10]=(C&m)<<4|A>>>22,A=C}A>>>=22,c.words[E-10]=A,A===0&&c.length>10?c.length-=10:c.length-=9},Z.prototype.imulK=function(c){c.words[c.length]=0,c.words[c.length+1]=0,c.length+=2;for(var p=0,m=0;m<c.length;m++){var I=c.words[m]|0;p+=I*977,c.words[m]=p&67108863,p=I*64+(p/67108864|0)}return c.words[c.length-1]===0&&(c.length--,c.words[c.length-1]===0&&c.length--),c};function j(){D.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}s(j,D);function X(){D.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}s(X,D);function z(){D.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}s(z,D),z.prototype.imulK=function(c){for(var p=0,m=0;m<c.length;m++){var I=(c.words[m]|0)*19+p,E=I&67108863;I>>>=26,c.words[m]=E,p=I}return p!==0&&(c.words[c.length++]=p),c},i._prime=function(c){if(q[c])return q[c];var p;if(c==="k256")p=new Z;else if(c==="p224")p=new j;else if(c==="p192")p=new X;else if(c==="p25519")p=new z;else throw new Error("Unknown prime "+c);return q[c]=p,p};function V(S){if(typeof S=="string"){var c=i._prime(S);this.m=c.p,this.prime=c}else r(S.gtn(1),"modulus must be greater than 1"),this.m=S,this.prime=null}V.prototype._verify1=function(c){r(c.negative===0,"red works only with positives"),r(c.red,"red works only with red numbers")},V.prototype._verify2=function(c,p){r((c.negative|p.negative)===0,"red works only with positives"),r(c.red&&c.red===p.red,"red works only with red numbers")},V.prototype.imod=function(c){return this.prime?this.prime.ireduce(c)._forceRed(this):(w(c,c.umod(this.m)._forceRed(this)),c)},V.prototype.neg=function(c){return c.isZero()?c.clone():this.m.sub(c)._forceRed(this)},V.prototype.add=function(c,p){this._verify2(c,p);var m=c.add(p);return m.cmp(this.m)>=0&&m.isub(this.m),m._forceRed(this)},V.prototype.iadd=function(c,p){this._verify2(c,p);var m=c.iadd(p);return m.cmp(this.m)>=0&&m.isub(this.m),m},V.prototype.sub=function(c,p){this._verify2(c,p);var m=c.sub(p);return m.cmpn(0)<0&&m.iadd(this.m),m._forceRed(this)},V.prototype.isub=function(c,p){this._verify2(c,p);var m=c.isub(p);return m.cmpn(0)<0&&m.iadd(this.m),m},V.prototype.shl=function(c,p){return this._verify1(c),this.imod(c.ushln(p))},V.prototype.imul=function(c,p){return this._verify2(c,p),this.imod(c.imul(p))},V.prototype.mul=function(c,p){return this._verify2(c,p),this.imod(c.mul(p))},V.prototype.isqr=function(c){return this.imul(c,c.clone())},V.prototype.sqr=function(c){return this.mul(c,c)},V.prototype.sqrt=function(c){if(c.isZero())return c.clone();var p=this.m.andln(3);if(r(p%2===1),p===3){var m=this.m.add(new i(1)).iushrn(2);return this.pow(c,m)}for(var I=this.m.subn(1),E=0;!I.isZero()&&I.andln(1)===0;)E++,I.iushrn(1);r(!I.isZero());var A=new i(1).toRed(this),C=A.redNeg(),R=this.m.subn(1).iushrn(1),u=this.m.bitLength();for(u=new i(2*u*u).toRed(this);this.pow(u,R).cmp(C)!==0;)u.redIAdd(C);for(var l=this.pow(u,I),y=this.pow(c,I.addn(1).iushrn(1)),k=this.pow(c,I),P=E;k.cmp(A)!==0;){for(var G=k,re=0;G.cmp(A)!==0;re++)G=G.redSqr();r(re<P);var J=this.pow(l,new i(1).iushln(P-re-1));y=y.redMul(J),l=J.redSqr(),k=k.redMul(l),P=re}return y},V.prototype.invm=function(c){var p=c._invmp(this.m);return p.negative!==0?(p.negative=0,this.imod(p).redNeg()):this.imod(p)},V.prototype.pow=function(c,p){if(p.isZero())return new i(1).toRed(this);if(p.cmpn(1)===0)return c.clone();var m=4,I=new Array(1<<m);I[0]=new i(1).toRed(this),I[1]=c;for(var E=2;E<I.length;E++)I[E]=this.mul(I[E-1],c);var A=I[0],C=0,R=0,u=p.bitLength()%26;for(u===0&&(u=26),E=p.length-1;E>=0;E--){for(var l=p.words[E],y=u-1;y>=0;y--){var k=l>>y&1;if(A!==I[0]&&(A=this.sqr(A)),k===0&&C===0){R=0;continue}C<<=1,C|=k,R++,!(R!==m&&(E!==0||y!==0))&&(A=this.mul(A,I[C]),R=0,C=0)}u=26}return A},V.prototype.convertTo=function(c){var p=c.umod(this.m);return p===c?p.clone():p},V.prototype.convertFrom=function(c){var p=c.clone();return p.red=null,p},i.mont=function(c){return new ee(c)};function ee(S){V.call(this,S),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)}s(ee,V),ee.prototype.convertTo=function(c){return this.imod(c.ushln(this.shift))},ee.prototype.convertFrom=function(c){var p=this.imod(c.mul(this.rinv));return p.red=null,p},ee.prototype.imul=function(c,p){if(c.isZero()||p.isZero())return c.words[0]=0,c.length=1,c;var m=c.imul(p),I=m.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),E=m.isub(I).iushrn(this.shift),A=E;return E.cmp(this.m)>=0?A=E.isub(this.m):E.cmpn(0)<0&&(A=E.iadd(this.m)),A._forceRed(this)},ee.prototype.mul=function(c,p){if(c.isZero()||p.isZero())return new i(0)._forceRed(this);var m=c.mul(p),I=m.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),E=m.isub(I).iushrn(this.shift),A=E;return E.cmp(this.m)>=0?A=E.isub(this.m):E.cmpn(0)<0&&(A=E.iadd(this.m)),A._forceRed(this)},ee.prototype.invm=function(c){var p=this.imod(c._invmp(this.m).mul(this.r2));return p._forceRed(this)}})(n,eu)}(cr)),cr.exports}var tu=Qs();const eo=Fn(tu);var ur={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var to;function nu(){return to||(to=1,function(n,e){var t=zr(),r=t.Buffer;function s(o,a){for(var f in o)a[f]=o[f]}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?n.exports=t:(s(t,e),e.Buffer=i);function i(o,a,f){return r(o,a,f)}i.prototype=Object.create(r.prototype),s(r,i),i.from=function(o,a,f){if(typeof o=="number")throw new TypeError("Argument must not be a number");return r(o,a,f)},i.alloc=function(o,a,f){if(typeof o!="number")throw new TypeError("Argument must be a number");var g=r(o);return a!==void 0?typeof f=="string"?g.fill(a,f):g.fill(a):g.fill(0),g},i.allocUnsafe=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return r(o)},i.allocUnsafeSlow=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return t.SlowBuffer(o)}}(ur,ur.exports)),ur.exports}var ei,no;function ru(){if(no)return ei;no=1;var n=nu().Buffer;function e(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),s=0;s<r.length;s++)r[s]=255;for(var i=0;i<t.length;i++){var o=t.charAt(i),a=o.charCodeAt(0);if(r[a]!==255)throw new TypeError(o+" is ambiguous");r[a]=i}var f=t.length,g=t.charAt(0),w=Math.log(f)/Math.log(256),b=Math.log(256)/Math.log(f);function x(O){if((Array.isArray(O)||O instanceof Uint8Array)&&(O=n.from(O)),!n.isBuffer(O))throw new TypeError("Expected Buffer");if(O.length===0)return"";for(var N=0,M=0,H=0,K=O.length;H!==K&&O[H]===0;)H++,N++;for(var Q=(K-H)*b+1>>>0,q=new Uint8Array(Q);H!==K;){for(var D=O[H],Z=0,j=Q-1;(D!==0||Z<M)&&j!==-1;j--,Z++)D+=256*q[j]>>>0,q[j]=D%f>>>0,D=D/f>>>0;if(D!==0)throw new Error("Non-zero carry");M=Z,H++}for(var X=Q-M;X!==Q&&q[X]===0;)X++;for(var z=g.repeat(N);X<Q;++X)z+=t.charAt(q[X]);return z}function T(O){if(typeof O!="string")throw new TypeError("Expected String");if(O.length===0)return n.alloc(0);for(var N=0,M=0,H=0;O[N]===g;)M++,N++;for(var K=(O.length-N)*w+1>>>0,Q=new Uint8Array(K);N<O.length;){var q=O.charCodeAt(N);if(q>255)return;var D=r[q];if(D===255)return;for(var Z=0,j=K-1;(D!==0||Z<H)&&j!==-1;j--,Z++)D+=f*Q[j]>>>0,Q[j]=D%256>>>0,D=D/256>>>0;if(D!==0)throw new Error("Non-zero carry");H=Z,N++}for(var X=K-H;X!==K&&Q[X]===0;)X++;var z=n.allocUnsafe(M+(K-X));z.fill(0,0,M);for(var V=M;X!==K;)z[V++]=Q[X++];return z}function L(O){var N=T(O);if(N)return N;throw new Error("Non-base"+f+" character")}return{encode:x,decodeUnsafe:T,decode:L}}return ei=e,ei}var ti,ro;function io(){if(ro)return ti;ro=1;var n=ru(),e="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";return ti=n(e),ti}var iu=io();const pt=Fn(iu),su=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]),Qt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),en=new Uint32Array(64);class ou extends xs{constructor(){super(64,32,8,!1),this.A=Qt[0]|0,this.B=Qt[1]|0,this.C=Qt[2]|0,this.D=Qt[3]|0,this.E=Qt[4]|0,this.F=Qt[5]|0,this.G=Qt[6]|0,this.H=Qt[7]|0}get(){const{A:e,B:t,C:r,D:s,E:i,F:o,G:a,H:f}=this;return[e,t,r,s,i,o,a,f]}set(e,t,r,s,i,o,a,f){this.A=e|0,this.B=t|0,this.C=r|0,this.D=s|0,this.E=i|0,this.F=o|0,this.G=a|0,this.H=f|0}process(e,t){for(let b=0;b<16;b++,t+=4)en[b]=e.getUint32(t,!1);for(let b=16;b<64;b++){const x=en[b-15],T=en[b-2],L=Ct(x,7)^Ct(x,18)^x>>>3,O=Ct(T,17)^Ct(T,19)^T>>>10;en[b]=O+en[b-7]+L+en[b-16]|0}let{A:r,B:s,C:i,D:o,E:a,F:f,G:g,H:w}=this;for(let b=0;b<64;b++){const x=Ct(a,6)^Ct(a,11)^Ct(a,25),T=w+x+ic(a,f,g)+su[b]+en[b]|0,O=(Ct(r,2)^Ct(r,13)^Ct(r,22))+sc(r,s,i)|0;w=g,g=f,f=a,a=o+T|0,o=i,i=s,s=r,r=T+O|0}r=r+this.A|0,s=s+this.B|0,i=i+this.C|0,o=o+this.D|0,a=a+this.E|0,f=f+this.F|0,g=g+this.G|0,w=w+this.H|0,this.set(r,s,i,o,a,f,g,w)}roundClean(){en.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const ni=Wr(()=>new ou);var Ne={};function Vt(n,e,t){return e<=n&&n<=t}function lr(n){if(n===void 0)return{};if(n===Object(n))return n;throw TypeError("Could not convert argument to dictionary")}function au(n){for(var e=String(n),t=e.length,r=0,s=[];r<t;){var i=e.charCodeAt(r);if(i<55296||i>57343)s.push(i);else if(56320<=i&&i<=57343)s.push(65533);else if(55296<=i&&i<=56319)if(r===t-1)s.push(65533);else{var o=n.charCodeAt(r+1);if(56320<=o&&o<=57343){var a=i&1023,f=o&1023;s.push(65536+(a<<10)+f),r+=1}else s.push(65533)}r+=1}return s}function cu(n){for(var e="",t=0;t<n.length;++t){var r=n[t];r<=65535?e+=String.fromCharCode(r):(r-=65536,e+=String.fromCharCode((r>>10)+55296,(r&1023)+56320))}return e}var hr=-1;function ri(n){this.tokens=[].slice.call(n)}ri.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():hr},prepend:function(n){if(Array.isArray(n))for(var e=n;e.length;)this.tokens.unshift(e.pop());else this.tokens.unshift(n)},push:function(n){if(Array.isArray(n))for(var e=n;e.length;)this.tokens.push(e.shift());else this.tokens.push(n)}};var vn=-1;function ii(n,e){if(n)throw TypeError("Decoder error");return e||65533}var fr="utf-8";function dr(n,e){if(!(this instanceof dr))return new dr(n,e);if(n=n!==void 0?String(n).toLowerCase():fr,n!==fr)throw new Error("Encoding not supported. Only utf-8 is supported");e=lr(e),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=!!e.fatal,this._ignoreBOM=!!e.ignoreBOM,Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}dr.prototype={decode:function(e,t){var r;typeof e=="object"&&e instanceof ArrayBuffer?r=new Uint8Array(e):typeof e=="object"&&"buffer"in e&&e.buffer instanceof ArrayBuffer?r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):r=new Uint8Array(0),t=lr(t),this._streaming||(this._decoder=new uu({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!t.stream;for(var s=new ri(r),i=[],o;!s.endOfStream()&&(o=this._decoder.handler(s,s.read()),o!==vn);)o!==null&&(Array.isArray(o)?i.push.apply(i,o):i.push(o));if(!this._streaming){do{if(o=this._decoder.handler(s,s.read()),o===vn)break;o!==null&&(Array.isArray(o)?i.push.apply(i,o):i.push(o))}while(!s.endOfStream());this._decoder=null}return i.length&&["utf-8"].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(i[0]===65279?(this._BOMseen=!0,i.shift()):this._BOMseen=!0),cu(i)}};function pr(n,e){if(!(this instanceof pr))return new pr(n,e);if(n=n!==void 0?String(n).toLowerCase():fr,n!==fr)throw new Error("Encoding not supported. Only utf-8 is supported");e=lr(e),this._streaming=!1,this._encoder=null,this._options={fatal:!!e.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}pr.prototype={encode:function(e,t){e=e?String(e):"",t=lr(t),this._streaming||(this._encoder=new lu(this._options)),this._streaming=!!t.stream;for(var r=[],s=new ri(au(e)),i;!s.endOfStream()&&(i=this._encoder.handler(s,s.read()),i!==vn);)Array.isArray(i)?r.push.apply(r,i):r.push(i);if(!this._streaming){for(;i=this._encoder.handler(s,s.read()),i!==vn;)Array.isArray(i)?r.push.apply(r,i):r.push(i);this._encoder=null}return new Uint8Array(r)}};function uu(n){var e=n.fatal,t=0,r=0,s=0,i=128,o=191;this.handler=function(a,f){if(f===hr&&s!==0)return s=0,ii(e);if(f===hr)return vn;if(s===0){if(Vt(f,0,127))return f;if(Vt(f,194,223))s=1,t=f-192;else if(Vt(f,224,239))f===224&&(i=160),f===237&&(o=159),s=2,t=f-224;else if(Vt(f,240,244))f===240&&(i=144),f===244&&(o=143),s=3,t=f-240;else return ii(e);return t=t<<6*s,null}if(!Vt(f,i,o))return t=s=r=0,i=128,o=191,a.prepend(f),ii(e);if(i=128,o=191,r+=1,t+=f-128<<6*(s-r),r!==s)return null;var g=t;return t=s=r=0,g}}function lu(n){n.fatal,this.handler=function(e,t){if(t===hr)return vn;if(Vt(t,0,127))return t;var r,s;Vt(t,128,2047)?(r=1,s=192):Vt(t,2048,65535)?(r=2,s=224):Vt(t,65536,1114111)&&(r=3,s=240);for(var i=[(t>>6*r)+s];r>0;){var o=t>>6*(r-1);i.push(128|o&63),r-=1}return i}}const hu=Dr(Object.freeze(Object.defineProperty({__proto__:null,TextDecoder:dr,TextEncoder:pr},Symbol.toStringTag,{value:"Module"})));var so;function fu(){if(so)return Ne;so=1;var n=Ne&&Ne.__createBinding||(Object.create?function(X,z,V,ee){ee===void 0&&(ee=V),Object.defineProperty(X,ee,{enumerable:!0,get:function(){return z[V]}})}:function(X,z,V,ee){ee===void 0&&(ee=V),X[ee]=z[V]}),e=Ne&&Ne.__setModuleDefault||(Object.create?function(X,z){Object.defineProperty(X,"default",{enumerable:!0,value:z})}:function(X,z){X.default=z}),t=Ne&&Ne.__decorate||function(X,z,V,ee){var S=arguments.length,c=S<3?z:ee===null?ee=Object.getOwnPropertyDescriptor(z,V):ee,p;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")c=Reflect.decorate(X,z,V,ee);else for(var m=X.length-1;m>=0;m--)(p=X[m])&&(c=(S<3?p(c):S>3?p(z,V,c):p(z,V))||c);return S>3&&c&&Object.defineProperty(z,V,c),c},r=Ne&&Ne.__importStar||function(X){if(X&&X.__esModule)return X;var z={};if(X!=null)for(var V in X)V!=="default"&&Object.hasOwnProperty.call(X,V)&&n(z,X,V);return e(z,X),z},s=Ne&&Ne.__importDefault||function(X){return X&&X.__esModule?X:{default:X}};Object.defineProperty(Ne,"__esModule",{value:!0}),Ne.deserializeUnchecked=Ne.deserialize=Ne.serialize=Ne.BinaryReader=Ne.BinaryWriter=Ne.BorshError=Ne.baseDecode=Ne.baseEncode=void 0;const i=s(Qs()),o=s(io()),a=r(hu),f=typeof TextDecoder!="function"?a.TextDecoder:TextDecoder,g=new f("utf-8",{fatal:!0});function w(X){return typeof X=="string"&&(X=Buffer.from(X,"utf8")),o.default.encode(Buffer.from(X))}Ne.baseEncode=w;function b(X){return Buffer.from(o.default.decode(X))}Ne.baseDecode=b;const x=1024;class T extends Error{constructor(z){super(z),this.fieldPath=[],this.originalMessage=z}addToFieldPath(z){this.fieldPath.splice(0,0,z),this.message=this.originalMessage+": "+this.fieldPath.join(".")}}Ne.BorshError=T;class L{constructor(){this.buf=Buffer.alloc(x),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(x)]))}writeU8(z){this.maybeResize(),this.buf.writeUInt8(z,this.length),this.length+=1}writeU16(z){this.maybeResize(),this.buf.writeUInt16LE(z,this.length),this.length+=2}writeU32(z){this.maybeResize(),this.buf.writeUInt32LE(z,this.length),this.length+=4}writeU64(z){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(z).toArray("le",8)))}writeU128(z){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(z).toArray("le",16)))}writeU256(z){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(z).toArray("le",32)))}writeU512(z){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(z).toArray("le",64)))}writeBuffer(z){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),z,Buffer.alloc(x)]),this.length+=z.length}writeString(z){this.maybeResize();const V=Buffer.from(z,"utf8");this.writeU32(V.length),this.writeBuffer(V)}writeFixedArray(z){this.writeBuffer(Buffer.from(z))}writeArray(z,V){this.maybeResize(),this.writeU32(z.length);for(const ee of z)this.maybeResize(),V(ee)}toArray(){return this.buf.subarray(0,this.length)}}Ne.BinaryWriter=L;function O(X,z,V){const ee=V.value;V.value=function(...S){try{return ee.apply(this,S)}catch(c){if(c instanceof RangeError){const p=c.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(p)>=0)throw new T("Reached the end of buffer when deserializing")}throw c}}}class N{constructor(z){this.buf=z,this.offset=0}readU8(){const z=this.buf.readUInt8(this.offset);return this.offset+=1,z}readU16(){const z=this.buf.readUInt16LE(this.offset);return this.offset+=2,z}readU32(){const z=this.buf.readUInt32LE(this.offset);return this.offset+=4,z}readU64(){const z=this.readBuffer(8);return new i.default(z,"le")}readU128(){const z=this.readBuffer(16);return new i.default(z,"le")}readU256(){const z=this.readBuffer(32);return new i.default(z,"le")}readU512(){const z=this.readBuffer(64);return new i.default(z,"le")}readBuffer(z){if(this.offset+z>this.buf.length)throw new T(`Expected buffer length ${z} isn't within bounds`);const V=this.buf.slice(this.offset,this.offset+z);return this.offset+=z,V}readString(){const z=this.readU32(),V=this.readBuffer(z);try{return g.decode(V)}catch(ee){throw new T(`Error decoding UTF-8 string: ${ee}`)}}readFixedArray(z){return new Uint8Array(this.readBuffer(z))}readArray(z){const V=this.readU32(),ee=Array();for(let S=0;S<V;++S)ee.push(z());return ee}}t([O],N.prototype,"readU8",null),t([O],N.prototype,"readU16",null),t([O],N.prototype,"readU32",null),t([O],N.prototype,"readU64",null),t([O],N.prototype,"readU128",null),t([O],N.prototype,"readU256",null),t([O],N.prototype,"readU512",null),t([O],N.prototype,"readString",null),t([O],N.prototype,"readFixedArray",null),t([O],N.prototype,"readArray",null),Ne.BinaryReader=N;function M(X){return X.charAt(0).toUpperCase()+X.slice(1)}function H(X,z,V,ee,S){try{if(typeof ee=="string")S[`write${M(ee)}`](V);else if(ee instanceof Array)if(typeof ee[0]=="number"){if(V.length!==ee[0])throw new T(`Expecting byte array of length ${ee[0]}, but got ${V.length} bytes`);S.writeFixedArray(V)}else if(ee.length===2&&typeof ee[1]=="number"){if(V.length!==ee[1])throw new T(`Expecting byte array of length ${ee[1]}, but got ${V.length} bytes`);for(let c=0;c<ee[1];c++)H(X,null,V[c],ee[0],S)}else S.writeArray(V,c=>{H(X,z,c,ee[0],S)});else if(ee.kind!==void 0)switch(ee.kind){case"option":{V==null?S.writeU8(0):(S.writeU8(1),H(X,z,V,ee.type,S));break}case"map":{S.writeU32(V.size),V.forEach((c,p)=>{H(X,z,p,ee.key,S),H(X,z,c,ee.value,S)});break}default:throw new T(`FieldType ${ee} unrecognized`)}else K(X,V,S)}catch(c){throw c instanceof T&&c.addToFieldPath(z),c}}function K(X,z,V){if(typeof z.borshSerialize=="function"){z.borshSerialize(V);return}const ee=X.get(z.constructor);if(!ee)throw new T(`Class ${z.constructor.name} is missing in schema`);if(ee.kind==="struct")ee.fields.map(([S,c])=>{H(X,S,z[S],c,V)});else if(ee.kind==="enum"){const S=z[ee.field];for(let c=0;c<ee.values.length;++c){const[p,m]=ee.values[c];if(p===S){V.writeU8(c),H(X,p,z[p],m,V);break}}}else throw new T(`Unexpected schema kind: ${ee.kind} for ${z.constructor.name}`)}function Q(X,z,V=L){const ee=new V;return K(X,z,ee),ee.toArray()}Ne.serialize=Q;function q(X,z,V,ee){try{if(typeof V=="string")return ee[`read${M(V)}`]();if(V instanceof Array){if(typeof V[0]=="number")return ee.readFixedArray(V[0]);if(typeof V[1]=="number"){const S=[];for(let c=0;c<V[1];c++)S.push(q(X,null,V[0],ee));return S}else return ee.readArray(()=>q(X,z,V[0],ee))}if(V.kind==="option")return ee.readU8()?q(X,z,V.type,ee):void 0;if(V.kind==="map"){let S=new Map;const c=ee.readU32();for(let p=0;p<c;p++){const m=q(X,z,V.key,ee),I=q(X,z,V.value,ee);S.set(m,I)}return S}return D(X,V,ee)}catch(S){throw S instanceof T&&S.addToFieldPath(z),S}}function D(X,z,V){if(typeof z.borshDeserialize=="function")return z.borshDeserialize(V);const ee=X.get(z);if(!ee)throw new T(`Class ${z.name} is missing in schema`);if(ee.kind==="struct"){const S={};for(const[c,p]of X.get(z).fields)S[c]=q(X,c,p,V);return new z(S)}if(ee.kind==="enum"){const S=V.readU8();if(S>=ee.values.length)throw new T(`Enum index: ${S} is out of range`);const[c,p]=ee.values[S],m=q(X,c,p,V);return new z({[c]:m})}throw new T(`Unexpected schema kind: ${ee.kind} for ${z.constructor.name}`)}function Z(X,z,V,ee=N){const S=new ee(V),c=D(X,z,S);if(S.offset<V.length)throw new T(`Unexpected ${V.length-S.offset} bytes after deserialized data`);return c}Ne.deserialize=Z;function j(X,z,V,ee=N){const S=new ee(V);return D(X,z,S)}return Ne.deserializeUnchecked=j,Ne}var si=fu(),W={},oo;function du(){if(oo)return W;oo=1,Object.defineProperty(W,"__esModule",{value:!0}),W.s16=W.s8=W.nu64be=W.u48be=W.u40be=W.u32be=W.u24be=W.u16be=W.nu64=W.u48=W.u40=W.u32=W.u24=W.u16=W.u8=W.offset=W.greedy=W.Constant=W.UTF8=W.CString=W.Blob=W.Boolean=W.BitField=W.BitStructure=W.VariantLayout=W.Union=W.UnionLayoutDiscriminator=W.UnionDiscriminator=W.Structure=W.Sequence=W.DoubleBE=W.Double=W.FloatBE=W.Float=W.NearInt64BE=W.NearInt64=W.NearUInt64BE=W.NearUInt64=W.IntBE=W.Int=W.UIntBE=W.UInt=W.OffsetLayout=W.GreedyCount=W.ExternalLayout=W.bindConstructorLayout=W.nameWithProperty=W.Layout=W.uint8ArrayToBuffer=W.checkUint8Array=void 0,W.constant=W.utf8=W.cstr=W.blob=W.unionLayoutDiscriminator=W.union=W.seq=W.bits=W.struct=W.f64be=W.f64=W.f32be=W.f32=W.ns64be=W.s48be=W.s40be=W.s32be=W.s24be=W.s16be=W.ns64=W.s48=W.s40=W.s32=W.s24=void 0;const n=zr();function e(u){if(!(u instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}W.checkUint8Array=e;function t(u){return e(u),n.Buffer.from(u.buffer,u.byteOffset,u.length)}W.uint8ArrayToBuffer=t;let r=class{constructor(l,y){if(!Number.isInteger(l))throw new TypeError("span must be an integer");this.span=l,this.property=y}makeDestinationObject(){return{}}getSpan(l,y){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(l){const y=Object.create(this.constructor.prototype);return Object.assign(y,this),y.property=l,y}fromArray(l){}};W.Layout=r;function s(u,l){return l.property?u+"["+l.property+"]":u}W.nameWithProperty=s;function i(u,l){if(typeof u!="function")throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(u,"layout_"))throw new Error("Class is already bound to a layout");if(!(l&&l instanceof r))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(l,"boundConstructor_"))throw new Error("layout is already bound to a constructor");u.layout_=l,l.boundConstructor_=u,l.makeDestinationObject=()=>new u,Object.defineProperty(u.prototype,"encode",{value(y,k){return l.encode(this,y,k)},writable:!0}),Object.defineProperty(u,"decode",{value(y,k){return l.decode(y,k)},writable:!0})}W.bindConstructorLayout=i;class o extends r{isCount(){throw new Error("ExternalLayout is abstract")}}W.ExternalLayout=o;class a extends o{constructor(l=1,y){if(!Number.isInteger(l)||0>=l)throw new TypeError("elementSpan must be a (positive) integer");super(-1,y),this.elementSpan=l}isCount(){return!0}decode(l,y=0){e(l);const k=l.length-y;return Math.floor(k/this.elementSpan)}encode(l,y,k){return 0}}W.GreedyCount=a;class f extends o{constructor(l,y=0,k){if(!(l instanceof r))throw new TypeError("layout must be a Layout");if(!Number.isInteger(y))throw new TypeError("offset must be integer or undefined");super(l.span,k||l.property),this.layout=l,this.offset=y}isCount(){return this.layout instanceof g||this.layout instanceof w}decode(l,y=0){return this.layout.decode(l,y+this.offset)}encode(l,y,k=0){return this.layout.encode(l,y,k+this.offset)}}W.OffsetLayout=f;class g extends r{constructor(l,y){if(super(l,y),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,y=0){return t(l).readUIntLE(y,this.span)}encode(l,y,k=0){return t(y).writeUIntLE(l,k,this.span),this.span}}W.UInt=g;class w extends r{constructor(l,y){if(super(l,y),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,y=0){return t(l).readUIntBE(y,this.span)}encode(l,y,k=0){return t(y).writeUIntBE(l,k,this.span),this.span}}W.UIntBE=w;class b extends r{constructor(l,y){if(super(l,y),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,y=0){return t(l).readIntLE(y,this.span)}encode(l,y,k=0){return t(y).writeIntLE(l,k,this.span),this.span}}W.Int=b;class x extends r{constructor(l,y){if(super(l,y),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,y=0){return t(l).readIntBE(y,this.span)}encode(l,y,k=0){return t(y).writeIntBE(l,k,this.span),this.span}}W.IntBE=x;const T=Math.pow(2,32);function L(u){const l=Math.floor(u/T),y=u-l*T;return{hi32:l,lo32:y}}function O(u,l){return u*T+l}class N extends r{constructor(l){super(8,l)}decode(l,y=0){const k=t(l),P=k.readUInt32LE(y),G=k.readUInt32LE(y+4);return O(G,P)}encode(l,y,k=0){const P=L(l),G=t(y);return G.writeUInt32LE(P.lo32,k),G.writeUInt32LE(P.hi32,k+4),8}}W.NearUInt64=N;class M extends r{constructor(l){super(8,l)}decode(l,y=0){const k=t(l),P=k.readUInt32BE(y),G=k.readUInt32BE(y+4);return O(P,G)}encode(l,y,k=0){const P=L(l),G=t(y);return G.writeUInt32BE(P.hi32,k),G.writeUInt32BE(P.lo32,k+4),8}}W.NearUInt64BE=M;class H extends r{constructor(l){super(8,l)}decode(l,y=0){const k=t(l),P=k.readUInt32LE(y),G=k.readInt32LE(y+4);return O(G,P)}encode(l,y,k=0){const P=L(l),G=t(y);return G.writeUInt32LE(P.lo32,k),G.writeInt32LE(P.hi32,k+4),8}}W.NearInt64=H;class K extends r{constructor(l){super(8,l)}decode(l,y=0){const k=t(l),P=k.readInt32BE(y),G=k.readUInt32BE(y+4);return O(P,G)}encode(l,y,k=0){const P=L(l),G=t(y);return G.writeInt32BE(P.hi32,k),G.writeUInt32BE(P.lo32,k+4),8}}W.NearInt64BE=K;class Q extends r{constructor(l){super(4,l)}decode(l,y=0){return t(l).readFloatLE(y)}encode(l,y,k=0){return t(y).writeFloatLE(l,k),4}}W.Float=Q;class q extends r{constructor(l){super(4,l)}decode(l,y=0){return t(l).readFloatBE(y)}encode(l,y,k=0){return t(y).writeFloatBE(l,k),4}}W.FloatBE=q;class D extends r{constructor(l){super(8,l)}decode(l,y=0){return t(l).readDoubleLE(y)}encode(l,y,k=0){return t(y).writeDoubleLE(l,k),8}}W.Double=D;class Z extends r{constructor(l){super(8,l)}decode(l,y=0){return t(l).readDoubleBE(y)}encode(l,y,k=0){return t(y).writeDoubleBE(l,k),8}}W.DoubleBE=Z;class j extends r{constructor(l,y,k){if(!(l instanceof r))throw new TypeError("elementLayout must be a Layout");if(!(y instanceof o&&y.isCount()||Number.isInteger(y)&&0<=y))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let P=-1;!(y instanceof o)&&0<l.span&&(P=y*l.span),super(P,k),this.elementLayout=l,this.count=y}getSpan(l,y=0){if(0<=this.span)return this.span;let k=0,P=this.count;if(P instanceof o&&(P=P.decode(l,y)),0<this.elementLayout.span)k=P*this.elementLayout.span;else{let G=0;for(;G<P;)k+=this.elementLayout.getSpan(l,y+k),++G}return k}decode(l,y=0){const k=[];let P=0,G=this.count;for(G instanceof o&&(G=G.decode(l,y));P<G;)k.push(this.elementLayout.decode(l,y)),y+=this.elementLayout.getSpan(l,y),P+=1;return k}encode(l,y,k=0){const P=this.elementLayout,G=l.reduce((re,J)=>re+P.encode(J,y,k+re),0);return this.count instanceof o&&this.count.encode(l.length,y,k),G}}W.Sequence=j;class X extends r{constructor(l,y,k){if(!(Array.isArray(l)&&l.reduce((G,re)=>G&&re instanceof r,!0)))throw new TypeError("fields must be array of Layout instances");typeof y=="boolean"&&k===void 0&&(k=y,y=void 0);for(const G of l)if(0>G.span&&G.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let P=-1;try{P=l.reduce((G,re)=>G+re.getSpan(),0)}catch{}super(P,y),this.fields=l,this.decodePrefixes=!!k}getSpan(l,y=0){if(0<=this.span)return this.span;let k=0;try{k=this.fields.reduce((P,G)=>{const re=G.getSpan(l,y);return y+=re,P+re},0)}catch{throw new RangeError("indeterminate span")}return k}decode(l,y=0){e(l);const k=this.makeDestinationObject();for(const P of this.fields)if(P.property!==void 0&&(k[P.property]=P.decode(l,y)),y+=P.getSpan(l,y),this.decodePrefixes&&l.length===y)break;return k}encode(l,y,k=0){const P=k;let G=0,re=0;for(const J of this.fields){let Ae=J.span;if(re=0<Ae?Ae:0,J.property!==void 0){const ge=l[J.property];ge!==void 0&&(re=J.encode(ge,y,k),0>Ae&&(Ae=J.getSpan(y,k)))}G=k,k+=Ae}return G+re-P}fromArray(l){const y=this.makeDestinationObject();for(const k of this.fields)k.property!==void 0&&0<l.length&&(y[k.property]=l.shift());return y}layoutFor(l){if(typeof l!="string")throw new TypeError("property must be string");for(const y of this.fields)if(y.property===l)return y}offsetOf(l){if(typeof l!="string")throw new TypeError("property must be string");let y=0;for(const k of this.fields){if(k.property===l)return y;0>k.span?y=-1:0<=y&&(y+=k.span)}}}W.Structure=X;class z{constructor(l){this.property=l}decode(l,y){throw new Error("UnionDiscriminator is abstract")}encode(l,y,k){throw new Error("UnionDiscriminator is abstract")}}W.UnionDiscriminator=z;class V extends z{constructor(l,y){if(!(l instanceof o&&l.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(y||l.property||"variant"),this.layout=l}decode(l,y){return this.layout.decode(l,y)}encode(l,y,k){return this.layout.encode(l,y,k)}}W.UnionLayoutDiscriminator=V;class ee extends r{constructor(l,y,k){let P;if(l instanceof g||l instanceof w)P=new V(new f(l));else if(l instanceof o&&l.isCount())P=new V(l);else if(l instanceof z)P=l;else throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(y===void 0&&(y=null),!(y===null||y instanceof r))throw new TypeError("defaultLayout must be null or a Layout");if(y!==null){if(0>y.span)throw new Error("defaultLayout must have constant span");y.property===void 0&&(y=y.replicate("content"))}let G=-1;y&&(G=y.span,0<=G&&(l instanceof g||l instanceof w)&&(G+=P.layout.span)),super(G,k),this.discriminator=P,this.usesPrefixDiscriminator=l instanceof g||l instanceof w,this.defaultLayout=y,this.registry={};let re=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(J){return re(J)},this.configGetSourceVariant=function(J){re=J.bind(this)}}getSpan(l,y=0){if(0<=this.span)return this.span;const k=this.getVariant(l,y);if(!k)throw new Error("unable to determine span for unrecognized variant");return k.getSpan(l,y)}defaultGetSourceVariant(l){if(Object.prototype.hasOwnProperty.call(l,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(l,this.defaultLayout.property))return;const y=this.registry[l[this.discriminator.property]];if(y&&(!y.layout||y.property&&Object.prototype.hasOwnProperty.call(l,y.property)))return y}else for(const y in this.registry){const k=this.registry[y];if(k.property&&Object.prototype.hasOwnProperty.call(l,k.property))return k}throw new Error("unable to infer src variant")}decode(l,y=0){let k;const P=this.discriminator,G=P.decode(l,y),re=this.registry[G];if(re===void 0){const J=this.defaultLayout;let Ae=0;this.usesPrefixDiscriminator&&(Ae=P.layout.span),k=this.makeDestinationObject(),k[P.property]=G,k[J.property]=J.decode(l,y+Ae)}else k=re.decode(l,y);return k}encode(l,y,k=0){const P=this.getSourceVariant(l);if(P===void 0){const G=this.discriminator,re=this.defaultLayout;let J=0;return this.usesPrefixDiscriminator&&(J=G.layout.span),G.encode(l[G.property],y,k),J+re.encode(l[re.property],y,k+J)}return P.encode(l,y,k)}addVariant(l,y,k){const P=new S(this,l,y,k);return this.registry[l]=P,P}getVariant(l,y=0){let k;return l instanceof Uint8Array?k=this.discriminator.decode(l,y):k=l,this.registry[k]}}W.Union=ee;class S extends r{constructor(l,y,k,P){if(!(l instanceof ee))throw new TypeError("union must be a Union");if(!Number.isInteger(y)||0>y)throw new TypeError("variant must be a (non-negative) integer");if(typeof k=="string"&&P===void 0&&(P=k,k=null),k){if(!(k instanceof r))throw new TypeError("layout must be a Layout");if(l.defaultLayout!==null&&0<=k.span&&k.span>l.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof P!="string")throw new TypeError("variant must have a String property")}let G=l.span;0>l.span&&(G=k?k.span:0,0<=G&&l.usesPrefixDiscriminator&&(G+=l.discriminator.layout.span)),super(G,P),this.union=l,this.variant=y,this.layout=k||null}getSpan(l,y=0){if(0<=this.span)return this.span;let k=0;this.union.usesPrefixDiscriminator&&(k=this.union.discriminator.layout.span);let P=0;return this.layout&&(P=this.layout.getSpan(l,y+k)),k+P}decode(l,y=0){const k=this.makeDestinationObject();if(this!==this.union.getVariant(l,y))throw new Error("variant mismatch");let P=0;return this.union.usesPrefixDiscriminator&&(P=this.union.discriminator.layout.span),this.layout?k[this.property]=this.layout.decode(l,y+P):this.property?k[this.property]=!0:this.union.usesPrefixDiscriminator&&(k[this.union.discriminator.property]=this.variant),k}encode(l,y,k=0){let P=0;if(this.union.usesPrefixDiscriminator&&(P=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(l,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,y,k);let G=P;if(this.layout&&(this.layout.encode(l[this.property],y,k+P),G+=this.layout.getSpan(y,k+P),0<=this.union.span&&G>this.union.span))throw new Error("encoded variant overruns containing union");return G}fromArray(l){if(this.layout)return this.layout.fromArray(l)}}W.VariantLayout=S;function c(u){return 0>u&&(u+=4294967296),u}class p extends r{constructor(l,y,k){if(!(l instanceof g||l instanceof w))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof y=="string"&&k===void 0&&(k=y,y=!1),4<l.span)throw new RangeError("word cannot exceed 32 bits");super(l.span,k),this.word=l,this.msb=!!y,this.fields=[];let P=0;this._packedSetValue=function(G){return P=c(G),this},this._packedGetValue=function(){return P}}decode(l,y=0){const k=this.makeDestinationObject(),P=this.word.decode(l,y);this._packedSetValue(P);for(const G of this.fields)G.property!==void 0&&(k[G.property]=G.decode(l));return k}encode(l,y,k=0){const P=this.word.decode(y,k);this._packedSetValue(P);for(const G of this.fields)if(G.property!==void 0){const re=l[G.property];re!==void 0&&G.encode(re)}return this.word.encode(this._packedGetValue(),y,k)}addField(l,y){const k=new m(this,l,y);return this.fields.push(k),k}addBoolean(l){const y=new I(this,l);return this.fields.push(y),y}fieldFor(l){if(typeof l!="string")throw new TypeError("property must be string");for(const y of this.fields)if(y.property===l)return y}}W.BitStructure=p;class m{constructor(l,y,k){if(!(l instanceof p))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(y)||0>=y)throw new TypeError("bits must be positive integer");const P=8*l.span,G=l.fields.reduce((re,J)=>re+J.bits,0);if(y+G>P)throw new Error("bits too long for span remainder ("+(P-G)+" of "+P+" remain)");this.container=l,this.bits=y,this.valueMask=(1<<y)-1,y===32&&(this.valueMask=4294967295),this.start=G,this.container.msb&&(this.start=P-G-y),this.wordMask=c(this.valueMask<<this.start),this.property=k}decode(l,y){const k=this.container._packedGetValue();return c(k&this.wordMask)>>>this.start}encode(l){if(typeof l!="number"||!Number.isInteger(l)||l!==c(l&this.valueMask))throw new TypeError(s("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const y=this.container._packedGetValue(),k=c(l<<this.start);this.container._packedSetValue(c(y&~this.wordMask)|k)}}W.BitField=m;class I extends m{constructor(l,y){super(l,1,y)}decode(l,y){return!!super.decode(l,y)}encode(l){typeof l=="boolean"&&(l=+l),super.encode(l)}}W.Boolean=I;class E extends r{constructor(l,y){if(!(l instanceof o&&l.isCount()||Number.isInteger(l)&&0<=l))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let k=-1;l instanceof o||(k=l),super(k,y),this.length=l}getSpan(l,y){let k=this.span;return 0>k&&(k=this.length.decode(l,y)),k}decode(l,y=0){let k=this.span;return 0>k&&(k=this.length.decode(l,y)),t(l).slice(y,y+k)}encode(l,y,k){let P=this.length;if(this.length instanceof o&&(P=l.length),!(l instanceof Uint8Array&&P===l.length))throw new TypeError(s("Blob.encode",this)+" requires (length "+P+") Uint8Array as src");if(k+P>y.length)throw new RangeError("encoding overruns Uint8Array");const G=t(l);return t(y).write(G.toString("hex"),k,P,"hex"),this.length instanceof o&&this.length.encode(P,y,k),P}}W.Blob=E;class A extends r{constructor(l){super(-1,l)}getSpan(l,y=0){e(l);let k=y;for(;k<l.length&&l[k]!==0;)k+=1;return 1+k-y}decode(l,y=0){const k=this.getSpan(l,y);return t(l).slice(y,y+k-1).toString("utf-8")}encode(l,y,k=0){typeof l!="string"&&(l=String(l));const P=n.Buffer.from(l,"utf8"),G=P.length;if(k+G>y.length)throw new RangeError("encoding overruns Buffer");const re=t(y);return P.copy(re,k),re[k+G]=0,G+1}}W.CString=A;class C extends r{constructor(l,y){if(typeof l=="string"&&y===void 0&&(y=l,l=void 0),l===void 0)l=-1;else if(!Number.isInteger(l))throw new TypeError("maxSpan must be an integer");super(-1,y),this.maxSpan=l}getSpan(l,y=0){return e(l),l.length-y}decode(l,y=0){const k=this.getSpan(l,y);if(0<=this.maxSpan&&this.maxSpan<k)throw new RangeError("text length exceeds maxSpan");return t(l).slice(y,y+k).toString("utf-8")}encode(l,y,k=0){typeof l!="string"&&(l=String(l));const P=n.Buffer.from(l,"utf8"),G=P.length;if(0<=this.maxSpan&&this.maxSpan<G)throw new RangeError("text length exceeds maxSpan");if(k+G>y.length)throw new RangeError("encoding overruns Buffer");return P.copy(t(y),k),G}}W.UTF8=C;class R extends r{constructor(l,y){super(0,y),this.value=l}decode(l,y){return this.value}encode(l,y,k){return 0}}return W.Constant=R,W.greedy=(u,l)=>new a(u,l),W.offset=(u,l,y)=>new f(u,l,y),W.u8=u=>new g(1,u),W.u16=u=>new g(2,u),W.u24=u=>new g(3,u),W.u32=u=>new g(4,u),W.u40=u=>new g(5,u),W.u48=u=>new g(6,u),W.nu64=u=>new N(u),W.u16be=u=>new w(2,u),W.u24be=u=>new w(3,u),W.u32be=u=>new w(4,u),W.u40be=u=>new w(5,u),W.u48be=u=>new w(6,u),W.nu64be=u=>new M(u),W.s8=u=>new b(1,u),W.s16=u=>new b(2,u),W.s24=u=>new b(3,u),W.s32=u=>new b(4,u),W.s40=u=>new b(5,u),W.s48=u=>new b(6,u),W.ns64=u=>new H(u),W.s16be=u=>new x(2,u),W.s24be=u=>new x(3,u),W.s32be=u=>new x(4,u),W.s40be=u=>new x(5,u),W.s48be=u=>new x(6,u),W.ns64be=u=>new K(u),W.f32=u=>new Q(u),W.f32be=u=>new q(u),W.f64=u=>new D(u),W.f64be=u=>new Z(u),W.struct=(u,l,y)=>new X(u,l,y),W.bits=(u,l,y)=>new p(u,l,y),W.seq=(u,l,y)=>new j(u,l,y),W.union=(u,l,y)=>new ee(u,l,y),W.unionLayoutDiscriminator=(u,l)=>new V(u,l),W.blob=(u,l)=>new E(u,l),W.cstr=u=>new A(u),W.utf8=(u,l)=>new C(u,l),W.constant=(u,l)=>new R(u,l),W}var B=du(),pu=1,gu=2,mu=3,_u=4,yu=5,wu=6,bu=7,Ru=8,Eu=9,Su=10,Au=-32700,Iu=-32603,vu=-32602,Ou=-32601,ku=-32600,Tu=-32016,Nu=-32015,xu=-32014,Bu=-32013,Lu=-32012,Cu=-32011,Mu=-32010,Pu=-32009,Uu=-32008,Du=-32007,Fu=-32006,zu=-32005,Ku=-32004,$u=-32003,Hu=-32002,Wu=-32001,qu=28e5,Vu=2800001,Gu=2800002,Yu=2800003,ju=2800004,Zu=2800005,Xu=2800006,Ju=2800007,Qu=2800008,el=2800009,tl=2800010,nl=323e4,rl=32300001,il=3230002,sl=3230003,ol=3230004,al=361e4,cl=3610001,ul=3610002,ll=3610003,hl=3610004,fl=3610005,dl=3610006,pl=3610007,gl=3611e3,ml=3704e3,_l=3704001,yl=3704002,wl=3704003,bl=3704004,Rl=4128e3,El=4128001,Sl=4128002,Al=4615e3,Il=4615001,vl=4615002,Ol=4615003,kl=4615004,Tl=4615005,Nl=4615006,xl=4615007,Bl=4615008,Ll=4615009,Cl=4615010,Ml=4615011,Pl=4615012,Ul=4615013,Dl=4615014,Fl=4615015,zl=4615016,Kl=4615017,$l=4615018,Hl=4615019,Wl=4615020,ql=4615021,Vl=4615022,Gl=4615023,Yl=4615024,jl=4615025,Zl=4615026,Xl=4615027,Jl=4615028,Ql=4615029,eh=4615030,th=4615031,nh=4615032,rh=4615033,ih=4615034,sh=4615035,oh=4615036,ah=4615037,ch=4615038,uh=4615039,lh=4615040,hh=4615041,fh=4615042,dh=4615043,ph=4615044,gh=4615045,mh=4615046,_h=4615047,yh=4615048,wh=4615049,bh=4615050,Rh=4615051,Eh=4615052,Sh=4615053,Ah=4615054,Ih=5508e3,vh=5508001,Oh=5508002,kh=5508003,Th=5508004,Nh=5508005,xh=5508006,Bh=5508007,Lh=5508008,Ch=5508009,Mh=5508010,Ph=5508011,Uh=5663e3,Dh=5663001,Fh=5663002,zh=5663003,Kh=5663004,$h=5663005,Hh=5663006,Wh=5663007,qh=5663008,Vh=5663009,Gh=5663010,Yh=5663011,jh=5663012,Zh=5663013,Xh=5663014,Jh=5663015,Qh=5663016,ef=5663017,tf=5663018,nf=5663019,rf=705e4,sf=7050001,of=7050002,af=7050003,cf=7050004,uf=7050005,lf=7050006,hf=7050007,ff=7050008,df=7050009,pf=7050010,gf=7050011,mf=7050012,_f=7050013,yf=7050014,wf=7050015,bf=7050016,Rf=7050017,Ef=7050018,Sf=7050019,Af=7050020,If=7050021,vf=7050022,Of=7050023,kf=7050024,Tf=7050025,Nf=7050026,xf=7050027,Bf=7050028,Lf=7050029,Cf=7050030,Mf=7050031,Pf=7050032,Uf=7050033,Df=7050034,Ff=7050035,zf=7050036,ao=8078e3,co=8078001,Kf=8078002,$f=8078003,uo=8078004,lo=8078005,ho=8078006,Hf=8078007,Wf=8078008,qf=8078009,Vf=8078010,fo=8078011,Gf=8078012,Yf=8078013,jf=8078014,Zf=8078015,Xf=8078016,Jf=8078017,Qf=8078018,ed=8078019,td=8078020,nd=8078021,rd=8078022,id=81e5,sd=8100001,od=8100002,ad=8100003,cd=819e4,ud=8190001,ld=8190002,hd=8190003,fd=8190004,dd=99e5,pd=9900001,gd=9900002,md=9900003,_d=9900004;function po(n){return Array.isArray(n)?"%5B"+n.map(po).join("%2C%20")+"%5D":typeof n=="bigint"?`${n}n`:encodeURIComponent(String(n!=null&&Object.getPrototypeOf(n)===null?{...n}:n))}function yd([n,e]){return`${n}=${po(e)}`}function wd(n){const e=Object.entries(n).map(yd).join("&");return btoa(e)}var bd={[nl]:"Account not found at address: $address",[ol]:"Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",[sl]:"Expected decoded account at address: $address",[il]:"Failed to decode account data at address: $address",[rl]:"Accounts not found at addresses: $addresses",[el]:"Unable to find a viable program address bump seed.",[Gu]:"$putativeAddress is not a base58-encoded address.",[qu]:"Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",[Yu]:"The `CryptoKey` must be an `Ed25519` public key.",[Qu]:"Invalid seeds; point must fall off the Ed25519 curve.",[ju]:"Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",[Xu]:"A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",[Ju]:"The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",[Zu]:"Expected program derived address bump to be in the range [0, 255], got: $bump.",[tl]:"Program address cannot end with PDA marker.",[Vu]:"Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",[_u]:"Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",[pu]:"The network has progressed past the last block for which this transaction could have been committed.",[ao]:"Codec [$codecDescription] cannot decode empty byte arrays.",[rd]:"Enum codec cannot use lexical values [$stringValues] as discriminators. Either remove all lexical values or set `useValuesAsDiscriminators` to `false`.",[td]:"Sentinel [$hexSentinel] must not be present in encoded bytes [$hexEncodedBytes].",[lo]:"Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",[ho]:"Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",[uo]:"Encoder and decoder must either both be fixed-size or variable-size.",[Wf]:"Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",[Kf]:"Expected a fixed-size codec, got a variable-size one.",[Yf]:"Codec [$codecDescription] expected a positive byte length, got $bytesLength.",[$f]:"Expected a variable-size codec, got a fixed-size one.",[ed]:"Codec [$codecDescription] expected zero-value [$hexZeroValue] to have the same size as the provided fixed-size item [$expectedSize bytes].",[co]:"Codec [$codecDescription] expected $expected bytes, got $bytesLength.",[Qf]:"Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",[qf]:"Invalid discriminated union variant. Expected one of [$variants], got $value.",[Vf]:"Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",[Zf]:"Invalid literal union variant. Expected one of [$variants], got $value.",[Hf]:"Expected [$codecDescription] to have $expected items, got $actual.",[Gf]:"Invalid value $value for base $base with alphabet $alphabet.",[Xf]:"Literal union discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",[fo]:"Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",[jf]:"Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",[nd]:"Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",[Jf]:"Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",[gl]:"No random values implementation could be found.",[Ll]:"instruction requires an uninitialized account",[Gl]:"instruction tries to borrow reference for an account which is already borrowed",[Yl]:"instruction left account with an outstanding borrowed reference",[ql]:"program other than the account's owner changed the size of the account data",[Tl]:"account data too small for instruction",[Vl]:"instruction expected an executable account",[mh]:"An account does not have enough lamports to be rent-exempt",[yh]:"Program arithmetic overflowed",[gh]:"Failed to serialize or deserialize account data: $encodedData",[Ah]:"Builtin programs must consume compute units",[nh]:"Cross-program invocation call depth too deep",[ch]:"Computational budget exceeded",[Zl]:"custom program error: #$code",[Kl]:"instruction contains duplicate accounts",[jl]:"instruction modifications of multiply-passed account differ",[eh]:"executable accounts must be rent exempt",[Jl]:"instruction changed executable accounts data",[Ql]:"instruction changed the balance of an executable account",[$l]:"instruction changed executable bit of an account",[Dl]:"instruction modified data of an account it does not own",[Ul]:"instruction spent from the balance of an account it does not own",[Il]:"generic instruction error",[bh]:"Provided owner is not allowed",[dh]:"Account is immutable",[ph]:"Incorrect authority provided",[xl]:"incorrect program id for instruction",[Nl]:"insufficient funds for instruction",[kl]:"invalid account data for instruction",[_h]:"Invalid account owner",[vl]:"invalid program argument",[Xl]:"program returned invalid error code",[Ol]:"invalid instruction data",[ah]:"Failed to reallocate account data",[oh]:"Provided seeds do not result in a valid address",[Rh]:"Accounts data allocations exceeded the maximum allowed per transaction",[Eh]:"Max accounts exceeded",[Sh]:"Max instruction trace length exceeded",[sh]:"Length of the seed is too long for address generation",[rh]:"An account required by the instruction is missing",[Bl]:"missing required signature for instruction",[Pl]:"instruction illegally modified the program id of an account",[Wl]:"insufficient account keys for instruction",[uh]:"Cross-program invocation with unauthorized signer or writable account",[lh]:"Failed to create program execution environment",[fh]:"Program failed to compile",[hh]:"Program failed to complete",[zl]:"instruction modified data of a read-only account",[Fl]:"instruction changed the balance of a read-only account",[ih]:"Cross-program invocation reentrancy not allowed for this instruction",[Hl]:"instruction modified rent epoch of an account",[Ml]:"sum of account balances before and after instruction do not match",[Cl]:"instruction requires an initialized account",[Al]:"",[th]:"Unsupported program id",[wh]:"Unsupported sysvar",[Rl]:"The instruction does not have any accounts.",[El]:"The instruction does not have any data.",[Sl]:"Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",[yu]:"Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",[gu]:"The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",[gd]:"Invariant violation: Found no abortable iterable cache entry for key `$cacheKey`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[_d]:"Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",[pd]:"Invariant violation: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[dd]:"Invariant violation: WebSocket message iterator is missing state storage. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[md]:"Invariant violation: Switch statement non-exhaustive. Received unexpected value `$unexpectedValue`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[Iu]:"JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",[vu]:"JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",[ku]:"JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",[Ou]:"JSON-RPC error: The method does not exist / is not available ($__serverMessage)",[Au]:"JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",[Lu]:"$__serverMessage",[Wu]:"$__serverMessage",[Ku]:"$__serverMessage",[xu]:"$__serverMessage",[Mu]:"$__serverMessage",[Pu]:"$__serverMessage",[Tu]:"Minimum context slot has not been reached",[zu]:"Node is unhealthy; behind by $numSlotsBehind slots",[Uu]:"No snapshot",[Hu]:"Transaction simulation failed",[Du]:"$__serverMessage",[Cu]:"Transaction history is not available from this node",[Fu]:"$__serverMessage",[Bu]:"Transaction signature length mismatch",[$u]:"Transaction signature verification failure",[Nu]:"$__serverMessage",[ml]:"Key pair bytes must be of length 64, got $byteLength.",[_l]:"Expected private key bytes with length 32. Actual length: $actualLength.",[yl]:"Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",[bl]:"The provided private key does not match the provided public key.",[wl]:"Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",[wu]:"Lamports value must be in the range [0, 2e64-1]",[bu]:"`$value` cannot be parsed as a `BigInt`",[Su]:"$message",[Ru]:"`$value` cannot be parsed as a `Number`",[mu]:"No nonce account could be found at address `$nonceAccountAddress`",[cd]:"The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",[ld]:"WebSocket was closed before payload could be added to the send buffer",[hd]:"WebSocket connection closed",[fd]:"WebSocket failed to connect",[ud]:"Failed to obtain a subscription id from the server",[ad]:"Could not find an API plan for RPC method: `$method`",[id]:"The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was `$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds `Number.MAX_SAFE_INTEGER`.",[od]:"HTTP error ($statusCode): $message",[sd]:"HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",[Ih]:"Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",[vh]:"The provided value does not implement the `KeyPairSigner` interface",[kh]:"The provided value does not implement the `MessageModifyingSigner` interface",[Th]:"The provided value does not implement the `MessagePartialSigner` interface",[Oh]:"The provided value does not implement any of the `MessageSigner` interfaces",[xh]:"The provided value does not implement the `TransactionModifyingSigner` interface",[Bh]:"The provided value does not implement the `TransactionPartialSigner` interface",[Lh]:"The provided value does not implement the `TransactionSendingSigner` interface",[Nh]:"The provided value does not implement any of the `TransactionSigner` interfaces",[Ch]:"More than one `TransactionSendingSigner` was identified.",[Mh]:"No `TransactionSendingSigner` was identified. Please provide a valid `ITransactionWithSingleSendingSigner` transaction.",[Ph]:"Wallet account signers do not support signing multiple messages/transactions in a single operation",[pl]:"Cannot export a non-extractable key.",[cl]:"No digest implementation could be found.",[al]:"Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",[ul]:`This runtime does not support the generation of Ed25519 key pairs.
|
|
7
7
|
|
|
8
8
|
Install @solana/webcrypto-ed25519-polyfill and call its \`install\` function before generating keys in environments that do not support Ed25519.
|
|
9
9
|
|
|
10
|
-
For a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20.`,[ll]:"No signature verification implementation could be found.",[hl]:"No key generation implementation could be found.",[fl]:"No signing implementation could be found.",[dl]:"No key export implementation could be found.",[Eu]:"Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",[bf]:"Transaction processing left an account with an outstanding borrowed reference",[sf]:"Account in use",[of]:"Account loaded twice",[af]:"Attempt to debit an account but found no record of a prior credit.",[Of]:"Transaction loads an address table account that doesn't exist",[hf]:"This transaction has already been processed",[ff]:"Blockhash not found",[df]:"Loader call chain is too deep",[wf]:"Transactions are currently disabled due to cluster maintenance",[Cf]:"Transaction contains a duplicate instruction ($index) that is not allowed",[uf]:"Insufficient funds for fee",[Mf]:"Transaction results in an account ($accountIndex) with insufficient funds for rent",[lf]:"This account may not be used to pay transaction fees",[gf]:"Transaction contains an invalid account reference",[Tf]:"Transaction loads an address table account with invalid data",[Nf]:"Transaction address table lookup uses an invalid index",[kf]:"Transaction loads an address table account with an invalid owner",[Uf]:"LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",[_f]:"This program may not be used for executing instructions",[xf]:"Transaction leaves an account with a lower balance than rent-exempt minimum",[Sf]:"Transaction loads a writable account that cannot be written",[Pf]:"Transaction exceeded max loaded accounts data size cap",[pf]:"Transaction requires a fee but has no signature present",[cf]:"Attempt to load a program that does not exist",[Ff]:"Execution of the program referenced by account at index $accountIndex is temporarily restricted.",[Df]:"ResanitizationNeeded",[yf]:"Transaction failed to sanitize accounts offsets correctly",[mf]:"Transaction did not pass signature verification",[vf]:"Transaction locked too many accounts",[zf]:"Sum of account balances before and after transaction do not match",[rf]:"The transaction failed with the error `$errorName`",[Ef]:"Transaction version is unsupported",[If]:"Transaction would exceed account data limit within the block",[Lf]:"Transaction would exceed total account data limit",[Af]:"Transaction would exceed max account limit within the block",[Rf]:"Transaction would exceed max Block Cost Limit",[Bf]:"Transaction would exceed max Vote Cost Limit",[Jh]:"Attempted to sign a transaction with an address that is not a signer for it",[Gh]:"Transaction is missing an address at index: $index.",[Qh]:"Transaction has no expected signers therefore it cannot be encoded",[Fh]:"Transaction does not have a blockhash lifetime",[zh]:"Transaction is not a durable nonce transaction",[$h]:"Contents of these address lookup tables unknown: $lookupTableAddresses",[Hh]:"Lookup of address at index $highestRequestedIndex failed for lookup table `$lookupTableAddress`. Highest known index is $highestKnownIndex. The lookup table may have been extended since its contents were retrieved",[qh]:"No fee payer set in CompiledTransaction",[Wh]:"Could not find program address at index $index",[tf]:"Failed to estimate the compute unit consumption for this transaction message. This is likely because simulating the transaction failed. Inspect the `cause` property of this error to learn more",[nf]:"Transaction failed when it was simulated in order to estimate the compute unit consumption. The compute unit estimate provided is for a transaction that failed when simulated and may not be representative of the compute units this transaction would consume if successful. Inspect the `cause` property of this error to learn more",[Yh]:"Transaction is missing a fee payer.",[jh]:"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",[Xh]:"Transaction first instruction is not advance nonce account instruction.",[Zh]:"Transaction with no instructions cannot be durable nonce transaction.",[Uh]:"This transaction includes an address (`$programAddress`) which is both invoked and set as the fee payer. Program addresses may not pay fees",[Dh]:"This transaction includes an address (`$programAddress`) which is both invoked and marked writable. Program addresses may not be writable",[ef]:"The transaction message expected the transaction to have $signerAddressesLength signatures, got $signaturesLength.",[Vh]:"Transaction is missing signatures for addresses: $addresses.",[Kh]:"Transaction version must be in the range [0, 127]. `$actualVersion` given"},Gt="i",Mt="t";function Rd(n,e={}){const t=bd[n];if(t.length===0)return"";let r;function s(o){if(r[Mt]===2){const a=t.slice(r[Gt]+1,o);i.push(a in e?`${e[a]}`:`$${a}`)}else r[Mt]===1&&i.push(t.slice(r[Gt],o))}const i=[];return t.split("").forEach((o,a)=>{if(a===0){r={[Gt]:0,[Mt]:t[0]==="\\"?0:t[0]==="$"?2:1};return}let f;switch(r[Mt]){case 0:f={[Gt]:a,[Mt]:1};break;case 1:o==="\\"?f={[Gt]:a,[Mt]:0}:o==="$"&&(f={[Gt]:a,[Mt]:2});break;case 2:o==="\\"?f={[Gt]:a,[Mt]:0}:o==="$"?f={[Gt]:a,[Mt]:2}:o.match(/\w/)||(f={[Gt]:a,[Mt]:1});break}f&&(r!==f&&s(a),r=f)}),s(),i.join("")}function Ed(n,e={}){if(process.env.NODE_ENV!=="production")return Rd(n,e);{let t=`Solana error #${n}; Decode this error by running \`npx @solana/errors decode -- ${n}`;return Object.keys(e).length&&(t+=` '${wd(e)}'`),`${t}\``}}var On=class extends Error{cause=this.cause;context;constructor(...[n,e]){let t,r;if(e){const{cause:i,...o}=e;i&&(r={cause:i}),Object.keys(o).length>0&&(t=o)}const s=Ed(n,t);super(s,r),this.context={__code:n,...t},this.name="SolanaError"}};function Sd(n,e){return"fixedSize"in e?e.fixedSize:e.getSizeFromValue(n)}function Ad(n){return Object.freeze({...n,encode:e=>{const t=new Uint8Array(Sd(e,n));return n.write(e,t,0),t}})}function Id(n){return Object.freeze({...n,decode:(e,t=0)=>n.read(e,t)[0]})}function kn(n){return"fixedSize"in n&&typeof n.fixedSize=="number"}function vd(n,e){if(kn(n)!==kn(e))throw new On(uo);if(kn(n)&&kn(e)&&n.fixedSize!==e.fixedSize)throw new On(lo,{decoderFixedSize:e.fixedSize,encoderFixedSize:n.fixedSize});if(!kn(n)&&!kn(e)&&n.maxSize!==e.maxSize)throw new On(ho,{decoderMaxSize:e.maxSize,encoderMaxSize:n.maxSize});return{...e,...n,decode:e.decode,encode:n.encode,read:e.read,write:n.write}}function Od(n,e,t=0){if(e.length-t<=0)throw new On(ao,{codecDescription:n})}function kd(n,e,t,r=0){const s=t.length-r;if(s<e)throw new On(co,{bytesLength:s,codecDescription:n,expected:e})}function Td(n,e,t,r){if(r<e||r>t)throw new On(fo,{codecDescription:n,max:t,min:e,value:r})}function go(n){return n?.endian!==1}function Nd(n){return Ad({fixedSize:n.size,write(e,t,r){n.range&&Td(n.name,n.range[0],n.range[1],e);const s=new ArrayBuffer(n.size);return n.set(new DataView(s),e,go(n.config)),t.set(new Uint8Array(s),r),r+n.size}})}function xd(n){return Id({fixedSize:n.size,read(e,t=0){Od(n.name,e,t),kd(n.name,n.size,e,t);const r=new DataView(Bd(e,t,n.size));return[n.get(r,go(n.config)),t+n.size]}})}function Bd(n,e,t){const r=n.byteOffset+(e??0),s=t??n.byteLength;return n.buffer.slice(r,r+s)}var mo=(n={})=>Nd({config:n,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(e,t,r)=>e.setBigUint64(0,BigInt(t),r),size:8}),Ld=(n={})=>xd({config:n,get:(e,t)=>e.getBigUint64(0,t),name:"u64",size:8}),Cd=(n={})=>vd(mo(n),Ld(n));class Md extends TypeError{constructor(e,t){let r;const{message:s,explanation:i,...o}=e,{path:a}=e,f=a.length===0?s:`At path: ${a.join(".")} -- ${s}`;super(i??f),i!=null&&(this.cause=f),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>r??(r=[e,...t()])}}function Pd(n){return Wn(n)&&typeof n[Symbol.iterator]=="function"}function Wn(n){return typeof n=="object"&&n!=null}function gr(n){return Wn(n)&&!Array.isArray(n)}function xt(n){return typeof n=="symbol"?n.toString():typeof n=="string"?JSON.stringify(n):`${n}`}function Ud(n){const{done:e,value:t}=n.next();return e?void 0:t}function Dd(n,e,t,r){if(n===!0)return;n===!1?n={}:typeof n=="string"&&(n={message:n});const{path:s,branch:i}=e,{type:o}=t,{refinement:a,message:f=`Expected a value of type \`${o}\`${a?` with refinement \`${a}\``:""}, but received: \`${xt(r)}\``}=n;return{value:r,type:o,refinement:a,key:s[s.length-1],path:s,branch:i,...n,message:f}}function*_o(n,e,t,r){Pd(n)||(n=[n]);for(const s of n){const i=Dd(s,e,t,r);i&&(yield i)}}function*oi(n,e,t={}){const{path:r=[],branch:s=[n],coerce:i=!1,mask:o=!1}=t,a={path:r,branch:s,mask:o};i&&(n=e.coercer(n,a));let f="valid";for(const g of e.validator(n,a))g.explanation=t.message,f="not_valid",yield[g,void 0];for(let[g,w,b]of e.entries(n,a)){const x=oi(w,b,{path:g===void 0?r:[...r,g],branch:g===void 0?s:[...s,w],coerce:i,mask:o,message:t.message});for(const T of x)T[0]?(f=T[0].refinement!=null?"not_refined":"not_valid",yield[T[0],void 0]):i&&(w=T[1],g===void 0?n=w:n instanceof Map?n.set(g,w):n instanceof Set?n.add(w):Wn(n)&&(w!==void 0||g in n)&&(n[g]=w))}if(f!=="not_valid")for(const g of e.refiner(n,a))g.explanation=t.message,f="not_refined",yield[g,void 0];f==="valid"&&(yield[void 0,n])}let Pt=class{constructor(e){const{type:t,schema:r,validator:s,refiner:i,coercer:o=f=>f,entries:a=function*(){}}=e;this.type=t,this.schema=r,this.entries=a,this.coercer=o,s?this.validator=(f,g)=>{const w=s(f,g);return _o(w,g,this,f)}:this.validator=()=>[],i?this.refiner=(f,g)=>{const w=i(f,g);return _o(w,g,this,f)}:this.refiner=()=>[]}assert(e,t){return yo(e,this,t)}create(e,t){return se(e,this,t)}is(e){return wo(e,this)}mask(e,t){return Fd(e,this,t)}validate(e,t={}){return qn(e,this,t)}};function yo(n,e,t){const r=qn(n,e,{message:t});if(r[0])throw r[0]}function se(n,e,t){const r=qn(n,e,{coerce:!0,message:t});if(r[0])throw r[0];return r[1]}function Fd(n,e,t){const r=qn(n,e,{coerce:!0,mask:!0,message:t});if(r[0])throw r[0];return r[1]}function wo(n,e){return!qn(n,e)[0]}function qn(n,e,t={}){const r=oi(n,e,t),s=Ud(r);return s[0]?[new Md(s[0],function*(){for(const o of r)o[0]&&(yield o[0])}),void 0]:[void 0,s[1]]}function hn(n,e){return new Pt({type:n,schema:null,validator:e})}function zd(){return hn("any",()=>!0)}function oe(n){return new Pt({type:"array",schema:n,*entries(e){if(n&&Array.isArray(e))for(const[t,r]of e.entries())yield[t,r,n]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||`Expected an array value, but received: ${xt(e)}`}})}function Ut(){return hn("boolean",n=>typeof n=="boolean")}function ai(n){return hn("instance",e=>e instanceof n||`Expected a \`${n.name}\` instance, but received: ${xt(e)}`)}function qe(n){const e=xt(n),t=typeof n;return new Pt({type:"literal",schema:t==="string"||t==="number"||t==="boolean"?n:null,validator(r){return r===n||`Expected the literal \`${e}\`, but received: ${xt(r)}`}})}function Kd(){return hn("never",()=>!1)}function ae(n){return new Pt({...n,validator:(e,t)=>e===null||n.validator(e,t),refiner:(e,t)=>e===null||n.refiner(e,t)})}function $(){return hn("number",n=>typeof n=="number"&&!isNaN(n)||`Expected a number, but received: ${xt(n)}`)}function le(n){return new Pt({...n,validator:(e,t)=>e===void 0||n.validator(e,t),refiner:(e,t)=>e===void 0||n.refiner(e,t)})}function bo(n,e){return new Pt({type:"record",schema:null,*entries(t){if(Wn(t))for(const r in t){const s=t[r];yield[r,r,n],yield[r,s,e]}},validator(t){return gr(t)||`Expected an object, but received: ${xt(t)}`},coercer(t){return gr(t)?{...t}:t}})}function re(){return hn("string",n=>typeof n=="string"||`Expected a string, but received: ${xt(n)}`)}function ci(n){const e=Kd();return new Pt({type:"tuple",schema:null,*entries(t){if(Array.isArray(t)){const r=Math.max(n.length,t.length);for(let s=0;s<r;s++)yield[s,t[s],n[s]||e]}},validator(t){return Array.isArray(t)||`Expected an array, but received: ${xt(t)}`},coercer(t){return Array.isArray(t)?t.slice():t}})}function te(n){const e=Object.keys(n);return new Pt({type:"type",schema:n,*entries(t){if(Wn(t))for(const r of e)yield[r,t[r],n[r]]},validator(t){return gr(t)||`Expected an object, but received: ${xt(t)}`},coercer(t){return gr(t)?{...t}:t}})}function St(n){const e=n.map(t=>t.type).join(" | ");return new Pt({type:"union",schema:null,coercer(t,r){for(const s of n){const[i,o]=s.validate(t,{coerce:!0,mask:r.mask});if(!i)return o}return t},validator(t,r){const s=[];for(const i of n){const[...o]=oi(t,i,r),[a]=o;if(a[0])for(const[f]of o)f&&s.push(f);else return[]}return[`Expected the value to satisfy a union of \`${e}\`, but received: ${xt(t)}`,...s]}})}function Tn(){return hn("unknown",()=>!0)}function Vn(n,e,t){return new Pt({...n,coercer:(r,s)=>wo(r,e)?n.coercer(t(r,s),s):n.coercer(r,s)})}var mr,$d=new Uint8Array(16);function Ro(){if(!mr&&(mr=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!mr))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return mr($d)}const Hd=/^(?:[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 _r(n){return typeof n=="string"&&Hd.test(n)}for(var _t=[],ui=0;ui<256;++ui)_t.push((ui+256).toString(16).substr(1));function yr(n){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,t=(_t[n[e+0]]+_t[n[e+1]]+_t[n[e+2]]+_t[n[e+3]]+"-"+_t[n[e+4]]+_t[n[e+5]]+"-"+_t[n[e+6]]+_t[n[e+7]]+"-"+_t[n[e+8]]+_t[n[e+9]]+"-"+_t[n[e+10]]+_t[n[e+11]]+_t[n[e+12]]+_t[n[e+13]]+_t[n[e+14]]+_t[n[e+15]]).toLowerCase();if(!_r(t))throw TypeError("Stringified UUID is invalid");return t}var Eo,li,hi=0,fi=0;function Wd(n,e,t){var r=e&&t||0,s=e||new Array(16);n=n||{};var i=n.node||Eo,o=n.clockseq!==void 0?n.clockseq:li;if(i==null||o==null){var a=n.random||(n.rng||Ro)();i==null&&(i=Eo=[a[0]|1,a[1],a[2],a[3],a[4],a[5]]),o==null&&(o=li=(a[6]<<8|a[7])&16383)}var f=n.msecs!==void 0?n.msecs:Date.now(),g=n.nsecs!==void 0?n.nsecs:fi+1,w=f-hi+(g-fi)/1e4;if(w<0&&n.clockseq===void 0&&(o=o+1&16383),(w<0||f>hi)&&n.nsecs===void 0&&(g=0),g>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");hi=f,fi=g,li=o,f+=122192928e5;var b=((f&268435455)*1e4+g)%4294967296;s[r++]=b>>>24&255,s[r++]=b>>>16&255,s[r++]=b>>>8&255,s[r++]=b&255;var x=f/4294967296*1e4&268435455;s[r++]=x>>>8&255,s[r++]=x&255,s[r++]=x>>>24&15|16,s[r++]=x>>>16&255,s[r++]=o>>>8|128,s[r++]=o&255;for(var T=0;T<6;++T)s[r+T]=i[T];return e||yr(s)}function So(n){if(!_r(n))throw TypeError("Invalid UUID");var e,t=new Uint8Array(16);return t[0]=(e=parseInt(n.slice(0,8),16))>>>24,t[1]=e>>>16&255,t[2]=e>>>8&255,t[3]=e&255,t[4]=(e=parseInt(n.slice(9,13),16))>>>8,t[5]=e&255,t[6]=(e=parseInt(n.slice(14,18),16))>>>8,t[7]=e&255,t[8]=(e=parseInt(n.slice(19,23),16))>>>8,t[9]=e&255,t[10]=(e=parseInt(n.slice(24,36),16))/1099511627776&255,t[11]=e/4294967296&255,t[12]=e>>>24&255,t[13]=e>>>16&255,t[14]=e>>>8&255,t[15]=e&255,t}function qd(n){n=unescape(encodeURIComponent(n));for(var e=[],t=0;t<n.length;++t)e.push(n.charCodeAt(t));return e}var Vd="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Gd="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function Ao(n,e,t){function r(s,i,o,a){if(typeof s=="string"&&(s=qd(s)),typeof i=="string"&&(i=So(i)),i.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var f=new Uint8Array(16+s.length);if(f.set(i),f.set(s,i.length),f=t(f),f[6]=f[6]&15|e,f[8]=f[8]&63|128,o){a=a||0;for(var g=0;g<16;++g)o[a+g]=f[g];return o}return yr(f)}try{r.name=n}catch{}return r.DNS=Vd,r.URL=Gd,r}function Yd(n){if(typeof n=="string"){var e=unescape(encodeURIComponent(n));n=new Uint8Array(e.length);for(var t=0;t<e.length;++t)n[t]=e.charCodeAt(t)}return jd(Zd(Xd(n),n.length*8))}function jd(n){for(var e=[],t=n.length*32,r="0123456789abcdef",s=0;s<t;s+=8){var i=n[s>>5]>>>s%32&255,o=parseInt(r.charAt(i>>>4&15)+r.charAt(i&15),16);e.push(o)}return e}function Io(n){return(n+64>>>9<<4)+14+1}function Zd(n,e){n[e>>5]|=128<<e%32,n[Io(e)-1]=e;for(var t=1732584193,r=-271733879,s=-1732584194,i=271733878,o=0;o<n.length;o+=16){var a=t,f=r,g=s,w=i;t=yt(t,r,s,i,n[o],7,-680876936),i=yt(i,t,r,s,n[o+1],12,-389564586),s=yt(s,i,t,r,n[o+2],17,606105819),r=yt(r,s,i,t,n[o+3],22,-1044525330),t=yt(t,r,s,i,n[o+4],7,-176418897),i=yt(i,t,r,s,n[o+5],12,1200080426),s=yt(s,i,t,r,n[o+6],17,-1473231341),r=yt(r,s,i,t,n[o+7],22,-45705983),t=yt(t,r,s,i,n[o+8],7,1770035416),i=yt(i,t,r,s,n[o+9],12,-1958414417),s=yt(s,i,t,r,n[o+10],17,-42063),r=yt(r,s,i,t,n[o+11],22,-1990404162),t=yt(t,r,s,i,n[o+12],7,1804603682),i=yt(i,t,r,s,n[o+13],12,-40341101),s=yt(s,i,t,r,n[o+14],17,-1502002290),r=yt(r,s,i,t,n[o+15],22,1236535329),t=wt(t,r,s,i,n[o+1],5,-165796510),i=wt(i,t,r,s,n[o+6],9,-1069501632),s=wt(s,i,t,r,n[o+11],14,643717713),r=wt(r,s,i,t,n[o],20,-373897302),t=wt(t,r,s,i,n[o+5],5,-701558691),i=wt(i,t,r,s,n[o+10],9,38016083),s=wt(s,i,t,r,n[o+15],14,-660478335),r=wt(r,s,i,t,n[o+4],20,-405537848),t=wt(t,r,s,i,n[o+9],5,568446438),i=wt(i,t,r,s,n[o+14],9,-1019803690),s=wt(s,i,t,r,n[o+3],14,-187363961),r=wt(r,s,i,t,n[o+8],20,1163531501),t=wt(t,r,s,i,n[o+13],5,-1444681467),i=wt(i,t,r,s,n[o+2],9,-51403784),s=wt(s,i,t,r,n[o+7],14,1735328473),r=wt(r,s,i,t,n[o+12],20,-1926607734),t=bt(t,r,s,i,n[o+5],4,-378558),i=bt(i,t,r,s,n[o+8],11,-2022574463),s=bt(s,i,t,r,n[o+11],16,1839030562),r=bt(r,s,i,t,n[o+14],23,-35309556),t=bt(t,r,s,i,n[o+1],4,-1530992060),i=bt(i,t,r,s,n[o+4],11,1272893353),s=bt(s,i,t,r,n[o+7],16,-155497632),r=bt(r,s,i,t,n[o+10],23,-1094730640),t=bt(t,r,s,i,n[o+13],4,681279174),i=bt(i,t,r,s,n[o],11,-358537222),s=bt(s,i,t,r,n[o+3],16,-722521979),r=bt(r,s,i,t,n[o+6],23,76029189),t=bt(t,r,s,i,n[o+9],4,-640364487),i=bt(i,t,r,s,n[o+12],11,-421815835),s=bt(s,i,t,r,n[o+15],16,530742520),r=bt(r,s,i,t,n[o+2],23,-995338651),t=Rt(t,r,s,i,n[o],6,-198630844),i=Rt(i,t,r,s,n[o+7],10,1126891415),s=Rt(s,i,t,r,n[o+14],15,-1416354905),r=Rt(r,s,i,t,n[o+5],21,-57434055),t=Rt(t,r,s,i,n[o+12],6,1700485571),i=Rt(i,t,r,s,n[o+3],10,-1894986606),s=Rt(s,i,t,r,n[o+10],15,-1051523),r=Rt(r,s,i,t,n[o+1],21,-2054922799),t=Rt(t,r,s,i,n[o+8],6,1873313359),i=Rt(i,t,r,s,n[o+15],10,-30611744),s=Rt(s,i,t,r,n[o+6],15,-1560198380),r=Rt(r,s,i,t,n[o+13],21,1309151649),t=Rt(t,r,s,i,n[o+4],6,-145523070),i=Rt(i,t,r,s,n[o+11],10,-1120210379),s=Rt(s,i,t,r,n[o+2],15,718787259),r=Rt(r,s,i,t,n[o+9],21,-343485551),t=tn(t,a),r=tn(r,f),s=tn(s,g),i=tn(i,w)}return[t,r,s,i]}function Xd(n){if(n.length===0)return[];for(var e=n.length*8,t=new Uint32Array(Io(e)),r=0;r<e;r+=8)t[r>>5]|=(n[r/8]&255)<<r%32;return t}function tn(n,e){var t=(n&65535)+(e&65535),r=(n>>16)+(e>>16)+(t>>16);return r<<16|t&65535}function Jd(n,e){return n<<e|n>>>32-e}function wr(n,e,t,r,s,i){return tn(Jd(tn(tn(e,n),tn(r,i)),s),t)}function yt(n,e,t,r,s,i,o){return wr(e&t|~e&r,n,e,s,i,o)}function wt(n,e,t,r,s,i,o){return wr(e&r|t&~r,n,e,s,i,o)}function bt(n,e,t,r,s,i,o){return wr(e^t^r,n,e,s,i,o)}function Rt(n,e,t,r,s,i,o){return wr(t^(e|~r),n,e,s,i,o)}var Qd=Ao("v3",48,Yd);function e0(n,e,t){n=n||{};var r=n.random||(n.rng||Ro)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,e){t=t||0;for(var s=0;s<16;++s)e[t+s]=r[s];return e}return yr(r)}function t0(n,e,t,r){switch(n){case 0:return e&t^~e&r;case 1:return e^t^r;case 2:return e&t^e&r^t&r;case 3:return e^t^r}}function di(n,e){return n<<e|n>>>32-e}function n0(n){var e=[1518500249,1859775393,2400959708,3395469782],t=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof n=="string"){var r=unescape(encodeURIComponent(n));n=[];for(var s=0;s<r.length;++s)n.push(r.charCodeAt(s))}else Array.isArray(n)||(n=Array.prototype.slice.call(n));n.push(128);for(var i=n.length/4+2,o=Math.ceil(i/16),a=new Array(o),f=0;f<o;++f){for(var g=new Uint32Array(16),w=0;w<16;++w)g[w]=n[f*64+w*4]<<24|n[f*64+w*4+1]<<16|n[f*64+w*4+2]<<8|n[f*64+w*4+3];a[f]=g}a[o-1][14]=(n.length-1)*8/Math.pow(2,32),a[o-1][14]=Math.floor(a[o-1][14]),a[o-1][15]=(n.length-1)*8&4294967295;for(var b=0;b<o;++b){for(var x=new Uint32Array(80),T=0;T<16;++T)x[T]=a[b][T];for(var L=16;L<80;++L)x[L]=di(x[L-3]^x[L-8]^x[L-14]^x[L-16],1);for(var O=t[0],N=t[1],M=t[2],H=t[3],K=t[4],Q=0;Q<80;++Q){var q=Math.floor(Q/20),D=di(O,5)+t0(q,N,M,H)+K+e[q]+x[Q]>>>0;K=H,H=M,M=di(N,30)>>>0,N=O,O=D}t[0]=t[0]+O>>>0,t[1]=t[1]+N>>>0,t[2]=t[2]+M>>>0,t[3]=t[3]+H>>>0,t[4]=t[4]+K>>>0}return[t[0]>>24&255,t[0]>>16&255,t[0]>>8&255,t[0]&255,t[1]>>24&255,t[1]>>16&255,t[1]>>8&255,t[1]&255,t[2]>>24&255,t[2]>>16&255,t[2]>>8&255,t[2]&255,t[3]>>24&255,t[3]>>16&255,t[3]>>8&255,t[3]&255,t[4]>>24&255,t[4]>>16&255,t[4]>>8&255,t[4]&255]}var r0=Ao("v5",80,n0);const i0="00000000-0000-0000-0000-000000000000";function s0(n){if(!_r(n))throw TypeError("Invalid UUID");return parseInt(n.substr(14,1),16)}const vo=Dr(Object.freeze(Object.defineProperty({__proto__:null,NIL:i0,parse:So,stringify:yr,v1:Wd,v3:Qd,v4:e0,v5:r0,validate:_r,version:s0},Symbol.toStringTag,{value:"Module"})));var pi,Oo;function o0(){if(Oo)return pi;Oo=1;const n=vo.v4;return pi=function(t,r,s,i){if(typeof t!="string")throw new TypeError(t+" must be a string");i=i||{};const o=typeof i.version=="number"?i.version:2;if(o!==1&&o!==2)throw new TypeError(o+" must be 1 or 2");const a={method:t};if(o===2&&(a.jsonrpc="2.0"),r){if(typeof r!="object"&&!Array.isArray(r))throw new TypeError(r+" must be an object, array or omitted");a.params=r}if(typeof s>"u"){const f=typeof i.generator=="function"?i.generator:function(){return n()};a.id=f(a,i)}else o===2&&s===null?i.notificationIdNull&&(a.id=null):a.id=s;return a},pi}var gi,ko;function a0(){if(ko)return gi;ko=1;const n=vo.v4,e=o0(),t=function(r,s){if(!(this instanceof t))return new t(r,s);s||(s={}),this.options={reviver:typeof s.reviver<"u"?s.reviver:null,replacer:typeof s.replacer<"u"?s.replacer:null,generator:typeof s.generator<"u"?s.generator:function(){return n()},version:typeof s.version<"u"?s.version:2,notificationIdNull:typeof s.notificationIdNull=="boolean"?s.notificationIdNull:!1},this.callServer=r};return gi=t,t.prototype.request=function(r,s,i,o){const a=this;let f=null;const g=Array.isArray(r)&&typeof s=="function";if(this.options.version===1&&g)throw new TypeError("JSON-RPC 1.0 does not support batching");if(g||!g&&r&&typeof r=="object"&&typeof s=="function")o=s,f=r;else{typeof i=="function"&&(o=i,i=void 0);const x=typeof o=="function";try{f=e(r,s,i,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(T){if(x)return o(T);throw T}if(!x)return f}let b;try{b=JSON.stringify(f,this.options.replacer)}catch(x){return o(x)}return this.callServer(b,function(x,T){a._parseResponse(x,T,o)}),f},t.prototype._parseResponse=function(r,s,i){if(r){i(r);return}if(!s)return i();let o;try{o=JSON.parse(s,this.options.reviver)}catch(a){return i(a)}if(i.length===3)if(Array.isArray(o)){const a=function(g){return typeof g.error<"u"},f=function(g){return!a(g)};return i(null,o.filter(a),o.filter(f))}else return i(null,o.error,o.result);i(null,o)},gi}var c0=a0();const u0=Fn(c0);var mi={exports:{}},To;function l0(){return To||(To=1,function(n){var e=Object.prototype.hasOwnProperty,t="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(t=!1));function s(f,g,w){this.fn=f,this.context=g,this.once=w||!1}function i(f,g,w,b,x){if(typeof w!="function")throw new TypeError("The listener must be a function");var T=new s(w,b||f,x),L=t?t+g:g;return f._events[L]?f._events[L].fn?f._events[L]=[f._events[L],T]:f._events[L].push(T):(f._events[L]=T,f._eventsCount++),f}function o(f,g){--f._eventsCount===0?f._events=new r:delete f._events[g]}function a(){this._events=new r,this._eventsCount=0}a.prototype.eventNames=function(){var g=[],w,b;if(this._eventsCount===0)return g;for(b in w=this._events)e.call(w,b)&&g.push(t?b.slice(1):b);return Object.getOwnPropertySymbols?g.concat(Object.getOwnPropertySymbols(w)):g},a.prototype.listeners=function(g){var w=t?t+g:g,b=this._events[w];if(!b)return[];if(b.fn)return[b.fn];for(var x=0,T=b.length,L=new Array(T);x<T;x++)L[x]=b[x].fn;return L},a.prototype.listenerCount=function(g){var w=t?t+g:g,b=this._events[w];return b?b.fn?1:b.length:0},a.prototype.emit=function(g,w,b,x,T,L){var O=t?t+g:g;if(!this._events[O])return!1;var N=this._events[O],M=arguments.length,H,K;if(N.fn){switch(N.once&&this.removeListener(g,N.fn,void 0,!0),M){case 1:return N.fn.call(N.context),!0;case 2:return N.fn.call(N.context,w),!0;case 3:return N.fn.call(N.context,w,b),!0;case 4:return N.fn.call(N.context,w,b,x),!0;case 5:return N.fn.call(N.context,w,b,x,T),!0;case 6:return N.fn.call(N.context,w,b,x,T,L),!0}for(K=1,H=new Array(M-1);K<M;K++)H[K-1]=arguments[K];N.fn.apply(N.context,H)}else{var Q=N.length,q;for(K=0;K<Q;K++)switch(N[K].once&&this.removeListener(g,N[K].fn,void 0,!0),M){case 1:N[K].fn.call(N[K].context);break;case 2:N[K].fn.call(N[K].context,w);break;case 3:N[K].fn.call(N[K].context,w,b);break;case 4:N[K].fn.call(N[K].context,w,b,x);break;default:if(!H)for(q=1,H=new Array(M-1);q<M;q++)H[q-1]=arguments[q];N[K].fn.apply(N[K].context,H)}}return!0},a.prototype.on=function(g,w,b){return i(this,g,w,b,!1)},a.prototype.once=function(g,w,b){return i(this,g,w,b,!0)},a.prototype.removeListener=function(g,w,b,x){var T=t?t+g:g;if(!this._events[T])return this;if(!w)return o(this,T),this;var L=this._events[T];if(L.fn)L.fn===w&&(!x||L.once)&&(!b||L.context===b)&&o(this,T);else{for(var O=0,N=[],M=L.length;O<M;O++)(L[O].fn!==w||x&&!L[O].once||b&&L[O].context!==b)&&N.push(L[O]);N.length?this._events[T]=N.length===1?N[0]:N:o(this,T)}return this},a.prototype.removeAllListeners=function(g){var w;return g?(w=t?t+g:g,this._events[w]&&o(this,w)):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=t,a.EventEmitter=a,n.exports=a}(mi)),mi.exports}var h0=l0();const No=Fn(h0);var f0=class extends No{socket;constructor(n,e,t){super(),this.socket=new window.WebSocket(n,t),this.socket.onopen=()=>this.emit("open"),this.socket.onmessage=r=>this.emit("message",r.data),this.socket.onerror=r=>this.emit("error",r),this.socket.onclose=r=>{this.emit("close",r.code,r.reason)}}send(n,e,t){const r=t||e;try{this.socket.send(n),r()}catch(s){r(s)}}close(n,e){this.socket.close(n,e)}addEventListener(n,e,t){this.socket.addEventListener(n,e,t)}};function d0(n,e){return new f0(n,e)}var p0=class{encode(n){return JSON.stringify(n)}decode(n){return JSON.parse(n)}},g0=class extends No{address;rpc_id;queue;options;autoconnect;ready;reconnect;reconnect_timer_id;reconnect_interval;max_reconnects;rest_options;current_reconnects;generate_request_id;socket;webSocketFactory;dataPack;constructor(n,e="ws://localhost:8080",{autoconnect:t=!0,reconnect:r=!0,reconnect_interval:s=1e3,max_reconnects:i=5,...o}={},a,f){super(),this.webSocketFactory=n,this.queue={},this.rpc_id=0,this.address=e,this.autoconnect=t,this.ready=!1,this.reconnect=r,this.reconnect_timer_id=void 0,this.reconnect_interval=s,this.max_reconnects=i,this.rest_options=o,this.current_reconnects=0,this.generate_request_id=a||(()=>++this.rpc_id),f?this.dataPack=f:this.dataPack=new p0,this.autoconnect&&this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}connect(){this.socket||this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}call(n,e,t,r){return!r&&typeof t=="object"&&(r=t,t=null),new Promise((s,i)=>{if(!this.ready)return i(new Error("socket not ready"));const o=this.generate_request_id(n,e),a={jsonrpc:"2.0",method:n,params:e||void 0,id:o};this.socket.send(this.dataPack.encode(a),r,f=>{if(f)return i(f);this.queue[o]={promise:[s,i]},t&&(this.queue[o].timeout=setTimeout(()=>{delete this.queue[o],i(new Error("reply timeout"))},t))})})}async login(n){const e=await this.call("rpc.login",n);if(!e)throw new Error("authentication failed");return e}async listMethods(){return await this.call("__listMethods")}notify(n,e){return new Promise((t,r)=>{if(!this.ready)return r(new Error("socket not ready"));const s={jsonrpc:"2.0",method:n,params:e};this.socket.send(this.dataPack.encode(s),i=>{if(i)return r(i);t()})})}async subscribe(n){typeof n=="string"&&(n=[n]);const e=await this.call("rpc.on",n);if(typeof n=="string"&&e[n]!=="ok")throw new Error("Failed subscribing to an event '"+n+"' with: "+e[n]);return e}async unsubscribe(n){typeof n=="string"&&(n=[n]);const e=await this.call("rpc.off",n);if(typeof n=="string"&&e[n]!=="ok")throw new Error("Failed unsubscribing from an event with: "+e);return e}close(n,e){this.socket.close(n||1e3,e)}setAutoReconnect(n){this.reconnect=n}setReconnectInterval(n){this.reconnect_interval=n}setMaxReconnects(n){this.max_reconnects=n}_connect(n,e){clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(n,e),this.socket.addEventListener("open",()=>{this.ready=!0,this.emit("open"),this.current_reconnects=0}),this.socket.addEventListener("message",({data:t})=>{t instanceof ArrayBuffer&&(t=he.Buffer.from(t).toString());try{t=this.dataPack.decode(t)}catch{return}if(t.notification&&this.listeners(t.notification).length){if(!Object.keys(t.params).length)return this.emit(t.notification);const r=[t.notification];if(t.params.constructor===Object)r.push(t.params);else for(let s=0;s<t.params.length;s++)r.push(t.params[s]);return Promise.resolve().then(()=>{this.emit.apply(this,r)})}if(!this.queue[t.id])return t.method?Promise.resolve().then(()=>{this.emit(t.method,t?.params)}):void 0;"error"in t=="result"in t&&this.queue[t.id].promise[1](new Error('Server response malformed. Response must include either "result" or "error", but not both.')),this.queue[t.id].timeout&&clearTimeout(this.queue[t.id].timeout),t.error?this.queue[t.id].promise[1](t.error):this.queue[t.id].promise[0](t.result),delete this.queue[t.id]}),this.socket.addEventListener("error",t=>this.emit("error",t)),this.socket.addEventListener("close",({code:t,reason:r})=>{this.ready&&setTimeout(()=>this.emit("close",t,r),0),this.ready=!1,this.socket=void 0,t!==1e3&&(this.current_reconnects++,this.reconnect&&(this.max_reconnects>this.current_reconnects||this.max_reconnects===0)&&(this.reconnect_timer_id=setTimeout(()=>this._connect(n,e),this.reconnect_interval)))})}};const xo=[],Bo=[],Lo=[],m0=BigInt(0),Gn=BigInt(1),_0=BigInt(2),y0=BigInt(7),w0=BigInt(256),b0=BigInt(113);for(let n=0,e=Gn,t=1,r=0;n<24;n++){[t,r]=[r,(2*t+3*r)%5],xo.push(2*(5*r+t)),Bo.push((n+1)*(n+2)/2%64);let s=m0;for(let i=0;i<7;i++)e=(e<<Gn^(e>>y0)*b0)%w0,e&_0&&(s^=Gn<<(Gn<<BigInt(i))-Gn);Lo.push(s)}const[R0,E0]=Ls(Lo,!0),Co=(n,e,t)=>t>32?Ps(n,e,t):Cs(n,e,t),Mo=(n,e,t)=>t>32?Us(n,e,t):Ms(n,e,t);function S0(n,e=24){const t=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let o=0;o<10;o++)t[o]=n[o]^n[o+10]^n[o+20]^n[o+30]^n[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,f=(o+2)%10,g=t[f],w=t[f+1],b=Co(g,w,1)^t[a],x=Mo(g,w,1)^t[a+1];for(let T=0;T<50;T+=10)n[o+T]^=b,n[o+T+1]^=x}let s=n[2],i=n[3];for(let o=0;o<24;o++){const a=Bo[o],f=Co(s,i,a),g=Mo(s,i,a),w=xo[o];s=n[w],i=n[w+1],n[w]=f,n[w+1]=g}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=n[o+a];for(let a=0;a<10;a++)n[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}n[0]^=R0[r],n[1]^=E0[r]}t.fill(0)}class _i extends Hr{constructor(e,t,r,s=!1,i=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=s,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,rr(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=Qa(this.state)}keccak(){ks||Ts(this.state32),S0(this.state32,this.rounds),ks||Ts(this.state32),this.posOut=0,this.pos=0}update(e){bn(this);const{blockLen:t,state:r}=this;e=ir(e);const s=e.length;for(let i=0;i<s;){const o=Math.min(t-this.pos,s-i);for(let a=0;a<o;a++)r[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:r,blockLen:s}=this;e[r]^=t,(t&128)!==0&&r===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){bn(this,!1),Kn(e),this.finish();const t=this.state,{blockLen:r}=this;for(let s=0,i=e.length;s<i;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,i-s);e.set(t.subarray(this.posOut,this.posOut+o),s),this.posOut+=o,s+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return rr(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Os(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:r,outputLen:s,rounds:i,enableXOF:o}=this;return e||(e=new _i(t,r,s,o,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=r,e.outputLen=s,e.enableXOF=o,e.destroyed=this.destroyed,e}}const Po=((n,e,t)=>Wr(()=>new _i(e,n,t)))(1,136,256/8);class Uo extends Hr{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,Ja(e);const r=ir(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,i=new Uint8Array(s);i.set(r.length>s?e.create().update(r).digest():r);for(let o=0;o<i.length;o++)i[o]^=54;this.iHash.update(i),this.oHash=e.create();for(let o=0;o<i.length;o++)i[o]^=106;this.oHash.update(i),i.fill(0)}update(e){return bn(this),this.iHash.update(e),this}digestInto(e){bn(this),Kn(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:r,finished:s,destroyed:i,blockLen:o,outputLen:a}=this;return e=e,e.finished=s,e.destroyed=i,e.blockLen=o,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Do=(n,e,t)=>new Uo(n,e).update(t).digest();Do.create=(n,e)=>new Uo(n,e);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function A0(n){const e=Jr(n);An(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:t,Fp:r,a:s}=e;if(t){if(!r.eql(s,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:I0,hexToBytes:v0}=Tc,fn={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(n){const{Err:e}=fn;if(n.length<2||n[0]!==2)throw new e("Invalid signature integer tag");const t=n[1],r=n.subarray(2,t+2);if(!t||r.length!==t)throw new e("Invalid signature integer: wrong length");if(r[0]&128)throw new e("Invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:I0(r),l:n.subarray(t+2)}},toSig(n){const{Err:e}=fn,t=typeof n=="string"?v0(n):n;$n(t);let r=t.length;if(r<2||t[0]!=48)throw new e("Invalid signature tag");if(t[1]!==r-2)throw new e("Invalid signature: incorrect length");const{d:s,l:i}=fn._parseInt(t.subarray(2)),{d:o,l:a}=fn._parseInt(i);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:s,s:o}},hexFromSig(n){const e=g=>Number.parseInt(g[0],16)&8?"00"+g:g,t=g=>{const w=g.toString(16);return w.length&1?`0${w}`:w},r=e(t(n.s)),s=e(t(n.r)),i=r.length/2,o=s.length/2,a=t(i),f=t(o);return`30${t(o+i+4)}02${f}${s}02${a}${r}`}},Yt=BigInt(0),Tt=BigInt(1);BigInt(2);const Fo=BigInt(3);BigInt(4);function O0(n){const e=A0(n),{Fp:t}=e,r=e.toBytes||((L,O,N)=>{const M=O.toAffine();return un(Uint8Array.from([4]),t.toBytes(M.x),t.toBytes(M.y))}),s=e.fromBytes||(L=>{const O=L.subarray(1),N=t.fromBytes(O.subarray(0,t.BYTES)),M=t.fromBytes(O.subarray(t.BYTES,2*t.BYTES));return{x:N,y:M}});function i(L){const{a:O,b:N}=e,M=t.sqr(L),H=t.mul(M,L);return t.add(t.add(H,t.mul(L,O)),N)}if(!t.eql(t.sqr(e.Gy),i(e.Gx)))throw new Error("bad generator point: equation left != right");function o(L){return typeof L=="bigint"&&Yt<L&&L<e.n}function a(L){if(!o(L))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function f(L){const{allowedPrivateKeyLengths:O,nByteLength:N,wrapPrivateKey:M,n:H}=e;if(O&&typeof L!="bigint"){if(on(L)&&(L=an(L)),typeof L!="string"||!O.includes(L.length))throw new Error("Invalid key");L=L.padStart(N*2,"0")}let K;try{K=typeof L=="bigint"?L:cn(ft("private key",L,N))}catch{throw new Error(`private key must be ${N} bytes, hex or bigint, not ${typeof L}`)}return M&&(K=$e(K,H)),a(K),K}const g=new Map;function w(L){if(!(L instanceof b))throw new Error("ProjectivePoint expected")}class b{constructor(O,N,M){if(this.px=O,this.py=N,this.pz=M,O==null||!t.isValid(O))throw new Error("x required");if(N==null||!t.isValid(N))throw new Error("y required");if(M==null||!t.isValid(M))throw new Error("z required")}static fromAffine(O){const{x:N,y:M}=O||{};if(!O||!t.isValid(N)||!t.isValid(M))throw new Error("invalid affine point");if(O instanceof b)throw new Error("projective point not allowed");const H=K=>t.eql(K,t.ZERO);return H(N)&&H(M)?b.ZERO:new b(N,M,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(O){const N=t.invertBatch(O.map(M=>M.pz));return O.map((M,H)=>M.toAffine(N[H])).map(b.fromAffine)}static fromHex(O){const N=b.fromAffine(s(ft("pointHex",O)));return N.assertValidity(),N}static fromPrivateKey(O){return b.BASE.multiply(f(O))}_setWindowSize(O){this._WINDOW_SIZE=O,g.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!t.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:O,y:N}=this.toAffine();if(!t.isValid(O)||!t.isValid(N))throw new Error("bad point: x or y not FE");const M=t.sqr(N),H=i(O);if(!t.eql(M,H))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:O}=this.toAffine();if(t.isOdd)return!t.isOdd(O);throw new Error("Field doesn't support isOdd")}equals(O){w(O);const{px:N,py:M,pz:H}=this,{px:K,py:Q,pz:q}=O,D=t.eql(t.mul(N,q),t.mul(K,H)),X=t.eql(t.mul(M,q),t.mul(Q,H));return D&&X}negate(){return new b(this.px,t.neg(this.py),this.pz)}double(){const{a:O,b:N}=e,M=t.mul(N,Fo),{px:H,py:K,pz:Q}=this;let q=t.ZERO,D=t.ZERO,X=t.ZERO,Z=t.mul(H,H),J=t.mul(K,K),z=t.mul(Q,Q),V=t.mul(H,K);return V=t.add(V,V),X=t.mul(H,Q),X=t.add(X,X),q=t.mul(O,X),D=t.mul(M,z),D=t.add(q,D),q=t.sub(J,D),D=t.add(J,D),D=t.mul(q,D),q=t.mul(V,q),X=t.mul(M,X),z=t.mul(O,z),V=t.sub(Z,z),V=t.mul(O,V),V=t.add(V,X),X=t.add(Z,Z),Z=t.add(X,Z),Z=t.add(Z,z),Z=t.mul(Z,V),D=t.add(D,Z),z=t.mul(K,Q),z=t.add(z,z),Z=t.mul(z,V),q=t.sub(q,Z),X=t.mul(z,J),X=t.add(X,X),X=t.add(X,X),new b(q,D,X)}add(O){w(O);const{px:N,py:M,pz:H}=this,{px:K,py:Q,pz:q}=O;let D=t.ZERO,X=t.ZERO,Z=t.ZERO;const J=e.a,z=t.mul(e.b,Fo);let V=t.mul(N,K),ee=t.mul(M,Q),S=t.mul(H,q),c=t.add(N,M),p=t.add(K,Q);c=t.mul(c,p),p=t.add(V,ee),c=t.sub(c,p),p=t.add(N,H);let m=t.add(K,q);return p=t.mul(p,m),m=t.add(V,S),p=t.sub(p,m),m=t.add(M,H),D=t.add(Q,q),m=t.mul(m,D),D=t.add(ee,S),m=t.sub(m,D),Z=t.mul(J,p),D=t.mul(z,S),Z=t.add(D,Z),D=t.sub(ee,Z),Z=t.add(ee,Z),X=t.mul(D,Z),ee=t.add(V,V),ee=t.add(ee,V),S=t.mul(J,S),p=t.mul(z,p),ee=t.add(ee,S),S=t.sub(V,S),S=t.mul(J,S),p=t.add(p,S),V=t.mul(ee,p),X=t.add(X,V),V=t.mul(m,p),D=t.mul(c,D),D=t.sub(D,V),V=t.mul(c,ee),Z=t.mul(m,Z),Z=t.add(Z,V),new b(D,X,Z)}subtract(O){return this.add(O.negate())}is0(){return this.equals(b.ZERO)}wNAF(O){return T.wNAFCached(this,g,O,N=>{const M=t.invertBatch(N.map(H=>H.pz));return N.map((H,K)=>H.toAffine(M[K])).map(b.fromAffine)})}multiplyUnsafe(O){const N=b.ZERO;if(O===Yt)return N;if(a(O),O===Tt)return this;const{endo:M}=e;if(!M)return T.unsafeLadder(this,O);let{k1neg:H,k1:K,k2neg:Q,k2:q}=M.splitScalar(O),D=N,X=N,Z=this;for(;K>Yt||q>Yt;)K&Tt&&(D=D.add(Z)),q&Tt&&(X=X.add(Z)),Z=Z.double(),K>>=Tt,q>>=Tt;return H&&(D=D.negate()),Q&&(X=X.negate()),X=new b(t.mul(X.px,M.beta),X.py,X.pz),D.add(X)}multiply(O){a(O);let N=O,M,H;const{endo:K}=e;if(K){const{k1neg:Q,k1:q,k2neg:D,k2:X}=K.splitScalar(N);let{p:Z,f:J}=this.wNAF(q),{p:z,f:V}=this.wNAF(X);Z=T.constTimeNegate(Q,Z),z=T.constTimeNegate(D,z),z=new b(t.mul(z.px,K.beta),z.py,z.pz),M=Z.add(z),H=J.add(V)}else{const{p:Q,f:q}=this.wNAF(N);M=Q,H=q}return b.normalizeZ([M,H])[0]}multiplyAndAddUnsafe(O,N,M){const H=b.BASE,K=(q,D)=>D===Yt||D===Tt||!q.equals(H)?q.multiplyUnsafe(D):q.multiply(D),Q=K(this,N).add(K(O,M));return Q.is0()?void 0:Q}toAffine(O){const{px:N,py:M,pz:H}=this,K=this.is0();O==null&&(O=K?t.ONE:t.inv(H));const Q=t.mul(N,O),q=t.mul(M,O),D=t.mul(H,O);if(K)return{x:t.ZERO,y:t.ZERO};if(!t.eql(D,t.ONE))throw new Error("invZ was invalid");return{x:Q,y:q}}isTorsionFree(){const{h:O,isTorsionFree:N}=e;if(O===Tt)return!0;if(N)return N(b,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:O,clearCofactor:N}=e;return O===Tt?this:N?N(b,this):this.multiplyUnsafe(e.h)}toRawBytes(O=!0){return this.assertValidity(),r(b,this,O)}toHex(O=!0){return an(this.toRawBytes(O))}}b.BASE=new b(e.Gx,e.Gy,t.ONE),b.ZERO=new b(t.ZERO,t.ONE,t.ZERO);const x=e.nBitLength,T=js(b,e.endo?Math.ceil(x/2):x);return{CURVE:e,ProjectivePoint:b,normPrivateKeyToScalar:f,weierstrassEquation:i,isWithinCurveOrder:o}}function k0(n){const e=Jr(n);return An(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function T0(n){const e=k0(n),{Fp:t,n:r}=e,s=t.BYTES+1,i=2*t.BYTES+1;function o(p){return Yt<p&&p<t.ORDER}function a(p){return $e(p,r)}function f(p){return Zr(p,r)}const{ProjectivePoint:g,normPrivateKeyToScalar:w,weierstrassEquation:b,isWithinCurveOrder:x}=O0({...e,toBytes(p,m,I){const E=m.toAffine(),A=t.toBytes(E.x),C=un;return I?C(Uint8Array.from([m.hasEvenY()?2:3]),A):C(Uint8Array.from([4]),A,t.toBytes(E.y))},fromBytes(p){const m=p.length,I=p[0],E=p.subarray(1);if(m===s&&(I===2||I===3)){const A=cn(E);if(!o(A))throw new Error("Point is not on curve");const C=b(A);let R;try{R=t.sqrt(C)}catch(y){const k=y instanceof Error?": "+y.message:"";throw new Error("Point is not on curve"+k)}const u=(R&Tt)===Tt;return(I&1)===1!==u&&(R=t.neg(R)),{x:A,y:R}}else if(m===i&&I===4){const A=t.fromBytes(E.subarray(0,t.BYTES)),C=t.fromBytes(E.subarray(t.BYTES,2*t.BYTES));return{x:A,y:C}}else throw new Error(`Point of length ${m} was invalid. Expected ${s} compressed bytes or ${i} uncompressed bytes`)}}),T=p=>an(Sn(p,e.nByteLength));function L(p){const m=r>>Tt;return p>m}function O(p){return L(p)?a(-p):p}const N=(p,m,I)=>cn(p.slice(m,I));class M{constructor(m,I,E){this.r=m,this.s=I,this.recovery=E,this.assertValidity()}static fromCompact(m){const I=e.nByteLength;return m=ft("compactSignature",m,I*2),new M(N(m,0,I),N(m,I,2*I))}static fromDER(m){const{r:I,s:E}=fn.toSig(ft("DER",m));return new M(I,E)}assertValidity(){if(!x(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!x(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(m){return new M(this.r,this.s,m)}recoverPublicKey(m){const{r:I,s:E,recovery:A}=this,C=X(ft("msgHash",m));if(A==null||![0,1,2,3].includes(A))throw new Error("recovery id invalid");const R=A===2||A===3?I+e.n:I;if(R>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");const u=(A&1)===0?"02":"03",l=g.fromHex(u+T(R)),y=f(R),k=a(-C*y),P=a(E*y),G=g.BASE.multiplyAndAddUnsafe(l,k,P);if(!G)throw new Error("point at infinify");return G.assertValidity(),G}hasHighS(){return L(this.s)}normalizeS(){return this.hasHighS()?new M(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return Rn(this.toDERHex())}toDERHex(){return fn.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Rn(this.toCompactHex())}toCompactHex(){return T(this.r)+T(this.s)}}const H={isValidPrivateKey(p){try{return w(p),!0}catch{return!1}},normPrivateKeyToScalar:w,randomPrivateKey:()=>{const p=Ys(e.n);return Fc(e.randomBytes(p),e.n)},precompute(p=8,m=g.BASE){return m._setWindowSize(p),m.multiply(BigInt(3)),m}};function K(p,m=!0){return g.fromPrivateKey(p).toRawBytes(m)}function Q(p){const m=on(p),I=typeof p=="string",E=(m||I)&&p.length;return m?E===s||E===i:I?E===2*s||E===2*i:p instanceof g}function q(p,m,I=!0){if(Q(p))throw new Error("first arg must be private key");if(!Q(m))throw new Error("second arg must be public key");return g.fromHex(m).multiply(w(p)).toRawBytes(I)}const D=e.bits2int||function(p){const m=cn(p),I=p.length*8-e.nBitLength;return I>0?m>>BigInt(I):m},X=e.bits2int_modN||function(p){return a(D(p))},Z=Gr(e.nBitLength);function J(p){if(typeof p!="bigint")throw new Error("bigint expected");if(!(Yt<=p&&p<Z))throw new Error(`bigint expected < 2^${e.nBitLength}`);return Sn(p,e.nByteLength)}function z(p,m,I=V){if(["recovered","canonical"].some(ce=>ce in I))throw new Error("sign() legacy options not supported");const{hash:E,randomBytes:A}=e;let{lowS:C,prehash:R,extraEntropy:u}=I;C==null&&(C=!0),p=ft("msgHash",p),R&&(p=ft("prehashed msgHash",E(p)));const l=X(p),y=w(m),k=[J(y),J(l)];if(u!=null&&u!==!1){const ce=u===!0?A(t.BYTES):u;k.push(ft("extraEntropy",ce))}const P=un(...k),G=l;function j(ce){const ve=D(ce);if(!x(ve))return;const ge=f(ve),me=g.BASE.multiply(ve).toAffine(),Ue=a(me.x);if(Ue===Yt)return;const Se=a(ge*a(G+Ue*y));if(Se===Yt)return;let Te=(me.x===Ue?0:2)|Number(me.y&Tt),Wt=Se;return C&&L(Se)&&(Wt=O(Se),Te^=1),new M(Ue,Wt,Te)}return{seed:P,k2sig:j}}const V={lowS:e.lowS,prehash:!1},ee={lowS:e.lowS,prehash:!1};function S(p,m,I=V){const{seed:E,k2sig:A}=z(p,m,I),C=e;return $s(C.hash.outputLen,C.nByteLength,C.hmac)(E,A)}g.BASE._setWindowSize(8);function c(p,m,I,E=ee){const A=p;if(m=ft("msgHash",m),I=ft("publicKey",I),"strict"in E)throw new Error("options.strict was renamed to lowS");const{lowS:C,prehash:R}=E;let u,l;try{if(typeof A=="string"||on(A))try{u=M.fromDER(A)}catch(me){if(!(me instanceof fn.Err))throw me;u=M.fromCompact(A)}else if(typeof A=="object"&&typeof A.r=="bigint"&&typeof A.s=="bigint"){const{r:me,s:Ue}=A;u=new M(me,Ue)}else throw new Error("PARSE");l=g.fromHex(I)}catch(me){if(me.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(C&&u.hasHighS())return!1;R&&(m=e.hash(m));const{r:y,s:k}=u,P=X(m),G=f(k),j=a(P*G),ce=a(y*G),ve=g.BASE.multiplyAndAddUnsafe(l,j,ce)?.toAffine();return ve?a(ve.x)===y:!1}return{CURVE:e,getPublicKey:K,getSharedSecret:q,sign:S,verify:c,ProjectivePoint:g,Signature:M,utils:H}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function N0(n){return{hash:n,hmac:(e,...t)=>Do(n,e,nc(...t)),randomBytes:Ns}}function x0(n,e){const t=r=>T0({...n,...N0(r)});return Object.freeze({...t(e),create:t})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const zo=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ko=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),B0=BigInt(1),yi=BigInt(2),$o=(n,e)=>(n+e/yi)/e;function L0(n){const e=zo,t=BigInt(3),r=BigInt(6),s=BigInt(11),i=BigInt(22),o=BigInt(23),a=BigInt(44),f=BigInt(88),g=n*n*n%e,w=g*g*n%e,b=Ge(w,t,e)*w%e,x=Ge(b,t,e)*w%e,T=Ge(x,yi,e)*g%e,L=Ge(T,s,e)*T%e,O=Ge(L,i,e)*L%e,N=Ge(O,a,e)*O%e,M=Ge(N,f,e)*N%e,H=Ge(M,a,e)*O%e,K=Ge(H,t,e)*w%e,Q=Ge(K,o,e)*L%e,q=Ge(Q,r,e)*g%e,D=Ge(q,yi,e);if(!wi.eql(wi.sqr(D),n))throw new Error("Cannot find square root");return D}const wi=Vs(zo,void 0,void 0,{sqrt:L0}),br=x0({a:BigInt(0),b:BigInt(7),Fp:wi,n:Ko,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:n=>{const e=Ko,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-B0*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=t,o=BigInt("0x100000000000000000000000000000000"),a=$o(i*n,e),f=$o(-r*n,e);let g=$e(n-a*t-f*s,e),w=$e(-a*r-f*i,e);const b=g>o,x=w>o;if(b&&(g=e-g),x&&(w=e-w),g>o||w>o)throw new Error("splitScalar: Endomorphism failed, k="+n);return{k1neg:b,k1:g,k2neg:x,k2:w}}}},ni);BigInt(0),br.ProjectivePoint;const C0=In.utils.randomPrivateKey,Ho=()=>{const n=In.utils.randomPrivateKey(),e=Rr(n),t=new Uint8Array(64);return t.set(n),t.set(e,32),{publicKey:e,secretKey:t}},Rr=In.getPublicKey;function Wo(n){try{return In.ExtendedPoint.fromHex(n),!0}catch{return!1}}const bi=(n,e)=>In.sign(n,e.slice(0,32)),M0=In.verify,we=n=>he.Buffer.isBuffer(n)?n:n instanceof Uint8Array?he.Buffer.from(n.buffer,n.byteOffset,n.byteLength):he.Buffer.from(n);class Ri{constructor(e){Object.assign(this,e)}encode(){return he.Buffer.from(si.serialize(Yn,this))}static decode(e){return si.deserialize(Yn,this,e)}static decodeUnchecked(e){return si.deserializeUnchecked(Yn,this,e)}}class P0 extends Ri{constructor(e){if(super(e),this.enum="",Object.keys(e).length!==1)throw new Error("Enum can only take single value");Object.keys(e).map(t=>{this.enum=t})}}const Yn=new Map;var qo;const Vo=32,Dt=32;function U0(n){return n._bn!==void 0}let Go=1;class ie extends Ri{constructor(e){if(super({}),this._bn=void 0,U0(e))this._bn=e._bn;else{if(typeof e=="string"){const t=pt.decode(e);if(t.length!=Dt)throw new Error("Invalid public key input");this._bn=new eo(t)}else this._bn=new eo(e);if(this._bn.byteLength()>Dt)throw new Error("Invalid public key input")}}static unique(){const e=new ie(Go);return Go+=1,new ie(e.toBuffer())}equals(e){return this._bn.eq(e._bn)}toBase58(){return pt.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){const e=this.toBuffer();return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}toBuffer(){const e=this._bn.toArrayLike(he.Buffer);if(e.length===Dt)return e;const t=he.Buffer.alloc(32);return e.copy(t,32-e.length),t}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(e,t,r){const s=he.Buffer.concat([e.toBuffer(),he.Buffer.from(t),r.toBuffer()]),i=ni(s);return new ie(i)}static createProgramAddressSync(e,t){let r=he.Buffer.alloc(0);e.forEach(function(i){if(i.length>Vo)throw new TypeError("Max seed length exceeded");r=he.Buffer.concat([r,we(i)])}),r=he.Buffer.concat([r,t.toBuffer(),he.Buffer.from("ProgramDerivedAddress")]);const s=ni(r);if(Wo(s))throw new Error("Invalid seeds, address must fall off the curve");return new ie(s)}static async createProgramAddress(e,t){return this.createProgramAddressSync(e,t)}static findProgramAddressSync(e,t){let r=255,s;for(;r!=0;){try{const i=e.concat(he.Buffer.from([r]));s=this.createProgramAddressSync(i,t)}catch(i){if(i instanceof TypeError)throw i;r--;continue}return[s,r]}throw new Error("Unable to find a viable program address nonce")}static async findProgramAddress(e,t){return this.findProgramAddressSync(e,t)}static isOnCurve(e){const t=new ie(e);return Wo(t.toBytes())}}qo=ie,ie.default=new qo("11111111111111111111111111111111"),Yn.set(ie,{kind:"struct",fields:[["_bn","u256"]]});class D0{constructor(e){if(this._publicKey=void 0,this._secretKey=void 0,e){const t=we(e);if(e.length!==64)throw new Error("bad secret key size");this._publicKey=t.slice(32,64),this._secretKey=t.slice(0,32)}else this._secretKey=we(C0()),this._publicKey=we(Rr(this._secretKey))}get publicKey(){return new ie(this._publicKey)}get secretKey(){return he.Buffer.concat([this._secretKey,this._publicKey],64)}}const F0=new ie("BPFLoader1111111111111111111111111111111111"),nn=1232,Er=127,jn=64;class Ei extends Error{constructor(e){super(`Signature ${e} has expired: block height exceeded.`),this.signature=void 0,this.signature=e}}Object.defineProperty(Ei.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});class Si extends Error{constructor(e,t){super(`Transaction was not confirmed in ${t.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${e} using the Solana Explorer or CLI tools.`),this.signature=void 0,this.signature=e}}Object.defineProperty(Si.prototype,"name",{value:"TransactionExpiredTimeoutError"});class Nn extends Error{constructor(e){super(`Signature ${e} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=e}}Object.defineProperty(Nn.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});class Zn{constructor(e,t){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=e,this.accountKeysFromLookups=t}keySegments(){const e=[this.staticAccountKeys];return this.accountKeysFromLookups&&(e.push(this.accountKeysFromLookups.writable),e.push(this.accountKeysFromLookups.readonly)),e}get(e){for(const t of this.keySegments()){if(e<t.length)return t[e];e-=t.length}}get length(){return this.keySegments().flat().length}compileInstructions(e){if(this.length>256)throw new Error("Account index overflow encountered during compilation");const r=new Map;this.keySegments().flat().forEach((i,o)=>{r.set(i.toBase58(),o)});const s=i=>{const o=r.get(i.toBase58());if(o===void 0)throw new Error("Encountered an unknown instruction account key during compilation");return o};return e.map(i=>({programIdIndex:s(i.programId),accountKeyIndexes:i.keys.map(o=>s(o.pubkey)),data:i.data}))}}const Ee=(n="publicKey")=>B.blob(32,n),z0=(n="signature")=>B.blob(64,n),dn=(n="string")=>{const e=B.struct([B.u32("length"),B.u32("lengthPadding"),B.blob(B.offset(B.u32(),-8),"chars")],n),t=e.decode.bind(e),r=e.encode.bind(e),s=e;return s.decode=(i,o)=>t(i,o).chars.toString(),s.encode=(i,o,a)=>{const f={chars:he.Buffer.from(i,"utf8")};return r(f,o,a)},s.alloc=i=>B.u32().span+B.u32().span+he.Buffer.from(i,"utf8").length,s},K0=(n="authorized")=>B.struct([Ee("staker"),Ee("withdrawer")],n),$0=(n="lockup")=>B.struct([B.ns64("unixTimestamp"),B.ns64("epoch"),Ee("custodian")],n),H0=(n="voteInit")=>B.struct([Ee("nodePubkey"),Ee("authorizedVoter"),Ee("authorizedWithdrawer"),B.u8("commission")],n),W0=(n="voteAuthorizeWithSeedArgs")=>B.struct([B.u32("voteAuthorizationType"),Ee("currentAuthorityDerivedKeyOwnerPubkey"),dn("currentAuthorityDerivedKeySeed"),Ee("newAuthorized")],n);function Yo(n,e){const t=s=>{if(s.span>=0)return s.span;if(typeof s.alloc=="function")return s.alloc(e[s.property]);if("count"in s&&"elementLayout"in s){const i=e[s.property];if(Array.isArray(i))return i.length*t(s.elementLayout)}else if("fields"in s)return Yo({layout:s},e[s.property]);return 0};let r=0;return n.layout.fields.forEach(s=>{r+=t(s)}),r}function At(n){let e=0,t=0;for(;;){let r=n.shift();if(e|=(r&127)<<t*7,t+=1,(r&128)===0)break}return e}function kt(n,e){let t=e;for(;;){let r=t&127;if(t>>=7,t==0){n.push(r);break}else r|=128,n.push(r)}}function Ie(n,e){if(!n)throw new Error(e||"Assertion failed")}class Sr{constructor(e,t){this.payer=void 0,this.keyMetaMap=void 0,this.payer=e,this.keyMetaMap=t}static compile(e,t){const r=new Map,s=o=>{const a=o.toBase58();let f=r.get(a);return f===void 0&&(f={isSigner:!1,isWritable:!1,isInvoked:!1},r.set(a,f)),f},i=s(t);i.isSigner=!0,i.isWritable=!0;for(const o of e){s(o.programId).isInvoked=!0;for(const a of o.keys){const f=s(a.pubkey);f.isSigner||=a.isSigner,f.isWritable||=a.isWritable}}return new Sr(t,r)}getMessageComponents(){const e=[...this.keyMetaMap.entries()];Ie(e.length<=256,"Max static account keys length exceeded");const t=e.filter(([,f])=>f.isSigner&&f.isWritable),r=e.filter(([,f])=>f.isSigner&&!f.isWritable),s=e.filter(([,f])=>!f.isSigner&&f.isWritable),i=e.filter(([,f])=>!f.isSigner&&!f.isWritable),o={numRequiredSignatures:t.length+r.length,numReadonlySignedAccounts:r.length,numReadonlyUnsignedAccounts:i.length};{Ie(t.length>0,"Expected at least one writable signer key");const[f]=t[0];Ie(f===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}const a=[...t.map(([f])=>new ie(f)),...r.map(([f])=>new ie(f)),...s.map(([f])=>new ie(f)),...i.map(([f])=>new ie(f))];return[o,a]}extractTableLookup(e){const[t,r]=this.drainKeysFoundInLookupTable(e.state.addresses,o=>!o.isSigner&&!o.isInvoked&&o.isWritable),[s,i]=this.drainKeysFoundInLookupTable(e.state.addresses,o=>!o.isSigner&&!o.isInvoked&&!o.isWritable);if(!(t.length===0&&s.length===0))return[{accountKey:e.key,writableIndexes:t,readonlyIndexes:s},{writable:r,readonly:i}]}drainKeysFoundInLookupTable(e,t){const r=new Array,s=new Array;for(const[i,o]of this.keyMetaMap.entries())if(t(o)){const a=new ie(i),f=e.findIndex(g=>g.equals(a));f>=0&&(Ie(f<256,"Max lookup table index exceeded"),r.push(f),s.push(a),this.keyMetaMap.delete(i))}return[r,s]}}const jo="Reached end of buffer unexpectedly";function Ft(n){if(n.length===0)throw new Error(jo);return n.shift()}function It(n,...e){const[t]=e;if(e.length===2?t+(e[1]??0)>n.length:t>=n.length)throw new Error(jo);return n.splice(...e)}class Bt{constructor(e){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=e.header,this.accountKeys=e.accountKeys.map(t=>new ie(t)),this.recentBlockhash=e.recentBlockhash,this.instructions=e.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(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:pt.decode(e.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new Zn(this.staticAccountKeys)}static compile(e){const t=Sr.compile(e.instructions,e.payerKey),[r,s]=t.getMessageComponents(),o=new Zn(s).compileInstructions(e.instructions).map(a=>({programIdIndex:a.programIdIndex,accounts:a.accountKeyIndexes,data:pt.encode(a.data)}));return new Bt({header:r,accountKeys:s,recentBlockhash:e.recentBlockhash,instructions:o})}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){const t=this.header.numRequiredSignatures;if(e>=this.header.numRequiredSignatures){const r=e-t,i=this.accountKeys.length-t-this.header.numReadonlyUnsignedAccounts;return r<i}else{const r=t-this.header.numReadonlySignedAccounts;return e<r}}isProgramId(e){return this.indexToProgramIds.has(e)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter((e,t)=>!this.isProgramId(t))}serialize(){const e=this.accountKeys.length;let t=[];kt(t,e);const r=this.instructions.map(b=>{const{accounts:x,programIdIndex:T}=b,L=Array.from(pt.decode(b.data));let O=[];kt(O,x.length);let N=[];return kt(N,L.length),{programIdIndex:T,keyIndicesCount:he.Buffer.from(O),keyIndices:x,dataLength:he.Buffer.from(N),data:L}});let s=[];kt(s,r.length);let i=he.Buffer.alloc(nn);he.Buffer.from(s).copy(i);let o=s.length;r.forEach(b=>{const T=B.struct([B.u8("programIdIndex"),B.blob(b.keyIndicesCount.length,"keyIndicesCount"),B.seq(B.u8("keyIndex"),b.keyIndices.length,"keyIndices"),B.blob(b.dataLength.length,"dataLength"),B.seq(B.u8("userdatum"),b.data.length,"data")]).encode(b,i,o);o+=T}),i=i.slice(0,o);const a=B.struct([B.blob(1,"numRequiredSignatures"),B.blob(1,"numReadonlySignedAccounts"),B.blob(1,"numReadonlyUnsignedAccounts"),B.blob(t.length,"keyCount"),B.seq(Ee("key"),e,"keys"),Ee("recentBlockhash")]),f={numRequiredSignatures:he.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:he.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:he.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:he.Buffer.from(t),keys:this.accountKeys.map(b=>we(b.toBytes())),recentBlockhash:pt.decode(this.recentBlockhash)};let g=he.Buffer.alloc(2048);const w=a.encode(f,g);return i.copy(g,w),g.slice(0,w+i.length)}static from(e){let t=[...e];const r=Ft(t);if(r!==(r&Er))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const s=Ft(t),i=Ft(t),o=At(t);let a=[];for(let x=0;x<o;x++){const T=It(t,0,Dt);a.push(new ie(he.Buffer.from(T)))}const f=It(t,0,Dt),g=At(t);let w=[];for(let x=0;x<g;x++){const T=Ft(t),L=At(t),O=It(t,0,L),N=At(t),M=It(t,0,N),H=pt.encode(he.Buffer.from(M));w.push({programIdIndex:T,accounts:O,data:H})}const b={header:{numRequiredSignatures:r,numReadonlySignedAccounts:s,numReadonlyUnsignedAccounts:i},recentBlockhash:pt.encode(he.Buffer.from(f)),accountKeys:a,instructions:w};return new Bt(b)}}class pn{constructor(e){this.header=void 0,this.staticAccountKeys=void 0,this.recentBlockhash=void 0,this.compiledInstructions=void 0,this.addressTableLookups=void 0,this.header=e.header,this.staticAccountKeys=e.staticAccountKeys,this.recentBlockhash=e.recentBlockhash,this.compiledInstructions=e.compiledInstructions,this.addressTableLookups=e.addressTableLookups}get version(){return 0}get numAccountKeysFromLookups(){let e=0;for(const t of this.addressTableLookups)e+=t.readonlyIndexes.length+t.writableIndexes.length;return e}getAccountKeys(e){let t;if(e&&"accountKeysFromLookups"in e&&e.accountKeysFromLookups){if(this.numAccountKeysFromLookups!=e.accountKeysFromLookups.writable.length+e.accountKeysFromLookups.readonly.length)throw new Error("Failed to get account keys because of a mismatch in the number of account keys from lookups");t=e.accountKeysFromLookups}else if(e&&"addressLookupTableAccounts"in e&&e.addressLookupTableAccounts)t=this.resolveAddressTableLookups(e.addressLookupTableAccounts);else if(this.addressTableLookups.length>0)throw new Error("Failed to get account keys because address table lookups were not resolved");return new Zn(this.staticAccountKeys,t)}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){const t=this.header.numRequiredSignatures,r=this.staticAccountKeys.length;if(e>=r){const s=e-r,i=this.addressTableLookups.reduce((o,a)=>o+a.writableIndexes.length,0);return s<i}else if(e>=this.header.numRequiredSignatures){const s=e-t,o=r-t-this.header.numReadonlyUnsignedAccounts;return s<o}else{const s=t-this.header.numReadonlySignedAccounts;return e<s}}resolveAddressTableLookups(e){const t={writable:[],readonly:[]};for(const r of this.addressTableLookups){const s=e.find(i=>i.key.equals(r.accountKey));if(!s)throw new Error(`Failed to find address lookup table account for table key ${r.accountKey.toBase58()}`);for(const i of r.writableIndexes)if(i<s.state.addresses.length)t.writable.push(s.state.addresses[i]);else throw new Error(`Failed to find address for index ${i} in address lookup table ${r.accountKey.toBase58()}`);for(const i of r.readonlyIndexes)if(i<s.state.addresses.length)t.readonly.push(s.state.addresses[i]);else throw new Error(`Failed to find address for index ${i} in address lookup table ${r.accountKey.toBase58()}`)}return t}static compile(e){const t=Sr.compile(e.instructions,e.payerKey),r=new Array,s={writable:new Array,readonly:new Array},i=e.addressLookupTableAccounts||[];for(const w of i){const b=t.extractTableLookup(w);if(b!==void 0){const[x,{writable:T,readonly:L}]=b;r.push(x),s.writable.push(...T),s.readonly.push(...L)}}const[o,a]=t.getMessageComponents(),g=new Zn(a,s).compileInstructions(e.instructions);return new pn({header:o,staticAccountKeys:a,recentBlockhash:e.recentBlockhash,compiledInstructions:g,addressTableLookups:r})}serialize(){const e=Array();kt(e,this.staticAccountKeys.length);const t=this.serializeInstructions(),r=Array();kt(r,this.compiledInstructions.length);const s=this.serializeAddressTableLookups(),i=Array();kt(i,this.addressTableLookups.length);const o=B.struct([B.u8("prefix"),B.struct([B.u8("numRequiredSignatures"),B.u8("numReadonlySignedAccounts"),B.u8("numReadonlyUnsignedAccounts")],"header"),B.blob(e.length,"staticAccountKeysLength"),B.seq(Ee(),this.staticAccountKeys.length,"staticAccountKeys"),Ee("recentBlockhash"),B.blob(r.length,"instructionsLength"),B.blob(t.length,"serializedInstructions"),B.blob(i.length,"addressTableLookupsLength"),B.blob(s.length,"serializedAddressTableLookups")]),a=new Uint8Array(nn),g=o.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(e),staticAccountKeys:this.staticAccountKeys.map(w=>w.toBytes()),recentBlockhash:pt.decode(this.recentBlockhash),instructionsLength:new Uint8Array(r),serializedInstructions:t,addressTableLookupsLength:new Uint8Array(i),serializedAddressTableLookups:s},a);return a.slice(0,g)}serializeInstructions(){let e=0;const t=new Uint8Array(nn);for(const r of this.compiledInstructions){const s=Array();kt(s,r.accountKeyIndexes.length);const i=Array();kt(i,r.data.length);const o=B.struct([B.u8("programIdIndex"),B.blob(s.length,"encodedAccountKeyIndexesLength"),B.seq(B.u8(),r.accountKeyIndexes.length,"accountKeyIndexes"),B.blob(i.length,"encodedDataLength"),B.blob(r.data.length,"data")]);e+=o.encode({programIdIndex:r.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(s),accountKeyIndexes:r.accountKeyIndexes,encodedDataLength:new Uint8Array(i),data:r.data},t,e)}return t.slice(0,e)}serializeAddressTableLookups(){let e=0;const t=new Uint8Array(nn);for(const r of this.addressTableLookups){const s=Array();kt(s,r.writableIndexes.length);const i=Array();kt(i,r.readonlyIndexes.length);const o=B.struct([Ee("accountKey"),B.blob(s.length,"encodedWritableIndexesLength"),B.seq(B.u8(),r.writableIndexes.length,"writableIndexes"),B.blob(i.length,"encodedReadonlyIndexesLength"),B.seq(B.u8(),r.readonlyIndexes.length,"readonlyIndexes")]);e+=o.encode({accountKey:r.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(s),writableIndexes:r.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(i),readonlyIndexes:r.readonlyIndexes},t,e)}return t.slice(0,e)}static deserialize(e){let t=[...e];const r=Ft(t),s=r&Er;Ie(r!==s,"Expected versioned message but received legacy message");const i=s;Ie(i===0,`Expected versioned message with version 0 but found version ${i}`);const o={numRequiredSignatures:Ft(t),numReadonlySignedAccounts:Ft(t),numReadonlyUnsignedAccounts:Ft(t)},a=[],f=At(t);for(let L=0;L<f;L++)a.push(new ie(It(t,0,Dt)));const g=pt.encode(It(t,0,Dt)),w=At(t),b=[];for(let L=0;L<w;L++){const O=Ft(t),N=At(t),M=It(t,0,N),H=At(t),K=new Uint8Array(It(t,0,H));b.push({programIdIndex:O,accountKeyIndexes:M,data:K})}const x=At(t),T=[];for(let L=0;L<x;L++){const O=new ie(It(t,0,Dt)),N=At(t),M=It(t,0,N),H=At(t),K=It(t,0,H);T.push({accountKey:O,writableIndexes:M,readonlyIndexes:K})}return new pn({header:o,staticAccountKeys:a,recentBlockhash:g,compiledInstructions:b,addressTableLookups:T})}}const Ai={deserializeMessageVersion(n){const e=n[0],t=e&Er;return t===e?"legacy":t},deserialize:n=>{const e=Ai.deserializeMessageVersion(n);if(e==="legacy")return Bt.from(n);if(e===0)return pn.deserialize(n);throw new Error(`Transaction message version ${e} deserialization is not supported`)}};let jt=function(n){return n[n.BLOCKHEIGHT_EXCEEDED=0]="BLOCKHEIGHT_EXCEEDED",n[n.PROCESSED=1]="PROCESSED",n[n.TIMED_OUT=2]="TIMED_OUT",n[n.NONCE_INVALID=3]="NONCE_INVALID",n}({});const q0=he.Buffer.alloc(jn).fill(0);class xe{constructor(e){this.keys=void 0,this.programId=void 0,this.data=he.Buffer.alloc(0),this.programId=e.programId,this.keys=e.keys,e.data&&(this.data=e.data)}toJSON(){return{keys:this.keys.map(({pubkey:e,isSigner:t,isWritable:r})=>({pubkey:e.toJSON(),isSigner:t,isWritable:r})),programId:this.programId.toJSON(),data:[...this.data]}}}class Oe{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(e){if(this.signatures=[],this.feePayer=void 0,this.instructions=[],this.recentBlockhash=void 0,this.lastValidBlockHeight=void 0,this.nonceInfo=void 0,this.minNonceContextSlot=void 0,this._message=void 0,this._json=void 0,!!e)if(e.feePayer&&(this.feePayer=e.feePayer),e.signatures&&(this.signatures=e.signatures),Object.prototype.hasOwnProperty.call(e,"nonceInfo")){const{minContextSlot:t,nonceInfo:r}=e;this.minNonceContextSlot=t,this.nonceInfo=r}else if(Object.prototype.hasOwnProperty.call(e,"lastValidBlockHeight")){const{blockhash:t,lastValidBlockHeight:r}=e;this.recentBlockhash=t,this.lastValidBlockHeight=r}else{const{recentBlockhash:t,nonceInfo:r}=e;r&&(this.nonceInfo=r),this.recentBlockhash=t}}toJSON(){return{recentBlockhash:this.recentBlockhash||null,feePayer:this.feePayer?this.feePayer.toJSON():null,nonceInfo:this.nonceInfo?{nonce:this.nonceInfo.nonce,nonceInstruction:this.nonceInfo.nonceInstruction.toJSON()}:null,instructions:this.instructions.map(e=>e.toJSON()),signers:this.signatures.map(({publicKey:e})=>e.toJSON())}}add(...e){if(e.length===0)throw new Error("No instructions");return e.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 xe(t))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let e,t;if(this.nonceInfo?(e=this.nonceInfo.nonce,this.instructions[0]!=this.nonceInfo.nonceInstruction?t=[this.nonceInfo.nonceInstruction,...this.instructions]:t=this.instructions):(e=this.recentBlockhash,t=this.instructions),!e)throw new Error("Transaction recentBlockhash required");t.length<1&&console.warn("No instructions provided");let r;if(this.feePayer)r=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)r=this.signatures[0].publicKey;else throw new Error("Transaction fee payer required");for(let O=0;O<t.length;O++)if(t[O].programId===void 0)throw new Error(`Transaction instruction index ${O} has undefined program id`);const s=[],i=[];t.forEach(O=>{O.keys.forEach(M=>{i.push({...M})});const N=O.programId.toString();s.includes(N)||s.push(N)}),s.forEach(O=>{i.push({pubkey:new ie(O),isSigner:!1,isWritable:!1})});const o=[];i.forEach(O=>{const N=O.pubkey.toString(),M=o.findIndex(H=>H.pubkey.toString()===N);M>-1?(o[M].isWritable=o[M].isWritable||O.isWritable,o[M].isSigner=o[M].isSigner||O.isSigner):o.push(O)}),o.sort(function(O,N){if(O.isSigner!==N.isSigner)return O.isSigner?-1:1;if(O.isWritable!==N.isWritable)return O.isWritable?-1:1;const M={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return O.pubkey.toBase58().localeCompare(N.pubkey.toBase58(),"en",M)});const a=o.findIndex(O=>O.pubkey.equals(r));if(a>-1){const[O]=o.splice(a,1);O.isSigner=!0,O.isWritable=!0,o.unshift(O)}else o.unshift({pubkey:r,isSigner:!0,isWritable:!0});for(const O of this.signatures){const N=o.findIndex(M=>M.pubkey.equals(O.publicKey));if(N>-1)o[N].isSigner||(o[N].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."));else throw new Error(`unknown signer: ${O.publicKey.toString()}`)}let f=0,g=0,w=0;const b=[],x=[];o.forEach(({pubkey:O,isSigner:N,isWritable:M})=>{N?(b.push(O.toString()),f+=1,M||(g+=1)):(x.push(O.toString()),M||(w+=1))});const T=b.concat(x),L=t.map(O=>{const{data:N,programId:M}=O;return{programIdIndex:T.indexOf(M.toString()),accounts:O.keys.map(H=>T.indexOf(H.pubkey.toString())),data:pt.encode(N)}});return L.forEach(O=>{Ie(O.programIdIndex>=0),O.accounts.forEach(N=>Ie(N>=0))}),new Bt({header:{numRequiredSignatures:f,numReadonlySignedAccounts:g,numReadonlyUnsignedAccounts:w},accountKeys:T,recentBlockhash:e,instructions:L})}_compile(){const e=this.compileMessage(),t=e.accountKeys.slice(0,e.header.numRequiredSignatures);return this.signatures.length===t.length&&this.signatures.every((s,i)=>t[i].equals(s.publicKey))||(this.signatures=t.map(r=>({signature:null,publicKey:r}))),e}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(e){return(await e.getFeeForMessage(this.compileMessage())).value}setSigners(...e){if(e.length===0)throw new Error("No signers");const t=new Set;this.signatures=e.filter(r=>{const s=r.toString();return t.has(s)?!1:(t.add(s),!0)}).map(r=>({signature:null,publicKey:r}))}sign(...e){if(e.length===0)throw new Error("No signers");const t=new Set,r=[];for(const i of e){const o=i.publicKey.toString();t.has(o)||(t.add(o),r.push(i))}this.signatures=r.map(i=>({signature:null,publicKey:i.publicKey}));const s=this._compile();this._partialSign(s,...r)}partialSign(...e){if(e.length===0)throw new Error("No signers");const t=new Set,r=[];for(const i of e){const o=i.publicKey.toString();t.has(o)||(t.add(o),r.push(i))}const s=this._compile();this._partialSign(s,...r)}_partialSign(e,...t){const r=e.serialize();t.forEach(s=>{const i=bi(r,s.secretKey);this._addSignature(s.publicKey,we(i))})}addSignature(e,t){this._compile(),this._addSignature(e,t)}_addSignature(e,t){Ie(t.length===64);const r=this.signatures.findIndex(s=>e.equals(s.publicKey));if(r<0)throw new Error(`unknown signer: ${e.toString()}`);this.signatures[r].signature=he.Buffer.from(t)}verifySignatures(e=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),e)}_getMessageSignednessErrors(e,t){const r={};for(const{signature:s,publicKey:i}of this.signatures)s===null?t&&(r.missing||=[]).push(i):M0(s,e,i.toBytes())||(r.invalid||=[]).push(i);return r.invalid||r.missing?r:void 0}serialize(e){const{requireAllSignatures:t,verifySignatures:r}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},e),s=this.serializeMessage();if(r){const i=this._getMessageSignednessErrors(s,t);if(i){let o="Signature verification failed.";throw i.invalid&&(o+=`
|
|
10
|
+
For a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20.`,[ll]:"No signature verification implementation could be found.",[hl]:"No key generation implementation could be found.",[fl]:"No signing implementation could be found.",[dl]:"No key export implementation could be found.",[Eu]:"Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",[bf]:"Transaction processing left an account with an outstanding borrowed reference",[sf]:"Account in use",[of]:"Account loaded twice",[af]:"Attempt to debit an account but found no record of a prior credit.",[Of]:"Transaction loads an address table account that doesn't exist",[hf]:"This transaction has already been processed",[ff]:"Blockhash not found",[df]:"Loader call chain is too deep",[wf]:"Transactions are currently disabled due to cluster maintenance",[Cf]:"Transaction contains a duplicate instruction ($index) that is not allowed",[uf]:"Insufficient funds for fee",[Mf]:"Transaction results in an account ($accountIndex) with insufficient funds for rent",[lf]:"This account may not be used to pay transaction fees",[gf]:"Transaction contains an invalid account reference",[Tf]:"Transaction loads an address table account with invalid data",[Nf]:"Transaction address table lookup uses an invalid index",[kf]:"Transaction loads an address table account with an invalid owner",[Uf]:"LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",[_f]:"This program may not be used for executing instructions",[xf]:"Transaction leaves an account with a lower balance than rent-exempt minimum",[Sf]:"Transaction loads a writable account that cannot be written",[Pf]:"Transaction exceeded max loaded accounts data size cap",[pf]:"Transaction requires a fee but has no signature present",[cf]:"Attempt to load a program that does not exist",[Ff]:"Execution of the program referenced by account at index $accountIndex is temporarily restricted.",[Df]:"ResanitizationNeeded",[yf]:"Transaction failed to sanitize accounts offsets correctly",[mf]:"Transaction did not pass signature verification",[vf]:"Transaction locked too many accounts",[zf]:"Sum of account balances before and after transaction do not match",[rf]:"The transaction failed with the error `$errorName`",[Ef]:"Transaction version is unsupported",[If]:"Transaction would exceed account data limit within the block",[Lf]:"Transaction would exceed total account data limit",[Af]:"Transaction would exceed max account limit within the block",[Rf]:"Transaction would exceed max Block Cost Limit",[Bf]:"Transaction would exceed max Vote Cost Limit",[Jh]:"Attempted to sign a transaction with an address that is not a signer for it",[Gh]:"Transaction is missing an address at index: $index.",[Qh]:"Transaction has no expected signers therefore it cannot be encoded",[Fh]:"Transaction does not have a blockhash lifetime",[zh]:"Transaction is not a durable nonce transaction",[$h]:"Contents of these address lookup tables unknown: $lookupTableAddresses",[Hh]:"Lookup of address at index $highestRequestedIndex failed for lookup table `$lookupTableAddress`. Highest known index is $highestKnownIndex. The lookup table may have been extended since its contents were retrieved",[qh]:"No fee payer set in CompiledTransaction",[Wh]:"Could not find program address at index $index",[tf]:"Failed to estimate the compute unit consumption for this transaction message. This is likely because simulating the transaction failed. Inspect the `cause` property of this error to learn more",[nf]:"Transaction failed when it was simulated in order to estimate the compute unit consumption. The compute unit estimate provided is for a transaction that failed when simulated and may not be representative of the compute units this transaction would consume if successful. Inspect the `cause` property of this error to learn more",[Yh]:"Transaction is missing a fee payer.",[jh]:"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",[Xh]:"Transaction first instruction is not advance nonce account instruction.",[Zh]:"Transaction with no instructions cannot be durable nonce transaction.",[Uh]:"This transaction includes an address (`$programAddress`) which is both invoked and set as the fee payer. Program addresses may not pay fees",[Dh]:"This transaction includes an address (`$programAddress`) which is both invoked and marked writable. Program addresses may not be writable",[ef]:"The transaction message expected the transaction to have $signerAddressesLength signatures, got $signaturesLength.",[Vh]:"Transaction is missing signatures for addresses: $addresses.",[Kh]:"Transaction version must be in the range [0, 127]. `$actualVersion` given"},Gt="i",Mt="t";function Rd(n,e={}){const t=bd[n];if(t.length===0)return"";let r;function s(o){if(r[Mt]===2){const a=t.slice(r[Gt]+1,o);i.push(a in e?`${e[a]}`:`$${a}`)}else r[Mt]===1&&i.push(t.slice(r[Gt],o))}const i=[];return t.split("").forEach((o,a)=>{if(a===0){r={[Gt]:0,[Mt]:t[0]==="\\"?0:t[0]==="$"?2:1};return}let f;switch(r[Mt]){case 0:f={[Gt]:a,[Mt]:1};break;case 1:o==="\\"?f={[Gt]:a,[Mt]:0}:o==="$"&&(f={[Gt]:a,[Mt]:2});break;case 2:o==="\\"?f={[Gt]:a,[Mt]:0}:o==="$"?f={[Gt]:a,[Mt]:2}:o.match(/\w/)||(f={[Gt]:a,[Mt]:1});break}f&&(r!==f&&s(a),r=f)}),s(),i.join("")}function Ed(n,e={}){if(process.env.NODE_ENV!=="production")return Rd(n,e);{let t=`Solana error #${n}; Decode this error by running \`npx @solana/errors decode -- ${n}`;return Object.keys(e).length&&(t+=` '${wd(e)}'`),`${t}\``}}var On=class extends Error{cause=this.cause;context;constructor(...[n,e]){let t,r;if(e){const{cause:i,...o}=e;i&&(r={cause:i}),Object.keys(o).length>0&&(t=o)}const s=Ed(n,t);super(s,r),this.context={__code:n,...t},this.name="SolanaError"}};function Sd(n,e){return"fixedSize"in e?e.fixedSize:e.getSizeFromValue(n)}function Ad(n){return Object.freeze({...n,encode:e=>{const t=new Uint8Array(Sd(e,n));return n.write(e,t,0),t}})}function Id(n){return Object.freeze({...n,decode:(e,t=0)=>n.read(e,t)[0]})}function kn(n){return"fixedSize"in n&&typeof n.fixedSize=="number"}function vd(n,e){if(kn(n)!==kn(e))throw new On(uo);if(kn(n)&&kn(e)&&n.fixedSize!==e.fixedSize)throw new On(lo,{decoderFixedSize:e.fixedSize,encoderFixedSize:n.fixedSize});if(!kn(n)&&!kn(e)&&n.maxSize!==e.maxSize)throw new On(ho,{decoderMaxSize:e.maxSize,encoderMaxSize:n.maxSize});return{...e,...n,decode:e.decode,encode:n.encode,read:e.read,write:n.write}}function Od(n,e,t=0){if(e.length-t<=0)throw new On(ao,{codecDescription:n})}function kd(n,e,t,r=0){const s=t.length-r;if(s<e)throw new On(co,{bytesLength:s,codecDescription:n,expected:e})}function Td(n,e,t,r){if(r<e||r>t)throw new On(fo,{codecDescription:n,max:t,min:e,value:r})}function go(n){return n?.endian!==1}function Nd(n){return Ad({fixedSize:n.size,write(e,t,r){n.range&&Td(n.name,n.range[0],n.range[1],e);const s=new ArrayBuffer(n.size);return n.set(new DataView(s),e,go(n.config)),t.set(new Uint8Array(s),r),r+n.size}})}function xd(n){return Id({fixedSize:n.size,read(e,t=0){Od(n.name,e,t),kd(n.name,n.size,e,t);const r=new DataView(Bd(e,t,n.size));return[n.get(r,go(n.config)),t+n.size]}})}function Bd(n,e,t){const r=n.byteOffset+(e??0),s=t??n.byteLength;return n.buffer.slice(r,r+s)}var mo=(n={})=>Nd({config:n,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(e,t,r)=>e.setBigUint64(0,BigInt(t),r),size:8}),Ld=(n={})=>xd({config:n,get:(e,t)=>e.getBigUint64(0,t),name:"u64",size:8}),Cd=(n={})=>vd(mo(n),Ld(n));class Md extends TypeError{constructor(e,t){let r;const{message:s,explanation:i,...o}=e,{path:a}=e,f=a.length===0?s:`At path: ${a.join(".")} -- ${s}`;super(i??f),i!=null&&(this.cause=f),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>r??(r=[e,...t()])}}function Pd(n){return Wn(n)&&typeof n[Symbol.iterator]=="function"}function Wn(n){return typeof n=="object"&&n!=null}function gr(n){return Wn(n)&&!Array.isArray(n)}function xt(n){return typeof n=="symbol"?n.toString():typeof n=="string"?JSON.stringify(n):`${n}`}function Ud(n){const{done:e,value:t}=n.next();return e?void 0:t}function Dd(n,e,t,r){if(n===!0)return;n===!1?n={}:typeof n=="string"&&(n={message:n});const{path:s,branch:i}=e,{type:o}=t,{refinement:a,message:f=`Expected a value of type \`${o}\`${a?` with refinement \`${a}\``:""}, but received: \`${xt(r)}\``}=n;return{value:r,type:o,refinement:a,key:s[s.length-1],path:s,branch:i,...n,message:f}}function*_o(n,e,t,r){Pd(n)||(n=[n]);for(const s of n){const i=Dd(s,e,t,r);i&&(yield i)}}function*oi(n,e,t={}){const{path:r=[],branch:s=[n],coerce:i=!1,mask:o=!1}=t,a={path:r,branch:s,mask:o};i&&(n=e.coercer(n,a));let f="valid";for(const g of e.validator(n,a))g.explanation=t.message,f="not_valid",yield[g,void 0];for(let[g,w,b]of e.entries(n,a)){const x=oi(w,b,{path:g===void 0?r:[...r,g],branch:g===void 0?s:[...s,w],coerce:i,mask:o,message:t.message});for(const T of x)T[0]?(f=T[0].refinement!=null?"not_refined":"not_valid",yield[T[0],void 0]):i&&(w=T[1],g===void 0?n=w:n instanceof Map?n.set(g,w):n instanceof Set?n.add(w):Wn(n)&&(w!==void 0||g in n)&&(n[g]=w))}if(f!=="not_valid")for(const g of e.refiner(n,a))g.explanation=t.message,f="not_refined",yield[g,void 0];f==="valid"&&(yield[void 0,n])}let Pt=class{constructor(e){const{type:t,schema:r,validator:s,refiner:i,coercer:o=f=>f,entries:a=function*(){}}=e;this.type=t,this.schema=r,this.entries=a,this.coercer=o,s?this.validator=(f,g)=>{const w=s(f,g);return _o(w,g,this,f)}:this.validator=()=>[],i?this.refiner=(f,g)=>{const w=i(f,g);return _o(w,g,this,f)}:this.refiner=()=>[]}assert(e,t){return yo(e,this,t)}create(e,t){return oe(e,this,t)}is(e){return wo(e,this)}mask(e,t){return Fd(e,this,t)}validate(e,t={}){return qn(e,this,t)}};function yo(n,e,t){const r=qn(n,e,{message:t});if(r[0])throw r[0]}function oe(n,e,t){const r=qn(n,e,{coerce:!0,message:t});if(r[0])throw r[0];return r[1]}function Fd(n,e,t){const r=qn(n,e,{coerce:!0,mask:!0,message:t});if(r[0])throw r[0];return r[1]}function wo(n,e){return!qn(n,e)[0]}function qn(n,e,t={}){const r=oi(n,e,t),s=Ud(r);return s[0]?[new Md(s[0],function*(){for(const o of r)o[0]&&(yield o[0])}),void 0]:[void 0,s[1]]}function hn(n,e){return new Pt({type:n,schema:null,validator:e})}function zd(){return hn("any",()=>!0)}function ae(n){return new Pt({type:"array",schema:n,*entries(e){if(n&&Array.isArray(e))for(const[t,r]of e.entries())yield[t,r,n]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||`Expected an array value, but received: ${xt(e)}`}})}function Ut(){return hn("boolean",n=>typeof n=="boolean")}function ai(n){return hn("instance",e=>e instanceof n||`Expected a \`${n.name}\` instance, but received: ${xt(e)}`)}function qe(n){const e=xt(n),t=typeof n;return new Pt({type:"literal",schema:t==="string"||t==="number"||t==="boolean"?n:null,validator(r){return r===n||`Expected the literal \`${e}\`, but received: ${xt(r)}`}})}function Kd(){return hn("never",()=>!1)}function ce(n){return new Pt({...n,validator:(e,t)=>e===null||n.validator(e,t),refiner:(e,t)=>e===null||n.refiner(e,t)})}function $(){return hn("number",n=>typeof n=="number"&&!isNaN(n)||`Expected a number, but received: ${xt(n)}`)}function le(n){return new Pt({...n,validator:(e,t)=>e===void 0||n.validator(e,t),refiner:(e,t)=>e===void 0||n.refiner(e,t)})}function bo(n,e){return new Pt({type:"record",schema:null,*entries(t){if(Wn(t))for(const r in t){const s=t[r];yield[r,r,n],yield[r,s,e]}},validator(t){return gr(t)||`Expected an object, but received: ${xt(t)}`},coercer(t){return gr(t)?{...t}:t}})}function ie(){return hn("string",n=>typeof n=="string"||`Expected a string, but received: ${xt(n)}`)}function ci(n){const e=Kd();return new Pt({type:"tuple",schema:null,*entries(t){if(Array.isArray(t)){const r=Math.max(n.length,t.length);for(let s=0;s<r;s++)yield[s,t[s],n[s]||e]}},validator(t){return Array.isArray(t)||`Expected an array, but received: ${xt(t)}`},coercer(t){return Array.isArray(t)?t.slice():t}})}function te(n){const e=Object.keys(n);return new Pt({type:"type",schema:n,*entries(t){if(Wn(t))for(const r of e)yield[r,t[r],n[r]]},validator(t){return gr(t)||`Expected an object, but received: ${xt(t)}`},coercer(t){return gr(t)?{...t}:t}})}function St(n){const e=n.map(t=>t.type).join(" | ");return new Pt({type:"union",schema:null,coercer(t,r){for(const s of n){const[i,o]=s.validate(t,{coerce:!0,mask:r.mask});if(!i)return o}return t},validator(t,r){const s=[];for(const i of n){const[...o]=oi(t,i,r),[a]=o;if(a[0])for(const[f]of o)f&&s.push(f);else return[]}return[`Expected the value to satisfy a union of \`${e}\`, but received: ${xt(t)}`,...s]}})}function Tn(){return hn("unknown",()=>!0)}function Vn(n,e,t){return new Pt({...n,coercer:(r,s)=>wo(r,e)?n.coercer(t(r,s),s):n.coercer(r,s)})}var mr,$d=new Uint8Array(16);function Ro(){if(!mr&&(mr=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!mr))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return mr($d)}const Hd=/^(?:[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 _r(n){return typeof n=="string"&&Hd.test(n)}for(var _t=[],ui=0;ui<256;++ui)_t.push((ui+256).toString(16).substr(1));function yr(n){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,t=(_t[n[e+0]]+_t[n[e+1]]+_t[n[e+2]]+_t[n[e+3]]+"-"+_t[n[e+4]]+_t[n[e+5]]+"-"+_t[n[e+6]]+_t[n[e+7]]+"-"+_t[n[e+8]]+_t[n[e+9]]+"-"+_t[n[e+10]]+_t[n[e+11]]+_t[n[e+12]]+_t[n[e+13]]+_t[n[e+14]]+_t[n[e+15]]).toLowerCase();if(!_r(t))throw TypeError("Stringified UUID is invalid");return t}var Eo,li,hi=0,fi=0;function Wd(n,e,t){var r=e&&t||0,s=e||new Array(16);n=n||{};var i=n.node||Eo,o=n.clockseq!==void 0?n.clockseq:li;if(i==null||o==null){var a=n.random||(n.rng||Ro)();i==null&&(i=Eo=[a[0]|1,a[1],a[2],a[3],a[4],a[5]]),o==null&&(o=li=(a[6]<<8|a[7])&16383)}var f=n.msecs!==void 0?n.msecs:Date.now(),g=n.nsecs!==void 0?n.nsecs:fi+1,w=f-hi+(g-fi)/1e4;if(w<0&&n.clockseq===void 0&&(o=o+1&16383),(w<0||f>hi)&&n.nsecs===void 0&&(g=0),g>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");hi=f,fi=g,li=o,f+=122192928e5;var b=((f&268435455)*1e4+g)%4294967296;s[r++]=b>>>24&255,s[r++]=b>>>16&255,s[r++]=b>>>8&255,s[r++]=b&255;var x=f/4294967296*1e4&268435455;s[r++]=x>>>8&255,s[r++]=x&255,s[r++]=x>>>24&15|16,s[r++]=x>>>16&255,s[r++]=o>>>8|128,s[r++]=o&255;for(var T=0;T<6;++T)s[r+T]=i[T];return e||yr(s)}function So(n){if(!_r(n))throw TypeError("Invalid UUID");var e,t=new Uint8Array(16);return t[0]=(e=parseInt(n.slice(0,8),16))>>>24,t[1]=e>>>16&255,t[2]=e>>>8&255,t[3]=e&255,t[4]=(e=parseInt(n.slice(9,13),16))>>>8,t[5]=e&255,t[6]=(e=parseInt(n.slice(14,18),16))>>>8,t[7]=e&255,t[8]=(e=parseInt(n.slice(19,23),16))>>>8,t[9]=e&255,t[10]=(e=parseInt(n.slice(24,36),16))/1099511627776&255,t[11]=e/4294967296&255,t[12]=e>>>24&255,t[13]=e>>>16&255,t[14]=e>>>8&255,t[15]=e&255,t}function qd(n){n=unescape(encodeURIComponent(n));for(var e=[],t=0;t<n.length;++t)e.push(n.charCodeAt(t));return e}var Vd="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Gd="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function Ao(n,e,t){function r(s,i,o,a){if(typeof s=="string"&&(s=qd(s)),typeof i=="string"&&(i=So(i)),i.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var f=new Uint8Array(16+s.length);if(f.set(i),f.set(s,i.length),f=t(f),f[6]=f[6]&15|e,f[8]=f[8]&63|128,o){a=a||0;for(var g=0;g<16;++g)o[a+g]=f[g];return o}return yr(f)}try{r.name=n}catch{}return r.DNS=Vd,r.URL=Gd,r}function Yd(n){if(typeof n=="string"){var e=unescape(encodeURIComponent(n));n=new Uint8Array(e.length);for(var t=0;t<e.length;++t)n[t]=e.charCodeAt(t)}return jd(Zd(Xd(n),n.length*8))}function jd(n){for(var e=[],t=n.length*32,r="0123456789abcdef",s=0;s<t;s+=8){var i=n[s>>5]>>>s%32&255,o=parseInt(r.charAt(i>>>4&15)+r.charAt(i&15),16);e.push(o)}return e}function Io(n){return(n+64>>>9<<4)+14+1}function Zd(n,e){n[e>>5]|=128<<e%32,n[Io(e)-1]=e;for(var t=1732584193,r=-271733879,s=-1732584194,i=271733878,o=0;o<n.length;o+=16){var a=t,f=r,g=s,w=i;t=yt(t,r,s,i,n[o],7,-680876936),i=yt(i,t,r,s,n[o+1],12,-389564586),s=yt(s,i,t,r,n[o+2],17,606105819),r=yt(r,s,i,t,n[o+3],22,-1044525330),t=yt(t,r,s,i,n[o+4],7,-176418897),i=yt(i,t,r,s,n[o+5],12,1200080426),s=yt(s,i,t,r,n[o+6],17,-1473231341),r=yt(r,s,i,t,n[o+7],22,-45705983),t=yt(t,r,s,i,n[o+8],7,1770035416),i=yt(i,t,r,s,n[o+9],12,-1958414417),s=yt(s,i,t,r,n[o+10],17,-42063),r=yt(r,s,i,t,n[o+11],22,-1990404162),t=yt(t,r,s,i,n[o+12],7,1804603682),i=yt(i,t,r,s,n[o+13],12,-40341101),s=yt(s,i,t,r,n[o+14],17,-1502002290),r=yt(r,s,i,t,n[o+15],22,1236535329),t=wt(t,r,s,i,n[o+1],5,-165796510),i=wt(i,t,r,s,n[o+6],9,-1069501632),s=wt(s,i,t,r,n[o+11],14,643717713),r=wt(r,s,i,t,n[o],20,-373897302),t=wt(t,r,s,i,n[o+5],5,-701558691),i=wt(i,t,r,s,n[o+10],9,38016083),s=wt(s,i,t,r,n[o+15],14,-660478335),r=wt(r,s,i,t,n[o+4],20,-405537848),t=wt(t,r,s,i,n[o+9],5,568446438),i=wt(i,t,r,s,n[o+14],9,-1019803690),s=wt(s,i,t,r,n[o+3],14,-187363961),r=wt(r,s,i,t,n[o+8],20,1163531501),t=wt(t,r,s,i,n[o+13],5,-1444681467),i=wt(i,t,r,s,n[o+2],9,-51403784),s=wt(s,i,t,r,n[o+7],14,1735328473),r=wt(r,s,i,t,n[o+12],20,-1926607734),t=bt(t,r,s,i,n[o+5],4,-378558),i=bt(i,t,r,s,n[o+8],11,-2022574463),s=bt(s,i,t,r,n[o+11],16,1839030562),r=bt(r,s,i,t,n[o+14],23,-35309556),t=bt(t,r,s,i,n[o+1],4,-1530992060),i=bt(i,t,r,s,n[o+4],11,1272893353),s=bt(s,i,t,r,n[o+7],16,-155497632),r=bt(r,s,i,t,n[o+10],23,-1094730640),t=bt(t,r,s,i,n[o+13],4,681279174),i=bt(i,t,r,s,n[o],11,-358537222),s=bt(s,i,t,r,n[o+3],16,-722521979),r=bt(r,s,i,t,n[o+6],23,76029189),t=bt(t,r,s,i,n[o+9],4,-640364487),i=bt(i,t,r,s,n[o+12],11,-421815835),s=bt(s,i,t,r,n[o+15],16,530742520),r=bt(r,s,i,t,n[o+2],23,-995338651),t=Rt(t,r,s,i,n[o],6,-198630844),i=Rt(i,t,r,s,n[o+7],10,1126891415),s=Rt(s,i,t,r,n[o+14],15,-1416354905),r=Rt(r,s,i,t,n[o+5],21,-57434055),t=Rt(t,r,s,i,n[o+12],6,1700485571),i=Rt(i,t,r,s,n[o+3],10,-1894986606),s=Rt(s,i,t,r,n[o+10],15,-1051523),r=Rt(r,s,i,t,n[o+1],21,-2054922799),t=Rt(t,r,s,i,n[o+8],6,1873313359),i=Rt(i,t,r,s,n[o+15],10,-30611744),s=Rt(s,i,t,r,n[o+6],15,-1560198380),r=Rt(r,s,i,t,n[o+13],21,1309151649),t=Rt(t,r,s,i,n[o+4],6,-145523070),i=Rt(i,t,r,s,n[o+11],10,-1120210379),s=Rt(s,i,t,r,n[o+2],15,718787259),r=Rt(r,s,i,t,n[o+9],21,-343485551),t=tn(t,a),r=tn(r,f),s=tn(s,g),i=tn(i,w)}return[t,r,s,i]}function Xd(n){if(n.length===0)return[];for(var e=n.length*8,t=new Uint32Array(Io(e)),r=0;r<e;r+=8)t[r>>5]|=(n[r/8]&255)<<r%32;return t}function tn(n,e){var t=(n&65535)+(e&65535),r=(n>>16)+(e>>16)+(t>>16);return r<<16|t&65535}function Jd(n,e){return n<<e|n>>>32-e}function wr(n,e,t,r,s,i){return tn(Jd(tn(tn(e,n),tn(r,i)),s),t)}function yt(n,e,t,r,s,i,o){return wr(e&t|~e&r,n,e,s,i,o)}function wt(n,e,t,r,s,i,o){return wr(e&r|t&~r,n,e,s,i,o)}function bt(n,e,t,r,s,i,o){return wr(e^t^r,n,e,s,i,o)}function Rt(n,e,t,r,s,i,o){return wr(t^(e|~r),n,e,s,i,o)}var Qd=Ao("v3",48,Yd);function e0(n,e,t){n=n||{};var r=n.random||(n.rng||Ro)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,e){t=t||0;for(var s=0;s<16;++s)e[t+s]=r[s];return e}return yr(r)}function t0(n,e,t,r){switch(n){case 0:return e&t^~e&r;case 1:return e^t^r;case 2:return e&t^e&r^t&r;case 3:return e^t^r}}function di(n,e){return n<<e|n>>>32-e}function n0(n){var e=[1518500249,1859775393,2400959708,3395469782],t=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof n=="string"){var r=unescape(encodeURIComponent(n));n=[];for(var s=0;s<r.length;++s)n.push(r.charCodeAt(s))}else Array.isArray(n)||(n=Array.prototype.slice.call(n));n.push(128);for(var i=n.length/4+2,o=Math.ceil(i/16),a=new Array(o),f=0;f<o;++f){for(var g=new Uint32Array(16),w=0;w<16;++w)g[w]=n[f*64+w*4]<<24|n[f*64+w*4+1]<<16|n[f*64+w*4+2]<<8|n[f*64+w*4+3];a[f]=g}a[o-1][14]=(n.length-1)*8/Math.pow(2,32),a[o-1][14]=Math.floor(a[o-1][14]),a[o-1][15]=(n.length-1)*8&4294967295;for(var b=0;b<o;++b){for(var x=new Uint32Array(80),T=0;T<16;++T)x[T]=a[b][T];for(var L=16;L<80;++L)x[L]=di(x[L-3]^x[L-8]^x[L-14]^x[L-16],1);for(var O=t[0],N=t[1],M=t[2],H=t[3],K=t[4],Q=0;Q<80;++Q){var q=Math.floor(Q/20),D=di(O,5)+t0(q,N,M,H)+K+e[q]+x[Q]>>>0;K=H,H=M,M=di(N,30)>>>0,N=O,O=D}t[0]=t[0]+O>>>0,t[1]=t[1]+N>>>0,t[2]=t[2]+M>>>0,t[3]=t[3]+H>>>0,t[4]=t[4]+K>>>0}return[t[0]>>24&255,t[0]>>16&255,t[0]>>8&255,t[0]&255,t[1]>>24&255,t[1]>>16&255,t[1]>>8&255,t[1]&255,t[2]>>24&255,t[2]>>16&255,t[2]>>8&255,t[2]&255,t[3]>>24&255,t[3]>>16&255,t[3]>>8&255,t[3]&255,t[4]>>24&255,t[4]>>16&255,t[4]>>8&255,t[4]&255]}var r0=Ao("v5",80,n0);const i0="00000000-0000-0000-0000-000000000000";function s0(n){if(!_r(n))throw TypeError("Invalid UUID");return parseInt(n.substr(14,1),16)}const vo=Dr(Object.freeze(Object.defineProperty({__proto__:null,NIL:i0,parse:So,stringify:yr,v1:Wd,v3:Qd,v4:e0,v5:r0,validate:_r,version:s0},Symbol.toStringTag,{value:"Module"})));var pi,Oo;function o0(){if(Oo)return pi;Oo=1;const n=vo.v4;return pi=function(t,r,s,i){if(typeof t!="string")throw new TypeError(t+" must be a string");i=i||{};const o=typeof i.version=="number"?i.version:2;if(o!==1&&o!==2)throw new TypeError(o+" must be 1 or 2");const a={method:t};if(o===2&&(a.jsonrpc="2.0"),r){if(typeof r!="object"&&!Array.isArray(r))throw new TypeError(r+" must be an object, array or omitted");a.params=r}if(typeof s>"u"){const f=typeof i.generator=="function"?i.generator:function(){return n()};a.id=f(a,i)}else o===2&&s===null?i.notificationIdNull&&(a.id=null):a.id=s;return a},pi}var gi,ko;function a0(){if(ko)return gi;ko=1;const n=vo.v4,e=o0(),t=function(r,s){if(!(this instanceof t))return new t(r,s);s||(s={}),this.options={reviver:typeof s.reviver<"u"?s.reviver:null,replacer:typeof s.replacer<"u"?s.replacer:null,generator:typeof s.generator<"u"?s.generator:function(){return n()},version:typeof s.version<"u"?s.version:2,notificationIdNull:typeof s.notificationIdNull=="boolean"?s.notificationIdNull:!1},this.callServer=r};return gi=t,t.prototype.request=function(r,s,i,o){const a=this;let f=null;const g=Array.isArray(r)&&typeof s=="function";if(this.options.version===1&&g)throw new TypeError("JSON-RPC 1.0 does not support batching");if(g||!g&&r&&typeof r=="object"&&typeof s=="function")o=s,f=r;else{typeof i=="function"&&(o=i,i=void 0);const x=typeof o=="function";try{f=e(r,s,i,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(T){if(x)return o(T);throw T}if(!x)return f}let b;try{b=JSON.stringify(f,this.options.replacer)}catch(x){return o(x)}return this.callServer(b,function(x,T){a._parseResponse(x,T,o)}),f},t.prototype._parseResponse=function(r,s,i){if(r){i(r);return}if(!s)return i();let o;try{o=JSON.parse(s,this.options.reviver)}catch(a){return i(a)}if(i.length===3)if(Array.isArray(o)){const a=function(g){return typeof g.error<"u"},f=function(g){return!a(g)};return i(null,o.filter(a),o.filter(f))}else return i(null,o.error,o.result);i(null,o)},gi}var c0=a0();const u0=Fn(c0);var mi={exports:{}},To;function l0(){return To||(To=1,function(n){var e=Object.prototype.hasOwnProperty,t="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(t=!1));function s(f,g,w){this.fn=f,this.context=g,this.once=w||!1}function i(f,g,w,b,x){if(typeof w!="function")throw new TypeError("The listener must be a function");var T=new s(w,b||f,x),L=t?t+g:g;return f._events[L]?f._events[L].fn?f._events[L]=[f._events[L],T]:f._events[L].push(T):(f._events[L]=T,f._eventsCount++),f}function o(f,g){--f._eventsCount===0?f._events=new r:delete f._events[g]}function a(){this._events=new r,this._eventsCount=0}a.prototype.eventNames=function(){var g=[],w,b;if(this._eventsCount===0)return g;for(b in w=this._events)e.call(w,b)&&g.push(t?b.slice(1):b);return Object.getOwnPropertySymbols?g.concat(Object.getOwnPropertySymbols(w)):g},a.prototype.listeners=function(g){var w=t?t+g:g,b=this._events[w];if(!b)return[];if(b.fn)return[b.fn];for(var x=0,T=b.length,L=new Array(T);x<T;x++)L[x]=b[x].fn;return L},a.prototype.listenerCount=function(g){var w=t?t+g:g,b=this._events[w];return b?b.fn?1:b.length:0},a.prototype.emit=function(g,w,b,x,T,L){var O=t?t+g:g;if(!this._events[O])return!1;var N=this._events[O],M=arguments.length,H,K;if(N.fn){switch(N.once&&this.removeListener(g,N.fn,void 0,!0),M){case 1:return N.fn.call(N.context),!0;case 2:return N.fn.call(N.context,w),!0;case 3:return N.fn.call(N.context,w,b),!0;case 4:return N.fn.call(N.context,w,b,x),!0;case 5:return N.fn.call(N.context,w,b,x,T),!0;case 6:return N.fn.call(N.context,w,b,x,T,L),!0}for(K=1,H=new Array(M-1);K<M;K++)H[K-1]=arguments[K];N.fn.apply(N.context,H)}else{var Q=N.length,q;for(K=0;K<Q;K++)switch(N[K].once&&this.removeListener(g,N[K].fn,void 0,!0),M){case 1:N[K].fn.call(N[K].context);break;case 2:N[K].fn.call(N[K].context,w);break;case 3:N[K].fn.call(N[K].context,w,b);break;case 4:N[K].fn.call(N[K].context,w,b,x);break;default:if(!H)for(q=1,H=new Array(M-1);q<M;q++)H[q-1]=arguments[q];N[K].fn.apply(N[K].context,H)}}return!0},a.prototype.on=function(g,w,b){return i(this,g,w,b,!1)},a.prototype.once=function(g,w,b){return i(this,g,w,b,!0)},a.prototype.removeListener=function(g,w,b,x){var T=t?t+g:g;if(!this._events[T])return this;if(!w)return o(this,T),this;var L=this._events[T];if(L.fn)L.fn===w&&(!x||L.once)&&(!b||L.context===b)&&o(this,T);else{for(var O=0,N=[],M=L.length;O<M;O++)(L[O].fn!==w||x&&!L[O].once||b&&L[O].context!==b)&&N.push(L[O]);N.length?this._events[T]=N.length===1?N[0]:N:o(this,T)}return this},a.prototype.removeAllListeners=function(g){var w;return g?(w=t?t+g:g,this._events[w]&&o(this,w)):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=t,a.EventEmitter=a,n.exports=a}(mi)),mi.exports}var h0=l0();const No=Fn(h0);var f0=class extends No{socket;constructor(n,e,t){super(),this.socket=new window.WebSocket(n,t),this.socket.onopen=()=>this.emit("open"),this.socket.onmessage=r=>this.emit("message",r.data),this.socket.onerror=r=>this.emit("error",r),this.socket.onclose=r=>{this.emit("close",r.code,r.reason)}}send(n,e,t){const r=t||e;try{this.socket.send(n),r()}catch(s){r(s)}}close(n,e){this.socket.close(n,e)}addEventListener(n,e,t){this.socket.addEventListener(n,e,t)}};function d0(n,e){return new f0(n,e)}var p0=class{encode(n){return JSON.stringify(n)}decode(n){return JSON.parse(n)}},g0=class extends No{address;rpc_id;queue;options;autoconnect;ready;reconnect;reconnect_timer_id;reconnect_interval;max_reconnects;rest_options;current_reconnects;generate_request_id;socket;webSocketFactory;dataPack;constructor(n,e="ws://localhost:8080",{autoconnect:t=!0,reconnect:r=!0,reconnect_interval:s=1e3,max_reconnects:i=5,...o}={},a,f){super(),this.webSocketFactory=n,this.queue={},this.rpc_id=0,this.address=e,this.autoconnect=t,this.ready=!1,this.reconnect=r,this.reconnect_timer_id=void 0,this.reconnect_interval=s,this.max_reconnects=i,this.rest_options=o,this.current_reconnects=0,this.generate_request_id=a||(()=>++this.rpc_id),f?this.dataPack=f:this.dataPack=new p0,this.autoconnect&&this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}connect(){this.socket||this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}call(n,e,t,r){return!r&&typeof t=="object"&&(r=t,t=null),new Promise((s,i)=>{if(!this.ready)return i(new Error("socket not ready"));const o=this.generate_request_id(n,e),a={jsonrpc:"2.0",method:n,params:e||void 0,id:o};this.socket.send(this.dataPack.encode(a),r,f=>{if(f)return i(f);this.queue[o]={promise:[s,i]},t&&(this.queue[o].timeout=setTimeout(()=>{delete this.queue[o],i(new Error("reply timeout"))},t))})})}async login(n){const e=await this.call("rpc.login",n);if(!e)throw new Error("authentication failed");return e}async listMethods(){return await this.call("__listMethods")}notify(n,e){return new Promise((t,r)=>{if(!this.ready)return r(new Error("socket not ready"));const s={jsonrpc:"2.0",method:n,params:e};this.socket.send(this.dataPack.encode(s),i=>{if(i)return r(i);t()})})}async subscribe(n){typeof n=="string"&&(n=[n]);const e=await this.call("rpc.on",n);if(typeof n=="string"&&e[n]!=="ok")throw new Error("Failed subscribing to an event '"+n+"' with: "+e[n]);return e}async unsubscribe(n){typeof n=="string"&&(n=[n]);const e=await this.call("rpc.off",n);if(typeof n=="string"&&e[n]!=="ok")throw new Error("Failed unsubscribing from an event with: "+e);return e}close(n,e){this.socket.close(n||1e3,e)}setAutoReconnect(n){this.reconnect=n}setReconnectInterval(n){this.reconnect_interval=n}setMaxReconnects(n){this.max_reconnects=n}_connect(n,e){clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(n,e),this.socket.addEventListener("open",()=>{this.ready=!0,this.emit("open"),this.current_reconnects=0}),this.socket.addEventListener("message",({data:t})=>{t instanceof ArrayBuffer&&(t=he.Buffer.from(t).toString());try{t=this.dataPack.decode(t)}catch{return}if(t.notification&&this.listeners(t.notification).length){if(!Object.keys(t.params).length)return this.emit(t.notification);const r=[t.notification];if(t.params.constructor===Object)r.push(t.params);else for(let s=0;s<t.params.length;s++)r.push(t.params[s]);return Promise.resolve().then(()=>{this.emit.apply(this,r)})}if(!this.queue[t.id])return t.method?Promise.resolve().then(()=>{this.emit(t.method,t?.params)}):void 0;"error"in t=="result"in t&&this.queue[t.id].promise[1](new Error('Server response malformed. Response must include either "result" or "error", but not both.')),this.queue[t.id].timeout&&clearTimeout(this.queue[t.id].timeout),t.error?this.queue[t.id].promise[1](t.error):this.queue[t.id].promise[0](t.result),delete this.queue[t.id]}),this.socket.addEventListener("error",t=>this.emit("error",t)),this.socket.addEventListener("close",({code:t,reason:r})=>{this.ready&&setTimeout(()=>this.emit("close",t,r),0),this.ready=!1,this.socket=void 0,t!==1e3&&(this.current_reconnects++,this.reconnect&&(this.max_reconnects>this.current_reconnects||this.max_reconnects===0)&&(this.reconnect_timer_id=setTimeout(()=>this._connect(n,e),this.reconnect_interval)))})}};const xo=[],Bo=[],Lo=[],m0=BigInt(0),Gn=BigInt(1),_0=BigInt(2),y0=BigInt(7),w0=BigInt(256),b0=BigInt(113);for(let n=0,e=Gn,t=1,r=0;n<24;n++){[t,r]=[r,(2*t+3*r)%5],xo.push(2*(5*r+t)),Bo.push((n+1)*(n+2)/2%64);let s=m0;for(let i=0;i<7;i++)e=(e<<Gn^(e>>y0)*b0)%w0,e&_0&&(s^=Gn<<(Gn<<BigInt(i))-Gn);Lo.push(s)}const[R0,E0]=Ls(Lo,!0),Co=(n,e,t)=>t>32?Ps(n,e,t):Cs(n,e,t),Mo=(n,e,t)=>t>32?Us(n,e,t):Ms(n,e,t);function S0(n,e=24){const t=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let o=0;o<10;o++)t[o]=n[o]^n[o+10]^n[o+20]^n[o+30]^n[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,f=(o+2)%10,g=t[f],w=t[f+1],b=Co(g,w,1)^t[a],x=Mo(g,w,1)^t[a+1];for(let T=0;T<50;T+=10)n[o+T]^=b,n[o+T+1]^=x}let s=n[2],i=n[3];for(let o=0;o<24;o++){const a=Bo[o],f=Co(s,i,a),g=Mo(s,i,a),w=xo[o];s=n[w],i=n[w+1],n[w]=f,n[w+1]=g}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=n[o+a];for(let a=0;a<10;a++)n[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}n[0]^=R0[r],n[1]^=E0[r]}t.fill(0)}class _i extends Hr{constructor(e,t,r,s=!1,i=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=s,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,rr(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=Qa(this.state)}keccak(){ks||Ts(this.state32),S0(this.state32,this.rounds),ks||Ts(this.state32),this.posOut=0,this.pos=0}update(e){bn(this);const{blockLen:t,state:r}=this;e=ir(e);const s=e.length;for(let i=0;i<s;){const o=Math.min(t-this.pos,s-i);for(let a=0;a<o;a++)r[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:r,blockLen:s}=this;e[r]^=t,(t&128)!==0&&r===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){bn(this,!1),Kn(e),this.finish();const t=this.state,{blockLen:r}=this;for(let s=0,i=e.length;s<i;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,i-s);e.set(t.subarray(this.posOut,this.posOut+o),s),this.posOut+=o,s+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return rr(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Os(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:r,outputLen:s,rounds:i,enableXOF:o}=this;return e||(e=new _i(t,r,s,o,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=r,e.outputLen=s,e.enableXOF=o,e.destroyed=this.destroyed,e}}const Po=((n,e,t)=>Wr(()=>new _i(e,n,t)))(1,136,256/8);class Uo extends Hr{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,Ja(e);const r=ir(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,i=new Uint8Array(s);i.set(r.length>s?e.create().update(r).digest():r);for(let o=0;o<i.length;o++)i[o]^=54;this.iHash.update(i),this.oHash=e.create();for(let o=0;o<i.length;o++)i[o]^=106;this.oHash.update(i),i.fill(0)}update(e){return bn(this),this.iHash.update(e),this}digestInto(e){bn(this),Kn(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:r,finished:s,destroyed:i,blockLen:o,outputLen:a}=this;return e=e,e.finished=s,e.destroyed=i,e.blockLen=o,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Do=(n,e,t)=>new Uo(n,e).update(t).digest();Do.create=(n,e)=>new Uo(n,e);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function A0(n){const e=Jr(n);An(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:t,Fp:r,a:s}=e;if(t){if(!r.eql(s,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:I0,hexToBytes:v0}=Tc,fn={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(n){const{Err:e}=fn;if(n.length<2||n[0]!==2)throw new e("Invalid signature integer tag");const t=n[1],r=n.subarray(2,t+2);if(!t||r.length!==t)throw new e("Invalid signature integer: wrong length");if(r[0]&128)throw new e("Invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:I0(r),l:n.subarray(t+2)}},toSig(n){const{Err:e}=fn,t=typeof n=="string"?v0(n):n;$n(t);let r=t.length;if(r<2||t[0]!=48)throw new e("Invalid signature tag");if(t[1]!==r-2)throw new e("Invalid signature: incorrect length");const{d:s,l:i}=fn._parseInt(t.subarray(2)),{d:o,l:a}=fn._parseInt(i);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:s,s:o}},hexFromSig(n){const e=g=>Number.parseInt(g[0],16)&8?"00"+g:g,t=g=>{const w=g.toString(16);return w.length&1?`0${w}`:w},r=e(t(n.s)),s=e(t(n.r)),i=r.length/2,o=s.length/2,a=t(i),f=t(o);return`30${t(o+i+4)}02${f}${s}02${a}${r}`}},Yt=BigInt(0),Tt=BigInt(1);BigInt(2);const Fo=BigInt(3);BigInt(4);function O0(n){const e=A0(n),{Fp:t}=e,r=e.toBytes||((L,O,N)=>{const M=O.toAffine();return un(Uint8Array.from([4]),t.toBytes(M.x),t.toBytes(M.y))}),s=e.fromBytes||(L=>{const O=L.subarray(1),N=t.fromBytes(O.subarray(0,t.BYTES)),M=t.fromBytes(O.subarray(t.BYTES,2*t.BYTES));return{x:N,y:M}});function i(L){const{a:O,b:N}=e,M=t.sqr(L),H=t.mul(M,L);return t.add(t.add(H,t.mul(L,O)),N)}if(!t.eql(t.sqr(e.Gy),i(e.Gx)))throw new Error("bad generator point: equation left != right");function o(L){return typeof L=="bigint"&&Yt<L&&L<e.n}function a(L){if(!o(L))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function f(L){const{allowedPrivateKeyLengths:O,nByteLength:N,wrapPrivateKey:M,n:H}=e;if(O&&typeof L!="bigint"){if(on(L)&&(L=an(L)),typeof L!="string"||!O.includes(L.length))throw new Error("Invalid key");L=L.padStart(N*2,"0")}let K;try{K=typeof L=="bigint"?L:cn(ft("private key",L,N))}catch{throw new Error(`private key must be ${N} bytes, hex or bigint, not ${typeof L}`)}return M&&(K=$e(K,H)),a(K),K}const g=new Map;function w(L){if(!(L instanceof b))throw new Error("ProjectivePoint expected")}class b{constructor(O,N,M){if(this.px=O,this.py=N,this.pz=M,O==null||!t.isValid(O))throw new Error("x required");if(N==null||!t.isValid(N))throw new Error("y required");if(M==null||!t.isValid(M))throw new Error("z required")}static fromAffine(O){const{x:N,y:M}=O||{};if(!O||!t.isValid(N)||!t.isValid(M))throw new Error("invalid affine point");if(O instanceof b)throw new Error("projective point not allowed");const H=K=>t.eql(K,t.ZERO);return H(N)&&H(M)?b.ZERO:new b(N,M,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(O){const N=t.invertBatch(O.map(M=>M.pz));return O.map((M,H)=>M.toAffine(N[H])).map(b.fromAffine)}static fromHex(O){const N=b.fromAffine(s(ft("pointHex",O)));return N.assertValidity(),N}static fromPrivateKey(O){return b.BASE.multiply(f(O))}_setWindowSize(O){this._WINDOW_SIZE=O,g.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!t.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:O,y:N}=this.toAffine();if(!t.isValid(O)||!t.isValid(N))throw new Error("bad point: x or y not FE");const M=t.sqr(N),H=i(O);if(!t.eql(M,H))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:O}=this.toAffine();if(t.isOdd)return!t.isOdd(O);throw new Error("Field doesn't support isOdd")}equals(O){w(O);const{px:N,py:M,pz:H}=this,{px:K,py:Q,pz:q}=O,D=t.eql(t.mul(N,q),t.mul(K,H)),Z=t.eql(t.mul(M,q),t.mul(Q,H));return D&&Z}negate(){return new b(this.px,t.neg(this.py),this.pz)}double(){const{a:O,b:N}=e,M=t.mul(N,Fo),{px:H,py:K,pz:Q}=this;let q=t.ZERO,D=t.ZERO,Z=t.ZERO,j=t.mul(H,H),X=t.mul(K,K),z=t.mul(Q,Q),V=t.mul(H,K);return V=t.add(V,V),Z=t.mul(H,Q),Z=t.add(Z,Z),q=t.mul(O,Z),D=t.mul(M,z),D=t.add(q,D),q=t.sub(X,D),D=t.add(X,D),D=t.mul(q,D),q=t.mul(V,q),Z=t.mul(M,Z),z=t.mul(O,z),V=t.sub(j,z),V=t.mul(O,V),V=t.add(V,Z),Z=t.add(j,j),j=t.add(Z,j),j=t.add(j,z),j=t.mul(j,V),D=t.add(D,j),z=t.mul(K,Q),z=t.add(z,z),j=t.mul(z,V),q=t.sub(q,j),Z=t.mul(z,X),Z=t.add(Z,Z),Z=t.add(Z,Z),new b(q,D,Z)}add(O){w(O);const{px:N,py:M,pz:H}=this,{px:K,py:Q,pz:q}=O;let D=t.ZERO,Z=t.ZERO,j=t.ZERO;const X=e.a,z=t.mul(e.b,Fo);let V=t.mul(N,K),ee=t.mul(M,Q),S=t.mul(H,q),c=t.add(N,M),p=t.add(K,Q);c=t.mul(c,p),p=t.add(V,ee),c=t.sub(c,p),p=t.add(N,H);let m=t.add(K,q);return p=t.mul(p,m),m=t.add(V,S),p=t.sub(p,m),m=t.add(M,H),D=t.add(Q,q),m=t.mul(m,D),D=t.add(ee,S),m=t.sub(m,D),j=t.mul(X,p),D=t.mul(z,S),j=t.add(D,j),D=t.sub(ee,j),j=t.add(ee,j),Z=t.mul(D,j),ee=t.add(V,V),ee=t.add(ee,V),S=t.mul(X,S),p=t.mul(z,p),ee=t.add(ee,S),S=t.sub(V,S),S=t.mul(X,S),p=t.add(p,S),V=t.mul(ee,p),Z=t.add(Z,V),V=t.mul(m,p),D=t.mul(c,D),D=t.sub(D,V),V=t.mul(c,ee),j=t.mul(m,j),j=t.add(j,V),new b(D,Z,j)}subtract(O){return this.add(O.negate())}is0(){return this.equals(b.ZERO)}wNAF(O){return T.wNAFCached(this,g,O,N=>{const M=t.invertBatch(N.map(H=>H.pz));return N.map((H,K)=>H.toAffine(M[K])).map(b.fromAffine)})}multiplyUnsafe(O){const N=b.ZERO;if(O===Yt)return N;if(a(O),O===Tt)return this;const{endo:M}=e;if(!M)return T.unsafeLadder(this,O);let{k1neg:H,k1:K,k2neg:Q,k2:q}=M.splitScalar(O),D=N,Z=N,j=this;for(;K>Yt||q>Yt;)K&Tt&&(D=D.add(j)),q&Tt&&(Z=Z.add(j)),j=j.double(),K>>=Tt,q>>=Tt;return H&&(D=D.negate()),Q&&(Z=Z.negate()),Z=new b(t.mul(Z.px,M.beta),Z.py,Z.pz),D.add(Z)}multiply(O){a(O);let N=O,M,H;const{endo:K}=e;if(K){const{k1neg:Q,k1:q,k2neg:D,k2:Z}=K.splitScalar(N);let{p:j,f:X}=this.wNAF(q),{p:z,f:V}=this.wNAF(Z);j=T.constTimeNegate(Q,j),z=T.constTimeNegate(D,z),z=new b(t.mul(z.px,K.beta),z.py,z.pz),M=j.add(z),H=X.add(V)}else{const{p:Q,f:q}=this.wNAF(N);M=Q,H=q}return b.normalizeZ([M,H])[0]}multiplyAndAddUnsafe(O,N,M){const H=b.BASE,K=(q,D)=>D===Yt||D===Tt||!q.equals(H)?q.multiplyUnsafe(D):q.multiply(D),Q=K(this,N).add(K(O,M));return Q.is0()?void 0:Q}toAffine(O){const{px:N,py:M,pz:H}=this,K=this.is0();O==null&&(O=K?t.ONE:t.inv(H));const Q=t.mul(N,O),q=t.mul(M,O),D=t.mul(H,O);if(K)return{x:t.ZERO,y:t.ZERO};if(!t.eql(D,t.ONE))throw new Error("invZ was invalid");return{x:Q,y:q}}isTorsionFree(){const{h:O,isTorsionFree:N}=e;if(O===Tt)return!0;if(N)return N(b,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:O,clearCofactor:N}=e;return O===Tt?this:N?N(b,this):this.multiplyUnsafe(e.h)}toRawBytes(O=!0){return this.assertValidity(),r(b,this,O)}toHex(O=!0){return an(this.toRawBytes(O))}}b.BASE=new b(e.Gx,e.Gy,t.ONE),b.ZERO=new b(t.ZERO,t.ONE,t.ZERO);const x=e.nBitLength,T=js(b,e.endo?Math.ceil(x/2):x);return{CURVE:e,ProjectivePoint:b,normPrivateKeyToScalar:f,weierstrassEquation:i,isWithinCurveOrder:o}}function k0(n){const e=Jr(n);return An(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function T0(n){const e=k0(n),{Fp:t,n:r}=e,s=t.BYTES+1,i=2*t.BYTES+1;function o(p){return Yt<p&&p<t.ORDER}function a(p){return $e(p,r)}function f(p){return Zr(p,r)}const{ProjectivePoint:g,normPrivateKeyToScalar:w,weierstrassEquation:b,isWithinCurveOrder:x}=O0({...e,toBytes(p,m,I){const E=m.toAffine(),A=t.toBytes(E.x),C=un;return I?C(Uint8Array.from([m.hasEvenY()?2:3]),A):C(Uint8Array.from([4]),A,t.toBytes(E.y))},fromBytes(p){const m=p.length,I=p[0],E=p.subarray(1);if(m===s&&(I===2||I===3)){const A=cn(E);if(!o(A))throw new Error("Point is not on curve");const C=b(A);let R;try{R=t.sqrt(C)}catch(y){const k=y instanceof Error?": "+y.message:"";throw new Error("Point is not on curve"+k)}const u=(R&Tt)===Tt;return(I&1)===1!==u&&(R=t.neg(R)),{x:A,y:R}}else if(m===i&&I===4){const A=t.fromBytes(E.subarray(0,t.BYTES)),C=t.fromBytes(E.subarray(t.BYTES,2*t.BYTES));return{x:A,y:C}}else throw new Error(`Point of length ${m} was invalid. Expected ${s} compressed bytes or ${i} uncompressed bytes`)}}),T=p=>an(Sn(p,e.nByteLength));function L(p){const m=r>>Tt;return p>m}function O(p){return L(p)?a(-p):p}const N=(p,m,I)=>cn(p.slice(m,I));class M{constructor(m,I,E){this.r=m,this.s=I,this.recovery=E,this.assertValidity()}static fromCompact(m){const I=e.nByteLength;return m=ft("compactSignature",m,I*2),new M(N(m,0,I),N(m,I,2*I))}static fromDER(m){const{r:I,s:E}=fn.toSig(ft("DER",m));return new M(I,E)}assertValidity(){if(!x(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!x(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(m){return new M(this.r,this.s,m)}recoverPublicKey(m){const{r:I,s:E,recovery:A}=this,C=Z(ft("msgHash",m));if(A==null||![0,1,2,3].includes(A))throw new Error("recovery id invalid");const R=A===2||A===3?I+e.n:I;if(R>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");const u=(A&1)===0?"02":"03",l=g.fromHex(u+T(R)),y=f(R),k=a(-C*y),P=a(E*y),G=g.BASE.multiplyAndAddUnsafe(l,k,P);if(!G)throw new Error("point at infinify");return G.assertValidity(),G}hasHighS(){return L(this.s)}normalizeS(){return this.hasHighS()?new M(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return Rn(this.toDERHex())}toDERHex(){return fn.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Rn(this.toCompactHex())}toCompactHex(){return T(this.r)+T(this.s)}}const H={isValidPrivateKey(p){try{return w(p),!0}catch{return!1}},normPrivateKeyToScalar:w,randomPrivateKey:()=>{const p=Ys(e.n);return Fc(e.randomBytes(p),e.n)},precompute(p=8,m=g.BASE){return m._setWindowSize(p),m.multiply(BigInt(3)),m}};function K(p,m=!0){return g.fromPrivateKey(p).toRawBytes(m)}function Q(p){const m=on(p),I=typeof p=="string",E=(m||I)&&p.length;return m?E===s||E===i:I?E===2*s||E===2*i:p instanceof g}function q(p,m,I=!0){if(Q(p))throw new Error("first arg must be private key");if(!Q(m))throw new Error("second arg must be public key");return g.fromHex(m).multiply(w(p)).toRawBytes(I)}const D=e.bits2int||function(p){const m=cn(p),I=p.length*8-e.nBitLength;return I>0?m>>BigInt(I):m},Z=e.bits2int_modN||function(p){return a(D(p))},j=Gr(e.nBitLength);function X(p){if(typeof p!="bigint")throw new Error("bigint expected");if(!(Yt<=p&&p<j))throw new Error(`bigint expected < 2^${e.nBitLength}`);return Sn(p,e.nByteLength)}function z(p,m,I=V){if(["recovered","canonical"].some(J=>J in I))throw new Error("sign() legacy options not supported");const{hash:E,randomBytes:A}=e;let{lowS:C,prehash:R,extraEntropy:u}=I;C==null&&(C=!0),p=ft("msgHash",p),R&&(p=ft("prehashed msgHash",E(p)));const l=Z(p),y=w(m),k=[X(y),X(l)];if(u!=null&&u!==!1){const J=u===!0?A(t.BYTES):u;k.push(ft("extraEntropy",J))}const P=un(...k),G=l;function re(J){const Ae=D(J);if(!x(Ae))return;const ge=f(Ae),me=g.BASE.multiply(Ae).toAffine(),Ue=a(me.x);if(Ue===Yt)return;const Se=a(ge*a(G+Ue*y));if(Se===Yt)return;let Te=(me.x===Ue?0:2)|Number(me.y&Tt),Wt=Se;return C&&L(Se)&&(Wt=O(Se),Te^=1),new M(Ue,Wt,Te)}return{seed:P,k2sig:re}}const V={lowS:e.lowS,prehash:!1},ee={lowS:e.lowS,prehash:!1};function S(p,m,I=V){const{seed:E,k2sig:A}=z(p,m,I),C=e;return $s(C.hash.outputLen,C.nByteLength,C.hmac)(E,A)}g.BASE._setWindowSize(8);function c(p,m,I,E=ee){const A=p;if(m=ft("msgHash",m),I=ft("publicKey",I),"strict"in E)throw new Error("options.strict was renamed to lowS");const{lowS:C,prehash:R}=E;let u,l;try{if(typeof A=="string"||on(A))try{u=M.fromDER(A)}catch(me){if(!(me instanceof fn.Err))throw me;u=M.fromCompact(A)}else if(typeof A=="object"&&typeof A.r=="bigint"&&typeof A.s=="bigint"){const{r:me,s:Ue}=A;u=new M(me,Ue)}else throw new Error("PARSE");l=g.fromHex(I)}catch(me){if(me.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(C&&u.hasHighS())return!1;R&&(m=e.hash(m));const{r:y,s:k}=u,P=Z(m),G=f(k),re=a(P*G),J=a(y*G),Ae=g.BASE.multiplyAndAddUnsafe(l,re,J)?.toAffine();return Ae?a(Ae.x)===y:!1}return{CURVE:e,getPublicKey:K,getSharedSecret:q,sign:S,verify:c,ProjectivePoint:g,Signature:M,utils:H}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function N0(n){return{hash:n,hmac:(e,...t)=>Do(n,e,nc(...t)),randomBytes:Ns}}function x0(n,e){const t=r=>T0({...n,...N0(r)});return Object.freeze({...t(e),create:t})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const zo=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ko=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),B0=BigInt(1),yi=BigInt(2),$o=(n,e)=>(n+e/yi)/e;function L0(n){const e=zo,t=BigInt(3),r=BigInt(6),s=BigInt(11),i=BigInt(22),o=BigInt(23),a=BigInt(44),f=BigInt(88),g=n*n*n%e,w=g*g*n%e,b=Ge(w,t,e)*w%e,x=Ge(b,t,e)*w%e,T=Ge(x,yi,e)*g%e,L=Ge(T,s,e)*T%e,O=Ge(L,i,e)*L%e,N=Ge(O,a,e)*O%e,M=Ge(N,f,e)*N%e,H=Ge(M,a,e)*O%e,K=Ge(H,t,e)*w%e,Q=Ge(K,o,e)*L%e,q=Ge(Q,r,e)*g%e,D=Ge(q,yi,e);if(!wi.eql(wi.sqr(D),n))throw new Error("Cannot find square root");return D}const wi=Vs(zo,void 0,void 0,{sqrt:L0}),br=x0({a:BigInt(0),b:BigInt(7),Fp:wi,n:Ko,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:n=>{const e=Ko,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-B0*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=t,o=BigInt("0x100000000000000000000000000000000"),a=$o(i*n,e),f=$o(-r*n,e);let g=$e(n-a*t-f*s,e),w=$e(-a*r-f*i,e);const b=g>o,x=w>o;if(b&&(g=e-g),x&&(w=e-w),g>o||w>o)throw new Error("splitScalar: Endomorphism failed, k="+n);return{k1neg:b,k1:g,k2neg:x,k2:w}}}},ni);BigInt(0),br.ProjectivePoint;const C0=In.utils.randomPrivateKey,Ho=()=>{const n=In.utils.randomPrivateKey(),e=Rr(n),t=new Uint8Array(64);return t.set(n),t.set(e,32),{publicKey:e,secretKey:t}},Rr=In.getPublicKey;function Wo(n){try{return In.ExtendedPoint.fromHex(n),!0}catch{return!1}}const bi=(n,e)=>In.sign(n,e.slice(0,32)),M0=In.verify,we=n=>he.Buffer.isBuffer(n)?n:n instanceof Uint8Array?he.Buffer.from(n.buffer,n.byteOffset,n.byteLength):he.Buffer.from(n);class Ri{constructor(e){Object.assign(this,e)}encode(){return he.Buffer.from(si.serialize(Yn,this))}static decode(e){return si.deserialize(Yn,this,e)}static decodeUnchecked(e){return si.deserializeUnchecked(Yn,this,e)}}class P0 extends Ri{constructor(e){if(super(e),this.enum="",Object.keys(e).length!==1)throw new Error("Enum can only take single value");Object.keys(e).map(t=>{this.enum=t})}}const Yn=new Map;var qo;const Vo=32,Dt=32;function U0(n){return n._bn!==void 0}let Go=1;class se extends Ri{constructor(e){if(super({}),this._bn=void 0,U0(e))this._bn=e._bn;else{if(typeof e=="string"){const t=pt.decode(e);if(t.length!=Dt)throw new Error("Invalid public key input");this._bn=new eo(t)}else this._bn=new eo(e);if(this._bn.byteLength()>Dt)throw new Error("Invalid public key input")}}static unique(){const e=new se(Go);return Go+=1,new se(e.toBuffer())}equals(e){return this._bn.eq(e._bn)}toBase58(){return pt.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){const e=this.toBuffer();return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}toBuffer(){const e=this._bn.toArrayLike(he.Buffer);if(e.length===Dt)return e;const t=he.Buffer.alloc(32);return e.copy(t,32-e.length),t}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(e,t,r){const s=he.Buffer.concat([e.toBuffer(),he.Buffer.from(t),r.toBuffer()]),i=ni(s);return new se(i)}static createProgramAddressSync(e,t){let r=he.Buffer.alloc(0);e.forEach(function(i){if(i.length>Vo)throw new TypeError("Max seed length exceeded");r=he.Buffer.concat([r,we(i)])}),r=he.Buffer.concat([r,t.toBuffer(),he.Buffer.from("ProgramDerivedAddress")]);const s=ni(r);if(Wo(s))throw new Error("Invalid seeds, address must fall off the curve");return new se(s)}static async createProgramAddress(e,t){return this.createProgramAddressSync(e,t)}static findProgramAddressSync(e,t){let r=255,s;for(;r!=0;){try{const i=e.concat(he.Buffer.from([r]));s=this.createProgramAddressSync(i,t)}catch(i){if(i instanceof TypeError)throw i;r--;continue}return[s,r]}throw new Error("Unable to find a viable program address nonce")}static async findProgramAddress(e,t){return this.findProgramAddressSync(e,t)}static isOnCurve(e){const t=new se(e);return Wo(t.toBytes())}}qo=se,se.default=new qo("11111111111111111111111111111111"),Yn.set(se,{kind:"struct",fields:[["_bn","u256"]]});class D0{constructor(e){if(this._publicKey=void 0,this._secretKey=void 0,e){const t=we(e);if(e.length!==64)throw new Error("bad secret key size");this._publicKey=t.slice(32,64),this._secretKey=t.slice(0,32)}else this._secretKey=we(C0()),this._publicKey=we(Rr(this._secretKey))}get publicKey(){return new se(this._publicKey)}get secretKey(){return he.Buffer.concat([this._secretKey,this._publicKey],64)}}const F0=new se("BPFLoader1111111111111111111111111111111111"),nn=1232,Er=127,jn=64;class Ei extends Error{constructor(e){super(`Signature ${e} has expired: block height exceeded.`),this.signature=void 0,this.signature=e}}Object.defineProperty(Ei.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});class Si extends Error{constructor(e,t){super(`Transaction was not confirmed in ${t.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${e} using the Solana Explorer or CLI tools.`),this.signature=void 0,this.signature=e}}Object.defineProperty(Si.prototype,"name",{value:"TransactionExpiredTimeoutError"});class Nn extends Error{constructor(e){super(`Signature ${e} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=e}}Object.defineProperty(Nn.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});class Zn{constructor(e,t){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=e,this.accountKeysFromLookups=t}keySegments(){const e=[this.staticAccountKeys];return this.accountKeysFromLookups&&(e.push(this.accountKeysFromLookups.writable),e.push(this.accountKeysFromLookups.readonly)),e}get(e){for(const t of this.keySegments()){if(e<t.length)return t[e];e-=t.length}}get length(){return this.keySegments().flat().length}compileInstructions(e){if(this.length>256)throw new Error("Account index overflow encountered during compilation");const r=new Map;this.keySegments().flat().forEach((i,o)=>{r.set(i.toBase58(),o)});const s=i=>{const o=r.get(i.toBase58());if(o===void 0)throw new Error("Encountered an unknown instruction account key during compilation");return o};return e.map(i=>({programIdIndex:s(i.programId),accountKeyIndexes:i.keys.map(o=>s(o.pubkey)),data:i.data}))}}const Ee=(n="publicKey")=>B.blob(32,n),z0=(n="signature")=>B.blob(64,n),dn=(n="string")=>{const e=B.struct([B.u32("length"),B.u32("lengthPadding"),B.blob(B.offset(B.u32(),-8),"chars")],n),t=e.decode.bind(e),r=e.encode.bind(e),s=e;return s.decode=(i,o)=>t(i,o).chars.toString(),s.encode=(i,o,a)=>{const f={chars:he.Buffer.from(i,"utf8")};return r(f,o,a)},s.alloc=i=>B.u32().span+B.u32().span+he.Buffer.from(i,"utf8").length,s},K0=(n="authorized")=>B.struct([Ee("staker"),Ee("withdrawer")],n),$0=(n="lockup")=>B.struct([B.ns64("unixTimestamp"),B.ns64("epoch"),Ee("custodian")],n),H0=(n="voteInit")=>B.struct([Ee("nodePubkey"),Ee("authorizedVoter"),Ee("authorizedWithdrawer"),B.u8("commission")],n),W0=(n="voteAuthorizeWithSeedArgs")=>B.struct([B.u32("voteAuthorizationType"),Ee("currentAuthorityDerivedKeyOwnerPubkey"),dn("currentAuthorityDerivedKeySeed"),Ee("newAuthorized")],n);function Yo(n,e){const t=s=>{if(s.span>=0)return s.span;if(typeof s.alloc=="function")return s.alloc(e[s.property]);if("count"in s&&"elementLayout"in s){const i=e[s.property];if(Array.isArray(i))return i.length*t(s.elementLayout)}else if("fields"in s)return Yo({layout:s},e[s.property]);return 0};let r=0;return n.layout.fields.forEach(s=>{r+=t(s)}),r}function At(n){let e=0,t=0;for(;;){let r=n.shift();if(e|=(r&127)<<t*7,t+=1,(r&128)===0)break}return e}function kt(n,e){let t=e;for(;;){let r=t&127;if(t>>=7,t==0){n.push(r);break}else r|=128,n.push(r)}}function ve(n,e){if(!n)throw new Error(e||"Assertion failed")}class Sr{constructor(e,t){this.payer=void 0,this.keyMetaMap=void 0,this.payer=e,this.keyMetaMap=t}static compile(e,t){const r=new Map,s=o=>{const a=o.toBase58();let f=r.get(a);return f===void 0&&(f={isSigner:!1,isWritable:!1,isInvoked:!1},r.set(a,f)),f},i=s(t);i.isSigner=!0,i.isWritable=!0;for(const o of e){s(o.programId).isInvoked=!0;for(const a of o.keys){const f=s(a.pubkey);f.isSigner||=a.isSigner,f.isWritable||=a.isWritable}}return new Sr(t,r)}getMessageComponents(){const e=[...this.keyMetaMap.entries()];ve(e.length<=256,"Max static account keys length exceeded");const t=e.filter(([,f])=>f.isSigner&&f.isWritable),r=e.filter(([,f])=>f.isSigner&&!f.isWritable),s=e.filter(([,f])=>!f.isSigner&&f.isWritable),i=e.filter(([,f])=>!f.isSigner&&!f.isWritable),o={numRequiredSignatures:t.length+r.length,numReadonlySignedAccounts:r.length,numReadonlyUnsignedAccounts:i.length};{ve(t.length>0,"Expected at least one writable signer key");const[f]=t[0];ve(f===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}const a=[...t.map(([f])=>new se(f)),...r.map(([f])=>new se(f)),...s.map(([f])=>new se(f)),...i.map(([f])=>new se(f))];return[o,a]}extractTableLookup(e){const[t,r]=this.drainKeysFoundInLookupTable(e.state.addresses,o=>!o.isSigner&&!o.isInvoked&&o.isWritable),[s,i]=this.drainKeysFoundInLookupTable(e.state.addresses,o=>!o.isSigner&&!o.isInvoked&&!o.isWritable);if(!(t.length===0&&s.length===0))return[{accountKey:e.key,writableIndexes:t,readonlyIndexes:s},{writable:r,readonly:i}]}drainKeysFoundInLookupTable(e,t){const r=new Array,s=new Array;for(const[i,o]of this.keyMetaMap.entries())if(t(o)){const a=new se(i),f=e.findIndex(g=>g.equals(a));f>=0&&(ve(f<256,"Max lookup table index exceeded"),r.push(f),s.push(a),this.keyMetaMap.delete(i))}return[r,s]}}const jo="Reached end of buffer unexpectedly";function Ft(n){if(n.length===0)throw new Error(jo);return n.shift()}function It(n,...e){const[t]=e;if(e.length===2?t+(e[1]??0)>n.length:t>=n.length)throw new Error(jo);return n.splice(...e)}class Bt{constructor(e){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=e.header,this.accountKeys=e.accountKeys.map(t=>new se(t)),this.recentBlockhash=e.recentBlockhash,this.instructions=e.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(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:pt.decode(e.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new Zn(this.staticAccountKeys)}static compile(e){const t=Sr.compile(e.instructions,e.payerKey),[r,s]=t.getMessageComponents(),o=new Zn(s).compileInstructions(e.instructions).map(a=>({programIdIndex:a.programIdIndex,accounts:a.accountKeyIndexes,data:pt.encode(a.data)}));return new Bt({header:r,accountKeys:s,recentBlockhash:e.recentBlockhash,instructions:o})}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){const t=this.header.numRequiredSignatures;if(e>=this.header.numRequiredSignatures){const r=e-t,i=this.accountKeys.length-t-this.header.numReadonlyUnsignedAccounts;return r<i}else{const r=t-this.header.numReadonlySignedAccounts;return e<r}}isProgramId(e){return this.indexToProgramIds.has(e)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter((e,t)=>!this.isProgramId(t))}serialize(){const e=this.accountKeys.length;let t=[];kt(t,e);const r=this.instructions.map(b=>{const{accounts:x,programIdIndex:T}=b,L=Array.from(pt.decode(b.data));let O=[];kt(O,x.length);let N=[];return kt(N,L.length),{programIdIndex:T,keyIndicesCount:he.Buffer.from(O),keyIndices:x,dataLength:he.Buffer.from(N),data:L}});let s=[];kt(s,r.length);let i=he.Buffer.alloc(nn);he.Buffer.from(s).copy(i);let o=s.length;r.forEach(b=>{const T=B.struct([B.u8("programIdIndex"),B.blob(b.keyIndicesCount.length,"keyIndicesCount"),B.seq(B.u8("keyIndex"),b.keyIndices.length,"keyIndices"),B.blob(b.dataLength.length,"dataLength"),B.seq(B.u8("userdatum"),b.data.length,"data")]).encode(b,i,o);o+=T}),i=i.slice(0,o);const a=B.struct([B.blob(1,"numRequiredSignatures"),B.blob(1,"numReadonlySignedAccounts"),B.blob(1,"numReadonlyUnsignedAccounts"),B.blob(t.length,"keyCount"),B.seq(Ee("key"),e,"keys"),Ee("recentBlockhash")]),f={numRequiredSignatures:he.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:he.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:he.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:he.Buffer.from(t),keys:this.accountKeys.map(b=>we(b.toBytes())),recentBlockhash:pt.decode(this.recentBlockhash)};let g=he.Buffer.alloc(2048);const w=a.encode(f,g);return i.copy(g,w),g.slice(0,w+i.length)}static from(e){let t=[...e];const r=Ft(t);if(r!==(r&Er))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const s=Ft(t),i=Ft(t),o=At(t);let a=[];for(let x=0;x<o;x++){const T=It(t,0,Dt);a.push(new se(he.Buffer.from(T)))}const f=It(t,0,Dt),g=At(t);let w=[];for(let x=0;x<g;x++){const T=Ft(t),L=At(t),O=It(t,0,L),N=At(t),M=It(t,0,N),H=pt.encode(he.Buffer.from(M));w.push({programIdIndex:T,accounts:O,data:H})}const b={header:{numRequiredSignatures:r,numReadonlySignedAccounts:s,numReadonlyUnsignedAccounts:i},recentBlockhash:pt.encode(he.Buffer.from(f)),accountKeys:a,instructions:w};return new Bt(b)}}class pn{constructor(e){this.header=void 0,this.staticAccountKeys=void 0,this.recentBlockhash=void 0,this.compiledInstructions=void 0,this.addressTableLookups=void 0,this.header=e.header,this.staticAccountKeys=e.staticAccountKeys,this.recentBlockhash=e.recentBlockhash,this.compiledInstructions=e.compiledInstructions,this.addressTableLookups=e.addressTableLookups}get version(){return 0}get numAccountKeysFromLookups(){let e=0;for(const t of this.addressTableLookups)e+=t.readonlyIndexes.length+t.writableIndexes.length;return e}getAccountKeys(e){let t;if(e&&"accountKeysFromLookups"in e&&e.accountKeysFromLookups){if(this.numAccountKeysFromLookups!=e.accountKeysFromLookups.writable.length+e.accountKeysFromLookups.readonly.length)throw new Error("Failed to get account keys because of a mismatch in the number of account keys from lookups");t=e.accountKeysFromLookups}else if(e&&"addressLookupTableAccounts"in e&&e.addressLookupTableAccounts)t=this.resolveAddressTableLookups(e.addressLookupTableAccounts);else if(this.addressTableLookups.length>0)throw new Error("Failed to get account keys because address table lookups were not resolved");return new Zn(this.staticAccountKeys,t)}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){const t=this.header.numRequiredSignatures,r=this.staticAccountKeys.length;if(e>=r){const s=e-r,i=this.addressTableLookups.reduce((o,a)=>o+a.writableIndexes.length,0);return s<i}else if(e>=this.header.numRequiredSignatures){const s=e-t,o=r-t-this.header.numReadonlyUnsignedAccounts;return s<o}else{const s=t-this.header.numReadonlySignedAccounts;return e<s}}resolveAddressTableLookups(e){const t={writable:[],readonly:[]};for(const r of this.addressTableLookups){const s=e.find(i=>i.key.equals(r.accountKey));if(!s)throw new Error(`Failed to find address lookup table account for table key ${r.accountKey.toBase58()}`);for(const i of r.writableIndexes)if(i<s.state.addresses.length)t.writable.push(s.state.addresses[i]);else throw new Error(`Failed to find address for index ${i} in address lookup table ${r.accountKey.toBase58()}`);for(const i of r.readonlyIndexes)if(i<s.state.addresses.length)t.readonly.push(s.state.addresses[i]);else throw new Error(`Failed to find address for index ${i} in address lookup table ${r.accountKey.toBase58()}`)}return t}static compile(e){const t=Sr.compile(e.instructions,e.payerKey),r=new Array,s={writable:new Array,readonly:new Array},i=e.addressLookupTableAccounts||[];for(const w of i){const b=t.extractTableLookup(w);if(b!==void 0){const[x,{writable:T,readonly:L}]=b;r.push(x),s.writable.push(...T),s.readonly.push(...L)}}const[o,a]=t.getMessageComponents(),g=new Zn(a,s).compileInstructions(e.instructions);return new pn({header:o,staticAccountKeys:a,recentBlockhash:e.recentBlockhash,compiledInstructions:g,addressTableLookups:r})}serialize(){const e=Array();kt(e,this.staticAccountKeys.length);const t=this.serializeInstructions(),r=Array();kt(r,this.compiledInstructions.length);const s=this.serializeAddressTableLookups(),i=Array();kt(i,this.addressTableLookups.length);const o=B.struct([B.u8("prefix"),B.struct([B.u8("numRequiredSignatures"),B.u8("numReadonlySignedAccounts"),B.u8("numReadonlyUnsignedAccounts")],"header"),B.blob(e.length,"staticAccountKeysLength"),B.seq(Ee(),this.staticAccountKeys.length,"staticAccountKeys"),Ee("recentBlockhash"),B.blob(r.length,"instructionsLength"),B.blob(t.length,"serializedInstructions"),B.blob(i.length,"addressTableLookupsLength"),B.blob(s.length,"serializedAddressTableLookups")]),a=new Uint8Array(nn),g=o.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(e),staticAccountKeys:this.staticAccountKeys.map(w=>w.toBytes()),recentBlockhash:pt.decode(this.recentBlockhash),instructionsLength:new Uint8Array(r),serializedInstructions:t,addressTableLookupsLength:new Uint8Array(i),serializedAddressTableLookups:s},a);return a.slice(0,g)}serializeInstructions(){let e=0;const t=new Uint8Array(nn);for(const r of this.compiledInstructions){const s=Array();kt(s,r.accountKeyIndexes.length);const i=Array();kt(i,r.data.length);const o=B.struct([B.u8("programIdIndex"),B.blob(s.length,"encodedAccountKeyIndexesLength"),B.seq(B.u8(),r.accountKeyIndexes.length,"accountKeyIndexes"),B.blob(i.length,"encodedDataLength"),B.blob(r.data.length,"data")]);e+=o.encode({programIdIndex:r.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(s),accountKeyIndexes:r.accountKeyIndexes,encodedDataLength:new Uint8Array(i),data:r.data},t,e)}return t.slice(0,e)}serializeAddressTableLookups(){let e=0;const t=new Uint8Array(nn);for(const r of this.addressTableLookups){const s=Array();kt(s,r.writableIndexes.length);const i=Array();kt(i,r.readonlyIndexes.length);const o=B.struct([Ee("accountKey"),B.blob(s.length,"encodedWritableIndexesLength"),B.seq(B.u8(),r.writableIndexes.length,"writableIndexes"),B.blob(i.length,"encodedReadonlyIndexesLength"),B.seq(B.u8(),r.readonlyIndexes.length,"readonlyIndexes")]);e+=o.encode({accountKey:r.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(s),writableIndexes:r.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(i),readonlyIndexes:r.readonlyIndexes},t,e)}return t.slice(0,e)}static deserialize(e){let t=[...e];const r=Ft(t),s=r&Er;ve(r!==s,"Expected versioned message but received legacy message");const i=s;ve(i===0,`Expected versioned message with version 0 but found version ${i}`);const o={numRequiredSignatures:Ft(t),numReadonlySignedAccounts:Ft(t),numReadonlyUnsignedAccounts:Ft(t)},a=[],f=At(t);for(let L=0;L<f;L++)a.push(new se(It(t,0,Dt)));const g=pt.encode(It(t,0,Dt)),w=At(t),b=[];for(let L=0;L<w;L++){const O=Ft(t),N=At(t),M=It(t,0,N),H=At(t),K=new Uint8Array(It(t,0,H));b.push({programIdIndex:O,accountKeyIndexes:M,data:K})}const x=At(t),T=[];for(let L=0;L<x;L++){const O=new se(It(t,0,Dt)),N=At(t),M=It(t,0,N),H=At(t),K=It(t,0,H);T.push({accountKey:O,writableIndexes:M,readonlyIndexes:K})}return new pn({header:o,staticAccountKeys:a,recentBlockhash:g,compiledInstructions:b,addressTableLookups:T})}}const Ai={deserializeMessageVersion(n){const e=n[0],t=e&Er;return t===e?"legacy":t},deserialize:n=>{const e=Ai.deserializeMessageVersion(n);if(e==="legacy")return Bt.from(n);if(e===0)return pn.deserialize(n);throw new Error(`Transaction message version ${e} deserialization is not supported`)}};let jt=function(n){return n[n.BLOCKHEIGHT_EXCEEDED=0]="BLOCKHEIGHT_EXCEEDED",n[n.PROCESSED=1]="PROCESSED",n[n.TIMED_OUT=2]="TIMED_OUT",n[n.NONCE_INVALID=3]="NONCE_INVALID",n}({});const q0=he.Buffer.alloc(jn).fill(0);class xe{constructor(e){this.keys=void 0,this.programId=void 0,this.data=he.Buffer.alloc(0),this.programId=e.programId,this.keys=e.keys,e.data&&(this.data=e.data)}toJSON(){return{keys:this.keys.map(({pubkey:e,isSigner:t,isWritable:r})=>({pubkey:e.toJSON(),isSigner:t,isWritable:r})),programId:this.programId.toJSON(),data:[...this.data]}}}class Oe{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(e){if(this.signatures=[],this.feePayer=void 0,this.instructions=[],this.recentBlockhash=void 0,this.lastValidBlockHeight=void 0,this.nonceInfo=void 0,this.minNonceContextSlot=void 0,this._message=void 0,this._json=void 0,!!e)if(e.feePayer&&(this.feePayer=e.feePayer),e.signatures&&(this.signatures=e.signatures),Object.prototype.hasOwnProperty.call(e,"nonceInfo")){const{minContextSlot:t,nonceInfo:r}=e;this.minNonceContextSlot=t,this.nonceInfo=r}else if(Object.prototype.hasOwnProperty.call(e,"lastValidBlockHeight")){const{blockhash:t,lastValidBlockHeight:r}=e;this.recentBlockhash=t,this.lastValidBlockHeight=r}else{const{recentBlockhash:t,nonceInfo:r}=e;r&&(this.nonceInfo=r),this.recentBlockhash=t}}toJSON(){return{recentBlockhash:this.recentBlockhash||null,feePayer:this.feePayer?this.feePayer.toJSON():null,nonceInfo:this.nonceInfo?{nonce:this.nonceInfo.nonce,nonceInstruction:this.nonceInfo.nonceInstruction.toJSON()}:null,instructions:this.instructions.map(e=>e.toJSON()),signers:this.signatures.map(({publicKey:e})=>e.toJSON())}}add(...e){if(e.length===0)throw new Error("No instructions");return e.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 xe(t))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let e,t;if(this.nonceInfo?(e=this.nonceInfo.nonce,this.instructions[0]!=this.nonceInfo.nonceInstruction?t=[this.nonceInfo.nonceInstruction,...this.instructions]:t=this.instructions):(e=this.recentBlockhash,t=this.instructions),!e)throw new Error("Transaction recentBlockhash required");t.length<1&&console.warn("No instructions provided");let r;if(this.feePayer)r=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)r=this.signatures[0].publicKey;else throw new Error("Transaction fee payer required");for(let O=0;O<t.length;O++)if(t[O].programId===void 0)throw new Error(`Transaction instruction index ${O} has undefined program id`);const s=[],i=[];t.forEach(O=>{O.keys.forEach(M=>{i.push({...M})});const N=O.programId.toString();s.includes(N)||s.push(N)}),s.forEach(O=>{i.push({pubkey:new se(O),isSigner:!1,isWritable:!1})});const o=[];i.forEach(O=>{const N=O.pubkey.toString(),M=o.findIndex(H=>H.pubkey.toString()===N);M>-1?(o[M].isWritable=o[M].isWritable||O.isWritable,o[M].isSigner=o[M].isSigner||O.isSigner):o.push(O)}),o.sort(function(O,N){if(O.isSigner!==N.isSigner)return O.isSigner?-1:1;if(O.isWritable!==N.isWritable)return O.isWritable?-1:1;const M={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return O.pubkey.toBase58().localeCompare(N.pubkey.toBase58(),"en",M)});const a=o.findIndex(O=>O.pubkey.equals(r));if(a>-1){const[O]=o.splice(a,1);O.isSigner=!0,O.isWritable=!0,o.unshift(O)}else o.unshift({pubkey:r,isSigner:!0,isWritable:!0});for(const O of this.signatures){const N=o.findIndex(M=>M.pubkey.equals(O.publicKey));if(N>-1)o[N].isSigner||(o[N].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."));else throw new Error(`unknown signer: ${O.publicKey.toString()}`)}let f=0,g=0,w=0;const b=[],x=[];o.forEach(({pubkey:O,isSigner:N,isWritable:M})=>{N?(b.push(O.toString()),f+=1,M||(g+=1)):(x.push(O.toString()),M||(w+=1))});const T=b.concat(x),L=t.map(O=>{const{data:N,programId:M}=O;return{programIdIndex:T.indexOf(M.toString()),accounts:O.keys.map(H=>T.indexOf(H.pubkey.toString())),data:pt.encode(N)}});return L.forEach(O=>{ve(O.programIdIndex>=0),O.accounts.forEach(N=>ve(N>=0))}),new Bt({header:{numRequiredSignatures:f,numReadonlySignedAccounts:g,numReadonlyUnsignedAccounts:w},accountKeys:T,recentBlockhash:e,instructions:L})}_compile(){const e=this.compileMessage(),t=e.accountKeys.slice(0,e.header.numRequiredSignatures);return this.signatures.length===t.length&&this.signatures.every((s,i)=>t[i].equals(s.publicKey))||(this.signatures=t.map(r=>({signature:null,publicKey:r}))),e}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(e){return(await e.getFeeForMessage(this.compileMessage())).value}setSigners(...e){if(e.length===0)throw new Error("No signers");const t=new Set;this.signatures=e.filter(r=>{const s=r.toString();return t.has(s)?!1:(t.add(s),!0)}).map(r=>({signature:null,publicKey:r}))}sign(...e){if(e.length===0)throw new Error("No signers");const t=new Set,r=[];for(const i of e){const o=i.publicKey.toString();t.has(o)||(t.add(o),r.push(i))}this.signatures=r.map(i=>({signature:null,publicKey:i.publicKey}));const s=this._compile();this._partialSign(s,...r)}partialSign(...e){if(e.length===0)throw new Error("No signers");const t=new Set,r=[];for(const i of e){const o=i.publicKey.toString();t.has(o)||(t.add(o),r.push(i))}const s=this._compile();this._partialSign(s,...r)}_partialSign(e,...t){const r=e.serialize();t.forEach(s=>{const i=bi(r,s.secretKey);this._addSignature(s.publicKey,we(i))})}addSignature(e,t){this._compile(),this._addSignature(e,t)}_addSignature(e,t){ve(t.length===64);const r=this.signatures.findIndex(s=>e.equals(s.publicKey));if(r<0)throw new Error(`unknown signer: ${e.toString()}`);this.signatures[r].signature=he.Buffer.from(t)}verifySignatures(e=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),e)}_getMessageSignednessErrors(e,t){const r={};for(const{signature:s,publicKey:i}of this.signatures)s===null?t&&(r.missing||=[]).push(i):M0(s,e,i.toBytes())||(r.invalid||=[]).push(i);return r.invalid||r.missing?r:void 0}serialize(e){const{requireAllSignatures:t,verifySignatures:r}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},e),s=this.serializeMessage();if(r){const i=this._getMessageSignednessErrors(s,t);if(i){let o="Signature verification failed.";throw i.invalid&&(o+=`
|
|
11
11
|
Invalid signature for public key${i.invalid.length===1?"":"(s)"} [\`${i.invalid.map(a=>a.toBase58()).join("`, `")}\`].`),i.missing&&(o+=`
|
|
12
|
-
Missing signature for public key${i.missing.length===1?"":"(s)"} [\`${i.missing.map(a=>a.toBase58()).join("`, `")}\`].`),new Error(o)}}return this._serialize(s)}_serialize(e){const{signatures:t}=this,r=[];kt(r,t.length);const s=r.length+t.length*64+e.length,i=he.Buffer.alloc(s);return
|
|
12
|
+
Missing signature for public key${i.missing.length===1?"":"(s)"} [\`${i.missing.map(a=>a.toBase58()).join("`, `")}\`].`),new Error(o)}}return this._serialize(s)}_serialize(e){const{signatures:t}=this,r=[];kt(r,t.length);const s=r.length+t.length*64+e.length,i=he.Buffer.alloc(s);return ve(t.length<256),he.Buffer.from(r).copy(i,0),t.forEach(({signature:o},a)=>{o!==null&&(ve(o.length===64,"signature has invalid length"),he.Buffer.from(o).copy(i,r.length+a*64))}),e.copy(i,r.length+t.length*64),ve(i.length<=nn,`Transaction too large: ${i.length} > ${nn}`),i}get keys(){return ve(this.instructions.length===1),this.instructions[0].keys.map(e=>e.pubkey)}get programId(){return ve(this.instructions.length===1),this.instructions[0].programId}get data(){return ve(this.instructions.length===1),this.instructions[0].data}static from(e){let t=[...e];const r=At(t);let s=[];for(let i=0;i<r;i++){const o=It(t,0,jn);s.push(pt.encode(he.Buffer.from(o)))}return Oe.populate(Bt.from(t),s)}static populate(e,t=[]){const r=new Oe;return r.recentBlockhash=e.recentBlockhash,e.header.numRequiredSignatures>0&&(r.feePayer=e.accountKeys[0]),t.forEach((s,i)=>{const o={signature:s==pt.encode(q0)?null:pt.decode(s),publicKey:e.accountKeys[i]};r.signatures.push(o)}),e.instructions.forEach(s=>{const i=s.accounts.map(o=>{const a=e.accountKeys[o];return{pubkey:a,isSigner:r.signatures.some(f=>f.publicKey.toString()===a.toString())||e.isAccountSigner(o),isWritable:e.isAccountWritable(o)}});r.instructions.push(new xe({keys:i,programId:e.accountKeys[s.programIdIndex],data:pt.decode(s.data)}))}),r._message=e,r._json=r.toJSON(),r}}class Ii{constructor(e){this.payerKey=void 0,this.instructions=void 0,this.recentBlockhash=void 0,this.payerKey=e.payerKey,this.instructions=e.instructions,this.recentBlockhash=e.recentBlockhash}static decompile(e,t){const{header:r,compiledInstructions:s,recentBlockhash:i}=e,{numRequiredSignatures:o,numReadonlySignedAccounts:a,numReadonlyUnsignedAccounts:f}=r,g=o-a;ve(g>0,"Message header is invalid");const w=e.staticAccountKeys.length-o-f;ve(w>=0,"Message header is invalid");const b=e.getAccountKeys(t),x=b.get(0);if(x===void 0)throw new Error("Failed to decompile message because no account keys were found");const T=[];for(const L of s){const O=[];for(const M of L.accountKeyIndexes){const H=b.get(M);if(H===void 0)throw new Error(`Failed to find key for account key index ${M}`);const K=M<o;let Q;K?Q=M<g:M<b.staticAccountKeys.length?Q=M-o<w:Q=M-b.staticAccountKeys.length<b.accountKeysFromLookups.writable.length,O.push({pubkey:H,isSigner:M<r.numRequiredSignatures,isWritable:Q})}const N=b.get(L.programIdIndex);if(N===void 0)throw new Error(`Failed to find program id for program id index ${L.programIdIndex}`);T.push(new xe({programId:N,data:we(L.data),keys:O}))}return new Ii({payerKey:x,instructions:T,recentBlockhash:i})}compileToLegacyMessage(){return Bt.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions})}compileToV0Message(e){return pn.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions,addressLookupTableAccounts:e})}}class vi{get version(){return this.message.version}constructor(e,t){if(this.signatures=void 0,this.message=void 0,t!==void 0)ve(t.length===e.header.numRequiredSignatures,"Expected signatures length to be equal to the number of required signatures"),this.signatures=t;else{const r=[];for(let s=0;s<e.header.numRequiredSignatures;s++)r.push(new Uint8Array(jn));this.signatures=r}this.message=e}serialize(){const e=this.message.serialize(),t=Array();kt(t,this.signatures.length);const r=B.struct([B.blob(t.length,"encodedSignaturesLength"),B.seq(z0(),this.signatures.length,"signatures"),B.blob(e.length,"serializedMessage")]),s=new Uint8Array(2048),i=r.encode({encodedSignaturesLength:new Uint8Array(t),signatures:this.signatures,serializedMessage:e},s);return s.slice(0,i)}static deserialize(e){let t=[...e];const r=[],s=At(t);for(let o=0;o<s;o++)r.push(new Uint8Array(It(t,0,jn)));const i=Ai.deserialize(new Uint8Array(t));return new vi(i,r)}sign(e){const t=this.message.serialize(),r=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures);for(const s of e){const i=r.findIndex(o=>o.equals(s.publicKey));ve(i>=0,`Cannot sign with non signer key ${s.publicKey.toBase58()}`),this.signatures[i]=bi(t,s.secretKey)}}addSignature(e,t){ve(t.byteLength===64,"Signature must be 64 bytes long");const s=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex(i=>i.equals(e));ve(s>=0,`Can not add signature; \`${e.toBase58()}\` is not required to sign this transaction`),this.signatures[s]=t}}const Zo=1e3/(160/64),zt=new se("SysvarC1ock11111111111111111111111111111111"),V0=new se("SysvarEpochSchedu1e111111111111111111111111"),G0=new se("Sysvar1nstructions1111111111111111111111111"),Ar=new se("SysvarRecentB1ockHashes11111111111111111111"),xn=new se("SysvarRent111111111111111111111111111111111"),Y0=new se("SysvarRewards111111111111111111111111111111"),j0=new se("SysvarS1otHashes111111111111111111111111111"),Z0=new se("SysvarS1otHistory11111111111111111111111111"),Ir=new se("SysvarStakeHistory1111111111111111111111111");class Xn extends Error{constructor({action:e,signature:t,transactionMessage:r,logs:s}){const i=s?`Logs:
|
|
13
13
|
${JSON.stringify(s.slice(-10),null,2)}. `:"",o="\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.";let a;switch(e){case"send":a=`Transaction ${t} resulted in an error.
|
|
14
14
|
${r}. `+i+o;break;case"simulate":a=`Simulation failed.
|
|
15
15
|
Message: ${r}.
|
|
16
|
-
`+i+o;break;default:a=`Unknown action '${(f=>f)(e)}'`}super(a),this.signature=void 0,this.transactionMessage=void 0,this.transactionLogs=void 0,this.signature=t,this.transactionMessage=r,this.transactionLogs=s||void 0}get transactionError(){return{message:this.transactionMessage,logs:Array.isArray(this.transactionLogs)?this.transactionLogs:void 0}}get logs(){const e=this.transactionLogs;if(!(e!=null&&typeof e=="object"&&"then"in e))return e}async getLogs(e){return Array.isArray(this.transactionLogs)||(this.transactionLogs=new Promise((t,r)=>{e.getTransaction(this.signature).then(s=>{if(s&&s.meta&&s.meta.logMessages){const i=s.meta.logMessages;this.transactionLogs=i,t(i)}else r(new Error("Log messages not found"))}).catch(r)})),await this.transactionLogs}}const X0={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};class ue extends Error{constructor({code:e,message:t,data:r},s){super(s!=null?`${s}: ${t}`:t),this.code=void 0,this.data=void 0,this.code=e,this.data=r,this.name="SolanaJSONRPCError"}}async function Oi(n,e,t,r){const s=r&&{skipPreflight:r.skipPreflight,preflightCommitment:r.preflightCommitment||r.commitment,maxRetries:r.maxRetries,minContextSlot:r.minContextSlot},i=await n.sendTransaction(e,t,s);let o;if(e.recentBlockhash!=null&&e.lastValidBlockHeight!=null)o=(await n.confirmTransaction({abortSignal:r?.abortSignal,signature:i,blockhash:e.recentBlockhash,lastValidBlockHeight:e.lastValidBlockHeight},r&&r.commitment)).value;else if(e.minNonceContextSlot!=null&&e.nonceInfo!=null){const{nonceInstruction:a}=e.nonceInfo,f=a.keys[0].pubkey;o=(await n.confirmTransaction({abortSignal:r?.abortSignal,minContextSlot:e.minNonceContextSlot,nonceAccountPubkey:f,nonceValue:e.nonceInfo.nonce,signature:i},r&&r.commitment)).value}else r?.abortSignal!=null&&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."),o=(await n.confirmTransaction(i,r&&r.commitment)).value;if(o.err)throw i!=null?new Xn({action:"send",signature:i,transactionMessage:`Status: (${JSON.stringify(o)})`}):new Error(`Transaction ${i} failed (${JSON.stringify(o)})`);return i}function gn(n){return new Promise(e=>setTimeout(e,n))}function Ae(n,e){const t=n.layout.span>=0?n.layout.span:Yo(n,e),r=he.Buffer.alloc(t),s=Object.assign({instruction:n.index},e);return n.layout.encode(s,r),r}function ke(n,e){let t;try{t=n.layout.decode(e)}catch(r){throw new Error("invalid instruction; "+r)}if(t.instruction!==n.index)throw new Error(`invalid instruction; instruction index mismatch ${t.instruction} != ${n.index}`);return t}const Xo=B.nu64("lamportsPerSignature"),Jo=B.struct([B.u32("version"),B.u32("state"),Ee("authorizedPubkey"),Ee("nonce"),B.struct([Xo],"feeCalculator")]),ki=Jo.span;class vr{constructor(e){this.authorizedPubkey=void 0,this.nonce=void 0,this.feeCalculator=void 0,this.authorizedPubkey=e.authorizedPubkey,this.nonce=e.nonce,this.feeCalculator=e.feeCalculator}static fromAccountData(e){const t=Jo.decode(we(e),0);return new vr({authorizedPubkey:new ie(t.authorizedPubkey),nonce:new ie(t.nonce).toString(),feeCalculator:t.feeCalculator})}}function Bn(n){const e=B.blob(8,n),t=e.decode.bind(e),r=e.encode.bind(e),s=e,i=Cd();return s.decode=(o,a)=>{const f=t(o,a);return i.decode(f)},s.encode=(o,a,f)=>{const g=i.encode(o);return r(g,a,f)},s}class J0{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);const r=B.u32("instruction").decode(e.data);let s;for(const[i,o]of Object.entries(Me))if(o.index==r){s=i;break}if(!s)throw new Error("Instruction type incorrect; not a SystemInstruction");return s}static decodeCreateAccount(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{lamports:t,space:r,programId:s}=ke(Me.Create,e.data);return{fromPubkey:e.keys[0].pubkey,newAccountPubkey:e.keys[1].pubkey,lamports:t,space:r,programId:new ie(s)}}static decodeTransfer(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{lamports:t}=ke(Me.Transfer,e.data);return{fromPubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,lamports:t}}static decodeTransferWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{lamports:t,seed:r,programId:s}=ke(Me.TransferWithSeed,e.data);return{fromPubkey:e.keys[0].pubkey,basePubkey:e.keys[1].pubkey,toPubkey:e.keys[2].pubkey,lamports:t,seed:r,programId:new ie(s)}}static decodeAllocate(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);const{space:t}=ke(Me.Allocate,e.data);return{accountPubkey:e.keys[0].pubkey,space:t}}static decodeAllocateWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);const{base:t,seed:r,space:s,programId:i}=ke(Me.AllocateWithSeed,e.data);return{accountPubkey:e.keys[0].pubkey,basePubkey:new ie(t),seed:r,space:s,programId:new ie(i)}}static decodeAssign(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);const{programId:t}=ke(Me.Assign,e.data);return{accountPubkey:e.keys[0].pubkey,programId:new ie(t)}}static decodeAssignWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);const{base:t,seed:r,programId:s}=ke(Me.AssignWithSeed,e.data);return{accountPubkey:e.keys[0].pubkey,basePubkey:new ie(t),seed:r,programId:new ie(s)}}static decodeCreateWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{base:t,seed:r,lamports:s,space:i,programId:o}=ke(Me.CreateWithSeed,e.data);return{fromPubkey:e.keys[0].pubkey,newAccountPubkey:e.keys[1].pubkey,basePubkey:new ie(t),seed:r,lamports:s,space:i,programId:new ie(o)}}static decodeNonceInitialize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{authorized:t}=ke(Me.InitializeNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,authorizedPubkey:new ie(t)}}static decodeNonceAdvance(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3),ke(Me.AdvanceNonceAccount,e.data),{noncePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey}}static decodeNonceWithdraw(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,5);const{lamports:t}=ke(Me.WithdrawNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[4].pubkey,lamports:t}}static decodeNonceAuthorize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{authorized:t}=ke(Me.AuthorizeNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[1].pubkey,newAuthorizedPubkey:new ie(t)}}static checkProgramId(e){if(!e.equals(gt.programId))throw new Error("invalid instruction; programId is not SystemProgram")}static checkKeyLength(e,t){if(e.length<t)throw new Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}}const Me=Object.freeze({Create:{index:0,layout:B.struct([B.u32("instruction"),B.ns64("lamports"),B.ns64("space"),Ee("programId")])},Assign:{index:1,layout:B.struct([B.u32("instruction"),Ee("programId")])},Transfer:{index:2,layout:B.struct([B.u32("instruction"),Bn("lamports")])},CreateWithSeed:{index:3,layout:B.struct([B.u32("instruction"),Ee("base"),dn("seed"),B.ns64("lamports"),B.ns64("space"),Ee("programId")])},AdvanceNonceAccount:{index:4,layout:B.struct([B.u32("instruction")])},WithdrawNonceAccount:{index:5,layout:B.struct([B.u32("instruction"),B.ns64("lamports")])},InitializeNonceAccount:{index:6,layout:B.struct([B.u32("instruction"),Ee("authorized")])},AuthorizeNonceAccount:{index:7,layout:B.struct([B.u32("instruction"),Ee("authorized")])},Allocate:{index:8,layout:B.struct([B.u32("instruction"),B.ns64("space")])},AllocateWithSeed:{index:9,layout:B.struct([B.u32("instruction"),Ee("base"),dn("seed"),B.ns64("space"),Ee("programId")])},AssignWithSeed:{index:10,layout:B.struct([B.u32("instruction"),Ee("base"),dn("seed"),Ee("programId")])},TransferWithSeed:{index:11,layout:B.struct([B.u32("instruction"),Bn("lamports"),dn("seed"),Ee("programId")])},UpgradeNonceAccount:{index:12,layout:B.struct([B.u32("instruction")])}});class gt{constructor(){}static createAccount(e){const t=Me.Create,r=Ae(t,{lamports:e.lamports,space:e.space,programId:we(e.programId.toBuffer())});return new xe({keys:[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:r})}static transfer(e){let t,r;if("basePubkey"in e){const s=Me.TransferWithSeed;t=Ae(s,{lamports:BigInt(e.lamports),seed:e.seed,programId:we(e.programId.toBuffer())}),r=[{pubkey:e.fromPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}else{const s=Me.Transfer;t=Ae(s,{lamports:BigInt(e.lamports)}),r=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}return new xe({keys:r,programId:this.programId,data:t})}static assign(e){let t,r;if("basePubkey"in e){const s=Me.AssignWithSeed;t=Ae(s,{base:we(e.basePubkey.toBuffer()),seed:e.seed,programId:we(e.programId.toBuffer())}),r=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{const s=Me.Assign;t=Ae(s,{programId:we(e.programId.toBuffer())}),r=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new xe({keys:r,programId:this.programId,data:t})}static createAccountWithSeed(e){const t=Me.CreateWithSeed,r=Ae(t,{base:we(e.basePubkey.toBuffer()),seed:e.seed,lamports:e.lamports,space:e.space,programId:we(e.programId.toBuffer())});let s=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!1,isWritable:!0}];return e.basePubkey.equals(e.fromPubkey)||s.push({pubkey:e.basePubkey,isSigner:!0,isWritable:!1}),new xe({keys:s,programId:this.programId,data:r})}static createNonceAccount(e){const t=new Oe;"basePubkey"in e&&"seed"in e?t.add(gt.createAccountWithSeed({fromPubkey:e.fromPubkey,newAccountPubkey:e.noncePubkey,basePubkey:e.basePubkey,seed:e.seed,lamports:e.lamports,space:ki,programId:this.programId})):t.add(gt.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.noncePubkey,lamports:e.lamports,space:ki,programId:this.programId}));const r={noncePubkey:e.noncePubkey,authorizedPubkey:e.authorizedPubkey};return t.add(this.nonceInitialize(r)),t}static nonceInitialize(e){const t=Me.InitializeNonceAccount,r=Ae(t,{authorized:we(e.authorizedPubkey.toBuffer())}),s={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:Ar,isSigner:!1,isWritable:!1},{pubkey:xn,isSigner:!1,isWritable:!1}],programId:this.programId,data:r};return new xe(s)}static nonceAdvance(e){const t=Me.AdvanceNonceAccount,r=Ae(t),s={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:Ar,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r};return new xe(s)}static nonceWithdraw(e){const t=Me.WithdrawNonceAccount,r=Ae(t,{lamports:e.lamports});return new xe({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0},{pubkey:Ar,isSigner:!1,isWritable:!1},{pubkey:xn,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r})}static nonceAuthorize(e){const t=Me.AuthorizeNonceAccount,r=Ae(t,{authorized:we(e.newAuthorizedPubkey.toBuffer())});return new xe({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r})}static allocate(e){let t,r;if("basePubkey"in e){const s=Me.AllocateWithSeed;t=Ae(s,{base:we(e.basePubkey.toBuffer()),seed:e.seed,space:e.space,programId:we(e.programId.toBuffer())}),r=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{const s=Me.Allocate;t=Ae(s,{space:e.space}),r=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new xe({keys:r,programId:this.programId,data:t})}}gt.programId=new ie("11111111111111111111111111111111");const Q0=nn-300;class mn{constructor(){}static getMinNumSignatures(e){return 2*(Math.ceil(e/mn.chunkSize)+1+1)}static async load(e,t,r,s,i){{const b=await e.getMinimumBalanceForRentExemption(i.length),x=await e.getAccountInfo(r.publicKey,"confirmed");let T=null;if(x!==null){if(x.executable)return console.error("Program load failed, account is already executable"),!1;x.data.length!==i.length&&(T=T||new Oe,T.add(gt.allocate({accountPubkey:r.publicKey,space:i.length}))),x.owner.equals(s)||(T=T||new Oe,T.add(gt.assign({accountPubkey:r.publicKey,programId:s}))),x.lamports<b&&(T=T||new Oe,T.add(gt.transfer({fromPubkey:t.publicKey,toPubkey:r.publicKey,lamports:b-x.lamports})))}else T=new Oe().add(gt.createAccount({fromPubkey:t.publicKey,newAccountPubkey:r.publicKey,lamports:b>0?b:1,space:i.length,programId:s}));T!==null&&await Oi(e,T,[t,r],{commitment:"confirmed"})}const o=B.struct([B.u32("instruction"),B.u32("offset"),B.u32("bytesLength"),B.u32("bytesLengthPadding"),B.seq(B.u8("byte"),B.offset(B.u32(),-8),"bytes")]),a=mn.chunkSize;let f=0,g=i,w=[];for(;g.length>0;){const b=g.slice(0,a),x=he.Buffer.alloc(a+16);o.encode({instruction:0,offset:f,bytes:b,bytesLength:0,bytesLengthPadding:0},x);const T=new Oe().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0}],programId:s,data:x});w.push(Oi(e,T,[t,r],{commitment:"confirmed"})),e._rpcEndpoint.includes("solana.com")&&await gn(1e3/4),f+=a,g=g.slice(a)}await Promise.all(w);{const b=B.struct([B.u32("instruction")]),x=he.Buffer.alloc(b.span);b.encode({instruction:1},x);const T=new Oe().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0},{pubkey:xn,isSigner:!1,isWritable:!1}],programId:s,data:x}),L="processed",O=await e.sendTransaction(T,[t,r],{preflightCommitment:L}),{context:N,value:M}=await e.confirmTransaction({signature:O,lastValidBlockHeight:T.lastValidBlockHeight,blockhash:T.recentBlockhash},L);if(M.err)throw new Error(`Transaction ${O} failed (${JSON.stringify(M)})`);for(;;){try{if(await e.getSlot({commitment:L})>N.slot)break}catch{}await new Promise(H=>setTimeout(H,Math.round(Zo/2)))}}return!0}}mn.chunkSize=Q0;const ep=new ie("BPFLoader2111111111111111111111111111111111");class tp{static getMinNumSignatures(e){return mn.getMinNumSignatures(e)}static load(e,t,r,s,i){return mn.load(e,t,r,i,s)}}function np(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Ti,Qo;function rp(){if(Qo)return Ti;Qo=1;var n=Object.prototype.toString,e=Object.keys||function(r){var s=[];for(var i in r)s.push(i);return s};function t(r,s){var i,o,a,f,g,w,b;if(r===!0)return"true";if(r===!1)return"false";switch(typeof r){case"object":if(r===null)return null;if(r.toJSON&&typeof r.toJSON=="function")return t(r.toJSON(),s);if(b=n.call(r),b==="[object Array]"){for(a="[",o=r.length-1,i=0;i<o;i++)a+=t(r[i],!0)+",";return o>-1&&(a+=t(r[i],!0)),a+"]"}else if(b==="[object Object]"){for(f=e(r).sort(),o=f.length,a="",i=0;i<o;)g=f[i],w=t(r[g],!1),w!==void 0&&(a&&(a+=","),a+=JSON.stringify(g)+":"+w),i++;return"{"+a+"}"}else return JSON.stringify(r);case"function":case"undefined":return s?null:void 0;case"string":return JSON.stringify(r);default:return isFinite(r)?r:null}}return Ti=function(r){var s=t(r,!1);if(s!==void 0)return""+s},Ti}var ip=rp(),ea=np(ip);const Jn=32;function Ni(n){let e=0;for(;n>1;)n/=2,e++;return e}function sp(n){return n===0?1:(n--,n|=n>>1,n|=n>>2,n|=n>>4,n|=n>>8,n|=n>>16,n|=n>>32,n+1)}class ta{constructor(e,t,r,s,i){this.slotsPerEpoch=void 0,this.leaderScheduleSlotOffset=void 0,this.warmup=void 0,this.firstNormalEpoch=void 0,this.firstNormalSlot=void 0,this.slotsPerEpoch=e,this.leaderScheduleSlotOffset=t,this.warmup=r,this.firstNormalEpoch=s,this.firstNormalSlot=i}getEpoch(e){return this.getEpochAndSlotIndex(e)[0]}getEpochAndSlotIndex(e){if(e<this.firstNormalSlot){const t=Ni(sp(e+Jn+1))-Ni(Jn)-1,r=this.getSlotsInEpoch(t),s=e-(r-Jn);return[t,s]}else{const t=e-this.firstNormalSlot,r=Math.floor(t/this.slotsPerEpoch),s=this.firstNormalEpoch+r,i=t%this.slotsPerEpoch;return[s,i]}}getFirstSlotInEpoch(e){return e<=this.firstNormalEpoch?(Math.pow(2,e)-1)*Jn:(e-this.firstNormalEpoch)*this.slotsPerEpoch+this.firstNormalSlot}getLastSlotInEpoch(e){return this.getFirstSlotInEpoch(e)+this.getSlotsInEpoch(e)-1}getSlotsInEpoch(e){return e<this.firstNormalEpoch?Math.pow(2,e+Ni(Jn)):this.slotsPerEpoch}}var op=globalThis.fetch;class ap extends g0{constructor(e,t,r){const s=i=>{const o=d0(i,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...t});return"socket"in o?this.underlyingSocket=o.socket:this.underlyingSocket=o,o};super(s,e,t,r),this.underlyingSocket=void 0}call(...e){const t=this.underlyingSocket?.readyState;return t===1?super.call(...e):Promise.reject(new Error("Tried to call a JSON-RPC method `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+")"))}notify(...e){const t=this.underlyingSocket?.readyState;return t===1?super.notify(...e):Promise.reject(new Error("Tried to send a JSON-RPC notification `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+")"))}}function cp(n,e){let t;try{t=n.layout.decode(e)}catch(r){throw new Error("invalid instruction; "+r)}if(t.typeIndex!==n.index)throw new Error(`invalid account data; account type mismatch ${t.typeIndex} != ${n.index}`);return t}const na=56;class xi{constructor(e){this.key=void 0,this.state=void 0,this.key=e.key,this.state=e.state}isActive(){const e=BigInt("0xffffffffffffffff");return this.state.deactivationSlot===e}static deserialize(e){const t=cp(up,e),r=e.length-na;Ie(r>=0,"lookup table is invalid"),Ie(r%32===0,"lookup table is invalid");const s=r/32,{addresses:i}=B.struct([B.seq(Ee(),s,"addresses")]).decode(e.slice(na));return{deactivationSlot:t.deactivationSlot,lastExtendedSlot:t.lastExtendedSlot,lastExtendedSlotStartIndex:t.lastExtendedStartIndex,authority:t.authority.length!==0?new ie(t.authority[0]):void 0,addresses:i.map(o=>new ie(o))}}}const up={index:1,layout:B.struct([B.u32("typeIndex"),Bn("deactivationSlot"),B.nu64("lastExtendedSlot"),B.u8("lastExtendedStartIndex"),B.u8(),B.seq(Ee(),B.offset(B.u8(),-1),"authority")])},lp=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;function hp(n){const e=n.match(lp);if(e==null)throw TypeError(`Failed to validate endpoint URL \`${n}\``);const[t,r,s,i]=e,o=n.startsWith("https:")?"wss:":"ws:",a=s==null?null:parseInt(s.slice(1),10),f=a==null?"":`:${a+1}`;return`${o}//${r}${f}${i}`}const Ve=Vn(ai(ie),re(),n=>new ie(n)),ra=ci([re(),qe("base64")]),Bi=Vn(ai(he.Buffer),ra,n=>he.Buffer.from(n[0],"base64")),ia=30*1e3;function fp(n){if(/^https?:/.test(n)===!1)throw new TypeError("Endpoint URL must start with `http:` or `https:`.");return n}function Pe(n){let e,t;if(typeof n=="string")e=n;else if(n){const{commitment:r,...s}=n;e=r,t=s}return{commitment:e,config:t}}function sa(n){return n.map(e=>"memcmp"in e?{...e,memcmp:{...e.memcmp,encoding:e.memcmp.encoding??"base58"}}:e)}function oa(n){return St([te({jsonrpc:qe("2.0"),id:re(),result:n}),te({jsonrpc:qe("2.0"),id:re(),error:te({code:Tn(),message:re(),data:le(zd())})})])}const dp=oa(Tn());function be(n){return Vn(oa(n),dp,e=>"error"in e?e:{...e,result:se(e.result,n)})}function Ye(n){return be(te({context:te({slot:$()}),value:n}))}function Or(n){return te({context:te({slot:$()}),value:n})}function Li(n,e){return n===0?new pn({header:e.header,staticAccountKeys:e.accountKeys.map(t=>new ie(t)),recentBlockhash:e.recentBlockhash,compiledInstructions:e.instructions.map(t=>({programIdIndex:t.programIdIndex,accountKeyIndexes:t.accounts,data:pt.decode(t.data)})),addressTableLookups:e.addressTableLookups}):new Bt(e)}const pp=te({foundation:$(),foundationTerm:$(),initial:$(),taper:$(),terminal:$()}),gp=be(oe(ae(te({epoch:$(),effectiveSlot:$(),amount:$(),postBalance:$(),commission:le(ae($()))})))),mp=oe(te({slot:$(),prioritizationFee:$()})),_p=te({total:$(),validator:$(),foundation:$(),epoch:$()}),yp=te({epoch:$(),slotIndex:$(),slotsInEpoch:$(),absoluteSlot:$(),blockHeight:le($()),transactionCount:le($())}),wp=te({slotsPerEpoch:$(),leaderScheduleSlotOffset:$(),warmup:Ut(),firstNormalEpoch:$(),firstNormalSlot:$()}),bp=bo(re(),oe($())),_n=ae(St([te({}),re()])),Rp=te({err:_n}),Ep=qe("receivedSignature"),Sp=te({"solana-core":re(),"feature-set":le($())}),Ap=te({program:re(),programId:Ve,parsed:Tn()}),Ip=te({programId:Ve,accounts:oe(Ve),data:re()}),aa=Ye(te({err:ae(St([te({}),re()])),logs:ae(oe(re())),accounts:le(ae(oe(ae(te({executable:Ut(),owner:re(),lamports:$(),data:oe(re()),rentEpoch:le($())}))))),unitsConsumed:le($()),returnData:le(ae(te({programId:re(),data:ci([re(),qe("base64")])}))),innerInstructions:le(ae(oe(te({index:$(),instructions:oe(St([Ap,Ip]))}))))})),vp=Ye(te({byIdentity:bo(re(),oe($())),range:te({firstSlot:$(),lastSlot:$()})}));function Op(n,e,t,r,s,i){const o=t||op;let a;i!=null&&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.");let f;return r&&(f=async(w,b)=>{const x=await new Promise((T,L)=>{try{r(w,b,(O,N)=>T([O,N]))}catch(O){L(O)}});return await o(...x)}),new u0(async(w,b)=>{const x={method:"POST",body:w,agent:a,headers:Object.assign({"Content-Type":"application/json"},e||{},Og)};try{let T=5,L,O=500;for(;f?L=await f(n,x):L=await o(n,x),!(L.status!==429||s===!0||(T-=1,T===0));)console.error(`Server responded with ${L.status} ${L.statusText}. Retrying after ${O}ms delay...`),await gn(O),O*=2;const N=await L.text();L.ok?b(null,N):b(new Error(`${L.status} ${L.statusText}: ${N}`))}catch(T){T instanceof Error&&b(T)}},{})}function kp(n){return(e,t)=>new Promise((r,s)=>{n.request(e,t,(i,o)=>{if(i){s(i);return}r(o)})})}function Tp(n){return e=>new Promise((t,r)=>{e.length===0&&t([]);const s=e.map(i=>n.request(i.methodName,i.args));n.request(s,(i,o)=>{if(i){r(i);return}t(o)})})}const Np=be(pp),xp=be(_p),Bp=be(mp),Lp=be(yp),Cp=be(wp),Mp=be(bp),Pp=be($()),Up=Ye(te({total:$(),circulating:$(),nonCirculating:$(),nonCirculatingAccounts:oe(Ve)})),Ci=te({amount:re(),uiAmount:ae($()),decimals:$(),uiAmountString:le(re())}),Dp=Ye(oe(te({address:Ve,amount:re(),uiAmount:ae($()),decimals:$(),uiAmountString:le(re())}))),Fp=Ye(oe(te({pubkey:Ve,account:te({executable:Ut(),owner:Ve,lamports:$(),data:Bi,rentEpoch:$()})}))),Mi=te({program:re(),parsed:Tn(),space:$()}),zp=Ye(oe(te({pubkey:Ve,account:te({executable:Ut(),owner:Ve,lamports:$(),data:Mi,rentEpoch:$()})}))),Kp=Ye(oe(te({lamports:$(),address:Ve}))),Qn=te({executable:Ut(),owner:Ve,lamports:$(),data:Bi,rentEpoch:$()}),$p=te({pubkey:Ve,account:Qn}),Hp=Vn(St([ai(he.Buffer),Mi]),St([ra,Mi]),n=>Array.isArray(n)?se(n,Bi):n),Pi=te({executable:Ut(),owner:Ve,lamports:$(),data:Hp,rentEpoch:$()}),Wp=te({pubkey:Ve,account:Pi}),qp=te({state:St([qe("active"),qe("inactive"),qe("activating"),qe("deactivating")]),active:$(),inactive:$()}),Vp=be(oe(te({signature:re(),slot:$(),err:_n,memo:ae(re()),blockTime:le(ae($()))}))),Gp=be(oe(te({signature:re(),slot:$(),err:_n,memo:ae(re()),blockTime:le(ae($()))}))),Yp=te({subscription:$(),result:Or(Qn)}),jp=te({pubkey:Ve,account:Qn}),Zp=te({subscription:$(),result:Or(jp)}),Xp=te({parent:$(),slot:$(),root:$()}),Jp=te({subscription:$(),result:Xp}),Qp=St([te({type:St([qe("firstShredReceived"),qe("completed"),qe("optimisticConfirmation"),qe("root")]),slot:$(),timestamp:$()}),te({type:qe("createdBank"),parent:$(),slot:$(),timestamp:$()}),te({type:qe("frozen"),slot:$(),timestamp:$(),stats:te({numTransactionEntries:$(),numSuccessfulTransactions:$(),numFailedTransactions:$(),maxTransactionsPerEntry:$()})}),te({type:qe("dead"),slot:$(),timestamp:$(),err:re()})]),eg=te({subscription:$(),result:Qp}),tg=te({subscription:$(),result:Or(St([Rp,Ep]))}),ng=te({subscription:$(),result:$()}),rg=te({pubkey:re(),gossip:ae(re()),tpu:ae(re()),rpc:ae(re()),version:ae(re())}),ca=te({votePubkey:re(),nodePubkey:re(),activatedStake:$(),epochVoteAccount:Ut(),epochCredits:oe(ci([$(),$(),$()])),commission:$(),lastVote:$(),rootSlot:ae($())}),ig=be(te({current:oe(ca),delinquent:oe(ca)})),sg=St([qe("processed"),qe("confirmed"),qe("finalized")]),og=te({slot:$(),confirmations:ae($()),err:_n,confirmationStatus:le(sg)}),ag=Ye(oe(ae(og))),cg=be($()),ua=te({accountKey:Ve,writableIndexes:oe($()),readonlyIndexes:oe($())}),Ui=te({signatures:oe(re()),message:te({accountKeys:oe(re()),header:te({numRequiredSignatures:$(),numReadonlySignedAccounts:$(),numReadonlyUnsignedAccounts:$()}),instructions:oe(te({accounts:oe($()),data:re(),programIdIndex:$()})),recentBlockhash:re(),addressTableLookups:le(oe(ua))})}),la=te({pubkey:Ve,signer:Ut(),writable:Ut(),source:le(St([qe("transaction"),qe("lookupTable")]))}),ha=te({accountKeys:oe(la),signatures:oe(re())}),fa=te({parsed:Tn(),program:re(),programId:Ve}),da=te({accounts:oe(Ve),data:re(),programId:Ve}),ug=St([da,fa]),lg=St([te({parsed:Tn(),program:re(),programId:re()}),te({accounts:oe(re()),data:re(),programId:re()})]),pa=Vn(ug,lg,n=>"accounts"in n?se(n,da):se(n,fa)),ga=te({signatures:oe(re()),message:te({accountKeys:oe(la),instructions:oe(pa),recentBlockhash:re(),addressTableLookups:le(ae(oe(ua)))})}),kr=te({accountIndex:$(),mint:re(),owner:le(re()),programId:le(re()),uiTokenAmount:Ci}),ma=te({writable:oe(Ve),readonly:oe(Ve)}),Tr=te({err:_n,fee:$(),innerInstructions:le(ae(oe(te({index:$(),instructions:oe(te({accounts:oe($()),data:re(),programIdIndex:$()}))})))),preBalances:oe($()),postBalances:oe($()),logMessages:le(ae(oe(re()))),preTokenBalances:le(ae(oe(kr))),postTokenBalances:le(ae(oe(kr))),loadedAddresses:le(ma),computeUnitsConsumed:le($())}),Di=te({err:_n,fee:$(),innerInstructions:le(ae(oe(te({index:$(),instructions:oe(pa)})))),preBalances:oe($()),postBalances:oe($()),logMessages:le(ae(oe(re()))),preTokenBalances:le(ae(oe(kr))),postTokenBalances:le(ae(oe(kr))),loadedAddresses:le(ma),computeUnitsConsumed:le($())}),Ln=St([qe(0),qe("legacy")]),yn=te({pubkey:re(),lamports:$(),postBalance:ae($()),rewardType:ae(re()),commission:le(ae($()))}),hg=be(ae(te({blockhash:re(),previousBlockhash:re(),parentSlot:$(),transactions:oe(te({transaction:Ui,meta:ae(Tr),version:le(Ln)})),rewards:le(oe(yn)),blockTime:ae($()),blockHeight:ae($())}))),fg=be(ae(te({blockhash:re(),previousBlockhash:re(),parentSlot:$(),rewards:le(oe(yn)),blockTime:ae($()),blockHeight:ae($())}))),dg=be(ae(te({blockhash:re(),previousBlockhash:re(),parentSlot:$(),transactions:oe(te({transaction:ha,meta:ae(Tr),version:le(Ln)})),rewards:le(oe(yn)),blockTime:ae($()),blockHeight:ae($())}))),pg=be(ae(te({blockhash:re(),previousBlockhash:re(),parentSlot:$(),transactions:oe(te({transaction:ga,meta:ae(Di),version:le(Ln)})),rewards:le(oe(yn)),blockTime:ae($()),blockHeight:ae($())}))),gg=be(ae(te({blockhash:re(),previousBlockhash:re(),parentSlot:$(),transactions:oe(te({transaction:ha,meta:ae(Di),version:le(Ln)})),rewards:le(oe(yn)),blockTime:ae($()),blockHeight:ae($())}))),mg=be(ae(te({blockhash:re(),previousBlockhash:re(),parentSlot:$(),rewards:le(oe(yn)),blockTime:ae($()),blockHeight:ae($())}))),_g=be(ae(te({blockhash:re(),previousBlockhash:re(),parentSlot:$(),transactions:oe(te({transaction:Ui,meta:ae(Tr)})),rewards:le(oe(yn)),blockTime:ae($())}))),_a=be(ae(te({blockhash:re(),previousBlockhash:re(),parentSlot:$(),signatures:oe(re()),blockTime:ae($())}))),Fi=be(ae(te({slot:$(),meta:ae(Tr),blockTime:le(ae($())),transaction:Ui,version:le(Ln)}))),Nr=be(ae(te({slot:$(),transaction:ga,meta:ae(Di),blockTime:le(ae($())),version:le(Ln)}))),yg=Ye(te({blockhash:re(),lastValidBlockHeight:$()})),wg=Ye(Ut()),bg=te({slot:$(),numTransactions:$(),numSlots:$(),samplePeriodSecs:$()}),Rg=be(oe(bg)),Eg=Ye(ae(te({feeCalculator:te({lamportsPerSignature:$()})}))),Sg=be(re()),Ag=be(re()),Ig=te({err:_n,logs:oe(re()),signature:re()}),vg=te({result:Or(Ig),subscription:$()}),Og={"solana-client":"js/1.0.0-maintenance"};class kg{constructor(e,t){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 g={};return async w=>{const{commitment:b,config:x}=Pe(w),T=this._buildArgs([],b,void 0,x),L=ea(T);return g[L]=g[L]??(async()=>{try{const O=await this._rpcRequest("getBlockHeight",T),N=se(O,be($()));if("error"in N)throw new ue(N.error,"failed to get block height information");return N.result}finally{delete g[L]}})(),await g[L]}})();let r,s,i,o,a,f;t&&typeof t=="string"?this._commitment=t:t&&(this._commitment=t.commitment,this._confirmTransactionInitialTimeout=t.confirmTransactionInitialTimeout,r=t.wsEndpoint,s=t.httpHeaders,i=t.fetch,o=t.fetchMiddleware,a=t.disableRetryOnRateLimit,f=t.httpAgent),this._rpcEndpoint=fp(e),this._rpcWsEndpoint=r||hp(e),this._rpcClient=Op(e,s,i,o,a,f),this._rpcRequest=kp(this._rpcClient),this._rpcBatchRequest=Tp(this._rpcClient),this._rpcWebSocket=new ap(this._rpcWsEndpoint,{autoconnect:!1,max_reconnects:1/0}),this._rpcWebSocket.on("open",this._wsOnOpen.bind(this)),this._rpcWebSocket.on("error",this._wsOnError.bind(this)),this._rpcWebSocket.on("close",this._wsOnClose.bind(this)),this._rpcWebSocket.on("accountNotification",this._wsOnAccountNotification.bind(this)),this._rpcWebSocket.on("programNotification",this._wsOnProgramAccountNotification.bind(this)),this._rpcWebSocket.on("slotNotification",this._wsOnSlotNotification.bind(this)),this._rpcWebSocket.on("slotsUpdatesNotification",this._wsOnSlotUpdatesNotification.bind(this)),this._rpcWebSocket.on("signatureNotification",this._wsOnSignatureNotification.bind(this)),this._rpcWebSocket.on("rootNotification",this._wsOnRootNotification.bind(this)),this._rpcWebSocket.on("logsNotification",this._wsOnLogsNotification.bind(this))}get commitment(){return this._commitment}get rpcEndpoint(){return this._rpcEndpoint}async getBalanceAndContext(e,t){const{commitment:r,config:s}=Pe(t),i=this._buildArgs([e.toBase58()],r,void 0,s),o=await this._rpcRequest("getBalance",i),a=se(o,Ye($()));if("error"in a)throw new ue(a.error,`failed to get balance for ${e.toBase58()}`);return a.result}async getBalance(e,t){return await this.getBalanceAndContext(e,t).then(r=>r.value).catch(r=>{throw new Error("failed to get balance of account "+e.toBase58()+": "+r)})}async getBlockTime(e){const t=await this._rpcRequest("getBlockTime",[e]),r=se(t,be(ae($())));if("error"in r)throw new ue(r.error,`failed to get block time for slot ${e}`);return r.result}async getMinimumLedgerSlot(){const e=await this._rpcRequest("minimumLedgerSlot",[]),t=se(e,be($()));if("error"in t)throw new ue(t.error,"failed to get minimum ledger slot");return t.result}async getFirstAvailableBlock(){const e=await this._rpcRequest("getFirstAvailableBlock",[]),t=se(e,Pp);if("error"in t)throw new ue(t.error,"failed to get first available block");return t.result}async getSupply(e){let t={};typeof e=="string"?t={commitment:e}:e?t={...e,commitment:e&&e.commitment||this.commitment}:t={commitment:this.commitment};const r=await this._rpcRequest("getSupply",[t]),s=se(r,Up);if("error"in s)throw new ue(s.error,"failed to get supply");return s.result}async getTokenSupply(e,t){const r=this._buildArgs([e.toBase58()],t),s=await this._rpcRequest("getTokenSupply",r),i=se(s,Ye(Ci));if("error"in i)throw new ue(i.error,"failed to get token supply");return i.result}async getTokenAccountBalance(e,t){const r=this._buildArgs([e.toBase58()],t),s=await this._rpcRequest("getTokenAccountBalance",r),i=se(s,Ye(Ci));if("error"in i)throw new ue(i.error,"failed to get token account balance");return i.result}async getTokenAccountsByOwner(e,t,r){const{commitment:s,config:i}=Pe(r);let o=[e.toBase58()];"mint"in t?o.push({mint:t.mint.toBase58()}):o.push({programId:t.programId.toBase58()});const a=this._buildArgs(o,s,"base64",i),f=await this._rpcRequest("getTokenAccountsByOwner",a),g=se(f,Fp);if("error"in g)throw new ue(g.error,`failed to get token accounts owned by account ${e.toBase58()}`);return g.result}async getParsedTokenAccountsByOwner(e,t,r){let s=[e.toBase58()];"mint"in t?s.push({mint:t.mint.toBase58()}):s.push({programId:t.programId.toBase58()});const i=this._buildArgs(s,r,"jsonParsed"),o=await this._rpcRequest("getTokenAccountsByOwner",i),a=se(o,zp);if("error"in a)throw new ue(a.error,`failed to get token accounts owned by account ${e.toBase58()}`);return a.result}async getLargestAccounts(e){const t={...e,commitment:e&&e.commitment||this.commitment},r=t.filter||t.commitment?[t]:[],s=await this._rpcRequest("getLargestAccounts",r),i=se(s,Kp);if("error"in i)throw new ue(i.error,"failed to get largest accounts");return i.result}async getTokenLargestAccounts(e,t){const r=this._buildArgs([e.toBase58()],t),s=await this._rpcRequest("getTokenLargestAccounts",r),i=se(s,Dp);if("error"in i)throw new ue(i.error,"failed to get token largest accounts");return i.result}async getAccountInfoAndContext(e,t){const{commitment:r,config:s}=Pe(t),i=this._buildArgs([e.toBase58()],r,"base64",s),o=await this._rpcRequest("getAccountInfo",i),a=se(o,Ye(ae(Qn)));if("error"in a)throw new ue(a.error,`failed to get info about account ${e.toBase58()}`);return a.result}async getParsedAccountInfo(e,t){const{commitment:r,config:s}=Pe(t),i=this._buildArgs([e.toBase58()],r,"jsonParsed",s),o=await this._rpcRequest("getAccountInfo",i),a=se(o,Ye(ae(Pi)));if("error"in a)throw new ue(a.error,`failed to get info about account ${e.toBase58()}`);return a.result}async getAccountInfo(e,t){try{return(await this.getAccountInfoAndContext(e,t)).value}catch(r){throw new Error("failed to get info about account "+e.toBase58()+": "+r)}}async getMultipleParsedAccounts(e,t){const{commitment:r,config:s}=Pe(t),i=e.map(g=>g.toBase58()),o=this._buildArgs([i],r,"jsonParsed",s),a=await this._rpcRequest("getMultipleAccounts",o),f=se(a,Ye(oe(ae(Pi))));if("error"in f)throw new ue(f.error,`failed to get info for accounts ${i}`);return f.result}async getMultipleAccountsInfoAndContext(e,t){const{commitment:r,config:s}=Pe(t),i=e.map(g=>g.toBase58()),o=this._buildArgs([i],r,"base64",s),a=await this._rpcRequest("getMultipleAccounts",o),f=se(a,Ye(oe(ae(Qn))));if("error"in f)throw new ue(f.error,`failed to get info for accounts ${i}`);return f.result}async getMultipleAccountsInfo(e,t){return(await this.getMultipleAccountsInfoAndContext(e,t)).value}async getStakeActivation(e,t,r){const{commitment:s,config:i}=Pe(t),o=this._buildArgs([e.toBase58()],s,void 0,{...i,epoch:r??i?.epoch}),a=await this._rpcRequest("getStakeActivation",o),f=se(a,be(qp));if("error"in f)throw new ue(f.error,`failed to get Stake Activation ${e.toBase58()}`);return f.result}async getProgramAccounts(e,t){const{commitment:r,config:s}=Pe(t),{encoding:i,...o}=s||{},a=this._buildArgs([e.toBase58()],r,i||"base64",{...o,...o.filters?{filters:sa(o.filters)}:null}),f=await this._rpcRequest("getProgramAccounts",a),g=oe($p),w=o.withContext===!0?se(f,Ye(g)):se(f,be(g));if("error"in w)throw new ue(w.error,`failed to get accounts owned by program ${e.toBase58()}`);return w.result}async getParsedProgramAccounts(e,t){const{commitment:r,config:s}=Pe(t),i=this._buildArgs([e.toBase58()],r,"jsonParsed",s),o=await this._rpcRequest("getProgramAccounts",i),a=se(o,be(oe(Wp)));if("error"in a)throw new ue(a.error,`failed to get accounts owned by program ${e.toBase58()}`);return a.result}async confirmTransaction(e,t){let r;if(typeof e=="string")r=e;else{const i=e;if(i.abortSignal?.aborted)return Promise.reject(i.abortSignal.reason);r=i.signature}let s;try{s=pt.decode(r)}catch{throw new Error("signature must be base58 encoded: "+r)}return Ie(s.length===64,"signature has invalid length"),typeof e=="string"?await this.confirmTransactionUsingLegacyTimeoutStrategy({commitment:t||this.commitment,signature:r}):"lastValidBlockHeight"in e?await this.confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:t||this.commitment,strategy:e}):await this.confirmTransactionUsingDurableNonceStrategy({commitment:t||this.commitment,strategy:e})}getCancellationPromise(e){return new Promise((t,r)=>{e!=null&&(e.aborted?r(e.reason):e.addEventListener("abort",()=>{r(e.reason)}))})}getTransactionConfirmationPromise({commitment:e,signature:t}){let r,s,i=!1;const o=new Promise((f,g)=>{try{r=this.onSignature(t,(b,x)=>{r=void 0;const T={context:x,value:b};f({__type:jt.PROCESSED,response:T})},e);const w=new Promise(b=>{r==null?b():s=this._onSubscriptionStateChange(r,x=>{x==="subscribed"&&b()})});(async()=>{if(await w,i)return;const b=await this.getSignatureStatus(t);if(i||b==null)return;const{context:x,value:T}=b;if(T!=null)if(T?.err)g(T.err);else{switch(e){case"confirmed":case"single":case"singleGossip":{if(T.confirmationStatus==="processed")return;break}case"finalized":case"max":case"root":{if(T.confirmationStatus==="processed"||T.confirmationStatus==="confirmed")return;break}case"processed":case"recent":}i=!0,f({__type:jt.PROCESSED,response:{context:x,value:T}})}})()}catch(w){g(w)}});return{abortConfirmation:()=>{s&&(s(),s=void 0),r!=null&&(this.removeSignatureListener(r),r=void 0)},confirmationPromise:o}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:e,strategy:{abortSignal:t,lastValidBlockHeight:r,signature:s}}){let i=!1;const o=new Promise(b=>{const x=async()=>{try{return await this.getBlockHeight(e)}catch{return-1}};(async()=>{let T=await x();if(!i){for(;T<=r;)if(await gn(1e3),i||(T=await x(),i))return;b({__type:jt.BLOCKHEIGHT_EXCEEDED})}})()}),{abortConfirmation:a,confirmationPromise:f}=this.getTransactionConfirmationPromise({commitment:e,signature:s}),g=this.getCancellationPromise(t);let w;try{const b=await Promise.race([g,f,o]);if(b.__type===jt.PROCESSED)w=b.response;else throw new Ei(s)}finally{i=!0,a()}return w}async confirmTransactionUsingDurableNonceStrategy({commitment:e,strategy:{abortSignal:t,minContextSlot:r,nonceAccountPubkey:s,nonceValue:i,signature:o}}){let a=!1;const f=new Promise(T=>{let L=i,O=null;const N=async()=>{try{const{context:M,value:H}=await this.getNonceAndContext(s,{commitment:e,minContextSlot:r});return O=M.slot,H?.nonce}catch{return L}};(async()=>{if(L=await N(),!a)for(;;){if(i!==L){T({__type:jt.NONCE_INVALID,slotInWhichNonceDidAdvance:O});return}if(await gn(2e3),a||(L=await N(),a))return}})()}),{abortConfirmation:g,confirmationPromise:w}=this.getTransactionConfirmationPromise({commitment:e,signature:o}),b=this.getCancellationPromise(t);let x;try{const T=await Promise.race([b,w,f]);if(T.__type===jt.PROCESSED)x=T.response;else{let L;for(;;){const O=await this.getSignatureStatus(o);if(O==null)break;if(O.context.slot<(T.slotInWhichNonceDidAdvance??r)){await gn(400);continue}L=O;break}if(L?.value){const O=e||"finalized",{confirmationStatus:N}=L.value;switch(O){case"processed":case"recent":if(N!=="processed"&&N!=="confirmed"&&N!=="finalized")throw new Nn(o);break;case"confirmed":case"single":case"singleGossip":if(N!=="confirmed"&&N!=="finalized")throw new Nn(o);break;case"finalized":case"max":case"root":if(N!=="finalized")throw new Nn(o);break;default:}x={context:L.context,value:{err:L.value.err}}}else throw new Nn(o)}}finally{a=!0,g()}return x}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:e,signature:t}){let r;const s=new Promise(f=>{let g=this._confirmTransactionInitialTimeout||6e4;switch(e){case"processed":case"recent":case"single":case"confirmed":case"singleGossip":{g=this._confirmTransactionInitialTimeout||3e4;break}}r=setTimeout(()=>f({__type:jt.TIMED_OUT,timeoutMs:g}),g)}),{abortConfirmation:i,confirmationPromise:o}=this.getTransactionConfirmationPromise({commitment:e,signature:t});let a;try{const f=await Promise.race([o,s]);if(f.__type===jt.PROCESSED)a=f.response;else throw new Si(t,f.timeoutMs/1e3)}finally{clearTimeout(r),i()}return a}async getClusterNodes(){const e=await this._rpcRequest("getClusterNodes",[]),t=se(e,be(oe(rg)));if("error"in t)throw new ue(t.error,"failed to get cluster nodes");return t.result}async getVoteAccounts(e){const t=this._buildArgs([],e),r=await this._rpcRequest("getVoteAccounts",t),s=se(r,ig);if("error"in s)throw new ue(s.error,"failed to get vote accounts");return s.result}async getSlot(e){const{commitment:t,config:r}=Pe(e),s=this._buildArgs([],t,void 0,r),i=await this._rpcRequest("getSlot",s),o=se(i,be($()));if("error"in o)throw new ue(o.error,"failed to get slot");return o.result}async getSlotLeader(e){const{commitment:t,config:r}=Pe(e),s=this._buildArgs([],t,void 0,r),i=await this._rpcRequest("getSlotLeader",s),o=se(i,be(re()));if("error"in o)throw new ue(o.error,"failed to get slot leader");return o.result}async getSlotLeaders(e,t){const r=[e,t],s=await this._rpcRequest("getSlotLeaders",r),i=se(s,be(oe(Ve)));if("error"in i)throw new ue(i.error,"failed to get slot leaders");return i.result}async getSignatureStatus(e,t){const{context:r,value:s}=await this.getSignatureStatuses([e],t);Ie(s.length===1);const i=s[0];return{context:r,value:i}}async getSignatureStatuses(e,t){const r=[e];t&&r.push(t);const s=await this._rpcRequest("getSignatureStatuses",r),i=se(s,ag);if("error"in i)throw new ue(i.error,"failed to get signature status");return i.result}async getTransactionCount(e){const{commitment:t,config:r}=Pe(e),s=this._buildArgs([],t,void 0,r),i=await this._rpcRequest("getTransactionCount",s),o=se(i,be($()));if("error"in o)throw new ue(o.error,"failed to get transaction count");return o.result}async getTotalSupply(e){return(await this.getSupply({commitment:e,excludeNonCirculatingAccountsList:!0})).value.total}async getInflationGovernor(e){const t=this._buildArgs([],e),r=await this._rpcRequest("getInflationGovernor",t),s=se(r,Np);if("error"in s)throw new ue(s.error,"failed to get inflation");return s.result}async getInflationReward(e,t,r){const{commitment:s,config:i}=Pe(r),o=this._buildArgs([e.map(g=>g.toBase58())],s,void 0,{...i,epoch:t??i?.epoch}),a=await this._rpcRequest("getInflationReward",o),f=se(a,gp);if("error"in f)throw new ue(f.error,"failed to get inflation reward");return f.result}async getInflationRate(){const e=await this._rpcRequest("getInflationRate",[]),t=se(e,xp);if("error"in t)throw new ue(t.error,"failed to get inflation rate");return t.result}async getEpochInfo(e){const{commitment:t,config:r}=Pe(e),s=this._buildArgs([],t,void 0,r),i=await this._rpcRequest("getEpochInfo",s),o=se(i,Lp);if("error"in o)throw new ue(o.error,"failed to get epoch info");return o.result}async getEpochSchedule(){const e=await this._rpcRequest("getEpochSchedule",[]),t=se(e,Cp);if("error"in t)throw new ue(t.error,"failed to get epoch schedule");const r=t.result;return new ta(r.slotsPerEpoch,r.leaderScheduleSlotOffset,r.warmup,r.firstNormalEpoch,r.firstNormalSlot)}async getLeaderSchedule(){const e=await this._rpcRequest("getLeaderSchedule",[]),t=se(e,Mp);if("error"in t)throw new ue(t.error,"failed to get leader schedule");return t.result}async getMinimumBalanceForRentExemption(e,t){const r=this._buildArgs([e],t),s=await this._rpcRequest("getMinimumBalanceForRentExemption",r),i=se(s,cg);return"error"in i?(console.warn("Unable to fetch minimum balance for rent exemption"),0):i.result}async getRecentBlockhashAndContext(e){const{context:t,value:{blockhash:r}}=await this.getLatestBlockhashAndContext(e);return{context:t,value:{blockhash:r,feeCalculator:{get lamportsPerSignature(){throw new Error("The capability to fetch `lamportsPerSignature` using the `getRecentBlockhash` API is no longer offered by the network. Use the `getFeeForMessage` API to obtain the fee for a given message.")},toJSON(){return{}}}}}}async getRecentPerformanceSamples(e){const t=await this._rpcRequest("getRecentPerformanceSamples",e?[e]:[]),r=se(t,Rg);if("error"in r)throw new ue(r.error,"failed to get recent performance samples");return r.result}async getFeeCalculatorForBlockhash(e,t){const r=this._buildArgs([e],t),s=await this._rpcRequest("getFeeCalculatorForBlockhash",r),i=se(s,Eg);if("error"in i)throw new ue(i.error,"failed to get fee calculator");const{context:o,value:a}=i.result;return{context:o,value:a!==null?a.feeCalculator:null}}async getFeeForMessage(e,t){const r=we(e.serialize()).toString("base64"),s=this._buildArgs([r],t),i=await this._rpcRequest("getFeeForMessage",s),o=se(i,Ye(ae($())));if("error"in o)throw new ue(o.error,"failed to get fee for message");if(o.result===null)throw new Error("invalid blockhash");return o.result}async getRecentPrioritizationFees(e){const t=e?.lockedWritableAccounts?.map(o=>o.toBase58()),r=t?.length?[t]:[],s=await this._rpcRequest("getRecentPrioritizationFees",r),i=se(s,Bp);if("error"in i)throw new ue(i.error,"failed to get recent prioritization fees");return i.result}async getRecentBlockhash(e){try{return(await this.getRecentBlockhashAndContext(e)).value}catch(t){throw new Error("failed to get recent blockhash: "+t)}}async getLatestBlockhash(e){try{return(await this.getLatestBlockhashAndContext(e)).value}catch(t){throw new Error("failed to get recent blockhash: "+t)}}async getLatestBlockhashAndContext(e){const{commitment:t,config:r}=Pe(e),s=this._buildArgs([],t,void 0,r),i=await this._rpcRequest("getLatestBlockhash",s),o=se(i,yg);if("error"in o)throw new ue(o.error,"failed to get latest blockhash");return o.result}async isBlockhashValid(e,t){const{commitment:r,config:s}=Pe(t),i=this._buildArgs([e],r,void 0,s),o=await this._rpcRequest("isBlockhashValid",i),a=se(o,wg);if("error"in a)throw new ue(a.error,"failed to determine if the blockhash `"+e+"`is valid");return a.result}async getVersion(){const e=await this._rpcRequest("getVersion",[]),t=se(e,be(Sp));if("error"in t)throw new ue(t.error,"failed to get version");return t.result}async getGenesisHash(){const e=await this._rpcRequest("getGenesisHash",[]),t=se(e,be(re()));if("error"in t)throw new ue(t.error,"failed to get genesis hash");return t.result}async getBlock(e,t){const{commitment:r,config:s}=Pe(t),i=this._buildArgsAtLeastConfirmed([e],r,void 0,s),o=await this._rpcRequest("getBlock",i);try{switch(s?.transactionDetails){case"accounts":{const a=se(o,dg);if("error"in a)throw a.error;return a.result}case"none":{const a=se(o,fg);if("error"in a)throw a.error;return a.result}default:{const a=se(o,hg);if("error"in a)throw a.error;const{result:f}=a;return f?{...f,transactions:f.transactions.map(({transaction:g,meta:w,version:b})=>({meta:w,transaction:{...g,message:Li(b,g.message)},version:b}))}:null}}}catch(a){throw new ue(a,"failed to get confirmed block")}}async getParsedBlock(e,t){const{commitment:r,config:s}=Pe(t),i=this._buildArgsAtLeastConfirmed([e],r,"jsonParsed",s),o=await this._rpcRequest("getBlock",i);try{switch(s?.transactionDetails){case"accounts":{const a=se(o,gg);if("error"in a)throw a.error;return a.result}case"none":{const a=se(o,mg);if("error"in a)throw a.error;return a.result}default:{const a=se(o,pg);if("error"in a)throw a.error;return a.result}}}catch(a){throw new ue(a,"failed to get block")}}async getBlockProduction(e){let t,r;if(typeof e=="string")r=e;else if(e){const{commitment:a,...f}=e;r=a,t=f}const s=this._buildArgs([],r,"base64",t),i=await this._rpcRequest("getBlockProduction",s),o=se(i,vp);if("error"in o)throw new ue(o.error,"failed to get block production information");return o.result}async getTransaction(e,t){const{commitment:r,config:s}=Pe(t),i=this._buildArgsAtLeastConfirmed([e],r,void 0,s),o=await this._rpcRequest("getTransaction",i),a=se(o,Fi);if("error"in a)throw new ue(a.error,"failed to get transaction");const f=a.result;return f&&{...f,transaction:{...f.transaction,message:Li(f.version,f.transaction.message)}}}async getParsedTransaction(e,t){const{commitment:r,config:s}=Pe(t),i=this._buildArgsAtLeastConfirmed([e],r,"jsonParsed",s),o=await this._rpcRequest("getTransaction",i),a=se(o,Nr);if("error"in a)throw new ue(a.error,"failed to get transaction");return a.result}async getParsedTransactions(e,t){const{commitment:r,config:s}=Pe(t),i=e.map(f=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([f],r,"jsonParsed",s)}));return(await this._rpcBatchRequest(i)).map(f=>{const g=se(f,Nr);if("error"in g)throw new ue(g.error,"failed to get transactions");return g.result})}async getTransactions(e,t){const{commitment:r,config:s}=Pe(t),i=e.map(f=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([f],r,void 0,s)}));return(await this._rpcBatchRequest(i)).map(f=>{const g=se(f,Fi);if("error"in g)throw new ue(g.error,"failed to get transactions");const w=g.result;return w&&{...w,transaction:{...w.transaction,message:Li(w.version,w.transaction.message)}}})}async getConfirmedBlock(e,t){const r=this._buildArgsAtLeastConfirmed([e],t),s=await this._rpcRequest("getBlock",r),i=se(s,_g);if("error"in i)throw new ue(i.error,"failed to get confirmed block");const o=i.result;if(!o)throw new Error("Confirmed block "+e+" not found");const a={...o,transactions:o.transactions.map(({transaction:f,meta:g})=>{const w=new Bt(f.message);return{meta:g,transaction:{...f,message:w}}})};return{...a,transactions:a.transactions.map(({transaction:f,meta:g})=>({meta:g,transaction:Oe.populate(f.message,f.signatures)}))}}async getBlocks(e,t,r){const s=this._buildArgsAtLeastConfirmed(t!==void 0?[e,t]:[e],r),i=await this._rpcRequest("getBlocks",s),o=se(i,be(oe($())));if("error"in o)throw new ue(o.error,"failed to get blocks");return o.result}async getBlockSignatures(e,t){const r=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:"signatures",rewards:!1}),s=await this._rpcRequest("getBlock",r),i=se(s,_a);if("error"in i)throw new ue(i.error,"failed to get block");const o=i.result;if(!o)throw new Error("Block "+e+" not found");return o}async getConfirmedBlockSignatures(e,t){const r=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:"signatures",rewards:!1}),s=await this._rpcRequest("getBlock",r),i=se(s,_a);if("error"in i)throw new ue(i.error,"failed to get confirmed block");const o=i.result;if(!o)throw new Error("Confirmed block "+e+" not found");return o}async getConfirmedTransaction(e,t){const r=this._buildArgsAtLeastConfirmed([e],t),s=await this._rpcRequest("getTransaction",r),i=se(s,Fi);if("error"in i)throw new ue(i.error,"failed to get transaction");const o=i.result;if(!o)return o;const a=new Bt(o.transaction.message),f=o.transaction.signatures;return{...o,transaction:Oe.populate(a,f)}}async getParsedConfirmedTransaction(e,t){const r=this._buildArgsAtLeastConfirmed([e],t,"jsonParsed"),s=await this._rpcRequest("getTransaction",r),i=se(s,Nr);if("error"in i)throw new ue(i.error,"failed to get confirmed transaction");return i.result}async getParsedConfirmedTransactions(e,t){const r=e.map(o=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([o],t,"jsonParsed")}));return(await this._rpcBatchRequest(r)).map(o=>{const a=se(o,Nr);if("error"in a)throw new ue(a.error,"failed to get confirmed transactions");return a.result})}async getConfirmedSignaturesForAddress(e,t,r){let s={},i=await this.getFirstAvailableBlock();for(;!("until"in s)&&(t--,!(t<=0||t<i));)try{const f=await this.getConfirmedBlockSignatures(t,"finalized");f.signatures.length>0&&(s.until=f.signatures[f.signatures.length-1].toString())}catch(f){if(f instanceof Error&&f.message.includes("skipped"))continue;throw f}let o=await this.getSlot("finalized");for(;!("before"in s)&&(r++,!(r>o));)try{const f=await this.getConfirmedBlockSignatures(r);f.signatures.length>0&&(s.before=f.signatures[f.signatures.length-1].toString())}catch(f){if(f instanceof Error&&f.message.includes("skipped"))continue;throw f}return(await this.getConfirmedSignaturesForAddress2(e,s)).map(f=>f.signature)}async getConfirmedSignaturesForAddress2(e,t,r){const s=this._buildArgsAtLeastConfirmed([e.toBase58()],r,void 0,t),i=await this._rpcRequest("getConfirmedSignaturesForAddress2",s),o=se(i,Vp);if("error"in o)throw new ue(o.error,"failed to get confirmed signatures for address");return o.result}async getSignaturesForAddress(e,t,r){const s=this._buildArgsAtLeastConfirmed([e.toBase58()],r,void 0,t),i=await this._rpcRequest("getSignaturesForAddress",s),o=se(i,Gp);if("error"in o)throw new ue(o.error,"failed to get signatures for address");return o.result}async getAddressLookupTable(e,t){const{context:r,value:s}=await this.getAccountInfoAndContext(e,t);let i=null;return s!==null&&(i=new xi({key:e,state:xi.deserialize(s.data)})),{context:r,value:i}}async getNonceAndContext(e,t){const{context:r,value:s}=await this.getAccountInfoAndContext(e,t);let i=null;return s!==null&&(i=vr.fromAccountData(s.data)),{context:r,value:i}}async getNonce(e,t){return await this.getNonceAndContext(e,t).then(r=>r.value).catch(r=>{throw new Error("failed to get nonce for account "+e.toBase58()+": "+r)})}async requestAirdrop(e,t){const r=await this._rpcRequest("requestAirdrop",[e.toBase58(),t]),s=se(r,Sg);if("error"in s)throw new ue(s.error,`airdrop to ${e.toBase58()} failed`);return s.result}async _blockhashWithExpiryBlockHeight(e){if(!e){for(;this._pollingBlockhash;)await gn(100);const r=Date.now()-this._blockhashInfo.lastFetch>=ia;if(this._blockhashInfo.latestBlockhash!==null&&!r)return this._blockhashInfo.latestBlockhash}return await this._pollNewBlockhash()}async _pollNewBlockhash(){this._pollingBlockhash=!0;try{const e=Date.now(),t=this._blockhashInfo.latestBlockhash,r=t?t.blockhash:null;for(let s=0;s<50;s++){const i=await this.getLatestBlockhash("finalized");if(r!==i.blockhash)return this._blockhashInfo={latestBlockhash:i,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},i;await gn(Zo/2)}throw new Error(`Unable to obtain a new blockhash after ${Date.now()-e}ms`)}finally{this._pollingBlockhash=!1}}async getStakeMinimumDelegation(e){const{commitment:t,config:r}=Pe(e),s=this._buildArgs([],t,"base64",r),i=await this._rpcRequest("getStakeMinimumDelegation",s),o=se(i,Ye($()));if("error"in o)throw new ue(o.error,"failed to get stake minimum delegation");return o.result}async simulateTransaction(e,t,r){if("message"in e){const O=e.serialize(),N=he.Buffer.from(O).toString("base64");if(Array.isArray(t)||r!==void 0)throw new Error("Invalid arguments");const M=t||{};M.encoding="base64","commitment"in M||(M.commitment=this.commitment),t&&typeof t=="object"&&"innerInstructions"in t&&(M.innerInstructions=t.innerInstructions);const H=[N,M],K=await this._rpcRequest("simulateTransaction",H),Q=se(K,aa);if("error"in Q)throw new Error("failed to simulate transaction: "+Q.error.message);return Q.result}let s;if(e instanceof Oe){let L=e;s=new Oe,s.feePayer=L.feePayer,s.instructions=e.instructions,s.nonceInfo=L.nonceInfo,s.signatures=L.signatures}else s=Oe.populate(e),s._message=s._json=void 0;if(t!==void 0&&!Array.isArray(t))throw new Error("Invalid arguments");const i=t;if(s.nonceInfo&&i)s.sign(...i);else{let L=this._disableBlockhashCaching;for(;;){const O=await this._blockhashWithExpiryBlockHeight(L);if(s.lastValidBlockHeight=O.lastValidBlockHeight,s.recentBlockhash=O.blockhash,!i)break;if(s.sign(...i),!s.signature)throw new Error("!signature");const N=s.signature.toString("base64");if(!this._blockhashInfo.simulatedSignatures.includes(N)&&!this._blockhashInfo.transactionSignatures.includes(N)){this._blockhashInfo.simulatedSignatures.push(N);break}else L=!0}}const o=s._compile(),a=o.serialize(),g=s._serialize(a).toString("base64"),w={encoding:"base64",commitment:this.commitment};if(r){const L=(Array.isArray(r)?r:o.nonProgramIds()).map(O=>O.toBase58());w.accounts={encoding:"base64",addresses:L}}i&&(w.sigVerify=!0),t&&typeof t=="object"&&"innerInstructions"in t&&(w.innerInstructions=t.innerInstructions);const b=[g,w],x=await this._rpcRequest("simulateTransaction",b),T=se(x,aa);if("error"in T){let L;if("data"in T.error&&(L=T.error.data.logs,L&&Array.isArray(L))){const O=`
|
|
17
|
-
`,N=O+L.join(O);console.error(T.error.message,N)}throw new Xn({action:"simulate",signature:"",transactionMessage:T.error.message,logs:L})}return T.result}async sendTransaction(e,t,r){if("version"in e){if(t&&Array.isArray(t))throw new Error("Invalid arguments");const o=e.serialize();return await this.sendRawTransaction(o,t)}if(t===void 0||!Array.isArray(t))throw new Error("Invalid arguments");const s=t;if(e.nonceInfo)e.sign(...s);else{let o=this._disableBlockhashCaching;for(;;){const a=await this._blockhashWithExpiryBlockHeight(o);if(e.lastValidBlockHeight=a.lastValidBlockHeight,e.recentBlockhash=a.blockhash,e.sign(...s),!e.signature)throw new Error("!signature");const f=e.signature.toString("base64");if(this._blockhashInfo.transactionSignatures.includes(f))o=!0;else{this._blockhashInfo.transactionSignatures.push(f);break}}}const i=e.serialize();return await this.sendRawTransaction(i,r)}async sendRawTransaction(e,t){const r=we(e).toString("base64");return await this.sendEncodedTransaction(r,t)}async sendEncodedTransaction(e,t){const r={encoding:"base64"},s=t&&t.skipPreflight,i=s===!0?"processed":t&&t.preflightCommitment||this.commitment;t&&t.maxRetries!=null&&(r.maxRetries=t.maxRetries),t&&t.minContextSlot!=null&&(r.minContextSlot=t.minContextSlot),s&&(r.skipPreflight=s),i&&(r.preflightCommitment=i);const o=[e,r],a=await this._rpcRequest("sendTransaction",o),f=se(a,Ag);if("error"in f){let g;throw"data"in f.error&&(g=f.error.data.logs),new Xn({action:s?"send":"simulate",signature:"",transactionMessage:f.error.message,logs:g})}return f.result}_wsOnOpen(){this._rpcWebSocketConnected=!0,this._rpcWebSocketHeartbeat=setInterval(()=>{(async()=>{try{await this._rpcWebSocket.notify("ping")}catch{}})()},5e3),this._updateSubscriptions()}_wsOnError(e){this._rpcWebSocketConnected=!1,console.error("ws error:",e.message)}_wsOnClose(e){if(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),e===1e3){this._updateSubscriptions();return}this._subscriptionCallbacksByServerSubscriptionId={},Object.entries(this._subscriptionsByHash).forEach(([t,r])=>{this._setSubscription(t,{...r,state:"pending"})})}_setSubscription(e,t){const r=this._subscriptionsByHash[e]?.state;if(this._subscriptionsByHash[e]=t,r!==t.state){const s=this._subscriptionStateChangeCallbacksByHash[e];s&&s.forEach(i=>{try{i(t.state)}catch{}})}}_onSubscriptionStateChange(e,t){const r=this._subscriptionHashByClientSubscriptionId[e];if(r==null)return()=>{};const s=this._subscriptionStateChangeCallbacksByHash[r]||=new Set;return s.add(t),()=>{s.delete(t),s.size===0&&delete this._subscriptionStateChangeCallbacksByHash[r]}}async _updateSubscriptions(){if(Object.keys(this._subscriptionsByHash).length===0){this._rpcWebSocketConnected&&(this._rpcWebSocketConnected=!1,this._rpcWebSocketIdleTimeout=setTimeout(()=>{this._rpcWebSocketIdleTimeout=null;try{this._rpcWebSocket.close()}catch(r){r instanceof Error&&console.log(`Error when closing socket connection: ${r.message}`)}},500));return}if(this._rpcWebSocketIdleTimeout!==null&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketConnected=!0),!this._rpcWebSocketConnected){this._rpcWebSocket.connect();return}const e=this._rpcWebSocketGeneration,t=()=>e===this._rpcWebSocketGeneration;await Promise.all(Object.keys(this._subscriptionsByHash).map(async r=>{const s=this._subscriptionsByHash[r];if(s!==void 0)switch(s.state){case"pending":case"unsubscribed":if(s.callbacks.size===0){delete this._subscriptionsByHash[r],s.state==="unsubscribed"&&delete this._subscriptionCallbacksByServerSubscriptionId[s.serverSubscriptionId],await this._updateSubscriptions();return}await(async()=>{const{args:i,method:o}=s;try{this._setSubscription(r,{...s,state:"subscribing"});const a=await this._rpcWebSocket.call(o,i);this._setSubscription(r,{...s,serverSubscriptionId:a,state:"subscribed"}),this._subscriptionCallbacksByServerSubscriptionId[a]=s.callbacks,await this._updateSubscriptions()}catch(a){if(console.error(`Received ${a instanceof Error?"":"JSON-RPC "}error calling \`${o}\``,{args:i,error:a}),!t())return;this._setSubscription(r,{...s,state:"pending"}),await this._updateSubscriptions()}})();break;case"subscribed":s.callbacks.size===0&&await(async()=>{const{serverSubscriptionId:i,unsubscribeMethod:o}=s;if(this._subscriptionsAutoDisposedByRpc.has(i))this._subscriptionsAutoDisposedByRpc.delete(i);else{this._setSubscription(r,{...s,state:"unsubscribing"}),this._setSubscription(r,{...s,state:"unsubscribing"});try{await this._rpcWebSocket.call(o,[i])}catch(a){if(a instanceof Error&&console.error(`${o} error:`,a.message),!t())return;this._setSubscription(r,{...s,state:"subscribed"}),await this._updateSubscriptions();return}}this._setSubscription(r,{...s,state:"unsubscribed"}),await this._updateSubscriptions()})();break}}))}_handleServerNotification(e,t){const r=this._subscriptionCallbacksByServerSubscriptionId[e];r!==void 0&&r.forEach(s=>{try{s(...t)}catch(i){console.error(i)}})}_wsOnAccountNotification(e){const{result:t,subscription:r}=se(e,Yp);this._handleServerNotification(r,[t.value,t.context])}_makeSubscription(e,t){const r=this._nextClientSubscriptionId++,s=ea([e.method,t]),i=this._subscriptionsByHash[s];return i===void 0?this._subscriptionsByHash[s]={...e,args:t,callbacks:new Set([e.callback]),state:"pending"}:i.callbacks.add(e.callback),this._subscriptionHashByClientSubscriptionId[r]=s,this._subscriptionDisposeFunctionsByClientSubscriptionId[r]=async()=>{delete this._subscriptionDisposeFunctionsByClientSubscriptionId[r],delete this._subscriptionHashByClientSubscriptionId[r];const o=this._subscriptionsByHash[s];Ie(o!==void 0,`Could not find a \`Subscription\` when tearing down client subscription #${r}`),o.callbacks.delete(e.callback),await this._updateSubscriptions()},this._updateSubscriptions(),r}onAccountChange(e,t,r){const{commitment:s,config:i}=Pe(r),o=this._buildArgs([e.toBase58()],s||this._commitment||"finalized","base64",i);return this._makeSubscription({callback:t,method:"accountSubscribe",unsubscribeMethod:"accountUnsubscribe"},o)}async removeAccountChangeListener(e){await this._unsubscribeClientSubscription(e,"account change")}_wsOnProgramAccountNotification(e){const{result:t,subscription:r}=se(e,Zp);this._handleServerNotification(r,[{accountId:t.value.pubkey,accountInfo:t.value.account},t.context])}onProgramAccountChange(e,t,r,s){const{commitment:i,config:o}=Pe(r),a=this._buildArgs([e.toBase58()],i||this._commitment||"finalized","base64",o||(s?{filters:sa(s)}:void 0));return this._makeSubscription({callback:t,method:"programSubscribe",unsubscribeMethod:"programUnsubscribe"},a)}async removeProgramAccountChangeListener(e){await this._unsubscribeClientSubscription(e,"program account change")}onLogs(e,t,r){const s=this._buildArgs([typeof e=="object"?{mentions:[e.toString()]}:e],r||this._commitment||"finalized");return this._makeSubscription({callback:t,method:"logsSubscribe",unsubscribeMethod:"logsUnsubscribe"},s)}async removeOnLogsListener(e){await this._unsubscribeClientSubscription(e,"logs")}_wsOnLogsNotification(e){const{result:t,subscription:r}=se(e,vg);this._handleServerNotification(r,[t.value,t.context])}_wsOnSlotNotification(e){const{result:t,subscription:r}=se(e,Jp);this._handleServerNotification(r,[t])}onSlotChange(e){return this._makeSubscription({callback:e,method:"slotSubscribe",unsubscribeMethod:"slotUnsubscribe"},[])}async removeSlotChangeListener(e){await this._unsubscribeClientSubscription(e,"slot change")}_wsOnSlotUpdatesNotification(e){const{result:t,subscription:r}=se(e,eg);this._handleServerNotification(r,[t])}onSlotUpdate(e){return this._makeSubscription({callback:e,method:"slotsUpdatesSubscribe",unsubscribeMethod:"slotsUpdatesUnsubscribe"},[])}async removeSlotUpdateListener(e){await this._unsubscribeClientSubscription(e,"slot update")}async _unsubscribeClientSubscription(e,t){const r=this._subscriptionDisposeFunctionsByClientSubscriptionId[e];r?await r():console.warn(`Ignored unsubscribe request because an active subscription with id \`${e}\` for '${t}' events could not be found.`)}_buildArgs(e,t,r,s){const i=t||this._commitment;if(i||r||s){let o={};r&&(o.encoding=r),i&&(o.commitment=i),s&&(o=Object.assign(o,s)),e.push(o)}return e}_buildArgsAtLeastConfirmed(e,t,r,s){const i=t||this._commitment;if(i&&!["confirmed","finalized"].includes(i))throw new Error("Using Connection with default commitment: `"+this._commitment+"`, but method requires at least `confirmed`");return this._buildArgs(e,t,r,s)}_wsOnSignatureNotification(e){const{result:t,subscription:r}=se(e,tg);t.value!=="receivedSignature"&&this._subscriptionsAutoDisposedByRpc.add(r),this._handleServerNotification(r,t.value==="receivedSignature"?[{type:"received"},t.context]:[{type:"status",result:t.value},t.context])}onSignature(e,t,r){const s=this._buildArgs([e],r||this._commitment||"finalized"),i=this._makeSubscription({callback:(o,a)=>{if(o.type==="status"){t(o.result,a);try{this.removeSignatureListener(i)}catch{}}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},s);return i}onSignatureWithOptions(e,t,r){const{commitment:s,...i}={...r,commitment:r&&r.commitment||this._commitment||"finalized"},o=this._buildArgs([e],s,void 0,i),a=this._makeSubscription({callback:(f,g)=>{t(f,g);try{this.removeSignatureListener(a)}catch{}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},o);return a}async removeSignatureListener(e){await this._unsubscribeClientSubscription(e,"signature result")}_wsOnRootNotification(e){const{result:t,subscription:r}=se(e,ng);this._handleServerNotification(r,[t])}onRootChange(e){return this._makeSubscription({callback:e,method:"rootSubscribe",unsubscribeMethod:"rootUnsubscribe"},[])}async removeRootChangeListener(e){await this._unsubscribeClientSubscription(e,"root change")}}class Cn{constructor(e){this._keypair=void 0,this._keypair=e??Ho()}static generate(){return new Cn(Ho())}static fromSecretKey(e,t){if(e.byteLength!==64)throw new Error("bad secret key size");const r=e.slice(32,64);if(!t||!t.skipValidation){const s=e.slice(0,32),i=Rr(s);for(let o=0;o<32;o++)if(r[o]!==i[o])throw new Error("provided secretKey is invalid")}return new Cn({publicKey:r,secretKey:e})}static fromSeed(e){const t=Rr(e),r=new Uint8Array(64);return r.set(e),r.set(t,32),new Cn({publicKey:t,secretKey:r})}get publicKey(){return new ie(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}}const Zt=Object.freeze({CreateLookupTable:{index:0,layout:B.struct([B.u32("instruction"),Bn("recentSlot"),B.u8("bumpSeed")])},FreezeLookupTable:{index:1,layout:B.struct([B.u32("instruction")])},ExtendLookupTable:{index:2,layout:B.struct([B.u32("instruction"),Bn(),B.seq(Ee(),B.offset(B.u32(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:B.struct([B.u32("instruction")])},CloseLookupTable:{index:4,layout:B.struct([B.u32("instruction")])}});class Tg{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);const r=B.u32("instruction").decode(e.data);let s;for(const[i,o]of Object.entries(Zt))if(o.index==r){s=i;break}if(!s)throw new Error("Invalid Instruction. Should be a LookupTable Instruction");return s}static decodeCreateLookupTable(e){this.checkProgramId(e.programId),this.checkKeysLength(e.keys,4);const{recentSlot:t}=ke(Zt.CreateLookupTable,e.data);return{authority:e.keys[1].pubkey,payer:e.keys[2].pubkey,recentSlot:Number(t)}}static decodeExtendLookupTable(e){if(this.checkProgramId(e.programId),e.keys.length<2)throw new Error(`invalid instruction; found ${e.keys.length} keys, expected at least 2`);const{addresses:t}=ke(Zt.ExtendLookupTable,e.data);return{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey,payer:e.keys.length>2?e.keys[2].pubkey:void 0,addresses:t.map(r=>new ie(r))}}static decodeCloseLookupTable(e){return this.checkProgramId(e.programId),this.checkKeysLength(e.keys,3),{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey,recipient:e.keys[2].pubkey}}static decodeFreezeLookupTable(e){return this.checkProgramId(e.programId),this.checkKeysLength(e.keys,2),{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey}}static decodeDeactivateLookupTable(e){return this.checkProgramId(e.programId),this.checkKeysLength(e.keys,2),{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey}}static checkProgramId(e){if(!e.equals(zi.programId))throw new Error("invalid instruction; programId is not AddressLookupTable Program")}static checkKeysLength(e,t){if(e.length<t)throw new Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}}class zi{constructor(){}static createLookupTable(e){const[t,r]=ie.findProgramAddressSync([e.authority.toBuffer(),mo().encode(e.recentSlot)],this.programId),s=Zt.CreateLookupTable,i=Ae(s,{recentSlot:BigInt(e.recentSlot),bumpSeed:r}),o=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1},{pubkey:e.payer,isSigner:!0,isWritable:!0},{pubkey:gt.programId,isSigner:!1,isWritable:!1}];return[new xe({programId:this.programId,keys:o,data:i}),t]}static freezeLookupTable(e){const t=Zt.FreezeLookupTable,r=Ae(t),s=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new xe({programId:this.programId,keys:s,data:r})}static extendLookupTable(e){const t=Zt.ExtendLookupTable,r=Ae(t,{addresses:e.addresses.map(i=>i.toBytes())}),s=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return e.payer&&s.push({pubkey:e.payer,isSigner:!0,isWritable:!0},{pubkey:gt.programId,isSigner:!1,isWritable:!1}),new xe({programId:this.programId,keys:s,data:r})}static deactivateLookupTable(e){const t=Zt.DeactivateLookupTable,r=Ae(t),s=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new xe({programId:this.programId,keys:s,data:r})}static closeLookupTable(e){const t=Zt.CloseLookupTable,r=Ae(t),s=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1},{pubkey:e.recipient,isSigner:!1,isWritable:!0}];return new xe({programId:this.programId,keys:s,data:r})}}zi.programId=new ie("AddressLookupTab1e1111111111111111111111111");class Ng{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);const r=B.u8("instruction").decode(e.data);let s;for(const[i,o]of Object.entries(Kt))if(o.index==r){s=i;break}if(!s)throw new Error("Instruction type incorrect; not a ComputeBudgetInstruction");return s}static decodeRequestUnits(e){this.checkProgramId(e.programId);const{units:t,additionalFee:r}=ke(Kt.RequestUnits,e.data);return{units:t,additionalFee:r}}static decodeRequestHeapFrame(e){this.checkProgramId(e.programId);const{bytes:t}=ke(Kt.RequestHeapFrame,e.data);return{bytes:t}}static decodeSetComputeUnitLimit(e){this.checkProgramId(e.programId);const{units:t}=ke(Kt.SetComputeUnitLimit,e.data);return{units:t}}static decodeSetComputeUnitPrice(e){this.checkProgramId(e.programId);const{microLamports:t}=ke(Kt.SetComputeUnitPrice,e.data);return{microLamports:t}}static checkProgramId(e){if(!e.equals(Ki.programId))throw new Error("invalid instruction; programId is not ComputeBudgetProgram")}}const Kt=Object.freeze({RequestUnits:{index:0,layout:B.struct([B.u8("instruction"),B.u32("units"),B.u32("additionalFee")])},RequestHeapFrame:{index:1,layout:B.struct([B.u8("instruction"),B.u32("bytes")])},SetComputeUnitLimit:{index:2,layout:B.struct([B.u8("instruction"),B.u32("units")])},SetComputeUnitPrice:{index:3,layout:B.struct([B.u8("instruction"),Bn("microLamports")])}});class Ki{constructor(){}static requestUnits(e){const t=Kt.RequestUnits,r=Ae(t,e);return new xe({keys:[],programId:this.programId,data:r})}static requestHeapFrame(e){const t=Kt.RequestHeapFrame,r=Ae(t,e);return new xe({keys:[],programId:this.programId,data:r})}static setComputeUnitLimit(e){const t=Kt.SetComputeUnitLimit,r=Ae(t,e);return new xe({keys:[],programId:this.programId,data:r})}static setComputeUnitPrice(e){const t=Kt.SetComputeUnitPrice,r=Ae(t,{microLamports:BigInt(e.microLamports)});return new xe({keys:[],programId:this.programId,data:r})}}Ki.programId=new ie("ComputeBudget111111111111111111111111111111");const ya=64,wa=32,ba=64,Ra=B.struct([B.u8("numSignatures"),B.u8("padding"),B.u16("signatureOffset"),B.u16("signatureInstructionIndex"),B.u16("publicKeyOffset"),B.u16("publicKeyInstructionIndex"),B.u16("messageDataOffset"),B.u16("messageDataSize"),B.u16("messageInstructionIndex")]);class xr{constructor(){}static createInstructionWithPublicKey(e){const{publicKey:t,message:r,signature:s,instructionIndex:i}=e;Ie(t.length===wa,`Public Key must be ${wa} bytes but received ${t.length} bytes`),Ie(s.length===ba,`Signature must be ${ba} bytes but received ${s.length} bytes`);const o=Ra.span,a=o+t.length,f=a+s.length,g=1,w=he.Buffer.alloc(f+r.length),b=i??65535;return Ra.encode({numSignatures:g,padding:0,signatureOffset:a,signatureInstructionIndex:b,publicKeyOffset:o,publicKeyInstructionIndex:b,messageDataOffset:f,messageDataSize:r.length,messageInstructionIndex:b},w),w.fill(t,o),w.fill(s,a),w.fill(r,f),new xe({keys:[],programId:xr.programId,data:w})}static createInstructionWithPrivateKey(e){const{privateKey:t,message:r,instructionIndex:s}=e;Ie(t.length===ya,`Private key must be ${ya} bytes but received ${t.length} bytes`);try{const i=Cn.fromSecretKey(t),o=i.publicKey.toBytes(),a=bi(r,i.secretKey);return this.createInstructionWithPublicKey({publicKey:o,message:r,signature:a,instructionIndex:s})}catch(i){throw new Error(`Error creating instruction; ${i}`)}}}xr.programId=new ie("Ed25519SigVerify111111111111111111111111111");const xg=(n,e)=>{const t=br.sign(n,e);return[t.toCompactRawBytes(),t.recovery]};br.utils.isValidPrivateKey;const Bg=br.getPublicKey,Ea=32,$i=20,Sa=64,Lg=11,Hi=B.struct([B.u8("numSignatures"),B.u16("signatureOffset"),B.u8("signatureInstructionIndex"),B.u16("ethAddressOffset"),B.u8("ethAddressInstructionIndex"),B.u16("messageDataOffset"),B.u16("messageDataSize"),B.u8("messageInstructionIndex"),B.blob(20,"ethAddress"),B.blob(64,"signature"),B.u8("recoveryId")]);class Mn{constructor(){}static publicKeyToEthAddress(e){Ie(e.length===Sa,`Public key must be ${Sa} bytes but received ${e.length} bytes`);try{return he.Buffer.from(Po(we(e))).slice(-$i)}catch(t){throw new Error(`Error constructing Ethereum address: ${t}`)}}static createInstructionWithPublicKey(e){const{publicKey:t,message:r,signature:s,recoveryId:i,instructionIndex:o}=e;return Mn.createInstructionWithEthAddress({ethAddress:Mn.publicKeyToEthAddress(t),message:r,signature:s,recoveryId:i,instructionIndex:o})}static createInstructionWithEthAddress(e){const{ethAddress:t,message:r,signature:s,recoveryId:i,instructionIndex:o=0}=e;let a;typeof t=="string"?t.startsWith("0x")?a=he.Buffer.from(t.substr(2),"hex"):a=he.Buffer.from(t,"hex"):a=t,Ie(a.length===$i,`Address must be ${$i} bytes but received ${a.length} bytes`);const f=1+Lg,g=f,w=f+a.length,b=w+s.length+1,x=1,T=he.Buffer.alloc(Hi.span+r.length);return Hi.encode({numSignatures:x,signatureOffset:w,signatureInstructionIndex:o,ethAddressOffset:g,ethAddressInstructionIndex:o,messageDataOffset:b,messageDataSize:r.length,messageInstructionIndex:o,signature:we(s),ethAddress:we(a),recoveryId:i},T),T.fill(we(r),Hi.span),new xe({keys:[],programId:Mn.programId,data:T})}static createInstructionWithPrivateKey(e){const{privateKey:t,message:r,instructionIndex:s}=e;Ie(t.length===Ea,`Private key must be ${Ea} bytes but received ${t.length} bytes`);try{const i=we(t),o=Bg(i,!1).slice(1),a=he.Buffer.from(Po(we(r))),[f,g]=xg(a,i);return this.createInstructionWithPublicKey({publicKey:o,message:r,signature:f,recoveryId:g,instructionIndex:s})}catch(i){throw new Error(`Error creating instruction; ${i}`)}}}Mn.programId=new ie("KeccakSecp256k11111111111111111111111111111");var Aa;const Ia=new ie("StakeConfig11111111111111111111111111111111");class va{constructor(e,t){this.staker=void 0,this.withdrawer=void 0,this.staker=e,this.withdrawer=t}}class er{constructor(e,t,r){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=e,this.epoch=t,this.custodian=r}}Aa=er,er.default=new Aa(0,0,ie.default);class Cg{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);const r=B.u32("instruction").decode(e.data);let s;for(const[i,o]of Object.entries(mt))if(o.index==r){s=i;break}if(!s)throw new Error("Instruction type incorrect; not a StakeInstruction");return s}static decodeInitialize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{authorized:t,lockup:r}=ke(mt.Initialize,e.data);return{stakePubkey:e.keys[0].pubkey,authorized:new va(new ie(t.staker),new ie(t.withdrawer)),lockup:new er(r.unixTimestamp,r.epoch,new ie(r.custodian))}}static decodeDelegate(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,6),ke(mt.Delegate,e.data),{stakePubkey:e.keys[0].pubkey,votePubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[5].pubkey}}static decodeAuthorize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{newAuthorized:t,stakeAuthorizationType:r}=ke(mt.Authorize,e.data),s={stakePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey,newAuthorizedPubkey:new ie(t),stakeAuthorizationType:{index:r}};return e.keys.length>3&&(s.custodianPubkey=e.keys[3].pubkey),s}static decodeAuthorizeWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{newAuthorized:t,stakeAuthorizationType:r,authoritySeed:s,authorityOwner:i}=ke(mt.AuthorizeWithSeed,e.data),o={stakePubkey:e.keys[0].pubkey,authorityBase:e.keys[1].pubkey,authoritySeed:s,authorityOwner:new ie(i),newAuthorizedPubkey:new ie(t),stakeAuthorizationType:{index:r}};return e.keys.length>3&&(o.custodianPubkey=e.keys[3].pubkey),o}static decodeSplit(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{lamports:t}=ke(mt.Split,e.data);return{stakePubkey:e.keys[0].pubkey,splitStakePubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[2].pubkey,lamports:t}}static decodeMerge(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3),ke(mt.Merge,e.data),{stakePubkey:e.keys[0].pubkey,sourceStakePubKey:e.keys[1].pubkey,authorizedPubkey:e.keys[4].pubkey}}static decodeWithdraw(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,5);const{lamports:t}=ke(mt.Withdraw,e.data),r={stakePubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[4].pubkey,lamports:t};return e.keys.length>5&&(r.custodianPubkey=e.keys[5].pubkey),r}static decodeDeactivate(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3),ke(mt.Deactivate,e.data),{stakePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey}}static checkProgramId(e){if(!e.equals(Br.programId))throw new Error("invalid instruction; programId is not StakeProgram")}static checkKeyLength(e,t){if(e.length<t)throw new Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}}const mt=Object.freeze({Initialize:{index:0,layout:B.struct([B.u32("instruction"),K0(),$0()])},Authorize:{index:1,layout:B.struct([B.u32("instruction"),Ee("newAuthorized"),B.u32("stakeAuthorizationType")])},Delegate:{index:2,layout:B.struct([B.u32("instruction")])},Split:{index:3,layout:B.struct([B.u32("instruction"),B.ns64("lamports")])},Withdraw:{index:4,layout:B.struct([B.u32("instruction"),B.ns64("lamports")])},Deactivate:{index:5,layout:B.struct([B.u32("instruction")])},Merge:{index:7,layout:B.struct([B.u32("instruction")])},AuthorizeWithSeed:{index:8,layout:B.struct([B.u32("instruction"),Ee("newAuthorized"),B.u32("stakeAuthorizationType"),dn("authoritySeed"),Ee("authorityOwner")])}}),Mg=Object.freeze({Staker:{index:0},Withdrawer:{index:1}});class Br{constructor(){}static initialize(e){const{stakePubkey:t,authorized:r,lockup:s}=e,i=s||er.default,o=mt.Initialize,a=Ae(o,{authorized:{staker:we(r.staker.toBuffer()),withdrawer:we(r.withdrawer.toBuffer())},lockup:{unixTimestamp:i.unixTimestamp,epoch:i.epoch,custodian:we(i.custodian.toBuffer())}}),f={keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:xn,isSigner:!1,isWritable:!1}],programId:this.programId,data:a};return new xe(f)}static createAccountWithSeed(e){const t=new Oe;t.add(gt.createAccountWithSeed({fromPubkey:e.fromPubkey,newAccountPubkey:e.stakePubkey,basePubkey:e.basePubkey,seed:e.seed,lamports:e.lamports,space:this.space,programId:this.programId}));const{stakePubkey:r,authorized:s,lockup:i}=e;return t.add(this.initialize({stakePubkey:r,authorized:s,lockup:i}))}static createAccount(e){const t=new Oe;t.add(gt.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.stakePubkey,lamports:e.lamports,space:this.space,programId:this.programId}));const{stakePubkey:r,authorized:s,lockup:i}=e;return t.add(this.initialize({stakePubkey:r,authorized:s,lockup:i}))}static delegate(e){const{stakePubkey:t,authorizedPubkey:r,votePubkey:s}=e,i=mt.Delegate,o=Ae(i);return new Oe().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!1},{pubkey:zt,isSigner:!1,isWritable:!1},{pubkey:Ir,isSigner:!1,isWritable:!1},{pubkey:Ia,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static authorize(e){const{stakePubkey:t,authorizedPubkey:r,newAuthorizedPubkey:s,stakeAuthorizationType:i,custodianPubkey:o}=e,a=mt.Authorize,f=Ae(a,{newAuthorized:we(s.toBuffer()),stakeAuthorizationType:i.index}),g=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:zt,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}];return o&&g.push({pubkey:o,isSigner:!0,isWritable:!1}),new Oe().add({keys:g,programId:this.programId,data:f})}static authorizeWithSeed(e){const{stakePubkey:t,authorityBase:r,authoritySeed:s,authorityOwner:i,newAuthorizedPubkey:o,stakeAuthorizationType:a,custodianPubkey:f}=e,g=mt.AuthorizeWithSeed,w=Ae(g,{newAuthorized:we(o.toBuffer()),stakeAuthorizationType:a.index,authoritySeed:s,authorityOwner:we(i.toBuffer())}),b=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1},{pubkey:zt,isSigner:!1,isWritable:!1}];return f&&b.push({pubkey:f,isSigner:!0,isWritable:!1}),new Oe().add({keys:b,programId:this.programId,data:w})}static splitInstruction(e){const{stakePubkey:t,authorizedPubkey:r,splitStakePubkey:s,lamports:i}=e,o=mt.Split,a=Ae(o,{lamports:i});return new xe({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:a})}static split(e,t){const r=new Oe;return r.add(gt.createAccount({fromPubkey:e.authorizedPubkey,newAccountPubkey:e.splitStakePubkey,lamports:t,space:this.space,programId:this.programId})),r.add(this.splitInstruction(e))}static splitWithSeed(e,t){const{stakePubkey:r,authorizedPubkey:s,splitStakePubkey:i,basePubkey:o,seed:a,lamports:f}=e,g=new Oe;return g.add(gt.allocate({accountPubkey:i,basePubkey:o,seed:a,space:this.space,programId:this.programId})),t&&t>0&&g.add(gt.transfer({fromPubkey:e.authorizedPubkey,toPubkey:i,lamports:t})),g.add(this.splitInstruction({stakePubkey:r,authorizedPubkey:s,splitStakePubkey:i,lamports:f}))}static merge(e){const{stakePubkey:t,sourceStakePubKey:r,authorizedPubkey:s}=e,i=mt.Merge,o=Ae(i);return new Oe().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:zt,isSigner:!1,isWritable:!1},{pubkey:Ir,isSigner:!1,isWritable:!1},{pubkey:s,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static withdraw(e){const{stakePubkey:t,authorizedPubkey:r,toPubkey:s,lamports:i,custodianPubkey:o}=e,a=mt.Withdraw,f=Ae(a,{lamports:i}),g=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:zt,isSigner:!1,isWritable:!1},{pubkey:Ir,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return o&&g.push({pubkey:o,isSigner:!0,isWritable:!1}),new Oe().add({keys:g,programId:this.programId,data:f})}static deactivate(e){const{stakePubkey:t,authorizedPubkey:r}=e,s=mt.Deactivate,i=Ae(s);return new Oe().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:zt,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:i})}}Br.programId=new ie("Stake11111111111111111111111111111111111111"),Br.space=200;class Oa{constructor(e,t,r,s){this.nodePubkey=void 0,this.authorizedVoter=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.nodePubkey=e,this.authorizedVoter=t,this.authorizedWithdrawer=r,this.commission=s}}class Pg{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);const r=B.u32("instruction").decode(e.data);let s;for(const[i,o]of Object.entries($t))if(o.index==r){s=i;break}if(!s)throw new Error("Instruction type incorrect; not a VoteInstruction");return s}static decodeInitializeAccount(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,4);const{voteInit:t}=ke($t.InitializeAccount,e.data);return{votePubkey:e.keys[0].pubkey,nodePubkey:e.keys[3].pubkey,voteInit:new Oa(new ie(t.nodePubkey),new ie(t.authorizedVoter),new ie(t.authorizedWithdrawer),t.commission)}}static decodeAuthorize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{newAuthorized:t,voteAuthorizationType:r}=ke($t.Authorize,e.data);return{votePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey,newAuthorizedPubkey:new ie(t),voteAuthorizationType:{index:r}}}static decodeAuthorizeWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:t,currentAuthorityDerivedKeySeed:r,newAuthorized:s,voteAuthorizationType:i}}=ke($t.AuthorizeWithSeed,e.data);return{currentAuthorityDerivedKeyBasePubkey:e.keys[2].pubkey,currentAuthorityDerivedKeyOwnerPubkey:new ie(t),currentAuthorityDerivedKeySeed:r,newAuthorizedPubkey:new ie(s),voteAuthorizationType:{index:i},votePubkey:e.keys[0].pubkey}}static decodeWithdraw(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{lamports:t}=ke($t.Withdraw,e.data);return{votePubkey:e.keys[0].pubkey,authorizedWithdrawerPubkey:e.keys[2].pubkey,lamports:t,toPubkey:e.keys[1].pubkey}}static checkProgramId(e){if(!e.equals(Pn.programId))throw new Error("invalid instruction; programId is not VoteProgram")}static checkKeyLength(e,t){if(e.length<t)throw new Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}}const $t=Object.freeze({InitializeAccount:{index:0,layout:B.struct([B.u32("instruction"),H0()])},Authorize:{index:1,layout:B.struct([B.u32("instruction"),Ee("newAuthorized"),B.u32("voteAuthorizationType")])},Withdraw:{index:3,layout:B.struct([B.u32("instruction"),B.ns64("lamports")])},UpdateValidatorIdentity:{index:4,layout:B.struct([B.u32("instruction")])},AuthorizeWithSeed:{index:10,layout:B.struct([B.u32("instruction"),W0()])}}),Ug=Object.freeze({Voter:{index:0},Withdrawer:{index:1}});class Pn{constructor(){}static initializeAccount(e){const{votePubkey:t,nodePubkey:r,voteInit:s}=e,i=$t.InitializeAccount,o=Ae(i,{voteInit:{nodePubkey:we(s.nodePubkey.toBuffer()),authorizedVoter:we(s.authorizedVoter.toBuffer()),authorizedWithdrawer:we(s.authorizedWithdrawer.toBuffer()),commission:s.commission}}),a={keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:xn,isSigner:!1,isWritable:!1},{pubkey:zt,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:o};return new xe(a)}static createAccount(e){const t=new Oe;return t.add(gt.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.votePubkey,lamports:e.lamports,space:this.space,programId:this.programId})),t.add(this.initializeAccount({votePubkey:e.votePubkey,nodePubkey:e.voteInit.nodePubkey,voteInit:e.voteInit}))}static authorize(e){const{votePubkey:t,authorizedPubkey:r,newAuthorizedPubkey:s,voteAuthorizationType:i}=e,o=$t.Authorize,a=Ae(o,{newAuthorized:we(s.toBuffer()),voteAuthorizationType:i.index}),f=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:zt,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return new Oe().add({keys:f,programId:this.programId,data:a})}static authorizeWithSeed(e){const{currentAuthorityDerivedKeyBasePubkey:t,currentAuthorityDerivedKeyOwnerPubkey:r,currentAuthorityDerivedKeySeed:s,newAuthorizedPubkey:i,voteAuthorizationType:o,votePubkey:a}=e,f=$t.AuthorizeWithSeed,g=Ae(f,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:we(r.toBuffer()),currentAuthorityDerivedKeySeed:s,newAuthorized:we(i.toBuffer()),voteAuthorizationType:o.index}}),w=[{pubkey:a,isSigner:!1,isWritable:!0},{pubkey:zt,isSigner:!1,isWritable:!1},{pubkey:t,isSigner:!0,isWritable:!1}];return new Oe().add({keys:w,programId:this.programId,data:g})}static withdraw(e){const{votePubkey:t,authorizedWithdrawerPubkey:r,lamports:s,toPubkey:i}=e,o=$t.Withdraw,a=Ae(o,{lamports:s}),f=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}];return new Oe().add({keys:f,programId:this.programId,data:a})}static safeWithdraw(e,t,r){if(e.lamports>t-r)throw new Error("Withdraw will leave vote account with insufficient funds.");return Pn.withdraw(e)}static updateValidatorIdentity(e){const{votePubkey:t,authorizedWithdrawerPubkey:r,nodePubkey:s}=e,i=$t.UpdateValidatorIdentity,o=Ae(i),a=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!0,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return new Oe().add({keys:a,programId:this.programId,data:o})}}Pn.programId=new ie("Vote111111111111111111111111111111111111111"),Pn.space=3762;const ka=new ie("Va1idator1nfo111111111111111111111111111111"),Dg=te({name:re(),website:le(re()),details:le(re()),iconUrl:le(re()),keybaseUsername:le(re())});class Wi{constructor(e,t){this.key=void 0,this.info=void 0,this.key=e,this.info=t}static fromConfigData(e){let t=[...e];if(At(t)!==2)return null;const s=[];for(let i=0;i<2;i++){const o=new ie(It(t,0,Dt)),a=Ft(t)===1;s.push({publicKey:o,isSigner:a})}if(s[0].publicKey.equals(ka)&&s[1].isSigner){const i=dn().decode(he.Buffer.from(t)),o=JSON.parse(i);return yo(o,Dg),new Wi(s[1].publicKey,o)}return null}}const Fg=new ie("Vote111111111111111111111111111111111111111"),zg=B.struct([Ee("nodePubkey"),Ee("authorizedWithdrawer"),B.u8("commission"),B.nu64(),B.seq(B.struct([B.nu64("slot"),B.u32("confirmationCount")]),B.offset(B.u32(),-8),"votes"),B.u8("rootSlotValid"),B.nu64("rootSlot"),B.nu64(),B.seq(B.struct([B.nu64("epoch"),Ee("authorizedVoter")]),B.offset(B.u32(),-8),"authorizedVoters"),B.struct([B.seq(B.struct([Ee("authorizedPubkey"),B.nu64("epochOfLastAuthorizedSwitch"),B.nu64("targetEpoch")]),32,"buf"),B.nu64("idx"),B.u8("isEmpty")],"priorVoters"),B.nu64(),B.seq(B.struct([B.nu64("epoch"),B.nu64("credits"),B.nu64("prevCredits")]),B.offset(B.u32(),-8),"epochCredits"),B.struct([B.nu64("slot"),B.nu64("timestamp")],"lastTimestamp")]);class qi{constructor(e){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=e.nodePubkey,this.authorizedWithdrawer=e.authorizedWithdrawer,this.commission=e.commission,this.rootSlot=e.rootSlot,this.votes=e.votes,this.authorizedVoters=e.authorizedVoters,this.priorVoters=e.priorVoters,this.epochCredits=e.epochCredits,this.lastTimestamp=e.lastTimestamp}static fromAccountData(e){const r=zg.decode(we(e),4);let s=r.rootSlot;return r.rootSlotValid||(s=null),new qi({nodePubkey:new ie(r.nodePubkey),authorizedWithdrawer:new ie(r.authorizedWithdrawer),commission:r.commission,votes:r.votes,rootSlot:s,authorizedVoters:r.authorizedVoters.map(Kg),priorVoters:$g(r.priorVoters),epochCredits:r.epochCredits,lastTimestamp:r.lastTimestamp})}}function Kg({authorizedVoter:n,epoch:e}){return{epoch:e,authorizedVoter:new ie(n)}}function Ta({authorizedPubkey:n,epochOfLastAuthorizedSwitch:e,targetEpoch:t}){return{authorizedPubkey:new ie(n),epochOfLastAuthorizedSwitch:e,targetEpoch:t}}function $g({buf:n,idx:e,isEmpty:t}){return t?[]:[...n.slice(e+1).map(Ta),...n.slice(0,e).map(Ta)]}const Na={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/"}};function Hg(n,e){const t=e===!1?"http":"https";if(!n)return Na[t].devnet;const r=Na[t][n];if(!r)throw new Error(`Unknown ${t} cluster: ${n}`);return r}async function Wg(n,e,t,r){let s,i;t&&Object.prototype.hasOwnProperty.call(t,"lastValidBlockHeight")||t&&Object.prototype.hasOwnProperty.call(t,"nonceValue")?(s=t,i=r):i=t;const o=i&&{skipPreflight:i.skipPreflight,preflightCommitment:i.preflightCommitment||i.commitment,minContextSlot:i.minContextSlot},a=await n.sendRawTransaction(e,o),f=i&&i.commitment,w=(await(s?n.confirmTransaction(s,f):n.confirmTransaction(a,f))).value;if(w.err)throw a!=null?new Xn({action:o?.skipPreflight?"send":"simulate",signature:a,transactionMessage:`Status: (${JSON.stringify(w)})`}):new Error(`Raw transaction ${a} failed (${JSON.stringify(w)})`);return a}const Lr=Object.freeze(Object.defineProperty({__proto__:null,Account:D0,AddressLookupTableAccount:xi,AddressLookupTableInstruction:Tg,AddressLookupTableProgram:zi,Authorized:va,BLOCKHASH_CACHE_TIMEOUT_MS:ia,BPF_LOADER_DEPRECATED_PROGRAM_ID:F0,BPF_LOADER_PROGRAM_ID:ep,BpfLoader:tp,COMPUTE_BUDGET_INSTRUCTION_LAYOUTS:Kt,ComputeBudgetInstruction:Ng,ComputeBudgetProgram:Ki,Connection:kg,Ed25519Program:xr,Enum:P0,EpochSchedule:ta,FeeCalculatorLayout:Xo,Keypair:Cn,LAMPORTS_PER_SOL:1e9,LOOKUP_TABLE_INSTRUCTION_LAYOUTS:Zt,Loader:mn,Lockup:er,MAX_SEED_LENGTH:Vo,Message:Bt,MessageAccountKeys:Zn,MessageV0:pn,NONCE_ACCOUNT_LENGTH:ki,NonceAccount:vr,PACKET_DATA_SIZE:nn,PUBLIC_KEY_LENGTH:Dt,PublicKey:ie,SIGNATURE_LENGTH_IN_BYTES:jn,SOLANA_SCHEMA:Yn,STAKE_CONFIG_ID:Ia,STAKE_INSTRUCTION_LAYOUTS:mt,SYSTEM_INSTRUCTION_LAYOUTS:Me,SYSVAR_CLOCK_PUBKEY:zt,SYSVAR_EPOCH_SCHEDULE_PUBKEY:V0,SYSVAR_INSTRUCTIONS_PUBKEY:G0,SYSVAR_RECENT_BLOCKHASHES_PUBKEY:Ar,SYSVAR_RENT_PUBKEY:xn,SYSVAR_REWARDS_PUBKEY:Y0,SYSVAR_SLOT_HASHES_PUBKEY:j0,SYSVAR_SLOT_HISTORY_PUBKEY:Z0,SYSVAR_STAKE_HISTORY_PUBKEY:Ir,Secp256k1Program:Mn,SendTransactionError:Xn,SolanaJSONRPCError:ue,SolanaJSONRPCErrorCode:X0,StakeAuthorizationLayout:Mg,StakeInstruction:Cg,StakeProgram:Br,Struct:Ri,SystemInstruction:J0,SystemProgram:gt,Transaction:Oe,TransactionExpiredBlockheightExceededError:Ei,TransactionExpiredNonceInvalidError:Nn,TransactionExpiredTimeoutError:Si,TransactionInstruction:xe,TransactionMessage:Ii,TransactionStatus:jt,VALIDATOR_INFO_KEY:ka,VERSION_PREFIX_MASK:Er,VOTE_PROGRAM_ID:Fg,ValidatorInfo:Wi,VersionedMessage:Ai,VersionedTransaction:vi,VoteAccount:qi,VoteAuthorizationLayout:Ug,VoteInit:Oa,VoteInstruction:Pg,VoteProgram:Pn,clusterApiUrl:Hg,sendAndConfirmRawTransaction:Wg,sendAndConfirmTransaction:Oi},Symbol.toStringTag,{value:"Module"})),rn=pt;var Vi={exports:{}},xa;function qg(){return xa||(xa=1,function(n){var e=function(){var t=String.fromCharCode,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",i={};function o(f,g){if(!i[f]){i[f]={};for(var w=0;w<f.length;w++)i[f][f.charAt(w)]=w}return i[f][g]}var a={compressToBase64:function(f){if(f==null)return"";var g=a._compress(f,6,function(w){return r.charAt(w)});switch(g.length%4){default:case 0:return g;case 1:return g+"===";case 2:return g+"==";case 3:return g+"="}},decompressFromBase64:function(f){return f==null?"":f==""?null:a._decompress(f.length,32,function(g){return o(r,f.charAt(g))})},compressToUTF16:function(f){return f==null?"":a._compress(f,15,function(g){return t(g+32)})+" "},decompressFromUTF16:function(f){return f==null?"":f==""?null:a._decompress(f.length,16384,function(g){return f.charCodeAt(g)-32})},compressToUint8Array:function(f){for(var g=a.compress(f),w=new Uint8Array(g.length*2),b=0,x=g.length;b<x;b++){var T=g.charCodeAt(b);w[b*2]=T>>>8,w[b*2+1]=T%256}return w},decompressFromUint8Array:function(f){if(f==null)return a.decompress(f);for(var g=new Array(f.length/2),w=0,b=g.length;w<b;w++)g[w]=f[w*2]*256+f[w*2+1];var x=[];return g.forEach(function(T){x.push(t(T))}),a.decompress(x.join(""))},compressToEncodedURIComponent:function(f){return f==null?"":a._compress(f,6,function(g){return s.charAt(g)})},decompressFromEncodedURIComponent:function(f){return f==null?"":f==""?null:(f=f.replace(/ /g,"+"),a._decompress(f.length,32,function(g){return o(s,f.charAt(g))}))},compress:function(f){return a._compress(f,16,function(g){return t(g)})},_compress:function(f,g,w){if(f==null)return"";var b,x,T={},L={},O="",N="",M="",H=2,K=3,Q=2,q=[],D=0,X=0,Z;for(Z=0;Z<f.length;Z+=1)if(O=f.charAt(Z),Object.prototype.hasOwnProperty.call(T,O)||(T[O]=K++,L[O]=!0),N=M+O,Object.prototype.hasOwnProperty.call(T,N))M=N;else{if(Object.prototype.hasOwnProperty.call(L,M)){if(M.charCodeAt(0)<256){for(b=0;b<Q;b++)D=D<<1,X==g-1?(X=0,q.push(w(D)),D=0):X++;for(x=M.charCodeAt(0),b=0;b<8;b++)D=D<<1|x&1,X==g-1?(X=0,q.push(w(D)),D=0):X++,x=x>>1}else{for(x=1,b=0;b<Q;b++)D=D<<1|x,X==g-1?(X=0,q.push(w(D)),D=0):X++,x=0;for(x=M.charCodeAt(0),b=0;b<16;b++)D=D<<1|x&1,X==g-1?(X=0,q.push(w(D)),D=0):X++,x=x>>1}H--,H==0&&(H=Math.pow(2,Q),Q++),delete L[M]}else for(x=T[M],b=0;b<Q;b++)D=D<<1|x&1,X==g-1?(X=0,q.push(w(D)),D=0):X++,x=x>>1;H--,H==0&&(H=Math.pow(2,Q),Q++),T[N]=K++,M=String(O)}if(M!==""){if(Object.prototype.hasOwnProperty.call(L,M)){if(M.charCodeAt(0)<256){for(b=0;b<Q;b++)D=D<<1,X==g-1?(X=0,q.push(w(D)),D=0):X++;for(x=M.charCodeAt(0),b=0;b<8;b++)D=D<<1|x&1,X==g-1?(X=0,q.push(w(D)),D=0):X++,x=x>>1}else{for(x=1,b=0;b<Q;b++)D=D<<1|x,X==g-1?(X=0,q.push(w(D)),D=0):X++,x=0;for(x=M.charCodeAt(0),b=0;b<16;b++)D=D<<1|x&1,X==g-1?(X=0,q.push(w(D)),D=0):X++,x=x>>1}H--,H==0&&(H=Math.pow(2,Q),Q++),delete L[M]}else for(x=T[M],b=0;b<Q;b++)D=D<<1|x&1,X==g-1?(X=0,q.push(w(D)),D=0):X++,x=x>>1;H--,H==0&&(H=Math.pow(2,Q),Q++)}for(x=2,b=0;b<Q;b++)D=D<<1|x&1,X==g-1?(X=0,q.push(w(D)),D=0):X++,x=x>>1;for(;;)if(D=D<<1,X==g-1){q.push(w(D));break}else X++;return q.join("")},decompress:function(f){return f==null?"":f==""?null:a._decompress(f.length,32768,function(g){return f.charCodeAt(g)})},_decompress:function(f,g,w){var b=[],x=4,T=4,L=3,O="",N=[],M,H,K,Q,q,D,X,Z={val:w(0),position:g,index:1};for(M=0;M<3;M+=1)b[M]=M;for(K=0,q=Math.pow(2,2),D=1;D!=q;)Q=Z.val&Z.position,Z.position>>=1,Z.position==0&&(Z.position=g,Z.val=w(Z.index++)),K|=(Q>0?1:0)*D,D<<=1;switch(K){case 0:for(K=0,q=Math.pow(2,8),D=1;D!=q;)Q=Z.val&Z.position,Z.position>>=1,Z.position==0&&(Z.position=g,Z.val=w(Z.index++)),K|=(Q>0?1:0)*D,D<<=1;X=t(K);break;case 1:for(K=0,q=Math.pow(2,16),D=1;D!=q;)Q=Z.val&Z.position,Z.position>>=1,Z.position==0&&(Z.position=g,Z.val=w(Z.index++)),K|=(Q>0?1:0)*D,D<<=1;X=t(K);break;case 2:return""}for(b[3]=X,H=X,N.push(X);;){if(Z.index>f)return"";for(K=0,q=Math.pow(2,L),D=1;D!=q;)Q=Z.val&Z.position,Z.position>>=1,Z.position==0&&(Z.position=g,Z.val=w(Z.index++)),K|=(Q>0?1:0)*D,D<<=1;switch(X=K){case 0:for(K=0,q=Math.pow(2,8),D=1;D!=q;)Q=Z.val&Z.position,Z.position>>=1,Z.position==0&&(Z.position=g,Z.val=w(Z.index++)),K|=(Q>0?1:0)*D,D<<=1;b[T++]=t(K),X=T-1,x--;break;case 1:for(K=0,q=Math.pow(2,16),D=1;D!=q;)Q=Z.val&Z.position,Z.position>>=1,Z.position==0&&(Z.position=g,Z.val=w(Z.index++)),K|=(Q>0?1:0)*D,D<<=1;b[T++]=t(K),X=T-1,x--;break;case 2:return N.join("")}if(x==0&&(x=Math.pow(2,L),L++),b[X])O=b[X];else if(X===T)O=H+H.charAt(0);else return null;N.push(O),b[T++]=H+O.charAt(0),x--,H=O,x==0&&(x=Math.pow(2,L),L++)}}};return a}();n!=null?n.exports=e:typeof angular<"u"&&angular!=null&&angular.module("LZString",[]).factory("LZString",function(){return e})}(Vi)),Vi.exports}var Vg=qg();const Lt=Fn(Vg);var Gi=(n=>(n.USD="USD",n.AED="AED",n.AFN="AFN",n.ALL="ALL",n.ANG="ANG",n.AOA="AOA",n.ARS="ARS",n.AUD="AUD",n.AWG="AWG",n.AZN="AZN",n.BAM="BAM",n.BBD="BBD",n.BDT="BDT",n.BGN="BGN",n.BHD="BHD",n.BIF="BIF",n.BMD="BMD",n.BND="BND",n.BOB="BOB",n.BRL="BRL",n.BSD="BSD",n.BTN="BTN",n.BWP="BWP",n.BYN="BYN",n.BZD="BZD",n.CAD="CAD",n.CHF="CHF",n.CLF="CLF",n.CLP="CLP",n.CNY="CNY",n.COP="COP",n.CRC="CRC",n.CUP="CUP",n.CVE="CVE",n.CZK="CZK",n.DJF="DJF",n.DKK="DKK",n.DOP="DOP",n.DZD="DZD",n.EGP="EGP",n.ETB="ETB",n.EUR="EUR",n.FJD="FJD",n.GBP="GBP",n.GEL="GEL",n.GHS="GHS",n.GMD="GMD",n.GNF="GNF",n.GTQ="GTQ",n.GYD="GYD",n.HKD="HKD",n.HNL="HNL",n.HTG="HTG",n.HUF="HUF",n.IDR="IDR",n.ILS="ILS",n.INR="INR",n.IQD="IQD",n.IRR="IRR",n.ISK="ISK",n.JMD="JMD",n.JOD="JOD",n.JPY="JPY",n.KES="KES",n.KGS="KGS",n.KHR="KHR",n.KMF="KMF",n.KRW="KRW",n.KWD="KWD",n.KYD="KYD",n.KZT="KZT",n.LAK="LAK",n.LBP="LBP",n.LKR="LKR",n.LRD="LRD",n.LSL="LSL",n.LYD="LYD",n.MAD="MAD",n.MDL="MDL",n.MGA="MGA",n.MKD="MKD",n.MMK="MMK",n.MNT="MNT",n.MOP="MOP",n.MRU="MRU",n.MUR="MUR",n.MWK="MWK",n.MVR="MVR",n.MXN="MXN",n.MYR="MYR",n.MZN="MZN",n.NAD="NAD",n.NGN="NGN",n.NIO="NIO",n.NOK="NOK",n.NPR="NPR",n.NZD="NZD",n.OMR="OMR",n.PAB="PAB",n.PEN="PEN",n.PGK="PGK",n.PHP="PHP",n.PKR="PKR",n.PLN="PLN",n.PYG="PYG",n.QAR="QAR",n.RON="RON",n.RSD="RSD",n.RWF="RWF",n.SAR="SAR",n.SCR="SCR",n.SDG="SDG",n.SEK="SEK",n.SGD="SGD",n.SLE="SLE",n.SLL="SLL",n.SOS="SOS",n.SRD="SRD",n.STN="STN",n.SVC="SVC",n.SYP="SYP",n.SZL="SZL",n.THB="THB",n.TJS="TJS",n.TMT="TMT",n.TND="TND",n.TOP="TOP",n.TRY="TRY",n.TTD="TTD",n.TWD="TWD",n.TZS="TZS",n.UAH="UAH",n.UGX="UGX",n.UYU="UYU",n.UZS="UZS",n.VND="VND",n.VUV="VUV",n.XAF="XAF",n.XCD="XCD",n.XOF="XOF",n.XPF="XPF",n.YER="YER",n.ZAR="ZAR",n.ZMW="ZMW",n.ZWL="ZWL",n))(Gi||{});const Gg={AED:"784",AFN:"971",ALL:"008",ANG:"532",AOA:"973",AUD:"036",AWG:"533",AZN:"944",BAM:"977",BBD:"052",BDT:"050",BGN:"975",BHD:"048",BIF:"108",BND:"096",BOB:"068",BRL:"986",BTN:"064",BWP:"072",BZD:"084",CAD:"124",CHF:"756",CLP:"152",CNY:"156",COP:"170",CRC:"188",CVE:"132",CZK:"203",DJF:"262",DKK:"208",DOP:"214",DZD:"012",EGP:"818",ETB:"230",EUR:"978",GBP:"826",GEL:"981",GHS:"936",GMD:"270",GNF:"324",GTQ:"320",GYD:"328",HKD:"344",HNL:"340",HTG:"332",HUF:"348",IDR:"360",INR:"356",IQD:"368",IRR:"364",ISK:"352",JMD:"388",JOD:"400",JPY:"392",KES:"404",KGS:"417",KHR:"116",KMF:"174",KRW:"410",KWD:"414",KYD:"136",KZT:"398",LKR:"144",LRD:"430",LSL:"426",LYD:"434",MAD:"504",MDL:"498",MGA:"969",MKD:"807",MMK:"104",MNT:"496",MOP:"446",MRU:"929",MUR:"480",MVR:"462",MXN:"484",MYR:"458",NAD:"516",NGN:"566",NIO:"558",NOK:"578",NPR:"524",NZD:"554",OMR:"512",PAB:"590",PEN:"604",PHP:"608",PKR:"586",PLN:"985",PYG:"600",QAR:"634",RON:"946",RSD:"941",RWF:"646",SAR:"682",SCR:"690",SDG:"938",SEK:"752",SGD:"702",SLE:"925",SLL:"694",SOS:"706",STN:"930",SVC:"222",SYP:"760",SZL:"748",THB:"764",TJS:"972",TMT:"934",TND:"788",TRY:"949",TTD:"780",TWD:"901",TZS:"834",UAH:"980",UGX:"800",USD:"840",UYU:"858",UZS:"860",VND:"704",XAF:"950",XCD:"951",XOF:"952",XPF:"953",YER:"886",ZAR:"710",ZMW:"967",ARS:"032",BMD:"060",BSD:"044",BYN:"933",CUP:"192",FJD:"242",ILS:"376",LAK:"418",LBP:"422",MWK:"454",MZN:"943",PGK:"598",SRD:"968",TOP:"776",VUV:"548",ZWL:"932",CLF:"990"},Ba={USD:"USD",EUR:"EUR",GBP:"GBP",BRL:"BRL",CAD:"CAD"};function Yg(n){return n in Ba}function jg(n,e){return n.currency===e}class Ht{env;url;constructor(e){this.env=e??"prod",this.env==="prod"?this.url="https://api.coinflow.cash":this.env==="local"?this.url="http://localhost:5000":this.url=`https://api-${this.env}.coinflow.cash`}async getNSurePartnerId(e){return fetch(this.url+`/merchant/view/${e}`).then(t=>t.json()).then(t=>t.nSureSettings?.nSurePartnerId||t.nSurePartnerId).catch(t=>{console.error(t)})}static getCoinflowBaseUrl(e){return!e||e==="prod"?"https://coinflow.cash":e==="ngrok"?"https://coinflow.ngrok.app":e==="local"?"http://localhost:3000":`https://${e}.coinflow.cash`}static getCoinflowApiUrl(e){return!e||e==="prod"?"https://api.coinflow.cash":e==="local"?"http://localhost:5000":`https://api-${e}.coinflow.cash`}static getCoinflowUrl({walletPubkey:e,sessionKey:t,route:r,routePrefix:s,env:i,subtotal:o,presentment:a,transaction:f,blockchain:g="solana",webhookInfo:w,email:b,loaderBackground:x,handleHeightChangeId:T,bankAccountLinkRedirect:L,additionalWallets:O,chargebackProtectionData:N,merchantCss:M,color:H,rent:K,lockDefaultToken:Q,tokens:q,planCode:D,disableApplePay:X,disableGooglePay:Z,customerInfo:J,settlementType:z,lockAmount:V,nativeSolToConvert:ee,theme:S,usePermit:c,transactionSigner:p,authOnly:m,deviceId:I,jwtToken:E,origins:A,threeDsChallengePreference:C,supportEmail:R,destinationAuthKey:u,allowedPaymentMethods:l,accountFundingTransaction:y,partialUsdcChecked:k,allowedWithdrawSpeeds:P}){const G=s?`/${s}/${g}`:`/${g}`,j=new URL(G+r,Ht.getCoinflowBaseUrl(i));if(e&&j.searchParams.append("pubkey",e),t&&j.searchParams.append("sessionKey",t),f&&j.searchParams.append("transaction",f),o&&("cents"in o?(j.searchParams.append("cents",o.cents.toString()),"currency"in o?j.searchParams.append("currency",o.currency.toString()):j.searchParams.append("currency",Gi.USD)):(j.searchParams.append("token",o.address.toString()),j.searchParams.append("amount",o.amount.toString()))),a&&j.searchParams.append("presentment",a),w&&j.searchParams.append("webhookInfo",Lt.compressToEncodedURIComponent(JSON.stringify(w))),S&&j.searchParams.append("theme",Lt.compressToEncodedURIComponent(JSON.stringify(S))),J&&j.searchParams.append("customerInfo",Lt.compressToEncodedURIComponent(JSON.stringify(J))),b&&j.searchParams.append("email",b),R&&j.searchParams.append("supportEmail",R),q&&j.searchParams.append("tokens",q.toString()),x&&j.searchParams.append("loaderBackground",x),T&&j.searchParams.append("useHeightChange",T.toString()),L&&j.searchParams.append("bankAccountLinkRedirect",L),O&&j.searchParams.append("additionalWallets",Lt.compressToEncodedURIComponent(JSON.stringify(O))),N&&j.searchParams.append("chargebackProtectionData",Lt.compressToEncodedURIComponent(JSON.stringify(N))),I)j.searchParams.append("deviceId",I);else if(typeof window<"u"){const ce=window?.nSureSDK?.getDeviceId();ce&&j.searchParams.append("deviceId",ce)}return M&&j.searchParams.append("merchantCss",M),H&&j.searchParams.append("color",H),K&&j.searchParams.append("rent",K.lamports.toString()),ee&&j.searchParams.append("nativeSolToConvert",ee.lamports.toString()),Q&&j.searchParams.append("lockDefaultToken","true"),D&&j.searchParams.append("planCode",D),X&&j.searchParams.append("disableApplePay","true"),Z&&j.searchParams.append("disableGooglePay","true"),z&&j.searchParams.append("settlementType",z),V&&j.searchParams.append("lockAmount","true"),c===!1&&j.searchParams.append("usePermit","false"),p&&j.searchParams.append("transactionSigner",p),m===!0&&j.searchParams.append("authOnly","true"),k===!0&&j.searchParams.append("partialUsdcChecked","true"),E&&j.searchParams.append("jwtToken",E),A&&j.searchParams.append("origins",Lt.compressToEncodedURIComponent(JSON.stringify(A))),l&&j.searchParams.append("allowedPaymentMethods",l.join(",")),C&&j.searchParams.append("threeDsChallengePreference",C),u&&j.searchParams.append("destinationAuthKey",u),y&&j.searchParams.append("accountFundingTransaction",Lt.compressToEncodedURIComponent(JSON.stringify(y))),P&&j.searchParams.append("allowedWithdrawSpeeds",P.join(",")),j.toString()}static getTransaction(e){if(e.blockchain)return this.byBlockchain(e.blockchain,{solana:()=>{if(!("transaction"in e))return;const{transaction:t}=e;if(!Lr)throw new Error("@solana/web3.js dependency is required for Solana");if(!rn)throw new Error("bs58 dependency is required for Solana");if(t)return rn.encode(t.serialize({requireAllSignatures:!1,verifySignatures:!1}))},polygon:()=>{if(!("transaction"in e))return;const{transaction:t}=e;return Lt.compressToEncodedURIComponent(JSON.stringify(t))},eth:()=>{if(!("transaction"in e))return;const{transaction:t}=e;return Lt.compressToEncodedURIComponent(JSON.stringify(t))},base:()=>{if(!("transaction"in e))return;const{transaction:t}=e;return Lt.compressToEncodedURIComponent(JSON.stringify(t))},arbitrum:()=>{if(!("transaction"in e))return;const{transaction:t}=e;return Lt.compressToEncodedURIComponent(JSON.stringify(t))},user:()=>{}})()}static byBlockchain(e,t){switch(e){case"solana":return t.solana;case"polygon":return t.polygon;case"eth":return t.eth;case"base":return t.base;case"arbitrum":return t.arbitrum;case"user":return t.user;default:throw new Error("blockchain not supported!")}}}function Zg(n){if(!n)return;let e,t;if("name"in n&&n.name&&(e=n.name.split(" ")[0],t=n.name.split(" ").slice(1).join(" ")),"firstName"in n&&n.firstName&&(e=n.firstName),"lastName"in n&&n.lastName&&(t=n.lastName),e&&t)return{firstName:e,lastName:t}}var Yi=(n=>(n.SignMessage="signMessage",n.SignTransaction="signTransaction",n.SendTransaction="sendTransaction",n.HeightChange="heightChange",n.Success="success",n.AuthDeclined="authDeclined",n.Loaded="loaded",n.AccountLinked="accountLinked",n))(Yi||{});function Cr(n){let e;if("signer"in n&&typeof n.signer=="object"&&n.signer&&"wallet"in n.signer?e=n.signer.wallet:"wallet"in n&&n.wallet&&(e=n.wallet),!!e){if(typeof e=="string")return e;if(typeof e=="object"){if("publicKey"in e)return e.publicKey?e.publicKey.toString():void 0;if("address"in e)return e.address?e.address:void 0}return null}}function La(n,e,t){let r;try{if(r=JSON.parse(n),!("method"in r)||!("data"in r))return}catch(o){console.error("handleIFrameMessage JSON parse",o);return}const{data:s,method:i}=r;switch(i){case"signMessage":return e.handleSignMessage?e.handleSignMessage(s):void 0;case"signTransaction":return e.handleSignTransaction?e.handleSignTransaction(s):void 0;case"sendTransaction":return e.handleSendTransaction(s);case"heightChange:"+t:return e.handleHeightChange?e.handleHeightChange(s):void 0;case"success":if(!e.onSuccess)return;e.onSuccess(r.info);return;case"authDeclined":if(!e.onAuthDeclined)return;e.onAuthDeclined(r.info);return;case"loaded":return;case"accountLinked":return}console.warn(`Didn't expect to get here, handleIFrameMessage method:${i} is not one of ${Object.values(Yi)}`)}function Mr(n){let e,t;return"signer"in n&&typeof n.signer=="object"&&n.signer&&"blockchain"in n.signer&&"wallet"in n.signer?(e=n.signer.blockchain,t=n.signer.wallet):"blockchain"in n&&n.blockchain&&(e=n.blockchain,t=n.wallet),e?Ht.byBlockchain(e,{solana:()=>Xg({wallet:t,onSuccess:n.onSuccess,onAuthDeclined:n.onAuthDeclined}),eth:()=>Pr({wallet:t,onSuccess:n.onSuccess,onAuthDeclined:n.onAuthDeclined}),polygon:()=>Pr({wallet:t,onSuccess:n.onSuccess,onAuthDeclined:n.onAuthDeclined}),base:()=>Pr({wallet:t,onSuccess:n.onSuccess,onAuthDeclined:n.onAuthDeclined}),arbitrum:()=>Pr({wallet:t,onSuccess:n.onSuccess,onAuthDeclined:n.onAuthDeclined}),user:()=>Jg(n)})():{handleSendTransaction:()=>{throw new Error("handleSendTransaction Not Implemented")},handleSignMessage:()=>{throw new Error("handleSendTransaction Not Implemented")},handleSignTransaction:()=>{throw new Error("handleSendTransaction Not Implemented")},onSuccess:n.onSuccess,onAuthDeclined:n.onAuthDeclined}}function Xg({wallet:n,onSuccess:e,onAuthDeclined:t}){return{handleSendTransaction:async r=>{const s=Ca(r);return await n.sendTransaction(s)},handleSignMessage:async r=>{const s=n.signMessage;if(!s)throw new Error("signMessage is not supported by this wallet");const i=await s(new TextEncoder().encode(r));if(!rn)throw new Error("bs58 dependency is required");return rn.encode(i)},handleSignTransaction:async r=>{const s=n.signTransaction;if(!s)throw new Error("signTransaction is not supported by this wallet");const i=Ca(r),o=await s(i);if(!rn)throw new Error("bs58 dependency is required");return rn.encode(o.serialize({requireAllSignatures:!1,verifySignatures:!1}))},onSuccess:e,onAuthDeclined:t}}function Ca(n){if(!Lr)throw new Error("@solana/web3.js is not defined. Please install @solana/web3.js into your project");if(!rn)throw new Error("bs58 is not defined. Please install bs58 into your project");const e=rn.decode(n),t=Lr.VersionedTransaction.deserialize(e);return t.version==="legacy"?Lr.Transaction.from(e):t}function Pr({wallet:n,onSuccess:e,onAuthDeclined:t}){return{handleSendTransaction:async r=>{const s=JSON.parse(Buffer.from(r,"base64").toString()),{hash:i}=await n.sendTransaction(s);return i},handleSignMessage:async r=>n.signMessage(r),onSuccess:e,onAuthDeclined:t}}function Jg({onSuccess:n,onAuthDeclined:e}){return{handleSendTransaction:async()=>Promise.resolve(""),onSuccess:n,onAuthDeclined:e}}class Qg{static on(e,t){document.addEventListener(e,t)}static dispatch(e,t){document.dispatchEvent(new CustomEvent(e,{detail:t}))}static remove(e,t){document.removeEventListener(e,t)}}const tr="tokenExCardNumber",Un="tokenExCardCvv",Ma={[wn.VISA]:"visa",[wn.MASTERCARD]:"masterCard",[wn.AMEX]:"americanExpress",[wn.DISCOVER]:"discover"};async function Pa(n){const{token:e,origins:t,env:r}=n;return new Promise((s,i)=>{fetch(new Ht(r).url+"/api/tokenize/iframe/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({origins:t,token:e,merchantId:"merchantId"in n?n.merchantId:void 0,checkoutJwt:"checkoutJwt"in n?n.checkoutJwt:void 0})}).then(async o=>{s(await o.json())}).catch(o=>i(o))})}function ji({env:n,setTokenExScriptLoaded:e}){const t="tokenex-script";document.head.querySelector(`#${t}`)&&e(!0);const r=document.createElement("script");r.src=n==="prod"?"https://htp.tokenex.com/iframe/iframe-v3.min.js":"https://test-htp.tokenex.com/iframe/iframe-v3.min.js",r.id=t,document.head.appendChild(r),document.getElementById(t).addEventListener("load",()=>{console.log("Setting tokenExScriptLoaded to true!"),e(!0)})}function em({iframe:n,setCachedToken:e,setLoaded:t}){const r=async()=>(n.tokenize(),await new Promise((s,i)=>{n.on("tokenize",o=>{e(o.token),s(o)}),n.on("validate",o=>{(!o.isValid||o.isCvvValid===!1)&&i(o)})}));return n.on("change",()=>e(void 0)),n.on("cvvChange",()=>e(void 0)),n.on("load",()=>{setTimeout(()=>t(!0),350);const s=document.querySelector("#tx_iframe_tokenExCardNumber");s&&(s.scrolling="no")}),n.on("focus",()=>{n.focus()}),n.on("cvvFocus",()=>{n.cvvFocus()}),t(!1),n.load(),{...n,tokenize:r}}async function Ua(n){const{token:e,cardType:t}=n;return await Zi(Un,n,{cvvOnly:!0,cvv:!0,cvvContainerID:Un,placeholder:"CVV",token:e,cardType:Ma[t]})}async function Da(n){return await Zi(tr,n,{cvv:!0,cvvContainerID:Un,cvvPlaceholder:"CVV"})}async function Fa(n){return await Zi(tr,n,{cvv:!1})}async function Zi(n,e,t){const{tokenExScriptLoaded:r,css:s,debug:i,font:o,setCachedToken:a,setLoaded:f}=e;if(!r&&typeof TokenEx>"u"){console.warn("Warning Unable to load TokenEx on first attempt waiting for load event from document.head.script#tokenex-script");return}const g=await Pa({...e,token:t.token}),{styles:w}=tm(s),b={...g,placeholder:"0000 0000 0000 0000",enablePrettyFormat:!0,styles:w,font:o,debug:i??!1,...t},x=TokenEx.Iframe(n,b);return em({iframe:x,setCachedToken:a,setLoaded:f})}function tm(n){const e=JSON.parse(n);return{styles:{base:sn(e.base),focus:sn(e.focus),error:sn(e.error),placeholder:sn(e.placeholder),cvv:{base:sn(e.cvv?.base),focus:sn(e.cvv?.focus),error:sn(e.cvv?.error),placeholder:sn(e?.placeholder)}}}}function sn(n){if(!n)return"";if(typeof n=="string")return n;let e="";for(const[t,r]of Object.entries(n)){let s="";t.split("").forEach(i=>{i.toUpperCase()===i?s+="-"+i.toLowerCase():s+=i}),e+=s+":"+r+";"}return e}de.nftCartItem=void 0,(n=>{(e=>{e.NFT="nft"})(n.itemClass||(n.itemClass={})),(e=>{e.IN_GAME_PRODUCT="inGameProduct",e.GAME_OF_SKILL="gameOfSkill",e.DATA_STORAGE="dataStorage",e.COMPUTING_RESOURCES="computingResources",e.SPORTS_TICKET="sportsTicket",e.E_SPORTS_TICKET="eSportsTicket",e.MUSIC_TICKET="musicTicket",e.CONFERENCE_TICKET="conferenceTicket",e.VIRTUAL_SPORTS_TICKET="virtualSportsTicket",e.VIRTUAL_ESPORTS_TICKET="virtualESportsTicket",e.VIRTUAL_MUSIC_TICKET="virtualMusicTicket",e.VIRTUAL_CONFERENCE_TICKET="virtualConferenceTicket",e.ALCOHOL="alcohol",e.DLC="DLC",e.SUBSCRIPTION="subscription",e.FUND_ACAUSE="fundACause",e.REAL_ESTATE="realEstate",e.COMPUTING_CONTRACT="computingContract",e.DIGITAL_ART="digitalArt",e.TOP_UP="topUp",e.OWNERSHIP_CONTRACT="ownershipContract",e.IN_GAME_CURRENCY="inGameCurrency",e.MONEY_TOP_UP_CART_ITEM="moneyTopUpCartItem"})(n.productType||(n.productType={}))})(de.nftCartItem||(de.nftCartItem={}));const nm=ne.defineComponent({name:"CoinflowIFrame",props:{args:{type:Object,required:!0}},computed:{url(){return Ht.getCoinflowUrl(this.args)}},emits:{onMessage(n){return!0}},methods:{sendMessage(n){const e=this.$refs.iframeRef;if(!e?.contentWindow)throw new Error("Iframe not defined");e.contentWindow.postMessage(n,"*")},handleIframeMessages({data:n,origin:e}){if(!e.includes(Ht.getCoinflowBaseUrl(this.args.env)))return;this.$emit("onMessage",{data:n,origin:e});const t=La(n,this.args,this.args.handleHeightChangeId);t&&t.then(this.sendMessage).catch(r=>{console.error(r),this.sendMessage("ERROR "+r.message)})},async listenForMessage(n){let e;return new Promise((t,r)=>{if(e=({data:s,origin:i})=>{if(i.includes(Ht.getCoinflowBaseUrl(this.args.env))){if(s.startsWith("ERROR")){r(new Error(s.replace("ERROR","")));return}n(s)&&t(s)}},!window)throw new Error("Window not defined");window.addEventListener("message",e)}).finally(()=>{window.removeEventListener("message",e)})},async sendAndReceiveMessage(n,e){return this.sendMessage(n),this.listenForMessage(e)}},mounted(){if(!window)throw new Error("Window not defined");return window.addEventListener("message",this.handleIframeMessages),()=>{window.removeEventListener("message",this.handleIframeMessages)}}}),Xi=(n,e)=>{const t=n.__vccOpts||n;for(const[r,s]of e)t[r]=s;return t},rm=["src","scrolling"];function im(n,e,t,r,s,i){return ne.openBlock(),ne.createElementBlock("iframe",{credentialless:"",style:{height:"100%",width:"100%"},ref:"iframeRef",allow:"payment;camera;clipboard-write",title:"withdraw",frameBorder:"0",src:n.url,scrolling:n.args.handleHeightChange?"no":"yes",onLoad:e[0]||(e[0]=()=>{const o=n.$refs.iframeRef;o&&(o.style.opacity="1")})},null,40,rm)}const Ur=Xi(nm,[["render",im]]),sm=ne.defineComponent({name:"CoinflowWithdraw",components:{CoinflowIFrame:Ur},props:{args:{type:Object,required:!0}},computed:{handleHeightChangeId(){return Math.random().toString(16).substring(2)},iframeProps(){const n=Cr(this.args);return{...this.args,walletPubkey:n,route:`/withdraw/${this.args.merchantId}`,transaction:void 0}},messageHandlers(){return{...Mr(this.args),handleHeightChange:this.args.handleHeightChange}}}});function om(n,e,t,r,s,i){const o=ne.resolveComponent("coinflow-i-frame");return ne.openBlock(),ne.createBlock(o,{args:{...n.iframeProps,...n.messageHandlers,handleHeightChangeId:n.handleHeightChangeId}},null,8,["args"])}const am=Xi(sm,[["render",om]]),cm=ne.defineComponent({name:"CoinflowPurchase",components:{CoinflowIFrame:Ur},props:{args:{type:Object,required:!0}},computed:{handleHeightChangeId(){return Math.random().toString(16).substring(2)},iframeProps(){const n=Cr(this.args);return{...this.args,walletPubkey:n,route:`/purchase-v2/${this.args.merchantId}`,transaction:Ht.getTransaction(this.args)}},messageHandlers(){return{...Mr(this.args),handleHeightChange:this.args.handleHeightChange}}}});function um(n,e,t,r,s,i){const o=ne.resolveComponent("coinflow-i-frame");return ne.openBlock(),ne.createBlock(o,{args:{...n.iframeProps,...n.messageHandlers,handleHeightChangeId:n.handleHeightChangeId}},null,8,["args"])}const lm=Xi(cm,[["render",um]]),Ji=n=>{const e=ne.ref(!1),t=ne.ref(!1),r=ne.ref(void 0),s=ne.ref(void 0);ne.onMounted(()=>{ji({env:n.env,setTokenExScriptLoaded:()=>{console.log("tokenExScriptLoaded.value = true"),t.value=!0}})});const i=b=>s.value=b,o=()=>e.value=!0,a=b=>r.value=b,f=async b=>{const x=await Ua({...n,...b,tokenExScriptLoaded:t.value,setCachedToken:i,setLoaded:o});return a(x),x},g=async b=>{const x=await Da({...n,...b,tokenExScriptLoaded:t.value,setCachedToken:i,setLoaded:o});return a(x),x},w=async b=>{const x=await Fa({...n,...b,tokenExScriptLoaded:t.value,setCachedToken:i,setLoaded:o});return a(x),x};return ne.watchEffect(b=>{r.value&&(r.value.load(),b(()=>r.value?.remove()))}),{tokenExIframe:r,initializeTokenExIframe:g,initializeCvvOnlyTokenExIframe:f,initializeTokenExCardOnlyIframe:w,loaded:e,cachedToken:s,setTokenExScriptTag:ji,tokenExScriptLoaded:t}},hm=["id"],fm=ne.defineComponent({__name:"CoinflowCardNumberInput",props:{args:{type:Object,required:!0}},setup(n,{expose:e}){const{initializeTokenExIframe:t,tokenExIframe:r}=Ji(n.args);async function s(){if(!r.value)throw new Error("Unable to get token");return r.value.tokenize()}e({getToken:s});function i(){return JSON.stringify(n.args.css)}return ne.watchEffect(()=>{t({css:i(),debug:n.args.debug,origins:n.args.origins,font:n.args.font})},{}),(o,a)=>(ne.openBlock(),ne.createElementBlock("div",{id:ne.unref(tr)},null,8,hm))}}),dm=["id"],pm=ne.defineComponent({__name:"CoinflowCvvInput",setup(n){return(e,t)=>(ne.openBlock(),ne.createElementBlock("div",{id:ne.unref(Un)},null,8,dm))}}),gm=["id"],mm=ne.defineComponent({__name:"CoinflowCvvOnlyInput",props:{args:{type:Object,required:!0}},setup(n,{expose:e}){const{initializeCvvOnlyTokenExIframe:t,tokenExIframe:r}=Ji(n.args);async function s(){if(!r.value)throw new Error("Unable to get token");return r.value.tokenize()}e({getToken:s});function i(){return JSON.stringify(n.args.css)}return ne.watchEffect(()=>{t({...n.args,origins:n.args.origins??[],css:i(),font:n.args.font})},{}),(o,a)=>(ne.openBlock(),ne.createElementBlock("div",{id:ne.unref(Un)},null,8,gm))}}),_m=ne.defineComponent({__name:"CoinflowPurchaseProtection",props:{args:{type:Object,required:!0}},setup(n){const e=ne.ref(void 0);ne.onMounted(()=>new Ht(n.args.env).getNSurePartnerId(n.args.merchantId).then(s=>e.value=s));function t(){return n.args.env==="prod"?"9JBW2RHC7JNJN8ZQ":"SANDBOX_CTCE4XK53ZW0R7V1"}function r(){return n.args.env==="prod"?"https://sdk.nsureapi.com/sdk.js":"https://sdk.nsureapi.com/sdk-sandbox.js"}return ne.watchEffect(s=>{if(!e.value)return;const i=document.createElement("script");i.src=r(),document.head.appendChild(i);const o=`window.nSureAsyncInit = function(deviceId) {
|
|
16
|
+
`+i+o;break;default:a=`Unknown action '${(f=>f)(e)}'`}super(a),this.signature=void 0,this.transactionMessage=void 0,this.transactionLogs=void 0,this.signature=t,this.transactionMessage=r,this.transactionLogs=s||void 0}get transactionError(){return{message:this.transactionMessage,logs:Array.isArray(this.transactionLogs)?this.transactionLogs:void 0}}get logs(){const e=this.transactionLogs;if(!(e!=null&&typeof e=="object"&&"then"in e))return e}async getLogs(e){return Array.isArray(this.transactionLogs)||(this.transactionLogs=new Promise((t,r)=>{e.getTransaction(this.signature).then(s=>{if(s&&s.meta&&s.meta.logMessages){const i=s.meta.logMessages;this.transactionLogs=i,t(i)}else r(new Error("Log messages not found"))}).catch(r)})),await this.transactionLogs}}const X0={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};class ue extends Error{constructor({code:e,message:t,data:r},s){super(s!=null?`${s}: ${t}`:t),this.code=void 0,this.data=void 0,this.code=e,this.data=r,this.name="SolanaJSONRPCError"}}async function Oi(n,e,t,r){const s=r&&{skipPreflight:r.skipPreflight,preflightCommitment:r.preflightCommitment||r.commitment,maxRetries:r.maxRetries,minContextSlot:r.minContextSlot},i=await n.sendTransaction(e,t,s);let o;if(e.recentBlockhash!=null&&e.lastValidBlockHeight!=null)o=(await n.confirmTransaction({abortSignal:r?.abortSignal,signature:i,blockhash:e.recentBlockhash,lastValidBlockHeight:e.lastValidBlockHeight},r&&r.commitment)).value;else if(e.minNonceContextSlot!=null&&e.nonceInfo!=null){const{nonceInstruction:a}=e.nonceInfo,f=a.keys[0].pubkey;o=(await n.confirmTransaction({abortSignal:r?.abortSignal,minContextSlot:e.minNonceContextSlot,nonceAccountPubkey:f,nonceValue:e.nonceInfo.nonce,signature:i},r&&r.commitment)).value}else r?.abortSignal!=null&&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."),o=(await n.confirmTransaction(i,r&&r.commitment)).value;if(o.err)throw i!=null?new Xn({action:"send",signature:i,transactionMessage:`Status: (${JSON.stringify(o)})`}):new Error(`Transaction ${i} failed (${JSON.stringify(o)})`);return i}function gn(n){return new Promise(e=>setTimeout(e,n))}function Ie(n,e){const t=n.layout.span>=0?n.layout.span:Yo(n,e),r=he.Buffer.alloc(t),s=Object.assign({instruction:n.index},e);return n.layout.encode(s,r),r}function ke(n,e){let t;try{t=n.layout.decode(e)}catch(r){throw new Error("invalid instruction; "+r)}if(t.instruction!==n.index)throw new Error(`invalid instruction; instruction index mismatch ${t.instruction} != ${n.index}`);return t}const Xo=B.nu64("lamportsPerSignature"),Jo=B.struct([B.u32("version"),B.u32("state"),Ee("authorizedPubkey"),Ee("nonce"),B.struct([Xo],"feeCalculator")]),ki=Jo.span;class vr{constructor(e){this.authorizedPubkey=void 0,this.nonce=void 0,this.feeCalculator=void 0,this.authorizedPubkey=e.authorizedPubkey,this.nonce=e.nonce,this.feeCalculator=e.feeCalculator}static fromAccountData(e){const t=Jo.decode(we(e),0);return new vr({authorizedPubkey:new se(t.authorizedPubkey),nonce:new se(t.nonce).toString(),feeCalculator:t.feeCalculator})}}function Bn(n){const e=B.blob(8,n),t=e.decode.bind(e),r=e.encode.bind(e),s=e,i=Cd();return s.decode=(o,a)=>{const f=t(o,a);return i.decode(f)},s.encode=(o,a,f)=>{const g=i.encode(o);return r(g,a,f)},s}class J0{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);const r=B.u32("instruction").decode(e.data);let s;for(const[i,o]of Object.entries(Me))if(o.index==r){s=i;break}if(!s)throw new Error("Instruction type incorrect; not a SystemInstruction");return s}static decodeCreateAccount(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{lamports:t,space:r,programId:s}=ke(Me.Create,e.data);return{fromPubkey:e.keys[0].pubkey,newAccountPubkey:e.keys[1].pubkey,lamports:t,space:r,programId:new se(s)}}static decodeTransfer(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{lamports:t}=ke(Me.Transfer,e.data);return{fromPubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,lamports:t}}static decodeTransferWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{lamports:t,seed:r,programId:s}=ke(Me.TransferWithSeed,e.data);return{fromPubkey:e.keys[0].pubkey,basePubkey:e.keys[1].pubkey,toPubkey:e.keys[2].pubkey,lamports:t,seed:r,programId:new se(s)}}static decodeAllocate(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);const{space:t}=ke(Me.Allocate,e.data);return{accountPubkey:e.keys[0].pubkey,space:t}}static decodeAllocateWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);const{base:t,seed:r,space:s,programId:i}=ke(Me.AllocateWithSeed,e.data);return{accountPubkey:e.keys[0].pubkey,basePubkey:new se(t),seed:r,space:s,programId:new se(i)}}static decodeAssign(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);const{programId:t}=ke(Me.Assign,e.data);return{accountPubkey:e.keys[0].pubkey,programId:new se(t)}}static decodeAssignWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);const{base:t,seed:r,programId:s}=ke(Me.AssignWithSeed,e.data);return{accountPubkey:e.keys[0].pubkey,basePubkey:new se(t),seed:r,programId:new se(s)}}static decodeCreateWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{base:t,seed:r,lamports:s,space:i,programId:o}=ke(Me.CreateWithSeed,e.data);return{fromPubkey:e.keys[0].pubkey,newAccountPubkey:e.keys[1].pubkey,basePubkey:new se(t),seed:r,lamports:s,space:i,programId:new se(o)}}static decodeNonceInitialize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{authorized:t}=ke(Me.InitializeNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,authorizedPubkey:new se(t)}}static decodeNonceAdvance(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3),ke(Me.AdvanceNonceAccount,e.data),{noncePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey}}static decodeNonceWithdraw(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,5);const{lamports:t}=ke(Me.WithdrawNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[4].pubkey,lamports:t}}static decodeNonceAuthorize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{authorized:t}=ke(Me.AuthorizeNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[1].pubkey,newAuthorizedPubkey:new se(t)}}static checkProgramId(e){if(!e.equals(gt.programId))throw new Error("invalid instruction; programId is not SystemProgram")}static checkKeyLength(e,t){if(e.length<t)throw new Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}}const Me=Object.freeze({Create:{index:0,layout:B.struct([B.u32("instruction"),B.ns64("lamports"),B.ns64("space"),Ee("programId")])},Assign:{index:1,layout:B.struct([B.u32("instruction"),Ee("programId")])},Transfer:{index:2,layout:B.struct([B.u32("instruction"),Bn("lamports")])},CreateWithSeed:{index:3,layout:B.struct([B.u32("instruction"),Ee("base"),dn("seed"),B.ns64("lamports"),B.ns64("space"),Ee("programId")])},AdvanceNonceAccount:{index:4,layout:B.struct([B.u32("instruction")])},WithdrawNonceAccount:{index:5,layout:B.struct([B.u32("instruction"),B.ns64("lamports")])},InitializeNonceAccount:{index:6,layout:B.struct([B.u32("instruction"),Ee("authorized")])},AuthorizeNonceAccount:{index:7,layout:B.struct([B.u32("instruction"),Ee("authorized")])},Allocate:{index:8,layout:B.struct([B.u32("instruction"),B.ns64("space")])},AllocateWithSeed:{index:9,layout:B.struct([B.u32("instruction"),Ee("base"),dn("seed"),B.ns64("space"),Ee("programId")])},AssignWithSeed:{index:10,layout:B.struct([B.u32("instruction"),Ee("base"),dn("seed"),Ee("programId")])},TransferWithSeed:{index:11,layout:B.struct([B.u32("instruction"),Bn("lamports"),dn("seed"),Ee("programId")])},UpgradeNonceAccount:{index:12,layout:B.struct([B.u32("instruction")])}});class gt{constructor(){}static createAccount(e){const t=Me.Create,r=Ie(t,{lamports:e.lamports,space:e.space,programId:we(e.programId.toBuffer())});return new xe({keys:[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:r})}static transfer(e){let t,r;if("basePubkey"in e){const s=Me.TransferWithSeed;t=Ie(s,{lamports:BigInt(e.lamports),seed:e.seed,programId:we(e.programId.toBuffer())}),r=[{pubkey:e.fromPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}else{const s=Me.Transfer;t=Ie(s,{lamports:BigInt(e.lamports)}),r=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}return new xe({keys:r,programId:this.programId,data:t})}static assign(e){let t,r;if("basePubkey"in e){const s=Me.AssignWithSeed;t=Ie(s,{base:we(e.basePubkey.toBuffer()),seed:e.seed,programId:we(e.programId.toBuffer())}),r=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{const s=Me.Assign;t=Ie(s,{programId:we(e.programId.toBuffer())}),r=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new xe({keys:r,programId:this.programId,data:t})}static createAccountWithSeed(e){const t=Me.CreateWithSeed,r=Ie(t,{base:we(e.basePubkey.toBuffer()),seed:e.seed,lamports:e.lamports,space:e.space,programId:we(e.programId.toBuffer())});let s=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!1,isWritable:!0}];return e.basePubkey.equals(e.fromPubkey)||s.push({pubkey:e.basePubkey,isSigner:!0,isWritable:!1}),new xe({keys:s,programId:this.programId,data:r})}static createNonceAccount(e){const t=new Oe;"basePubkey"in e&&"seed"in e?t.add(gt.createAccountWithSeed({fromPubkey:e.fromPubkey,newAccountPubkey:e.noncePubkey,basePubkey:e.basePubkey,seed:e.seed,lamports:e.lamports,space:ki,programId:this.programId})):t.add(gt.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.noncePubkey,lamports:e.lamports,space:ki,programId:this.programId}));const r={noncePubkey:e.noncePubkey,authorizedPubkey:e.authorizedPubkey};return t.add(this.nonceInitialize(r)),t}static nonceInitialize(e){const t=Me.InitializeNonceAccount,r=Ie(t,{authorized:we(e.authorizedPubkey.toBuffer())}),s={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:Ar,isSigner:!1,isWritable:!1},{pubkey:xn,isSigner:!1,isWritable:!1}],programId:this.programId,data:r};return new xe(s)}static nonceAdvance(e){const t=Me.AdvanceNonceAccount,r=Ie(t),s={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:Ar,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r};return new xe(s)}static nonceWithdraw(e){const t=Me.WithdrawNonceAccount,r=Ie(t,{lamports:e.lamports});return new xe({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0},{pubkey:Ar,isSigner:!1,isWritable:!1},{pubkey:xn,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r})}static nonceAuthorize(e){const t=Me.AuthorizeNonceAccount,r=Ie(t,{authorized:we(e.newAuthorizedPubkey.toBuffer())});return new xe({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r})}static allocate(e){let t,r;if("basePubkey"in e){const s=Me.AllocateWithSeed;t=Ie(s,{base:we(e.basePubkey.toBuffer()),seed:e.seed,space:e.space,programId:we(e.programId.toBuffer())}),r=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{const s=Me.Allocate;t=Ie(s,{space:e.space}),r=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new xe({keys:r,programId:this.programId,data:t})}}gt.programId=new se("11111111111111111111111111111111");const Q0=nn-300;class mn{constructor(){}static getMinNumSignatures(e){return 2*(Math.ceil(e/mn.chunkSize)+1+1)}static async load(e,t,r,s,i){{const b=await e.getMinimumBalanceForRentExemption(i.length),x=await e.getAccountInfo(r.publicKey,"confirmed");let T=null;if(x!==null){if(x.executable)return console.error("Program load failed, account is already executable"),!1;x.data.length!==i.length&&(T=T||new Oe,T.add(gt.allocate({accountPubkey:r.publicKey,space:i.length}))),x.owner.equals(s)||(T=T||new Oe,T.add(gt.assign({accountPubkey:r.publicKey,programId:s}))),x.lamports<b&&(T=T||new Oe,T.add(gt.transfer({fromPubkey:t.publicKey,toPubkey:r.publicKey,lamports:b-x.lamports})))}else T=new Oe().add(gt.createAccount({fromPubkey:t.publicKey,newAccountPubkey:r.publicKey,lamports:b>0?b:1,space:i.length,programId:s}));T!==null&&await Oi(e,T,[t,r],{commitment:"confirmed"})}const o=B.struct([B.u32("instruction"),B.u32("offset"),B.u32("bytesLength"),B.u32("bytesLengthPadding"),B.seq(B.u8("byte"),B.offset(B.u32(),-8),"bytes")]),a=mn.chunkSize;let f=0,g=i,w=[];for(;g.length>0;){const b=g.slice(0,a),x=he.Buffer.alloc(a+16);o.encode({instruction:0,offset:f,bytes:b,bytesLength:0,bytesLengthPadding:0},x);const T=new Oe().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0}],programId:s,data:x});w.push(Oi(e,T,[t,r],{commitment:"confirmed"})),e._rpcEndpoint.includes("solana.com")&&await gn(1e3/4),f+=a,g=g.slice(a)}await Promise.all(w);{const b=B.struct([B.u32("instruction")]),x=he.Buffer.alloc(b.span);b.encode({instruction:1},x);const T=new Oe().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0},{pubkey:xn,isSigner:!1,isWritable:!1}],programId:s,data:x}),L="processed",O=await e.sendTransaction(T,[t,r],{preflightCommitment:L}),{context:N,value:M}=await e.confirmTransaction({signature:O,lastValidBlockHeight:T.lastValidBlockHeight,blockhash:T.recentBlockhash},L);if(M.err)throw new Error(`Transaction ${O} failed (${JSON.stringify(M)})`);for(;;){try{if(await e.getSlot({commitment:L})>N.slot)break}catch{}await new Promise(H=>setTimeout(H,Math.round(Zo/2)))}}return!0}}mn.chunkSize=Q0;const ep=new se("BPFLoader2111111111111111111111111111111111");class tp{static getMinNumSignatures(e){return mn.getMinNumSignatures(e)}static load(e,t,r,s,i){return mn.load(e,t,r,i,s)}}function np(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Ti,Qo;function rp(){if(Qo)return Ti;Qo=1;var n=Object.prototype.toString,e=Object.keys||function(r){var s=[];for(var i in r)s.push(i);return s};function t(r,s){var i,o,a,f,g,w,b;if(r===!0)return"true";if(r===!1)return"false";switch(typeof r){case"object":if(r===null)return null;if(r.toJSON&&typeof r.toJSON=="function")return t(r.toJSON(),s);if(b=n.call(r),b==="[object Array]"){for(a="[",o=r.length-1,i=0;i<o;i++)a+=t(r[i],!0)+",";return o>-1&&(a+=t(r[i],!0)),a+"]"}else if(b==="[object Object]"){for(f=e(r).sort(),o=f.length,a="",i=0;i<o;)g=f[i],w=t(r[g],!1),w!==void 0&&(a&&(a+=","),a+=JSON.stringify(g)+":"+w),i++;return"{"+a+"}"}else return JSON.stringify(r);case"function":case"undefined":return s?null:void 0;case"string":return JSON.stringify(r);default:return isFinite(r)?r:null}}return Ti=function(r){var s=t(r,!1);if(s!==void 0)return""+s},Ti}var ip=rp(),ea=np(ip);const Jn=32;function Ni(n){let e=0;for(;n>1;)n/=2,e++;return e}function sp(n){return n===0?1:(n--,n|=n>>1,n|=n>>2,n|=n>>4,n|=n>>8,n|=n>>16,n|=n>>32,n+1)}class ta{constructor(e,t,r,s,i){this.slotsPerEpoch=void 0,this.leaderScheduleSlotOffset=void 0,this.warmup=void 0,this.firstNormalEpoch=void 0,this.firstNormalSlot=void 0,this.slotsPerEpoch=e,this.leaderScheduleSlotOffset=t,this.warmup=r,this.firstNormalEpoch=s,this.firstNormalSlot=i}getEpoch(e){return this.getEpochAndSlotIndex(e)[0]}getEpochAndSlotIndex(e){if(e<this.firstNormalSlot){const t=Ni(sp(e+Jn+1))-Ni(Jn)-1,r=this.getSlotsInEpoch(t),s=e-(r-Jn);return[t,s]}else{const t=e-this.firstNormalSlot,r=Math.floor(t/this.slotsPerEpoch),s=this.firstNormalEpoch+r,i=t%this.slotsPerEpoch;return[s,i]}}getFirstSlotInEpoch(e){return e<=this.firstNormalEpoch?(Math.pow(2,e)-1)*Jn:(e-this.firstNormalEpoch)*this.slotsPerEpoch+this.firstNormalSlot}getLastSlotInEpoch(e){return this.getFirstSlotInEpoch(e)+this.getSlotsInEpoch(e)-1}getSlotsInEpoch(e){return e<this.firstNormalEpoch?Math.pow(2,e+Ni(Jn)):this.slotsPerEpoch}}var op=globalThis.fetch;class ap extends g0{constructor(e,t,r){const s=i=>{const o=d0(i,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...t});return"socket"in o?this.underlyingSocket=o.socket:this.underlyingSocket=o,o};super(s,e,t,r),this.underlyingSocket=void 0}call(...e){const t=this.underlyingSocket?.readyState;return t===1?super.call(...e):Promise.reject(new Error("Tried to call a JSON-RPC method `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+")"))}notify(...e){const t=this.underlyingSocket?.readyState;return t===1?super.notify(...e):Promise.reject(new Error("Tried to send a JSON-RPC notification `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+")"))}}function cp(n,e){let t;try{t=n.layout.decode(e)}catch(r){throw new Error("invalid instruction; "+r)}if(t.typeIndex!==n.index)throw new Error(`invalid account data; account type mismatch ${t.typeIndex} != ${n.index}`);return t}const na=56;class xi{constructor(e){this.key=void 0,this.state=void 0,this.key=e.key,this.state=e.state}isActive(){const e=BigInt("0xffffffffffffffff");return this.state.deactivationSlot===e}static deserialize(e){const t=cp(up,e),r=e.length-na;ve(r>=0,"lookup table is invalid"),ve(r%32===0,"lookup table is invalid");const s=r/32,{addresses:i}=B.struct([B.seq(Ee(),s,"addresses")]).decode(e.slice(na));return{deactivationSlot:t.deactivationSlot,lastExtendedSlot:t.lastExtendedSlot,lastExtendedSlotStartIndex:t.lastExtendedStartIndex,authority:t.authority.length!==0?new se(t.authority[0]):void 0,addresses:i.map(o=>new se(o))}}}const up={index:1,layout:B.struct([B.u32("typeIndex"),Bn("deactivationSlot"),B.nu64("lastExtendedSlot"),B.u8("lastExtendedStartIndex"),B.u8(),B.seq(Ee(),B.offset(B.u8(),-1),"authority")])},lp=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;function hp(n){const e=n.match(lp);if(e==null)throw TypeError(`Failed to validate endpoint URL \`${n}\``);const[t,r,s,i]=e,o=n.startsWith("https:")?"wss:":"ws:",a=s==null?null:parseInt(s.slice(1),10),f=a==null?"":`:${a+1}`;return`${o}//${r}${f}${i}`}const Ve=Vn(ai(se),ie(),n=>new se(n)),ra=ci([ie(),qe("base64")]),Bi=Vn(ai(he.Buffer),ra,n=>he.Buffer.from(n[0],"base64")),ia=30*1e3;function fp(n){if(/^https?:/.test(n)===!1)throw new TypeError("Endpoint URL must start with `http:` or `https:`.");return n}function Pe(n){let e,t;if(typeof n=="string")e=n;else if(n){const{commitment:r,...s}=n;e=r,t=s}return{commitment:e,config:t}}function sa(n){return n.map(e=>"memcmp"in e?{...e,memcmp:{...e.memcmp,encoding:e.memcmp.encoding??"base58"}}:e)}function oa(n){return St([te({jsonrpc:qe("2.0"),id:ie(),result:n}),te({jsonrpc:qe("2.0"),id:ie(),error:te({code:Tn(),message:ie(),data:le(zd())})})])}const dp=oa(Tn());function be(n){return Vn(oa(n),dp,e=>"error"in e?e:{...e,result:oe(e.result,n)})}function Ye(n){return be(te({context:te({slot:$()}),value:n}))}function Or(n){return te({context:te({slot:$()}),value:n})}function Li(n,e){return n===0?new pn({header:e.header,staticAccountKeys:e.accountKeys.map(t=>new se(t)),recentBlockhash:e.recentBlockhash,compiledInstructions:e.instructions.map(t=>({programIdIndex:t.programIdIndex,accountKeyIndexes:t.accounts,data:pt.decode(t.data)})),addressTableLookups:e.addressTableLookups}):new Bt(e)}const pp=te({foundation:$(),foundationTerm:$(),initial:$(),taper:$(),terminal:$()}),gp=be(ae(ce(te({epoch:$(),effectiveSlot:$(),amount:$(),postBalance:$(),commission:le(ce($()))})))),mp=ae(te({slot:$(),prioritizationFee:$()})),_p=te({total:$(),validator:$(),foundation:$(),epoch:$()}),yp=te({epoch:$(),slotIndex:$(),slotsInEpoch:$(),absoluteSlot:$(),blockHeight:le($()),transactionCount:le($())}),wp=te({slotsPerEpoch:$(),leaderScheduleSlotOffset:$(),warmup:Ut(),firstNormalEpoch:$(),firstNormalSlot:$()}),bp=bo(ie(),ae($())),_n=ce(St([te({}),ie()])),Rp=te({err:_n}),Ep=qe("receivedSignature"),Sp=te({"solana-core":ie(),"feature-set":le($())}),Ap=te({program:ie(),programId:Ve,parsed:Tn()}),Ip=te({programId:Ve,accounts:ae(Ve),data:ie()}),aa=Ye(te({err:ce(St([te({}),ie()])),logs:ce(ae(ie())),accounts:le(ce(ae(ce(te({executable:Ut(),owner:ie(),lamports:$(),data:ae(ie()),rentEpoch:le($())}))))),unitsConsumed:le($()),returnData:le(ce(te({programId:ie(),data:ci([ie(),qe("base64")])}))),innerInstructions:le(ce(ae(te({index:$(),instructions:ae(St([Ap,Ip]))}))))})),vp=Ye(te({byIdentity:bo(ie(),ae($())),range:te({firstSlot:$(),lastSlot:$()})}));function Op(n,e,t,r,s,i){const o=t||op;let a;i!=null&&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.");let f;return r&&(f=async(w,b)=>{const x=await new Promise((T,L)=>{try{r(w,b,(O,N)=>T([O,N]))}catch(O){L(O)}});return await o(...x)}),new u0(async(w,b)=>{const x={method:"POST",body:w,agent:a,headers:Object.assign({"Content-Type":"application/json"},e||{},Og)};try{let T=5,L,O=500;for(;f?L=await f(n,x):L=await o(n,x),!(L.status!==429||s===!0||(T-=1,T===0));)console.error(`Server responded with ${L.status} ${L.statusText}. Retrying after ${O}ms delay...`),await gn(O),O*=2;const N=await L.text();L.ok?b(null,N):b(new Error(`${L.status} ${L.statusText}: ${N}`))}catch(T){T instanceof Error&&b(T)}},{})}function kp(n){return(e,t)=>new Promise((r,s)=>{n.request(e,t,(i,o)=>{if(i){s(i);return}r(o)})})}function Tp(n){return e=>new Promise((t,r)=>{e.length===0&&t([]);const s=e.map(i=>n.request(i.methodName,i.args));n.request(s,(i,o)=>{if(i){r(i);return}t(o)})})}const Np=be(pp),xp=be(_p),Bp=be(mp),Lp=be(yp),Cp=be(wp),Mp=be(bp),Pp=be($()),Up=Ye(te({total:$(),circulating:$(),nonCirculating:$(),nonCirculatingAccounts:ae(Ve)})),Ci=te({amount:ie(),uiAmount:ce($()),decimals:$(),uiAmountString:le(ie())}),Dp=Ye(ae(te({address:Ve,amount:ie(),uiAmount:ce($()),decimals:$(),uiAmountString:le(ie())}))),Fp=Ye(ae(te({pubkey:Ve,account:te({executable:Ut(),owner:Ve,lamports:$(),data:Bi,rentEpoch:$()})}))),Mi=te({program:ie(),parsed:Tn(),space:$()}),zp=Ye(ae(te({pubkey:Ve,account:te({executable:Ut(),owner:Ve,lamports:$(),data:Mi,rentEpoch:$()})}))),Kp=Ye(ae(te({lamports:$(),address:Ve}))),Qn=te({executable:Ut(),owner:Ve,lamports:$(),data:Bi,rentEpoch:$()}),$p=te({pubkey:Ve,account:Qn}),Hp=Vn(St([ai(he.Buffer),Mi]),St([ra,Mi]),n=>Array.isArray(n)?oe(n,Bi):n),Pi=te({executable:Ut(),owner:Ve,lamports:$(),data:Hp,rentEpoch:$()}),Wp=te({pubkey:Ve,account:Pi}),qp=te({state:St([qe("active"),qe("inactive"),qe("activating"),qe("deactivating")]),active:$(),inactive:$()}),Vp=be(ae(te({signature:ie(),slot:$(),err:_n,memo:ce(ie()),blockTime:le(ce($()))}))),Gp=be(ae(te({signature:ie(),slot:$(),err:_n,memo:ce(ie()),blockTime:le(ce($()))}))),Yp=te({subscription:$(),result:Or(Qn)}),jp=te({pubkey:Ve,account:Qn}),Zp=te({subscription:$(),result:Or(jp)}),Xp=te({parent:$(),slot:$(),root:$()}),Jp=te({subscription:$(),result:Xp}),Qp=St([te({type:St([qe("firstShredReceived"),qe("completed"),qe("optimisticConfirmation"),qe("root")]),slot:$(),timestamp:$()}),te({type:qe("createdBank"),parent:$(),slot:$(),timestamp:$()}),te({type:qe("frozen"),slot:$(),timestamp:$(),stats:te({numTransactionEntries:$(),numSuccessfulTransactions:$(),numFailedTransactions:$(),maxTransactionsPerEntry:$()})}),te({type:qe("dead"),slot:$(),timestamp:$(),err:ie()})]),eg=te({subscription:$(),result:Qp}),tg=te({subscription:$(),result:Or(St([Rp,Ep]))}),ng=te({subscription:$(),result:$()}),rg=te({pubkey:ie(),gossip:ce(ie()),tpu:ce(ie()),rpc:ce(ie()),version:ce(ie())}),ca=te({votePubkey:ie(),nodePubkey:ie(),activatedStake:$(),epochVoteAccount:Ut(),epochCredits:ae(ci([$(),$(),$()])),commission:$(),lastVote:$(),rootSlot:ce($())}),ig=be(te({current:ae(ca),delinquent:ae(ca)})),sg=St([qe("processed"),qe("confirmed"),qe("finalized")]),og=te({slot:$(),confirmations:ce($()),err:_n,confirmationStatus:le(sg)}),ag=Ye(ae(ce(og))),cg=be($()),ua=te({accountKey:Ve,writableIndexes:ae($()),readonlyIndexes:ae($())}),Ui=te({signatures:ae(ie()),message:te({accountKeys:ae(ie()),header:te({numRequiredSignatures:$(),numReadonlySignedAccounts:$(),numReadonlyUnsignedAccounts:$()}),instructions:ae(te({accounts:ae($()),data:ie(),programIdIndex:$()})),recentBlockhash:ie(),addressTableLookups:le(ae(ua))})}),la=te({pubkey:Ve,signer:Ut(),writable:Ut(),source:le(St([qe("transaction"),qe("lookupTable")]))}),ha=te({accountKeys:ae(la),signatures:ae(ie())}),fa=te({parsed:Tn(),program:ie(),programId:Ve}),da=te({accounts:ae(Ve),data:ie(),programId:Ve}),ug=St([da,fa]),lg=St([te({parsed:Tn(),program:ie(),programId:ie()}),te({accounts:ae(ie()),data:ie(),programId:ie()})]),pa=Vn(ug,lg,n=>"accounts"in n?oe(n,da):oe(n,fa)),ga=te({signatures:ae(ie()),message:te({accountKeys:ae(la),instructions:ae(pa),recentBlockhash:ie(),addressTableLookups:le(ce(ae(ua)))})}),kr=te({accountIndex:$(),mint:ie(),owner:le(ie()),programId:le(ie()),uiTokenAmount:Ci}),ma=te({writable:ae(Ve),readonly:ae(Ve)}),Tr=te({err:_n,fee:$(),innerInstructions:le(ce(ae(te({index:$(),instructions:ae(te({accounts:ae($()),data:ie(),programIdIndex:$()}))})))),preBalances:ae($()),postBalances:ae($()),logMessages:le(ce(ae(ie()))),preTokenBalances:le(ce(ae(kr))),postTokenBalances:le(ce(ae(kr))),loadedAddresses:le(ma),computeUnitsConsumed:le($())}),Di=te({err:_n,fee:$(),innerInstructions:le(ce(ae(te({index:$(),instructions:ae(pa)})))),preBalances:ae($()),postBalances:ae($()),logMessages:le(ce(ae(ie()))),preTokenBalances:le(ce(ae(kr))),postTokenBalances:le(ce(ae(kr))),loadedAddresses:le(ma),computeUnitsConsumed:le($())}),Ln=St([qe(0),qe("legacy")]),yn=te({pubkey:ie(),lamports:$(),postBalance:ce($()),rewardType:ce(ie()),commission:le(ce($()))}),hg=be(ce(te({blockhash:ie(),previousBlockhash:ie(),parentSlot:$(),transactions:ae(te({transaction:Ui,meta:ce(Tr),version:le(Ln)})),rewards:le(ae(yn)),blockTime:ce($()),blockHeight:ce($())}))),fg=be(ce(te({blockhash:ie(),previousBlockhash:ie(),parentSlot:$(),rewards:le(ae(yn)),blockTime:ce($()),blockHeight:ce($())}))),dg=be(ce(te({blockhash:ie(),previousBlockhash:ie(),parentSlot:$(),transactions:ae(te({transaction:ha,meta:ce(Tr),version:le(Ln)})),rewards:le(ae(yn)),blockTime:ce($()),blockHeight:ce($())}))),pg=be(ce(te({blockhash:ie(),previousBlockhash:ie(),parentSlot:$(),transactions:ae(te({transaction:ga,meta:ce(Di),version:le(Ln)})),rewards:le(ae(yn)),blockTime:ce($()),blockHeight:ce($())}))),gg=be(ce(te({blockhash:ie(),previousBlockhash:ie(),parentSlot:$(),transactions:ae(te({transaction:ha,meta:ce(Di),version:le(Ln)})),rewards:le(ae(yn)),blockTime:ce($()),blockHeight:ce($())}))),mg=be(ce(te({blockhash:ie(),previousBlockhash:ie(),parentSlot:$(),rewards:le(ae(yn)),blockTime:ce($()),blockHeight:ce($())}))),_g=be(ce(te({blockhash:ie(),previousBlockhash:ie(),parentSlot:$(),transactions:ae(te({transaction:Ui,meta:ce(Tr)})),rewards:le(ae(yn)),blockTime:ce($())}))),_a=be(ce(te({blockhash:ie(),previousBlockhash:ie(),parentSlot:$(),signatures:ae(ie()),blockTime:ce($())}))),Fi=be(ce(te({slot:$(),meta:ce(Tr),blockTime:le(ce($())),transaction:Ui,version:le(Ln)}))),Nr=be(ce(te({slot:$(),transaction:ga,meta:ce(Di),blockTime:le(ce($())),version:le(Ln)}))),yg=Ye(te({blockhash:ie(),lastValidBlockHeight:$()})),wg=Ye(Ut()),bg=te({slot:$(),numTransactions:$(),numSlots:$(),samplePeriodSecs:$()}),Rg=be(ae(bg)),Eg=Ye(ce(te({feeCalculator:te({lamportsPerSignature:$()})}))),Sg=be(ie()),Ag=be(ie()),Ig=te({err:_n,logs:ae(ie()),signature:ie()}),vg=te({result:Or(Ig),subscription:$()}),Og={"solana-client":"js/1.0.0-maintenance"};class kg{constructor(e,t){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 g={};return async w=>{const{commitment:b,config:x}=Pe(w),T=this._buildArgs([],b,void 0,x),L=ea(T);return g[L]=g[L]??(async()=>{try{const O=await this._rpcRequest("getBlockHeight",T),N=oe(O,be($()));if("error"in N)throw new ue(N.error,"failed to get block height information");return N.result}finally{delete g[L]}})(),await g[L]}})();let r,s,i,o,a,f;t&&typeof t=="string"?this._commitment=t:t&&(this._commitment=t.commitment,this._confirmTransactionInitialTimeout=t.confirmTransactionInitialTimeout,r=t.wsEndpoint,s=t.httpHeaders,i=t.fetch,o=t.fetchMiddleware,a=t.disableRetryOnRateLimit,f=t.httpAgent),this._rpcEndpoint=fp(e),this._rpcWsEndpoint=r||hp(e),this._rpcClient=Op(e,s,i,o,a,f),this._rpcRequest=kp(this._rpcClient),this._rpcBatchRequest=Tp(this._rpcClient),this._rpcWebSocket=new ap(this._rpcWsEndpoint,{autoconnect:!1,max_reconnects:1/0}),this._rpcWebSocket.on("open",this._wsOnOpen.bind(this)),this._rpcWebSocket.on("error",this._wsOnError.bind(this)),this._rpcWebSocket.on("close",this._wsOnClose.bind(this)),this._rpcWebSocket.on("accountNotification",this._wsOnAccountNotification.bind(this)),this._rpcWebSocket.on("programNotification",this._wsOnProgramAccountNotification.bind(this)),this._rpcWebSocket.on("slotNotification",this._wsOnSlotNotification.bind(this)),this._rpcWebSocket.on("slotsUpdatesNotification",this._wsOnSlotUpdatesNotification.bind(this)),this._rpcWebSocket.on("signatureNotification",this._wsOnSignatureNotification.bind(this)),this._rpcWebSocket.on("rootNotification",this._wsOnRootNotification.bind(this)),this._rpcWebSocket.on("logsNotification",this._wsOnLogsNotification.bind(this))}get commitment(){return this._commitment}get rpcEndpoint(){return this._rpcEndpoint}async getBalanceAndContext(e,t){const{commitment:r,config:s}=Pe(t),i=this._buildArgs([e.toBase58()],r,void 0,s),o=await this._rpcRequest("getBalance",i),a=oe(o,Ye($()));if("error"in a)throw new ue(a.error,`failed to get balance for ${e.toBase58()}`);return a.result}async getBalance(e,t){return await this.getBalanceAndContext(e,t).then(r=>r.value).catch(r=>{throw new Error("failed to get balance of account "+e.toBase58()+": "+r)})}async getBlockTime(e){const t=await this._rpcRequest("getBlockTime",[e]),r=oe(t,be(ce($())));if("error"in r)throw new ue(r.error,`failed to get block time for slot ${e}`);return r.result}async getMinimumLedgerSlot(){const e=await this._rpcRequest("minimumLedgerSlot",[]),t=oe(e,be($()));if("error"in t)throw new ue(t.error,"failed to get minimum ledger slot");return t.result}async getFirstAvailableBlock(){const e=await this._rpcRequest("getFirstAvailableBlock",[]),t=oe(e,Pp);if("error"in t)throw new ue(t.error,"failed to get first available block");return t.result}async getSupply(e){let t={};typeof e=="string"?t={commitment:e}:e?t={...e,commitment:e&&e.commitment||this.commitment}:t={commitment:this.commitment};const r=await this._rpcRequest("getSupply",[t]),s=oe(r,Up);if("error"in s)throw new ue(s.error,"failed to get supply");return s.result}async getTokenSupply(e,t){const r=this._buildArgs([e.toBase58()],t),s=await this._rpcRequest("getTokenSupply",r),i=oe(s,Ye(Ci));if("error"in i)throw new ue(i.error,"failed to get token supply");return i.result}async getTokenAccountBalance(e,t){const r=this._buildArgs([e.toBase58()],t),s=await this._rpcRequest("getTokenAccountBalance",r),i=oe(s,Ye(Ci));if("error"in i)throw new ue(i.error,"failed to get token account balance");return i.result}async getTokenAccountsByOwner(e,t,r){const{commitment:s,config:i}=Pe(r);let o=[e.toBase58()];"mint"in t?o.push({mint:t.mint.toBase58()}):o.push({programId:t.programId.toBase58()});const a=this._buildArgs(o,s,"base64",i),f=await this._rpcRequest("getTokenAccountsByOwner",a),g=oe(f,Fp);if("error"in g)throw new ue(g.error,`failed to get token accounts owned by account ${e.toBase58()}`);return g.result}async getParsedTokenAccountsByOwner(e,t,r){let s=[e.toBase58()];"mint"in t?s.push({mint:t.mint.toBase58()}):s.push({programId:t.programId.toBase58()});const i=this._buildArgs(s,r,"jsonParsed"),o=await this._rpcRequest("getTokenAccountsByOwner",i),a=oe(o,zp);if("error"in a)throw new ue(a.error,`failed to get token accounts owned by account ${e.toBase58()}`);return a.result}async getLargestAccounts(e){const t={...e,commitment:e&&e.commitment||this.commitment},r=t.filter||t.commitment?[t]:[],s=await this._rpcRequest("getLargestAccounts",r),i=oe(s,Kp);if("error"in i)throw new ue(i.error,"failed to get largest accounts");return i.result}async getTokenLargestAccounts(e,t){const r=this._buildArgs([e.toBase58()],t),s=await this._rpcRequest("getTokenLargestAccounts",r),i=oe(s,Dp);if("error"in i)throw new ue(i.error,"failed to get token largest accounts");return i.result}async getAccountInfoAndContext(e,t){const{commitment:r,config:s}=Pe(t),i=this._buildArgs([e.toBase58()],r,"base64",s),o=await this._rpcRequest("getAccountInfo",i),a=oe(o,Ye(ce(Qn)));if("error"in a)throw new ue(a.error,`failed to get info about account ${e.toBase58()}`);return a.result}async getParsedAccountInfo(e,t){const{commitment:r,config:s}=Pe(t),i=this._buildArgs([e.toBase58()],r,"jsonParsed",s),o=await this._rpcRequest("getAccountInfo",i),a=oe(o,Ye(ce(Pi)));if("error"in a)throw new ue(a.error,`failed to get info about account ${e.toBase58()}`);return a.result}async getAccountInfo(e,t){try{return(await this.getAccountInfoAndContext(e,t)).value}catch(r){throw new Error("failed to get info about account "+e.toBase58()+": "+r)}}async getMultipleParsedAccounts(e,t){const{commitment:r,config:s}=Pe(t),i=e.map(g=>g.toBase58()),o=this._buildArgs([i],r,"jsonParsed",s),a=await this._rpcRequest("getMultipleAccounts",o),f=oe(a,Ye(ae(ce(Pi))));if("error"in f)throw new ue(f.error,`failed to get info for accounts ${i}`);return f.result}async getMultipleAccountsInfoAndContext(e,t){const{commitment:r,config:s}=Pe(t),i=e.map(g=>g.toBase58()),o=this._buildArgs([i],r,"base64",s),a=await this._rpcRequest("getMultipleAccounts",o),f=oe(a,Ye(ae(ce(Qn))));if("error"in f)throw new ue(f.error,`failed to get info for accounts ${i}`);return f.result}async getMultipleAccountsInfo(e,t){return(await this.getMultipleAccountsInfoAndContext(e,t)).value}async getStakeActivation(e,t,r){const{commitment:s,config:i}=Pe(t),o=this._buildArgs([e.toBase58()],s,void 0,{...i,epoch:r??i?.epoch}),a=await this._rpcRequest("getStakeActivation",o),f=oe(a,be(qp));if("error"in f)throw new ue(f.error,`failed to get Stake Activation ${e.toBase58()}`);return f.result}async getProgramAccounts(e,t){const{commitment:r,config:s}=Pe(t),{encoding:i,...o}=s||{},a=this._buildArgs([e.toBase58()],r,i||"base64",{...o,...o.filters?{filters:sa(o.filters)}:null}),f=await this._rpcRequest("getProgramAccounts",a),g=ae($p),w=o.withContext===!0?oe(f,Ye(g)):oe(f,be(g));if("error"in w)throw new ue(w.error,`failed to get accounts owned by program ${e.toBase58()}`);return w.result}async getParsedProgramAccounts(e,t){const{commitment:r,config:s}=Pe(t),i=this._buildArgs([e.toBase58()],r,"jsonParsed",s),o=await this._rpcRequest("getProgramAccounts",i),a=oe(o,be(ae(Wp)));if("error"in a)throw new ue(a.error,`failed to get accounts owned by program ${e.toBase58()}`);return a.result}async confirmTransaction(e,t){let r;if(typeof e=="string")r=e;else{const i=e;if(i.abortSignal?.aborted)return Promise.reject(i.abortSignal.reason);r=i.signature}let s;try{s=pt.decode(r)}catch{throw new Error("signature must be base58 encoded: "+r)}return ve(s.length===64,"signature has invalid length"),typeof e=="string"?await this.confirmTransactionUsingLegacyTimeoutStrategy({commitment:t||this.commitment,signature:r}):"lastValidBlockHeight"in e?await this.confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:t||this.commitment,strategy:e}):await this.confirmTransactionUsingDurableNonceStrategy({commitment:t||this.commitment,strategy:e})}getCancellationPromise(e){return new Promise((t,r)=>{e!=null&&(e.aborted?r(e.reason):e.addEventListener("abort",()=>{r(e.reason)}))})}getTransactionConfirmationPromise({commitment:e,signature:t}){let r,s,i=!1;const o=new Promise((f,g)=>{try{r=this.onSignature(t,(b,x)=>{r=void 0;const T={context:x,value:b};f({__type:jt.PROCESSED,response:T})},e);const w=new Promise(b=>{r==null?b():s=this._onSubscriptionStateChange(r,x=>{x==="subscribed"&&b()})});(async()=>{if(await w,i)return;const b=await this.getSignatureStatus(t);if(i||b==null)return;const{context:x,value:T}=b;if(T!=null)if(T?.err)g(T.err);else{switch(e){case"confirmed":case"single":case"singleGossip":{if(T.confirmationStatus==="processed")return;break}case"finalized":case"max":case"root":{if(T.confirmationStatus==="processed"||T.confirmationStatus==="confirmed")return;break}case"processed":case"recent":}i=!0,f({__type:jt.PROCESSED,response:{context:x,value:T}})}})()}catch(w){g(w)}});return{abortConfirmation:()=>{s&&(s(),s=void 0),r!=null&&(this.removeSignatureListener(r),r=void 0)},confirmationPromise:o}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:e,strategy:{abortSignal:t,lastValidBlockHeight:r,signature:s}}){let i=!1;const o=new Promise(b=>{const x=async()=>{try{return await this.getBlockHeight(e)}catch{return-1}};(async()=>{let T=await x();if(!i){for(;T<=r;)if(await gn(1e3),i||(T=await x(),i))return;b({__type:jt.BLOCKHEIGHT_EXCEEDED})}})()}),{abortConfirmation:a,confirmationPromise:f}=this.getTransactionConfirmationPromise({commitment:e,signature:s}),g=this.getCancellationPromise(t);let w;try{const b=await Promise.race([g,f,o]);if(b.__type===jt.PROCESSED)w=b.response;else throw new Ei(s)}finally{i=!0,a()}return w}async confirmTransactionUsingDurableNonceStrategy({commitment:e,strategy:{abortSignal:t,minContextSlot:r,nonceAccountPubkey:s,nonceValue:i,signature:o}}){let a=!1;const f=new Promise(T=>{let L=i,O=null;const N=async()=>{try{const{context:M,value:H}=await this.getNonceAndContext(s,{commitment:e,minContextSlot:r});return O=M.slot,H?.nonce}catch{return L}};(async()=>{if(L=await N(),!a)for(;;){if(i!==L){T({__type:jt.NONCE_INVALID,slotInWhichNonceDidAdvance:O});return}if(await gn(2e3),a||(L=await N(),a))return}})()}),{abortConfirmation:g,confirmationPromise:w}=this.getTransactionConfirmationPromise({commitment:e,signature:o}),b=this.getCancellationPromise(t);let x;try{const T=await Promise.race([b,w,f]);if(T.__type===jt.PROCESSED)x=T.response;else{let L;for(;;){const O=await this.getSignatureStatus(o);if(O==null)break;if(O.context.slot<(T.slotInWhichNonceDidAdvance??r)){await gn(400);continue}L=O;break}if(L?.value){const O=e||"finalized",{confirmationStatus:N}=L.value;switch(O){case"processed":case"recent":if(N!=="processed"&&N!=="confirmed"&&N!=="finalized")throw new Nn(o);break;case"confirmed":case"single":case"singleGossip":if(N!=="confirmed"&&N!=="finalized")throw new Nn(o);break;case"finalized":case"max":case"root":if(N!=="finalized")throw new Nn(o);break;default:}x={context:L.context,value:{err:L.value.err}}}else throw new Nn(o)}}finally{a=!0,g()}return x}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:e,signature:t}){let r;const s=new Promise(f=>{let g=this._confirmTransactionInitialTimeout||6e4;switch(e){case"processed":case"recent":case"single":case"confirmed":case"singleGossip":{g=this._confirmTransactionInitialTimeout||3e4;break}}r=setTimeout(()=>f({__type:jt.TIMED_OUT,timeoutMs:g}),g)}),{abortConfirmation:i,confirmationPromise:o}=this.getTransactionConfirmationPromise({commitment:e,signature:t});let a;try{const f=await Promise.race([o,s]);if(f.__type===jt.PROCESSED)a=f.response;else throw new Si(t,f.timeoutMs/1e3)}finally{clearTimeout(r),i()}return a}async getClusterNodes(){const e=await this._rpcRequest("getClusterNodes",[]),t=oe(e,be(ae(rg)));if("error"in t)throw new ue(t.error,"failed to get cluster nodes");return t.result}async getVoteAccounts(e){const t=this._buildArgs([],e),r=await this._rpcRequest("getVoteAccounts",t),s=oe(r,ig);if("error"in s)throw new ue(s.error,"failed to get vote accounts");return s.result}async getSlot(e){const{commitment:t,config:r}=Pe(e),s=this._buildArgs([],t,void 0,r),i=await this._rpcRequest("getSlot",s),o=oe(i,be($()));if("error"in o)throw new ue(o.error,"failed to get slot");return o.result}async getSlotLeader(e){const{commitment:t,config:r}=Pe(e),s=this._buildArgs([],t,void 0,r),i=await this._rpcRequest("getSlotLeader",s),o=oe(i,be(ie()));if("error"in o)throw new ue(o.error,"failed to get slot leader");return o.result}async getSlotLeaders(e,t){const r=[e,t],s=await this._rpcRequest("getSlotLeaders",r),i=oe(s,be(ae(Ve)));if("error"in i)throw new ue(i.error,"failed to get slot leaders");return i.result}async getSignatureStatus(e,t){const{context:r,value:s}=await this.getSignatureStatuses([e],t);ve(s.length===1);const i=s[0];return{context:r,value:i}}async getSignatureStatuses(e,t){const r=[e];t&&r.push(t);const s=await this._rpcRequest("getSignatureStatuses",r),i=oe(s,ag);if("error"in i)throw new ue(i.error,"failed to get signature status");return i.result}async getTransactionCount(e){const{commitment:t,config:r}=Pe(e),s=this._buildArgs([],t,void 0,r),i=await this._rpcRequest("getTransactionCount",s),o=oe(i,be($()));if("error"in o)throw new ue(o.error,"failed to get transaction count");return o.result}async getTotalSupply(e){return(await this.getSupply({commitment:e,excludeNonCirculatingAccountsList:!0})).value.total}async getInflationGovernor(e){const t=this._buildArgs([],e),r=await this._rpcRequest("getInflationGovernor",t),s=oe(r,Np);if("error"in s)throw new ue(s.error,"failed to get inflation");return s.result}async getInflationReward(e,t,r){const{commitment:s,config:i}=Pe(r),o=this._buildArgs([e.map(g=>g.toBase58())],s,void 0,{...i,epoch:t??i?.epoch}),a=await this._rpcRequest("getInflationReward",o),f=oe(a,gp);if("error"in f)throw new ue(f.error,"failed to get inflation reward");return f.result}async getInflationRate(){const e=await this._rpcRequest("getInflationRate",[]),t=oe(e,xp);if("error"in t)throw new ue(t.error,"failed to get inflation rate");return t.result}async getEpochInfo(e){const{commitment:t,config:r}=Pe(e),s=this._buildArgs([],t,void 0,r),i=await this._rpcRequest("getEpochInfo",s),o=oe(i,Lp);if("error"in o)throw new ue(o.error,"failed to get epoch info");return o.result}async getEpochSchedule(){const e=await this._rpcRequest("getEpochSchedule",[]),t=oe(e,Cp);if("error"in t)throw new ue(t.error,"failed to get epoch schedule");const r=t.result;return new ta(r.slotsPerEpoch,r.leaderScheduleSlotOffset,r.warmup,r.firstNormalEpoch,r.firstNormalSlot)}async getLeaderSchedule(){const e=await this._rpcRequest("getLeaderSchedule",[]),t=oe(e,Mp);if("error"in t)throw new ue(t.error,"failed to get leader schedule");return t.result}async getMinimumBalanceForRentExemption(e,t){const r=this._buildArgs([e],t),s=await this._rpcRequest("getMinimumBalanceForRentExemption",r),i=oe(s,cg);return"error"in i?(console.warn("Unable to fetch minimum balance for rent exemption"),0):i.result}async getRecentBlockhashAndContext(e){const{context:t,value:{blockhash:r}}=await this.getLatestBlockhashAndContext(e);return{context:t,value:{blockhash:r,feeCalculator:{get lamportsPerSignature(){throw new Error("The capability to fetch `lamportsPerSignature` using the `getRecentBlockhash` API is no longer offered by the network. Use the `getFeeForMessage` API to obtain the fee for a given message.")},toJSON(){return{}}}}}}async getRecentPerformanceSamples(e){const t=await this._rpcRequest("getRecentPerformanceSamples",e?[e]:[]),r=oe(t,Rg);if("error"in r)throw new ue(r.error,"failed to get recent performance samples");return r.result}async getFeeCalculatorForBlockhash(e,t){const r=this._buildArgs([e],t),s=await this._rpcRequest("getFeeCalculatorForBlockhash",r),i=oe(s,Eg);if("error"in i)throw new ue(i.error,"failed to get fee calculator");const{context:o,value:a}=i.result;return{context:o,value:a!==null?a.feeCalculator:null}}async getFeeForMessage(e,t){const r=we(e.serialize()).toString("base64"),s=this._buildArgs([r],t),i=await this._rpcRequest("getFeeForMessage",s),o=oe(i,Ye(ce($())));if("error"in o)throw new ue(o.error,"failed to get fee for message");if(o.result===null)throw new Error("invalid blockhash");return o.result}async getRecentPrioritizationFees(e){const t=e?.lockedWritableAccounts?.map(o=>o.toBase58()),r=t?.length?[t]:[],s=await this._rpcRequest("getRecentPrioritizationFees",r),i=oe(s,Bp);if("error"in i)throw new ue(i.error,"failed to get recent prioritization fees");return i.result}async getRecentBlockhash(e){try{return(await this.getRecentBlockhashAndContext(e)).value}catch(t){throw new Error("failed to get recent blockhash: "+t)}}async getLatestBlockhash(e){try{return(await this.getLatestBlockhashAndContext(e)).value}catch(t){throw new Error("failed to get recent blockhash: "+t)}}async getLatestBlockhashAndContext(e){const{commitment:t,config:r}=Pe(e),s=this._buildArgs([],t,void 0,r),i=await this._rpcRequest("getLatestBlockhash",s),o=oe(i,yg);if("error"in o)throw new ue(o.error,"failed to get latest blockhash");return o.result}async isBlockhashValid(e,t){const{commitment:r,config:s}=Pe(t),i=this._buildArgs([e],r,void 0,s),o=await this._rpcRequest("isBlockhashValid",i),a=oe(o,wg);if("error"in a)throw new ue(a.error,"failed to determine if the blockhash `"+e+"`is valid");return a.result}async getVersion(){const e=await this._rpcRequest("getVersion",[]),t=oe(e,be(Sp));if("error"in t)throw new ue(t.error,"failed to get version");return t.result}async getGenesisHash(){const e=await this._rpcRequest("getGenesisHash",[]),t=oe(e,be(ie()));if("error"in t)throw new ue(t.error,"failed to get genesis hash");return t.result}async getBlock(e,t){const{commitment:r,config:s}=Pe(t),i=this._buildArgsAtLeastConfirmed([e],r,void 0,s),o=await this._rpcRequest("getBlock",i);try{switch(s?.transactionDetails){case"accounts":{const a=oe(o,dg);if("error"in a)throw a.error;return a.result}case"none":{const a=oe(o,fg);if("error"in a)throw a.error;return a.result}default:{const a=oe(o,hg);if("error"in a)throw a.error;const{result:f}=a;return f?{...f,transactions:f.transactions.map(({transaction:g,meta:w,version:b})=>({meta:w,transaction:{...g,message:Li(b,g.message)},version:b}))}:null}}}catch(a){throw new ue(a,"failed to get confirmed block")}}async getParsedBlock(e,t){const{commitment:r,config:s}=Pe(t),i=this._buildArgsAtLeastConfirmed([e],r,"jsonParsed",s),o=await this._rpcRequest("getBlock",i);try{switch(s?.transactionDetails){case"accounts":{const a=oe(o,gg);if("error"in a)throw a.error;return a.result}case"none":{const a=oe(o,mg);if("error"in a)throw a.error;return a.result}default:{const a=oe(o,pg);if("error"in a)throw a.error;return a.result}}}catch(a){throw new ue(a,"failed to get block")}}async getBlockProduction(e){let t,r;if(typeof e=="string")r=e;else if(e){const{commitment:a,...f}=e;r=a,t=f}const s=this._buildArgs([],r,"base64",t),i=await this._rpcRequest("getBlockProduction",s),o=oe(i,vp);if("error"in o)throw new ue(o.error,"failed to get block production information");return o.result}async getTransaction(e,t){const{commitment:r,config:s}=Pe(t),i=this._buildArgsAtLeastConfirmed([e],r,void 0,s),o=await this._rpcRequest("getTransaction",i),a=oe(o,Fi);if("error"in a)throw new ue(a.error,"failed to get transaction");const f=a.result;return f&&{...f,transaction:{...f.transaction,message:Li(f.version,f.transaction.message)}}}async getParsedTransaction(e,t){const{commitment:r,config:s}=Pe(t),i=this._buildArgsAtLeastConfirmed([e],r,"jsonParsed",s),o=await this._rpcRequest("getTransaction",i),a=oe(o,Nr);if("error"in a)throw new ue(a.error,"failed to get transaction");return a.result}async getParsedTransactions(e,t){const{commitment:r,config:s}=Pe(t),i=e.map(f=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([f],r,"jsonParsed",s)}));return(await this._rpcBatchRequest(i)).map(f=>{const g=oe(f,Nr);if("error"in g)throw new ue(g.error,"failed to get transactions");return g.result})}async getTransactions(e,t){const{commitment:r,config:s}=Pe(t),i=e.map(f=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([f],r,void 0,s)}));return(await this._rpcBatchRequest(i)).map(f=>{const g=oe(f,Fi);if("error"in g)throw new ue(g.error,"failed to get transactions");const w=g.result;return w&&{...w,transaction:{...w.transaction,message:Li(w.version,w.transaction.message)}}})}async getConfirmedBlock(e,t){const r=this._buildArgsAtLeastConfirmed([e],t),s=await this._rpcRequest("getBlock",r),i=oe(s,_g);if("error"in i)throw new ue(i.error,"failed to get confirmed block");const o=i.result;if(!o)throw new Error("Confirmed block "+e+" not found");const a={...o,transactions:o.transactions.map(({transaction:f,meta:g})=>{const w=new Bt(f.message);return{meta:g,transaction:{...f,message:w}}})};return{...a,transactions:a.transactions.map(({transaction:f,meta:g})=>({meta:g,transaction:Oe.populate(f.message,f.signatures)}))}}async getBlocks(e,t,r){const s=this._buildArgsAtLeastConfirmed(t!==void 0?[e,t]:[e],r),i=await this._rpcRequest("getBlocks",s),o=oe(i,be(ae($())));if("error"in o)throw new ue(o.error,"failed to get blocks");return o.result}async getBlockSignatures(e,t){const r=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:"signatures",rewards:!1}),s=await this._rpcRequest("getBlock",r),i=oe(s,_a);if("error"in i)throw new ue(i.error,"failed to get block");const o=i.result;if(!o)throw new Error("Block "+e+" not found");return o}async getConfirmedBlockSignatures(e,t){const r=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:"signatures",rewards:!1}),s=await this._rpcRequest("getBlock",r),i=oe(s,_a);if("error"in i)throw new ue(i.error,"failed to get confirmed block");const o=i.result;if(!o)throw new Error("Confirmed block "+e+" not found");return o}async getConfirmedTransaction(e,t){const r=this._buildArgsAtLeastConfirmed([e],t),s=await this._rpcRequest("getTransaction",r),i=oe(s,Fi);if("error"in i)throw new ue(i.error,"failed to get transaction");const o=i.result;if(!o)return o;const a=new Bt(o.transaction.message),f=o.transaction.signatures;return{...o,transaction:Oe.populate(a,f)}}async getParsedConfirmedTransaction(e,t){const r=this._buildArgsAtLeastConfirmed([e],t,"jsonParsed"),s=await this._rpcRequest("getTransaction",r),i=oe(s,Nr);if("error"in i)throw new ue(i.error,"failed to get confirmed transaction");return i.result}async getParsedConfirmedTransactions(e,t){const r=e.map(o=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([o],t,"jsonParsed")}));return(await this._rpcBatchRequest(r)).map(o=>{const a=oe(o,Nr);if("error"in a)throw new ue(a.error,"failed to get confirmed transactions");return a.result})}async getConfirmedSignaturesForAddress(e,t,r){let s={},i=await this.getFirstAvailableBlock();for(;!("until"in s)&&(t--,!(t<=0||t<i));)try{const f=await this.getConfirmedBlockSignatures(t,"finalized");f.signatures.length>0&&(s.until=f.signatures[f.signatures.length-1].toString())}catch(f){if(f instanceof Error&&f.message.includes("skipped"))continue;throw f}let o=await this.getSlot("finalized");for(;!("before"in s)&&(r++,!(r>o));)try{const f=await this.getConfirmedBlockSignatures(r);f.signatures.length>0&&(s.before=f.signatures[f.signatures.length-1].toString())}catch(f){if(f instanceof Error&&f.message.includes("skipped"))continue;throw f}return(await this.getConfirmedSignaturesForAddress2(e,s)).map(f=>f.signature)}async getConfirmedSignaturesForAddress2(e,t,r){const s=this._buildArgsAtLeastConfirmed([e.toBase58()],r,void 0,t),i=await this._rpcRequest("getConfirmedSignaturesForAddress2",s),o=oe(i,Vp);if("error"in o)throw new ue(o.error,"failed to get confirmed signatures for address");return o.result}async getSignaturesForAddress(e,t,r){const s=this._buildArgsAtLeastConfirmed([e.toBase58()],r,void 0,t),i=await this._rpcRequest("getSignaturesForAddress",s),o=oe(i,Gp);if("error"in o)throw new ue(o.error,"failed to get signatures for address");return o.result}async getAddressLookupTable(e,t){const{context:r,value:s}=await this.getAccountInfoAndContext(e,t);let i=null;return s!==null&&(i=new xi({key:e,state:xi.deserialize(s.data)})),{context:r,value:i}}async getNonceAndContext(e,t){const{context:r,value:s}=await this.getAccountInfoAndContext(e,t);let i=null;return s!==null&&(i=vr.fromAccountData(s.data)),{context:r,value:i}}async getNonce(e,t){return await this.getNonceAndContext(e,t).then(r=>r.value).catch(r=>{throw new Error("failed to get nonce for account "+e.toBase58()+": "+r)})}async requestAirdrop(e,t){const r=await this._rpcRequest("requestAirdrop",[e.toBase58(),t]),s=oe(r,Sg);if("error"in s)throw new ue(s.error,`airdrop to ${e.toBase58()} failed`);return s.result}async _blockhashWithExpiryBlockHeight(e){if(!e){for(;this._pollingBlockhash;)await gn(100);const r=Date.now()-this._blockhashInfo.lastFetch>=ia;if(this._blockhashInfo.latestBlockhash!==null&&!r)return this._blockhashInfo.latestBlockhash}return await this._pollNewBlockhash()}async _pollNewBlockhash(){this._pollingBlockhash=!0;try{const e=Date.now(),t=this._blockhashInfo.latestBlockhash,r=t?t.blockhash:null;for(let s=0;s<50;s++){const i=await this.getLatestBlockhash("finalized");if(r!==i.blockhash)return this._blockhashInfo={latestBlockhash:i,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},i;await gn(Zo/2)}throw new Error(`Unable to obtain a new blockhash after ${Date.now()-e}ms`)}finally{this._pollingBlockhash=!1}}async getStakeMinimumDelegation(e){const{commitment:t,config:r}=Pe(e),s=this._buildArgs([],t,"base64",r),i=await this._rpcRequest("getStakeMinimumDelegation",s),o=oe(i,Ye($()));if("error"in o)throw new ue(o.error,"failed to get stake minimum delegation");return o.result}async simulateTransaction(e,t,r){if("message"in e){const O=e.serialize(),N=he.Buffer.from(O).toString("base64");if(Array.isArray(t)||r!==void 0)throw new Error("Invalid arguments");const M=t||{};M.encoding="base64","commitment"in M||(M.commitment=this.commitment),t&&typeof t=="object"&&"innerInstructions"in t&&(M.innerInstructions=t.innerInstructions);const H=[N,M],K=await this._rpcRequest("simulateTransaction",H),Q=oe(K,aa);if("error"in Q)throw new Error("failed to simulate transaction: "+Q.error.message);return Q.result}let s;if(e instanceof Oe){let L=e;s=new Oe,s.feePayer=L.feePayer,s.instructions=e.instructions,s.nonceInfo=L.nonceInfo,s.signatures=L.signatures}else s=Oe.populate(e),s._message=s._json=void 0;if(t!==void 0&&!Array.isArray(t))throw new Error("Invalid arguments");const i=t;if(s.nonceInfo&&i)s.sign(...i);else{let L=this._disableBlockhashCaching;for(;;){const O=await this._blockhashWithExpiryBlockHeight(L);if(s.lastValidBlockHeight=O.lastValidBlockHeight,s.recentBlockhash=O.blockhash,!i)break;if(s.sign(...i),!s.signature)throw new Error("!signature");const N=s.signature.toString("base64");if(!this._blockhashInfo.simulatedSignatures.includes(N)&&!this._blockhashInfo.transactionSignatures.includes(N)){this._blockhashInfo.simulatedSignatures.push(N);break}else L=!0}}const o=s._compile(),a=o.serialize(),g=s._serialize(a).toString("base64"),w={encoding:"base64",commitment:this.commitment};if(r){const L=(Array.isArray(r)?r:o.nonProgramIds()).map(O=>O.toBase58());w.accounts={encoding:"base64",addresses:L}}i&&(w.sigVerify=!0),t&&typeof t=="object"&&"innerInstructions"in t&&(w.innerInstructions=t.innerInstructions);const b=[g,w],x=await this._rpcRequest("simulateTransaction",b),T=oe(x,aa);if("error"in T){let L;if("data"in T.error&&(L=T.error.data.logs,L&&Array.isArray(L))){const O=`
|
|
17
|
+
`,N=O+L.join(O);console.error(T.error.message,N)}throw new Xn({action:"simulate",signature:"",transactionMessage:T.error.message,logs:L})}return T.result}async sendTransaction(e,t,r){if("version"in e){if(t&&Array.isArray(t))throw new Error("Invalid arguments");const o=e.serialize();return await this.sendRawTransaction(o,t)}if(t===void 0||!Array.isArray(t))throw new Error("Invalid arguments");const s=t;if(e.nonceInfo)e.sign(...s);else{let o=this._disableBlockhashCaching;for(;;){const a=await this._blockhashWithExpiryBlockHeight(o);if(e.lastValidBlockHeight=a.lastValidBlockHeight,e.recentBlockhash=a.blockhash,e.sign(...s),!e.signature)throw new Error("!signature");const f=e.signature.toString("base64");if(this._blockhashInfo.transactionSignatures.includes(f))o=!0;else{this._blockhashInfo.transactionSignatures.push(f);break}}}const i=e.serialize();return await this.sendRawTransaction(i,r)}async sendRawTransaction(e,t){const r=we(e).toString("base64");return await this.sendEncodedTransaction(r,t)}async sendEncodedTransaction(e,t){const r={encoding:"base64"},s=t&&t.skipPreflight,i=s===!0?"processed":t&&t.preflightCommitment||this.commitment;t&&t.maxRetries!=null&&(r.maxRetries=t.maxRetries),t&&t.minContextSlot!=null&&(r.minContextSlot=t.minContextSlot),s&&(r.skipPreflight=s),i&&(r.preflightCommitment=i);const o=[e,r],a=await this._rpcRequest("sendTransaction",o),f=oe(a,Ag);if("error"in f){let g;throw"data"in f.error&&(g=f.error.data.logs),new Xn({action:s?"send":"simulate",signature:"",transactionMessage:f.error.message,logs:g})}return f.result}_wsOnOpen(){this._rpcWebSocketConnected=!0,this._rpcWebSocketHeartbeat=setInterval(()=>{(async()=>{try{await this._rpcWebSocket.notify("ping")}catch{}})()},5e3),this._updateSubscriptions()}_wsOnError(e){this._rpcWebSocketConnected=!1,console.error("ws error:",e.message)}_wsOnClose(e){if(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),e===1e3){this._updateSubscriptions();return}this._subscriptionCallbacksByServerSubscriptionId={},Object.entries(this._subscriptionsByHash).forEach(([t,r])=>{this._setSubscription(t,{...r,state:"pending"})})}_setSubscription(e,t){const r=this._subscriptionsByHash[e]?.state;if(this._subscriptionsByHash[e]=t,r!==t.state){const s=this._subscriptionStateChangeCallbacksByHash[e];s&&s.forEach(i=>{try{i(t.state)}catch{}})}}_onSubscriptionStateChange(e,t){const r=this._subscriptionHashByClientSubscriptionId[e];if(r==null)return()=>{};const s=this._subscriptionStateChangeCallbacksByHash[r]||=new Set;return s.add(t),()=>{s.delete(t),s.size===0&&delete this._subscriptionStateChangeCallbacksByHash[r]}}async _updateSubscriptions(){if(Object.keys(this._subscriptionsByHash).length===0){this._rpcWebSocketConnected&&(this._rpcWebSocketConnected=!1,this._rpcWebSocketIdleTimeout=setTimeout(()=>{this._rpcWebSocketIdleTimeout=null;try{this._rpcWebSocket.close()}catch(r){r instanceof Error&&console.log(`Error when closing socket connection: ${r.message}`)}},500));return}if(this._rpcWebSocketIdleTimeout!==null&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketConnected=!0),!this._rpcWebSocketConnected){this._rpcWebSocket.connect();return}const e=this._rpcWebSocketGeneration,t=()=>e===this._rpcWebSocketGeneration;await Promise.all(Object.keys(this._subscriptionsByHash).map(async r=>{const s=this._subscriptionsByHash[r];if(s!==void 0)switch(s.state){case"pending":case"unsubscribed":if(s.callbacks.size===0){delete this._subscriptionsByHash[r],s.state==="unsubscribed"&&delete this._subscriptionCallbacksByServerSubscriptionId[s.serverSubscriptionId],await this._updateSubscriptions();return}await(async()=>{const{args:i,method:o}=s;try{this._setSubscription(r,{...s,state:"subscribing"});const a=await this._rpcWebSocket.call(o,i);this._setSubscription(r,{...s,serverSubscriptionId:a,state:"subscribed"}),this._subscriptionCallbacksByServerSubscriptionId[a]=s.callbacks,await this._updateSubscriptions()}catch(a){if(console.error(`Received ${a instanceof Error?"":"JSON-RPC "}error calling \`${o}\``,{args:i,error:a}),!t())return;this._setSubscription(r,{...s,state:"pending"}),await this._updateSubscriptions()}})();break;case"subscribed":s.callbacks.size===0&&await(async()=>{const{serverSubscriptionId:i,unsubscribeMethod:o}=s;if(this._subscriptionsAutoDisposedByRpc.has(i))this._subscriptionsAutoDisposedByRpc.delete(i);else{this._setSubscription(r,{...s,state:"unsubscribing"}),this._setSubscription(r,{...s,state:"unsubscribing"});try{await this._rpcWebSocket.call(o,[i])}catch(a){if(a instanceof Error&&console.error(`${o} error:`,a.message),!t())return;this._setSubscription(r,{...s,state:"subscribed"}),await this._updateSubscriptions();return}}this._setSubscription(r,{...s,state:"unsubscribed"}),await this._updateSubscriptions()})();break}}))}_handleServerNotification(e,t){const r=this._subscriptionCallbacksByServerSubscriptionId[e];r!==void 0&&r.forEach(s=>{try{s(...t)}catch(i){console.error(i)}})}_wsOnAccountNotification(e){const{result:t,subscription:r}=oe(e,Yp);this._handleServerNotification(r,[t.value,t.context])}_makeSubscription(e,t){const r=this._nextClientSubscriptionId++,s=ea([e.method,t]),i=this._subscriptionsByHash[s];return i===void 0?this._subscriptionsByHash[s]={...e,args:t,callbacks:new Set([e.callback]),state:"pending"}:i.callbacks.add(e.callback),this._subscriptionHashByClientSubscriptionId[r]=s,this._subscriptionDisposeFunctionsByClientSubscriptionId[r]=async()=>{delete this._subscriptionDisposeFunctionsByClientSubscriptionId[r],delete this._subscriptionHashByClientSubscriptionId[r];const o=this._subscriptionsByHash[s];ve(o!==void 0,`Could not find a \`Subscription\` when tearing down client subscription #${r}`),o.callbacks.delete(e.callback),await this._updateSubscriptions()},this._updateSubscriptions(),r}onAccountChange(e,t,r){const{commitment:s,config:i}=Pe(r),o=this._buildArgs([e.toBase58()],s||this._commitment||"finalized","base64",i);return this._makeSubscription({callback:t,method:"accountSubscribe",unsubscribeMethod:"accountUnsubscribe"},o)}async removeAccountChangeListener(e){await this._unsubscribeClientSubscription(e,"account change")}_wsOnProgramAccountNotification(e){const{result:t,subscription:r}=oe(e,Zp);this._handleServerNotification(r,[{accountId:t.value.pubkey,accountInfo:t.value.account},t.context])}onProgramAccountChange(e,t,r,s){const{commitment:i,config:o}=Pe(r),a=this._buildArgs([e.toBase58()],i||this._commitment||"finalized","base64",o||(s?{filters:sa(s)}:void 0));return this._makeSubscription({callback:t,method:"programSubscribe",unsubscribeMethod:"programUnsubscribe"},a)}async removeProgramAccountChangeListener(e){await this._unsubscribeClientSubscription(e,"program account change")}onLogs(e,t,r){const s=this._buildArgs([typeof e=="object"?{mentions:[e.toString()]}:e],r||this._commitment||"finalized");return this._makeSubscription({callback:t,method:"logsSubscribe",unsubscribeMethod:"logsUnsubscribe"},s)}async removeOnLogsListener(e){await this._unsubscribeClientSubscription(e,"logs")}_wsOnLogsNotification(e){const{result:t,subscription:r}=oe(e,vg);this._handleServerNotification(r,[t.value,t.context])}_wsOnSlotNotification(e){const{result:t,subscription:r}=oe(e,Jp);this._handleServerNotification(r,[t])}onSlotChange(e){return this._makeSubscription({callback:e,method:"slotSubscribe",unsubscribeMethod:"slotUnsubscribe"},[])}async removeSlotChangeListener(e){await this._unsubscribeClientSubscription(e,"slot change")}_wsOnSlotUpdatesNotification(e){const{result:t,subscription:r}=oe(e,eg);this._handleServerNotification(r,[t])}onSlotUpdate(e){return this._makeSubscription({callback:e,method:"slotsUpdatesSubscribe",unsubscribeMethod:"slotsUpdatesUnsubscribe"},[])}async removeSlotUpdateListener(e){await this._unsubscribeClientSubscription(e,"slot update")}async _unsubscribeClientSubscription(e,t){const r=this._subscriptionDisposeFunctionsByClientSubscriptionId[e];r?await r():console.warn(`Ignored unsubscribe request because an active subscription with id \`${e}\` for '${t}' events could not be found.`)}_buildArgs(e,t,r,s){const i=t||this._commitment;if(i||r||s){let o={};r&&(o.encoding=r),i&&(o.commitment=i),s&&(o=Object.assign(o,s)),e.push(o)}return e}_buildArgsAtLeastConfirmed(e,t,r,s){const i=t||this._commitment;if(i&&!["confirmed","finalized"].includes(i))throw new Error("Using Connection with default commitment: `"+this._commitment+"`, but method requires at least `confirmed`");return this._buildArgs(e,t,r,s)}_wsOnSignatureNotification(e){const{result:t,subscription:r}=oe(e,tg);t.value!=="receivedSignature"&&this._subscriptionsAutoDisposedByRpc.add(r),this._handleServerNotification(r,t.value==="receivedSignature"?[{type:"received"},t.context]:[{type:"status",result:t.value},t.context])}onSignature(e,t,r){const s=this._buildArgs([e],r||this._commitment||"finalized"),i=this._makeSubscription({callback:(o,a)=>{if(o.type==="status"){t(o.result,a);try{this.removeSignatureListener(i)}catch{}}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},s);return i}onSignatureWithOptions(e,t,r){const{commitment:s,...i}={...r,commitment:r&&r.commitment||this._commitment||"finalized"},o=this._buildArgs([e],s,void 0,i),a=this._makeSubscription({callback:(f,g)=>{t(f,g);try{this.removeSignatureListener(a)}catch{}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},o);return a}async removeSignatureListener(e){await this._unsubscribeClientSubscription(e,"signature result")}_wsOnRootNotification(e){const{result:t,subscription:r}=oe(e,ng);this._handleServerNotification(r,[t])}onRootChange(e){return this._makeSubscription({callback:e,method:"rootSubscribe",unsubscribeMethod:"rootUnsubscribe"},[])}async removeRootChangeListener(e){await this._unsubscribeClientSubscription(e,"root change")}}class Cn{constructor(e){this._keypair=void 0,this._keypair=e??Ho()}static generate(){return new Cn(Ho())}static fromSecretKey(e,t){if(e.byteLength!==64)throw new Error("bad secret key size");const r=e.slice(32,64);if(!t||!t.skipValidation){const s=e.slice(0,32),i=Rr(s);for(let o=0;o<32;o++)if(r[o]!==i[o])throw new Error("provided secretKey is invalid")}return new Cn({publicKey:r,secretKey:e})}static fromSeed(e){const t=Rr(e),r=new Uint8Array(64);return r.set(e),r.set(t,32),new Cn({publicKey:t,secretKey:r})}get publicKey(){return new se(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}}const Zt=Object.freeze({CreateLookupTable:{index:0,layout:B.struct([B.u32("instruction"),Bn("recentSlot"),B.u8("bumpSeed")])},FreezeLookupTable:{index:1,layout:B.struct([B.u32("instruction")])},ExtendLookupTable:{index:2,layout:B.struct([B.u32("instruction"),Bn(),B.seq(Ee(),B.offset(B.u32(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:B.struct([B.u32("instruction")])},CloseLookupTable:{index:4,layout:B.struct([B.u32("instruction")])}});class Tg{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);const r=B.u32("instruction").decode(e.data);let s;for(const[i,o]of Object.entries(Zt))if(o.index==r){s=i;break}if(!s)throw new Error("Invalid Instruction. Should be a LookupTable Instruction");return s}static decodeCreateLookupTable(e){this.checkProgramId(e.programId),this.checkKeysLength(e.keys,4);const{recentSlot:t}=ke(Zt.CreateLookupTable,e.data);return{authority:e.keys[1].pubkey,payer:e.keys[2].pubkey,recentSlot:Number(t)}}static decodeExtendLookupTable(e){if(this.checkProgramId(e.programId),e.keys.length<2)throw new Error(`invalid instruction; found ${e.keys.length} keys, expected at least 2`);const{addresses:t}=ke(Zt.ExtendLookupTable,e.data);return{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey,payer:e.keys.length>2?e.keys[2].pubkey:void 0,addresses:t.map(r=>new se(r))}}static decodeCloseLookupTable(e){return this.checkProgramId(e.programId),this.checkKeysLength(e.keys,3),{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey,recipient:e.keys[2].pubkey}}static decodeFreezeLookupTable(e){return this.checkProgramId(e.programId),this.checkKeysLength(e.keys,2),{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey}}static decodeDeactivateLookupTable(e){return this.checkProgramId(e.programId),this.checkKeysLength(e.keys,2),{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey}}static checkProgramId(e){if(!e.equals(zi.programId))throw new Error("invalid instruction; programId is not AddressLookupTable Program")}static checkKeysLength(e,t){if(e.length<t)throw new Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}}class zi{constructor(){}static createLookupTable(e){const[t,r]=se.findProgramAddressSync([e.authority.toBuffer(),mo().encode(e.recentSlot)],this.programId),s=Zt.CreateLookupTable,i=Ie(s,{recentSlot:BigInt(e.recentSlot),bumpSeed:r}),o=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1},{pubkey:e.payer,isSigner:!0,isWritable:!0},{pubkey:gt.programId,isSigner:!1,isWritable:!1}];return[new xe({programId:this.programId,keys:o,data:i}),t]}static freezeLookupTable(e){const t=Zt.FreezeLookupTable,r=Ie(t),s=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new xe({programId:this.programId,keys:s,data:r})}static extendLookupTable(e){const t=Zt.ExtendLookupTable,r=Ie(t,{addresses:e.addresses.map(i=>i.toBytes())}),s=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return e.payer&&s.push({pubkey:e.payer,isSigner:!0,isWritable:!0},{pubkey:gt.programId,isSigner:!1,isWritable:!1}),new xe({programId:this.programId,keys:s,data:r})}static deactivateLookupTable(e){const t=Zt.DeactivateLookupTable,r=Ie(t),s=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new xe({programId:this.programId,keys:s,data:r})}static closeLookupTable(e){const t=Zt.CloseLookupTable,r=Ie(t),s=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1},{pubkey:e.recipient,isSigner:!1,isWritable:!0}];return new xe({programId:this.programId,keys:s,data:r})}}zi.programId=new se("AddressLookupTab1e1111111111111111111111111");class Ng{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);const r=B.u8("instruction").decode(e.data);let s;for(const[i,o]of Object.entries(Kt))if(o.index==r){s=i;break}if(!s)throw new Error("Instruction type incorrect; not a ComputeBudgetInstruction");return s}static decodeRequestUnits(e){this.checkProgramId(e.programId);const{units:t,additionalFee:r}=ke(Kt.RequestUnits,e.data);return{units:t,additionalFee:r}}static decodeRequestHeapFrame(e){this.checkProgramId(e.programId);const{bytes:t}=ke(Kt.RequestHeapFrame,e.data);return{bytes:t}}static decodeSetComputeUnitLimit(e){this.checkProgramId(e.programId);const{units:t}=ke(Kt.SetComputeUnitLimit,e.data);return{units:t}}static decodeSetComputeUnitPrice(e){this.checkProgramId(e.programId);const{microLamports:t}=ke(Kt.SetComputeUnitPrice,e.data);return{microLamports:t}}static checkProgramId(e){if(!e.equals(Ki.programId))throw new Error("invalid instruction; programId is not ComputeBudgetProgram")}}const Kt=Object.freeze({RequestUnits:{index:0,layout:B.struct([B.u8("instruction"),B.u32("units"),B.u32("additionalFee")])},RequestHeapFrame:{index:1,layout:B.struct([B.u8("instruction"),B.u32("bytes")])},SetComputeUnitLimit:{index:2,layout:B.struct([B.u8("instruction"),B.u32("units")])},SetComputeUnitPrice:{index:3,layout:B.struct([B.u8("instruction"),Bn("microLamports")])}});class Ki{constructor(){}static requestUnits(e){const t=Kt.RequestUnits,r=Ie(t,e);return new xe({keys:[],programId:this.programId,data:r})}static requestHeapFrame(e){const t=Kt.RequestHeapFrame,r=Ie(t,e);return new xe({keys:[],programId:this.programId,data:r})}static setComputeUnitLimit(e){const t=Kt.SetComputeUnitLimit,r=Ie(t,e);return new xe({keys:[],programId:this.programId,data:r})}static setComputeUnitPrice(e){const t=Kt.SetComputeUnitPrice,r=Ie(t,{microLamports:BigInt(e.microLamports)});return new xe({keys:[],programId:this.programId,data:r})}}Ki.programId=new se("ComputeBudget111111111111111111111111111111");const ya=64,wa=32,ba=64,Ra=B.struct([B.u8("numSignatures"),B.u8("padding"),B.u16("signatureOffset"),B.u16("signatureInstructionIndex"),B.u16("publicKeyOffset"),B.u16("publicKeyInstructionIndex"),B.u16("messageDataOffset"),B.u16("messageDataSize"),B.u16("messageInstructionIndex")]);class xr{constructor(){}static createInstructionWithPublicKey(e){const{publicKey:t,message:r,signature:s,instructionIndex:i}=e;ve(t.length===wa,`Public Key must be ${wa} bytes but received ${t.length} bytes`),ve(s.length===ba,`Signature must be ${ba} bytes but received ${s.length} bytes`);const o=Ra.span,a=o+t.length,f=a+s.length,g=1,w=he.Buffer.alloc(f+r.length),b=i??65535;return Ra.encode({numSignatures:g,padding:0,signatureOffset:a,signatureInstructionIndex:b,publicKeyOffset:o,publicKeyInstructionIndex:b,messageDataOffset:f,messageDataSize:r.length,messageInstructionIndex:b},w),w.fill(t,o),w.fill(s,a),w.fill(r,f),new xe({keys:[],programId:xr.programId,data:w})}static createInstructionWithPrivateKey(e){const{privateKey:t,message:r,instructionIndex:s}=e;ve(t.length===ya,`Private key must be ${ya} bytes but received ${t.length} bytes`);try{const i=Cn.fromSecretKey(t),o=i.publicKey.toBytes(),a=bi(r,i.secretKey);return this.createInstructionWithPublicKey({publicKey:o,message:r,signature:a,instructionIndex:s})}catch(i){throw new Error(`Error creating instruction; ${i}`)}}}xr.programId=new se("Ed25519SigVerify111111111111111111111111111");const xg=(n,e)=>{const t=br.sign(n,e);return[t.toCompactRawBytes(),t.recovery]};br.utils.isValidPrivateKey;const Bg=br.getPublicKey,Ea=32,$i=20,Sa=64,Lg=11,Hi=B.struct([B.u8("numSignatures"),B.u16("signatureOffset"),B.u8("signatureInstructionIndex"),B.u16("ethAddressOffset"),B.u8("ethAddressInstructionIndex"),B.u16("messageDataOffset"),B.u16("messageDataSize"),B.u8("messageInstructionIndex"),B.blob(20,"ethAddress"),B.blob(64,"signature"),B.u8("recoveryId")]);class Mn{constructor(){}static publicKeyToEthAddress(e){ve(e.length===Sa,`Public key must be ${Sa} bytes but received ${e.length} bytes`);try{return he.Buffer.from(Po(we(e))).slice(-$i)}catch(t){throw new Error(`Error constructing Ethereum address: ${t}`)}}static createInstructionWithPublicKey(e){const{publicKey:t,message:r,signature:s,recoveryId:i,instructionIndex:o}=e;return Mn.createInstructionWithEthAddress({ethAddress:Mn.publicKeyToEthAddress(t),message:r,signature:s,recoveryId:i,instructionIndex:o})}static createInstructionWithEthAddress(e){const{ethAddress:t,message:r,signature:s,recoveryId:i,instructionIndex:o=0}=e;let a;typeof t=="string"?t.startsWith("0x")?a=he.Buffer.from(t.substr(2),"hex"):a=he.Buffer.from(t,"hex"):a=t,ve(a.length===$i,`Address must be ${$i} bytes but received ${a.length} bytes`);const f=1+Lg,g=f,w=f+a.length,b=w+s.length+1,x=1,T=he.Buffer.alloc(Hi.span+r.length);return Hi.encode({numSignatures:x,signatureOffset:w,signatureInstructionIndex:o,ethAddressOffset:g,ethAddressInstructionIndex:o,messageDataOffset:b,messageDataSize:r.length,messageInstructionIndex:o,signature:we(s),ethAddress:we(a),recoveryId:i},T),T.fill(we(r),Hi.span),new xe({keys:[],programId:Mn.programId,data:T})}static createInstructionWithPrivateKey(e){const{privateKey:t,message:r,instructionIndex:s}=e;ve(t.length===Ea,`Private key must be ${Ea} bytes but received ${t.length} bytes`);try{const i=we(t),o=Bg(i,!1).slice(1),a=he.Buffer.from(Po(we(r))),[f,g]=xg(a,i);return this.createInstructionWithPublicKey({publicKey:o,message:r,signature:f,recoveryId:g,instructionIndex:s})}catch(i){throw new Error(`Error creating instruction; ${i}`)}}}Mn.programId=new se("KeccakSecp256k11111111111111111111111111111");var Aa;const Ia=new se("StakeConfig11111111111111111111111111111111");class va{constructor(e,t){this.staker=void 0,this.withdrawer=void 0,this.staker=e,this.withdrawer=t}}class er{constructor(e,t,r){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=e,this.epoch=t,this.custodian=r}}Aa=er,er.default=new Aa(0,0,se.default);class Cg{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);const r=B.u32("instruction").decode(e.data);let s;for(const[i,o]of Object.entries(mt))if(o.index==r){s=i;break}if(!s)throw new Error("Instruction type incorrect; not a StakeInstruction");return s}static decodeInitialize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{authorized:t,lockup:r}=ke(mt.Initialize,e.data);return{stakePubkey:e.keys[0].pubkey,authorized:new va(new se(t.staker),new se(t.withdrawer)),lockup:new er(r.unixTimestamp,r.epoch,new se(r.custodian))}}static decodeDelegate(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,6),ke(mt.Delegate,e.data),{stakePubkey:e.keys[0].pubkey,votePubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[5].pubkey}}static decodeAuthorize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{newAuthorized:t,stakeAuthorizationType:r}=ke(mt.Authorize,e.data),s={stakePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey,newAuthorizedPubkey:new se(t),stakeAuthorizationType:{index:r}};return e.keys.length>3&&(s.custodianPubkey=e.keys[3].pubkey),s}static decodeAuthorizeWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{newAuthorized:t,stakeAuthorizationType:r,authoritySeed:s,authorityOwner:i}=ke(mt.AuthorizeWithSeed,e.data),o={stakePubkey:e.keys[0].pubkey,authorityBase:e.keys[1].pubkey,authoritySeed:s,authorityOwner:new se(i),newAuthorizedPubkey:new se(t),stakeAuthorizationType:{index:r}};return e.keys.length>3&&(o.custodianPubkey=e.keys[3].pubkey),o}static decodeSplit(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{lamports:t}=ke(mt.Split,e.data);return{stakePubkey:e.keys[0].pubkey,splitStakePubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[2].pubkey,lamports:t}}static decodeMerge(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3),ke(mt.Merge,e.data),{stakePubkey:e.keys[0].pubkey,sourceStakePubKey:e.keys[1].pubkey,authorizedPubkey:e.keys[4].pubkey}}static decodeWithdraw(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,5);const{lamports:t}=ke(mt.Withdraw,e.data),r={stakePubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[4].pubkey,lamports:t};return e.keys.length>5&&(r.custodianPubkey=e.keys[5].pubkey),r}static decodeDeactivate(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3),ke(mt.Deactivate,e.data),{stakePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey}}static checkProgramId(e){if(!e.equals(Br.programId))throw new Error("invalid instruction; programId is not StakeProgram")}static checkKeyLength(e,t){if(e.length<t)throw new Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}}const mt=Object.freeze({Initialize:{index:0,layout:B.struct([B.u32("instruction"),K0(),$0()])},Authorize:{index:1,layout:B.struct([B.u32("instruction"),Ee("newAuthorized"),B.u32("stakeAuthorizationType")])},Delegate:{index:2,layout:B.struct([B.u32("instruction")])},Split:{index:3,layout:B.struct([B.u32("instruction"),B.ns64("lamports")])},Withdraw:{index:4,layout:B.struct([B.u32("instruction"),B.ns64("lamports")])},Deactivate:{index:5,layout:B.struct([B.u32("instruction")])},Merge:{index:7,layout:B.struct([B.u32("instruction")])},AuthorizeWithSeed:{index:8,layout:B.struct([B.u32("instruction"),Ee("newAuthorized"),B.u32("stakeAuthorizationType"),dn("authoritySeed"),Ee("authorityOwner")])}}),Mg=Object.freeze({Staker:{index:0},Withdrawer:{index:1}});class Br{constructor(){}static initialize(e){const{stakePubkey:t,authorized:r,lockup:s}=e,i=s||er.default,o=mt.Initialize,a=Ie(o,{authorized:{staker:we(r.staker.toBuffer()),withdrawer:we(r.withdrawer.toBuffer())},lockup:{unixTimestamp:i.unixTimestamp,epoch:i.epoch,custodian:we(i.custodian.toBuffer())}}),f={keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:xn,isSigner:!1,isWritable:!1}],programId:this.programId,data:a};return new xe(f)}static createAccountWithSeed(e){const t=new Oe;t.add(gt.createAccountWithSeed({fromPubkey:e.fromPubkey,newAccountPubkey:e.stakePubkey,basePubkey:e.basePubkey,seed:e.seed,lamports:e.lamports,space:this.space,programId:this.programId}));const{stakePubkey:r,authorized:s,lockup:i}=e;return t.add(this.initialize({stakePubkey:r,authorized:s,lockup:i}))}static createAccount(e){const t=new Oe;t.add(gt.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.stakePubkey,lamports:e.lamports,space:this.space,programId:this.programId}));const{stakePubkey:r,authorized:s,lockup:i}=e;return t.add(this.initialize({stakePubkey:r,authorized:s,lockup:i}))}static delegate(e){const{stakePubkey:t,authorizedPubkey:r,votePubkey:s}=e,i=mt.Delegate,o=Ie(i);return new Oe().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!1},{pubkey:zt,isSigner:!1,isWritable:!1},{pubkey:Ir,isSigner:!1,isWritable:!1},{pubkey:Ia,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static authorize(e){const{stakePubkey:t,authorizedPubkey:r,newAuthorizedPubkey:s,stakeAuthorizationType:i,custodianPubkey:o}=e,a=mt.Authorize,f=Ie(a,{newAuthorized:we(s.toBuffer()),stakeAuthorizationType:i.index}),g=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:zt,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}];return o&&g.push({pubkey:o,isSigner:!0,isWritable:!1}),new Oe().add({keys:g,programId:this.programId,data:f})}static authorizeWithSeed(e){const{stakePubkey:t,authorityBase:r,authoritySeed:s,authorityOwner:i,newAuthorizedPubkey:o,stakeAuthorizationType:a,custodianPubkey:f}=e,g=mt.AuthorizeWithSeed,w=Ie(g,{newAuthorized:we(o.toBuffer()),stakeAuthorizationType:a.index,authoritySeed:s,authorityOwner:we(i.toBuffer())}),b=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1},{pubkey:zt,isSigner:!1,isWritable:!1}];return f&&b.push({pubkey:f,isSigner:!0,isWritable:!1}),new Oe().add({keys:b,programId:this.programId,data:w})}static splitInstruction(e){const{stakePubkey:t,authorizedPubkey:r,splitStakePubkey:s,lamports:i}=e,o=mt.Split,a=Ie(o,{lamports:i});return new xe({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:a})}static split(e,t){const r=new Oe;return r.add(gt.createAccount({fromPubkey:e.authorizedPubkey,newAccountPubkey:e.splitStakePubkey,lamports:t,space:this.space,programId:this.programId})),r.add(this.splitInstruction(e))}static splitWithSeed(e,t){const{stakePubkey:r,authorizedPubkey:s,splitStakePubkey:i,basePubkey:o,seed:a,lamports:f}=e,g=new Oe;return g.add(gt.allocate({accountPubkey:i,basePubkey:o,seed:a,space:this.space,programId:this.programId})),t&&t>0&&g.add(gt.transfer({fromPubkey:e.authorizedPubkey,toPubkey:i,lamports:t})),g.add(this.splitInstruction({stakePubkey:r,authorizedPubkey:s,splitStakePubkey:i,lamports:f}))}static merge(e){const{stakePubkey:t,sourceStakePubKey:r,authorizedPubkey:s}=e,i=mt.Merge,o=Ie(i);return new Oe().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:zt,isSigner:!1,isWritable:!1},{pubkey:Ir,isSigner:!1,isWritable:!1},{pubkey:s,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static withdraw(e){const{stakePubkey:t,authorizedPubkey:r,toPubkey:s,lamports:i,custodianPubkey:o}=e,a=mt.Withdraw,f=Ie(a,{lamports:i}),g=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:zt,isSigner:!1,isWritable:!1},{pubkey:Ir,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return o&&g.push({pubkey:o,isSigner:!0,isWritable:!1}),new Oe().add({keys:g,programId:this.programId,data:f})}static deactivate(e){const{stakePubkey:t,authorizedPubkey:r}=e,s=mt.Deactivate,i=Ie(s);return new Oe().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:zt,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:i})}}Br.programId=new se("Stake11111111111111111111111111111111111111"),Br.space=200;class Oa{constructor(e,t,r,s){this.nodePubkey=void 0,this.authorizedVoter=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.nodePubkey=e,this.authorizedVoter=t,this.authorizedWithdrawer=r,this.commission=s}}class Pg{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);const r=B.u32("instruction").decode(e.data);let s;for(const[i,o]of Object.entries($t))if(o.index==r){s=i;break}if(!s)throw new Error("Instruction type incorrect; not a VoteInstruction");return s}static decodeInitializeAccount(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,4);const{voteInit:t}=ke($t.InitializeAccount,e.data);return{votePubkey:e.keys[0].pubkey,nodePubkey:e.keys[3].pubkey,voteInit:new Oa(new se(t.nodePubkey),new se(t.authorizedVoter),new se(t.authorizedWithdrawer),t.commission)}}static decodeAuthorize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{newAuthorized:t,voteAuthorizationType:r}=ke($t.Authorize,e.data);return{votePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey,newAuthorizedPubkey:new se(t),voteAuthorizationType:{index:r}}}static decodeAuthorizeWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:t,currentAuthorityDerivedKeySeed:r,newAuthorized:s,voteAuthorizationType:i}}=ke($t.AuthorizeWithSeed,e.data);return{currentAuthorityDerivedKeyBasePubkey:e.keys[2].pubkey,currentAuthorityDerivedKeyOwnerPubkey:new se(t),currentAuthorityDerivedKeySeed:r,newAuthorizedPubkey:new se(s),voteAuthorizationType:{index:i},votePubkey:e.keys[0].pubkey}}static decodeWithdraw(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{lamports:t}=ke($t.Withdraw,e.data);return{votePubkey:e.keys[0].pubkey,authorizedWithdrawerPubkey:e.keys[2].pubkey,lamports:t,toPubkey:e.keys[1].pubkey}}static checkProgramId(e){if(!e.equals(Pn.programId))throw new Error("invalid instruction; programId is not VoteProgram")}static checkKeyLength(e,t){if(e.length<t)throw new Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}}const $t=Object.freeze({InitializeAccount:{index:0,layout:B.struct([B.u32("instruction"),H0()])},Authorize:{index:1,layout:B.struct([B.u32("instruction"),Ee("newAuthorized"),B.u32("voteAuthorizationType")])},Withdraw:{index:3,layout:B.struct([B.u32("instruction"),B.ns64("lamports")])},UpdateValidatorIdentity:{index:4,layout:B.struct([B.u32("instruction")])},AuthorizeWithSeed:{index:10,layout:B.struct([B.u32("instruction"),W0()])}}),Ug=Object.freeze({Voter:{index:0},Withdrawer:{index:1}});class Pn{constructor(){}static initializeAccount(e){const{votePubkey:t,nodePubkey:r,voteInit:s}=e,i=$t.InitializeAccount,o=Ie(i,{voteInit:{nodePubkey:we(s.nodePubkey.toBuffer()),authorizedVoter:we(s.authorizedVoter.toBuffer()),authorizedWithdrawer:we(s.authorizedWithdrawer.toBuffer()),commission:s.commission}}),a={keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:xn,isSigner:!1,isWritable:!1},{pubkey:zt,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:o};return new xe(a)}static createAccount(e){const t=new Oe;return t.add(gt.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.votePubkey,lamports:e.lamports,space:this.space,programId:this.programId})),t.add(this.initializeAccount({votePubkey:e.votePubkey,nodePubkey:e.voteInit.nodePubkey,voteInit:e.voteInit}))}static authorize(e){const{votePubkey:t,authorizedPubkey:r,newAuthorizedPubkey:s,voteAuthorizationType:i}=e,o=$t.Authorize,a=Ie(o,{newAuthorized:we(s.toBuffer()),voteAuthorizationType:i.index}),f=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:zt,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return new Oe().add({keys:f,programId:this.programId,data:a})}static authorizeWithSeed(e){const{currentAuthorityDerivedKeyBasePubkey:t,currentAuthorityDerivedKeyOwnerPubkey:r,currentAuthorityDerivedKeySeed:s,newAuthorizedPubkey:i,voteAuthorizationType:o,votePubkey:a}=e,f=$t.AuthorizeWithSeed,g=Ie(f,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:we(r.toBuffer()),currentAuthorityDerivedKeySeed:s,newAuthorized:we(i.toBuffer()),voteAuthorizationType:o.index}}),w=[{pubkey:a,isSigner:!1,isWritable:!0},{pubkey:zt,isSigner:!1,isWritable:!1},{pubkey:t,isSigner:!0,isWritable:!1}];return new Oe().add({keys:w,programId:this.programId,data:g})}static withdraw(e){const{votePubkey:t,authorizedWithdrawerPubkey:r,lamports:s,toPubkey:i}=e,o=$t.Withdraw,a=Ie(o,{lamports:s}),f=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}];return new Oe().add({keys:f,programId:this.programId,data:a})}static safeWithdraw(e,t,r){if(e.lamports>t-r)throw new Error("Withdraw will leave vote account with insufficient funds.");return Pn.withdraw(e)}static updateValidatorIdentity(e){const{votePubkey:t,authorizedWithdrawerPubkey:r,nodePubkey:s}=e,i=$t.UpdateValidatorIdentity,o=Ie(i),a=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!0,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return new Oe().add({keys:a,programId:this.programId,data:o})}}Pn.programId=new se("Vote111111111111111111111111111111111111111"),Pn.space=3762;const ka=new se("Va1idator1nfo111111111111111111111111111111"),Dg=te({name:ie(),website:le(ie()),details:le(ie()),iconUrl:le(ie()),keybaseUsername:le(ie())});class Wi{constructor(e,t){this.key=void 0,this.info=void 0,this.key=e,this.info=t}static fromConfigData(e){let t=[...e];if(At(t)!==2)return null;const s=[];for(let i=0;i<2;i++){const o=new se(It(t,0,Dt)),a=Ft(t)===1;s.push({publicKey:o,isSigner:a})}if(s[0].publicKey.equals(ka)&&s[1].isSigner){const i=dn().decode(he.Buffer.from(t)),o=JSON.parse(i);return yo(o,Dg),new Wi(s[1].publicKey,o)}return null}}const Fg=new se("Vote111111111111111111111111111111111111111"),zg=B.struct([Ee("nodePubkey"),Ee("authorizedWithdrawer"),B.u8("commission"),B.nu64(),B.seq(B.struct([B.nu64("slot"),B.u32("confirmationCount")]),B.offset(B.u32(),-8),"votes"),B.u8("rootSlotValid"),B.nu64("rootSlot"),B.nu64(),B.seq(B.struct([B.nu64("epoch"),Ee("authorizedVoter")]),B.offset(B.u32(),-8),"authorizedVoters"),B.struct([B.seq(B.struct([Ee("authorizedPubkey"),B.nu64("epochOfLastAuthorizedSwitch"),B.nu64("targetEpoch")]),32,"buf"),B.nu64("idx"),B.u8("isEmpty")],"priorVoters"),B.nu64(),B.seq(B.struct([B.nu64("epoch"),B.nu64("credits"),B.nu64("prevCredits")]),B.offset(B.u32(),-8),"epochCredits"),B.struct([B.nu64("slot"),B.nu64("timestamp")],"lastTimestamp")]);class qi{constructor(e){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=e.nodePubkey,this.authorizedWithdrawer=e.authorizedWithdrawer,this.commission=e.commission,this.rootSlot=e.rootSlot,this.votes=e.votes,this.authorizedVoters=e.authorizedVoters,this.priorVoters=e.priorVoters,this.epochCredits=e.epochCredits,this.lastTimestamp=e.lastTimestamp}static fromAccountData(e){const r=zg.decode(we(e),4);let s=r.rootSlot;return r.rootSlotValid||(s=null),new qi({nodePubkey:new se(r.nodePubkey),authorizedWithdrawer:new se(r.authorizedWithdrawer),commission:r.commission,votes:r.votes,rootSlot:s,authorizedVoters:r.authorizedVoters.map(Kg),priorVoters:$g(r.priorVoters),epochCredits:r.epochCredits,lastTimestamp:r.lastTimestamp})}}function Kg({authorizedVoter:n,epoch:e}){return{epoch:e,authorizedVoter:new se(n)}}function Ta({authorizedPubkey:n,epochOfLastAuthorizedSwitch:e,targetEpoch:t}){return{authorizedPubkey:new se(n),epochOfLastAuthorizedSwitch:e,targetEpoch:t}}function $g({buf:n,idx:e,isEmpty:t}){return t?[]:[...n.slice(e+1).map(Ta),...n.slice(0,e).map(Ta)]}const Na={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/"}};function Hg(n,e){const t=e===!1?"http":"https";if(!n)return Na[t].devnet;const r=Na[t][n];if(!r)throw new Error(`Unknown ${t} cluster: ${n}`);return r}async function Wg(n,e,t,r){let s,i;t&&Object.prototype.hasOwnProperty.call(t,"lastValidBlockHeight")||t&&Object.prototype.hasOwnProperty.call(t,"nonceValue")?(s=t,i=r):i=t;const o=i&&{skipPreflight:i.skipPreflight,preflightCommitment:i.preflightCommitment||i.commitment,minContextSlot:i.minContextSlot},a=await n.sendRawTransaction(e,o),f=i&&i.commitment,w=(await(s?n.confirmTransaction(s,f):n.confirmTransaction(a,f))).value;if(w.err)throw a!=null?new Xn({action:o?.skipPreflight?"send":"simulate",signature:a,transactionMessage:`Status: (${JSON.stringify(w)})`}):new Error(`Raw transaction ${a} failed (${JSON.stringify(w)})`);return a}const Lr=Object.freeze(Object.defineProperty({__proto__:null,Account:D0,AddressLookupTableAccount:xi,AddressLookupTableInstruction:Tg,AddressLookupTableProgram:zi,Authorized:va,BLOCKHASH_CACHE_TIMEOUT_MS:ia,BPF_LOADER_DEPRECATED_PROGRAM_ID:F0,BPF_LOADER_PROGRAM_ID:ep,BpfLoader:tp,COMPUTE_BUDGET_INSTRUCTION_LAYOUTS:Kt,ComputeBudgetInstruction:Ng,ComputeBudgetProgram:Ki,Connection:kg,Ed25519Program:xr,Enum:P0,EpochSchedule:ta,FeeCalculatorLayout:Xo,Keypair:Cn,LAMPORTS_PER_SOL:1e9,LOOKUP_TABLE_INSTRUCTION_LAYOUTS:Zt,Loader:mn,Lockup:er,MAX_SEED_LENGTH:Vo,Message:Bt,MessageAccountKeys:Zn,MessageV0:pn,NONCE_ACCOUNT_LENGTH:ki,NonceAccount:vr,PACKET_DATA_SIZE:nn,PUBLIC_KEY_LENGTH:Dt,PublicKey:se,SIGNATURE_LENGTH_IN_BYTES:jn,SOLANA_SCHEMA:Yn,STAKE_CONFIG_ID:Ia,STAKE_INSTRUCTION_LAYOUTS:mt,SYSTEM_INSTRUCTION_LAYOUTS:Me,SYSVAR_CLOCK_PUBKEY:zt,SYSVAR_EPOCH_SCHEDULE_PUBKEY:V0,SYSVAR_INSTRUCTIONS_PUBKEY:G0,SYSVAR_RECENT_BLOCKHASHES_PUBKEY:Ar,SYSVAR_RENT_PUBKEY:xn,SYSVAR_REWARDS_PUBKEY:Y0,SYSVAR_SLOT_HASHES_PUBKEY:j0,SYSVAR_SLOT_HISTORY_PUBKEY:Z0,SYSVAR_STAKE_HISTORY_PUBKEY:Ir,Secp256k1Program:Mn,SendTransactionError:Xn,SolanaJSONRPCError:ue,SolanaJSONRPCErrorCode:X0,StakeAuthorizationLayout:Mg,StakeInstruction:Cg,StakeProgram:Br,Struct:Ri,SystemInstruction:J0,SystemProgram:gt,Transaction:Oe,TransactionExpiredBlockheightExceededError:Ei,TransactionExpiredNonceInvalidError:Nn,TransactionExpiredTimeoutError:Si,TransactionInstruction:xe,TransactionMessage:Ii,TransactionStatus:jt,VALIDATOR_INFO_KEY:ka,VERSION_PREFIX_MASK:Er,VOTE_PROGRAM_ID:Fg,ValidatorInfo:Wi,VersionedMessage:Ai,VersionedTransaction:vi,VoteAccount:qi,VoteAuthorizationLayout:Ug,VoteInit:Oa,VoteInstruction:Pg,VoteProgram:Pn,clusterApiUrl:Hg,sendAndConfirmRawTransaction:Wg,sendAndConfirmTransaction:Oi},Symbol.toStringTag,{value:"Module"})),rn=pt;var Vi={exports:{}},xa;function qg(){return xa||(xa=1,function(n){var e=function(){var t=String.fromCharCode,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",i={};function o(f,g){if(!i[f]){i[f]={};for(var w=0;w<f.length;w++)i[f][f.charAt(w)]=w}return i[f][g]}var a={compressToBase64:function(f){if(f==null)return"";var g=a._compress(f,6,function(w){return r.charAt(w)});switch(g.length%4){default:case 0:return g;case 1:return g+"===";case 2:return g+"==";case 3:return g+"="}},decompressFromBase64:function(f){return f==null?"":f==""?null:a._decompress(f.length,32,function(g){return o(r,f.charAt(g))})},compressToUTF16:function(f){return f==null?"":a._compress(f,15,function(g){return t(g+32)})+" "},decompressFromUTF16:function(f){return f==null?"":f==""?null:a._decompress(f.length,16384,function(g){return f.charCodeAt(g)-32})},compressToUint8Array:function(f){for(var g=a.compress(f),w=new Uint8Array(g.length*2),b=0,x=g.length;b<x;b++){var T=g.charCodeAt(b);w[b*2]=T>>>8,w[b*2+1]=T%256}return w},decompressFromUint8Array:function(f){if(f==null)return a.decompress(f);for(var g=new Array(f.length/2),w=0,b=g.length;w<b;w++)g[w]=f[w*2]*256+f[w*2+1];var x=[];return g.forEach(function(T){x.push(t(T))}),a.decompress(x.join(""))},compressToEncodedURIComponent:function(f){return f==null?"":a._compress(f,6,function(g){return s.charAt(g)})},decompressFromEncodedURIComponent:function(f){return f==null?"":f==""?null:(f=f.replace(/ /g,"+"),a._decompress(f.length,32,function(g){return o(s,f.charAt(g))}))},compress:function(f){return a._compress(f,16,function(g){return t(g)})},_compress:function(f,g,w){if(f==null)return"";var b,x,T={},L={},O="",N="",M="",H=2,K=3,Q=2,q=[],D=0,Z=0,j;for(j=0;j<f.length;j+=1)if(O=f.charAt(j),Object.prototype.hasOwnProperty.call(T,O)||(T[O]=K++,L[O]=!0),N=M+O,Object.prototype.hasOwnProperty.call(T,N))M=N;else{if(Object.prototype.hasOwnProperty.call(L,M)){if(M.charCodeAt(0)<256){for(b=0;b<Q;b++)D=D<<1,Z==g-1?(Z=0,q.push(w(D)),D=0):Z++;for(x=M.charCodeAt(0),b=0;b<8;b++)D=D<<1|x&1,Z==g-1?(Z=0,q.push(w(D)),D=0):Z++,x=x>>1}else{for(x=1,b=0;b<Q;b++)D=D<<1|x,Z==g-1?(Z=0,q.push(w(D)),D=0):Z++,x=0;for(x=M.charCodeAt(0),b=0;b<16;b++)D=D<<1|x&1,Z==g-1?(Z=0,q.push(w(D)),D=0):Z++,x=x>>1}H--,H==0&&(H=Math.pow(2,Q),Q++),delete L[M]}else for(x=T[M],b=0;b<Q;b++)D=D<<1|x&1,Z==g-1?(Z=0,q.push(w(D)),D=0):Z++,x=x>>1;H--,H==0&&(H=Math.pow(2,Q),Q++),T[N]=K++,M=String(O)}if(M!==""){if(Object.prototype.hasOwnProperty.call(L,M)){if(M.charCodeAt(0)<256){for(b=0;b<Q;b++)D=D<<1,Z==g-1?(Z=0,q.push(w(D)),D=0):Z++;for(x=M.charCodeAt(0),b=0;b<8;b++)D=D<<1|x&1,Z==g-1?(Z=0,q.push(w(D)),D=0):Z++,x=x>>1}else{for(x=1,b=0;b<Q;b++)D=D<<1|x,Z==g-1?(Z=0,q.push(w(D)),D=0):Z++,x=0;for(x=M.charCodeAt(0),b=0;b<16;b++)D=D<<1|x&1,Z==g-1?(Z=0,q.push(w(D)),D=0):Z++,x=x>>1}H--,H==0&&(H=Math.pow(2,Q),Q++),delete L[M]}else for(x=T[M],b=0;b<Q;b++)D=D<<1|x&1,Z==g-1?(Z=0,q.push(w(D)),D=0):Z++,x=x>>1;H--,H==0&&(H=Math.pow(2,Q),Q++)}for(x=2,b=0;b<Q;b++)D=D<<1|x&1,Z==g-1?(Z=0,q.push(w(D)),D=0):Z++,x=x>>1;for(;;)if(D=D<<1,Z==g-1){q.push(w(D));break}else Z++;return q.join("")},decompress:function(f){return f==null?"":f==""?null:a._decompress(f.length,32768,function(g){return f.charCodeAt(g)})},_decompress:function(f,g,w){var b=[],x=4,T=4,L=3,O="",N=[],M,H,K,Q,q,D,Z,j={val:w(0),position:g,index:1};for(M=0;M<3;M+=1)b[M]=M;for(K=0,q=Math.pow(2,2),D=1;D!=q;)Q=j.val&j.position,j.position>>=1,j.position==0&&(j.position=g,j.val=w(j.index++)),K|=(Q>0?1:0)*D,D<<=1;switch(K){case 0:for(K=0,q=Math.pow(2,8),D=1;D!=q;)Q=j.val&j.position,j.position>>=1,j.position==0&&(j.position=g,j.val=w(j.index++)),K|=(Q>0?1:0)*D,D<<=1;Z=t(K);break;case 1:for(K=0,q=Math.pow(2,16),D=1;D!=q;)Q=j.val&j.position,j.position>>=1,j.position==0&&(j.position=g,j.val=w(j.index++)),K|=(Q>0?1:0)*D,D<<=1;Z=t(K);break;case 2:return""}for(b[3]=Z,H=Z,N.push(Z);;){if(j.index>f)return"";for(K=0,q=Math.pow(2,L),D=1;D!=q;)Q=j.val&j.position,j.position>>=1,j.position==0&&(j.position=g,j.val=w(j.index++)),K|=(Q>0?1:0)*D,D<<=1;switch(Z=K){case 0:for(K=0,q=Math.pow(2,8),D=1;D!=q;)Q=j.val&j.position,j.position>>=1,j.position==0&&(j.position=g,j.val=w(j.index++)),K|=(Q>0?1:0)*D,D<<=1;b[T++]=t(K),Z=T-1,x--;break;case 1:for(K=0,q=Math.pow(2,16),D=1;D!=q;)Q=j.val&j.position,j.position>>=1,j.position==0&&(j.position=g,j.val=w(j.index++)),K|=(Q>0?1:0)*D,D<<=1;b[T++]=t(K),Z=T-1,x--;break;case 2:return N.join("")}if(x==0&&(x=Math.pow(2,L),L++),b[Z])O=b[Z];else if(Z===T)O=H+H.charAt(0);else return null;N.push(O),b[T++]=H+O.charAt(0),x--,H=O,x==0&&(x=Math.pow(2,L),L++)}}};return a}();n!=null?n.exports=e:typeof angular<"u"&&angular!=null&&angular.module("LZString",[]).factory("LZString",function(){return e})}(Vi)),Vi.exports}var Vg=qg();const Lt=Fn(Vg);var Gi=(n=>(n.USD="USD",n.AED="AED",n.AFN="AFN",n.ALL="ALL",n.ANG="ANG",n.AOA="AOA",n.ARS="ARS",n.AUD="AUD",n.AWG="AWG",n.AZN="AZN",n.BAM="BAM",n.BBD="BBD",n.BDT="BDT",n.BGN="BGN",n.BHD="BHD",n.BIF="BIF",n.BMD="BMD",n.BND="BND",n.BOB="BOB",n.BRL="BRL",n.BSD="BSD",n.BTN="BTN",n.BWP="BWP",n.BYN="BYN",n.BZD="BZD",n.CAD="CAD",n.CHF="CHF",n.CLF="CLF",n.CLP="CLP",n.CNY="CNY",n.COP="COP",n.CRC="CRC",n.CUP="CUP",n.CVE="CVE",n.CZK="CZK",n.DJF="DJF",n.DKK="DKK",n.DOP="DOP",n.DZD="DZD",n.EGP="EGP",n.ETB="ETB",n.EUR="EUR",n.FJD="FJD",n.GBP="GBP",n.GEL="GEL",n.GHS="GHS",n.GMD="GMD",n.GNF="GNF",n.GTQ="GTQ",n.GYD="GYD",n.HKD="HKD",n.HNL="HNL",n.HTG="HTG",n.HUF="HUF",n.IDR="IDR",n.ILS="ILS",n.INR="INR",n.IQD="IQD",n.IRR="IRR",n.ISK="ISK",n.JMD="JMD",n.JOD="JOD",n.JPY="JPY",n.KES="KES",n.KGS="KGS",n.KHR="KHR",n.KMF="KMF",n.KRW="KRW",n.KWD="KWD",n.KYD="KYD",n.KZT="KZT",n.LAK="LAK",n.LBP="LBP",n.LKR="LKR",n.LRD="LRD",n.LSL="LSL",n.LYD="LYD",n.MAD="MAD",n.MDL="MDL",n.MGA="MGA",n.MKD="MKD",n.MMK="MMK",n.MNT="MNT",n.MOP="MOP",n.MRU="MRU",n.MUR="MUR",n.MWK="MWK",n.MVR="MVR",n.MXN="MXN",n.MYR="MYR",n.MZN="MZN",n.NAD="NAD",n.NGN="NGN",n.NIO="NIO",n.NOK="NOK",n.NPR="NPR",n.NZD="NZD",n.OMR="OMR",n.PAB="PAB",n.PEN="PEN",n.PGK="PGK",n.PHP="PHP",n.PKR="PKR",n.PLN="PLN",n.PYG="PYG",n.QAR="QAR",n.RON="RON",n.RSD="RSD",n.RWF="RWF",n.SAR="SAR",n.SCR="SCR",n.SDG="SDG",n.SEK="SEK",n.SGD="SGD",n.SLE="SLE",n.SLL="SLL",n.SOS="SOS",n.SRD="SRD",n.STN="STN",n.SVC="SVC",n.SYP="SYP",n.SZL="SZL",n.THB="THB",n.TJS="TJS",n.TMT="TMT",n.TND="TND",n.TOP="TOP",n.TRY="TRY",n.TTD="TTD",n.TWD="TWD",n.TZS="TZS",n.UAH="UAH",n.UGX="UGX",n.UYU="UYU",n.UZS="UZS",n.VND="VND",n.VUV="VUV",n.XAF="XAF",n.XCD="XCD",n.XOF="XOF",n.XPF="XPF",n.YER="YER",n.ZAR="ZAR",n.ZMW="ZMW",n.ZWL="ZWL",n))(Gi||{});const Gg={AED:"784",AFN:"971",ALL:"008",ANG:"532",AOA:"973",AUD:"036",AWG:"533",AZN:"944",BAM:"977",BBD:"052",BDT:"050",BGN:"975",BHD:"048",BIF:"108",BND:"096",BOB:"068",BRL:"986",BTN:"064",BWP:"072",BZD:"084",CAD:"124",CHF:"756",CLP:"152",CNY:"156",COP:"170",CRC:"188",CVE:"132",CZK:"203",DJF:"262",DKK:"208",DOP:"214",DZD:"012",EGP:"818",ETB:"230",EUR:"978",GBP:"826",GEL:"981",GHS:"936",GMD:"270",GNF:"324",GTQ:"320",GYD:"328",HKD:"344",HNL:"340",HTG:"332",HUF:"348",IDR:"360",INR:"356",IQD:"368",IRR:"364",ISK:"352",JMD:"388",JOD:"400",JPY:"392",KES:"404",KGS:"417",KHR:"116",KMF:"174",KRW:"410",KWD:"414",KYD:"136",KZT:"398",LKR:"144",LRD:"430",LSL:"426",LYD:"434",MAD:"504",MDL:"498",MGA:"969",MKD:"807",MMK:"104",MNT:"496",MOP:"446",MRU:"929",MUR:"480",MVR:"462",MXN:"484",MYR:"458",NAD:"516",NGN:"566",NIO:"558",NOK:"578",NPR:"524",NZD:"554",OMR:"512",PAB:"590",PEN:"604",PHP:"608",PKR:"586",PLN:"985",PYG:"600",QAR:"634",RON:"946",RSD:"941",RWF:"646",SAR:"682",SCR:"690",SDG:"938",SEK:"752",SGD:"702",SLE:"925",SLL:"694",SOS:"706",STN:"930",SVC:"222",SYP:"760",SZL:"748",THB:"764",TJS:"972",TMT:"934",TND:"788",TRY:"949",TTD:"780",TWD:"901",TZS:"834",UAH:"980",UGX:"800",USD:"840",UYU:"858",UZS:"860",VND:"704",XAF:"950",XCD:"951",XOF:"952",XPF:"953",YER:"886",ZAR:"710",ZMW:"967",ARS:"032",BMD:"060",BSD:"044",BYN:"933",CUP:"192",FJD:"242",ILS:"376",LAK:"418",LBP:"422",MWK:"454",MZN:"943",PGK:"598",SRD:"968",TOP:"776",VUV:"548",ZWL:"932",CLF:"990"},Ba={USD:"USD",EUR:"EUR",GBP:"GBP",BRL:"BRL",CAD:"CAD"};function Yg(n){return n in Ba}function jg(n,e){return n.currency===e}class Ht{env;url;constructor(e){this.env=e??"prod",this.env==="prod"?this.url="https://api.coinflow.cash":this.env==="local"?this.url="http://localhost:5000":this.url=`https://api-${this.env}.coinflow.cash`}async getNSurePartnerId(e){return fetch(this.url+`/merchant/view/${e}`).then(t=>t.json()).then(t=>t.nSureSettings?.nSurePartnerId||t.nSurePartnerId).catch(t=>{console.error(t)})}static getCoinflowBaseUrl(e){return!e||e==="prod"?"https://coinflow.cash":e==="ngrok"?"https://coinflow.ngrok.app":e==="local"?"http://localhost:3000":`https://${e}.coinflow.cash`}static getCoinflowApiUrl(e){return!e||e==="prod"?"https://api.coinflow.cash":e==="local"?"http://localhost:5000":`https://api-${e}.coinflow.cash`}static getCoinflowUrl({walletPubkey:e,sessionKey:t,route:r,routePrefix:s,env:i,subtotal:o,presentment:a,transaction:f,blockchain:g="solana",webhookInfo:w,email:b,loaderBackground:x,handleHeightChangeId:T,bankAccountLinkRedirect:L,additionalWallets:O,chargebackProtectionData:N,merchantCss:M,color:H,rent:K,lockDefaultToken:Q,tokens:q,planCode:D,disableApplePay:Z,disableGooglePay:j,customerInfo:X,settlementType:z,lockAmount:V,nativeSolToConvert:ee,theme:S,usePermit:c,transactionSigner:p,authOnly:m,deviceId:I,jwtToken:E,origins:A,threeDsChallengePreference:C,supportEmail:R,destinationAuthKey:u,allowedPaymentMethods:l,accountFundingTransaction:y,partialUsdcChecked:k,redemptionCheck:P,allowedWithdrawSpeeds:G}){const re=s?`/${s}/${g}`:`/${g}`,J=new URL(re+r,Ht.getCoinflowBaseUrl(i));if(e&&J.searchParams.append("pubkey",e),t&&J.searchParams.append("sessionKey",t),f&&J.searchParams.append("transaction",f),o&&("cents"in o?(J.searchParams.append("cents",o.cents.toString()),"currency"in o?J.searchParams.append("currency",o.currency.toString()):J.searchParams.append("currency",Gi.USD)):(J.searchParams.append("token",o.address.toString()),J.searchParams.append("amount",o.amount.toString()))),a&&J.searchParams.append("presentment",a),w&&J.searchParams.append("webhookInfo",Lt.compressToEncodedURIComponent(JSON.stringify(w))),S&&J.searchParams.append("theme",Lt.compressToEncodedURIComponent(JSON.stringify(S))),X&&J.searchParams.append("customerInfo",Lt.compressToEncodedURIComponent(JSON.stringify(X))),b&&J.searchParams.append("email",b),R&&J.searchParams.append("supportEmail",R),q&&J.searchParams.append("tokens",q.toString()),x&&J.searchParams.append("loaderBackground",x),T&&J.searchParams.append("useHeightChange",T.toString()),L&&J.searchParams.append("bankAccountLinkRedirect",L),O&&J.searchParams.append("additionalWallets",Lt.compressToEncodedURIComponent(JSON.stringify(O))),N&&J.searchParams.append("chargebackProtectionData",Lt.compressToEncodedURIComponent(JSON.stringify(N))),I)J.searchParams.append("deviceId",I);else if(typeof window<"u"){const Ae=window?.nSureSDK?.getDeviceId();Ae&&J.searchParams.append("deviceId",Ae)}return M&&J.searchParams.append("merchantCss",M),H&&J.searchParams.append("color",H),K&&J.searchParams.append("rent",K.lamports.toString()),P&&J.searchParams.append("redemptionCheck","true"),ee&&J.searchParams.append("nativeSolToConvert",ee.lamports.toString()),Q&&J.searchParams.append("lockDefaultToken","true"),D&&J.searchParams.append("planCode",D),Z&&J.searchParams.append("disableApplePay","true"),j&&J.searchParams.append("disableGooglePay","true"),z&&J.searchParams.append("settlementType",z),V&&J.searchParams.append("lockAmount","true"),c===!1&&J.searchParams.append("usePermit","false"),p&&J.searchParams.append("transactionSigner",p),m===!0&&J.searchParams.append("authOnly","true"),k===!0&&J.searchParams.append("partialUsdcChecked","true"),E&&J.searchParams.append("jwtToken",E),A&&J.searchParams.append("origins",Lt.compressToEncodedURIComponent(JSON.stringify(A))),l&&J.searchParams.append("allowedPaymentMethods",l.join(",")),C&&J.searchParams.append("threeDsChallengePreference",C),u&&J.searchParams.append("destinationAuthKey",u),y&&J.searchParams.append("accountFundingTransaction",Lt.compressToEncodedURIComponent(JSON.stringify(y))),G&&J.searchParams.append("allowedWithdrawSpeeds",G.join(",")),J.toString()}static getTransaction(e){if(e.blockchain)return this.byBlockchain(e.blockchain,{solana:()=>{if(!("transaction"in e))return;const{transaction:t}=e;if(!Lr)throw new Error("@solana/web3.js dependency is required for Solana");if(!rn)throw new Error("bs58 dependency is required for Solana");if(t)return rn.encode(t.serialize({requireAllSignatures:!1,verifySignatures:!1}))},polygon:()=>{if(!("transaction"in e))return;const{transaction:t}=e;return Lt.compressToEncodedURIComponent(JSON.stringify(t))},eth:()=>{if(!("transaction"in e))return;const{transaction:t}=e;return Lt.compressToEncodedURIComponent(JSON.stringify(t))},base:()=>{if(!("transaction"in e))return;const{transaction:t}=e;return Lt.compressToEncodedURIComponent(JSON.stringify(t))},arbitrum:()=>{if(!("transaction"in e))return;const{transaction:t}=e;return Lt.compressToEncodedURIComponent(JSON.stringify(t))},user:()=>{}})()}static byBlockchain(e,t){switch(e){case"solana":return t.solana;case"polygon":return t.polygon;case"eth":return t.eth;case"base":return t.base;case"arbitrum":return t.arbitrum;case"user":return t.user;default:throw new Error("blockchain not supported!")}}}function Zg(n){if(!n)return;let e,t;if("name"in n&&n.name&&(e=n.name.split(" ")[0],t=n.name.split(" ").slice(1).join(" ")),"firstName"in n&&n.firstName&&(e=n.firstName),"lastName"in n&&n.lastName&&(t=n.lastName),e&&t)return{firstName:e,lastName:t}}var Yi=(n=>(n.SignMessage="signMessage",n.SignTransaction="signTransaction",n.SendTransaction="sendTransaction",n.HeightChange="heightChange",n.Success="success",n.AuthDeclined="authDeclined",n.Loaded="loaded",n.AccountLinked="accountLinked",n))(Yi||{});function Cr(n){let e;if("signer"in n&&typeof n.signer=="object"&&n.signer&&"wallet"in n.signer?e=n.signer.wallet:"wallet"in n&&n.wallet&&(e=n.wallet),!!e){if(typeof e=="string")return e;if(typeof e=="object"){if("publicKey"in e)return e.publicKey?e.publicKey.toString():void 0;if("address"in e)return e.address?e.address:void 0}return null}}function La(n,e,t){let r;try{if(r=JSON.parse(n),!("method"in r)||!("data"in r))return}catch(o){console.error("handleIFrameMessage JSON parse",o);return}const{data:s,method:i}=r;switch(i){case"signMessage":return e.handleSignMessage?e.handleSignMessage(s):void 0;case"signTransaction":return e.handleSignTransaction?e.handleSignTransaction(s):void 0;case"sendTransaction":return e.handleSendTransaction(s);case"heightChange:"+t:return e.handleHeightChange?e.handleHeightChange(s):void 0;case"success":if(!e.onSuccess)return;e.onSuccess(r.info);return;case"authDeclined":if(!e.onAuthDeclined)return;e.onAuthDeclined(r.info);return;case"loaded":return;case"accountLinked":return}console.warn(`Didn't expect to get here, handleIFrameMessage method:${i} is not one of ${Object.values(Yi)}`)}function Mr(n){let e,t;return"signer"in n&&typeof n.signer=="object"&&n.signer&&"blockchain"in n.signer&&"wallet"in n.signer?(e=n.signer.blockchain,t=n.signer.wallet):"blockchain"in n&&n.blockchain&&(e=n.blockchain,t=n.wallet),e?Ht.byBlockchain(e,{solana:()=>Xg({wallet:t,onSuccess:n.onSuccess,onAuthDeclined:n.onAuthDeclined}),eth:()=>Pr({wallet:t,onSuccess:n.onSuccess,onAuthDeclined:n.onAuthDeclined}),polygon:()=>Pr({wallet:t,onSuccess:n.onSuccess,onAuthDeclined:n.onAuthDeclined}),base:()=>Pr({wallet:t,onSuccess:n.onSuccess,onAuthDeclined:n.onAuthDeclined}),arbitrum:()=>Pr({wallet:t,onSuccess:n.onSuccess,onAuthDeclined:n.onAuthDeclined}),user:()=>Jg(n)})():{handleSendTransaction:()=>{throw new Error("handleSendTransaction Not Implemented")},handleSignMessage:()=>{throw new Error("handleSendTransaction Not Implemented")},handleSignTransaction:()=>{throw new Error("handleSendTransaction Not Implemented")},onSuccess:n.onSuccess,onAuthDeclined:n.onAuthDeclined}}function Xg({wallet:n,onSuccess:e,onAuthDeclined:t}){return{handleSendTransaction:async r=>{const s=Ca(r);return await n.sendTransaction(s)},handleSignMessage:async r=>{const s=n.signMessage;if(!s)throw new Error("signMessage is not supported by this wallet");const i=await s(new TextEncoder().encode(r));if(!rn)throw new Error("bs58 dependency is required");return rn.encode(i)},handleSignTransaction:async r=>{const s=n.signTransaction;if(!s)throw new Error("signTransaction is not supported by this wallet");const i=Ca(r),o=await s(i);if(!rn)throw new Error("bs58 dependency is required");return rn.encode(o.serialize({requireAllSignatures:!1,verifySignatures:!1}))},onSuccess:e,onAuthDeclined:t}}function Ca(n){if(!Lr)throw new Error("@solana/web3.js is not defined. Please install @solana/web3.js into your project");if(!rn)throw new Error("bs58 is not defined. Please install bs58 into your project");const e=rn.decode(n),t=Lr.VersionedTransaction.deserialize(e);return t.version==="legacy"?Lr.Transaction.from(e):t}function Pr({wallet:n,onSuccess:e,onAuthDeclined:t}){return{handleSendTransaction:async r=>{const s=JSON.parse(Buffer.from(r,"base64").toString()),{hash:i}=await n.sendTransaction(s);return i},handleSignMessage:async r=>n.signMessage(r),onSuccess:e,onAuthDeclined:t}}function Jg({onSuccess:n,onAuthDeclined:e}){return{handleSendTransaction:async()=>Promise.resolve(""),onSuccess:n,onAuthDeclined:e}}class Qg{static on(e,t){document.addEventListener(e,t)}static dispatch(e,t){document.dispatchEvent(new CustomEvent(e,{detail:t}))}static remove(e,t){document.removeEventListener(e,t)}}const tr="tokenExCardNumber",Un="tokenExCardCvv",Ma={[wn.VISA]:"visa",[wn.MASTERCARD]:"masterCard",[wn.AMEX]:"americanExpress",[wn.DISCOVER]:"discover"};async function Pa(n){const{token:e,origins:t,env:r}=n;return new Promise((s,i)=>{fetch(new Ht(r).url+"/api/tokenize/iframe/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({origins:t,token:e,merchantId:"merchantId"in n?n.merchantId:void 0,checkoutJwt:"checkoutJwt"in n?n.checkoutJwt:void 0})}).then(async o=>{s(await o.json())}).catch(o=>i(o))})}function ji({env:n,setTokenExScriptLoaded:e}){const t="tokenex-script";document.head.querySelector(`#${t}`)&&e(!0);const r=document.createElement("script");r.src=n==="prod"?"https://htp.tokenex.com/iframe/iframe-v3.min.js":"https://test-htp.tokenex.com/iframe/iframe-v3.min.js",r.id=t,document.head.appendChild(r),document.getElementById(t).addEventListener("load",()=>{console.log("Setting tokenExScriptLoaded to true!"),e(!0)})}function em({iframe:n,setCachedToken:e,setLoaded:t}){const r=async()=>(n.tokenize(),await new Promise((s,i)=>{n.on("tokenize",o=>{e(o.token),s(o)}),n.on("validate",o=>{(!o.isValid||o.isCvvValid===!1)&&i(o)})}));return n.on("change",()=>e(void 0)),n.on("cvvChange",()=>e(void 0)),n.on("load",()=>{setTimeout(()=>t(!0),350);const s=document.querySelector("#tx_iframe_tokenExCardNumber");s&&(s.scrolling="no")}),n.on("focus",()=>{n.focus()}),n.on("cvvFocus",()=>{n.cvvFocus()}),t(!1),n.load(),{...n,tokenize:r}}async function Ua(n){const{token:e,cardType:t}=n;return await Zi(Un,n,{cvvOnly:!0,cvv:!0,cvvContainerID:Un,placeholder:"CVV",token:e,cardType:Ma[t]})}async function Da(n){return await Zi(tr,n,{cvv:!0,cvvContainerID:Un,cvvPlaceholder:"CVV"})}async function Fa(n){return await Zi(tr,n,{cvv:!1})}async function Zi(n,e,t){const{tokenExScriptLoaded:r,css:s,debug:i,font:o,setCachedToken:a,setLoaded:f}=e;if(!r&&typeof TokenEx>"u"){console.warn("Warning Unable to load TokenEx on first attempt waiting for load event from document.head.script#tokenex-script");return}const g=await Pa({...e,token:t.token}),{styles:w}=tm(s),b={...g,placeholder:"0000 0000 0000 0000",enablePrettyFormat:!0,styles:w,font:o,debug:i??!1,...t},x=TokenEx.Iframe(n,b);return em({iframe:x,setCachedToken:a,setLoaded:f})}function tm(n){const e=JSON.parse(n);return{styles:{base:sn(e.base),focus:sn(e.focus),error:sn(e.error),placeholder:sn(e.placeholder),cvv:{base:sn(e.cvv?.base),focus:sn(e.cvv?.focus),error:sn(e.cvv?.error),placeholder:sn(e?.placeholder)}}}}function sn(n){if(!n)return"";if(typeof n=="string")return n;let e="";for(const[t,r]of Object.entries(n)){let s="";t.split("").forEach(i=>{i.toUpperCase()===i?s+="-"+i.toLowerCase():s+=i}),e+=s+":"+r+";"}return e}de.nftCartItem=void 0,(n=>{(e=>{e.NFT="nft"})(n.itemClass||(n.itemClass={})),(e=>{e.IN_GAME_PRODUCT="inGameProduct",e.GAME_OF_SKILL="gameOfSkill",e.DATA_STORAGE="dataStorage",e.COMPUTING_RESOURCES="computingResources",e.SPORTS_TICKET="sportsTicket",e.E_SPORTS_TICKET="eSportsTicket",e.MUSIC_TICKET="musicTicket",e.CONFERENCE_TICKET="conferenceTicket",e.VIRTUAL_SPORTS_TICKET="virtualSportsTicket",e.VIRTUAL_ESPORTS_TICKET="virtualESportsTicket",e.VIRTUAL_MUSIC_TICKET="virtualMusicTicket",e.VIRTUAL_CONFERENCE_TICKET="virtualConferenceTicket",e.ALCOHOL="alcohol",e.DLC="DLC",e.SUBSCRIPTION="subscription",e.FUND_ACAUSE="fundACause",e.REAL_ESTATE="realEstate",e.COMPUTING_CONTRACT="computingContract",e.DIGITAL_ART="digitalArt",e.TOP_UP="topUp",e.OWNERSHIP_CONTRACT="ownershipContract",e.IN_GAME_CURRENCY="inGameCurrency",e.MONEY_TOP_UP_CART_ITEM="moneyTopUpCartItem"})(n.productType||(n.productType={}))})(de.nftCartItem||(de.nftCartItem={}));const nm=ne.defineComponent({name:"CoinflowIFrame",props:{args:{type:Object,required:!0}},computed:{url(){return Ht.getCoinflowUrl(this.args)}},emits:{onMessage(n){return!0}},methods:{sendMessage(n){const e=this.$refs.iframeRef;if(!e?.contentWindow)throw new Error("Iframe not defined");e.contentWindow.postMessage(n,"*")},handleIframeMessages({data:n,origin:e}){if(!e.includes(Ht.getCoinflowBaseUrl(this.args.env)))return;this.$emit("onMessage",{data:n,origin:e});const t=La(n,this.args,this.args.handleHeightChangeId);t&&t.then(this.sendMessage).catch(r=>{console.error(r),this.sendMessage("ERROR "+r.message)})},async listenForMessage(n){let e;return new Promise((t,r)=>{if(e=({data:s,origin:i})=>{if(i.includes(Ht.getCoinflowBaseUrl(this.args.env))){if(s.startsWith("ERROR")){r(new Error(s.replace("ERROR","")));return}n(s)&&t(s)}},!window)throw new Error("Window not defined");window.addEventListener("message",e)}).finally(()=>{window.removeEventListener("message",e)})},async sendAndReceiveMessage(n,e){return this.sendMessage(n),this.listenForMessage(e)}},mounted(){if(!window)throw new Error("Window not defined");return window.addEventListener("message",this.handleIframeMessages),()=>{window.removeEventListener("message",this.handleIframeMessages)}}}),Xi=(n,e)=>{const t=n.__vccOpts||n;for(const[r,s]of e)t[r]=s;return t},rm=["src","scrolling"];function im(n,e,t,r,s,i){return ne.openBlock(),ne.createElementBlock("iframe",{credentialless:"",style:{height:"100%",width:"100%"},ref:"iframeRef",allow:"payment;camera;clipboard-write",title:"withdraw",frameBorder:"0",src:n.url,scrolling:n.args.handleHeightChange?"no":"yes",onLoad:e[0]||(e[0]=()=>{const o=n.$refs.iframeRef;o&&(o.style.opacity="1")})},null,40,rm)}const Ur=Xi(nm,[["render",im]]),sm=ne.defineComponent({name:"CoinflowWithdraw",components:{CoinflowIFrame:Ur},props:{args:{type:Object,required:!0}},computed:{handleHeightChangeId(){return Math.random().toString(16).substring(2)},iframeProps(){const n=Cr(this.args);return{...this.args,walletPubkey:n,route:`/withdraw/${this.args.merchantId}`,transaction:void 0}},messageHandlers(){return{...Mr(this.args),handleHeightChange:this.args.handleHeightChange}}}});function om(n,e,t,r,s,i){const o=ne.resolveComponent("coinflow-i-frame");return ne.openBlock(),ne.createBlock(o,{args:{...n.iframeProps,...n.messageHandlers,handleHeightChangeId:n.handleHeightChangeId}},null,8,["args"])}const am=Xi(sm,[["render",om]]),cm=ne.defineComponent({name:"CoinflowPurchase",components:{CoinflowIFrame:Ur},props:{args:{type:Object,required:!0}},computed:{handleHeightChangeId(){return Math.random().toString(16).substring(2)},iframeProps(){const n=Cr(this.args);return{...this.args,walletPubkey:n,route:`/purchase-v2/${this.args.merchantId}`,transaction:Ht.getTransaction(this.args)}},messageHandlers(){return{...Mr(this.args),handleHeightChange:this.args.handleHeightChange}}}});function um(n,e,t,r,s,i){const o=ne.resolveComponent("coinflow-i-frame");return ne.openBlock(),ne.createBlock(o,{args:{...n.iframeProps,...n.messageHandlers,handleHeightChangeId:n.handleHeightChangeId}},null,8,["args"])}const lm=Xi(cm,[["render",um]]),Ji=n=>{const e=ne.ref(!1),t=ne.ref(!1),r=ne.ref(void 0),s=ne.ref(void 0);ne.onMounted(()=>{ji({env:n.env,setTokenExScriptLoaded:()=>{console.log("tokenExScriptLoaded.value = true"),t.value=!0}})});const i=b=>s.value=b,o=()=>e.value=!0,a=b=>r.value=b,f=async b=>{const x=await Ua({...n,...b,tokenExScriptLoaded:t.value,setCachedToken:i,setLoaded:o});return a(x),x},g=async b=>{const x=await Da({...n,...b,tokenExScriptLoaded:t.value,setCachedToken:i,setLoaded:o});return a(x),x},w=async b=>{const x=await Fa({...n,...b,tokenExScriptLoaded:t.value,setCachedToken:i,setLoaded:o});return a(x),x};return ne.watchEffect(b=>{r.value&&(r.value.load(),b(()=>r.value?.remove()))}),{tokenExIframe:r,initializeTokenExIframe:g,initializeCvvOnlyTokenExIframe:f,initializeTokenExCardOnlyIframe:w,loaded:e,cachedToken:s,setTokenExScriptTag:ji,tokenExScriptLoaded:t}},hm=["id"],fm=ne.defineComponent({__name:"CoinflowCardNumberInput",props:{args:{type:Object,required:!0}},setup(n,{expose:e}){const{initializeTokenExIframe:t,tokenExIframe:r}=Ji(n.args);async function s(){if(!r.value)throw new Error("Unable to get token");return r.value.tokenize()}e({getToken:s});function i(){return JSON.stringify(n.args.css)}return ne.watchEffect(()=>{t({css:i(),debug:n.args.debug,origins:n.args.origins,font:n.args.font})},{}),(o,a)=>(ne.openBlock(),ne.createElementBlock("div",{id:ne.unref(tr)},null,8,hm))}}),dm=["id"],pm=ne.defineComponent({__name:"CoinflowCvvInput",setup(n){return(e,t)=>(ne.openBlock(),ne.createElementBlock("div",{id:ne.unref(Un)},null,8,dm))}}),gm=["id"],mm=ne.defineComponent({__name:"CoinflowCvvOnlyInput",props:{args:{type:Object,required:!0}},setup(n,{expose:e}){const{initializeCvvOnlyTokenExIframe:t,tokenExIframe:r}=Ji(n.args);async function s(){if(!r.value)throw new Error("Unable to get token");return r.value.tokenize()}e({getToken:s});function i(){return JSON.stringify(n.args.css)}return ne.watchEffect(()=>{t({...n.args,origins:n.args.origins??[],css:i(),font:n.args.font})},{}),(o,a)=>(ne.openBlock(),ne.createElementBlock("div",{id:ne.unref(Un)},null,8,gm))}}),_m=ne.defineComponent({__name:"CoinflowPurchaseProtection",props:{args:{type:Object,required:!0}},setup(n){const e=ne.ref(void 0);ne.onMounted(()=>new Ht(n.args.env).getNSurePartnerId(n.args.merchantId).then(s=>e.value=s));function t(){return n.args.env==="prod"?"9JBW2RHC7JNJN8ZQ":"SANDBOX_CTCE4XK53ZW0R7V1"}function r(){return n.args.env==="prod"?"https://sdk.nsureapi.com/sdk.js":"https://sdk.nsureapi.com/sdk-sandbox.js"}return ne.watchEffect(s=>{if(!e.value)return;const i=document.createElement("script");i.src=r(),document.head.appendChild(i);const o=`window.nSureAsyncInit = function(deviceId) {
|
|
18
18
|
window.nSureSDK.init({
|
|
19
19
|
appId: '${t()}',
|
|
20
20
|
partnerId: '${e.value}',
|