pump-kit 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/@pump-kit.png +0 -0
- package/README.md +133 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +173 -0
- package/dist/types/ammsdk/bondingCurveMath.d.ts +41 -0
- package/dist/types/ammsdk/generated/accounts/bondingCurve.d.ts +39 -0
- package/dist/types/ammsdk/generated/accounts/feeConfig.d.ts +33 -0
- package/dist/types/ammsdk/generated/accounts/globalConfig.d.ts +61 -0
- package/dist/types/ammsdk/generated/accounts/globalVolumeAccumulator.d.ts +37 -0
- package/dist/types/ammsdk/generated/accounts/index.d.ts +13 -0
- package/dist/types/ammsdk/generated/accounts/pool.d.ts +47 -0
- package/dist/types/ammsdk/generated/accounts/userVolumeAccumulator.d.ts +39 -0
- package/dist/types/ammsdk/generated/errors/index.d.ts +8 -0
- package/dist/types/ammsdk/generated/errors/pumpAmm.d.ts +101 -0
- package/dist/types/ammsdk/generated/index.d.ts +12 -0
- package/dist/types/ammsdk/generated/instructions/adminSetCoinCreator.d.ts +63 -0
- package/dist/types/ammsdk/generated/instructions/adminUpdateTokenIncentives.d.ts +99 -0
- package/dist/types/ammsdk/generated/instructions/buy.d.ts +144 -0
- package/dist/types/ammsdk/generated/instructions/buyExactQuoteIn.d.ts +144 -0
- package/dist/types/ammsdk/generated/instructions/claimTokenIncentives.d.ts +86 -0
- package/dist/types/ammsdk/generated/instructions/closeUserVolumeAccumulator.d.ts +54 -0
- package/dist/types/ammsdk/generated/instructions/collectCoinCreatorFee.d.ts +70 -0
- package/dist/types/ammsdk/generated/instructions/createConfig.d.ts +79 -0
- package/dist/types/ammsdk/generated/instructions/createPool.d.ts +127 -0
- package/dist/types/ammsdk/generated/instructions/deposit.d.ts +111 -0
- package/dist/types/ammsdk/generated/instructions/disable.d.ts +75 -0
- package/dist/types/ammsdk/generated/instructions/extendAccount.d.ts +58 -0
- package/dist/types/ammsdk/generated/instructions/index.d.ts +26 -0
- package/dist/types/ammsdk/generated/instructions/initUserVolumeAccumulator.d.ts +62 -0
- package/dist/types/ammsdk/generated/instructions/sell.d.ts +131 -0
- package/dist/types/ammsdk/generated/instructions/setCoinCreator.d.ts +58 -0
- package/dist/types/ammsdk/generated/instructions/syncUserVolumeAccumulator.d.ts +58 -0
- package/dist/types/ammsdk/generated/instructions/updateAdmin.d.ts +58 -0
- package/dist/types/ammsdk/generated/instructions/updateFeeConfig.d.ts +75 -0
- package/dist/types/ammsdk/generated/instructions/withdraw.d.ts +111 -0
- package/dist/types/ammsdk/generated/programs/index.d.ts +8 -0
- package/dist/types/ammsdk/generated/programs/pumpAmm.d.ts +84 -0
- package/dist/types/ammsdk/generated/shared/index.d.ts +49 -0
- package/dist/types/ammsdk/generated/types/adminSetCoinCreatorEvent.d.ts +27 -0
- package/dist/types/ammsdk/generated/types/adminUpdateTokenIncentivesEvent.d.ts +29 -0
- package/dist/types/ammsdk/generated/types/buyEvent.d.ts +76 -0
- package/dist/types/ammsdk/generated/types/claimTokenIncentivesEvent.d.ts +27 -0
- package/dist/types/ammsdk/generated/types/closeUserVolumeAccumulatorEvent.d.ts +27 -0
- package/dist/types/ammsdk/generated/types/collectCoinCreatorFeeEvent.d.ts +25 -0
- package/dist/types/ammsdk/generated/types/createConfigEvent.d.ts +29 -0
- package/dist/types/ammsdk/generated/types/createPoolEvent.d.ts +55 -0
- package/dist/types/ammsdk/generated/types/depositEvent.d.ts +47 -0
- package/dist/types/ammsdk/generated/types/disableEvent.d.ts +29 -0
- package/dist/types/ammsdk/generated/types/extendAccountEvent.d.ts +25 -0
- package/dist/types/ammsdk/generated/types/feeTier.d.ts +20 -0
- package/dist/types/ammsdk/generated/types/fees.d.ts +21 -0
- package/dist/types/ammsdk/generated/types/index.d.ts +29 -0
- package/dist/types/ammsdk/generated/types/initUserVolumeAccumulatorEvent.d.ts +21 -0
- package/dist/types/ammsdk/generated/types/optionBool.d.ts +13 -0
- package/dist/types/ammsdk/generated/types/sellEvent.d.ts +61 -0
- package/dist/types/ammsdk/generated/types/setBondingCurveCoinCreatorEvent.d.ts +25 -0
- package/dist/types/ammsdk/generated/types/setMetaplexCoinCreatorEvent.d.ts +25 -0
- package/dist/types/ammsdk/generated/types/syncUserVolumeAccumulatorEvent.d.ts +23 -0
- package/dist/types/ammsdk/generated/types/updateAdminEvent.d.ts +21 -0
- package/dist/types/ammsdk/generated/types/updateFeeConfigEvent.d.ts +29 -0
- package/dist/types/ammsdk/generated/types/withdrawEvent.d.ts +47 -0
- package/dist/types/clients/amm.d.ts +109 -0
- package/dist/types/clients/pump.d.ts +76 -0
- package/dist/types/config/addresses.d.ts +12 -0
- package/dist/types/config/commitment.d.ts +4 -0
- package/dist/types/config/connection.d.ts +10 -0
- package/dist/types/config/constants.d.ts +4 -0
- package/dist/types/config/polyfills.d.ts +1 -0
- package/dist/types/events/pumpEvents.d.ts +30 -0
- package/dist/types/helpers/createAndBuy.d.ts +34 -0
- package/dist/types/index.d.ts +20 -0
- package/dist/types/liquidity.d.ts +47 -0
- package/dist/types/pda/ata.d.ts +29 -0
- package/dist/types/pda/pump.d.ts +46 -0
- package/dist/types/pda/pumpAmm.d.ts +55 -0
- package/dist/types/pumpsdk/generated/accounts/bondingCurve.d.ts +39 -0
- package/dist/types/pumpsdk/generated/accounts/feeConfig.d.ts +33 -0
- package/dist/types/pumpsdk/generated/accounts/global.d.ts +59 -0
- package/dist/types/pumpsdk/generated/accounts/globalVolumeAccumulator.d.ts +37 -0
- package/dist/types/pumpsdk/generated/accounts/index.d.ts +12 -0
- package/dist/types/pumpsdk/generated/accounts/userVolumeAccumulator.d.ts +39 -0
- package/dist/types/pumpsdk/generated/errors/index.d.ts +8 -0
- package/dist/types/pumpsdk/generated/errors/pump.d.ts +105 -0
- package/dist/types/pumpsdk/generated/index.d.ts +12 -0
- package/dist/types/pumpsdk/generated/instructions/adminSetCreator.d.ts +67 -0
- package/dist/types/pumpsdk/generated/instructions/adminSetIdlAuthority.d.ts +71 -0
- package/dist/types/pumpsdk/generated/instructions/adminUpdateTokenIncentives.d.ts +99 -0
- package/dist/types/pumpsdk/generated/instructions/buy.d.ts +116 -0
- package/dist/types/pumpsdk/generated/instructions/buyExactSolIn.d.ts +116 -0
- package/dist/types/pumpsdk/generated/instructions/claimTokenIncentives.d.ts +86 -0
- package/dist/types/pumpsdk/generated/instructions/closeUserVolumeAccumulator.d.ts +54 -0
- package/dist/types/pumpsdk/generated/instructions/collectCreatorFee.d.ts +58 -0
- package/dist/types/pumpsdk/generated/instructions/create.d.ts +111 -0
- package/dist/types/pumpsdk/generated/instructions/extendAccount.d.ts +58 -0
- package/dist/types/pumpsdk/generated/instructions/index.d.ts +26 -0
- package/dist/types/pumpsdk/generated/instructions/initUserVolumeAccumulator.d.ts +62 -0
- package/dist/types/pumpsdk/generated/instructions/initialize.d.ts +50 -0
- package/dist/types/pumpsdk/generated/instructions/migrate.d.ts +134 -0
- package/dist/types/pumpsdk/generated/instructions/sell.d.ts +103 -0
- package/dist/types/pumpsdk/generated/instructions/setCreator.d.ts +71 -0
- package/dist/types/pumpsdk/generated/instructions/setMetaplexCreator.d.ts +58 -0
- package/dist/types/pumpsdk/generated/instructions/setParams.d.ts +99 -0
- package/dist/types/pumpsdk/generated/instructions/syncUserVolumeAccumulator.d.ts +58 -0
- package/dist/types/pumpsdk/generated/instructions/updateGlobalAuthority.d.ts +58 -0
- package/dist/types/pumpsdk/generated/programs/index.d.ts +8 -0
- package/dist/types/pumpsdk/generated/programs/pump.d.ts +83 -0
- package/dist/types/pumpsdk/generated/shared/index.d.ts +49 -0
- package/dist/types/pumpsdk/generated/types/adminSetCreatorEvent.d.ts +27 -0
- package/dist/types/pumpsdk/generated/types/adminSetIdlAuthorityEvent.d.ts +15 -0
- package/dist/types/pumpsdk/generated/types/adminUpdateTokenIncentivesEvent.d.ts +29 -0
- package/dist/types/pumpsdk/generated/types/claimTokenIncentivesEvent.d.ts +27 -0
- package/dist/types/pumpsdk/generated/types/closeUserVolumeAccumulatorEvent.d.ts +27 -0
- package/dist/types/pumpsdk/generated/types/collectCreatorFeeEvent.d.ts +21 -0
- package/dist/types/pumpsdk/generated/types/completeEvent.d.ts +23 -0
- package/dist/types/pumpsdk/generated/types/completePumpAmmMigrationEvent.d.ts +31 -0
- package/dist/types/pumpsdk/generated/types/createEvent.d.ts +39 -0
- package/dist/types/pumpsdk/generated/types/extendAccountEvent.d.ts +25 -0
- package/dist/types/pumpsdk/generated/types/feeTier.d.ts +20 -0
- package/dist/types/pumpsdk/generated/types/fees.d.ts +21 -0
- package/dist/types/pumpsdk/generated/types/index.d.ts +27 -0
- package/dist/types/pumpsdk/generated/types/initUserVolumeAccumulatorEvent.d.ts +21 -0
- package/dist/types/pumpsdk/generated/types/optionBool.d.ts +13 -0
- package/dist/types/pumpsdk/generated/types/setCreatorEvent.d.ts +23 -0
- package/dist/types/pumpsdk/generated/types/setMetaplexCreatorEvent.d.ts +25 -0
- package/dist/types/pumpsdk/generated/types/setParamsEvent.d.ts +43 -0
- package/dist/types/pumpsdk/generated/types/syncUserVolumeAccumulatorEvent.d.ts +23 -0
- package/dist/types/pumpsdk/generated/types/tradeEvent.d.ts +60 -0
- package/dist/types/pumpsdk/generated/types/updateGlobalAuthorityEvent.d.ts +23 -0
- package/dist/types/recipes/buy.d.ts +51 -0
- package/dist/types/recipes/mintFirstBuy.d.ts +51 -0
- package/dist/types/recipes/provideLiquidity.d.ts +42 -0
- package/dist/types/recipes/removeLiquidity.d.ts +40 -0
- package/dist/types/recipes/sell.d.ts +39 -0
- package/dist/types/simple.d.ts +10 -0
- package/dist/types/swap.d.ts +49 -0
- package/dist/types/utils/amounts.d.ts +4 -0
- package/dist/types/utils/ata.d.ts +15 -0
- package/dist/types/utils/slippage.d.ts +37 -0
- package/dist/types/utils/transaction.d.ts +101 -0
- package/dist/types/utils/wsol.d.ts +18 -0
- package/metadata/social.json +8 -0
- package/package.json +56 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
var mq=Object.create;var{getPrototypeOf:gq,defineProperty:l8,getOwnPropertyNames:TG,getOwnPropertyDescriptor:vq}=Object,AG=Object.prototype.hasOwnProperty;var yT=(T,A,P)=>{P=T!=null?mq(gq(T)):{};let Q=A||!T||!T.__esModule?l8(P,"default",{value:T,enumerable:!0}):P;for(let C of TG(T))if(!AG.call(Q,C))l8(Q,C,{get:()=>T[C],enumerable:!0});return Q},eW=new WeakMap,G8=(T)=>{var A=eW.get(T),P;if(A)return A;if(A=l8({},"__esModule",{value:!0}),T&&typeof T==="object"||typeof T==="function")TG(T).map((Q)=>!AG.call(A,Q)&&l8(A,Q,{get:()=>T[Q],enumerable:!(P=vq(T,Q))||P.enumerable}));return eW.set(T,A),A},T0=(T,A)=>()=>(A||T((A={exports:{}}).exports,A),A.exports);var s4=(T,A)=>{for(var P in A)l8(T,P,{get:A[P],enumerable:!0,configurable:!0,set:(Q)=>A[P]=()=>Q})};var jT=(T,A)=>()=>(T&&(A=T(T=0)),A);var QG=T0((cq)=>{cq.byteLength=bq;cq.toByteArray=pq;cq.fromByteArray=rq;var R0=[],A0=[],yq=typeof Uint8Array<"u"?Uint8Array:Array,t4="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for($A=0,e4=t4.length;$A<e4;++$A)R0[$A]=t4[$A],A0[t4.charCodeAt($A)]=$A;var $A,e4;A0[45]=62;A0[95]=63;function PG(T){var A=T.length;if(A%4>0)throw Error("Invalid string. Length must be a multiple of 4");var P=T.indexOf("=");if(P===-1)P=A;var Q=P===A?0:4-P%4;return[P,Q]}function bq(T){var A=PG(T),P=A[0],Q=A[1];return(P+Q)*3/4-Q}function lq(T,A,P){return(A+P)*3/4-P}function pq(T){var A,P=PG(T),Q=P[0],C=P[1],W=new yq(lq(T,Q,C)),G=0,J=C>0?Q-4:Q,$;for($=0;$<J;$+=4)A=A0[T.charCodeAt($)]<<18|A0[T.charCodeAt($+1)]<<12|A0[T.charCodeAt($+2)]<<6|A0[T.charCodeAt($+3)],W[G++]=A>>16&255,W[G++]=A>>8&255,W[G++]=A&255;if(C===2)A=A0[T.charCodeAt($)]<<2|A0[T.charCodeAt($+1)]>>4,W[G++]=A&255;if(C===1)A=A0[T.charCodeAt($)]<<10|A0[T.charCodeAt($+1)]<<4|A0[T.charCodeAt($+2)]>>2,W[G++]=A>>8&255,W[G++]=A&255;return W}function uq(T){return R0[T>>18&63]+R0[T>>12&63]+R0[T>>6&63]+R0[T&63]}function dq(T,A,P){var Q,C=[];for(var W=A;W<P;W+=3)Q=(T[W]<<16&16711680)+(T[W+1]<<8&65280)+(T[W+2]&255),C.push(uq(Q));return C.join("")}function rq(T){var A,P=T.length,Q=P%3,C=[],W=16383;for(var G=0,J=P-Q;G<J;G+=W)C.push(dq(T,G,G+W>J?J:G+W));if(Q===1)A=T[P-1],C.push(R0[A>>2]+R0[A<<4&63]+"==");else if(Q===2)A=(T[P-2]<<8)+T[P-1],C.push(R0[A>>10]+R0[A>>4&63]+R0[A<<2&63]+"=");return C.join("")}});var CG=T0((iq)=>{/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */iq.read=function(T,A,P,Q,C){var W,G,J=C*8-Q-1,$=(1<<J)-1,X=$>>1,Z=-7,R=P?C-1:0,D=P?-1:1,z=T[A+R];R+=D,W=z&(1<<-Z)-1,z>>=-Z,Z+=J;for(;Z>0;W=W*256+T[A+R],R+=D,Z-=8);G=W&(1<<-Z)-1,W>>=-Z,Z+=Q;for(;Z>0;G=G*256+T[A+R],R+=D,Z-=8);if(W===0)W=1-X;else if(W===$)return G?NaN:(z?-1:1)*(1/0);else G=G+Math.pow(2,Q),W=W-X;return(z?-1:1)*G*Math.pow(2,W-Q)};iq.write=function(T,A,P,Q,C,W){var G,J,$,X=W*8-C-1,Z=(1<<X)-1,R=Z>>1,D=C===23?Math.pow(2,-24)-Math.pow(2,-77):0,z=Q?0:W-1,S=Q?1:-1,E=A<0||A===0&&1/A<0?1:0;if(A=Math.abs(A),isNaN(A)||A===1/0)J=isNaN(A)?1:0,G=Z;else{if(G=Math.floor(Math.log(A)/Math.LN2),A*($=Math.pow(2,-G))<1)G--,$*=2;if(G+R>=1)A+=D/$;else A+=D*Math.pow(2,1-R);if(A*$>=2)G++,$/=2;if(G+R>=Z)J=0,G=Z;else if(G+R>=1)J=(A*$-1)*Math.pow(2,C),G=G+R;else J=A*Math.pow(2,R-1)*Math.pow(2,C),G=0}for(;C>=8;T[P+z]=J&255,z+=S,J/=256,C-=8);G=G<<C|J,X+=C;for(;X>0;T[P+z]=G&255,z+=S,G/=256,X-=8);T[P+z-S]|=E*128}});var O6={};s4(O6,{transcode:()=>Zk,resolveObjectURL:()=>Vk,kStringMaxLength:()=>C$,kMaxLength:()=>A2,isUtf8:()=>qk,isAscii:()=>Yk,default:()=>Xk,constants:()=>yR,btoa:()=>hR,atob:()=>mR,INSPECT_MAX_BYTES:()=>Q$,File:()=>gR,Buffer:()=>L,Blob:()=>vR});function ER(T){var A=T.length;if(A%4>0)throw Error("Invalid string. Length must be a multiple of 4");var P=T.indexOf("=");if(P===-1)P=A;var Q=P===A?0:4-P%4;return[P,Q]}function BR(T,A){return(T+A)*3/4-A}function OR(T){var A,P=ER(T),Q=P[0],C=P[1],W=new Uint8Array(BR(Q,C)),G=0,J=C>0?Q-4:Q,$;for($=0;$<J;$+=4)A=G0[T.charCodeAt($)]<<18|G0[T.charCodeAt($+1)]<<12|G0[T.charCodeAt($+2)]<<6|G0[T.charCodeAt($+3)],W[G++]=A>>16&255,W[G++]=A>>8&255,W[G++]=A&255;if(C===2)A=G0[T.charCodeAt($)]<<2|G0[T.charCodeAt($+1)]>>4,W[G++]=A&255;if(C===1)A=G0[T.charCodeAt($)]<<10|G0[T.charCodeAt($+1)]<<4|G0[T.charCodeAt($+2)]>>2,W[G++]=A>>8&255,W[G++]=A&255;return W}function xR(T){return B0[T>>18&63]+B0[T>>12&63]+B0[T>>6&63]+B0[T&63]}function _R(T,A,P){var Q,C=[];for(var W=A;W<P;W+=3)Q=(T[W]<<16&16711680)+(T[W+1]<<8&65280)+(T[W+2]&255),C.push(xR(Q));return C.join("")}function sJ(T){var A,P=T.length,Q=P%3,C=[],W=16383;for(var G=0,J=P-Q;G<J;G+=W)C.push(_R(T,G,G+W>J?J:G+W));if(Q===1)A=T[P-1],C.push(B0[A>>2]+B0[A<<4&63]+"==");else if(Q===2)A=(T[P-2]<<8)+T[P-1],C.push(B0[A>>10]+B0[A>>4&63]+B0[A<<2&63]+"=");return C.join("")}function E6(T,A,P,Q,C){var W,G,J=C*8-Q-1,$=(1<<J)-1,X=$>>1,Z=-7,R=P?C-1:0,D=P?-1:1,z=T[A+R];R+=D,W=z&(1<<-Z)-1,z>>=-Z,Z+=J;for(;Z>0;W=W*256+T[A+R],R+=D,Z-=8);G=W&(1<<-Z)-1,W>>=-Z,Z+=Q;for(;Z>0;G=G*256+T[A+R],R+=D,Z-=8);if(W===0)W=1-X;else if(W===$)return G?NaN:(z?-1:1)*(1/0);else G=G+Math.pow(2,Q),W=W-X;return(z?-1:1)*G*Math.pow(2,W-Q)}function P$(T,A,P,Q,C,W){var G,J,$,X=W*8-C-1,Z=(1<<X)-1,R=Z>>1,D=C===23?Math.pow(2,-24)-Math.pow(2,-77):0,z=Q?0:W-1,S=Q?1:-1,E=A<0||A===0&&1/A<0?1:0;if(A=Math.abs(A),isNaN(A)||A===1/0)J=isNaN(A)?1:0,G=Z;else{if(G=Math.floor(Math.log(A)/Math.LN2),A*($=Math.pow(2,-G))<1)G--,$*=2;if(G+R>=1)A+=D/$;else A+=D*Math.pow(2,1-R);if(A*$>=2)G++,$/=2;if(G+R>=Z)J=0,G=Z;else if(G+R>=1)J=(A*$-1)*Math.pow(2,C),G=G+R;else J=A*Math.pow(2,R-1)*Math.pow(2,C),G=0}for(;C>=8;T[P+z]=J&255,z+=S,J/=256,C-=8);G=G<<C|J,X+=C;for(;X>0;T[P+z]=G&255,z+=S,G/=256,X-=8);T[P+z-S]|=E*128}function n0(T){if(T>A2)throw RangeError('The value "'+T+'" is invalid for option "size"');let A=new Uint8Array(T);return Object.setPrototypeOf(A,L.prototype),A}function BQ(T,A,P){return class extends P{constructor(){super();Object.defineProperty(this,"message",{value:A.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${T}]`,this.stack,delete this.name}get code(){return T}set code(C){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:C,writable:!0})}toString(){return`${this.name} [${T}]: ${this.message}`}}}function L(T,A,P){if(typeof T==="number"){if(typeof A==="string")throw TypeError('The "string" argument must be of type string. Received type number');return OQ(T)}return W$(T,A,P)}function W$(T,A,P){if(typeof T==="string")return uR(T,A);if(ArrayBuffer.isView(T))return dR(T);if(T==null)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof T);if(O0(T,ArrayBuffer)||T&&O0(T.buffer,ArrayBuffer))return LQ(T,A,P);if(typeof SharedArrayBuffer<"u"&&(O0(T,SharedArrayBuffer)||T&&O0(T.buffer,SharedArrayBuffer)))return LQ(T,A,P);if(typeof T==="number")throw TypeError('The "value" argument must not be of type number. Received type number');let Q=T.valueOf&&T.valueOf();if(Q!=null&&Q!==T)return L.from(Q,A,P);let C=rR(T);if(C)return C;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof T[Symbol.toPrimitive]==="function")return L.from(T[Symbol.toPrimitive]("string"),A,P);throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof T)}function G$(T){if(typeof T!=="number")throw TypeError('"size" argument must be of type number');else if(T<0)throw RangeError('The value "'+T+'" is invalid for option "size"')}function pR(T,A,P){if(G$(T),T<=0)return n0(T);if(A!==void 0)return typeof P==="string"?n0(T).fill(A,P):n0(T).fill(A);return n0(T)}function OQ(T){return G$(T),n0(T<0?0:xQ(T)|0)}function uR(T,A){if(typeof A!=="string"||A==="")A="utf8";if(!L.isEncoding(A))throw TypeError("Unknown encoding: "+A);let P=U$(T,A)|0,Q=n0(P),C=Q.write(T,A);if(C!==P)Q=Q.slice(0,C);return Q}function wQ(T){let A=T.length<0?0:xQ(T.length)|0,P=n0(A);for(let Q=0;Q<A;Q+=1)P[Q]=T[Q]&255;return P}function dR(T){if(O0(T,Uint8Array)){let A=new Uint8Array(T);return LQ(A.buffer,A.byteOffset,A.byteLength)}return wQ(T)}function LQ(T,A,P){if(A<0||T.byteLength<A)throw RangeError('"offset" is outside of buffer bounds');if(T.byteLength<A+(P||0))throw RangeError('"length" is outside of buffer bounds');let Q;if(A===void 0&&P===void 0)Q=new Uint8Array(T);else if(P===void 0)Q=new Uint8Array(T,A);else Q=new Uint8Array(T,A,P);return Object.setPrototypeOf(Q,L.prototype),Q}function rR(T){if(L.isBuffer(T)){let A=xQ(T.length)|0,P=n0(A);if(P.length===0)return P;return T.copy(P,0,0,A),P}if(T.length!==void 0){if(typeof T.length!=="number"||Number.isNaN(T.length))return n0(0);return wQ(T)}if(T.type==="Buffer"&&Array.isArray(T.data))return wQ(T.data)}function xQ(T){if(T>=A2)throw RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+A2.toString(16)+" bytes");return T|0}function U$(T,A){if(L.isBuffer(T))return T.length;if(ArrayBuffer.isView(T)||O0(T,ArrayBuffer))return T.byteLength;if(typeof T!=="string")throw TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof T);let P=T.length,Q=arguments.length>2&&arguments[2]===!0;if(!Q&&P===0)return 0;let C=!1;for(;;)switch(A){case"ascii":case"latin1":case"binary":return P;case"utf8":case"utf-8":return EQ(T).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P*2;case"hex":return P>>>1;case"base64":return K$(T).length;default:if(C)return Q?-1:EQ(T).length;A=(""+A).toLowerCase(),C=!0}}function cR(T,A,P){let Q=!1;if(A===void 0||A<0)A=0;if(A>this.length)return"";if(P===void 0||P>this.length)P=this.length;if(P<=0)return"";if(P>>>=0,A>>>=0,P<=A)return"";if(!T)T="utf8";while(!0)switch(T){case"hex":return Ak(this,A,P);case"utf8":case"utf-8":return $$(this,A,P);case"ascii":return eR(this,A,P);case"latin1":case"binary":return Tk(this,A,P);case"base64":return sR(this,A,P);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Pk(this,A,P);default:if(Q)throw TypeError("Unknown encoding: "+T);T=(T+"").toLowerCase(),Q=!0}}function pA(T,A,P){let Q=T[A];T[A]=T[P],T[P]=Q}function J$(T,A,P,Q,C){if(T.length===0)return-1;if(typeof P==="string")Q=P,P=0;else if(P>2147483647)P=2147483647;else if(P<-2147483648)P=-2147483648;if(P=+P,Number.isNaN(P))P=C?0:T.length-1;if(P<0)P=T.length+P;if(P>=T.length)if(C)return-1;else P=T.length-1;else if(P<0)if(C)P=0;else return-1;if(typeof A==="string")A=L.from(A,Q);if(L.isBuffer(A)){if(A.length===0)return-1;return eJ(T,A,P,Q,C)}else if(typeof A==="number"){if(A=A&255,typeof Uint8Array.prototype.indexOf==="function")if(C)return Uint8Array.prototype.indexOf.call(T,A,P);else return Uint8Array.prototype.lastIndexOf.call(T,A,P);return eJ(T,[A],P,Q,C)}throw TypeError("val must be string, number or Buffer")}function eJ(T,A,P,Q,C){let W=1,G=T.length,J=A.length;if(Q!==void 0){if(Q=String(Q).toLowerCase(),Q==="ucs2"||Q==="ucs-2"||Q==="utf16le"||Q==="utf-16le"){if(T.length<2||A.length<2)return-1;W=2,G/=2,J/=2,P/=2}}function $(Z,R){if(W===1)return Z[R];else return Z.readUInt16BE(R*W)}let X;if(C){let Z=-1;for(X=P;X<G;X++)if($(T,X)===$(A,Z===-1?0:X-Z)){if(Z===-1)Z=X;if(X-Z+1===J)return Z*W}else{if(Z!==-1)X-=X-Z;Z=-1}}else{if(P+J>G)P=G-J;for(X=P;X>=0;X--){let Z=!0;for(let R=0;R<J;R++)if($(T,X+R)!==$(A,R)){Z=!1;break}if(Z)return X}}return-1}function oR(T,A,P,Q){P=Number(P)||0;let C=T.length-P;if(!Q)Q=C;else if(Q=Number(Q),Q>C)Q=C;let W=A.length;if(Q>W/2)Q=W/2;let G;for(G=0;G<Q;++G){let J=parseInt(A.substr(G*2,2),16);if(Number.isNaN(J))return G;T[P+G]=J}return G}function nR(T,A,P,Q){return B6(EQ(A,T.length-P),T,P,Q)}function fR(T,A,P,Q){return B6(Gk(A),T,P,Q)}function iR(T,A,P,Q){return B6(K$(A),T,P,Q)}function aR(T,A,P,Q){return B6(Uk(A,T.length-P),T,P,Q)}function sR(T,A,P){if(A===0&&P===T.length)return sJ(T);else return sJ(T.slice(A,P))}function $$(T,A,P){P=Math.min(T.length,P);let Q=[],C=A;while(C<P){let W=T[C],G=null,J=W>239?4:W>223?3:W>191?2:1;if(C+J<=P){let $,X,Z,R;switch(J){case 1:if(W<128)G=W;break;case 2:if($=T[C+1],($&192)===128){if(R=(W&31)<<6|$&63,R>127)G=R}break;case 3:if($=T[C+1],X=T[C+2],($&192)===128&&(X&192)===128){if(R=(W&15)<<12|($&63)<<6|X&63,R>2047&&(R<55296||R>57343))G=R}break;case 4:if($=T[C+1],X=T[C+2],Z=T[C+3],($&192)===128&&(X&192)===128&&(Z&192)===128){if(R=(W&15)<<18|($&63)<<12|(X&63)<<6|Z&63,R>65535&&R<1114112)G=R}}}if(G===null)G=65533,J=1;else if(G>65535)G-=65536,Q.push(G>>>10&1023|55296),G=56320|G&1023;Q.push(G),C+=J}return tR(Q)}function tR(T){let A=T.length;if(A<=T$)return String.fromCharCode.apply(String,T);let P="",Q=0;while(Q<A)P+=String.fromCharCode.apply(String,T.slice(Q,Q+=T$));return P}function eR(T,A,P){let Q="";P=Math.min(T.length,P);for(let C=A;C<P;++C)Q+=String.fromCharCode(T[C]&127);return Q}function Tk(T,A,P){let Q="";P=Math.min(T.length,P);for(let C=A;C<P;++C)Q+=String.fromCharCode(T[C]);return Q}function Ak(T,A,P){let Q=T.length;if(!A||A<0)A=0;if(!P||P<0||P>Q)P=Q;let C="";for(let W=A;W<P;++W)C+=Jk[T[W]];return C}function Pk(T,A,P){let Q=T.slice(A,P),C="";for(let W=0;W<Q.length-1;W+=2)C+=String.fromCharCode(Q[W]+Q[W+1]*256);return C}function YT(T,A,P){if(T%1!==0||T<0)throw RangeError("offset is not uint");if(T+A>P)throw RangeError("Trying to access beyond buffer length")}function rT(T,A,P,Q,C,W){if(!L.isBuffer(T))throw TypeError('"buffer" argument must be a Buffer instance');if(A>C||A<W)throw RangeError('"value" argument is out of bounds');if(P+Q>T.length)throw RangeError("Index out of range")}function V$(T,A,P,Q,C){H$(A,Q,C,T,P,7);let W=Number(A&BigInt(4294967295));T[P++]=W,W=W>>8,T[P++]=W,W=W>>8,T[P++]=W,W=W>>8,T[P++]=W;let G=Number(A>>BigInt(32)&BigInt(4294967295));return T[P++]=G,G=G>>8,T[P++]=G,G=G>>8,T[P++]=G,G=G>>8,T[P++]=G,P}function q$(T,A,P,Q,C){H$(A,Q,C,T,P,7);let W=Number(A&BigInt(4294967295));T[P+7]=W,W=W>>8,T[P+6]=W,W=W>>8,T[P+5]=W,W=W>>8,T[P+4]=W;let G=Number(A>>BigInt(32)&BigInt(4294967295));return T[P+3]=G,G=G>>8,T[P+2]=G,G=G>>8,T[P+1]=G,G=G>>8,T[P]=G,P+8}function Y$(T,A,P,Q,C,W){if(P+Q>T.length)throw RangeError("Index out of range");if(P<0)throw RangeError("Index out of range")}function Z$(T,A,P,Q,C){if(A=+A,P=P>>>0,!C)Y$(T,A,P,4,340282346638528860000000000000000000000,-340282346638528860000000000000000000000);return P$(T,A,P,Q,23,4),P+4}function X$(T,A,P,Q,C){if(A=+A,P=P>>>0,!C)Y$(T,A,P,8,179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,-179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000);return P$(T,A,P,Q,52,8),P+8}function A$(T){let A="",P=T.length,Q=T[0]==="-"?1:0;for(;P>=Q+4;P-=3)A=`_${T.slice(P-3,P)}${A}`;return`${T.slice(0,P)}${A}`}function Qk(T,A,P){if(k8(A,"offset"),T[A]===void 0||T[A+P]===void 0)P2(A,T.length-(P+1))}function H$(T,A,P,Q,C,W){if(T>P||T<A){let G=typeof A==="bigint"?"n":"",J;if(W>3)if(A===0||A===BigInt(0))J=`>= 0${G} and < 2${G} ** ${(W+1)*8}${G}`;else J=`>= -(2${G} ** ${(W+1)*8-1}${G}) and < 2 ** ${(W+1)*8-1}${G}`;else J=`>= ${A}${G} and <= ${P}${G}`;throw new NQ("value",J,T)}Qk(Q,C,W)}function k8(T,A){if(typeof T!=="number")throw new lR(A,"number",T)}function P2(T,A,P){if(Math.floor(T)!==T)throw k8(T,P),new NQ(P||"offset","an integer",T);if(A<0)throw new bR;throw new NQ(P||"offset",`>= ${P?1:0} and <= ${A}`,T)}function Wk(T){if(T=T.split("=")[0],T=T.trim().replace(Ck,""),T.length<2)return"";while(T.length%4!==0)T=T+"=";return T}function EQ(T,A){A=A||1/0;let P,Q=T.length,C=null,W=[];for(let G=0;G<Q;++G){if(P=T.charCodeAt(G),P>55295&&P<57344){if(!C){if(P>56319){if((A-=3)>-1)W.push(239,191,189);continue}else if(G+1===Q){if((A-=3)>-1)W.push(239,191,189);continue}C=P;continue}if(P<56320){if((A-=3)>-1)W.push(239,191,189);C=P;continue}P=(C-55296<<10|P-56320)+65536}else if(C){if((A-=3)>-1)W.push(239,191,189)}if(C=null,P<128){if((A-=1)<0)break;W.push(P)}else if(P<2048){if((A-=2)<0)break;W.push(P>>6|192,P&63|128)}else if(P<65536){if((A-=3)<0)break;W.push(P>>12|224,P>>6&63|128,P&63|128)}else if(P<1114112){if((A-=4)<0)break;W.push(P>>18|240,P>>12&63|128,P>>6&63|128,P&63|128)}else throw Error("Invalid code point")}return W}function Gk(T){let A=[];for(let P=0;P<T.length;++P)A.push(T.charCodeAt(P)&255);return A}function Uk(T,A){let P,Q,C,W=[];for(let G=0;G<T.length;++G){if((A-=2)<0)break;P=T.charCodeAt(G),Q=P>>8,C=P%256,W.push(C),W.push(Q)}return W}function K$(T){return OR(Wk(T))}function B6(T,A,P,Q){let C;for(C=0;C<Q;++C){if(C+P>=A.length||C>=T.length)break;A[C+P]=T[C]}return C}function O0(T,A){return T instanceof A||T!=null&&T.constructor!=null&&T.constructor.name!=null&&T.constructor.name===A.name}function HA(T){return typeof BigInt>"u"?$k:T}function $k(){throw Error("BigInt not supported")}function _Q(T){return()=>{throw Error(T+" is not implemented for node:buffer browser polyfill")}}var B0,G0,SQ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",lA,aJ,tJ,Q$=50,A2=2147483647,C$=536870888,hR,mR,gR,vR,yR,bR,lR,NQ,T$=4096,Ck,Jk,Vk,qk,Yk=(T)=>{for(let A of T)if(A.charCodeAt(0)>127)return!1;return!0},Zk,Xk;var j8=jT(()=>{B0=[],G0=[];for(lA=0,aJ=SQ.length;lA<aJ;++lA)B0[lA]=SQ[lA],G0[SQ.charCodeAt(lA)]=lA;G0[45]=62;G0[95]=63;tJ=typeof Symbol==="function"&&typeof Symbol.for==="function"?Symbol.for("nodejs.util.inspect.custom"):null,hR=globalThis.btoa,mR=globalThis.atob,gR=globalThis.File,vR=globalThis.Blob,yR={MAX_LENGTH:A2,MAX_STRING_LENGTH:C$};bR=BQ("ERR_BUFFER_OUT_OF_BOUNDS",function(T){if(T)return`${T} is outside of buffer bounds`;return"Attempt to access memory outside buffer bounds"},RangeError),lR=BQ("ERR_INVALID_ARG_TYPE",function(T,A){return`The "${T}" argument must be of type number. Received type ${typeof A}`},TypeError),NQ=BQ("ERR_OUT_OF_RANGE",function(T,A,P){let Q=`The value of "${T}" is out of range.`,C=P;if(Number.isInteger(P)&&Math.abs(P)>4294967296)C=A$(String(P));else if(typeof P==="bigint"){if(C=String(P),P>BigInt(2)**BigInt(32)||P<-(BigInt(2)**BigInt(32)))C=A$(C);C+="n"}return Q+=` It must be ${A}. Received ${C}`,Q},RangeError);Object.defineProperty(L.prototype,"parent",{enumerable:!0,get:function(){if(!L.isBuffer(this))return;return this.buffer}});Object.defineProperty(L.prototype,"offset",{enumerable:!0,get:function(){if(!L.isBuffer(this))return;return this.byteOffset}});L.poolSize=8192;L.from=function(T,A,P){return W$(T,A,P)};Object.setPrototypeOf(L.prototype,Uint8Array.prototype);Object.setPrototypeOf(L,Uint8Array);L.alloc=function(T,A,P){return pR(T,A,P)};L.allocUnsafe=function(T){return OQ(T)};L.allocUnsafeSlow=function(T){return OQ(T)};L.isBuffer=function(A){return A!=null&&A._isBuffer===!0&&A!==L.prototype};L.compare=function(A,P){if(O0(A,Uint8Array))A=L.from(A,A.offset,A.byteLength);if(O0(P,Uint8Array))P=L.from(P,P.offset,P.byteLength);if(!L.isBuffer(A)||!L.isBuffer(P))throw TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(A===P)return 0;let Q=A.length,C=P.length;for(let W=0,G=Math.min(Q,C);W<G;++W)if(A[W]!==P[W]){Q=A[W],C=P[W];break}if(Q<C)return-1;if(C<Q)return 1;return 0};L.isEncoding=function(A){switch(String(A).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};L.concat=function(A,P){if(!Array.isArray(A))throw TypeError('"list" argument must be an Array of Buffers');if(A.length===0)return L.alloc(0);let Q;if(P===void 0){P=0;for(Q=0;Q<A.length;++Q)P+=A[Q].length}let C=L.allocUnsafe(P),W=0;for(Q=0;Q<A.length;++Q){let G=A[Q];if(O0(G,Uint8Array))if(W+G.length>C.length){if(!L.isBuffer(G))G=L.from(G);G.copy(C,W)}else Uint8Array.prototype.set.call(C,G,W);else if(!L.isBuffer(G))throw TypeError('"list" argument must be an Array of Buffers');else G.copy(C,W);W+=G.length}return C};L.byteLength=U$;L.prototype._isBuffer=!0;L.prototype.swap16=function(){let A=this.length;if(A%2!==0)throw RangeError("Buffer size must be a multiple of 16-bits");for(let P=0;P<A;P+=2)pA(this,P,P+1);return this};L.prototype.swap32=function(){let A=this.length;if(A%4!==0)throw RangeError("Buffer size must be a multiple of 32-bits");for(let P=0;P<A;P+=4)pA(this,P,P+3),pA(this,P+1,P+2);return this};L.prototype.swap64=function(){let A=this.length;if(A%8!==0)throw RangeError("Buffer size must be a multiple of 64-bits");for(let P=0;P<A;P+=8)pA(this,P,P+7),pA(this,P+1,P+6),pA(this,P+2,P+5),pA(this,P+3,P+4);return this};L.prototype.toString=function(){let A=this.length;if(A===0)return"";if(arguments.length===0)return $$(this,0,A);return cR.apply(this,arguments)};L.prototype.toLocaleString=L.prototype.toString;L.prototype.equals=function(A){if(!L.isBuffer(A))throw TypeError("Argument must be a Buffer");if(this===A)return!0;return L.compare(this,A)===0};L.prototype.inspect=function(){let A="",P=Q$;if(A=this.toString("hex",0,P).replace(/(.{2})/g,"$1 ").trim(),this.length>P)A+=" ... ";return"<Buffer "+A+">"};if(tJ)L.prototype[tJ]=L.prototype.inspect;L.prototype.compare=function(A,P,Q,C,W){if(O0(A,Uint8Array))A=L.from(A,A.offset,A.byteLength);if(!L.isBuffer(A))throw TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof A);if(P===void 0)P=0;if(Q===void 0)Q=A?A.length:0;if(C===void 0)C=0;if(W===void 0)W=this.length;if(P<0||Q>A.length||C<0||W>this.length)throw RangeError("out of range index");if(C>=W&&P>=Q)return 0;if(C>=W)return-1;if(P>=Q)return 1;if(P>>>=0,Q>>>=0,C>>>=0,W>>>=0,this===A)return 0;let G=W-C,J=Q-P,$=Math.min(G,J),X=this.slice(C,W),Z=A.slice(P,Q);for(let R=0;R<$;++R)if(X[R]!==Z[R]){G=X[R],J=Z[R];break}if(G<J)return-1;if(J<G)return 1;return 0};L.prototype.includes=function(A,P,Q){return this.indexOf(A,P,Q)!==-1};L.prototype.indexOf=function(A,P,Q){return J$(this,A,P,Q,!0)};L.prototype.lastIndexOf=function(A,P,Q){return J$(this,A,P,Q,!1)};L.prototype.write=function(A,P,Q,C){if(P===void 0)C="utf8",Q=this.length,P=0;else if(Q===void 0&&typeof P==="string")C=P,Q=this.length,P=0;else if(isFinite(P))if(P=P>>>0,isFinite(Q)){if(Q=Q>>>0,C===void 0)C="utf8"}else C=Q,Q=void 0;else throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let W=this.length-P;if(Q===void 0||Q>W)Q=W;if(A.length>0&&(Q<0||P<0)||P>this.length)throw RangeError("Attempt to write outside buffer bounds");if(!C)C="utf8";let G=!1;for(;;)switch(C){case"hex":return oR(this,A,P,Q);case"utf8":case"utf-8":return nR(this,A,P,Q);case"ascii":case"latin1":case"binary":return fR(this,A,P,Q);case"base64":return iR(this,A,P,Q);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return aR(this,A,P,Q);default:if(G)throw TypeError("Unknown encoding: "+C);C=(""+C).toLowerCase(),G=!0}};L.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};L.prototype.slice=function(A,P){let Q=this.length;if(A=~~A,P=P===void 0?Q:~~P,A<0){if(A+=Q,A<0)A=0}else if(A>Q)A=Q;if(P<0){if(P+=Q,P<0)P=0}else if(P>Q)P=Q;if(P<A)P=A;let C=this.subarray(A,P);return Object.setPrototypeOf(C,L.prototype),C};L.prototype.readUintLE=L.prototype.readUIntLE=function(A,P,Q){if(A=A>>>0,P=P>>>0,!Q)YT(A,P,this.length);let C=this[A],W=1,G=0;while(++G<P&&(W*=256))C+=this[A+G]*W;return C};L.prototype.readUintBE=L.prototype.readUIntBE=function(A,P,Q){if(A=A>>>0,P=P>>>0,!Q)YT(A,P,this.length);let C=this[A+--P],W=1;while(P>0&&(W*=256))C+=this[A+--P]*W;return C};L.prototype.readUint8=L.prototype.readUInt8=function(A,P){if(A=A>>>0,!P)YT(A,1,this.length);return this[A]};L.prototype.readUint16LE=L.prototype.readUInt16LE=function(A,P){if(A=A>>>0,!P)YT(A,2,this.length);return this[A]|this[A+1]<<8};L.prototype.readUint16BE=L.prototype.readUInt16BE=function(A,P){if(A=A>>>0,!P)YT(A,2,this.length);return this[A]<<8|this[A+1]};L.prototype.readUint32LE=L.prototype.readUInt32LE=function(A,P){if(A=A>>>0,!P)YT(A,4,this.length);return(this[A]|this[A+1]<<8|this[A+2]<<16)+this[A+3]*16777216};L.prototype.readUint32BE=L.prototype.readUInt32BE=function(A,P){if(A=A>>>0,!P)YT(A,4,this.length);return this[A]*16777216+(this[A+1]<<16|this[A+2]<<8|this[A+3])};L.prototype.readBigUInt64LE=HA(function(A){A=A>>>0,k8(A,"offset");let P=this[A],Q=this[A+7];if(P===void 0||Q===void 0)P2(A,this.length-8);let C=P+this[++A]*256+this[++A]*65536+this[++A]*16777216,W=this[++A]+this[++A]*256+this[++A]*65536+Q*16777216;return BigInt(C)+(BigInt(W)<<BigInt(32))});L.prototype.readBigUInt64BE=HA(function(A){A=A>>>0,k8(A,"offset");let P=this[A],Q=this[A+7];if(P===void 0||Q===void 0)P2(A,this.length-8);let C=P*16777216+this[++A]*65536+this[++A]*256+this[++A],W=this[++A]*16777216+this[++A]*65536+this[++A]*256+Q;return(BigInt(C)<<BigInt(32))+BigInt(W)});L.prototype.readIntLE=function(A,P,Q){if(A=A>>>0,P=P>>>0,!Q)YT(A,P,this.length);let C=this[A],W=1,G=0;while(++G<P&&(W*=256))C+=this[A+G]*W;if(W*=128,C>=W)C-=Math.pow(2,8*P);return C};L.prototype.readIntBE=function(A,P,Q){if(A=A>>>0,P=P>>>0,!Q)YT(A,P,this.length);let C=P,W=1,G=this[A+--C];while(C>0&&(W*=256))G+=this[A+--C]*W;if(W*=128,G>=W)G-=Math.pow(2,8*P);return G};L.prototype.readInt8=function(A,P){if(A=A>>>0,!P)YT(A,1,this.length);if(!(this[A]&128))return this[A];return(255-this[A]+1)*-1};L.prototype.readInt16LE=function(A,P){if(A=A>>>0,!P)YT(A,2,this.length);let Q=this[A]|this[A+1]<<8;return Q&32768?Q|4294901760:Q};L.prototype.readInt16BE=function(A,P){if(A=A>>>0,!P)YT(A,2,this.length);let Q=this[A+1]|this[A]<<8;return Q&32768?Q|4294901760:Q};L.prototype.readInt32LE=function(A,P){if(A=A>>>0,!P)YT(A,4,this.length);return this[A]|this[A+1]<<8|this[A+2]<<16|this[A+3]<<24};L.prototype.readInt32BE=function(A,P){if(A=A>>>0,!P)YT(A,4,this.length);return this[A]<<24|this[A+1]<<16|this[A+2]<<8|this[A+3]};L.prototype.readBigInt64LE=HA(function(A){A=A>>>0,k8(A,"offset");let P=this[A],Q=this[A+7];if(P===void 0||Q===void 0)P2(A,this.length-8);let C=this[A+4]+this[A+5]*256+this[A+6]*65536+(Q<<24);return(BigInt(C)<<BigInt(32))+BigInt(P+this[++A]*256+this[++A]*65536+this[++A]*16777216)});L.prototype.readBigInt64BE=HA(function(A){A=A>>>0,k8(A,"offset");let P=this[A],Q=this[A+7];if(P===void 0||Q===void 0)P2(A,this.length-8);let C=(P<<24)+this[++A]*65536+this[++A]*256+this[++A];return(BigInt(C)<<BigInt(32))+BigInt(this[++A]*16777216+this[++A]*65536+this[++A]*256+Q)});L.prototype.readFloatLE=function(A,P){if(A=A>>>0,!P)YT(A,4,this.length);return E6(this,A,!0,23,4)};L.prototype.readFloatBE=function(A,P){if(A=A>>>0,!P)YT(A,4,this.length);return E6(this,A,!1,23,4)};L.prototype.readDoubleLE=function(A,P){if(A=A>>>0,!P)YT(A,8,this.length);return E6(this,A,!0,52,8)};L.prototype.readDoubleBE=function(A,P){if(A=A>>>0,!P)YT(A,8,this.length);return E6(this,A,!1,52,8)};L.prototype.writeUintLE=L.prototype.writeUIntLE=function(A,P,Q,C){if(A=+A,P=P>>>0,Q=Q>>>0,!C){let J=Math.pow(2,8*Q)-1;rT(this,A,P,Q,J,0)}let W=1,G=0;this[P]=A&255;while(++G<Q&&(W*=256))this[P+G]=A/W&255;return P+Q};L.prototype.writeUintBE=L.prototype.writeUIntBE=function(A,P,Q,C){if(A=+A,P=P>>>0,Q=Q>>>0,!C){let J=Math.pow(2,8*Q)-1;rT(this,A,P,Q,J,0)}let W=Q-1,G=1;this[P+W]=A&255;while(--W>=0&&(G*=256))this[P+W]=A/G&255;return P+Q};L.prototype.writeUint8=L.prototype.writeUInt8=function(A,P,Q){if(A=+A,P=P>>>0,!Q)rT(this,A,P,1,255,0);return this[P]=A&255,P+1};L.prototype.writeUint16LE=L.prototype.writeUInt16LE=function(A,P,Q){if(A=+A,P=P>>>0,!Q)rT(this,A,P,2,65535,0);return this[P]=A&255,this[P+1]=A>>>8,P+2};L.prototype.writeUint16BE=L.prototype.writeUInt16BE=function(A,P,Q){if(A=+A,P=P>>>0,!Q)rT(this,A,P,2,65535,0);return this[P]=A>>>8,this[P+1]=A&255,P+2};L.prototype.writeUint32LE=L.prototype.writeUInt32LE=function(A,P,Q){if(A=+A,P=P>>>0,!Q)rT(this,A,P,4,4294967295,0);return this[P+3]=A>>>24,this[P+2]=A>>>16,this[P+1]=A>>>8,this[P]=A&255,P+4};L.prototype.writeUint32BE=L.prototype.writeUInt32BE=function(A,P,Q){if(A=+A,P=P>>>0,!Q)rT(this,A,P,4,4294967295,0);return this[P]=A>>>24,this[P+1]=A>>>16,this[P+2]=A>>>8,this[P+3]=A&255,P+4};L.prototype.writeBigUInt64LE=HA(function(A,P=0){return V$(this,A,P,BigInt(0),BigInt("0xffffffffffffffff"))});L.prototype.writeBigUInt64BE=HA(function(A,P=0){return q$(this,A,P,BigInt(0),BigInt("0xffffffffffffffff"))});L.prototype.writeIntLE=function(A,P,Q,C){if(A=+A,P=P>>>0,!C){let $=Math.pow(2,8*Q-1);rT(this,A,P,Q,$-1,-$)}let W=0,G=1,J=0;this[P]=A&255;while(++W<Q&&(G*=256)){if(A<0&&J===0&&this[P+W-1]!==0)J=1;this[P+W]=(A/G>>0)-J&255}return P+Q};L.prototype.writeIntBE=function(A,P,Q,C){if(A=+A,P=P>>>0,!C){let $=Math.pow(2,8*Q-1);rT(this,A,P,Q,$-1,-$)}let W=Q-1,G=1,J=0;this[P+W]=A&255;while(--W>=0&&(G*=256)){if(A<0&&J===0&&this[P+W+1]!==0)J=1;this[P+W]=(A/G>>0)-J&255}return P+Q};L.prototype.writeInt8=function(A,P,Q){if(A=+A,P=P>>>0,!Q)rT(this,A,P,1,127,-128);if(A<0)A=255+A+1;return this[P]=A&255,P+1};L.prototype.writeInt16LE=function(A,P,Q){if(A=+A,P=P>>>0,!Q)rT(this,A,P,2,32767,-32768);return this[P]=A&255,this[P+1]=A>>>8,P+2};L.prototype.writeInt16BE=function(A,P,Q){if(A=+A,P=P>>>0,!Q)rT(this,A,P,2,32767,-32768);return this[P]=A>>>8,this[P+1]=A&255,P+2};L.prototype.writeInt32LE=function(A,P,Q){if(A=+A,P=P>>>0,!Q)rT(this,A,P,4,2147483647,-2147483648);return this[P]=A&255,this[P+1]=A>>>8,this[P+2]=A>>>16,this[P+3]=A>>>24,P+4};L.prototype.writeInt32BE=function(A,P,Q){if(A=+A,P=P>>>0,!Q)rT(this,A,P,4,2147483647,-2147483648);if(A<0)A=4294967295+A+1;return this[P]=A>>>24,this[P+1]=A>>>16,this[P+2]=A>>>8,this[P+3]=A&255,P+4};L.prototype.writeBigInt64LE=HA(function(A,P=0){return V$(this,A,P,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});L.prototype.writeBigInt64BE=HA(function(A,P=0){return q$(this,A,P,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});L.prototype.writeFloatLE=function(A,P,Q){return Z$(this,A,P,!0,Q)};L.prototype.writeFloatBE=function(A,P,Q){return Z$(this,A,P,!1,Q)};L.prototype.writeDoubleLE=function(A,P,Q){return X$(this,A,P,!0,Q)};L.prototype.writeDoubleBE=function(A,P,Q){return X$(this,A,P,!1,Q)};L.prototype.copy=function(A,P,Q,C){if(!L.isBuffer(A))throw TypeError("argument should be a Buffer");if(!Q)Q=0;if(!C&&C!==0)C=this.length;if(P>=A.length)P=A.length;if(!P)P=0;if(C>0&&C<Q)C=Q;if(C===Q)return 0;if(A.length===0||this.length===0)return 0;if(P<0)throw RangeError("targetStart out of bounds");if(Q<0||Q>=this.length)throw RangeError("Index out of range");if(C<0)throw RangeError("sourceEnd out of bounds");if(C>this.length)C=this.length;if(A.length-P<C-Q)C=A.length-P+Q;let W=C-Q;if(this===A&&typeof Uint8Array.prototype.copyWithin==="function")this.copyWithin(P,Q,C);else Uint8Array.prototype.set.call(A,this.subarray(Q,C),P);return W};L.prototype.fill=function(A,P,Q,C){if(typeof A==="string"){if(typeof P==="string")C=P,P=0,Q=this.length;else if(typeof Q==="string")C=Q,Q=this.length;if(C!==void 0&&typeof C!=="string")throw TypeError("encoding must be a string");if(typeof C==="string"&&!L.isEncoding(C))throw TypeError("Unknown encoding: "+C);if(A.length===1){let G=A.charCodeAt(0);if(C==="utf8"&&G<128||C==="latin1")A=G}}else if(typeof A==="number")A=A&255;else if(typeof A==="boolean")A=Number(A);if(P<0||this.length<P||this.length<Q)throw RangeError("Out of range index");if(Q<=P)return this;if(P=P>>>0,Q=Q===void 0?this.length:Q>>>0,!A)A=0;let W;if(typeof A==="number")for(W=P;W<Q;++W)this[W]=A;else{let G=L.isBuffer(A)?A:L.from(A,C),J=G.length;if(J===0)throw TypeError('The value "'+A+'" is invalid for argument "value"');for(W=0;W<Q-P;++W)this[W+P]=G[W%J]}return this};Ck=/[^+/0-9A-Za-z-_]/g;Jk=function(){let T=Array(256);for(let A=0;A<16;++A){let P=A*16;for(let Q=0;Q<16;++Q)T[P+Q]="0123456789abcdef"[A]+"0123456789abcdef"[Q]}return T}();Vk=_Q("resolveObjectURL"),qk=_Q("isUtf8"),Zk=_Q("transcode"),Xk=L});var WC=T0((G9,CC)=>{(function(T,A){function P(k,U){if(!k)throw Error(U||"Assertion failed")}function Q(k,U){k.super_=U;var V=function(){};V.prototype=U.prototype,k.prototype=new V,k.prototype.constructor=k}function C(k,U,V){if(C.isBN(k))return k;if(this.negative=0,this.words=null,this.length=0,this.red=null,k!==null){if(U==="le"||U==="be")V=U,U=10;this._init(k||0,U||10,V||"be")}}if(typeof T==="object")T.exports=C;else A.BN=C;C.BN=C,C.wordSize=26;var W;try{if(typeof window<"u"&&typeof window.Buffer<"u")W=window.Buffer;else W=(j8(),G8(O6)).Buffer}catch(k){}C.isBN=function(U){if(U instanceof C)return!0;return U!==null&&typeof U==="object"&&U.constructor.wordSize===C.wordSize&&Array.isArray(U.words)},C.max=function(U,V){if(U.cmp(V)>0)return U;return V},C.min=function(U,V){if(U.cmp(V)<0)return U;return V},C.prototype._init=function(U,V,Y){if(typeof U==="number")return this._initNumber(U,V,Y);if(typeof U==="object")return this._initArray(U,V,Y);if(V==="hex")V=16;P(V===(V|0)&&V>=2&&V<=36),U=U.toString().replace(/\s+/g,"");var H=0;if(U[0]==="-")H++,this.negative=1;if(H<U.length){if(V===16)this._parseHex(U,H,Y);else if(this._parseBase(U,V,H),Y==="le")this._initArray(this.toArray(),V,Y)}},C.prototype._initNumber=function(U,V,Y){if(U<0)this.negative=1,U=-U;if(U<67108864)this.words=[U&67108863],this.length=1;else if(U<4503599627370496)this.words=[U&67108863,U/67108864&67108863],this.length=2;else P(U<9007199254740992),this.words=[U&67108863,U/67108864&67108863,1],this.length=3;if(Y!=="le")return;this._initArray(this.toArray(),V,Y)},C.prototype._initArray=function(U,V,Y){if(P(typeof U.length==="number"),U.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(U.length/3),this.words=Array(this.length);for(var H=0;H<this.length;H++)this.words[H]=0;var K,M,I=0;if(Y==="be"){for(H=U.length-1,K=0;H>=0;H-=3)if(M=U[H]|U[H-1]<<8|U[H-2]<<16,this.words[K]|=M<<I&67108863,this.words[K+1]=M>>>26-I&67108863,I+=24,I>=26)I-=26,K++}else if(Y==="le"){for(H=0,K=0;H<U.length;H+=3)if(M=U[H]|U[H+1]<<8|U[H+2]<<16,this.words[K]|=M<<I&67108863,this.words[K+1]=M>>>26-I&67108863,I+=24,I>=26)I-=26,K++}return this._strip()};function G(k,U){var V=k.charCodeAt(U);if(V>=48&&V<=57)return V-48;else if(V>=65&&V<=70)return V-55;else if(V>=97&&V<=102)return V-87;else P(!1,"Invalid character in "+k)}function J(k,U,V){var Y=G(k,V);if(V-1>=U)Y|=G(k,V-1)<<4;return Y}C.prototype._parseHex=function(U,V,Y){this.length=Math.ceil((U.length-V)/6),this.words=Array(this.length);for(var H=0;H<this.length;H++)this.words[H]=0;var K=0,M=0,I;if(Y==="be")for(H=U.length-1;H>=V;H-=2)if(I=J(U,V,H)<<K,this.words[M]|=I&67108863,K>=18)K-=18,M+=1,this.words[M]|=I>>>26;else K+=8;else{var j=U.length-V;for(H=j%2===0?V+1:V;H<U.length;H+=2)if(I=J(U,V,H)<<K,this.words[M]|=I&67108863,K>=18)K-=18,M+=1,this.words[M]|=I>>>26;else K+=8}this._strip()};function $(k,U,V,Y){var H=0,K=0,M=Math.min(k.length,V);for(var I=U;I<M;I++){var j=k.charCodeAt(I)-48;if(H*=Y,j>=49)K=j-49+10;else if(j>=17)K=j-17+10;else K=j;P(j>=0&&K<Y,"Invalid character"),H+=K}return H}C.prototype._parseBase=function(U,V,Y){this.words=[0],this.length=1;for(var H=0,K=1;K<=67108863;K*=V)H++;H--,K=K/V|0;var M=U.length-Y,I=M%H,j=Math.min(M,M-I)+Y,q=0;for(var F=Y;F<j;F+=H)if(q=$(U,F,F+H,V),this.imuln(K),this.words[0]+q<67108864)this.words[0]+=q;else this._iaddn(q);if(I!==0){var y=1;q=$(U,F,U.length,V);for(F=0;F<I;F++)y*=V;if(this.imuln(y),this.words[0]+q<67108864)this.words[0]+=q;else this._iaddn(q)}this._strip()},C.prototype.copy=function(U){U.words=Array(this.length);for(var V=0;V<this.length;V++)U.words[V]=this.words[V];U.length=this.length,U.negative=this.negative,U.red=this.red};function X(k,U){k.words=U.words,k.length=U.length,k.negative=U.negative,k.red=U.red}if(C.prototype._move=function(U){X(U,this)},C.prototype.clone=function(){var U=new C(null);return this.copy(U),U},C.prototype._expand=function(U){while(this.length<U)this.words[this.length++]=0;return this},C.prototype._strip=function(){while(this.length>1&&this.words[this.length-1]===0)this.length--;return this._normSign()},C.prototype._normSign=function(){if(this.length===1&&this.words[0]===0)this.negative=0;return this},typeof Symbol<"u"&&typeof Symbol.for==="function")try{C.prototype[Symbol.for("nodejs.util.inspect.custom")]=Z}catch(k){C.prototype.inspect=Z}else C.prototype.inspect=Z;function Z(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var R=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],D=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],z=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64000000,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,24300000,28629151,33554432,39135393,45435424,52521875,60466176];if(C.prototype.toString=function(U,V){U=U||10,V=V|0||1;var Y;if(U===16||U==="hex"){Y="";var H=0,K=0;for(var M=0;M<this.length;M++){var I=this.words[M],j=((I<<H|K)&16777215).toString(16);if(K=I>>>24-H&16777215,H+=2,H>=26)H-=26,M--;if(K!==0||M!==this.length-1)Y=R[6-j.length]+j+Y;else Y=j+Y}if(K!==0)Y=K.toString(16)+Y;while(Y.length%V!==0)Y="0"+Y;if(this.negative!==0)Y="-"+Y;return Y}if(U===(U|0)&&U>=2&&U<=36){var q=D[U],F=z[U];Y="";var y=this.clone();y.negative=0;while(!y.isZero()){var r=y.modrn(F).toString(U);if(y=y.idivn(F),!y.isZero())Y=R[q-r.length]+r+Y;else Y=r+Y}if(this.isZero())Y="0"+Y;while(Y.length%V!==0)Y="0"+Y;if(this.negative!==0)Y="-"+Y;return Y}P(!1,"Base should be between 2 and 36")},C.prototype.toNumber=function(){var U=this.words[0];if(this.length===2)U+=this.words[1]*67108864;else if(this.length===3&&this.words[2]===1)U+=4503599627370496+this.words[1]*67108864;else if(this.length>2)P(!1,"Number can only safely store up to 53 bits");return this.negative!==0?-U:U},C.prototype.toJSON=function(){return this.toString(16,2)},W)C.prototype.toBuffer=function(U,V){return this.toArrayLike(W,U,V)};C.prototype.toArray=function(U,V){return this.toArrayLike(Array,U,V)};var S=function(U,V){if(U.allocUnsafe)return U.allocUnsafe(V);return new U(V)};if(C.prototype.toArrayLike=function(U,V,Y){this._strip();var H=this.byteLength(),K=Y||Math.max(1,H);P(H<=K,"byte array longer than desired length"),P(K>0,"Requested array length <= 0");var M=S(U,K),I=V==="le"?"LE":"BE";return this["_toArrayLike"+I](M,H),M},C.prototype._toArrayLikeLE=function(U,V){var Y=0,H=0;for(var K=0,M=0;K<this.length;K++){var I=this.words[K]<<M|H;if(U[Y++]=I&255,Y<U.length)U[Y++]=I>>8&255;if(Y<U.length)U[Y++]=I>>16&255;if(M===6){if(Y<U.length)U[Y++]=I>>24&255;H=0,M=0}else H=I>>>24,M+=2}if(Y<U.length){U[Y++]=H;while(Y<U.length)U[Y++]=0}},C.prototype._toArrayLikeBE=function(U,V){var Y=U.length-1,H=0;for(var K=0,M=0;K<this.length;K++){var I=this.words[K]<<M|H;if(U[Y--]=I&255,Y>=0)U[Y--]=I>>8&255;if(Y>=0)U[Y--]=I>>16&255;if(M===6){if(Y>=0)U[Y--]=I>>24&255;H=0,M=0}else H=I>>>24,M+=2}if(Y>=0){U[Y--]=H;while(Y>=0)U[Y--]=0}},Math.clz32)C.prototype._countBits=function(U){return 32-Math.clz32(U)};else C.prototype._countBits=function(U){var V=U,Y=0;if(V>=4096)Y+=13,V>>>=13;if(V>=64)Y+=7,V>>>=7;if(V>=8)Y+=4,V>>>=4;if(V>=2)Y+=2,V>>>=2;return Y+V};C.prototype._zeroBits=function(U){if(U===0)return 26;var V=U,Y=0;if((V&8191)===0)Y+=13,V>>>=13;if((V&127)===0)Y+=7,V>>>=7;if((V&15)===0)Y+=4,V>>>=4;if((V&3)===0)Y+=2,V>>>=2;if((V&1)===0)Y++;return Y},C.prototype.bitLength=function(){var U=this.words[this.length-1],V=this._countBits(U);return(this.length-1)*26+V};function E(k){var U=Array(k.bitLength());for(var V=0;V<U.length;V++){var Y=V/26|0,H=V%26;U[V]=k.words[Y]>>>H&1}return U}C.prototype.zeroBits=function(){if(this.isZero())return 0;var U=0;for(var V=0;V<this.length;V++){var Y=this._zeroBits(this.words[V]);if(U+=Y,Y!==26)break}return U},C.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},C.prototype.toTwos=function(U){if(this.negative!==0)return this.abs().inotn(U).iaddn(1);return this.clone()},C.prototype.fromTwos=function(U){if(this.testn(U-1))return this.notn(U).iaddn(1).ineg();return this.clone()},C.prototype.isNeg=function(){return this.negative!==0},C.prototype.neg=function(){return this.clone().ineg()},C.prototype.ineg=function(){if(!this.isZero())this.negative^=1;return this},C.prototype.iuor=function(U){while(this.length<U.length)this.words[this.length++]=0;for(var V=0;V<U.length;V++)this.words[V]=this.words[V]|U.words[V];return this._strip()},C.prototype.ior=function(U){return P((this.negative|U.negative)===0),this.iuor(U)},C.prototype.or=function(U){if(this.length>U.length)return this.clone().ior(U);return U.clone().ior(this)},C.prototype.uor=function(U){if(this.length>U.length)return this.clone().iuor(U);return U.clone().iuor(this)},C.prototype.iuand=function(U){var V;if(this.length>U.length)V=U;else V=this;for(var Y=0;Y<V.length;Y++)this.words[Y]=this.words[Y]&U.words[Y];return this.length=V.length,this._strip()},C.prototype.iand=function(U){return P((this.negative|U.negative)===0),this.iuand(U)},C.prototype.and=function(U){if(this.length>U.length)return this.clone().iand(U);return U.clone().iand(this)},C.prototype.uand=function(U){if(this.length>U.length)return this.clone().iuand(U);return U.clone().iuand(this)},C.prototype.iuxor=function(U){var V,Y;if(this.length>U.length)V=this,Y=U;else V=U,Y=this;for(var H=0;H<Y.length;H++)this.words[H]=V.words[H]^Y.words[H];if(this!==V)for(;H<V.length;H++)this.words[H]=V.words[H];return this.length=V.length,this._strip()},C.prototype.ixor=function(U){return P((this.negative|U.negative)===0),this.iuxor(U)},C.prototype.xor=function(U){if(this.length>U.length)return this.clone().ixor(U);return U.clone().ixor(this)},C.prototype.uxor=function(U){if(this.length>U.length)return this.clone().iuxor(U);return U.clone().iuxor(this)},C.prototype.inotn=function(U){P(typeof U==="number"&&U>=0);var V=Math.ceil(U/26)|0,Y=U%26;if(this._expand(V),Y>0)V--;for(var H=0;H<V;H++)this.words[H]=~this.words[H]&67108863;if(Y>0)this.words[H]=~this.words[H]&67108863>>26-Y;return this._strip()},C.prototype.notn=function(U){return this.clone().inotn(U)},C.prototype.setn=function(U,V){P(typeof U==="number"&&U>=0);var Y=U/26|0,H=U%26;if(this._expand(Y+1),V)this.words[Y]=this.words[Y]|1<<H;else this.words[Y]=this.words[Y]&~(1<<H);return this._strip()},C.prototype.iadd=function(U){var V;if(this.negative!==0&&U.negative===0)return this.negative=0,V=this.isub(U),this.negative^=1,this._normSign();else if(this.negative===0&&U.negative!==0)return U.negative=0,V=this.isub(U),U.negative=1,V._normSign();var Y,H;if(this.length>U.length)Y=this,H=U;else Y=U,H=this;var K=0;for(var M=0;M<H.length;M++)V=(Y.words[M]|0)+(H.words[M]|0)+K,this.words[M]=V&67108863,K=V>>>26;for(;K!==0&&M<Y.length;M++)V=(Y.words[M]|0)+K,this.words[M]=V&67108863,K=V>>>26;if(this.length=Y.length,K!==0)this.words[this.length]=K,this.length++;else if(Y!==this)for(;M<Y.length;M++)this.words[M]=Y.words[M];return this},C.prototype.add=function(U){var V;if(U.negative!==0&&this.negative===0)return U.negative=0,V=this.sub(U),U.negative^=1,V;else if(U.negative===0&&this.negative!==0)return this.negative=0,V=U.sub(this),this.negative=1,V;if(this.length>U.length)return this.clone().iadd(U);return U.clone().iadd(this)},C.prototype.isub=function(U){if(U.negative!==0){U.negative=0;var V=this.iadd(U);return U.negative=1,V._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(U),this.negative=1,this._normSign();var Y=this.cmp(U);if(Y===0)return this.negative=0,this.length=1,this.words[0]=0,this;var H,K;if(Y>0)H=this,K=U;else H=U,K=this;var M=0;for(var I=0;I<K.length;I++)V=(H.words[I]|0)-(K.words[I]|0)+M,M=V>>26,this.words[I]=V&67108863;for(;M!==0&&I<H.length;I++)V=(H.words[I]|0)+M,M=V>>26,this.words[I]=V&67108863;if(M===0&&I<H.length&&H!==this)for(;I<H.length;I++)this.words[I]=H.words[I];if(this.length=Math.max(this.length,I),H!==this)this.negative=1;return this._strip()},C.prototype.sub=function(U){return this.clone().isub(U)};function w(k,U,V){V.negative=U.negative^k.negative;var Y=k.length+U.length|0;V.length=Y,Y=Y-1|0;var H=k.words[0]|0,K=U.words[0]|0,M=H*K,I=M&67108863,j=M/67108864|0;V.words[0]=I;for(var q=1;q<Y;q++){var F=j>>>26,y=j&67108863,r=Math.min(q,U.length-1);for(var u=Math.max(0,q-k.length+1);u<=r;u++){var T1=q-u|0;H=k.words[T1]|0,K=U.words[u]|0,M=H*K+y,F+=M/67108864|0,y=M&67108863}V.words[q]=y|0,j=F|0}if(j!==0)V.words[q]=j|0;else V.length--;return V._strip()}var O=function(U,V,Y){var H=U.words,K=V.words,M=Y.words,I=0,j,q,F,y=H[0]|0,r=y&8191,u=y>>>13,T1=H[1]|0,P1=T1&8191,Q1=T1>>>13,vT=H[2]|0,$1=vT&8191,Z1=vT>>>13,b8=H[3]|0,N1=b8&8191,w1=b8>>>13,vW=H[4]|0,L1=vW&8191,E1=vW>>>13,yW=H[5]|0,B1=yW&8191,O1=yW>>>13,bW=H[6]|0,x1=bW&8191,_1=bW>>>13,lW=H[7]|0,h1=lW&8191,m1=lW>>>13,pW=H[8]|0,g1=pW&8191,v1=pW>>>13,uW=H[9]|0,y1=uW&8191,b1=uW>>>13,dW=K[0]|0,l1=dW&8191,p1=dW>>>13,rW=K[1]|0,u1=rW&8191,d1=rW>>>13,cW=K[2]|0,r1=cW&8191,c1=cW>>>13,oW=K[3]|0,o1=oW&8191,n1=oW>>>13,nW=K[4]|0,f1=nW&8191,i1=nW>>>13,fW=K[5]|0,a1=fW&8191,s1=fW>>>13,iW=K[6]|0,t1=iW&8191,e1=iW>>>13,aW=K[7]|0,TT=aW&8191,AT=aW>>>13,sW=K[8]|0,PT=sW&8191,QT=sW>>>13,tW=K[9]|0,CT=tW&8191,WT=tW>>>13;Y.negative=U.negative^V.negative,Y.length=19,j=Math.imul(r,l1),q=Math.imul(r,p1),q=q+Math.imul(u,l1)|0,F=Math.imul(u,p1);var x4=(I+j|0)+((q&8191)<<13)|0;I=(F+(q>>>13)|0)+(x4>>>26)|0,x4&=67108863,j=Math.imul(P1,l1),q=Math.imul(P1,p1),q=q+Math.imul(Q1,l1)|0,F=Math.imul(Q1,p1),j=j+Math.imul(r,u1)|0,q=q+Math.imul(r,d1)|0,q=q+Math.imul(u,u1)|0,F=F+Math.imul(u,d1)|0;var _4=(I+j|0)+((q&8191)<<13)|0;I=(F+(q>>>13)|0)+(_4>>>26)|0,_4&=67108863,j=Math.imul($1,l1),q=Math.imul($1,p1),q=q+Math.imul(Z1,l1)|0,F=Math.imul(Z1,p1),j=j+Math.imul(P1,u1)|0,q=q+Math.imul(P1,d1)|0,q=q+Math.imul(Q1,u1)|0,F=F+Math.imul(Q1,d1)|0,j=j+Math.imul(r,r1)|0,q=q+Math.imul(r,c1)|0,q=q+Math.imul(u,r1)|0,F=F+Math.imul(u,c1)|0;var h4=(I+j|0)+((q&8191)<<13)|0;I=(F+(q>>>13)|0)+(h4>>>26)|0,h4&=67108863,j=Math.imul(N1,l1),q=Math.imul(N1,p1),q=q+Math.imul(w1,l1)|0,F=Math.imul(w1,p1),j=j+Math.imul($1,u1)|0,q=q+Math.imul($1,d1)|0,q=q+Math.imul(Z1,u1)|0,F=F+Math.imul(Z1,d1)|0,j=j+Math.imul(P1,r1)|0,q=q+Math.imul(P1,c1)|0,q=q+Math.imul(Q1,r1)|0,F=F+Math.imul(Q1,c1)|0,j=j+Math.imul(r,o1)|0,q=q+Math.imul(r,n1)|0,q=q+Math.imul(u,o1)|0,F=F+Math.imul(u,n1)|0;var m4=(I+j|0)+((q&8191)<<13)|0;I=(F+(q>>>13)|0)+(m4>>>26)|0,m4&=67108863,j=Math.imul(L1,l1),q=Math.imul(L1,p1),q=q+Math.imul(E1,l1)|0,F=Math.imul(E1,p1),j=j+Math.imul(N1,u1)|0,q=q+Math.imul(N1,d1)|0,q=q+Math.imul(w1,u1)|0,F=F+Math.imul(w1,d1)|0,j=j+Math.imul($1,r1)|0,q=q+Math.imul($1,c1)|0,q=q+Math.imul(Z1,r1)|0,F=F+Math.imul(Z1,c1)|0,j=j+Math.imul(P1,o1)|0,q=q+Math.imul(P1,n1)|0,q=q+Math.imul(Q1,o1)|0,F=F+Math.imul(Q1,n1)|0,j=j+Math.imul(r,f1)|0,q=q+Math.imul(r,i1)|0,q=q+Math.imul(u,f1)|0,F=F+Math.imul(u,i1)|0;var g4=(I+j|0)+((q&8191)<<13)|0;I=(F+(q>>>13)|0)+(g4>>>26)|0,g4&=67108863,j=Math.imul(B1,l1),q=Math.imul(B1,p1),q=q+Math.imul(O1,l1)|0,F=Math.imul(O1,p1),j=j+Math.imul(L1,u1)|0,q=q+Math.imul(L1,d1)|0,q=q+Math.imul(E1,u1)|0,F=F+Math.imul(E1,d1)|0,j=j+Math.imul(N1,r1)|0,q=q+Math.imul(N1,c1)|0,q=q+Math.imul(w1,r1)|0,F=F+Math.imul(w1,c1)|0,j=j+Math.imul($1,o1)|0,q=q+Math.imul($1,n1)|0,q=q+Math.imul(Z1,o1)|0,F=F+Math.imul(Z1,n1)|0,j=j+Math.imul(P1,f1)|0,q=q+Math.imul(P1,i1)|0,q=q+Math.imul(Q1,f1)|0,F=F+Math.imul(Q1,i1)|0,j=j+Math.imul(r,a1)|0,q=q+Math.imul(r,s1)|0,q=q+Math.imul(u,a1)|0,F=F+Math.imul(u,s1)|0;var v4=(I+j|0)+((q&8191)<<13)|0;I=(F+(q>>>13)|0)+(v4>>>26)|0,v4&=67108863,j=Math.imul(x1,l1),q=Math.imul(x1,p1),q=q+Math.imul(_1,l1)|0,F=Math.imul(_1,p1),j=j+Math.imul(B1,u1)|0,q=q+Math.imul(B1,d1)|0,q=q+Math.imul(O1,u1)|0,F=F+Math.imul(O1,d1)|0,j=j+Math.imul(L1,r1)|0,q=q+Math.imul(L1,c1)|0,q=q+Math.imul(E1,r1)|0,F=F+Math.imul(E1,c1)|0,j=j+Math.imul(N1,o1)|0,q=q+Math.imul(N1,n1)|0,q=q+Math.imul(w1,o1)|0,F=F+Math.imul(w1,n1)|0,j=j+Math.imul($1,f1)|0,q=q+Math.imul($1,i1)|0,q=q+Math.imul(Z1,f1)|0,F=F+Math.imul(Z1,i1)|0,j=j+Math.imul(P1,a1)|0,q=q+Math.imul(P1,s1)|0,q=q+Math.imul(Q1,a1)|0,F=F+Math.imul(Q1,s1)|0,j=j+Math.imul(r,t1)|0,q=q+Math.imul(r,e1)|0,q=q+Math.imul(u,t1)|0,F=F+Math.imul(u,e1)|0;var y4=(I+j|0)+((q&8191)<<13)|0;I=(F+(q>>>13)|0)+(y4>>>26)|0,y4&=67108863,j=Math.imul(h1,l1),q=Math.imul(h1,p1),q=q+Math.imul(m1,l1)|0,F=Math.imul(m1,p1),j=j+Math.imul(x1,u1)|0,q=q+Math.imul(x1,d1)|0,q=q+Math.imul(_1,u1)|0,F=F+Math.imul(_1,d1)|0,j=j+Math.imul(B1,r1)|0,q=q+Math.imul(B1,c1)|0,q=q+Math.imul(O1,r1)|0,F=F+Math.imul(O1,c1)|0,j=j+Math.imul(L1,o1)|0,q=q+Math.imul(L1,n1)|0,q=q+Math.imul(E1,o1)|0,F=F+Math.imul(E1,n1)|0,j=j+Math.imul(N1,f1)|0,q=q+Math.imul(N1,i1)|0,q=q+Math.imul(w1,f1)|0,F=F+Math.imul(w1,i1)|0,j=j+Math.imul($1,a1)|0,q=q+Math.imul($1,s1)|0,q=q+Math.imul(Z1,a1)|0,F=F+Math.imul(Z1,s1)|0,j=j+Math.imul(P1,t1)|0,q=q+Math.imul(P1,e1)|0,q=q+Math.imul(Q1,t1)|0,F=F+Math.imul(Q1,e1)|0,j=j+Math.imul(r,TT)|0,q=q+Math.imul(r,AT)|0,q=q+Math.imul(u,TT)|0,F=F+Math.imul(u,AT)|0;var b4=(I+j|0)+((q&8191)<<13)|0;I=(F+(q>>>13)|0)+(b4>>>26)|0,b4&=67108863,j=Math.imul(g1,l1),q=Math.imul(g1,p1),q=q+Math.imul(v1,l1)|0,F=Math.imul(v1,p1),j=j+Math.imul(h1,u1)|0,q=q+Math.imul(h1,d1)|0,q=q+Math.imul(m1,u1)|0,F=F+Math.imul(m1,d1)|0,j=j+Math.imul(x1,r1)|0,q=q+Math.imul(x1,c1)|0,q=q+Math.imul(_1,r1)|0,F=F+Math.imul(_1,c1)|0,j=j+Math.imul(B1,o1)|0,q=q+Math.imul(B1,n1)|0,q=q+Math.imul(O1,o1)|0,F=F+Math.imul(O1,n1)|0,j=j+Math.imul(L1,f1)|0,q=q+Math.imul(L1,i1)|0,q=q+Math.imul(E1,f1)|0,F=F+Math.imul(E1,i1)|0,j=j+Math.imul(N1,a1)|0,q=q+Math.imul(N1,s1)|0,q=q+Math.imul(w1,a1)|0,F=F+Math.imul(w1,s1)|0,j=j+Math.imul($1,t1)|0,q=q+Math.imul($1,e1)|0,q=q+Math.imul(Z1,t1)|0,F=F+Math.imul(Z1,e1)|0,j=j+Math.imul(P1,TT)|0,q=q+Math.imul(P1,AT)|0,q=q+Math.imul(Q1,TT)|0,F=F+Math.imul(Q1,AT)|0,j=j+Math.imul(r,PT)|0,q=q+Math.imul(r,QT)|0,q=q+Math.imul(u,PT)|0,F=F+Math.imul(u,QT)|0;var l4=(I+j|0)+((q&8191)<<13)|0;I=(F+(q>>>13)|0)+(l4>>>26)|0,l4&=67108863,j=Math.imul(y1,l1),q=Math.imul(y1,p1),q=q+Math.imul(b1,l1)|0,F=Math.imul(b1,p1),j=j+Math.imul(g1,u1)|0,q=q+Math.imul(g1,d1)|0,q=q+Math.imul(v1,u1)|0,F=F+Math.imul(v1,d1)|0,j=j+Math.imul(h1,r1)|0,q=q+Math.imul(h1,c1)|0,q=q+Math.imul(m1,r1)|0,F=F+Math.imul(m1,c1)|0,j=j+Math.imul(x1,o1)|0,q=q+Math.imul(x1,n1)|0,q=q+Math.imul(_1,o1)|0,F=F+Math.imul(_1,n1)|0,j=j+Math.imul(B1,f1)|0,q=q+Math.imul(B1,i1)|0,q=q+Math.imul(O1,f1)|0,F=F+Math.imul(O1,i1)|0,j=j+Math.imul(L1,a1)|0,q=q+Math.imul(L1,s1)|0,q=q+Math.imul(E1,a1)|0,F=F+Math.imul(E1,s1)|0,j=j+Math.imul(N1,t1)|0,q=q+Math.imul(N1,e1)|0,q=q+Math.imul(w1,t1)|0,F=F+Math.imul(w1,e1)|0,j=j+Math.imul($1,TT)|0,q=q+Math.imul($1,AT)|0,q=q+Math.imul(Z1,TT)|0,F=F+Math.imul(Z1,AT)|0,j=j+Math.imul(P1,PT)|0,q=q+Math.imul(P1,QT)|0,q=q+Math.imul(Q1,PT)|0,F=F+Math.imul(Q1,QT)|0,j=j+Math.imul(r,CT)|0,q=q+Math.imul(r,WT)|0,q=q+Math.imul(u,CT)|0,F=F+Math.imul(u,WT)|0;var p4=(I+j|0)+((q&8191)<<13)|0;I=(F+(q>>>13)|0)+(p4>>>26)|0,p4&=67108863,j=Math.imul(y1,u1),q=Math.imul(y1,d1),q=q+Math.imul(b1,u1)|0,F=Math.imul(b1,d1),j=j+Math.imul(g1,r1)|0,q=q+Math.imul(g1,c1)|0,q=q+Math.imul(v1,r1)|0,F=F+Math.imul(v1,c1)|0,j=j+Math.imul(h1,o1)|0,q=q+Math.imul(h1,n1)|0,q=q+Math.imul(m1,o1)|0,F=F+Math.imul(m1,n1)|0,j=j+Math.imul(x1,f1)|0,q=q+Math.imul(x1,i1)|0,q=q+Math.imul(_1,f1)|0,F=F+Math.imul(_1,i1)|0,j=j+Math.imul(B1,a1)|0,q=q+Math.imul(B1,s1)|0,q=q+Math.imul(O1,a1)|0,F=F+Math.imul(O1,s1)|0,j=j+Math.imul(L1,t1)|0,q=q+Math.imul(L1,e1)|0,q=q+Math.imul(E1,t1)|0,F=F+Math.imul(E1,e1)|0,j=j+Math.imul(N1,TT)|0,q=q+Math.imul(N1,AT)|0,q=q+Math.imul(w1,TT)|0,F=F+Math.imul(w1,AT)|0,j=j+Math.imul($1,PT)|0,q=q+Math.imul($1,QT)|0,q=q+Math.imul(Z1,PT)|0,F=F+Math.imul(Z1,QT)|0,j=j+Math.imul(P1,CT)|0,q=q+Math.imul(P1,WT)|0,q=q+Math.imul(Q1,CT)|0,F=F+Math.imul(Q1,WT)|0;var u4=(I+j|0)+((q&8191)<<13)|0;I=(F+(q>>>13)|0)+(u4>>>26)|0,u4&=67108863,j=Math.imul(y1,r1),q=Math.imul(y1,c1),q=q+Math.imul(b1,r1)|0,F=Math.imul(b1,c1),j=j+Math.imul(g1,o1)|0,q=q+Math.imul(g1,n1)|0,q=q+Math.imul(v1,o1)|0,F=F+Math.imul(v1,n1)|0,j=j+Math.imul(h1,f1)|0,q=q+Math.imul(h1,i1)|0,q=q+Math.imul(m1,f1)|0,F=F+Math.imul(m1,i1)|0,j=j+Math.imul(x1,a1)|0,q=q+Math.imul(x1,s1)|0,q=q+Math.imul(_1,a1)|0,F=F+Math.imul(_1,s1)|0,j=j+Math.imul(B1,t1)|0,q=q+Math.imul(B1,e1)|0,q=q+Math.imul(O1,t1)|0,F=F+Math.imul(O1,e1)|0,j=j+Math.imul(L1,TT)|0,q=q+Math.imul(L1,AT)|0,q=q+Math.imul(E1,TT)|0,F=F+Math.imul(E1,AT)|0,j=j+Math.imul(N1,PT)|0,q=q+Math.imul(N1,QT)|0,q=q+Math.imul(w1,PT)|0,F=F+Math.imul(w1,QT)|0,j=j+Math.imul($1,CT)|0,q=q+Math.imul($1,WT)|0,q=q+Math.imul(Z1,CT)|0,F=F+Math.imul(Z1,WT)|0;var d4=(I+j|0)+((q&8191)<<13)|0;I=(F+(q>>>13)|0)+(d4>>>26)|0,d4&=67108863,j=Math.imul(y1,o1),q=Math.imul(y1,n1),q=q+Math.imul(b1,o1)|0,F=Math.imul(b1,n1),j=j+Math.imul(g1,f1)|0,q=q+Math.imul(g1,i1)|0,q=q+Math.imul(v1,f1)|0,F=F+Math.imul(v1,i1)|0,j=j+Math.imul(h1,a1)|0,q=q+Math.imul(h1,s1)|0,q=q+Math.imul(m1,a1)|0,F=F+Math.imul(m1,s1)|0,j=j+Math.imul(x1,t1)|0,q=q+Math.imul(x1,e1)|0,q=q+Math.imul(_1,t1)|0,F=F+Math.imul(_1,e1)|0,j=j+Math.imul(B1,TT)|0,q=q+Math.imul(B1,AT)|0,q=q+Math.imul(O1,TT)|0,F=F+Math.imul(O1,AT)|0,j=j+Math.imul(L1,PT)|0,q=q+Math.imul(L1,QT)|0,q=q+Math.imul(E1,PT)|0,F=F+Math.imul(E1,QT)|0,j=j+Math.imul(N1,CT)|0,q=q+Math.imul(N1,WT)|0,q=q+Math.imul(w1,CT)|0,F=F+Math.imul(w1,WT)|0;var r4=(I+j|0)+((q&8191)<<13)|0;I=(F+(q>>>13)|0)+(r4>>>26)|0,r4&=67108863,j=Math.imul(y1,f1),q=Math.imul(y1,i1),q=q+Math.imul(b1,f1)|0,F=Math.imul(b1,i1),j=j+Math.imul(g1,a1)|0,q=q+Math.imul(g1,s1)|0,q=q+Math.imul(v1,a1)|0,F=F+Math.imul(v1,s1)|0,j=j+Math.imul(h1,t1)|0,q=q+Math.imul(h1,e1)|0,q=q+Math.imul(m1,t1)|0,F=F+Math.imul(m1,e1)|0,j=j+Math.imul(x1,TT)|0,q=q+Math.imul(x1,AT)|0,q=q+Math.imul(_1,TT)|0,F=F+Math.imul(_1,AT)|0,j=j+Math.imul(B1,PT)|0,q=q+Math.imul(B1,QT)|0,q=q+Math.imul(O1,PT)|0,F=F+Math.imul(O1,QT)|0,j=j+Math.imul(L1,CT)|0,q=q+Math.imul(L1,WT)|0,q=q+Math.imul(E1,CT)|0,F=F+Math.imul(E1,WT)|0;var c4=(I+j|0)+((q&8191)<<13)|0;I=(F+(q>>>13)|0)+(c4>>>26)|0,c4&=67108863,j=Math.imul(y1,a1),q=Math.imul(y1,s1),q=q+Math.imul(b1,a1)|0,F=Math.imul(b1,s1),j=j+Math.imul(g1,t1)|0,q=q+Math.imul(g1,e1)|0,q=q+Math.imul(v1,t1)|0,F=F+Math.imul(v1,e1)|0,j=j+Math.imul(h1,TT)|0,q=q+Math.imul(h1,AT)|0,q=q+Math.imul(m1,TT)|0,F=F+Math.imul(m1,AT)|0,j=j+Math.imul(x1,PT)|0,q=q+Math.imul(x1,QT)|0,q=q+Math.imul(_1,PT)|0,F=F+Math.imul(_1,QT)|0,j=j+Math.imul(B1,CT)|0,q=q+Math.imul(B1,WT)|0,q=q+Math.imul(O1,CT)|0,F=F+Math.imul(O1,WT)|0;var o4=(I+j|0)+((q&8191)<<13)|0;I=(F+(q>>>13)|0)+(o4>>>26)|0,o4&=67108863,j=Math.imul(y1,t1),q=Math.imul(y1,e1),q=q+Math.imul(b1,t1)|0,F=Math.imul(b1,e1),j=j+Math.imul(g1,TT)|0,q=q+Math.imul(g1,AT)|0,q=q+Math.imul(v1,TT)|0,F=F+Math.imul(v1,AT)|0,j=j+Math.imul(h1,PT)|0,q=q+Math.imul(h1,QT)|0,q=q+Math.imul(m1,PT)|0,F=F+Math.imul(m1,QT)|0,j=j+Math.imul(x1,CT)|0,q=q+Math.imul(x1,WT)|0,q=q+Math.imul(_1,CT)|0,F=F+Math.imul(_1,WT)|0;var n4=(I+j|0)+((q&8191)<<13)|0;I=(F+(q>>>13)|0)+(n4>>>26)|0,n4&=67108863,j=Math.imul(y1,TT),q=Math.imul(y1,AT),q=q+Math.imul(b1,TT)|0,F=Math.imul(b1,AT),j=j+Math.imul(g1,PT)|0,q=q+Math.imul(g1,QT)|0,q=q+Math.imul(v1,PT)|0,F=F+Math.imul(v1,QT)|0,j=j+Math.imul(h1,CT)|0,q=q+Math.imul(h1,WT)|0,q=q+Math.imul(m1,CT)|0,F=F+Math.imul(m1,WT)|0;var f4=(I+j|0)+((q&8191)<<13)|0;I=(F+(q>>>13)|0)+(f4>>>26)|0,f4&=67108863,j=Math.imul(y1,PT),q=Math.imul(y1,QT),q=q+Math.imul(b1,PT)|0,F=Math.imul(b1,QT),j=j+Math.imul(g1,CT)|0,q=q+Math.imul(g1,WT)|0,q=q+Math.imul(v1,CT)|0,F=F+Math.imul(v1,WT)|0;var i4=(I+j|0)+((q&8191)<<13)|0;I=(F+(q>>>13)|0)+(i4>>>26)|0,i4&=67108863,j=Math.imul(y1,CT),q=Math.imul(y1,WT),q=q+Math.imul(b1,CT)|0,F=Math.imul(b1,WT);var a4=(I+j|0)+((q&8191)<<13)|0;if(I=(F+(q>>>13)|0)+(a4>>>26)|0,a4&=67108863,M[0]=x4,M[1]=_4,M[2]=h4,M[3]=m4,M[4]=g4,M[5]=v4,M[6]=y4,M[7]=b4,M[8]=l4,M[9]=p4,M[10]=u4,M[11]=d4,M[12]=r4,M[13]=c4,M[14]=o4,M[15]=n4,M[16]=f4,M[17]=i4,M[18]=a4,I!==0)M[19]=I,Y.length++;return Y};if(!Math.imul)O=w;function m(k,U,V){V.negative=U.negative^k.negative,V.length=k.length+U.length;var Y=0,H=0;for(var K=0;K<V.length-1;K++){var M=H;H=0;var I=Y&67108863,j=Math.min(K,U.length-1);for(var q=Math.max(0,K-k.length+1);q<=j;q++){var F=K-q,y=k.words[F]|0,r=U.words[q]|0,u=y*r,T1=u&67108863;M=M+(u/67108864|0)|0,T1=T1+I|0,I=T1&67108863,M=M+(T1>>>26)|0,H+=M>>>26,M&=67108863}V.words[K]=I,Y=M,M=H}if(Y!==0)V.words[K]=Y;else V.length--;return V._strip()}function g(k,U,V){return m(k,U,V)}C.prototype.mulTo=function(U,V){var Y,H=this.length+U.length;if(this.length===10&&U.length===10)Y=O(this,U,V);else if(H<63)Y=w(this,U,V);else if(H<1024)Y=m(this,U,V);else Y=g(this,U,V);return Y};function p(k,U){this.x=k,this.y=U}p.prototype.makeRBT=function(U){var V=Array(U),Y=C.prototype._countBits(U)-1;for(var H=0;H<U;H++)V[H]=this.revBin(H,Y,U);return V},p.prototype.revBin=function(U,V,Y){if(U===0||U===Y-1)return U;var H=0;for(var K=0;K<V;K++)H|=(U&1)<<V-K-1,U>>=1;return H},p.prototype.permute=function(U,V,Y,H,K,M){for(var I=0;I<M;I++)H[I]=V[U[I]],K[I]=Y[U[I]]},p.prototype.transform=function(U,V,Y,H,K,M){this.permute(M,U,V,Y,H,K);for(var I=1;I<K;I<<=1){var j=I<<1,q=Math.cos(2*Math.PI/j),F=Math.sin(2*Math.PI/j);for(var y=0;y<K;y+=j){var r=q,u=F;for(var T1=0;T1<I;T1++){var P1=Y[y+T1],Q1=H[y+T1],vT=Y[y+T1+I],$1=H[y+T1+I],Z1=r*vT-u*$1;if($1=r*$1+u*vT,vT=Z1,Y[y+T1]=P1+vT,H[y+T1]=Q1+$1,Y[y+T1+I]=P1-vT,H[y+T1+I]=Q1-$1,T1!==j)Z1=q*r-F*u,u=q*u+F*r,r=Z1}}}},p.prototype.guessLen13b=function(U,V){var Y=Math.max(V,U)|1,H=Y&1,K=0;for(Y=Y/2|0;Y;Y=Y>>>1)K++;return 1<<K+1+H},p.prototype.conjugate=function(U,V,Y){if(Y<=1)return;for(var H=0;H<Y/2;H++){var K=U[H];U[H]=U[Y-H-1],U[Y-H-1]=K,K=V[H],V[H]=-V[Y-H-1],V[Y-H-1]=-K}},p.prototype.normalize13b=function(U,V){var Y=0;for(var H=0;H<V/2;H++){var K=Math.round(U[2*H+1]/V)*8192+Math.round(U[2*H]/V)+Y;if(U[H]=K&67108863,K<67108864)Y=0;else Y=K/67108864|0}return U},p.prototype.convert13b=function(U,V,Y,H){var K=0;for(var M=0;M<V;M++)K=K+(U[M]|0),Y[2*M]=K&8191,K=K>>>13,Y[2*M+1]=K&8191,K=K>>>13;for(M=2*V;M<H;++M)Y[M]=0;P(K===0),P((K&-8192)===0)},p.prototype.stub=function(U){var V=Array(U);for(var Y=0;Y<U;Y++)V[Y]=0;return V},p.prototype.mulp=function(U,V,Y){var H=2*this.guessLen13b(U.length,V.length),K=this.makeRBT(H),M=this.stub(H),I=Array(H),j=Array(H),q=Array(H),F=Array(H),y=Array(H),r=Array(H),u=Y.words;u.length=H,this.convert13b(U.words,U.length,I,H),this.convert13b(V.words,V.length,F,H),this.transform(I,M,j,q,H,K),this.transform(F,M,y,r,H,K);for(var T1=0;T1<H;T1++){var P1=j[T1]*y[T1]-q[T1]*r[T1];q[T1]=j[T1]*r[T1]+q[T1]*y[T1],j[T1]=P1}return this.conjugate(j,q,H),this.transform(j,q,u,M,H,K),this.conjugate(u,M,H),this.normalize13b(u,H),Y.negative=U.negative^V.negative,Y.length=U.length+V.length,Y._strip()},C.prototype.mul=function(U){var V=new C(null);return V.words=Array(this.length+U.length),this.mulTo(U,V)},C.prototype.mulf=function(U){var V=new C(null);return V.words=Array(this.length+U.length),g(this,U,V)},C.prototype.imul=function(U){return this.clone().mulTo(U,this)},C.prototype.imuln=function(U){var V=U<0;if(V)U=-U;P(typeof U==="number"),P(U<67108864);var Y=0;for(var H=0;H<this.length;H++){var K=(this.words[H]|0)*U,M=(K&67108863)+(Y&67108863);Y>>=26,Y+=K/67108864|0,Y+=M>>>26,this.words[H]=M&67108863}if(Y!==0)this.words[H]=Y,this.length++;return this.length=U===0?1:this.length,V?this.ineg():this},C.prototype.muln=function(U){return this.clone().imuln(U)},C.prototype.sqr=function(){return this.mul(this)},C.prototype.isqr=function(){return this.imul(this.clone())},C.prototype.pow=function(U){var V=E(U);if(V.length===0)return new C(1);var Y=this;for(var H=0;H<V.length;H++,Y=Y.sqr())if(V[H]!==0)break;if(++H<V.length)for(var K=Y.sqr();H<V.length;H++,K=K.sqr()){if(V[H]===0)continue;Y=Y.mul(K)}return Y},C.prototype.iushln=function(U){P(typeof U==="number"&&U>=0);var V=U%26,Y=(U-V)/26,H=67108863>>>26-V<<26-V,K;if(V!==0){var M=0;for(K=0;K<this.length;K++){var I=this.words[K]&H,j=(this.words[K]|0)-I<<V;this.words[K]=j|M,M=I>>>26-V}if(M)this.words[K]=M,this.length++}if(Y!==0){for(K=this.length-1;K>=0;K--)this.words[K+Y]=this.words[K];for(K=0;K<Y;K++)this.words[K]=0;this.length+=Y}return this._strip()},C.prototype.ishln=function(U){return P(this.negative===0),this.iushln(U)},C.prototype.iushrn=function(U,V,Y){P(typeof U==="number"&&U>=0);var H;if(V)H=(V-V%26)/26;else H=0;var K=U%26,M=Math.min((U-K)/26,this.length),I=67108863^67108863>>>K<<K,j=Y;if(H-=M,H=Math.max(0,H),j){for(var q=0;q<M;q++)j.words[q]=this.words[q];j.length=M}if(M===0);else if(this.length>M){this.length-=M;for(q=0;q<this.length;q++)this.words[q]=this.words[q+M]}else this.words[0]=0,this.length=1;var F=0;for(q=this.length-1;q>=0&&(F!==0||q>=H);q--){var y=this.words[q]|0;this.words[q]=F<<26-K|y>>>K,F=y&I}if(j&&F!==0)j.words[j.length++]=F;if(this.length===0)this.words[0]=0,this.length=1;return this._strip()},C.prototype.ishrn=function(U,V,Y){return P(this.negative===0),this.iushrn(U,V,Y)},C.prototype.shln=function(U){return this.clone().ishln(U)},C.prototype.ushln=function(U){return this.clone().iushln(U)},C.prototype.shrn=function(U){return this.clone().ishrn(U)},C.prototype.ushrn=function(U){return this.clone().iushrn(U)},C.prototype.testn=function(U){P(typeof U==="number"&&U>=0);var V=U%26,Y=(U-V)/26,H=1<<V;if(this.length<=Y)return!1;var K=this.words[Y];return!!(K&H)},C.prototype.imaskn=function(U){P(typeof U==="number"&&U>=0);var V=U%26,Y=(U-V)/26;if(P(this.negative===0,"imaskn works only with positive numbers"),this.length<=Y)return this;if(V!==0)Y++;if(this.length=Math.min(Y,this.length),V!==0){var H=67108863^67108863>>>V<<V;this.words[this.length-1]&=H}return this._strip()},C.prototype.maskn=function(U){return this.clone().imaskn(U)},C.prototype.iaddn=function(U){if(P(typeof U==="number"),P(U<67108864),U<0)return this.isubn(-U);if(this.negative!==0){if(this.length===1&&(this.words[0]|0)<=U)return this.words[0]=U-(this.words[0]|0),this.negative=0,this;return this.negative=0,this.isubn(U),this.negative=1,this}return this._iaddn(U)},C.prototype._iaddn=function(U){this.words[0]+=U;for(var V=0;V<this.length&&this.words[V]>=67108864;V++)if(this.words[V]-=67108864,V===this.length-1)this.words[V+1]=1;else this.words[V+1]++;return this.length=Math.max(this.length,V+1),this},C.prototype.isubn=function(U){if(P(typeof U==="number"),P(U<67108864),U<0)return this.iaddn(-U);if(this.negative!==0)return this.negative=0,this.iaddn(U),this.negative=1,this;if(this.words[0]-=U,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var V=0;V<this.length&&this.words[V]<0;V++)this.words[V]+=67108864,this.words[V+1]-=1;return this._strip()},C.prototype.addn=function(U){return this.clone().iaddn(U)},C.prototype.subn=function(U){return this.clone().isubn(U)},C.prototype.iabs=function(){return this.negative=0,this},C.prototype.abs=function(){return this.clone().iabs()},C.prototype._ishlnsubmul=function(U,V,Y){var H=U.length+Y,K;this._expand(H);var M,I=0;for(K=0;K<U.length;K++){M=(this.words[K+Y]|0)+I;var j=(U.words[K]|0)*V;M-=j&67108863,I=(M>>26)-(j/67108864|0),this.words[K+Y]=M&67108863}for(;K<this.length-Y;K++)M=(this.words[K+Y]|0)+I,I=M>>26,this.words[K+Y]=M&67108863;if(I===0)return this._strip();P(I===-1),I=0;for(K=0;K<this.length;K++)M=-(this.words[K]|0)+I,I=M>>26,this.words[K]=M&67108863;return this.negative=1,this._strip()},C.prototype._wordDiv=function(U,V){var Y=this.length-U.length,H=this.clone(),K=U,M=K.words[K.length-1]|0,I=this._countBits(M);if(Y=26-I,Y!==0)K=K.ushln(Y),H.iushln(Y),M=K.words[K.length-1]|0;var j=H.length-K.length,q;if(V!=="mod"){q=new C(null),q.length=j+1,q.words=Array(q.length);for(var F=0;F<q.length;F++)q.words[F]=0}var y=H.clone()._ishlnsubmul(K,1,j);if(y.negative===0){if(H=y,q)q.words[j]=1}for(var r=j-1;r>=0;r--){var u=(H.words[K.length+r]|0)*67108864+(H.words[K.length+r-1]|0);u=Math.min(u/M|0,67108863),H._ishlnsubmul(K,u,r);while(H.negative!==0)if(u--,H.negative=0,H._ishlnsubmul(K,1,r),!H.isZero())H.negative^=1;if(q)q.words[r]=u}if(q)q._strip();if(H._strip(),V!=="div"&&Y!==0)H.iushrn(Y);return{div:q||null,mod:H}},C.prototype.divmod=function(U,V,Y){if(P(!U.isZero()),this.isZero())return{div:new C(0),mod:new C(0)};var H,K,M;if(this.negative!==0&&U.negative===0){if(M=this.neg().divmod(U,V),V!=="mod")H=M.div.neg();if(V!=="div"){if(K=M.mod.neg(),Y&&K.negative!==0)K.iadd(U)}return{div:H,mod:K}}if(this.negative===0&&U.negative!==0){if(M=this.divmod(U.neg(),V),V!=="mod")H=M.div.neg();return{div:H,mod:M.mod}}if((this.negative&U.negative)!==0){if(M=this.neg().divmod(U.neg(),V),V!=="div"){if(K=M.mod.neg(),Y&&K.negative!==0)K.isub(U)}return{div:M.div,mod:K}}if(U.length>this.length||this.cmp(U)<0)return{div:new C(0),mod:this};if(U.length===1){if(V==="div")return{div:this.divn(U.words[0]),mod:null};if(V==="mod")return{div:null,mod:new C(this.modrn(U.words[0]))};return{div:this.divn(U.words[0]),mod:new C(this.modrn(U.words[0]))}}return this._wordDiv(U,V)},C.prototype.div=function(U){return this.divmod(U,"div",!1).div},C.prototype.mod=function(U){return this.divmod(U,"mod",!1).mod},C.prototype.umod=function(U){return this.divmod(U,"mod",!0).mod},C.prototype.divRound=function(U){var V=this.divmod(U);if(V.mod.isZero())return V.div;var Y=V.div.negative!==0?V.mod.isub(U):V.mod,H=U.ushrn(1),K=U.andln(1),M=Y.cmp(H);if(M<0||K===1&&M===0)return V.div;return V.div.negative!==0?V.div.isubn(1):V.div.iaddn(1)},C.prototype.modrn=function(U){var V=U<0;if(V)U=-U;P(U<=67108863);var Y=67108864%U,H=0;for(var K=this.length-1;K>=0;K--)H=(Y*H+(this.words[K]|0))%U;return V?-H:H},C.prototype.modn=function(U){return this.modrn(U)},C.prototype.idivn=function(U){var V=U<0;if(V)U=-U;P(U<=67108863);var Y=0;for(var H=this.length-1;H>=0;H--){var K=(this.words[H]|0)+Y*67108864;this.words[H]=K/U|0,Y=K%U}return this._strip(),V?this.ineg():this},C.prototype.divn=function(U){return this.clone().idivn(U)},C.prototype.egcd=function(U){P(U.negative===0),P(!U.isZero());var V=this,Y=U.clone();if(V.negative!==0)V=V.umod(U);else V=V.clone();var H=new C(1),K=new C(0),M=new C(0),I=new C(1),j=0;while(V.isEven()&&Y.isEven())V.iushrn(1),Y.iushrn(1),++j;var q=Y.clone(),F=V.clone();while(!V.isZero()){for(var y=0,r=1;(V.words[0]&r)===0&&y<26;++y,r<<=1);if(y>0){V.iushrn(y);while(y-- >0){if(H.isOdd()||K.isOdd())H.iadd(q),K.isub(F);H.iushrn(1),K.iushrn(1)}}for(var u=0,T1=1;(Y.words[0]&T1)===0&&u<26;++u,T1<<=1);if(u>0){Y.iushrn(u);while(u-- >0){if(M.isOdd()||I.isOdd())M.iadd(q),I.isub(F);M.iushrn(1),I.iushrn(1)}}if(V.cmp(Y)>=0)V.isub(Y),H.isub(M),K.isub(I);else Y.isub(V),M.isub(H),I.isub(K)}return{a:M,b:I,gcd:Y.iushln(j)}},C.prototype._invmp=function(U){P(U.negative===0),P(!U.isZero());var V=this,Y=U.clone();if(V.negative!==0)V=V.umod(U);else V=V.clone();var H=new C(1),K=new C(0),M=Y.clone();while(V.cmpn(1)>0&&Y.cmpn(1)>0){for(var I=0,j=1;(V.words[0]&j)===0&&I<26;++I,j<<=1);if(I>0){V.iushrn(I);while(I-- >0){if(H.isOdd())H.iadd(M);H.iushrn(1)}}for(var q=0,F=1;(Y.words[0]&F)===0&&q<26;++q,F<<=1);if(q>0){Y.iushrn(q);while(q-- >0){if(K.isOdd())K.iadd(M);K.iushrn(1)}}if(V.cmp(Y)>=0)V.isub(Y),H.isub(K);else Y.isub(V),K.isub(H)}var y;if(V.cmpn(1)===0)y=H;else y=K;if(y.cmpn(0)<0)y.iadd(U);return y},C.prototype.gcd=function(U){if(this.isZero())return U.abs();if(U.isZero())return this.abs();var V=this.clone(),Y=U.clone();V.negative=0,Y.negative=0;for(var H=0;V.isEven()&&Y.isEven();H++)V.iushrn(1),Y.iushrn(1);do{while(V.isEven())V.iushrn(1);while(Y.isEven())Y.iushrn(1);var K=V.cmp(Y);if(K<0){var M=V;V=Y,Y=M}else if(K===0||Y.cmpn(1)===0)break;V.isub(Y)}while(!0);return Y.iushln(H)},C.prototype.invm=function(U){return this.egcd(U).a.umod(U)},C.prototype.isEven=function(){return(this.words[0]&1)===0},C.prototype.isOdd=function(){return(this.words[0]&1)===1},C.prototype.andln=function(U){return this.words[0]&U},C.prototype.bincn=function(U){P(typeof U==="number");var V=U%26,Y=(U-V)/26,H=1<<V;if(this.length<=Y)return this._expand(Y+1),this.words[Y]|=H,this;var K=H;for(var M=Y;K!==0&&M<this.length;M++){var I=this.words[M]|0;I+=K,K=I>>>26,I&=67108863,this.words[M]=I}if(K!==0)this.words[M]=K,this.length++;return this},C.prototype.isZero=function(){return this.length===1&&this.words[0]===0},C.prototype.cmpn=function(U){var V=U<0;if(this.negative!==0&&!V)return-1;if(this.negative===0&&V)return 1;this._strip();var Y;if(this.length>1)Y=1;else{if(V)U=-U;P(U<=67108863,"Number is too big");var H=this.words[0]|0;Y=H===U?0:H<U?-1:1}if(this.negative!==0)return-Y|0;return Y},C.prototype.cmp=function(U){if(this.negative!==0&&U.negative===0)return-1;if(this.negative===0&&U.negative!==0)return 1;var V=this.ucmp(U);if(this.negative!==0)return-V|0;return V},C.prototype.ucmp=function(U){if(this.length>U.length)return 1;if(this.length<U.length)return-1;var V=0;for(var Y=this.length-1;Y>=0;Y--){var H=this.words[Y]|0,K=U.words[Y]|0;if(H===K)continue;if(H<K)V=-1;else if(H>K)V=1;break}return V},C.prototype.gtn=function(U){return this.cmpn(U)===1},C.prototype.gt=function(U){return this.cmp(U)===1},C.prototype.gten=function(U){return this.cmpn(U)>=0},C.prototype.gte=function(U){return this.cmp(U)>=0},C.prototype.ltn=function(U){return this.cmpn(U)===-1},C.prototype.lt=function(U){return this.cmp(U)===-1},C.prototype.lten=function(U){return this.cmpn(U)<=0},C.prototype.lte=function(U){return this.cmp(U)<=0},C.prototype.eqn=function(U){return this.cmpn(U)===0},C.prototype.eq=function(U){return this.cmp(U)===0},C.red=function(U){return new i(U)},C.prototype.toRed=function(U){return P(!this.red,"Already a number in reduction context"),P(this.negative===0,"red works only with positives"),U.convertTo(this)._forceRed(U)},C.prototype.fromRed=function(){return P(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},C.prototype._forceRed=function(U){return this.red=U,this},C.prototype.forceRed=function(U){return P(!this.red,"Already a number in reduction context"),this._forceRed(U)},C.prototype.redAdd=function(U){return P(this.red,"redAdd works only with red numbers"),this.red.add(this,U)},C.prototype.redIAdd=function(U){return P(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,U)},C.prototype.redSub=function(U){return P(this.red,"redSub works only with red numbers"),this.red.sub(this,U)},C.prototype.redISub=function(U){return P(this.red,"redISub works only with red numbers"),this.red.isub(this,U)},C.prototype.redShl=function(U){return P(this.red,"redShl works only with red numbers"),this.red.shl(this,U)},C.prototype.redMul=function(U){return P(this.red,"redMul works only with red numbers"),this.red._verify2(this,U),this.red.mul(this,U)},C.prototype.redIMul=function(U){return P(this.red,"redMul works only with red numbers"),this.red._verify2(this,U),this.red.imul(this,U)},C.prototype.redSqr=function(){return P(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},C.prototype.redISqr=function(){return P(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},C.prototype.redSqrt=function(){return P(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},C.prototype.redInvm=function(){return P(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},C.prototype.redNeg=function(){return P(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},C.prototype.redPow=function(U){return P(this.red&&!U.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,U)};var c={k256:null,p224:null,p192:null,p25519:null};function o(k,U){this.name=k,this.p=new C(U,16),this.n=this.p.bitLength(),this.k=new C(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}o.prototype._tmp=function(){var U=new C(null);return U.words=Array(Math.ceil(this.n/13)),U},o.prototype.ireduce=function(U){var V=U,Y;do this.split(V,this.tmp),V=this.imulK(V),V=V.iadd(this.tmp),Y=V.bitLength();while(Y>this.n);var H=Y<this.n?-1:V.ucmp(this.p);if(H===0)V.words[0]=0,V.length=1;else if(H>0)V.isub(this.p);else if(V.strip!==void 0)V.strip();else V._strip();return V},o.prototype.split=function(U,V){U.iushrn(this.n,0,V)},o.prototype.imulK=function(U){return U.imul(this.k)};function f(){o.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}Q(f,o),f.prototype.split=function(U,V){var Y=4194303,H=Math.min(U.length,9);for(var K=0;K<H;K++)V.words[K]=U.words[K];if(V.length=H,U.length<=9){U.words[0]=0,U.length=1;return}var M=U.words[9];V.words[V.length++]=M&Y;for(K=10;K<U.length;K++){var I=U.words[K]|0;U.words[K-10]=(I&Y)<<4|M>>>22,M=I}if(M>>>=22,U.words[K-10]=M,M===0&&U.length>10)U.length-=10;else U.length-=9},f.prototype.imulK=function(U){U.words[U.length]=0,U.words[U.length+1]=0,U.length+=2;var V=0;for(var Y=0;Y<U.length;Y++){var H=U.words[Y]|0;V+=H*977,U.words[Y]=V&67108863,V=H*64+(V/67108864|0)}if(U.words[U.length-1]===0){if(U.length--,U.words[U.length-1]===0)U.length--}return U};function d(){o.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}Q(d,o);function _(){o.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}Q(_,o);function t(){o.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}Q(t,o),t.prototype.imulK=function(U){var V=0;for(var Y=0;Y<U.length;Y++){var H=(U.words[Y]|0)*19+V,K=H&67108863;H>>>=26,U.words[Y]=K,V=H}if(V!==0)U.words[U.length++]=V;return U},C._prime=function(U){if(c[U])return c[U];var V;if(U==="k256")V=new f;else if(U==="p224")V=new d;else if(U==="p192")V=new _;else if(U==="p25519")V=new t;else throw Error("Unknown prime "+U);return c[U]=V,V};function i(k){if(typeof k==="string"){var U=C._prime(k);this.m=U.p,this.prime=U}else P(k.gtn(1),"modulus must be greater than 1"),this.m=k,this.prime=null}i.prototype._verify1=function(U){P(U.negative===0,"red works only with positives"),P(U.red,"red works only with red numbers")},i.prototype._verify2=function(U,V){P((U.negative|V.negative)===0,"red works only with positives"),P(U.red&&U.red===V.red,"red works only with red numbers")},i.prototype.imod=function(U){if(this.prime)return this.prime.ireduce(U)._forceRed(this);return X(U,U.umod(this.m)._forceRed(this)),U},i.prototype.neg=function(U){if(U.isZero())return U.clone();return this.m.sub(U)._forceRed(this)},i.prototype.add=function(U,V){this._verify2(U,V);var Y=U.add(V);if(Y.cmp(this.m)>=0)Y.isub(this.m);return Y._forceRed(this)},i.prototype.iadd=function(U,V){this._verify2(U,V);var Y=U.iadd(V);if(Y.cmp(this.m)>=0)Y.isub(this.m);return Y},i.prototype.sub=function(U,V){this._verify2(U,V);var Y=U.sub(V);if(Y.cmpn(0)<0)Y.iadd(this.m);return Y._forceRed(this)},i.prototype.isub=function(U,V){this._verify2(U,V);var Y=U.isub(V);if(Y.cmpn(0)<0)Y.iadd(this.m);return Y},i.prototype.shl=function(U,V){return this._verify1(U),this.imod(U.ushln(V))},i.prototype.imul=function(U,V){return this._verify2(U,V),this.imod(U.imul(V))},i.prototype.mul=function(U,V){return this._verify2(U,V),this.imod(U.mul(V))},i.prototype.isqr=function(U){return this.imul(U,U.clone())},i.prototype.sqr=function(U){return this.mul(U,U)},i.prototype.sqrt=function(U){if(U.isZero())return U.clone();var V=this.m.andln(3);if(P(V%2===1),V===3){var Y=this.m.add(new C(1)).iushrn(2);return this.pow(U,Y)}var H=this.m.subn(1),K=0;while(!H.isZero()&&H.andln(1)===0)K++,H.iushrn(1);P(!H.isZero());var M=new C(1).toRed(this),I=M.redNeg(),j=this.m.subn(1).iushrn(1),q=this.m.bitLength();q=new C(2*q*q).toRed(this);while(this.pow(q,j).cmp(I)!==0)q.redIAdd(I);var F=this.pow(q,H),y=this.pow(U,H.addn(1).iushrn(1)),r=this.pow(U,H),u=K;while(r.cmp(M)!==0){var T1=r;for(var P1=0;T1.cmp(M)!==0;P1++)T1=T1.redSqr();P(P1<u);var Q1=this.pow(F,new C(1).iushln(u-P1-1));y=y.redMul(Q1),F=Q1.redSqr(),r=r.redMul(F),u=P1}return y},i.prototype.invm=function(U){var V=U._invmp(this.m);if(V.negative!==0)return V.negative=0,this.imod(V).redNeg();else return this.imod(V)},i.prototype.pow=function(U,V){if(V.isZero())return new C(1).toRed(this);if(V.cmpn(1)===0)return U.clone();var Y=4,H=Array(1<<Y);H[0]=new C(1).toRed(this),H[1]=U;for(var K=2;K<H.length;K++)H[K]=this.mul(H[K-1],U);var M=H[0],I=0,j=0,q=V.bitLength()%26;if(q===0)q=26;for(K=V.length-1;K>=0;K--){var F=V.words[K];for(var y=q-1;y>=0;y--){var r=F>>y&1;if(M!==H[0])M=this.sqr(M);if(r===0&&I===0){j=0;continue}if(I<<=1,I|=r,j++,j!==Y&&(K!==0||y!==0))continue;M=this.mul(M,H[I]),j=0,I=0}q=26}return M},i.prototype.convertTo=function(U){var V=U.umod(this.m);return V===U?V.clone():V},i.prototype.convertFrom=function(U){var V=U.clone();return V.red=null,V},C.mont=function(U){return new x(U)};function x(k){if(i.call(this,k),this.shift=this.m.bitLength(),this.shift%26!==0)this.shift+=26-this.shift%26;this.r=new C(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}Q(x,i),x.prototype.convertTo=function(U){return this.imod(U.ushln(this.shift))},x.prototype.convertFrom=function(U){var V=this.imod(U.mul(this.rinv));return V.red=null,V},x.prototype.imul=function(U,V){if(U.isZero()||V.isZero())return U.words[0]=0,U.length=1,U;var Y=U.imul(V),H=Y.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),K=Y.isub(H).iushrn(this.shift),M=K;if(K.cmp(this.m)>=0)M=K.isub(this.m);else if(K.cmpn(0)<0)M=K.iadd(this.m);return M._forceRed(this)},x.prototype.mul=function(U,V){if(U.isZero()||V.isZero())return new C(0)._forceRed(this);var Y=U.mul(V),H=Y.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),K=Y.isub(H).iushrn(this.shift),M=K;if(K.cmp(this.m)>=0)M=K.isub(this.m);else if(K.cmpn(0)<0)M=K.iadd(this.m);return M._forceRed(this)},x.prototype.invm=function(U){var V=this.imod(U._invmp(this.m).mul(this.r2));return V._forceRed(this)}})(typeof CC>"u"||CC,G9)});var $9=T0((GC,J9)=>{/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var d6=(j8(),G8(O6)),_0=d6.Buffer;function U9(T,A){for(var P in T)A[P]=T[P]}if(_0.from&&_0.alloc&&_0.allocUnsafe&&_0.allocUnsafeSlow)J9.exports=d6;else U9(d6,GC),GC.Buffer=aA;function aA(T,A,P){return _0(T,A,P)}aA.prototype=Object.create(_0.prototype);U9(_0,aA);aA.from=function(T,A,P){if(typeof T==="number")throw TypeError("Argument must not be a number");return _0(T,A,P)};aA.alloc=function(T,A,P){if(typeof T!=="number")throw TypeError("Argument must be a number");var Q=_0(T);if(A!==void 0)if(typeof P==="string")Q.fill(A,P);else Q.fill(A);else Q.fill(0);return Q};aA.allocUnsafe=function(T){if(typeof T!=="number")throw TypeError("Argument must be a number");return _0(T)};aA.allocUnsafeSlow=function(T){if(typeof T!=="number")throw TypeError("Argument must be a number");return d6.SlowBuffer(T)}});var q9=T0((DO,V9)=>{var r6=$9().Buffer;function ek(T){if(T.length>=255)throw TypeError("Alphabet too long");var A=new Uint8Array(256);for(var P=0;P<A.length;P++)A[P]=255;for(var Q=0;Q<T.length;Q++){var C=T.charAt(Q),W=C.charCodeAt(0);if(A[W]!==255)throw TypeError(C+" is ambiguous");A[W]=Q}var G=T.length,J=T.charAt(0),$=Math.log(G)/Math.log(256),X=Math.log(256)/Math.log(G);function Z(z){if(Array.isArray(z)||z instanceof Uint8Array)z=r6.from(z);if(!r6.isBuffer(z))throw TypeError("Expected Buffer");if(z.length===0)return"";var S=0,E=0,w=0,O=z.length;while(w!==O&&z[w]===0)w++,S++;var m=(O-w)*X+1>>>0,g=new Uint8Array(m);while(w!==O){var p=z[w],c=0;for(var o=m-1;(p!==0||c<E)&&o!==-1;o--,c++)p+=256*g[o]>>>0,g[o]=p%G>>>0,p=p/G>>>0;if(p!==0)throw Error("Non-zero carry");E=c,w++}var f=m-E;while(f!==m&&g[f]===0)f++;var d=J.repeat(S);for(;f<m;++f)d+=T.charAt(g[f]);return d}function R(z){if(typeof z!=="string")throw TypeError("Expected String");if(z.length===0)return r6.alloc(0);var S=0,E=0,w=0;while(z[S]===J)E++,S++;var O=(z.length-S)*$+1>>>0,m=new Uint8Array(O);while(S<z.length){var g=z.charCodeAt(S);if(g>255)return;var p=A[g];if(p===255)return;var c=0;for(var o=O-1;(p!==0||c<w)&&o!==-1;o--,c++)p+=G*m[o]>>>0,m[o]=p%256>>>0,p=p/256>>>0;if(p!==0)throw Error("Non-zero carry");w=c,S++}var f=O-w;while(f!==O&&m[f]===0)f++;var d=r6.allocUnsafe(E+(O-f));d.fill(0,0,E);var _=E;while(f!==O)d[_++]=m[f++];return d}function D(z){var S=R(z);if(S)return S;throw Error("Non-base"+G+" character")}return{encode:Z,decodeUnsafe:R,decode:D}}V9.exports=ek});var UC=T0((FO,Y9)=>{var Tj=q9(),Aj="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";Y9.exports=Tj(Aj)});var Z9={};s4(Z9,{TextEncoder:()=>f6,TextDecoder:()=>n6});function QA(T,A,P){return A<=T&&T<=P}function i6(T){if(T===void 0)return{};if(T===Object(T))return T;throw TypeError("Could not convert argument to dictionary")}function Pj(T){var A=String(T),P=A.length,Q=0,C=[];while(Q<P){var W=A.charCodeAt(Q);if(W<55296||W>57343)C.push(W);else if(56320<=W&&W<=57343)C.push(65533);else if(55296<=W&&W<=56319)if(Q===P-1)C.push(65533);else{var G=T.charCodeAt(Q+1);if(56320<=G&&G<=57343){var J=W&1023,$=G&1023;C.push(65536+(J<<10)+$),Q+=1}else C.push(65533)}Q+=1}return C}function Qj(T){var A="";for(var P=0;P<T.length;++P){var Q=T[P];if(Q<=65535)A+=String.fromCharCode(Q);else Q-=65536,A+=String.fromCharCode((Q>>10)+55296,(Q&1023)+56320)}return A}function VC(T){this.tokens=[].slice.call(T)}function $C(T,A){if(T)throw TypeError("Decoder error");return A||65533}function Cj(){}function Wj(){}function n6(T,A){if(!(this instanceof n6))return new n6(T,A);if(T=T!==void 0?String(T).toLowerCase():o6,T!==o6)throw Error("Encoding not supported. Only utf-8 is supported");A=i6(A),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=Boolean(A.fatal),this._ignoreBOM=Boolean(A.ignoreBOM),Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}function f6(T,A){if(!(this instanceof f6))return new f6(T,A);if(T=T!==void 0?String(T).toLowerCase():o6,T!==o6)throw Error("Encoding not supported. Only utf-8 is supported");A=i6(A),this._streaming=!1,this._encoder=null,this._options={fatal:Boolean(A.fatal)},Object.defineProperty(this,"encoding",{value:"utf-8"})}function Gj(T){var A=T.fatal,P=0,Q=0,C=0,W=128,G=191;this.handler=function(J,$){if($===c6&&C!==0)return C=0,$C(A);if($===c6)return N8;if(C===0){if(QA($,0,127))return $;if(QA($,194,223))C=1,P=$-192;else if(QA($,224,239)){if($===224)W=160;if($===237)G=159;C=2,P=$-224}else if(QA($,240,244)){if($===240)W=144;if($===244)G=143;C=3,P=$-240}else return $C(A);return P=P<<6*C,null}if(!QA($,W,G))return P=C=Q=0,W=128,G=191,J.prepend($),$C(A);if(W=128,G=191,Q+=1,P+=$-128<<6*(C-Q),Q!==C)return null;var X=P;return P=C=Q=0,X}}function Uj(T){var A=T.fatal;this.handler=function(P,Q){if(Q===c6)return N8;if(QA(Q,0,127))return Q;var C,W;if(QA(Q,128,2047))C=1,W=192;else if(QA(Q,2048,65535))C=2,W=224;else if(QA(Q,65536,1114111))C=3,W=240;var G=[(Q>>6*C)+W];while(C>0){var J=Q>>6*(C-1);G.push(128|J&63),C-=1}return G}}var c6=-1,N8=-1,o6="utf-8";var X9=jT(()=>{VC.prototype={endOfStream:function(){return!this.tokens.length},read:function(){if(!this.tokens.length)return c6;return this.tokens.shift()},prepend:function(T){if(Array.isArray(T)){var A=T;while(A.length)this.tokens.unshift(A.pop())}else this.tokens.unshift(T)},push:function(T){if(Array.isArray(T)){var A=T;while(A.length)this.tokens.push(A.shift())}else this.tokens.push(T)}};Cj.prototype={handler:function(T,A){}};Wj.prototype={handler:function(T,A){}};n6.prototype={decode:function(A,P){var Q;if(typeof A==="object"&&A instanceof ArrayBuffer)Q=new Uint8Array(A);else if(typeof A==="object"&&"buffer"in A&&A.buffer instanceof ArrayBuffer)Q=new Uint8Array(A.buffer,A.byteOffset,A.byteLength);else Q=new Uint8Array(0);if(P=i6(P),!this._streaming)this._decoder=new Gj({fatal:this._fatal}),this._BOMseen=!1;this._streaming=Boolean(P.stream);var C=new VC(Q),W=[],G;while(!C.endOfStream()){if(G=this._decoder.handler(C,C.read()),G===N8)break;if(G===null)continue;if(Array.isArray(G))W.push.apply(W,G);else W.push(G)}if(!this._streaming){do{if(G=this._decoder.handler(C,C.read()),G===N8)break;if(G===null)continue;if(Array.isArray(G))W.push.apply(W,G);else W.push(G)}while(!C.endOfStream());this._decoder=null}if(W.length){if(["utf-8"].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen)if(W[0]===65279)this._BOMseen=!0,W.shift();else this._BOMseen=!0}return Qj(W)}};f6.prototype={encode:function(A,P){if(A=A?String(A):"",P=i6(P),!this._streaming)this._encoder=new Uj(this._options);this._streaming=Boolean(P.stream);var Q=[],C=new VC(Pj(A)),W;while(!C.endOfStream()){if(W=this._encoder.handler(C,C.read()),W===N8)break;if(Array.isArray(W))Q.push.apply(Q,W);else Q.push(W)}if(!this._streaming){while(!0){if(W=this._encoder.handler(C,C.read()),W===N8)break;if(Array.isArray(W))Q.push.apply(Q,W);else Q.push(W)}this._encoder=null}return new Uint8Array(Q)}}});var j9=T0((Y1)=>{var Jj=Y1&&Y1.__createBinding||(Object.create?function(T,A,P,Q){if(Q===void 0)Q=P;Object.defineProperty(T,Q,{enumerable:!0,get:function(){return A[P]}})}:function(T,A,P,Q){if(Q===void 0)Q=P;T[Q]=A[P]}),$j=Y1&&Y1.__setModuleDefault||(Object.create?function(T,A){Object.defineProperty(T,"default",{enumerable:!0,value:A})}:function(T,A){T.default=A}),h0=Y1&&Y1.__decorate||function(T,A,P,Q){var C=arguments.length,W=C<3?A:Q===null?Q=Object.getOwnPropertyDescriptor(A,P):Q,G;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")W=Reflect.decorate(T,A,P,Q);else for(var J=T.length-1;J>=0;J--)if(G=T[J])W=(C<3?G(W):C>3?G(A,P,W):G(A,P))||W;return C>3&&W&&Object.defineProperty(A,P,W),W},Vj=Y1&&Y1.__importStar||function(T){if(T&&T.__esModule)return T;var A={};if(T!=null){for(var P in T)if(P!=="default"&&Object.hasOwnProperty.call(T,P))Jj(A,T,P)}return $j(A,T),A},H9=Y1&&Y1.__importDefault||function(T){return T&&T.__esModule?T:{default:T}};Object.defineProperty(Y1,"__esModule",{value:!0});Y1.deserializeUnchecked=Y1.deserialize=Y1.serialize=Y1.BinaryReader=Y1.BinaryWriter=Y1.BorshError=Y1.baseDecode=Y1.baseEncode=void 0;var IA=H9(WC()),K9=H9(UC()),qj=Vj((X9(),G8(Z9))),Yj=typeof TextDecoder!=="function"?qj.TextDecoder:TextDecoder,Zj=new Yj("utf-8",{fatal:!0});function Xj(T){if(typeof T==="string")T=Buffer.from(T,"utf8");return K9.default.encode(Buffer.from(T))}Y1.baseEncode=Xj;function Hj(T){return Buffer.from(K9.default.decode(T))}Y1.baseDecode=Hj;var qC=1024;class zT extends Error{constructor(T){super(T);this.fieldPath=[],this.originalMessage=T}addToFieldPath(T){this.fieldPath.splice(0,0,T),this.message=this.originalMessage+": "+this.fieldPath.join(".")}}Y1.BorshError=zT;class YC{constructor(){this.buf=Buffer.alloc(qC),this.length=0}maybeResize(){if(this.buf.length<16+this.length)this.buf=Buffer.concat([this.buf,Buffer.alloc(qC)])}writeU8(T){this.maybeResize(),this.buf.writeUInt8(T,this.length),this.length+=1}writeU16(T){this.maybeResize(),this.buf.writeUInt16LE(T,this.length),this.length+=2}writeU32(T){this.maybeResize(),this.buf.writeUInt32LE(T,this.length),this.length+=4}writeU64(T){this.maybeResize(),this.writeBuffer(Buffer.from(new IA.default(T).toArray("le",8)))}writeU128(T){this.maybeResize(),this.writeBuffer(Buffer.from(new IA.default(T).toArray("le",16)))}writeU256(T){this.maybeResize(),this.writeBuffer(Buffer.from(new IA.default(T).toArray("le",32)))}writeU512(T){this.maybeResize(),this.writeBuffer(Buffer.from(new IA.default(T).toArray("le",64)))}writeBuffer(T){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),T,Buffer.alloc(qC)]),this.length+=T.length}writeString(T){this.maybeResize();let A=Buffer.from(T,"utf8");this.writeU32(A.length),this.writeBuffer(A)}writeFixedArray(T){this.writeBuffer(Buffer.from(T))}writeArray(T,A){this.maybeResize(),this.writeU32(T.length);for(let P of T)this.maybeResize(),A(P)}toArray(){return this.buf.subarray(0,this.length)}}Y1.BinaryWriter=YC;function m0(T,A,P){let Q=P.value;P.value=function(...C){try{return Q.apply(this,C)}catch(W){if(W instanceof RangeError){let G=W.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(G)>=0)throw new zT("Reached the end of buffer when deserializing")}throw W}}}class oT{constructor(T){this.buf=T,this.offset=0}readU8(){let T=this.buf.readUInt8(this.offset);return this.offset+=1,T}readU16(){let T=this.buf.readUInt16LE(this.offset);return this.offset+=2,T}readU32(){let T=this.buf.readUInt32LE(this.offset);return this.offset+=4,T}readU64(){let T=this.readBuffer(8);return new IA.default(T,"le")}readU128(){let T=this.readBuffer(16);return new IA.default(T,"le")}readU256(){let T=this.readBuffer(32);return new IA.default(T,"le")}readU512(){let T=this.readBuffer(64);return new IA.default(T,"le")}readBuffer(T){if(this.offset+T>this.buf.length)throw new zT(`Expected buffer length ${T} isn't within bounds`);let A=this.buf.slice(this.offset,this.offset+T);return this.offset+=T,A}readString(){let T=this.readU32(),A=this.readBuffer(T);try{return Zj.decode(A)}catch(P){throw new zT(`Error decoding UTF-8 string: ${P}`)}}readFixedArray(T){return new Uint8Array(this.readBuffer(T))}readArray(T){let A=this.readU32(),P=Array();for(let Q=0;Q<A;++Q)P.push(T());return P}}h0([m0],oT.prototype,"readU8",null);h0([m0],oT.prototype,"readU16",null);h0([m0],oT.prototype,"readU32",null);h0([m0],oT.prototype,"readU64",null);h0([m0],oT.prototype,"readU128",null);h0([m0],oT.prototype,"readU256",null);h0([m0],oT.prototype,"readU512",null);h0([m0],oT.prototype,"readString",null);h0([m0],oT.prototype,"readFixedArray",null);h0([m0],oT.prototype,"readArray",null);Y1.BinaryReader=oT;function R9(T){return T.charAt(0).toUpperCase()+T.slice(1)}function sA(T,A,P,Q,C){try{if(typeof Q==="string")C[`write${R9(Q)}`](P);else if(Q instanceof Array)if(typeof Q[0]==="number"){if(P.length!==Q[0])throw new zT(`Expecting byte array of length ${Q[0]}, but got ${P.length} bytes`);C.writeFixedArray(P)}else if(Q.length===2&&typeof Q[1]==="number"){if(P.length!==Q[1])throw new zT(`Expecting byte array of length ${Q[1]}, but got ${P.length} bytes`);for(let W=0;W<Q[1];W++)sA(T,null,P[W],Q[0],C)}else C.writeArray(P,(W)=>{sA(T,A,W,Q[0],C)});else if(Q.kind!==void 0)switch(Q.kind){case"option":{if(P===null||P===void 0)C.writeU8(0);else C.writeU8(1),sA(T,A,P,Q.type,C);break}case"map":{C.writeU32(P.size),P.forEach((W,G)=>{sA(T,A,G,Q.key,C),sA(T,A,W,Q.value,C)});break}default:throw new zT(`FieldType ${Q} unrecognized`)}else k9(T,P,C)}catch(W){if(W instanceof zT)W.addToFieldPath(A);throw W}}function k9(T,A,P){if(typeof A.borshSerialize==="function"){A.borshSerialize(P);return}let Q=T.get(A.constructor);if(!Q)throw new zT(`Class ${A.constructor.name} is missing in schema`);if(Q.kind==="struct")Q.fields.map(([C,W])=>{sA(T,C,A[C],W,P)});else if(Q.kind==="enum"){let C=A[Q.field];for(let W=0;W<Q.values.length;++W){let[G,J]=Q.values[W];if(G===C){P.writeU8(W),sA(T,G,A[G],J,P);break}}}else throw new zT(`Unexpected schema kind: ${Q.kind} for ${A.constructor.name}`)}function Kj(T,A,P=YC){let Q=new P;return k9(T,A,Q),Q.toArray()}Y1.serialize=Kj;function tA(T,A,P,Q){try{if(typeof P==="string")return Q[`read${R9(P)}`]();if(P instanceof Array)if(typeof P[0]==="number")return Q.readFixedArray(P[0]);else if(typeof P[1]==="number"){let C=[];for(let W=0;W<P[1];W++)C.push(tA(T,null,P[0],Q));return C}else return Q.readArray(()=>tA(T,A,P[0],Q));if(P.kind==="option"){if(Q.readU8())return tA(T,A,P.type,Q);return}if(P.kind==="map"){let C=new Map,W=Q.readU32();for(let G=0;G<W;G++){let J=tA(T,A,P.key,Q),$=tA(T,A,P.value,Q);C.set(J,$)}return C}return ZC(T,P,Q)}catch(C){if(C instanceof zT)C.addToFieldPath(A);throw C}}function ZC(T,A,P){if(typeof A.borshDeserialize==="function")return A.borshDeserialize(P);let Q=T.get(A);if(!Q)throw new zT(`Class ${A.name} is missing in schema`);if(Q.kind==="struct"){let C={};for(let[W,G]of T.get(A).fields)C[W]=tA(T,W,G,P);return new A(C)}if(Q.kind==="enum"){let C=P.readU8();if(C>=Q.values.length)throw new zT(`Enum index: ${C} is out of range`);let[W,G]=Q.values[C],J=tA(T,W,G,P);return new A({[W]:J})}throw new zT(`Unexpected schema kind: ${Q.kind} for ${A.constructor.name}`)}function Rj(T,A,P,Q=oT){let C=new Q(P),W=ZC(T,A,C);if(C.offset<P.length)throw new zT(`Unexpected ${P.length-C.offset} bytes after deserialized data`);return W}Y1.deserialize=Rj;function kj(T,A,P,Q=oT){let C=new Q(P);return ZC(T,A,C)}Y1.deserializeUnchecked=kj});var CA=T0((D9)=>{Object.defineProperty(D9,"__esModule",{value:!0});D9.s16=D9.s8=D9.nu64be=D9.u48be=D9.u40be=D9.u32be=D9.u24be=D9.u16be=D9.nu64=D9.u48=D9.u40=D9.u32=D9.u24=D9.u16=D9.u8=D9.offset=D9.greedy=D9.Constant=D9.UTF8=D9.CString=D9.Blob=D9.Boolean=D9.BitField=D9.BitStructure=D9.VariantLayout=D9.Union=D9.UnionLayoutDiscriminator=D9.UnionDiscriminator=D9.Structure=D9.Sequence=D9.DoubleBE=D9.Double=D9.FloatBE=D9.Float=D9.NearInt64BE=D9.NearInt64=D9.NearUInt64BE=D9.NearUInt64=D9.IntBE=D9.Int=D9.UIntBE=D9.UInt=D9.OffsetLayout=D9.GreedyCount=D9.ExternalLayout=D9.bindConstructorLayout=D9.nameWithProperty=D9.Layout=D9.uint8ArrayToBuffer=D9.checkUint8Array=void 0;D9.constant=D9.utf8=D9.cstr=D9.blob=D9.unionLayoutDiscriminator=D9.union=D9.seq=D9.bits=D9.struct=D9.f64be=D9.f64=D9.f32be=D9.f32=D9.ns64be=D9.s48be=D9.s40be=D9.s32be=D9.s24be=D9.s16be=D9.ns64=D9.s48=D9.s40=D9.s32=D9.s24=void 0;var HC=(j8(),G8(O6));function L8(T){if(!(T instanceof Uint8Array))throw TypeError("b must be a Uint8Array")}D9.checkUint8Array=L8;function G1(T){return L8(T),HC.Buffer.from(T.buffer,T.byteOffset,T.length)}D9.uint8ArrayToBuffer=G1;class V1{constructor(T,A){if(!Number.isInteger(T))throw TypeError("span must be an integer");this.span=T,this.property=A}makeDestinationObject(){return{}}getSpan(T,A){if(0>this.span)throw RangeError("indeterminate span");return this.span}replicate(T){let A=Object.create(this.constructor.prototype);return Object.assign(A,this),A.property=T,A}fromArray(T){return}}D9.Layout=V1;function KC(T,A){if(A.property)return T+"["+A.property+"]";return T}D9.nameWithProperty=KC;function jj(T,A){if(typeof T!=="function")throw TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(T,"layout_"))throw Error("Class is already bound to a layout");if(!(A&&A instanceof V1))throw TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(A,"boundConstructor_"))throw Error("layout is already bound to a constructor");T.layout_=A,A.boundConstructor_=T,A.makeDestinationObject=()=>new T,Object.defineProperty(T.prototype,"encode",{value(P,Q){return A.encode(this,P,Q)},writable:!0}),Object.defineProperty(T,"decode",{value(P,Q){return A.decode(P,Q)},writable:!0})}D9.bindConstructorLayout=jj;class mT extends V1{isCount(){throw Error("ExternalLayout is abstract")}}D9.ExternalLayout=mT;class RC extends mT{constructor(T=1,A){if(!Number.isInteger(T)||0>=T)throw TypeError("elementSpan must be a (positive) integer");super(-1,A);this.elementSpan=T}isCount(){return!0}decode(T,A=0){L8(T);let P=T.length-A;return Math.floor(P/this.elementSpan)}encode(T,A,P){return 0}}D9.GreedyCount=RC;class a6 extends mT{constructor(T,A=0,P){if(!(T instanceof V1))throw TypeError("layout must be a Layout");if(!Number.isInteger(A))throw TypeError("offset must be integer or undefined");super(T.span,P||T.property);this.layout=T,this.offset=A}isCount(){return this.layout instanceof eT||this.layout instanceof $0}decode(T,A=0){return this.layout.decode(T,A+this.offset)}encode(T,A,P=0){return this.layout.encode(T,A,P+this.offset)}}D9.OffsetLayout=a6;class eT extends V1{constructor(T,A){super(T,A);if(6<this.span)throw RangeError("span must not exceed 6 bytes")}decode(T,A=0){return G1(T).readUIntLE(A,this.span)}encode(T,A,P=0){return G1(A).writeUIntLE(T,P,this.span),this.span}}D9.UInt=eT;class $0 extends V1{constructor(T,A){super(T,A);if(6<this.span)throw RangeError("span must not exceed 6 bytes")}decode(T,A=0){return G1(T).readUIntBE(A,this.span)}encode(T,A,P=0){return G1(A).writeUIntBE(T,P,this.span),this.span}}D9.UIntBE=$0;class SA extends V1{constructor(T,A){super(T,A);if(6<this.span)throw RangeError("span must not exceed 6 bytes")}decode(T,A=0){return G1(T).readIntLE(A,this.span)}encode(T,A,P=0){return G1(A).writeIntLE(T,P,this.span),this.span}}D9.Int=SA;class eA extends V1{constructor(T,A){super(T,A);if(6<this.span)throw RangeError("span must not exceed 6 bytes")}decode(T,A=0){return G1(T).readIntBE(A,this.span)}encode(T,A,P=0){return G1(A).writeIntBE(T,P,this.span),this.span}}D9.IntBE=eA;var XC=Math.pow(2,32);function s6(T){let A=Math.floor(T/XC),P=T-A*XC;return{hi32:A,lo32:P}}function t6(T,A){return T*XC+A}class kC extends V1{constructor(T){super(8,T)}decode(T,A=0){let P=G1(T),Q=P.readUInt32LE(A),C=P.readUInt32LE(A+4);return t6(C,Q)}encode(T,A,P=0){let Q=s6(T),C=G1(A);return C.writeUInt32LE(Q.lo32,P),C.writeUInt32LE(Q.hi32,P+4),8}}D9.NearUInt64=kC;class jC extends V1{constructor(T){super(8,T)}decode(T,A=0){let P=G1(T),Q=P.readUInt32BE(A),C=P.readUInt32BE(A+4);return t6(Q,C)}encode(T,A,P=0){let Q=s6(T),C=G1(A);return C.writeUInt32BE(Q.hi32,P),C.writeUInt32BE(Q.lo32,P+4),8}}D9.NearUInt64BE=jC;class DC extends V1{constructor(T){super(8,T)}decode(T,A=0){let P=G1(T),Q=P.readUInt32LE(A),C=P.readInt32LE(A+4);return t6(C,Q)}encode(T,A,P=0){let Q=s6(T),C=G1(A);return C.writeUInt32LE(Q.lo32,P),C.writeInt32LE(Q.hi32,P+4),8}}D9.NearInt64=DC;class FC extends V1{constructor(T){super(8,T)}decode(T,A=0){let P=G1(T),Q=P.readInt32BE(A),C=P.readUInt32BE(A+4);return t6(Q,C)}encode(T,A,P=0){let Q=s6(T),C=G1(A);return C.writeInt32BE(Q.hi32,P),C.writeUInt32BE(Q.lo32,P+4),8}}D9.NearInt64BE=FC;class MC extends V1{constructor(T){super(4,T)}decode(T,A=0){return G1(T).readFloatLE(A)}encode(T,A,P=0){return G1(A).writeFloatLE(T,P),4}}D9.Float=MC;class zC extends V1{constructor(T){super(4,T)}decode(T,A=0){return G1(T).readFloatBE(A)}encode(T,A,P=0){return G1(A).writeFloatBE(T,P),4}}D9.FloatBE=zC;class IC extends V1{constructor(T){super(8,T)}decode(T,A=0){return G1(T).readDoubleLE(A)}encode(T,A,P=0){return G1(A).writeDoubleLE(T,P),8}}D9.Double=IC;class SC extends V1{constructor(T){super(8,T)}decode(T,A=0){return G1(T).readDoubleBE(A)}encode(T,A,P=0){return G1(A).writeDoubleBE(T,P),8}}D9.DoubleBE=SC;class NC extends V1{constructor(T,A,P){if(!(T instanceof V1))throw TypeError("elementLayout must be a Layout");if(!(A instanceof mT&&A.isCount()||Number.isInteger(A)&&0<=A))throw TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let Q=-1;if(!(A instanceof mT)&&0<T.span)Q=A*T.span;super(Q,P);this.elementLayout=T,this.count=A}getSpan(T,A=0){if(0<=this.span)return this.span;let P=0,Q=this.count;if(Q instanceof mT)Q=Q.decode(T,A);if(0<this.elementLayout.span)P=Q*this.elementLayout.span;else{let C=0;while(C<Q)P+=this.elementLayout.getSpan(T,A+P),++C}return P}decode(T,A=0){let P=[],Q=0,C=this.count;if(C instanceof mT)C=C.decode(T,A);while(Q<C)P.push(this.elementLayout.decode(T,A)),A+=this.elementLayout.getSpan(T,A),Q+=1;return P}encode(T,A,P=0){let Q=this.elementLayout,C=T.reduce((W,G)=>{return W+Q.encode(G,A,P+W)},0);if(this.count instanceof mT)this.count.encode(T.length,A,P);return C}}D9.Sequence=NC;class wC extends V1{constructor(T,A,P){if(!(Array.isArray(T)&&T.reduce((C,W)=>C&&W instanceof V1,!0)))throw TypeError("fields must be array of Layout instances");if(typeof A==="boolean"&&P===void 0)P=A,A=void 0;for(let C of T)if(0>C.span&&C.property===void 0)throw Error("fields cannot contain unnamed variable-length layout");let Q=-1;try{Q=T.reduce((C,W)=>C+W.getSpan(),0)}catch(C){}super(Q,A);this.fields=T,this.decodePrefixes=!!P}getSpan(T,A=0){if(0<=this.span)return this.span;let P=0;try{P=this.fields.reduce((Q,C)=>{let W=C.getSpan(T,A);return A+=W,Q+W},0)}catch(Q){throw RangeError("indeterminate span")}return P}decode(T,A=0){L8(T);let P=this.makeDestinationObject();for(let Q of this.fields){if(Q.property!==void 0)P[Q.property]=Q.decode(T,A);if(A+=Q.getSpan(T,A),this.decodePrefixes&&T.length===A)break}return P}encode(T,A,P=0){let Q=P,C=0,W=0;for(let G of this.fields){let J=G.span;if(W=0<J?J:0,G.property!==void 0){let $=T[G.property];if($!==void 0){if(W=G.encode($,A,P),0>J)J=G.getSpan(A,P)}}C=P,P+=J}return C+W-Q}fromArray(T){let A=this.makeDestinationObject();for(let P of this.fields)if(P.property!==void 0&&0<T.length)A[P.property]=T.shift();return A}layoutFor(T){if(typeof T!=="string")throw TypeError("property must be string");for(let A of this.fields)if(A.property===T)return A;return}offsetOf(T){if(typeof T!=="string")throw TypeError("property must be string");let A=0;for(let P of this.fields){if(P.property===T)return A;if(0>P.span)A=-1;else if(0<=A)A+=P.span}return}}D9.Structure=wC;class e6{constructor(T){this.property=T}decode(T,A){throw Error("UnionDiscriminator is abstract")}encode(T,A,P){throw Error("UnionDiscriminator is abstract")}}D9.UnionDiscriminator=e6;class Y2 extends e6{constructor(T,A){if(!(T instanceof mT&&T.isCount()))throw TypeError("layout must be an unsigned integer ExternalLayout");super(A||T.property||"variant");this.layout=T}decode(T,A){return this.layout.decode(T,A)}encode(T,A,P){return this.layout.encode(T,A,P)}}D9.UnionLayoutDiscriminator=Y2;class T4 extends V1{constructor(T,A,P){let Q;if(T instanceof eT||T instanceof $0)Q=new Y2(new a6(T));else if(T instanceof mT&&T.isCount())Q=new Y2(T);else if(!(T instanceof e6))throw TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");else Q=T;if(A===void 0)A=null;if(!(A===null||A instanceof V1))throw TypeError("defaultLayout must be null or a Layout");if(A!==null){if(0>A.span)throw Error("defaultLayout must have constant span");if(A.property===void 0)A=A.replicate("content")}let C=-1;if(A){if(C=A.span,0<=C&&(T instanceof eT||T instanceof $0))C+=Q.layout.span}super(C,P);this.discriminator=Q,this.usesPrefixDiscriminator=T instanceof eT||T instanceof $0,this.defaultLayout=A,this.registry={};let W=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(G){return W(G)},this.configGetSourceVariant=function(G){W=G.bind(this)}}getSpan(T,A=0){if(0<=this.span)return this.span;let P=this.getVariant(T,A);if(!P)throw Error("unable to determine span for unrecognized variant");return P.getSpan(T,A)}defaultGetSourceVariant(T){if(Object.prototype.hasOwnProperty.call(T,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(T,this.defaultLayout.property))return;let A=this.registry[T[this.discriminator.property]];if(A&&(!A.layout||A.property&&Object.prototype.hasOwnProperty.call(T,A.property)))return A}else for(let A in this.registry){let P=this.registry[A];if(P.property&&Object.prototype.hasOwnProperty.call(T,P.property))return P}throw Error("unable to infer src variant")}decode(T,A=0){let P,Q=this.discriminator,C=Q.decode(T,A),W=this.registry[C];if(W===void 0){let G=this.defaultLayout,J=0;if(this.usesPrefixDiscriminator)J=Q.layout.span;P=this.makeDestinationObject(),P[Q.property]=C,P[G.property]=G.decode(T,A+J)}else P=W.decode(T,A);return P}encode(T,A,P=0){let Q=this.getSourceVariant(T);if(Q===void 0){let C=this.discriminator,W=this.defaultLayout,G=0;if(this.usesPrefixDiscriminator)G=C.layout.span;return C.encode(T[C.property],A,P),G+W.encode(T[W.property],A,P+G)}return Q.encode(T,A,P)}addVariant(T,A,P){let Q=new LC(this,T,A,P);return this.registry[T]=Q,Q}getVariant(T,A=0){let P;if(T instanceof Uint8Array)P=this.discriminator.decode(T,A);else P=T;return this.registry[P]}}D9.Union=T4;class LC extends V1{constructor(T,A,P,Q){if(!(T instanceof T4))throw TypeError("union must be a Union");if(!Number.isInteger(A)||0>A)throw TypeError("variant must be a (non-negative) integer");if(typeof P==="string"&&Q===void 0)Q=P,P=null;if(P){if(!(P instanceof V1))throw TypeError("layout must be a Layout");if(T.defaultLayout!==null&&0<=P.span&&P.span>T.defaultLayout.span)throw Error("variant span exceeds span of containing union");if(typeof Q!=="string")throw TypeError("variant must have a String property")}let C=T.span;if(0>T.span){if(C=P?P.span:0,0<=C&&T.usesPrefixDiscriminator)C+=T.discriminator.layout.span}super(C,Q);this.union=T,this.variant=A,this.layout=P||null}getSpan(T,A=0){if(0<=this.span)return this.span;let P=0;if(this.union.usesPrefixDiscriminator)P=this.union.discriminator.layout.span;let Q=0;if(this.layout)Q=this.layout.getSpan(T,A+P);return P+Q}decode(T,A=0){let P=this.makeDestinationObject();if(this!==this.union.getVariant(T,A))throw Error("variant mismatch");let Q=0;if(this.union.usesPrefixDiscriminator)Q=this.union.discriminator.layout.span;if(this.layout)P[this.property]=this.layout.decode(T,A+Q);else if(this.property)P[this.property]=!0;else if(this.union.usesPrefixDiscriminator)P[this.union.discriminator.property]=this.variant;return P}encode(T,A,P=0){let Q=0;if(this.union.usesPrefixDiscriminator)Q=this.union.discriminator.layout.span;if(this.layout&&!Object.prototype.hasOwnProperty.call(T,this.property))throw TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,A,P);let C=Q;if(this.layout){if(this.layout.encode(T[this.property],A,P+Q),C+=this.layout.getSpan(A,P+Q),0<=this.union.span&&C>this.union.span)throw Error("encoded variant overruns containing union")}return C}fromArray(T){if(this.layout)return this.layout.fromArray(T);return}}D9.VariantLayout=LC;function w8(T){if(0>T)T+=4294967296;return T}class A4 extends V1{constructor(T,A,P){if(!(T instanceof eT||T instanceof $0))throw TypeError("word must be a UInt or UIntBE layout");if(typeof A==="string"&&P===void 0)P=A,A=!1;if(4<T.span)throw RangeError("word cannot exceed 32 bits");super(T.span,P);this.word=T,this.msb=!!A,this.fields=[];let Q=0;this._packedSetValue=function(C){return Q=w8(C),this},this._packedGetValue=function(){return Q}}decode(T,A=0){let P=this.makeDestinationObject(),Q=this.word.decode(T,A);this._packedSetValue(Q);for(let C of this.fields)if(C.property!==void 0)P[C.property]=C.decode(T);return P}encode(T,A,P=0){let Q=this.word.decode(A,P);this._packedSetValue(Q);for(let C of this.fields)if(C.property!==void 0){let W=T[C.property];if(W!==void 0)C.encode(W)}return this.word.encode(this._packedGetValue(),A,P)}addField(T,A){let P=new P4(this,T,A);return this.fields.push(P),P}addBoolean(T){let A=new EC(this,T);return this.fields.push(A),A}fieldFor(T){if(typeof T!=="string")throw TypeError("property must be string");for(let A of this.fields)if(A.property===T)return A;return}}D9.BitStructure=A4;class P4{constructor(T,A,P){if(!(T instanceof A4))throw TypeError("container must be a BitStructure");if(!Number.isInteger(A)||0>=A)throw TypeError("bits must be positive integer");let Q=8*T.span,C=T.fields.reduce((W,G)=>W+G.bits,0);if(A+C>Q)throw Error("bits too long for span remainder ("+(Q-C)+" of "+Q+" remain)");if(this.container=T,this.bits=A,this.valueMask=(1<<A)-1,A===32)this.valueMask=4294967295;if(this.start=C,this.container.msb)this.start=Q-C-A;this.wordMask=w8(this.valueMask<<this.start),this.property=P}decode(T,A){let P=this.container._packedGetValue();return w8(P&this.wordMask)>>>this.start}encode(T){if(typeof T!=="number"||!Number.isInteger(T)||T!==w8(T&this.valueMask))throw TypeError(KC("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);let A=this.container._packedGetValue(),P=w8(T<<this.start);this.container._packedSetValue(w8(A&~this.wordMask)|P)}}D9.BitField=P4;class EC extends P4{constructor(T,A){super(T,1,A)}decode(T,A){return!!super.decode(T,A)}encode(T){if(typeof T==="boolean")T=+T;super.encode(T)}}D9.Boolean=EC;class BC extends V1{constructor(T,A){if(!(T instanceof mT&&T.isCount()||Number.isInteger(T)&&0<=T))throw TypeError("length must be positive integer or an unsigned integer ExternalLayout");let P=-1;if(!(T instanceof mT))P=T;super(P,A);this.length=T}getSpan(T,A){let P=this.span;if(0>P)P=this.length.decode(T,A);return P}decode(T,A=0){let P=this.span;if(0>P)P=this.length.decode(T,A);return G1(T).slice(A,A+P)}encode(T,A,P){let Q=this.length;if(this.length instanceof mT)Q=T.length;if(!(T instanceof Uint8Array&&Q===T.length))throw TypeError(KC("Blob.encode",this)+" requires (length "+Q+") Uint8Array as src");if(P+Q>A.length)throw RangeError("encoding overruns Uint8Array");let C=G1(T);if(G1(A).write(C.toString("hex"),P,Q,"hex"),this.length instanceof mT)this.length.encode(Q,A,P);return Q}}D9.Blob=BC;class OC extends V1{constructor(T){super(-1,T)}getSpan(T,A=0){L8(T);let P=A;while(P<T.length&&T[P]!==0)P+=1;return 1+P-A}decode(T,A=0){let P=this.getSpan(T,A);return G1(T).slice(A,A+P-1).toString("utf-8")}encode(T,A,P=0){if(typeof T!=="string")T=String(T);let Q=HC.Buffer.from(T,"utf8"),C=Q.length;if(P+C>A.length)throw RangeError("encoding overruns Buffer");let W=G1(A);return Q.copy(W,P),W[P+C]=0,C+1}}D9.CString=OC;class xC extends V1{constructor(T,A){if(typeof T==="string"&&A===void 0)A=T,T=void 0;if(T===void 0)T=-1;else if(!Number.isInteger(T))throw TypeError("maxSpan must be an integer");super(-1,A);this.maxSpan=T}getSpan(T,A=0){return L8(T),T.length-A}decode(T,A=0){let P=this.getSpan(T,A);if(0<=this.maxSpan&&this.maxSpan<P)throw RangeError("text length exceeds maxSpan");return G1(T).slice(A,A+P).toString("utf-8")}encode(T,A,P=0){if(typeof T!=="string")T=String(T);let Q=HC.Buffer.from(T,"utf8"),C=Q.length;if(0<=this.maxSpan&&this.maxSpan<C)throw RangeError("text length exceeds maxSpan");if(P+C>A.length)throw RangeError("encoding overruns Buffer");return Q.copy(G1(A),P),C}}D9.UTF8=xC;class _C extends V1{constructor(T,A){super(0,A);this.value=T}decode(T,A){return this.value}encode(T,A,P){return 0}}D9.Constant=_C;D9.greedy=(T,A)=>new RC(T,A);D9.offset=(T,A,P)=>new a6(T,A,P);D9.u8=(T)=>new eT(1,T);D9.u16=(T)=>new eT(2,T);D9.u24=(T)=>new eT(3,T);D9.u32=(T)=>new eT(4,T);D9.u40=(T)=>new eT(5,T);D9.u48=(T)=>new eT(6,T);D9.nu64=(T)=>new kC(T);D9.u16be=(T)=>new $0(2,T);D9.u24be=(T)=>new $0(3,T);D9.u32be=(T)=>new $0(4,T);D9.u40be=(T)=>new $0(5,T);D9.u48be=(T)=>new $0(6,T);D9.nu64be=(T)=>new jC(T);D9.s8=(T)=>new SA(1,T);D9.s16=(T)=>new SA(2,T);D9.s24=(T)=>new SA(3,T);D9.s32=(T)=>new SA(4,T);D9.s40=(T)=>new SA(5,T);D9.s48=(T)=>new SA(6,T);D9.ns64=(T)=>new DC(T);D9.s16be=(T)=>new eA(2,T);D9.s24be=(T)=>new eA(3,T);D9.s32be=(T)=>new eA(4,T);D9.s40be=(T)=>new eA(5,T);D9.s48be=(T)=>new eA(6,T);D9.ns64be=(T)=>new FC(T);D9.f32=(T)=>new MC(T);D9.f32be=(T)=>new zC(T);D9.f64=(T)=>new IC(T);D9.f64be=(T)=>new SC(T);D9.struct=(T,A,P)=>new wC(T,A,P);D9.bits=(T,A,P)=>new A4(T,A,P);D9.seq=(T,A,P)=>new NC(T,A,P);D9.union=(T,A,P)=>new T4(T,A,P);D9.unionLayoutDiscriminator=(T,A)=>new Y2(T,A);D9.blob=(T,A)=>new BC(T,A);D9.cstr=(T)=>new OC(T);D9.utf8=(T,A)=>new xC(T,A);D9.constant=(T,A)=>new _C(T,A)});function H2(){if(!G4){if(G4=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues==="function"&&msCrypto.getRandomValues.bind(msCrypto),!G4)throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported")}return G4(sM)}var G4,sM;var dC=jT(()=>{sM=new Uint8Array(16)});var p9;var u9=jT(()=>{p9=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i});function tM(T){return typeof T==="string"&&p9.test(T)}var wA;var K2=jT(()=>{u9();wA=tM});function eM(T){var A=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,P=(kT[T[A+0]]+kT[T[A+1]]+kT[T[A+2]]+kT[T[A+3]]+"-"+kT[T[A+4]]+kT[T[A+5]]+"-"+kT[T[A+6]]+kT[T[A+7]]+"-"+kT[T[A+8]]+kT[T[A+9]]+"-"+kT[T[A+10]]+kT[T[A+11]]+kT[T[A+12]]+kT[T[A+13]]+kT[T[A+14]]+kT[T[A+15]]).toLowerCase();if(!wA(P))throw TypeError("Stringified UUID is invalid");return P}var kT,R2,LA;var k2=jT(()=>{K2();kT=[];for(R2=0;R2<256;++R2)kT.push((R2+256).toString(16).substr(1));LA=eM});function Tz(T,A,P){var Q=A&&P||0,C=A||Array(16);T=T||{};var W=T.node||d9,G=T.clockseq!==void 0?T.clockseq:rC;if(W==null||G==null){var J=T.random||(T.rng||H2)();if(W==null)W=d9=[J[0]|1,J[1],J[2],J[3],J[4],J[5]];if(G==null)G=rC=(J[6]<<8|J[7])&16383}var $=T.msecs!==void 0?T.msecs:Date.now(),X=T.nsecs!==void 0?T.nsecs:oC+1,Z=$-cC+(X-oC)/1e4;if(Z<0&&T.clockseq===void 0)G=G+1&16383;if((Z<0||$>cC)&&T.nsecs===void 0)X=0;if(X>=1e4)throw Error("uuid.v1(): Can't create more than 10M uuids/sec");cC=$,oC=X,rC=G,$+=12219292800000;var R=(($&268435455)*1e4+X)%4294967296;C[Q++]=R>>>24&255,C[Q++]=R>>>16&255,C[Q++]=R>>>8&255,C[Q++]=R&255;var D=$/4294967296*1e4&268435455;C[Q++]=D>>>8&255,C[Q++]=D&255,C[Q++]=D>>>24&15|16,C[Q++]=D>>>16&255,C[Q++]=G>>>8|128,C[Q++]=G&255;for(var z=0;z<6;++z)C[Q+z]=W[z];return A||LA(C)}var d9,rC,cC=0,oC=0,r9;var c9=jT(()=>{dC();k2();r9=Tz});function Az(T){if(!wA(T))throw TypeError("Invalid UUID");var A,P=new Uint8Array(16);return P[0]=(A=parseInt(T.slice(0,8),16))>>>24,P[1]=A>>>16&255,P[2]=A>>>8&255,P[3]=A&255,P[4]=(A=parseInt(T.slice(9,13),16))>>>8,P[5]=A&255,P[6]=(A=parseInt(T.slice(14,18),16))>>>8,P[7]=A&255,P[8]=(A=parseInt(T.slice(19,23),16))>>>8,P[9]=A&255,P[10]=(A=parseInt(T.slice(24,36),16))/1099511627776&255,P[11]=A/4294967296&255,P[12]=A>>>24&255,P[13]=A>>>16&255,P[14]=A>>>8&255,P[15]=A&255,P}var U4;var nC=jT(()=>{K2();U4=Az});function Pz(T){T=unescape(encodeURIComponent(T));var A=[];for(var P=0;P<T.length;++P)A.push(T.charCodeAt(P));return A}function j2(T,A,P){function Q(C,W,G,J){if(typeof C==="string")C=Pz(C);if(typeof W==="string")W=U4(W);if(W.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var $=new Uint8Array(16+C.length);if($.set(W),$.set(C,W.length),$=P($),$[6]=$[6]&15|A,$[8]=$[8]&63|128,G){J=J||0;for(var X=0;X<16;++X)G[J+X]=$[X];return G}return LA($)}try{Q.name=T}catch(C){}return Q.DNS=Qz,Q.URL=Cz,Q}var Qz="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Cz="6ba7b811-9dad-11d1-80b4-00c04fd430c8";var fC=jT(()=>{k2();nC()});function Wz(T){if(typeof T==="string"){var A=unescape(encodeURIComponent(T));T=new Uint8Array(A.length);for(var P=0;P<A.length;++P)T[P]=A.charCodeAt(P)}return Gz(Uz(Jz(T),T.length*8))}function Gz(T){var A=[],P=T.length*32,Q="0123456789abcdef";for(var C=0;C<P;C+=8){var W=T[C>>5]>>>C%32&255,G=parseInt(Q.charAt(W>>>4&15)+Q.charAt(W&15),16);A.push(G)}return A}function o9(T){return(T+64>>>9<<4)+14+1}function Uz(T,A){T[A>>5]|=128<<A%32,T[o9(A)-1]=A;var P=1732584193,Q=-271733879,C=-1732584194,W=271733878;for(var G=0;G<T.length;G+=16){var J=P,$=Q,X=C,Z=W;P=ST(P,Q,C,W,T[G],7,-680876936),W=ST(W,P,Q,C,T[G+1],12,-389564586),C=ST(C,W,P,Q,T[G+2],17,606105819),Q=ST(Q,C,W,P,T[G+3],22,-1044525330),P=ST(P,Q,C,W,T[G+4],7,-176418897),W=ST(W,P,Q,C,T[G+5],12,1200080426),C=ST(C,W,P,Q,T[G+6],17,-1473231341),Q=ST(Q,C,W,P,T[G+7],22,-45705983),P=ST(P,Q,C,W,T[G+8],7,1770035416),W=ST(W,P,Q,C,T[G+9],12,-1958414417),C=ST(C,W,P,Q,T[G+10],17,-42063),Q=ST(Q,C,W,P,T[G+11],22,-1990404162),P=ST(P,Q,C,W,T[G+12],7,1804603682),W=ST(W,P,Q,C,T[G+13],12,-40341101),C=ST(C,W,P,Q,T[G+14],17,-1502002290),Q=ST(Q,C,W,P,T[G+15],22,1236535329),P=NT(P,Q,C,W,T[G+1],5,-165796510),W=NT(W,P,Q,C,T[G+6],9,-1069501632),C=NT(C,W,P,Q,T[G+11],14,643717713),Q=NT(Q,C,W,P,T[G],20,-373897302),P=NT(P,Q,C,W,T[G+5],5,-701558691),W=NT(W,P,Q,C,T[G+10],9,38016083),C=NT(C,W,P,Q,T[G+15],14,-660478335),Q=NT(Q,C,W,P,T[G+4],20,-405537848),P=NT(P,Q,C,W,T[G+9],5,568446438),W=NT(W,P,Q,C,T[G+14],9,-1019803690),C=NT(C,W,P,Q,T[G+3],14,-187363961),Q=NT(Q,C,W,P,T[G+8],20,1163531501),P=NT(P,Q,C,W,T[G+13],5,-1444681467),W=NT(W,P,Q,C,T[G+2],9,-51403784),C=NT(C,W,P,Q,T[G+7],14,1735328473),Q=NT(Q,C,W,P,T[G+12],20,-1926607734),P=wT(P,Q,C,W,T[G+5],4,-378558),W=wT(W,P,Q,C,T[G+8],11,-2022574463),C=wT(C,W,P,Q,T[G+11],16,1839030562),Q=wT(Q,C,W,P,T[G+14],23,-35309556),P=wT(P,Q,C,W,T[G+1],4,-1530992060),W=wT(W,P,Q,C,T[G+4],11,1272893353),C=wT(C,W,P,Q,T[G+7],16,-155497632),Q=wT(Q,C,W,P,T[G+10],23,-1094730640),P=wT(P,Q,C,W,T[G+13],4,681279174),W=wT(W,P,Q,C,T[G],11,-358537222),C=wT(C,W,P,Q,T[G+3],16,-722521979),Q=wT(Q,C,W,P,T[G+6],23,76029189),P=wT(P,Q,C,W,T[G+9],4,-640364487),W=wT(W,P,Q,C,T[G+12],11,-421815835),C=wT(C,W,P,Q,T[G+15],16,530742520),Q=wT(Q,C,W,P,T[G+2],23,-995338651),P=LT(P,Q,C,W,T[G],6,-198630844),W=LT(W,P,Q,C,T[G+7],10,1126891415),C=LT(C,W,P,Q,T[G+14],15,-1416354905),Q=LT(Q,C,W,P,T[G+5],21,-57434055),P=LT(P,Q,C,W,T[G+12],6,1700485571),W=LT(W,P,Q,C,T[G+3],10,-1894986606),C=LT(C,W,P,Q,T[G+10],15,-1051523),Q=LT(Q,C,W,P,T[G+1],21,-2054922799),P=LT(P,Q,C,W,T[G+8],6,1873313359),W=LT(W,P,Q,C,T[G+15],10,-30611744),C=LT(C,W,P,Q,T[G+6],15,-1560198380),Q=LT(Q,C,W,P,T[G+13],21,1309151649),P=LT(P,Q,C,W,T[G+4],6,-145523070),W=LT(W,P,Q,C,T[G+11],10,-1120210379),C=LT(C,W,P,Q,T[G+2],15,718787259),Q=LT(Q,C,W,P,T[G+9],21,-343485551),P=EA(P,J),Q=EA(Q,$),C=EA(C,X),W=EA(W,Z)}return[P,Q,C,W]}function Jz(T){if(T.length===0)return[];var A=T.length*8,P=new Uint32Array(o9(A));for(var Q=0;Q<A;Q+=8)P[Q>>5]|=(T[Q/8]&255)<<Q%32;return P}function EA(T,A){var P=(T&65535)+(A&65535),Q=(T>>16)+(A>>16)+(P>>16);return Q<<16|P&65535}function $z(T,A){return T<<A|T>>>32-A}function J4(T,A,P,Q,C,W){return EA($z(EA(EA(A,T),EA(Q,W)),C),P)}function ST(T,A,P,Q,C,W,G){return J4(A&P|~A&Q,T,A,C,W,G)}function NT(T,A,P,Q,C,W,G){return J4(A&Q|P&~Q,T,A,C,W,G)}function wT(T,A,P,Q,C,W,G){return J4(A^P^Q,T,A,C,W,G)}function LT(T,A,P,Q,C,W,G){return J4(P^(A|~Q),T,A,C,W,G)}var n9;var f9=jT(()=>{n9=Wz});var Vz,i9;var a9=jT(()=>{fC();f9();Vz=j2("v3",48,n9),i9=Vz});function qz(T,A,P){T=T||{};var Q=T.random||(T.rng||H2)();if(Q[6]=Q[6]&15|64,Q[8]=Q[8]&63|128,A){P=P||0;for(var C=0;C<16;++C)A[P+C]=Q[C];return A}return LA(Q)}var s9;var t9=jT(()=>{dC();k2();s9=qz});function Yz(T,A,P,Q){switch(T){case 0:return A&P^~A&Q;case 1:return A^P^Q;case 2:return A&P^A&Q^P&Q;case 3:return A^P^Q}}function iC(T,A){return T<<A|T>>>32-A}function Zz(T){var A=[1518500249,1859775393,2400959708,3395469782],P=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof T==="string"){var Q=unescape(encodeURIComponent(T));T=[];for(var C=0;C<Q.length;++C)T.push(Q.charCodeAt(C))}else if(!Array.isArray(T))T=Array.prototype.slice.call(T);T.push(128);var W=T.length/4+2,G=Math.ceil(W/16),J=Array(G);for(var $=0;$<G;++$){var X=new Uint32Array(16);for(var Z=0;Z<16;++Z)X[Z]=T[$*64+Z*4]<<24|T[$*64+Z*4+1]<<16|T[$*64+Z*4+2]<<8|T[$*64+Z*4+3];J[$]=X}J[G-1][14]=(T.length-1)*8/Math.pow(2,32),J[G-1][14]=Math.floor(J[G-1][14]),J[G-1][15]=(T.length-1)*8&4294967295;for(var R=0;R<G;++R){var D=new Uint32Array(80);for(var z=0;z<16;++z)D[z]=J[R][z];for(var S=16;S<80;++S)D[S]=iC(D[S-3]^D[S-8]^D[S-14]^D[S-16],1);var E=P[0],w=P[1],O=P[2],m=P[3],g=P[4];for(var p=0;p<80;++p){var c=Math.floor(p/20),o=iC(E,5)+Yz(c,w,O,m)+g+A[c]+D[p]>>>0;g=m,m=O,O=iC(w,30)>>>0,w=E,E=o}P[0]=P[0]+E>>>0,P[1]=P[1]+w>>>0,P[2]=P[2]+O>>>0,P[3]=P[3]+m>>>0,P[4]=P[4]+g>>>0}return[P[0]>>24&255,P[0]>>16&255,P[0]>>8&255,P[0]&255,P[1]>>24&255,P[1]>>16&255,P[1]>>8&255,P[1]&255,P[2]>>24&255,P[2]>>16&255,P[2]>>8&255,P[2]&255,P[3]>>24&255,P[3]>>16&255,P[3]>>8&255,P[3]&255,P[4]>>24&255,P[4]>>16&255,P[4]>>8&255,P[4]&255]}var e9;var TV=jT(()=>{e9=Zz});var Xz,AV;var PV=jT(()=>{fC();TV();Xz=j2("v5",80,e9),AV=Xz});var QV="00000000-0000-0000-0000-000000000000";function Kz(T){if(!wA(T))throw TypeError("Invalid UUID");return parseInt(T.substr(14,1),16)}var CV;var WV=jT(()=>{K2();CV=Kz});var aC={};s4(aC,{version:()=>CV,validate:()=>wA,v5:()=>AV,v4:()=>s9,v3:()=>i9,v1:()=>r9,stringify:()=>LA,parse:()=>U4,NIL:()=>QV});var sC=jT(()=>{c9();a9();t9();PV();WV();K2();k2();nC()});var UV=T0((jx,GV)=>{var Rz=(sC(),G8(aC)).v4,kz=function(T,A,P,Q){if(typeof T!=="string")throw TypeError(T+" must be a string");Q=Q||{};let C=typeof Q.version==="number"?Q.version:2;if(C!==1&&C!==2)throw TypeError(C+" must be 1 or 2");let W={method:T};if(C===2)W.jsonrpc="2.0";if(A){if(typeof A!=="object"&&!Array.isArray(A))throw TypeError(A+" must be an object, array or omitted");W.params=A}if(typeof P>"u"){let G=typeof Q.generator==="function"?Q.generator:function(){return Rz()};W.id=G(W,Q)}else if(C===2&&P===null){if(Q.notificationIdNull)W.id=null}else W.id=P;return W};GV.exports=kz});var $V=T0((Dx,JV)=>{var jz=(sC(),G8(aC)).v4,Dz=UV(),D2=function(T,A){if(!(this instanceof D2))return new D2(T,A);if(!A)A={};this.options={reviver:typeof A.reviver<"u"?A.reviver:null,replacer:typeof A.replacer<"u"?A.replacer:null,generator:typeof A.generator<"u"?A.generator:function(){return jz()},version:typeof A.version<"u"?A.version:2,notificationIdNull:typeof A.notificationIdNull==="boolean"?A.notificationIdNull:!1},this.callServer=T};JV.exports=D2;D2.prototype.request=function(T,A,P,Q){let C=this,W=null,G=Array.isArray(T)&&typeof A==="function";if(this.options.version===1&&G)throw TypeError("JSON-RPC 1.0 does not support batching");if(G||!G&&T&&typeof T==="object"&&typeof A==="function")Q=A,W=T;else{if(typeof P==="function")Q=P,P=void 0;let X=typeof Q==="function";try{W=Dz(T,A,P,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(Z){if(X)return Q(Z);throw Z}if(!X)return W}let $;try{$=JSON.stringify(W,this.options.replacer)}catch(X){return Q(X)}return this.callServer($,function(X,Z){C._parseResponse(X,Z,Q)}),W};D2.prototype._parseResponse=function(T,A,P){if(T){P(T);return}if(!A)return P();let Q;try{Q=JSON.parse(A,this.options.reviver)}catch(C){return P(C)}if(P.length===3)if(Array.isArray(Q)){let C=function(G){return typeof G.error<"u"},W=function(G){return!C(G)};return P(null,Q.filter(C),Q.filter(W))}else return P(null,Q.error,Q.result);P(null,Q)}});var qV=T0((Fx,tC)=>{var Fz=Object.prototype.hasOwnProperty,gT="~";function F2(){}if(Object.create){if(F2.prototype=Object.create(null),!new F2().__proto__)gT=!1}function Mz(T,A,P){this.fn=T,this.context=A,this.once=P||!1}function VV(T,A,P,Q,C){if(typeof P!=="function")throw TypeError("The listener must be a function");var W=new Mz(P,Q||T,C),G=gT?gT+A:A;if(!T._events[G])T._events[G]=W,T._eventsCount++;else if(!T._events[G].fn)T._events[G].push(W);else T._events[G]=[T._events[G],W];return T}function $4(T,A){if(--T._eventsCount===0)T._events=new F2;else delete T._events[A]}function ET(){this._events=new F2,this._eventsCount=0}ET.prototype.eventNames=function(){var A=[],P,Q;if(this._eventsCount===0)return A;for(Q in P=this._events)if(Fz.call(P,Q))A.push(gT?Q.slice(1):Q);if(Object.getOwnPropertySymbols)return A.concat(Object.getOwnPropertySymbols(P));return A};ET.prototype.listeners=function(A){var P=gT?gT+A:A,Q=this._events[P];if(!Q)return[];if(Q.fn)return[Q.fn];for(var C=0,W=Q.length,G=Array(W);C<W;C++)G[C]=Q[C].fn;return G};ET.prototype.listenerCount=function(A){var P=gT?gT+A:A,Q=this._events[P];if(!Q)return 0;if(Q.fn)return 1;return Q.length};ET.prototype.emit=function(A,P,Q,C,W,G){var J=gT?gT+A:A;if(!this._events[J])return!1;var $=this._events[J],X=arguments.length,Z,R;if($.fn){if($.once)this.removeListener(A,$.fn,void 0,!0);switch(X){case 1:return $.fn.call($.context),!0;case 2:return $.fn.call($.context,P),!0;case 3:return $.fn.call($.context,P,Q),!0;case 4:return $.fn.call($.context,P,Q,C),!0;case 5:return $.fn.call($.context,P,Q,C,W),!0;case 6:return $.fn.call($.context,P,Q,C,W,G),!0}for(R=1,Z=Array(X-1);R<X;R++)Z[R-1]=arguments[R];$.fn.apply($.context,Z)}else{var D=$.length,z;for(R=0;R<D;R++){if($[R].once)this.removeListener(A,$[R].fn,void 0,!0);switch(X){case 1:$[R].fn.call($[R].context);break;case 2:$[R].fn.call($[R].context,P);break;case 3:$[R].fn.call($[R].context,P,Q);break;case 4:$[R].fn.call($[R].context,P,Q,C);break;default:if(!Z)for(z=1,Z=Array(X-1);z<X;z++)Z[z-1]=arguments[z];$[R].fn.apply($[R].context,Z)}}}return!0};ET.prototype.on=function(A,P,Q){return VV(this,A,P,Q,!1)};ET.prototype.once=function(A,P,Q){return VV(this,A,P,Q,!0)};ET.prototype.removeListener=function(A,P,Q,C){var W=gT?gT+A:A;if(!this._events[W])return this;if(!P)return $4(this,W),this;var G=this._events[W];if(G.fn){if(G.fn===P&&(!C||G.once)&&(!Q||G.context===Q))$4(this,W)}else{for(var J=0,$=[],X=G.length;J<X;J++)if(G[J].fn!==P||C&&!G[J].once||Q&&G[J].context!==Q)$.push(G[J]);if($.length)this._events[W]=$.length===1?$[0]:$;else $4(this,W)}return this};ET.prototype.removeAllListeners=function(A){var P;if(A){if(P=gT?gT+A:A,this._events[P])$4(this,P)}else this._events=new F2,this._eventsCount=0;return this};ET.prototype.off=ET.prototype.removeListener;ET.prototype.addListener=ET.prototype.on;ET.prefixed=gT;ET.EventEmitter=ET;if(typeof tC<"u")tC.exports=ET});var Vq=T0(($q)=>{Object.defineProperty($q,"__esModule",{value:!0});var M4;function _I(T){{let A=Buffer.from(T);A.reverse();let P=A.toString("hex");if(P.length===0)return BigInt(0);return BigInt(`0x${P}`)}return M4.toBigInt(T,!1)}$q.toBigIntLE=_I;function hI(T){{let A=T.toString("hex");if(A.length===0)return BigInt(0);return BigInt(`0x${A}`)}return M4.toBigInt(T,!0)}$q.toBigIntBE=hI;function mI(T,A){{let P=T.toString(16),Q=Buffer.from(P.padStart(A*2,"0").slice(0,A*2),"hex");return Q.reverse(),Q}return M4.fromBigInt(T,Buffer.allocUnsafe(A),!1)}$q.toBufferLE=mI;function gI(T,A){{let P=T.toString(16);return Buffer.from(P.padStart(A*2,"0").slice(0,A*2),"hex")}return M4.fromBigInt(T,Buffer.allocUnsafe(A),!0)}$q.toBufferBE=gI});/*!
|
|
2
|
+
* The buffer module from node.js, for the browser.
|
|
3
|
+
*
|
|
4
|
+
* @author Feross Aboukhadijeh <https://feross.org>
|
|
5
|
+
* @license MIT
|
|
6
|
+
*/var TP=QG(),J8=CG(),WG=typeof Symbol==="function"&&typeof Symbol.for==="function"?Symbol.for("nodejs.util.inspect.custom"):null;var $P=h;var FG=50;var AP=2147483647;h.TYPED_ARRAY_SUPPORT=tq();if(!h.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error==="function")console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function tq(){try{let T=new Uint8Array(1),A={foo:function(){return 42}};return Object.setPrototypeOf(A,Uint8Array.prototype),Object.setPrototypeOf(T,A),T.foo()===42}catch(T){return!1}}Object.defineProperty(h.prototype,"parent",{enumerable:!0,get:function(){if(!h.isBuffer(this))return;return this.buffer}});Object.defineProperty(h.prototype,"offset",{enumerable:!0,get:function(){if(!h.isBuffer(this))return;return this.byteOffset}});function y0(T){if(T>AP)throw RangeError('The value "'+T+'" is invalid for option "size"');let A=new Uint8Array(T);return Object.setPrototypeOf(A,h.prototype),A}function h(T,A,P){if(typeof T==="number"){if(typeof A==="string")throw TypeError('The "string" argument must be of type string. Received type number');return WP(T)}return $G(T,A,P)}h.poolSize=8192;function $G(T,A,P){if(typeof T==="string")return TY(T,A);if(ArrayBuffer.isView(T))return AY(T);if(T==null)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof T);if(k0(T,ArrayBuffer)||T&&k0(T.buffer,ArrayBuffer))return QP(T,A,P);if(typeof SharedArrayBuffer<"u"&&(k0(T,SharedArrayBuffer)||T&&k0(T.buffer,SharedArrayBuffer)))return QP(T,A,P);if(typeof T==="number")throw TypeError('The "value" argument must not be of type number. Received type number');let Q=T.valueOf&&T.valueOf();if(Q!=null&&Q!==T)return h.from(Q,A,P);let C=PY(T);if(C)return C;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof T[Symbol.toPrimitive]==="function")return h.from(T[Symbol.toPrimitive]("string"),A,P);throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof T)}h.from=function(T,A,P){return $G(T,A,P)};Object.setPrototypeOf(h.prototype,Uint8Array.prototype);Object.setPrototypeOf(h,Uint8Array);function VG(T){if(typeof T!=="number")throw TypeError('"size" argument must be of type number');else if(T<0)throw RangeError('The value "'+T+'" is invalid for option "size"')}function eq(T,A,P){if(VG(T),T<=0)return y0(T);if(A!==void 0)return typeof P==="string"?y0(T).fill(A,P):y0(T).fill(A);return y0(T)}h.alloc=function(T,A,P){return eq(T,A,P)};function WP(T){return VG(T),y0(T<0?0:GP(T)|0)}h.allocUnsafe=function(T){return WP(T)};h.allocUnsafeSlow=function(T){return WP(T)};function TY(T,A){if(typeof A!=="string"||A==="")A="utf8";if(!h.isEncoding(A))throw TypeError("Unknown encoding: "+A);let P=qG(T,A)|0,Q=y0(P),C=Q.write(T,A);if(C!==P)Q=Q.slice(0,C);return Q}function PP(T){let A=T.length<0?0:GP(T.length)|0,P=y0(A);for(let Q=0;Q<A;Q+=1)P[Q]=T[Q]&255;return P}function AY(T){if(k0(T,Uint8Array)){let A=new Uint8Array(T);return QP(A.buffer,A.byteOffset,A.byteLength)}return PP(T)}function QP(T,A,P){if(A<0||T.byteLength<A)throw RangeError('"offset" is outside of buffer bounds');if(T.byteLength<A+(P||0))throw RangeError('"length" is outside of buffer bounds');let Q;if(A===void 0&&P===void 0)Q=new Uint8Array(T);else if(P===void 0)Q=new Uint8Array(T,A);else Q=new Uint8Array(T,A,P);return Object.setPrototypeOf(Q,h.prototype),Q}function PY(T){if(h.isBuffer(T)){let A=GP(T.length)|0,P=y0(A);if(P.length===0)return P;return T.copy(P,0,0,A),P}if(T.length!==void 0){if(typeof T.length!=="number"||JP(T.length))return y0(0);return PP(T)}if(T.type==="Buffer"&&Array.isArray(T.data))return PP(T.data)}function GP(T){if(T>=AP)throw RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+AP.toString(16)+" bytes");return T|0}h.isBuffer=function(A){return A!=null&&A._isBuffer===!0&&A!==h.prototype};h.compare=function(A,P){if(k0(A,Uint8Array))A=h.from(A,A.offset,A.byteLength);if(k0(P,Uint8Array))P=h.from(P,P.offset,P.byteLength);if(!h.isBuffer(A)||!h.isBuffer(P))throw TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(A===P)return 0;let Q=A.length,C=P.length;for(let W=0,G=Math.min(Q,C);W<G;++W)if(A[W]!==P[W]){Q=A[W],C=P[W];break}if(Q<C)return-1;if(C<Q)return 1;return 0};h.isEncoding=function(A){switch(String(A).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};h.concat=function(A,P){if(!Array.isArray(A))throw TypeError('"list" argument must be an Array of Buffers');if(A.length===0)return h.alloc(0);let Q;if(P===void 0){P=0;for(Q=0;Q<A.length;++Q)P+=A[Q].length}let C=h.allocUnsafe(P),W=0;for(Q=0;Q<A.length;++Q){let G=A[Q];if(k0(G,Uint8Array))if(W+G.length>C.length){if(!h.isBuffer(G))G=h.from(G);G.copy(C,W)}else Uint8Array.prototype.set.call(C,G,W);else if(!h.isBuffer(G))throw TypeError('"list" argument must be an Array of Buffers');else G.copy(C,W);W+=G.length}return C};function qG(T,A){if(h.isBuffer(T))return T.length;if(ArrayBuffer.isView(T)||k0(T,ArrayBuffer))return T.byteLength;if(typeof T!=="string")throw TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof T);let P=T.length,Q=arguments.length>2&&arguments[2]===!0;if(!Q&&P===0)return 0;let C=!1;for(;;)switch(A){case"ascii":case"latin1":case"binary":return P;case"utf8":case"utf-8":return CP(T).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P*2;case"hex":return P>>>1;case"base64":return DG(T).length;default:if(C)return Q?-1:CP(T).length;A=(""+A).toLowerCase(),C=!0}}h.byteLength=qG;function QY(T,A,P){let Q=!1;if(A===void 0||A<0)A=0;if(A>this.length)return"";if(P===void 0||P>this.length)P=this.length;if(P<=0)return"";if(P>>>=0,A>>>=0,P<=A)return"";if(!T)T="utf8";while(!0)switch(T){case"hex":return ZY(this,A,P);case"utf8":case"utf-8":return ZG(this,A,P);case"ascii":return qY(this,A,P);case"latin1":case"binary":return YY(this,A,P);case"base64":return $Y(this,A,P);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return XY(this,A,P);default:if(Q)throw TypeError("Unknown encoding: "+T);T=(T+"").toLowerCase(),Q=!0}}h.prototype._isBuffer=!0;function _A(T,A,P){let Q=T[A];T[A]=T[P],T[P]=Q}h.prototype.swap16=function(){let A=this.length;if(A%2!==0)throw RangeError("Buffer size must be a multiple of 16-bits");for(let P=0;P<A;P+=2)_A(this,P,P+1);return this};h.prototype.swap32=function(){let A=this.length;if(A%4!==0)throw RangeError("Buffer size must be a multiple of 32-bits");for(let P=0;P<A;P+=4)_A(this,P,P+3),_A(this,P+1,P+2);return this};h.prototype.swap64=function(){let A=this.length;if(A%8!==0)throw RangeError("Buffer size must be a multiple of 64-bits");for(let P=0;P<A;P+=8)_A(this,P,P+7),_A(this,P+1,P+6),_A(this,P+2,P+5),_A(this,P+3,P+4);return this};h.prototype.toString=function(){let A=this.length;if(A===0)return"";if(arguments.length===0)return ZG(this,0,A);return QY.apply(this,arguments)};h.prototype.toLocaleString=h.prototype.toString;h.prototype.equals=function(A){if(!h.isBuffer(A))throw TypeError("Argument must be a Buffer");if(this===A)return!0;return h.compare(this,A)===0};h.prototype.inspect=function(){let A="",P=FG;if(A=this.toString("hex",0,P).replace(/(.{2})/g,"$1 ").trim(),this.length>P)A+=" ... ";return"<Buffer "+A+">"};if(WG)h.prototype[WG]=h.prototype.inspect;h.prototype.compare=function(A,P,Q,C,W){if(k0(A,Uint8Array))A=h.from(A,A.offset,A.byteLength);if(!h.isBuffer(A))throw TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof A);if(P===void 0)P=0;if(Q===void 0)Q=A?A.length:0;if(C===void 0)C=0;if(W===void 0)W=this.length;if(P<0||Q>A.length||C<0||W>this.length)throw RangeError("out of range index");if(C>=W&&P>=Q)return 0;if(C>=W)return-1;if(P>=Q)return 1;if(P>>>=0,Q>>>=0,C>>>=0,W>>>=0,this===A)return 0;let G=W-C,J=Q-P,$=Math.min(G,J),X=this.slice(C,W),Z=A.slice(P,Q);for(let R=0;R<$;++R)if(X[R]!==Z[R]){G=X[R],J=Z[R];break}if(G<J)return-1;if(J<G)return 1;return 0};function YG(T,A,P,Q,C){if(T.length===0)return-1;if(typeof P==="string")Q=P,P=0;else if(P>2147483647)P=2147483647;else if(P<-2147483648)P=-2147483648;if(P=+P,JP(P))P=C?0:T.length-1;if(P<0)P=T.length+P;if(P>=T.length)if(C)return-1;else P=T.length-1;else if(P<0)if(C)P=0;else return-1;if(typeof A==="string")A=h.from(A,Q);if(h.isBuffer(A)){if(A.length===0)return-1;return GG(T,A,P,Q,C)}else if(typeof A==="number"){if(A=A&255,typeof Uint8Array.prototype.indexOf==="function")if(C)return Uint8Array.prototype.indexOf.call(T,A,P);else return Uint8Array.prototype.lastIndexOf.call(T,A,P);return GG(T,[A],P,Q,C)}throw TypeError("val must be string, number or Buffer")}function GG(T,A,P,Q,C){let W=1,G=T.length,J=A.length;if(Q!==void 0){if(Q=String(Q).toLowerCase(),Q==="ucs2"||Q==="ucs-2"||Q==="utf16le"||Q==="utf-16le"){if(T.length<2||A.length<2)return-1;W=2,G/=2,J/=2,P/=2}}function $(Z,R){if(W===1)return Z[R];else return Z.readUInt16BE(R*W)}let X;if(C){let Z=-1;for(X=P;X<G;X++)if($(T,X)===$(A,Z===-1?0:X-Z)){if(Z===-1)Z=X;if(X-Z+1===J)return Z*W}else{if(Z!==-1)X-=X-Z;Z=-1}}else{if(P+J>G)P=G-J;for(X=P;X>=0;X--){let Z=!0;for(let R=0;R<J;R++)if($(T,X+R)!==$(A,R)){Z=!1;break}if(Z)return X}}return-1}h.prototype.includes=function(A,P,Q){return this.indexOf(A,P,Q)!==-1};h.prototype.indexOf=function(A,P,Q){return YG(this,A,P,Q,!0)};h.prototype.lastIndexOf=function(A,P,Q){return YG(this,A,P,Q,!1)};function CY(T,A,P,Q){P=Number(P)||0;let C=T.length-P;if(!Q)Q=C;else if(Q=Number(Q),Q>C)Q=C;let W=A.length;if(Q>W/2)Q=W/2;let G;for(G=0;G<Q;++G){let J=parseInt(A.substr(G*2,2),16);if(JP(J))return G;T[P+G]=J}return G}function WY(T,A,P,Q){return g2(CP(A,T.length-P),T,P,Q)}function GY(T,A,P,Q){return g2(kY(A),T,P,Q)}function UY(T,A,P,Q){return g2(DG(A),T,P,Q)}function JY(T,A,P,Q){return g2(jY(A,T.length-P),T,P,Q)}h.prototype.write=function(A,P,Q,C){if(P===void 0)C="utf8",Q=this.length,P=0;else if(Q===void 0&&typeof P==="string")C=P,Q=this.length,P=0;else if(isFinite(P))if(P=P>>>0,isFinite(Q)){if(Q=Q>>>0,C===void 0)C="utf8"}else C=Q,Q=void 0;else throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let W=this.length-P;if(Q===void 0||Q>W)Q=W;if(A.length>0&&(Q<0||P<0)||P>this.length)throw RangeError("Attempt to write outside buffer bounds");if(!C)C="utf8";let G=!1;for(;;)switch(C){case"hex":return CY(this,A,P,Q);case"utf8":case"utf-8":return WY(this,A,P,Q);case"ascii":case"latin1":case"binary":return GY(this,A,P,Q);case"base64":return UY(this,A,P,Q);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return JY(this,A,P,Q);default:if(G)throw TypeError("Unknown encoding: "+C);C=(""+C).toLowerCase(),G=!0}};h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function $Y(T,A,P){if(A===0&&P===T.length)return TP.fromByteArray(T);else return TP.fromByteArray(T.slice(A,P))}function ZG(T,A,P){P=Math.min(T.length,P);let Q=[],C=A;while(C<P){let W=T[C],G=null,J=W>239?4:W>223?3:W>191?2:1;if(C+J<=P){let $,X,Z,R;switch(J){case 1:if(W<128)G=W;break;case 2:if($=T[C+1],($&192)===128){if(R=(W&31)<<6|$&63,R>127)G=R}break;case 3:if($=T[C+1],X=T[C+2],($&192)===128&&(X&192)===128){if(R=(W&15)<<12|($&63)<<6|X&63,R>2047&&(R<55296||R>57343))G=R}break;case 4:if($=T[C+1],X=T[C+2],Z=T[C+3],($&192)===128&&(X&192)===128&&(Z&192)===128){if(R=(W&15)<<18|($&63)<<12|(X&63)<<6|Z&63,R>65535&&R<1114112)G=R}}}if(G===null)G=65533,J=1;else if(G>65535)G-=65536,Q.push(G>>>10&1023|55296),G=56320|G&1023;Q.push(G),C+=J}return VY(Q)}var UG=4096;function VY(T){let A=T.length;if(A<=UG)return String.fromCharCode.apply(String,T);let P="",Q=0;while(Q<A)P+=String.fromCharCode.apply(String,T.slice(Q,Q+=UG));return P}function qY(T,A,P){let Q="";P=Math.min(T.length,P);for(let C=A;C<P;++C)Q+=String.fromCharCode(T[C]&127);return Q}function YY(T,A,P){let Q="";P=Math.min(T.length,P);for(let C=A;C<P;++C)Q+=String.fromCharCode(T[C]);return Q}function ZY(T,A,P){let Q=T.length;if(!A||A<0)A=0;if(!P||P<0||P>Q)P=Q;let C="";for(let W=A;W<P;++W)C+=DY[T[W]];return C}function XY(T,A,P){let Q=T.slice(A,P),C="";for(let W=0;W<Q.length-1;W+=2)C+=String.fromCharCode(Q[W]+Q[W+1]*256);return C}h.prototype.slice=function(A,P){let Q=this.length;if(A=~~A,P=P===void 0?Q:~~P,A<0){if(A+=Q,A<0)A=0}else if(A>Q)A=Q;if(P<0){if(P+=Q,P<0)P=0}else if(P>Q)P=Q;if(P<A)P=A;let C=this.subarray(A,P);return Object.setPrototypeOf(C,h.prototype),C};function VT(T,A,P){if(T%1!==0||T<0)throw RangeError("offset is not uint");if(T+A>P)throw RangeError("Trying to access beyond buffer length")}h.prototype.readUintLE=h.prototype.readUIntLE=function(A,P,Q){if(A=A>>>0,P=P>>>0,!Q)VT(A,P,this.length);let C=this[A],W=1,G=0;while(++G<P&&(W*=256))C+=this[A+G]*W;return C};h.prototype.readUintBE=h.prototype.readUIntBE=function(A,P,Q){if(A=A>>>0,P=P>>>0,!Q)VT(A,P,this.length);let C=this[A+--P],W=1;while(P>0&&(W*=256))C+=this[A+--P]*W;return C};h.prototype.readUint8=h.prototype.readUInt8=function(A,P){if(A=A>>>0,!P)VT(A,1,this.length);return this[A]};h.prototype.readUint16LE=h.prototype.readUInt16LE=function(A,P){if(A=A>>>0,!P)VT(A,2,this.length);return this[A]|this[A+1]<<8};h.prototype.readUint16BE=h.prototype.readUInt16BE=function(A,P){if(A=A>>>0,!P)VT(A,2,this.length);return this[A]<<8|this[A+1]};h.prototype.readUint32LE=h.prototype.readUInt32LE=function(A,P){if(A=A>>>0,!P)VT(A,4,this.length);return(this[A]|this[A+1]<<8|this[A+2]<<16)+this[A+3]*16777216};h.prototype.readUint32BE=h.prototype.readUInt32BE=function(A,P){if(A=A>>>0,!P)VT(A,4,this.length);return this[A]*16777216+(this[A+1]<<16|this[A+2]<<8|this[A+3])};h.prototype.readBigUInt64LE=VA(function(A){A=A>>>0,$8(A,"offset");let P=this[A],Q=this[A+7];if(P===void 0||Q===void 0)p8(A,this.length-8);let C=P+this[++A]*256+this[++A]*65536+this[++A]*16777216,W=this[++A]+this[++A]*256+this[++A]*65536+Q*16777216;return BigInt(C)+(BigInt(W)<<BigInt(32))});h.prototype.readBigUInt64BE=VA(function(A){A=A>>>0,$8(A,"offset");let P=this[A],Q=this[A+7];if(P===void 0||Q===void 0)p8(A,this.length-8);let C=P*16777216+this[++A]*65536+this[++A]*256+this[++A],W=this[++A]*16777216+this[++A]*65536+this[++A]*256+Q;return(BigInt(C)<<BigInt(32))+BigInt(W)});h.prototype.readIntLE=function(A,P,Q){if(A=A>>>0,P=P>>>0,!Q)VT(A,P,this.length);let C=this[A],W=1,G=0;while(++G<P&&(W*=256))C+=this[A+G]*W;if(W*=128,C>=W)C-=Math.pow(2,8*P);return C};h.prototype.readIntBE=function(A,P,Q){if(A=A>>>0,P=P>>>0,!Q)VT(A,P,this.length);let C=P,W=1,G=this[A+--C];while(C>0&&(W*=256))G+=this[A+--C]*W;if(W*=128,G>=W)G-=Math.pow(2,8*P);return G};h.prototype.readInt8=function(A,P){if(A=A>>>0,!P)VT(A,1,this.length);if(!(this[A]&128))return this[A];return(255-this[A]+1)*-1};h.prototype.readInt16LE=function(A,P){if(A=A>>>0,!P)VT(A,2,this.length);let Q=this[A]|this[A+1]<<8;return Q&32768?Q|4294901760:Q};h.prototype.readInt16BE=function(A,P){if(A=A>>>0,!P)VT(A,2,this.length);let Q=this[A+1]|this[A]<<8;return Q&32768?Q|4294901760:Q};h.prototype.readInt32LE=function(A,P){if(A=A>>>0,!P)VT(A,4,this.length);return this[A]|this[A+1]<<8|this[A+2]<<16|this[A+3]<<24};h.prototype.readInt32BE=function(A,P){if(A=A>>>0,!P)VT(A,4,this.length);return this[A]<<24|this[A+1]<<16|this[A+2]<<8|this[A+3]};h.prototype.readBigInt64LE=VA(function(A){A=A>>>0,$8(A,"offset");let P=this[A],Q=this[A+7];if(P===void 0||Q===void 0)p8(A,this.length-8);let C=this[A+4]+this[A+5]*256+this[A+6]*65536+(Q<<24);return(BigInt(C)<<BigInt(32))+BigInt(P+this[++A]*256+this[++A]*65536+this[++A]*16777216)});h.prototype.readBigInt64BE=VA(function(A){A=A>>>0,$8(A,"offset");let P=this[A],Q=this[A+7];if(P===void 0||Q===void 0)p8(A,this.length-8);let C=(P<<24)+this[++A]*65536+this[++A]*256+this[++A];return(BigInt(C)<<BigInt(32))+BigInt(this[++A]*16777216+this[++A]*65536+this[++A]*256+Q)});h.prototype.readFloatLE=function(A,P){if(A=A>>>0,!P)VT(A,4,this.length);return J8.read(this,A,!0,23,4)};h.prototype.readFloatBE=function(A,P){if(A=A>>>0,!P)VT(A,4,this.length);return J8.read(this,A,!1,23,4)};h.prototype.readDoubleLE=function(A,P){if(A=A>>>0,!P)VT(A,8,this.length);return J8.read(this,A,!0,52,8)};h.prototype.readDoubleBE=function(A,P){if(A=A>>>0,!P)VT(A,8,this.length);return J8.read(this,A,!1,52,8)};function bT(T,A,P,Q,C,W){if(!h.isBuffer(T))throw TypeError('"buffer" argument must be a Buffer instance');if(A>C||A<W)throw RangeError('"value" argument is out of bounds');if(P+Q>T.length)throw RangeError("Index out of range")}h.prototype.writeUintLE=h.prototype.writeUIntLE=function(A,P,Q,C){if(A=+A,P=P>>>0,Q=Q>>>0,!C){let J=Math.pow(2,8*Q)-1;bT(this,A,P,Q,J,0)}let W=1,G=0;this[P]=A&255;while(++G<Q&&(W*=256))this[P+G]=A/W&255;return P+Q};h.prototype.writeUintBE=h.prototype.writeUIntBE=function(A,P,Q,C){if(A=+A,P=P>>>0,Q=Q>>>0,!C){let J=Math.pow(2,8*Q)-1;bT(this,A,P,Q,J,0)}let W=Q-1,G=1;this[P+W]=A&255;while(--W>=0&&(G*=256))this[P+W]=A/G&255;return P+Q};h.prototype.writeUint8=h.prototype.writeUInt8=function(A,P,Q){if(A=+A,P=P>>>0,!Q)bT(this,A,P,1,255,0);return this[P]=A&255,P+1};h.prototype.writeUint16LE=h.prototype.writeUInt16LE=function(A,P,Q){if(A=+A,P=P>>>0,!Q)bT(this,A,P,2,65535,0);return this[P]=A&255,this[P+1]=A>>>8,P+2};h.prototype.writeUint16BE=h.prototype.writeUInt16BE=function(A,P,Q){if(A=+A,P=P>>>0,!Q)bT(this,A,P,2,65535,0);return this[P]=A>>>8,this[P+1]=A&255,P+2};h.prototype.writeUint32LE=h.prototype.writeUInt32LE=function(A,P,Q){if(A=+A,P=P>>>0,!Q)bT(this,A,P,4,4294967295,0);return this[P+3]=A>>>24,this[P+2]=A>>>16,this[P+1]=A>>>8,this[P]=A&255,P+4};h.prototype.writeUint32BE=h.prototype.writeUInt32BE=function(A,P,Q){if(A=+A,P=P>>>0,!Q)bT(this,A,P,4,4294967295,0);return this[P]=A>>>24,this[P+1]=A>>>16,this[P+2]=A>>>8,this[P+3]=A&255,P+4};function XG(T,A,P,Q,C){jG(A,Q,C,T,P,7);let W=Number(A&BigInt(4294967295));T[P++]=W,W=W>>8,T[P++]=W,W=W>>8,T[P++]=W,W=W>>8,T[P++]=W;let G=Number(A>>BigInt(32)&BigInt(4294967295));return T[P++]=G,G=G>>8,T[P++]=G,G=G>>8,T[P++]=G,G=G>>8,T[P++]=G,P}function HG(T,A,P,Q,C){jG(A,Q,C,T,P,7);let W=Number(A&BigInt(4294967295));T[P+7]=W,W=W>>8,T[P+6]=W,W=W>>8,T[P+5]=W,W=W>>8,T[P+4]=W;let G=Number(A>>BigInt(32)&BigInt(4294967295));return T[P+3]=G,G=G>>8,T[P+2]=G,G=G>>8,T[P+1]=G,G=G>>8,T[P]=G,P+8}h.prototype.writeBigUInt64LE=VA(function(A,P=0){return XG(this,A,P,BigInt(0),BigInt("0xffffffffffffffff"))});h.prototype.writeBigUInt64BE=VA(function(A,P=0){return HG(this,A,P,BigInt(0),BigInt("0xffffffffffffffff"))});h.prototype.writeIntLE=function(A,P,Q,C){if(A=+A,P=P>>>0,!C){let $=Math.pow(2,8*Q-1);bT(this,A,P,Q,$-1,-$)}let W=0,G=1,J=0;this[P]=A&255;while(++W<Q&&(G*=256)){if(A<0&&J===0&&this[P+W-1]!==0)J=1;this[P+W]=(A/G>>0)-J&255}return P+Q};h.prototype.writeIntBE=function(A,P,Q,C){if(A=+A,P=P>>>0,!C){let $=Math.pow(2,8*Q-1);bT(this,A,P,Q,$-1,-$)}let W=Q-1,G=1,J=0;this[P+W]=A&255;while(--W>=0&&(G*=256)){if(A<0&&J===0&&this[P+W+1]!==0)J=1;this[P+W]=(A/G>>0)-J&255}return P+Q};h.prototype.writeInt8=function(A,P,Q){if(A=+A,P=P>>>0,!Q)bT(this,A,P,1,127,-128);if(A<0)A=255+A+1;return this[P]=A&255,P+1};h.prototype.writeInt16LE=function(A,P,Q){if(A=+A,P=P>>>0,!Q)bT(this,A,P,2,32767,-32768);return this[P]=A&255,this[P+1]=A>>>8,P+2};h.prototype.writeInt16BE=function(A,P,Q){if(A=+A,P=P>>>0,!Q)bT(this,A,P,2,32767,-32768);return this[P]=A>>>8,this[P+1]=A&255,P+2};h.prototype.writeInt32LE=function(A,P,Q){if(A=+A,P=P>>>0,!Q)bT(this,A,P,4,2147483647,-2147483648);return this[P]=A&255,this[P+1]=A>>>8,this[P+2]=A>>>16,this[P+3]=A>>>24,P+4};h.prototype.writeInt32BE=function(A,P,Q){if(A=+A,P=P>>>0,!Q)bT(this,A,P,4,2147483647,-2147483648);if(A<0)A=4294967295+A+1;return this[P]=A>>>24,this[P+1]=A>>>16,this[P+2]=A>>>8,this[P+3]=A&255,P+4};h.prototype.writeBigInt64LE=VA(function(A,P=0){return XG(this,A,P,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});h.prototype.writeBigInt64BE=VA(function(A,P=0){return HG(this,A,P,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function KG(T,A,P,Q,C,W){if(P+Q>T.length)throw RangeError("Index out of range");if(P<0)throw RangeError("Index out of range")}function RG(T,A,P,Q,C){if(A=+A,P=P>>>0,!C)KG(T,A,P,4,340282346638528860000000000000000000000,-340282346638528860000000000000000000000);return J8.write(T,A,P,Q,23,4),P+4}h.prototype.writeFloatLE=function(A,P,Q){return RG(this,A,P,!0,Q)};h.prototype.writeFloatBE=function(A,P,Q){return RG(this,A,P,!1,Q)};function kG(T,A,P,Q,C){if(A=+A,P=P>>>0,!C)KG(T,A,P,8,179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,-179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000);return J8.write(T,A,P,Q,52,8),P+8}h.prototype.writeDoubleLE=function(A,P,Q){return kG(this,A,P,!0,Q)};h.prototype.writeDoubleBE=function(A,P,Q){return kG(this,A,P,!1,Q)};h.prototype.copy=function(A,P,Q,C){if(!h.isBuffer(A))throw TypeError("argument should be a Buffer");if(!Q)Q=0;if(!C&&C!==0)C=this.length;if(P>=A.length)P=A.length;if(!P)P=0;if(C>0&&C<Q)C=Q;if(C===Q)return 0;if(A.length===0||this.length===0)return 0;if(P<0)throw RangeError("targetStart out of bounds");if(Q<0||Q>=this.length)throw RangeError("Index out of range");if(C<0)throw RangeError("sourceEnd out of bounds");if(C>this.length)C=this.length;if(A.length-P<C-Q)C=A.length-P+Q;let W=C-Q;if(this===A&&typeof Uint8Array.prototype.copyWithin==="function")this.copyWithin(P,Q,C);else Uint8Array.prototype.set.call(A,this.subarray(Q,C),P);return W};h.prototype.fill=function(A,P,Q,C){if(typeof A==="string"){if(typeof P==="string")C=P,P=0,Q=this.length;else if(typeof Q==="string")C=Q,Q=this.length;if(C!==void 0&&typeof C!=="string")throw TypeError("encoding must be a string");if(typeof C==="string"&&!h.isEncoding(C))throw TypeError("Unknown encoding: "+C);if(A.length===1){let G=A.charCodeAt(0);if(C==="utf8"&&G<128||C==="latin1")A=G}}else if(typeof A==="number")A=A&255;else if(typeof A==="boolean")A=Number(A);if(P<0||this.length<P||this.length<Q)throw RangeError("Out of range index");if(Q<=P)return this;if(P=P>>>0,Q=Q===void 0?this.length:Q>>>0,!A)A=0;let W;if(typeof A==="number")for(W=P;W<Q;++W)this[W]=A;else{let G=h.isBuffer(A)?A:h.from(A,C),J=G.length;if(J===0)throw TypeError('The value "'+A+'" is invalid for argument "value"');for(W=0;W<Q-P;++W)this[W+P]=G[W%J]}return this};var U8={};function UP(T,A,P){U8[T]=class extends P{constructor(){super();Object.defineProperty(this,"message",{value:A.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${T}]`,this.stack,delete this.name}get code(){return T}set code(C){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:C,writable:!0})}toString(){return`${this.name} [${T}]: ${this.message}`}}}UP("ERR_BUFFER_OUT_OF_BOUNDS",function(T){if(T)return`${T} is outside of buffer bounds`;return"Attempt to access memory outside buffer bounds"},RangeError);UP("ERR_INVALID_ARG_TYPE",function(T,A){return`The "${T}" argument must be of type number. Received type ${typeof A}`},TypeError);UP("ERR_OUT_OF_RANGE",function(T,A,P){let Q=`The value of "${T}" is out of range.`,C=P;if(Number.isInteger(P)&&Math.abs(P)>4294967296)C=JG(String(P));else if(typeof P==="bigint"){if(C=String(P),P>BigInt(2)**BigInt(32)||P<-(BigInt(2)**BigInt(32)))C=JG(C);C+="n"}return Q+=` It must be ${A}. Received ${C}`,Q},RangeError);function JG(T){let A="",P=T.length,Q=T[0]==="-"?1:0;for(;P>=Q+4;P-=3)A=`_${T.slice(P-3,P)}${A}`;return`${T.slice(0,P)}${A}`}function HY(T,A,P){if($8(A,"offset"),T[A]===void 0||T[A+P]===void 0)p8(A,T.length-(P+1))}function jG(T,A,P,Q,C,W){if(T>P||T<A){let G=typeof A==="bigint"?"n":"",J;if(W>3)if(A===0||A===BigInt(0))J=`>= 0${G} and < 2${G} ** ${(W+1)*8}${G}`;else J=`>= -(2${G} ** ${(W+1)*8-1}${G}) and < 2 ** ${(W+1)*8-1}${G}`;else J=`>= ${A}${G} and <= ${P}${G}`;throw new U8.ERR_OUT_OF_RANGE("value",J,T)}HY(Q,C,W)}function $8(T,A){if(typeof T!=="number")throw new U8.ERR_INVALID_ARG_TYPE(A,"number",T)}function p8(T,A,P){if(Math.floor(T)!==T)throw $8(T,P),new U8.ERR_OUT_OF_RANGE(P||"offset","an integer",T);if(A<0)throw new U8.ERR_BUFFER_OUT_OF_BOUNDS;throw new U8.ERR_OUT_OF_RANGE(P||"offset",`>= ${P?1:0} and <= ${A}`,T)}var KY=/[^+/0-9A-Za-z-_]/g;function RY(T){if(T=T.split("=")[0],T=T.trim().replace(KY,""),T.length<2)return"";while(T.length%4!==0)T=T+"=";return T}function CP(T,A){A=A||1/0;let P,Q=T.length,C=null,W=[];for(let G=0;G<Q;++G){if(P=T.charCodeAt(G),P>55295&&P<57344){if(!C){if(P>56319){if((A-=3)>-1)W.push(239,191,189);continue}else if(G+1===Q){if((A-=3)>-1)W.push(239,191,189);continue}C=P;continue}if(P<56320){if((A-=3)>-1)W.push(239,191,189);C=P;continue}P=(C-55296<<10|P-56320)+65536}else if(C){if((A-=3)>-1)W.push(239,191,189)}if(C=null,P<128){if((A-=1)<0)break;W.push(P)}else if(P<2048){if((A-=2)<0)break;W.push(P>>6|192,P&63|128)}else if(P<65536){if((A-=3)<0)break;W.push(P>>12|224,P>>6&63|128,P&63|128)}else if(P<1114112){if((A-=4)<0)break;W.push(P>>18|240,P>>12&63|128,P>>6&63|128,P&63|128)}else throw Error("Invalid code point")}return W}function kY(T){let A=[];for(let P=0;P<T.length;++P)A.push(T.charCodeAt(P)&255);return A}function jY(T,A){let P,Q,C,W=[];for(let G=0;G<T.length;++G){if((A-=2)<0)break;P=T.charCodeAt(G),Q=P>>8,C=P%256,W.push(C),W.push(Q)}return W}function DG(T){return TP.toByteArray(RY(T))}function g2(T,A,P,Q){let C;for(C=0;C<Q;++C){if(C+P>=A.length||C>=T.length)break;A[C+P]=T[C]}return C}function k0(T,A){return T instanceof A||T!=null&&T.constructor!=null&&T.constructor.name!=null&&T.constructor.name===A.name}function JP(T){return T!==T}var DY=function(){let A=Array(256);for(let P=0;P<16;++P){let Q=P*16;for(let C=0;C<16;++C)A[Q+C]="0123456789abcdef"[P]+"0123456789abcdef"[C]}return A}();function VA(T){return typeof BigInt>"u"?FY:T}function FY(){throw Error("BigInt not supported")}if(typeof globalThis.Buffer>"u")globalThis.Buffer=$P;var VP=1,MG=2,zG=3,IG=4,SG=5,NG=6,wG=7,LG=8,EG=9,MY=10,zY=-32700,IY=-32603,SY=-32602,NY=-32601,wY=-32600,LY=-32019,EY=-32018,BY=-32017,OY=-32016,xY=-32015,_Y=-32014,hY=-32013,mY=-32012,gY=-32011,vY=-32010,yY=-32009,bY=-32008,lY=-32007,pY=-32006,uY=-32005,dY=-32004,rY=-32003,cY=-32002,oY=-32001,v2=2800000,y2=2800001,nY=2800002,qP=2800003,BG=2800004,OG=2800005,YP=2800006,ZP=2800007,b2=2800008,XP=2800009,xG=2800010,_G=2800011,HP=3230000,hG=32300001,KP=3230002,mG=3230003,gG=3230004,RP=3610000,kP=3610001,jP=3610002,DP=3610003,FP=3610004,MP=3610005,vG=3610006,fY=3610007,yG=3611000,iY=3704000,aY=3704001,sY=3704002,tY=3704003,eY=3704004,TZ=4128000,AZ=4128001,PZ=4128002,bG=4615000,QZ=4615001,CZ=4615002,WZ=4615003,GZ=4615004,UZ=4615005,JZ=4615006,$Z=4615007,VZ=4615008,qZ=4615009,YZ=4615010,ZZ=4615011,XZ=4615012,HZ=4615013,KZ=4615014,RZ=4615015,kZ=4615016,jZ=4615017,DZ=4615018,FZ=4615019,MZ=4615020,zZ=4615021,IZ=4615022,SZ=4615023,NZ=4615024,wZ=4615025,lG=4615026,LZ=4615027,EZ=4615028,BZ=4615029,OZ=4615030,xZ=4615031,_Z=4615032,hZ=4615033,mZ=4615034,gZ=4615035,vZ=4615036,yZ=4615037,bZ=4615038,lZ=4615039,pZ=4615040,uZ=4615041,dZ=4615042,rZ=4615043,cZ=4615044,oZ=4615045,nZ=4615046,fZ=4615047,iZ=4615048,aZ=4615049,sZ=4615050,tZ=4615051,eZ=4615052,TX=4615053,AX=4615054,zP=5508000,pG=5508001,uG=5508002,dG=5508003,rG=5508004,cG=5508005,oG=5508006,nG=5508007,fG=5508008,iG=5508009,aG=5508010,PX=5508011,IP=5663000,l2=5663001,SP=5663002,NP=5663003,wP=5663004,sG=5663005,tG=5663006,eG=5663007,TU=5663008,LP=5663009,QX=5663010,CX=5663011,EP=5663012,WX=5663013,GX=5663014,BP=5663015,OP=5663016,AU=5663017,UX=5663018,JX=5663019,PU=5663020,xP=5663021,QU=5663022,CU=7050000,$X=7050001,VX=7050002,qX=7050003,YX=7050004,ZX=7050005,XX=7050006,HX=7050007,KX=7050008,RX=7050009,kX=7050010,jX=7050011,DX=7050012,FX=7050013,MX=7050014,zX=7050015,IX=7050016,SX=7050017,NX=7050018,wX=7050019,LX=7050020,EX=7050021,BX=7050022,OX=7050023,xX=7050024,_X=7050025,hX=7050026,mX=7050027,gX=7050028,vX=7050029,WU=7050030,GU=7050031,yX=7050032,bX=7050033,lX=7050034,UU=7050035,pX=7050036,uX=7618000,dX=7618001,rX=7618002,cX=7618003,p2=8078000,u8=8078001,_P=8078002,hP=8078003,u2=8078004,d2=8078005,r2=8078006,hA=8078007,c2=8078008,o2=8078009,n2=8078010,mA=8078011,qA=8078012,mP=8078013,gP=8078014,f2=8078015,i2=8078016,d8=8078017,a2=8078018,oX=8078019,vP=8078020,yP=8078021,s2=8078022,bP=8078023,nX=8100000,fX=8100001,iX=8100002,aX=8100003,sX=8190000,tX=8190001,eX=8190002,TH=8190003,AH=8190004,PH=9900000,QH=9900001,CH=9900002,lP=9900003,WH=9900004,GH=9900005,UH=9900006;var JH={[HP]:"Account not found at address: $address",[gG]:"Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",[mG]:"Expected decoded account at address: $address",[KP]:"Failed to decode account data at address: $address",[hG]:"Accounts not found at addresses: $addresses",[XP]:"Unable to find a viable program address bump seed.",[nY]:"$putativeAddress is not a base58-encoded address.",[v2]:"Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",[qP]:"The `CryptoKey` must be an `Ed25519` public key.",[_G]:"$putativeOffCurveAddress is not a base58-encoded off-curve address.",[b2]:"Invalid seeds; point must fall off the Ed25519 curve.",[BG]:"Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",[YP]:"A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",[ZP]:"The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",[OG]:"Expected program derived address bump to be in the range [0, 255], got: $bump.",[xG]:"Program address cannot end with PDA marker.",[y2]:"Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",[IG]:"Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",[VP]:"The network has progressed past the last block for which this transaction could have been committed.",[p2]:"Codec [$codecDescription] cannot decode empty byte arrays.",[s2]:"Enum codec cannot use lexical values [$stringValues] as discriminators. Either remove all lexical values or set `useValuesAsDiscriminators` to `false`.",[vP]:"Sentinel [$hexSentinel] must not be present in encoded bytes [$hexEncodedBytes].",[d2]:"Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",[r2]:"Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",[u2]:"Encoder and decoder must either both be fixed-size or variable-size.",[c2]:"Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",[_P]:"Expected a fixed-size codec, got a variable-size one.",[mP]:"Codec [$codecDescription] expected a positive byte length, got $bytesLength.",[hP]:"Expected a variable-size codec, got a fixed-size one.",[oX]:"Codec [$codecDescription] expected zero-value [$hexZeroValue] to have the same size as the provided fixed-size item [$expectedSize bytes].",[u8]:"Codec [$codecDescription] expected $expected bytes, got $bytesLength.",[a2]:"Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",[o2]:"Invalid discriminated union variant. Expected one of [$variants], got $value.",[n2]:"Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",[f2]:"Invalid literal union variant. Expected one of [$variants], got $value.",[hA]:"Expected [$codecDescription] to have $expected items, got $actual.",[qA]:"Invalid value $value for base $base with alphabet $alphabet.",[i2]:"Literal union discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",[mA]:"Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",[gP]:"Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",[yP]:"Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",[d8]:"Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",[bP]:"This decoder expected a byte array of exactly $expectedLength bytes, but $numExcessBytes unexpected excess bytes remained after decoding. Are you sure that you have chosen the correct decoder for this data?",[yG]:"No random values implementation could be found.",[qZ]:"instruction requires an uninitialized account",[SZ]:"instruction tries to borrow reference for an account which is already borrowed",[NZ]:"instruction left account with an outstanding borrowed reference",[zZ]:"program other than the account's owner changed the size of the account data",[UZ]:"account data too small for instruction",[IZ]:"instruction expected an executable account",[nZ]:"An account does not have enough lamports to be rent-exempt",[iZ]:"Program arithmetic overflowed",[oZ]:"Failed to serialize or deserialize account data: $encodedData",[AX]:"Builtin programs must consume compute units",[_Z]:"Cross-program invocation call depth too deep",[bZ]:"Computational budget exceeded",[lG]:"custom program error: #$code",[jZ]:"instruction contains duplicate accounts",[wZ]:"instruction modifications of multiply-passed account differ",[OZ]:"executable accounts must be rent exempt",[EZ]:"instruction changed executable accounts data",[BZ]:"instruction changed the balance of an executable account",[DZ]:"instruction changed executable bit of an account",[KZ]:"instruction modified data of an account it does not own",[HZ]:"instruction spent from the balance of an account it does not own",[QZ]:"generic instruction error",[sZ]:"Provided owner is not allowed",[rZ]:"Account is immutable",[cZ]:"Incorrect authority provided",[$Z]:"incorrect program id for instruction",[JZ]:"insufficient funds for instruction",[GZ]:"invalid account data for instruction",[fZ]:"Invalid account owner",[CZ]:"invalid program argument",[LZ]:"program returned invalid error code",[WZ]:"invalid instruction data",[yZ]:"Failed to reallocate account data",[vZ]:"Provided seeds do not result in a valid address",[tZ]:"Accounts data allocations exceeded the maximum allowed per transaction",[eZ]:"Max accounts exceeded",[TX]:"Max instruction trace length exceeded",[gZ]:"Length of the seed is too long for address generation",[hZ]:"An account required by the instruction is missing",[VZ]:"missing required signature for instruction",[XZ]:"instruction illegally modified the program id of an account",[MZ]:"insufficient account keys for instruction",[lZ]:"Cross-program invocation with unauthorized signer or writable account",[pZ]:"Failed to create program execution environment",[dZ]:"Program failed to compile",[uZ]:"Program failed to complete",[kZ]:"instruction modified data of a read-only account",[RZ]:"instruction changed the balance of a read-only account",[mZ]:"Cross-program invocation reentrancy not allowed for this instruction",[FZ]:"instruction modified rent epoch of an account",[ZZ]:"sum of account balances before and after instruction do not match",[YZ]:"instruction requires an initialized account",[bG]:"",[xZ]:"Unsupported program id",[aZ]:"Unsupported sysvar",[GH]:"Invalid instruction plan kind: $kind.",[rX]:"The provided instruction plan is empty.",[cX]:"The provided transaction plan failed to execute. See the `transactionPlanResult` attribute and the `cause` error for more details.",[uX]:"The provided message has insufficient capacity to accommodate the next instruction(s) in this plan. Expected at least $numBytesRequired free byte(s), got $numFreeBytes byte(s).",[UH]:"Invalid transaction plan kind: $kind.",[dX]:"No more instructions to pack; the message packer has completed the instruction plan.",[TZ]:"The instruction does not have any accounts.",[AZ]:"The instruction does not have any data.",[PZ]:"Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",[SG]:"Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",[MG]:"The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",[CH]:"Invariant violation: Found no abortable iterable cache entry for key `$cacheKey`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[WH]:"Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",[QH]:"Invariant violation: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[PH]:"Invariant violation: WebSocket message iterator is missing state storage. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[lP]:"Invariant violation: Switch statement non-exhaustive. Received unexpected value `$unexpectedValue`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[IY]:"JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",[SY]:"JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",[wY]:"JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",[NY]:"JSON-RPC error: The method does not exist / is not available ($__serverMessage)",[zY]:"JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",[mY]:"$__serverMessage",[oY]:"$__serverMessage",[dY]:"$__serverMessage",[_Y]:"$__serverMessage",[BY]:"Epoch rewards period still active at slot $slot",[vY]:"$__serverMessage",[yY]:"$__serverMessage",[LY]:"Failed to query long-term storage; please try again",[OY]:"Minimum context slot has not been reached",[uY]:"Node is unhealthy; behind by $numSlotsBehind slots",[bY]:"No snapshot",[cY]:"Transaction simulation failed",[EY]:"Rewards cannot be found because slot $slot is not the epoch boundary. This may be due to gap in the queried node's local ledger or long-term storage",[lY]:"$__serverMessage",[gY]:"Transaction history is not available from this node",[pY]:"$__serverMessage",[hY]:"Transaction signature length mismatch",[rY]:"Transaction signature verification failure",[xY]:"$__serverMessage",[iY]:"Key pair bytes must be of length 64, got $byteLength.",[aY]:"Expected private key bytes with length 32. Actual length: $actualLength.",[sY]:"Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",[eY]:"The provided private key does not match the provided public key.",[tY]:"Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",[NG]:"Lamports value must be in the range [0, 2e64-1]",[wG]:"`$value` cannot be parsed as a `BigInt`",[MY]:"$message",[LG]:"`$value` cannot be parsed as a `Number`",[zG]:"No nonce account could be found at address `$nonceAccountAddress`",[sX]:"The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",[eX]:"WebSocket was closed before payload could be added to the send buffer",[TH]:"WebSocket connection closed",[AH]:"WebSocket failed to connect",[tX]:"Failed to obtain a subscription id from the server",[aX]:"Could not find an API plan for RPC method: `$method`",[nX]:"The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was `$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds `Number.MAX_SAFE_INTEGER`.",[iX]:"HTTP error ($statusCode): $message",[fX]:"HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",[zP]:"Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",[pG]:"The provided value does not implement the `KeyPairSigner` interface",[dG]:"The provided value does not implement the `MessageModifyingSigner` interface",[rG]:"The provided value does not implement the `MessagePartialSigner` interface",[uG]:"The provided value does not implement any of the `MessageSigner` interfaces",[oG]:"The provided value does not implement the `TransactionModifyingSigner` interface",[nG]:"The provided value does not implement the `TransactionPartialSigner` interface",[fG]:"The provided value does not implement the `TransactionSendingSigner` interface",[cG]:"The provided value does not implement any of the `TransactionSigner` interfaces",[iG]:"More than one `TransactionSendingSigner` was identified.",[aG]:"No `TransactionSendingSigner` was identified. Please provide a valid `TransactionWithSingleSendingSigner` transaction.",[PX]:"Wallet account signers do not support signing multiple messages/transactions in a single operation",[fY]:"Cannot export a non-extractable key.",[kP]:"No digest implementation could be found.",[RP]:"Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",[jP]:`This runtime does not support the generation of Ed25519 key pairs.
|
|
7
|
+
|
|
8
|
+
Install @solana/webcrypto-ed25519-polyfill and call its \`install\` function before generating keys in environments that do not support Ed25519.
|
|
9
|
+
|
|
10
|
+
For a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20.`,[DP]:"No signature verification implementation could be found.",[FP]:"No key generation implementation could be found.",[MP]:"No signing implementation could be found.",[vG]:"No key export implementation could be found.",[EG]:"Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",[IX]:"Transaction processing left an account with an outstanding borrowed reference",[$X]:"Account in use",[VX]:"Account loaded twice",[qX]:"Attempt to debit an account but found no record of a prior credit.",[OX]:"Transaction loads an address table account that doesn't exist",[HX]:"This transaction has already been processed",[KX]:"Blockhash not found",[RX]:"Loader call chain is too deep",[zX]:"Transactions are currently disabled due to cluster maintenance",[WU]:"Transaction contains a duplicate instruction ($index) that is not allowed",[ZX]:"Insufficient funds for fee",[GU]:"Transaction results in an account ($accountIndex) with insufficient funds for rent",[XX]:"This account may not be used to pay transaction fees",[jX]:"Transaction contains an invalid account reference",[_X]:"Transaction loads an address table account with invalid data",[hX]:"Transaction address table lookup uses an invalid index",[xX]:"Transaction loads an address table account with an invalid owner",[bX]:"LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",[FX]:"This program may not be used for executing instructions",[mX]:"Transaction leaves an account with a lower balance than rent-exempt minimum",[wX]:"Transaction loads a writable account that cannot be written",[yX]:"Transaction exceeded max loaded accounts data size cap",[kX]:"Transaction requires a fee but has no signature present",[YX]:"Attempt to load a program that does not exist",[UU]:"Execution of the program referenced by account at index $accountIndex is temporarily restricted.",[lX]:"ResanitizationNeeded",[MX]:"Transaction failed to sanitize accounts offsets correctly",[DX]:"Transaction did not pass signature verification",[BX]:"Transaction locked too many accounts",[pX]:"Sum of account balances before and after transaction do not match",[CU]:"The transaction failed with the error `$errorName`",[NX]:"Transaction version is unsupported",[EX]:"Transaction would exceed account data limit within the block",[vX]:"Transaction would exceed total account data limit",[LX]:"Transaction would exceed max account limit within the block",[SX]:"Transaction would exceed max Block Cost Limit",[gX]:"Transaction would exceed max Vote Cost Limit",[BP]:"Attempted to sign a transaction with an address that is not a signer for it",[QX]:"Transaction is missing an address at index: $index.",[OP]:"Transaction has no expected signers therefore it cannot be encoded",[PU]:"Transaction size $transactionSize exceeds limit of $transactionSizeLimit bytes",[SP]:"Transaction does not have a blockhash lifetime",[NP]:"Transaction is not a durable nonce transaction",[sG]:"Contents of these address lookup tables unknown: $lookupTableAddresses",[tG]:"Lookup of address at index $highestRequestedIndex failed for lookup table `$lookupTableAddress`. Highest known index is $highestKnownIndex. The lookup table may have been extended since its contents were retrieved",[TU]:"No fee payer set in CompiledTransaction",[eG]:"Could not find program address at index $index",[UX]:"Failed to estimate the compute unit consumption for this transaction message. This is likely because simulating the transaction failed. Inspect the `cause` property of this error to learn more",[JX]:"Transaction failed when it was simulated in order to estimate the compute unit consumption. The compute unit estimate provided is for a transaction that failed when simulated and may not be representative of the compute units this transaction would consume if successful. Inspect the `cause` property of this error to learn more",[CX]:"Transaction is missing a fee payer.",[EP]:"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",[GX]:"Transaction first instruction is not advance nonce account instruction.",[WX]:"Transaction with no instructions cannot be durable nonce transaction.",[IP]:"This transaction includes an address (`$programAddress`) which is both invoked and set as the fee payer. Program addresses may not pay fees",[l2]:"This transaction includes an address (`$programAddress`) which is both invoked and marked writable. Program addresses may not be writable",[AU]:"The transaction message expected the transaction to have $numRequiredSignatures signatures, got $signaturesLength.",[LP]:"Transaction is missing signatures for addresses: $addresses.",[wP]:"Transaction version must be in the range [0, 127]. `$actualVersion` given",[xP]:"This version of Kit does not support decoding transactions with version $unsupportedVersion. The current max supported version is 0.",[QU]:"The transaction has a durable nonce lifetime (with nonce `$nonce`), but the nonce account address is in a lookup table. The lifetime constraint cannot be constructed without fetching the lookup tables for the transaction."},b0="i",j0="t";function $H(T,A={}){let P=JH[T];if(P.length===0)return"";let Q;function C(G){if(Q[j0]===2){let J=P.slice(Q[b0]+1,G);W.push(J in A?`${A[J]}`:`$${J}`)}else if(Q[j0]===1)W.push(P.slice(Q[b0],G))}let W=[];return P.split("").forEach((G,J)=>{if(J===0){Q={[b0]:0,[j0]:P[0]==="\\"?0:P[0]==="$"?2:1};return}let $;switch(Q[j0]){case 0:$={[b0]:J,[j0]:1};break;case 1:if(G==="\\")$={[b0]:J,[j0]:0};else if(G==="$")$={[b0]:J,[j0]:2};break;case 2:if(G==="\\")$={[b0]:J,[j0]:0};else if(G==="$")$={[b0]:J,[j0]:2};else if(!G.match(/\w/))$={[b0]:J,[j0]:1};break}if($){if(Q!==$)C(J);Q=$}}),C(),W.join("")}function VH(T,A={}){return $H(T,A)}function pP(T,A){if(T instanceof Error&&T.name==="SolanaError"){if(A!==void 0)return T.context.__code===A;return!0}return!1}var e=class extends Error{cause=this.cause;context;constructor(...[T,A]){let P,Q;if(A)Object.entries(Object.getOwnPropertyDescriptors(A)).forEach(([W,G])=>{if(W==="cause")Q={cause:G.value};else{if(P===void 0)P={};Object.defineProperty(P,W,G)}});let C=VH(T,P);super(C,Q);this.context=P===void 0?{}:P,this.context.__code=T,this.name="SolanaError"}};function qH(...T){if("captureStackTrace"in Error&&typeof Error.captureStackTrace==="function")Error.captureStackTrace(...T)}function JU({errorCodeBaseOffset:T,getErrorContext:A,orderedErrorNames:P,rpcEnumError:Q},C){let W,G;if(typeof Q==="string")W=Q;else W=Object.keys(Q)[0],G=Q[W];let J=P.indexOf(W),$=T+J,X=A($,W,G),Z=new e($,X);return qH(Z,C),Z}var YH=["GenericError","InvalidArgument","InvalidInstructionData","InvalidAccountData","AccountDataTooSmall","InsufficientFunds","IncorrectProgramId","MissingRequiredSignature","AccountAlreadyInitialized","UninitializedAccount","UnbalancedInstruction","ModifiedProgramId","ExternalAccountLamportSpend","ExternalAccountDataModified","ReadonlyLamportChange","ReadonlyDataModified","DuplicateAccountIndex","ExecutableModified","RentEpochModified","NotEnoughAccountKeys","AccountDataSizeChanged","AccountNotExecutable","AccountBorrowFailed","AccountBorrowOutstanding","DuplicateAccountOutOfSync","Custom","InvalidError","ExecutableDataModified","ExecutableLamportChange","ExecutableAccountNotRentExempt","UnsupportedProgramId","CallDepth","MissingAccount","ReentrancyNotAllowed","MaxSeedLengthExceeded","InvalidSeeds","InvalidRealloc","ComputationalBudgetExceeded","PrivilegeEscalation","ProgramEnvironmentSetupFailure","ProgramFailedToComplete","ProgramFailedToCompile","Immutable","IncorrectAuthority","BorshIoError","AccountNotRentExempt","InvalidAccountOwner","ArithmeticOverflow","UnsupportedSysvar","IllegalOwner","MaxAccountsDataAllocationsExceeded","MaxAccountsExceeded","MaxInstructionTraceLengthExceeded","BuiltinProgramsMustConsumeComputeUnits"];function $U(T,A){let P=Number(T);return JU({errorCodeBaseOffset:4615001,getErrorContext(Q,C,W){if(Q===bG)return{errorName:C,index:P,...W!==void 0?{instructionErrorContext:W}:null};else if(Q===lG)return{code:Number(W),index:P};return{index:P}},orderedErrorNames:YH,rpcEnumError:A},$U)}var ZH=["AccountInUse","AccountLoadedTwice","AccountNotFound","ProgramAccountNotFound","InsufficientFundsForFee","InvalidAccountForFee","AlreadyProcessed","BlockhashNotFound","CallChainTooDeep","MissingSignatureForFee","InvalidAccountIndex","SignatureFailure","InvalidProgramForExecution","SanitizeFailure","ClusterMaintenance","AccountBorrowOutstanding","WouldExceedMaxBlockCostLimit","UnsupportedVersion","InvalidWritableAccount","WouldExceedMaxAccountCostLimit","WouldExceedAccountDataBlockLimit","TooManyAccountLocks","AddressLookupTableNotFound","InvalidAddressLookupTableOwner","InvalidAddressLookupTableData","InvalidAddressLookupTableIndex","InvalidRentPayingAccount","WouldExceedMaxVoteCostLimit","WouldExceedAccountDataTotalLimit","DuplicateInstruction","InsufficientFundsForRent","MaxLoadedAccountsDataSizeExceeded","InvalidLoadedAccountsDataSizeLimit","ResanitizationNeeded","ProgramExecutionTemporarilyRestricted","UnbalancedTransaction"];function t2(T){if(typeof T==="object"&&"InstructionError"in T)return $U(...T.InstructionError);return JU({errorCodeBaseOffset:7050001,getErrorContext(A,P,Q){if(A===CU)return{errorName:P,...Q!==void 0?{transactionErrorContext:Q}:null};else if(A===WU)return{index:Number(Q)};else if(A===GU||A===UU)return{accountIndex:Number(Q.account_index)}},orderedErrorNames:ZH,rpcEnumError:T},t2)}function XH(T,A){return"fixedSize"in A?A.fixedSize:A.getSizeFromValue(T)}function VU(T){return Object.freeze({...T,encode:(A)=>{let P=new Uint8Array(XH(A,T));return T.write(A,P,0),P}})}var qU="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",YU=()=>{return VU({getSizeFromValue:(T)=>{try{return atob(T).length}catch{throw new e(qA,{alphabet:qU,base:64,value:T})}},write(T,A,P){try{let Q=atob(T).split("").map((C)=>C.charCodeAt(0));return A.set(Q,P),Q.length+P}catch{throw new e(qA,{alphabet:qU,base:64,value:T})}}})};var{TextDecoder:ES,TextEncoder:BS}=globalThis;function e2(T,A){try{if("exists"in T&&!T.exists)return T;return Object.freeze({...T,data:A.decode(T.data)})}catch{throw new e(KP,{address:T.address})}}function HH(T,A){if(!A)return Object.freeze({address:T,exists:!1});let P=YU().encode(A.data[0]);return Object.freeze({...KH(A),address:T,data:P,exists:!0})}function KH(T){return Object.freeze({executable:T.executable,lamports:T.lamports,programAddress:T.owner,space:T.space})}async function T6(T,A,P={}){let{abortSignal:Q,...C}=P,W=await T.getAccountInfo(A,{...C,encoding:"base64"}).send({abortSignal:Q});return HH(A,W.value)}function A6(T){if(!T.exists)throw new e(HP,{address:T.address})}function RH(T,A){if(T.length>=A)return T;let P=new Uint8Array(A).fill(0);return P.set(T),P}var kH=(T,A)=>RH(T.length<=A?T:T.slice(0,A),A);function jH(T,A){return"fixedSize"in A?A.fixedSize:A.getSizeFromValue(T)}function P6(T){return Object.freeze({...T,encode:(A)=>{let P=new Uint8Array(jH(A,T));return T.write(A,P,0),P}})}function uP(T){return Object.freeze({...T,decode:(A,P=0)=>T.read(A,P)[0]})}function YA(T){return"fixedSize"in T&&typeof T.fixedSize==="number"}function DH(T){return!YA(T)}function dP(T,A){if(YA(T)!==YA(A))throw new e(u2);if(YA(T)&&YA(A)&&T.fixedSize!==A.fixedSize)throw new e(d2,{decoderFixedSize:A.fixedSize,encoderFixedSize:T.fixedSize});if(!YA(T)&&!YA(A)&&T.maxSize!==A.maxSize)throw new e(r2,{decoderMaxSize:A.maxSize,encoderMaxSize:T.maxSize});return{...A,...T,decode:A.decode,encode:T.encode,read:A.read,write:T.write}}function FH(T,A,P,Q=0){let C=P.length-Q;if(C<A)throw new e(u8,{bytesLength:C,codecDescription:T,expected:A})}function ZU(T,A){return P6({fixedSize:A,write:(P,Q,C)=>{let W=T.encode(P),G=W.length>A?W.slice(0,A):W;return Q.set(G,C),C+A}})}function XU(T,A){return uP({fixedSize:A,read:(P,Q)=>{if(FH("fixCodecSize",A,P,Q),Q>0||P.length>A)P=P.slice(Q,Q+A);if(YA(T))P=kH(P,T.fixedSize);let[C]=T.read(P,0);return[C,Q+A]}})}function HU(T,A){return P6({...DH(T)?{...T,getSizeFromValue:(P)=>T.getSizeFromValue(A(P))}:T,write:(P,Q,C)=>T.write(A(P),Q,C)})}function MH(T,A,P=A){if(!A.match(new RegExp(`^[${T}]*$`)))throw new e(qA,{alphabet:T,base:T.length,value:P})}var zH=(T)=>{return P6({getSizeFromValue:(A)=>{let[P,Q]=KU(A,T[0]);if(!Q)return A.length;let C=RU(Q,T);return P.length+Math.ceil(C.toString(16).length/2)},write(A,P,Q){if(MH(T,A),A==="")return Q;let[C,W]=KU(A,T[0]);if(!W)return P.set(new Uint8Array(C.length).fill(0),Q),Q+C.length;let G=RU(W,T),J=[];while(G>0n)J.unshift(Number(G%256n)),G/=256n;let $=[...Array(C.length).fill(0),...J];return P.set($,Q),Q+$.length}})},IH=(T)=>{return uP({read(A,P){let Q=P===0?A:A.slice(P);if(Q.length===0)return["",0];let C=Q.findIndex(($)=>$!==0);C=C===-1?Q.length:C;let W=T[0].repeat(C);if(C===Q.length)return[W,A.length];let G=Q.slice(C).reduce(($,X)=>$*256n+BigInt(X),0n),J=SH(G,T);return[W+J,A.length]}})};function KU(T,A){let[P,Q]=T.split(new RegExp(`((?!${A}).*)`));return[P,Q]}function RU(T,A){let P=BigInt(A.length),Q=0n;for(let C of T)Q*=P,Q+=BigInt(A.indexOf(C));return Q}function SH(T,A){let P=BigInt(A.length),Q=[];while(T>0n)Q.unshift(A[Number(T%P)]),T/=P;return Q.join("")}var kU="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",jU=()=>zH(kU),DU=()=>IH(kU);var{TextDecoder:lS,TextEncoder:pS}=globalThis;function Q6(){if(!globalThis.isSecureContext)throw new e(RP)}var gA;async function NH(T){if(gA===void 0)gA=new Promise((A)=>{T.generateKey("Ed25519",!1,["sign","verify"]).then(()=>{A(gA=!0)}).catch(()=>{A(gA=!1)})});if(typeof gA==="boolean")return gA;else return await gA}function FU(){if(Q6(),typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.digest!=="function")throw new e(kP)}async function MU(){if(Q6(),typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.generateKey!=="function")throw new e(FP);if(!await NH(globalThis.crypto.subtle))throw new e(jP)}function rP(){if(Q6(),typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.exportKey!=="function")throw new e(DP)}function zU(){if(Q6(),typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.sign!=="function")throw new e(MP)}var cP,oP;function nP(){if(!cP)cP=jU();return cP}function wH(){if(!oP)oP=DU();return oP}function C6(T){if(T.length<32||T.length>44)return!1;let A=nP();try{return A.encode(T).byteLength===32}catch{return!1}}function fP(T){if(T.length<32||T.length>44)throw new e(y2,{actualLength:T.length});let Q=nP().encode(T).byteLength;if(Q!==32)throw new e(v2,{actualLength:Q})}function b(T){return fP(T),T}function HT(){return HU(ZU(nP(),32),(T)=>b(T))}function F0(){return XU(wH(),32)}function LH(){return dP(HT(),F0())}function W6(){return new Intl.Collator("en",{caseFirst:"lower",ignorePunctuation:!1,localeMatcher:"best fit",numeric:!1,sensitivity:"variant",usage:"sort"}).compare}var EH=37095705934669439343138083508754565189542113879843219016388785533085940283555n,BT=57896044618658097711785492504343953926634992332820282019728792003956564819949n,IU=19681161376707505956807079304988542015446066515923890162744021073123829784752n;function P0(T){let A=T%BT;return A>=0n?A:BT+A}function D0(T,A){let P=T;while(A-- >0n)P*=P,P%=BT;return P}function BH(T){let P=T*T%BT*T%BT,Q=D0(P,2n)*P%BT,C=D0(Q,1n)*T%BT,W=D0(C,5n)*C%BT,G=D0(W,10n)*W%BT,J=D0(G,20n)*G%BT,$=D0(J,40n)*J%BT,X=D0($,80n)*$%BT,Z=D0(X,80n)*$%BT,R=D0(Z,10n)*W%BT;return D0(R,2n)*T%BT}function OH(T,A){let P=P0(A*A*A),Q=P0(P*P*A),C=BH(T*Q),W=P0(T*P*C),G=P0(A*W*W),J=W,$=P0(W*IU),X=G===T,Z=G===P0(-T),R=G===P0(-T*IU);if(X)W=J;if(Z||R)W=$;if((P0(W)&1n)===1n)W=P0(-W);if(!X&&!Z)return null;return W}function xH(T,A){let P=P0(T*T),Q=P0(P-1n),C=P0(EH*P+1n),W=OH(Q,C);if(W===null)return!1;let G=(A&128)!==0;if(W===0n&&G)return!1;return!0}function _H(T){let A=T.toString(16);if(A.length===1)return`0${A}`;else return A}function hH(T){let P=`0x${T.reduce((Q,C,W)=>`${_H(W===31?C&-129:C)}${Q}`,"")}`;return BigInt(P)}function mH(T){if(T.byteLength!==32)return!1;let A=hH(T);return xH(A,T[31])}var SU=32,NU=16,gH=[80,114,111,103,114,97,109,68,101,114,105,118,101,100,65,100,100,114,101,115,115];async function vH({programAddress:T,seeds:A}){if(FU(),A.length>NU)throw new e(YP,{actual:A.length,maxSeeds:NU});let P,Q=A.reduce(($,X,Z)=>{let R=typeof X==="string"?(P||=new TextEncoder).encode(X):X;if(R.byteLength>SU)throw new e(ZP,{actual:R.byteLength,index:Z,maxSeedLength:SU});return $.push(...R),$},[]),C=LH(),W=C.encode(T),G=await crypto.subtle.digest("SHA-256",new Uint8Array([...Q,...W,...gH])),J=new Uint8Array(G);if(mH(J))throw new e(b2);return C.decode(J)}async function j1({programAddress:T,seeds:A}){let P=255;while(P>0)try{return[await vH({programAddress:T,seeds:[...A,new Uint8Array([P])]}),P]}catch(Q){if(pP(Q,b2))P--;else throw Q}throw new e(XP)}async function G6(T){if(rP(),T.type!=="public"||T.algorithm.name!=="Ed25519")throw new e(qP);let A=await crypto.subtle.exportKey("raw",T);return F0().decode(new Uint8Array(A))}function yH(T,A){if(T.length>=A)return T;let P=new Uint8Array(A).fill(0);return P.set(T),P}var bH=(T,A)=>yH(T.length<=A?T:T.slice(0,A),A);function V8(T,A){return"fixedSize"in A?A.fixedSize:A.getSizeFromValue(T)}function Q0(T){return Object.freeze({...T,encode:(A)=>{let P=new Uint8Array(V8(A,T));return T.write(A,P,0),P}})}function p0(T){return Object.freeze({...T,decode:(A,P=0)=>T.read(A,P)[0]})}function l0(T){return"fixedSize"in T&&typeof T.fixedSize==="number"}function lH(T){return!l0(T)}function wU(T,A,P=0){if(A.length-P<=0)throw new e(p2,{codecDescription:T})}function U6(T,A,P,Q=0){let C=P.length-Q;if(C<A)throw new e(u8,{bytesLength:C,codecDescription:T,expected:A})}function J6(T,A){let P=(G,J,$)=>{let X=T.encode(G);return $=A.write(X.length,J,$),J.set(X,$),$+X.length};if(l0(A)&&l0(T))return Q0({...T,fixedSize:A.fixedSize+T.fixedSize,write:P});let Q=l0(A)?A.fixedSize:A.maxSize??null,C=l0(T)?T.fixedSize:T.maxSize??null,W=Q!==null&&C!==null?Q+C:null;return Q0({...T,...W!==null?{maxSize:W}:{},getSizeFromValue:(G)=>{let J=V8(G,T);return V8(J,A)+J},write:P})}function iT(T,A){return Q0({fixedSize:A,write:(P,Q,C)=>{let W=T.encode(P),G=W.length>A?W.slice(0,A):W;return Q.set(G,C),C+A}})}function M0(T,A){return p0({fixedSize:A,read:(P,Q)=>{if(U6("fixCodecSize",A,P,Q),Q>0||P.length>A)P=P.slice(Q,Q+A);if(l0(T))P=bH(P,T.fixedSize);let[C]=T.read(P,0);return[C,Q+A]}})}function lT(T,A){return Q0({...lH(T)?{...T,getSizeFromValue:(P)=>T.getSizeFromValue(A(P))}:T,write:(P,Q,C)=>T.write(A(P),Q,C)})}function LU(T,A){return p0({...T,read:(P,Q)=>{let[C,W]=T.read(P,Q);return[A(C,P,Q),W]}})}function pH(T,A,P,Q){if(Q<A||Q>P)throw new e(mA,{codecDescription:T,max:P,min:A,value:Q})}function EU(T){return T?.endian===1?!1:!0}function iP(T){return Q0({fixedSize:T.size,write(A,P,Q){if(T.range)pH(T.name,T.range[0],T.range[1],A);let C=new ArrayBuffer(T.size);return T.set(new DataView(C),A,EU(T.config)),P.set(new Uint8Array(C),Q),Q+T.size}})}function $6(T){return p0({fixedSize:T.size,read(A,P=0){wU(T.name,A,P),U6(T.name,T.size,A,P);let Q=new DataView(uH(A,P,T.size));return[T.get(Q,EU(T.config)),P+T.size]}})}function uH(T,A,P){let Q=T.byteOffset+(A??0),C=P??T.byteLength;return T.buffer.slice(Q,Q+C)}var BU=(T={})=>$6({config:T,get:(A,P)=>{let Q=P?8:0,C=P?0:8,W=A.getBigUint64(Q,P),G=A.getBigUint64(C,P);return(W<<64n)+G},name:"u128",size:16});var r8=(T={})=>iP({config:T,name:"u32",range:[0,Number("0xffffffff")],set:(A,P,Q)=>A.setUint32(0,Number(P),Q),size:4}),aP=(T={})=>$6({config:T,get:(A,P)=>A.getUint32(0,P),name:"u32",size:4});var DT=(T={})=>iP({config:T,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(A,P,Q)=>A.setBigUint64(0,BigInt(P),Q),size:8}),pT=(T={})=>$6({config:T,get:(A,P)=>A.getBigUint64(0,P),name:"u64",size:8});var sP=()=>iP({name:"u8",range:[0,Number("0xff")],set:(T,A)=>T.setUint8(0,Number(A)),size:1}),V6=()=>$6({get:(T)=>T.getUint8(0),name:"u8",size:1});function dH(T,A,P){if(A!==P)throw new e(hA,{actual:P,codecDescription:T,expected:A})}function q8(T){return T.reduce((A,P)=>A===null||P===null?null:A+P,0)}function q6(T){return l0(T)?T.fixedSize:null}function Y6(T){return l0(T)?T.fixedSize:T.maxSize??null}function xU(T,A={}){let P=A.size??aP(),Q=q6(T),C=OU(P,Q),W=OU(P,Y6(T))??void 0;return p0({...C!==null?{fixedSize:C}:{maxSize:W},read:(G,J)=>{let $=[];if(typeof P==="object"&&G.slice(J).length===0)return[$,J];if(P==="remainder"){while(J<G.length){let[R,D]=T.read(G,J);J=D,$.push(R)}return[$,J]}let[X,Z]=typeof P==="number"?[P,J]:P.read(G,J);J=Z;for(let R=0;R<X;R+=1){let[D,z]=T.read(G,J);J=z,$.push(D)}return[$,J]}})}function OU(T,A){if(typeof T!=="number")return null;if(T===0)return 0;return A===null?null:A*T}function tP(T={}){return lT(T.size??sP(),(A)=>A?1:0)}function eP(T={}){return LU(T.size??V6(),(A)=>Number(A)===1)}function W0(){return Q0({getSizeFromValue:(T)=>T.length,write:(T,A,P)=>{return A.set(T,P),P+T.length}})}function u0(){return p0({read:(T,A)=>{let P=T.slice(A);return[P,A+P.length]}})}function _U(T){let A=q8(T.map(q6)),P=q8(T.map(Y6))??void 0;return Q0({...A===null?{getSizeFromValue:(Q)=>T.map((C,W)=>V8(Q[W],C)).reduce((C,W)=>C+W,0),maxSize:P}:{fixedSize:A},write:(Q,C,W)=>{return dH("tuple",T.length,Q.length),T.forEach((G,J)=>{W=G.write(Q[J],C,W)}),W}})}function uT(T){let A=T.map(([,C])=>C),P=q8(A.map(q6)),Q=q8(A.map(Y6))??void 0;return Q0({...P===null?{getSizeFromValue:(C)=>T.map(([W,G])=>V8(C[W],G)).reduce((W,G)=>W+G,0),maxSize:Q}:{fixedSize:P},write:(C,W,G)=>{return T.forEach(([J,$])=>{G=$.write(C[J],W,G)}),G}})}function aT(T){let A=T.map(([,C])=>C),P=q8(A.map(q6)),Q=q8(A.map(Y6))??void 0;return p0({...P===null?{maxSize:Q}:{fixedSize:P},read:(C,W)=>{let G={};return T.forEach(([J,$])=>{let[X,Z]=$.read(C,W);W=Z,G[J]=X}),[G,W]}})}var{TextDecoder:JN,TextEncoder:hU}=globalThis,Z6=()=>{let T;return Q0({getSizeFromValue:(A)=>(T||=new hU).encode(A).length,write:(A,P,Q)=>{let C=(T||=new hU).encode(A);return P.set(C,Q),Q+C.length}})};var X1=((T)=>{return T[T.WRITABLE_SIGNER=3]="WRITABLE_SIGNER",T[T.READONLY_SIGNER=2]="READONLY_SIGNER",T[T.WRITABLE=1]="WRITABLE",T[T.READONLY=0]="READONLY",T})(X1||{}),rH=2,cH=1;function d0(T){return T>=2}function Y8(T){return(T&cH)!==0}function TQ(T,A){return T|A}function X6(T){return T|rH}function gU(T){return C6(T)}function mU(T){switch(T){case"finalized":return 2;case"confirmed":return 1;case"processed":return 0;default:throw new e(lP,{unexpectedValue:T})}}function H6(T,A){if(T===A)return 0;return mU(T)<mU(A)?-1:1}var ZN=-9223372036854775808n;function ZA(T,A){return"fixedSize"in A?A.fixedSize:A.getSizeFromValue(T)}function qT(T){return Object.freeze({...T,encode:(A)=>{let P=new Uint8Array(ZA(A,T));return T.write(A,P,0),P}})}function z0(T){return"fixedSize"in T&&typeof T.fixedSize==="number"}function oH(T){return!z0(T)}function vU(T,A){let P=(G,J,$)=>{let X=T.encode(G);return $=A.write(X.length,J,$),J.set(X,$),$+X.length};if(z0(A)&&z0(T))return qT({...T,fixedSize:A.fixedSize+T.fixedSize,write:P});let Q=z0(A)?A.fixedSize:A.maxSize??null,C=z0(T)?T.fixedSize:T.maxSize??null,W=Q!==null&&C!==null?Q+C:null;return qT({...T,...W!==null?{maxSize:W}:{},getSizeFromValue:(G)=>{let J=ZA(G,T);return ZA(J,A)+J},write:P})}function AQ(T,A){return qT({fixedSize:A,write:(P,Q,C)=>{let W=T.encode(P),G=W.length>A?W.slice(0,A):W;return Q.set(G,C),C+A}})}function K6(T,A){return qT({...oH(T)?{...T,getSizeFromValue:(P)=>T.getSizeFromValue(A(P))}:T,write:(P,Q,C)=>T.write(A(P),Q,C)})}function lU(T,A,P,Q){if(Q<A||Q>P)throw new e(mA,{codecDescription:T,max:P,min:A,value:Q})}function fH(T){return T?.endian===1?!1:!0}function pU(T){return qT({fixedSize:T.size,write(A,P,Q){if(T.range)lU(T.name,T.range[0],T.range[1],A);let C=new ArrayBuffer(T.size);return T.set(new DataView(C),A,fH(T.config)),P.set(new Uint8Array(C),Q),Q+T.size}})}var vA=()=>qT({getSizeFromValue:(T)=>{if(T<=127)return 1;if(T<=16383)return 2;return 3},maxSize:3,write:(T,A,P)=>{lU("shortU16",0,65535,T);let Q=[0];for(let C=0;;C+=1){let W=Number(T)>>C*7;if(W===0)break;let G=127&W;if(Q[C]=G,C>0)Q[C-1]|=128}return A.set(Q,P),P+Q.length}});var uU=(T={})=>pU({config:T,name:"u32",range:[0,Number("0xffffffff")],set:(A,P,Q)=>A.setUint32(0,Number(P),Q),size:4});var Z8=()=>pU({name:"u8",range:[0,Number("0xff")],set:(T,A)=>T.setUint8(0,Number(A)),size:1});function tH(T,A,P){if(A!==P)throw new e(hA,{actual:P,codecDescription:T,expected:A})}function eH(T){return T.reduce((A,P)=>A===null||P===null?null:Math.max(A,P),0)}function dU(T){return T.reduce((A,P)=>A===null||P===null?null:A+P,0)}function oU(T){return z0(T)?T.fixedSize:null}function PQ(T){return z0(T)?T.fixedSize:T.maxSize??null}function X8(T,A={}){let P=A.size??uU(),Q=rU(P,oU(T)),C=rU(P,PQ(T))??void 0;return qT({...Q!==null?{fixedSize:Q}:{getSizeFromValue:(W)=>{return(typeof P==="object"?ZA(W.length,P):0)+[...W].reduce((J,$)=>J+ZA($,T),0)},maxSize:C},write:(W,G,J)=>{if(typeof P==="number")tH("array",P,W.length);if(typeof P==="object")J=P.write(W.length,G,J);return W.forEach(($)=>{J=T.write($,G,J)}),J}})}function rU(T,A){if(typeof T!=="number")return null;if(T===0)return 0;return A===null?null:A*T}function nU(){return qT({getSizeFromValue:(T)=>T.length,write:(T,A,P)=>{return A.set(T,P),P+T.length}})}function fU(T){return qT({fixedSize:T.length,write:(A,P,Q)=>{return P.set(T,Q),Q+T.length}})}function iU(T,A){let P=TK(T),Q=(W,G,J)=>{let $=A(W);return cU(T,$),T[$].write(W,G,J)};if(P!==null)return qT({fixedSize:P,write:Q});let C=AK(T);return qT({...C!==null?{maxSize:C}:{},getSizeFromValue:(W)=>{let G=A(W);return cU(T,G),ZA(W,T[G])},write:Q})}function cU(T,A){if(typeof T[A]>"u")throw new e(d8,{maxRange:T.length-1,minRange:0,variant:A})}function TK(T){if(T.length===0)return 0;if(!z0(T[0]))return null;let A=T[0].fixedSize;return T.every((Q)=>z0(Q)&&Q.fixedSize===A)?A:null}function AK(T){return eH(T.map((A)=>PQ(A)))}function H8(T){let A=T.map(([,C])=>C),P=dU(A.map(oU)),Q=dU(A.map(PQ))??void 0;return qT({...P===null?{getSizeFromValue:(C)=>T.map(([W,G])=>ZA(C[W],G)).reduce((W,G)=>W+G,0),maxSize:Q}:{fixedSize:P},write:(C,W,G)=>{return T.forEach(([J,$])=>{G=$.write(C[J],W,G)}),G}})}function AJ(T){return"lifetimeConstraint"in T&&typeof T.lifetimeConstraint.blockhash==="string"&&typeof T.lifetimeConstraint.lastValidBlockHeight==="bigint"&&gU(T.lifetimeConstraint.blockhash)}function PJ(T,A){if("lifetimeConstraint"in A&&A.lifetimeConstraint&&"blockhash"in A.lifetimeConstraint&&A.lifetimeConstraint.blockhash===T.blockhash&&A.lifetimeConstraint.lastValidBlockHeight===T.lastValidBlockHeight)return A;return Object.freeze({...A,lifetimeConstraint:Object.freeze(T)})}function PK(T,A,P=A){if(!A.match(new RegExp(`^[${T}]*$`)))throw new e(qA,{alphabet:T,base:T.length,value:P})}var QK=(T)=>{return qT({getSizeFromValue:(A)=>{let[P,Q]=aU(A,T[0]);if(!Q)return A.length;let C=sU(Q,T);return P.length+Math.ceil(C.toString(16).length/2)},write(A,P,Q){if(PK(T,A),A==="")return Q;let[C,W]=aU(A,T[0]);if(!W)return P.set(new Uint8Array(C.length).fill(0),Q),Q+C.length;let G=sU(W,T),J=[];while(G>0n)J.unshift(Number(G%256n)),G/=256n;let $=[...Array(C.length).fill(0),...J];return P.set($,Q),Q+$.length}})};function aU(T,A){let[P,Q]=T.split(new RegExp(`((?!${A}).*)`));return[P,Q]}function sU(T,A){let P=BigInt(A.length),Q=0n;for(let C of T)Q*=P,Q+=BigInt(A.indexOf(C));return Q}var CK="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",WK=()=>QK(CK);var QQ;function GK(){if(!QQ){let T=X8(Z8(),{size:vA()});QQ=H8([["lookupTableAddress",HT()],["writableIndexes",T],["readonlyIndexes",T]])}return QQ}var CQ;function WQ(){if(!CQ)CQ=Z8();return CQ}function UK(){return H8([["numSignerAccounts",WQ()],["numReadonlySignerAccounts",WQ()],["numReadonlyNonSignerAccounts",WQ()]])}var GQ;function JK(){if(!GQ)GQ=K6(H8([["programAddressIndex",Z8()],["accountIndices",X8(Z8(),{size:vA()})],["data",vU(nU(),vA())]]),(T)=>{if(T.accountIndices!==void 0&&T.data!==void 0)return T;return{...T,accountIndices:T.accountIndices??[],data:T.data??new Uint8Array(0)}});return GQ}var $K=0,VK=128;function qK(){return qT({getSizeFromValue:(T)=>T==="legacy"?0:1,maxSize:1,write:(T,A,P)=>{if(T==="legacy")return P;if(T<0||T>127)throw new e(wP,{actualVersion:T});if(T>$K)throw new e(xP,{unsupportedVersion:T});return A.set([T|VK],P),P+1}})}function tU(){return H8(QJ())}function eU(){return K6(H8([...QJ(),["addressTableLookups",YK()]]),(T)=>{if(T.version==="legacy")return T;return{...T,addressTableLookups:T.addressTableLookups??[]}})}function QJ(){let T=iU([fU(new Uint8Array(32)),AQ(WK(),32)],(A)=>A===void 0?0:1);return[["version",qK()],["header",UK()],["staticAccounts",X8(HT(),{size:vA()})],["lifetimeToken",T],["instructions",X8(JK(),{size:vA()})]]}function YK(){return X8(GK(),{size:vA()})}function CJ(){return qT({getSizeFromValue:(T)=>{if(T.version==="legacy")return tU().getSizeFromValue(T);else return eU().getSizeFromValue(T)},write:(T,A,P)=>{if(T.version==="legacy")return tU().write(T,A,P);else return eU().write(T,A,P)}})}function TJ(T,A,P){T[A]=P(T[A]??{role:X1.READONLY})}var GT=Symbol("AddressMapTypeProperty");function ZK(T,A){let P={[T]:{[GT]:0,role:X1.WRITABLE_SIGNER}},Q=new Set;for(let C of A){TJ(P,C.programAddress,(G)=>{if(Q.add(C.programAddress),GT in G){if(Y8(G.role))switch(G[GT]){case 0:throw new e(IP,{programAddress:C.programAddress});default:throw new e(l2,{programAddress:C.programAddress})}if(G[GT]===2)return G}return{[GT]:2,role:X1.READONLY}});let W;if(!C.accounts)continue;for(let G of C.accounts)TJ(P,G.address,(J)=>{let{address:$,...X}=G;if(GT in J)switch(J[GT]){case 0:return J;case 1:{let Z=TQ(J.role,X.role);if("lookupTableAddress"in X){if(J.lookupTableAddress!==X.lookupTableAddress&&(W||=W6())(X.lookupTableAddress,J.lookupTableAddress)<0)return{[GT]:1,...X,role:Z}}else if(d0(X.role))return{[GT]:2,role:Z};if(J.role!==Z)return{...J,role:Z};else return J}case 2:{let Z=TQ(J.role,X.role);if(Q.has(G.address)){if(Y8(X.role))throw new e(l2,{programAddress:G.address});if(J.role!==Z)return{...J,role:Z};else return J}else if("lookupTableAddress"in X&&!d0(J.role))return{...X,[GT]:1,role:Z};else if(J.role!==Z)return{...J,role:Z};else return J}}if("lookupTableAddress"in X)return{...X,[GT]:1};else return{...X,[GT]:2}})}return P}function XK(T){let A;return Object.entries(T).sort(([Q,C],[W,G])=>{if(C[GT]!==G[GT]){if(C[GT]===0)return-1;else if(G[GT]===0)return 1;else if(C[GT]===2)return-1;else if(G[GT]===2)return 1}let J=d0(C.role);if(J!==d0(G.role))return J?-1:1;let $=Y8(C.role);if($!==Y8(G.role))return $?-1:1;if(A||=W6(),C[GT]===1&&G[GT]===1&&C.lookupTableAddress!==G.lookupTableAddress)return A(C.lookupTableAddress,G.lookupTableAddress);else return A(Q,W)}).map(([Q,C])=>({address:Q,...C}))}function HK(T){let A={};for(let P of T){if(!("lookupTableAddress"in P))continue;let Q=A[P.lookupTableAddress]||={readonlyIndexes:[],writableIndexes:[]};if(P.role===X1.WRITABLE)Q.writableIndexes.push(P.addressIndex);else Q.readonlyIndexes.push(P.addressIndex)}return Object.keys(A).sort(W6()).map((P)=>({lookupTableAddress:P,...A[P]}))}function KK(T){let A=0,P=0,Q=0;for(let C of T){if("lookupTableAddress"in C)break;let W=Y8(C.role);if(d0(C.role)){if(Q++,!W)P++}else if(!W)A++}return{numReadonlyNonSignerAccounts:A,numReadonlySignerAccounts:P,numSignerAccounts:Q}}function RK(T){let A={};for(let[P,Q]of T.entries())A[Q.address]=P;return A}function kK(T,A){let P=RK(A);return T.map(({accounts:Q,data:C,programAddress:W})=>{return{programAddressIndex:P[W],...Q?{accountIndices:Q.map(({address:G})=>P[G])}:null,...C?{data:C}:null}})}function jK(T){if("nonce"in T)return T.nonce;return T.blockhash}function DK(T){let A=T.findIndex((Q)=>("lookupTableAddress"in Q));return(A===-1?T:T.slice(0,A)).map(({address:Q})=>Q)}function WJ(T){let A=ZK(T.feePayer.address,T.instructions),P=XK(A),Q=T.lifetimeConstraint;return{...T.version!=="legacy"?{addressTableLookups:HK(P)}:null,...Q?{lifetimeToken:jK(Q)}:null,header:KK(P),instructions:kK(T.instructions,P),staticAccounts:DK(P),version:T.version}}function GJ(T){return Object.freeze({instructions:Object.freeze([]),version:T.version})}var FK="SysvarRecentB1ockHashes11111111111111111111",MK="11111111111111111111111111111111";function zK(T){return T.programAddress===MK&&T.data!=null&&IK(T.data)&&T.accounts?.length===3&&T.accounts[0].address!=null&&T.accounts[0].role===X1.WRITABLE&&T.accounts[1].address===FK&&T.accounts[1].role===X1.READONLY&&T.accounts[2].address!=null&&d0(T.accounts[2].role)}function IK(T){return T.byteLength===4&&T[0]===4&&T[1]===0&&T[2]===0&&T[3]===0}function UJ(T){return"lifetimeConstraint"in T&&typeof T.lifetimeConstraint.nonce==="string"&&T.instructions[0]!=null&&zK(T.instructions[0])}function JJ(T,A){if("feePayer"in A&&T===A.feePayer?.address&&SK(A.feePayer))return A;let P={...A,feePayer:Object.freeze({address:T})};return Object.freeze(P),P}function SK(T){return!!T&&"address"in T&&typeof T.address==="string"&&Object.keys(T).length===1}function $J(T,A){return NK([T],A)}function NK(T,A){return Object.freeze({...A,instructions:Object.freeze([...A.instructions,...T])})}function c8(T,A){return"fixedSize"in A?A.fixedSize:A.getSizeFromValue(T)}function I0(T){return Object.freeze({...T,encode:(A)=>{let P=new Uint8Array(c8(A,T));return T.write(A,P,0),P}})}function o8(T){return Object.freeze({...T,decode:(A,P=0)=>T.read(A,P)[0]})}function R6(T){return"fixedSize"in T&&typeof T.fixedSize==="number"}function wK(T){return!R6(T)}function UQ(T,A){return I0({fixedSize:A,write:(P,Q,C)=>{let W=T.encode(P),G=W.length>A?W.slice(0,A):W;return Q.set(G,C),C+A}})}function JQ(T,A){return I0({...wK(T)?{...T,getSizeFromValue:(P)=>T.getSizeFromValue(A(P))}:T,write:(P,Q,C)=>T.write(A(P),Q,C)})}function VJ(T,A,P,Q){if(Q<A||Q>P)throw new e(mA,{codecDescription:T,max:P,min:A,value:Q})}function EK(T){return T?.endian===1?!1:!0}function BK(T){return I0({fixedSize:T.size,write(A,P,Q){if(T.range)VJ(T.name,T.range[0],T.range[1],A);let C=new ArrayBuffer(T.size);return T.set(new DataView(C),A,EK(T.config)),P.set(new Uint8Array(C),Q),Q+T.size}})}var qJ=()=>I0({getSizeFromValue:(T)=>{if(T<=127)return 1;if(T<=16383)return 2;return 3},maxSize:3,write:(T,A,P)=>{VJ("shortU16",0,65535,T);let Q=[0];for(let C=0;;C+=1){let W=Number(T)>>C*7;if(W===0)break;let G=127&W;if(Q[C]=G,C>0)Q[C-1]|=128}return A.set(Q,P),P+Q.length}});var YJ=(T={})=>BK({config:T,name:"u32",range:[0,Number("0xffffffff")],set:(A,P,Q)=>A.setUint32(0,Number(P),Q),size:4});function hK(T,A,P){if(A!==P)throw new e(hA,{actual:P,codecDescription:T,expected:A})}function ZJ(T){return T.reduce((A,P)=>A===null||P===null?null:A+P,0)}function HJ(T){return R6(T)?T.fixedSize:null}function KJ(T){return R6(T)?T.fixedSize:T.maxSize??null}function RJ(T,A={}){let P=A.size??YJ(),Q=XJ(P,HJ(T)),C=XJ(P,KJ(T))??void 0;return I0({...Q!==null?{fixedSize:Q}:{getSizeFromValue:(W)=>{return(typeof P==="object"?c8(W.length,P):0)+[...W].reduce((J,$)=>J+c8($,T),0)},maxSize:C},write:(W,G,J)=>{if(typeof P==="number")hK("array",P,W.length);if(typeof P==="object")J=P.write(W.length,G,J);return W.forEach(($)=>{J=T.write($,G,J)}),J}})}function XJ(T,A){if(typeof T!=="number")return null;if(T===0)return 0;return A===null?null:A*T}function VQ(){return I0({getSizeFromValue:(T)=>T.length,write:(T,A,P)=>{return A.set(T,P),P+T.length}})}function kJ(T){let A=T.map(([,C])=>C),P=ZJ(A.map(HJ)),Q=ZJ(A.map(KJ))??void 0;return I0({...P===null?{getSizeFromValue:(C)=>T.map(([W,G])=>c8(C[W],G)).reduce((W,G)=>W+G,0),maxSize:Q}:{fixedSize:P},write:(C,W,G)=>{return T.forEach(([J,$])=>{G=$.write(C[J],W,G)}),G}})}var mK=(T)=>{return o8({read(A,P){let Q=P===0?A:A.slice(P);if(Q.length===0)return["",0];let C=Q.findIndex(($)=>$!==0);C=C===-1?Q.length:C;let W=T[0].repeat(C);if(C===Q.length)return[W,A.length];let G=Q.slice(C).reduce(($,X)=>$*256n+BigInt(X),0n),J=gK(G,T);return[W+J,A.length]}})};function gK(T,A){let P=BigInt(A.length),Q=[];while(T>0n)Q.unshift(A[Number(T%P)]),T/=P;return Q.join("")}var vK="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";var jJ=()=>mK(vK);var DJ=()=>{return o8({read(T,A=0){let P=T.slice(A);return[btoa(String.fromCharCode(...P)),T.length]}})};var{TextDecoder:T3,TextEncoder:A3}=globalThis;var FJ=Object.freeze({name:"Ed25519"});async function k6(T,A){zU();let P=await crypto.subtle.sign(FJ,T,A);return new Uint8Array(P)}async function MJ(){return await MU(),await crypto.subtle.generateKey(FJ,!1,["sign","verify"])}function yK(T){let A=Object.values(T);if(A.length===0)throw new e(OP);return A.map((P)=>{if(!P)return new Uint8Array(64).fill(0);return P})}function bK(){return JQ(RJ(UQ(VQ(),64),{size:qJ()}),yK)}function lK(){return kJ([["signatures",bK()],["messageBytes",VQ()]])}function zJ(T){let A=WJ(T),P=CJ().encode(A),Q=A.staticAccounts.slice(0,A.header.numSignerAccounts),C={};for(let G of Q)C[G]=null;let W;if(AJ(T))W={blockhash:T.lifetimeConstraint.blockhash,lastValidBlockHeight:T.lifetimeConstraint.lastValidBlockHeight};else if(UJ(T))W={nonce:T.lifetimeConstraint.nonce,nonceAccountAddress:T.instructions[0].accounts[0].address};return Object.freeze({...W?{lifetimeConstraint:W}:void 0,messageBytes:P,signatures:Object.freeze(C)})}var qQ;function j6(T){if(!qQ)qQ=jJ();let A=Object.values(T.signatures)[0];if(!A)throw new e(EP);return qQ.decode(A)}function pK(T,A){return T.length===A.length&&T.every((P,Q)=>P===A[Q])}async function IJ(T,A){let P,Q;if(await Promise.all(T.map(async(C)=>{let W=await G6(C.publicKey),G=A.signatures[W];if(G===void 0){Q||=new Set,Q.add(W);return}if(Q)return;let J=await k6(C.privateKey,A.messageBytes);if(G!==null&&pK(J,G))return;P||={},P[W]=J})),Q&&Q.size>0){let C=Object.keys(A.signatures);throw new e(BP,{expectedAddresses:C,unexpectedAddresses:[...Q]})}if(!P)return A;return Object.freeze({...A,signatures:Object.freeze({...A.signatures,...P})})}function SJ(T){let A=[];if(Object.entries(T.signatures).forEach(([P,Q])=>{if(!Q)A.push(P)}),A.length>0)throw new e(LP,{addresses:A})}function D6(T){let A=lK().encode(T);return DJ().decode(A)}var uK=1280,dK=48,M3=uK-dK;function NJ(T){return T!==null&&(typeof T==="object"||typeof T==="function")}function rK(T){let A=new Set,P={deferreds:A,settled:!1};return Promise.resolve(T).then((Q)=>{for(let{resolve:C}of A)C(Q);A.clear(),P.settled=!0},(Q)=>{for(let{reject:C}of A)C(Q);A.clear(),P.settled=!0}),P}var YQ=new WeakMap;async function ZQ(T){let A;return await new Promise((Q,C)=>{A={reject:C,resolve:Q};for(let W of T){if(!NJ(W)){Promise.resolve(W).then(Q,C);continue}let G=YQ.get(W);if(G===void 0)G=rK(W),G.deferreds.add(A),YQ.set(W,G);else if(G.settled)Promise.resolve(W).then(Q,C);else G.deferreds.add(A)}}).finally(()=>{for(let Q of T)if(NJ(Q))YQ.get(Q).deferreds.delete(A)})}function F6(T){let A={};return T.forEach((P)=>{if(!A[P.address])A[P.address]=P;else if(A[P.address]!==P)throw new e(zP,{address:P.address})}),Object.values(A)}function M6(T){return"modifyAndSignTransactions"in T&&typeof T.modifyAndSignTransactions==="function"}function n8(T){return"signTransactions"in T&&typeof T.signTransactions==="function"}function wJ(T){return"signAndSendTransactions"in T&&typeof T.signAndSendTransactions==="function"}function S0(T){return n8(T)||M6(T)||wJ(T)}function cK(T){return F6((T.accounts??[]).flatMap((A)=>("signer"in A)?A.signer:[]))}function oK(T){return F6([...T.feePayer&&S0(T.feePayer)?[T.feePayer]:[],...T.instructions.flatMap(cK)])}function nK(T,A){if(!A.accounts||A.accounts.length===0)return A;let P=new Map(F6(T).map((Q)=>[Q.address,Q]));return Object.freeze({...A,accounts:A.accounts.map((Q)=>{let C=P.get(Q.address);if(!d0(Q.role)||"signer"in Q||!C)return Q;return Object.freeze({...Q,signer:C})})})}function LJ(T,A){let P=fK(A)?T.find((Q)=>Q.address===A.feePayer.address):void 0;if(!P&&A.instructions.length===0)return A;return Object.freeze({...A,...P?{feePayer:P}:null,instructions:A.instructions.map((Q)=>nK(T,Q))})}function fK(T){return!!T&&"feePayer"in T&&!!T.feePayer&&typeof T.feePayer.address==="string"&&!S0(T.feePayer)}function EJ(T,A){Object.freeze(T);let P={...A,feePayer:T};return Object.freeze(P),P}async function iK(T){let A=await G6(T.publicKey);return Object.freeze({address:A,keyPair:T,signMessages:(Q)=>Promise.all(Q.map(async(C)=>Object.freeze({[A]:await k6(T.privateKey,C.content)}))),signTransactions:(Q)=>Promise.all(Q.map(async(C)=>{let W=await IJ([T],C);return Object.freeze({[A]:W.signatures[A]})}))})}async function BJ(){return await iK(await MJ())}async function aK(T,A){let{partialSigners:P,modifyingSigners:Q}=sK(F6(oK(T).filter(S0)),{identifySendingSigner:!1});return await TR(T,Q,P,A)}async function XQ(T,A){let P=await aK(T,A);return SJ(P),P}function sK(T,A={}){let Q=A.identifySendingSigner??!0?tK(T):null,C=T.filter((J)=>J!==Q&&(M6(J)||n8(J))),W=eK(C),G=C.filter(n8).filter((J)=>!W.includes(J));return Object.freeze({modifyingSigners:W,partialSigners:G,sendingSigner:Q})}function tK(T){let A=T.filter(wJ);if(A.length===0)return null;let P=A.filter((Q)=>!M6(Q)&&!n8(Q));if(P.length>0)return P[0];return A[0]}function eK(T){let A=T.filter(M6);if(A.length===0)return[];let P=A.filter((Q)=>!n8(Q));if(P.length>0)return P;return[A[0]]}async function TR(T,A=[],P=[],Q){let C=zJ(T),W=await A.reduce(async(J,$)=>{Q?.abortSignal?.throwIfAborted();let[X]=await $.modifyAndSignTransactions([await J],Q);return Object.freeze(X)},Promise.resolve(C));Q?.abortSignal?.throwIfAborted();let G=await Promise.all(P.map(async(J)=>{let[$]=await J.signTransactions([W],Q);return $}));return Object.freeze({...W,signatures:Object.freeze(G.reduce((J,$)=>{return{...J,...$}},W.signatures??{}))})}var x3=globalThis.TextEncoder;var HQ=globalThis.AbortController;function OJ({rpc:T,rpcSubscriptions:A}){return async function({abortSignal:Q,commitment:C,lastValidBlockHeight:W}){Q.throwIfAborted();let G=new HQ,J=()=>{G.abort()};Q.addEventListener("abort",J,{signal:G.signal});async function $(){let{absoluteSlot:X,blockHeight:Z}=await T.getEpochInfo({commitment:C}).send({abortSignal:G.signal});return{blockHeight:Z,differenceBetweenSlotHeightAndBlockHeight:X-Z}}try{let[X,{blockHeight:Z,differenceBetweenSlotHeightAndBlockHeight:R}]=await Promise.all([A.slotNotifications().subscribe({abortSignal:G.signal}),$()]);Q.throwIfAborted();let D=Z;if(D<=W){let z=R;for await(let S of X){let{slot:E}=S;if(E-z>W){let{blockHeight:w,differenceBetweenSlotHeightAndBlockHeight:O}=await $();if(D=w,D>W)break;else z=O}}}throw Q.throwIfAborted(),new e(VP,{currentBlockHeight:D,lastValidBlockHeight:W})}finally{G.abort()}}}function xJ({rpc:T,rpcSubscriptions:A}){return async function({abortSignal:Q,commitment:C,signature:W}){let G=new HQ;function J(){G.abort()}Q.addEventListener("abort",J,{signal:G.signal});let $=await A.signatureNotifications(W,{commitment:C}).subscribe({abortSignal:G.signal}),X=(async()=>{for await(let R of $)if(R.value.err)throw t2(R.value.err);else return})(),Z=(async()=>{let{value:R}=await T.getSignatureStatuses([W]).send({abortSignal:G.signal}),D=R[0];if(D?.confirmationStatus&&H6(D.confirmationStatus,C)>=0)return;else if(D?.err)throw t2(D.err);else await new Promise(()=>{})})();try{return await ZQ([X,Z])}finally{G.abort()}}}async function AR(T,A,P){let{abortSignal:Q,commitment:C,getRecentSignatureConfirmationPromise:W}=A;Q?.throwIfAborted();let G=new HQ;if(Q){let J=()=>{G.abort()};Q.addEventListener("abort",J,{signal:G.signal})}try{let J=P({...A,abortSignal:G.signal});return await ZQ([W({abortSignal:G.signal,commitment:C,signature:T}),...J])}finally{G.abort()}}async function _J(T){await AR(j6(T.transaction),T,function({abortSignal:P,commitment:Q,getBlockHeightExceedencePromise:C,transaction:W}){return[C({abortSignal:P,commitment:Q,lastValidBlockHeight:W.lifetimeConstraint.lastValidBlockHeight})]})}function PR(T,A){if(!A?.preflightCommitment&&H6(T,"finalized")<0)return{...A,preflightCommitment:T};return A}async function QR({abortSignal:T,commitment:A,rpc:P,transaction:Q,...C}){let W=D6(Q);return await P.sendTransaction(W,{...PR(A,C),encoding:"base64"}).send({abortSignal:T})}async function CR({abortSignal:T,commitment:A,confirmRecentTransaction:P,rpc:Q,transaction:C,...W}){let G=await QR({...W,abortSignal:T,commitment:A,rpc:Q,transaction:C});return await P({abortSignal:T,commitment:A,transaction:C}),G}function hJ({rpc:T,rpcSubscriptions:A}){let P=OJ({rpc:T,rpcSubscriptions:A}),Q=xJ({rpc:T,rpcSubscriptions:A});async function C(W){await _J({...W,getBlockHeightExceedencePromise:P,getRecentSignatureConfirmationPromise:Q})}return async function(G,J){await CR({...J,confirmRecentTransaction:C,rpc:T,transaction:G})}}var dT="6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P",N0="pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA",f8="11111111111111111111111111111111",FT="TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",i8="TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb",KQ="ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";var K8="pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ";var RQ=HT(),mJ=KQ;async function MT({owner:T,mint:A,tokenProgram:P=FT,associatedTokenProgram:Q=mJ}){return await j1({programAddress:b(Q),seeds:[RQ.encode(b(T)),RQ.encode(b(P)),RQ.encode(b(A))]})}async function gJ(T){return await MT({...T,tokenProgram:T.tokenProgram??i8,associatedTokenProgram:T.associatedTokenProgram??mJ})}var yA=new TextEncoder,z6=HT();async function I6(){let[T]=await j1({programAddress:b(dT),seeds:[yA.encode("global")]});return T}async function r0(T){let[A]=await j1({programAddress:b(dT),seeds:[yA.encode("bonding-curve"),z6.encode(b(T))]});return A}async function S6(T,A){let[P]=await MT({owner:b(T),mint:b(A),tokenProgram:b(FT)});return P}async function kQ(T){let[A]=await j1({programAddress:b(dT),seeds:[yA.encode("creator-vault"),z6.encode(b(T))]});return A}async function vJ(){let[T]=await j1({programAddress:b(dT),seeds:[yA.encode("global_volume_accumulator")]});return T}async function yJ(T){let[A]=await j1({programAddress:b(dT),seeds:[yA.encode("user_volume_accumulator"),z6.encode(b(T))]});return A}async function N6(){let[T]=await j1({programAddress:b(dT),seeds:[yA.encode("__event_authority")]});return T}async function c0(){let[T]=await j1({programAddress:b(K8),seeds:[yA.encode("fee_config"),z6.encode(b(dT))]});return T}var D1="6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P";function OT(T){if(!T)throw Error("Expected a Address.");if(typeof T==="object"&&"address"in T)return T.address;if(Array.isArray(T))return T[0];return T}function F1(T,A){return(P)=>{if(!P.value){if(A==="omitted")return;return Object.freeze({address:T,role:X1.READONLY})}let Q=P.isWritable?X1.WRITABLE:X1.READONLY;return Object.freeze({address:OT(P.value),role:bJ(P.value)?X6(Q):Q,...bJ(P.value)?{signer:P.value}:{}})}}function bJ(T){return!!T&&typeof T==="object"&&"address"in T&&S0(T)}var Iw=new Uint8Array([69,25,171,142,57,239,13,4]);var Lw=new Uint8Array([8,217,96,231,144,104,192,5]);var xw=new Uint8Array([209,11,115,87,213,23,124,204]);function w6(){return aT([["lpFeeBps",pT()],["protocolFeeBps",pT()],["creatorFeeBps",pT()]])}function lJ(){return aT([["marketCapLamportsThreshold",BU()],["fees",w6()]])}function jQ(){return _U([tP()])}var JR=new Uint8Array([102,6,61,18,1,218,235,234]);function $R(){return lT(uT([["discriminator",iT(W0(),8)],["amount",DT()],["maxSolCost",DT()],["trackVolume",jQ()]]),(T)=>({...T,discriminator:JR}))}function pJ(T,A){let P=A?.programAddress??D1,C={global:{value:T.global??null,isWritable:!1},feeRecipient:{value:T.feeRecipient??null,isWritable:!0},mint:{value:T.mint??null,isWritable:!1},bondingCurve:{value:T.bondingCurve??null,isWritable:!0},associatedBondingCurve:{value:T.associatedBondingCurve??null,isWritable:!0},associatedUser:{value:T.associatedUser??null,isWritable:!0},user:{value:T.user??null,isWritable:!0},systemProgram:{value:T.systemProgram??null,isWritable:!1},tokenProgram:{value:T.tokenProgram??null,isWritable:!1},creatorVault:{value:T.creatorVault??null,isWritable:!0},eventAuthority:{value:T.eventAuthority??null,isWritable:!1},program:{value:T.program??null,isWritable:!1},globalVolumeAccumulator:{value:T.globalVolumeAccumulator??null,isWritable:!0},userVolumeAccumulator:{value:T.userVolumeAccumulator??null,isWritable:!0},feeConfig:{value:T.feeConfig??null,isWritable:!1},feeProgram:{value:T.feeProgram??null,isWritable:!1}},W={...T};if(!C.systemProgram.value)C.systemProgram.value="11111111111111111111111111111111";if(!C.tokenProgram.value)C.tokenProgram.value="TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";if(!C.program.value)C.program.value="6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P";if(!C.feeProgram.value)C.feeProgram.value="pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ";let G=F1(P,"programId");return Object.freeze({accounts:[G(C.global),G(C.feeRecipient),G(C.mint),G(C.bondingCurve),G(C.associatedBondingCurve),G(C.associatedUser),G(C.user),G(C.systemProgram),G(C.tokenProgram),G(C.creatorVault),G(C.eventAuthority),G(C.program),G(C.globalVolumeAccumulator),G(C.userVolumeAccumulator),G(C.feeConfig),G(C.feeProgram)],data:$R().encode(W),programAddress:P})}var mL=new Uint8Array([56,252,116,8,158,223,205,95]);var bL=new Uint8Array([16,4,71,28,204,1,40,27]);var dL=new Uint8Array([249,69,164,218,150,103,84,138]);var nL=new Uint8Array([20,22,86,123,198,28,219,132]);var VR=new Uint8Array([24,30,200,40,5,28,7,119]);function qR(){return lT(uT([["discriminator",iT(W0(),8)],["name",J6(Z6(),r8())],["symbol",J6(Z6(),r8())],["uri",J6(Z6(),r8())],["creator",HT()]]),(T)=>({...T,discriminator:VR}))}function uJ(T,A){let P=A?.programAddress??D1,C={mint:{value:T.mint??null,isWritable:!0},mintAuthority:{value:T.mintAuthority??null,isWritable:!1},bondingCurve:{value:T.bondingCurve??null,isWritable:!0},associatedBondingCurve:{value:T.associatedBondingCurve??null,isWritable:!0},global:{value:T.global??null,isWritable:!1},mplTokenMetadata:{value:T.mplTokenMetadata??null,isWritable:!1},metadata:{value:T.metadata??null,isWritable:!0},user:{value:T.user??null,isWritable:!0},systemProgram:{value:T.systemProgram??null,isWritable:!1},tokenProgram:{value:T.tokenProgram??null,isWritable:!1},associatedTokenProgram:{value:T.associatedTokenProgram??null,isWritable:!1},rent:{value:T.rent??null,isWritable:!1},eventAuthority:{value:T.eventAuthority??null,isWritable:!1},program:{value:T.program??null,isWritable:!1}},W={...T};if(!C.mplTokenMetadata.value)C.mplTokenMetadata.value="metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s";if(!C.systemProgram.value)C.systemProgram.value="11111111111111111111111111111111";if(!C.tokenProgram.value)C.tokenProgram.value="TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";if(!C.associatedTokenProgram.value)C.associatedTokenProgram.value="ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";if(!C.rent.value)C.rent.value="SysvarRent111111111111111111111111111111111";let G=F1(P,"programId");return Object.freeze({accounts:[G(C.mint),G(C.mintAuthority),G(C.bondingCurve),G(C.associatedBondingCurve),G(C.global),G(C.mplTokenMetadata),G(C.metadata),G(C.user),G(C.systemProgram),G(C.tokenProgram),G(C.associatedTokenProgram),G(C.rent),G(C.eventAuthority),G(C.program)],data:qR().encode(W),programAddress:P})}var QE=new Uint8Array([234,102,194,203,150,72,62,229]);var UE=new Uint8Array([175,175,109,31,13,152,155,237]);var qE=new Uint8Array([94,6,202,115,255,96,232,183]);var HE=new Uint8Array([155,234,231,146,236,158,162,30]);var YR=new Uint8Array([51,230,133,164,1,127,131,173]);function ZR(){return lT(uT([["discriminator",iT(W0(),8)],["amount",DT()],["minSolOutput",DT()]]),(T)=>({...T,discriminator:YR}))}function dJ(T,A){let P=A?.programAddress??D1,C={global:{value:T.global??null,isWritable:!1},feeRecipient:{value:T.feeRecipient??null,isWritable:!0},mint:{value:T.mint??null,isWritable:!1},bondingCurve:{value:T.bondingCurve??null,isWritable:!0},associatedBondingCurve:{value:T.associatedBondingCurve??null,isWritable:!0},associatedUser:{value:T.associatedUser??null,isWritable:!0},user:{value:T.user??null,isWritable:!0},systemProgram:{value:T.systemProgram??null,isWritable:!1},creatorVault:{value:T.creatorVault??null,isWritable:!0},tokenProgram:{value:T.tokenProgram??null,isWritable:!1},eventAuthority:{value:T.eventAuthority??null,isWritable:!1},program:{value:T.program??null,isWritable:!1},feeConfig:{value:T.feeConfig??null,isWritable:!1},feeProgram:{value:T.feeProgram??null,isWritable:!1}},W={...T};if(!C.systemProgram.value)C.systemProgram.value="11111111111111111111111111111111";if(!C.tokenProgram.value)C.tokenProgram.value="TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";if(!C.program.value)C.program.value="6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P";if(!C.feeProgram.value)C.feeProgram.value="pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ";let G=F1(P,"programId");return Object.freeze({accounts:[G(C.global),G(C.feeRecipient),G(C.mint),G(C.bondingCurve),G(C.associatedBondingCurve),G(C.associatedUser),G(C.user),G(C.systemProgram),G(C.creatorVault),G(C.tokenProgram),G(C.eventAuthority),G(C.program),G(C.feeConfig),G(C.feeProgram)],data:ZR().encode(W),programAddress:P})}var zE=new Uint8Array([254,148,255,112,207,142,170,165]);var wE=new Uint8Array([138,96,174,217,48,85,197,246]);var OE=new Uint8Array([27,234,178,52,147,2,187,141]);var mE=new Uint8Array([86,31,192,87,163,87,79,238]);var bE=new Uint8Array([227,181,74,196,208,21,97,213]);var JB=new Uint8Array([23,183,248,55,96,216,172,96]);function KR(){return aT([["discriminator",M0(u0(),8)],["virtualTokenReserves",pT()],["virtualSolReserves",pT()],["realTokenReserves",pT()],["realSolReserves",pT()],["tokenTotalSupply",pT()],["complete",eP()],["creator",F0()]])}function RR(T){return e2(T,KR())}async function bA(T,A,P){let Q=await kR(T,A,P);return A6(Q),Q}async function kR(T,A,P){let Q=await T6(T,A,P);return RR(Q)}var rJ="confirmed";function jR(T){rJ=T}function JT(){return rJ}async function a8(T){let{user:A,mint:P,tokenAmount:Q,maxSolCostLamports:C,feeRecipient:W,trackVolume:G=!0,bondingCurveCreator:J,rpc:$,commitment:X=JT()}=T,Z=b(P),R=A.address,D=await r0(Z),z=c0(),S=I6(),E=N6(),w=vJ(),O=yJ(R),m=S6(D,Z),g=MT({owner:R,mint:Z,tokenProgram:b(FT)}),p=await oJ({bondingCurve:D,providedCreator:J,rpc:$,commitment:X}),[c,o,[f],d,_,t,i,x]=await Promise.all([S,m,g,kQ(p),E,w,O,z]);return pJ({global:c,feeRecipient:b(W),mint:Z,bondingCurve:D,associatedBondingCurve:o,associatedUser:f,user:A,systemProgram:b(f8),tokenProgram:b(FT),creatorVault:d,eventAuthority:_,program:b(dT),globalVolumeAccumulator:t,userVolumeAccumulator:i,feeConfig:x,feeProgram:b(K8),amount:Q,maxSolCost:C,trackVolume:[G]})}async function DQ(T){let{user:A,mint:P,tokenAmount:Q,minSolOutputLamports:C,feeRecipient:W,bondingCurveCreator:G,rpc:J,commitment:$=JT()}=T,X=b(P),Z=A.address,R=await r0(X),D=I6(),z=S6(R,X),S=MT({owner:Z,mint:X,tokenProgram:b(FT)}),E=c0(),w=N6(),O=await oJ({bondingCurve:R,providedCreator:G,rpc:J,commitment:$}),[m,g,[p],c,o,f]=await Promise.all([D,z,S,kQ(O),w,E]);return dJ({global:m,feeRecipient:b(W),mint:X,bondingCurve:R,associatedBondingCurve:g,associatedUser:p,user:A,systemProgram:b(f8),creatorVault:c,tokenProgram:b(FT),eventAuthority:o,program:b(dT),feeConfig:f,feeProgram:b(K8),amount:Q,minSolOutput:C})}async function cJ(T){let{user:A,mint:P,mintAuthority:Q,name:C,symbol:W,uri:G,creator:J}=T,$=P.address,X=J?b(J):A.address,Z=await I6(),R=await r0($),D=await S6(R,$),[z]=await j1({programAddress:b("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),seeds:[new TextEncoder().encode("metadata"),b("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),$]}),S=await N6();return uJ({mint:P,mintAuthority:b(Q),bondingCurve:R,associatedBondingCurve:D,global:Z,mplTokenMetadata:b("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),metadata:z,user:A,systemProgram:b(f8),tokenProgram:b(FT),associatedTokenProgram:b("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"),rent:b("SysvarRent111111111111111111111111111111111"),eventAuthority:S,program:b(dT),name:C,symbol:W,uri:G,creator:X})}async function oJ(T){let{bondingCurve:A,providedCreator:P,rpc:Q,commitment:C}=T;if(P)return b(P);try{return(await bA(Q,A,{commitment:C})).data.creator}catch(W){throw Error("Unable to resolve bonding curve creator. Provide `bondingCurveCreator` or configure an RPC endpoint with access to the bonding curve account.",{cause:W})}}var w0="CebN5WGQ4jvEPvsVU4EoHEpgzq1VV7AbicfhtW4xC9iM";var L0=50,s8=(T,A=50)=>T+T*BigInt(A)/10000n,t8=(T,A=50)=>T-T*BigInt(A)/10000n;function E0(T){if(T<0)throw Error("Slippage cannot be negative");if(T>1e4)throw Error("Slippage cannot exceed 100%")}function DR(T){if(T<0||T>100)throw Error("Percent must be between 0 and 100");return Math.round(T*100)}function FR(T){return T/100}var MR=1000000000n;function XA(T){if(!Number.isFinite(T)||T<0)throw Error("SOL value must be a non-negative finite number");return BigInt(Math.round(T*Number(MR)))}function e8(T,A){if(!Number.isInteger(A)||A<0)throw Error("Token decimals must be a non-negative integer");let P=BigInt(10)**BigInt(A);return BigInt(Math.round(T*10**A))}async function zR(T){let{user:A,mint:P,tokenAmount:Q,estimatedSolCostSol:C,slippageBps:W=L0,feeRecipient:G=w0,bondingCurveCreator:J,trackVolume:$=!0,rpc:X,commitment:Z=JT()}=T;if(E0(W),Q<=0n)throw Error("Token amount must be positive");if(!Number.isFinite(C)||C<=0)throw Error("Estimated SOL cost must be a positive number");let R=XA(C),D=s8(R,W);return await a8({user:A,mint:P,tokenAmount:Q,maxSolCostLamports:D,feeRecipient:G,trackVolume:$,bondingCurveCreator:J,rpc:X,commitment:Z})}async function FQ(T){let{user:A,mint:P,tokenAmount:Q,maxSolCostSol:C,maxSolCostLamports:W,feeRecipient:G=w0,trackVolume:J=!0,bondingCurveCreator:$,rpc:X,commitment:Z=JT()}=T;if(Q<=0n)throw Error("Token amount must be positive");let R=null;if(W!==void 0){if(W<=0n)throw Error("Max SOL cost lamports must be positive");R=W}else if(C!==void 0){if(!Number.isFinite(C)||C<=0)throw Error("Max SOL cost must be a positive number");R=XA(C)}if(R===null)throw Error("Provide either maxSolCostLamports or maxSolCostSol when calling buySimple");return await a8({user:A,mint:P,tokenAmount:Q,maxSolCostLamports:R,feeRecipient:G,trackVolume:J,bondingCurveCreator:$,rpc:X,commitment:Z})}var nJ=6;async function IR(T){let{user:A,mint:P,tokenAmount:Q,estimatedSolOutSol:C,slippageBps:W=L0,feeRecipient:G=w0,bondingCurveCreator:J,rpc:$,commitment:X}=T;if(E0(W),!Number.isFinite(Q)||Q<=0)throw Error("Token amount must be a positive number");if(!Number.isFinite(C)||C<0)throw Error("Estimated SOL output cannot be negative");let Z=e8(Q,nJ),R=XA(C),D=t8(R,W);return await DQ({user:A,mint:P,tokenAmount:Z,minSolOutputLamports:D,feeRecipient:G,bondingCurveCreator:J,rpc:$,commitment:X})}async function MQ(T){let{user:A,mint:P,tokenAmount:Q,tokenAmountRaw:C,minSolOutputSol:W,minSolOutputLamports:G,feeRecipient:J=w0,bondingCurveCreator:$,rpc:X,commitment:Z}=T,R=null;if(C!==void 0){if(C<=0n)throw Error("Token amount lamports must be positive");R=C}else if(Q!==void 0){if(!Number.isFinite(Q)||Q<=0)throw Error("Token amount must be a positive number");R=e8(Q,nJ)}if(R===null)throw Error("Provide either tokenAmountRaw or tokenAmount when calling sellSimple");let D=null;if(G!==void 0){if(G<0n)throw Error("Min SOL output lamports cannot be negative");D=G}else if(W!==void 0){if(!Number.isFinite(W)||W<0)throw Error("Min SOL output cannot be negative");D=XA(W)}if(D===null)throw Error("Provide either minSolOutputLamports or minSolOutputSol when calling sellSimple");return await DQ({user:A,mint:P,tokenAmount:R,minSolOutputLamports:D,feeRecipient:J,bondingCurveCreator:$,rpc:X,commitment:Z})}var yB=new Uint8Array([143,52,146,187,219,123,76,155]);function SR(){return aT([["discriminator",M0(u0(),8)],["bump",V6()],["admin",F0()],["flatFees",w6()],["feeTiers",xU(lJ())]])}function NR(T){return e2(T,SR())}async function T2(T,A,P){let Q=await wR(T,A,P);return A6(Q),Q}async function wR(T,A,P){let Q=await T6(T,A,P);return NR(Q)}var o0=10000n,R8=(T,A,P)=>{if(P<=0n)throw Error("Division by zero (floor)");return T*A/P},LR=(T,A,P)=>{if(P<=0n)throw Error("Division by zero (ceil)");let Q=T*A,C=Q/P;return Q%P===0n?C:C+1n},zQ=(T)=>{let A=BigInt(T.lpFeeBps),P=BigInt(T.protocolFeeBps),Q=BigInt(T.creatorFeeBps),C=A+P,W=C+Q;if(W>=o0)throw Error("Total fee basis points must be less than 10_000");return{totalFeeBps:W,combinedFeeBps:C}},IQ=(T)=>{let A=T.virtualTokenReserves+T.realTokenReserves,P=T.virtualSolReserves+T.realSolReserves;return A*P};function fJ(T,A,P){if(P<=0n)throw Error("Total SOL cost must be positive");let{combinedFeeBps:Q,totalFeeBps:C}=zQ(A),W=R8(P,Q,o0),G=R8(P,BigInt(A.creatorFeeBps),o0),J=P-W-G;if(J<=0n)throw Error("Net SOL after fees must be positive");let $=IQ(T),X=T.virtualSolReserves+T.realSolReserves,Z=T.virtualTokenReserves+T.realTokenReserves,R=X+J,D=$/R,z=Z-D,S=z>T.realTokenReserves?T.realTokenReserves:z;if(S<=0n)throw Error("SOL amount is too small to purchase any tokens");let E=L6(T,A,S);while(E.totalSolCostLamports>P&&S>0n)S-=1n,E=L6(T,A,S);if(E.totalSolCostLamports>P)throw Error("Insufficient SOL to purchase any tokens with fees applied");return{tokenAmount:S,totalSolCostLamports:E.totalSolCostLamports,effectiveSolInLamports:E.effectiveSolInLamports,feeLamports:E.feeLamports,creatorFeeLamports:E.creatorFeeLamports}}function L6(T,A,P){if(P<=0n)throw Error("Token amount must be positive");if(P>T.realTokenReserves)throw Error("Token amount exceeds available reserves");let{combinedFeeBps:Q,totalFeeBps:C}=zQ(A),W=IQ(T),G=T.virtualSolReserves+T.realSolReserves,$=T.virtualTokenReserves+T.realTokenReserves-P;if($<=0n)throw Error("Purchase would exhaust token reserves");let Z=W/$-G;if(Z<=0n)throw Error("Resolved SOL input must be positive");let R=o0-C,D=LR(Z,o0,R),z=R8(D,Q,o0),S=R8(D,BigInt(A.creatorFeeBps),o0);return{tokenAmount:P,totalSolCostLamports:D,effectiveSolInLamports:Z,feeLamports:z,creatorFeeLamports:S}}function iJ(T,A,P){if(P<=0n)throw Error("Token amount must be positive");let Q=IQ(T),C=T.virtualSolReserves+T.realSolReserves,G=T.virtualTokenReserves+T.realTokenReserves+P,J=Q/G,$=C-J;if($<=0n)throw Error("No SOL output available for the given token amount");let{combinedFeeBps:X}=zQ(A),Z=R8($,X,o0),R=R8($,BigInt(A.creatorFeeBps),o0),D=$-Z-R;if(D<=0n)throw Error("SOL output after fees is non-positive");return{solOutputLamports:D,preFeeSolOutputLamports:$,feeLamports:Z,creatorFeeLamports:R}}j8();var uA=typeof globalThis==="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function i0(T){return T instanceof Uint8Array||ArrayBuffer.isView(T)&&T.constructor.name==="Uint8Array"}function KA(T){if(!Number.isSafeInteger(T)||T<0)throw Error("positive integer expected, got "+T)}function KT(T,...A){if(!i0(T))throw Error("Uint8Array expected");if(A.length>0&&!A.includes(T.length))throw Error("Uint8Array expected of length "+A+", got length="+T.length)}function x6(T){if(typeof T!=="function"||typeof T.create!=="function")throw Error("Hash should be wrapped by utils.createHasher");KA(T.outputLen),KA(T.blockLen)}function a0(T,A=!0){if(T.destroyed)throw Error("Hash instance has been destroyed");if(A&&T.finished)throw Error("Hash#digest() has already been called")}function _6(T,A){KT(T);let P=A.outputLen;if(T.length<P)throw Error("digestInto() expects output buffer of length at least "+P)}function k$(T){return new Uint32Array(T.buffer,T.byteOffset,Math.floor(T.byteLength/4))}function U0(...T){for(let A=0;A<T.length;A++)T[A].fill(0)}function h6(T){return new DataView(T.buffer,T.byteOffset,T.byteLength)}function q0(T,A){return T<<32-A|T>>>A}var Hk=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function Kk(T){return T<<24&4278190080|T<<8&16711680|T>>>8&65280|T>>>24&255}function Rk(T){for(let A=0;A<T.length;A++)T[A]=Kk(T[A]);return T}var hQ=Hk?(T)=>T:Rk,j$=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),kk=Array.from({length:256},(T,A)=>A.toString(16).padStart(2,"0"));function J0(T){if(KT(T),j$)return T.toHex();let A="";for(let P=0;P<T.length;P++)A+=kk[T[P]];return A}var f0={_0:48,_9:57,A:65,F:70,a:97,f:102};function R$(T){if(T>=f0._0&&T<=f0._9)return T-f0._0;if(T>=f0.A&&T<=f0.F)return T-(f0.A-10);if(T>=f0.a&&T<=f0.f)return T-(f0.a-10);return}function dA(T){if(typeof T!=="string")throw Error("hex string expected, got "+typeof T);if(j$)return Uint8Array.fromHex(T);let A=T.length,P=A/2;if(A%2)throw Error("hex string expected, got unpadded hex of length "+A);let Q=new Uint8Array(P);for(let C=0,W=0;C<P;C++,W+=2){let G=R$(T.charCodeAt(W)),J=R$(T.charCodeAt(W+1));if(G===void 0||J===void 0){let $=T[W]+T[W+1];throw Error('hex string expected, got non-hex character "'+$+'" at index '+W)}Q[C]=G*16+J}return Q}function mQ(T){if(typeof T!=="string")throw Error("string expected");return new Uint8Array(new TextEncoder().encode(T))}function rA(T){if(typeof T==="string")T=mQ(T);return KT(T),T}function xT(...T){let A=0;for(let Q=0;Q<T.length;Q++){let C=T[Q];KT(C),A+=C.length}let P=new Uint8Array(A);for(let Q=0,C=0;Q<T.length;Q++){let W=T[Q];P.set(W,C),C+=W.length}return P}class cA{}function Q2(T){let A=(Q)=>T().update(rA(Q)).digest(),P=T();return A.outputLen=P.outputLen,A.blockLen=P.blockLen,A.create=()=>T(),A}function D8(T=32){if(uA&&typeof uA.getRandomValues==="function")return uA.getRandomValues(new Uint8Array(T));if(uA&&typeof uA.randomBytes==="function")return Uint8Array.from(uA.randomBytes(T));throw Error("crypto.getRandomValues must be defined")}function jk(T,A,P,Q){if(typeof T.setBigUint64==="function")return T.setBigUint64(A,P,Q);let C=BigInt(32),W=BigInt(4294967295),G=Number(P>>C&W),J=Number(P&W),$=Q?4:0,X=Q?0:4;T.setUint32(A+$,G,Q),T.setUint32(A+X,J,Q)}function D$(T,A,P){return T&A^~T&P}function F$(T,A,P){return T&A^T&P^A&P}class m6 extends cA{constructor(T,A,P,Q){super();this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=T,this.outputLen=A,this.padOffset=P,this.isLE=Q,this.buffer=new Uint8Array(T),this.view=h6(this.buffer)}update(T){a0(this),T=rA(T),KT(T);let{view:A,buffer:P,blockLen:Q}=this,C=T.length;for(let W=0;W<C;){let G=Math.min(Q-this.pos,C-W);if(G===Q){let J=h6(T);for(;Q<=C-W;W+=Q)this.process(J,W);continue}if(P.set(T.subarray(W,W+G),this.pos),this.pos+=G,W+=G,this.pos===Q)this.process(A,0),this.pos=0}return this.length+=T.length,this.roundClean(),this}digestInto(T){a0(this),_6(T,this),this.finished=!0;let{buffer:A,view:P,blockLen:Q,isLE:C}=this,{pos:W}=this;if(A[W++]=128,U0(this.buffer.subarray(W)),this.padOffset>Q-W)this.process(P,0),W=0;for(let Z=W;Z<Q;Z++)A[Z]=0;jk(P,Q-8,BigInt(this.length*8),C),this.process(P,0);let G=h6(T),J=this.outputLen;if(J%4)throw Error("_sha2: outputLen should be aligned to 32bit");let $=J/4,X=this.get();if($>X.length)throw Error("_sha2: outputLen bigger than state");for(let Z=0;Z<$;Z++)G.setUint32(4*Z,X[Z],C)}digest(){let{buffer:T,outputLen:A}=this;this.digestInto(T);let P=T.slice(0,A);return this.destroy(),P}_cloneInto(T){T||(T=new this.constructor),T.set(...this.get());let{blockLen:A,buffer:P,length:Q,finished:C,destroyed:W,pos:G}=this;if(T.destroyed=W,T.finished=C,T.length=Q,T.pos=G,Q%A)T.buffer.set(P);return T}clone(){return this._cloneInto()}}var s0=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var RT=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var g6=BigInt(4294967295),M$=BigInt(32);function Dk(T,A=!1){if(A)return{h:Number(T&g6),l:Number(T>>M$&g6)};return{h:Number(T>>M$&g6)|0,l:Number(T&g6)|0}}function v6(T,A=!1){let P=T.length,Q=new Uint32Array(P),C=new Uint32Array(P);for(let W=0;W<P;W++){let{h:G,l:J}=Dk(T[W],A);[Q[W],C[W]]=[G,J]}return[Q,C]}var gQ=(T,A,P)=>T>>>P,vQ=(T,A,P)=>T<<32-P|A>>>P,oA=(T,A,P)=>T>>>P|A<<32-P,nA=(T,A,P)=>T<<32-P|A>>>P,C2=(T,A,P)=>T<<64-P|A>>>P-32,W2=(T,A,P)=>T>>>P-32|A<<64-P;var z$=(T,A,P)=>T<<P|A>>>32-P,I$=(T,A,P)=>A<<P|T>>>32-P,S$=(T,A,P)=>A<<P-32|T>>>64-P,N$=(T,A,P)=>T<<P-32|A>>>64-P;function x0(T,A,P,Q){let C=(A>>>0)+(Q>>>0);return{h:T+P+(C/4294967296|0)|0,l:C|0}}var w$=(T,A,P)=>(T>>>0)+(A>>>0)+(P>>>0),L$=(T,A,P,Q)=>A+P+Q+(T/4294967296|0)|0,E$=(T,A,P,Q)=>(T>>>0)+(A>>>0)+(P>>>0)+(Q>>>0),B$=(T,A,P,Q,C)=>A+P+Q+C+(T/4294967296|0)|0,O$=(T,A,P,Q,C)=>(T>>>0)+(A>>>0)+(P>>>0)+(Q>>>0)+(C>>>0),x$=(T,A,P,Q,C,W)=>A+P+Q+C+W+(T/4294967296|0)|0;var Mk=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),RA=new Uint32Array(64);class yQ extends m6{constructor(T=32){super(64,T,8,!1);this.A=s0[0]|0,this.B=s0[1]|0,this.C=s0[2]|0,this.D=s0[3]|0,this.E=s0[4]|0,this.F=s0[5]|0,this.G=s0[6]|0,this.H=s0[7]|0}get(){let{A:T,B:A,C:P,D:Q,E:C,F:W,G,H:J}=this;return[T,A,P,Q,C,W,G,J]}set(T,A,P,Q,C,W,G,J){this.A=T|0,this.B=A|0,this.C=P|0,this.D=Q|0,this.E=C|0,this.F=W|0,this.G=G|0,this.H=J|0}process(T,A){for(let Z=0;Z<16;Z++,A+=4)RA[Z]=T.getUint32(A,!1);for(let Z=16;Z<64;Z++){let R=RA[Z-15],D=RA[Z-2],z=q0(R,7)^q0(R,18)^R>>>3,S=q0(D,17)^q0(D,19)^D>>>10;RA[Z]=S+RA[Z-7]+z+RA[Z-16]|0}let{A:P,B:Q,C,D:W,E:G,F:J,G:$,H:X}=this;for(let Z=0;Z<64;Z++){let R=q0(G,6)^q0(G,11)^q0(G,25),D=X+R+D$(G,J,$)+Mk[Z]+RA[Z]|0,S=(q0(P,2)^q0(P,13)^q0(P,22))+F$(P,Q,C)|0;X=$,$=J,J=G,G=W+D|0,W=C,C=Q,Q=P,P=D+S|0}P=P+this.A|0,Q=Q+this.B|0,C=C+this.C|0,W=W+this.D|0,G=G+this.E|0,J=J+this.F|0,$=$+this.G|0,X=X+this.H|0,this.set(P,Q,C,W,G,J,$,X)}roundClean(){U0(RA)}destroy(){this.set(0,0,0,0,0,0,0,0),U0(this.buffer)}}var _$=(()=>v6(["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((T)=>BigInt(T))))(),zk=(()=>_$[0])(),Ik=(()=>_$[1])(),kA=new Uint32Array(80),jA=new Uint32Array(80);class h$ extends m6{constructor(T=64){super(128,T,16,!1);this.Ah=RT[0]|0,this.Al=RT[1]|0,this.Bh=RT[2]|0,this.Bl=RT[3]|0,this.Ch=RT[4]|0,this.Cl=RT[5]|0,this.Dh=RT[6]|0,this.Dl=RT[7]|0,this.Eh=RT[8]|0,this.El=RT[9]|0,this.Fh=RT[10]|0,this.Fl=RT[11]|0,this.Gh=RT[12]|0,this.Gl=RT[13]|0,this.Hh=RT[14]|0,this.Hl=RT[15]|0}get(){let{Ah:T,Al:A,Bh:P,Bl:Q,Ch:C,Cl:W,Dh:G,Dl:J,Eh:$,El:X,Fh:Z,Fl:R,Gh:D,Gl:z,Hh:S,Hl:E}=this;return[T,A,P,Q,C,W,G,J,$,X,Z,R,D,z,S,E]}set(T,A,P,Q,C,W,G,J,$,X,Z,R,D,z,S,E){this.Ah=T|0,this.Al=A|0,this.Bh=P|0,this.Bl=Q|0,this.Ch=C|0,this.Cl=W|0,this.Dh=G|0,this.Dl=J|0,this.Eh=$|0,this.El=X|0,this.Fh=Z|0,this.Fl=R|0,this.Gh=D|0,this.Gl=z|0,this.Hh=S|0,this.Hl=E|0}process(T,A){for(let m=0;m<16;m++,A+=4)kA[m]=T.getUint32(A),jA[m]=T.getUint32(A+=4);for(let m=16;m<80;m++){let g=kA[m-15]|0,p=jA[m-15]|0,c=oA(g,p,1)^oA(g,p,8)^gQ(g,p,7),o=nA(g,p,1)^nA(g,p,8)^vQ(g,p,7),f=kA[m-2]|0,d=jA[m-2]|0,_=oA(f,d,19)^C2(f,d,61)^gQ(f,d,6),t=nA(f,d,19)^W2(f,d,61)^vQ(f,d,6),i=E$(o,t,jA[m-7],jA[m-16]),x=B$(i,c,_,kA[m-7],kA[m-16]);kA[m]=x|0,jA[m]=i|0}let{Ah:P,Al:Q,Bh:C,Bl:W,Ch:G,Cl:J,Dh:$,Dl:X,Eh:Z,El:R,Fh:D,Fl:z,Gh:S,Gl:E,Hh:w,Hl:O}=this;for(let m=0;m<80;m++){let g=oA(Z,R,14)^oA(Z,R,18)^C2(Z,R,41),p=nA(Z,R,14)^nA(Z,R,18)^W2(Z,R,41),c=Z&D^~Z&S,o=R&z^~R&E,f=O$(O,p,o,Ik[m],jA[m]),d=x$(f,w,g,c,zk[m],kA[m]),_=f|0,t=oA(P,Q,28)^C2(P,Q,34)^C2(P,Q,39),i=nA(P,Q,28)^W2(P,Q,34)^W2(P,Q,39),x=P&C^P&G^C&G,k=Q&W^Q&J^W&J;w=S|0,O=E|0,S=D|0,E=z|0,D=Z|0,z=R|0,{h:Z,l:R}=x0($|0,X|0,d|0,_|0),$=G|0,X=J|0,G=C|0,J=W|0,C=P|0,W=Q|0;let U=w$(_,i,k);P=L$(U,d,t,x),Q=U|0}({h:P,l:Q}=x0(this.Ah|0,this.Al|0,P|0,Q|0)),{h:C,l:W}=x0(this.Bh|0,this.Bl|0,C|0,W|0),{h:G,l:J}=x0(this.Ch|0,this.Cl|0,G|0,J|0),{h:$,l:X}=x0(this.Dh|0,this.Dl|0,$|0,X|0),{h:Z,l:R}=x0(this.Eh|0,this.El|0,Z|0,R|0),{h:D,l:z}=x0(this.Fh|0,this.Fl|0,D|0,z|0),{h:S,l:E}=x0(this.Gh|0,this.Gl|0,S|0,E|0),{h:w,l:O}=x0(this.Hh|0,this.Hl|0,w|0,O|0),this.set(P,Q,C,W,G,J,$,X,Z,R,D,z,S,E,w,O)}roundClean(){U0(kA,jA)}destroy(){U0(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}var y6=Q2(()=>new yQ);var m$=Q2(()=>new h$);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var pQ=BigInt(0),lQ=BigInt(1);function t0(T,A=""){if(typeof T!=="boolean"){let P=A&&`"${A}"`;throw Error(P+"expected boolean, got type="+typeof T)}return T}function sT(T,A,P=""){let Q=i0(T),C=T?.length,W=A!==void 0;if(!Q||W&&C!==A){let G=P&&`"${P}" `,J=W?` of length ${A}`:"",$=Q?`length=${C}`:`type=${typeof T}`;throw Error(G+"expected Uint8Array"+J+", got "+$)}return T}function G2(T){let A=T.toString(16);return A.length&1?"0"+A:A}function g$(T){if(typeof T!=="string")throw Error("hex string expected, got "+typeof T);return T===""?pQ:BigInt("0x"+T)}function F8(T){return g$(J0(T))}function e0(T){return KT(T),g$(J0(Uint8Array.from(T).reverse()))}function b6(T,A){return dA(T.toString(16).padStart(A*2,"0"))}function uQ(T,A){return b6(T,A).reverse()}function q1(T,A,P){let Q;if(typeof A==="string")try{Q=dA(A)}catch(W){throw Error(T+" must be hex string or Uint8Array, cause: "+W)}else if(i0(A))Q=Uint8Array.from(A);else throw Error(T+" must be hex string or Uint8Array");let C=Q.length;if(typeof P==="number"&&C!==P)throw Error(T+" of length "+P+" expected, got "+C);return Q}function v$(T,A){if(T.length!==A.length)return!1;let P=0;for(let Q=0;Q<T.length;Q++)P|=T[Q]^A[Q];return P===0}function dQ(T){return Uint8Array.from(T)}var bQ=(T)=>typeof T==="bigint"&&pQ<=T;function y$(T,A,P){return bQ(T)&&bQ(A)&&bQ(P)&&A<=T&&T<P}function U2(T,A,P,Q){if(!y$(A,P,Q))throw Error("expected valid "+T+": "+P+" <= n < "+Q+", got "+A)}function l6(T){let A;for(A=0;T>pQ;T>>=lQ,A+=1);return A}var DA=(T)=>(lQ<<BigInt(T))-lQ;function b$(T,A,P){if(typeof T!=="number"||T<2)throw Error("hashLen must be a number");if(typeof A!=="number"||A<2)throw Error("qByteLen must be a number");if(typeof P!=="function")throw Error("hmacFn must be a function");let Q=(z)=>new Uint8Array(z),C=(z)=>Uint8Array.of(z),W=Q(T),G=Q(T),J=0,$=()=>{W.fill(1),G.fill(0),J=0},X=(...z)=>P(G,W,...z),Z=(z=Q(0))=>{if(G=X(C(0),z),W=X(),z.length===0)return;G=X(C(1),z),W=X()},R=()=>{if(J++>=1000)throw Error("drbg: tried 1000 values");let z=0,S=[];while(z<A){W=X();let E=W.slice();S.push(E),z+=W.length}return xT(...S)};return(z,S)=>{$(),Z(z);let E=void 0;while(!(E=S(R())))Z();return $(),E}}function FA(T,A,P={}){if(!T||typeof T!=="object")throw Error("expected valid options object");function Q(C,W,G){let J=T[C];if(G&&J===void 0)return;let $=typeof J;if($!==W||J===null)throw Error(`param "${C}" is invalid: expected ${W}, got ${$}`)}Object.entries(A).forEach(([C,W])=>Q(C,W,!1)),Object.entries(P).forEach(([C,W])=>Q(C,W,!0))}var rQ=()=>{throw Error("not implemented")};function M8(T){let A=new WeakMap;return(P,...Q)=>{let C=A.get(P);if(C!==void 0)return C;let W=T(P,...Q);return A.set(P,W),W}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var _T=BigInt(0),ZT=BigInt(1),fA=BigInt(2),u$=BigInt(3),d$=BigInt(4),r$=BigInt(5),Sk=BigInt(7),c$=BigInt(8),Nk=BigInt(9),o$=BigInt(16);function M1(T,A){let P=T%A;return P>=_T?P:A+P}function R1(T,A,P){let Q=T;while(A-- >_T)Q*=Q,Q%=P;return Q}function l$(T,A){if(T===_T)throw Error("invert: expected non-zero number");if(A<=_T)throw Error("invert: expected positive modulus, got "+A);let P=M1(T,A),Q=A,C=_T,W=ZT,G=ZT,J=_T;while(P!==_T){let X=Q/P,Z=Q%P,R=C-G*X,D=W-J*X;Q=P,P=Z,C=G,W=J,G=R,J=D}if(Q!==ZT)throw Error("invert: does not exist");return M1(C,A)}function cQ(T,A,P){if(!T.eql(T.sqr(A),P))throw Error("Cannot find square root")}function n$(T,A){let P=(T.ORDER+ZT)/d$,Q=T.pow(A,P);return cQ(T,Q,A),Q}function wk(T,A){let P=(T.ORDER-r$)/c$,Q=T.mul(A,fA),C=T.pow(Q,P),W=T.mul(A,C),G=T.mul(T.mul(W,fA),C),J=T.mul(W,T.sub(G,T.ONE));return cQ(T,J,A),J}function Lk(T){let A=tT(T),P=f$(T),Q=P(A,A.neg(A.ONE)),C=P(A,Q),W=P(A,A.neg(Q)),G=(T+Sk)/o$;return(J,$)=>{let X=J.pow($,G),Z=J.mul(X,Q),R=J.mul(X,C),D=J.mul(X,W),z=J.eql(J.sqr(Z),$),S=J.eql(J.sqr(R),$);X=J.cmov(X,Z,z),Z=J.cmov(D,R,S);let E=J.eql(J.sqr(Z),$),w=J.cmov(X,Z,E);return cQ(J,w,$),w}}function f$(T){if(T<u$)throw Error("sqrt is not defined for small field");let A=T-ZT,P=0;while(A%fA===_T)A/=fA,P++;let Q=fA,C=tT(T);while(p$(C,Q)===1)if(Q++>1000)throw Error("Cannot find square root: probably non-prime P");if(P===1)return n$;let W=C.pow(Q,A),G=(A+ZT)/fA;return function($,X){if($.is0(X))return X;if(p$($,X)!==1)throw Error("Cannot find square root");let Z=P,R=$.mul($.ONE,W),D=$.pow(X,A),z=$.pow(X,G);while(!$.eql(D,$.ONE)){if($.is0(D))return $.ZERO;let S=1,E=$.sqr(D);while(!$.eql(E,$.ONE))if(S++,E=$.sqr(E),S===Z)throw Error("Cannot find square root");let w=ZT<<BigInt(Z-S-1),O=$.pow(R,w);Z=S,R=$.sqr(O),D=$.mul(D,R),z=$.mul(z,O)}return z}}function Ek(T){if(T%d$===u$)return n$;if(T%c$===r$)return wk;if(T%o$===Nk)return Lk(T);return f$(T)}var TA=(T,A)=>(M1(T,A)&ZT)===ZT,Bk=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function oQ(T){let A={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},P=Bk.reduce((Q,C)=>{return Q[C]="function",Q},A);return FA(T,P),T}function Ok(T,A,P){if(P<_T)throw Error("invalid exponent, negatives unsupported");if(P===_T)return T.ONE;if(P===ZT)return A;let Q=T.ONE,C=A;while(P>_T){if(P&ZT)Q=T.mul(Q,C);C=T.sqr(C),P>>=ZT}return Q}function J2(T,A,P=!1){let Q=Array(A.length).fill(P?T.ZERO:void 0),C=A.reduce((G,J,$)=>{if(T.is0(J))return G;return Q[$]=G,T.mul(G,J)},T.ONE),W=T.inv(C);return A.reduceRight((G,J,$)=>{if(T.is0(J))return G;return Q[$]=T.mul(G,Q[$]),T.mul(G,J)},W),Q}function p$(T,A){let P=(T.ORDER-ZT)/fA,Q=T.pow(A,P),C=T.eql(Q,T.ONE),W=T.eql(Q,T.ZERO),G=T.eql(Q,T.neg(T.ONE));if(!C&&!W&&!G)throw Error("invalid Legendre symbol result");return C?1:W?0:-1}function p6(T,A){if(A!==void 0)KA(A);let P=A!==void 0?A:T.toString(2).length,Q=Math.ceil(P/8);return{nBitLength:P,nByteLength:Q}}function tT(T,A,P=!1,Q={}){if(T<=_T)throw Error("invalid field: expected ORDER > 0, got "+T);let C=void 0,W=void 0,G=!1,J=void 0;if(typeof A==="object"&&A!=null){if(Q.sqrt||P)throw Error("cannot specify opts in two arguments");let D=A;if(D.BITS)C=D.BITS;if(D.sqrt)W=D.sqrt;if(typeof D.isLE==="boolean")P=D.isLE;if(typeof D.modFromBytes==="boolean")G=D.modFromBytes;J=D.allowedLengths}else{if(typeof A==="number")C=A;if(Q.sqrt)W=Q.sqrt}let{nBitLength:$,nByteLength:X}=p6(T,C);if(X>2048)throw Error("invalid field: expected ORDER of <= 2048 bytes");let Z,R=Object.freeze({ORDER:T,isLE:P,BITS:$,BYTES:X,MASK:DA($),ZERO:_T,ONE:ZT,allowedLengths:J,create:(D)=>M1(D,T),isValid:(D)=>{if(typeof D!=="bigint")throw Error("invalid field element: expected bigint, got "+typeof D);return _T<=D&&D<T},is0:(D)=>D===_T,isValidNot0:(D)=>!R.is0(D)&&R.isValid(D),isOdd:(D)=>(D&ZT)===ZT,neg:(D)=>M1(-D,T),eql:(D,z)=>D===z,sqr:(D)=>M1(D*D,T),add:(D,z)=>M1(D+z,T),sub:(D,z)=>M1(D-z,T),mul:(D,z)=>M1(D*z,T),pow:(D,z)=>Ok(R,D,z),div:(D,z)=>M1(D*l$(z,T),T),sqrN:(D)=>D*D,addN:(D,z)=>D+z,subN:(D,z)=>D-z,mulN:(D,z)=>D*z,inv:(D)=>l$(D,T),sqrt:W||((D)=>{if(!Z)Z=Ek(T);return Z(R,D)}),toBytes:(D)=>P?uQ(D,X):b6(D,X),fromBytes:(D,z=!0)=>{if(J){if(!J.includes(D.length)||D.length>X)throw Error("Field.fromBytes: expected "+J+" bytes, got "+D.length);let E=new Uint8Array(X);E.set(D,P?0:E.length-D.length),D=E}if(D.length!==X)throw Error("Field.fromBytes: expected "+X+" bytes, got "+D.length);let S=P?e0(D):F8(D);if(G)S=M1(S,T);if(!z){if(!R.isValid(S))throw Error("invalid field element: outside of range 0..ORDER")}return S},invertBatch:(D)=>J2(R,D),cmov:(D,z,S)=>S?z:D});return Object.freeze(R)}function i$(T){if(typeof T!=="bigint")throw Error("field order must be bigint");let A=T.toString(2).length;return Math.ceil(A/8)}function nQ(T){let A=i$(T);return A+Math.ceil(A/2)}function fQ(T,A,P=!1){let Q=T.length,C=i$(A),W=nQ(A);if(Q<16||Q<W||Q>1024)throw Error("expected "+W+"-1024 bytes of input, got "+Q);let G=P?e0(T):F8(T),J=M1(G,A-ZT)+ZT;return P?uQ(J,C):b6(J,C)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var z8=BigInt(0),iA=BigInt(1);function $2(T,A){let P=A.negate();return T?P:A}function AA(T,A){let P=J2(T.Fp,A.map((Q)=>Q.Z));return A.map((Q,C)=>T.fromAffine(Q.toAffine(P[C])))}function e$(T,A){if(!Number.isSafeInteger(T)||T<=0||T>A)throw Error("invalid window size, expected [1.."+A+"], got W="+T)}function iQ(T,A){e$(T,A);let P=Math.ceil(A/T)+1,Q=2**(T-1),C=2**T,W=DA(T),G=BigInt(T);return{windows:P,windowSize:Q,mask:W,maxNumber:C,shiftBy:G}}function a$(T,A,P){let{windowSize:Q,mask:C,maxNumber:W,shiftBy:G}=P,J=Number(T&C),$=T>>G;if(J>Q)J-=W,$+=iA;let X=A*Q,Z=X+Math.abs(J)-1,R=J===0,D=J<0,z=A%2!==0;return{nextN:$,offset:Z,isZero:R,isNeg:D,isNegF:z,offsetF:X}}function xk(T,A){if(!Array.isArray(T))throw Error("array expected");T.forEach((P,Q)=>{if(!(P instanceof A))throw Error("invalid point at index "+Q)})}function _k(T,A){if(!Array.isArray(T))throw Error("array of scalars expected");T.forEach((P,Q)=>{if(!A.isValid(P))throw Error("invalid scalar at index "+Q)})}var aQ=new WeakMap,T9=new WeakMap;function sQ(T){return T9.get(T)||1}function s$(T){if(T!==z8)throw Error("invalid wNAF")}class V2{constructor(T,A){this.BASE=T.BASE,this.ZERO=T.ZERO,this.Fn=T.Fn,this.bits=A}_unsafeLadder(T,A,P=this.ZERO){let Q=T;while(A>z8){if(A&iA)P=P.add(Q);Q=Q.double(),A>>=iA}return P}precomputeWindow(T,A){let{windows:P,windowSize:Q}=iQ(A,this.bits),C=[],W=T,G=W;for(let J=0;J<P;J++){G=W,C.push(G);for(let $=1;$<Q;$++)G=G.add(W),C.push(G);W=G.double()}return C}wNAF(T,A,P){if(!this.Fn.isValid(P))throw Error("invalid scalar");let Q=this.ZERO,C=this.BASE,W=iQ(T,this.bits);for(let G=0;G<W.windows;G++){let{nextN:J,offset:$,isZero:X,isNeg:Z,isNegF:R,offsetF:D}=a$(P,G,W);if(P=J,X)C=C.add($2(R,A[D]));else Q=Q.add($2(Z,A[$]))}return s$(P),{p:Q,f:C}}wNAFUnsafe(T,A,P,Q=this.ZERO){let C=iQ(T,this.bits);for(let W=0;W<C.windows;W++){if(P===z8)break;let{nextN:G,offset:J,isZero:$,isNeg:X}=a$(P,W,C);if(P=G,$)continue;else{let Z=A[J];Q=Q.add(X?Z.negate():Z)}}return s$(P),Q}getPrecomputes(T,A,P){let Q=aQ.get(A);if(!Q){if(Q=this.precomputeWindow(A,T),T!==1){if(typeof P==="function")Q=P(Q);aQ.set(A,Q)}}return Q}cached(T,A,P){let Q=sQ(T);return this.wNAF(Q,this.getPrecomputes(Q,T,P),A)}unsafe(T,A,P,Q){let C=sQ(T);if(C===1)return this._unsafeLadder(T,A,Q);return this.wNAFUnsafe(C,this.getPrecomputes(C,T,P),A,Q)}createCache(T,A){e$(A,this.bits),T9.set(T,A),aQ.delete(T)}hasCache(T){return sQ(T)!==1}}function A9(T,A,P,Q){let C=A,W=T.ZERO,G=T.ZERO;while(P>z8||Q>z8){if(P&iA)W=W.add(C);if(Q&iA)G=G.add(C);C=C.double(),P>>=iA,Q>>=iA}return{p1:W,p2:G}}function I8(T,A,P,Q){xk(P,T),_k(Q,A);let C=P.length,W=Q.length;if(C!==W)throw Error("arrays of points and scalars must have equal length");let G=T.ZERO,J=l6(BigInt(C)),$=1;if(J>12)$=J-3;else if(J>4)$=J-2;else if(J>0)$=2;let X=DA($),Z=Array(Number(X)+1).fill(G),R=Math.floor((A.BITS-1)/$)*$,D=G;for(let z=R;z>=0;z-=$){Z.fill(G);for(let E=0;E<W;E++){let w=Q[E],O=Number(w>>BigInt(z)&X);Z[O]=Z[O].add(P[E])}let S=G;for(let E=Z.length-1,w=G;E>0;E--)w=w.add(Z[E]),S=S.add(w);if(D=D.add(S),z!==0)for(let E=0;E<$;E++)D=D.double()}return D}function t$(T,A,P){if(A){if(A.ORDER!==T)throw Error("Field.ORDER must match order: Fp == p, Fn == n");return oQ(A),A}else return tT(T,{isLE:P})}function u6(T,A,P={},Q){if(Q===void 0)Q=T==="edwards";if(!A||typeof A!=="object")throw Error(`expected valid ${T} CURVE object`);for(let $ of["p","n","h"]){let X=A[$];if(!(typeof X==="bigint"&&X>z8))throw Error(`CURVE.${$} must be positive bigint`)}let C=t$(A.p,P.Fp,Q),W=t$(A.n,P.Fn,Q),J=["Gx","Gy","a",T==="weierstrass"?"b":"d"];for(let $ of J)if(!C.isValid(A[$]))throw Error(`CURVE.${$} must be valid field element of CURVE.Fp`);return A=Object.freeze(Object.assign({},A)),{CURVE:A,Fp:C,Fn:W}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var MA=BigInt(0),XT=BigInt(1),tQ=BigInt(2),hk=BigInt(8);function mk(T,A,P,Q){let C=T.sqr(P),W=T.sqr(Q),G=T.add(T.mul(A.a,C),W),J=T.add(T.ONE,T.mul(A.d,T.mul(C,W)));return T.eql(G,J)}function gk(T,A={}){let P=u6("edwards",T,A,A.FpFnLE),{Fp:Q,Fn:C}=P,W=P.CURVE,{h:G}=W;FA(A,{},{uvRatio:"function"});let J=tQ<<BigInt(C.BYTES*8)-XT,$=(w)=>Q.create(w),X=A.uvRatio||((w,O)=>{try{return{isValid:!0,value:Q.sqrt(Q.div(w,O))}}catch(m){return{isValid:!1,value:MA}}});if(!mk(Q,W,W.Gx,W.Gy))throw Error("bad curve params: generator point");function Z(w,O,m=!1){let g=m?XT:MA;return U2("coordinate "+w,O,g,J),O}function R(w){if(!(w instanceof S))throw Error("ExtendedPoint expected")}let D=M8((w,O)=>{let{X:m,Y:g,Z:p}=w,c=w.is0();if(O==null)O=c?hk:Q.inv(p);let o=$(m*O),f=$(g*O),d=Q.mul(p,O);if(c)return{x:MA,y:XT};if(d!==XT)throw Error("invZ was invalid");return{x:o,y:f}}),z=M8((w)=>{let{a:O,d:m}=W;if(w.is0())throw Error("bad point: ZERO");let{X:g,Y:p,Z:c,T:o}=w,f=$(g*g),d=$(p*p),_=$(c*c),t=$(_*_),i=$(f*O),x=$(_*$(i+d)),k=$(t+$(m*$(f*d)));if(x!==k)throw Error("bad point: equation left != right (1)");let U=$(g*p),V=$(c*o);if(U!==V)throw Error("bad point: equation left != right (2)");return!0});class S{constructor(w,O,m,g){this.X=Z("x",w),this.Y=Z("y",O),this.Z=Z("z",m,!0),this.T=Z("t",g),Object.freeze(this)}static CURVE(){return W}static fromAffine(w){if(w instanceof S)throw Error("extended point not allowed");let{x:O,y:m}=w||{};return Z("x",O),Z("y",m),new S(O,m,XT,$(O*m))}static fromBytes(w,O=!1){let m=Q.BYTES,{a:g,d:p}=W;w=dQ(sT(w,m,"point")),t0(O,"zip215");let c=dQ(w),o=w[m-1];c[m-1]=o&-129;let f=e0(c),d=O?J:Q.ORDER;U2("point.y",f,MA,d);let _=$(f*f),t=$(_-XT),i=$(p*_-g),{isValid:x,value:k}=X(t,i);if(!x)throw Error("bad point: invalid y coordinate");let U=(k&XT)===XT,V=(o&128)!==0;if(!O&&k===MA&&V)throw Error("bad point: x=0 and x_0=1");if(V!==U)k=$(-k);return S.fromAffine({x:k,y:f})}static fromHex(w,O=!1){return S.fromBytes(q1("point",w),O)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(w=8,O=!0){if(E.createCache(this,w),!O)this.multiply(tQ);return this}assertValidity(){z(this)}equals(w){R(w);let{X:O,Y:m,Z:g}=this,{X:p,Y:c,Z:o}=w,f=$(O*o),d=$(p*g),_=$(m*o),t=$(c*g);return f===d&&_===t}is0(){return this.equals(S.ZERO)}negate(){return new S($(-this.X),this.Y,this.Z,$(-this.T))}double(){let{a:w}=W,{X:O,Y:m,Z:g}=this,p=$(O*O),c=$(m*m),o=$(tQ*$(g*g)),f=$(w*p),d=O+m,_=$($(d*d)-p-c),t=f+c,i=t-o,x=f-c,k=$(_*i),U=$(t*x),V=$(_*x),Y=$(i*t);return new S(k,U,Y,V)}add(w){R(w);let{a:O,d:m}=W,{X:g,Y:p,Z:c,T:o}=this,{X:f,Y:d,Z:_,T:t}=w,i=$(g*f),x=$(p*d),k=$(o*m*t),U=$(c*_),V=$((g+p)*(f+d)-i-x),Y=U-k,H=U+k,K=$(x-O*i),M=$(V*Y),I=$(H*K),j=$(V*K),q=$(Y*H);return new S(M,I,q,j)}subtract(w){return this.add(w.negate())}multiply(w){if(!C.isValidNot0(w))throw Error("invalid scalar: expected 1 <= sc < curve.n");let{p:O,f:m}=E.cached(this,w,(g)=>AA(S,g));return AA(S,[O,m])[0]}multiplyUnsafe(w,O=S.ZERO){if(!C.isValid(w))throw Error("invalid scalar: expected 0 <= sc < curve.n");if(w===MA)return S.ZERO;if(this.is0()||w===XT)return this;return E.unsafe(this,w,(m)=>AA(S,m),O)}isSmallOrder(){return this.multiplyUnsafe(G).is0()}isTorsionFree(){return E.unsafe(this,W.n).is0()}toAffine(w){return D(this,w)}clearCofactor(){if(G===XT)return this;return this.multiplyUnsafe(G)}toBytes(){let{x:w,y:O}=this.toAffine(),m=Q.toBytes(O);return m[m.length-1]|=w&XT?128:0,m}toHex(){return J0(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get ex(){return this.X}get ey(){return this.Y}get ez(){return this.Z}get et(){return this.T}static normalizeZ(w){return AA(S,w)}static msm(w,O){return I8(S,C,w,O)}_setWindowSize(w){this.precompute(w)}toRawBytes(){return this.toBytes()}}S.BASE=new S(W.Gx,W.Gy,XT,$(W.Gx*W.Gy)),S.ZERO=new S(MA,XT,XT,MA),S.Fp=Q,S.Fn=C;let E=new V2(S,C.BITS);return S.BASE.precompute(8),S}class eQ{constructor(T){this.ep=T}static fromBytes(T){rQ()}static fromHex(T){rQ()}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine(T){return this.ep.toAffine(T)}toHex(){return J0(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add(T){return this.assertSame(T),this.init(this.ep.add(T.ep))}subtract(T){return this.assertSame(T),this.init(this.ep.subtract(T.ep))}multiply(T){return this.init(this.ep.multiply(T))}multiplyUnsafe(T){return this.init(this.ep.multiplyUnsafe(T))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute(T,A){return this.init(this.ep.precompute(T,A))}toRawBytes(){return this.toBytes()}}function vk(T,A,P={}){if(typeof A!=="function")throw Error('"hash" function param is required');FA(P,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});let{prehash:Q}=P,{BASE:C,Fp:W,Fn:G}=T,J=P.randomBytes||D8,$=P.adjustScalarBytes||((_)=>_),X=P.domain||((_,t,i)=>{if(t0(i,"phflag"),t.length||i)throw Error("Contexts/pre-hash are not supported");return _});function Z(_){return G.create(e0(_))}function R(_){let t=g.secretKey;_=q1("private key",_,t);let i=q1("hashed private key",A(_),2*t),x=$(i.slice(0,t)),k=i.slice(t,2*t),U=Z(x);return{head:x,prefix:k,scalar:U}}function D(_){let{head:t,prefix:i,scalar:x}=R(_),k=C.multiply(x),U=k.toBytes();return{head:t,prefix:i,scalar:x,point:k,pointBytes:U}}function z(_){return D(_).pointBytes}function S(_=Uint8Array.of(),...t){let i=xT(...t);return Z(A(X(i,q1("context",_),!!Q)))}function E(_,t,i={}){if(_=q1("message",_),Q)_=Q(_);let{prefix:x,scalar:k,pointBytes:U}=D(t),V=S(i.context,x,_),Y=C.multiply(V).toBytes(),H=S(i.context,Y,U,_),K=G.create(V+H*k);if(!G.isValid(K))throw Error("sign failed: invalid s");let M=xT(Y,G.toBytes(K));return sT(M,g.signature,"result")}let w={zip215:!0};function O(_,t,i,x=w){let{context:k,zip215:U}=x,V=g.signature;if(_=q1("signature",_,V),t=q1("message",t),i=q1("publicKey",i,g.publicKey),U!==void 0)t0(U,"zip215");if(Q)t=Q(t);let Y=V/2,H=_.subarray(0,Y),K=e0(_.subarray(Y,V)),M,I,j;try{M=T.fromBytes(i,U),I=T.fromBytes(H,U),j=C.multiplyUnsafe(K)}catch(y){return!1}if(!U&&M.isSmallOrder())return!1;let q=S(k,I.toBytes(),M.toBytes(),t);return I.add(M.multiplyUnsafe(q)).subtract(j).clearCofactor().is0()}let m=W.BYTES,g={secretKey:m,publicKey:m,signature:2*m,seed:m};function p(_=J(g.seed)){return sT(_,g.seed,"seed")}function c(_){let t=d.randomSecretKey(_);return{secretKey:t,publicKey:z(t)}}function o(_){return i0(_)&&_.length===G.BYTES}function f(_,t){try{return!!T.fromBytes(_,t)}catch(i){return!1}}let d={getExtendedPublicKey:D,randomSecretKey:p,isValidSecretKey:o,isValidPublicKey:f,toMontgomery(_){let{y:t}=T.fromBytes(_),i=g.publicKey,x=i===32;if(!x&&i!==57)throw Error("only defined for 25519 and 448");let k=x?W.div(XT+t,XT-t):W.div(t-XT,t+XT);return W.toBytes(k)},toMontgomerySecret(_){let t=g.secretKey;sT(_,t);let i=A(_.subarray(0,t));return $(i).subarray(0,t)},randomPrivateKey:p,precompute(_=8,t=T.BASE){return t.precompute(_,!1)}};return Object.freeze({keygen:c,getPublicKey:z,sign:E,verify:O,utils:d,Point:T,lengths:g})}function yk(T){let A={a:T.a,d:T.d,p:T.Fp.ORDER,n:T.n,h:T.h,Gx:T.Gx,Gy:T.Gy},P=T.Fp,Q=tT(A.n,T.nBitLength,!0),C={Fp:P,Fn:Q,uvRatio:T.uvRatio},W={randomBytes:T.randomBytes,adjustScalarBytes:T.adjustScalarBytes,domain:T.domain,prehash:T.prehash,mapToCurve:T.mapToCurve};return{CURVE:A,curveOpts:C,hash:T.hash,eddsaOpts:W}}function bk(T,A){let P=A.Point;return Object.assign({},A,{ExtendedPoint:P,CURVE:T,nBitLength:P.Fn.BITS,nByteLength:P.Fn.BYTES})}function P9(T){let{CURVE:A,curveOpts:P,hash:Q,eddsaOpts:C}=yk(T),W=gk(A,P),G=vk(W,Q,C);return bk(T,G)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var lk=BigInt(0),PA=BigInt(1),Q9=BigInt(2),kO=BigInt(3),pk=BigInt(5),uk=BigInt(8),S8=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),q2=(()=>({p:S8,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:uk,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")}))();function dk(T){let A=BigInt(10),P=BigInt(20),Q=BigInt(40),C=BigInt(80),W=S8,J=T*T%W*T%W,$=R1(J,Q9,W)*J%W,X=R1($,PA,W)*T%W,Z=R1(X,pk,W)*X%W,R=R1(Z,A,W)*Z%W,D=R1(R,P,W)*R%W,z=R1(D,Q,W)*D%W,S=R1(z,C,W)*z%W,E=R1(S,C,W)*z%W,w=R1(E,A,W)*Z%W;return{pow_p_5_8:R1(w,Q9,W)*T%W,b2:J}}function rk(T){return T[0]&=248,T[31]&=127,T[31]|=64,T}var TC=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function QC(T,A){let P=S8,Q=M1(A*A*A,P),C=M1(Q*Q*A,P),W=dk(T*C).pow_p_5_8,G=M1(T*Q*W,P),J=M1(A*G*G,P),$=G,X=M1(G*TC,P),Z=J===T,R=J===M1(-T,P),D=J===M1(-T*TC,P);if(Z)G=$;if(R||D)G=X;if(TA(G,P))G=M1(-G,P);return{isValid:Z||R,value:G}}var zA=(()=>tT(q2.p,{isLE:!0}))(),ck=(()=>tT(q2.n,{isLE:!0}))(),ok=(()=>({...q2,Fp:zA,hash:m$,adjustScalarBytes:rk,uvRatio:QC}))(),cT=(()=>P9(ok))();var AC=TC,nk=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),fk=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),ik=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),ak=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),C9=(T)=>QC(PA,T),sk=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),PC=(T)=>cT.Point.Fp.create(e0(T)&sk);function W9(T){let{d:A}=q2,P=S8,Q=(O)=>zA.create(O),C=Q(AC*T*T),W=Q((C+PA)*ik),G=BigInt(-1),J=Q((G-A*C)*Q(C+A)),{isValid:$,value:X}=QC(W,J),Z=Q(X*T);if(!TA(Z,P))Z=Q(-Z);if(!$)X=Z;if(!$)G=C;let R=Q(G*(C-PA)*ak-J),D=X*X,z=Q((X+X)*J),S=Q(R*nk),E=Q(PA-D),w=Q(PA+D);return new cT.Point(Q(z*w),Q(E*S),Q(S*w),Q(z*E))}function tk(T){KT(T,64);let A=PC(T.subarray(0,32)),P=W9(A),Q=PC(T.subarray(32,64)),C=W9(Q);return new hT(P.add(C))}class hT extends eQ{constructor(T){super(T)}static fromAffine(T){return new hT(cT.Point.fromAffine(T))}assertSame(T){if(!(T instanceof hT))throw Error("RistrettoPoint expected")}init(T){return new hT(T)}static hashToCurve(T){return tk(q1("ristrettoHash",T,64))}static fromBytes(T){KT(T,32);let{a:A,d:P}=q2,Q=S8,C=(g)=>zA.create(g),W=PC(T);if(!v$(zA.toBytes(W),T)||TA(W,Q))throw Error("invalid ristretto255 encoding 1");let G=C(W*W),J=C(PA+A*G),$=C(PA-A*G),X=C(J*J),Z=C($*$),R=C(A*P*X-Z),{isValid:D,value:z}=C9(C(R*Z)),S=C(z*$),E=C(z*S*R),w=C((W+W)*S);if(TA(w,Q))w=C(-w);let O=C(J*E),m=C(w*O);if(!D||TA(m,Q)||O===lk)throw Error("invalid ristretto255 encoding 2");return new hT(new cT.Point(w,O,PA,m))}static fromHex(T){return hT.fromBytes(q1("ristrettoHex",T,32))}static msm(T,A){return I8(hT,cT.Point.Fn,T,A)}toBytes(){let{X:T,Y:A,Z:P,T:Q}=this.ep,C=S8,W=(E)=>zA.create(E),G=W(W(P+A)*W(P-A)),J=W(T*A),$=W(J*J),{value:X}=C9(W(G*$)),Z=W(X*G),R=W(X*J),D=W(Z*R*Q),z;if(TA(Q*D,C)){let E=W(A*AC),w=W(T*AC);T=E,A=w,z=W(Z*fk)}else z=R;if(TA(T*D,C))A=W(-A);let S=W((P-A)*z);if(TA(S,C))S=W(-S);return zA.toBytes(S)}equals(T){this.assertSame(T);let{X:A,Y:P}=this.ep,{X:Q,Y:C}=T.ep,W=($)=>zA.create($),G=W(A*C)===W(P*Q),J=W(P*C)===W(A*Q);return G||J}is0(){return this.equals(hT.ZERO)}}hT.BASE=(()=>new hT(cT.Point.BASE))();hT.ZERO=(()=>new hT(cT.Point.ZERO))();hT.Fp=(()=>zA)();hT.Fn=(()=>ck)();var qW=yT(WC(),1),nT=yT(UC(),1);var JC=y6;var g8=yT(j9(),1),N=yT(CA(),1),bV=yT(CA(),1);var yD=1,bD=2,lD=3,pD=4,uD=5,dD=6,rD=7,cD=8,oD=9,nD=10,fD=-32700,iD=-32603,aD=-32602,sD=-32601,tD=-32600,eD=-32016,TF=-32015,AF=-32014,PF=-32013,QF=-32012,CF=-32011,WF=-32010,GF=-32009,UF=-32008,JF=-32007,$F=-32006,VF=-32005,qF=-32004,YF=-32003,ZF=-32002,XF=-32001,HF=2800000,KF=2800001,RF=2800002,kF=2800003,jF=2800004,DF=2800005,FF=2800006,MF=2800007,zF=2800008,IF=2800009,SF=2800010,NF=2800011,wF=3230000,LF=32300001,EF=3230002,BF=3230003,OF=3230004,xF=3610000,_F=3610001,hF=3610002,mF=3610003,gF=3610004,vF=3610005,yF=3610006,bF=3610007,lF=3611000,pF=3704000,uF=3704001,dF=3704002,rF=3704003,cF=3704004,oF=4128000,nF=4128001,fF=4128002,iF=4615000,aF=4615001,sF=4615002,tF=4615003,eF=4615004,T5=4615005,A5=4615006,P5=4615007,Q5=4615008,C5=4615009,W5=4615010,G5=4615011,U5=4615012,J5=4615013,$5=4615014,V5=4615015,q5=4615016,Y5=4615017,Z5=4615018,X5=4615019,H5=4615020,K5=4615021,R5=4615022,k5=4615023,j5=4615024,D5=4615025,F5=4615026,M5=4615027,z5=4615028,I5=4615029,S5=4615030,N5=4615031,w5=4615032,L5=4615033,E5=4615034,B5=4615035,O5=4615036,x5=4615037,_5=4615038,h5=4615039,m5=4615040,g5=4615041,v5=4615042,y5=4615043,b5=4615044,l5=4615045,p5=4615046,u5=4615047,d5=4615048,r5=4615049,c5=4615050,o5=4615051,n5=4615052,f5=4615053,i5=4615054,a5=5508000,s5=5508001,t5=5508002,e5=5508003,T7=5508004,A7=5508005,P7=5508006,Q7=5508007,C7=5508008,W7=5508009,G7=5508010,U7=5508011,J7=5663000,$7=5663001,V7=5663002,q7=5663003,Y7=5663004,Z7=5663005,X7=5663006,H7=5663007,K7=5663008,R7=5663009,k7=5663010,j7=5663011,D7=5663012,F7=5663013,M7=5663014,z7=5663015,I7=5663016,S7=5663017,N7=5663018,w7=5663019,L7=5663020,E7=7050000,B7=7050001,O7=7050002,x7=7050003,_7=7050004,h7=7050005,m7=7050006,g7=7050007,v7=7050008,y7=7050009,b7=7050010,l7=7050011,p7=7050012,u7=7050013,d7=7050014,r7=7050015,c7=7050016,o7=7050017,n7=7050018,f7=7050019,i7=7050020,a7=7050021,s7=7050022,t7=7050023,e7=7050024,TM=7050025,AM=7050026,PM=7050027,QM=7050028,CM=7050029,WM=7050030,GM=7050031,UM=7050032,JM=7050033,$M=7050034,VM=7050035,qM=7050036,hC=8078000,mC=8078001,z9=8078002,I9=8078003,gC=8078004,vC=8078005,yC=8078006,YM=8078007,ZM=8078008,XM=8078009,HM=8078010,bC=8078011,KM=8078012,S9=8078013,N9=8078014,RM=8078015,kM=8078016,jM=8078017,DM=8078018,FM=8078019,w9=8078020,L9=8078021,MM=8078022,zM=8100000,IM=8100001,SM=8100002,NM=8100003,wM=8190000,LM=8190001,EM=8190002,BM=8190003,OM=8190004,xM=9900000,_M=9900001,hM=9900002,mM=9900003,gM=9900004;var vM={[wF]:"Account not found at address: $address",[OF]:"Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",[BF]:"Expected decoded account at address: $address",[EF]:"Failed to decode account data at address: $address",[LF]:"Accounts not found at addresses: $addresses",[IF]:"Unable to find a viable program address bump seed.",[RF]:"$putativeAddress is not a base58-encoded address.",[HF]:"Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",[kF]:"The `CryptoKey` must be an `Ed25519` public key.",[NF]:"$putativeOffCurveAddress is not a base58-encoded off-curve address.",[zF]:"Invalid seeds; point must fall off the Ed25519 curve.",[jF]:"Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",[FF]:"A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",[MF]:"The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",[DF]:"Expected program derived address bump to be in the range [0, 255], got: $bump.",[SF]:"Program address cannot end with PDA marker.",[KF]:"Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",[pD]:"Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",[yD]:"The network has progressed past the last block for which this transaction could have been committed.",[hC]:"Codec [$codecDescription] cannot decode empty byte arrays.",[MM]:"Enum codec cannot use lexical values [$stringValues] as discriminators. Either remove all lexical values or set `useValuesAsDiscriminators` to `false`.",[w9]:"Sentinel [$hexSentinel] must not be present in encoded bytes [$hexEncodedBytes].",[vC]:"Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",[yC]:"Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",[gC]:"Encoder and decoder must either both be fixed-size or variable-size.",[ZM]:"Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",[z9]:"Expected a fixed-size codec, got a variable-size one.",[S9]:"Codec [$codecDescription] expected a positive byte length, got $bytesLength.",[I9]:"Expected a variable-size codec, got a fixed-size one.",[FM]:"Codec [$codecDescription] expected zero-value [$hexZeroValue] to have the same size as the provided fixed-size item [$expectedSize bytes].",[mC]:"Codec [$codecDescription] expected $expected bytes, got $bytesLength.",[DM]:"Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",[XM]:"Invalid discriminated union variant. Expected one of [$variants], got $value.",[HM]:"Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",[RM]:"Invalid literal union variant. Expected one of [$variants], got $value.",[YM]:"Expected [$codecDescription] to have $expected items, got $actual.",[KM]:"Invalid value $value for base $base with alphabet $alphabet.",[kM]:"Literal union discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",[bC]:"Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",[N9]:"Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",[L9]:"Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",[jM]:"Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",[lF]:"No random values implementation could be found.",[C5]:"instruction requires an uninitialized account",[k5]:"instruction tries to borrow reference for an account which is already borrowed",[j5]:"instruction left account with an outstanding borrowed reference",[K5]:"program other than the account's owner changed the size of the account data",[T5]:"account data too small for instruction",[R5]:"instruction expected an executable account",[p5]:"An account does not have enough lamports to be rent-exempt",[d5]:"Program arithmetic overflowed",[l5]:"Failed to serialize or deserialize account data: $encodedData",[i5]:"Builtin programs must consume compute units",[w5]:"Cross-program invocation call depth too deep",[_5]:"Computational budget exceeded",[F5]:"custom program error: #$code",[Y5]:"instruction contains duplicate accounts",[D5]:"instruction modifications of multiply-passed account differ",[S5]:"executable accounts must be rent exempt",[z5]:"instruction changed executable accounts data",[I5]:"instruction changed the balance of an executable account",[Z5]:"instruction changed executable bit of an account",[$5]:"instruction modified data of an account it does not own",[J5]:"instruction spent from the balance of an account it does not own",[aF]:"generic instruction error",[c5]:"Provided owner is not allowed",[y5]:"Account is immutable",[b5]:"Incorrect authority provided",[P5]:"incorrect program id for instruction",[A5]:"insufficient funds for instruction",[eF]:"invalid account data for instruction",[u5]:"Invalid account owner",[sF]:"invalid program argument",[M5]:"program returned invalid error code",[tF]:"invalid instruction data",[x5]:"Failed to reallocate account data",[O5]:"Provided seeds do not result in a valid address",[o5]:"Accounts data allocations exceeded the maximum allowed per transaction",[n5]:"Max accounts exceeded",[f5]:"Max instruction trace length exceeded",[B5]:"Length of the seed is too long for address generation",[L5]:"An account required by the instruction is missing",[Q5]:"missing required signature for instruction",[U5]:"instruction illegally modified the program id of an account",[H5]:"insufficient account keys for instruction",[h5]:"Cross-program invocation with unauthorized signer or writable account",[m5]:"Failed to create program execution environment",[v5]:"Program failed to compile",[g5]:"Program failed to complete",[q5]:"instruction modified data of a read-only account",[V5]:"instruction changed the balance of a read-only account",[E5]:"Cross-program invocation reentrancy not allowed for this instruction",[X5]:"instruction modified rent epoch of an account",[G5]:"sum of account balances before and after instruction do not match",[W5]:"instruction requires an initialized account",[iF]:"",[N5]:"Unsupported program id",[r5]:"Unsupported sysvar",[oF]:"The instruction does not have any accounts.",[nF]:"The instruction does not have any data.",[fF]:"Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",[uD]:"Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",[bD]:"The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",[hM]:"Invariant violation: Found no abortable iterable cache entry for key `$cacheKey`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[gM]:"Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",[_M]:"Invariant violation: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[xM]:"Invariant violation: WebSocket message iterator is missing state storage. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[mM]:"Invariant violation: Switch statement non-exhaustive. Received unexpected value `$unexpectedValue`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[iD]:"JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",[aD]:"JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",[tD]:"JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",[sD]:"JSON-RPC error: The method does not exist / is not available ($__serverMessage)",[fD]:"JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",[QF]:"$__serverMessage",[XF]:"$__serverMessage",[qF]:"$__serverMessage",[AF]:"$__serverMessage",[WF]:"$__serverMessage",[GF]:"$__serverMessage",[eD]:"Minimum context slot has not been reached",[VF]:"Node is unhealthy; behind by $numSlotsBehind slots",[UF]:"No snapshot",[ZF]:"Transaction simulation failed",[JF]:"$__serverMessage",[CF]:"Transaction history is not available from this node",[$F]:"$__serverMessage",[PF]:"Transaction signature length mismatch",[YF]:"Transaction signature verification failure",[TF]:"$__serverMessage",[pF]:"Key pair bytes must be of length 64, got $byteLength.",[uF]:"Expected private key bytes with length 32. Actual length: $actualLength.",[dF]:"Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",[cF]:"The provided private key does not match the provided public key.",[rF]:"Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",[dD]:"Lamports value must be in the range [0, 2e64-1]",[rD]:"`$value` cannot be parsed as a `BigInt`",[nD]:"$message",[cD]:"`$value` cannot be parsed as a `Number`",[lD]:"No nonce account could be found at address `$nonceAccountAddress`",[wM]:"The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",[EM]:"WebSocket was closed before payload could be added to the send buffer",[BM]:"WebSocket connection closed",[OM]:"WebSocket failed to connect",[LM]:"Failed to obtain a subscription id from the server",[NM]:"Could not find an API plan for RPC method: `$method`",[zM]:"The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was `$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds `Number.MAX_SAFE_INTEGER`.",[SM]:"HTTP error ($statusCode): $message",[IM]:"HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",[a5]:"Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",[s5]:"The provided value does not implement the `KeyPairSigner` interface",[e5]:"The provided value does not implement the `MessageModifyingSigner` interface",[T7]:"The provided value does not implement the `MessagePartialSigner` interface",[t5]:"The provided value does not implement any of the `MessageSigner` interfaces",[P7]:"The provided value does not implement the `TransactionModifyingSigner` interface",[Q7]:"The provided value does not implement the `TransactionPartialSigner` interface",[C7]:"The provided value does not implement the `TransactionSendingSigner` interface",[A7]:"The provided value does not implement any of the `TransactionSigner` interfaces",[W7]:"More than one `TransactionSendingSigner` was identified.",[G7]:"No `TransactionSendingSigner` was identified. Please provide a valid `TransactionWithSingleSendingSigner` transaction.",[U7]:"Wallet account signers do not support signing multiple messages/transactions in a single operation",[bF]:"Cannot export a non-extractable key.",[_F]:"No digest implementation could be found.",[xF]:"Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",[hF]:`This runtime does not support the generation of Ed25519 key pairs.
|
|
11
|
+
|
|
12
|
+
Install @solana/webcrypto-ed25519-polyfill and call its \`install\` function before generating keys in environments that do not support Ed25519.
|
|
13
|
+
|
|
14
|
+
For a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20.`,[mF]:"No signature verification implementation could be found.",[gF]:"No key generation implementation could be found.",[vF]:"No signing implementation could be found.",[yF]:"No key export implementation could be found.",[oD]:"Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",[c7]:"Transaction processing left an account with an outstanding borrowed reference",[B7]:"Account in use",[O7]:"Account loaded twice",[x7]:"Attempt to debit an account but found no record of a prior credit.",[t7]:"Transaction loads an address table account that doesn't exist",[g7]:"This transaction has already been processed",[v7]:"Blockhash not found",[y7]:"Loader call chain is too deep",[r7]:"Transactions are currently disabled due to cluster maintenance",[WM]:"Transaction contains a duplicate instruction ($index) that is not allowed",[h7]:"Insufficient funds for fee",[GM]:"Transaction results in an account ($accountIndex) with insufficient funds for rent",[m7]:"This account may not be used to pay transaction fees",[l7]:"Transaction contains an invalid account reference",[TM]:"Transaction loads an address table account with invalid data",[AM]:"Transaction address table lookup uses an invalid index",[e7]:"Transaction loads an address table account with an invalid owner",[JM]:"LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",[u7]:"This program may not be used for executing instructions",[PM]:"Transaction leaves an account with a lower balance than rent-exempt minimum",[f7]:"Transaction loads a writable account that cannot be written",[UM]:"Transaction exceeded max loaded accounts data size cap",[b7]:"Transaction requires a fee but has no signature present",[_7]:"Attempt to load a program that does not exist",[VM]:"Execution of the program referenced by account at index $accountIndex is temporarily restricted.",[$M]:"ResanitizationNeeded",[d7]:"Transaction failed to sanitize accounts offsets correctly",[p7]:"Transaction did not pass signature verification",[s7]:"Transaction locked too many accounts",[qM]:"Sum of account balances before and after transaction do not match",[E7]:"The transaction failed with the error `$errorName`",[n7]:"Transaction version is unsupported",[a7]:"Transaction would exceed account data limit within the block",[CM]:"Transaction would exceed total account data limit",[i7]:"Transaction would exceed max account limit within the block",[o7]:"Transaction would exceed max Block Cost Limit",[QM]:"Transaction would exceed max Vote Cost Limit",[z7]:"Attempted to sign a transaction with an address that is not a signer for it",[k7]:"Transaction is missing an address at index: $index.",[I7]:"Transaction has no expected signers therefore it cannot be encoded",[L7]:"Transaction size $transactionSize exceeds limit of $transactionSizeLimit bytes",[V7]:"Transaction does not have a blockhash lifetime",[q7]:"Transaction is not a durable nonce transaction",[Z7]:"Contents of these address lookup tables unknown: $lookupTableAddresses",[X7]:"Lookup of address at index $highestRequestedIndex failed for lookup table `$lookupTableAddress`. Highest known index is $highestKnownIndex. The lookup table may have been extended since its contents were retrieved",[K7]:"No fee payer set in CompiledTransaction",[H7]:"Could not find program address at index $index",[N7]:"Failed to estimate the compute unit consumption for this transaction message. This is likely because simulating the transaction failed. Inspect the `cause` property of this error to learn more",[w7]:"Transaction failed when it was simulated in order to estimate the compute unit consumption. The compute unit estimate provided is for a transaction that failed when simulated and may not be representative of the compute units this transaction would consume if successful. Inspect the `cause` property of this error to learn more",[j7]:"Transaction is missing a fee payer.",[D7]:"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",[M7]:"Transaction first instruction is not advance nonce account instruction.",[F7]:"Transaction with no instructions cannot be durable nonce transaction.",[J7]:"This transaction includes an address (`$programAddress`) which is both invoked and set as the fee payer. Program addresses may not pay fees",[$7]:"This transaction includes an address (`$programAddress`) which is both invoked and marked writable. Program addresses may not be writable",[S7]:"The transaction message expected the transaction to have $signerAddressesLength signatures, got $signaturesLength.",[R7]:"Transaction is missing signatures for addresses: $addresses.",[Y7]:"Transaction version must be in the range [0, 127]. `$actualVersion` given"},WA="i",g0="t";function yM(T,A={}){let P=vM[T];if(P.length===0)return"";let Q;function C(G){if(Q[g0]===2){let J=P.slice(Q[WA]+1,G);W.push(J in A?`${A[J]}`:`$${J}`)}else if(Q[g0]===1)W.push(P.slice(Q[WA],G))}let W=[];return P.split("").forEach((G,J)=>{if(J===0){Q={[WA]:0,[g0]:P[0]==="\\"?0:P[0]==="$"?2:1};return}let $;switch(Q[g0]){case 0:$={[WA]:J,[g0]:1};break;case 1:if(G==="\\")$={[WA]:J,[g0]:0};else if(G==="$")$={[WA]:J,[g0]:2};break;case 2:if(G==="\\")$={[WA]:J,[g0]:0};else if(G==="$")$={[WA]:J,[g0]:2};else if(!G.match(/\w/))$={[WA]:J,[g0]:1};break}if($){if(Q!==$)C(J);Q=$}}),C(),W.join("")}function bM(T,A={}){return yM(T,A)}var NA=class extends Error{cause=this.cause;context;constructor(...[T,A]){let P,Q;if(A){let{cause:W,...G}=A;if(W)Q={cause:W};if(Object.keys(G).length>0)P=G}let C=bM(T,P);super(C,Q);this.context={__code:T,...P},this.name="SolanaError"}};function lM(T,A){return"fixedSize"in A?A.fixedSize:A.getSizeFromValue(T)}function E9(T){return Object.freeze({...T,encode:(A)=>{let P=new Uint8Array(lM(A,T));return T.write(A,P,0),P}})}function B9(T){return Object.freeze({...T,decode:(A,P=0)=>T.read(A,P)[0]})}function E8(T){return"fixedSize"in T&&typeof T.fixedSize==="number"}function O9(T,A){if(E8(T)!==E8(A))throw new NA(gC);if(E8(T)&&E8(A)&&T.fixedSize!==A.fixedSize)throw new NA(vC,{decoderFixedSize:A.fixedSize,encoderFixedSize:T.fixedSize});if(!E8(T)&&!E8(A)&&T.maxSize!==A.maxSize)throw new NA(yC,{decoderMaxSize:A.maxSize,encoderMaxSize:T.maxSize});return{...A,...T,decode:A.decode,encode:T.encode,read:A.read,write:T.write}}function x9(T,A,P=0){if(A.length-P<=0)throw new NA(hC,{codecDescription:T})}function _9(T,A,P,Q=0){let C=P.length-Q;if(C<A)throw new NA(mC,{bytesLength:C,codecDescription:T,expected:A})}function pM(T,A,P,Q){if(Q<A||Q>P)throw new NA(bC,{codecDescription:T,max:P,min:A,value:Q})}function h9(T){return T?.endian===1?!1:!0}function uM(T){return E9({fixedSize:T.size,write(A,P,Q){if(T.range)pM(T.name,T.range[0],T.range[1],A);let C=new ArrayBuffer(T.size);return T.set(new DataView(C),A,h9(T.config)),P.set(new Uint8Array(C),Q),Q+T.size}})}function dM(T){return B9({fixedSize:T.size,read(A,P=0){x9(T.name,A,P),_9(T.name,T.size,A,P);let Q=new DataView(rM(A,P,T.size));return[T.get(Q,h9(T.config)),P+T.size]}})}function rM(T,A,P){let Q=T.byteOffset+(A??0),C=P??T.byteLength;return T.buffer.slice(Q,Q+C)}var lC=(T={})=>uM({config:T,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(A,P,Q)=>A.setBigUint64(0,BigInt(P),Q),size:8}),cM=(T={})=>dM({config:T,get:(A,P)=>A.getBigUint64(0,P),name:"u64",size:8}),m9=(T={})=>O9(lC(T),cM(T));class v9 extends TypeError{constructor(T,A){let P,{message:Q,explanation:C,...W}=T,{path:G}=T,J=G.length===0?Q:`At path: ${G.join(".")} -- ${Q}`;super(C??J);if(C!=null)this.cause=J;Object.assign(this,W),this.name=this.constructor.name,this.failures=()=>{return P??(P=[T,...A()])}}}function oM(T){return Z2(T)&&typeof T[Symbol.iterator]==="function"}function Z2(T){return typeof T==="object"&&T!=null}function Q4(T){return Z2(T)&&!Array.isArray(T)}function Y0(T){if(typeof T==="symbol")return T.toString();return typeof T==="string"?JSON.stringify(T):`${T}`}function nM(T){let{done:A,value:P}=T.next();return A?void 0:P}function fM(T,A,P,Q){if(T===!0)return;else if(T===!1)T={};else if(typeof T==="string")T={message:T};let{path:C,branch:W}=A,{type:G}=P,{refinement:J,message:$=`Expected a value of type \`${G}\`${J?` with refinement \`${J}\``:""}, but received: \`${Y0(Q)}\``}=T;return{value:Q,type:G,refinement:J,key:C[C.length-1],path:C,branch:W,...T,message:$}}function*g9(T,A,P,Q){if(!oM(T))T=[T];for(let C of T){let W=fM(C,A,P,Q);if(W)yield W}}function*pC(T,A,P={}){let{path:Q=[],branch:C=[T],coerce:W=!1,mask:G=!1}=P,J={path:Q,branch:C,mask:G};if(W)T=A.coercer(T,J);let $="valid";for(let X of A.validator(T,J))X.explanation=P.message,$="not_valid",yield[X,void 0];for(let[X,Z,R]of A.entries(T,J)){let D=pC(Z,R,{path:X===void 0?Q:[...Q,X],branch:X===void 0?C:[...C,Z],coerce:W,mask:G,message:P.message});for(let z of D)if(z[0])$=z[0].refinement!=null?"not_refined":"not_valid",yield[z[0],void 0];else if(W){if(Z=z[1],X===void 0)T=Z;else if(T instanceof Map)T.set(X,Z);else if(T instanceof Set)T.add(Z);else if(Z2(T)){if(Z!==void 0||X in T)T[X]=Z}}}if($!=="not_valid")for(let X of A.refiner(T,J))X.explanation=P.message,$="not_refined",yield[X,void 0];if($==="valid")yield[void 0,T]}class Z0{constructor(T){let{type:A,schema:P,validator:Q,refiner:C,coercer:W=(J)=>J,entries:G=function*(){}}=T;if(this.type=A,this.schema=P,this.entries=G,this.coercer=W,Q)this.validator=(J,$)=>{let X=Q(J,$);return g9(X,$,this,J)};else this.validator=()=>[];if(C)this.refiner=(J,$)=>{let X=C(J,$);return g9(X,$,this,J)};else this.refiner=()=>[]}assert(T,A){return y9(T,this,A)}create(T,A){return B8(T,this,A)}is(T){return b9(T,this)}mask(T,A){return iM(T,this,A)}validate(T,A={}){return X2(T,this,A)}}function y9(T,A,P){let Q=X2(T,A,{message:P});if(Q[0])throw Q[0]}function B8(T,A,P){let Q=X2(T,A,{coerce:!0,message:P});if(Q[0])throw Q[0];else return Q[1]}function iM(T,A,P){let Q=X2(T,A,{coerce:!0,mask:!0,message:P});if(Q[0])throw Q[0];else return Q[1]}function b9(T,A){return!X2(T,A)[0]}function X2(T,A,P={}){let Q=pC(T,A,P),C=nM(Q);if(C[0])return[new v9(C[0],function*(){for(let G of Q)if(G[0])yield G[0]}),void 0];else return[void 0,C[1]]}function T8(T,A){return new Z0({type:T,schema:null,validator:A})}function l9(){return T8("any",()=>!0)}function a(T){return new Z0({type:"array",schema:T,*entries(A){if(T&&Array.isArray(A))for(let[P,Q]of A.entries())yield[P,Q,T]},coercer(A){return Array.isArray(A)?A.slice():A},validator(A){return Array.isArray(A)||`Expected an array value, but received: ${Y0(A)}`}})}function X0(){return T8("boolean",(T)=>{return typeof T==="boolean"})}function C4(T){return T8("instance",(A)=>{return A instanceof T||`Expected a \`${T.name}\` instance, but received: ${Y0(A)}`})}function k1(T){let A=Y0(T),P=typeof T;return new Z0({type:"literal",schema:P==="string"||P==="number"||P==="boolean"?T:null,validator(Q){return Q===T||`Expected the literal \`${A}\`, but received: ${Y0(Q)}`}})}function aM(){return T8("never",()=>!1)}function s(T){return new Z0({...T,validator:(A,P)=>A===null||T.validator(A,P),refiner:(A,P)=>A===null||T.refiner(A,P)})}function B(){return T8("number",(T)=>{return typeof T==="number"&&!isNaN(T)||`Expected a number, but received: ${Y0(T)}`})}function A1(T){return new Z0({...T,validator:(A,P)=>A===void 0||T.validator(A,P),refiner:(A,P)=>A===void 0||T.refiner(A,P)})}function uC(T,A){return new Z0({type:"record",schema:null,*entries(P){if(Z2(P))for(let Q in P){let C=P[Q];yield[Q,Q,T],yield[Q,C,A]}},validator(P){return Q4(P)||`Expected an object, but received: ${Y0(P)}`},coercer(P){return Q4(P)?{...P}:P}})}function l(){return T8("string",(T)=>{return typeof T==="string"||`Expected a string, but received: ${Y0(T)}`})}function W4(T){let A=aM();return new Z0({type:"tuple",schema:null,*entries(P){if(Array.isArray(P)){let Q=Math.max(T.length,P.length);for(let C=0;C<Q;C++)yield[C,P[C],T[C]||A]}},validator(P){return Array.isArray(P)||`Expected an array, but received: ${Y0(P)}`},coercer(P){return Array.isArray(P)?P.slice():P}})}function v(T){let A=Object.keys(T);return new Z0({type:"type",schema:T,*entries(P){if(Z2(P))for(let Q of A)yield[Q,P[Q],T[Q]]},validator(P){return Q4(P)||`Expected an object, but received: ${Y0(P)}`},coercer(P){return Q4(P)?{...P}:P}})}function IT(T){let A=T.map((P)=>P.type).join(" | ");return new Z0({type:"union",schema:null,coercer(P,Q){for(let C of T){let[W,G]=C.validate(P,{coerce:!0,mask:Q.mask});if(!W)return G}return P},validator(P,Q){let C=[];for(let W of T){let[...G]=pC(P,W,Q),[J]=G;if(!J[0])return[];else for(let[$]of G)if($)C.push($)}return[`Expected the value to satisfy a union of \`${A}\`, but received: ${Y0(P)}`,...C]}})}function A8(){return T8("unknown",()=>!0)}function O8(T,A,P){return new Z0({...T,coercer:(Q,C)=>{return b9(Q,A)?T.coercer(P(Q,C),C):T.coercer(Q,C)}})}var uz=yT($V(),1);j8();var YV=yT(qV(),1);var zz=BigInt(0),M2=BigInt(1),Iz=BigInt(2),Sz=BigInt(7),Nz=BigInt(256),wz=BigInt(113),HV=[],KV=[],RV=[];for(let T=0,A=M2,P=1,Q=0;T<24;T++){[P,Q]=[Q,(2*P+3*Q)%5],HV.push(2*(5*Q+P)),KV.push((T+1)*(T+2)/2%64);let C=zz;for(let W=0;W<7;W++)if(A=(A<<M2^(A>>Sz)*wz)%Nz,A&Iz)C^=M2<<(M2<<BigInt(W))-M2;RV.push(C)}var kV=v6(RV,!0),Lz=kV[0],Ez=kV[1],ZV=(T,A,P)=>P>32?S$(T,A,P):z$(T,A,P),XV=(T,A,P)=>P>32?N$(T,A,P):I$(T,A,P);function Bz(T,A=24){let P=new Uint32Array(10);for(let Q=24-A;Q<24;Q++){for(let G=0;G<10;G++)P[G]=T[G]^T[G+10]^T[G+20]^T[G+30]^T[G+40];for(let G=0;G<10;G+=2){let J=(G+8)%10,$=(G+2)%10,X=P[$],Z=P[$+1],R=ZV(X,Z,1)^P[J],D=XV(X,Z,1)^P[J+1];for(let z=0;z<50;z+=10)T[G+z]^=R,T[G+z+1]^=D}let C=T[2],W=T[3];for(let G=0;G<24;G++){let J=KV[G],$=ZV(C,W,J),X=XV(C,W,J),Z=HV[G];C=T[Z],W=T[Z+1],T[Z]=$,T[Z+1]=X}for(let G=0;G<50;G+=10){for(let J=0;J<10;J++)P[J]=T[G+J];for(let J=0;J<10;J++)T[G+J]^=~P[(J+2)%10]&P[(J+4)%10]}T[0]^=Lz[Q],T[1]^=Ez[Q]}U0(P)}class eC extends cA{constructor(T,A,P,Q=!1,C=24){super();if(this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=T,this.suffix=A,this.outputLen=P,this.enableXOF=Q,this.rounds=C,KA(P),!(0<T&&T<200))throw Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=k$(this.state)}clone(){return this._cloneInto()}keccak(){hQ(this.state32),Bz(this.state32,this.rounds),hQ(this.state32),this.posOut=0,this.pos=0}update(T){a0(this),T=rA(T),KT(T);let{blockLen:A,state:P}=this,Q=T.length;for(let C=0;C<Q;){let W=Math.min(A-this.pos,Q-C);for(let G=0;G<W;G++)P[this.pos++]^=T[C++];if(this.pos===A)this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:T,suffix:A,pos:P,blockLen:Q}=this;if(T[P]^=A,(A&128)!==0&&P===Q-1)this.keccak();T[Q-1]^=128,this.keccak()}writeInto(T){a0(this,!1),KT(T),this.finish();let A=this.state,{blockLen:P}=this;for(let Q=0,C=T.length;Q<C;){if(this.posOut>=P)this.keccak();let W=Math.min(P-this.posOut,C-Q);T.set(A.subarray(this.posOut,this.posOut+W),Q),this.posOut+=W,Q+=W}return T}xofInto(T){if(!this.enableXOF)throw Error("XOF is not possible for this instance");return this.writeInto(T)}xof(T){return KA(T),this.xofInto(new Uint8Array(T))}digestInto(T){if(_6(T,this),this.finished)throw Error("digest() was already called");return this.writeInto(T),this.destroy(),T}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,U0(this.state)}_cloneInto(T){let{blockLen:A,suffix:P,outputLen:Q,rounds:C,enableXOF:W}=this;return T||(T=new eC(A,P,Q,W,C)),T.state32.set(this.state32),T.pos=this.pos,T.posOut=this.posOut,T.finished=this.finished,T.rounds=C,T.suffix=P,T.outputLen=Q,T.enableXOF=W,T.destroyed=this.destroyed,T}}var Oz=(T,A,P)=>Q2(()=>new eC(A,T,P));var TW=(()=>Oz(1,136,32))();class AW extends cA{constructor(T,A){super();this.finished=!1,this.destroyed=!1,x6(T);let P=rA(A);if(this.iHash=T.create(),typeof this.iHash.update!=="function")throw Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let Q=this.blockLen,C=new Uint8Array(Q);C.set(P.length>Q?T.create().update(P).digest():P);for(let W=0;W<C.length;W++)C[W]^=54;this.iHash.update(C),this.oHash=T.create();for(let W=0;W<C.length;W++)C[W]^=106;this.oHash.update(C),U0(C)}update(T){return a0(this),this.iHash.update(T),this}digestInto(T){a0(this),KT(T,this.outputLen),this.finished=!0,this.iHash.digestInto(T),this.oHash.update(T),this.oHash.digestInto(T),this.destroy()}digest(){let T=new Uint8Array(this.oHash.outputLen);return this.digestInto(T),T}_cloneInto(T){T||(T=Object.create(Object.getPrototypeOf(this),{}));let{oHash:A,iHash:P,finished:Q,destroyed:C,blockLen:W,outputLen:G}=this;return T=T,T.finished=Q,T.destroyed=C,T.blockLen=W,T.outputLen=G,T.oHash=A._cloneInto(T.oHash),T.iHash=P._cloneInto(T.iHash),T}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}var PW=(T,A,P)=>new AW(T,A).update(P).digest();PW.create=(T,A)=>new AW(T,A);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var jV=(T,A)=>(T+(T>=0?A:-A)/FV)/A;function xz(T,A,P){let[[Q,C],[W,G]]=A,J=jV(G*T,P),$=jV(-C*T,P),X=T-J*Q-$*W,Z=-J*C-$*G,R=X<UA,D=Z<UA;if(R)X=-X;if(D)Z=-Z;let z=DA(Math.ceil(l6(P)/2))+_8;if(X<UA||X>=z||Z<UA||Z>=z)throw Error("splitScalar (endomorphism): failed, k="+T);return{k1neg:R,k1:X,k2neg:D,k2:Z}}function CW(T){if(!["compact","recovered","der"].includes(T))throw Error('Signature format must be "compact", "recovered", or "der"');return T}function QW(T,A){let P={};for(let Q of Object.keys(A))P[Q]=T[Q]===void 0?A[Q]:T[Q];if(t0(P.lowS,"lowS"),t0(P.prehash,"prehash"),P.format!==void 0)CW(P.format);return P}class DV extends Error{constructor(T=""){super(T)}}var GA={Err:DV,_tlv:{encode:(T,A)=>{let{Err:P}=GA;if(T<0||T>256)throw new P("tlv.encode: wrong tag");if(A.length&1)throw new P("tlv.encode: unpadded data");let Q=A.length/2,C=G2(Q);if(C.length/2&128)throw new P("tlv.encode: long form length too big");let W=Q>127?G2(C.length/2|128):"";return G2(T)+W+C+A},decode(T,A){let{Err:P}=GA,Q=0;if(T<0||T>256)throw new P("tlv.encode: wrong tag");if(A.length<2||A[Q++]!==T)throw new P("tlv.decode: wrong tlv");let C=A[Q++],W=!!(C&128),G=0;if(!W)G=C;else{let $=C&127;if(!$)throw new P("tlv.decode(long): indefinite length not supported");if($>4)throw new P("tlv.decode(long): byte length is too big");let X=A.subarray(Q,Q+$);if(X.length!==$)throw new P("tlv.decode: length bytes not complete");if(X[0]===0)throw new P("tlv.decode(long): zero leftmost byte");for(let Z of X)G=G<<8|Z;if(Q+=$,G<128)throw new P("tlv.decode(long): not minimal encoding")}let J=A.subarray(Q,Q+G);if(J.length!==G)throw new P("tlv.decode: wrong value length");return{v:J,l:A.subarray(Q+G)}}},_int:{encode(T){let{Err:A}=GA;if(T<UA)throw new A("integer: negative integers are not allowed");let P=G2(T);if(Number.parseInt(P[0],16)&8)P="00"+P;if(P.length&1)throw new A("unexpected DER parsing assertion: unpadded hex");return P},decode(T){let{Err:A}=GA;if(T[0]&128)throw new A("invalid signature integer: negative");if(T[0]===0&&!(T[1]&128))throw new A("invalid signature integer: unnecessary leading zero");return F8(T)}},toSig(T){let{Err:A,_int:P,_tlv:Q}=GA,C=q1("signature",T),{v:W,l:G}=Q.decode(48,C);if(G.length)throw new A("invalid signature: left bytes after parsing");let{v:J,l:$}=Q.decode(2,W),{v:X,l:Z}=Q.decode(2,$);if(Z.length)throw new A("invalid signature: left bytes after parsing");return{r:P.decode(J),s:P.decode(X)}},hexFromSig(T){let{_tlv:A,_int:P}=GA,Q=A.encode(2,P.encode(T.r)),C=A.encode(2,P.encode(T.s)),W=Q+C;return A.encode(48,W)}},UA=BigInt(0),_8=BigInt(1),FV=BigInt(2),V4=BigInt(3),_z=BigInt(4);function x8(T,A){let{BYTES:P}=T,Q;if(typeof A==="bigint")Q=A;else{let C=q1("private key",A);try{Q=T.fromBytes(C)}catch(W){throw Error(`invalid private key: expected ui8a of size ${P}, got ${typeof A}`)}}if(!T.isValidNot0(Q))throw Error("invalid private key: out of range [1..N-1]");return Q}function hz(T,A={}){let P=u6("weierstrass",T,A),{Fp:Q,Fn:C}=P,W=P.CURVE,{h:G,n:J}=W;FA(A,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});let{endo:$}=A;if($){if(!Q.is0(W.a)||typeof $.beta!=="bigint"||!Array.isArray($.basises))throw Error('invalid endo: expected "beta": bigint and "basises": array')}let X=zV(Q,C);function Z(){if(!Q.isOdd)throw Error("compression is not supported: Field does not have .isOdd()")}function R(x,k,U){let{x:V,y:Y}=k.toAffine(),H=Q.toBytes(V);if(t0(U,"isCompressed"),U){Z();let K=!Q.isOdd(Y);return xT(MV(K),H)}else return xT(Uint8Array.of(4),H,Q.toBytes(Y))}function D(x){sT(x,void 0,"Point");let{publicKey:k,publicKeyUncompressed:U}=X,V=x.length,Y=x[0],H=x.subarray(1);if(V===k&&(Y===2||Y===3)){let K=Q.fromBytes(H);if(!Q.isValid(K))throw Error("bad point: is not on curve, wrong x");let M=E(K),I;try{I=Q.sqrt(M)}catch(F){let y=F instanceof Error?": "+F.message:"";throw Error("bad point: is not on curve, sqrt error"+y)}Z();let j=Q.isOdd(I);if((Y&1)===1!==j)I=Q.neg(I);return{x:K,y:I}}else if(V===U&&Y===4){let K=Q.BYTES,M=Q.fromBytes(H.subarray(0,K)),I=Q.fromBytes(H.subarray(K,K*2));if(!w(M,I))throw Error("bad point: is not on curve");return{x:M,y:I}}else throw Error(`bad point: got length ${V}, expected compressed=${k} or uncompressed=${U}`)}let z=A.toBytes||R,S=A.fromBytes||D;function E(x){let k=Q.sqr(x),U=Q.mul(k,x);return Q.add(Q.add(U,Q.mul(x,W.a)),W.b)}function w(x,k){let U=Q.sqr(k),V=E(x);return Q.eql(U,V)}if(!w(W.Gx,W.Gy))throw Error("bad curve params: generator point");let O=Q.mul(Q.pow(W.a,V4),_z),m=Q.mul(Q.sqr(W.b),BigInt(27));if(Q.is0(Q.add(O,m)))throw Error("bad curve params: a or b");function g(x,k,U=!1){if(!Q.isValid(k)||U&&Q.is0(k))throw Error(`bad point coordinate ${x}`);return k}function p(x){if(!(x instanceof _))throw Error("ProjectivePoint expected")}function c(x){if(!$||!$.basises)throw Error("no endo");return xz(x,$.basises,C.ORDER)}let o=M8((x,k)=>{let{X:U,Y:V,Z:Y}=x;if(Q.eql(Y,Q.ONE))return{x:U,y:V};let H=x.is0();if(k==null)k=H?Q.ONE:Q.inv(Y);let K=Q.mul(U,k),M=Q.mul(V,k),I=Q.mul(Y,k);if(H)return{x:Q.ZERO,y:Q.ZERO};if(!Q.eql(I,Q.ONE))throw Error("invZ was invalid");return{x:K,y:M}}),f=M8((x)=>{if(x.is0()){if(A.allowInfinityPoint&&!Q.is0(x.Y))return;throw Error("bad point: ZERO")}let{x:k,y:U}=x.toAffine();if(!Q.isValid(k)||!Q.isValid(U))throw Error("bad point: x or y not field elements");if(!w(k,U))throw Error("bad point: equation left != right");if(!x.isTorsionFree())throw Error("bad point: not in prime-order subgroup");return!0});function d(x,k,U,V,Y){return U=new _(Q.mul(U.X,x),U.Y,U.Z),k=$2(V,k),U=$2(Y,U),k.add(U)}class _{constructor(x,k,U){this.X=g("x",x),this.Y=g("y",k,!0),this.Z=g("z",U),Object.freeze(this)}static CURVE(){return W}static fromAffine(x){let{x:k,y:U}=x||{};if(!x||!Q.isValid(k)||!Q.isValid(U))throw Error("invalid affine point");if(x instanceof _)throw Error("projective point not allowed");if(Q.is0(k)&&Q.is0(U))return _.ZERO;return new _(k,U,Q.ONE)}static fromBytes(x){let k=_.fromAffine(S(sT(x,void 0,"point")));return k.assertValidity(),k}static fromHex(x){return _.fromBytes(q1("pointHex",x))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(x=8,k=!0){if(i.createCache(this,x),!k)this.multiply(V4);return this}assertValidity(){f(this)}hasEvenY(){let{y:x}=this.toAffine();if(!Q.isOdd)throw Error("Field doesn't support isOdd");return!Q.isOdd(x)}equals(x){p(x);let{X:k,Y:U,Z:V}=this,{X:Y,Y:H,Z:K}=x,M=Q.eql(Q.mul(k,K),Q.mul(Y,V)),I=Q.eql(Q.mul(U,K),Q.mul(H,V));return M&&I}negate(){return new _(this.X,Q.neg(this.Y),this.Z)}double(){let{a:x,b:k}=W,U=Q.mul(k,V4),{X:V,Y,Z:H}=this,K=Q.ZERO,M=Q.ZERO,I=Q.ZERO,j=Q.mul(V,V),q=Q.mul(Y,Y),F=Q.mul(H,H),y=Q.mul(V,Y);return y=Q.add(y,y),I=Q.mul(V,H),I=Q.add(I,I),K=Q.mul(x,I),M=Q.mul(U,F),M=Q.add(K,M),K=Q.sub(q,M),M=Q.add(q,M),M=Q.mul(K,M),K=Q.mul(y,K),I=Q.mul(U,I),F=Q.mul(x,F),y=Q.sub(j,F),y=Q.mul(x,y),y=Q.add(y,I),I=Q.add(j,j),j=Q.add(I,j),j=Q.add(j,F),j=Q.mul(j,y),M=Q.add(M,j),F=Q.mul(Y,H),F=Q.add(F,F),j=Q.mul(F,y),K=Q.sub(K,j),I=Q.mul(F,q),I=Q.add(I,I),I=Q.add(I,I),new _(K,M,I)}add(x){p(x);let{X:k,Y:U,Z:V}=this,{X:Y,Y:H,Z:K}=x,M=Q.ZERO,I=Q.ZERO,j=Q.ZERO,q=W.a,F=Q.mul(W.b,V4),y=Q.mul(k,Y),r=Q.mul(U,H),u=Q.mul(V,K),T1=Q.add(k,U),P1=Q.add(Y,H);T1=Q.mul(T1,P1),P1=Q.add(y,r),T1=Q.sub(T1,P1),P1=Q.add(k,V);let Q1=Q.add(Y,K);return P1=Q.mul(P1,Q1),Q1=Q.add(y,u),P1=Q.sub(P1,Q1),Q1=Q.add(U,V),M=Q.add(H,K),Q1=Q.mul(Q1,M),M=Q.add(r,u),Q1=Q.sub(Q1,M),j=Q.mul(q,P1),M=Q.mul(F,u),j=Q.add(M,j),M=Q.sub(r,j),j=Q.add(r,j),I=Q.mul(M,j),r=Q.add(y,y),r=Q.add(r,y),u=Q.mul(q,u),P1=Q.mul(F,P1),r=Q.add(r,u),u=Q.sub(y,u),u=Q.mul(q,u),P1=Q.add(P1,u),y=Q.mul(r,P1),I=Q.add(I,y),y=Q.mul(Q1,P1),M=Q.mul(T1,M),M=Q.sub(M,y),y=Q.mul(T1,r),j=Q.mul(Q1,j),j=Q.add(j,y),new _(M,I,j)}subtract(x){return this.add(x.negate())}is0(){return this.equals(_.ZERO)}multiply(x){let{endo:k}=A;if(!C.isValidNot0(x))throw Error("invalid scalar: out of range");let U,V,Y=(H)=>i.cached(this,H,(K)=>AA(_,K));if(k){let{k1neg:H,k1:K,k2neg:M,k2:I}=c(x),{p:j,f:q}=Y(K),{p:F,f:y}=Y(I);V=q.add(y),U=d(k.beta,j,F,H,M)}else{let{p:H,f:K}=Y(x);U=H,V=K}return AA(_,[U,V])[0]}multiplyUnsafe(x){let{endo:k}=A,U=this;if(!C.isValid(x))throw Error("invalid scalar: out of range");if(x===UA||U.is0())return _.ZERO;if(x===_8)return U;if(i.hasCache(this))return this.multiply(x);if(k){let{k1neg:V,k1:Y,k2neg:H,k2:K}=c(x),{p1:M,p2:I}=A9(_,U,Y,K);return d(k.beta,M,I,V,H)}else return i.unsafe(U,x)}multiplyAndAddUnsafe(x,k,U){let V=this.multiplyUnsafe(k).add(x.multiplyUnsafe(U));return V.is0()?void 0:V}toAffine(x){return o(this,x)}isTorsionFree(){let{isTorsionFree:x}=A;if(G===_8)return!0;if(x)return x(_,this);return i.unsafe(this,J).is0()}clearCofactor(){let{clearCofactor:x}=A;if(G===_8)return this;if(x)return x(_,this);return this.multiplyUnsafe(G)}isSmallOrder(){return this.multiplyUnsafe(G).is0()}toBytes(x=!0){return t0(x,"isCompressed"),this.assertValidity(),z(_,this,x)}toHex(x=!0){return J0(this.toBytes(x))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(x=!0){return this.toBytes(x)}_setWindowSize(x){this.precompute(x)}static normalizeZ(x){return AA(_,x)}static msm(x,k){return I8(_,C,x,k)}static fromPrivateKey(x){return _.BASE.multiply(x8(C,x))}}_.BASE=new _(W.Gx,W.Gy,Q.ONE),_.ZERO=new _(Q.ZERO,Q.ONE,Q.ZERO),_.Fp=Q,_.Fn=C;let t=C.BITS,i=new V2(_,A.endo?Math.ceil(t/2):t);return _.BASE.precompute(8),_}function MV(T){return Uint8Array.of(T?2:3)}function zV(T,A){return{secretKey:A.BYTES,publicKey:1+T.BYTES,publicKeyUncompressed:1+2*T.BYTES,publicKeyHasPrefix:!0,signature:2*A.BYTES}}function mz(T,A={}){let{Fn:P}=T,Q=A.randomBytes||D8,C=Object.assign(zV(T.Fp,P),{seed:nQ(P.ORDER)});function W(z){try{return!!x8(P,z)}catch(S){return!1}}function G(z,S){let{publicKey:E,publicKeyUncompressed:w}=C;try{let O=z.length;if(S===!0&&O!==E)return!1;if(S===!1&&O!==w)return!1;return!!T.fromBytes(z)}catch(O){return!1}}function J(z=Q(C.seed)){return fQ(sT(z,C.seed,"seed"),P.ORDER)}function $(z,S=!0){return T.BASE.multiply(x8(P,z)).toBytes(S)}function X(z){let S=J(z);return{secretKey:S,publicKey:$(S)}}function Z(z){if(typeof z==="bigint")return!1;if(z instanceof T)return!0;let{secretKey:S,publicKey:E,publicKeyUncompressed:w}=C;if(P.allowedLengths||S===E)return;let O=q1("key",z).length;return O===E||O===w}function R(z,S,E=!0){if(Z(z)===!0)throw Error("first arg must be private key");if(Z(S)===!1)throw Error("second arg must be public key");let w=x8(P,z);return T.fromHex(S).multiply(w).toBytes(E)}return Object.freeze({getPublicKey:$,getSharedSecret:R,keygen:X,Point:T,utils:{isValidSecretKey:W,isValidPublicKey:G,randomSecretKey:J,isValidPrivateKey:W,randomPrivateKey:J,normPrivateKeyToScalar:(z)=>x8(P,z),precompute(z=8,S=T.BASE){return S.precompute(z,!1)}},lengths:C})}function gz(T,A,P={}){x6(A),FA(P,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let Q=P.randomBytes||D8,C=P.hmac||((U,...V)=>PW(A,U,xT(...V))),{Fp:W,Fn:G}=T,{ORDER:J,BITS:$}=G,{keygen:X,getPublicKey:Z,getSharedSecret:R,utils:D,lengths:z}=mz(T,P),S={prehash:!1,lowS:typeof P.lowS==="boolean"?P.lowS:!1,format:void 0,extraEntropy:!1},E="compact";function w(U){let V=J>>_8;return U>V}function O(U,V){if(!G.isValidNot0(V))throw Error(`invalid signature ${U}: out of range 1..Point.Fn.ORDER`);return V}function m(U,V){CW(V);let Y=z.signature,H=V==="compact"?Y:V==="recovered"?Y+1:void 0;return sT(U,H,`${V} signature`)}class g{constructor(U,V,Y){if(this.r=O("r",U),this.s=O("s",V),Y!=null)this.recovery=Y;Object.freeze(this)}static fromBytes(U,V=E){m(U,V);let Y;if(V==="der"){let{r:I,s:j}=GA.toSig(sT(U));return new g(I,j)}if(V==="recovered")Y=U[0],V="compact",U=U.subarray(1);let H=G.BYTES,K=U.subarray(0,H),M=U.subarray(H,H*2);return new g(G.fromBytes(K),G.fromBytes(M),Y)}static fromHex(U,V){return this.fromBytes(dA(U),V)}addRecoveryBit(U){return new g(this.r,this.s,U)}recoverPublicKey(U){let V=W.ORDER,{r:Y,s:H,recovery:K}=this;if(K==null||![0,1,2,3].includes(K))throw Error("recovery id invalid");if(J*FV<V&&K>1)throw Error("recovery id is ambiguous for h>1 curve");let I=K===2||K===3?Y+J:Y;if(!W.isValid(I))throw Error("recovery id 2 or 3 invalid");let j=W.toBytes(I),q=T.fromBytes(xT(MV((K&1)===0),j)),F=G.inv(I),y=c(q1("msgHash",U)),r=G.create(-y*F),u=G.create(H*F),T1=T.BASE.multiplyUnsafe(r).add(q.multiplyUnsafe(u));if(T1.is0())throw Error("point at infinify");return T1.assertValidity(),T1}hasHighS(){return w(this.s)}toBytes(U=E){if(CW(U),U==="der")return dA(GA.hexFromSig(this));let V=G.toBytes(this.r),Y=G.toBytes(this.s);if(U==="recovered"){if(this.recovery==null)throw Error("recovery bit must be present");return xT(Uint8Array.of(this.recovery),V,Y)}return xT(V,Y)}toHex(U){return J0(this.toBytes(U))}assertValidity(){}static fromCompact(U){return g.fromBytes(q1("sig",U),"compact")}static fromDER(U){return g.fromBytes(q1("sig",U),"der")}normalizeS(){return this.hasHighS()?new g(this.r,G.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return J0(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return J0(this.toBytes("compact"))}}let p=P.bits2int||function(V){if(V.length>8192)throw Error("input is too large");let Y=F8(V),H=V.length*8-$;return H>0?Y>>BigInt(H):Y},c=P.bits2int_modN||function(V){return G.create(p(V))},o=DA($);function f(U){return U2("num < 2^"+$,U,UA,o),G.toBytes(U)}function d(U,V){return sT(U,void 0,"message"),V?sT(A(U),void 0,"prehashed message"):U}function _(U,V,Y){if(["recovered","canonical"].some((u)=>(u in Y)))throw Error("sign() legacy options not supported");let{lowS:H,prehash:K,extraEntropy:M}=QW(Y,S);U=d(U,K);let I=c(U),j=x8(G,V),q=[f(j),f(I)];if(M!=null&&M!==!1){let u=M===!0?Q(z.secretKey):M;q.push(q1("extraEntropy",u))}let F=xT(...q),y=I;function r(u){let T1=p(u);if(!G.isValidNot0(T1))return;let P1=G.inv(T1),Q1=T.BASE.multiply(T1).toAffine(),vT=G.create(Q1.x);if(vT===UA)return;let $1=G.create(P1*G.create(y+vT*j));if($1===UA)return;let Z1=(Q1.x===vT?0:2)|Number(Q1.y&_8),b8=$1;if(H&&w($1))b8=G.neg($1),Z1^=1;return new g(vT,b8,Z1)}return{seed:F,k2sig:r}}function t(U,V,Y={}){U=q1("message",U);let{seed:H,k2sig:K}=_(U,V,Y);return b$(A.outputLen,G.BYTES,C)(H,K)}function i(U){let V=void 0,Y=typeof U==="string"||i0(U),H=!Y&&U!==null&&typeof U==="object"&&typeof U.r==="bigint"&&typeof U.s==="bigint";if(!Y&&!H)throw Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(H)V=new g(U.r,U.s);else if(Y){try{V=g.fromBytes(q1("sig",U),"der")}catch(K){if(!(K instanceof GA.Err))throw K}if(!V)try{V=g.fromBytes(q1("sig",U),"compact")}catch(K){return!1}}if(!V)return!1;return V}function x(U,V,Y,H={}){let{lowS:K,prehash:M,format:I}=QW(H,S);if(Y=q1("publicKey",Y),V=d(q1("message",V),M),"strict"in H)throw Error("options.strict was renamed to lowS");let j=I===void 0?i(U):g.fromBytes(q1("sig",U),I);if(j===!1)return!1;try{let q=T.fromBytes(Y);if(K&&j.hasHighS())return!1;let{r:F,s:y}=j,r=c(V),u=G.inv(y),T1=G.create(r*u),P1=G.create(F*u),Q1=T.BASE.multiplyUnsafe(T1).add(q.multiplyUnsafe(P1));if(Q1.is0())return!1;return G.create(Q1.x)===F}catch(q){return!1}}function k(U,V,Y={}){let{prehash:H}=QW(Y,S);return V=d(V,H),g.fromBytes(U,"recovered").recoverPublicKey(V).toBytes()}return Object.freeze({keygen:X,getPublicKey:Z,getSharedSecret:R,utils:D,lengths:z,Point:T,sign:t,verify:x,recoverPublicKey:k,Signature:g,hash:A})}function vz(T){let A={a:T.a,b:T.b,p:T.Fp.ORDER,n:T.n,h:T.h,Gx:T.Gx,Gy:T.Gy},P=T.Fp,Q=T.allowedPrivateKeyLengths?Array.from(new Set(T.allowedPrivateKeyLengths.map((G)=>Math.ceil(G/2)))):void 0,C=tT(A.n,{BITS:T.nBitLength,allowedLengths:Q,modFromBytes:T.wrapPrivateKey}),W={Fp:P,Fn:C,allowInfinityPoint:T.allowInfinityPoint,endo:T.endo,isTorsionFree:T.isTorsionFree,clearCofactor:T.clearCofactor,fromBytes:T.fromBytes,toBytes:T.toBytes};return{CURVE:A,curveOpts:W}}function yz(T){let{CURVE:A,curveOpts:P}=vz(T),Q={hmac:T.hmac,randomBytes:T.randomBytes,lowS:T.lowS,bits2int:T.bits2int,bits2int_modN:T.bits2int_modN};return{CURVE:A,curveOpts:P,hash:T.hash,ecdsaOpts:Q}}function bz(T,A){let P=A.Point;return Object.assign({},A,{ProjectivePoint:P,CURVE:Object.assign({},T,p6(P.Fn.ORDER,P.Fn.BITS))})}function IV(T){let{CURVE:A,curveOpts:P,hash:Q,ecdsaOpts:C}=yz(T),W=hz(A,P),G=gz(W,Q,C);return bz(T,G)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function SV(T,A){let P=(Q)=>IV({...T,hash:Q});return{...P(A),create:P}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var GW={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},lz={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var NV=BigInt(2);function pz(T){let A=GW.p,P=BigInt(3),Q=BigInt(6),C=BigInt(11),W=BigInt(22),G=BigInt(23),J=BigInt(44),$=BigInt(88),X=T*T*T%A,Z=X*X*T%A,R=R1(Z,P,A)*Z%A,D=R1(R,P,A)*Z%A,z=R1(D,NV,A)*X%A,S=R1(z,C,A)*z%A,E=R1(S,W,A)*S%A,w=R1(E,J,A)*E%A,O=R1(w,$,A)*w%A,m=R1(O,J,A)*E%A,g=R1(m,P,A)*Z%A,p=R1(g,G,A)*S%A,c=R1(p,Q,A)*X%A,o=R1(c,NV,A);if(!WW.eql(WW.sqr(o),T))throw Error("Cannot find square root");return o}var WW=tT(GW.p,{sqrt:pz}),q4=SV({...GW,Fp:WW,lowS:!0,endo:lz},y6);var T_=cT.utils.randomPrivateKey,wV=()=>{let T=cT.utils.randomPrivateKey(),A=YW(T),P=new Uint8Array(64);return P.set(T),P.set(A,32),{publicKey:A,secretKey:P}},YW=cT.getPublicKey;function LV(T){try{return cT.ExtendedPoint.fromHex(T),!0}catch{return!1}}var lV=(T,A)=>cT.sign(T,A.slice(0,32)),dz=cT.verify,U1=(T)=>{if(L.isBuffer(T))return T;else if(T instanceof Uint8Array)return L.from(T.buffer,T.byteOffset,T.byteLength);else return L.from(T)};class pV{constructor(T){Object.assign(this,T)}encode(){return L.from(g8.serialize(X4,this))}static decode(T){return g8.deserialize(X4,this,T)}static decodeUnchecked(T){return g8.deserializeUnchecked(X4,this,T)}}var X4=new Map,uV,rz=32,L2=32;function cz(T){return T._bn!==void 0}var EV=1;class n extends pV{constructor(T){super({});if(this._bn=void 0,cz(T))this._bn=T._bn;else{if(typeof T==="string"){let A=nT.default.decode(T);if(A.length!=L2)throw Error("Invalid public key input");this._bn=new qW.default(A)}else this._bn=new qW.default(T);if(this._bn.byteLength()>L2)throw Error("Invalid public key input")}}static unique(){let T=new n(EV);return EV+=1,new n(T.toBuffer())}equals(T){return this._bn.eq(T._bn)}toBase58(){return nT.default.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){let T=this.toBuffer();return new Uint8Array(T.buffer,T.byteOffset,T.byteLength)}toBuffer(){let T=this._bn.toArrayLike(L);if(T.length===L2)return T;let A=L.alloc(32);return T.copy(A,32-T.length),A}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(T,A,P){let Q=L.concat([T.toBuffer(),L.from(A),P.toBuffer()]),C=JC(Q);return new n(C)}static createProgramAddressSync(T,A){let P=L.alloc(0);T.forEach(function(C){if(C.length>rz)throw TypeError("Max seed length exceeded");P=L.concat([P,U1(C)])}),P=L.concat([P,A.toBuffer(),L.from("ProgramDerivedAddress")]);let Q=JC(P);if(LV(Q))throw Error("Invalid seeds, address must fall off the curve");return new n(Q)}static async createProgramAddress(T,A){return this.createProgramAddressSync(T,A)}static findProgramAddressSync(T,A){let P=255,Q;while(P!=0){try{let C=T.concat(L.from([P]));Q=this.createProgramAddressSync(C,A)}catch(C){if(C instanceof TypeError)throw C;P--;continue}return[Q,P]}throw Error("Unable to find a viable program address nonce")}static async findProgramAddress(T,A){return this.findProgramAddressSync(T,A)}static isOnCurve(T){let A=new n(T);return LV(A.toBytes())}}uV=n;n.default=new uV("11111111111111111111111111111111");X4.set(n,{kind:"struct",fields:[["_bn","u256"]]});var A_=new n("BPFLoader1111111111111111111111111111111111"),H4=1232,oz=127,dV=64;class rV extends Error{constructor(T){super(`Signature ${T} has expired: block height exceeded.`);this.signature=void 0,this.signature=T}}Object.defineProperty(rV.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});class cV extends Error{constructor(T,A){super(`Transaction was not confirmed in ${A.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${T} using the Solana Explorer or CLI tools.`);this.signature=void 0,this.signature=T}}Object.defineProperty(cV.prototype,"name",{value:"TransactionExpiredTimeoutError"});class oV extends Error{constructor(T){super(`Signature ${T} has expired: the nonce is no longer valid.`);this.signature=void 0,this.signature=T}}Object.defineProperty(oV.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});class ZW{constructor(T,A){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=T,this.accountKeysFromLookups=A}keySegments(){let T=[this.staticAccountKeys];if(this.accountKeysFromLookups)T.push(this.accountKeysFromLookups.writable),T.push(this.accountKeysFromLookups.readonly);return T}get(T){for(let A of this.keySegments())if(T<A.length)return A[T];else T-=A.length;return}get length(){return this.keySegments().flat().length}compileInstructions(T){if(this.length>256)throw Error("Account index overflow encountered during compilation");let P=new Map;this.keySegments().flat().forEach((C,W)=>{P.set(C.toBase58(),W)});let Q=(C)=>{let W=P.get(C.toBase58());if(W===void 0)throw Error("Encountered an unknown instruction account key during compilation");return W};return T.map((C)=>{return{programIdIndex:Q(C.programId),accountKeyIndexes:C.keys.map((W)=>Q(W.pubkey)),data:C.data}})}}var W1=(T="publicKey")=>{return N.blob(32,T)};var h8=(T="string")=>{let A=N.struct([N.u32("length"),N.u32("lengthPadding"),N.blob(N.offset(N.u32(),-8),"chars")],T),P=A.decode.bind(A),Q=A.encode.bind(A),C=A;return C.decode=(W,G)=>{return P(W,G).chars.toString()},C.encode=(W,G,J)=>{let $={chars:L.from(W,"utf8")};return Q($,G,J)},C.alloc=(W)=>{return N.u32().span+N.u32().span+L.from(W,"utf8").length},C},nz=(T="authorized")=>{return N.struct([W1("staker"),W1("withdrawer")],T)},fz=(T="lockup")=>{return N.struct([N.ns64("unixTimestamp"),N.ns64("epoch"),W1("custodian")],T)},iz=(T="voteInit")=>{return N.struct([W1("nodePubkey"),W1("authorizedVoter"),W1("authorizedWithdrawer"),N.u8("commission")],T)},az=(T="voteAuthorizeWithSeedArgs")=>{return N.struct([N.u32("voteAuthorizationType"),W1("currentAuthorityDerivedKeyOwnerPubkey"),h8("currentAuthorityDerivedKeySeed"),W1("newAuthorized")],T)};function nV(T,A){let P=(C)=>{if(C.span>=0)return C.span;else if(typeof C.alloc==="function")return C.alloc(A[C.property]);else if("count"in C&&"elementLayout"in C){let W=A[C.property];if(Array.isArray(W))return W.length*P(C.elementLayout)}else if("fields"in C)return nV({layout:C},A[C.property]);return 0},Q=0;return T.layout.fields.forEach((C)=>{Q+=P(C)}),Q}function S2(T){let A=0,P=0;for(;;){let Q=T.shift();if(A|=(Q&127)<<P*7,P+=1,(Q&128)===0)break}return A}function N2(T,A){let P=A;for(;;){let Q=P&127;if(P>>=7,P==0){T.push(Q);break}else Q|=128,T.push(Q)}}function $T(T,A){if(!T)throw Error(A||"Assertion failed")}class HW{constructor(T,A){this.payer=void 0,this.keyMetaMap=void 0,this.payer=T,this.keyMetaMap=A}static compile(T,A){let P=new Map,Q=(W)=>{let G=W.toBase58(),J=P.get(G);if(J===void 0)J={isSigner:!1,isWritable:!1,isInvoked:!1},P.set(G,J);return J},C=Q(A);C.isSigner=!0,C.isWritable=!0;for(let W of T){Q(W.programId).isInvoked=!0;for(let G of W.keys){let J=Q(G.pubkey);J.isSigner||=G.isSigner,J.isWritable||=G.isWritable}}return new HW(A,P)}getMessageComponents(){let T=[...this.keyMetaMap.entries()];$T(T.length<=256,"Max static account keys length exceeded");let A=T.filter(([,J])=>J.isSigner&&J.isWritable),P=T.filter(([,J])=>J.isSigner&&!J.isWritable),Q=T.filter(([,J])=>!J.isSigner&&J.isWritable),C=T.filter(([,J])=>!J.isSigner&&!J.isWritable),W={numRequiredSignatures:A.length+P.length,numReadonlySignedAccounts:P.length,numReadonlyUnsignedAccounts:C.length};{$T(A.length>0,"Expected at least one writable signer key");let[J]=A[0];$T(J===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}let G=[...A.map(([J])=>new n(J)),...P.map(([J])=>new n(J)),...Q.map(([J])=>new n(J)),...C.map(([J])=>new n(J))];return[W,G]}extractTableLookup(T){let[A,P]=this.drainKeysFoundInLookupTable(T.state.addresses,(W)=>!W.isSigner&&!W.isInvoked&&W.isWritable),[Q,C]=this.drainKeysFoundInLookupTable(T.state.addresses,(W)=>!W.isSigner&&!W.isInvoked&&!W.isWritable);if(A.length===0&&Q.length===0)return;return[{accountKey:T.key,writableIndexes:A,readonlyIndexes:Q},{writable:P,readonly:C}]}drainKeysFoundInLookupTable(T,A){let P=[],Q=[];for(let[C,W]of this.keyMetaMap.entries())if(A(W)){let G=new n(C),J=T.findIndex(($)=>$.equals(G));if(J>=0)$T(J<256,"Max lookup table index exceeded"),P.push(J),Q.push(G),this.keyMetaMap.delete(C)}return[P,Q]}}var fV="Reached end of buffer unexpectedly";function Y4(T){if(T.length===0)throw Error(fV);return T.shift()}function w2(T,...A){let[P]=A;if(A.length===2?P+(A[1]??0)>T.length:P>=T.length)throw Error(fV);return T.splice(...A)}class O2{constructor(T){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=T.header,this.accountKeys=T.accountKeys.map((A)=>new n(A)),this.recentBlockhash=T.recentBlockhash,this.instructions=T.instructions,this.instructions.forEach((A)=>this.indexToProgramIds.set(A.programIdIndex,this.accountKeys[A.programIdIndex]))}get version(){return"legacy"}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map((T)=>({programIdIndex:T.programIdIndex,accountKeyIndexes:T.accounts,data:nT.default.decode(T.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new ZW(this.staticAccountKeys)}static compile(T){let A=HW.compile(T.instructions,T.payerKey),[P,Q]=A.getMessageComponents(),W=new ZW(Q).compileInstructions(T.instructions).map((G)=>({programIdIndex:G.programIdIndex,accounts:G.accountKeyIndexes,data:nT.default.encode(G.data)}));return new O2({header:P,accountKeys:Q,recentBlockhash:T.recentBlockhash,instructions:W})}isAccountSigner(T){return T<this.header.numRequiredSignatures}isAccountWritable(T){let A=this.header.numRequiredSignatures;if(T>=this.header.numRequiredSignatures){let P=T-A,C=this.accountKeys.length-A-this.header.numReadonlyUnsignedAccounts;return P<C}else{let P=A-this.header.numReadonlySignedAccounts;return T<P}}isProgramId(T){return this.indexToProgramIds.has(T)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter((T,A)=>!this.isProgramId(A))}serialize(){let T=this.accountKeys.length,A=[];N2(A,T);let P=this.instructions.map((Z)=>{let{accounts:R,programIdIndex:D}=Z,z=Array.from(nT.default.decode(Z.data)),S=[];N2(S,R.length);let E=[];return N2(E,z.length),{programIdIndex:D,keyIndicesCount:L.from(S),keyIndices:R,dataLength:L.from(E),data:z}}),Q=[];N2(Q,P.length);let C=L.alloc(H4);L.from(Q).copy(C);let W=Q.length;P.forEach((Z)=>{let D=N.struct([N.u8("programIdIndex"),N.blob(Z.keyIndicesCount.length,"keyIndicesCount"),N.seq(N.u8("keyIndex"),Z.keyIndices.length,"keyIndices"),N.blob(Z.dataLength.length,"dataLength"),N.seq(N.u8("userdatum"),Z.data.length,"data")]).encode(Z,C,W);W+=D}),C=C.slice(0,W);let G=N.struct([N.blob(1,"numRequiredSignatures"),N.blob(1,"numReadonlySignedAccounts"),N.blob(1,"numReadonlyUnsignedAccounts"),N.blob(A.length,"keyCount"),N.seq(W1("key"),T,"keys"),W1("recentBlockhash")]),J={numRequiredSignatures:L.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:L.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:L.from([this.header.numReadonlyUnsignedAccounts]),keyCount:L.from(A),keys:this.accountKeys.map((Z)=>U1(Z.toBytes())),recentBlockhash:nT.default.decode(this.recentBlockhash)},$=L.alloc(2048),X=G.encode(J,$);return C.copy($,X),$.slice(0,X+C.length)}static from(T){let A=[...T],P=Y4(A);if(P!==(P&oz))throw Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");let Q=Y4(A),C=Y4(A),W=S2(A),G=[];for(let R=0;R<W;R++){let D=w2(A,0,L2);G.push(new n(L.from(D)))}let J=w2(A,0,L2),$=S2(A),X=[];for(let R=0;R<$;R++){let D=Y4(A),z=S2(A),S=w2(A,0,z),E=S2(A),w=w2(A,0,E),O=nT.default.encode(L.from(w));X.push({programIdIndex:D,accounts:S,data:O})}let Z={header:{numRequiredSignatures:P,numReadonlySignedAccounts:Q,numReadonlyUnsignedAccounts:C},recentBlockhash:nT.default.encode(L.from(J)),accountKeys:G,instructions:X};return new O2(Z)}}var sz=L.alloc(dV).fill(0);class J1{constructor(T){if(this.keys=void 0,this.programId=void 0,this.data=L.alloc(0),this.programId=T.programId,this.keys=T.keys,T.data)this.data=T.data}toJSON(){return{keys:this.keys.map(({pubkey:T,isSigner:A,isWritable:P})=>({pubkey:T.toJSON(),isSigner:A,isWritable:P})),programId:this.programId.toJSON(),data:[...this.data]}}}class K1{get signature(){if(this.signatures.length>0)return this.signatures[0].signature;return null}constructor(T){if(this.signatures=[],this.feePayer=void 0,this.instructions=[],this.recentBlockhash=void 0,this.lastValidBlockHeight=void 0,this.nonceInfo=void 0,this.minNonceContextSlot=void 0,this._message=void 0,this._json=void 0,!T)return;if(T.feePayer)this.feePayer=T.feePayer;if(T.signatures)this.signatures=T.signatures;if(Object.prototype.hasOwnProperty.call(T,"nonceInfo")){let{minContextSlot:A,nonceInfo:P}=T;this.minNonceContextSlot=A,this.nonceInfo=P}else if(Object.prototype.hasOwnProperty.call(T,"lastValidBlockHeight")){let{blockhash:A,lastValidBlockHeight:P}=T;this.recentBlockhash=A,this.lastValidBlockHeight=P}else{let{recentBlockhash:A,nonceInfo:P}=T;if(P)this.nonceInfo=P;this.recentBlockhash=A}}toJSON(){return{recentBlockhash:this.recentBlockhash||null,feePayer:this.feePayer?this.feePayer.toJSON():null,nonceInfo:this.nonceInfo?{nonce:this.nonceInfo.nonce,nonceInstruction:this.nonceInfo.nonceInstruction.toJSON()}:null,instructions:this.instructions.map((T)=>T.toJSON()),signers:this.signatures.map(({publicKey:T})=>{return T.toJSON()})}}add(...T){if(T.length===0)throw Error("No instructions");return T.forEach((A)=>{if("instructions"in A)this.instructions=this.instructions.concat(A.instructions);else if("data"in A&&"programId"in A&&"keys"in A)this.instructions.push(A);else this.instructions.push(new J1(A))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let T,A;if(this.nonceInfo)if(T=this.nonceInfo.nonce,this.instructions[0]!=this.nonceInfo.nonceInstruction)A=[this.nonceInfo.nonceInstruction,...this.instructions];else A=this.instructions;else T=this.recentBlockhash,A=this.instructions;if(!T)throw Error("Transaction recentBlockhash required");if(A.length<1)console.warn("No instructions provided");let P;if(this.feePayer)P=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)P=this.signatures[0].publicKey;else throw Error("Transaction fee payer required");for(let S=0;S<A.length;S++)if(A[S].programId===void 0)throw Error(`Transaction instruction index ${S} has undefined program id`);let Q=[],C=[];A.forEach((S)=>{S.keys.forEach((w)=>{C.push({...w})});let E=S.programId.toString();if(!Q.includes(E))Q.push(E)}),Q.forEach((S)=>{C.push({pubkey:new n(S),isSigner:!1,isWritable:!1})});let W=[];C.forEach((S)=>{let E=S.pubkey.toString(),w=W.findIndex((O)=>{return O.pubkey.toString()===E});if(w>-1)W[w].isWritable=W[w].isWritable||S.isWritable,W[w].isSigner=W[w].isSigner||S.isSigner;else W.push(S)}),W.sort(function(S,E){if(S.isSigner!==E.isSigner)return S.isSigner?-1:1;if(S.isWritable!==E.isWritable)return S.isWritable?-1:1;let w={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return S.pubkey.toBase58().localeCompare(E.pubkey.toBase58(),"en",w)});let G=W.findIndex((S)=>{return S.pubkey.equals(P)});if(G>-1){let[S]=W.splice(G,1);S.isSigner=!0,S.isWritable=!0,W.unshift(S)}else W.unshift({pubkey:P,isSigner:!0,isWritable:!0});for(let S of this.signatures){let E=W.findIndex((w)=>{return w.pubkey.equals(S.publicKey)});if(E>-1){if(!W[E].isSigner)W[E].isSigner=!0,console.warn("Transaction references a signature that is unnecessary, only the fee payer and instruction signer accounts should sign a transaction. This behavior is deprecated and will throw an error in the next major version release.")}else throw Error(`unknown signer: ${S.publicKey.toString()}`)}let J=0,$=0,X=0,Z=[],R=[];W.forEach(({pubkey:S,isSigner:E,isWritable:w})=>{if(E){if(Z.push(S.toString()),J+=1,!w)$+=1}else if(R.push(S.toString()),!w)X+=1});let D=Z.concat(R),z=A.map((S)=>{let{data:E,programId:w}=S;return{programIdIndex:D.indexOf(w.toString()),accounts:S.keys.map((O)=>D.indexOf(O.pubkey.toString())),data:nT.default.encode(E)}});return z.forEach((S)=>{$T(S.programIdIndex>=0),S.accounts.forEach((E)=>$T(E>=0))}),new O2({header:{numRequiredSignatures:J,numReadonlySignedAccounts:$,numReadonlyUnsignedAccounts:X},accountKeys:D,recentBlockhash:T,instructions:z})}_compile(){let T=this.compileMessage(),A=T.accountKeys.slice(0,T.header.numRequiredSignatures);if(this.signatures.length===A.length){if(this.signatures.every((Q,C)=>{return A[C].equals(Q.publicKey)}))return T}return this.signatures=A.map((P)=>({signature:null,publicKey:P})),T}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(T){return(await T.getFeeForMessage(this.compileMessage())).value}setSigners(...T){if(T.length===0)throw Error("No signers");let A=new Set;this.signatures=T.filter((P)=>{let Q=P.toString();if(A.has(Q))return!1;else return A.add(Q),!0}).map((P)=>({signature:null,publicKey:P}))}sign(...T){if(T.length===0)throw Error("No signers");let A=new Set,P=[];for(let C of T){let W=C.publicKey.toString();if(A.has(W))continue;else A.add(W),P.push(C)}this.signatures=P.map((C)=>({signature:null,publicKey:C.publicKey}));let Q=this._compile();this._partialSign(Q,...P)}partialSign(...T){if(T.length===0)throw Error("No signers");let A=new Set,P=[];for(let C of T){let W=C.publicKey.toString();if(A.has(W))continue;else A.add(W),P.push(C)}let Q=this._compile();this._partialSign(Q,...P)}_partialSign(T,...A){let P=T.serialize();A.forEach((Q)=>{let C=lV(P,Q.secretKey);this._addSignature(Q.publicKey,U1(C))})}addSignature(T,A){this._compile(),this._addSignature(T,A)}_addSignature(T,A){$T(A.length===64);let P=this.signatures.findIndex((Q)=>T.equals(Q.publicKey));if(P<0)throw Error(`unknown signer: ${T.toString()}`);this.signatures[P].signature=L.from(A)}verifySignatures(T=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),T)}_getMessageSignednessErrors(T,A){let P={};for(let{signature:Q,publicKey:C}of this.signatures)if(Q===null){if(A)(P.missing||=[]).push(C)}else if(!dz(Q,T,C.toBytes()))(P.invalid||=[]).push(C);return P.invalid||P.missing?P:void 0}serialize(T){let{requireAllSignatures:A,verifySignatures:P}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},T),Q=this.serializeMessage();if(P){let C=this._getMessageSignednessErrors(Q,A);if(C){let W="Signature verification failed.";if(C.invalid)W+=`
|
|
15
|
+
Invalid signature for public key${C.invalid.length===1?"":"(s)"} [\`${C.invalid.map((G)=>G.toBase58()).join("`, `")}\`].`;if(C.missing)W+=`
|
|
16
|
+
Missing signature for public key${C.missing.length===1?"":"(s)"} [\`${C.missing.map((G)=>G.toBase58()).join("`, `")}\`].`;throw Error(W)}}return this._serialize(Q)}_serialize(T){let{signatures:A}=this,P=[];N2(P,A.length);let Q=P.length+A.length*64+T.length,C=L.alloc(Q);return $T(A.length<256),L.from(P).copy(C,0),A.forEach(({signature:W},G)=>{if(W!==null)$T(W.length===64,"signature has invalid length"),L.from(W).copy(C,P.length+G*64)}),T.copy(C,P.length+A.length*64),$T(C.length<=H4,`Transaction too large: ${C.length} > ${H4}`),C}get keys(){return $T(this.instructions.length===1),this.instructions[0].keys.map((T)=>T.pubkey)}get programId(){return $T(this.instructions.length===1),this.instructions[0].programId}get data(){return $T(this.instructions.length===1),this.instructions[0].data}static from(T){let A=[...T],P=S2(A),Q=[];for(let C=0;C<P;C++){let W=w2(A,0,dV);Q.push(nT.default.encode(L.from(W)))}return K1.populate(O2.from(A),Q)}static populate(T,A=[]){let P=new K1;if(P.recentBlockhash=T.recentBlockhash,T.header.numRequiredSignatures>0)P.feePayer=T.accountKeys[0];return A.forEach((Q,C)=>{let W={signature:Q==nT.default.encode(sz)?null:nT.default.decode(Q),publicKey:T.accountKeys[C]};P.signatures.push(W)}),T.instructions.forEach((Q)=>{let C=Q.accounts.map((W)=>{let G=T.accountKeys[W];return{pubkey:G,isSigner:P.signatures.some((J)=>J.publicKey.toString()===G.toString())||T.isAccountSigner(W),isWritable:T.isAccountWritable(W)}});P.instructions.push(new J1({keys:C,programId:T.accountKeys[Q.programIdIndex],data:nT.default.decode(Q.data)}))}),P._message=T,P._json=P.toJSON(),P}}var tz=160,ez=64,TI=tz/ez,AI=1000/TI,JA=new n("SysvarC1ock11111111111111111111111111111111"),P_=new n("SysvarEpochSchedu1e111111111111111111111111"),Q_=new n("Sysvar1nstructions1111111111111111111111111"),UW=new n("SysvarRecentB1ockHashes11111111111111111111"),x2=new n("SysvarRent111111111111111111111111111111111"),C_=new n("SysvarRewards111111111111111111111111111111"),W_=new n("SysvarS1otHashes111111111111111111111111111"),G_=new n("SysvarS1otHistory11111111111111111111111111"),JW=new n("SysvarStakeHistory1111111111111111111111111");class iV extends Error{constructor({action:T,signature:A,transactionMessage:P,logs:Q}){let C=Q?`Logs:
|
|
17
|
+
${JSON.stringify(Q.slice(-10),null,2)}. `:"",W="\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.",G;switch(T){case"send":G=`Transaction ${A} resulted in an error.
|
|
18
|
+
${P}. `+C+"\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.";break;case"simulate":G=`Simulation failed.
|
|
19
|
+
Message: ${P}.
|
|
20
|
+
`+C+"\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.";break;default:G=`Unknown action '${((J)=>J)(T)}'`}super(G);this.signature=void 0,this.transactionMessage=void 0,this.transactionLogs=void 0,this.signature=A,this.transactionMessage=P,this.transactionLogs=Q?Q:void 0}get transactionError(){return{message:this.transactionMessage,logs:Array.isArray(this.transactionLogs)?this.transactionLogs:void 0}}get logs(){let T=this.transactionLogs;if(T!=null&&typeof T==="object"&&"then"in T)return;return T}async getLogs(T){if(!Array.isArray(this.transactionLogs))this.transactionLogs=new Promise((A,P)=>{T.getTransaction(this.signature).then((Q)=>{if(Q&&Q.meta&&Q.meta.logMessages){let C=Q.meta.logMessages;this.transactionLogs=C,A(C)}else P(Error("Log messages not found"))}).catch(P)});return await this.transactionLogs}}async function BV(T,A,P,Q){let C=Q&&{skipPreflight:Q.skipPreflight,preflightCommitment:Q.preflightCommitment||Q.commitment,maxRetries:Q.maxRetries,minContextSlot:Q.minContextSlot},W=await T.sendTransaction(A,P,C),G;if(A.recentBlockhash!=null&&A.lastValidBlockHeight!=null)G=(await T.confirmTransaction({abortSignal:Q?.abortSignal,signature:W,blockhash:A.recentBlockhash,lastValidBlockHeight:A.lastValidBlockHeight},Q&&Q.commitment)).value;else if(A.minNonceContextSlot!=null&&A.nonceInfo!=null){let{nonceInstruction:J}=A.nonceInfo,$=J.keys[0].pubkey;G=(await T.confirmTransaction({abortSignal:Q?.abortSignal,minContextSlot:A.minNonceContextSlot,nonceAccountPubkey:$,nonceValue:A.nonceInfo.nonce,signature:W},Q&&Q.commitment)).value}else{if(Q?.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.");G=(await T.confirmTransaction(W,Q&&Q.commitment)).value}if(G.err){if(W!=null)throw new iV({action:"send",signature:W,transactionMessage:`Status: (${JSON.stringify(G)})`});throw Error(`Transaction ${W} failed (${JSON.stringify(G)})`)}return W}function PI(T){return new Promise((A)=>setTimeout(A,T))}function C1(T,A){let P=T.layout.span>=0?T.layout.span:nV(T,A),Q=L.alloc(P),C=Object.assign({instruction:T.index},A);return T.layout.encode(C,Q),Q}var QI=N.nu64("lamportsPerSignature"),CI=N.struct([N.u32("version"),N.u32("state"),W1("authorizedPubkey"),W1("nonce"),N.struct([QI],"feeCalculator")]),OV=CI.span;function m8(T){let A=bV.blob(8,T),P=A.decode.bind(A),Q=A.encode.bind(A),C=A,W=m9();return C.decode=(G,J)=>{let $=P(G,J);return W.decode($)},C.encode=(G,J,$)=>{let X=W.encode(G);return Q(X,J,$)},C}var V0=Object.freeze({Create:{index:0,layout:N.struct([N.u32("instruction"),N.ns64("lamports"),N.ns64("space"),W1("programId")])},Assign:{index:1,layout:N.struct([N.u32("instruction"),W1("programId")])},Transfer:{index:2,layout:N.struct([N.u32("instruction"),m8("lamports")])},CreateWithSeed:{index:3,layout:N.struct([N.u32("instruction"),W1("base"),h8("seed"),N.ns64("lamports"),N.ns64("space"),W1("programId")])},AdvanceNonceAccount:{index:4,layout:N.struct([N.u32("instruction")])},WithdrawNonceAccount:{index:5,layout:N.struct([N.u32("instruction"),N.ns64("lamports")])},InitializeNonceAccount:{index:6,layout:N.struct([N.u32("instruction"),W1("authorized")])},AuthorizeNonceAccount:{index:7,layout:N.struct([N.u32("instruction"),W1("authorized")])},Allocate:{index:8,layout:N.struct([N.u32("instruction"),N.ns64("space")])},AllocateWithSeed:{index:9,layout:N.struct([N.u32("instruction"),W1("base"),h8("seed"),N.ns64("space"),W1("programId")])},AssignWithSeed:{index:10,layout:N.struct([N.u32("instruction"),W1("base"),h8("seed"),W1("programId")])},TransferWithSeed:{index:11,layout:N.struct([N.u32("instruction"),m8("lamports"),h8("seed"),W1("programId")])},UpgradeNonceAccount:{index:12,layout:N.struct([N.u32("instruction")])}});class UT{constructor(){}static createAccount(T){let A=V0.Create,P=C1(A,{lamports:T.lamports,space:T.space,programId:U1(T.programId.toBuffer())});return new J1({keys:[{pubkey:T.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:T.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:P})}static transfer(T){let A,P;if("basePubkey"in T){let Q=V0.TransferWithSeed;A=C1(Q,{lamports:BigInt(T.lamports),seed:T.seed,programId:U1(T.programId.toBuffer())}),P=[{pubkey:T.fromPubkey,isSigner:!1,isWritable:!0},{pubkey:T.basePubkey,isSigner:!0,isWritable:!1},{pubkey:T.toPubkey,isSigner:!1,isWritable:!0}]}else{let Q=V0.Transfer;A=C1(Q,{lamports:BigInt(T.lamports)}),P=[{pubkey:T.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:T.toPubkey,isSigner:!1,isWritable:!0}]}return new J1({keys:P,programId:this.programId,data:A})}static assign(T){let A,P;if("basePubkey"in T){let Q=V0.AssignWithSeed;A=C1(Q,{base:U1(T.basePubkey.toBuffer()),seed:T.seed,programId:U1(T.programId.toBuffer())}),P=[{pubkey:T.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:T.basePubkey,isSigner:!0,isWritable:!1}]}else{let Q=V0.Assign;A=C1(Q,{programId:U1(T.programId.toBuffer())}),P=[{pubkey:T.accountPubkey,isSigner:!0,isWritable:!0}]}return new J1({keys:P,programId:this.programId,data:A})}static createAccountWithSeed(T){let A=V0.CreateWithSeed,P=C1(A,{base:U1(T.basePubkey.toBuffer()),seed:T.seed,lamports:T.lamports,space:T.space,programId:U1(T.programId.toBuffer())}),Q=[{pubkey:T.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:T.newAccountPubkey,isSigner:!1,isWritable:!0}];if(!T.basePubkey.equals(T.fromPubkey))Q.push({pubkey:T.basePubkey,isSigner:!0,isWritable:!1});return new J1({keys:Q,programId:this.programId,data:P})}static createNonceAccount(T){let A=new K1;if("basePubkey"in T&&"seed"in T)A.add(UT.createAccountWithSeed({fromPubkey:T.fromPubkey,newAccountPubkey:T.noncePubkey,basePubkey:T.basePubkey,seed:T.seed,lamports:T.lamports,space:OV,programId:this.programId}));else A.add(UT.createAccount({fromPubkey:T.fromPubkey,newAccountPubkey:T.noncePubkey,lamports:T.lamports,space:OV,programId:this.programId}));let P={noncePubkey:T.noncePubkey,authorizedPubkey:T.authorizedPubkey};return A.add(this.nonceInitialize(P)),A}static nonceInitialize(T){let A=V0.InitializeNonceAccount,P=C1(A,{authorized:U1(T.authorizedPubkey.toBuffer())}),Q={keys:[{pubkey:T.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:UW,isSigner:!1,isWritable:!1},{pubkey:x2,isSigner:!1,isWritable:!1}],programId:this.programId,data:P};return new J1(Q)}static nonceAdvance(T){let A=V0.AdvanceNonceAccount,P=C1(A),Q={keys:[{pubkey:T.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:UW,isSigner:!1,isWritable:!1},{pubkey:T.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:P};return new J1(Q)}static nonceWithdraw(T){let A=V0.WithdrawNonceAccount,P=C1(A,{lamports:T.lamports});return new J1({keys:[{pubkey:T.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:T.toPubkey,isSigner:!1,isWritable:!0},{pubkey:UW,isSigner:!1,isWritable:!1},{pubkey:x2,isSigner:!1,isWritable:!1},{pubkey:T.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:P})}static nonceAuthorize(T){let A=V0.AuthorizeNonceAccount,P=C1(A,{authorized:U1(T.newAuthorizedPubkey.toBuffer())});return new J1({keys:[{pubkey:T.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:T.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:P})}static allocate(T){let A,P;if("basePubkey"in T){let Q=V0.AllocateWithSeed;A=C1(Q,{base:U1(T.basePubkey.toBuffer()),seed:T.seed,space:T.space,programId:U1(T.programId.toBuffer())}),P=[{pubkey:T.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:T.basePubkey,isSigner:!0,isWritable:!1}]}else{let Q=V0.Allocate;A=C1(Q,{space:T.space}),P=[{pubkey:T.accountPubkey,isSigner:!0,isWritable:!0}]}return new J1({keys:P,programId:this.programId,data:A})}}UT.programId=new n("11111111111111111111111111111111");var WI=H4-300;class K4{constructor(){}static getMinNumSignatures(T){return 2*(Math.ceil(T/K4.chunkSize)+1+1)}static async load(T,A,P,Q,C){{let Z=await T.getMinimumBalanceForRentExemption(C.length),R=await T.getAccountInfo(P.publicKey,"confirmed"),D=null;if(R!==null){if(R.executable)return console.error("Program load failed, account is already executable"),!1;if(R.data.length!==C.length)D=D||new K1,D.add(UT.allocate({accountPubkey:P.publicKey,space:C.length}));if(!R.owner.equals(Q))D=D||new K1,D.add(UT.assign({accountPubkey:P.publicKey,programId:Q}));if(R.lamports<Z)D=D||new K1,D.add(UT.transfer({fromPubkey:A.publicKey,toPubkey:P.publicKey,lamports:Z-R.lamports}))}else D=new K1().add(UT.createAccount({fromPubkey:A.publicKey,newAccountPubkey:P.publicKey,lamports:Z>0?Z:1,space:C.length,programId:Q}));if(D!==null)await BV(T,D,[A,P],{commitment:"confirmed"})}let W=N.struct([N.u32("instruction"),N.u32("offset"),N.u32("bytesLength"),N.u32("bytesLengthPadding"),N.seq(N.u8("byte"),N.offset(N.u32(),-8),"bytes")]),G=K4.chunkSize,J=0,$=C,X=[];while($.length>0){let Z=$.slice(0,G),R=L.alloc(G+16);W.encode({instruction:0,offset:J,bytes:Z,bytesLength:0,bytesLengthPadding:0},R);let D=new K1().add({keys:[{pubkey:P.publicKey,isSigner:!0,isWritable:!0}],programId:Q,data:R});if(X.push(BV(T,D,[A,P],{commitment:"confirmed"})),T._rpcEndpoint.includes("solana.com"))await PI(250);J+=G,$=$.slice(G)}await Promise.all(X);{let Z=N.struct([N.u32("instruction")]),R=L.alloc(Z.span);Z.encode({instruction:1},R);let D=new K1().add({keys:[{pubkey:P.publicKey,isSigner:!0,isWritable:!0},{pubkey:x2,isSigner:!1,isWritable:!1}],programId:Q,data:R}),z="processed",S=await T.sendTransaction(D,[A,P],{preflightCommitment:z}),{context:E,value:w}=await T.confirmTransaction({signature:S,lastValidBlockHeight:D.lastValidBlockHeight,blockhash:D.recentBlockhash},z);if(w.err)throw Error(`Transaction ${S} failed (${JSON.stringify(w)})`);while(!0){try{if(await T.getSlot({commitment:z})>E.slot)break}catch{}await new Promise((O)=>setTimeout(O,Math.round(AI/2)))}}return!0}}K4.chunkSize=WI;var U_=new n("BPFLoader2111111111111111111111111111111111");var J_=globalThis.fetch;var $_={index:1,layout:N.struct([N.u32("typeIndex"),m8("deactivationSlot"),N.nu64("lastExtendedSlot"),N.u8("lastExtendedStartIndex"),N.u8(),N.seq(W1(),N.offset(N.u8(),-1),"authority")])};var z1=O8(C4(n),l(),(T)=>new n(T)),aV=W4([l(),k1("base64")]),KW=O8(C4(L),aV,(T)=>L.from(T[0],"base64"));function sV(T){return IT([v({jsonrpc:k1("2.0"),id:l(),result:T}),v({jsonrpc:k1("2.0"),id:l(),error:v({code:A8(),message:l(),data:A1(l9())})})])}var GI=sV(A8());function H1(T){return O8(sV(T),GI,(A)=>{if("error"in A)return A;else return{...A,result:B8(A.result,T)}})}function H0(T){return H1(v({context:v({slot:B()}),value:T}))}function k4(T){return v({context:v({slot:B()}),value:T})}var UI=v({foundation:B(),foundationTerm:B(),initial:B(),taper:B(),terminal:B()}),V_=H1(a(s(v({epoch:B(),effectiveSlot:B(),amount:B(),postBalance:B(),commission:A1(s(B()))})))),JI=a(v({slot:B(),prioritizationFee:B()})),$I=v({total:B(),validator:B(),foundation:B(),epoch:B()}),VI=v({epoch:B(),slotIndex:B(),slotsInEpoch:B(),absoluteSlot:B(),blockHeight:A1(B()),transactionCount:A1(B())}),qI=v({slotsPerEpoch:B(),leaderScheduleSlotOffset:B(),warmup:X0(),firstNormalEpoch:B(),firstNormalSlot:B()}),YI=uC(l(),a(B())),P8=s(IT([v({}),l()])),ZI=v({err:P8}),XI=k1("receivedSignature"),q_=v({"solana-core":l(),"feature-set":A1(B())}),HI=v({program:l(),programId:z1,parsed:A8()}),KI=v({programId:z1,accounts:a(z1),data:l()}),Y_=H0(v({err:s(IT([v({}),l()])),logs:s(a(l())),accounts:A1(s(a(s(v({executable:X0(),owner:l(),lamports:B(),data:a(l()),rentEpoch:A1(B())}))))),unitsConsumed:A1(B()),returnData:A1(s(v({programId:l(),data:W4([l(),k1("base64")])}))),innerInstructions:A1(s(a(v({index:B(),instructions:a(IT([HI,KI]))}))))})),Z_=H0(v({byIdentity:uC(l(),a(B())),range:v({firstSlot:B(),lastSlot:B()})}));var X_=H1(UI),H_=H1($I),K_=H1(JI),R_=H1(VI),k_=H1(qI),j_=H1(YI),D_=H1(B()),F_=H0(v({total:B(),circulating:B(),nonCirculating:B(),nonCirculatingAccounts:a(z1)})),RI=v({amount:l(),uiAmount:s(B()),decimals:B(),uiAmountString:A1(l())}),M_=H0(a(v({address:z1,amount:l(),uiAmount:s(B()),decimals:B(),uiAmountString:A1(l())}))),z_=H0(a(v({pubkey:z1,account:v({executable:X0(),owner:z1,lamports:B(),data:KW,rentEpoch:B()})}))),XW=v({program:l(),parsed:A8(),space:B()}),I_=H0(a(v({pubkey:z1,account:v({executable:X0(),owner:z1,lamports:B(),data:XW,rentEpoch:B()})}))),S_=H0(a(v({lamports:B(),address:z1}))),RW=v({executable:X0(),owner:z1,lamports:B(),data:KW,rentEpoch:B()}),N_=v({pubkey:z1,account:RW}),kI=O8(IT([C4(L),XW]),IT([aV,XW]),(T)=>{if(Array.isArray(T))return B8(T,KW);else return T}),jI=v({executable:X0(),owner:z1,lamports:B(),data:kI,rentEpoch:B()}),w_=v({pubkey:z1,account:jI}),L_=v({state:IT([k1("active"),k1("inactive"),k1("activating"),k1("deactivating")]),active:B(),inactive:B()}),E_=H1(a(v({signature:l(),slot:B(),err:P8,memo:s(l()),blockTime:A1(s(B()))}))),B_=H1(a(v({signature:l(),slot:B(),err:P8,memo:s(l()),blockTime:A1(s(B()))}))),O_=v({subscription:B(),result:k4(RW)}),DI=v({pubkey:z1,account:RW}),x_=v({subscription:B(),result:k4(DI)}),FI=v({parent:B(),slot:B(),root:B()}),__=v({subscription:B(),result:FI}),MI=IT([v({type:IT([k1("firstShredReceived"),k1("completed"),k1("optimisticConfirmation"),k1("root")]),slot:B(),timestamp:B()}),v({type:k1("createdBank"),parent:B(),slot:B(),timestamp:B()}),v({type:k1("frozen"),slot:B(),timestamp:B(),stats:v({numTransactionEntries:B(),numSuccessfulTransactions:B(),numFailedTransactions:B(),maxTransactionsPerEntry:B()})}),v({type:k1("dead"),slot:B(),timestamp:B(),err:l()})]),h_=v({subscription:B(),result:MI}),m_=v({subscription:B(),result:k4(IT([ZI,XI]))}),g_=v({subscription:B(),result:B()}),v_=v({pubkey:l(),gossip:s(l()),tpu:s(l()),rpc:s(l()),version:s(l())}),xV=v({votePubkey:l(),nodePubkey:l(),activatedStake:B(),epochVoteAccount:X0(),epochCredits:a(W4([B(),B(),B()])),commission:B(),lastVote:B(),rootSlot:s(B())}),y_=H1(v({current:a(xV),delinquent:a(xV)})),zI=IT([k1("processed"),k1("confirmed"),k1("finalized")]),II=v({slot:B(),confirmations:s(B()),err:P8,confirmationStatus:A1(zI)}),b_=H0(a(s(II))),l_=H1(B()),tV=v({accountKey:z1,writableIndexes:a(B()),readonlyIndexes:a(B())}),kW=v({signatures:a(l()),message:v({accountKeys:a(l()),header:v({numRequiredSignatures:B(),numReadonlySignedAccounts:B(),numReadonlyUnsignedAccounts:B()}),instructions:a(v({accounts:a(B()),data:l(),programIdIndex:B()})),recentBlockhash:l(),addressTableLookups:A1(a(tV))})}),eV=v({pubkey:z1,signer:X0(),writable:X0(),source:A1(IT([k1("transaction"),k1("lookupTable")]))}),Tq=v({accountKeys:a(eV),signatures:a(l())}),Aq=v({parsed:A8(),program:l(),programId:z1}),Pq=v({accounts:a(z1),data:l(),programId:z1}),SI=IT([Pq,Aq]),NI=IT([v({parsed:A8(),program:l(),programId:l()}),v({accounts:a(l()),data:l(),programId:l()})]),Qq=O8(SI,NI,(T)=>{if("accounts"in T)return B8(T,Pq);else return B8(T,Aq)}),Cq=v({signatures:a(l()),message:v({accountKeys:a(eV),instructions:a(Qq),recentBlockhash:l(),addressTableLookups:A1(s(a(tV)))})}),R4=v({accountIndex:B(),mint:l(),owner:A1(l()),programId:A1(l()),uiTokenAmount:RI}),Wq=v({writable:a(z1),readonly:a(z1)}),j4=v({err:P8,fee:B(),innerInstructions:A1(s(a(v({index:B(),instructions:a(v({accounts:a(B()),data:l(),programIdIndex:B()}))})))),preBalances:a(B()),postBalances:a(B()),logMessages:A1(s(a(l()))),preTokenBalances:A1(s(a(R4))),postTokenBalances:A1(s(a(R4))),loadedAddresses:A1(Wq),computeUnitsConsumed:A1(B()),costUnits:A1(B())}),jW=v({err:P8,fee:B(),innerInstructions:A1(s(a(v({index:B(),instructions:a(Qq)})))),preBalances:a(B()),postBalances:a(B()),logMessages:A1(s(a(l()))),preTokenBalances:A1(s(a(R4))),postTokenBalances:A1(s(a(R4))),loadedAddresses:A1(Wq),computeUnitsConsumed:A1(B()),costUnits:A1(B())}),v8=IT([k1(0),k1("legacy")]),Q8=v({pubkey:l(),lamports:B(),postBalance:s(B()),rewardType:s(l()),commission:A1(s(B()))}),p_=H1(s(v({blockhash:l(),previousBlockhash:l(),parentSlot:B(),transactions:a(v({transaction:kW,meta:s(j4),version:A1(v8)})),rewards:A1(a(Q8)),blockTime:s(B()),blockHeight:s(B())}))),u_=H1(s(v({blockhash:l(),previousBlockhash:l(),parentSlot:B(),rewards:A1(a(Q8)),blockTime:s(B()),blockHeight:s(B())}))),d_=H1(s(v({blockhash:l(),previousBlockhash:l(),parentSlot:B(),transactions:a(v({transaction:Tq,meta:s(j4),version:A1(v8)})),rewards:A1(a(Q8)),blockTime:s(B()),blockHeight:s(B())}))),r_=H1(s(v({blockhash:l(),previousBlockhash:l(),parentSlot:B(),transactions:a(v({transaction:Cq,meta:s(jW),version:A1(v8)})),rewards:A1(a(Q8)),blockTime:s(B()),blockHeight:s(B())}))),c_=H1(s(v({blockhash:l(),previousBlockhash:l(),parentSlot:B(),transactions:a(v({transaction:Tq,meta:s(jW),version:A1(v8)})),rewards:A1(a(Q8)),blockTime:s(B()),blockHeight:s(B())}))),o_=H1(s(v({blockhash:l(),previousBlockhash:l(),parentSlot:B(),rewards:A1(a(Q8)),blockTime:s(B()),blockHeight:s(B())}))),n_=H1(s(v({blockhash:l(),previousBlockhash:l(),parentSlot:B(),transactions:a(v({transaction:kW,meta:s(j4)})),rewards:A1(a(Q8)),blockTime:s(B())}))),f_=H1(s(v({blockhash:l(),previousBlockhash:l(),parentSlot:B(),signatures:a(l()),blockTime:s(B())}))),i_=H1(s(v({slot:B(),meta:s(j4),blockTime:A1(s(B())),transaction:kW,version:A1(v8)}))),a_=H1(s(v({slot:B(),transaction:Cq,meta:s(jW),blockTime:A1(s(B())),version:A1(v8)}))),s_=H0(v({blockhash:l(),lastValidBlockHeight:B()})),t_=H0(X0()),wI=v({slot:B(),numTransactions:B(),numSlots:B(),samplePeriodSecs:B()}),e_=H1(a(wI)),Th=H0(s(v({feeCalculator:v({lamportsPerSignature:B()})}))),Ah=H1(l()),Ph=H1(l()),LI=v({err:P8,logs:a(l()),signature:l()}),Qh=v({result:k4(LI),subscription:B()});class E2{constructor(T){this._keypair=void 0,this._keypair=T??wV()}static generate(){return new E2(wV())}static fromSecretKey(T,A){if(T.byteLength!==64)throw Error("bad secret key size");let P=T.slice(32,64);if(!A||!A.skipValidation){let Q=T.slice(0,32),C=YW(Q);for(let W=0;W<32;W++)if(P[W]!==C[W])throw Error("provided secretKey is invalid")}return new E2({publicKey:P,secretKey:T})}static fromSeed(T){let A=YW(T),P=new Uint8Array(64);return P.set(T),P.set(A,32),new E2({publicKey:A,secretKey:P})}get publicKey(){return new n(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}}var z2=Object.freeze({CreateLookupTable:{index:0,layout:N.struct([N.u32("instruction"),m8("recentSlot"),N.u8("bumpSeed")])},FreezeLookupTable:{index:1,layout:N.struct([N.u32("instruction")])},ExtendLookupTable:{index:2,layout:N.struct([N.u32("instruction"),m8(),N.seq(W1(),N.offset(N.u32(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:N.struct([N.u32("instruction")])},CloseLookupTable:{index:4,layout:N.struct([N.u32("instruction")])}});class Gq{constructor(){}static createLookupTable(T){let[A,P]=n.findProgramAddressSync([T.authority.toBuffer(),lC().encode(T.recentSlot)],this.programId),Q=z2.CreateLookupTable,C=C1(Q,{recentSlot:BigInt(T.recentSlot),bumpSeed:P}),W=[{pubkey:A,isSigner:!1,isWritable:!0},{pubkey:T.authority,isSigner:!0,isWritable:!1},{pubkey:T.payer,isSigner:!0,isWritable:!0},{pubkey:UT.programId,isSigner:!1,isWritable:!1}];return[new J1({programId:this.programId,keys:W,data:C}),A]}static freezeLookupTable(T){let A=z2.FreezeLookupTable,P=C1(A),Q=[{pubkey:T.lookupTable,isSigner:!1,isWritable:!0},{pubkey:T.authority,isSigner:!0,isWritable:!1}];return new J1({programId:this.programId,keys:Q,data:P})}static extendLookupTable(T){let A=z2.ExtendLookupTable,P=C1(A,{addresses:T.addresses.map((C)=>C.toBytes())}),Q=[{pubkey:T.lookupTable,isSigner:!1,isWritable:!0},{pubkey:T.authority,isSigner:!0,isWritable:!1}];if(T.payer)Q.push({pubkey:T.payer,isSigner:!0,isWritable:!0},{pubkey:UT.programId,isSigner:!1,isWritable:!1});return new J1({programId:this.programId,keys:Q,data:P})}static deactivateLookupTable(T){let A=z2.DeactivateLookupTable,P=C1(A),Q=[{pubkey:T.lookupTable,isSigner:!1,isWritable:!0},{pubkey:T.authority,isSigner:!0,isWritable:!1}];return new J1({programId:this.programId,keys:Q,data:P})}static closeLookupTable(T){let A=z2.CloseLookupTable,P=C1(A),Q=[{pubkey:T.lookupTable,isSigner:!1,isWritable:!0},{pubkey:T.authority,isSigner:!0,isWritable:!1},{pubkey:T.recipient,isSigner:!1,isWritable:!0}];return new J1({programId:this.programId,keys:Q,data:P})}}Gq.programId=new n("AddressLookupTab1e1111111111111111111111111");var Z4=Object.freeze({RequestUnits:{index:0,layout:N.struct([N.u8("instruction"),N.u32("units"),N.u32("additionalFee")])},RequestHeapFrame:{index:1,layout:N.struct([N.u8("instruction"),N.u32("bytes")])},SetComputeUnitLimit:{index:2,layout:N.struct([N.u8("instruction"),N.u32("units")])},SetComputeUnitPrice:{index:3,layout:N.struct([N.u8("instruction"),m8("microLamports")])}});class Uq{constructor(){}static requestUnits(T){let A=Z4.RequestUnits,P=C1(A,T);return new J1({keys:[],programId:this.programId,data:P})}static requestHeapFrame(T){let A=Z4.RequestHeapFrame,P=C1(A,T);return new J1({keys:[],programId:this.programId,data:P})}static setComputeUnitLimit(T){let A=Z4.SetComputeUnitLimit,P=C1(A,T);return new J1({keys:[],programId:this.programId,data:P})}static setComputeUnitPrice(T){let A=Z4.SetComputeUnitPrice,P=C1(A,{microLamports:BigInt(T.microLamports)});return new J1({keys:[],programId:this.programId,data:P})}}Uq.programId=new n("ComputeBudget111111111111111111111111111111");var _V=64,hV=32,mV=64,gV=N.struct([N.u8("numSignatures"),N.u8("padding"),N.u16("signatureOffset"),N.u16("signatureInstructionIndex"),N.u16("publicKeyOffset"),N.u16("publicKeyInstructionIndex"),N.u16("messageDataOffset"),N.u16("messageDataSize"),N.u16("messageInstructionIndex")]);class DW{constructor(){}static createInstructionWithPublicKey(T){let{publicKey:A,message:P,signature:Q,instructionIndex:C}=T;$T(A.length===hV,`Public Key must be ${hV} bytes but received ${A.length} bytes`),$T(Q.length===mV,`Signature must be ${mV} bytes but received ${Q.length} bytes`);let W=gV.span,G=W+A.length,J=G+Q.length,$=1,X=L.alloc(J+P.length),Z=C==null?65535:C;return gV.encode({numSignatures:$,padding:0,signatureOffset:G,signatureInstructionIndex:Z,publicKeyOffset:W,publicKeyInstructionIndex:Z,messageDataOffset:J,messageDataSize:P.length,messageInstructionIndex:Z},X),X.fill(A,W),X.fill(Q,G),X.fill(P,J),new J1({keys:[],programId:DW.programId,data:X})}static createInstructionWithPrivateKey(T){let{privateKey:A,message:P,instructionIndex:Q}=T;$T(A.length===_V,`Private key must be ${_V} bytes but received ${A.length} bytes`);try{let C=E2.fromSecretKey(A),W=C.publicKey.toBytes(),G=lV(P,C.secretKey);return this.createInstructionWithPublicKey({publicKey:W,message:P,signature:G,instructionIndex:Q})}catch(C){throw Error(`Error creating instruction; ${C}`)}}}DW.programId=new n("Ed25519SigVerify111111111111111111111111111");var EI=(T,A)=>{let P=q4.sign(T,A);return[P.toCompactRawBytes(),P.recovery]};q4.utils.isValidPrivateKey;var BI=q4.getPublicKey,vV=32,$W=20,yV=64,OI=11,VW=N.struct([N.u8("numSignatures"),N.u16("signatureOffset"),N.u8("signatureInstructionIndex"),N.u16("ethAddressOffset"),N.u8("ethAddressInstructionIndex"),N.u16("messageDataOffset"),N.u16("messageDataSize"),N.u8("messageInstructionIndex"),N.blob(20,"ethAddress"),N.blob(64,"signature"),N.u8("recoveryId")]);class B2{constructor(){}static publicKeyToEthAddress(T){$T(T.length===yV,`Public key must be ${yV} bytes but received ${T.length} bytes`);try{return L.from(TW(U1(T))).slice(-$W)}catch(A){throw Error(`Error constructing Ethereum address: ${A}`)}}static createInstructionWithPublicKey(T){let{publicKey:A,message:P,signature:Q,recoveryId:C,instructionIndex:W}=T;return B2.createInstructionWithEthAddress({ethAddress:B2.publicKeyToEthAddress(A),message:P,signature:Q,recoveryId:C,instructionIndex:W})}static createInstructionWithEthAddress(T){let{ethAddress:A,message:P,signature:Q,recoveryId:C,instructionIndex:W=0}=T,G;if(typeof A==="string")if(A.startsWith("0x"))G=L.from(A.substr(2),"hex");else G=L.from(A,"hex");else G=A;$T(G.length===$W,`Address must be ${$W} bytes but received ${G.length} bytes`);let J=1+OI,$=J,X=J+G.length,Z=X+Q.length+1,R=1,D=L.alloc(VW.span+P.length);return VW.encode({numSignatures:R,signatureOffset:X,signatureInstructionIndex:W,ethAddressOffset:$,ethAddressInstructionIndex:W,messageDataOffset:Z,messageDataSize:P.length,messageInstructionIndex:W,signature:U1(Q),ethAddress:U1(G),recoveryId:C},D),D.fill(U1(P),VW.span),new J1({keys:[],programId:B2.programId,data:D})}static createInstructionWithPrivateKey(T){let{privateKey:A,message:P,instructionIndex:Q}=T;$T(A.length===vV,`Private key must be ${vV} bytes but received ${A.length} bytes`);try{let C=U1(A),W=BI(C,!1).slice(1),G=L.from(TW(U1(P))),[J,$]=EI(G,C);return this.createInstructionWithPublicKey({publicKey:W,message:P,signature:J,recoveryId:$,instructionIndex:Q})}catch(C){throw Error(`Error creating instruction; ${C}`)}}}B2.programId=new n("KeccakSecp256k11111111111111111111111111111");var Jq,xI=new n("StakeConfig11111111111111111111111111111111");class D4{constructor(T,A,P){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=T,this.epoch=A,this.custodian=P}}Jq=D4;D4.default=new Jq(0,0,n.default);var BA=Object.freeze({Initialize:{index:0,layout:N.struct([N.u32("instruction"),nz(),fz()])},Authorize:{index:1,layout:N.struct([N.u32("instruction"),W1("newAuthorized"),N.u32("stakeAuthorizationType")])},Delegate:{index:2,layout:N.struct([N.u32("instruction")])},Split:{index:3,layout:N.struct([N.u32("instruction"),N.ns64("lamports")])},Withdraw:{index:4,layout:N.struct([N.u32("instruction"),N.ns64("lamports")])},Deactivate:{index:5,layout:N.struct([N.u32("instruction")])},Merge:{index:7,layout:N.struct([N.u32("instruction")])},AuthorizeWithSeed:{index:8,layout:N.struct([N.u32("instruction"),W1("newAuthorized"),N.u32("stakeAuthorizationType"),h8("authoritySeed"),W1("authorityOwner")])}}),Ch=Object.freeze({Staker:{index:0},Withdrawer:{index:1}});class FW{constructor(){}static initialize(T){let{stakePubkey:A,authorized:P,lockup:Q}=T,C=Q||D4.default,W=BA.Initialize,G=C1(W,{authorized:{staker:U1(P.staker.toBuffer()),withdrawer:U1(P.withdrawer.toBuffer())},lockup:{unixTimestamp:C.unixTimestamp,epoch:C.epoch,custodian:U1(C.custodian.toBuffer())}}),J={keys:[{pubkey:A,isSigner:!1,isWritable:!0},{pubkey:x2,isSigner:!1,isWritable:!1}],programId:this.programId,data:G};return new J1(J)}static createAccountWithSeed(T){let A=new K1;A.add(UT.createAccountWithSeed({fromPubkey:T.fromPubkey,newAccountPubkey:T.stakePubkey,basePubkey:T.basePubkey,seed:T.seed,lamports:T.lamports,space:this.space,programId:this.programId}));let{stakePubkey:P,authorized:Q,lockup:C}=T;return A.add(this.initialize({stakePubkey:P,authorized:Q,lockup:C}))}static createAccount(T){let A=new K1;A.add(UT.createAccount({fromPubkey:T.fromPubkey,newAccountPubkey:T.stakePubkey,lamports:T.lamports,space:this.space,programId:this.programId}));let{stakePubkey:P,authorized:Q,lockup:C}=T;return A.add(this.initialize({stakePubkey:P,authorized:Q,lockup:C}))}static delegate(T){let{stakePubkey:A,authorizedPubkey:P,votePubkey:Q}=T,C=BA.Delegate,W=C1(C);return new K1().add({keys:[{pubkey:A,isSigner:!1,isWritable:!0},{pubkey:Q,isSigner:!1,isWritable:!1},{pubkey:JA,isSigner:!1,isWritable:!1},{pubkey:JW,isSigner:!1,isWritable:!1},{pubkey:xI,isSigner:!1,isWritable:!1},{pubkey:P,isSigner:!0,isWritable:!1}],programId:this.programId,data:W})}static authorize(T){let{stakePubkey:A,authorizedPubkey:P,newAuthorizedPubkey:Q,stakeAuthorizationType:C,custodianPubkey:W}=T,G=BA.Authorize,J=C1(G,{newAuthorized:U1(Q.toBuffer()),stakeAuthorizationType:C.index}),$=[{pubkey:A,isSigner:!1,isWritable:!0},{pubkey:JA,isSigner:!1,isWritable:!0},{pubkey:P,isSigner:!0,isWritable:!1}];if(W)$.push({pubkey:W,isSigner:!0,isWritable:!1});return new K1().add({keys:$,programId:this.programId,data:J})}static authorizeWithSeed(T){let{stakePubkey:A,authorityBase:P,authoritySeed:Q,authorityOwner:C,newAuthorizedPubkey:W,stakeAuthorizationType:G,custodianPubkey:J}=T,$=BA.AuthorizeWithSeed,X=C1($,{newAuthorized:U1(W.toBuffer()),stakeAuthorizationType:G.index,authoritySeed:Q,authorityOwner:U1(C.toBuffer())}),Z=[{pubkey:A,isSigner:!1,isWritable:!0},{pubkey:P,isSigner:!0,isWritable:!1},{pubkey:JA,isSigner:!1,isWritable:!1}];if(J)Z.push({pubkey:J,isSigner:!0,isWritable:!1});return new K1().add({keys:Z,programId:this.programId,data:X})}static splitInstruction(T){let{stakePubkey:A,authorizedPubkey:P,splitStakePubkey:Q,lamports:C}=T,W=BA.Split,G=C1(W,{lamports:C});return new J1({keys:[{pubkey:A,isSigner:!1,isWritable:!0},{pubkey:Q,isSigner:!1,isWritable:!0},{pubkey:P,isSigner:!0,isWritable:!1}],programId:this.programId,data:G})}static split(T,A){let P=new K1;return P.add(UT.createAccount({fromPubkey:T.authorizedPubkey,newAccountPubkey:T.splitStakePubkey,lamports:A,space:this.space,programId:this.programId})),P.add(this.splitInstruction(T))}static splitWithSeed(T,A){let{stakePubkey:P,authorizedPubkey:Q,splitStakePubkey:C,basePubkey:W,seed:G,lamports:J}=T,$=new K1;if($.add(UT.allocate({accountPubkey:C,basePubkey:W,seed:G,space:this.space,programId:this.programId})),A&&A>0)$.add(UT.transfer({fromPubkey:T.authorizedPubkey,toPubkey:C,lamports:A}));return $.add(this.splitInstruction({stakePubkey:P,authorizedPubkey:Q,splitStakePubkey:C,lamports:J}))}static merge(T){let{stakePubkey:A,sourceStakePubKey:P,authorizedPubkey:Q}=T,C=BA.Merge,W=C1(C);return new K1().add({keys:[{pubkey:A,isSigner:!1,isWritable:!0},{pubkey:P,isSigner:!1,isWritable:!0},{pubkey:JA,isSigner:!1,isWritable:!1},{pubkey:JW,isSigner:!1,isWritable:!1},{pubkey:Q,isSigner:!0,isWritable:!1}],programId:this.programId,data:W})}static withdraw(T){let{stakePubkey:A,authorizedPubkey:P,toPubkey:Q,lamports:C,custodianPubkey:W}=T,G=BA.Withdraw,J=C1(G,{lamports:C}),$=[{pubkey:A,isSigner:!1,isWritable:!0},{pubkey:Q,isSigner:!1,isWritable:!0},{pubkey:JA,isSigner:!1,isWritable:!1},{pubkey:JW,isSigner:!1,isWritable:!1},{pubkey:P,isSigner:!0,isWritable:!1}];if(W)$.push({pubkey:W,isSigner:!0,isWritable:!1});return new K1().add({keys:$,programId:this.programId,data:J})}static deactivate(T){let{stakePubkey:A,authorizedPubkey:P}=T,Q=BA.Deactivate,C=C1(Q);return new K1().add({keys:[{pubkey:A,isSigner:!1,isWritable:!0},{pubkey:JA,isSigner:!1,isWritable:!1},{pubkey:P,isSigner:!0,isWritable:!1}],programId:this.programId,data:C})}}FW.programId=new n("Stake11111111111111111111111111111111111111");FW.space=200;var I2=Object.freeze({InitializeAccount:{index:0,layout:N.struct([N.u32("instruction"),iz()])},Authorize:{index:1,layout:N.struct([N.u32("instruction"),W1("newAuthorized"),N.u32("voteAuthorizationType")])},Withdraw:{index:3,layout:N.struct([N.u32("instruction"),N.ns64("lamports")])},UpdateValidatorIdentity:{index:4,layout:N.struct([N.u32("instruction")])},AuthorizeWithSeed:{index:10,layout:N.struct([N.u32("instruction"),az()])}}),Wh=Object.freeze({Voter:{index:0},Withdrawer:{index:1}});class F4{constructor(){}static initializeAccount(T){let{votePubkey:A,nodePubkey:P,voteInit:Q}=T,C=I2.InitializeAccount,W=C1(C,{voteInit:{nodePubkey:U1(Q.nodePubkey.toBuffer()),authorizedVoter:U1(Q.authorizedVoter.toBuffer()),authorizedWithdrawer:U1(Q.authorizedWithdrawer.toBuffer()),commission:Q.commission}}),G={keys:[{pubkey:A,isSigner:!1,isWritable:!0},{pubkey:x2,isSigner:!1,isWritable:!1},{pubkey:JA,isSigner:!1,isWritable:!1},{pubkey:P,isSigner:!0,isWritable:!1}],programId:this.programId,data:W};return new J1(G)}static createAccount(T){let A=new K1;return A.add(UT.createAccount({fromPubkey:T.fromPubkey,newAccountPubkey:T.votePubkey,lamports:T.lamports,space:this.space,programId:this.programId})),A.add(this.initializeAccount({votePubkey:T.votePubkey,nodePubkey:T.voteInit.nodePubkey,voteInit:T.voteInit}))}static authorize(T){let{votePubkey:A,authorizedPubkey:P,newAuthorizedPubkey:Q,voteAuthorizationType:C}=T,W=I2.Authorize,G=C1(W,{newAuthorized:U1(Q.toBuffer()),voteAuthorizationType:C.index}),J=[{pubkey:A,isSigner:!1,isWritable:!0},{pubkey:JA,isSigner:!1,isWritable:!1},{pubkey:P,isSigner:!0,isWritable:!1}];return new K1().add({keys:J,programId:this.programId,data:G})}static authorizeWithSeed(T){let{currentAuthorityDerivedKeyBasePubkey:A,currentAuthorityDerivedKeyOwnerPubkey:P,currentAuthorityDerivedKeySeed:Q,newAuthorizedPubkey:C,voteAuthorizationType:W,votePubkey:G}=T,J=I2.AuthorizeWithSeed,$=C1(J,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:U1(P.toBuffer()),currentAuthorityDerivedKeySeed:Q,newAuthorized:U1(C.toBuffer()),voteAuthorizationType:W.index}}),X=[{pubkey:G,isSigner:!1,isWritable:!0},{pubkey:JA,isSigner:!1,isWritable:!1},{pubkey:A,isSigner:!0,isWritable:!1}];return new K1().add({keys:X,programId:this.programId,data:$})}static withdraw(T){let{votePubkey:A,authorizedWithdrawerPubkey:P,lamports:Q,toPubkey:C}=T,W=I2.Withdraw,G=C1(W,{lamports:Q}),J=[{pubkey:A,isSigner:!1,isWritable:!0},{pubkey:C,isSigner:!1,isWritable:!0},{pubkey:P,isSigner:!0,isWritable:!1}];return new K1().add({keys:J,programId:this.programId,data:G})}static safeWithdraw(T,A,P){if(T.lamports>A-P)throw Error("Withdraw will leave vote account with insufficient funds.");return F4.withdraw(T)}static updateValidatorIdentity(T){let{votePubkey:A,authorizedWithdrawerPubkey:P,nodePubkey:Q}=T,C=I2.UpdateValidatorIdentity,W=C1(C),G=[{pubkey:A,isSigner:!1,isWritable:!0},{pubkey:Q,isSigner:!0,isWritable:!1},{pubkey:P,isSigner:!0,isWritable:!1}];return new K1().add({keys:G,programId:this.programId,data:W})}}F4.programId=new n("Vote111111111111111111111111111111111111111");F4.space=3762;var Gh=new n("Va1idator1nfo111111111111111111111111111111"),Uh=v({name:l(),website:A1(l()),details:A1(l()),iconUrl:A1(l()),keybaseUsername:A1(l())});var Jh=new n("Vote111111111111111111111111111111111111111"),$h=N.struct([W1("nodePubkey"),W1("authorizedWithdrawer"),N.u8("commission"),N.nu64(),N.seq(N.struct([N.nu64("slot"),N.u32("confirmationCount")]),N.offset(N.u32(),-8),"votes"),N.u8("rootSlotValid"),N.nu64("rootSlot"),N.nu64(),N.seq(N.struct([N.nu64("epoch"),W1("authorizedVoter")]),N.offset(N.u32(),-8),"authorizedVoters"),N.struct([N.seq(N.struct([W1("authorizedPubkey"),N.nu64("epochOfLastAuthorizedSwitch"),N.nu64("targetEpoch")]),32,"buf"),N.nu64("idx"),N.u8("isEmpty")],"priorVoters"),N.nu64(),N.seq(N.struct([N.nu64("epoch"),N.nu64("credits"),N.nu64("prevCredits")]),N.offset(N.u32(),-8),"epochCredits"),N.struct([N.nu64("slot"),N.nu64("timestamp")],"lastTimestamp")]);var fT=new n("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"),Yh=new n("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"),v0=new n("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"),Zh=new n("So11111111111111111111111111111111111111112"),Xh=new n("9pan9bMn5HatX4EJdBwg9VgCa7Uz5HL8N1m5D3NdXejP");var C8=(T)=>{let A=T.decode.bind(T),P=T.encode.bind(T);return{decode:A,encode:P}};var MW=yT(CA(),1),OA=yT(Vq(),1);var z4=(T)=>(A)=>{let P=MW.blob(T,A),{encode:Q,decode:C}=C8(P),W=P;return W.decode=(G,J)=>{let $=C(G,J);return OA.toBigIntLE(Buffer.from($))},W.encode=(G,J,$)=>{let X=OA.toBufferLE(G,T);return Q(X,J,$)},W},I4=(T)=>(A)=>{let P=MW.blob(T,A),{encode:Q,decode:C}=C8(P),W=P;return W.decode=(G,J)=>{let $=C(G,J);return OA.toBigIntBE(Buffer.from($))},W.encode=(G,J,$)=>{let X=OA.toBufferBE(G,T);return Q(X,J,$)},W},qq=z4(8),jh=I4(8),Dh=z4(16),Fh=I4(16),Mh=z4(24),zh=I4(24),Ih=z4(32),Sh=I4(32);var Yq=yT(CA(),1);var Zq=(T)=>{let A=Yq.u8(T),{encode:P,decode:Q}=C8(A),C=A;return C.decode=(W,G)=>{return!!Q(W,G)},C.encode=(W,G,J)=>{let $=Number(W);return P($,G,J)},C};var Xq=yT(CA(),1);var zW=(T)=>{let A=Xq.blob(32,T),{encode:P,decode:Q}=C8(A),C=A;return C.decode=(W,G)=>{let J=Q(W,G);return new n(J)},C.encode=(W,G,J)=>{let $=W.toBuffer();return P($,G,J)},C};class Hq extends Error{constructor(T){super(T)}}class IW extends Hq{constructor(){super(...arguments);this.name="TokenOwnerOffCurveError"}}var y8;(function(T){T[T.InitializeMint=0]="InitializeMint",T[T.InitializeAccount=1]="InitializeAccount",T[T.InitializeMultisig=2]="InitializeMultisig",T[T.Transfer=3]="Transfer",T[T.Approve=4]="Approve",T[T.Revoke=5]="Revoke",T[T.SetAuthority=6]="SetAuthority",T[T.MintTo=7]="MintTo",T[T.Burn=8]="Burn",T[T.CloseAccount=9]="CloseAccount",T[T.FreezeAccount=10]="FreezeAccount",T[T.ThawAccount=11]="ThawAccount",T[T.TransferChecked=12]="TransferChecked",T[T.ApproveChecked=13]="ApproveChecked",T[T.MintToChecked=14]="MintToChecked",T[T.BurnChecked=15]="BurnChecked",T[T.InitializeAccount2=16]="InitializeAccount2",T[T.SyncNative=17]="SyncNative",T[T.InitializeAccount3=18]="InitializeAccount3",T[T.InitializeMultisig2=19]="InitializeMultisig2",T[T.InitializeMint2=20]="InitializeMint2",T[T.GetAccountDataSize=21]="GetAccountDataSize",T[T.InitializeImmutableOwner=22]="InitializeImmutableOwner",T[T.AmountToUiAmount=23]="AmountToUiAmount",T[T.UiAmountToAmount=24]="UiAmountToAmount",T[T.InitializeMintCloseAuthority=25]="InitializeMintCloseAuthority",T[T.TransferFeeExtension=26]="TransferFeeExtension",T[T.ConfidentialTransferExtension=27]="ConfidentialTransferExtension",T[T.DefaultAccountStateExtension=28]="DefaultAccountStateExtension",T[T.Reallocate=29]="Reallocate",T[T.MemoTransferExtension=30]="MemoTransferExtension",T[T.CreateNativeMint=31]="CreateNativeMint",T[T.InitializeNonTransferableMint=32]="InitializeNonTransferableMint",T[T.InterestBearingMintExtension=33]="InterestBearingMintExtension",T[T.CpiGuardExtension=34]="CpiGuardExtension",T[T.InitializePermanentDelegate=35]="InitializePermanentDelegate",T[T.TransferHookExtension=36]="TransferHookExtension",T[T.MetadataPointerExtension=39]="MetadataPointerExtension",T[T.GroupPointerExtension=40]="GroupPointerExtension",T[T.GroupMemberPointerExtension=41]="GroupMemberPointerExtension",T[T.ScaledUiAmountExtension=43]="ScaledUiAmountExtension",T[T.PausableExtension=44]="PausableExtension"})(y8||(y8={}));var W8=yT(CA(),1);function Kq(T,A,P){if(P.length){T.push({pubkey:A,isSigner:!1,isWritable:!1});for(let Q of P)T.push({pubkey:Q instanceof n?Q:Q.publicKey,isSigner:!0,isWritable:!1})}else T.push({pubkey:A,isSigner:!0,isWritable:!1});return T}var pI=W8.struct([W8.u32("mintAuthorityOption"),zW("mintAuthority"),qq("supply"),W8.u8("decimals"),Zq("isInitialized"),W8.u32("freezeAuthorityOption"),zW("freezeAuthority")]),rh=pI.span;function _2(T,A,P=!1,Q=fT,C=v0){if(!P&&!n.isOnCurve(A.toBuffer()))throw new IW;let[W]=n.findProgramAddressSync([A.toBuffer(),Q.toBuffer(),T.toBuffer()],C);return W}var S4=yT(CA(),1);var Rq=S4.struct([S4.u8("instruction")]);function SW(T,A,P,Q=[],C=fT){let W=Kq([{pubkey:T,isSigner:!1,isWritable:!0},{pubkey:A,isSigner:!1,isWritable:!0}],P,Q),G=Buffer.alloc(Rq.span);return Rq.encode({instruction:y8.CloseAccount},G),new J1({keys:W,programId:C,data:G})}function N4(T,A,P,Q,C=fT,W=v0){return uI(T,A,P,Q,Buffer.alloc(0),C,W)}function uI(T,A,P,Q,C,W=fT,G=v0){let J=[{pubkey:T,isSigner:!0,isWritable:!0},{pubkey:A,isSigner:!1,isWritable:!0},{pubkey:P,isSigner:!1,isWritable:!1},{pubkey:Q,isSigner:!1,isWritable:!1},{pubkey:UT.programId,isSigner:!1,isWritable:!1},{pubkey:W,isSigner:!1,isWritable:!1}];return new J1({keys:J,programId:G,data:C})}var w4=yT(CA(),1);var kq=w4.struct([w4.u8("instruction")]);function jq(T,A=fT){let P=[{pubkey:T,isSigner:!1,isWritable:!0}],Q=Buffer.alloc(kq.span);return kq.encode({instruction:y8.SyncNative},Q),new J1({keys:P,programId:A,data:Q})}function L4(T){if(typeof T==="string")return new n(T);if(typeof T==="object"&&"address"in T)return new n(T.address);return new n(T)}function Dq(T){if(T instanceof n)return T;return L4(T)}function dI(T){return{programAddress:b(T.programId.toBase58()),accounts:T.keys.map((A)=>({address:b(A.pubkey.toBase58()),role:A.isSigner?A.isWritable?X1.WRITABLE_SIGNER:X1.READONLY_SIGNER:A.isWritable?X1.WRITABLE:X1.READONLY})),data:T.data}}function NW(T){let{payer:A,owner:P,mint:Q,tokenProgram:C=fT,associatedTokenProgram:W=v0}=T,G=L4(A),J=L4(P),$=L4(Q),X=Dq(C),Z=Dq(W),R=_2($,J,!1,X,Z);return dI(N4(G,R,J,$,X,Z))}var Fq=w0,Mq=(T,A)=>{if(!Number.isFinite(T)||T<=0)throw Error(`${A} must be a positive number`)},E4=(T)=>({lpFeeBps:T.lpFeeBps,protocolFeeBps:T.protocolFeeBps,creatorFeeBps:T.creatorFeeBps});async function rI(T,A,P,Q){let C=Q?.curve?Promise.resolve(Q.curve):(async()=>{let G=await r0(T);return(await bA(A,G,{commitment:P})).data})(),W=Q?.fees?Promise.resolve(Q.fees):(async()=>{let G=await c0(),J=await T2(A,G,{commitment:P});return E4(J.data.flatFees)})();try{let[G,J]=await Promise.all([C,W]);return{curve:G,fees:J}}catch(G){throw Error("Failed to load bonding curve state. Provide overrides or ensure the RPC endpoint can access Pump accounts.",{cause:G})}}async function cI(T,A,P){try{let Q=await r0(T),C=await bA(A,Q,{commitment:P});if(C.data.complete)return null;let W=await c0(),G=await T2(A,W,{commitment:P}),J=E4(G.data.flatFees);return{curve:C.data,fees:J,creator:C.data.creator}}catch{return null}}async function zq(T){Mq(T.solAmount,"solAmount");let A=T.slippageBps??L0;E0(A);let P=T.feeRecipient??Fq,Q=T.rpc,C=T.commitment??JT(),W=null;if(T.curveStateOverride&&T.feeStructureOverride)W={curve:T.curveStateOverride,fees:T.feeStructureOverride,creator:T.bondingCurveCreator?b(T.bondingCurveCreator):T.curveStateOverride.creator};else try{if(W=await cI(T.mint,Q,C),!W)throw Error("Token has migrated to AMM (bonding curve is complete or doesn't exist). This token can only be traded via AMM swaps.")}catch(G){try{let J=await r0(T.mint),$=await bA(Q,J,{commitment:C});if($.data.complete)throw Error("Token has migrated to AMM (bonding curve is complete). This token can only be traded via AMM swaps.");let X=await c0(),Z=await T2(Q,X,{commitment:C});W={curve:$.data,fees:E4(Z.data.flatFees),creator:$.data.creator}}catch(J){throw Error(`Unable to determine token state (bonding curve vs AMM): ${J.message}. Check network connectivity or provide curveStateOverride and feeStructureOverride.`)}}if(W){let G=await r0(T.mint),J=await bA(Q,G,{commitment:C}),$=await c0(),X=await T2(Q,$,{commitment:C}),Z={curve:J.data,fees:E4(X.data.flatFees),creator:J.data.creator},R=XA(T.solAmount),z=fJ(Z.curve,Z.fees,R).tokenAmount,E=L6(Z.curve,Z.fees,z).totalSolCostLamports*2n,w=b(T.mint),[O]=await MT({owner:b(T.user.address),mint:w,tokenProgram:b(FT)}),m=null;try{if(!(await Q.getAccountInfo(O).send()).value)m=NW({payer:T.user,owner:T.user,mint:w})}catch{m=NW({payer:T.user,owner:T.user,mint:w})}let g=await FQ({user:T.user,mint:T.mint,tokenAmount:z,maxSolCostLamports:E,feeRecipient:P,trackVolume:T.trackVolume,bondingCurveCreator:Z.creator,rpc:Q,commitment:C});if(m)return{...g,prepend:[m]};return g}throw Error("Token has migrated to AMM. Use AMM-specific buy functions or ensure bonding curve is active.")}var oI=1e4;function nI(T){if(!Number.isFinite(T)||T<=0||T>100)throw Error("walletPercentage must be between 0 and 100");return BigInt(Math.round(T*100))}async function Iq(T){let A=T.slippageBps??L0;E0(A);let P=T.feeRecipient??Fq,Q=T.rpc,C=T.commitment??JT(),{curve:W,fees:G}=await rI(T.mint,Q,C,{curve:T.curveStateOverride,fees:T.feeStructureOverride}),J=T.bondingCurveCreator??W.creator,$=T.useWalletPercentage??!1,X=b(T.mint),Z;if($){let z=T.walletPercentage??100,S=nI(z),[E]=await MT({owner:b(T.user.address),mint:X,tokenProgram:b(FT)}),w=await Q.getTokenAccountBalance(E).send(),O=BigInt(w.value.amount);if(O===0n)throw Error("Wallet token balance is zero; nothing to sell");if(Z=O*S/BigInt(oI),Z<=0n)Z=1n}else{if(T.tokenAmount===void 0)throw Error("tokenAmount is required when useWalletPercentage is false");Mq(T.tokenAmount,"tokenAmount");let z=T.tokenDecimals??6;Z=e8(T.tokenAmount,z)}let R=iJ(W,G,Z),D=t8(R.solOutputLamports,A);if(D<=0n)throw Error("Slippage settings would result in zero SOL output");return await MQ({user:T.user,mint:T.mint,tokenAmountRaw:Z,minSolOutputLamports:D,feeRecipient:P,bondingCurveCreator:J,rpc:Q,commitment:C})}async function fI(T,A,P,Q){if(!Q)throw Error("quickBuy requires options with an RPC client (options.rpc)");let{rpc:C,...W}=Q;return zq({user:T,mint:A,solAmount:P,rpc:C,...W})}async function iI(T,A,P,Q){if(!Q)throw Error("quickSell requires options with an RPC client (options.rpc)");let{rpc:C,...W}=Q;return Iq({user:T,mint:A,tokenAmount:P,rpc:C,...W})}async function wW(T){let{user:A,mint:P,mintAuthority:Q,name:C,symbol:W,uri:G,firstBuyTokenAmount:J,estimatedFirstBuyCost:$,slippageBps:X=L0,feeRecipient:Z=w0,bondingCurveCreator:R,trackVolume:D,rpc:z,commitment:S=JT()}=T;if(E0(X),!C||C.length===0)throw Error("Token name is required");if(!W||W.length===0)throw Error("Token symbol is required");if(!G||G.length===0)throw Error("Metadata URI is required");if(J<=0n)throw Error("First buy token amount must be positive");if($<=0n)throw Error("Estimated first buy cost must be positive");let E=await cJ({user:A,mint:P,mintAuthority:Q,name:C,symbol:W,uri:G}),w=s8($,X),O=await a8({user:A,mint:P.address,tokenAmount:J,maxSolCostLamports:w,feeRecipient:Z,trackVolume:D??!0,bondingCurveCreator:R??A.address,rpc:z,commitment:S});return{createInstruction:E,buyInstruction:O}}function aI(T){let{name:A,symbol:P,uri:Q}=T;if(!A||A.length===0)throw Error("Token name is required");if(A.length>32)throw Error("Token name too long (max 32 characters)");if(!P||P.length===0)throw Error("Token symbol is required");if(P.length>10)throw Error("Token symbol too long (max 10 characters)");if(!Q||Q.length===0)throw Error("Metadata URI is required");if(!Q.startsWith("http://")&&!Q.startsWith("https://")&&!Q.startsWith("ipfs://"))throw Error("Metadata URI must be a valid URL or IPFS link")}var Sq=b("ComputeBudget111111111111111111111111111111");async function LW({instructions:T,payer:A,additionalSigners:P=[],latestBlockhash:Q,lastValidBlockHeight:C,version:W="legacy",rpc:G,commitment:J=JT(),prependInstructions:$=[],appendInstructions:X=[],priorityFees:Z}){let R=typeof A==="string"?b(A):A.address,D=GJ({version:W}),z=Nq(Z),S=[],E=[];for(let d of T)if("prepend"in d&&Array.isArray(d.prepend)){S.push(...d.prepend);let{prepend:_,...t}=d;E.push(t)}else E.push(d);let w=[...z,...S,...$??[],...E,...X??[]],O=new Map;for(let d of w)if(D=$J(d,D),d.accounts){for(let _ of d.accounts)if("signer"in _&&_.signer&&typeof _.signer==="object"&&"address"in _.signer){let t=_.signer;O.set(t.address,t)}}let m=JJ(R,D),g=[];if(tI(A))m=EJ(A,m),g.push(A);for(let d of O.values())if(!g.some((_)=>_.address===d.address))g.push(d);if(P.length>0){for(let d of P)if(S0(d)&&!g.some((_)=>_.address===d.address))g.push(d)}let p=g.length>0?LJ(g,m):m,c=Q,o=C!==void 0?BigInt(C):void 0;if(!c||o===void 0){let{value:d}=await G.getLatestBlockhash({commitment:J}).send();if(c=c??d.blockhash,o===void 0)o=BigInt(d.lastValidBlockHeight)}return{transactionMessage:PJ({blockhash:c,lastValidBlockHeight:o},p),latestBlockhash:c,lastValidBlockHeight:o}}async function EW({instructions:T,payer:A,additionalSigners:P=[],latestBlockhash:Q,lastValidBlockHeight:C,version:W,prependInstructions:G,appendInstructions:J,priorityFees:$,rpc:X,rpcSubscriptions:Z,commitment:R=JT(),sendOptions:D={}}){let z=await LW({instructions:T,payer:A,additionalSigners:P,latestBlockhash:Q,lastValidBlockHeight:C,version:W,prependInstructions:G,appendInstructions:J,priorityFees:$,rpc:X,commitment:R}),S=await XQ(z.transactionMessage),E=j6(S),w=hJ({rpc:X,rpcSubscriptions:Z}),O={commitment:R};if(D.abortSignal)O.abortSignal=D.abortSignal;if(D.skipPreflight!==void 0)O.skipPreflight=D.skipPreflight;if(D.minContextSlot!==void 0)O.minContextSlot=BigInt(D.minContextSlot);if(D.maxRetries!==void 0)O.maxRetries=D.maxRetries;if(D.preflightCommitment)O.preflightCommitment=D.preflightCommitment;await w(S,O);let g=(await X.getSignatureStatuses([E],{searchTransactionHistory:!1}).send()).value?.[0]??null;if(g?.err)try{let c=await X.getTransaction(E,{commitment:R,encoding:"json",maxSupportedTransactionVersion:0}).send(),o="Transaction failed";if(g.err)o=`Transaction failed: ${typeof g.err==="object"?JSON.stringify(g.err,(d,_)=>typeof _==="bigint"?_.toString():_):String(g.err)}`;if(c?.meta?.err)o=`Transaction failed: ${typeof c.meta.err==="object"?JSON.stringify(c.meta.err,(d,_)=>typeof _==="bigint"?_.toString():_):String(c.meta.err)}`;if(c?.meta?.logMessages){let f=c.meta.logMessages.filter((d)=>d.toLowerCase().includes("error")||d.includes("Program log:"));if(f.length>0)o+=`
|
|
21
|
+
Program logs:
|
|
22
|
+
${f.slice(0,10).join(`
|
|
23
|
+
`)}`}throw Error(o)}catch(p){let c=g.err&&typeof g.err==="object"?JSON.stringify(g.err,(o,f)=>typeof f==="bigint"?f.toString():f):String(g.err);throw Error(`Transaction failed: ${c}`)}return{signature:E,slot:g?.slot??null}}async function sI({instructions:T,payer:A,additionalSigners:P=[],latestBlockhash:Q,lastValidBlockHeight:C,version:W,prependInstructions:G,appendInstructions:J,priorityFees:$,rpc:X,commitment:Z=JT(),options:R={}}){let D=await LW({instructions:T,payer:A,additionalSigners:P,latestBlockhash:Q,lastValidBlockHeight:C,version:W,prependInstructions:G,appendInstructions:J,priorityFees:$,rpc:X,commitment:Z}),z=await XQ(D.transactionMessage),S=D6(z),E={commitment:R.commitment??Z};if(R.minContextSlot!==void 0)E.minContextSlot=BigInt(R.minContextSlot);if(R.sigVerify!==void 0)E.sigVerify=R.sigVerify;if(R.replaceRecentBlockhash!==void 0){if(R.sigVerify)throw Error("replaceRecentBlockhash cannot be true when sigVerify is enabled.");E.replaceRecentBlockhash=R.replaceRecentBlockhash}if(R.accounts)E.accounts=R.accounts;let w=await X.simulateTransaction(S,E).send();return{context:{slot:Number(w.context.slot)},value:{err:w.value.err,logs:w.value.logs,unitsConsumed:w.value.unitsConsumed!==void 0?Number(w.value.unitsConsumed):void 0,accounts:w.value.accounts,returnData:w.value.returnData??void 0}}}function tI(T){return typeof T!=="string"&&S0(T)}function Nq(T){if(!T)return[];let A=[];if(T.computeUnitLimit!==void 0&&T.computeUnitLimit>0)A.push(eI(T.computeUnitLimit));if(T.computeUnitPriceMicroLamports!==void 0&&BigInt(T.computeUnitPriceMicroLamports)>0n)A.push(TS(BigInt(T.computeUnitPriceMicroLamports)));return A}function eI(T){let A=new Uint8Array(5);return A[0]=0,new DataView(A.buffer).setUint32(1,T,!0),{programAddress:Sq,accounts:[],data:A}}function TS(T){let A=new Uint8Array(9);return A[0]=3,new DataView(A.buffer).setBigUint64(1,T,!0),{programAddress:Sq,accounts:[],data:A}}async function AS(T){let{creator:A,metadata:P,firstBuyTokenAmount:Q,estimatedFirstBuyCost:C,slippageBps:W,feeRecipient:G,bondingCurveCreator:J,mintAuthority:$,mint:X,priorityFees:Z,prependInstructions:R,appendInstructions:D,additionalSigners:z,sendOptions:S,commitment:E=JT(),rpc:w,rpcSubscriptions:O}=T,m=X??await BJ(),g={user:A,mint:m,mintAuthority:$??A.address,name:P.name,symbol:P.symbol,uri:P.uri,firstBuyTokenAmount:Q,estimatedFirstBuyCost:C,slippageBps:W,feeRecipient:G,bondingCurveCreator:J??A.address,rpc:w,commitment:E},{createInstruction:p,buyInstruction:c}=await wW(g);return{...await EW({instructions:[p,c],payer:A,commitment:E,priorityFees:Z,prependInstructions:R,appendInstructions:D,additionalSigners:PS([m,...z??[]]),sendOptions:S,rpc:w,rpcSubscriptions:O}),mint:m,createInstruction:p,buyInstruction:c}}function PS(T){let A=new Set,P=[];for(let Q of T){let C=Q.address;if(!A.has(C))A.add(C),P.push(Q)}return P}var O4=new TextEncoder,B4=HT();async function BW(T,A,P,Q){let C=new Uint8Array(2);C[0]=T&255,C[1]=T>>8&255;let[W]=await j1({programAddress:b(N0),seeds:[O4.encode("pool"),C,B4.encode(b(A)),B4.encode(b(P)),B4.encode(b(Q))]});return W}async function OW(T){let[A]=await j1({programAddress:b(N0),seeds:[O4.encode("pool_lp_mint"),B4.encode(b(T))]});return A}async function xW(T,A){let[P]=await gJ({owner:T,mint:A});return P}async function h2(T,A,P){let[Q]=await MT({owner:T,mint:A,tokenProgram:P});return Q}async function _W(){let[T]=await j1({programAddress:b(N0),seeds:[O4.encode("global_config")]});return T}async function hW(){let[T]=await j1({programAddress:b(N0),seeds:[O4.encode("__event_authority")]});return T}var I1="pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA";function K0(T){if(!T)throw Error("Expected a Address.");if(typeof T==="object"&&"address"in T)return T.address;if(Array.isArray(T))return T[0];return T}function S1(T,A){return(P)=>{if(!P.value){if(A==="omitted")return;return Object.freeze({address:T,role:X1.READONLY})}let Q=P.isWritable?X1.WRITABLE:X1.READONLY;return Object.freeze({address:K0(P.value),role:wq(P.value)?X6(Q):Q,...wq(P.value)?{signer:P.value}:{}})}}function wq(T){return!!T&&typeof T==="object"&&"address"in T&&S0(T)}var Tg=new Uint8Array([242,40,117,145,73,96,105,104]);var Cg=new Uint8Array([209,11,115,87,213,23,124,204]);var Qv=new Uint8Array([102,6,61,18,1,218,235,234]);var Jv=new Uint8Array([198,46,21,82,180,217,232,112]);var Yv=new Uint8Array([16,4,71,28,204,1,40,27]);var Kv=new Uint8Array([249,69,164,218,150,103,84,138]);var Dv=new Uint8Array([160,57,89,42,181,139,43,66]);var Iv=new Uint8Array([201,207,243,114,75,111,47,189]);var Ev=new Uint8Array([233,146,209,142,207,104,64,188]);var WS=new Uint8Array([242,35,198,137,82,225,242,182]);function GS(){return lT(uT([["discriminator",iT(W0(),8)],["lpTokenAmountOut",DT()],["maxBaseAmountIn",DT()],["maxQuoteAmountIn",DT()]]),(T)=>({...T,discriminator:WS}))}function Lq(T,A){let P=A?.programAddress??I1,C={pool:{value:T.pool??null,isWritable:!0},globalConfig:{value:T.globalConfig??null,isWritable:!1},user:{value:T.user??null,isWritable:!1},baseMint:{value:T.baseMint??null,isWritable:!1},quoteMint:{value:T.quoteMint??null,isWritable:!1},lpMint:{value:T.lpMint??null,isWritable:!0},userBaseTokenAccount:{value:T.userBaseTokenAccount??null,isWritable:!0},userQuoteTokenAccount:{value:T.userQuoteTokenAccount??null,isWritable:!0},userPoolTokenAccount:{value:T.userPoolTokenAccount??null,isWritable:!0},poolBaseTokenAccount:{value:T.poolBaseTokenAccount??null,isWritable:!0},poolQuoteTokenAccount:{value:T.poolQuoteTokenAccount??null,isWritable:!0},tokenProgram:{value:T.tokenProgram??null,isWritable:!1},token2022Program:{value:T.token2022Program??null,isWritable:!1},eventAuthority:{value:T.eventAuthority??null,isWritable:!1},program:{value:T.program??null,isWritable:!1}},W={...T};if(!C.tokenProgram.value)C.tokenProgram.value="TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";if(!C.token2022Program.value)C.token2022Program.value="TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";let G=S1(P,"programId");return Object.freeze({accounts:[G(C.pool),G(C.globalConfig),G(C.user),G(C.baseMint),G(C.quoteMint),G(C.lpMint),G(C.userBaseTokenAccount),G(C.userQuoteTokenAccount),G(C.userPoolTokenAccount),G(C.poolBaseTokenAccount),G(C.poolQuoteTokenAccount),G(C.tokenProgram),G(C.token2022Program),G(C.eventAuthority),G(C.program)],data:GS().encode(W),programAddress:P})}var vv=new Uint8Array([185,173,187,90,216,15,238,233]);var pv=new Uint8Array([234,102,194,203,150,72,62,229]);var cv=new Uint8Array([94,6,202,115,255,96,232,183]);var iv=new Uint8Array([51,230,133,164,1,127,131,173]);var ev=new Uint8Array([210,149,128,45,188,58,78,175]);var Qy=new Uint8Array([86,31,192,87,163,87,79,238]);var Uy=new Uint8Array([161,176,40,213,60,184,179,228]);var qy=new Uint8Array([104,184,103,242,88,151,107,20]);var US=new Uint8Array([183,18,70,156,148,109,161,34]);function JS(){return lT(uT([["discriminator",iT(W0(),8)],["lpTokenAmountIn",DT()],["minBaseAmountOut",DT()],["minQuoteAmountOut",DT()]]),(T)=>({...T,discriminator:US}))}function Eq(T,A){let P=A?.programAddress??I1,C={pool:{value:T.pool??null,isWritable:!0},globalConfig:{value:T.globalConfig??null,isWritable:!1},user:{value:T.user??null,isWritable:!1},baseMint:{value:T.baseMint??null,isWritable:!1},quoteMint:{value:T.quoteMint??null,isWritable:!1},lpMint:{value:T.lpMint??null,isWritable:!0},userBaseTokenAccount:{value:T.userBaseTokenAccount??null,isWritable:!0},userQuoteTokenAccount:{value:T.userQuoteTokenAccount??null,isWritable:!0},userPoolTokenAccount:{value:T.userPoolTokenAccount??null,isWritable:!0},poolBaseTokenAccount:{value:T.poolBaseTokenAccount??null,isWritable:!0},poolQuoteTokenAccount:{value:T.poolQuoteTokenAccount??null,isWritable:!0},tokenProgram:{value:T.tokenProgram??null,isWritable:!1},token2022Program:{value:T.token2022Program??null,isWritable:!1},eventAuthority:{value:T.eventAuthority??null,isWritable:!1},program:{value:T.program??null,isWritable:!1}},W={...T};if(!C.tokenProgram.value)C.tokenProgram.value="TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";if(!C.token2022Program.value)C.token2022Program.value="TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";let G=S1(P,"programId");return Object.freeze({accounts:[G(C.pool),G(C.globalConfig),G(C.user),G(C.baseMint),G(C.quoteMint),G(C.lpMint),G(C.userBaseTokenAccount),G(C.userQuoteTokenAccount),G(C.userPoolTokenAccount),G(C.poolBaseTokenAccount),G(C.poolQuoteTokenAccount),G(C.tokenProgram),G(C.token2022Program),G(C.eventAuthority),G(C.program)],data:JS().encode(W),programAddress:P})}var vy=new Uint8Array([241,154,109,4,17,177,109,188]);var by=new Uint8Array([149,8,156,202,160,252,176,217]);var Bq=0;async function Oq(T){let{user:A,baseMint:P,quoteMint:Q,index:C=Bq,poolAddress:W,poolCreator:G,maxBaseIn:J,maxQuoteIn:$,minLpOut:X=0n,tokenProgram:Z=FT,token2022Program:R=i8}=T;if(J<=0n)throw Error("maxBaseIn must be positive");if($<=0n)throw Error("maxQuoteIn must be positive");if(X<0n)throw Error("minLpOut cannot be negative");let D=b(A.address),z=b(P),S=b(Q),E=b(Z),w=b(R),O=W?b(W):await BW(C,b(G??D),z,S),m=await _W(),g=await OW(O),p=await xW(D,g),[c]=await MT({owner:D,tokenProgram:E,mint:z}),[o]=await MT({owner:D,tokenProgram:E,mint:S}),f=await h2(O,z,E),d=await h2(O,S,E),_=await hW();return Lq({pool:O,globalConfig:m,user:A,baseMint:z,quoteMint:S,lpMint:g,userBaseTokenAccount:c,userQuoteTokenAccount:o,userPoolTokenAccount:p,poolBaseTokenAccount:f,poolQuoteTokenAccount:d,tokenProgram:E,token2022Program:w,eventAuthority:_,program:b(N0),lpTokenAmountOut:X,maxBaseAmountIn:J,maxQuoteAmountIn:$},{programAddress:b(N0)})}async function xq(T){let{user:A,baseMint:P,quoteMint:Q,index:C=Bq,poolAddress:W,poolCreator:G,lpAmountIn:J,minBaseOut:$=0n,minQuoteOut:X=0n,tokenProgram:Z=FT,token2022Program:R=i8}=T;if(J<=0n)throw Error("lpAmountIn must be positive");if($<0n)throw Error("minBaseOut cannot be negative");if(X<0n)throw Error("minQuoteOut cannot be negative");let D=b(A.address),z=b(P),S=b(Q),E=b(Z),w=b(R),O=W?b(W):await BW(C,b(G??D),z,S),m=await _W(),g=await OW(O),p=await xW(D,g),[c]=await MT({owner:D,tokenProgram:E,mint:z}),[o]=await MT({owner:D,tokenProgram:E,mint:S}),f=await h2(O,z,E),d=await h2(O,S,E),_=await hW();return Eq({pool:O,globalConfig:m,user:A,baseMint:z,quoteMint:S,lpMint:g,userBaseTokenAccount:c,userQuoteTokenAccount:o,userPoolTokenAccount:p,poolBaseTokenAccount:f,poolQuoteTokenAccount:d,tokenProgram:E,token2022Program:w,eventAuthority:_,program:b(N0),lpTokenAmountIn:J,minBaseAmountOut:$,minQuoteAmountOut:X},{programAddress:b(N0)})}function $S(T){let{owner:A,amount:P,payer:Q=A,associatedTokenAddress:C,createAta:W=!0,autoClose:G=!1}=T;if(P<=0n)throw Error("Amount must be positive when wrapping SOL");let J=mW(A),$=mW(Q),X=C?new n(C):_2(new n(xA),J,!1,fT,v0),Z=[],R=[];if(W)Z.push(m2(N4($,X,J,new n(xA))));if(Z.push(m2(UT.transfer({fromPubkey:$,toPubkey:X,lamports:Number(P)}))),Z.push(m2(jq(X))),G)R.push(m2(SW(X,$,J)));return{prepend:Z,append:R,associatedTokenAddress:b(X.toBase58())}}function VS(T,A){let P=mW(T),Q=A?new n(A):_2(new n(xA),P,!1,fT,v0);return[m2(SW(Q,P,P))]}function mW(T){if(typeof T==="string")return new n(T);if(typeof T==="object"&&"address"in T)return new n(T.address);return new n(T)}function m2(T){return{programAddress:b(T.programId.toBase58()),accounts:T.keys.map((A)=>({address:b(A.pubkey.toBase58()),role:A.isSigner?A.isWritable?X1.WRITABLE_SIGNER:X1.READONLY_SIGNER:A.isWritable?X1.WRITABLE:X1.READONLY})),data:T.data}}var xA="So11111111111111111111111111111111111111112";var qS=xA;async function _q(T){let{user:A,baseMint:P,quoteMint:Q=xA,poolIndex:C,poolAddress:W,poolCreator:G,maxBaseAmountIn:J,maxQuoteAmountIn:$,minLpTokensOut:X,tokenProgram:Z,token2022Program:R}=T;if(J<=0n)throw Error("maxBaseAmountIn must be positive");if($<=0n)throw Error("maxQuoteAmountIn must be positive");return await Oq({user:A,baseMint:P,quoteMint:Q,index:C,poolAddress:W,poolCreator:G,maxBaseIn:J,maxQuoteIn:$,minLpOut:X??0n,tokenProgram:Z,token2022Program:R})}async function hq(T){let{user:A,baseMint:P,quoteMint:Q=xA,poolIndex:C,poolAddress:W,poolCreator:G,lpAmountIn:J,minBaseAmountOut:$,minQuoteAmountOut:X,tokenProgram:Z,token2022Program:R}=T;if(J<=0n)throw Error("lpAmountIn must be positive");return await xq({user:A,baseMint:P,quoteMint:Q,index:C,poolAddress:W,poolCreator:G,lpAmountIn:J,minBaseOut:$??0n,minQuoteOut:X??0n,tokenProgram:Z,token2022Program:R})}async function YS(T,A,P,Q,C={}){return _q({user:T,baseMint:A,maxBaseAmountIn:P,maxQuoteAmountIn:Q,...C})}async function ZS(T,A,P,Q={}){return hq({user:T,baseMint:A,lpAmountIn:P,...Q})}class gW{connection;programId;commitment;listeners=new Map;nextListenerId=1;subscriptionId=null;constructor(T,A={}){this.connection=T,this.programId=new n(A.programId??dT),this.commitment=A.commitment??"confirmed"}addEventListener(T,A){let P=this.nextListenerId++;return this.listeners.set(P,{id:P,type:T,callback:A}),this.ensureSubscription(),P}removeEventListener(T){if(this.listeners.delete(T),this.listeners.size===0)this.teardownSubscription()}ensureSubscription(){if(this.subscriptionId!==null)return;let T=(A,P)=>{this.dispatch(A,P.slot)};try{let A=this.connection.onLogs(this.programId,T,this.commitment);this.subscriptionId=A}catch(A){console.error("Failed to subscribe to Pump.fun logs",A)}}async teardownSubscription(){if(this.subscriptionId!==null){try{await this.connection.removeOnLogsListener(this.subscriptionId)}catch(T){console.warn("Failed to remove Pump.fun log listener",T)}this.subscriptionId=null}}dispatch(T,A){let P=T.signature??"";for(let Q of T.logs){let C=HS(Q,A,P);for(let W of this.listeners.values())if(W.type==="raw"||W.type===C.type)W.callback(C)}}}var XS={create:["createEvent","create_event"],trade:["tradeEvent","trade_event"],complete:["completeEvent","complete_event"],raw:[]};function HS(T,A,P){let Q="raw";for(let[G,J]of Object.entries(XS)){if(G==="raw")continue;if(J.some(($)=>T.includes($))){Q=G;break}}let C,W=T.indexOf("{");if(W!==-1){let G=T.slice(W);try{C=JSON.parse(G)}catch{C=void 0}}return{type:Q,slot:A,signature:P,rawLog:T,parsed:C}}function KS(T,A={}){return new gW(T,A)}export{E0 as validateSlippage,aI as validateMintParams,t8 as subSlippage,sI as simulateTransaction,jR as setDefaultCommitment,EW as sendAndConfirmTransaction,IR as sellWithSlippage,MQ as sellSimple,Iq as sell,hq as removeLiquidity,iI as quickSell,ZS as quickRemoveLiquidity,fI as quickBuy,YS as quickAddLiquidity,DR as percentToBps,wW as mintWithFirstBuy,JT as getDefaultCommitment,KS as createPumpEventManager,AS as createAndBuy,zR as buyWithSlippage,FQ as buySimple,zq as buy,$S as buildWrapSolInstructions,VS as buildUnwrapSolInstructions,LW as buildTransaction,Nq as buildPriorityFeeInstructions,FR as bpsToPercent,s8 as addSlippage,_q as addLiquidity,xA as WSOL_ADDRESS,qS as WSOL,gW as PumpEventManager,L0 as DEFAULT_SLIPPAGE_BPS};
|
|
24
|
+
|
|
25
|
+
//# debugId=DCD7DDBE1978EC3A64756E2164756E21
|