(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)},1539(e,t,n){"use strict";n.d(t,{Ng:()=>fr,AX:()=>mr,Sr:()=>Yr,J3:()=>re,yq:()=>Ge,ZX:()=>Pe,fH:()=>We});var r=n(48287),i=n(55878),s=n(39404),o=n.n(s),a=n(43466),c=n.n(a),u=n(78226),l=n(92755),d=n(601),h=8078e3,p=8078001,g=8078004,f=8078005,m=8078006,y=8078011;function b(e){if(Array.isArray(e)){const t=e.map(b).join("%2C%20");return"%5B"+t+"%5D"}return"bigint"===typeof e?`${e}n`:encodeURIComponent(String(null!=e&&null===Object.getPrototypeOf(e)?{...e}:e))}function w([e,t]){return`${e}=${b(t)}`}function k(e){const t=Object.entries(e).map(w).join("&");return btoa(t)}function S(e,t={}){{let n=`Solana error #${e}; Decode this error by running \`npx @solana/errors decode -- ${e}`;return Object.keys(t).length&&(n+=` '${k(t)}'`),`${n}\``}}var v=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=S(e,n);super(i,r),this.context={__code:e,...n},this.name="SolanaError"}};function I(e,t){return"fixedSize"in t?t.fixedSize:t.getSizeFromValue(e)}function A(e){return Object.freeze({...e,encode:t=>{const n=new Uint8Array(I(t,e));return e.write(t,n,0),n}})}function x(e){return Object.freeze({...e,decode:(t,n=0)=>e.read(t,n)[0]})}function _(e){return"fixedSize"in e&&"number"===typeof e.fixedSize}function B(e,t){if(_(e)!==_(t))throw new v(g);if(_(e)&&_(t)&&e.fixedSize!==t.fixedSize)throw new v(f,{decoderFixedSize:t.fixedSize,encoderFixedSize:e.fixedSize});if(!_(e)&&!_(t)&&e.maxSize!==t.maxSize)throw new v(m,{decoderMaxSize:t.maxSize,encoderMaxSize:e.maxSize});return{...t,...e,decode:t.decode,encode:e.encode,read:t.read,write:e.write}}function E(e,t,n=0){if(t.length-n<=0)throw new v(h,{codecDescription:e})}function W(e,t,n,r=0){const i=n.length-r;if(i<t)throw new v(p,{bytesLength:i,codecDescription:e,expected:t})}function P(e,t,n,r){if(r<t||r>n)throw new v(y,{codecDescription:e,max:n,min:t,value:r})}function T(e){return 1!==e?.endian}function C(e){return A({fixedSize:e.size,write(t,n,r){e.range&&P(e.name,e.range[0],e.range[1],t);const i=new ArrayBuffer(e.size);return e.set(new DataView(i),t,T(e.config)),n.set(new Uint8Array(i),r),r+e.size}})}function N(e){return x({fixedSize:e.size,read(t,n=0){E(e.name,t,n),W(e.name,e.size,t,n);const r=new DataView(O(t,n,e.size));return[e.get(r,T(e.config)),n+e.size]}})}function O(e,t,n){const r=e.byteOffset+(t??0),i=n??e.byteLength;return e.buffer.slice(r,r+i)}var z=(e={})=>C({config:e,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(e,t,n)=>e.setBigUint64(0,BigInt(t),n),size:8}),L=(e={})=>N({config:e,get:(e,t)=>e.getBigUint64(0,t),name:"u64",size:8}),K=(e={})=>B(z(e),L(e)),R=n(2150),j=n(40022),q=n.n(j),Y=n(5079),D=n(77238),M=n(46128);i.ev.utils.randomPrivateKey;const H=()=>{const e=i.ev.utils.randomPrivateKey(),t=U(e),n=new Uint8Array(64);return n.set(e),n.set(t,32),{publicKey:t,secretKey:n}},U=i.ev.getPublicKey;function F(e){try{return i.ev.ExtendedPoint.fromHex(e),!0}catch{return!1}}const $=(e,t)=>i.ev.sign(e,t.slice(0,32)),V=i.ev.verify,J=e=>r.Buffer.isBuffer(e)?e:e instanceof Uint8Array?r.Buffer.from(e.buffer,e.byteOffset,e.byteLength):r.Buffer.from(e);class G{constructor(e){Object.assign(this,e)}encode(){return r.Buffer.from((0,l.serialize)(X,this))}static decode(e){return(0,l.deserialize)(X,this,e)}static decodeUnchecked(e){return(0,l.deserializeUnchecked)(X,this,e)}}const X=new Map;var Q;const Z=32,ee=32;function te(e){return void 0!==e._bn}let ne=1;class re extends G{constructor(e){if(super({}),this._bn=void 0,te(e))this._bn=e._bn;else{if("string"===typeof e){const t=c().decode(e);if(t.length!=ee)throw new Error("Invalid public key input");this._bn=new(o())(t)}else this._bn=new(o())(e);if(this._bn.byteLength()>ee)throw new Error("Invalid public key input")}}static unique(){const e=new re(ne);return ne+=1,new re(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===ee)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 re(s)}static createProgramAddressSync(e,t){let n=r.Buffer.alloc(0);e.forEach(function(e){if(e.length>Z)throw new TypeError("Max seed length exceeded");n=r.Buffer.concat([n,J(e)])}),n=r.Buffer.concat([n,t.toBuffer(),r.Buffer.from("ProgramDerivedAddress")]);const i=(0,u.sc)(n);if(F(i))throw new Error("Invalid seeds, address must fall off the curve");return new re(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 re(e);return F(t.toBytes())}}Q=re,re.default=new Q("11111111111111111111111111111111"),X.set(re,{kind:"struct",fields:[["_bn","u256"]]});new re("BPFLoader1111111111111111111111111111111111");const ie=1232,se=127,oe=64;class ae extends Error{constructor(e){super(`Signature ${e} has expired: block height exceeded.`),this.signature=void 0,this.signature=e}}Object.defineProperty(ae.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});class ce 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(ce.prototype,"name",{value:"TransactionExpiredTimeoutError"});class ue extends Error{constructor(e){super(`Signature ${e} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=e}}Object.defineProperty(ue.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});class le{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 de=(e="publicKey")=>d.av(32,e),he=(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},pe=(e="authorized")=>d.w3([de("staker"),de("withdrawer")],e),ge=(e="lockup")=>d.w3([d.Wg("unixTimestamp"),d.Wg("epoch"),de("custodian")],e),fe=(e="voteInit")=>d.w3([de("nodePubkey"),de("authorizedVoter"),de("authorizedWithdrawer"),d.u8("commission")],e),me=(e="voteAuthorizeWithSeedArgs")=>d.w3([d.DH("voteAuthorizationType"),de("currentAuthorityDerivedKeyOwnerPubkey"),he("currentAuthorityDerivedKeySeed"),de("newAuthorized")],e);function ye(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 ye({layout:e},t[e.property]);return 0};let r=0;return e.layout.fields.forEach(e=>{r+=n(e)}),r}function be(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 we(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 ke(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()];ke(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};{ke(t.length>0,"Expected at least one writable signer key");const[e]=t[0];ke(e===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}const o=[...t.map(([e])=>new re(e)),...n.map(([e])=>new re(e)),...r.map(([e])=>new re(e)),...i.map(([e])=>new re(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 re(i),s=e.findIndex(e=>e.equals(t));s>=0&&(ke(s<256,"Max lookup table index exceeded"),n.push(s),r.push(t),this.keyMetaMap.delete(i))}return[n,r]}}const ve="Reached end of buffer unexpectedly";function Ie(e){if(0===e.length)throw new Error(ve);return e.shift()}function Ae(e,...t){const[n]=t;if(2===t.length?n+(t[1]??0)>e.length:n>=e.length)throw new Error(ve);return e.splice(...t)}class xe{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 re(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 le(this.staticAccountKeys)}static compile(e){const t=Se.compile(e.instructions,e.payerKey),[n,r]=t.getMessageComponents(),i=new le(r),s=i.compileInstructions(e.instructions).map(e=>({programIdIndex:e.programIdIndex,accounts:e.accountKeyIndexes,data:c().encode(e.data)}));return new xe({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=[];we(t,e);const n=this.instructions.map(e=>{const{accounts:t,programIdIndex:n}=e,i=Array.from(c().decode(e.data));let s=[];we(s,t.length);let o=[];return we(o,i.length),{programIdIndex:n,keyIndicesCount:r.Buffer.from(s),keyIndices:t,dataLength:r.Buffer.from(o),data:i}});let i=[];we(i,n.length);let s=r.Buffer.alloc(ie);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(de("key"),e,"keys"),de("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=>J(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=Ie(t);if(n!==(n&se))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const i=Ie(t),s=Ie(t),o=be(t);let a=[];for(let c=0;c<o;c++){const e=Ae(t,0,ee);a.push(new re(r.Buffer.from(e)))}const u=Ae(t,0,ee),l=be(t);let d=[];for(let p=0;p<l;p++){const e=Ie(t),n=be(t),i=Ae(t,0,n),s=be(t),o=Ae(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 xe(h)}}class _e{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 le(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 le(o,r),c=a.compileInstructions(e.instructions);return new _e({header:s,staticAccountKeys:o,recentBlockhash:e.recentBlockhash,compiledInstructions:c,addressTableLookups:n})}serialize(){const e=Array();we(e,this.staticAccountKeys.length);const t=this.serializeInstructions(),n=Array();we(n,this.compiledInstructions.length);const r=this.serializeAddressTableLookups(),i=Array();we(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(de(),this.staticAccountKeys.length,"staticAccountKeys"),de("recentBlockhash"),d.av(n.length,"instructionsLength"),d.av(t.length,"serializedInstructions"),d.av(i.length,"addressTableLookupsLength"),d.av(r.length,"serializedAddressTableLookups")]),o=new Uint8Array(ie),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(ie);for(const n of this.compiledInstructions){const r=Array();we(r,n.accountKeyIndexes.length);const i=Array();we(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(ie);for(const n of this.addressTableLookups){const r=Array();we(r,n.writableIndexes.length);const i=Array();we(i,n.readonlyIndexes.length);const s=d.w3([de("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=Ie(t),r=n&se;ke(n!==r,"Expected versioned message but received legacy message");const i=r;ke(0===i,`Expected versioned message with version 0 but found version ${i}`);const s={numRequiredSignatures:Ie(t),numReadonlySignedAccounts:Ie(t),numReadonlyUnsignedAccounts:Ie(t)},o=[],a=be(t);for(let c=0;c<a;c++)o.push(new re(Ae(t,0,ee)));const u=c().encode(Ae(t,0,ee)),l=be(t),d=[];for(let c=0;c<l;c++){const e=Ie(t),n=be(t),r=Ae(t,0,n),i=be(t),s=new Uint8Array(Ae(t,0,i));d.push({programIdIndex:e,accountKeyIndexes:r,data:s})}const h=be(t),p=[];for(let c=0;c<h;c++){const e=new re(Ae(t,0,ee)),n=be(t),r=Ae(t,0,n),i=be(t),s=Ae(t,0,i);p.push({accountKey:e,writableIndexes:r,readonlyIndexes:s})}return new _e({header:s,staticAccountKeys:o,recentBlockhash:u,compiledInstructions:d,addressTableLookups:p})}}let Be=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 Ee=r.Buffer.alloc(oe).fill(0);class We{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 Pe{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 We(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 re(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=>{ke(e.programIdIndex>=0),e.accounts.forEach(e=>ke(e>=0))}),new xe({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=$(n,e.secretKey);this._addSignature(e.publicKey,J(t))})}addSignature(e,t){this._compile(),this._addSignature(e,t)}_addSignature(e,t){ke(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):V(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=[];we(n,t.length);const i=n.length+64*t.length+e.length,s=r.Buffer.alloc(i);return ke(t.length<256),r.Buffer.from(n).copy(s,0),t.forEach(({signature:e},t)=>{null!==e&&(ke(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),ke(s.length<=ie,`Transaction too large: ${s.length} > ${ie}`),s}get keys(){return ke(1===this.instructions.length),this.instructions[0].keys.map(e=>e.pubkey)}get programId(){return ke(1===this.instructions.length),this.instructions[0].programId}get data(){return ke(1===this.instructions.length),this.instructions[0].data}static from(e){let t=[...e];const n=be(t);let i=[];for(let s=0;s<n;s++){const e=Ae(t,0,oe);i.push(c().encode(r.Buffer.from(e)))}return Pe.populate(xe.from(t),i)}static populate(e,t=[]){const n=new Pe;return n.recentBlockhash=e.recentBlockhash,e.header.numRequiredSignatures>0&&(n.feePayer=e.accountKeys[0]),t.forEach((t,r)=>{const i={signature:t==c().encode(Ee)?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 We({keys:r,programId:e.accountKeys[t.programIdIndex],data:c().decode(t.data)}))}),n._message=e,n._json=n.toJSON(),n}}const Te=160,Ce=64,Ne=Te/Ce,Oe=1e3/Ne,ze=new re("SysvarC1ock11111111111111111111111111111111"),Le=(new re("SysvarEpochSchedu1e111111111111111111111111"),new re("Sysvar1nstructions1111111111111111111111111"),new re("SysvarRecentB1ockHashes11111111111111111111")),Ke=new re("SysvarRent111111111111111111111111111111111"),Re=(new re("SysvarRewards111111111111111111111111111111"),new re("SysvarS1otHashes111111111111111111111111111"),new re("SysvarS1otHistory11111111111111111111111111"),new re("SysvarStakeHistory1111111111111111111111111"));class je 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 qe 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 Ye(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 je({action:"send",signature:s,transactionMessage:`Status: (${JSON.stringify(o)})`});throw new Error(`Transaction ${s} failed (${JSON.stringify(o)})`)}return s}function De(e){return new Promise(t=>setTimeout(t,e))}function Me(e,t){const n=e.layout.span>=0?e.layout.span:ye(e,t),i=r.Buffer.alloc(n),s=Object.assign({instruction:e.index},t);return e.layout.encode(s,i),i}const He=d.I0("lamportsPerSignature"),Ue=d.w3([d.DH("version"),d.DH("state"),de("authorizedPubkey"),de("nonce"),d.w3([He],"feeCalculator")]),Fe=Ue.span;class $e{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=Ue.decode(J(e),0);return new $e({authorizedPubkey:new re(t.authorizedPubkey),nonce:new re(t.nonce).toString(),feeCalculator:t.feeCalculator})}}function Ve(e){const t=(0,d.av)(8,e),n=t.decode.bind(t),r=t.encode.bind(t),i=t,s=K();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 Je=Object.freeze({Create:{index:0,layout:d.w3([d.DH("instruction"),d.Wg("lamports"),d.Wg("space"),de("programId")])},Assign:{index:1,layout:d.w3([d.DH("instruction"),de("programId")])},Transfer:{index:2,layout:d.w3([d.DH("instruction"),Ve("lamports")])},CreateWithSeed:{index:3,layout:d.w3([d.DH("instruction"),de("base"),he("seed"),d.Wg("lamports"),d.Wg("space"),de("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"),de("authorized")])},AuthorizeNonceAccount:{index:7,layout:d.w3([d.DH("instruction"),de("authorized")])},Allocate:{index:8,layout:d.w3([d.DH("instruction"),d.Wg("space")])},AllocateWithSeed:{index:9,layout:d.w3([d.DH("instruction"),de("base"),he("seed"),d.Wg("space"),de("programId")])},AssignWithSeed:{index:10,layout:d.w3([d.DH("instruction"),de("base"),he("seed"),de("programId")])},TransferWithSeed:{index:11,layout:d.w3([d.DH("instruction"),Ve("lamports"),he("seed"),de("programId")])},UpgradeNonceAccount:{index:12,layout:d.w3([d.DH("instruction")])}});class Ge{constructor(){}static createAccount(e){const t=Je.Create,n=Me(t,{lamports:e.lamports,space:e.space,programId:J(e.programId.toBuffer())});return new We({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=Je.TransferWithSeed;t=Me(r,{lamports:BigInt(e.lamports),seed:e.seed,programId:J(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=Je.Transfer;t=Me(r,{lamports:BigInt(e.lamports)}),n=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}return new We({keys:n,programId:this.programId,data:t})}static assign(e){let t,n;if("basePubkey"in e){const r=Je.AssignWithSeed;t=Me(r,{base:J(e.basePubkey.toBuffer()),seed:e.seed,programId:J(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{const r=Je.Assign;t=Me(r,{programId:J(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new We({keys:n,programId:this.programId,data:t})}static createAccountWithSeed(e){const t=Je.CreateWithSeed,n=Me(t,{base:J(e.basePubkey.toBuffer()),seed:e.seed,lamports:e.lamports,space:e.space,programId:J(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 We({keys:r,programId:this.programId,data:n})}static createNonceAccount(e){const t=new Pe;"basePubkey"in e&&"seed"in e?t.add(Ge.createAccountWithSeed({fromPubkey:e.fromPubkey,newAccountPubkey:e.noncePubkey,basePubkey:e.basePubkey,seed:e.seed,lamports:e.lamports,space:Fe,programId:this.programId})):t.add(Ge.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.noncePubkey,lamports:e.lamports,space:Fe,programId:this.programId}));const n={noncePubkey:e.noncePubkey,authorizedPubkey:e.authorizedPubkey};return t.add(this.nonceInitialize(n)),t}static nonceInitialize(e){const t=Je.InitializeNonceAccount,n=Me(t,{authorized:J(e.authorizedPubkey.toBuffer())}),r={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:Le,isSigner:!1,isWritable:!1},{pubkey:Ke,isSigner:!1,isWritable:!1}],programId:this.programId,data:n};return new We(r)}static nonceAdvance(e){const t=Je.AdvanceNonceAccount,n=Me(t),r={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:Le,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n};return new We(r)}static nonceWithdraw(e){const t=Je.WithdrawNonceAccount,n=Me(t,{lamports:e.lamports});return new We({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0},{pubkey:Le,isSigner:!1,isWritable:!1},{pubkey:Ke,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static nonceAuthorize(e){const t=Je.AuthorizeNonceAccount,n=Me(t,{authorized:J(e.newAuthorizedPubkey.toBuffer())});return new We({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=Je.AllocateWithSeed;t=Me(r,{base:J(e.basePubkey.toBuffer()),seed:e.seed,space:e.space,programId:J(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{const r=Je.Allocate;t=Me(r,{space:e.space}),n=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new We({keys:n,programId:this.programId,data:t})}}Ge.programId=new re("11111111111111111111111111111111");const Xe=ie-300;class Qe{constructor(){}static getMinNumSignatures(e){return 2*(Math.ceil(e/Qe.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 Pe,a.add(Ge.allocate({accountPubkey:n.publicKey,space:s.length}))),o.owner.equals(i)||(a=a||new Pe,a.add(Ge.assign({accountPubkey:n.publicKey,programId:i}))),o.lamports<r&&(a=a||new Pe,a.add(Ge.transfer({fromPubkey:t.publicKey,toPubkey:n.publicKey,lamports:r-o.lamports})))}else a=(new Pe).add(Ge.createAccount({fromPubkey:t.publicKey,newAccountPubkey:n.publicKey,lamports:r>0?r:1,space:s.length,programId:i}));null!==a&&await Ye(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=Qe.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 Pe).add({keys:[{pubkey:n.publicKey,isSigner:!0,isWritable:!0}],programId:i,data:d});if(l.push(Ye(e,h,[t,n],{commitment:"confirmed"})),e._rpcEndpoint.includes("solana.com")){const e=4;await De(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 Pe).add({keys:[{pubkey:n.publicKey,isSigner:!0,isWritable:!0},{pubkey:Ke,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(Oe/2)))}}return!0}}Qe.chunkSize=Xe;new re("BPFLoader2111111111111111111111111111111111");function Ze(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e["default"]:e}var et,tt;function nt(){if(tt)return et;tt=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 et=function(e){var t=n(e,!1);if(void 0!==t)return""+t},et}var rt=nt(),it=Ze(rt);const st=32;function ot(e){let t=0;while(e>1)e/=2,t++;return t}function at(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 ct{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=ot(at(e+st+1))-ot(st)-1,n=this.getSlotsInEpoch(t),r=e-(n-st);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)*st:(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+ot(st)):this.slotsPerEpoch}}var ut=globalThis.fetch;class lt extends Y.vE{constructor(e,t,n){const r=e=>{const n=(0,Y.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 dt(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 ht=56;class pt{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=dt(gt,e),n=e.length-ht;ke(n>=0,"lookup table is invalid"),ke(n%32===0,"lookup table is invalid");const r=n/32,{addresses:i}=d.w3([d.O6(de(),r,"addresses")]).decode(e.slice(ht));return{deactivationSlot:t.deactivationSlot,lastExtendedSlot:t.lastExtendedSlot,lastExtendedSlotStartIndex:t.lastExtendedStartIndex,authority:0!==t.authority.length?new re(t.authority[0]):void 0,addresses:i.map(e=>new re(e))}}}const gt={index:1,layout:d.w3([d.DH("typeIndex"),Ve("deactivationSlot"),d.I0("lastExtendedSlot"),d.u8("lastExtendedStartIndex"),d.u8(),d.O6(de(),d.cY(d.u8(),-1),"authority")])},ft=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;function mt(e){const t=e.match(ft);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 yt=(0,R.au)((0,R.KJ)(re),(0,R.Yj)(),e=>new re(e)),bt=(0,R.PV)([(0,R.Yj)(),(0,R.eu)("base64")]),wt=(0,R.au)((0,R.KJ)(r.Buffer),bt,e=>r.Buffer.from(e[0],"base64")),kt=3e4;function St(e){if(!1===/^https?:/.test(e))throw new TypeError("Endpoint URL must start with `http:` or `https:`.");return e}function vt(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 It(e){return e.map(e=>"memcmp"in e?{...e,memcmp:{...e.memcmp,encoding:e.memcmp.encoding??"base58"}}:e)}function At(e){return(0,R.KC)([(0,R.NW)({jsonrpc:(0,R.eu)("2.0"),id:(0,R.Yj)(),result:e}),(0,R.NW)({jsonrpc:(0,R.eu)("2.0"),id:(0,R.Yj)(),error:(0,R.NW)({code:(0,R.L5)(),message:(0,R.Yj)(),data:(0,R.lq)((0,R.bz)())})})])}const xt=At((0,R.L5)());function _t(e){return(0,R.au)(At(e),xt,t=>"error"in t?t:{...t,result:(0,R.vt)(t.result,e)})}function Bt(e){return _t((0,R.NW)({context:(0,R.NW)({slot:(0,R.ai)()}),value:e}))}function Et(e){return(0,R.NW)({context:(0,R.NW)({slot:(0,R.ai)()}),value:e})}function Wt(e,t){return 0===e?new _e({header:t.header,staticAccountKeys:t.accountKeys.map(e=>new re(e)),recentBlockhash:t.recentBlockhash,compiledInstructions:t.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:c().decode(e.data)})),addressTableLookups:t.addressTableLookups}):new xe(t)}const Pt=(0,R.NW)({foundation:(0,R.ai)(),foundationTerm:(0,R.ai)(),initial:(0,R.ai)(),taper:(0,R.ai)(),terminal:(0,R.ai)()}),Tt=_t((0,R.YO)((0,R.me)((0,R.NW)({epoch:(0,R.ai)(),effectiveSlot:(0,R.ai)(),amount:(0,R.ai)(),postBalance:(0,R.ai)(),commission:(0,R.lq)((0,R.me)((0,R.ai)()))})))),Ct=(0,R.YO)((0,R.NW)({slot:(0,R.ai)(),prioritizationFee:(0,R.ai)()})),Nt=(0,R.NW)({total:(0,R.ai)(),validator:(0,R.ai)(),foundation:(0,R.ai)(),epoch:(0,R.ai)()}),Ot=(0,R.NW)({epoch:(0,R.ai)(),slotIndex:(0,R.ai)(),slotsInEpoch:(0,R.ai)(),absoluteSlot:(0,R.ai)(),blockHeight:(0,R.lq)((0,R.ai)()),transactionCount:(0,R.lq)((0,R.ai)())}),zt=(0,R.NW)({slotsPerEpoch:(0,R.ai)(),leaderScheduleSlotOffset:(0,R.ai)(),warmup:(0,R.zM)(),firstNormalEpoch:(0,R.ai)(),firstNormalSlot:(0,R.ai)()}),Lt=(0,R.g1)((0,R.Yj)(),(0,R.YO)((0,R.ai)())),Kt=(0,R.me)((0,R.KC)([(0,R.NW)({}),(0,R.Yj)()])),Rt=(0,R.NW)({err:Kt}),jt=(0,R.eu)("receivedSignature"),qt=(0,R.NW)({"solana-core":(0,R.Yj)(),"feature-set":(0,R.lq)((0,R.ai)())}),Yt=(0,R.NW)({program:(0,R.Yj)(),programId:yt,parsed:(0,R.L5)()}),Dt=(0,R.NW)({programId:yt,accounts:(0,R.YO)(yt),data:(0,R.Yj)()}),Mt=Bt((0,R.NW)({err:(0,R.me)((0,R.KC)([(0,R.NW)({}),(0,R.Yj)()])),logs:(0,R.me)((0,R.YO)((0,R.Yj)())),accounts:(0,R.lq)((0,R.me)((0,R.YO)((0,R.me)((0,R.NW)({executable:(0,R.zM)(),owner:(0,R.Yj)(),lamports:(0,R.ai)(),data:(0,R.YO)((0,R.Yj)()),rentEpoch:(0,R.lq)((0,R.ai)())}))))),unitsConsumed:(0,R.lq)((0,R.ai)()),returnData:(0,R.lq)((0,R.me)((0,R.NW)({programId:(0,R.Yj)(),data:(0,R.PV)([(0,R.Yj)(),(0,R.eu)("base64")])}))),innerInstructions:(0,R.lq)((0,R.me)((0,R.YO)((0,R.NW)({index:(0,R.ai)(),instructions:(0,R.YO)((0,R.KC)([Yt,Dt]))}))))})),Ht=Bt((0,R.NW)({byIdentity:(0,R.g1)((0,R.Yj)(),(0,R.YO)((0,R.ai)())),range:(0,R.NW)({firstSlot:(0,R.ai)(),lastSlot:(0,R.ai)()})}));function Ut(e,t,n,r,i,s){const o=n||ut;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(q())(async(n,r)=>{const s={method:"POST",body:n,agent:a,headers:Object.assign({"Content-Type":"application/json"},t||{},gr)};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 De(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 Ft(e){return(t,n)=>new Promise((r,i)=>{e.request(t,n,(e,t)=>{e?i(e):r(t)})})}function $t(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 Vt=_t(Pt),Jt=_t(Nt),Gt=_t(Ct),Xt=_t(Ot),Qt=_t(zt),Zt=_t(Lt),en=_t((0,R.ai)()),tn=Bt((0,R.NW)({total:(0,R.ai)(),circulating:(0,R.ai)(),nonCirculating:(0,R.ai)(),nonCirculatingAccounts:(0,R.YO)(yt)})),nn=(0,R.NW)({amount:(0,R.Yj)(),uiAmount:(0,R.me)((0,R.ai)()),decimals:(0,R.ai)(),uiAmountString:(0,R.lq)((0,R.Yj)())}),rn=Bt((0,R.YO)((0,R.NW)({address:yt,amount:(0,R.Yj)(),uiAmount:(0,R.me)((0,R.ai)()),decimals:(0,R.ai)(),uiAmountString:(0,R.lq)((0,R.Yj)())}))),sn=Bt((0,R.YO)((0,R.NW)({pubkey:yt,account:(0,R.NW)({executable:(0,R.zM)(),owner:yt,lamports:(0,R.ai)(),data:wt,rentEpoch:(0,R.ai)()})}))),on=(0,R.NW)({program:(0,R.Yj)(),parsed:(0,R.L5)(),space:(0,R.ai)()}),an=Bt((0,R.YO)((0,R.NW)({pubkey:yt,account:(0,R.NW)({executable:(0,R.zM)(),owner:yt,lamports:(0,R.ai)(),data:on,rentEpoch:(0,R.ai)()})}))),cn=Bt((0,R.YO)((0,R.NW)({lamports:(0,R.ai)(),address:yt}))),un=(0,R.NW)({executable:(0,R.zM)(),owner:yt,lamports:(0,R.ai)(),data:wt,rentEpoch:(0,R.ai)()}),ln=(0,R.NW)({pubkey:yt,account:un}),dn=(0,R.au)((0,R.KC)([(0,R.KJ)(r.Buffer),on]),(0,R.KC)([bt,on]),e=>Array.isArray(e)?(0,R.vt)(e,wt):e),hn=(0,R.NW)({executable:(0,R.zM)(),owner:yt,lamports:(0,R.ai)(),data:dn,rentEpoch:(0,R.ai)()}),pn=(0,R.NW)({pubkey:yt,account:hn}),gn=(0,R.NW)({state:(0,R.KC)([(0,R.eu)("active"),(0,R.eu)("inactive"),(0,R.eu)("activating"),(0,R.eu)("deactivating")]),active:(0,R.ai)(),inactive:(0,R.ai)()}),fn=_t((0,R.YO)((0,R.NW)({signature:(0,R.Yj)(),slot:(0,R.ai)(),err:Kt,memo:(0,R.me)((0,R.Yj)()),blockTime:(0,R.lq)((0,R.me)((0,R.ai)()))}))),mn=_t((0,R.YO)((0,R.NW)({signature:(0,R.Yj)(),slot:(0,R.ai)(),err:Kt,memo:(0,R.me)((0,R.Yj)()),blockTime:(0,R.lq)((0,R.me)((0,R.ai)()))}))),yn=(0,R.NW)({subscription:(0,R.ai)(),result:Et(un)}),bn=(0,R.NW)({pubkey:yt,account:un}),wn=(0,R.NW)({subscription:(0,R.ai)(),result:Et(bn)}),kn=(0,R.NW)({parent:(0,R.ai)(),slot:(0,R.ai)(),root:(0,R.ai)()}),Sn=(0,R.NW)({subscription:(0,R.ai)(),result:kn}),vn=(0,R.KC)([(0,R.NW)({type:(0,R.KC)([(0,R.eu)("firstShredReceived"),(0,R.eu)("completed"),(0,R.eu)("optimisticConfirmation"),(0,R.eu)("root")]),slot:(0,R.ai)(),timestamp:(0,R.ai)()}),(0,R.NW)({type:(0,R.eu)("createdBank"),parent:(0,R.ai)(),slot:(0,R.ai)(),timestamp:(0,R.ai)()}),(0,R.NW)({type:(0,R.eu)("frozen"),slot:(0,R.ai)(),timestamp:(0,R.ai)(),stats:(0,R.NW)({numTransactionEntries:(0,R.ai)(),numSuccessfulTransactions:(0,R.ai)(),numFailedTransactions:(0,R.ai)(),maxTransactionsPerEntry:(0,R.ai)()})}),(0,R.NW)({type:(0,R.eu)("dead"),slot:(0,R.ai)(),timestamp:(0,R.ai)(),err:(0,R.Yj)()})]),In=(0,R.NW)({subscription:(0,R.ai)(),result:vn}),An=(0,R.NW)({subscription:(0,R.ai)(),result:Et((0,R.KC)([Rt,jt]))}),xn=(0,R.NW)({subscription:(0,R.ai)(),result:(0,R.ai)()}),_n=(0,R.NW)({pubkey:(0,R.Yj)(),gossip:(0,R.me)((0,R.Yj)()),tpu:(0,R.me)((0,R.Yj)()),rpc:(0,R.me)((0,R.Yj)()),version:(0,R.me)((0,R.Yj)())}),Bn=(0,R.NW)({votePubkey:(0,R.Yj)(),nodePubkey:(0,R.Yj)(),activatedStake:(0,R.ai)(),epochVoteAccount:(0,R.zM)(),epochCredits:(0,R.YO)((0,R.PV)([(0,R.ai)(),(0,R.ai)(),(0,R.ai)()])),commission:(0,R.ai)(),lastVote:(0,R.ai)(),rootSlot:(0,R.me)((0,R.ai)())}),En=_t((0,R.NW)({current:(0,R.YO)(Bn),delinquent:(0,R.YO)(Bn)})),Wn=(0,R.KC)([(0,R.eu)("processed"),(0,R.eu)("confirmed"),(0,R.eu)("finalized")]),Pn=(0,R.NW)({slot:(0,R.ai)(),confirmations:(0,R.me)((0,R.ai)()),err:Kt,confirmationStatus:(0,R.lq)(Wn)}),Tn=Bt((0,R.YO)((0,R.me)(Pn))),Cn=_t((0,R.ai)()),Nn=(0,R.NW)({accountKey:yt,writableIndexes:(0,R.YO)((0,R.ai)()),readonlyIndexes:(0,R.YO)((0,R.ai)())}),On=(0,R.NW)({signatures:(0,R.YO)((0,R.Yj)()),message:(0,R.NW)({accountKeys:(0,R.YO)((0,R.Yj)()),header:(0,R.NW)({numRequiredSignatures:(0,R.ai)(),numReadonlySignedAccounts:(0,R.ai)(),numReadonlyUnsignedAccounts:(0,R.ai)()}),instructions:(0,R.YO)((0,R.NW)({accounts:(0,R.YO)((0,R.ai)()),data:(0,R.Yj)(),programIdIndex:(0,R.ai)()})),recentBlockhash:(0,R.Yj)(),addressTableLookups:(0,R.lq)((0,R.YO)(Nn))})}),zn=(0,R.NW)({pubkey:yt,signer:(0,R.zM)(),writable:(0,R.zM)(),source:(0,R.lq)((0,R.KC)([(0,R.eu)("transaction"),(0,R.eu)("lookupTable")]))}),Ln=(0,R.NW)({accountKeys:(0,R.YO)(zn),signatures:(0,R.YO)((0,R.Yj)())}),Kn=(0,R.NW)({parsed:(0,R.L5)(),program:(0,R.Yj)(),programId:yt}),Rn=(0,R.NW)({accounts:(0,R.YO)(yt),data:(0,R.Yj)(),programId:yt}),jn=(0,R.KC)([Rn,Kn]),qn=(0,R.KC)([(0,R.NW)({parsed:(0,R.L5)(),program:(0,R.Yj)(),programId:(0,R.Yj)()}),(0,R.NW)({accounts:(0,R.YO)((0,R.Yj)()),data:(0,R.Yj)(),programId:(0,R.Yj)()})]),Yn=(0,R.au)(jn,qn,e=>"accounts"in e?(0,R.vt)(e,Rn):(0,R.vt)(e,Kn)),Dn=(0,R.NW)({signatures:(0,R.YO)((0,R.Yj)()),message:(0,R.NW)({accountKeys:(0,R.YO)(zn),instructions:(0,R.YO)(Yn),recentBlockhash:(0,R.Yj)(),addressTableLookups:(0,R.lq)((0,R.me)((0,R.YO)(Nn)))})}),Mn=(0,R.NW)({accountIndex:(0,R.ai)(),mint:(0,R.Yj)(),owner:(0,R.lq)((0,R.Yj)()),programId:(0,R.lq)((0,R.Yj)()),uiTokenAmount:nn}),Hn=(0,R.NW)({writable:(0,R.YO)(yt),readonly:(0,R.YO)(yt)}),Un=(0,R.NW)({err:Kt,fee:(0,R.ai)(),innerInstructions:(0,R.lq)((0,R.me)((0,R.YO)((0,R.NW)({index:(0,R.ai)(),instructions:(0,R.YO)((0,R.NW)({accounts:(0,R.YO)((0,R.ai)()),data:(0,R.Yj)(),programIdIndex:(0,R.ai)()}))})))),preBalances:(0,R.YO)((0,R.ai)()),postBalances:(0,R.YO)((0,R.ai)()),logMessages:(0,R.lq)((0,R.me)((0,R.YO)((0,R.Yj)()))),preTokenBalances:(0,R.lq)((0,R.me)((0,R.YO)(Mn))),postTokenBalances:(0,R.lq)((0,R.me)((0,R.YO)(Mn))),loadedAddresses:(0,R.lq)(Hn),computeUnitsConsumed:(0,R.lq)((0,R.ai)()),costUnits:(0,R.lq)((0,R.ai)())}),Fn=(0,R.NW)({err:Kt,fee:(0,R.ai)(),innerInstructions:(0,R.lq)((0,R.me)((0,R.YO)((0,R.NW)({index:(0,R.ai)(),instructions:(0,R.YO)(Yn)})))),preBalances:(0,R.YO)((0,R.ai)()),postBalances:(0,R.YO)((0,R.ai)()),logMessages:(0,R.lq)((0,R.me)((0,R.YO)((0,R.Yj)()))),preTokenBalances:(0,R.lq)((0,R.me)((0,R.YO)(Mn))),postTokenBalances:(0,R.lq)((0,R.me)((0,R.YO)(Mn))),loadedAddresses:(0,R.lq)(Hn),computeUnitsConsumed:(0,R.lq)((0,R.ai)()),costUnits:(0,R.lq)((0,R.ai)())}),$n=(0,R.KC)([(0,R.eu)(0),(0,R.eu)("legacy")]),Vn=(0,R.NW)({pubkey:(0,R.Yj)(),lamports:(0,R.ai)(),postBalance:(0,R.me)((0,R.ai)()),rewardType:(0,R.me)((0,R.Yj)()),commission:(0,R.lq)((0,R.me)((0,R.ai)()))}),Jn=_t((0,R.me)((0,R.NW)({blockhash:(0,R.Yj)(),previousBlockhash:(0,R.Yj)(),parentSlot:(0,R.ai)(),transactions:(0,R.YO)((0,R.NW)({transaction:On,meta:(0,R.me)(Un),version:(0,R.lq)($n)})),rewards:(0,R.lq)((0,R.YO)(Vn)),blockTime:(0,R.me)((0,R.ai)()),blockHeight:(0,R.me)((0,R.ai)())}))),Gn=_t((0,R.me)((0,R.NW)({blockhash:(0,R.Yj)(),previousBlockhash:(0,R.Yj)(),parentSlot:(0,R.ai)(),rewards:(0,R.lq)((0,R.YO)(Vn)),blockTime:(0,R.me)((0,R.ai)()),blockHeight:(0,R.me)((0,R.ai)())}))),Xn=_t((0,R.me)((0,R.NW)({blockhash:(0,R.Yj)(),previousBlockhash:(0,R.Yj)(),parentSlot:(0,R.ai)(),transactions:(0,R.YO)((0,R.NW)({transaction:Ln,meta:(0,R.me)(Un),version:(0,R.lq)($n)})),rewards:(0,R.lq)((0,R.YO)(Vn)),blockTime:(0,R.me)((0,R.ai)()),blockHeight:(0,R.me)((0,R.ai)())}))),Qn=_t((0,R.me)((0,R.NW)({blockhash:(0,R.Yj)(),previousBlockhash:(0,R.Yj)(),parentSlot:(0,R.ai)(),transactions:(0,R.YO)((0,R.NW)({transaction:Dn,meta:(0,R.me)(Fn),version:(0,R.lq)($n)})),rewards:(0,R.lq)((0,R.YO)(Vn)),blockTime:(0,R.me)((0,R.ai)()),blockHeight:(0,R.me)((0,R.ai)())}))),Zn=_t((0,R.me)((0,R.NW)({blockhash:(0,R.Yj)(),previousBlockhash:(0,R.Yj)(),parentSlot:(0,R.ai)(),transactions:(0,R.YO)((0,R.NW)({transaction:Ln,meta:(0,R.me)(Fn),version:(0,R.lq)($n)})),rewards:(0,R.lq)((0,R.YO)(Vn)),blockTime:(0,R.me)((0,R.ai)()),blockHeight:(0,R.me)((0,R.ai)())}))),er=_t((0,R.me)((0,R.NW)({blockhash:(0,R.Yj)(),previousBlockhash:(0,R.Yj)(),parentSlot:(0,R.ai)(),rewards:(0,R.lq)((0,R.YO)(Vn)),blockTime:(0,R.me)((0,R.ai)()),blockHeight:(0,R.me)((0,R.ai)())}))),tr=_t((0,R.me)((0,R.NW)({blockhash:(0,R.Yj)(),previousBlockhash:(0,R.Yj)(),parentSlot:(0,R.ai)(),transactions:(0,R.YO)((0,R.NW)({transaction:On,meta:(0,R.me)(Un)})),rewards:(0,R.lq)((0,R.YO)(Vn)),blockTime:(0,R.me)((0,R.ai)())}))),nr=_t((0,R.me)((0,R.NW)({blockhash:(0,R.Yj)(),previousBlockhash:(0,R.Yj)(),parentSlot:(0,R.ai)(),signatures:(0,R.YO)((0,R.Yj)()),blockTime:(0,R.me)((0,R.ai)())}))),rr=_t((0,R.me)((0,R.NW)({slot:(0,R.ai)(),meta:(0,R.me)(Un),blockTime:(0,R.lq)((0,R.me)((0,R.ai)())),transaction:On,version:(0,R.lq)($n)}))),ir=_t((0,R.me)((0,R.NW)({slot:(0,R.ai)(),transaction:Dn,meta:(0,R.me)(Fn),blockTime:(0,R.lq)((0,R.me)((0,R.ai)())),version:(0,R.lq)($n)}))),sr=Bt((0,R.NW)({blockhash:(0,R.Yj)(),lastValidBlockHeight:(0,R.ai)()})),or=Bt((0,R.zM)()),ar=(0,R.NW)({slot:(0,R.ai)(),numTransactions:(0,R.ai)(),numSlots:(0,R.ai)(),samplePeriodSecs:(0,R.ai)()}),cr=_t((0,R.YO)(ar)),ur=Bt((0,R.me)((0,R.NW)({feeCalculator:(0,R.NW)({lamportsPerSignature:(0,R.ai)()})}))),lr=_t((0,R.Yj)()),dr=_t((0,R.Yj)()),hr=(0,R.NW)({err:Kt,logs:(0,R.YO)((0,R.Yj)()),signature:(0,R.Yj)()}),pr=(0,R.NW)({result:Et(hr),subscription:(0,R.ai)()}),gr={"solana-client":"js/1.0.0-maintenance"};class fr{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}=vt(t),i=this._buildArgs([],n,void 0,r),s=it(i);return e[s]=e[s]??(async()=>{try{const e=await this._rpcRequest("getBlockHeight",i),t=(0,R.vt)(e,_t((0,R.ai)()));if("error"in t)throw new qe(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||mt(e),this._rpcClient=Ut(e,r,i,s,o,a),this._rpcRequest=Ft(this._rpcClient),this._rpcBatchRequest=$t(this._rpcClient),this._rpcWebSocket=new lt(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}=vt(t),i=this._buildArgs([e.toBase58()],n,void 0,r),s=await this._rpcRequest("getBalance",i),o=(0,R.vt)(s,Bt((0,R.ai)()));if("error"in o)throw new qe(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,R.vt)(t,_t((0,R.me)((0,R.ai)())));if("error"in n)throw new qe(n.error,`failed to get block time for slot ${e}`);return n.result}async getMinimumLedgerSlot(){const e=await this._rpcRequest("minimumLedgerSlot",[]),t=(0,R.vt)(e,_t((0,R.ai)()));if("error"in t)throw new qe(t.error,"failed to get minimum ledger slot");return t.result}async getFirstAvailableBlock(){const e=await this._rpcRequest("getFirstAvailableBlock",[]),t=(0,R.vt)(e,en);if("error"in t)throw new qe(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,R.vt)(n,tn);if("error"in r)throw new qe(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,R.vt)(r,Bt(nn));if("error"in i)throw new qe(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,R.vt)(r,Bt(nn));if("error"in i)throw new qe(i.error,"failed to get token account balance");return i.result}async getTokenAccountsByOwner(e,t,n){const{commitment:r,config:i}=vt(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,R.vt)(a,sn);if("error"in c)throw new qe(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,R.vt)(s,an);if("error"in o)throw new qe(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,R.vt)(r,cn);if("error"in i)throw new qe(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,R.vt)(r,rn);if("error"in i)throw new qe(i.error,"failed to get token largest accounts");return i.result}async getAccountInfoAndContext(e,t){const{commitment:n,config:r}=vt(t),i=this._buildArgs([e.toBase58()],n,"base64",r),s=await this._rpcRequest("getAccountInfo",i),o=(0,R.vt)(s,Bt((0,R.me)(un)));if("error"in o)throw new qe(o.error,`failed to get info about account ${e.toBase58()}`);return o.result}async getParsedAccountInfo(e,t){const{commitment:n,config:r}=vt(t),i=this._buildArgs([e.toBase58()],n,"jsonParsed",r),s=await this._rpcRequest("getAccountInfo",i),o=(0,R.vt)(s,Bt((0,R.me)(hn)));if("error"in o)throw new qe(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}=vt(t),i=e.map(e=>e.toBase58()),s=this._buildArgs([i],n,"jsonParsed",r),o=await this._rpcRequest("getMultipleAccounts",s),a=(0,R.vt)(o,Bt((0,R.YO)((0,R.me)(hn))));if("error"in a)throw new qe(a.error,`failed to get info for accounts ${i}`);return a.result}async getMultipleAccountsInfoAndContext(e,t){const{commitment:n,config:r}=vt(t),i=e.map(e=>e.toBase58()),s=this._buildArgs([i],n,"base64",r),o=await this._rpcRequest("getMultipleAccounts",s),a=(0,R.vt)(o,Bt((0,R.YO)((0,R.me)(un))));if("error"in a)throw new qe(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}=vt(t),s=this._buildArgs([e.toBase58()],r,void 0,{...i,epoch:null!=n?n:i?.epoch}),o=await this._rpcRequest("getStakeActivation",s),a=(0,R.vt)(o,_t(gn));if("error"in a)throw new qe(a.error,`failed to get Stake Activation ${e.toBase58()}`);return a.result}async getProgramAccounts(e,t){const{commitment:n,config:r}=vt(t),{encoding:i,...s}=r||{},o=this._buildArgs([e.toBase58()],n,i||"base64",{...s,...s.filters?{filters:It(s.filters)}:null}),a=await this._rpcRequest("getProgramAccounts",o),c=(0,R.YO)(ln),u=!0===s.withContext?(0,R.vt)(a,Bt(c)):(0,R.vt)(a,_t(c));if("error"in u)throw new qe(u.error,`failed to get accounts owned by program ${e.toBase58()}`);return u.result}async getParsedProgramAccounts(e,t){const{commitment:n,config:r}=vt(t),i=this._buildArgs([e.toBase58()],n,"jsonParsed",r),s=await this._rpcRequest("getProgramAccounts",i),o=(0,R.vt)(s,_t((0,R.YO)(pn)));if("error"in o)throw new qe(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 ke(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:Be.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:Be.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 De(1e3),i)return;if(e=await r(),i)return}t({__type:Be.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!==Be.PROCESSED)throw new ae(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:Be.NONCE_INVALID,slotInWhichNonceDidAdvance:a});if(await De(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===Be.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 De(400)}if(!r?.value)throw new ue(s);{const t=e||"finalized",{confirmationStatus:n}=r.value;switch(t){case"processed":case"recent":if("processed"!==n&&"confirmed"!==n&&"finalized"!==n)throw new ue(s);break;case"confirmed":case"single":case"singleGossip":if("confirmed"!==n&&"finalized"!==n)throw new ue(s);break;case"finalized":case"max":case"root":if("finalized"!==n)throw new ue(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:Be.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!==Be.PROCESSED)throw new ce(t,e.timeoutMs/1e3);o=e.response}finally{clearTimeout(n),i()}return o}async getClusterNodes(){const e=await this._rpcRequest("getClusterNodes",[]),t=(0,R.vt)(e,_t((0,R.YO)(_n)));if("error"in t)throw new qe(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,R.vt)(n,En);if("error"in r)throw new qe(r.error,"failed to get vote accounts");return r.result}async getSlot(e){const{commitment:t,config:n}=vt(e),r=this._buildArgs([],t,void 0,n),i=await this._rpcRequest("getSlot",r),s=(0,R.vt)(i,_t((0,R.ai)()));if("error"in s)throw new qe(s.error,"failed to get slot");return s.result}async getSlotLeader(e){const{commitment:t,config:n}=vt(e),r=this._buildArgs([],t,void 0,n),i=await this._rpcRequest("getSlotLeader",r),s=(0,R.vt)(i,_t((0,R.Yj)()));if("error"in s)throw new qe(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,R.vt)(r,_t((0,R.YO)(yt)));if("error"in i)throw new qe(i.error,"failed to get slot leaders");return i.result}async getSignatureStatus(e,t){const{context:n,value:r}=await this.getSignatureStatuses([e],t);ke(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,R.vt)(r,Tn);if("error"in i)throw new qe(i.error,"failed to get signature status");return i.result}async getTransactionCount(e){const{commitment:t,config:n}=vt(e),r=this._buildArgs([],t,void 0,n),i=await this._rpcRequest("getTransactionCount",r),s=(0,R.vt)(i,_t((0,R.ai)()));if("error"in s)throw new qe(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,R.vt)(n,Vt);if("error"in r)throw new qe(r.error,"failed to get inflation");return r.result}async getInflationReward(e,t,n){const{commitment:r,config:i}=vt(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,R.vt)(o,Tt);if("error"in a)throw new qe(a.error,"failed to get inflation reward");return a.result}async getInflationRate(){const e=await this._rpcRequest("getInflationRate",[]),t=(0,R.vt)(e,Jt);if("error"in t)throw new qe(t.error,"failed to get inflation rate");return t.result}async getEpochInfo(e){const{commitment:t,config:n}=vt(e),r=this._buildArgs([],t,void 0,n),i=await this._rpcRequest("getEpochInfo",r),s=(0,R.vt)(i,Xt);if("error"in s)throw new qe(s.error,"failed to get epoch info");return s.result}async getEpochSchedule(){const e=await this._rpcRequest("getEpochSchedule",[]),t=(0,R.vt)(e,Qt);if("error"in t)throw new qe(t.error,"failed to get epoch schedule");const n=t.result;return new ct(n.slotsPerEpoch,n.leaderScheduleSlotOffset,n.warmup,n.firstNormalEpoch,n.firstNormalSlot)}async getLeaderSchedule(){const e=await this._rpcRequest("getLeaderSchedule",[]),t=(0,R.vt)(e,Zt);if("error"in t)throw new qe(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,R.vt)(r,Cn);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,R.vt)(t,cr);if("error"in n)throw new qe(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,R.vt)(r,ur);if("error"in i)throw new qe(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=J(e.serialize()).toString("base64"),r=this._buildArgs([n],t),i=await this._rpcRequest("getFeeForMessage",r),s=(0,R.vt)(i,Bt((0,R.me)((0,R.ai)())));if("error"in s)throw new qe(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,R.vt)(r,Gt);if("error"in i)throw new qe(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}=vt(e),r=this._buildArgs([],t,void 0,n),i=await this._rpcRequest("getLatestBlockhash",r),s=(0,R.vt)(i,sr);if("error"in s)throw new qe(s.error,"failed to get latest blockhash");return s.result}async isBlockhashValid(e,t){const{commitment:n,config:r}=vt(t),i=this._buildArgs([e],n,void 0,r),s=await this._rpcRequest("isBlockhashValid",i),o=(0,R.vt)(s,or);if("error"in o)throw new qe(o.error,"failed to determine if the blockhash `"+e+"`is valid");return o.result}async getVersion(){const e=await this._rpcRequest("getVersion",[]),t=(0,R.vt)(e,_t(qt));if("error"in t)throw new qe(t.error,"failed to get version");return t.result}async getGenesisHash(){const e=await this._rpcRequest("getGenesisHash",[]),t=(0,R.vt)(e,_t((0,R.Yj)()));if("error"in t)throw new qe(t.error,"failed to get genesis hash");return t.result}async getBlock(e,t){const{commitment:n,config:r}=vt(t),i=this._buildArgsAtLeastConfirmed([e],n,void 0,r),s=await this._rpcRequest("getBlock",i);try{switch(r?.transactionDetails){case"accounts":{const e=(0,R.vt)(s,Xn);if("error"in e)throw e.error;return e.result}case"none":{const e=(0,R.vt)(s,Gn);if("error"in e)throw e.error;return e.result}default:{const e=(0,R.vt)(s,Jn);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:Wt(n,e.message)},version:n}))}:null}}}catch(o){throw new qe(o,"failed to get confirmed block")}}async getParsedBlock(e,t){const{commitment:n,config:r}=vt(t),i=this._buildArgsAtLeastConfirmed([e],n,"jsonParsed",r),s=await this._rpcRequest("getBlock",i);try{switch(r?.transactionDetails){case"accounts":{const e=(0,R.vt)(s,Zn);if("error"in e)throw e.error;return e.result}case"none":{const e=(0,R.vt)(s,er);if("error"in e)throw e.error;return e.result}default:{const e=(0,R.vt)(s,Qn);if("error"in e)throw e.error;return e.result}}}catch(o){throw new qe(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,R.vt)(i,Ht);if("error"in s)throw new qe(s.error,"failed to get block production information");return s.result}async getTransaction(e,t){const{commitment:n,config:r}=vt(t),i=this._buildArgsAtLeastConfirmed([e],n,void 0,r),s=await this._rpcRequest("getTransaction",i),o=(0,R.vt)(s,rr);if("error"in o)throw new qe(o.error,"failed to get transaction");const a=o.result;return a?{...a,transaction:{...a.transaction,message:Wt(a.version,a.transaction.message)}}:a}async getParsedTransaction(e,t){const{commitment:n,config:r}=vt(t),i=this._buildArgsAtLeastConfirmed([e],n,"jsonParsed",r),s=await this._rpcRequest("getTransaction",i),o=(0,R.vt)(s,ir);if("error"in o)throw new qe(o.error,"failed to get transaction");return o.result}async getParsedTransactions(e,t){const{commitment:n,config:r}=vt(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,R.vt)(e,ir);if("error"in t)throw new qe(t.error,"failed to get transactions");return t.result});return o}async getTransactions(e,t){const{commitment:n,config:r}=vt(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,R.vt)(e,rr);if("error"in t)throw new qe(t.error,"failed to get transactions");const n=t.result;return n?{...n,transaction:{...n.transaction,message:Wt(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,R.vt)(r,tr);if("error"in i)throw new qe(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 xe(e.message);return{meta:t,transaction:{...e,message:n}}})};return{...o,transactions:o.transactions.map(({transaction:e,meta:t})=>({meta:t,transaction:Pe.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,R.vt)(i,_t((0,R.YO)((0,R.ai)())));if("error"in s)throw new qe(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,R.vt)(r,nr);if("error"in i)throw new qe(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,R.vt)(r,nr);if("error"in i)throw new qe(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,R.vt)(r,rr);if("error"in i)throw new qe(i.error,"failed to get transaction");const s=i.result;if(!s)return s;const o=new xe(s.transaction.message),a=s.transaction.signatures;return{...s,transaction:Pe.populate(o,a)}}async getParsedConfirmedTransaction(e,t){const n=this._buildArgsAtLeastConfirmed([e],t,"jsonParsed"),r=await this._rpcRequest("getTransaction",n),i=(0,R.vt)(r,ir);if("error"in i)throw new qe(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,R.vt)(e,ir);if("error"in t)throw new qe(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,R.vt)(i,fn);if("error"in s)throw new qe(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,R.vt)(i,mn);if("error"in s)throw new qe(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 pt({key:e,state:pt.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=$e.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,R.vt)(n,lr);if("error"in r)throw new qe(r.error,`airdrop to ${e.toBase58()} failed`);return r.result}async _blockhashWithExpiryBlockHeight(e){if(!e){while(this._pollingBlockhash)await De(100);const e=Date.now()-this._blockhashInfo.lastFetch,t=e>=kt;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 De(Oe/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}=vt(e),r=this._buildArgs([],t,"base64",n),i=await this._rpcRequest("getStakeMinimumDelegation",r),s=(0,R.vt)(i,Bt((0,R.ai)()));if("error"in s)throw new qe(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,R.vt)(u,Mt);if("error"in l)throw new Error("failed to simulate transaction: "+l.error.message);return l.result}let i;if(e instanceof Pe){let t=e;i=new Pe,i.feePayer=t.feePayer,i.instructions=e.instructions,i.nonceInfo=t.nonceInfo,i.signatures=t.signatures}else i=Pe.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,R.vt)(h,Mt);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 je({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=J(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,R.vt)(o,dr);if("error"in a){let e;throw"data"in a.error&&(e=a.error.data.logs),new je({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,R.vt)(e,yn);this._handleServerNotification(n,[t.value,t.context])}_makeSubscription(e,t){const n=this._nextClientSubscriptionId++,r=it([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];ke(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}=vt(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,R.vt)(e,wn);this._handleServerNotification(n,[{accountId:t.value.pubkey,accountInfo:t.value.account},t.context])}onProgramAccountChange(e,t,n,r){const{commitment:i,config:s}=vt(n),o=this._buildArgs([e.toBase58()],i||this._commitment||"finalized","base64",s||(r?{filters:It(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,R.vt)(e,pr);this._handleServerNotification(n,[t.value,t.context])}_wsOnSlotNotification(e){const{result:t,subscription:n}=(0,R.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,R.vt)(e,In);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,R.vt)(e,An);"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,R.vt)(e,xn);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 mr{constructor(e){this._keypair=void 0,this._keypair=e??H()}static generate(){return new mr(H())}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=U(t);for(let e=0;e<32;e++)if(n[e]!==r[e])throw new Error("provided secretKey is invalid")}return new mr({publicKey:n,secretKey:e})}static fromSeed(e){const t=U(e),n=new Uint8Array(64);return n.set(e),n.set(t,32),new mr({publicKey:t,secretKey:n})}get publicKey(){return new re(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}}const yr=Object.freeze({CreateLookupTable:{index:0,layout:d.w3([d.DH("instruction"),Ve("recentSlot"),d.u8("bumpSeed")])},FreezeLookupTable:{index:1,layout:d.w3([d.DH("instruction")])},ExtendLookupTable:{index:2,layout:d.w3([d.DH("instruction"),Ve(),d.O6(de(),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 br{constructor(){}static createLookupTable(e){const[t,n]=re.findProgramAddressSync([e.authority.toBuffer(),z().encode(e.recentSlot)],this.programId),r=yr.CreateLookupTable,i=Me(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:Ge.programId,isSigner:!1,isWritable:!1}];return[new We({programId:this.programId,keys:s,data:i}),t]}static freezeLookupTable(e){const t=yr.FreezeLookupTable,n=Me(t),r=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new We({programId:this.programId,keys:r,data:n})}static extendLookupTable(e){const t=yr.ExtendLookupTable,n=Me(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:Ge.programId,isSigner:!1,isWritable:!1}),new We({programId:this.programId,keys:r,data:n})}static deactivateLookupTable(e){const t=yr.DeactivateLookupTable,n=Me(t),r=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new We({programId:this.programId,keys:r,data:n})}static closeLookupTable(e){const t=yr.CloseLookupTable,n=Me(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 We({programId:this.programId,keys:r,data:n})}}br.programId=new re("AddressLookupTab1e1111111111111111111111111");const wr=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"),Ve("microLamports")])}});class kr{constructor(){}static requestUnits(e){const t=wr.RequestUnits,n=Me(t,e);return new We({keys:[],programId:this.programId,data:n})}static requestHeapFrame(e){const t=wr.RequestHeapFrame,n=Me(t,e);return new We({keys:[],programId:this.programId,data:n})}static setComputeUnitLimit(e){const t=wr.SetComputeUnitLimit,n=Me(t,e);return new We({keys:[],programId:this.programId,data:n})}static setComputeUnitPrice(e){const t=wr.SetComputeUnitPrice,n=Me(t,{microLamports:BigInt(e.microLamports)});return new We({keys:[],programId:this.programId,data:n})}}kr.programId=new re("ComputeBudget111111111111111111111111111111");const Sr=64,vr=32,Ir=64,Ar=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 xr{constructor(){}static createInstructionWithPublicKey(e){const{publicKey:t,message:n,signature:i,instructionIndex:s}=e;ke(t.length===vr,`Public Key must be ${vr} bytes but received ${t.length} bytes`),ke(i.length===Ir,`Signature must be ${Ir} bytes but received ${i.length} bytes`);const o=Ar.span,a=o+t.length,c=a+i.length,u=1,l=r.Buffer.alloc(c+n.length),d=null==s?65535:s;return Ar.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 We({keys:[],programId:xr.programId,data:l})}static createInstructionWithPrivateKey(e){const{privateKey:t,message:n,instructionIndex:r}=e;ke(t.length===Sr,`Private key must be ${Sr} bytes but received ${t.length} bytes`);try{const e=mr.fromSecretKey(t),i=e.publicKey.toBytes(),s=$(n,e.secretKey);return this.createInstructionWithPublicKey({publicKey:i,message:n,signature:s,instructionIndex:r})}catch(i){throw new Error(`Error creating instruction; ${i}`)}}}xr.programId=new re("Ed25519SigVerify111111111111111111111111111");const _r=(e,t)=>{const n=M.bI.sign(e,t);return[n.toCompactRawBytes(),n.recovery]};M.bI.utils.isValidPrivateKey;const Br=M.bI.getPublicKey,Er=32,Wr=20,Pr=64,Tr=11,Cr=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 Nr{constructor(){}static publicKeyToEthAddress(e){ke(e.length===Pr,`Public key must be ${Pr} bytes but received ${e.length} bytes`);try{return r.Buffer.from((0,D.lY)(J(e))).slice(-Wr)}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 Nr.createInstructionWithEthAddress({ethAddress:Nr.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,ke(a.length===Wr,`Address must be ${Wr} bytes but received ${a.length} bytes`);const c=1+Tr,u=c,l=c+a.length,d=l+i.length+1,h=1,p=r.Buffer.alloc(Cr.span+n.length);return Cr.encode({numSignatures:h,signatureOffset:l,signatureInstructionIndex:o,ethAddressOffset:u,ethAddressInstructionIndex:o,messageDataOffset:d,messageDataSize:n.length,messageInstructionIndex:o,signature:J(i),ethAddress:J(a),recoveryId:s},p),p.fill(J(n),Cr.span),new We({keys:[],programId:Nr.programId,data:p})}static createInstructionWithPrivateKey(e){const{privateKey:t,message:n,instructionIndex:i}=e;ke(t.length===Er,`Private key must be ${Er} bytes but received ${t.length} bytes`);try{const e=J(t),s=Br(e,!1).slice(1),o=r.Buffer.from((0,D.lY)(J(n))),[a,c]=_r(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 Or;Nr.programId=new re("KeccakSecp256k11111111111111111111111111111");const zr=new re("StakeConfig11111111111111111111111111111111");class Lr{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}}Or=Lr,Lr.default=new Or(0,0,re.default);const Kr=Object.freeze({Initialize:{index:0,layout:d.w3([d.DH("instruction"),pe(),ge()])},Authorize:{index:1,layout:d.w3([d.DH("instruction"),de("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"),de("newAuthorized"),d.DH("stakeAuthorizationType"),he("authoritySeed"),de("authorityOwner")])}});Object.freeze({Staker:{index:0},Withdrawer:{index:1}});class Rr{constructor(){}static initialize(e){const{stakePubkey:t,authorized:n,lockup:r}=e,i=r||Lr.default,s=Kr.Initialize,o=Me(s,{authorized:{staker:J(n.staker.toBuffer()),withdrawer:J(n.withdrawer.toBuffer())},lockup:{unixTimestamp:i.unixTimestamp,epoch:i.epoch,custodian:J(i.custodian.toBuffer())}}),a={keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Ke,isSigner:!1,isWritable:!1}],programId:this.programId,data:o};return new We(a)}static createAccountWithSeed(e){const t=new Pe;t.add(Ge.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 Pe;t.add(Ge.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=Kr.Delegate,s=Me(i);return(new Pe).add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!1},{pubkey:ze,isSigner:!1,isWritable:!1},{pubkey:Re,isSigner:!1,isWritable:!1},{pubkey:zr,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=Kr.Authorize,a=Me(o,{newAuthorized:J(r.toBuffer()),stakeAuthorizationType:i.index}),c=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:ze,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return s&&c.push({pubkey:s,isSigner:!0,isWritable:!1}),(new Pe).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=Kr.AuthorizeWithSeed,u=Me(c,{newAuthorized:J(s.toBuffer()),stakeAuthorizationType:o.index,authoritySeed:r,authorityOwner:J(i.toBuffer())}),l=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1},{pubkey:ze,isSigner:!1,isWritable:!1}];return a&&l.push({pubkey:a,isSigner:!0,isWritable:!1}),(new Pe).add({keys:l,programId:this.programId,data:u})}static splitInstruction(e){const{stakePubkey:t,authorizedPubkey:n,splitStakePubkey:r,lamports:i}=e,s=Kr.Split,o=Me(s,{lamports:i});return new We({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 Pe;return n.add(Ge.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 Pe;return c.add(Ge.allocate({accountPubkey:i,basePubkey:s,seed:o,space:this.space,programId:this.programId})),t&&t>0&&c.add(Ge.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=Kr.Merge,s=Me(i);return(new Pe).add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!0},{pubkey:ze,isSigner:!1,isWritable:!1},{pubkey:Re,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=Kr.Withdraw,a=Me(o,{lamports:i}),c=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:ze,isSigner:!1,isWritable:!1},{pubkey:Re,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return s&&c.push({pubkey:s,isSigner:!0,isWritable:!1}),(new Pe).add({keys:c,programId:this.programId,data:a})}static deactivate(e){const{stakePubkey:t,authorizedPubkey:n}=e,r=Kr.Deactivate,i=Me(r);return(new Pe).add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:ze,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:i})}}Rr.programId=new re("Stake11111111111111111111111111111111111111"),Rr.space=200;const jr=Object.freeze({InitializeAccount:{index:0,layout:d.w3([d.DH("instruction"),fe()])},Authorize:{index:1,layout:d.w3([d.DH("instruction"),de("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"),me()])}});Object.freeze({Voter:{index:0},Withdrawer:{index:1}});class qr{constructor(){}static initializeAccount(e){const{votePubkey:t,nodePubkey:n,voteInit:r}=e,i=jr.InitializeAccount,s=Me(i,{voteInit:{nodePubkey:J(r.nodePubkey.toBuffer()),authorizedVoter:J(r.authorizedVoter.toBuffer()),authorizedWithdrawer:J(r.authorizedWithdrawer.toBuffer()),commission:r.commission}}),o={keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Ke,isSigner:!1,isWritable:!1},{pubkey:ze,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:s};return new We(o)}static createAccount(e){const t=new Pe;return t.add(Ge.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=jr.Authorize,o=Me(s,{newAuthorized:J(r.toBuffer()),voteAuthorizationType:i.index}),a=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:ze,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return(new Pe).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=jr.AuthorizeWithSeed,c=Me(a,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:J(n.toBuffer()),currentAuthorityDerivedKeySeed:r,newAuthorized:J(i.toBuffer()),voteAuthorizationType:s.index}}),u=[{pubkey:o,isSigner:!1,isWritable:!0},{pubkey:ze,isSigner:!1,isWritable:!1},{pubkey:t,isSigner:!0,isWritable:!1}];return(new Pe).add({keys:u,programId:this.programId,data:c})}static withdraw(e){const{votePubkey:t,authorizedWithdrawerPubkey:n,lamports:r,toPubkey:i}=e,s=jr.Withdraw,o=Me(s,{lamports:r}),a=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:i,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return(new Pe).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 qr.withdraw(e)}static updateValidatorIdentity(e){const{votePubkey:t,authorizedWithdrawerPubkey:n,nodePubkey:r}=e,i=jr.UpdateValidatorIdentity,s=Me(i),o=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return(new Pe).add({keys:o,programId:this.programId,data:s})}}qr.programId=new re("Vote111111111111111111111111111111111111111"),qr.space=3762;new re("Va1idator1nfo111111111111111111111111111111"),(0,R.NW)({name:(0,R.Yj)(),website:(0,R.lq)((0,R.Yj)()),details:(0,R.lq)((0,R.Yj)()),iconUrl:(0,R.lq)((0,R.Yj)()),keybaseUsername:(0,R.lq)((0,R.Yj)())});new re("Vote111111111111111111111111111111111111111"),d.w3([de("nodePubkey"),de("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"),de("authorizedVoter")]),d.cY(d.DH(),-8),"authorizedVoters"),d.w3([d.O6(d.w3([de("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 Yr=1e9},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},43466(e,t,n){var r=n(15621),i="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";e.exports=r(i)},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}},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}},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},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}},72713(e,t,n){"use strict";n.d(t,{lc:()=>d,jE:()=>p,_l:()=>u});var r=n(601),i=n(30184);const s=e=>{const t=e.decode.bind(e),n=e.encode.bind(e);return{decode:t,encode:n}};var o=n(48287)["Buffer"];const a=e=>t=>{const n=(0,r.av)(e,t),{encode:a,decode:c}=s(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}=s(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}=s(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(1539);const p=e=>{const t=(0,r.av)(32,e),{encode:n,decode:i}=s(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}},49215(e,t,n){"use strict";n.d(t,{EK:()=>s,x5:()=>i});var r=n(1539);const i=new r.J3("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"),s=(new r.J3("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"),new r.J3("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"));new r.J3("So11111111111111111111111111111111111111112"),new r.J3("9pan9bMn5HatX4EJdBwg9VgCa7Uz5HL8N1m5D3NdXejP")},9646(e,t,n){"use strict";n.d(t,{JA:()=>o});var r=n(1539),i=n(49215),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})}},23825(e,t,n){"use strict";n.d(t,{C3:()=>d});var r,i=n(601),s=n(72713),o=n(1539),a=n(49215);function c(e,t,n){if(n.length){e.push({pubkey:t,isSigner:!1,isWritable:!1});for(const t of n)e.push({pubkey:t instanceof o.J3?t:t.publicKey,isSigner:!0,isWritable:!1})}else e.push({pubkey:t,isSigner:!0,isWritable:!1});return e}(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={}));var u=n(48287)["Buffer"];const l=(0,i.w3)([(0,i.u8)("instruction"),(0,s._l)("amount")]);function d(e,t,n,i,s=[],d=a.x5){const h=c([{pubkey:e,isSigner:!1,isWritable:!0},{pubkey:t,isSigner:!1,isWritable:!0}],n,s),p=u.alloc(l.span);return l.encode({instruction:r.Transfer,amount:BigInt(i)},p),new o.fH({keys:h,programId:d,data:p})}},48625(e,t,n){"use strict";n.d(t,{Ob:()=>l});var r=n(601),i=n(72713),s=n(1539),o=n(49215);class a extends Error{constructor(e){super(e)}}class c extends a{constructor(){super(...arguments),this.name="TokenOwnerOffCurveError"}}n(48287)["Buffer"];const u=(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")]);u.span;async function l(e,t,n=!1,r=o.x5,i=o.EK){if(!n&&!s.J3.isOnCurve(t.toBuffer()))throw new c;const[a]=await s.J3.findProgramAddress([t.toBuffer(),r.toBuffer(),e.toBuffer()],i);return a}}}]);