@solana-agent-wallet-adapter/cli 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1122 -221
- package/dist/index.js.map +4 -4
- package/dist/wallet-host/assets/index-BF6JLAtr.js +3215 -0
- package/dist/wallet-host/assets/index-dftlursl.css +1 -0
- package/dist/wallet-host/assets/{mobile-wallet-adapter-CqDJSDZ5.js → mobile-wallet-adapter-B8zYDJwO.js} +1 -1
- package/dist/wallet-host/assets/solana-runtime-CsPLEN69.js +13 -0
- package/dist/wallet-host/assets/{wallet-standard-eoxEevjj.js → wallet-standard-CIBAN9Xp.js} +1 -1
- package/dist/wallet-host/index.html +5 -8
- package/dist/wallet-host/manifest.webmanifest +2 -13
- package/package.json +1 -1
- package/dist/wallet-host/assets/index-D5ySS2CU.js +0 -2143
- package/dist/wallet-host/assets/index-ZynMhs1G.css +0 -1
- package/dist/wallet-host/assets/solana-runtime-BhiDfU5_.js +0 -20
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
var su=Object.defineProperty;var iu=(s,t,e)=>t in s?su(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var ye=(s,t,e)=>iu(s,typeof t!="symbol"?t+"":t,e);var Ye=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ir(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function Ri(s){if(s.__esModule)return s;var t=s.default;if(typeof t=="function"){var e=function n(){return this instanceof n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(s).forEach(function(n){var i=Object.getOwnPropertyDescriptor(s,n);Object.defineProperty(e,n,i.get?i:{enumerable:!0,get:function(){return s[n]}})}),e}const ou={},au=Object.freeze(Object.defineProperty({__proto__:null,default:ou},Symbol.toStringTag,{value:"Module"})),cu=Ri(au);var Y={},ls={};ls.byteLength=fu;ls.toByteArray=du;ls.fromByteArray=mu;var Qe=[],Oe=[],uu=typeof Uint8Array<"u"?Uint8Array:Array,Hs="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var Dn=0,lu=Hs.length;Dn<lu;++Dn)Qe[Dn]=Hs[Dn],Oe[Hs.charCodeAt(Dn)]=Dn;Oe[45]=62;Oe[95]=63;function ta(s){var t=s.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=s.indexOf("=");e===-1&&(e=t);var n=e===t?0:4-e%4;return[e,n]}function fu(s){var t=ta(s),e=t[0],n=t[1];return(e+n)*3/4-n}function hu(s,t,e){return(t+e)*3/4-e}function du(s){var t,e=ta(s),n=e[0],i=e[1],r=new uu(hu(s,n,i)),o=0,a=i>0?n-4:n,u;for(u=0;u<a;u+=4)t=Oe[s.charCodeAt(u)]<<18|Oe[s.charCodeAt(u+1)]<<12|Oe[s.charCodeAt(u+2)]<<6|Oe[s.charCodeAt(u+3)],r[o++]=t>>16&255,r[o++]=t>>8&255,r[o++]=t&255;return i===2&&(t=Oe[s.charCodeAt(u)]<<2|Oe[s.charCodeAt(u+1)]>>4,r[o++]=t&255),i===1&&(t=Oe[s.charCodeAt(u)]<<10|Oe[s.charCodeAt(u+1)]<<4|Oe[s.charCodeAt(u+2)]>>2,r[o++]=t>>8&255,r[o++]=t&255),r}function pu(s){return Qe[s>>18&63]+Qe[s>>12&63]+Qe[s>>6&63]+Qe[s&63]}function gu(s,t,e){for(var n,i=[],r=t;r<e;r+=3)n=(s[r]<<16&16711680)+(s[r+1]<<8&65280)+(s[r+2]&255),i.push(pu(n));return i.join("")}function mu(s){for(var t,e=s.length,n=e%3,i=[],r=16383,o=0,a=e-n;o<a;o+=r)i.push(gu(s,o,o+r>a?a:o+r));return n===1?(t=s[e-1],i.push(Qe[t>>2]+Qe[t<<4&63]+"==")):n===2&&(t=(s[e-2]<<8)+s[e-1],i.push(Qe[t>>10]+Qe[t>>4&63]+Qe[t<<2&63]+"=")),i.join("")}var Mi={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */Mi.read=function(s,t,e,n,i){var r,o,a=i*8-n-1,u=(1<<a)-1,g=u>>1,x=-7,B=e?i-1:0,I=e?-1:1,v=s[t+B];for(B+=I,r=v&(1<<-x)-1,v>>=-x,x+=a;x>0;r=r*256+s[t+B],B+=I,x-=8);for(o=r&(1<<-x)-1,r>>=-x,x+=n;x>0;o=o*256+s[t+B],B+=I,x-=8);if(r===0)r=1-g;else{if(r===u)return o?NaN:(v?-1:1)*(1/0);o=o+Math.pow(2,n),r=r-g}return(v?-1:1)*o*Math.pow(2,r-n)};Mi.write=function(s,t,e,n,i,r){var o,a,u,g=r*8-i-1,x=(1<<g)-1,B=x>>1,I=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,v=n?0:r-1,E=n?1:-1,R=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=x):(o=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-o))<1&&(o--,u*=2),o+B>=1?t+=I/u:t+=I*Math.pow(2,1-B),t*u>=2&&(o++,u/=2),o+B>=x?(a=0,o=x):o+B>=1?(a=(t*u-1)*Math.pow(2,i),o=o+B):(a=t*Math.pow(2,B-1)*Math.pow(2,i),o=0));i>=8;s[e+v]=a&255,v+=E,a/=256,i-=8);for(o=o<<i|a,g+=i;g>0;s[e+v]=o&255,v+=E,o/=256,g-=8);s[e+v-E]|=R*128};/*!
|
|
2
|
-
* The buffer module from node.js, for the browser.
|
|
3
|
-
*
|
|
4
|
-
* @author Feross Aboukhadijeh <https://feross.org>
|
|
5
|
-
* @license MIT
|
|
6
|
-
*/(function(s){const t=ls,e=Mi,n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;s.Buffer=a,s.SlowBuffer=W,s.INSPECT_MAX_BYTES=50;const i=2147483647;s.kMaxLength=i,a.TYPED_ARRAY_SUPPORT=r(),!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 r(){try{const m=new Uint8Array(1),l={foo:function(){return 42}};return Object.setPrototypeOf(l,Uint8Array.prototype),Object.setPrototypeOf(m,l),m.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(m){if(m>i)throw new RangeError('The value "'+m+'" is invalid for option "size"');const l=new Uint8Array(m);return Object.setPrototypeOf(l,a.prototype),l}function a(m,l,h){if(typeof m=="number"){if(typeof l=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return B(m)}return u(m,l,h)}a.poolSize=8192;function u(m,l,h){if(typeof m=="string")return I(m,l);if(ArrayBuffer.isView(m))return E(m);if(m==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof m);if(Ue(m,ArrayBuffer)||m&&Ue(m.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Ue(m,SharedArrayBuffer)||m&&Ue(m.buffer,SharedArrayBuffer)))return R(m,l,h);if(typeof m=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const _=m.valueOf&&m.valueOf();if(_!=null&&_!==m)return a.from(_,l,h);const U=T(m);if(U)return U;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof m[Symbol.toPrimitive]=="function")return a.from(m[Symbol.toPrimitive]("string"),l,h);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof m)}a.from=function(m,l,h){return u(m,l,h)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function g(m){if(typeof m!="number")throw new TypeError('"size" argument must be of type number');if(m<0)throw new RangeError('The value "'+m+'" is invalid for option "size"')}function x(m,l,h){return g(m),m<=0?o(m):l!==void 0?typeof h=="string"?o(m).fill(l,h):o(m).fill(l):o(m)}a.alloc=function(m,l,h){return x(m,l,h)};function B(m){return g(m),o(m<0?0:N(m)|0)}a.allocUnsafe=function(m){return B(m)},a.allocUnsafeSlow=function(m){return B(m)};function I(m,l){if((typeof l!="string"||l==="")&&(l="utf8"),!a.isEncoding(l))throw new TypeError("Unknown encoding: "+l);const h=D(m,l)|0;let _=o(h);const U=_.write(m,l);return U!==h&&(_=_.slice(0,U)),_}function v(m){const l=m.length<0?0:N(m.length)|0,h=o(l);for(let _=0;_<l;_+=1)h[_]=m[_]&255;return h}function E(m){if(Ue(m,Uint8Array)){const l=new Uint8Array(m);return R(l.buffer,l.byteOffset,l.byteLength)}return v(m)}function R(m,l,h){if(l<0||m.byteLength<l)throw new RangeError('"offset" is outside of buffer bounds');if(m.byteLength<l+(h||0))throw new RangeError('"length" is outside of buffer bounds');let _;return l===void 0&&h===void 0?_=new Uint8Array(m):h===void 0?_=new Uint8Array(m,l):_=new Uint8Array(m,l,h),Object.setPrototypeOf(_,a.prototype),_}function T(m){if(a.isBuffer(m)){const l=N(m.length)|0,h=o(l);return h.length===0||m.copy(h,0,0,l),h}if(m.length!==void 0)return typeof m.length!="number"||qt(m.length)?o(0):v(m);if(m.type==="Buffer"&&Array.isArray(m.data))return v(m.data)}function N(m){if(m>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return m|0}function W(m){return+m!=m&&(m=0),a.alloc(+m)}a.isBuffer=function(l){return l!=null&&l._isBuffer===!0&&l!==a.prototype},a.compare=function(l,h){if(Ue(l,Uint8Array)&&(l=a.from(l,l.offset,l.byteLength)),Ue(h,Uint8Array)&&(h=a.from(h,h.offset,h.byteLength)),!a.isBuffer(l)||!a.isBuffer(h))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(l===h)return 0;let _=l.length,U=h.length;for(let F=0,z=Math.min(_,U);F<z;++F)if(l[F]!==h[F]){_=l[F],U=h[F];break}return _<U?-1:U<_?1:0},a.isEncoding=function(l){switch(String(l).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(l,h){if(!Array.isArray(l))throw new TypeError('"list" argument must be an Array of Buffers');if(l.length===0)return a.alloc(0);let _;if(h===void 0)for(h=0,_=0;_<l.length;++_)h+=l[_].length;const U=a.allocUnsafe(h);let F=0;for(_=0;_<l.length;++_){let z=l[_];if(Ue(z,Uint8Array))F+z.length>U.length?(a.isBuffer(z)||(z=a.from(z)),z.copy(U,F)):Uint8Array.prototype.set.call(U,z,F);else if(a.isBuffer(z))z.copy(U,F);else throw new TypeError('"list" argument must be an Array of Buffers');F+=z.length}return U};function D(m,l){if(a.isBuffer(m))return m.length;if(ArrayBuffer.isView(m)||Ue(m,ArrayBuffer))return m.byteLength;if(typeof m!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof m);const h=m.length,_=arguments.length>2&&arguments[2]===!0;if(!_&&h===0)return 0;let U=!1;for(;;)switch(l){case"ascii":case"latin1":case"binary":return h;case"utf8":case"utf-8":return $t(m).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return h*2;case"hex":return h>>>1;case"base64":return Kt(m).length;default:if(U)return _?-1:$t(m).length;l=(""+l).toLowerCase(),U=!0}}a.byteLength=D;function X(m,l,h){let _=!1;if((l===void 0||l<0)&&(l=0),l>this.length||((h===void 0||h>this.length)&&(h=this.length),h<=0)||(h>>>=0,l>>>=0,h<=l))return"";for(m||(m="utf8");;)switch(m){case"hex":return M(this,l,h);case"utf8":case"utf-8":return c(this,l,h);case"ascii":return S(this,l,h);case"latin1":case"binary":return k(this,l,h);case"base64":return y(this,l,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,l,h);default:if(_)throw new TypeError("Unknown encoding: "+m);m=(m+"").toLowerCase(),_=!0}}a.prototype._isBuffer=!0;function nt(m,l,h){const _=m[l];m[l]=m[h],m[h]=_}a.prototype.swap16=function(){const l=this.length;if(l%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let h=0;h<l;h+=2)nt(this,h,h+1);return this},a.prototype.swap32=function(){const l=this.length;if(l%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let h=0;h<l;h+=4)nt(this,h,h+3),nt(this,h+1,h+2);return this},a.prototype.swap64=function(){const l=this.length;if(l%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let h=0;h<l;h+=8)nt(this,h,h+7),nt(this,h+1,h+6),nt(this,h+2,h+5),nt(this,h+3,h+4);return this},a.prototype.toString=function(){const l=this.length;return l===0?"":arguments.length===0?c(this,0,l):X.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(l){if(!a.isBuffer(l))throw new TypeError("Argument must be a Buffer");return this===l?!0:a.compare(this,l)===0},a.prototype.inspect=function(){let l="";const h=s.INSPECT_MAX_BYTES;return l=this.toString("hex",0,h).replace(/(.{2})/g,"$1 ").trim(),this.length>h&&(l+=" ... "),"<Buffer "+l+">"},n&&(a.prototype[n]=a.prototype.inspect),a.prototype.compare=function(l,h,_,U,F){if(Ue(l,Uint8Array)&&(l=a.from(l,l.offset,l.byteLength)),!a.isBuffer(l))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof l);if(h===void 0&&(h=0),_===void 0&&(_=l?l.length:0),U===void 0&&(U=0),F===void 0&&(F=this.length),h<0||_>l.length||U<0||F>this.length)throw new RangeError("out of range index");if(U>=F&&h>=_)return 0;if(U>=F)return-1;if(h>=_)return 1;if(h>>>=0,_>>>=0,U>>>=0,F>>>=0,this===l)return 0;let z=F-U,bt=_-h;const mt=Math.min(z,bt),gt=this.slice(U,F),Ft=l.slice(h,_);for(let lt=0;lt<mt;++lt)if(gt[lt]!==Ft[lt]){z=gt[lt],bt=Ft[lt];break}return z<bt?-1:bt<z?1:0};function at(m,l,h,_,U){if(m.length===0)return-1;if(typeof h=="string"?(_=h,h=0):h>2147483647?h=2147483647:h<-2147483648&&(h=-2147483648),h=+h,qt(h)&&(h=U?0:m.length-1),h<0&&(h=m.length+h),h>=m.length){if(U)return-1;h=m.length-1}else if(h<0)if(U)h=0;else return-1;if(typeof l=="string"&&(l=a.from(l,_)),a.isBuffer(l))return l.length===0?-1:ht(m,l,h,_,U);if(typeof l=="number")return l=l&255,typeof Uint8Array.prototype.indexOf=="function"?U?Uint8Array.prototype.indexOf.call(m,l,h):Uint8Array.prototype.lastIndexOf.call(m,l,h):ht(m,[l],h,_,U);throw new TypeError("val must be string, number or Buffer")}function ht(m,l,h,_,U){let F=1,z=m.length,bt=l.length;if(_!==void 0&&(_=String(_).toLowerCase(),_==="ucs2"||_==="ucs-2"||_==="utf16le"||_==="utf-16le")){if(m.length<2||l.length<2)return-1;F=2,z/=2,bt/=2,h/=2}function mt(Ft,lt){return F===1?Ft[lt]:Ft.readUInt16BE(lt*F)}let gt;if(U){let Ft=-1;for(gt=h;gt<z;gt++)if(mt(m,gt)===mt(l,Ft===-1?0:gt-Ft)){if(Ft===-1&&(Ft=gt),gt-Ft+1===bt)return Ft*F}else Ft!==-1&&(gt-=gt-Ft),Ft=-1}else for(h+bt>z&&(h=z-bt),gt=h;gt>=0;gt--){let Ft=!0;for(let lt=0;lt<bt;lt++)if(mt(m,gt+lt)!==mt(l,lt)){Ft=!1;break}if(Ft)return gt}return-1}a.prototype.includes=function(l,h,_){return this.indexOf(l,h,_)!==-1},a.prototype.indexOf=function(l,h,_){return at(this,l,h,_,!0)},a.prototype.lastIndexOf=function(l,h,_){return at(this,l,h,_,!1)};function ut(m,l,h,_){h=Number(h)||0;const U=m.length-h;_?(_=Number(_),_>U&&(_=U)):_=U;const F=l.length;_>F/2&&(_=F/2);let z;for(z=0;z<_;++z){const bt=parseInt(l.substr(z*2,2),16);if(qt(bt))return z;m[h+z]=bt}return z}function j(m,l,h,_){return Pt($t(l,m.length-h),m,h,_)}function rt(m,l,h,_){return Pt(Vt(l),m,h,_)}function Q(m,l,h,_){return Pt(Kt(l),m,h,_)}function et(m,l,h,_){return Pt(Nr(l,m.length-h),m,h,_)}a.prototype.write=function(l,h,_,U){if(h===void 0)U="utf8",_=this.length,h=0;else if(_===void 0&&typeof h=="string")U=h,_=this.length,h=0;else if(isFinite(h))h=h>>>0,isFinite(_)?(_=_>>>0,U===void 0&&(U="utf8")):(U=_,_=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const F=this.length-h;if((_===void 0||_>F)&&(_=F),l.length>0&&(_<0||h<0)||h>this.length)throw new RangeError("Attempt to write outside buffer bounds");U||(U="utf8");let z=!1;for(;;)switch(U){case"hex":return ut(this,l,h,_);case"utf8":case"utf-8":return j(this,l,h,_);case"ascii":case"latin1":case"binary":return rt(this,l,h,_);case"base64":return Q(this,l,h,_);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return et(this,l,h,_);default:if(z)throw new TypeError("Unknown encoding: "+U);U=(""+U).toLowerCase(),z=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function y(m,l,h){return l===0&&h===m.length?t.fromByteArray(m):t.fromByteArray(m.slice(l,h))}function c(m,l,h){h=Math.min(m.length,h);const _=[];let U=l;for(;U<h;){const F=m[U];let z=null,bt=F>239?4:F>223?3:F>191?2:1;if(U+bt<=h){let mt,gt,Ft,lt;switch(bt){case 1:F<128&&(z=F);break;case 2:mt=m[U+1],(mt&192)===128&&(lt=(F&31)<<6|mt&63,lt>127&&(z=lt));break;case 3:mt=m[U+1],gt=m[U+2],(mt&192)===128&&(gt&192)===128&&(lt=(F&15)<<12|(mt&63)<<6|gt&63,lt>2047&&(lt<55296||lt>57343)&&(z=lt));break;case 4:mt=m[U+1],gt=m[U+2],Ft=m[U+3],(mt&192)===128&&(gt&192)===128&&(Ft&192)===128&&(lt=(F&15)<<18|(mt&63)<<12|(gt&63)<<6|Ft&63,lt>65535&<<1114112&&(z=lt))}}z===null?(z=65533,bt=1):z>65535&&(z-=65536,_.push(z>>>10&1023|55296),z=56320|z&1023),_.push(z),U+=bt}return p(_)}const d=4096;function p(m){const l=m.length;if(l<=d)return String.fromCharCode.apply(String,m);let h="",_=0;for(;_<l;)h+=String.fromCharCode.apply(String,m.slice(_,_+=d));return h}function S(m,l,h){let _="";h=Math.min(m.length,h);for(let U=l;U<h;++U)_+=String.fromCharCode(m[U]&127);return _}function k(m,l,h){let _="";h=Math.min(m.length,h);for(let U=l;U<h;++U)_+=String.fromCharCode(m[U]);return _}function M(m,l,h){const _=m.length;(!l||l<0)&&(l=0),(!h||h<0||h>_)&&(h=_);let U="";for(let F=l;F<h;++F)U+=Gt[m[F]];return U}function C(m,l,h){const _=m.slice(l,h);let U="";for(let F=0;F<_.length-1;F+=2)U+=String.fromCharCode(_[F]+_[F+1]*256);return U}a.prototype.slice=function(l,h){const _=this.length;l=~~l,h=h===void 0?_:~~h,l<0?(l+=_,l<0&&(l=0)):l>_&&(l=_),h<0?(h+=_,h<0&&(h=0)):h>_&&(h=_),h<l&&(h=l);const U=this.subarray(l,h);return Object.setPrototypeOf(U,a.prototype),U};function w(m,l,h){if(m%1!==0||m<0)throw new RangeError("offset is not uint");if(m+l>h)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(l,h,_){l=l>>>0,h=h>>>0,_||w(l,h,this.length);let U=this[l],F=1,z=0;for(;++z<h&&(F*=256);)U+=this[l+z]*F;return U},a.prototype.readUintBE=a.prototype.readUIntBE=function(l,h,_){l=l>>>0,h=h>>>0,_||w(l,h,this.length);let U=this[l+--h],F=1;for(;h>0&&(F*=256);)U+=this[l+--h]*F;return U},a.prototype.readUint8=a.prototype.readUInt8=function(l,h){return l=l>>>0,h||w(l,1,this.length),this[l]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(l,h){return l=l>>>0,h||w(l,2,this.length),this[l]|this[l+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(l,h){return l=l>>>0,h||w(l,2,this.length),this[l]<<8|this[l+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(l,h){return l=l>>>0,h||w(l,4,this.length),(this[l]|this[l+1]<<8|this[l+2]<<16)+this[l+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(l,h){return l=l>>>0,h||w(l,4,this.length),this[l]*16777216+(this[l+1]<<16|this[l+2]<<8|this[l+3])},a.prototype.readBigUInt64LE=Ve(function(l){l=l>>>0,Fe(l,"offset");const h=this[l],_=this[l+7];(h===void 0||_===void 0)&&Lt(l,this.length-8);const U=h+this[++l]*2**8+this[++l]*2**16+this[++l]*2**24,F=this[++l]+this[++l]*2**8+this[++l]*2**16+_*2**24;return BigInt(U)+(BigInt(F)<<BigInt(32))}),a.prototype.readBigUInt64BE=Ve(function(l){l=l>>>0,Fe(l,"offset");const h=this[l],_=this[l+7];(h===void 0||_===void 0)&&Lt(l,this.length-8);const U=h*2**24+this[++l]*2**16+this[++l]*2**8+this[++l],F=this[++l]*2**24+this[++l]*2**16+this[++l]*2**8+_;return(BigInt(U)<<BigInt(32))+BigInt(F)}),a.prototype.readIntLE=function(l,h,_){l=l>>>0,h=h>>>0,_||w(l,h,this.length);let U=this[l],F=1,z=0;for(;++z<h&&(F*=256);)U+=this[l+z]*F;return F*=128,U>=F&&(U-=Math.pow(2,8*h)),U},a.prototype.readIntBE=function(l,h,_){l=l>>>0,h=h>>>0,_||w(l,h,this.length);let U=h,F=1,z=this[l+--U];for(;U>0&&(F*=256);)z+=this[l+--U]*F;return F*=128,z>=F&&(z-=Math.pow(2,8*h)),z},a.prototype.readInt8=function(l,h){return l=l>>>0,h||w(l,1,this.length),this[l]&128?(255-this[l]+1)*-1:this[l]},a.prototype.readInt16LE=function(l,h){l=l>>>0,h||w(l,2,this.length);const _=this[l]|this[l+1]<<8;return _&32768?_|4294901760:_},a.prototype.readInt16BE=function(l,h){l=l>>>0,h||w(l,2,this.length);const _=this[l+1]|this[l]<<8;return _&32768?_|4294901760:_},a.prototype.readInt32LE=function(l,h){return l=l>>>0,h||w(l,4,this.length),this[l]|this[l+1]<<8|this[l+2]<<16|this[l+3]<<24},a.prototype.readInt32BE=function(l,h){return l=l>>>0,h||w(l,4,this.length),this[l]<<24|this[l+1]<<16|this[l+2]<<8|this[l+3]},a.prototype.readBigInt64LE=Ve(function(l){l=l>>>0,Fe(l,"offset");const h=this[l],_=this[l+7];(h===void 0||_===void 0)&&Lt(l,this.length-8);const U=this[l+4]+this[l+5]*2**8+this[l+6]*2**16+(_<<24);return(BigInt(U)<<BigInt(32))+BigInt(h+this[++l]*2**8+this[++l]*2**16+this[++l]*2**24)}),a.prototype.readBigInt64BE=Ve(function(l){l=l>>>0,Fe(l,"offset");const h=this[l],_=this[l+7];(h===void 0||_===void 0)&&Lt(l,this.length-8);const U=(h<<24)+this[++l]*2**16+this[++l]*2**8+this[++l];return(BigInt(U)<<BigInt(32))+BigInt(this[++l]*2**24+this[++l]*2**16+this[++l]*2**8+_)}),a.prototype.readFloatLE=function(l,h){return l=l>>>0,h||w(l,4,this.length),e.read(this,l,!0,23,4)},a.prototype.readFloatBE=function(l,h){return l=l>>>0,h||w(l,4,this.length),e.read(this,l,!1,23,4)},a.prototype.readDoubleLE=function(l,h){return l=l>>>0,h||w(l,8,this.length),e.read(this,l,!0,52,8)},a.prototype.readDoubleBE=function(l,h){return l=l>>>0,h||w(l,8,this.length),e.read(this,l,!1,52,8)};function f(m,l,h,_,U,F){if(!a.isBuffer(m))throw new TypeError('"buffer" argument must be a Buffer instance');if(l>U||l<F)throw new RangeError('"value" argument is out of bounds');if(h+_>m.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(l,h,_,U){if(l=+l,h=h>>>0,_=_>>>0,!U){const bt=Math.pow(2,8*_)-1;f(this,l,h,_,bt,0)}let F=1,z=0;for(this[h]=l&255;++z<_&&(F*=256);)this[h+z]=l/F&255;return h+_},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(l,h,_,U){if(l=+l,h=h>>>0,_=_>>>0,!U){const bt=Math.pow(2,8*_)-1;f(this,l,h,_,bt,0)}let F=_-1,z=1;for(this[h+F]=l&255;--F>=0&&(z*=256);)this[h+F]=l/z&255;return h+_},a.prototype.writeUint8=a.prototype.writeUInt8=function(l,h,_){return l=+l,h=h>>>0,_||f(this,l,h,1,255,0),this[h]=l&255,h+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(l,h,_){return l=+l,h=h>>>0,_||f(this,l,h,2,65535,0),this[h]=l&255,this[h+1]=l>>>8,h+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(l,h,_){return l=+l,h=h>>>0,_||f(this,l,h,2,65535,0),this[h]=l>>>8,this[h+1]=l&255,h+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(l,h,_){return l=+l,h=h>>>0,_||f(this,l,h,4,4294967295,0),this[h+3]=l>>>24,this[h+2]=l>>>16,this[h+1]=l>>>8,this[h]=l&255,h+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(l,h,_){return l=+l,h=h>>>0,_||f(this,l,h,4,4294967295,0),this[h]=l>>>24,this[h+1]=l>>>16,this[h+2]=l>>>8,this[h+3]=l&255,h+4};function A(m,l,h,_,U){Ct(l,_,U,m,h,7);let F=Number(l&BigInt(4294967295));m[h++]=F,F=F>>8,m[h++]=F,F=F>>8,m[h++]=F,F=F>>8,m[h++]=F;let z=Number(l>>BigInt(32)&BigInt(4294967295));return m[h++]=z,z=z>>8,m[h++]=z,z=z>>8,m[h++]=z,z=z>>8,m[h++]=z,h}function J(m,l,h,_,U){Ct(l,_,U,m,h,7);let F=Number(l&BigInt(4294967295));m[h+7]=F,F=F>>8,m[h+6]=F,F=F>>8,m[h+5]=F,F=F>>8,m[h+4]=F;let z=Number(l>>BigInt(32)&BigInt(4294967295));return m[h+3]=z,z=z>>8,m[h+2]=z,z=z>>8,m[h+1]=z,z=z>>8,m[h]=z,h+8}a.prototype.writeBigUInt64LE=Ve(function(l,h=0){return A(this,l,h,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=Ve(function(l,h=0){return J(this,l,h,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(l,h,_,U){if(l=+l,h=h>>>0,!U){const mt=Math.pow(2,8*_-1);f(this,l,h,_,mt-1,-mt)}let F=0,z=1,bt=0;for(this[h]=l&255;++F<_&&(z*=256);)l<0&&bt===0&&this[h+F-1]!==0&&(bt=1),this[h+F]=(l/z>>0)-bt&255;return h+_},a.prototype.writeIntBE=function(l,h,_,U){if(l=+l,h=h>>>0,!U){const mt=Math.pow(2,8*_-1);f(this,l,h,_,mt-1,-mt)}let F=_-1,z=1,bt=0;for(this[h+F]=l&255;--F>=0&&(z*=256);)l<0&&bt===0&&this[h+F+1]!==0&&(bt=1),this[h+F]=(l/z>>0)-bt&255;return h+_},a.prototype.writeInt8=function(l,h,_){return l=+l,h=h>>>0,_||f(this,l,h,1,127,-128),l<0&&(l=255+l+1),this[h]=l&255,h+1},a.prototype.writeInt16LE=function(l,h,_){return l=+l,h=h>>>0,_||f(this,l,h,2,32767,-32768),this[h]=l&255,this[h+1]=l>>>8,h+2},a.prototype.writeInt16BE=function(l,h,_){return l=+l,h=h>>>0,_||f(this,l,h,2,32767,-32768),this[h]=l>>>8,this[h+1]=l&255,h+2},a.prototype.writeInt32LE=function(l,h,_){return l=+l,h=h>>>0,_||f(this,l,h,4,2147483647,-2147483648),this[h]=l&255,this[h+1]=l>>>8,this[h+2]=l>>>16,this[h+3]=l>>>24,h+4},a.prototype.writeInt32BE=function(l,h,_){return l=+l,h=h>>>0,_||f(this,l,h,4,2147483647,-2147483648),l<0&&(l=4294967295+l+1),this[h]=l>>>24,this[h+1]=l>>>16,this[h+2]=l>>>8,this[h+3]=l&255,h+4},a.prototype.writeBigInt64LE=Ve(function(l,h=0){return A(this,l,h,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=Ve(function(l,h=0){return J(this,l,h,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Z(m,l,h,_,U,F){if(h+_>m.length)throw new RangeError("Index out of range");if(h<0)throw new RangeError("Index out of range")}function tt(m,l,h,_,U){return l=+l,h=h>>>0,U||Z(m,l,h,4),e.write(m,l,h,_,23,4),h+4}a.prototype.writeFloatLE=function(l,h,_){return tt(this,l,h,!0,_)},a.prototype.writeFloatBE=function(l,h,_){return tt(this,l,h,!1,_)};function xt(m,l,h,_,U){return l=+l,h=h>>>0,U||Z(m,l,h,8),e.write(m,l,h,_,52,8),h+8}a.prototype.writeDoubleLE=function(l,h,_){return xt(this,l,h,!0,_)},a.prototype.writeDoubleBE=function(l,h,_){return xt(this,l,h,!1,_)},a.prototype.copy=function(l,h,_,U){if(!a.isBuffer(l))throw new TypeError("argument should be a Buffer");if(_||(_=0),!U&&U!==0&&(U=this.length),h>=l.length&&(h=l.length),h||(h=0),U>0&&U<_&&(U=_),U===_||l.length===0||this.length===0)return 0;if(h<0)throw new RangeError("targetStart out of bounds");if(_<0||_>=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),l.length-h<U-_&&(U=l.length-h+_);const F=U-_;return this===l&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(h,_,U):Uint8Array.prototype.set.call(l,this.subarray(_,U),h),F},a.prototype.fill=function(l,h,_,U){if(typeof l=="string"){if(typeof h=="string"?(U=h,h=0,_=this.length):typeof _=="string"&&(U=_,_=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(l.length===1){const z=l.charCodeAt(0);(U==="utf8"&&z<128||U==="latin1")&&(l=z)}}else typeof l=="number"?l=l&255:typeof l=="boolean"&&(l=Number(l));if(h<0||this.length<h||this.length<_)throw new RangeError("Out of range index");if(_<=h)return this;h=h>>>0,_=_===void 0?this.length:_>>>0,l||(l=0);let F;if(typeof l=="number")for(F=h;F<_;++F)this[F]=l;else{const z=a.isBuffer(l)?l:a.from(l,U),bt=z.length;if(bt===0)throw new TypeError('The value "'+l+'" is invalid for argument "value"');for(F=0;F<_-h;++F)this[F+h]=z[F%bt]}return this};const dt={};function ct(m,l,h){dt[m]=class extends h{constructor(){super(),Object.defineProperty(this,"message",{value:l.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${m}]`,this.stack,delete this.name}get code(){return m}set code(U){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:U,writable:!0})}toString(){return`${this.name} [${m}]: ${this.message}`}}}ct("ERR_BUFFER_OUT_OF_BOUNDS",function(m){return m?`${m} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),ct("ERR_INVALID_ARG_TYPE",function(m,l){return`The "${m}" argument must be of type number. Received type ${typeof l}`},TypeError),ct("ERR_OUT_OF_RANGE",function(m,l,h){let _=`The value of "${m}" is out of range.`,U=h;return Number.isInteger(h)&&Math.abs(h)>2**32?U=Wt(String(h)):typeof h=="bigint"&&(U=String(h),(h>BigInt(2)**BigInt(32)||h<-(BigInt(2)**BigInt(32)))&&(U=Wt(U)),U+="n"),_+=` It must be ${l}. Received ${U}`,_},RangeError);function Wt(m){let l="",h=m.length;const _=m[0]==="-"?1:0;for(;h>=_+4;h-=3)l=`_${m.slice(h-3,h)}${l}`;return`${m.slice(0,h)}${l}`}function Tt(m,l,h){Fe(l,"offset"),(m[l]===void 0||m[l+h]===void 0)&&Lt(l,m.length-(h+1))}function Ct(m,l,h,_,U,F){if(m>h||m<l){const z=typeof l=="bigint"?"n":"";let bt;throw l===0||l===BigInt(0)?bt=`>= 0${z} and < 2${z} ** ${(F+1)*8}${z}`:bt=`>= -(2${z} ** ${(F+1)*8-1}${z}) and < 2 ** ${(F+1)*8-1}${z}`,new dt.ERR_OUT_OF_RANGE("value",bt,m)}Tt(_,U,F)}function Fe(m,l){if(typeof m!="number")throw new dt.ERR_INVALID_ARG_TYPE(l,"number",m)}function Lt(m,l,h){throw Math.floor(m)!==m?(Fe(m,h),new dt.ERR_OUT_OF_RANGE("offset","an integer",m)):l<0?new dt.ERR_BUFFER_OUT_OF_BOUNDS:new dt.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${l}`,m)}const jt=/[^+/0-9A-Za-z-_]/g;function Ur(m){if(m=m.split("=")[0],m=m.trim().replace(jt,""),m.length<2)return"";for(;m.length%4!==0;)m=m+"=";return m}function $t(m,l){l=l||1/0;let h;const _=m.length;let U=null;const F=[];for(let z=0;z<_;++z){if(h=m.charCodeAt(z),h>55295&&h<57344){if(!U){if(h>56319){(l-=3)>-1&&F.push(239,191,189);continue}else if(z+1===_){(l-=3)>-1&&F.push(239,191,189);continue}U=h;continue}if(h<56320){(l-=3)>-1&&F.push(239,191,189),U=h;continue}h=(U-55296<<10|h-56320)+65536}else U&&(l-=3)>-1&&F.push(239,191,189);if(U=null,h<128){if((l-=1)<0)break;F.push(h)}else if(h<2048){if((l-=2)<0)break;F.push(h>>6|192,h&63|128)}else if(h<65536){if((l-=3)<0)break;F.push(h>>12|224,h>>6&63|128,h&63|128)}else if(h<1114112){if((l-=4)<0)break;F.push(h>>18|240,h>>12&63|128,h>>6&63|128,h&63|128)}else throw new Error("Invalid code point")}return F}function Vt(m){const l=[];for(let h=0;h<m.length;++h)l.push(m.charCodeAt(h)&255);return l}function Nr(m,l){let h,_,U;const F=[];for(let z=0;z<m.length&&!((l-=2)<0);++z)h=m.charCodeAt(z),_=h>>8,U=h%256,F.push(U),F.push(_);return F}function Kt(m){return t.toByteArray(Ur(m))}function Pt(m,l,h,_){let U;for(U=0;U<_&&!(U+h>=l.length||U>=m.length);++U)l[U+h]=m[U];return U}function Ue(m,l){return m instanceof l||m!=null&&m.constructor!=null&&m.constructor.name!=null&&m.constructor.name===l.name}function qt(m){return m!==m}const Gt=function(){const m="0123456789abcdef",l=new Array(256);for(let h=0;h<16;++h){const _=h*16;for(let U=0;U<16;++U)l[_+U]=m[h]+m[U]}return l}();function Ve(m){return typeof BigInt>"u"?Zt:m}function Zt(){throw new Error("BigInt not supported")}})(Y);const zn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Rr(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function di(s){if(!Number.isSafeInteger(s)||s<0)throw new Error("positive integer expected, got "+s)}function Un(s,...t){if(!Rr(s))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(s.length))throw new Error("Uint8Array expected of length "+t+", got length="+s.length)}function ea(s){if(typeof s!="function"||typeof s.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");di(s.outputLen),di(s.blockLen)}function Vr(s,t=!0){if(s.destroyed)throw new Error("Hash instance has been destroyed");if(t&&s.finished)throw new Error("Hash#digest() has already been called")}function yu(s,t){Un(s);const e=t.outputLen;if(s.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}function sr(...s){for(let t=0;t<s.length;t++)s[t].fill(0)}function Ws(s){return new DataView(s.buffer,s.byteOffset,s.byteLength)}function Je(s,t){return s<<32-t|s>>>t}const na=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",wu=Array.from({length:256},(s,t)=>t.toString(16).padStart(2,"0"));function Cn(s){if(Un(s),na)return s.toHex();let t="";for(let e=0;e<s.length;e++)t+=wu[s[e]];return t}const an={_0:48,_9:57,A:65,F:70,a:97,f:102};function po(s){if(s>=an._0&&s<=an._9)return s-an._0;if(s>=an.A&&s<=an.F)return s-(an.A-10);if(s>=an.a&&s<=an.f)return s-(an.a-10)}function Gr(s){if(typeof s!="string")throw new Error("hex string expected, got "+typeof s);if(na)return Uint8Array.fromHex(s);const t=s.length,e=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(e);for(let i=0,r=0;i<e;i++,r+=2){const o=po(s.charCodeAt(r)),a=po(s.charCodeAt(r+1));if(o===void 0||a===void 0){const u=s[r]+s[r+1];throw new Error('hex string expected, got non-hex character "'+u+'" at index '+r)}n[i]=o*16+a}return n}function bu(s){if(typeof s!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(s))}function Ti(s){return typeof s=="string"&&(s=bu(s)),Un(s),s}function tn(...s){let t=0;for(let n=0;n<s.length;n++){const i=s[n];Un(i),t+=i.length}const e=new Uint8Array(t);for(let n=0,i=0;n<s.length;n++){const r=s[n];e.set(r,i),i+=r.length}return e}class ra{}function sa(s){const t=n=>s().update(Ti(n)).digest(),e=s();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>s(),t}function Ci(s=32){if(zn&&typeof zn.getRandomValues=="function")return zn.getRandomValues(new Uint8Array(s));if(zn&&typeof zn.randomBytes=="function")return Uint8Array.from(zn.randomBytes(s));throw new Error("crypto.getRandomValues must be defined")}function Su(s,t,e,n){if(typeof s.setBigUint64=="function")return s.setBigUint64(t,e,n);const i=BigInt(32),r=BigInt(4294967295),o=Number(e>>i&r),a=Number(e&r),u=n?4:0,g=n?0:4;s.setUint32(t+u,o,n),s.setUint32(t+g,a,n)}function vu(s,t,e){return s&t^~s&e}function xu(s,t,e){return s&t^s&e^t&e}class ia extends ra{constructor(t,e,n,i){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=i,this.buffer=new Uint8Array(t),this.view=Ws(this.buffer)}update(t){Vr(this),t=Ti(t),Un(t);const{view:e,buffer:n,blockLen:i}=this,r=t.length;for(let o=0;o<r;){const a=Math.min(i-this.pos,r-o);if(a===i){const u=Ws(t);for(;i<=r-o;o+=i)this.process(u,o);continue}n.set(t.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===i&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Vr(this),yu(t,this),this.finished=!0;const{buffer:e,view:n,blockLen:i,isLE:r}=this;let{pos:o}=this;e[o++]=128,sr(this.buffer.subarray(o)),this.padOffset>i-o&&(this.process(n,0),o=0);for(let B=o;B<i;B++)e[B]=0;Su(n,i-8,BigInt(this.length*8),r),this.process(n,0);const a=Ws(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const g=u/4,x=this.get();if(g>x.length)throw new Error("_sha2: outputLen bigger than state");for(let B=0;B<g;B++)a.setUint32(4*B,x[B],r)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:n,length:i,finished:r,destroyed:o,pos:a}=this;return t.destroyed=o,t.finished=r,t.length=i,t.pos=a,i%e&&t.buffer.set(n),t}clone(){return this._cloneInto()}}const pn=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Be=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),Pr=BigInt(2**32-1),go=BigInt(32);function _u(s,t=!1){return t?{h:Number(s&Pr),l:Number(s>>go&Pr)}:{h:Number(s>>go&Pr)|0,l:Number(s&Pr)|0}}function ku(s,t=!1){const e=s.length;let n=new Uint32Array(e),i=new Uint32Array(e);for(let r=0;r<e;r++){const{h:o,l:a}=_u(s[r],t);[n[r],i[r]]=[o,a]}return[n,i]}const mo=(s,t,e)=>s>>>e,yo=(s,t,e)=>s<<32-e|t>>>e,Hn=(s,t,e)=>s>>>e|t<<32-e,Wn=(s,t,e)=>s<<32-e|t>>>e,Fr=(s,t,e)=>s<<64-e|t>>>e-32,Or=(s,t,e)=>s>>>e-32|t<<64-e;function cn(s,t,e,n){const i=(t>>>0)+(n>>>0);return{h:s+e+(i/2**32|0)|0,l:i|0}}const Eu=(s,t,e)=>(s>>>0)+(t>>>0)+(e>>>0),Bu=(s,t,e,n)=>t+e+n+(s/2**32|0)|0,Au=(s,t,e,n)=>(s>>>0)+(t>>>0)+(e>>>0)+(n>>>0),Iu=(s,t,e,n,i)=>t+e+n+i+(s/2**32|0)|0,Ru=(s,t,e,n,i)=>(s>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(i>>>0),Mu=(s,t,e,n,i,r)=>t+e+n+i+r+(s/2**32|0)|0,Tu=Uint32Array.from([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]),gn=new Uint32Array(64);class Cu extends ia{constructor(t=32){super(64,t,8,!1),this.A=pn[0]|0,this.B=pn[1]|0,this.C=pn[2]|0,this.D=pn[3]|0,this.E=pn[4]|0,this.F=pn[5]|0,this.G=pn[6]|0,this.H=pn[7]|0}get(){const{A:t,B:e,C:n,D:i,E:r,F:o,G:a,H:u}=this;return[t,e,n,i,r,o,a,u]}set(t,e,n,i,r,o,a,u){this.A=t|0,this.B=e|0,this.C=n|0,this.D=i|0,this.E=r|0,this.F=o|0,this.G=a|0,this.H=u|0}process(t,e){for(let B=0;B<16;B++,e+=4)gn[B]=t.getUint32(e,!1);for(let B=16;B<64;B++){const I=gn[B-15],v=gn[B-2],E=Je(I,7)^Je(I,18)^I>>>3,R=Je(v,17)^Je(v,19)^v>>>10;gn[B]=R+gn[B-7]+E+gn[B-16]|0}let{A:n,B:i,C:r,D:o,E:a,F:u,G:g,H:x}=this;for(let B=0;B<64;B++){const I=Je(a,6)^Je(a,11)^Je(a,25),v=x+I+vu(a,u,g)+Tu[B]+gn[B]|0,R=(Je(n,2)^Je(n,13)^Je(n,22))+xu(n,i,r)|0;x=g,g=u,u=a,a=o+v|0,o=r,r=i,i=n,n=v+R|0}n=n+this.A|0,i=i+this.B|0,r=r+this.C|0,o=o+this.D|0,a=a+this.E|0,u=u+this.F|0,g=g+this.G|0,x=x+this.H|0,this.set(n,i,r,o,a,u,g,x)}roundClean(){sr(gn)}destroy(){this.set(0,0,0,0,0,0,0,0),sr(this.buffer)}}const oa=ku(["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(s=>BigInt(s))),Lu=oa[0],Uu=oa[1],mn=new Uint32Array(80),yn=new Uint32Array(80);class Nu extends ia{constructor(t=64){super(128,t,16,!1),this.Ah=Be[0]|0,this.Al=Be[1]|0,this.Bh=Be[2]|0,this.Bl=Be[3]|0,this.Ch=Be[4]|0,this.Cl=Be[5]|0,this.Dh=Be[6]|0,this.Dl=Be[7]|0,this.Eh=Be[8]|0,this.El=Be[9]|0,this.Fh=Be[10]|0,this.Fl=Be[11]|0,this.Gh=Be[12]|0,this.Gl=Be[13]|0,this.Hh=Be[14]|0,this.Hl=Be[15]|0}get(){const{Ah:t,Al:e,Bh:n,Bl:i,Ch:r,Cl:o,Dh:a,Dl:u,Eh:g,El:x,Fh:B,Fl:I,Gh:v,Gl:E,Hh:R,Hl:T}=this;return[t,e,n,i,r,o,a,u,g,x,B,I,v,E,R,T]}set(t,e,n,i,r,o,a,u,g,x,B,I,v,E,R,T){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=i|0,this.Ch=r|0,this.Cl=o|0,this.Dh=a|0,this.Dl=u|0,this.Eh=g|0,this.El=x|0,this.Fh=B|0,this.Fl=I|0,this.Gh=v|0,this.Gl=E|0,this.Hh=R|0,this.Hl=T|0}process(t,e){for(let D=0;D<16;D++,e+=4)mn[D]=t.getUint32(e),yn[D]=t.getUint32(e+=4);for(let D=16;D<80;D++){const X=mn[D-15]|0,nt=yn[D-15]|0,at=Hn(X,nt,1)^Hn(X,nt,8)^mo(X,nt,7),ht=Wn(X,nt,1)^Wn(X,nt,8)^yo(X,nt,7),ut=mn[D-2]|0,j=yn[D-2]|0,rt=Hn(ut,j,19)^Fr(ut,j,61)^mo(ut,j,6),Q=Wn(ut,j,19)^Or(ut,j,61)^yo(ut,j,6),et=Au(ht,Q,yn[D-7],yn[D-16]),y=Iu(et,at,rt,mn[D-7],mn[D-16]);mn[D]=y|0,yn[D]=et|0}let{Ah:n,Al:i,Bh:r,Bl:o,Ch:a,Cl:u,Dh:g,Dl:x,Eh:B,El:I,Fh:v,Fl:E,Gh:R,Gl:T,Hh:N,Hl:W}=this;for(let D=0;D<80;D++){const X=Hn(B,I,14)^Hn(B,I,18)^Fr(B,I,41),nt=Wn(B,I,14)^Wn(B,I,18)^Or(B,I,41),at=B&v^~B&R,ht=I&E^~I&T,ut=Ru(W,nt,ht,Uu[D],yn[D]),j=Mu(ut,N,X,at,Lu[D],mn[D]),rt=ut|0,Q=Hn(n,i,28)^Fr(n,i,34)^Fr(n,i,39),et=Wn(n,i,28)^Or(n,i,34)^Or(n,i,39),y=n&r^n&a^r&a,c=i&o^i&u^o&u;N=R|0,W=T|0,R=v|0,T=E|0,v=B|0,E=I|0,{h:B,l:I}=cn(g|0,x|0,j|0,rt|0),g=a|0,x=u|0,a=r|0,u=o|0,r=n|0,o=i|0;const d=Eu(rt,et,c);n=Bu(d,j,Q,y),i=d|0}({h:n,l:i}=cn(this.Ah|0,this.Al|0,n|0,i|0)),{h:r,l:o}=cn(this.Bh|0,this.Bl|0,r|0,o|0),{h:a,l:u}=cn(this.Ch|0,this.Cl|0,a|0,u|0),{h:g,l:x}=cn(this.Dh|0,this.Dl|0,g|0,x|0),{h:B,l:I}=cn(this.Eh|0,this.El|0,B|0,I|0),{h:v,l:E}=cn(this.Fh|0,this.Fl|0,v|0,E|0),{h:R,l:T}=cn(this.Gh|0,this.Gl|0,R|0,T|0),{h:N,l:W}=cn(this.Hh|0,this.Hl|0,N|0,W|0),this.set(n,i,r,o,a,u,g,x,B,I,v,E,R,T,N,W)}roundClean(){sr(mn,yn)}destroy(){sr(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const aa=sa(()=>new Cu),Pu=sa(()=>new Nu);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Li=BigInt(0),pi=BigInt(1);function Ln(s,t=""){if(typeof s!="boolean"){const e=t&&`"${t}"`;throw new Error(e+"expected boolean, got type="+typeof s)}return s}function Ge(s,t,e=""){const n=Rr(s),i=s==null?void 0:s.length,r=t!==void 0;if(!n||r&&i!==t){const o=e&&`"${e}" `,a=r?` of length ${t}`:"",u=n?`length=${i}`:`type=${typeof s}`;throw new Error(o+"expected Uint8Array"+a+", got "+u)}return s}function $r(s){const t=s.toString(16);return t.length&1?"0"+t:t}function ca(s){if(typeof s!="string")throw new Error("hex string expected, got "+typeof s);return s===""?Li:BigInt("0x"+s)}function fs(s){return ca(Cn(s))}function xr(s){return Un(s),ca(Cn(Uint8Array.from(s).reverse()))}function Ui(s,t){return Gr(s.toString(16).padStart(t*2,"0"))}function ua(s,t){return Ui(s,t).reverse()}function Xt(s,t,e){let n;if(typeof t=="string")try{n=Gr(t)}catch(r){throw new Error(s+" must be hex string or Uint8Array, cause: "+r)}else if(Rr(t))n=Uint8Array.from(t);else throw new Error(s+" must be hex string or Uint8Array");const i=n.length;if(typeof e=="number"&&i!==e)throw new Error(s+" of length "+e+" expected, got "+i);return n}function wo(s){return Uint8Array.from(s)}const js=s=>typeof s=="bigint"&&Li<=s;function Fu(s,t,e){return js(s)&&js(t)&&js(e)&&t<=s&&s<e}function gi(s,t,e,n){if(!Fu(t,e,n))throw new Error("expected valid "+s+": "+e+" <= n < "+n+", got "+t)}function la(s){let t;for(t=0;s>Li;s>>=pi,t+=1);return t}const Mr=s=>(pi<<BigInt(s))-pi;function Ou(s,t,e){if(typeof s!="number"||s<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");const n=v=>new Uint8Array(v),i=v=>Uint8Array.of(v);let r=n(s),o=n(s),a=0;const u=()=>{r.fill(1),o.fill(0),a=0},g=(...v)=>e(o,r,...v),x=(v=n(0))=>{o=g(i(0),v),r=g(),v.length!==0&&(o=g(i(1),v),r=g())},B=()=>{if(a++>=1e3)throw new Error("drbg: tried 1000 values");let v=0;const E=[];for(;v<t;){r=g();const R=r.slice();E.push(R),v+=r.length}return tn(...E)};return(v,E)=>{u(),x(v);let R;for(;!(R=E(B()));)x();return u(),R}}function Tr(s,t,e={}){if(!s||typeof s!="object")throw new Error("expected valid options object");function n(i,r,o){const a=s[i];if(o&&a===void 0)return;const u=typeof a;if(u!==r||a===null)throw new Error(`param "${i}" is invalid: expected ${r}, got ${u}`)}Object.entries(t).forEach(([i,r])=>n(i,r,!1)),Object.entries(e).forEach(([i,r])=>n(i,r,!0))}function Zr(s){const t=new WeakMap;return(e,...n)=>{const i=t.get(e);if(i!==void 0)return i;const r=s(e,...n);return t.set(e,r),r}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Le=BigInt(0),Ee=BigInt(1),Rn=BigInt(2),fa=BigInt(3),ha=BigInt(4),da=BigInt(5),$u=BigInt(7),pa=BigInt(8),qu=BigInt(9),ga=BigInt(16);function Se(s,t){const e=s%t;return e>=Le?e:t+e}function Yt(s,t,e){let n=s;for(;t-- >Le;)n*=n,n%=e;return n}function bo(s,t){if(s===Le)throw new Error("invert: expected non-zero number");if(t<=Le)throw new Error("invert: expected positive modulus, got "+t);let e=Se(s,t),n=t,i=Le,r=Ee;for(;e!==Le;){const a=n/e,u=n%e,g=i-r*a;n=e,e=u,i=r,r=g}if(n!==Ee)throw new Error("invert: does not exist");return Se(i,t)}function Ni(s,t,e){if(!s.eql(s.sqr(t),e))throw new Error("Cannot find square root")}function ma(s,t){const e=(s.ORDER+Ee)/ha,n=s.pow(t,e);return Ni(s,n,t),n}function Ku(s,t){const e=(s.ORDER-da)/pa,n=s.mul(t,Rn),i=s.pow(n,e),r=s.mul(t,i),o=s.mul(s.mul(r,Rn),i),a=s.mul(r,s.sub(o,s.ONE));return Ni(s,a,t),a}function Du(s){const t=Nn(s),e=ya(s),n=e(t,t.neg(t.ONE)),i=e(t,n),r=e(t,t.neg(n)),o=(s+$u)/ga;return(a,u)=>{let g=a.pow(u,o),x=a.mul(g,n);const B=a.mul(g,i),I=a.mul(g,r),v=a.eql(a.sqr(x),u),E=a.eql(a.sqr(B),u);g=a.cmov(g,x,v),x=a.cmov(I,B,E);const R=a.eql(a.sqr(x),u),T=a.cmov(g,x,R);return Ni(a,T,u),T}}function ya(s){if(s<fa)throw new Error("sqrt is not defined for small field");let t=s-Ee,e=0;for(;t%Rn===Le;)t/=Rn,e++;let n=Rn;const i=Nn(s);for(;So(i,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(e===1)return ma;let r=i.pow(n,t);const o=(t+Ee)/Rn;return function(u,g){if(u.is0(g))return g;if(So(u,g)!==1)throw new Error("Cannot find square root");let x=e,B=u.mul(u.ONE,r),I=u.pow(g,t),v=u.pow(g,o);for(;!u.eql(I,u.ONE);){if(u.is0(I))return u.ZERO;let E=1,R=u.sqr(I);for(;!u.eql(R,u.ONE);)if(E++,R=u.sqr(R),E===x)throw new Error("Cannot find square root");const T=Ee<<BigInt(x-E-1),N=u.pow(B,T);x=E,B=u.sqr(N),I=u.mul(I,B),v=u.mul(v,N)}return v}}function zu(s){return s%ha===fa?ma:s%pa===da?Ku:s%ga===qu?Du(s):ya(s)}const Hu=(s,t)=>(Se(s,t)&Ee)===Ee,Wu=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function ju(s){const t={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},e=Wu.reduce((n,i)=>(n[i]="function",n),t);return Tr(s,e),s}function Vu(s,t,e){if(e<Le)throw new Error("invalid exponent, negatives unsupported");if(e===Le)return s.ONE;if(e===Ee)return t;let n=s.ONE,i=t;for(;e>Le;)e&Ee&&(n=s.mul(n,i)),i=s.sqr(i),e>>=Ee;return n}function wa(s,t,e=!1){const n=new Array(t.length).fill(e?s.ZERO:void 0),i=t.reduce((o,a,u)=>s.is0(a)?o:(n[u]=o,s.mul(o,a)),s.ONE),r=s.inv(i);return t.reduceRight((o,a,u)=>s.is0(a)?o:(n[u]=s.mul(o,n[u]),s.mul(o,a)),r),n}function So(s,t){const e=(s.ORDER-Ee)/Rn,n=s.pow(t,e),i=s.eql(n,s.ONE),r=s.eql(n,s.ZERO),o=s.eql(n,s.neg(s.ONE));if(!i&&!r&&!o)throw new Error("invalid Legendre symbol result");return i?1:r?0:-1}function ba(s,t){t!==void 0&&di(t);const e=t!==void 0?t:s.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function Nn(s,t,e=!1,n={}){if(s<=Le)throw new Error("invalid field: expected ORDER > 0, got "+s);let i,r,o=!1,a;if(typeof t=="object"&&t!=null){if(n.sqrt||e)throw new Error("cannot specify opts in two arguments");const I=t;I.BITS&&(i=I.BITS),I.sqrt&&(r=I.sqrt),typeof I.isLE=="boolean"&&(e=I.isLE),typeof I.modFromBytes=="boolean"&&(o=I.modFromBytes),a=I.allowedLengths}else typeof t=="number"&&(i=t),n.sqrt&&(r=n.sqrt);const{nBitLength:u,nByteLength:g}=ba(s,i);if(g>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let x;const B=Object.freeze({ORDER:s,isLE:e,BITS:u,BYTES:g,MASK:Mr(u),ZERO:Le,ONE:Ee,allowedLengths:a,create:I=>Se(I,s),isValid:I=>{if(typeof I!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof I);return Le<=I&&I<s},is0:I=>I===Le,isValidNot0:I=>!B.is0(I)&&B.isValid(I),isOdd:I=>(I&Ee)===Ee,neg:I=>Se(-I,s),eql:(I,v)=>I===v,sqr:I=>Se(I*I,s),add:(I,v)=>Se(I+v,s),sub:(I,v)=>Se(I-v,s),mul:(I,v)=>Se(I*v,s),pow:(I,v)=>Vu(B,I,v),div:(I,v)=>Se(I*bo(v,s),s),sqrN:I=>I*I,addN:(I,v)=>I+v,subN:(I,v)=>I-v,mulN:(I,v)=>I*v,inv:I=>bo(I,s),sqrt:r||(I=>(x||(x=zu(s)),x(B,I))),toBytes:I=>e?ua(I,g):Ui(I,g),fromBytes:(I,v=!0)=>{if(a){if(!a.includes(I.length)||I.length>g)throw new Error("Field.fromBytes: expected "+a+" bytes, got "+I.length);const R=new Uint8Array(g);R.set(I,e?0:R.length-I.length),I=R}if(I.length!==g)throw new Error("Field.fromBytes: expected "+g+" bytes, got "+I.length);let E=e?xr(I):fs(I);if(o&&(E=Se(E,s)),!v&&!B.isValid(E))throw new Error("invalid field element: outside of range 0..ORDER");return E},invertBatch:I=>wa(B,I),cmov:(I,v,E)=>E?v:I});return Object.freeze(B)}function Sa(s){if(typeof s!="bigint")throw new Error("field order must be bigint");const t=s.toString(2).length;return Math.ceil(t/8)}function va(s){const t=Sa(s);return t+Math.ceil(t/2)}function Gu(s,t,e=!1){const n=s.length,i=Sa(t),r=va(t);if(n<16||n<r||n>1024)throw new Error("expected "+r+"-1024 bytes of input, got "+n);const o=e?xr(s):fs(s),a=Se(o,t-Ee)+Ee;return e?ua(a,i):Ui(a,i)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ir=BigInt(0),Mn=BigInt(1);function Yr(s,t){const e=t.negate();return s?e:t}function Tn(s,t){const e=wa(s.Fp,t.map(n=>n.Z));return t.map((n,i)=>s.fromAffine(n.toAffine(e[i])))}function xa(s,t){if(!Number.isSafeInteger(s)||s<=0||s>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+s)}function Vs(s,t){xa(s,t);const e=Math.ceil(t/s)+1,n=2**(s-1),i=2**s,r=Mr(s),o=BigInt(s);return{windows:e,windowSize:n,mask:r,maxNumber:i,shiftBy:o}}function vo(s,t,e){const{windowSize:n,mask:i,maxNumber:r,shiftBy:o}=e;let a=Number(s&i),u=s>>o;a>n&&(a-=r,u+=Mn);const g=t*n,x=g+Math.abs(a)-1,B=a===0,I=a<0,v=t%2!==0;return{nextN:u,offset:x,isZero:B,isNeg:I,isNegF:v,offsetF:g}}function Zu(s,t){if(!Array.isArray(s))throw new Error("array expected");s.forEach((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)})}function Yu(s,t){if(!Array.isArray(s))throw new Error("array of scalars expected");s.forEach((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)})}const Gs=new WeakMap,_a=new WeakMap;function Zs(s){return _a.get(s)||1}function xo(s){if(s!==ir)throw new Error("invalid wNAF")}class ka{constructor(t,e){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=e}_unsafeLadder(t,e,n=this.ZERO){let i=t;for(;e>ir;)e&Mn&&(n=n.add(i)),i=i.double(),e>>=Mn;return n}precomputeWindow(t,e){const{windows:n,windowSize:i}=Vs(e,this.bits),r=[];let o=t,a=o;for(let u=0;u<n;u++){a=o,r.push(a);for(let g=1;g<i;g++)a=a.add(o),r.push(a);o=a.double()}return r}wNAF(t,e,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let i=this.ZERO,r=this.BASE;const o=Vs(t,this.bits);for(let a=0;a<o.windows;a++){const{nextN:u,offset:g,isZero:x,isNeg:B,isNegF:I,offsetF:v}=vo(n,a,o);n=u,x?r=r.add(Yr(I,e[v])):i=i.add(Yr(B,e[g]))}return xo(n),{p:i,f:r}}wNAFUnsafe(t,e,n,i=this.ZERO){const r=Vs(t,this.bits);for(let o=0;o<r.windows&&n!==ir;o++){const{nextN:a,offset:u,isZero:g,isNeg:x}=vo(n,o,r);if(n=a,!g){const B=e[u];i=i.add(x?B.negate():B)}}return xo(n),i}getPrecomputes(t,e,n){let i=Gs.get(e);return i||(i=this.precomputeWindow(e,t),t!==1&&(typeof n=="function"&&(i=n(i)),Gs.set(e,i))),i}cached(t,e,n){const i=Zs(t);return this.wNAF(i,this.getPrecomputes(i,t,n),e)}unsafe(t,e,n,i){const r=Zs(t);return r===1?this._unsafeLadder(t,e,i):this.wNAFUnsafe(r,this.getPrecomputes(r,t,n),e,i)}createCache(t,e){xa(e,this.bits),_a.set(t,e),Gs.delete(t)}hasCache(t){return Zs(t)!==1}}function Xu(s,t,e,n){let i=t,r=s.ZERO,o=s.ZERO;for(;e>ir||n>ir;)e&Mn&&(r=r.add(i)),n&Mn&&(o=o.add(i)),i=i.double(),e>>=Mn,n>>=Mn;return{p1:r,p2:o}}function Ea(s,t,e,n){Zu(e,s),Yu(n,t);const i=e.length,r=n.length;if(i!==r)throw new Error("arrays of points and scalars must have equal length");const o=s.ZERO,a=la(BigInt(i));let u=1;a>12?u=a-3:a>4?u=a-2:a>0&&(u=2);const g=Mr(u),x=new Array(Number(g)+1).fill(o),B=Math.floor((t.BITS-1)/u)*u;let I=o;for(let v=B;v>=0;v-=u){x.fill(o);for(let R=0;R<r;R++){const T=n[R],N=Number(T>>BigInt(v)&g);x[N]=x[N].add(e[R])}let E=o;for(let R=x.length-1,T=o;R>0;R--)T=T.add(x[R]),E=E.add(T);if(I=I.add(E),v!==0)for(let R=0;R<u;R++)I=I.double()}return I}function _o(s,t,e){if(t){if(t.ORDER!==s)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return ju(t),t}else return Nn(s,{isLE:e})}function Ba(s,t,e={},n){if(n===void 0&&(n=s==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${s} CURVE object`);for(const u of["p","n","h"]){const g=t[u];if(!(typeof g=="bigint"&&g>ir))throw new Error(`CURVE.${u} must be positive bigint`)}const i=_o(t.p,e.Fp,n),r=_o(t.n,e.Fn,n),a=["Gx","Gy","a",s==="weierstrass"?"b":"d"];for(const u of a)if(!i.isValid(t[u]))throw new Error(`CURVE.${u} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:i,Fn:r}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const wn=BigInt(0),xe=BigInt(1),Ys=BigInt(2),Ju=BigInt(8);function Qu(s,t,e,n){const i=s.sqr(e),r=s.sqr(n),o=s.add(s.mul(t.a,i),r),a=s.add(s.ONE,s.mul(t.d,s.mul(i,r)));return s.eql(o,a)}function tl(s,t={}){const e=Ba("edwards",s,t,t.FpFnLE),{Fp:n,Fn:i}=e;let r=e.CURVE;const{h:o}=r;Tr(t,{},{uvRatio:"function"});const a=Ys<<BigInt(i.BYTES*8)-xe,u=T=>n.create(T),g=t.uvRatio||((T,N)=>{try{return{isValid:!0,value:n.sqrt(n.div(T,N))}}catch{return{isValid:!1,value:wn}}});if(!Qu(n,r,r.Gx,r.Gy))throw new Error("bad curve params: generator point");function x(T,N,W=!1){const D=W?xe:wn;return gi("coordinate "+T,N,D,a),N}function B(T){if(!(T instanceof E))throw new Error("ExtendedPoint expected")}const I=Zr((T,N)=>{const{X:W,Y:D,Z:X}=T,nt=T.is0();N==null&&(N=nt?Ju:n.inv(X));const at=u(W*N),ht=u(D*N),ut=n.mul(X,N);if(nt)return{x:wn,y:xe};if(ut!==xe)throw new Error("invZ was invalid");return{x:at,y:ht}}),v=Zr(T=>{const{a:N,d:W}=r;if(T.is0())throw new Error("bad point: ZERO");const{X:D,Y:X,Z:nt,T:at}=T,ht=u(D*D),ut=u(X*X),j=u(nt*nt),rt=u(j*j),Q=u(ht*N),et=u(j*u(Q+ut)),y=u(rt+u(W*u(ht*ut)));if(et!==y)throw new Error("bad point: equation left != right (1)");const c=u(D*X),d=u(nt*at);if(c!==d)throw new Error("bad point: equation left != right (2)");return!0});class E{constructor(N,W,D,X){this.X=x("x",N),this.Y=x("y",W),this.Z=x("z",D,!0),this.T=x("t",X),Object.freeze(this)}static CURVE(){return r}static fromAffine(N){if(N instanceof E)throw new Error("extended point not allowed");const{x:W,y:D}=N||{};return x("x",W),x("y",D),new E(W,D,xe,u(W*D))}static fromBytes(N,W=!1){const D=n.BYTES,{a:X,d:nt}=r;N=wo(Ge(N,D,"point")),Ln(W,"zip215");const at=wo(N),ht=N[D-1];at[D-1]=ht&-129;const ut=xr(at),j=W?a:n.ORDER;gi("point.y",ut,wn,j);const rt=u(ut*ut),Q=u(rt-xe),et=u(nt*rt-X);let{isValid:y,value:c}=g(Q,et);if(!y)throw new Error("bad point: invalid y coordinate");const d=(c&xe)===xe,p=(ht&128)!==0;if(!W&&c===wn&&p)throw new Error("bad point: x=0 and x_0=1");return p!==d&&(c=u(-c)),E.fromAffine({x:c,y:ut})}static fromHex(N,W=!1){return E.fromBytes(Xt("point",N),W)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(N=8,W=!0){return R.createCache(this,N),W||this.multiply(Ys),this}assertValidity(){v(this)}equals(N){B(N);const{X:W,Y:D,Z:X}=this,{X:nt,Y:at,Z:ht}=N,ut=u(W*ht),j=u(nt*X),rt=u(D*ht),Q=u(at*X);return ut===j&&rt===Q}is0(){return this.equals(E.ZERO)}negate(){return new E(u(-this.X),this.Y,this.Z,u(-this.T))}double(){const{a:N}=r,{X:W,Y:D,Z:X}=this,nt=u(W*W),at=u(D*D),ht=u(Ys*u(X*X)),ut=u(N*nt),j=W+D,rt=u(u(j*j)-nt-at),Q=ut+at,et=Q-ht,y=ut-at,c=u(rt*et),d=u(Q*y),p=u(rt*y),S=u(et*Q);return new E(c,d,S,p)}add(N){B(N);const{a:W,d:D}=r,{X,Y:nt,Z:at,T:ht}=this,{X:ut,Y:j,Z:rt,T:Q}=N,et=u(X*ut),y=u(nt*j),c=u(ht*D*Q),d=u(at*rt),p=u((X+nt)*(ut+j)-et-y),S=d-c,k=d+c,M=u(y-W*et),C=u(p*S),w=u(k*M),f=u(p*M),A=u(S*k);return new E(C,w,A,f)}subtract(N){return this.add(N.negate())}multiply(N){if(!i.isValidNot0(N))throw new Error("invalid scalar: expected 1 <= sc < curve.n");const{p:W,f:D}=R.cached(this,N,X=>Tn(E,X));return Tn(E,[W,D])[0]}multiplyUnsafe(N,W=E.ZERO){if(!i.isValid(N))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return N===wn?E.ZERO:this.is0()||N===xe?this:R.unsafe(this,N,D=>Tn(E,D),W)}isSmallOrder(){return this.multiplyUnsafe(o).is0()}isTorsionFree(){return R.unsafe(this,r.n).is0()}toAffine(N){return I(this,N)}clearCofactor(){return o===xe?this:this.multiplyUnsafe(o)}toBytes(){const{x:N,y:W}=this.toAffine(),D=n.toBytes(W);return D[D.length-1]|=N&xe?128:0,D}toHex(){return Cn(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get ex(){return this.X}get ey(){return this.Y}get ez(){return this.Z}get et(){return this.T}static normalizeZ(N){return Tn(E,N)}static msm(N,W){return Ea(E,i,N,W)}_setWindowSize(N){this.precompute(N)}toRawBytes(){return this.toBytes()}}E.BASE=new E(r.Gx,r.Gy,xe,u(r.Gx*r.Gy)),E.ZERO=new E(wn,xe,xe,wn),E.Fp=n,E.Fn=i;const R=new ka(E,i.BITS);return E.BASE.precompute(8),E}function el(s,t,e={}){if(typeof t!="function")throw new Error('"hash" function param is required');Tr(e,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});const{prehash:n}=e,{BASE:i,Fp:r,Fn:o}=s,a=e.randomBytes||Ci,u=e.adjustScalarBytes||(j=>j),g=e.domain||((j,rt,Q)=>{if(Ln(Q,"phflag"),rt.length||Q)throw new Error("Contexts/pre-hash are not supported");return j});function x(j){return o.create(xr(j))}function B(j){const rt=D.secretKey;j=Xt("private key",j,rt);const Q=Xt("hashed private key",t(j),2*rt),et=u(Q.slice(0,rt)),y=Q.slice(rt,2*rt),c=x(et);return{head:et,prefix:y,scalar:c}}function I(j){const{head:rt,prefix:Q,scalar:et}=B(j),y=i.multiply(et),c=y.toBytes();return{head:rt,prefix:Q,scalar:et,point:y,pointBytes:c}}function v(j){return I(j).pointBytes}function E(j=Uint8Array.of(),...rt){const Q=tn(...rt);return x(t(g(Q,Xt("context",j),!!n)))}function R(j,rt,Q={}){j=Xt("message",j),n&&(j=n(j));const{prefix:et,scalar:y,pointBytes:c}=I(rt),d=E(Q.context,et,j),p=i.multiply(d).toBytes(),S=E(Q.context,p,c,j),k=o.create(d+S*y);if(!o.isValid(k))throw new Error("sign failed: invalid s");const M=tn(p,o.toBytes(k));return Ge(M,D.signature,"result")}const T={zip215:!0};function N(j,rt,Q,et=T){const{context:y,zip215:c}=et,d=D.signature;j=Xt("signature",j,d),rt=Xt("message",rt),Q=Xt("publicKey",Q,D.publicKey),c!==void 0&&Ln(c,"zip215"),n&&(rt=n(rt));const p=d/2,S=j.subarray(0,p),k=xr(j.subarray(p,d));let M,C,w;try{M=s.fromBytes(Q,c),C=s.fromBytes(S,c),w=i.multiplyUnsafe(k)}catch{return!1}if(!c&&M.isSmallOrder())return!1;const f=E(y,C.toBytes(),M.toBytes(),rt);return C.add(M.multiplyUnsafe(f)).subtract(w).clearCofactor().is0()}const W=r.BYTES,D={secretKey:W,publicKey:W,signature:2*W,seed:W};function X(j=a(D.seed)){return Ge(j,D.seed,"seed")}function nt(j){const rt=ut.randomSecretKey(j);return{secretKey:rt,publicKey:v(rt)}}function at(j){return Rr(j)&&j.length===o.BYTES}function ht(j,rt){try{return!!s.fromBytes(j,rt)}catch{return!1}}const ut={getExtendedPublicKey:I,randomSecretKey:X,isValidSecretKey:at,isValidPublicKey:ht,toMontgomery(j){const{y:rt}=s.fromBytes(j),Q=D.publicKey,et=Q===32;if(!et&&Q!==57)throw new Error("only defined for 25519 and 448");const y=et?r.div(xe+rt,xe-rt):r.div(rt-xe,rt+xe);return r.toBytes(y)},toMontgomerySecret(j){const rt=D.secretKey;Ge(j,rt);const Q=t(j.subarray(0,rt));return u(Q).subarray(0,rt)},randomPrivateKey:X,precompute(j=8,rt=s.BASE){return rt.precompute(j,!1)}};return Object.freeze({keygen:nt,getPublicKey:v,sign:R,verify:N,utils:ut,Point:s,lengths:D})}function nl(s){const t={a:s.a,d:s.d,p:s.Fp.ORDER,n:s.n,h:s.h,Gx:s.Gx,Gy:s.Gy},e=s.Fp,n=Nn(t.n,s.nBitLength,!0),i={Fp:e,Fn:n,uvRatio:s.uvRatio},r={randomBytes:s.randomBytes,adjustScalarBytes:s.adjustScalarBytes,domain:s.domain,prehash:s.prehash,mapToCurve:s.mapToCurve};return{CURVE:t,curveOpts:i,hash:s.hash,eddsaOpts:r}}function rl(s,t){const e=t.Point;return Object.assign({},t,{ExtendedPoint:e,CURVE:s,nBitLength:e.Fn.BITS,nByteLength:e.Fn.BYTES})}function sl(s){const{CURVE:t,curveOpts:e,hash:n,eddsaOpts:i}=nl(s),r=tl(t,e),o=el(r,n,i);return rl(s,o)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const il=BigInt(1),ko=BigInt(2);BigInt(3);const ol=BigInt(5),al=BigInt(8),Pi=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),Aa={p:Pi,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:al,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function cl(s){const t=BigInt(10),e=BigInt(20),n=BigInt(40),i=BigInt(80),r=Pi,a=s*s%r*s%r,u=Yt(a,ko,r)*a%r,g=Yt(u,il,r)*s%r,x=Yt(g,ol,r)*g%r,B=Yt(x,t,r)*x%r,I=Yt(B,e,r)*B%r,v=Yt(I,n,r)*I%r,E=Yt(v,i,r)*v%r,R=Yt(E,i,r)*v%r,T=Yt(R,t,r)*x%r;return{pow_p_5_8:Yt(T,ko,r)*s%r,b2:a}}function ul(s){return s[0]&=248,s[31]&=127,s[31]|=64,s}const Eo=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function ll(s,t){const e=Pi,n=Se(t*t*t,e),i=Se(n*n*t,e),r=cl(s*i).pow_p_5_8;let o=Se(s*n*r,e);const a=Se(t*o*o,e),u=o,g=Se(o*Eo,e),x=a===s,B=a===Se(-s,e),I=a===Se(-s*Eo,e);return x&&(o=u),(B||I)&&(o=g),Hu(o,e)&&(o=Se(-o,e)),{isValid:x||B,value:o}}const fl=Nn(Aa.p,{isLE:!0}),hl={...Aa,Fp:fl,hash:Pu,adjustScalarBytes:ul,uvRatio:ll},en=sl(hl);var Fi={exports:{}};Fi.exports;(function(s){(function(t,e){function n(y,c){if(!y)throw new Error(c||"Assertion failed")}function i(y,c){y.super_=c;var d=function(){};d.prototype=c.prototype,y.prototype=new d,y.prototype.constructor=y}function r(y,c,d){if(r.isBN(y))return y;this.negative=0,this.words=null,this.length=0,this.red=null,y!==null&&((c==="le"||c==="be")&&(d=c,c=10),this._init(y||0,c||10,d||"be"))}typeof t=="object"?t.exports=r:e.BN=r,r.BN=r,r.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=cu.Buffer}catch{}r.isBN=function(c){return c instanceof r?!0:c!==null&&typeof c=="object"&&c.constructor.wordSize===r.wordSize&&Array.isArray(c.words)},r.max=function(c,d){return c.cmp(d)>0?c:d},r.min=function(c,d){return c.cmp(d)<0?c:d},r.prototype._init=function(c,d,p){if(typeof c=="number")return this._initNumber(c,d,p);if(typeof c=="object")return this._initArray(c,d,p);d==="hex"&&(d=16),n(d===(d|0)&&d>=2&&d<=36),c=c.toString().replace(/\s+/g,"");var S=0;c[0]==="-"&&(S++,this.negative=1),S<c.length&&(d===16?this._parseHex(c,S,p):(this._parseBase(c,d,S),p==="le"&&this._initArray(this.toArray(),d,p)))},r.prototype._initNumber=function(c,d,p){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):(n(c<9007199254740992),this.words=[c&67108863,c/67108864&67108863,1],this.length=3),p==="le"&&this._initArray(this.toArray(),d,p)},r.prototype._initArray=function(c,d,p){if(n(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 S=0;S<this.length;S++)this.words[S]=0;var k,M,C=0;if(p==="be")for(S=c.length-1,k=0;S>=0;S-=3)M=c[S]|c[S-1]<<8|c[S-2]<<16,this.words[k]|=M<<C&67108863,this.words[k+1]=M>>>26-C&67108863,C+=24,C>=26&&(C-=26,k++);else if(p==="le")for(S=0,k=0;S<c.length;S+=3)M=c[S]|c[S+1]<<8|c[S+2]<<16,this.words[k]|=M<<C&67108863,this.words[k+1]=M>>>26-C&67108863,C+=24,C>=26&&(C-=26,k++);return this._strip()};function a(y,c){var d=y.charCodeAt(c);if(d>=48&&d<=57)return d-48;if(d>=65&&d<=70)return d-55;if(d>=97&&d<=102)return d-87;n(!1,"Invalid character in "+y)}function u(y,c,d){var p=a(y,d);return d-1>=c&&(p|=a(y,d-1)<<4),p}r.prototype._parseHex=function(c,d,p){this.length=Math.ceil((c.length-d)/6),this.words=new Array(this.length);for(var S=0;S<this.length;S++)this.words[S]=0;var k=0,M=0,C;if(p==="be")for(S=c.length-1;S>=d;S-=2)C=u(c,d,S)<<k,this.words[M]|=C&67108863,k>=18?(k-=18,M+=1,this.words[M]|=C>>>26):k+=8;else{var w=c.length-d;for(S=w%2===0?d+1:d;S<c.length;S+=2)C=u(c,d,S)<<k,this.words[M]|=C&67108863,k>=18?(k-=18,M+=1,this.words[M]|=C>>>26):k+=8}this._strip()};function g(y,c,d,p){for(var S=0,k=0,M=Math.min(y.length,d),C=c;C<M;C++){var w=y.charCodeAt(C)-48;S*=p,w>=49?k=w-49+10:w>=17?k=w-17+10:k=w,n(w>=0&&k<p,"Invalid character"),S+=k}return S}r.prototype._parseBase=function(c,d,p){this.words=[0],this.length=1;for(var S=0,k=1;k<=67108863;k*=d)S++;S--,k=k/d|0;for(var M=c.length-p,C=M%S,w=Math.min(M,M-C)+p,f=0,A=p;A<w;A+=S)f=g(c,A,A+S,d),this.imuln(k),this.words[0]+f<67108864?this.words[0]+=f:this._iaddn(f);if(C!==0){var J=1;for(f=g(c,A,c.length,d),A=0;A<C;A++)J*=d;this.imuln(J),this.words[0]+f<67108864?this.words[0]+=f:this._iaddn(f)}this._strip()},r.prototype.copy=function(c){c.words=new Array(this.length);for(var d=0;d<this.length;d++)c.words[d]=this.words[d];c.length=this.length,c.negative=this.negative,c.red=this.red};function x(y,c){y.words=c.words,y.length=c.length,y.negative=c.negative,y.red=c.red}if(r.prototype._move=function(c){x(c,this)},r.prototype.clone=function(){var c=new r(null);return this.copy(c),c},r.prototype._expand=function(c){for(;this.length<c;)this.words[this.length++]=0;return this},r.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},r.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{r.prototype[Symbol.for("nodejs.util.inspect.custom")]=B}catch{r.prototype.inspect=B}else r.prototype.inspect=B;function B(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var I=["","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"],v=[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],E=[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];r.prototype.toString=function(c,d){c=c||10,d=d|0||1;var p;if(c===16||c==="hex"){p="";for(var S=0,k=0,M=0;M<this.length;M++){var C=this.words[M],w=((C<<S|k)&16777215).toString(16);k=C>>>24-S&16777215,S+=2,S>=26&&(S-=26,M--),k!==0||M!==this.length-1?p=I[6-w.length]+w+p:p=w+p}for(k!==0&&(p=k.toString(16)+p);p.length%d!==0;)p="0"+p;return this.negative!==0&&(p="-"+p),p}if(c===(c|0)&&c>=2&&c<=36){var f=v[c],A=E[c];p="";var J=this.clone();for(J.negative=0;!J.isZero();){var Z=J.modrn(A).toString(c);J=J.idivn(A),J.isZero()?p=Z+p:p=I[f-Z.length]+Z+p}for(this.isZero()&&(p="0"+p);p.length%d!==0;)p="0"+p;return this.negative!==0&&(p="-"+p),p}n(!1,"Base should be between 2 and 36")},r.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&&n(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-c:c},r.prototype.toJSON=function(){return this.toString(16,2)},o&&(r.prototype.toBuffer=function(c,d){return this.toArrayLike(o,c,d)}),r.prototype.toArray=function(c,d){return this.toArrayLike(Array,c,d)};var R=function(c,d){return c.allocUnsafe?c.allocUnsafe(d):new c(d)};r.prototype.toArrayLike=function(c,d,p){this._strip();var S=this.byteLength(),k=p||Math.max(1,S);n(S<=k,"byte array longer than desired length"),n(k>0,"Requested array length <= 0");var M=R(c,k),C=d==="le"?"LE":"BE";return this["_toArrayLike"+C](M,S),M},r.prototype._toArrayLikeLE=function(c,d){for(var p=0,S=0,k=0,M=0;k<this.length;k++){var C=this.words[k]<<M|S;c[p++]=C&255,p<c.length&&(c[p++]=C>>8&255),p<c.length&&(c[p++]=C>>16&255),M===6?(p<c.length&&(c[p++]=C>>24&255),S=0,M=0):(S=C>>>24,M+=2)}if(p<c.length)for(c[p++]=S;p<c.length;)c[p++]=0},r.prototype._toArrayLikeBE=function(c,d){for(var p=c.length-1,S=0,k=0,M=0;k<this.length;k++){var C=this.words[k]<<M|S;c[p--]=C&255,p>=0&&(c[p--]=C>>8&255),p>=0&&(c[p--]=C>>16&255),M===6?(p>=0&&(c[p--]=C>>24&255),S=0,M=0):(S=C>>>24,M+=2)}if(p>=0)for(c[p--]=S;p>=0;)c[p--]=0},Math.clz32?r.prototype._countBits=function(c){return 32-Math.clz32(c)}:r.prototype._countBits=function(c){var d=c,p=0;return d>=4096&&(p+=13,d>>>=13),d>=64&&(p+=7,d>>>=7),d>=8&&(p+=4,d>>>=4),d>=2&&(p+=2,d>>>=2),p+d},r.prototype._zeroBits=function(c){if(c===0)return 26;var d=c,p=0;return d&8191||(p+=13,d>>>=13),d&127||(p+=7,d>>>=7),d&15||(p+=4,d>>>=4),d&3||(p+=2,d>>>=2),d&1||p++,p},r.prototype.bitLength=function(){var c=this.words[this.length-1],d=this._countBits(c);return(this.length-1)*26+d};function T(y){for(var c=new Array(y.bitLength()),d=0;d<c.length;d++){var p=d/26|0,S=d%26;c[d]=y.words[p]>>>S&1}return c}r.prototype.zeroBits=function(){if(this.isZero())return 0;for(var c=0,d=0;d<this.length;d++){var p=this._zeroBits(this.words[d]);if(c+=p,p!==26)break}return c},r.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},r.prototype.toTwos=function(c){return this.negative!==0?this.abs().inotn(c).iaddn(1):this.clone()},r.prototype.fromTwos=function(c){return this.testn(c-1)?this.notn(c).iaddn(1).ineg():this.clone()},r.prototype.isNeg=function(){return this.negative!==0},r.prototype.neg=function(){return this.clone().ineg()},r.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},r.prototype.iuor=function(c){for(;this.length<c.length;)this.words[this.length++]=0;for(var d=0;d<c.length;d++)this.words[d]=this.words[d]|c.words[d];return this._strip()},r.prototype.ior=function(c){return n((this.negative|c.negative)===0),this.iuor(c)},r.prototype.or=function(c){return this.length>c.length?this.clone().ior(c):c.clone().ior(this)},r.prototype.uor=function(c){return this.length>c.length?this.clone().iuor(c):c.clone().iuor(this)},r.prototype.iuand=function(c){var d;this.length>c.length?d=c:d=this;for(var p=0;p<d.length;p++)this.words[p]=this.words[p]&c.words[p];return this.length=d.length,this._strip()},r.prototype.iand=function(c){return n((this.negative|c.negative)===0),this.iuand(c)},r.prototype.and=function(c){return this.length>c.length?this.clone().iand(c):c.clone().iand(this)},r.prototype.uand=function(c){return this.length>c.length?this.clone().iuand(c):c.clone().iuand(this)},r.prototype.iuxor=function(c){var d,p;this.length>c.length?(d=this,p=c):(d=c,p=this);for(var S=0;S<p.length;S++)this.words[S]=d.words[S]^p.words[S];if(this!==d)for(;S<d.length;S++)this.words[S]=d.words[S];return this.length=d.length,this._strip()},r.prototype.ixor=function(c){return n((this.negative|c.negative)===0),this.iuxor(c)},r.prototype.xor=function(c){return this.length>c.length?this.clone().ixor(c):c.clone().ixor(this)},r.prototype.uxor=function(c){return this.length>c.length?this.clone().iuxor(c):c.clone().iuxor(this)},r.prototype.inotn=function(c){n(typeof c=="number"&&c>=0);var d=Math.ceil(c/26)|0,p=c%26;this._expand(d),p>0&&d--;for(var S=0;S<d;S++)this.words[S]=~this.words[S]&67108863;return p>0&&(this.words[S]=~this.words[S]&67108863>>26-p),this._strip()},r.prototype.notn=function(c){return this.clone().inotn(c)},r.prototype.setn=function(c,d){n(typeof c=="number"&&c>=0);var p=c/26|0,S=c%26;return this._expand(p+1),d?this.words[p]=this.words[p]|1<<S:this.words[p]=this.words[p]&~(1<<S),this._strip()},r.prototype.iadd=function(c){var d;if(this.negative!==0&&c.negative===0)return this.negative=0,d=this.isub(c),this.negative^=1,this._normSign();if(this.negative===0&&c.negative!==0)return c.negative=0,d=this.isub(c),c.negative=1,d._normSign();var p,S;this.length>c.length?(p=this,S=c):(p=c,S=this);for(var k=0,M=0;M<S.length;M++)d=(p.words[M]|0)+(S.words[M]|0)+k,this.words[M]=d&67108863,k=d>>>26;for(;k!==0&&M<p.length;M++)d=(p.words[M]|0)+k,this.words[M]=d&67108863,k=d>>>26;if(this.length=p.length,k!==0)this.words[this.length]=k,this.length++;else if(p!==this)for(;M<p.length;M++)this.words[M]=p.words[M];return this},r.prototype.add=function(c){var d;return c.negative!==0&&this.negative===0?(c.negative=0,d=this.sub(c),c.negative^=1,d):c.negative===0&&this.negative!==0?(this.negative=0,d=c.sub(this),this.negative=1,d):this.length>c.length?this.clone().iadd(c):c.clone().iadd(this)},r.prototype.isub=function(c){if(c.negative!==0){c.negative=0;var d=this.iadd(c);return c.negative=1,d._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(c),this.negative=1,this._normSign();var p=this.cmp(c);if(p===0)return this.negative=0,this.length=1,this.words[0]=0,this;var S,k;p>0?(S=this,k=c):(S=c,k=this);for(var M=0,C=0;C<k.length;C++)d=(S.words[C]|0)-(k.words[C]|0)+M,M=d>>26,this.words[C]=d&67108863;for(;M!==0&&C<S.length;C++)d=(S.words[C]|0)+M,M=d>>26,this.words[C]=d&67108863;if(M===0&&C<S.length&&S!==this)for(;C<S.length;C++)this.words[C]=S.words[C];return this.length=Math.max(this.length,C),S!==this&&(this.negative=1),this._strip()},r.prototype.sub=function(c){return this.clone().isub(c)};function N(y,c,d){d.negative=c.negative^y.negative;var p=y.length+c.length|0;d.length=p,p=p-1|0;var S=y.words[0]|0,k=c.words[0]|0,M=S*k,C=M&67108863,w=M/67108864|0;d.words[0]=C;for(var f=1;f<p;f++){for(var A=w>>>26,J=w&67108863,Z=Math.min(f,c.length-1),tt=Math.max(0,f-y.length+1);tt<=Z;tt++){var xt=f-tt|0;S=y.words[xt]|0,k=c.words[tt]|0,M=S*k+J,A+=M/67108864|0,J=M&67108863}d.words[f]=J|0,w=A|0}return w!==0?d.words[f]=w|0:d.length--,d._strip()}var W=function(c,d,p){var S=c.words,k=d.words,M=p.words,C=0,w,f,A,J=S[0]|0,Z=J&8191,tt=J>>>13,xt=S[1]|0,dt=xt&8191,ct=xt>>>13,Wt=S[2]|0,Tt=Wt&8191,Ct=Wt>>>13,Fe=S[3]|0,Lt=Fe&8191,jt=Fe>>>13,Ur=S[4]|0,$t=Ur&8191,Vt=Ur>>>13,Nr=S[5]|0,Kt=Nr&8191,Pt=Nr>>>13,Ue=S[6]|0,qt=Ue&8191,Gt=Ue>>>13,Ve=S[7]|0,Zt=Ve&8191,m=Ve>>>13,l=S[8]|0,h=l&8191,_=l>>>13,U=S[9]|0,F=U&8191,z=U>>>13,bt=k[0]|0,mt=bt&8191,gt=bt>>>13,Ft=k[1]|0,lt=Ft&8191,te=Ft>>>13,io=k[2]|0,ee=io&8191,ne=io>>>13,oo=k[3]|0,re=oo&8191,se=oo>>>13,ao=k[4]|0,ie=ao&8191,oe=ao>>>13,co=k[5]|0,ae=co&8191,ce=co>>>13,uo=k[6]|0,ue=uo&8191,le=uo>>>13,lo=k[7]|0,fe=lo&8191,he=lo>>>13,fo=k[8]|0,de=fo&8191,pe=fo>>>13,ho=k[9]|0,ge=ho&8191,me=ho>>>13;p.negative=c.negative^d.negative,p.length=19,w=Math.imul(Z,mt),f=Math.imul(Z,gt),f=f+Math.imul(tt,mt)|0,A=Math.imul(tt,gt);var Es=(C+w|0)+((f&8191)<<13)|0;C=(A+(f>>>13)|0)+(Es>>>26)|0,Es&=67108863,w=Math.imul(dt,mt),f=Math.imul(dt,gt),f=f+Math.imul(ct,mt)|0,A=Math.imul(ct,gt),w=w+Math.imul(Z,lt)|0,f=f+Math.imul(Z,te)|0,f=f+Math.imul(tt,lt)|0,A=A+Math.imul(tt,te)|0;var Bs=(C+w|0)+((f&8191)<<13)|0;C=(A+(f>>>13)|0)+(Bs>>>26)|0,Bs&=67108863,w=Math.imul(Tt,mt),f=Math.imul(Tt,gt),f=f+Math.imul(Ct,mt)|0,A=Math.imul(Ct,gt),w=w+Math.imul(dt,lt)|0,f=f+Math.imul(dt,te)|0,f=f+Math.imul(ct,lt)|0,A=A+Math.imul(ct,te)|0,w=w+Math.imul(Z,ee)|0,f=f+Math.imul(Z,ne)|0,f=f+Math.imul(tt,ee)|0,A=A+Math.imul(tt,ne)|0;var As=(C+w|0)+((f&8191)<<13)|0;C=(A+(f>>>13)|0)+(As>>>26)|0,As&=67108863,w=Math.imul(Lt,mt),f=Math.imul(Lt,gt),f=f+Math.imul(jt,mt)|0,A=Math.imul(jt,gt),w=w+Math.imul(Tt,lt)|0,f=f+Math.imul(Tt,te)|0,f=f+Math.imul(Ct,lt)|0,A=A+Math.imul(Ct,te)|0,w=w+Math.imul(dt,ee)|0,f=f+Math.imul(dt,ne)|0,f=f+Math.imul(ct,ee)|0,A=A+Math.imul(ct,ne)|0,w=w+Math.imul(Z,re)|0,f=f+Math.imul(Z,se)|0,f=f+Math.imul(tt,re)|0,A=A+Math.imul(tt,se)|0;var Is=(C+w|0)+((f&8191)<<13)|0;C=(A+(f>>>13)|0)+(Is>>>26)|0,Is&=67108863,w=Math.imul($t,mt),f=Math.imul($t,gt),f=f+Math.imul(Vt,mt)|0,A=Math.imul(Vt,gt),w=w+Math.imul(Lt,lt)|0,f=f+Math.imul(Lt,te)|0,f=f+Math.imul(jt,lt)|0,A=A+Math.imul(jt,te)|0,w=w+Math.imul(Tt,ee)|0,f=f+Math.imul(Tt,ne)|0,f=f+Math.imul(Ct,ee)|0,A=A+Math.imul(Ct,ne)|0,w=w+Math.imul(dt,re)|0,f=f+Math.imul(dt,se)|0,f=f+Math.imul(ct,re)|0,A=A+Math.imul(ct,se)|0,w=w+Math.imul(Z,ie)|0,f=f+Math.imul(Z,oe)|0,f=f+Math.imul(tt,ie)|0,A=A+Math.imul(tt,oe)|0;var Rs=(C+w|0)+((f&8191)<<13)|0;C=(A+(f>>>13)|0)+(Rs>>>26)|0,Rs&=67108863,w=Math.imul(Kt,mt),f=Math.imul(Kt,gt),f=f+Math.imul(Pt,mt)|0,A=Math.imul(Pt,gt),w=w+Math.imul($t,lt)|0,f=f+Math.imul($t,te)|0,f=f+Math.imul(Vt,lt)|0,A=A+Math.imul(Vt,te)|0,w=w+Math.imul(Lt,ee)|0,f=f+Math.imul(Lt,ne)|0,f=f+Math.imul(jt,ee)|0,A=A+Math.imul(jt,ne)|0,w=w+Math.imul(Tt,re)|0,f=f+Math.imul(Tt,se)|0,f=f+Math.imul(Ct,re)|0,A=A+Math.imul(Ct,se)|0,w=w+Math.imul(dt,ie)|0,f=f+Math.imul(dt,oe)|0,f=f+Math.imul(ct,ie)|0,A=A+Math.imul(ct,oe)|0,w=w+Math.imul(Z,ae)|0,f=f+Math.imul(Z,ce)|0,f=f+Math.imul(tt,ae)|0,A=A+Math.imul(tt,ce)|0;var Ms=(C+w|0)+((f&8191)<<13)|0;C=(A+(f>>>13)|0)+(Ms>>>26)|0,Ms&=67108863,w=Math.imul(qt,mt),f=Math.imul(qt,gt),f=f+Math.imul(Gt,mt)|0,A=Math.imul(Gt,gt),w=w+Math.imul(Kt,lt)|0,f=f+Math.imul(Kt,te)|0,f=f+Math.imul(Pt,lt)|0,A=A+Math.imul(Pt,te)|0,w=w+Math.imul($t,ee)|0,f=f+Math.imul($t,ne)|0,f=f+Math.imul(Vt,ee)|0,A=A+Math.imul(Vt,ne)|0,w=w+Math.imul(Lt,re)|0,f=f+Math.imul(Lt,se)|0,f=f+Math.imul(jt,re)|0,A=A+Math.imul(jt,se)|0,w=w+Math.imul(Tt,ie)|0,f=f+Math.imul(Tt,oe)|0,f=f+Math.imul(Ct,ie)|0,A=A+Math.imul(Ct,oe)|0,w=w+Math.imul(dt,ae)|0,f=f+Math.imul(dt,ce)|0,f=f+Math.imul(ct,ae)|0,A=A+Math.imul(ct,ce)|0,w=w+Math.imul(Z,ue)|0,f=f+Math.imul(Z,le)|0,f=f+Math.imul(tt,ue)|0,A=A+Math.imul(tt,le)|0;var Ts=(C+w|0)+((f&8191)<<13)|0;C=(A+(f>>>13)|0)+(Ts>>>26)|0,Ts&=67108863,w=Math.imul(Zt,mt),f=Math.imul(Zt,gt),f=f+Math.imul(m,mt)|0,A=Math.imul(m,gt),w=w+Math.imul(qt,lt)|0,f=f+Math.imul(qt,te)|0,f=f+Math.imul(Gt,lt)|0,A=A+Math.imul(Gt,te)|0,w=w+Math.imul(Kt,ee)|0,f=f+Math.imul(Kt,ne)|0,f=f+Math.imul(Pt,ee)|0,A=A+Math.imul(Pt,ne)|0,w=w+Math.imul($t,re)|0,f=f+Math.imul($t,se)|0,f=f+Math.imul(Vt,re)|0,A=A+Math.imul(Vt,se)|0,w=w+Math.imul(Lt,ie)|0,f=f+Math.imul(Lt,oe)|0,f=f+Math.imul(jt,ie)|0,A=A+Math.imul(jt,oe)|0,w=w+Math.imul(Tt,ae)|0,f=f+Math.imul(Tt,ce)|0,f=f+Math.imul(Ct,ae)|0,A=A+Math.imul(Ct,ce)|0,w=w+Math.imul(dt,ue)|0,f=f+Math.imul(dt,le)|0,f=f+Math.imul(ct,ue)|0,A=A+Math.imul(ct,le)|0,w=w+Math.imul(Z,fe)|0,f=f+Math.imul(Z,he)|0,f=f+Math.imul(tt,fe)|0,A=A+Math.imul(tt,he)|0;var Cs=(C+w|0)+((f&8191)<<13)|0;C=(A+(f>>>13)|0)+(Cs>>>26)|0,Cs&=67108863,w=Math.imul(h,mt),f=Math.imul(h,gt),f=f+Math.imul(_,mt)|0,A=Math.imul(_,gt),w=w+Math.imul(Zt,lt)|0,f=f+Math.imul(Zt,te)|0,f=f+Math.imul(m,lt)|0,A=A+Math.imul(m,te)|0,w=w+Math.imul(qt,ee)|0,f=f+Math.imul(qt,ne)|0,f=f+Math.imul(Gt,ee)|0,A=A+Math.imul(Gt,ne)|0,w=w+Math.imul(Kt,re)|0,f=f+Math.imul(Kt,se)|0,f=f+Math.imul(Pt,re)|0,A=A+Math.imul(Pt,se)|0,w=w+Math.imul($t,ie)|0,f=f+Math.imul($t,oe)|0,f=f+Math.imul(Vt,ie)|0,A=A+Math.imul(Vt,oe)|0,w=w+Math.imul(Lt,ae)|0,f=f+Math.imul(Lt,ce)|0,f=f+Math.imul(jt,ae)|0,A=A+Math.imul(jt,ce)|0,w=w+Math.imul(Tt,ue)|0,f=f+Math.imul(Tt,le)|0,f=f+Math.imul(Ct,ue)|0,A=A+Math.imul(Ct,le)|0,w=w+Math.imul(dt,fe)|0,f=f+Math.imul(dt,he)|0,f=f+Math.imul(ct,fe)|0,A=A+Math.imul(ct,he)|0,w=w+Math.imul(Z,de)|0,f=f+Math.imul(Z,pe)|0,f=f+Math.imul(tt,de)|0,A=A+Math.imul(tt,pe)|0;var Ls=(C+w|0)+((f&8191)<<13)|0;C=(A+(f>>>13)|0)+(Ls>>>26)|0,Ls&=67108863,w=Math.imul(F,mt),f=Math.imul(F,gt),f=f+Math.imul(z,mt)|0,A=Math.imul(z,gt),w=w+Math.imul(h,lt)|0,f=f+Math.imul(h,te)|0,f=f+Math.imul(_,lt)|0,A=A+Math.imul(_,te)|0,w=w+Math.imul(Zt,ee)|0,f=f+Math.imul(Zt,ne)|0,f=f+Math.imul(m,ee)|0,A=A+Math.imul(m,ne)|0,w=w+Math.imul(qt,re)|0,f=f+Math.imul(qt,se)|0,f=f+Math.imul(Gt,re)|0,A=A+Math.imul(Gt,se)|0,w=w+Math.imul(Kt,ie)|0,f=f+Math.imul(Kt,oe)|0,f=f+Math.imul(Pt,ie)|0,A=A+Math.imul(Pt,oe)|0,w=w+Math.imul($t,ae)|0,f=f+Math.imul($t,ce)|0,f=f+Math.imul(Vt,ae)|0,A=A+Math.imul(Vt,ce)|0,w=w+Math.imul(Lt,ue)|0,f=f+Math.imul(Lt,le)|0,f=f+Math.imul(jt,ue)|0,A=A+Math.imul(jt,le)|0,w=w+Math.imul(Tt,fe)|0,f=f+Math.imul(Tt,he)|0,f=f+Math.imul(Ct,fe)|0,A=A+Math.imul(Ct,he)|0,w=w+Math.imul(dt,de)|0,f=f+Math.imul(dt,pe)|0,f=f+Math.imul(ct,de)|0,A=A+Math.imul(ct,pe)|0,w=w+Math.imul(Z,ge)|0,f=f+Math.imul(Z,me)|0,f=f+Math.imul(tt,ge)|0,A=A+Math.imul(tt,me)|0;var Us=(C+w|0)+((f&8191)<<13)|0;C=(A+(f>>>13)|0)+(Us>>>26)|0,Us&=67108863,w=Math.imul(F,lt),f=Math.imul(F,te),f=f+Math.imul(z,lt)|0,A=Math.imul(z,te),w=w+Math.imul(h,ee)|0,f=f+Math.imul(h,ne)|0,f=f+Math.imul(_,ee)|0,A=A+Math.imul(_,ne)|0,w=w+Math.imul(Zt,re)|0,f=f+Math.imul(Zt,se)|0,f=f+Math.imul(m,re)|0,A=A+Math.imul(m,se)|0,w=w+Math.imul(qt,ie)|0,f=f+Math.imul(qt,oe)|0,f=f+Math.imul(Gt,ie)|0,A=A+Math.imul(Gt,oe)|0,w=w+Math.imul(Kt,ae)|0,f=f+Math.imul(Kt,ce)|0,f=f+Math.imul(Pt,ae)|0,A=A+Math.imul(Pt,ce)|0,w=w+Math.imul($t,ue)|0,f=f+Math.imul($t,le)|0,f=f+Math.imul(Vt,ue)|0,A=A+Math.imul(Vt,le)|0,w=w+Math.imul(Lt,fe)|0,f=f+Math.imul(Lt,he)|0,f=f+Math.imul(jt,fe)|0,A=A+Math.imul(jt,he)|0,w=w+Math.imul(Tt,de)|0,f=f+Math.imul(Tt,pe)|0,f=f+Math.imul(Ct,de)|0,A=A+Math.imul(Ct,pe)|0,w=w+Math.imul(dt,ge)|0,f=f+Math.imul(dt,me)|0,f=f+Math.imul(ct,ge)|0,A=A+Math.imul(ct,me)|0;var Ns=(C+w|0)+((f&8191)<<13)|0;C=(A+(f>>>13)|0)+(Ns>>>26)|0,Ns&=67108863,w=Math.imul(F,ee),f=Math.imul(F,ne),f=f+Math.imul(z,ee)|0,A=Math.imul(z,ne),w=w+Math.imul(h,re)|0,f=f+Math.imul(h,se)|0,f=f+Math.imul(_,re)|0,A=A+Math.imul(_,se)|0,w=w+Math.imul(Zt,ie)|0,f=f+Math.imul(Zt,oe)|0,f=f+Math.imul(m,ie)|0,A=A+Math.imul(m,oe)|0,w=w+Math.imul(qt,ae)|0,f=f+Math.imul(qt,ce)|0,f=f+Math.imul(Gt,ae)|0,A=A+Math.imul(Gt,ce)|0,w=w+Math.imul(Kt,ue)|0,f=f+Math.imul(Kt,le)|0,f=f+Math.imul(Pt,ue)|0,A=A+Math.imul(Pt,le)|0,w=w+Math.imul($t,fe)|0,f=f+Math.imul($t,he)|0,f=f+Math.imul(Vt,fe)|0,A=A+Math.imul(Vt,he)|0,w=w+Math.imul(Lt,de)|0,f=f+Math.imul(Lt,pe)|0,f=f+Math.imul(jt,de)|0,A=A+Math.imul(jt,pe)|0,w=w+Math.imul(Tt,ge)|0,f=f+Math.imul(Tt,me)|0,f=f+Math.imul(Ct,ge)|0,A=A+Math.imul(Ct,me)|0;var Ps=(C+w|0)+((f&8191)<<13)|0;C=(A+(f>>>13)|0)+(Ps>>>26)|0,Ps&=67108863,w=Math.imul(F,re),f=Math.imul(F,se),f=f+Math.imul(z,re)|0,A=Math.imul(z,se),w=w+Math.imul(h,ie)|0,f=f+Math.imul(h,oe)|0,f=f+Math.imul(_,ie)|0,A=A+Math.imul(_,oe)|0,w=w+Math.imul(Zt,ae)|0,f=f+Math.imul(Zt,ce)|0,f=f+Math.imul(m,ae)|0,A=A+Math.imul(m,ce)|0,w=w+Math.imul(qt,ue)|0,f=f+Math.imul(qt,le)|0,f=f+Math.imul(Gt,ue)|0,A=A+Math.imul(Gt,le)|0,w=w+Math.imul(Kt,fe)|0,f=f+Math.imul(Kt,he)|0,f=f+Math.imul(Pt,fe)|0,A=A+Math.imul(Pt,he)|0,w=w+Math.imul($t,de)|0,f=f+Math.imul($t,pe)|0,f=f+Math.imul(Vt,de)|0,A=A+Math.imul(Vt,pe)|0,w=w+Math.imul(Lt,ge)|0,f=f+Math.imul(Lt,me)|0,f=f+Math.imul(jt,ge)|0,A=A+Math.imul(jt,me)|0;var Fs=(C+w|0)+((f&8191)<<13)|0;C=(A+(f>>>13)|0)+(Fs>>>26)|0,Fs&=67108863,w=Math.imul(F,ie),f=Math.imul(F,oe),f=f+Math.imul(z,ie)|0,A=Math.imul(z,oe),w=w+Math.imul(h,ae)|0,f=f+Math.imul(h,ce)|0,f=f+Math.imul(_,ae)|0,A=A+Math.imul(_,ce)|0,w=w+Math.imul(Zt,ue)|0,f=f+Math.imul(Zt,le)|0,f=f+Math.imul(m,ue)|0,A=A+Math.imul(m,le)|0,w=w+Math.imul(qt,fe)|0,f=f+Math.imul(qt,he)|0,f=f+Math.imul(Gt,fe)|0,A=A+Math.imul(Gt,he)|0,w=w+Math.imul(Kt,de)|0,f=f+Math.imul(Kt,pe)|0,f=f+Math.imul(Pt,de)|0,A=A+Math.imul(Pt,pe)|0,w=w+Math.imul($t,ge)|0,f=f+Math.imul($t,me)|0,f=f+Math.imul(Vt,ge)|0,A=A+Math.imul(Vt,me)|0;var Os=(C+w|0)+((f&8191)<<13)|0;C=(A+(f>>>13)|0)+(Os>>>26)|0,Os&=67108863,w=Math.imul(F,ae),f=Math.imul(F,ce),f=f+Math.imul(z,ae)|0,A=Math.imul(z,ce),w=w+Math.imul(h,ue)|0,f=f+Math.imul(h,le)|0,f=f+Math.imul(_,ue)|0,A=A+Math.imul(_,le)|0,w=w+Math.imul(Zt,fe)|0,f=f+Math.imul(Zt,he)|0,f=f+Math.imul(m,fe)|0,A=A+Math.imul(m,he)|0,w=w+Math.imul(qt,de)|0,f=f+Math.imul(qt,pe)|0,f=f+Math.imul(Gt,de)|0,A=A+Math.imul(Gt,pe)|0,w=w+Math.imul(Kt,ge)|0,f=f+Math.imul(Kt,me)|0,f=f+Math.imul(Pt,ge)|0,A=A+Math.imul(Pt,me)|0;var $s=(C+w|0)+((f&8191)<<13)|0;C=(A+(f>>>13)|0)+($s>>>26)|0,$s&=67108863,w=Math.imul(F,ue),f=Math.imul(F,le),f=f+Math.imul(z,ue)|0,A=Math.imul(z,le),w=w+Math.imul(h,fe)|0,f=f+Math.imul(h,he)|0,f=f+Math.imul(_,fe)|0,A=A+Math.imul(_,he)|0,w=w+Math.imul(Zt,de)|0,f=f+Math.imul(Zt,pe)|0,f=f+Math.imul(m,de)|0,A=A+Math.imul(m,pe)|0,w=w+Math.imul(qt,ge)|0,f=f+Math.imul(qt,me)|0,f=f+Math.imul(Gt,ge)|0,A=A+Math.imul(Gt,me)|0;var qs=(C+w|0)+((f&8191)<<13)|0;C=(A+(f>>>13)|0)+(qs>>>26)|0,qs&=67108863,w=Math.imul(F,fe),f=Math.imul(F,he),f=f+Math.imul(z,fe)|0,A=Math.imul(z,he),w=w+Math.imul(h,de)|0,f=f+Math.imul(h,pe)|0,f=f+Math.imul(_,de)|0,A=A+Math.imul(_,pe)|0,w=w+Math.imul(Zt,ge)|0,f=f+Math.imul(Zt,me)|0,f=f+Math.imul(m,ge)|0,A=A+Math.imul(m,me)|0;var Ks=(C+w|0)+((f&8191)<<13)|0;C=(A+(f>>>13)|0)+(Ks>>>26)|0,Ks&=67108863,w=Math.imul(F,de),f=Math.imul(F,pe),f=f+Math.imul(z,de)|0,A=Math.imul(z,pe),w=w+Math.imul(h,ge)|0,f=f+Math.imul(h,me)|0,f=f+Math.imul(_,ge)|0,A=A+Math.imul(_,me)|0;var Ds=(C+w|0)+((f&8191)<<13)|0;C=(A+(f>>>13)|0)+(Ds>>>26)|0,Ds&=67108863,w=Math.imul(F,ge),f=Math.imul(F,me),f=f+Math.imul(z,ge)|0,A=Math.imul(z,me);var zs=(C+w|0)+((f&8191)<<13)|0;return C=(A+(f>>>13)|0)+(zs>>>26)|0,zs&=67108863,M[0]=Es,M[1]=Bs,M[2]=As,M[3]=Is,M[4]=Rs,M[5]=Ms,M[6]=Ts,M[7]=Cs,M[8]=Ls,M[9]=Us,M[10]=Ns,M[11]=Ps,M[12]=Fs,M[13]=Os,M[14]=$s,M[15]=qs,M[16]=Ks,M[17]=Ds,M[18]=zs,C!==0&&(M[19]=C,p.length++),p};Math.imul||(W=N);function D(y,c,d){d.negative=c.negative^y.negative,d.length=y.length+c.length;for(var p=0,S=0,k=0;k<d.length-1;k++){var M=S;S=0;for(var C=p&67108863,w=Math.min(k,c.length-1),f=Math.max(0,k-y.length+1);f<=w;f++){var A=k-f,J=y.words[A]|0,Z=c.words[f]|0,tt=J*Z,xt=tt&67108863;M=M+(tt/67108864|0)|0,xt=xt+C|0,C=xt&67108863,M=M+(xt>>>26)|0,S+=M>>>26,M&=67108863}d.words[k]=C,p=M,M=S}return p!==0?d.words[k]=p:d.length--,d._strip()}function X(y,c,d){return D(y,c,d)}r.prototype.mulTo=function(c,d){var p,S=this.length+c.length;return this.length===10&&c.length===10?p=W(this,c,d):S<63?p=N(this,c,d):S<1024?p=D(this,c,d):p=X(this,c,d),p},r.prototype.mul=function(c){var d=new r(null);return d.words=new Array(this.length+c.length),this.mulTo(c,d)},r.prototype.mulf=function(c){var d=new r(null);return d.words=new Array(this.length+c.length),X(this,c,d)},r.prototype.imul=function(c){return this.clone().mulTo(c,this)},r.prototype.imuln=function(c){var d=c<0;d&&(c=-c),n(typeof c=="number"),n(c<67108864);for(var p=0,S=0;S<this.length;S++){var k=(this.words[S]|0)*c,M=(k&67108863)+(p&67108863);p>>=26,p+=k/67108864|0,p+=M>>>26,this.words[S]=M&67108863}return p!==0&&(this.words[S]=p,this.length++),this.length=c===0?1:this.length,d?this.ineg():this},r.prototype.muln=function(c){return this.clone().imuln(c)},r.prototype.sqr=function(){return this.mul(this)},r.prototype.isqr=function(){return this.imul(this.clone())},r.prototype.pow=function(c){var d=T(c);if(d.length===0)return new r(1);for(var p=this,S=0;S<d.length&&d[S]===0;S++,p=p.sqr());if(++S<d.length)for(var k=p.sqr();S<d.length;S++,k=k.sqr())d[S]!==0&&(p=p.mul(k));return p},r.prototype.iushln=function(c){n(typeof c=="number"&&c>=0);var d=c%26,p=(c-d)/26,S=67108863>>>26-d<<26-d,k;if(d!==0){var M=0;for(k=0;k<this.length;k++){var C=this.words[k]&S,w=(this.words[k]|0)-C<<d;this.words[k]=w|M,M=C>>>26-d}M&&(this.words[k]=M,this.length++)}if(p!==0){for(k=this.length-1;k>=0;k--)this.words[k+p]=this.words[k];for(k=0;k<p;k++)this.words[k]=0;this.length+=p}return this._strip()},r.prototype.ishln=function(c){return n(this.negative===0),this.iushln(c)},r.prototype.iushrn=function(c,d,p){n(typeof c=="number"&&c>=0);var S;d?S=(d-d%26)/26:S=0;var k=c%26,M=Math.min((c-k)/26,this.length),C=67108863^67108863>>>k<<k,w=p;if(S-=M,S=Math.max(0,S),w){for(var f=0;f<M;f++)w.words[f]=this.words[f];w.length=M}if(M!==0)if(this.length>M)for(this.length-=M,f=0;f<this.length;f++)this.words[f]=this.words[f+M];else this.words[0]=0,this.length=1;var A=0;for(f=this.length-1;f>=0&&(A!==0||f>=S);f--){var J=this.words[f]|0;this.words[f]=A<<26-k|J>>>k,A=J&C}return w&&A!==0&&(w.words[w.length++]=A),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},r.prototype.ishrn=function(c,d,p){return n(this.negative===0),this.iushrn(c,d,p)},r.prototype.shln=function(c){return this.clone().ishln(c)},r.prototype.ushln=function(c){return this.clone().iushln(c)},r.prototype.shrn=function(c){return this.clone().ishrn(c)},r.prototype.ushrn=function(c){return this.clone().iushrn(c)},r.prototype.testn=function(c){n(typeof c=="number"&&c>=0);var d=c%26,p=(c-d)/26,S=1<<d;if(this.length<=p)return!1;var k=this.words[p];return!!(k&S)},r.prototype.imaskn=function(c){n(typeof c=="number"&&c>=0);var d=c%26,p=(c-d)/26;if(n(this.negative===0,"imaskn works only with positive numbers"),this.length<=p)return this;if(d!==0&&p++,this.length=Math.min(p,this.length),d!==0){var S=67108863^67108863>>>d<<d;this.words[this.length-1]&=S}return this.length===0&&(this.words[0]=0,this.length=1),this._strip()},r.prototype.maskn=function(c){return this.clone().imaskn(c)},r.prototype.iaddn=function(c){return n(typeof c=="number"),n(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)},r.prototype._iaddn=function(c){this.words[0]+=c;for(var d=0;d<this.length&&this.words[d]>=67108864;d++)this.words[d]-=67108864,d===this.length-1?this.words[d+1]=1:this.words[d+1]++;return this.length=Math.max(this.length,d+1),this},r.prototype.isubn=function(c){if(n(typeof c=="number"),n(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 d=0;d<this.length&&this.words[d]<0;d++)this.words[d]+=67108864,this.words[d+1]-=1;return this._strip()},r.prototype.addn=function(c){return this.clone().iaddn(c)},r.prototype.subn=function(c){return this.clone().isubn(c)},r.prototype.iabs=function(){return this.negative=0,this},r.prototype.abs=function(){return this.clone().iabs()},r.prototype._ishlnsubmul=function(c,d,p){var S=c.length+p,k;this._expand(S);var M,C=0;for(k=0;k<c.length;k++){M=(this.words[k+p]|0)+C;var w=(c.words[k]|0)*d;M-=w&67108863,C=(M>>26)-(w/67108864|0),this.words[k+p]=M&67108863}for(;k<this.length-p;k++)M=(this.words[k+p]|0)+C,C=M>>26,this.words[k+p]=M&67108863;if(C===0)return this._strip();for(n(C===-1),C=0,k=0;k<this.length;k++)M=-(this.words[k]|0)+C,C=M>>26,this.words[k]=M&67108863;return this.negative=1,this._strip()},r.prototype._wordDiv=function(c,d){var p=this.length-c.length,S=this.clone(),k=c,M=k.words[k.length-1]|0,C=this._countBits(M);p=26-C,p!==0&&(k=k.ushln(p),S.iushln(p),M=k.words[k.length-1]|0);var w=S.length-k.length,f;if(d!=="mod"){f=new r(null),f.length=w+1,f.words=new Array(f.length);for(var A=0;A<f.length;A++)f.words[A]=0}var J=S.clone()._ishlnsubmul(k,1,w);J.negative===0&&(S=J,f&&(f.words[w]=1));for(var Z=w-1;Z>=0;Z--){var tt=(S.words[k.length+Z]|0)*67108864+(S.words[k.length+Z-1]|0);for(tt=Math.min(tt/M|0,67108863),S._ishlnsubmul(k,tt,Z);S.negative!==0;)tt--,S.negative=0,S._ishlnsubmul(k,1,Z),S.isZero()||(S.negative^=1);f&&(f.words[Z]=tt)}return f&&f._strip(),S._strip(),d!=="div"&&p!==0&&S.iushrn(p),{div:f||null,mod:S}},r.prototype.divmod=function(c,d,p){if(n(!c.isZero()),this.isZero())return{div:new r(0),mod:new r(0)};var S,k,M;return this.negative!==0&&c.negative===0?(M=this.neg().divmod(c,d),d!=="mod"&&(S=M.div.neg()),d!=="div"&&(k=M.mod.neg(),p&&k.negative!==0&&k.iadd(c)),{div:S,mod:k}):this.negative===0&&c.negative!==0?(M=this.divmod(c.neg(),d),d!=="mod"&&(S=M.div.neg()),{div:S,mod:M.mod}):this.negative&c.negative?(M=this.neg().divmod(c.neg(),d),d!=="div"&&(k=M.mod.neg(),p&&k.negative!==0&&k.isub(c)),{div:M.div,mod:k}):c.length>this.length||this.cmp(c)<0?{div:new r(0),mod:this}:c.length===1?d==="div"?{div:this.divn(c.words[0]),mod:null}:d==="mod"?{div:null,mod:new r(this.modrn(c.words[0]))}:{div:this.divn(c.words[0]),mod:new r(this.modrn(c.words[0]))}:this._wordDiv(c,d)},r.prototype.div=function(c){return this.divmod(c,"div",!1).div},r.prototype.mod=function(c){return this.divmod(c,"mod",!1).mod},r.prototype.umod=function(c){return this.divmod(c,"mod",!0).mod},r.prototype.divRound=function(c){var d=this.divmod(c);if(d.mod.isZero())return d.div;var p=d.div.negative!==0?d.mod.isub(c):d.mod,S=c.ushrn(1),k=c.andln(1),M=p.cmp(S);return M<0||k===1&&M===0?d.div:d.div.negative!==0?d.div.isubn(1):d.div.iaddn(1)},r.prototype.modrn=function(c){var d=c<0;d&&(c=-c),n(c<=67108863);for(var p=(1<<26)%c,S=0,k=this.length-1;k>=0;k--)S=(p*S+(this.words[k]|0))%c;return d?-S:S},r.prototype.modn=function(c){return this.modrn(c)},r.prototype.idivn=function(c){var d=c<0;d&&(c=-c),n(c<=67108863);for(var p=0,S=this.length-1;S>=0;S--){var k=(this.words[S]|0)+p*67108864;this.words[S]=k/c|0,p=k%c}return this._strip(),d?this.ineg():this},r.prototype.divn=function(c){return this.clone().idivn(c)},r.prototype.egcd=function(c){n(c.negative===0),n(!c.isZero());var d=this,p=c.clone();d.negative!==0?d=d.umod(c):d=d.clone();for(var S=new r(1),k=new r(0),M=new r(0),C=new r(1),w=0;d.isEven()&&p.isEven();)d.iushrn(1),p.iushrn(1),++w;for(var f=p.clone(),A=d.clone();!d.isZero();){for(var J=0,Z=1;!(d.words[0]&Z)&&J<26;++J,Z<<=1);if(J>0)for(d.iushrn(J);J-- >0;)(S.isOdd()||k.isOdd())&&(S.iadd(f),k.isub(A)),S.iushrn(1),k.iushrn(1);for(var tt=0,xt=1;!(p.words[0]&xt)&&tt<26;++tt,xt<<=1);if(tt>0)for(p.iushrn(tt);tt-- >0;)(M.isOdd()||C.isOdd())&&(M.iadd(f),C.isub(A)),M.iushrn(1),C.iushrn(1);d.cmp(p)>=0?(d.isub(p),S.isub(M),k.isub(C)):(p.isub(d),M.isub(S),C.isub(k))}return{a:M,b:C,gcd:p.iushln(w)}},r.prototype._invmp=function(c){n(c.negative===0),n(!c.isZero());var d=this,p=c.clone();d.negative!==0?d=d.umod(c):d=d.clone();for(var S=new r(1),k=new r(0),M=p.clone();d.cmpn(1)>0&&p.cmpn(1)>0;){for(var C=0,w=1;!(d.words[0]&w)&&C<26;++C,w<<=1);if(C>0)for(d.iushrn(C);C-- >0;)S.isOdd()&&S.iadd(M),S.iushrn(1);for(var f=0,A=1;!(p.words[0]&A)&&f<26;++f,A<<=1);if(f>0)for(p.iushrn(f);f-- >0;)k.isOdd()&&k.iadd(M),k.iushrn(1);d.cmp(p)>=0?(d.isub(p),S.isub(k)):(p.isub(d),k.isub(S))}var J;return d.cmpn(1)===0?J=S:J=k,J.cmpn(0)<0&&J.iadd(c),J},r.prototype.gcd=function(c){if(this.isZero())return c.abs();if(c.isZero())return this.abs();var d=this.clone(),p=c.clone();d.negative=0,p.negative=0;for(var S=0;d.isEven()&&p.isEven();S++)d.iushrn(1),p.iushrn(1);do{for(;d.isEven();)d.iushrn(1);for(;p.isEven();)p.iushrn(1);var k=d.cmp(p);if(k<0){var M=d;d=p,p=M}else if(k===0||p.cmpn(1)===0)break;d.isub(p)}while(!0);return p.iushln(S)},r.prototype.invm=function(c){return this.egcd(c).a.umod(c)},r.prototype.isEven=function(){return(this.words[0]&1)===0},r.prototype.isOdd=function(){return(this.words[0]&1)===1},r.prototype.andln=function(c){return this.words[0]&c},r.prototype.bincn=function(c){n(typeof c=="number");var d=c%26,p=(c-d)/26,S=1<<d;if(this.length<=p)return this._expand(p+1),this.words[p]|=S,this;for(var k=S,M=p;k!==0&&M<this.length;M++){var C=this.words[M]|0;C+=k,k=C>>>26,C&=67108863,this.words[M]=C}return k!==0&&(this.words[M]=k,this.length++),this},r.prototype.isZero=function(){return this.length===1&&this.words[0]===0},r.prototype.cmpn=function(c){var d=c<0;if(this.negative!==0&&!d)return-1;if(this.negative===0&&d)return 1;this._strip();var p;if(this.length>1)p=1;else{d&&(c=-c),n(c<=67108863,"Number is too big");var S=this.words[0]|0;p=S===c?0:S<c?-1:1}return this.negative!==0?-p|0:p},r.prototype.cmp=function(c){if(this.negative!==0&&c.negative===0)return-1;if(this.negative===0&&c.negative!==0)return 1;var d=this.ucmp(c);return this.negative!==0?-d|0:d},r.prototype.ucmp=function(c){if(this.length>c.length)return 1;if(this.length<c.length)return-1;for(var d=0,p=this.length-1;p>=0;p--){var S=this.words[p]|0,k=c.words[p]|0;if(S!==k){S<k?d=-1:S>k&&(d=1);break}}return d},r.prototype.gtn=function(c){return this.cmpn(c)===1},r.prototype.gt=function(c){return this.cmp(c)===1},r.prototype.gten=function(c){return this.cmpn(c)>=0},r.prototype.gte=function(c){return this.cmp(c)>=0},r.prototype.ltn=function(c){return this.cmpn(c)===-1},r.prototype.lt=function(c){return this.cmp(c)===-1},r.prototype.lten=function(c){return this.cmpn(c)<=0},r.prototype.lte=function(c){return this.cmp(c)<=0},r.prototype.eqn=function(c){return this.cmpn(c)===0},r.prototype.eq=function(c){return this.cmp(c)===0},r.red=function(c){return new Q(c)},r.prototype.toRed=function(c){return n(!this.red,"Already a number in reduction context"),n(this.negative===0,"red works only with positives"),c.convertTo(this)._forceRed(c)},r.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},r.prototype._forceRed=function(c){return this.red=c,this},r.prototype.forceRed=function(c){return n(!this.red,"Already a number in reduction context"),this._forceRed(c)},r.prototype.redAdd=function(c){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,c)},r.prototype.redIAdd=function(c){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,c)},r.prototype.redSub=function(c){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,c)},r.prototype.redISub=function(c){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,c)},r.prototype.redShl=function(c){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,c)},r.prototype.redMul=function(c){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,c),this.red.mul(this,c)},r.prototype.redIMul=function(c){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,c),this.red.imul(this,c)},r.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},r.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},r.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},r.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},r.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},r.prototype.redPow=function(c){return n(this.red&&!c.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,c)};var nt={k256:null,p224:null,p192:null,p25519:null};function at(y,c){this.name=y,this.p=new r(c,16),this.n=this.p.bitLength(),this.k=new r(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}at.prototype._tmp=function(){var c=new r(null);return c.words=new Array(Math.ceil(this.n/13)),c},at.prototype.ireduce=function(c){var d=c,p;do this.split(d,this.tmp),d=this.imulK(d),d=d.iadd(this.tmp),p=d.bitLength();while(p>this.n);var S=p<this.n?-1:d.ucmp(this.p);return S===0?(d.words[0]=0,d.length=1):S>0?d.isub(this.p):d.strip!==void 0?d.strip():d._strip(),d},at.prototype.split=function(c,d){c.iushrn(this.n,0,d)},at.prototype.imulK=function(c){return c.imul(this.k)};function ht(){at.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(ht,at),ht.prototype.split=function(c,d){for(var p=4194303,S=Math.min(c.length,9),k=0;k<S;k++)d.words[k]=c.words[k];if(d.length=S,c.length<=9){c.words[0]=0,c.length=1;return}var M=c.words[9];for(d.words[d.length++]=M&p,k=10;k<c.length;k++){var C=c.words[k]|0;c.words[k-10]=(C&p)<<4|M>>>22,M=C}M>>>=22,c.words[k-10]=M,M===0&&c.length>10?c.length-=10:c.length-=9},ht.prototype.imulK=function(c){c.words[c.length]=0,c.words[c.length+1]=0,c.length+=2;for(var d=0,p=0;p<c.length;p++){var S=c.words[p]|0;d+=S*977,c.words[p]=d&67108863,d=S*64+(d/67108864|0)}return c.words[c.length-1]===0&&(c.length--,c.words[c.length-1]===0&&c.length--),c};function ut(){at.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}i(ut,at);function j(){at.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}i(j,at);function rt(){at.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}i(rt,at),rt.prototype.imulK=function(c){for(var d=0,p=0;p<c.length;p++){var S=(c.words[p]|0)*19+d,k=S&67108863;S>>>=26,c.words[p]=k,d=S}return d!==0&&(c.words[c.length++]=d),c},r._prime=function(c){if(nt[c])return nt[c];var d;if(c==="k256")d=new ht;else if(c==="p224")d=new ut;else if(c==="p192")d=new j;else if(c==="p25519")d=new rt;else throw new Error("Unknown prime "+c);return nt[c]=d,d};function Q(y){if(typeof y=="string"){var c=r._prime(y);this.m=c.p,this.prime=c}else n(y.gtn(1),"modulus must be greater than 1"),this.m=y,this.prime=null}Q.prototype._verify1=function(c){n(c.negative===0,"red works only with positives"),n(c.red,"red works only with red numbers")},Q.prototype._verify2=function(c,d){n((c.negative|d.negative)===0,"red works only with positives"),n(c.red&&c.red===d.red,"red works only with red numbers")},Q.prototype.imod=function(c){return this.prime?this.prime.ireduce(c)._forceRed(this):(x(c,c.umod(this.m)._forceRed(this)),c)},Q.prototype.neg=function(c){return c.isZero()?c.clone():this.m.sub(c)._forceRed(this)},Q.prototype.add=function(c,d){this._verify2(c,d);var p=c.add(d);return p.cmp(this.m)>=0&&p.isub(this.m),p._forceRed(this)},Q.prototype.iadd=function(c,d){this._verify2(c,d);var p=c.iadd(d);return p.cmp(this.m)>=0&&p.isub(this.m),p},Q.prototype.sub=function(c,d){this._verify2(c,d);var p=c.sub(d);return p.cmpn(0)<0&&p.iadd(this.m),p._forceRed(this)},Q.prototype.isub=function(c,d){this._verify2(c,d);var p=c.isub(d);return p.cmpn(0)<0&&p.iadd(this.m),p},Q.prototype.shl=function(c,d){return this._verify1(c),this.imod(c.ushln(d))},Q.prototype.imul=function(c,d){return this._verify2(c,d),this.imod(c.imul(d))},Q.prototype.mul=function(c,d){return this._verify2(c,d),this.imod(c.mul(d))},Q.prototype.isqr=function(c){return this.imul(c,c.clone())},Q.prototype.sqr=function(c){return this.mul(c,c)},Q.prototype.sqrt=function(c){if(c.isZero())return c.clone();var d=this.m.andln(3);if(n(d%2===1),d===3){var p=this.m.add(new r(1)).iushrn(2);return this.pow(c,p)}for(var S=this.m.subn(1),k=0;!S.isZero()&&S.andln(1)===0;)k++,S.iushrn(1);n(!S.isZero());var M=new r(1).toRed(this),C=M.redNeg(),w=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new r(2*f*f).toRed(this);this.pow(f,w).cmp(C)!==0;)f.redIAdd(C);for(var A=this.pow(f,S),J=this.pow(c,S.addn(1).iushrn(1)),Z=this.pow(c,S),tt=k;Z.cmp(M)!==0;){for(var xt=Z,dt=0;xt.cmp(M)!==0;dt++)xt=xt.redSqr();n(dt<tt);var ct=this.pow(A,new r(1).iushln(tt-dt-1));J=J.redMul(ct),A=ct.redSqr(),Z=Z.redMul(A),tt=dt}return J},Q.prototype.invm=function(c){var d=c._invmp(this.m);return d.negative!==0?(d.negative=0,this.imod(d).redNeg()):this.imod(d)},Q.prototype.pow=function(c,d){if(d.isZero())return new r(1).toRed(this);if(d.cmpn(1)===0)return c.clone();var p=4,S=new Array(1<<p);S[0]=new r(1).toRed(this),S[1]=c;for(var k=2;k<S.length;k++)S[k]=this.mul(S[k-1],c);var M=S[0],C=0,w=0,f=d.bitLength()%26;for(f===0&&(f=26),k=d.length-1;k>=0;k--){for(var A=d.words[k],J=f-1;J>=0;J--){var Z=A>>J&1;if(M!==S[0]&&(M=this.sqr(M)),Z===0&&C===0){w=0;continue}C<<=1,C|=Z,w++,!(w!==p&&(k!==0||J!==0))&&(M=this.mul(M,S[C]),w=0,C=0)}f=26}return M},Q.prototype.convertTo=function(c){var d=c.umod(this.m);return d===c?d.clone():d},Q.prototype.convertFrom=function(c){var d=c.clone();return d.red=null,d},r.mont=function(c){return new et(c)};function et(y){Q.call(this,y),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new r(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)}i(et,Q),et.prototype.convertTo=function(c){return this.imod(c.ushln(this.shift))},et.prototype.convertFrom=function(c){var d=this.imod(c.mul(this.rinv));return d.red=null,d},et.prototype.imul=function(c,d){if(c.isZero()||d.isZero())return c.words[0]=0,c.length=1,c;var p=c.imul(d),S=p.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),k=p.isub(S).iushrn(this.shift),M=k;return k.cmp(this.m)>=0?M=k.isub(this.m):k.cmpn(0)<0&&(M=k.iadd(this.m)),M._forceRed(this)},et.prototype.mul=function(c,d){if(c.isZero()||d.isZero())return new r(0)._forceRed(this);var p=c.mul(d),S=p.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),k=p.isub(S).iushrn(this.shift),M=k;return k.cmp(this.m)>=0?M=k.isub(this.m):k.cmpn(0)<0&&(M=k.iadd(this.m)),M._forceRed(this)},et.prototype.invm=function(c){var d=this.imod(c._invmp(this.m).mul(this.r2));return d._forceRed(this)}})(s,Ye)})(Fi);var Ia=Fi.exports;const Xr=Ir(Ia);var mi={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(s,t){var e=Y,n=e.Buffer;function i(o,a){for(var u in o)a[u]=o[u]}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?s.exports=e:(i(e,t),t.Buffer=r);function r(o,a,u){return n(o,a,u)}r.prototype=Object.create(n.prototype),i(n,r),r.from=function(o,a,u){if(typeof o=="number")throw new TypeError("Argument must not be a number");return n(o,a,u)},r.alloc=function(o,a,u){if(typeof o!="number")throw new TypeError("Argument must be a number");var g=n(o);return a!==void 0?typeof u=="string"?g.fill(a,u):g.fill(a):g.fill(0),g},r.allocUnsafe=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return n(o)},r.allocUnsafeSlow=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return e.SlowBuffer(o)}})(mi,mi.exports);var dl=mi.exports,qr=dl.Buffer;function pl(s){if(s.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),e=0;e<t.length;e++)t[e]=255;for(var n=0;n<s.length;n++){var i=s.charAt(n),r=i.charCodeAt(0);if(t[r]!==255)throw new TypeError(i+" is ambiguous");t[r]=n}var o=s.length,a=s.charAt(0),u=Math.log(o)/Math.log(256),g=Math.log(256)/Math.log(o);function x(v){if((Array.isArray(v)||v instanceof Uint8Array)&&(v=qr.from(v)),!qr.isBuffer(v))throw new TypeError("Expected Buffer");if(v.length===0)return"";for(var E=0,R=0,T=0,N=v.length;T!==N&&v[T]===0;)T++,E++;for(var W=(N-T)*g+1>>>0,D=new Uint8Array(W);T!==N;){for(var X=v[T],nt=0,at=W-1;(X!==0||nt<R)&&at!==-1;at--,nt++)X+=256*D[at]>>>0,D[at]=X%o>>>0,X=X/o>>>0;if(X!==0)throw new Error("Non-zero carry");R=nt,T++}for(var ht=W-R;ht!==W&&D[ht]===0;)ht++;for(var ut=a.repeat(E);ht<W;++ht)ut+=s.charAt(D[ht]);return ut}function B(v){if(typeof v!="string")throw new TypeError("Expected String");if(v.length===0)return qr.alloc(0);for(var E=0,R=0,T=0;v[E]===a;)R++,E++;for(var N=(v.length-E)*u+1>>>0,W=new Uint8Array(N);E<v.length;){var D=v.charCodeAt(E);if(D>255)return;var X=t[D];if(X===255)return;for(var nt=0,at=N-1;(X!==0||nt<T)&&at!==-1;at--,nt++)X+=o*W[at]>>>0,W[at]=X%256>>>0,X=X/256>>>0;if(X!==0)throw new Error("Non-zero carry");T=nt,E++}for(var ht=N-T;ht!==N&&W[ht]===0;)ht++;var ut=qr.allocUnsafe(R+(N-ht));ut.fill(0,0,R);for(var j=R;ht!==N;)ut[j++]=W[ht++];return ut}function I(v){var E=B(v);if(E)return E;throw new Error("Non-base"+o+" character")}return{encode:x,decodeUnsafe:B,decode:I}}var gl=pl,ml=gl,yl="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",Ra=ml(yl);const Et=Ir(Ra),Jr=aa;var ke={};function ln(s,t,e){return t<=s&&s<=e}function hs(s){if(s===void 0)return{};if(s===Object(s))return s;throw TypeError("Could not convert argument to dictionary")}function wl(s){for(var t=String(s),e=t.length,n=0,i=[];n<e;){var r=t.charCodeAt(n);if(r<55296||r>57343)i.push(r);else if(56320<=r&&r<=57343)i.push(65533);else if(55296<=r&&r<=56319)if(n===e-1)i.push(65533);else{var o=s.charCodeAt(n+1);if(56320<=o&&o<=57343){var a=r&1023,u=o&1023;i.push(65536+(a<<10)+u),n+=1}else i.push(65533)}n+=1}return i}function bl(s){for(var t="",e=0;e<s.length;++e){var n=s[e];n<=65535?t+=String.fromCharCode(n):(n-=65536,t+=String.fromCharCode((n>>10)+55296,(n&1023)+56320))}return t}var Qr=-1;function Oi(s){this.tokens=[].slice.call(s)}Oi.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():Qr},prepend:function(s){if(Array.isArray(s))for(var t=s;t.length;)this.tokens.unshift(t.pop());else this.tokens.unshift(s)},push:function(s){if(Array.isArray(s))for(var t=s;t.length;)this.tokens.push(t.shift());else this.tokens.push(s)}};var or=-1;function Xs(s,t){if(s)throw TypeError("Decoder error");return t||65533}var ts="utf-8";function es(s,t){if(!(this instanceof es))return new es(s,t);if(s=s!==void 0?String(s).toLowerCase():ts,s!==ts)throw new Error("Encoding not supported. Only utf-8 is supported");t=hs(t),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=!!t.fatal,this._ignoreBOM=!!t.ignoreBOM,Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}es.prototype={decode:function(t,e){var n;typeof t=="object"&&t instanceof ArrayBuffer?n=new Uint8Array(t):typeof t=="object"&&"buffer"in t&&t.buffer instanceof ArrayBuffer?n=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):n=new Uint8Array(0),e=hs(e),this._streaming||(this._decoder=new Sl({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!e.stream;for(var i=new Oi(n),r=[],o;!i.endOfStream()&&(o=this._decoder.handler(i,i.read()),o!==or);)o!==null&&(Array.isArray(o)?r.push.apply(r,o):r.push(o));if(!this._streaming){do{if(o=this._decoder.handler(i,i.read()),o===or)break;o!==null&&(Array.isArray(o)?r.push.apply(r,o):r.push(o))}while(!i.endOfStream());this._decoder=null}return r.length&&["utf-8"].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(r[0]===65279?(this._BOMseen=!0,r.shift()):this._BOMseen=!0),bl(r)}};function ns(s,t){if(!(this instanceof ns))return new ns(s,t);if(s=s!==void 0?String(s).toLowerCase():ts,s!==ts)throw new Error("Encoding not supported. Only utf-8 is supported");t=hs(t),this._streaming=!1,this._encoder=null,this._options={fatal:!!t.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}ns.prototype={encode:function(t,e){t=t?String(t):"",e=hs(e),this._streaming||(this._encoder=new vl(this._options)),this._streaming=!!e.stream;for(var n=[],i=new Oi(wl(t)),r;!i.endOfStream()&&(r=this._encoder.handler(i,i.read()),r!==or);)Array.isArray(r)?n.push.apply(n,r):n.push(r);if(!this._streaming){for(;r=this._encoder.handler(i,i.read()),r!==or;)Array.isArray(r)?n.push.apply(n,r):n.push(r);this._encoder=null}return new Uint8Array(n)}};function Sl(s){var t=s.fatal,e=0,n=0,i=0,r=128,o=191;this.handler=function(a,u){if(u===Qr&&i!==0)return i=0,Xs(t);if(u===Qr)return or;if(i===0){if(ln(u,0,127))return u;if(ln(u,194,223))i=1,e=u-192;else if(ln(u,224,239))u===224&&(r=160),u===237&&(o=159),i=2,e=u-224;else if(ln(u,240,244))u===240&&(r=144),u===244&&(o=143),i=3,e=u-240;else return Xs(t);return e=e<<6*i,null}if(!ln(u,r,o))return e=i=n=0,r=128,o=191,a.prepend(u),Xs(t);if(r=128,o=191,n+=1,e+=u-128<<6*(i-n),n!==i)return null;var g=e;return e=i=n=0,g}}function vl(s){s.fatal,this.handler=function(t,e){if(e===Qr)return or;if(ln(e,0,127))return e;var n,i;ln(e,128,2047)?(n=1,i=192):ln(e,2048,65535)?(n=2,i=224):ln(e,65536,1114111)&&(n=3,i=240);for(var r=[(e>>6*n)+i];n>0;){var o=e>>6*(n-1);r.push(128|o&63),n-=1}return r}}const xl=Object.freeze(Object.defineProperty({__proto__:null,TextDecoder:es,TextEncoder:ns},Symbol.toStringTag,{value:"Module"})),_l=Ri(xl);var kl=Ye&&Ye.__createBinding||(Object.create?function(s,t,e,n){n===void 0&&(n=e),Object.defineProperty(s,n,{enumerable:!0,get:function(){return t[e]}})}:function(s,t,e,n){n===void 0&&(n=e),s[n]=t[e]}),El=Ye&&Ye.__setModuleDefault||(Object.create?function(s,t){Object.defineProperty(s,"default",{enumerable:!0,value:t})}:function(s,t){s.default=t}),nn=Ye&&Ye.__decorate||function(s,t,e,n){var i=arguments.length,r=i<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(s,t,e,n);else for(var a=s.length-1;a>=0;a--)(o=s[a])&&(r=(i<3?o(r):i>3?o(t,e,r):o(t,e))||r);return i>3&&r&&Object.defineProperty(t,e,r),r},Bl=Ye&&Ye.__importStar||function(s){if(s&&s.__esModule)return s;var t={};if(s!=null)for(var e in s)e!=="default"&&Object.hasOwnProperty.call(s,e)&&kl(t,s,e);return El(t,s),t},Ma=Ye&&Ye.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(ke,"__esModule",{value:!0});var $i=ke.deserializeUnchecked=Di=ke.deserialize=qi=ke.serialize=ke.BinaryReader=ke.BinaryWriter=ke.BorshError=ke.baseDecode=ke.baseEncode=void 0;const xn=Ma(Ia),Ta=Ma(Ra),Al=Bl(_l),Il=typeof TextDecoder!="function"?Al.TextDecoder:TextDecoder,Rl=new Il("utf-8",{fatal:!0});function Ml(s){return typeof s=="string"&&(s=Buffer.from(s,"utf8")),Ta.default.encode(Buffer.from(s))}ke.baseEncode=Ml;function Tl(s){return Buffer.from(Ta.default.decode(s))}ke.baseDecode=Tl;const Js=1024;class Te extends Error{constructor(t){super(t),this.fieldPath=[],this.originalMessage=t}addToFieldPath(t){this.fieldPath.splice(0,0,t),this.message=this.originalMessage+": "+this.fieldPath.join(".")}}ke.BorshError=Te;class Ca{constructor(){this.buf=Buffer.alloc(Js),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(Js)]))}writeU8(t){this.maybeResize(),this.buf.writeUInt8(t,this.length),this.length+=1}writeU16(t){this.maybeResize(),this.buf.writeUInt16LE(t,this.length),this.length+=2}writeU32(t){this.maybeResize(),this.buf.writeUInt32LE(t,this.length),this.length+=4}writeU64(t){this.maybeResize(),this.writeBuffer(Buffer.from(new xn.default(t).toArray("le",8)))}writeU128(t){this.maybeResize(),this.writeBuffer(Buffer.from(new xn.default(t).toArray("le",16)))}writeU256(t){this.maybeResize(),this.writeBuffer(Buffer.from(new xn.default(t).toArray("le",32)))}writeU512(t){this.maybeResize(),this.writeBuffer(Buffer.from(new xn.default(t).toArray("le",64)))}writeBuffer(t){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),t,Buffer.alloc(Js)]),this.length+=t.length}writeString(t){this.maybeResize();const e=Buffer.from(t,"utf8");this.writeU32(e.length),this.writeBuffer(e)}writeFixedArray(t){this.writeBuffer(Buffer.from(t))}writeArray(t,e){this.maybeResize(),this.writeU32(t.length);for(const n of t)this.maybeResize(),e(n)}toArray(){return this.buf.subarray(0,this.length)}}ke.BinaryWriter=Ca;function rn(s,t,e){const n=e.value;e.value=function(...i){try{return n.apply(this,i)}catch(r){if(r instanceof RangeError){const o=r.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(o)>=0)throw new Te("Reached the end of buffer when deserializing")}throw r}}}class Pe{constructor(t){this.buf=t,this.offset=0}readU8(){const t=this.buf.readUInt8(this.offset);return this.offset+=1,t}readU16(){const t=this.buf.readUInt16LE(this.offset);return this.offset+=2,t}readU32(){const t=this.buf.readUInt32LE(this.offset);return this.offset+=4,t}readU64(){const t=this.readBuffer(8);return new xn.default(t,"le")}readU128(){const t=this.readBuffer(16);return new xn.default(t,"le")}readU256(){const t=this.readBuffer(32);return new xn.default(t,"le")}readU512(){const t=this.readBuffer(64);return new xn.default(t,"le")}readBuffer(t){if(this.offset+t>this.buf.length)throw new Te(`Expected buffer length ${t} isn't within bounds`);const e=this.buf.slice(this.offset,this.offset+t);return this.offset+=t,e}readString(){const t=this.readU32(),e=this.readBuffer(t);try{return Rl.decode(e)}catch(n){throw new Te(`Error decoding UTF-8 string: ${n}`)}}readFixedArray(t){return new Uint8Array(this.readBuffer(t))}readArray(t){const e=this.readU32(),n=Array();for(let i=0;i<e;++i)n.push(t());return n}}nn([rn],Pe.prototype,"readU8",null);nn([rn],Pe.prototype,"readU16",null);nn([rn],Pe.prototype,"readU32",null);nn([rn],Pe.prototype,"readU64",null);nn([rn],Pe.prototype,"readU128",null);nn([rn],Pe.prototype,"readU256",null);nn([rn],Pe.prototype,"readU512",null);nn([rn],Pe.prototype,"readString",null);nn([rn],Pe.prototype,"readFixedArray",null);nn([rn],Pe.prototype,"readArray",null);ke.BinaryReader=Pe;function La(s){return s.charAt(0).toUpperCase()+s.slice(1)}function An(s,t,e,n,i){try{if(typeof n=="string")i[`write${La(n)}`](e);else if(n instanceof Array)if(typeof n[0]=="number"){if(e.length!==n[0])throw new Te(`Expecting byte array of length ${n[0]}, but got ${e.length} bytes`);i.writeFixedArray(e)}else if(n.length===2&&typeof n[1]=="number"){if(e.length!==n[1])throw new Te(`Expecting byte array of length ${n[1]}, but got ${e.length} bytes`);for(let r=0;r<n[1];r++)An(s,null,e[r],n[0],i)}else i.writeArray(e,r=>{An(s,t,r,n[0],i)});else if(n.kind!==void 0)switch(n.kind){case"option":{e==null?i.writeU8(0):(i.writeU8(1),An(s,t,e,n.type,i));break}case"map":{i.writeU32(e.size),e.forEach((r,o)=>{An(s,t,o,n.key,i),An(s,t,r,n.value,i)});break}default:throw new Te(`FieldType ${n} unrecognized`)}else Ua(s,e,i)}catch(r){throw r instanceof Te&&r.addToFieldPath(t),r}}function Ua(s,t,e){if(typeof t.borshSerialize=="function"){t.borshSerialize(e);return}const n=s.get(t.constructor);if(!n)throw new Te(`Class ${t.constructor.name} is missing in schema`);if(n.kind==="struct")n.fields.map(([i,r])=>{An(s,i,t[i],r,e)});else if(n.kind==="enum"){const i=t[n.field];for(let r=0;r<n.values.length;++r){const[o,a]=n.values[r];if(o===i){e.writeU8(r),An(s,o,t[o],a,e);break}}}else throw new Te(`Unexpected schema kind: ${n.kind} for ${t.constructor.name}`)}function Cl(s,t,e=Ca){const n=new e;return Ua(s,t,n),n.toArray()}var qi=ke.serialize=Cl;function In(s,t,e,n){try{if(typeof e=="string")return n[`read${La(e)}`]();if(e instanceof Array){if(typeof e[0]=="number")return n.readFixedArray(e[0]);if(typeof e[1]=="number"){const i=[];for(let r=0;r<e[1];r++)i.push(In(s,null,e[0],n));return i}else return n.readArray(()=>In(s,t,e[0],n))}if(e.kind==="option")return n.readU8()?In(s,t,e.type,n):void 0;if(e.kind==="map"){let i=new Map;const r=n.readU32();for(let o=0;o<r;o++){const a=In(s,t,e.key,n),u=In(s,t,e.value,n);i.set(a,u)}return i}return Ki(s,e,n)}catch(i){throw i instanceof Te&&i.addToFieldPath(t),i}}function Ki(s,t,e){if(typeof t.borshDeserialize=="function")return t.borshDeserialize(e);const n=s.get(t);if(!n)throw new Te(`Class ${t.name} is missing in schema`);if(n.kind==="struct"){const i={};for(const[r,o]of s.get(t).fields)i[r]=In(s,r,o,e);return new t(i)}if(n.kind==="enum"){const i=e.readU8();if(i>=n.values.length)throw new Te(`Enum index: ${i} is out of range`);const[r,o]=n.values[i],a=In(s,r,o,e);return new t({[r]:a})}throw new Te(`Unexpected schema kind: ${n.kind} for ${t.constructor.name}`)}function Ll(s,t,e,n=Pe){const i=new n(e),r=Ki(s,t,i);if(i.offset<e.length)throw new Te(`Unexpected ${e.length-i.offset} bytes after deserialized data`);return r}var Di=ke.deserialize=Ll;function Ul(s,t,e,n=Pe){const i=new n(e);return Ki(s,t,i)}$i=ke.deserializeUnchecked=Ul;var q={};Object.defineProperty(q,"__esModule",{value:!0});q.s16=q.s8=q.nu64be=q.u48be=q.u40be=q.u32be=q.u24be=q.u16be=Bt=q.nu64=q.u48=q.u40=G=q.u32=q.u24=Dt=q.u16=st=q.u8=Ne=q.offset=q.greedy=q.Constant=q.UTF8=q.CString=q.Blob=q.Boolean=q.BitField=q.BitStructure=q.VariantLayout=q.Union=q.UnionLayoutDiscriminator=q.UnionDiscriminator=q.Structure=q.Sequence=q.DoubleBE=q.Double=q.FloatBE=q.Float=q.NearInt64BE=q.NearInt64=q.NearUInt64BE=q.NearUInt64=q.IntBE=q.Int=q.UIntBE=q.UInt=q.OffsetLayout=q.GreedyCount=q.ExternalLayout=q.bindConstructorLayout=q.nameWithProperty=q.Layout=q.uint8ArrayToBuffer=q.checkUint8Array=void 0;q.constant=q.utf8=q.cstr=yt=q.blob=q.unionLayoutDiscriminator=q.union=Rt=q.seq=q.bits=H=q.struct=q.f64be=q.f64=q.f32be=q.f32=q.ns64be=q.s48be=q.s40be=q.s32be=q.s24be=q.s16be=Ot=q.ns64=q.s48=q.s40=q.s32=q.s24=void 0;const zi=Y;function fr(s){if(!(s instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}q.checkUint8Array=fr;function At(s){return fr(s),zi.Buffer.from(s.buffer,s.byteOffset,s.length)}q.uint8ArrayToBuffer=At;class Mt{constructor(t,e){if(!Number.isInteger(t))throw new TypeError("span must be an integer");this.span=t,this.property=e}makeDestinationObject(){return{}}getSpan(t,e){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(t){const e=Object.create(this.constructor.prototype);return Object.assign(e,this),e.property=t,e}fromArray(t){}}q.Layout=Mt;function Hi(s,t){return t.property?s+"["+t.property+"]":s}q.nameWithProperty=Hi;function Nl(s,t){if(typeof s!="function")throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(s,"layout_"))throw new Error("Class is already bound to a layout");if(!(t&&t instanceof Mt))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(t,"boundConstructor_"))throw new Error("layout is already bound to a constructor");s.layout_=t,t.boundConstructor_=s,t.makeDestinationObject=()=>new s,Object.defineProperty(s.prototype,"encode",{value(e,n){return t.encode(this,e,n)},writable:!0}),Object.defineProperty(s,"decode",{value(e,n){return t.decode(e,n)},writable:!0})}q.bindConstructorLayout=Nl;class Ce extends Mt{isCount(){throw new Error("ExternalLayout is abstract")}}q.ExternalLayout=Ce;class Na extends Ce{constructor(t=1,e){if(!Number.isInteger(t)||0>=t)throw new TypeError("elementSpan must be a (positive) integer");super(-1,e),this.elementSpan=t}isCount(){return!0}decode(t,e=0){fr(t);const n=t.length-e;return Math.floor(n/this.elementSpan)}encode(t,e,n){return 0}}q.GreedyCount=Na;class Wi extends Ce{constructor(t,e=0,n){if(!(t instanceof Mt))throw new TypeError("layout must be a Layout");if(!Number.isInteger(e))throw new TypeError("offset must be integer or undefined");super(t.span,n||t.property),this.layout=t,this.offset=e}isCount(){return this.layout instanceof We||this.layout instanceof Ze}decode(t,e=0){return this.layout.decode(t,e+this.offset)}encode(t,e,n=0){return this.layout.encode(t,e,n+this.offset)}}q.OffsetLayout=Wi;class We extends Mt{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return At(t).readUIntLE(e,this.span)}encode(t,e,n=0){return At(e).writeUIntLE(t,n,this.span),this.span}}q.UInt=We;class Ze extends Mt{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return At(t).readUIntBE(e,this.span)}encode(t,e,n=0){return At(e).writeUIntBE(t,n,this.span),this.span}}q.UIntBE=Ze;class Pn extends Mt{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return At(t).readIntLE(e,this.span)}encode(t,e,n=0){return At(e).writeIntLE(t,n,this.span),this.span}}q.Int=Pn;class hr extends Mt{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e=0){return At(t).readIntBE(e,this.span)}encode(t,e,n=0){return At(e).writeIntBE(t,n,this.span),this.span}}q.IntBE=hr;const yi=Math.pow(2,32);function ds(s){const t=Math.floor(s/yi),e=s-t*yi;return{hi32:t,lo32:e}}function ps(s,t){return s*yi+t}class Pa extends Mt{constructor(t){super(8,t)}decode(t,e=0){const n=At(t),i=n.readUInt32LE(e),r=n.readUInt32LE(e+4);return ps(r,i)}encode(t,e,n=0){const i=ds(t),r=At(e);return r.writeUInt32LE(i.lo32,n),r.writeUInt32LE(i.hi32,n+4),8}}q.NearUInt64=Pa;class Fa extends Mt{constructor(t){super(8,t)}decode(t,e=0){const n=At(t),i=n.readUInt32BE(e),r=n.readUInt32BE(e+4);return ps(i,r)}encode(t,e,n=0){const i=ds(t),r=At(e);return r.writeUInt32BE(i.hi32,n),r.writeUInt32BE(i.lo32,n+4),8}}q.NearUInt64BE=Fa;class Oa extends Mt{constructor(t){super(8,t)}decode(t,e=0){const n=At(t),i=n.readUInt32LE(e),r=n.readInt32LE(e+4);return ps(r,i)}encode(t,e,n=0){const i=ds(t),r=At(e);return r.writeUInt32LE(i.lo32,n),r.writeInt32LE(i.hi32,n+4),8}}q.NearInt64=Oa;class $a extends Mt{constructor(t){super(8,t)}decode(t,e=0){const n=At(t),i=n.readInt32BE(e),r=n.readUInt32BE(e+4);return ps(i,r)}encode(t,e,n=0){const i=ds(t),r=At(e);return r.writeInt32BE(i.hi32,n),r.writeUInt32BE(i.lo32,n+4),8}}q.NearInt64BE=$a;class qa extends Mt{constructor(t){super(4,t)}decode(t,e=0){return At(t).readFloatLE(e)}encode(t,e,n=0){return At(e).writeFloatLE(t,n),4}}q.Float=qa;class Ka extends Mt{constructor(t){super(4,t)}decode(t,e=0){return At(t).readFloatBE(e)}encode(t,e,n=0){return At(e).writeFloatBE(t,n),4}}q.FloatBE=Ka;class Da extends Mt{constructor(t){super(8,t)}decode(t,e=0){return At(t).readDoubleLE(e)}encode(t,e,n=0){return At(e).writeDoubleLE(t,n),8}}q.Double=Da;class za extends Mt{constructor(t){super(8,t)}decode(t,e=0){return At(t).readDoubleBE(e)}encode(t,e,n=0){return At(e).writeDoubleBE(t,n),8}}q.DoubleBE=za;class Ha extends Mt{constructor(t,e,n){if(!(t instanceof Mt))throw new TypeError("elementLayout must be a Layout");if(!(e instanceof Ce&&e.isCount()||Number.isInteger(e)&&0<=e))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let i=-1;!(e instanceof Ce)&&0<t.span&&(i=e*t.span),super(i,n),this.elementLayout=t,this.count=e}getSpan(t,e=0){if(0<=this.span)return this.span;let n=0,i=this.count;if(i instanceof Ce&&(i=i.decode(t,e)),0<this.elementLayout.span)n=i*this.elementLayout.span;else{let r=0;for(;r<i;)n+=this.elementLayout.getSpan(t,e+n),++r}return n}decode(t,e=0){const n=[];let i=0,r=this.count;for(r instanceof Ce&&(r=r.decode(t,e));i<r;)n.push(this.elementLayout.decode(t,e)),e+=this.elementLayout.getSpan(t,e),i+=1;return n}encode(t,e,n=0){const i=this.elementLayout,r=t.reduce((o,a)=>o+i.encode(a,e,n+o),0);return this.count instanceof Ce&&this.count.encode(t.length,e,n),r}}q.Sequence=Ha;class Wa extends Mt{constructor(t,e,n){if(!(Array.isArray(t)&&t.reduce((r,o)=>r&&o instanceof Mt,!0)))throw new TypeError("fields must be array of Layout instances");typeof e=="boolean"&&n===void 0&&(n=e,e=void 0);for(const r of t)if(0>r.span&&r.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let i=-1;try{i=t.reduce((r,o)=>r+o.getSpan(),0)}catch{}super(i,e),this.fields=t,this.decodePrefixes=!!n}getSpan(t,e=0){if(0<=this.span)return this.span;let n=0;try{n=this.fields.reduce((i,r)=>{const o=r.getSpan(t,e);return e+=o,i+o},0)}catch{throw new RangeError("indeterminate span")}return n}decode(t,e=0){fr(t);const n=this.makeDestinationObject();for(const i of this.fields)if(i.property!==void 0&&(n[i.property]=i.decode(t,e)),e+=i.getSpan(t,e),this.decodePrefixes&&t.length===e)break;return n}encode(t,e,n=0){const i=n;let r=0,o=0;for(const a of this.fields){let u=a.span;if(o=0<u?u:0,a.property!==void 0){const g=t[a.property];g!==void 0&&(o=a.encode(g,e,n),0>u&&(u=a.getSpan(e,n)))}r=n,n+=u}return r+o-i}fromArray(t){const e=this.makeDestinationObject();for(const n of this.fields)n.property!==void 0&&0<t.length&&(e[n.property]=t.shift());return e}layoutFor(t){if(typeof t!="string")throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}offsetOf(t){if(typeof t!="string")throw new TypeError("property must be string");let e=0;for(const n of this.fields){if(n.property===t)return e;0>n.span?e=-1:0<=e&&(e+=n.span)}}}q.Structure=Wa;class ji{constructor(t){this.property=t}decode(t,e){throw new Error("UnionDiscriminator is abstract")}encode(t,e,n){throw new Error("UnionDiscriminator is abstract")}}q.UnionDiscriminator=ji;class rs extends ji{constructor(t,e){if(!(t instanceof Ce&&t.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(e||t.property||"variant"),this.layout=t}decode(t,e){return this.layout.decode(t,e)}encode(t,e,n){return this.layout.encode(t,e,n)}}q.UnionLayoutDiscriminator=rs;class Vi extends Mt{constructor(t,e,n){let i;if(t instanceof We||t instanceof Ze)i=new rs(new Wi(t));else if(t instanceof Ce&&t.isCount())i=new rs(t);else if(t instanceof ji)i=t;else throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(e===void 0&&(e=null),!(e===null||e instanceof Mt))throw new TypeError("defaultLayout must be null or a Layout");if(e!==null){if(0>e.span)throw new Error("defaultLayout must have constant span");e.property===void 0&&(e=e.replicate("content"))}let r=-1;e&&(r=e.span,0<=r&&(t instanceof We||t instanceof Ze)&&(r+=i.layout.span)),super(r,n),this.discriminator=i,this.usesPrefixDiscriminator=t instanceof We||t instanceof Ze,this.defaultLayout=e,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(a){return o(a)},this.configGetSourceVariant=function(a){o=a.bind(this)}}getSpan(t,e=0){if(0<=this.span)return this.span;const n=this.getVariant(t,e);if(!n)throw new Error("unable to determine span for unrecognized variant");return n.getSpan(t,e)}defaultGetSourceVariant(t){if(Object.prototype.hasOwnProperty.call(t,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(t,this.defaultLayout.property))return;const e=this.registry[t[this.discriminator.property]];if(e&&(!e.layout||e.property&&Object.prototype.hasOwnProperty.call(t,e.property)))return e}else for(const e in this.registry){const n=this.registry[e];if(n.property&&Object.prototype.hasOwnProperty.call(t,n.property))return n}throw new Error("unable to infer src variant")}decode(t,e=0){let n;const i=this.discriminator,r=i.decode(t,e),o=this.registry[r];if(o===void 0){const a=this.defaultLayout;let u=0;this.usesPrefixDiscriminator&&(u=i.layout.span),n=this.makeDestinationObject(),n[i.property]=r,n[a.property]=a.decode(t,e+u)}else n=o.decode(t,e);return n}encode(t,e,n=0){const i=this.getSourceVariant(t);if(i===void 0){const r=this.discriminator,o=this.defaultLayout;let a=0;return this.usesPrefixDiscriminator&&(a=r.layout.span),r.encode(t[r.property],e,n),a+o.encode(t[o.property],e,n+a)}return i.encode(t,e,n)}addVariant(t,e,n){const i=new ja(this,t,e,n);return this.registry[t]=i,i}getVariant(t,e=0){let n;return t instanceof Uint8Array?n=this.discriminator.decode(t,e):n=t,this.registry[n]}}q.Union=Vi;class ja extends Mt{constructor(t,e,n,i){if(!(t instanceof Vi))throw new TypeError("union must be a Union");if(!Number.isInteger(e)||0>e)throw new TypeError("variant must be a (non-negative) integer");if(typeof n=="string"&&i===void 0&&(i=n,n=null),n){if(!(n instanceof Mt))throw new TypeError("layout must be a Layout");if(t.defaultLayout!==null&&0<=n.span&&n.span>t.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof i!="string")throw new TypeError("variant must have a String property")}let r=t.span;0>t.span&&(r=n?n.span:0,0<=r&&t.usesPrefixDiscriminator&&(r+=t.discriminator.layout.span)),super(r,i),this.union=t,this.variant=e,this.layout=n||null}getSpan(t,e=0){if(0<=this.span)return this.span;let n=0;this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span);let i=0;return this.layout&&(i=this.layout.getSpan(t,e+n)),n+i}decode(t,e=0){const n=this.makeDestinationObject();if(this!==this.union.getVariant(t,e))throw new Error("variant mismatch");let i=0;return this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout?n[this.property]=this.layout.decode(t,e+i):this.property?n[this.property]=!0:this.union.usesPrefixDiscriminator&&(n[this.union.discriminator.property]=this.variant),n}encode(t,e,n=0){let i=0;if(this.union.usesPrefixDiscriminator&&(i=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(t,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,e,n);let r=i;if(this.layout&&(this.layout.encode(t[this.property],e,n+i),r+=this.layout.getSpan(e,n+i),0<=this.union.span&&r>this.union.span))throw new Error("encoded variant overruns containing union");return r}fromArray(t){if(this.layout)return this.layout.fromArray(t)}}q.VariantLayout=ja;function Vn(s){return 0>s&&(s+=4294967296),s}class Gi extends Mt{constructor(t,e,n){if(!(t instanceof We||t instanceof Ze))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof e=="string"&&n===void 0&&(n=e,e=!1),4<t.span)throw new RangeError("word cannot exceed 32 bits");super(t.span,n),this.word=t,this.msb=!!e,this.fields=[];let i=0;this._packedSetValue=function(r){return i=Vn(r),this},this._packedGetValue=function(){return i}}decode(t,e=0){const n=this.makeDestinationObject(),i=this.word.decode(t,e);this._packedSetValue(i);for(const r of this.fields)r.property!==void 0&&(n[r.property]=r.decode(t));return n}encode(t,e,n=0){const i=this.word.decode(e,n);this._packedSetValue(i);for(const r of this.fields)if(r.property!==void 0){const o=t[r.property];o!==void 0&&r.encode(o)}return this.word.encode(this._packedGetValue(),e,n)}addField(t,e){const n=new Zi(this,t,e);return this.fields.push(n),n}addBoolean(t){const e=new Va(this,t);return this.fields.push(e),e}fieldFor(t){if(typeof t!="string")throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}}q.BitStructure=Gi;class Zi{constructor(t,e,n){if(!(t instanceof Gi))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(e)||0>=e)throw new TypeError("bits must be positive integer");const i=8*t.span,r=t.fields.reduce((o,a)=>o+a.bits,0);if(e+r>i)throw new Error("bits too long for span remainder ("+(i-r)+" of "+i+" remain)");this.container=t,this.bits=e,this.valueMask=(1<<e)-1,e===32&&(this.valueMask=4294967295),this.start=r,this.container.msb&&(this.start=i-r-e),this.wordMask=Vn(this.valueMask<<this.start),this.property=n}decode(t,e){const n=this.container._packedGetValue();return Vn(n&this.wordMask)>>>this.start}encode(t){if(typeof t!="number"||!Number.isInteger(t)||t!==Vn(t&this.valueMask))throw new TypeError(Hi("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const e=this.container._packedGetValue(),n=Vn(t<<this.start);this.container._packedSetValue(Vn(e&~this.wordMask)|n)}}q.BitField=Zi;let Va=class extends Zi{constructor(t,e){super(t,1,e)}decode(t,e){return!!super.decode(t,e)}encode(t){typeof t=="boolean"&&(t=+t),super.encode(t)}};q.Boolean=Va;class Ga extends Mt{constructor(t,e){if(!(t instanceof Ce&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let n=-1;t instanceof Ce||(n=t),super(n,e),this.length=t}getSpan(t,e){let n=this.span;return 0>n&&(n=this.length.decode(t,e)),n}decode(t,e=0){let n=this.span;return 0>n&&(n=this.length.decode(t,e)),At(t).slice(e,e+n)}encode(t,e,n){let i=this.length;if(this.length instanceof Ce&&(i=t.length),!(t instanceof Uint8Array&&i===t.length))throw new TypeError(Hi("Blob.encode",this)+" requires (length "+i+") Uint8Array as src");if(n+i>e.length)throw new RangeError("encoding overruns Uint8Array");const r=At(t);return At(e).write(r.toString("hex"),n,i,"hex"),this.length instanceof Ce&&this.length.encode(i,e,n),i}}q.Blob=Ga;class Za extends Mt{constructor(t){super(-1,t)}getSpan(t,e=0){fr(t);let n=e;for(;n<t.length&&t[n]!==0;)n+=1;return 1+n-e}decode(t,e=0){const n=this.getSpan(t,e);return At(t).slice(e,e+n-1).toString("utf-8")}encode(t,e,n=0){typeof t!="string"&&(t=String(t));const i=zi.Buffer.from(t,"utf8"),r=i.length;if(n+r>e.length)throw new RangeError("encoding overruns Buffer");const o=At(e);return i.copy(o,n),o[n+r]=0,r+1}}q.CString=Za;class Ya extends Mt{constructor(t,e){if(typeof t=="string"&&e===void 0&&(e=t,t=void 0),t===void 0)t=-1;else if(!Number.isInteger(t))throw new TypeError("maxSpan must be an integer");super(-1,e),this.maxSpan=t}getSpan(t,e=0){return fr(t),t.length-e}decode(t,e=0){const n=this.getSpan(t,e);if(0<=this.maxSpan&&this.maxSpan<n)throw new RangeError("text length exceeds maxSpan");return At(t).slice(e,e+n).toString("utf-8")}encode(t,e,n=0){typeof t!="string"&&(t=String(t));const i=zi.Buffer.from(t,"utf8"),r=i.length;if(0<=this.maxSpan&&this.maxSpan<r)throw new RangeError("text length exceeds maxSpan");if(n+r>e.length)throw new RangeError("encoding overruns Buffer");return i.copy(At(e),n),r}}q.UTF8=Ya;class Xa extends Mt{constructor(t,e){super(0,e),this.value=t}decode(t,e){return this.value}encode(t,e,n){return 0}}q.Constant=Xa;q.greedy=(s,t)=>new Na(s,t);var Ne=q.offset=(s,t,e)=>new Wi(s,t,e),st=q.u8=s=>new We(1,s),Dt=q.u16=s=>new We(2,s);q.u24=s=>new We(3,s);var G=q.u32=s=>new We(4,s);q.u40=s=>new We(5,s);q.u48=s=>new We(6,s);var Bt=q.nu64=s=>new Pa(s);q.u16be=s=>new Ze(2,s);q.u24be=s=>new Ze(3,s);q.u32be=s=>new Ze(4,s);q.u40be=s=>new Ze(5,s);q.u48be=s=>new Ze(6,s);q.nu64be=s=>new Fa(s);q.s8=s=>new Pn(1,s);q.s16=s=>new Pn(2,s);q.s24=s=>new Pn(3,s);q.s32=s=>new Pn(4,s);q.s40=s=>new Pn(5,s);q.s48=s=>new Pn(6,s);var Ot=q.ns64=s=>new Oa(s);q.s16be=s=>new hr(2,s);q.s24be=s=>new hr(3,s);q.s32be=s=>new hr(4,s);q.s40be=s=>new hr(5,s);q.s48be=s=>new hr(6,s);q.ns64be=s=>new $a(s);q.f32=s=>new qa(s);q.f32be=s=>new Ka(s);q.f64=s=>new Da(s);q.f64be=s=>new za(s);var H=q.struct=(s,t,e)=>new Wa(s,t,e);q.bits=(s,t,e)=>new Gi(s,t,e);var Rt=q.seq=(s,t,e)=>new Ha(s,t,e);q.union=(s,t,e)=>new Vi(s,t,e);q.unionLayoutDiscriminator=(s,t)=>new rs(s,t);var yt=q.blob=(s,t)=>new Ga(s,t);q.cstr=s=>new Za(s);q.utf8=(s,t)=>new Ya(s,t);q.constant=(s,t)=>new Xa(s,t);var Pl=8078e3,Fl=8078001,Ol=8078004,$l=8078005,ql=8078006,Kl=8078011;function Ja(s){return Array.isArray(s)?"%5B"+s.map(Ja).join("%2C%20")+"%5D":typeof s=="bigint"?`${s}n`:encodeURIComponent(String(s!=null&&Object.getPrototypeOf(s)===null?{...s}:s))}function Dl([s,t]){return`${s}=${Ja(t)}`}function zl(s){const t=Object.entries(s).map(Dl).join("&");return btoa(t)}function Hl(s,t={}){{let e=`Solana error #${s}; Decode this error by running \`npx @solana/errors decode -- ${s}`;return Object.keys(t).length&&(e+=` '${zl(t)}'`),`${e}\``}}var tr=class extends Error{constructor(...[t,e]){let n,i;if(e){const{cause:o,...a}=e;o&&(i={cause:o}),Object.keys(a).length>0&&(n=a)}const r=Hl(t,n);super(r,i);ye(this,"cause",this.cause);ye(this,"context");this.context={__code:t,...n},this.name="SolanaError"}};function Wl(s,t){return"fixedSize"in t?t.fixedSize:t.getSizeFromValue(s)}function jl(s){return Object.freeze({...s,encode:t=>{const e=new Uint8Array(Wl(t,s));return s.write(t,e,0),e}})}function Vl(s){return Object.freeze({...s,decode:(t,e=0)=>s.read(t,e)[0]})}function jn(s){return"fixedSize"in s&&typeof s.fixedSize=="number"}function Gl(s,t){if(jn(s)!==jn(t))throw new tr(Ol);if(jn(s)&&jn(t)&&s.fixedSize!==t.fixedSize)throw new tr($l,{decoderFixedSize:t.fixedSize,encoderFixedSize:s.fixedSize});if(!jn(s)&&!jn(t)&&s.maxSize!==t.maxSize)throw new tr(ql,{decoderMaxSize:t.maxSize,encoderMaxSize:s.maxSize});return{...t,...s,decode:t.decode,encode:s.encode,read:t.read,write:s.write}}function Zl(s,t,e=0){if(t.length-e<=0)throw new tr(Pl,{codecDescription:s})}function Yl(s,t,e,n=0){const i=e.length-n;if(i<t)throw new tr(Fl,{bytesLength:i,codecDescription:s,expected:t})}function Xl(s,t,e,n){if(n<t||n>e)throw new tr(Kl,{codecDescription:s,max:e,min:t,value:n})}function Qa(s){return(s==null?void 0:s.endian)!==1}function Jl(s){return jl({fixedSize:s.size,write(t,e,n){s.range&&Xl(s.name,s.range[0],s.range[1],t);const i=new ArrayBuffer(s.size);return s.set(new DataView(i),t,Qa(s.config)),e.set(new Uint8Array(i),n),n+s.size}})}function Ql(s){return Vl({fixedSize:s.size,read(t,e=0){Zl(s.name,t,e),Yl(s.name,s.size,t,e);const n=new DataView(tf(t,e,s.size));return[s.get(n,Qa(s.config)),e+s.size]}})}function tf(s,t,e){const n=s.byteOffset+(t??0),i=e??s.byteLength;return s.buffer.slice(n,n+i)}var ef=(s={})=>Jl({config:s,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(t,e,n)=>t.setBigUint64(0,BigInt(e),n),size:8}),nf=(s={})=>Ql({config:s,get:(t,e)=>t.getBigUint64(0,e),name:"u64",size:8}),tc=(s={})=>Gl(ef(s),nf(s));class rf extends TypeError{constructor(t,e){let n;const{message:i,explanation:r,...o}=t,{path:a}=t,u=a.length===0?i:`At path: ${a.join(".")} -- ${i}`;super(r??u),r!=null&&(this.cause=u),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>n??(n=[t,...e()])}}function sf(s){return Cr(s)&&typeof s[Symbol.iterator]=="function"}function Cr(s){return typeof s=="object"&&s!=null}function ss(s){return Cr(s)&&!Array.isArray(s)}function Xe(s){return typeof s=="symbol"?s.toString():typeof s=="string"?JSON.stringify(s):`${s}`}function of(s){const{done:t,value:e}=s.next();return t?void 0:e}function af(s,t,e,n){if(s===!0)return;s===!1?s={}:typeof s=="string"&&(s={message:s});const{path:i,branch:r}=t,{type:o}=e,{refinement:a,message:u=`Expected a value of type \`${o}\`${a?` with refinement \`${a}\``:""}, but received: \`${Xe(n)}\``}=s;return{value:n,type:o,refinement:a,key:i[i.length-1],path:i,branch:r,...s,message:u}}function*Bo(s,t,e,n){sf(s)||(s=[s]);for(const i of s){const r=af(i,t,e,n);r&&(yield r)}}function*Yi(s,t,e={}){const{path:n=[],branch:i=[s],coerce:r=!1,mask:o=!1}=e,a={path:n,branch:i,mask:o};r&&(s=t.coercer(s,a));let u="valid";for(const g of t.validator(s,a))g.explanation=e.message,u="not_valid",yield[g,void 0];for(let[g,x,B]of t.entries(s,a)){const I=Yi(x,B,{path:g===void 0?n:[...n,g],branch:g===void 0?i:[...i,x],coerce:r,mask:o,message:e.message});for(const v of I)v[0]?(u=v[0].refinement!=null?"not_refined":"not_valid",yield[v[0],void 0]):r&&(x=v[1],g===void 0?s=x:s instanceof Map?s.set(g,x):s instanceof Set?s.add(x):Cr(s)&&(x!==void 0||g in s)&&(s[g]=x))}if(u!=="not_valid")for(const g of t.refiner(s,a))g.explanation=e.message,u="not_refined",yield[g,void 0];u==="valid"&&(yield[void 0,s])}let sn=class{constructor(t){const{type:e,schema:n,validator:i,refiner:r,coercer:o=u=>u,entries:a=function*(){}}=t;this.type=e,this.schema=n,this.entries=a,this.coercer=o,i?this.validator=(u,g)=>{const x=i(u,g);return Bo(x,g,this,u)}:this.validator=()=>[],r?this.refiner=(u,g)=>{const x=r(u,g);return Bo(x,g,this,u)}:this.refiner=()=>[]}assert(t,e){return cf(t,this,e)}create(t,e){return O(t,this,e)}is(t){return ec(t,this)}mask(t,e){return uf(t,this,e)}validate(t,e={}){return Lr(t,this,e)}};function cf(s,t,e){const n=Lr(s,t,{message:e});if(n[0])throw n[0]}function O(s,t,e){const n=Lr(s,t,{coerce:!0,message:e});if(n[0])throw n[0];return n[1]}function uf(s,t,e){const n=Lr(s,t,{coerce:!0,mask:!0,message:e});if(n[0])throw n[0];return n[1]}function ec(s,t){return!Lr(s,t)[0]}function Lr(s,t,e={}){const n=Yi(s,t,e),i=of(n);return i[0]?[new rf(i[0],function*(){for(const o of n)o[0]&&(yield o[0])}),void 0]:[void 0,i[1]]}function Fn(s,t){return new sn({type:s,schema:null,validator:t})}function nc(){return Fn("any",()=>!0)}function $(s){return new sn({type:"array",schema:s,*entries(t){if(s&&Array.isArray(t))for(const[e,n]of t.entries())yield[e,n,s]},coercer(t){return Array.isArray(t)?t.slice():t},validator(t){return Array.isArray(t)||`Expected an array value, but received: ${Xe(t)}`}})}function ve(){return Fn("boolean",s=>typeof s=="boolean")}function dr(s){return Fn("instance",t=>t instanceof s||`Expected a \`${s.name}\` instance, but received: ${Xe(t)}`)}function pt(s){const t=Xe(s),e=typeof s;return new sn({type:"literal",schema:e==="string"||e==="number"||e==="boolean"?s:null,validator(n){return n===s||`Expected the literal \`${t}\`, but received: ${Xe(n)}`}})}function lf(){return Fn("never",()=>!1)}function K(s){return new sn({...s,validator:(t,e)=>t===null||s.validator(t,e),refiner:(t,e)=>t===null||s.refiner(t,e)})}function b(){return Fn("number",s=>typeof s=="number"&&!isNaN(s)||`Expected a number, but received: ${Xe(s)}`)}function V(s){return new sn({...s,validator:(t,e)=>t===void 0||s.validator(t,e),refiner:(t,e)=>t===void 0||s.refiner(t,e)})}function gs(s,t){return new sn({type:"record",schema:null,*entries(e){if(Cr(e))for(const n in e){const i=e[n];yield[n,n,s],yield[n,i,t]}},validator(e){return ss(e)||`Expected an object, but received: ${Xe(e)}`},coercer(e){return ss(e)?{...e}:e}})}function P(){return Fn("string",s=>typeof s=="string"||`Expected a string, but received: ${Xe(s)}`)}function pr(s){const t=lf();return new sn({type:"tuple",schema:null,*entries(e){if(Array.isArray(e)){const n=Math.max(s.length,e.length);for(let i=0;i<n;i++)yield[i,e[i],s[i]||t]}},validator(e){return Array.isArray(e)||`Expected an array, but received: ${Xe(e)}`},coercer(e){return Array.isArray(e)?e.slice():e}})}function L(s){const t=Object.keys(s);return new sn({type:"type",schema:s,*entries(e){if(Cr(e))for(const n of t)yield[n,e[n],s[n]]},validator(e){return ss(e)||`Expected an object, but received: ${Xe(e)}`},coercer(e){return ss(e)?{...e}:e}})}function It(s){const t=s.map(e=>e.type).join(" | ");return new sn({type:"union",schema:null,coercer(e,n){for(const i of s){const[r,o]=i.validate(e,{coerce:!0,mask:n.mask});if(!r)return o}return e},validator(e,n){const i=[];for(const r of s){const[...o]=Yi(e,r,n),[a]=o;if(a[0])for(const[u]of o)u&&i.push(u);else return[]}return[`Expected the value to satisfy a union of \`${t}\`, but received: ${Xe(e)}`,...i]}})}function je(){return Fn("unknown",()=>!0)}function on(s,t,e){return new sn({...s,coercer:(n,i)=>ec(n,t)?s.coercer(e(n,i),i):s.coercer(n,i)})}var Kr,ff=new Uint8Array(16);function rc(){if(!Kr&&(Kr=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!Kr))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Kr(ff)}const hf=/^(?:[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 ms(s){return typeof s=="string"&&hf.test(s)}var _e=[];for(var Qs=0;Qs<256;++Qs)_e.push((Qs+256).toString(16).substr(1));function ys(s){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,e=(_e[s[t+0]]+_e[s[t+1]]+_e[s[t+2]]+_e[s[t+3]]+"-"+_e[s[t+4]]+_e[s[t+5]]+"-"+_e[s[t+6]]+_e[s[t+7]]+"-"+_e[s[t+8]]+_e[s[t+9]]+"-"+_e[s[t+10]]+_e[s[t+11]]+_e[s[t+12]]+_e[s[t+13]]+_e[s[t+14]]+_e[s[t+15]]).toLowerCase();if(!ms(e))throw TypeError("Stringified UUID is invalid");return e}var Ao,ti,ei=0,ni=0;function df(s,t,e){var n=t&&e||0,i=t||new Array(16);s=s||{};var r=s.node||Ao,o=s.clockseq!==void 0?s.clockseq:ti;if(r==null||o==null){var a=s.random||(s.rng||rc)();r==null&&(r=Ao=[a[0]|1,a[1],a[2],a[3],a[4],a[5]]),o==null&&(o=ti=(a[6]<<8|a[7])&16383)}var u=s.msecs!==void 0?s.msecs:Date.now(),g=s.nsecs!==void 0?s.nsecs:ni+1,x=u-ei+(g-ni)/1e4;if(x<0&&s.clockseq===void 0&&(o=o+1&16383),(x<0||u>ei)&&s.nsecs===void 0&&(g=0),g>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");ei=u,ni=g,ti=o,u+=122192928e5;var B=((u&268435455)*1e4+g)%4294967296;i[n++]=B>>>24&255,i[n++]=B>>>16&255,i[n++]=B>>>8&255,i[n++]=B&255;var I=u/4294967296*1e4&268435455;i[n++]=I>>>8&255,i[n++]=I&255,i[n++]=I>>>24&15|16,i[n++]=I>>>16&255,i[n++]=o>>>8|128,i[n++]=o&255;for(var v=0;v<6;++v)i[n+v]=r[v];return t||ys(i)}function sc(s){if(!ms(s))throw TypeError("Invalid UUID");var t,e=new Uint8Array(16);return e[0]=(t=parseInt(s.slice(0,8),16))>>>24,e[1]=t>>>16&255,e[2]=t>>>8&255,e[3]=t&255,e[4]=(t=parseInt(s.slice(9,13),16))>>>8,e[5]=t&255,e[6]=(t=parseInt(s.slice(14,18),16))>>>8,e[7]=t&255,e[8]=(t=parseInt(s.slice(19,23),16))>>>8,e[9]=t&255,e[10]=(t=parseInt(s.slice(24,36),16))/1099511627776&255,e[11]=t/4294967296&255,e[12]=t>>>24&255,e[13]=t>>>16&255,e[14]=t>>>8&255,e[15]=t&255,e}function pf(s){s=unescape(encodeURIComponent(s));for(var t=[],e=0;e<s.length;++e)t.push(s.charCodeAt(e));return t}var gf="6ba7b810-9dad-11d1-80b4-00c04fd430c8",mf="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function ic(s,t,e){function n(i,r,o,a){if(typeof i=="string"&&(i=pf(i)),typeof r=="string"&&(r=sc(r)),r.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var u=new Uint8Array(16+i.length);if(u.set(r),u.set(i,r.length),u=e(u),u[6]=u[6]&15|t,u[8]=u[8]&63|128,o){a=a||0;for(var g=0;g<16;++g)o[a+g]=u[g];return o}return ys(u)}try{n.name=s}catch{}return n.DNS=gf,n.URL=mf,n}function yf(s){if(typeof s=="string"){var t=unescape(encodeURIComponent(s));s=new Uint8Array(t.length);for(var e=0;e<t.length;++e)s[e]=t.charCodeAt(e)}return wf(bf(Sf(s),s.length*8))}function wf(s){for(var t=[],e=s.length*32,n="0123456789abcdef",i=0;i<e;i+=8){var r=s[i>>5]>>>i%32&255,o=parseInt(n.charAt(r>>>4&15)+n.charAt(r&15),16);t.push(o)}return t}function oc(s){return(s+64>>>9<<4)+14+1}function bf(s,t){s[t>>5]|=128<<t%32,s[oc(t)-1]=t;for(var e=1732584193,n=-271733879,i=-1732584194,r=271733878,o=0;o<s.length;o+=16){var a=e,u=n,g=i,x=r;e=Ae(e,n,i,r,s[o],7,-680876936),r=Ae(r,e,n,i,s[o+1],12,-389564586),i=Ae(i,r,e,n,s[o+2],17,606105819),n=Ae(n,i,r,e,s[o+3],22,-1044525330),e=Ae(e,n,i,r,s[o+4],7,-176418897),r=Ae(r,e,n,i,s[o+5],12,1200080426),i=Ae(i,r,e,n,s[o+6],17,-1473231341),n=Ae(n,i,r,e,s[o+7],22,-45705983),e=Ae(e,n,i,r,s[o+8],7,1770035416),r=Ae(r,e,n,i,s[o+9],12,-1958414417),i=Ae(i,r,e,n,s[o+10],17,-42063),n=Ae(n,i,r,e,s[o+11],22,-1990404162),e=Ae(e,n,i,r,s[o+12],7,1804603682),r=Ae(r,e,n,i,s[o+13],12,-40341101),i=Ae(i,r,e,n,s[o+14],17,-1502002290),n=Ae(n,i,r,e,s[o+15],22,1236535329),e=Ie(e,n,i,r,s[o+1],5,-165796510),r=Ie(r,e,n,i,s[o+6],9,-1069501632),i=Ie(i,r,e,n,s[o+11],14,643717713),n=Ie(n,i,r,e,s[o],20,-373897302),e=Ie(e,n,i,r,s[o+5],5,-701558691),r=Ie(r,e,n,i,s[o+10],9,38016083),i=Ie(i,r,e,n,s[o+15],14,-660478335),n=Ie(n,i,r,e,s[o+4],20,-405537848),e=Ie(e,n,i,r,s[o+9],5,568446438),r=Ie(r,e,n,i,s[o+14],9,-1019803690),i=Ie(i,r,e,n,s[o+3],14,-187363961),n=Ie(n,i,r,e,s[o+8],20,1163531501),e=Ie(e,n,i,r,s[o+13],5,-1444681467),r=Ie(r,e,n,i,s[o+2],9,-51403784),i=Ie(i,r,e,n,s[o+7],14,1735328473),n=Ie(n,i,r,e,s[o+12],20,-1926607734),e=Re(e,n,i,r,s[o+5],4,-378558),r=Re(r,e,n,i,s[o+8],11,-2022574463),i=Re(i,r,e,n,s[o+11],16,1839030562),n=Re(n,i,r,e,s[o+14],23,-35309556),e=Re(e,n,i,r,s[o+1],4,-1530992060),r=Re(r,e,n,i,s[o+4],11,1272893353),i=Re(i,r,e,n,s[o+7],16,-155497632),n=Re(n,i,r,e,s[o+10],23,-1094730640),e=Re(e,n,i,r,s[o+13],4,681279174),r=Re(r,e,n,i,s[o],11,-358537222),i=Re(i,r,e,n,s[o+3],16,-722521979),n=Re(n,i,r,e,s[o+6],23,76029189),e=Re(e,n,i,r,s[o+9],4,-640364487),r=Re(r,e,n,i,s[o+12],11,-421815835),i=Re(i,r,e,n,s[o+15],16,530742520),n=Re(n,i,r,e,s[o+2],23,-995338651),e=Me(e,n,i,r,s[o],6,-198630844),r=Me(r,e,n,i,s[o+7],10,1126891415),i=Me(i,r,e,n,s[o+14],15,-1416354905),n=Me(n,i,r,e,s[o+5],21,-57434055),e=Me(e,n,i,r,s[o+12],6,1700485571),r=Me(r,e,n,i,s[o+3],10,-1894986606),i=Me(i,r,e,n,s[o+10],15,-1051523),n=Me(n,i,r,e,s[o+1],21,-2054922799),e=Me(e,n,i,r,s[o+8],6,1873313359),r=Me(r,e,n,i,s[o+15],10,-30611744),i=Me(i,r,e,n,s[o+6],15,-1560198380),n=Me(n,i,r,e,s[o+13],21,1309151649),e=Me(e,n,i,r,s[o+4],6,-145523070),r=Me(r,e,n,i,s[o+11],10,-1120210379),i=Me(i,r,e,n,s[o+2],15,718787259),n=Me(n,i,r,e,s[o+9],21,-343485551),e=_n(e,a),n=_n(n,u),i=_n(i,g),r=_n(r,x)}return[e,n,i,r]}function Sf(s){if(s.length===0)return[];for(var t=s.length*8,e=new Uint32Array(oc(t)),n=0;n<t;n+=8)e[n>>5]|=(s[n/8]&255)<<n%32;return e}function _n(s,t){var e=(s&65535)+(t&65535),n=(s>>16)+(t>>16)+(e>>16);return n<<16|e&65535}function vf(s,t){return s<<t|s>>>32-t}function ws(s,t,e,n,i,r){return _n(vf(_n(_n(t,s),_n(n,r)),i),e)}function Ae(s,t,e,n,i,r,o){return ws(t&e|~t&n,s,t,i,r,o)}function Ie(s,t,e,n,i,r,o){return ws(t&n|e&~n,s,t,i,r,o)}function Re(s,t,e,n,i,r,o){return ws(t^e^n,s,t,i,r,o)}function Me(s,t,e,n,i,r,o){return ws(e^(t|~n),s,t,i,r,o)}var xf=ic("v3",48,yf);function _f(s,t,e){s=s||{};var n=s.random||(s.rng||rc)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){e=e||0;for(var i=0;i<16;++i)t[e+i]=n[i];return t}return ys(n)}function kf(s,t,e,n){switch(s){case 0:return t&e^~t&n;case 1:return t^e^n;case 2:return t&e^t&n^e&n;case 3:return t^e^n}}function ri(s,t){return s<<t|s>>>32-t}function Ef(s){var t=[1518500249,1859775393,2400959708,3395469782],e=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof s=="string"){var n=unescape(encodeURIComponent(s));s=[];for(var i=0;i<n.length;++i)s.push(n.charCodeAt(i))}else Array.isArray(s)||(s=Array.prototype.slice.call(s));s.push(128);for(var r=s.length/4+2,o=Math.ceil(r/16),a=new Array(o),u=0;u<o;++u){for(var g=new Uint32Array(16),x=0;x<16;++x)g[x]=s[u*64+x*4]<<24|s[u*64+x*4+1]<<16|s[u*64+x*4+2]<<8|s[u*64+x*4+3];a[u]=g}a[o-1][14]=(s.length-1)*8/Math.pow(2,32),a[o-1][14]=Math.floor(a[o-1][14]),a[o-1][15]=(s.length-1)*8&4294967295;for(var B=0;B<o;++B){for(var I=new Uint32Array(80),v=0;v<16;++v)I[v]=a[B][v];for(var E=16;E<80;++E)I[E]=ri(I[E-3]^I[E-8]^I[E-14]^I[E-16],1);for(var R=e[0],T=e[1],N=e[2],W=e[3],D=e[4],X=0;X<80;++X){var nt=Math.floor(X/20),at=ri(R,5)+kf(nt,T,N,W)+D+t[nt]+I[X]>>>0;D=W,W=N,N=ri(T,30)>>>0,T=R,R=at}e[0]=e[0]+R>>>0,e[1]=e[1]+T>>>0,e[2]=e[2]+N>>>0,e[3]=e[3]+W>>>0,e[4]=e[4]+D>>>0}return[e[0]>>24&255,e[0]>>16&255,e[0]>>8&255,e[0]&255,e[1]>>24&255,e[1]>>16&255,e[1]>>8&255,e[1]&255,e[2]>>24&255,e[2]>>16&255,e[2]>>8&255,e[2]&255,e[3]>>24&255,e[3]>>16&255,e[3]>>8&255,e[3]&255,e[4]>>24&255,e[4]>>16&255,e[4]>>8&255,e[4]&255]}var Bf=ic("v5",80,Ef);const Af="00000000-0000-0000-0000-000000000000";function If(s){if(!ms(s))throw TypeError("Invalid UUID");return parseInt(s.substr(14,1),16)}const Rf=Object.freeze(Object.defineProperty({__proto__:null,NIL:Af,parse:sc,stringify:ys,v1:df,v3:xf,v4:_f,v5:Bf,validate:ms,version:If},Symbol.toStringTag,{value:"Module"})),bs=Ri(Rf),Mf=bs.v4,Tf=function(s,t,e,n){if(typeof s!="string")throw new TypeError(s+" must be a string");n=n||{};const i=typeof n.version=="number"?n.version:2;if(i!==1&&i!==2)throw new TypeError(i+" must be 1 or 2");const r={method:s};if(i===2&&(r.jsonrpc="2.0"),t){if(typeof t!="object"&&!Array.isArray(t))throw new TypeError(t+" must be an object, array or omitted");r.params=t}if(typeof e>"u"){const o=typeof n.generator=="function"?n.generator:function(){return Mf()};r.id=o(r,n)}else i===2&&e===null?n.notificationIdNull&&(r.id=null):r.id=e;return r};var Cf=Tf;const Lf=bs.v4,Uf=Cf,_r=function(s,t){if(!(this instanceof _r))return new _r(s,t);t||(t={}),this.options={reviver:typeof t.reviver<"u"?t.reviver:null,replacer:typeof t.replacer<"u"?t.replacer:null,generator:typeof t.generator<"u"?t.generator:function(){return Lf()},version:typeof t.version<"u"?t.version:2,notificationIdNull:typeof t.notificationIdNull=="boolean"?t.notificationIdNull:!1},this.callServer=s};var Nf=_r;_r.prototype.request=function(s,t,e,n){const i=this;let r=null;const o=Array.isArray(s)&&typeof t=="function";if(this.options.version===1&&o)throw new TypeError("JSON-RPC 1.0 does not support batching");if(o||!o&&s&&typeof s=="object"&&typeof t=="function")n=t,r=s;else{typeof e=="function"&&(n=e,e=void 0);const g=typeof n=="function";try{r=Uf(s,t,e,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(x){if(g){n(x);return}throw x}if(!g)return r}let u;try{u=JSON.stringify(r,this.options.replacer)}catch(g){n(g);return}return this.callServer(u,function(g,x){i._parseResponse(g,x,n)}),r};_r.prototype._parseResponse=function(s,t,e){if(s){e(s);return}if(!t){e();return}let n;try{n=JSON.parse(t,this.options.reviver)}catch(i){e(i);return}if(e.length===3)if(Array.isArray(n)){const i=function(o){return typeof o.error<"u"},r=function(o){return!i(o)};e(null,n.filter(i),n.filter(r));return}else{e(null,n.error,n.result);return}e(null,n)};const Pf=Ir(Nf);var ac={exports:{}};(function(s){var t=Object.prototype.hasOwnProperty,e="~";function n(){}Object.create&&(n.prototype=Object.create(null),new n().__proto__||(e=!1));function i(u,g,x){this.fn=u,this.context=g,this.once=x||!1}function r(u,g,x,B,I){if(typeof x!="function")throw new TypeError("The listener must be a function");var v=new i(x,B||u,I),E=e?e+g:g;return u._events[E]?u._events[E].fn?u._events[E]=[u._events[E],v]:u._events[E].push(v):(u._events[E]=v,u._eventsCount++),u}function o(u,g){--u._eventsCount===0?u._events=new n:delete u._events[g]}function a(){this._events=new n,this._eventsCount=0}a.prototype.eventNames=function(){var g=[],x,B;if(this._eventsCount===0)return g;for(B in x=this._events)t.call(x,B)&&g.push(e?B.slice(1):B);return Object.getOwnPropertySymbols?g.concat(Object.getOwnPropertySymbols(x)):g},a.prototype.listeners=function(g){var x=e?e+g:g,B=this._events[x];if(!B)return[];if(B.fn)return[B.fn];for(var I=0,v=B.length,E=new Array(v);I<v;I++)E[I]=B[I].fn;return E},a.prototype.listenerCount=function(g){var x=e?e+g:g,B=this._events[x];return B?B.fn?1:B.length:0},a.prototype.emit=function(g,x,B,I,v,E){var R=e?e+g:g;if(!this._events[R])return!1;var T=this._events[R],N=arguments.length,W,D;if(T.fn){switch(T.once&&this.removeListener(g,T.fn,void 0,!0),N){case 1:return T.fn.call(T.context),!0;case 2:return T.fn.call(T.context,x),!0;case 3:return T.fn.call(T.context,x,B),!0;case 4:return T.fn.call(T.context,x,B,I),!0;case 5:return T.fn.call(T.context,x,B,I,v),!0;case 6:return T.fn.call(T.context,x,B,I,v,E),!0}for(D=1,W=new Array(N-1);D<N;D++)W[D-1]=arguments[D];T.fn.apply(T.context,W)}else{var X=T.length,nt;for(D=0;D<X;D++)switch(T[D].once&&this.removeListener(g,T[D].fn,void 0,!0),N){case 1:T[D].fn.call(T[D].context);break;case 2:T[D].fn.call(T[D].context,x);break;case 3:T[D].fn.call(T[D].context,x,B);break;case 4:T[D].fn.call(T[D].context,x,B,I);break;default:if(!W)for(nt=1,W=new Array(N-1);nt<N;nt++)W[nt-1]=arguments[nt];T[D].fn.apply(T[D].context,W)}}return!0},a.prototype.on=function(g,x,B){return r(this,g,x,B,!1)},a.prototype.once=function(g,x,B){return r(this,g,x,B,!0)},a.prototype.removeListener=function(g,x,B,I){var v=e?e+g:g;if(!this._events[v])return this;if(!x)return o(this,v),this;var E=this._events[v];if(E.fn)E.fn===x&&(!I||E.once)&&(!B||E.context===B)&&o(this,v);else{for(var R=0,T=[],N=E.length;R<N;R++)(E[R].fn!==x||I&&!E[R].once||B&&E[R].context!==B)&&T.push(E[R]);T.length?this._events[v]=T.length===1?T[0]:T:o(this,v)}return this},a.prototype.removeAllListeners=function(g){var x;return g?(x=e?e+g:g,this._events[x]&&o(this,x)):(this._events=new n,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=e,a.EventEmitter=a,s.exports=a})(ac);var Ff=ac.exports;const cc=Ir(Ff);var Of=class extends cc{constructor(t,e){super();ye(this,"socket");this.socket=new window.WebSocket(t,e.protocols),this.socket.onopen=()=>this.emit("open"),this.socket.onmessage=n=>this.emit("message",n.data),this.socket.onerror=n=>this.emit("error",n),this.socket.onclose=n=>{this.emit("close",n.code,n.reason)}}send(t,e,n){const i=n||e;try{this.socket.send(t),i()}catch(r){i(r)}}close(t,e){this.socket.close(t,e)}addEventListener(t,e,n){this.socket.addEventListener(t,e,n)}};function uc(s,t){return new Of(s,t)}var $f=class{encode(s){return JSON.stringify(s)}decode(s){return JSON.parse(s)}},lc=class extends cc{constructor(t,e="ws://localhost:8080",{autoconnect:n=!0,reconnect:i=!0,reconnect_interval:r=1e3,max_reconnects:o=5,...a}={},u,g){super();ye(this,"address");ye(this,"rpc_id");ye(this,"queue");ye(this,"options");ye(this,"autoconnect");ye(this,"ready");ye(this,"reconnect");ye(this,"reconnect_timer_id");ye(this,"reconnect_interval");ye(this,"max_reconnects");ye(this,"rest_options");ye(this,"current_reconnects");ye(this,"generate_request_id");ye(this,"socket");ye(this,"webSocketFactory");ye(this,"dataPack");this.webSocketFactory=t,this.queue={},this.rpc_id=0,this.address=e,this.autoconnect=n,this.ready=!1,this.reconnect=i,this.reconnect_timer_id=void 0,this.reconnect_interval=r,this.max_reconnects=o,this.rest_options=a,this.current_reconnects=0,this.generate_request_id=u||(()=>typeof this.rpc_id=="number"?++this.rpc_id:Number(this.rpc_id)+1),g?this.dataPack=g:this.dataPack=new $f,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(t,e,n,i){return!i&&typeof n=="object"&&(i=n,n=null),new Promise((r,o)=>{if(!this.ready)return o(new Error("socket not ready"));const a=this.generate_request_id(t,e),u={jsonrpc:"2.0",method:t,params:e||void 0,id:a};this.socket.send(this.dataPack.encode(u),i,g=>{if(g)return o(g);this.queue[a]={promise:[r,o]},n&&(this.queue[a].timeout=setTimeout(()=>{delete this.queue[a],o(new Error("reply timeout"))},n))})})}async login(t){const e=await this.call("rpc.login",t);if(!e)throw new Error("authentication failed");return e}async listMethods(){return await this.call("__listMethods")}notify(t,e){return new Promise((n,i)=>{if(!this.ready)return i(new Error("socket not ready"));const r={jsonrpc:"2.0",method:t,params:e};this.socket.send(this.dataPack.encode(r),o=>{if(o)return i(o);n()})})}async subscribe(t){typeof t=="string"&&(t=[t]);const e=await this.call("rpc.on",t);if(typeof t=="string"&&e[t]!=="ok")throw new Error("Failed subscribing to an event '"+t+"' with: "+e[t]);return e}async unsubscribe(t){typeof t=="string"&&(t=[t]);const e=await this.call("rpc.off",t);if(typeof t=="string"&&e[t]!=="ok")throw new Error("Failed unsubscribing from an event with: "+e);return e}close(t,e){this.socket&&this.socket.close(t||1e3,e)}setAutoReconnect(t){this.reconnect=t}setReconnectInterval(t){this.reconnect_interval=t}setMaxReconnects(t){this.max_reconnects=t}getCurrentReconnects(){return this.current_reconnects}getMaxReconnects(){return this.max_reconnects}isReconnecting(){return this.reconnect_timer_id!==void 0}willReconnect(){return this.reconnect&&(this.max_reconnects===0||this.current_reconnects<this.max_reconnects)}_connect(t,e){clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(t,e),this.socket.addEventListener("open",()=>{this.ready=!0,this.emit("open"),this.current_reconnects=0}),this.socket.addEventListener("message",({data:n})=>{n instanceof ArrayBuffer&&(n=Y.Buffer.from(n).toString());try{n=this.dataPack.decode(n)}catch{return}if(n.notification&&this.listeners(n.notification).length){if(!Object.keys(n.params).length)return this.emit(n.notification);const i=[n.notification];if(n.params.constructor===Object)i.push(n.params);else for(let r=0;r<n.params.length;r++)i.push(n.params[r]);return Promise.resolve().then(()=>{this.emit.apply(this,i)})}if(!this.queue[n.id])return n.method?Promise.resolve().then(()=>{this.emit(n.method,n==null?void 0:n.params)}):void 0;"error"in n=="result"in n&&this.queue[n.id].promise[1](new Error('Server response malformed. Response must include either "result" or "error", but not both.')),this.queue[n.id].timeout&&clearTimeout(this.queue[n.id].timeout),n.error?this.queue[n.id].promise[1](n.error):this.queue[n.id].promise[0](n.result),delete this.queue[n.id]}),this.socket.addEventListener("error",n=>this.emit("error",n)),this.socket.addEventListener("close",({code:n,reason:i})=>{this.ready&&setTimeout(()=>this.emit("close",n,i),0),this.ready=!1,this.socket=void 0,n!==1e3&&(this.current_reconnects++,this.reconnect&&(this.max_reconnects>this.current_reconnects||this.max_reconnects===0)?this.reconnect_timer_id=setTimeout(()=>this._connect(t,e),this.reconnect_interval):this.reconnect&&this.max_reconnects>0&&this.current_reconnects>=this.max_reconnects&&setTimeout(()=>this.emit("max_reconnects_reached",n,i),1))})}};class fc extends ra{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,ea(t);const n=Ti(e);if(this.iHash=t.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 i=this.blockLen,r=new Uint8Array(i);r.set(n.length>i?t.create().update(n).digest():n);for(let o=0;o<r.length;o++)r[o]^=54;this.iHash.update(r),this.oHash=t.create();for(let o=0;o<r.length;o++)r[o]^=106;this.oHash.update(r),sr(r)}update(t){return Vr(this),this.iHash.update(t),this}digestInto(t){Vr(this),Un(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:n,finished:i,destroyed:r,blockLen:o,outputLen:a}=this;return t=t,t.finished=i,t.destroyed=r,t.blockLen=o,t.outputLen=a,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const hc=(s,t,e)=>new fc(s,t).update(e).digest();hc.create=(s,t)=>new fc(s,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Io=(s,t)=>(s+(s>=0?t:-t)/dc)/t;function qf(s,t,e){const[[n,i],[r,o]]=t,a=Io(o*s,e),u=Io(-i*s,e);let g=s-a*n-u*r,x=-a*i-u*o;const B=g<dn,I=x<dn;B&&(g=-g),I&&(x=-x);const v=Mr(Math.ceil(la(e)/2))+er;if(g<dn||g>=v||x<dn||x>=v)throw new Error("splitScalar (endomorphism): failed, k="+s);return{k1neg:B,k1:g,k2neg:I,k2:x}}function wi(s){if(!["compact","recovered","der"].includes(s))throw new Error('Signature format must be "compact", "recovered", or "der"');return s}function si(s,t){const e={};for(let n of Object.keys(t))e[n]=s[n]===void 0?t[n]:s[n];return Ln(e.lowS,"lowS"),Ln(e.prehash,"prehash"),e.format!==void 0&&wi(e.format),e}class Kf extends Error{constructor(t=""){super(t)}}const un={Err:Kf,_tlv:{encode:(s,t)=>{const{Err:e}=un;if(s<0||s>256)throw new e("tlv.encode: wrong tag");if(t.length&1)throw new e("tlv.encode: unpadded data");const n=t.length/2,i=$r(n);if(i.length/2&128)throw new e("tlv.encode: long form length too big");const r=n>127?$r(i.length/2|128):"";return $r(s)+r+i+t},decode(s,t){const{Err:e}=un;let n=0;if(s<0||s>256)throw new e("tlv.encode: wrong tag");if(t.length<2||t[n++]!==s)throw new e("tlv.decode: wrong tlv");const i=t[n++],r=!!(i&128);let o=0;if(!r)o=i;else{const u=i&127;if(!u)throw new e("tlv.decode(long): indefinite length not supported");if(u>4)throw new e("tlv.decode(long): byte length is too big");const g=t.subarray(n,n+u);if(g.length!==u)throw new e("tlv.decode: length bytes not complete");if(g[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(const x of g)o=o<<8|x;if(n+=u,o<128)throw new e("tlv.decode(long): not minimal encoding")}const a=t.subarray(n,n+o);if(a.length!==o)throw new e("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+o)}}},_int:{encode(s){const{Err:t}=un;if(s<dn)throw new t("integer: negative integers are not allowed");let e=$r(s);if(Number.parseInt(e[0],16)&8&&(e="00"+e),e.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return e},decode(s){const{Err:t}=un;if(s[0]&128)throw new t("invalid signature integer: negative");if(s[0]===0&&!(s[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return fs(s)}},toSig(s){const{Err:t,_int:e,_tlv:n}=un,i=Xt("signature",s),{v:r,l:o}=n.decode(48,i);if(o.length)throw new t("invalid signature: left bytes after parsing");const{v:a,l:u}=n.decode(2,r),{v:g,l:x}=n.decode(2,u);if(x.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(a),s:e.decode(g)}},hexFromSig(s){const{_tlv:t,_int:e}=un,n=t.encode(2,e.encode(s.r)),i=t.encode(2,e.encode(s.s)),r=n+i;return t.encode(48,r)}},dn=BigInt(0),er=BigInt(1),dc=BigInt(2),Dr=BigInt(3),Df=BigInt(4);function Xn(s,t){const{BYTES:e}=s;let n;if(typeof t=="bigint")n=t;else{let i=Xt("private key",t);try{n=s.fromBytes(i)}catch{throw new Error(`invalid private key: expected ui8a of size ${e}, got ${typeof t}`)}}if(!s.isValidNot0(n))throw new Error("invalid private key: out of range [1..N-1]");return n}function zf(s,t={}){const e=Ba("weierstrass",s,t),{Fp:n,Fn:i}=e;let r=e.CURVE;const{h:o,n:a}=r;Tr(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:u}=t;if(u&&(!n.is0(r.a)||typeof u.beta!="bigint"||!Array.isArray(u.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const g=gc(n,i);function x(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function B(et,y,c){const{x:d,y:p}=y.toAffine(),S=n.toBytes(d);if(Ln(c,"isCompressed"),c){x();const k=!n.isOdd(p);return tn(pc(k),S)}else return tn(Uint8Array.of(4),S,n.toBytes(p))}function I(et){Ge(et,void 0,"Point");const{publicKey:y,publicKeyUncompressed:c}=g,d=et.length,p=et[0],S=et.subarray(1);if(d===y&&(p===2||p===3)){const k=n.fromBytes(S);if(!n.isValid(k))throw new Error("bad point: is not on curve, wrong x");const M=R(k);let C;try{C=n.sqrt(M)}catch(A){const J=A instanceof Error?": "+A.message:"";throw new Error("bad point: is not on curve, sqrt error"+J)}x();const w=n.isOdd(C);return(p&1)===1!==w&&(C=n.neg(C)),{x:k,y:C}}else if(d===c&&p===4){const k=n.BYTES,M=n.fromBytes(S.subarray(0,k)),C=n.fromBytes(S.subarray(k,k*2));if(!T(M,C))throw new Error("bad point: is not on curve");return{x:M,y:C}}else throw new Error(`bad point: got length ${d}, expected compressed=${y} or uncompressed=${c}`)}const v=t.toBytes||B,E=t.fromBytes||I;function R(et){const y=n.sqr(et),c=n.mul(y,et);return n.add(n.add(c,n.mul(et,r.a)),r.b)}function T(et,y){const c=n.sqr(y),d=R(et);return n.eql(c,d)}if(!T(r.Gx,r.Gy))throw new Error("bad curve params: generator point");const N=n.mul(n.pow(r.a,Dr),Df),W=n.mul(n.sqr(r.b),BigInt(27));if(n.is0(n.add(N,W)))throw new Error("bad curve params: a or b");function D(et,y,c=!1){if(!n.isValid(y)||c&&n.is0(y))throw new Error(`bad point coordinate ${et}`);return y}function X(et){if(!(et instanceof j))throw new Error("ProjectivePoint expected")}function nt(et){if(!u||!u.basises)throw new Error("no endo");return qf(et,u.basises,i.ORDER)}const at=Zr((et,y)=>{const{X:c,Y:d,Z:p}=et;if(n.eql(p,n.ONE))return{x:c,y:d};const S=et.is0();y==null&&(y=S?n.ONE:n.inv(p));const k=n.mul(c,y),M=n.mul(d,y),C=n.mul(p,y);if(S)return{x:n.ZERO,y:n.ZERO};if(!n.eql(C,n.ONE))throw new Error("invZ was invalid");return{x:k,y:M}}),ht=Zr(et=>{if(et.is0()){if(t.allowInfinityPoint&&!n.is0(et.Y))return;throw new Error("bad point: ZERO")}const{x:y,y:c}=et.toAffine();if(!n.isValid(y)||!n.isValid(c))throw new Error("bad point: x or y not field elements");if(!T(y,c))throw new Error("bad point: equation left != right");if(!et.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function ut(et,y,c,d,p){return c=new j(n.mul(c.X,et),c.Y,c.Z),y=Yr(d,y),c=Yr(p,c),y.add(c)}class j{constructor(y,c,d){this.X=D("x",y),this.Y=D("y",c,!0),this.Z=D("z",d),Object.freeze(this)}static CURVE(){return r}static fromAffine(y){const{x:c,y:d}=y||{};if(!y||!n.isValid(c)||!n.isValid(d))throw new Error("invalid affine point");if(y instanceof j)throw new Error("projective point not allowed");return n.is0(c)&&n.is0(d)?j.ZERO:new j(c,d,n.ONE)}static fromBytes(y){const c=j.fromAffine(E(Ge(y,void 0,"point")));return c.assertValidity(),c}static fromHex(y){return j.fromBytes(Xt("pointHex",y))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(y=8,c=!0){return Q.createCache(this,y),c||this.multiply(Dr),this}assertValidity(){ht(this)}hasEvenY(){const{y}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(y)}equals(y){X(y);const{X:c,Y:d,Z:p}=this,{X:S,Y:k,Z:M}=y,C=n.eql(n.mul(c,M),n.mul(S,p)),w=n.eql(n.mul(d,M),n.mul(k,p));return C&&w}negate(){return new j(this.X,n.neg(this.Y),this.Z)}double(){const{a:y,b:c}=r,d=n.mul(c,Dr),{X:p,Y:S,Z:k}=this;let M=n.ZERO,C=n.ZERO,w=n.ZERO,f=n.mul(p,p),A=n.mul(S,S),J=n.mul(k,k),Z=n.mul(p,S);return Z=n.add(Z,Z),w=n.mul(p,k),w=n.add(w,w),M=n.mul(y,w),C=n.mul(d,J),C=n.add(M,C),M=n.sub(A,C),C=n.add(A,C),C=n.mul(M,C),M=n.mul(Z,M),w=n.mul(d,w),J=n.mul(y,J),Z=n.sub(f,J),Z=n.mul(y,Z),Z=n.add(Z,w),w=n.add(f,f),f=n.add(w,f),f=n.add(f,J),f=n.mul(f,Z),C=n.add(C,f),J=n.mul(S,k),J=n.add(J,J),f=n.mul(J,Z),M=n.sub(M,f),w=n.mul(J,A),w=n.add(w,w),w=n.add(w,w),new j(M,C,w)}add(y){X(y);const{X:c,Y:d,Z:p}=this,{X:S,Y:k,Z:M}=y;let C=n.ZERO,w=n.ZERO,f=n.ZERO;const A=r.a,J=n.mul(r.b,Dr);let Z=n.mul(c,S),tt=n.mul(d,k),xt=n.mul(p,M),dt=n.add(c,d),ct=n.add(S,k);dt=n.mul(dt,ct),ct=n.add(Z,tt),dt=n.sub(dt,ct),ct=n.add(c,p);let Wt=n.add(S,M);return ct=n.mul(ct,Wt),Wt=n.add(Z,xt),ct=n.sub(ct,Wt),Wt=n.add(d,p),C=n.add(k,M),Wt=n.mul(Wt,C),C=n.add(tt,xt),Wt=n.sub(Wt,C),f=n.mul(A,ct),C=n.mul(J,xt),f=n.add(C,f),C=n.sub(tt,f),f=n.add(tt,f),w=n.mul(C,f),tt=n.add(Z,Z),tt=n.add(tt,Z),xt=n.mul(A,xt),ct=n.mul(J,ct),tt=n.add(tt,xt),xt=n.sub(Z,xt),xt=n.mul(A,xt),ct=n.add(ct,xt),Z=n.mul(tt,ct),w=n.add(w,Z),Z=n.mul(Wt,ct),C=n.mul(dt,C),C=n.sub(C,Z),Z=n.mul(dt,tt),f=n.mul(Wt,f),f=n.add(f,Z),new j(C,w,f)}subtract(y){return this.add(y.negate())}is0(){return this.equals(j.ZERO)}multiply(y){const{endo:c}=t;if(!i.isValidNot0(y))throw new Error("invalid scalar: out of range");let d,p;const S=k=>Q.cached(this,k,M=>Tn(j,M));if(c){const{k1neg:k,k1:M,k2neg:C,k2:w}=nt(y),{p:f,f:A}=S(M),{p:J,f:Z}=S(w);p=A.add(Z),d=ut(c.beta,f,J,k,C)}else{const{p:k,f:M}=S(y);d=k,p=M}return Tn(j,[d,p])[0]}multiplyUnsafe(y){const{endo:c}=t,d=this;if(!i.isValid(y))throw new Error("invalid scalar: out of range");if(y===dn||d.is0())return j.ZERO;if(y===er)return d;if(Q.hasCache(this))return this.multiply(y);if(c){const{k1neg:p,k1:S,k2neg:k,k2:M}=nt(y),{p1:C,p2:w}=Xu(j,d,S,M);return ut(c.beta,C,w,p,k)}else return Q.unsafe(d,y)}multiplyAndAddUnsafe(y,c,d){const p=this.multiplyUnsafe(c).add(y.multiplyUnsafe(d));return p.is0()?void 0:p}toAffine(y){return at(this,y)}isTorsionFree(){const{isTorsionFree:y}=t;return o===er?!0:y?y(j,this):Q.unsafe(this,a).is0()}clearCofactor(){const{clearCofactor:y}=t;return o===er?this:y?y(j,this):this.multiplyUnsafe(o)}isSmallOrder(){return this.multiplyUnsafe(o).is0()}toBytes(y=!0){return Ln(y,"isCompressed"),this.assertValidity(),v(j,this,y)}toHex(y=!0){return Cn(this.toBytes(y))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(y=!0){return this.toBytes(y)}_setWindowSize(y){this.precompute(y)}static normalizeZ(y){return Tn(j,y)}static msm(y,c){return Ea(j,i,y,c)}static fromPrivateKey(y){return j.BASE.multiply(Xn(i,y))}}j.BASE=new j(r.Gx,r.Gy,n.ONE),j.ZERO=new j(n.ZERO,n.ONE,n.ZERO),j.Fp=n,j.Fn=i;const rt=i.BITS,Q=new ka(j,t.endo?Math.ceil(rt/2):rt);return j.BASE.precompute(8),j}function pc(s){return Uint8Array.of(s?2:3)}function gc(s,t){return{secretKey:t.BYTES,publicKey:1+s.BYTES,publicKeyUncompressed:1+2*s.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function Hf(s,t={}){const{Fn:e}=s,n=t.randomBytes||Ci,i=Object.assign(gc(s.Fp,e),{seed:va(e.ORDER)});function r(v){try{return!!Xn(e,v)}catch{return!1}}function o(v,E){const{publicKey:R,publicKeyUncompressed:T}=i;try{const N=v.length;return E===!0&&N!==R||E===!1&&N!==T?!1:!!s.fromBytes(v)}catch{return!1}}function a(v=n(i.seed)){return Gu(Ge(v,i.seed,"seed"),e.ORDER)}function u(v,E=!0){return s.BASE.multiply(Xn(e,v)).toBytes(E)}function g(v){const E=a(v);return{secretKey:E,publicKey:u(E)}}function x(v){if(typeof v=="bigint")return!1;if(v instanceof s)return!0;const{secretKey:E,publicKey:R,publicKeyUncompressed:T}=i;if(e.allowedLengths||E===R)return;const N=Xt("key",v).length;return N===R||N===T}function B(v,E,R=!0){if(x(v)===!0)throw new Error("first arg must be private key");if(x(E)===!1)throw new Error("second arg must be public key");const T=Xn(e,v);return s.fromHex(E).multiply(T).toBytes(R)}return Object.freeze({getPublicKey:u,getSharedSecret:B,keygen:g,Point:s,utils:{isValidSecretKey:r,isValidPublicKey:o,randomSecretKey:a,isValidPrivateKey:r,randomPrivateKey:a,normPrivateKeyToScalar:v=>Xn(e,v),precompute(v=8,E=s.BASE){return E.precompute(v,!1)}},lengths:i})}function Wf(s,t,e={}){ea(t),Tr(e,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const n=e.randomBytes||Ci,i=e.hmac||((c,...d)=>hc(t,c,tn(...d))),{Fp:r,Fn:o}=s,{ORDER:a,BITS:u}=o,{keygen:g,getPublicKey:x,getSharedSecret:B,utils:I,lengths:v}=Hf(s,e),E={prehash:!1,lowS:typeof e.lowS=="boolean"?e.lowS:!1,format:void 0,extraEntropy:!1},R="compact";function T(c){const d=a>>er;return c>d}function N(c,d){if(!o.isValidNot0(d))throw new Error(`invalid signature ${c}: out of range 1..Point.Fn.ORDER`);return d}function W(c,d){wi(d);const p=v.signature,S=d==="compact"?p:d==="recovered"?p+1:void 0;return Ge(c,S,`${d} signature`)}class D{constructor(d,p,S){this.r=N("r",d),this.s=N("s",p),S!=null&&(this.recovery=S),Object.freeze(this)}static fromBytes(d,p=R){W(d,p);let S;if(p==="der"){const{r:w,s:f}=un.toSig(Ge(d));return new D(w,f)}p==="recovered"&&(S=d[0],p="compact",d=d.subarray(1));const k=o.BYTES,M=d.subarray(0,k),C=d.subarray(k,k*2);return new D(o.fromBytes(M),o.fromBytes(C),S)}static fromHex(d,p){return this.fromBytes(Gr(d),p)}addRecoveryBit(d){return new D(this.r,this.s,d)}recoverPublicKey(d){const p=r.ORDER,{r:S,s:k,recovery:M}=this;if(M==null||![0,1,2,3].includes(M))throw new Error("recovery id invalid");if(a*dc<p&&M>1)throw new Error("recovery id is ambiguous for h>1 curve");const w=M===2||M===3?S+a:S;if(!r.isValid(w))throw new Error("recovery id 2 or 3 invalid");const f=r.toBytes(w),A=s.fromBytes(tn(pc((M&1)===0),f)),J=o.inv(w),Z=nt(Xt("msgHash",d)),tt=o.create(-Z*J),xt=o.create(k*J),dt=s.BASE.multiplyUnsafe(tt).add(A.multiplyUnsafe(xt));if(dt.is0())throw new Error("point at infinify");return dt.assertValidity(),dt}hasHighS(){return T(this.s)}toBytes(d=R){if(wi(d),d==="der")return Gr(un.hexFromSig(this));const p=o.toBytes(this.r),S=o.toBytes(this.s);if(d==="recovered"){if(this.recovery==null)throw new Error("recovery bit must be present");return tn(Uint8Array.of(this.recovery),p,S)}return tn(p,S)}toHex(d){return Cn(this.toBytes(d))}assertValidity(){}static fromCompact(d){return D.fromBytes(Xt("sig",d),"compact")}static fromDER(d){return D.fromBytes(Xt("sig",d),"der")}normalizeS(){return this.hasHighS()?new D(this.r,o.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return Cn(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return Cn(this.toBytes("compact"))}}const X=e.bits2int||function(d){if(d.length>8192)throw new Error("input is too large");const p=fs(d),S=d.length*8-u;return S>0?p>>BigInt(S):p},nt=e.bits2int_modN||function(d){return o.create(X(d))},at=Mr(u);function ht(c){return gi("num < 2^"+u,c,dn,at),o.toBytes(c)}function ut(c,d){return Ge(c,void 0,"message"),d?Ge(t(c),void 0,"prehashed message"):c}function j(c,d,p){if(["recovered","canonical"].some(tt=>tt in p))throw new Error("sign() legacy options not supported");const{lowS:S,prehash:k,extraEntropy:M}=si(p,E);c=ut(c,k);const C=nt(c),w=Xn(o,d),f=[ht(w),ht(C)];if(M!=null&&M!==!1){const tt=M===!0?n(v.secretKey):M;f.push(Xt("extraEntropy",tt))}const A=tn(...f),J=C;function Z(tt){const xt=X(tt);if(!o.isValidNot0(xt))return;const dt=o.inv(xt),ct=s.BASE.multiply(xt).toAffine(),Wt=o.create(ct.x);if(Wt===dn)return;const Tt=o.create(dt*o.create(J+Wt*w));if(Tt===dn)return;let Ct=(ct.x===Wt?0:2)|Number(ct.y&er),Fe=Tt;return S&&T(Tt)&&(Fe=o.neg(Tt),Ct^=1),new D(Wt,Fe,Ct)}return{seed:A,k2sig:Z}}function rt(c,d,p={}){c=Xt("message",c);const{seed:S,k2sig:k}=j(c,d,p);return Ou(t.outputLen,o.BYTES,i)(S,k)}function Q(c){let d;const p=typeof c=="string"||Rr(c),S=!p&&c!==null&&typeof c=="object"&&typeof c.r=="bigint"&&typeof c.s=="bigint";if(!p&&!S)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(S)d=new D(c.r,c.s);else if(p){try{d=D.fromBytes(Xt("sig",c),"der")}catch(k){if(!(k instanceof un.Err))throw k}if(!d)try{d=D.fromBytes(Xt("sig",c),"compact")}catch{return!1}}return d||!1}function et(c,d,p,S={}){const{lowS:k,prehash:M,format:C}=si(S,E);if(p=Xt("publicKey",p),d=ut(Xt("message",d),M),"strict"in S)throw new Error("options.strict was renamed to lowS");const w=C===void 0?Q(c):D.fromBytes(Xt("sig",c),C);if(w===!1)return!1;try{const f=s.fromBytes(p);if(k&&w.hasHighS())return!1;const{r:A,s:J}=w,Z=nt(d),tt=o.inv(J),xt=o.create(Z*tt),dt=o.create(A*tt),ct=s.BASE.multiplyUnsafe(xt).add(f.multiplyUnsafe(dt));return ct.is0()?!1:o.create(ct.x)===A}catch{return!1}}function y(c,d,p={}){const{prehash:S}=si(p,E);return d=ut(d,S),D.fromBytes(c,"recovered").recoverPublicKey(d).toBytes()}return Object.freeze({keygen:g,getPublicKey:x,getSharedSecret:B,utils:I,lengths:v,Point:s,sign:rt,verify:et,recoverPublicKey:y,Signature:D,hash:t})}function jf(s){const t={a:s.a,b:s.b,p:s.Fp.ORDER,n:s.n,h:s.h,Gx:s.Gx,Gy:s.Gy},e=s.Fp;let n=s.allowedPrivateKeyLengths?Array.from(new Set(s.allowedPrivateKeyLengths.map(o=>Math.ceil(o/2)))):void 0;const i=Nn(t.n,{BITS:s.nBitLength,allowedLengths:n,modFromBytes:s.wrapPrivateKey}),r={Fp:e,Fn:i,allowInfinityPoint:s.allowInfinityPoint,endo:s.endo,isTorsionFree:s.isTorsionFree,clearCofactor:s.clearCofactor,fromBytes:s.fromBytes,toBytes:s.toBytes};return{CURVE:t,curveOpts:r}}function Vf(s){const{CURVE:t,curveOpts:e}=jf(s),n={hmac:s.hmac,randomBytes:s.randomBytes,lowS:s.lowS,bits2int:s.bits2int,bits2int_modN:s.bits2int_modN};return{CURVE:t,curveOpts:e,hash:s.hash,ecdsaOpts:n}}function Gf(s,t){const e=t.Point;return Object.assign({},t,{ProjectivePoint:e,CURVE:Object.assign({},s,ba(e.Fn.ORDER,e.Fn.BITS))})}function Zf(s){const{CURVE:t,curveOpts:e,hash:n,ecdsaOpts:i}=Vf(s),r=zf(t,e),o=Wf(r,n,i);return Gf(s,o)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Yf(s,t){const e=n=>Zf({...s,hash:n});return{...e(t),create:e}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Xi={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},Xf={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},Ro=BigInt(2);function Jf(s){const t=Xi.p,e=BigInt(3),n=BigInt(6),i=BigInt(11),r=BigInt(22),o=BigInt(23),a=BigInt(44),u=BigInt(88),g=s*s*s%t,x=g*g*s%t,B=Yt(x,e,t)*x%t,I=Yt(B,e,t)*x%t,v=Yt(I,Ro,t)*g%t,E=Yt(v,i,t)*v%t,R=Yt(E,r,t)*E%t,T=Yt(R,a,t)*R%t,N=Yt(T,u,t)*T%t,W=Yt(N,a,t)*R%t,D=Yt(W,e,t)*x%t,X=Yt(D,o,t)*E%t,nt=Yt(X,n,t)*g%t,at=Yt(nt,Ro,t);if(!bi.eql(bi.sqr(at),s))throw new Error("Cannot find square root");return at}const bi=Nn(Xi.p,{sqrt:Jf}),mc=Yf({...Xi,Fp:bi,lowS:!0,endo:Xf},aa);en.utils.randomPrivateKey;en.getPublicKey;function Mo(s){try{return en.ExtendedPoint.fromHex(s),!0}catch{return!1}}const Qf=(s,t)=>en.sign(s,t.slice(0,32)),th=en.verify,ar=s=>Y.Buffer.isBuffer(s)?s:s instanceof Uint8Array?Y.Buffer.from(s.buffer,s.byteOffset,s.byteLength):Y.Buffer.from(s);let eh=class{constructor(t){Object.assign(this,t)}encode(){return Y.Buffer.from(qi(Wr,this))}static decode(t){return Di(Wr,this,t)}static decodeUnchecked(t){return $i(Wr,this,t)}};const Wr=new Map;var yc;const nh=32,kn=32;function rh(s){return s._bn!==void 0}let To=1,wt=class Gn extends eh{constructor(t){if(super({}),this._bn=void 0,rh(t))this._bn=t._bn;else{if(typeof t=="string"){const e=Et.decode(t);if(e.length!=kn)throw new Error("Invalid public key input");this._bn=new Xr(e)}else this._bn=new Xr(t);if(this._bn.byteLength()>kn)throw new Error("Invalid public key input")}}static unique(){const t=new Gn(To);return To+=1,new Gn(t.toBuffer())}equals(t){return this._bn.eq(t._bn)}toBase58(){return Et.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){const t=this.toBuffer();return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}toBuffer(){const t=this._bn.toArrayLike(Y.Buffer);if(t.length===kn)return t;const e=Y.Buffer.alloc(32);return t.copy(e,32-t.length),e}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(t,e,n){const i=Y.Buffer.concat([t.toBuffer(),Y.Buffer.from(e),n.toBuffer()]),r=Jr(i);return new Gn(r)}static createProgramAddressSync(t,e){let n=Y.Buffer.alloc(0);t.forEach(function(r){if(r.length>nh)throw new TypeError("Max seed length exceeded");n=Y.Buffer.concat([n,ar(r)])}),n=Y.Buffer.concat([n,e.toBuffer(),Y.Buffer.from("ProgramDerivedAddress")]);const i=Jr(n);if(Mo(i))throw new Error("Invalid seeds, address must fall off the curve");return new Gn(i)}static async createProgramAddress(t,e){return this.createProgramAddressSync(t,e)}static findProgramAddressSync(t,e){let n=255,i;for(;n!=0;){try{const r=t.concat(Y.Buffer.from([n]));i=this.createProgramAddressSync(r,e)}catch(r){if(r instanceof TypeError)throw r;n--;continue}return[i,n]}throw new Error("Unable to find a viable program address nonce")}static async findProgramAddress(t,e){return this.findProgramAddressSync(t,e)}static isOnCurve(t){const e=new Gn(t);return Mo(e.toBytes())}};yc=wt;wt.default=new yc("11111111111111111111111111111111");Wr.set(wt,{kind:"struct",fields:[["_bn","u256"]]});new wt("BPFLoader1111111111111111111111111111111111");const nr=1232,wc=127,bc=64;let Sc=class extends Error{constructor(t){super(`Signature ${t} has expired: block height exceeded.`),this.signature=void 0,this.signature=t}};Object.defineProperty(Sc.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});let vc=class extends Error{constructor(t,e){super(`Transaction was not confirmed in ${e.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${t} using the Solana Explorer or CLI tools.`),this.signature=void 0,this.signature=t}};Object.defineProperty(vc.prototype,"name",{value:"TransactionExpiredTimeoutError"});let Sr=class extends Error{constructor(t){super(`Signature ${t} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=t}};Object.defineProperty(Sr.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});let is=class{constructor(t,e){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=t,this.accountKeysFromLookups=e}keySegments(){const t=[this.staticAccountKeys];return this.accountKeysFromLookups&&(t.push(this.accountKeysFromLookups.writable),t.push(this.accountKeysFromLookups.readonly)),t}get(t){for(const e of this.keySegments()){if(t<e.length)return e[t];t-=e.length}}get length(){return this.keySegments().flat().length}compileInstructions(t){if(this.length>256)throw new Error("Account index overflow encountered during compilation");const n=new Map;this.keySegments().flat().forEach((r,o)=>{n.set(r.toBase58(),o)});const i=r=>{const o=n.get(r.toBase58());if(o===void 0)throw new Error("Encountered an unknown instruction account key during compilation");return o};return t.map(r=>({programIdIndex:i(r.programId),accountKeyIndexes:r.keys.map(o=>i(o.pubkey)),data:r.data}))}};const _t=(s="publicKey")=>yt(32,s),Jn=(s="string")=>{const t=H([G("length"),G("lengthPadding"),yt(Ne(G(),-8),"chars")],s),e=t.decode.bind(t),n=t.encode.bind(t),i=t;return i.decode=(r,o)=>e(r,o).chars.toString(),i.encode=(r,o,a)=>{const u={chars:Y.Buffer.from(r,"utf8")};return n(u,o,a)},i.alloc=r=>G().span+G().span+Y.Buffer.from(r,"utf8").length,i},sh=(s="authorized")=>H([_t("staker"),_t("withdrawer")],s),ih=(s="lockup")=>H([Ot("unixTimestamp"),Ot("epoch"),_t("custodian")],s),oh=(s="voteInit")=>H([_t("nodePubkey"),_t("authorizedVoter"),_t("authorizedWithdrawer"),st("commission")],s),ah=(s="voteAuthorizeWithSeedArgs")=>H([G("voteAuthorizationType"),_t("currentAuthorityDerivedKeyOwnerPubkey"),Jn("currentAuthorityDerivedKeySeed"),_t("newAuthorized")],s);function $e(s){let t=0,e=0;for(;;){let n=s.shift();if(t|=(n&127)<<e*7,e+=1,!(n&128))break}return t}function qe(s,t){let e=t;for(;;){let n=e&127;if(e>>=7,e==0){s.push(n);break}else n|=128,s.push(n)}}function we(s,t){if(!s)throw new Error(t||"Assertion failed")}let xc=class _c{constructor(t,e){this.payer=void 0,this.keyMetaMap=void 0,this.payer=t,this.keyMetaMap=e}static compile(t,e){const n=new Map,i=o=>{const a=o.toBase58();let u=n.get(a);return u===void 0&&(u={isSigner:!1,isWritable:!1,isInvoked:!1},n.set(a,u)),u},r=i(e);r.isSigner=!0,r.isWritable=!0;for(const o of t){i(o.programId).isInvoked=!0;for(const a of o.keys){const u=i(a.pubkey);u.isSigner||(u.isSigner=a.isSigner),u.isWritable||(u.isWritable=a.isWritable)}}return new _c(e,n)}getMessageComponents(){const t=[...this.keyMetaMap.entries()];we(t.length<=256,"Max static account keys length exceeded");const e=t.filter(([,u])=>u.isSigner&&u.isWritable),n=t.filter(([,u])=>u.isSigner&&!u.isWritable),i=t.filter(([,u])=>!u.isSigner&&u.isWritable),r=t.filter(([,u])=>!u.isSigner&&!u.isWritable),o={numRequiredSignatures:e.length+n.length,numReadonlySignedAccounts:n.length,numReadonlyUnsignedAccounts:r.length};{we(e.length>0,"Expected at least one writable signer key");const[u]=e[0];we(u===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}const a=[...e.map(([u])=>new wt(u)),...n.map(([u])=>new wt(u)),...i.map(([u])=>new wt(u)),...r.map(([u])=>new wt(u))];return[o,a]}extractTableLookup(t){const[e,n]=this.drainKeysFoundInLookupTable(t.state.addresses,o=>!o.isSigner&&!o.isInvoked&&o.isWritable),[i,r]=this.drainKeysFoundInLookupTable(t.state.addresses,o=>!o.isSigner&&!o.isInvoked&&!o.isWritable);if(!(e.length===0&&i.length===0))return[{accountKey:t.key,writableIndexes:e,readonlyIndexes:i},{writable:n,readonly:r}]}drainKeysFoundInLookupTable(t,e){const n=new Array,i=new Array;for(const[r,o]of this.keyMetaMap.entries())if(e(o)){const a=new wt(r),u=t.findIndex(g=>g.equals(a));u>=0&&(we(u<256,"Max lookup table index exceeded"),n.push(u),i.push(a),this.keyMetaMap.delete(r))}return[n,i]}};const kc="Reached end of buffer unexpectedly";function fn(s){if(s.length===0)throw new Error(kc);return s.shift()}function Ke(s,...t){const[e]=t;if(t.length===2?e+(t[1]??0)>s.length:e>=s.length)throw new Error(kc);return s.splice(...t)}let kr=class Si{constructor(t){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=t.header,this.accountKeys=t.accountKeys.map(e=>new wt(e)),this.recentBlockhash=t.recentBlockhash,this.instructions=t.instructions,this.instructions.forEach(e=>this.indexToProgramIds.set(e.programIdIndex,this.accountKeys[e.programIdIndex]))}get version(){return"legacy"}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map(t=>({programIdIndex:t.programIdIndex,accountKeyIndexes:t.accounts,data:Et.decode(t.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new is(this.staticAccountKeys)}static compile(t){const e=xc.compile(t.instructions,t.payerKey),[n,i]=e.getMessageComponents(),o=new is(i).compileInstructions(t.instructions).map(a=>({programIdIndex:a.programIdIndex,accounts:a.accountKeyIndexes,data:Et.encode(a.data)}));return new Si({header:n,accountKeys:i,recentBlockhash:t.recentBlockhash,instructions:o})}isAccountSigner(t){return t<this.header.numRequiredSignatures}isAccountWritable(t){const e=this.header.numRequiredSignatures;if(t>=this.header.numRequiredSignatures){const n=t-e,r=this.accountKeys.length-e-this.header.numReadonlyUnsignedAccounts;return n<r}else{const n=e-this.header.numReadonlySignedAccounts;return t<n}}isProgramId(t){return this.indexToProgramIds.has(t)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter((t,e)=>!this.isProgramId(e))}serialize(){const t=this.accountKeys.length;let e=[];qe(e,t);const n=this.instructions.map(B=>{const{accounts:I,programIdIndex:v}=B,E=Array.from(Et.decode(B.data));let R=[];qe(R,I.length);let T=[];return qe(T,E.length),{programIdIndex:v,keyIndicesCount:Y.Buffer.from(R),keyIndices:I,dataLength:Y.Buffer.from(T),data:E}});let i=[];qe(i,n.length);let r=Y.Buffer.alloc(nr);Y.Buffer.from(i).copy(r);let o=i.length;n.forEach(B=>{const v=H([st("programIdIndex"),yt(B.keyIndicesCount.length,"keyIndicesCount"),Rt(st("keyIndex"),B.keyIndices.length,"keyIndices"),yt(B.dataLength.length,"dataLength"),Rt(st("userdatum"),B.data.length,"data")]).encode(B,r,o);o+=v}),r=r.slice(0,o);const a=H([yt(1,"numRequiredSignatures"),yt(1,"numReadonlySignedAccounts"),yt(1,"numReadonlyUnsignedAccounts"),yt(e.length,"keyCount"),Rt(_t("key"),t,"keys"),_t("recentBlockhash")]),u={numRequiredSignatures:Y.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:Y.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:Y.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:Y.Buffer.from(e),keys:this.accountKeys.map(B=>ar(B.toBytes())),recentBlockhash:Et.decode(this.recentBlockhash)};let g=Y.Buffer.alloc(2048);const x=a.encode(u,g);return r.copy(g,x),g.slice(0,x+r.length)}static from(t){let e=[...t];const n=fn(e);if(n!==(n&wc))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const i=fn(e),r=fn(e),o=$e(e);let a=[];for(let I=0;I<o;I++){const v=Ke(e,0,kn);a.push(new wt(Y.Buffer.from(v)))}const u=Ke(e,0,kn),g=$e(e);let x=[];for(let I=0;I<g;I++){const v=fn(e),E=$e(e),R=Ke(e,0,E),T=$e(e),N=Ke(e,0,T),W=Et.encode(Y.Buffer.from(N));x.push({programIdIndex:v,accounts:R,data:W})}const B={header:{numRequiredSignatures:n,numReadonlySignedAccounts:i,numReadonlyUnsignedAccounts:r},recentBlockhash:Et.encode(Y.Buffer.from(u)),accountKeys:a,instructions:x};return new Si(B)}},ch=class vi{constructor(t){this.header=void 0,this.staticAccountKeys=void 0,this.recentBlockhash=void 0,this.compiledInstructions=void 0,this.addressTableLookups=void 0,this.header=t.header,this.staticAccountKeys=t.staticAccountKeys,this.recentBlockhash=t.recentBlockhash,this.compiledInstructions=t.compiledInstructions,this.addressTableLookups=t.addressTableLookups}get version(){return 0}get numAccountKeysFromLookups(){let t=0;for(const e of this.addressTableLookups)t+=e.readonlyIndexes.length+e.writableIndexes.length;return t}getAccountKeys(t){let e;if(t&&"accountKeysFromLookups"in t&&t.accountKeysFromLookups){if(this.numAccountKeysFromLookups!=t.accountKeysFromLookups.writable.length+t.accountKeysFromLookups.readonly.length)throw new Error("Failed to get account keys because of a mismatch in the number of account keys from lookups");e=t.accountKeysFromLookups}else if(t&&"addressLookupTableAccounts"in t&&t.addressLookupTableAccounts)e=this.resolveAddressTableLookups(t.addressLookupTableAccounts);else if(this.addressTableLookups.length>0)throw new Error("Failed to get account keys because address table lookups were not resolved");return new is(this.staticAccountKeys,e)}isAccountSigner(t){return t<this.header.numRequiredSignatures}isAccountWritable(t){const e=this.header.numRequiredSignatures,n=this.staticAccountKeys.length;if(t>=n){const i=t-n,r=this.addressTableLookups.reduce((o,a)=>o+a.writableIndexes.length,0);return i<r}else if(t>=this.header.numRequiredSignatures){const i=t-e,o=n-e-this.header.numReadonlyUnsignedAccounts;return i<o}else{const i=e-this.header.numReadonlySignedAccounts;return t<i}}resolveAddressTableLookups(t){const e={writable:[],readonly:[]};for(const n of this.addressTableLookups){const i=t.find(r=>r.key.equals(n.accountKey));if(!i)throw new Error(`Failed to find address lookup table account for table key ${n.accountKey.toBase58()}`);for(const r of n.writableIndexes)if(r<i.state.addresses.length)e.writable.push(i.state.addresses[r]);else throw new Error(`Failed to find address for index ${r} in address lookup table ${n.accountKey.toBase58()}`);for(const r of n.readonlyIndexes)if(r<i.state.addresses.length)e.readonly.push(i.state.addresses[r]);else throw new Error(`Failed to find address for index ${r} in address lookup table ${n.accountKey.toBase58()}`)}return e}static compile(t){const e=xc.compile(t.instructions,t.payerKey),n=new Array,i={writable:new Array,readonly:new Array},r=t.addressLookupTableAccounts||[];for(const x of r){const B=e.extractTableLookup(x);if(B!==void 0){const[I,{writable:v,readonly:E}]=B;n.push(I),i.writable.push(...v),i.readonly.push(...E)}}const[o,a]=e.getMessageComponents(),g=new is(a,i).compileInstructions(t.instructions);return new vi({header:o,staticAccountKeys:a,recentBlockhash:t.recentBlockhash,compiledInstructions:g,addressTableLookups:n})}serialize(){const t=Array();qe(t,this.staticAccountKeys.length);const e=this.serializeInstructions(),n=Array();qe(n,this.compiledInstructions.length);const i=this.serializeAddressTableLookups(),r=Array();qe(r,this.addressTableLookups.length);const o=H([st("prefix"),H([st("numRequiredSignatures"),st("numReadonlySignedAccounts"),st("numReadonlyUnsignedAccounts")],"header"),yt(t.length,"staticAccountKeysLength"),Rt(_t(),this.staticAccountKeys.length,"staticAccountKeys"),_t("recentBlockhash"),yt(n.length,"instructionsLength"),yt(e.length,"serializedInstructions"),yt(r.length,"addressTableLookupsLength"),yt(i.length,"serializedAddressTableLookups")]),a=new Uint8Array(nr),g=o.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(t),staticAccountKeys:this.staticAccountKeys.map(x=>x.toBytes()),recentBlockhash:Et.decode(this.recentBlockhash),instructionsLength:new Uint8Array(n),serializedInstructions:e,addressTableLookupsLength:new Uint8Array(r),serializedAddressTableLookups:i},a);return a.slice(0,g)}serializeInstructions(){let t=0;const e=new Uint8Array(nr);for(const n of this.compiledInstructions){const i=Array();qe(i,n.accountKeyIndexes.length);const r=Array();qe(r,n.data.length);const o=H([st("programIdIndex"),yt(i.length,"encodedAccountKeyIndexesLength"),Rt(st(),n.accountKeyIndexes.length,"accountKeyIndexes"),yt(r.length,"encodedDataLength"),yt(n.data.length,"data")]);t+=o.encode({programIdIndex:n.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(i),accountKeyIndexes:n.accountKeyIndexes,encodedDataLength:new Uint8Array(r),data:n.data},e,t)}return e.slice(0,t)}serializeAddressTableLookups(){let t=0;const e=new Uint8Array(nr);for(const n of this.addressTableLookups){const i=Array();qe(i,n.writableIndexes.length);const r=Array();qe(r,n.readonlyIndexes.length);const o=H([_t("accountKey"),yt(i.length,"encodedWritableIndexesLength"),Rt(st(),n.writableIndexes.length,"writableIndexes"),yt(r.length,"encodedReadonlyIndexesLength"),Rt(st(),n.readonlyIndexes.length,"readonlyIndexes")]);t+=o.encode({accountKey:n.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(i),writableIndexes:n.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(r),readonlyIndexes:n.readonlyIndexes},e,t)}return e.slice(0,t)}static deserialize(t){let e=[...t];const n=fn(e),i=n&wc;we(n!==i,"Expected versioned message but received legacy message");const r=i;we(r===0,`Expected versioned message with version 0 but found version ${r}`);const o={numRequiredSignatures:fn(e),numReadonlySignedAccounts:fn(e),numReadonlyUnsignedAccounts:fn(e)},a=[],u=$e(e);for(let E=0;E<u;E++)a.push(new wt(Ke(e,0,kn)));const g=Et.encode(Ke(e,0,kn)),x=$e(e),B=[];for(let E=0;E<x;E++){const R=fn(e),T=$e(e),N=Ke(e,0,T),W=$e(e),D=new Uint8Array(Ke(e,0,W));B.push({programIdIndex:R,accountKeyIndexes:N,data:D})}const I=$e(e),v=[];for(let E=0;E<I;E++){const R=new wt(Ke(e,0,kn)),T=$e(e),N=Ke(e,0,T),W=$e(e),D=Ke(e,0,W);v.push({accountKey:R,writableIndexes:N,readonlyIndexes:D})}return new vi({header:o,staticAccountKeys:a,recentBlockhash:g,compiledInstructions:B,addressTableLookups:v})}},bn=function(s){return s[s.BLOCKHEIGHT_EXCEEDED=0]="BLOCKHEIGHT_EXCEEDED",s[s.PROCESSED=1]="PROCESSED",s[s.TIMED_OUT=2]="TIMED_OUT",s[s.NONCE_INVALID=3]="NONCE_INVALID",s}({});const uh=Y.Buffer.alloc(bc).fill(0);let Co=class{constructor(t){this.keys=void 0,this.programId=void 0,this.data=Y.Buffer.alloc(0),this.programId=t.programId,this.keys=t.keys,t.data&&(this.data=t.data)}toJSON(){return{keys:this.keys.map(({pubkey:t,isSigner:e,isWritable:n})=>({pubkey:t.toJSON(),isSigner:e,isWritable:n})),programId:this.programId.toJSON(),data:[...this.data]}}},yr=class xi{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(t){if(this.signatures=[],this.feePayer=void 0,this.instructions=[],this.recentBlockhash=void 0,this.lastValidBlockHeight=void 0,this.nonceInfo=void 0,this.minNonceContextSlot=void 0,this._message=void 0,this._json=void 0,!!t)if(t.feePayer&&(this.feePayer=t.feePayer),t.signatures&&(this.signatures=t.signatures),Object.prototype.hasOwnProperty.call(t,"nonceInfo")){const{minContextSlot:e,nonceInfo:n}=t;this.minNonceContextSlot=e,this.nonceInfo=n}else if(Object.prototype.hasOwnProperty.call(t,"lastValidBlockHeight")){const{blockhash:e,lastValidBlockHeight:n}=t;this.recentBlockhash=e,this.lastValidBlockHeight=n}else{const{recentBlockhash:e,nonceInfo:n}=t;n&&(this.nonceInfo=n),this.recentBlockhash=e}}toJSON(){return{recentBlockhash:this.recentBlockhash||null,feePayer:this.feePayer?this.feePayer.toJSON():null,nonceInfo:this.nonceInfo?{nonce:this.nonceInfo.nonce,nonceInstruction:this.nonceInfo.nonceInstruction.toJSON()}:null,instructions:this.instructions.map(t=>t.toJSON()),signers:this.signatures.map(({publicKey:t})=>t.toJSON())}}add(...t){if(t.length===0)throw new Error("No instructions");return t.forEach(e=>{"instructions"in e?this.instructions=this.instructions.concat(e.instructions):"data"in e&&"programId"in e&&"keys"in e?this.instructions.push(e):this.instructions.push(new Co(e))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let t,e;if(this.nonceInfo?(t=this.nonceInfo.nonce,this.instructions[0]!=this.nonceInfo.nonceInstruction?e=[this.nonceInfo.nonceInstruction,...this.instructions]:e=this.instructions):(t=this.recentBlockhash,e=this.instructions),!t)throw new Error("Transaction recentBlockhash required");e.length<1&&console.warn("No instructions provided");let n;if(this.feePayer)n=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)n=this.signatures[0].publicKey;else throw new Error("Transaction fee payer required");for(let R=0;R<e.length;R++)if(e[R].programId===void 0)throw new Error(`Transaction instruction index ${R} has undefined program id`);const i=[],r=[];e.forEach(R=>{R.keys.forEach(N=>{r.push({...N})});const T=R.programId.toString();i.includes(T)||i.push(T)}),i.forEach(R=>{r.push({pubkey:new wt(R),isSigner:!1,isWritable:!1})});const o=[];r.forEach(R=>{const T=R.pubkey.toString(),N=o.findIndex(W=>W.pubkey.toString()===T);N>-1?(o[N].isWritable=o[N].isWritable||R.isWritable,o[N].isSigner=o[N].isSigner||R.isSigner):o.push(R)}),o.sort(function(R,T){if(R.isSigner!==T.isSigner)return R.isSigner?-1:1;if(R.isWritable!==T.isWritable)return R.isWritable?-1:1;const N={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return R.pubkey.toBase58().localeCompare(T.pubkey.toBase58(),"en",N)});const a=o.findIndex(R=>R.pubkey.equals(n));if(a>-1){const[R]=o.splice(a,1);R.isSigner=!0,R.isWritable=!0,o.unshift(R)}else o.unshift({pubkey:n,isSigner:!0,isWritable:!0});for(const R of this.signatures){const T=o.findIndex(N=>N.pubkey.equals(R.publicKey));if(T>-1)o[T].isSigner||(o[T].isSigner=!0,console.warn("Transaction references a signature that is unnecessary, only the fee payer and instruction signer accounts should sign a transaction. This behavior is deprecated and will throw an error in the next major version release."));else throw new Error(`unknown signer: ${R.publicKey.toString()}`)}let u=0,g=0,x=0;const B=[],I=[];o.forEach(({pubkey:R,isSigner:T,isWritable:N})=>{T?(B.push(R.toString()),u+=1,N||(g+=1)):(I.push(R.toString()),N||(x+=1))});const v=B.concat(I),E=e.map(R=>{const{data:T,programId:N}=R;return{programIdIndex:v.indexOf(N.toString()),accounts:R.keys.map(W=>v.indexOf(W.pubkey.toString())),data:Et.encode(T)}});return E.forEach(R=>{we(R.programIdIndex>=0),R.accounts.forEach(T=>we(T>=0))}),new kr({header:{numRequiredSignatures:u,numReadonlySignedAccounts:g,numReadonlyUnsignedAccounts:x},accountKeys:v,recentBlockhash:t,instructions:E})}_compile(){const t=this.compileMessage(),e=t.accountKeys.slice(0,t.header.numRequiredSignatures);return this.signatures.length===e.length&&this.signatures.every((i,r)=>e[r].equals(i.publicKey))||(this.signatures=e.map(n=>({signature:null,publicKey:n}))),t}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(t){return(await t.getFeeForMessage(this.compileMessage())).value}setSigners(...t){if(t.length===0)throw new Error("No signers");const e=new Set;this.signatures=t.filter(n=>{const i=n.toString();return e.has(i)?!1:(e.add(i),!0)}).map(n=>({signature:null,publicKey:n}))}sign(...t){if(t.length===0)throw new Error("No signers");const e=new Set,n=[];for(const r of t){const o=r.publicKey.toString();e.has(o)||(e.add(o),n.push(r))}this.signatures=n.map(r=>({signature:null,publicKey:r.publicKey}));const i=this._compile();this._partialSign(i,...n)}partialSign(...t){if(t.length===0)throw new Error("No signers");const e=new Set,n=[];for(const r of t){const o=r.publicKey.toString();e.has(o)||(e.add(o),n.push(r))}const i=this._compile();this._partialSign(i,...n)}_partialSign(t,...e){const n=t.serialize();e.forEach(i=>{const r=Qf(n,i.secretKey);this._addSignature(i.publicKey,ar(r))})}addSignature(t,e){this._compile(),this._addSignature(t,e)}_addSignature(t,e){we(e.length===64);const n=this.signatures.findIndex(i=>t.equals(i.publicKey));if(n<0)throw new Error(`unknown signer: ${t.toString()}`);this.signatures[n].signature=Y.Buffer.from(e)}verifySignatures(t=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),t)}_getMessageSignednessErrors(t,e){const n={};for(const{signature:i,publicKey:r}of this.signatures)i===null?e&&(n.missing||(n.missing=[])).push(r):th(i,t,r.toBytes())||(n.invalid||(n.invalid=[])).push(r);return n.invalid||n.missing?n:void 0}serialize(t){const{requireAllSignatures:e,verifySignatures:n}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},t),i=this.serializeMessage();if(n){const r=this._getMessageSignednessErrors(i,e);if(r){let o="Signature verification failed.";throw r.invalid&&(o+=`
|
|
7
|
-
Invalid signature for public key${r.invalid.length===1?"":"(s)"} [\`${r.invalid.map(a=>a.toBase58()).join("`, `")}\`].`),r.missing&&(o+=`
|
|
8
|
-
Missing signature for public key${r.missing.length===1?"":"(s)"} [\`${r.missing.map(a=>a.toBase58()).join("`, `")}\`].`),new Error(o)}}return this._serialize(i)}_serialize(t){const{signatures:e}=this,n=[];qe(n,e.length);const i=n.length+e.length*64+t.length,r=Y.Buffer.alloc(i);return we(e.length<256),Y.Buffer.from(n).copy(r,0),e.forEach(({signature:o},a)=>{o!==null&&(we(o.length===64,"signature has invalid length"),Y.Buffer.from(o).copy(r,n.length+a*64))}),t.copy(r,n.length+e.length*64),we(r.length<=nr,`Transaction too large: ${r.length} > ${nr}`),r}get keys(){return we(this.instructions.length===1),this.instructions[0].keys.map(t=>t.pubkey)}get programId(){return we(this.instructions.length===1),this.instructions[0].programId}get data(){return we(this.instructions.length===1),this.instructions[0].data}static from(t){let e=[...t];const n=$e(e);let i=[];for(let r=0;r<n;r++){const o=Ke(e,0,bc);i.push(Et.encode(Y.Buffer.from(o)))}return xi.populate(kr.from(e),i)}static populate(t,e=[]){const n=new xi;return n.recentBlockhash=t.recentBlockhash,t.header.numRequiredSignatures>0&&(n.feePayer=t.accountKeys[0]),e.forEach((i,r)=>{const o={signature:i==Et.encode(uh)?null:Et.decode(i),publicKey:t.accountKeys[r]};n.signatures.push(o)}),t.instructions.forEach(i=>{const r=i.accounts.map(o=>{const a=t.accountKeys[o];return{pubkey:a,isSigner:n.signatures.some(u=>u.publicKey.toString()===a.toString())||t.isAccountSigner(o),isWritable:t.isAccountWritable(o)}});n.instructions.push(new Co({keys:r,programId:t.accountKeys[i.programIdIndex],data:Et.decode(i.data)}))}),n._message=t,n._json=n.toJSON(),n}};const lh=160,fh=64,hh=lh/fh,dh=1e3/hh;new wt("SysvarC1ock11111111111111111111111111111111");new wt("SysvarEpochSchedu1e111111111111111111111111");new wt("Sysvar1nstructions1111111111111111111111111");new wt("SysvarRecentB1ockHashes11111111111111111111");new wt("SysvarRent111111111111111111111111111111111");new wt("SysvarRewards111111111111111111111111111111");new wt("SysvarS1otHashes111111111111111111111111111");new wt("SysvarS1otHistory11111111111111111111111111");new wt("SysvarStakeHistory1111111111111111111111111");let Lo=class extends Error{constructor({action:t,signature:e,transactionMessage:n,logs:i}){const r=i?`Logs:
|
|
9
|
-
${JSON.stringify(i.slice(-10),null,2)}. `:"",o="\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.";let a;switch(t){case"send":a=`Transaction ${e} resulted in an error.
|
|
10
|
-
${n}. `+r+o;break;case"simulate":a=`Simulation failed.
|
|
11
|
-
Message: ${n}.
|
|
12
|
-
`+r+o;break;default:a=`Unknown action '${(u=>u)(t)}'`}super(a),this.signature=void 0,this.transactionMessage=void 0,this.transactionLogs=void 0,this.signature=e,this.transactionMessage=n,this.transactionLogs=i||void 0}get transactionError(){return{message:this.transactionMessage,logs:Array.isArray(this.transactionLogs)?this.transactionLogs:void 0}}get logs(){const t=this.transactionLogs;if(!(t!=null&&typeof t=="object"&&"then"in t))return t}async getLogs(t){return Array.isArray(this.transactionLogs)||(this.transactionLogs=new Promise((e,n)=>{t.getTransaction(this.signature).then(i=>{if(i&&i.meta&&i.meta.logMessages){const r=i.meta.logMessages;this.transactionLogs=r,e(r)}else n(new Error("Log messages not found"))}).catch(n)})),await this.transactionLogs}},it=class extends Error{constructor({code:t,message:e,data:n},i){super(i!=null?`${i}: ${e}`:e),this.code=void 0,this.data=void 0,this.code=t,this.data=n,this.name="SolanaJSONRPCError"}};function Zn(s){return new Promise(t=>setTimeout(t,s))}const ph=Bt("lamportsPerSignature"),Ec=H([G("version"),G("state"),_t("authorizedPubkey"),_t("nonce"),H([ph],"feeCalculator")]);Ec.span;let gh=class Bc{constructor(t){this.authorizedPubkey=void 0,this.nonce=void 0,this.feeCalculator=void 0,this.authorizedPubkey=t.authorizedPubkey,this.nonce=t.nonce,this.feeCalculator=t.feeCalculator}static fromAccountData(t){const e=Ec.decode(ar(t),0);return new Bc({authorizedPubkey:new wt(e.authorizedPubkey),nonce:new wt(e.nonce).toString(),feeCalculator:e.feeCalculator})}};function cr(s){const t=yt(8,s),e=t.decode.bind(t),n=t.encode.bind(t),i=t,r=tc();return i.decode=(o,a)=>{const u=e(o,a);return r.decode(u)},i.encode=(o,a,u)=>{const g=r.encode(o);return n(g,a,u)},i}Object.freeze({Create:{index:0,layout:H([G("instruction"),Ot("lamports"),Ot("space"),_t("programId")])},Assign:{index:1,layout:H([G("instruction"),_t("programId")])},Transfer:{index:2,layout:H([G("instruction"),cr("lamports")])},CreateWithSeed:{index:3,layout:H([G("instruction"),_t("base"),Jn("seed"),Ot("lamports"),Ot("space"),_t("programId")])},AdvanceNonceAccount:{index:4,layout:H([G("instruction")])},WithdrawNonceAccount:{index:5,layout:H([G("instruction"),Ot("lamports")])},InitializeNonceAccount:{index:6,layout:H([G("instruction"),_t("authorized")])},AuthorizeNonceAccount:{index:7,layout:H([G("instruction"),_t("authorized")])},Allocate:{index:8,layout:H([G("instruction"),Ot("space")])},AllocateWithSeed:{index:9,layout:H([G("instruction"),_t("base"),Jn("seed"),Ot("space"),_t("programId")])},AssignWithSeed:{index:10,layout:H([G("instruction"),_t("base"),Jn("seed"),_t("programId")])},TransferWithSeed:{index:11,layout:H([G("instruction"),cr("lamports"),Jn("seed"),_t("programId")])},UpgradeNonceAccount:{index:12,layout:H([G("instruction")])}});new wt("11111111111111111111111111111111");new wt("BPFLoader2111111111111111111111111111111111");function mh(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var ii,Uo;function yh(){if(Uo)return ii;Uo=1;var s=Object.prototype.toString,t=Object.keys||function(n){var i=[];for(var r in n)i.push(r);return i};function e(n,i){var r,o,a,u,g,x,B;if(n===!0)return"true";if(n===!1)return"false";switch(typeof n){case"object":if(n===null)return null;if(n.toJSON&&typeof n.toJSON=="function")return e(n.toJSON(),i);if(B=s.call(n),B==="[object Array]"){for(a="[",o=n.length-1,r=0;r<o;r++)a+=e(n[r],!0)+",";return o>-1&&(a+=e(n[r],!0)),a+"]"}else if(B==="[object Object]"){for(u=t(n).sort(),o=u.length,a="",r=0;r<o;)g=u[r],x=e(n[g],!1),x!==void 0&&(a&&(a+=","),a+=JSON.stringify(g)+":"+x),r++;return"{"+a+"}"}else return JSON.stringify(n);case"function":case"undefined":return i?null:void 0;case"string":return JSON.stringify(n);default:return isFinite(n)?n:null}}return ii=function(n){var i=e(n,!1);if(i!==void 0)return""+i},ii}var wh=yh(),No=mh(wh);const wr=32;function oi(s){let t=0;for(;s>1;)s/=2,t++;return t}function bh(s){return s===0?1:(s--,s|=s>>1,s|=s>>2,s|=s>>4,s|=s>>8,s|=s>>16,s|=s>>32,s+1)}let Sh=class{constructor(t,e,n,i,r){this.slotsPerEpoch=void 0,this.leaderScheduleSlotOffset=void 0,this.warmup=void 0,this.firstNormalEpoch=void 0,this.firstNormalSlot=void 0,this.slotsPerEpoch=t,this.leaderScheduleSlotOffset=e,this.warmup=n,this.firstNormalEpoch=i,this.firstNormalSlot=r}getEpoch(t){return this.getEpochAndSlotIndex(t)[0]}getEpochAndSlotIndex(t){if(t<this.firstNormalSlot){const e=oi(bh(t+wr+1))-oi(wr)-1,n=this.getSlotsInEpoch(e),i=t-(n-wr);return[e,i]}else{const e=t-this.firstNormalSlot,n=Math.floor(e/this.slotsPerEpoch),i=this.firstNormalEpoch+n,r=e%this.slotsPerEpoch;return[i,r]}}getFirstSlotInEpoch(t){return t<=this.firstNormalEpoch?(Math.pow(2,t)-1)*wr:(t-this.firstNormalEpoch)*this.slotsPerEpoch+this.firstNormalSlot}getLastSlotInEpoch(t){return this.getFirstSlotInEpoch(t)+this.getSlotsInEpoch(t)-1}getSlotsInEpoch(t){return t<this.firstNormalEpoch?Math.pow(2,t+oi(wr)):this.slotsPerEpoch}};var vh=globalThis.fetch;let xh=class extends lc{constructor(t,e,n){const i=r=>{const o=uc(r,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...e});return"socket"in o?this.underlyingSocket=o.socket:this.underlyingSocket=o,o};super(i,t,e,n),this.underlyingSocket=void 0}call(...t){var n;const e=(n=this.underlyingSocket)==null?void 0:n.readyState;return e===1?super.call(...t):Promise.reject(new Error("Tried to call a JSON-RPC method `"+t[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+e+")"))}notify(...t){var n;const e=(n=this.underlyingSocket)==null?void 0:n.readyState;return e===1?super.notify(...t):Promise.reject(new Error("Tried to send a JSON-RPC notification `"+t[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+e+")"))}};function _h(s,t){let e;try{e=s.layout.decode(t)}catch(n){throw new Error("invalid instruction; "+n)}if(e.typeIndex!==s.index)throw new Error(`invalid account data; account type mismatch ${e.typeIndex} != ${s.index}`);return e}const Po=56;let Fo=class{constructor(t){this.key=void 0,this.state=void 0,this.key=t.key,this.state=t.state}isActive(){const t=BigInt("0xffffffffffffffff");return this.state.deactivationSlot===t}static deserialize(t){const e=_h(kh,t),n=t.length-Po;we(n>=0,"lookup table is invalid"),we(n%32===0,"lookup table is invalid");const i=n/32,{addresses:r}=H([Rt(_t(),i,"addresses")]).decode(t.slice(Po));return{deactivationSlot:e.deactivationSlot,lastExtendedSlot:e.lastExtendedSlot,lastExtendedSlotStartIndex:e.lastExtendedStartIndex,authority:e.authority.length!==0?new wt(e.authority[0]):void 0,addresses:r.map(o=>new wt(o))}}};const kh={index:1,layout:H([G("typeIndex"),cr("deactivationSlot"),Bt("lastExtendedSlot"),st("lastExtendedStartIndex"),st(),Rt(_t(),Ne(st(),-1),"authority")])},Eh=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;function Bh(s){const t=s.match(Eh);if(t==null)throw TypeError(`Failed to validate endpoint URL \`${s}\``);const[e,n,i,r]=t,o=s.startsWith("https:")?"wss:":"ws:",a=i==null?null:parseInt(i.slice(1),10),u=a==null?"":`:${a+1}`;return`${o}//${n}${u}${r}`}const zt=on(dr(wt),P(),s=>new wt(s)),Ac=pr([P(),pt("base64")]),Ji=on(dr(Y.Buffer),Ac,s=>Y.Buffer.from(s[0],"base64")),Ah=30*1e3;function Ih(s){if(/^https?:/.test(s)===!1)throw new TypeError("Endpoint URL must start with `http:` or `https:`.");return s}function Ut(s){let t,e;if(typeof s=="string")t=s;else if(s){const{commitment:n,...i}=s;t=n,e=i}return{commitment:t,config:e}}function Oo(s){return s.map(t=>"memcmp"in t?{...t,memcmp:{...t.memcmp,encoding:t.memcmp.encoding??"base58"}}:t)}function Ic(s){return It([L({jsonrpc:pt("2.0"),id:P(),result:s}),L({jsonrpc:pt("2.0"),id:P(),error:L({code:je(),message:P(),data:V(nc())})})])}const Rh=Ic(je());function St(s){return on(Ic(s),Rh,t=>"error"in t?t:{...t,result:O(t.result,s)})}function Jt(s){return St(L({context:L({slot:b()}),value:s}))}function Ss(s){return L({context:L({slot:b()}),value:s})}function ai(s,t){return s===0?new ch({header:t.header,staticAccountKeys:t.accountKeys.map(e=>new wt(e)),recentBlockhash:t.recentBlockhash,compiledInstructions:t.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:Et.decode(e.data)})),addressTableLookups:t.addressTableLookups}):new kr(t)}const Mh=L({foundation:b(),foundationTerm:b(),initial:b(),taper:b(),terminal:b()}),Th=St($(K(L({epoch:b(),effectiveSlot:b(),amount:b(),postBalance:b(),commission:V(K(b()))})))),Ch=$(L({slot:b(),prioritizationFee:b()})),Lh=L({total:b(),validator:b(),foundation:b(),epoch:b()}),Uh=L({epoch:b(),slotIndex:b(),slotsInEpoch:b(),absoluteSlot:b(),blockHeight:V(b()),transactionCount:V(b())}),Nh=L({slotsPerEpoch:b(),leaderScheduleSlotOffset:b(),warmup:ve(),firstNormalEpoch:b(),firstNormalSlot:b()}),Ph=gs(P(),$(b())),On=K(It([L({}),P()])),Fh=L({err:On}),Oh=pt("receivedSignature"),$h=L({"solana-core":P(),"feature-set":V(b())}),qh=L({program:P(),programId:zt,parsed:je()}),Kh=L({programId:zt,accounts:$(zt),data:P()}),$o=Jt(L({err:K(It([L({}),P()])),logs:K($(P())),accounts:V(K($(K(L({executable:ve(),owner:P(),lamports:b(),data:$(P()),rentEpoch:V(b())}))))),unitsConsumed:V(b()),returnData:V(K(L({programId:P(),data:pr([P(),pt("base64")])}))),innerInstructions:V(K($(L({index:b(),instructions:$(It([qh,Kh]))}))))})),Dh=Jt(L({byIdentity:gs(P(),$(b())),range:L({firstSlot:b(),lastSlot:b()})}));function zh(s,t,e,n,i,r){const o=e||vh;let a;r!=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 u;return n&&(u=async(x,B)=>{const I=await new Promise((v,E)=>{try{n(x,B,(R,T)=>v([R,T]))}catch(R){E(R)}});return await o(...I)}),new Pf(async(x,B)=>{const I={method:"POST",body:x,agent:a,headers:Object.assign({"Content-Type":"application/json"},t||{},zd)};try{let v=5,E,R=500;for(;u?E=await u(s,I):E=await o(s,I),!(E.status!==429||i===!0||(v-=1,v===0));)console.error(`Server responded with ${E.status} ${E.statusText}. Retrying after ${R}ms delay...`),await Zn(R),R*=2;const T=await E.text();E.ok?B(null,T):B(new Error(`${E.status} ${E.statusText}: ${T}`))}catch(v){v instanceof Error&&B(v)}},{})}function Hh(s){return(t,e)=>new Promise((n,i)=>{s.request(t,e,(r,o)=>{if(r){i(r);return}n(o)})})}function Wh(s){return t=>new Promise((e,n)=>{t.length===0&&e([]);const i=t.map(r=>s.request(r.methodName,r.args));s.request(i,(r,o)=>{if(r){n(r);return}e(o)})})}const jh=St(Mh),Vh=St(Lh),Gh=St(Ch),Zh=St(Uh),Yh=St(Nh),Xh=St(Ph),Jh=St(b()),Qh=Jt(L({total:b(),circulating:b(),nonCirculating:b(),nonCirculatingAccounts:$(zt)})),_i=L({amount:P(),uiAmount:K(b()),decimals:b(),uiAmountString:V(P())}),td=Jt($(L({address:zt,amount:P(),uiAmount:K(b()),decimals:b(),uiAmountString:V(P())}))),ed=Jt($(L({pubkey:zt,account:L({executable:ve(),owner:zt,lamports:b(),data:Ji,rentEpoch:b()})}))),ki=L({program:P(),parsed:je(),space:b()}),nd=Jt($(L({pubkey:zt,account:L({executable:ve(),owner:zt,lamports:b(),data:ki,rentEpoch:b()})}))),rd=Jt($(L({lamports:b(),address:zt}))),Er=L({executable:ve(),owner:zt,lamports:b(),data:Ji,rentEpoch:b()}),sd=L({pubkey:zt,account:Er}),id=on(It([dr(Y.Buffer),ki]),It([Ac,ki]),s=>Array.isArray(s)?O(s,Ji):s),Ei=L({executable:ve(),owner:zt,lamports:b(),data:id,rentEpoch:b()}),od=L({pubkey:zt,account:Ei}),ad=L({state:It([pt("active"),pt("inactive"),pt("activating"),pt("deactivating")]),active:b(),inactive:b()}),cd=St($(L({signature:P(),slot:b(),err:On,memo:K(P()),blockTime:V(K(b()))}))),ud=St($(L({signature:P(),slot:b(),err:On,memo:K(P()),blockTime:V(K(b()))}))),ld=L({subscription:b(),result:Ss(Er)}),fd=L({pubkey:zt,account:Er}),hd=L({subscription:b(),result:Ss(fd)}),dd=L({parent:b(),slot:b(),root:b()}),pd=L({subscription:b(),result:dd}),gd=It([L({type:It([pt("firstShredReceived"),pt("completed"),pt("optimisticConfirmation"),pt("root")]),slot:b(),timestamp:b()}),L({type:pt("createdBank"),parent:b(),slot:b(),timestamp:b()}),L({type:pt("frozen"),slot:b(),timestamp:b(),stats:L({numTransactionEntries:b(),numSuccessfulTransactions:b(),numFailedTransactions:b(),maxTransactionsPerEntry:b()})}),L({type:pt("dead"),slot:b(),timestamp:b(),err:P()})]),md=L({subscription:b(),result:gd}),yd=L({subscription:b(),result:Ss(It([Fh,Oh]))}),wd=L({subscription:b(),result:b()}),bd=L({pubkey:P(),gossip:K(P()),tpu:K(P()),rpc:K(P()),version:K(P())}),qo=L({votePubkey:P(),nodePubkey:P(),activatedStake:b(),epochVoteAccount:ve(),epochCredits:$(pr([b(),b(),b()])),commission:b(),lastVote:b(),rootSlot:K(b())}),Sd=St(L({current:$(qo),delinquent:$(qo)})),vd=It([pt("processed"),pt("confirmed"),pt("finalized")]),xd=L({slot:b(),confirmations:K(b()),err:On,confirmationStatus:V(vd)}),_d=Jt($(K(xd))),kd=St(b()),Rc=L({accountKey:zt,writableIndexes:$(b()),readonlyIndexes:$(b())}),Qi=L({signatures:$(P()),message:L({accountKeys:$(P()),header:L({numRequiredSignatures:b(),numReadonlySignedAccounts:b(),numReadonlyUnsignedAccounts:b()}),instructions:$(L({accounts:$(b()),data:P(),programIdIndex:b()})),recentBlockhash:P(),addressTableLookups:V($(Rc))})}),Mc=L({pubkey:zt,signer:ve(),writable:ve(),source:V(It([pt("transaction"),pt("lookupTable")]))}),Tc=L({accountKeys:$(Mc),signatures:$(P())}),Cc=L({parsed:je(),program:P(),programId:zt}),Lc=L({accounts:$(zt),data:P(),programId:zt}),Ed=It([Lc,Cc]),Bd=It([L({parsed:je(),program:P(),programId:P()}),L({accounts:$(P()),data:P(),programId:P()})]),Uc=on(Ed,Bd,s=>"accounts"in s?O(s,Lc):O(s,Cc)),Nc=L({signatures:$(P()),message:L({accountKeys:$(Mc),instructions:$(Uc),recentBlockhash:P(),addressTableLookups:V(K($(Rc)))})}),os=L({accountIndex:b(),mint:P(),owner:V(P()),programId:V(P()),uiTokenAmount:_i}),Pc=L({writable:$(zt),readonly:$(zt)}),vs=L({err:On,fee:b(),innerInstructions:V(K($(L({index:b(),instructions:$(L({accounts:$(b()),data:P(),programIdIndex:b()}))})))),preBalances:$(b()),postBalances:$(b()),logMessages:V(K($(P()))),preTokenBalances:V(K($(os))),postTokenBalances:V(K($(os))),loadedAddresses:V(Pc),computeUnitsConsumed:V(b()),costUnits:V(b())}),to=L({err:On,fee:b(),innerInstructions:V(K($(L({index:b(),instructions:$(Uc)})))),preBalances:$(b()),postBalances:$(b()),logMessages:V(K($(P()))),preTokenBalances:V(K($(os))),postTokenBalances:V(K($(os))),loadedAddresses:V(Pc),computeUnitsConsumed:V(b()),costUnits:V(b())}),gr=It([pt(0),pt("legacy")]),$n=L({pubkey:P(),lamports:b(),postBalance:K(b()),rewardType:K(P()),commission:V(K(b()))}),Ad=St(K(L({blockhash:P(),previousBlockhash:P(),parentSlot:b(),transactions:$(L({transaction:Qi,meta:K(vs),version:V(gr)})),rewards:V($($n)),blockTime:K(b()),blockHeight:K(b())}))),Id=St(K(L({blockhash:P(),previousBlockhash:P(),parentSlot:b(),rewards:V($($n)),blockTime:K(b()),blockHeight:K(b())}))),Rd=St(K(L({blockhash:P(),previousBlockhash:P(),parentSlot:b(),transactions:$(L({transaction:Tc,meta:K(vs),version:V(gr)})),rewards:V($($n)),blockTime:K(b()),blockHeight:K(b())}))),Md=St(K(L({blockhash:P(),previousBlockhash:P(),parentSlot:b(),transactions:$(L({transaction:Nc,meta:K(to),version:V(gr)})),rewards:V($($n)),blockTime:K(b()),blockHeight:K(b())}))),Td=St(K(L({blockhash:P(),previousBlockhash:P(),parentSlot:b(),transactions:$(L({transaction:Tc,meta:K(to),version:V(gr)})),rewards:V($($n)),blockTime:K(b()),blockHeight:K(b())}))),Cd=St(K(L({blockhash:P(),previousBlockhash:P(),parentSlot:b(),rewards:V($($n)),blockTime:K(b()),blockHeight:K(b())}))),Ld=St(K(L({blockhash:P(),previousBlockhash:P(),parentSlot:b(),transactions:$(L({transaction:Qi,meta:K(vs)})),rewards:V($($n)),blockTime:K(b())}))),Ko=St(K(L({blockhash:P(),previousBlockhash:P(),parentSlot:b(),signatures:$(P()),blockTime:K(b())}))),ci=St(K(L({slot:b(),meta:K(vs),blockTime:V(K(b())),transaction:Qi,version:V(gr)}))),zr=St(K(L({slot:b(),transaction:Nc,meta:K(to),blockTime:V(K(b())),version:V(gr)}))),Ud=Jt(L({blockhash:P(),lastValidBlockHeight:b()})),Nd=Jt(ve()),Pd=L({slot:b(),numTransactions:b(),numSlots:b(),samplePeriodSecs:b()}),Fd=St($(Pd)),Od=Jt(K(L({feeCalculator:L({lamportsPerSignature:b()})}))),$d=St(P()),qd=St(P()),Kd=L({err:On,logs:$(P()),signature:P()}),Dd=L({result:Ss(Kd),subscription:b()}),zd={"solana-client":"js/1.0.0-maintenance"};let eg=class{constructor(t,e){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 x=>{const{commitment:B,config:I}=Ut(x),v=this._buildArgs([],B,void 0,I),E=No(v);return g[E]=g[E]??(async()=>{try{const R=await this._rpcRequest("getBlockHeight",v),T=O(R,St(b()));if("error"in T)throw new it(T.error,"failed to get block height information");return T.result}finally{delete g[E]}})(),await g[E]}})();let n,i,r,o,a,u;e&&typeof e=="string"?this._commitment=e:e&&(this._commitment=e.commitment,this._confirmTransactionInitialTimeout=e.confirmTransactionInitialTimeout,n=e.wsEndpoint,i=e.httpHeaders,r=e.fetch,o=e.fetchMiddleware,a=e.disableRetryOnRateLimit,u=e.httpAgent),this._rpcEndpoint=Ih(t),this._rpcWsEndpoint=n||Bh(t),this._rpcClient=zh(t,i,r,o,a,u),this._rpcRequest=Hh(this._rpcClient),this._rpcBatchRequest=Wh(this._rpcClient),this._rpcWebSocket=new xh(this._rpcWsEndpoint,{autoconnect:!1,max_reconnects:1/0}),this._rpcWebSocket.on("open",this._wsOnOpen.bind(this)),this._rpcWebSocket.on("error",this._wsOnError.bind(this)),this._rpcWebSocket.on("close",this._wsOnClose.bind(this)),this._rpcWebSocket.on("accountNotification",this._wsOnAccountNotification.bind(this)),this._rpcWebSocket.on("programNotification",this._wsOnProgramAccountNotification.bind(this)),this._rpcWebSocket.on("slotNotification",this._wsOnSlotNotification.bind(this)),this._rpcWebSocket.on("slotsUpdatesNotification",this._wsOnSlotUpdatesNotification.bind(this)),this._rpcWebSocket.on("signatureNotification",this._wsOnSignatureNotification.bind(this)),this._rpcWebSocket.on("rootNotification",this._wsOnRootNotification.bind(this)),this._rpcWebSocket.on("logsNotification",this._wsOnLogsNotification.bind(this))}get commitment(){return this._commitment}get rpcEndpoint(){return this._rpcEndpoint}async getBalanceAndContext(t,e){const{commitment:n,config:i}=Ut(e),r=this._buildArgs([t.toBase58()],n,void 0,i),o=await this._rpcRequest("getBalance",r),a=O(o,Jt(b()));if("error"in a)throw new it(a.error,`failed to get balance for ${t.toBase58()}`);return a.result}async getBalance(t,e){return await this.getBalanceAndContext(t,e).then(n=>n.value).catch(n=>{throw new Error("failed to get balance of account "+t.toBase58()+": "+n)})}async getBlockTime(t){const e=await this._rpcRequest("getBlockTime",[t]),n=O(e,St(K(b())));if("error"in n)throw new it(n.error,`failed to get block time for slot ${t}`);return n.result}async getMinimumLedgerSlot(){const t=await this._rpcRequest("minimumLedgerSlot",[]),e=O(t,St(b()));if("error"in e)throw new it(e.error,"failed to get minimum ledger slot");return e.result}async getFirstAvailableBlock(){const t=await this._rpcRequest("getFirstAvailableBlock",[]),e=O(t,Jh);if("error"in e)throw new it(e.error,"failed to get first available block");return e.result}async getSupply(t){let e={};typeof t=="string"?e={commitment:t}:t?e={...t,commitment:t&&t.commitment||this.commitment}:e={commitment:this.commitment};const n=await this._rpcRequest("getSupply",[e]),i=O(n,Qh);if("error"in i)throw new it(i.error,"failed to get supply");return i.result}async getTokenSupply(t,e){const n=this._buildArgs([t.toBase58()],e),i=await this._rpcRequest("getTokenSupply",n),r=O(i,Jt(_i));if("error"in r)throw new it(r.error,"failed to get token supply");return r.result}async getTokenAccountBalance(t,e){const n=this._buildArgs([t.toBase58()],e),i=await this._rpcRequest("getTokenAccountBalance",n),r=O(i,Jt(_i));if("error"in r)throw new it(r.error,"failed to get token account balance");return r.result}async getTokenAccountsByOwner(t,e,n){const{commitment:i,config:r}=Ut(n);let o=[t.toBase58()];"mint"in e?o.push({mint:e.mint.toBase58()}):o.push({programId:e.programId.toBase58()});const a=this._buildArgs(o,i,"base64",r),u=await this._rpcRequest("getTokenAccountsByOwner",a),g=O(u,ed);if("error"in g)throw new it(g.error,`failed to get token accounts owned by account ${t.toBase58()}`);return g.result}async getParsedTokenAccountsByOwner(t,e,n){let i=[t.toBase58()];"mint"in e?i.push({mint:e.mint.toBase58()}):i.push({programId:e.programId.toBase58()});const r=this._buildArgs(i,n,"jsonParsed"),o=await this._rpcRequest("getTokenAccountsByOwner",r),a=O(o,nd);if("error"in a)throw new it(a.error,`failed to get token accounts owned by account ${t.toBase58()}`);return a.result}async getLargestAccounts(t){const e={...t,commitment:t&&t.commitment||this.commitment},n=e.filter||e.commitment?[e]:[],i=await this._rpcRequest("getLargestAccounts",n),r=O(i,rd);if("error"in r)throw new it(r.error,"failed to get largest accounts");return r.result}async getTokenLargestAccounts(t,e){const n=this._buildArgs([t.toBase58()],e),i=await this._rpcRequest("getTokenLargestAccounts",n),r=O(i,td);if("error"in r)throw new it(r.error,"failed to get token largest accounts");return r.result}async getAccountInfoAndContext(t,e){const{commitment:n,config:i}=Ut(e),r=this._buildArgs([t.toBase58()],n,"base64",i),o=await this._rpcRequest("getAccountInfo",r),a=O(o,Jt(K(Er)));if("error"in a)throw new it(a.error,`failed to get info about account ${t.toBase58()}`);return a.result}async getParsedAccountInfo(t,e){const{commitment:n,config:i}=Ut(e),r=this._buildArgs([t.toBase58()],n,"jsonParsed",i),o=await this._rpcRequest("getAccountInfo",r),a=O(o,Jt(K(Ei)));if("error"in a)throw new it(a.error,`failed to get info about account ${t.toBase58()}`);return a.result}async getAccountInfo(t,e){try{return(await this.getAccountInfoAndContext(t,e)).value}catch(n){throw new Error("failed to get info about account "+t.toBase58()+": "+n)}}async getMultipleParsedAccounts(t,e){const{commitment:n,config:i}=Ut(e),r=t.map(g=>g.toBase58()),o=this._buildArgs([r],n,"jsonParsed",i),a=await this._rpcRequest("getMultipleAccounts",o),u=O(a,Jt($(K(Ei))));if("error"in u)throw new it(u.error,`failed to get info for accounts ${r}`);return u.result}async getMultipleAccountsInfoAndContext(t,e){const{commitment:n,config:i}=Ut(e),r=t.map(g=>g.toBase58()),o=this._buildArgs([r],n,"base64",i),a=await this._rpcRequest("getMultipleAccounts",o),u=O(a,Jt($(K(Er))));if("error"in u)throw new it(u.error,`failed to get info for accounts ${r}`);return u.result}async getMultipleAccountsInfo(t,e){return(await this.getMultipleAccountsInfoAndContext(t,e)).value}async getStakeActivation(t,e,n){const{commitment:i,config:r}=Ut(e),o=this._buildArgs([t.toBase58()],i,void 0,{...r,epoch:n??(r==null?void 0:r.epoch)}),a=await this._rpcRequest("getStakeActivation",o),u=O(a,St(ad));if("error"in u)throw new it(u.error,`failed to get Stake Activation ${t.toBase58()}`);return u.result}async getProgramAccounts(t,e){const{commitment:n,config:i}=Ut(e),{encoding:r,...o}=i||{},a=this._buildArgs([t.toBase58()],n,r||"base64",{...o,...o.filters?{filters:Oo(o.filters)}:null}),u=await this._rpcRequest("getProgramAccounts",a),g=$(sd),x=o.withContext===!0?O(u,Jt(g)):O(u,St(g));if("error"in x)throw new it(x.error,`failed to get accounts owned by program ${t.toBase58()}`);return x.result}async getParsedProgramAccounts(t,e){const{commitment:n,config:i}=Ut(e),r=this._buildArgs([t.toBase58()],n,"jsonParsed",i),o=await this._rpcRequest("getProgramAccounts",r),a=O(o,St($(od)));if("error"in a)throw new it(a.error,`failed to get accounts owned by program ${t.toBase58()}`);return a.result}async confirmTransaction(t,e){var r;let n;if(typeof t=="string")n=t;else{const o=t;if((r=o.abortSignal)!=null&&r.aborted)return Promise.reject(o.abortSignal.reason);n=o.signature}let i;try{i=Et.decode(n)}catch{throw new Error("signature must be base58 encoded: "+n)}return we(i.length===64,"signature has invalid length"),typeof t=="string"?await this.confirmTransactionUsingLegacyTimeoutStrategy({commitment:e||this.commitment,signature:n}):"lastValidBlockHeight"in t?await this.confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:e||this.commitment,strategy:t}):await this.confirmTransactionUsingDurableNonceStrategy({commitment:e||this.commitment,strategy:t})}getCancellationPromise(t){return new Promise((e,n)=>{t!=null&&(t.aborted?n(t.reason):t.addEventListener("abort",()=>{n(t.reason)}))})}getTransactionConfirmationPromise({commitment:t,signature:e}){let n,i,r=!1;const o=new Promise((u,g)=>{try{n=this.onSignature(e,(B,I)=>{n=void 0;const v={context:I,value:B};u({__type:bn.PROCESSED,response:v})},t);const x=new Promise(B=>{n==null?B():i=this._onSubscriptionStateChange(n,I=>{I==="subscribed"&&B()})});(async()=>{if(await x,r)return;const B=await this.getSignatureStatus(e);if(r||B==null)return;const{context:I,value:v}=B;if(v!=null)if(v!=null&&v.err)g(v.err);else{switch(t){case"confirmed":case"single":case"singleGossip":{if(v.confirmationStatus==="processed")return;break}case"finalized":case"max":case"root":{if(v.confirmationStatus==="processed"||v.confirmationStatus==="confirmed")return;break}case"processed":case"recent":}r=!0,u({__type:bn.PROCESSED,response:{context:I,value:v}})}})()}catch(x){g(x)}});return{abortConfirmation:()=>{i&&(i(),i=void 0),n!=null&&(this.removeSignatureListener(n),n=void 0)},confirmationPromise:o}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:t,strategy:{abortSignal:e,lastValidBlockHeight:n,signature:i}}){let r=!1;const o=new Promise(B=>{const I=async()=>{try{return await this.getBlockHeight(t)}catch{return-1}};(async()=>{let v=await I();if(!r){for(;v<=n;)if(await Zn(1e3),r||(v=await I(),r))return;B({__type:bn.BLOCKHEIGHT_EXCEEDED})}})()}),{abortConfirmation:a,confirmationPromise:u}=this.getTransactionConfirmationPromise({commitment:t,signature:i}),g=this.getCancellationPromise(e);let x;try{const B=await Promise.race([g,u,o]);if(B.__type===bn.PROCESSED)x=B.response;else throw new Sc(i)}finally{r=!0,a()}return x}async confirmTransactionUsingDurableNonceStrategy({commitment:t,strategy:{abortSignal:e,minContextSlot:n,nonceAccountPubkey:i,nonceValue:r,signature:o}}){let a=!1;const u=new Promise(v=>{let E=r,R=null;const T=async()=>{try{const{context:N,value:W}=await this.getNonceAndContext(i,{commitment:t,minContextSlot:n});return R=N.slot,W==null?void 0:W.nonce}catch{return E}};(async()=>{if(E=await T(),!a)for(;;){if(r!==E){v({__type:bn.NONCE_INVALID,slotInWhichNonceDidAdvance:R});return}if(await Zn(2e3),a||(E=await T(),a))return}})()}),{abortConfirmation:g,confirmationPromise:x}=this.getTransactionConfirmationPromise({commitment:t,signature:o}),B=this.getCancellationPromise(e);let I;try{const v=await Promise.race([B,x,u]);if(v.__type===bn.PROCESSED)I=v.response;else{let E;for(;;){const R=await this.getSignatureStatus(o);if(R==null)break;if(R.context.slot<(v.slotInWhichNonceDidAdvance??n)){await Zn(400);continue}E=R;break}if(E!=null&&E.value){const R=t||"finalized",{confirmationStatus:T}=E.value;switch(R){case"processed":case"recent":if(T!=="processed"&&T!=="confirmed"&&T!=="finalized")throw new Sr(o);break;case"confirmed":case"single":case"singleGossip":if(T!=="confirmed"&&T!=="finalized")throw new Sr(o);break;case"finalized":case"max":case"root":if(T!=="finalized")throw new Sr(o);break;default:}I={context:E.context,value:{err:E.value.err}}}else throw new Sr(o)}}finally{a=!0,g()}return I}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:t,signature:e}){let n;const i=new Promise(u=>{let g=this._confirmTransactionInitialTimeout||6e4;switch(t){case"processed":case"recent":case"single":case"confirmed":case"singleGossip":{g=this._confirmTransactionInitialTimeout||3e4;break}}n=setTimeout(()=>u({__type:bn.TIMED_OUT,timeoutMs:g}),g)}),{abortConfirmation:r,confirmationPromise:o}=this.getTransactionConfirmationPromise({commitment:t,signature:e});let a;try{const u=await Promise.race([o,i]);if(u.__type===bn.PROCESSED)a=u.response;else throw new vc(e,u.timeoutMs/1e3)}finally{clearTimeout(n),r()}return a}async getClusterNodes(){const t=await this._rpcRequest("getClusterNodes",[]),e=O(t,St($(bd)));if("error"in e)throw new it(e.error,"failed to get cluster nodes");return e.result}async getVoteAccounts(t){const e=this._buildArgs([],t),n=await this._rpcRequest("getVoteAccounts",e),i=O(n,Sd);if("error"in i)throw new it(i.error,"failed to get vote accounts");return i.result}async getSlot(t){const{commitment:e,config:n}=Ut(t),i=this._buildArgs([],e,void 0,n),r=await this._rpcRequest("getSlot",i),o=O(r,St(b()));if("error"in o)throw new it(o.error,"failed to get slot");return o.result}async getSlotLeader(t){const{commitment:e,config:n}=Ut(t),i=this._buildArgs([],e,void 0,n),r=await this._rpcRequest("getSlotLeader",i),o=O(r,St(P()));if("error"in o)throw new it(o.error,"failed to get slot leader");return o.result}async getSlotLeaders(t,e){const n=[t,e],i=await this._rpcRequest("getSlotLeaders",n),r=O(i,St($(zt)));if("error"in r)throw new it(r.error,"failed to get slot leaders");return r.result}async getSignatureStatus(t,e){const{context:n,value:i}=await this.getSignatureStatuses([t],e);we(i.length===1);const r=i[0];return{context:n,value:r}}async getSignatureStatuses(t,e){const n=[t];e&&n.push(e);const i=await this._rpcRequest("getSignatureStatuses",n),r=O(i,_d);if("error"in r)throw new it(r.error,"failed to get signature status");return r.result}async getTransactionCount(t){const{commitment:e,config:n}=Ut(t),i=this._buildArgs([],e,void 0,n),r=await this._rpcRequest("getTransactionCount",i),o=O(r,St(b()));if("error"in o)throw new it(o.error,"failed to get transaction count");return o.result}async getTotalSupply(t){return(await this.getSupply({commitment:t,excludeNonCirculatingAccountsList:!0})).value.total}async getInflationGovernor(t){const e=this._buildArgs([],t),n=await this._rpcRequest("getInflationGovernor",e),i=O(n,jh);if("error"in i)throw new it(i.error,"failed to get inflation");return i.result}async getInflationReward(t,e,n){const{commitment:i,config:r}=Ut(n),o=this._buildArgs([t.map(g=>g.toBase58())],i,void 0,{...r,epoch:e??(r==null?void 0:r.epoch)}),a=await this._rpcRequest("getInflationReward",o),u=O(a,Th);if("error"in u)throw new it(u.error,"failed to get inflation reward");return u.result}async getInflationRate(){const t=await this._rpcRequest("getInflationRate",[]),e=O(t,Vh);if("error"in e)throw new it(e.error,"failed to get inflation rate");return e.result}async getEpochInfo(t){const{commitment:e,config:n}=Ut(t),i=this._buildArgs([],e,void 0,n),r=await this._rpcRequest("getEpochInfo",i),o=O(r,Zh);if("error"in o)throw new it(o.error,"failed to get epoch info");return o.result}async getEpochSchedule(){const t=await this._rpcRequest("getEpochSchedule",[]),e=O(t,Yh);if("error"in e)throw new it(e.error,"failed to get epoch schedule");const n=e.result;return new Sh(n.slotsPerEpoch,n.leaderScheduleSlotOffset,n.warmup,n.firstNormalEpoch,n.firstNormalSlot)}async getLeaderSchedule(){const t=await this._rpcRequest("getLeaderSchedule",[]),e=O(t,Xh);if("error"in e)throw new it(e.error,"failed to get leader schedule");return e.result}async getMinimumBalanceForRentExemption(t,e){const n=this._buildArgs([t],e),i=await this._rpcRequest("getMinimumBalanceForRentExemption",n),r=O(i,kd);return"error"in r?(console.warn("Unable to fetch minimum balance for rent exemption"),0):r.result}async getRecentBlockhashAndContext(t){const{context:e,value:{blockhash:n}}=await this.getLatestBlockhashAndContext(t);return{context:e,value:{blockhash:n,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(t){const e=await this._rpcRequest("getRecentPerformanceSamples",t?[t]:[]),n=O(e,Fd);if("error"in n)throw new it(n.error,"failed to get recent performance samples");return n.result}async getFeeCalculatorForBlockhash(t,e){const n=this._buildArgs([t],e),i=await this._rpcRequest("getFeeCalculatorForBlockhash",n),r=O(i,Od);if("error"in r)throw new it(r.error,"failed to get fee calculator");const{context:o,value:a}=r.result;return{context:o,value:a!==null?a.feeCalculator:null}}async getFeeForMessage(t,e){const n=ar(t.serialize()).toString("base64"),i=this._buildArgs([n],e),r=await this._rpcRequest("getFeeForMessage",i),o=O(r,Jt(K(b())));if("error"in o)throw new it(o.error,"failed to get fee for message");if(o.result===null)throw new Error("invalid blockhash");return o.result}async getRecentPrioritizationFees(t){var o;const e=(o=t==null?void 0:t.lockedWritableAccounts)==null?void 0:o.map(a=>a.toBase58()),n=e!=null&&e.length?[e]:[],i=await this._rpcRequest("getRecentPrioritizationFees",n),r=O(i,Gh);if("error"in r)throw new it(r.error,"failed to get recent prioritization fees");return r.result}async getRecentBlockhash(t){try{return(await this.getRecentBlockhashAndContext(t)).value}catch(e){throw new Error("failed to get recent blockhash: "+e)}}async getLatestBlockhash(t){try{return(await this.getLatestBlockhashAndContext(t)).value}catch(e){throw new Error("failed to get recent blockhash: "+e)}}async getLatestBlockhashAndContext(t){const{commitment:e,config:n}=Ut(t),i=this._buildArgs([],e,void 0,n),r=await this._rpcRequest("getLatestBlockhash",i),o=O(r,Ud);if("error"in o)throw new it(o.error,"failed to get latest blockhash");return o.result}async isBlockhashValid(t,e){const{commitment:n,config:i}=Ut(e),r=this._buildArgs([t],n,void 0,i),o=await this._rpcRequest("isBlockhashValid",r),a=O(o,Nd);if("error"in a)throw new it(a.error,"failed to determine if the blockhash `"+t+"`is valid");return a.result}async getVersion(){const t=await this._rpcRequest("getVersion",[]),e=O(t,St($h));if("error"in e)throw new it(e.error,"failed to get version");return e.result}async getGenesisHash(){const t=await this._rpcRequest("getGenesisHash",[]),e=O(t,St(P()));if("error"in e)throw new it(e.error,"failed to get genesis hash");return e.result}async getBlock(t,e){const{commitment:n,config:i}=Ut(e),r=this._buildArgsAtLeastConfirmed([t],n,void 0,i),o=await this._rpcRequest("getBlock",r);try{switch(i==null?void 0:i.transactionDetails){case"accounts":{const a=O(o,Rd);if("error"in a)throw a.error;return a.result}case"none":{const a=O(o,Id);if("error"in a)throw a.error;return a.result}default:{const a=O(o,Ad);if("error"in a)throw a.error;const{result:u}=a;return u?{...u,transactions:u.transactions.map(({transaction:g,meta:x,version:B})=>({meta:x,transaction:{...g,message:ai(B,g.message)},version:B}))}:null}}}catch(a){throw new it(a,"failed to get confirmed block")}}async getParsedBlock(t,e){const{commitment:n,config:i}=Ut(e),r=this._buildArgsAtLeastConfirmed([t],n,"jsonParsed",i),o=await this._rpcRequest("getBlock",r);try{switch(i==null?void 0:i.transactionDetails){case"accounts":{const a=O(o,Td);if("error"in a)throw a.error;return a.result}case"none":{const a=O(o,Cd);if("error"in a)throw a.error;return a.result}default:{const a=O(o,Md);if("error"in a)throw a.error;return a.result}}}catch(a){throw new it(a,"failed to get block")}}async getBlockProduction(t){let e,n;if(typeof t=="string")n=t;else if(t){const{commitment:a,...u}=t;n=a,e=u}const i=this._buildArgs([],n,"base64",e),r=await this._rpcRequest("getBlockProduction",i),o=O(r,Dh);if("error"in o)throw new it(o.error,"failed to get block production information");return o.result}async getTransaction(t,e){const{commitment:n,config:i}=Ut(e),r=this._buildArgsAtLeastConfirmed([t],n,void 0,i),o=await this._rpcRequest("getTransaction",r),a=O(o,ci);if("error"in a)throw new it(a.error,"failed to get transaction");const u=a.result;return u&&{...u,transaction:{...u.transaction,message:ai(u.version,u.transaction.message)}}}async getParsedTransaction(t,e){const{commitment:n,config:i}=Ut(e),r=this._buildArgsAtLeastConfirmed([t],n,"jsonParsed",i),o=await this._rpcRequest("getTransaction",r),a=O(o,zr);if("error"in a)throw new it(a.error,"failed to get transaction");return a.result}async getParsedTransactions(t,e){const{commitment:n,config:i}=Ut(e),r=t.map(u=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([u],n,"jsonParsed",i)}));return(await this._rpcBatchRequest(r)).map(u=>{const g=O(u,zr);if("error"in g)throw new it(g.error,"failed to get transactions");return g.result})}async getTransactions(t,e){const{commitment:n,config:i}=Ut(e),r=t.map(u=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([u],n,void 0,i)}));return(await this._rpcBatchRequest(r)).map(u=>{const g=O(u,ci);if("error"in g)throw new it(g.error,"failed to get transactions");const x=g.result;return x&&{...x,transaction:{...x.transaction,message:ai(x.version,x.transaction.message)}}})}async getConfirmedBlock(t,e){const n=this._buildArgsAtLeastConfirmed([t],e),i=await this._rpcRequest("getBlock",n),r=O(i,Ld);if("error"in r)throw new it(r.error,"failed to get confirmed block");const o=r.result;if(!o)throw new Error("Confirmed block "+t+" not found");const a={...o,transactions:o.transactions.map(({transaction:u,meta:g})=>{const x=new kr(u.message);return{meta:g,transaction:{...u,message:x}}})};return{...a,transactions:a.transactions.map(({transaction:u,meta:g})=>({meta:g,transaction:yr.populate(u.message,u.signatures)}))}}async getBlocks(t,e,n){const i=this._buildArgsAtLeastConfirmed(e!==void 0?[t,e]:[t],n),r=await this._rpcRequest("getBlocks",i),o=O(r,St($(b())));if("error"in o)throw new it(o.error,"failed to get blocks");return o.result}async getBlockSignatures(t,e){const n=this._buildArgsAtLeastConfirmed([t],e,void 0,{transactionDetails:"signatures",rewards:!1}),i=await this._rpcRequest("getBlock",n),r=O(i,Ko);if("error"in r)throw new it(r.error,"failed to get block");const o=r.result;if(!o)throw new Error("Block "+t+" not found");return o}async getConfirmedBlockSignatures(t,e){const n=this._buildArgsAtLeastConfirmed([t],e,void 0,{transactionDetails:"signatures",rewards:!1}),i=await this._rpcRequest("getBlock",n),r=O(i,Ko);if("error"in r)throw new it(r.error,"failed to get confirmed block");const o=r.result;if(!o)throw new Error("Confirmed block "+t+" not found");return o}async getConfirmedTransaction(t,e){const n=this._buildArgsAtLeastConfirmed([t],e),i=await this._rpcRequest("getTransaction",n),r=O(i,ci);if("error"in r)throw new it(r.error,"failed to get transaction");const o=r.result;if(!o)return o;const a=new kr(o.transaction.message),u=o.transaction.signatures;return{...o,transaction:yr.populate(a,u)}}async getParsedConfirmedTransaction(t,e){const n=this._buildArgsAtLeastConfirmed([t],e,"jsonParsed"),i=await this._rpcRequest("getTransaction",n),r=O(i,zr);if("error"in r)throw new it(r.error,"failed to get confirmed transaction");return r.result}async getParsedConfirmedTransactions(t,e){const n=t.map(o=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([o],e,"jsonParsed")}));return(await this._rpcBatchRequest(n)).map(o=>{const a=O(o,zr);if("error"in a)throw new it(a.error,"failed to get confirmed transactions");return a.result})}async getConfirmedSignaturesForAddress(t,e,n){let i={},r=await this.getFirstAvailableBlock();for(;!("until"in i)&&(e--,!(e<=0||e<r));)try{const u=await this.getConfirmedBlockSignatures(e,"finalized");u.signatures.length>0&&(i.until=u.signatures[u.signatures.length-1].toString())}catch(u){if(u instanceof Error&&u.message.includes("skipped"))continue;throw u}let o=await this.getSlot("finalized");for(;!("before"in i)&&(n++,!(n>o));)try{const u=await this.getConfirmedBlockSignatures(n);u.signatures.length>0&&(i.before=u.signatures[u.signatures.length-1].toString())}catch(u){if(u instanceof Error&&u.message.includes("skipped"))continue;throw u}return(await this.getConfirmedSignaturesForAddress2(t,i)).map(u=>u.signature)}async getConfirmedSignaturesForAddress2(t,e,n){const i=this._buildArgsAtLeastConfirmed([t.toBase58()],n,void 0,e),r=await this._rpcRequest("getConfirmedSignaturesForAddress2",i),o=O(r,cd);if("error"in o)throw new it(o.error,"failed to get confirmed signatures for address");return o.result}async getSignaturesForAddress(t,e,n){const i=this._buildArgsAtLeastConfirmed([t.toBase58()],n,void 0,e),r=await this._rpcRequest("getSignaturesForAddress",i),o=O(r,ud);if("error"in o)throw new it(o.error,"failed to get signatures for address");return o.result}async getAddressLookupTable(t,e){const{context:n,value:i}=await this.getAccountInfoAndContext(t,e);let r=null;return i!==null&&(r=new Fo({key:t,state:Fo.deserialize(i.data)})),{context:n,value:r}}async getNonceAndContext(t,e){const{context:n,value:i}=await this.getAccountInfoAndContext(t,e);let r=null;return i!==null&&(r=gh.fromAccountData(i.data)),{context:n,value:r}}async getNonce(t,e){return await this.getNonceAndContext(t,e).then(n=>n.value).catch(n=>{throw new Error("failed to get nonce for account "+t.toBase58()+": "+n)})}async requestAirdrop(t,e){const n=await this._rpcRequest("requestAirdrop",[t.toBase58(),e]),i=O(n,$d);if("error"in i)throw new it(i.error,`airdrop to ${t.toBase58()} failed`);return i.result}async _blockhashWithExpiryBlockHeight(t){if(!t){for(;this._pollingBlockhash;)await Zn(100);const n=Date.now()-this._blockhashInfo.lastFetch>=Ah;if(this._blockhashInfo.latestBlockhash!==null&&!n)return this._blockhashInfo.latestBlockhash}return await this._pollNewBlockhash()}async _pollNewBlockhash(){this._pollingBlockhash=!0;try{const t=Date.now(),e=this._blockhashInfo.latestBlockhash,n=e?e.blockhash:null;for(let i=0;i<50;i++){const r=await this.getLatestBlockhash("finalized");if(n!==r.blockhash)return this._blockhashInfo={latestBlockhash:r,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},r;await Zn(dh/2)}throw new Error(`Unable to obtain a new blockhash after ${Date.now()-t}ms`)}finally{this._pollingBlockhash=!1}}async getStakeMinimumDelegation(t){const{commitment:e,config:n}=Ut(t),i=this._buildArgs([],e,"base64",n),r=await this._rpcRequest("getStakeMinimumDelegation",i),o=O(r,Jt(b()));if("error"in o)throw new it(o.error,"failed to get stake minimum delegation");return o.result}async simulateTransaction(t,e,n){if("message"in t){const R=t.serialize(),T=Y.Buffer.from(R).toString("base64");if(Array.isArray(e)||n!==void 0)throw new Error("Invalid arguments");const N=e||{};N.encoding="base64","commitment"in N||(N.commitment=this.commitment),e&&typeof e=="object"&&"innerInstructions"in e&&(N.innerInstructions=e.innerInstructions);const W=[T,N],D=await this._rpcRequest("simulateTransaction",W),X=O(D,$o);if("error"in X)throw new Error("failed to simulate transaction: "+X.error.message);return X.result}let i;if(t instanceof yr){let E=t;i=new yr,i.feePayer=E.feePayer,i.instructions=t.instructions,i.nonceInfo=E.nonceInfo,i.signatures=E.signatures}else i=yr.populate(t),i._message=i._json=void 0;if(e!==void 0&&!Array.isArray(e))throw new Error("Invalid arguments");const r=e;if(i.nonceInfo&&r)i.sign(...r);else{let E=this._disableBlockhashCaching;for(;;){const R=await this._blockhashWithExpiryBlockHeight(E);if(i.lastValidBlockHeight=R.lastValidBlockHeight,i.recentBlockhash=R.blockhash,!r)break;if(i.sign(...r),!i.signature)throw new Error("!signature");const T=i.signature.toString("base64");if(!this._blockhashInfo.simulatedSignatures.includes(T)&&!this._blockhashInfo.transactionSignatures.includes(T)){this._blockhashInfo.simulatedSignatures.push(T);break}else E=!0}}const o=i._compile(),a=o.serialize(),g=i._serialize(a).toString("base64"),x={encoding:"base64",commitment:this.commitment};if(n){const E=(Array.isArray(n)?n:o.nonProgramIds()).map(R=>R.toBase58());x.accounts={encoding:"base64",addresses:E}}r&&(x.sigVerify=!0),e&&typeof e=="object"&&"innerInstructions"in e&&(x.innerInstructions=e.innerInstructions);const B=[g,x],I=await this._rpcRequest("simulateTransaction",B),v=O(I,$o);if("error"in v){let E;if("data"in v.error&&(E=v.error.data.logs,E&&Array.isArray(E))){const R=`
|
|
13
|
-
`,T=R+E.join(R);console.error(v.error.message,T)}throw new Lo({action:"simulate",signature:"",transactionMessage:v.error.message,logs:E})}return v.result}async sendTransaction(t,e,n){if("version"in t){if(e&&Array.isArray(e))throw new Error("Invalid arguments");const o=t.serialize();return await this.sendRawTransaction(o,e)}if(e===void 0||!Array.isArray(e))throw new Error("Invalid arguments");const i=e;if(t.nonceInfo)t.sign(...i);else{let o=this._disableBlockhashCaching;for(;;){const a=await this._blockhashWithExpiryBlockHeight(o);if(t.lastValidBlockHeight=a.lastValidBlockHeight,t.recentBlockhash=a.blockhash,t.sign(...i),!t.signature)throw new Error("!signature");const u=t.signature.toString("base64");if(this._blockhashInfo.transactionSignatures.includes(u))o=!0;else{this._blockhashInfo.transactionSignatures.push(u);break}}}const r=t.serialize();return await this.sendRawTransaction(r,n)}async sendRawTransaction(t,e){const n=ar(t).toString("base64");return await this.sendEncodedTransaction(n,e)}async sendEncodedTransaction(t,e){const n={encoding:"base64"},i=e&&e.skipPreflight,r=i===!0?"processed":e&&e.preflightCommitment||this.commitment;e&&e.maxRetries!=null&&(n.maxRetries=e.maxRetries),e&&e.minContextSlot!=null&&(n.minContextSlot=e.minContextSlot),i&&(n.skipPreflight=i),r&&(n.preflightCommitment=r);const o=[t,n],a=await this._rpcRequest("sendTransaction",o),u=O(a,qd);if("error"in u){let g;throw"data"in u.error&&(g=u.error.data.logs),new Lo({action:i?"send":"simulate",signature:"",transactionMessage:u.error.message,logs:g})}return u.result}_wsOnOpen(){this._rpcWebSocketConnected=!0,this._rpcWebSocketHeartbeat=setInterval(()=>{(async()=>{try{await this._rpcWebSocket.notify("ping")}catch{}})()},5e3),this._updateSubscriptions()}_wsOnError(t){this._rpcWebSocketConnected=!1,console.error("ws error:",t.message)}_wsOnClose(t){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),t===1e3){this._updateSubscriptions();return}this._subscriptionCallbacksByServerSubscriptionId={},Object.entries(this._subscriptionsByHash).forEach(([e,n])=>{this._setSubscription(e,{...n,state:"pending"})})}_setSubscription(t,e){var i;const n=(i=this._subscriptionsByHash[t])==null?void 0:i.state;if(this._subscriptionsByHash[t]=e,n!==e.state){const r=this._subscriptionStateChangeCallbacksByHash[t];r&&r.forEach(o=>{try{o(e.state)}catch{}})}}_onSubscriptionStateChange(t,e){var r;const n=this._subscriptionHashByClientSubscriptionId[t];if(n==null)return()=>{};const i=(r=this._subscriptionStateChangeCallbacksByHash)[n]||(r[n]=new Set);return i.add(e),()=>{i.delete(e),i.size===0&&delete this._subscriptionStateChangeCallbacksByHash[n]}}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(n){n instanceof Error&&console.log(`Error when closing socket connection: ${n.message}`)}},500));return}if(this._rpcWebSocketIdleTimeout!==null&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketConnected=!0),!this._rpcWebSocketConnected){this._rpcWebSocket.connect();return}const t=this._rpcWebSocketGeneration,e=()=>t===this._rpcWebSocketGeneration;await Promise.all(Object.keys(this._subscriptionsByHash).map(async n=>{const i=this._subscriptionsByHash[n];if(i!==void 0)switch(i.state){case"pending":case"unsubscribed":if(i.callbacks.size===0){delete this._subscriptionsByHash[n],i.state==="unsubscribed"&&delete this._subscriptionCallbacksByServerSubscriptionId[i.serverSubscriptionId],await this._updateSubscriptions();return}await(async()=>{const{args:r,method:o}=i;try{this._setSubscription(n,{...i,state:"subscribing"});const a=await this._rpcWebSocket.call(o,r);this._setSubscription(n,{...i,serverSubscriptionId:a,state:"subscribed"}),this._subscriptionCallbacksByServerSubscriptionId[a]=i.callbacks,await this._updateSubscriptions()}catch(a){if(console.error(`Received ${a instanceof Error?"":"JSON-RPC "}error calling \`${o}\``,{args:r,error:a}),!e())return;this._setSubscription(n,{...i,state:"pending"}),await this._updateSubscriptions()}})();break;case"subscribed":i.callbacks.size===0&&await(async()=>{const{serverSubscriptionId:r,unsubscribeMethod:o}=i;if(this._subscriptionsAutoDisposedByRpc.has(r))this._subscriptionsAutoDisposedByRpc.delete(r);else{this._setSubscription(n,{...i,state:"unsubscribing"}),this._setSubscription(n,{...i,state:"unsubscribing"});try{await this._rpcWebSocket.call(o,[r])}catch(a){if(a instanceof Error&&console.error(`${o} error:`,a.message),!e())return;this._setSubscription(n,{...i,state:"subscribed"}),await this._updateSubscriptions();return}}this._setSubscription(n,{...i,state:"unsubscribed"}),await this._updateSubscriptions()})();break}}))}_handleServerNotification(t,e){const n=this._subscriptionCallbacksByServerSubscriptionId[t];n!==void 0&&n.forEach(i=>{try{i(...e)}catch(r){console.error(r)}})}_wsOnAccountNotification(t){const{result:e,subscription:n}=O(t,ld);this._handleServerNotification(n,[e.value,e.context])}_makeSubscription(t,e){const n=this._nextClientSubscriptionId++,i=No([t.method,e]),r=this._subscriptionsByHash[i];return r===void 0?this._subscriptionsByHash[i]={...t,args:e,callbacks:new Set([t.callback]),state:"pending"}:r.callbacks.add(t.callback),this._subscriptionHashByClientSubscriptionId[n]=i,this._subscriptionDisposeFunctionsByClientSubscriptionId[n]=async()=>{delete this._subscriptionDisposeFunctionsByClientSubscriptionId[n],delete this._subscriptionHashByClientSubscriptionId[n];const o=this._subscriptionsByHash[i];we(o!==void 0,`Could not find a \`Subscription\` when tearing down client subscription #${n}`),o.callbacks.delete(t.callback),await this._updateSubscriptions()},this._updateSubscriptions(),n}onAccountChange(t,e,n){const{commitment:i,config:r}=Ut(n),o=this._buildArgs([t.toBase58()],i||this._commitment||"finalized","base64",r);return this._makeSubscription({callback:e,method:"accountSubscribe",unsubscribeMethod:"accountUnsubscribe"},o)}async removeAccountChangeListener(t){await this._unsubscribeClientSubscription(t,"account change")}_wsOnProgramAccountNotification(t){const{result:e,subscription:n}=O(t,hd);this._handleServerNotification(n,[{accountId:e.value.pubkey,accountInfo:e.value.account},e.context])}onProgramAccountChange(t,e,n,i){const{commitment:r,config:o}=Ut(n),a=this._buildArgs([t.toBase58()],r||this._commitment||"finalized","base64",o||(i?{filters:Oo(i)}:void 0));return this._makeSubscription({callback:e,method:"programSubscribe",unsubscribeMethod:"programUnsubscribe"},a)}async removeProgramAccountChangeListener(t){await this._unsubscribeClientSubscription(t,"program account change")}onLogs(t,e,n){const i=this._buildArgs([typeof t=="object"?{mentions:[t.toString()]}:t],n||this._commitment||"finalized");return this._makeSubscription({callback:e,method:"logsSubscribe",unsubscribeMethod:"logsUnsubscribe"},i)}async removeOnLogsListener(t){await this._unsubscribeClientSubscription(t,"logs")}_wsOnLogsNotification(t){const{result:e,subscription:n}=O(t,Dd);this._handleServerNotification(n,[e.value,e.context])}_wsOnSlotNotification(t){const{result:e,subscription:n}=O(t,pd);this._handleServerNotification(n,[e])}onSlotChange(t){return this._makeSubscription({callback:t,method:"slotSubscribe",unsubscribeMethod:"slotUnsubscribe"},[])}async removeSlotChangeListener(t){await this._unsubscribeClientSubscription(t,"slot change")}_wsOnSlotUpdatesNotification(t){const{result:e,subscription:n}=O(t,md);this._handleServerNotification(n,[e])}onSlotUpdate(t){return this._makeSubscription({callback:t,method:"slotsUpdatesSubscribe",unsubscribeMethod:"slotsUpdatesUnsubscribe"},[])}async removeSlotUpdateListener(t){await this._unsubscribeClientSubscription(t,"slot update")}async _unsubscribeClientSubscription(t,e){const n=this._subscriptionDisposeFunctionsByClientSubscriptionId[t];n?await n():console.warn(`Ignored unsubscribe request because an active subscription with id \`${t}\` for '${e}' events could not be found.`)}_buildArgs(t,e,n,i){const r=e||this._commitment;if(r||n||i){let o={};n&&(o.encoding=n),r&&(o.commitment=r),i&&(o=Object.assign(o,i)),t.push(o)}return t}_buildArgsAtLeastConfirmed(t,e,n,i){const r=e||this._commitment;if(r&&!["confirmed","finalized"].includes(r))throw new Error("Using Connection with default commitment: `"+this._commitment+"`, but method requires at least `confirmed`");return this._buildArgs(t,e,n,i)}_wsOnSignatureNotification(t){const{result:e,subscription:n}=O(t,yd);e.value!=="receivedSignature"&&this._subscriptionsAutoDisposedByRpc.add(n),this._handleServerNotification(n,e.value==="receivedSignature"?[{type:"received"},e.context]:[{type:"status",result:e.value},e.context])}onSignature(t,e,n){const i=this._buildArgs([t],n||this._commitment||"finalized"),r=this._makeSubscription({callback:(o,a)=>{if(o.type==="status"){e(o.result,a);try{this.removeSignatureListener(r)}catch{}}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},i);return r}onSignatureWithOptions(t,e,n){const{commitment:i,...r}={...n,commitment:n&&n.commitment||this._commitment||"finalized"},o=this._buildArgs([t],i,void 0,r),a=this._makeSubscription({callback:(u,g)=>{e(u,g);try{this.removeSignatureListener(a)}catch{}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},o);return a}async removeSignatureListener(t){await this._unsubscribeClientSubscription(t,"signature result")}_wsOnRootNotification(t){const{result:e,subscription:n}=O(t,wd);this._handleServerNotification(n,[e])}onRootChange(t){return this._makeSubscription({callback:t,method:"rootSubscribe",unsubscribeMethod:"rootUnsubscribe"},[])}async removeRootChangeListener(t){await this._unsubscribeClientSubscription(t,"root change")}};Object.freeze({CreateLookupTable:{index:0,layout:H([G("instruction"),cr("recentSlot"),st("bumpSeed")])},FreezeLookupTable:{index:1,layout:H([G("instruction")])},ExtendLookupTable:{index:2,layout:H([G("instruction"),cr(),Rt(_t(),Ne(G(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:H([G("instruction")])},CloseLookupTable:{index:4,layout:H([G("instruction")])}});new wt("AddressLookupTab1e1111111111111111111111111");Object.freeze({RequestUnits:{index:0,layout:H([st("instruction"),G("units"),G("additionalFee")])},RequestHeapFrame:{index:1,layout:H([st("instruction"),G("bytes")])},SetComputeUnitLimit:{index:2,layout:H([st("instruction"),G("units")])},SetComputeUnitPrice:{index:3,layout:H([st("instruction"),cr("microLamports")])}});new wt("ComputeBudget111111111111111111111111111111");H([st("numSignatures"),st("padding"),Dt("signatureOffset"),Dt("signatureInstructionIndex"),Dt("publicKeyOffset"),Dt("publicKeyInstructionIndex"),Dt("messageDataOffset"),Dt("messageDataSize"),Dt("messageInstructionIndex")]);new wt("Ed25519SigVerify111111111111111111111111111");mc.utils.isValidPrivateKey;H([st("numSignatures"),Dt("signatureOffset"),st("signatureInstructionIndex"),Dt("ethAddressOffset"),st("ethAddressInstructionIndex"),Dt("messageDataOffset"),Dt("messageDataSize"),st("messageInstructionIndex"),yt(20,"ethAddress"),yt(64,"signature"),st("recoveryId")]);new wt("KeccakSecp256k11111111111111111111111111111");var Fc;new wt("StakeConfig11111111111111111111111111111111");let Oc=class{constructor(t,e,n){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=t,this.epoch=e,this.custodian=n}};Fc=Oc;Oc.default=new Fc(0,0,wt.default);Object.freeze({Initialize:{index:0,layout:H([G("instruction"),sh(),ih()])},Authorize:{index:1,layout:H([G("instruction"),_t("newAuthorized"),G("stakeAuthorizationType")])},Delegate:{index:2,layout:H([G("instruction")])},Split:{index:3,layout:H([G("instruction"),Ot("lamports")])},Withdraw:{index:4,layout:H([G("instruction"),Ot("lamports")])},Deactivate:{index:5,layout:H([G("instruction")])},Merge:{index:7,layout:H([G("instruction")])},AuthorizeWithSeed:{index:8,layout:H([G("instruction"),_t("newAuthorized"),G("stakeAuthorizationType"),Jn("authoritySeed"),_t("authorityOwner")])}});new wt("Stake11111111111111111111111111111111111111");Object.freeze({InitializeAccount:{index:0,layout:H([G("instruction"),oh()])},Authorize:{index:1,layout:H([G("instruction"),_t("newAuthorized"),G("voteAuthorizationType")])},Withdraw:{index:3,layout:H([G("instruction"),Ot("lamports")])},UpdateValidatorIdentity:{index:4,layout:H([G("instruction")])},AuthorizeWithSeed:{index:10,layout:H([G("instruction"),ah()])}});new wt("Vote111111111111111111111111111111111111111");new wt("Va1idator1nfo111111111111111111111111111111");L({name:P(),website:V(P()),details:V(P()),iconUrl:V(P()),keybaseUsername:V(P())});new wt("Vote111111111111111111111111111111111111111");H([_t("nodePubkey"),_t("authorizedWithdrawer"),st("commission"),Bt(),Rt(H([Bt("slot"),G("confirmationCount")]),Ne(G(),-8),"votes"),st("rootSlotValid"),Bt("rootSlot"),Bt(),Rt(H([Bt("epoch"),_t("authorizedVoter")]),Ne(G(),-8),"authorizedVoters"),H([Rt(H([_t("authorizedPubkey"),Bt("epochOfLastAuthorizedSwitch"),Bt("targetEpoch")]),32,"buf"),Bt("idx"),st("isEmpty")],"priorVoters"),Bt(),Rt(H([Bt("epoch"),Bt("credits"),Bt("prevCredits")]),Ne(G(),-8),"epochCredits"),H([Bt("slot"),Bt("timestamp")],"lastTimestamp")]);const Hd=bs.v4,Wd=function(s,t,e,n){if(typeof s!="string")throw new TypeError(s+" must be a string");n=n||{};const i=typeof n.version=="number"?n.version:2;if(i!==1&&i!==2)throw new TypeError(i+" must be 1 or 2");const r={method:s};if(i===2&&(r.jsonrpc="2.0"),t){if(typeof t!="object"&&!Array.isArray(t))throw new TypeError(t+" must be an object, array or omitted");r.params=t}if(typeof e>"u"){const o=typeof n.generator=="function"?n.generator:function(){return Hd()};r.id=o(r,n)}else i===2&&e===null?n.notificationIdNull&&(r.id=null):r.id=e;return r};var jd=Wd;const Vd=bs.v4,Gd=jd,Br=function(s,t){if(!(this instanceof Br))return new Br(s,t);t||(t={}),this.options={reviver:typeof t.reviver<"u"?t.reviver:null,replacer:typeof t.replacer<"u"?t.replacer:null,generator:typeof t.generator<"u"?t.generator:function(){return Vd()},version:typeof t.version<"u"?t.version:2,notificationIdNull:typeof t.notificationIdNull=="boolean"?t.notificationIdNull:!1},this.callServer=s};var Zd=Br;Br.prototype.request=function(s,t,e,n){const i=this;let r=null;const o=Array.isArray(s)&&typeof t=="function";if(this.options.version===1&&o)throw new TypeError("JSON-RPC 1.0 does not support batching");if(o||!o&&s&&typeof s=="object"&&typeof t=="function")n=t,r=s;else{typeof e=="function"&&(n=e,e=void 0);const g=typeof n=="function";try{r=Gd(s,t,e,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(x){if(g){n(x);return}throw x}if(!g)return r}let u;try{u=JSON.stringify(r,this.options.replacer)}catch(g){n(g);return}return this.callServer(u,function(g,x){i._parseResponse(g,x,n)}),r};Br.prototype._parseResponse=function(s,t,e){if(s){e(s);return}if(!t){e();return}let n;try{n=JSON.parse(t,this.options.reviver)}catch(i){e(i);return}if(e.length===3)if(Array.isArray(n)){const i=function(o){return typeof o.error<"u"},r=function(o){return!i(o)};e(null,n.filter(i),n.filter(r));return}else{e(null,n.error,n.result);return}e(null,n)};const Yd=Ir(Zd);en.utils.randomPrivateKey;en.getPublicKey;function Do(s){try{return en.ExtendedPoint.fromHex(s),!0}catch{return!1}}const Xd=(s,t)=>en.sign(s,t.slice(0,32)),Jd=en.verify,ur=s=>Y.Buffer.isBuffer(s)?s:s instanceof Uint8Array?Y.Buffer.from(s.buffer,s.byteOffset,s.byteLength):Y.Buffer.from(s);class Qd{constructor(t){Object.assign(this,t)}encode(){return Y.Buffer.from(qi(jr,this))}static decode(t){return Di(jr,this,t)}static decodeUnchecked(t){return $i(jr,this,t)}}const jr=new Map;var $c;const t0=32,En=32;function e0(s){return s._bn!==void 0}let zo=1;class ft extends Qd{constructor(t){if(super({}),this._bn=void 0,e0(t))this._bn=t._bn;else{if(typeof t=="string"){const e=Et.decode(t);if(e.length!=En)throw new Error("Invalid public key input");this._bn=new Xr(e)}else this._bn=new Xr(t);if(this._bn.byteLength()>En)throw new Error("Invalid public key input")}}static unique(){const t=new ft(zo);return zo+=1,new ft(t.toBuffer())}equals(t){return this._bn.eq(t._bn)}toBase58(){return Et.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){const t=this.toBuffer();return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}toBuffer(){const t=this._bn.toArrayLike(Y.Buffer);if(t.length===En)return t;const e=Y.Buffer.alloc(32);return t.copy(e,32-t.length),e}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(t,e,n){const i=Y.Buffer.concat([t.toBuffer(),Y.Buffer.from(e),n.toBuffer()]),r=Jr(i);return new ft(r)}static createProgramAddressSync(t,e){let n=Y.Buffer.alloc(0);t.forEach(function(r){if(r.length>t0)throw new TypeError("Max seed length exceeded");n=Y.Buffer.concat([n,ur(r)])}),n=Y.Buffer.concat([n,e.toBuffer(),Y.Buffer.from("ProgramDerivedAddress")]);const i=Jr(n);if(Do(i))throw new Error("Invalid seeds, address must fall off the curve");return new ft(i)}static async createProgramAddress(t,e){return this.createProgramAddressSync(t,e)}static findProgramAddressSync(t,e){let n=255,i;for(;n!=0;){try{const r=t.concat(Y.Buffer.from([n]));i=this.createProgramAddressSync(r,e)}catch(r){if(r instanceof TypeError)throw r;n--;continue}return[i,n]}throw new Error("Unable to find a viable program address nonce")}static async findProgramAddress(t,e){return this.findProgramAddressSync(t,e)}static isOnCurve(t){const e=new ft(t);return Do(e.toBytes())}}$c=ft;ft.default=new $c("11111111111111111111111111111111");jr.set(ft,{kind:"struct",fields:[["_bn","u256"]]});new ft("BPFLoader1111111111111111111111111111111111");const rr=1232,qc=127,Kc=64;class Dc extends Error{constructor(t){super(`Signature ${t} has expired: block height exceeded.`),this.signature=void 0,this.signature=t}}Object.defineProperty(Dc.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});class zc extends Error{constructor(t,e){super(`Transaction was not confirmed in ${e.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${t} using the Solana Explorer or CLI tools.`),this.signature=void 0,this.signature=t}}Object.defineProperty(zc.prototype,"name",{value:"TransactionExpiredTimeoutError"});class vr extends Error{constructor(t){super(`Signature ${t} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=t}}Object.defineProperty(vr.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});class as{constructor(t,e){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=t,this.accountKeysFromLookups=e}keySegments(){const t=[this.staticAccountKeys];return this.accountKeysFromLookups&&(t.push(this.accountKeysFromLookups.writable),t.push(this.accountKeysFromLookups.readonly)),t}get(t){for(const e of this.keySegments()){if(t<e.length)return e[t];t-=e.length}}get length(){return this.keySegments().flat().length}compileInstructions(t){if(this.length>256)throw new Error("Account index overflow encountered during compilation");const n=new Map;this.keySegments().flat().forEach((r,o)=>{n.set(r.toBase58(),o)});const i=r=>{const o=n.get(r.toBase58());if(o===void 0)throw new Error("Encountered an unknown instruction account key during compilation");return o};return t.map(r=>({programIdIndex:i(r.programId),accountKeyIndexes:r.keys.map(o=>i(o.pubkey)),data:r.data}))}}const kt=(s="publicKey")=>yt(32,s),Qn=(s="string")=>{const t=H([G("length"),G("lengthPadding"),yt(Ne(G(),-8),"chars")],s),e=t.decode.bind(t),n=t.encode.bind(t),i=t;return i.decode=(r,o)=>e(r,o).chars.toString(),i.encode=(r,o,a)=>{const u={chars:Y.Buffer.from(r,"utf8")};return n(u,o,a)},i.alloc=r=>G().span+G().span+Y.Buffer.from(r,"utf8").length,i},n0=(s="authorized")=>H([kt("staker"),kt("withdrawer")],s),r0=(s="lockup")=>H([Ot("unixTimestamp"),Ot("epoch"),kt("custodian")],s),s0=(s="voteInit")=>H([kt("nodePubkey"),kt("authorizedVoter"),kt("authorizedWithdrawer"),st("commission")],s),i0=(s="voteAuthorizeWithSeedArgs")=>H([G("voteAuthorizationType"),kt("currentAuthorityDerivedKeyOwnerPubkey"),Qn("currentAuthorityDerivedKeySeed"),kt("newAuthorized")],s);function De(s){let t=0,e=0;for(;;){let n=s.shift();if(t|=(n&127)<<e*7,e+=1,!(n&128))break}return t}function ze(s,t){let e=t;for(;;){let n=e&127;if(e>>=7,e==0){s.push(n);break}else n|=128,s.push(n)}}function be(s,t){if(!s)throw new Error(t||"Assertion failed")}class xs{constructor(t,e){this.payer=void 0,this.keyMetaMap=void 0,this.payer=t,this.keyMetaMap=e}static compile(t,e){const n=new Map,i=o=>{const a=o.toBase58();let u=n.get(a);return u===void 0&&(u={isSigner:!1,isWritable:!1,isInvoked:!1},n.set(a,u)),u},r=i(e);r.isSigner=!0,r.isWritable=!0;for(const o of t){i(o.programId).isInvoked=!0;for(const a of o.keys){const u=i(a.pubkey);u.isSigner||(u.isSigner=a.isSigner),u.isWritable||(u.isWritable=a.isWritable)}}return new xs(e,n)}getMessageComponents(){const t=[...this.keyMetaMap.entries()];be(t.length<=256,"Max static account keys length exceeded");const e=t.filter(([,u])=>u.isSigner&&u.isWritable),n=t.filter(([,u])=>u.isSigner&&!u.isWritable),i=t.filter(([,u])=>!u.isSigner&&u.isWritable),r=t.filter(([,u])=>!u.isSigner&&!u.isWritable),o={numRequiredSignatures:e.length+n.length,numReadonlySignedAccounts:n.length,numReadonlyUnsignedAccounts:r.length};{be(e.length>0,"Expected at least one writable signer key");const[u]=e[0];be(u===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}const a=[...e.map(([u])=>new ft(u)),...n.map(([u])=>new ft(u)),...i.map(([u])=>new ft(u)),...r.map(([u])=>new ft(u))];return[o,a]}extractTableLookup(t){const[e,n]=this.drainKeysFoundInLookupTable(t.state.addresses,o=>!o.isSigner&&!o.isInvoked&&o.isWritable),[i,r]=this.drainKeysFoundInLookupTable(t.state.addresses,o=>!o.isSigner&&!o.isInvoked&&!o.isWritable);if(!(e.length===0&&i.length===0))return[{accountKey:t.key,writableIndexes:e,readonlyIndexes:i},{writable:n,readonly:r}]}drainKeysFoundInLookupTable(t,e){const n=new Array,i=new Array;for(const[r,o]of this.keyMetaMap.entries())if(e(o)){const a=new ft(r),u=t.findIndex(g=>g.equals(a));u>=0&&(be(u<256,"Max lookup table index exceeded"),n.push(u),i.push(a),this.keyMetaMap.delete(r))}return[n,i]}}const Hc="Reached end of buffer unexpectedly";function hn(s){if(s.length===0)throw new Error(Hc);return s.shift()}function He(s,...t){const[e]=t;if(t.length===2?e+(t[1]??0)>s.length:e>=s.length)throw new Error(Hc);return s.splice(...t)}class Bn{constructor(t){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=t.header,this.accountKeys=t.accountKeys.map(e=>new ft(e)),this.recentBlockhash=t.recentBlockhash,this.instructions=t.instructions,this.instructions.forEach(e=>this.indexToProgramIds.set(e.programIdIndex,this.accountKeys[e.programIdIndex]))}get version(){return"legacy"}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map(t=>({programIdIndex:t.programIdIndex,accountKeyIndexes:t.accounts,data:Et.decode(t.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new as(this.staticAccountKeys)}static compile(t){const e=xs.compile(t.instructions,t.payerKey),[n,i]=e.getMessageComponents(),o=new as(i).compileInstructions(t.instructions).map(a=>({programIdIndex:a.programIdIndex,accounts:a.accountKeyIndexes,data:Et.encode(a.data)}));return new Bn({header:n,accountKeys:i,recentBlockhash:t.recentBlockhash,instructions:o})}isAccountSigner(t){return t<this.header.numRequiredSignatures}isAccountWritable(t){const e=this.header.numRequiredSignatures;if(t>=this.header.numRequiredSignatures){const n=t-e,r=this.accountKeys.length-e-this.header.numReadonlyUnsignedAccounts;return n<r}else{const n=e-this.header.numReadonlySignedAccounts;return t<n}}isProgramId(t){return this.indexToProgramIds.has(t)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter((t,e)=>!this.isProgramId(e))}serialize(){const t=this.accountKeys.length;let e=[];ze(e,t);const n=this.instructions.map(B=>{const{accounts:I,programIdIndex:v}=B,E=Array.from(Et.decode(B.data));let R=[];ze(R,I.length);let T=[];return ze(T,E.length),{programIdIndex:v,keyIndicesCount:Y.Buffer.from(R),keyIndices:I,dataLength:Y.Buffer.from(T),data:E}});let i=[];ze(i,n.length);let r=Y.Buffer.alloc(rr);Y.Buffer.from(i).copy(r);let o=i.length;n.forEach(B=>{const v=H([st("programIdIndex"),yt(B.keyIndicesCount.length,"keyIndicesCount"),Rt(st("keyIndex"),B.keyIndices.length,"keyIndices"),yt(B.dataLength.length,"dataLength"),Rt(st("userdatum"),B.data.length,"data")]).encode(B,r,o);o+=v}),r=r.slice(0,o);const a=H([yt(1,"numRequiredSignatures"),yt(1,"numReadonlySignedAccounts"),yt(1,"numReadonlyUnsignedAccounts"),yt(e.length,"keyCount"),Rt(kt("key"),t,"keys"),kt("recentBlockhash")]),u={numRequiredSignatures:Y.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:Y.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:Y.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:Y.Buffer.from(e),keys:this.accountKeys.map(B=>ur(B.toBytes())),recentBlockhash:Et.decode(this.recentBlockhash)};let g=Y.Buffer.alloc(2048);const x=a.encode(u,g);return r.copy(g,x),g.slice(0,x+r.length)}static from(t){let e=[...t];const n=hn(e);if(n!==(n&qc))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const i=hn(e),r=hn(e),o=De(e);let a=[];for(let I=0;I<o;I++){const v=He(e,0,En);a.push(new ft(Y.Buffer.from(v)))}const u=He(e,0,En),g=De(e);let x=[];for(let I=0;I<g;I++){const v=hn(e),E=De(e),R=He(e,0,E),T=De(e),N=He(e,0,T),W=Et.encode(Y.Buffer.from(N));x.push({programIdIndex:v,accounts:R,data:W})}const B={header:{numRequiredSignatures:n,numReadonlySignedAccounts:i,numReadonlyUnsignedAccounts:r},recentBlockhash:Et.encode(Y.Buffer.from(u)),accountKeys:a,instructions:x};return new Bn(B)}}class cs{constructor(t){this.header=void 0,this.staticAccountKeys=void 0,this.recentBlockhash=void 0,this.compiledInstructions=void 0,this.addressTableLookups=void 0,this.header=t.header,this.staticAccountKeys=t.staticAccountKeys,this.recentBlockhash=t.recentBlockhash,this.compiledInstructions=t.compiledInstructions,this.addressTableLookups=t.addressTableLookups}get version(){return 0}get numAccountKeysFromLookups(){let t=0;for(const e of this.addressTableLookups)t+=e.readonlyIndexes.length+e.writableIndexes.length;return t}getAccountKeys(t){let e;if(t&&"accountKeysFromLookups"in t&&t.accountKeysFromLookups){if(this.numAccountKeysFromLookups!=t.accountKeysFromLookups.writable.length+t.accountKeysFromLookups.readonly.length)throw new Error("Failed to get account keys because of a mismatch in the number of account keys from lookups");e=t.accountKeysFromLookups}else if(t&&"addressLookupTableAccounts"in t&&t.addressLookupTableAccounts)e=this.resolveAddressTableLookups(t.addressLookupTableAccounts);else if(this.addressTableLookups.length>0)throw new Error("Failed to get account keys because address table lookups were not resolved");return new as(this.staticAccountKeys,e)}isAccountSigner(t){return t<this.header.numRequiredSignatures}isAccountWritable(t){const e=this.header.numRequiredSignatures,n=this.staticAccountKeys.length;if(t>=n){const i=t-n,r=this.addressTableLookups.reduce((o,a)=>o+a.writableIndexes.length,0);return i<r}else if(t>=this.header.numRequiredSignatures){const i=t-e,o=n-e-this.header.numReadonlyUnsignedAccounts;return i<o}else{const i=e-this.header.numReadonlySignedAccounts;return t<i}}resolveAddressTableLookups(t){const e={writable:[],readonly:[]};for(const n of this.addressTableLookups){const i=t.find(r=>r.key.equals(n.accountKey));if(!i)throw new Error(`Failed to find address lookup table account for table key ${n.accountKey.toBase58()}`);for(const r of n.writableIndexes)if(r<i.state.addresses.length)e.writable.push(i.state.addresses[r]);else throw new Error(`Failed to find address for index ${r} in address lookup table ${n.accountKey.toBase58()}`);for(const r of n.readonlyIndexes)if(r<i.state.addresses.length)e.readonly.push(i.state.addresses[r]);else throw new Error(`Failed to find address for index ${r} in address lookup table ${n.accountKey.toBase58()}`)}return e}static compile(t){const e=xs.compile(t.instructions,t.payerKey),n=new Array,i={writable:new Array,readonly:new Array},r=t.addressLookupTableAccounts||[];for(const x of r){const B=e.extractTableLookup(x);if(B!==void 0){const[I,{writable:v,readonly:E}]=B;n.push(I),i.writable.push(...v),i.readonly.push(...E)}}const[o,a]=e.getMessageComponents(),g=new as(a,i).compileInstructions(t.instructions);return new cs({header:o,staticAccountKeys:a,recentBlockhash:t.recentBlockhash,compiledInstructions:g,addressTableLookups:n})}serialize(){const t=Array();ze(t,this.staticAccountKeys.length);const e=this.serializeInstructions(),n=Array();ze(n,this.compiledInstructions.length);const i=this.serializeAddressTableLookups(),r=Array();ze(r,this.addressTableLookups.length);const o=H([st("prefix"),H([st("numRequiredSignatures"),st("numReadonlySignedAccounts"),st("numReadonlyUnsignedAccounts")],"header"),yt(t.length,"staticAccountKeysLength"),Rt(kt(),this.staticAccountKeys.length,"staticAccountKeys"),kt("recentBlockhash"),yt(n.length,"instructionsLength"),yt(e.length,"serializedInstructions"),yt(r.length,"addressTableLookupsLength"),yt(i.length,"serializedAddressTableLookups")]),a=new Uint8Array(rr),g=o.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(t),staticAccountKeys:this.staticAccountKeys.map(x=>x.toBytes()),recentBlockhash:Et.decode(this.recentBlockhash),instructionsLength:new Uint8Array(n),serializedInstructions:e,addressTableLookupsLength:new Uint8Array(r),serializedAddressTableLookups:i},a);return a.slice(0,g)}serializeInstructions(){let t=0;const e=new Uint8Array(rr);for(const n of this.compiledInstructions){const i=Array();ze(i,n.accountKeyIndexes.length);const r=Array();ze(r,n.data.length);const o=H([st("programIdIndex"),yt(i.length,"encodedAccountKeyIndexesLength"),Rt(st(),n.accountKeyIndexes.length,"accountKeyIndexes"),yt(r.length,"encodedDataLength"),yt(n.data.length,"data")]);t+=o.encode({programIdIndex:n.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(i),accountKeyIndexes:n.accountKeyIndexes,encodedDataLength:new Uint8Array(r),data:n.data},e,t)}return e.slice(0,t)}serializeAddressTableLookups(){let t=0;const e=new Uint8Array(rr);for(const n of this.addressTableLookups){const i=Array();ze(i,n.writableIndexes.length);const r=Array();ze(r,n.readonlyIndexes.length);const o=H([kt("accountKey"),yt(i.length,"encodedWritableIndexesLength"),Rt(st(),n.writableIndexes.length,"writableIndexes"),yt(r.length,"encodedReadonlyIndexesLength"),Rt(st(),n.readonlyIndexes.length,"readonlyIndexes")]);t+=o.encode({accountKey:n.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(i),writableIndexes:n.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(r),readonlyIndexes:n.readonlyIndexes},e,t)}return e.slice(0,t)}static deserialize(t){let e=[...t];const n=hn(e),i=n&qc;be(n!==i,"Expected versioned message but received legacy message");const r=i;be(r===0,`Expected versioned message with version 0 but found version ${r}`);const o={numRequiredSignatures:hn(e),numReadonlySignedAccounts:hn(e),numReadonlyUnsignedAccounts:hn(e)},a=[],u=De(e);for(let E=0;E<u;E++)a.push(new ft(He(e,0,En)));const g=Et.encode(He(e,0,En)),x=De(e),B=[];for(let E=0;E<x;E++){const R=hn(e),T=De(e),N=He(e,0,T),W=De(e),D=new Uint8Array(He(e,0,W));B.push({programIdIndex:R,accountKeyIndexes:N,data:D})}const I=De(e),v=[];for(let E=0;E<I;E++){const R=new ft(He(e,0,En)),T=De(e),N=He(e,0,T),W=De(e),D=He(e,0,W);v.push({accountKey:R,writableIndexes:N,readonlyIndexes:D})}return new cs({header:o,staticAccountKeys:a,recentBlockhash:g,compiledInstructions:B,addressTableLookups:v})}}let Sn=function(s){return s[s.BLOCKHEIGHT_EXCEEDED=0]="BLOCKHEIGHT_EXCEEDED",s[s.PROCESSED=1]="PROCESSED",s[s.TIMED_OUT=2]="TIMED_OUT",s[s.NONCE_INVALID=3]="NONCE_INVALID",s}({});const o0=Y.Buffer.alloc(Kc).fill(0);class Ho{constructor(t){this.keys=void 0,this.programId=void 0,this.data=Y.Buffer.alloc(0),this.programId=t.programId,this.keys=t.keys,t.data&&(this.data=t.data)}toJSON(){return{keys:this.keys.map(({pubkey:t,isSigner:e,isWritable:n})=>({pubkey:t.toJSON(),isSigner:e,isWritable:n})),programId:this.programId.toJSON(),data:[...this.data]}}}class vn{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(t){if(this.signatures=[],this.feePayer=void 0,this.instructions=[],this.recentBlockhash=void 0,this.lastValidBlockHeight=void 0,this.nonceInfo=void 0,this.minNonceContextSlot=void 0,this._message=void 0,this._json=void 0,!!t)if(t.feePayer&&(this.feePayer=t.feePayer),t.signatures&&(this.signatures=t.signatures),Object.prototype.hasOwnProperty.call(t,"nonceInfo")){const{minContextSlot:e,nonceInfo:n}=t;this.minNonceContextSlot=e,this.nonceInfo=n}else if(Object.prototype.hasOwnProperty.call(t,"lastValidBlockHeight")){const{blockhash:e,lastValidBlockHeight:n}=t;this.recentBlockhash=e,this.lastValidBlockHeight=n}else{const{recentBlockhash:e,nonceInfo:n}=t;n&&(this.nonceInfo=n),this.recentBlockhash=e}}toJSON(){return{recentBlockhash:this.recentBlockhash||null,feePayer:this.feePayer?this.feePayer.toJSON():null,nonceInfo:this.nonceInfo?{nonce:this.nonceInfo.nonce,nonceInstruction:this.nonceInfo.nonceInstruction.toJSON()}:null,instructions:this.instructions.map(t=>t.toJSON()),signers:this.signatures.map(({publicKey:t})=>t.toJSON())}}add(...t){if(t.length===0)throw new Error("No instructions");return t.forEach(e=>{"instructions"in e?this.instructions=this.instructions.concat(e.instructions):"data"in e&&"programId"in e&&"keys"in e?this.instructions.push(e):this.instructions.push(new Ho(e))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let t,e;if(this.nonceInfo?(t=this.nonceInfo.nonce,this.instructions[0]!=this.nonceInfo.nonceInstruction?e=[this.nonceInfo.nonceInstruction,...this.instructions]:e=this.instructions):(t=this.recentBlockhash,e=this.instructions),!t)throw new Error("Transaction recentBlockhash required");e.length<1&&console.warn("No instructions provided");let n;if(this.feePayer)n=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)n=this.signatures[0].publicKey;else throw new Error("Transaction fee payer required");for(let R=0;R<e.length;R++)if(e[R].programId===void 0)throw new Error(`Transaction instruction index ${R} has undefined program id`);const i=[],r=[];e.forEach(R=>{R.keys.forEach(N=>{r.push({...N})});const T=R.programId.toString();i.includes(T)||i.push(T)}),i.forEach(R=>{r.push({pubkey:new ft(R),isSigner:!1,isWritable:!1})});const o=[];r.forEach(R=>{const T=R.pubkey.toString(),N=o.findIndex(W=>W.pubkey.toString()===T);N>-1?(o[N].isWritable=o[N].isWritable||R.isWritable,o[N].isSigner=o[N].isSigner||R.isSigner):o.push(R)}),o.sort(function(R,T){if(R.isSigner!==T.isSigner)return R.isSigner?-1:1;if(R.isWritable!==T.isWritable)return R.isWritable?-1:1;const N={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return R.pubkey.toBase58().localeCompare(T.pubkey.toBase58(),"en",N)});const a=o.findIndex(R=>R.pubkey.equals(n));if(a>-1){const[R]=o.splice(a,1);R.isSigner=!0,R.isWritable=!0,o.unshift(R)}else o.unshift({pubkey:n,isSigner:!0,isWritable:!0});for(const R of this.signatures){const T=o.findIndex(N=>N.pubkey.equals(R.publicKey));if(T>-1)o[T].isSigner||(o[T].isSigner=!0,console.warn("Transaction references a signature that is unnecessary, only the fee payer and instruction signer accounts should sign a transaction. This behavior is deprecated and will throw an error in the next major version release."));else throw new Error(`unknown signer: ${R.publicKey.toString()}`)}let u=0,g=0,x=0;const B=[],I=[];o.forEach(({pubkey:R,isSigner:T,isWritable:N})=>{T?(B.push(R.toString()),u+=1,N||(g+=1)):(I.push(R.toString()),N||(x+=1))});const v=B.concat(I),E=e.map(R=>{const{data:T,programId:N}=R;return{programIdIndex:v.indexOf(N.toString()),accounts:R.keys.map(W=>v.indexOf(W.pubkey.toString())),data:Et.encode(T)}});return E.forEach(R=>{be(R.programIdIndex>=0),R.accounts.forEach(T=>be(T>=0))}),new Bn({header:{numRequiredSignatures:u,numReadonlySignedAccounts:g,numReadonlyUnsignedAccounts:x},accountKeys:v,recentBlockhash:t,instructions:E})}_compile(){const t=this.compileMessage(),e=t.accountKeys.slice(0,t.header.numRequiredSignatures);return this.signatures.length===e.length&&this.signatures.every((i,r)=>e[r].equals(i.publicKey))||(this.signatures=e.map(n=>({signature:null,publicKey:n}))),t}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(t){return(await t.getFeeForMessage(this.compileMessage())).value}setSigners(...t){if(t.length===0)throw new Error("No signers");const e=new Set;this.signatures=t.filter(n=>{const i=n.toString();return e.has(i)?!1:(e.add(i),!0)}).map(n=>({signature:null,publicKey:n}))}sign(...t){if(t.length===0)throw new Error("No signers");const e=new Set,n=[];for(const r of t){const o=r.publicKey.toString();e.has(o)||(e.add(o),n.push(r))}this.signatures=n.map(r=>({signature:null,publicKey:r.publicKey}));const i=this._compile();this._partialSign(i,...n)}partialSign(...t){if(t.length===0)throw new Error("No signers");const e=new Set,n=[];for(const r of t){const o=r.publicKey.toString();e.has(o)||(e.add(o),n.push(r))}const i=this._compile();this._partialSign(i,...n)}_partialSign(t,...e){const n=t.serialize();e.forEach(i=>{const r=Xd(n,i.secretKey);this._addSignature(i.publicKey,ur(r))})}addSignature(t,e){this._compile(),this._addSignature(t,e)}_addSignature(t,e){be(e.length===64);const n=this.signatures.findIndex(i=>t.equals(i.publicKey));if(n<0)throw new Error(`unknown signer: ${t.toString()}`);this.signatures[n].signature=Y.Buffer.from(e)}verifySignatures(t=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),t)}_getMessageSignednessErrors(t,e){const n={};for(const{signature:i,publicKey:r}of this.signatures)i===null?e&&(n.missing||(n.missing=[])).push(r):Jd(i,t,r.toBytes())||(n.invalid||(n.invalid=[])).push(r);return n.invalid||n.missing?n:void 0}serialize(t){const{requireAllSignatures:e,verifySignatures:n}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},t),i=this.serializeMessage();if(n){const r=this._getMessageSignednessErrors(i,e);if(r){let o="Signature verification failed.";throw r.invalid&&(o+=`
|
|
14
|
-
Invalid signature for public key${r.invalid.length===1?"":"(s)"} [\`${r.invalid.map(a=>a.toBase58()).join("`, `")}\`].`),r.missing&&(o+=`
|
|
15
|
-
Missing signature for public key${r.missing.length===1?"":"(s)"} [\`${r.missing.map(a=>a.toBase58()).join("`, `")}\`].`),new Error(o)}}return this._serialize(i)}_serialize(t){const{signatures:e}=this,n=[];ze(n,e.length);const i=n.length+e.length*64+t.length,r=Y.Buffer.alloc(i);return be(e.length<256),Y.Buffer.from(n).copy(r,0),e.forEach(({signature:o},a)=>{o!==null&&(be(o.length===64,"signature has invalid length"),Y.Buffer.from(o).copy(r,n.length+a*64))}),t.copy(r,n.length+e.length*64),be(r.length<=rr,`Transaction too large: ${r.length} > ${rr}`),r}get keys(){return be(this.instructions.length===1),this.instructions[0].keys.map(t=>t.pubkey)}get programId(){return be(this.instructions.length===1),this.instructions[0].programId}get data(){return be(this.instructions.length===1),this.instructions[0].data}static from(t){let e=[...t];const n=De(e);let i=[];for(let r=0;r<n;r++){const o=He(e,0,Kc);i.push(Et.encode(Y.Buffer.from(o)))}return vn.populate(Bn.from(e),i)}static populate(t,e=[]){const n=new vn;return n.recentBlockhash=t.recentBlockhash,t.header.numRequiredSignatures>0&&(n.feePayer=t.accountKeys[0]),e.forEach((i,r)=>{const o={signature:i==Et.encode(o0)?null:Et.decode(i),publicKey:t.accountKeys[r]};n.signatures.push(o)}),t.instructions.forEach(i=>{const r=i.accounts.map(o=>{const a=t.accountKeys[o];return{pubkey:a,isSigner:n.signatures.some(u=>u.publicKey.toString()===a.toString())||t.isAccountSigner(o),isWritable:t.isAccountWritable(o)}});n.instructions.push(new Ho({keys:r,programId:t.accountKeys[i.programIdIndex],data:Et.decode(i.data)}))}),n._message=t,n._json=n.toJSON(),n}}const a0=160,c0=64,u0=a0/c0,l0=1e3/u0;new ft("SysvarC1ock11111111111111111111111111111111");new ft("SysvarEpochSchedu1e111111111111111111111111");new ft("Sysvar1nstructions1111111111111111111111111");new ft("SysvarRecentB1ockHashes11111111111111111111");new ft("SysvarRent111111111111111111111111111111111");new ft("SysvarRewards111111111111111111111111111111");new ft("SysvarS1otHashes111111111111111111111111111");new ft("SysvarS1otHistory11111111111111111111111111");new ft("SysvarStakeHistory1111111111111111111111111");class Wo extends Error{constructor({action:t,signature:e,transactionMessage:n,logs:i}){const r=i?`Logs:
|
|
16
|
-
${JSON.stringify(i.slice(-10),null,2)}. `:"",o="\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.";let a;switch(t){case"send":a=`Transaction ${e} resulted in an error.
|
|
17
|
-
${n}. `+r+o;break;case"simulate":a=`Simulation failed.
|
|
18
|
-
Message: ${n}.
|
|
19
|
-
`+r+o;break;default:a=`Unknown action '${(u=>u)(t)}'`}super(a),this.signature=void 0,this.transactionMessage=void 0,this.transactionLogs=void 0,this.signature=e,this.transactionMessage=n,this.transactionLogs=i||void 0}get transactionError(){return{message:this.transactionMessage,logs:Array.isArray(this.transactionLogs)?this.transactionLogs:void 0}}get logs(){const t=this.transactionLogs;if(!(t!=null&&typeof t=="object"&&"then"in t))return t}async getLogs(t){return Array.isArray(this.transactionLogs)||(this.transactionLogs=new Promise((e,n)=>{t.getTransaction(this.signature).then(i=>{if(i&&i.meta&&i.meta.logMessages){const r=i.meta.logMessages;this.transactionLogs=r,e(r)}else n(new Error("Log messages not found"))}).catch(n)})),await this.transactionLogs}}class ot extends Error{constructor({code:t,message:e,data:n},i){super(i!=null?`${i}: ${e}`:e),this.code=void 0,this.data=void 0,this.code=t,this.data=n,this.name="SolanaJSONRPCError"}}function Yn(s){return new Promise(t=>setTimeout(t,s))}const f0=Bt("lamportsPerSignature"),Wc=H([G("version"),G("state"),kt("authorizedPubkey"),kt("nonce"),H([f0],"feeCalculator")]);Wc.span;class eo{constructor(t){this.authorizedPubkey=void 0,this.nonce=void 0,this.feeCalculator=void 0,this.authorizedPubkey=t.authorizedPubkey,this.nonce=t.nonce,this.feeCalculator=t.feeCalculator}static fromAccountData(t){const e=Wc.decode(ur(t),0);return new eo({authorizedPubkey:new ft(e.authorizedPubkey),nonce:new ft(e.nonce).toString(),feeCalculator:e.feeCalculator})}}function lr(s){const t=yt(8,s),e=t.decode.bind(t),n=t.encode.bind(t),i=t,r=tc();return i.decode=(o,a)=>{const u=e(o,a);return r.decode(u)},i.encode=(o,a,u)=>{const g=r.encode(o);return n(g,a,u)},i}Object.freeze({Create:{index:0,layout:H([G("instruction"),Ot("lamports"),Ot("space"),kt("programId")])},Assign:{index:1,layout:H([G("instruction"),kt("programId")])},Transfer:{index:2,layout:H([G("instruction"),lr("lamports")])},CreateWithSeed:{index:3,layout:H([G("instruction"),kt("base"),Qn("seed"),Ot("lamports"),Ot("space"),kt("programId")])},AdvanceNonceAccount:{index:4,layout:H([G("instruction")])},WithdrawNonceAccount:{index:5,layout:H([G("instruction"),Ot("lamports")])},InitializeNonceAccount:{index:6,layout:H([G("instruction"),kt("authorized")])},AuthorizeNonceAccount:{index:7,layout:H([G("instruction"),kt("authorized")])},Allocate:{index:8,layout:H([G("instruction"),Ot("space")])},AllocateWithSeed:{index:9,layout:H([G("instruction"),kt("base"),Qn("seed"),Ot("space"),kt("programId")])},AssignWithSeed:{index:10,layout:H([G("instruction"),kt("base"),Qn("seed"),kt("programId")])},TransferWithSeed:{index:11,layout:H([G("instruction"),lr("lamports"),Qn("seed"),kt("programId")])},UpgradeNonceAccount:{index:12,layout:H([G("instruction")])}});new ft("11111111111111111111111111111111");new ft("BPFLoader2111111111111111111111111111111111");function h0(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var ui,jo;function d0(){if(jo)return ui;jo=1;var s=Object.prototype.toString,t=Object.keys||function(n){var i=[];for(var r in n)i.push(r);return i};function e(n,i){var r,o,a,u,g,x,B;if(n===!0)return"true";if(n===!1)return"false";switch(typeof n){case"object":if(n===null)return null;if(n.toJSON&&typeof n.toJSON=="function")return e(n.toJSON(),i);if(B=s.call(n),B==="[object Array]"){for(a="[",o=n.length-1,r=0;r<o;r++)a+=e(n[r],!0)+",";return o>-1&&(a+=e(n[r],!0)),a+"]"}else if(B==="[object Object]"){for(u=t(n).sort(),o=u.length,a="",r=0;r<o;)g=u[r],x=e(n[g],!1),x!==void 0&&(a&&(a+=","),a+=JSON.stringify(g)+":"+x),r++;return"{"+a+"}"}else return JSON.stringify(n);case"function":case"undefined":return i?null:void 0;case"string":return JSON.stringify(n);default:return isFinite(n)?n:null}}return ui=function(n){var i=e(n,!1);if(i!==void 0)return""+i},ui}var p0=d0(),Vo=h0(p0);const br=32;function li(s){let t=0;for(;s>1;)s/=2,t++;return t}function g0(s){return s===0?1:(s--,s|=s>>1,s|=s>>2,s|=s>>4,s|=s>>8,s|=s>>16,s|=s>>32,s+1)}class m0{constructor(t,e,n,i,r){this.slotsPerEpoch=void 0,this.leaderScheduleSlotOffset=void 0,this.warmup=void 0,this.firstNormalEpoch=void 0,this.firstNormalSlot=void 0,this.slotsPerEpoch=t,this.leaderScheduleSlotOffset=e,this.warmup=n,this.firstNormalEpoch=i,this.firstNormalSlot=r}getEpoch(t){return this.getEpochAndSlotIndex(t)[0]}getEpochAndSlotIndex(t){if(t<this.firstNormalSlot){const e=li(g0(t+br+1))-li(br)-1,n=this.getSlotsInEpoch(e),i=t-(n-br);return[e,i]}else{const e=t-this.firstNormalSlot,n=Math.floor(e/this.slotsPerEpoch),i=this.firstNormalEpoch+n,r=e%this.slotsPerEpoch;return[i,r]}}getFirstSlotInEpoch(t){return t<=this.firstNormalEpoch?(Math.pow(2,t)-1)*br:(t-this.firstNormalEpoch)*this.slotsPerEpoch+this.firstNormalSlot}getLastSlotInEpoch(t){return this.getFirstSlotInEpoch(t)+this.getSlotsInEpoch(t)-1}getSlotsInEpoch(t){return t<this.firstNormalEpoch?Math.pow(2,t+li(br)):this.slotsPerEpoch}}var y0=globalThis.fetch;class w0 extends lc{constructor(t,e,n){const i=r=>{const o=uc(r,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...e});return"socket"in o?this.underlyingSocket=o.socket:this.underlyingSocket=o,o};super(i,t,e,n),this.underlyingSocket=void 0}call(...t){var n;const e=(n=this.underlyingSocket)==null?void 0:n.readyState;return e===1?super.call(...t):Promise.reject(new Error("Tried to call a JSON-RPC method `"+t[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+e+")"))}notify(...t){var n;const e=(n=this.underlyingSocket)==null?void 0:n.readyState;return e===1?super.notify(...t):Promise.reject(new Error("Tried to send a JSON-RPC notification `"+t[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+e+")"))}}function b0(s,t){let e;try{e=s.layout.decode(t)}catch(n){throw new Error("invalid instruction; "+n)}if(e.typeIndex!==s.index)throw new Error(`invalid account data; account type mismatch ${e.typeIndex} != ${s.index}`);return e}const Go=56;class Zo{constructor(t){this.key=void 0,this.state=void 0,this.key=t.key,this.state=t.state}isActive(){const t=BigInt("0xffffffffffffffff");return this.state.deactivationSlot===t}static deserialize(t){const e=b0(S0,t),n=t.length-Go;be(n>=0,"lookup table is invalid"),be(n%32===0,"lookup table is invalid");const i=n/32,{addresses:r}=H([Rt(kt(),i,"addresses")]).decode(t.slice(Go));return{deactivationSlot:e.deactivationSlot,lastExtendedSlot:e.lastExtendedSlot,lastExtendedSlotStartIndex:e.lastExtendedStartIndex,authority:e.authority.length!==0?new ft(e.authority[0]):void 0,addresses:r.map(o=>new ft(o))}}}const S0={index:1,layout:H([G("typeIndex"),lr("deactivationSlot"),Bt("lastExtendedSlot"),st("lastExtendedStartIndex"),st(),Rt(kt(),Ne(st(),-1),"authority")])},v0=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;function x0(s){const t=s.match(v0);if(t==null)throw TypeError(`Failed to validate endpoint URL \`${s}\``);const[e,n,i,r]=t,o=s.startsWith("https:")?"wss:":"ws:",a=i==null?null:parseInt(i.slice(1),10),u=a==null?"":`:${a+1}`;return`${o}//${n}${u}${r}`}const Ht=on(dr(ft),P(),s=>new ft(s)),jc=pr([P(),pt("base64")]),no=on(dr(Y.Buffer),jc,s=>Y.Buffer.from(s[0],"base64")),_0=30*1e3;function k0(s){if(/^https?:/.test(s)===!1)throw new TypeError("Endpoint URL must start with `http:` or `https:`.");return s}function Nt(s){let t,e;if(typeof s=="string")t=s;else if(s){const{commitment:n,...i}=s;t=n,e=i}return{commitment:t,config:e}}function Yo(s){return s.map(t=>"memcmp"in t?{...t,memcmp:{...t.memcmp,encoding:t.memcmp.encoding??"base58"}}:t)}function Vc(s){return It([L({jsonrpc:pt("2.0"),id:P(),result:s}),L({jsonrpc:pt("2.0"),id:P(),error:L({code:je(),message:P(),data:V(nc())})})])}const E0=Vc(je());function vt(s){return on(Vc(s),E0,t=>"error"in t?t:{...t,result:O(t.result,s)})}function Qt(s){return vt(L({context:L({slot:b()}),value:s}))}function _s(s){return L({context:L({slot:b()}),value:s})}function fi(s,t){return s===0?new cs({header:t.header,staticAccountKeys:t.accountKeys.map(e=>new ft(e)),recentBlockhash:t.recentBlockhash,compiledInstructions:t.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:Et.decode(e.data)})),addressTableLookups:t.addressTableLookups}):new Bn(t)}const B0=L({foundation:b(),foundationTerm:b(),initial:b(),taper:b(),terminal:b()}),A0=vt($(K(L({epoch:b(),effectiveSlot:b(),amount:b(),postBalance:b(),commission:V(K(b()))})))),I0=$(L({slot:b(),prioritizationFee:b()})),R0=L({total:b(),validator:b(),foundation:b(),epoch:b()}),M0=L({epoch:b(),slotIndex:b(),slotsInEpoch:b(),absoluteSlot:b(),blockHeight:V(b()),transactionCount:V(b())}),T0=L({slotsPerEpoch:b(),leaderScheduleSlotOffset:b(),warmup:ve(),firstNormalEpoch:b(),firstNormalSlot:b()}),C0=gs(P(),$(b())),qn=K(It([L({}),P()])),L0=L({err:qn}),U0=pt("receivedSignature"),N0=L({"solana-core":P(),"feature-set":V(b())}),P0=L({program:P(),programId:Ht,parsed:je()}),F0=L({programId:Ht,accounts:$(Ht),data:P()}),Xo=Qt(L({err:K(It([L({}),P()])),logs:K($(P())),accounts:V(K($(K(L({executable:ve(),owner:P(),lamports:b(),data:$(P()),rentEpoch:V(b())}))))),unitsConsumed:V(b()),returnData:V(K(L({programId:P(),data:pr([P(),pt("base64")])}))),innerInstructions:V(K($(L({index:b(),instructions:$(It([P0,F0]))}))))})),O0=Qt(L({byIdentity:gs(P(),$(b())),range:L({firstSlot:b(),lastSlot:b()})}));function $0(s,t,e,n,i,r){const o=e||y0;let a;r!=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 u;return n&&(u=async(x,B)=>{const I=await new Promise((v,E)=>{try{n(x,B,(R,T)=>v([R,T]))}catch(R){E(R)}});return await o(...I)}),new Yd(async(x,B)=>{const I={method:"POST",body:x,agent:a,headers:Object.assign({"Content-Type":"application/json"},t||{},$p)};try{let v=5,E,R=500;for(;u?E=await u(s,I):E=await o(s,I),!(E.status!==429||i===!0||(v-=1,v===0));)console.error(`Server responded with ${E.status} ${E.statusText}. Retrying after ${R}ms delay...`),await Yn(R),R*=2;const T=await E.text();E.ok?B(null,T):B(new Error(`${E.status} ${E.statusText}: ${T}`))}catch(v){v instanceof Error&&B(v)}},{})}function q0(s){return(t,e)=>new Promise((n,i)=>{s.request(t,e,(r,o)=>{if(r){i(r);return}n(o)})})}function K0(s){return t=>new Promise((e,n)=>{t.length===0&&e([]);const i=t.map(r=>s.request(r.methodName,r.args));s.request(i,(r,o)=>{if(r){n(r);return}e(o)})})}const D0=vt(B0),z0=vt(R0),H0=vt(I0),W0=vt(M0),j0=vt(T0),V0=vt(C0),G0=vt(b()),Z0=Qt(L({total:b(),circulating:b(),nonCirculating:b(),nonCirculatingAccounts:$(Ht)})),Bi=L({amount:P(),uiAmount:K(b()),decimals:b(),uiAmountString:V(P())}),Y0=Qt($(L({address:Ht,amount:P(),uiAmount:K(b()),decimals:b(),uiAmountString:V(P())}))),X0=Qt($(L({pubkey:Ht,account:L({executable:ve(),owner:Ht,lamports:b(),data:no,rentEpoch:b()})}))),Ai=L({program:P(),parsed:je(),space:b()}),J0=Qt($(L({pubkey:Ht,account:L({executable:ve(),owner:Ht,lamports:b(),data:Ai,rentEpoch:b()})}))),Q0=Qt($(L({lamports:b(),address:Ht}))),Ar=L({executable:ve(),owner:Ht,lamports:b(),data:no,rentEpoch:b()}),tp=L({pubkey:Ht,account:Ar}),ep=on(It([dr(Y.Buffer),Ai]),It([jc,Ai]),s=>Array.isArray(s)?O(s,no):s),Ii=L({executable:ve(),owner:Ht,lamports:b(),data:ep,rentEpoch:b()}),np=L({pubkey:Ht,account:Ii}),rp=L({state:It([pt("active"),pt("inactive"),pt("activating"),pt("deactivating")]),active:b(),inactive:b()}),sp=vt($(L({signature:P(),slot:b(),err:qn,memo:K(P()),blockTime:V(K(b()))}))),ip=vt($(L({signature:P(),slot:b(),err:qn,memo:K(P()),blockTime:V(K(b()))}))),op=L({subscription:b(),result:_s(Ar)}),ap=L({pubkey:Ht,account:Ar}),cp=L({subscription:b(),result:_s(ap)}),up=L({parent:b(),slot:b(),root:b()}),lp=L({subscription:b(),result:up}),fp=It([L({type:It([pt("firstShredReceived"),pt("completed"),pt("optimisticConfirmation"),pt("root")]),slot:b(),timestamp:b()}),L({type:pt("createdBank"),parent:b(),slot:b(),timestamp:b()}),L({type:pt("frozen"),slot:b(),timestamp:b(),stats:L({numTransactionEntries:b(),numSuccessfulTransactions:b(),numFailedTransactions:b(),maxTransactionsPerEntry:b()})}),L({type:pt("dead"),slot:b(),timestamp:b(),err:P()})]),hp=L({subscription:b(),result:fp}),dp=L({subscription:b(),result:_s(It([L0,U0]))}),pp=L({subscription:b(),result:b()}),gp=L({pubkey:P(),gossip:K(P()),tpu:K(P()),rpc:K(P()),version:K(P())}),Jo=L({votePubkey:P(),nodePubkey:P(),activatedStake:b(),epochVoteAccount:ve(),epochCredits:$(pr([b(),b(),b()])),commission:b(),lastVote:b(),rootSlot:K(b())}),mp=vt(L({current:$(Jo),delinquent:$(Jo)})),yp=It([pt("processed"),pt("confirmed"),pt("finalized")]),wp=L({slot:b(),confirmations:K(b()),err:qn,confirmationStatus:V(yp)}),bp=Qt($(K(wp))),Sp=vt(b()),Gc=L({accountKey:Ht,writableIndexes:$(b()),readonlyIndexes:$(b())}),ro=L({signatures:$(P()),message:L({accountKeys:$(P()),header:L({numRequiredSignatures:b(),numReadonlySignedAccounts:b(),numReadonlyUnsignedAccounts:b()}),instructions:$(L({accounts:$(b()),data:P(),programIdIndex:b()})),recentBlockhash:P(),addressTableLookups:V($(Gc))})}),Zc=L({pubkey:Ht,signer:ve(),writable:ve(),source:V(It([pt("transaction"),pt("lookupTable")]))}),Yc=L({accountKeys:$(Zc),signatures:$(P())}),Xc=L({parsed:je(),program:P(),programId:Ht}),Jc=L({accounts:$(Ht),data:P(),programId:Ht}),vp=It([Jc,Xc]),xp=It([L({parsed:je(),program:P(),programId:P()}),L({accounts:$(P()),data:P(),programId:P()})]),Qc=on(vp,xp,s=>"accounts"in s?O(s,Jc):O(s,Xc)),tu=L({signatures:$(P()),message:L({accountKeys:$(Zc),instructions:$(Qc),recentBlockhash:P(),addressTableLookups:V(K($(Gc)))})}),us=L({accountIndex:b(),mint:P(),owner:V(P()),programId:V(P()),uiTokenAmount:Bi}),eu=L({writable:$(Ht),readonly:$(Ht)}),ks=L({err:qn,fee:b(),innerInstructions:V(K($(L({index:b(),instructions:$(L({accounts:$(b()),data:P(),programIdIndex:b()}))})))),preBalances:$(b()),postBalances:$(b()),logMessages:V(K($(P()))),preTokenBalances:V(K($(us))),postTokenBalances:V(K($(us))),loadedAddresses:V(eu),computeUnitsConsumed:V(b()),costUnits:V(b())}),so=L({err:qn,fee:b(),innerInstructions:V(K($(L({index:b(),instructions:$(Qc)})))),preBalances:$(b()),postBalances:$(b()),logMessages:V(K($(P()))),preTokenBalances:V(K($(us))),postTokenBalances:V(K($(us))),loadedAddresses:V(eu),computeUnitsConsumed:V(b()),costUnits:V(b())}),mr=It([pt(0),pt("legacy")]),Kn=L({pubkey:P(),lamports:b(),postBalance:K(b()),rewardType:K(P()),commission:V(K(b()))}),_p=vt(K(L({blockhash:P(),previousBlockhash:P(),parentSlot:b(),transactions:$(L({transaction:ro,meta:K(ks),version:V(mr)})),rewards:V($(Kn)),blockTime:K(b()),blockHeight:K(b())}))),kp=vt(K(L({blockhash:P(),previousBlockhash:P(),parentSlot:b(),rewards:V($(Kn)),blockTime:K(b()),blockHeight:K(b())}))),Ep=vt(K(L({blockhash:P(),previousBlockhash:P(),parentSlot:b(),transactions:$(L({transaction:Yc,meta:K(ks),version:V(mr)})),rewards:V($(Kn)),blockTime:K(b()),blockHeight:K(b())}))),Bp=vt(K(L({blockhash:P(),previousBlockhash:P(),parentSlot:b(),transactions:$(L({transaction:tu,meta:K(so),version:V(mr)})),rewards:V($(Kn)),blockTime:K(b()),blockHeight:K(b())}))),Ap=vt(K(L({blockhash:P(),previousBlockhash:P(),parentSlot:b(),transactions:$(L({transaction:Yc,meta:K(so),version:V(mr)})),rewards:V($(Kn)),blockTime:K(b()),blockHeight:K(b())}))),Ip=vt(K(L({blockhash:P(),previousBlockhash:P(),parentSlot:b(),rewards:V($(Kn)),blockTime:K(b()),blockHeight:K(b())}))),Rp=vt(K(L({blockhash:P(),previousBlockhash:P(),parentSlot:b(),transactions:$(L({transaction:ro,meta:K(ks)})),rewards:V($(Kn)),blockTime:K(b())}))),Qo=vt(K(L({blockhash:P(),previousBlockhash:P(),parentSlot:b(),signatures:$(P()),blockTime:K(b())}))),hi=vt(K(L({slot:b(),meta:K(ks),blockTime:V(K(b())),transaction:ro,version:V(mr)}))),Hr=vt(K(L({slot:b(),transaction:tu,meta:K(so),blockTime:V(K(b())),version:V(mr)}))),Mp=Qt(L({blockhash:P(),lastValidBlockHeight:b()})),Tp=Qt(ve()),Cp=L({slot:b(),numTransactions:b(),numSlots:b(),samplePeriodSecs:b()}),Lp=vt($(Cp)),Up=Qt(K(L({feeCalculator:L({lamportsPerSignature:b()})}))),Np=vt(P()),Pp=vt(P()),Fp=L({err:qn,logs:$(P()),signature:P()}),Op=L({result:_s(Fp),subscription:b()}),$p={"solana-client":"js/1.0.0-maintenance"};class sg{constructor(t,e){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 x=>{const{commitment:B,config:I}=Nt(x),v=this._buildArgs([],B,void 0,I),E=Vo(v);return g[E]=g[E]??(async()=>{try{const R=await this._rpcRequest("getBlockHeight",v),T=O(R,vt(b()));if("error"in T)throw new ot(T.error,"failed to get block height information");return T.result}finally{delete g[E]}})(),await g[E]}})();let n,i,r,o,a,u;e&&typeof e=="string"?this._commitment=e:e&&(this._commitment=e.commitment,this._confirmTransactionInitialTimeout=e.confirmTransactionInitialTimeout,n=e.wsEndpoint,i=e.httpHeaders,r=e.fetch,o=e.fetchMiddleware,a=e.disableRetryOnRateLimit,u=e.httpAgent),this._rpcEndpoint=k0(t),this._rpcWsEndpoint=n||x0(t),this._rpcClient=$0(t,i,r,o,a,u),this._rpcRequest=q0(this._rpcClient),this._rpcBatchRequest=K0(this._rpcClient),this._rpcWebSocket=new w0(this._rpcWsEndpoint,{autoconnect:!1,max_reconnects:1/0}),this._rpcWebSocket.on("open",this._wsOnOpen.bind(this)),this._rpcWebSocket.on("error",this._wsOnError.bind(this)),this._rpcWebSocket.on("close",this._wsOnClose.bind(this)),this._rpcWebSocket.on("accountNotification",this._wsOnAccountNotification.bind(this)),this._rpcWebSocket.on("programNotification",this._wsOnProgramAccountNotification.bind(this)),this._rpcWebSocket.on("slotNotification",this._wsOnSlotNotification.bind(this)),this._rpcWebSocket.on("slotsUpdatesNotification",this._wsOnSlotUpdatesNotification.bind(this)),this._rpcWebSocket.on("signatureNotification",this._wsOnSignatureNotification.bind(this)),this._rpcWebSocket.on("rootNotification",this._wsOnRootNotification.bind(this)),this._rpcWebSocket.on("logsNotification",this._wsOnLogsNotification.bind(this))}get commitment(){return this._commitment}get rpcEndpoint(){return this._rpcEndpoint}async getBalanceAndContext(t,e){const{commitment:n,config:i}=Nt(e),r=this._buildArgs([t.toBase58()],n,void 0,i),o=await this._rpcRequest("getBalance",r),a=O(o,Qt(b()));if("error"in a)throw new ot(a.error,`failed to get balance for ${t.toBase58()}`);return a.result}async getBalance(t,e){return await this.getBalanceAndContext(t,e).then(n=>n.value).catch(n=>{throw new Error("failed to get balance of account "+t.toBase58()+": "+n)})}async getBlockTime(t){const e=await this._rpcRequest("getBlockTime",[t]),n=O(e,vt(K(b())));if("error"in n)throw new ot(n.error,`failed to get block time for slot ${t}`);return n.result}async getMinimumLedgerSlot(){const t=await this._rpcRequest("minimumLedgerSlot",[]),e=O(t,vt(b()));if("error"in e)throw new ot(e.error,"failed to get minimum ledger slot");return e.result}async getFirstAvailableBlock(){const t=await this._rpcRequest("getFirstAvailableBlock",[]),e=O(t,G0);if("error"in e)throw new ot(e.error,"failed to get first available block");return e.result}async getSupply(t){let e={};typeof t=="string"?e={commitment:t}:t?e={...t,commitment:t&&t.commitment||this.commitment}:e={commitment:this.commitment};const n=await this._rpcRequest("getSupply",[e]),i=O(n,Z0);if("error"in i)throw new ot(i.error,"failed to get supply");return i.result}async getTokenSupply(t,e){const n=this._buildArgs([t.toBase58()],e),i=await this._rpcRequest("getTokenSupply",n),r=O(i,Qt(Bi));if("error"in r)throw new ot(r.error,"failed to get token supply");return r.result}async getTokenAccountBalance(t,e){const n=this._buildArgs([t.toBase58()],e),i=await this._rpcRequest("getTokenAccountBalance",n),r=O(i,Qt(Bi));if("error"in r)throw new ot(r.error,"failed to get token account balance");return r.result}async getTokenAccountsByOwner(t,e,n){const{commitment:i,config:r}=Nt(n);let o=[t.toBase58()];"mint"in e?o.push({mint:e.mint.toBase58()}):o.push({programId:e.programId.toBase58()});const a=this._buildArgs(o,i,"base64",r),u=await this._rpcRequest("getTokenAccountsByOwner",a),g=O(u,X0);if("error"in g)throw new ot(g.error,`failed to get token accounts owned by account ${t.toBase58()}`);return g.result}async getParsedTokenAccountsByOwner(t,e,n){let i=[t.toBase58()];"mint"in e?i.push({mint:e.mint.toBase58()}):i.push({programId:e.programId.toBase58()});const r=this._buildArgs(i,n,"jsonParsed"),o=await this._rpcRequest("getTokenAccountsByOwner",r),a=O(o,J0);if("error"in a)throw new ot(a.error,`failed to get token accounts owned by account ${t.toBase58()}`);return a.result}async getLargestAccounts(t){const e={...t,commitment:t&&t.commitment||this.commitment},n=e.filter||e.commitment?[e]:[],i=await this._rpcRequest("getLargestAccounts",n),r=O(i,Q0);if("error"in r)throw new ot(r.error,"failed to get largest accounts");return r.result}async getTokenLargestAccounts(t,e){const n=this._buildArgs([t.toBase58()],e),i=await this._rpcRequest("getTokenLargestAccounts",n),r=O(i,Y0);if("error"in r)throw new ot(r.error,"failed to get token largest accounts");return r.result}async getAccountInfoAndContext(t,e){const{commitment:n,config:i}=Nt(e),r=this._buildArgs([t.toBase58()],n,"base64",i),o=await this._rpcRequest("getAccountInfo",r),a=O(o,Qt(K(Ar)));if("error"in a)throw new ot(a.error,`failed to get info about account ${t.toBase58()}`);return a.result}async getParsedAccountInfo(t,e){const{commitment:n,config:i}=Nt(e),r=this._buildArgs([t.toBase58()],n,"jsonParsed",i),o=await this._rpcRequest("getAccountInfo",r),a=O(o,Qt(K(Ii)));if("error"in a)throw new ot(a.error,`failed to get info about account ${t.toBase58()}`);return a.result}async getAccountInfo(t,e){try{return(await this.getAccountInfoAndContext(t,e)).value}catch(n){throw new Error("failed to get info about account "+t.toBase58()+": "+n)}}async getMultipleParsedAccounts(t,e){const{commitment:n,config:i}=Nt(e),r=t.map(g=>g.toBase58()),o=this._buildArgs([r],n,"jsonParsed",i),a=await this._rpcRequest("getMultipleAccounts",o),u=O(a,Qt($(K(Ii))));if("error"in u)throw new ot(u.error,`failed to get info for accounts ${r}`);return u.result}async getMultipleAccountsInfoAndContext(t,e){const{commitment:n,config:i}=Nt(e),r=t.map(g=>g.toBase58()),o=this._buildArgs([r],n,"base64",i),a=await this._rpcRequest("getMultipleAccounts",o),u=O(a,Qt($(K(Ar))));if("error"in u)throw new ot(u.error,`failed to get info for accounts ${r}`);return u.result}async getMultipleAccountsInfo(t,e){return(await this.getMultipleAccountsInfoAndContext(t,e)).value}async getStakeActivation(t,e,n){const{commitment:i,config:r}=Nt(e),o=this._buildArgs([t.toBase58()],i,void 0,{...r,epoch:n??(r==null?void 0:r.epoch)}),a=await this._rpcRequest("getStakeActivation",o),u=O(a,vt(rp));if("error"in u)throw new ot(u.error,`failed to get Stake Activation ${t.toBase58()}`);return u.result}async getProgramAccounts(t,e){const{commitment:n,config:i}=Nt(e),{encoding:r,...o}=i||{},a=this._buildArgs([t.toBase58()],n,r||"base64",{...o,...o.filters?{filters:Yo(o.filters)}:null}),u=await this._rpcRequest("getProgramAccounts",a),g=$(tp),x=o.withContext===!0?O(u,Qt(g)):O(u,vt(g));if("error"in x)throw new ot(x.error,`failed to get accounts owned by program ${t.toBase58()}`);return x.result}async getParsedProgramAccounts(t,e){const{commitment:n,config:i}=Nt(e),r=this._buildArgs([t.toBase58()],n,"jsonParsed",i),o=await this._rpcRequest("getProgramAccounts",r),a=O(o,vt($(np)));if("error"in a)throw new ot(a.error,`failed to get accounts owned by program ${t.toBase58()}`);return a.result}async confirmTransaction(t,e){var r;let n;if(typeof t=="string")n=t;else{const o=t;if((r=o.abortSignal)!=null&&r.aborted)return Promise.reject(o.abortSignal.reason);n=o.signature}let i;try{i=Et.decode(n)}catch{throw new Error("signature must be base58 encoded: "+n)}return be(i.length===64,"signature has invalid length"),typeof t=="string"?await this.confirmTransactionUsingLegacyTimeoutStrategy({commitment:e||this.commitment,signature:n}):"lastValidBlockHeight"in t?await this.confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:e||this.commitment,strategy:t}):await this.confirmTransactionUsingDurableNonceStrategy({commitment:e||this.commitment,strategy:t})}getCancellationPromise(t){return new Promise((e,n)=>{t!=null&&(t.aborted?n(t.reason):t.addEventListener("abort",()=>{n(t.reason)}))})}getTransactionConfirmationPromise({commitment:t,signature:e}){let n,i,r=!1;const o=new Promise((u,g)=>{try{n=this.onSignature(e,(B,I)=>{n=void 0;const v={context:I,value:B};u({__type:Sn.PROCESSED,response:v})},t);const x=new Promise(B=>{n==null?B():i=this._onSubscriptionStateChange(n,I=>{I==="subscribed"&&B()})});(async()=>{if(await x,r)return;const B=await this.getSignatureStatus(e);if(r||B==null)return;const{context:I,value:v}=B;if(v!=null)if(v!=null&&v.err)g(v.err);else{switch(t){case"confirmed":case"single":case"singleGossip":{if(v.confirmationStatus==="processed")return;break}case"finalized":case"max":case"root":{if(v.confirmationStatus==="processed"||v.confirmationStatus==="confirmed")return;break}case"processed":case"recent":}r=!0,u({__type:Sn.PROCESSED,response:{context:I,value:v}})}})()}catch(x){g(x)}});return{abortConfirmation:()=>{i&&(i(),i=void 0),n!=null&&(this.removeSignatureListener(n),n=void 0)},confirmationPromise:o}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:t,strategy:{abortSignal:e,lastValidBlockHeight:n,signature:i}}){let r=!1;const o=new Promise(B=>{const I=async()=>{try{return await this.getBlockHeight(t)}catch{return-1}};(async()=>{let v=await I();if(!r){for(;v<=n;)if(await Yn(1e3),r||(v=await I(),r))return;B({__type:Sn.BLOCKHEIGHT_EXCEEDED})}})()}),{abortConfirmation:a,confirmationPromise:u}=this.getTransactionConfirmationPromise({commitment:t,signature:i}),g=this.getCancellationPromise(e);let x;try{const B=await Promise.race([g,u,o]);if(B.__type===Sn.PROCESSED)x=B.response;else throw new Dc(i)}finally{r=!0,a()}return x}async confirmTransactionUsingDurableNonceStrategy({commitment:t,strategy:{abortSignal:e,minContextSlot:n,nonceAccountPubkey:i,nonceValue:r,signature:o}}){let a=!1;const u=new Promise(v=>{let E=r,R=null;const T=async()=>{try{const{context:N,value:W}=await this.getNonceAndContext(i,{commitment:t,minContextSlot:n});return R=N.slot,W==null?void 0:W.nonce}catch{return E}};(async()=>{if(E=await T(),!a)for(;;){if(r!==E){v({__type:Sn.NONCE_INVALID,slotInWhichNonceDidAdvance:R});return}if(await Yn(2e3),a||(E=await T(),a))return}})()}),{abortConfirmation:g,confirmationPromise:x}=this.getTransactionConfirmationPromise({commitment:t,signature:o}),B=this.getCancellationPromise(e);let I;try{const v=await Promise.race([B,x,u]);if(v.__type===Sn.PROCESSED)I=v.response;else{let E;for(;;){const R=await this.getSignatureStatus(o);if(R==null)break;if(R.context.slot<(v.slotInWhichNonceDidAdvance??n)){await Yn(400);continue}E=R;break}if(E!=null&&E.value){const R=t||"finalized",{confirmationStatus:T}=E.value;switch(R){case"processed":case"recent":if(T!=="processed"&&T!=="confirmed"&&T!=="finalized")throw new vr(o);break;case"confirmed":case"single":case"singleGossip":if(T!=="confirmed"&&T!=="finalized")throw new vr(o);break;case"finalized":case"max":case"root":if(T!=="finalized")throw new vr(o);break;default:}I={context:E.context,value:{err:E.value.err}}}else throw new vr(o)}}finally{a=!0,g()}return I}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:t,signature:e}){let n;const i=new Promise(u=>{let g=this._confirmTransactionInitialTimeout||6e4;switch(t){case"processed":case"recent":case"single":case"confirmed":case"singleGossip":{g=this._confirmTransactionInitialTimeout||3e4;break}}n=setTimeout(()=>u({__type:Sn.TIMED_OUT,timeoutMs:g}),g)}),{abortConfirmation:r,confirmationPromise:o}=this.getTransactionConfirmationPromise({commitment:t,signature:e});let a;try{const u=await Promise.race([o,i]);if(u.__type===Sn.PROCESSED)a=u.response;else throw new zc(e,u.timeoutMs/1e3)}finally{clearTimeout(n),r()}return a}async getClusterNodes(){const t=await this._rpcRequest("getClusterNodes",[]),e=O(t,vt($(gp)));if("error"in e)throw new ot(e.error,"failed to get cluster nodes");return e.result}async getVoteAccounts(t){const e=this._buildArgs([],t),n=await this._rpcRequest("getVoteAccounts",e),i=O(n,mp);if("error"in i)throw new ot(i.error,"failed to get vote accounts");return i.result}async getSlot(t){const{commitment:e,config:n}=Nt(t),i=this._buildArgs([],e,void 0,n),r=await this._rpcRequest("getSlot",i),o=O(r,vt(b()));if("error"in o)throw new ot(o.error,"failed to get slot");return o.result}async getSlotLeader(t){const{commitment:e,config:n}=Nt(t),i=this._buildArgs([],e,void 0,n),r=await this._rpcRequest("getSlotLeader",i),o=O(r,vt(P()));if("error"in o)throw new ot(o.error,"failed to get slot leader");return o.result}async getSlotLeaders(t,e){const n=[t,e],i=await this._rpcRequest("getSlotLeaders",n),r=O(i,vt($(Ht)));if("error"in r)throw new ot(r.error,"failed to get slot leaders");return r.result}async getSignatureStatus(t,e){const{context:n,value:i}=await this.getSignatureStatuses([t],e);be(i.length===1);const r=i[0];return{context:n,value:r}}async getSignatureStatuses(t,e){const n=[t];e&&n.push(e);const i=await this._rpcRequest("getSignatureStatuses",n),r=O(i,bp);if("error"in r)throw new ot(r.error,"failed to get signature status");return r.result}async getTransactionCount(t){const{commitment:e,config:n}=Nt(t),i=this._buildArgs([],e,void 0,n),r=await this._rpcRequest("getTransactionCount",i),o=O(r,vt(b()));if("error"in o)throw new ot(o.error,"failed to get transaction count");return o.result}async getTotalSupply(t){return(await this.getSupply({commitment:t,excludeNonCirculatingAccountsList:!0})).value.total}async getInflationGovernor(t){const e=this._buildArgs([],t),n=await this._rpcRequest("getInflationGovernor",e),i=O(n,D0);if("error"in i)throw new ot(i.error,"failed to get inflation");return i.result}async getInflationReward(t,e,n){const{commitment:i,config:r}=Nt(n),o=this._buildArgs([t.map(g=>g.toBase58())],i,void 0,{...r,epoch:e??(r==null?void 0:r.epoch)}),a=await this._rpcRequest("getInflationReward",o),u=O(a,A0);if("error"in u)throw new ot(u.error,"failed to get inflation reward");return u.result}async getInflationRate(){const t=await this._rpcRequest("getInflationRate",[]),e=O(t,z0);if("error"in e)throw new ot(e.error,"failed to get inflation rate");return e.result}async getEpochInfo(t){const{commitment:e,config:n}=Nt(t),i=this._buildArgs([],e,void 0,n),r=await this._rpcRequest("getEpochInfo",i),o=O(r,W0);if("error"in o)throw new ot(o.error,"failed to get epoch info");return o.result}async getEpochSchedule(){const t=await this._rpcRequest("getEpochSchedule",[]),e=O(t,j0);if("error"in e)throw new ot(e.error,"failed to get epoch schedule");const n=e.result;return new m0(n.slotsPerEpoch,n.leaderScheduleSlotOffset,n.warmup,n.firstNormalEpoch,n.firstNormalSlot)}async getLeaderSchedule(){const t=await this._rpcRequest("getLeaderSchedule",[]),e=O(t,V0);if("error"in e)throw new ot(e.error,"failed to get leader schedule");return e.result}async getMinimumBalanceForRentExemption(t,e){const n=this._buildArgs([t],e),i=await this._rpcRequest("getMinimumBalanceForRentExemption",n),r=O(i,Sp);return"error"in r?(console.warn("Unable to fetch minimum balance for rent exemption"),0):r.result}async getRecentBlockhashAndContext(t){const{context:e,value:{blockhash:n}}=await this.getLatestBlockhashAndContext(t);return{context:e,value:{blockhash:n,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(t){const e=await this._rpcRequest("getRecentPerformanceSamples",t?[t]:[]),n=O(e,Lp);if("error"in n)throw new ot(n.error,"failed to get recent performance samples");return n.result}async getFeeCalculatorForBlockhash(t,e){const n=this._buildArgs([t],e),i=await this._rpcRequest("getFeeCalculatorForBlockhash",n),r=O(i,Up);if("error"in r)throw new ot(r.error,"failed to get fee calculator");const{context:o,value:a}=r.result;return{context:o,value:a!==null?a.feeCalculator:null}}async getFeeForMessage(t,e){const n=ur(t.serialize()).toString("base64"),i=this._buildArgs([n],e),r=await this._rpcRequest("getFeeForMessage",i),o=O(r,Qt(K(b())));if("error"in o)throw new ot(o.error,"failed to get fee for message");if(o.result===null)throw new Error("invalid blockhash");return o.result}async getRecentPrioritizationFees(t){var o;const e=(o=t==null?void 0:t.lockedWritableAccounts)==null?void 0:o.map(a=>a.toBase58()),n=e!=null&&e.length?[e]:[],i=await this._rpcRequest("getRecentPrioritizationFees",n),r=O(i,H0);if("error"in r)throw new ot(r.error,"failed to get recent prioritization fees");return r.result}async getRecentBlockhash(t){try{return(await this.getRecentBlockhashAndContext(t)).value}catch(e){throw new Error("failed to get recent blockhash: "+e)}}async getLatestBlockhash(t){try{return(await this.getLatestBlockhashAndContext(t)).value}catch(e){throw new Error("failed to get recent blockhash: "+e)}}async getLatestBlockhashAndContext(t){const{commitment:e,config:n}=Nt(t),i=this._buildArgs([],e,void 0,n),r=await this._rpcRequest("getLatestBlockhash",i),o=O(r,Mp);if("error"in o)throw new ot(o.error,"failed to get latest blockhash");return o.result}async isBlockhashValid(t,e){const{commitment:n,config:i}=Nt(e),r=this._buildArgs([t],n,void 0,i),o=await this._rpcRequest("isBlockhashValid",r),a=O(o,Tp);if("error"in a)throw new ot(a.error,"failed to determine if the blockhash `"+t+"`is valid");return a.result}async getVersion(){const t=await this._rpcRequest("getVersion",[]),e=O(t,vt(N0));if("error"in e)throw new ot(e.error,"failed to get version");return e.result}async getGenesisHash(){const t=await this._rpcRequest("getGenesisHash",[]),e=O(t,vt(P()));if("error"in e)throw new ot(e.error,"failed to get genesis hash");return e.result}async getBlock(t,e){const{commitment:n,config:i}=Nt(e),r=this._buildArgsAtLeastConfirmed([t],n,void 0,i),o=await this._rpcRequest("getBlock",r);try{switch(i==null?void 0:i.transactionDetails){case"accounts":{const a=O(o,Ep);if("error"in a)throw a.error;return a.result}case"none":{const a=O(o,kp);if("error"in a)throw a.error;return a.result}default:{const a=O(o,_p);if("error"in a)throw a.error;const{result:u}=a;return u?{...u,transactions:u.transactions.map(({transaction:g,meta:x,version:B})=>({meta:x,transaction:{...g,message:fi(B,g.message)},version:B}))}:null}}}catch(a){throw new ot(a,"failed to get confirmed block")}}async getParsedBlock(t,e){const{commitment:n,config:i}=Nt(e),r=this._buildArgsAtLeastConfirmed([t],n,"jsonParsed",i),o=await this._rpcRequest("getBlock",r);try{switch(i==null?void 0:i.transactionDetails){case"accounts":{const a=O(o,Ap);if("error"in a)throw a.error;return a.result}case"none":{const a=O(o,Ip);if("error"in a)throw a.error;return a.result}default:{const a=O(o,Bp);if("error"in a)throw a.error;return a.result}}}catch(a){throw new ot(a,"failed to get block")}}async getBlockProduction(t){let e,n;if(typeof t=="string")n=t;else if(t){const{commitment:a,...u}=t;n=a,e=u}const i=this._buildArgs([],n,"base64",e),r=await this._rpcRequest("getBlockProduction",i),o=O(r,O0);if("error"in o)throw new ot(o.error,"failed to get block production information");return o.result}async getTransaction(t,e){const{commitment:n,config:i}=Nt(e),r=this._buildArgsAtLeastConfirmed([t],n,void 0,i),o=await this._rpcRequest("getTransaction",r),a=O(o,hi);if("error"in a)throw new ot(a.error,"failed to get transaction");const u=a.result;return u&&{...u,transaction:{...u.transaction,message:fi(u.version,u.transaction.message)}}}async getParsedTransaction(t,e){const{commitment:n,config:i}=Nt(e),r=this._buildArgsAtLeastConfirmed([t],n,"jsonParsed",i),o=await this._rpcRequest("getTransaction",r),a=O(o,Hr);if("error"in a)throw new ot(a.error,"failed to get transaction");return a.result}async getParsedTransactions(t,e){const{commitment:n,config:i}=Nt(e),r=t.map(u=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([u],n,"jsonParsed",i)}));return(await this._rpcBatchRequest(r)).map(u=>{const g=O(u,Hr);if("error"in g)throw new ot(g.error,"failed to get transactions");return g.result})}async getTransactions(t,e){const{commitment:n,config:i}=Nt(e),r=t.map(u=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([u],n,void 0,i)}));return(await this._rpcBatchRequest(r)).map(u=>{const g=O(u,hi);if("error"in g)throw new ot(g.error,"failed to get transactions");const x=g.result;return x&&{...x,transaction:{...x.transaction,message:fi(x.version,x.transaction.message)}}})}async getConfirmedBlock(t,e){const n=this._buildArgsAtLeastConfirmed([t],e),i=await this._rpcRequest("getBlock",n),r=O(i,Rp);if("error"in r)throw new ot(r.error,"failed to get confirmed block");const o=r.result;if(!o)throw new Error("Confirmed block "+t+" not found");const a={...o,transactions:o.transactions.map(({transaction:u,meta:g})=>{const x=new Bn(u.message);return{meta:g,transaction:{...u,message:x}}})};return{...a,transactions:a.transactions.map(({transaction:u,meta:g})=>({meta:g,transaction:vn.populate(u.message,u.signatures)}))}}async getBlocks(t,e,n){const i=this._buildArgsAtLeastConfirmed(e!==void 0?[t,e]:[t],n),r=await this._rpcRequest("getBlocks",i),o=O(r,vt($(b())));if("error"in o)throw new ot(o.error,"failed to get blocks");return o.result}async getBlockSignatures(t,e){const n=this._buildArgsAtLeastConfirmed([t],e,void 0,{transactionDetails:"signatures",rewards:!1}),i=await this._rpcRequest("getBlock",n),r=O(i,Qo);if("error"in r)throw new ot(r.error,"failed to get block");const o=r.result;if(!o)throw new Error("Block "+t+" not found");return o}async getConfirmedBlockSignatures(t,e){const n=this._buildArgsAtLeastConfirmed([t],e,void 0,{transactionDetails:"signatures",rewards:!1}),i=await this._rpcRequest("getBlock",n),r=O(i,Qo);if("error"in r)throw new ot(r.error,"failed to get confirmed block");const o=r.result;if(!o)throw new Error("Confirmed block "+t+" not found");return o}async getConfirmedTransaction(t,e){const n=this._buildArgsAtLeastConfirmed([t],e),i=await this._rpcRequest("getTransaction",n),r=O(i,hi);if("error"in r)throw new ot(r.error,"failed to get transaction");const o=r.result;if(!o)return o;const a=new Bn(o.transaction.message),u=o.transaction.signatures;return{...o,transaction:vn.populate(a,u)}}async getParsedConfirmedTransaction(t,e){const n=this._buildArgsAtLeastConfirmed([t],e,"jsonParsed"),i=await this._rpcRequest("getTransaction",n),r=O(i,Hr);if("error"in r)throw new ot(r.error,"failed to get confirmed transaction");return r.result}async getParsedConfirmedTransactions(t,e){const n=t.map(o=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([o],e,"jsonParsed")}));return(await this._rpcBatchRequest(n)).map(o=>{const a=O(o,Hr);if("error"in a)throw new ot(a.error,"failed to get confirmed transactions");return a.result})}async getConfirmedSignaturesForAddress(t,e,n){let i={},r=await this.getFirstAvailableBlock();for(;!("until"in i)&&(e--,!(e<=0||e<r));)try{const u=await this.getConfirmedBlockSignatures(e,"finalized");u.signatures.length>0&&(i.until=u.signatures[u.signatures.length-1].toString())}catch(u){if(u instanceof Error&&u.message.includes("skipped"))continue;throw u}let o=await this.getSlot("finalized");for(;!("before"in i)&&(n++,!(n>o));)try{const u=await this.getConfirmedBlockSignatures(n);u.signatures.length>0&&(i.before=u.signatures[u.signatures.length-1].toString())}catch(u){if(u instanceof Error&&u.message.includes("skipped"))continue;throw u}return(await this.getConfirmedSignaturesForAddress2(t,i)).map(u=>u.signature)}async getConfirmedSignaturesForAddress2(t,e,n){const i=this._buildArgsAtLeastConfirmed([t.toBase58()],n,void 0,e),r=await this._rpcRequest("getConfirmedSignaturesForAddress2",i),o=O(r,sp);if("error"in o)throw new ot(o.error,"failed to get confirmed signatures for address");return o.result}async getSignaturesForAddress(t,e,n){const i=this._buildArgsAtLeastConfirmed([t.toBase58()],n,void 0,e),r=await this._rpcRequest("getSignaturesForAddress",i),o=O(r,ip);if("error"in o)throw new ot(o.error,"failed to get signatures for address");return o.result}async getAddressLookupTable(t,e){const{context:n,value:i}=await this.getAccountInfoAndContext(t,e);let r=null;return i!==null&&(r=new Zo({key:t,state:Zo.deserialize(i.data)})),{context:n,value:r}}async getNonceAndContext(t,e){const{context:n,value:i}=await this.getAccountInfoAndContext(t,e);let r=null;return i!==null&&(r=eo.fromAccountData(i.data)),{context:n,value:r}}async getNonce(t,e){return await this.getNonceAndContext(t,e).then(n=>n.value).catch(n=>{throw new Error("failed to get nonce for account "+t.toBase58()+": "+n)})}async requestAirdrop(t,e){const n=await this._rpcRequest("requestAirdrop",[t.toBase58(),e]),i=O(n,Np);if("error"in i)throw new ot(i.error,`airdrop to ${t.toBase58()} failed`);return i.result}async _blockhashWithExpiryBlockHeight(t){if(!t){for(;this._pollingBlockhash;)await Yn(100);const n=Date.now()-this._blockhashInfo.lastFetch>=_0;if(this._blockhashInfo.latestBlockhash!==null&&!n)return this._blockhashInfo.latestBlockhash}return await this._pollNewBlockhash()}async _pollNewBlockhash(){this._pollingBlockhash=!0;try{const t=Date.now(),e=this._blockhashInfo.latestBlockhash,n=e?e.blockhash:null;for(let i=0;i<50;i++){const r=await this.getLatestBlockhash("finalized");if(n!==r.blockhash)return this._blockhashInfo={latestBlockhash:r,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},r;await Yn(l0/2)}throw new Error(`Unable to obtain a new blockhash after ${Date.now()-t}ms`)}finally{this._pollingBlockhash=!1}}async getStakeMinimumDelegation(t){const{commitment:e,config:n}=Nt(t),i=this._buildArgs([],e,"base64",n),r=await this._rpcRequest("getStakeMinimumDelegation",i),o=O(r,Qt(b()));if("error"in o)throw new ot(o.error,"failed to get stake minimum delegation");return o.result}async simulateTransaction(t,e,n){if("message"in t){const R=t.serialize(),T=Y.Buffer.from(R).toString("base64");if(Array.isArray(e)||n!==void 0)throw new Error("Invalid arguments");const N=e||{};N.encoding="base64","commitment"in N||(N.commitment=this.commitment),e&&typeof e=="object"&&"innerInstructions"in e&&(N.innerInstructions=e.innerInstructions);const W=[T,N],D=await this._rpcRequest("simulateTransaction",W),X=O(D,Xo);if("error"in X)throw new Error("failed to simulate transaction: "+X.error.message);return X.result}let i;if(t instanceof vn){let E=t;i=new vn,i.feePayer=E.feePayer,i.instructions=t.instructions,i.nonceInfo=E.nonceInfo,i.signatures=E.signatures}else i=vn.populate(t),i._message=i._json=void 0;if(e!==void 0&&!Array.isArray(e))throw new Error("Invalid arguments");const r=e;if(i.nonceInfo&&r)i.sign(...r);else{let E=this._disableBlockhashCaching;for(;;){const R=await this._blockhashWithExpiryBlockHeight(E);if(i.lastValidBlockHeight=R.lastValidBlockHeight,i.recentBlockhash=R.blockhash,!r)break;if(i.sign(...r),!i.signature)throw new Error("!signature");const T=i.signature.toString("base64");if(!this._blockhashInfo.simulatedSignatures.includes(T)&&!this._blockhashInfo.transactionSignatures.includes(T)){this._blockhashInfo.simulatedSignatures.push(T);break}else E=!0}}const o=i._compile(),a=o.serialize(),g=i._serialize(a).toString("base64"),x={encoding:"base64",commitment:this.commitment};if(n){const E=(Array.isArray(n)?n:o.nonProgramIds()).map(R=>R.toBase58());x.accounts={encoding:"base64",addresses:E}}r&&(x.sigVerify=!0),e&&typeof e=="object"&&"innerInstructions"in e&&(x.innerInstructions=e.innerInstructions);const B=[g,x],I=await this._rpcRequest("simulateTransaction",B),v=O(I,Xo);if("error"in v){let E;if("data"in v.error&&(E=v.error.data.logs,E&&Array.isArray(E))){const R=`
|
|
20
|
-
`,T=R+E.join(R);console.error(v.error.message,T)}throw new Wo({action:"simulate",signature:"",transactionMessage:v.error.message,logs:E})}return v.result}async sendTransaction(t,e,n){if("version"in t){if(e&&Array.isArray(e))throw new Error("Invalid arguments");const o=t.serialize();return await this.sendRawTransaction(o,e)}if(e===void 0||!Array.isArray(e))throw new Error("Invalid arguments");const i=e;if(t.nonceInfo)t.sign(...i);else{let o=this._disableBlockhashCaching;for(;;){const a=await this._blockhashWithExpiryBlockHeight(o);if(t.lastValidBlockHeight=a.lastValidBlockHeight,t.recentBlockhash=a.blockhash,t.sign(...i),!t.signature)throw new Error("!signature");const u=t.signature.toString("base64");if(this._blockhashInfo.transactionSignatures.includes(u))o=!0;else{this._blockhashInfo.transactionSignatures.push(u);break}}}const r=t.serialize();return await this.sendRawTransaction(r,n)}async sendRawTransaction(t,e){const n=ur(t).toString("base64");return await this.sendEncodedTransaction(n,e)}async sendEncodedTransaction(t,e){const n={encoding:"base64"},i=e&&e.skipPreflight,r=i===!0?"processed":e&&e.preflightCommitment||this.commitment;e&&e.maxRetries!=null&&(n.maxRetries=e.maxRetries),e&&e.minContextSlot!=null&&(n.minContextSlot=e.minContextSlot),i&&(n.skipPreflight=i),r&&(n.preflightCommitment=r);const o=[t,n],a=await this._rpcRequest("sendTransaction",o),u=O(a,Pp);if("error"in u){let g;throw"data"in u.error&&(g=u.error.data.logs),new Wo({action:i?"send":"simulate",signature:"",transactionMessage:u.error.message,logs:g})}return u.result}_wsOnOpen(){this._rpcWebSocketConnected=!0,this._rpcWebSocketHeartbeat=setInterval(()=>{(async()=>{try{await this._rpcWebSocket.notify("ping")}catch{}})()},5e3),this._updateSubscriptions()}_wsOnError(t){this._rpcWebSocketConnected=!1,console.error("ws error:",t.message)}_wsOnClose(t){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),t===1e3){this._updateSubscriptions();return}this._subscriptionCallbacksByServerSubscriptionId={},Object.entries(this._subscriptionsByHash).forEach(([e,n])=>{this._setSubscription(e,{...n,state:"pending"})})}_setSubscription(t,e){var i;const n=(i=this._subscriptionsByHash[t])==null?void 0:i.state;if(this._subscriptionsByHash[t]=e,n!==e.state){const r=this._subscriptionStateChangeCallbacksByHash[t];r&&r.forEach(o=>{try{o(e.state)}catch{}})}}_onSubscriptionStateChange(t,e){var r;const n=this._subscriptionHashByClientSubscriptionId[t];if(n==null)return()=>{};const i=(r=this._subscriptionStateChangeCallbacksByHash)[n]||(r[n]=new Set);return i.add(e),()=>{i.delete(e),i.size===0&&delete this._subscriptionStateChangeCallbacksByHash[n]}}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(n){n instanceof Error&&console.log(`Error when closing socket connection: ${n.message}`)}},500));return}if(this._rpcWebSocketIdleTimeout!==null&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketConnected=!0),!this._rpcWebSocketConnected){this._rpcWebSocket.connect();return}const t=this._rpcWebSocketGeneration,e=()=>t===this._rpcWebSocketGeneration;await Promise.all(Object.keys(this._subscriptionsByHash).map(async n=>{const i=this._subscriptionsByHash[n];if(i!==void 0)switch(i.state){case"pending":case"unsubscribed":if(i.callbacks.size===0){delete this._subscriptionsByHash[n],i.state==="unsubscribed"&&delete this._subscriptionCallbacksByServerSubscriptionId[i.serverSubscriptionId],await this._updateSubscriptions();return}await(async()=>{const{args:r,method:o}=i;try{this._setSubscription(n,{...i,state:"subscribing"});const a=await this._rpcWebSocket.call(o,r);this._setSubscription(n,{...i,serverSubscriptionId:a,state:"subscribed"}),this._subscriptionCallbacksByServerSubscriptionId[a]=i.callbacks,await this._updateSubscriptions()}catch(a){if(console.error(`Received ${a instanceof Error?"":"JSON-RPC "}error calling \`${o}\``,{args:r,error:a}),!e())return;this._setSubscription(n,{...i,state:"pending"}),await this._updateSubscriptions()}})();break;case"subscribed":i.callbacks.size===0&&await(async()=>{const{serverSubscriptionId:r,unsubscribeMethod:o}=i;if(this._subscriptionsAutoDisposedByRpc.has(r))this._subscriptionsAutoDisposedByRpc.delete(r);else{this._setSubscription(n,{...i,state:"unsubscribing"}),this._setSubscription(n,{...i,state:"unsubscribing"});try{await this._rpcWebSocket.call(o,[r])}catch(a){if(a instanceof Error&&console.error(`${o} error:`,a.message),!e())return;this._setSubscription(n,{...i,state:"subscribed"}),await this._updateSubscriptions();return}}this._setSubscription(n,{...i,state:"unsubscribed"}),await this._updateSubscriptions()})();break}}))}_handleServerNotification(t,e){const n=this._subscriptionCallbacksByServerSubscriptionId[t];n!==void 0&&n.forEach(i=>{try{i(...e)}catch(r){console.error(r)}})}_wsOnAccountNotification(t){const{result:e,subscription:n}=O(t,op);this._handleServerNotification(n,[e.value,e.context])}_makeSubscription(t,e){const n=this._nextClientSubscriptionId++,i=Vo([t.method,e]),r=this._subscriptionsByHash[i];return r===void 0?this._subscriptionsByHash[i]={...t,args:e,callbacks:new Set([t.callback]),state:"pending"}:r.callbacks.add(t.callback),this._subscriptionHashByClientSubscriptionId[n]=i,this._subscriptionDisposeFunctionsByClientSubscriptionId[n]=async()=>{delete this._subscriptionDisposeFunctionsByClientSubscriptionId[n],delete this._subscriptionHashByClientSubscriptionId[n];const o=this._subscriptionsByHash[i];be(o!==void 0,`Could not find a \`Subscription\` when tearing down client subscription #${n}`),o.callbacks.delete(t.callback),await this._updateSubscriptions()},this._updateSubscriptions(),n}onAccountChange(t,e,n){const{commitment:i,config:r}=Nt(n),o=this._buildArgs([t.toBase58()],i||this._commitment||"finalized","base64",r);return this._makeSubscription({callback:e,method:"accountSubscribe",unsubscribeMethod:"accountUnsubscribe"},o)}async removeAccountChangeListener(t){await this._unsubscribeClientSubscription(t,"account change")}_wsOnProgramAccountNotification(t){const{result:e,subscription:n}=O(t,cp);this._handleServerNotification(n,[{accountId:e.value.pubkey,accountInfo:e.value.account},e.context])}onProgramAccountChange(t,e,n,i){const{commitment:r,config:o}=Nt(n),a=this._buildArgs([t.toBase58()],r||this._commitment||"finalized","base64",o||(i?{filters:Yo(i)}:void 0));return this._makeSubscription({callback:e,method:"programSubscribe",unsubscribeMethod:"programUnsubscribe"},a)}async removeProgramAccountChangeListener(t){await this._unsubscribeClientSubscription(t,"program account change")}onLogs(t,e,n){const i=this._buildArgs([typeof t=="object"?{mentions:[t.toString()]}:t],n||this._commitment||"finalized");return this._makeSubscription({callback:e,method:"logsSubscribe",unsubscribeMethod:"logsUnsubscribe"},i)}async removeOnLogsListener(t){await this._unsubscribeClientSubscription(t,"logs")}_wsOnLogsNotification(t){const{result:e,subscription:n}=O(t,Op);this._handleServerNotification(n,[e.value,e.context])}_wsOnSlotNotification(t){const{result:e,subscription:n}=O(t,lp);this._handleServerNotification(n,[e])}onSlotChange(t){return this._makeSubscription({callback:t,method:"slotSubscribe",unsubscribeMethod:"slotUnsubscribe"},[])}async removeSlotChangeListener(t){await this._unsubscribeClientSubscription(t,"slot change")}_wsOnSlotUpdatesNotification(t){const{result:e,subscription:n}=O(t,hp);this._handleServerNotification(n,[e])}onSlotUpdate(t){return this._makeSubscription({callback:t,method:"slotsUpdatesSubscribe",unsubscribeMethod:"slotsUpdatesUnsubscribe"},[])}async removeSlotUpdateListener(t){await this._unsubscribeClientSubscription(t,"slot update")}async _unsubscribeClientSubscription(t,e){const n=this._subscriptionDisposeFunctionsByClientSubscriptionId[t];n?await n():console.warn(`Ignored unsubscribe request because an active subscription with id \`${t}\` for '${e}' events could not be found.`)}_buildArgs(t,e,n,i){const r=e||this._commitment;if(r||n||i){let o={};n&&(o.encoding=n),r&&(o.commitment=r),i&&(o=Object.assign(o,i)),t.push(o)}return t}_buildArgsAtLeastConfirmed(t,e,n,i){const r=e||this._commitment;if(r&&!["confirmed","finalized"].includes(r))throw new Error("Using Connection with default commitment: `"+this._commitment+"`, but method requires at least `confirmed`");return this._buildArgs(t,e,n,i)}_wsOnSignatureNotification(t){const{result:e,subscription:n}=O(t,dp);e.value!=="receivedSignature"&&this._subscriptionsAutoDisposedByRpc.add(n),this._handleServerNotification(n,e.value==="receivedSignature"?[{type:"received"},e.context]:[{type:"status",result:e.value},e.context])}onSignature(t,e,n){const i=this._buildArgs([t],n||this._commitment||"finalized"),r=this._makeSubscription({callback:(o,a)=>{if(o.type==="status"){e(o.result,a);try{this.removeSignatureListener(r)}catch{}}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},i);return r}onSignatureWithOptions(t,e,n){const{commitment:i,...r}={...n,commitment:n&&n.commitment||this._commitment||"finalized"},o=this._buildArgs([t],i,void 0,r),a=this._makeSubscription({callback:(u,g)=>{e(u,g);try{this.removeSignatureListener(a)}catch{}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},o);return a}async removeSignatureListener(t){await this._unsubscribeClientSubscription(t,"signature result")}_wsOnRootNotification(t){const{result:e,subscription:n}=O(t,pp);this._handleServerNotification(n,[e])}onRootChange(t){return this._makeSubscription({callback:t,method:"rootSubscribe",unsubscribeMethod:"rootUnsubscribe"},[])}async removeRootChangeListener(t){await this._unsubscribeClientSubscription(t,"root change")}}Object.freeze({CreateLookupTable:{index:0,layout:H([G("instruction"),lr("recentSlot"),st("bumpSeed")])},FreezeLookupTable:{index:1,layout:H([G("instruction")])},ExtendLookupTable:{index:2,layout:H([G("instruction"),lr(),Rt(kt(),Ne(G(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:H([G("instruction")])},CloseLookupTable:{index:4,layout:H([G("instruction")])}});new ft("AddressLookupTab1e1111111111111111111111111");Object.freeze({RequestUnits:{index:0,layout:H([st("instruction"),G("units"),G("additionalFee")])},RequestHeapFrame:{index:1,layout:H([st("instruction"),G("bytes")])},SetComputeUnitLimit:{index:2,layout:H([st("instruction"),G("units")])},SetComputeUnitPrice:{index:3,layout:H([st("instruction"),lr("microLamports")])}});new ft("ComputeBudget111111111111111111111111111111");H([st("numSignatures"),st("padding"),Dt("signatureOffset"),Dt("signatureInstructionIndex"),Dt("publicKeyOffset"),Dt("publicKeyInstructionIndex"),Dt("messageDataOffset"),Dt("messageDataSize"),Dt("messageInstructionIndex")]);new ft("Ed25519SigVerify111111111111111111111111111");mc.utils.isValidPrivateKey;H([st("numSignatures"),Dt("signatureOffset"),st("signatureInstructionIndex"),Dt("ethAddressOffset"),st("ethAddressInstructionIndex"),Dt("messageDataOffset"),Dt("messageDataSize"),st("messageInstructionIndex"),yt(20,"ethAddress"),yt(64,"signature"),st("recoveryId")]);new ft("KeccakSecp256k11111111111111111111111111111");var nu;new ft("StakeConfig11111111111111111111111111111111");class ru{constructor(t,e,n){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=t,this.epoch=e,this.custodian=n}}nu=ru;ru.default=new nu(0,0,ft.default);Object.freeze({Initialize:{index:0,layout:H([G("instruction"),n0(),r0()])},Authorize:{index:1,layout:H([G("instruction"),kt("newAuthorized"),G("stakeAuthorizationType")])},Delegate:{index:2,layout:H([G("instruction")])},Split:{index:3,layout:H([G("instruction"),Ot("lamports")])},Withdraw:{index:4,layout:H([G("instruction"),Ot("lamports")])},Deactivate:{index:5,layout:H([G("instruction")])},Merge:{index:7,layout:H([G("instruction")])},AuthorizeWithSeed:{index:8,layout:H([G("instruction"),kt("newAuthorized"),G("stakeAuthorizationType"),Qn("authoritySeed"),kt("authorityOwner")])}});new ft("Stake11111111111111111111111111111111111111");Object.freeze({InitializeAccount:{index:0,layout:H([G("instruction"),s0()])},Authorize:{index:1,layout:H([G("instruction"),kt("newAuthorized"),G("voteAuthorizationType")])},Withdraw:{index:3,layout:H([G("instruction"),Ot("lamports")])},UpdateValidatorIdentity:{index:4,layout:H([G("instruction")])},AuthorizeWithSeed:{index:10,layout:H([G("instruction"),i0()])}});new ft("Vote111111111111111111111111111111111111111");new ft("Va1idator1nfo111111111111111111111111111111");L({name:P(),website:V(P()),details:V(P()),iconUrl:V(P()),keybaseUsername:V(P())});new ft("Vote111111111111111111111111111111111111111");H([kt("nodePubkey"),kt("authorizedWithdrawer"),st("commission"),Bt(),Rt(H([Bt("slot"),G("confirmationCount")]),Ne(G(),-8),"votes"),st("rootSlotValid"),Bt("rootSlot"),Bt(),Rt(H([Bt("epoch"),kt("authorizedVoter")]),Ne(G(),-8),"authorizedVoters"),H([Rt(H([kt("authorizedPubkey"),Bt("epochOfLastAuthorizedSwitch"),Bt("targetEpoch")]),32,"buf"),Bt("idx"),st("isEmpty")],"priorVoters"),Bt(),Rt(H([Bt("epoch"),Bt("credits"),Bt("prevCredits")]),Ne(G(),-8),"epochCredits"),H([Bt("slot"),Bt("timestamp")],"lastTimestamp")]);export{eg as C,ft as P,vn as T,sg as a,Ho as b,Ir as g,cu as r};
|