edge-currency-accountbased 3.2.3 → 3.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- (self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[8193],{39386:function(ee,J,A){"use strict";var h;/**
1
+ (self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[8193],{39386:function(ne,$,A){"use strict";var h;/**
2
2
  * Support for translating between Uint8Array instances and JavaScript
3
3
  * native types.
4
4
  *
@@ -105,5 +105,5 @@
105
105
  * @license MIT
106
106
  * @author Peter A. Bigot
107
107
  * @see {@link https://github.com/pabigot/buffer-layout|buffer-layout on GitHub}
108
- */h={value:!0},h=h=h=h=h=h=h=h=J._O=h=h=J.Jq=h=J.KB=J.u8=J.cv=h=h=h=h=h=h=h=h=h=h=h=h=h=h=h=h=h=h=h=h=h=h=h=h=h=h=h=h=h=h=h=h=h=h=void 0,h=h=h=J.Ik=h=h=J.A9=h=J.n_=h=h=h=h=h=h=h=h=h=h=J.gM=h=h=h=h=void 0;const P=A(48764);function X(x){if(!(x instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}h=X;function S(x){return X(x),P.Buffer.from(x.buffer,x.byteOffset,x.length)}h=S;class B{constructor(c,l){if(!Number.isInteger(c))throw new TypeError("span must be an integer");this.span=c,this.property=l}makeDestinationObject(){return{}}getSpan(c,l){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(c){const l=Object.create(this.constructor.prototype);return Object.assign(l,this),l.property=c,l}fromArray(c){}}h=B;function Q(x,c){return c.property?x+"["+c.property+"]":x}h=Q;function F(x,c){if(typeof x!="function")throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(x,"layout_"))throw new Error("Class is already bound to a layout");if(!(c&&c instanceof B))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(c,"boundConstructor_"))throw new Error("layout is already bound to a constructor");x.layout_=c,c.boundConstructor_=x,c.makeDestinationObject=()=>new x,Object.defineProperty(x.prototype,"encode",{value(l,y){return c.encode(this,l,y)},writable:!0}),Object.defineProperty(x,"decode",{value(l,y){return c.decode(l,y)},writable:!0})}h=F;class R extends B{isCount(){throw new Error("ExternalLayout is abstract")}}h=R;class G extends R{constructor(c=1,l){if(!Number.isInteger(c)||0>=c)throw new TypeError("elementSpan must be a (positive) integer");super(-1,l),this.elementSpan=c}isCount(){return!0}decode(c,l=0){X(c);const y=c.length-l;return Math.floor(y/this.elementSpan)}encode(c,l,y){return 0}}h=G;class ke extends R{constructor(c,l=0,y){if(!(c instanceof B))throw new TypeError("layout must be a Layout");if(!Number.isInteger(l))throw new TypeError("offset must be integer or undefined");super(c.span,y||c.property),this.layout=c,this.offset=l}isCount(){return this.layout instanceof oe||this.layout instanceof _}decode(c,l=0){return this.layout.decode(c,l+this.offset)}encode(c,l,y=0){return this.layout.encode(c,l,y+this.offset)}}h=ke;class oe extends B{constructor(c,l){if(super(c,l),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(c,l=0){return S(c).readUIntLE(l,this.span)}encode(c,l,y=0){return S(l).writeUIntLE(c,y,this.span),this.span}}h=oe;class _ extends B{constructor(c,l){if(super(c,l),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(c,l=0){return S(c).readUIntBE(l,this.span)}encode(c,l,y=0){return S(l).writeUIntBE(c,y,this.span),this.span}}h=_;class ne extends B{constructor(c,l){if(super(c,l),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(c,l=0){return S(c).readIntLE(l,this.span)}encode(c,l,y=0){return S(l).writeIntLE(c,y,this.span),this.span}}h=ne;class M extends B{constructor(c,l){if(super(c,l),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(c,l=0){return S(c).readIntBE(l,this.span)}encode(c,l,y=0){return S(l).writeIntBE(c,y,this.span),this.span}}h=M;const le=Math.pow(2,32);function re(x){const c=Math.floor(x/le),l=x-c*le;return{hi32:c,lo32:l}}function V(x,c){return x*le+c}class te extends B{constructor(c){super(8,c)}decode(c,l=0){const y=S(c),W=y.readUInt32LE(l),E=y.readUInt32LE(l+4);return V(E,W)}encode(c,l,y=0){const W=re(c),E=S(l);return E.writeUInt32LE(W.lo32,y),E.writeUInt32LE(W.hi32,y+4),8}}h=te;class ge extends B{constructor(c){super(8,c)}decode(c,l=0){const y=S(c),W=y.readUInt32BE(l),E=y.readUInt32BE(l+4);return V(W,E)}encode(c,l,y=0){const W=re(c),E=S(l);return E.writeUInt32BE(W.hi32,y),E.writeUInt32BE(W.lo32,y+4),8}}h=ge;class Ne extends B{constructor(c){super(8,c)}decode(c,l=0){const y=S(c),W=y.readUInt32LE(l),E=y.readInt32LE(l+4);return V(E,W)}encode(c,l,y=0){const W=re(c),E=S(l);return E.writeUInt32LE(W.lo32,y),E.writeInt32LE(W.hi32,y+4),8}}h=Ne;class Z extends B{constructor(c){super(8,c)}decode(c,l=0){const y=S(c),W=y.readInt32BE(l),E=y.readUInt32BE(l+4);return V(W,E)}encode(c,l,y=0){const W=re(c),E=S(l);return E.writeInt32BE(W.hi32,y),E.writeUInt32BE(W.lo32,y+4),8}}h=Z;class be extends B{constructor(c){super(4,c)}decode(c,l=0){return S(c).readFloatLE(l)}encode(c,l,y=0){return S(l).writeFloatLE(c,y),4}}h=be;class qe extends B{constructor(c){super(4,c)}decode(c,l=0){return S(c).readFloatBE(l)}encode(c,l,y=0){return S(l).writeFloatBE(c,y),4}}h=qe;class pe extends B{constructor(c){super(8,c)}decode(c,l=0){return S(c).readDoubleLE(l)}encode(c,l,y=0){return S(l).writeDoubleLE(c,y),8}}h=pe;class Be extends B{constructor(c){super(8,c)}decode(c,l=0){return S(c).readDoubleBE(l)}encode(c,l,y=0){return S(l).writeDoubleBE(c,y),8}}h=Be;class xe extends B{constructor(c,l,y){if(!(c instanceof B))throw new TypeError("elementLayout must be a Layout");if(!(l instanceof R&&l.isCount()||Number.isInteger(l)&&0<=l))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let W=-1;!(l instanceof R)&&0<c.span&&(W=l*c.span),super(W,y),this.elementLayout=c,this.count=l}getSpan(c,l=0){if(0<=this.span)return this.span;let y=0,W=this.count;if(W instanceof R&&(W=W.decode(c,l)),0<this.elementLayout.span)y=W*this.elementLayout.span;else{let E=0;for(;E<W;)y+=this.elementLayout.getSpan(c,l+y),++E}return y}decode(c,l=0){const y=[];let W=0,E=this.count;for(E instanceof R&&(E=E.decode(c,l));W<E;)y.push(this.elementLayout.decode(c,l)),l+=this.elementLayout.getSpan(c,l),W+=1;return y}encode(c,l,y=0){const W=this.elementLayout,E=c.reduce((Ae,ze)=>Ae+W.encode(ze,l,y+Ae),0);return this.count instanceof R&&this.count.encode(c.length,l,y),E}}h=xe;class $ extends B{constructor(c,l,y){if(!(Array.isArray(c)&&c.reduce((E,Ae)=>E&&Ae instanceof B,!0)))throw new TypeError("fields must be array of Layout instances");typeof l=="boolean"&&y===void 0&&(y=l,l=void 0);for(const E of c)if(0>E.span&&E.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let W=-1;try{W=c.reduce((E,Ae)=>E+Ae.getSpan(),0)}catch{}super(W,l),this.fields=c,this.decodePrefixes=!!y}getSpan(c,l=0){if(0<=this.span)return this.span;let y=0;try{y=this.fields.reduce((W,E)=>{const Ae=E.getSpan(c,l);return l+=Ae,W+Ae},0)}catch{throw new RangeError("indeterminate span")}return y}decode(c,l=0){X(c);const y=this.makeDestinationObject();for(const W of this.fields)if(W.property!==void 0&&(y[W.property]=W.decode(c,l)),l+=W.getSpan(c,l),this.decodePrefixes&&c.length===l)break;return y}encode(c,l,y=0){const W=y;let E=0,Ae=0;for(const ze of this.fields){let Je=ze.span;if(Ae=0<Je?Je:0,ze.property!==void 0){const dt=c[ze.property];dt!==void 0&&(Ae=ze.encode(dt,l,y),0>Je&&(Je=ze.getSpan(l,y)))}E=y,y+=Je}return E+Ae-W}fromArray(c){const l=this.makeDestinationObject();for(const y of this.fields)y.property!==void 0&&0<c.length&&(l[y.property]=c.shift());return l}layoutFor(c){if(typeof c!="string")throw new TypeError("property must be string");for(const l of this.fields)if(l.property===c)return l}offsetOf(c){if(typeof c!="string")throw new TypeError("property must be string");let l=0;for(const y of this.fields){if(y.property===c)return l;0>y.span?l=-1:0<=l&&(l+=y.span)}}}h=$;class U{constructor(c){this.property=c}decode(c,l){throw new Error("UnionDiscriminator is abstract")}encode(c,l,y){throw new Error("UnionDiscriminator is abstract")}}h=U;class ie extends U{constructor(c,l){if(!(c instanceof R&&c.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(l||c.property||"variant"),this.layout=c}decode(c,l){return this.layout.decode(c,l)}encode(c,l,y){return this.layout.encode(c,l,y)}}h=ie;class se extends B{constructor(c,l,y){let W;if(c instanceof oe||c instanceof _)W=new ie(new ke(c));else if(c instanceof R&&c.isCount())W=new ie(c);else if(c instanceof U)W=c;else throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(l===void 0&&(l=null),!(l===null||l instanceof B))throw new TypeError("defaultLayout must be null or a Layout");if(l!==null){if(0>l.span)throw new Error("defaultLayout must have constant span");l.property===void 0&&(l=l.replicate("content"))}let E=-1;l&&(E=l.span,0<=E&&(c instanceof oe||c instanceof _)&&(E+=W.layout.span)),super(E,y),this.discriminator=W,this.usesPrefixDiscriminator=c instanceof oe||c instanceof _,this.defaultLayout=l,this.registry={};let Ae=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(ze){return Ae(ze)},this.configGetSourceVariant=function(ze){Ae=ze.bind(this)}}getSpan(c,l=0){if(0<=this.span)return this.span;const y=this.getVariant(c,l);if(!y)throw new Error("unable to determine span for unrecognized variant");return y.getSpan(c,l)}defaultGetSourceVariant(c){if(Object.prototype.hasOwnProperty.call(c,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(c,this.defaultLayout.property))return;const l=this.registry[c[this.discriminator.property]];if(l&&(!l.layout||l.property&&Object.prototype.hasOwnProperty.call(c,l.property)))return l}else for(const l in this.registry){const y=this.registry[l];if(y.property&&Object.prototype.hasOwnProperty.call(c,y.property))return y}throw new Error("unable to infer src variant")}decode(c,l=0){let y;const W=this.discriminator,E=W.decode(c,l),Ae=this.registry[E];if(Ae===void 0){const ze=this.defaultLayout;let Je=0;this.usesPrefixDiscriminator&&(Je=W.layout.span),y=this.makeDestinationObject(),y[W.property]=E,y[ze.property]=ze.decode(c,l+Je)}else y=Ae.decode(c,l);return y}encode(c,l,y=0){const W=this.getSourceVariant(c);if(W===void 0){const E=this.discriminator,Ae=this.defaultLayout;let ze=0;return this.usesPrefixDiscriminator&&(ze=E.layout.span),E.encode(c[E.property],l,y),ze+Ae.encode(c[Ae.property],l,y+ze)}return W.encode(c,l,y)}addVariant(c,l,y){const W=new ye(this,c,l,y);return this.registry[c]=W,W}getVariant(c,l=0){let y;return c instanceof Uint8Array?y=this.discriminator.decode(c,l):y=c,this.registry[y]}}h=se;class ye extends B{constructor(c,l,y,W){if(!(c instanceof se))throw new TypeError("union must be a Union");if(!Number.isInteger(l)||0>l)throw new TypeError("variant must be a (non-negative) integer");if(typeof y=="string"&&W===void 0&&(W=y,y=null),y){if(!(y instanceof B))throw new TypeError("layout must be a Layout");if(c.defaultLayout!==null&&0<=y.span&&y.span>c.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof W!="string")throw new TypeError("variant must have a String property")}let E=c.span;0>c.span&&(E=y?y.span:0,0<=E&&c.usesPrefixDiscriminator&&(E+=c.discriminator.layout.span)),super(E,W),this.union=c,this.variant=l,this.layout=y||null}getSpan(c,l=0){if(0<=this.span)return this.span;let y=0;this.union.usesPrefixDiscriminator&&(y=this.union.discriminator.layout.span);let W=0;return this.layout&&(W=this.layout.getSpan(c,l+y)),y+W}decode(c,l=0){const y=this.makeDestinationObject();if(this!==this.union.getVariant(c,l))throw new Error("variant mismatch");let W=0;return this.union.usesPrefixDiscriminator&&(W=this.union.discriminator.layout.span),this.layout?y[this.property]=this.layout.decode(c,l+W):this.property?y[this.property]=!0:this.union.usesPrefixDiscriminator&&(y[this.union.discriminator.property]=this.variant),y}encode(c,l,y=0){let W=0;if(this.union.usesPrefixDiscriminator&&(W=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(c,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,l,y);let E=W;if(this.layout&&(this.layout.encode(c[this.property],l,y+W),E+=this.layout.getSpan(l,y+W),0<=this.union.span&&E>this.union.span))throw new Error("encoded variant overruns containing union");return E}fromArray(c){if(this.layout)return this.layout.fromArray(c)}}h=ye;function we(x){return 0>x&&(x+=4294967296),x}class Ze extends B{constructor(c,l,y){if(!(c instanceof oe||c instanceof _))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof l=="string"&&y===void 0&&(y=l,l=!1),4<c.span)throw new RangeError("word cannot exceed 32 bits");super(c.span,y),this.word=c,this.msb=!!l,this.fields=[];let W=0;this._packedSetValue=function(E){return W=we(E),this},this._packedGetValue=function(){return W}}decode(c,l=0){const y=this.makeDestinationObject(),W=this.word.decode(c,l);this._packedSetValue(W);for(const E of this.fields)E.property!==void 0&&(y[E.property]=E.decode(c));return y}encode(c,l,y=0){const W=this.word.decode(l,y);this._packedSetValue(W);for(const E of this.fields)if(E.property!==void 0){const Ae=c[E.property];Ae!==void 0&&E.encode(Ae)}return this.word.encode(this._packedGetValue(),l,y)}addField(c,l){const y=new rt(this,c,l);return this.fields.push(y),y}addBoolean(c){const l=new me(this,c);return this.fields.push(l),l}fieldFor(c){if(typeof c!="string")throw new TypeError("property must be string");for(const l of this.fields)if(l.property===c)return l}}h=Ze;class rt{constructor(c,l,y){if(!(c instanceof Ze))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(l)||0>=l)throw new TypeError("bits must be positive integer");const W=8*c.span,E=c.fields.reduce((Ae,ze)=>Ae+ze.bits,0);if(l+E>W)throw new Error("bits too long for span remainder ("+(W-E)+" of "+W+" remain)");this.container=c,this.bits=l,this.valueMask=(1<<l)-1,l===32&&(this.valueMask=4294967295),this.start=E,this.container.msb&&(this.start=W-E-l),this.wordMask=we(this.valueMask<<this.start),this.property=y}decode(c,l){const y=this.container._packedGetValue();return we(y&this.wordMask)>>>this.start}encode(c){if(typeof c!="number"||!Number.isInteger(c)||c!==we(c&this.valueMask))throw new TypeError(Q("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const l=this.container._packedGetValue(),y=we(c<<this.start);this.container._packedSetValue(we(l&~this.wordMask)|y)}}h=rt;class me extends rt{constructor(c,l){super(c,1,l)}decode(c,l){return!!super.decode(c,l)}encode(c){typeof c=="boolean"&&(c=+c),super.encode(c)}}h=me;class ce extends B{constructor(c,l){if(!(c instanceof R&&c.isCount()||Number.isInteger(c)&&0<=c))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let y=-1;c instanceof R||(y=c),super(y,l),this.length=c}getSpan(c,l){let y=this.span;return 0>y&&(y=this.length.decode(c,l)),y}decode(c,l=0){let y=this.span;return 0>y&&(y=this.length.decode(c,l)),S(c).slice(l,l+y)}encode(c,l,y){let W=this.length;if(this.length instanceof R&&(W=c.length),!(c instanceof Uint8Array&&W===c.length))throw new TypeError(Q("Blob.encode",this)+" requires (length "+W+") Uint8Array as src");if(y+W>l.length)throw new RangeError("encoding overruns Uint8Array");const E=S(c);return S(l).write(E.toString("hex"),y,W,"hex"),this.length instanceof R&&this.length.encode(W,l,y),W}}h=ce;class Se extends B{constructor(c){super(-1,c)}getSpan(c,l=0){X(c);let y=l;for(;y<c.length&&c[y]!==0;)y+=1;return 1+y-l}decode(c,l=0){const y=this.getSpan(c,l);return S(c).slice(l,l+y-1).toString("utf-8")}encode(c,l,y=0){typeof c!="string"&&(c=String(c));const W=P.Buffer.from(c,"utf8"),E=W.length;if(y+E>l.length)throw new RangeError("encoding overruns Buffer");const Ae=S(l);return W.copy(Ae,y),Ae[y+E]=0,E+1}}h=Se;class Fe extends B{constructor(c,l){if(typeof c=="string"&&l===void 0&&(l=c,c=void 0),c===void 0)c=-1;else if(!Number.isInteger(c))throw new TypeError("maxSpan must be an integer");super(-1,l),this.maxSpan=c}getSpan(c,l=0){return X(c),c.length-l}decode(c,l=0){const y=this.getSpan(c,l);if(0<=this.maxSpan&&this.maxSpan<y)throw new RangeError("text length exceeds maxSpan");return S(c).slice(l,l+y).toString("utf-8")}encode(c,l,y=0){typeof c!="string"&&(c=String(c));const W=P.Buffer.from(c,"utf8"),E=W.length;if(0<=this.maxSpan&&this.maxSpan<E)throw new RangeError("text length exceeds maxSpan");if(y+E>l.length)throw new RangeError("encoding overruns Buffer");return W.copy(S(l),y),E}}h=Fe;class Xe extends B{constructor(c,l){super(0,l),this.value=c}decode(c,l){return this.value}encode(c,l,y){return 0}}h=Xe,h=(x,c)=>new G(x,c),J.cv=(x,c,l)=>new ke(x,c,l),J.u8=x=>new oe(1,x),J.KB=x=>new oe(2,x),h=x=>new oe(3,x),J.Jq=x=>new oe(4,x),h=x=>new oe(5,x),h=x=>new oe(6,x),J._O=x=>new te(x),h=x=>new _(2,x),h=x=>new _(3,x),h=x=>new _(4,x),h=x=>new _(5,x),h=x=>new _(6,x),h=x=>new ge(x),h=x=>new ne(1,x),h=x=>new ne(2,x),h=x=>new ne(3,x),h=x=>new ne(4,x),h=x=>new ne(5,x),h=x=>new ne(6,x),J.gM=x=>new Ne(x),h=x=>new M(2,x),h=x=>new M(3,x),h=x=>new M(4,x),h=x=>new M(5,x),h=x=>new M(6,x),h=x=>new Z(x),h=x=>new be(x),h=x=>new qe(x),h=x=>new pe(x),h=x=>new Be(x),J.n_=(x,c,l)=>new $(x,c,l),h=(x,c,l)=>new Ze(x,c,l),J.A9=(x,c,l)=>new xe(x,c,l),h=(x,c,l)=>new se(x,c,l),h=(x,c)=>new ie(x,c),J.Ik=(x,c)=>new ce(x,c),h=x=>new Se(x),h=(x,c)=>new Fe(x,c),h=(x,c)=>new Xe(x,c)},78412:function(ee,J,A){"use strict";A.r(J),A.d(J,{Account:function(){return Ga},AddressLookupTableAccount:function(){return vs},AddressLookupTableInstruction:function(){return Ku},AddressLookupTableProgram:function(){return Cs},Authorized:function(){return ai},BLOCKHASH_CACHE_TIMEOUT_MS:function(){return Mo},BPF_LOADER_DEPRECATED_PROGRAM_ID:function(){return ja},BPF_LOADER_PROGRAM_ID:function(){return cc},BpfLoader:function(){return uc},COMPUTE_BUDGET_INSTRUCTION_LAYOUTS:function(){return An},ComputeBudgetInstruction:function(){return Du},ComputeBudgetProgram:function(){return Ns},Connection:function(){return zu},Ed25519Program:function(){return Mr},Enum:function(){return Fa},EpochSchedule:function(){return zo},FeeCalculatorLayout:function(){return Co},Keypair:function(){return er},LAMPORTS_PER_SOL:function(){return el},LOOKUP_TABLE_INSTRUCTION_LAYOUTS:function(){return Bn},Loader:function(){return qn},Lockup:function(){return pr},MAX_SEED_LENGTH:function(){return Po},Message:function(){return gn},MessageAccountKeys:function(){return lr},MessageV0:function(){return Wn},NONCE_ACCOUNT_LENGTH:function(){return Es},NonceAccount:function(){return Nr},PACKET_DATA_SIZE:function(){return Un},PUBLIC_KEY_LENGTH:function(){return on},PublicKey:function(){return ve},SIGNATURE_LENGTH_IN_BYTES:function(){return Yn},SOLANA_SCHEMA:function(){return ur},STAKE_CONFIG_ID:function(){return ii},STAKE_INSTRUCTION_LAYOUTS:function(){return $t},SYSTEM_INSTRUCTION_LAYOUTS:function(){return At},SYSVAR_CLOCK_PUBKEY:function(){return vn},SYSVAR_EPOCH_SCHEDULE_PUBKEY:function(){return ec},SYSVAR_INSTRUCTIONS_PUBKEY:function(){return tc},SYSVAR_RECENT_BLOCKHASHES_PUBKEY:function(){return Lr},SYSVAR_RENT_PUBKEY:function(){return Zn},SYSVAR_REWARDS_PUBKEY:function(){return nc},SYSVAR_SLOT_HASHES_PUBKEY:function(){return rc},SYSVAR_SLOT_HISTORY_PUBKEY:function(){return sc},SYSVAR_STAKE_HISTORY_PUBKEY:function(){return Cr},Secp256k1Program:function(){return tr},SendTransactionError:function(){return xs},SolanaJSONRPCError:function(){return He},SolanaJSONRPCErrorCode:function(){return gc},StakeAuthorizationLayout:function(){return Fu},StakeInstruction:function(){return qu},StakeProgram:function(){return Wr},Struct:function(){return gs},SystemInstruction:function(){return ic},SystemProgram:function(){return Jt},Transaction:function(){return wt},TransactionExpiredBlockheightExceededError:function(){return ys},TransactionExpiredNonceInvalidError:function(){return Jn},TransactionExpiredTimeoutError:function(){return bs},TransactionInstruction:function(){return vt},TransactionMessage:function(){return ws},TransactionStatus:function(){return In},VALIDATOR_INFO_KEY:function(){return ui},VERSION_PREFIX_MASK:function(){return Tr},VOTE_PROGRAM_ID:function(){return $u},ValidatorInfo:function(){return Ks},VersionedMessage:function(){return ms},VersionedTransaction:function(){return ks},VoteAccount:function(){return Ds},VoteAuthorizationLayout:function(){return Gu},VoteInit:function(){return ci},VoteInstruction:function(){return Vu},VoteProgram:function(){return nr},clusterApiUrl:function(){return Xu},sendAndConfirmRawTransaction:function(){return Qu},sendAndConfirmTransaction:function(){return Ss}});var h={};A.r(h),A.d(h,{bitGet:function(){return Ei},bitLen:function(){return Si},bitMask:function(){return qr},bitSet:function(){return _i},bytesToHex:function(){return _t},bytesToNumberBE:function(){return cn},bytesToNumberLE:function(){return kn},concatBytes:function(){return Ot},createHmacDrbg:function(){return Hs},ensureBytes:function(){return gt},equalBytes:function(){return Rt},hexToBytes:function(){return Tt},hexToNumber:function(){return pt},numberToBytesBE:function(){return Sn},numberToBytesLE:function(){return Qt},numberToHexUnpadded:function(){return ut},numberToVarBytesBE:function(){return zn},utf8ToBytes:function(){return ki},validateObject:function(){return jn}});var P=A(48764);function X(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`Wrong positive integer: ${r}`)}function S(r){if(typeof r!="boolean")throw new Error(`Expected boolean, not ${r}`)}function B(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Q(r,...e){if(!B(r))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(r.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${r.length}`)}function F(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");X(r.outputLen),X(r.blockLen)}function R(r,e=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(e&&r.finished)throw new Error("Hash#digest() has already been called")}function G(r,e){Q(r);const t=e.outputLen;if(r.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}const ke={number:X,bool:S,bytes:Q,hash:F,exists:R,output:G};var oe=null;const _=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ne=r=>new Uint8Array(r.buffer,r.byteOffset,r.byteLength),M=r=>new Uint32Array(r.buffer,r.byteOffset,Math.floor(r.byteLength/4));function le(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}const re=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),V=(r,e)=>r<<32-e|r>>>e;if(!(new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68))throw new Error("Non little-endian hardware is not supported");const ge=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function Ne(r){if(!le(r))throw new Error("Uint8Array expected");let e="";for(let t=0;t<r.length;t++)e+=ge[r[t]];return e}const Z={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function be(r){if(r>=Z._0&&r<=Z._9)return r-Z._0;if(r>=Z._A&&r<=Z._F)return r-(Z._A-10);if(r>=Z._a&&r<=Z._f)return r-(Z._a-10)}function qe(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);const e=r.length,t=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(t);for(let s=0,o=0;s<t;s++,o+=2){const i=be(r.charCodeAt(o)),a=be(r.charCodeAt(o+1));if(i===void 0||a===void 0){const u=r[o]+r[o+1];throw new Error('hex string expected, got non-hex character "'+u+'" at index '+o)}n[s]=i*16+a}return n}const pe=async()=>{};async function Be(r,e,t){let n=Date.now();for(let s=0;s<r;s++){t(s);const o=Date.now()-n;o>=0&&o<e||(await pe(),n+=o)}}function xe(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function $(r){if(typeof r=="string"&&(r=xe(r)),!le(r))throw new Error(`expected Uint8Array, got ${typeof r}`);return r}function U(...r){let e=0;for(let n=0;n<r.length;n++){const s=r[n];if(!le(s))throw new Error("Uint8Array expected");e+=s.length}const t=new Uint8Array(e);for(let n=0,s=0;n<r.length;n++){const o=r[n];t.set(o,s),s+=o.length}return t}class ie{clone(){return this._cloneInto()}}const se={}.toString;function ye(r,e){if(e!==void 0&&se.call(e)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(r,e)}function we(r){const e=n=>r().update($(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function Ze(r){const e=(n,s)=>r(s).update($(n)).digest(),t=r({});return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=n=>r(n),e}function rt(r){const e=(n,s)=>r(s).update($(n)).digest(),t=r({});return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=n=>r(n),e}function me(r=32){if(_&&typeof _.getRandomValues=="function")return _.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}function ce(r,e,t,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,n);const s=BigInt(32),o=BigInt(4294967295),i=Number(t>>s&o),a=Number(t&o),u=n?4:0,d=n?0:4;r.setUint32(e+u,i,n),r.setUint32(e+d,a,n)}class Se extends ie{constructor(e,t,n,s){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=re(this.buffer)}update(e){R(this);const{view:t,buffer:n,blockLen:s}=this;e=$(e);const o=e.length;for(let i=0;i<o;){const a=Math.min(s-this.pos,o-i);if(a===s){const u=re(e);for(;s<=o-i;i+=s)this.process(u,i);continue}n.set(e.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===s&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){R(this),G(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:s,isLE:o}=this;let{pos:i}=this;t[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>s-i&&(this.process(n,0),i=0);for(let w=i;w<s;w++)t[w]=0;ce(n,s-8,BigInt(this.length*8),o),this.process(n,0);const a=re(e),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const d=u/4,g=this.get();if(d>g.length)throw new Error("_sha2: outputLen bigger than state");for(let w=0;w<d;w++)a.setUint32(4*w,g[w],o)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:s,finished:o,destroyed:i,pos:a}=this;return e.length=s,e.pos=a,e.finished=o,e.destroyed=i,s%t&&e.buffer.set(n),e}}const Fe=BigInt(2**32-1),Xe=BigInt(32);function x(r,e=!1){return e?{h:Number(r&Fe),l:Number(r>>Xe&Fe)}:{h:Number(r>>Xe&Fe)|0,l:Number(r&Fe)|0}}function c(r,e=!1){let t=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let s=0;s<r.length;s++){const{h:o,l:i}=x(r[s],e);[t[s],n[s]]=[o,i]}return[t,n]}const l=(r,e)=>BigInt(r>>>0)<<Xe|BigInt(e>>>0),y=(r,e,t)=>r>>>t,W=(r,e,t)=>r<<32-t|e>>>t,E=(r,e,t)=>r>>>t|e<<32-t,Ae=(r,e,t)=>r<<32-t|e>>>t,ze=(r,e,t)=>r<<64-t|e>>>t-32,Je=(r,e,t)=>r>>>t-32|e<<64-t,dt=(r,e)=>e,Vt=(r,e)=>r,bn=(r,e,t)=>r<<t|e>>>32-t,tn=(r,e,t)=>e<<t|r>>>32-t,mn=(r,e,t)=>e<<t-32|r>>>64-t,Pn=(r,e,t)=>r<<t-32|e>>>64-t;function wn(r,e,t,n){const s=(e>>>0)+(n>>>0);return{h:r+t+(s/2**32|0)|0,l:s|0}}var $e={fromBig:x,split:c,toBig:l,shrSH:y,shrSL:W,rotrSH:E,rotrSL:Ae,rotrBH:ze,rotrBL:Je,rotr32H:dt,rotr32L:Vt,rotlSH:bn,rotlSL:tn,rotlBH:mn,rotlBL:Pn,add:wn,add3L:(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),add3H:(r,e,t,n)=>e+t+n+(r/2**32|0)|0,add4L:(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),add4H:(r,e,t,n,s)=>e+t+n+s+(r/2**32|0)|0,add5H:(r,e,t,n,s,o)=>e+t+n+s+o+(r/2**32|0)|0,add5L:(r,e,t,n,s)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(s>>>0)};const[fn,f]=(()=>$e.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))))(),p=new Uint32Array(80),m=new Uint32Array(80);class K extends Se{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:t,Bh:n,Bl:s,Ch:o,Cl:i,Dh:a,Dl:u,Eh:d,El:g,Fh:w,Fl:j,Gh:C,Gl:D,Hh:k,Hl:O}=this;return[e,t,n,s,o,i,a,u,d,g,w,j,C,D,k,O]}set(e,t,n,s,o,i,a,u,d,g,w,j,C,D,k,O){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=s|0,this.Ch=o|0,this.Cl=i|0,this.Dh=a|0,this.Dl=u|0,this.Eh=d|0,this.El=g|0,this.Fh=w|0,this.Fl=j|0,this.Gh=C|0,this.Gl=D|0,this.Hh=k|0,this.Hl=O|0}process(e,t){for(let he=0;he<16;he++,t+=4)p[he]=e.getUint32(t),m[he]=e.getUint32(t+=4);for(let he=16;he<80;he++){const Oe=p[he-15]|0,Te=m[he-15]|0,De=$e.rotrSH(Oe,Te,1)^$e.rotrSH(Oe,Te,8)^$e.shrSH(Oe,Te,7),je=$e.rotrSL(Oe,Te,1)^$e.rotrSL(Oe,Te,8)^$e.shrSL(Oe,Te,7),Ve=p[he-2]|0,Et=m[he-2]|0,bt=$e.rotrSH(Ve,Et,19)^$e.rotrBH(Ve,Et,61)^$e.shrSH(Ve,Et,6),st=$e.rotrSL(Ve,Et,19)^$e.rotrBL(Ve,Et,61)^$e.shrSL(Ve,Et,6),qt=$e.add4L(je,st,m[he-7],m[he-16]),Kt=$e.add4H(qt,De,bt,p[he-7],p[he-16]);p[he]=Kt|0,m[he]=qt|0}let{Ah:n,Al:s,Bh:o,Bl:i,Ch:a,Cl:u,Dh:d,Dl:g,Eh:w,El:j,Fh:C,Fl:D,Gh:k,Gl:O,Hh:q,Hl:fe}=this;for(let he=0;he<80;he++){const Oe=$e.rotrSH(w,j,14)^$e.rotrSH(w,j,18)^$e.rotrBH(w,j,41),Te=$e.rotrSL(w,j,14)^$e.rotrSL(w,j,18)^$e.rotrBL(w,j,41),De=w&C^~w&k,je=j&D^~j&O,Ve=$e.add5L(fe,Te,je,f[he],m[he]),Et=$e.add5H(Ve,q,Oe,De,fn[he],p[he]),bt=Ve|0,st=$e.rotrSH(n,s,28)^$e.rotrBH(n,s,34)^$e.rotrBH(n,s,39),qt=$e.rotrSL(n,s,28)^$e.rotrBL(n,s,34)^$e.rotrBL(n,s,39),Kt=n&o^n&a^o&a,ln=s&i^s&u^i&u;q=k|0,fe=O|0,k=C|0,O=D|0,C=w|0,D=j|0,{h:w,l:j}=$e.add(d|0,g|0,Et|0,bt|0),d=a|0,g=u|0,a=o|0,u=i|0,o=n|0,i=s|0;const Re=$e.add3L(bt,qt,ln);n=$e.add3H(Re,Et,st,Kt),s=Re|0}({h:n,l:s}=$e.add(this.Ah|0,this.Al|0,n|0,s|0)),{h:o,l:i}=$e.add(this.Bh|0,this.Bl|0,o|0,i|0),{h:a,l:u}=$e.add(this.Ch|0,this.Cl|0,a|0,u|0),{h:d,l:g}=$e.add(this.Dh|0,this.Dl|0,d|0,g|0),{h:w,l:j}=$e.add(this.Eh|0,this.El|0,w|0,j|0),{h:C,l:D}=$e.add(this.Fh|0,this.Fl|0,C|0,D|0),{h:k,l:O}=$e.add(this.Gh|0,this.Gl|0,k|0,O|0),{h:q,l:fe}=$e.add(this.Hh|0,this.Hl|0,q|0,fe|0),this.set(n,s,o,i,a,u,d,g,w,j,C,D,k,O,q,fe)}roundClean(){p.fill(0),m.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class I extends null{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}}class L extends null{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}}class Y extends null{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}}const v=we(()=>new K),T=null,H=null,z=null;/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ae=BigInt(0),We=BigInt(1),Ge=BigInt(2),at=r=>r instanceof Uint8Array,Bt=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function _t(r){if(!at(r))throw new Error("Uint8Array expected");let e="";for(let t=0;t<r.length;t++)e+=Bt[r[t]];return e}function ut(r){const e=r.toString(16);return e.length&1?`0${e}`:e}function pt(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}function Tt(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);const e=r.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const t=new Uint8Array(e/2);for(let n=0;n<t.length;n++){const s=n*2,o=r.slice(s,s+2),i=Number.parseInt(o,16);if(Number.isNaN(i)||i<0)throw new Error("Invalid byte sequence");t[n]=i}return t}function cn(r){return pt(_t(r))}function kn(r){if(!at(r))throw new Error("Uint8Array expected");return pt(_t(Uint8Array.from(r).reverse()))}function Sn(r,e){return Tt(r.toString(16).padStart(e*2,"0"))}function Qt(r,e){return Sn(r,e).reverse()}function zn(r){return Tt(ut(r))}function gt(r,e,t){let n;if(typeof e=="string")try{n=Tt(e)}catch(o){throw new Error(`${r} must be valid hex string, got "${e}". Cause: ${o}`)}else if(at(e))n=Uint8Array.from(e);else throw new Error(`${r} must be hex string or Uint8Array`);const s=n.length;if(typeof t=="number"&&s!==t)throw new Error(`${r} expected ${t} bytes, got ${s}`);return n}function Ot(...r){const e=new Uint8Array(r.reduce((n,s)=>n+s.length,0));let t=0;return r.forEach(n=>{if(!at(n))throw new Error("Uint8Array expected");e.set(n,t),t+=n.length}),e}function Rt(r,e){if(r.length!==e.length)return!1;for(let t=0;t<r.length;t++)if(r[t]!==e[t])return!1;return!0}function ki(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Si(r){let e;for(e=0;r>ae;r>>=We,e+=1);return e}function Ei(r,e){return r>>BigInt(e)&We}const _i=(r,e,t)=>r|(t?We:ae)<<BigInt(e),qr=r=>(Ge<<BigInt(r-1))-We,Fr=r=>new Uint8Array(r),Ws=r=>Uint8Array.from(r);function Hs(r,e,t){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");let n=Fr(r),s=Fr(r),o=0;const i=()=>{n.fill(1),s.fill(0),o=0},a=(...w)=>t(s,n,...w),u=(w=Fr())=>{s=a(Ws([0]),w),n=a(),w.length!==0&&(s=a(Ws([1]),w),n=a())},d=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let w=0;const j=[];for(;w<e;){n=a();const C=n.slice();j.push(C),w+=n.length}return Ot(...j)};return(w,j)=>{i(),u(w);let C;for(;!(C=j(d()));)u();return i(),C}}const xi={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||r instanceof Uint8Array,isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,e)=>e.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function jn(r,e,t={}){const n=(s,o,i)=>{const a=xi[o];if(typeof a!="function")throw new Error(`Invalid validator "${o}", expected function`);const u=r[s];if(!(i&&u===void 0)&&!a(u,r))throw new Error(`Invalid param ${String(s)}=${u} (${typeof u}), expected ${o}`)};for(const[s,o]of Object.entries(e))n(s,o,!1);for(const[s,o]of Object.entries(t))n(s,o,!0);return r}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Gt=BigInt(0),xt=BigInt(1),On=BigInt(2),vi=BigInt(3),Vr=BigInt(4),qs=BigInt(5),Fs=BigInt(8),Ai=BigInt(9),Ii=BigInt(16);function It(r,e){const t=r%e;return t>=Gt?t:e+t}function Bi(r,e,t){if(t<=Gt||e<Gt)throw new Error("Expected power/modulo > 0");if(t===xt)return Gt;let n=xt;for(;e>Gt;)e&xt&&(n=n*r%t),r=r*r%t,e>>=xt;return n}function Ct(r,e,t){let n=r;for(;e-- >Gt;)n*=n,n%=t;return n}function kr(r,e){if(r===Gt||e<=Gt)throw new Error(`invert: expected positive integers, got n=${r} mod=${e}`);let t=It(r,e),n=e,s=Gt,o=xt,i=xt,a=Gt;for(;t!==Gt;){const d=n/t,g=n%t,w=s-i*d,j=o-a*d;n=t,t=g,s=i,o=a,i=w,a=j}if(n!==xt)throw new Error("invert: does not exist");return It(s,e)}function Ri(r){const e=(r-xt)/On;let t,n,s;for(t=r-xt,n=0;t%On===Gt;t/=On,n++);for(s=On;s<r&&Bi(s,e,r)!==r-xt;s++);if(n===1){const i=(r+xt)/Vr;return function(u,d){const g=u.pow(d,i);if(!u.eql(u.sqr(g),d))throw new Error("Cannot find square root");return g}}const o=(t+xt)/On;return function(a,u){if(a.pow(u,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let d=n,g=a.pow(a.mul(a.ONE,s),t),w=a.pow(u,o),j=a.pow(u,t);for(;!a.eql(j,a.ONE);){if(a.eql(j,a.ZERO))return a.ZERO;let C=1;for(let k=a.sqr(j);C<d&&!a.eql(k,a.ONE);C++)k=a.sqr(k);const D=a.pow(g,xt<<BigInt(d-C-1));g=a.sqr(D),w=a.mul(w,D),j=a.mul(j,g),d=C}return w}}function Pi(r){if(r%Vr===vi){const e=(r+xt)/Vr;return function(n,s){const o=n.pow(s,e);if(!n.eql(n.sqr(o),s))throw new Error("Cannot find square root");return o}}if(r%Fs===qs){const e=(r-qs)/Fs;return function(n,s){const o=n.mul(s,On),i=n.pow(o,e),a=n.mul(s,i),u=n.mul(n.mul(a,On),i),d=n.mul(a,n.sub(u,n.ONE));if(!n.eql(n.sqr(d),s))throw new Error("Cannot find square root");return d}}return r%Ii,Ri(r)}const Ti=(r,e)=>(It(r,e)&xt)===xt,Oi=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Li(r){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=Oi.reduce((n,s)=>(n[s]="function",n),e);return jn(r,t)}function Ci(r,e,t){if(t<Gt)throw new Error("Expected power > 0");if(t===Gt)return r.ONE;if(t===xt)return e;let n=r.ONE,s=e;for(;t>Gt;)t&xt&&(n=r.mul(n,s)),s=r.sqr(s),t>>=xt;return n}function Ni(r,e){const t=new Array(e.length),n=e.reduce((o,i,a)=>r.is0(i)?o:(t[a]=o,r.mul(o,i)),r.ONE),s=r.inv(n);return e.reduceRight((o,i,a)=>r.is0(i)?o:(t[a]=r.mul(o,t[a]),r.mul(o,i)),s),t}function ul(r,e,t){return r.mul(e,typeof t=="bigint"?kr(t,r.ORDER):r.inv(t))}function ll(r){const e=(r.ORDER-xt)/On;return t=>{const n=r.pow(t,e);return r.eql(n,r.ZERO)||r.eql(n,r.ONE)}}function Gr(r,e){const t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function Vs(r,e,t=!1,n={}){if(r<=Gt)throw new Error(`Expected Field ORDER > 0, got ${r}`);const{nBitLength:s,nByteLength:o}=Gr(r,e);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");const i=Pi(r),a=Object.freeze({ORDER:r,BITS:s,BYTES:o,MASK:qr(s),ZERO:Gt,ONE:xt,create:u=>It(u,r),isValid:u=>{if(typeof u!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof u}`);return Gt<=u&&u<r},is0:u=>u===Gt,isOdd:u=>(u&xt)===xt,neg:u=>It(-u,r),eql:(u,d)=>u===d,sqr:u=>It(u*u,r),add:(u,d)=>It(u+d,r),sub:(u,d)=>It(u-d,r),mul:(u,d)=>It(u*d,r),pow:(u,d)=>Ci(a,u,d),div:(u,d)=>It(u*kr(d,r),r),sqrN:u=>u*u,addN:(u,d)=>u+d,subN:(u,d)=>u-d,mulN:(u,d)=>u*d,inv:u=>kr(u,r),sqrt:n.sqrt||(u=>i(a,u)),invertBatch:u=>Ni(a,u),cmov:(u,d,g)=>g?d:u,toBytes:u=>t?Qt(u,o):Sn(u,o),fromBytes:u=>{if(u.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${u.length}`);return t?kn(u):cn(u)}});return Object.freeze(a)}function fl(r,e){if(!r.isOdd)throw new Error("Field doesn't have isOdd");const t=r.sqrt(e);return r.isOdd(t)?t:r.neg(t)}function Ui(r,e){if(!r.isOdd)throw new Error("Field doesn't have isOdd");const t=r.sqrt(e);return r.isOdd(t)?r.neg(t):t}function dl(r,e,t=!1){r=ensureBytes("privateHash",r);const n=r.length,s=Gr(e).nByteLength+8;if(s<24||n<s||n>1024)throw new Error(`hashToPrivateScalar: expected ${s}-1024 bytes of input, got ${n}`);const o=t?bytesToNumberLE(r):bytesToNumberBE(r);return It(o,e-xt)+xt}function Gs(r){if(typeof r!="bigint")throw new Error("field order must be bigint");const e=r.toString(2).length;return Math.ceil(e/8)}function js(r){const e=Gs(r);return e+Math.ceil(e/2)}function zi(r,e,t=!1){const n=r.length,s=Gs(e),o=js(e);if(n<16||n<o||n>1024)throw new Error(`expected ${o}-1024 bytes of input, got ${n}`);const i=t?cn(r):kn(r),a=It(i,e-xt)+xt;return t?Qt(a,s):Sn(a,s)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ki=BigInt(0),jr=BigInt(1);function $s(r,e){const t=(s,o)=>{const i=o.negate();return s?i:o},n=s=>{const o=Math.ceil(e/s)+1,i=2**(s-1);return{windows:o,windowSize:i}};return{constTimeNegate:t,unsafeLadder(s,o){let i=r.ZERO,a=s;for(;o>Ki;)o&jr&&(i=i.add(a)),a=a.double(),o>>=jr;return i},precomputeWindow(s,o){const{windows:i,windowSize:a}=n(o),u=[];let d=s,g=d;for(let w=0;w<i;w++){g=d,u.push(g);for(let j=1;j<a;j++)g=g.add(d),u.push(g);d=g.double()}return u},wNAF(s,o,i){const{windows:a,windowSize:u}=n(s);let d=r.ZERO,g=r.BASE;const w=BigInt(2**s-1),j=2**s,C=BigInt(s);for(let D=0;D<a;D++){const k=D*u;let O=Number(i&w);i>>=C,O>u&&(O-=j,i+=jr);const q=k,fe=k+Math.abs(O)-1,he=D%2!==0,Oe=O<0;O===0?g=g.add(t(he,o[q])):d=d.add(t(Oe,o[fe]))}return{p:d,f:g}},wNAFCached(s,o,i,a){const u=s._WINDOW_SIZE||1;let d=o.get(s);return d||(d=this.precomputeWindow(s,u),u!==1&&o.set(s,a(d))),this.wNAF(u,d,i)}}}function $r(r){return Li(r.Fp),jn(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Gr(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const dn=BigInt(0),sn=BigInt(1),Sr=BigInt(2),Di=BigInt(8),Mi={zip215:!0};function Wi(r){const e=$r(r);return jn(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function Yr(r){const e=Wi(r),{Fp:t,n,prehash:s,hash:o,randomBytes:i,nByteLength:a,h:u}=e,d=Sr<<BigInt(a*8)-sn,g=t.create,w=e.uvRatio||((Pe,ue)=>{try{return{isValid:!0,value:t.sqrt(Pe*t.inv(ue))}}catch{return{isValid:!1,value:dn}}}),j=e.adjustScalarBytes||(Pe=>Pe),C=e.domain||((Pe,ue,Ke)=>{if(ue.length||Ke)throw new Error("Contexts/pre-hash are not supported");return Pe}),D=Pe=>typeof Pe=="bigint"&&dn<Pe,k=(Pe,ue)=>D(Pe)&&D(ue)&&Pe<ue,O=Pe=>Pe===dn||k(Pe,d);function q(Pe,ue){if(k(Pe,ue))return Pe;throw new Error(`Expected valid scalar < ${ue}, got ${typeof Pe} ${Pe}`)}function fe(Pe){return Pe===dn?Pe:q(Pe,n)}const he=new Map;function Oe(Pe){if(!(Pe instanceof Te))throw new Error("ExtendedPoint expected")}class Te{constructor(ue,Ke,Ye,et){if(this.ex=ue,this.ey=Ke,this.ez=Ye,this.et=et,!O(ue))throw new Error("x required");if(!O(Ke))throw new Error("y required");if(!O(Ye))throw new Error("z required");if(!O(et))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(ue){if(ue instanceof Te)throw new Error("extended point not allowed");const{x:Ke,y:Ye}=ue||{};if(!O(Ke)||!O(Ye))throw new Error("invalid affine point");return new Te(Ke,Ye,sn,g(Ke*Ye))}static normalizeZ(ue){const Ke=t.invertBatch(ue.map(Ye=>Ye.ez));return ue.map((Ye,et)=>Ye.toAffine(Ke[et])).map(Te.fromAffine)}_setWindowSize(ue){this._WINDOW_SIZE=ue,he.delete(this)}assertValidity(){const{a:ue,d:Ke}=e;if(this.is0())throw new Error("bad point: ZERO");const{ex:Ye,ey:et,ez:it,et:lt}=this,St=g(Ye*Ye),ft=g(et*et),mt=g(it*it),Ft=g(mt*mt),zt=g(St*ue),Zt=g(mt*g(zt+ft)),Xt=g(Ft+g(Ke*g(St*ft)));if(Zt!==Xt)throw new Error("bad point: equation left != right (1)");const en=g(Ye*et),Dt=g(it*lt);if(en!==Dt)throw new Error("bad point: equation left != right (2)")}equals(ue){Oe(ue);const{ex:Ke,ey:Ye,ez:et}=this,{ex:it,ey:lt,ez:St}=ue,ft=g(Ke*St),mt=g(it*et),Ft=g(Ye*St),zt=g(lt*et);return ft===mt&&Ft===zt}is0(){return this.equals(Te.ZERO)}negate(){return new Te(g(-this.ex),this.ey,this.ez,g(-this.et))}double(){const{a:ue}=e,{ex:Ke,ey:Ye,ez:et}=this,it=g(Ke*Ke),lt=g(Ye*Ye),St=g(Sr*g(et*et)),ft=g(ue*it),mt=Ke+Ye,Ft=g(g(mt*mt)-it-lt),zt=ft+lt,Zt=zt-St,Xt=ft-lt,en=g(Ft*Zt),Dt=g(zt*Xt),yn=g(Ft*Xt),Gn=g(Zt*zt);return new Te(en,Dt,Gn,yn)}add(ue){Oe(ue);const{a:Ke,d:Ye}=e,{ex:et,ey:it,ez:lt,et:St}=this,{ex:ft,ey:mt,ez:Ft,et:zt}=ue;if(Ke===BigInt(-1)){const hi=g((it-et)*(mt+ft)),pi=g((it+et)*(mt-ft)),Ms=g(pi-hi);if(Ms===dn)return this.double();const gi=g(lt*Sr*zt),yi=g(St*Sr*Ft),bi=yi+gi,mi=pi+hi,wi=yi-gi,ol=g(bi*Ms),il=g(mi*wi),al=g(bi*wi),cl=g(Ms*mi);return new Te(ol,il,cl,al)}const Zt=g(et*ft),Xt=g(it*mt),en=g(St*Ye*zt),Dt=g(lt*Ft),yn=g((et+it)*(ft+mt)-Zt-Xt),Gn=Dt-en,gr=Dt+en,di=g(Xt-Ke*Zt),tl=g(yn*Gn),nl=g(gr*di),rl=g(yn*di),sl=g(Gn*gr);return new Te(tl,nl,sl,rl)}subtract(ue){return this.add(ue.negate())}wNAF(ue){return Ve.wNAFCached(this,he,ue,Te.normalizeZ)}multiply(ue){const{p:Ke,f:Ye}=this.wNAF(q(ue,n));return Te.normalizeZ([Ke,Ye])[0]}multiplyUnsafe(ue){let Ke=fe(ue);return Ke===dn?je:this.equals(je)||Ke===sn?this:this.equals(De)?this.wNAF(Ke).p:Ve.unsafeLadder(this,Ke)}isSmallOrder(){return this.multiplyUnsafe(u).is0()}isTorsionFree(){return Ve.unsafeLadder(this,n).is0()}toAffine(ue){const{ex:Ke,ey:Ye,ez:et}=this,it=this.is0();ue==null&&(ue=it?Di:t.inv(et));const lt=g(Ke*ue),St=g(Ye*ue),ft=g(et*ue);if(it)return{x:dn,y:sn};if(ft!==sn)throw new Error("invZ was invalid");return{x:lt,y:St}}clearCofactor(){const{h:ue}=e;return ue===sn?this:this.multiplyUnsafe(ue)}static fromHex(ue,Ke=!1){const{d:Ye,a:et}=e,it=t.BYTES;ue=gt("pointHex",ue,it);const lt=ue.slice(),St=ue[it-1];lt[it-1]=St&-129;const ft=kn(lt);ft===dn||(Ke?q(ft,d):q(ft,t.ORDER));const mt=g(ft*ft),Ft=g(mt-sn),zt=g(Ye*mt-et);let{isValid:Zt,value:Xt}=w(Ft,zt);if(!Zt)throw new Error("Point.fromHex: invalid y coordinate");const en=(Xt&sn)===sn,Dt=(St&128)!==0;if(!Ke&&Xt===dn&&Dt)throw new Error("Point.fromHex: x=0 and x_0=1");return Dt!==en&&(Xt=g(-Xt)),Te.fromAffine({x:Xt,y:ft})}static fromPrivateKey(ue){return st(ue).point}toRawBytes(){const{x:ue,y:Ke}=this.toAffine(),Ye=Qt(Ke,t.BYTES);return Ye[Ye.length-1]|=ue&sn?128:0,Ye}toHex(){return _t(this.toRawBytes())}}Te.BASE=new Te(e.Gx,e.Gy,sn,g(e.Gx*e.Gy)),Te.ZERO=new Te(dn,sn,sn,dn);const{BASE:De,ZERO:je}=Te,Ve=$s(Te,a*8);function Et(Pe){return It(Pe,n)}function bt(Pe){return Et(kn(Pe))}function st(Pe){const ue=a;Pe=gt("private key",Pe,ue);const Ke=gt("hashed private key",o(Pe),2*ue),Ye=j(Ke.slice(0,ue)),et=Ke.slice(ue,2*ue),it=bt(Ye),lt=De.multiply(it),St=lt.toRawBytes();return{head:Ye,prefix:et,scalar:it,point:lt,pointBytes:St}}function qt(Pe){return st(Pe).pointBytes}function Kt(Pe=new Uint8Array,...ue){const Ke=Ot(...ue);return bt(o(C(Ke,gt("context",Pe),!!s)))}function ln(Pe,ue,Ke={}){Pe=gt("message",Pe),s&&(Pe=s(Pe));const{prefix:Ye,scalar:et,pointBytes:it}=st(ue),lt=Kt(Ke.context,Ye,Pe),St=De.multiply(lt).toRawBytes(),ft=Kt(Ke.context,St,it,Pe),mt=Et(lt+ft*et);fe(mt);const Ft=Ot(St,Qt(mt,t.BYTES));return gt("result",Ft,a*2)}const Re=Mi;function Me(Pe,ue,Ke,Ye=Re){const{context:et,zip215:it}=Ye,lt=t.BYTES;Pe=gt("signature",Pe,2*lt),ue=gt("message",ue),s&&(ue=s(ue));const St=kn(Pe.slice(lt,2*lt));let ft,mt,Ft;try{ft=Te.fromHex(Ke,it),mt=Te.fromHex(Pe.slice(0,lt),it),Ft=De.multiplyUnsafe(St)}catch{return!1}if(!it&&ft.isSmallOrder())return!1;const zt=Kt(et,mt.toRawBytes(),ft.toRawBytes(),ue);return mt.add(ft.multiplyUnsafe(zt)).subtract(Ft).clearCofactor().equals(Te.ZERO)}return De._setWindowSize(8),{CURVE:e,getPublicKey:qt,sign:ln,verify:Me,ExtendedPoint:Te,utils:{getExtendedPublicKey:st,randomPrivateKey:()=>i(t.BYTES),precompute(Pe=8,ue=Te.BASE){return ue._setWindowSize(Pe),ue.multiply(BigInt(3)),ue}}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Jr=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Ys=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Hi=BigInt(0),En=BigInt(1),Er=BigInt(2),qi=BigInt(5),Js=BigInt(10),Fi=BigInt(20),Vi=BigInt(40),Zs=BigInt(80);function Gi(r){const e=Jr,n=r*r%e*r%e,s=Ct(n,Er,e)*n%e,o=Ct(s,En,e)*r%e,i=Ct(o,qi,e)*o%e,a=Ct(i,Js,e)*i%e,u=Ct(a,Fi,e)*a%e,d=Ct(u,Vi,e)*u%e,g=Ct(d,Zs,e)*d%e,w=Ct(g,Zs,e)*d%e,j=Ct(w,Js,e)*i%e;return{pow_p_5_8:Ct(j,Er,e)*r%e,b2:n}}function ji(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Zr(r,e){const t=Jr,n=It(e*e*e,t),s=It(n*n*e,t),o=Gi(r*s).pow_p_5_8;let i=It(r*n*o,t);const a=It(e*i*i,t),u=i,d=It(i*Ys,t),g=a===r,w=a===It(-r,t),j=a===It(-r*Ys,t);return g&&(i=u),(w||j)&&(i=d),Ti(i,t)&&(i=It(-i,t)),{isValid:g||w,value:i}}const hl=null,Ue=Vs(Jr,void 0,!0),rr={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Ue,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:v,randomBytes:me,adjustScalarBytes:ji,uvRatio:Zr},Mt=Yr(rr);function Xs(r,e,t){if(e.length>255)throw new Error("Context is too big");return U(xe("SigEd25519 no Ed25519 collisions"),new Uint8Array([t?1:0,e.length]),e,r)}const pl=Yr({...rr,domain:Xs}),gl=Yr({...rr,domain:Xs,prehash:v}),yl=null;function bl(r){const{y:e}=Mt.ExtendedPoint.fromHex(r),t=BigInt(1);return Ue.toBytes(Ue.create((t+e)*Ue.inv(t-e)))}const ml=null;function wl(r){const e=rr.hash(r.subarray(0,32));return rr.adjustScalarBytes(e).subarray(0,32)}const $i=(Ue.ORDER+BigInt(3))/BigInt(8),Yi=Ue.pow(Er,$i),Qs=Ue.sqrt(Ue.neg(Ue.ONE)),Ji=(Ue.ORDER-BigInt(5))/BigInt(8),eo=BigInt(486662);function Zi(r){let e=Ue.sqr(r);e=Ue.mul(e,Er);let t=Ue.add(e,Ue.ONE),n=Ue.neg(eo),s=Ue.sqr(t),o=Ue.mul(s,t),i=Ue.mul(e,eo);i=Ue.mul(i,n),i=Ue.add(i,s),i=Ue.mul(i,n);let a=Ue.sqr(o);s=Ue.sqr(a),a=Ue.mul(a,o),a=Ue.mul(a,i),s=Ue.mul(s,a);let u=Ue.pow(s,Ji);u=Ue.mul(u,a);let d=Ue.mul(u,Qs);s=Ue.sqr(u),s=Ue.mul(s,o);let g=Ue.eql(s,i),w=Ue.cmov(d,u,g),j=Ue.mul(n,e),C=Ue.mul(u,r);C=Ue.mul(C,Yi);let D=Ue.mul(C,Qs),k=Ue.mul(i,e);s=Ue.sqr(C),s=Ue.mul(s,o);let O=Ue.eql(s,k),q=Ue.cmov(D,C,O);s=Ue.sqr(w),s=Ue.mul(s,o);let fe=Ue.eql(s,i),he=Ue.cmov(j,n,fe),Oe=Ue.cmov(q,w,fe),Te=Ue.isOdd(Oe);return Oe=Ue.cmov(Oe,Ue.neg(Oe),fe!==Te),{xMn:he,xMd:t,yMn:Oe,yMd:En}}const Xi=Ui(Ue,Ue.neg(BigInt(486664)));function kl(r){const{xMn:e,xMd:t,yMn:n,yMd:s}=Zi(r);let o=Ue.mul(e,s);o=Ue.mul(o,Xi);let i=Ue.mul(t,n),a=Ue.sub(e,t),u=Ue.add(e,t),d=Ue.mul(i,u),g=Ue.eql(d,Ue.ZERO);o=Ue.cmov(o,Ue.ZERO,g),i=Ue.cmov(i,Ue.ONE,g),a=Ue.cmov(a,Ue.ONE,g),u=Ue.cmov(u,Ue.ONE,g);const w=Ue.invertBatch([i,u]);return{x:Ue.mul(o,w[0]),y:Ue.mul(a,w[1])}}const Sl=null,El=null,_l=null;function Xr(r){if(!(r instanceof _n))throw new Error("RistrettoPoint expected")}const Qr=null,Qi=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),ea=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),ta=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),na=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),to=r=>Zr(En,r),ra=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),es=r=>Mt.CURVE.Fp.create(bytesToNumberLE(r)&ra);function no(r){const{d:e}=Mt.CURVE,t=Mt.CURVE.Fp.ORDER,n=Mt.CURVE.Fp.create,s=n(Qr*r*r),o=n((s+En)*ta);let i=BigInt(-1);const a=n((i-e*s)*n(s+e));let{isValid:u,value:d}=Zr(o,a),g=n(d*r);isNegativeLE(g,t)||(g=n(-g)),u||(d=g),u||(i=s);const w=n(i*(s-En)*na-a),j=d*d,C=n((d+d)*a),D=n(w*Qi),k=n(En-j),O=n(En+j);return new Mt.ExtendedPoint(n(C*O),n(k*D),n(D*O),n(C*k))}class _n{constructor(e){this.ep=e}static fromAffine(e){return new _n(Mt.ExtendedPoint.fromAffine(e))}static hashToCurve(e){e=ensureBytes("ristrettoHash",e,64);const t=es(e.slice(0,32)),n=no(t),s=es(e.slice(32,64)),o=no(s);return new _n(n.add(o))}static fromHex(e){e=ensureBytes("ristrettoHex",e,32);const{a:t,d:n}=Mt.CURVE,s=Mt.CURVE.Fp.ORDER,o=Mt.CURVE.Fp.create,i="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",a=es(e);if(!equalBytes(numberToBytesLE(a,32),e)||isNegativeLE(a,s))throw new Error(i);const u=o(a*a),d=o(En+t*u),g=o(En-t*u),w=o(d*d),j=o(g*g),C=o(t*n*w-j),{isValid:D,value:k}=to(o(C*j)),O=o(k*g),q=o(k*O*C);let fe=o((a+a)*O);isNegativeLE(fe,s)&&(fe=o(-fe));const he=o(d*q),Oe=o(fe*he);if(!D||isNegativeLE(Oe,s)||he===Hi)throw new Error(i);return new _n(new Mt.ExtendedPoint(fe,he,En,Oe))}toRawBytes(){let{ex:e,ey:t,ez:n,et:s}=this.ep;const o=Mt.CURVE.Fp.ORDER,i=Mt.CURVE.Fp.create,a=i(i(n+t)*i(n-t)),u=i(e*t),d=i(u*u),{value:g}=to(i(a*d)),w=i(g*a),j=i(g*u),C=i(w*j*s);let D;if(isNegativeLE(s*C,o)){let O=i(t*Qr),q=i(e*Qr);e=O,t=q,D=i(w*ea)}else D=j;isNegativeLE(e*C,o)&&(t=i(-t));let k=i((n-t)*D);return isNegativeLE(k,o)&&(k=i(-k)),numberToBytesLE(k,32)}toHex(){return bytesToHex(this.toRawBytes())}toString(){return this.toHex()}equals(e){Xr(e);const{ex:t,ey:n}=this.ep,{ex:s,ey:o}=e.ep,i=Mt.CURVE.Fp.create,a=i(t*o)===i(n*s),u=i(n*o)===i(t*s);return a||u}add(e){return Xr(e),new _n(this.ep.add(e.ep))}subtract(e){return Xr(e),new _n(this.ep.subtract(e.ep))}multiply(e){return new _n(this.ep.multiply(e))}multiplyUnsafe(e){return new _n(this.ep.multiplyUnsafe(e))}}const xl=null,vl=(r,e)=>{const t=e.DST,n=typeof t=="string"?utf8ToBytes(t):t,s=expand_message_xmd(r,n,64,sha512);return _n.hashToCurve(s)},Al=null;var sa=A(13550),ro=A.n(sa),oa=A(77191),Yt=A.n(oa);const ia=(r,e,t)=>r&e^~r&t,aa=(r,e,t)=>r&e^r&t^e&t,ca=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ln=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Cn=new Uint32Array(64);class ua extends Se{constructor(){super(64,32,8,!1),this.A=Ln[0]|0,this.B=Ln[1]|0,this.C=Ln[2]|0,this.D=Ln[3]|0,this.E=Ln[4]|0,this.F=Ln[5]|0,this.G=Ln[6]|0,this.H=Ln[7]|0}get(){const{A:e,B:t,C:n,D:s,E:o,F:i,G:a,H:u}=this;return[e,t,n,s,o,i,a,u]}set(e,t,n,s,o,i,a,u){this.A=e|0,this.B=t|0,this.C=n|0,this.D=s|0,this.E=o|0,this.F=i|0,this.G=a|0,this.H=u|0}process(e,t){for(let w=0;w<16;w++,t+=4)Cn[w]=e.getUint32(t,!1);for(let w=16;w<64;w++){const j=Cn[w-15],C=Cn[w-2],D=V(j,7)^V(j,18)^j>>>3,k=V(C,17)^V(C,19)^C>>>10;Cn[w]=k+Cn[w-7]+D+Cn[w-16]|0}let{A:n,B:s,C:o,D:i,E:a,F:u,G:d,H:g}=this;for(let w=0;w<64;w++){const j=V(a,6)^V(a,11)^V(a,25),C=g+j+ia(a,u,d)+ca[w]+Cn[w]|0,k=(V(n,2)^V(n,13)^V(n,22))+aa(n,s,o)|0;g=d,d=u,u=a,a=i+C|0,i=o,o=s,s=n,n=C+k|0}n=n+this.A|0,s=s+this.B|0,o=o+this.C|0,i=i+this.D|0,a=a+this.E|0,u=u+this.F|0,d=d+this.G|0,g=g+this.H|0,this.set(n,s,o,i,a,u,d,g)}roundClean(){Cn.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class Il extends null{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}const ts=we(()=>new ua),Bl=null;var ns=A(25532),b=A(39386),rs=A(40475);class la extends TypeError{constructor(e,t){let n;const{message:s,...o}=e,{path:i}=e,a=i.length===0?s:"At path: "+i.join(".")+" -- "+s;super(a),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>{var u;return(u=n)!=null?u:n=[e,...t()]}}}function fa(r){return hn(r)&&typeof r[Symbol.iterator]=="function"}function hn(r){return typeof r=="object"&&r!=null}function so(r){if(Object.prototype.toString.call(r)!=="[object Object]")return!1;const e=Object.getPrototypeOf(r);return e===null||e===Object.prototype}function jt(r){return typeof r=="string"?JSON.stringify(r):""+r}function da(r){const{done:e,value:t}=r.next();return e?void 0:t}function ha(r,e,t,n){if(r===!0)return;r===!1?r={}:typeof r=="string"&&(r={message:r});const{path:s,branch:o}=e,{type:i}=t,{refinement:a,message:u="Expected a value of type `"+i+"`"+(a?" with refinement `"+a+"`":"")+", but received: `"+jt(n)+"`"}=r;return{value:n,type:i,refinement:a,key:s[s.length-1],path:s,branch:o,...r,message:u}}function*ss(r,e,t,n){fa(r)||(r=[r]);for(const s of r){const o=ha(s,e,t,n);o&&(yield o)}}function*os(r,e,t={}){const{path:n=[],branch:s=[r],coerce:o=!1,mask:i=!1}=t,a={path:n,branch:s};if(o&&(r=e.coercer(r,a),i&&e.type!=="type"&&hn(e.schema)&&hn(r)&&!Array.isArray(r)))for(const d in r)e.schema[d]===void 0&&delete r[d];let u=!0;for(const d of e.validator(r,a))u=!1,yield[d,void 0];for(let[d,g,w]of e.entries(r,a)){const j=os(g,w,{path:d===void 0?n:[...n,d],branch:d===void 0?s:[...s,g],coerce:o,mask:i});for(const C of j)C[0]?(u=!1,yield[C[0],void 0]):o&&(g=C[1],d===void 0?r=g:r instanceof Map?r.set(d,g):r instanceof Set?r.add(g):hn(r)&&(r[d]=g))}if(u)for(const d of e.refiner(r,a))u=!1,yield[d,void 0];u&&(yield[void 0,r])}class Wt{constructor(e){const{type:t,schema:n,validator:s,refiner:o,coercer:i=u=>u,entries:a=function*(){}}=e;this.type=t,this.schema=n,this.entries=a,this.coercer=i,s?this.validator=(u,d)=>{const g=s(u,d);return ss(g,d,this,u)}:this.validator=()=>[],o?this.refiner=(u,d)=>{const g=o(u,d);return ss(g,d,this,u)}:this.refiner=()=>[]}assert(e){return oo(e,this)}create(e){return Ie(e,this)}is(e){return io(e,this)}mask(e){return pa(e,this)}validate(e,t={}){return sr(e,this,t)}}function oo(r,e){const t=sr(r,e);if(t[0])throw t[0]}function Ie(r,e){const t=sr(r,e,{coerce:!0});if(t[0])throw t[0];return t[1]}function pa(r,e){const t=sr(r,e,{coerce:!0,mask:!0});if(t[0])throw t[0];return t[1]}function io(r,e){return!sr(r,e)[0]}function sr(r,e,t={}){const n=os(r,e,t),s=da(n);return s[0]?[new la(s[0],function*(){for(const i of n)i[0]&&(yield i[0])}),void 0]:[void 0,s[1]]}function Rl(...r){const e=r.map(n=>n.schema),t=Object.assign({},...e);return _r(t)}function un(r,e){return new Wt({type:r,schema:null,validator:e})}function Pl(r,e){return new Wt({...r,refiner:(t,n)=>t===void 0||r.refiner(t,n),validator(t,n){return t===void 0?!0:(e(t,n),r.validator(t,n))}})}function Tl(r){return new Wt({type:"dynamic",schema:null,*entries(e,t){yield*r(e,t).entries(e,t)},validator(e,t){return r(e,t).validator(e,t)},coercer(e,t){return r(e,t).coercer(e,t)}})}function Ol(r){let e;return new Wt({type:"lazy",schema:null,*entries(t,n){var s;(s=e)!=null||(e=r()),yield*e.entries(t,n)},validator(t,n){var s;return(s=e)!=null||(e=r()),e.validator(t,n)},coercer(t,n){var s;return(s=e)!=null||(e=r()),e.coercer(t,n)}})}function Ll(r,e){const{schema:t}=r,n={...t};for(const s of e)delete n[s];return _r(n)}function Cl(r){const e=r instanceof Wt?{...r.schema}:{...r};for(const t in e)e[t]=Qe(e[t]);return _r(e)}function Nl(r,e){const{schema:t}=r,n={};for(const s of e)n[s]=t[s];return _r(n)}function Ul(r,e){return console.warn("superstruct@0.11 - The `struct` helper has been renamed to `define`."),un(r,e)}function ga(){return un("any",()=>!0)}function Ce(r){return new Wt({type:"array",schema:r,*entries(e){if(r&&Array.isArray(e))for(const[t,n]of e.entries())yield[t,n,r]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||"Expected an array value, but received: "+jt(e)}})}function xn(){return un("boolean",r=>typeof r=="boolean")}function zl(){return un("date",r=>r instanceof Date&&!isNaN(r.getTime())||"Expected a valid `Date` object, but received: "+jt(r))}function Kl(r){const e={},t=r.map(n=>jt(n)).join();for(const n of r)e[n]=n;return new Wt({type:"enums",schema:e,validator(n){return r.includes(n)||"Expected one of `"+t+"`, but received: "+jt(n)}})}function Dl(){return un("func",r=>typeof r=="function"||"Expected a function, but received: "+jt(r))}function is(r){return un("instance",e=>e instanceof r||"Expected a `"+r.name+"` instance, but received: "+jt(e))}function Ml(){return un("integer",r=>typeof r=="number"&&!isNaN(r)&&Number.isInteger(r)||"Expected an integer, but received: "+jt(r))}function Wl(r){return new Wt({type:"intersection",schema:null,*entries(e,t){for(const n of r)yield*n.entries(e,t)},*validator(e,t){for(const n of r)yield*n.validator(e,t)},*refiner(e,t){for(const n of r)yield*n.refiner(e,t)}})}function Lt(r){const e=jt(r),t=typeof r;return new Wt({type:"literal",schema:t==="string"||t==="number"||t==="boolean"?r:null,validator(n){return n===r||"Expected the literal `"+e+"`, but received: "+jt(n)}})}function Hl(r,e){return new Wt({type:"map",schema:null,*entries(t){if(r&&e&&t instanceof Map)for(const[n,s]of t.entries())yield[n,n,r],yield[n,s,e]},coercer(t){return t instanceof Map?new Map(t):t},validator(t){return t instanceof Map||"Expected a `Map` object, but received: "+jt(t)}})}function ao(){return un("never",()=>!1)}function Le(r){return new Wt({...r,validator:(e,t)=>e===null||r.validator(e,t),refiner:(e,t)=>e===null||r.refiner(e,t)})}function N(){return un("number",r=>typeof r=="number"&&!isNaN(r)||"Expected a number, but received: "+jt(r))}function _r(r){const e=r?Object.keys(r):[],t=ao();return new Wt({type:"object",schema:r||null,*entries(n){if(r&&hn(n)){const s=new Set(Object.keys(n));for(const o of e)s.delete(o),yield[o,n[o],r[o]];for(const o of s)yield[o,n[o],t]}},validator(n){return hn(n)||"Expected an object, but received: "+jt(n)},coercer(n){return hn(n)?{...n}:n}})}function Qe(r){return new Wt({...r,validator:(e,t)=>e===void 0||r.validator(e,t),refiner:(e,t)=>e===void 0||r.refiner(e,t)})}function co(r,e){return new Wt({type:"record",schema:null,*entries(t){if(hn(t))for(const n in t){const s=t[n];yield[n,n,r],yield[n,s,e]}},validator(t){return hn(t)||"Expected an object, but received: "+jt(t)}})}function ql(){return un("regexp",r=>r instanceof RegExp)}function Fl(r){return new Wt({type:"set",schema:null,*entries(e){if(r&&e instanceof Set)for(const t of e)yield[t,t,r]},coercer(e){return e instanceof Set?new Set(e):e},validator(e){return e instanceof Set||"Expected a `Set` object, but received: "+jt(e)}})}function _e(){return un("string",r=>typeof r=="string"||"Expected a string, but received: "+jt(r))}function as(r){const e=ao();return new Wt({type:"tuple",schema:null,*entries(t){if(Array.isArray(t)){const n=Math.max(r.length,t.length);for(let s=0;s<n;s++)yield[s,t[s],r[s]||e]}},validator(t){return Array.isArray(t)||"Expected an array, but received: "+jt(t)}})}function de(r){const e=Object.keys(r);return new Wt({type:"type",schema:r,*entries(t){if(hn(t))for(const n of e)yield[n,t[n],r[n]]},validator(t){return hn(t)||"Expected an object, but received: "+jt(t)}})}function nn(r){const e=r.map(t=>t.type).join(" | ");return new Wt({type:"union",schema:null,validator(t,n){const s=[];for(const o of r){const[...i]=os(t,o,n),[a]=i;if(a[0])for(const[u]of i)u&&s.push(u);else return[]}return["Expected the value to satisfy a union of `"+e+"`, but received: "+jt(t),...s]}})}function $n(){return un("unknown",()=>!0)}function Kn(r,e,t){return new Wt({...r,coercer:(n,s)=>io(n,e)?r.coercer(t(n,s),s):r.coercer(n,s)})}function Vl(r,e,t={}){return Kn(r,$n(),n=>{const s=typeof e=="function"?e():e;if(n===void 0)return s;if(!t.strict&&so(n)&&so(s)){const o={...n};let i=!1;for(const a in s)o[a]===void 0&&(o[a]=s[a],i=!0);if(i)return o}return n})}function Gl(r){return Kn(r,_e(),e=>e.trim())}function jl(r){const e="Expected an empty "+r.type;return or(r,"empty",t=>{if(t instanceof Map||t instanceof Set){const{size:n}=t;return n===0||e+" but received one with a size of `"+n+"`"}else{const{length:n}=t;return n===0||e+" but received one with a length of `"+n+"`"}})}function $l(r,e,t={}){const{exclusive:n}=t;return or(r,"max",s=>n?s<e:s<=e||"Expected a "+r.type+" greater than "+(n?"":"or equal to ")+e+" but received `"+s+"`")}function Yl(r,e,t={}){const{exclusive:n}=t;return or(r,"min",s=>n?s>e:s>=e||"Expected a "+r.type+" greater than "+(n?"":"or equal to ")+e+" but received `"+s+"`")}function Jl(r,e){return or(r,"pattern",t=>e.test(t)||"Expected a "+r.type+" matching `/"+e.source+'/` but received "'+t+'"')}function Zl(r,e,t=e){const n="Expected a "+r.type,s=e===t?"of `"+e+"`":"between `"+e+"` and `"+t+"`";return or(r,"size",o=>{if(typeof o=="number"||o instanceof Date)return e<=o&&o<=t||n+" "+s+" but received `"+o+"`";if(o instanceof Map||o instanceof Set){const{size:i}=o;return e<=i&&i<=t||n+" with a size "+s+" but received one with a size of `"+i+"`"}else{const{length:i}=o;return e<=i&&i<=t||n+" with a length "+s+" but received one with a length of `"+i+"`"}})}function or(r,e,t){return new Wt({...r,*refiner(n,s){yield*r.refiner(n,s);const o=t(n,s),i=ss(o,s,r,n);for(const a of i)yield{...a,refinement:e}}})}var ya=A(31198),ba=A.n(ya),ma=A(66855),wa=A(89062);const[uo,lo,fo]=[[],[],[]],ka=BigInt(0),ir=BigInt(1),Sa=BigInt(2),Ea=BigInt(7),_a=BigInt(256),xa=BigInt(113);for(let r=0,e=ir,t=1,n=0;r<24;r++){[t,n]=[n,(2*t+3*n)%5],uo.push(2*(5*n+t)),lo.push((r+1)*(r+2)/2%64);let s=ka;for(let o=0;o<7;o++)e=(e<<ir^(e>>Ea)*xa)%_a,e&Sa&&(s^=ir<<(ir<<BigInt(o))-ir);fo.push(s)}const[va,Aa]=c(fo,!0),ho=(r,e,t)=>t>32?mn(r,e,t):bn(r,e,t),po=(r,e,t)=>t>32?Pn(r,e,t):tn(r,e,t);function Ia(r,e=24){const t=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let i=0;i<10;i++)t[i]=r[i]^r[i+10]^r[i+20]^r[i+30]^r[i+40];for(let i=0;i<10;i+=2){const a=(i+8)%10,u=(i+2)%10,d=t[u],g=t[u+1],w=ho(d,g,1)^t[a],j=po(d,g,1)^t[a+1];for(let C=0;C<50;C+=10)r[i+C]^=w,r[i+C+1]^=j}let s=r[2],o=r[3];for(let i=0;i<24;i++){const a=lo[i],u=ho(s,o,a),d=po(s,o,a),g=uo[i];s=r[g],o=r[g+1],r[g]=u,r[g+1]=d}for(let i=0;i<50;i+=10){for(let a=0;a<10;a++)t[a]=r[i+a];for(let a=0;a<10;a++)r[i+a]^=~t[(a+2)%10]&t[(a+4)%10]}r[0]^=va[n],r[1]^=Aa[n]}t.fill(0)}class xr extends ie{constructor(e,t,n,s=!1,o=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=s,this.rounds=o,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,X(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=M(this.state)}keccak(){Ia(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){R(this);const{blockLen:t,state:n}=this;e=$(e);const s=e.length;for(let o=0;o<s;){const i=Math.min(t-this.pos,s-o);for(let a=0;a<i;a++)n[this.pos++]^=e[o++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:n,blockLen:s}=this;e[n]^=t,(t&128)!==0&&n===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){R(this,!1),Q(e),this.finish();const t=this.state,{blockLen:n}=this;for(let s=0,o=e.length;s<o;){this.posOut>=n&&this.keccak();const i=Math.min(n-this.posOut,o-s);e.set(t.subarray(this.posOut,this.posOut+i),s),this.posOut+=i,s+=i}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return X(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(G(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:n,outputLen:s,rounds:o,enableXOF:i}=this;return e||(e=new xr(t,n,s,i,o)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=o,e.suffix=n,e.outputLen=s,e.enableXOF=i,e.destroyed=this.destroyed,e}}const Ba=(r,e,t)=>we(()=>new xr(e,r,t)),Xl=null,Ql=null,ef=null,tf=null,nf=null,go=Ba(1,136,256/8),rf=null,sf=null,of=(r,e,t)=>wrapXOFConstructorWithOpts((n={})=>new xr(e,r,n.dkLen===void 0?t:n.dkLen,!0)),af=null,cf=null;class yo extends ie{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,F(e);const n=$(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,o=new Uint8Array(s);o.set(n.length>s?e.create().update(n).digest():n);for(let i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=e.create();for(let i=0;i<o.length;i++)o[i]^=106;this.oHash.update(o),o.fill(0)}update(e){return R(this),this.iHash.update(e),this}digestInto(e){R(this),Q(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:s,destroyed:o,blockLen:i,outputLen:a}=this;return e=e,e.finished=s,e.destroyed=o,e.blockLen=i,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const bo=(r,e,t)=>new yo(r,e).update(t).digest();bo.create=(r,e)=>new yo(r,e);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Ra(r){const e=$r(r);jn(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:t,Fp:n,a:s}=e;if(t){if(!n.eql(s,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:Pa,hexToBytes:Ta}=h,Dn={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(r){const{Err:e}=Dn;if(r.length<2||r[0]!==2)throw new e("Invalid signature integer tag");const t=r[1],n=r.subarray(2,t+2);if(!t||n.length!==t)throw new e("Invalid signature integer: wrong length");if(n[0]&128)throw new e("Invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:Pa(n),l:r.subarray(t+2)}},toSig(r){const{Err:e}=Dn,t=typeof r=="string"?Ta(r):r;if(!(t instanceof Uint8Array))throw new Error("ui8a expected");let n=t.length;if(n<2||t[0]!=48)throw new e("Invalid signature tag");if(t[1]!==n-2)throw new e("Invalid signature: incorrect length");const{d:s,l:o}=Dn._parseInt(t.subarray(2)),{d:i,l:a}=Dn._parseInt(o);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:s,s:i}},hexFromSig(r){const e=d=>Number.parseInt(d[0],16)&8?"00"+d:d,t=d=>{const g=d.toString(16);return g.length&1?`0${g}`:g},n=e(t(r.s)),s=e(t(r.r)),o=n.length/2,i=s.length/2,a=t(o),u=t(i);return`30${t(i+o+4)}02${u}${s}02${a}${n}`}},pn=BigInt(0),Nt=BigInt(1),Nn=BigInt(2),vr=BigInt(3),mo=BigInt(4);function Oa(r){const e=Ra(r),{Fp:t}=e,n=e.toBytes||((D,k,O)=>{const q=k.toAffine();return Ot(Uint8Array.from([4]),t.toBytes(q.x),t.toBytes(q.y))}),s=e.fromBytes||(D=>{const k=D.subarray(1),O=t.fromBytes(k.subarray(0,t.BYTES)),q=t.fromBytes(k.subarray(t.BYTES,2*t.BYTES));return{x:O,y:q}});function o(D){const{a:k,b:O}=e,q=t.sqr(D),fe=t.mul(q,D);return t.add(t.add(fe,t.mul(D,k)),O)}if(!t.eql(t.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function i(D){return typeof D=="bigint"&&pn<D&&D<e.n}function a(D){if(!i(D))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function u(D){const{allowedPrivateKeyLengths:k,nByteLength:O,wrapPrivateKey:q,n:fe}=e;if(k&&typeof D!="bigint"){if(D instanceof Uint8Array&&(D=_t(D)),typeof D!="string"||!k.includes(D.length))throw new Error("Invalid key");D=D.padStart(O*2,"0")}let he;try{he=typeof D=="bigint"?D:cn(gt("private key",D,O))}catch{throw new Error(`private key must be ${O} bytes, hex or bigint, not ${typeof D}`)}return q&&(he=It(he,fe)),a(he),he}const d=new Map;function g(D){if(!(D instanceof w))throw new Error("ProjectivePoint expected")}class w{constructor(k,O,q){if(this.px=k,this.py=O,this.pz=q,k==null||!t.isValid(k))throw new Error("x required");if(O==null||!t.isValid(O))throw new Error("y required");if(q==null||!t.isValid(q))throw new Error("z required")}static fromAffine(k){const{x:O,y:q}=k||{};if(!k||!t.isValid(O)||!t.isValid(q))throw new Error("invalid affine point");if(k instanceof w)throw new Error("projective point not allowed");const fe=he=>t.eql(he,t.ZERO);return fe(O)&&fe(q)?w.ZERO:new w(O,q,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(k){const O=t.invertBatch(k.map(q=>q.pz));return k.map((q,fe)=>q.toAffine(O[fe])).map(w.fromAffine)}static fromHex(k){const O=w.fromAffine(s(gt("pointHex",k)));return O.assertValidity(),O}static fromPrivateKey(k){return w.BASE.multiply(u(k))}_setWindowSize(k){this._WINDOW_SIZE=k,d.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!t.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:k,y:O}=this.toAffine();if(!t.isValid(k)||!t.isValid(O))throw new Error("bad point: x or y not FE");const q=t.sqr(O),fe=o(k);if(!t.eql(q,fe))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:k}=this.toAffine();if(t.isOdd)return!t.isOdd(k);throw new Error("Field doesn't support isOdd")}equals(k){g(k);const{px:O,py:q,pz:fe}=this,{px:he,py:Oe,pz:Te}=k,De=t.eql(t.mul(O,Te),t.mul(he,fe)),je=t.eql(t.mul(q,Te),t.mul(Oe,fe));return De&&je}negate(){return new w(this.px,t.neg(this.py),this.pz)}double(){const{a:k,b:O}=e,q=t.mul(O,vr),{px:fe,py:he,pz:Oe}=this;let Te=t.ZERO,De=t.ZERO,je=t.ZERO,Ve=t.mul(fe,fe),Et=t.mul(he,he),bt=t.mul(Oe,Oe),st=t.mul(fe,he);return st=t.add(st,st),je=t.mul(fe,Oe),je=t.add(je,je),Te=t.mul(k,je),De=t.mul(q,bt),De=t.add(Te,De),Te=t.sub(Et,De),De=t.add(Et,De),De=t.mul(Te,De),Te=t.mul(st,Te),je=t.mul(q,je),bt=t.mul(k,bt),st=t.sub(Ve,bt),st=t.mul(k,st),st=t.add(st,je),je=t.add(Ve,Ve),Ve=t.add(je,Ve),Ve=t.add(Ve,bt),Ve=t.mul(Ve,st),De=t.add(De,Ve),bt=t.mul(he,Oe),bt=t.add(bt,bt),Ve=t.mul(bt,st),Te=t.sub(Te,Ve),je=t.mul(bt,Et),je=t.add(je,je),je=t.add(je,je),new w(Te,De,je)}add(k){g(k);const{px:O,py:q,pz:fe}=this,{px:he,py:Oe,pz:Te}=k;let De=t.ZERO,je=t.ZERO,Ve=t.ZERO;const Et=e.a,bt=t.mul(e.b,vr);let st=t.mul(O,he),qt=t.mul(q,Oe),Kt=t.mul(fe,Te),ln=t.add(O,q),Re=t.add(he,Oe);ln=t.mul(ln,Re),Re=t.add(st,qt),ln=t.sub(ln,Re),Re=t.add(O,fe);let Me=t.add(he,Te);return Re=t.mul(Re,Me),Me=t.add(st,Kt),Re=t.sub(Re,Me),Me=t.add(q,fe),De=t.add(Oe,Te),Me=t.mul(Me,De),De=t.add(qt,Kt),Me=t.sub(Me,De),Ve=t.mul(Et,Re),De=t.mul(bt,Kt),Ve=t.add(De,Ve),De=t.sub(qt,Ve),Ve=t.add(qt,Ve),je=t.mul(De,Ve),qt=t.add(st,st),qt=t.add(qt,st),Kt=t.mul(Et,Kt),Re=t.mul(bt,Re),qt=t.add(qt,Kt),Kt=t.sub(st,Kt),Kt=t.mul(Et,Kt),Re=t.add(Re,Kt),st=t.mul(qt,Re),je=t.add(je,st),st=t.mul(Me,Re),De=t.mul(ln,De),De=t.sub(De,st),st=t.mul(ln,qt),Ve=t.mul(Me,Ve),Ve=t.add(Ve,st),new w(De,je,Ve)}subtract(k){return this.add(k.negate())}is0(){return this.equals(w.ZERO)}wNAF(k){return C.wNAFCached(this,d,k,O=>{const q=t.invertBatch(O.map(fe=>fe.pz));return O.map((fe,he)=>fe.toAffine(q[he])).map(w.fromAffine)})}multiplyUnsafe(k){const O=w.ZERO;if(k===pn)return O;if(a(k),k===Nt)return this;const{endo:q}=e;if(!q)return C.unsafeLadder(this,k);let{k1neg:fe,k1:he,k2neg:Oe,k2:Te}=q.splitScalar(k),De=O,je=O,Ve=this;for(;he>pn||Te>pn;)he&Nt&&(De=De.add(Ve)),Te&Nt&&(je=je.add(Ve)),Ve=Ve.double(),he>>=Nt,Te>>=Nt;return fe&&(De=De.negate()),Oe&&(je=je.negate()),je=new w(t.mul(je.px,q.beta),je.py,je.pz),De.add(je)}multiply(k){a(k);let O=k,q,fe;const{endo:he}=e;if(he){const{k1neg:Oe,k1:Te,k2neg:De,k2:je}=he.splitScalar(O);let{p:Ve,f:Et}=this.wNAF(Te),{p:bt,f:st}=this.wNAF(je);Ve=C.constTimeNegate(Oe,Ve),bt=C.constTimeNegate(De,bt),bt=new w(t.mul(bt.px,he.beta),bt.py,bt.pz),q=Ve.add(bt),fe=Et.add(st)}else{const{p:Oe,f:Te}=this.wNAF(O);q=Oe,fe=Te}return w.normalizeZ([q,fe])[0]}multiplyAndAddUnsafe(k,O,q){const fe=w.BASE,he=(Te,De)=>De===pn||De===Nt||!Te.equals(fe)?Te.multiplyUnsafe(De):Te.multiply(De),Oe=he(this,O).add(he(k,q));return Oe.is0()?void 0:Oe}toAffine(k){const{px:O,py:q,pz:fe}=this,he=this.is0();k==null&&(k=he?t.ONE:t.inv(fe));const Oe=t.mul(O,k),Te=t.mul(q,k),De=t.mul(fe,k);if(he)return{x:t.ZERO,y:t.ZERO};if(!t.eql(De,t.ONE))throw new Error("invZ was invalid");return{x:Oe,y:Te}}isTorsionFree(){const{h:k,isTorsionFree:O}=e;if(k===Nt)return!0;if(O)return O(w,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:k,clearCofactor:O}=e;return k===Nt?this:O?O(w,this):this.multiplyUnsafe(e.h)}toRawBytes(k=!0){return this.assertValidity(),n(w,this,k)}toHex(k=!0){return _t(this.toRawBytes(k))}}w.BASE=new w(e.Gx,e.Gy,t.ONE),w.ZERO=new w(t.ZERO,t.ONE,t.ZERO);const j=e.nBitLength,C=$s(w,e.endo?Math.ceil(j/2):j);return{CURVE:e,ProjectivePoint:w,normPrivateKeyToScalar:u,weierstrassEquation:o,isWithinCurveOrder:i}}function La(r){const e=$r(r);return jn(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function Ca(r){const e=La(r),{Fp:t,n}=e,s=t.BYTES+1,o=2*t.BYTES+1;function i(Re){return pn<Re&&Re<t.ORDER}function a(Re){return It(Re,n)}function u(Re){return kr(Re,n)}const{ProjectivePoint:d,normPrivateKeyToScalar:g,weierstrassEquation:w,isWithinCurveOrder:j}=Oa({...e,toBytes(Re,Me,ot){const Pe=Me.toAffine(),ue=t.toBytes(Pe.x),Ke=Ot;return ot?Ke(Uint8Array.from([Me.hasEvenY()?2:3]),ue):Ke(Uint8Array.from([4]),ue,t.toBytes(Pe.y))},fromBytes(Re){const Me=Re.length,ot=Re[0],Pe=Re.subarray(1);if(Me===s&&(ot===2||ot===3)){const ue=cn(Pe);if(!i(ue))throw new Error("Point is not on curve");const Ke=w(ue);let Ye=t.sqrt(Ke);const et=(Ye&Nt)===Nt;return(ot&1)===1!==et&&(Ye=t.neg(Ye)),{x:ue,y:Ye}}else if(Me===o&&ot===4){const ue=t.fromBytes(Pe.subarray(0,t.BYTES)),Ke=t.fromBytes(Pe.subarray(t.BYTES,2*t.BYTES));return{x:ue,y:Ke}}else throw new Error(`Point of length ${Me} was invalid. Expected ${s} compressed bytes or ${o} uncompressed bytes`)}}),C=Re=>_t(Sn(Re,e.nByteLength));function D(Re){const Me=n>>Nt;return Re>Me}function k(Re){return D(Re)?a(-Re):Re}const O=(Re,Me,ot)=>cn(Re.slice(Me,ot));class q{constructor(Me,ot,Pe){this.r=Me,this.s=ot,this.recovery=Pe,this.assertValidity()}static fromCompact(Me){const ot=e.nByteLength;return Me=gt("compactSignature",Me,ot*2),new q(O(Me,0,ot),O(Me,ot,2*ot))}static fromDER(Me){const{r:ot,s:Pe}=Dn.toSig(gt("DER",Me));return new q(ot,Pe)}assertValidity(){if(!j(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!j(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(Me){return new q(this.r,this.s,Me)}recoverPublicKey(Me){const{r:ot,s:Pe,recovery:ue}=this,Ke=je(gt("msgHash",Me));if(ue==null||![0,1,2,3].includes(ue))throw new Error("recovery id invalid");const Ye=ue===2||ue===3?ot+e.n:ot;if(Ye>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");const et=(ue&1)===0?"02":"03",it=d.fromHex(et+C(Ye)),lt=u(Ye),St=a(-Ke*lt),ft=a(Pe*lt),mt=d.BASE.multiplyAndAddUnsafe(it,St,ft);if(!mt)throw new Error("point at infinify");return mt.assertValidity(),mt}hasHighS(){return D(this.s)}normalizeS(){return this.hasHighS()?new q(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return Tt(this.toDERHex())}toDERHex(){return Dn.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Tt(this.toCompactHex())}toCompactHex(){return C(this.r)+C(this.s)}}const fe={isValidPrivateKey(Re){try{return g(Re),!0}catch{return!1}},normPrivateKeyToScalar:g,randomPrivateKey:()=>{const Re=js(e.n);return zi(e.randomBytes(Re),e.n)},precompute(Re=8,Me=d.BASE){return Me._setWindowSize(Re),Me.multiply(BigInt(3)),Me}};function he(Re,Me=!0){return d.fromPrivateKey(Re).toRawBytes(Me)}function Oe(Re){const Me=Re instanceof Uint8Array,ot=typeof Re=="string",Pe=(Me||ot)&&Re.length;return Me?Pe===s||Pe===o:ot?Pe===2*s||Pe===2*o:Re instanceof d}function Te(Re,Me,ot=!0){if(Oe(Re))throw new Error("first arg must be private key");if(!Oe(Me))throw new Error("second arg must be public key");return d.fromHex(Me).multiply(g(Re)).toRawBytes(ot)}const De=e.bits2int||function(Re){const Me=cn(Re),ot=Re.length*8-e.nBitLength;return ot>0?Me>>BigInt(ot):Me},je=e.bits2int_modN||function(Re){return a(De(Re))},Ve=qr(e.nBitLength);function Et(Re){if(typeof Re!="bigint")throw new Error("bigint expected");if(!(pn<=Re&&Re<Ve))throw new Error(`bigint expected < 2^${e.nBitLength}`);return Sn(Re,e.nByteLength)}function bt(Re,Me,ot=st){if(["recovered","canonical"].some(zt=>zt in ot))throw new Error("sign() legacy options not supported");const{hash:Pe,randomBytes:ue}=e;let{lowS:Ke,prehash:Ye,extraEntropy:et}=ot;Ke==null&&(Ke=!0),Re=gt("msgHash",Re),Ye&&(Re=gt("prehashed msgHash",Pe(Re)));const it=je(Re),lt=g(Me),St=[Et(lt),Et(it)];if(et!=null){const zt=et===!0?ue(t.BYTES):et;St.push(gt("extraEntropy",zt))}const ft=Ot(...St),mt=it;function Ft(zt){const Zt=De(zt);if(!j(Zt))return;const Xt=u(Zt),en=d.BASE.multiply(Zt).toAffine(),Dt=a(en.x);if(Dt===pn)return;const yn=a(Xt*a(mt+Dt*lt));if(yn===pn)return;let Gn=(en.x===Dt?0:2)|Number(en.y&Nt),gr=yn;return Ke&&D(yn)&&(gr=k(yn),Gn^=1),new q(Dt,gr,Gn)}return{seed:ft,k2sig:Ft}}const st={lowS:e.lowS,prehash:!1},qt={lowS:e.lowS,prehash:!1};function Kt(Re,Me,ot=st){const{seed:Pe,k2sig:ue}=bt(Re,Me,ot),Ke=e;return Hs(Ke.hash.outputLen,Ke.nByteLength,Ke.hmac)(Pe,ue)}d.BASE._setWindowSize(8);function ln(Re,Me,ot,Pe=qt){var en;const ue=Re;if(Me=gt("msgHash",Me),ot=gt("publicKey",ot),"strict"in Pe)throw new Error("options.strict was renamed to lowS");const{lowS:Ke,prehash:Ye}=Pe;let et,it;try{if(typeof ue=="string"||ue instanceof Uint8Array)try{et=q.fromDER(ue)}catch(Dt){if(!(Dt instanceof Dn.Err))throw Dt;et=q.fromCompact(ue)}else if(typeof ue=="object"&&typeof ue.r=="bigint"&&typeof ue.s=="bigint"){const{r:Dt,s:yn}=ue;et=new q(Dt,yn)}else throw new Error("PARSE");it=d.fromHex(ot)}catch(Dt){if(Dt.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(Ke&&et.hasHighS())return!1;Ye&&(Me=e.hash(Me));const{r:lt,s:St}=et,ft=je(Me),mt=u(St),Ft=a(ft*mt),zt=a(lt*mt),Zt=(en=d.BASE.multiplyAndAddUnsafe(it,Ft,zt))==null?void 0:en.toAffine();return Zt?a(Zt.x)===lt:!1}return{CURVE:e,getPublicKey:he,getSharedSecret:Te,sign:Kt,verify:ln,ProjectivePoint:d,Signature:q,utils:fe}}function Na(r,e){const t=r.ORDER;let n=pn;for(let D=t-Nt;D%Nn===pn;D/=Nn)n+=Nt;const s=n,o=Nn<<s-Nt-Nt,i=o*Nn,a=(t-Nt)/i,u=(a-Nt)/Nn,d=i-Nt,g=o,w=r.pow(e,a),j=r.pow(e,(a+Nt)/Nn);let C=(D,k)=>{let O=w,q=r.pow(k,d),fe=r.sqr(q);fe=r.mul(fe,k);let he=r.mul(D,fe);he=r.pow(he,u),he=r.mul(he,q),q=r.mul(he,k),fe=r.mul(he,D);let Oe=r.mul(fe,q);he=r.pow(Oe,g);let Te=r.eql(he,r.ONE);q=r.mul(fe,j),he=r.mul(Oe,O),fe=r.cmov(q,fe,Te),Oe=r.cmov(he,Oe,Te);for(let De=s;De>Nt;De--){let je=De-Nn;je=Nn<<je-Nt;let Ve=r.pow(Oe,je);const Et=r.eql(Ve,r.ONE);q=r.mul(fe,O),O=r.mul(O,O),Ve=r.mul(Oe,O),fe=r.cmov(q,fe,Et),Oe=r.cmov(Ve,Oe,Et)}return{isValid:Te,value:fe}};if(r.ORDER%mo===vr){const D=(r.ORDER-vr)/mo,k=r.sqrt(r.neg(e));C=(O,q)=>{let fe=r.sqr(q);const he=r.mul(O,q);fe=r.mul(fe,he);let Oe=r.pow(fe,D);Oe=r.mul(Oe,he);const Te=r.mul(Oe,k),De=r.mul(r.sqr(Oe),q),je=r.eql(De,O);let Ve=r.cmov(Te,Oe,je);return{isValid:je,value:Ve}}}return C}function uf(r,e){if(mod.validateField(r),!r.isValid(e.A)||!r.isValid(e.B)||!r.isValid(e.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");const t=Na(r,e.Z);if(!r.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let s,o,i,a,u,d,g,w;s=r.sqr(n),s=r.mul(s,e.Z),o=r.sqr(s),o=r.add(o,s),i=r.add(o,r.ONE),i=r.mul(i,e.B),a=r.cmov(e.Z,r.neg(o),!r.eql(o,r.ZERO)),a=r.mul(a,e.A),o=r.sqr(i),d=r.sqr(a),u=r.mul(d,e.A),o=r.add(o,u),o=r.mul(o,i),d=r.mul(d,a),u=r.mul(d,e.B),o=r.add(o,u),g=r.mul(s,i);const{isValid:j,value:C}=t(o,d);w=r.mul(s,n),w=r.mul(w,C),g=r.cmov(g,i,j),w=r.cmov(w,C,j);const D=r.isOdd(n)===r.isOdd(w);return w=r.cmov(r.neg(w),w,D),g=r.div(g,a),{x:g,y:w}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Ua(r){return{hash:r,hmac:(e,...t)=>bo(r,e,U(...t)),randomBytes:me}}function za(r,e){const t=n=>Ca({...r,...Ua(n)});return Object.freeze({...t(e),create:t})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ar=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ir=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),wo=BigInt(1),Br=BigInt(2),ko=(r,e)=>(r+e/Br)/e;function So(r){const e=Ar,t=BigInt(3),n=BigInt(6),s=BigInt(11),o=BigInt(22),i=BigInt(23),a=BigInt(44),u=BigInt(88),d=r*r*r%e,g=d*d*r%e,w=Ct(g,t,e)*g%e,j=Ct(w,t,e)*g%e,C=Ct(j,Br,e)*d%e,D=Ct(C,s,e)*C%e,k=Ct(D,o,e)*D%e,O=Ct(k,a,e)*k%e,q=Ct(O,u,e)*O%e,fe=Ct(q,a,e)*k%e,he=Ct(fe,t,e)*g%e,Oe=Ct(he,i,e)*D%e,Te=Ct(Oe,n,e)*d%e,De=Ct(Te,Br,e);if(!cs.eql(cs.sqr(De),r))throw new Error("Cannot find square root");return De}const cs=Vs(Ar,void 0,void 0,{sqrt:So}),ar=za({a:BigInt(0),b:BigInt(7),Fp:cs,n:Ir,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{const e=Ir,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-wo*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=t,i=BigInt("0x100000000000000000000000000000000"),a=ko(o*r,e),u=ko(-n*r,e);let d=It(r-a*t-u*s,e),g=It(-a*n-u*o,e);const w=d>i,j=g>i;if(w&&(d=e-d),j&&(g=e-g),d>i||g>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:w,k1:d,k2neg:j,k2:g}}}},ts),Rr=BigInt(0),Eo=r=>typeof r=="bigint"&&Rr<r&&r<Ar,Ka=r=>typeof r=="bigint"&&Rr<r&&r<Ir,_o={};function us(r,...e){let t=_o[r];if(t===void 0){const n=sha256(Uint8Array.from(r,s=>s.charCodeAt(0)));t=concatBytes(n,n),_o[r]=t}return sha256(concatBytes(t,...e))}const xo=r=>r.toRawBytes(!0).slice(1),ls=r=>numberToBytesBE(r,32),fs=r=>mod(r,Ar),cr=r=>mod(r,Ir),ds=ar.ProjectivePoint,Da=(r,e,t)=>ds.BASE.multiplyAndAddUnsafe(r,e,t);function hs(r){let e=ar.utils.normPrivateKeyToScalar(r),t=ds.fromPrivateKey(e);return{scalar:t.hasEvenY()?e:cr(-e),bytes:xo(t)}}function Ma(r){if(!Eo(r))throw new Error("bad x: need 0 < x < p");const e=fs(r*r),t=fs(e*r+BigInt(7));let n=So(t);n%Br!==Rr&&(n=fs(-n));const s=new ds(r,n,wo);return s.assertValidity(),s}function vo(...r){return cr(bytesToNumberBE(us("BIP0340/challenge",...r)))}function lf(r){return hs(r).bytes}function ff(r,e,t=randomBytes(32)){const n=ensureBytes("message",r),{bytes:s,scalar:o}=hs(e),i=ensureBytes("auxRand",t,32),a=ls(o^bytesToNumberBE(us("BIP0340/aux",i))),u=us("BIP0340/nonce",a,s,n),d=cr(bytesToNumberBE(u));if(d===Rr)throw new Error("sign failed: k is zero");const{bytes:g,scalar:w}=hs(d),j=vo(g,s,n),C=new Uint8Array(64);if(C.set(g,0),C.set(ls(cr(w+j*o)),32),!Wa(C,n,s))throw new Error("sign: Invalid signature produced");return C}function Wa(r,e,t){const n=ensureBytes("signature",r,64),s=ensureBytes("message",e),o=ensureBytes("publicKey",t,32);try{const i=Ma(bytesToNumberBE(o)),a=bytesToNumberBE(n.subarray(0,32));if(!Eo(a))return!1;const u=bytesToNumberBE(n.subarray(32,64));if(!Ka(u))return!1;const d=vo(ls(a),xo(i),s),g=Da(i,u,cr(-d));return!(!g||!g.hasEvenY()||g.toAffine().x!==a)}catch{return!1}}const df=null,hf=null,pf=null,gf=null,yf=null,bf=null,Ha=Mt.utils.randomPrivateKey,Ao=()=>{const r=Mt.utils.randomPrivateKey(),e=Pr(r),t=new Uint8Array(64);return t.set(r),t.set(e,32),{publicKey:e,secretKey:t}},Pr=Mt.getPublicKey;function Io(r){try{return Mt.ExtendedPoint.fromHex(r),!0}catch{return!1}}const ps=(r,e)=>Mt.sign(r,e.slice(0,32)),qa=Mt.verify,tt=r=>P.Buffer.isBuffer(r)?r:r instanceof Uint8Array?P.Buffer.from(r.buffer,r.byteOffset,r.byteLength):P.Buffer.from(r);class gs{constructor(e){Object.assign(this,e)}encode(){return P.Buffer.from((0,ns.serialize)(ur,this))}static decode(e){return(0,ns.deserialize)(ur,this,e)}static decodeUnchecked(e){return(0,ns.deserializeUnchecked)(ur,this,e)}}class Fa extends gs{constructor(e){if(super(e),this.enum="",Object.keys(e).length!==1)throw new Error("Enum can only take single value");Object.keys(e).map(t=>{this.enum=t})}}const ur=new Map;var Bo;let Ro;const Po=32,on=32;function Va(r){return r._bn!==void 0}let To=1;Ro=Symbol.toStringTag;class ve extends gs{constructor(e){if(super({}),this._bn=void 0,Va(e))this._bn=e._bn;else{if(typeof e=="string"){const t=Yt().decode(e);if(t.length!=on)throw new Error("Invalid public key input");this._bn=new(ro())(t)}else this._bn=new(ro())(e);if(this._bn.byteLength()>on)throw new Error("Invalid public key input")}}static unique(){const e=new ve(To);return To+=1,new ve(e.toBuffer())}equals(e){return this._bn.eq(e._bn)}toBase58(){return Yt().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(P.Buffer);if(e.length===on)return e;const t=P.Buffer.alloc(32);return e.copy(t,32-e.length),t}get[Ro](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(e,t,n){const s=P.Buffer.concat([e.toBuffer(),P.Buffer.from(t),n.toBuffer()]),o=ts(s);return new ve(o)}static createProgramAddressSync(e,t){let n=P.Buffer.alloc(0);e.forEach(function(o){if(o.length>Po)throw new TypeError("Max seed length exceeded");n=P.Buffer.concat([n,tt(o)])}),n=P.Buffer.concat([n,t.toBuffer(),P.Buffer.from("ProgramDerivedAddress")]);const s=ts(n);if(Io(s))throw new Error("Invalid seeds, address must fall off the curve");return new ve(s)}static async createProgramAddress(e,t){return this.createProgramAddressSync(e,t)}static findProgramAddressSync(e,t){let n=255,s;for(;n!=0;){try{const o=e.concat(P.Buffer.from([n]));s=this.createProgramAddressSync(o,t)}catch(o){if(o instanceof TypeError)throw o;n--;continue}return[s,n]}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 ve(e);return Io(t.toBytes())}}Bo=ve,ve.default=new Bo("11111111111111111111111111111111"),ur.set(ve,{kind:"struct",fields:[["_bn","u256"]]});class Ga{constructor(e){if(this._publicKey=void 0,this._secretKey=void 0,e){const t=tt(e);if(e.length!==64)throw new Error("bad secret key size");this._publicKey=t.slice(32,64),this._secretKey=t.slice(0,32)}else this._secretKey=tt(Ha()),this._publicKey=tt(Pr(this._secretKey))}get publicKey(){return new ve(this._publicKey)}get secretKey(){return P.Buffer.concat([this._secretKey,this._publicKey],64)}}const ja=new ve("BPFLoader1111111111111111111111111111111111"),Un=1280-40-8,Tr=127,Yn=64;class ys extends Error{constructor(e){super(`Signature ${e} has expired: block height exceeded.`),this.signature=void 0,this.signature=e}}Object.defineProperty(ys.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});class bs 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(bs.prototype,"name",{value:"TransactionExpiredTimeoutError"});class Jn extends Error{constructor(e){super(`Signature ${e} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=e}}Object.defineProperty(Jn.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});class lr{constructor(e,t){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=e,this.accountKeysFromLookups=t}keySegments(){const e=[this.staticAccountKeys];return this.accountKeysFromLookups&&(e.push(this.accountKeysFromLookups.writable),e.push(this.accountKeysFromLookups.readonly)),e}get(e){for(const t of this.keySegments()){if(e<t.length)return t[e];e-=t.length}}get length(){return this.keySegments().flat().length}compileInstructions(e){if(this.length>255+1)throw new Error("Account index overflow encountered during compilation");const n=new Map;this.keySegments().flat().forEach((o,i)=>{n.set(o.toBase58(),i)});const s=o=>{const i=n.get(o.toBase58());if(i===void 0)throw new Error("Encountered an unknown instruction account key during compilation");return i};return e.map(o=>({programIdIndex:s(o.programId),accountKeyIndexes:o.keys.map(i=>s(i.pubkey)),data:o.data}))}}const ct=(r="publicKey")=>b.Ik(32,r),$a=(r="signature")=>b.Ik(64,r),Mn=(r="string")=>{const e=b.n_([b.Jq("length"),b.Jq("lengthPadding"),b.Ik(b.cv(b.Jq(),-8),"chars")],r),t=e.decode.bind(e),n=e.encode.bind(e),s=e;return s.decode=(o,i)=>t(o,i).chars.toString(),s.encode=(o,i,a)=>{const u={chars:P.Buffer.from(o,"utf8")};return n(u,i,a)},s.alloc=o=>b.Jq().span+b.Jq().span+P.Buffer.from(o,"utf8").length,s},Ya=(r="authorized")=>b.n_([ct("staker"),ct("withdrawer")],r),Ja=(r="lockup")=>b.n_([b.gM("unixTimestamp"),b.gM("epoch"),ct("custodian")],r),Za=(r="voteInit")=>b.n_([ct("nodePubkey"),ct("authorizedVoter"),ct("authorizedWithdrawer"),b.u8("commission")],r),Xa=(r="voteAuthorizeWithSeedArgs")=>b.n_([b.Jq("voteAuthorizationType"),ct("currentAuthorityDerivedKeyOwnerPubkey"),Mn("currentAuthorityDerivedKeySeed"),ct("newAuthorized")],r);function Oo(r,e){const t=s=>{if(s.span>=0)return s.span;if(typeof s.alloc=="function")return s.alloc(e[s.property]);if("count"in s&&"elementLayout"in s){const o=e[s.property];if(Array.isArray(o))return o.length*t(s.elementLayout)}else if("fields"in s)return Oo({layout:s},e[s.property]);return 0};let n=0;return r.layout.fields.forEach(s=>{n+=t(s)}),n}function rn(r){let e=0,t=0;for(;;){let n=r.shift();if(e|=(n&127)<<t*7,t+=1,(n&128)===0)break}return e}function an(r,e){let t=e;for(;;){let n=t&127;if(t>>=7,t==0){r.push(n);break}else n|=128,r.push(n)}}function yt(r,e){if(!r)throw new Error(e||"Assertion failed")}class Or{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,s=i=>{const a=i.toBase58();let u=n.get(a);return u===void 0&&(u={isSigner:!1,isWritable:!1,isInvoked:!1},n.set(a,u)),u},o=s(t);o.isSigner=!0,o.isWritable=!0;for(const i of e){s(i.programId).isInvoked=!0;for(const a of i.keys){const u=s(a.pubkey);u.isSigner||(u.isSigner=a.isSigner),u.isWritable||(u.isWritable=a.isWritable)}}return new Or(t,n)}getMessageComponents(){const e=[...this.keyMetaMap.entries()];yt(e.length<=256,"Max static account keys length exceeded");const t=e.filter(([,u])=>u.isSigner&&u.isWritable),n=e.filter(([,u])=>u.isSigner&&!u.isWritable),s=e.filter(([,u])=>!u.isSigner&&u.isWritable),o=e.filter(([,u])=>!u.isSigner&&!u.isWritable),i={numRequiredSignatures:t.length+n.length,numReadonlySignedAccounts:n.length,numReadonlyUnsignedAccounts:o.length};{yt(t.length>0,"Expected at least one writable signer key");const[u]=t[0];yt(u===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}const a=[...t.map(([u])=>new ve(u)),...n.map(([u])=>new ve(u)),...s.map(([u])=>new ve(u)),...o.map(([u])=>new ve(u))];return[i,a]}extractTableLookup(e){const[t,n]=this.drainKeysFoundInLookupTable(e.state.addresses,i=>!i.isSigner&&!i.isInvoked&&i.isWritable),[s,o]=this.drainKeysFoundInLookupTable(e.state.addresses,i=>!i.isSigner&&!i.isInvoked&&!i.isWritable);if(!(t.length===0&&s.length===0))return[{accountKey:e.key,writableIndexes:t,readonlyIndexes:s},{writable:n,readonly:o}]}drainKeysFoundInLookupTable(e,t){const n=new Array,s=new Array;for(const[o,i]of this.keyMetaMap.entries())if(t(i)){const a=new ve(o),u=e.findIndex(d=>d.equals(a));u>=0&&(yt(u<256,"Max lookup table index exceeded"),n.push(u),s.push(a),this.keyMetaMap.delete(o))}return[n,s]}}class gn{constructor(e){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=e.header,this.accountKeys=e.accountKeys.map(t=>new ve(t)),this.recentBlockhash=e.recentBlockhash,this.instructions=e.instructions,this.instructions.forEach(t=>this.indexToProgramIds.set(t.programIdIndex,this.accountKeys[t.programIdIndex]))}get version(){return"legacy"}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:Yt().decode(e.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new lr(this.staticAccountKeys)}static compile(e){const t=Or.compile(e.instructions,e.payerKey),[n,s]=t.getMessageComponents(),i=new lr(s).compileInstructions(e.instructions).map(a=>({programIdIndex:a.programIdIndex,accounts:a.accountKeyIndexes,data:Yt().encode(a.data)}));return new gn({header:n,accountKeys:s,recentBlockhash:e.recentBlockhash,instructions:i})}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){const t=this.header.numRequiredSignatures;if(e>=this.header.numRequiredSignatures){const n=e-t,o=this.accountKeys.length-t-this.header.numReadonlyUnsignedAccounts;return n<o}else{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=[];an(t,e);const n=this.instructions.map(w=>{const{accounts:j,programIdIndex:C}=w,D=Array.from(Yt().decode(w.data));let k=[];an(k,j.length);let O=[];return an(O,D.length),{programIdIndex:C,keyIndicesCount:P.Buffer.from(k),keyIndices:j,dataLength:P.Buffer.from(O),data:D}});let s=[];an(s,n.length);let o=P.Buffer.alloc(Un);P.Buffer.from(s).copy(o);let i=s.length;n.forEach(w=>{const C=b.n_([b.u8("programIdIndex"),b.Ik(w.keyIndicesCount.length,"keyIndicesCount"),b.A9(b.u8("keyIndex"),w.keyIndices.length,"keyIndices"),b.Ik(w.dataLength.length,"dataLength"),b.A9(b.u8("userdatum"),w.data.length,"data")]).encode(w,o,i);i+=C}),o=o.slice(0,i);const a=b.n_([b.Ik(1,"numRequiredSignatures"),b.Ik(1,"numReadonlySignedAccounts"),b.Ik(1,"numReadonlyUnsignedAccounts"),b.Ik(t.length,"keyCount"),b.A9(ct("key"),e,"keys"),ct("recentBlockhash")]),u={numRequiredSignatures:P.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:P.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:P.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:P.Buffer.from(t),keys:this.accountKeys.map(w=>tt(w.toBytes())),recentBlockhash:Yt().decode(this.recentBlockhash)};let d=P.Buffer.alloc(2048);const g=a.encode(u,d);return o.copy(d,g),d.slice(0,g+o.length)}static from(e){let t=[...e];const n=t.shift();if(n!==(n&Tr))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const s=t.shift(),o=t.shift(),i=rn(t);let a=[];for(let j=0;j<i;j++){const C=t.slice(0,on);t=t.slice(on),a.push(new ve(P.Buffer.from(C)))}const u=t.slice(0,on);t=t.slice(on);const d=rn(t);let g=[];for(let j=0;j<d;j++){const C=t.shift(),D=rn(t),k=t.slice(0,D);t=t.slice(D);const O=rn(t),q=t.slice(0,O),fe=Yt().encode(P.Buffer.from(q));t=t.slice(O),g.push({programIdIndex:C,accounts:k,data:fe})}const w={header:{numRequiredSignatures:n,numReadonlySignedAccounts:s,numReadonlyUnsignedAccounts:o},recentBlockhash:Yt().encode(P.Buffer.from(u)),accountKeys:a,instructions:g};return new gn(w)}}class Wn{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 lr(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 s=e-n,o=this.addressTableLookups.reduce((i,a)=>i+a.writableIndexes.length,0);return s<o}else if(e>=this.header.numRequiredSignatures){const s=e-t,i=n-t-this.header.numReadonlyUnsignedAccounts;return s<i}else{const s=t-this.header.numReadonlySignedAccounts;return e<s}}resolveAddressTableLookups(e){const t={writable:[],readonly:[]};for(const n of this.addressTableLookups){const s=e.find(o=>o.key.equals(n.accountKey));if(!s)throw new Error(`Failed to find address lookup table account for table key ${n.accountKey.toBase58()}`);for(const o of n.writableIndexes)if(o<s.state.addresses.length)t.writable.push(s.state.addresses[o]);else throw new Error(`Failed to find address for index ${o} in address lookup table ${n.accountKey.toBase58()}`);for(const o of n.readonlyIndexes)if(o<s.state.addresses.length)t.readonly.push(s.state.addresses[o]);else throw new Error(`Failed to find address for index ${o} in address lookup table ${n.accountKey.toBase58()}`)}return t}static compile(e){const t=Or.compile(e.instructions,e.payerKey),n=new Array,s={writable:new Array,readonly:new Array},o=e.addressLookupTableAccounts||[];for(const g of o){const w=t.extractTableLookup(g);if(w!==void 0){const[j,{writable:C,readonly:D}]=w;n.push(j),s.writable.push(...C),s.readonly.push(...D)}}const[i,a]=t.getMessageComponents(),d=new lr(a,s).compileInstructions(e.instructions);return new Wn({header:i,staticAccountKeys:a,recentBlockhash:e.recentBlockhash,compiledInstructions:d,addressTableLookups:n})}serialize(){const e=Array();an(e,this.staticAccountKeys.length);const t=this.serializeInstructions(),n=Array();an(n,this.compiledInstructions.length);const s=this.serializeAddressTableLookups(),o=Array();an(o,this.addressTableLookups.length);const i=b.n_([b.u8("prefix"),b.n_([b.u8("numRequiredSignatures"),b.u8("numReadonlySignedAccounts"),b.u8("numReadonlyUnsignedAccounts")],"header"),b.Ik(e.length,"staticAccountKeysLength"),b.A9(ct(),this.staticAccountKeys.length,"staticAccountKeys"),ct("recentBlockhash"),b.Ik(n.length,"instructionsLength"),b.Ik(t.length,"serializedInstructions"),b.Ik(o.length,"addressTableLookupsLength"),b.Ik(s.length,"serializedAddressTableLookups")]),a=new Uint8Array(Un),u=1<<7,d=i.encode({prefix:u,header:this.header,staticAccountKeysLength:new Uint8Array(e),staticAccountKeys:this.staticAccountKeys.map(g=>g.toBytes()),recentBlockhash:Yt().decode(this.recentBlockhash),instructionsLength:new Uint8Array(n),serializedInstructions:t,addressTableLookupsLength:new Uint8Array(o),serializedAddressTableLookups:s},a);return a.slice(0,d)}serializeInstructions(){let e=0;const t=new Uint8Array(Un);for(const n of this.compiledInstructions){const s=Array();an(s,n.accountKeyIndexes.length);const o=Array();an(o,n.data.length);const i=b.n_([b.u8("programIdIndex"),b.Ik(s.length,"encodedAccountKeyIndexesLength"),b.A9(b.u8(),n.accountKeyIndexes.length,"accountKeyIndexes"),b.Ik(o.length,"encodedDataLength"),b.Ik(n.data.length,"data")]);e+=i.encode({programIdIndex:n.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(s),accountKeyIndexes:n.accountKeyIndexes,encodedDataLength:new Uint8Array(o),data:n.data},t,e)}return t.slice(0,e)}serializeAddressTableLookups(){let e=0;const t=new Uint8Array(Un);for(const n of this.addressTableLookups){const s=Array();an(s,n.writableIndexes.length);const o=Array();an(o,n.readonlyIndexes.length);const i=b.n_([ct("accountKey"),b.Ik(s.length,"encodedWritableIndexesLength"),b.A9(b.u8(),n.writableIndexes.length,"writableIndexes"),b.Ik(o.length,"encodedReadonlyIndexesLength"),b.A9(b.u8(),n.readonlyIndexes.length,"readonlyIndexes")]);e+=i.encode({accountKey:n.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(s),writableIndexes:n.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(o),readonlyIndexes:n.readonlyIndexes},t,e)}return t.slice(0,e)}static deserialize(e){let t=[...e];const n=t.shift(),s=n&Tr;yt(n!==s,"Expected versioned message but received legacy message");const o=s;yt(o===0,`Expected versioned message with version 0 but found version ${o}`);const i={numRequiredSignatures:t.shift(),numReadonlySignedAccounts:t.shift(),numReadonlyUnsignedAccounts:t.shift()},a=[],u=rn(t);for(let D=0;D<u;D++)a.push(new ve(t.splice(0,on)));const d=Yt().encode(t.splice(0,on)),g=rn(t),w=[];for(let D=0;D<g;D++){const k=t.shift(),O=rn(t),q=t.splice(0,O),fe=rn(t),he=new Uint8Array(t.splice(0,fe));w.push({programIdIndex:k,accountKeyIndexes:q,data:he})}const j=rn(t),C=[];for(let D=0;D<j;D++){const k=new ve(t.splice(0,on)),O=rn(t),q=t.splice(0,O),fe=rn(t),he=t.splice(0,fe);C.push({accountKey:k,writableIndexes:q,readonlyIndexes:he})}return new Wn({header:i,staticAccountKeys:a,recentBlockhash:d,compiledInstructions:w,addressTableLookups:C})}}const ms={deserializeMessageVersion(r){const e=r[0],t=e&Tr;return t===e?"legacy":t},deserialize:r=>{const e=ms.deserializeMessageVersion(r);if(e==="legacy")return gn.from(r);if(e===0)return Wn.deserialize(r);throw new Error(`Transaction message version ${e} deserialization is not supported`)}};let In=function(r){return r[r.BLOCKHEIGHT_EXCEEDED=0]="BLOCKHEIGHT_EXCEEDED",r[r.PROCESSED=1]="PROCESSED",r[r.TIMED_OUT=2]="TIMED_OUT",r[r.NONCE_INVALID=3]="NONCE_INVALID",r}({});const Qa=P.Buffer.alloc(Yn).fill(0);class vt{constructor(e){this.keys=void 0,this.programId=void 0,this.data=P.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 wt{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(e.length===0)throw new Error("No instructions");return e.forEach(t=>{"instructions"in t?this.instructions=this.instructions.concat(t.instructions):"data"in t&&"programId"in t&&"keys"in t?this.instructions.push(t):this.instructions.push(new vt(t))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let e,t;if(this.nonceInfo?(e=this.nonceInfo.nonce,this.instructions[0]!=this.nonceInfo.nonceInstruction?t=[this.nonceInfo.nonceInstruction,...this.instructions]:t=this.instructions):(e=this.recentBlockhash,t=this.instructions),!e)throw new Error("Transaction recentBlockhash required");t.length<1&&console.warn("No instructions provided");let n;if(this.feePayer)n=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)n=this.signatures[0].publicKey;else throw new Error("Transaction fee payer required");for(let k=0;k<t.length;k++)if(t[k].programId===void 0)throw new Error(`Transaction instruction index ${k} has undefined program id`);const s=[],o=[];t.forEach(k=>{k.keys.forEach(q=>{o.push({...q})});const O=k.programId.toString();s.includes(O)||s.push(O)}),s.forEach(k=>{o.push({pubkey:new ve(k),isSigner:!1,isWritable:!1})});const i=[];o.forEach(k=>{const O=k.pubkey.toString(),q=i.findIndex(fe=>fe.pubkey.toString()===O);q>-1?(i[q].isWritable=i[q].isWritable||k.isWritable,i[q].isSigner=i[q].isSigner||k.isSigner):i.push(k)}),i.sort(function(k,O){if(k.isSigner!==O.isSigner)return k.isSigner?-1:1;if(k.isWritable!==O.isWritable)return k.isWritable?-1:1;const q={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return k.pubkey.toBase58().localeCompare(O.pubkey.toBase58(),"en",q)});const a=i.findIndex(k=>k.pubkey.equals(n));if(a>-1){const[k]=i.splice(a,1);k.isSigner=!0,k.isWritable=!0,i.unshift(k)}else i.unshift({pubkey:n,isSigner:!0,isWritable:!0});for(const k of this.signatures){const O=i.findIndex(q=>q.pubkey.equals(k.publicKey));if(O>-1)i[O].isSigner||(i[O].isSigner=!0,console.warn("Transaction references a signature that is unnecessary, only the fee payer and instruction signer accounts should sign a transaction. This behavior is deprecated and will throw an error in the next major version release."));else throw new Error(`unknown signer: ${k.publicKey.toString()}`)}let u=0,d=0,g=0;const w=[],j=[];i.forEach(({pubkey:k,isSigner:O,isWritable:q})=>{O?(w.push(k.toString()),u+=1,q||(d+=1)):(j.push(k.toString()),q||(g+=1))});const C=w.concat(j),D=t.map(k=>{const{data:O,programId:q}=k;return{programIdIndex:C.indexOf(q.toString()),accounts:k.keys.map(fe=>C.indexOf(fe.pubkey.toString())),data:Yt().encode(O)}});return D.forEach(k=>{yt(k.programIdIndex>=0),k.accounts.forEach(O=>yt(O>=0))}),new gn({header:{numRequiredSignatures:u,numReadonlySignedAccounts:d,numReadonlyUnsignedAccounts:g},accountKeys:C,recentBlockhash:e,instructions:D})}_compile(){const e=this.compileMessage(),t=e.accountKeys.slice(0,e.header.numRequiredSignatures);return this.signatures.length===t.length&&this.signatures.every((s,o)=>t[o].equals(s.publicKey))||(this.signatures=t.map(n=>({signature:null,publicKey:n}))),e}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(e){return(await e.getFeeForMessage(this.compileMessage())).value}setSigners(...e){if(e.length===0)throw new Error("No signers");const t=new Set;this.signatures=e.filter(n=>{const s=n.toString();return t.has(s)?!1:(t.add(s),!0)}).map(n=>({signature:null,publicKey:n}))}sign(...e){if(e.length===0)throw new Error("No signers");const t=new Set,n=[];for(const o of e){const i=o.publicKey.toString();t.has(i)||(t.add(i),n.push(o))}this.signatures=n.map(o=>({signature:null,publicKey:o.publicKey}));const s=this._compile();this._partialSign(s,...n)}partialSign(...e){if(e.length===0)throw new Error("No signers");const t=new Set,n=[];for(const o of e){const i=o.publicKey.toString();t.has(i)||(t.add(i),n.push(o))}const s=this._compile();this._partialSign(s,...n)}_partialSign(e,...t){const n=e.serialize();t.forEach(s=>{const o=ps(n,s.secretKey);this._addSignature(s.publicKey,tt(o))})}addSignature(e,t){this._compile(),this._addSignature(e,t)}_addSignature(e,t){yt(t.length===64);const n=this.signatures.findIndex(s=>e.equals(s.publicKey));if(n<0)throw new Error(`unknown signer: ${e.toString()}`);this.signatures[n].signature=P.Buffer.from(t)}verifySignatures(e){return this._verifySignatures(this.serializeMessage(),e===void 0?!0:e)}_verifySignatures(e,t){for(const{signature:n,publicKey:s}of this.signatures)if(n===null){if(t)return!1}else if(!qa(n,e,s.toBytes()))return!1;return!0}serialize(e){const{requireAllSignatures:t,verifySignatures:n}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},e),s=this.serializeMessage();if(n&&!this._verifySignatures(s,t))throw new Error("Signature verification failed");return this._serialize(s)}_serialize(e){const{signatures:t}=this,n=[];an(n,t.length);const s=n.length+t.length*64+e.length,o=P.Buffer.alloc(s);return yt(t.length<256),P.Buffer.from(n).copy(o,0),t.forEach(({signature:i},a)=>{i!==null&&(yt(i.length===64,"signature has invalid length"),P.Buffer.from(i).copy(o,n.length+a*64))}),e.copy(o,n.length+t.length*64),yt(o.length<=Un,`Transaction too large: ${o.length} > ${Un}`),o}get keys(){return yt(this.instructions.length===1),this.instructions[0].keys.map(e=>e.pubkey)}get programId(){return yt(this.instructions.length===1),this.instructions[0].programId}get data(){return yt(this.instructions.length===1),this.instructions[0].data}static from(e){let t=[...e];const n=rn(t);let s=[];for(let o=0;o<n;o++){const i=t.slice(0,Yn);t=t.slice(Yn),s.push(Yt().encode(P.Buffer.from(i)))}return wt.populate(gn.from(t),s)}static populate(e,t=[]){const n=new wt;return n.recentBlockhash=e.recentBlockhash,e.header.numRequiredSignatures>0&&(n.feePayer=e.accountKeys[0]),t.forEach((s,o)=>{const i={signature:s==Yt().encode(Qa)?null:Yt().decode(s),publicKey:e.accountKeys[o]};n.signatures.push(i)}),e.instructions.forEach(s=>{const o=s.accounts.map(i=>{const a=e.accountKeys[i];return{pubkey:a,isSigner:n.signatures.some(u=>u.publicKey.toString()===a.toString())||e.isAccountSigner(i),isWritable:e.isAccountWritable(i)}});n.instructions.push(new vt({keys:o,programId:e.accountKeys[s.programIdIndex],data:Yt().decode(s.data)}))}),n._message=e,n._json=n.toJSON(),n}}class ws{constructor(e){this.payerKey=void 0,this.instructions=void 0,this.recentBlockhash=void 0,this.payerKey=e.payerKey,this.instructions=e.instructions,this.recentBlockhash=e.recentBlockhash}static decompile(e,t){const{header:n,compiledInstructions:s,recentBlockhash:o}=e,{numRequiredSignatures:i,numReadonlySignedAccounts:a,numReadonlyUnsignedAccounts:u}=n,d=i-a;yt(d>0,"Message header is invalid");const g=e.staticAccountKeys.length-i-u;yt(g>=0,"Message header is invalid");const w=e.getAccountKeys(t),j=w.get(0);if(j===void 0)throw new Error("Failed to decompile message because no account keys were found");const C=[];for(const D of s){const k=[];for(const q of D.accountKeyIndexes){const fe=w.get(q);if(fe===void 0)throw new Error(`Failed to find key for account key index ${q}`);const he=q<i;let Oe;he?Oe=q<d:q<w.staticAccountKeys.length?Oe=q-i<g:Oe=q-w.staticAccountKeys.length<w.accountKeysFromLookups.writable.length,k.push({pubkey:fe,isSigner:q<n.numRequiredSignatures,isWritable:Oe})}const O=w.get(D.programIdIndex);if(O===void 0)throw new Error(`Failed to find program id for program id index ${D.programIdIndex}`);C.push(new vt({programId:O,data:tt(D.data),keys:k}))}return new ws({payerKey:j,instructions:C,recentBlockhash:o})}compileToLegacyMessage(){return gn.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions})}compileToV0Message(e){return Wn.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions,addressLookupTableAccounts:e})}}class ks{get version(){return this.message.version}constructor(e,t){if(this.signatures=void 0,this.message=void 0,t!==void 0)yt(t.length===e.header.numRequiredSignatures,"Expected signatures length to be equal to the number of required signatures"),this.signatures=t;else{const n=[];for(let s=0;s<e.header.numRequiredSignatures;s++)n.push(new Uint8Array(Yn));this.signatures=n}this.message=e}serialize(){const e=this.message.serialize(),t=Array();an(t,this.signatures.length);const n=b.n_([b.Ik(t.length,"encodedSignaturesLength"),b.A9($a(),this.signatures.length,"signatures"),b.Ik(e.length,"serializedMessage")]),s=new Uint8Array(2048),o=n.encode({encodedSignaturesLength:new Uint8Array(t),signatures:this.signatures,serializedMessage:e},s);return s.slice(0,o)}static deserialize(e){let t=[...e];const n=[],s=rn(t);for(let i=0;i<s;i++)n.push(new Uint8Array(t.splice(0,Yn)));const o=ms.deserialize(new Uint8Array(t));return new ks(o,n)}sign(e){const t=this.message.serialize(),n=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures);for(const s of e){const o=n.findIndex(i=>i.equals(s.publicKey));yt(o>=0,`Cannot sign with non signer key ${s.publicKey.toBase58()}`),this.signatures[o]=ps(t,s.secretKey)}}addSignature(e,t){yt(t.byteLength===64,"Signature must be 64 bytes long");const s=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex(o=>o.equals(e));yt(s>=0,`Can not add signature; \`${e.toBase58()}\` is not required to sign this transaction`),this.signatures[s]=t}}const Lo=1e3/(160/64),vn=new ve("SysvarC1ock11111111111111111111111111111111"),ec=new ve("SysvarEpochSchedu1e111111111111111111111111"),tc=new ve("Sysvar1nstructions1111111111111111111111111"),Lr=new ve("SysvarRecentB1ockHashes11111111111111111111"),Zn=new ve("SysvarRent111111111111111111111111111111111"),nc=new ve("SysvarRewards111111111111111111111111111111"),rc=new ve("SysvarS1otHashes111111111111111111111111111"),sc=new ve("SysvarS1otHistory11111111111111111111111111"),Cr=new ve("SysvarStakeHistory1111111111111111111111111");async function Ss(r,e,t,n){const s=n&&{skipPreflight:n.skipPreflight,preflightCommitment:n.preflightCommitment||n.commitment,maxRetries:n.maxRetries,minContextSlot:n.minContextSlot},o=await r.sendTransaction(e,t,s);let i;if(e.recentBlockhash!=null&&e.lastValidBlockHeight!=null)i=(await r.confirmTransaction({abortSignal:n==null?void 0:n.abortSignal,signature:o,blockhash:e.recentBlockhash,lastValidBlockHeight:e.lastValidBlockHeight},n&&n.commitment)).value;else if(e.minNonceContextSlot!=null&&e.nonceInfo!=null){const{nonceInstruction:a}=e.nonceInfo,u=a.keys[0].pubkey;i=(await r.confirmTransaction({abortSignal:n==null?void 0:n.abortSignal,minContextSlot:e.minNonceContextSlot,nonceAccountPubkey:u,nonceValue:e.nonceInfo.nonce,signature:o},n&&n.commitment)).value}else(n==null?void 0:n.abortSignal)!=null&&console.warn("sendAndConfirmTransaction(): A transaction with a deprecated confirmation strategy was supplied along with an `abortSignal`. Only transactions having `lastValidBlockHeight` or a combination of `nonceInfo` and `minNonceContextSlot` are abortable."),i=(await r.confirmTransaction(o,n&&n.commitment)).value;if(i.err)throw new Error(`Transaction ${o} failed (${JSON.stringify(i)})`);return o}function Hn(r){return new Promise(e=>setTimeout(e,r))}function ht(r,e){const t=r.layout.span>=0?r.layout.span:Oo(r,e),n=P.Buffer.alloc(t),s=Object.assign({instruction:r.index},e);return r.layout.encode(s,n),n}function kt(r,e){let t;try{t=r.layout.decode(e)}catch(n){throw new Error("invalid instruction; "+n)}if(t.instruction!==r.index)throw new Error(`invalid instruction; instruction index mismatch ${t.instruction} != ${r.index}`);return t}const Co=b._O("lamportsPerSignature"),No=b.n_([b.Jq("version"),b.Jq("state"),ct("authorizedPubkey"),ct("nonce"),b.n_([Co],"feeCalculator")]),Es=No.span;class Nr{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=No.decode(tt(e),0);return new Nr({authorizedPubkey:new ve(t.authorizedPubkey),nonce:new ve(t.nonce).toString(),feeCalculator:t.feeCalculator})}}const oc=r=>{const e=r.decode.bind(r),t=r.encode.bind(r);return{decode:e,encode:t}},Xn=(r=>e=>{const t=(0,b.Ik)(r,e),{encode:n,decode:s}=oc(t),o=t;return o.decode=(i,a)=>{const u=s(i,a);return(0,rs.oU)(P.Buffer.from(u))},o.encode=(i,a,u)=>{const d=(0,rs.k$)(i,r);return n(d,a,u)},o})(8);class ic{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);const n=b.Jq("instruction").decode(e.data);let s;for(const[o,i]of Object.entries(At))if(i.index==n){s=o;break}if(!s)throw new Error("Instruction type incorrect; not a SystemInstruction");return s}static decodeCreateAccount(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{lamports:t,space:n,programId:s}=kt(At.Create,e.data);return{fromPubkey:e.keys[0].pubkey,newAccountPubkey:e.keys[1].pubkey,lamports:t,space:n,programId:new ve(s)}}static decodeTransfer(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{lamports:t}=kt(At.Transfer,e.data);return{fromPubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,lamports:t}}static decodeTransferWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{lamports:t,seed:n,programId:s}=kt(At.TransferWithSeed,e.data);return{fromPubkey:e.keys[0].pubkey,basePubkey:e.keys[1].pubkey,toPubkey:e.keys[2].pubkey,lamports:t,seed:n,programId:new ve(s)}}static decodeAllocate(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);const{space:t}=kt(At.Allocate,e.data);return{accountPubkey:e.keys[0].pubkey,space:t}}static decodeAllocateWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);const{base:t,seed:n,space:s,programId:o}=kt(At.AllocateWithSeed,e.data);return{accountPubkey:e.keys[0].pubkey,basePubkey:new ve(t),seed:n,space:s,programId:new ve(o)}}static decodeAssign(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);const{programId:t}=kt(At.Assign,e.data);return{accountPubkey:e.keys[0].pubkey,programId:new ve(t)}}static decodeAssignWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);const{base:t,seed:n,programId:s}=kt(At.AssignWithSeed,e.data);return{accountPubkey:e.keys[0].pubkey,basePubkey:new ve(t),seed:n,programId:new ve(s)}}static decodeCreateWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{base:t,seed:n,lamports:s,space:o,programId:i}=kt(At.CreateWithSeed,e.data);return{fromPubkey:e.keys[0].pubkey,newAccountPubkey:e.keys[1].pubkey,basePubkey:new ve(t),seed:n,lamports:s,space:o,programId:new ve(i)}}static decodeNonceInitialize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{authorized:t}=kt(At.InitializeNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,authorizedPubkey:new ve(t)}}static decodeNonceAdvance(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3),kt(At.AdvanceNonceAccount,e.data),{noncePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey}}static decodeNonceWithdraw(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,5);const{lamports:t}=kt(At.WithdrawNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[4].pubkey,lamports:t}}static decodeNonceAuthorize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{authorized:t}=kt(At.AuthorizeNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[1].pubkey,newAuthorizedPubkey:new ve(t)}}static checkProgramId(e){if(!e.equals(Jt.programId))throw new Error("invalid instruction; programId is not SystemProgram")}static checkKeyLength(e,t){if(e.length<t)throw new Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}}const At=Object.freeze({Create:{index:0,layout:b.n_([b.Jq("instruction"),b.gM("lamports"),b.gM("space"),ct("programId")])},Assign:{index:1,layout:b.n_([b.Jq("instruction"),ct("programId")])},Transfer:{index:2,layout:b.n_([b.Jq("instruction"),Xn("lamports")])},CreateWithSeed:{index:3,layout:b.n_([b.Jq("instruction"),ct("base"),Mn("seed"),b.gM("lamports"),b.gM("space"),ct("programId")])},AdvanceNonceAccount:{index:4,layout:b.n_([b.Jq("instruction")])},WithdrawNonceAccount:{index:5,layout:b.n_([b.Jq("instruction"),b.gM("lamports")])},InitializeNonceAccount:{index:6,layout:b.n_([b.Jq("instruction"),ct("authorized")])},AuthorizeNonceAccount:{index:7,layout:b.n_([b.Jq("instruction"),ct("authorized")])},Allocate:{index:8,layout:b.n_([b.Jq("instruction"),b.gM("space")])},AllocateWithSeed:{index:9,layout:b.n_([b.Jq("instruction"),ct("base"),Mn("seed"),b.gM("space"),ct("programId")])},AssignWithSeed:{index:10,layout:b.n_([b.Jq("instruction"),ct("base"),Mn("seed"),ct("programId")])},TransferWithSeed:{index:11,layout:b.n_([b.Jq("instruction"),Xn("lamports"),Mn("seed"),ct("programId")])},UpgradeNonceAccount:{index:12,layout:b.n_([b.Jq("instruction")])}});class Jt{constructor(){}static createAccount(e){const t=At.Create,n=ht(t,{lamports:e.lamports,space:e.space,programId:tt(e.programId.toBuffer())});return new vt({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 s=At.TransferWithSeed;t=ht(s,{lamports:BigInt(e.lamports),seed:e.seed,programId:tt(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 s=At.Transfer;t=ht(s,{lamports:BigInt(e.lamports)}),n=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}return new vt({keys:n,programId:this.programId,data:t})}static assign(e){let t,n;if("basePubkey"in e){const s=At.AssignWithSeed;t=ht(s,{base:tt(e.basePubkey.toBuffer()),seed:e.seed,programId:tt(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{const s=At.Assign;t=ht(s,{programId:tt(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new vt({keys:n,programId:this.programId,data:t})}static createAccountWithSeed(e){const t=At.CreateWithSeed,n=ht(t,{base:tt(e.basePubkey.toBuffer()),seed:e.seed,lamports:e.lamports,space:e.space,programId:tt(e.programId.toBuffer())});let s=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!1,isWritable:!0}];return e.basePubkey!=e.fromPubkey&&s.push({pubkey:e.basePubkey,isSigner:!0,isWritable:!1}),new vt({keys:s,programId:this.programId,data:n})}static createNonceAccount(e){const t=new wt;"basePubkey"in e&&"seed"in e?t.add(Jt.createAccountWithSeed({fromPubkey:e.fromPubkey,newAccountPubkey:e.noncePubkey,basePubkey:e.basePubkey,seed:e.seed,lamports:e.lamports,space:Es,programId:this.programId})):t.add(Jt.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.noncePubkey,lamports:e.lamports,space:Es,programId:this.programId}));const n={noncePubkey:e.noncePubkey,authorizedPubkey:e.authorizedPubkey};return t.add(this.nonceInitialize(n)),t}static nonceInitialize(e){const t=At.InitializeNonceAccount,n=ht(t,{authorized:tt(e.authorizedPubkey.toBuffer())}),s={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:Lr,isSigner:!1,isWritable:!1},{pubkey:Zn,isSigner:!1,isWritable:!1}],programId:this.programId,data:n};return new vt(s)}static nonceAdvance(e){const t=At.AdvanceNonceAccount,n=ht(t),s={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:Lr,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n};return new vt(s)}static nonceWithdraw(e){const t=At.WithdrawNonceAccount,n=ht(t,{lamports:e.lamports});return new vt({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0},{pubkey:Lr,isSigner:!1,isWritable:!1},{pubkey:Zn,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static nonceAuthorize(e){const t=At.AuthorizeNonceAccount,n=ht(t,{authorized:tt(e.newAuthorizedPubkey.toBuffer())});return new vt({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 s=At.AllocateWithSeed;t=ht(s,{base:tt(e.basePubkey.toBuffer()),seed:e.seed,space:e.space,programId:tt(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{const s=At.Allocate;t=ht(s,{space:e.space}),n=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new vt({keys:n,programId:this.programId,data:t})}}Jt.programId=new ve("11111111111111111111111111111111");const ac=Un-300;class qn{constructor(){}static getMinNumSignatures(e){return 2*(Math.ceil(e/qn.chunkSize)+1+1)}static async load(e,t,n,s,o){{const w=await e.getMinimumBalanceForRentExemption(o.length),j=await e.getAccountInfo(n.publicKey,"confirmed");let C=null;if(j!==null){if(j.executable)return console.error("Program load failed, account is already executable"),!1;j.data.length!==o.length&&(C=C||new wt,C.add(Jt.allocate({accountPubkey:n.publicKey,space:o.length}))),j.owner.equals(s)||(C=C||new wt,C.add(Jt.assign({accountPubkey:n.publicKey,programId:s}))),j.lamports<w&&(C=C||new wt,C.add(Jt.transfer({fromPubkey:t.publicKey,toPubkey:n.publicKey,lamports:w-j.lamports})))}else C=new wt().add(Jt.createAccount({fromPubkey:t.publicKey,newAccountPubkey:n.publicKey,lamports:w>0?w:1,space:o.length,programId:s}));C!==null&&await Ss(e,C,[t,n],{commitment:"confirmed"})}const i=b.n_([b.Jq("instruction"),b.Jq("offset"),b.Jq("bytesLength"),b.Jq("bytesLengthPadding"),b.A9(b.u8("byte"),b.cv(b.Jq(),-8),"bytes")]),a=qn.chunkSize;let u=0,d=o,g=[];for(;d.length>0;){const w=d.slice(0,a),j=P.Buffer.alloc(a+16);i.encode({instruction:0,offset:u,bytes:w,bytesLength:0,bytesLengthPadding:0},j);const C=new wt().add({keys:[{pubkey:n.publicKey,isSigner:!0,isWritable:!0}],programId:s,data:j});g.push(Ss(e,C,[t,n],{commitment:"confirmed"})),e._rpcEndpoint.includes("solana.com")&&await Hn(1e3/4),u+=a,d=d.slice(a)}await Promise.all(g);{const w=b.n_([b.Jq("instruction")]),j=P.Buffer.alloc(w.span);w.encode({instruction:1},j);const C=new wt().add({keys:[{pubkey:n.publicKey,isSigner:!0,isWritable:!0},{pubkey:Zn,isSigner:!1,isWritable:!1}],programId:s,data:j}),D="processed",k=await e.sendTransaction(C,[t,n],{preflightCommitment:D}),{context:O,value:q}=await e.confirmTransaction({signature:k,lastValidBlockHeight:C.lastValidBlockHeight,blockhash:C.recentBlockhash},D);if(q.err)throw new Error(`Transaction ${k} failed (${JSON.stringify(q)})`);for(;;){try{if(await e.getSlot({commitment:D})>O.slot)break}catch{}await new Promise(fe=>setTimeout(fe,Math.round(Lo/2)))}}return!0}}qn.chunkSize=ac;const cc=new ve("BPFLoader2111111111111111111111111111111111");class uc{static getMinNumSignatures(e){return qn.getMinNumSignatures(e)}static load(e,t,n,s,o){return qn.load(e,t,n,o,s)}}function lc(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var fc=Object.prototype.toString,dc=Object.keys||function(r){var e=[];for(var t in r)e.push(t);return e};function fr(r,e){var t,n,s,o,i,a,u;if(r===!0)return"true";if(r===!1)return"false";switch(typeof r){case"object":if(r===null)return null;if(r.toJSON&&typeof r.toJSON=="function")return fr(r.toJSON(),e);if(u=fc.call(r),u==="[object Array]"){for(s="[",n=r.length-1,t=0;t<n;t++)s+=fr(r[t],!0)+",";return n>-1&&(s+=fr(r[t],!0)),s+"]"}else if(u==="[object Object]"){for(o=dc(r).sort(),n=o.length,s="",t=0;t<n;)i=o[t],a=fr(r[i],!1),a!==void 0&&(s&&(s+=","),s+=JSON.stringify(i)+":"+a),t++;return"{"+s+"}"}else return JSON.stringify(r);case"function":case"undefined":return e?null:void 0;case"string":return JSON.stringify(r);default:return isFinite(r)?r:null}}var hc=function(r){var e=fr(r,!1);if(e!==void 0)return""+e},Uo=lc(hc);const dr=32;function _s(r){let e=0;for(;r>1;)r/=2,e++;return e}function pc(r){return r===0?1:(r--,r|=r>>1,r|=r>>2,r|=r>>4,r|=r>>8,r|=r>>16,r|=r>>32,r+1)}class zo{constructor(e,t,n,s,o){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=s,this.firstNormalSlot=o}getEpoch(e){return this.getEpochAndSlotIndex(e)[0]}getEpochAndSlotIndex(e){if(e<this.firstNormalSlot){const t=_s(pc(e+dr+1))-_s(dr)-1,n=this.getSlotsInEpoch(t),s=e-(n-dr);return[t,s]}else{const t=e-this.firstNormalSlot,n=Math.floor(t/this.slotsPerEpoch),s=this.firstNormalEpoch+n,o=t%this.slotsPerEpoch;return[s,o]}}getFirstSlotInEpoch(e){return e<=this.firstNormalEpoch?(Math.pow(2,e)-1)*dr:(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+_s(dr)):this.slotsPerEpoch}}class xs extends Error{constructor(e,t){super(e),this.logs=void 0,this.logs=t}}const gc={JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP:-32001,JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE:-32002,JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE:-32003,JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE:-32004,JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY:-32005,JSON_RPC_SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE:-32006,JSON_RPC_SERVER_ERROR_SLOT_SKIPPED:-32007,JSON_RPC_SERVER_ERROR_NO_SNAPSHOT:-32008,JSON_RPC_SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED:-32009,JSON_RPC_SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX:-32010,JSON_RPC_SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE:-32011,JSON_RPC_SCAN_ERROR:-32012,JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH:-32013,JSON_RPC_SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET:-32014,JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION:-32015,JSON_RPC_SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED:-32016};class He extends Error{constructor({code:e,message:t,data:n},s){super(s!=null?`${s}: ${t}`:t),this.code=void 0,this.data=void 0,this.code=e,this.data=n,this.name="SolanaJSONRPCError"}}var yc=globalThis.fetch;class bc extends ma.Z{constructor(e,t,n){const s=o=>{const i=(0,wa.Z)(o,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...t});return"socket"in i?this.underlyingSocket=i.socket:this.underlyingSocket=i,i};super(s,e,t,n),this.underlyingSocket=void 0}call(...e){var n;const t=(n=this.underlyingSocket)==null?void 0:n.readyState;return t===1?super.call(...e):Promise.reject(new Error("Tried to call a JSON-RPC method `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+")"))}notify(...e){var n;const t=(n=this.underlyingSocket)==null?void 0:n.readyState;return t===1?super.notify(...e):Promise.reject(new Error("Tried to send a JSON-RPC notification `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+")"))}}function mc(r,e){let t;try{t=r.layout.decode(e)}catch(n){throw new Error("invalid instruction; "+n)}if(t.typeIndex!==r.index)throw new Error(`invalid account data; account type mismatch ${t.typeIndex} != ${r.index}`);return t}const Ko=56;class vs{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=mc(wc,e),n=e.length-Ko;yt(n>=0,"lookup table is invalid"),yt(n%32===0,"lookup table is invalid");const s=n/32,{addresses:o}=b.n_([b.A9(ct(),s,"addresses")]).decode(e.slice(Ko));return{deactivationSlot:t.deactivationSlot,lastExtendedSlot:t.lastExtendedSlot,lastExtendedSlotStartIndex:t.lastExtendedStartIndex,authority:t.authority.length!==0?new ve(t.authority[0]):void 0,addresses:o.map(i=>new ve(i))}}}const wc={index:1,layout:b.n_([b.Jq("typeIndex"),Xn("deactivationSlot"),b._O("lastExtendedSlot"),b.u8("lastExtendedStartIndex"),b.u8(),b.A9(ct(),b.cv(b.u8(),-1),"authority")])},kc=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;function Sc(r){const e=r.match(kc);if(e==null)throw TypeError(`Failed to validate endpoint URL \`${r}\``);const[t,n,s,o]=e,i=r.startsWith("https:")?"wss:":"ws:",a=s==null?null:parseInt(s.slice(1),10),u=a==null?"":`:${a+1}`;return`${i}//${n}${u}${o}`}const Ht=Kn(is(ve),_e(),r=>new ve(r)),Do=as([_e(),Lt("base64")]),As=Kn(is(P.Buffer),Do,r=>P.Buffer.from(r[0],"base64")),Mo=30*1e3;function Ec(r){if(/^https?:/.test(r)===!1)throw new TypeError("Endpoint URL must start with `http:` or `https:`.");return r}function Pt(r){let e,t;if(typeof r=="string")e=r;else if(r){const{commitment:n,...s}=r;e=n,t=s}return{commitment:e,config:t}}function Wo(r){return nn([de({jsonrpc:Lt("2.0"),id:_e(),result:r}),de({jsonrpc:Lt("2.0"),id:_e(),error:de({code:$n(),message:_e(),data:Qe(ga())})})])}const _c=Wo($n());function nt(r){return Kn(Wo(r),_c,e=>"error"in e?e:{...e,result:Ie(e.result,r)})}function Ut(r){return nt(de({context:de({slot:N()}),value:r}))}function Ur(r){return de({context:de({slot:N()}),value:r})}function Is(r,e){return r===0?new Wn({header:e.header,staticAccountKeys:e.accountKeys.map(t=>new ve(t)),recentBlockhash:e.recentBlockhash,compiledInstructions:e.instructions.map(t=>({programIdIndex:t.programIdIndex,accountKeyIndexes:t.accounts,data:Yt().decode(t.data)})),addressTableLookups:e.addressTableLookups}):new gn(e)}const xc=de({foundation:N(),foundationTerm:N(),initial:N(),taper:N(),terminal:N()}),vc=nt(Ce(Le(de({epoch:N(),effectiveSlot:N(),amount:N(),postBalance:N(),commission:Qe(Le(N()))})))),Ac=Ce(de({slot:N(),prioritizationFee:N()})),Ic=de({total:N(),validator:N(),foundation:N(),epoch:N()}),Bc=de({epoch:N(),slotIndex:N(),slotsInEpoch:N(),absoluteSlot:N(),blockHeight:Qe(N()),transactionCount:Qe(N())}),Rc=de({slotsPerEpoch:N(),leaderScheduleSlotOffset:N(),warmup:xn(),firstNormalEpoch:N(),firstNormalSlot:N()}),Pc=co(_e(),Ce(N())),Fn=Le(nn([de({}),_e()])),Tc=de({err:Fn}),Oc=Lt("receivedSignature"),Lc=de({"solana-core":_e(),"feature-set":Qe(N())}),Ho=Ut(de({err:Le(nn([de({}),_e()])),logs:Le(Ce(_e())),accounts:Qe(Le(Ce(Le(de({executable:xn(),owner:_e(),lamports:N(),data:Ce(_e()),rentEpoch:Qe(N())}))))),unitsConsumed:Qe(N()),returnData:Qe(Le(de({programId:_e(),data:as([_e(),Lt("base64")])})))})),Cc=Ut(de({byIdentity:co(_e(),Ce(N())),range:de({firstSlot:N(),lastSlot:N()})}));function Nc(r,e,t,n,s,o){const i=t||yc;let a;o!=null&&console.warn("You have supplied an `httpAgent` when creating a `Connection` in a browser environment.It has been ignored; `httpAgent` is only used in Node environments.");let u;return n&&(u=async(g,w)=>{const j=await new Promise((C,D)=>{try{n(g,w,(k,O)=>C([k,O]))}catch(k){D(k)}});return await i(...j)}),new(ba())(async(g,w)=>{const j={method:"POST",body:g,agent:a,headers:Object.assign({"Content-Type":"application/json"},e||{},Uu)};try{let C=5,D,k=500;for(;u?D=await u(r,j):D=await i(r,j),!(D.status!==429||s===!0||(C-=1,C===0));)console.log(`Server responded with ${D.status} ${D.statusText}. Retrying after ${k}ms delay...`),await Hn(k),k*=2;const O=await D.text();D.ok?w(null,O):w(new Error(`${D.status} ${D.statusText}: ${O}`))}catch(C){C instanceof Error&&w(C)}},{})}function Uc(r){return(e,t)=>new Promise((n,s)=>{r.request(e,t,(o,i)=>{if(o){s(o);return}n(i)})})}function zc(r){return e=>new Promise((t,n)=>{e.length===0&&t([]);const s=e.map(o=>r.request(o.methodName,o.args));r.request(s,(o,i)=>{if(o){n(o);return}t(i)})})}const Kc=nt(xc),Dc=nt(Ic),Mc=nt(Ac),Wc=nt(Bc),Hc=nt(Rc),qc=nt(Pc),Fc=nt(N()),Vc=Ut(de({total:N(),circulating:N(),nonCirculating:N(),nonCirculatingAccounts:Ce(Ht)})),Bs=de({amount:_e(),uiAmount:Le(N()),decimals:N(),uiAmountString:Qe(_e())}),Gc=Ut(Ce(de({address:Ht,amount:_e(),uiAmount:Le(N()),decimals:N(),uiAmountString:Qe(_e())}))),jc=Ut(Ce(de({pubkey:Ht,account:de({executable:xn(),owner:Ht,lamports:N(),data:As,rentEpoch:N()})}))),Rs=de({program:_e(),parsed:$n(),space:N()}),$c=Ut(Ce(de({pubkey:Ht,account:de({executable:xn(),owner:Ht,lamports:N(),data:Rs,rentEpoch:N()})}))),Yc=Ut(Ce(de({lamports:N(),address:Ht}))),hr=de({executable:xn(),owner:Ht,lamports:N(),data:As,rentEpoch:N()}),Jc=de({pubkey:Ht,account:hr}),Zc=Kn(nn([is(P.Buffer),Rs]),nn([Do,Rs]),r=>Array.isArray(r)?Ie(r,As):r),Ps=de({executable:xn(),owner:Ht,lamports:N(),data:Zc,rentEpoch:N()}),Xc=de({pubkey:Ht,account:Ps}),Qc=de({state:nn([Lt("active"),Lt("inactive"),Lt("activating"),Lt("deactivating")]),active:N(),inactive:N()}),eu=nt(Ce(de({signature:_e(),slot:N(),err:Fn,memo:Le(_e()),blockTime:Qe(Le(N()))}))),tu=nt(Ce(de({signature:_e(),slot:N(),err:Fn,memo:Le(_e()),blockTime:Qe(Le(N()))}))),nu=de({subscription:N(),result:Ur(hr)}),ru=de({pubkey:Ht,account:hr}),su=de({subscription:N(),result:Ur(ru)}),ou=de({parent:N(),slot:N(),root:N()}),iu=de({subscription:N(),result:ou}),au=nn([de({type:nn([Lt("firstShredReceived"),Lt("completed"),Lt("optimisticConfirmation"),Lt("root")]),slot:N(),timestamp:N()}),de({type:Lt("createdBank"),parent:N(),slot:N(),timestamp:N()}),de({type:Lt("frozen"),slot:N(),timestamp:N(),stats:de({numTransactionEntries:N(),numSuccessfulTransactions:N(),numFailedTransactions:N(),maxTransactionsPerEntry:N()})}),de({type:Lt("dead"),slot:N(),timestamp:N(),err:_e()})]),cu=de({subscription:N(),result:au}),uu=de({subscription:N(),result:Ur(nn([Tc,Oc]))}),lu=de({subscription:N(),result:N()}),fu=de({pubkey:_e(),gossip:Le(_e()),tpu:Le(_e()),rpc:Le(_e()),version:Le(_e())}),qo=de({votePubkey:_e(),nodePubkey:_e(),activatedStake:N(),epochVoteAccount:xn(),epochCredits:Ce(as([N(),N(),N()])),commission:N(),lastVote:N(),rootSlot:Le(N())}),du=nt(de({current:Ce(qo),delinquent:Ce(qo)})),hu=nn([Lt("processed"),Lt("confirmed"),Lt("finalized")]),pu=de({slot:N(),confirmations:Le(N()),err:Fn,confirmationStatus:Qe(hu)}),gu=Ut(Ce(Le(pu))),yu=nt(N()),Fo=de({accountKey:Ht,writableIndexes:Ce(N()),readonlyIndexes:Ce(N())}),Ts=de({signatures:Ce(_e()),message:de({accountKeys:Ce(_e()),header:de({numRequiredSignatures:N(),numReadonlySignedAccounts:N(),numReadonlyUnsignedAccounts:N()}),instructions:Ce(de({accounts:Ce(N()),data:_e(),programIdIndex:N()})),recentBlockhash:_e(),addressTableLookups:Qe(Ce(Fo))})}),Vo=de({pubkey:Ht,signer:xn(),writable:xn(),source:Qe(nn([Lt("transaction"),Lt("lookupTable")]))}),Go=de({accountKeys:Ce(Vo),signatures:Ce(_e())}),jo=de({parsed:$n(),program:_e(),programId:Ht}),$o=de({accounts:Ce(Ht),data:_e(),programId:Ht}),bu=nn([$o,jo]),mu=nn([de({parsed:$n(),program:_e(),programId:_e()}),de({accounts:Ce(_e()),data:_e(),programId:_e()})]),Yo=Kn(bu,mu,r=>"accounts"in r?Ie(r,$o):Ie(r,jo)),Jo=de({signatures:Ce(_e()),message:de({accountKeys:Ce(Vo),instructions:Ce(Yo),recentBlockhash:_e(),addressTableLookups:Qe(Le(Ce(Fo)))})}),zr=de({accountIndex:N(),mint:_e(),owner:Qe(_e()),uiTokenAmount:Bs}),Zo=de({writable:Ce(Ht),readonly:Ce(Ht)}),Kr=de({err:Fn,fee:N(),innerInstructions:Qe(Le(Ce(de({index:N(),instructions:Ce(de({accounts:Ce(N()),data:_e(),programIdIndex:N()}))})))),preBalances:Ce(N()),postBalances:Ce(N()),logMessages:Qe(Le(Ce(_e()))),preTokenBalances:Qe(Le(Ce(zr))),postTokenBalances:Qe(Le(Ce(zr))),loadedAddresses:Qe(Zo),computeUnitsConsumed:Qe(N())}),Os=de({err:Fn,fee:N(),innerInstructions:Qe(Le(Ce(de({index:N(),instructions:Ce(Yo)})))),preBalances:Ce(N()),postBalances:Ce(N()),logMessages:Qe(Le(Ce(_e()))),preTokenBalances:Qe(Le(Ce(zr))),postTokenBalances:Qe(Le(Ce(zr))),loadedAddresses:Qe(Zo),computeUnitsConsumed:Qe(N())}),Qn=nn([Lt(0),Lt("legacy")]),Vn=de({pubkey:_e(),lamports:N(),postBalance:Le(N()),rewardType:Le(_e()),commission:Qe(Le(N()))}),wu=nt(Le(de({blockhash:_e(),previousBlockhash:_e(),parentSlot:N(),transactions:Ce(de({transaction:Ts,meta:Le(Kr),version:Qe(Qn)})),rewards:Qe(Ce(Vn)),blockTime:Le(N()),blockHeight:Le(N())}))),ku=nt(Le(de({blockhash:_e(),previousBlockhash:_e(),parentSlot:N(),rewards:Qe(Ce(Vn)),blockTime:Le(N()),blockHeight:Le(N())}))),Su=nt(Le(de({blockhash:_e(),previousBlockhash:_e(),parentSlot:N(),transactions:Ce(de({transaction:Go,meta:Le(Kr),version:Qe(Qn)})),rewards:Qe(Ce(Vn)),blockTime:Le(N()),blockHeight:Le(N())}))),Eu=nt(Le(de({blockhash:_e(),previousBlockhash:_e(),parentSlot:N(),transactions:Ce(de({transaction:Jo,meta:Le(Os),version:Qe(Qn)})),rewards:Qe(Ce(Vn)),blockTime:Le(N()),blockHeight:Le(N())}))),_u=nt(Le(de({blockhash:_e(),previousBlockhash:_e(),parentSlot:N(),transactions:Ce(de({transaction:Go,meta:Le(Os),version:Qe(Qn)})),rewards:Qe(Ce(Vn)),blockTime:Le(N()),blockHeight:Le(N())}))),xu=nt(Le(de({blockhash:_e(),previousBlockhash:_e(),parentSlot:N(),rewards:Qe(Ce(Vn)),blockTime:Le(N()),blockHeight:Le(N())}))),vu=nt(Le(de({blockhash:_e(),previousBlockhash:_e(),parentSlot:N(),transactions:Ce(de({transaction:Ts,meta:Le(Kr)})),rewards:Qe(Ce(Vn)),blockTime:Le(N())}))),Xo=nt(Le(de({blockhash:_e(),previousBlockhash:_e(),parentSlot:N(),signatures:Ce(_e()),blockTime:Le(N())}))),Ls=nt(Le(de({slot:N(),meta:Le(Kr),blockTime:Qe(Le(N())),transaction:Ts,version:Qe(Qn)}))),Dr=nt(Le(de({slot:N(),transaction:Jo,meta:Le(Os),blockTime:Qe(Le(N())),version:Qe(Qn)}))),Au=Ut(de({blockhash:_e(),feeCalculator:de({lamportsPerSignature:N()})})),Iu=Ut(de({blockhash:_e(),lastValidBlockHeight:N()})),Bu=Ut(xn()),Ru=de({slot:N(),numTransactions:N(),numSlots:N(),samplePeriodSecs:N()}),Pu=nt(Ce(Ru)),Tu=Ut(Le(de({feeCalculator:de({lamportsPerSignature:N()})}))),Ou=nt(_e()),Lu=nt(_e()),Cu=de({err:Fn,logs:Ce(_e()),signature:_e()}),Nu=de({result:Ur(Cu),subscription:N()}),Uu={"solana-client":"js/0.0.0-development"};class zu{constructor(e,t){this._commitment=void 0,this._confirmTransactionInitialTimeout=void 0,this._rpcEndpoint=void 0,this._rpcWsEndpoint=void 0,this._rpcClient=void 0,this._rpcRequest=void 0,this._rpcBatchRequest=void 0,this._rpcWebSocket=void 0,this._rpcWebSocketConnected=!1,this._rpcWebSocketHeartbeat=null,this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketGeneration=0,this._disableBlockhashCaching=!1,this._pollingBlockhash=!1,this._blockhashInfo={latestBlockhash:null,lastFetch:0,transactionSignatures:[],simulatedSignatures:[]},this._nextClientSubscriptionId=0,this._subscriptionDisposeFunctionsByClientSubscriptionId={},this._subscriptionHashByClientSubscriptionId={},this._subscriptionStateChangeCallbacksByHash={},this._subscriptionCallbacksByServerSubscriptionId={},this._subscriptionsByHash={},this._subscriptionsAutoDisposedByRpc=new Set,this.getBlockHeight=(()=>{const d={};return async g=>{var k;const{commitment:w,config:j}=Pt(g),C=this._buildArgs([],w,void 0,j),D=Uo(C);return d[D]=(k=d[D])!=null?k:(async()=>{try{const O=await this._rpcRequest("getBlockHeight",C),q=Ie(O,nt(N()));if("error"in q)throw new He(q.error,"failed to get block height information");return q.result}finally{delete d[D]}})(),await d[D]}})();let n,s,o,i,a,u;t&&typeof t=="string"?this._commitment=t:t&&(this._commitment=t.commitment,this._confirmTransactionInitialTimeout=t.confirmTransactionInitialTimeout,n=t.wsEndpoint,s=t.httpHeaders,o=t.fetch,i=t.fetchMiddleware,a=t.disableRetryOnRateLimit,u=t.httpAgent),this._rpcEndpoint=Ec(e),this._rpcWsEndpoint=n||Sc(e),this._rpcClient=Nc(e,s,o,i,a,u),this._rpcRequest=Uc(this._rpcClient),this._rpcBatchRequest=zc(this._rpcClient),this._rpcWebSocket=new bc(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:s}=Pt(t),o=this._buildArgs([e.toBase58()],n,void 0,s),i=await this._rpcRequest("getBalance",o),a=Ie(i,Ut(N()));if("error"in a)throw new He(a.error,`failed to get balance for ${e.toBase58()}`);return a.result}async getBalance(e,t){return await this.getBalanceAndContext(e,t).then(n=>n.value).catch(n=>{throw new Error("failed to get balance of account "+e.toBase58()+": "+n)})}async getBlockTime(e){const t=await this._rpcRequest("getBlockTime",[e]),n=Ie(t,nt(Le(N())));if("error"in n)throw new He(n.error,`failed to get block time for slot ${e}`);return n.result}async getMinimumLedgerSlot(){const e=await this._rpcRequest("minimumLedgerSlot",[]),t=Ie(e,nt(N()));if("error"in t)throw new He(t.error,"failed to get minimum ledger slot");return t.result}async getFirstAvailableBlock(){const e=await this._rpcRequest("getFirstAvailableBlock",[]),t=Ie(e,Fc);if("error"in t)throw new He(t.error,"failed to get first available block");return t.result}async getSupply(e){let t={};typeof e=="string"?t={commitment:e}:e?t={...e,commitment:e&&e.commitment||this.commitment}:t={commitment:this.commitment};const n=await this._rpcRequest("getSupply",[t]),s=Ie(n,Vc);if("error"in s)throw new He(s.error,"failed to get supply");return s.result}async getTokenSupply(e,t){const n=this._buildArgs([e.toBase58()],t),s=await this._rpcRequest("getTokenSupply",n),o=Ie(s,Ut(Bs));if("error"in o)throw new He(o.error,"failed to get token supply");return o.result}async getTokenAccountBalance(e,t){const n=this._buildArgs([e.toBase58()],t),s=await this._rpcRequest("getTokenAccountBalance",n),o=Ie(s,Ut(Bs));if("error"in o)throw new He(o.error,"failed to get token account balance");return o.result}async getTokenAccountsByOwner(e,t,n){const{commitment:s,config:o}=Pt(n);let i=[e.toBase58()];"mint"in t?i.push({mint:t.mint.toBase58()}):i.push({programId:t.programId.toBase58()});const a=this._buildArgs(i,s,"base64",o),u=await this._rpcRequest("getTokenAccountsByOwner",a),d=Ie(u,jc);if("error"in d)throw new He(d.error,`failed to get token accounts owned by account ${e.toBase58()}`);return d.result}async getParsedTokenAccountsByOwner(e,t,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,n,"jsonParsed"),i=await this._rpcRequest("getTokenAccountsByOwner",o),a=Ie(i,$c);if("error"in a)throw new He(a.error,`failed to get token accounts owned by account ${e.toBase58()}`);return a.result}async getLargestAccounts(e){const t={...e,commitment:e&&e.commitment||this.commitment},n=t.filter||t.commitment?[t]:[],s=await this._rpcRequest("getLargestAccounts",n),o=Ie(s,Yc);if("error"in o)throw new He(o.error,"failed to get largest accounts");return o.result}async getTokenLargestAccounts(e,t){const n=this._buildArgs([e.toBase58()],t),s=await this._rpcRequest("getTokenLargestAccounts",n),o=Ie(s,Gc);if("error"in o)throw new He(o.error,"failed to get token largest accounts");return o.result}async getAccountInfoAndContext(e,t){const{commitment:n,config:s}=Pt(t),o=this._buildArgs([e.toBase58()],n,"base64",s),i=await this._rpcRequest("getAccountInfo",o),a=Ie(i,Ut(Le(hr)));if("error"in a)throw new He(a.error,`failed to get info about account ${e.toBase58()}`);return a.result}async getParsedAccountInfo(e,t){const{commitment:n,config:s}=Pt(t),o=this._buildArgs([e.toBase58()],n,"jsonParsed",s),i=await this._rpcRequest("getAccountInfo",o),a=Ie(i,Ut(Le(Ps)));if("error"in a)throw new He(a.error,`failed to get info about account ${e.toBase58()}`);return a.result}async getAccountInfo(e,t){try{return(await this.getAccountInfoAndContext(e,t)).value}catch(n){throw new Error("failed to get info about account "+e.toBase58()+": "+n)}}async getMultipleParsedAccounts(e,t){const{commitment:n,config:s}=Pt(t),o=e.map(d=>d.toBase58()),i=this._buildArgs([o],n,"jsonParsed",s),a=await this._rpcRequest("getMultipleAccounts",i),u=Ie(a,Ut(Ce(Le(Ps))));if("error"in u)throw new He(u.error,`failed to get info for accounts ${o}`);return u.result}async getMultipleAccountsInfoAndContext(e,t){const{commitment:n,config:s}=Pt(t),o=e.map(d=>d.toBase58()),i=this._buildArgs([o],n,"base64",s),a=await this._rpcRequest("getMultipleAccounts",i),u=Ie(a,Ut(Ce(Le(hr))));if("error"in u)throw new He(u.error,`failed to get info for accounts ${o}`);return u.result}async getMultipleAccountsInfo(e,t){return(await this.getMultipleAccountsInfoAndContext(e,t)).value}async getStakeActivation(e,t,n){const{commitment:s,config:o}=Pt(t),i=this._buildArgs([e.toBase58()],s,void 0,{...o,epoch:n!=null?n:o==null?void 0:o.epoch}),a=await this._rpcRequest("getStakeActivation",i),u=Ie(a,nt(Qc));if("error"in u)throw new He(u.error,`failed to get Stake Activation ${e.toBase58()}`);return u.result}async getProgramAccounts(e,t){const{commitment:n,config:s}=Pt(t),{encoding:o,...i}=s||{},a=this._buildArgs([e.toBase58()],n,o||"base64",i),u=await this._rpcRequest("getProgramAccounts",a),d=Ce(Jc),g=i.withContext===!0?Ie(u,Ut(d)):Ie(u,nt(d));if("error"in g)throw new He(g.error,`failed to get accounts owned by program ${e.toBase58()}`);return g.result}async getParsedProgramAccounts(e,t){const{commitment:n,config:s}=Pt(t),o=this._buildArgs([e.toBase58()],n,"jsonParsed",s),i=await this._rpcRequest("getProgramAccounts",o),a=Ie(i,nt(Ce(Xc)));if("error"in a)throw new He(a.error,`failed to get accounts owned by program ${e.toBase58()}`);return a.result}async confirmTransaction(e,t){var o;let n;if(typeof e=="string")n=e;else{const i=e;if((o=i.abortSignal)!=null&&o.aborted)return Promise.reject(i.abortSignal.reason);n=i.signature}let s;try{s=Yt().decode(n)}catch{throw new Error("signature must be base58 encoded: "+n)}return yt(s.length===64,"signature has invalid length"),typeof e=="string"?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)=>{e!=null&&(e.aborted?n(e.reason):e.addEventListener("abort",()=>{n(e.reason)}))})}getTransactionConfirmationPromise({commitment:e,signature:t}){let n,s,o=!1;const i=new Promise((u,d)=>{try{n=this.onSignature(t,(w,j)=>{n=void 0;const C={context:j,value:w};u({__type:In.PROCESSED,response:C})},e);const g=new Promise(w=>{n==null?w():s=this._onSubscriptionStateChange(n,j=>{j==="subscribed"&&w()})});(async()=>{if(await g,o)return;const w=await this.getSignatureStatus(t);if(o||w==null)return;const{context:j,value:C}=w;if(C!=null)if(C!=null&&C.err)d(C.err);else{switch(e){case"confirmed":case"single":case"singleGossip":{if(C.confirmationStatus==="processed")return;break}case"finalized":case"max":case"root":{if(C.confirmationStatus==="processed"||C.confirmationStatus==="confirmed")return;break}case"processed":case"recent":}o=!0,u({__type:In.PROCESSED,response:{context:j,value:C}})}})()}catch(g){d(g)}});return{abortConfirmation:()=>{s&&(s(),s=void 0),n!=null&&(this.removeSignatureListener(n),n=void 0)},confirmationPromise:i}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:e,strategy:{abortSignal:t,lastValidBlockHeight:n,signature:s}}){let o=!1;const i=new Promise(w=>{const j=async()=>{try{return await this.getBlockHeight(e)}catch{return-1}};(async()=>{let C=await j();if(!o){for(;C<=n;)if(await Hn(1e3),o||(C=await j(),o))return;w({__type:In.BLOCKHEIGHT_EXCEEDED})}})()}),{abortConfirmation:a,confirmationPromise:u}=this.getTransactionConfirmationPromise({commitment:e,signature:s}),d=this.getCancellationPromise(t);let g;try{const w=await Promise.race([d,u,i]);if(w.__type===In.PROCESSED)g=w.response;else throw new ys(s)}finally{o=!0,a()}return g}async confirmTransactionUsingDurableNonceStrategy({commitment:e,strategy:{abortSignal:t,minContextSlot:n,nonceAccountPubkey:s,nonceValue:o,signature:i}}){var C;let a=!1;const u=new Promise(D=>{let k=o,O=null;const q=async()=>{try{const{context:fe,value:he}=await this.getNonceAndContext(s,{commitment:e,minContextSlot:n});return O=fe.slot,he==null?void 0:he.nonce}catch{return k}};(async()=>{if(k=await q(),!a)for(;;){if(o!==k){D({__type:In.NONCE_INVALID,slotInWhichNonceDidAdvance:O});return}if(await Hn(2e3),a||(k=await q(),a))return}})()}),{abortConfirmation:d,confirmationPromise:g}=this.getTransactionConfirmationPromise({commitment:e,signature:i}),w=this.getCancellationPromise(t);let j;try{const D=await Promise.race([w,g,u]);if(D.__type===In.PROCESSED)j=D.response;else{let k;for(;;){const O=await this.getSignatureStatus(i);if(O==null)break;if(O.context.slot<((C=D.slotInWhichNonceDidAdvance)!=null?C:n)){await Hn(400);continue}k=O;break}if(k!=null&&k.value){const O=e||"finalized",{confirmationStatus:q}=k.value;switch(O){case"processed":case"recent":if(q!=="processed"&&q!=="confirmed"&&q!=="finalized")throw new Jn(i);break;case"confirmed":case"single":case"singleGossip":if(q!=="confirmed"&&q!=="finalized")throw new Jn(i);break;case"finalized":case"max":case"root":if(q!=="finalized")throw new Jn(i);break;default:(fe=>{})(O)}j={context:k.context,value:{err:k.value.err}}}else throw new Jn(i)}}finally{a=!0,d()}return j}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:e,signature:t}){let n;const s=new Promise(u=>{let d=this._confirmTransactionInitialTimeout||6e4;switch(e){case"processed":case"recent":case"single":case"confirmed":case"singleGossip":{d=this._confirmTransactionInitialTimeout||3e4;break}}n=setTimeout(()=>u({__type:In.TIMED_OUT,timeoutMs:d}),d)}),{abortConfirmation:o,confirmationPromise:i}=this.getTransactionConfirmationPromise({commitment:e,signature:t});let a;try{const u=await Promise.race([i,s]);if(u.__type===In.PROCESSED)a=u.response;else throw new bs(t,u.timeoutMs/1e3)}finally{clearTimeout(n),o()}return a}async getClusterNodes(){const e=await this._rpcRequest("getClusterNodes",[]),t=Ie(e,nt(Ce(fu)));if("error"in t)throw new He(t.error,"failed to get cluster nodes");return t.result}async getVoteAccounts(e){const t=this._buildArgs([],e),n=await this._rpcRequest("getVoteAccounts",t),s=Ie(n,du);if("error"in s)throw new He(s.error,"failed to get vote accounts");return s.result}async getSlot(e){const{commitment:t,config:n}=Pt(e),s=this._buildArgs([],t,void 0,n),o=await this._rpcRequest("getSlot",s),i=Ie(o,nt(N()));if("error"in i)throw new He(i.error,"failed to get slot");return i.result}async getSlotLeader(e){const{commitment:t,config:n}=Pt(e),s=this._buildArgs([],t,void 0,n),o=await this._rpcRequest("getSlotLeader",s),i=Ie(o,nt(_e()));if("error"in i)throw new He(i.error,"failed to get slot leader");return i.result}async getSlotLeaders(e,t){const n=[e,t],s=await this._rpcRequest("getSlotLeaders",n),o=Ie(s,nt(Ce(Ht)));if("error"in o)throw new He(o.error,"failed to get slot leaders");return o.result}async getSignatureStatus(e,t){const{context:n,value:s}=await this.getSignatureStatuses([e],t);yt(s.length===1);const o=s[0];return{context:n,value:o}}async getSignatureStatuses(e,t){const n=[e];t&&n.push(t);const s=await this._rpcRequest("getSignatureStatuses",n),o=Ie(s,gu);if("error"in o)throw new He(o.error,"failed to get signature status");return o.result}async getTransactionCount(e){const{commitment:t,config:n}=Pt(e),s=this._buildArgs([],t,void 0,n),o=await this._rpcRequest("getTransactionCount",s),i=Ie(o,nt(N()));if("error"in i)throw new He(i.error,"failed to get transaction count");return i.result}async getTotalSupply(e){return(await this.getSupply({commitment:e,excludeNonCirculatingAccountsList:!0})).value.total}async getInflationGovernor(e){const t=this._buildArgs([],e),n=await this._rpcRequest("getInflationGovernor",t),s=Ie(n,Kc);if("error"in s)throw new He(s.error,"failed to get inflation");return s.result}async getInflationReward(e,t,n){const{commitment:s,config:o}=Pt(n),i=this._buildArgs([e.map(d=>d.toBase58())],s,void 0,{...o,epoch:t!=null?t:o==null?void 0:o.epoch}),a=await this._rpcRequest("getInflationReward",i),u=Ie(a,vc);if("error"in u)throw new He(u.error,"failed to get inflation reward");return u.result}async getInflationRate(){const e=await this._rpcRequest("getInflationRate",[]),t=Ie(e,Dc);if("error"in t)throw new He(t.error,"failed to get inflation rate");return t.result}async getEpochInfo(e){const{commitment:t,config:n}=Pt(e),s=this._buildArgs([],t,void 0,n),o=await this._rpcRequest("getEpochInfo",s),i=Ie(o,Wc);if("error"in i)throw new He(i.error,"failed to get epoch info");return i.result}async getEpochSchedule(){const e=await this._rpcRequest("getEpochSchedule",[]),t=Ie(e,Hc);if("error"in t)throw new He(t.error,"failed to get epoch schedule");const n=t.result;return new zo(n.slotsPerEpoch,n.leaderScheduleSlotOffset,n.warmup,n.firstNormalEpoch,n.firstNormalSlot)}async getLeaderSchedule(){const e=await this._rpcRequest("getLeaderSchedule",[]),t=Ie(e,qc);if("error"in t)throw new He(t.error,"failed to get leader schedule");return t.result}async getMinimumBalanceForRentExemption(e,t){const n=this._buildArgs([e],t),s=await this._rpcRequest("getMinimumBalanceForRentExemption",n),o=Ie(s,yu);return"error"in o?(console.warn("Unable to fetch minimum balance for rent exemption"),0):o.result}async getRecentBlockhashAndContext(e){const t=this._buildArgs([],e),n=await this._rpcRequest("getRecentBlockhash",t),s=Ie(n,Au);if("error"in s)throw new He(s.error,"failed to get recent blockhash");return s.result}async getRecentPerformanceSamples(e){const t=await this._rpcRequest("getRecentPerformanceSamples",e?[e]:[]),n=Ie(t,Pu);if("error"in n)throw new He(n.error,"failed to get recent performance samples");return n.result}async getFeeCalculatorForBlockhash(e,t){const n=this._buildArgs([e],t),s=await this._rpcRequest("getFeeCalculatorForBlockhash",n),o=Ie(s,Tu);if("error"in o)throw new He(o.error,"failed to get fee calculator");const{context:i,value:a}=o.result;return{context:i,value:a!==null?a.feeCalculator:null}}async getFeeForMessage(e,t){const n=tt(e.serialize()).toString("base64"),s=this._buildArgs([n],t),o=await this._rpcRequest("getFeeForMessage",s),i=Ie(o,Ut(Le(N())));if("error"in i)throw new He(i.error,"failed to get fee for message");if(i.result===null)throw new Error("invalid blockhash");return i.result}async getRecentPrioritizationFees(e){var i;const t=(i=e==null?void 0:e.lockedWritableAccounts)==null?void 0:i.map(a=>a.toBase58()),n=t!=null&&t.length?[t]:[],s=await this._rpcRequest("getRecentPrioritizationFees",n),o=Ie(s,Mc);if("error"in o)throw new He(o.error,"failed to get recent prioritization fees");return o.result}async getRecentBlockhash(e){try{return(await this.getRecentBlockhashAndContext(e)).value}catch(t){throw new Error("failed to get recent blockhash: "+t)}}async getLatestBlockhash(e){try{return(await this.getLatestBlockhashAndContext(e)).value}catch(t){throw new Error("failed to get recent blockhash: "+t)}}async getLatestBlockhashAndContext(e){const{commitment:t,config:n}=Pt(e),s=this._buildArgs([],t,void 0,n),o=await this._rpcRequest("getLatestBlockhash",s),i=Ie(o,Iu);if("error"in i)throw new He(i.error,"failed to get latest blockhash");return i.result}async isBlockhashValid(e,t){const{commitment:n,config:s}=Pt(t),o=this._buildArgs([e],n,void 0,s),i=await this._rpcRequest("isBlockhashValid",o),a=Ie(i,Bu);if("error"in a)throw new He(a.error,"failed to determine if the blockhash `"+e+"`is valid");return a.result}async getVersion(){const e=await this._rpcRequest("getVersion",[]),t=Ie(e,nt(Lc));if("error"in t)throw new He(t.error,"failed to get version");return t.result}async getGenesisHash(){const e=await this._rpcRequest("getGenesisHash",[]),t=Ie(e,nt(_e()));if("error"in t)throw new He(t.error,"failed to get genesis hash");return t.result}async getBlock(e,t){const{commitment:n,config:s}=Pt(t),o=this._buildArgsAtLeastConfirmed([e],n,void 0,s),i=await this._rpcRequest("getBlock",o);try{switch(s==null?void 0:s.transactionDetails){case"accounts":{const a=Ie(i,Su);if("error"in a)throw a.error;return a.result}case"none":{const a=Ie(i,ku);if("error"in a)throw a.error;return a.result}default:{const a=Ie(i,wu);if("error"in a)throw a.error;const{result:u}=a;return u?{...u,transactions:u.transactions.map(({transaction:d,meta:g,version:w})=>({meta:g,transaction:{...d,message:Is(w,d.message)},version:w}))}:null}}}catch(a){throw new He(a,"failed to get confirmed block")}}async getParsedBlock(e,t){const{commitment:n,config:s}=Pt(t),o=this._buildArgsAtLeastConfirmed([e],n,"jsonParsed",s),i=await this._rpcRequest("getBlock",o);try{switch(s==null?void 0:s.transactionDetails){case"accounts":{const a=Ie(i,_u);if("error"in a)throw a.error;return a.result}case"none":{const a=Ie(i,xu);if("error"in a)throw a.error;return a.result}default:{const a=Ie(i,Eu);if("error"in a)throw a.error;return a.result}}}catch(a){throw new He(a,"failed to get block")}}async getBlockProduction(e){let t,n;if(typeof e=="string")n=e;else if(e){const{commitment:a,...u}=e;n=a,t=u}const s=this._buildArgs([],n,"base64",t),o=await this._rpcRequest("getBlockProduction",s),i=Ie(o,Cc);if("error"in i)throw new He(i.error,"failed to get block production information");return i.result}async getTransaction(e,t){const{commitment:n,config:s}=Pt(t),o=this._buildArgsAtLeastConfirmed([e],n,void 0,s),i=await this._rpcRequest("getTransaction",o),a=Ie(i,Ls);if("error"in a)throw new He(a.error,"failed to get transaction");const u=a.result;return u&&{...u,transaction:{...u.transaction,message:Is(u.version,u.transaction.message)}}}async getParsedTransaction(e,t){const{commitment:n,config:s}=Pt(t),o=this._buildArgsAtLeastConfirmed([e],n,"jsonParsed",s),i=await this._rpcRequest("getTransaction",o),a=Ie(i,Dr);if("error"in a)throw new He(a.error,"failed to get transaction");return a.result}async getParsedTransactions(e,t){const{commitment:n,config:s}=Pt(t),o=e.map(u=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([u],n,"jsonParsed",s)}));return(await this._rpcBatchRequest(o)).map(u=>{const d=Ie(u,Dr);if("error"in d)throw new He(d.error,"failed to get transactions");return d.result})}async getTransactions(e,t){const{commitment:n,config:s}=Pt(t),o=e.map(u=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([u],n,void 0,s)}));return(await this._rpcBatchRequest(o)).map(u=>{const d=Ie(u,Ls);if("error"in d)throw new He(d.error,"failed to get transactions");const g=d.result;return g&&{...g,transaction:{...g.transaction,message:Is(g.version,g.transaction.message)}}})}async getConfirmedBlock(e,t){const n=this._buildArgsAtLeastConfirmed([e],t),s=await this._rpcRequest("getConfirmedBlock",n),o=Ie(s,vu);if("error"in o)throw new He(o.error,"failed to get confirmed block");const i=o.result;if(!i)throw new Error("Confirmed block "+e+" not found");const a={...i,transactions:i.transactions.map(({transaction:u,meta:d})=>{const g=new gn(u.message);return{meta:d,transaction:{...u,message:g}}})};return{...a,transactions:a.transactions.map(({transaction:u,meta:d})=>({meta:d,transaction:wt.populate(u.message,u.signatures)}))}}async getBlocks(e,t,n){const s=this._buildArgsAtLeastConfirmed(t!==void 0?[e,t]:[e],n),o=await this._rpcRequest("getBlocks",s),i=Ie(o,nt(Ce(N())));if("error"in i)throw new He(i.error,"failed to get blocks");return i.result}async getBlockSignatures(e,t){const n=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:"signatures",rewards:!1}),s=await this._rpcRequest("getBlock",n),o=Ie(s,Xo);if("error"in o)throw new He(o.error,"failed to get block");const i=o.result;if(!i)throw new Error("Block "+e+" not found");return i}async getConfirmedBlockSignatures(e,t){const n=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:"signatures",rewards:!1}),s=await this._rpcRequest("getConfirmedBlock",n),o=Ie(s,Xo);if("error"in o)throw new He(o.error,"failed to get confirmed block");const i=o.result;if(!i)throw new Error("Confirmed block "+e+" not found");return i}async getConfirmedTransaction(e,t){const n=this._buildArgsAtLeastConfirmed([e],t),s=await this._rpcRequest("getConfirmedTransaction",n),o=Ie(s,Ls);if("error"in o)throw new He(o.error,"failed to get transaction");const i=o.result;if(!i)return i;const a=new gn(i.transaction.message),u=i.transaction.signatures;return{...i,transaction:wt.populate(a,u)}}async getParsedConfirmedTransaction(e,t){const n=this._buildArgsAtLeastConfirmed([e],t,"jsonParsed"),s=await this._rpcRequest("getConfirmedTransaction",n),o=Ie(s,Dr);if("error"in o)throw new He(o.error,"failed to get confirmed transaction");return o.result}async getParsedConfirmedTransactions(e,t){const n=e.map(i=>({methodName:"getConfirmedTransaction",args:this._buildArgsAtLeastConfirmed([i],t,"jsonParsed")}));return(await this._rpcBatchRequest(n)).map(i=>{const a=Ie(i,Dr);if("error"in a)throw new He(a.error,"failed to get confirmed transactions");return a.result})}async getConfirmedSignaturesForAddress(e,t,n){let s={},o=await this.getFirstAvailableBlock();for(;!("until"in s)&&(t--,!(t<=0||t<o));)try{const u=await this.getConfirmedBlockSignatures(t,"finalized");u.signatures.length>0&&(s.until=u.signatures[u.signatures.length-1].toString())}catch(u){if(u instanceof Error&&u.message.includes("skipped"))continue;throw u}let i=await this.getSlot("finalized");for(;!("before"in s)&&(n++,!(n>i));)try{const u=await this.getConfirmedBlockSignatures(n);u.signatures.length>0&&(s.before=u.signatures[u.signatures.length-1].toString())}catch(u){if(u instanceof Error&&u.message.includes("skipped"))continue;throw u}return(await this.getConfirmedSignaturesForAddress2(e,s)).map(u=>u.signature)}async getConfirmedSignaturesForAddress2(e,t,n){const s=this._buildArgsAtLeastConfirmed([e.toBase58()],n,void 0,t),o=await this._rpcRequest("getConfirmedSignaturesForAddress2",s),i=Ie(o,eu);if("error"in i)throw new He(i.error,"failed to get confirmed signatures for address");return i.result}async getSignaturesForAddress(e,t,n){const s=this._buildArgsAtLeastConfirmed([e.toBase58()],n,void 0,t),o=await this._rpcRequest("getSignaturesForAddress",s),i=Ie(o,tu);if("error"in i)throw new He(i.error,"failed to get signatures for address");return i.result}async getAddressLookupTable(e,t){const{context:n,value:s}=await this.getAccountInfoAndContext(e,t);let o=null;return s!==null&&(o=new vs({key:e,state:vs.deserialize(s.data)})),{context:n,value:o}}async getNonceAndContext(e,t){const{context:n,value:s}=await this.getAccountInfoAndContext(e,t);let o=null;return s!==null&&(o=Nr.fromAccountData(s.data)),{context:n,value:o}}async getNonce(e,t){return await this.getNonceAndContext(e,t).then(n=>n.value).catch(n=>{throw new Error("failed to get nonce for account "+e.toBase58()+": "+n)})}async requestAirdrop(e,t){const n=await this._rpcRequest("requestAirdrop",[e.toBase58(),t]),s=Ie(n,Ou);if("error"in s)throw new He(s.error,`airdrop to ${e.toBase58()} failed`);return s.result}async _blockhashWithExpiryBlockHeight(e){if(!e){for(;this._pollingBlockhash;)await Hn(100);const n=Date.now()-this._blockhashInfo.lastFetch>=Mo;if(this._blockhashInfo.latestBlockhash!==null&&!n)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 s=0;s<50;s++){const o=await this.getLatestBlockhash("finalized");if(n!==o.blockhash)return this._blockhashInfo={latestBlockhash:o,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},o;await Hn(Lo/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}=Pt(e),s=this._buildArgs([],t,"base64",n),o=await this._rpcRequest("getStakeMinimumDelegation",s),i=Ie(o,Ut(N()));if("error"in i)throw new He(i.error,"failed to get stake minimum delegation");return i.result}async simulateTransaction(e,t,n){if("message"in e){const k=e.serialize(),O=P.Buffer.from(k).toString("base64");if(Array.isArray(t)||n!==void 0)throw new Error("Invalid arguments");const q=t||{};q.encoding="base64","commitment"in q||(q.commitment=this.commitment);const fe=[O,q],he=await this._rpcRequest("simulateTransaction",fe),Oe=Ie(he,Ho);if("error"in Oe)throw new Error("failed to simulate transaction: "+Oe.error.message);return Oe.result}let s;if(e instanceof wt){let D=e;s=new wt,s.feePayer=D.feePayer,s.instructions=e.instructions,s.nonceInfo=D.nonceInfo,s.signatures=D.signatures}else s=wt.populate(e),s._message=s._json=void 0;if(t!==void 0&&!Array.isArray(t))throw new Error("Invalid arguments");const o=t;if(s.nonceInfo&&o)s.sign(...o);else{let D=this._disableBlockhashCaching;for(;;){const k=await this._blockhashWithExpiryBlockHeight(D);if(s.lastValidBlockHeight=k.lastValidBlockHeight,s.recentBlockhash=k.blockhash,!o)break;if(s.sign(...o),!s.signature)throw new Error("!signature");const O=s.signature.toString("base64");if(!this._blockhashInfo.simulatedSignatures.includes(O)&&!this._blockhashInfo.transactionSignatures.includes(O)){this._blockhashInfo.simulatedSignatures.push(O);break}else D=!0}}const i=s._compile(),a=i.serialize(),d=s._serialize(a).toString("base64"),g={encoding:"base64",commitment:this.commitment};if(n){const D=(Array.isArray(n)?n:i.nonProgramIds()).map(k=>k.toBase58());g.accounts={encoding:"base64",addresses:D}}o&&(g.sigVerify=!0);const w=[d,g],j=await this._rpcRequest("simulateTransaction",w),C=Ie(j,Ho);if("error"in C){let D;if("data"in C.error&&(D=C.error.data.logs,D&&Array.isArray(D))){const k=`
109
- `,O=k+D.join(k);console.error(C.error.message,O)}throw new xs("failed to simulate transaction: "+C.error.message,D)}return C.result}async sendTransaction(e,t,n){if("version"in e){if(t&&Array.isArray(t))throw new Error("Invalid arguments");const i=e.serialize();return await this.sendRawTransaction(i,t)}if(t===void 0||!Array.isArray(t))throw new Error("Invalid arguments");const s=t;if(e.nonceInfo)e.sign(...s);else{let i=this._disableBlockhashCaching;for(;;){const a=await this._blockhashWithExpiryBlockHeight(i);if(e.lastValidBlockHeight=a.lastValidBlockHeight,e.recentBlockhash=a.blockhash,e.sign(...s),!e.signature)throw new Error("!signature");const u=e.signature.toString("base64");if(this._blockhashInfo.transactionSignatures.includes(u))i=!0;else{this._blockhashInfo.transactionSignatures.push(u);break}}}const o=e.serialize();return await this.sendRawTransaction(o,n)}async sendRawTransaction(e,t){const n=tt(e).toString("base64");return await this.sendEncodedTransaction(n,t)}async sendEncodedTransaction(e,t){const n={encoding:"base64"},s=t&&t.skipPreflight,o=t&&t.preflightCommitment||this.commitment;t&&t.maxRetries!=null&&(n.maxRetries=t.maxRetries),t&&t.minContextSlot!=null&&(n.minContextSlot=t.minContextSlot),s&&(n.skipPreflight=s),o&&(n.preflightCommitment=o);const i=[e,n],a=await this._rpcRequest("sendTransaction",i),u=Ie(a,Lu);if("error"in u){let d;throw"data"in u.error&&(d=u.error.data.logs),new xs("failed to send transaction: "+u.error.message,d)}return u.result}_wsOnOpen(){this._rpcWebSocketConnected=!0,this._rpcWebSocketHeartbeat=setInterval(()=>{(async()=>{try{await this._rpcWebSocket.notify("ping")}catch{}})()},5e3),this._updateSubscriptions()}_wsOnError(e){this._rpcWebSocketConnected=!1,console.error("ws error:",e.message)}_wsOnClose(e){if(this._rpcWebSocketConnected=!1,this._rpcWebSocketGeneration=(this._rpcWebSocketGeneration+1)%Number.MAX_SAFE_INTEGER,this._rpcWebSocketIdleTimeout&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null),this._rpcWebSocketHeartbeat&&(clearInterval(this._rpcWebSocketHeartbeat),this._rpcWebSocketHeartbeat=null),e===1e3){this._updateSubscriptions();return}this._subscriptionCallbacksByServerSubscriptionId={},Object.entries(this._subscriptionsByHash).forEach(([t,n])=>{this._setSubscription(t,{...n,state:"pending"})})}_setSubscription(e,t){var s;const n=(s=this._subscriptionsByHash[e])==null?void 0:s.state;if(this._subscriptionsByHash[e]=t,n!==t.state){const o=this._subscriptionStateChangeCallbacksByHash[e];o&&o.forEach(i=>{try{i(t.state)}catch{}})}}_onSubscriptionStateChange(e,t){var o;const n=this._subscriptionHashByClientSubscriptionId[e];if(n==null)return()=>{};const s=(o=this._subscriptionStateChangeCallbacksByHash)[n]||(o[n]=new Set);return s.add(t),()=>{s.delete(t),s.size===0&&delete this._subscriptionStateChangeCallbacksByHash[n]}}async _updateSubscriptions(){if(Object.keys(this._subscriptionsByHash).length===0){this._rpcWebSocketConnected&&(this._rpcWebSocketConnected=!1,this._rpcWebSocketIdleTimeout=setTimeout(()=>{this._rpcWebSocketIdleTimeout=null;try{this._rpcWebSocket.close()}catch(n){n instanceof Error&&console.log(`Error when closing socket connection: ${n.message}`)}},500));return}if(this._rpcWebSocketIdleTimeout!==null&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketConnected=!0),!this._rpcWebSocketConnected){this._rpcWebSocket.connect();return}const e=this._rpcWebSocketGeneration,t=()=>e===this._rpcWebSocketGeneration;await Promise.all(Object.keys(this._subscriptionsByHash).map(async n=>{const s=this._subscriptionsByHash[n];if(s!==void 0)switch(s.state){case"pending":case"unsubscribed":if(s.callbacks.size===0){delete this._subscriptionsByHash[n],s.state==="unsubscribed"&&delete this._subscriptionCallbacksByServerSubscriptionId[s.serverSubscriptionId],await this._updateSubscriptions();return}await(async()=>{const{args:o,method:i}=s;try{this._setSubscription(n,{...s,state:"subscribing"});const a=await this._rpcWebSocket.call(i,o);this._setSubscription(n,{...s,serverSubscriptionId:a,state:"subscribed"}),this._subscriptionCallbacksByServerSubscriptionId[a]=s.callbacks,await this._updateSubscriptions()}catch(a){if(a instanceof Error&&console.error(`${i} error for argument`,o,a.message),!t())return;this._setSubscription(n,{...s,state:"pending"}),await this._updateSubscriptions()}})();break;case"subscribed":s.callbacks.size===0&&await(async()=>{const{serverSubscriptionId:o,unsubscribeMethod:i}=s;if(this._subscriptionsAutoDisposedByRpc.has(o))this._subscriptionsAutoDisposedByRpc.delete(o);else{this._setSubscription(n,{...s,state:"unsubscribing"}),this._setSubscription(n,{...s,state:"unsubscribing"});try{await this._rpcWebSocket.call(i,[o])}catch(a){if(a instanceof Error&&console.error(`${i} error:`,a.message),!t())return;this._setSubscription(n,{...s,state:"subscribed"}),await this._updateSubscriptions();return}}this._setSubscription(n,{...s,state:"unsubscribed"}),await this._updateSubscriptions()})();break}}))}_handleServerNotification(e,t){const n=this._subscriptionCallbacksByServerSubscriptionId[e];n!==void 0&&n.forEach(s=>{try{s(...t)}catch(o){console.error(o)}})}_wsOnAccountNotification(e){const{result:t,subscription:n}=Ie(e,nu);this._handleServerNotification(n,[t.value,t.context])}_makeSubscription(e,t){const n=this._nextClientSubscriptionId++,s=Uo([e.method,t],!0),o=this._subscriptionsByHash[s];return o===void 0?this._subscriptionsByHash[s]={...e,args:t,callbacks:new Set([e.callback]),state:"pending"}:o.callbacks.add(e.callback),this._subscriptionHashByClientSubscriptionId[n]=s,this._subscriptionDisposeFunctionsByClientSubscriptionId[n]=async()=>{delete this._subscriptionDisposeFunctionsByClientSubscriptionId[n],delete this._subscriptionHashByClientSubscriptionId[n];const i=this._subscriptionsByHash[s];yt(i!==void 0,`Could not find a \`Subscription\` when tearing down client subscription #${n}`),i.callbacks.delete(e.callback),await this._updateSubscriptions()},this._updateSubscriptions(),n}onAccountChange(e,t,n){const s=this._buildArgs([e.toBase58()],n||this._commitment||"finalized","base64");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}=Ie(e,su);this._handleServerNotification(n,[{accountId:t.value.pubkey,accountInfo:t.value.account},t.context])}onProgramAccountChange(e,t,n,s){const o=this._buildArgs([e.toBase58()],n||this._commitment||"finalized","base64",s?{filters:s}: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 s=this._buildArgs([typeof e=="object"?{mentions:[e.toString()]}:e],n||this._commitment||"finalized");return this._makeSubscription({callback:t,method:"logsSubscribe",unsubscribeMethod:"logsUnsubscribe"},s)}async removeOnLogsListener(e){await this._unsubscribeClientSubscription(e,"logs")}_wsOnLogsNotification(e){const{result:t,subscription:n}=Ie(e,Nu);this._handleServerNotification(n,[t.value,t.context])}_wsOnSlotNotification(e){const{result:t,subscription:n}=Ie(e,iu);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}=Ie(e,cu);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,s){const o=t||this._commitment;if(o||n||s){let i={};n&&(i.encoding=n),o&&(i.commitment=o),s&&(i=Object.assign(i,s)),e.push(i)}return e}_buildArgsAtLeastConfirmed(e,t,n,s){const o=t||this._commitment;if(o&&!["confirmed","finalized"].includes(o))throw new Error("Using Connection with default commitment: `"+this._commitment+"`, but method requires at least `confirmed`");return this._buildArgs(e,t,n,s)}_wsOnSignatureNotification(e){const{result:t,subscription:n}=Ie(e,uu);t.value!=="receivedSignature"&&this._subscriptionsAutoDisposedByRpc.add(n),this._handleServerNotification(n,t.value==="receivedSignature"?[{type:"received"},t.context]:[{type:"status",result:t.value},t.context])}onSignature(e,t,n){const s=this._buildArgs([e],n||this._commitment||"finalized"),o=this._makeSubscription({callback:(i,a)=>{if(i.type==="status"){t(i.result,a);try{this.removeSignatureListener(o)}catch{}}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},s);return o}onSignatureWithOptions(e,t,n){const{commitment:s,...o}={...n,commitment:n&&n.commitment||this._commitment||"finalized"},i=this._buildArgs([e],s,void 0,o),a=this._makeSubscription({callback:(u,d)=>{t(u,d);try{this.removeSignatureListener(a)}catch{}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},i);return a}async removeSignatureListener(e){await this._unsubscribeClientSubscription(e,"signature result")}_wsOnRootNotification(e){const{result:t,subscription:n}=Ie(e,lu);this._handleServerNotification(n,[t])}onRootChange(e){return this._makeSubscription({callback:e,method:"rootSubscribe",unsubscribeMethod:"rootUnsubscribe"},[])}async removeRootChangeListener(e){await this._unsubscribeClientSubscription(e,"root change")}}class er{constructor(e){this._keypair=void 0,this._keypair=e!=null?e:Ao()}static generate(){return new er(Ao())}static fromSecretKey(e,t){if(e.byteLength!==64)throw new Error("bad secret key size");const n=e.slice(32,64);if(!t||!t.skipValidation){const s=e.slice(0,32),o=Pr(s);for(let i=0;i<32;i++)if(n[i]!==o[i])throw new Error("provided secretKey is invalid")}return new er({publicKey:n,secretKey:e})}static fromSeed(e){const t=Pr(e),n=new Uint8Array(64);return n.set(e),n.set(t,32),new er({publicKey:t,secretKey:n})}get publicKey(){return new ve(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}}const Bn=Object.freeze({CreateLookupTable:{index:0,layout:b.n_([b.Jq("instruction"),Xn("recentSlot"),b.u8("bumpSeed")])},FreezeLookupTable:{index:1,layout:b.n_([b.Jq("instruction")])},ExtendLookupTable:{index:2,layout:b.n_([b.Jq("instruction"),Xn(),b.A9(ct(),b.cv(b.Jq(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:b.n_([b.Jq("instruction")])},CloseLookupTable:{index:4,layout:b.n_([b.Jq("instruction")])}});class Ku{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);const n=b.Jq("instruction").decode(e.data);let s;for(const[o,i]of Object.entries(Bn))if(i.index==n){s=o;break}if(!s)throw new Error("Invalid Instruction. Should be a LookupTable Instruction");return s}static decodeCreateLookupTable(e){this.checkProgramId(e.programId),this.checkKeysLength(e.keys,4);const{recentSlot:t}=kt(Bn.CreateLookupTable,e.data);return{authority:e.keys[1].pubkey,payer:e.keys[2].pubkey,recentSlot:Number(t)}}static decodeExtendLookupTable(e){if(this.checkProgramId(e.programId),e.keys.length<2)throw new Error(`invalid instruction; found ${e.keys.length} keys, expected at least 2`);const{addresses:t}=kt(Bn.ExtendLookupTable,e.data);return{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey,payer:e.keys.length>2?e.keys[2].pubkey:void 0,addresses:t.map(n=>new ve(n))}}static decodeCloseLookupTable(e){return this.checkProgramId(e.programId),this.checkKeysLength(e.keys,3),{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey,recipient:e.keys[2].pubkey}}static decodeFreezeLookupTable(e){return this.checkProgramId(e.programId),this.checkKeysLength(e.keys,2),{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey}}static decodeDeactivateLookupTable(e){return this.checkProgramId(e.programId),this.checkKeysLength(e.keys,2),{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey}}static checkProgramId(e){if(!e.equals(Cs.programId))throw new Error("invalid instruction; programId is not AddressLookupTable Program")}static checkKeysLength(e,t){if(e.length<t)throw new Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}}class Cs{constructor(){}static createLookupTable(e){const[t,n]=ve.findProgramAddressSync([e.authority.toBuffer(),(0,rs.k$)(BigInt(e.recentSlot),8)],this.programId),s=Bn.CreateLookupTable,o=ht(s,{recentSlot:BigInt(e.recentSlot),bumpSeed:n}),i=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1},{pubkey:e.payer,isSigner:!0,isWritable:!0},{pubkey:Jt.programId,isSigner:!1,isWritable:!1}];return[new vt({programId:this.programId,keys:i,data:o}),t]}static freezeLookupTable(e){const t=Bn.FreezeLookupTable,n=ht(t),s=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new vt({programId:this.programId,keys:s,data:n})}static extendLookupTable(e){const t=Bn.ExtendLookupTable,n=ht(t,{addresses:e.addresses.map(o=>o.toBytes())}),s=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return e.payer&&s.push({pubkey:e.payer,isSigner:!0,isWritable:!0},{pubkey:Jt.programId,isSigner:!1,isWritable:!1}),new vt({programId:this.programId,keys:s,data:n})}static deactivateLookupTable(e){const t=Bn.DeactivateLookupTable,n=ht(t),s=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new vt({programId:this.programId,keys:s,data:n})}static closeLookupTable(e){const t=Bn.CloseLookupTable,n=ht(t),s=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1},{pubkey:e.recipient,isSigner:!1,isWritable:!0}];return new vt({programId:this.programId,keys:s,data:n})}}Cs.programId=new ve("AddressLookupTab1e1111111111111111111111111");class Du{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);const n=b.u8("instruction").decode(e.data);let s;for(const[o,i]of Object.entries(An))if(i.index==n){s=o;break}if(!s)throw new Error("Instruction type incorrect; not a ComputeBudgetInstruction");return s}static decodeRequestUnits(e){this.checkProgramId(e.programId);const{units:t,additionalFee:n}=kt(An.RequestUnits,e.data);return{units:t,additionalFee:n}}static decodeRequestHeapFrame(e){this.checkProgramId(e.programId);const{bytes:t}=kt(An.RequestHeapFrame,e.data);return{bytes:t}}static decodeSetComputeUnitLimit(e){this.checkProgramId(e.programId);const{units:t}=kt(An.SetComputeUnitLimit,e.data);return{units:t}}static decodeSetComputeUnitPrice(e){this.checkProgramId(e.programId);const{microLamports:t}=kt(An.SetComputeUnitPrice,e.data);return{microLamports:t}}static checkProgramId(e){if(!e.equals(Ns.programId))throw new Error("invalid instruction; programId is not ComputeBudgetProgram")}}const An=Object.freeze({RequestUnits:{index:0,layout:b.n_([b.u8("instruction"),b.Jq("units"),b.Jq("additionalFee")])},RequestHeapFrame:{index:1,layout:b.n_([b.u8("instruction"),b.Jq("bytes")])},SetComputeUnitLimit:{index:2,layout:b.n_([b.u8("instruction"),b.Jq("units")])},SetComputeUnitPrice:{index:3,layout:b.n_([b.u8("instruction"),Xn("microLamports")])}});class Ns{constructor(){}static requestUnits(e){const t=An.RequestUnits,n=ht(t,e);return new vt({keys:[],programId:this.programId,data:n})}static requestHeapFrame(e){const t=An.RequestHeapFrame,n=ht(t,e);return new vt({keys:[],programId:this.programId,data:n})}static setComputeUnitLimit(e){const t=An.SetComputeUnitLimit,n=ht(t,e);return new vt({keys:[],programId:this.programId,data:n})}static setComputeUnitPrice(e){const t=An.SetComputeUnitPrice,n=ht(t,{microLamports:BigInt(e.microLamports)});return new vt({keys:[],programId:this.programId,data:n})}}Ns.programId=new ve("ComputeBudget111111111111111111111111111111");const Qo=64,ei=32,ti=64,ni=b.n_([b.u8("numSignatures"),b.u8("padding"),b.KB("signatureOffset"),b.KB("signatureInstructionIndex"),b.KB("publicKeyOffset"),b.KB("publicKeyInstructionIndex"),b.KB("messageDataOffset"),b.KB("messageDataSize"),b.KB("messageInstructionIndex")]);class Mr{constructor(){}static createInstructionWithPublicKey(e){const{publicKey:t,message:n,signature:s,instructionIndex:o}=e;yt(t.length===ei,`Public Key must be ${ei} bytes but received ${t.length} bytes`),yt(s.length===ti,`Signature must be ${ti} bytes but received ${s.length} bytes`);const i=ni.span,a=i+t.length,u=a+s.length,d=1,g=P.Buffer.alloc(u+n.length),w=o==null?65535:o;return ni.encode({numSignatures:d,padding:0,signatureOffset:a,signatureInstructionIndex:w,publicKeyOffset:i,publicKeyInstructionIndex:w,messageDataOffset:u,messageDataSize:n.length,messageInstructionIndex:w},g),g.fill(t,i),g.fill(s,a),g.fill(n,u),new vt({keys:[],programId:Mr.programId,data:g})}static createInstructionWithPrivateKey(e){const{privateKey:t,message:n,instructionIndex:s}=e;yt(t.length===Qo,`Private key must be ${Qo} bytes but received ${t.length} bytes`);try{const o=er.fromSecretKey(t),i=o.publicKey.toBytes(),a=ps(n,o.secretKey);return this.createInstructionWithPublicKey({publicKey:i,message:n,signature:a,instructionIndex:s})}catch(o){throw new Error(`Error creating instruction; ${o}`)}}}Mr.programId=new ve("Ed25519SigVerify111111111111111111111111111");const Mu=(r,e)=>{const t=ar.sign(r,e);return[t.toCompactRawBytes(),t.recovery]};ar.utils.isValidPrivateKey;const Wu=ar.getPublicKey,ri=32,Us=20,si=64,Hu=11,zs=b.n_([b.u8("numSignatures"),b.KB("signatureOffset"),b.u8("signatureInstructionIndex"),b.KB("ethAddressOffset"),b.u8("ethAddressInstructionIndex"),b.KB("messageDataOffset"),b.KB("messageDataSize"),b.u8("messageInstructionIndex"),b.Ik(20,"ethAddress"),b.Ik(64,"signature"),b.u8("recoveryId")]);class tr{constructor(){}static publicKeyToEthAddress(e){yt(e.length===si,`Public key must be ${si} bytes but received ${e.length} bytes`);try{return P.Buffer.from(go(tt(e))).slice(-Us)}catch(t){throw new Error(`Error constructing Ethereum address: ${t}`)}}static createInstructionWithPublicKey(e){const{publicKey:t,message:n,signature:s,recoveryId:o,instructionIndex:i}=e;return tr.createInstructionWithEthAddress({ethAddress:tr.publicKeyToEthAddress(t),message:n,signature:s,recoveryId:o,instructionIndex:i})}static createInstructionWithEthAddress(e){const{ethAddress:t,message:n,signature:s,recoveryId:o,instructionIndex:i=0}=e;let a;typeof t=="string"?t.startsWith("0x")?a=P.Buffer.from(t.substr(2),"hex"):a=P.Buffer.from(t,"hex"):a=t,yt(a.length===Us,`Address must be ${Us} bytes but received ${a.length} bytes`);const u=1+Hu,d=u,g=u+a.length,w=g+s.length+1,j=1,C=P.Buffer.alloc(zs.span+n.length);return zs.encode({numSignatures:j,signatureOffset:g,signatureInstructionIndex:i,ethAddressOffset:d,ethAddressInstructionIndex:i,messageDataOffset:w,messageDataSize:n.length,messageInstructionIndex:i,signature:tt(s),ethAddress:tt(a),recoveryId:o},C),C.fill(tt(n),zs.span),new vt({keys:[],programId:tr.programId,data:C})}static createInstructionWithPrivateKey(e){const{privateKey:t,message:n,instructionIndex:s}=e;yt(t.length===ri,`Private key must be ${ri} bytes but received ${t.length} bytes`);try{const o=tt(t),i=Wu(o,!1).slice(1),a=P.Buffer.from(go(tt(n))),[u,d]=Mu(a,o);return this.createInstructionWithPublicKey({publicKey:i,message:n,signature:u,recoveryId:d,instructionIndex:s})}catch(o){throw new Error(`Error creating instruction; ${o}`)}}}tr.programId=new ve("KeccakSecp256k11111111111111111111111111111");var oi;const ii=new ve("StakeConfig11111111111111111111111111111111");class ai{constructor(e,t){this.staker=void 0,this.withdrawer=void 0,this.staker=e,this.withdrawer=t}}class pr{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}}oi=pr,pr.default=new oi(0,0,ve.default);class qu{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);const n=b.Jq("instruction").decode(e.data);let s;for(const[o,i]of Object.entries($t))if(i.index==n){s=o;break}if(!s)throw new Error("Instruction type incorrect; not a StakeInstruction");return s}static decodeInitialize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{authorized:t,lockup:n}=kt($t.Initialize,e.data);return{stakePubkey:e.keys[0].pubkey,authorized:new ai(new ve(t.staker),new ve(t.withdrawer)),lockup:new pr(n.unixTimestamp,n.epoch,new ve(n.custodian))}}static decodeDelegate(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,6),kt($t.Delegate,e.data),{stakePubkey:e.keys[0].pubkey,votePubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[5].pubkey}}static decodeAuthorize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{newAuthorized:t,stakeAuthorizationType:n}=kt($t.Authorize,e.data),s={stakePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey,newAuthorizedPubkey:new ve(t),stakeAuthorizationType:{index:n}};return e.keys.length>3&&(s.custodianPubkey=e.keys[3].pubkey),s}static decodeAuthorizeWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{newAuthorized:t,stakeAuthorizationType:n,authoritySeed:s,authorityOwner:o}=kt($t.AuthorizeWithSeed,e.data),i={stakePubkey:e.keys[0].pubkey,authorityBase:e.keys[1].pubkey,authoritySeed:s,authorityOwner:new ve(o),newAuthorizedPubkey:new ve(t),stakeAuthorizationType:{index:n}};return e.keys.length>3&&(i.custodianPubkey=e.keys[3].pubkey),i}static decodeSplit(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{lamports:t}=kt($t.Split,e.data);return{stakePubkey:e.keys[0].pubkey,splitStakePubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[2].pubkey,lamports:t}}static decodeMerge(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3),kt($t.Merge,e.data),{stakePubkey:e.keys[0].pubkey,sourceStakePubKey:e.keys[1].pubkey,authorizedPubkey:e.keys[4].pubkey}}static decodeWithdraw(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,5);const{lamports:t}=kt($t.Withdraw,e.data),n={stakePubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[4].pubkey,lamports:t};return e.keys.length>5&&(n.custodianPubkey=e.keys[5].pubkey),n}static decodeDeactivate(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3),kt($t.Deactivate,e.data),{stakePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey}}static checkProgramId(e){if(!e.equals(Wr.programId))throw new Error("invalid instruction; programId is not StakeProgram")}static checkKeyLength(e,t){if(e.length<t)throw new Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}}const $t=Object.freeze({Initialize:{index:0,layout:b.n_([b.Jq("instruction"),Ya(),Ja()])},Authorize:{index:1,layout:b.n_([b.Jq("instruction"),ct("newAuthorized"),b.Jq("stakeAuthorizationType")])},Delegate:{index:2,layout:b.n_([b.Jq("instruction")])},Split:{index:3,layout:b.n_([b.Jq("instruction"),b.gM("lamports")])},Withdraw:{index:4,layout:b.n_([b.Jq("instruction"),b.gM("lamports")])},Deactivate:{index:5,layout:b.n_([b.Jq("instruction")])},Merge:{index:7,layout:b.n_([b.Jq("instruction")])},AuthorizeWithSeed:{index:8,layout:b.n_([b.Jq("instruction"),ct("newAuthorized"),b.Jq("stakeAuthorizationType"),Mn("authoritySeed"),ct("authorityOwner")])}}),Fu=Object.freeze({Staker:{index:0},Withdrawer:{index:1}});class Wr{constructor(){}static initialize(e){const{stakePubkey:t,authorized:n,lockup:s}=e,o=s||pr.default,i=$t.Initialize,a=ht(i,{authorized:{staker:tt(n.staker.toBuffer()),withdrawer:tt(n.withdrawer.toBuffer())},lockup:{unixTimestamp:o.unixTimestamp,epoch:o.epoch,custodian:tt(o.custodian.toBuffer())}}),u={keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Zn,isSigner:!1,isWritable:!1}],programId:this.programId,data:a};return new vt(u)}static createAccountWithSeed(e){const t=new wt;t.add(Jt.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:s,lockup:o}=e;return t.add(this.initialize({stakePubkey:n,authorized:s,lockup:o}))}static createAccount(e){const t=new wt;t.add(Jt.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.stakePubkey,lamports:e.lamports,space:this.space,programId:this.programId}));const{stakePubkey:n,authorized:s,lockup:o}=e;return t.add(this.initialize({stakePubkey:n,authorized:s,lockup:o}))}static delegate(e){const{stakePubkey:t,authorizedPubkey:n,votePubkey:s}=e,o=$t.Delegate,i=ht(o);return new wt().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!1},{pubkey:vn,isSigner:!1,isWritable:!1},{pubkey:Cr,isSigner:!1,isWritable:!1},{pubkey:ii,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:i})}static authorize(e){const{stakePubkey:t,authorizedPubkey:n,newAuthorizedPubkey:s,stakeAuthorizationType:o,custodianPubkey:i}=e,a=$t.Authorize,u=ht(a,{newAuthorized:tt(s.toBuffer()),stakeAuthorizationType:o.index}),d=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:vn,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return i&&d.push({pubkey:i,isSigner:!1,isWritable:!1}),new wt().add({keys:d,programId:this.programId,data:u})}static authorizeWithSeed(e){const{stakePubkey:t,authorityBase:n,authoritySeed:s,authorityOwner:o,newAuthorizedPubkey:i,stakeAuthorizationType:a,custodianPubkey:u}=e,d=$t.AuthorizeWithSeed,g=ht(d,{newAuthorized:tt(i.toBuffer()),stakeAuthorizationType:a.index,authoritySeed:s,authorityOwner:tt(o.toBuffer())}),w=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1},{pubkey:vn,isSigner:!1,isWritable:!1}];return u&&w.push({pubkey:u,isSigner:!1,isWritable:!1}),new wt().add({keys:w,programId:this.programId,data:g})}static splitInstruction(e){const{stakePubkey:t,authorizedPubkey:n,splitStakePubkey:s,lamports:o}=e,i=$t.Split,a=ht(i,{lamports:o});return new vt({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:a})}static split(e){const t=new wt;return t.add(Jt.createAccount({fromPubkey:e.authorizedPubkey,newAccountPubkey:e.splitStakePubkey,lamports:0,space:this.space,programId:this.programId})),t.add(this.splitInstruction(e))}static splitWithSeed(e){const{stakePubkey:t,authorizedPubkey:n,splitStakePubkey:s,basePubkey:o,seed:i,lamports:a}=e,u=new wt;return u.add(Jt.allocate({accountPubkey:s,basePubkey:o,seed:i,space:this.space,programId:this.programId})),u.add(this.splitInstruction({stakePubkey:t,authorizedPubkey:n,splitStakePubkey:s,lamports:a}))}static merge(e){const{stakePubkey:t,sourceStakePubKey:n,authorizedPubkey:s}=e,o=$t.Merge,i=ht(o);return new wt().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!0},{pubkey:vn,isSigner:!1,isWritable:!1},{pubkey:Cr,isSigner:!1,isWritable:!1},{pubkey:s,isSigner:!0,isWritable:!1}],programId:this.programId,data:i})}static withdraw(e){const{stakePubkey:t,authorizedPubkey:n,toPubkey:s,lamports:o,custodianPubkey:i}=e,a=$t.Withdraw,u=ht(a,{lamports:o}),d=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:vn,isSigner:!1,isWritable:!1},{pubkey:Cr,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return i&&d.push({pubkey:i,isSigner:!1,isWritable:!1}),new wt().add({keys:d,programId:this.programId,data:u})}static deactivate(e){const{stakePubkey:t,authorizedPubkey:n}=e,s=$t.Deactivate,o=ht(s);return new wt().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:vn,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}}Wr.programId=new ve("Stake11111111111111111111111111111111111111"),Wr.space=200;class ci{constructor(e,t,n,s){this.nodePubkey=void 0,this.authorizedVoter=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.nodePubkey=e,this.authorizedVoter=t,this.authorizedWithdrawer=n,this.commission=s}}class Vu{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);const n=b.Jq("instruction").decode(e.data);let s;for(const[o,i]of Object.entries(Rn))if(i.index==n){s=o;break}if(!s)throw new Error("Instruction type incorrect; not a VoteInstruction");return s}static decodeInitializeAccount(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,4);const{voteInit:t}=kt(Rn.InitializeAccount,e.data);return{votePubkey:e.keys[0].pubkey,nodePubkey:e.keys[3].pubkey,voteInit:new ci(new ve(t.nodePubkey),new ve(t.authorizedVoter),new ve(t.authorizedWithdrawer),t.commission)}}static decodeAuthorize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{newAuthorized:t,voteAuthorizationType:n}=kt(Rn.Authorize,e.data);return{votePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey,newAuthorizedPubkey:new ve(t),voteAuthorizationType:{index:n}}}static decodeAuthorizeWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:t,currentAuthorityDerivedKeySeed:n,newAuthorized:s,voteAuthorizationType:o}}=kt(Rn.AuthorizeWithSeed,e.data);return{currentAuthorityDerivedKeyBasePubkey:e.keys[2].pubkey,currentAuthorityDerivedKeyOwnerPubkey:new ve(t),currentAuthorityDerivedKeySeed:n,newAuthorizedPubkey:new ve(s),voteAuthorizationType:{index:o},votePubkey:e.keys[0].pubkey}}static decodeWithdraw(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{lamports:t}=kt(Rn.Withdraw,e.data);return{votePubkey:e.keys[0].pubkey,authorizedWithdrawerPubkey:e.keys[2].pubkey,lamports:t,toPubkey:e.keys[1].pubkey}}static checkProgramId(e){if(!e.equals(nr.programId))throw new Error("invalid instruction; programId is not VoteProgram")}static checkKeyLength(e,t){if(e.length<t)throw new Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}}const Rn=Object.freeze({InitializeAccount:{index:0,layout:b.n_([b.Jq("instruction"),Za()])},Authorize:{index:1,layout:b.n_([b.Jq("instruction"),ct("newAuthorized"),b.Jq("voteAuthorizationType")])},Withdraw:{index:3,layout:b.n_([b.Jq("instruction"),b.gM("lamports")])},AuthorizeWithSeed:{index:10,layout:b.n_([b.Jq("instruction"),Xa()])}}),Gu=Object.freeze({Voter:{index:0},Withdrawer:{index:1}});class nr{constructor(){}static initializeAccount(e){const{votePubkey:t,nodePubkey:n,voteInit:s}=e,o=Rn.InitializeAccount,i=ht(o,{voteInit:{nodePubkey:tt(s.nodePubkey.toBuffer()),authorizedVoter:tt(s.authorizedVoter.toBuffer()),authorizedWithdrawer:tt(s.authorizedWithdrawer.toBuffer()),commission:s.commission}}),a={keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Zn,isSigner:!1,isWritable:!1},{pubkey:vn,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:i};return new vt(a)}static createAccount(e){const t=new wt;return t.add(Jt.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:s,voteAuthorizationType:o}=e,i=Rn.Authorize,a=ht(i,{newAuthorized:tt(s.toBuffer()),voteAuthorizationType:o.index}),u=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:vn,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return new wt().add({keys:u,programId:this.programId,data:a})}static authorizeWithSeed(e){const{currentAuthorityDerivedKeyBasePubkey:t,currentAuthorityDerivedKeyOwnerPubkey:n,currentAuthorityDerivedKeySeed:s,newAuthorizedPubkey:o,voteAuthorizationType:i,votePubkey:a}=e,u=Rn.AuthorizeWithSeed,d=ht(u,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:tt(n.toBuffer()),currentAuthorityDerivedKeySeed:s,newAuthorized:tt(o.toBuffer()),voteAuthorizationType:i.index}}),g=[{pubkey:a,isSigner:!1,isWritable:!0},{pubkey:vn,isSigner:!1,isWritable:!1},{pubkey:t,isSigner:!0,isWritable:!1}];return new wt().add({keys:g,programId:this.programId,data:d})}static withdraw(e){const{votePubkey:t,authorizedWithdrawerPubkey:n,lamports:s,toPubkey:o}=e,i=Rn.Withdraw,a=ht(i,{lamports:s}),u=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:o,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return new wt().add({keys:u,programId:this.programId,data:a})}static safeWithdraw(e,t,n){if(e.lamports>t-n)throw new Error("Withdraw will leave vote account with insuffcient funds.");return nr.withdraw(e)}}nr.programId=new ve("Vote111111111111111111111111111111111111111"),nr.space=3731;const ui=new ve("Va1idator1nfo111111111111111111111111111111"),ju=de({name:_e(),website:Qe(_e()),details:Qe(_e()),keybaseUsername:Qe(_e())});class Ks{constructor(e,t){this.key=void 0,this.info=void 0,this.key=e,this.info=t}static fromConfigData(e){let t=[...e];if(rn(t)!==2)return null;const s=[];for(let o=0;o<2;o++){const i=new ve(t.slice(0,on));t=t.slice(on);const a=t.slice(0,1)[0]===1;t=t.slice(1),s.push({publicKey:i,isSigner:a})}if(s[0].publicKey.equals(ui)&&s[1].isSigner){const o=Mn().decode(P.Buffer.from(t)),i=JSON.parse(o);return oo(i,ju),new Ks(s[1].publicKey,i)}return null}}const $u=new ve("Vote111111111111111111111111111111111111111"),Yu=b.n_([ct("nodePubkey"),ct("authorizedWithdrawer"),b.u8("commission"),b._O(),b.A9(b.n_([b._O("slot"),b.Jq("confirmationCount")]),b.cv(b.Jq(),-8),"votes"),b.u8("rootSlotValid"),b._O("rootSlot"),b._O(),b.A9(b.n_([b._O("epoch"),ct("authorizedVoter")]),b.cv(b.Jq(),-8),"authorizedVoters"),b.n_([b.A9(b.n_([ct("authorizedPubkey"),b._O("epochOfLastAuthorizedSwitch"),b._O("targetEpoch")]),32,"buf"),b._O("idx"),b.u8("isEmpty")],"priorVoters"),b._O(),b.A9(b.n_([b._O("epoch"),b._O("credits"),b._O("prevCredits")]),b.cv(b.Jq(),-8),"epochCredits"),b.n_([b._O("slot"),b._O("timestamp")],"lastTimestamp")]);class Ds{constructor(e){this.nodePubkey=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.rootSlot=void 0,this.votes=void 0,this.authorizedVoters=void 0,this.priorVoters=void 0,this.epochCredits=void 0,this.lastTimestamp=void 0,this.nodePubkey=e.nodePubkey,this.authorizedWithdrawer=e.authorizedWithdrawer,this.commission=e.commission,this.rootSlot=e.rootSlot,this.votes=e.votes,this.authorizedVoters=e.authorizedVoters,this.priorVoters=e.priorVoters,this.epochCredits=e.epochCredits,this.lastTimestamp=e.lastTimestamp}static fromAccountData(e){const n=Yu.decode(tt(e),4);let s=n.rootSlot;return n.rootSlotValid||(s=null),new Ds({nodePubkey:new ve(n.nodePubkey),authorizedWithdrawer:new ve(n.authorizedWithdrawer),commission:n.commission,votes:n.votes,rootSlot:s,authorizedVoters:n.authorizedVoters.map(Ju),priorVoters:Zu(n.priorVoters),epochCredits:n.epochCredits,lastTimestamp:n.lastTimestamp})}}function Ju({authorizedVoter:r,epoch:e}){return{epoch:e,authorizedVoter:new ve(r)}}function li({authorizedPubkey:r,epochOfLastAuthorizedSwitch:e,targetEpoch:t}){return{authorizedPubkey:new ve(r),epochOfLastAuthorizedSwitch:e,targetEpoch:t}}function Zu({buf:r,idx:e,isEmpty:t}){return t?[]:[...r.slice(e+1).map(li),...r.slice(0,e).map(li)]}const fi={http:{devnet:"http://api.devnet.solana.com",testnet:"http://api.testnet.solana.com","mainnet-beta":"http://api.mainnet-beta.solana.com/"},https:{devnet:"https://api.devnet.solana.com",testnet:"https://api.testnet.solana.com","mainnet-beta":"https://api.mainnet-beta.solana.com/"}};function Xu(r,e){const t=e===!1?"http":"https";if(!r)return fi[t].devnet;const n=fi[t][r];if(!n)throw new Error(`Unknown ${t} cluster: ${r}`);return n}async function Qu(r,e,t,n){let s,o;t&&Object.prototype.hasOwnProperty.call(t,"lastValidBlockHeight")||t&&Object.prototype.hasOwnProperty.call(t,"nonceValue")?(s=t,o=n):o=t;const i=o&&{skipPreflight:o.skipPreflight,preflightCommitment:o.preflightCommitment||o.commitment,minContextSlot:o.minContextSlot},a=await r.sendRawTransaction(e,i),u=o&&o.commitment,g=(await(s?r.confirmTransaction(s,u):r.confirmTransaction(a,u))).value;if(g.err)throw new Error(`Raw transaction ${a} failed (${JSON.stringify(g)})`);return a}const el=1e9},58162:function(ee,J,A){"use strict";var h=A(89509).Buffer;function P(X){if(X.length>=255)throw new TypeError("Alphabet too long");for(var S=new Uint8Array(256),B=0;B<S.length;B++)S[B]=255;for(var Q=0;Q<X.length;Q++){var F=X.charAt(Q),R=F.charCodeAt(0);if(S[R]!==255)throw new TypeError(F+" is ambiguous");S[R]=Q}var G=X.length,ke=X.charAt(0),oe=Math.log(G)/Math.log(256),_=Math.log(256)/Math.log(G);function ne(re){if((Array.isArray(re)||re instanceof Uint8Array)&&(re=h.from(re)),!h.isBuffer(re))throw new TypeError("Expected Buffer");if(re.length===0)return"";for(var V=0,te=0,ge=0,Ne=re.length;ge!==Ne&&re[ge]===0;)ge++,V++;for(var Z=(Ne-ge)*_+1>>>0,be=new Uint8Array(Z);ge!==Ne;){for(var qe=re[ge],pe=0,Be=Z-1;(qe!==0||pe<te)&&Be!==-1;Be--,pe++)qe+=256*be[Be]>>>0,be[Be]=qe%G>>>0,qe=qe/G>>>0;if(qe!==0)throw new Error("Non-zero carry");te=pe,ge++}for(var xe=Z-te;xe!==Z&&be[xe]===0;)xe++;for(var $=ke.repeat(V);xe<Z;++xe)$+=X.charAt(be[xe]);return $}function M(re){if(typeof re!="string")throw new TypeError("Expected String");if(re.length===0)return h.alloc(0);for(var V=0,te=0,ge=0;re[V]===ke;)te++,V++;for(var Ne=(re.length-V)*oe+1>>>0,Z=new Uint8Array(Ne);re[V];){var be=S[re.charCodeAt(V)];if(be===255)return;for(var qe=0,pe=Ne-1;(be!==0||qe<ge)&&pe!==-1;pe--,qe++)be+=G*Z[pe]>>>0,Z[pe]=be%256>>>0,be=be/256>>>0;if(be!==0)throw new Error("Non-zero carry");ge=qe,V++}for(var Be=Ne-ge;Be!==Ne&&Z[Be]===0;)Be++;var xe=h.allocUnsafe(te+(Ne-Be));xe.fill(0,0,te);for(var $=te;Be!==Ne;)xe[$++]=Z[Be++];return xe}function le(re){var V=M(re);if(V)return V;throw new Error("Non-base"+G+" character")}return{encode:ne,decodeUnsafe:M,decode:le}}ee.exports=P},40475:function(ee,J,A){"use strict";var h,P=A(48764).Buffer;h={value:!0};let X;function S(R){{const G=P.from(R);G.reverse();const ke=G.toString("hex");return ke.length===0?BigInt(0):BigInt(`0x${ke}`)}return X.toBigInt(R,!1)}J.oU=S;function B(R){{const G=R.toString("hex");return G.length===0?BigInt(0):BigInt(`0x${G}`)}return X.toBigInt(R,!0)}J.Q5=B;function Q(R,G){{const ke=R.toString(16),oe=P.from(ke.padStart(G*2,"0").slice(0,G*2),"hex");return oe.reverse(),oe}return X.fromBigInt(R,P.allocUnsafe(G),!1)}J.k$=Q;function F(R,G){{const ke=R.toString(16);return P.from(ke.padStart(G*2,"0").slice(0,G*2),"hex")}return X.fromBigInt(R,P.allocUnsafe(G),!0)}J.zP=F},25532:function(ee,J,A){"use strict";var h=A(48764).Buffer,P=this&&this.__createBinding||(Object.create?function($,U,ie,se){se===void 0&&(se=ie),Object.defineProperty($,se,{enumerable:!0,get:function(){return U[ie]}})}:function($,U,ie,se){se===void 0&&(se=ie),$[se]=U[ie]}),X=this&&this.__setModuleDefault||(Object.create?function($,U){Object.defineProperty($,"default",{enumerable:!0,value:U})}:function($,U){$.default=U}),S=this&&this.__decorate||function($,U,ie,se){var ye=arguments.length,we=ye<3?U:se===null?se=Object.getOwnPropertyDescriptor(U,ie):se,Ze;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")we=Reflect.decorate($,U,ie,se);else for(var rt=$.length-1;rt>=0;rt--)(Ze=$[rt])&&(we=(ye<3?Ze(we):ye>3?Ze(U,ie,we):Ze(U,ie))||we);return ye>3&&we&&Object.defineProperty(U,ie,we),we},B=this&&this.__importStar||function($){if($&&$.__esModule)return $;var U={};if($!=null)for(var ie in $)ie!=="default"&&Object.hasOwnProperty.call($,ie)&&P(U,$,ie);return X(U,$),U},Q=this&&this.__importDefault||function($){return $&&$.__esModule?$:{default:$}};Object.defineProperty(J,"__esModule",{value:!0}),J.deserializeUnchecked=J.deserialize=J.serialize=J.BinaryReader=J.BinaryWriter=J.BorshError=J.baseDecode=J.baseEncode=void 0;const F=Q(A(13550)),R=Q(A(77191)),G=B(A(11379)),ke=typeof TextDecoder!="function"?G.TextDecoder:TextDecoder,oe=new ke("utf-8",{fatal:!0});function _($){return typeof $=="string"&&($=h.from($,"utf8")),R.default.encode(h.from($))}J.baseEncode=_;function ne($){return h.from(R.default.decode($))}J.baseDecode=ne;const M=1024;class le extends Error{constructor(U){super(U),this.fieldPath=[],this.originalMessage=U}addToFieldPath(U){this.fieldPath.splice(0,0,U),this.message=this.originalMessage+": "+this.fieldPath.join(".")}}J.BorshError=le;class re{constructor(){this.buf=h.alloc(M),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=h.concat([this.buf,h.alloc(M)]))}writeU8(U){this.maybeResize(),this.buf.writeUInt8(U,this.length),this.length+=1}writeU16(U){this.maybeResize(),this.buf.writeUInt16LE(U,this.length),this.length+=2}writeU32(U){this.maybeResize(),this.buf.writeUInt32LE(U,this.length),this.length+=4}writeU64(U){this.maybeResize(),this.writeBuffer(h.from(new F.default(U).toArray("le",8)))}writeU128(U){this.maybeResize(),this.writeBuffer(h.from(new F.default(U).toArray("le",16)))}writeU256(U){this.maybeResize(),this.writeBuffer(h.from(new F.default(U).toArray("le",32)))}writeU512(U){this.maybeResize(),this.writeBuffer(h.from(new F.default(U).toArray("le",64)))}writeBuffer(U){this.buf=h.concat([h.from(this.buf.subarray(0,this.length)),U,h.alloc(M)]),this.length+=U.length}writeString(U){this.maybeResize();const ie=h.from(U,"utf8");this.writeU32(ie.length),this.writeBuffer(ie)}writeFixedArray(U){this.writeBuffer(h.from(U))}writeArray(U,ie){this.maybeResize(),this.writeU32(U.length);for(const se of U)this.maybeResize(),ie(se)}toArray(){return this.buf.subarray(0,this.length)}}J.BinaryWriter=re;function V($,U,ie){const se=ie.value;ie.value=function(...ye){try{return se.apply(this,ye)}catch(we){if(we instanceof RangeError){const Ze=we.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(Ze)>=0)throw new le("Reached the end of buffer when deserializing")}throw we}}}class te{constructor(U){this.buf=U,this.offset=0}readU8(){const U=this.buf.readUInt8(this.offset);return this.offset+=1,U}readU16(){const U=this.buf.readUInt16LE(this.offset);return this.offset+=2,U}readU32(){const U=this.buf.readUInt32LE(this.offset);return this.offset+=4,U}readU64(){const U=this.readBuffer(8);return new F.default(U,"le")}readU128(){const U=this.readBuffer(16);return new F.default(U,"le")}readU256(){const U=this.readBuffer(32);return new F.default(U,"le")}readU512(){const U=this.readBuffer(64);return new F.default(U,"le")}readBuffer(U){if(this.offset+U>this.buf.length)throw new le(`Expected buffer length ${U} isn't within bounds`);const ie=this.buf.slice(this.offset,this.offset+U);return this.offset+=U,ie}readString(){const U=this.readU32(),ie=this.readBuffer(U);try{return oe.decode(ie)}catch(se){throw new le(`Error decoding UTF-8 string: ${se}`)}}readFixedArray(U){return new Uint8Array(this.readBuffer(U))}readArray(U){const ie=this.readU32(),se=Array();for(let ye=0;ye<ie;++ye)se.push(U());return se}}S([V],te.prototype,"readU8",null),S([V],te.prototype,"readU16",null),S([V],te.prototype,"readU32",null),S([V],te.prototype,"readU64",null),S([V],te.prototype,"readU128",null),S([V],te.prototype,"readU256",null),S([V],te.prototype,"readU512",null),S([V],te.prototype,"readString",null),S([V],te.prototype,"readFixedArray",null),S([V],te.prototype,"readArray",null),J.BinaryReader=te;function ge($){return $.charAt(0).toUpperCase()+$.slice(1)}function Ne($,U,ie,se,ye){try{if(typeof se=="string")ye[`write${ge(se)}`](ie);else if(se instanceof Array)if(typeof se[0]=="number"){if(ie.length!==se[0])throw new le(`Expecting byte array of length ${se[0]}, but got ${ie.length} bytes`);ye.writeFixedArray(ie)}else if(se.length===2&&typeof se[1]=="number"){if(ie.length!==se[1])throw new le(`Expecting byte array of length ${se[1]}, but got ${ie.length} bytes`);for(let we=0;we<se[1];we++)Ne($,null,ie[we],se[0],ye)}else ye.writeArray(ie,we=>{Ne($,U,we,se[0],ye)});else if(se.kind!==void 0)switch(se.kind){case"option":{ie==null?ye.writeU8(0):(ye.writeU8(1),Ne($,U,ie,se.type,ye));break}case"map":{ye.writeU32(ie.size),ie.forEach((we,Ze)=>{Ne($,U,Ze,se.key,ye),Ne($,U,we,se.value,ye)});break}default:throw new le(`FieldType ${se} unrecognized`)}else Z($,ie,ye)}catch(we){throw we instanceof le&&we.addToFieldPath(U),we}}function Z($,U,ie){if(typeof U.borshSerialize=="function"){U.borshSerialize(ie);return}const se=$.get(U.constructor);if(!se)throw new le(`Class ${U.constructor.name} is missing in schema`);if(se.kind==="struct")se.fields.map(([ye,we])=>{Ne($,ye,U[ye],we,ie)});else if(se.kind==="enum"){const ye=U[se.field];for(let we=0;we<se.values.length;++we){const[Ze,rt]=se.values[we];if(Ze===ye){ie.writeU8(we),Ne($,Ze,U[Ze],rt,ie);break}}}else throw new le(`Unexpected schema kind: ${se.kind} for ${U.constructor.name}`)}function be($,U,ie=re){const se=new ie;return Z($,U,se),se.toArray()}J.serialize=be;function qe($,U,ie,se){try{if(typeof ie=="string")return se[`read${ge(ie)}`]();if(ie instanceof Array){if(typeof ie[0]=="number")return se.readFixedArray(ie[0]);if(typeof ie[1]=="number"){const ye=[];for(let we=0;we<ie[1];we++)ye.push(qe($,null,ie[0],se));return ye}else return se.readArray(()=>qe($,U,ie[0],se))}if(ie.kind==="option")return se.readU8()?qe($,U,ie.type,se):void 0;if(ie.kind==="map"){let ye=new Map;const we=se.readU32();for(let Ze=0;Ze<we;Ze++){const rt=qe($,U,ie.key,se),me=qe($,U,ie.value,se);ye.set(rt,me)}return ye}return pe($,ie,se)}catch(ye){throw ye instanceof le&&ye.addToFieldPath(U),ye}}function pe($,U,ie){if(typeof U.borshDeserialize=="function")return U.borshDeserialize(ie);const se=$.get(U);if(!se)throw new le(`Class ${U.name} is missing in schema`);if(se.kind==="struct"){const ye={};for(const[we,Ze]of $.get(U).fields)ye[we]=qe($,we,Ze,ie);return new U(ye)}if(se.kind==="enum"){const ye=ie.readU8();if(ye>=se.values.length)throw new le(`Enum index: ${ye} is out of range`);const[we,Ze]=se.values[ye],rt=qe($,we,Ze,ie);return new U({[we]:rt})}throw new le(`Unexpected schema kind: ${se.kind} for ${U.constructor.name}`)}function Be($,U,ie,se=te){const ye=new se(ie),we=pe($,U,ye);if(ye.offset<ie.length)throw new le(`Unexpected ${ie.length-ye.offset} bytes after deserialized data`);return we}J.deserialize=Be;function xe($,U,ie,se=te){const ye=new se(ie);return pe($,U,ye)}J.deserializeUnchecked=xe},77191:function(ee,J,A){var h=A(58162),P="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";ee.exports=h(P)},58355:function(ee,J,A){"use strict";var h=A(35717),P=A(51031),X=A(71027),S=A(89509).Buffer,B=A(78028),Q=A(79785),F=A(89072),R=S.alloc(128);function G(ke,oe){X.call(this,"digest"),typeof oe=="string"&&(oe=S.from(oe));var _=ke==="sha512"||ke==="sha384"?128:64;if(this._alg=ke,this._key=oe,oe.length>_){var ne=ke==="rmd160"?new Q:F(ke);oe=ne.update(oe).digest()}else oe.length<_&&(oe=S.concat([oe,R],_));for(var M=this._ipad=S.allocUnsafe(_),le=this._opad=S.allocUnsafe(_),re=0;re<_;re++)M[re]=oe[re]^54,le[re]=oe[re]^92;this._hash=ke==="rmd160"?new Q:F(ke),this._hash.update(M)}h(G,X),G.prototype._update=function(ke){this._hash.update(ke)},G.prototype._final=function(){var ke=this._hash.digest(),oe=this._alg==="rmd160"?new Q:F(this._alg);return oe.update(this._opad).update(ke).digest()},ee.exports=function(oe,_){return oe=oe.toLowerCase(),oe==="rmd160"||oe==="ripemd160"?new G("rmd160",_):oe==="md5"?new P(B,_):new G(oe,_)}},51031:function(ee,J,A){"use strict";var h=A(35717),P=A(89509).Buffer,X=A(71027),S=P.alloc(128),B=64;function Q(F,R){X.call(this,"digest"),typeof R=="string"&&(R=P.from(R)),this._alg=F,this._key=R,R.length>B?R=F(R):R.length<B&&(R=P.concat([R,S],B));for(var G=this._ipad=P.allocUnsafe(B),ke=this._opad=P.allocUnsafe(B),oe=0;oe<B;oe++)G[oe]=R[oe]^54,ke[oe]=R[oe]^92;this._hash=[G]}h(Q,X),Q.prototype._update=function(F){this._hash.push(F)},Q.prototype._final=function(){var F=this._alg(P.concat(this._hash));return this._alg(P.concat([this._opad,F]))},ee.exports=Q},62678:function(ee,J,A){"use strict";var h=A(48764).Buffer;Object.defineProperty(J,"__esModule",{value:!0}),J.derivePath=J.isValidPath=J.getPublicKey=J.CKDPriv=J.getMasterKeyFromSeed=void 0;const P=A(58355),X=A(50780),S=A(91110),B="ed25519 seed",Q=2147483648;J.getMasterKeyFromSeed=F=>{const G=P("sha512",B).update(h.from(F,"hex")).digest(),ke=G.slice(0,32),oe=G.slice(32);return{key:ke,chainCode:oe}},J.CKDPriv=({key:F,chainCode:R},G)=>{const ke=h.allocUnsafe(4);ke.writeUInt32BE(G,0);const oe=h.concat([h.alloc(1,0),F,ke]),_=P("sha512",R).update(oe).digest(),ne=_.slice(0,32),M=_.slice(32);return{key:ne,chainCode:M}},J.getPublicKey=(F,R=!0)=>{const ke=X.sign.keyPair.fromSeed(F).secretKey.subarray(32),oe=h.alloc(1,0);return R?h.concat([oe,h.from(ke)]):h.from(ke)},J.isValidPath=F=>S.pathRegex.test(F)?!F.split("/").slice(1).map(S.replaceDerive).some(isNaN):!1,J.derivePath=(F,R,G=Q)=>{if(!J.isValidPath(F))throw new Error("Invalid derivation path");const{key:ke,chainCode:oe}=J.getMasterKeyFromSeed(R);return F.split("/").slice(1).map(S.replaceDerive).map(ne=>parseInt(ne,10)).reduce((ne,M)=>J.CKDPriv(ne,M+G),{key:ke,chainCode:oe})}},91110:function(ee,J){"use strict";Object.defineProperty(J,"__esModule",{value:!0}),J.replaceDerive=J.pathRegex=void 0,J.pathRegex=new RegExp("^m(\\/[0-9]+')+$"),J.replaceDerive=A=>A.replace("'","")},26729:function(ee){"use strict";var J=Object.prototype.hasOwnProperty,A="~";function h(){}Object.create&&(h.prototype=Object.create(null),new h().__proto__||(A=!1));function P(Q,F,R){this.fn=Q,this.context=F,this.once=R||!1}function X(Q,F,R,G,ke){if(typeof R!="function")throw new TypeError("The listener must be a function");var oe=new P(R,G||Q,ke),_=A?A+F:F;return Q._events[_]?Q._events[_].fn?Q._events[_]=[Q._events[_],oe]:Q._events[_].push(oe):(Q._events[_]=oe,Q._eventsCount++),Q}function S(Q,F){--Q._eventsCount===0?Q._events=new h:delete Q._events[F]}function B(){this._events=new h,this._eventsCount=0}B.prototype.eventNames=function(){var F=[],R,G;if(this._eventsCount===0)return F;for(G in R=this._events)J.call(R,G)&&F.push(A?G.slice(1):G);return Object.getOwnPropertySymbols?F.concat(Object.getOwnPropertySymbols(R)):F},B.prototype.listeners=function(F){var R=A?A+F:F,G=this._events[R];if(!G)return[];if(G.fn)return[G.fn];for(var ke=0,oe=G.length,_=new Array(oe);ke<oe;ke++)_[ke]=G[ke].fn;return _},B.prototype.listenerCount=function(F){var R=A?A+F:F,G=this._events[R];return G?G.fn?1:G.length:0},B.prototype.emit=function(F,R,G,ke,oe,_){var ne=A?A+F:F;if(!this._events[ne])return!1;var M=this._events[ne],le=arguments.length,re,V;if(M.fn){switch(M.once&&this.removeListener(F,M.fn,void 0,!0),le){case 1:return M.fn.call(M.context),!0;case 2:return M.fn.call(M.context,R),!0;case 3:return M.fn.call(M.context,R,G),!0;case 4:return M.fn.call(M.context,R,G,ke),!0;case 5:return M.fn.call(M.context,R,G,ke,oe),!0;case 6:return M.fn.call(M.context,R,G,ke,oe,_),!0}for(V=1,re=new Array(le-1);V<le;V++)re[V-1]=arguments[V];M.fn.apply(M.context,re)}else{var te=M.length,ge;for(V=0;V<te;V++)switch(M[V].once&&this.removeListener(F,M[V].fn,void 0,!0),le){case 1:M[V].fn.call(M[V].context);break;case 2:M[V].fn.call(M[V].context,R);break;case 3:M[V].fn.call(M[V].context,R,G);break;case 4:M[V].fn.call(M[V].context,R,G,ke);break;default:if(!re)for(ge=1,re=new Array(le-1);ge<le;ge++)re[ge-1]=arguments[ge];M[V].fn.apply(M[V].context,re)}}return!0},B.prototype.on=function(F,R,G){return X(this,F,R,G,!1)},B.prototype.once=function(F,R,G){return X(this,F,R,G,!0)},B.prototype.removeListener=function(F,R,G,ke){var oe=A?A+F:F;if(!this._events[oe])return this;if(!R)return S(this,oe),this;var _=this._events[oe];if(_.fn)_.fn===R&&(!ke||_.once)&&(!G||_.context===G)&&S(this,oe);else{for(var ne=0,M=[],le=_.length;ne<le;ne++)(_[ne].fn!==R||ke&&!_[ne].once||G&&_[ne].context!==G)&&M.push(_[ne]);M.length?this._events[oe]=M.length===1?M[0]:M:S(this,oe)}return this},B.prototype.removeAllListeners=function(F){var R;return F?(R=A?A+F:F,this._events[R]&&S(this,R)):(this._events=new h,this._eventsCount=0),this},B.prototype.off=B.prototype.removeListener,B.prototype.addListener=B.prototype.on,B.prefixed=A,B.EventEmitter=B,ee.exports=B},31198:function(ee,J,A){"use strict";const h=A(55877).v4,P=A(17741),X=function(S,B){if(!(this instanceof X))return new X(S,B);B||(B={}),this.options={reviver:typeof B.reviver<"u"?B.reviver:null,replacer:typeof B.replacer<"u"?B.replacer:null,generator:typeof B.generator<"u"?B.generator:function(){return h()},version:typeof B.version<"u"?B.version:2,notificationIdNull:typeof B.notificationIdNull=="boolean"?B.notificationIdNull:!1},this.callServer=S};ee.exports=X,X.prototype.request=function(S,B,Q,F){const R=this;let G=null;const ke=Array.isArray(S)&&typeof B=="function";if(this.options.version===1&&ke)throw new TypeError("JSON-RPC 1.0 does not support batching");if(ke||!ke&&S&&typeof S=="object"&&typeof B=="function")F=B,G=S;else{typeof Q=="function"&&(F=Q,Q=void 0);const ne=typeof F=="function";try{G=P(S,B,Q,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(M){if(ne)return F(M);throw M}if(!ne)return G}let _;try{_=JSON.stringify(G,this.options.replacer)}catch(ne){return F(ne)}return this.callServer(_,function(ne,M){R._parseResponse(ne,M,F)}),G},X.prototype._parseResponse=function(S,B,Q){if(S){Q(S);return}if(!B)return Q();let F;try{F=JSON.parse(B,this.options.reviver)}catch(R){return Q(R)}if(Q.length===3)if(Array.isArray(F)){const R=function(ke){return typeof ke.error<"u"},G=function(ke){return!R(ke)};return Q(null,F.filter(R),F.filter(G))}else return Q(null,F.error,F.result);Q(null,F)}},17741:function(ee,J,A){"use strict";const h=A(55877).v4,P=function(X,S,B,Q){if(typeof X!="string")throw new TypeError(X+" must be a string");Q=Q||{};const F=typeof Q.version=="number"?Q.version:2;if(F!==1&&F!==2)throw new TypeError(F+" must be 1 or 2");const R={method:X};if(F===2&&(R.jsonrpc="2.0"),S){if(typeof S!="object"&&!Array.isArray(S))throw new TypeError(S+" must be an object, array or omitted");R.params=S}if(typeof B>"u"){const G=typeof Q.generator=="function"?Q.generator:function(){return h()};R.id=G(R,Q)}else F===2&&B===null?Q.notificationIdNull&&(R.id=null):R.id=B;return R};ee.exports=P},66855:function(ee,J,A){"use strict";var h,P=A(48764).Buffer,X=A(64836);h={value:!0},J.Z=void 0;var S=X(A(64687)),B=X(A(17156)),Q=X(A(18698)),F=X(A(56690)),R=X(A(89728)),G=X(A(61655)),ke=X(A(94993)),oe=X(A(73808)),_=A(26729),ne=A(70395);function M(te){var ge=le();return function(){var Z=(0,oe.default)(te),be;if(ge){var qe=(0,oe.default)(this).constructor;be=Reflect.construct(Z,arguments,qe)}else be=Z.apply(this,arguments);return(0,ke.default)(this,be)}}function le(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var re=function(te,ge){var Ne={};for(var Z in te)Object.prototype.hasOwnProperty.call(te,Z)&&ge.indexOf(Z)<0&&(Ne[Z]=te[Z]);if(te!=null&&typeof Object.getOwnPropertySymbols=="function")for(var be=0,Z=Object.getOwnPropertySymbols(te);be<Z.length;be++)ge.indexOf(Z[be])<0&&Object.prototype.propertyIsEnumerable.call(te,Z[be])&&(Ne[Z[be]]=te[Z[be]]);return Ne},V=function(te){(0,G.default)(Ne,te);var ge=M(Ne);function Ne(Z){var be,qe=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"ws://localhost:8080",pe=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},Be=arguments.length>3?arguments[3]:void 0,xe=arguments.length>4?arguments[4]:void 0;(0,F.default)(this,Ne);var $=pe.autoconnect,U=$===void 0?!0:$,ie=pe.reconnect,se=ie===void 0?!0:ie,ye=pe.reconnect_interval,we=ye===void 0?1e3:ye,Ze=pe.max_reconnects,rt=Ze===void 0?5:Ze,me=re(pe,["autoconnect","reconnect","reconnect_interval","max_reconnects"]);return be=ge.call(this),be.webSocketFactory=Z,be.queue={},be.rpc_id=0,be.address=qe,be.autoconnect=U,be.ready=!1,be.reconnect=se,be.reconnect_timer_id=void 0,be.reconnect_interval=we,be.max_reconnects=rt,be.rest_options=me,be.current_reconnects=0,be.generate_request_id=Be||function(){return++be.rpc_id},xe?be.dataPack=xe:be.dataPack=new ne.DefaultDataPack,be.autoconnect&&be._connect(be.address,Object.assign({autoconnect:be.autoconnect,reconnect:be.reconnect,reconnect_interval:be.reconnect_interval,max_reconnects:be.max_reconnects},be.rest_options)),be}return(0,R.default)(Ne,[{key:"connect",value:function(){this.socket||this._connect(this.address,Object.assign({autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects},this.rest_options))}},{key:"call",value:function(be,qe,pe,Be){var xe=this;return!Be&&(0,Q.default)(pe)==="object"&&(Be=pe,pe=null),new Promise(function($,U){if(!xe.ready)return U(new Error("socket not ready"));var ie=xe.generate_request_id(be,qe),se={jsonrpc:"2.0",method:be,params:qe||void 0,id:ie};xe.socket.send(xe.dataPack.encode(se),Be,function(ye){if(ye)return U(ye);xe.queue[ie]={promise:[$,U]},pe&&(xe.queue[ie].timeout=setTimeout(function(){delete xe.queue[ie],U(new Error("reply timeout"))},pe))})})}},{key:"login",value:function(){var Z=(0,B.default)(S.default.mark(function qe(pe){var Be;return S.default.wrap(function($){for(;;)switch($.prev=$.next){case 0:return $.next=2,this.call("rpc.login",pe);case 2:if(Be=$.sent,Be){$.next=5;break}throw new Error("authentication failed");case 5:return $.abrupt("return",Be);case 6:case"end":return $.stop()}},qe,this)}));function be(qe){return Z.apply(this,arguments)}return be}()},{key:"listMethods",value:function(){var Z=(0,B.default)(S.default.mark(function qe(){return S.default.wrap(function(Be){for(;;)switch(Be.prev=Be.next){case 0:return Be.next=2,this.call("__listMethods");case 2:return Be.abrupt("return",Be.sent);case 3:case"end":return Be.stop()}},qe,this)}));function be(){return Z.apply(this,arguments)}return be}()},{key:"notify",value:function(be,qe){var pe=this;return new Promise(function(Be,xe){if(!pe.ready)return xe(new Error("socket not ready"));var $={jsonrpc:"2.0",method:be,params:qe};pe.socket.send(pe.dataPack.encode($),function(U){if(U)return xe(U);Be()})})}},{key:"subscribe",value:function(){var Z=(0,B.default)(S.default.mark(function qe(pe){var Be;return S.default.wrap(function($){for(;;)switch($.prev=$.next){case 0:return typeof pe=="string"&&(pe=[pe]),$.next=3,this.call("rpc.on",pe);case 3:if(Be=$.sent,!(typeof pe=="string"&&Be[pe]!=="ok")){$.next=6;break}throw new Error("Failed subscribing to an event '"+pe+"' with: "+Be[pe]);case 6:return $.abrupt("return",Be);case 7:case"end":return $.stop()}},qe,this)}));function be(qe){return Z.apply(this,arguments)}return be}()},{key:"unsubscribe",value:function(){var Z=(0,B.default)(S.default.mark(function qe(pe){var Be;return S.default.wrap(function($){for(;;)switch($.prev=$.next){case 0:return typeof pe=="string"&&(pe=[pe]),$.next=3,this.call("rpc.off",pe);case 3:if(Be=$.sent,!(typeof pe=="string"&&Be[pe]!=="ok")){$.next=6;break}throw new Error("Failed unsubscribing from an event with: "+Be);case 6:return $.abrupt("return",Be);case 7:case"end":return $.stop()}},qe,this)}));function be(qe){return Z.apply(this,arguments)}return be}()},{key:"close",value:function(be,qe){this.socket.close(be||1e3,qe)}},{key:"_connect",value:function(be,qe){var pe=this;clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(be,qe),this.socket.addEventListener("open",function(){pe.ready=!0,pe.emit("open"),pe.current_reconnects=0}),this.socket.addEventListener("message",function(Be){var xe=Be.data;xe instanceof ArrayBuffer&&(xe=P.from(xe).toString());try{xe=pe.dataPack.decode(xe)}catch{return}if(xe.notification&&pe.listeners(xe.notification).length){if(!Object.keys(xe.params).length)return pe.emit(xe.notification);var $=[xe.notification];if(xe.params.constructor===Object)$.push(xe.params);else for(var U=0;U<xe.params.length;U++)$.push(xe.params[U]);return Promise.resolve().then(function(){pe.emit.apply(pe,$)})}if(!pe.queue[xe.id])return xe.method&&xe.params?Promise.resolve().then(function(){pe.emit(xe.method,xe.params)}):void 0;"error"in xe=="result"in xe&&pe.queue[xe.id].promise[1](new Error('Server response malformed. Response must include either "result" or "error", but not both.')),pe.queue[xe.id].timeout&&clearTimeout(pe.queue[xe.id].timeout),xe.error?pe.queue[xe.id].promise[1](xe.error):pe.queue[xe.id].promise[0](xe.result),delete pe.queue[xe.id]}),this.socket.addEventListener("error",function(Be){return pe.emit("error",Be)}),this.socket.addEventListener("close",function(Be){var xe=Be.code,$=Be.reason;pe.ready&&setTimeout(function(){return pe.emit("close",xe,$)},0),pe.ready=!1,pe.socket=void 0,xe!==1e3&&(pe.current_reconnects++,pe.reconnect&&(pe.max_reconnects>pe.current_reconnects||pe.max_reconnects===0)&&(pe.reconnect_timer_id=setTimeout(function(){return pe._connect(be,qe)},pe.reconnect_interval)))})}}]),Ne}(_.EventEmitter);J.Z=V},89062:function(ee,J,A){"use strict";var h,P=A(64836);h={value:!0},J.Z=_;var X=P(A(56690)),S=P(A(89728)),B=P(A(61655)),Q=P(A(94993)),F=P(A(73808)),R=A(26729);function G(ne){var M=ke();return function(){var re=(0,F.default)(ne),V;if(M){var te=(0,F.default)(this).constructor;V=Reflect.construct(re,arguments,te)}else V=re.apply(this,arguments);return(0,Q.default)(this,V)}}function ke(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var oe=function(ne){(0,B.default)(le,ne);var M=G(le);function le(re,V,te){var ge;return(0,X.default)(this,le),ge=M.call(this),ge.socket=new window.WebSocket(re,te),ge.socket.onopen=function(){return ge.emit("open")},ge.socket.onmessage=function(Ne){return ge.emit("message",Ne.data)},ge.socket.onerror=function(Ne){return ge.emit("error",Ne)},ge.socket.onclose=function(Ne){ge.emit("close",Ne.code,Ne.reason)},ge}return(0,S.default)(le,[{key:"send",value:function(V,te,ge){var Ne=ge||te;try{this.socket.send(V),Ne()}catch(Z){Ne(Z)}}},{key:"close",value:function(V,te){this.socket.close(V,te)}},{key:"addEventListener",value:function(V,te,ge){this.socket.addEventListener(V,te,ge)}}]),le}(R.EventEmitter);function _(ne,M){return new oe(ne,M)}},70395:function(ee,J,A){"use strict";var h=A(64836);Object.defineProperty(J,"__esModule",{value:!0}),J.DefaultDataPack=void 0,J.createError=Q;var P=h(A(56690)),X=h(A(89728)),S=new Map([[-32e3,"Event not provided"],[-32600,"Invalid Request"],[-32601,"Method not found"],[-32602,"Invalid params"],[-32603,"Internal error"],[-32604,"Params not found"],[-32605,"Method forbidden"],[-32606,"Event forbidden"],[-32700,"Parse error"]]),B=function(){function F(){(0,P.default)(this,F)}return(0,X.default)(F,[{key:"encode",value:function(G){return JSON.stringify(G)}},{key:"decode",value:function(G){return JSON.parse(G)}}]),F}();J.DefaultDataPack=B;function Q(F,R){var G={code:F,message:S.get(F)||"Internal Server Error"};return R&&(G.data=R),G}},11379:function(ee,J){"use strict";function A(ne,M,le){return M<=ne&&ne<=le}function h(ne){if(ne===void 0)return{};if(ne===Object(ne))return ne;throw TypeError("Could not convert argument to dictionary")}function P(ne){for(var M=String(ne),le=M.length,re=0,V=[];re<le;){var te=M.charCodeAt(re);if(te<55296||te>57343)V.push(te);else if(56320<=te&&te<=57343)V.push(65533);else if(55296<=te&&te<=56319)if(re===le-1)V.push(65533);else{var ge=ne.charCodeAt(re+1);if(56320<=ge&&ge<=57343){var Ne=te&1023,Z=ge&1023;V.push(65536+(Ne<<10)+Z),re+=1}else V.push(65533)}re+=1}return V}function X(ne){for(var M="",le=0;le<ne.length;++le){var re=ne[le];re<=65535?M+=String.fromCharCode(re):(re-=65536,M+=String.fromCharCode((re>>10)+55296,(re&1023)+56320))}return M}var S=-1;function B(ne){this.tokens=[].slice.call(ne)}B.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():S},prepend:function(ne){if(Array.isArray(ne))for(var M=ne;M.length;)this.tokens.unshift(M.pop());else this.tokens.unshift(ne)},push:function(ne){if(Array.isArray(ne))for(var M=ne;M.length;)this.tokens.push(M.shift());else this.tokens.push(ne)}};var Q=-1;function F(ne,M){if(ne)throw TypeError("Decoder error");return M||65533}var R="utf-8";function G(ne,M){if(!(this instanceof G))return new G(ne,M);if(ne=ne!==void 0?String(ne).toLowerCase():R,ne!==R)throw new Error("Encoding not supported. Only utf-8 is supported");M=h(M),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=Boolean(M.fatal),this._ignoreBOM=Boolean(M.ignoreBOM),Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}G.prototype={decode:function(M,le){var re;typeof M=="object"&&M instanceof ArrayBuffer?re=new Uint8Array(M):typeof M=="object"&&"buffer"in M&&M.buffer instanceof ArrayBuffer?re=new Uint8Array(M.buffer,M.byteOffset,M.byteLength):re=new Uint8Array(0),le=h(le),this._streaming||(this._decoder=new oe({fatal:this._fatal}),this._BOMseen=!1),this._streaming=Boolean(le.stream);for(var V=new B(re),te=[],ge;!V.endOfStream()&&(ge=this._decoder.handler(V,V.read()),ge!==Q);)ge!==null&&(Array.isArray(ge)?te.push.apply(te,ge):te.push(ge));if(!this._streaming){do{if(ge=this._decoder.handler(V,V.read()),ge===Q)break;ge!==null&&(Array.isArray(ge)?te.push.apply(te,ge):te.push(ge))}while(!V.endOfStream());this._decoder=null}return te.length&&["utf-8"].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(te[0]===65279?(this._BOMseen=!0,te.shift()):this._BOMseen=!0),X(te)}};function ke(ne,M){if(!(this instanceof ke))return new ke(ne,M);if(ne=ne!==void 0?String(ne).toLowerCase():R,ne!==R)throw new Error("Encoding not supported. Only utf-8 is supported");M=h(M),this._streaming=!1,this._encoder=null,this._options={fatal:Boolean(M.fatal)},Object.defineProperty(this,"encoding",{value:"utf-8"})}ke.prototype={encode:function(M,le){M=M?String(M):"",le=h(le),this._streaming||(this._encoder=new _(this._options)),this._streaming=Boolean(le.stream);for(var re=[],V=new B(P(M)),te;!V.endOfStream()&&(te=this._encoder.handler(V,V.read()),te!==Q);)Array.isArray(te)?re.push.apply(re,te):re.push(te);if(!this._streaming){for(;te=this._encoder.handler(V,V.read()),te!==Q;)Array.isArray(te)?re.push.apply(re,te):re.push(te);this._encoder=null}return new Uint8Array(re)}};function oe(ne){var M=ne.fatal,le=0,re=0,V=0,te=128,ge=191;this.handler=function(Ne,Z){if(Z===S&&V!==0)return V=0,F(M);if(Z===S)return Q;if(V===0){if(A(Z,0,127))return Z;if(A(Z,194,223))V=1,le=Z-192;else if(A(Z,224,239))Z===224&&(te=160),Z===237&&(ge=159),V=2,le=Z-224;else if(A(Z,240,244))Z===240&&(te=144),Z===244&&(ge=143),V=3,le=Z-240;else return F(M);return le=le<<6*V,null}if(!A(Z,te,ge))return le=V=re=0,te=128,ge=191,Ne.prepend(Z),F(M);if(te=128,ge=191,re+=1,le+=Z-128<<6*(V-re),re!==V)return null;var be=le;return le=V=re=0,be}}function _(ne){var M=ne.fatal;this.handler=function(le,re){if(re===S)return Q;if(A(re,0,127))return re;var V,te;A(re,128,2047)?(V=1,te=192):A(re,2048,65535)?(V=2,te=224):A(re,65536,1114111)&&(V=3,te=240);for(var ge=[(re>>6*V)+te];V>0;){var Ne=re>>6*(V-1);ge.push(128|Ne&63),V-=1}return ge}}J.TextEncoder=ke,J.TextDecoder=G},55877:function(ee,J,A){var h=A(23570),P=A(71171),X=P;X.v1=h,X.v4=P,ee.exports=X},45327:function(ee){for(var J=[],A=0;A<256;++A)J[A]=(A+256).toString(16).substr(1);function h(P,X){var S=X||0,B=J;return[B[P[S++]],B[P[S++]],B[P[S++]],B[P[S++]],"-",B[P[S++]],B[P[S++]],"-",B[P[S++]],B[P[S++]],"-",B[P[S++]],B[P[S++]],"-",B[P[S++]],B[P[S++]],B[P[S++]],B[P[S++]],B[P[S++]],B[P[S++]]].join("")}ee.exports=h},85217:function(ee){var J=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof window.msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto);if(J){var A=new Uint8Array(16);ee.exports=function(){return J(A),A}}else{var h=new Array(16);ee.exports=function(){for(var X=0,S;X<16;X++)(X&3)===0&&(S=Math.random()*4294967296),h[X]=S>>>((X&3)<<3)&255;return h}}},23570:function(ee,J,A){var h=A(85217),P=A(45327),X,S,B=0,Q=0;function F(R,G,ke){var oe=G&&ke||0,_=G||[];R=R||{};var ne=R.node||X,M=R.clockseq!==void 0?R.clockseq:S;if(ne==null||M==null){var le=h();ne==null&&(ne=X=[le[0]|1,le[1],le[2],le[3],le[4],le[5]]),M==null&&(M=S=(le[6]<<8|le[7])&16383)}var re=R.msecs!==void 0?R.msecs:new Date().getTime(),V=R.nsecs!==void 0?R.nsecs:Q+1,te=re-B+(V-Q)/1e4;if(te<0&&R.clockseq===void 0&&(M=M+1&16383),(te<0||re>B)&&R.nsecs===void 0&&(V=0),V>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");B=re,Q=V,S=M,re+=122192928e5;var ge=((re&268435455)*1e4+V)%4294967296;_[oe++]=ge>>>24&255,_[oe++]=ge>>>16&255,_[oe++]=ge>>>8&255,_[oe++]=ge&255;var Ne=re/4294967296*1e4&268435455;_[oe++]=Ne>>>8&255,_[oe++]=Ne&255,_[oe++]=Ne>>>24&15|16,_[oe++]=Ne>>>16&255,_[oe++]=M>>>8|128,_[oe++]=M&255;for(var Z=0;Z<6;++Z)_[oe+Z]=ne[Z];return G||P(_)}ee.exports=F},71171:function(ee,J,A){var h=A(85217),P=A(45327);function X(S,B,Q){var F=B&&Q||0;typeof S=="string"&&(B=S==="binary"?new Array(16):null,S=null),S=S||{};var R=S.random||(S.rng||h)();if(R[6]=R[6]&15|64,R[8]=R[8]&63|128,B)for(var G=0;G<16;++G)B[F+G]=R[G];return B||P(R)}ee.exports=X},66115:function(ee){function J(A){if(A===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return A}ee.exports=J,ee.exports.__esModule=!0,ee.exports.default=ee.exports},17156:function(ee){function J(h,P,X,S,B,Q,F){try{var R=h[Q](F),G=R.value}catch(ke){X(ke);return}R.done?P(G):Promise.resolve(G).then(S,B)}function A(h){return function(){var P=this,X=arguments;return new Promise(function(S,B){var Q=h.apply(P,X);function F(G){J(Q,S,B,F,R,"next",G)}function R(G){J(Q,S,B,F,R,"throw",G)}F(void 0)})}}ee.exports=A,ee.exports.__esModule=!0,ee.exports.default=ee.exports},56690:function(ee){function J(A,h){if(!(A instanceof h))throw new TypeError("Cannot call a class as a function")}ee.exports=J,ee.exports.__esModule=!0,ee.exports.default=ee.exports},89728:function(ee,J,A){var h=A(64062);function P(S,B){for(var Q=0;Q<B.length;Q++){var F=B[Q];F.enumerable=F.enumerable||!1,F.configurable=!0,"value"in F&&(F.writable=!0),Object.defineProperty(S,h(F.key),F)}}function X(S,B,Q){return B&&P(S.prototype,B),Q&&P(S,Q),Object.defineProperty(S,"prototype",{writable:!1}),S}ee.exports=X,ee.exports.__esModule=!0,ee.exports.default=ee.exports},73808:function(ee){function J(A){return ee.exports=J=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(P){return P.__proto__||Object.getPrototypeOf(P)},ee.exports.__esModule=!0,ee.exports.default=ee.exports,J(A)}ee.exports=J,ee.exports.__esModule=!0,ee.exports.default=ee.exports},61655:function(ee,J,A){var h=A(6015);function P(X,S){if(typeof S!="function"&&S!==null)throw new TypeError("Super expression must either be null or a function");X.prototype=Object.create(S&&S.prototype,{constructor:{value:X,writable:!0,configurable:!0}}),Object.defineProperty(X,"prototype",{writable:!1}),S&&h(X,S)}ee.exports=P,ee.exports.__esModule=!0,ee.exports.default=ee.exports},64836:function(ee){function J(A){return A&&A.__esModule?A:{default:A}}ee.exports=J,ee.exports.__esModule=!0,ee.exports.default=ee.exports},94993:function(ee,J,A){var h=A(18698).default,P=A(66115);function X(S,B){if(B&&(h(B)==="object"||typeof B=="function"))return B;if(B!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return P(S)}ee.exports=X,ee.exports.__esModule=!0,ee.exports.default=ee.exports},17061:function(ee,J,A){var h=A(18698).default;function P(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ee.exports=P=function(){return S},ee.exports.__esModule=!0,ee.exports.default=ee.exports;var X,S={},B=Object.prototype,Q=B.hasOwnProperty,F=Object.defineProperty||function(me,ce,Se){me[ce]=Se.value},R=typeof Symbol=="function"?Symbol:{},G=R.iterator||"@@iterator",ke=R.asyncIterator||"@@asyncIterator",oe=R.toStringTag||"@@toStringTag";function _(me,ce,Se){return Object.defineProperty(me,ce,{value:Se,enumerable:!0,configurable:!0,writable:!0}),me[ce]}try{_({},"")}catch{_=function(Se,Fe,Xe){return Se[Fe]=Xe}}function ne(me,ce,Se,Fe){var Xe=ce&&ce.prototype instanceof Ne?ce:Ne,x=Object.create(Xe.prototype),c=new Ze(Fe||[]);return F(x,"_invoke",{value:ie(me,Se,c)}),x}function M(me,ce,Se){try{return{type:"normal",arg:me.call(ce,Se)}}catch(Fe){return{type:"throw",arg:Fe}}}S.wrap=ne;var le="suspendedStart",re="suspendedYield",V="executing",te="completed",ge={};function Ne(){}function Z(){}function be(){}var qe={};_(qe,G,function(){return this});var pe=Object.getPrototypeOf,Be=pe&&pe(pe(rt([])));Be&&Be!==B&&Q.call(Be,G)&&(qe=Be);var xe=be.prototype=Ne.prototype=Object.create(qe);function $(me){["next","throw","return"].forEach(function(ce){_(me,ce,function(Se){return this._invoke(ce,Se)})})}function U(me,ce){function Se(Xe,x,c,l){var y=M(me[Xe],me,x);if(y.type!=="throw"){var W=y.arg,E=W.value;return E&&h(E)=="object"&&Q.call(E,"__await")?ce.resolve(E.__await).then(function(Ae){Se("next",Ae,c,l)},function(Ae){Se("throw",Ae,c,l)}):ce.resolve(E).then(function(Ae){W.value=Ae,c(W)},function(Ae){return Se("throw",Ae,c,l)})}l(y.arg)}var Fe;F(this,"_invoke",{value:function(x,c){function l(){return new ce(function(y,W){Se(x,c,y,W)})}return Fe=Fe?Fe.then(l,l):l()}})}function ie(me,ce,Se){var Fe=le;return function(Xe,x){if(Fe===V)throw new Error("Generator is already running");if(Fe===te){if(Xe==="throw")throw x;return{value:X,done:!0}}for(Se.method=Xe,Se.arg=x;;){var c=Se.delegate;if(c){var l=se(c,Se);if(l){if(l===ge)continue;return l}}if(Se.method==="next")Se.sent=Se._sent=Se.arg;else if(Se.method==="throw"){if(Fe===le)throw Fe=te,Se.arg;Se.dispatchException(Se.arg)}else Se.method==="return"&&Se.abrupt("return",Se.arg);Fe=V;var y=M(me,ce,Se);if(y.type==="normal"){if(Fe=Se.done?te:re,y.arg===ge)continue;return{value:y.arg,done:Se.done}}y.type==="throw"&&(Fe=te,Se.method="throw",Se.arg=y.arg)}}}function se(me,ce){var Se=ce.method,Fe=me.iterator[Se];if(Fe===X)return ce.delegate=null,Se==="throw"&&me.iterator.return&&(ce.method="return",ce.arg=X,se(me,ce),ce.method==="throw")||Se!=="return"&&(ce.method="throw",ce.arg=new TypeError("The iterator does not provide a '"+Se+"' method")),ge;var Xe=M(Fe,me.iterator,ce.arg);if(Xe.type==="throw")return ce.method="throw",ce.arg=Xe.arg,ce.delegate=null,ge;var x=Xe.arg;return x?x.done?(ce[me.resultName]=x.value,ce.next=me.nextLoc,ce.method!=="return"&&(ce.method="next",ce.arg=X),ce.delegate=null,ge):x:(ce.method="throw",ce.arg=new TypeError("iterator result is not an object"),ce.delegate=null,ge)}function ye(me){var ce={tryLoc:me[0]};1 in me&&(ce.catchLoc=me[1]),2 in me&&(ce.finallyLoc=me[2],ce.afterLoc=me[3]),this.tryEntries.push(ce)}function we(me){var ce=me.completion||{};ce.type="normal",delete ce.arg,me.completion=ce}function Ze(me){this.tryEntries=[{tryLoc:"root"}],me.forEach(ye,this),this.reset(!0)}function rt(me){if(me||me===""){var ce=me[G];if(ce)return ce.call(me);if(typeof me.next=="function")return me;if(!isNaN(me.length)){var Se=-1,Fe=function Xe(){for(;++Se<me.length;)if(Q.call(me,Se))return Xe.value=me[Se],Xe.done=!1,Xe;return Xe.value=X,Xe.done=!0,Xe};return Fe.next=Fe}}throw new TypeError(h(me)+" is not iterable")}return Z.prototype=be,F(xe,"constructor",{value:be,configurable:!0}),F(be,"constructor",{value:Z,configurable:!0}),Z.displayName=_(be,oe,"GeneratorFunction"),S.isGeneratorFunction=function(me){var ce=typeof me=="function"&&me.constructor;return!!ce&&(ce===Z||(ce.displayName||ce.name)==="GeneratorFunction")},S.mark=function(me){return Object.setPrototypeOf?Object.setPrototypeOf(me,be):(me.__proto__=be,_(me,oe,"GeneratorFunction")),me.prototype=Object.create(xe),me},S.awrap=function(me){return{__await:me}},$(U.prototype),_(U.prototype,ke,function(){return this}),S.AsyncIterator=U,S.async=function(me,ce,Se,Fe,Xe){Xe===void 0&&(Xe=Promise);var x=new U(ne(me,ce,Se,Fe),Xe);return S.isGeneratorFunction(ce)?x:x.next().then(function(c){return c.done?c.value:x.next()})},$(xe),_(xe,oe,"Generator"),_(xe,G,function(){return this}),_(xe,"toString",function(){return"[object Generator]"}),S.keys=function(me){var ce=Object(me),Se=[];for(var Fe in ce)Se.push(Fe);return Se.reverse(),function Xe(){for(;Se.length;){var x=Se.pop();if(x in ce)return Xe.value=x,Xe.done=!1,Xe}return Xe.done=!0,Xe}},S.values=rt,Ze.prototype={constructor:Ze,reset:function(ce){if(this.prev=0,this.next=0,this.sent=this._sent=X,this.done=!1,this.delegate=null,this.method="next",this.arg=X,this.tryEntries.forEach(we),!ce)for(var Se in this)Se.charAt(0)==="t"&&Q.call(this,Se)&&!isNaN(+Se.slice(1))&&(this[Se]=X)},stop:function(){this.done=!0;var ce=this.tryEntries[0].completion;if(ce.type==="throw")throw ce.arg;return this.rval},dispatchException:function(ce){if(this.done)throw ce;var Se=this;function Fe(W,E){return c.type="throw",c.arg=ce,Se.next=W,E&&(Se.method="next",Se.arg=X),!!E}for(var Xe=this.tryEntries.length-1;Xe>=0;--Xe){var x=this.tryEntries[Xe],c=x.completion;if(x.tryLoc==="root")return Fe("end");if(x.tryLoc<=this.prev){var l=Q.call(x,"catchLoc"),y=Q.call(x,"finallyLoc");if(l&&y){if(this.prev<x.catchLoc)return Fe(x.catchLoc,!0);if(this.prev<x.finallyLoc)return Fe(x.finallyLoc)}else if(l){if(this.prev<x.catchLoc)return Fe(x.catchLoc,!0)}else{if(!y)throw new Error("try statement without catch or finally");if(this.prev<x.finallyLoc)return Fe(x.finallyLoc)}}}},abrupt:function(ce,Se){for(var Fe=this.tryEntries.length-1;Fe>=0;--Fe){var Xe=this.tryEntries[Fe];if(Xe.tryLoc<=this.prev&&Q.call(Xe,"finallyLoc")&&this.prev<Xe.finallyLoc){var x=Xe;break}}x&&(ce==="break"||ce==="continue")&&x.tryLoc<=Se&&Se<=x.finallyLoc&&(x=null);var c=x?x.completion:{};return c.type=ce,c.arg=Se,x?(this.method="next",this.next=x.finallyLoc,ge):this.complete(c)},complete:function(ce,Se){if(ce.type==="throw")throw ce.arg;return ce.type==="break"||ce.type==="continue"?this.next=ce.arg:ce.type==="return"?(this.rval=this.arg=ce.arg,this.method="return",this.next="end"):ce.type==="normal"&&Se&&(this.next=Se),ge},finish:function(ce){for(var Se=this.tryEntries.length-1;Se>=0;--Se){var Fe=this.tryEntries[Se];if(Fe.finallyLoc===ce)return this.complete(Fe.completion,Fe.afterLoc),we(Fe),ge}},catch:function(ce){for(var Se=this.tryEntries.length-1;Se>=0;--Se){var Fe=this.tryEntries[Se];if(Fe.tryLoc===ce){var Xe=Fe.completion;if(Xe.type==="throw"){var x=Xe.arg;we(Fe)}return x}}throw new Error("illegal catch attempt")},delegateYield:function(ce,Se,Fe){return this.delegate={iterator:rt(ce),resultName:Se,nextLoc:Fe},this.method==="next"&&(this.arg=X),ge}},S}ee.exports=P,ee.exports.__esModule=!0,ee.exports.default=ee.exports},6015:function(ee){function J(A,h){return ee.exports=J=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(X,S){return X.__proto__=S,X},ee.exports.__esModule=!0,ee.exports.default=ee.exports,J(A,h)}ee.exports=J,ee.exports.__esModule=!0,ee.exports.default=ee.exports},95036:function(ee,J,A){var h=A(18698).default;function P(X,S){if(h(X)!=="object"||X===null)return X;var B=X[Symbol.toPrimitive];if(B!==void 0){var Q=B.call(X,S||"default");if(h(Q)!=="object")return Q;throw new TypeError("@@toPrimitive must return a primitive value.")}return(S==="string"?String:Number)(X)}ee.exports=P,ee.exports.__esModule=!0,ee.exports.default=ee.exports},64062:function(ee,J,A){var h=A(18698).default,P=A(95036);function X(S){var B=P(S,"string");return h(B)==="symbol"?B:String(B)}ee.exports=X,ee.exports.__esModule=!0,ee.exports.default=ee.exports},18698:function(ee){function J(A){return ee.exports=J=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(h){return typeof h}:function(h){return h&&typeof Symbol=="function"&&h.constructor===Symbol&&h!==Symbol.prototype?"symbol":typeof h},ee.exports.__esModule=!0,ee.exports.default=ee.exports,J(A)}ee.exports=J,ee.exports.__esModule=!0,ee.exports.default=ee.exports},64687:function(ee,J,A){var h=A(17061)();ee.exports=h;try{regeneratorRuntime=h}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=h:Function("r","regeneratorRuntime = r")(h)}},75101:function(ee,J,A){"use strict";A.d(J,{Xg:function(){return Fe},ZL:function(){return x},AW:function(){return F}});var h=A(39386),P=A(40475);const X=c=>{const l=c.decode.bind(c),y=c.encode.bind(c);return{decode:l,encode:y}};var S=A(48764).Buffer;const B=c=>l=>{const y=(0,h.Ik)(c,l),{encode:W,decode:E}=X(y),Ae=y;return Ae.decode=(ze,Je)=>{const dt=E(ze,Je);return(0,P.oU)(S.from(dt))},Ae.encode=(ze,Je,dt)=>{const Vt=(0,P.k$)(ze,c);return W(Vt,Je,dt)},Ae},Q=c=>l=>{const y=(0,h.Ik)(c,l),{encode:W,decode:E}=X(y),Ae=y;return Ae.decode=(ze,Je)=>{const dt=E(ze,Je);return(0,P.Q5)(S.from(dt))},Ae.encode=(ze,Je,dt)=>{const Vt=(0,P.zP)(ze,c);return W(Vt,Je,dt)},Ae},F=B(8),R=Q(8),G=B(16),ke=Q(16),oe=B(24),_=Q(24),ne=B(32),M=Q(32);var le=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,re=Math.ceil,V=Math.floor,te="[BigNumber Error] ",ge=te+"Number primitive has more than 15 significant digits: ",Ne=1e14,Z=14,be=9007199254740991,qe=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],pe=1e7,Be=1e9;function xe(c){var l,y,W,E=Ee.prototype={constructor:Ee,toString:null,valueOf:null},Ae=new Ee(1),ze=20,Je=4,dt=-7,Vt=21,bn=-1e7,tn=1e7,mn=!1,Pn=1,wn=0,yr={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},Tn="0123456789abcdefghijklmnopqrstuvwxyz",br=!0;function Ee(f,p){var m,K,I,L,Y,v,T,H,z=this;if(!(z instanceof Ee))return new Ee(f,p);if(p==null){if(f&&f._isBigNumber===!0){z.s=f.s,!f.c||f.e>tn?z.c=z.e=null:f.e<bn?z.c=[z.e=0]:(z.e=f.e,z.c=f.c.slice());return}if((v=typeof f=="number")&&f*0==0){if(z.s=1/f<0?(f=-f,-1):1,f===~~f){for(L=0,Y=f;Y>=10;Y/=10,L++);L>tn?z.c=z.e=null:(z.e=L,z.c=[f]);return}H=String(f)}else{if(!le.test(H=String(f)))return W(z,H,v);z.s=H.charCodeAt(0)==45?(H=H.slice(1),-1):1}(L=H.indexOf("."))>-1&&(H=H.replace(".","")),(Y=H.search(/e/i))>0?(L<0&&(L=Y),L+=+H.slice(Y+1),H=H.substring(0,Y)):L<0&&(L=H.length)}else{if(se(p,2,Tn.length,"Base"),p==10&&br)return z=new Ee(f),$e(z,ze+z.e+1,Je);if(H=String(f),v=typeof f=="number"){if(f*0!=0)return W(z,H,v,p);if(z.s=1/f<0?(H=H.slice(1),-1):1,Ee.DEBUG&&H.replace(/^0\.0*|\./,"").length>15)throw Error(ge+f)}else z.s=H.charCodeAt(0)===45?(H=H.slice(1),-1):1;for(m=Tn.slice(0,p),L=Y=0,T=H.length;Y<T;Y++)if(m.indexOf(K=H.charAt(Y))<0){if(K=="."){if(Y>L){L=T;continue}}else if(!I&&(H==H.toUpperCase()&&(H=H.toLowerCase())||H==H.toLowerCase()&&(H=H.toUpperCase()))){I=!0,Y=-1,L=0;continue}return W(z,String(f),v,p)}v=!1,H=y(H,p,10,z.s),(L=H.indexOf("."))>-1?H=H.replace(".",""):L=H.length}for(Y=0;H.charCodeAt(Y)===48;Y++);for(T=H.length;H.charCodeAt(--T)===48;);if(H=H.slice(Y,++T)){if(T-=Y,v&&Ee.DEBUG&&T>15&&(f>be||f!==V(f)))throw Error(ge+z.s*f);if((L=L-Y-1)>tn)z.c=z.e=null;else if(L<bn)z.c=[z.e=0];else{if(z.e=L,z.c=[],Y=(L+1)%Z,L<0&&(Y+=Z),Y<T){for(Y&&z.c.push(+H.slice(0,Y)),T-=Z;Y<T;)z.c.push(+H.slice(Y,Y+=Z));Y=Z-(H=H.slice(Y)).length}else Y-=T;for(;Y--;H+="0");z.c.push(+H)}}else z.c=[z.e=0]}Ee.clone=xe,Ee.ROUND_UP=0,Ee.ROUND_DOWN=1,Ee.ROUND_CEIL=2,Ee.ROUND_FLOOR=3,Ee.ROUND_HALF_UP=4,Ee.ROUND_HALF_DOWN=5,Ee.ROUND_HALF_EVEN=6,Ee.ROUND_HALF_CEIL=7,Ee.ROUND_HALF_FLOOR=8,Ee.EUCLID=9,Ee.config=Ee.set=function(f){var p,m;if(f!=null)if(typeof f=="object"){if(f.hasOwnProperty(p="DECIMAL_PLACES")&&(m=f[p],se(m,0,Be,p),ze=m),f.hasOwnProperty(p="ROUNDING_MODE")&&(m=f[p],se(m,0,8,p),Je=m),f.hasOwnProperty(p="EXPONENTIAL_AT")&&(m=f[p],m&&m.pop?(se(m[0],-Be,0,p),se(m[1],0,Be,p),dt=m[0],Vt=m[1]):(se(m,-Be,Be,p),dt=-(Vt=m<0?-m:m))),f.hasOwnProperty(p="RANGE"))if(m=f[p],m&&m.pop)se(m[0],-Be,-1,p),se(m[1],1,Be,p),bn=m[0],tn=m[1];else if(se(m,-Be,Be,p),m)bn=-(tn=m<0?-m:m);else throw Error(te+p+" cannot be zero: "+m);if(f.hasOwnProperty(p="CRYPTO"))if(m=f[p],m===!!m)if(m)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))mn=m;else throw mn=!m,Error(te+"crypto unavailable");else mn=m;else throw Error(te+p+" not true or false: "+m);if(f.hasOwnProperty(p="MODULO_MODE")&&(m=f[p],se(m,0,9,p),Pn=m),f.hasOwnProperty(p="POW_PRECISION")&&(m=f[p],se(m,0,Be,p),wn=m),f.hasOwnProperty(p="FORMAT"))if(m=f[p],typeof m=="object")yr=m;else throw Error(te+p+" not an object: "+m);if(f.hasOwnProperty(p="ALPHABET"))if(m=f[p],typeof m=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(m))br=m.slice(0,10)=="0123456789",Tn=m;else throw Error(te+p+" invalid: "+m)}else throw Error(te+"Object expected: "+f);return{DECIMAL_PLACES:ze,ROUNDING_MODE:Je,EXPONENTIAL_AT:[dt,Vt],RANGE:[bn,tn],CRYPTO:mn,MODULO_MODE:Pn,POW_PRECISION:wn,FORMAT:yr,ALPHABET:Tn}},Ee.isBigNumber=function(f){if(!f||f._isBigNumber!==!0)return!1;if(!Ee.DEBUG)return!0;var p,m,K=f.c,I=f.e,L=f.s;e:if({}.toString.call(K)=="[object Array]"){if((L===1||L===-1)&&I>=-Be&&I<=Be&&I===V(I)){if(K[0]===0){if(I===0&&K.length===1)return!0;break e}if(p=(I+1)%Z,p<1&&(p+=Z),String(K[0]).length==p){for(p=0;p<K.length;p++)if(m=K[p],m<0||m>=Ne||m!==V(m))break e;if(m!==0)return!0}}}else if(K===null&&I===null&&(L===null||L===1||L===-1))return!0;throw Error(te+"Invalid BigNumber: "+f)},Ee.maximum=Ee.max=function(){return Hr(arguments,-1)},Ee.minimum=Ee.min=function(){return Hr(arguments,1)},Ee.random=function(){var f=9007199254740992,p=Math.random()*f&2097151?function(){return V(Math.random()*f)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(m){var K,I,L,Y,v,T=0,H=[],z=new Ee(Ae);if(m==null?m=ze:se(m,0,Be),Y=re(m/Z),mn)if(crypto.getRandomValues){for(K=crypto.getRandomValues(new Uint32Array(Y*=2));T<Y;)v=K[T]*131072+(K[T+1]>>>11),v>=9e15?(I=crypto.getRandomValues(new Uint32Array(2)),K[T]=I[0],K[T+1]=I[1]):(H.push(v%1e14),T+=2);T=Y/2}else if(crypto.randomBytes){for(K=crypto.randomBytes(Y*=7);T<Y;)v=(K[T]&31)*281474976710656+K[T+1]*1099511627776+K[T+2]*4294967296+K[T+3]*16777216+(K[T+4]<<16)+(K[T+5]<<8)+K[T+6],v>=9e15?crypto.randomBytes(7).copy(K,T):(H.push(v%1e14),T+=7);T=Y/7}else throw mn=!1,Error(te+"crypto unavailable");if(!mn)for(;T<Y;)v=p(),v<9e15&&(H[T++]=v%1e14);for(Y=H[--T],m%=Z,Y&&m&&(v=qe[Z-m],H[T]=V(Y/v)*v);H[T]===0;H.pop(),T--);if(T<0)H=[L=0];else{for(L=-1;H[0]===0;H.splice(0,1),L-=Z);for(T=1,v=H[0];v>=10;v/=10,T++);T<Z&&(L-=Z-T)}return z.e=L,z.c=H,z}}(),Ee.sum=function(){for(var f=1,p=arguments,m=new Ee(p[0]);f<p.length;)m=m.plus(p[f++]);return m},y=function(){var f="0123456789";function p(m,K,I,L){for(var Y,v=[0],T,H=0,z=m.length;H<z;){for(T=v.length;T--;v[T]*=K);for(v[0]+=L.indexOf(m.charAt(H++)),Y=0;Y<v.length;Y++)v[Y]>I-1&&(v[Y+1]==null&&(v[Y+1]=0),v[Y+1]+=v[Y]/I|0,v[Y]%=I)}return v.reverse()}return function(m,K,I,L,Y){var v,T,H,z,ae,We,Ge,at,Bt=m.indexOf("."),_t=ze,ut=Je;for(Bt>=0&&(z=wn,wn=0,m=m.replace(".",""),at=new Ee(K),We=at.pow(m.length-Bt),wn=z,at.c=p(Ze(U(We.c),We.e,"0"),10,I,f),at.e=at.c.length),Ge=p(m,K,I,Y?(v=Tn,f):(v=f,Tn)),H=z=Ge.length;Ge[--z]==0;Ge.pop());if(!Ge[0])return v.charAt(0);if(Bt<0?--H:(We.c=Ge,We.e=H,We.s=L,We=l(We,at,_t,ut,I),Ge=We.c,ae=We.r,H=We.e),T=H+_t+1,Bt=Ge[T],z=I/2,ae=ae||T<0||Ge[T+1]!=null,ae=ut<4?(Bt!=null||ae)&&(ut==0||ut==(We.s<0?3:2)):Bt>z||Bt==z&&(ut==4||ae||ut==6&&Ge[T-1]&1||ut==(We.s<0?8:7)),T<1||!Ge[0])m=ae?Ze(v.charAt(1),-_t,v.charAt(0)):v.charAt(0);else{if(Ge.length=T,ae)for(--I;++Ge[--T]>I;)Ge[T]=0,T||(++H,Ge=[1].concat(Ge));for(z=Ge.length;!Ge[--z];);for(Bt=0,m="";Bt<=z;m+=v.charAt(Ge[Bt++]));m=Ze(m,H,v.charAt(0))}return m}}(),l=function(){function f(K,I,L){var Y,v,T,H,z=0,ae=K.length,We=I%pe,Ge=I/pe|0;for(K=K.slice();ae--;)T=K[ae]%pe,H=K[ae]/pe|0,Y=Ge*T+H*We,v=We*T+Y%pe*pe+z,z=(v/L|0)+(Y/pe|0)+Ge*H,K[ae]=v%L;return z&&(K=[z].concat(K)),K}function p(K,I,L,Y){var v,T;if(L!=Y)T=L>Y?1:-1;else for(v=T=0;v<L;v++)if(K[v]!=I[v]){T=K[v]>I[v]?1:-1;break}return T}function m(K,I,L,Y){for(var v=0;L--;)K[L]-=v,v=K[L]<I[L]?1:0,K[L]=v*Y+K[L]-I[L];for(;!K[0]&&K.length>1;K.splice(0,1));}return function(K,I,L,Y,v){var T,H,z,ae,We,Ge,at,Bt,_t,ut,pt,Tt,cn,kn,Sn,Qt,zn,gt=K.s==I.s?1:-1,Ot=K.c,Rt=I.c;if(!Ot||!Ot[0]||!Rt||!Rt[0])return new Ee(!K.s||!I.s||(Ot?Rt&&Ot[0]==Rt[0]:!Rt)?NaN:Ot&&Ot[0]==0||!Rt?gt*0:gt/0);for(Bt=new Ee(gt),_t=Bt.c=[],H=K.e-I.e,gt=L+H+1,v||(v=Ne,H=$(K.e/Z)-$(I.e/Z),gt=gt/Z|0),z=0;Rt[z]==(Ot[z]||0);z++);if(Rt[z]>(Ot[z]||0)&&H--,gt<0)_t.push(1),ae=!0;else{for(kn=Ot.length,Qt=Rt.length,z=0,gt+=2,We=V(v/(Rt[0]+1)),We>1&&(Rt=f(Rt,We,v),Ot=f(Ot,We,v),Qt=Rt.length,kn=Ot.length),cn=Qt,ut=Ot.slice(0,Qt),pt=ut.length;pt<Qt;ut[pt++]=0);zn=Rt.slice(),zn=[0].concat(zn),Sn=Rt[0],Rt[1]>=v/2&&Sn++;do{if(We=0,T=p(Rt,ut,Qt,pt),T<0){if(Tt=ut[0],Qt!=pt&&(Tt=Tt*v+(ut[1]||0)),We=V(Tt/Sn),We>1)for(We>=v&&(We=v-1),Ge=f(Rt,We,v),at=Ge.length,pt=ut.length;p(Ge,ut,at,pt)==1;)We--,m(Ge,Qt<at?zn:Rt,at,v),at=Ge.length,T=1;else We==0&&(T=We=1),Ge=Rt.slice(),at=Ge.length;if(at<pt&&(Ge=[0].concat(Ge)),m(ut,Ge,pt,v),pt=ut.length,T==-1)for(;p(Rt,ut,Qt,pt)<1;)We++,m(ut,Qt<pt?zn:Rt,pt,v),pt=ut.length}else T===0&&(We++,ut=[0]);_t[z++]=We,ut[0]?ut[pt++]=Ot[cn]||0:(ut=[Ot[cn]],pt=1)}while((cn++<kn||ut[0]!=null)&&gt--);ae=ut[0]!=null,_t[0]||_t.splice(0,1)}if(v==Ne){for(z=1,gt=_t[0];gt>=10;gt/=10,z++);$e(Bt,L+(Bt.e=z+H*Z-1)+1,Y,ae)}else Bt.e=H,Bt.r=+ae;return Bt}}();function mr(f,p,m,K){var I,L,Y,v,T;if(m==null?m=Je:se(m,0,8),!f.c)return f.toString();if(I=f.c[0],Y=f.e,p==null)T=U(f.c),T=K==1||K==2&&(Y<=dt||Y>=Vt)?we(T,Y):Ze(T,Y,"0");else if(f=$e(new Ee(f),p,m),L=f.e,T=U(f.c),v=T.length,K==1||K==2&&(p<=L||L<=dt)){for(;v<p;T+="0",v++);T=we(T,L)}else if(p-=Y,T=Ze(T,L,"0"),L+1>v){if(--p>0)for(T+=".";p--;T+="0");}else if(p+=L-v,p>0)for(L+1==v&&(T+=".");p--;T+="0");return f.s<0&&I?"-"+T:T}function Hr(f,p){for(var m,K,I=1,L=new Ee(f[0]);I<f.length;I++)K=new Ee(f[I]),(!K.s||(m=ie(L,K))===p||m===0&&L.s===p)&&(L=K);return L}function wr(f,p,m){for(var K=1,I=p.length;!p[--I];p.pop());for(I=p[0];I>=10;I/=10,K++);return(m=K+m*Z-1)>tn?f.c=f.e=null:m<bn?f.c=[f.e=0]:(f.e=m,f.c=p),f}W=function(){var f=/^(-?)0([xbo])(?=\w[\w.]*$)/i,p=/^([^.]+)\.$/,m=/^\.([^.]+)$/,K=/^-?(Infinity|NaN)$/,I=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(L,Y,v,T){var H,z=v?Y:Y.replace(I,"");if(K.test(z))L.s=isNaN(z)?null:z<0?-1:1;else{if(!v&&(z=z.replace(f,function(ae,We,Ge){return H=(Ge=Ge.toLowerCase())=="x"?16:Ge=="b"?2:8,!T||T==H?We:ae}),T&&(H=T,z=z.replace(p,"$1").replace(m,"0.$1")),Y!=z))return new Ee(z,H);if(Ee.DEBUG)throw Error(te+"Not a"+(T?" base "+T:"")+" number: "+Y);L.s=null}L.c=L.e=null}}();function $e(f,p,m,K){var I,L,Y,v,T,H,z,ae=f.c,We=qe;if(ae){e:{for(I=1,v=ae[0];v>=10;v/=10,I++);if(L=p-I,L<0)L+=Z,Y=p,T=ae[H=0],z=V(T/We[I-Y-1]%10);else if(H=re((L+1)/Z),H>=ae.length)if(K){for(;ae.length<=H;ae.push(0));T=z=0,I=1,L%=Z,Y=L-Z+1}else break e;else{for(T=v=ae[H],I=1;v>=10;v/=10,I++);L%=Z,Y=L-Z+I,z=Y<0?0:V(T/We[I-Y-1]%10)}if(K=K||p<0||ae[H+1]!=null||(Y<0?T:T%We[I-Y-1]),K=m<4?(z||K)&&(m==0||m==(f.s<0?3:2)):z>5||z==5&&(m==4||K||m==6&&(L>0?Y>0?T/We[I-Y]:0:ae[H-1])%10&1||m==(f.s<0?8:7)),p<1||!ae[0])return ae.length=0,K?(p-=f.e+1,ae[0]=We[(Z-p%Z)%Z],f.e=-p||0):ae[0]=f.e=0,f;if(L==0?(ae.length=H,v=1,H--):(ae.length=H+1,v=We[Z-L],ae[H]=Y>0?V(T/We[I-Y]%We[Y])*v:0),K)for(;;)if(H==0){for(L=1,Y=ae[0];Y>=10;Y/=10,L++);for(Y=ae[0]+=v,v=1;Y>=10;Y/=10,v++);L!=v&&(f.e++,ae[0]==Ne&&(ae[0]=1));break}else{if(ae[H]+=v,ae[H]!=Ne)break;ae[H--]=0,v=1}for(L=ae.length;ae[--L]===0;ae.pop());}f.e>tn?f.c=f.e=null:f.e<bn&&(f.c=[f.e=0])}return f}function fn(f){var p,m=f.e;return m===null?f.toString():(p=U(f.c),p=m<=dt||m>=Vt?we(p,m):Ze(p,m,"0"),f.s<0?"-"+p:p)}return E.absoluteValue=E.abs=function(){var f=new Ee(this);return f.s<0&&(f.s=1),f},E.comparedTo=function(f,p){return ie(this,new Ee(f,p))},E.decimalPlaces=E.dp=function(f,p){var m,K,I,L=this;if(f!=null)return se(f,0,Be),p==null?p=Je:se(p,0,8),$e(new Ee(L),f+L.e+1,p);if(!(m=L.c))return null;if(K=((I=m.length-1)-$(this.e/Z))*Z,I=m[I])for(;I%10==0;I/=10,K--);return K<0&&(K=0),K},E.dividedBy=E.div=function(f,p){return l(this,new Ee(f,p),ze,Je)},E.dividedToIntegerBy=E.idiv=function(f,p){return l(this,new Ee(f,p),0,1)},E.exponentiatedBy=E.pow=function(f,p){var m,K,I,L,Y,v,T,H,z,ae=this;if(f=new Ee(f),f.c&&!f.isInteger())throw Error(te+"Exponent not an integer: "+fn(f));if(p!=null&&(p=new Ee(p)),v=f.e>14,!ae.c||!ae.c[0]||ae.c[0]==1&&!ae.e&&ae.c.length==1||!f.c||!f.c[0])return z=new Ee(Math.pow(+fn(ae),v?f.s*(2-ye(f)):+fn(f))),p?z.mod(p):z;if(T=f.s<0,p){if(p.c?!p.c[0]:!p.s)return new Ee(NaN);K=!T&&ae.isInteger()&&p.isInteger(),K&&(ae=ae.mod(p))}else{if(f.e>9&&(ae.e>0||ae.e<-1||(ae.e==0?ae.c[0]>1||v&&ae.c[1]>=24e7:ae.c[0]<8e13||v&&ae.c[0]<=9999975e7)))return L=ae.s<0&&ye(f)?-0:0,ae.e>-1&&(L=1/L),new Ee(T?1/L:L);wn&&(L=re(wn/Z+2))}for(v?(m=new Ee(.5),T&&(f.s=1),H=ye(f)):(I=Math.abs(+fn(f)),H=I%2),z=new Ee(Ae);;){if(H){if(z=z.times(ae),!z.c)break;L?z.c.length>L&&(z.c.length=L):K&&(z=z.mod(p))}if(I){if(I=V(I/2),I===0)break;H=I%2}else if(f=f.times(m),$e(f,f.e+1,1),f.e>14)H=ye(f);else{if(I=+fn(f),I===0)break;H=I%2}ae=ae.times(ae),L?ae.c&&ae.c.length>L&&(ae.c.length=L):K&&(ae=ae.mod(p))}return K?z:(T&&(z=Ae.div(z)),p?z.mod(p):L?$e(z,wn,Je,Y):z)},E.integerValue=function(f){var p=new Ee(this);return f==null?f=Je:se(f,0,8),$e(p,p.e+1,f)},E.isEqualTo=E.eq=function(f,p){return ie(this,new Ee(f,p))===0},E.isFinite=function(){return!!this.c},E.isGreaterThan=E.gt=function(f,p){return ie(this,new Ee(f,p))>0},E.isGreaterThanOrEqualTo=E.gte=function(f,p){return(p=ie(this,new Ee(f,p)))===1||p===0},E.isInteger=function(){return!!this.c&&$(this.e/Z)>this.c.length-2},E.isLessThan=E.lt=function(f,p){return ie(this,new Ee(f,p))<0},E.isLessThanOrEqualTo=E.lte=function(f,p){return(p=ie(this,new Ee(f,p)))===-1||p===0},E.isNaN=function(){return!this.s},E.isNegative=function(){return this.s<0},E.isPositive=function(){return this.s>0},E.isZero=function(){return!!this.c&&this.c[0]==0},E.minus=function(f,p){var m,K,I,L,Y=this,v=Y.s;if(f=new Ee(f,p),p=f.s,!v||!p)return new Ee(NaN);if(v!=p)return f.s=-p,Y.plus(f);var T=Y.e/Z,H=f.e/Z,z=Y.c,ae=f.c;if(!T||!H){if(!z||!ae)return z?(f.s=-p,f):new Ee(ae?Y:NaN);if(!z[0]||!ae[0])return ae[0]?(f.s=-p,f):new Ee(z[0]?Y:Je==3?-0:0)}if(T=$(T),H=$(H),z=z.slice(),v=T-H){for((L=v<0)?(v=-v,I=z):(H=T,I=ae),I.reverse(),p=v;p--;I.push(0));I.reverse()}else for(K=(L=(v=z.length)<(p=ae.length))?v:p,v=p=0;p<K;p++)if(z[p]!=ae[p]){L=z[p]<ae[p];break}if(L&&(I=z,z=ae,ae=I,f.s=-f.s),p=(K=ae.length)-(m=z.length),p>0)for(;p--;z[m++]=0);for(p=Ne-1;K>v;){if(z[--K]<ae[K]){for(m=K;m&&!z[--m];z[m]=p);--z[m],z[K]+=Ne}z[K]-=ae[K]}for(;z[0]==0;z.splice(0,1),--H);return z[0]?wr(f,z,H):(f.s=Je==3?-1:1,f.c=[f.e=0],f)},E.modulo=E.mod=function(f,p){var m,K,I=this;return f=new Ee(f,p),!I.c||!f.s||f.c&&!f.c[0]?new Ee(NaN):!f.c||I.c&&!I.c[0]?new Ee(I):(Pn==9?(K=f.s,f.s=1,m=l(I,f,0,3),f.s=K,m.s*=K):m=l(I,f,0,Pn),f=I.minus(m.times(f)),!f.c[0]&&Pn==1&&(f.s=I.s),f)},E.multipliedBy=E.times=function(f,p){var m,K,I,L,Y,v,T,H,z,ae,We,Ge,at,Bt,_t,ut=this,pt=ut.c,Tt=(f=new Ee(f,p)).c;if(!pt||!Tt||!pt[0]||!Tt[0])return!ut.s||!f.s||pt&&!pt[0]&&!Tt||Tt&&!Tt[0]&&!pt?f.c=f.e=f.s=null:(f.s*=ut.s,!pt||!Tt?f.c=f.e=null:(f.c=[0],f.e=0)),f;for(K=$(ut.e/Z)+$(f.e/Z),f.s*=ut.s,T=pt.length,ae=Tt.length,T<ae&&(at=pt,pt=Tt,Tt=at,I=T,T=ae,ae=I),I=T+ae,at=[];I--;at.push(0));for(Bt=Ne,_t=pe,I=ae;--I>=0;){for(m=0,We=Tt[I]%_t,Ge=Tt[I]/_t|0,Y=T,L=I+Y;L>I;)H=pt[--Y]%_t,z=pt[Y]/_t|0,v=Ge*H+z*We,H=We*H+v%_t*_t+at[L]+m,m=(H/Bt|0)+(v/_t|0)+Ge*z,at[L--]=H%Bt;at[L]=m}return m?++K:at.splice(0,1),wr(f,at,K)},E.negated=function(){var f=new Ee(this);return f.s=-f.s||null,f},E.plus=function(f,p){var m,K=this,I=K.s;if(f=new Ee(f,p),p=f.s,!I||!p)return new Ee(NaN);if(I!=p)return f.s=-p,K.minus(f);var L=K.e/Z,Y=f.e/Z,v=K.c,T=f.c;if(!L||!Y){if(!v||!T)return new Ee(I/0);if(!v[0]||!T[0])return T[0]?f:new Ee(v[0]?K:I*0)}if(L=$(L),Y=$(Y),v=v.slice(),I=L-Y){for(I>0?(Y=L,m=T):(I=-I,m=v),m.reverse();I--;m.push(0));m.reverse()}for(I=v.length,p=T.length,I-p<0&&(m=T,T=v,v=m,p=I),I=0;p;)I=(v[--p]=v[p]+T[p]+I)/Ne|0,v[p]=Ne===v[p]?0:v[p]%Ne;return I&&(v=[I].concat(v),++Y),wr(f,v,Y)},E.precision=E.sd=function(f,p){var m,K,I,L=this;if(f!=null&&f!==!!f)return se(f,1,Be),p==null?p=Je:se(p,0,8),$e(new Ee(L),f,p);if(!(m=L.c))return null;if(I=m.length-1,K=I*Z+1,I=m[I]){for(;I%10==0;I/=10,K--);for(I=m[0];I>=10;I/=10,K++);}return f&&L.e+1>K&&(K=L.e+1),K},E.shiftedBy=function(f){return se(f,-be,be),this.times("1e"+f)},E.squareRoot=E.sqrt=function(){var f,p,m,K,I,L=this,Y=L.c,v=L.s,T=L.e,H=ze+4,z=new Ee("0.5");if(v!==1||!Y||!Y[0])return new Ee(!v||v<0&&(!Y||Y[0])?NaN:Y?L:1/0);if(v=Math.sqrt(+fn(L)),v==0||v==1/0?(p=U(Y),(p.length+T)%2==0&&(p+="0"),v=Math.sqrt(+p),T=$((T+1)/2)-(T<0||T%2),v==1/0?p="5e"+T:(p=v.toExponential(),p=p.slice(0,p.indexOf("e")+1)+T),m=new Ee(p)):m=new Ee(v+""),m.c[0]){for(T=m.e,v=T+H,v<3&&(v=0);;)if(I=m,m=z.times(I.plus(l(L,I,H,1))),U(I.c).slice(0,v)===(p=U(m.c)).slice(0,v))if(m.e<T&&--v,p=p.slice(v-3,v+1),p=="9999"||!K&&p=="4999"){if(!K&&($e(I,I.e+ze+2,0),I.times(I).eq(L))){m=I;break}H+=4,v+=4,K=1}else{(!+p||!+p.slice(1)&&p.charAt(0)=="5")&&($e(m,m.e+ze+2,1),f=!m.times(m).eq(L));break}}return $e(m,m.e+ze+1,Je,f)},E.toExponential=function(f,p){return f!=null&&(se(f,0,Be),f++),mr(this,f,p,1)},E.toFixed=function(f,p){return f!=null&&(se(f,0,Be),f=f+this.e+1),mr(this,f,p)},E.toFormat=function(f,p,m){var K,I=this;if(m==null)f!=null&&p&&typeof p=="object"?(m=p,p=null):f&&typeof f=="object"?(m=f,f=p=null):m=yr;else if(typeof m!="object")throw Error(te+"Argument not an object: "+m);if(K=I.toFixed(f,p),I.c){var L,Y=K.split("."),v=+m.groupSize,T=+m.secondaryGroupSize,H=m.groupSeparator||"",z=Y[0],ae=Y[1],We=I.s<0,Ge=We?z.slice(1):z,at=Ge.length;if(T&&(L=v,v=T,T=L,at-=L),v>0&&at>0){for(L=at%v||v,z=Ge.substr(0,L);L<at;L+=v)z+=H+Ge.substr(L,v);T>0&&(z+=H+Ge.slice(L)),We&&(z="-"+z)}K=ae?z+(m.decimalSeparator||"")+((T=+m.fractionGroupSize)?ae.replace(new RegExp("\\d{"+T+"}\\B","g"),"$&"+(m.fractionGroupSeparator||"")):ae):z}return(m.prefix||"")+K+(m.suffix||"")},E.toFraction=function(f){var p,m,K,I,L,Y,v,T,H,z,ae,We,Ge=this,at=Ge.c;if(f!=null&&(v=new Ee(f),!v.isInteger()&&(v.c||v.s!==1)||v.lt(Ae)))throw Error(te+"Argument "+(v.isInteger()?"out of range: ":"not an integer: ")+fn(v));if(!at)return new Ee(Ge);for(p=new Ee(Ae),H=m=new Ee(Ae),K=T=new Ee(Ae),We=U(at),L=p.e=We.length-Ge.e-1,p.c[0]=qe[(Y=L%Z)<0?Z+Y:Y],f=!f||v.comparedTo(p)>0?L>0?p:H:v,Y=tn,tn=1/0,v=new Ee(We),T.c[0]=0;z=l(v,p,0,1),I=m.plus(z.times(K)),I.comparedTo(f)!=1;)m=K,K=I,H=T.plus(z.times(I=H)),T=I,p=v.minus(z.times(I=p)),v=I;return I=l(f.minus(m),K,0,1),T=T.plus(I.times(H)),m=m.plus(I.times(K)),T.s=H.s=Ge.s,L=L*2,ae=l(H,K,L,Je).minus(Ge).abs().comparedTo(l(T,m,L,Je).minus(Ge).abs())<1?[H,K]:[T,m],tn=Y,ae},E.toNumber=function(){return+fn(this)},E.toPrecision=function(f,p){return f!=null&&se(f,1,Be),mr(this,f,p,2)},E.toString=function(f){var p,m=this,K=m.s,I=m.e;return I===null?K?(p="Infinity",K<0&&(p="-"+p)):p="NaN":(f==null?p=I<=dt||I>=Vt?we(U(m.c),I):Ze(U(m.c),I,"0"):f===10&&br?(m=$e(new Ee(m),ze+I+1,Je),p=Ze(U(m.c),m.e,"0")):(se(f,2,Tn.length,"Base"),p=y(Ze(U(m.c),I,"0"),10,f,K,!0)),K<0&&m.c[0]&&(p="-"+p)),p},E.valueOf=E.toJSON=function(){return fn(this)},E._isBigNumber=!0,E[Symbol.toStringTag]="BigNumber",E[Symbol.for("nodejs.util.inspect.custom")]=E.valueOf,c!=null&&Ee.set(c),Ee}function $(c){var l=c|0;return c>0||c===l?l:l-1}function U(c){for(var l,y,W=1,E=c.length,Ae=c[0]+"";W<E;){for(l=c[W++]+"",y=Z-l.length;y--;l="0"+l);Ae+=l}for(E=Ae.length;Ae.charCodeAt(--E)===48;);return Ae.slice(0,E+1||1)}function ie(c,l){var y,W,E=c.c,Ae=l.c,ze=c.s,Je=l.s,dt=c.e,Vt=l.e;if(!ze||!Je)return null;if(y=E&&!E[0],W=Ae&&!Ae[0],y||W)return y?W?0:-Je:ze;if(ze!=Je)return ze;if(y=ze<0,W=dt==Vt,!E||!Ae)return W?0:!E^y?1:-1;if(!W)return dt>Vt^y?1:-1;for(Je=(dt=E.length)<(Vt=Ae.length)?dt:Vt,ze=0;ze<Je;ze++)if(E[ze]!=Ae[ze])return E[ze]>Ae[ze]^y?1:-1;return dt==Vt?0:dt>Vt^y?1:-1}function se(c,l,y,W){if(c<l||c>y||c!==V(c))throw Error(te+(W||"Argument")+(typeof c=="number"?c<l||c>y?" out of range: ":" not an integer: ":" not a primitive number: ")+String(c))}function ye(c){var l=c.c.length-1;return $(c.e/Z)==l&&c.c[l]%2!=0}function we(c,l){return(c.length>1?c.charAt(0)+"."+c.slice(1):c)+(l<0?"e":"e+")+l}function Ze(c,l,y){var W,E;if(l<0){for(E=y+".";++l;E+=y);c=E+c}else if(W=c.length,++l>W){for(E=y,l-=W;--l;E+=y);c+=E}else l<W&&(c=c.slice(0,l)+"."+c.slice(l));return c}var rt=xe(),me=rt;const ce=new me("1e+18"),Se=c=>{const l=u128(c),{encode:y,decode:W}=encodeDecode(l),E=l;return E.decode=(Ae,ze)=>{const Je=W(Ae,ze).toString();return new BigNumber(Je).div(ce)},E.encode=(Ae,ze,Je)=>{const dt=BigInt(Ae.times(ce).integerValue().toString());return y(dt,ze,Je)},E},Fe=c=>{const l=(0,h.u8)(c),{encode:y,decode:W}=X(l),E=l;return E.decode=(Ae,ze)=>!!W(Ae,ze),E.encode=(Ae,ze,Je)=>{const dt=Number(Ae);return y(dt,ze,Je)},E};var Xe=A(78412);const x=c=>{const l=(0,h.Ik)(32,c),{encode:y,decode:W}=X(l),E=l;return E.decode=(Ae,ze)=>{const Je=W(Ae,ze);return new Xe.PublicKey(Je)},E.encode=(Ae,ze,Je)=>{const dt=Ae.toBuffer();return y(dt,ze,Je)},E}},58467:function(ee,J,A){"use strict";A.d(J,{H_:function(){return P},_u:function(){return S}});var h=A(78412);const P=new h.PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"),X=new h.PublicKey("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"),S=new h.PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"),B=new h.PublicKey("So11111111111111111111111111111111111111112"),Q=new h.PublicKey("9pan9bMn5HatX4EJdBwg9VgCa7Uz5HL8N1m5D3NdXejP");function F(R){return R!==P}},77043:function(ee,J,A){"use strict";A.d(J,{Ek:function(){return S}});var h=A(78412),P=A(58467),X=A(48764).Buffer;function S(R,G,ke,oe,_=P.H_,ne=P._u){return Q(R,G,ke,oe,X.alloc(0),_,ne)}function B(R,G,ke,oe,_=TOKEN_PROGRAM_ID,ne=ASSOCIATED_TOKEN_PROGRAM_ID){return Q(R,G,ke,oe,X.from([1]),_,ne)}function Q(R,G,ke,oe,_,ne=P.H_,M=P._u){const le=[{pubkey:R,isSigner:!0,isWritable:!0},{pubkey:G,isSigner:!1,isWritable:!0},{pubkey:ke,isSigner:!1,isWritable:!1},{pubkey:oe,isSigner:!1,isWritable:!1},{pubkey:h.SystemProgram.programId,isSigner:!1,isWritable:!1},{pubkey:ne,isSigner:!1,isWritable:!1}];return new h.TransactionInstruction({keys:le,programId:M,data:_})}function F(R,G,ke,oe,_,ne,M=TOKEN_PROGRAM_ID,le=ASSOCIATED_TOKEN_PROGRAM_ID){const re=[{pubkey:R,isSigner:!1,isWritable:!0},{pubkey:G,isSigner:!1,isWritable:!1},{pubkey:ke,isSigner:!1,isWritable:!0},{pubkey:oe,isSigner:!1,isWritable:!0},{pubkey:_,isSigner:!1,isWritable:!1},{pubkey:ne,isSigner:!0,isWritable:!0},{pubkey:M,isSigner:!1,isWritable:!1}];return new TransactionInstruction({keys:re,programId:le,data:X.from([2])})}},49687:function(ee,J,A){"use strict";A.d(J,{$B:function(){return G}});var h=A(39386),P=A(75101),X=A(78412),S=A(58467);function B(_,ne,M){if(M.length){_.push({pubkey:ne,isSigner:!1,isWritable:!1});for(const le of M)_.push({pubkey:le instanceof X.PublicKey?le:le.publicKey,isSigner:!0,isWritable:!1})}else _.push({pubkey:ne,isSigner:!0,isWritable:!1});return _}var Q;(function(_){_[_.InitializeMint=0]="InitializeMint",_[_.InitializeAccount=1]="InitializeAccount",_[_.InitializeMultisig=2]="InitializeMultisig",_[_.Transfer=3]="Transfer",_[_.Approve=4]="Approve",_[_.Revoke=5]="Revoke",_[_.SetAuthority=6]="SetAuthority",_[_.MintTo=7]="MintTo",_[_.Burn=8]="Burn",_[_.CloseAccount=9]="CloseAccount",_[_.FreezeAccount=10]="FreezeAccount",_[_.ThawAccount=11]="ThawAccount",_[_.TransferChecked=12]="TransferChecked",_[_.ApproveChecked=13]="ApproveChecked",_[_.MintToChecked=14]="MintToChecked",_[_.BurnChecked=15]="BurnChecked",_[_.InitializeAccount2=16]="InitializeAccount2",_[_.SyncNative=17]="SyncNative",_[_.InitializeAccount3=18]="InitializeAccount3",_[_.InitializeMultisig2=19]="InitializeMultisig2",_[_.InitializeMint2=20]="InitializeMint2",_[_.GetAccountDataSize=21]="GetAccountDataSize",_[_.InitializeImmutableOwner=22]="InitializeImmutableOwner",_[_.AmountToUiAmount=23]="AmountToUiAmount",_[_.UiAmountToAmount=24]="UiAmountToAmount",_[_.InitializeMintCloseAuthority=25]="InitializeMintCloseAuthority",_[_.TransferFeeExtension=26]="TransferFeeExtension",_[_.ConfidentialTransferExtension=27]="ConfidentialTransferExtension",_[_.DefaultAccountStateExtension=28]="DefaultAccountStateExtension",_[_.Reallocate=29]="Reallocate",_[_.MemoTransferExtension=30]="MemoTransferExtension",_[_.CreateNativeMint=31]="CreateNativeMint",_[_.InitializeNonTransferableMint=32]="InitializeNonTransferableMint",_[_.InterestBearingMintExtension=33]="InterestBearingMintExtension",_[_.CpiGuardExtension=34]="CpiGuardExtension",_[_.InitializePermanentDelegate=35]="InitializePermanentDelegate",_[_.TransferHookExtension=36]="TransferHookExtension",_[_.MetadataPointerExtension=39]="MetadataPointerExtension"})(Q||(Q={}));var F=A(48764).Buffer;const R=(0,h.n_)([(0,h.u8)("instruction"),(0,P.AW)("amount")]);function G(_,ne,M,le,re=[],V=S.H_){const te=B([{pubkey:_,isSigner:!1,isWritable:!0},{pubkey:ne,isSigner:!1,isWritable:!0}],M,re),ge=F.alloc(R.span);return R.encode({instruction:Q.Transfer,amount:BigInt(le)},ge),new X.TransactionInstruction({keys:te,programId:V,data:ge})}function ke(_,ne=TOKEN_PROGRAM_ID){if(!_.programId.equals(ne))throw new TokenInvalidInstructionProgramError;if(_.data.length!==R.span)throw new TokenInvalidInstructionDataError;const{keys:{source:M,destination:le,owner:re,multiSigners:V},data:te}=oe(_);if(te.instruction!==TokenInstruction.Transfer)throw new TokenInvalidInstructionTypeError;if(!M||!le||!re)throw new TokenInvalidInstructionKeysError;return{programId:ne,keys:{source:M,destination:le,owner:re,multiSigners:V},data:te}}function oe({programId:_,keys:[ne,M,le,...re],data:V}){return{programId:_,keys:{source:ne,destination:M,owner:le,multiSigners:re},data:R.decode(V)}}},20302:function(ee,J,A){"use strict";A.d(J,{Am:function(){return ie}});var h=A(39386),P=A(75101),X=A(78412),S=A(58467);class B extends Error{constructor(we){super(we)}}class Q extends null{constructor(){super(...arguments),this.name="TokenAccountNotFoundError"}}class F extends null{constructor(){super(...arguments),this.name="TokenInvalidAccountError"}}class R extends null{constructor(){super(...arguments),this.name="TokenInvalidAccountDataError"}}class G extends null{constructor(){super(...arguments),this.name="TokenInvalidAccountOwnerError"}}class ke extends null{constructor(){super(...arguments),this.name="TokenInvalidAccountSizeError"}}class oe extends null{constructor(){super(...arguments),this.name="TokenInvalidMintError"}}class _ extends null{constructor(){super(...arguments),this.name="TokenInvalidOwnerError"}}class ne extends B{constructor(){super(...arguments),this.name="TokenOwnerOffCurveError"}}class M extends null{constructor(){super(...arguments),this.name="TokenInvalidInstructionProgramError"}}class le extends null{constructor(){super(...arguments),this.name="TokenInvalidInstructionKeysError"}}class re extends null{constructor(){super(...arguments),this.name="TokenInvalidInstructionDataError"}}class V extends null{constructor(){super(...arguments),this.name="TokenInvalidInstructionTypeError"}}class te extends null{constructor(){super(...arguments),this.name="TokenUnsupportedInstructionError"}}class ge extends null{constructor(){super(...arguments),this.name="TokenTransferHookAccountNotFound"}}class Ne extends null{constructor(){super(...arguments),this.name="TokenTransferHookInvalidSeed"}}class Z extends null{constructor(){super(...arguments),this.name="TokenTransferHookAccountDataNotFound"}}var be=A(48764).Buffer;const qe=(0,h.n_)([(0,h.Jq)("mintAuthorityOption"),(0,P.ZL)("mintAuthority"),(0,P.AW)("supply"),(0,h.u8)("decimals"),(0,P.Xg)("isInitialized"),(0,h.Jq)("freezeAuthorityOption"),(0,P.ZL)("freezeAuthority")]),pe=qe.span;async function Be(ye,we,Ze,rt=TOKEN_PROGRAM_ID){const me=await ye.getAccountInfo(we,Ze);return xe(we,me,rt)}function xe(ye,we,Ze=TOKEN_PROGRAM_ID){if(!we)throw new TokenAccountNotFoundError;if(!we.owner.equals(Ze))throw new TokenInvalidAccountOwnerError;if(we.data.length<pe)throw new TokenInvalidAccountSizeError;const rt=qe.decode(we.data.slice(0,pe));let me=be.alloc(0);if(we.data.length>pe){if(we.data.length<=ACCOUNT_SIZE)throw new TokenInvalidAccountSizeError;if(we.data.length===MULTISIG_SIZE)throw new TokenInvalidAccountSizeError;if(we.data[ACCOUNT_SIZE]!=AccountType.Mint)throw new TokenInvalidMintError;me=we.data.slice(ACCOUNT_SIZE+ACCOUNT_TYPE_SIZE)}return{address:ye,mintAuthority:rt.mintAuthorityOption?rt.mintAuthority:null,supply:rt.supply,decimals:rt.decimals,isInitialized:rt.isInitialized,freezeAuthority:rt.freezeAuthorityOption?rt.freezeAuthority:null,tlvData:me}}async function $(ye,we){return await U(ye,[],we)}async function U(ye,we,Ze){const rt=getMintLen(we);return await ye.getMinimumBalanceForRentExemption(rt,Ze)}async function ie(ye,we,Ze=!1,rt=S.H_,me=S._u){if(!Ze&&!X.PublicKey.isOnCurve(we.toBuffer()))throw new ne;const[ce]=await X.PublicKey.findProgramAddress([we.toBuffer(),rt.toBuffer(),ye.toBuffer()],me);return ce}function se(ye,we,Ze=!1,rt=TOKEN_PROGRAM_ID,me=ASSOCIATED_TOKEN_PROGRAM_ID){if(!Ze&&!PublicKey.isOnCurve(we.toBuffer()))throw new TokenOwnerOffCurveError;const[ce]=PublicKey.findProgramAddressSync([we.toBuffer(),rt.toBuffer(),ye.toBuffer()],me);return ce}}}]);
108
+ */h={value:!0},h=h=h=h=h=h=h=h=$._O=h=h=$.Jq=h=$.KB=$.u8=$.cv=h=h=h=h=h=h=h=h=h=h=h=h=h=h=h=h=h=h=h=h=h=h=h=h=h=h=h=h=h=h=h=h=h=h=void 0,h=h=h=$.Ik=h=h=$.A9=h=$.n_=h=h=h=h=h=h=h=h=h=h=$.gM=h=h=h=h=void 0;const T=A(48764);function Z(x){if(!(x instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}h=Z;function S(x){return Z(x),T.Buffer.from(x.buffer,x.byteOffset,x.length)}h=S;class B{constructor(c,l){if(!Number.isInteger(c))throw new TypeError("span must be an integer");this.span=c,this.property=l}makeDestinationObject(){return{}}getSpan(c,l){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(c){const l=Object.create(this.constructor.prototype);return Object.assign(l,this),l.property=c,l}fromArray(c){}}h=B;function X(x,c){return c.property?x+"["+c.property+"]":x}h=X;function H(x,c){if(typeof x!="function")throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(x,"layout_"))throw new Error("Class is already bound to a layout");if(!(c&&c instanceof B))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(c,"boundConstructor_"))throw new Error("layout is already bound to a constructor");x.layout_=c,c.boundConstructor_=x,c.makeDestinationObject=()=>new x,Object.defineProperty(x.prototype,"encode",{value(l,y){return c.encode(this,l,y)},writable:!0}),Object.defineProperty(x,"decode",{value(l,y){return c.decode(l,y)},writable:!0})}h=H;class R extends B{isCount(){throw new Error("ExternalLayout is abstract")}}h=R;class j extends R{constructor(c=1,l){if(!Number.isInteger(c)||0>=c)throw new TypeError("elementSpan must be a (positive) integer");super(-1,l),this.elementSpan=c}isCount(){return!0}decode(c,l=0){Z(c);const y=c.length-l;return Math.floor(y/this.elementSpan)}encode(c,l,y){return 0}}h=j;class me extends R{constructor(c,l=0,y){if(!(c instanceof B))throw new TypeError("layout must be a Layout");if(!Number.isInteger(l))throw new TypeError("offset must be integer or undefined");super(c.span,y||c.property),this.layout=c,this.offset=l}isCount(){return this.layout instanceof se||this.layout instanceof _}decode(c,l=0){return this.layout.decode(c,l+this.offset)}encode(c,l,y=0){return this.layout.encode(c,l,y+this.offset)}}h=me;class se extends B{constructor(c,l){if(super(c,l),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(c,l=0){return S(c).readUIntLE(l,this.span)}encode(c,l,y=0){return S(l).writeUIntLE(c,y,this.span),this.span}}h=se;class _ extends B{constructor(c,l){if(super(c,l),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(c,l=0){return S(c).readUIntBE(l,this.span)}encode(c,l,y=0){return S(l).writeUIntBE(c,y,this.span),this.span}}h=_;class re extends B{constructor(c,l){if(super(c,l),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(c,l=0){return S(c).readIntLE(l,this.span)}encode(c,l,y=0){return S(l).writeIntLE(c,y,this.span),this.span}}h=re;class D extends B{constructor(c,l){if(super(c,l),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(c,l=0){return S(c).readIntBE(l,this.span)}encode(c,l,y=0){return S(l).writeIntBE(c,y,this.span),this.span}}h=D;const fe=Math.pow(2,32);function Q(x){const c=Math.floor(x/fe),l=x-c*fe;return{hi32:c,lo32:l}}function Y(x,c){return x*fe+c}class te extends B{constructor(c){super(8,c)}decode(c,l=0){const y=S(c),q=y.readUInt32LE(l),E=y.readUInt32LE(l+4);return Y(E,q)}encode(c,l,y=0){const q=Q(c),E=S(l);return E.writeUInt32LE(q.lo32,y),E.writeUInt32LE(q.hi32,y+4),8}}h=te;class ye extends B{constructor(c){super(8,c)}decode(c,l=0){const y=S(c),q=y.readUInt32BE(l),E=y.readUInt32BE(l+4);return Y(q,E)}encode(c,l,y=0){const q=Q(c),E=S(l);return E.writeUInt32BE(q.hi32,y),E.writeUInt32BE(q.lo32,y+4),8}}h=ye;class Ne extends B{constructor(c){super(8,c)}decode(c,l=0){const y=S(c),q=y.readUInt32LE(l),E=y.readInt32LE(l+4);return Y(E,q)}encode(c,l,y=0){const q=Q(c),E=S(l);return E.writeUInt32LE(q.lo32,y),E.writeInt32LE(q.hi32,y+4),8}}h=Ne;class ee extends B{constructor(c){super(8,c)}decode(c,l=0){const y=S(c),q=y.readInt32BE(l),E=y.readUInt32BE(l+4);return Y(q,E)}encode(c,l,y=0){const q=Q(c),E=S(l);return E.writeInt32BE(q.hi32,y),E.writeUInt32BE(q.lo32,y+4),8}}h=ee;class we extends B{constructor(c){super(4,c)}decode(c,l=0){return S(c).readFloatLE(l)}encode(c,l,y=0){return S(l).writeFloatLE(c,y),4}}h=we;class He extends B{constructor(c){super(4,c)}decode(c,l=0){return S(c).readFloatBE(l)}encode(c,l,y=0){return S(l).writeFloatBE(c,y),4}}h=He;class ue extends B{constructor(c){super(8,c)}decode(c,l=0){return S(c).readDoubleLE(l)}encode(c,l,y=0){return S(l).writeDoubleLE(c,y),8}}h=ue;class Ae extends B{constructor(c){super(8,c)}decode(c,l=0){return S(c).readDoubleBE(l)}encode(c,l,y=0){return S(l).writeDoubleBE(c,y),8}}h=Ae;class xe extends B{constructor(c,l,y){if(!(c instanceof B))throw new TypeError("elementLayout must be a Layout");if(!(l instanceof R&&l.isCount()||Number.isInteger(l)&&0<=l))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let q=-1;!(l instanceof R)&&0<c.span&&(q=l*c.span),super(q,y),this.elementLayout=c,this.count=l}getSpan(c,l=0){if(0<=this.span)return this.span;let y=0,q=this.count;if(q instanceof R&&(q=q.decode(c,l)),0<this.elementLayout.span)y=q*this.elementLayout.span;else{let E=0;for(;E<q;)y+=this.elementLayout.getSpan(c,l+y),++E}return y}decode(c,l=0){const y=[];let q=0,E=this.count;for(E instanceof R&&(E=E.decode(c,l));q<E;)y.push(this.elementLayout.decode(c,l)),l+=this.elementLayout.getSpan(c,l),q+=1;return y}encode(c,l,y=0){const q=this.elementLayout,E=c.reduce((Ie,ze)=>Ie+q.encode(ze,l,y+Ie),0);return this.count instanceof R&&this.count.encode(c.length,l,y),E}}h=xe;class J extends B{constructor(c,l,y){if(!(Array.isArray(c)&&c.reduce((E,Ie)=>E&&Ie instanceof B,!0)))throw new TypeError("fields must be array of Layout instances");typeof l=="boolean"&&y===void 0&&(y=l,l=void 0);for(const E of c)if(0>E.span&&E.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let q=-1;try{q=c.reduce((E,Ie)=>E+Ie.getSpan(),0)}catch{}super(q,l),this.fields=c,this.decodePrefixes=!!y}getSpan(c,l=0){if(0<=this.span)return this.span;let y=0;try{y=this.fields.reduce((q,E)=>{const Ie=E.getSpan(c,l);return l+=Ie,q+Ie},0)}catch{throw new RangeError("indeterminate span")}return y}decode(c,l=0){Z(c);const y=this.makeDestinationObject();for(const q of this.fields)if(q.property!==void 0&&(y[q.property]=q.decode(c,l)),l+=q.getSpan(c,l),this.decodePrefixes&&c.length===l)break;return y}encode(c,l,y=0){const q=y;let E=0,Ie=0;for(const ze of this.fields){let $e=ze.span;if(Ie=0<$e?$e:0,ze.property!==void 0){const dt=c[ze.property];dt!==void 0&&(Ie=ze.encode(dt,l,y),0>$e&&($e=ze.getSpan(l,y)))}E=y,y+=$e}return E+Ie-q}fromArray(c){const l=this.makeDestinationObject();for(const y of this.fields)y.property!==void 0&&0<c.length&&(l[y.property]=c.shift());return l}layoutFor(c){if(typeof c!="string")throw new TypeError("property must be string");for(const l of this.fields)if(l.property===c)return l}offsetOf(c){if(typeof c!="string")throw new TypeError("property must be string");let l=0;for(const y of this.fields){if(y.property===c)return l;0>y.span?l=-1:0<=l&&(l+=y.span)}}}h=J;class z{constructor(c){this.property=c}decode(c,l){throw new Error("UnionDiscriminator is abstract")}encode(c,l,y){throw new Error("UnionDiscriminator is abstract")}}h=z;class ie extends z{constructor(c,l){if(!(c instanceof R&&c.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(l||c.property||"variant"),this.layout=c}decode(c,l){return this.layout.decode(c,l)}encode(c,l,y){return this.layout.encode(c,l,y)}}h=ie;class oe extends B{constructor(c,l,y){let q;if(c instanceof se||c instanceof _)q=new ie(new me(c));else if(c instanceof R&&c.isCount())q=new ie(c);else if(c instanceof z)q=c;else throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(l===void 0&&(l=null),!(l===null||l instanceof B))throw new TypeError("defaultLayout must be null or a Layout");if(l!==null){if(0>l.span)throw new Error("defaultLayout must have constant span");l.property===void 0&&(l=l.replicate("content"))}let E=-1;l&&(E=l.span,0<=E&&(c instanceof se||c instanceof _)&&(E+=q.layout.span)),super(E,y),this.discriminator=q,this.usesPrefixDiscriminator=c instanceof se||c instanceof _,this.defaultLayout=l,this.registry={};let Ie=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(ze){return Ie(ze)},this.configGetSourceVariant=function(ze){Ie=ze.bind(this)}}getSpan(c,l=0){if(0<=this.span)return this.span;const y=this.getVariant(c,l);if(!y)throw new Error("unable to determine span for unrecognized variant");return y.getSpan(c,l)}defaultGetSourceVariant(c){if(Object.prototype.hasOwnProperty.call(c,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(c,this.defaultLayout.property))return;const l=this.registry[c[this.discriminator.property]];if(l&&(!l.layout||l.property&&Object.prototype.hasOwnProperty.call(c,l.property)))return l}else for(const l in this.registry){const y=this.registry[l];if(y.property&&Object.prototype.hasOwnProperty.call(c,y.property))return y}throw new Error("unable to infer src variant")}decode(c,l=0){let y;const q=this.discriminator,E=q.decode(c,l),Ie=this.registry[E];if(Ie===void 0){const ze=this.defaultLayout;let $e=0;this.usesPrefixDiscriminator&&($e=q.layout.span),y=this.makeDestinationObject(),y[q.property]=E,y[ze.property]=ze.decode(c,l+$e)}else y=Ie.decode(c,l);return y}encode(c,l,y=0){const q=this.getSourceVariant(c);if(q===void 0){const E=this.discriminator,Ie=this.defaultLayout;let ze=0;return this.usesPrefixDiscriminator&&(ze=E.layout.span),E.encode(c[E.property],l,y),ze+Ie.encode(c[Ie.property],l,y+ze)}return q.encode(c,l,y)}addVariant(c,l,y){const q=new ge(this,c,l,y);return this.registry[c]=q,q}getVariant(c,l=0){let y;return c instanceof Uint8Array?y=this.discriminator.decode(c,l):y=c,this.registry[y]}}h=oe;class ge extends B{constructor(c,l,y,q){if(!(c instanceof oe))throw new TypeError("union must be a Union");if(!Number.isInteger(l)||0>l)throw new TypeError("variant must be a (non-negative) integer");if(typeof y=="string"&&q===void 0&&(q=y,y=null),y){if(!(y instanceof B))throw new TypeError("layout must be a Layout");if(c.defaultLayout!==null&&0<=y.span&&y.span>c.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof q!="string")throw new TypeError("variant must have a String property")}let E=c.span;0>c.span&&(E=y?y.span:0,0<=E&&c.usesPrefixDiscriminator&&(E+=c.discriminator.layout.span)),super(E,q),this.union=c,this.variant=l,this.layout=y||null}getSpan(c,l=0){if(0<=this.span)return this.span;let y=0;this.union.usesPrefixDiscriminator&&(y=this.union.discriminator.layout.span);let q=0;return this.layout&&(q=this.layout.getSpan(c,l+y)),y+q}decode(c,l=0){const y=this.makeDestinationObject();if(this!==this.union.getVariant(c,l))throw new Error("variant mismatch");let q=0;return this.union.usesPrefixDiscriminator&&(q=this.union.discriminator.layout.span),this.layout?y[this.property]=this.layout.decode(c,l+q):this.property?y[this.property]=!0:this.union.usesPrefixDiscriminator&&(y[this.union.discriminator.property]=this.variant),y}encode(c,l,y=0){let q=0;if(this.union.usesPrefixDiscriminator&&(q=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(c,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,l,y);let E=q;if(this.layout&&(this.layout.encode(c[this.property],l,y+q),E+=this.layout.getSpan(l,y+q),0<=this.union.span&&E>this.union.span))throw new Error("encoded variant overruns containing union");return E}fromArray(c){if(this.layout)return this.layout.fromArray(c)}}h=ge;function ke(x){return 0>x&&(x+=4294967296),x}class Je extends B{constructor(c,l,y){if(!(c instanceof se||c instanceof _))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof l=="string"&&y===void 0&&(y=l,l=!1),4<c.span)throw new RangeError("word cannot exceed 32 bits");super(c.span,y),this.word=c,this.msb=!!l,this.fields=[];let q=0;this._packedSetValue=function(E){return q=ke(E),this},this._packedGetValue=function(){return q}}decode(c,l=0){const y=this.makeDestinationObject(),q=this.word.decode(c,l);this._packedSetValue(q);for(const E of this.fields)E.property!==void 0&&(y[E.property]=E.decode(c));return y}encode(c,l,y=0){const q=this.word.decode(l,y);this._packedSetValue(q);for(const E of this.fields)if(E.property!==void 0){const Ie=c[E.property];Ie!==void 0&&E.encode(Ie)}return this.word.encode(this._packedGetValue(),l,y)}addField(c,l){const y=new nt(this,c,l);return this.fields.push(y),y}addBoolean(c){const l=new be(this,c);return this.fields.push(l),l}fieldFor(c){if(typeof c!="string")throw new TypeError("property must be string");for(const l of this.fields)if(l.property===c)return l}}h=Je;class nt{constructor(c,l,y){if(!(c instanceof Je))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(l)||0>=l)throw new TypeError("bits must be positive integer");const q=8*c.span,E=c.fields.reduce((Ie,ze)=>Ie+ze.bits,0);if(l+E>q)throw new Error("bits too long for span remainder ("+(q-E)+" of "+q+" remain)");this.container=c,this.bits=l,this.valueMask=(1<<l)-1,l===32&&(this.valueMask=4294967295),this.start=E,this.container.msb&&(this.start=q-E-l),this.wordMask=ke(this.valueMask<<this.start),this.property=y}decode(c,l){const y=this.container._packedGetValue();return ke(y&this.wordMask)>>>this.start}encode(c){if(typeof c!="number"||!Number.isInteger(c)||c!==ke(c&this.valueMask))throw new TypeError(X("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const l=this.container._packedGetValue(),y=ke(c<<this.start);this.container._packedSetValue(ke(l&~this.wordMask)|y)}}h=nt;class be extends nt{constructor(c,l){super(c,1,l)}decode(c,l){return!!super.decode(c,l)}encode(c){typeof c=="boolean"&&(c=+c),super.encode(c)}}h=be;class ce extends B{constructor(c,l){if(!(c instanceof R&&c.isCount()||Number.isInteger(c)&&0<=c))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let y=-1;c instanceof R||(y=c),super(y,l),this.length=c}getSpan(c,l){let y=this.span;return 0>y&&(y=this.length.decode(c,l)),y}decode(c,l=0){let y=this.span;return 0>y&&(y=this.length.decode(c,l)),S(c).slice(l,l+y)}encode(c,l,y){let q=this.length;if(this.length instanceof R&&(q=c.length),!(c instanceof Uint8Array&&q===c.length))throw new TypeError(X("Blob.encode",this)+" requires (length "+q+") Uint8Array as src");if(y+q>l.length)throw new RangeError("encoding overruns Uint8Array");const E=S(c);return S(l).write(E.toString("hex"),y,q,"hex"),this.length instanceof R&&this.length.encode(q,l,y),q}}h=ce;class Se extends B{constructor(c){super(-1,c)}getSpan(c,l=0){Z(c);let y=l;for(;y<c.length&&c[y]!==0;)y+=1;return 1+y-l}decode(c,l=0){const y=this.getSpan(c,l);return S(c).slice(l,l+y-1).toString("utf-8")}encode(c,l,y=0){typeof c!="string"&&(c=String(c));const q=T.Buffer.from(c,"utf8"),E=q.length;if(y+E>l.length)throw new RangeError("encoding overruns Buffer");const Ie=S(l);return q.copy(Ie,y),Ie[y+E]=0,E+1}}h=Se;class Ve extends B{constructor(c,l){if(typeof c=="string"&&l===void 0&&(l=c,c=void 0),c===void 0)c=-1;else if(!Number.isInteger(c))throw new TypeError("maxSpan must be an integer");super(-1,l),this.maxSpan=c}getSpan(c,l=0){return Z(c),c.length-l}decode(c,l=0){const y=this.getSpan(c,l);if(0<=this.maxSpan&&this.maxSpan<y)throw new RangeError("text length exceeds maxSpan");return S(c).slice(l,l+y).toString("utf-8")}encode(c,l,y=0){typeof c!="string"&&(c=String(c));const q=T.Buffer.from(c,"utf8"),E=q.length;if(0<=this.maxSpan&&this.maxSpan<E)throw new RangeError("text length exceeds maxSpan");if(y+E>l.length)throw new RangeError("encoding overruns Buffer");return q.copy(S(l),y),E}}h=Ve;class Xe extends B{constructor(c,l){super(0,l),this.value=c}decode(c,l){return this.value}encode(c,l,y){return 0}}h=Xe,h=(x,c)=>new j(x,c),$.cv=(x,c,l)=>new me(x,c,l),$.u8=x=>new se(1,x),$.KB=x=>new se(2,x),h=x=>new se(3,x),$.Jq=x=>new se(4,x),h=x=>new se(5,x),h=x=>new se(6,x),$._O=x=>new te(x),h=x=>new _(2,x),h=x=>new _(3,x),h=x=>new _(4,x),h=x=>new _(5,x),h=x=>new _(6,x),h=x=>new ye(x),h=x=>new re(1,x),h=x=>new re(2,x),h=x=>new re(3,x),h=x=>new re(4,x),h=x=>new re(5,x),h=x=>new re(6,x),$.gM=x=>new Ne(x),h=x=>new D(2,x),h=x=>new D(3,x),h=x=>new D(4,x),h=x=>new D(5,x),h=x=>new D(6,x),h=x=>new ee(x),h=x=>new we(x),h=x=>new He(x),h=x=>new ue(x),h=x=>new Ae(x),$.n_=(x,c,l)=>new J(x,c,l),h=(x,c,l)=>new Je(x,c,l),$.A9=(x,c,l)=>new xe(x,c,l),h=(x,c,l)=>new oe(x,c,l),h=(x,c)=>new ie(x,c),$.Ik=(x,c)=>new ce(x,c),h=x=>new Se(x),h=(x,c)=>new Ve(x,c),h=(x,c)=>new Xe(x,c)},64705:function(ne,$,A){"use strict";A.r($),A.d($,{Account:function(){return qa},AddressLookupTableAccount:function(){return vs},AddressLookupTableInstruction:function(){return Nu},AddressLookupTableProgram:function(){return Cs},Authorized:function(){return ai},BLOCKHASH_CACHE_TIMEOUT_MS:function(){return Mo},BPF_LOADER_DEPRECATED_PROGRAM_ID:function(){return Fa},BPF_LOADER_PROGRAM_ID:function(){return oc},BpfLoader:function(){return ic},COMPUTE_BUDGET_INSTRUCTION_LAYOUTS:function(){return xn},ComputeBudgetInstruction:function(){return Uu},ComputeBudgetProgram:function(){return Ns},Connection:function(){return Cu},Ed25519Program:function(){return Wr},Enum:function(){return Wa},EpochSchedule:function(){return zo},FeeCalculatorLayout:function(){return Co},Keypair:function(){return er},LAMPORTS_PER_SOL:function(){return Zu},LOOKUP_TABLE_INSTRUCTION_LAYOUTS:function(){return In},Loader:function(){return Hn},Lockup:function(){return yr},MAX_SEED_LENGTH:function(){return Po},Message:function(){return yn},MessageAccountKeys:function(){return dr},MessageV0:function(){return Mn},NONCE_ACCOUNT_LENGTH:function(){return Es},NonceAccount:function(){return Ur},PACKET_DATA_SIZE:function(){return Nn},PUBLIC_KEY_LENGTH:function(){return un},PublicKey:function(){return ve},SIGNATURE_LENGTH_IN_BYTES:function(){return Yn},SOLANA_SCHEMA:function(){return fr},STAKE_CONFIG_ID:function(){return ii},STAKE_INSTRUCTION_LAYOUTS:function(){return Jt},SYSTEM_INSTRUCTION_LAYOUTS:function(){return At},SYSVAR_CLOCK_PUBKEY:function(){return _n},SYSVAR_EPOCH_SCHEDULE_PUBKEY:function(){return Za},SYSVAR_INSTRUCTIONS_PUBKEY:function(){return Xa},SYSVAR_RECENT_BLOCKHASHES_PUBKEY:function(){return Cr},SYSVAR_RENT_PUBKEY:function(){return Zn},SYSVAR_REWARDS_PUBKEY:function(){return Qa},SYSVAR_SLOT_HASHES_PUBKEY:function(){return ec},SYSVAR_SLOT_HISTORY_PUBKEY:function(){return tc},SYSVAR_STAKE_HISTORY_PUBKEY:function(){return Nr},Secp256k1Program:function(){return tr},SendTransactionError:function(){return xs},SolanaJSONRPCError:function(){return qe},SolanaJSONRPCErrorCode:function(){return dc},StakeAuthorizationLayout:function(){return Wu},StakeInstruction:function(){return Mu},StakeProgram:function(){return Hr},Struct:function(){return gs},SystemInstruction:function(){return rc},SystemProgram:function(){return Qt},Transaction:function(){return mt},TransactionExpiredBlockheightExceededError:function(){return ys},TransactionExpiredNonceInvalidError:function(){return Jn},TransactionExpiredTimeoutError:function(){return bs},TransactionInstruction:function(){return _t},TransactionMessage:function(){return ws},TransactionStatus:function(){return An},VALIDATOR_INFO_KEY:function(){return ui},VERSION_PREFIX_MASK:function(){return Or},VOTE_PROGRAM_ID:function(){return Vu},ValidatorInfo:function(){return Ks},VersionedMessage:function(){return ms},VersionedTransaction:function(){return ks},VoteAccount:function(){return Ds},VoteAuthorizationLayout:function(){return qu},VoteInit:function(){return ci},VoteInstruction:function(){return Hu},VoteProgram:function(){return nr},clusterApiUrl:function(){return Yu},sendAndConfirmRawTransaction:function(){return Ju},sendAndConfirmTransaction:function(){return Ss}});var h={};A.r(h),A.d(h,{bitGet:function(){return Bt},bitLen:function(){return Zt},bitMask:function(){return qr},bitSet:function(){return ki},bytesToHex:function(){return We},bytesToNumberBE:function(){return tt},bytesToNumberLE:function(){return lt},concatBytes:function(){return Yt},createHmacDrbg:function(){return Hs},ensureBytes:function(){return Tt},equalBytes:function(){return Un},hexToBytes:function(){return vt},hexToNumber:function(){return xt},numberToBytesBE:function(){return Pt},numberToBytesLE:function(){return wn},numberToHexUnpadded:function(){return ut},numberToVarBytesBE:function(){return sr},utf8ToBytes:function(){return rn},validateObject:function(){return jn}});var T=A(48764);function Z(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`Wrong positive integer: ${r}`)}function S(r){if(typeof r!="boolean")throw new Error(`Expected boolean, not ${r}`)}function B(r,...e){if(!(r instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(r.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${r.length}`)}function X(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Z(r.outputLen),Z(r.blockLen)}function H(r,e=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(e&&r.finished)throw new Error("Hash#digest() has already been called")}function R(r,e){B(r);const t=e.outputLen;if(r.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}const j={number:Z,bool:S,bytes:B,hash:X,exists:H,output:R};var me=null;const se=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _=r=>r instanceof Uint8Array,re=r=>new Uint8Array(r.buffer,r.byteOffset,r.byteLength),D=r=>new Uint32Array(r.buffer,r.byteOffset,Math.floor(r.byteLength/4)),fe=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),Q=(r,e)=>r<<32-e|r>>>e;if(!(new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68))throw new Error("Non little-endian hardware is not supported");const te=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function ye(r){if(!_(r))throw new Error("Uint8Array expected");let e="";for(let t=0;t<r.length;t++)e+=te[r[t]];return e}function Ne(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);const e=r.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const t=new Uint8Array(e/2);for(let n=0;n<t.length;n++){const s=n*2,o=r.slice(s,s+2),i=Number.parseInt(o,16);if(Number.isNaN(i)||i<0)throw new Error("Invalid byte sequence");t[n]=i}return t}const ee=async()=>{};async function we(r,e,t){let n=Date.now();for(let s=0;s<r;s++){t(s);const o=Date.now()-n;o>=0&&o<e||(await ee(),n+=o)}}function He(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function ue(r){if(typeof r=="string"&&(r=He(r)),!_(r))throw new Error(`expected Uint8Array, got ${typeof r}`);return r}function Ae(...r){const e=new Uint8Array(r.reduce((n,s)=>n+s.length,0));let t=0;return r.forEach(n=>{if(!_(n))throw new Error("Uint8Array expected");e.set(n,t),t+=n.length}),e}class xe{clone(){return this._cloneInto()}}const J={}.toString;function z(r,e){if(e!==void 0&&J.call(e)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(r,e)}function ie(r){const e=n=>r().update(ue(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function oe(r){const e=(n,s)=>r(s).update(ue(n)).digest(),t=r({});return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=n=>r(n),e}function ge(r){const e=(n,s)=>r(s).update(ue(n)).digest(),t=r({});return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=n=>r(n),e}function ke(r=32){if(se&&typeof se.getRandomValues=="function")return se.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}function Je(r,e,t,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,n);const s=BigInt(32),o=BigInt(4294967295),i=Number(t>>s&o),a=Number(t&o),u=n?4:0,d=n?0:4;r.setUint32(e+u,i,n),r.setUint32(e+d,a,n)}class nt extends xe{constructor(e,t,n,s){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=fe(this.buffer)}update(e){H(this);const{view:t,buffer:n,blockLen:s}=this;e=ue(e);const o=e.length;for(let i=0;i<o;){const a=Math.min(s-this.pos,o-i);if(a===s){const u=fe(e);for(;s<=o-i;i+=s)this.process(u,i);continue}n.set(e.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===s&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){H(this),R(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:s,isLE:o}=this;let{pos:i}=this;t[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>s-i&&(this.process(n,0),i=0);for(let m=i;m<s;m++)t[m]=0;Je(n,s-8,BigInt(this.length*8),o),this.process(n,0);const a=fe(e),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const d=u/4,p=this.get();if(d>p.length)throw new Error("_sha2: outputLen bigger than state");for(let m=0;m<d;m++)a.setUint32(4*m,p[m],o)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:s,finished:o,destroyed:i,pos:a}=this;return e.length=s,e.pos=a,e.finished=o,e.destroyed=i,s%t&&e.buffer.set(n),e}}const be=BigInt(2**32-1),ce=BigInt(32);function Se(r,e=!1){return e?{h:Number(r&be),l:Number(r>>ce&be)}:{h:Number(r>>ce&be)|0,l:Number(r&be)|0}}function Ve(r,e=!1){let t=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let s=0;s<r.length;s++){const{h:o,l:i}=Se(r[s],e);[t[s],n[s]]=[o,i]}return[t,n]}const Xe=(r,e)=>BigInt(r>>>0)<<ce|BigInt(e>>>0),x=(r,e,t)=>r>>>t,c=(r,e,t)=>r<<32-t|e>>>t,l=(r,e,t)=>r>>>t|e<<32-t,y=(r,e,t)=>r<<32-t|e>>>t,q=(r,e,t)=>r<<64-t|e>>>t-32,E=(r,e,t)=>r>>>t-32|e<<64-t,Ie=(r,e)=>e,ze=(r,e)=>r,$e=(r,e,t)=>r<<t|e>>>32-t,dt=(r,e,t)=>e<<t|r>>>32-t,Mt=(r,e,t)=>e<<t-32|r>>>64-t,mn=(r,e,t)=>r<<t-32|e>>>64-t;function an(r,e,t,n){const s=(e>>>0)+(n>>>0);return{h:r+t+(s/2**32|0)|0,l:s|0}}var Qe={fromBig:Se,split:Ve,toBig:Xe,shrSH:x,shrSL:c,rotrSH:l,rotrSL:y,rotrBH:q,rotrBL:E,rotr32H:Ie,rotr32L:ze,rotlSH:$e,rotlSL:dt,rotlBH:Mt,rotlBL:mn,add:an,add3L:(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),add3H:(r,e,t,n)=>e+t+n+(r/2**32|0)|0,add4L:(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),add4H:(r,e,t,n,s)=>e+t+n+s+(r/2**32|0)|0,add5H:(r,e,t,n,s,o)=>e+t+n+s+o+(r/2**32|0)|0,add5L:(r,e,t,n,s)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(s>>>0)};const[kr,rr]=(()=>Qe.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))))(),zt=new Uint32Array(80),$t=new Uint32Array(80);class f extends nt{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:t,Bh:n,Bl:s,Ch:o,Cl:i,Dh:a,Dl:u,Eh:d,El:p,Fh:m,Fl:V,Gh:C,Gl:K,Hh:k,Hl:O}=this;return[e,t,n,s,o,i,a,u,d,p,m,V,C,K,k,O]}set(e,t,n,s,o,i,a,u,d,p,m,V,C,K,k,O){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=s|0,this.Ch=o|0,this.Cl=i|0,this.Dh=a|0,this.Dl=u|0,this.Eh=d|0,this.El=p|0,this.Fh=m|0,this.Fl=V|0,this.Gh=C|0,this.Gl=K|0,this.Hh=k|0,this.Hl=O|0}process(e,t){for(let pe=0;pe<16;pe++,t+=4)zt[pe]=e.getUint32(t),$t[pe]=e.getUint32(t+=4);for(let pe=16;pe<80;pe++){const Oe=zt[pe-15]|0,Te=$t[pe-15]|0,De=Qe.rotrSH(Oe,Te,1)^Qe.rotrSH(Oe,Te,8)^Qe.shrSH(Oe,Te,7),je=Qe.rotrSL(Oe,Te,1)^Qe.rotrSL(Oe,Te,8)^Qe.shrSL(Oe,Te,7),Ge=zt[pe-2]|0,St=$t[pe-2]|0,yt=Qe.rotrSH(Ge,St,19)^Qe.rotrBH(Ge,St,61)^Qe.shrSH(Ge,St,6),ot=Qe.rotrSL(Ge,St,19)^Qe.rotrBL(Ge,St,61)^Qe.shrSL(Ge,St,6),Ft=Qe.add4L(je,ot,$t[pe-7],$t[pe-16]),Kt=Qe.add4H(Ft,De,yt,zt[pe-7],zt[pe-16]);zt[pe]=Kt|0,$t[pe]=Ft|0}let{Ah:n,Al:s,Bh:o,Bl:i,Ch:a,Cl:u,Dh:d,Dl:p,Eh:m,El:V,Fh:C,Fl:K,Gh:k,Gl:O,Hh:F,Hl:de}=this;for(let pe=0;pe<80;pe++){const Oe=Qe.rotrSH(m,V,14)^Qe.rotrSH(m,V,18)^Qe.rotrBH(m,V,41),Te=Qe.rotrSL(m,V,14)^Qe.rotrSL(m,V,18)^Qe.rotrBL(m,V,41),De=m&C^~m&k,je=V&K^~V&O,Ge=Qe.add5L(de,Te,je,rr[pe],$t[pe]),St=Qe.add5H(Ge,F,Oe,De,kr[pe],zt[pe]),yt=Ge|0,ot=Qe.rotrSH(n,s,28)^Qe.rotrBH(n,s,34)^Qe.rotrBH(n,s,39),Ft=Qe.rotrSL(n,s,28)^Qe.rotrBL(n,s,34)^Qe.rotrBL(n,s,39),Kt=n&o^n&a^o&a,dn=s&i^s&u^i&u;F=k|0,de=O|0,k=C|0,O=K|0,C=m|0,K=V|0,{h:m,l:V}=Qe.add(d|0,p|0,St|0,yt|0),d=a|0,p=u|0,a=o|0,u=i|0,o=n|0,i=s|0;const Re=Qe.add3L(yt,Ft,dn);n=Qe.add3H(Re,St,ot,Kt),s=Re|0}({h:n,l:s}=Qe.add(this.Ah|0,this.Al|0,n|0,s|0)),{h:o,l:i}=Qe.add(this.Bh|0,this.Bl|0,o|0,i|0),{h:a,l:u}=Qe.add(this.Ch|0,this.Cl|0,a|0,u|0),{h:d,l:p}=Qe.add(this.Dh|0,this.Dl|0,d|0,p|0),{h:m,l:V}=Qe.add(this.Eh|0,this.El|0,m|0,V|0),{h:C,l:K}=Qe.add(this.Fh|0,this.Fl|0,C|0,K|0),{h:k,l:O}=Qe.add(this.Gh|0,this.Gl|0,k|0,O|0),{h:F,l:de}=Qe.add(this.Hh|0,this.Hl|0,F|0,de|0),this.set(n,s,o,i,a,u,d,p,m,V,C,K,k,O,F,de)}roundClean(){zt.fill(0),$t.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class g extends null{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}}class w extends null{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}}class M extends null{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}}const I=ie(()=>new f),L=null,G=null,v=null;/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const P=BigInt(0),W=BigInt(1),U=BigInt(2),ae=r=>r instanceof Uint8Array,Fe=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function We(r){if(!ae(r))throw new Error("Uint8Array expected");let e="";for(let t=0;t<r.length;t++)e+=Fe[r[t]];return e}function ut(r){const e=r.toString(16);return e.length&1?`0${e}`:e}function xt(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}function vt(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);const e=r.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const t=new Uint8Array(e/2);for(let n=0;n<t.length;n++){const s=n*2,o=r.slice(s,s+2),i=Number.parseInt(o,16);if(Number.isNaN(i)||i<0)throw new Error("Invalid byte sequence");t[n]=i}return t}function tt(r){return xt(We(r))}function lt(r){if(!ae(r))throw new Error("Uint8Array expected");return xt(We(Uint8Array.from(r).reverse()))}function Pt(r,e){return vt(r.toString(16).padStart(e*2,"0"))}function wn(r,e){return Pt(r,e).reverse()}function sr(r){return vt(ut(r))}function Tt(r,e,t){let n;if(typeof e=="string")try{n=vt(e)}catch(o){throw new Error(`${r} must be valid hex string, got "${e}". Cause: ${o}`)}else if(ae(e))n=Uint8Array.from(e);else throw new Error(`${r} must be hex string or Uint8Array`);const s=n.length;if(typeof t=="number"&&s!==t)throw new Error(`${r} expected ${t} bytes, got ${s}`);return n}function Yt(...r){const e=new Uint8Array(r.reduce((n,s)=>n+s.length,0));let t=0;return r.forEach(n=>{if(!ae(n))throw new Error("Uint8Array expected");e.set(n,t),t+=n.length}),e}function Un(r,e){if(r.length!==e.length)return!1;for(let t=0;t<r.length;t++)if(r[t]!==e[t])return!1;return!0}function rn(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Zt(r){let e;for(e=0;r>P;r>>=W,e+=1);return e}function Bt(r,e){return r>>BigInt(e)&W}const ki=(r,e,t)=>r|(t?W:P)<<BigInt(e),qr=r=>(U<<BigInt(r-1))-W,Fr=r=>new Uint8Array(r),Ws=r=>Uint8Array.from(r);function Hs(r,e,t){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");let n=Fr(r),s=Fr(r),o=0;const i=()=>{n.fill(1),s.fill(0),o=0},a=(...m)=>t(s,n,...m),u=(m=Fr())=>{s=a(Ws([0]),m),n=a(),m.length!==0&&(s=a(Ws([1]),m),n=a())},d=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let m=0;const V=[];for(;m<e;){n=a();const C=n.slice();V.push(C),m+=n.length}return Yt(...V)};return(m,V)=>{i(),u(m);let C;for(;!(C=V(d()));)u();return i(),C}}const Si={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||r instanceof Uint8Array,isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,e)=>e.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function jn(r,e,t={}){const n=(s,o,i)=>{const a=Si[o];if(typeof a!="function")throw new Error(`Invalid validator "${o}", expected function`);const u=r[s];if(!(i&&u===void 0)&&!a(u,r))throw new Error(`Invalid param ${String(s)}=${u} (${typeof u}), expected ${o}`)};for(const[s,o]of Object.entries(e))n(s,o,!1);for(const[s,o]of Object.entries(t))n(s,o,!0);return r}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Gt=BigInt(0),Et=BigInt(1),Tn=BigInt(2),Ei=BigInt(3),Vr=BigInt(4),qs=BigInt(5),Fs=BigInt(8),_i=BigInt(9),xi=BigInt(16);function It(r,e){const t=r%e;return t>=Gt?t:e+t}function vi(r,e,t){if(t<=Gt||e<Gt)throw new Error("Expected power/modulo > 0");if(t===Et)return Gt;let n=Et;for(;e>Gt;)e&Et&&(n=n*r%t),r=r*r%t,e>>=Et;return n}function Lt(r,e,t){let n=r;for(;e-- >Gt;)n*=n,n%=t;return n}function Sr(r,e){if(r===Gt||e<=Gt)throw new Error(`invert: expected positive integers, got n=${r} mod=${e}`);let t=It(r,e),n=e,s=Gt,o=Et,i=Et,a=Gt;for(;t!==Gt;){const d=n/t,p=n%t,m=s-i*d,V=o-a*d;n=t,t=p,s=i,o=a,i=m,a=V}if(n!==Et)throw new Error("invert: does not exist");return It(s,e)}function Ai(r){const e=(r-Et)/Tn;let t,n,s;for(t=r-Et,n=0;t%Tn===Gt;t/=Tn,n++);for(s=Tn;s<r&&vi(s,e,r)!==r-Et;s++);if(n===1){const i=(r+Et)/Vr;return function(u,d){const p=u.pow(d,i);if(!u.eql(u.sqr(p),d))throw new Error("Cannot find square root");return p}}const o=(t+Et)/Tn;return function(a,u){if(a.pow(u,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let d=n,p=a.pow(a.mul(a.ONE,s),t),m=a.pow(u,o),V=a.pow(u,t);for(;!a.eql(V,a.ONE);){if(a.eql(V,a.ZERO))return a.ZERO;let C=1;for(let k=a.sqr(V);C<d&&!a.eql(k,a.ONE);C++)k=a.sqr(k);const K=a.pow(p,Et<<BigInt(d-C-1));p=a.sqr(K),m=a.mul(m,K),V=a.mul(V,p),d=C}return m}}function Ii(r){if(r%Vr===Ei){const e=(r+Et)/Vr;return function(n,s){const o=n.pow(s,e);if(!n.eql(n.sqr(o),s))throw new Error("Cannot find square root");return o}}if(r%Fs===qs){const e=(r-qs)/Fs;return function(n,s){const o=n.mul(s,Tn),i=n.pow(o,e),a=n.mul(s,i),u=n.mul(n.mul(a,Tn),i),d=n.mul(a,n.sub(u,n.ONE));if(!n.eql(n.sqr(d),s))throw new Error("Cannot find square root");return d}}return r%xi,Ai(r)}const Bi=(r,e)=>(It(r,e)&Et)===Et,Ri=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Pi(r){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=Ri.reduce((n,s)=>(n[s]="function",n),e);return jn(r,t)}function Ti(r,e,t){if(t<Gt)throw new Error("Expected power > 0");if(t===Gt)return r.ONE;if(t===Et)return e;let n=r.ONE,s=e;for(;t>Gt;)t&Et&&(n=r.mul(n,s)),s=r.sqr(s),t>>=Et;return n}function Oi(r,e){const t=new Array(e.length),n=e.reduce((o,i,a)=>r.is0(i)?o:(t[a]=o,r.mul(o,i)),r.ONE),s=r.inv(n);return e.reduceRight((o,i,a)=>r.is0(i)?o:(t[a]=r.mul(o,t[a]),r.mul(o,i)),s),t}function il(r,e,t){return r.mul(e,typeof t=="bigint"?Sr(t,r.ORDER):r.inv(t))}function al(r){const e=(r.ORDER-Et)/Tn;return t=>{const n=r.pow(t,e);return r.eql(n,r.ZERO)||r.eql(n,r.ONE)}}function Gr(r,e){const t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function Vs(r,e,t=!1,n={}){if(r<=Gt)throw new Error(`Expected Field ORDER > 0, got ${r}`);const{nBitLength:s,nByteLength:o}=Gr(r,e);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");const i=Ii(r),a=Object.freeze({ORDER:r,BITS:s,BYTES:o,MASK:qr(s),ZERO:Gt,ONE:Et,create:u=>It(u,r),isValid:u=>{if(typeof u!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof u}`);return Gt<=u&&u<r},is0:u=>u===Gt,isOdd:u=>(u&Et)===Et,neg:u=>It(-u,r),eql:(u,d)=>u===d,sqr:u=>It(u*u,r),add:(u,d)=>It(u+d,r),sub:(u,d)=>It(u-d,r),mul:(u,d)=>It(u*d,r),pow:(u,d)=>Ti(a,u,d),div:(u,d)=>It(u*Sr(d,r),r),sqrN:u=>u*u,addN:(u,d)=>u+d,subN:(u,d)=>u-d,mulN:(u,d)=>u*d,inv:u=>Sr(u,r),sqrt:n.sqrt||(u=>i(a,u)),invertBatch:u=>Oi(a,u),cmov:(u,d,p)=>p?d:u,toBytes:u=>t?wn(u,o):Pt(u,o),fromBytes:u=>{if(u.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${u.length}`);return t?lt(u):tt(u)}});return Object.freeze(a)}function cl(r,e){if(!r.isOdd)throw new Error("Field doesn't have isOdd");const t=r.sqrt(e);return r.isOdd(t)?t:r.neg(t)}function Li(r,e){if(!r.isOdd)throw new Error("Field doesn't have isOdd");const t=r.sqrt(e);return r.isOdd(t)?r.neg(t):t}function ul(r,e,t=!1){r=ensureBytes("privateHash",r);const n=r.length,s=Gr(e).nByteLength+8;if(s<24||n<s||n>1024)throw new Error(`hashToPrivateScalar: expected ${s}-1024 bytes of input, got ${n}`);const o=t?bytesToNumberLE(r):bytesToNumberBE(r);return It(o,e-Et)+Et}function Gs(r){if(typeof r!="bigint")throw new Error("field order must be bigint");const e=r.toString(2).length;return Math.ceil(e/8)}function js(r){const e=Gs(r);return e+Math.ceil(e/2)}function Ci(r,e,t=!1){const n=r.length,s=Gs(e),o=js(e);if(n<16||n<o||n>1024)throw new Error(`expected ${o}-1024 bytes of input, got ${n}`);const i=t?tt(r):lt(r),a=It(i,e-Et)+Et;return t?wn(a,s):Pt(a,s)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ni=BigInt(0),jr=BigInt(1);function $s(r,e){const t=(s,o)=>{const i=o.negate();return s?i:o},n=s=>{const o=Math.ceil(e/s)+1,i=2**(s-1);return{windows:o,windowSize:i}};return{constTimeNegate:t,unsafeLadder(s,o){let i=r.ZERO,a=s;for(;o>Ni;)o&jr&&(i=i.add(a)),a=a.double(),o>>=jr;return i},precomputeWindow(s,o){const{windows:i,windowSize:a}=n(o),u=[];let d=s,p=d;for(let m=0;m<i;m++){p=d,u.push(p);for(let V=1;V<a;V++)p=p.add(d),u.push(p);d=p.double()}return u},wNAF(s,o,i){const{windows:a,windowSize:u}=n(s);let d=r.ZERO,p=r.BASE;const m=BigInt(2**s-1),V=2**s,C=BigInt(s);for(let K=0;K<a;K++){const k=K*u;let O=Number(i&m);i>>=C,O>u&&(O-=V,i+=jr);const F=k,de=k+Math.abs(O)-1,pe=K%2!==0,Oe=O<0;O===0?p=p.add(t(pe,o[F])):d=d.add(t(Oe,o[de]))}return{p:d,f:p}},wNAFCached(s,o,i,a){const u=s._WINDOW_SIZE||1;let d=o.get(s);return d||(d=this.precomputeWindow(s,u),u!==1&&o.set(s,a(d))),this.wNAF(u,d,i)}}}function $r(r){return Pi(r.Fp),jn(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Gr(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const hn=BigInt(0),cn=BigInt(1),Er=BigInt(2),Ui=BigInt(8),zi={zip215:!0};function Ki(r){const e=$r(r);return jn(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function Yr(r){const e=Ki(r),{Fp:t,n,prehash:s,hash:o,randomBytes:i,nByteLength:a,h:u}=e,d=Er<<BigInt(a*8)-cn,p=t.create,m=e.uvRatio||((Pe,le)=>{try{return{isValid:!0,value:t.sqrt(Pe*t.inv(le))}}catch{return{isValid:!1,value:hn}}}),V=e.adjustScalarBytes||(Pe=>Pe),C=e.domain||((Pe,le,Ke)=>{if(le.length||Ke)throw new Error("Contexts/pre-hash are not supported");return Pe}),K=Pe=>typeof Pe=="bigint"&&hn<Pe,k=(Pe,le)=>K(Pe)&&K(le)&&Pe<le,O=Pe=>Pe===hn||k(Pe,d);function F(Pe,le){if(k(Pe,le))return Pe;throw new Error(`Expected valid scalar < ${le}, got ${typeof Pe} ${Pe}`)}function de(Pe){return Pe===hn?Pe:F(Pe,n)}const pe=new Map;function Oe(Pe){if(!(Pe instanceof Te))throw new Error("ExtendedPoint expected")}class Te{constructor(le,Ke,Ye,et){if(this.ex=le,this.ey=Ke,this.ez=Ye,this.et=et,!O(le))throw new Error("x required");if(!O(Ke))throw new Error("y required");if(!O(Ye))throw new Error("z required");if(!O(et))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(le){if(le instanceof Te)throw new Error("extended point not allowed");const{x:Ke,y:Ye}=le||{};if(!O(Ke)||!O(Ye))throw new Error("invalid affine point");return new Te(Ke,Ye,cn,p(Ke*Ye))}static normalizeZ(le){const Ke=t.invertBatch(le.map(Ye=>Ye.ez));return le.map((Ye,et)=>Ye.toAffine(Ke[et])).map(Te.fromAffine)}_setWindowSize(le){this._WINDOW_SIZE=le,pe.delete(this)}assertValidity(){const{a:le,d:Ke}=e;if(this.is0())throw new Error("bad point: ZERO");const{ex:Ye,ey:et,ez:at,et:ft}=this,kt=p(Ye*Ye),ht=p(et*et),bt=p(at*at),Vt=p(bt*bt),Ut=p(kt*le),en=p(bt*p(Ut+ht)),tn=p(Vt+p(Ke*p(kt*ht)));if(en!==tn)throw new Error("bad point: equation left != right (1)");const nn=p(Ye*et),Dt=p(at*ft);if(nn!==Dt)throw new Error("bad point: equation left != right (2)")}equals(le){Oe(le);const{ex:Ke,ey:Ye,ez:et}=this,{ex:at,ey:ft,ez:kt}=le,ht=p(Ke*kt),bt=p(at*et),Vt=p(Ye*kt),Ut=p(ft*et);return ht===bt&&Vt===Ut}is0(){return this.equals(Te.ZERO)}negate(){return new Te(p(-this.ex),this.ey,this.ez,p(-this.et))}double(){const{a:le}=e,{ex:Ke,ey:Ye,ez:et}=this,at=p(Ke*Ke),ft=p(Ye*Ye),kt=p(Er*p(et*et)),ht=p(le*at),bt=Ke+Ye,Vt=p(p(bt*bt)-at-ft),Ut=ht+ft,en=Ut-kt,tn=ht-ft,nn=p(Vt*en),Dt=p(Ut*tn),bn=p(Vt*tn),Vn=p(en*Ut);return new Te(nn,Dt,Vn,bn)}add(le){Oe(le);const{a:Ke,d:Ye}=e,{ex:et,ey:at,ez:ft,et:kt}=this,{ex:ht,ey:bt,ez:Vt,et:Ut}=le;if(Ke===BigInt(-1)){const hi=p((at-et)*(bt+ht)),pi=p((at+et)*(bt-ht)),Ms=p(pi-hi);if(Ms===hn)return this.double();const gi=p(ft*Er*Ut),yi=p(kt*Er*Vt),bi=yi+gi,mi=pi+hi,wi=yi-gi,nl=p(bi*Ms),rl=p(mi*wi),sl=p(bi*wi),ol=p(Ms*mi);return new Te(nl,rl,ol,sl)}const en=p(et*ht),tn=p(at*bt),nn=p(kt*Ye*Ut),Dt=p(ft*Vt),bn=p((et+at)*(ht+bt)-en-tn),Vn=Dt-nn,br=Dt+nn,di=p(tn-Ke*en),Xu=p(bn*Vn),Qu=p(br*di),el=p(bn*di),tl=p(Vn*br);return new Te(Xu,Qu,tl,el)}subtract(le){return this.add(le.negate())}wNAF(le){return Ge.wNAFCached(this,pe,le,Te.normalizeZ)}multiply(le){const{p:Ke,f:Ye}=this.wNAF(F(le,n));return Te.normalizeZ([Ke,Ye])[0]}multiplyUnsafe(le){let Ke=de(le);return Ke===hn?je:this.equals(je)||Ke===cn?this:this.equals(De)?this.wNAF(Ke).p:Ge.unsafeLadder(this,Ke)}isSmallOrder(){return this.multiplyUnsafe(u).is0()}isTorsionFree(){return Ge.unsafeLadder(this,n).is0()}toAffine(le){const{ex:Ke,ey:Ye,ez:et}=this,at=this.is0();le==null&&(le=at?Ui:t.inv(et));const ft=p(Ke*le),kt=p(Ye*le),ht=p(et*le);if(at)return{x:hn,y:cn};if(ht!==cn)throw new Error("invZ was invalid");return{x:ft,y:kt}}clearCofactor(){const{h:le}=e;return le===cn?this:this.multiplyUnsafe(le)}static fromHex(le,Ke=!1){const{d:Ye,a:et}=e,at=t.BYTES;le=Tt("pointHex",le,at);const ft=le.slice(),kt=le[at-1];ft[at-1]=kt&-129;const ht=lt(ft);ht===hn||(Ke?F(ht,d):F(ht,t.ORDER));const bt=p(ht*ht),Vt=p(bt-cn),Ut=p(Ye*bt-et);let{isValid:en,value:tn}=m(Vt,Ut);if(!en)throw new Error("Point.fromHex: invalid y coordinate");const nn=(tn&cn)===cn,Dt=(kt&128)!==0;if(!Ke&&tn===hn&&Dt)throw new Error("Point.fromHex: x=0 and x_0=1");return Dt!==nn&&(tn=p(-tn)),Te.fromAffine({x:tn,y:ht})}static fromPrivateKey(le){return ot(le).point}toRawBytes(){const{x:le,y:Ke}=this.toAffine(),Ye=wn(Ke,t.BYTES);return Ye[Ye.length-1]|=le&cn?128:0,Ye}toHex(){return We(this.toRawBytes())}}Te.BASE=new Te(e.Gx,e.Gy,cn,p(e.Gx*e.Gy)),Te.ZERO=new Te(hn,cn,cn,hn);const{BASE:De,ZERO:je}=Te,Ge=$s(Te,a*8);function St(Pe){return It(Pe,n)}function yt(Pe){return St(lt(Pe))}function ot(Pe){const le=a;Pe=Tt("private key",Pe,le);const Ke=Tt("hashed private key",o(Pe),2*le),Ye=V(Ke.slice(0,le)),et=Ke.slice(le,2*le),at=yt(Ye),ft=De.multiply(at),kt=ft.toRawBytes();return{head:Ye,prefix:et,scalar:at,point:ft,pointBytes:kt}}function Ft(Pe){return ot(Pe).pointBytes}function Kt(Pe=new Uint8Array,...le){const Ke=Yt(...le);return yt(o(C(Ke,Tt("context",Pe),!!s)))}function dn(Pe,le,Ke={}){Pe=Tt("message",Pe),s&&(Pe=s(Pe));const{prefix:Ye,scalar:et,pointBytes:at}=ot(le),ft=Kt(Ke.context,Ye,Pe),kt=De.multiply(ft).toRawBytes(),ht=Kt(Ke.context,kt,at,Pe),bt=St(ft+ht*et);de(bt);const Vt=Yt(kt,wn(bt,t.BYTES));return Tt("result",Vt,a*2)}const Re=zi;function Me(Pe,le,Ke,Ye=Re){const{context:et,zip215:at}=Ye,ft=t.BYTES;Pe=Tt("signature",Pe,2*ft),le=Tt("message",le),s&&(le=s(le));const kt=lt(Pe.slice(ft,2*ft));let ht,bt,Vt;try{ht=Te.fromHex(Ke,at),bt=Te.fromHex(Pe.slice(0,ft),at),Vt=De.multiplyUnsafe(kt)}catch{return!1}if(!at&&ht.isSmallOrder())return!1;const Ut=Kt(et,bt.toRawBytes(),ht.toRawBytes(),le);return bt.add(ht.multiplyUnsafe(Ut)).subtract(Vt).clearCofactor().equals(Te.ZERO)}return De._setWindowSize(8),{CURVE:e,getPublicKey:Ft,sign:dn,verify:Me,ExtendedPoint:Te,utils:{getExtendedPublicKey:ot,randomPrivateKey:()=>i(t.BYTES),precompute(Pe=8,le=Te.BASE){return le._setWindowSize(Pe),le.multiply(BigInt(3)),le}}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Jr=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Ys=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Di=BigInt(0),kn=BigInt(1),_r=BigInt(2),Mi=BigInt(5),Js=BigInt(10),Wi=BigInt(20),Hi=BigInt(40),Zs=BigInt(80);function qi(r){const e=Jr,n=r*r%e*r%e,s=Lt(n,_r,e)*n%e,o=Lt(s,kn,e)*r%e,i=Lt(o,Mi,e)*o%e,a=Lt(i,Js,e)*i%e,u=Lt(a,Wi,e)*a%e,d=Lt(u,Hi,e)*u%e,p=Lt(d,Zs,e)*d%e,m=Lt(p,Zs,e)*d%e,V=Lt(m,Js,e)*i%e;return{pow_p_5_8:Lt(V,_r,e)*r%e,b2:n}}function Fi(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Zr(r,e){const t=Jr,n=It(e*e*e,t),s=It(n*n*e,t),o=qi(r*s).pow_p_5_8;let i=It(r*n*o,t);const a=It(e*i*i,t),u=i,d=It(i*Ys,t),p=a===r,m=a===It(-r,t),V=a===It(-r*Ys,t);return p&&(i=u),(m||V)&&(i=d),Bi(i,t)&&(i=It(-i,t)),{isValid:p||m,value:i}}const ll=null,Ue=Vs(Jr,void 0,!0),or={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Ue,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:I,randomBytes:ke,adjustScalarBytes:Fi,uvRatio:Zr},Wt=Yr(or);function Xs(r,e,t){if(e.length>255)throw new Error("Context is too big");return Ae(He("SigEd25519 no Ed25519 collisions"),new Uint8Array([t?1:0,e.length]),e,r)}const fl=Yr({...or,domain:Xs}),dl=Yr({...or,domain:Xs,prehash:I}),hl=null;function pl(r){const{y:e}=Wt.ExtendedPoint.fromHex(r),t=BigInt(1);return Ue.toBytes(Ue.create((t+e)*Ue.inv(t-e)))}const gl=null;function yl(r){const e=or.hash(r.subarray(0,32));return or.adjustScalarBytes(e).subarray(0,32)}const Vi=(Ue.ORDER+BigInt(3))/BigInt(8),Gi=Ue.pow(_r,Vi),Qs=Ue.sqrt(Ue.neg(Ue.ONE)),ji=(Ue.ORDER-BigInt(5))/BigInt(8),eo=BigInt(486662);function $i(r){let e=Ue.sqr(r);e=Ue.mul(e,_r);let t=Ue.add(e,Ue.ONE),n=Ue.neg(eo),s=Ue.sqr(t),o=Ue.mul(s,t),i=Ue.mul(e,eo);i=Ue.mul(i,n),i=Ue.add(i,s),i=Ue.mul(i,n);let a=Ue.sqr(o);s=Ue.sqr(a),a=Ue.mul(a,o),a=Ue.mul(a,i),s=Ue.mul(s,a);let u=Ue.pow(s,ji);u=Ue.mul(u,a);let d=Ue.mul(u,Qs);s=Ue.sqr(u),s=Ue.mul(s,o);let p=Ue.eql(s,i),m=Ue.cmov(d,u,p),V=Ue.mul(n,e),C=Ue.mul(u,r);C=Ue.mul(C,Gi);let K=Ue.mul(C,Qs),k=Ue.mul(i,e);s=Ue.sqr(C),s=Ue.mul(s,o);let O=Ue.eql(s,k),F=Ue.cmov(K,C,O);s=Ue.sqr(m),s=Ue.mul(s,o);let de=Ue.eql(s,i),pe=Ue.cmov(V,n,de),Oe=Ue.cmov(F,m,de),Te=Ue.isOdd(Oe);return Oe=Ue.cmov(Oe,Ue.neg(Oe),de!==Te),{xMn:pe,xMd:t,yMn:Oe,yMd:kn}}const Yi=Li(Ue,Ue.neg(BigInt(486664)));function bl(r){const{xMn:e,xMd:t,yMn:n,yMd:s}=$i(r);let o=Ue.mul(e,s);o=Ue.mul(o,Yi);let i=Ue.mul(t,n),a=Ue.sub(e,t),u=Ue.add(e,t),d=Ue.mul(i,u),p=Ue.eql(d,Ue.ZERO);o=Ue.cmov(o,Ue.ZERO,p),i=Ue.cmov(i,Ue.ONE,p),a=Ue.cmov(a,Ue.ONE,p),u=Ue.cmov(u,Ue.ONE,p);const m=Ue.invertBatch([i,u]);return{x:Ue.mul(o,m[0]),y:Ue.mul(a,m[1])}}const ml=null,wl=null,kl=null;function Xr(r){if(!(r instanceof Sn))throw new Error("RistrettoPoint expected")}const Qr=null,Ji=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),Zi=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),Xi=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),Qi=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),to=r=>Zr(kn,r),ea=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),es=r=>Wt.CURVE.Fp.create(bytesToNumberLE(r)&ea);function no(r){const{d:e}=Wt.CURVE,t=Wt.CURVE.Fp.ORDER,n=Wt.CURVE.Fp.create,s=n(Qr*r*r),o=n((s+kn)*Xi);let i=BigInt(-1);const a=n((i-e*s)*n(s+e));let{isValid:u,value:d}=Zr(o,a),p=n(d*r);isNegativeLE(p,t)||(p=n(-p)),u||(d=p),u||(i=s);const m=n(i*(s-kn)*Qi-a),V=d*d,C=n((d+d)*a),K=n(m*Ji),k=n(kn-V),O=n(kn+V);return new Wt.ExtendedPoint(n(C*O),n(k*K),n(K*O),n(C*k))}class Sn{constructor(e){this.ep=e}static fromAffine(e){return new Sn(Wt.ExtendedPoint.fromAffine(e))}static hashToCurve(e){e=ensureBytes("ristrettoHash",e,64);const t=es(e.slice(0,32)),n=no(t),s=es(e.slice(32,64)),o=no(s);return new Sn(n.add(o))}static fromHex(e){e=ensureBytes("ristrettoHex",e,32);const{a:t,d:n}=Wt.CURVE,s=Wt.CURVE.Fp.ORDER,o=Wt.CURVE.Fp.create,i="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",a=es(e);if(!equalBytes(numberToBytesLE(a,32),e)||isNegativeLE(a,s))throw new Error(i);const u=o(a*a),d=o(kn+t*u),p=o(kn-t*u),m=o(d*d),V=o(p*p),C=o(t*n*m-V),{isValid:K,value:k}=to(o(C*V)),O=o(k*p),F=o(k*O*C);let de=o((a+a)*O);isNegativeLE(de,s)&&(de=o(-de));const pe=o(d*F),Oe=o(de*pe);if(!K||isNegativeLE(Oe,s)||pe===Di)throw new Error(i);return new Sn(new Wt.ExtendedPoint(de,pe,kn,Oe))}toRawBytes(){let{ex:e,ey:t,ez:n,et:s}=this.ep;const o=Wt.CURVE.Fp.ORDER,i=Wt.CURVE.Fp.create,a=i(i(n+t)*i(n-t)),u=i(e*t),d=i(u*u),{value:p}=to(i(a*d)),m=i(p*a),V=i(p*u),C=i(m*V*s);let K;if(isNegativeLE(s*C,o)){let O=i(t*Qr),F=i(e*Qr);e=O,t=F,K=i(m*Zi)}else K=V;isNegativeLE(e*C,o)&&(t=i(-t));let k=i((n-t)*K);return isNegativeLE(k,o)&&(k=i(-k)),numberToBytesLE(k,32)}toHex(){return bytesToHex(this.toRawBytes())}toString(){return this.toHex()}equals(e){Xr(e);const{ex:t,ey:n}=this.ep,{ex:s,ey:o}=e.ep,i=Wt.CURVE.Fp.create,a=i(t*o)===i(n*s),u=i(n*o)===i(t*s);return a||u}add(e){return Xr(e),new Sn(this.ep.add(e.ep))}subtract(e){return Xr(e),new Sn(this.ep.subtract(e.ep))}multiply(e){return new Sn(this.ep.multiply(e))}multiplyUnsafe(e){return new Sn(this.ep.multiplyUnsafe(e))}}const Sl=null,El=(r,e)=>{const t=e.DST,n=typeof t=="string"?utf8ToBytes(t):t,s=expand_message_xmd(r,n,64,sha512);return Sn.hashToCurve(s)},_l=null;var ta=A(13550),ro=A.n(ta),na=A(77191),Xt=A.n(na);const ra=(r,e,t)=>r&e^~r&t,sa=(r,e,t)=>r&e^r&t^e&t,oa=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),On=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ln=new Uint32Array(64);class ia extends nt{constructor(){super(64,32,8,!1),this.A=On[0]|0,this.B=On[1]|0,this.C=On[2]|0,this.D=On[3]|0,this.E=On[4]|0,this.F=On[5]|0,this.G=On[6]|0,this.H=On[7]|0}get(){const{A:e,B:t,C:n,D:s,E:o,F:i,G:a,H:u}=this;return[e,t,n,s,o,i,a,u]}set(e,t,n,s,o,i,a,u){this.A=e|0,this.B=t|0,this.C=n|0,this.D=s|0,this.E=o|0,this.F=i|0,this.G=a|0,this.H=u|0}process(e,t){for(let m=0;m<16;m++,t+=4)Ln[m]=e.getUint32(t,!1);for(let m=16;m<64;m++){const V=Ln[m-15],C=Ln[m-2],K=Q(V,7)^Q(V,18)^V>>>3,k=Q(C,17)^Q(C,19)^C>>>10;Ln[m]=k+Ln[m-7]+K+Ln[m-16]|0}let{A:n,B:s,C:o,D:i,E:a,F:u,G:d,H:p}=this;for(let m=0;m<64;m++){const V=Q(a,6)^Q(a,11)^Q(a,25),C=p+V+ra(a,u,d)+oa[m]+Ln[m]|0,k=(Q(n,2)^Q(n,13)^Q(n,22))+sa(n,s,o)|0;p=d,d=u,u=a,a=i+C|0,i=o,o=s,s=n,n=C+k|0}n=n+this.A|0,s=s+this.B|0,o=o+this.C|0,i=i+this.D|0,a=a+this.E|0,u=u+this.F|0,d=d+this.G|0,p=p+this.H|0,this.set(n,s,o,i,a,u,d,p)}roundClean(){Ln.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class xl extends null{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}const ts=ie(()=>new ia),vl=null;var ns=A(25532),b=A(39386),rs=A(40475);class aa extends TypeError{constructor(e,t){let n;const{message:s,...o}=e,{path:i}=e,a=i.length===0?s:"At path: "+i.join(".")+" -- "+s;super(a),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>{var u;return(u=n)!=null?u:n=[e,...t()]}}}function ca(r){return pn(r)&&typeof r[Symbol.iterator]=="function"}function pn(r){return typeof r=="object"&&r!=null}function so(r){if(Object.prototype.toString.call(r)!=="[object Object]")return!1;const e=Object.getPrototypeOf(r);return e===null||e===Object.prototype}function jt(r){return typeof r=="string"?JSON.stringify(r):""+r}function ua(r){const{done:e,value:t}=r.next();return e?void 0:t}function la(r,e,t,n){if(r===!0)return;r===!1?r={}:typeof r=="string"&&(r={message:r});const{path:s,branch:o}=e,{type:i}=t,{refinement:a,message:u="Expected a value of type `"+i+"`"+(a?" with refinement `"+a+"`":"")+", but received: `"+jt(n)+"`"}=r;return{value:n,type:i,refinement:a,key:s[s.length-1],path:s,branch:o,...r,message:u}}function*ss(r,e,t,n){ca(r)||(r=[r]);for(const s of r){const o=la(s,e,t,n);o&&(yield o)}}function*os(r,e,t={}){const{path:n=[],branch:s=[r],coerce:o=!1,mask:i=!1}=t,a={path:n,branch:s};if(o&&(r=e.coercer(r,a),i&&e.type!=="type"&&pn(e.schema)&&pn(r)&&!Array.isArray(r)))for(const d in r)e.schema[d]===void 0&&delete r[d];let u=!0;for(const d of e.validator(r,a))u=!1,yield[d,void 0];for(let[d,p,m]of e.entries(r,a)){const V=os(p,m,{path:d===void 0?n:[...n,d],branch:d===void 0?s:[...s,p],coerce:o,mask:i});for(const C of V)C[0]?(u=!1,yield[C[0],void 0]):o&&(p=C[1],d===void 0?r=p:r instanceof Map?r.set(d,p):r instanceof Set?r.add(p):pn(r)&&(r[d]=p))}if(u)for(const d of e.refiner(r,a))u=!1,yield[d,void 0];u&&(yield[void 0,r])}class Ht{constructor(e){const{type:t,schema:n,validator:s,refiner:o,coercer:i=u=>u,entries:a=function*(){}}=e;this.type=t,this.schema=n,this.entries=a,this.coercer=i,s?this.validator=(u,d)=>{const p=s(u,d);return ss(p,d,this,u)}:this.validator=()=>[],o?this.refiner=(u,d)=>{const p=o(u,d);return ss(p,d,this,u)}:this.refiner=()=>[]}assert(e){return oo(e,this)}create(e){return Be(e,this)}is(e){return io(e,this)}mask(e){return fa(e,this)}validate(e,t={}){return ir(e,this,t)}}function oo(r,e){const t=ir(r,e);if(t[0])throw t[0]}function Be(r,e){const t=ir(r,e,{coerce:!0});if(t[0])throw t[0];return t[1]}function fa(r,e){const t=ir(r,e,{coerce:!0,mask:!0});if(t[0])throw t[0];return t[1]}function io(r,e){return!ir(r,e)[0]}function ir(r,e,t={}){const n=os(r,e,t),s=ua(n);return s[0]?[new aa(s[0],function*(){for(const i of n)i[0]&&(yield i[0])}),void 0]:[void 0,s[1]]}function Al(...r){const e=r.map(n=>n.schema),t=Object.assign({},...e);return xr(t)}function fn(r,e){return new Ht({type:r,schema:null,validator:e})}function Il(r,e){return new Ht({...r,refiner:(t,n)=>t===void 0||r.refiner(t,n),validator(t,n){return t===void 0?!0:(e(t,n),r.validator(t,n))}})}function Bl(r){return new Ht({type:"dynamic",schema:null,*entries(e,t){yield*r(e,t).entries(e,t)},validator(e,t){return r(e,t).validator(e,t)},coercer(e,t){return r(e,t).coercer(e,t)}})}function Rl(r){let e;return new Ht({type:"lazy",schema:null,*entries(t,n){var s;(s=e)!=null||(e=r()),yield*e.entries(t,n)},validator(t,n){var s;return(s=e)!=null||(e=r()),e.validator(t,n)},coercer(t,n){var s;return(s=e)!=null||(e=r()),e.coercer(t,n)}})}function Pl(r,e){const{schema:t}=r,n={...t};for(const s of e)delete n[s];return xr(n)}function Tl(r){const e=r instanceof Ht?{...r.schema}:{...r};for(const t in e)e[t]=Ze(e[t]);return xr(e)}function Ol(r,e){const{schema:t}=r,n={};for(const s of e)n[s]=t[s];return xr(n)}function Ll(r,e){return console.warn("superstruct@0.11 - The `struct` helper has been renamed to `define`."),fn(r,e)}function da(){return fn("any",()=>!0)}function Ce(r){return new Ht({type:"array",schema:r,*entries(e){if(r&&Array.isArray(e))for(const[t,n]of e.entries())yield[t,n,r]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||"Expected an array value, but received: "+jt(e)}})}function En(){return fn("boolean",r=>typeof r=="boolean")}function Cl(){return fn("date",r=>r instanceof Date&&!isNaN(r.getTime())||"Expected a valid `Date` object, but received: "+jt(r))}function Nl(r){const e={},t=r.map(n=>jt(n)).join();for(const n of r)e[n]=n;return new Ht({type:"enums",schema:e,validator(n){return r.includes(n)||"Expected one of `"+t+"`, but received: "+jt(n)}})}function Ul(){return fn("func",r=>typeof r=="function"||"Expected a function, but received: "+jt(r))}function is(r){return fn("instance",e=>e instanceof r||"Expected a `"+r.name+"` instance, but received: "+jt(e))}function zl(){return fn("integer",r=>typeof r=="number"&&!isNaN(r)&&Number.isInteger(r)||"Expected an integer, but received: "+jt(r))}function Kl(r){return new Ht({type:"intersection",schema:null,*entries(e,t){for(const n of r)yield*n.entries(e,t)},*validator(e,t){for(const n of r)yield*n.validator(e,t)},*refiner(e,t){for(const n of r)yield*n.refiner(e,t)}})}function Ot(r){const e=jt(r),t=typeof r;return new Ht({type:"literal",schema:t==="string"||t==="number"||t==="boolean"?r:null,validator(n){return n===r||"Expected the literal `"+e+"`, but received: "+jt(n)}})}function Dl(r,e){return new Ht({type:"map",schema:null,*entries(t){if(r&&e&&t instanceof Map)for(const[n,s]of t.entries())yield[n,n,r],yield[n,s,e]},coercer(t){return t instanceof Map?new Map(t):t},validator(t){return t instanceof Map||"Expected a `Map` object, but received: "+jt(t)}})}function ao(){return fn("never",()=>!1)}function Le(r){return new Ht({...r,validator:(e,t)=>e===null||r.validator(e,t),refiner:(e,t)=>e===null||r.refiner(e,t)})}function N(){return fn("number",r=>typeof r=="number"&&!isNaN(r)||"Expected a number, but received: "+jt(r))}function xr(r){const e=r?Object.keys(r):[],t=ao();return new Ht({type:"object",schema:r||null,*entries(n){if(r&&pn(n)){const s=new Set(Object.keys(n));for(const o of e)s.delete(o),yield[o,n[o],r[o]];for(const o of s)yield[o,n[o],t]}},validator(n){return pn(n)||"Expected an object, but received: "+jt(n)},coercer(n){return pn(n)?{...n}:n}})}function Ze(r){return new Ht({...r,validator:(e,t)=>e===void 0||r.validator(e,t),refiner:(e,t)=>e===void 0||r.refiner(e,t)})}function co(r,e){return new Ht({type:"record",schema:null,*entries(t){if(pn(t))for(const n in t){const s=t[n];yield[n,n,r],yield[n,s,e]}},validator(t){return pn(t)||"Expected an object, but received: "+jt(t)}})}function Ml(){return fn("regexp",r=>r instanceof RegExp)}function Wl(r){return new Ht({type:"set",schema:null,*entries(e){if(r&&e instanceof Set)for(const t of e)yield[t,t,r]},coercer(e){return e instanceof Set?new Set(e):e},validator(e){return e instanceof Set||"Expected a `Set` object, but received: "+jt(e)}})}function _e(){return fn("string",r=>typeof r=="string"||"Expected a string, but received: "+jt(r))}function as(r){const e=ao();return new Ht({type:"tuple",schema:null,*entries(t){if(Array.isArray(t)){const n=Math.max(r.length,t.length);for(let s=0;s<n;s++)yield[s,t[s],r[s]||e]}},validator(t){return Array.isArray(t)||"Expected an array, but received: "+jt(t)}})}function he(r){const e=Object.keys(r);return new Ht({type:"type",schema:r,*entries(t){if(pn(t))for(const n of e)yield[n,t[n],r[n]]},validator(t){return pn(t)||"Expected an object, but received: "+jt(t)}})}function sn(r){const e=r.map(t=>t.type).join(" | ");return new Ht({type:"union",schema:null,validator(t,n){const s=[];for(const o of r){const[...i]=os(t,o,n),[a]=i;if(a[0])for(const[u]of i)u&&s.push(u);else return[]}return["Expected the value to satisfy a union of `"+e+"`, but received: "+jt(t),...s]}})}function $n(){return fn("unknown",()=>!0)}function zn(r,e,t){return new Ht({...r,coercer:(n,s)=>io(n,e)?r.coercer(t(n,s),s):r.coercer(n,s)})}function Hl(r,e,t={}){return zn(r,$n(),n=>{const s=typeof e=="function"?e():e;if(n===void 0)return s;if(!t.strict&&so(n)&&so(s)){const o={...n};let i=!1;for(const a in s)o[a]===void 0&&(o[a]=s[a],i=!0);if(i)return o}return n})}function ql(r){return zn(r,_e(),e=>e.trim())}function Fl(r){const e="Expected an empty "+r.type;return ar(r,"empty",t=>{if(t instanceof Map||t instanceof Set){const{size:n}=t;return n===0||e+" but received one with a size of `"+n+"`"}else{const{length:n}=t;return n===0||e+" but received one with a length of `"+n+"`"}})}function Vl(r,e,t={}){const{exclusive:n}=t;return ar(r,"max",s=>n?s<e:s<=e||"Expected a "+r.type+" greater than "+(n?"":"or equal to ")+e+" but received `"+s+"`")}function Gl(r,e,t={}){const{exclusive:n}=t;return ar(r,"min",s=>n?s>e:s>=e||"Expected a "+r.type+" greater than "+(n?"":"or equal to ")+e+" but received `"+s+"`")}function jl(r,e){return ar(r,"pattern",t=>e.test(t)||"Expected a "+r.type+" matching `/"+e.source+'/` but received "'+t+'"')}function $l(r,e,t=e){const n="Expected a "+r.type,s=e===t?"of `"+e+"`":"between `"+e+"` and `"+t+"`";return ar(r,"size",o=>{if(typeof o=="number"||o instanceof Date)return e<=o&&o<=t||n+" "+s+" but received `"+o+"`";if(o instanceof Map||o instanceof Set){const{size:i}=o;return e<=i&&i<=t||n+" with a size "+s+" but received one with a size of `"+i+"`"}else{const{length:i}=o;return e<=i&&i<=t||n+" with a length "+s+" but received one with a length of `"+i+"`"}})}function ar(r,e,t){return new Ht({...r,*refiner(n,s){yield*r.refiner(n,s);const o=t(n,s),i=ss(o,s,r,n);for(const a of i)yield{...a,refinement:e}}})}var ha=A(31198),pa=A.n(ha),ga=A(66855),ya=A(89062);const[uo,lo,fo]=[[],[],[]],ba=BigInt(0),cr=BigInt(1),ma=BigInt(2),wa=BigInt(7),ka=BigInt(256),Sa=BigInt(113);for(let r=0,e=cr,t=1,n=0;r<24;r++){[t,n]=[n,(2*t+3*n)%5],uo.push(2*(5*n+t)),lo.push((r+1)*(r+2)/2%64);let s=ba;for(let o=0;o<7;o++)e=(e<<cr^(e>>wa)*Sa)%ka,e&ma&&(s^=cr<<(cr<<BigInt(o))-cr);fo.push(s)}const[Ea,_a]=Ve(fo,!0),ho=(r,e,t)=>t>32?Mt(r,e,t):$e(r,e,t),po=(r,e,t)=>t>32?mn(r,e,t):dt(r,e,t);function xa(r,e=24){const t=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let i=0;i<10;i++)t[i]=r[i]^r[i+10]^r[i+20]^r[i+30]^r[i+40];for(let i=0;i<10;i+=2){const a=(i+8)%10,u=(i+2)%10,d=t[u],p=t[u+1],m=ho(d,p,1)^t[a],V=po(d,p,1)^t[a+1];for(let C=0;C<50;C+=10)r[i+C]^=m,r[i+C+1]^=V}let s=r[2],o=r[3];for(let i=0;i<24;i++){const a=lo[i],u=ho(s,o,a),d=po(s,o,a),p=uo[i];s=r[p],o=r[p+1],r[p]=u,r[p+1]=d}for(let i=0;i<50;i+=10){for(let a=0;a<10;a++)t[a]=r[i+a];for(let a=0;a<10;a++)r[i+a]^=~t[(a+2)%10]&t[(a+4)%10]}r[0]^=Ea[n],r[1]^=_a[n]}t.fill(0)}class vr extends xe{constructor(e,t,n,s=!1,o=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=s,this.rounds=o,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Z(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=D(this.state)}keccak(){xa(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){H(this);const{blockLen:t,state:n}=this;e=ue(e);const s=e.length;for(let o=0;o<s;){const i=Math.min(t-this.pos,s-o);for(let a=0;a<i;a++)n[this.pos++]^=e[o++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:n,blockLen:s}=this;e[n]^=t,(t&128)!==0&&n===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){H(this,!1),B(e),this.finish();const t=this.state,{blockLen:n}=this;for(let s=0,o=e.length;s<o;){this.posOut>=n&&this.keccak();const i=Math.min(n-this.posOut,o-s);e.set(t.subarray(this.posOut,this.posOut+i),s),this.posOut+=i,s+=i}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Z(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(R(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:n,outputLen:s,rounds:o,enableXOF:i}=this;return e||(e=new vr(t,n,s,i,o)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=o,e.suffix=n,e.outputLen=s,e.enableXOF=i,e.destroyed=this.destroyed,e}}const va=(r,e,t)=>ie(()=>new vr(e,r,t)),Yl=null,Jl=null,Zl=null,Xl=null,Ql=null,go=va(1,136,256/8),ef=null,tf=null,nf=(r,e,t)=>wrapXOFConstructorWithOpts((n={})=>new vr(e,r,n.dkLen===void 0?t:n.dkLen,!0)),rf=null,sf=null;class yo extends xe{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,X(e);const n=ue(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,o=new Uint8Array(s);o.set(n.length>s?e.create().update(n).digest():n);for(let i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=e.create();for(let i=0;i<o.length;i++)o[i]^=106;this.oHash.update(o),o.fill(0)}update(e){return H(this),this.iHash.update(e),this}digestInto(e){H(this),B(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:s,destroyed:o,blockLen:i,outputLen:a}=this;return e=e,e.finished=s,e.destroyed=o,e.blockLen=i,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const bo=(r,e,t)=>new yo(r,e).update(t).digest();bo.create=(r,e)=>new yo(r,e);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Aa(r){const e=$r(r);jn(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:t,Fp:n,a:s}=e;if(t){if(!n.eql(s,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:Ia,hexToBytes:Ba}=h,Kn={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(r){const{Err:e}=Kn;if(r.length<2||r[0]!==2)throw new e("Invalid signature integer tag");const t=r[1],n=r.subarray(2,t+2);if(!t||n.length!==t)throw new e("Invalid signature integer: wrong length");if(n[0]&128)throw new e("Invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:Ia(n),l:r.subarray(t+2)}},toSig(r){const{Err:e}=Kn,t=typeof r=="string"?Ba(r):r;if(!(t instanceof Uint8Array))throw new Error("ui8a expected");let n=t.length;if(n<2||t[0]!=48)throw new e("Invalid signature tag");if(t[1]!==n-2)throw new e("Invalid signature: incorrect length");const{d:s,l:o}=Kn._parseInt(t.subarray(2)),{d:i,l:a}=Kn._parseInt(o);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:s,s:i}},hexFromSig(r){const e=d=>Number.parseInt(d[0],16)&8?"00"+d:d,t=d=>{const p=d.toString(16);return p.length&1?`0${p}`:p},n=e(t(r.s)),s=e(t(r.r)),o=n.length/2,i=s.length/2,a=t(o),u=t(i);return`30${t(i+o+4)}02${u}${s}02${a}${n}`}},gn=BigInt(0),Ct=BigInt(1),Cn=BigInt(2),Ar=BigInt(3),mo=BigInt(4);function Ra(r){const e=Aa(r),{Fp:t}=e,n=e.toBytes||((K,k,O)=>{const F=k.toAffine();return Yt(Uint8Array.from([4]),t.toBytes(F.x),t.toBytes(F.y))}),s=e.fromBytes||(K=>{const k=K.subarray(1),O=t.fromBytes(k.subarray(0,t.BYTES)),F=t.fromBytes(k.subarray(t.BYTES,2*t.BYTES));return{x:O,y:F}});function o(K){const{a:k,b:O}=e,F=t.sqr(K),de=t.mul(F,K);return t.add(t.add(de,t.mul(K,k)),O)}if(!t.eql(t.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function i(K){return typeof K=="bigint"&&gn<K&&K<e.n}function a(K){if(!i(K))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function u(K){const{allowedPrivateKeyLengths:k,nByteLength:O,wrapPrivateKey:F,n:de}=e;if(k&&typeof K!="bigint"){if(K instanceof Uint8Array&&(K=We(K)),typeof K!="string"||!k.includes(K.length))throw new Error("Invalid key");K=K.padStart(O*2,"0")}let pe;try{pe=typeof K=="bigint"?K:tt(Tt("private key",K,O))}catch{throw new Error(`private key must be ${O} bytes, hex or bigint, not ${typeof K}`)}return F&&(pe=It(pe,de)),a(pe),pe}const d=new Map;function p(K){if(!(K instanceof m))throw new Error("ProjectivePoint expected")}class m{constructor(k,O,F){if(this.px=k,this.py=O,this.pz=F,k==null||!t.isValid(k))throw new Error("x required");if(O==null||!t.isValid(O))throw new Error("y required");if(F==null||!t.isValid(F))throw new Error("z required")}static fromAffine(k){const{x:O,y:F}=k||{};if(!k||!t.isValid(O)||!t.isValid(F))throw new Error("invalid affine point");if(k instanceof m)throw new Error("projective point not allowed");const de=pe=>t.eql(pe,t.ZERO);return de(O)&&de(F)?m.ZERO:new m(O,F,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(k){const O=t.invertBatch(k.map(F=>F.pz));return k.map((F,de)=>F.toAffine(O[de])).map(m.fromAffine)}static fromHex(k){const O=m.fromAffine(s(Tt("pointHex",k)));return O.assertValidity(),O}static fromPrivateKey(k){return m.BASE.multiply(u(k))}_setWindowSize(k){this._WINDOW_SIZE=k,d.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!t.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:k,y:O}=this.toAffine();if(!t.isValid(k)||!t.isValid(O))throw new Error("bad point: x or y not FE");const F=t.sqr(O),de=o(k);if(!t.eql(F,de))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:k}=this.toAffine();if(t.isOdd)return!t.isOdd(k);throw new Error("Field doesn't support isOdd")}equals(k){p(k);const{px:O,py:F,pz:de}=this,{px:pe,py:Oe,pz:Te}=k,De=t.eql(t.mul(O,Te),t.mul(pe,de)),je=t.eql(t.mul(F,Te),t.mul(Oe,de));return De&&je}negate(){return new m(this.px,t.neg(this.py),this.pz)}double(){const{a:k,b:O}=e,F=t.mul(O,Ar),{px:de,py:pe,pz:Oe}=this;let Te=t.ZERO,De=t.ZERO,je=t.ZERO,Ge=t.mul(de,de),St=t.mul(pe,pe),yt=t.mul(Oe,Oe),ot=t.mul(de,pe);return ot=t.add(ot,ot),je=t.mul(de,Oe),je=t.add(je,je),Te=t.mul(k,je),De=t.mul(F,yt),De=t.add(Te,De),Te=t.sub(St,De),De=t.add(St,De),De=t.mul(Te,De),Te=t.mul(ot,Te),je=t.mul(F,je),yt=t.mul(k,yt),ot=t.sub(Ge,yt),ot=t.mul(k,ot),ot=t.add(ot,je),je=t.add(Ge,Ge),Ge=t.add(je,Ge),Ge=t.add(Ge,yt),Ge=t.mul(Ge,ot),De=t.add(De,Ge),yt=t.mul(pe,Oe),yt=t.add(yt,yt),Ge=t.mul(yt,ot),Te=t.sub(Te,Ge),je=t.mul(yt,St),je=t.add(je,je),je=t.add(je,je),new m(Te,De,je)}add(k){p(k);const{px:O,py:F,pz:de}=this,{px:pe,py:Oe,pz:Te}=k;let De=t.ZERO,je=t.ZERO,Ge=t.ZERO;const St=e.a,yt=t.mul(e.b,Ar);let ot=t.mul(O,pe),Ft=t.mul(F,Oe),Kt=t.mul(de,Te),dn=t.add(O,F),Re=t.add(pe,Oe);dn=t.mul(dn,Re),Re=t.add(ot,Ft),dn=t.sub(dn,Re),Re=t.add(O,de);let Me=t.add(pe,Te);return Re=t.mul(Re,Me),Me=t.add(ot,Kt),Re=t.sub(Re,Me),Me=t.add(F,de),De=t.add(Oe,Te),Me=t.mul(Me,De),De=t.add(Ft,Kt),Me=t.sub(Me,De),Ge=t.mul(St,Re),De=t.mul(yt,Kt),Ge=t.add(De,Ge),De=t.sub(Ft,Ge),Ge=t.add(Ft,Ge),je=t.mul(De,Ge),Ft=t.add(ot,ot),Ft=t.add(Ft,ot),Kt=t.mul(St,Kt),Re=t.mul(yt,Re),Ft=t.add(Ft,Kt),Kt=t.sub(ot,Kt),Kt=t.mul(St,Kt),Re=t.add(Re,Kt),ot=t.mul(Ft,Re),je=t.add(je,ot),ot=t.mul(Me,Re),De=t.mul(dn,De),De=t.sub(De,ot),ot=t.mul(dn,Ft),Ge=t.mul(Me,Ge),Ge=t.add(Ge,ot),new m(De,je,Ge)}subtract(k){return this.add(k.negate())}is0(){return this.equals(m.ZERO)}wNAF(k){return C.wNAFCached(this,d,k,O=>{const F=t.invertBatch(O.map(de=>de.pz));return O.map((de,pe)=>de.toAffine(F[pe])).map(m.fromAffine)})}multiplyUnsafe(k){const O=m.ZERO;if(k===gn)return O;if(a(k),k===Ct)return this;const{endo:F}=e;if(!F)return C.unsafeLadder(this,k);let{k1neg:de,k1:pe,k2neg:Oe,k2:Te}=F.splitScalar(k),De=O,je=O,Ge=this;for(;pe>gn||Te>gn;)pe&Ct&&(De=De.add(Ge)),Te&Ct&&(je=je.add(Ge)),Ge=Ge.double(),pe>>=Ct,Te>>=Ct;return de&&(De=De.negate()),Oe&&(je=je.negate()),je=new m(t.mul(je.px,F.beta),je.py,je.pz),De.add(je)}multiply(k){a(k);let O=k,F,de;const{endo:pe}=e;if(pe){const{k1neg:Oe,k1:Te,k2neg:De,k2:je}=pe.splitScalar(O);let{p:Ge,f:St}=this.wNAF(Te),{p:yt,f:ot}=this.wNAF(je);Ge=C.constTimeNegate(Oe,Ge),yt=C.constTimeNegate(De,yt),yt=new m(t.mul(yt.px,pe.beta),yt.py,yt.pz),F=Ge.add(yt),de=St.add(ot)}else{const{p:Oe,f:Te}=this.wNAF(O);F=Oe,de=Te}return m.normalizeZ([F,de])[0]}multiplyAndAddUnsafe(k,O,F){const de=m.BASE,pe=(Te,De)=>De===gn||De===Ct||!Te.equals(de)?Te.multiplyUnsafe(De):Te.multiply(De),Oe=pe(this,O).add(pe(k,F));return Oe.is0()?void 0:Oe}toAffine(k){const{px:O,py:F,pz:de}=this,pe=this.is0();k==null&&(k=pe?t.ONE:t.inv(de));const Oe=t.mul(O,k),Te=t.mul(F,k),De=t.mul(de,k);if(pe)return{x:t.ZERO,y:t.ZERO};if(!t.eql(De,t.ONE))throw new Error("invZ was invalid");return{x:Oe,y:Te}}isTorsionFree(){const{h:k,isTorsionFree:O}=e;if(k===Ct)return!0;if(O)return O(m,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:k,clearCofactor:O}=e;return k===Ct?this:O?O(m,this):this.multiplyUnsafe(e.h)}toRawBytes(k=!0){return this.assertValidity(),n(m,this,k)}toHex(k=!0){return We(this.toRawBytes(k))}}m.BASE=new m(e.Gx,e.Gy,t.ONE),m.ZERO=new m(t.ZERO,t.ONE,t.ZERO);const V=e.nBitLength,C=$s(m,e.endo?Math.ceil(V/2):V);return{CURVE:e,ProjectivePoint:m,normPrivateKeyToScalar:u,weierstrassEquation:o,isWithinCurveOrder:i}}function Pa(r){const e=$r(r);return jn(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function Ta(r){const e=Pa(r),{Fp:t,n}=e,s=t.BYTES+1,o=2*t.BYTES+1;function i(Re){return gn<Re&&Re<t.ORDER}function a(Re){return It(Re,n)}function u(Re){return Sr(Re,n)}const{ProjectivePoint:d,normPrivateKeyToScalar:p,weierstrassEquation:m,isWithinCurveOrder:V}=Ra({...e,toBytes(Re,Me,it){const Pe=Me.toAffine(),le=t.toBytes(Pe.x),Ke=Yt;return it?Ke(Uint8Array.from([Me.hasEvenY()?2:3]),le):Ke(Uint8Array.from([4]),le,t.toBytes(Pe.y))},fromBytes(Re){const Me=Re.length,it=Re[0],Pe=Re.subarray(1);if(Me===s&&(it===2||it===3)){const le=tt(Pe);if(!i(le))throw new Error("Point is not on curve");const Ke=m(le);let Ye=t.sqrt(Ke);const et=(Ye&Ct)===Ct;return(it&1)===1!==et&&(Ye=t.neg(Ye)),{x:le,y:Ye}}else if(Me===o&&it===4){const le=t.fromBytes(Pe.subarray(0,t.BYTES)),Ke=t.fromBytes(Pe.subarray(t.BYTES,2*t.BYTES));return{x:le,y:Ke}}else throw new Error(`Point of length ${Me} was invalid. Expected ${s} compressed bytes or ${o} uncompressed bytes`)}}),C=Re=>We(Pt(Re,e.nByteLength));function K(Re){const Me=n>>Ct;return Re>Me}function k(Re){return K(Re)?a(-Re):Re}const O=(Re,Me,it)=>tt(Re.slice(Me,it));class F{constructor(Me,it,Pe){this.r=Me,this.s=it,this.recovery=Pe,this.assertValidity()}static fromCompact(Me){const it=e.nByteLength;return Me=Tt("compactSignature",Me,it*2),new F(O(Me,0,it),O(Me,it,2*it))}static fromDER(Me){const{r:it,s:Pe}=Kn.toSig(Tt("DER",Me));return new F(it,Pe)}assertValidity(){if(!V(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!V(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(Me){return new F(this.r,this.s,Me)}recoverPublicKey(Me){const{r:it,s:Pe,recovery:le}=this,Ke=je(Tt("msgHash",Me));if(le==null||![0,1,2,3].includes(le))throw new Error("recovery id invalid");const Ye=le===2||le===3?it+e.n:it;if(Ye>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");const et=(le&1)===0?"02":"03",at=d.fromHex(et+C(Ye)),ft=u(Ye),kt=a(-Ke*ft),ht=a(Pe*ft),bt=d.BASE.multiplyAndAddUnsafe(at,kt,ht);if(!bt)throw new Error("point at infinify");return bt.assertValidity(),bt}hasHighS(){return K(this.s)}normalizeS(){return this.hasHighS()?new F(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return vt(this.toDERHex())}toDERHex(){return Kn.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return vt(this.toCompactHex())}toCompactHex(){return C(this.r)+C(this.s)}}const de={isValidPrivateKey(Re){try{return p(Re),!0}catch{return!1}},normPrivateKeyToScalar:p,randomPrivateKey:()=>{const Re=js(e.n);return Ci(e.randomBytes(Re),e.n)},precompute(Re=8,Me=d.BASE){return Me._setWindowSize(Re),Me.multiply(BigInt(3)),Me}};function pe(Re,Me=!0){return d.fromPrivateKey(Re).toRawBytes(Me)}function Oe(Re){const Me=Re instanceof Uint8Array,it=typeof Re=="string",Pe=(Me||it)&&Re.length;return Me?Pe===s||Pe===o:it?Pe===2*s||Pe===2*o:Re instanceof d}function Te(Re,Me,it=!0){if(Oe(Re))throw new Error("first arg must be private key");if(!Oe(Me))throw new Error("second arg must be public key");return d.fromHex(Me).multiply(p(Re)).toRawBytes(it)}const De=e.bits2int||function(Re){const Me=tt(Re),it=Re.length*8-e.nBitLength;return it>0?Me>>BigInt(it):Me},je=e.bits2int_modN||function(Re){return a(De(Re))},Ge=qr(e.nBitLength);function St(Re){if(typeof Re!="bigint")throw new Error("bigint expected");if(!(gn<=Re&&Re<Ge))throw new Error(`bigint expected < 2^${e.nBitLength}`);return Pt(Re,e.nByteLength)}function yt(Re,Me,it=ot){if(["recovered","canonical"].some(Ut=>Ut in it))throw new Error("sign() legacy options not supported");const{hash:Pe,randomBytes:le}=e;let{lowS:Ke,prehash:Ye,extraEntropy:et}=it;Ke==null&&(Ke=!0),Re=Tt("msgHash",Re),Ye&&(Re=Tt("prehashed msgHash",Pe(Re)));const at=je(Re),ft=p(Me),kt=[St(ft),St(at)];if(et!=null){const Ut=et===!0?le(t.BYTES):et;kt.push(Tt("extraEntropy",Ut))}const ht=Yt(...kt),bt=at;function Vt(Ut){const en=De(Ut);if(!V(en))return;const tn=u(en),nn=d.BASE.multiply(en).toAffine(),Dt=a(nn.x);if(Dt===gn)return;const bn=a(tn*a(bt+Dt*ft));if(bn===gn)return;let Vn=(nn.x===Dt?0:2)|Number(nn.y&Ct),br=bn;return Ke&&K(bn)&&(br=k(bn),Vn^=1),new F(Dt,br,Vn)}return{seed:ht,k2sig:Vt}}const ot={lowS:e.lowS,prehash:!1},Ft={lowS:e.lowS,prehash:!1};function Kt(Re,Me,it=ot){const{seed:Pe,k2sig:le}=yt(Re,Me,it),Ke=e;return Hs(Ke.hash.outputLen,Ke.nByteLength,Ke.hmac)(Pe,le)}d.BASE._setWindowSize(8);function dn(Re,Me,it,Pe=Ft){var nn;const le=Re;if(Me=Tt("msgHash",Me),it=Tt("publicKey",it),"strict"in Pe)throw new Error("options.strict was renamed to lowS");const{lowS:Ke,prehash:Ye}=Pe;let et,at;try{if(typeof le=="string"||le instanceof Uint8Array)try{et=F.fromDER(le)}catch(Dt){if(!(Dt instanceof Kn.Err))throw Dt;et=F.fromCompact(le)}else if(typeof le=="object"&&typeof le.r=="bigint"&&typeof le.s=="bigint"){const{r:Dt,s:bn}=le;et=new F(Dt,bn)}else throw new Error("PARSE");at=d.fromHex(it)}catch(Dt){if(Dt.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(Ke&&et.hasHighS())return!1;Ye&&(Me=e.hash(Me));const{r:ft,s:kt}=et,ht=je(Me),bt=u(kt),Vt=a(ht*bt),Ut=a(ft*bt),en=(nn=d.BASE.multiplyAndAddUnsafe(at,Vt,Ut))==null?void 0:nn.toAffine();return en?a(en.x)===ft:!1}return{CURVE:e,getPublicKey:pe,getSharedSecret:Te,sign:Kt,verify:dn,ProjectivePoint:d,Signature:F,utils:de}}function Oa(r,e){const t=r.ORDER;let n=gn;for(let K=t-Ct;K%Cn===gn;K/=Cn)n+=Ct;const s=n,o=Cn<<s-Ct-Ct,i=o*Cn,a=(t-Ct)/i,u=(a-Ct)/Cn,d=i-Ct,p=o,m=r.pow(e,a),V=r.pow(e,(a+Ct)/Cn);let C=(K,k)=>{let O=m,F=r.pow(k,d),de=r.sqr(F);de=r.mul(de,k);let pe=r.mul(K,de);pe=r.pow(pe,u),pe=r.mul(pe,F),F=r.mul(pe,k),de=r.mul(pe,K);let Oe=r.mul(de,F);pe=r.pow(Oe,p);let Te=r.eql(pe,r.ONE);F=r.mul(de,V),pe=r.mul(Oe,O),de=r.cmov(F,de,Te),Oe=r.cmov(pe,Oe,Te);for(let De=s;De>Ct;De--){let je=De-Cn;je=Cn<<je-Ct;let Ge=r.pow(Oe,je);const St=r.eql(Ge,r.ONE);F=r.mul(de,O),O=r.mul(O,O),Ge=r.mul(Oe,O),de=r.cmov(F,de,St),Oe=r.cmov(Ge,Oe,St)}return{isValid:Te,value:de}};if(r.ORDER%mo===Ar){const K=(r.ORDER-Ar)/mo,k=r.sqrt(r.neg(e));C=(O,F)=>{let de=r.sqr(F);const pe=r.mul(O,F);de=r.mul(de,pe);let Oe=r.pow(de,K);Oe=r.mul(Oe,pe);const Te=r.mul(Oe,k),De=r.mul(r.sqr(Oe),F),je=r.eql(De,O);let Ge=r.cmov(Te,Oe,je);return{isValid:je,value:Ge}}}return C}function of(r,e){if(mod.validateField(r),!r.isValid(e.A)||!r.isValid(e.B)||!r.isValid(e.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");const t=Oa(r,e.Z);if(!r.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let s,o,i,a,u,d,p,m;s=r.sqr(n),s=r.mul(s,e.Z),o=r.sqr(s),o=r.add(o,s),i=r.add(o,r.ONE),i=r.mul(i,e.B),a=r.cmov(e.Z,r.neg(o),!r.eql(o,r.ZERO)),a=r.mul(a,e.A),o=r.sqr(i),d=r.sqr(a),u=r.mul(d,e.A),o=r.add(o,u),o=r.mul(o,i),d=r.mul(d,a),u=r.mul(d,e.B),o=r.add(o,u),p=r.mul(s,i);const{isValid:V,value:C}=t(o,d);m=r.mul(s,n),m=r.mul(m,C),p=r.cmov(p,i,V),m=r.cmov(m,C,V);const K=r.isOdd(n)===r.isOdd(m);return m=r.cmov(r.neg(m),m,K),p=r.div(p,a),{x:p,y:m}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function La(r){return{hash:r,hmac:(e,...t)=>bo(r,e,Ae(...t)),randomBytes:ke}}function Ca(r,e){const t=n=>Ta({...r,...La(n)});return Object.freeze({...t(e),create:t})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ir=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Br=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),wo=BigInt(1),Rr=BigInt(2),ko=(r,e)=>(r+e/Rr)/e;function So(r){const e=Ir,t=BigInt(3),n=BigInt(6),s=BigInt(11),o=BigInt(22),i=BigInt(23),a=BigInt(44),u=BigInt(88),d=r*r*r%e,p=d*d*r%e,m=Lt(p,t,e)*p%e,V=Lt(m,t,e)*p%e,C=Lt(V,Rr,e)*d%e,K=Lt(C,s,e)*C%e,k=Lt(K,o,e)*K%e,O=Lt(k,a,e)*k%e,F=Lt(O,u,e)*O%e,de=Lt(F,a,e)*k%e,pe=Lt(de,t,e)*p%e,Oe=Lt(pe,i,e)*K%e,Te=Lt(Oe,n,e)*d%e,De=Lt(Te,Rr,e);if(!cs.eql(cs.sqr(De),r))throw new Error("Cannot find square root");return De}const cs=Vs(Ir,void 0,void 0,{sqrt:So}),ur=Ca({a:BigInt(0),b:BigInt(7),Fp:cs,n:Br,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{const e=Br,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-wo*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=t,i=BigInt("0x100000000000000000000000000000000"),a=ko(o*r,e),u=ko(-n*r,e);let d=It(r-a*t-u*s,e),p=It(-a*n-u*o,e);const m=d>i,V=p>i;if(m&&(d=e-d),V&&(p=e-p),d>i||p>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:m,k1:d,k2neg:V,k2:p}}}},ts),Pr=BigInt(0),Eo=r=>typeof r=="bigint"&&Pr<r&&r<Ir,Na=r=>typeof r=="bigint"&&Pr<r&&r<Br,_o={};function us(r,...e){let t=_o[r];if(t===void 0){const n=sha256(Uint8Array.from(r,s=>s.charCodeAt(0)));t=concatBytes(n,n),_o[r]=t}return sha256(concatBytes(t,...e))}const xo=r=>r.toRawBytes(!0).slice(1),ls=r=>numberToBytesBE(r,32),fs=r=>mod(r,Ir),lr=r=>mod(r,Br),ds=ur.ProjectivePoint,Ua=(r,e,t)=>ds.BASE.multiplyAndAddUnsafe(r,e,t);function hs(r){let e=ur.utils.normPrivateKeyToScalar(r),t=ds.fromPrivateKey(e);return{scalar:t.hasEvenY()?e:lr(-e),bytes:xo(t)}}function za(r){if(!Eo(r))throw new Error("bad x: need 0 < x < p");const e=fs(r*r),t=fs(e*r+BigInt(7));let n=So(t);n%Rr!==Pr&&(n=fs(-n));const s=new ds(r,n,wo);return s.assertValidity(),s}function vo(...r){return lr(bytesToNumberBE(us("BIP0340/challenge",...r)))}function af(r){return hs(r).bytes}function cf(r,e,t=randomBytes(32)){const n=ensureBytes("message",r),{bytes:s,scalar:o}=hs(e),i=ensureBytes("auxRand",t,32),a=ls(o^bytesToNumberBE(us("BIP0340/aux",i))),u=us("BIP0340/nonce",a,s,n),d=lr(bytesToNumberBE(u));if(d===Pr)throw new Error("sign failed: k is zero");const{bytes:p,scalar:m}=hs(d),V=vo(p,s,n),C=new Uint8Array(64);if(C.set(p,0),C.set(ls(lr(m+V*o)),32),!Ka(C,n,s))throw new Error("sign: Invalid signature produced");return C}function Ka(r,e,t){const n=ensureBytes("signature",r,64),s=ensureBytes("message",e),o=ensureBytes("publicKey",t,32);try{const i=za(bytesToNumberBE(o)),a=bytesToNumberBE(n.subarray(0,32));if(!Eo(a))return!1;const u=bytesToNumberBE(n.subarray(32,64));if(!Na(u))return!1;const d=vo(ls(a),xo(i),s),p=Ua(i,u,lr(-d));return!(!p||!p.hasEvenY()||p.toAffine().x!==a)}catch{return!1}}const uf=null,lf=null,ff=null,df=null,hf=null,pf=null,Da=Wt.utils.randomPrivateKey,Ao=()=>{const r=Wt.utils.randomPrivateKey(),e=Tr(r),t=new Uint8Array(64);return t.set(r),t.set(e,32),{publicKey:e,secretKey:t}},Tr=Wt.getPublicKey;function Io(r){try{return Wt.ExtendedPoint.fromHex(r),!0}catch{return!1}}const ps=(r,e)=>Wt.sign(r,e.slice(0,32)),Ma=Wt.verify,rt=r=>T.Buffer.isBuffer(r)?r:r instanceof Uint8Array?T.Buffer.from(r.buffer,r.byteOffset,r.byteLength):T.Buffer.from(r);class gs{constructor(e){Object.assign(this,e)}encode(){return T.Buffer.from((0,ns.serialize)(fr,this))}static decode(e){return(0,ns.deserialize)(fr,this,e)}static decodeUnchecked(e){return(0,ns.deserializeUnchecked)(fr,this,e)}}class Wa extends gs{constructor(e){if(super(e),this.enum="",Object.keys(e).length!==1)throw new Error("Enum can only take single value");Object.keys(e).map(t=>{this.enum=t})}}const fr=new Map;var Bo;let Ro;const Po=32,un=32;function Ha(r){return r._bn!==void 0}let To=1;Ro=Symbol.toStringTag;class ve extends gs{constructor(e){if(super({}),this._bn=void 0,Ha(e))this._bn=e._bn;else{if(typeof e=="string"){const t=Xt().decode(e);if(t.length!=un)throw new Error("Invalid public key input");this._bn=new(ro())(t)}else this._bn=new(ro())(e);if(this._bn.byteLength()>un)throw new Error("Invalid public key input")}}static unique(){const e=new ve(To);return To+=1,new ve(e.toBuffer())}equals(e){return this._bn.eq(e._bn)}toBase58(){return Xt().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(T.Buffer);if(e.length===un)return e;const t=T.Buffer.alloc(32);return e.copy(t,32-e.length),t}get[Ro](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(e,t,n){const s=T.Buffer.concat([e.toBuffer(),T.Buffer.from(t),n.toBuffer()]),o=ts(s);return new ve(o)}static createProgramAddressSync(e,t){let n=T.Buffer.alloc(0);e.forEach(function(o){if(o.length>Po)throw new TypeError("Max seed length exceeded");n=T.Buffer.concat([n,rt(o)])}),n=T.Buffer.concat([n,t.toBuffer(),T.Buffer.from("ProgramDerivedAddress")]);const s=ts(n);if(Io(s))throw new Error("Invalid seeds, address must fall off the curve");return new ve(s)}static async createProgramAddress(e,t){return this.createProgramAddressSync(e,t)}static findProgramAddressSync(e,t){let n=255,s;for(;n!=0;){try{const o=e.concat(T.Buffer.from([n]));s=this.createProgramAddressSync(o,t)}catch(o){if(o instanceof TypeError)throw o;n--;continue}return[s,n]}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 ve(e);return Io(t.toBytes())}}Bo=ve,ve.default=new Bo("11111111111111111111111111111111"),fr.set(ve,{kind:"struct",fields:[["_bn","u256"]]});class qa{constructor(e){if(this._publicKey=void 0,this._secretKey=void 0,e){const t=rt(e);if(e.length!==64)throw new Error("bad secret key size");this._publicKey=t.slice(32,64),this._secretKey=t.slice(0,32)}else this._secretKey=rt(Da()),this._publicKey=rt(Tr(this._secretKey))}get publicKey(){return new ve(this._publicKey)}get secretKey(){return T.Buffer.concat([this._secretKey,this._publicKey],64)}}const Fa=new ve("BPFLoader1111111111111111111111111111111111"),Nn=1280-40-8,Or=127,Yn=64;class ys extends Error{constructor(e){super(`Signature ${e} has expired: block height exceeded.`),this.signature=void 0,this.signature=e}}Object.defineProperty(ys.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});class bs 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(bs.prototype,"name",{value:"TransactionExpiredTimeoutError"});class Jn extends Error{constructor(e){super(`Signature ${e} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=e}}Object.defineProperty(Jn.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});class dr{constructor(e,t){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=e,this.accountKeysFromLookups=t}keySegments(){const e=[this.staticAccountKeys];return this.accountKeysFromLookups&&(e.push(this.accountKeysFromLookups.writable),e.push(this.accountKeysFromLookups.readonly)),e}get(e){for(const t of this.keySegments()){if(e<t.length)return t[e];e-=t.length}}get length(){return this.keySegments().flat().length}compileInstructions(e){if(this.length>255+1)throw new Error("Account index overflow encountered during compilation");const n=new Map;this.keySegments().flat().forEach((o,i)=>{n.set(o.toBase58(),i)});const s=o=>{const i=n.get(o.toBase58());if(i===void 0)throw new Error("Encountered an unknown instruction account key during compilation");return i};return e.map(o=>({programIdIndex:s(o.programId),accountKeyIndexes:o.keys.map(i=>s(i.pubkey)),data:o.data}))}}const ct=(r="publicKey")=>b.Ik(32,r),Va=(r="signature")=>b.Ik(64,r),Dn=(r="string")=>{const e=b.n_([b.Jq("length"),b.Jq("lengthPadding"),b.Ik(b.cv(b.Jq(),-8),"chars")],r),t=e.decode.bind(e),n=e.encode.bind(e),s=e;return s.decode=(o,i)=>t(o,i).chars.toString(),s.encode=(o,i,a)=>{const u={chars:T.Buffer.from(o,"utf8")};return n(u,i,a)},s.alloc=o=>b.Jq().span+b.Jq().span+T.Buffer.from(o,"utf8").length,s},Ga=(r="authorized")=>b.n_([ct("staker"),ct("withdrawer")],r),ja=(r="lockup")=>b.n_([b.gM("unixTimestamp"),b.gM("epoch"),ct("custodian")],r),$a=(r="voteInit")=>b.n_([ct("nodePubkey"),ct("authorizedVoter"),ct("authorizedWithdrawer"),b.u8("commission")],r),Ya=(r="voteAuthorizeWithSeedArgs")=>b.n_([b.Jq("voteAuthorizationType"),ct("currentAuthorityDerivedKeyOwnerPubkey"),Dn("currentAuthorityDerivedKeySeed"),ct("newAuthorized")],r);function Oo(r,e){const t=s=>{if(s.span>=0)return s.span;if(typeof s.alloc=="function")return s.alloc(e[s.property]);if("count"in s&&"elementLayout"in s){const o=e[s.property];if(Array.isArray(o))return o.length*t(s.elementLayout)}else if("fields"in s)return Oo({layout:s},e[s.property]);return 0};let n=0;return r.layout.fields.forEach(s=>{n+=t(s)}),n}function on(r){let e=0,t=0;for(;;){let n=r.shift();if(e|=(n&127)<<t*7,t+=1,(n&128)===0)break}return e}function ln(r,e){let t=e;for(;;){let n=t&127;if(t>>=7,t==0){r.push(n);break}else n|=128,r.push(n)}}function gt(r,e){if(!r)throw new Error(e||"Assertion failed")}class Lr{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,s=i=>{const a=i.toBase58();let u=n.get(a);return u===void 0&&(u={isSigner:!1,isWritable:!1,isInvoked:!1},n.set(a,u)),u},o=s(t);o.isSigner=!0,o.isWritable=!0;for(const i of e){s(i.programId).isInvoked=!0;for(const a of i.keys){const u=s(a.pubkey);u.isSigner||(u.isSigner=a.isSigner),u.isWritable||(u.isWritable=a.isWritable)}}return new Lr(t,n)}getMessageComponents(){const e=[...this.keyMetaMap.entries()];gt(e.length<=256,"Max static account keys length exceeded");const t=e.filter(([,u])=>u.isSigner&&u.isWritable),n=e.filter(([,u])=>u.isSigner&&!u.isWritable),s=e.filter(([,u])=>!u.isSigner&&u.isWritable),o=e.filter(([,u])=>!u.isSigner&&!u.isWritable),i={numRequiredSignatures:t.length+n.length,numReadonlySignedAccounts:n.length,numReadonlyUnsignedAccounts:o.length};{gt(t.length>0,"Expected at least one writable signer key");const[u]=t[0];gt(u===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}const a=[...t.map(([u])=>new ve(u)),...n.map(([u])=>new ve(u)),...s.map(([u])=>new ve(u)),...o.map(([u])=>new ve(u))];return[i,a]}extractTableLookup(e){const[t,n]=this.drainKeysFoundInLookupTable(e.state.addresses,i=>!i.isSigner&&!i.isInvoked&&i.isWritable),[s,o]=this.drainKeysFoundInLookupTable(e.state.addresses,i=>!i.isSigner&&!i.isInvoked&&!i.isWritable);if(!(t.length===0&&s.length===0))return[{accountKey:e.key,writableIndexes:t,readonlyIndexes:s},{writable:n,readonly:o}]}drainKeysFoundInLookupTable(e,t){const n=new Array,s=new Array;for(const[o,i]of this.keyMetaMap.entries())if(t(i)){const a=new ve(o),u=e.findIndex(d=>d.equals(a));u>=0&&(gt(u<256,"Max lookup table index exceeded"),n.push(u),s.push(a),this.keyMetaMap.delete(o))}return[n,s]}}class yn{constructor(e){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=e.header,this.accountKeys=e.accountKeys.map(t=>new ve(t)),this.recentBlockhash=e.recentBlockhash,this.instructions=e.instructions,this.instructions.forEach(t=>this.indexToProgramIds.set(t.programIdIndex,this.accountKeys[t.programIdIndex]))}get version(){return"legacy"}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:Xt().decode(e.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new dr(this.staticAccountKeys)}static compile(e){const t=Lr.compile(e.instructions,e.payerKey),[n,s]=t.getMessageComponents(),i=new dr(s).compileInstructions(e.instructions).map(a=>({programIdIndex:a.programIdIndex,accounts:a.accountKeyIndexes,data:Xt().encode(a.data)}));return new yn({header:n,accountKeys:s,recentBlockhash:e.recentBlockhash,instructions:i})}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){const t=this.header.numRequiredSignatures;if(e>=this.header.numRequiredSignatures){const n=e-t,o=this.accountKeys.length-t-this.header.numReadonlyUnsignedAccounts;return n<o}else{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=[];ln(t,e);const n=this.instructions.map(m=>{const{accounts:V,programIdIndex:C}=m,K=Array.from(Xt().decode(m.data));let k=[];ln(k,V.length);let O=[];return ln(O,K.length),{programIdIndex:C,keyIndicesCount:T.Buffer.from(k),keyIndices:V,dataLength:T.Buffer.from(O),data:K}});let s=[];ln(s,n.length);let o=T.Buffer.alloc(Nn);T.Buffer.from(s).copy(o);let i=s.length;n.forEach(m=>{const C=b.n_([b.u8("programIdIndex"),b.Ik(m.keyIndicesCount.length,"keyIndicesCount"),b.A9(b.u8("keyIndex"),m.keyIndices.length,"keyIndices"),b.Ik(m.dataLength.length,"dataLength"),b.A9(b.u8("userdatum"),m.data.length,"data")]).encode(m,o,i);i+=C}),o=o.slice(0,i);const a=b.n_([b.Ik(1,"numRequiredSignatures"),b.Ik(1,"numReadonlySignedAccounts"),b.Ik(1,"numReadonlyUnsignedAccounts"),b.Ik(t.length,"keyCount"),b.A9(ct("key"),e,"keys"),ct("recentBlockhash")]),u={numRequiredSignatures:T.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:T.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:T.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:T.Buffer.from(t),keys:this.accountKeys.map(m=>rt(m.toBytes())),recentBlockhash:Xt().decode(this.recentBlockhash)};let d=T.Buffer.alloc(2048);const p=a.encode(u,d);return o.copy(d,p),d.slice(0,p+o.length)}static from(e){let t=[...e];const n=t.shift();if(n!==(n&Or))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const s=t.shift(),o=t.shift(),i=on(t);let a=[];for(let V=0;V<i;V++){const C=t.slice(0,un);t=t.slice(un),a.push(new ve(T.Buffer.from(C)))}const u=t.slice(0,un);t=t.slice(un);const d=on(t);let p=[];for(let V=0;V<d;V++){const C=t.shift(),K=on(t),k=t.slice(0,K);t=t.slice(K);const O=on(t),F=t.slice(0,O),de=Xt().encode(T.Buffer.from(F));t=t.slice(O),p.push({programIdIndex:C,accounts:k,data:de})}const m={header:{numRequiredSignatures:n,numReadonlySignedAccounts:s,numReadonlyUnsignedAccounts:o},recentBlockhash:Xt().encode(T.Buffer.from(u)),accountKeys:a,instructions:p};return new yn(m)}}class Mn{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 dr(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 s=e-n,o=this.addressTableLookups.reduce((i,a)=>i+a.writableIndexes.length,0);return s<o}else if(e>=this.header.numRequiredSignatures){const s=e-t,i=n-t-this.header.numReadonlyUnsignedAccounts;return s<i}else{const s=t-this.header.numReadonlySignedAccounts;return e<s}}resolveAddressTableLookups(e){const t={writable:[],readonly:[]};for(const n of this.addressTableLookups){const s=e.find(o=>o.key.equals(n.accountKey));if(!s)throw new Error(`Failed to find address lookup table account for table key ${n.accountKey.toBase58()}`);for(const o of n.writableIndexes)if(o<s.state.addresses.length)t.writable.push(s.state.addresses[o]);else throw new Error(`Failed to find address for index ${o} in address lookup table ${n.accountKey.toBase58()}`);for(const o of n.readonlyIndexes)if(o<s.state.addresses.length)t.readonly.push(s.state.addresses[o]);else throw new Error(`Failed to find address for index ${o} in address lookup table ${n.accountKey.toBase58()}`)}return t}static compile(e){const t=Lr.compile(e.instructions,e.payerKey),n=new Array,s={writable:new Array,readonly:new Array},o=e.addressLookupTableAccounts||[];for(const p of o){const m=t.extractTableLookup(p);if(m!==void 0){const[V,{writable:C,readonly:K}]=m;n.push(V),s.writable.push(...C),s.readonly.push(...K)}}const[i,a]=t.getMessageComponents(),d=new dr(a,s).compileInstructions(e.instructions);return new Mn({header:i,staticAccountKeys:a,recentBlockhash:e.recentBlockhash,compiledInstructions:d,addressTableLookups:n})}serialize(){const e=Array();ln(e,this.staticAccountKeys.length);const t=this.serializeInstructions(),n=Array();ln(n,this.compiledInstructions.length);const s=this.serializeAddressTableLookups(),o=Array();ln(o,this.addressTableLookups.length);const i=b.n_([b.u8("prefix"),b.n_([b.u8("numRequiredSignatures"),b.u8("numReadonlySignedAccounts"),b.u8("numReadonlyUnsignedAccounts")],"header"),b.Ik(e.length,"staticAccountKeysLength"),b.A9(ct(),this.staticAccountKeys.length,"staticAccountKeys"),ct("recentBlockhash"),b.Ik(n.length,"instructionsLength"),b.Ik(t.length,"serializedInstructions"),b.Ik(o.length,"addressTableLookupsLength"),b.Ik(s.length,"serializedAddressTableLookups")]),a=new Uint8Array(Nn),u=1<<7,d=i.encode({prefix:u,header:this.header,staticAccountKeysLength:new Uint8Array(e),staticAccountKeys:this.staticAccountKeys.map(p=>p.toBytes()),recentBlockhash:Xt().decode(this.recentBlockhash),instructionsLength:new Uint8Array(n),serializedInstructions:t,addressTableLookupsLength:new Uint8Array(o),serializedAddressTableLookups:s},a);return a.slice(0,d)}serializeInstructions(){let e=0;const t=new Uint8Array(Nn);for(const n of this.compiledInstructions){const s=Array();ln(s,n.accountKeyIndexes.length);const o=Array();ln(o,n.data.length);const i=b.n_([b.u8("programIdIndex"),b.Ik(s.length,"encodedAccountKeyIndexesLength"),b.A9(b.u8(),n.accountKeyIndexes.length,"accountKeyIndexes"),b.Ik(o.length,"encodedDataLength"),b.Ik(n.data.length,"data")]);e+=i.encode({programIdIndex:n.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(s),accountKeyIndexes:n.accountKeyIndexes,encodedDataLength:new Uint8Array(o),data:n.data},t,e)}return t.slice(0,e)}serializeAddressTableLookups(){let e=0;const t=new Uint8Array(Nn);for(const n of this.addressTableLookups){const s=Array();ln(s,n.writableIndexes.length);const o=Array();ln(o,n.readonlyIndexes.length);const i=b.n_([ct("accountKey"),b.Ik(s.length,"encodedWritableIndexesLength"),b.A9(b.u8(),n.writableIndexes.length,"writableIndexes"),b.Ik(o.length,"encodedReadonlyIndexesLength"),b.A9(b.u8(),n.readonlyIndexes.length,"readonlyIndexes")]);e+=i.encode({accountKey:n.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(s),writableIndexes:n.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(o),readonlyIndexes:n.readonlyIndexes},t,e)}return t.slice(0,e)}static deserialize(e){let t=[...e];const n=t.shift(),s=n&Or;gt(n!==s,"Expected versioned message but received legacy message");const o=s;gt(o===0,`Expected versioned message with version 0 but found version ${o}`);const i={numRequiredSignatures:t.shift(),numReadonlySignedAccounts:t.shift(),numReadonlyUnsignedAccounts:t.shift()},a=[],u=on(t);for(let K=0;K<u;K++)a.push(new ve(t.splice(0,un)));const d=Xt().encode(t.splice(0,un)),p=on(t),m=[];for(let K=0;K<p;K++){const k=t.shift(),O=on(t),F=t.splice(0,O),de=on(t),pe=new Uint8Array(t.splice(0,de));m.push({programIdIndex:k,accountKeyIndexes:F,data:pe})}const V=on(t),C=[];for(let K=0;K<V;K++){const k=new ve(t.splice(0,un)),O=on(t),F=t.splice(0,O),de=on(t),pe=t.splice(0,de);C.push({accountKey:k,writableIndexes:F,readonlyIndexes:pe})}return new Mn({header:i,staticAccountKeys:a,recentBlockhash:d,compiledInstructions:m,addressTableLookups:C})}}const ms={deserializeMessageVersion(r){const e=r[0],t=e&Or;return t===e?"legacy":t},deserialize:r=>{const e=ms.deserializeMessageVersion(r);if(e==="legacy")return yn.from(r);if(e===0)return Mn.deserialize(r);throw new Error(`Transaction message version ${e} deserialization is not supported`)}};let An=function(r){return r[r.BLOCKHEIGHT_EXCEEDED=0]="BLOCKHEIGHT_EXCEEDED",r[r.PROCESSED=1]="PROCESSED",r[r.TIMED_OUT=2]="TIMED_OUT",r[r.NONCE_INVALID=3]="NONCE_INVALID",r}({});const Ja=T.Buffer.alloc(Yn).fill(0);class _t{constructor(e){this.keys=void 0,this.programId=void 0,this.data=T.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 mt{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(e.length===0)throw new Error("No instructions");return e.forEach(t=>{"instructions"in t?this.instructions=this.instructions.concat(t.instructions):"data"in t&&"programId"in t&&"keys"in t?this.instructions.push(t):this.instructions.push(new _t(t))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let e,t;if(this.nonceInfo?(e=this.nonceInfo.nonce,this.instructions[0]!=this.nonceInfo.nonceInstruction?t=[this.nonceInfo.nonceInstruction,...this.instructions]:t=this.instructions):(e=this.recentBlockhash,t=this.instructions),!e)throw new Error("Transaction recentBlockhash required");t.length<1&&console.warn("No instructions provided");let n;if(this.feePayer)n=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)n=this.signatures[0].publicKey;else throw new Error("Transaction fee payer required");for(let k=0;k<t.length;k++)if(t[k].programId===void 0)throw new Error(`Transaction instruction index ${k} has undefined program id`);const s=[],o=[];t.forEach(k=>{k.keys.forEach(F=>{o.push({...F})});const O=k.programId.toString();s.includes(O)||s.push(O)}),s.forEach(k=>{o.push({pubkey:new ve(k),isSigner:!1,isWritable:!1})});const i=[];o.forEach(k=>{const O=k.pubkey.toString(),F=i.findIndex(de=>de.pubkey.toString()===O);F>-1?(i[F].isWritable=i[F].isWritable||k.isWritable,i[F].isSigner=i[F].isSigner||k.isSigner):i.push(k)}),i.sort(function(k,O){if(k.isSigner!==O.isSigner)return k.isSigner?-1:1;if(k.isWritable!==O.isWritable)return k.isWritable?-1:1;const F={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return k.pubkey.toBase58().localeCompare(O.pubkey.toBase58(),"en",F)});const a=i.findIndex(k=>k.pubkey.equals(n));if(a>-1){const[k]=i.splice(a,1);k.isSigner=!0,k.isWritable=!0,i.unshift(k)}else i.unshift({pubkey:n,isSigner:!0,isWritable:!0});for(const k of this.signatures){const O=i.findIndex(F=>F.pubkey.equals(k.publicKey));if(O>-1)i[O].isSigner||(i[O].isSigner=!0,console.warn("Transaction references a signature that is unnecessary, only the fee payer and instruction signer accounts should sign a transaction. This behavior is deprecated and will throw an error in the next major version release."));else throw new Error(`unknown signer: ${k.publicKey.toString()}`)}let u=0,d=0,p=0;const m=[],V=[];i.forEach(({pubkey:k,isSigner:O,isWritable:F})=>{O?(m.push(k.toString()),u+=1,F||(d+=1)):(V.push(k.toString()),F||(p+=1))});const C=m.concat(V),K=t.map(k=>{const{data:O,programId:F}=k;return{programIdIndex:C.indexOf(F.toString()),accounts:k.keys.map(de=>C.indexOf(de.pubkey.toString())),data:Xt().encode(O)}});return K.forEach(k=>{gt(k.programIdIndex>=0),k.accounts.forEach(O=>gt(O>=0))}),new yn({header:{numRequiredSignatures:u,numReadonlySignedAccounts:d,numReadonlyUnsignedAccounts:p},accountKeys:C,recentBlockhash:e,instructions:K})}_compile(){const e=this.compileMessage(),t=e.accountKeys.slice(0,e.header.numRequiredSignatures);return this.signatures.length===t.length&&this.signatures.every((s,o)=>t[o].equals(s.publicKey))||(this.signatures=t.map(n=>({signature:null,publicKey:n}))),e}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(e){return(await e.getFeeForMessage(this.compileMessage())).value}setSigners(...e){if(e.length===0)throw new Error("No signers");const t=new Set;this.signatures=e.filter(n=>{const s=n.toString();return t.has(s)?!1:(t.add(s),!0)}).map(n=>({signature:null,publicKey:n}))}sign(...e){if(e.length===0)throw new Error("No signers");const t=new Set,n=[];for(const o of e){const i=o.publicKey.toString();t.has(i)||(t.add(i),n.push(o))}this.signatures=n.map(o=>({signature:null,publicKey:o.publicKey}));const s=this._compile();this._partialSign(s,...n)}partialSign(...e){if(e.length===0)throw new Error("No signers");const t=new Set,n=[];for(const o of e){const i=o.publicKey.toString();t.has(i)||(t.add(i),n.push(o))}const s=this._compile();this._partialSign(s,...n)}_partialSign(e,...t){const n=e.serialize();t.forEach(s=>{const o=ps(n,s.secretKey);this._addSignature(s.publicKey,rt(o))})}addSignature(e,t){this._compile(),this._addSignature(e,t)}_addSignature(e,t){gt(t.length===64);const n=this.signatures.findIndex(s=>e.equals(s.publicKey));if(n<0)throw new Error(`unknown signer: ${e.toString()}`);this.signatures[n].signature=T.Buffer.from(t)}verifySignatures(e){return this._verifySignatures(this.serializeMessage(),e===void 0?!0:e)}_verifySignatures(e,t){for(const{signature:n,publicKey:s}of this.signatures)if(n===null){if(t)return!1}else if(!Ma(n,e,s.toBytes()))return!1;return!0}serialize(e){const{requireAllSignatures:t,verifySignatures:n}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},e),s=this.serializeMessage();if(n&&!this._verifySignatures(s,t))throw new Error("Signature verification failed");return this._serialize(s)}_serialize(e){const{signatures:t}=this,n=[];ln(n,t.length);const s=n.length+t.length*64+e.length,o=T.Buffer.alloc(s);return gt(t.length<256),T.Buffer.from(n).copy(o,0),t.forEach(({signature:i},a)=>{i!==null&&(gt(i.length===64,"signature has invalid length"),T.Buffer.from(i).copy(o,n.length+a*64))}),e.copy(o,n.length+t.length*64),gt(o.length<=Nn,`Transaction too large: ${o.length} > ${Nn}`),o}get keys(){return gt(this.instructions.length===1),this.instructions[0].keys.map(e=>e.pubkey)}get programId(){return gt(this.instructions.length===1),this.instructions[0].programId}get data(){return gt(this.instructions.length===1),this.instructions[0].data}static from(e){let t=[...e];const n=on(t);let s=[];for(let o=0;o<n;o++){const i=t.slice(0,Yn);t=t.slice(Yn),s.push(Xt().encode(T.Buffer.from(i)))}return mt.populate(yn.from(t),s)}static populate(e,t=[]){const n=new mt;return n.recentBlockhash=e.recentBlockhash,e.header.numRequiredSignatures>0&&(n.feePayer=e.accountKeys[0]),t.forEach((s,o)=>{const i={signature:s==Xt().encode(Ja)?null:Xt().decode(s),publicKey:e.accountKeys[o]};n.signatures.push(i)}),e.instructions.forEach(s=>{const o=s.accounts.map(i=>{const a=e.accountKeys[i];return{pubkey:a,isSigner:n.signatures.some(u=>u.publicKey.toString()===a.toString())||e.isAccountSigner(i),isWritable:e.isAccountWritable(i)}});n.instructions.push(new _t({keys:o,programId:e.accountKeys[s.programIdIndex],data:Xt().decode(s.data)}))}),n._message=e,n._json=n.toJSON(),n}}class ws{constructor(e){this.payerKey=void 0,this.instructions=void 0,this.recentBlockhash=void 0,this.payerKey=e.payerKey,this.instructions=e.instructions,this.recentBlockhash=e.recentBlockhash}static decompile(e,t){const{header:n,compiledInstructions:s,recentBlockhash:o}=e,{numRequiredSignatures:i,numReadonlySignedAccounts:a,numReadonlyUnsignedAccounts:u}=n,d=i-a;gt(d>0,"Message header is invalid");const p=e.staticAccountKeys.length-i-u;gt(p>=0,"Message header is invalid");const m=e.getAccountKeys(t),V=m.get(0);if(V===void 0)throw new Error("Failed to decompile message because no account keys were found");const C=[];for(const K of s){const k=[];for(const F of K.accountKeyIndexes){const de=m.get(F);if(de===void 0)throw new Error(`Failed to find key for account key index ${F}`);const pe=F<i;let Oe;pe?Oe=F<d:F<m.staticAccountKeys.length?Oe=F-i<p:Oe=F-m.staticAccountKeys.length<m.accountKeysFromLookups.writable.length,k.push({pubkey:de,isSigner:F<n.numRequiredSignatures,isWritable:Oe})}const O=m.get(K.programIdIndex);if(O===void 0)throw new Error(`Failed to find program id for program id index ${K.programIdIndex}`);C.push(new _t({programId:O,data:rt(K.data),keys:k}))}return new ws({payerKey:V,instructions:C,recentBlockhash:o})}compileToLegacyMessage(){return yn.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions})}compileToV0Message(e){return Mn.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions,addressLookupTableAccounts:e})}}class ks{get version(){return this.message.version}constructor(e,t){if(this.signatures=void 0,this.message=void 0,t!==void 0)gt(t.length===e.header.numRequiredSignatures,"Expected signatures length to be equal to the number of required signatures"),this.signatures=t;else{const n=[];for(let s=0;s<e.header.numRequiredSignatures;s++)n.push(new Uint8Array(Yn));this.signatures=n}this.message=e}serialize(){const e=this.message.serialize(),t=Array();ln(t,this.signatures.length);const n=b.n_([b.Ik(t.length,"encodedSignaturesLength"),b.A9(Va(),this.signatures.length,"signatures"),b.Ik(e.length,"serializedMessage")]),s=new Uint8Array(2048),o=n.encode({encodedSignaturesLength:new Uint8Array(t),signatures:this.signatures,serializedMessage:e},s);return s.slice(0,o)}static deserialize(e){let t=[...e];const n=[],s=on(t);for(let i=0;i<s;i++)n.push(new Uint8Array(t.splice(0,Yn)));const o=ms.deserialize(new Uint8Array(t));return new ks(o,n)}sign(e){const t=this.message.serialize(),n=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures);for(const s of e){const o=n.findIndex(i=>i.equals(s.publicKey));gt(o>=0,`Cannot sign with non signer key ${s.publicKey.toBase58()}`),this.signatures[o]=ps(t,s.secretKey)}}addSignature(e,t){gt(t.byteLength===64,"Signature must be 64 bytes long");const s=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex(o=>o.equals(e));gt(s>=0,`Can not add signature; \`${e.toBase58()}\` is not required to sign this transaction`),this.signatures[s]=t}}const Lo=1e3/(160/64),_n=new ve("SysvarC1ock11111111111111111111111111111111"),Za=new ve("SysvarEpochSchedu1e111111111111111111111111"),Xa=new ve("Sysvar1nstructions1111111111111111111111111"),Cr=new ve("SysvarRecentB1ockHashes11111111111111111111"),Zn=new ve("SysvarRent111111111111111111111111111111111"),Qa=new ve("SysvarRewards111111111111111111111111111111"),ec=new ve("SysvarS1otHashes111111111111111111111111111"),tc=new ve("SysvarS1otHistory11111111111111111111111111"),Nr=new ve("SysvarStakeHistory1111111111111111111111111");async function Ss(r,e,t,n){const s=n&&{skipPreflight:n.skipPreflight,preflightCommitment:n.preflightCommitment||n.commitment,maxRetries:n.maxRetries,minContextSlot:n.minContextSlot},o=await r.sendTransaction(e,t,s);let i;if(e.recentBlockhash!=null&&e.lastValidBlockHeight!=null)i=(await r.confirmTransaction({abortSignal:n==null?void 0:n.abortSignal,signature:o,blockhash:e.recentBlockhash,lastValidBlockHeight:e.lastValidBlockHeight},n&&n.commitment)).value;else if(e.minNonceContextSlot!=null&&e.nonceInfo!=null){const{nonceInstruction:a}=e.nonceInfo,u=a.keys[0].pubkey;i=(await r.confirmTransaction({abortSignal:n==null?void 0:n.abortSignal,minContextSlot:e.minNonceContextSlot,nonceAccountPubkey:u,nonceValue:e.nonceInfo.nonce,signature:o},n&&n.commitment)).value}else(n==null?void 0:n.abortSignal)!=null&&console.warn("sendAndConfirmTransaction(): A transaction with a deprecated confirmation strategy was supplied along with an `abortSignal`. Only transactions having `lastValidBlockHeight` or a combination of `nonceInfo` and `minNonceContextSlot` are abortable."),i=(await r.confirmTransaction(o,n&&n.commitment)).value;if(i.err)throw new Error(`Transaction ${o} failed (${JSON.stringify(i)})`);return o}function Wn(r){return new Promise(e=>setTimeout(e,r))}function pt(r,e){const t=r.layout.span>=0?r.layout.span:Oo(r,e),n=T.Buffer.alloc(t),s=Object.assign({instruction:r.index},e);return r.layout.encode(s,n),n}function wt(r,e){let t;try{t=r.layout.decode(e)}catch(n){throw new Error("invalid instruction; "+n)}if(t.instruction!==r.index)throw new Error(`invalid instruction; instruction index mismatch ${t.instruction} != ${r.index}`);return t}const Co=b._O("lamportsPerSignature"),No=b.n_([b.Jq("version"),b.Jq("state"),ct("authorizedPubkey"),ct("nonce"),b.n_([Co],"feeCalculator")]),Es=No.span;class Ur{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=No.decode(rt(e),0);return new Ur({authorizedPubkey:new ve(t.authorizedPubkey),nonce:new ve(t.nonce).toString(),feeCalculator:t.feeCalculator})}}const nc=r=>{const e=r.decode.bind(r),t=r.encode.bind(r);return{decode:e,encode:t}},Xn=(r=>e=>{const t=(0,b.Ik)(r,e),{encode:n,decode:s}=nc(t),o=t;return o.decode=(i,a)=>{const u=s(i,a);return(0,rs.oU)(T.Buffer.from(u))},o.encode=(i,a,u)=>{const d=(0,rs.k$)(i,r);return n(d,a,u)},o})(8);class rc{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);const n=b.Jq("instruction").decode(e.data);let s;for(const[o,i]of Object.entries(At))if(i.index==n){s=o;break}if(!s)throw new Error("Instruction type incorrect; not a SystemInstruction");return s}static decodeCreateAccount(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{lamports:t,space:n,programId:s}=wt(At.Create,e.data);return{fromPubkey:e.keys[0].pubkey,newAccountPubkey:e.keys[1].pubkey,lamports:t,space:n,programId:new ve(s)}}static decodeTransfer(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{lamports:t}=wt(At.Transfer,e.data);return{fromPubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,lamports:t}}static decodeTransferWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{lamports:t,seed:n,programId:s}=wt(At.TransferWithSeed,e.data);return{fromPubkey:e.keys[0].pubkey,basePubkey:e.keys[1].pubkey,toPubkey:e.keys[2].pubkey,lamports:t,seed:n,programId:new ve(s)}}static decodeAllocate(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);const{space:t}=wt(At.Allocate,e.data);return{accountPubkey:e.keys[0].pubkey,space:t}}static decodeAllocateWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);const{base:t,seed:n,space:s,programId:o}=wt(At.AllocateWithSeed,e.data);return{accountPubkey:e.keys[0].pubkey,basePubkey:new ve(t),seed:n,space:s,programId:new ve(o)}}static decodeAssign(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);const{programId:t}=wt(At.Assign,e.data);return{accountPubkey:e.keys[0].pubkey,programId:new ve(t)}}static decodeAssignWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);const{base:t,seed:n,programId:s}=wt(At.AssignWithSeed,e.data);return{accountPubkey:e.keys[0].pubkey,basePubkey:new ve(t),seed:n,programId:new ve(s)}}static decodeCreateWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{base:t,seed:n,lamports:s,space:o,programId:i}=wt(At.CreateWithSeed,e.data);return{fromPubkey:e.keys[0].pubkey,newAccountPubkey:e.keys[1].pubkey,basePubkey:new ve(t),seed:n,lamports:s,space:o,programId:new ve(i)}}static decodeNonceInitialize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{authorized:t}=wt(At.InitializeNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,authorizedPubkey:new ve(t)}}static decodeNonceAdvance(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3),wt(At.AdvanceNonceAccount,e.data),{noncePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey}}static decodeNonceWithdraw(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,5);const{lamports:t}=wt(At.WithdrawNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[4].pubkey,lamports:t}}static decodeNonceAuthorize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{authorized:t}=wt(At.AuthorizeNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[1].pubkey,newAuthorizedPubkey:new ve(t)}}static checkProgramId(e){if(!e.equals(Qt.programId))throw new Error("invalid instruction; programId is not SystemProgram")}static checkKeyLength(e,t){if(e.length<t)throw new Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}}const At=Object.freeze({Create:{index:0,layout:b.n_([b.Jq("instruction"),b.gM("lamports"),b.gM("space"),ct("programId")])},Assign:{index:1,layout:b.n_([b.Jq("instruction"),ct("programId")])},Transfer:{index:2,layout:b.n_([b.Jq("instruction"),Xn("lamports")])},CreateWithSeed:{index:3,layout:b.n_([b.Jq("instruction"),ct("base"),Dn("seed"),b.gM("lamports"),b.gM("space"),ct("programId")])},AdvanceNonceAccount:{index:4,layout:b.n_([b.Jq("instruction")])},WithdrawNonceAccount:{index:5,layout:b.n_([b.Jq("instruction"),b.gM("lamports")])},InitializeNonceAccount:{index:6,layout:b.n_([b.Jq("instruction"),ct("authorized")])},AuthorizeNonceAccount:{index:7,layout:b.n_([b.Jq("instruction"),ct("authorized")])},Allocate:{index:8,layout:b.n_([b.Jq("instruction"),b.gM("space")])},AllocateWithSeed:{index:9,layout:b.n_([b.Jq("instruction"),ct("base"),Dn("seed"),b.gM("space"),ct("programId")])},AssignWithSeed:{index:10,layout:b.n_([b.Jq("instruction"),ct("base"),Dn("seed"),ct("programId")])},TransferWithSeed:{index:11,layout:b.n_([b.Jq("instruction"),Xn("lamports"),Dn("seed"),ct("programId")])},UpgradeNonceAccount:{index:12,layout:b.n_([b.Jq("instruction")])}});class Qt{constructor(){}static createAccount(e){const t=At.Create,n=pt(t,{lamports:e.lamports,space:e.space,programId:rt(e.programId.toBuffer())});return new _t({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 s=At.TransferWithSeed;t=pt(s,{lamports:BigInt(e.lamports),seed:e.seed,programId:rt(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 s=At.Transfer;t=pt(s,{lamports:BigInt(e.lamports)}),n=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}return new _t({keys:n,programId:this.programId,data:t})}static assign(e){let t,n;if("basePubkey"in e){const s=At.AssignWithSeed;t=pt(s,{base:rt(e.basePubkey.toBuffer()),seed:e.seed,programId:rt(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{const s=At.Assign;t=pt(s,{programId:rt(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new _t({keys:n,programId:this.programId,data:t})}static createAccountWithSeed(e){const t=At.CreateWithSeed,n=pt(t,{base:rt(e.basePubkey.toBuffer()),seed:e.seed,lamports:e.lamports,space:e.space,programId:rt(e.programId.toBuffer())});let s=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!1,isWritable:!0}];return e.basePubkey!=e.fromPubkey&&s.push({pubkey:e.basePubkey,isSigner:!0,isWritable:!1}),new _t({keys:s,programId:this.programId,data:n})}static createNonceAccount(e){const t=new mt;"basePubkey"in e&&"seed"in e?t.add(Qt.createAccountWithSeed({fromPubkey:e.fromPubkey,newAccountPubkey:e.noncePubkey,basePubkey:e.basePubkey,seed:e.seed,lamports:e.lamports,space:Es,programId:this.programId})):t.add(Qt.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.noncePubkey,lamports:e.lamports,space:Es,programId:this.programId}));const n={noncePubkey:e.noncePubkey,authorizedPubkey:e.authorizedPubkey};return t.add(this.nonceInitialize(n)),t}static nonceInitialize(e){const t=At.InitializeNonceAccount,n=pt(t,{authorized:rt(e.authorizedPubkey.toBuffer())}),s={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:Cr,isSigner:!1,isWritable:!1},{pubkey:Zn,isSigner:!1,isWritable:!1}],programId:this.programId,data:n};return new _t(s)}static nonceAdvance(e){const t=At.AdvanceNonceAccount,n=pt(t),s={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:Cr,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n};return new _t(s)}static nonceWithdraw(e){const t=At.WithdrawNonceAccount,n=pt(t,{lamports:e.lamports});return new _t({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0},{pubkey:Cr,isSigner:!1,isWritable:!1},{pubkey:Zn,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:n})}static nonceAuthorize(e){const t=At.AuthorizeNonceAccount,n=pt(t,{authorized:rt(e.newAuthorizedPubkey.toBuffer())});return new _t({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 s=At.AllocateWithSeed;t=pt(s,{base:rt(e.basePubkey.toBuffer()),seed:e.seed,space:e.space,programId:rt(e.programId.toBuffer())}),n=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{const s=At.Allocate;t=pt(s,{space:e.space}),n=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new _t({keys:n,programId:this.programId,data:t})}}Qt.programId=new ve("11111111111111111111111111111111");const sc=Nn-300;class Hn{constructor(){}static getMinNumSignatures(e){return 2*(Math.ceil(e/Hn.chunkSize)+1+1)}static async load(e,t,n,s,o){{const m=await e.getMinimumBalanceForRentExemption(o.length),V=await e.getAccountInfo(n.publicKey,"confirmed");let C=null;if(V!==null){if(V.executable)return console.error("Program load failed, account is already executable"),!1;V.data.length!==o.length&&(C=C||new mt,C.add(Qt.allocate({accountPubkey:n.publicKey,space:o.length}))),V.owner.equals(s)||(C=C||new mt,C.add(Qt.assign({accountPubkey:n.publicKey,programId:s}))),V.lamports<m&&(C=C||new mt,C.add(Qt.transfer({fromPubkey:t.publicKey,toPubkey:n.publicKey,lamports:m-V.lamports})))}else C=new mt().add(Qt.createAccount({fromPubkey:t.publicKey,newAccountPubkey:n.publicKey,lamports:m>0?m:1,space:o.length,programId:s}));C!==null&&await Ss(e,C,[t,n],{commitment:"confirmed"})}const i=b.n_([b.Jq("instruction"),b.Jq("offset"),b.Jq("bytesLength"),b.Jq("bytesLengthPadding"),b.A9(b.u8("byte"),b.cv(b.Jq(),-8),"bytes")]),a=Hn.chunkSize;let u=0,d=o,p=[];for(;d.length>0;){const m=d.slice(0,a),V=T.Buffer.alloc(a+16);i.encode({instruction:0,offset:u,bytes:m,bytesLength:0,bytesLengthPadding:0},V);const C=new mt().add({keys:[{pubkey:n.publicKey,isSigner:!0,isWritable:!0}],programId:s,data:V});p.push(Ss(e,C,[t,n],{commitment:"confirmed"})),e._rpcEndpoint.includes("solana.com")&&await Wn(1e3/4),u+=a,d=d.slice(a)}await Promise.all(p);{const m=b.n_([b.Jq("instruction")]),V=T.Buffer.alloc(m.span);m.encode({instruction:1},V);const C=new mt().add({keys:[{pubkey:n.publicKey,isSigner:!0,isWritable:!0},{pubkey:Zn,isSigner:!1,isWritable:!1}],programId:s,data:V}),K="processed",k=await e.sendTransaction(C,[t,n],{preflightCommitment:K}),{context:O,value:F}=await e.confirmTransaction({signature:k,lastValidBlockHeight:C.lastValidBlockHeight,blockhash:C.recentBlockhash},K);if(F.err)throw new Error(`Transaction ${k} failed (${JSON.stringify(F)})`);for(;;){try{if(await e.getSlot({commitment:K})>O.slot)break}catch{}await new Promise(de=>setTimeout(de,Math.round(Lo/2)))}}return!0}}Hn.chunkSize=sc;const oc=new ve("BPFLoader2111111111111111111111111111111111");class ic{static getMinNumSignatures(e){return Hn.getMinNumSignatures(e)}static load(e,t,n,s,o){return Hn.load(e,t,n,o,s)}}function ac(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var cc=Object.prototype.toString,uc=Object.keys||function(r){var e=[];for(var t in r)e.push(t);return e};function hr(r,e){var t,n,s,o,i,a,u;if(r===!0)return"true";if(r===!1)return"false";switch(typeof r){case"object":if(r===null)return null;if(r.toJSON&&typeof r.toJSON=="function")return hr(r.toJSON(),e);if(u=cc.call(r),u==="[object Array]"){for(s="[",n=r.length-1,t=0;t<n;t++)s+=hr(r[t],!0)+",";return n>-1&&(s+=hr(r[t],!0)),s+"]"}else if(u==="[object Object]"){for(o=uc(r).sort(),n=o.length,s="",t=0;t<n;)i=o[t],a=hr(r[i],!1),a!==void 0&&(s&&(s+=","),s+=JSON.stringify(i)+":"+a),t++;return"{"+s+"}"}else return JSON.stringify(r);case"function":case"undefined":return e?null:void 0;case"string":return JSON.stringify(r);default:return isFinite(r)?r:null}}var lc=function(r){var e=hr(r,!1);if(e!==void 0)return""+e},Uo=ac(lc);const pr=32;function _s(r){let e=0;for(;r>1;)r/=2,e++;return e}function fc(r){return r===0?1:(r--,r|=r>>1,r|=r>>2,r|=r>>4,r|=r>>8,r|=r>>16,r|=r>>32,r+1)}class zo{constructor(e,t,n,s,o){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=s,this.firstNormalSlot=o}getEpoch(e){return this.getEpochAndSlotIndex(e)[0]}getEpochAndSlotIndex(e){if(e<this.firstNormalSlot){const t=_s(fc(e+pr+1))-_s(pr)-1,n=this.getSlotsInEpoch(t),s=e-(n-pr);return[t,s]}else{const t=e-this.firstNormalSlot,n=Math.floor(t/this.slotsPerEpoch),s=this.firstNormalEpoch+n,o=t%this.slotsPerEpoch;return[s,o]}}getFirstSlotInEpoch(e){return e<=this.firstNormalEpoch?(Math.pow(2,e)-1)*pr:(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+_s(pr)):this.slotsPerEpoch}}class xs extends Error{constructor(e,t){super(e),this.logs=void 0,this.logs=t}}const dc={JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP:-32001,JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE:-32002,JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE:-32003,JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE:-32004,JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY:-32005,JSON_RPC_SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE:-32006,JSON_RPC_SERVER_ERROR_SLOT_SKIPPED:-32007,JSON_RPC_SERVER_ERROR_NO_SNAPSHOT:-32008,JSON_RPC_SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED:-32009,JSON_RPC_SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX:-32010,JSON_RPC_SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE:-32011,JSON_RPC_SCAN_ERROR:-32012,JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH:-32013,JSON_RPC_SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET:-32014,JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION:-32015,JSON_RPC_SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED:-32016};class qe extends Error{constructor({code:e,message:t,data:n},s){super(s!=null?`${s}: ${t}`:t),this.code=void 0,this.data=void 0,this.code=e,this.data=n,this.name="SolanaJSONRPCError"}}var hc=globalThis.fetch;class pc extends ga.Z{constructor(e,t,n){const s=o=>{const i=(0,ya.Z)(o,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...t});return"socket"in i?this.underlyingSocket=i.socket:this.underlyingSocket=i,i};super(s,e,t,n),this.underlyingSocket=void 0}call(...e){var n;const t=(n=this.underlyingSocket)==null?void 0:n.readyState;return t===1?super.call(...e):Promise.reject(new Error("Tried to call a JSON-RPC method `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+")"))}notify(...e){var n;const t=(n=this.underlyingSocket)==null?void 0:n.readyState;return t===1?super.notify(...e):Promise.reject(new Error("Tried to send a JSON-RPC notification `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+")"))}}function gc(r,e){let t;try{t=r.layout.decode(e)}catch(n){throw new Error("invalid instruction; "+n)}if(t.typeIndex!==r.index)throw new Error(`invalid account data; account type mismatch ${t.typeIndex} != ${r.index}`);return t}const Ko=56;class vs{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=gc(yc,e),n=e.length-Ko;gt(n>=0,"lookup table is invalid"),gt(n%32===0,"lookup table is invalid");const s=n/32,{addresses:o}=b.n_([b.A9(ct(),s,"addresses")]).decode(e.slice(Ko));return{deactivationSlot:t.deactivationSlot,lastExtendedSlot:t.lastExtendedSlot,lastExtendedSlotStartIndex:t.lastExtendedStartIndex,authority:t.authority.length!==0?new ve(t.authority[0]):void 0,addresses:o.map(i=>new ve(i))}}}const yc={index:1,layout:b.n_([b.Jq("typeIndex"),Xn("deactivationSlot"),b._O("lastExtendedSlot"),b.u8("lastExtendedStartIndex"),b.u8(),b.A9(ct(),b.cv(b.u8(),-1),"authority")])},bc=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;function mc(r){const e=r.match(bc);if(e==null)throw TypeError(`Failed to validate endpoint URL \`${r}\``);const[t,n,s,o]=e,i=r.startsWith("https:")?"wss:":"ws:",a=s==null?null:parseInt(s.slice(1),10),u=a==null?"":`:${a+1}`;return`${i}//${n}${u}${o}`}const qt=zn(is(ve),_e(),r=>new ve(r)),Do=as([_e(),Ot("base64")]),As=zn(is(T.Buffer),Do,r=>T.Buffer.from(r[0],"base64")),Mo=30*1e3;function wc(r){if(/^https?:/.test(r)===!1)throw new TypeError("Endpoint URL must start with `http:` or `https:`.");return r}function Rt(r){let e,t;if(typeof r=="string")e=r;else if(r){const{commitment:n,...s}=r;e=n,t=s}return{commitment:e,config:t}}function Wo(r){return sn([he({jsonrpc:Ot("2.0"),id:_e(),result:r}),he({jsonrpc:Ot("2.0"),id:_e(),error:he({code:$n(),message:_e(),data:Ze(da())})})])}const kc=Wo($n());function st(r){return zn(Wo(r),kc,e=>"error"in e?e:{...e,result:Be(e.result,r)})}function Nt(r){return st(he({context:he({slot:N()}),value:r}))}function zr(r){return he({context:he({slot:N()}),value:r})}function Is(r,e){return r===0?new Mn({header:e.header,staticAccountKeys:e.accountKeys.map(t=>new ve(t)),recentBlockhash:e.recentBlockhash,compiledInstructions:e.instructions.map(t=>({programIdIndex:t.programIdIndex,accountKeyIndexes:t.accounts,data:Xt().decode(t.data)})),addressTableLookups:e.addressTableLookups}):new yn(e)}const Sc=he({foundation:N(),foundationTerm:N(),initial:N(),taper:N(),terminal:N()}),Ec=st(Ce(Le(he({epoch:N(),effectiveSlot:N(),amount:N(),postBalance:N(),commission:Ze(Le(N()))})))),_c=Ce(he({slot:N(),prioritizationFee:N()})),xc=he({total:N(),validator:N(),foundation:N(),epoch:N()}),vc=he({epoch:N(),slotIndex:N(),slotsInEpoch:N(),absoluteSlot:N(),blockHeight:Ze(N()),transactionCount:Ze(N())}),Ac=he({slotsPerEpoch:N(),leaderScheduleSlotOffset:N(),warmup:En(),firstNormalEpoch:N(),firstNormalSlot:N()}),Ic=co(_e(),Ce(N())),qn=Le(sn([he({}),_e()])),Bc=he({err:qn}),Rc=Ot("receivedSignature"),Pc=he({"solana-core":_e(),"feature-set":Ze(N())}),Ho=Nt(he({err:Le(sn([he({}),_e()])),logs:Le(Ce(_e())),accounts:Ze(Le(Ce(Le(he({executable:En(),owner:_e(),lamports:N(),data:Ce(_e()),rentEpoch:Ze(N())}))))),unitsConsumed:Ze(N()),returnData:Ze(Le(he({programId:_e(),data:as([_e(),Ot("base64")])})))})),Tc=Nt(he({byIdentity:co(_e(),Ce(N())),range:he({firstSlot:N(),lastSlot:N()})}));function Oc(r,e,t,n,s,o){const i=t||hc;let a;o!=null&&console.warn("You have supplied an `httpAgent` when creating a `Connection` in a browser environment.It has been ignored; `httpAgent` is only used in Node environments.");let u;return n&&(u=async(p,m)=>{const V=await new Promise((C,K)=>{try{n(p,m,(k,O)=>C([k,O]))}catch(k){K(k)}});return await i(...V)}),new(pa())(async(p,m)=>{const V={method:"POST",body:p,agent:a,headers:Object.assign({"Content-Type":"application/json"},e||{},Lu)};try{let C=5,K,k=500;for(;u?K=await u(r,V):K=await i(r,V),!(K.status!==429||s===!0||(C-=1,C===0));)console.log(`Server responded with ${K.status} ${K.statusText}. Retrying after ${k}ms delay...`),await Wn(k),k*=2;const O=await K.text();K.ok?m(null,O):m(new Error(`${K.status} ${K.statusText}: ${O}`))}catch(C){C instanceof Error&&m(C)}},{})}function Lc(r){return(e,t)=>new Promise((n,s)=>{r.request(e,t,(o,i)=>{if(o){s(o);return}n(i)})})}function Cc(r){return e=>new Promise((t,n)=>{e.length===0&&t([]);const s=e.map(o=>r.request(o.methodName,o.args));r.request(s,(o,i)=>{if(o){n(o);return}t(i)})})}const Nc=st(Sc),Uc=st(xc),zc=st(_c),Kc=st(vc),Dc=st(Ac),Mc=st(Ic),Wc=st(N()),Hc=Nt(he({total:N(),circulating:N(),nonCirculating:N(),nonCirculatingAccounts:Ce(qt)})),Bs=he({amount:_e(),uiAmount:Le(N()),decimals:N(),uiAmountString:Ze(_e())}),qc=Nt(Ce(he({address:qt,amount:_e(),uiAmount:Le(N()),decimals:N(),uiAmountString:Ze(_e())}))),Fc=Nt(Ce(he({pubkey:qt,account:he({executable:En(),owner:qt,lamports:N(),data:As,rentEpoch:N()})}))),Rs=he({program:_e(),parsed:$n(),space:N()}),Vc=Nt(Ce(he({pubkey:qt,account:he({executable:En(),owner:qt,lamports:N(),data:Rs,rentEpoch:N()})}))),Gc=Nt(Ce(he({lamports:N(),address:qt}))),gr=he({executable:En(),owner:qt,lamports:N(),data:As,rentEpoch:N()}),jc=he({pubkey:qt,account:gr}),$c=zn(sn([is(T.Buffer),Rs]),sn([Do,Rs]),r=>Array.isArray(r)?Be(r,As):r),Ps=he({executable:En(),owner:qt,lamports:N(),data:$c,rentEpoch:N()}),Yc=he({pubkey:qt,account:Ps}),Jc=he({state:sn([Ot("active"),Ot("inactive"),Ot("activating"),Ot("deactivating")]),active:N(),inactive:N()}),Zc=st(Ce(he({signature:_e(),slot:N(),err:qn,memo:Le(_e()),blockTime:Ze(Le(N()))}))),Xc=st(Ce(he({signature:_e(),slot:N(),err:qn,memo:Le(_e()),blockTime:Ze(Le(N()))}))),Qc=he({subscription:N(),result:zr(gr)}),eu=he({pubkey:qt,account:gr}),tu=he({subscription:N(),result:zr(eu)}),nu=he({parent:N(),slot:N(),root:N()}),ru=he({subscription:N(),result:nu}),su=sn([he({type:sn([Ot("firstShredReceived"),Ot("completed"),Ot("optimisticConfirmation"),Ot("root")]),slot:N(),timestamp:N()}),he({type:Ot("createdBank"),parent:N(),slot:N(),timestamp:N()}),he({type:Ot("frozen"),slot:N(),timestamp:N(),stats:he({numTransactionEntries:N(),numSuccessfulTransactions:N(),numFailedTransactions:N(),maxTransactionsPerEntry:N()})}),he({type:Ot("dead"),slot:N(),timestamp:N(),err:_e()})]),ou=he({subscription:N(),result:su}),iu=he({subscription:N(),result:zr(sn([Bc,Rc]))}),au=he({subscription:N(),result:N()}),cu=he({pubkey:_e(),gossip:Le(_e()),tpu:Le(_e()),rpc:Le(_e()),version:Le(_e())}),qo=he({votePubkey:_e(),nodePubkey:_e(),activatedStake:N(),epochVoteAccount:En(),epochCredits:Ce(as([N(),N(),N()])),commission:N(),lastVote:N(),rootSlot:Le(N())}),uu=st(he({current:Ce(qo),delinquent:Ce(qo)})),lu=sn([Ot("processed"),Ot("confirmed"),Ot("finalized")]),fu=he({slot:N(),confirmations:Le(N()),err:qn,confirmationStatus:Ze(lu)}),du=Nt(Ce(Le(fu))),hu=st(N()),Fo=he({accountKey:qt,writableIndexes:Ce(N()),readonlyIndexes:Ce(N())}),Ts=he({signatures:Ce(_e()),message:he({accountKeys:Ce(_e()),header:he({numRequiredSignatures:N(),numReadonlySignedAccounts:N(),numReadonlyUnsignedAccounts:N()}),instructions:Ce(he({accounts:Ce(N()),data:_e(),programIdIndex:N()})),recentBlockhash:_e(),addressTableLookups:Ze(Ce(Fo))})}),Vo=he({pubkey:qt,signer:En(),writable:En(),source:Ze(sn([Ot("transaction"),Ot("lookupTable")]))}),Go=he({accountKeys:Ce(Vo),signatures:Ce(_e())}),jo=he({parsed:$n(),program:_e(),programId:qt}),$o=he({accounts:Ce(qt),data:_e(),programId:qt}),pu=sn([$o,jo]),gu=sn([he({parsed:$n(),program:_e(),programId:_e()}),he({accounts:Ce(_e()),data:_e(),programId:_e()})]),Yo=zn(pu,gu,r=>"accounts"in r?Be(r,$o):Be(r,jo)),Jo=he({signatures:Ce(_e()),message:he({accountKeys:Ce(Vo),instructions:Ce(Yo),recentBlockhash:_e(),addressTableLookups:Ze(Le(Ce(Fo)))})}),Kr=he({accountIndex:N(),mint:_e(),owner:Ze(_e()),uiTokenAmount:Bs}),Zo=he({writable:Ce(qt),readonly:Ce(qt)}),Dr=he({err:qn,fee:N(),innerInstructions:Ze(Le(Ce(he({index:N(),instructions:Ce(he({accounts:Ce(N()),data:_e(),programIdIndex:N()}))})))),preBalances:Ce(N()),postBalances:Ce(N()),logMessages:Ze(Le(Ce(_e()))),preTokenBalances:Ze(Le(Ce(Kr))),postTokenBalances:Ze(Le(Ce(Kr))),loadedAddresses:Ze(Zo),computeUnitsConsumed:Ze(N())}),Os=he({err:qn,fee:N(),innerInstructions:Ze(Le(Ce(he({index:N(),instructions:Ce(Yo)})))),preBalances:Ce(N()),postBalances:Ce(N()),logMessages:Ze(Le(Ce(_e()))),preTokenBalances:Ze(Le(Ce(Kr))),postTokenBalances:Ze(Le(Ce(Kr))),loadedAddresses:Ze(Zo),computeUnitsConsumed:Ze(N())}),Qn=sn([Ot(0),Ot("legacy")]),Fn=he({pubkey:_e(),lamports:N(),postBalance:Le(N()),rewardType:Le(_e()),commission:Ze(Le(N()))}),yu=st(Le(he({blockhash:_e(),previousBlockhash:_e(),parentSlot:N(),transactions:Ce(he({transaction:Ts,meta:Le(Dr),version:Ze(Qn)})),rewards:Ze(Ce(Fn)),blockTime:Le(N()),blockHeight:Le(N())}))),bu=st(Le(he({blockhash:_e(),previousBlockhash:_e(),parentSlot:N(),rewards:Ze(Ce(Fn)),blockTime:Le(N()),blockHeight:Le(N())}))),mu=st(Le(he({blockhash:_e(),previousBlockhash:_e(),parentSlot:N(),transactions:Ce(he({transaction:Go,meta:Le(Dr),version:Ze(Qn)})),rewards:Ze(Ce(Fn)),blockTime:Le(N()),blockHeight:Le(N())}))),wu=st(Le(he({blockhash:_e(),previousBlockhash:_e(),parentSlot:N(),transactions:Ce(he({transaction:Jo,meta:Le(Os),version:Ze(Qn)})),rewards:Ze(Ce(Fn)),blockTime:Le(N()),blockHeight:Le(N())}))),ku=st(Le(he({blockhash:_e(),previousBlockhash:_e(),parentSlot:N(),transactions:Ce(he({transaction:Go,meta:Le(Os),version:Ze(Qn)})),rewards:Ze(Ce(Fn)),blockTime:Le(N()),blockHeight:Le(N())}))),Su=st(Le(he({blockhash:_e(),previousBlockhash:_e(),parentSlot:N(),rewards:Ze(Ce(Fn)),blockTime:Le(N()),blockHeight:Le(N())}))),Eu=st(Le(he({blockhash:_e(),previousBlockhash:_e(),parentSlot:N(),transactions:Ce(he({transaction:Ts,meta:Le(Dr)})),rewards:Ze(Ce(Fn)),blockTime:Le(N())}))),Xo=st(Le(he({blockhash:_e(),previousBlockhash:_e(),parentSlot:N(),signatures:Ce(_e()),blockTime:Le(N())}))),Ls=st(Le(he({slot:N(),meta:Le(Dr),blockTime:Ze(Le(N())),transaction:Ts,version:Ze(Qn)}))),Mr=st(Le(he({slot:N(),transaction:Jo,meta:Le(Os),blockTime:Ze(Le(N())),version:Ze(Qn)}))),_u=Nt(he({blockhash:_e(),feeCalculator:he({lamportsPerSignature:N()})})),xu=Nt(he({blockhash:_e(),lastValidBlockHeight:N()})),vu=Nt(En()),Au=he({slot:N(),numTransactions:N(),numSlots:N(),samplePeriodSecs:N()}),Iu=st(Ce(Au)),Bu=Nt(Le(he({feeCalculator:he({lamportsPerSignature:N()})}))),Ru=st(_e()),Pu=st(_e()),Tu=he({err:qn,logs:Ce(_e()),signature:_e()}),Ou=he({result:zr(Tu),subscription:N()}),Lu={"solana-client":"js/0.0.0-development"};class Cu{constructor(e,t){this._commitment=void 0,this._confirmTransactionInitialTimeout=void 0,this._rpcEndpoint=void 0,this._rpcWsEndpoint=void 0,this._rpcClient=void 0,this._rpcRequest=void 0,this._rpcBatchRequest=void 0,this._rpcWebSocket=void 0,this._rpcWebSocketConnected=!1,this._rpcWebSocketHeartbeat=null,this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketGeneration=0,this._disableBlockhashCaching=!1,this._pollingBlockhash=!1,this._blockhashInfo={latestBlockhash:null,lastFetch:0,transactionSignatures:[],simulatedSignatures:[]},this._nextClientSubscriptionId=0,this._subscriptionDisposeFunctionsByClientSubscriptionId={},this._subscriptionHashByClientSubscriptionId={},this._subscriptionStateChangeCallbacksByHash={},this._subscriptionCallbacksByServerSubscriptionId={},this._subscriptionsByHash={},this._subscriptionsAutoDisposedByRpc=new Set,this.getBlockHeight=(()=>{const d={};return async p=>{var k;const{commitment:m,config:V}=Rt(p),C=this._buildArgs([],m,void 0,V),K=Uo(C);return d[K]=(k=d[K])!=null?k:(async()=>{try{const O=await this._rpcRequest("getBlockHeight",C),F=Be(O,st(N()));if("error"in F)throw new qe(F.error,"failed to get block height information");return F.result}finally{delete d[K]}})(),await d[K]}})();let n,s,o,i,a,u;t&&typeof t=="string"?this._commitment=t:t&&(this._commitment=t.commitment,this._confirmTransactionInitialTimeout=t.confirmTransactionInitialTimeout,n=t.wsEndpoint,s=t.httpHeaders,o=t.fetch,i=t.fetchMiddleware,a=t.disableRetryOnRateLimit,u=t.httpAgent),this._rpcEndpoint=wc(e),this._rpcWsEndpoint=n||mc(e),this._rpcClient=Oc(e,s,o,i,a,u),this._rpcRequest=Lc(this._rpcClient),this._rpcBatchRequest=Cc(this._rpcClient),this._rpcWebSocket=new pc(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:s}=Rt(t),o=this._buildArgs([e.toBase58()],n,void 0,s),i=await this._rpcRequest("getBalance",o),a=Be(i,Nt(N()));if("error"in a)throw new qe(a.error,`failed to get balance for ${e.toBase58()}`);return a.result}async getBalance(e,t){return await this.getBalanceAndContext(e,t).then(n=>n.value).catch(n=>{throw new Error("failed to get balance of account "+e.toBase58()+": "+n)})}async getBlockTime(e){const t=await this._rpcRequest("getBlockTime",[e]),n=Be(t,st(Le(N())));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=Be(e,st(N()));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=Be(e,Wc);if("error"in t)throw new qe(t.error,"failed to get first available block");return t.result}async getSupply(e){let t={};typeof e=="string"?t={commitment:e}:e?t={...e,commitment:e&&e.commitment||this.commitment}:t={commitment:this.commitment};const n=await this._rpcRequest("getSupply",[t]),s=Be(n,Hc);if("error"in s)throw new qe(s.error,"failed to get supply");return s.result}async getTokenSupply(e,t){const n=this._buildArgs([e.toBase58()],t),s=await this._rpcRequest("getTokenSupply",n),o=Be(s,Nt(Bs));if("error"in o)throw new qe(o.error,"failed to get token supply");return o.result}async getTokenAccountBalance(e,t){const n=this._buildArgs([e.toBase58()],t),s=await this._rpcRequest("getTokenAccountBalance",n),o=Be(s,Nt(Bs));if("error"in o)throw new qe(o.error,"failed to get token account balance");return o.result}async getTokenAccountsByOwner(e,t,n){const{commitment:s,config:o}=Rt(n);let i=[e.toBase58()];"mint"in t?i.push({mint:t.mint.toBase58()}):i.push({programId:t.programId.toBase58()});const a=this._buildArgs(i,s,"base64",o),u=await this._rpcRequest("getTokenAccountsByOwner",a),d=Be(u,Fc);if("error"in d)throw new qe(d.error,`failed to get token accounts owned by account ${e.toBase58()}`);return d.result}async getParsedTokenAccountsByOwner(e,t,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,n,"jsonParsed"),i=await this._rpcRequest("getTokenAccountsByOwner",o),a=Be(i,Vc);if("error"in a)throw new qe(a.error,`failed to get token accounts owned by account ${e.toBase58()}`);return a.result}async getLargestAccounts(e){const t={...e,commitment:e&&e.commitment||this.commitment},n=t.filter||t.commitment?[t]:[],s=await this._rpcRequest("getLargestAccounts",n),o=Be(s,Gc);if("error"in o)throw new qe(o.error,"failed to get largest accounts");return o.result}async getTokenLargestAccounts(e,t){const n=this._buildArgs([e.toBase58()],t),s=await this._rpcRequest("getTokenLargestAccounts",n),o=Be(s,qc);if("error"in o)throw new qe(o.error,"failed to get token largest accounts");return o.result}async getAccountInfoAndContext(e,t){const{commitment:n,config:s}=Rt(t),o=this._buildArgs([e.toBase58()],n,"base64",s),i=await this._rpcRequest("getAccountInfo",o),a=Be(i,Nt(Le(gr)));if("error"in a)throw new qe(a.error,`failed to get info about account ${e.toBase58()}`);return a.result}async getParsedAccountInfo(e,t){const{commitment:n,config:s}=Rt(t),o=this._buildArgs([e.toBase58()],n,"jsonParsed",s),i=await this._rpcRequest("getAccountInfo",o),a=Be(i,Nt(Le(Ps)));if("error"in a)throw new qe(a.error,`failed to get info about account ${e.toBase58()}`);return a.result}async getAccountInfo(e,t){try{return(await this.getAccountInfoAndContext(e,t)).value}catch(n){throw new Error("failed to get info about account "+e.toBase58()+": "+n)}}async getMultipleParsedAccounts(e,t){const{commitment:n,config:s}=Rt(t),o=e.map(d=>d.toBase58()),i=this._buildArgs([o],n,"jsonParsed",s),a=await this._rpcRequest("getMultipleAccounts",i),u=Be(a,Nt(Ce(Le(Ps))));if("error"in u)throw new qe(u.error,`failed to get info for accounts ${o}`);return u.result}async getMultipleAccountsInfoAndContext(e,t){const{commitment:n,config:s}=Rt(t),o=e.map(d=>d.toBase58()),i=this._buildArgs([o],n,"base64",s),a=await this._rpcRequest("getMultipleAccounts",i),u=Be(a,Nt(Ce(Le(gr))));if("error"in u)throw new qe(u.error,`failed to get info for accounts ${o}`);return u.result}async getMultipleAccountsInfo(e,t){return(await this.getMultipleAccountsInfoAndContext(e,t)).value}async getStakeActivation(e,t,n){const{commitment:s,config:o}=Rt(t),i=this._buildArgs([e.toBase58()],s,void 0,{...o,epoch:n!=null?n:o==null?void 0:o.epoch}),a=await this._rpcRequest("getStakeActivation",i),u=Be(a,st(Jc));if("error"in u)throw new qe(u.error,`failed to get Stake Activation ${e.toBase58()}`);return u.result}async getProgramAccounts(e,t){const{commitment:n,config:s}=Rt(t),{encoding:o,...i}=s||{},a=this._buildArgs([e.toBase58()],n,o||"base64",i),u=await this._rpcRequest("getProgramAccounts",a),d=Ce(jc),p=i.withContext===!0?Be(u,Nt(d)):Be(u,st(d));if("error"in p)throw new qe(p.error,`failed to get accounts owned by program ${e.toBase58()}`);return p.result}async getParsedProgramAccounts(e,t){const{commitment:n,config:s}=Rt(t),o=this._buildArgs([e.toBase58()],n,"jsonParsed",s),i=await this._rpcRequest("getProgramAccounts",o),a=Be(i,st(Ce(Yc)));if("error"in a)throw new qe(a.error,`failed to get accounts owned by program ${e.toBase58()}`);return a.result}async confirmTransaction(e,t){var o;let n;if(typeof e=="string")n=e;else{const i=e;if((o=i.abortSignal)!=null&&o.aborted)return Promise.reject(i.abortSignal.reason);n=i.signature}let s;try{s=Xt().decode(n)}catch{throw new Error("signature must be base58 encoded: "+n)}return gt(s.length===64,"signature has invalid length"),typeof e=="string"?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)=>{e!=null&&(e.aborted?n(e.reason):e.addEventListener("abort",()=>{n(e.reason)}))})}getTransactionConfirmationPromise({commitment:e,signature:t}){let n,s,o=!1;const i=new Promise((u,d)=>{try{n=this.onSignature(t,(m,V)=>{n=void 0;const C={context:V,value:m};u({__type:An.PROCESSED,response:C})},e);const p=new Promise(m=>{n==null?m():s=this._onSubscriptionStateChange(n,V=>{V==="subscribed"&&m()})});(async()=>{if(await p,o)return;const m=await this.getSignatureStatus(t);if(o||m==null)return;const{context:V,value:C}=m;if(C!=null)if(C!=null&&C.err)d(C.err);else{switch(e){case"confirmed":case"single":case"singleGossip":{if(C.confirmationStatus==="processed")return;break}case"finalized":case"max":case"root":{if(C.confirmationStatus==="processed"||C.confirmationStatus==="confirmed")return;break}case"processed":case"recent":}o=!0,u({__type:An.PROCESSED,response:{context:V,value:C}})}})()}catch(p){d(p)}});return{abortConfirmation:()=>{s&&(s(),s=void 0),n!=null&&(this.removeSignatureListener(n),n=void 0)},confirmationPromise:i}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:e,strategy:{abortSignal:t,lastValidBlockHeight:n,signature:s}}){let o=!1;const i=new Promise(m=>{const V=async()=>{try{return await this.getBlockHeight(e)}catch{return-1}};(async()=>{let C=await V();if(!o){for(;C<=n;)if(await Wn(1e3),o||(C=await V(),o))return;m({__type:An.BLOCKHEIGHT_EXCEEDED})}})()}),{abortConfirmation:a,confirmationPromise:u}=this.getTransactionConfirmationPromise({commitment:e,signature:s}),d=this.getCancellationPromise(t);let p;try{const m=await Promise.race([d,u,i]);if(m.__type===An.PROCESSED)p=m.response;else throw new ys(s)}finally{o=!0,a()}return p}async confirmTransactionUsingDurableNonceStrategy({commitment:e,strategy:{abortSignal:t,minContextSlot:n,nonceAccountPubkey:s,nonceValue:o,signature:i}}){var C;let a=!1;const u=new Promise(K=>{let k=o,O=null;const F=async()=>{try{const{context:de,value:pe}=await this.getNonceAndContext(s,{commitment:e,minContextSlot:n});return O=de.slot,pe==null?void 0:pe.nonce}catch{return k}};(async()=>{if(k=await F(),!a)for(;;){if(o!==k){K({__type:An.NONCE_INVALID,slotInWhichNonceDidAdvance:O});return}if(await Wn(2e3),a||(k=await F(),a))return}})()}),{abortConfirmation:d,confirmationPromise:p}=this.getTransactionConfirmationPromise({commitment:e,signature:i}),m=this.getCancellationPromise(t);let V;try{const K=await Promise.race([m,p,u]);if(K.__type===An.PROCESSED)V=K.response;else{let k;for(;;){const O=await this.getSignatureStatus(i);if(O==null)break;if(O.context.slot<((C=K.slotInWhichNonceDidAdvance)!=null?C:n)){await Wn(400);continue}k=O;break}if(k!=null&&k.value){const O=e||"finalized",{confirmationStatus:F}=k.value;switch(O){case"processed":case"recent":if(F!=="processed"&&F!=="confirmed"&&F!=="finalized")throw new Jn(i);break;case"confirmed":case"single":case"singleGossip":if(F!=="confirmed"&&F!=="finalized")throw new Jn(i);break;case"finalized":case"max":case"root":if(F!=="finalized")throw new Jn(i);break;default:(de=>{})(O)}V={context:k.context,value:{err:k.value.err}}}else throw new Jn(i)}}finally{a=!0,d()}return V}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:e,signature:t}){let n;const s=new Promise(u=>{let d=this._confirmTransactionInitialTimeout||6e4;switch(e){case"processed":case"recent":case"single":case"confirmed":case"singleGossip":{d=this._confirmTransactionInitialTimeout||3e4;break}}n=setTimeout(()=>u({__type:An.TIMED_OUT,timeoutMs:d}),d)}),{abortConfirmation:o,confirmationPromise:i}=this.getTransactionConfirmationPromise({commitment:e,signature:t});let a;try{const u=await Promise.race([i,s]);if(u.__type===An.PROCESSED)a=u.response;else throw new bs(t,u.timeoutMs/1e3)}finally{clearTimeout(n),o()}return a}async getClusterNodes(){const e=await this._rpcRequest("getClusterNodes",[]),t=Be(e,st(Ce(cu)));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),s=Be(n,uu);if("error"in s)throw new qe(s.error,"failed to get vote accounts");return s.result}async getSlot(e){const{commitment:t,config:n}=Rt(e),s=this._buildArgs([],t,void 0,n),o=await this._rpcRequest("getSlot",s),i=Be(o,st(N()));if("error"in i)throw new qe(i.error,"failed to get slot");return i.result}async getSlotLeader(e){const{commitment:t,config:n}=Rt(e),s=this._buildArgs([],t,void 0,n),o=await this._rpcRequest("getSlotLeader",s),i=Be(o,st(_e()));if("error"in i)throw new qe(i.error,"failed to get slot leader");return i.result}async getSlotLeaders(e,t){const n=[e,t],s=await this._rpcRequest("getSlotLeaders",n),o=Be(s,st(Ce(qt)));if("error"in o)throw new qe(o.error,"failed to get slot leaders");return o.result}async getSignatureStatus(e,t){const{context:n,value:s}=await this.getSignatureStatuses([e],t);gt(s.length===1);const o=s[0];return{context:n,value:o}}async getSignatureStatuses(e,t){const n=[e];t&&n.push(t);const s=await this._rpcRequest("getSignatureStatuses",n),o=Be(s,du);if("error"in o)throw new qe(o.error,"failed to get signature status");return o.result}async getTransactionCount(e){const{commitment:t,config:n}=Rt(e),s=this._buildArgs([],t,void 0,n),o=await this._rpcRequest("getTransactionCount",s),i=Be(o,st(N()));if("error"in i)throw new qe(i.error,"failed to get transaction count");return i.result}async getTotalSupply(e){return(await this.getSupply({commitment:e,excludeNonCirculatingAccountsList:!0})).value.total}async getInflationGovernor(e){const t=this._buildArgs([],e),n=await this._rpcRequest("getInflationGovernor",t),s=Be(n,Nc);if("error"in s)throw new qe(s.error,"failed to get inflation");return s.result}async getInflationReward(e,t,n){const{commitment:s,config:o}=Rt(n),i=this._buildArgs([e.map(d=>d.toBase58())],s,void 0,{...o,epoch:t!=null?t:o==null?void 0:o.epoch}),a=await this._rpcRequest("getInflationReward",i),u=Be(a,Ec);if("error"in u)throw new qe(u.error,"failed to get inflation reward");return u.result}async getInflationRate(){const e=await this._rpcRequest("getInflationRate",[]),t=Be(e,Uc);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}=Rt(e),s=this._buildArgs([],t,void 0,n),o=await this._rpcRequest("getEpochInfo",s),i=Be(o,Kc);if("error"in i)throw new qe(i.error,"failed to get epoch info");return i.result}async getEpochSchedule(){const e=await this._rpcRequest("getEpochSchedule",[]),t=Be(e,Dc);if("error"in t)throw new qe(t.error,"failed to get epoch schedule");const n=t.result;return new zo(n.slotsPerEpoch,n.leaderScheduleSlotOffset,n.warmup,n.firstNormalEpoch,n.firstNormalSlot)}async getLeaderSchedule(){const e=await this._rpcRequest("getLeaderSchedule",[]),t=Be(e,Mc);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),s=await this._rpcRequest("getMinimumBalanceForRentExemption",n),o=Be(s,hu);return"error"in o?(console.warn("Unable to fetch minimum balance for rent exemption"),0):o.result}async getRecentBlockhashAndContext(e){const t=this._buildArgs([],e),n=await this._rpcRequest("getRecentBlockhash",t),s=Be(n,_u);if("error"in s)throw new qe(s.error,"failed to get recent blockhash");return s.result}async getRecentPerformanceSamples(e){const t=await this._rpcRequest("getRecentPerformanceSamples",e?[e]:[]),n=Be(t,Iu);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),s=await this._rpcRequest("getFeeCalculatorForBlockhash",n),o=Be(s,Bu);if("error"in o)throw new qe(o.error,"failed to get fee calculator");const{context:i,value:a}=o.result;return{context:i,value:a!==null?a.feeCalculator:null}}async getFeeForMessage(e,t){const n=rt(e.serialize()).toString("base64"),s=this._buildArgs([n],t),o=await this._rpcRequest("getFeeForMessage",s),i=Be(o,Nt(Le(N())));if("error"in i)throw new qe(i.error,"failed to get fee for message");if(i.result===null)throw new Error("invalid blockhash");return i.result}async getRecentPrioritizationFees(e){var i;const t=(i=e==null?void 0:e.lockedWritableAccounts)==null?void 0:i.map(a=>a.toBase58()),n=t!=null&&t.length?[t]:[],s=await this._rpcRequest("getRecentPrioritizationFees",n),o=Be(s,zc);if("error"in o)throw new qe(o.error,"failed to get recent prioritization fees");return o.result}async getRecentBlockhash(e){try{return(await this.getRecentBlockhashAndContext(e)).value}catch(t){throw new Error("failed to get recent blockhash: "+t)}}async getLatestBlockhash(e){try{return(await this.getLatestBlockhashAndContext(e)).value}catch(t){throw new Error("failed to get recent blockhash: "+t)}}async getLatestBlockhashAndContext(e){const{commitment:t,config:n}=Rt(e),s=this._buildArgs([],t,void 0,n),o=await this._rpcRequest("getLatestBlockhash",s),i=Be(o,xu);if("error"in i)throw new qe(i.error,"failed to get latest blockhash");return i.result}async isBlockhashValid(e,t){const{commitment:n,config:s}=Rt(t),o=this._buildArgs([e],n,void 0,s),i=await this._rpcRequest("isBlockhashValid",o),a=Be(i,vu);if("error"in a)throw new qe(a.error,"failed to determine if the blockhash `"+e+"`is valid");return a.result}async getVersion(){const e=await this._rpcRequest("getVersion",[]),t=Be(e,st(Pc));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=Be(e,st(_e()));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:s}=Rt(t),o=this._buildArgsAtLeastConfirmed([e],n,void 0,s),i=await this._rpcRequest("getBlock",o);try{switch(s==null?void 0:s.transactionDetails){case"accounts":{const a=Be(i,mu);if("error"in a)throw a.error;return a.result}case"none":{const a=Be(i,bu);if("error"in a)throw a.error;return a.result}default:{const a=Be(i,yu);if("error"in a)throw a.error;const{result:u}=a;return u?{...u,transactions:u.transactions.map(({transaction:d,meta:p,version:m})=>({meta:p,transaction:{...d,message:Is(m,d.message)},version:m}))}:null}}}catch(a){throw new qe(a,"failed to get confirmed block")}}async getParsedBlock(e,t){const{commitment:n,config:s}=Rt(t),o=this._buildArgsAtLeastConfirmed([e],n,"jsonParsed",s),i=await this._rpcRequest("getBlock",o);try{switch(s==null?void 0:s.transactionDetails){case"accounts":{const a=Be(i,ku);if("error"in a)throw a.error;return a.result}case"none":{const a=Be(i,Su);if("error"in a)throw a.error;return a.result}default:{const a=Be(i,wu);if("error"in a)throw a.error;return a.result}}}catch(a){throw new qe(a,"failed to get block")}}async getBlockProduction(e){let t,n;if(typeof e=="string")n=e;else if(e){const{commitment:a,...u}=e;n=a,t=u}const s=this._buildArgs([],n,"base64",t),o=await this._rpcRequest("getBlockProduction",s),i=Be(o,Tc);if("error"in i)throw new qe(i.error,"failed to get block production information");return i.result}async getTransaction(e,t){const{commitment:n,config:s}=Rt(t),o=this._buildArgsAtLeastConfirmed([e],n,void 0,s),i=await this._rpcRequest("getTransaction",o),a=Be(i,Ls);if("error"in a)throw new qe(a.error,"failed to get transaction");const u=a.result;return u&&{...u,transaction:{...u.transaction,message:Is(u.version,u.transaction.message)}}}async getParsedTransaction(e,t){const{commitment:n,config:s}=Rt(t),o=this._buildArgsAtLeastConfirmed([e],n,"jsonParsed",s),i=await this._rpcRequest("getTransaction",o),a=Be(i,Mr);if("error"in a)throw new qe(a.error,"failed to get transaction");return a.result}async getParsedTransactions(e,t){const{commitment:n,config:s}=Rt(t),o=e.map(u=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([u],n,"jsonParsed",s)}));return(await this._rpcBatchRequest(o)).map(u=>{const d=Be(u,Mr);if("error"in d)throw new qe(d.error,"failed to get transactions");return d.result})}async getTransactions(e,t){const{commitment:n,config:s}=Rt(t),o=e.map(u=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([u],n,void 0,s)}));return(await this._rpcBatchRequest(o)).map(u=>{const d=Be(u,Ls);if("error"in d)throw new qe(d.error,"failed to get transactions");const p=d.result;return p&&{...p,transaction:{...p.transaction,message:Is(p.version,p.transaction.message)}}})}async getConfirmedBlock(e,t){const n=this._buildArgsAtLeastConfirmed([e],t),s=await this._rpcRequest("getConfirmedBlock",n),o=Be(s,Eu);if("error"in o)throw new qe(o.error,"failed to get confirmed block");const i=o.result;if(!i)throw new Error("Confirmed block "+e+" not found");const a={...i,transactions:i.transactions.map(({transaction:u,meta:d})=>{const p=new yn(u.message);return{meta:d,transaction:{...u,message:p}}})};return{...a,transactions:a.transactions.map(({transaction:u,meta:d})=>({meta:d,transaction:mt.populate(u.message,u.signatures)}))}}async getBlocks(e,t,n){const s=this._buildArgsAtLeastConfirmed(t!==void 0?[e,t]:[e],n),o=await this._rpcRequest("getBlocks",s),i=Be(o,st(Ce(N())));if("error"in i)throw new qe(i.error,"failed to get blocks");return i.result}async getBlockSignatures(e,t){const n=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:"signatures",rewards:!1}),s=await this._rpcRequest("getBlock",n),o=Be(s,Xo);if("error"in o)throw new qe(o.error,"failed to get block");const i=o.result;if(!i)throw new Error("Block "+e+" not found");return i}async getConfirmedBlockSignatures(e,t){const n=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:"signatures",rewards:!1}),s=await this._rpcRequest("getConfirmedBlock",n),o=Be(s,Xo);if("error"in o)throw new qe(o.error,"failed to get confirmed block");const i=o.result;if(!i)throw new Error("Confirmed block "+e+" not found");return i}async getConfirmedTransaction(e,t){const n=this._buildArgsAtLeastConfirmed([e],t),s=await this._rpcRequest("getConfirmedTransaction",n),o=Be(s,Ls);if("error"in o)throw new qe(o.error,"failed to get transaction");const i=o.result;if(!i)return i;const a=new yn(i.transaction.message),u=i.transaction.signatures;return{...i,transaction:mt.populate(a,u)}}async getParsedConfirmedTransaction(e,t){const n=this._buildArgsAtLeastConfirmed([e],t,"jsonParsed"),s=await this._rpcRequest("getConfirmedTransaction",n),o=Be(s,Mr);if("error"in o)throw new qe(o.error,"failed to get confirmed transaction");return o.result}async getParsedConfirmedTransactions(e,t){const n=e.map(i=>({methodName:"getConfirmedTransaction",args:this._buildArgsAtLeastConfirmed([i],t,"jsonParsed")}));return(await this._rpcBatchRequest(n)).map(i=>{const a=Be(i,Mr);if("error"in a)throw new qe(a.error,"failed to get confirmed transactions");return a.result})}async getConfirmedSignaturesForAddress(e,t,n){let s={},o=await this.getFirstAvailableBlock();for(;!("until"in s)&&(t--,!(t<=0||t<o));)try{const u=await this.getConfirmedBlockSignatures(t,"finalized");u.signatures.length>0&&(s.until=u.signatures[u.signatures.length-1].toString())}catch(u){if(u instanceof Error&&u.message.includes("skipped"))continue;throw u}let i=await this.getSlot("finalized");for(;!("before"in s)&&(n++,!(n>i));)try{const u=await this.getConfirmedBlockSignatures(n);u.signatures.length>0&&(s.before=u.signatures[u.signatures.length-1].toString())}catch(u){if(u instanceof Error&&u.message.includes("skipped"))continue;throw u}return(await this.getConfirmedSignaturesForAddress2(e,s)).map(u=>u.signature)}async getConfirmedSignaturesForAddress2(e,t,n){const s=this._buildArgsAtLeastConfirmed([e.toBase58()],n,void 0,t),o=await this._rpcRequest("getConfirmedSignaturesForAddress2",s),i=Be(o,Zc);if("error"in i)throw new qe(i.error,"failed to get confirmed signatures for address");return i.result}async getSignaturesForAddress(e,t,n){const s=this._buildArgsAtLeastConfirmed([e.toBase58()],n,void 0,t),o=await this._rpcRequest("getSignaturesForAddress",s),i=Be(o,Xc);if("error"in i)throw new qe(i.error,"failed to get signatures for address");return i.result}async getAddressLookupTable(e,t){const{context:n,value:s}=await this.getAccountInfoAndContext(e,t);let o=null;return s!==null&&(o=new vs({key:e,state:vs.deserialize(s.data)})),{context:n,value:o}}async getNonceAndContext(e,t){const{context:n,value:s}=await this.getAccountInfoAndContext(e,t);let o=null;return s!==null&&(o=Ur.fromAccountData(s.data)),{context:n,value:o}}async getNonce(e,t){return await this.getNonceAndContext(e,t).then(n=>n.value).catch(n=>{throw new Error("failed to get nonce for account "+e.toBase58()+": "+n)})}async requestAirdrop(e,t){const n=await this._rpcRequest("requestAirdrop",[e.toBase58(),t]),s=Be(n,Ru);if("error"in s)throw new qe(s.error,`airdrop to ${e.toBase58()} failed`);return s.result}async _blockhashWithExpiryBlockHeight(e){if(!e){for(;this._pollingBlockhash;)await Wn(100);const n=Date.now()-this._blockhashInfo.lastFetch>=Mo;if(this._blockhashInfo.latestBlockhash!==null&&!n)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 s=0;s<50;s++){const o=await this.getLatestBlockhash("finalized");if(n!==o.blockhash)return this._blockhashInfo={latestBlockhash:o,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},o;await Wn(Lo/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}=Rt(e),s=this._buildArgs([],t,"base64",n),o=await this._rpcRequest("getStakeMinimumDelegation",s),i=Be(o,Nt(N()));if("error"in i)throw new qe(i.error,"failed to get stake minimum delegation");return i.result}async simulateTransaction(e,t,n){if("message"in e){const k=e.serialize(),O=T.Buffer.from(k).toString("base64");if(Array.isArray(t)||n!==void 0)throw new Error("Invalid arguments");const F=t||{};F.encoding="base64","commitment"in F||(F.commitment=this.commitment);const de=[O,F],pe=await this._rpcRequest("simulateTransaction",de),Oe=Be(pe,Ho);if("error"in Oe)throw new Error("failed to simulate transaction: "+Oe.error.message);return Oe.result}let s;if(e instanceof mt){let K=e;s=new mt,s.feePayer=K.feePayer,s.instructions=e.instructions,s.nonceInfo=K.nonceInfo,s.signatures=K.signatures}else s=mt.populate(e),s._message=s._json=void 0;if(t!==void 0&&!Array.isArray(t))throw new Error("Invalid arguments");const o=t;if(s.nonceInfo&&o)s.sign(...o);else{let K=this._disableBlockhashCaching;for(;;){const k=await this._blockhashWithExpiryBlockHeight(K);if(s.lastValidBlockHeight=k.lastValidBlockHeight,s.recentBlockhash=k.blockhash,!o)break;if(s.sign(...o),!s.signature)throw new Error("!signature");const O=s.signature.toString("base64");if(!this._blockhashInfo.simulatedSignatures.includes(O)&&!this._blockhashInfo.transactionSignatures.includes(O)){this._blockhashInfo.simulatedSignatures.push(O);break}else K=!0}}const i=s._compile(),a=i.serialize(),d=s._serialize(a).toString("base64"),p={encoding:"base64",commitment:this.commitment};if(n){const K=(Array.isArray(n)?n:i.nonProgramIds()).map(k=>k.toBase58());p.accounts={encoding:"base64",addresses:K}}o&&(p.sigVerify=!0);const m=[d,p],V=await this._rpcRequest("simulateTransaction",m),C=Be(V,Ho);if("error"in C){let K;if("data"in C.error&&(K=C.error.data.logs,K&&Array.isArray(K))){const k=`
109
+ `,O=k+K.join(k);console.error(C.error.message,O)}throw new xs("failed to simulate transaction: "+C.error.message,K)}return C.result}async sendTransaction(e,t,n){if("version"in e){if(t&&Array.isArray(t))throw new Error("Invalid arguments");const i=e.serialize();return await this.sendRawTransaction(i,t)}if(t===void 0||!Array.isArray(t))throw new Error("Invalid arguments");const s=t;if(e.nonceInfo)e.sign(...s);else{let i=this._disableBlockhashCaching;for(;;){const a=await this._blockhashWithExpiryBlockHeight(i);if(e.lastValidBlockHeight=a.lastValidBlockHeight,e.recentBlockhash=a.blockhash,e.sign(...s),!e.signature)throw new Error("!signature");const u=e.signature.toString("base64");if(this._blockhashInfo.transactionSignatures.includes(u))i=!0;else{this._blockhashInfo.transactionSignatures.push(u);break}}}const o=e.serialize();return await this.sendRawTransaction(o,n)}async sendRawTransaction(e,t){const n=rt(e).toString("base64");return await this.sendEncodedTransaction(n,t)}async sendEncodedTransaction(e,t){const n={encoding:"base64"},s=t&&t.skipPreflight,o=t&&t.preflightCommitment||this.commitment;t&&t.maxRetries!=null&&(n.maxRetries=t.maxRetries),t&&t.minContextSlot!=null&&(n.minContextSlot=t.minContextSlot),s&&(n.skipPreflight=s),o&&(n.preflightCommitment=o);const i=[e,n],a=await this._rpcRequest("sendTransaction",i),u=Be(a,Pu);if("error"in u){let d;throw"data"in u.error&&(d=u.error.data.logs),new xs("failed to send transaction: "+u.error.message,d)}return u.result}_wsOnOpen(){this._rpcWebSocketConnected=!0,this._rpcWebSocketHeartbeat=setInterval(()=>{(async()=>{try{await this._rpcWebSocket.notify("ping")}catch{}})()},5e3),this._updateSubscriptions()}_wsOnError(e){this._rpcWebSocketConnected=!1,console.error("ws error:",e.message)}_wsOnClose(e){if(this._rpcWebSocketConnected=!1,this._rpcWebSocketGeneration=(this._rpcWebSocketGeneration+1)%Number.MAX_SAFE_INTEGER,this._rpcWebSocketIdleTimeout&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null),this._rpcWebSocketHeartbeat&&(clearInterval(this._rpcWebSocketHeartbeat),this._rpcWebSocketHeartbeat=null),e===1e3){this._updateSubscriptions();return}this._subscriptionCallbacksByServerSubscriptionId={},Object.entries(this._subscriptionsByHash).forEach(([t,n])=>{this._setSubscription(t,{...n,state:"pending"})})}_setSubscription(e,t){var s;const n=(s=this._subscriptionsByHash[e])==null?void 0:s.state;if(this._subscriptionsByHash[e]=t,n!==t.state){const o=this._subscriptionStateChangeCallbacksByHash[e];o&&o.forEach(i=>{try{i(t.state)}catch{}})}}_onSubscriptionStateChange(e,t){var o;const n=this._subscriptionHashByClientSubscriptionId[e];if(n==null)return()=>{};const s=(o=this._subscriptionStateChangeCallbacksByHash)[n]||(o[n]=new Set);return s.add(t),()=>{s.delete(t),s.size===0&&delete this._subscriptionStateChangeCallbacksByHash[n]}}async _updateSubscriptions(){if(Object.keys(this._subscriptionsByHash).length===0){this._rpcWebSocketConnected&&(this._rpcWebSocketConnected=!1,this._rpcWebSocketIdleTimeout=setTimeout(()=>{this._rpcWebSocketIdleTimeout=null;try{this._rpcWebSocket.close()}catch(n){n instanceof Error&&console.log(`Error when closing socket connection: ${n.message}`)}},500));return}if(this._rpcWebSocketIdleTimeout!==null&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketConnected=!0),!this._rpcWebSocketConnected){this._rpcWebSocket.connect();return}const e=this._rpcWebSocketGeneration,t=()=>e===this._rpcWebSocketGeneration;await Promise.all(Object.keys(this._subscriptionsByHash).map(async n=>{const s=this._subscriptionsByHash[n];if(s!==void 0)switch(s.state){case"pending":case"unsubscribed":if(s.callbacks.size===0){delete this._subscriptionsByHash[n],s.state==="unsubscribed"&&delete this._subscriptionCallbacksByServerSubscriptionId[s.serverSubscriptionId],await this._updateSubscriptions();return}await(async()=>{const{args:o,method:i}=s;try{this._setSubscription(n,{...s,state:"subscribing"});const a=await this._rpcWebSocket.call(i,o);this._setSubscription(n,{...s,serverSubscriptionId:a,state:"subscribed"}),this._subscriptionCallbacksByServerSubscriptionId[a]=s.callbacks,await this._updateSubscriptions()}catch(a){if(a instanceof Error&&console.error(`${i} error for argument`,o,a.message),!t())return;this._setSubscription(n,{...s,state:"pending"}),await this._updateSubscriptions()}})();break;case"subscribed":s.callbacks.size===0&&await(async()=>{const{serverSubscriptionId:o,unsubscribeMethod:i}=s;if(this._subscriptionsAutoDisposedByRpc.has(o))this._subscriptionsAutoDisposedByRpc.delete(o);else{this._setSubscription(n,{...s,state:"unsubscribing"}),this._setSubscription(n,{...s,state:"unsubscribing"});try{await this._rpcWebSocket.call(i,[o])}catch(a){if(a instanceof Error&&console.error(`${i} error:`,a.message),!t())return;this._setSubscription(n,{...s,state:"subscribed"}),await this._updateSubscriptions();return}}this._setSubscription(n,{...s,state:"unsubscribed"}),await this._updateSubscriptions()})();break}}))}_handleServerNotification(e,t){const n=this._subscriptionCallbacksByServerSubscriptionId[e];n!==void 0&&n.forEach(s=>{try{s(...t)}catch(o){console.error(o)}})}_wsOnAccountNotification(e){const{result:t,subscription:n}=Be(e,Qc);this._handleServerNotification(n,[t.value,t.context])}_makeSubscription(e,t){const n=this._nextClientSubscriptionId++,s=Uo([e.method,t],!0),o=this._subscriptionsByHash[s];return o===void 0?this._subscriptionsByHash[s]={...e,args:t,callbacks:new Set([e.callback]),state:"pending"}:o.callbacks.add(e.callback),this._subscriptionHashByClientSubscriptionId[n]=s,this._subscriptionDisposeFunctionsByClientSubscriptionId[n]=async()=>{delete this._subscriptionDisposeFunctionsByClientSubscriptionId[n],delete this._subscriptionHashByClientSubscriptionId[n];const i=this._subscriptionsByHash[s];gt(i!==void 0,`Could not find a \`Subscription\` when tearing down client subscription #${n}`),i.callbacks.delete(e.callback),await this._updateSubscriptions()},this._updateSubscriptions(),n}onAccountChange(e,t,n){const s=this._buildArgs([e.toBase58()],n||this._commitment||"finalized","base64");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}=Be(e,tu);this._handleServerNotification(n,[{accountId:t.value.pubkey,accountInfo:t.value.account},t.context])}onProgramAccountChange(e,t,n,s){const o=this._buildArgs([e.toBase58()],n||this._commitment||"finalized","base64",s?{filters:s}: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 s=this._buildArgs([typeof e=="object"?{mentions:[e.toString()]}:e],n||this._commitment||"finalized");return this._makeSubscription({callback:t,method:"logsSubscribe",unsubscribeMethod:"logsUnsubscribe"},s)}async removeOnLogsListener(e){await this._unsubscribeClientSubscription(e,"logs")}_wsOnLogsNotification(e){const{result:t,subscription:n}=Be(e,Ou);this._handleServerNotification(n,[t.value,t.context])}_wsOnSlotNotification(e){const{result:t,subscription:n}=Be(e,ru);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}=Be(e,ou);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,s){const o=t||this._commitment;if(o||n||s){let i={};n&&(i.encoding=n),o&&(i.commitment=o),s&&(i=Object.assign(i,s)),e.push(i)}return e}_buildArgsAtLeastConfirmed(e,t,n,s){const o=t||this._commitment;if(o&&!["confirmed","finalized"].includes(o))throw new Error("Using Connection with default commitment: `"+this._commitment+"`, but method requires at least `confirmed`");return this._buildArgs(e,t,n,s)}_wsOnSignatureNotification(e){const{result:t,subscription:n}=Be(e,iu);t.value!=="receivedSignature"&&this._subscriptionsAutoDisposedByRpc.add(n),this._handleServerNotification(n,t.value==="receivedSignature"?[{type:"received"},t.context]:[{type:"status",result:t.value},t.context])}onSignature(e,t,n){const s=this._buildArgs([e],n||this._commitment||"finalized"),o=this._makeSubscription({callback:(i,a)=>{if(i.type==="status"){t(i.result,a);try{this.removeSignatureListener(o)}catch{}}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},s);return o}onSignatureWithOptions(e,t,n){const{commitment:s,...o}={...n,commitment:n&&n.commitment||this._commitment||"finalized"},i=this._buildArgs([e],s,void 0,o),a=this._makeSubscription({callback:(u,d)=>{t(u,d);try{this.removeSignatureListener(a)}catch{}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},i);return a}async removeSignatureListener(e){await this._unsubscribeClientSubscription(e,"signature result")}_wsOnRootNotification(e){const{result:t,subscription:n}=Be(e,au);this._handleServerNotification(n,[t])}onRootChange(e){return this._makeSubscription({callback:e,method:"rootSubscribe",unsubscribeMethod:"rootUnsubscribe"},[])}async removeRootChangeListener(e){await this._unsubscribeClientSubscription(e,"root change")}}class er{constructor(e){this._keypair=void 0,this._keypair=e!=null?e:Ao()}static generate(){return new er(Ao())}static fromSecretKey(e,t){if(e.byteLength!==64)throw new Error("bad secret key size");const n=e.slice(32,64);if(!t||!t.skipValidation){const s=e.slice(0,32),o=Tr(s);for(let i=0;i<32;i++)if(n[i]!==o[i])throw new Error("provided secretKey is invalid")}return new er({publicKey:n,secretKey:e})}static fromSeed(e){const t=Tr(e),n=new Uint8Array(64);return n.set(e),n.set(t,32),new er({publicKey:t,secretKey:n})}get publicKey(){return new ve(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}}const In=Object.freeze({CreateLookupTable:{index:0,layout:b.n_([b.Jq("instruction"),Xn("recentSlot"),b.u8("bumpSeed")])},FreezeLookupTable:{index:1,layout:b.n_([b.Jq("instruction")])},ExtendLookupTable:{index:2,layout:b.n_([b.Jq("instruction"),Xn(),b.A9(ct(),b.cv(b.Jq(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:b.n_([b.Jq("instruction")])},CloseLookupTable:{index:4,layout:b.n_([b.Jq("instruction")])}});class Nu{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);const n=b.Jq("instruction").decode(e.data);let s;for(const[o,i]of Object.entries(In))if(i.index==n){s=o;break}if(!s)throw new Error("Invalid Instruction. Should be a LookupTable Instruction");return s}static decodeCreateLookupTable(e){this.checkProgramId(e.programId),this.checkKeysLength(e.keys,4);const{recentSlot:t}=wt(In.CreateLookupTable,e.data);return{authority:e.keys[1].pubkey,payer:e.keys[2].pubkey,recentSlot:Number(t)}}static decodeExtendLookupTable(e){if(this.checkProgramId(e.programId),e.keys.length<2)throw new Error(`invalid instruction; found ${e.keys.length} keys, expected at least 2`);const{addresses:t}=wt(In.ExtendLookupTable,e.data);return{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey,payer:e.keys.length>2?e.keys[2].pubkey:void 0,addresses:t.map(n=>new ve(n))}}static decodeCloseLookupTable(e){return this.checkProgramId(e.programId),this.checkKeysLength(e.keys,3),{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey,recipient:e.keys[2].pubkey}}static decodeFreezeLookupTable(e){return this.checkProgramId(e.programId),this.checkKeysLength(e.keys,2),{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey}}static decodeDeactivateLookupTable(e){return this.checkProgramId(e.programId),this.checkKeysLength(e.keys,2),{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey}}static checkProgramId(e){if(!e.equals(Cs.programId))throw new Error("invalid instruction; programId is not AddressLookupTable Program")}static checkKeysLength(e,t){if(e.length<t)throw new Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}}class Cs{constructor(){}static createLookupTable(e){const[t,n]=ve.findProgramAddressSync([e.authority.toBuffer(),(0,rs.k$)(BigInt(e.recentSlot),8)],this.programId),s=In.CreateLookupTable,o=pt(s,{recentSlot:BigInt(e.recentSlot),bumpSeed:n}),i=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1},{pubkey:e.payer,isSigner:!0,isWritable:!0},{pubkey:Qt.programId,isSigner:!1,isWritable:!1}];return[new _t({programId:this.programId,keys:i,data:o}),t]}static freezeLookupTable(e){const t=In.FreezeLookupTable,n=pt(t),s=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new _t({programId:this.programId,keys:s,data:n})}static extendLookupTable(e){const t=In.ExtendLookupTable,n=pt(t,{addresses:e.addresses.map(o=>o.toBytes())}),s=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return e.payer&&s.push({pubkey:e.payer,isSigner:!0,isWritable:!0},{pubkey:Qt.programId,isSigner:!1,isWritable:!1}),new _t({programId:this.programId,keys:s,data:n})}static deactivateLookupTable(e){const t=In.DeactivateLookupTable,n=pt(t),s=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new _t({programId:this.programId,keys:s,data:n})}static closeLookupTable(e){const t=In.CloseLookupTable,n=pt(t),s=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1},{pubkey:e.recipient,isSigner:!1,isWritable:!0}];return new _t({programId:this.programId,keys:s,data:n})}}Cs.programId=new ve("AddressLookupTab1e1111111111111111111111111");class Uu{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);const n=b.u8("instruction").decode(e.data);let s;for(const[o,i]of Object.entries(xn))if(i.index==n){s=o;break}if(!s)throw new Error("Instruction type incorrect; not a ComputeBudgetInstruction");return s}static decodeRequestUnits(e){this.checkProgramId(e.programId);const{units:t,additionalFee:n}=wt(xn.RequestUnits,e.data);return{units:t,additionalFee:n}}static decodeRequestHeapFrame(e){this.checkProgramId(e.programId);const{bytes:t}=wt(xn.RequestHeapFrame,e.data);return{bytes:t}}static decodeSetComputeUnitLimit(e){this.checkProgramId(e.programId);const{units:t}=wt(xn.SetComputeUnitLimit,e.data);return{units:t}}static decodeSetComputeUnitPrice(e){this.checkProgramId(e.programId);const{microLamports:t}=wt(xn.SetComputeUnitPrice,e.data);return{microLamports:t}}static checkProgramId(e){if(!e.equals(Ns.programId))throw new Error("invalid instruction; programId is not ComputeBudgetProgram")}}const xn=Object.freeze({RequestUnits:{index:0,layout:b.n_([b.u8("instruction"),b.Jq("units"),b.Jq("additionalFee")])},RequestHeapFrame:{index:1,layout:b.n_([b.u8("instruction"),b.Jq("bytes")])},SetComputeUnitLimit:{index:2,layout:b.n_([b.u8("instruction"),b.Jq("units")])},SetComputeUnitPrice:{index:3,layout:b.n_([b.u8("instruction"),Xn("microLamports")])}});class Ns{constructor(){}static requestUnits(e){const t=xn.RequestUnits,n=pt(t,e);return new _t({keys:[],programId:this.programId,data:n})}static requestHeapFrame(e){const t=xn.RequestHeapFrame,n=pt(t,e);return new _t({keys:[],programId:this.programId,data:n})}static setComputeUnitLimit(e){const t=xn.SetComputeUnitLimit,n=pt(t,e);return new _t({keys:[],programId:this.programId,data:n})}static setComputeUnitPrice(e){const t=xn.SetComputeUnitPrice,n=pt(t,{microLamports:BigInt(e.microLamports)});return new _t({keys:[],programId:this.programId,data:n})}}Ns.programId=new ve("ComputeBudget111111111111111111111111111111");const Qo=64,ei=32,ti=64,ni=b.n_([b.u8("numSignatures"),b.u8("padding"),b.KB("signatureOffset"),b.KB("signatureInstructionIndex"),b.KB("publicKeyOffset"),b.KB("publicKeyInstructionIndex"),b.KB("messageDataOffset"),b.KB("messageDataSize"),b.KB("messageInstructionIndex")]);class Wr{constructor(){}static createInstructionWithPublicKey(e){const{publicKey:t,message:n,signature:s,instructionIndex:o}=e;gt(t.length===ei,`Public Key must be ${ei} bytes but received ${t.length} bytes`),gt(s.length===ti,`Signature must be ${ti} bytes but received ${s.length} bytes`);const i=ni.span,a=i+t.length,u=a+s.length,d=1,p=T.Buffer.alloc(u+n.length),m=o==null?65535:o;return ni.encode({numSignatures:d,padding:0,signatureOffset:a,signatureInstructionIndex:m,publicKeyOffset:i,publicKeyInstructionIndex:m,messageDataOffset:u,messageDataSize:n.length,messageInstructionIndex:m},p),p.fill(t,i),p.fill(s,a),p.fill(n,u),new _t({keys:[],programId:Wr.programId,data:p})}static createInstructionWithPrivateKey(e){const{privateKey:t,message:n,instructionIndex:s}=e;gt(t.length===Qo,`Private key must be ${Qo} bytes but received ${t.length} bytes`);try{const o=er.fromSecretKey(t),i=o.publicKey.toBytes(),a=ps(n,o.secretKey);return this.createInstructionWithPublicKey({publicKey:i,message:n,signature:a,instructionIndex:s})}catch(o){throw new Error(`Error creating instruction; ${o}`)}}}Wr.programId=new ve("Ed25519SigVerify111111111111111111111111111");const zu=(r,e)=>{const t=ur.sign(r,e);return[t.toCompactRawBytes(),t.recovery]};ur.utils.isValidPrivateKey;const Ku=ur.getPublicKey,ri=32,Us=20,si=64,Du=11,zs=b.n_([b.u8("numSignatures"),b.KB("signatureOffset"),b.u8("signatureInstructionIndex"),b.KB("ethAddressOffset"),b.u8("ethAddressInstructionIndex"),b.KB("messageDataOffset"),b.KB("messageDataSize"),b.u8("messageInstructionIndex"),b.Ik(20,"ethAddress"),b.Ik(64,"signature"),b.u8("recoveryId")]);class tr{constructor(){}static publicKeyToEthAddress(e){gt(e.length===si,`Public key must be ${si} bytes but received ${e.length} bytes`);try{return T.Buffer.from(go(rt(e))).slice(-Us)}catch(t){throw new Error(`Error constructing Ethereum address: ${t}`)}}static createInstructionWithPublicKey(e){const{publicKey:t,message:n,signature:s,recoveryId:o,instructionIndex:i}=e;return tr.createInstructionWithEthAddress({ethAddress:tr.publicKeyToEthAddress(t),message:n,signature:s,recoveryId:o,instructionIndex:i})}static createInstructionWithEthAddress(e){const{ethAddress:t,message:n,signature:s,recoveryId:o,instructionIndex:i=0}=e;let a;typeof t=="string"?t.startsWith("0x")?a=T.Buffer.from(t.substr(2),"hex"):a=T.Buffer.from(t,"hex"):a=t,gt(a.length===Us,`Address must be ${Us} bytes but received ${a.length} bytes`);const u=1+Du,d=u,p=u+a.length,m=p+s.length+1,V=1,C=T.Buffer.alloc(zs.span+n.length);return zs.encode({numSignatures:V,signatureOffset:p,signatureInstructionIndex:i,ethAddressOffset:d,ethAddressInstructionIndex:i,messageDataOffset:m,messageDataSize:n.length,messageInstructionIndex:i,signature:rt(s),ethAddress:rt(a),recoveryId:o},C),C.fill(rt(n),zs.span),new _t({keys:[],programId:tr.programId,data:C})}static createInstructionWithPrivateKey(e){const{privateKey:t,message:n,instructionIndex:s}=e;gt(t.length===ri,`Private key must be ${ri} bytes but received ${t.length} bytes`);try{const o=rt(t),i=Ku(o,!1).slice(1),a=T.Buffer.from(go(rt(n))),[u,d]=zu(a,o);return this.createInstructionWithPublicKey({publicKey:i,message:n,signature:u,recoveryId:d,instructionIndex:s})}catch(o){throw new Error(`Error creating instruction; ${o}`)}}}tr.programId=new ve("KeccakSecp256k11111111111111111111111111111");var oi;const ii=new ve("StakeConfig11111111111111111111111111111111");class ai{constructor(e,t){this.staker=void 0,this.withdrawer=void 0,this.staker=e,this.withdrawer=t}}class yr{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}}oi=yr,yr.default=new oi(0,0,ve.default);class Mu{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);const n=b.Jq("instruction").decode(e.data);let s;for(const[o,i]of Object.entries(Jt))if(i.index==n){s=o;break}if(!s)throw new Error("Instruction type incorrect; not a StakeInstruction");return s}static decodeInitialize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{authorized:t,lockup:n}=wt(Jt.Initialize,e.data);return{stakePubkey:e.keys[0].pubkey,authorized:new ai(new ve(t.staker),new ve(t.withdrawer)),lockup:new yr(n.unixTimestamp,n.epoch,new ve(n.custodian))}}static decodeDelegate(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,6),wt(Jt.Delegate,e.data),{stakePubkey:e.keys[0].pubkey,votePubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[5].pubkey}}static decodeAuthorize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{newAuthorized:t,stakeAuthorizationType:n}=wt(Jt.Authorize,e.data),s={stakePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey,newAuthorizedPubkey:new ve(t),stakeAuthorizationType:{index:n}};return e.keys.length>3&&(s.custodianPubkey=e.keys[3].pubkey),s}static decodeAuthorizeWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);const{newAuthorized:t,stakeAuthorizationType:n,authoritySeed:s,authorityOwner:o}=wt(Jt.AuthorizeWithSeed,e.data),i={stakePubkey:e.keys[0].pubkey,authorityBase:e.keys[1].pubkey,authoritySeed:s,authorityOwner:new ve(o),newAuthorizedPubkey:new ve(t),stakeAuthorizationType:{index:n}};return e.keys.length>3&&(i.custodianPubkey=e.keys[3].pubkey),i}static decodeSplit(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{lamports:t}=wt(Jt.Split,e.data);return{stakePubkey:e.keys[0].pubkey,splitStakePubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[2].pubkey,lamports:t}}static decodeMerge(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3),wt(Jt.Merge,e.data),{stakePubkey:e.keys[0].pubkey,sourceStakePubKey:e.keys[1].pubkey,authorizedPubkey:e.keys[4].pubkey}}static decodeWithdraw(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,5);const{lamports:t}=wt(Jt.Withdraw,e.data),n={stakePubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[4].pubkey,lamports:t};return e.keys.length>5&&(n.custodianPubkey=e.keys[5].pubkey),n}static decodeDeactivate(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3),wt(Jt.Deactivate,e.data),{stakePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey}}static checkProgramId(e){if(!e.equals(Hr.programId))throw new Error("invalid instruction; programId is not StakeProgram")}static checkKeyLength(e,t){if(e.length<t)throw new Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}}const Jt=Object.freeze({Initialize:{index:0,layout:b.n_([b.Jq("instruction"),Ga(),ja()])},Authorize:{index:1,layout:b.n_([b.Jq("instruction"),ct("newAuthorized"),b.Jq("stakeAuthorizationType")])},Delegate:{index:2,layout:b.n_([b.Jq("instruction")])},Split:{index:3,layout:b.n_([b.Jq("instruction"),b.gM("lamports")])},Withdraw:{index:4,layout:b.n_([b.Jq("instruction"),b.gM("lamports")])},Deactivate:{index:5,layout:b.n_([b.Jq("instruction")])},Merge:{index:7,layout:b.n_([b.Jq("instruction")])},AuthorizeWithSeed:{index:8,layout:b.n_([b.Jq("instruction"),ct("newAuthorized"),b.Jq("stakeAuthorizationType"),Dn("authoritySeed"),ct("authorityOwner")])}}),Wu=Object.freeze({Staker:{index:0},Withdrawer:{index:1}});class Hr{constructor(){}static initialize(e){const{stakePubkey:t,authorized:n,lockup:s}=e,o=s||yr.default,i=Jt.Initialize,a=pt(i,{authorized:{staker:rt(n.staker.toBuffer()),withdrawer:rt(n.withdrawer.toBuffer())},lockup:{unixTimestamp:o.unixTimestamp,epoch:o.epoch,custodian:rt(o.custodian.toBuffer())}}),u={keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Zn,isSigner:!1,isWritable:!1}],programId:this.programId,data:a};return new _t(u)}static createAccountWithSeed(e){const t=new mt;t.add(Qt.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:s,lockup:o}=e;return t.add(this.initialize({stakePubkey:n,authorized:s,lockup:o}))}static createAccount(e){const t=new mt;t.add(Qt.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.stakePubkey,lamports:e.lamports,space:this.space,programId:this.programId}));const{stakePubkey:n,authorized:s,lockup:o}=e;return t.add(this.initialize({stakePubkey:n,authorized:s,lockup:o}))}static delegate(e){const{stakePubkey:t,authorizedPubkey:n,votePubkey:s}=e,o=Jt.Delegate,i=pt(o);return new mt().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!1},{pubkey:_n,isSigner:!1,isWritable:!1},{pubkey:Nr,isSigner:!1,isWritable:!1},{pubkey:ii,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:i})}static authorize(e){const{stakePubkey:t,authorizedPubkey:n,newAuthorizedPubkey:s,stakeAuthorizationType:o,custodianPubkey:i}=e,a=Jt.Authorize,u=pt(a,{newAuthorized:rt(s.toBuffer()),stakeAuthorizationType:o.index}),d=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:_n,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return i&&d.push({pubkey:i,isSigner:!1,isWritable:!1}),new mt().add({keys:d,programId:this.programId,data:u})}static authorizeWithSeed(e){const{stakePubkey:t,authorityBase:n,authoritySeed:s,authorityOwner:o,newAuthorizedPubkey:i,stakeAuthorizationType:a,custodianPubkey:u}=e,d=Jt.AuthorizeWithSeed,p=pt(d,{newAuthorized:rt(i.toBuffer()),stakeAuthorizationType:a.index,authoritySeed:s,authorityOwner:rt(o.toBuffer())}),m=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1},{pubkey:_n,isSigner:!1,isWritable:!1}];return u&&m.push({pubkey:u,isSigner:!1,isWritable:!1}),new mt().add({keys:m,programId:this.programId,data:p})}static splitInstruction(e){const{stakePubkey:t,authorizedPubkey:n,splitStakePubkey:s,lamports:o}=e,i=Jt.Split,a=pt(i,{lamports:o});return new _t({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:a})}static split(e){const t=new mt;return t.add(Qt.createAccount({fromPubkey:e.authorizedPubkey,newAccountPubkey:e.splitStakePubkey,lamports:0,space:this.space,programId:this.programId})),t.add(this.splitInstruction(e))}static splitWithSeed(e){const{stakePubkey:t,authorizedPubkey:n,splitStakePubkey:s,basePubkey:o,seed:i,lamports:a}=e,u=new mt;return u.add(Qt.allocate({accountPubkey:s,basePubkey:o,seed:i,space:this.space,programId:this.programId})),u.add(this.splitInstruction({stakePubkey:t,authorizedPubkey:n,splitStakePubkey:s,lamports:a}))}static merge(e){const{stakePubkey:t,sourceStakePubKey:n,authorizedPubkey:s}=e,o=Jt.Merge,i=pt(o);return new mt().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!1,isWritable:!0},{pubkey:_n,isSigner:!1,isWritable:!1},{pubkey:Nr,isSigner:!1,isWritable:!1},{pubkey:s,isSigner:!0,isWritable:!1}],programId:this.programId,data:i})}static withdraw(e){const{stakePubkey:t,authorizedPubkey:n,toPubkey:s,lamports:o,custodianPubkey:i}=e,a=Jt.Withdraw,u=pt(a,{lamports:o}),d=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:_n,isSigner:!1,isWritable:!1},{pubkey:Nr,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return i&&d.push({pubkey:i,isSigner:!1,isWritable:!1}),new mt().add({keys:d,programId:this.programId,data:u})}static deactivate(e){const{stakePubkey:t,authorizedPubkey:n}=e,s=Jt.Deactivate,o=pt(s);return new mt().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:_n,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:o})}}Hr.programId=new ve("Stake11111111111111111111111111111111111111"),Hr.space=200;class ci{constructor(e,t,n,s){this.nodePubkey=void 0,this.authorizedVoter=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.nodePubkey=e,this.authorizedVoter=t,this.authorizedWithdrawer=n,this.commission=s}}class Hu{constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);const n=b.Jq("instruction").decode(e.data);let s;for(const[o,i]of Object.entries(Bn))if(i.index==n){s=o;break}if(!s)throw new Error("Instruction type incorrect; not a VoteInstruction");return s}static decodeInitializeAccount(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,4);const{voteInit:t}=wt(Bn.InitializeAccount,e.data);return{votePubkey:e.keys[0].pubkey,nodePubkey:e.keys[3].pubkey,voteInit:new ci(new ve(t.nodePubkey),new ve(t.authorizedVoter),new ve(t.authorizedWithdrawer),t.commission)}}static decodeAuthorize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{newAuthorized:t,voteAuthorizationType:n}=wt(Bn.Authorize,e.data);return{votePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey,newAuthorizedPubkey:new ve(t),voteAuthorizationType:{index:n}}}static decodeAuthorizeWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:t,currentAuthorityDerivedKeySeed:n,newAuthorized:s,voteAuthorizationType:o}}=wt(Bn.AuthorizeWithSeed,e.data);return{currentAuthorityDerivedKeyBasePubkey:e.keys[2].pubkey,currentAuthorityDerivedKeyOwnerPubkey:new ve(t),currentAuthorityDerivedKeySeed:n,newAuthorizedPubkey:new ve(s),voteAuthorizationType:{index:o},votePubkey:e.keys[0].pubkey}}static decodeWithdraw(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);const{lamports:t}=wt(Bn.Withdraw,e.data);return{votePubkey:e.keys[0].pubkey,authorizedWithdrawerPubkey:e.keys[2].pubkey,lamports:t,toPubkey:e.keys[1].pubkey}}static checkProgramId(e){if(!e.equals(nr.programId))throw new Error("invalid instruction; programId is not VoteProgram")}static checkKeyLength(e,t){if(e.length<t)throw new Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}}const Bn=Object.freeze({InitializeAccount:{index:0,layout:b.n_([b.Jq("instruction"),$a()])},Authorize:{index:1,layout:b.n_([b.Jq("instruction"),ct("newAuthorized"),b.Jq("voteAuthorizationType")])},Withdraw:{index:3,layout:b.n_([b.Jq("instruction"),b.gM("lamports")])},AuthorizeWithSeed:{index:10,layout:b.n_([b.Jq("instruction"),Ya()])}}),qu=Object.freeze({Voter:{index:0},Withdrawer:{index:1}});class nr{constructor(){}static initializeAccount(e){const{votePubkey:t,nodePubkey:n,voteInit:s}=e,o=Bn.InitializeAccount,i=pt(o,{voteInit:{nodePubkey:rt(s.nodePubkey.toBuffer()),authorizedVoter:rt(s.authorizedVoter.toBuffer()),authorizedWithdrawer:rt(s.authorizedWithdrawer.toBuffer()),commission:s.commission}}),a={keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Zn,isSigner:!1,isWritable:!1},{pubkey:_n,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}],programId:this.programId,data:i};return new _t(a)}static createAccount(e){const t=new mt;return t.add(Qt.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:s,voteAuthorizationType:o}=e,i=Bn.Authorize,a=pt(i,{newAuthorized:rt(s.toBuffer()),voteAuthorizationType:o.index}),u=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:_n,isSigner:!1,isWritable:!1},{pubkey:n,isSigner:!0,isWritable:!1}];return new mt().add({keys:u,programId:this.programId,data:a})}static authorizeWithSeed(e){const{currentAuthorityDerivedKeyBasePubkey:t,currentAuthorityDerivedKeyOwnerPubkey:n,currentAuthorityDerivedKeySeed:s,newAuthorizedPubkey:o,voteAuthorizationType:i,votePubkey:a}=e,u=Bn.AuthorizeWithSeed,d=pt(u,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:rt(n.toBuffer()),currentAuthorityDerivedKeySeed:s,newAuthorized:rt(o.toBuffer()),voteAuthorizationType:i.index}}),p=[{pubkey:a,isSigner:!1,isWritable:!0},{pubkey:_n,isSigner:!1,isWritable:!1},{pubkey:t,isSigner:!0,isWritable:!1}];return new mt().add({keys:p,programId:this.programId,data:d})}static withdraw(e){const{votePubkey:t,authorizedWithdrawerPubkey:n,lamports:s,toPubkey:o}=e,i=Bn.Withdraw,a=pt(i,{lamports:s}),u=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:o,isSigner:!1,isWritable:!0},{pubkey:n,isSigner:!0,isWritable:!1}];return new mt().add({keys:u,programId:this.programId,data:a})}static safeWithdraw(e,t,n){if(e.lamports>t-n)throw new Error("Withdraw will leave vote account with insuffcient funds.");return nr.withdraw(e)}}nr.programId=new ve("Vote111111111111111111111111111111111111111"),nr.space=3731;const ui=new ve("Va1idator1nfo111111111111111111111111111111"),Fu=he({name:_e(),website:Ze(_e()),details:Ze(_e()),keybaseUsername:Ze(_e())});class Ks{constructor(e,t){this.key=void 0,this.info=void 0,this.key=e,this.info=t}static fromConfigData(e){let t=[...e];if(on(t)!==2)return null;const s=[];for(let o=0;o<2;o++){const i=new ve(t.slice(0,un));t=t.slice(un);const a=t.slice(0,1)[0]===1;t=t.slice(1),s.push({publicKey:i,isSigner:a})}if(s[0].publicKey.equals(ui)&&s[1].isSigner){const o=Dn().decode(T.Buffer.from(t)),i=JSON.parse(o);return oo(i,Fu),new Ks(s[1].publicKey,i)}return null}}const Vu=new ve("Vote111111111111111111111111111111111111111"),Gu=b.n_([ct("nodePubkey"),ct("authorizedWithdrawer"),b.u8("commission"),b._O(),b.A9(b.n_([b._O("slot"),b.Jq("confirmationCount")]),b.cv(b.Jq(),-8),"votes"),b.u8("rootSlotValid"),b._O("rootSlot"),b._O(),b.A9(b.n_([b._O("epoch"),ct("authorizedVoter")]),b.cv(b.Jq(),-8),"authorizedVoters"),b.n_([b.A9(b.n_([ct("authorizedPubkey"),b._O("epochOfLastAuthorizedSwitch"),b._O("targetEpoch")]),32,"buf"),b._O("idx"),b.u8("isEmpty")],"priorVoters"),b._O(),b.A9(b.n_([b._O("epoch"),b._O("credits"),b._O("prevCredits")]),b.cv(b.Jq(),-8),"epochCredits"),b.n_([b._O("slot"),b._O("timestamp")],"lastTimestamp")]);class Ds{constructor(e){this.nodePubkey=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.rootSlot=void 0,this.votes=void 0,this.authorizedVoters=void 0,this.priorVoters=void 0,this.epochCredits=void 0,this.lastTimestamp=void 0,this.nodePubkey=e.nodePubkey,this.authorizedWithdrawer=e.authorizedWithdrawer,this.commission=e.commission,this.rootSlot=e.rootSlot,this.votes=e.votes,this.authorizedVoters=e.authorizedVoters,this.priorVoters=e.priorVoters,this.epochCredits=e.epochCredits,this.lastTimestamp=e.lastTimestamp}static fromAccountData(e){const n=Gu.decode(rt(e),4);let s=n.rootSlot;return n.rootSlotValid||(s=null),new Ds({nodePubkey:new ve(n.nodePubkey),authorizedWithdrawer:new ve(n.authorizedWithdrawer),commission:n.commission,votes:n.votes,rootSlot:s,authorizedVoters:n.authorizedVoters.map(ju),priorVoters:$u(n.priorVoters),epochCredits:n.epochCredits,lastTimestamp:n.lastTimestamp})}}function ju({authorizedVoter:r,epoch:e}){return{epoch:e,authorizedVoter:new ve(r)}}function li({authorizedPubkey:r,epochOfLastAuthorizedSwitch:e,targetEpoch:t}){return{authorizedPubkey:new ve(r),epochOfLastAuthorizedSwitch:e,targetEpoch:t}}function $u({buf:r,idx:e,isEmpty:t}){return t?[]:[...r.slice(e+1).map(li),...r.slice(0,e).map(li)]}const fi={http:{devnet:"http://api.devnet.solana.com",testnet:"http://api.testnet.solana.com","mainnet-beta":"http://api.mainnet-beta.solana.com/"},https:{devnet:"https://api.devnet.solana.com",testnet:"https://api.testnet.solana.com","mainnet-beta":"https://api.mainnet-beta.solana.com/"}};function Yu(r,e){const t=e===!1?"http":"https";if(!r)return fi[t].devnet;const n=fi[t][r];if(!n)throw new Error(`Unknown ${t} cluster: ${r}`);return n}async function Ju(r,e,t,n){let s,o;t&&Object.prototype.hasOwnProperty.call(t,"lastValidBlockHeight")||t&&Object.prototype.hasOwnProperty.call(t,"nonceValue")?(s=t,o=n):o=t;const i=o&&{skipPreflight:o.skipPreflight,preflightCommitment:o.preflightCommitment||o.commitment,minContextSlot:o.minContextSlot},a=await r.sendRawTransaction(e,i),u=o&&o.commitment,p=(await(s?r.confirmTransaction(s,u):r.confirmTransaction(a,u))).value;if(p.err)throw new Error(`Raw transaction ${a} failed (${JSON.stringify(p)})`);return a}const Zu=1e9},58162:function(ne,$,A){"use strict";var h=A(89509).Buffer;function T(Z){if(Z.length>=255)throw new TypeError("Alphabet too long");for(var S=new Uint8Array(256),B=0;B<S.length;B++)S[B]=255;for(var X=0;X<Z.length;X++){var H=Z.charAt(X),R=H.charCodeAt(0);if(S[R]!==255)throw new TypeError(H+" is ambiguous");S[R]=X}var j=Z.length,me=Z.charAt(0),se=Math.log(j)/Math.log(256),_=Math.log(256)/Math.log(j);function re(Q){if((Array.isArray(Q)||Q instanceof Uint8Array)&&(Q=h.from(Q)),!h.isBuffer(Q))throw new TypeError("Expected Buffer");if(Q.length===0)return"";for(var Y=0,te=0,ye=0,Ne=Q.length;ye!==Ne&&Q[ye]===0;)ye++,Y++;for(var ee=(Ne-ye)*_+1>>>0,we=new Uint8Array(ee);ye!==Ne;){for(var He=Q[ye],ue=0,Ae=ee-1;(He!==0||ue<te)&&Ae!==-1;Ae--,ue++)He+=256*we[Ae]>>>0,we[Ae]=He%j>>>0,He=He/j>>>0;if(He!==0)throw new Error("Non-zero carry");te=ue,ye++}for(var xe=ee-te;xe!==ee&&we[xe]===0;)xe++;for(var J=me.repeat(Y);xe<ee;++xe)J+=Z.charAt(we[xe]);return J}function D(Q){if(typeof Q!="string")throw new TypeError("Expected String");if(Q.length===0)return h.alloc(0);for(var Y=0,te=0,ye=0;Q[Y]===me;)te++,Y++;for(var Ne=(Q.length-Y)*se+1>>>0,ee=new Uint8Array(Ne);Q[Y];){var we=S[Q.charCodeAt(Y)];if(we===255)return;for(var He=0,ue=Ne-1;(we!==0||He<ye)&&ue!==-1;ue--,He++)we+=j*ee[ue]>>>0,ee[ue]=we%256>>>0,we=we/256>>>0;if(we!==0)throw new Error("Non-zero carry");ye=He,Y++}for(var Ae=Ne-ye;Ae!==Ne&&ee[Ae]===0;)Ae++;var xe=h.allocUnsafe(te+(Ne-Ae));xe.fill(0,0,te);for(var J=te;Ae!==Ne;)xe[J++]=ee[Ae++];return xe}function fe(Q){var Y=D(Q);if(Y)return Y;throw new Error("Non-base"+j+" character")}return{encode:re,decodeUnsafe:D,decode:fe}}ne.exports=T},40475:function(ne,$,A){"use strict";var h,T=A(48764).Buffer;h={value:!0};let Z;function S(R){{const j=T.from(R);j.reverse();const me=j.toString("hex");return me.length===0?BigInt(0):BigInt(`0x${me}`)}return Z.toBigInt(R,!1)}$.oU=S;function B(R){{const j=R.toString("hex");return j.length===0?BigInt(0):BigInt(`0x${j}`)}return Z.toBigInt(R,!0)}$.Q5=B;function X(R,j){{const me=R.toString(16),se=T.from(me.padStart(j*2,"0").slice(0,j*2),"hex");return se.reverse(),se}return Z.fromBigInt(R,T.allocUnsafe(j),!1)}$.k$=X;function H(R,j){{const me=R.toString(16);return T.from(me.padStart(j*2,"0").slice(0,j*2),"hex")}return Z.fromBigInt(R,T.allocUnsafe(j),!0)}$.zP=H},25532:function(ne,$,A){"use strict";var h=A(48764).Buffer,T=this&&this.__createBinding||(Object.create?function(J,z,ie,oe){oe===void 0&&(oe=ie),Object.defineProperty(J,oe,{enumerable:!0,get:function(){return z[ie]}})}:function(J,z,ie,oe){oe===void 0&&(oe=ie),J[oe]=z[ie]}),Z=this&&this.__setModuleDefault||(Object.create?function(J,z){Object.defineProperty(J,"default",{enumerable:!0,value:z})}:function(J,z){J.default=z}),S=this&&this.__decorate||function(J,z,ie,oe){var ge=arguments.length,ke=ge<3?z:oe===null?oe=Object.getOwnPropertyDescriptor(z,ie):oe,Je;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")ke=Reflect.decorate(J,z,ie,oe);else for(var nt=J.length-1;nt>=0;nt--)(Je=J[nt])&&(ke=(ge<3?Je(ke):ge>3?Je(z,ie,ke):Je(z,ie))||ke);return ge>3&&ke&&Object.defineProperty(z,ie,ke),ke},B=this&&this.__importStar||function(J){if(J&&J.__esModule)return J;var z={};if(J!=null)for(var ie in J)ie!=="default"&&Object.hasOwnProperty.call(J,ie)&&T(z,J,ie);return Z(z,J),z},X=this&&this.__importDefault||function(J){return J&&J.__esModule?J:{default:J}};Object.defineProperty($,"__esModule",{value:!0}),$.deserializeUnchecked=$.deserialize=$.serialize=$.BinaryReader=$.BinaryWriter=$.BorshError=$.baseDecode=$.baseEncode=void 0;const H=X(A(13550)),R=X(A(77191)),j=B(A(11379)),me=typeof TextDecoder!="function"?j.TextDecoder:TextDecoder,se=new me("utf-8",{fatal:!0});function _(J){return typeof J=="string"&&(J=h.from(J,"utf8")),R.default.encode(h.from(J))}$.baseEncode=_;function re(J){return h.from(R.default.decode(J))}$.baseDecode=re;const D=1024;class fe extends Error{constructor(z){super(z),this.fieldPath=[],this.originalMessage=z}addToFieldPath(z){this.fieldPath.splice(0,0,z),this.message=this.originalMessage+": "+this.fieldPath.join(".")}}$.BorshError=fe;class Q{constructor(){this.buf=h.alloc(D),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=h.concat([this.buf,h.alloc(D)]))}writeU8(z){this.maybeResize(),this.buf.writeUInt8(z,this.length),this.length+=1}writeU16(z){this.maybeResize(),this.buf.writeUInt16LE(z,this.length),this.length+=2}writeU32(z){this.maybeResize(),this.buf.writeUInt32LE(z,this.length),this.length+=4}writeU64(z){this.maybeResize(),this.writeBuffer(h.from(new H.default(z).toArray("le",8)))}writeU128(z){this.maybeResize(),this.writeBuffer(h.from(new H.default(z).toArray("le",16)))}writeU256(z){this.maybeResize(),this.writeBuffer(h.from(new H.default(z).toArray("le",32)))}writeU512(z){this.maybeResize(),this.writeBuffer(h.from(new H.default(z).toArray("le",64)))}writeBuffer(z){this.buf=h.concat([h.from(this.buf.subarray(0,this.length)),z,h.alloc(D)]),this.length+=z.length}writeString(z){this.maybeResize();const ie=h.from(z,"utf8");this.writeU32(ie.length),this.writeBuffer(ie)}writeFixedArray(z){this.writeBuffer(h.from(z))}writeArray(z,ie){this.maybeResize(),this.writeU32(z.length);for(const oe of z)this.maybeResize(),ie(oe)}toArray(){return this.buf.subarray(0,this.length)}}$.BinaryWriter=Q;function Y(J,z,ie){const oe=ie.value;ie.value=function(...ge){try{return oe.apply(this,ge)}catch(ke){if(ke instanceof RangeError){const Je=ke.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(Je)>=0)throw new fe("Reached the end of buffer when deserializing")}throw ke}}}class te{constructor(z){this.buf=z,this.offset=0}readU8(){const z=this.buf.readUInt8(this.offset);return this.offset+=1,z}readU16(){const z=this.buf.readUInt16LE(this.offset);return this.offset+=2,z}readU32(){const z=this.buf.readUInt32LE(this.offset);return this.offset+=4,z}readU64(){const z=this.readBuffer(8);return new H.default(z,"le")}readU128(){const z=this.readBuffer(16);return new H.default(z,"le")}readU256(){const z=this.readBuffer(32);return new H.default(z,"le")}readU512(){const z=this.readBuffer(64);return new H.default(z,"le")}readBuffer(z){if(this.offset+z>this.buf.length)throw new fe(`Expected buffer length ${z} isn't within bounds`);const ie=this.buf.slice(this.offset,this.offset+z);return this.offset+=z,ie}readString(){const z=this.readU32(),ie=this.readBuffer(z);try{return se.decode(ie)}catch(oe){throw new fe(`Error decoding UTF-8 string: ${oe}`)}}readFixedArray(z){return new Uint8Array(this.readBuffer(z))}readArray(z){const ie=this.readU32(),oe=Array();for(let ge=0;ge<ie;++ge)oe.push(z());return oe}}S([Y],te.prototype,"readU8",null),S([Y],te.prototype,"readU16",null),S([Y],te.prototype,"readU32",null),S([Y],te.prototype,"readU64",null),S([Y],te.prototype,"readU128",null),S([Y],te.prototype,"readU256",null),S([Y],te.prototype,"readU512",null),S([Y],te.prototype,"readString",null),S([Y],te.prototype,"readFixedArray",null),S([Y],te.prototype,"readArray",null),$.BinaryReader=te;function ye(J){return J.charAt(0).toUpperCase()+J.slice(1)}function Ne(J,z,ie,oe,ge){try{if(typeof oe=="string")ge[`write${ye(oe)}`](ie);else if(oe instanceof Array)if(typeof oe[0]=="number"){if(ie.length!==oe[0])throw new fe(`Expecting byte array of length ${oe[0]}, but got ${ie.length} bytes`);ge.writeFixedArray(ie)}else if(oe.length===2&&typeof oe[1]=="number"){if(ie.length!==oe[1])throw new fe(`Expecting byte array of length ${oe[1]}, but got ${ie.length} bytes`);for(let ke=0;ke<oe[1];ke++)Ne(J,null,ie[ke],oe[0],ge)}else ge.writeArray(ie,ke=>{Ne(J,z,ke,oe[0],ge)});else if(oe.kind!==void 0)switch(oe.kind){case"option":{ie==null?ge.writeU8(0):(ge.writeU8(1),Ne(J,z,ie,oe.type,ge));break}case"map":{ge.writeU32(ie.size),ie.forEach((ke,Je)=>{Ne(J,z,Je,oe.key,ge),Ne(J,z,ke,oe.value,ge)});break}default:throw new fe(`FieldType ${oe} unrecognized`)}else ee(J,ie,ge)}catch(ke){throw ke instanceof fe&&ke.addToFieldPath(z),ke}}function ee(J,z,ie){if(typeof z.borshSerialize=="function"){z.borshSerialize(ie);return}const oe=J.get(z.constructor);if(!oe)throw new fe(`Class ${z.constructor.name} is missing in schema`);if(oe.kind==="struct")oe.fields.map(([ge,ke])=>{Ne(J,ge,z[ge],ke,ie)});else if(oe.kind==="enum"){const ge=z[oe.field];for(let ke=0;ke<oe.values.length;++ke){const[Je,nt]=oe.values[ke];if(Je===ge){ie.writeU8(ke),Ne(J,Je,z[Je],nt,ie);break}}}else throw new fe(`Unexpected schema kind: ${oe.kind} for ${z.constructor.name}`)}function we(J,z,ie=Q){const oe=new ie;return ee(J,z,oe),oe.toArray()}$.serialize=we;function He(J,z,ie,oe){try{if(typeof ie=="string")return oe[`read${ye(ie)}`]();if(ie instanceof Array){if(typeof ie[0]=="number")return oe.readFixedArray(ie[0]);if(typeof ie[1]=="number"){const ge=[];for(let ke=0;ke<ie[1];ke++)ge.push(He(J,null,ie[0],oe));return ge}else return oe.readArray(()=>He(J,z,ie[0],oe))}if(ie.kind==="option")return oe.readU8()?He(J,z,ie.type,oe):void 0;if(ie.kind==="map"){let ge=new Map;const ke=oe.readU32();for(let Je=0;Je<ke;Je++){const nt=He(J,z,ie.key,oe),be=He(J,z,ie.value,oe);ge.set(nt,be)}return ge}return ue(J,ie,oe)}catch(ge){throw ge instanceof fe&&ge.addToFieldPath(z),ge}}function ue(J,z,ie){if(typeof z.borshDeserialize=="function")return z.borshDeserialize(ie);const oe=J.get(z);if(!oe)throw new fe(`Class ${z.name} is missing in schema`);if(oe.kind==="struct"){const ge={};for(const[ke,Je]of J.get(z).fields)ge[ke]=He(J,ke,Je,ie);return new z(ge)}if(oe.kind==="enum"){const ge=ie.readU8();if(ge>=oe.values.length)throw new fe(`Enum index: ${ge} is out of range`);const[ke,Je]=oe.values[ge],nt=He(J,ke,Je,ie);return new z({[ke]:nt})}throw new fe(`Unexpected schema kind: ${oe.kind} for ${z.constructor.name}`)}function Ae(J,z,ie,oe=te){const ge=new oe(ie),ke=ue(J,z,ge);if(ge.offset<ie.length)throw new fe(`Unexpected ${ie.length-ge.offset} bytes after deserialized data`);return ke}$.deserialize=Ae;function xe(J,z,ie,oe=te){const ge=new oe(ie);return ue(J,z,ge)}$.deserializeUnchecked=xe},77191:function(ne,$,A){var h=A(58162),T="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";ne.exports=h(T)},58355:function(ne,$,A){"use strict";var h=A(35717),T=A(51031),Z=A(71027),S=A(89509).Buffer,B=A(78028),X=A(79785),H=A(89072),R=S.alloc(128);function j(me,se){Z.call(this,"digest"),typeof se=="string"&&(se=S.from(se));var _=me==="sha512"||me==="sha384"?128:64;if(this._alg=me,this._key=se,se.length>_){var re=me==="rmd160"?new X:H(me);se=re.update(se).digest()}else se.length<_&&(se=S.concat([se,R],_));for(var D=this._ipad=S.allocUnsafe(_),fe=this._opad=S.allocUnsafe(_),Q=0;Q<_;Q++)D[Q]=se[Q]^54,fe[Q]=se[Q]^92;this._hash=me==="rmd160"?new X:H(me),this._hash.update(D)}h(j,Z),j.prototype._update=function(me){this._hash.update(me)},j.prototype._final=function(){var me=this._hash.digest(),se=this._alg==="rmd160"?new X:H(this._alg);return se.update(this._opad).update(me).digest()},ne.exports=function(se,_){return se=se.toLowerCase(),se==="rmd160"||se==="ripemd160"?new j("rmd160",_):se==="md5"?new T(B,_):new j(se,_)}},51031:function(ne,$,A){"use strict";var h=A(35717),T=A(89509).Buffer,Z=A(71027),S=T.alloc(128),B=64;function X(H,R){Z.call(this,"digest"),typeof R=="string"&&(R=T.from(R)),this._alg=H,this._key=R,R.length>B?R=H(R):R.length<B&&(R=T.concat([R,S],B));for(var j=this._ipad=T.allocUnsafe(B),me=this._opad=T.allocUnsafe(B),se=0;se<B;se++)j[se]=R[se]^54,me[se]=R[se]^92;this._hash=[j]}h(X,Z),X.prototype._update=function(H){this._hash.push(H)},X.prototype._final=function(){var H=this._alg(T.concat(this._hash));return this._alg(T.concat([this._opad,H]))},ne.exports=X},62678:function(ne,$,A){"use strict";var h=A(48764).Buffer;Object.defineProperty($,"__esModule",{value:!0}),$.derivePath=$.isValidPath=$.getPublicKey=$.CKDPriv=$.getMasterKeyFromSeed=void 0;const T=A(58355),Z=A(50780),S=A(91110),B="ed25519 seed",X=2147483648;$.getMasterKeyFromSeed=H=>{const j=T("sha512",B).update(h.from(H,"hex")).digest(),me=j.slice(0,32),se=j.slice(32);return{key:me,chainCode:se}},$.CKDPriv=({key:H,chainCode:R},j)=>{const me=h.allocUnsafe(4);me.writeUInt32BE(j,0);const se=h.concat([h.alloc(1,0),H,me]),_=T("sha512",R).update(se).digest(),re=_.slice(0,32),D=_.slice(32);return{key:re,chainCode:D}},$.getPublicKey=(H,R=!0)=>{const me=Z.sign.keyPair.fromSeed(H).secretKey.subarray(32),se=h.alloc(1,0);return R?h.concat([se,h.from(me)]):h.from(me)},$.isValidPath=H=>S.pathRegex.test(H)?!H.split("/").slice(1).map(S.replaceDerive).some(isNaN):!1,$.derivePath=(H,R,j=X)=>{if(!$.isValidPath(H))throw new Error("Invalid derivation path");const{key:me,chainCode:se}=$.getMasterKeyFromSeed(R);return H.split("/").slice(1).map(S.replaceDerive).map(re=>parseInt(re,10)).reduce((re,D)=>$.CKDPriv(re,D+j),{key:me,chainCode:se})}},91110:function(ne,$){"use strict";Object.defineProperty($,"__esModule",{value:!0}),$.replaceDerive=$.pathRegex=void 0,$.pathRegex=new RegExp("^m(\\/[0-9]+')+$"),$.replaceDerive=A=>A.replace("'","")},26729:function(ne){"use strict";var $=Object.prototype.hasOwnProperty,A="~";function h(){}Object.create&&(h.prototype=Object.create(null),new h().__proto__||(A=!1));function T(X,H,R){this.fn=X,this.context=H,this.once=R||!1}function Z(X,H,R,j,me){if(typeof R!="function")throw new TypeError("The listener must be a function");var se=new T(R,j||X,me),_=A?A+H:H;return X._events[_]?X._events[_].fn?X._events[_]=[X._events[_],se]:X._events[_].push(se):(X._events[_]=se,X._eventsCount++),X}function S(X,H){--X._eventsCount===0?X._events=new h:delete X._events[H]}function B(){this._events=new h,this._eventsCount=0}B.prototype.eventNames=function(){var H=[],R,j;if(this._eventsCount===0)return H;for(j in R=this._events)$.call(R,j)&&H.push(A?j.slice(1):j);return Object.getOwnPropertySymbols?H.concat(Object.getOwnPropertySymbols(R)):H},B.prototype.listeners=function(H){var R=A?A+H:H,j=this._events[R];if(!j)return[];if(j.fn)return[j.fn];for(var me=0,se=j.length,_=new Array(se);me<se;me++)_[me]=j[me].fn;return _},B.prototype.listenerCount=function(H){var R=A?A+H:H,j=this._events[R];return j?j.fn?1:j.length:0},B.prototype.emit=function(H,R,j,me,se,_){var re=A?A+H:H;if(!this._events[re])return!1;var D=this._events[re],fe=arguments.length,Q,Y;if(D.fn){switch(D.once&&this.removeListener(H,D.fn,void 0,!0),fe){case 1:return D.fn.call(D.context),!0;case 2:return D.fn.call(D.context,R),!0;case 3:return D.fn.call(D.context,R,j),!0;case 4:return D.fn.call(D.context,R,j,me),!0;case 5:return D.fn.call(D.context,R,j,me,se),!0;case 6:return D.fn.call(D.context,R,j,me,se,_),!0}for(Y=1,Q=new Array(fe-1);Y<fe;Y++)Q[Y-1]=arguments[Y];D.fn.apply(D.context,Q)}else{var te=D.length,ye;for(Y=0;Y<te;Y++)switch(D[Y].once&&this.removeListener(H,D[Y].fn,void 0,!0),fe){case 1:D[Y].fn.call(D[Y].context);break;case 2:D[Y].fn.call(D[Y].context,R);break;case 3:D[Y].fn.call(D[Y].context,R,j);break;case 4:D[Y].fn.call(D[Y].context,R,j,me);break;default:if(!Q)for(ye=1,Q=new Array(fe-1);ye<fe;ye++)Q[ye-1]=arguments[ye];D[Y].fn.apply(D[Y].context,Q)}}return!0},B.prototype.on=function(H,R,j){return Z(this,H,R,j,!1)},B.prototype.once=function(H,R,j){return Z(this,H,R,j,!0)},B.prototype.removeListener=function(H,R,j,me){var se=A?A+H:H;if(!this._events[se])return this;if(!R)return S(this,se),this;var _=this._events[se];if(_.fn)_.fn===R&&(!me||_.once)&&(!j||_.context===j)&&S(this,se);else{for(var re=0,D=[],fe=_.length;re<fe;re++)(_[re].fn!==R||me&&!_[re].once||j&&_[re].context!==j)&&D.push(_[re]);D.length?this._events[se]=D.length===1?D[0]:D:S(this,se)}return this},B.prototype.removeAllListeners=function(H){var R;return H?(R=A?A+H:H,this._events[R]&&S(this,R)):(this._events=new h,this._eventsCount=0),this},B.prototype.off=B.prototype.removeListener,B.prototype.addListener=B.prototype.on,B.prefixed=A,B.EventEmitter=B,ne.exports=B},31198:function(ne,$,A){"use strict";const h=A(55877).v4,T=A(17741),Z=function(S,B){if(!(this instanceof Z))return new Z(S,B);B||(B={}),this.options={reviver:typeof B.reviver<"u"?B.reviver:null,replacer:typeof B.replacer<"u"?B.replacer:null,generator:typeof B.generator<"u"?B.generator:function(){return h()},version:typeof B.version<"u"?B.version:2,notificationIdNull:typeof B.notificationIdNull=="boolean"?B.notificationIdNull:!1},this.callServer=S};ne.exports=Z,Z.prototype.request=function(S,B,X,H){const R=this;let j=null;const me=Array.isArray(S)&&typeof B=="function";if(this.options.version===1&&me)throw new TypeError("JSON-RPC 1.0 does not support batching");if(me||!me&&S&&typeof S=="object"&&typeof B=="function")H=B,j=S;else{typeof X=="function"&&(H=X,X=void 0);const re=typeof H=="function";try{j=T(S,B,X,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(D){if(re)return H(D);throw D}if(!re)return j}let _;try{_=JSON.stringify(j,this.options.replacer)}catch(re){return H(re)}return this.callServer(_,function(re,D){R._parseResponse(re,D,H)}),j},Z.prototype._parseResponse=function(S,B,X){if(S){X(S);return}if(!B)return X();let H;try{H=JSON.parse(B,this.options.reviver)}catch(R){return X(R)}if(X.length===3)if(Array.isArray(H)){const R=function(me){return typeof me.error<"u"},j=function(me){return!R(me)};return X(null,H.filter(R),H.filter(j))}else return X(null,H.error,H.result);X(null,H)}},17741:function(ne,$,A){"use strict";const h=A(55877).v4,T=function(Z,S,B,X){if(typeof Z!="string")throw new TypeError(Z+" must be a string");X=X||{};const H=typeof X.version=="number"?X.version:2;if(H!==1&&H!==2)throw new TypeError(H+" must be 1 or 2");const R={method:Z};if(H===2&&(R.jsonrpc="2.0"),S){if(typeof S!="object"&&!Array.isArray(S))throw new TypeError(S+" must be an object, array or omitted");R.params=S}if(typeof B>"u"){const j=typeof X.generator=="function"?X.generator:function(){return h()};R.id=j(R,X)}else H===2&&B===null?X.notificationIdNull&&(R.id=null):R.id=B;return R};ne.exports=T},66855:function(ne,$,A){"use strict";var h,T=A(48764).Buffer,Z=A(64836);h={value:!0},$.Z=void 0;var S=Z(A(64687)),B=Z(A(17156)),X=Z(A(18698)),H=Z(A(56690)),R=Z(A(89728)),j=Z(A(61655)),me=Z(A(94993)),se=Z(A(73808)),_=A(26729),re=A(70395);function D(te){var ye=fe();return function(){var ee=(0,se.default)(te),we;if(ye){var He=(0,se.default)(this).constructor;we=Reflect.construct(ee,arguments,He)}else we=ee.apply(this,arguments);return(0,me.default)(this,we)}}function fe(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Q=function(te,ye){var Ne={};for(var ee in te)Object.prototype.hasOwnProperty.call(te,ee)&&ye.indexOf(ee)<0&&(Ne[ee]=te[ee]);if(te!=null&&typeof Object.getOwnPropertySymbols=="function")for(var we=0,ee=Object.getOwnPropertySymbols(te);we<ee.length;we++)ye.indexOf(ee[we])<0&&Object.prototype.propertyIsEnumerable.call(te,ee[we])&&(Ne[ee[we]]=te[ee[we]]);return Ne},Y=function(te){(0,j.default)(Ne,te);var ye=D(Ne);function Ne(ee){var we,He=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"ws://localhost:8080",ue=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},Ae=arguments.length>3?arguments[3]:void 0,xe=arguments.length>4?arguments[4]:void 0;(0,H.default)(this,Ne);var J=ue.autoconnect,z=J===void 0?!0:J,ie=ue.reconnect,oe=ie===void 0?!0:ie,ge=ue.reconnect_interval,ke=ge===void 0?1e3:ge,Je=ue.max_reconnects,nt=Je===void 0?5:Je,be=Q(ue,["autoconnect","reconnect","reconnect_interval","max_reconnects"]);return we=ye.call(this),we.webSocketFactory=ee,we.queue={},we.rpc_id=0,we.address=He,we.autoconnect=z,we.ready=!1,we.reconnect=oe,we.reconnect_timer_id=void 0,we.reconnect_interval=ke,we.max_reconnects=nt,we.rest_options=be,we.current_reconnects=0,we.generate_request_id=Ae||function(){return++we.rpc_id},xe?we.dataPack=xe:we.dataPack=new re.DefaultDataPack,we.autoconnect&&we._connect(we.address,Object.assign({autoconnect:we.autoconnect,reconnect:we.reconnect,reconnect_interval:we.reconnect_interval,max_reconnects:we.max_reconnects},we.rest_options)),we}return(0,R.default)(Ne,[{key:"connect",value:function(){this.socket||this._connect(this.address,Object.assign({autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects},this.rest_options))}},{key:"call",value:function(we,He,ue,Ae){var xe=this;return!Ae&&(0,X.default)(ue)==="object"&&(Ae=ue,ue=null),new Promise(function(J,z){if(!xe.ready)return z(new Error("socket not ready"));var ie=xe.generate_request_id(we,He),oe={jsonrpc:"2.0",method:we,params:He||void 0,id:ie};xe.socket.send(xe.dataPack.encode(oe),Ae,function(ge){if(ge)return z(ge);xe.queue[ie]={promise:[J,z]},ue&&(xe.queue[ie].timeout=setTimeout(function(){delete xe.queue[ie],z(new Error("reply timeout"))},ue))})})}},{key:"login",value:function(){var ee=(0,B.default)(S.default.mark(function He(ue){var Ae;return S.default.wrap(function(J){for(;;)switch(J.prev=J.next){case 0:return J.next=2,this.call("rpc.login",ue);case 2:if(Ae=J.sent,Ae){J.next=5;break}throw new Error("authentication failed");case 5:return J.abrupt("return",Ae);case 6:case"end":return J.stop()}},He,this)}));function we(He){return ee.apply(this,arguments)}return we}()},{key:"listMethods",value:function(){var ee=(0,B.default)(S.default.mark(function He(){return S.default.wrap(function(Ae){for(;;)switch(Ae.prev=Ae.next){case 0:return Ae.next=2,this.call("__listMethods");case 2:return Ae.abrupt("return",Ae.sent);case 3:case"end":return Ae.stop()}},He,this)}));function we(){return ee.apply(this,arguments)}return we}()},{key:"notify",value:function(we,He){var ue=this;return new Promise(function(Ae,xe){if(!ue.ready)return xe(new Error("socket not ready"));var J={jsonrpc:"2.0",method:we,params:He};ue.socket.send(ue.dataPack.encode(J),function(z){if(z)return xe(z);Ae()})})}},{key:"subscribe",value:function(){var ee=(0,B.default)(S.default.mark(function He(ue){var Ae;return S.default.wrap(function(J){for(;;)switch(J.prev=J.next){case 0:return typeof ue=="string"&&(ue=[ue]),J.next=3,this.call("rpc.on",ue);case 3:if(Ae=J.sent,!(typeof ue=="string"&&Ae[ue]!=="ok")){J.next=6;break}throw new Error("Failed subscribing to an event '"+ue+"' with: "+Ae[ue]);case 6:return J.abrupt("return",Ae);case 7:case"end":return J.stop()}},He,this)}));function we(He){return ee.apply(this,arguments)}return we}()},{key:"unsubscribe",value:function(){var ee=(0,B.default)(S.default.mark(function He(ue){var Ae;return S.default.wrap(function(J){for(;;)switch(J.prev=J.next){case 0:return typeof ue=="string"&&(ue=[ue]),J.next=3,this.call("rpc.off",ue);case 3:if(Ae=J.sent,!(typeof ue=="string"&&Ae[ue]!=="ok")){J.next=6;break}throw new Error("Failed unsubscribing from an event with: "+Ae);case 6:return J.abrupt("return",Ae);case 7:case"end":return J.stop()}},He,this)}));function we(He){return ee.apply(this,arguments)}return we}()},{key:"close",value:function(we,He){this.socket.close(we||1e3,He)}},{key:"_connect",value:function(we,He){var ue=this;clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(we,He),this.socket.addEventListener("open",function(){ue.ready=!0,ue.emit("open"),ue.current_reconnects=0}),this.socket.addEventListener("message",function(Ae){var xe=Ae.data;xe instanceof ArrayBuffer&&(xe=T.from(xe).toString());try{xe=ue.dataPack.decode(xe)}catch{return}if(xe.notification&&ue.listeners(xe.notification).length){if(!Object.keys(xe.params).length)return ue.emit(xe.notification);var J=[xe.notification];if(xe.params.constructor===Object)J.push(xe.params);else for(var z=0;z<xe.params.length;z++)J.push(xe.params[z]);return Promise.resolve().then(function(){ue.emit.apply(ue,J)})}if(!ue.queue[xe.id])return xe.method&&xe.params?Promise.resolve().then(function(){ue.emit(xe.method,xe.params)}):void 0;"error"in xe=="result"in xe&&ue.queue[xe.id].promise[1](new Error('Server response malformed. Response must include either "result" or "error", but not both.')),ue.queue[xe.id].timeout&&clearTimeout(ue.queue[xe.id].timeout),xe.error?ue.queue[xe.id].promise[1](xe.error):ue.queue[xe.id].promise[0](xe.result),delete ue.queue[xe.id]}),this.socket.addEventListener("error",function(Ae){return ue.emit("error",Ae)}),this.socket.addEventListener("close",function(Ae){var xe=Ae.code,J=Ae.reason;ue.ready&&setTimeout(function(){return ue.emit("close",xe,J)},0),ue.ready=!1,ue.socket=void 0,xe!==1e3&&(ue.current_reconnects++,ue.reconnect&&(ue.max_reconnects>ue.current_reconnects||ue.max_reconnects===0)&&(ue.reconnect_timer_id=setTimeout(function(){return ue._connect(we,He)},ue.reconnect_interval)))})}}]),Ne}(_.EventEmitter);$.Z=Y},89062:function(ne,$,A){"use strict";var h,T=A(64836);h={value:!0},$.Z=_;var Z=T(A(56690)),S=T(A(89728)),B=T(A(61655)),X=T(A(94993)),H=T(A(73808)),R=A(26729);function j(re){var D=me();return function(){var Q=(0,H.default)(re),Y;if(D){var te=(0,H.default)(this).constructor;Y=Reflect.construct(Q,arguments,te)}else Y=Q.apply(this,arguments);return(0,X.default)(this,Y)}}function me(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var se=function(re){(0,B.default)(fe,re);var D=j(fe);function fe(Q,Y,te){var ye;return(0,Z.default)(this,fe),ye=D.call(this),ye.socket=new window.WebSocket(Q,te),ye.socket.onopen=function(){return ye.emit("open")},ye.socket.onmessage=function(Ne){return ye.emit("message",Ne.data)},ye.socket.onerror=function(Ne){return ye.emit("error",Ne)},ye.socket.onclose=function(Ne){ye.emit("close",Ne.code,Ne.reason)},ye}return(0,S.default)(fe,[{key:"send",value:function(Y,te,ye){var Ne=ye||te;try{this.socket.send(Y),Ne()}catch(ee){Ne(ee)}}},{key:"close",value:function(Y,te){this.socket.close(Y,te)}},{key:"addEventListener",value:function(Y,te,ye){this.socket.addEventListener(Y,te,ye)}}]),fe}(R.EventEmitter);function _(re,D){return new se(re,D)}},70395:function(ne,$,A){"use strict";var h=A(64836);Object.defineProperty($,"__esModule",{value:!0}),$.DefaultDataPack=void 0,$.createError=X;var T=h(A(56690)),Z=h(A(89728)),S=new Map([[-32e3,"Event not provided"],[-32600,"Invalid Request"],[-32601,"Method not found"],[-32602,"Invalid params"],[-32603,"Internal error"],[-32604,"Params not found"],[-32605,"Method forbidden"],[-32606,"Event forbidden"],[-32700,"Parse error"]]),B=function(){function H(){(0,T.default)(this,H)}return(0,Z.default)(H,[{key:"encode",value:function(j){return JSON.stringify(j)}},{key:"decode",value:function(j){return JSON.parse(j)}}]),H}();$.DefaultDataPack=B;function X(H,R){var j={code:H,message:S.get(H)||"Internal Server Error"};return R&&(j.data=R),j}},11379:function(ne,$){"use strict";function A(re,D,fe){return D<=re&&re<=fe}function h(re){if(re===void 0)return{};if(re===Object(re))return re;throw TypeError("Could not convert argument to dictionary")}function T(re){for(var D=String(re),fe=D.length,Q=0,Y=[];Q<fe;){var te=D.charCodeAt(Q);if(te<55296||te>57343)Y.push(te);else if(56320<=te&&te<=57343)Y.push(65533);else if(55296<=te&&te<=56319)if(Q===fe-1)Y.push(65533);else{var ye=re.charCodeAt(Q+1);if(56320<=ye&&ye<=57343){var Ne=te&1023,ee=ye&1023;Y.push(65536+(Ne<<10)+ee),Q+=1}else Y.push(65533)}Q+=1}return Y}function Z(re){for(var D="",fe=0;fe<re.length;++fe){var Q=re[fe];Q<=65535?D+=String.fromCharCode(Q):(Q-=65536,D+=String.fromCharCode((Q>>10)+55296,(Q&1023)+56320))}return D}var S=-1;function B(re){this.tokens=[].slice.call(re)}B.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():S},prepend:function(re){if(Array.isArray(re))for(var D=re;D.length;)this.tokens.unshift(D.pop());else this.tokens.unshift(re)},push:function(re){if(Array.isArray(re))for(var D=re;D.length;)this.tokens.push(D.shift());else this.tokens.push(re)}};var X=-1;function H(re,D){if(re)throw TypeError("Decoder error");return D||65533}var R="utf-8";function j(re,D){if(!(this instanceof j))return new j(re,D);if(re=re!==void 0?String(re).toLowerCase():R,re!==R)throw new Error("Encoding not supported. Only utf-8 is supported");D=h(D),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=Boolean(D.fatal),this._ignoreBOM=Boolean(D.ignoreBOM),Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}j.prototype={decode:function(D,fe){var Q;typeof D=="object"&&D instanceof ArrayBuffer?Q=new Uint8Array(D):typeof D=="object"&&"buffer"in D&&D.buffer instanceof ArrayBuffer?Q=new Uint8Array(D.buffer,D.byteOffset,D.byteLength):Q=new Uint8Array(0),fe=h(fe),this._streaming||(this._decoder=new se({fatal:this._fatal}),this._BOMseen=!1),this._streaming=Boolean(fe.stream);for(var Y=new B(Q),te=[],ye;!Y.endOfStream()&&(ye=this._decoder.handler(Y,Y.read()),ye!==X);)ye!==null&&(Array.isArray(ye)?te.push.apply(te,ye):te.push(ye));if(!this._streaming){do{if(ye=this._decoder.handler(Y,Y.read()),ye===X)break;ye!==null&&(Array.isArray(ye)?te.push.apply(te,ye):te.push(ye))}while(!Y.endOfStream());this._decoder=null}return te.length&&["utf-8"].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(te[0]===65279?(this._BOMseen=!0,te.shift()):this._BOMseen=!0),Z(te)}};function me(re,D){if(!(this instanceof me))return new me(re,D);if(re=re!==void 0?String(re).toLowerCase():R,re!==R)throw new Error("Encoding not supported. Only utf-8 is supported");D=h(D),this._streaming=!1,this._encoder=null,this._options={fatal:Boolean(D.fatal)},Object.defineProperty(this,"encoding",{value:"utf-8"})}me.prototype={encode:function(D,fe){D=D?String(D):"",fe=h(fe),this._streaming||(this._encoder=new _(this._options)),this._streaming=Boolean(fe.stream);for(var Q=[],Y=new B(T(D)),te;!Y.endOfStream()&&(te=this._encoder.handler(Y,Y.read()),te!==X);)Array.isArray(te)?Q.push.apply(Q,te):Q.push(te);if(!this._streaming){for(;te=this._encoder.handler(Y,Y.read()),te!==X;)Array.isArray(te)?Q.push.apply(Q,te):Q.push(te);this._encoder=null}return new Uint8Array(Q)}};function se(re){var D=re.fatal,fe=0,Q=0,Y=0,te=128,ye=191;this.handler=function(Ne,ee){if(ee===S&&Y!==0)return Y=0,H(D);if(ee===S)return X;if(Y===0){if(A(ee,0,127))return ee;if(A(ee,194,223))Y=1,fe=ee-192;else if(A(ee,224,239))ee===224&&(te=160),ee===237&&(ye=159),Y=2,fe=ee-224;else if(A(ee,240,244))ee===240&&(te=144),ee===244&&(ye=143),Y=3,fe=ee-240;else return H(D);return fe=fe<<6*Y,null}if(!A(ee,te,ye))return fe=Y=Q=0,te=128,ye=191,Ne.prepend(ee),H(D);if(te=128,ye=191,Q+=1,fe+=ee-128<<6*(Y-Q),Q!==Y)return null;var we=fe;return fe=Y=Q=0,we}}function _(re){var D=re.fatal;this.handler=function(fe,Q){if(Q===S)return X;if(A(Q,0,127))return Q;var Y,te;A(Q,128,2047)?(Y=1,te=192):A(Q,2048,65535)?(Y=2,te=224):A(Q,65536,1114111)&&(Y=3,te=240);for(var ye=[(Q>>6*Y)+te];Y>0;){var Ne=Q>>6*(Y-1);ye.push(128|Ne&63),Y-=1}return ye}}$.TextEncoder=me,$.TextDecoder=j},55877:function(ne,$,A){var h=A(23570),T=A(71171),Z=T;Z.v1=h,Z.v4=T,ne.exports=Z},45327:function(ne){for(var $=[],A=0;A<256;++A)$[A]=(A+256).toString(16).substr(1);function h(T,Z){var S=Z||0,B=$;return[B[T[S++]],B[T[S++]],B[T[S++]],B[T[S++]],"-",B[T[S++]],B[T[S++]],"-",B[T[S++]],B[T[S++]],"-",B[T[S++]],B[T[S++]],"-",B[T[S++]],B[T[S++]],B[T[S++]],B[T[S++]],B[T[S++]],B[T[S++]]].join("")}ne.exports=h},85217:function(ne){var $=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof window.msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto);if($){var A=new Uint8Array(16);ne.exports=function(){return $(A),A}}else{var h=new Array(16);ne.exports=function(){for(var Z=0,S;Z<16;Z++)(Z&3)===0&&(S=Math.random()*4294967296),h[Z]=S>>>((Z&3)<<3)&255;return h}}},23570:function(ne,$,A){var h=A(85217),T=A(45327),Z,S,B=0,X=0;function H(R,j,me){var se=j&&me||0,_=j||[];R=R||{};var re=R.node||Z,D=R.clockseq!==void 0?R.clockseq:S;if(re==null||D==null){var fe=h();re==null&&(re=Z=[fe[0]|1,fe[1],fe[2],fe[3],fe[4],fe[5]]),D==null&&(D=S=(fe[6]<<8|fe[7])&16383)}var Q=R.msecs!==void 0?R.msecs:new Date().getTime(),Y=R.nsecs!==void 0?R.nsecs:X+1,te=Q-B+(Y-X)/1e4;if(te<0&&R.clockseq===void 0&&(D=D+1&16383),(te<0||Q>B)&&R.nsecs===void 0&&(Y=0),Y>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");B=Q,X=Y,S=D,Q+=122192928e5;var ye=((Q&268435455)*1e4+Y)%4294967296;_[se++]=ye>>>24&255,_[se++]=ye>>>16&255,_[se++]=ye>>>8&255,_[se++]=ye&255;var Ne=Q/4294967296*1e4&268435455;_[se++]=Ne>>>8&255,_[se++]=Ne&255,_[se++]=Ne>>>24&15|16,_[se++]=Ne>>>16&255,_[se++]=D>>>8|128,_[se++]=D&255;for(var ee=0;ee<6;++ee)_[se+ee]=re[ee];return j||T(_)}ne.exports=H},71171:function(ne,$,A){var h=A(85217),T=A(45327);function Z(S,B,X){var H=B&&X||0;typeof S=="string"&&(B=S==="binary"?new Array(16):null,S=null),S=S||{};var R=S.random||(S.rng||h)();if(R[6]=R[6]&15|64,R[8]=R[8]&63|128,B)for(var j=0;j<16;++j)B[H+j]=R[j];return B||T(R)}ne.exports=Z},66115:function(ne){function $(A){if(A===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return A}ne.exports=$,ne.exports.__esModule=!0,ne.exports.default=ne.exports},17156:function(ne){function $(h,T,Z,S,B,X,H){try{var R=h[X](H),j=R.value}catch(me){Z(me);return}R.done?T(j):Promise.resolve(j).then(S,B)}function A(h){return function(){var T=this,Z=arguments;return new Promise(function(S,B){var X=h.apply(T,Z);function H(j){$(X,S,B,H,R,"next",j)}function R(j){$(X,S,B,H,R,"throw",j)}H(void 0)})}}ne.exports=A,ne.exports.__esModule=!0,ne.exports.default=ne.exports},56690:function(ne){function $(A,h){if(!(A instanceof h))throw new TypeError("Cannot call a class as a function")}ne.exports=$,ne.exports.__esModule=!0,ne.exports.default=ne.exports},89728:function(ne,$,A){var h=A(64062);function T(S,B){for(var X=0;X<B.length;X++){var H=B[X];H.enumerable=H.enumerable||!1,H.configurable=!0,"value"in H&&(H.writable=!0),Object.defineProperty(S,h(H.key),H)}}function Z(S,B,X){return B&&T(S.prototype,B),X&&T(S,X),Object.defineProperty(S,"prototype",{writable:!1}),S}ne.exports=Z,ne.exports.__esModule=!0,ne.exports.default=ne.exports},73808:function(ne){function $(A){return ne.exports=$=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(T){return T.__proto__||Object.getPrototypeOf(T)},ne.exports.__esModule=!0,ne.exports.default=ne.exports,$(A)}ne.exports=$,ne.exports.__esModule=!0,ne.exports.default=ne.exports},61655:function(ne,$,A){var h=A(6015);function T(Z,S){if(typeof S!="function"&&S!==null)throw new TypeError("Super expression must either be null or a function");Z.prototype=Object.create(S&&S.prototype,{constructor:{value:Z,writable:!0,configurable:!0}}),Object.defineProperty(Z,"prototype",{writable:!1}),S&&h(Z,S)}ne.exports=T,ne.exports.__esModule=!0,ne.exports.default=ne.exports},64836:function(ne){function $(A){return A&&A.__esModule?A:{default:A}}ne.exports=$,ne.exports.__esModule=!0,ne.exports.default=ne.exports},94993:function(ne,$,A){var h=A(18698).default,T=A(66115);function Z(S,B){if(B&&(h(B)==="object"||typeof B=="function"))return B;if(B!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return T(S)}ne.exports=Z,ne.exports.__esModule=!0,ne.exports.default=ne.exports},17061:function(ne,$,A){var h=A(18698).default;function T(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ne.exports=T=function(){return S},ne.exports.__esModule=!0,ne.exports.default=ne.exports;var Z,S={},B=Object.prototype,X=B.hasOwnProperty,H=Object.defineProperty||function(be,ce,Se){be[ce]=Se.value},R=typeof Symbol=="function"?Symbol:{},j=R.iterator||"@@iterator",me=R.asyncIterator||"@@asyncIterator",se=R.toStringTag||"@@toStringTag";function _(be,ce,Se){return Object.defineProperty(be,ce,{value:Se,enumerable:!0,configurable:!0,writable:!0}),be[ce]}try{_({},"")}catch{_=function(Se,Ve,Xe){return Se[Ve]=Xe}}function re(be,ce,Se,Ve){var Xe=ce&&ce.prototype instanceof Ne?ce:Ne,x=Object.create(Xe.prototype),c=new Je(Ve||[]);return H(x,"_invoke",{value:ie(be,Se,c)}),x}function D(be,ce,Se){try{return{type:"normal",arg:be.call(ce,Se)}}catch(Ve){return{type:"throw",arg:Ve}}}S.wrap=re;var fe="suspendedStart",Q="suspendedYield",Y="executing",te="completed",ye={};function Ne(){}function ee(){}function we(){}var He={};_(He,j,function(){return this});var ue=Object.getPrototypeOf,Ae=ue&&ue(ue(nt([])));Ae&&Ae!==B&&X.call(Ae,j)&&(He=Ae);var xe=we.prototype=Ne.prototype=Object.create(He);function J(be){["next","throw","return"].forEach(function(ce){_(be,ce,function(Se){return this._invoke(ce,Se)})})}function z(be,ce){function Se(Xe,x,c,l){var y=D(be[Xe],be,x);if(y.type!=="throw"){var q=y.arg,E=q.value;return E&&h(E)=="object"&&X.call(E,"__await")?ce.resolve(E.__await).then(function(Ie){Se("next",Ie,c,l)},function(Ie){Se("throw",Ie,c,l)}):ce.resolve(E).then(function(Ie){q.value=Ie,c(q)},function(Ie){return Se("throw",Ie,c,l)})}l(y.arg)}var Ve;H(this,"_invoke",{value:function(x,c){function l(){return new ce(function(y,q){Se(x,c,y,q)})}return Ve=Ve?Ve.then(l,l):l()}})}function ie(be,ce,Se){var Ve=fe;return function(Xe,x){if(Ve===Y)throw new Error("Generator is already running");if(Ve===te){if(Xe==="throw")throw x;return{value:Z,done:!0}}for(Se.method=Xe,Se.arg=x;;){var c=Se.delegate;if(c){var l=oe(c,Se);if(l){if(l===ye)continue;return l}}if(Se.method==="next")Se.sent=Se._sent=Se.arg;else if(Se.method==="throw"){if(Ve===fe)throw Ve=te,Se.arg;Se.dispatchException(Se.arg)}else Se.method==="return"&&Se.abrupt("return",Se.arg);Ve=Y;var y=D(be,ce,Se);if(y.type==="normal"){if(Ve=Se.done?te:Q,y.arg===ye)continue;return{value:y.arg,done:Se.done}}y.type==="throw"&&(Ve=te,Se.method="throw",Se.arg=y.arg)}}}function oe(be,ce){var Se=ce.method,Ve=be.iterator[Se];if(Ve===Z)return ce.delegate=null,Se==="throw"&&be.iterator.return&&(ce.method="return",ce.arg=Z,oe(be,ce),ce.method==="throw")||Se!=="return"&&(ce.method="throw",ce.arg=new TypeError("The iterator does not provide a '"+Se+"' method")),ye;var Xe=D(Ve,be.iterator,ce.arg);if(Xe.type==="throw")return ce.method="throw",ce.arg=Xe.arg,ce.delegate=null,ye;var x=Xe.arg;return x?x.done?(ce[be.resultName]=x.value,ce.next=be.nextLoc,ce.method!=="return"&&(ce.method="next",ce.arg=Z),ce.delegate=null,ye):x:(ce.method="throw",ce.arg=new TypeError("iterator result is not an object"),ce.delegate=null,ye)}function ge(be){var ce={tryLoc:be[0]};1 in be&&(ce.catchLoc=be[1]),2 in be&&(ce.finallyLoc=be[2],ce.afterLoc=be[3]),this.tryEntries.push(ce)}function ke(be){var ce=be.completion||{};ce.type="normal",delete ce.arg,be.completion=ce}function Je(be){this.tryEntries=[{tryLoc:"root"}],be.forEach(ge,this),this.reset(!0)}function nt(be){if(be||be===""){var ce=be[j];if(ce)return ce.call(be);if(typeof be.next=="function")return be;if(!isNaN(be.length)){var Se=-1,Ve=function Xe(){for(;++Se<be.length;)if(X.call(be,Se))return Xe.value=be[Se],Xe.done=!1,Xe;return Xe.value=Z,Xe.done=!0,Xe};return Ve.next=Ve}}throw new TypeError(h(be)+" is not iterable")}return ee.prototype=we,H(xe,"constructor",{value:we,configurable:!0}),H(we,"constructor",{value:ee,configurable:!0}),ee.displayName=_(we,se,"GeneratorFunction"),S.isGeneratorFunction=function(be){var ce=typeof be=="function"&&be.constructor;return!!ce&&(ce===ee||(ce.displayName||ce.name)==="GeneratorFunction")},S.mark=function(be){return Object.setPrototypeOf?Object.setPrototypeOf(be,we):(be.__proto__=we,_(be,se,"GeneratorFunction")),be.prototype=Object.create(xe),be},S.awrap=function(be){return{__await:be}},J(z.prototype),_(z.prototype,me,function(){return this}),S.AsyncIterator=z,S.async=function(be,ce,Se,Ve,Xe){Xe===void 0&&(Xe=Promise);var x=new z(re(be,ce,Se,Ve),Xe);return S.isGeneratorFunction(ce)?x:x.next().then(function(c){return c.done?c.value:x.next()})},J(xe),_(xe,se,"Generator"),_(xe,j,function(){return this}),_(xe,"toString",function(){return"[object Generator]"}),S.keys=function(be){var ce=Object(be),Se=[];for(var Ve in ce)Se.push(Ve);return Se.reverse(),function Xe(){for(;Se.length;){var x=Se.pop();if(x in ce)return Xe.value=x,Xe.done=!1,Xe}return Xe.done=!0,Xe}},S.values=nt,Je.prototype={constructor:Je,reset:function(ce){if(this.prev=0,this.next=0,this.sent=this._sent=Z,this.done=!1,this.delegate=null,this.method="next",this.arg=Z,this.tryEntries.forEach(ke),!ce)for(var Se in this)Se.charAt(0)==="t"&&X.call(this,Se)&&!isNaN(+Se.slice(1))&&(this[Se]=Z)},stop:function(){this.done=!0;var ce=this.tryEntries[0].completion;if(ce.type==="throw")throw ce.arg;return this.rval},dispatchException:function(ce){if(this.done)throw ce;var Se=this;function Ve(q,E){return c.type="throw",c.arg=ce,Se.next=q,E&&(Se.method="next",Se.arg=Z),!!E}for(var Xe=this.tryEntries.length-1;Xe>=0;--Xe){var x=this.tryEntries[Xe],c=x.completion;if(x.tryLoc==="root")return Ve("end");if(x.tryLoc<=this.prev){var l=X.call(x,"catchLoc"),y=X.call(x,"finallyLoc");if(l&&y){if(this.prev<x.catchLoc)return Ve(x.catchLoc,!0);if(this.prev<x.finallyLoc)return Ve(x.finallyLoc)}else if(l){if(this.prev<x.catchLoc)return Ve(x.catchLoc,!0)}else{if(!y)throw new Error("try statement without catch or finally");if(this.prev<x.finallyLoc)return Ve(x.finallyLoc)}}}},abrupt:function(ce,Se){for(var Ve=this.tryEntries.length-1;Ve>=0;--Ve){var Xe=this.tryEntries[Ve];if(Xe.tryLoc<=this.prev&&X.call(Xe,"finallyLoc")&&this.prev<Xe.finallyLoc){var x=Xe;break}}x&&(ce==="break"||ce==="continue")&&x.tryLoc<=Se&&Se<=x.finallyLoc&&(x=null);var c=x?x.completion:{};return c.type=ce,c.arg=Se,x?(this.method="next",this.next=x.finallyLoc,ye):this.complete(c)},complete:function(ce,Se){if(ce.type==="throw")throw ce.arg;return ce.type==="break"||ce.type==="continue"?this.next=ce.arg:ce.type==="return"?(this.rval=this.arg=ce.arg,this.method="return",this.next="end"):ce.type==="normal"&&Se&&(this.next=Se),ye},finish:function(ce){for(var Se=this.tryEntries.length-1;Se>=0;--Se){var Ve=this.tryEntries[Se];if(Ve.finallyLoc===ce)return this.complete(Ve.completion,Ve.afterLoc),ke(Ve),ye}},catch:function(ce){for(var Se=this.tryEntries.length-1;Se>=0;--Se){var Ve=this.tryEntries[Se];if(Ve.tryLoc===ce){var Xe=Ve.completion;if(Xe.type==="throw"){var x=Xe.arg;ke(Ve)}return x}}throw new Error("illegal catch attempt")},delegateYield:function(ce,Se,Ve){return this.delegate={iterator:nt(ce),resultName:Se,nextLoc:Ve},this.method==="next"&&(this.arg=Z),ye}},S}ne.exports=T,ne.exports.__esModule=!0,ne.exports.default=ne.exports},6015:function(ne){function $(A,h){return ne.exports=$=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(Z,S){return Z.__proto__=S,Z},ne.exports.__esModule=!0,ne.exports.default=ne.exports,$(A,h)}ne.exports=$,ne.exports.__esModule=!0,ne.exports.default=ne.exports},95036:function(ne,$,A){var h=A(18698).default;function T(Z,S){if(h(Z)!=="object"||Z===null)return Z;var B=Z[Symbol.toPrimitive];if(B!==void 0){var X=B.call(Z,S||"default");if(h(X)!=="object")return X;throw new TypeError("@@toPrimitive must return a primitive value.")}return(S==="string"?String:Number)(Z)}ne.exports=T,ne.exports.__esModule=!0,ne.exports.default=ne.exports},64062:function(ne,$,A){var h=A(18698).default,T=A(95036);function Z(S){var B=T(S,"string");return h(B)==="symbol"?B:String(B)}ne.exports=Z,ne.exports.__esModule=!0,ne.exports.default=ne.exports},18698:function(ne){function $(A){return ne.exports=$=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(h){return typeof h}:function(h){return h&&typeof Symbol=="function"&&h.constructor===Symbol&&h!==Symbol.prototype?"symbol":typeof h},ne.exports.__esModule=!0,ne.exports.default=ne.exports,$(A)}ne.exports=$,ne.exports.__esModule=!0,ne.exports.default=ne.exports},64687:function(ne,$,A){var h=A(17061)();ne.exports=h;try{regeneratorRuntime=h}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=h:Function("r","regeneratorRuntime = r")(h)}},75101:function(ne,$,A){"use strict";A.d($,{Xg:function(){return Ve},ZL:function(){return x},AW:function(){return H}});var h=A(39386),T=A(40475);const Z=c=>{const l=c.decode.bind(c),y=c.encode.bind(c);return{decode:l,encode:y}};var S=A(48764).Buffer;const B=c=>l=>{const y=(0,h.Ik)(c,l),{encode:q,decode:E}=Z(y),Ie=y;return Ie.decode=(ze,$e)=>{const dt=E(ze,$e);return(0,T.oU)(S.from(dt))},Ie.encode=(ze,$e,dt)=>{const Mt=(0,T.k$)(ze,c);return q(Mt,$e,dt)},Ie},X=c=>l=>{const y=(0,h.Ik)(c,l),{encode:q,decode:E}=Z(y),Ie=y;return Ie.decode=(ze,$e)=>{const dt=E(ze,$e);return(0,T.Q5)(S.from(dt))},Ie.encode=(ze,$e,dt)=>{const Mt=(0,T.zP)(ze,c);return q(Mt,$e,dt)},Ie},H=B(8),R=X(8),j=B(16),me=X(16),se=B(24),_=X(24),re=B(32),D=X(32);var fe=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,Q=Math.ceil,Y=Math.floor,te="[BigNumber Error] ",ye=te+"Number primitive has more than 15 significant digits: ",Ne=1e14,ee=14,we=9007199254740991,He=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],ue=1e7,Ae=1e9;function xe(c){var l,y,q,E=Ee.prototype={constructor:Ee,toString:null,valueOf:null},Ie=new Ee(1),ze=20,$e=4,dt=-7,Mt=21,mn=-1e7,an=1e7,Rn=!1,Gn=1,vn=0,mr={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},Pn="0123456789abcdefghijklmnopqrstuvwxyz",wr=!0;function Ee(f,g){var w,M,I,L,G,v,P,W,U=this;if(!(U instanceof Ee))return new Ee(f,g);if(g==null){if(f&&f._isBigNumber===!0){U.s=f.s,!f.c||f.e>an?U.c=U.e=null:f.e<mn?U.c=[U.e=0]:(U.e=f.e,U.c=f.c.slice());return}if((v=typeof f=="number")&&f*0==0){if(U.s=1/f<0?(f=-f,-1):1,f===~~f){for(L=0,G=f;G>=10;G/=10,L++);L>an?U.c=U.e=null:(U.e=L,U.c=[f]);return}W=String(f)}else{if(!fe.test(W=String(f)))return q(U,W,v);U.s=W.charCodeAt(0)==45?(W=W.slice(1),-1):1}(L=W.indexOf("."))>-1&&(W=W.replace(".","")),(G=W.search(/e/i))>0?(L<0&&(L=G),L+=+W.slice(G+1),W=W.substring(0,G)):L<0&&(L=W.length)}else{if(oe(g,2,Pn.length,"Base"),g==10&&wr)return U=new Ee(f),zt(U,ze+U.e+1,$e);if(W=String(f),v=typeof f=="number"){if(f*0!=0)return q(U,W,v,g);if(U.s=1/f<0?(W=W.slice(1),-1):1,Ee.DEBUG&&W.replace(/^0\.0*|\./,"").length>15)throw Error(ye+f)}else U.s=W.charCodeAt(0)===45?(W=W.slice(1),-1):1;for(w=Pn.slice(0,g),L=G=0,P=W.length;G<P;G++)if(w.indexOf(M=W.charAt(G))<0){if(M=="."){if(G>L){L=P;continue}}else if(!I&&(W==W.toUpperCase()&&(W=W.toLowerCase())||W==W.toLowerCase()&&(W=W.toUpperCase()))){I=!0,G=-1,L=0;continue}return q(U,String(f),v,g)}v=!1,W=y(W,g,10,U.s),(L=W.indexOf("."))>-1?W=W.replace(".",""):L=W.length}for(G=0;W.charCodeAt(G)===48;G++);for(P=W.length;W.charCodeAt(--P)===48;);if(W=W.slice(G,++P)){if(P-=G,v&&Ee.DEBUG&&P>15&&(f>we||f!==Y(f)))throw Error(ye+U.s*f);if((L=L-G-1)>an)U.c=U.e=null;else if(L<mn)U.c=[U.e=0];else{if(U.e=L,U.c=[],G=(L+1)%ee,L<0&&(G+=ee),G<P){for(G&&U.c.push(+W.slice(0,G)),P-=ee;G<P;)U.c.push(+W.slice(G,G+=ee));G=ee-(W=W.slice(G)).length}else G-=P;for(;G--;W+="0");U.c.push(+W)}}else U.c=[U.e=0]}Ee.clone=xe,Ee.ROUND_UP=0,Ee.ROUND_DOWN=1,Ee.ROUND_CEIL=2,Ee.ROUND_FLOOR=3,Ee.ROUND_HALF_UP=4,Ee.ROUND_HALF_DOWN=5,Ee.ROUND_HALF_EVEN=6,Ee.ROUND_HALF_CEIL=7,Ee.ROUND_HALF_FLOOR=8,Ee.EUCLID=9,Ee.config=Ee.set=function(f){var g,w;if(f!=null)if(typeof f=="object"){if(f.hasOwnProperty(g="DECIMAL_PLACES")&&(w=f[g],oe(w,0,Ae,g),ze=w),f.hasOwnProperty(g="ROUNDING_MODE")&&(w=f[g],oe(w,0,8,g),$e=w),f.hasOwnProperty(g="EXPONENTIAL_AT")&&(w=f[g],w&&w.pop?(oe(w[0],-Ae,0,g),oe(w[1],0,Ae,g),dt=w[0],Mt=w[1]):(oe(w,-Ae,Ae,g),dt=-(Mt=w<0?-w:w))),f.hasOwnProperty(g="RANGE"))if(w=f[g],w&&w.pop)oe(w[0],-Ae,-1,g),oe(w[1],1,Ae,g),mn=w[0],an=w[1];else if(oe(w,-Ae,Ae,g),w)mn=-(an=w<0?-w:w);else throw Error(te+g+" cannot be zero: "+w);if(f.hasOwnProperty(g="CRYPTO"))if(w=f[g],w===!!w)if(w)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))Rn=w;else throw Rn=!w,Error(te+"crypto unavailable");else Rn=w;else throw Error(te+g+" not true or false: "+w);if(f.hasOwnProperty(g="MODULO_MODE")&&(w=f[g],oe(w,0,9,g),Gn=w),f.hasOwnProperty(g="POW_PRECISION")&&(w=f[g],oe(w,0,Ae,g),vn=w),f.hasOwnProperty(g="FORMAT"))if(w=f[g],typeof w=="object")mr=w;else throw Error(te+g+" not an object: "+w);if(f.hasOwnProperty(g="ALPHABET"))if(w=f[g],typeof w=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(w))wr=w.slice(0,10)=="0123456789",Pn=w;else throw Error(te+g+" invalid: "+w)}else throw Error(te+"Object expected: "+f);return{DECIMAL_PLACES:ze,ROUNDING_MODE:$e,EXPONENTIAL_AT:[dt,Mt],RANGE:[mn,an],CRYPTO:Rn,MODULO_MODE:Gn,POW_PRECISION:vn,FORMAT:mr,ALPHABET:Pn}},Ee.isBigNumber=function(f){if(!f||f._isBigNumber!==!0)return!1;if(!Ee.DEBUG)return!0;var g,w,M=f.c,I=f.e,L=f.s;e:if({}.toString.call(M)=="[object Array]"){if((L===1||L===-1)&&I>=-Ae&&I<=Ae&&I===Y(I)){if(M[0]===0){if(I===0&&M.length===1)return!0;break e}if(g=(I+1)%ee,g<1&&(g+=ee),String(M[0]).length==g){for(g=0;g<M.length;g++)if(w=M[g],w<0||w>=Ne||w!==Y(w))break e;if(w!==0)return!0}}}else if(M===null&&I===null&&(L===null||L===1||L===-1))return!0;throw Error(te+"Invalid BigNumber: "+f)},Ee.maximum=Ee.max=function(){return kr(arguments,-1)},Ee.minimum=Ee.min=function(){return kr(arguments,1)},Ee.random=function(){var f=9007199254740992,g=Math.random()*f&2097151?function(){return Y(Math.random()*f)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(w){var M,I,L,G,v,P=0,W=[],U=new Ee(Ie);if(w==null?w=ze:oe(w,0,Ae),G=Q(w/ee),Rn)if(crypto.getRandomValues){for(M=crypto.getRandomValues(new Uint32Array(G*=2));P<G;)v=M[P]*131072+(M[P+1]>>>11),v>=9e15?(I=crypto.getRandomValues(new Uint32Array(2)),M[P]=I[0],M[P+1]=I[1]):(W.push(v%1e14),P+=2);P=G/2}else if(crypto.randomBytes){for(M=crypto.randomBytes(G*=7);P<G;)v=(M[P]&31)*281474976710656+M[P+1]*1099511627776+M[P+2]*4294967296+M[P+3]*16777216+(M[P+4]<<16)+(M[P+5]<<8)+M[P+6],v>=9e15?crypto.randomBytes(7).copy(M,P):(W.push(v%1e14),P+=7);P=G/7}else throw Rn=!1,Error(te+"crypto unavailable");if(!Rn)for(;P<G;)v=g(),v<9e15&&(W[P++]=v%1e14);for(G=W[--P],w%=ee,G&&w&&(v=He[ee-w],W[P]=Y(G/v)*v);W[P]===0;W.pop(),P--);if(P<0)W=[L=0];else{for(L=-1;W[0]===0;W.splice(0,1),L-=ee);for(P=1,v=W[0];v>=10;v/=10,P++);P<ee&&(L-=ee-P)}return U.e=L,U.c=W,U}}(),Ee.sum=function(){for(var f=1,g=arguments,w=new Ee(g[0]);f<g.length;)w=w.plus(g[f++]);return w},y=function(){var f="0123456789";function g(w,M,I,L){for(var G,v=[0],P,W=0,U=w.length;W<U;){for(P=v.length;P--;v[P]*=M);for(v[0]+=L.indexOf(w.charAt(W++)),G=0;G<v.length;G++)v[G]>I-1&&(v[G+1]==null&&(v[G+1]=0),v[G+1]+=v[G]/I|0,v[G]%=I)}return v.reverse()}return function(w,M,I,L,G){var v,P,W,U,ae,Fe,We,ut,xt=w.indexOf("."),vt=ze,tt=$e;for(xt>=0&&(U=vn,vn=0,w=w.replace(".",""),ut=new Ee(M),Fe=ut.pow(w.length-xt),vn=U,ut.c=g(Je(z(Fe.c),Fe.e,"0"),10,I,f),ut.e=ut.c.length),We=g(w,M,I,G?(v=Pn,f):(v=f,Pn)),W=U=We.length;We[--U]==0;We.pop());if(!We[0])return v.charAt(0);if(xt<0?--W:(Fe.c=We,Fe.e=W,Fe.s=L,Fe=l(Fe,ut,vt,tt,I),We=Fe.c,ae=Fe.r,W=Fe.e),P=W+vt+1,xt=We[P],U=I/2,ae=ae||P<0||We[P+1]!=null,ae=tt<4?(xt!=null||ae)&&(tt==0||tt==(Fe.s<0?3:2)):xt>U||xt==U&&(tt==4||ae||tt==6&&We[P-1]&1||tt==(Fe.s<0?8:7)),P<1||!We[0])w=ae?Je(v.charAt(1),-vt,v.charAt(0)):v.charAt(0);else{if(We.length=P,ae)for(--I;++We[--P]>I;)We[P]=0,P||(++W,We=[1].concat(We));for(U=We.length;!We[--U];);for(xt=0,w="";xt<=U;w+=v.charAt(We[xt++]));w=Je(w,W,v.charAt(0))}return w}}(),l=function(){function f(M,I,L){var G,v,P,W,U=0,ae=M.length,Fe=I%ue,We=I/ue|0;for(M=M.slice();ae--;)P=M[ae]%ue,W=M[ae]/ue|0,G=We*P+W*Fe,v=Fe*P+G%ue*ue+U,U=(v/L|0)+(G/ue|0)+We*W,M[ae]=v%L;return U&&(M=[U].concat(M)),M}function g(M,I,L,G){var v,P;if(L!=G)P=L>G?1:-1;else for(v=P=0;v<L;v++)if(M[v]!=I[v]){P=M[v]>I[v]?1:-1;break}return P}function w(M,I,L,G){for(var v=0;L--;)M[L]-=v,v=M[L]<I[L]?1:0,M[L]=v*G+M[L]-I[L];for(;!M[0]&&M.length>1;M.splice(0,1));}return function(M,I,L,G,v){var P,W,U,ae,Fe,We,ut,xt,vt,tt,lt,Pt,wn,sr,Tt,Yt,Un,rn=M.s==I.s?1:-1,Zt=M.c,Bt=I.c;if(!Zt||!Zt[0]||!Bt||!Bt[0])return new Ee(!M.s||!I.s||(Zt?Bt&&Zt[0]==Bt[0]:!Bt)?NaN:Zt&&Zt[0]==0||!Bt?rn*0:rn/0);for(xt=new Ee(rn),vt=xt.c=[],W=M.e-I.e,rn=L+W+1,v||(v=Ne,W=J(M.e/ee)-J(I.e/ee),rn=rn/ee|0),U=0;Bt[U]==(Zt[U]||0);U++);if(Bt[U]>(Zt[U]||0)&&W--,rn<0)vt.push(1),ae=!0;else{for(sr=Zt.length,Yt=Bt.length,U=0,rn+=2,Fe=Y(v/(Bt[0]+1)),Fe>1&&(Bt=f(Bt,Fe,v),Zt=f(Zt,Fe,v),Yt=Bt.length,sr=Zt.length),wn=Yt,tt=Zt.slice(0,Yt),lt=tt.length;lt<Yt;tt[lt++]=0);Un=Bt.slice(),Un=[0].concat(Un),Tt=Bt[0],Bt[1]>=v/2&&Tt++;do{if(Fe=0,P=g(Bt,tt,Yt,lt),P<0){if(Pt=tt[0],Yt!=lt&&(Pt=Pt*v+(tt[1]||0)),Fe=Y(Pt/Tt),Fe>1)for(Fe>=v&&(Fe=v-1),We=f(Bt,Fe,v),ut=We.length,lt=tt.length;g(We,tt,ut,lt)==1;)Fe--,w(We,Yt<ut?Un:Bt,ut,v),ut=We.length,P=1;else Fe==0&&(P=Fe=1),We=Bt.slice(),ut=We.length;if(ut<lt&&(We=[0].concat(We)),w(tt,We,lt,v),lt=tt.length,P==-1)for(;g(Bt,tt,Yt,lt)<1;)Fe++,w(tt,Yt<lt?Un:Bt,lt,v),lt=tt.length}else P===0&&(Fe++,tt=[0]);vt[U++]=Fe,tt[0]?tt[lt++]=Zt[wn]||0:(tt=[Zt[wn]],lt=1)}while((wn++<sr||tt[0]!=null)&&rn--);ae=tt[0]!=null,vt[0]||vt.splice(0,1)}if(v==Ne){for(U=1,rn=vt[0];rn>=10;rn/=10,U++);zt(xt,L+(xt.e=U+W*ee-1)+1,G,ae)}else xt.e=W,xt.r=+ae;return xt}}();function Qe(f,g,w,M){var I,L,G,v,P;if(w==null?w=$e:oe(w,0,8),!f.c)return f.toString();if(I=f.c[0],G=f.e,g==null)P=z(f.c),P=M==1||M==2&&(G<=dt||G>=Mt)?ke(P,G):Je(P,G,"0");else if(f=zt(new Ee(f),g,w),L=f.e,P=z(f.c),v=P.length,M==1||M==2&&(g<=L||L<=dt)){for(;v<g;P+="0",v++);P=ke(P,L)}else if(g-=G,P=Je(P,L,"0"),L+1>v){if(--g>0)for(P+=".";g--;P+="0");}else if(g+=L-v,g>0)for(L+1==v&&(P+=".");g--;P+="0");return f.s<0&&I?"-"+P:P}function kr(f,g){for(var w,M,I=1,L=new Ee(f[0]);I<f.length;I++)M=new Ee(f[I]),(!M.s||(w=ie(L,M))===g||w===0&&L.s===g)&&(L=M);return L}function rr(f,g,w){for(var M=1,I=g.length;!g[--I];g.pop());for(I=g[0];I>=10;I/=10,M++);return(w=M+w*ee-1)>an?f.c=f.e=null:w<mn?f.c=[f.e=0]:(f.e=w,f.c=g),f}q=function(){var f=/^(-?)0([xbo])(?=\w[\w.]*$)/i,g=/^([^.]+)\.$/,w=/^\.([^.]+)$/,M=/^-?(Infinity|NaN)$/,I=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(L,G,v,P){var W,U=v?G:G.replace(I,"");if(M.test(U))L.s=isNaN(U)?null:U<0?-1:1;else{if(!v&&(U=U.replace(f,function(ae,Fe,We){return W=(We=We.toLowerCase())=="x"?16:We=="b"?2:8,!P||P==W?Fe:ae}),P&&(W=P,U=U.replace(g,"$1").replace(w,"0.$1")),G!=U))return new Ee(U,W);if(Ee.DEBUG)throw Error(te+"Not a"+(P?" base "+P:"")+" number: "+G);L.s=null}L.c=L.e=null}}();function zt(f,g,w,M){var I,L,G,v,P,W,U,ae=f.c,Fe=He;if(ae){e:{for(I=1,v=ae[0];v>=10;v/=10,I++);if(L=g-I,L<0)L+=ee,G=g,P=ae[W=0],U=Y(P/Fe[I-G-1]%10);else if(W=Q((L+1)/ee),W>=ae.length)if(M){for(;ae.length<=W;ae.push(0));P=U=0,I=1,L%=ee,G=L-ee+1}else break e;else{for(P=v=ae[W],I=1;v>=10;v/=10,I++);L%=ee,G=L-ee+I,U=G<0?0:Y(P/Fe[I-G-1]%10)}if(M=M||g<0||ae[W+1]!=null||(G<0?P:P%Fe[I-G-1]),M=w<4?(U||M)&&(w==0||w==(f.s<0?3:2)):U>5||U==5&&(w==4||M||w==6&&(L>0?G>0?P/Fe[I-G]:0:ae[W-1])%10&1||w==(f.s<0?8:7)),g<1||!ae[0])return ae.length=0,M?(g-=f.e+1,ae[0]=Fe[(ee-g%ee)%ee],f.e=-g||0):ae[0]=f.e=0,f;if(L==0?(ae.length=W,v=1,W--):(ae.length=W+1,v=Fe[ee-L],ae[W]=G>0?Y(P/Fe[I-G]%Fe[G])*v:0),M)for(;;)if(W==0){for(L=1,G=ae[0];G>=10;G/=10,L++);for(G=ae[0]+=v,v=1;G>=10;G/=10,v++);L!=v&&(f.e++,ae[0]==Ne&&(ae[0]=1));break}else{if(ae[W]+=v,ae[W]!=Ne)break;ae[W--]=0,v=1}for(L=ae.length;ae[--L]===0;ae.pop());}f.e>an?f.c=f.e=null:f.e<mn&&(f.c=[f.e=0])}return f}function $t(f){var g,w=f.e;return w===null?f.toString():(g=z(f.c),g=w<=dt||w>=Mt?ke(g,w):Je(g,w,"0"),f.s<0?"-"+g:g)}return E.absoluteValue=E.abs=function(){var f=new Ee(this);return f.s<0&&(f.s=1),f},E.comparedTo=function(f,g){return ie(this,new Ee(f,g))},E.decimalPlaces=E.dp=function(f,g){var w,M,I,L=this;if(f!=null)return oe(f,0,Ae),g==null?g=$e:oe(g,0,8),zt(new Ee(L),f+L.e+1,g);if(!(w=L.c))return null;if(M=((I=w.length-1)-J(this.e/ee))*ee,I=w[I])for(;I%10==0;I/=10,M--);return M<0&&(M=0),M},E.dividedBy=E.div=function(f,g){return l(this,new Ee(f,g),ze,$e)},E.dividedToIntegerBy=E.idiv=function(f,g){return l(this,new Ee(f,g),0,1)},E.exponentiatedBy=E.pow=function(f,g){var w,M,I,L,G,v,P,W,U,ae=this;if(f=new Ee(f),f.c&&!f.isInteger())throw Error(te+"Exponent not an integer: "+$t(f));if(g!=null&&(g=new Ee(g)),v=f.e>14,!ae.c||!ae.c[0]||ae.c[0]==1&&!ae.e&&ae.c.length==1||!f.c||!f.c[0])return U=new Ee(Math.pow(+$t(ae),v?f.s*(2-ge(f)):+$t(f))),g?U.mod(g):U;if(P=f.s<0,g){if(g.c?!g.c[0]:!g.s)return new Ee(NaN);M=!P&&ae.isInteger()&&g.isInteger(),M&&(ae=ae.mod(g))}else{if(f.e>9&&(ae.e>0||ae.e<-1||(ae.e==0?ae.c[0]>1||v&&ae.c[1]>=24e7:ae.c[0]<8e13||v&&ae.c[0]<=9999975e7)))return L=ae.s<0&&ge(f)?-0:0,ae.e>-1&&(L=1/L),new Ee(P?1/L:L);vn&&(L=Q(vn/ee+2))}for(v?(w=new Ee(.5),P&&(f.s=1),W=ge(f)):(I=Math.abs(+$t(f)),W=I%2),U=new Ee(Ie);;){if(W){if(U=U.times(ae),!U.c)break;L?U.c.length>L&&(U.c.length=L):M&&(U=U.mod(g))}if(I){if(I=Y(I/2),I===0)break;W=I%2}else if(f=f.times(w),zt(f,f.e+1,1),f.e>14)W=ge(f);else{if(I=+$t(f),I===0)break;W=I%2}ae=ae.times(ae),L?ae.c&&ae.c.length>L&&(ae.c.length=L):M&&(ae=ae.mod(g))}return M?U:(P&&(U=Ie.div(U)),g?U.mod(g):L?zt(U,vn,$e,G):U)},E.integerValue=function(f){var g=new Ee(this);return f==null?f=$e:oe(f,0,8),zt(g,g.e+1,f)},E.isEqualTo=E.eq=function(f,g){return ie(this,new Ee(f,g))===0},E.isFinite=function(){return!!this.c},E.isGreaterThan=E.gt=function(f,g){return ie(this,new Ee(f,g))>0},E.isGreaterThanOrEqualTo=E.gte=function(f,g){return(g=ie(this,new Ee(f,g)))===1||g===0},E.isInteger=function(){return!!this.c&&J(this.e/ee)>this.c.length-2},E.isLessThan=E.lt=function(f,g){return ie(this,new Ee(f,g))<0},E.isLessThanOrEqualTo=E.lte=function(f,g){return(g=ie(this,new Ee(f,g)))===-1||g===0},E.isNaN=function(){return!this.s},E.isNegative=function(){return this.s<0},E.isPositive=function(){return this.s>0},E.isZero=function(){return!!this.c&&this.c[0]==0},E.minus=function(f,g){var w,M,I,L,G=this,v=G.s;if(f=new Ee(f,g),g=f.s,!v||!g)return new Ee(NaN);if(v!=g)return f.s=-g,G.plus(f);var P=G.e/ee,W=f.e/ee,U=G.c,ae=f.c;if(!P||!W){if(!U||!ae)return U?(f.s=-g,f):new Ee(ae?G:NaN);if(!U[0]||!ae[0])return ae[0]?(f.s=-g,f):new Ee(U[0]?G:$e==3?-0:0)}if(P=J(P),W=J(W),U=U.slice(),v=P-W){for((L=v<0)?(v=-v,I=U):(W=P,I=ae),I.reverse(),g=v;g--;I.push(0));I.reverse()}else for(M=(L=(v=U.length)<(g=ae.length))?v:g,v=g=0;g<M;g++)if(U[g]!=ae[g]){L=U[g]<ae[g];break}if(L&&(I=U,U=ae,ae=I,f.s=-f.s),g=(M=ae.length)-(w=U.length),g>0)for(;g--;U[w++]=0);for(g=Ne-1;M>v;){if(U[--M]<ae[M]){for(w=M;w&&!U[--w];U[w]=g);--U[w],U[M]+=Ne}U[M]-=ae[M]}for(;U[0]==0;U.splice(0,1),--W);return U[0]?rr(f,U,W):(f.s=$e==3?-1:1,f.c=[f.e=0],f)},E.modulo=E.mod=function(f,g){var w,M,I=this;return f=new Ee(f,g),!I.c||!f.s||f.c&&!f.c[0]?new Ee(NaN):!f.c||I.c&&!I.c[0]?new Ee(I):(Gn==9?(M=f.s,f.s=1,w=l(I,f,0,3),f.s=M,w.s*=M):w=l(I,f,0,Gn),f=I.minus(w.times(f)),!f.c[0]&&Gn==1&&(f.s=I.s),f)},E.multipliedBy=E.times=function(f,g){var w,M,I,L,G,v,P,W,U,ae,Fe,We,ut,xt,vt,tt=this,lt=tt.c,Pt=(f=new Ee(f,g)).c;if(!lt||!Pt||!lt[0]||!Pt[0])return!tt.s||!f.s||lt&&!lt[0]&&!Pt||Pt&&!Pt[0]&&!lt?f.c=f.e=f.s=null:(f.s*=tt.s,!lt||!Pt?f.c=f.e=null:(f.c=[0],f.e=0)),f;for(M=J(tt.e/ee)+J(f.e/ee),f.s*=tt.s,P=lt.length,ae=Pt.length,P<ae&&(ut=lt,lt=Pt,Pt=ut,I=P,P=ae,ae=I),I=P+ae,ut=[];I--;ut.push(0));for(xt=Ne,vt=ue,I=ae;--I>=0;){for(w=0,Fe=Pt[I]%vt,We=Pt[I]/vt|0,G=P,L=I+G;L>I;)W=lt[--G]%vt,U=lt[G]/vt|0,v=We*W+U*Fe,W=Fe*W+v%vt*vt+ut[L]+w,w=(W/xt|0)+(v/vt|0)+We*U,ut[L--]=W%xt;ut[L]=w}return w?++M:ut.splice(0,1),rr(f,ut,M)},E.negated=function(){var f=new Ee(this);return f.s=-f.s||null,f},E.plus=function(f,g){var w,M=this,I=M.s;if(f=new Ee(f,g),g=f.s,!I||!g)return new Ee(NaN);if(I!=g)return f.s=-g,M.minus(f);var L=M.e/ee,G=f.e/ee,v=M.c,P=f.c;if(!L||!G){if(!v||!P)return new Ee(I/0);if(!v[0]||!P[0])return P[0]?f:new Ee(v[0]?M:I*0)}if(L=J(L),G=J(G),v=v.slice(),I=L-G){for(I>0?(G=L,w=P):(I=-I,w=v),w.reverse();I--;w.push(0));w.reverse()}for(I=v.length,g=P.length,I-g<0&&(w=P,P=v,v=w,g=I),I=0;g;)I=(v[--g]=v[g]+P[g]+I)/Ne|0,v[g]=Ne===v[g]?0:v[g]%Ne;return I&&(v=[I].concat(v),++G),rr(f,v,G)},E.precision=E.sd=function(f,g){var w,M,I,L=this;if(f!=null&&f!==!!f)return oe(f,1,Ae),g==null?g=$e:oe(g,0,8),zt(new Ee(L),f,g);if(!(w=L.c))return null;if(I=w.length-1,M=I*ee+1,I=w[I]){for(;I%10==0;I/=10,M--);for(I=w[0];I>=10;I/=10,M++);}return f&&L.e+1>M&&(M=L.e+1),M},E.shiftedBy=function(f){return oe(f,-we,we),this.times("1e"+f)},E.squareRoot=E.sqrt=function(){var f,g,w,M,I,L=this,G=L.c,v=L.s,P=L.e,W=ze+4,U=new Ee("0.5");if(v!==1||!G||!G[0])return new Ee(!v||v<0&&(!G||G[0])?NaN:G?L:1/0);if(v=Math.sqrt(+$t(L)),v==0||v==1/0?(g=z(G),(g.length+P)%2==0&&(g+="0"),v=Math.sqrt(+g),P=J((P+1)/2)-(P<0||P%2),v==1/0?g="5e"+P:(g=v.toExponential(),g=g.slice(0,g.indexOf("e")+1)+P),w=new Ee(g)):w=new Ee(v+""),w.c[0]){for(P=w.e,v=P+W,v<3&&(v=0);;)if(I=w,w=U.times(I.plus(l(L,I,W,1))),z(I.c).slice(0,v)===(g=z(w.c)).slice(0,v))if(w.e<P&&--v,g=g.slice(v-3,v+1),g=="9999"||!M&&g=="4999"){if(!M&&(zt(I,I.e+ze+2,0),I.times(I).eq(L))){w=I;break}W+=4,v+=4,M=1}else{(!+g||!+g.slice(1)&&g.charAt(0)=="5")&&(zt(w,w.e+ze+2,1),f=!w.times(w).eq(L));break}}return zt(w,w.e+ze+1,$e,f)},E.toExponential=function(f,g){return f!=null&&(oe(f,0,Ae),f++),Qe(this,f,g,1)},E.toFixed=function(f,g){return f!=null&&(oe(f,0,Ae),f=f+this.e+1),Qe(this,f,g)},E.toFormat=function(f,g,w){var M,I=this;if(w==null)f!=null&&g&&typeof g=="object"?(w=g,g=null):f&&typeof f=="object"?(w=f,f=g=null):w=mr;else if(typeof w!="object")throw Error(te+"Argument not an object: "+w);if(M=I.toFixed(f,g),I.c){var L,G=M.split("."),v=+w.groupSize,P=+w.secondaryGroupSize,W=w.groupSeparator||"",U=G[0],ae=G[1],Fe=I.s<0,We=Fe?U.slice(1):U,ut=We.length;if(P&&(L=v,v=P,P=L,ut-=L),v>0&&ut>0){for(L=ut%v||v,U=We.substr(0,L);L<ut;L+=v)U+=W+We.substr(L,v);P>0&&(U+=W+We.slice(L)),Fe&&(U="-"+U)}M=ae?U+(w.decimalSeparator||"")+((P=+w.fractionGroupSize)?ae.replace(new RegExp("\\d{"+P+"}\\B","g"),"$&"+(w.fractionGroupSeparator||"")):ae):U}return(w.prefix||"")+M+(w.suffix||"")},E.toFraction=function(f){var g,w,M,I,L,G,v,P,W,U,ae,Fe,We=this,ut=We.c;if(f!=null&&(v=new Ee(f),!v.isInteger()&&(v.c||v.s!==1)||v.lt(Ie)))throw Error(te+"Argument "+(v.isInteger()?"out of range: ":"not an integer: ")+$t(v));if(!ut)return new Ee(We);for(g=new Ee(Ie),W=w=new Ee(Ie),M=P=new Ee(Ie),Fe=z(ut),L=g.e=Fe.length-We.e-1,g.c[0]=He[(G=L%ee)<0?ee+G:G],f=!f||v.comparedTo(g)>0?L>0?g:W:v,G=an,an=1/0,v=new Ee(Fe),P.c[0]=0;U=l(v,g,0,1),I=w.plus(U.times(M)),I.comparedTo(f)!=1;)w=M,M=I,W=P.plus(U.times(I=W)),P=I,g=v.minus(U.times(I=g)),v=I;return I=l(f.minus(w),M,0,1),P=P.plus(I.times(W)),w=w.plus(I.times(M)),P.s=W.s=We.s,L=L*2,ae=l(W,M,L,$e).minus(We).abs().comparedTo(l(P,w,L,$e).minus(We).abs())<1?[W,M]:[P,w],an=G,ae},E.toNumber=function(){return+$t(this)},E.toPrecision=function(f,g){return f!=null&&oe(f,1,Ae),Qe(this,f,g,2)},E.toString=function(f){var g,w=this,M=w.s,I=w.e;return I===null?M?(g="Infinity",M<0&&(g="-"+g)):g="NaN":(f==null?g=I<=dt||I>=Mt?ke(z(w.c),I):Je(z(w.c),I,"0"):f===10&&wr?(w=zt(new Ee(w),ze+I+1,$e),g=Je(z(w.c),w.e,"0")):(oe(f,2,Pn.length,"Base"),g=y(Je(z(w.c),I,"0"),10,f,M,!0)),M<0&&w.c[0]&&(g="-"+g)),g},E.valueOf=E.toJSON=function(){return $t(this)},E._isBigNumber=!0,E[Symbol.toStringTag]="BigNumber",E[Symbol.for("nodejs.util.inspect.custom")]=E.valueOf,c!=null&&Ee.set(c),Ee}function J(c){var l=c|0;return c>0||c===l?l:l-1}function z(c){for(var l,y,q=1,E=c.length,Ie=c[0]+"";q<E;){for(l=c[q++]+"",y=ee-l.length;y--;l="0"+l);Ie+=l}for(E=Ie.length;Ie.charCodeAt(--E)===48;);return Ie.slice(0,E+1||1)}function ie(c,l){var y,q,E=c.c,Ie=l.c,ze=c.s,$e=l.s,dt=c.e,Mt=l.e;if(!ze||!$e)return null;if(y=E&&!E[0],q=Ie&&!Ie[0],y||q)return y?q?0:-$e:ze;if(ze!=$e)return ze;if(y=ze<0,q=dt==Mt,!E||!Ie)return q?0:!E^y?1:-1;if(!q)return dt>Mt^y?1:-1;for($e=(dt=E.length)<(Mt=Ie.length)?dt:Mt,ze=0;ze<$e;ze++)if(E[ze]!=Ie[ze])return E[ze]>Ie[ze]^y?1:-1;return dt==Mt?0:dt>Mt^y?1:-1}function oe(c,l,y,q){if(c<l||c>y||c!==Y(c))throw Error(te+(q||"Argument")+(typeof c=="number"?c<l||c>y?" out of range: ":" not an integer: ":" not a primitive number: ")+String(c))}function ge(c){var l=c.c.length-1;return J(c.e/ee)==l&&c.c[l]%2!=0}function ke(c,l){return(c.length>1?c.charAt(0)+"."+c.slice(1):c)+(l<0?"e":"e+")+l}function Je(c,l,y){var q,E;if(l<0){for(E=y+".";++l;E+=y);c=E+c}else if(q=c.length,++l>q){for(E=y,l-=q;--l;E+=y);c+=E}else l<q&&(c=c.slice(0,l)+"."+c.slice(l));return c}var nt=xe(),be=nt;const ce=new be("1e+18"),Se=c=>{const l=u128(c),{encode:y,decode:q}=encodeDecode(l),E=l;return E.decode=(Ie,ze)=>{const $e=q(Ie,ze).toString();return new BigNumber($e).div(ce)},E.encode=(Ie,ze,$e)=>{const dt=BigInt(Ie.times(ce).integerValue().toString());return y(dt,ze,$e)},E},Ve=c=>{const l=(0,h.u8)(c),{encode:y,decode:q}=Z(l),E=l;return E.decode=(Ie,ze)=>!!q(Ie,ze),E.encode=(Ie,ze,$e)=>{const dt=Number(Ie);return y(dt,ze,$e)},E};var Xe=A(64705);const x=c=>{const l=(0,h.Ik)(32,c),{encode:y,decode:q}=Z(l),E=l;return E.decode=(Ie,ze)=>{const $e=q(Ie,ze);return new Xe.PublicKey($e)},E.encode=(Ie,ze,$e)=>{const dt=Ie.toBuffer();return y(dt,ze,$e)},E}},58467:function(ne,$,A){"use strict";A.d($,{H_:function(){return T},_u:function(){return S}});var h=A(64705);const T=new h.PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"),Z=new h.PublicKey("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"),S=new h.PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"),B=new h.PublicKey("So11111111111111111111111111111111111111112"),X=new h.PublicKey("9pan9bMn5HatX4EJdBwg9VgCa7Uz5HL8N1m5D3NdXejP");function H(R){return R!==T}},77043:function(ne,$,A){"use strict";A.d($,{Ek:function(){return S}});var h=A(64705),T=A(58467),Z=A(48764).Buffer;function S(R,j,me,se,_=T.H_,re=T._u){return X(R,j,me,se,Z.alloc(0),_,re)}function B(R,j,me,se,_=TOKEN_PROGRAM_ID,re=ASSOCIATED_TOKEN_PROGRAM_ID){return X(R,j,me,se,Z.from([1]),_,re)}function X(R,j,me,se,_,re=T.H_,D=T._u){const fe=[{pubkey:R,isSigner:!0,isWritable:!0},{pubkey:j,isSigner:!1,isWritable:!0},{pubkey:me,isSigner:!1,isWritable:!1},{pubkey:se,isSigner:!1,isWritable:!1},{pubkey:h.SystemProgram.programId,isSigner:!1,isWritable:!1},{pubkey:re,isSigner:!1,isWritable:!1}];return new h.TransactionInstruction({keys:fe,programId:D,data:_})}function H(R,j,me,se,_,re,D=TOKEN_PROGRAM_ID,fe=ASSOCIATED_TOKEN_PROGRAM_ID){const Q=[{pubkey:R,isSigner:!1,isWritable:!0},{pubkey:j,isSigner:!1,isWritable:!1},{pubkey:me,isSigner:!1,isWritable:!0},{pubkey:se,isSigner:!1,isWritable:!0},{pubkey:_,isSigner:!1,isWritable:!1},{pubkey:re,isSigner:!0,isWritable:!0},{pubkey:D,isSigner:!1,isWritable:!1}];return new TransactionInstruction({keys:Q,programId:fe,data:Z.from([2])})}},49687:function(ne,$,A){"use strict";A.d($,{$B:function(){return j}});var h=A(39386),T=A(75101),Z=A(64705),S=A(58467);function B(_,re,D){if(D.length){_.push({pubkey:re,isSigner:!1,isWritable:!1});for(const fe of D)_.push({pubkey:fe instanceof Z.PublicKey?fe:fe.publicKey,isSigner:!0,isWritable:!1})}else _.push({pubkey:re,isSigner:!0,isWritable:!1});return _}var X;(function(_){_[_.InitializeMint=0]="InitializeMint",_[_.InitializeAccount=1]="InitializeAccount",_[_.InitializeMultisig=2]="InitializeMultisig",_[_.Transfer=3]="Transfer",_[_.Approve=4]="Approve",_[_.Revoke=5]="Revoke",_[_.SetAuthority=6]="SetAuthority",_[_.MintTo=7]="MintTo",_[_.Burn=8]="Burn",_[_.CloseAccount=9]="CloseAccount",_[_.FreezeAccount=10]="FreezeAccount",_[_.ThawAccount=11]="ThawAccount",_[_.TransferChecked=12]="TransferChecked",_[_.ApproveChecked=13]="ApproveChecked",_[_.MintToChecked=14]="MintToChecked",_[_.BurnChecked=15]="BurnChecked",_[_.InitializeAccount2=16]="InitializeAccount2",_[_.SyncNative=17]="SyncNative",_[_.InitializeAccount3=18]="InitializeAccount3",_[_.InitializeMultisig2=19]="InitializeMultisig2",_[_.InitializeMint2=20]="InitializeMint2",_[_.GetAccountDataSize=21]="GetAccountDataSize",_[_.InitializeImmutableOwner=22]="InitializeImmutableOwner",_[_.AmountToUiAmount=23]="AmountToUiAmount",_[_.UiAmountToAmount=24]="UiAmountToAmount",_[_.InitializeMintCloseAuthority=25]="InitializeMintCloseAuthority",_[_.TransferFeeExtension=26]="TransferFeeExtension",_[_.ConfidentialTransferExtension=27]="ConfidentialTransferExtension",_[_.DefaultAccountStateExtension=28]="DefaultAccountStateExtension",_[_.Reallocate=29]="Reallocate",_[_.MemoTransferExtension=30]="MemoTransferExtension",_[_.CreateNativeMint=31]="CreateNativeMint",_[_.InitializeNonTransferableMint=32]="InitializeNonTransferableMint",_[_.InterestBearingMintExtension=33]="InterestBearingMintExtension",_[_.CpiGuardExtension=34]="CpiGuardExtension",_[_.InitializePermanentDelegate=35]="InitializePermanentDelegate",_[_.TransferHookExtension=36]="TransferHookExtension",_[_.MetadataPointerExtension=39]="MetadataPointerExtension"})(X||(X={}));var H=A(48764).Buffer;const R=(0,h.n_)([(0,h.u8)("instruction"),(0,T.AW)("amount")]);function j(_,re,D,fe,Q=[],Y=S.H_){const te=B([{pubkey:_,isSigner:!1,isWritable:!0},{pubkey:re,isSigner:!1,isWritable:!0}],D,Q),ye=H.alloc(R.span);return R.encode({instruction:X.Transfer,amount:BigInt(fe)},ye),new Z.TransactionInstruction({keys:te,programId:Y,data:ye})}function me(_,re=TOKEN_PROGRAM_ID){if(!_.programId.equals(re))throw new TokenInvalidInstructionProgramError;if(_.data.length!==R.span)throw new TokenInvalidInstructionDataError;const{keys:{source:D,destination:fe,owner:Q,multiSigners:Y},data:te}=se(_);if(te.instruction!==TokenInstruction.Transfer)throw new TokenInvalidInstructionTypeError;if(!D||!fe||!Q)throw new TokenInvalidInstructionKeysError;return{programId:re,keys:{source:D,destination:fe,owner:Q,multiSigners:Y},data:te}}function se({programId:_,keys:[re,D,fe,...Q],data:Y}){return{programId:_,keys:{source:re,destination:D,owner:fe,multiSigners:Q},data:R.decode(Y)}}},20302:function(ne,$,A){"use strict";A.d($,{Am:function(){return ie}});var h=A(39386),T=A(75101),Z=A(64705),S=A(58467);class B extends Error{constructor(ke){super(ke)}}class X extends null{constructor(){super(...arguments),this.name="TokenAccountNotFoundError"}}class H extends null{constructor(){super(...arguments),this.name="TokenInvalidAccountError"}}class R extends null{constructor(){super(...arguments),this.name="TokenInvalidAccountDataError"}}class j extends null{constructor(){super(...arguments),this.name="TokenInvalidAccountOwnerError"}}class me extends null{constructor(){super(...arguments),this.name="TokenInvalidAccountSizeError"}}class se extends null{constructor(){super(...arguments),this.name="TokenInvalidMintError"}}class _ extends null{constructor(){super(...arguments),this.name="TokenInvalidOwnerError"}}class re extends B{constructor(){super(...arguments),this.name="TokenOwnerOffCurveError"}}class D extends null{constructor(){super(...arguments),this.name="TokenInvalidInstructionProgramError"}}class fe extends null{constructor(){super(...arguments),this.name="TokenInvalidInstructionKeysError"}}class Q extends null{constructor(){super(...arguments),this.name="TokenInvalidInstructionDataError"}}class Y extends null{constructor(){super(...arguments),this.name="TokenInvalidInstructionTypeError"}}class te extends null{constructor(){super(...arguments),this.name="TokenUnsupportedInstructionError"}}class ye extends null{constructor(){super(...arguments),this.name="TokenTransferHookAccountNotFound"}}class Ne extends null{constructor(){super(...arguments),this.name="TokenTransferHookInvalidSeed"}}class ee extends null{constructor(){super(...arguments),this.name="TokenTransferHookAccountDataNotFound"}}var we=A(48764).Buffer;const He=(0,h.n_)([(0,h.Jq)("mintAuthorityOption"),(0,T.ZL)("mintAuthority"),(0,T.AW)("supply"),(0,h.u8)("decimals"),(0,T.Xg)("isInitialized"),(0,h.Jq)("freezeAuthorityOption"),(0,T.ZL)("freezeAuthority")]),ue=He.span;async function Ae(ge,ke,Je,nt=TOKEN_PROGRAM_ID){const be=await ge.getAccountInfo(ke,Je);return xe(ke,be,nt)}function xe(ge,ke,Je=TOKEN_PROGRAM_ID){if(!ke)throw new TokenAccountNotFoundError;if(!ke.owner.equals(Je))throw new TokenInvalidAccountOwnerError;if(ke.data.length<ue)throw new TokenInvalidAccountSizeError;const nt=He.decode(ke.data.slice(0,ue));let be=we.alloc(0);if(ke.data.length>ue){if(ke.data.length<=ACCOUNT_SIZE)throw new TokenInvalidAccountSizeError;if(ke.data.length===MULTISIG_SIZE)throw new TokenInvalidAccountSizeError;if(ke.data[ACCOUNT_SIZE]!=AccountType.Mint)throw new TokenInvalidMintError;be=ke.data.slice(ACCOUNT_SIZE+ACCOUNT_TYPE_SIZE)}return{address:ge,mintAuthority:nt.mintAuthorityOption?nt.mintAuthority:null,supply:nt.supply,decimals:nt.decimals,isInitialized:nt.isInitialized,freezeAuthority:nt.freezeAuthorityOption?nt.freezeAuthority:null,tlvData:be}}async function J(ge,ke){return await z(ge,[],ke)}async function z(ge,ke,Je){const nt=getMintLen(ke);return await ge.getMinimumBalanceForRentExemption(nt,Je)}async function ie(ge,ke,Je=!1,nt=S.H_,be=S._u){if(!Je&&!Z.PublicKey.isOnCurve(ke.toBuffer()))throw new re;const[ce]=await Z.PublicKey.findProgramAddress([ke.toBuffer(),nt.toBuffer(),ge.toBuffer()],be);return ce}function oe(ge,ke,Je=!1,nt=TOKEN_PROGRAM_ID,be=ASSOCIATED_TOKEN_PROGRAM_ID){if(!Je&&!PublicKey.isOnCurve(ke.toBuffer()))throw new TokenOwnerOffCurveError;const[ce]=PublicKey.findProgramAddressSync([ke.toBuffer(),nt.toBuffer(),ge.toBuffer()],be);return ce}}}]);