(self["webpackChunksuperhero_wallet"]=self["webpackChunksuperhero_wallet"]||[]).push([[783],{601:(e,t,n)=>{"use strict";
/**
 * Support for translating between Uint8Array instances and JavaScript
 * native types.
 *
 * {@link module:Layout~Layout|Layout} is the basis of a class
 * hierarchy that associates property names with sequences of encoded
 * bytes.
 *
 * Layouts are supported for these scalar (numeric) types:
 * * {@link module:Layout~UInt|Unsigned integers in little-endian
 *   format} with {@link module:Layout.u8|8-bit}, {@link
 *   module:Layout.u16|16-bit}, {@link module:Layout.u24|24-bit},
 *   {@link module:Layout.u32|32-bit}, {@link
 *   module:Layout.u40|40-bit}, and {@link module:Layout.u48|48-bit}
 *   representation ranges;
 * * {@link module:Layout~UIntBE|Unsigned integers in big-endian
 *   format} with {@link module:Layout.u16be|16-bit}, {@link
 *   module:Layout.u24be|24-bit}, {@link module:Layout.u32be|32-bit},
 *   {@link module:Layout.u40be|40-bit}, and {@link
 *   module:Layout.u48be|48-bit} representation ranges;
 * * {@link module:Layout~Int|Signed integers in little-endian
 *   format} with {@link module:Layout.s8|8-bit}, {@link
 *   module:Layout.s16|16-bit}, {@link module:Layout.s24|24-bit},
 *   {@link module:Layout.s32|32-bit}, {@link
 *   module:Layout.s40|40-bit}, and {@link module:Layout.s48|48-bit}
 *   representation ranges;
 * * {@link module:Layout~IntBE|Signed integers in big-endian format}
 *   with {@link module:Layout.s16be|16-bit}, {@link
 *   module:Layout.s24be|24-bit}, {@link module:Layout.s32be|32-bit},
 *   {@link module:Layout.s40be|40-bit}, and {@link
 *   module:Layout.s48be|48-bit} representation ranges;
 * * 64-bit integral values that decode to an exact (if magnitude is
 *   less than 2^53) or nearby integral Number in {@link
 *   module:Layout.nu64|unsigned little-endian}, {@link
 *   module:Layout.nu64be|unsigned big-endian}, {@link
 *   module:Layout.ns64|signed little-endian}, and {@link
 *   module:Layout.ns64be|unsigned big-endian} encodings;
 * * 32-bit floating point values with {@link
 *   module:Layout.f32|little-endian} and {@link
 *   module:Layout.f32be|big-endian} representations;
 * * 64-bit floating point values with {@link
 *   module:Layout.f64|little-endian} and {@link
 *   module:Layout.f64be|big-endian} representations;
 * * {@link module:Layout.const|Constants} that take no space in the
 *   encoded expression.
 *
 * and for these aggregate types:
 * * {@link module:Layout.seq|Sequence}s of instances of a {@link
 *   module:Layout~Layout|Layout}, with JavaScript representation as
 *   an Array and constant or data-dependent {@link
 *   module:Layout~Sequence#count|length};
 * * {@link module:Layout.struct|Structure}s that aggregate a
 *   heterogeneous sequence of {@link module:Layout~Layout|Layout}
 *   instances, with JavaScript representation as an Object;
 * * {@link module:Layout.union|Union}s that support multiple {@link
 *   module:Layout~VariantLayout|variant layouts} over a fixed
 *   (padded) or variable (not padded) span of bytes, using an
 *   unsigned integer at the start of the data or a separate {@link
 *   module:Layout.unionLayoutDiscriminator|layout element} to
 *   determine which layout to use when interpreting the buffer
 *   contents;
 * * {@link module:Layout.bits|BitStructure}s that contain a sequence
 *   of individual {@link
 *   module:Layout~BitStructure#addField|BitField}s packed into an 8,
 *   16, 24, or 32-bit unsigned integer starting at the least- or
 *   most-significant bit;
 * * {@link module:Layout.cstr|C strings} of varying length;
 * * {@link module:Layout.blob|Blobs} of fixed- or variable-{@link
 *   module:Layout~Blob#length|length} raw data.
 *
 * All {@link module:Layout~Layout|Layout} instances are immutable
 * after construction, to prevent internal state from becoming
 * inconsistent.
 *
 * @local Layout
 * @local ExternalLayout
 * @local GreedyCount
 * @local OffsetLayout
 * @local UInt
 * @local UIntBE
 * @local Int
 * @local IntBE
 * @local NearUInt64
 * @local NearUInt64BE
 * @local NearInt64
 * @local NearInt64BE
 * @local Float
 * @local FloatBE
 * @local Double
 * @local DoubleBE
 * @local Sequence
 * @local Structure
 * @local UnionDiscriminator
 * @local UnionLayoutDiscriminator
 * @local Union
 * @local VariantLayout
 * @local BitStructure
 * @local BitField
 * @local Boolean
 * @local Blob
 * @local CString
 * @local Constant
 * @local bindConstructorLayout
 * @module Layout
 * @license MIT
 * @author Peter A. Bigot
 * @see {@link https://github.com/pabigot/buffer-layout|buffer-layout on GitHub}
 */
t.I0=t.DH=t.NX=t.u8=t.cY=void 0,t.av=t.O6=t.w3=t.Wg=void 0;const r=n(48287);function i(e){if(!(e instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}function s(e){return i(e),r.Buffer.from(e.buffer,e.byteOffset,e.length)}class o{constructor(e,t){if(!Number.isInteger(e))throw new TypeError("span must be an integer");this.span=e,this.property=t}makeDestinationObject(){return{}}getSpan(e,t){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(e){const t=Object.create(this.constructor.prototype);return Object.assign(t,this),t.property=e,t}fromArray(e){}}function a(e,t){return t.property?e+"["+t.property+"]":e}function c(e,t){if("function"!==typeof e)throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(e,"layout_"))throw new Error("Class is already bound to a layout");if(!(t&&t instanceof o))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(t,"boundConstructor_"))throw new Error("layout is already bound to a constructor");e.layout_=t,t.boundConstructor_=e,t.makeDestinationObject=()=>new e,Object.defineProperty(e.prototype,"encode",{value(e,n){return t.encode(this,e,n)},writable:!0}),Object.defineProperty(e,"decode",{value(e,n){return t.decode(e,n)},writable:!0})}class u extends o{isCount(){throw new Error("ExternalLayout is abstract")}}class l extends u{constructor(e=1,t){if(!Number.isInteger(e)||0>=e)throw new TypeError("elementSpan must be a (positive) integer");super(-1,t),this.elementSpan=e}isCount(){return!0}decode(e,t=0){i(e);const n=e.length-t;return Math.floor(n/this.elementSpan)}encode(e,t,n){return 0}}class d extends u{constructor(e,t=0,n){if(!(e instanceof o))throw new TypeError("layout must be a Layout");if(!Number.isInteger(t))throw new TypeError("offset must be integer or undefined");super(e.span,n||e.property),this.layout=e,this.offset=t}isCount(){return this.layout instanceof h||this.layout instanceof p}decode(e,t=0){return this.layout.decode(e,t+this.offset)}encode(e,t,n=0){return this.layout.encode(e,t,n+this.offset)}}class h extends o{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t=0){return s(e).readUIntLE(t,this.span)}encode(e,t,n=0){return s(t).writeUIntLE(e,n,this.span),this.span}}class p extends o{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t=0){return s(e).readUIntBE(t,this.span)}encode(e,t,n=0){return s(t).writeUIntBE(e,n,this.span),this.span}}class g extends o{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t=0){return s(e).readIntLE(t,this.span)}encode(e,t,n=0){return s(t).writeIntLE(e,n,this.span),this.span}}class f extends o{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t=0){return s(e).readIntBE(t,this.span)}encode(e,t,n=0){return s(t).writeIntBE(e,n,this.span),this.span}}const m=Math.pow(2,32);function y(e){const t=Math.floor(e/m),n=e-t*m;return{hi32:t,lo32:n}}function b(e,t){return e*m+t}class w extends o{constructor(e){super(8,e)}decode(e,t=0){const n=s(e),r=n.readUInt32LE(t),i=n.readUInt32LE(t+4);return b(i,r)}encode(e,t,n=0){const r=y(e),i=s(t);return i.writeUInt32LE(r.lo32,n),i.writeUInt32LE(r.hi32,n+4),8}}class k extends o{constructor(e){super(8,e)}decode(e,t=0){const n=s(e),r=n.readUInt32BE(t),i=n.readUInt32BE(t+4);return b(r,i)}encode(e,t,n=0){const r=y(e),i=s(t);return i.writeUInt32BE(r.hi32,n),i.writeUInt32BE(r.lo32,n+4),8}}class S extends o{constructor(e){super(8,e)}decode(e,t=0){const n=s(e),r=n.readUInt32LE(t),i=n.readInt32LE(t+4);return b(i,r)}encode(e,t,n=0){const r=y(e),i=s(t);return i.writeUInt32LE(r.lo32,n),i.writeInt32LE(r.hi32,n+4),8}}class v extends o{constructor(e){super(8,e)}decode(e,t=0){const n=s(e),r=n.readInt32BE(t),i=n.readUInt32BE(t+4);return b(r,i)}encode(e,t,n=0){const r=y(e),i=s(t);return i.writeInt32BE(r.hi32,n),i.writeUInt32BE(r.lo32,n+4),8}}class I extends o{constructor(e){super(4,e)}decode(e,t=0){return s(e).readFloatLE(t)}encode(e,t,n=0){return s(t).writeFloatLE(e,n),4}}class A extends o{constructor(e){super(4,e)}decode(e,t=0){return s(e).readFloatBE(t)}encode(e,t,n=0){return s(t).writeFloatBE(e,n),4}}class x extends o{constructor(e){super(8,e)}decode(e,t=0){return s(e).readDoubleLE(t)}encode(e,t,n=0){return s(t).writeDoubleLE(e,n),8}}class _ extends o{constructor(e){super(8,e)}decode(e,t=0){return s(e).readDoubleBE(t)}encode(e,t,n=0){return s(t).writeDoubleBE(e,n),8}}class B extends o{constructor(e,t,n){if(!(e instanceof o))throw new TypeError("elementLayout must be a Layout");if(!(t instanceof u&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let r=-1;!(t instanceof u)&&0<e.span&&(r=t*e.span),super(r,n),this.elementLayout=e,this.count=t}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0,r=this.count;if(r instanceof u&&(r=r.decode(e,t)),0<this.elementLayout.span)n=r*this.elementLayout.span;else{let i=0;while(i<r)n+=this.elementLayout.getSpan(e,t+n),++i}return n}decode(e,t=0){const n=[];let r=0,i=this.count;i instanceof u&&(i=i.decode(e,t));while(r<i)n.push(this.elementLayout.decode(e,t)),t+=this.elementLayout.getSpan(e,t),r+=1;return n}encode(e,t,n=0){const r=this.elementLayout,i=e.reduce((e,i)=>e+r.encode(i,t,n+e),0);return this.count instanceof u&&this.count.encode(e.length,t,n),i}}class E extends o{constructor(e,t,n){if(!Array.isArray(e)||!e.reduce((e,t)=>e&&t instanceof o,!0))throw new TypeError("fields must be array of Layout instances");"boolean"===typeof t&&void 0===n&&(n=t,t=void 0);for(const s of e)if(0>s.span&&void 0===s.property)throw new Error("fields cannot contain unnamed variable-length layout");let r=-1;try{r=e.reduce((e,t)=>e+t.getSpan(),0)}catch(i){}super(r,t),this.fields=e,this.decodePrefixes=!!n}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0;try{n=this.fields.reduce((n,r)=>{const i=r.getSpan(e,t);return t+=i,n+i},0)}catch(r){throw new RangeError("indeterminate span")}return n}decode(e,t=0){i(e);const n=this.makeDestinationObject();for(const r of this.fields)if(void 0!==r.property&&(n[r.property]=r.decode(e,t)),t+=r.getSpan(e,t),this.decodePrefixes&&e.length===t)break;return n}encode(e,t,n=0){const r=n;let i=0,s=0;for(const o of this.fields){let r=o.span;if(s=0<r?r:0,void 0!==o.property){const i=e[o.property];void 0!==i&&(s=o.encode(i,t,n),0>r&&(r=o.getSpan(t,n)))}i=n,n+=r}return i+s-r}fromArray(e){const t=this.makeDestinationObject();for(const n of this.fields)void 0!==n.property&&0<e.length&&(t[n.property]=e.shift());return t}layoutFor(e){if("string"!==typeof e)throw new TypeError("property must be string");for(const t of this.fields)if(t.property===e)return t}offsetOf(e){if("string"!==typeof e)throw new TypeError("property must be string");let t=0;for(const n of this.fields){if(n.property===e)return t;0>n.span?t=-1:0<=t&&(t+=n.span)}}}class W{constructor(e){this.property=e}decode(e,t){throw new Error("UnionDiscriminator is abstract")}encode(e,t,n){throw new Error("UnionDiscriminator is abstract")}}class P extends W{constructor(e,t){if(!(e instanceof u&&e.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(t||e.property||"variant"),this.layout=e}decode(e,t){return this.layout.decode(e,t)}encode(e,t,n){return this.layout.encode(e,t,n)}}class T extends o{constructor(e,t,n){let r;if(e instanceof h||e instanceof p)r=new P(new d(e));else if(e instanceof u&&e.isCount())r=new P(e);else{if(!(e instanceof W))throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");r=e}if(void 0===t&&(t=null),!(null===t||t instanceof o))throw new TypeError("defaultLayout must be null or a Layout");if(null!==t){if(0>t.span)throw new Error("defaultLayout must have constant span");void 0===t.property&&(t=t.replicate("content"))}let i=-1;t&&(i=t.span,0<=i&&(e instanceof h||e instanceof p)&&(i+=r.layout.span)),super(i,n),this.discriminator=r,this.usesPrefixDiscriminator=e instanceof h||e instanceof p,this.defaultLayout=t,this.registry={};let s=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(e){return s(e)},this.configGetSourceVariant=function(e){s=e.bind(this)}}getSpan(e,t=0){if(0<=this.span)return this.span;const n=this.getVariant(e,t);if(!n)throw new Error("unable to determine span for unrecognized variant");return n.getSpan(e,t)}defaultGetSourceVariant(e){if(Object.prototype.hasOwnProperty.call(e,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(e,this.defaultLayout.property))return;const t=this.registry[e[this.discriminator.property]];if(t&&(!t.layout||t.property&&Object.prototype.hasOwnProperty.call(e,t.property)))return t}else for(const t in this.registry){const n=this.registry[t];if(n.property&&Object.prototype.hasOwnProperty.call(e,n.property))return n}throw new Error("unable to infer src variant")}decode(e,t=0){let n;const r=this.discriminator,i=r.decode(e,t),s=this.registry[i];if(void 0===s){const s=this.defaultLayout;let o=0;this.usesPrefixDiscriminator&&(o=r.layout.span),n=this.makeDestinationObject(),n[r.property]=i,n[s.property]=s.decode(e,t+o)}else n=s.decode(e,t);return n}encode(e,t,n=0){const r=this.getSourceVariant(e);if(void 0===r){const r=this.discriminator,i=this.defaultLayout;let s=0;return this.usesPrefixDiscriminator&&(s=r.layout.span),r.encode(e[r.property],t,n),s+i.encode(e[i.property],t,n+s)}return r.encode(e,t,n)}addVariant(e,t,n){const r=new C(this,e,t,n);return this.registry[e]=r,r}getVariant(e,t=0){let n;return n=e instanceof Uint8Array?this.discriminator.decode(e,t):e,this.registry[n]}}class C extends o{constructor(e,t,n,r){if(!(e instanceof T))throw new TypeError("union must be a Union");if(!Number.isInteger(t)||0>t)throw new TypeError("variant must be a (non-negative) integer");if("string"===typeof n&&void 0===r&&(r=n,n=null),n){if(!(n instanceof o))throw new TypeError("layout must be a Layout");if(null!==e.defaultLayout&&0<=n.span&&n.span>e.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if("string"!==typeof r)throw new TypeError("variant must have a String property")}let i=e.span;0>e.span&&(i=n?n.span:0,0<=i&&e.usesPrefixDiscriminator&&(i+=e.discriminator.layout.span)),super(i,r),this.union=e,this.variant=t,this.layout=n||null}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0;this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span);let r=0;return this.layout&&(r=this.layout.getSpan(e,t+n)),n+r}decode(e,t=0){const n=this.makeDestinationObject();if(this!==this.union.getVariant(e,t))throw new Error("variant mismatch");let r=0;return this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span),this.layout?n[this.property]=this.layout.decode(e,t+r):this.property?n[this.property]=!0:this.union.usesPrefixDiscriminator&&(n[this.union.discriminator.property]=this.variant),n}encode(e,t,n=0){let r=0;if(this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(e,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,t,n);let i=r;if(this.layout&&(this.layout.encode(e[this.property],t,n+r),i+=this.layout.getSpan(t,n+r),0<=this.union.span&&i>this.union.span))throw new Error("encoded variant overruns containing union");return i}fromArray(e){if(this.layout)return this.layout.fromArray(e)}}function N(e){return 0>e&&(e+=4294967296),e}class O extends o{constructor(e,t,n){if(!(e instanceof h||e instanceof p))throw new TypeError("word must be a UInt or UIntBE layout");if("string"===typeof t&&void 0===n&&(n=t,t=!1),4<e.span)throw new RangeError("word cannot exceed 32 bits");super(e.span,n),this.word=e,this.msb=!!t,this.fields=[];let r=0;this._packedSetValue=function(e){return r=N(e),this},this._packedGetValue=function(){return r}}decode(e,t=0){const n=this.makeDestinationObject(),r=this.word.decode(e,t);this._packedSetValue(r);for(const i of this.fields)void 0!==i.property&&(n[i.property]=i.decode(e));return n}encode(e,t,n=0){const r=this.word.decode(t,n);this._packedSetValue(r);for(const i of this.fields)if(void 0!==i.property){const t=e[i.property];void 0!==t&&i.encode(t)}return this.word.encode(this._packedGetValue(),t,n)}addField(e,t){const n=new z(this,e,t);return this.fields.push(n),n}addBoolean(e){const t=new L(this,e);return this.fields.push(t),t}fieldFor(e){if("string"!==typeof e)throw new TypeError("property must be string");for(const t of this.fields)if(t.property===e)return t}}class z{constructor(e,t,n){if(!(e instanceof O))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(t)||0>=t)throw new TypeError("bits must be positive integer");const r=8*e.span,i=e.fields.reduce((e,t)=>e+t.bits,0);if(t+i>r)throw new Error("bits too long for span remainder ("+(r-i)+" of "+r+" remain)");this.container=e,this.bits=t,this.valueMask=(1<<t)-1,32===t&&(this.valueMask=4294967295),this.start=i,this.container.msb&&(this.start=r-i-t),this.wordMask=N(this.valueMask<<this.start),this.property=n}decode(e,t){const n=this.container._packedGetValue(),r=N(n&this.wordMask),i=r>>>this.start;return i}encode(e){if("number"!==typeof e||!Number.isInteger(e)||e!==N(e&this.valueMask))throw new TypeError(a("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const t=this.container._packedGetValue(),n=N(e<<this.start);this.container._packedSetValue(N(t&~this.wordMask)|n)}}class L extends z{constructor(e,t){super(e,1,t)}decode(e,t){return!!super.decode(e,t)}encode(e){"boolean"===typeof e&&(e=+e),super.encode(e)}}class K extends o{constructor(e,t){if(!(e instanceof u&&e.isCount()||Number.isInteger(e)&&0<=e))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let n=-1;e instanceof u||(n=e),super(n,t),this.length=e}getSpan(e,t){let n=this.span;return 0>n&&(n=this.length.decode(e,t)),n}decode(e,t=0){let n=this.span;return 0>n&&(n=this.length.decode(e,t)),s(e).slice(t,t+n)}encode(e,t,n){let r=this.length;if(this.length instanceof u&&(r=e.length),!(e instanceof Uint8Array&&r===e.length))throw new TypeError(a("Blob.encode",this)+" requires (length "+r+") Uint8Array as src");if(n+r>t.length)throw new RangeError("encoding overruns Uint8Array");const i=s(e);return s(t).write(i.toString("hex"),n,r,"hex"),this.length instanceof u&&this.length.encode(r,t,n),r}}class R extends o{constructor(e){super(-1,e)}getSpan(e,t=0){i(e);let n=t;while(n<e.length&&0!==e[n])n+=1;return 1+n-t}decode(e,t=0){const n=this.getSpan(e,t);return s(e).slice(t,t+n-1).toString("utf-8")}encode(e,t,n=0){"string"!==typeof e&&(e=String(e));const i=r.Buffer.from(e,"utf8"),o=i.length;if(n+o>t.length)throw new RangeError("encoding overruns Buffer");const a=s(t);return i.copy(a,n),a[n+o]=0,o+1}}class j extends o{constructor(e,t){if("string"===typeof e&&void 0===t&&(t=e,e=void 0),void 0===e)e=-1;else if(!Number.isInteger(e))throw new TypeError("maxSpan must be an integer");super(-1,t),this.maxSpan=e}getSpan(e,t=0){return i(e),e.length-t}decode(e,t=0){const n=this.getSpan(e,t);if(0<=this.maxSpan&&this.maxSpan<n)throw new RangeError("text length exceeds maxSpan");return s(e).slice(t,t+n).toString("utf-8")}encode(e,t,n=0){"string"!==typeof e&&(e=String(e));const i=r.Buffer.from(e,"utf8"),o=i.length;if(0<=this.maxSpan&&this.maxSpan<o)throw new RangeError("text length exceeds maxSpan");if(n+o>t.length)throw new RangeError("encoding overruns Buffer");return i.copy(s(t),n),o}}class q extends o{constructor(e,t){super(0,t),this.value=e}decode(e,t){return this.value}encode(e,t,n){return 0}}t.cY=(e,t,n)=>new d(e,t,n),t.u8=e=>new h(1,e),t.NX=e=>new h(2,e),t.DH=e=>new h(4,e),t.I0=e=>new w(e),t.Wg=e=>new S(e),t.w3=(e,t,n)=>new E(e,t,n),t.O6=(e,t,n)=>new B(e,t,n),t.av=(e,t)=>new K(e,t)},920:(e,t,n)=>{"use strict";var r=n(69675),i=n(58859),s=n(14803),o=n(80507),a=n(72271),c=a||o||s;e.exports=function(){var e,t={assert:function(e){if(!t.has(e))throw new r("Side channel does not contain "+i(e))},delete:function(t){return!!e&&e["delete"](t)},get:function(t){return e&&e.get(t)},has:function(t){return!!e&&e.has(t)},set:function(t,n){e||(e=c()),e.set(t,n)}};return t}},9646:(e,t,n)=>{"use strict";n.d(t,{JA:()=>o});var r=n(20079);if(185!=n.j)var i=n(49215);var s=n(48287)["Buffer"];function o(e,t,n,r,o=i.x5,c=i.EK){return a(e,t,n,r,s.alloc(0),o,c)}function a(e,t,n,s,o,a=i.x5,c=i.EK){const u=[{pubkey:e,isSigner:!0,isWritable:!0},{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!1},{pubkey:s,isSigner:!1,isWritable:!1},{pubkey:r.yq.programId,isSigner:!1,isWritable:!1},{pubkey:a,isSigner:!1,isWritable:!1}];return new r.fH({keys:u,programId:c,data:o})}},9683:(e,t,n)=>{"use strict";n.d(t,{lu:()=>i});class r extends Error{constructor(e){super(e)}}class i extends r{constructor(){super(...arguments),this.name="TokenOwnerOffCurveError"}}},10898:(e,t,n)=>{"use strict";n.d(t,{P:()=>r});const r=e=>{const t=e.decode.bind(e),n=e.encode.bind(e);return{decode:t,encode:n}}},14753:(e,t,n)=>{"use strict";n.d(t,{d:()=>i});var r=n(20079);function i(e,t,n){if(n.length){e.push({pubkey:t,isSigner:!1,isWritable:!1});for(const t of n)e.push({pubkey:t instanceof r.J3?t:t.publicKey,isSigner:!0,isWritable:!1})}else e.push({pubkey:t,isSigner:!0,isWritable:!1});return e}},14803:(e,t,n)=>{"use strict";var r=n(58859),i=n(69675),s=function(e,t,n){for(var r,i=e;null!=(r=i.next);i=r)if(r.key===t)return i.next=r.next,n||(r.next=e.next,e.next=r),r},o=function(e,t){if(e){var n=s(e,t);return n&&n.value}},a=function(e,t,n){var r=s(e,t);r?r.value=n:e.next={key:t,next:e.next,value:n}},c=function(e,t){return!!e&&!!s(e,t)},u=function(e,t){if(e)return s(e,t,!0)};e.exports=function(){var e,t={assert:function(e){if(!t.has(e))throw new i("Side channel does not contain "+r(e))},delete:function(t){var n=e&&e.next,r=u(e,t);return r&&n&&n===r&&(e=void 0),!!r},get:function(t){return o(e,t)},has:function(t){return c(e,t)},set:function(t,n){e||(e={next:void 0}),a(e,t,n)}};return t}},14829:(e,t,n)=>{"use strict";if(n.d(t,{$C:()=>o,C1:()=>l,mC:()=>c,xL:()=>u,xv:()=>s}),185!=n.j)var r=n(36027);function i(e,t){return"fixedSize"in t?t.fixedSize:t.getSizeFromValue(e)}function s(e){return Object.freeze({...e,encode:t=>{const n=new Uint8Array(i(t,e));return e.write(t,n,0),n}})}function o(e){return Object.freeze({...e,decode:(t,n=0)=>e.read(t,n)[0]})}function a(e){return"fixedSize"in e&&"number"===typeof e.fixedSize}function c(e,t){if(a(e)!==a(t))throw new r.tsw(r.CvZ);if(a(e)&&a(t)&&e.fixedSize!==t.fixedSize)throw new r.tsw(r.Uq4,{decoderFixedSize:t.fixedSize,encoderFixedSize:e.fixedSize});if(!a(e)&&!a(t)&&e.maxSize!==t.maxSize)throw new r.tsw(r.SHY,{decoderMaxSize:t.maxSize,encoderMaxSize:e.maxSize});return{...t,...e,decode:t.decode,encode:e.encode,read:t.read,write:e.write}}function u(e,t,n=0){if(t.length-n<=0)throw new r.tsw(r.Ot7,{codecDescription:e})}function l(e,t,n,i=0){const s=n.length-i;if(s<t)throw new r.tsw(r.Uyo,{bytesLength:s,codecDescription:e,expected:t})}},15621:(e,t,n)=>{"use strict";var r=n(92861).Buffer;function i(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var i=0;i<e.length;i++){var s=e.charAt(i),o=s.charCodeAt(0);if(255!==t[o])throw new TypeError(s+" is ambiguous");t[o]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function d(t){if((Array.isArray(t)||t instanceof Uint8Array)&&(t=r.from(t)),!r.isBuffer(t))throw new TypeError("Expected Buffer");if(0===t.length)return"";var n=0,i=0,s=0,o=t.length;while(s!==o&&0===t[s])s++,n++;var u=(o-s)*l+1>>>0,d=new Uint8Array(u);while(s!==o){for(var h=t[s],p=0,g=u-1;(0!==h||p<i)&&-1!==g;g--,p++)h+=256*d[g]>>>0,d[g]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");i=p,s++}var f=u-i;while(f!==u&&0===d[f])f++;for(var m=c.repeat(n);f<u;++f)m+=e.charAt(d[f]);return m}function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return r.alloc(0);var n=0,i=0,s=0;while(e[n]===c)i++,n++;var o=(e.length-n)*u+1>>>0,l=new Uint8Array(o);while(n<e.length){var d=e.charCodeAt(n);if(d>255)return;var h=t[d];if(255===h)return;for(var p=0,g=o-1;(0!==h||p<s)&&-1!==g;g--,p++)h+=a*l[g]>>>0,l[g]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");s=p,n++}var f=o-s;while(f!==o&&0===l[f])f++;var m=r.allocUnsafe(i+(o-f));m.fill(0,0,i);var y=i;while(f!==o)m[y++]=l[f++];return m}function p(e){var t=h(e);if(t)return t;throw new Error("Non-base"+a+" character")}return{encode:d,decodeUnsafe:h,decode:p}}e.exports=i},20079:(e,t,n)=>{"use strict";n.d(t,{Ng:()=>Qn,AX:()=>er,Sr:()=>xr,J3:()=>Y,yq:()=>Oe,ZX:()=>ge,fH:()=>pe});var r=n(48287),i=n(36216),s=n(39404),o=n.n(s),a=n(43466),c=n.n(a),u=n(78226),l=n(92755),d=n(601),h=n(36027),p=n(14829);function g(e,t,n,r){if(r<t||r>n)throw new h.tsw(h.hMG,{codecDescription:e,max:n,min:t,value:r})}function f(e){return 1!==e?.endian}function m(e){return(0,p.xv)({fixedSize:e.size,write(t,n,r){e.range&&g(e.name,e.range[0],e.range[1],t);const i=new ArrayBuffer(e.size);return e.set(new DataView(i),t,f(e.config)),n.set(new Uint8Array(i),r),r+e.size}})}function y(e){return(0,p.$C)({fixedSize:e.size,read(t,n=0){(0,p.xL)(e.name,t,n),(0,p.C1)(e.name,e.size,t,n);const r=new DataView(b(t,n,e.size));return[e.get(r,f(e.config)),n+e.size]}})}function b(e,t,n){const r=e.byteOffset+(t??0),i=n??e.byteLength;return e.buffer.slice(r,r+i)}var w=(e={})=>m({config:e,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(e,t,n)=>e.setBigUint64(0,BigInt(t),n),size:8}),k=(e={})=>y({config:e,get:(e,t)=>e.getBigUint64(0,t),name:"u64",size:8}),S=(e={})=>(0,p.mC)(w(e),k(e)),v=n(2150),I=n(40022),A=n.n(I),x=n(5079),_=n(77238),B=n(11630);i.ev.utils.randomPrivateKey;const E=()=>{const e=i.ev.utils.randomPrivateKey(),t=W(e),n=new Uint8Array(64);return n.set(e),n.set(t,32),{publicKey:t,secretKey:n}},W=i.ev.getPublicKey;function P(e){try{return i.ev.ExtendedPoint.fromHex(e),!0}catch{return!1}}const T=(e,t)=>i.ev.sign(e,t.slice(0,32)),C=i.ev.verify,N=e=>r.Buffer.isBuffer(e)?e:e instanceof Uint8Array?r.Buffer.from(e.buffer,e.byteOffset,e.byteLength):r.Buffer.from(e);class O{constructor(e){Object.assign(this,e)}encode(){return r.Buffer.from((0,l.serialize)(z,this))}static decode(e){return(0,l.deserialize)(z,this,e)}static decodeUnchecked(e){return(0,l.deserializeUnchecked)(z,this,e)}}const z=new Map;var L;const K=32,R=32;function j(e){return void 0!==e._bn}let q=1;class Y extends O{constructor(e){if(super({}),this._bn=void 0,j(e))this._bn=e._bn;else{if("string"===typeof e){const t=c().decode(e);if(t.length!=R)throw new Error("Invalid public key input");this._bn=new(o())(t)}else this._bn=new(o())(e);if(this._bn.byteLength()>R)throw new Error("Invalid public key input")}}static unique(){const e=new Y(q);return q+=1,new Y(e.toBuffer())}equals(e){return this._bn.eq(e._bn)}toBase58(){return c().encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){const e=this.toBuffer();return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}toBuffer(){const e=this._bn.toArrayLike(r.Buffer);if(e.length===R)return e;const t=r.Buffer.alloc(32);return e.copy(t,32-e.length),t}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(e,t,n){const i=r.Buffer.concat([e.toBuffer(),r.Buffer.from(t),n.toBuffer()]),s=(0,u.sc)(i);return new Y(s)}static createProgramAddressSync(e,t){let n=r.Buffer.alloc(0);e.forEach(function(e){if(e.length>K)throw new TypeError("Max seed length exceeded");n=r.Buffer.concat([n,N(e)])}),n=r.Buffer.concat([n,t.toBuffer(),r.Buffer.from("ProgramDerivedAddress")]);const i=(0,u.sc)(n);if(P(i))throw new Error("Invalid seeds, address must fall off the curve");return new Y(i)}static async createProgramAddress(e,t){return this.createProgramAddressSync(e,t)}static findProgramAddressSync(e,t){let n,i=255;while(0!=i){try{const s=e.concat(r.Buffer.from([i]));n=this.createProgramAddressSync(s,t)}catch(s){if(s instanceof TypeError)throw s;i--;continue}return[n,i]}throw new Error("Unable to find a viable program address nonce")}static async findProgramAddress(e,t){return this.findProgramAddressSync(e,t)}static isOnCurve(e){const t=new Y(e);return P(t.toBytes())}}L=Y,Y.default=new L("11111111111111111111111111111111"),z.set(Y,{kind:"struct",fields:[["_bn","u256"]]});new Y("BPFLoader1111111111111111111111111111111111");const D=1232,M=127,H=64;class U extends Error{constructor(e){super(`Signature ${e} has expired: block height exceeded.`),this.signature=void 0,this.signature=e}}Object.defineProperty(U.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});class $ extends Error{constructor(e,t){super(`Transaction was not confirmed in ${t.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${e} using the Solana Explorer or CLI tools.`),this.signature=void 0,this.signature=e}}Object.defineProperty($.prototype,"name",{value:"TransactionExpiredTimeoutError"});class F extends Error{constructor(e){super(`Signature ${e} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=e}}Object.defineProperty(F.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});class V{constructor(e,t){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=e,this.accountKeysFromLookups=t}keySegments(){const e=[this.staticAccountKeys];return this.accountKeysFromLookups&&(e.push(this.accountKeysFromLookups.writable),e.push(this.accountKeysFromLookups.readonly)),e}get(e){for(const t of this.keySegments()){if(e<t.length)return t[e];e-=t.length}}get length(){return this.keySegments().flat().length}compileInstructions(e){const t=255;if(this.length>t+1)throw new Error("Account index overflow encountered during compilation");const n=new Map;this.keySegments().flat().forEach((e,t)=>{n.set(e.toBase58(),t)});const r=e=>{const t=n.get(e.toBase58());if(void 0===t)throw new Error("Encountered an unknown instruction account key during compilation");return t};return e.map(e=>({programIdIndex:r(e.programId),accountKeyIndexes:e.keys.map(e=>r(e.pubkey)),data:e.data}))}}const J=(e="publicKey")=>d.av(32,e),G=(e="string")=>{const t=d.w3([d.DH("length"),d.DH("lengthPadding"),d.av(d.cY(d.DH(),-8),"chars")],e),n=t.decode.bind(t),i=t.encode.bind(t),s=t;return s.decode=(e,t)=>{const r=n(e,t);return r["chars"].toString()},s.encode=(e,t,n)=>{const s={chars:r.Buffer.from(e,"utf8")};return i(s,t,n)},s.alloc=e=>d.DH().span+d.DH().span+r.Buffer.from(e,"utf8").length,s},X=(e="authorized")=>d.w3([J("staker"),J("withdrawer")],e),Z=(e="lockup")=>d.w3([d.Wg("unixTimestamp"),d.Wg("epoch"),J("custodian")],e),Q=(e="voteInit")=>d.w3([J("nodePubkey"),J("authorizedVoter"),J("authorizedWithdrawer"),d.u8("commission")],e),ee=(e="voteAuthorizeWithSeedArgs")=>d.w3([d.DH("voteAuthorizationType"),J("currentAuthorityDerivedKeyOwnerPubkey"),G("currentAuthorityDerivedKeySeed"),J("newAuthorized")],e);function te(e,t){const n=e=>{if(e.span>=0)return e.span;if("function"===typeof e.alloc)return e.alloc(t[e.property]);if("count"in e&&"elementLayout"in e){const r=t[e.property];if(Array.isArray(r))return r.length*n(e.elementLayout)}else if("fields"in e)return te({layout:e},t[e.property]);return 0};let r=0;return e.layout.fields.forEach(e=>{r+=n(e)}),r}function ne(e){let t=0,n=0;for(;;){let r=e.shift();if(t|=(127&r)<<7*n,n+=1,0===(128&r))break}return t}function re(e,t){let n=t;for(;;){let t=127&n;if(n>>=7,0==n){e.push(t);break}t|=128,e.push(t)}}function ie(e,t){if(!e)throw new Error(t||"Assertion failed")}class se{constructor(e,t){this.payer=void 0,this.keyMetaMap=void 0,this.payer=e,this.keyMetaMap=t}static compile(e,t){const n=new Map,r=e=>{const t=e.toBase58();let r=n.get(t);return void 0===r&&(r={isSigner:!1,isWritable:!1,isInvoked:!1},n.set(t,r)),r},i=r(t);i.isSigner=!0,i.isWritable=!0;for(const s of e){r(s.programId).isInvoked=!0;for(const e of s.keys){const t=r(e.pubkey);t.isSigner||=e.isSigner,t.isWritable||=e.isWritable}}return new se(t,n)}getMessageComponents(){const e=[...this.keyMetaMap.entries()];ie(e.length<=256,"Max static account keys length exceeded");const t=e.filter(([,e])=>e.isSigner&&e.isWritable),n=e.filter(([,e])=>e.isSigner&&!e.isWritable),r=e.filter(([,e])=>!e.isSigner&&e.isWritable),i=e.filter(([,e])=>!e.isSigner&&!e.isWritable),s={numRequiredSignatures:t.length+n.length,numReadonlySignedAccounts:n.length,numReadonlyUnsignedAccounts:i.length};{ie(t.length>0,"Expected at least one writable signer key");const[e]=t[0];ie(e===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}const o=[...t.map(([e])=>new Y(e)),...n.map(([e])=>new Y(e)),...r.map(([e])=>new Y(e)),...i.map(([e])=>new Y(e))];return[s,o]}extractTableLookup(e){const[t,n]=this.drainKeysFoundInLookupTable(e.state.addresses,e=>!e.isSigner&&!e.isInvoked&&e.isWritable),[r,i]=this.drainKeysFoundInLookupTable(e.state.addresses,e=>!e.isSigner&&!e.isInvoked&&!e.isWritable);if(0!==t.length||0!==r.length)return[{accountKey:e.key,writableIndexes:t,readonlyIndexes:r},{writable:n,readonly:i}]}drainKeysFoundInLookupTable(e,t){const n=new Array,r=new Array;for(const[i,s]of this.keyMetaMap.entries())if(t(s)){const t=new Y(i),s=e.findIndex(e=>e.equals(t));s>=0&&(ie(s<256,"Max lookup table index exceeded"),n.push(s),r.push(t),this.keyMetaMap.delete(i))}return[n,r]}}const oe="Reached end of buffer unexpectedly";function ae(e){if(0===e.length)throw new Error(oe);return e.shift()}function ce(e,...t){const[n]=t;if(2===t.length?n+(t[1]??0)>e.length:n>=e.length)throw new Error(oe);return e.splice(...t)}class ue{constructor(e){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=e.header,this.accountKeys=e.accountKeys.map(e=>new Y(e)),this.recentBlockhash=e.recentBlockhash,this.instructions=e.instructions,this.instructions.forEach(e=>this.indexToProgramIds.set(e.programIdIndex,this.accountKeys[e.programIdIndex]))}get version(){return"legacy"}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:c().decode(e.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new V(this.staticAccountKeys)}static compile(e){const t=se.compile(e.instructions,e.payerKey),[n,r]=t.getMessageComponents(),i=new V(r),s=i.compileInstructions(e.instructions).map(e=>({programIdIndex:e.programIdIndex,accounts:e.accountKeyIndexes,data:c().encode(e.data)}));return new ue({header:n,accountKeys:r,recentBlockhash:e.recentBlockhash,instructions:s})}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){const t=this.header.numRequiredSignatures;if(e>=this.header.numRequiredSignatures){const n=e-t,r=this.accountKeys.length-t,i=r-this.header.numReadonlyUnsignedAccounts;return n<i}{const n=t-this.header.numReadonlySignedAccounts;return e<n}}isProgramId(e){return this.indexToProgramIds.has(e)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter((e,t)=>!this.isProgramId(t))}serialize(){const e=this.accountKeys.length;let t=[];re(t,e);const n=this.instructions.map(e=>{const{accounts:t,programIdIndex:n}=e,i=Array.from(c().decode(e.data));let s=[];re(s,t.length);let o=[];return re(o,i.length),{programIdIndex:n,keyIndicesCount:r.Buffer.from(s),keyIndices:t,dataLength:r.Buffer.from(o),data:i}});let i=[];re(i,n.length);let s=r.Buffer.alloc(D);r.Buffer.from(i).copy(s);let o=i.length;n.forEach(e=>{const t=d.w3([d.u8("programIdIndex"),d.av(e.keyIndicesCount.length,"keyIndicesCount"),d.O6(d.u8("keyIndex"),e.keyIndices.length,"keyIndices"),d.av(e.dataLength.length,"dataLength"),d.O6(d.u8("userdatum"),e.data.length,"data")]),n=t.encode(e,s,o);o+=n}),s=s.slice(0,o);const a=d.w3([d.av(1,"numRequiredSignatures"),d.av(1,"numReadonlySignedAccounts"),d.av(1,"numReadonlyUnsignedAccounts"),d.av(t.length,"keyCount"),d.O6(J("key"),e,"keys"),J("recentBlockhash")]),u={numRequiredSignatures:r.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:r.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:r.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:r.Buffer.from(t),keys:this.accountKeys.map(e=>N(e.toBytes())),recentBlockhash:c().decode(this.recentBlockhash)};let l=r.Buffer.alloc(2048);const h=a.encode(u,l);return s.copy(l,h),l.slice(0,h+s.length)}static from(e){let t=[...e];const n=ae(t);if(n!==(n&M))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const i=ae(t),s=ae(t),o=ne(t);let a=[];for(let c=0;c<o;c++){const e=ce(t,0,R);a.push(new Y(r.Buffer.from(e)))}const u=ce(t,0,R),l=ne(t);let d=[];for(let p=0;p<l;p++){const e=ae(t),n=ne(t),i=ce(t,0,n),s=ne(t),o=ce(t,0,s),a=c().encode(r.Buffer.from(o));d.push({programIdIndex:e,accounts:i,data:a})}const h={header:{numRequiredSignatures:n,numReadonlySignedAccounts:i,numReadonlyUnsignedAccounts:s},recentBlockhash:c().encode(r.Buffer.from(u)),accountKeys:a,instructions:d};return new ue(h)}}class le{constructor(e){this.header=void 0,this.staticAccountKeys=void 0,this.recentBlockhash=void 0,this.compiledInstructions=void 0,this.addressTableLookups=void 0,this.header=e.header,this.staticAccountKeys=e.staticAccountKeys,this.recentBlockhash=e.recentBlockhash,this.compiledInstructions=e.compiledInstructions,this.addressTableLookups=e.addressTableLookups}get version(){return 0}get numAccountKeysFromLookups(){let e=0;for(const t of this.addressTableLookups)e+=t.readonlyIndexes.length+t.writableIndexes.length;return e}getAccountKeys(e){let t;if(e&&"accountKeysFromLookups"in e&&e.accountKeysFromLookups){if(this.numAccountKeysFromLookups!=e.accountKeysFromLookups.writable.length+e.accountKeysFromLookups.readonly.length)throw new Error("Failed to get account keys because of a mismatch in the number of account keys from lookups");t=e.accountKeysFromLookups}else if(e&&"addressLookupTableAccounts"in e&&e.addressLookupTableAccounts)t=this.resolveAddressTableLookups(e.addressLookupTableAccounts);else if(this.addressTableLookups.length>0)throw new Error("Failed to get account keys because address table lookups were not resolved");return new V(this.staticAccountKeys,t)}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){const t=this.header.numRequiredSignatures,n=this.staticAccountKeys.length;if(e>=n){const t=e-n,r=this.addressTableLookups.reduce((e,t)=>e+t.writableIndexes.length,0);return t<r}if(e>=this.header.numRequiredSignatures){const r=e-t,i=n-t,s=i-this.header.numReadonlyUnsignedAccounts;return r<s}{const n=t-this.header.numReadonlySignedAccounts;return e<n}}resolveAddressTableLookups(e){const t={writable:[],readonly:[]};for(const n of this.addressTableLookups){const r=e.find(e=>e.key.equals(n.accountKey));if(!r)throw new Error(`Failed to find address lookup table account for table key ${n.accountKey.toBase58()}`);for(const e of n.writableIndexes){if(!(e<r.state.addresses.length))throw new Error(`Failed to find address for index ${e} in address lookup table ${n.accountKey.toBase58()}`);t.writable.push(r.state.addresses[e])}for(const e of n.readonlyIndexes){if(!(e<r.state.addresses.length))throw new Error(`Failed to find address for index ${e} in address lookup table ${n.accountKey.toBase58()}`);t.readonly.push(r.state.addresses[e])}}return t}static compile(e){const t=se.compile(e.instructions,e.payerKey),n=new Array,r={writable:new Array,readonly:new Array},i=e.addressLookupTableAccounts||[];for(const u of i){const e=t.extractTableLookup(u);if(void 0!==e){const[t,{writable:i,readonly:s}]=e;n.push(t),r.writable.push(...i),r.readonly.push(...s)}}const[s,o]=t.getMessageComponents(),a=new V(o,r),c=a.compileInstructions(e.instructions);return new le({header:s,staticAccountKeys:o,recentBlockhash:e.recentBlockhash,compiledInstructions:c,addressTableLookups:n})}serialize(){const e=Array();re(e,this.staticAccountKeys.length);const t=this.serializeInstructions(),n=Array();re(n,this.compiledInstructions.length);const r=this.serializeAddressTableLookups(),i=Array();re(i,this.addressTableLookups.length);const s=d.w3([d.u8("prefix"),d.w3([d.u8("numRequiredSignatures"),d.u8("numReadonlySignedAccounts"),d.u8("numReadonlyUnsignedAccounts")],"header"),d.av(e.length,"staticAccountKeysLength"),d.O6(J(),this.staticAccountKeys.length,"staticAccountKeys"),J("recentBlockhash"),d.av(n.length,"instructionsLength"),d.av(t.length,"serializedInstructions"),d.av(i.length,"addressTableLookupsLength"),d.av(r.length,"serializedAddressTableLookups")]),o=new Uint8Array(D),a=128,u=s.encode({prefix:a,header:this.header,staticAccountKeysLength:new Uint8Array(e),staticAccountKeys:this.staticAccountKeys.map(e=>e.toBytes()),recentBlockhash:c().decode(this.recentBlockhash),instructionsLength:new Uint8Array(n),serializedInstructions:t,addressTableLookupsLength:new Uint8Array(i),serializedAddressTableLookups:r},o);return o.slice(0,u)}serializeInstructions(){let e=0;const t=new Uint8Array(D);for(const n of this.compiledInstructions){const r=Array();re(r,n.accountKeyIndexes.length);const i=Array();re(i,n.data.length);const s=d.w3([d.u8("programIdIndex"),d.av(r.length,"encodedAccountKeyIndexesLength"),d.O6(d.u8(),n.accountKeyIndexes.length,"accountKeyIndexes"),d.av(i.length,"encodedDataLength"),d.av(n.data.length,"data")]);e+=s.encode({programIdIndex:n.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(r),accountKeyIndexes:n.accountKeyIndexes,encodedDataLength:new Uint8Array(i),data:n.data},t,e)}return t.slice(0,e)}serializeAddressTableLookups(){let e=0;const t=new Uint8Array(D);for(const n of this.addressTableLookups){const r=Array();re(r,n.writableIndexes.length);const i=Array();re(i,n.readonlyIndexes.length);const s=d.w3([J("accountKey"),d.av(r.length,"encodedWritableIndexesLength"),d.O6(d.u8(),n.writableIndexes.length,"writableIndexes"),d.av(i.length,"encodedReadonlyIndexesLength"),d.O6(d.u8(),n.readonlyIndexes.length,"readonlyIndexes")]);e+=s.encode({accountKey:n.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(r),writableIndexes:n.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(i),readonlyIndexes:n.readonlyIndexes},t,e)}return t.slice(0,e)}static deserialize(e){let t=[...e];const n=ae(t),r=n&M;ie(n!==r,"Expected versioned message but received legacy message");const i=r;ie(0===i,`Expected versioned message with version 0 but found version ${i}`);const s={numRequiredSignatures:ae(t),numReadonlySignedAccounts:ae(t),numReadonlyUnsignedAccounts:ae(t)},o=[],a=ne(t);for(let c=0;c<a;c++)o.push(new Y(ce(t,0,R)));const u=c().encode(ce(t,0,R)),l=ne(t),d=[];for(let c=0;c<l;c++){const e=ae(t),n=ne(t),r=ce(t,0,n),i=ne(t),s=new Uint8Array(ce(t,0,i));d.push({programIdIndex:e,accountKeyIndexes:r,data:s})}const h=ne(t),p=[];for(let c=0;c<h;c++){const e=new Y(ce(t,0,R)),n=ne(t),r=ce(t,0,n),i=ne(t),s=ce(t,0,i);p.push({accountKey:e,writableIndexes:r,readonlyIndexes:s})}return new le({header:s,staticAccountKeys:o,recentBlockhash:u,compiledInstructions:d,addressTableLookups:p})}}let de=function(e){return e[e["BLOCKHEIGHT_EXCEEDED"]=0]="BLOCKHEIGHT_EXCEEDED",e[e["PROCESSED"]=1]="PROCESSED",e[e["TIMED_OUT"]=2]="TIMED_OUT",e[e["NONCE_INVALID"]=3]="NONCE_INVALID",e}({});const he=r.Buffer.alloc(H).fill(0);class pe{constructor(e){this.keys=void 0,this.programId=void 0,this.data=r.Buffer.alloc(0),this.programId=e.programId,this.keys=e.keys,e.data&&(this.data=e.data)}toJSON(){return{keys:this.keys.map(({pubkey:e,isSigner:t,isWritable:n})=>({pubkey:e.toJSON(),isSigner:t,isWritable:n})),programId:this.programId.toJSON(),data:[...this.data]}}}class ge{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(e){if(this.signatures=[],this.feePayer=void 0,this.instructions=[],this.recentBlockhash=void 0,this.lastValidBlockHeight=void 0,this.nonceInfo=void 0,this.minNonceContextSlot=void 0,this._message=void 0,this._json=void 0,e)if(e.feePayer&&(this.feePayer=e.feePayer),e.signatures&&(this.signatures=e.signatures),Object.prototype.hasOwnProperty.call(e,"nonceInfo")){const{minContextSlot:t,nonceInfo:n}=e;this.minNonceContextSlot=t,this.nonceInfo=n}else if(Object.prototype.hasOwnProperty.call(e,"lastValidBlockHeight")){const{blockhash:t,lastValidBlockHeight:n}=e;this.recentBlockhash=t,this.lastValidBlockHeight=n}else{const{recentBlockhash:t,nonceInfo:n}=e;n&&(this.nonceInfo=n),this.recentBlockhash=t}}toJSON(){return{recentBlockhash:this.recentBlockhash||null,feePayer:this.feePayer?this.feePayer.toJSON():null,nonceInfo:this.nonceInfo?{nonce:this.nonceInfo.nonce,nonceInstruction:this.nonceInfo.nonceInstruction.toJSON()}:null,instructions:this.instructions.map(e=>e.toJSON()),signers:this.signatures.map(({publicKey:e})=>e.toJSON())}}add(...e){if(0===e.length)throw new Error("No instructions");return e.forEach(e=>{"instructions"in e?this.instructions=this.instructions.concat(e.instructions):"data"in e&&"programId"in e&&"keys"in e?this.instructions.push(e):this.instructions.push(new pe(e))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let e,t,n;if(this.nonceInfo?(e=this.nonceInfo.nonce,t=this.instructions[0]!=this.nonceInfo.nonceInstruction?[this.nonceInfo.nonceInstruction,...this.instructions]:this.instructions):(e=this.recentBlockhash,t=this.instructions),!e)throw new Error("Transaction recentBlockhash required");if(t.length<1&&console.warn("No instructions provided"),this.feePayer)n=this.feePayer;else{if(!(this.signatures.length>0&&this.signatures[0].publicKey))throw new Error("Transaction fee payer required");n=this.signatures[0].publicKey}for(let c=0;c<t.length;c++)if(void 0===t[c].programId)throw new Error(`Transaction instruction index ${c} has undefined program id`);const r=[],i=[];t.forEach(e=>{e.keys.forEach(e=>{i.push({...e})});const t=e.programId.toString();r.includes(t)||r.push(t)}),r.forEach(e=>{i.push({pubkey:new Y(e),isSigner:!1,isWritable:!1})});const s=[];i.forEach(e=>{const t=e.pubkey.toString(),n=s.findIndex(e=>e.pubkey.toString()===t);n>-1?(s[n].isWritable=s[n].isWritable||e.isWritable,s[n].isSigner=s[n].isSigner||e.isSigner):s.push(e)}),s.sort(function(e,t){if(e.isSigner!==t.isSigner)return e.isSigner?-1:1;if(e.isWritable!==t.isWritable)return e.isWritable?-1:1;const n={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return e.pubkey.toBase58().localeCompare(t.pubkey.toBase58(),"en",n)});const o=s.findIndex(e=>e.pubkey.equals(n));if(o>-1){const[e]=s.splice(o,1);e.isSigner=!0,e.isWritable=!0,s.unshift(e)}else s.unshift({pubkey:n,isSigner:!0,isWritable:!0});for(const c of this.signatures){const e=s.findIndex(e=>e.pubkey.equals(c.publicKey));if(!(e>-1))throw new Error(`unknown signer: ${c.publicKey.toString()}`);s[e].isSigner||(s[e].isSigner=!0,console.warn("Transaction references a signature that is unnecessary, only the fee payer and instruction signer accounts should sign a transaction. This behavior is deprecated and will throw an error in the next major version release."))}let a=0,u=0,l=0;const d=[],h=[];s.forEach(({pubkey:e,isSigner:t,isWritable:n})=>{t?(d.push(e.toString()),a+=1,n||(u+=1)):(h.push(e.toString()),n||(l+=1))});const p=d.concat(h),g=t.map(e=>{const{data:t,programId:n}=e;return{programIdIndex:p.indexOf(n.toString()),accounts:e.keys.map(e=>p.indexOf(e.pubkey.toString())),data:c().encode(t)}});return g.forEach(e=>{ie(e.programIdIndex>=0),e.accounts.forEach(e=>ie(e>=0))}),new ue({header:{numRequiredSignatures:a,numReadonlySignedAccounts:u,numReadonlyUnsignedAccounts:l},accountKeys:p,recentBlockhash:e,instructions:g})}_compile(){const e=this.compileMessage(),t=e.accountKeys.slice(0,e.header.numRequiredSignatures);if(this.signatures.length===t.length){const n=this.signatures.every((e,n)=>t[n].equals(e.publicKey));if(n)return e}return this.signatures=t.map(e=>({signature:null,publicKey:e})),e}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(e){return(await e.getFeeForMessage(this.compileMessage())).value}setSigners(...e){if(0===e.length)throw new Error("No signers");const t=new Set;this.signatures=e.filter(e=>{const n=e.toString();return!t.has(n)&&(t.add(n),!0)}).map(e=>({signature:null,publicKey:e}))}sign(...e){if(0===e.length)throw new Error("No signers");const t=new Set,n=[];for(const i of e){const e=i.publicKey.toString();t.has(e)||(t.add(e),n.push(i))}this.signatures=n.map(e=>({signature:null,publicKey:e.publicKey}));const r=this._compile();this._partialSign(r,...n)}partialSign(...e){if(0===e.length)throw new Error("No signers");const t=new Set,n=[];for(const i of e){const e=i.publicKey.toString();t.has(e)||(t.add(e),n.push(i))}const r=this._compile();this._partialSign(r,...n)}_partialSign(e,...t){const n=e.serialize();t.forEach(e=>{const t=T(n,e.secretKey);this._addSignature(e.publicKey,N(t))})}addSignature(e,t){this._compile(),this._addSignature(e,t)}_addSignature(e,t){ie(64===t.length);const n=this.signatures.findIndex(t=>e.equals(t.publicKey));if(n<0)throw new Error(`unknown signer: ${e.toString()}`);this.signatures[n].signature=r.Buffer.from(t)}verifySignatures(e=!0){const t=this._getMessageSignednessErrors(this.serializeMessage(),e);return!t}_getMessageSignednessErrors(e,t){const n={};for(const{signature:r,publicKey:i}of this.signatures)null===r?t&&(n.missing||=[]).push(i):C(r,e,i.toBytes())||(n.invalid||=[]).push(i);return n.invalid||n.missing?n:void 0}serialize(e){const{requireAllSignatures:t,verifySignatures:n}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},e),r=this.serializeMessage();if(n){const e=this._getMessageSignednessErrors(r,t);if(e){let t="Signature verification failed.";throw e.invalid&&(t+=`\nInvalid signature for public key${1===e.invalid.length?"":"(s)"} [\`${e.invalid.map(e=>e.toBase58()).join("`, `")}\`].`),e.missing&&(t+=`\nMissing signature for public key${1===e.missing.length?"":"(s)"} [\`${e.missing.map(e=>e.toBase58()).join("`, `")}\`].`),new Error(t)}}return this._serialize(r)}_serialize(e){const{signatures:t}=this,n=[];re(n,t.length);const i=n.length+64*t.length+e.length,s=r.Buffer.alloc(i);return ie(t.length<256),r.Buffer.from(n).copy(s,0),t.forEach(({signature:e},t)=>{null!==e&&(ie(64===e.length,"signature has invalid length"),r.Buffer.from(e).copy(s,n.length+64*t))}),e.copy(s,n.length+64*t.length),ie(s.length<=D,`Transaction too large: ${s.length} > ${D}`),s}get keys(){return ie(1===this.instructions.length),this.instructions[0].keys.map(e=>e.pubkey)}get programId(){return ie(1===this.instructions.length),this.instructions[0].programId}get data(){return ie(1===this.instructions.length),this.instructions[0].data}static from(e){let t=[...e];const n=ne(t);let i=[];for(let s=0;s<n;s++){const e=ce(t,0,H);i.push(c().encode(r.Buffer.from(e)))}return ge.populate(ue.from(t),i)}static populate(e,t=[]){const n=new ge;return n.recentBlockhash=e.recentBlockhash,e.header.numRequiredSignatures>0&&(n.feePayer=e.accountKeys[0]),t.forEach((t,r)=>{const i={signature:t==c().encode(he)?null:c().decode(t),publicKey:e.accountKeys[r]};n.signatures.push(i)}),e.instructions.forEach(t=>{const r=t.accounts.map(t=>{const r=e.accountKeys[t];return{pubkey:r,isSigner:n.signatures.some(e=>e.publicKey.toString()===r.toString())||e.isAccountSigner(t),isWritable:e.isAccountWritable(t)}});n.instructions.push(new pe({keys:r,programId:e.accountKeys[t.programIdIndex],data:c().decode(t.data)}))}),n._message=e,n._json=n.toJSON(),n}}const fe=160,me=64,ye=fe/me,be=1e3/ye,we=new Y("SysvarC1ock11111111111111111111111111111111"),ke=(new Y("SysvarEpochSchedu1e111111111111111111111111"),new Y("Sysvar1nstructions1111111111111111111111111"),new Y("SysvarRecentB1ockHashes11111111111111111111")),Se=new Y("SysvarRent111111111111111111111111111111111"),ve=(new Y("SysvarRewards111111111111111111111111111111"),new Y("SysvarS1otHashes111111111111111111111111111"),new Y("SysvarS1otHistory11111111111111111111111111"),new Y("SysvarStakeHistory1111111111111111111111111"));class Ie extends Error{constructor({action:e,signature:t,transactionMessage:n,logs:r}){const i=r?`Logs: \n${JSON.stringify(r.slice(-10),null,2)}. `:"",s="\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.";let o;switch(e){case"send":o=`Transaction ${t} resulted in an error. \n${n}. `+i+s;break;case"simulate":o=`Simulation failed. \nMessage: ${n}. \n`+i+s;break;default:o=`Unknown action '${(e=>e)(e)}'`}super(o),this.signature=void 0,this.transactionMessage=void 0,this.transactionLogs=void 0,this.signature=t,this.transactionMessage=n,this.transactionLogs=r||void 0}get transactionError(){return{message:this.transactionMessage,logs:Array.isArray(this.transactionLogs)?this.transactionLogs:void 0}}get logs(){const e=this.transactionLogs;if(null==e||"object"!==typeof e||!("then"in e))return e}async getLogs(e){return Array.isArray(this.transactionLogs)||(this.transactionLogs=new Promise((t,n)=>{e.getTransaction(this.signature).then(e=>{if(e&&e.meta&&e.meta.logMessages){const n=e.meta.logMessages;this.transactionLogs=n,t(n)}else n(new Error("Log messages not found"))}).catch(n)})),await this.transactionLogs}}class Ae extends Error{constructor({code:e,message:t,data:n},r){super(null!=r?`${r}: ${t}`:t),this.code=void 0,this.data=void 0,this.code=e,this.data=n,this.name="SolanaJSONRPCError"}}async function xe(e,t,n,r){const i=r&&{skipPreflight:r.skipPreflight,preflightCommitment:r.preflightCommitment||r.commitment,maxRetries:r.maxRetries,minContextSlot:r.minContextSlot},s=await e.sendTransaction(t,n,i);let o;if(null!=t.recentBlockhash&&null!=t.lastValidBlockHeight)o=(await e.confirmTransaction({abortSignal:r?.abortSignal,signature:s,blockhash:t.recentBlockhash,lastValidBlockHeight:t.lastValidBlockHeight},r&&r.commitment)).value;else if(null!=t.minNonceContextSlot&&null!=t.nonceInfo){const{nonceInstruction:n}=t.nonceInfo,i=n.keys[0].pubkey;o=(await e.confirmTransaction({abortSignal:r?.abortSignal,minContextSlot:t.minNonceContextSlot,nonceAccountPubkey:i,nonceValue:t.nonceInfo.nonce,signature:s},r&&r.commitment)).value}else null!=r?.abortSignal&&console.warn("sendAndConfirmTransaction(): A transaction with a deprecated confirmation strategy was supplied along with an `abortSignal`. Only transactions having `lastValidBlockHeight` or a combination of `nonceInfo` and `minNonceContextSlot` are abortable."),o=(await e.confirmTransaction(s,r&&r.commitment)).value;if(o.err){if(null!=s)throw new Ie({action:"send",signature:s,transactionMessage:`Status: (${JSON.stringify(o)})`});throw new Error(`Transaction ${s} failed (${JSON.stringify(o)})`)}return s}function _e(e){return new Promise(t=>setTimeout(t,e))}function Be(e,t){const n=e.layout.span>=0?e.layout.span:te(e,t),i=r.Buffer.alloc(n),s=Object.assign({instruction:e.index},t);return e.layout.encode(s,i),i}const Ee=d.I0("lamportsPerSignature"),We=d.w3([d.DH("version"),d.DH("state"),J("authorizedPubkey"),J("nonce"),d.w3([Ee],"feeCalculator")]),Pe=We.span;class Te{constructor(e){this.authorizedPubkey=void 0,this.nonce=void 0,this.feeCalculator=void 0,this.authorizedPubkey=e.authorizedPubkey,this.nonce=e.nonce,this.feeCalculator=e.feeCalculator}static fromAccountData(e){const t=We.decode(N(e),0);return new Te({authorizedPubkey:new Y(t.authorizedPubkey),nonce:new Y(t.nonce).toString(),feeCalculator:t.feeCalculator})}}function Ce(e){const t=(0,d.av)(8,e),n=t.decode.bind(t),r=t.encode.bind(t),i=t,s=S();return i.decode=(e,t)=>{const r=n(e,t);return s.decode(r)},i.encode=(e,t,n)=>{const i=s.encode(e);return r(i,t,n)},i}const Ne=Object.freeze({Create:{index:0,layout:d.w3([d.DH("instruction"),d.Wg("lamports"),d.Wg("space"),J("programId")])},Assign:{index:1,layout:d.w3([d.DH("instruction"),J("programId")])},Transfer:{index:2,layout:d.w3([d.DH("instruction"),Ce("lamports")])},CreateWithSeed:{index:3,layout:d.w3([d.DH("instruction"),J("base"),G("seed"),d.Wg("lamports"),d.Wg("space"),J("programId")])},AdvanceNonceAccount:{index:4,layout:d.w3([d.DH("instruction")])},WithdrawNonceAccount:{index:5,layout:d.w3([d.DH("instruction"),d.Wg("lamports")])},InitializeNonceAccount:{index:6,layout:d.w3([d.DH("instruction"),J("authorized")])},AuthorizeNonceAccount:{index:7,layout:d.w3([d.DH("instruction"),J("authorized")])},Allocate:{index:8,layout:d.w3([d.DH("instruction"),d.Wg("space")])},AllocateWithSeed:{index:9,layout:d.w3([d.DH("instruction"),J("base"),G("seed"),d.Wg("space"),J("programId")])},AssignWithSeed:{index:10,layout:d.w3([d.DH("instruction"),J("base"),G("seed"),J("programId")])},TransferWithSeed:{index:11,layout:d.w3([d.DH("instruction"),Ce("lamports"),G("seed"),J("programId")])},UpgradeNonceAccount:{index:12,layout:d.w3([d.DH("instruction")])}});class Oe{constructor(){}static createAccount(e){const t=Ne.Create,n=Be(t,{lamports:e.lamports,space:e.space,programId:N(e.programId.toBuffer())});return new pe({keys:[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:n})}static transfer(e){let t,n;if("basePubkey"in e){const r=Ne.TransferWithSeed;t=Be(r,{lamports:BigInt(e.lamports),seed:e.seed,programId:N(e.programId.toBuffer())}),n=[{pubkey:e.fromPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}else{const r=Ne.Transfer;t=Be(r,{lamports:BigInt(e.lamports)}),n=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}return new pe({keys:n,programId:this.programId,data:t})}static assign(e){let t,n;if("basePubkey"in e){const r=Ne.AssignWithSeed;t=Be(r,{base:N(e.basePubkey.toBuffer()),seed:e.seed,programId:N(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{const r=Ne.Assign;t=Be(r,{programId:N(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new pe({keys:n,programId:this.programId,data:t})}static createAccountWithSeed(e){const t=Ne.CreateWithSeed,n=Be(t,{base:N(e.basePubkey.toBuffer()),seed:e.seed,lamports:e.lamports,space:e.space,programId:N(e.programId.toBuffer())});let r=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!1,isWritable:!0}];return e.basePubkey.equals(e.fromPubkey)||r.push({pubkey:e.basePubkey,isSigner:!0,isWritable:!1}),new pe({keys:r,programId:this.programId,data:n})}static createNonceAccount(e){const t=new ge;"basePubkey"in e&&"seed"in e?t.add(Oe.createAccountWithSeed({fromPubkey:e.fromPubkey,newAccountPubkey:e.noncePubkey,basePubkey:e.basePubkey,seed:e.seed,lamports:e.lamports,space:Pe,programId:this.programId})):t.add(Oe.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.noncePubkey,lamports:e.lamports,space:Pe,programId:this.programId}));const n={noncePubkey:e.noncePubkey,authorizedPubkey:e.authorizedPubkey};return t.add(this.nonceInitialize(n)),t}static nonceInitialize(e){const t=Ne.InitializeNonceAccount,n=Be(t,{authorized:N(e.authorizedPubkey.toBuffer())}),r={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:ke,isSigner:!1,isWritable:!1},{pubkey:Se,isSigner:!1,isWritable:!1}],programId:this.programId,data:n};return new pe(r)}static nonceAdvance(e){const t=Ne.AdvanceNonceAccount,n=Be(t),r={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:ke,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n};return new pe(r)}static nonceWithdraw(e){const t=Ne.WithdrawNonceAccount,n=Be(t,{lamports:e.lamports});return new pe({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0},{pubkey:ke,isSigner:!1,isWritable:!1},{pubkey:Se,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static nonceAuthorize(e){const t=Ne.AuthorizeNonceAccount,n=Be(t,{authorized:N(e.newAuthorizedPubkey.toBuffer())});return new pe({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static allocate(e){let t,n;if("basePubkey"in e){const r=Ne.AllocateWithSeed;t=Be(r,{base:N(e.basePubkey.toBuffer()),seed:e.seed,space:e.space,programId:N(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{const r=Ne.Allocate;t=Be(r,{space:e.space}),n=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new pe({keys:n,programId:this.programId,data:t})}}Oe.programId=new Y("11111111111111111111111111111111");const ze=D-300;class Le{constructor(){}static getMinNumSignatures(e){return 2*(Math.ceil(e/Le.chunkSize)+1+1)}static async load(e,t,n,i,s){{const r=await e.getMinimumBalanceForRentExemption(s.length),o=await e.getAccountInfo(n.publicKey,"confirmed");let a=null;if(null!==o){if(o.executable)return console.error("Program load failed, account is already executable"),!1;o.data.length!==s.length&&(a=a||new ge,a.add(Oe.allocate({accountPubkey:n.publicKey,space:s.length}))),o.owner.equals(i)||(a=a||new ge,a.add(Oe.assign({accountPubkey:n.publicKey,programId:i}))),o.lamports<r&&(a=a||new ge,a.add(Oe.transfer({fromPubkey:t.publicKey,toPubkey:n.publicKey,lamports:r-o.lamports})))}else a=(new ge).add(Oe.createAccount({fromPubkey:t.publicKey,newAccountPubkey:n.publicKey,lamports:r>0?r:1,space:s.length,programId:i}));null!==a&&await xe(e,a,[t,n],{commitment:"confirmed"})}const o=d.w3([d.DH("instruction"),d.DH("offset"),d.DH("bytesLength"),d.DH("bytesLengthPadding"),d.O6(d.u8("byte"),d.cY(d.DH(),-8),"bytes")]),a=Le.chunkSize;let c=0,u=s,l=[];while(u.length>0){const s=u.slice(0,a),d=r.Buffer.alloc(a+16);o.encode({instruction:0,offset:c,bytes:s,bytesLength:0,bytesLengthPadding:0},d);const h=(new ge).add({keys:[{pubkey:n.publicKey,isSigner:!0,isWritable:!0}],programId:i,data:d});if(l.push(xe(e,h,[t,n],{commitment:"confirmed"})),e._rpcEndpoint.includes("solana.com")){const e=4;await _e(1e3/e)}c+=a,u=u.slice(a)}await Promise.all(l);{const s=d.w3([d.DH("instruction")]),o=r.Buffer.alloc(s.span);s.encode({instruction:1},o);const a=(new ge).add({keys:[{pubkey:n.publicKey,isSigner:!0,isWritable:!0},{pubkey:Se,isSigner:!1,isWritable:!1}],programId:i,data:o}),c="processed",u=await e.sendTransaction(a,[t,n],{preflightCommitment:c}),{context:l,value:h}=await e.confirmTransaction({signature:u,lastValidBlockHeight:a.lastValidBlockHeight,blockhash:a.recentBlockhash},c);if(h.err)throw new Error(`Transaction ${u} failed (${JSON.stringify(h)})`);while(1){try{const t=await e.getSlot({commitment:c});if(t>l.slot)break}catch{}await new Promise(e=>setTimeout(e,Math.round(be/2)))}}return!0}}Le.chunkSize=ze;new Y("BPFLoader2111111111111111111111111111111111");function Ke(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e["default"]:e}var Re,je;function qe(){if(je)return Re;je=1;var e=Object.prototype.toString,t=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};function n(r,i){var s,o,a,c,u,l,d;if(!0===r)return"true";if(!1===r)return"false";switch(typeof r){case"object":if(null===r)return null;if(r.toJSON&&"function"===typeof r.toJSON)return n(r.toJSON(),i);if(d=e.call(r),"[object Array]"===d){for(a="[",o=r.length-1,s=0;s<o;s++)a+=n(r[s],!0)+",";return o>-1&&(a+=n(r[s],!0)),a+"]"}if("[object Object]"===d){c=t(r).sort(),o=c.length,a="",s=0;while(s<o)u=c[s],l=n(r[u],!1),void 0!==l&&(a&&(a+=","),a+=JSON.stringify(u)+":"+l),s++;return"{"+a+"}"}return JSON.stringify(r);case"function":case"undefined":return i?null:void 0;case"string":return JSON.stringify(r);default:return isFinite(r)?r:null}}return Re=function(e){var t=n(e,!1);if(void 0!==t)return""+t},Re}var Ye=qe(),De=Ke(Ye);const Me=32;function He(e){let t=0;while(e>1)e/=2,t++;return t}function Ue(e){return 0===e?1:(e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e|=e>>32,e+1)}class $e{constructor(e,t,n,r,i){this.slotsPerEpoch=void 0,this.leaderScheduleSlotOffset=void 0,this.warmup=void 0,this.firstNormalEpoch=void 0,this.firstNormalSlot=void 0,this.slotsPerEpoch=e,this.leaderScheduleSlotOffset=t,this.warmup=n,this.firstNormalEpoch=r,this.firstNormalSlot=i}getEpoch(e){return this.getEpochAndSlotIndex(e)[0]}getEpochAndSlotIndex(e){if(e<this.firstNormalSlot){const t=He(Ue(e+Me+1))-He(Me)-1,n=this.getSlotsInEpoch(t),r=e-(n-Me);return[t,r]}{const t=e-this.firstNormalSlot,n=Math.floor(t/this.slotsPerEpoch),r=this.firstNormalEpoch+n,i=t%this.slotsPerEpoch;return[r,i]}}getFirstSlotInEpoch(e){return e<=this.firstNormalEpoch?(Math.pow(2,e)-1)*Me:(e-this.firstNormalEpoch)*this.slotsPerEpoch+this.firstNormalSlot}getLastSlotInEpoch(e){return this.getFirstSlotInEpoch(e)+this.getSlotsInEpoch(e)-1}getSlotsInEpoch(e){return e<this.firstNormalEpoch?Math.pow(2,e+He(Me)):this.slotsPerEpoch}}var Fe=globalThis.fetch;class Ve extends x.vE{constructor(e,t,n){const r=e=>{const n=(0,x.kb)(e,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...t});return this.underlyingSocket="socket"in n?n.socket:n,n};super(r,e,t,n),this.underlyingSocket=void 0}call(...e){const t=this.underlyingSocket?.readyState;return 1===t?super.call(...e):Promise.reject(new Error("Tried to call a JSON-RPC method `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+")"))}notify(...e){const t=this.underlyingSocket?.readyState;return 1===t?super.notify(...e):Promise.reject(new Error("Tried to send a JSON-RPC notification `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+")"))}}function Je(e,t){let n;try{n=e.layout.decode(t)}catch(r){throw new Error("invalid instruction; "+r)}if(n.typeIndex!==e.index)throw new Error(`invalid account data; account type mismatch ${n.typeIndex} != ${e.index}`);return n}const Ge=56;class Xe{constructor(e){this.key=void 0,this.state=void 0,this.key=e.key,this.state=e.state}isActive(){const e=BigInt("0xffffffffffffffff");return this.state.deactivationSlot===e}static deserialize(e){const t=Je(Ze,e),n=e.length-Ge;ie(n>=0,"lookup table is invalid"),ie(n%32===0,"lookup table is invalid");const r=n/32,{addresses:i}=d.w3([d.O6(J(),r,"addresses")]).decode(e.slice(Ge));return{deactivationSlot:t.deactivationSlot,lastExtendedSlot:t.lastExtendedSlot,lastExtendedSlotStartIndex:t.lastExtendedStartIndex,authority:0!==t.authority.length?new Y(t.authority[0]):void 0,addresses:i.map(e=>new Y(e))}}}const Ze={index:1,layout:d.w3([d.DH("typeIndex"),Ce("deactivationSlot"),d.I0("lastExtendedSlot"),d.u8("lastExtendedStartIndex"),d.u8(),d.O6(J(),d.cY(d.u8(),-1),"authority")])},Qe=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;function et(e){const t=e.match(Qe);if(null==t)throw TypeError(`Failed to validate endpoint URL \`${e}\``);const[n,r,i,s]=t,o=e.startsWith("https:")?"wss:":"ws:",a=null==i?null:parseInt(i.slice(1),10),c=null==a?"":`:${a+1}`;return`${o}//${r}${c}${s}`}const tt=(0,v.au)((0,v.KJ)(Y),(0,v.Yj)(),e=>new Y(e)),nt=(0,v.PV)([(0,v.Yj)(),(0,v.eu)("base64")]),rt=(0,v.au)((0,v.KJ)(r.Buffer),nt,e=>r.Buffer.from(e[0],"base64")),it=3e4;function st(e){if(!1===/^https?:/.test(e))throw new TypeError("Endpoint URL must start with `http:` or `https:`.");return e}function ot(e){let t,n;if("string"===typeof e)t=e;else if(e){const{commitment:r,...i}=e;t=r,n=i}return{commitment:t,config:n}}function at(e){return e.map(e=>"memcmp"in e?{...e,memcmp:{...e.memcmp,encoding:e.memcmp.encoding??"base58"}}:e)}function ct(e){return(0,v.KC)([(0,v.NW)({jsonrpc:(0,v.eu)("2.0"),id:(0,v.Yj)(),result:e}),(0,v.NW)({jsonrpc:(0,v.eu)("2.0"),id:(0,v.Yj)(),error:(0,v.NW)({code:(0,v.L5)(),message:(0,v.Yj)(),data:(0,v.lq)((0,v.bz)())})})])}const ut=ct((0,v.L5)());function lt(e){return(0,v.au)(ct(e),ut,t=>"error"in t?t:{...t,result:(0,v.vt)(t.result,e)})}function dt(e){return lt((0,v.NW)({context:(0,v.NW)({slot:(0,v.ai)()}),value:e}))}function ht(e){return(0,v.NW)({context:(0,v.NW)({slot:(0,v.ai)()}),value:e})}function pt(e,t){return 0===e?new le({header:t.header,staticAccountKeys:t.accountKeys.map(e=>new Y(e)),recentBlockhash:t.recentBlockhash,compiledInstructions:t.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:c().decode(e.data)})),addressTableLookups:t.addressTableLookups}):new ue(t)}const gt=(0,v.NW)({foundation:(0,v.ai)(),foundationTerm:(0,v.ai)(),initial:(0,v.ai)(),taper:(0,v.ai)(),terminal:(0,v.ai)()}),ft=lt((0,v.YO)((0,v.me)((0,v.NW)({epoch:(0,v.ai)(),effectiveSlot:(0,v.ai)(),amount:(0,v.ai)(),postBalance:(0,v.ai)(),commission:(0,v.lq)((0,v.me)((0,v.ai)()))})))),mt=(0,v.YO)((0,v.NW)({slot:(0,v.ai)(),prioritizationFee:(0,v.ai)()})),yt=(0,v.NW)({total:(0,v.ai)(),validator:(0,v.ai)(),foundation:(0,v.ai)(),epoch:(0,v.ai)()}),bt=(0,v.NW)({epoch:(0,v.ai)(),slotIndex:(0,v.ai)(),slotsInEpoch:(0,v.ai)(),absoluteSlot:(0,v.ai)(),blockHeight:(0,v.lq)((0,v.ai)()),transactionCount:(0,v.lq)((0,v.ai)())}),wt=(0,v.NW)({slotsPerEpoch:(0,v.ai)(),leaderScheduleSlotOffset:(0,v.ai)(),warmup:(0,v.zM)(),firstNormalEpoch:(0,v.ai)(),firstNormalSlot:(0,v.ai)()}),kt=(0,v.g1)((0,v.Yj)(),(0,v.YO)((0,v.ai)())),St=(0,v.me)((0,v.KC)([(0,v.NW)({}),(0,v.Yj)()])),vt=(0,v.NW)({err:St}),It=(0,v.eu)("receivedSignature"),At=(0,v.NW)({"solana-core":(0,v.Yj)(),"feature-set":(0,v.lq)((0,v.ai)())}),xt=(0,v.NW)({program:(0,v.Yj)(),programId:tt,parsed:(0,v.L5)()}),_t=(0,v.NW)({programId:tt,accounts:(0,v.YO)(tt),data:(0,v.Yj)()}),Bt=dt((0,v.NW)({err:(0,v.me)((0,v.KC)([(0,v.NW)({}),(0,v.Yj)()])),logs:(0,v.me)((0,v.YO)((0,v.Yj)())),accounts:(0,v.lq)((0,v.me)((0,v.YO)((0,v.me)((0,v.NW)({executable:(0,v.zM)(),owner:(0,v.Yj)(),lamports:(0,v.ai)(),data:(0,v.YO)((0,v.Yj)()),rentEpoch:(0,v.lq)((0,v.ai)())}))))),unitsConsumed:(0,v.lq)((0,v.ai)()),returnData:(0,v.lq)((0,v.me)((0,v.NW)({programId:(0,v.Yj)(),data:(0,v.PV)([(0,v.Yj)(),(0,v.eu)("base64")])}))),innerInstructions:(0,v.lq)((0,v.me)((0,v.YO)((0,v.NW)({index:(0,v.ai)(),instructions:(0,v.YO)((0,v.KC)([xt,_t]))}))))})),Et=dt((0,v.NW)({byIdentity:(0,v.g1)((0,v.Yj)(),(0,v.YO)((0,v.ai)())),range:(0,v.NW)({firstSlot:(0,v.ai)(),lastSlot:(0,v.ai)()})}));function Wt(e,t,n,r,i,s){const o=n||Fe;let a,c;null!=s&&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."),r&&(c=async(e,t)=>{const n=await new Promise((n,i)=>{try{r(e,t,(e,t)=>n([e,t]))}catch(s){i(s)}});return await o(...n)});const u=new(A())(async(n,r)=>{const s={method:"POST",body:n,agent:a,headers:Object.assign({"Content-Type":"application/json"},t||{},Zn)};try{let t,n=5,a=500;for(;;){if(t=c?await c(e,s):await o(e,s),429!==t.status)break;if(!0===i)break;if(n-=1,0===n)break;console.error(`Server responded with ${t.status} ${t.statusText}.  Retrying after ${a}ms delay...`),await _e(a),a*=2}const u=await t.text();t.ok?r(null,u):r(new Error(`${t.status} ${t.statusText}: ${u}`))}catch(u){u instanceof Error&&r(u)}},{});return u}function Pt(e){return(t,n)=>new Promise((r,i)=>{e.request(t,n,(e,t)=>{e?i(e):r(t)})})}function Tt(e){return t=>new Promise((n,r)=>{0===t.length&&n([]);const i=t.map(t=>e.request(t.methodName,t.args));e.request(i,(e,t)=>{e?r(e):n(t)})})}const Ct=lt(gt),Nt=lt(yt),Ot=lt(mt),zt=lt(bt),Lt=lt(wt),Kt=lt(kt),Rt=lt((0,v.ai)()),jt=dt((0,v.NW)({total:(0,v.ai)(),circulating:(0,v.ai)(),nonCirculating:(0,v.ai)(),nonCirculatingAccounts:(0,v.YO)(tt)})),qt=(0,v.NW)({amount:(0,v.Yj)(),uiAmount:(0,v.me)((0,v.ai)()),decimals:(0,v.ai)(),uiAmountString:(0,v.lq)((0,v.Yj)())}),Yt=dt((0,v.YO)((0,v.NW)({address:tt,amount:(0,v.Yj)(),uiAmount:(0,v.me)((0,v.ai)()),decimals:(0,v.ai)(),uiAmountString:(0,v.lq)((0,v.Yj)())}))),Dt=dt((0,v.YO)((0,v.NW)({pubkey:tt,account:(0,v.NW)({executable:(0,v.zM)(),owner:tt,lamports:(0,v.ai)(),data:rt,rentEpoch:(0,v.ai)()})}))),Mt=(0,v.NW)({program:(0,v.Yj)(),parsed:(0,v.L5)(),space:(0,v.ai)()}),Ht=dt((0,v.YO)((0,v.NW)({pubkey:tt,account:(0,v.NW)({executable:(0,v.zM)(),owner:tt,lamports:(0,v.ai)(),data:Mt,rentEpoch:(0,v.ai)()})}))),Ut=dt((0,v.YO)((0,v.NW)({lamports:(0,v.ai)(),address:tt}))),$t=(0,v.NW)({executable:(0,v.zM)(),owner:tt,lamports:(0,v.ai)(),data:rt,rentEpoch:(0,v.ai)()}),Ft=(0,v.NW)({pubkey:tt,account:$t}),Vt=(0,v.au)((0,v.KC)([(0,v.KJ)(r.Buffer),Mt]),(0,v.KC)([nt,Mt]),e=>Array.isArray(e)?(0,v.vt)(e,rt):e),Jt=(0,v.NW)({executable:(0,v.zM)(),owner:tt,lamports:(0,v.ai)(),data:Vt,rentEpoch:(0,v.ai)()}),Gt=(0,v.NW)({pubkey:tt,account:Jt}),Xt=(0,v.NW)({state:(0,v.KC)([(0,v.eu)("active"),(0,v.eu)("inactive"),(0,v.eu)("activating"),(0,v.eu)("deactivating")]),active:(0,v.ai)(),inactive:(0,v.ai)()}),Zt=lt((0,v.YO)((0,v.NW)({signature:(0,v.Yj)(),slot:(0,v.ai)(),err:St,memo:(0,v.me)((0,v.Yj)()),blockTime:(0,v.lq)((0,v.me)((0,v.ai)()))}))),Qt=lt((0,v.YO)((0,v.NW)({signature:(0,v.Yj)(),slot:(0,v.ai)(),err:St,memo:(0,v.me)((0,v.Yj)()),blockTime:(0,v.lq)((0,v.me)((0,v.ai)()))}))),en=(0,v.NW)({subscription:(0,v.ai)(),result:ht($t)}),tn=(0,v.NW)({pubkey:tt,account:$t}),nn=(0,v.NW)({subscription:(0,v.ai)(),result:ht(tn)}),rn=(0,v.NW)({parent:(0,v.ai)(),slot:(0,v.ai)(),root:(0,v.ai)()}),sn=(0,v.NW)({subscription:(0,v.ai)(),result:rn}),on=(0,v.KC)([(0,v.NW)({type:(0,v.KC)([(0,v.eu)("firstShredReceived"),(0,v.eu)("completed"),(0,v.eu)("optimisticConfirmation"),(0,v.eu)("root")]),slot:(0,v.ai)(),timestamp:(0,v.ai)()}),(0,v.NW)({type:(0,v.eu)("createdBank"),parent:(0,v.ai)(),slot:(0,v.ai)(),timestamp:(0,v.ai)()}),(0,v.NW)({type:(0,v.eu)("frozen"),slot:(0,v.ai)(),timestamp:(0,v.ai)(),stats:(0,v.NW)({numTransactionEntries:(0,v.ai)(),numSuccessfulTransactions:(0,v.ai)(),numFailedTransactions:(0,v.ai)(),maxTransactionsPerEntry:(0,v.ai)()})}),(0,v.NW)({type:(0,v.eu)("dead"),slot:(0,v.ai)(),timestamp:(0,v.ai)(),err:(0,v.Yj)()})]),an=(0,v.NW)({subscription:(0,v.ai)(),result:on}),cn=(0,v.NW)({subscription:(0,v.ai)(),result:ht((0,v.KC)([vt,It]))}),un=(0,v.NW)({subscription:(0,v.ai)(),result:(0,v.ai)()}),ln=(0,v.NW)({pubkey:(0,v.Yj)(),gossip:(0,v.me)((0,v.Yj)()),tpu:(0,v.me)((0,v.Yj)()),rpc:(0,v.me)((0,v.Yj)()),version:(0,v.me)((0,v.Yj)())}),dn=(0,v.NW)({votePubkey:(0,v.Yj)(),nodePubkey:(0,v.Yj)(),activatedStake:(0,v.ai)(),epochVoteAccount:(0,v.zM)(),epochCredits:(0,v.YO)((0,v.PV)([(0,v.ai)(),(0,v.ai)(),(0,v.ai)()])),commission:(0,v.ai)(),lastVote:(0,v.ai)(),rootSlot:(0,v.me)((0,v.ai)())}),hn=lt((0,v.NW)({current:(0,v.YO)(dn),delinquent:(0,v.YO)(dn)})),pn=(0,v.KC)([(0,v.eu)("processed"),(0,v.eu)("confirmed"),(0,v.eu)("finalized")]),gn=(0,v.NW)({slot:(0,v.ai)(),confirmations:(0,v.me)((0,v.ai)()),err:St,confirmationStatus:(0,v.lq)(pn)}),fn=dt((0,v.YO)((0,v.me)(gn))),mn=lt((0,v.ai)()),yn=(0,v.NW)({accountKey:tt,writableIndexes:(0,v.YO)((0,v.ai)()),readonlyIndexes:(0,v.YO)((0,v.ai)())}),bn=(0,v.NW)({signatures:(0,v.YO)((0,v.Yj)()),message:(0,v.NW)({accountKeys:(0,v.YO)((0,v.Yj)()),header:(0,v.NW)({numRequiredSignatures:(0,v.ai)(),numReadonlySignedAccounts:(0,v.ai)(),numReadonlyUnsignedAccounts:(0,v.ai)()}),instructions:(0,v.YO)((0,v.NW)({accounts:(0,v.YO)((0,v.ai)()),data:(0,v.Yj)(),programIdIndex:(0,v.ai)()})),recentBlockhash:(0,v.Yj)(),addressTableLookups:(0,v.lq)((0,v.YO)(yn))})}),wn=(0,v.NW)({pubkey:tt,signer:(0,v.zM)(),writable:(0,v.zM)(),source:(0,v.lq)((0,v.KC)([(0,v.eu)("transaction"),(0,v.eu)("lookupTable")]))}),kn=(0,v.NW)({accountKeys:(0,v.YO)(wn),signatures:(0,v.YO)((0,v.Yj)())}),Sn=(0,v.NW)({parsed:(0,v.L5)(),program:(0,v.Yj)(),programId:tt}),vn=(0,v.NW)({accounts:(0,v.YO)(tt),data:(0,v.Yj)(),programId:tt}),In=(0,v.KC)([vn,Sn]),An=(0,v.KC)([(0,v.NW)({parsed:(0,v.L5)(),program:(0,v.Yj)(),programId:(0,v.Yj)()}),(0,v.NW)({accounts:(0,v.YO)((0,v.Yj)()),data:(0,v.Yj)(),programId:(0,v.Yj)()})]),xn=(0,v.au)(In,An,e=>"accounts"in e?(0,v.vt)(e,vn):(0,v.vt)(e,Sn)),_n=(0,v.NW)({signatures:(0,v.YO)((0,v.Yj)()),message:(0,v.NW)({accountKeys:(0,v.YO)(wn),instructions:(0,v.YO)(xn),recentBlockhash:(0,v.Yj)(),addressTableLookups:(0,v.lq)((0,v.me)((0,v.YO)(yn)))})}),Bn=(0,v.NW)({accountIndex:(0,v.ai)(),mint:(0,v.Yj)(),owner:(0,v.lq)((0,v.Yj)()),programId:(0,v.lq)((0,v.Yj)()),uiTokenAmount:qt}),En=(0,v.NW)({writable:(0,v.YO)(tt),readonly:(0,v.YO)(tt)}),Wn=(0,v.NW)({err:St,fee:(0,v.ai)(),innerInstructions:(0,v.lq)((0,v.me)((0,v.YO)((0,v.NW)({index:(0,v.ai)(),instructions:(0,v.YO)((0,v.NW)({accounts:(0,v.YO)((0,v.ai)()),data:(0,v.Yj)(),programIdIndex:(0,v.ai)()}))})))),preBalances:(0,v.YO)((0,v.ai)()),postBalances:(0,v.YO)((0,v.ai)()),logMessages:(0,v.lq)((0,v.me)((0,v.YO)((0,v.Yj)()))),preTokenBalances:(0,v.lq)((0,v.me)((0,v.YO)(Bn))),postTokenBalances:(0,v.lq)((0,v.me)((0,v.YO)(Bn))),loadedAddresses:(0,v.lq)(En),computeUnitsConsumed:(0,v.lq)((0,v.ai)()),costUnits:(0,v.lq)((0,v.ai)())}),Pn=(0,v.NW)({err:St,fee:(0,v.ai)(),innerInstructions:(0,v.lq)((0,v.me)((0,v.YO)((0,v.NW)({index:(0,v.ai)(),instructions:(0,v.YO)(xn)})))),preBalances:(0,v.YO)((0,v.ai)()),postBalances:(0,v.YO)((0,v.ai)()),logMessages:(0,v.lq)((0,v.me)((0,v.YO)((0,v.Yj)()))),preTokenBalances:(0,v.lq)((0,v.me)((0,v.YO)(Bn))),postTokenBalances:(0,v.lq)((0,v.me)((0,v.YO)(Bn))),loadedAddresses:(0,v.lq)(En),computeUnitsConsumed:(0,v.lq)((0,v.ai)()),costUnits:(0,v.lq)((0,v.ai)())}),Tn=(0,v.KC)([(0,v.eu)(0),(0,v.eu)("legacy")]),Cn=(0,v.NW)({pubkey:(0,v.Yj)(),lamports:(0,v.ai)(),postBalance:(0,v.me)((0,v.ai)()),rewardType:(0,v.me)((0,v.Yj)()),commission:(0,v.lq)((0,v.me)((0,v.ai)()))}),Nn=lt((0,v.me)((0,v.NW)({blockhash:(0,v.Yj)(),previousBlockhash:(0,v.Yj)(),parentSlot:(0,v.ai)(),transactions:(0,v.YO)((0,v.NW)({transaction:bn,meta:(0,v.me)(Wn),version:(0,v.lq)(Tn)})),rewards:(0,v.lq)((0,v.YO)(Cn)),blockTime:(0,v.me)((0,v.ai)()),blockHeight:(0,v.me)((0,v.ai)())}))),On=lt((0,v.me)((0,v.NW)({blockhash:(0,v.Yj)(),previousBlockhash:(0,v.Yj)(),parentSlot:(0,v.ai)(),rewards:(0,v.lq)((0,v.YO)(Cn)),blockTime:(0,v.me)((0,v.ai)()),blockHeight:(0,v.me)((0,v.ai)())}))),zn=lt((0,v.me)((0,v.NW)({blockhash:(0,v.Yj)(),previousBlockhash:(0,v.Yj)(),parentSlot:(0,v.ai)(),transactions:(0,v.YO)((0,v.NW)({transaction:kn,meta:(0,v.me)(Wn),version:(0,v.lq)(Tn)})),rewards:(0,v.lq)((0,v.YO)(Cn)),blockTime:(0,v.me)((0,v.ai)()),blockHeight:(0,v.me)((0,v.ai)())}))),Ln=lt((0,v.me)((0,v.NW)({blockhash:(0,v.Yj)(),previousBlockhash:(0,v.Yj)(),parentSlot:(0,v.ai)(),transactions:(0,v.YO)((0,v.NW)({transaction:_n,meta:(0,v.me)(Pn),version:(0,v.lq)(Tn)})),rewards:(0,v.lq)((0,v.YO)(Cn)),blockTime:(0,v.me)((0,v.ai)()),blockHeight:(0,v.me)((0,v.ai)())}))),Kn=lt((0,v.me)((0,v.NW)({blockhash:(0,v.Yj)(),previousBlockhash:(0,v.Yj)(),parentSlot:(0,v.ai)(),transactions:(0,v.YO)((0,v.NW)({transaction:kn,meta:(0,v.me)(Pn),version:(0,v.lq)(Tn)})),rewards:(0,v.lq)((0,v.YO)(Cn)),blockTime:(0,v.me)((0,v.ai)()),blockHeight:(0,v.me)((0,v.ai)())}))),Rn=lt((0,v.me)((0,v.NW)({blockhash:(0,v.Yj)(),previousBlockhash:(0,v.Yj)(),parentSlot:(0,v.ai)(),rewards:(0,v.lq)((0,v.YO)(Cn)),blockTime:(0,v.me)((0,v.ai)()),blockHeight:(0,v.me)((0,v.ai)())}))),jn=lt((0,v.me)((0,v.NW)({blockhash:(0,v.Yj)(),previousBlockhash:(0,v.Yj)(),parentSlot:(0,v.ai)(),transactions:(0,v.YO)((0,v.NW)({transaction:bn,meta:(0,v.me)(Wn)})),rewards:(0,v.lq)((0,v.YO)(Cn)),blockTime:(0,v.me)((0,v.ai)())}))),qn=lt((0,v.me)((0,v.NW)({blockhash:(0,v.Yj)(),previousBlockhash:(0,v.Yj)(),parentSlot:(0,v.ai)(),signatures:(0,v.YO)((0,v.Yj)()),blockTime:(0,v.me)((0,v.ai)())}))),Yn=lt((0,v.me)((0,v.NW)({slot:(0,v.ai)(),meta:(0,v.me)(Wn),blockTime:(0,v.lq)((0,v.me)((0,v.ai)())),transaction:bn,version:(0,v.lq)(Tn)}))),Dn=lt((0,v.me)((0,v.NW)({slot:(0,v.ai)(),transaction:_n,meta:(0,v.me)(Pn),blockTime:(0,v.lq)((0,v.me)((0,v.ai)())),version:(0,v.lq)(Tn)}))),Mn=dt((0,v.NW)({blockhash:(0,v.Yj)(),lastValidBlockHeight:(0,v.ai)()})),Hn=dt((0,v.zM)()),Un=(0,v.NW)({slot:(0,v.ai)(),numTransactions:(0,v.ai)(),numSlots:(0,v.ai)(),samplePeriodSecs:(0,v.ai)()}),$n=lt((0,v.YO)(Un)),Fn=dt((0,v.me)((0,v.NW)({feeCalculator:(0,v.NW)({lamportsPerSignature:(0,v.ai)()})}))),Vn=lt((0,v.Yj)()),Jn=lt((0,v.Yj)()),Gn=(0,v.NW)({err:St,logs:(0,v.YO)((0,v.Yj)()),signature:(0,v.Yj)()}),Xn=(0,v.NW)({result:ht(Gn),subscription:(0,v.ai)()}),Zn={"solana-client":"js/1.0.0-maintenance"};class Qn{constructor(e,t){let n,r,i,s,o,a;this._commitment=void 0,this._confirmTransactionInitialTimeout=void 0,this._rpcEndpoint=void 0,this._rpcWsEndpoint=void 0,this._rpcClient=void 0,this._rpcRequest=void 0,this._rpcBatchRequest=void 0,this._rpcWebSocket=void 0,this._rpcWebSocketConnected=!1,this._rpcWebSocketHeartbeat=null,this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketGeneration=0,this._disableBlockhashCaching=!1,this._pollingBlockhash=!1,this._blockhashInfo={latestBlockhash:null,lastFetch:0,transactionSignatures:[],simulatedSignatures:[]},this._nextClientSubscriptionId=0,this._subscriptionDisposeFunctionsByClientSubscriptionId={},this._subscriptionHashByClientSubscriptionId={},this._subscriptionStateChangeCallbacksByHash={},this._subscriptionCallbacksByServerSubscriptionId={},this._subscriptionsByHash={},this._subscriptionsAutoDisposedByRpc=new Set,this.getBlockHeight=(()=>{const e={};return async t=>{const{commitment:n,config:r}=ot(t),i=this._buildArgs([],n,void 0,r),s=De(i);return e[s]=e[s]??(async()=>{try{const e=await this._rpcRequest("getBlockHeight",i),t=(0,v.vt)(e,lt((0,v.ai)()));if("error"in t)throw new Ae(t.error,"failed to get block height information");return t.result}finally{delete e[s]}})(),await e[s]}})(),t&&"string"===typeof t?this._commitment=t:t&&(this._commitment=t.commitment,this._confirmTransactionInitialTimeout=t.confirmTransactionInitialTimeout,n=t.wsEndpoint,r=t.httpHeaders,i=t.fetch,s=t.fetchMiddleware,o=t.disableRetryOnRateLimit,a=t.httpAgent),this._rpcEndpoint=st(e),this._rpcWsEndpoint=n||et(e),this._rpcClient=Wt(e,r,i,s,o,a),this._rpcRequest=Pt(this._rpcClient),this._rpcBatchRequest=Tt(this._rpcClient),this._rpcWebSocket=new Ve(this._rpcWsEndpoint,{autoconnect:!1,max_reconnects:1/0}),this._rpcWebSocket.on("open",this._wsOnOpen.bind(this)),this._rpcWebSocket.on("error",this._wsOnError.bind(this)),this._rpcWebSocket.on("close",this._wsOnClose.bind(this)),this._rpcWebSocket.on("accountNotification",this._wsOnAccountNotification.bind(this)),this._rpcWebSocket.on("programNotification",this._wsOnProgramAccountNotification.bind(this)),this._rpcWebSocket.on("slotNotification",this._wsOnSlotNotification.bind(this)),this._rpcWebSocket.on("slotsUpdatesNotification",this._wsOnSlotUpdatesNotification.bind(this)),this._rpcWebSocket.on("signatureNotification",this._wsOnSignatureNotification.bind(this)),this._rpcWebSocket.on("rootNotification",this._wsOnRootNotification.bind(this)),this._rpcWebSocket.on("logsNotification",this._wsOnLogsNotification.bind(this))}get commitment(){return this._commitment}get rpcEndpoint(){return this._rpcEndpoint}async getBalanceAndContext(e,t){const{commitment:n,config:r}=ot(t),i=this._buildArgs([e.toBase58()],n,void 0,r),s=await this._rpcRequest("getBalance",i),o=(0,v.vt)(s,dt((0,v.ai)()));if("error"in o)throw new Ae(o.error,`failed to get balance for ${e.toBase58()}`);return o.result}async getBalance(e,t){return await this.getBalanceAndContext(e,t).then(e=>e.value).catch(t=>{throw new Error("failed to get balance of account "+e.toBase58()+": "+t)})}async getBlockTime(e){const t=await this._rpcRequest("getBlockTime",[e]),n=(0,v.vt)(t,lt((0,v.me)((0,v.ai)())));if("error"in n)throw new Ae(n.error,`failed to get block time for slot ${e}`);return n.result}async getMinimumLedgerSlot(){const e=await this._rpcRequest("minimumLedgerSlot",[]),t=(0,v.vt)(e,lt((0,v.ai)()));if("error"in t)throw new Ae(t.error,"failed to get minimum ledger slot");return t.result}async getFirstAvailableBlock(){const e=await this._rpcRequest("getFirstAvailableBlock",[]),t=(0,v.vt)(e,Rt);if("error"in t)throw new Ae(t.error,"failed to get first available block");return t.result}async getSupply(e){let t={};t="string"===typeof e?{commitment:e}:e?{...e,commitment:e&&e.commitment||this.commitment}:{commitment:this.commitment};const n=await this._rpcRequest("getSupply",[t]),r=(0,v.vt)(n,jt);if("error"in r)throw new Ae(r.error,"failed to get supply");return r.result}async getTokenSupply(e,t){const n=this._buildArgs([e.toBase58()],t),r=await this._rpcRequest("getTokenSupply",n),i=(0,v.vt)(r,dt(qt));if("error"in i)throw new Ae(i.error,"failed to get token supply");return i.result}async getTokenAccountBalance(e,t){const n=this._buildArgs([e.toBase58()],t),r=await this._rpcRequest("getTokenAccountBalance",n),i=(0,v.vt)(r,dt(qt));if("error"in i)throw new Ae(i.error,"failed to get token account balance");return i.result}async getTokenAccountsByOwner(e,t,n){const{commitment:r,config:i}=ot(n);let s=[e.toBase58()];"mint"in t?s.push({mint:t.mint.toBase58()}):s.push({programId:t.programId.toBase58()});const o=this._buildArgs(s,r,"base64",i),a=await this._rpcRequest("getTokenAccountsByOwner",o),c=(0,v.vt)(a,Dt);if("error"in c)throw new Ae(c.error,`failed to get token accounts owned by account ${e.toBase58()}`);return c.result}async getParsedTokenAccountsByOwner(e,t,n){let r=[e.toBase58()];"mint"in t?r.push({mint:t.mint.toBase58()}):r.push({programId:t.programId.toBase58()});const i=this._buildArgs(r,n,"jsonParsed"),s=await this._rpcRequest("getTokenAccountsByOwner",i),o=(0,v.vt)(s,Ht);if("error"in o)throw new Ae(o.error,`failed to get token accounts owned by account ${e.toBase58()}`);return o.result}async getLargestAccounts(e){const t={...e,commitment:e&&e.commitment||this.commitment},n=t.filter||t.commitment?[t]:[],r=await this._rpcRequest("getLargestAccounts",n),i=(0,v.vt)(r,Ut);if("error"in i)throw new Ae(i.error,"failed to get largest accounts");return i.result}async getTokenLargestAccounts(e,t){const n=this._buildArgs([e.toBase58()],t),r=await this._rpcRequest("getTokenLargestAccounts",n),i=(0,v.vt)(r,Yt);if("error"in i)throw new Ae(i.error,"failed to get token largest accounts");return i.result}async getAccountInfoAndContext(e,t){const{commitment:n,config:r}=ot(t),i=this._buildArgs([e.toBase58()],n,"base64",r),s=await this._rpcRequest("getAccountInfo",i),o=(0,v.vt)(s,dt((0,v.me)($t)));if("error"in o)throw new Ae(o.error,`failed to get info about account ${e.toBase58()}`);return o.result}async getParsedAccountInfo(e,t){const{commitment:n,config:r}=ot(t),i=this._buildArgs([e.toBase58()],n,"jsonParsed",r),s=await this._rpcRequest("getAccountInfo",i),o=(0,v.vt)(s,dt((0,v.me)(Jt)));if("error"in o)throw new Ae(o.error,`failed to get info about account ${e.toBase58()}`);return o.result}async getAccountInfo(e,t){try{const n=await this.getAccountInfoAndContext(e,t);return n.value}catch(n){throw new Error("failed to get info about account "+e.toBase58()+": "+n)}}async getMultipleParsedAccounts(e,t){const{commitment:n,config:r}=ot(t),i=e.map(e=>e.toBase58()),s=this._buildArgs([i],n,"jsonParsed",r),o=await this._rpcRequest("getMultipleAccounts",s),a=(0,v.vt)(o,dt((0,v.YO)((0,v.me)(Jt))));if("error"in a)throw new Ae(a.error,`failed to get info for accounts ${i}`);return a.result}async getMultipleAccountsInfoAndContext(e,t){const{commitment:n,config:r}=ot(t),i=e.map(e=>e.toBase58()),s=this._buildArgs([i],n,"base64",r),o=await this._rpcRequest("getMultipleAccounts",s),a=(0,v.vt)(o,dt((0,v.YO)((0,v.me)($t))));if("error"in a)throw new Ae(a.error,`failed to get info for accounts ${i}`);return a.result}async getMultipleAccountsInfo(e,t){const n=await this.getMultipleAccountsInfoAndContext(e,t);return n.value}async getStakeActivation(e,t,n){const{commitment:r,config:i}=ot(t),s=this._buildArgs([e.toBase58()],r,void 0,{...i,epoch:null!=n?n:i?.epoch}),o=await this._rpcRequest("getStakeActivation",s),a=(0,v.vt)(o,lt(Xt));if("error"in a)throw new Ae(a.error,`failed to get Stake Activation ${e.toBase58()}`);return a.result}async getProgramAccounts(e,t){const{commitment:n,config:r}=ot(t),{encoding:i,...s}=r||{},o=this._buildArgs([e.toBase58()],n,i||"base64",{...s,...s.filters?{filters:at(s.filters)}:null}),a=await this._rpcRequest("getProgramAccounts",o),c=(0,v.YO)(Ft),u=!0===s.withContext?(0,v.vt)(a,dt(c)):(0,v.vt)(a,lt(c));if("error"in u)throw new Ae(u.error,`failed to get accounts owned by program ${e.toBase58()}`);return u.result}async getParsedProgramAccounts(e,t){const{commitment:n,config:r}=ot(t),i=this._buildArgs([e.toBase58()],n,"jsonParsed",r),s=await this._rpcRequest("getProgramAccounts",i),o=(0,v.vt)(s,lt((0,v.YO)(Gt)));if("error"in o)throw new Ae(o.error,`failed to get accounts owned by program ${e.toBase58()}`);return o.result}async confirmTransaction(e,t){let n,r;if("string"==typeof e)n=e;else{const t=e;if(t.abortSignal?.aborted)return Promise.reject(t.abortSignal.reason);n=t.signature}try{r=c().decode(n)}catch(i){throw new Error("signature must be base58 encoded: "+n)}return ie(64===r.length,"signature has invalid length"),"string"===typeof e?await this.confirmTransactionUsingLegacyTimeoutStrategy({commitment:t||this.commitment,signature:n}):"lastValidBlockHeight"in e?await this.confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:t||this.commitment,strategy:e}):await this.confirmTransactionUsingDurableNonceStrategy({commitment:t||this.commitment,strategy:e})}getCancellationPromise(e){return new Promise((t,n)=>{null!=e&&(e.aborted?n(e.reason):e.addEventListener("abort",()=>{n(e.reason)}))})}getTransactionConfirmationPromise({commitment:e,signature:t}){let n,r,i=!1;const s=new Promise((s,o)=>{try{n=this.onSignature(t,(e,t)=>{n=void 0;const r={context:t,value:e};s({__type:de.PROCESSED,response:r})},e);const a=new Promise(e=>{null==n?e():r=this._onSubscriptionStateChange(n,t=>{"subscribed"===t&&e()})});(async()=>{if(await a,i)return;const n=await this.getSignatureStatus(t);if(i)return;if(null==n)return;const{context:r,value:c}=n;if(null!=c)if(c?.err)o(c.err);else{switch(e){case"confirmed":case"single":case"singleGossip":if("processed"===c.confirmationStatus)return;break;case"finalized":case"max":case"root":if("processed"===c.confirmationStatus||"confirmed"===c.confirmationStatus)return;break;case"processed":case"recent":}i=!0,s({__type:de.PROCESSED,response:{context:r,value:c}})}})()}catch(a){o(a)}}),o=()=>{r&&(r(),r=void 0),null!=n&&(this.removeSignatureListener(n),n=void 0)};return{abortConfirmation:o,confirmationPromise:s}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:e,strategy:{abortSignal:t,lastValidBlockHeight:n,signature:r}}){let i=!1;const s=new Promise(t=>{const r=async()=>{try{const t=await this.getBlockHeight(e);return t}catch(t){return-1}};(async()=>{let e=await r();if(!i){while(e<=n){if(await _e(1e3),i)return;if(e=await r(),i)return}t({__type:de.BLOCKHEIGHT_EXCEEDED})}})()}),{abortConfirmation:o,confirmationPromise:a}=this.getTransactionConfirmationPromise({commitment:e,signature:r}),c=this.getCancellationPromise(t);let u;try{const e=await Promise.race([c,a,s]);if(e.__type!==de.PROCESSED)throw new U(r);u=e.response}finally{i=!0,o()}return u}async confirmTransactionUsingDurableNonceStrategy({commitment:e,strategy:{abortSignal:t,minContextSlot:n,nonceAccountPubkey:r,nonceValue:i,signature:s}}){let o=!1;const a=new Promise(t=>{let s=i,a=null;const c=async()=>{try{const{context:t,value:i}=await this.getNonceAndContext(r,{commitment:e,minContextSlot:n});return a=t.slot,i?.nonce}catch(t){return s}};(async()=>{if(s=await c(),!o)while(1){if(i!==s)return void t({__type:de.NONCE_INVALID,slotInWhichNonceDidAdvance:a});if(await _e(2e3),o)return;if(s=await c(),o)return}})()}),{abortConfirmation:c,confirmationPromise:u}=this.getTransactionConfirmationPromise({commitment:e,signature:s}),l=this.getCancellationPromise(t);let d;try{const t=await Promise.race([l,u,a]);if(t.__type===de.PROCESSED)d=t.response;else{let r;while(1){const e=await this.getSignatureStatus(s);if(null==e)break;if(!(e.context.slot<(t.slotInWhichNonceDidAdvance??n))){r=e;break}await _e(400)}if(!r?.value)throw new F(s);{const t=e||"finalized",{confirmationStatus:n}=r.value;switch(t){case"processed":case"recent":if("processed"!==n&&"confirmed"!==n&&"finalized"!==n)throw new F(s);break;case"confirmed":case"single":case"singleGossip":if("confirmed"!==n&&"finalized"!==n)throw new F(s);break;case"finalized":case"max":case"root":if("finalized"!==n)throw new F(s);break;default:}d={context:r.context,value:{err:r.value.err}}}}}finally{o=!0,c()}return d}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:e,signature:t}){let n;const r=new Promise(t=>{let r=this._confirmTransactionInitialTimeout||6e4;switch(e){case"processed":case"recent":case"single":case"confirmed":case"singleGossip":r=this._confirmTransactionInitialTimeout||3e4;break}n=setTimeout(()=>t({__type:de.TIMED_OUT,timeoutMs:r}),r)}),{abortConfirmation:i,confirmationPromise:s}=this.getTransactionConfirmationPromise({commitment:e,signature:t});let o;try{const e=await Promise.race([s,r]);if(e.__type!==de.PROCESSED)throw new $(t,e.timeoutMs/1e3);o=e.response}finally{clearTimeout(n),i()}return o}async getClusterNodes(){const e=await this._rpcRequest("getClusterNodes",[]),t=(0,v.vt)(e,lt((0,v.YO)(ln)));if("error"in t)throw new Ae(t.error,"failed to get cluster nodes");return t.result}async getVoteAccounts(e){const t=this._buildArgs([],e),n=await this._rpcRequest("getVoteAccounts",t),r=(0,v.vt)(n,hn);if("error"in r)throw new Ae(r.error,"failed to get vote accounts");return r.result}async getSlot(e){const{commitment:t,config:n}=ot(e),r=this._buildArgs([],t,void 0,n),i=await this._rpcRequest("getSlot",r),s=(0,v.vt)(i,lt((0,v.ai)()));if("error"in s)throw new Ae(s.error,"failed to get slot");return s.result}async getSlotLeader(e){const{commitment:t,config:n}=ot(e),r=this._buildArgs([],t,void 0,n),i=await this._rpcRequest("getSlotLeader",r),s=(0,v.vt)(i,lt((0,v.Yj)()));if("error"in s)throw new Ae(s.error,"failed to get slot leader");return s.result}async getSlotLeaders(e,t){const n=[e,t],r=await this._rpcRequest("getSlotLeaders",n),i=(0,v.vt)(r,lt((0,v.YO)(tt)));if("error"in i)throw new Ae(i.error,"failed to get slot leaders");return i.result}async getSignatureStatus(e,t){const{context:n,value:r}=await this.getSignatureStatuses([e],t);ie(1===r.length);const i=r[0];return{context:n,value:i}}async getSignatureStatuses(e,t){const n=[e];t&&n.push(t);const r=await this._rpcRequest("getSignatureStatuses",n),i=(0,v.vt)(r,fn);if("error"in i)throw new Ae(i.error,"failed to get signature status");return i.result}async getTransactionCount(e){const{commitment:t,config:n}=ot(e),r=this._buildArgs([],t,void 0,n),i=await this._rpcRequest("getTransactionCount",r),s=(0,v.vt)(i,lt((0,v.ai)()));if("error"in s)throw new Ae(s.error,"failed to get transaction count");return s.result}async getTotalSupply(e){const t=await this.getSupply({commitment:e,excludeNonCirculatingAccountsList:!0});return t.value.total}async getInflationGovernor(e){const t=this._buildArgs([],e),n=await this._rpcRequest("getInflationGovernor",t),r=(0,v.vt)(n,Ct);if("error"in r)throw new Ae(r.error,"failed to get inflation");return r.result}async getInflationReward(e,t,n){const{commitment:r,config:i}=ot(n),s=this._buildArgs([e.map(e=>e.toBase58())],r,void 0,{...i,epoch:null!=t?t:i?.epoch}),o=await this._rpcRequest("getInflationReward",s),a=(0,v.vt)(o,ft);if("error"in a)throw new Ae(a.error,"failed to get inflation reward");return a.result}async getInflationRate(){const e=await this._rpcRequest("getInflationRate",[]),t=(0,v.vt)(e,Nt);if("error"in t)throw new Ae(t.error,"failed to get inflation rate");return t.result}async getEpochInfo(e){const{commitment:t,config:n}=ot(e),r=this._buildArgs([],t,void 0,n),i=await this._rpcRequest("getEpochInfo",r),s=(0,v.vt)(i,zt);if("error"in s)throw new Ae(s.error,"failed to get epoch info");return s.result}async getEpochSchedule(){const e=await this._rpcRequest("getEpochSchedule",[]),t=(0,v.vt)(e,Lt);if("error"in t)throw new Ae(t.error,"failed to get epoch schedule");const n=t.result;return new $e(n.slotsPerEpoch,n.leaderScheduleSlotOffset,n.warmup,n.firstNormalEpoch,n.firstNormalSlot)}async getLeaderSchedule(){const e=await this._rpcRequest("getLeaderSchedule",[]),t=(0,v.vt)(e,Kt);if("error"in t)throw new Ae(t.error,"failed to get leader schedule");return t.result}async getMinimumBalanceForRentExemption(e,t){const n=this._buildArgs([e],t),r=await this._rpcRequest("getMinimumBalanceForRentExemption",n),i=(0,v.vt)(r,mn);return"error"in i?(console.warn("Unable to fetch minimum balance for rent exemption"),0):i.result}async getRecentBlockhashAndContext(e){const{context:t,value:{blockhash:n}}=await this.getLatestBlockhashAndContext(e),r={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{}}};return{context:t,value:{blockhash:n,feeCalculator:r}}}async getRecentPerformanceSamples(e){const t=await this._rpcRequest("getRecentPerformanceSamples",e?[e]:[]),n=(0,v.vt)(t,$n);if("error"in n)throw new Ae(n.error,"failed to get recent performance samples");return n.result}async getFeeCalculatorForBlockhash(e,t){const n=this._buildArgs([e],t),r=await this._rpcRequest("getFeeCalculatorForBlockhash",n),i=(0,v.vt)(r,Fn);if("error"in i)throw new Ae(i.error,"failed to get fee calculator");const{context:s,value:o}=i.result;return{context:s,value:null!==o?o.feeCalculator:null}}async getFeeForMessage(e,t){const n=N(e.serialize()).toString("base64"),r=this._buildArgs([n],t),i=await this._rpcRequest("getFeeForMessage",r),s=(0,v.vt)(i,dt((0,v.me)((0,v.ai)())));if("error"in s)throw new Ae(s.error,"failed to get fee for message");if(null===s.result)throw new Error("invalid blockhash");return s.result}async getRecentPrioritizationFees(e){const t=e?.lockedWritableAccounts?.map(e=>e.toBase58()),n=t?.length?[t]:[],r=await this._rpcRequest("getRecentPrioritizationFees",n),i=(0,v.vt)(r,Ot);if("error"in i)throw new Ae(i.error,"failed to get recent prioritization fees");return i.result}async getRecentBlockhash(e){try{const t=await this.getRecentBlockhashAndContext(e);return t.value}catch(t){throw new Error("failed to get recent blockhash: "+t)}}async getLatestBlockhash(e){try{const t=await this.getLatestBlockhashAndContext(e);return t.value}catch(t){throw new Error("failed to get recent blockhash: "+t)}}async getLatestBlockhashAndContext(e){const{commitment:t,config:n}=ot(e),r=this._buildArgs([],t,void 0,n),i=await this._rpcRequest("getLatestBlockhash",r),s=(0,v.vt)(i,Mn);if("error"in s)throw new Ae(s.error,"failed to get latest blockhash");return s.result}async isBlockhashValid(e,t){const{commitment:n,config:r}=ot(t),i=this._buildArgs([e],n,void 0,r),s=await this._rpcRequest("isBlockhashValid",i),o=(0,v.vt)(s,Hn);if("error"in o)throw new Ae(o.error,"failed to determine if the blockhash `"+e+"`is valid");return o.result}async getVersion(){const e=await this._rpcRequest("getVersion",[]),t=(0,v.vt)(e,lt(At));if("error"in t)throw new Ae(t.error,"failed to get version");return t.result}async getGenesisHash(){const e=await this._rpcRequest("getGenesisHash",[]),t=(0,v.vt)(e,lt((0,v.Yj)()));if("error"in t)throw new Ae(t.error,"failed to get genesis hash");return t.result}async getBlock(e,t){const{commitment:n,config:r}=ot(t),i=this._buildArgsAtLeastConfirmed([e],n,void 0,r),s=await this._rpcRequest("getBlock",i);try{switch(r?.transactionDetails){case"accounts":{const e=(0,v.vt)(s,zn);if("error"in e)throw e.error;return e.result}case"none":{const e=(0,v.vt)(s,On);if("error"in e)throw e.error;return e.result}default:{const e=(0,v.vt)(s,Nn);if("error"in e)throw e.error;const{result:t}=e;return t?{...t,transactions:t.transactions.map(({transaction:e,meta:t,version:n})=>({meta:t,transaction:{...e,message:pt(n,e.message)},version:n}))}:null}}}catch(o){throw new Ae(o,"failed to get confirmed block")}}async getParsedBlock(e,t){const{commitment:n,config:r}=ot(t),i=this._buildArgsAtLeastConfirmed([e],n,"jsonParsed",r),s=await this._rpcRequest("getBlock",i);try{switch(r?.transactionDetails){case"accounts":{const e=(0,v.vt)(s,Kn);if("error"in e)throw e.error;return e.result}case"none":{const e=(0,v.vt)(s,Rn);if("error"in e)throw e.error;return e.result}default:{const e=(0,v.vt)(s,Ln);if("error"in e)throw e.error;return e.result}}}catch(o){throw new Ae(o,"failed to get block")}}async getBlockProduction(e){let t,n;if("string"===typeof e)n=e;else if(e){const{commitment:r,...i}=e;n=r,t=i}const r=this._buildArgs([],n,"base64",t),i=await this._rpcRequest("getBlockProduction",r),s=(0,v.vt)(i,Et);if("error"in s)throw new Ae(s.error,"failed to get block production information");return s.result}async getTransaction(e,t){const{commitment:n,config:r}=ot(t),i=this._buildArgsAtLeastConfirmed([e],n,void 0,r),s=await this._rpcRequest("getTransaction",i),o=(0,v.vt)(s,Yn);if("error"in o)throw new Ae(o.error,"failed to get transaction");const a=o.result;return a?{...a,transaction:{...a.transaction,message:pt(a.version,a.transaction.message)}}:a}async getParsedTransaction(e,t){const{commitment:n,config:r}=ot(t),i=this._buildArgsAtLeastConfirmed([e],n,"jsonParsed",r),s=await this._rpcRequest("getTransaction",i),o=(0,v.vt)(s,Dn);if("error"in o)throw new Ae(o.error,"failed to get transaction");return o.result}async getParsedTransactions(e,t){const{commitment:n,config:r}=ot(t),i=e.map(e=>{const t=this._buildArgsAtLeastConfirmed([e],n,"jsonParsed",r);return{methodName:"getTransaction",args:t}}),s=await this._rpcBatchRequest(i),o=s.map(e=>{const t=(0,v.vt)(e,Dn);if("error"in t)throw new Ae(t.error,"failed to get transactions");return t.result});return o}async getTransactions(e,t){const{commitment:n,config:r}=ot(t),i=e.map(e=>{const t=this._buildArgsAtLeastConfirmed([e],n,void 0,r);return{methodName:"getTransaction",args:t}}),s=await this._rpcBatchRequest(i),o=s.map(e=>{const t=(0,v.vt)(e,Yn);if("error"in t)throw new Ae(t.error,"failed to get transactions");const n=t.result;return n?{...n,transaction:{...n.transaction,message:pt(n.version,n.transaction.message)}}:n});return o}async getConfirmedBlock(e,t){const n=this._buildArgsAtLeastConfirmed([e],t),r=await this._rpcRequest("getBlock",n),i=(0,v.vt)(r,jn);if("error"in i)throw new Ae(i.error,"failed to get confirmed block");const s=i.result;if(!s)throw new Error("Confirmed block "+e+" not found");const o={...s,transactions:s.transactions.map(({transaction:e,meta:t})=>{const n=new ue(e.message);return{meta:t,transaction:{...e,message:n}}})};return{...o,transactions:o.transactions.map(({transaction:e,meta:t})=>({meta:t,transaction:ge.populate(e.message,e.signatures)}))}}async getBlocks(e,t,n){const r=this._buildArgsAtLeastConfirmed(void 0!==t?[e,t]:[e],n),i=await this._rpcRequest("getBlocks",r),s=(0,v.vt)(i,lt((0,v.YO)((0,v.ai)())));if("error"in s)throw new Ae(s.error,"failed to get blocks");return s.result}async getBlockSignatures(e,t){const n=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:"signatures",rewards:!1}),r=await this._rpcRequest("getBlock",n),i=(0,v.vt)(r,qn);if("error"in i)throw new Ae(i.error,"failed to get block");const s=i.result;if(!s)throw new Error("Block "+e+" not found");return s}async getConfirmedBlockSignatures(e,t){const n=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:"signatures",rewards:!1}),r=await this._rpcRequest("getBlock",n),i=(0,v.vt)(r,qn);if("error"in i)throw new Ae(i.error,"failed to get confirmed block");const s=i.result;if(!s)throw new Error("Confirmed block "+e+" not found");return s}async getConfirmedTransaction(e,t){const n=this._buildArgsAtLeastConfirmed([e],t),r=await this._rpcRequest("getTransaction",n),i=(0,v.vt)(r,Yn);if("error"in i)throw new Ae(i.error,"failed to get transaction");const s=i.result;if(!s)return s;const o=new ue(s.transaction.message),a=s.transaction.signatures;return{...s,transaction:ge.populate(o,a)}}async getParsedConfirmedTransaction(e,t){const n=this._buildArgsAtLeastConfirmed([e],t,"jsonParsed"),r=await this._rpcRequest("getTransaction",n),i=(0,v.vt)(r,Dn);if("error"in i)throw new Ae(i.error,"failed to get confirmed transaction");return i.result}async getParsedConfirmedTransactions(e,t){const n=e.map(e=>{const n=this._buildArgsAtLeastConfirmed([e],t,"jsonParsed");return{methodName:"getTransaction",args:n}}),r=await this._rpcBatchRequest(n),i=r.map(e=>{const t=(0,v.vt)(e,Dn);if("error"in t)throw new Ae(t.error,"failed to get confirmed transactions");return t.result});return i}async getConfirmedSignaturesForAddress(e,t,n){let r={},i=await this.getFirstAvailableBlock();while(!("until"in r)){if(t--,t<=0||t<i)break;try{const e=await this.getConfirmedBlockSignatures(t,"finalized");e.signatures.length>0&&(r.until=e.signatures[e.signatures.length-1].toString())}catch(a){if(a instanceof Error&&a.message.includes("skipped"))continue;throw a}}let s=await this.getSlot("finalized");while(!("before"in r)){if(n++,n>s)break;try{const e=await this.getConfirmedBlockSignatures(n);e.signatures.length>0&&(r.before=e.signatures[e.signatures.length-1].toString())}catch(a){if(a instanceof Error&&a.message.includes("skipped"))continue;throw a}}const o=await this.getConfirmedSignaturesForAddress2(e,r);return o.map(e=>e.signature)}async getConfirmedSignaturesForAddress2(e,t,n){const r=this._buildArgsAtLeastConfirmed([e.toBase58()],n,void 0,t),i=await this._rpcRequest("getConfirmedSignaturesForAddress2",r),s=(0,v.vt)(i,Zt);if("error"in s)throw new Ae(s.error,"failed to get confirmed signatures for address");return s.result}async getSignaturesForAddress(e,t,n){const r=this._buildArgsAtLeastConfirmed([e.toBase58()],n,void 0,t),i=await this._rpcRequest("getSignaturesForAddress",r),s=(0,v.vt)(i,Qt);if("error"in s)throw new Ae(s.error,"failed to get signatures for address");return s.result}async getAddressLookupTable(e,t){const{context:n,value:r}=await this.getAccountInfoAndContext(e,t);let i=null;return null!==r&&(i=new Xe({key:e,state:Xe.deserialize(r.data)})),{context:n,value:i}}async getNonceAndContext(e,t){const{context:n,value:r}=await this.getAccountInfoAndContext(e,t);let i=null;return null!==r&&(i=Te.fromAccountData(r.data)),{context:n,value:i}}async getNonce(e,t){return await this.getNonceAndContext(e,t).then(e=>e.value).catch(t=>{throw new Error("failed to get nonce for account "+e.toBase58()+": "+t)})}async requestAirdrop(e,t){const n=await this._rpcRequest("requestAirdrop",[e.toBase58(),t]),r=(0,v.vt)(n,Vn);if("error"in r)throw new Ae(r.error,`airdrop to ${e.toBase58()} failed`);return r.result}async _blockhashWithExpiryBlockHeight(e){if(!e){while(this._pollingBlockhash)await _e(100);const e=Date.now()-this._blockhashInfo.lastFetch,t=e>=it;if(null!==this._blockhashInfo.latestBlockhash&&!t)return this._blockhashInfo.latestBlockhash}return await this._pollNewBlockhash()}async _pollNewBlockhash(){this._pollingBlockhash=!0;try{const e=Date.now(),t=this._blockhashInfo.latestBlockhash,n=t?t.blockhash:null;for(let r=0;r<50;r++){const e=await this.getLatestBlockhash("finalized");if(n!==e.blockhash)return this._blockhashInfo={latestBlockhash:e,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},e;await _e(be/2)}throw new Error(`Unable to obtain a new blockhash after ${Date.now()-e}ms`)}finally{this._pollingBlockhash=!1}}async getStakeMinimumDelegation(e){const{commitment:t,config:n}=ot(e),r=this._buildArgs([],t,"base64",n),i=await this._rpcRequest("getStakeMinimumDelegation",r),s=(0,v.vt)(i,dt((0,v.ai)()));if("error"in s)throw new Ae(s.error,"failed to get stake minimum delegation");return s.result}async simulateTransaction(e,t,n){if("message"in e){const i=e,s=i.serialize(),o=r.Buffer.from(s).toString("base64");if(Array.isArray(t)||void 0!==n)throw new Error("Invalid arguments");const a=t||{};a.encoding="base64","commitment"in a||(a.commitment=this.commitment),t&&"object"===typeof t&&"innerInstructions"in t&&(a.innerInstructions=t.innerInstructions);const c=[o,a],u=await this._rpcRequest("simulateTransaction",c),l=(0,v.vt)(u,Bt);if("error"in l)throw new Error("failed to simulate transaction: "+l.error.message);return l.result}let i;if(e instanceof ge){let t=e;i=new ge,i.feePayer=t.feePayer,i.instructions=e.instructions,i.nonceInfo=t.nonceInfo,i.signatures=t.signatures}else i=ge.populate(e),i._message=i._json=void 0;if(void 0!==t&&!Array.isArray(t))throw new Error("Invalid arguments");const s=t;if(i.nonceInfo&&s)i.sign(...s);else{let e=this._disableBlockhashCaching;for(;;){const t=await this._blockhashWithExpiryBlockHeight(e);if(i.lastValidBlockHeight=t.lastValidBlockHeight,i.recentBlockhash=t.blockhash,!s)break;if(i.sign(...s),!i.signature)throw new Error("!signature");const n=i.signature.toString("base64");if(!this._blockhashInfo.simulatedSignatures.includes(n)&&!this._blockhashInfo.transactionSignatures.includes(n)){this._blockhashInfo.simulatedSignatures.push(n);break}e=!0}}const o=i._compile(),a=o.serialize(),c=i._serialize(a),u=c.toString("base64"),l={encoding:"base64",commitment:this.commitment};if(n){const e=(Array.isArray(n)?n:o.nonProgramIds()).map(e=>e.toBase58());l["accounts"]={encoding:"base64",addresses:e}}s&&(l.sigVerify=!0),t&&"object"===typeof t&&"innerInstructions"in t&&(l.innerInstructions=t.innerInstructions);const d=[u,l],h=await this._rpcRequest("simulateTransaction",d),p=(0,v.vt)(h,Bt);if("error"in p){let e;if("data"in p.error&&(e=p.error.data.logs,e&&Array.isArray(e))){const t="\n    ",n=t+e.join(t);console.error(p.error.message,n)}throw new Ie({action:"simulate",signature:"",transactionMessage:p.error.message,logs:e})}return p.result}async sendTransaction(e,t,n){if("version"in e){if(t&&Array.isArray(t))throw new Error("Invalid arguments");const n=e.serialize();return await this.sendRawTransaction(n,t)}if(void 0===t||!Array.isArray(t))throw new Error("Invalid arguments");const r=t;if(e.nonceInfo)e.sign(...r);else{let t=this._disableBlockhashCaching;for(;;){const n=await this._blockhashWithExpiryBlockHeight(t);if(e.lastValidBlockHeight=n.lastValidBlockHeight,e.recentBlockhash=n.blockhash,e.sign(...r),!e.signature)throw new Error("!signature");const i=e.signature.toString("base64");if(!this._blockhashInfo.transactionSignatures.includes(i)){this._blockhashInfo.transactionSignatures.push(i);break}t=!0}}const i=e.serialize();return await this.sendRawTransaction(i,n)}async sendRawTransaction(e,t){const n=N(e).toString("base64"),r=await this.sendEncodedTransaction(n,t);return r}async sendEncodedTransaction(e,t){const n={encoding:"base64"},r=t&&t.skipPreflight,i=!0===r?"processed":t&&t.preflightCommitment||this.commitment;t&&null!=t.maxRetries&&(n.maxRetries=t.maxRetries),t&&null!=t.minContextSlot&&(n.minContextSlot=t.minContextSlot),r&&(n.skipPreflight=r),i&&(n.preflightCommitment=i);const s=[e,n],o=await this._rpcRequest("sendTransaction",s),a=(0,v.vt)(o,Jn);if("error"in a){let e;throw"data"in a.error&&(e=a.error.data.logs),new Ie({action:r?"send":"simulate",signature:"",transactionMessage:a.error.message,logs:e})}return a.result}_wsOnOpen(){this._rpcWebSocketConnected=!0,this._rpcWebSocketHeartbeat=setInterval(()=>{(async()=>{try{await this._rpcWebSocket.notify("ping")}catch{}})()},5e3),this._updateSubscriptions()}_wsOnError(e){this._rpcWebSocketConnected=!1,console.error("ws error:",e.message)}_wsOnClose(e){this._rpcWebSocketConnected=!1,this._rpcWebSocketGeneration=(this._rpcWebSocketGeneration+1)%Number.MAX_SAFE_INTEGER,this._rpcWebSocketIdleTimeout&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null),this._rpcWebSocketHeartbeat&&(clearInterval(this._rpcWebSocketHeartbeat),this._rpcWebSocketHeartbeat=null),1e3!==e?(this._subscriptionCallbacksByServerSubscriptionId={},Object.entries(this._subscriptionsByHash).forEach(([e,t])=>{this._setSubscription(e,{...t,state:"pending"})})):this._updateSubscriptions()}_setSubscription(e,t){const n=this._subscriptionsByHash[e]?.state;if(this._subscriptionsByHash[e]=t,n!==t.state){const n=this._subscriptionStateChangeCallbacksByHash[e];n&&n.forEach(e=>{try{e(t.state)}catch{}})}}_onSubscriptionStateChange(e,t){const n=this._subscriptionHashByClientSubscriptionId[e];if(null==n)return()=>{};const r=this._subscriptionStateChangeCallbacksByHash[n]||=new Set;return r.add(t),()=>{r.delete(t),0===r.size&&delete this._subscriptionStateChangeCallbacksByHash[n]}}async _updateSubscriptions(){if(0===Object.keys(this._subscriptionsByHash).length)return void(this._rpcWebSocketConnected&&(this._rpcWebSocketConnected=!1,this._rpcWebSocketIdleTimeout=setTimeout(()=>{this._rpcWebSocketIdleTimeout=null;try{this._rpcWebSocket.close()}catch(e){e instanceof Error&&console.log(`Error when closing socket connection: ${e.message}`)}},500)));if(null!==this._rpcWebSocketIdleTimeout&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketConnected=!0),!this._rpcWebSocketConnected)return void this._rpcWebSocket.connect();const e=this._rpcWebSocketGeneration,t=()=>e===this._rpcWebSocketGeneration;await Promise.all(Object.keys(this._subscriptionsByHash).map(async e=>{const n=this._subscriptionsByHash[e];if(void 0!==n)switch(n.state){case"pending":case"unsubscribed":if(0===n.callbacks.size)return delete this._subscriptionsByHash[e],"unsubscribed"===n.state&&delete this._subscriptionCallbacksByServerSubscriptionId[n.serverSubscriptionId],void await this._updateSubscriptions();await(async()=>{const{args:r,method:i}=n;try{this._setSubscription(e,{...n,state:"subscribing"});const t=await this._rpcWebSocket.call(i,r);this._setSubscription(e,{...n,serverSubscriptionId:t,state:"subscribed"}),this._subscriptionCallbacksByServerSubscriptionId[t]=n.callbacks,await this._updateSubscriptions()}catch(s){if(console.error(`Received ${s instanceof Error?"":"JSON-RPC "}error calling \`${i}\``,{args:r,error:s}),!t())return;this._setSubscription(e,{...n,state:"pending"}),await this._updateSubscriptions()}})();break;case"subscribed":0===n.callbacks.size&&await(async()=>{const{serverSubscriptionId:r,unsubscribeMethod:i}=n;if(this._subscriptionsAutoDisposedByRpc.has(r))this._subscriptionsAutoDisposedByRpc.delete(r);else{this._setSubscription(e,{...n,state:"unsubscribing"}),this._setSubscription(e,{...n,state:"unsubscribing"});try{await this._rpcWebSocket.call(i,[r])}catch(s){if(s instanceof Error&&console.error(`${i} error:`,s.message),!t())return;return this._setSubscription(e,{...n,state:"subscribed"}),void await this._updateSubscriptions()}}this._setSubscription(e,{...n,state:"unsubscribed"}),await this._updateSubscriptions()})();break}}))}_handleServerNotification(e,t){const n=this._subscriptionCallbacksByServerSubscriptionId[e];void 0!==n&&n.forEach(e=>{try{e(...t)}catch(n){console.error(n)}})}_wsOnAccountNotification(e){const{result:t,subscription:n}=(0,v.vt)(e,en);this._handleServerNotification(n,[t.value,t.context])}_makeSubscription(e,t){const n=this._nextClientSubscriptionId++,r=De([e.method,t]),i=this._subscriptionsByHash[r];return void 0===i?this._subscriptionsByHash[r]={...e,args:t,callbacks:new Set([e.callback]),state:"pending"}:i.callbacks.add(e.callback),this._subscriptionHashByClientSubscriptionId[n]=r,this._subscriptionDisposeFunctionsByClientSubscriptionId[n]=async()=>{delete this._subscriptionDisposeFunctionsByClientSubscriptionId[n],delete this._subscriptionHashByClientSubscriptionId[n];const t=this._subscriptionsByHash[r];ie(void 0!==t,`Could not find a \`Subscription\` when tearing down client subscription #${n}`),t.callbacks.delete(e.callback),await this._updateSubscriptions()},this._updateSubscriptions(),n}onAccountChange(e,t,n){const{commitment:r,config:i}=ot(n),s=this._buildArgs([e.toBase58()],r||this._commitment||"finalized","base64",i);return this._makeSubscription({callback:t,method:"accountSubscribe",unsubscribeMethod:"accountUnsubscribe"},s)}async removeAccountChangeListener(e){await this._unsubscribeClientSubscription(e,"account change")}_wsOnProgramAccountNotification(e){const{result:t,subscription:n}=(0,v.vt)(e,nn);this._handleServerNotification(n,[{accountId:t.value.pubkey,accountInfo:t.value.account},t.context])}onProgramAccountChange(e,t,n,r){const{commitment:i,config:s}=ot(n),o=this._buildArgs([e.toBase58()],i||this._commitment||"finalized","base64",s||(r?{filters:at(r)}:void 0));return this._makeSubscription({callback:t,method:"programSubscribe",unsubscribeMethod:"programUnsubscribe"},o)}async removeProgramAccountChangeListener(e){await this._unsubscribeClientSubscription(e,"program account change")}onLogs(e,t,n){const r=this._buildArgs(["object"===typeof e?{mentions:[e.toString()]}:e],n||this._commitment||"finalized");return this._makeSubscription({callback:t,method:"logsSubscribe",unsubscribeMethod:"logsUnsubscribe"},r)}async removeOnLogsListener(e){await this._unsubscribeClientSubscription(e,"logs")}_wsOnLogsNotification(e){const{result:t,subscription:n}=(0,v.vt)(e,Xn);this._handleServerNotification(n,[t.value,t.context])}_wsOnSlotNotification(e){const{result:t,subscription:n}=(0,v.vt)(e,sn);this._handleServerNotification(n,[t])}onSlotChange(e){return this._makeSubscription({callback:e,method:"slotSubscribe",unsubscribeMethod:"slotUnsubscribe"},[])}async removeSlotChangeListener(e){await this._unsubscribeClientSubscription(e,"slot change")}_wsOnSlotUpdatesNotification(e){const{result:t,subscription:n}=(0,v.vt)(e,an);this._handleServerNotification(n,[t])}onSlotUpdate(e){return this._makeSubscription({callback:e,method:"slotsUpdatesSubscribe",unsubscribeMethod:"slotsUpdatesUnsubscribe"},[])}async removeSlotUpdateListener(e){await this._unsubscribeClientSubscription(e,"slot update")}async _unsubscribeClientSubscription(e,t){const n=this._subscriptionDisposeFunctionsByClientSubscriptionId[e];n?await n():console.warn(`Ignored unsubscribe request because an active subscription with id \`${e}\` for '${t}' events could not be found.`)}_buildArgs(e,t,n,r){const i=t||this._commitment;if(i||n||r){let t={};n&&(t.encoding=n),i&&(t.commitment=i),r&&(t=Object.assign(t,r)),e.push(t)}return e}_buildArgsAtLeastConfirmed(e,t,n,r){const i=t||this._commitment;if(i&&!["confirmed","finalized"].includes(i))throw new Error("Using Connection with default commitment: `"+this._commitment+"`, but method requires at least `confirmed`");return this._buildArgs(e,t,n,r)}_wsOnSignatureNotification(e){const{result:t,subscription:n}=(0,v.vt)(e,cn);"receivedSignature"!==t.value&&this._subscriptionsAutoDisposedByRpc.add(n),this._handleServerNotification(n,"receivedSignature"===t.value?[{type:"received"},t.context]:[{type:"status",result:t.value},t.context])}onSignature(e,t,n){const r=this._buildArgs([e],n||this._commitment||"finalized"),i=this._makeSubscription({callback:(e,n)=>{if("status"===e.type){t(e.result,n);try{this.removeSignatureListener(i)}catch(r){}}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},r);return i}onSignatureWithOptions(e,t,n){const{commitment:r,...i}={...n,commitment:n&&n.commitment||this._commitment||"finalized"},s=this._buildArgs([e],r,void 0,i),o=this._makeSubscription({callback:(e,n)=>{t(e,n);try{this.removeSignatureListener(o)}catch(r){}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},s);return o}async removeSignatureListener(e){await this._unsubscribeClientSubscription(e,"signature result")}_wsOnRootNotification(e){const{result:t,subscription:n}=(0,v.vt)(e,un);this._handleServerNotification(n,[t])}onRootChange(e){return this._makeSubscription({callback:e,method:"rootSubscribe",unsubscribeMethod:"rootUnsubscribe"},[])}async removeRootChangeListener(e){await this._unsubscribeClientSubscription(e,"root change")}}class er{constructor(e){this._keypair=void 0,this._keypair=e??E()}static generate(){return new er(E())}static fromSecretKey(e,t){if(64!==e.byteLength)throw new Error("bad secret key size");const n=e.slice(32,64);if(!t||!t.skipValidation){const t=e.slice(0,32),r=W(t);for(let e=0;e<32;e++)if(n[e]!==r[e])throw new Error("provided secretKey is invalid")}return new er({publicKey:n,secretKey:e})}static fromSeed(e){const t=W(e),n=new Uint8Array(64);return n.set(e),n.set(t,32),new er({publicKey:t,secretKey:n})}get publicKey(){return new Y(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}}const tr=Object.freeze({CreateLookupTable:{index:0,layout:d.w3([d.DH("instruction"),Ce("recentSlot"),d.u8("bumpSeed")])},FreezeLookupTable:{index:1,layout:d.w3([d.DH("instruction")])},ExtendLookupTable:{index:2,layout:d.w3([d.DH("instruction"),Ce(),d.O6(J(),d.cY(d.DH(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:d.w3([d.DH("instruction")])},CloseLookupTable:{index:4,layout:d.w3([d.DH("instruction")])}});class nr{constructor(){}static createLookupTable(e){const[t,n]=Y.findProgramAddressSync([e.authority.toBuffer(),w().encode(e.recentSlot)],this.programId),r=tr.CreateLookupTable,i=Be(r,{recentSlot:BigInt(e.recentSlot),bumpSeed:n}),s=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1},{pubkey:e.payer,isSigner:!0,isWritable:!0},{pubkey:Oe.programId,isSigner:!1,isWritable:!1}];return[new pe({programId:this.programId,keys:s,data:i}),t]}static freezeLookupTable(e){const t=tr.FreezeLookupTable,n=Be(t),r=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new pe({programId:this.programId,keys:r,data:n})}static extendLookupTable(e){const t=tr.ExtendLookupTable,n=Be(t,{addresses:e.addresses.map(e=>e.toBytes())}),r=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return e.payer&&r.push({pubkey:e.payer,isSigner:!0,isWritable:!0},{pubkey:Oe.programId,isSigner:!1,isWritable:!1}),new pe({programId:this.programId,keys:r,data:n})}static deactivateLookupTable(e){const t=tr.DeactivateLookupTable,n=Be(t),r=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new pe({programId:this.programId,keys:r,data:n})}static closeLookupTable(e){const t=tr.CloseLookupTable,n=Be(t),r=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1},{pubkey:e.recipient,isSigner:!1,isWritable:!0}];return new pe({programId:this.programId,keys:r,data:n})}}nr.programId=new Y("AddressLookupTab1e1111111111111111111111111");const rr=Object.freeze({RequestUnits:{index:0,layout:d.w3([d.u8("instruction"),d.DH("units"),d.DH("additionalFee")])},RequestHeapFrame:{index:1,layout:d.w3([d.u8("instruction"),d.DH("bytes")])},SetComputeUnitLimit:{index:2,layout:d.w3([d.u8("instruction"),d.DH("units")])},SetComputeUnitPrice:{index:3,layout:d.w3([d.u8("instruction"),Ce("microLamports")])}});class ir{constructor(){}static requestUnits(e){const t=rr.RequestUnits,n=Be(t,e);return new pe({keys:[],programId:this.programId,data:n})}static requestHeapFrame(e){const t=rr.RequestHeapFrame,n=Be(t,e);return new pe({keys:[],programId:this.programId,data:n})}static setComputeUnitLimit(e){const t=rr.SetComputeUnitLimit,n=Be(t,e);return new pe({keys:[],programId:this.programId,data:n})}static setComputeUnitPrice(e){const t=rr.SetComputeUnitPrice,n=Be(t,{microLamports:BigInt(e.microLamports)});return new pe({keys:[],programId:this.programId,data:n})}}ir.programId=new Y("ComputeBudget111111111111111111111111111111");const sr=64,or=32,ar=64,cr=d.w3([d.u8("numSignatures"),d.u8("padding"),d.NX("signatureOffset"),d.NX("signatureInstructionIndex"),d.NX("publicKeyOffset"),d.NX("publicKeyInstructionIndex"),d.NX("messageDataOffset"),d.NX("messageDataSize"),d.NX("messageInstructionIndex")]);class ur{constructor(){}static createInstructionWithPublicKey(e){const{publicKey:t,message:n,signature:i,instructionIndex:s}=e;ie(t.length===or,`Public Key must be ${or} bytes but received ${t.length} bytes`),ie(i.length===ar,`Signature must be ${ar} bytes but received ${i.length} bytes`);const o=cr.span,a=o+t.length,c=a+i.length,u=1,l=r.Buffer.alloc(c+n.length),d=null==s?65535:s;return cr.encode({numSignatures:u,padding:0,signatureOffset:a,signatureInstructionIndex:d,publicKeyOffset:o,publicKeyInstructionIndex:d,messageDataOffset:c,messageDataSize:n.length,messageInstructionIndex:d},l),l.fill(t,o),l.fill(i,a),l.fill(n,c),new pe({keys:[],programId:ur.programId,data:l})}static createInstructionWithPrivateKey(e){const{privateKey:t,message:n,instructionIndex:r}=e;ie(t.length===sr,`Private key must be ${sr} bytes but received ${t.length} bytes`);try{const e=er.fromSecretKey(t),i=e.publicKey.toBytes(),s=T(n,e.secretKey);return this.createInstructionWithPublicKey({publicKey:i,message:n,signature:s,instructionIndex:r})}catch(i){throw new Error(`Error creating instruction; ${i}`)}}}ur.programId=new Y("Ed25519SigVerify111111111111111111111111111");const lr=(e,t)=>{const n=B.bI.sign(e,t);return[n.toCompactRawBytes(),n.recovery]};B.bI.utils.isValidPrivateKey;const dr=B.bI.getPublicKey,hr=32,pr=20,gr=64,fr=11,mr=d.w3([d.u8("numSignatures"),d.NX("signatureOffset"),d.u8("signatureInstructionIndex"),d.NX("ethAddressOffset"),d.u8("ethAddressInstructionIndex"),d.NX("messageDataOffset"),d.NX("messageDataSize"),d.u8("messageInstructionIndex"),d.av(20,"ethAddress"),d.av(64,"signature"),d.u8("recoveryId")]);class yr{constructor(){}static publicKeyToEthAddress(e){ie(e.length===gr,`Public key must be ${gr} bytes but received ${e.length} bytes`);try{return r.Buffer.from((0,_.lY)(N(e))).slice(-pr)}catch(t){throw new Error(`Error constructing Ethereum address: ${t}`)}}static createInstructionWithPublicKey(e){const{publicKey:t,message:n,signature:r,recoveryId:i,instructionIndex:s}=e;return yr.createInstructionWithEthAddress({ethAddress:yr.publicKeyToEthAddress(t),message:n,signature:r,recoveryId:i,instructionIndex:s})}static createInstructionWithEthAddress(e){const{ethAddress:t,message:n,signature:i,recoveryId:s,instructionIndex:o=0}=e;let a;a="string"===typeof t?t.startsWith("0x")?r.Buffer.from(t.substr(2),"hex"):r.Buffer.from(t,"hex"):t,ie(a.length===pr,`Address must be ${pr} bytes but received ${a.length} bytes`);const c=1+fr,u=c,l=c+a.length,d=l+i.length+1,h=1,p=r.Buffer.alloc(mr.span+n.length);return mr.encode({numSignatures:h,signatureOffset:l,signatureInstructionIndex:o,ethAddressOffset:u,ethAddressInstructionIndex:o,messageDataOffset:d,messageDataSize:n.length,messageInstructionIndex:o,signature:N(i),ethAddress:N(a),recoveryId:s},p),p.fill(N(n),mr.span),new pe({keys:[],programId:yr.programId,data:p})}static createInstructionWithPrivateKey(e){const{privateKey:t,message:n,instructionIndex:i}=e;ie(t.length===hr,`Private key must be ${hr} bytes but received ${t.length} bytes`);try{const e=N(t),s=dr(e,!1).slice(1),o=r.Buffer.from((0,_.lY)(N(n))),[a,c]=lr(o,e);return this.createInstructionWithPublicKey({publicKey:s,message:n,signature:a,recoveryId:c,instructionIndex:i})}catch(s){throw new Error(`Error creating instruction; ${s}`)}}}var br;yr.programId=new Y("KeccakSecp256k11111111111111111111111111111");const wr=new Y("StakeConfig11111111111111111111111111111111");class kr{constructor(e,t,n){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=e,this.epoch=t,this.custodian=n}}br=kr,kr.default=new br(0,0,Y.default);const Sr=Object.freeze({Initialize:{index:0,layout:d.w3([d.DH("instruction"),X(),Z()])},Authorize:{index:1,layout:d.w3([d.DH("instruction"),J("newAuthorized"),d.DH("stakeAuthorizationType")])},Delegate:{index:2,layout:d.w3([d.DH("instruction")])},Split:{index:3,layout:d.w3([d.DH("instruction"),d.Wg("lamports")])},Withdraw:{index:4,layout:d.w3([d.DH("instruction"),d.Wg("lamports")])},Deactivate:{index:5,layout:d.w3([d.DH("instruction")])},Merge:{index:7,layout:d.w3([d.DH("instruction")])},AuthorizeWithSeed:{index:8,layout:d.w3([d.DH("instruction"),J("newAuthorized"),d.DH("stakeAuthorizationType"),G("authoritySeed"),J("authorityOwner")])}});Object.freeze({Staker:{index:0},Withdrawer:{index:1}});class vr{constructor(){}static initialize(e){const{stakePubkey:t,authorized:n,lockup:r}=e,i=r||kr.default,s=Sr.Initialize,o=Be(s,{authorized:{staker:N(n.staker.toBuffer()),withdrawer:N(n.withdrawer.toBuffer())},lockup:{unixTimestamp:i.unixTimestamp,epoch:i.epoch,custodian:N(i.custodian.toBuffer())}}),a={keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Se,isSigner:!1,isWritable:!1}],programId:this.programId,data:o};return new pe(a)}static createAccountWithSeed(e){const t=new ge;t.add(Oe.createAccountWithSeed({fromPubkey:e.fromPubkey,newAccountPubkey:e.stakePubkey,basePubkey:e.basePubkey,seed:e.seed,lamports:e.lamports,space:this.space,programId:this.programId}));const{stakePubkey:n,authorized:r,lockup:i}=e;return t.add(this.initialize({stakePubkey:n,authorized:r,lockup:i}))}static createAccount(e){const t=new ge;t.add(Oe.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.stakePubkey,lamports:e.lamports,space:this.space,programId:this.programId}));const{stakePubkey:n,authorized:r,lockup:i}=e;return t.add(this.initialize({stakePubkey:n,authorized:r,lockup:i}))}static delegate(e){const{stakePubkey:t,authorizedPubkey:n,votePubkey:r}=e,i=Sr.Delegate,s=Be(i);return(new ge).add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!1},{pubkey:we,isSigner:!1,isWritable:!1},{pubkey:ve,isSigner:!1,isWritable:!1},{pubkey:wr,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:s})}static authorize(e){const{stakePubkey:t,authorizedPubkey:n,newAuthorizedPubkey:r,stakeAuthorizationType:i,custodianPubkey:s}=e,o=Sr.Authorize,a=Be(o,{newAuthorized:N(r.toBuffer()),stakeAuthorizationType:i.index}),c=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:we,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return s&&c.push({pubkey:s,isSigner:!0,isWritable:!1}),(new ge).add({keys:c,programId:this.programId,data:a})}static authorizeWithSeed(e){const{stakePubkey:t,authorityBase:n,authoritySeed:r,authorityOwner:i,newAuthorizedPubkey:s,stakeAuthorizationType:o,custodianPubkey:a}=e,c=Sr.AuthorizeWithSeed,u=Be(c,{newAuthorized:N(s.toBuffer()),stakeAuthorizationType:o.index,authoritySeed:r,authorityOwner:N(i.toBuffer())}),l=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1},{pubkey:we,isSigner:!1,isWritable:!1}];return a&&l.push({pubkey:a,isSigner:!0,isWritable:!1}),(new ge).add({keys:l,programId:this.programId,data:u})}static splitInstruction(e){const{stakePubkey:t,authorizedPubkey:n,splitStakePubkey:r,lamports:i}=e,s=Sr.Split,o=Be(s,{lamports:i});return new pe({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}static split(e,t){const n=new ge;return n.add(Oe.createAccount({fromPubkey:e.authorizedPubkey,newAccountPubkey:e.splitStakePubkey,lamports:t,space:this.space,programId:this.programId})),n.add(this.splitInstruction(e))}static splitWithSeed(e,t){const{stakePubkey:n,authorizedPubkey:r,splitStakePubkey:i,basePubkey:s,seed:o,lamports:a}=e,c=new ge;return c.add(Oe.allocate({accountPubkey:i,basePubkey:s,seed:o,space:this.space,programId:this.programId})),t&&t>0&&c.add(Oe.transfer({fromPubkey:e.authorizedPubkey,toPubkey:i,lamports:t})),c.add(this.splitInstruction({stakePubkey:n,authorizedPubkey:r,splitStakePubkey:i,lamports:a}))}static merge(e){const{stakePubkey:t,sourceStakePubKey:n,authorizedPubkey:r}=e,i=Sr.Merge,s=Be(i);return(new ge).add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!0},{pubkey:we,isSigner:!1,isWritable:!1},{pubkey:ve,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:s})}static withdraw(e){const{stakePubkey:t,authorizedPubkey:n,toPubkey:r,lamports:i,custodianPubkey:s}=e,o=Sr.Withdraw,a=Be(o,{lamports:i}),c=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:we,isSigner:!1,isWritable:!1},{pubkey:ve,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return s&&c.push({pubkey:s,isSigner:!0,isWritable:!1}),(new ge).add({keys:c,programId:this.programId,data:a})}static deactivate(e){const{stakePubkey:t,authorizedPubkey:n}=e,r=Sr.Deactivate,i=Be(r);return(new ge).add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:we,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:i})}}vr.programId=new Y("Stake11111111111111111111111111111111111111"),vr.space=200;const Ir=Object.freeze({InitializeAccount:{index:0,layout:d.w3([d.DH("instruction"),Q()])},Authorize:{index:1,layout:d.w3([d.DH("instruction"),J("newAuthorized"),d.DH("voteAuthorizationType")])},Withdraw:{index:3,layout:d.w3([d.DH("instruction"),d.Wg("lamports")])},UpdateValidatorIdentity:{index:4,layout:d.w3([d.DH("instruction")])},AuthorizeWithSeed:{index:10,layout:d.w3([d.DH("instruction"),ee()])}});Object.freeze({Voter:{index:0},Withdrawer:{index:1}});class Ar{constructor(){}static initializeAccount(e){const{votePubkey:t,nodePubkey:n,voteInit:r}=e,i=Ir.InitializeAccount,s=Be(i,{voteInit:{nodePubkey:N(r.nodePubkey.toBuffer()),authorizedVoter:N(r.authorizedVoter.toBuffer()),authorizedWithdrawer:N(r.authorizedWithdrawer.toBuffer()),commission:r.commission}}),o={keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Se,isSigner:!1,isWritable:!1},{pubkey:we,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:s};return new pe(o)}static createAccount(e){const t=new ge;return t.add(Oe.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.votePubkey,lamports:e.lamports,space:this.space,programId:this.programId})),t.add(this.initializeAccount({votePubkey:e.votePubkey,nodePubkey:e.voteInit.nodePubkey,voteInit:e.voteInit}))}static authorize(e){const{votePubkey:t,authorizedPubkey:n,newAuthorizedPubkey:r,voteAuthorizationType:i}=e,s=Ir.Authorize,o=Be(s,{newAuthorized:N(r.toBuffer()),voteAuthorizationType:i.index}),a=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:we,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return(new ge).add({keys:a,programId:this.programId,data:o})}static authorizeWithSeed(e){const{currentAuthorityDerivedKeyBasePubkey:t,currentAuthorityDerivedKeyOwnerPubkey:n,currentAuthorityDerivedKeySeed:r,newAuthorizedPubkey:i,voteAuthorizationType:s,votePubkey:o}=e,a=Ir.AuthorizeWithSeed,c=Be(a,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:N(n.toBuffer()),currentAuthorityDerivedKeySeed:r,newAuthorized:N(i.toBuffer()),voteAuthorizationType:s.index}}),u=[{pubkey:o,isSigner:!1,isWritable:!0},{pubkey:we,isSigner:!1,isWritable:!1},{pubkey:t,isSigner:!0,isWritable:!1}];return(new ge).add({keys:u,programId:this.programId,data:c})}static withdraw(e){const{votePubkey:t,authorizedWithdrawerPubkey:n,lamports:r,toPubkey:i}=e,s=Ir.Withdraw,o=Be(s,{lamports:r}),a=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return(new ge).add({keys:a,programId:this.programId,data:o})}static safeWithdraw(e,t,n){if(e.lamports>t-n)throw new Error("Withdraw will leave vote account with insufficient funds.");return Ar.withdraw(e)}static updateValidatorIdentity(e){const{votePubkey:t,authorizedWithdrawerPubkey:n,nodePubkey:r}=e,i=Ir.UpdateValidatorIdentity,s=Be(i),o=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return(new ge).add({keys:o,programId:this.programId,data:s})}}Ar.programId=new Y("Vote111111111111111111111111111111111111111"),Ar.space=3762;new Y("Va1idator1nfo111111111111111111111111111111"),(0,v.NW)({name:(0,v.Yj)(),website:(0,v.lq)((0,v.Yj)()),details:(0,v.lq)((0,v.Yj)()),iconUrl:(0,v.lq)((0,v.Yj)()),keybaseUsername:(0,v.lq)((0,v.Yj)())});new Y("Vote111111111111111111111111111111111111111"),d.w3([J("nodePubkey"),J("authorizedWithdrawer"),d.u8("commission"),d.I0(),d.O6(d.w3([d.I0("slot"),d.DH("confirmationCount")]),d.cY(d.DH(),-8),"votes"),d.u8("rootSlotValid"),d.I0("rootSlot"),d.I0(),d.O6(d.w3([d.I0("epoch"),J("authorizedVoter")]),d.cY(d.DH(),-8),"authorizedVoters"),d.w3([d.O6(d.w3([J("authorizedPubkey"),d.I0("epochOfLastAuthorizedSwitch"),d.I0("targetEpoch")]),32,"buf"),d.I0("idx"),d.u8("isEmpty")],"priorVoters"),d.I0(),d.O6(d.w3([d.I0("epoch"),d.I0("credits"),d.I0("prevCredits")]),d.cY(d.DH(),-8),"epochCredits"),d.w3([d.I0("slot"),d.I0("timestamp")],"lastTimestamp")]);const xr=1e9},21498:(e,t,n)=>{"use strict";n.d(t,{Ob:()=>u});var r=n(601),i=n(27630),s=n(20079);if(185!=n.j)var o=n(49215);if(185!=n.j)var a=n(9683);n(48287)["Buffer"];const c=(0,r.w3)([(0,r.DH)("mintAuthorityOption"),(0,i.jE)("mintAuthority"),(0,i._l)("supply"),(0,r.u8)("decimals"),(0,i.lc)("isInitialized"),(0,r.DH)("freezeAuthorityOption"),(0,i.jE)("freezeAuthority")]);c.span;async function u(e,t,n=!1,r=o.x5,i=o.EK){if(!n&&!s.J3.isOnCurve(t.toBuffer()))throw new a.lu;const[c]=await s.J3.findProgramAddress([t.toBuffer(),r.toBuffer(),e.toBuffer()],i);return c}},26227:(e,t,n)=>{"use strict";var r;n.d(t,{_:()=>r}),function(e){e[e["InitializeMint"]=0]="InitializeMint",e[e["InitializeAccount"]=1]="InitializeAccount",e[e["InitializeMultisig"]=2]="InitializeMultisig",e[e["Transfer"]=3]="Transfer",e[e["Approve"]=4]="Approve",e[e["Revoke"]=5]="Revoke",e[e["SetAuthority"]=6]="SetAuthority",e[e["MintTo"]=7]="MintTo",e[e["Burn"]=8]="Burn",e[e["CloseAccount"]=9]="CloseAccount",e[e["FreezeAccount"]=10]="FreezeAccount",e[e["ThawAccount"]=11]="ThawAccount",e[e["TransferChecked"]=12]="TransferChecked",e[e["ApproveChecked"]=13]="ApproveChecked",e[e["MintToChecked"]=14]="MintToChecked",e[e["BurnChecked"]=15]="BurnChecked",e[e["InitializeAccount2"]=16]="InitializeAccount2",e[e["SyncNative"]=17]="SyncNative",e[e["InitializeAccount3"]=18]="InitializeAccount3",e[e["InitializeMultisig2"]=19]="InitializeMultisig2",e[e["InitializeMint2"]=20]="InitializeMint2",e[e["GetAccountDataSize"]=21]="GetAccountDataSize",e[e["InitializeImmutableOwner"]=22]="InitializeImmutableOwner",e[e["AmountToUiAmount"]=23]="AmountToUiAmount",e[e["UiAmountToAmount"]=24]="UiAmountToAmount",e[e["InitializeMintCloseAuthority"]=25]="InitializeMintCloseAuthority",e[e["TransferFeeExtension"]=26]="TransferFeeExtension",e[e["ConfidentialTransferExtension"]=27]="ConfidentialTransferExtension",e[e["DefaultAccountStateExtension"]=28]="DefaultAccountStateExtension",e[e["Reallocate"]=29]="Reallocate",e[e["MemoTransferExtension"]=30]="MemoTransferExtension",e[e["CreateNativeMint"]=31]="CreateNativeMint",e[e["InitializeNonTransferableMint"]=32]="InitializeNonTransferableMint",e[e["InterestBearingMintExtension"]=33]="InterestBearingMintExtension",e[e["CpiGuardExtension"]=34]="CpiGuardExtension",e[e["InitializePermanentDelegate"]=35]="InitializePermanentDelegate",e[e["TransferHookExtension"]=36]="TransferHookExtension",e[e["MetadataPointerExtension"]=39]="MetadataPointerExtension",e[e["GroupPointerExtension"]=40]="GroupPointerExtension",e[e["GroupMemberPointerExtension"]=41]="GroupMemberPointerExtension",e[e["ScaledUiAmountExtension"]=43]="ScaledUiAmountExtension",e[e["PausableExtension"]=44]="PausableExtension"}(r||(r={}))},27630:(e,t,n)=>{"use strict";n.d(t,{lc:()=>d,jE:()=>p,_l:()=>u});var r=n(601),i=n(30184),s=n(10898),o=n(48287)["Buffer"];const a=e=>t=>{const n=(0,r.av)(e,t),{encode:a,decode:c}=(0,s.P)(n),u=n;return u.decode=(e,t)=>{const n=c(e,t);return(0,i.k5)(o.from(n))},u.encode=(t,n,r)=>{const s=(0,i.Bq)(t,e);return a(s,n,r)},u},c=e=>t=>{const n=(0,r.av)(e,t),{encode:a,decode:c}=(0,s.P)(n),u=n;return u.decode=(e,t)=>{const n=c(e,t);return(0,i.cI)(o.from(n))},u.encode=(t,n,r)=>{const s=(0,i.zy)(t,e);return a(s,n,r)},u},u=a(8);c(8),a(16),c(16),a(24),c(24),a(32),c(32);var l=n(60346);new l.A("1e+18");const d=e=>{const t=(0,r.u8)(e),{encode:n,decode:i}=(0,s.P)(t),o=t;return o.decode=(e,t)=>{const n=i(e,t);return!!n},o.encode=(e,t,r)=>{const i=Number(e);return n(i,t,r)},o};var h=n(20079);const p=e=>{const t=(0,r.av)(32,e),{encode:n,decode:i}=(0,s.P)(t),o=t;return o.decode=(e,t)=>{const n=i(e,t);return new h.J3(n)},o.encode=(e,t,r)=>{const i=e.toBuffer();return n(i,t,r)},o}},36027:(e,t,n)=>{"use strict";n.d(t,{CvZ:()=>s,Ot7:()=>r,SHY:()=>a,Uq4:()=>o,Uyo:()=>i,hMG:()=>c,tsw:()=>p});var r=8078e3,i=8078001,s=8078004,o=8078005,a=8078006,c=8078011;function u(e){if(Array.isArray(e)){const t=e.map(u).join("%2C%20");return"%5B"+t+"%5D"}return"bigint"===typeof e?`${e}n`:encodeURIComponent(String(null!=e&&null===Object.getPrototypeOf(e)?{...e}:e))}function l([e,t]){return`${e}=${u(t)}`}function d(e){const t=Object.entries(e).map(l).join("&");return btoa(t)}function h(e,t={}){{let n=`Solana error #${e}; Decode this error by running \`npx @solana/errors decode -- ${e}`;return Object.keys(t).length&&(n+=` '${d(t)}'`),`${n}\``}}var p=class extends Error{cause=this.cause;context;constructor(...[e,t]){let n,r;if(t){const{cause:e,...i}=t;e&&(r={cause:e}),Object.keys(i).length>0&&(n=i)}const i=h(e,n);super(i,r),this.context={__code:e,...n},this.name="SolanaError"}}},43466:(e,t,n)=>{var r=n(15621),i="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";e.exports=r(i)},44675:(e,t,n)=>{"use strict";n.d(t,{C3:()=>d});var r=n(601),i=n(27630),s=n(20079);if(185!=n.j)var o=n(49215);if(185!=n.j)var a=n(14753);if(185!=n.j)var c=n(26227);var u=n(48287)["Buffer"];const l=(0,r.w3)([(0,r.u8)("instruction"),(0,i._l)("amount")]);function d(e,t,n,r,i=[],d=o.x5){const h=(0,a.d)([{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:t,isSigner:!1,isWritable:!0}],n,i),p=u.alloc(l.span);return l.encode({instruction:c._.Transfer,amount:BigInt(r)},p),new s.fH({keys:h,programId:d,data:p})}},49215:(e,t,n)=>{"use strict";n.d(t,{EK:()=>s,x5:()=>i});var r=n(20079);const i=new r.J3("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"),s=(new r.J3("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"),new r.J3("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"));new r.J3("So11111111111111111111111111111111111111112"),new r.J3("9pan9bMn5HatX4EJdBwg9VgCa7Uz5HL8N1m5D3NdXejP")},72271:(e,t,n)=>{"use strict";var r=n(70453),i=n(36556),s=n(58859),o=n(80507),a=n(69675),c=r("%WeakMap%",!0),u=i("WeakMap.prototype.get",!0),l=i("WeakMap.prototype.set",!0),d=i("WeakMap.prototype.has",!0),h=i("WeakMap.prototype.delete",!0);e.exports=c?function(){var e,t,n={assert:function(e){if(!n.has(e))throw new a("Side channel does not contain "+s(e))},delete:function(n){if(c&&n&&("object"===typeof n||"function"===typeof n)){if(e)return h(e,n)}else if(o&&t)return t["delete"](n);return!1},get:function(n){return c&&n&&("object"===typeof n||"function"===typeof n)&&e?u(e,n):t&&t.get(n)},has:function(n){return c&&n&&("object"===typeof n||"function"===typeof n)&&e?d(e,n):!!t&&t.has(n)},set:function(n,r){c&&n&&("object"===typeof n||"function"===typeof n)?(e||(e=new c),l(e,n,r)):o&&(t||(t=o()),t.set(n,r))}};return n}:o},80507:(e,t,n)=>{"use strict";var r=n(70453),i=n(36556),s=n(58859),o=n(69675),a=r("%Map%",!0),c=i("Map.prototype.get",!0),u=i("Map.prototype.set",!0),l=i("Map.prototype.has",!0),d=i("Map.prototype.delete",!0),h=i("Map.prototype.size",!0);e.exports=!!a&&function(){var e,t={assert:function(e){if(!t.has(e))throw new o("Side channel does not contain "+s(e))},delete:function(t){if(e){var n=d(e,t);return 0===h(e)&&(e=void 0),n}return!1},get:function(t){if(e)return c(e,t)},has:function(t){return!!e&&l(e,t)},set:function(t,n){e||(e=new a),u(e,t,n)}};return t}}}]);