pump-kit 0.2.4 → 0.2.5

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.
Files changed (98) hide show
  1. package/README.md +12 -36
  2. package/dist/index.js +12 -12
  3. package/dist/types/ammsdk/generated/accounts/bondingCurve.d.ts +43 -0
  4. package/dist/types/ammsdk/generated/accounts/feeConfig.d.ts +33 -0
  5. package/dist/types/ammsdk/generated/accounts/globalConfig.d.ts +16 -4
  6. package/dist/types/ammsdk/generated/accounts/globalVolumeAccumulator.d.ts +37 -0
  7. package/dist/types/ammsdk/generated/accounts/index.d.ts +5 -0
  8. package/dist/types/ammsdk/generated/accounts/pool.d.ts +6 -0
  9. package/dist/types/ammsdk/generated/accounts/sharingConfig.d.ts +39 -0
  10. package/dist/types/ammsdk/generated/accounts/userVolumeAccumulator.d.ts +43 -0
  11. package/dist/types/ammsdk/generated/errors/pumpAmm.d.ts +79 -29
  12. package/dist/types/ammsdk/generated/instructions/adminSetCoinCreator.d.ts +63 -0
  13. package/dist/types/ammsdk/generated/instructions/adminUpdateTokenIncentives.d.ts +99 -0
  14. package/dist/types/ammsdk/generated/instructions/buy.d.ts +67 -14
  15. package/dist/types/ammsdk/generated/instructions/buyExactQuoteIn.d.ts +144 -0
  16. package/dist/types/ammsdk/generated/instructions/claimCashback.d.ts +74 -0
  17. package/dist/types/ammsdk/generated/instructions/claimTokenIncentives.d.ts +86 -0
  18. package/dist/types/ammsdk/generated/instructions/closeUserVolumeAccumulator.d.ts +54 -0
  19. package/dist/types/ammsdk/generated/instructions/collectCoinCreatorFee.d.ts +70 -0
  20. package/dist/types/ammsdk/generated/instructions/createConfig.d.ts +26 -5
  21. package/dist/types/ammsdk/generated/instructions/createPool.d.ts +51 -12
  22. package/dist/types/ammsdk/generated/instructions/deposit.d.ts +33 -10
  23. package/dist/types/ammsdk/generated/instructions/disable.d.ts +16 -2
  24. package/dist/types/ammsdk/generated/instructions/extendAccount.d.ts +12 -2
  25. package/dist/types/ammsdk/generated/instructions/index.d.ts +15 -0
  26. package/dist/types/ammsdk/generated/instructions/initUserVolumeAccumulator.d.ts +62 -0
  27. package/dist/types/ammsdk/generated/instructions/migratePoolCoinCreator.d.ts +54 -0
  28. package/dist/types/ammsdk/generated/instructions/sell.d.ts +54 -14
  29. package/dist/types/ammsdk/generated/instructions/setCoinCreator.d.ts +58 -0
  30. package/dist/types/ammsdk/generated/instructions/setReservedFeeRecipients.d.ts +59 -0
  31. package/dist/types/ammsdk/generated/instructions/syncUserVolumeAccumulator.d.ts +58 -0
  32. package/dist/types/ammsdk/generated/instructions/toggleCashbackEnabled.d.ts +59 -0
  33. package/dist/types/ammsdk/generated/instructions/toggleMayhemMode.d.ts +59 -0
  34. package/dist/types/ammsdk/generated/instructions/transferCreatorFeesToPump.d.ts +81 -0
  35. package/dist/types/ammsdk/generated/instructions/updateAdmin.d.ts +12 -2
  36. package/dist/types/ammsdk/generated/instructions/updateFeeConfig.d.ts +22 -2
  37. package/dist/types/ammsdk/generated/instructions/withdraw.d.ts +33 -10
  38. package/dist/types/ammsdk/generated/programs/pumpAmm.d.ts +65 -15
  39. package/dist/types/ammsdk/generated/types/adminSetCoinCreatorEvent.d.ts +27 -0
  40. package/dist/types/ammsdk/generated/types/adminUpdateTokenIncentivesEvent.d.ts +29 -0
  41. package/dist/types/ammsdk/generated/types/buyEvent.d.ts +29 -4
  42. package/dist/types/ammsdk/generated/types/claimCashbackEvent.d.ts +25 -0
  43. package/dist/types/ammsdk/generated/types/claimTokenIncentivesEvent.d.ts +27 -0
  44. package/dist/types/ammsdk/generated/types/closeUserVolumeAccumulatorEvent.d.ts +27 -0
  45. package/dist/types/ammsdk/generated/types/collectCoinCreatorFeeEvent.d.ts +25 -0
  46. package/dist/types/ammsdk/generated/types/configStatus.d.ts +16 -0
  47. package/dist/types/ammsdk/generated/types/createConfigEvent.d.ts +4 -0
  48. package/dist/types/ammsdk/generated/types/createPoolEvent.d.ts +4 -0
  49. package/dist/types/ammsdk/generated/types/feeTier.d.ts +20 -0
  50. package/dist/types/ammsdk/generated/types/fees.d.ts +21 -0
  51. package/dist/types/ammsdk/generated/types/index.d.ts +17 -2
  52. package/dist/types/ammsdk/generated/types/initUserVolumeAccumulatorEvent.d.ts +21 -0
  53. package/dist/types/ammsdk/generated/types/migratePoolCoinCreatorEvent.d.ts +27 -0
  54. package/dist/types/ammsdk/generated/types/optionBool.d.ts +13 -0
  55. package/dist/types/ammsdk/generated/types/reservedFeeRecipientsEvent.d.ts +21 -0
  56. package/dist/types/ammsdk/generated/types/sellEvent.d.ts +10 -0
  57. package/dist/types/ammsdk/generated/types/setBondingCurveCoinCreatorEvent.d.ts +25 -0
  58. package/dist/types/ammsdk/generated/types/setMetaplexCoinCreatorEvent.d.ts +25 -0
  59. package/dist/types/ammsdk/generated/types/shareholder.d.ts +16 -0
  60. package/dist/types/ammsdk/generated/types/syncUserVolumeAccumulatorEvent.d.ts +23 -0
  61. package/dist/types/ammsdk/generated/types/updateFeeConfigEvent.d.ts +4 -0
  62. package/dist/types/clients/amm.d.ts +2 -10
  63. package/dist/types/pumpsdk/generated/accounts/bondingCurve.d.ts +4 -0
  64. package/dist/types/pumpsdk/generated/accounts/global.d.ts +12 -0
  65. package/dist/types/pumpsdk/generated/accounts/index.d.ts +1 -0
  66. package/dist/types/pumpsdk/generated/accounts/sharingConfig.d.ts +39 -0
  67. package/dist/types/pumpsdk/generated/accounts/userVolumeAccumulator.d.ts +4 -0
  68. package/dist/types/pumpsdk/generated/errors/pump.d.ts +29 -1
  69. package/dist/types/pumpsdk/generated/instructions/buy.d.ts +1 -1
  70. package/dist/types/pumpsdk/generated/instructions/buyExactSolIn.d.ts +1 -1
  71. package/dist/types/pumpsdk/generated/instructions/claimCashback.d.ts +58 -0
  72. package/dist/types/pumpsdk/generated/instructions/createV2.d.ts +128 -0
  73. package/dist/types/pumpsdk/generated/instructions/distributeCreatorFees.d.ts +66 -0
  74. package/dist/types/pumpsdk/generated/instructions/getMinimumDistributableFee.d.ts +54 -0
  75. package/dist/types/pumpsdk/generated/instructions/index.d.ts +10 -0
  76. package/dist/types/pumpsdk/generated/instructions/migrateBondingCurveCreator.d.ts +58 -0
  77. package/dist/types/pumpsdk/generated/instructions/setMayhemVirtualParams.d.ts +70 -0
  78. package/dist/types/pumpsdk/generated/instructions/setReservedFeeRecipients.d.ts +59 -0
  79. package/dist/types/pumpsdk/generated/instructions/toggleCashbackEnabled.d.ts +59 -0
  80. package/dist/types/pumpsdk/generated/instructions/toggleCreateV2.d.ts +59 -0
  81. package/dist/types/pumpsdk/generated/instructions/toggleMayhemMode.d.ts +59 -0
  82. package/dist/types/pumpsdk/generated/programs/pump.d.ts +47 -16
  83. package/dist/types/pumpsdk/generated/types/claimCashbackEvent.d.ts +25 -0
  84. package/dist/types/pumpsdk/generated/types/configStatus.d.ts +16 -0
  85. package/dist/types/pumpsdk/generated/types/createEvent.d.ts +6 -0
  86. package/dist/types/pumpsdk/generated/types/distributeCreatorFeesEvent.d.ts +30 -0
  87. package/dist/types/pumpsdk/generated/types/index.d.ts +8 -0
  88. package/dist/types/pumpsdk/generated/types/migrateBondingCurveCreatorEvent.d.ts +27 -0
  89. package/dist/types/pumpsdk/generated/types/minimumDistributableFeeEvent.d.ts +21 -0
  90. package/dist/types/pumpsdk/generated/types/reservedFeeRecipientsEvent.d.ts +21 -0
  91. package/dist/types/pumpsdk/generated/types/shareholder.d.ts +16 -0
  92. package/dist/types/pumpsdk/generated/types/tradeEvent.d.ts +6 -0
  93. package/dist/types/pumpsdk/generated/types/updateMayhemVirtualParamsEvent.d.ts +31 -0
  94. package/llms.txt +24 -0
  95. package/metadata/actions-registry.json +278 -0
  96. package/package.json +4 -2
  97. package/dist/types/ammsdk/generated/types/globalConfig.d.ts +0 -49
  98. package/dist/types/ammsdk/generated/types/pool.d.ts +0 -35
package/dist/index.js CHANGED
@@ -1,23 +1,23 @@
1
- var jq=Object.create;var{getPrototypeOf:Rq,defineProperty:A2,getOwnPropertyNames:KG,getOwnPropertyDescriptor:Dq}=Object,CG=Object.prototype.hasOwnProperty;var n0=(T,A,Q)=>{Q=T!=null?jq(Rq(T)):{};let J=A||!T||!T.__esModule?A2(Q,"default",{value:T,enumerable:!0}):Q;for(let $ of KG(T))if(!CG.call(J,$))A2(J,$,{get:()=>T[$],enumerable:!0});return J},qG=new WeakMap,VA=(T)=>{var A=qG.get(T),Q;if(A)return A;if(A=A2({},"__esModule",{value:!0}),T&&typeof T==="object"||typeof T==="function")KG(T).map((J)=>!CG.call(A,J)&&A2(A,J,{get:()=>T[J],enumerable:!(Q=Dq(T,J))||Q.enumerable}));return qG.set(T,A),A},ZT=(T,A)=>()=>(A||T((A={exports:{}}).exports,A),A.exports);var P4=(T,A)=>{for(var Q in A)A2(T,Q,{get:A[Q],enumerable:!0,configurable:!0,set:(J)=>A[Q]=()=>J})};var w0=(T,A)=>()=>(T&&(A=T(T=0)),A);var VG=ZT((Lq)=>{Lq.byteLength=kq;Lq.toByteArray=Fq;Lq.fromByteArray=Sq;var NT=[],XT=[],Mq=typeof Uint8Array<"u"?Uint8Array:Array,q4="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(q8=0,K4=q4.length;q8<K4;++q8)NT[q8]=q4[q8],XT[q4.charCodeAt(q8)]=q8;var q8,K4;XT[45]=62;XT[95]=63;function HG(T){var A=T.length;if(A%4>0)throw Error("Invalid string. Length must be a multiple of 4");var Q=T.indexOf("=");if(Q===-1)Q=A;var J=Q===A?0:4-Q%4;return[Q,J]}function kq(T){var A=HG(T),Q=A[0],J=A[1];return(Q+J)*3/4-J}function zq(T,A,Q){return(A+Q)*3/4-Q}function Fq(T){var A,Q=HG(T),J=Q[0],$=Q[1],W=new Mq(zq(T,J,$)),G=0,Y=$>0?J-4:J,Z;for(Z=0;Z<Y;Z+=4)A=XT[T.charCodeAt(Z)]<<18|XT[T.charCodeAt(Z+1)]<<12|XT[T.charCodeAt(Z+2)]<<6|XT[T.charCodeAt(Z+3)],W[G++]=A>>16&255,W[G++]=A>>8&255,W[G++]=A&255;if($===2)A=XT[T.charCodeAt(Z)]<<2|XT[T.charCodeAt(Z+1)]>>4,W[G++]=A&255;if($===1)A=XT[T.charCodeAt(Z)]<<10|XT[T.charCodeAt(Z+1)]<<4|XT[T.charCodeAt(Z+2)]>>2,W[G++]=A>>8&255,W[G++]=A&255;return W}function Nq(T){return NT[T>>18&63]+NT[T>>12&63]+NT[T>>6&63]+NT[T&63]}function Iq(T,A,Q){var J,$=[];for(var W=A;W<Q;W+=3)J=(T[W]<<16&16711680)+(T[W+1]<<8&65280)+(T[W+2]&255),$.push(Nq(J));return $.join("")}function Sq(T){var A,Q=T.length,J=Q%3,$=[],W=16383;for(var G=0,Y=Q-J;G<Y;G+=W)$.push(Iq(T,G,G+W>Y?Y:G+W));if(J===1)A=T[Q-1],$.push(NT[A>>2]+NT[A<<4&63]+"==");else if(J===2)A=(T[Q-2]<<8)+T[Q-1],$.push(NT[A>>10]+NT[A>>4&63]+NT[A<<2&63]+"=");return $.join("")}});var jG=ZT((Bq)=>{/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */Bq.read=function(T,A,Q,J,$){var W,G,Y=$*8-J-1,Z=(1<<Y)-1,C=Z>>1,K=-7,j=Q?$-1:0,M=Q?-1:1,z=T[A+j];j+=M,W=z&(1<<-K)-1,z>>=-K,K+=Y;for(;K>0;W=W*256+T[A+j],j+=M,K-=8);G=W&(1<<-K)-1,W>>=-K,K+=J;for(;K>0;G=G*256+T[A+j],j+=M,K-=8);if(W===0)W=1-C;else if(W===Z)return G?NaN:(z?-1:1)*(1/0);else G=G+Math.pow(2,J),W=W-C;return(z?-1:1)*G*Math.pow(2,W-J)};Bq.write=function(T,A,Q,J,$,W){var G,Y,Z,C=W*8-$-1,K=(1<<C)-1,j=K>>1,M=$===23?Math.pow(2,-24)-Math.pow(2,-77):0,z=J?0:W-1,N=J?1:-1,E=A<0||A===0&&1/A<0?1:0;if(A=Math.abs(A),isNaN(A)||A===1/0)Y=isNaN(A)?1:0,G=K;else{if(G=Math.floor(Math.log(A)/Math.LN2),A*(Z=Math.pow(2,-G))<1)G--,Z*=2;if(G+j>=1)A+=M/Z;else A+=M*Math.pow(2,1-j);if(A*Z>=2)G++,Z/=2;if(G+j>=K)Y=0,G=K;else if(G+j>=1)Y=(A*Z-1)*Math.pow(2,$),G=G+j;else Y=A*Math.pow(2,j-1)*Math.pow(2,$),G=0}for(;$>=8;T[Q+z]=Y&255,z+=N,Y/=256,$-=8);G=G<<$|Y,C+=$;for(;C>0;T[Q+z]=G&255,z+=N,G/=256,C-=8);T[Q+z-N]|=E*128}});var l6={};P4(l6,{transcode:()=>Lj,resolveObjectURL:()=>Nj,kStringMaxLength:()=>MZ,kMaxLength:()=>V2,isUtf8:()=>Ij,isAscii:()=>Sj,default:()=>wj,constants:()=>t5,btoa:()=>i5,atob:()=>o5,INSPECT_MAX_BYTES:()=>DZ,File:()=>a5,Buffer:()=>w,Blob:()=>s5});function d5(T){var A=T.length;if(A%4>0)throw Error("Invalid string. Length must be a multiple of 4");var Q=T.indexOf("=");if(Q===-1)Q=A;var J=Q===A?0:4-Q%4;return[Q,J]}function c5(T,A){return(T+A)*3/4-A}function f5(T){var A,Q=d5(T),J=Q[0],$=Q[1],W=new Uint8Array(c5(J,$)),G=0,Y=$>0?J-4:J,Z;for(Z=0;Z<Y;Z+=4)A=KT[T.charCodeAt(Z)]<<18|KT[T.charCodeAt(Z+1)]<<12|KT[T.charCodeAt(Z+2)]<<6|KT[T.charCodeAt(Z+3)],W[G++]=A>>16&255,W[G++]=A>>8&255,W[G++]=A&255;if($===2)A=KT[T.charCodeAt(Z)]<<2|KT[T.charCodeAt(Z+1)]>>4,W[G++]=A&255;if($===1)A=KT[T.charCodeAt(Z)]<<10|KT[T.charCodeAt(Z+1)]<<4|KT[T.charCodeAt(Z+2)]>>2,W[G++]=A>>8&255,W[G++]=A&255;return W}function r5(T){return hT[T>>18&63]+hT[T>>12&63]+hT[T>>6&63]+hT[T&63]}function n5(T,A,Q){var J,$=[];for(var W=A;W<Q;W+=3)J=(T[W]<<16&16711680)+(T[W+1]<<8&65280)+(T[W+2]&255),$.push(r5(J));return $.join("")}function KZ(T){var A,Q=T.length,J=Q%3,$=[],W=16383;for(var G=0,Y=Q-J;G<Y;G+=W)$.push(n5(T,G,G+W>Y?Y:G+W));if(J===1)A=T[Q-1],$.push(hT[A>>2]+hT[A<<4&63]+"==");else if(J===2)A=(T[Q-2]<<8)+T[Q-1],$.push(hT[A>>10]+hT[A>>4&63]+hT[A<<2&63]+"=");return $.join("")}function b6(T,A,Q,J,$){var W,G,Y=$*8-J-1,Z=(1<<Y)-1,C=Z>>1,K=-7,j=Q?$-1:0,M=Q?-1:1,z=T[A+j];j+=M,W=z&(1<<-K)-1,z>>=-K,K+=Y;for(;K>0;W=W*256+T[A+j],j+=M,K-=8);G=W&(1<<-K)-1,W>>=-K,K+=J;for(;K>0;G=G*256+T[A+j],j+=M,K-=8);if(W===0)W=1-C;else if(W===Z)return G?NaN:(z?-1:1)*(1/0);else G=G+Math.pow(2,J),W=W-C;return(z?-1:1)*G*Math.pow(2,W-J)}function RZ(T,A,Q,J,$,W){var G,Y,Z,C=W*8-$-1,K=(1<<C)-1,j=K>>1,M=$===23?Math.pow(2,-24)-Math.pow(2,-77):0,z=J?0:W-1,N=J?1:-1,E=A<0||A===0&&1/A<0?1:0;if(A=Math.abs(A),isNaN(A)||A===1/0)Y=isNaN(A)?1:0,G=K;else{if(G=Math.floor(Math.log(A)/Math.LN2),A*(Z=Math.pow(2,-G))<1)G--,Z*=2;if(G+j>=1)A+=M/Z;else A+=M*Math.pow(2,1-j);if(A*Z>=2)G++,Z/=2;if(G+j>=K)Y=0,G=K;else if(G+j>=1)Y=(A*Z-1)*Math.pow(2,$),G=G+j;else Y=A*Math.pow(2,j-1)*Math.pow(2,$),G=0}for(;$>=8;T[Q+z]=Y&255,z+=N,Y/=256,$-=8);G=G<<$|Y,C+=$;for(;C>0;T[Q+z]=G&255,z+=N,G/=256,C-=8);T[Q+z-N]|=E*128}function oT(T){if(T>V2)throw RangeError('The value "'+T+'" is invalid for option "size"');let A=new Uint8Array(T);return Object.setPrototypeOf(A,w.prototype),A}function lJ(T,A,Q){return class extends Q{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(J){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:J,writable:!0})}toString(){return`${this.name} [${T}]: ${this.message}`}}}function w(T,A,Q){if(typeof T==="number"){if(typeof A==="string")throw TypeError('The "string" argument must be of type string. Received type number');return uJ(T)}return kZ(T,A,Q)}function kZ(T,A,Q){if(typeof T==="string")return Qj(T,A);if(ArrayBuffer.isView(T))return Jj(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(gT(T,ArrayBuffer)||T&&gT(T.buffer,ArrayBuffer))return bJ(T,A,Q);if(typeof SharedArrayBuffer<"u"&&(gT(T,SharedArrayBuffer)||T&&gT(T.buffer,SharedArrayBuffer)))return bJ(T,A,Q);if(typeof T==="number")throw TypeError('The "value" argument must not be of type number. Received type number');let J=T.valueOf&&T.valueOf();if(J!=null&&J!==T)return w.from(J,A,Q);let $=$j(T);if($)return $;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof T[Symbol.toPrimitive]==="function")return w.from(T[Symbol.toPrimitive]("string"),A,Q);throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof T)}function zZ(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 Aj(T,A,Q){if(zZ(T),T<=0)return oT(T);if(A!==void 0)return typeof Q==="string"?oT(T).fill(A,Q):oT(T).fill(A);return oT(T)}function uJ(T){return zZ(T),oT(T<0?0:dJ(T)|0)}function Qj(T,A){if(typeof A!=="string"||A==="")A="utf8";if(!w.isEncoding(A))throw TypeError("Unknown encoding: "+A);let Q=FZ(T,A)|0,J=oT(Q),$=J.write(T,A);if($!==Q)J=J.slice(0,$);return J}function yJ(T){let A=T.length<0?0:dJ(T.length)|0,Q=oT(A);for(let J=0;J<A;J+=1)Q[J]=T[J]&255;return Q}function Jj(T){if(gT(T,Uint8Array)){let A=new Uint8Array(T);return bJ(A.buffer,A.byteOffset,A.byteLength)}return yJ(T)}function bJ(T,A,Q){if(A<0||T.byteLength<A)throw RangeError('"offset" is outside of buffer bounds');if(T.byteLength<A+(Q||0))throw RangeError('"length" is outside of buffer bounds');let J;if(A===void 0&&Q===void 0)J=new Uint8Array(T);else if(Q===void 0)J=new Uint8Array(T,A);else J=new Uint8Array(T,A,Q);return Object.setPrototypeOf(J,w.prototype),J}function $j(T){if(w.isBuffer(T)){let A=dJ(T.length)|0,Q=oT(A);if(Q.length===0)return Q;return T.copy(Q,0,0,A),Q}if(T.length!==void 0){if(typeof T.length!=="number"||Number.isNaN(T.length))return oT(0);return yJ(T)}if(T.type==="Buffer"&&Array.isArray(T.data))return yJ(T.data)}function dJ(T){if(T>=V2)throw RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+V2.toString(16)+" bytes");return T|0}function FZ(T,A){if(w.isBuffer(T))return T.length;if(ArrayBuffer.isView(T)||gT(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 Q=T.length,J=arguments.length>2&&arguments[2]===!0;if(!J&&Q===0)return 0;let $=!1;for(;;)switch(A){case"ascii":case"latin1":case"binary":return Q;case"utf8":case"utf-8":return pJ(T).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Q*2;case"hex":return Q>>>1;case"base64":return _Z(T).length;default:if($)return J?-1:pJ(T).length;A=(""+A).toLowerCase(),$=!0}}function Wj(T,A,Q){let J=!1;if(A===void 0||A<0)A=0;if(A>this.length)return"";if(Q===void 0||Q>this.length)Q=this.length;if(Q<=0)return"";if(Q>>>=0,A>>>=0,Q<=A)return"";if(!T)T="utf8";while(!0)switch(T){case"hex":return Hj(this,A,Q);case"utf8":case"utf-8":return IZ(this,A,Q);case"ascii":return Kj(this,A,Q);case"latin1":case"binary":return Cj(this,A,Q);case"base64":return Pj(this,A,Q);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Vj(this,A,Q);default:if(J)throw TypeError("Unknown encoding: "+T);T=(T+"").toLowerCase(),J=!0}}function a8(T,A,Q){let J=T[A];T[A]=T[Q],T[Q]=J}function NZ(T,A,Q,J,$){if(T.length===0)return-1;if(typeof Q==="string")J=Q,Q=0;else if(Q>2147483647)Q=2147483647;else if(Q<-2147483648)Q=-2147483648;if(Q=+Q,Number.isNaN(Q))Q=$?0:T.length-1;if(Q<0)Q=T.length+Q;if(Q>=T.length)if($)return-1;else Q=T.length-1;else if(Q<0)if($)Q=0;else return-1;if(typeof A==="string")A=w.from(A,J);if(w.isBuffer(A)){if(A.length===0)return-1;return HZ(T,A,Q,J,$)}else if(typeof A==="number"){if(A=A&255,typeof Uint8Array.prototype.indexOf==="function")if($)return Uint8Array.prototype.indexOf.call(T,A,Q);else return Uint8Array.prototype.lastIndexOf.call(T,A,Q);return HZ(T,[A],Q,J,$)}throw TypeError("val must be string, number or Buffer")}function HZ(T,A,Q,J,$){let W=1,G=T.length,Y=A.length;if(J!==void 0){if(J=String(J).toLowerCase(),J==="ucs2"||J==="ucs-2"||J==="utf16le"||J==="utf-16le"){if(T.length<2||A.length<2)return-1;W=2,G/=2,Y/=2,Q/=2}}function Z(K,j){if(W===1)return K[j];else return K.readUInt16BE(j*W)}let C;if($){let K=-1;for(C=Q;C<G;C++)if(Z(T,C)===Z(A,K===-1?0:C-K)){if(K===-1)K=C;if(C-K+1===Y)return K*W}else{if(K!==-1)C-=C-K;K=-1}}else{if(Q+Y>G)Q=G-Y;for(C=Q;C>=0;C--){let K=!0;for(let j=0;j<Y;j++)if(Z(T,C+j)!==Z(A,j)){K=!1;break}if(K)return C}}return-1}function Gj(T,A,Q,J){Q=Number(Q)||0;let $=T.length-Q;if(!J)J=$;else if(J=Number(J),J>$)J=$;let W=A.length;if(J>W/2)J=W/2;let G;for(G=0;G<J;++G){let Y=parseInt(A.substr(G*2,2),16);if(Number.isNaN(Y))return G;T[Q+G]=Y}return G}function Uj(T,A,Q,J){return p6(pJ(A,T.length-Q),T,Q,J)}function Yj(T,A,Q,J){return p6(Mj(A),T,Q,J)}function Zj(T,A,Q,J){return p6(_Z(A),T,Q,J)}function Xj(T,A,Q,J){return p6(kj(A,T.length-Q),T,Q,J)}function Pj(T,A,Q){if(A===0&&Q===T.length)return KZ(T);else return KZ(T.slice(A,Q))}function IZ(T,A,Q){Q=Math.min(T.length,Q);let J=[],$=A;while($<Q){let W=T[$],G=null,Y=W>239?4:W>223?3:W>191?2:1;if($+Y<=Q){let Z,C,K,j;switch(Y){case 1:if(W<128)G=W;break;case 2:if(Z=T[$+1],(Z&192)===128){if(j=(W&31)<<6|Z&63,j>127)G=j}break;case 3:if(Z=T[$+1],C=T[$+2],(Z&192)===128&&(C&192)===128){if(j=(W&15)<<12|(Z&63)<<6|C&63,j>2047&&(j<55296||j>57343))G=j}break;case 4:if(Z=T[$+1],C=T[$+2],K=T[$+3],(Z&192)===128&&(C&192)===128&&(K&192)===128){if(j=(W&15)<<18|(Z&63)<<12|(C&63)<<6|K&63,j>65535&&j<1114112)G=j}}}if(G===null)G=65533,Y=1;else if(G>65535)G-=65536,J.push(G>>>10&1023|55296),G=56320|G&1023;J.push(G),$+=Y}return qj(J)}function qj(T){let A=T.length;if(A<=VZ)return String.fromCharCode.apply(String,T);let Q="",J=0;while(J<A)Q+=String.fromCharCode.apply(String,T.slice(J,J+=VZ));return Q}function Kj(T,A,Q){let J="";Q=Math.min(T.length,Q);for(let $=A;$<Q;++$)J+=String.fromCharCode(T[$]&127);return J}function Cj(T,A,Q){let J="";Q=Math.min(T.length,Q);for(let $=A;$<Q;++$)J+=String.fromCharCode(T[$]);return J}function Hj(T,A,Q){let J=T.length;if(!A||A<0)A=0;if(!Q||Q<0||Q>J)Q=J;let $="";for(let W=A;W<Q;++W)$+=zj[T[W]];return $}function Vj(T,A,Q){let J=T.slice(A,Q),$="";for(let W=0;W<J.length-1;W+=2)$+=String.fromCharCode(J[W]+J[W+1]*256);return $}function z0(T,A,Q){if(T%1!==0||T<0)throw RangeError("offset is not uint");if(T+A>Q)throw RangeError("Trying to access beyond buffer length")}function s0(T,A,Q,J,$,W){if(!w.isBuffer(T))throw TypeError('"buffer" argument must be a Buffer instance');if(A>$||A<W)throw RangeError('"value" argument is out of bounds');if(Q+J>T.length)throw RangeError("Index out of range")}function SZ(T,A,Q,J,$){BZ(A,J,$,T,Q,7);let W=Number(A&BigInt(4294967295));T[Q++]=W,W=W>>8,T[Q++]=W,W=W>>8,T[Q++]=W,W=W>>8,T[Q++]=W;let G=Number(A>>BigInt(32)&BigInt(4294967295));return T[Q++]=G,G=G>>8,T[Q++]=G,G=G>>8,T[Q++]=G,G=G>>8,T[Q++]=G,Q}function LZ(T,A,Q,J,$){BZ(A,J,$,T,Q,7);let W=Number(A&BigInt(4294967295));T[Q+7]=W,W=W>>8,T[Q+6]=W,W=W>>8,T[Q+5]=W,W=W>>8,T[Q+4]=W;let G=Number(A>>BigInt(32)&BigInt(4294967295));return T[Q+3]=G,G=G>>8,T[Q+2]=G,G=G>>8,T[Q+1]=G,G=G>>8,T[Q]=G,Q+8}function wZ(T,A,Q,J,$,W){if(Q+J>T.length)throw RangeError("Index out of range");if(Q<0)throw RangeError("Index out of range")}function EZ(T,A,Q,J,$){if(A=+A,Q=Q>>>0,!$)wZ(T,A,Q,4,340282346638528860000000000000000000000,-340282346638528860000000000000000000000);return RZ(T,A,Q,J,23,4),Q+4}function OZ(T,A,Q,J,$){if(A=+A,Q=Q>>>0,!$)wZ(T,A,Q,8,179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,-179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000);return RZ(T,A,Q,J,52,8),Q+8}function jZ(T){let A="",Q=T.length,J=T[0]==="-"?1:0;for(;Q>=J+4;Q-=3)A=`_${T.slice(Q-3,Q)}${A}`;return`${T.slice(0,Q)}${A}`}function jj(T,A,Q){if(EA(A,"offset"),T[A]===void 0||T[A+Q]===void 0)j2(A,T.length-(Q+1))}function BZ(T,A,Q,J,$,W){if(T>Q||T<A){let G=typeof A==="bigint"?"n":"",Y;if(W>3)if(A===0||A===BigInt(0))Y=`>= 0${G} and < 2${G} ** ${(W+1)*8}${G}`;else Y=`>= -(2${G} ** ${(W+1)*8-1}${G}) and < 2 ** ${(W+1)*8-1}${G}`;else Y=`>= ${A}${G} and <= ${Q}${G}`;throw new vJ("value",Y,T)}jj(J,$,W)}function EA(T,A){if(typeof T!=="number")throw new Tj(A,"number",T)}function j2(T,A,Q){if(Math.floor(T)!==T)throw EA(T,Q),new vJ(Q||"offset","an integer",T);if(A<0)throw new e5;throw new vJ(Q||"offset",`>= ${Q?1:0} and <= ${A}`,T)}function Dj(T){if(T=T.split("=")[0],T=T.trim().replace(Rj,""),T.length<2)return"";while(T.length%4!==0)T=T+"=";return T}function pJ(T,A){A=A||1/0;let Q,J=T.length,$=null,W=[];for(let G=0;G<J;++G){if(Q=T.charCodeAt(G),Q>55295&&Q<57344){if(!$){if(Q>56319){if((A-=3)>-1)W.push(239,191,189);continue}else if(G+1===J){if((A-=3)>-1)W.push(239,191,189);continue}$=Q;continue}if(Q<56320){if((A-=3)>-1)W.push(239,191,189);$=Q;continue}Q=($-55296<<10|Q-56320)+65536}else if($){if((A-=3)>-1)W.push(239,191,189)}if($=null,Q<128){if((A-=1)<0)break;W.push(Q)}else if(Q<2048){if((A-=2)<0)break;W.push(Q>>6|192,Q&63|128)}else if(Q<65536){if((A-=3)<0)break;W.push(Q>>12|224,Q>>6&63|128,Q&63|128)}else if(Q<1114112){if((A-=4)<0)break;W.push(Q>>18|240,Q>>12&63|128,Q>>6&63|128,Q&63|128)}else throw Error("Invalid code point")}return W}function Mj(T){let A=[];for(let Q=0;Q<T.length;++Q)A.push(T.charCodeAt(Q)&255);return A}function kj(T,A){let Q,J,$,W=[];for(let G=0;G<T.length;++G){if((A-=2)<0)break;Q=T.charCodeAt(G),J=Q>>8,$=Q%256,W.push($),W.push(J)}return W}function _Z(T){return f5(Dj(T))}function p6(T,A,Q,J){let $;for($=0;$<J;++$){if($+Q>=A.length||$>=T.length)break;A[$+Q]=T[$]}return $}function gT(T,A){return T instanceof A||T!=null&&T.constructor!=null&&T.constructor.name!=null&&T.constructor.name===A.name}function z8(T){return typeof BigInt>"u"?Fj:T}function Fj(){throw Error("BigInt not supported")}function cJ(T){return()=>{throw Error(T+" is not implemented for node:buffer browser polyfill")}}var hT,KT,mJ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o8,qZ,CZ,DZ=50,V2=2147483647,MZ=536870888,i5,o5,a5,s5,t5,e5,Tj,vJ,VZ=4096,Rj,zj,Nj,Ij,Sj=(T)=>{for(let A of T)if(A.charCodeAt(0)>127)return!1;return!0},Lj,wj;var OA=w0(()=>{hT=[],KT=[];for(o8=0,qZ=mJ.length;o8<qZ;++o8)hT[o8]=mJ[o8],KT[mJ.charCodeAt(o8)]=o8;KT[45]=62;KT[95]=63;CZ=typeof Symbol==="function"&&typeof Symbol.for==="function"?Symbol.for("nodejs.util.inspect.custom"):null,i5=globalThis.btoa,o5=globalThis.atob,a5=globalThis.File,s5=globalThis.Blob,t5={MAX_LENGTH:V2,MAX_STRING_LENGTH:MZ};e5=lJ("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),Tj=lJ("ERR_INVALID_ARG_TYPE",function(T,A){return`The "${T}" argument must be of type number. Received type ${typeof A}`},TypeError),vJ=lJ("ERR_OUT_OF_RANGE",function(T,A,Q){let J=`The value of "${T}" is out of range.`,$=Q;if(Number.isInteger(Q)&&Math.abs(Q)>4294967296)$=jZ(String(Q));else if(typeof Q==="bigint"){if($=String(Q),Q>BigInt(2)**BigInt(32)||Q<-(BigInt(2)**BigInt(32)))$=jZ($);$+="n"}return J+=` It must be ${A}. Received ${$}`,J},RangeError);Object.defineProperty(w.prototype,"parent",{enumerable:!0,get:function(){if(!w.isBuffer(this))return;return this.buffer}});Object.defineProperty(w.prototype,"offset",{enumerable:!0,get:function(){if(!w.isBuffer(this))return;return this.byteOffset}});w.poolSize=8192;w.from=function(T,A,Q){return kZ(T,A,Q)};Object.setPrototypeOf(w.prototype,Uint8Array.prototype);Object.setPrototypeOf(w,Uint8Array);w.alloc=function(T,A,Q){return Aj(T,A,Q)};w.allocUnsafe=function(T){return uJ(T)};w.allocUnsafeSlow=function(T){return uJ(T)};w.isBuffer=function(T){return T!=null&&T._isBuffer===!0&&T!==w.prototype};w.compare=function(T,A){if(gT(T,Uint8Array))T=w.from(T,T.offset,T.byteLength);if(gT(A,Uint8Array))A=w.from(A,A.offset,A.byteLength);if(!w.isBuffer(T)||!w.isBuffer(A))throw TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(T===A)return 0;let Q=T.length,J=A.length;for(let $=0,W=Math.min(Q,J);$<W;++$)if(T[$]!==A[$]){Q=T[$],J=A[$];break}if(Q<J)return-1;if(J<Q)return 1;return 0};w.isEncoding=function(T){switch(String(T).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}};w.concat=function(T,A){if(!Array.isArray(T))throw TypeError('"list" argument must be an Array of Buffers');if(T.length===0)return w.alloc(0);let Q;if(A===void 0){A=0;for(Q=0;Q<T.length;++Q)A+=T[Q].length}let J=w.allocUnsafe(A),$=0;for(Q=0;Q<T.length;++Q){let W=T[Q];if(gT(W,Uint8Array))if($+W.length>J.length){if(!w.isBuffer(W))W=w.from(W);W.copy(J,$)}else Uint8Array.prototype.set.call(J,W,$);else if(!w.isBuffer(W))throw TypeError('"list" argument must be an Array of Buffers');else W.copy(J,$);$+=W.length}return J};w.byteLength=FZ;w.prototype._isBuffer=!0;w.prototype.swap16=function(){let T=this.length;if(T%2!==0)throw RangeError("Buffer size must be a multiple of 16-bits");for(let A=0;A<T;A+=2)a8(this,A,A+1);return this};w.prototype.swap32=function(){let T=this.length;if(T%4!==0)throw RangeError("Buffer size must be a multiple of 32-bits");for(let A=0;A<T;A+=4)a8(this,A,A+3),a8(this,A+1,A+2);return this};w.prototype.swap64=function(){let T=this.length;if(T%8!==0)throw RangeError("Buffer size must be a multiple of 64-bits");for(let A=0;A<T;A+=8)a8(this,A,A+7),a8(this,A+1,A+6),a8(this,A+2,A+5),a8(this,A+3,A+4);return this};w.prototype.toString=function(){let T=this.length;if(T===0)return"";if(arguments.length===0)return IZ(this,0,T);return Wj.apply(this,arguments)};w.prototype.toLocaleString=w.prototype.toString;w.prototype.equals=function(T){if(!w.isBuffer(T))throw TypeError("Argument must be a Buffer");if(this===T)return!0;return w.compare(this,T)===0};w.prototype.inspect=function(){let T="",A=DZ;if(T=this.toString("hex",0,A).replace(/(.{2})/g,"$1 ").trim(),this.length>A)T+=" ... ";return"<Buffer "+T+">"};if(CZ)w.prototype[CZ]=w.prototype.inspect;w.prototype.compare=function(T,A,Q,J,$){if(gT(T,Uint8Array))T=w.from(T,T.offset,T.byteLength);if(!w.isBuffer(T))throw TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof T);if(A===void 0)A=0;if(Q===void 0)Q=T?T.length:0;if(J===void 0)J=0;if($===void 0)$=this.length;if(A<0||Q>T.length||J<0||$>this.length)throw RangeError("out of range index");if(J>=$&&A>=Q)return 0;if(J>=$)return-1;if(A>=Q)return 1;if(A>>>=0,Q>>>=0,J>>>=0,$>>>=0,this===T)return 0;let W=$-J,G=Q-A,Y=Math.min(W,G),Z=this.slice(J,$),C=T.slice(A,Q);for(let K=0;K<Y;++K)if(Z[K]!==C[K]){W=Z[K],G=C[K];break}if(W<G)return-1;if(G<W)return 1;return 0};w.prototype.includes=function(T,A,Q){return this.indexOf(T,A,Q)!==-1};w.prototype.indexOf=function(T,A,Q){return NZ(this,T,A,Q,!0)};w.prototype.lastIndexOf=function(T,A,Q){return NZ(this,T,A,Q,!1)};w.prototype.write=function(T,A,Q,J){if(A===void 0)J="utf8",Q=this.length,A=0;else if(Q===void 0&&typeof A==="string")J=A,Q=this.length,A=0;else if(isFinite(A))if(A=A>>>0,isFinite(Q)){if(Q=Q>>>0,J===void 0)J="utf8"}else J=Q,Q=void 0;else throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let $=this.length-A;if(Q===void 0||Q>$)Q=$;if(T.length>0&&(Q<0||A<0)||A>this.length)throw RangeError("Attempt to write outside buffer bounds");if(!J)J="utf8";let W=!1;for(;;)switch(J){case"hex":return Gj(this,T,A,Q);case"utf8":case"utf-8":return Uj(this,T,A,Q);case"ascii":case"latin1":case"binary":return Yj(this,T,A,Q);case"base64":return Zj(this,T,A,Q);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Xj(this,T,A,Q);default:if(W)throw TypeError("Unknown encoding: "+J);J=(""+J).toLowerCase(),W=!0}};w.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};w.prototype.slice=function(T,A){let Q=this.length;if(T=~~T,A=A===void 0?Q:~~A,T<0){if(T+=Q,T<0)T=0}else if(T>Q)T=Q;if(A<0){if(A+=Q,A<0)A=0}else if(A>Q)A=Q;if(A<T)A=T;let J=this.subarray(T,A);return Object.setPrototypeOf(J,w.prototype),J};w.prototype.readUintLE=w.prototype.readUIntLE=function(T,A,Q){if(T=T>>>0,A=A>>>0,!Q)z0(T,A,this.length);let J=this[T],$=1,W=0;while(++W<A&&($*=256))J+=this[T+W]*$;return J};w.prototype.readUintBE=w.prototype.readUIntBE=function(T,A,Q){if(T=T>>>0,A=A>>>0,!Q)z0(T,A,this.length);let J=this[T+--A],$=1;while(A>0&&($*=256))J+=this[T+--A]*$;return J};w.prototype.readUint8=w.prototype.readUInt8=function(T,A){if(T=T>>>0,!A)z0(T,1,this.length);return this[T]};w.prototype.readUint16LE=w.prototype.readUInt16LE=function(T,A){if(T=T>>>0,!A)z0(T,2,this.length);return this[T]|this[T+1]<<8};w.prototype.readUint16BE=w.prototype.readUInt16BE=function(T,A){if(T=T>>>0,!A)z0(T,2,this.length);return this[T]<<8|this[T+1]};w.prototype.readUint32LE=w.prototype.readUInt32LE=function(T,A){if(T=T>>>0,!A)z0(T,4,this.length);return(this[T]|this[T+1]<<8|this[T+2]<<16)+this[T+3]*16777216};w.prototype.readUint32BE=w.prototype.readUInt32BE=function(T,A){if(T=T>>>0,!A)z0(T,4,this.length);return this[T]*16777216+(this[T+1]<<16|this[T+2]<<8|this[T+3])};w.prototype.readBigUInt64LE=z8(function(T){T=T>>>0,EA(T,"offset");let A=this[T],Q=this[T+7];if(A===void 0||Q===void 0)j2(T,this.length-8);let J=A+this[++T]*256+this[++T]*65536+this[++T]*16777216,$=this[++T]+this[++T]*256+this[++T]*65536+Q*16777216;return BigInt(J)+(BigInt($)<<BigInt(32))});w.prototype.readBigUInt64BE=z8(function(T){T=T>>>0,EA(T,"offset");let A=this[T],Q=this[T+7];if(A===void 0||Q===void 0)j2(T,this.length-8);let J=A*16777216+this[++T]*65536+this[++T]*256+this[++T],$=this[++T]*16777216+this[++T]*65536+this[++T]*256+Q;return(BigInt(J)<<BigInt(32))+BigInt($)});w.prototype.readIntLE=function(T,A,Q){if(T=T>>>0,A=A>>>0,!Q)z0(T,A,this.length);let J=this[T],$=1,W=0;while(++W<A&&($*=256))J+=this[T+W]*$;if($*=128,J>=$)J-=Math.pow(2,8*A);return J};w.prototype.readIntBE=function(T,A,Q){if(T=T>>>0,A=A>>>0,!Q)z0(T,A,this.length);let J=A,$=1,W=this[T+--J];while(J>0&&($*=256))W+=this[T+--J]*$;if($*=128,W>=$)W-=Math.pow(2,8*A);return W};w.prototype.readInt8=function(T,A){if(T=T>>>0,!A)z0(T,1,this.length);if(!(this[T]&128))return this[T];return(255-this[T]+1)*-1};w.prototype.readInt16LE=function(T,A){if(T=T>>>0,!A)z0(T,2,this.length);let Q=this[T]|this[T+1]<<8;return Q&32768?Q|4294901760:Q};w.prototype.readInt16BE=function(T,A){if(T=T>>>0,!A)z0(T,2,this.length);let Q=this[T+1]|this[T]<<8;return Q&32768?Q|4294901760:Q};w.prototype.readInt32LE=function(T,A){if(T=T>>>0,!A)z0(T,4,this.length);return this[T]|this[T+1]<<8|this[T+2]<<16|this[T+3]<<24};w.prototype.readInt32BE=function(T,A){if(T=T>>>0,!A)z0(T,4,this.length);return this[T]<<24|this[T+1]<<16|this[T+2]<<8|this[T+3]};w.prototype.readBigInt64LE=z8(function(T){T=T>>>0,EA(T,"offset");let A=this[T],Q=this[T+7];if(A===void 0||Q===void 0)j2(T,this.length-8);let J=this[T+4]+this[T+5]*256+this[T+6]*65536+(Q<<24);return(BigInt(J)<<BigInt(32))+BigInt(A+this[++T]*256+this[++T]*65536+this[++T]*16777216)});w.prototype.readBigInt64BE=z8(function(T){T=T>>>0,EA(T,"offset");let A=this[T],Q=this[T+7];if(A===void 0||Q===void 0)j2(T,this.length-8);let J=(A<<24)+this[++T]*65536+this[++T]*256+this[++T];return(BigInt(J)<<BigInt(32))+BigInt(this[++T]*16777216+this[++T]*65536+this[++T]*256+Q)});w.prototype.readFloatLE=function(T,A){if(T=T>>>0,!A)z0(T,4,this.length);return b6(this,T,!0,23,4)};w.prototype.readFloatBE=function(T,A){if(T=T>>>0,!A)z0(T,4,this.length);return b6(this,T,!1,23,4)};w.prototype.readDoubleLE=function(T,A){if(T=T>>>0,!A)z0(T,8,this.length);return b6(this,T,!0,52,8)};w.prototype.readDoubleBE=function(T,A){if(T=T>>>0,!A)z0(T,8,this.length);return b6(this,T,!1,52,8)};w.prototype.writeUintLE=w.prototype.writeUIntLE=function(T,A,Q,J){if(T=+T,A=A>>>0,Q=Q>>>0,!J){let G=Math.pow(2,8*Q)-1;s0(this,T,A,Q,G,0)}let $=1,W=0;this[A]=T&255;while(++W<Q&&($*=256))this[A+W]=T/$&255;return A+Q};w.prototype.writeUintBE=w.prototype.writeUIntBE=function(T,A,Q,J){if(T=+T,A=A>>>0,Q=Q>>>0,!J){let G=Math.pow(2,8*Q)-1;s0(this,T,A,Q,G,0)}let $=Q-1,W=1;this[A+$]=T&255;while(--$>=0&&(W*=256))this[A+$]=T/W&255;return A+Q};w.prototype.writeUint8=w.prototype.writeUInt8=function(T,A,Q){if(T=+T,A=A>>>0,!Q)s0(this,T,A,1,255,0);return this[A]=T&255,A+1};w.prototype.writeUint16LE=w.prototype.writeUInt16LE=function(T,A,Q){if(T=+T,A=A>>>0,!Q)s0(this,T,A,2,65535,0);return this[A]=T&255,this[A+1]=T>>>8,A+2};w.prototype.writeUint16BE=w.prototype.writeUInt16BE=function(T,A,Q){if(T=+T,A=A>>>0,!Q)s0(this,T,A,2,65535,0);return this[A]=T>>>8,this[A+1]=T&255,A+2};w.prototype.writeUint32LE=w.prototype.writeUInt32LE=function(T,A,Q){if(T=+T,A=A>>>0,!Q)s0(this,T,A,4,4294967295,0);return this[A+3]=T>>>24,this[A+2]=T>>>16,this[A+1]=T>>>8,this[A]=T&255,A+4};w.prototype.writeUint32BE=w.prototype.writeUInt32BE=function(T,A,Q){if(T=+T,A=A>>>0,!Q)s0(this,T,A,4,4294967295,0);return this[A]=T>>>24,this[A+1]=T>>>16,this[A+2]=T>>>8,this[A+3]=T&255,A+4};w.prototype.writeBigUInt64LE=z8(function(T,A=0){return SZ(this,T,A,BigInt(0),BigInt("0xffffffffffffffff"))});w.prototype.writeBigUInt64BE=z8(function(T,A=0){return LZ(this,T,A,BigInt(0),BigInt("0xffffffffffffffff"))});w.prototype.writeIntLE=function(T,A,Q,J){if(T=+T,A=A>>>0,!J){let Y=Math.pow(2,8*Q-1);s0(this,T,A,Q,Y-1,-Y)}let $=0,W=1,G=0;this[A]=T&255;while(++$<Q&&(W*=256)){if(T<0&&G===0&&this[A+$-1]!==0)G=1;this[A+$]=(T/W>>0)-G&255}return A+Q};w.prototype.writeIntBE=function(T,A,Q,J){if(T=+T,A=A>>>0,!J){let Y=Math.pow(2,8*Q-1);s0(this,T,A,Q,Y-1,-Y)}let $=Q-1,W=1,G=0;this[A+$]=T&255;while(--$>=0&&(W*=256)){if(T<0&&G===0&&this[A+$+1]!==0)G=1;this[A+$]=(T/W>>0)-G&255}return A+Q};w.prototype.writeInt8=function(T,A,Q){if(T=+T,A=A>>>0,!Q)s0(this,T,A,1,127,-128);if(T<0)T=255+T+1;return this[A]=T&255,A+1};w.prototype.writeInt16LE=function(T,A,Q){if(T=+T,A=A>>>0,!Q)s0(this,T,A,2,32767,-32768);return this[A]=T&255,this[A+1]=T>>>8,A+2};w.prototype.writeInt16BE=function(T,A,Q){if(T=+T,A=A>>>0,!Q)s0(this,T,A,2,32767,-32768);return this[A]=T>>>8,this[A+1]=T&255,A+2};w.prototype.writeInt32LE=function(T,A,Q){if(T=+T,A=A>>>0,!Q)s0(this,T,A,4,2147483647,-2147483648);return this[A]=T&255,this[A+1]=T>>>8,this[A+2]=T>>>16,this[A+3]=T>>>24,A+4};w.prototype.writeInt32BE=function(T,A,Q){if(T=+T,A=A>>>0,!Q)s0(this,T,A,4,2147483647,-2147483648);if(T<0)T=4294967295+T+1;return this[A]=T>>>24,this[A+1]=T>>>16,this[A+2]=T>>>8,this[A+3]=T&255,A+4};w.prototype.writeBigInt64LE=z8(function(T,A=0){return SZ(this,T,A,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});w.prototype.writeBigInt64BE=z8(function(T,A=0){return LZ(this,T,A,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});w.prototype.writeFloatLE=function(T,A,Q){return EZ(this,T,A,!0,Q)};w.prototype.writeFloatBE=function(T,A,Q){return EZ(this,T,A,!1,Q)};w.prototype.writeDoubleLE=function(T,A,Q){return OZ(this,T,A,!0,Q)};w.prototype.writeDoubleBE=function(T,A,Q){return OZ(this,T,A,!1,Q)};w.prototype.copy=function(T,A,Q,J){if(!w.isBuffer(T))throw TypeError("argument should be a Buffer");if(!Q)Q=0;if(!J&&J!==0)J=this.length;if(A>=T.length)A=T.length;if(!A)A=0;if(J>0&&J<Q)J=Q;if(J===Q)return 0;if(T.length===0||this.length===0)return 0;if(A<0)throw RangeError("targetStart out of bounds");if(Q<0||Q>=this.length)throw RangeError("Index out of range");if(J<0)throw RangeError("sourceEnd out of bounds");if(J>this.length)J=this.length;if(T.length-A<J-Q)J=T.length-A+Q;let $=J-Q;if(this===T&&typeof Uint8Array.prototype.copyWithin==="function")this.copyWithin(A,Q,J);else Uint8Array.prototype.set.call(T,this.subarray(Q,J),A);return $};w.prototype.fill=function(T,A,Q,J){if(typeof T==="string"){if(typeof A==="string")J=A,A=0,Q=this.length;else if(typeof Q==="string")J=Q,Q=this.length;if(J!==void 0&&typeof J!=="string")throw TypeError("encoding must be a string");if(typeof J==="string"&&!w.isEncoding(J))throw TypeError("Unknown encoding: "+J);if(T.length===1){let W=T.charCodeAt(0);if(J==="utf8"&&W<128||J==="latin1")T=W}}else if(typeof T==="number")T=T&255;else if(typeof T==="boolean")T=Number(T);if(A<0||this.length<A||this.length<Q)throw RangeError("Out of range index");if(Q<=A)return this;if(A=A>>>0,Q=Q===void 0?this.length:Q>>>0,!T)T=0;let $;if(typeof T==="number")for($=A;$<Q;++$)this[$]=T;else{let W=w.isBuffer(T)?T:w.from(T,J),G=W.length;if(G===0)throw TypeError('The value "'+T+'" is invalid for argument "value"');for($=0;$<Q-A;++$)this[$+A]=W[$%G]}return this};Rj=/[^+/0-9A-Za-z-_]/g;zj=function(){let T=Array(256);for(let A=0;A<16;++A){let Q=A*16;for(let J=0;J<16;++J)T[Q+J]="0123456789abcdef"[A]+"0123456789abcdef"[J]}return T}();Nj=cJ("resolveObjectURL"),Ij=cJ("isUtf8"),Lj=cJ("transcode"),wj=w});var V$=ZT((z9,H$)=>{(function(T,A){function Q(R,U){if(!R)throw Error(U||"Assertion failed")}function J(R,U){R.super_=U;var X=function(){};X.prototype=U.prototype,R.prototype=new X,R.prototype.constructor=R}function $(R,U,X){if($.isBN(R))return R;if(this.negative=0,this.words=null,this.length=0,this.red=null,R!==null){if(U==="le"||U==="be")X=U,U=10;this._init(R||0,U||10,X||"be")}}if(typeof T==="object")T.exports=$;else A.BN=$;$.BN=$,$.wordSize=26;var W;try{if(typeof window<"u"&&typeof window.Buffer<"u")W=window.Buffer;else W=(OA(),VA(l6)).Buffer}catch(R){}$.isBN=function(U){if(U instanceof $)return!0;return U!==null&&typeof U==="object"&&U.constructor.wordSize===$.wordSize&&Array.isArray(U.words)},$.max=function(U,X){if(U.cmp(X)>0)return U;return X},$.min=function(U,X){if(U.cmp(X)<0)return U;return X},$.prototype._init=function(U,X,q){if(typeof U==="number")return this._initNumber(U,X,q);if(typeof U==="object")return this._initArray(U,X,q);if(X==="hex")X=16;Q(X===(X|0)&&X>=2&&X<=36),U=U.toString().replace(/\s+/g,"");var H=0;if(U[0]==="-")H++,this.negative=1;if(H<U.length){if(X===16)this._parseHex(U,H,q);else if(this._parseBase(U,X,H),q==="le")this._initArray(this.toArray(),X,q)}},$.prototype._initNumber=function(U,X,q){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 Q(U<9007199254740992),this.words=[U&67108863,U/67108864&67108863,1],this.length=3;if(q!=="le")return;this._initArray(this.toArray(),X,q)},$.prototype._initArray=function(U,X,q){if(Q(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 V,F,I=0;if(q==="be"){for(H=U.length-1,V=0;H>=0;H-=3)if(F=U[H]|U[H-1]<<8|U[H-2]<<16,this.words[V]|=F<<I&67108863,this.words[V+1]=F>>>26-I&67108863,I+=24,I>=26)I-=26,V++}else if(q==="le"){for(H=0,V=0;H<U.length;H+=3)if(F=U[H]|U[H+1]<<8|U[H+2]<<16,this.words[V]|=F<<I&67108863,this.words[V+1]=F>>>26-I&67108863,I+=24,I>=26)I-=26,V++}return this._strip()};function G(R,U){var X=R.charCodeAt(U);if(X>=48&&X<=57)return X-48;else if(X>=65&&X<=70)return X-55;else if(X>=97&&X<=102)return X-87;else Q(!1,"Invalid character in "+R)}function Y(R,U,X){var q=G(R,X);if(X-1>=U)q|=G(R,X-1)<<4;return q}$.prototype._parseHex=function(U,X,q){this.length=Math.ceil((U.length-X)/6),this.words=Array(this.length);for(var H=0;H<this.length;H++)this.words[H]=0;var V=0,F=0,I;if(q==="be")for(H=U.length-1;H>=X;H-=2)if(I=Y(U,X,H)<<V,this.words[F]|=I&67108863,V>=18)V-=18,F+=1,this.words[F]|=I>>>26;else V+=8;else{var D=U.length-X;for(H=D%2===0?X+1:X;H<U.length;H+=2)if(I=Y(U,X,H)<<V,this.words[F]|=I&67108863,V>=18)V-=18,F+=1,this.words[F]|=I>>>26;else V+=8}this._strip()};function Z(R,U,X,q){var H=0,V=0,F=Math.min(R.length,X);for(var I=U;I<F;I++){var D=R.charCodeAt(I)-48;if(H*=q,D>=49)V=D-49+10;else if(D>=17)V=D-17+10;else V=D;Q(D>=0&&V<q,"Invalid character"),H+=V}return H}$.prototype._parseBase=function(U,X,q){this.words=[0],this.length=1;for(var H=0,V=1;V<=67108863;V*=X)H++;H--,V=V/X|0;var F=U.length-q,I=F%H,D=Math.min(F,F-I)+q,P=0;for(var k=q;k<D;k+=H)if(P=Z(U,k,k+H,X),this.imuln(V),this.words[0]+P<67108864)this.words[0]+=P;else this._iaddn(P);if(I!==0){var b=1;P=Z(U,k,U.length,X);for(k=0;k<I;k++)b*=X;if(this.imuln(b),this.words[0]+P<67108864)this.words[0]+=P;else this._iaddn(P)}this._strip()},$.prototype.copy=function(U){U.words=Array(this.length);for(var X=0;X<this.length;X++)U.words[X]=this.words[X];U.length=this.length,U.negative=this.negative,U.red=this.red};function C(R,U){R.words=U.words,R.length=U.length,R.negative=U.negative,R.red=U.red}if($.prototype._move=function(U){C(U,this)},$.prototype.clone=function(){var U=new $(null);return this.copy(U),U},$.prototype._expand=function(U){while(this.length<U)this.words[this.length++]=0;return this},$.prototype._strip=function(){while(this.length>1&&this.words[this.length-1]===0)this.length--;return this._normSign()},$.prototype._normSign=function(){if(this.length===1&&this.words[0]===0)this.negative=0;return this},typeof Symbol<"u"&&typeof Symbol.for==="function")try{$.prototype[Symbol.for("nodejs.util.inspect.custom")]=K}catch(R){$.prototype.inspect=K}else $.prototype.inspect=K;function K(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var j=["","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"],M=[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($.prototype.toString=function(U,X){U=U||10,X=X|0||1;var q;if(U===16||U==="hex"){q="";var H=0,V=0;for(var F=0;F<this.length;F++){var I=this.words[F],D=((I<<H|V)&16777215).toString(16);if(V=I>>>24-H&16777215,H+=2,H>=26)H-=26,F--;if(V!==0||F!==this.length-1)q=j[6-D.length]+D+q;else q=D+q}if(V!==0)q=V.toString(16)+q;while(q.length%X!==0)q="0"+q;if(this.negative!==0)q="-"+q;return q}if(U===(U|0)&&U>=2&&U<=36){var P=M[U],k=z[U];q="";var b=this.clone();b.negative=0;while(!b.isZero()){var r=b.modrn(k).toString(U);if(b=b.idivn(k),!b.isZero())q=j[P-r.length]+r+q;else q=r+q}if(this.isZero())q="0"+q;while(q.length%X!==0)q="0"+q;if(this.negative!==0)q="-"+q;return q}Q(!1,"Base should be between 2 and 36")},$.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)Q(!1,"Number can only safely store up to 53 bits");return this.negative!==0?-U:U},$.prototype.toJSON=function(){return this.toString(16,2)},W)$.prototype.toBuffer=function(U,X){return this.toArrayLike(W,U,X)};$.prototype.toArray=function(U,X){return this.toArrayLike(Array,U,X)};var N=function(U,X){if(U.allocUnsafe)return U.allocUnsafe(X);return new U(X)};if($.prototype.toArrayLike=function(U,X,q){this._strip();var H=this.byteLength(),V=q||Math.max(1,H);Q(H<=V,"byte array longer than desired length"),Q(V>0,"Requested array length <= 0");var F=N(U,V),I=X==="le"?"LE":"BE";return this["_toArrayLike"+I](F,H),F},$.prototype._toArrayLikeLE=function(U,X){var q=0,H=0;for(var V=0,F=0;V<this.length;V++){var I=this.words[V]<<F|H;if(U[q++]=I&255,q<U.length)U[q++]=I>>8&255;if(q<U.length)U[q++]=I>>16&255;if(F===6){if(q<U.length)U[q++]=I>>24&255;H=0,F=0}else H=I>>>24,F+=2}if(q<U.length){U[q++]=H;while(q<U.length)U[q++]=0}},$.prototype._toArrayLikeBE=function(U,X){var q=U.length-1,H=0;for(var V=0,F=0;V<this.length;V++){var I=this.words[V]<<F|H;if(U[q--]=I&255,q>=0)U[q--]=I>>8&255;if(q>=0)U[q--]=I>>16&255;if(F===6){if(q>=0)U[q--]=I>>24&255;H=0,F=0}else H=I>>>24,F+=2}if(q>=0){U[q--]=H;while(q>=0)U[q--]=0}},Math.clz32)$.prototype._countBits=function(U){return 32-Math.clz32(U)};else $.prototype._countBits=function(U){var X=U,q=0;if(X>=4096)q+=13,X>>>=13;if(X>=64)q+=7,X>>>=7;if(X>=8)q+=4,X>>>=4;if(X>=2)q+=2,X>>>=2;return q+X};$.prototype._zeroBits=function(U){if(U===0)return 26;var X=U,q=0;if((X&8191)===0)q+=13,X>>>=13;if((X&127)===0)q+=7,X>>>=7;if((X&15)===0)q+=4,X>>>=4;if((X&3)===0)q+=2,X>>>=2;if((X&1)===0)q++;return q},$.prototype.bitLength=function(){var U=this.words[this.length-1],X=this._countBits(U);return(this.length-1)*26+X};function E(R){var U=Array(R.bitLength());for(var X=0;X<U.length;X++){var q=X/26|0,H=X%26;U[X]=R.words[q]>>>H&1}return U}$.prototype.zeroBits=function(){if(this.isZero())return 0;var U=0;for(var X=0;X<this.length;X++){var q=this._zeroBits(this.words[X]);if(U+=q,q!==26)break}return U},$.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},$.prototype.toTwos=function(U){if(this.negative!==0)return this.abs().inotn(U).iaddn(1);return this.clone()},$.prototype.fromTwos=function(U){if(this.testn(U-1))return this.notn(U).iaddn(1).ineg();return this.clone()},$.prototype.isNeg=function(){return this.negative!==0},$.prototype.neg=function(){return this.clone().ineg()},$.prototype.ineg=function(){if(!this.isZero())this.negative^=1;return this},$.prototype.iuor=function(U){while(this.length<U.length)this.words[this.length++]=0;for(var X=0;X<U.length;X++)this.words[X]=this.words[X]|U.words[X];return this._strip()},$.prototype.ior=function(U){return Q((this.negative|U.negative)===0),this.iuor(U)},$.prototype.or=function(U){if(this.length>U.length)return this.clone().ior(U);return U.clone().ior(this)},$.prototype.uor=function(U){if(this.length>U.length)return this.clone().iuor(U);return U.clone().iuor(this)},$.prototype.iuand=function(U){var X;if(this.length>U.length)X=U;else X=this;for(var q=0;q<X.length;q++)this.words[q]=this.words[q]&U.words[q];return this.length=X.length,this._strip()},$.prototype.iand=function(U){return Q((this.negative|U.negative)===0),this.iuand(U)},$.prototype.and=function(U){if(this.length>U.length)return this.clone().iand(U);return U.clone().iand(this)},$.prototype.uand=function(U){if(this.length>U.length)return this.clone().iuand(U);return U.clone().iuand(this)},$.prototype.iuxor=function(U){var X,q;if(this.length>U.length)X=this,q=U;else X=U,q=this;for(var H=0;H<q.length;H++)this.words[H]=X.words[H]^q.words[H];if(this!==X)for(;H<X.length;H++)this.words[H]=X.words[H];return this.length=X.length,this._strip()},$.prototype.ixor=function(U){return Q((this.negative|U.negative)===0),this.iuxor(U)},$.prototype.xor=function(U){if(this.length>U.length)return this.clone().ixor(U);return U.clone().ixor(this)},$.prototype.uxor=function(U){if(this.length>U.length)return this.clone().iuxor(U);return U.clone().iuxor(this)},$.prototype.inotn=function(U){Q(typeof U==="number"&&U>=0);var X=Math.ceil(U/26)|0,q=U%26;if(this._expand(X),q>0)X--;for(var H=0;H<X;H++)this.words[H]=~this.words[H]&67108863;if(q>0)this.words[H]=~this.words[H]&67108863>>26-q;return this._strip()},$.prototype.notn=function(U){return this.clone().inotn(U)},$.prototype.setn=function(U,X){Q(typeof U==="number"&&U>=0);var q=U/26|0,H=U%26;if(this._expand(q+1),X)this.words[q]=this.words[q]|1<<H;else this.words[q]=this.words[q]&~(1<<H);return this._strip()},$.prototype.iadd=function(U){var X;if(this.negative!==0&&U.negative===0)return this.negative=0,X=this.isub(U),this.negative^=1,this._normSign();else if(this.negative===0&&U.negative!==0)return U.negative=0,X=this.isub(U),U.negative=1,X._normSign();var q,H;if(this.length>U.length)q=this,H=U;else q=U,H=this;var V=0;for(var F=0;F<H.length;F++)X=(q.words[F]|0)+(H.words[F]|0)+V,this.words[F]=X&67108863,V=X>>>26;for(;V!==0&&F<q.length;F++)X=(q.words[F]|0)+V,this.words[F]=X&67108863,V=X>>>26;if(this.length=q.length,V!==0)this.words[this.length]=V,this.length++;else if(q!==this)for(;F<q.length;F++)this.words[F]=q.words[F];return this},$.prototype.add=function(U){var X;if(U.negative!==0&&this.negative===0)return U.negative=0,X=this.sub(U),U.negative^=1,X;else if(U.negative===0&&this.negative!==0)return this.negative=0,X=U.sub(this),this.negative=1,X;if(this.length>U.length)return this.clone().iadd(U);return U.clone().iadd(this)},$.prototype.isub=function(U){if(U.negative!==0){U.negative=0;var X=this.iadd(U);return U.negative=1,X._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(U),this.negative=1,this._normSign();var q=this.cmp(U);if(q===0)return this.negative=0,this.length=1,this.words[0]=0,this;var H,V;if(q>0)H=this,V=U;else H=U,V=this;var F=0;for(var I=0;I<V.length;I++)X=(H.words[I]|0)-(V.words[I]|0)+F,F=X>>26,this.words[I]=X&67108863;for(;F!==0&&I<H.length;I++)X=(H.words[I]|0)+F,F=X>>26,this.words[I]=X&67108863;if(F===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()},$.prototype.sub=function(U){return this.clone().isub(U)};function L(R,U,X){X.negative=U.negative^R.negative;var q=R.length+U.length|0;X.length=q,q=q-1|0;var H=R.words[0]|0,V=U.words[0]|0,F=H*V,I=F&67108863,D=F/67108864|0;X.words[0]=I;for(var P=1;P<q;P++){var k=D>>>26,b=D&67108863,r=Math.min(P,U.length-1);for(var f=Math.max(0,P-R.length+1);f<=r;f++){var T1=P-f|0;H=R.words[T1]|0,V=U.words[f]|0,F=H*V+b,k+=F/67108864|0,b=F&67108863}X.words[P]=b|0,D=k|0}if(D!==0)X.words[P]=D|0;else X.length--;return X._strip()}var O=function(U,X,q){var H=U.words,V=X.words,F=q.words,I=0,D,P,k,b=H[0]|0,r=b&8191,f=b>>>13,T1=H[1]|0,Q1=T1&8191,J1=T1>>>13,r0=H[2]|0,X1=r0&8191,C1=r0>>>13,T2=H[3]|0,w1=T2&8191,E1=T2>>>13,aW=H[4]|0,O1=aW&8191,B1=aW>>>13,sW=H[5]|0,_1=sW&8191,x1=sW>>>13,tW=H[6]|0,h1=tW&8191,g1=tW>>>13,eW=H[7]|0,m1=eW&8191,v1=eW>>>13,TG=H[8]|0,y1=TG&8191,b1=TG>>>13,AG=H[9]|0,p1=AG&8191,l1=AG>>>13,QG=V[0]|0,u1=QG&8191,d1=QG>>>13,JG=V[1]|0,c1=JG&8191,f1=JG>>>13,$G=V[2]|0,r1=$G&8191,n1=$G>>>13,WG=V[3]|0,i1=WG&8191,o1=WG>>>13,GG=V[4]|0,a1=GG&8191,s1=GG>>>13,UG=V[5]|0,t1=UG&8191,e1=UG>>>13,YG=V[6]|0,T0=YG&8191,A0=YG>>>13,ZG=V[7]|0,Q0=ZG&8191,J0=ZG>>>13,XG=V[8]|0,$0=XG&8191,W0=XG>>>13,PG=V[9]|0,G0=PG&8191,U0=PG>>>13;q.negative=U.negative^X.negative,q.length=19,D=Math.imul(r,u1),P=Math.imul(r,d1),P=P+Math.imul(f,u1)|0,k=Math.imul(f,d1);var rQ=(I+D|0)+((P&8191)<<13)|0;I=(k+(P>>>13)|0)+(rQ>>>26)|0,rQ&=67108863,D=Math.imul(Q1,u1),P=Math.imul(Q1,d1),P=P+Math.imul(J1,u1)|0,k=Math.imul(J1,d1),D=D+Math.imul(r,c1)|0,P=P+Math.imul(r,f1)|0,P=P+Math.imul(f,c1)|0,k=k+Math.imul(f,f1)|0;var nQ=(I+D|0)+((P&8191)<<13)|0;I=(k+(P>>>13)|0)+(nQ>>>26)|0,nQ&=67108863,D=Math.imul(X1,u1),P=Math.imul(X1,d1),P=P+Math.imul(C1,u1)|0,k=Math.imul(C1,d1),D=D+Math.imul(Q1,c1)|0,P=P+Math.imul(Q1,f1)|0,P=P+Math.imul(J1,c1)|0,k=k+Math.imul(J1,f1)|0,D=D+Math.imul(r,r1)|0,P=P+Math.imul(r,n1)|0,P=P+Math.imul(f,r1)|0,k=k+Math.imul(f,n1)|0;var iQ=(I+D|0)+((P&8191)<<13)|0;I=(k+(P>>>13)|0)+(iQ>>>26)|0,iQ&=67108863,D=Math.imul(w1,u1),P=Math.imul(w1,d1),P=P+Math.imul(E1,u1)|0,k=Math.imul(E1,d1),D=D+Math.imul(X1,c1)|0,P=P+Math.imul(X1,f1)|0,P=P+Math.imul(C1,c1)|0,k=k+Math.imul(C1,f1)|0,D=D+Math.imul(Q1,r1)|0,P=P+Math.imul(Q1,n1)|0,P=P+Math.imul(J1,r1)|0,k=k+Math.imul(J1,n1)|0,D=D+Math.imul(r,i1)|0,P=P+Math.imul(r,o1)|0,P=P+Math.imul(f,i1)|0,k=k+Math.imul(f,o1)|0;var oQ=(I+D|0)+((P&8191)<<13)|0;I=(k+(P>>>13)|0)+(oQ>>>26)|0,oQ&=67108863,D=Math.imul(O1,u1),P=Math.imul(O1,d1),P=P+Math.imul(B1,u1)|0,k=Math.imul(B1,d1),D=D+Math.imul(w1,c1)|0,P=P+Math.imul(w1,f1)|0,P=P+Math.imul(E1,c1)|0,k=k+Math.imul(E1,f1)|0,D=D+Math.imul(X1,r1)|0,P=P+Math.imul(X1,n1)|0,P=P+Math.imul(C1,r1)|0,k=k+Math.imul(C1,n1)|0,D=D+Math.imul(Q1,i1)|0,P=P+Math.imul(Q1,o1)|0,P=P+Math.imul(J1,i1)|0,k=k+Math.imul(J1,o1)|0,D=D+Math.imul(r,a1)|0,P=P+Math.imul(r,s1)|0,P=P+Math.imul(f,a1)|0,k=k+Math.imul(f,s1)|0;var aQ=(I+D|0)+((P&8191)<<13)|0;I=(k+(P>>>13)|0)+(aQ>>>26)|0,aQ&=67108863,D=Math.imul(_1,u1),P=Math.imul(_1,d1),P=P+Math.imul(x1,u1)|0,k=Math.imul(x1,d1),D=D+Math.imul(O1,c1)|0,P=P+Math.imul(O1,f1)|0,P=P+Math.imul(B1,c1)|0,k=k+Math.imul(B1,f1)|0,D=D+Math.imul(w1,r1)|0,P=P+Math.imul(w1,n1)|0,P=P+Math.imul(E1,r1)|0,k=k+Math.imul(E1,n1)|0,D=D+Math.imul(X1,i1)|0,P=P+Math.imul(X1,o1)|0,P=P+Math.imul(C1,i1)|0,k=k+Math.imul(C1,o1)|0,D=D+Math.imul(Q1,a1)|0,P=P+Math.imul(Q1,s1)|0,P=P+Math.imul(J1,a1)|0,k=k+Math.imul(J1,s1)|0,D=D+Math.imul(r,t1)|0,P=P+Math.imul(r,e1)|0,P=P+Math.imul(f,t1)|0,k=k+Math.imul(f,e1)|0;var sQ=(I+D|0)+((P&8191)<<13)|0;I=(k+(P>>>13)|0)+(sQ>>>26)|0,sQ&=67108863,D=Math.imul(h1,u1),P=Math.imul(h1,d1),P=P+Math.imul(g1,u1)|0,k=Math.imul(g1,d1),D=D+Math.imul(_1,c1)|0,P=P+Math.imul(_1,f1)|0,P=P+Math.imul(x1,c1)|0,k=k+Math.imul(x1,f1)|0,D=D+Math.imul(O1,r1)|0,P=P+Math.imul(O1,n1)|0,P=P+Math.imul(B1,r1)|0,k=k+Math.imul(B1,n1)|0,D=D+Math.imul(w1,i1)|0,P=P+Math.imul(w1,o1)|0,P=P+Math.imul(E1,i1)|0,k=k+Math.imul(E1,o1)|0,D=D+Math.imul(X1,a1)|0,P=P+Math.imul(X1,s1)|0,P=P+Math.imul(C1,a1)|0,k=k+Math.imul(C1,s1)|0,D=D+Math.imul(Q1,t1)|0,P=P+Math.imul(Q1,e1)|0,P=P+Math.imul(J1,t1)|0,k=k+Math.imul(J1,e1)|0,D=D+Math.imul(r,T0)|0,P=P+Math.imul(r,A0)|0,P=P+Math.imul(f,T0)|0,k=k+Math.imul(f,A0)|0;var tQ=(I+D|0)+((P&8191)<<13)|0;I=(k+(P>>>13)|0)+(tQ>>>26)|0,tQ&=67108863,D=Math.imul(m1,u1),P=Math.imul(m1,d1),P=P+Math.imul(v1,u1)|0,k=Math.imul(v1,d1),D=D+Math.imul(h1,c1)|0,P=P+Math.imul(h1,f1)|0,P=P+Math.imul(g1,c1)|0,k=k+Math.imul(g1,f1)|0,D=D+Math.imul(_1,r1)|0,P=P+Math.imul(_1,n1)|0,P=P+Math.imul(x1,r1)|0,k=k+Math.imul(x1,n1)|0,D=D+Math.imul(O1,i1)|0,P=P+Math.imul(O1,o1)|0,P=P+Math.imul(B1,i1)|0,k=k+Math.imul(B1,o1)|0,D=D+Math.imul(w1,a1)|0,P=P+Math.imul(w1,s1)|0,P=P+Math.imul(E1,a1)|0,k=k+Math.imul(E1,s1)|0,D=D+Math.imul(X1,t1)|0,P=P+Math.imul(X1,e1)|0,P=P+Math.imul(C1,t1)|0,k=k+Math.imul(C1,e1)|0,D=D+Math.imul(Q1,T0)|0,P=P+Math.imul(Q1,A0)|0,P=P+Math.imul(J1,T0)|0,k=k+Math.imul(J1,A0)|0,D=D+Math.imul(r,Q0)|0,P=P+Math.imul(r,J0)|0,P=P+Math.imul(f,Q0)|0,k=k+Math.imul(f,J0)|0;var eQ=(I+D|0)+((P&8191)<<13)|0;I=(k+(P>>>13)|0)+(eQ>>>26)|0,eQ&=67108863,D=Math.imul(y1,u1),P=Math.imul(y1,d1),P=P+Math.imul(b1,u1)|0,k=Math.imul(b1,d1),D=D+Math.imul(m1,c1)|0,P=P+Math.imul(m1,f1)|0,P=P+Math.imul(v1,c1)|0,k=k+Math.imul(v1,f1)|0,D=D+Math.imul(h1,r1)|0,P=P+Math.imul(h1,n1)|0,P=P+Math.imul(g1,r1)|0,k=k+Math.imul(g1,n1)|0,D=D+Math.imul(_1,i1)|0,P=P+Math.imul(_1,o1)|0,P=P+Math.imul(x1,i1)|0,k=k+Math.imul(x1,o1)|0,D=D+Math.imul(O1,a1)|0,P=P+Math.imul(O1,s1)|0,P=P+Math.imul(B1,a1)|0,k=k+Math.imul(B1,s1)|0,D=D+Math.imul(w1,t1)|0,P=P+Math.imul(w1,e1)|0,P=P+Math.imul(E1,t1)|0,k=k+Math.imul(E1,e1)|0,D=D+Math.imul(X1,T0)|0,P=P+Math.imul(X1,A0)|0,P=P+Math.imul(C1,T0)|0,k=k+Math.imul(C1,A0)|0,D=D+Math.imul(Q1,Q0)|0,P=P+Math.imul(Q1,J0)|0,P=P+Math.imul(J1,Q0)|0,k=k+Math.imul(J1,J0)|0,D=D+Math.imul(r,$0)|0,P=P+Math.imul(r,W0)|0,P=P+Math.imul(f,$0)|0,k=k+Math.imul(f,W0)|0;var T4=(I+D|0)+((P&8191)<<13)|0;I=(k+(P>>>13)|0)+(T4>>>26)|0,T4&=67108863,D=Math.imul(p1,u1),P=Math.imul(p1,d1),P=P+Math.imul(l1,u1)|0,k=Math.imul(l1,d1),D=D+Math.imul(y1,c1)|0,P=P+Math.imul(y1,f1)|0,P=P+Math.imul(b1,c1)|0,k=k+Math.imul(b1,f1)|0,D=D+Math.imul(m1,r1)|0,P=P+Math.imul(m1,n1)|0,P=P+Math.imul(v1,r1)|0,k=k+Math.imul(v1,n1)|0,D=D+Math.imul(h1,i1)|0,P=P+Math.imul(h1,o1)|0,P=P+Math.imul(g1,i1)|0,k=k+Math.imul(g1,o1)|0,D=D+Math.imul(_1,a1)|0,P=P+Math.imul(_1,s1)|0,P=P+Math.imul(x1,a1)|0,k=k+Math.imul(x1,s1)|0,D=D+Math.imul(O1,t1)|0,P=P+Math.imul(O1,e1)|0,P=P+Math.imul(B1,t1)|0,k=k+Math.imul(B1,e1)|0,D=D+Math.imul(w1,T0)|0,P=P+Math.imul(w1,A0)|0,P=P+Math.imul(E1,T0)|0,k=k+Math.imul(E1,A0)|0,D=D+Math.imul(X1,Q0)|0,P=P+Math.imul(X1,J0)|0,P=P+Math.imul(C1,Q0)|0,k=k+Math.imul(C1,J0)|0,D=D+Math.imul(Q1,$0)|0,P=P+Math.imul(Q1,W0)|0,P=P+Math.imul(J1,$0)|0,k=k+Math.imul(J1,W0)|0,D=D+Math.imul(r,G0)|0,P=P+Math.imul(r,U0)|0,P=P+Math.imul(f,G0)|0,k=k+Math.imul(f,U0)|0;var A4=(I+D|0)+((P&8191)<<13)|0;I=(k+(P>>>13)|0)+(A4>>>26)|0,A4&=67108863,D=Math.imul(p1,c1),P=Math.imul(p1,f1),P=P+Math.imul(l1,c1)|0,k=Math.imul(l1,f1),D=D+Math.imul(y1,r1)|0,P=P+Math.imul(y1,n1)|0,P=P+Math.imul(b1,r1)|0,k=k+Math.imul(b1,n1)|0,D=D+Math.imul(m1,i1)|0,P=P+Math.imul(m1,o1)|0,P=P+Math.imul(v1,i1)|0,k=k+Math.imul(v1,o1)|0,D=D+Math.imul(h1,a1)|0,P=P+Math.imul(h1,s1)|0,P=P+Math.imul(g1,a1)|0,k=k+Math.imul(g1,s1)|0,D=D+Math.imul(_1,t1)|0,P=P+Math.imul(_1,e1)|0,P=P+Math.imul(x1,t1)|0,k=k+Math.imul(x1,e1)|0,D=D+Math.imul(O1,T0)|0,P=P+Math.imul(O1,A0)|0,P=P+Math.imul(B1,T0)|0,k=k+Math.imul(B1,A0)|0,D=D+Math.imul(w1,Q0)|0,P=P+Math.imul(w1,J0)|0,P=P+Math.imul(E1,Q0)|0,k=k+Math.imul(E1,J0)|0,D=D+Math.imul(X1,$0)|0,P=P+Math.imul(X1,W0)|0,P=P+Math.imul(C1,$0)|0,k=k+Math.imul(C1,W0)|0,D=D+Math.imul(Q1,G0)|0,P=P+Math.imul(Q1,U0)|0,P=P+Math.imul(J1,G0)|0,k=k+Math.imul(J1,U0)|0;var Q4=(I+D|0)+((P&8191)<<13)|0;I=(k+(P>>>13)|0)+(Q4>>>26)|0,Q4&=67108863,D=Math.imul(p1,r1),P=Math.imul(p1,n1),P=P+Math.imul(l1,r1)|0,k=Math.imul(l1,n1),D=D+Math.imul(y1,i1)|0,P=P+Math.imul(y1,o1)|0,P=P+Math.imul(b1,i1)|0,k=k+Math.imul(b1,o1)|0,D=D+Math.imul(m1,a1)|0,P=P+Math.imul(m1,s1)|0,P=P+Math.imul(v1,a1)|0,k=k+Math.imul(v1,s1)|0,D=D+Math.imul(h1,t1)|0,P=P+Math.imul(h1,e1)|0,P=P+Math.imul(g1,t1)|0,k=k+Math.imul(g1,e1)|0,D=D+Math.imul(_1,T0)|0,P=P+Math.imul(_1,A0)|0,P=P+Math.imul(x1,T0)|0,k=k+Math.imul(x1,A0)|0,D=D+Math.imul(O1,Q0)|0,P=P+Math.imul(O1,J0)|0,P=P+Math.imul(B1,Q0)|0,k=k+Math.imul(B1,J0)|0,D=D+Math.imul(w1,$0)|0,P=P+Math.imul(w1,W0)|0,P=P+Math.imul(E1,$0)|0,k=k+Math.imul(E1,W0)|0,D=D+Math.imul(X1,G0)|0,P=P+Math.imul(X1,U0)|0,P=P+Math.imul(C1,G0)|0,k=k+Math.imul(C1,U0)|0;var J4=(I+D|0)+((P&8191)<<13)|0;I=(k+(P>>>13)|0)+(J4>>>26)|0,J4&=67108863,D=Math.imul(p1,i1),P=Math.imul(p1,o1),P=P+Math.imul(l1,i1)|0,k=Math.imul(l1,o1),D=D+Math.imul(y1,a1)|0,P=P+Math.imul(y1,s1)|0,P=P+Math.imul(b1,a1)|0,k=k+Math.imul(b1,s1)|0,D=D+Math.imul(m1,t1)|0,P=P+Math.imul(m1,e1)|0,P=P+Math.imul(v1,t1)|0,k=k+Math.imul(v1,e1)|0,D=D+Math.imul(h1,T0)|0,P=P+Math.imul(h1,A0)|0,P=P+Math.imul(g1,T0)|0,k=k+Math.imul(g1,A0)|0,D=D+Math.imul(_1,Q0)|0,P=P+Math.imul(_1,J0)|0,P=P+Math.imul(x1,Q0)|0,k=k+Math.imul(x1,J0)|0,D=D+Math.imul(O1,$0)|0,P=P+Math.imul(O1,W0)|0,P=P+Math.imul(B1,$0)|0,k=k+Math.imul(B1,W0)|0,D=D+Math.imul(w1,G0)|0,P=P+Math.imul(w1,U0)|0,P=P+Math.imul(E1,G0)|0,k=k+Math.imul(E1,U0)|0;var $4=(I+D|0)+((P&8191)<<13)|0;I=(k+(P>>>13)|0)+($4>>>26)|0,$4&=67108863,D=Math.imul(p1,a1),P=Math.imul(p1,s1),P=P+Math.imul(l1,a1)|0,k=Math.imul(l1,s1),D=D+Math.imul(y1,t1)|0,P=P+Math.imul(y1,e1)|0,P=P+Math.imul(b1,t1)|0,k=k+Math.imul(b1,e1)|0,D=D+Math.imul(m1,T0)|0,P=P+Math.imul(m1,A0)|0,P=P+Math.imul(v1,T0)|0,k=k+Math.imul(v1,A0)|0,D=D+Math.imul(h1,Q0)|0,P=P+Math.imul(h1,J0)|0,P=P+Math.imul(g1,Q0)|0,k=k+Math.imul(g1,J0)|0,D=D+Math.imul(_1,$0)|0,P=P+Math.imul(_1,W0)|0,P=P+Math.imul(x1,$0)|0,k=k+Math.imul(x1,W0)|0,D=D+Math.imul(O1,G0)|0,P=P+Math.imul(O1,U0)|0,P=P+Math.imul(B1,G0)|0,k=k+Math.imul(B1,U0)|0;var W4=(I+D|0)+((P&8191)<<13)|0;I=(k+(P>>>13)|0)+(W4>>>26)|0,W4&=67108863,D=Math.imul(p1,t1),P=Math.imul(p1,e1),P=P+Math.imul(l1,t1)|0,k=Math.imul(l1,e1),D=D+Math.imul(y1,T0)|0,P=P+Math.imul(y1,A0)|0,P=P+Math.imul(b1,T0)|0,k=k+Math.imul(b1,A0)|0,D=D+Math.imul(m1,Q0)|0,P=P+Math.imul(m1,J0)|0,P=P+Math.imul(v1,Q0)|0,k=k+Math.imul(v1,J0)|0,D=D+Math.imul(h1,$0)|0,P=P+Math.imul(h1,W0)|0,P=P+Math.imul(g1,$0)|0,k=k+Math.imul(g1,W0)|0,D=D+Math.imul(_1,G0)|0,P=P+Math.imul(_1,U0)|0,P=P+Math.imul(x1,G0)|0,k=k+Math.imul(x1,U0)|0;var G4=(I+D|0)+((P&8191)<<13)|0;I=(k+(P>>>13)|0)+(G4>>>26)|0,G4&=67108863,D=Math.imul(p1,T0),P=Math.imul(p1,A0),P=P+Math.imul(l1,T0)|0,k=Math.imul(l1,A0),D=D+Math.imul(y1,Q0)|0,P=P+Math.imul(y1,J0)|0,P=P+Math.imul(b1,Q0)|0,k=k+Math.imul(b1,J0)|0,D=D+Math.imul(m1,$0)|0,P=P+Math.imul(m1,W0)|0,P=P+Math.imul(v1,$0)|0,k=k+Math.imul(v1,W0)|0,D=D+Math.imul(h1,G0)|0,P=P+Math.imul(h1,U0)|0,P=P+Math.imul(g1,G0)|0,k=k+Math.imul(g1,U0)|0;var U4=(I+D|0)+((P&8191)<<13)|0;I=(k+(P>>>13)|0)+(U4>>>26)|0,U4&=67108863,D=Math.imul(p1,Q0),P=Math.imul(p1,J0),P=P+Math.imul(l1,Q0)|0,k=Math.imul(l1,J0),D=D+Math.imul(y1,$0)|0,P=P+Math.imul(y1,W0)|0,P=P+Math.imul(b1,$0)|0,k=k+Math.imul(b1,W0)|0,D=D+Math.imul(m1,G0)|0,P=P+Math.imul(m1,U0)|0,P=P+Math.imul(v1,G0)|0,k=k+Math.imul(v1,U0)|0;var Y4=(I+D|0)+((P&8191)<<13)|0;I=(k+(P>>>13)|0)+(Y4>>>26)|0,Y4&=67108863,D=Math.imul(p1,$0),P=Math.imul(p1,W0),P=P+Math.imul(l1,$0)|0,k=Math.imul(l1,W0),D=D+Math.imul(y1,G0)|0,P=P+Math.imul(y1,U0)|0,P=P+Math.imul(b1,G0)|0,k=k+Math.imul(b1,U0)|0;var Z4=(I+D|0)+((P&8191)<<13)|0;I=(k+(P>>>13)|0)+(Z4>>>26)|0,Z4&=67108863,D=Math.imul(p1,G0),P=Math.imul(p1,U0),P=P+Math.imul(l1,G0)|0,k=Math.imul(l1,U0);var X4=(I+D|0)+((P&8191)<<13)|0;if(I=(k+(P>>>13)|0)+(X4>>>26)|0,X4&=67108863,F[0]=rQ,F[1]=nQ,F[2]=iQ,F[3]=oQ,F[4]=aQ,F[5]=sQ,F[6]=tQ,F[7]=eQ,F[8]=T4,F[9]=A4,F[10]=Q4,F[11]=J4,F[12]=$4,F[13]=W4,F[14]=G4,F[15]=U4,F[16]=Y4,F[17]=Z4,F[18]=X4,I!==0)F[19]=I,q.length++;return q};if(!Math.imul)O=L;function g(R,U,X){X.negative=U.negative^R.negative,X.length=R.length+U.length;var q=0,H=0;for(var V=0;V<X.length-1;V++){var F=H;H=0;var I=q&67108863,D=Math.min(V,U.length-1);for(var P=Math.max(0,V-R.length+1);P<=D;P++){var k=V-P,b=R.words[k]|0,r=U.words[P]|0,f=b*r,T1=f&67108863;F=F+(f/67108864|0)|0,T1=T1+I|0,I=T1&67108863,F=F+(T1>>>26)|0,H+=F>>>26,F&=67108863}X.words[V]=I,q=F,F=H}if(q!==0)X.words[V]=q;else X.length--;return X._strip()}function v(R,U,X){return g(R,U,X)}$.prototype.mulTo=function(U,X){var q,H=this.length+U.length;if(this.length===10&&U.length===10)q=O(this,U,X);else if(H<63)q=L(this,U,X);else if(H<1024)q=g(this,U,X);else q=v(this,U,X);return q};function p(R,U){this.x=R,this.y=U}p.prototype.makeRBT=function(U){var X=Array(U),q=$.prototype._countBits(U)-1;for(var H=0;H<U;H++)X[H]=this.revBin(H,q,U);return X},p.prototype.revBin=function(U,X,q){if(U===0||U===q-1)return U;var H=0;for(var V=0;V<X;V++)H|=(U&1)<<X-V-1,U>>=1;return H},p.prototype.permute=function(U,X,q,H,V,F){for(var I=0;I<F;I++)H[I]=X[U[I]],V[I]=q[U[I]]},p.prototype.transform=function(U,X,q,H,V,F){this.permute(F,U,X,q,H,V);for(var I=1;I<V;I<<=1){var D=I<<1,P=Math.cos(2*Math.PI/D),k=Math.sin(2*Math.PI/D);for(var b=0;b<V;b+=D){var r=P,f=k;for(var T1=0;T1<I;T1++){var Q1=q[b+T1],J1=H[b+T1],r0=q[b+T1+I],X1=H[b+T1+I],C1=r*r0-f*X1;if(X1=r*X1+f*r0,r0=C1,q[b+T1]=Q1+r0,H[b+T1]=J1+X1,q[b+T1+I]=Q1-r0,H[b+T1+I]=J1-X1,T1!==D)C1=P*r-k*f,f=P*f+k*r,r=C1}}}},p.prototype.guessLen13b=function(U,X){var q=Math.max(X,U)|1,H=q&1,V=0;for(q=q/2|0;q;q=q>>>1)V++;return 1<<V+1+H},p.prototype.conjugate=function(U,X,q){if(q<=1)return;for(var H=0;H<q/2;H++){var V=U[H];U[H]=U[q-H-1],U[q-H-1]=V,V=X[H],X[H]=-X[q-H-1],X[q-H-1]=-V}},p.prototype.normalize13b=function(U,X){var q=0;for(var H=0;H<X/2;H++){var V=Math.round(U[2*H+1]/X)*8192+Math.round(U[2*H]/X)+q;if(U[H]=V&67108863,V<67108864)q=0;else q=V/67108864|0}return U},p.prototype.convert13b=function(U,X,q,H){var V=0;for(var F=0;F<X;F++)V=V+(U[F]|0),q[2*F]=V&8191,V=V>>>13,q[2*F+1]=V&8191,V=V>>>13;for(F=2*X;F<H;++F)q[F]=0;Q(V===0),Q((V&-8192)===0)},p.prototype.stub=function(U){var X=Array(U);for(var q=0;q<U;q++)X[q]=0;return X},p.prototype.mulp=function(U,X,q){var H=2*this.guessLen13b(U.length,X.length),V=this.makeRBT(H),F=this.stub(H),I=Array(H),D=Array(H),P=Array(H),k=Array(H),b=Array(H),r=Array(H),f=q.words;f.length=H,this.convert13b(U.words,U.length,I,H),this.convert13b(X.words,X.length,k,H),this.transform(I,F,D,P,H,V),this.transform(k,F,b,r,H,V);for(var T1=0;T1<H;T1++){var Q1=D[T1]*b[T1]-P[T1]*r[T1];P[T1]=D[T1]*r[T1]+P[T1]*b[T1],D[T1]=Q1}return this.conjugate(D,P,H),this.transform(D,P,f,F,H,V),this.conjugate(f,F,H),this.normalize13b(f,H),q.negative=U.negative^X.negative,q.length=U.length+X.length,q._strip()},$.prototype.mul=function(U){var X=new $(null);return X.words=Array(this.length+U.length),this.mulTo(U,X)},$.prototype.mulf=function(U){var X=new $(null);return X.words=Array(this.length+U.length),v(this,U,X)},$.prototype.imul=function(U){return this.clone().mulTo(U,this)},$.prototype.imuln=function(U){var X=U<0;if(X)U=-U;Q(typeof U==="number"),Q(U<67108864);var q=0;for(var H=0;H<this.length;H++){var V=(this.words[H]|0)*U,F=(V&67108863)+(q&67108863);q>>=26,q+=V/67108864|0,q+=F>>>26,this.words[H]=F&67108863}if(q!==0)this.words[H]=q,this.length++;return this.length=U===0?1:this.length,X?this.ineg():this},$.prototype.muln=function(U){return this.clone().imuln(U)},$.prototype.sqr=function(){return this.mul(this)},$.prototype.isqr=function(){return this.imul(this.clone())},$.prototype.pow=function(U){var X=E(U);if(X.length===0)return new $(1);var q=this;for(var H=0;H<X.length;H++,q=q.sqr())if(X[H]!==0)break;if(++H<X.length)for(var V=q.sqr();H<X.length;H++,V=V.sqr()){if(X[H]===0)continue;q=q.mul(V)}return q},$.prototype.iushln=function(U){Q(typeof U==="number"&&U>=0);var X=U%26,q=(U-X)/26,H=67108863>>>26-X<<26-X,V;if(X!==0){var F=0;for(V=0;V<this.length;V++){var I=this.words[V]&H,D=(this.words[V]|0)-I<<X;this.words[V]=D|F,F=I>>>26-X}if(F)this.words[V]=F,this.length++}if(q!==0){for(V=this.length-1;V>=0;V--)this.words[V+q]=this.words[V];for(V=0;V<q;V++)this.words[V]=0;this.length+=q}return this._strip()},$.prototype.ishln=function(U){return Q(this.negative===0),this.iushln(U)},$.prototype.iushrn=function(U,X,q){Q(typeof U==="number"&&U>=0);var H;if(X)H=(X-X%26)/26;else H=0;var V=U%26,F=Math.min((U-V)/26,this.length),I=67108863^67108863>>>V<<V,D=q;if(H-=F,H=Math.max(0,H),D){for(var P=0;P<F;P++)D.words[P]=this.words[P];D.length=F}if(F===0);else if(this.length>F){this.length-=F;for(P=0;P<this.length;P++)this.words[P]=this.words[P+F]}else this.words[0]=0,this.length=1;var k=0;for(P=this.length-1;P>=0&&(k!==0||P>=H);P--){var b=this.words[P]|0;this.words[P]=k<<26-V|b>>>V,k=b&I}if(D&&k!==0)D.words[D.length++]=k;if(this.length===0)this.words[0]=0,this.length=1;return this._strip()},$.prototype.ishrn=function(U,X,q){return Q(this.negative===0),this.iushrn(U,X,q)},$.prototype.shln=function(U){return this.clone().ishln(U)},$.prototype.ushln=function(U){return this.clone().iushln(U)},$.prototype.shrn=function(U){return this.clone().ishrn(U)},$.prototype.ushrn=function(U){return this.clone().iushrn(U)},$.prototype.testn=function(U){Q(typeof U==="number"&&U>=0);var X=U%26,q=(U-X)/26,H=1<<X;if(this.length<=q)return!1;var V=this.words[q];return!!(V&H)},$.prototype.imaskn=function(U){Q(typeof U==="number"&&U>=0);var X=U%26,q=(U-X)/26;if(Q(this.negative===0,"imaskn works only with positive numbers"),this.length<=q)return this;if(X!==0)q++;if(this.length=Math.min(q,this.length),X!==0){var H=67108863^67108863>>>X<<X;this.words[this.length-1]&=H}return this._strip()},$.prototype.maskn=function(U){return this.clone().imaskn(U)},$.prototype.iaddn=function(U){if(Q(typeof U==="number"),Q(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)},$.prototype._iaddn=function(U){this.words[0]+=U;for(var X=0;X<this.length&&this.words[X]>=67108864;X++)if(this.words[X]-=67108864,X===this.length-1)this.words[X+1]=1;else this.words[X+1]++;return this.length=Math.max(this.length,X+1),this},$.prototype.isubn=function(U){if(Q(typeof U==="number"),Q(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 X=0;X<this.length&&this.words[X]<0;X++)this.words[X]+=67108864,this.words[X+1]-=1;return this._strip()},$.prototype.addn=function(U){return this.clone().iaddn(U)},$.prototype.subn=function(U){return this.clone().isubn(U)},$.prototype.iabs=function(){return this.negative=0,this},$.prototype.abs=function(){return this.clone().iabs()},$.prototype._ishlnsubmul=function(U,X,q){var H=U.length+q,V;this._expand(H);var F,I=0;for(V=0;V<U.length;V++){F=(this.words[V+q]|0)+I;var D=(U.words[V]|0)*X;F-=D&67108863,I=(F>>26)-(D/67108864|0),this.words[V+q]=F&67108863}for(;V<this.length-q;V++)F=(this.words[V+q]|0)+I,I=F>>26,this.words[V+q]=F&67108863;if(I===0)return this._strip();Q(I===-1),I=0;for(V=0;V<this.length;V++)F=-(this.words[V]|0)+I,I=F>>26,this.words[V]=F&67108863;return this.negative=1,this._strip()},$.prototype._wordDiv=function(U,X){var q=this.length-U.length,H=this.clone(),V=U,F=V.words[V.length-1]|0,I=this._countBits(F);if(q=26-I,q!==0)V=V.ushln(q),H.iushln(q),F=V.words[V.length-1]|0;var D=H.length-V.length,P;if(X!=="mod"){P=new $(null),P.length=D+1,P.words=Array(P.length);for(var k=0;k<P.length;k++)P.words[k]=0}var b=H.clone()._ishlnsubmul(V,1,D);if(b.negative===0){if(H=b,P)P.words[D]=1}for(var r=D-1;r>=0;r--){var f=(H.words[V.length+r]|0)*67108864+(H.words[V.length+r-1]|0);f=Math.min(f/F|0,67108863),H._ishlnsubmul(V,f,r);while(H.negative!==0)if(f--,H.negative=0,H._ishlnsubmul(V,1,r),!H.isZero())H.negative^=1;if(P)P.words[r]=f}if(P)P._strip();if(H._strip(),X!=="div"&&q!==0)H.iushrn(q);return{div:P||null,mod:H}},$.prototype.divmod=function(U,X,q){if(Q(!U.isZero()),this.isZero())return{div:new $(0),mod:new $(0)};var H,V,F;if(this.negative!==0&&U.negative===0){if(F=this.neg().divmod(U,X),X!=="mod")H=F.div.neg();if(X!=="div"){if(V=F.mod.neg(),q&&V.negative!==0)V.iadd(U)}return{div:H,mod:V}}if(this.negative===0&&U.negative!==0){if(F=this.divmod(U.neg(),X),X!=="mod")H=F.div.neg();return{div:H,mod:F.mod}}if((this.negative&U.negative)!==0){if(F=this.neg().divmod(U.neg(),X),X!=="div"){if(V=F.mod.neg(),q&&V.negative!==0)V.isub(U)}return{div:F.div,mod:V}}if(U.length>this.length||this.cmp(U)<0)return{div:new $(0),mod:this};if(U.length===1){if(X==="div")return{div:this.divn(U.words[0]),mod:null};if(X==="mod")return{div:null,mod:new $(this.modrn(U.words[0]))};return{div:this.divn(U.words[0]),mod:new $(this.modrn(U.words[0]))}}return this._wordDiv(U,X)},$.prototype.div=function(U){return this.divmod(U,"div",!1).div},$.prototype.mod=function(U){return this.divmod(U,"mod",!1).mod},$.prototype.umod=function(U){return this.divmod(U,"mod",!0).mod},$.prototype.divRound=function(U){var X=this.divmod(U);if(X.mod.isZero())return X.div;var q=X.div.negative!==0?X.mod.isub(U):X.mod,H=U.ushrn(1),V=U.andln(1),F=q.cmp(H);if(F<0||V===1&&F===0)return X.div;return X.div.negative!==0?X.div.isubn(1):X.div.iaddn(1)},$.prototype.modrn=function(U){var X=U<0;if(X)U=-U;Q(U<=67108863);var q=67108864%U,H=0;for(var V=this.length-1;V>=0;V--)H=(q*H+(this.words[V]|0))%U;return X?-H:H},$.prototype.modn=function(U){return this.modrn(U)},$.prototype.idivn=function(U){var X=U<0;if(X)U=-U;Q(U<=67108863);var q=0;for(var H=this.length-1;H>=0;H--){var V=(this.words[H]|0)+q*67108864;this.words[H]=V/U|0,q=V%U}return this._strip(),X?this.ineg():this},$.prototype.divn=function(U){return this.clone().idivn(U)},$.prototype.egcd=function(U){Q(U.negative===0),Q(!U.isZero());var X=this,q=U.clone();if(X.negative!==0)X=X.umod(U);else X=X.clone();var H=new $(1),V=new $(0),F=new $(0),I=new $(1),D=0;while(X.isEven()&&q.isEven())X.iushrn(1),q.iushrn(1),++D;var P=q.clone(),k=X.clone();while(!X.isZero()){for(var b=0,r=1;(X.words[0]&r)===0&&b<26;++b,r<<=1);if(b>0){X.iushrn(b);while(b-- >0){if(H.isOdd()||V.isOdd())H.iadd(P),V.isub(k);H.iushrn(1),V.iushrn(1)}}for(var f=0,T1=1;(q.words[0]&T1)===0&&f<26;++f,T1<<=1);if(f>0){q.iushrn(f);while(f-- >0){if(F.isOdd()||I.isOdd())F.iadd(P),I.isub(k);F.iushrn(1),I.iushrn(1)}}if(X.cmp(q)>=0)X.isub(q),H.isub(F),V.isub(I);else q.isub(X),F.isub(H),I.isub(V)}return{a:F,b:I,gcd:q.iushln(D)}},$.prototype._invmp=function(U){Q(U.negative===0),Q(!U.isZero());var X=this,q=U.clone();if(X.negative!==0)X=X.umod(U);else X=X.clone();var H=new $(1),V=new $(0),F=q.clone();while(X.cmpn(1)>0&&q.cmpn(1)>0){for(var I=0,D=1;(X.words[0]&D)===0&&I<26;++I,D<<=1);if(I>0){X.iushrn(I);while(I-- >0){if(H.isOdd())H.iadd(F);H.iushrn(1)}}for(var P=0,k=1;(q.words[0]&k)===0&&P<26;++P,k<<=1);if(P>0){q.iushrn(P);while(P-- >0){if(V.isOdd())V.iadd(F);V.iushrn(1)}}if(X.cmp(q)>=0)X.isub(q),H.isub(V);else q.isub(X),V.isub(H)}var b;if(X.cmpn(1)===0)b=H;else b=V;if(b.cmpn(0)<0)b.iadd(U);return b},$.prototype.gcd=function(U){if(this.isZero())return U.abs();if(U.isZero())return this.abs();var X=this.clone(),q=U.clone();X.negative=0,q.negative=0;for(var H=0;X.isEven()&&q.isEven();H++)X.iushrn(1),q.iushrn(1);do{while(X.isEven())X.iushrn(1);while(q.isEven())q.iushrn(1);var V=X.cmp(q);if(V<0){var F=X;X=q,q=F}else if(V===0||q.cmpn(1)===0)break;X.isub(q)}while(!0);return q.iushln(H)},$.prototype.invm=function(U){return this.egcd(U).a.umod(U)},$.prototype.isEven=function(){return(this.words[0]&1)===0},$.prototype.isOdd=function(){return(this.words[0]&1)===1},$.prototype.andln=function(U){return this.words[0]&U},$.prototype.bincn=function(U){Q(typeof U==="number");var X=U%26,q=(U-X)/26,H=1<<X;if(this.length<=q)return this._expand(q+1),this.words[q]|=H,this;var V=H;for(var F=q;V!==0&&F<this.length;F++){var I=this.words[F]|0;I+=V,V=I>>>26,I&=67108863,this.words[F]=I}if(V!==0)this.words[F]=V,this.length++;return this},$.prototype.isZero=function(){return this.length===1&&this.words[0]===0},$.prototype.cmpn=function(U){var X=U<0;if(this.negative!==0&&!X)return-1;if(this.negative===0&&X)return 1;this._strip();var q;if(this.length>1)q=1;else{if(X)U=-U;Q(U<=67108863,"Number is too big");var H=this.words[0]|0;q=H===U?0:H<U?-1:1}if(this.negative!==0)return-q|0;return q},$.prototype.cmp=function(U){if(this.negative!==0&&U.negative===0)return-1;if(this.negative===0&&U.negative!==0)return 1;var X=this.ucmp(U);if(this.negative!==0)return-X|0;return X},$.prototype.ucmp=function(U){if(this.length>U.length)return 1;if(this.length<U.length)return-1;var X=0;for(var q=this.length-1;q>=0;q--){var H=this.words[q]|0,V=U.words[q]|0;if(H===V)continue;if(H<V)X=-1;else if(H>V)X=1;break}return X},$.prototype.gtn=function(U){return this.cmpn(U)===1},$.prototype.gt=function(U){return this.cmp(U)===1},$.prototype.gten=function(U){return this.cmpn(U)>=0},$.prototype.gte=function(U){return this.cmp(U)>=0},$.prototype.ltn=function(U){return this.cmpn(U)===-1},$.prototype.lt=function(U){return this.cmp(U)===-1},$.prototype.lten=function(U){return this.cmpn(U)<=0},$.prototype.lte=function(U){return this.cmp(U)<=0},$.prototype.eqn=function(U){return this.cmpn(U)===0},$.prototype.eq=function(U){return this.cmp(U)===0},$.red=function(U){return new n(U)},$.prototype.toRed=function(U){return Q(!this.red,"Already a number in reduction context"),Q(this.negative===0,"red works only with positives"),U.convertTo(this)._forceRed(U)},$.prototype.fromRed=function(){return Q(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},$.prototype._forceRed=function(U){return this.red=U,this},$.prototype.forceRed=function(U){return Q(!this.red,"Already a number in reduction context"),this._forceRed(U)},$.prototype.redAdd=function(U){return Q(this.red,"redAdd works only with red numbers"),this.red.add(this,U)},$.prototype.redIAdd=function(U){return Q(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,U)},$.prototype.redSub=function(U){return Q(this.red,"redSub works only with red numbers"),this.red.sub(this,U)},$.prototype.redISub=function(U){return Q(this.red,"redISub works only with red numbers"),this.red.isub(this,U)},$.prototype.redShl=function(U){return Q(this.red,"redShl works only with red numbers"),this.red.shl(this,U)},$.prototype.redMul=function(U){return Q(this.red,"redMul works only with red numbers"),this.red._verify2(this,U),this.red.mul(this,U)},$.prototype.redIMul=function(U){return Q(this.red,"redMul works only with red numbers"),this.red._verify2(this,U),this.red.imul(this,U)},$.prototype.redSqr=function(){return Q(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},$.prototype.redISqr=function(){return Q(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},$.prototype.redSqrt=function(){return Q(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},$.prototype.redInvm=function(){return Q(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},$.prototype.redNeg=function(){return Q(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},$.prototype.redPow=function(U){return Q(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 u(R,U){this.name=R,this.p=new $(U,16),this.n=this.p.bitLength(),this.k=new $(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}u.prototype._tmp=function(){var U=new $(null);return U.words=Array(Math.ceil(this.n/13)),U},u.prototype.ireduce=function(U){var X=U,q;do this.split(X,this.tmp),X=this.imulK(X),X=X.iadd(this.tmp),q=X.bitLength();while(q>this.n);var H=q<this.n?-1:X.ucmp(this.p);if(H===0)X.words[0]=0,X.length=1;else if(H>0)X.isub(this.p);else if(X.strip!==void 0)X.strip();else X._strip();return X},u.prototype.split=function(U,X){U.iushrn(this.n,0,X)},u.prototype.imulK=function(U){return U.imul(this.k)};function i(){u.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}J(i,u),i.prototype.split=function(U,X){var q=4194303,H=Math.min(U.length,9);for(var V=0;V<H;V++)X.words[V]=U.words[V];if(X.length=H,U.length<=9){U.words[0]=0,U.length=1;return}var F=U.words[9];X.words[X.length++]=F&q;for(V=10;V<U.length;V++){var I=U.words[V]|0;U.words[V-10]=(I&q)<<4|F>>>22,F=I}if(F>>>=22,U.words[V-10]=F,F===0&&U.length>10)U.length-=10;else U.length-=9},i.prototype.imulK=function(U){U.words[U.length]=0,U.words[U.length+1]=0,U.length+=2;var X=0;for(var q=0;q<U.length;q++){var H=U.words[q]|0;X+=H*977,U.words[q]=X&67108863,X=H*64+(X/67108864|0)}if(U.words[U.length-1]===0){if(U.length--,U.words[U.length-1]===0)U.length--}return U};function d(){u.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}J(d,u);function h(){u.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}J(h,u);function o(){u.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}J(o,u),o.prototype.imulK=function(U){var X=0;for(var q=0;q<U.length;q++){var H=(U.words[q]|0)*19+X,V=H&67108863;H>>>=26,U.words[q]=V,X=H}if(X!==0)U.words[U.length++]=X;return U},$._prime=function(U){if(c[U])return c[U];var X;if(U==="k256")X=new i;else if(U==="p224")X=new d;else if(U==="p192")X=new h;else if(U==="p25519")X=new o;else throw Error("Unknown prime "+U);return c[U]=X,X};function n(R){if(typeof R==="string"){var U=$._prime(R);this.m=U.p,this.prime=U}else Q(R.gtn(1),"modulus must be greater than 1"),this.m=R,this.prime=null}n.prototype._verify1=function(U){Q(U.negative===0,"red works only with positives"),Q(U.red,"red works only with red numbers")},n.prototype._verify2=function(U,X){Q((U.negative|X.negative)===0,"red works only with positives"),Q(U.red&&U.red===X.red,"red works only with red numbers")},n.prototype.imod=function(U){if(this.prime)return this.prime.ireduce(U)._forceRed(this);return C(U,U.umod(this.m)._forceRed(this)),U},n.prototype.neg=function(U){if(U.isZero())return U.clone();return this.m.sub(U)._forceRed(this)},n.prototype.add=function(U,X){this._verify2(U,X);var q=U.add(X);if(q.cmp(this.m)>=0)q.isub(this.m);return q._forceRed(this)},n.prototype.iadd=function(U,X){this._verify2(U,X);var q=U.iadd(X);if(q.cmp(this.m)>=0)q.isub(this.m);return q},n.prototype.sub=function(U,X){this._verify2(U,X);var q=U.sub(X);if(q.cmpn(0)<0)q.iadd(this.m);return q._forceRed(this)},n.prototype.isub=function(U,X){this._verify2(U,X);var q=U.isub(X);if(q.cmpn(0)<0)q.iadd(this.m);return q},n.prototype.shl=function(U,X){return this._verify1(U),this.imod(U.ushln(X))},n.prototype.imul=function(U,X){return this._verify2(U,X),this.imod(U.imul(X))},n.prototype.mul=function(U,X){return this._verify2(U,X),this.imod(U.mul(X))},n.prototype.isqr=function(U){return this.imul(U,U.clone())},n.prototype.sqr=function(U){return this.mul(U,U)},n.prototype.sqrt=function(U){if(U.isZero())return U.clone();var X=this.m.andln(3);if(Q(X%2===1),X===3){var q=this.m.add(new $(1)).iushrn(2);return this.pow(U,q)}var H=this.m.subn(1),V=0;while(!H.isZero()&&H.andln(1)===0)V++,H.iushrn(1);Q(!H.isZero());var F=new $(1).toRed(this),I=F.redNeg(),D=this.m.subn(1).iushrn(1),P=this.m.bitLength();P=new $(2*P*P).toRed(this);while(this.pow(P,D).cmp(I)!==0)P.redIAdd(I);var k=this.pow(P,H),b=this.pow(U,H.addn(1).iushrn(1)),r=this.pow(U,H),f=V;while(r.cmp(F)!==0){var T1=r;for(var Q1=0;T1.cmp(F)!==0;Q1++)T1=T1.redSqr();Q(Q1<f);var J1=this.pow(k,new $(1).iushln(f-Q1-1));b=b.redMul(J1),k=J1.redSqr(),r=r.redMul(k),f=Q1}return b},n.prototype.invm=function(U){var X=U._invmp(this.m);if(X.negative!==0)return X.negative=0,this.imod(X).redNeg();else return this.imod(X)},n.prototype.pow=function(U,X){if(X.isZero())return new $(1).toRed(this);if(X.cmpn(1)===0)return U.clone();var q=4,H=Array(1<<q);H[0]=new $(1).toRed(this),H[1]=U;for(var V=2;V<H.length;V++)H[V]=this.mul(H[V-1],U);var F=H[0],I=0,D=0,P=X.bitLength()%26;if(P===0)P=26;for(V=X.length-1;V>=0;V--){var k=X.words[V];for(var b=P-1;b>=0;b--){var r=k>>b&1;if(F!==H[0])F=this.sqr(F);if(r===0&&I===0){D=0;continue}if(I<<=1,I|=r,D++,D!==q&&(V!==0||b!==0))continue;F=this.mul(F,H[I]),D=0,I=0}P=26}return F},n.prototype.convertTo=function(U){var X=U.umod(this.m);return X===U?X.clone():X},n.prototype.convertFrom=function(U){var X=U.clone();return X.red=null,X},$.mont=function(U){return new x(U)};function x(R){if(n.call(this,R),this.shift=this.m.bitLength(),this.shift%26!==0)this.shift+=26-this.shift%26;this.r=new $(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)}J(x,n),x.prototype.convertTo=function(U){return this.imod(U.ushln(this.shift))},x.prototype.convertFrom=function(U){var X=this.imod(U.mul(this.rinv));return X.red=null,X},x.prototype.imul=function(U,X){if(U.isZero()||X.isZero())return U.words[0]=0,U.length=1,U;var q=U.imul(X),H=q.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),V=q.isub(H).iushrn(this.shift),F=V;if(V.cmp(this.m)>=0)F=V.isub(this.m);else if(V.cmpn(0)<0)F=V.iadd(this.m);return F._forceRed(this)},x.prototype.mul=function(U,X){if(U.isZero()||X.isZero())return new $(0)._forceRed(this);var q=U.mul(X),H=q.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),V=q.isub(H).iushrn(this.shift),F=V;if(V.cmp(this.m)>=0)F=V.isub(this.m);else if(V.cmpn(0)<0)F=V.iadd(this.m);return F._forceRed(this)},x.prototype.invm=function(U){var X=this.imod(U._invmp(this.m).mul(this.r2));return X._forceRed(this)}})(typeof H$>"u"||H$,z9)});var I9=ZT((j$,N9)=>{/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var e6=(OA(),VA(l6)),vT=e6.Buffer;function F9(T,A){for(var Q in T)A[Q]=T[Q]}if(vT.from&&vT.alloc&&vT.allocUnsafe&&vT.allocUnsafeSlow)N9.exports=e6;else F9(e6,j$),j$.Buffer=WA;function WA(T,A,Q){return vT(T,A,Q)}WA.prototype=Object.create(vT.prototype);F9(vT,WA);WA.from=function(T,A,Q){if(typeof T==="number")throw TypeError("Argument must not be a number");return vT(T,A,Q)};WA.alloc=function(T,A,Q){if(typeof T!=="number")throw TypeError("Argument must be a number");var J=vT(T);if(A!==void 0)if(typeof Q==="string")J.fill(A,Q);else J.fill(A);else J.fill(0);return J};WA.allocUnsafe=function(T){if(typeof T!=="number")throw TypeError("Argument must be a number");return vT(T)};WA.allocUnsafeSlow=function(T){if(typeof T!=="number")throw TypeError("Argument must be a number");return e6.SlowBuffer(T)}});var L9=ZT((Gx,S9)=>{var TQ=I9().Buffer;function KR(T){if(T.length>=255)throw TypeError("Alphabet too long");var A=new Uint8Array(256);for(var Q=0;Q<A.length;Q++)A[Q]=255;for(var J=0;J<T.length;J++){var $=T.charAt(J),W=$.charCodeAt(0);if(A[W]!==255)throw TypeError($+" is ambiguous");A[W]=J}var G=T.length,Y=T.charAt(0),Z=Math.log(G)/Math.log(256),C=Math.log(256)/Math.log(G);function K(z){if(Array.isArray(z)||z instanceof Uint8Array)z=TQ.from(z);if(!TQ.isBuffer(z))throw TypeError("Expected Buffer");if(z.length===0)return"";var N=0,E=0,L=0,O=z.length;while(L!==O&&z[L]===0)L++,N++;var g=(O-L)*C+1>>>0,v=new Uint8Array(g);while(L!==O){var p=z[L],c=0;for(var u=g-1;(p!==0||c<E)&&u!==-1;u--,c++)p+=256*v[u]>>>0,v[u]=p%G>>>0,p=p/G>>>0;if(p!==0)throw Error("Non-zero carry");E=c,L++}var i=g-E;while(i!==g&&v[i]===0)i++;var d=Y.repeat(N);for(;i<g;++i)d+=T.charAt(v[i]);return d}function j(z){if(typeof z!=="string")throw TypeError("Expected String");if(z.length===0)return TQ.alloc(0);var N=0,E=0,L=0;while(z[N]===Y)E++,N++;var O=(z.length-N)*Z+1>>>0,g=new Uint8Array(O);while(N<z.length){var v=z.charCodeAt(N);if(v>255)return;var p=A[v];if(p===255)return;var c=0;for(var u=O-1;(p!==0||c<L)&&u!==-1;u--,c++)p+=G*g[u]>>>0,g[u]=p%256>>>0,p=p/256>>>0;if(p!==0)throw Error("Non-zero carry");L=c,N++}var i=O-L;while(i!==O&&g[i]===0)i++;var d=TQ.allocUnsafe(E+(O-i));d.fill(0,0,E);var h=E;while(i!==O)d[h++]=g[i++];return d}function M(z){var N=j(z);if(N)return N;throw Error("Non-base"+G+" character")}return{encode:K,decodeUnsafe:j,decode:M}}S9.exports=KR});var R$=ZT((Ux,w9)=>{var CR=L9(),HR="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";w9.exports=CR(HR)});var E9={};P4(E9,{TextEncoder:()=>$Q,TextDecoder:()=>JQ});function W8(T,A,Q){return A<=T&&T<=Q}function WQ(T){if(T===void 0)return{};if(T===Object(T))return T;throw TypeError("Could not convert argument to dictionary")}function VR(T){var A=String(T),Q=A.length,J=0,$=[];while(J<Q){var W=A.charCodeAt(J);if(W<55296||W>57343)$.push(W);else if(56320<=W&&W<=57343)$.push(65533);else if(55296<=W&&W<=56319)if(J===Q-1)$.push(65533);else{var G=T.charCodeAt(J+1);if(56320<=G&&G<=57343){var Y=W&1023,Z=G&1023;$.push(65536+(Y<<10)+Z),J+=1}else $.push(65533)}J+=1}return $}function jR(T){var A="";for(var Q=0;Q<T.length;++Q){var J=T[Q];if(J<=65535)A+=String.fromCharCode(J);else J-=65536,A+=String.fromCharCode((J>>10)+55296,(J&1023)+56320)}return A}function k$(T){this.tokens=[].slice.call(T)}function M$(T,A){if(T)throw TypeError("Decoder error");return A||65533}function RR(){}function DR(){}function JQ(T,A){if(!(this instanceof JQ))return new JQ(T,A);if(T=T!==void 0?String(T).toLowerCase():QQ,T!==QQ)throw Error("Encoding not supported. Only utf-8 is supported");A=WQ(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 $Q(T,A){if(!(this instanceof $Q))return new $Q(T,A);if(T=T!==void 0?String(T).toLowerCase():QQ,T!==QQ)throw Error("Encoding not supported. Only utf-8 is supported");A=WQ(A),this._streaming=!1,this._encoder=null,this._options={fatal:Boolean(A.fatal)},Object.defineProperty(this,"encoding",{value:"utf-8"})}function MR(T){var A=T.fatal,Q=0,J=0,$=0,W=128,G=191;this.handler=function(Y,Z){if(Z===AQ&&$!==0)return $=0,M$(A);if(Z===AQ)return vA;if($===0){if(W8(Z,0,127))return Z;if(W8(Z,194,223))$=1,Q=Z-192;else if(W8(Z,224,239)){if(Z===224)W=160;if(Z===237)G=159;$=2,Q=Z-224}else if(W8(Z,240,244)){if(Z===240)W=144;if(Z===244)G=143;$=3,Q=Z-240}else return M$(A);return Q=Q<<6*$,null}if(!W8(Z,W,G))return Q=$=J=0,W=128,G=191,Y.prepend(Z),M$(A);if(W=128,G=191,J+=1,Q+=Z-128<<6*($-J),J!==$)return null;var C=Q;return Q=$=J=0,C}}function kR(T){var A=T.fatal;this.handler=function(Q,J){if(J===AQ)return vA;if(W8(J,0,127))return J;var $,W;if(W8(J,128,2047))$=1,W=192;else if(W8(J,2048,65535))$=2,W=224;else if(W8(J,65536,1114111))$=3,W=240;var G=[(J>>6*$)+W];while($>0){var Y=J>>6*($-1);G.push(128|Y&63),$-=1}return G}}var AQ=-1,vA=-1,QQ="utf-8";var O9=w0(()=>{k$.prototype={endOfStream:function(){return!this.tokens.length},read:function(){if(!this.tokens.length)return AQ;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)}};RR.prototype={handler:function(T,A){}};DR.prototype={handler:function(T,A){}};JQ.prototype={decode:function(A,Q){var J;if(typeof A==="object"&&A instanceof ArrayBuffer)J=new Uint8Array(A);else if(typeof A==="object"&&"buffer"in A&&A.buffer instanceof ArrayBuffer)J=new Uint8Array(A.buffer,A.byteOffset,A.byteLength);else J=new Uint8Array(0);if(Q=WQ(Q),!this._streaming)this._decoder=new MR({fatal:this._fatal}),this._BOMseen=!1;this._streaming=Boolean(Q.stream);var $=new k$(J),W=[],G;while(!$.endOfStream()){if(G=this._decoder.handler($,$.read()),G===vA)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($,$.read()),G===vA)break;if(G===null)continue;if(Array.isArray(G))W.push.apply(W,G);else W.push(G)}while(!$.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 jR(W)}};$Q.prototype={encode:function(A,Q){if(A=A?String(A):"",Q=WQ(Q),!this._streaming)this._encoder=new kR(this._options);this._streaming=Boolean(Q.stream);var J=[],$=new k$(VR(A)),W;while(!$.endOfStream()){if(W=this._encoder.handler($,$.read()),W===vA)break;if(Array.isArray(W))J.push.apply(J,W);else J.push(W)}if(!this._streaming){while(!0){if(W=this._encoder.handler($,$.read()),W===vA)break;if(Array.isArray(W))J.push.apply(J,W);else J.push(W)}this._encoder=null}return new Uint8Array(J)}}});var g9=ZT((K1)=>{var zR=K1&&K1.__createBinding||(Object.create?function(T,A,Q,J){if(J===void 0)J=Q;Object.defineProperty(T,J,{enumerable:!0,get:function(){return A[Q]}})}:function(T,A,Q,J){if(J===void 0)J=Q;T[J]=A[Q]}),FR=K1&&K1.__setModuleDefault||(Object.create?function(T,A){Object.defineProperty(T,"default",{enumerable:!0,value:A})}:function(T,A){T.default=A}),yT=K1&&K1.__decorate||function(T,A,Q,J){var $=arguments.length,W=$<3?A:J===null?J=Object.getOwnPropertyDescriptor(A,Q):J,G;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")W=Reflect.decorate(T,A,Q,J);else for(var Y=T.length-1;Y>=0;Y--)if(G=T[Y])W=($<3?G(W):$>3?G(A,Q,W):G(A,Q))||W;return $>3&&W&&Object.defineProperty(A,Q,W),W},NR=K1&&K1.__importStar||function(T){if(T&&T.__esModule)return T;var A={};if(T!=null){for(var Q in T)if(Q!=="default"&&Object.hasOwnProperty.call(T,Q))zR(A,T,Q)}return FR(A,T),A},B9=K1&&K1.__importDefault||function(T){return T&&T.__esModule?T:{default:T}};Object.defineProperty(K1,"__esModule",{value:!0});K1.deserializeUnchecked=K1.deserialize=K1.serialize=K1.BinaryReader=K1.BinaryWriter=K1.BorshError=K1.baseDecode=K1.baseEncode=void 0;var B8=B9(V$()),_9=B9(R$()),IR=NR((O9(),VA(E9))),SR=typeof TextDecoder!=="function"?IR.TextDecoder:TextDecoder,LR=new SR("utf-8",{fatal:!0});function wR(T){if(typeof T==="string")T=Buffer.from(T,"utf8");return _9.default.encode(Buffer.from(T))}K1.baseEncode=wR;function ER(T){return Buffer.from(_9.default.decode(T))}K1.baseDecode=ER;var z$=1024;class B0 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(".")}}K1.BorshError=B0;class F${constructor(){this.buf=Buffer.alloc(z$),this.length=0}maybeResize(){if(this.buf.length<16+this.length)this.buf=Buffer.concat([this.buf,Buffer.alloc(z$)])}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 B8.default(T).toArray("le",8)))}writeU128(T){this.maybeResize(),this.writeBuffer(Buffer.from(new B8.default(T).toArray("le",16)))}writeU256(T){this.maybeResize(),this.writeBuffer(Buffer.from(new B8.default(T).toArray("le",32)))}writeU512(T){this.maybeResize(),this.writeBuffer(Buffer.from(new B8.default(T).toArray("le",64)))}writeBuffer(T){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),T,Buffer.alloc(z$)]),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 Q of T)this.maybeResize(),A(Q)}toArray(){return this.buf.subarray(0,this.length)}}K1.BinaryWriter=F$;function bT(T,A,Q){let J=Q.value;Q.value=function(...$){try{return J.apply(this,$)}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 B0("Reached the end of buffer when deserializing")}throw W}}}class e0{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 B8.default(T,"le")}readU128(){let T=this.readBuffer(16);return new B8.default(T,"le")}readU256(){let T=this.readBuffer(32);return new B8.default(T,"le")}readU512(){let T=this.readBuffer(64);return new B8.default(T,"le")}readBuffer(T){if(this.offset+T>this.buf.length)throw new B0(`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 LR.decode(A)}catch(Q){throw new B0(`Error decoding UTF-8 string: ${Q}`)}}readFixedArray(T){return new Uint8Array(this.readBuffer(T))}readArray(T){let A=this.readU32(),Q=Array();for(let J=0;J<A;++J)Q.push(T());return Q}}yT([bT],e0.prototype,"readU8",null);yT([bT],e0.prototype,"readU16",null);yT([bT],e0.prototype,"readU32",null);yT([bT],e0.prototype,"readU64",null);yT([bT],e0.prototype,"readU128",null);yT([bT],e0.prototype,"readU256",null);yT([bT],e0.prototype,"readU512",null);yT([bT],e0.prototype,"readString",null);yT([bT],e0.prototype,"readFixedArray",null);yT([bT],e0.prototype,"readArray",null);K1.BinaryReader=e0;function x9(T){return T.charAt(0).toUpperCase()+T.slice(1)}function GA(T,A,Q,J,$){try{if(typeof J==="string")$[`write${x9(J)}`](Q);else if(J instanceof Array)if(typeof J[0]==="number"){if(Q.length!==J[0])throw new B0(`Expecting byte array of length ${J[0]}, but got ${Q.length} bytes`);$.writeFixedArray(Q)}else if(J.length===2&&typeof J[1]==="number"){if(Q.length!==J[1])throw new B0(`Expecting byte array of length ${J[1]}, but got ${Q.length} bytes`);for(let W=0;W<J[1];W++)GA(T,null,Q[W],J[0],$)}else $.writeArray(Q,(W)=>{GA(T,A,W,J[0],$)});else if(J.kind!==void 0)switch(J.kind){case"option":{if(Q===null||Q===void 0)$.writeU8(0);else $.writeU8(1),GA(T,A,Q,J.type,$);break}case"map":{$.writeU32(Q.size),Q.forEach((W,G)=>{GA(T,A,G,J.key,$),GA(T,A,W,J.value,$)});break}default:throw new B0(`FieldType ${J} unrecognized`)}else h9(T,Q,$)}catch(W){if(W instanceof B0)W.addToFieldPath(A);throw W}}function h9(T,A,Q){if(typeof A.borshSerialize==="function"){A.borshSerialize(Q);return}let J=T.get(A.constructor);if(!J)throw new B0(`Class ${A.constructor.name} is missing in schema`);if(J.kind==="struct")J.fields.map(([$,W])=>{GA(T,$,A[$],W,Q)});else if(J.kind==="enum"){let $=A[J.field];for(let W=0;W<J.values.length;++W){let[G,Y]=J.values[W];if(G===$){Q.writeU8(W),GA(T,G,A[G],Y,Q);break}}}else throw new B0(`Unexpected schema kind: ${J.kind} for ${A.constructor.name}`)}function OR(T,A,Q=F$){let J=new Q;return h9(T,A,J),J.toArray()}K1.serialize=OR;function UA(T,A,Q,J){try{if(typeof Q==="string")return J[`read${x9(Q)}`]();if(Q instanceof Array)if(typeof Q[0]==="number")return J.readFixedArray(Q[0]);else if(typeof Q[1]==="number"){let $=[];for(let W=0;W<Q[1];W++)$.push(UA(T,null,Q[0],J));return $}else return J.readArray(()=>UA(T,A,Q[0],J));if(Q.kind==="option"){if(J.readU8())return UA(T,A,Q.type,J);return}if(Q.kind==="map"){let $=new Map,W=J.readU32();for(let G=0;G<W;G++){let Y=UA(T,A,Q.key,J),Z=UA(T,A,Q.value,J);$.set(Y,Z)}return $}return N$(T,Q,J)}catch($){if($ instanceof B0)$.addToFieldPath(A);throw $}}function N$(T,A,Q){if(typeof A.borshDeserialize==="function")return A.borshDeserialize(Q);let J=T.get(A);if(!J)throw new B0(`Class ${A.name} is missing in schema`);if(J.kind==="struct"){let $={};for(let[W,G]of T.get(A).fields)$[W]=UA(T,W,G,Q);return new A($)}if(J.kind==="enum"){let $=Q.readU8();if($>=J.values.length)throw new B0(`Enum index: ${$} is out of range`);let[W,G]=J.values[$],Y=UA(T,W,G,Q);return new A({[W]:Y})}throw new B0(`Unexpected schema kind: ${J.kind} for ${A.constructor.name}`)}function BR(T,A,Q,J=e0){let $=new J(Q),W=N$(T,A,$);if($.offset<Q.length)throw new B0(`Unexpected ${Q.length-$.offset} bytes after deserialized data`);return W}K1.deserialize=BR;function _R(T,A,Q,J=e0){let $=new J(Q);return N$(T,A,$)}K1.deserializeUnchecked=_R});var G8=ZT((m9)=>{Object.defineProperty(m9,"__esModule",{value:!0});m9.s16=m9.s8=m9.nu64be=m9.u48be=m9.u40be=m9.u32be=m9.u24be=m9.u16be=m9.nu64=m9.u48=m9.u40=m9.u32=m9.u24=m9.u16=m9.u8=m9.offset=m9.greedy=m9.Constant=m9.UTF8=m9.CString=m9.Blob=m9.Boolean=m9.BitField=m9.BitStructure=m9.VariantLayout=m9.Union=m9.UnionLayoutDiscriminator=m9.UnionDiscriminator=m9.Structure=m9.Sequence=m9.DoubleBE=m9.Double=m9.FloatBE=m9.Float=m9.NearInt64BE=m9.NearInt64=m9.NearUInt64BE=m9.NearUInt64=m9.IntBE=m9.Int=m9.UIntBE=m9.UInt=m9.OffsetLayout=m9.GreedyCount=m9.ExternalLayout=m9.bindConstructorLayout=m9.nameWithProperty=m9.Layout=m9.uint8ArrayToBuffer=m9.checkUint8Array=void 0;m9.constant=m9.utf8=m9.cstr=m9.blob=m9.unionLayoutDiscriminator=m9.union=m9.seq=m9.bits=m9.struct=m9.f64be=m9.f64=m9.f32be=m9.f32=m9.ns64be=m9.s48be=m9.s40be=m9.s32be=m9.s24be=m9.s16be=m9.ns64=m9.s48=m9.s40=m9.s32=m9.s24=void 0;var S$=(OA(),VA(l6));function bA(T){if(!(T instanceof Uint8Array))throw TypeError("b must be a Uint8Array")}m9.checkUint8Array=bA;function U1(T){return bA(T),S$.Buffer.from(T.buffer,T.byteOffset,T.length)}m9.uint8ArrayToBuffer=U1;class P1{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}}m9.Layout=P1;function L$(T,A){if(A.property)return T+"["+A.property+"]";return T}m9.nameWithProperty=L$;function xR(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 P1))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(Q,J){return A.encode(this,Q,J)},writable:!0}),Object.defineProperty(T,"decode",{value(Q,J){return A.decode(Q,J)},writable:!0})}m9.bindConstructorLayout=xR;class c0 extends P1{isCount(){throw Error("ExternalLayout is abstract")}}m9.ExternalLayout=c0;class w$ extends c0{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){bA(T);let Q=T.length-A;return Math.floor(Q/this.elementSpan)}encode(T,A,Q){return 0}}m9.GreedyCount=w$;class GQ extends c0{constructor(T,A=0,Q){if(!(T instanceof P1))throw TypeError("layout must be a Layout");if(!Number.isInteger(A))throw TypeError("offset must be integer or undefined");super(T.span,Q||T.property);this.layout=T,this.offset=A}isCount(){return this.layout instanceof YT||this.layout instanceof VT}decode(T,A=0){return this.layout.decode(T,A+this.offset)}encode(T,A,Q=0){return this.layout.encode(T,A,Q+this.offset)}}m9.OffsetLayout=GQ;class YT extends P1{constructor(T,A){super(T,A);if(6<this.span)throw RangeError("span must not exceed 6 bytes")}decode(T,A=0){return U1(T).readUIntLE(A,this.span)}encode(T,A,Q=0){return U1(A).writeUIntLE(T,Q,this.span),this.span}}m9.UInt=YT;class VT extends P1{constructor(T,A){super(T,A);if(6<this.span)throw RangeError("span must not exceed 6 bytes")}decode(T,A=0){return U1(T).readUIntBE(A,this.span)}encode(T,A,Q=0){return U1(A).writeUIntBE(T,Q,this.span),this.span}}m9.UIntBE=VT;class _8 extends P1{constructor(T,A){super(T,A);if(6<this.span)throw RangeError("span must not exceed 6 bytes")}decode(T,A=0){return U1(T).readIntLE(A,this.span)}encode(T,A,Q=0){return U1(A).writeIntLE(T,Q,this.span),this.span}}m9.Int=_8;class YA extends P1{constructor(T,A){super(T,A);if(6<this.span)throw RangeError("span must not exceed 6 bytes")}decode(T,A=0){return U1(T).readIntBE(A,this.span)}encode(T,A,Q=0){return U1(A).writeIntBE(T,Q,this.span),this.span}}m9.IntBE=YA;var I$=Math.pow(2,32);function UQ(T){let A=Math.floor(T/I$),Q=T-A*I$;return{hi32:A,lo32:Q}}function YQ(T,A){return T*I$+A}class E$ extends P1{constructor(T){super(8,T)}decode(T,A=0){let Q=U1(T),J=Q.readUInt32LE(A),$=Q.readUInt32LE(A+4);return YQ($,J)}encode(T,A,Q=0){let J=UQ(T),$=U1(A);return $.writeUInt32LE(J.lo32,Q),$.writeUInt32LE(J.hi32,Q+4),8}}m9.NearUInt64=E$;class O$ extends P1{constructor(T){super(8,T)}decode(T,A=0){let Q=U1(T),J=Q.readUInt32BE(A),$=Q.readUInt32BE(A+4);return YQ(J,$)}encode(T,A,Q=0){let J=UQ(T),$=U1(A);return $.writeUInt32BE(J.hi32,Q),$.writeUInt32BE(J.lo32,Q+4),8}}m9.NearUInt64BE=O$;class B$ extends P1{constructor(T){super(8,T)}decode(T,A=0){let Q=U1(T),J=Q.readUInt32LE(A),$=Q.readInt32LE(A+4);return YQ($,J)}encode(T,A,Q=0){let J=UQ(T),$=U1(A);return $.writeUInt32LE(J.lo32,Q),$.writeInt32LE(J.hi32,Q+4),8}}m9.NearInt64=B$;class _$ extends P1{constructor(T){super(8,T)}decode(T,A=0){let Q=U1(T),J=Q.readInt32BE(A),$=Q.readUInt32BE(A+4);return YQ(J,$)}encode(T,A,Q=0){let J=UQ(T),$=U1(A);return $.writeInt32BE(J.hi32,Q),$.writeUInt32BE(J.lo32,Q+4),8}}m9.NearInt64BE=_$;class x$ extends P1{constructor(T){super(4,T)}decode(T,A=0){return U1(T).readFloatLE(A)}encode(T,A,Q=0){return U1(A).writeFloatLE(T,Q),4}}m9.Float=x$;class h$ extends P1{constructor(T){super(4,T)}decode(T,A=0){return U1(T).readFloatBE(A)}encode(T,A,Q=0){return U1(A).writeFloatBE(T,Q),4}}m9.FloatBE=h$;class g$ extends P1{constructor(T){super(8,T)}decode(T,A=0){return U1(T).readDoubleLE(A)}encode(T,A,Q=0){return U1(A).writeDoubleLE(T,Q),8}}m9.Double=g$;class m$ extends P1{constructor(T){super(8,T)}decode(T,A=0){return U1(T).readDoubleBE(A)}encode(T,A,Q=0){return U1(A).writeDoubleBE(T,Q),8}}m9.DoubleBE=m$;class v$ extends P1{constructor(T,A,Q){if(!(T instanceof P1))throw TypeError("elementLayout must be a Layout");if(!(A instanceof c0&&A.isCount()||Number.isInteger(A)&&0<=A))throw TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let J=-1;if(!(A instanceof c0)&&0<T.span)J=A*T.span;super(J,Q);this.elementLayout=T,this.count=A}getSpan(T,A=0){if(0<=this.span)return this.span;let Q=0,J=this.count;if(J instanceof c0)J=J.decode(T,A);if(0<this.elementLayout.span)Q=J*this.elementLayout.span;else{let $=0;while($<J)Q+=this.elementLayout.getSpan(T,A+Q),++$}return Q}decode(T,A=0){let Q=[],J=0,$=this.count;if($ instanceof c0)$=$.decode(T,A);while(J<$)Q.push(this.elementLayout.decode(T,A)),A+=this.elementLayout.getSpan(T,A),J+=1;return Q}encode(T,A,Q=0){let J=this.elementLayout,$=T.reduce((W,G)=>{return W+J.encode(G,A,Q+W)},0);if(this.count instanceof c0)this.count.encode(T.length,A,Q);return $}}m9.Sequence=v$;class y$ extends P1{constructor(T,A,Q){if(!(Array.isArray(T)&&T.reduce(($,W)=>$&&W instanceof P1,!0)))throw TypeError("fields must be array of Layout instances");if(typeof A==="boolean"&&Q===void 0)Q=A,A=void 0;for(let $ of T)if(0>$.span&&$.property===void 0)throw Error("fields cannot contain unnamed variable-length layout");let J=-1;try{J=T.reduce(($,W)=>$+W.getSpan(),0)}catch($){}super(J,A);this.fields=T,this.decodePrefixes=!!Q}getSpan(T,A=0){if(0<=this.span)return this.span;let Q=0;try{Q=this.fields.reduce((J,$)=>{let W=$.getSpan(T,A);return A+=W,J+W},0)}catch(J){throw RangeError("indeterminate span")}return Q}decode(T,A=0){bA(T);let Q=this.makeDestinationObject();for(let J of this.fields){if(J.property!==void 0)Q[J.property]=J.decode(T,A);if(A+=J.getSpan(T,A),this.decodePrefixes&&T.length===A)break}return Q}encode(T,A,Q=0){let J=Q,$=0,W=0;for(let G of this.fields){let Y=G.span;if(W=0<Y?Y:0,G.property!==void 0){let Z=T[G.property];if(Z!==void 0){if(W=G.encode(Z,A,Q),0>Y)Y=G.getSpan(A,Q)}}$=Q,Q+=Y}return $+W-J}fromArray(T){let A=this.makeDestinationObject();for(let Q of this.fields)if(Q.property!==void 0&&0<T.length)A[Q.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 Q of this.fields){if(Q.property===T)return A;if(0>Q.span)A=-1;else if(0<=A)A+=Q.span}return}}m9.Structure=y$;class ZQ{constructor(T){this.property=T}decode(T,A){throw Error("UnionDiscriminator is abstract")}encode(T,A,Q){throw Error("UnionDiscriminator is abstract")}}m9.UnionDiscriminator=ZQ;class L2 extends ZQ{constructor(T,A){if(!(T instanceof c0&&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,Q){return this.layout.encode(T,A,Q)}}m9.UnionLayoutDiscriminator=L2;class XQ extends P1{constructor(T,A,Q){let J;if(T instanceof YT||T instanceof VT)J=new L2(new GQ(T));else if(T instanceof c0&&T.isCount())J=new L2(T);else if(!(T instanceof ZQ))throw TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");else J=T;if(A===void 0)A=null;if(!(A===null||A instanceof P1))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 $=-1;if(A){if($=A.span,0<=$&&(T instanceof YT||T instanceof VT))$+=J.layout.span}super($,Q);this.discriminator=J,this.usesPrefixDiscriminator=T instanceof YT||T instanceof VT,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 Q=this.getVariant(T,A);if(!Q)throw Error("unable to determine span for unrecognized variant");return Q.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 Q=this.registry[A];if(Q.property&&Object.prototype.hasOwnProperty.call(T,Q.property))return Q}throw Error("unable to infer src variant")}decode(T,A=0){let Q,J=this.discriminator,$=J.decode(T,A),W=this.registry[$];if(W===void 0){let G=this.defaultLayout,Y=0;if(this.usesPrefixDiscriminator)Y=J.layout.span;Q=this.makeDestinationObject(),Q[J.property]=$,Q[G.property]=G.decode(T,A+Y)}else Q=W.decode(T,A);return Q}encode(T,A,Q=0){let J=this.getSourceVariant(T);if(J===void 0){let $=this.discriminator,W=this.defaultLayout,G=0;if(this.usesPrefixDiscriminator)G=$.layout.span;return $.encode(T[$.property],A,Q),G+W.encode(T[W.property],A,Q+G)}return J.encode(T,A,Q)}addVariant(T,A,Q){let J=new b$(this,T,A,Q);return this.registry[T]=J,J}getVariant(T,A=0){let Q;if(T instanceof Uint8Array)Q=this.discriminator.decode(T,A);else Q=T;return this.registry[Q]}}m9.Union=XQ;class b$ extends P1{constructor(T,A,Q,J){if(!(T instanceof XQ))throw TypeError("union must be a Union");if(!Number.isInteger(A)||0>A)throw TypeError("variant must be a (non-negative) integer");if(typeof Q==="string"&&J===void 0)J=Q,Q=null;if(Q){if(!(Q instanceof P1))throw TypeError("layout must be a Layout");if(T.defaultLayout!==null&&0<=Q.span&&Q.span>T.defaultLayout.span)throw Error("variant span exceeds span of containing union");if(typeof J!=="string")throw TypeError("variant must have a String property")}let $=T.span;if(0>T.span){if($=Q?Q.span:0,0<=$&&T.usesPrefixDiscriminator)$+=T.discriminator.layout.span}super($,J);this.union=T,this.variant=A,this.layout=Q||null}getSpan(T,A=0){if(0<=this.span)return this.span;let Q=0;if(this.union.usesPrefixDiscriminator)Q=this.union.discriminator.layout.span;let J=0;if(this.layout)J=this.layout.getSpan(T,A+Q);return Q+J}decode(T,A=0){let Q=this.makeDestinationObject();if(this!==this.union.getVariant(T,A))throw Error("variant mismatch");let J=0;if(this.union.usesPrefixDiscriminator)J=this.union.discriminator.layout.span;if(this.layout)Q[this.property]=this.layout.decode(T,A+J);else if(this.property)Q[this.property]=!0;else if(this.union.usesPrefixDiscriminator)Q[this.union.discriminator.property]=this.variant;return Q}encode(T,A,Q=0){let J=0;if(this.union.usesPrefixDiscriminator)J=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,Q);let $=J;if(this.layout){if(this.layout.encode(T[this.property],A,Q+J),$+=this.layout.getSpan(A,Q+J),0<=this.union.span&&$>this.union.span)throw Error("encoded variant overruns containing union")}return $}fromArray(T){if(this.layout)return this.layout.fromArray(T);return}}m9.VariantLayout=b$;function yA(T){if(0>T)T+=4294967296;return T}class PQ extends P1{constructor(T,A,Q){if(!(T instanceof YT||T instanceof VT))throw TypeError("word must be a UInt or UIntBE layout");if(typeof A==="string"&&Q===void 0)Q=A,A=!1;if(4<T.span)throw RangeError("word cannot exceed 32 bits");super(T.span,Q);this.word=T,this.msb=!!A,this.fields=[];let J=0;this._packedSetValue=function($){return J=yA($),this},this._packedGetValue=function(){return J}}decode(T,A=0){let Q=this.makeDestinationObject(),J=this.word.decode(T,A);this._packedSetValue(J);for(let $ of this.fields)if($.property!==void 0)Q[$.property]=$.decode(T);return Q}encode(T,A,Q=0){let J=this.word.decode(A,Q);this._packedSetValue(J);for(let $ of this.fields)if($.property!==void 0){let W=T[$.property];if(W!==void 0)$.encode(W)}return this.word.encode(this._packedGetValue(),A,Q)}addField(T,A){let Q=new qQ(this,T,A);return this.fields.push(Q),Q}addBoolean(T){let A=new p$(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}}m9.BitStructure=PQ;class qQ{constructor(T,A,Q){if(!(T instanceof PQ))throw TypeError("container must be a BitStructure");if(!Number.isInteger(A)||0>=A)throw TypeError("bits must be positive integer");let J=8*T.span,$=T.fields.reduce((W,G)=>W+G.bits,0);if(A+$>J)throw Error("bits too long for span remainder ("+(J-$)+" of "+J+" remain)");if(this.container=T,this.bits=A,this.valueMask=(1<<A)-1,A===32)this.valueMask=4294967295;if(this.start=$,this.container.msb)this.start=J-$-A;this.wordMask=yA(this.valueMask<<this.start),this.property=Q}decode(T,A){let Q=this.container._packedGetValue();return yA(Q&this.wordMask)>>>this.start}encode(T){if(typeof T!=="number"||!Number.isInteger(T)||T!==yA(T&this.valueMask))throw TypeError(L$("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);let A=this.container._packedGetValue(),Q=yA(T<<this.start);this.container._packedSetValue(yA(A&~this.wordMask)|Q)}}m9.BitField=qQ;class p$ extends qQ{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)}}m9.Boolean=p$;class l$ extends P1{constructor(T,A){if(!(T instanceof c0&&T.isCount()||Number.isInteger(T)&&0<=T))throw TypeError("length must be positive integer or an unsigned integer ExternalLayout");let Q=-1;if(!(T instanceof c0))Q=T;super(Q,A);this.length=T}getSpan(T,A){let Q=this.span;if(0>Q)Q=this.length.decode(T,A);return Q}decode(T,A=0){let Q=this.span;if(0>Q)Q=this.length.decode(T,A);return U1(T).slice(A,A+Q)}encode(T,A,Q){let J=this.length;if(this.length instanceof c0)J=T.length;if(!(T instanceof Uint8Array&&J===T.length))throw TypeError(L$("Blob.encode",this)+" requires (length "+J+") Uint8Array as src");if(Q+J>A.length)throw RangeError("encoding overruns Uint8Array");let $=U1(T);if(U1(A).write($.toString("hex"),Q,J,"hex"),this.length instanceof c0)this.length.encode(J,A,Q);return J}}m9.Blob=l$;class u$ extends P1{constructor(T){super(-1,T)}getSpan(T,A=0){bA(T);let Q=A;while(Q<T.length&&T[Q]!==0)Q+=1;return 1+Q-A}decode(T,A=0){let Q=this.getSpan(T,A);return U1(T).slice(A,A+Q-1).toString("utf-8")}encode(T,A,Q=0){if(typeof T!=="string")T=String(T);let J=S$.Buffer.from(T,"utf8"),$=J.length;if(Q+$>A.length)throw RangeError("encoding overruns Buffer");let W=U1(A);return J.copy(W,Q),W[Q+$]=0,$+1}}m9.CString=u$;class d$ extends P1{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 bA(T),T.length-A}decode(T,A=0){let Q=this.getSpan(T,A);if(0<=this.maxSpan&&this.maxSpan<Q)throw RangeError("text length exceeds maxSpan");return U1(T).slice(A,A+Q).toString("utf-8")}encode(T,A,Q=0){if(typeof T!=="string")T=String(T);let J=S$.Buffer.from(T,"utf8"),$=J.length;if(0<=this.maxSpan&&this.maxSpan<$)throw RangeError("text length exceeds maxSpan");if(Q+$>A.length)throw RangeError("encoding overruns Buffer");return J.copy(U1(A),Q),$}}m9.UTF8=d$;class c$ extends P1{constructor(T,A){super(0,A);this.value=T}decode(T,A){return this.value}encode(T,A,Q){return 0}}m9.Constant=c$;m9.greedy=(T,A)=>new w$(T,A);m9.offset=(T,A,Q)=>new GQ(T,A,Q);m9.u8=(T)=>new YT(1,T);m9.u16=(T)=>new YT(2,T);m9.u24=(T)=>new YT(3,T);m9.u32=(T)=>new YT(4,T);m9.u40=(T)=>new YT(5,T);m9.u48=(T)=>new YT(6,T);m9.nu64=(T)=>new E$(T);m9.u16be=(T)=>new VT(2,T);m9.u24be=(T)=>new VT(3,T);m9.u32be=(T)=>new VT(4,T);m9.u40be=(T)=>new VT(5,T);m9.u48be=(T)=>new VT(6,T);m9.nu64be=(T)=>new O$(T);m9.s8=(T)=>new _8(1,T);m9.s16=(T)=>new _8(2,T);m9.s24=(T)=>new _8(3,T);m9.s32=(T)=>new _8(4,T);m9.s40=(T)=>new _8(5,T);m9.s48=(T)=>new _8(6,T);m9.ns64=(T)=>new B$(T);m9.s16be=(T)=>new YA(2,T);m9.s24be=(T)=>new YA(3,T);m9.s32be=(T)=>new YA(4,T);m9.s40be=(T)=>new YA(5,T);m9.s48be=(T)=>new YA(6,T);m9.ns64be=(T)=>new _$(T);m9.f32=(T)=>new x$(T);m9.f32be=(T)=>new h$(T);m9.f64=(T)=>new g$(T);m9.f64be=(T)=>new m$(T);m9.struct=(T,A,Q)=>new y$(T,A,Q);m9.bits=(T,A,Q)=>new PQ(T,A,Q);m9.seq=(T,A,Q)=>new v$(T,A,Q);m9.union=(T,A,Q)=>new XQ(T,A,Q);m9.unionLayoutDiscriminator=(T,A)=>new L2(T,A);m9.blob=(T,A)=>new l$(T,A);m9.cstr=(T)=>new u$(T);m9.utf8=(T,A)=>new d$(T,A);m9.constant=(T,A)=>new c$(T,A)});function O2(){if(!VQ){if(VQ=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues==="function"&&msCrypto.getRandomValues.bind(msCrypto),!VQ)throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported")}return VQ(PN)}var VQ,PN;var TW=w0(()=>{PN=new Uint8Array(16)});var JX;var $X=w0(()=>{JX=/^(?:[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 qN(T){return typeof T==="string"&&JX.test(T)}var h8;var B2=w0(()=>{$X();h8=qN});function KN(T){var A=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,Q=(L0[T[A+0]]+L0[T[A+1]]+L0[T[A+2]]+L0[T[A+3]]+"-"+L0[T[A+4]]+L0[T[A+5]]+"-"+L0[T[A+6]]+L0[T[A+7]]+"-"+L0[T[A+8]]+L0[T[A+9]]+"-"+L0[T[A+10]]+L0[T[A+11]]+L0[T[A+12]]+L0[T[A+13]]+L0[T[A+14]]+L0[T[A+15]]).toLowerCase();if(!h8(Q))throw TypeError("Stringified UUID is invalid");return Q}var L0,_2,g8;var x2=w0(()=>{B2();L0=[];for(_2=0;_2<256;++_2)L0.push((_2+256).toString(16).substr(1));g8=KN});function CN(T,A,Q){var J=A&&Q||0,$=A||Array(16);T=T||{};var W=T.node||WX,G=T.clockseq!==void 0?T.clockseq:AW;if(W==null||G==null){var Y=T.random||(T.rng||O2)();if(W==null)W=WX=[Y[0]|1,Y[1],Y[2],Y[3],Y[4],Y[5]];if(G==null)G=AW=(Y[6]<<8|Y[7])&16383}var Z=T.msecs!==void 0?T.msecs:Date.now(),C=T.nsecs!==void 0?T.nsecs:JW+1,K=Z-QW+(C-JW)/1e4;if(K<0&&T.clockseq===void 0)G=G+1&16383;if((K<0||Z>QW)&&T.nsecs===void 0)C=0;if(C>=1e4)throw Error("uuid.v1(): Can't create more than 10M uuids/sec");QW=Z,JW=C,AW=G,Z+=12219292800000;var j=((Z&268435455)*1e4+C)%4294967296;$[J++]=j>>>24&255,$[J++]=j>>>16&255,$[J++]=j>>>8&255,$[J++]=j&255;var M=Z/4294967296*1e4&268435455;$[J++]=M>>>8&255,$[J++]=M&255,$[J++]=M>>>24&15|16,$[J++]=M>>>16&255,$[J++]=G>>>8|128,$[J++]=G&255;for(var z=0;z<6;++z)$[J+z]=W[z];return A||g8($)}var WX,AW,QW=0,JW=0,GX;var UX=w0(()=>{TW();x2();GX=CN});function HN(T){if(!h8(T))throw TypeError("Invalid UUID");var A,Q=new Uint8Array(16);return Q[0]=(A=parseInt(T.slice(0,8),16))>>>24,Q[1]=A>>>16&255,Q[2]=A>>>8&255,Q[3]=A&255,Q[4]=(A=parseInt(T.slice(9,13),16))>>>8,Q[5]=A&255,Q[6]=(A=parseInt(T.slice(14,18),16))>>>8,Q[7]=A&255,Q[8]=(A=parseInt(T.slice(19,23),16))>>>8,Q[9]=A&255,Q[10]=(A=parseInt(T.slice(24,36),16))/1099511627776&255,Q[11]=A/4294967296&255,Q[12]=A>>>24&255,Q[13]=A>>>16&255,Q[14]=A>>>8&255,Q[15]=A&255,Q}var jQ;var $W=w0(()=>{B2();jQ=HN});function VN(T){T=unescape(encodeURIComponent(T));var A=[];for(var Q=0;Q<T.length;++Q)A.push(T.charCodeAt(Q));return A}function h2(T,A,Q){function J($,W,G,Y){if(typeof $==="string")$=VN($);if(typeof W==="string")W=jQ(W);if(W.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var Z=new Uint8Array(16+$.length);if(Z.set(W),Z.set($,W.length),Z=Q(Z),Z[6]=Z[6]&15|A,Z[8]=Z[8]&63|128,G){Y=Y||0;for(var C=0;C<16;++C)G[Y+C]=Z[C];return G}return g8(Z)}try{J.name=T}catch($){}return J.DNS=jN,J.URL=RN,J}var jN="6ba7b810-9dad-11d1-80b4-00c04fd430c8",RN="6ba7b811-9dad-11d1-80b4-00c04fd430c8";var WW=w0(()=>{x2();$W()});function DN(T){if(typeof T==="string"){var A=unescape(encodeURIComponent(T));T=new Uint8Array(A.length);for(var Q=0;Q<A.length;++Q)T[Q]=A.charCodeAt(Q)}return MN(kN(zN(T),T.length*8))}function MN(T){var A=[],Q=T.length*32,J="0123456789abcdef";for(var $=0;$<Q;$+=8){var W=T[$>>5]>>>$%32&255,G=parseInt(J.charAt(W>>>4&15)+J.charAt(W&15),16);A.push(G)}return A}function YX(T){return(T+64>>>9<<4)+14+1}function kN(T,A){T[A>>5]|=128<<A%32,T[YX(A)-1]=A;var Q=1732584193,J=-271733879,$=-1732584194,W=271733878;for(var G=0;G<T.length;G+=16){var Y=Q,Z=J,C=$,K=W;Q=x0(Q,J,$,W,T[G],7,-680876936),W=x0(W,Q,J,$,T[G+1],12,-389564586),$=x0($,W,Q,J,T[G+2],17,606105819),J=x0(J,$,W,Q,T[G+3],22,-1044525330),Q=x0(Q,J,$,W,T[G+4],7,-176418897),W=x0(W,Q,J,$,T[G+5],12,1200080426),$=x0($,W,Q,J,T[G+6],17,-1473231341),J=x0(J,$,W,Q,T[G+7],22,-45705983),Q=x0(Q,J,$,W,T[G+8],7,1770035416),W=x0(W,Q,J,$,T[G+9],12,-1958414417),$=x0($,W,Q,J,T[G+10],17,-42063),J=x0(J,$,W,Q,T[G+11],22,-1990404162),Q=x0(Q,J,$,W,T[G+12],7,1804603682),W=x0(W,Q,J,$,T[G+13],12,-40341101),$=x0($,W,Q,J,T[G+14],17,-1502002290),J=x0(J,$,W,Q,T[G+15],22,1236535329),Q=h0(Q,J,$,W,T[G+1],5,-165796510),W=h0(W,Q,J,$,T[G+6],9,-1069501632),$=h0($,W,Q,J,T[G+11],14,643717713),J=h0(J,$,W,Q,T[G],20,-373897302),Q=h0(Q,J,$,W,T[G+5],5,-701558691),W=h0(W,Q,J,$,T[G+10],9,38016083),$=h0($,W,Q,J,T[G+15],14,-660478335),J=h0(J,$,W,Q,T[G+4],20,-405537848),Q=h0(Q,J,$,W,T[G+9],5,568446438),W=h0(W,Q,J,$,T[G+14],9,-1019803690),$=h0($,W,Q,J,T[G+3],14,-187363961),J=h0(J,$,W,Q,T[G+8],20,1163531501),Q=h0(Q,J,$,W,T[G+13],5,-1444681467),W=h0(W,Q,J,$,T[G+2],9,-51403784),$=h0($,W,Q,J,T[G+7],14,1735328473),J=h0(J,$,W,Q,T[G+12],20,-1926607734),Q=g0(Q,J,$,W,T[G+5],4,-378558),W=g0(W,Q,J,$,T[G+8],11,-2022574463),$=g0($,W,Q,J,T[G+11],16,1839030562),J=g0(J,$,W,Q,T[G+14],23,-35309556),Q=g0(Q,J,$,W,T[G+1],4,-1530992060),W=g0(W,Q,J,$,T[G+4],11,1272893353),$=g0($,W,Q,J,T[G+7],16,-155497632),J=g0(J,$,W,Q,T[G+10],23,-1094730640),Q=g0(Q,J,$,W,T[G+13],4,681279174),W=g0(W,Q,J,$,T[G],11,-358537222),$=g0($,W,Q,J,T[G+3],16,-722521979),J=g0(J,$,W,Q,T[G+6],23,76029189),Q=g0(Q,J,$,W,T[G+9],4,-640364487),W=g0(W,Q,J,$,T[G+12],11,-421815835),$=g0($,W,Q,J,T[G+15],16,530742520),J=g0(J,$,W,Q,T[G+2],23,-995338651),Q=m0(Q,J,$,W,T[G],6,-198630844),W=m0(W,Q,J,$,T[G+7],10,1126891415),$=m0($,W,Q,J,T[G+14],15,-1416354905),J=m0(J,$,W,Q,T[G+5],21,-57434055),Q=m0(Q,J,$,W,T[G+12],6,1700485571),W=m0(W,Q,J,$,T[G+3],10,-1894986606),$=m0($,W,Q,J,T[G+10],15,-1051523),J=m0(J,$,W,Q,T[G+1],21,-2054922799),Q=m0(Q,J,$,W,T[G+8],6,1873313359),W=m0(W,Q,J,$,T[G+15],10,-30611744),$=m0($,W,Q,J,T[G+6],15,-1560198380),J=m0(J,$,W,Q,T[G+13],21,1309151649),Q=m0(Q,J,$,W,T[G+4],6,-145523070),W=m0(W,Q,J,$,T[G+11],10,-1120210379),$=m0($,W,Q,J,T[G+2],15,718787259),J=m0(J,$,W,Q,T[G+9],21,-343485551),Q=m8(Q,Y),J=m8(J,Z),$=m8($,C),W=m8(W,K)}return[Q,J,$,W]}function zN(T){if(T.length===0)return[];var A=T.length*8,Q=new Uint32Array(YX(A));for(var J=0;J<A;J+=8)Q[J>>5]|=(T[J/8]&255)<<J%32;return Q}function m8(T,A){var Q=(T&65535)+(A&65535),J=(T>>16)+(A>>16)+(Q>>16);return J<<16|Q&65535}function FN(T,A){return T<<A|T>>>32-A}function RQ(T,A,Q,J,$,W){return m8(FN(m8(m8(A,T),m8(J,W)),$),Q)}function x0(T,A,Q,J,$,W,G){return RQ(A&Q|~A&J,T,A,$,W,G)}function h0(T,A,Q,J,$,W,G){return RQ(A&J|Q&~J,T,A,$,W,G)}function g0(T,A,Q,J,$,W,G){return RQ(A^Q^J,T,A,$,W,G)}function m0(T,A,Q,J,$,W,G){return RQ(Q^(A|~J),T,A,$,W,G)}var ZX;var XX=w0(()=>{ZX=DN});var NN,PX;var qX=w0(()=>{WW();XX();NN=h2("v3",48,ZX),PX=NN});function IN(T,A,Q){T=T||{};var J=T.random||(T.rng||O2)();if(J[6]=J[6]&15|64,J[8]=J[8]&63|128,A){Q=Q||0;for(var $=0;$<16;++$)A[Q+$]=J[$];return A}return g8(J)}var KX;var CX=w0(()=>{TW();x2();KX=IN});function SN(T,A,Q,J){switch(T){case 0:return A&Q^~A&J;case 1:return A^Q^J;case 2:return A&Q^A&J^Q&J;case 3:return A^Q^J}}function GW(T,A){return T<<A|T>>>32-A}function LN(T){var A=[1518500249,1859775393,2400959708,3395469782],Q=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof T==="string"){var J=unescape(encodeURIComponent(T));T=[];for(var $=0;$<J.length;++$)T.push(J.charCodeAt($))}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),Y=Array(G);for(var Z=0;Z<G;++Z){var C=new Uint32Array(16);for(var K=0;K<16;++K)C[K]=T[Z*64+K*4]<<24|T[Z*64+K*4+1]<<16|T[Z*64+K*4+2]<<8|T[Z*64+K*4+3];Y[Z]=C}Y[G-1][14]=(T.length-1)*8/Math.pow(2,32),Y[G-1][14]=Math.floor(Y[G-1][14]),Y[G-1][15]=(T.length-1)*8&4294967295;for(var j=0;j<G;++j){var M=new Uint32Array(80);for(var z=0;z<16;++z)M[z]=Y[j][z];for(var N=16;N<80;++N)M[N]=GW(M[N-3]^M[N-8]^M[N-14]^M[N-16],1);var E=Q[0],L=Q[1],O=Q[2],g=Q[3],v=Q[4];for(var p=0;p<80;++p){var c=Math.floor(p/20),u=GW(E,5)+SN(c,L,O,g)+v+A[c]+M[p]>>>0;v=g,g=O,O=GW(L,30)>>>0,L=E,E=u}Q[0]=Q[0]+E>>>0,Q[1]=Q[1]+L>>>0,Q[2]=Q[2]+O>>>0,Q[3]=Q[3]+g>>>0,Q[4]=Q[4]+v>>>0}return[Q[0]>>24&255,Q[0]>>16&255,Q[0]>>8&255,Q[0]&255,Q[1]>>24&255,Q[1]>>16&255,Q[1]>>8&255,Q[1]&255,Q[2]>>24&255,Q[2]>>16&255,Q[2]>>8&255,Q[2]&255,Q[3]>>24&255,Q[3]>>16&255,Q[3]>>8&255,Q[3]&255,Q[4]>>24&255,Q[4]>>16&255,Q[4]>>8&255,Q[4]&255]}var HX;var VX=w0(()=>{HX=LN});var wN,jX;var RX=w0(()=>{WW();VX();wN=h2("v5",80,HX),jX=wN});var DX="00000000-0000-0000-0000-000000000000";function ON(T){if(!h8(T))throw TypeError("Invalid UUID");return parseInt(T.substr(14,1),16)}var MX;var kX=w0(()=>{B2();MX=ON});var UW={};P4(UW,{version:()=>MX,validate:()=>h8,v5:()=>jX,v4:()=>KX,v3:()=>PX,v1:()=>GX,stringify:()=>g8,parse:()=>jQ,NIL:()=>DX});var YW=w0(()=>{UX();qX();CX();RX();kX();B2();x2();$W()});var FX=ZT((Wh,zX)=>{var BN=(YW(),VA(UW)).v4,_N=function(T,A,Q,J){if(typeof T!=="string")throw TypeError(T+" must be a string");J=J||{};let $=typeof J.version==="number"?J.version:2;if($!==1&&$!==2)throw TypeError($+" must be 1 or 2");let W={method:T};if($===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 Q>"u"){let G=typeof J.generator==="function"?J.generator:function(){return BN()};W.id=G(W,J)}else if($===2&&Q===null){if(J.notificationIdNull)W.id=null}else W.id=Q;return W};zX.exports=_N});var IX=ZT((Gh,NX)=>{var xN=(YW(),VA(UW)).v4,hN=FX(),g2=function(T,A){if(!(this instanceof g2))return new g2(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 xN()},version:typeof A.version<"u"?A.version:2,notificationIdNull:typeof A.notificationIdNull==="boolean"?A.notificationIdNull:!1},this.callServer=T};NX.exports=g2;g2.prototype.request=function(T,A,Q,J){let $=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")J=A,W=T;else{if(typeof Q==="function")J=Q,Q=void 0;let C=typeof J==="function";try{W=hN(T,A,Q,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(K){if(C)return J(K);throw K}if(!C)return W}let Z;try{Z=JSON.stringify(W,this.options.replacer)}catch(C){return J(C)}return this.callServer(Z,function(C,K){$._parseResponse(C,K,J)}),W};g2.prototype._parseResponse=function(T,A,Q){if(T){Q(T);return}if(!A)return Q();let J;try{J=JSON.parse(A,this.options.reviver)}catch($){return Q($)}if(Q.length===3)if(Array.isArray(J)){let $=function(G){return typeof G.error<"u"},W=function(G){return!$(G)};return Q(null,J.filter($),J.filter(W))}else return Q(null,J.error,J.result);Q(null,J)}});var LX=ZT((Uh,ZW)=>{var gN=Object.prototype.hasOwnProperty,f0="~";function m2(){}if(Object.create){if(m2.prototype=Object.create(null),!new m2().__proto__)f0=!1}function mN(T,A,Q){this.fn=T,this.context=A,this.once=Q||!1}function SX(T,A,Q,J,$){if(typeof Q!=="function")throw TypeError("The listener must be a function");var W=new mN(Q,J||T,$),G=f0?f0+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 DQ(T,A){if(--T._eventsCount===0)T._events=new m2;else delete T._events[A]}function v0(){this._events=new m2,this._eventsCount=0}v0.prototype.eventNames=function(){var A=[],Q,J;if(this._eventsCount===0)return A;for(J in Q=this._events)if(gN.call(Q,J))A.push(f0?J.slice(1):J);if(Object.getOwnPropertySymbols)return A.concat(Object.getOwnPropertySymbols(Q));return A};v0.prototype.listeners=function(A){var Q=f0?f0+A:A,J=this._events[Q];if(!J)return[];if(J.fn)return[J.fn];for(var $=0,W=J.length,G=Array(W);$<W;$++)G[$]=J[$].fn;return G};v0.prototype.listenerCount=function(A){var Q=f0?f0+A:A,J=this._events[Q];if(!J)return 0;if(J.fn)return 1;return J.length};v0.prototype.emit=function(A,Q,J,$,W,G){var Y=f0?f0+A:A;if(!this._events[Y])return!1;var Z=this._events[Y],C=arguments.length,K,j;if(Z.fn){if(Z.once)this.removeListener(A,Z.fn,void 0,!0);switch(C){case 1:return Z.fn.call(Z.context),!0;case 2:return Z.fn.call(Z.context,Q),!0;case 3:return Z.fn.call(Z.context,Q,J),!0;case 4:return Z.fn.call(Z.context,Q,J,$),!0;case 5:return Z.fn.call(Z.context,Q,J,$,W),!0;case 6:return Z.fn.call(Z.context,Q,J,$,W,G),!0}for(j=1,K=Array(C-1);j<C;j++)K[j-1]=arguments[j];Z.fn.apply(Z.context,K)}else{var M=Z.length,z;for(j=0;j<M;j++){if(Z[j].once)this.removeListener(A,Z[j].fn,void 0,!0);switch(C){case 1:Z[j].fn.call(Z[j].context);break;case 2:Z[j].fn.call(Z[j].context,Q);break;case 3:Z[j].fn.call(Z[j].context,Q,J);break;case 4:Z[j].fn.call(Z[j].context,Q,J,$);break;default:if(!K)for(z=1,K=Array(C-1);z<C;z++)K[z-1]=arguments[z];Z[j].fn.apply(Z[j].context,K)}}}return!0};v0.prototype.on=function(A,Q,J){return SX(this,A,Q,J,!1)};v0.prototype.once=function(A,Q,J){return SX(this,A,Q,J,!0)};v0.prototype.removeListener=function(A,Q,J,$){var W=f0?f0+A:A;if(!this._events[W])return this;if(!Q)return DQ(this,W),this;var G=this._events[W];if(G.fn){if(G.fn===Q&&(!$||G.once)&&(!J||G.context===J))DQ(this,W)}else{for(var Y=0,Z=[],C=G.length;Y<C;Y++)if(G[Y].fn!==Q||$&&!G[Y].once||J&&G[Y].context!==J)Z.push(G[Y]);if(Z.length)this._events[W]=Z.length===1?Z[0]:Z;else DQ(this,W)}return this};v0.prototype.removeAllListeners=function(A){var Q;if(A){if(Q=f0?f0+A:A,this._events[Q])DQ(this,Q)}else this._events=new m2,this._eventsCount=0;return this};v0.prototype.off=v0.prototype.removeListener;v0.prototype.addListener=v0.prototype.on;v0.prefixed=f0;v0.EventEmitter=v0;if(typeof ZW<"u")ZW.exports=v0});var SP=ZT((IP)=>{Object.defineProperty(IP,"__esModule",{value:!0});var _Q;function nI(T){{let A=Buffer.from(T);A.reverse();let Q=A.toString("hex");if(Q.length===0)return BigInt(0);return BigInt(`0x${Q}`)}return _Q.toBigInt(T,!1)}IP.toBigIntLE=nI;function iI(T){{let A=T.toString("hex");if(A.length===0)return BigInt(0);return BigInt(`0x${A}`)}return _Q.toBigInt(T,!0)}IP.toBigIntBE=iI;function oI(T,A){{let Q=T.toString(16),J=Buffer.from(Q.padStart(A*2,"0").slice(0,A*2),"hex");return J.reverse(),J}return _Q.fromBigInt(T,Buffer.allocUnsafe(A),!1)}IP.toBufferLE=oI;function aI(T,A){{let Q=T.toString(16);return Buffer.from(Q.padStart(A*2,"0").slice(0,A*2),"hex")}return _Q.fromBigInt(T,Buffer.allocUnsafe(A),!0)}IP.toBufferBE=aI});/*!
1
+ var DZ=Object.create;var{getPrototypeOf:zZ,defineProperty:Q2,getOwnPropertyNames:KG,getOwnPropertyDescriptor:SZ}=Object,kG=Object.prototype.hasOwnProperty;var nT=(T,A,C)=>{C=T!=null?DZ(zZ(T)):{};let P=A||!T||!T.__esModule?Q2(C,"default",{value:T,enumerable:!0}):C;for(let Q of KG(T))if(!kG.call(P,Q))Q2(P,Q,{get:()=>T[Q],enumerable:!0});return P},HG=new WeakMap,R8=(T)=>{var A=HG.get(T),C;if(A)return A;if(A=Q2({},"__esModule",{value:!0}),T&&typeof T==="object"||typeof T==="function")KG(T).map((P)=>!kG.call(A,P)&&Q2(A,P,{get:()=>T[P],enumerable:!(C=SZ(T,P))||C.enumerable}));return HG.set(T,A),A},V0=(T,A)=>()=>(A||T((A={exports:{}}).exports,A),A.exports);var k4=(T,A)=>{for(var C in A)Q2(T,C,{get:A[C],enumerable:!0,configurable:!0,set:(P)=>A[C]=()=>P})};var _T=(T,A)=>()=>(T&&(A=T(T=0)),A);var RG=V0((OZ)=>{OZ.byteLength=IZ;OZ.toByteArray=LZ;OZ.fromByteArray=BZ;var N0=[],Y0=[],MZ=typeof Uint8Array<"u"?Uint8Array:Array,j4="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(XA=0,R4=j4.length;XA<R4;++XA)N0[XA]=j4[XA],Y0[j4.charCodeAt(XA)]=XA;var XA,R4;Y0[45]=62;Y0[95]=63;function jG(T){var A=T.length;if(A%4>0)throw Error("Invalid string. Length must be a multiple of 4");var C=T.indexOf("=");if(C===-1)C=A;var P=C===A?0:4-C%4;return[C,P]}function IZ(T){var A=jG(T),C=A[0],P=A[1];return(C+P)*3/4-P}function NZ(T,A,C){return(A+C)*3/4-C}function LZ(T){var A,C=jG(T),P=C[0],Q=C[1],W=new MZ(NZ(T,P,Q)),G=0,U=Q>0?P-4:P,$;for($=0;$<U;$+=4)A=Y0[T.charCodeAt($)]<<18|Y0[T.charCodeAt($+1)]<<12|Y0[T.charCodeAt($+2)]<<6|Y0[T.charCodeAt($+3)],W[G++]=A>>16&255,W[G++]=A>>8&255,W[G++]=A&255;if(Q===2)A=Y0[T.charCodeAt($)]<<2|Y0[T.charCodeAt($+1)]>>4,W[G++]=A&255;if(Q===1)A=Y0[T.charCodeAt($)]<<10|Y0[T.charCodeAt($+1)]<<4|Y0[T.charCodeAt($+2)]>>2,W[G++]=A>>8&255,W[G++]=A&255;return W}function wZ(T){return N0[T>>18&63]+N0[T>>12&63]+N0[T>>6&63]+N0[T&63]}function EZ(T,A,C){var P,Q=[];for(var W=A;W<C;W+=3)P=(T[W]<<16&16711680)+(T[W+1]<<8&65280)+(T[W+2]&255),Q.push(wZ(P));return Q.join("")}function BZ(T){var A,C=T.length,P=C%3,Q=[],W=16383;for(var G=0,U=C-P;G<U;G+=W)Q.push(EZ(T,G,G+W>U?U:G+W));if(P===1)A=T[C-1],Q.push(N0[A>>2]+N0[A<<4&63]+"==");else if(P===2)A=(T[C-2]<<8)+T[C-1],Q.push(N0[A>>10]+N0[A>>4&63]+N0[A<<2&63]+"=");return Q.join("")}});var FG=V0((mZ)=>{/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */mZ.read=function(T,A,C,P,Q){var W,G,U=Q*8-P-1,$=(1<<U)-1,X=$>>1,q=-7,K=C?Q-1:0,F=C?-1:1,z=T[A+K];K+=F,W=z&(1<<-q)-1,z>>=-q,q+=U;for(;q>0;W=W*256+T[A+K],K+=F,q-=8);G=W&(1<<-q)-1,W>>=-q,q+=P;for(;q>0;G=G*256+T[A+K],K+=F,q-=8);if(W===0)W=1-X;else if(W===$)return G?NaN:(z?-1:1)*(1/0);else G=G+Math.pow(2,P),W=W-X;return(z?-1:1)*G*Math.pow(2,W-P)};mZ.write=function(T,A,C,P,Q,W){var G,U,$,X=W*8-Q-1,q=(1<<X)-1,K=q>>1,F=Q===23?Math.pow(2,-24)-Math.pow(2,-77):0,z=P?0:W-1,M=P?1:-1,E=A<0||A===0&&1/A<0?1:0;if(A=Math.abs(A),isNaN(A)||A===1/0)U=isNaN(A)?1:0,G=q;else{if(G=Math.floor(Math.log(A)/Math.LN2),A*($=Math.pow(2,-G))<1)G--,$*=2;if(G+K>=1)A+=F/$;else A+=F*Math.pow(2,1-K);if(A*$>=2)G++,$/=2;if(G+K>=q)U=0,G=q;else if(G+K>=1)U=(A*$-1)*Math.pow(2,Q),G=G+K;else U=A*Math.pow(2,K-1)*Math.pow(2,Q),G=0}for(;Q>=8;T[C+z]=U&255,z+=M,U/=256,Q-=8);G=G<<Q|U,X+=Q;for(;X>0;T[C+z]=G&255,z+=M,G/=256,X-=8);T[C+z-M]|=E*128}});var i6={};k4(i6,{transcode:()=>OR,resolveObjectURL:()=>wR,kStringMaxLength:()=>S$,kMaxLength:()=>F2,isUtf8:()=>ER,isAscii:()=>BR,default:()=>_R,constants:()=>CR,btoa:()=>tj,atob:()=>ej,INSPECT_MAX_BYTES:()=>z$,File:()=>TR,Buffer:()=>w,Blob:()=>AR});function cj(T){var A=T.length;if(A%4>0)throw Error("Invalid string. Length must be a multiple of 4");var C=T.indexOf("=");if(C===-1)C=A;var P=C===A?0:4-C%4;return[C,P]}function oj(T,A){return(T+A)*3/4-A}function nj(T){var A,C=cj(T),P=C[0],Q=C[1],W=new Uint8Array(oj(P,Q)),G=0,U=Q>0?P-4:P,$;for($=0;$<U;$+=4)A=H0[T.charCodeAt($)]<<18|H0[T.charCodeAt($+1)]<<12|H0[T.charCodeAt($+2)]<<6|H0[T.charCodeAt($+3)],W[G++]=A>>16&255,W[G++]=A>>8&255,W[G++]=A&255;if(Q===2)A=H0[T.charCodeAt($)]<<2|H0[T.charCodeAt($+1)]>>4,W[G++]=A&255;if(Q===1)A=H0[T.charCodeAt($)]<<10|H0[T.charCodeAt($+1)]<<4|H0[T.charCodeAt($+2)]>>2,W[G++]=A>>8&255,W[G++]=A&255;return W}function aj(T){return g0[T>>18&63]+g0[T>>12&63]+g0[T>>6&63]+g0[T&63]}function sj(T,A,C){var P,Q=[];for(var W=A;W<C;W+=3)P=(T[W]<<16&16711680)+(T[W+1]<<8&65280)+(T[W+2]&255),Q.push(aj(P));return Q.join("")}function K$(T){var A,C=T.length,P=C%3,Q=[],W=16383;for(var G=0,U=C-P;G<U;G+=W)Q.push(sj(T,G,G+W>U?U:G+W));if(P===1)A=T[C-1],Q.push(g0[A>>2]+g0[A<<4&63]+"==");else if(P===2)A=(T[C-2]<<8)+T[C-1],Q.push(g0[A>>10]+g0[A>>4&63]+g0[A<<2&63]+"=");return Q.join("")}function r6(T,A,C,P,Q){var W,G,U=Q*8-P-1,$=(1<<U)-1,X=$>>1,q=-7,K=C?Q-1:0,F=C?-1:1,z=T[A+K];K+=F,W=z&(1<<-q)-1,z>>=-q,q+=U;for(;q>0;W=W*256+T[A+K],K+=F,q-=8);G=W&(1<<-q)-1,W>>=-q,q+=P;for(;q>0;G=G*256+T[A+K],K+=F,q-=8);if(W===0)W=1-X;else if(W===$)return G?NaN:(z?-1:1)*(1/0);else G=G+Math.pow(2,P),W=W-X;return(z?-1:1)*G*Math.pow(2,W-P)}function D$(T,A,C,P,Q,W){var G,U,$,X=W*8-Q-1,q=(1<<X)-1,K=q>>1,F=Q===23?Math.pow(2,-24)-Math.pow(2,-77):0,z=P?0:W-1,M=P?1:-1,E=A<0||A===0&&1/A<0?1:0;if(A=Math.abs(A),isNaN(A)||A===1/0)U=isNaN(A)?1:0,G=q;else{if(G=Math.floor(Math.log(A)/Math.LN2),A*($=Math.pow(2,-G))<1)G--,$*=2;if(G+K>=1)A+=F/$;else A+=F*Math.pow(2,1-K);if(A*$>=2)G++,$/=2;if(G+K>=q)U=0,G=q;else if(G+K>=1)U=(A*$-1)*Math.pow(2,Q),G=G+K;else U=A*Math.pow(2,K-1)*Math.pow(2,Q),G=0}for(;Q>=8;T[C+z]=U&255,z+=M,U/=256,Q-=8);G=G<<Q|U,X+=Q;for(;X>0;T[C+z]=G&255,z+=M,G/=256,X-=8);T[C+z-M]|=E*128}function s0(T){if(T>F2)throw RangeError('The value "'+T+'" is invalid for option "size"');let A=new Uint8Array(T);return Object.setPrototypeOf(A,w.prototype),A}function rP(T,A,C){return class extends C{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(P){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:P,writable:!0})}toString(){return`${this.name} [${T}]: ${this.message}`}}}function w(T,A,C){if(typeof T==="number"){if(typeof A==="string")throw TypeError('The "string" argument must be of type string. Received type number');return fP(T)}return M$(T,A,C)}function M$(T,A,C){if(typeof T==="string")return GR(T,A);if(ArrayBuffer.isView(T))return JR(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(v0(T,ArrayBuffer)||T&&v0(T.buffer,ArrayBuffer))return uP(T,A,C);if(typeof SharedArrayBuffer<"u"&&(v0(T,SharedArrayBuffer)||T&&v0(T.buffer,SharedArrayBuffer)))return uP(T,A,C);if(typeof T==="number")throw TypeError('The "value" argument must not be of type number. Received type number');let P=T.valueOf&&T.valueOf();if(P!=null&&P!==T)return w.from(P,A,C);let Q=UR(T);if(Q)return Q;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof T[Symbol.toPrimitive]==="function")return w.from(T[Symbol.toPrimitive]("string"),A,C);throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof T)}function I$(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 WR(T,A,C){if(I$(T),T<=0)return s0(T);if(A!==void 0)return typeof C==="string"?s0(T).fill(A,C):s0(T).fill(A);return s0(T)}function fP(T){return I$(T),s0(T<0?0:iP(T)|0)}function GR(T,A){if(typeof A!=="string"||A==="")A="utf8";if(!w.isEncoding(A))throw TypeError("Unknown encoding: "+A);let C=N$(T,A)|0,P=s0(C),Q=P.write(T,A);if(Q!==C)P=P.slice(0,Q);return P}function pP(T){let A=T.length<0?0:iP(T.length)|0,C=s0(A);for(let P=0;P<A;P+=1)C[P]=T[P]&255;return C}function JR(T){if(v0(T,Uint8Array)){let A=new Uint8Array(T);return uP(A.buffer,A.byteOffset,A.byteLength)}return pP(T)}function uP(T,A,C){if(A<0||T.byteLength<A)throw RangeError('"offset" is outside of buffer bounds');if(T.byteLength<A+(C||0))throw RangeError('"length" is outside of buffer bounds');let P;if(A===void 0&&C===void 0)P=new Uint8Array(T);else if(C===void 0)P=new Uint8Array(T,A);else P=new Uint8Array(T,A,C);return Object.setPrototypeOf(P,w.prototype),P}function UR(T){if(w.isBuffer(T)){let A=iP(T.length)|0,C=s0(A);if(C.length===0)return C;return T.copy(C,0,0,A),C}if(T.length!==void 0){if(typeof T.length!=="number"||Number.isNaN(T.length))return s0(0);return pP(T)}if(T.type==="Buffer"&&Array.isArray(T.data))return pP(T.data)}function iP(T){if(T>=F2)throw RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+F2.toString(16)+" bytes");return T|0}function N$(T,A){if(w.isBuffer(T))return T.length;if(ArrayBuffer.isView(T)||v0(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 C=T.length,P=arguments.length>2&&arguments[2]===!0;if(!P&&C===0)return 0;let Q=!1;for(;;)switch(A){case"ascii":case"latin1":case"binary":return C;case"utf8":case"utf-8":return dP(T).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C*2;case"hex":return C>>>1;case"base64":return m$(T).length;default:if(Q)return P?-1:dP(T).length;A=(""+A).toLowerCase(),Q=!0}}function $R(T,A,C){let P=!1;if(A===void 0||A<0)A=0;if(A>this.length)return"";if(C===void 0||C>this.length)C=this.length;if(C<=0)return"";if(C>>>=0,A>>>=0,C<=A)return"";if(!T)T="utf8";while(!0)switch(T){case"hex":return RR(this,A,C);case"utf8":case"utf-8":return w$(this,A,C);case"ascii":return kR(this,A,C);case"latin1":case"binary":return jR(this,A,C);case"base64":return HR(this,A,C);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return FR(this,A,C);default:if(P)throw TypeError("Unknown encoding: "+T);T=(T+"").toLowerCase(),P=!0}}function eA(T,A,C){let P=T[A];T[A]=T[C],T[C]=P}function L$(T,A,C,P,Q){if(T.length===0)return-1;if(typeof C==="string")P=C,C=0;else if(C>2147483647)C=2147483647;else if(C<-2147483648)C=-2147483648;if(C=+C,Number.isNaN(C))C=Q?0:T.length-1;if(C<0)C=T.length+C;if(C>=T.length)if(Q)return-1;else C=T.length-1;else if(C<0)if(Q)C=0;else return-1;if(typeof A==="string")A=w.from(A,P);if(w.isBuffer(A)){if(A.length===0)return-1;return j$(T,A,C,P,Q)}else if(typeof A==="number"){if(A=A&255,typeof Uint8Array.prototype.indexOf==="function")if(Q)return Uint8Array.prototype.indexOf.call(T,A,C);else return Uint8Array.prototype.lastIndexOf.call(T,A,C);return j$(T,[A],C,P,Q)}throw TypeError("val must be string, number or Buffer")}function j$(T,A,C,P,Q){let W=1,G=T.length,U=A.length;if(P!==void 0){if(P=String(P).toLowerCase(),P==="ucs2"||P==="ucs-2"||P==="utf16le"||P==="utf-16le"){if(T.length<2||A.length<2)return-1;W=2,G/=2,U/=2,C/=2}}function $(q,K){if(W===1)return q[K];else return q.readUInt16BE(K*W)}let X;if(Q){let q=-1;for(X=C;X<G;X++)if($(T,X)===$(A,q===-1?0:X-q)){if(q===-1)q=X;if(X-q+1===U)return q*W}else{if(q!==-1)X-=X-q;q=-1}}else{if(C+U>G)C=G-U;for(X=C;X>=0;X--){let q=!0;for(let K=0;K<U;K++)if($(T,X+K)!==$(A,K)){q=!1;break}if(q)return X}}return-1}function VR(T,A,C,P){C=Number(C)||0;let Q=T.length-C;if(!P)P=Q;else if(P=Number(P),P>Q)P=Q;let W=A.length;if(P>W/2)P=W/2;let G;for(G=0;G<P;++G){let U=parseInt(A.substr(G*2,2),16);if(Number.isNaN(U))return G;T[C+G]=U}return G}function YR(T,A,C,P){return f6(dP(A,T.length-C),T,C,P)}function ZR(T,A,C,P){return f6(MR(A),T,C,P)}function qR(T,A,C,P){return f6(m$(A),T,C,P)}function XR(T,A,C,P){return f6(IR(A,T.length-C),T,C,P)}function HR(T,A,C){if(A===0&&C===T.length)return K$(T);else return K$(T.slice(A,C))}function w$(T,A,C){C=Math.min(T.length,C);let P=[],Q=A;while(Q<C){let W=T[Q],G=null,U=W>239?4:W>223?3:W>191?2:1;if(Q+U<=C){let $,X,q,K;switch(U){case 1:if(W<128)G=W;break;case 2:if($=T[Q+1],($&192)===128){if(K=(W&31)<<6|$&63,K>127)G=K}break;case 3:if($=T[Q+1],X=T[Q+2],($&192)===128&&(X&192)===128){if(K=(W&15)<<12|($&63)<<6|X&63,K>2047&&(K<55296||K>57343))G=K}break;case 4:if($=T[Q+1],X=T[Q+2],q=T[Q+3],($&192)===128&&(X&192)===128&&(q&192)===128){if(K=(W&15)<<18|($&63)<<12|(X&63)<<6|q&63,K>65535&&K<1114112)G=K}}}if(G===null)G=65533,U=1;else if(G>65535)G-=65536,P.push(G>>>10&1023|55296),G=56320|G&1023;P.push(G),Q+=U}return KR(P)}function KR(T){let A=T.length;if(A<=R$)return String.fromCharCode.apply(String,T);let C="",P=0;while(P<A)C+=String.fromCharCode.apply(String,T.slice(P,P+=R$));return C}function kR(T,A,C){let P="";C=Math.min(T.length,C);for(let Q=A;Q<C;++Q)P+=String.fromCharCode(T[Q]&127);return P}function jR(T,A,C){let P="";C=Math.min(T.length,C);for(let Q=A;Q<C;++Q)P+=String.fromCharCode(T[Q]);return P}function RR(T,A,C){let P=T.length;if(!A||A<0)A=0;if(!C||C<0||C>P)C=P;let Q="";for(let W=A;W<C;++W)Q+=NR[T[W]];return Q}function FR(T,A,C){let P=T.slice(A,C),Q="";for(let W=0;W<P.length-1;W+=2)Q+=String.fromCharCode(P[W]+P[W+1]*256);return Q}function IT(T,A,C){if(T%1!==0||T<0)throw RangeError("offset is not uint");if(T+A>C)throw RangeError("Trying to access beyond buffer length")}function eT(T,A,C,P,Q,W){if(!w.isBuffer(T))throw TypeError('"buffer" argument must be a Buffer instance');if(A>Q||A<W)throw RangeError('"value" argument is out of bounds');if(C+P>T.length)throw RangeError("Index out of range")}function E$(T,A,C,P,Q){h$(A,P,Q,T,C,7);let W=Number(A&BigInt(4294967295));T[C++]=W,W=W>>8,T[C++]=W,W=W>>8,T[C++]=W,W=W>>8,T[C++]=W;let G=Number(A>>BigInt(32)&BigInt(4294967295));return T[C++]=G,G=G>>8,T[C++]=G,G=G>>8,T[C++]=G,G=G>>8,T[C++]=G,C}function B$(T,A,C,P,Q){h$(A,P,Q,T,C,7);let W=Number(A&BigInt(4294967295));T[C+7]=W,W=W>>8,T[C+6]=W,W=W>>8,T[C+5]=W,W=W>>8,T[C+4]=W;let G=Number(A>>BigInt(32)&BigInt(4294967295));return T[C+3]=G,G=G>>8,T[C+2]=G,G=G>>8,T[C+1]=G,G=G>>8,T[C]=G,C+8}function O$(T,A,C,P,Q,W){if(C+P>T.length)throw RangeError("Index out of range");if(C<0)throw RangeError("Index out of range")}function _$(T,A,C,P,Q){if(A=+A,C=C>>>0,!Q)O$(T,A,C,4,340282346638528860000000000000000000000,-340282346638528860000000000000000000000);return D$(T,A,C,P,23,4),C+4}function x$(T,A,C,P,Q){if(A=+A,C=C>>>0,!Q)O$(T,A,C,8,179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,-179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000);return D$(T,A,C,P,52,8),C+8}function F$(T){let A="",C=T.length,P=T[0]==="-"?1:0;for(;C>=P+4;C-=3)A=`_${T.slice(C-3,C)}${A}`;return`${T.slice(0,C)}${A}`}function DR(T,A,C){if(_8(A,"offset"),T[A]===void 0||T[A+C]===void 0)D2(A,T.length-(C+1))}function h$(T,A,C,P,Q,W){if(T>C||T<A){let G=typeof A==="bigint"?"n":"",U;if(W>3)if(A===0||A===BigInt(0))U=`>= 0${G} and < 2${G} ** ${(W+1)*8}${G}`;else U=`>= -(2${G} ** ${(W+1)*8-1}${G}) and < 2 ** ${(W+1)*8-1}${G}`;else U=`>= ${A}${G} and <= ${C}${G}`;throw new lP("value",U,T)}DR(P,Q,W)}function _8(T,A){if(typeof T!=="number")throw new QR(A,"number",T)}function D2(T,A,C){if(Math.floor(T)!==T)throw _8(T,C),new lP(C||"offset","an integer",T);if(A<0)throw new PR;throw new lP(C||"offset",`>= ${C?1:0} and <= ${A}`,T)}function SR(T){if(T=T.split("=")[0],T=T.trim().replace(zR,""),T.length<2)return"";while(T.length%4!==0)T=T+"=";return T}function dP(T,A){A=A||1/0;let C,P=T.length,Q=null,W=[];for(let G=0;G<P;++G){if(C=T.charCodeAt(G),C>55295&&C<57344){if(!Q){if(C>56319){if((A-=3)>-1)W.push(239,191,189);continue}else if(G+1===P){if((A-=3)>-1)W.push(239,191,189);continue}Q=C;continue}if(C<56320){if((A-=3)>-1)W.push(239,191,189);Q=C;continue}C=(Q-55296<<10|C-56320)+65536}else if(Q){if((A-=3)>-1)W.push(239,191,189)}if(Q=null,C<128){if((A-=1)<0)break;W.push(C)}else if(C<2048){if((A-=2)<0)break;W.push(C>>6|192,C&63|128)}else if(C<65536){if((A-=3)<0)break;W.push(C>>12|224,C>>6&63|128,C&63|128)}else if(C<1114112){if((A-=4)<0)break;W.push(C>>18|240,C>>12&63|128,C>>6&63|128,C&63|128)}else throw Error("Invalid code point")}return W}function MR(T){let A=[];for(let C=0;C<T.length;++C)A.push(T.charCodeAt(C)&255);return A}function IR(T,A){let C,P,Q,W=[];for(let G=0;G<T.length;++G){if((A-=2)<0)break;C=T.charCodeAt(G),P=C>>8,Q=C%256,W.push(Q),W.push(P)}return W}function m$(T){return nj(SR(T))}function f6(T,A,C,P){let Q;for(Q=0;Q<P;++Q){if(Q+C>=A.length||Q>=T.length)break;A[Q+C]=T[Q]}return Q}function v0(T,A){return T instanceof A||T!=null&&T.constructor!=null&&T.constructor.name!=null&&T.constructor.name===A.name}function MA(T){return typeof BigInt>"u"?LR:T}function LR(){throw Error("BigInt not supported")}function cP(T){return()=>{throw Error(T+" is not implemented for node:buffer browser polyfill")}}var g0,H0,bP="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",tA,H$,k$,z$=50,F2=2147483647,S$=536870888,tj,ej,TR,AR,CR,PR,QR,lP,R$=4096,zR,NR,wR,ER,BR=(T)=>{for(let A of T)if(A.charCodeAt(0)>127)return!1;return!0},OR,_R;var x8=_T(()=>{g0=[],H0=[];for(tA=0,H$=bP.length;tA<H$;++tA)g0[tA]=bP[tA],H0[bP.charCodeAt(tA)]=tA;H0[45]=62;H0[95]=63;k$=typeof Symbol==="function"&&typeof Symbol.for==="function"?Symbol.for("nodejs.util.inspect.custom"):null,tj=globalThis.btoa,ej=globalThis.atob,TR=globalThis.File,AR=globalThis.Blob,CR={MAX_LENGTH:F2,MAX_STRING_LENGTH:S$};PR=rP("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),QR=rP("ERR_INVALID_ARG_TYPE",function(T,A){return`The "${T}" argument must be of type number. Received type ${typeof A}`},TypeError),lP=rP("ERR_OUT_OF_RANGE",function(T,A,C){let P=`The value of "${T}" is out of range.`,Q=C;if(Number.isInteger(C)&&Math.abs(C)>4294967296)Q=F$(String(C));else if(typeof C==="bigint"){if(Q=String(C),C>BigInt(2)**BigInt(32)||C<-(BigInt(2)**BigInt(32)))Q=F$(Q);Q+="n"}return P+=` It must be ${A}. Received ${Q}`,P},RangeError);Object.defineProperty(w.prototype,"parent",{enumerable:!0,get:function(){if(!w.isBuffer(this))return;return this.buffer}});Object.defineProperty(w.prototype,"offset",{enumerable:!0,get:function(){if(!w.isBuffer(this))return;return this.byteOffset}});w.poolSize=8192;w.from=function(T,A,C){return M$(T,A,C)};Object.setPrototypeOf(w.prototype,Uint8Array.prototype);Object.setPrototypeOf(w,Uint8Array);w.alloc=function(T,A,C){return WR(T,A,C)};w.allocUnsafe=function(T){return fP(T)};w.allocUnsafeSlow=function(T){return fP(T)};w.isBuffer=function(T){return T!=null&&T._isBuffer===!0&&T!==w.prototype};w.compare=function(T,A){if(v0(T,Uint8Array))T=w.from(T,T.offset,T.byteLength);if(v0(A,Uint8Array))A=w.from(A,A.offset,A.byteLength);if(!w.isBuffer(T)||!w.isBuffer(A))throw TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(T===A)return 0;let C=T.length,P=A.length;for(let Q=0,W=Math.min(C,P);Q<W;++Q)if(T[Q]!==A[Q]){C=T[Q],P=A[Q];break}if(C<P)return-1;if(P<C)return 1;return 0};w.isEncoding=function(T){switch(String(T).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}};w.concat=function(T,A){if(!Array.isArray(T))throw TypeError('"list" argument must be an Array of Buffers');if(T.length===0)return w.alloc(0);let C;if(A===void 0){A=0;for(C=0;C<T.length;++C)A+=T[C].length}let P=w.allocUnsafe(A),Q=0;for(C=0;C<T.length;++C){let W=T[C];if(v0(W,Uint8Array))if(Q+W.length>P.length){if(!w.isBuffer(W))W=w.from(W);W.copy(P,Q)}else Uint8Array.prototype.set.call(P,W,Q);else if(!w.isBuffer(W))throw TypeError('"list" argument must be an Array of Buffers');else W.copy(P,Q);Q+=W.length}return P};w.byteLength=N$;w.prototype._isBuffer=!0;w.prototype.swap16=function(){let T=this.length;if(T%2!==0)throw RangeError("Buffer size must be a multiple of 16-bits");for(let A=0;A<T;A+=2)eA(this,A,A+1);return this};w.prototype.swap32=function(){let T=this.length;if(T%4!==0)throw RangeError("Buffer size must be a multiple of 32-bits");for(let A=0;A<T;A+=4)eA(this,A,A+3),eA(this,A+1,A+2);return this};w.prototype.swap64=function(){let T=this.length;if(T%8!==0)throw RangeError("Buffer size must be a multiple of 64-bits");for(let A=0;A<T;A+=8)eA(this,A,A+7),eA(this,A+1,A+6),eA(this,A+2,A+5),eA(this,A+3,A+4);return this};w.prototype.toString=function(){let T=this.length;if(T===0)return"";if(arguments.length===0)return w$(this,0,T);return $R.apply(this,arguments)};w.prototype.toLocaleString=w.prototype.toString;w.prototype.equals=function(T){if(!w.isBuffer(T))throw TypeError("Argument must be a Buffer");if(this===T)return!0;return w.compare(this,T)===0};w.prototype.inspect=function(){let T="",A=z$;if(T=this.toString("hex",0,A).replace(/(.{2})/g,"$1 ").trim(),this.length>A)T+=" ... ";return"<Buffer "+T+">"};if(k$)w.prototype[k$]=w.prototype.inspect;w.prototype.compare=function(T,A,C,P,Q){if(v0(T,Uint8Array))T=w.from(T,T.offset,T.byteLength);if(!w.isBuffer(T))throw TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof T);if(A===void 0)A=0;if(C===void 0)C=T?T.length:0;if(P===void 0)P=0;if(Q===void 0)Q=this.length;if(A<0||C>T.length||P<0||Q>this.length)throw RangeError("out of range index");if(P>=Q&&A>=C)return 0;if(P>=Q)return-1;if(A>=C)return 1;if(A>>>=0,C>>>=0,P>>>=0,Q>>>=0,this===T)return 0;let W=Q-P,G=C-A,U=Math.min(W,G),$=this.slice(P,Q),X=T.slice(A,C);for(let q=0;q<U;++q)if($[q]!==X[q]){W=$[q],G=X[q];break}if(W<G)return-1;if(G<W)return 1;return 0};w.prototype.includes=function(T,A,C){return this.indexOf(T,A,C)!==-1};w.prototype.indexOf=function(T,A,C){return L$(this,T,A,C,!0)};w.prototype.lastIndexOf=function(T,A,C){return L$(this,T,A,C,!1)};w.prototype.write=function(T,A,C,P){if(A===void 0)P="utf8",C=this.length,A=0;else if(C===void 0&&typeof A==="string")P=A,C=this.length,A=0;else if(isFinite(A))if(A=A>>>0,isFinite(C)){if(C=C>>>0,P===void 0)P="utf8"}else P=C,C=void 0;else throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let Q=this.length-A;if(C===void 0||C>Q)C=Q;if(T.length>0&&(C<0||A<0)||A>this.length)throw RangeError("Attempt to write outside buffer bounds");if(!P)P="utf8";let W=!1;for(;;)switch(P){case"hex":return VR(this,T,A,C);case"utf8":case"utf-8":return YR(this,T,A,C);case"ascii":case"latin1":case"binary":return ZR(this,T,A,C);case"base64":return qR(this,T,A,C);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return XR(this,T,A,C);default:if(W)throw TypeError("Unknown encoding: "+P);P=(""+P).toLowerCase(),W=!0}};w.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};w.prototype.slice=function(T,A){let C=this.length;if(T=~~T,A=A===void 0?C:~~A,T<0){if(T+=C,T<0)T=0}else if(T>C)T=C;if(A<0){if(A+=C,A<0)A=0}else if(A>C)A=C;if(A<T)A=T;let P=this.subarray(T,A);return Object.setPrototypeOf(P,w.prototype),P};w.prototype.readUintLE=w.prototype.readUIntLE=function(T,A,C){if(T=T>>>0,A=A>>>0,!C)IT(T,A,this.length);let P=this[T],Q=1,W=0;while(++W<A&&(Q*=256))P+=this[T+W]*Q;return P};w.prototype.readUintBE=w.prototype.readUIntBE=function(T,A,C){if(T=T>>>0,A=A>>>0,!C)IT(T,A,this.length);let P=this[T+--A],Q=1;while(A>0&&(Q*=256))P+=this[T+--A]*Q;return P};w.prototype.readUint8=w.prototype.readUInt8=function(T,A){if(T=T>>>0,!A)IT(T,1,this.length);return this[T]};w.prototype.readUint16LE=w.prototype.readUInt16LE=function(T,A){if(T=T>>>0,!A)IT(T,2,this.length);return this[T]|this[T+1]<<8};w.prototype.readUint16BE=w.prototype.readUInt16BE=function(T,A){if(T=T>>>0,!A)IT(T,2,this.length);return this[T]<<8|this[T+1]};w.prototype.readUint32LE=w.prototype.readUInt32LE=function(T,A){if(T=T>>>0,!A)IT(T,4,this.length);return(this[T]|this[T+1]<<8|this[T+2]<<16)+this[T+3]*16777216};w.prototype.readUint32BE=w.prototype.readUInt32BE=function(T,A){if(T=T>>>0,!A)IT(T,4,this.length);return this[T]*16777216+(this[T+1]<<16|this[T+2]<<8|this[T+3])};w.prototype.readBigUInt64LE=MA(function(T){T=T>>>0,_8(T,"offset");let A=this[T],C=this[T+7];if(A===void 0||C===void 0)D2(T,this.length-8);let P=A+this[++T]*256+this[++T]*65536+this[++T]*16777216,Q=this[++T]+this[++T]*256+this[++T]*65536+C*16777216;return BigInt(P)+(BigInt(Q)<<BigInt(32))});w.prototype.readBigUInt64BE=MA(function(T){T=T>>>0,_8(T,"offset");let A=this[T],C=this[T+7];if(A===void 0||C===void 0)D2(T,this.length-8);let P=A*16777216+this[++T]*65536+this[++T]*256+this[++T],Q=this[++T]*16777216+this[++T]*65536+this[++T]*256+C;return(BigInt(P)<<BigInt(32))+BigInt(Q)});w.prototype.readIntLE=function(T,A,C){if(T=T>>>0,A=A>>>0,!C)IT(T,A,this.length);let P=this[T],Q=1,W=0;while(++W<A&&(Q*=256))P+=this[T+W]*Q;if(Q*=128,P>=Q)P-=Math.pow(2,8*A);return P};w.prototype.readIntBE=function(T,A,C){if(T=T>>>0,A=A>>>0,!C)IT(T,A,this.length);let P=A,Q=1,W=this[T+--P];while(P>0&&(Q*=256))W+=this[T+--P]*Q;if(Q*=128,W>=Q)W-=Math.pow(2,8*A);return W};w.prototype.readInt8=function(T,A){if(T=T>>>0,!A)IT(T,1,this.length);if(!(this[T]&128))return this[T];return(255-this[T]+1)*-1};w.prototype.readInt16LE=function(T,A){if(T=T>>>0,!A)IT(T,2,this.length);let C=this[T]|this[T+1]<<8;return C&32768?C|4294901760:C};w.prototype.readInt16BE=function(T,A){if(T=T>>>0,!A)IT(T,2,this.length);let C=this[T+1]|this[T]<<8;return C&32768?C|4294901760:C};w.prototype.readInt32LE=function(T,A){if(T=T>>>0,!A)IT(T,4,this.length);return this[T]|this[T+1]<<8|this[T+2]<<16|this[T+3]<<24};w.prototype.readInt32BE=function(T,A){if(T=T>>>0,!A)IT(T,4,this.length);return this[T]<<24|this[T+1]<<16|this[T+2]<<8|this[T+3]};w.prototype.readBigInt64LE=MA(function(T){T=T>>>0,_8(T,"offset");let A=this[T],C=this[T+7];if(A===void 0||C===void 0)D2(T,this.length-8);let P=this[T+4]+this[T+5]*256+this[T+6]*65536+(C<<24);return(BigInt(P)<<BigInt(32))+BigInt(A+this[++T]*256+this[++T]*65536+this[++T]*16777216)});w.prototype.readBigInt64BE=MA(function(T){T=T>>>0,_8(T,"offset");let A=this[T],C=this[T+7];if(A===void 0||C===void 0)D2(T,this.length-8);let P=(A<<24)+this[++T]*65536+this[++T]*256+this[++T];return(BigInt(P)<<BigInt(32))+BigInt(this[++T]*16777216+this[++T]*65536+this[++T]*256+C)});w.prototype.readFloatLE=function(T,A){if(T=T>>>0,!A)IT(T,4,this.length);return r6(this,T,!0,23,4)};w.prototype.readFloatBE=function(T,A){if(T=T>>>0,!A)IT(T,4,this.length);return r6(this,T,!1,23,4)};w.prototype.readDoubleLE=function(T,A){if(T=T>>>0,!A)IT(T,8,this.length);return r6(this,T,!0,52,8)};w.prototype.readDoubleBE=function(T,A){if(T=T>>>0,!A)IT(T,8,this.length);return r6(this,T,!1,52,8)};w.prototype.writeUintLE=w.prototype.writeUIntLE=function(T,A,C,P){if(T=+T,A=A>>>0,C=C>>>0,!P){let G=Math.pow(2,8*C)-1;eT(this,T,A,C,G,0)}let Q=1,W=0;this[A]=T&255;while(++W<C&&(Q*=256))this[A+W]=T/Q&255;return A+C};w.prototype.writeUintBE=w.prototype.writeUIntBE=function(T,A,C,P){if(T=+T,A=A>>>0,C=C>>>0,!P){let G=Math.pow(2,8*C)-1;eT(this,T,A,C,G,0)}let Q=C-1,W=1;this[A+Q]=T&255;while(--Q>=0&&(W*=256))this[A+Q]=T/W&255;return A+C};w.prototype.writeUint8=w.prototype.writeUInt8=function(T,A,C){if(T=+T,A=A>>>0,!C)eT(this,T,A,1,255,0);return this[A]=T&255,A+1};w.prototype.writeUint16LE=w.prototype.writeUInt16LE=function(T,A,C){if(T=+T,A=A>>>0,!C)eT(this,T,A,2,65535,0);return this[A]=T&255,this[A+1]=T>>>8,A+2};w.prototype.writeUint16BE=w.prototype.writeUInt16BE=function(T,A,C){if(T=+T,A=A>>>0,!C)eT(this,T,A,2,65535,0);return this[A]=T>>>8,this[A+1]=T&255,A+2};w.prototype.writeUint32LE=w.prototype.writeUInt32LE=function(T,A,C){if(T=+T,A=A>>>0,!C)eT(this,T,A,4,4294967295,0);return this[A+3]=T>>>24,this[A+2]=T>>>16,this[A+1]=T>>>8,this[A]=T&255,A+4};w.prototype.writeUint32BE=w.prototype.writeUInt32BE=function(T,A,C){if(T=+T,A=A>>>0,!C)eT(this,T,A,4,4294967295,0);return this[A]=T>>>24,this[A+1]=T>>>16,this[A+2]=T>>>8,this[A+3]=T&255,A+4};w.prototype.writeBigUInt64LE=MA(function(T,A=0){return E$(this,T,A,BigInt(0),BigInt("0xffffffffffffffff"))});w.prototype.writeBigUInt64BE=MA(function(T,A=0){return B$(this,T,A,BigInt(0),BigInt("0xffffffffffffffff"))});w.prototype.writeIntLE=function(T,A,C,P){if(T=+T,A=A>>>0,!P){let U=Math.pow(2,8*C-1);eT(this,T,A,C,U-1,-U)}let Q=0,W=1,G=0;this[A]=T&255;while(++Q<C&&(W*=256)){if(T<0&&G===0&&this[A+Q-1]!==0)G=1;this[A+Q]=(T/W>>0)-G&255}return A+C};w.prototype.writeIntBE=function(T,A,C,P){if(T=+T,A=A>>>0,!P){let U=Math.pow(2,8*C-1);eT(this,T,A,C,U-1,-U)}let Q=C-1,W=1,G=0;this[A+Q]=T&255;while(--Q>=0&&(W*=256)){if(T<0&&G===0&&this[A+Q+1]!==0)G=1;this[A+Q]=(T/W>>0)-G&255}return A+C};w.prototype.writeInt8=function(T,A,C){if(T=+T,A=A>>>0,!C)eT(this,T,A,1,127,-128);if(T<0)T=255+T+1;return this[A]=T&255,A+1};w.prototype.writeInt16LE=function(T,A,C){if(T=+T,A=A>>>0,!C)eT(this,T,A,2,32767,-32768);return this[A]=T&255,this[A+1]=T>>>8,A+2};w.prototype.writeInt16BE=function(T,A,C){if(T=+T,A=A>>>0,!C)eT(this,T,A,2,32767,-32768);return this[A]=T>>>8,this[A+1]=T&255,A+2};w.prototype.writeInt32LE=function(T,A,C){if(T=+T,A=A>>>0,!C)eT(this,T,A,4,2147483647,-2147483648);return this[A]=T&255,this[A+1]=T>>>8,this[A+2]=T>>>16,this[A+3]=T>>>24,A+4};w.prototype.writeInt32BE=function(T,A,C){if(T=+T,A=A>>>0,!C)eT(this,T,A,4,2147483647,-2147483648);if(T<0)T=4294967295+T+1;return this[A]=T>>>24,this[A+1]=T>>>16,this[A+2]=T>>>8,this[A+3]=T&255,A+4};w.prototype.writeBigInt64LE=MA(function(T,A=0){return E$(this,T,A,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});w.prototype.writeBigInt64BE=MA(function(T,A=0){return B$(this,T,A,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});w.prototype.writeFloatLE=function(T,A,C){return _$(this,T,A,!0,C)};w.prototype.writeFloatBE=function(T,A,C){return _$(this,T,A,!1,C)};w.prototype.writeDoubleLE=function(T,A,C){return x$(this,T,A,!0,C)};w.prototype.writeDoubleBE=function(T,A,C){return x$(this,T,A,!1,C)};w.prototype.copy=function(T,A,C,P){if(!w.isBuffer(T))throw TypeError("argument should be a Buffer");if(!C)C=0;if(!P&&P!==0)P=this.length;if(A>=T.length)A=T.length;if(!A)A=0;if(P>0&&P<C)P=C;if(P===C)return 0;if(T.length===0||this.length===0)return 0;if(A<0)throw RangeError("targetStart out of bounds");if(C<0||C>=this.length)throw RangeError("Index out of range");if(P<0)throw RangeError("sourceEnd out of bounds");if(P>this.length)P=this.length;if(T.length-A<P-C)P=T.length-A+C;let Q=P-C;if(this===T&&typeof Uint8Array.prototype.copyWithin==="function")this.copyWithin(A,C,P);else Uint8Array.prototype.set.call(T,this.subarray(C,P),A);return Q};w.prototype.fill=function(T,A,C,P){if(typeof T==="string"){if(typeof A==="string")P=A,A=0,C=this.length;else if(typeof C==="string")P=C,C=this.length;if(P!==void 0&&typeof P!=="string")throw TypeError("encoding must be a string");if(typeof P==="string"&&!w.isEncoding(P))throw TypeError("Unknown encoding: "+P);if(T.length===1){let W=T.charCodeAt(0);if(P==="utf8"&&W<128||P==="latin1")T=W}}else if(typeof T==="number")T=T&255;else if(typeof T==="boolean")T=Number(T);if(A<0||this.length<A||this.length<C)throw RangeError("Out of range index");if(C<=A)return this;if(A=A>>>0,C=C===void 0?this.length:C>>>0,!T)T=0;let Q;if(typeof T==="number")for(Q=A;Q<C;++Q)this[Q]=T;else{let W=w.isBuffer(T)?T:w.from(T,P),G=W.length;if(G===0)throw TypeError('The value "'+T+'" is invalid for argument "value"');for(Q=0;Q<C-A;++Q)this[Q+A]=W[Q%G]}return this};zR=/[^+/0-9A-Za-z-_]/g;NR=function(){let T=Array(256);for(let A=0;A<16;++A){let C=A*16;for(let P=0;P<16;++P)T[C+P]="0123456789abcdef"[A]+"0123456789abcdef"[P]}return T}();wR=cP("resolveObjectURL"),ER=cP("isUtf8"),OR=cP("transcode"),_R=w});var RQ=V0((I9,jQ)=>{(function(T,A){function C(j,J){if(!j)throw Error(J||"Assertion failed")}function P(j,J){j.super_=J;var V=function(){};V.prototype=J.prototype,j.prototype=new V,j.prototype.constructor=j}function Q(j,J,V){if(Q.isBN(j))return j;if(this.negative=0,this.words=null,this.length=0,this.red=null,j!==null){if(J==="le"||J==="be")V=J,J=10;this._init(j||0,J||10,V||"be")}}if(typeof T==="object")T.exports=Q;else A.BN=Q;Q.BN=Q,Q.wordSize=26;var W;try{if(typeof window<"u"&&typeof window.Buffer<"u")W=window.Buffer;else W=(x8(),R8(i6)).Buffer}catch(j){}Q.isBN=function(J){if(J instanceof Q)return!0;return J!==null&&typeof J==="object"&&J.constructor.wordSize===Q.wordSize&&Array.isArray(J.words)},Q.max=function(J,V){if(J.cmp(V)>0)return J;return V},Q.min=function(J,V){if(J.cmp(V)<0)return J;return V},Q.prototype._init=function(J,V,Z){if(typeof J==="number")return this._initNumber(J,V,Z);if(typeof J==="object")return this._initArray(J,V,Z);if(V==="hex")V=16;C(V===(V|0)&&V>=2&&V<=36),J=J.toString().replace(/\s+/g,"");var H=0;if(J[0]==="-")H++,this.negative=1;if(H<J.length){if(V===16)this._parseHex(J,H,Z);else if(this._parseBase(J,V,H),Z==="le")this._initArray(this.toArray(),V,Z)}},Q.prototype._initNumber=function(J,V,Z){if(J<0)this.negative=1,J=-J;if(J<67108864)this.words=[J&67108863],this.length=1;else if(J<4503599627370496)this.words=[J&67108863,J/67108864&67108863],this.length=2;else C(J<9007199254740992),this.words=[J&67108863,J/67108864&67108863,1],this.length=3;if(Z!=="le")return;this._initArray(this.toArray(),V,Z)},Q.prototype._initArray=function(J,V,Z){if(C(typeof J.length==="number"),J.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(J.length/3),this.words=Array(this.length);for(var H=0;H<this.length;H++)this.words[H]=0;var k,S,I=0;if(Z==="be"){for(H=J.length-1,k=0;H>=0;H-=3)if(S=J[H]|J[H-1]<<8|J[H-2]<<16,this.words[k]|=S<<I&67108863,this.words[k+1]=S>>>26-I&67108863,I+=24,I>=26)I-=26,k++}else if(Z==="le"){for(H=0,k=0;H<J.length;H+=3)if(S=J[H]|J[H+1]<<8|J[H+2]<<16,this.words[k]|=S<<I&67108863,this.words[k+1]=S>>>26-I&67108863,I+=24,I>=26)I-=26,k++}return this._strip()};function G(j,J){var V=j.charCodeAt(J);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 C(!1,"Invalid character in "+j)}function U(j,J,V){var Z=G(j,V);if(V-1>=J)Z|=G(j,V-1)<<4;return Z}Q.prototype._parseHex=function(J,V,Z){this.length=Math.ceil((J.length-V)/6),this.words=Array(this.length);for(var H=0;H<this.length;H++)this.words[H]=0;var k=0,S=0,I;if(Z==="be")for(H=J.length-1;H>=V;H-=2)if(I=U(J,V,H)<<k,this.words[S]|=I&67108863,k>=18)k-=18,S+=1,this.words[S]|=I>>>26;else k+=8;else{var R=J.length-V;for(H=R%2===0?V+1:V;H<J.length;H+=2)if(I=U(J,V,H)<<k,this.words[S]|=I&67108863,k>=18)k-=18,S+=1,this.words[S]|=I>>>26;else k+=8}this._strip()};function $(j,J,V,Z){var H=0,k=0,S=Math.min(j.length,V);for(var I=J;I<S;I++){var R=j.charCodeAt(I)-48;if(H*=Z,R>=49)k=R-49+10;else if(R>=17)k=R-17+10;else k=R;C(R>=0&&k<Z,"Invalid character"),H+=k}return H}Q.prototype._parseBase=function(J,V,Z){this.words=[0],this.length=1;for(var H=0,k=1;k<=67108863;k*=V)H++;H--,k=k/V|0;var S=J.length-Z,I=S%H,R=Math.min(S,S-I)+Z,Y=0;for(var D=Z;D<R;D+=H)if(Y=$(J,D,D+H,V),this.imuln(k),this.words[0]+Y<67108864)this.words[0]+=Y;else this._iaddn(Y);if(I!==0){var b=1;Y=$(J,D,J.length,V);for(D=0;D<I;D++)b*=V;if(this.imuln(b),this.words[0]+Y<67108864)this.words[0]+=Y;else this._iaddn(Y)}this._strip()},Q.prototype.copy=function(J){J.words=Array(this.length);for(var V=0;V<this.length;V++)J.words[V]=this.words[V];J.length=this.length,J.negative=this.negative,J.red=this.red};function X(j,J){j.words=J.words,j.length=J.length,j.negative=J.negative,j.red=J.red}if(Q.prototype._move=function(J){X(J,this)},Q.prototype.clone=function(){var J=new Q(null);return this.copy(J),J},Q.prototype._expand=function(J){while(this.length<J)this.words[this.length++]=0;return this},Q.prototype._strip=function(){while(this.length>1&&this.words[this.length-1]===0)this.length--;return this._normSign()},Q.prototype._normSign=function(){if(this.length===1&&this.words[0]===0)this.negative=0;return this},typeof Symbol<"u"&&typeof Symbol.for==="function")try{Q.prototype[Symbol.for("nodejs.util.inspect.custom")]=q}catch(j){Q.prototype.inspect=q}else Q.prototype.inspect=q;function q(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var K=["","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"],F=[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(Q.prototype.toString=function(J,V){J=J||10,V=V|0||1;var Z;if(J===16||J==="hex"){Z="";var H=0,k=0;for(var S=0;S<this.length;S++){var I=this.words[S],R=((I<<H|k)&16777215).toString(16);if(k=I>>>24-H&16777215,H+=2,H>=26)H-=26,S--;if(k!==0||S!==this.length-1)Z=K[6-R.length]+R+Z;else Z=R+Z}if(k!==0)Z=k.toString(16)+Z;while(Z.length%V!==0)Z="0"+Z;if(this.negative!==0)Z="-"+Z;return Z}if(J===(J|0)&&J>=2&&J<=36){var Y=F[J],D=z[J];Z="";var b=this.clone();b.negative=0;while(!b.isZero()){var i=b.modrn(D).toString(J);if(b=b.idivn(D),!b.isZero())Z=K[Y-i.length]+i+Z;else Z=i+Z}if(this.isZero())Z="0"+Z;while(Z.length%V!==0)Z="0"+Z;if(this.negative!==0)Z="-"+Z;return Z}C(!1,"Base should be between 2 and 36")},Q.prototype.toNumber=function(){var J=this.words[0];if(this.length===2)J+=this.words[1]*67108864;else if(this.length===3&&this.words[2]===1)J+=4503599627370496+this.words[1]*67108864;else if(this.length>2)C(!1,"Number can only safely store up to 53 bits");return this.negative!==0?-J:J},Q.prototype.toJSON=function(){return this.toString(16,2)},W)Q.prototype.toBuffer=function(J,V){return this.toArrayLike(W,J,V)};Q.prototype.toArray=function(J,V){return this.toArrayLike(Array,J,V)};var M=function(J,V){if(J.allocUnsafe)return J.allocUnsafe(V);return new J(V)};if(Q.prototype.toArrayLike=function(J,V,Z){this._strip();var H=this.byteLength(),k=Z||Math.max(1,H);C(H<=k,"byte array longer than desired length"),C(k>0,"Requested array length <= 0");var S=M(J,k),I=V==="le"?"LE":"BE";return this["_toArrayLike"+I](S,H),S},Q.prototype._toArrayLikeLE=function(J,V){var Z=0,H=0;for(var k=0,S=0;k<this.length;k++){var I=this.words[k]<<S|H;if(J[Z++]=I&255,Z<J.length)J[Z++]=I>>8&255;if(Z<J.length)J[Z++]=I>>16&255;if(S===6){if(Z<J.length)J[Z++]=I>>24&255;H=0,S=0}else H=I>>>24,S+=2}if(Z<J.length){J[Z++]=H;while(Z<J.length)J[Z++]=0}},Q.prototype._toArrayLikeBE=function(J,V){var Z=J.length-1,H=0;for(var k=0,S=0;k<this.length;k++){var I=this.words[k]<<S|H;if(J[Z--]=I&255,Z>=0)J[Z--]=I>>8&255;if(Z>=0)J[Z--]=I>>16&255;if(S===6){if(Z>=0)J[Z--]=I>>24&255;H=0,S=0}else H=I>>>24,S+=2}if(Z>=0){J[Z--]=H;while(Z>=0)J[Z--]=0}},Math.clz32)Q.prototype._countBits=function(J){return 32-Math.clz32(J)};else Q.prototype._countBits=function(J){var V=J,Z=0;if(V>=4096)Z+=13,V>>>=13;if(V>=64)Z+=7,V>>>=7;if(V>=8)Z+=4,V>>>=4;if(V>=2)Z+=2,V>>>=2;return Z+V};Q.prototype._zeroBits=function(J){if(J===0)return 26;var V=J,Z=0;if((V&8191)===0)Z+=13,V>>>=13;if((V&127)===0)Z+=7,V>>>=7;if((V&15)===0)Z+=4,V>>>=4;if((V&3)===0)Z+=2,V>>>=2;if((V&1)===0)Z++;return Z},Q.prototype.bitLength=function(){var J=this.words[this.length-1],V=this._countBits(J);return(this.length-1)*26+V};function E(j){var J=Array(j.bitLength());for(var V=0;V<J.length;V++){var Z=V/26|0,H=V%26;J[V]=j.words[Z]>>>H&1}return J}Q.prototype.zeroBits=function(){if(this.isZero())return 0;var J=0;for(var V=0;V<this.length;V++){var Z=this._zeroBits(this.words[V]);if(J+=Z,Z!==26)break}return J},Q.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},Q.prototype.toTwos=function(J){if(this.negative!==0)return this.abs().inotn(J).iaddn(1);return this.clone()},Q.prototype.fromTwos=function(J){if(this.testn(J-1))return this.notn(J).iaddn(1).ineg();return this.clone()},Q.prototype.isNeg=function(){return this.negative!==0},Q.prototype.neg=function(){return this.clone().ineg()},Q.prototype.ineg=function(){if(!this.isZero())this.negative^=1;return this},Q.prototype.iuor=function(J){while(this.length<J.length)this.words[this.length++]=0;for(var V=0;V<J.length;V++)this.words[V]=this.words[V]|J.words[V];return this._strip()},Q.prototype.ior=function(J){return C((this.negative|J.negative)===0),this.iuor(J)},Q.prototype.or=function(J){if(this.length>J.length)return this.clone().ior(J);return J.clone().ior(this)},Q.prototype.uor=function(J){if(this.length>J.length)return this.clone().iuor(J);return J.clone().iuor(this)},Q.prototype.iuand=function(J){var V;if(this.length>J.length)V=J;else V=this;for(var Z=0;Z<V.length;Z++)this.words[Z]=this.words[Z]&J.words[Z];return this.length=V.length,this._strip()},Q.prototype.iand=function(J){return C((this.negative|J.negative)===0),this.iuand(J)},Q.prototype.and=function(J){if(this.length>J.length)return this.clone().iand(J);return J.clone().iand(this)},Q.prototype.uand=function(J){if(this.length>J.length)return this.clone().iuand(J);return J.clone().iuand(this)},Q.prototype.iuxor=function(J){var V,Z;if(this.length>J.length)V=this,Z=J;else V=J,Z=this;for(var H=0;H<Z.length;H++)this.words[H]=V.words[H]^Z.words[H];if(this!==V)for(;H<V.length;H++)this.words[H]=V.words[H];return this.length=V.length,this._strip()},Q.prototype.ixor=function(J){return C((this.negative|J.negative)===0),this.iuxor(J)},Q.prototype.xor=function(J){if(this.length>J.length)return this.clone().ixor(J);return J.clone().ixor(this)},Q.prototype.uxor=function(J){if(this.length>J.length)return this.clone().iuxor(J);return J.clone().iuxor(this)},Q.prototype.inotn=function(J){C(typeof J==="number"&&J>=0);var V=Math.ceil(J/26)|0,Z=J%26;if(this._expand(V),Z>0)V--;for(var H=0;H<V;H++)this.words[H]=~this.words[H]&67108863;if(Z>0)this.words[H]=~this.words[H]&67108863>>26-Z;return this._strip()},Q.prototype.notn=function(J){return this.clone().inotn(J)},Q.prototype.setn=function(J,V){C(typeof J==="number"&&J>=0);var Z=J/26|0,H=J%26;if(this._expand(Z+1),V)this.words[Z]=this.words[Z]|1<<H;else this.words[Z]=this.words[Z]&~(1<<H);return this._strip()},Q.prototype.iadd=function(J){var V;if(this.negative!==0&&J.negative===0)return this.negative=0,V=this.isub(J),this.negative^=1,this._normSign();else if(this.negative===0&&J.negative!==0)return J.negative=0,V=this.isub(J),J.negative=1,V._normSign();var Z,H;if(this.length>J.length)Z=this,H=J;else Z=J,H=this;var k=0;for(var S=0;S<H.length;S++)V=(Z.words[S]|0)+(H.words[S]|0)+k,this.words[S]=V&67108863,k=V>>>26;for(;k!==0&&S<Z.length;S++)V=(Z.words[S]|0)+k,this.words[S]=V&67108863,k=V>>>26;if(this.length=Z.length,k!==0)this.words[this.length]=k,this.length++;else if(Z!==this)for(;S<Z.length;S++)this.words[S]=Z.words[S];return this},Q.prototype.add=function(J){var V;if(J.negative!==0&&this.negative===0)return J.negative=0,V=this.sub(J),J.negative^=1,V;else if(J.negative===0&&this.negative!==0)return this.negative=0,V=J.sub(this),this.negative=1,V;if(this.length>J.length)return this.clone().iadd(J);return J.clone().iadd(this)},Q.prototype.isub=function(J){if(J.negative!==0){J.negative=0;var V=this.iadd(J);return J.negative=1,V._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(J),this.negative=1,this._normSign();var Z=this.cmp(J);if(Z===0)return this.negative=0,this.length=1,this.words[0]=0,this;var H,k;if(Z>0)H=this,k=J;else H=J,k=this;var S=0;for(var I=0;I<k.length;I++)V=(H.words[I]|0)-(k.words[I]|0)+S,S=V>>26,this.words[I]=V&67108863;for(;S!==0&&I<H.length;I++)V=(H.words[I]|0)+S,S=V>>26,this.words[I]=V&67108863;if(S===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()},Q.prototype.sub=function(J){return this.clone().isub(J)};function L(j,J,V){V.negative=J.negative^j.negative;var Z=j.length+J.length|0;V.length=Z,Z=Z-1|0;var H=j.words[0]|0,k=J.words[0]|0,S=H*k,I=S&67108863,R=S/67108864|0;V.words[0]=I;for(var Y=1;Y<Z;Y++){var D=R>>>26,b=R&67108863,i=Math.min(Y,J.length-1);for(var r=Math.max(0,Y-j.length+1);r<=i;r++){var T1=Y-r|0;H=j.words[T1]|0,k=J.words[r]|0,S=H*k+b,D+=S/67108864|0,b=S&67108863}V.words[Y]=b|0,R=D|0}if(R!==0)V.words[Y]=R|0;else V.length--;return V._strip()}var B=function(J,V,Z){var H=J.words,k=V.words,S=Z.words,I=0,R,Y,D,b=H[0]|0,i=b&8191,r=b>>>13,T1=H[1]|0,C1=T1&8191,P1=T1>>>13,oT=H[2]|0,Y1=oT&8191,j1=oT>>>13,P2=H[3]|0,x1=P2&8191,h1=P2>>>13,eW=H[4]|0,m1=eW&8191,g1=eW>>>13,TG=H[5]|0,v1=TG&8191,y1=TG>>>13,AG=H[6]|0,b1=AG&8191,l1=AG>>>13,CG=H[7]|0,p1=CG&8191,u1=CG>>>13,PG=H[8]|0,d1=PG&8191,r1=PG>>>13,QG=H[9]|0,f1=QG&8191,i1=QG>>>13,WG=k[0]|0,c1=WG&8191,o1=WG>>>13,GG=k[1]|0,n1=GG&8191,a1=GG>>>13,JG=k[2]|0,s1=JG&8191,t1=JG>>>13,UG=k[3]|0,e1=UG&8191,TT=UG>>>13,$G=k[4]|0,AT=$G&8191,CT=$G>>>13,VG=k[5]|0,PT=VG&8191,QT=VG>>>13,YG=k[6]|0,WT=YG&8191,GT=YG>>>13,ZG=k[7]|0,JT=ZG&8191,UT=ZG>>>13,qG=k[8]|0,$T=qG&8191,VT=qG>>>13,XG=k[9]|0,YT=XG&8191,ZT=XG>>>13;Z.negative=J.negative^V.negative,Z.length=19,R=Math.imul(i,c1),Y=Math.imul(i,o1),Y=Y+Math.imul(r,c1)|0,D=Math.imul(r,o1);var tC=(I+R|0)+((Y&8191)<<13)|0;I=(D+(Y>>>13)|0)+(tC>>>26)|0,tC&=67108863,R=Math.imul(C1,c1),Y=Math.imul(C1,o1),Y=Y+Math.imul(P1,c1)|0,D=Math.imul(P1,o1),R=R+Math.imul(i,n1)|0,Y=Y+Math.imul(i,a1)|0,Y=Y+Math.imul(r,n1)|0,D=D+Math.imul(r,a1)|0;var eC=(I+R|0)+((Y&8191)<<13)|0;I=(D+(Y>>>13)|0)+(eC>>>26)|0,eC&=67108863,R=Math.imul(Y1,c1),Y=Math.imul(Y1,o1),Y=Y+Math.imul(j1,c1)|0,D=Math.imul(j1,o1),R=R+Math.imul(C1,n1)|0,Y=Y+Math.imul(C1,a1)|0,Y=Y+Math.imul(P1,n1)|0,D=D+Math.imul(P1,a1)|0,R=R+Math.imul(i,s1)|0,Y=Y+Math.imul(i,t1)|0,Y=Y+Math.imul(r,s1)|0,D=D+Math.imul(r,t1)|0;var T4=(I+R|0)+((Y&8191)<<13)|0;I=(D+(Y>>>13)|0)+(T4>>>26)|0,T4&=67108863,R=Math.imul(x1,c1),Y=Math.imul(x1,o1),Y=Y+Math.imul(h1,c1)|0,D=Math.imul(h1,o1),R=R+Math.imul(Y1,n1)|0,Y=Y+Math.imul(Y1,a1)|0,Y=Y+Math.imul(j1,n1)|0,D=D+Math.imul(j1,a1)|0,R=R+Math.imul(C1,s1)|0,Y=Y+Math.imul(C1,t1)|0,Y=Y+Math.imul(P1,s1)|0,D=D+Math.imul(P1,t1)|0,R=R+Math.imul(i,e1)|0,Y=Y+Math.imul(i,TT)|0,Y=Y+Math.imul(r,e1)|0,D=D+Math.imul(r,TT)|0;var A4=(I+R|0)+((Y&8191)<<13)|0;I=(D+(Y>>>13)|0)+(A4>>>26)|0,A4&=67108863,R=Math.imul(m1,c1),Y=Math.imul(m1,o1),Y=Y+Math.imul(g1,c1)|0,D=Math.imul(g1,o1),R=R+Math.imul(x1,n1)|0,Y=Y+Math.imul(x1,a1)|0,Y=Y+Math.imul(h1,n1)|0,D=D+Math.imul(h1,a1)|0,R=R+Math.imul(Y1,s1)|0,Y=Y+Math.imul(Y1,t1)|0,Y=Y+Math.imul(j1,s1)|0,D=D+Math.imul(j1,t1)|0,R=R+Math.imul(C1,e1)|0,Y=Y+Math.imul(C1,TT)|0,Y=Y+Math.imul(P1,e1)|0,D=D+Math.imul(P1,TT)|0,R=R+Math.imul(i,AT)|0,Y=Y+Math.imul(i,CT)|0,Y=Y+Math.imul(r,AT)|0,D=D+Math.imul(r,CT)|0;var C4=(I+R|0)+((Y&8191)<<13)|0;I=(D+(Y>>>13)|0)+(C4>>>26)|0,C4&=67108863,R=Math.imul(v1,c1),Y=Math.imul(v1,o1),Y=Y+Math.imul(y1,c1)|0,D=Math.imul(y1,o1),R=R+Math.imul(m1,n1)|0,Y=Y+Math.imul(m1,a1)|0,Y=Y+Math.imul(g1,n1)|0,D=D+Math.imul(g1,a1)|0,R=R+Math.imul(x1,s1)|0,Y=Y+Math.imul(x1,t1)|0,Y=Y+Math.imul(h1,s1)|0,D=D+Math.imul(h1,t1)|0,R=R+Math.imul(Y1,e1)|0,Y=Y+Math.imul(Y1,TT)|0,Y=Y+Math.imul(j1,e1)|0,D=D+Math.imul(j1,TT)|0,R=R+Math.imul(C1,AT)|0,Y=Y+Math.imul(C1,CT)|0,Y=Y+Math.imul(P1,AT)|0,D=D+Math.imul(P1,CT)|0,R=R+Math.imul(i,PT)|0,Y=Y+Math.imul(i,QT)|0,Y=Y+Math.imul(r,PT)|0,D=D+Math.imul(r,QT)|0;var P4=(I+R|0)+((Y&8191)<<13)|0;I=(D+(Y>>>13)|0)+(P4>>>26)|0,P4&=67108863,R=Math.imul(b1,c1),Y=Math.imul(b1,o1),Y=Y+Math.imul(l1,c1)|0,D=Math.imul(l1,o1),R=R+Math.imul(v1,n1)|0,Y=Y+Math.imul(v1,a1)|0,Y=Y+Math.imul(y1,n1)|0,D=D+Math.imul(y1,a1)|0,R=R+Math.imul(m1,s1)|0,Y=Y+Math.imul(m1,t1)|0,Y=Y+Math.imul(g1,s1)|0,D=D+Math.imul(g1,t1)|0,R=R+Math.imul(x1,e1)|0,Y=Y+Math.imul(x1,TT)|0,Y=Y+Math.imul(h1,e1)|0,D=D+Math.imul(h1,TT)|0,R=R+Math.imul(Y1,AT)|0,Y=Y+Math.imul(Y1,CT)|0,Y=Y+Math.imul(j1,AT)|0,D=D+Math.imul(j1,CT)|0,R=R+Math.imul(C1,PT)|0,Y=Y+Math.imul(C1,QT)|0,Y=Y+Math.imul(P1,PT)|0,D=D+Math.imul(P1,QT)|0,R=R+Math.imul(i,WT)|0,Y=Y+Math.imul(i,GT)|0,Y=Y+Math.imul(r,WT)|0,D=D+Math.imul(r,GT)|0;var Q4=(I+R|0)+((Y&8191)<<13)|0;I=(D+(Y>>>13)|0)+(Q4>>>26)|0,Q4&=67108863,R=Math.imul(p1,c1),Y=Math.imul(p1,o1),Y=Y+Math.imul(u1,c1)|0,D=Math.imul(u1,o1),R=R+Math.imul(b1,n1)|0,Y=Y+Math.imul(b1,a1)|0,Y=Y+Math.imul(l1,n1)|0,D=D+Math.imul(l1,a1)|0,R=R+Math.imul(v1,s1)|0,Y=Y+Math.imul(v1,t1)|0,Y=Y+Math.imul(y1,s1)|0,D=D+Math.imul(y1,t1)|0,R=R+Math.imul(m1,e1)|0,Y=Y+Math.imul(m1,TT)|0,Y=Y+Math.imul(g1,e1)|0,D=D+Math.imul(g1,TT)|0,R=R+Math.imul(x1,AT)|0,Y=Y+Math.imul(x1,CT)|0,Y=Y+Math.imul(h1,AT)|0,D=D+Math.imul(h1,CT)|0,R=R+Math.imul(Y1,PT)|0,Y=Y+Math.imul(Y1,QT)|0,Y=Y+Math.imul(j1,PT)|0,D=D+Math.imul(j1,QT)|0,R=R+Math.imul(C1,WT)|0,Y=Y+Math.imul(C1,GT)|0,Y=Y+Math.imul(P1,WT)|0,D=D+Math.imul(P1,GT)|0,R=R+Math.imul(i,JT)|0,Y=Y+Math.imul(i,UT)|0,Y=Y+Math.imul(r,JT)|0,D=D+Math.imul(r,UT)|0;var W4=(I+R|0)+((Y&8191)<<13)|0;I=(D+(Y>>>13)|0)+(W4>>>26)|0,W4&=67108863,R=Math.imul(d1,c1),Y=Math.imul(d1,o1),Y=Y+Math.imul(r1,c1)|0,D=Math.imul(r1,o1),R=R+Math.imul(p1,n1)|0,Y=Y+Math.imul(p1,a1)|0,Y=Y+Math.imul(u1,n1)|0,D=D+Math.imul(u1,a1)|0,R=R+Math.imul(b1,s1)|0,Y=Y+Math.imul(b1,t1)|0,Y=Y+Math.imul(l1,s1)|0,D=D+Math.imul(l1,t1)|0,R=R+Math.imul(v1,e1)|0,Y=Y+Math.imul(v1,TT)|0,Y=Y+Math.imul(y1,e1)|0,D=D+Math.imul(y1,TT)|0,R=R+Math.imul(m1,AT)|0,Y=Y+Math.imul(m1,CT)|0,Y=Y+Math.imul(g1,AT)|0,D=D+Math.imul(g1,CT)|0,R=R+Math.imul(x1,PT)|0,Y=Y+Math.imul(x1,QT)|0,Y=Y+Math.imul(h1,PT)|0,D=D+Math.imul(h1,QT)|0,R=R+Math.imul(Y1,WT)|0,Y=Y+Math.imul(Y1,GT)|0,Y=Y+Math.imul(j1,WT)|0,D=D+Math.imul(j1,GT)|0,R=R+Math.imul(C1,JT)|0,Y=Y+Math.imul(C1,UT)|0,Y=Y+Math.imul(P1,JT)|0,D=D+Math.imul(P1,UT)|0,R=R+Math.imul(i,$T)|0,Y=Y+Math.imul(i,VT)|0,Y=Y+Math.imul(r,$T)|0,D=D+Math.imul(r,VT)|0;var G4=(I+R|0)+((Y&8191)<<13)|0;I=(D+(Y>>>13)|0)+(G4>>>26)|0,G4&=67108863,R=Math.imul(f1,c1),Y=Math.imul(f1,o1),Y=Y+Math.imul(i1,c1)|0,D=Math.imul(i1,o1),R=R+Math.imul(d1,n1)|0,Y=Y+Math.imul(d1,a1)|0,Y=Y+Math.imul(r1,n1)|0,D=D+Math.imul(r1,a1)|0,R=R+Math.imul(p1,s1)|0,Y=Y+Math.imul(p1,t1)|0,Y=Y+Math.imul(u1,s1)|0,D=D+Math.imul(u1,t1)|0,R=R+Math.imul(b1,e1)|0,Y=Y+Math.imul(b1,TT)|0,Y=Y+Math.imul(l1,e1)|0,D=D+Math.imul(l1,TT)|0,R=R+Math.imul(v1,AT)|0,Y=Y+Math.imul(v1,CT)|0,Y=Y+Math.imul(y1,AT)|0,D=D+Math.imul(y1,CT)|0,R=R+Math.imul(m1,PT)|0,Y=Y+Math.imul(m1,QT)|0,Y=Y+Math.imul(g1,PT)|0,D=D+Math.imul(g1,QT)|0,R=R+Math.imul(x1,WT)|0,Y=Y+Math.imul(x1,GT)|0,Y=Y+Math.imul(h1,WT)|0,D=D+Math.imul(h1,GT)|0,R=R+Math.imul(Y1,JT)|0,Y=Y+Math.imul(Y1,UT)|0,Y=Y+Math.imul(j1,JT)|0,D=D+Math.imul(j1,UT)|0,R=R+Math.imul(C1,$T)|0,Y=Y+Math.imul(C1,VT)|0,Y=Y+Math.imul(P1,$T)|0,D=D+Math.imul(P1,VT)|0,R=R+Math.imul(i,YT)|0,Y=Y+Math.imul(i,ZT)|0,Y=Y+Math.imul(r,YT)|0,D=D+Math.imul(r,ZT)|0;var J4=(I+R|0)+((Y&8191)<<13)|0;I=(D+(Y>>>13)|0)+(J4>>>26)|0,J4&=67108863,R=Math.imul(f1,n1),Y=Math.imul(f1,a1),Y=Y+Math.imul(i1,n1)|0,D=Math.imul(i1,a1),R=R+Math.imul(d1,s1)|0,Y=Y+Math.imul(d1,t1)|0,Y=Y+Math.imul(r1,s1)|0,D=D+Math.imul(r1,t1)|0,R=R+Math.imul(p1,e1)|0,Y=Y+Math.imul(p1,TT)|0,Y=Y+Math.imul(u1,e1)|0,D=D+Math.imul(u1,TT)|0,R=R+Math.imul(b1,AT)|0,Y=Y+Math.imul(b1,CT)|0,Y=Y+Math.imul(l1,AT)|0,D=D+Math.imul(l1,CT)|0,R=R+Math.imul(v1,PT)|0,Y=Y+Math.imul(v1,QT)|0,Y=Y+Math.imul(y1,PT)|0,D=D+Math.imul(y1,QT)|0,R=R+Math.imul(m1,WT)|0,Y=Y+Math.imul(m1,GT)|0,Y=Y+Math.imul(g1,WT)|0,D=D+Math.imul(g1,GT)|0,R=R+Math.imul(x1,JT)|0,Y=Y+Math.imul(x1,UT)|0,Y=Y+Math.imul(h1,JT)|0,D=D+Math.imul(h1,UT)|0,R=R+Math.imul(Y1,$T)|0,Y=Y+Math.imul(Y1,VT)|0,Y=Y+Math.imul(j1,$T)|0,D=D+Math.imul(j1,VT)|0,R=R+Math.imul(C1,YT)|0,Y=Y+Math.imul(C1,ZT)|0,Y=Y+Math.imul(P1,YT)|0,D=D+Math.imul(P1,ZT)|0;var U4=(I+R|0)+((Y&8191)<<13)|0;I=(D+(Y>>>13)|0)+(U4>>>26)|0,U4&=67108863,R=Math.imul(f1,s1),Y=Math.imul(f1,t1),Y=Y+Math.imul(i1,s1)|0,D=Math.imul(i1,t1),R=R+Math.imul(d1,e1)|0,Y=Y+Math.imul(d1,TT)|0,Y=Y+Math.imul(r1,e1)|0,D=D+Math.imul(r1,TT)|0,R=R+Math.imul(p1,AT)|0,Y=Y+Math.imul(p1,CT)|0,Y=Y+Math.imul(u1,AT)|0,D=D+Math.imul(u1,CT)|0,R=R+Math.imul(b1,PT)|0,Y=Y+Math.imul(b1,QT)|0,Y=Y+Math.imul(l1,PT)|0,D=D+Math.imul(l1,QT)|0,R=R+Math.imul(v1,WT)|0,Y=Y+Math.imul(v1,GT)|0,Y=Y+Math.imul(y1,WT)|0,D=D+Math.imul(y1,GT)|0,R=R+Math.imul(m1,JT)|0,Y=Y+Math.imul(m1,UT)|0,Y=Y+Math.imul(g1,JT)|0,D=D+Math.imul(g1,UT)|0,R=R+Math.imul(x1,$T)|0,Y=Y+Math.imul(x1,VT)|0,Y=Y+Math.imul(h1,$T)|0,D=D+Math.imul(h1,VT)|0,R=R+Math.imul(Y1,YT)|0,Y=Y+Math.imul(Y1,ZT)|0,Y=Y+Math.imul(j1,YT)|0,D=D+Math.imul(j1,ZT)|0;var $4=(I+R|0)+((Y&8191)<<13)|0;I=(D+(Y>>>13)|0)+($4>>>26)|0,$4&=67108863,R=Math.imul(f1,e1),Y=Math.imul(f1,TT),Y=Y+Math.imul(i1,e1)|0,D=Math.imul(i1,TT),R=R+Math.imul(d1,AT)|0,Y=Y+Math.imul(d1,CT)|0,Y=Y+Math.imul(r1,AT)|0,D=D+Math.imul(r1,CT)|0,R=R+Math.imul(p1,PT)|0,Y=Y+Math.imul(p1,QT)|0,Y=Y+Math.imul(u1,PT)|0,D=D+Math.imul(u1,QT)|0,R=R+Math.imul(b1,WT)|0,Y=Y+Math.imul(b1,GT)|0,Y=Y+Math.imul(l1,WT)|0,D=D+Math.imul(l1,GT)|0,R=R+Math.imul(v1,JT)|0,Y=Y+Math.imul(v1,UT)|0,Y=Y+Math.imul(y1,JT)|0,D=D+Math.imul(y1,UT)|0,R=R+Math.imul(m1,$T)|0,Y=Y+Math.imul(m1,VT)|0,Y=Y+Math.imul(g1,$T)|0,D=D+Math.imul(g1,VT)|0,R=R+Math.imul(x1,YT)|0,Y=Y+Math.imul(x1,ZT)|0,Y=Y+Math.imul(h1,YT)|0,D=D+Math.imul(h1,ZT)|0;var V4=(I+R|0)+((Y&8191)<<13)|0;I=(D+(Y>>>13)|0)+(V4>>>26)|0,V4&=67108863,R=Math.imul(f1,AT),Y=Math.imul(f1,CT),Y=Y+Math.imul(i1,AT)|0,D=Math.imul(i1,CT),R=R+Math.imul(d1,PT)|0,Y=Y+Math.imul(d1,QT)|0,Y=Y+Math.imul(r1,PT)|0,D=D+Math.imul(r1,QT)|0,R=R+Math.imul(p1,WT)|0,Y=Y+Math.imul(p1,GT)|0,Y=Y+Math.imul(u1,WT)|0,D=D+Math.imul(u1,GT)|0,R=R+Math.imul(b1,JT)|0,Y=Y+Math.imul(b1,UT)|0,Y=Y+Math.imul(l1,JT)|0,D=D+Math.imul(l1,UT)|0,R=R+Math.imul(v1,$T)|0,Y=Y+Math.imul(v1,VT)|0,Y=Y+Math.imul(y1,$T)|0,D=D+Math.imul(y1,VT)|0,R=R+Math.imul(m1,YT)|0,Y=Y+Math.imul(m1,ZT)|0,Y=Y+Math.imul(g1,YT)|0,D=D+Math.imul(g1,ZT)|0;var Y4=(I+R|0)+((Y&8191)<<13)|0;I=(D+(Y>>>13)|0)+(Y4>>>26)|0,Y4&=67108863,R=Math.imul(f1,PT),Y=Math.imul(f1,QT),Y=Y+Math.imul(i1,PT)|0,D=Math.imul(i1,QT),R=R+Math.imul(d1,WT)|0,Y=Y+Math.imul(d1,GT)|0,Y=Y+Math.imul(r1,WT)|0,D=D+Math.imul(r1,GT)|0,R=R+Math.imul(p1,JT)|0,Y=Y+Math.imul(p1,UT)|0,Y=Y+Math.imul(u1,JT)|0,D=D+Math.imul(u1,UT)|0,R=R+Math.imul(b1,$T)|0,Y=Y+Math.imul(b1,VT)|0,Y=Y+Math.imul(l1,$T)|0,D=D+Math.imul(l1,VT)|0,R=R+Math.imul(v1,YT)|0,Y=Y+Math.imul(v1,ZT)|0,Y=Y+Math.imul(y1,YT)|0,D=D+Math.imul(y1,ZT)|0;var Z4=(I+R|0)+((Y&8191)<<13)|0;I=(D+(Y>>>13)|0)+(Z4>>>26)|0,Z4&=67108863,R=Math.imul(f1,WT),Y=Math.imul(f1,GT),Y=Y+Math.imul(i1,WT)|0,D=Math.imul(i1,GT),R=R+Math.imul(d1,JT)|0,Y=Y+Math.imul(d1,UT)|0,Y=Y+Math.imul(r1,JT)|0,D=D+Math.imul(r1,UT)|0,R=R+Math.imul(p1,$T)|0,Y=Y+Math.imul(p1,VT)|0,Y=Y+Math.imul(u1,$T)|0,D=D+Math.imul(u1,VT)|0,R=R+Math.imul(b1,YT)|0,Y=Y+Math.imul(b1,ZT)|0,Y=Y+Math.imul(l1,YT)|0,D=D+Math.imul(l1,ZT)|0;var q4=(I+R|0)+((Y&8191)<<13)|0;I=(D+(Y>>>13)|0)+(q4>>>26)|0,q4&=67108863,R=Math.imul(f1,JT),Y=Math.imul(f1,UT),Y=Y+Math.imul(i1,JT)|0,D=Math.imul(i1,UT),R=R+Math.imul(d1,$T)|0,Y=Y+Math.imul(d1,VT)|0,Y=Y+Math.imul(r1,$T)|0,D=D+Math.imul(r1,VT)|0,R=R+Math.imul(p1,YT)|0,Y=Y+Math.imul(p1,ZT)|0,Y=Y+Math.imul(u1,YT)|0,D=D+Math.imul(u1,ZT)|0;var X4=(I+R|0)+((Y&8191)<<13)|0;I=(D+(Y>>>13)|0)+(X4>>>26)|0,X4&=67108863,R=Math.imul(f1,$T),Y=Math.imul(f1,VT),Y=Y+Math.imul(i1,$T)|0,D=Math.imul(i1,VT),R=R+Math.imul(d1,YT)|0,Y=Y+Math.imul(d1,ZT)|0,Y=Y+Math.imul(r1,YT)|0,D=D+Math.imul(r1,ZT)|0;var H4=(I+R|0)+((Y&8191)<<13)|0;I=(D+(Y>>>13)|0)+(H4>>>26)|0,H4&=67108863,R=Math.imul(f1,YT),Y=Math.imul(f1,ZT),Y=Y+Math.imul(i1,YT)|0,D=Math.imul(i1,ZT);var K4=(I+R|0)+((Y&8191)<<13)|0;if(I=(D+(Y>>>13)|0)+(K4>>>26)|0,K4&=67108863,S[0]=tC,S[1]=eC,S[2]=T4,S[3]=A4,S[4]=C4,S[5]=P4,S[6]=Q4,S[7]=W4,S[8]=G4,S[9]=J4,S[10]=U4,S[11]=$4,S[12]=V4,S[13]=Y4,S[14]=Z4,S[15]=q4,S[16]=X4,S[17]=H4,S[18]=K4,I!==0)S[19]=I,Z.length++;return Z};if(!Math.imul)B=L;function m(j,J,V){V.negative=J.negative^j.negative,V.length=j.length+J.length;var Z=0,H=0;for(var k=0;k<V.length-1;k++){var S=H;H=0;var I=Z&67108863,R=Math.min(k,J.length-1);for(var Y=Math.max(0,k-j.length+1);Y<=R;Y++){var D=k-Y,b=j.words[D]|0,i=J.words[Y]|0,r=b*i,T1=r&67108863;S=S+(r/67108864|0)|0,T1=T1+I|0,I=T1&67108863,S=S+(T1>>>26)|0,H+=S>>>26,S&=67108863}V.words[k]=I,Z=S,S=H}if(Z!==0)V.words[k]=Z;else V.length--;return V._strip()}function v(j,J,V){return m(j,J,V)}Q.prototype.mulTo=function(J,V){var Z,H=this.length+J.length;if(this.length===10&&J.length===10)Z=B(this,J,V);else if(H<63)Z=L(this,J,V);else if(H<1024)Z=m(this,J,V);else Z=v(this,J,V);return Z};function l(j,J){this.x=j,this.y=J}l.prototype.makeRBT=function(J){var V=Array(J),Z=Q.prototype._countBits(J)-1;for(var H=0;H<J;H++)V[H]=this.revBin(H,Z,J);return V},l.prototype.revBin=function(J,V,Z){if(J===0||J===Z-1)return J;var H=0;for(var k=0;k<V;k++)H|=(J&1)<<V-k-1,J>>=1;return H},l.prototype.permute=function(J,V,Z,H,k,S){for(var I=0;I<S;I++)H[I]=V[J[I]],k[I]=Z[J[I]]},l.prototype.transform=function(J,V,Z,H,k,S){this.permute(S,J,V,Z,H,k);for(var I=1;I<k;I<<=1){var R=I<<1,Y=Math.cos(2*Math.PI/R),D=Math.sin(2*Math.PI/R);for(var b=0;b<k;b+=R){var i=Y,r=D;for(var T1=0;T1<I;T1++){var C1=Z[b+T1],P1=H[b+T1],oT=Z[b+T1+I],Y1=H[b+T1+I],j1=i*oT-r*Y1;if(Y1=i*Y1+r*oT,oT=j1,Z[b+T1]=C1+oT,H[b+T1]=P1+Y1,Z[b+T1+I]=C1-oT,H[b+T1+I]=P1-Y1,T1!==R)j1=Y*i-D*r,r=Y*r+D*i,i=j1}}}},l.prototype.guessLen13b=function(J,V){var Z=Math.max(V,J)|1,H=Z&1,k=0;for(Z=Z/2|0;Z;Z=Z>>>1)k++;return 1<<k+1+H},l.prototype.conjugate=function(J,V,Z){if(Z<=1)return;for(var H=0;H<Z/2;H++){var k=J[H];J[H]=J[Z-H-1],J[Z-H-1]=k,k=V[H],V[H]=-V[Z-H-1],V[Z-H-1]=-k}},l.prototype.normalize13b=function(J,V){var Z=0;for(var H=0;H<V/2;H++){var k=Math.round(J[2*H+1]/V)*8192+Math.round(J[2*H]/V)+Z;if(J[H]=k&67108863,k<67108864)Z=0;else Z=k/67108864|0}return J},l.prototype.convert13b=function(J,V,Z,H){var k=0;for(var S=0;S<V;S++)k=k+(J[S]|0),Z[2*S]=k&8191,k=k>>>13,Z[2*S+1]=k&8191,k=k>>>13;for(S=2*V;S<H;++S)Z[S]=0;C(k===0),C((k&-8192)===0)},l.prototype.stub=function(J){var V=Array(J);for(var Z=0;Z<J;Z++)V[Z]=0;return V},l.prototype.mulp=function(J,V,Z){var H=2*this.guessLen13b(J.length,V.length),k=this.makeRBT(H),S=this.stub(H),I=Array(H),R=Array(H),Y=Array(H),D=Array(H),b=Array(H),i=Array(H),r=Z.words;r.length=H,this.convert13b(J.words,J.length,I,H),this.convert13b(V.words,V.length,D,H),this.transform(I,S,R,Y,H,k),this.transform(D,S,b,i,H,k);for(var T1=0;T1<H;T1++){var C1=R[T1]*b[T1]-Y[T1]*i[T1];Y[T1]=R[T1]*i[T1]+Y[T1]*b[T1],R[T1]=C1}return this.conjugate(R,Y,H),this.transform(R,Y,r,S,H,k),this.conjugate(r,S,H),this.normalize13b(r,H),Z.negative=J.negative^V.negative,Z.length=J.length+V.length,Z._strip()},Q.prototype.mul=function(J){var V=new Q(null);return V.words=Array(this.length+J.length),this.mulTo(J,V)},Q.prototype.mulf=function(J){var V=new Q(null);return V.words=Array(this.length+J.length),v(this,J,V)},Q.prototype.imul=function(J){return this.clone().mulTo(J,this)},Q.prototype.imuln=function(J){var V=J<0;if(V)J=-J;C(typeof J==="number"),C(J<67108864);var Z=0;for(var H=0;H<this.length;H++){var k=(this.words[H]|0)*J,S=(k&67108863)+(Z&67108863);Z>>=26,Z+=k/67108864|0,Z+=S>>>26,this.words[H]=S&67108863}if(Z!==0)this.words[H]=Z,this.length++;return this.length=J===0?1:this.length,V?this.ineg():this},Q.prototype.muln=function(J){return this.clone().imuln(J)},Q.prototype.sqr=function(){return this.mul(this)},Q.prototype.isqr=function(){return this.imul(this.clone())},Q.prototype.pow=function(J){var V=E(J);if(V.length===0)return new Q(1);var Z=this;for(var H=0;H<V.length;H++,Z=Z.sqr())if(V[H]!==0)break;if(++H<V.length)for(var k=Z.sqr();H<V.length;H++,k=k.sqr()){if(V[H]===0)continue;Z=Z.mul(k)}return Z},Q.prototype.iushln=function(J){C(typeof J==="number"&&J>=0);var V=J%26,Z=(J-V)/26,H=67108863>>>26-V<<26-V,k;if(V!==0){var S=0;for(k=0;k<this.length;k++){var I=this.words[k]&H,R=(this.words[k]|0)-I<<V;this.words[k]=R|S,S=I>>>26-V}if(S)this.words[k]=S,this.length++}if(Z!==0){for(k=this.length-1;k>=0;k--)this.words[k+Z]=this.words[k];for(k=0;k<Z;k++)this.words[k]=0;this.length+=Z}return this._strip()},Q.prototype.ishln=function(J){return C(this.negative===0),this.iushln(J)},Q.prototype.iushrn=function(J,V,Z){C(typeof J==="number"&&J>=0);var H;if(V)H=(V-V%26)/26;else H=0;var k=J%26,S=Math.min((J-k)/26,this.length),I=67108863^67108863>>>k<<k,R=Z;if(H-=S,H=Math.max(0,H),R){for(var Y=0;Y<S;Y++)R.words[Y]=this.words[Y];R.length=S}if(S===0);else if(this.length>S){this.length-=S;for(Y=0;Y<this.length;Y++)this.words[Y]=this.words[Y+S]}else this.words[0]=0,this.length=1;var D=0;for(Y=this.length-1;Y>=0&&(D!==0||Y>=H);Y--){var b=this.words[Y]|0;this.words[Y]=D<<26-k|b>>>k,D=b&I}if(R&&D!==0)R.words[R.length++]=D;if(this.length===0)this.words[0]=0,this.length=1;return this._strip()},Q.prototype.ishrn=function(J,V,Z){return C(this.negative===0),this.iushrn(J,V,Z)},Q.prototype.shln=function(J){return this.clone().ishln(J)},Q.prototype.ushln=function(J){return this.clone().iushln(J)},Q.prototype.shrn=function(J){return this.clone().ishrn(J)},Q.prototype.ushrn=function(J){return this.clone().iushrn(J)},Q.prototype.testn=function(J){C(typeof J==="number"&&J>=0);var V=J%26,Z=(J-V)/26,H=1<<V;if(this.length<=Z)return!1;var k=this.words[Z];return!!(k&H)},Q.prototype.imaskn=function(J){C(typeof J==="number"&&J>=0);var V=J%26,Z=(J-V)/26;if(C(this.negative===0,"imaskn works only with positive numbers"),this.length<=Z)return this;if(V!==0)Z++;if(this.length=Math.min(Z,this.length),V!==0){var H=67108863^67108863>>>V<<V;this.words[this.length-1]&=H}return this._strip()},Q.prototype.maskn=function(J){return this.clone().imaskn(J)},Q.prototype.iaddn=function(J){if(C(typeof J==="number"),C(J<67108864),J<0)return this.isubn(-J);if(this.negative!==0){if(this.length===1&&(this.words[0]|0)<=J)return this.words[0]=J-(this.words[0]|0),this.negative=0,this;return this.negative=0,this.isubn(J),this.negative=1,this}return this._iaddn(J)},Q.prototype._iaddn=function(J){this.words[0]+=J;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},Q.prototype.isubn=function(J){if(C(typeof J==="number"),C(J<67108864),J<0)return this.iaddn(-J);if(this.negative!==0)return this.negative=0,this.iaddn(J),this.negative=1,this;if(this.words[0]-=J,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()},Q.prototype.addn=function(J){return this.clone().iaddn(J)},Q.prototype.subn=function(J){return this.clone().isubn(J)},Q.prototype.iabs=function(){return this.negative=0,this},Q.prototype.abs=function(){return this.clone().iabs()},Q.prototype._ishlnsubmul=function(J,V,Z){var H=J.length+Z,k;this._expand(H);var S,I=0;for(k=0;k<J.length;k++){S=(this.words[k+Z]|0)+I;var R=(J.words[k]|0)*V;S-=R&67108863,I=(S>>26)-(R/67108864|0),this.words[k+Z]=S&67108863}for(;k<this.length-Z;k++)S=(this.words[k+Z]|0)+I,I=S>>26,this.words[k+Z]=S&67108863;if(I===0)return this._strip();C(I===-1),I=0;for(k=0;k<this.length;k++)S=-(this.words[k]|0)+I,I=S>>26,this.words[k]=S&67108863;return this.negative=1,this._strip()},Q.prototype._wordDiv=function(J,V){var Z=this.length-J.length,H=this.clone(),k=J,S=k.words[k.length-1]|0,I=this._countBits(S);if(Z=26-I,Z!==0)k=k.ushln(Z),H.iushln(Z),S=k.words[k.length-1]|0;var R=H.length-k.length,Y;if(V!=="mod"){Y=new Q(null),Y.length=R+1,Y.words=Array(Y.length);for(var D=0;D<Y.length;D++)Y.words[D]=0}var b=H.clone()._ishlnsubmul(k,1,R);if(b.negative===0){if(H=b,Y)Y.words[R]=1}for(var i=R-1;i>=0;i--){var r=(H.words[k.length+i]|0)*67108864+(H.words[k.length+i-1]|0);r=Math.min(r/S|0,67108863),H._ishlnsubmul(k,r,i);while(H.negative!==0)if(r--,H.negative=0,H._ishlnsubmul(k,1,i),!H.isZero())H.negative^=1;if(Y)Y.words[i]=r}if(Y)Y._strip();if(H._strip(),V!=="div"&&Z!==0)H.iushrn(Z);return{div:Y||null,mod:H}},Q.prototype.divmod=function(J,V,Z){if(C(!J.isZero()),this.isZero())return{div:new Q(0),mod:new Q(0)};var H,k,S;if(this.negative!==0&&J.negative===0){if(S=this.neg().divmod(J,V),V!=="mod")H=S.div.neg();if(V!=="div"){if(k=S.mod.neg(),Z&&k.negative!==0)k.iadd(J)}return{div:H,mod:k}}if(this.negative===0&&J.negative!==0){if(S=this.divmod(J.neg(),V),V!=="mod")H=S.div.neg();return{div:H,mod:S.mod}}if((this.negative&J.negative)!==0){if(S=this.neg().divmod(J.neg(),V),V!=="div"){if(k=S.mod.neg(),Z&&k.negative!==0)k.isub(J)}return{div:S.div,mod:k}}if(J.length>this.length||this.cmp(J)<0)return{div:new Q(0),mod:this};if(J.length===1){if(V==="div")return{div:this.divn(J.words[0]),mod:null};if(V==="mod")return{div:null,mod:new Q(this.modrn(J.words[0]))};return{div:this.divn(J.words[0]),mod:new Q(this.modrn(J.words[0]))}}return this._wordDiv(J,V)},Q.prototype.div=function(J){return this.divmod(J,"div",!1).div},Q.prototype.mod=function(J){return this.divmod(J,"mod",!1).mod},Q.prototype.umod=function(J){return this.divmod(J,"mod",!0).mod},Q.prototype.divRound=function(J){var V=this.divmod(J);if(V.mod.isZero())return V.div;var Z=V.div.negative!==0?V.mod.isub(J):V.mod,H=J.ushrn(1),k=J.andln(1),S=Z.cmp(H);if(S<0||k===1&&S===0)return V.div;return V.div.negative!==0?V.div.isubn(1):V.div.iaddn(1)},Q.prototype.modrn=function(J){var V=J<0;if(V)J=-J;C(J<=67108863);var Z=67108864%J,H=0;for(var k=this.length-1;k>=0;k--)H=(Z*H+(this.words[k]|0))%J;return V?-H:H},Q.prototype.modn=function(J){return this.modrn(J)},Q.prototype.idivn=function(J){var V=J<0;if(V)J=-J;C(J<=67108863);var Z=0;for(var H=this.length-1;H>=0;H--){var k=(this.words[H]|0)+Z*67108864;this.words[H]=k/J|0,Z=k%J}return this._strip(),V?this.ineg():this},Q.prototype.divn=function(J){return this.clone().idivn(J)},Q.prototype.egcd=function(J){C(J.negative===0),C(!J.isZero());var V=this,Z=J.clone();if(V.negative!==0)V=V.umod(J);else V=V.clone();var H=new Q(1),k=new Q(0),S=new Q(0),I=new Q(1),R=0;while(V.isEven()&&Z.isEven())V.iushrn(1),Z.iushrn(1),++R;var Y=Z.clone(),D=V.clone();while(!V.isZero()){for(var b=0,i=1;(V.words[0]&i)===0&&b<26;++b,i<<=1);if(b>0){V.iushrn(b);while(b-- >0){if(H.isOdd()||k.isOdd())H.iadd(Y),k.isub(D);H.iushrn(1),k.iushrn(1)}}for(var r=0,T1=1;(Z.words[0]&T1)===0&&r<26;++r,T1<<=1);if(r>0){Z.iushrn(r);while(r-- >0){if(S.isOdd()||I.isOdd())S.iadd(Y),I.isub(D);S.iushrn(1),I.iushrn(1)}}if(V.cmp(Z)>=0)V.isub(Z),H.isub(S),k.isub(I);else Z.isub(V),S.isub(H),I.isub(k)}return{a:S,b:I,gcd:Z.iushln(R)}},Q.prototype._invmp=function(J){C(J.negative===0),C(!J.isZero());var V=this,Z=J.clone();if(V.negative!==0)V=V.umod(J);else V=V.clone();var H=new Q(1),k=new Q(0),S=Z.clone();while(V.cmpn(1)>0&&Z.cmpn(1)>0){for(var I=0,R=1;(V.words[0]&R)===0&&I<26;++I,R<<=1);if(I>0){V.iushrn(I);while(I-- >0){if(H.isOdd())H.iadd(S);H.iushrn(1)}}for(var Y=0,D=1;(Z.words[0]&D)===0&&Y<26;++Y,D<<=1);if(Y>0){Z.iushrn(Y);while(Y-- >0){if(k.isOdd())k.iadd(S);k.iushrn(1)}}if(V.cmp(Z)>=0)V.isub(Z),H.isub(k);else Z.isub(V),k.isub(H)}var b;if(V.cmpn(1)===0)b=H;else b=k;if(b.cmpn(0)<0)b.iadd(J);return b},Q.prototype.gcd=function(J){if(this.isZero())return J.abs();if(J.isZero())return this.abs();var V=this.clone(),Z=J.clone();V.negative=0,Z.negative=0;for(var H=0;V.isEven()&&Z.isEven();H++)V.iushrn(1),Z.iushrn(1);do{while(V.isEven())V.iushrn(1);while(Z.isEven())Z.iushrn(1);var k=V.cmp(Z);if(k<0){var S=V;V=Z,Z=S}else if(k===0||Z.cmpn(1)===0)break;V.isub(Z)}while(!0);return Z.iushln(H)},Q.prototype.invm=function(J){return this.egcd(J).a.umod(J)},Q.prototype.isEven=function(){return(this.words[0]&1)===0},Q.prototype.isOdd=function(){return(this.words[0]&1)===1},Q.prototype.andln=function(J){return this.words[0]&J},Q.prototype.bincn=function(J){C(typeof J==="number");var V=J%26,Z=(J-V)/26,H=1<<V;if(this.length<=Z)return this._expand(Z+1),this.words[Z]|=H,this;var k=H;for(var S=Z;k!==0&&S<this.length;S++){var I=this.words[S]|0;I+=k,k=I>>>26,I&=67108863,this.words[S]=I}if(k!==0)this.words[S]=k,this.length++;return this},Q.prototype.isZero=function(){return this.length===1&&this.words[0]===0},Q.prototype.cmpn=function(J){var V=J<0;if(this.negative!==0&&!V)return-1;if(this.negative===0&&V)return 1;this._strip();var Z;if(this.length>1)Z=1;else{if(V)J=-J;C(J<=67108863,"Number is too big");var H=this.words[0]|0;Z=H===J?0:H<J?-1:1}if(this.negative!==0)return-Z|0;return Z},Q.prototype.cmp=function(J){if(this.negative!==0&&J.negative===0)return-1;if(this.negative===0&&J.negative!==0)return 1;var V=this.ucmp(J);if(this.negative!==0)return-V|0;return V},Q.prototype.ucmp=function(J){if(this.length>J.length)return 1;if(this.length<J.length)return-1;var V=0;for(var Z=this.length-1;Z>=0;Z--){var H=this.words[Z]|0,k=J.words[Z]|0;if(H===k)continue;if(H<k)V=-1;else if(H>k)V=1;break}return V},Q.prototype.gtn=function(J){return this.cmpn(J)===1},Q.prototype.gt=function(J){return this.cmp(J)===1},Q.prototype.gten=function(J){return this.cmpn(J)>=0},Q.prototype.gte=function(J){return this.cmp(J)>=0},Q.prototype.ltn=function(J){return this.cmpn(J)===-1},Q.prototype.lt=function(J){return this.cmp(J)===-1},Q.prototype.lten=function(J){return this.cmpn(J)<=0},Q.prototype.lte=function(J){return this.cmp(J)<=0},Q.prototype.eqn=function(J){return this.cmpn(J)===0},Q.prototype.eq=function(J){return this.cmp(J)===0},Q.red=function(J){return new c(J)},Q.prototype.toRed=function(J){return C(!this.red,"Already a number in reduction context"),C(this.negative===0,"red works only with positives"),J.convertTo(this)._forceRed(J)},Q.prototype.fromRed=function(){return C(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},Q.prototype._forceRed=function(J){return this.red=J,this},Q.prototype.forceRed=function(J){return C(!this.red,"Already a number in reduction context"),this._forceRed(J)},Q.prototype.redAdd=function(J){return C(this.red,"redAdd works only with red numbers"),this.red.add(this,J)},Q.prototype.redIAdd=function(J){return C(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,J)},Q.prototype.redSub=function(J){return C(this.red,"redSub works only with red numbers"),this.red.sub(this,J)},Q.prototype.redISub=function(J){return C(this.red,"redISub works only with red numbers"),this.red.isub(this,J)},Q.prototype.redShl=function(J){return C(this.red,"redShl works only with red numbers"),this.red.shl(this,J)},Q.prototype.redMul=function(J){return C(this.red,"redMul works only with red numbers"),this.red._verify2(this,J),this.red.mul(this,J)},Q.prototype.redIMul=function(J){return C(this.red,"redMul works only with red numbers"),this.red._verify2(this,J),this.red.imul(this,J)},Q.prototype.redSqr=function(){return C(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},Q.prototype.redISqr=function(){return C(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},Q.prototype.redSqrt=function(){return C(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},Q.prototype.redInvm=function(){return C(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},Q.prototype.redNeg=function(){return C(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},Q.prototype.redPow=function(J){return C(this.red&&!J.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,J)};var f={k256:null,p224:null,p192:null,p25519:null};function u(j,J){this.name=j,this.p=new Q(J,16),this.n=this.p.bitLength(),this.k=new Q(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}u.prototype._tmp=function(){var J=new Q(null);return J.words=Array(Math.ceil(this.n/13)),J},u.prototype.ireduce=function(J){var V=J,Z;do this.split(V,this.tmp),V=this.imulK(V),V=V.iadd(this.tmp),Z=V.bitLength();while(Z>this.n);var H=Z<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},u.prototype.split=function(J,V){J.iushrn(this.n,0,V)},u.prototype.imulK=function(J){return J.imul(this.k)};function a(){u.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}P(a,u),a.prototype.split=function(J,V){var Z=4194303,H=Math.min(J.length,9);for(var k=0;k<H;k++)V.words[k]=J.words[k];if(V.length=H,J.length<=9){J.words[0]=0,J.length=1;return}var S=J.words[9];V.words[V.length++]=S&Z;for(k=10;k<J.length;k++){var I=J.words[k]|0;J.words[k-10]=(I&Z)<<4|S>>>22,S=I}if(S>>>=22,J.words[k-10]=S,S===0&&J.length>10)J.length-=10;else J.length-=9},a.prototype.imulK=function(J){J.words[J.length]=0,J.words[J.length+1]=0,J.length+=2;var V=0;for(var Z=0;Z<J.length;Z++){var H=J.words[Z]|0;V+=H*977,J.words[Z]=V&67108863,V=H*64+(V/67108864|0)}if(J.words[J.length-1]===0){if(J.length--,J.words[J.length-1]===0)J.length--}return J};function d(){u.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}P(d,u);function h(){u.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}P(h,u);function o(){u.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}P(o,u),o.prototype.imulK=function(J){var V=0;for(var Z=0;Z<J.length;Z++){var H=(J.words[Z]|0)*19+V,k=H&67108863;H>>>=26,J.words[Z]=k,V=H}if(V!==0)J.words[J.length++]=V;return J},Q._prime=function(J){if(f[J])return f[J];var V;if(J==="k256")V=new a;else if(J==="p224")V=new d;else if(J==="p192")V=new h;else if(J==="p25519")V=new o;else throw Error("Unknown prime "+J);return f[J]=V,V};function c(j){if(typeof j==="string"){var J=Q._prime(j);this.m=J.p,this.prime=J}else C(j.gtn(1),"modulus must be greater than 1"),this.m=j,this.prime=null}c.prototype._verify1=function(J){C(J.negative===0,"red works only with positives"),C(J.red,"red works only with red numbers")},c.prototype._verify2=function(J,V){C((J.negative|V.negative)===0,"red works only with positives"),C(J.red&&J.red===V.red,"red works only with red numbers")},c.prototype.imod=function(J){if(this.prime)return this.prime.ireduce(J)._forceRed(this);return X(J,J.umod(this.m)._forceRed(this)),J},c.prototype.neg=function(J){if(J.isZero())return J.clone();return this.m.sub(J)._forceRed(this)},c.prototype.add=function(J,V){this._verify2(J,V);var Z=J.add(V);if(Z.cmp(this.m)>=0)Z.isub(this.m);return Z._forceRed(this)},c.prototype.iadd=function(J,V){this._verify2(J,V);var Z=J.iadd(V);if(Z.cmp(this.m)>=0)Z.isub(this.m);return Z},c.prototype.sub=function(J,V){this._verify2(J,V);var Z=J.sub(V);if(Z.cmpn(0)<0)Z.iadd(this.m);return Z._forceRed(this)},c.prototype.isub=function(J,V){this._verify2(J,V);var Z=J.isub(V);if(Z.cmpn(0)<0)Z.iadd(this.m);return Z},c.prototype.shl=function(J,V){return this._verify1(J),this.imod(J.ushln(V))},c.prototype.imul=function(J,V){return this._verify2(J,V),this.imod(J.imul(V))},c.prototype.mul=function(J,V){return this._verify2(J,V),this.imod(J.mul(V))},c.prototype.isqr=function(J){return this.imul(J,J.clone())},c.prototype.sqr=function(J){return this.mul(J,J)},c.prototype.sqrt=function(J){if(J.isZero())return J.clone();var V=this.m.andln(3);if(C(V%2===1),V===3){var Z=this.m.add(new Q(1)).iushrn(2);return this.pow(J,Z)}var H=this.m.subn(1),k=0;while(!H.isZero()&&H.andln(1)===0)k++,H.iushrn(1);C(!H.isZero());var S=new Q(1).toRed(this),I=S.redNeg(),R=this.m.subn(1).iushrn(1),Y=this.m.bitLength();Y=new Q(2*Y*Y).toRed(this);while(this.pow(Y,R).cmp(I)!==0)Y.redIAdd(I);var D=this.pow(Y,H),b=this.pow(J,H.addn(1).iushrn(1)),i=this.pow(J,H),r=k;while(i.cmp(S)!==0){var T1=i;for(var C1=0;T1.cmp(S)!==0;C1++)T1=T1.redSqr();C(C1<r);var P1=this.pow(D,new Q(1).iushln(r-C1-1));b=b.redMul(P1),D=P1.redSqr(),i=i.redMul(D),r=C1}return b},c.prototype.invm=function(J){var V=J._invmp(this.m);if(V.negative!==0)return V.negative=0,this.imod(V).redNeg();else return this.imod(V)},c.prototype.pow=function(J,V){if(V.isZero())return new Q(1).toRed(this);if(V.cmpn(1)===0)return J.clone();var Z=4,H=Array(1<<Z);H[0]=new Q(1).toRed(this),H[1]=J;for(var k=2;k<H.length;k++)H[k]=this.mul(H[k-1],J);var S=H[0],I=0,R=0,Y=V.bitLength()%26;if(Y===0)Y=26;for(k=V.length-1;k>=0;k--){var D=V.words[k];for(var b=Y-1;b>=0;b--){var i=D>>b&1;if(S!==H[0])S=this.sqr(S);if(i===0&&I===0){R=0;continue}if(I<<=1,I|=i,R++,R!==Z&&(k!==0||b!==0))continue;S=this.mul(S,H[I]),R=0,I=0}Y=26}return S},c.prototype.convertTo=function(J){var V=J.umod(this.m);return V===J?V.clone():V},c.prototype.convertFrom=function(J){var V=J.clone();return V.red=null,V},Q.mont=function(J){return new x(J)};function x(j){if(c.call(this,j),this.shift=this.m.bitLength(),this.shift%26!==0)this.shift+=26-this.shift%26;this.r=new Q(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)}P(x,c),x.prototype.convertTo=function(J){return this.imod(J.ushln(this.shift))},x.prototype.convertFrom=function(J){var V=this.imod(J.mul(this.rinv));return V.red=null,V},x.prototype.imul=function(J,V){if(J.isZero()||V.isZero())return J.words[0]=0,J.length=1,J;var Z=J.imul(V),H=Z.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),k=Z.isub(H).iushrn(this.shift),S=k;if(k.cmp(this.m)>=0)S=k.isub(this.m);else if(k.cmpn(0)<0)S=k.iadd(this.m);return S._forceRed(this)},x.prototype.mul=function(J,V){if(J.isZero()||V.isZero())return new Q(0)._forceRed(this);var Z=J.mul(V),H=Z.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),k=Z.isub(H).iushrn(this.shift),S=k;if(k.cmp(this.m)>=0)S=k.isub(this.m);else if(k.cmpn(0)<0)S=k.iadd(this.m);return S._forceRed(this)},x.prototype.invm=function(J){var V=this.imod(J._invmp(this.m).mul(this.r2));return V._forceRed(this)}})(typeof jQ>"u"||jQ,I9)});var w9=V0((FQ,L9)=>{/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var QC=(x8(),R8(i6)),b0=QC.Buffer;function N9(T,A){for(var C in T)A[C]=T[C]}if(b0.from&&b0.alloc&&b0.allocUnsafe&&b0.allocUnsafeSlow)L9.exports=QC;else N9(QC,FQ),FQ.Buffer=U8;function U8(T,A,C){return b0(T,A,C)}U8.prototype=Object.create(b0.prototype);N9(b0,U8);U8.from=function(T,A,C){if(typeof T==="number")throw TypeError("Argument must not be a number");return b0(T,A,C)};U8.alloc=function(T,A,C){if(typeof T!=="number")throw TypeError("Argument must be a number");var P=b0(T);if(A!==void 0)if(typeof C==="string")P.fill(A,C);else P.fill(A);else P.fill(0);return P};U8.allocUnsafe=function(T){if(typeof T!=="number")throw TypeError("Argument must be a number");return b0(T)};U8.allocUnsafeSlow=function(T){if(typeof T!=="number")throw TypeError("Argument must be a number");return QC.SlowBuffer(T)}});var B9=V0((Mh,E9)=>{var WC=w9().Buffer;function kF(T){if(T.length>=255)throw TypeError("Alphabet too long");var A=new Uint8Array(256);for(var C=0;C<A.length;C++)A[C]=255;for(var P=0;P<T.length;P++){var Q=T.charAt(P),W=Q.charCodeAt(0);if(A[W]!==255)throw TypeError(Q+" is ambiguous");A[W]=P}var G=T.length,U=T.charAt(0),$=Math.log(G)/Math.log(256),X=Math.log(256)/Math.log(G);function q(z){if(Array.isArray(z)||z instanceof Uint8Array)z=WC.from(z);if(!WC.isBuffer(z))throw TypeError("Expected Buffer");if(z.length===0)return"";var M=0,E=0,L=0,B=z.length;while(L!==B&&z[L]===0)L++,M++;var m=(B-L)*X+1>>>0,v=new Uint8Array(m);while(L!==B){var l=z[L],f=0;for(var u=m-1;(l!==0||f<E)&&u!==-1;u--,f++)l+=256*v[u]>>>0,v[u]=l%G>>>0,l=l/G>>>0;if(l!==0)throw Error("Non-zero carry");E=f,L++}var a=m-E;while(a!==m&&v[a]===0)a++;var d=U.repeat(M);for(;a<m;++a)d+=T.charAt(v[a]);return d}function K(z){if(typeof z!=="string")throw TypeError("Expected String");if(z.length===0)return WC.alloc(0);var M=0,E=0,L=0;while(z[M]===U)E++,M++;var B=(z.length-M)*$+1>>>0,m=new Uint8Array(B);while(M<z.length){var v=z.charCodeAt(M);if(v>255)return;var l=A[v];if(l===255)return;var f=0;for(var u=B-1;(l!==0||f<L)&&u!==-1;u--,f++)l+=G*m[u]>>>0,m[u]=l%256>>>0,l=l/256>>>0;if(l!==0)throw Error("Non-zero carry");L=f,M++}var a=B-L;while(a!==B&&m[a]===0)a++;var d=WC.allocUnsafe(E+(B-a));d.fill(0,0,E);var h=E;while(a!==B)d[h++]=m[a++];return d}function F(z){var M=K(z);if(M)return M;throw Error("Non-base"+G+" character")}return{encode:q,decodeUnsafe:K,decode:F}}E9.exports=kF});var DQ=V0((Ih,O9)=>{var jF=B9(),RF="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";O9.exports=jF(RF)});var _9={};k4(_9,{TextEncoder:()=>$C,TextDecoder:()=>UC});function JA(T,A,C){return A<=T&&T<=C}function VC(T){if(T===void 0)return{};if(T===Object(T))return T;throw TypeError("Could not convert argument to dictionary")}function FF(T){var A=String(T),C=A.length,P=0,Q=[];while(P<C){var W=A.charCodeAt(P);if(W<55296||W>57343)Q.push(W);else if(56320<=W&&W<=57343)Q.push(65533);else if(55296<=W&&W<=56319)if(P===C-1)Q.push(65533);else{var G=T.charCodeAt(P+1);if(56320<=G&&G<=57343){var U=W&1023,$=G&1023;Q.push(65536+(U<<10)+$),P+=1}else Q.push(65533)}P+=1}return Q}function DF(T){var A="";for(var C=0;C<T.length;++C){var P=T[C];if(P<=65535)A+=String.fromCharCode(P);else P-=65536,A+=String.fromCharCode((P>>10)+55296,(P&1023)+56320)}return A}function MQ(T){this.tokens=[].slice.call(T)}function SQ(T,A){if(T)throw TypeError("Decoder error");return A||65533}function zF(){}function SF(){}function UC(T,A){if(!(this instanceof UC))return new UC(T,A);if(T=T!==void 0?String(T).toLowerCase():JC,T!==JC)throw Error("Encoding not supported. Only utf-8 is supported");A=VC(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 $C(T,A){if(!(this instanceof $C))return new $C(T,A);if(T=T!==void 0?String(T).toLowerCase():JC,T!==JC)throw Error("Encoding not supported. Only utf-8 is supported");A=VC(A),this._streaming=!1,this._encoder=null,this._options={fatal:Boolean(A.fatal)},Object.defineProperty(this,"encoding",{value:"utf-8"})}function MF(T){var A=T.fatal,C=0,P=0,Q=0,W=128,G=191;this.handler=function(U,$){if($===GC&&Q!==0)return Q=0,SQ(A);if($===GC)return l8;if(Q===0){if(JA($,0,127))return $;if(JA($,194,223))Q=1,C=$-192;else if(JA($,224,239)){if($===224)W=160;if($===237)G=159;Q=2,C=$-224}else if(JA($,240,244)){if($===240)W=144;if($===244)G=143;Q=3,C=$-240}else return SQ(A);return C=C<<6*Q,null}if(!JA($,W,G))return C=Q=P=0,W=128,G=191,U.prepend($),SQ(A);if(W=128,G=191,P+=1,C+=$-128<<6*(Q-P),P!==Q)return null;var X=C;return C=Q=P=0,X}}function IF(T){var A=T.fatal;this.handler=function(C,P){if(P===GC)return l8;if(JA(P,0,127))return P;var Q,W;if(JA(P,128,2047))Q=1,W=192;else if(JA(P,2048,65535))Q=2,W=224;else if(JA(P,65536,1114111))Q=3,W=240;var G=[(P>>6*Q)+W];while(Q>0){var U=P>>6*(Q-1);G.push(128|U&63),Q-=1}return G}}var GC=-1,l8=-1,JC="utf-8";var x9=_T(()=>{MQ.prototype={endOfStream:function(){return!this.tokens.length},read:function(){if(!this.tokens.length)return GC;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)}};zF.prototype={handler:function(T,A){}};SF.prototype={handler:function(T,A){}};UC.prototype={decode:function(A,C){var P;if(typeof A==="object"&&A instanceof ArrayBuffer)P=new Uint8Array(A);else if(typeof A==="object"&&"buffer"in A&&A.buffer instanceof ArrayBuffer)P=new Uint8Array(A.buffer,A.byteOffset,A.byteLength);else P=new Uint8Array(0);if(C=VC(C),!this._streaming)this._decoder=new MF({fatal:this._fatal}),this._BOMseen=!1;this._streaming=Boolean(C.stream);var Q=new MQ(P),W=[],G;while(!Q.endOfStream()){if(G=this._decoder.handler(Q,Q.read()),G===l8)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(Q,Q.read()),G===l8)break;if(G===null)continue;if(Array.isArray(G))W.push.apply(W,G);else W.push(G)}while(!Q.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 DF(W)}};$C.prototype={encode:function(A,C){if(A=A?String(A):"",C=VC(C),!this._streaming)this._encoder=new IF(this._options);this._streaming=Boolean(C.stream);var P=[],Q=new MQ(FF(A)),W;while(!Q.endOfStream()){if(W=this._encoder.handler(Q,Q.read()),W===l8)break;if(Array.isArray(W))P.push.apply(P,W);else P.push(W)}if(!this._streaming){while(!0){if(W=this._encoder.handler(Q,Q.read()),W===l8)break;if(Array.isArray(W))P.push.apply(P,W);else P.push(W)}this._encoder=null}return new Uint8Array(P)}}});var y9=V0((k1)=>{var NF=k1&&k1.__createBinding||(Object.create?function(T,A,C,P){if(P===void 0)P=C;Object.defineProperty(T,P,{enumerable:!0,get:function(){return A[C]}})}:function(T,A,C,P){if(P===void 0)P=C;T[P]=A[C]}),LF=k1&&k1.__setModuleDefault||(Object.create?function(T,A){Object.defineProperty(T,"default",{enumerable:!0,value:A})}:function(T,A){T.default=A}),l0=k1&&k1.__decorate||function(T,A,C,P){var Q=arguments.length,W=Q<3?A:P===null?P=Object.getOwnPropertyDescriptor(A,C):P,G;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")W=Reflect.decorate(T,A,C,P);else for(var U=T.length-1;U>=0;U--)if(G=T[U])W=(Q<3?G(W):Q>3?G(A,C,W):G(A,C))||W;return Q>3&&W&&Object.defineProperty(A,C,W),W},wF=k1&&k1.__importStar||function(T){if(T&&T.__esModule)return T;var A={};if(T!=null){for(var C in T)if(C!=="default"&&Object.hasOwnProperty.call(T,C))NF(A,T,C)}return LF(A,T),A},h9=k1&&k1.__importDefault||function(T){return T&&T.__esModule?T:{default:T}};Object.defineProperty(k1,"__esModule",{value:!0});k1.deserializeUnchecked=k1.deserialize=k1.serialize=k1.BinaryReader=k1.BinaryWriter=k1.BorshError=k1.baseDecode=k1.baseEncode=void 0;var xA=h9(RQ()),m9=h9(DQ()),EF=wF((x9(),R8(_9))),BF=typeof TextDecoder!=="function"?EF.TextDecoder:TextDecoder,OF=new BF("utf-8",{fatal:!0});function _F(T){if(typeof T==="string")T=Buffer.from(T,"utf8");return m9.default.encode(Buffer.from(T))}k1.baseEncode=_F;function xF(T){return Buffer.from(m9.default.decode(T))}k1.baseDecode=xF;var IQ=1024;class hT 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(".")}}k1.BorshError=hT;class NQ{constructor(){this.buf=Buffer.alloc(IQ),this.length=0}maybeResize(){if(this.buf.length<16+this.length)this.buf=Buffer.concat([this.buf,Buffer.alloc(IQ)])}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 xA.default(T).toArray("le",8)))}writeU128(T){this.maybeResize(),this.writeBuffer(Buffer.from(new xA.default(T).toArray("le",16)))}writeU256(T){this.maybeResize(),this.writeBuffer(Buffer.from(new xA.default(T).toArray("le",32)))}writeU512(T){this.maybeResize(),this.writeBuffer(Buffer.from(new xA.default(T).toArray("le",64)))}writeBuffer(T){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),T,Buffer.alloc(IQ)]),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 C of T)this.maybeResize(),A(C)}toArray(){return this.buf.subarray(0,this.length)}}k1.BinaryWriter=NQ;function p0(T,A,C){let P=C.value;C.value=function(...Q){try{return P.apply(this,Q)}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 hT("Reached the end of buffer when deserializing")}throw W}}}class A0{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 xA.default(T,"le")}readU128(){let T=this.readBuffer(16);return new xA.default(T,"le")}readU256(){let T=this.readBuffer(32);return new xA.default(T,"le")}readU512(){let T=this.readBuffer(64);return new xA.default(T,"le")}readBuffer(T){if(this.offset+T>this.buf.length)throw new hT(`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 OF.decode(A)}catch(C){throw new hT(`Error decoding UTF-8 string: ${C}`)}}readFixedArray(T){return new Uint8Array(this.readBuffer(T))}readArray(T){let A=this.readU32(),C=Array();for(let P=0;P<A;++P)C.push(T());return C}}l0([p0],A0.prototype,"readU8",null);l0([p0],A0.prototype,"readU16",null);l0([p0],A0.prototype,"readU32",null);l0([p0],A0.prototype,"readU64",null);l0([p0],A0.prototype,"readU128",null);l0([p0],A0.prototype,"readU256",null);l0([p0],A0.prototype,"readU512",null);l0([p0],A0.prototype,"readString",null);l0([p0],A0.prototype,"readFixedArray",null);l0([p0],A0.prototype,"readArray",null);k1.BinaryReader=A0;function g9(T){return T.charAt(0).toUpperCase()+T.slice(1)}function $8(T,A,C,P,Q){try{if(typeof P==="string")Q[`write${g9(P)}`](C);else if(P instanceof Array)if(typeof P[0]==="number"){if(C.length!==P[0])throw new hT(`Expecting byte array of length ${P[0]}, but got ${C.length} bytes`);Q.writeFixedArray(C)}else if(P.length===2&&typeof P[1]==="number"){if(C.length!==P[1])throw new hT(`Expecting byte array of length ${P[1]}, but got ${C.length} bytes`);for(let W=0;W<P[1];W++)$8(T,null,C[W],P[0],Q)}else Q.writeArray(C,(W)=>{$8(T,A,W,P[0],Q)});else if(P.kind!==void 0)switch(P.kind){case"option":{if(C===null||C===void 0)Q.writeU8(0);else Q.writeU8(1),$8(T,A,C,P.type,Q);break}case"map":{Q.writeU32(C.size),C.forEach((W,G)=>{$8(T,A,G,P.key,Q),$8(T,A,W,P.value,Q)});break}default:throw new hT(`FieldType ${P} unrecognized`)}else v9(T,C,Q)}catch(W){if(W instanceof hT)W.addToFieldPath(A);throw W}}function v9(T,A,C){if(typeof A.borshSerialize==="function"){A.borshSerialize(C);return}let P=T.get(A.constructor);if(!P)throw new hT(`Class ${A.constructor.name} is missing in schema`);if(P.kind==="struct")P.fields.map(([Q,W])=>{$8(T,Q,A[Q],W,C)});else if(P.kind==="enum"){let Q=A[P.field];for(let W=0;W<P.values.length;++W){let[G,U]=P.values[W];if(G===Q){C.writeU8(W),$8(T,G,A[G],U,C);break}}}else throw new hT(`Unexpected schema kind: ${P.kind} for ${A.constructor.name}`)}function hF(T,A,C=NQ){let P=new C;return v9(T,A,P),P.toArray()}k1.serialize=hF;function V8(T,A,C,P){try{if(typeof C==="string")return P[`read${g9(C)}`]();if(C instanceof Array)if(typeof C[0]==="number")return P.readFixedArray(C[0]);else if(typeof C[1]==="number"){let Q=[];for(let W=0;W<C[1];W++)Q.push(V8(T,null,C[0],P));return Q}else return P.readArray(()=>V8(T,A,C[0],P));if(C.kind==="option"){if(P.readU8())return V8(T,A,C.type,P);return}if(C.kind==="map"){let Q=new Map,W=P.readU32();for(let G=0;G<W;G++){let U=V8(T,A,C.key,P),$=V8(T,A,C.value,P);Q.set(U,$)}return Q}return LQ(T,C,P)}catch(Q){if(Q instanceof hT)Q.addToFieldPath(A);throw Q}}function LQ(T,A,C){if(typeof A.borshDeserialize==="function")return A.borshDeserialize(C);let P=T.get(A);if(!P)throw new hT(`Class ${A.name} is missing in schema`);if(P.kind==="struct"){let Q={};for(let[W,G]of T.get(A).fields)Q[W]=V8(T,W,G,C);return new A(Q)}if(P.kind==="enum"){let Q=C.readU8();if(Q>=P.values.length)throw new hT(`Enum index: ${Q} is out of range`);let[W,G]=P.values[Q],U=V8(T,W,G,C);return new A({[W]:U})}throw new hT(`Unexpected schema kind: ${P.kind} for ${A.constructor.name}`)}function mF(T,A,C,P=A0){let Q=new P(C),W=LQ(T,A,Q);if(Q.offset<C.length)throw new hT(`Unexpected ${C.length-Q.offset} bytes after deserialized data`);return W}k1.deserialize=mF;function gF(T,A,C,P=A0){let Q=new P(C);return LQ(T,A,Q)}k1.deserializeUnchecked=gF});var UA=V0((b9)=>{Object.defineProperty(b9,"__esModule",{value:!0});b9.s16=b9.s8=b9.nu64be=b9.u48be=b9.u40be=b9.u32be=b9.u24be=b9.u16be=b9.nu64=b9.u48=b9.u40=b9.u32=b9.u24=b9.u16=b9.u8=b9.offset=b9.greedy=b9.Constant=b9.UTF8=b9.CString=b9.Blob=b9.Boolean=b9.BitField=b9.BitStructure=b9.VariantLayout=b9.Union=b9.UnionLayoutDiscriminator=b9.UnionDiscriminator=b9.Structure=b9.Sequence=b9.DoubleBE=b9.Double=b9.FloatBE=b9.Float=b9.NearInt64BE=b9.NearInt64=b9.NearUInt64BE=b9.NearUInt64=b9.IntBE=b9.Int=b9.UIntBE=b9.UInt=b9.OffsetLayout=b9.GreedyCount=b9.ExternalLayout=b9.bindConstructorLayout=b9.nameWithProperty=b9.Layout=b9.uint8ArrayToBuffer=b9.checkUint8Array=void 0;b9.constant=b9.utf8=b9.cstr=b9.blob=b9.unionLayoutDiscriminator=b9.union=b9.seq=b9.bits=b9.struct=b9.f64be=b9.f64=b9.f32be=b9.f32=b9.ns64be=b9.s48be=b9.s40be=b9.s32be=b9.s24be=b9.s16be=b9.ns64=b9.s48=b9.s40=b9.s32=b9.s24=void 0;var EQ=(x8(),R8(i6));function u8(T){if(!(T instanceof Uint8Array))throw TypeError("b must be a Uint8Array")}b9.checkUint8Array=u8;function U1(T){return u8(T),EQ.Buffer.from(T.buffer,T.byteOffset,T.length)}b9.uint8ArrayToBuffer=U1;class Z1{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}}b9.Layout=Z1;function BQ(T,A){if(A.property)return T+"["+A.property+"]";return T}b9.nameWithProperty=BQ;function vF(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 Z1))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(C,P){return A.encode(this,C,P)},writable:!0}),Object.defineProperty(T,"decode",{value(C,P){return A.decode(C,P)},writable:!0})}b9.bindConstructorLayout=vF;class iT extends Z1{isCount(){throw Error("ExternalLayout is abstract")}}b9.ExternalLayout=iT;class OQ extends iT{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){u8(T);let C=T.length-A;return Math.floor(C/this.elementSpan)}encode(T,A,C){return 0}}b9.GreedyCount=OQ;class YC extends iT{constructor(T,A=0,C){if(!(T instanceof Z1))throw TypeError("layout must be a Layout");if(!Number.isInteger(A))throw TypeError("offset must be integer or undefined");super(T.span,C||T.property);this.layout=T,this.offset=A}isCount(){return this.layout instanceof U0||this.layout instanceof j0}decode(T,A=0){return this.layout.decode(T,A+this.offset)}encode(T,A,C=0){return this.layout.encode(T,A,C+this.offset)}}b9.OffsetLayout=YC;class U0 extends Z1{constructor(T,A){super(T,A);if(6<this.span)throw RangeError("span must not exceed 6 bytes")}decode(T,A=0){return U1(T).readUIntLE(A,this.span)}encode(T,A,C=0){return U1(A).writeUIntLE(T,C,this.span),this.span}}b9.UInt=U0;class j0 extends Z1{constructor(T,A){super(T,A);if(6<this.span)throw RangeError("span must not exceed 6 bytes")}decode(T,A=0){return U1(T).readUIntBE(A,this.span)}encode(T,A,C=0){return U1(A).writeUIntBE(T,C,this.span),this.span}}b9.UIntBE=j0;class hA extends Z1{constructor(T,A){super(T,A);if(6<this.span)throw RangeError("span must not exceed 6 bytes")}decode(T,A=0){return U1(T).readIntLE(A,this.span)}encode(T,A,C=0){return U1(A).writeIntLE(T,C,this.span),this.span}}b9.Int=hA;class Y8 extends Z1{constructor(T,A){super(T,A);if(6<this.span)throw RangeError("span must not exceed 6 bytes")}decode(T,A=0){return U1(T).readIntBE(A,this.span)}encode(T,A,C=0){return U1(A).writeIntBE(T,C,this.span),this.span}}b9.IntBE=Y8;var wQ=Math.pow(2,32);function ZC(T){let A=Math.floor(T/wQ),C=T-A*wQ;return{hi32:A,lo32:C}}function qC(T,A){return T*wQ+A}class _Q extends Z1{constructor(T){super(8,T)}decode(T,A=0){let C=U1(T),P=C.readUInt32LE(A),Q=C.readUInt32LE(A+4);return qC(Q,P)}encode(T,A,C=0){let P=ZC(T),Q=U1(A);return Q.writeUInt32LE(P.lo32,C),Q.writeUInt32LE(P.hi32,C+4),8}}b9.NearUInt64=_Q;class xQ extends Z1{constructor(T){super(8,T)}decode(T,A=0){let C=U1(T),P=C.readUInt32BE(A),Q=C.readUInt32BE(A+4);return qC(P,Q)}encode(T,A,C=0){let P=ZC(T),Q=U1(A);return Q.writeUInt32BE(P.hi32,C),Q.writeUInt32BE(P.lo32,C+4),8}}b9.NearUInt64BE=xQ;class hQ extends Z1{constructor(T){super(8,T)}decode(T,A=0){let C=U1(T),P=C.readUInt32LE(A),Q=C.readInt32LE(A+4);return qC(Q,P)}encode(T,A,C=0){let P=ZC(T),Q=U1(A);return Q.writeUInt32LE(P.lo32,C),Q.writeInt32LE(P.hi32,C+4),8}}b9.NearInt64=hQ;class mQ extends Z1{constructor(T){super(8,T)}decode(T,A=0){let C=U1(T),P=C.readInt32BE(A),Q=C.readUInt32BE(A+4);return qC(P,Q)}encode(T,A,C=0){let P=ZC(T),Q=U1(A);return Q.writeInt32BE(P.hi32,C),Q.writeUInt32BE(P.lo32,C+4),8}}b9.NearInt64BE=mQ;class gQ extends Z1{constructor(T){super(4,T)}decode(T,A=0){return U1(T).readFloatLE(A)}encode(T,A,C=0){return U1(A).writeFloatLE(T,C),4}}b9.Float=gQ;class vQ extends Z1{constructor(T){super(4,T)}decode(T,A=0){return U1(T).readFloatBE(A)}encode(T,A,C=0){return U1(A).writeFloatBE(T,C),4}}b9.FloatBE=vQ;class yQ extends Z1{constructor(T){super(8,T)}decode(T,A=0){return U1(T).readDoubleLE(A)}encode(T,A,C=0){return U1(A).writeDoubleLE(T,C),8}}b9.Double=yQ;class bQ extends Z1{constructor(T){super(8,T)}decode(T,A=0){return U1(T).readDoubleBE(A)}encode(T,A,C=0){return U1(A).writeDoubleBE(T,C),8}}b9.DoubleBE=bQ;class lQ extends Z1{constructor(T,A,C){if(!(T instanceof Z1))throw TypeError("elementLayout must be a Layout");if(!(A instanceof iT&&A.isCount()||Number.isInteger(A)&&0<=A))throw TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let P=-1;if(!(A instanceof iT)&&0<T.span)P=A*T.span;super(P,C);this.elementLayout=T,this.count=A}getSpan(T,A=0){if(0<=this.span)return this.span;let C=0,P=this.count;if(P instanceof iT)P=P.decode(T,A);if(0<this.elementLayout.span)C=P*this.elementLayout.span;else{let Q=0;while(Q<P)C+=this.elementLayout.getSpan(T,A+C),++Q}return C}decode(T,A=0){let C=[],P=0,Q=this.count;if(Q instanceof iT)Q=Q.decode(T,A);while(P<Q)C.push(this.elementLayout.decode(T,A)),A+=this.elementLayout.getSpan(T,A),P+=1;return C}encode(T,A,C=0){let P=this.elementLayout,Q=T.reduce((W,G)=>{return W+P.encode(G,A,C+W)},0);if(this.count instanceof iT)this.count.encode(T.length,A,C);return Q}}b9.Sequence=lQ;class pQ extends Z1{constructor(T,A,C){if(!(Array.isArray(T)&&T.reduce((Q,W)=>Q&&W instanceof Z1,!0)))throw TypeError("fields must be array of Layout instances");if(typeof A==="boolean"&&C===void 0)C=A,A=void 0;for(let Q of T)if(0>Q.span&&Q.property===void 0)throw Error("fields cannot contain unnamed variable-length layout");let P=-1;try{P=T.reduce((Q,W)=>Q+W.getSpan(),0)}catch(Q){}super(P,A);this.fields=T,this.decodePrefixes=!!C}getSpan(T,A=0){if(0<=this.span)return this.span;let C=0;try{C=this.fields.reduce((P,Q)=>{let W=Q.getSpan(T,A);return A+=W,P+W},0)}catch(P){throw RangeError("indeterminate span")}return C}decode(T,A=0){u8(T);let C=this.makeDestinationObject();for(let P of this.fields){if(P.property!==void 0)C[P.property]=P.decode(T,A);if(A+=P.getSpan(T,A),this.decodePrefixes&&T.length===A)break}return C}encode(T,A,C=0){let P=C,Q=0,W=0;for(let G of this.fields){let U=G.span;if(W=0<U?U:0,G.property!==void 0){let $=T[G.property];if($!==void 0){if(W=G.encode($,A,C),0>U)U=G.getSpan(A,C)}}Q=C,C+=U}return Q+W-P}fromArray(T){let A=this.makeDestinationObject();for(let C of this.fields)if(C.property!==void 0&&0<T.length)A[C.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 C of this.fields){if(C.property===T)return A;if(0>C.span)A=-1;else if(0<=A)A+=C.span}return}}b9.Structure=pQ;class XC{constructor(T){this.property=T}decode(T,A){throw Error("UnionDiscriminator is abstract")}encode(T,A,C){throw Error("UnionDiscriminator is abstract")}}b9.UnionDiscriminator=XC;class O2 extends XC{constructor(T,A){if(!(T instanceof iT&&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,C){return this.layout.encode(T,A,C)}}b9.UnionLayoutDiscriminator=O2;class HC extends Z1{constructor(T,A,C){let P;if(T instanceof U0||T instanceof j0)P=new O2(new YC(T));else if(T instanceof iT&&T.isCount())P=new O2(T);else if(!(T instanceof XC))throw TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");else P=T;if(A===void 0)A=null;if(!(A===null||A instanceof Z1))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 Q=-1;if(A){if(Q=A.span,0<=Q&&(T instanceof U0||T instanceof j0))Q+=P.layout.span}super(Q,C);this.discriminator=P,this.usesPrefixDiscriminator=T instanceof U0||T instanceof j0,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 C=this.getVariant(T,A);if(!C)throw Error("unable to determine span for unrecognized variant");return C.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 C=this.registry[A];if(C.property&&Object.prototype.hasOwnProperty.call(T,C.property))return C}throw Error("unable to infer src variant")}decode(T,A=0){let C,P=this.discriminator,Q=P.decode(T,A),W=this.registry[Q];if(W===void 0){let G=this.defaultLayout,U=0;if(this.usesPrefixDiscriminator)U=P.layout.span;C=this.makeDestinationObject(),C[P.property]=Q,C[G.property]=G.decode(T,A+U)}else C=W.decode(T,A);return C}encode(T,A,C=0){let P=this.getSourceVariant(T);if(P===void 0){let Q=this.discriminator,W=this.defaultLayout,G=0;if(this.usesPrefixDiscriminator)G=Q.layout.span;return Q.encode(T[Q.property],A,C),G+W.encode(T[W.property],A,C+G)}return P.encode(T,A,C)}addVariant(T,A,C){let P=new uQ(this,T,A,C);return this.registry[T]=P,P}getVariant(T,A=0){let C;if(T instanceof Uint8Array)C=this.discriminator.decode(T,A);else C=T;return this.registry[C]}}b9.Union=HC;class uQ extends Z1{constructor(T,A,C,P){if(!(T instanceof HC))throw TypeError("union must be a Union");if(!Number.isInteger(A)||0>A)throw TypeError("variant must be a (non-negative) integer");if(typeof C==="string"&&P===void 0)P=C,C=null;if(C){if(!(C instanceof Z1))throw TypeError("layout must be a Layout");if(T.defaultLayout!==null&&0<=C.span&&C.span>T.defaultLayout.span)throw Error("variant span exceeds span of containing union");if(typeof P!=="string")throw TypeError("variant must have a String property")}let Q=T.span;if(0>T.span){if(Q=C?C.span:0,0<=Q&&T.usesPrefixDiscriminator)Q+=T.discriminator.layout.span}super(Q,P);this.union=T,this.variant=A,this.layout=C||null}getSpan(T,A=0){if(0<=this.span)return this.span;let C=0;if(this.union.usesPrefixDiscriminator)C=this.union.discriminator.layout.span;let P=0;if(this.layout)P=this.layout.getSpan(T,A+C);return C+P}decode(T,A=0){let C=this.makeDestinationObject();if(this!==this.union.getVariant(T,A))throw Error("variant mismatch");let P=0;if(this.union.usesPrefixDiscriminator)P=this.union.discriminator.layout.span;if(this.layout)C[this.property]=this.layout.decode(T,A+P);else if(this.property)C[this.property]=!0;else if(this.union.usesPrefixDiscriminator)C[this.union.discriminator.property]=this.variant;return C}encode(T,A,C=0){let P=0;if(this.union.usesPrefixDiscriminator)P=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,C);let Q=P;if(this.layout){if(this.layout.encode(T[this.property],A,C+P),Q+=this.layout.getSpan(A,C+P),0<=this.union.span&&Q>this.union.span)throw Error("encoded variant overruns containing union")}return Q}fromArray(T){if(this.layout)return this.layout.fromArray(T);return}}b9.VariantLayout=uQ;function p8(T){if(0>T)T+=4294967296;return T}class KC extends Z1{constructor(T,A,C){if(!(T instanceof U0||T instanceof j0))throw TypeError("word must be a UInt or UIntBE layout");if(typeof A==="string"&&C===void 0)C=A,A=!1;if(4<T.span)throw RangeError("word cannot exceed 32 bits");super(T.span,C);this.word=T,this.msb=!!A,this.fields=[];let P=0;this._packedSetValue=function(Q){return P=p8(Q),this},this._packedGetValue=function(){return P}}decode(T,A=0){let C=this.makeDestinationObject(),P=this.word.decode(T,A);this._packedSetValue(P);for(let Q of this.fields)if(Q.property!==void 0)C[Q.property]=Q.decode(T);return C}encode(T,A,C=0){let P=this.word.decode(A,C);this._packedSetValue(P);for(let Q of this.fields)if(Q.property!==void 0){let W=T[Q.property];if(W!==void 0)Q.encode(W)}return this.word.encode(this._packedGetValue(),A,C)}addField(T,A){let C=new kC(this,T,A);return this.fields.push(C),C}addBoolean(T){let A=new dQ(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}}b9.BitStructure=KC;class kC{constructor(T,A,C){if(!(T instanceof KC))throw TypeError("container must be a BitStructure");if(!Number.isInteger(A)||0>=A)throw TypeError("bits must be positive integer");let P=8*T.span,Q=T.fields.reduce((W,G)=>W+G.bits,0);if(A+Q>P)throw Error("bits too long for span remainder ("+(P-Q)+" of "+P+" remain)");if(this.container=T,this.bits=A,this.valueMask=(1<<A)-1,A===32)this.valueMask=4294967295;if(this.start=Q,this.container.msb)this.start=P-Q-A;this.wordMask=p8(this.valueMask<<this.start),this.property=C}decode(T,A){let C=this.container._packedGetValue();return p8(C&this.wordMask)>>>this.start}encode(T){if(typeof T!=="number"||!Number.isInteger(T)||T!==p8(T&this.valueMask))throw TypeError(BQ("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);let A=this.container._packedGetValue(),C=p8(T<<this.start);this.container._packedSetValue(p8(A&~this.wordMask)|C)}}b9.BitField=kC;class dQ extends kC{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)}}b9.Boolean=dQ;class rQ extends Z1{constructor(T,A){if(!(T instanceof iT&&T.isCount()||Number.isInteger(T)&&0<=T))throw TypeError("length must be positive integer or an unsigned integer ExternalLayout");let C=-1;if(!(T instanceof iT))C=T;super(C,A);this.length=T}getSpan(T,A){let C=this.span;if(0>C)C=this.length.decode(T,A);return C}decode(T,A=0){let C=this.span;if(0>C)C=this.length.decode(T,A);return U1(T).slice(A,A+C)}encode(T,A,C){let P=this.length;if(this.length instanceof iT)P=T.length;if(!(T instanceof Uint8Array&&P===T.length))throw TypeError(BQ("Blob.encode",this)+" requires (length "+P+") Uint8Array as src");if(C+P>A.length)throw RangeError("encoding overruns Uint8Array");let Q=U1(T);if(U1(A).write(Q.toString("hex"),C,P,"hex"),this.length instanceof iT)this.length.encode(P,A,C);return P}}b9.Blob=rQ;class fQ extends Z1{constructor(T){super(-1,T)}getSpan(T,A=0){u8(T);let C=A;while(C<T.length&&T[C]!==0)C+=1;return 1+C-A}decode(T,A=0){let C=this.getSpan(T,A);return U1(T).slice(A,A+C-1).toString("utf-8")}encode(T,A,C=0){if(typeof T!=="string")T=String(T);let P=EQ.Buffer.from(T,"utf8"),Q=P.length;if(C+Q>A.length)throw RangeError("encoding overruns Buffer");let W=U1(A);return P.copy(W,C),W[C+Q]=0,Q+1}}b9.CString=fQ;class iQ extends Z1{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 u8(T),T.length-A}decode(T,A=0){let C=this.getSpan(T,A);if(0<=this.maxSpan&&this.maxSpan<C)throw RangeError("text length exceeds maxSpan");return U1(T).slice(A,A+C).toString("utf-8")}encode(T,A,C=0){if(typeof T!=="string")T=String(T);let P=EQ.Buffer.from(T,"utf8"),Q=P.length;if(0<=this.maxSpan&&this.maxSpan<Q)throw RangeError("text length exceeds maxSpan");if(C+Q>A.length)throw RangeError("encoding overruns Buffer");return P.copy(U1(A),C),Q}}b9.UTF8=iQ;class cQ extends Z1{constructor(T,A){super(0,A);this.value=T}decode(T,A){return this.value}encode(T,A,C){return 0}}b9.Constant=cQ;b9.greedy=(T,A)=>new OQ(T,A);b9.offset=(T,A,C)=>new YC(T,A,C);b9.u8=(T)=>new U0(1,T);b9.u16=(T)=>new U0(2,T);b9.u24=(T)=>new U0(3,T);b9.u32=(T)=>new U0(4,T);b9.u40=(T)=>new U0(5,T);b9.u48=(T)=>new U0(6,T);b9.nu64=(T)=>new _Q(T);b9.u16be=(T)=>new j0(2,T);b9.u24be=(T)=>new j0(3,T);b9.u32be=(T)=>new j0(4,T);b9.u40be=(T)=>new j0(5,T);b9.u48be=(T)=>new j0(6,T);b9.nu64be=(T)=>new xQ(T);b9.s8=(T)=>new hA(1,T);b9.s16=(T)=>new hA(2,T);b9.s24=(T)=>new hA(3,T);b9.s32=(T)=>new hA(4,T);b9.s40=(T)=>new hA(5,T);b9.s48=(T)=>new hA(6,T);b9.ns64=(T)=>new hQ(T);b9.s16be=(T)=>new Y8(2,T);b9.s24be=(T)=>new Y8(3,T);b9.s32be=(T)=>new Y8(4,T);b9.s40be=(T)=>new Y8(5,T);b9.s48be=(T)=>new Y8(6,T);b9.ns64be=(T)=>new mQ(T);b9.f32=(T)=>new gQ(T);b9.f32be=(T)=>new vQ(T);b9.f64=(T)=>new yQ(T);b9.f64be=(T)=>new bQ(T);b9.struct=(T,A,C)=>new pQ(T,A,C);b9.bits=(T,A,C)=>new KC(T,A,C);b9.seq=(T,A,C)=>new lQ(T,A,C);b9.union=(T,A,C)=>new HC(T,A,C);b9.unionLayoutDiscriminator=(T,A)=>new O2(T,A);b9.blob=(T,A)=>new rQ(T,A);b9.cstr=(T)=>new fQ(T);b9.utf8=(T,A)=>new iQ(T,A);b9.constant=(T,A)=>new cQ(T,A)});function h2(){if(!DC){if(DC=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues==="function"&&msCrypto.getRandomValues.bind(msCrypto),!DC)throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported")}return DC(HM)}var DC,HM;var PW=_T(()=>{HM=new Uint8Array(16)});var GV;var JV=_T(()=>{GV=/^(?:[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 KM(T){return typeof T==="string"&&GV.test(T)}var gA;var m2=_T(()=>{JV();gA=KM});function kM(T){var A=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,C=(OT[T[A+0]]+OT[T[A+1]]+OT[T[A+2]]+OT[T[A+3]]+"-"+OT[T[A+4]]+OT[T[A+5]]+"-"+OT[T[A+6]]+OT[T[A+7]]+"-"+OT[T[A+8]]+OT[T[A+9]]+"-"+OT[T[A+10]]+OT[T[A+11]]+OT[T[A+12]]+OT[T[A+13]]+OT[T[A+14]]+OT[T[A+15]]).toLowerCase();if(!gA(C))throw TypeError("Stringified UUID is invalid");return C}var OT,g2,vA;var v2=_T(()=>{m2();OT=[];for(g2=0;g2<256;++g2)OT.push((g2+256).toString(16).substr(1));vA=kM});function jM(T,A,C){var P=A&&C||0,Q=A||Array(16);T=T||{};var W=T.node||UV,G=T.clockseq!==void 0?T.clockseq:QW;if(W==null||G==null){var U=T.random||(T.rng||h2)();if(W==null)W=UV=[U[0]|1,U[1],U[2],U[3],U[4],U[5]];if(G==null)G=QW=(U[6]<<8|U[7])&16383}var $=T.msecs!==void 0?T.msecs:Date.now(),X=T.nsecs!==void 0?T.nsecs:GW+1,q=$-WW+(X-GW)/1e4;if(q<0&&T.clockseq===void 0)G=G+1&16383;if((q<0||$>WW)&&T.nsecs===void 0)X=0;if(X>=1e4)throw Error("uuid.v1(): Can't create more than 10M uuids/sec");WW=$,GW=X,QW=G,$+=12219292800000;var K=(($&268435455)*1e4+X)%4294967296;Q[P++]=K>>>24&255,Q[P++]=K>>>16&255,Q[P++]=K>>>8&255,Q[P++]=K&255;var F=$/4294967296*1e4&268435455;Q[P++]=F>>>8&255,Q[P++]=F&255,Q[P++]=F>>>24&15|16,Q[P++]=F>>>16&255,Q[P++]=G>>>8|128,Q[P++]=G&255;for(var z=0;z<6;++z)Q[P+z]=W[z];return A||vA(Q)}var UV,QW,WW=0,GW=0,$V;var VV=_T(()=>{PW();v2();$V=jM});function RM(T){if(!gA(T))throw TypeError("Invalid UUID");var A,C=new Uint8Array(16);return C[0]=(A=parseInt(T.slice(0,8),16))>>>24,C[1]=A>>>16&255,C[2]=A>>>8&255,C[3]=A&255,C[4]=(A=parseInt(T.slice(9,13),16))>>>8,C[5]=A&255,C[6]=(A=parseInt(T.slice(14,18),16))>>>8,C[7]=A&255,C[8]=(A=parseInt(T.slice(19,23),16))>>>8,C[9]=A&255,C[10]=(A=parseInt(T.slice(24,36),16))/1099511627776&255,C[11]=A/4294967296&255,C[12]=A>>>24&255,C[13]=A>>>16&255,C[14]=A>>>8&255,C[15]=A&255,C}var zC;var JW=_T(()=>{m2();zC=RM});function FM(T){T=unescape(encodeURIComponent(T));var A=[];for(var C=0;C<T.length;++C)A.push(T.charCodeAt(C));return A}function y2(T,A,C){function P(Q,W,G,U){if(typeof Q==="string")Q=FM(Q);if(typeof W==="string")W=zC(W);if(W.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var $=new Uint8Array(16+Q.length);if($.set(W),$.set(Q,W.length),$=C($),$[6]=$[6]&15|A,$[8]=$[8]&63|128,G){U=U||0;for(var X=0;X<16;++X)G[U+X]=$[X];return G}return vA($)}try{P.name=T}catch(Q){}return P.DNS=DM,P.URL=zM,P}var DM="6ba7b810-9dad-11d1-80b4-00c04fd430c8",zM="6ba7b811-9dad-11d1-80b4-00c04fd430c8";var UW=_T(()=>{v2();JW()});function SM(T){if(typeof T==="string"){var A=unescape(encodeURIComponent(T));T=new Uint8Array(A.length);for(var C=0;C<A.length;++C)T[C]=A.charCodeAt(C)}return MM(IM(NM(T),T.length*8))}function MM(T){var A=[],C=T.length*32,P="0123456789abcdef";for(var Q=0;Q<C;Q+=8){var W=T[Q>>5]>>>Q%32&255,G=parseInt(P.charAt(W>>>4&15)+P.charAt(W&15),16);A.push(G)}return A}function YV(T){return(T+64>>>9<<4)+14+1}function IM(T,A){T[A>>5]|=128<<A%32,T[YV(A)-1]=A;var C=1732584193,P=-271733879,Q=-1732584194,W=271733878;for(var G=0;G<T.length;G+=16){var U=C,$=P,X=Q,q=W;C=gT(C,P,Q,W,T[G],7,-680876936),W=gT(W,C,P,Q,T[G+1],12,-389564586),Q=gT(Q,W,C,P,T[G+2],17,606105819),P=gT(P,Q,W,C,T[G+3],22,-1044525330),C=gT(C,P,Q,W,T[G+4],7,-176418897),W=gT(W,C,P,Q,T[G+5],12,1200080426),Q=gT(Q,W,C,P,T[G+6],17,-1473231341),P=gT(P,Q,W,C,T[G+7],22,-45705983),C=gT(C,P,Q,W,T[G+8],7,1770035416),W=gT(W,C,P,Q,T[G+9],12,-1958414417),Q=gT(Q,W,C,P,T[G+10],17,-42063),P=gT(P,Q,W,C,T[G+11],22,-1990404162),C=gT(C,P,Q,W,T[G+12],7,1804603682),W=gT(W,C,P,Q,T[G+13],12,-40341101),Q=gT(Q,W,C,P,T[G+14],17,-1502002290),P=gT(P,Q,W,C,T[G+15],22,1236535329),C=vT(C,P,Q,W,T[G+1],5,-165796510),W=vT(W,C,P,Q,T[G+6],9,-1069501632),Q=vT(Q,W,C,P,T[G+11],14,643717713),P=vT(P,Q,W,C,T[G],20,-373897302),C=vT(C,P,Q,W,T[G+5],5,-701558691),W=vT(W,C,P,Q,T[G+10],9,38016083),Q=vT(Q,W,C,P,T[G+15],14,-660478335),P=vT(P,Q,W,C,T[G+4],20,-405537848),C=vT(C,P,Q,W,T[G+9],5,568446438),W=vT(W,C,P,Q,T[G+14],9,-1019803690),Q=vT(Q,W,C,P,T[G+3],14,-187363961),P=vT(P,Q,W,C,T[G+8],20,1163531501),C=vT(C,P,Q,W,T[G+13],5,-1444681467),W=vT(W,C,P,Q,T[G+2],9,-51403784),Q=vT(Q,W,C,P,T[G+7],14,1735328473),P=vT(P,Q,W,C,T[G+12],20,-1926607734),C=yT(C,P,Q,W,T[G+5],4,-378558),W=yT(W,C,P,Q,T[G+8],11,-2022574463),Q=yT(Q,W,C,P,T[G+11],16,1839030562),P=yT(P,Q,W,C,T[G+14],23,-35309556),C=yT(C,P,Q,W,T[G+1],4,-1530992060),W=yT(W,C,P,Q,T[G+4],11,1272893353),Q=yT(Q,W,C,P,T[G+7],16,-155497632),P=yT(P,Q,W,C,T[G+10],23,-1094730640),C=yT(C,P,Q,W,T[G+13],4,681279174),W=yT(W,C,P,Q,T[G],11,-358537222),Q=yT(Q,W,C,P,T[G+3],16,-722521979),P=yT(P,Q,W,C,T[G+6],23,76029189),C=yT(C,P,Q,W,T[G+9],4,-640364487),W=yT(W,C,P,Q,T[G+12],11,-421815835),Q=yT(Q,W,C,P,T[G+15],16,530742520),P=yT(P,Q,W,C,T[G+2],23,-995338651),C=bT(C,P,Q,W,T[G],6,-198630844),W=bT(W,C,P,Q,T[G+7],10,1126891415),Q=bT(Q,W,C,P,T[G+14],15,-1416354905),P=bT(P,Q,W,C,T[G+5],21,-57434055),C=bT(C,P,Q,W,T[G+12],6,1700485571),W=bT(W,C,P,Q,T[G+3],10,-1894986606),Q=bT(Q,W,C,P,T[G+10],15,-1051523),P=bT(P,Q,W,C,T[G+1],21,-2054922799),C=bT(C,P,Q,W,T[G+8],6,1873313359),W=bT(W,C,P,Q,T[G+15],10,-30611744),Q=bT(Q,W,C,P,T[G+6],15,-1560198380),P=bT(P,Q,W,C,T[G+13],21,1309151649),C=bT(C,P,Q,W,T[G+4],6,-145523070),W=bT(W,C,P,Q,T[G+11],10,-1120210379),Q=bT(Q,W,C,P,T[G+2],15,718787259),P=bT(P,Q,W,C,T[G+9],21,-343485551),C=yA(C,U),P=yA(P,$),Q=yA(Q,X),W=yA(W,q)}return[C,P,Q,W]}function NM(T){if(T.length===0)return[];var A=T.length*8,C=new Uint32Array(YV(A));for(var P=0;P<A;P+=8)C[P>>5]|=(T[P/8]&255)<<P%32;return C}function yA(T,A){var C=(T&65535)+(A&65535),P=(T>>16)+(A>>16)+(C>>16);return P<<16|C&65535}function LM(T,A){return T<<A|T>>>32-A}function SC(T,A,C,P,Q,W){return yA(LM(yA(yA(A,T),yA(P,W)),Q),C)}function gT(T,A,C,P,Q,W,G){return SC(A&C|~A&P,T,A,Q,W,G)}function vT(T,A,C,P,Q,W,G){return SC(A&P|C&~P,T,A,Q,W,G)}function yT(T,A,C,P,Q,W,G){return SC(A^C^P,T,A,Q,W,G)}function bT(T,A,C,P,Q,W,G){return SC(C^(A|~P),T,A,Q,W,G)}var ZV;var qV=_T(()=>{ZV=SM});var wM,XV;var HV=_T(()=>{UW();qV();wM=y2("v3",48,ZV),XV=wM});function EM(T,A,C){T=T||{};var P=T.random||(T.rng||h2)();if(P[6]=P[6]&15|64,P[8]=P[8]&63|128,A){C=C||0;for(var Q=0;Q<16;++Q)A[C+Q]=P[Q];return A}return vA(P)}var KV;var kV=_T(()=>{PW();v2();KV=EM});function BM(T,A,C,P){switch(T){case 0:return A&C^~A&P;case 1:return A^C^P;case 2:return A&C^A&P^C&P;case 3:return A^C^P}}function $W(T,A){return T<<A|T>>>32-A}function OM(T){var A=[1518500249,1859775393,2400959708,3395469782],C=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof T==="string"){var P=unescape(encodeURIComponent(T));T=[];for(var Q=0;Q<P.length;++Q)T.push(P.charCodeAt(Q))}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),U=Array(G);for(var $=0;$<G;++$){var X=new Uint32Array(16);for(var q=0;q<16;++q)X[q]=T[$*64+q*4]<<24|T[$*64+q*4+1]<<16|T[$*64+q*4+2]<<8|T[$*64+q*4+3];U[$]=X}U[G-1][14]=(T.length-1)*8/Math.pow(2,32),U[G-1][14]=Math.floor(U[G-1][14]),U[G-1][15]=(T.length-1)*8&4294967295;for(var K=0;K<G;++K){var F=new Uint32Array(80);for(var z=0;z<16;++z)F[z]=U[K][z];for(var M=16;M<80;++M)F[M]=$W(F[M-3]^F[M-8]^F[M-14]^F[M-16],1);var E=C[0],L=C[1],B=C[2],m=C[3],v=C[4];for(var l=0;l<80;++l){var f=Math.floor(l/20),u=$W(E,5)+BM(f,L,B,m)+v+A[f]+F[l]>>>0;v=m,m=B,B=$W(L,30)>>>0,L=E,E=u}C[0]=C[0]+E>>>0,C[1]=C[1]+L>>>0,C[2]=C[2]+B>>>0,C[3]=C[3]+m>>>0,C[4]=C[4]+v>>>0}return[C[0]>>24&255,C[0]>>16&255,C[0]>>8&255,C[0]&255,C[1]>>24&255,C[1]>>16&255,C[1]>>8&255,C[1]&255,C[2]>>24&255,C[2]>>16&255,C[2]>>8&255,C[2]&255,C[3]>>24&255,C[3]>>16&255,C[3]>>8&255,C[3]&255,C[4]>>24&255,C[4]>>16&255,C[4]>>8&255,C[4]&255]}var jV;var RV=_T(()=>{jV=OM});var _M,FV;var DV=_T(()=>{UW();RV();_M=y2("v5",80,jV),FV=_M});var zV="00000000-0000-0000-0000-000000000000";function hM(T){if(!gA(T))throw TypeError("Invalid UUID");return parseInt(T.substr(14,1),16)}var SV;var MV=_T(()=>{m2();SV=hM});var VW={};k4(VW,{version:()=>SV,validate:()=>gA,v5:()=>FV,v4:()=>KV,v3:()=>XV,v1:()=>$V,stringify:()=>vA,parse:()=>zC,NIL:()=>zV});var YW=_T(()=>{VV();HV();kV();DV();MV();m2();v2();JW()});var NV=V0((Sm,IV)=>{var mM=(YW(),R8(VW)).v4,gM=function(T,A,C,P){if(typeof T!=="string")throw TypeError(T+" must be a string");P=P||{};let Q=typeof P.version==="number"?P.version:2;if(Q!==1&&Q!==2)throw TypeError(Q+" must be 1 or 2");let W={method:T};if(Q===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 C>"u"){let G=typeof P.generator==="function"?P.generator:function(){return mM()};W.id=G(W,P)}else if(Q===2&&C===null){if(P.notificationIdNull)W.id=null}else W.id=C;return W};IV.exports=gM});var wV=V0((Mm,LV)=>{var vM=(YW(),R8(VW)).v4,yM=NV(),b2=function(T,A){if(!(this instanceof b2))return new b2(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 vM()},version:typeof A.version<"u"?A.version:2,notificationIdNull:typeof A.notificationIdNull==="boolean"?A.notificationIdNull:!1},this.callServer=T};LV.exports=b2;b2.prototype.request=function(T,A,C,P){let Q=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")P=A,W=T;else{if(typeof C==="function")P=C,C=void 0;let X=typeof P==="function";try{W=yM(T,A,C,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(q){if(X)return P(q);throw q}if(!X)return W}let $;try{$=JSON.stringify(W,this.options.replacer)}catch(X){return P(X)}return this.callServer($,function(X,q){Q._parseResponse(X,q,P)}),W};b2.prototype._parseResponse=function(T,A,C){if(T){C(T);return}if(!A)return C();let P;try{P=JSON.parse(A,this.options.reviver)}catch(Q){return C(Q)}if(C.length===3)if(Array.isArray(P)){let Q=function(G){return typeof G.error<"u"},W=function(G){return!Q(G)};return C(null,P.filter(Q),P.filter(W))}else return C(null,P.error,P.result);C(null,P)}});var BV=V0((Im,ZW)=>{var bM=Object.prototype.hasOwnProperty,cT="~";function l2(){}if(Object.create){if(l2.prototype=Object.create(null),!new l2().__proto__)cT=!1}function lM(T,A,C){this.fn=T,this.context=A,this.once=C||!1}function EV(T,A,C,P,Q){if(typeof C!=="function")throw TypeError("The listener must be a function");var W=new lM(C,P||T,Q),G=cT?cT+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 MC(T,A){if(--T._eventsCount===0)T._events=new l2;else delete T._events[A]}function lT(){this._events=new l2,this._eventsCount=0}lT.prototype.eventNames=function(){var A=[],C,P;if(this._eventsCount===0)return A;for(P in C=this._events)if(bM.call(C,P))A.push(cT?P.slice(1):P);if(Object.getOwnPropertySymbols)return A.concat(Object.getOwnPropertySymbols(C));return A};lT.prototype.listeners=function(A){var C=cT?cT+A:A,P=this._events[C];if(!P)return[];if(P.fn)return[P.fn];for(var Q=0,W=P.length,G=Array(W);Q<W;Q++)G[Q]=P[Q].fn;return G};lT.prototype.listenerCount=function(A){var C=cT?cT+A:A,P=this._events[C];if(!P)return 0;if(P.fn)return 1;return P.length};lT.prototype.emit=function(A,C,P,Q,W,G){var U=cT?cT+A:A;if(!this._events[U])return!1;var $=this._events[U],X=arguments.length,q,K;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,C),!0;case 3:return $.fn.call($.context,C,P),!0;case 4:return $.fn.call($.context,C,P,Q),!0;case 5:return $.fn.call($.context,C,P,Q,W),!0;case 6:return $.fn.call($.context,C,P,Q,W,G),!0}for(K=1,q=Array(X-1);K<X;K++)q[K-1]=arguments[K];$.fn.apply($.context,q)}else{var F=$.length,z;for(K=0;K<F;K++){if($[K].once)this.removeListener(A,$[K].fn,void 0,!0);switch(X){case 1:$[K].fn.call($[K].context);break;case 2:$[K].fn.call($[K].context,C);break;case 3:$[K].fn.call($[K].context,C,P);break;case 4:$[K].fn.call($[K].context,C,P,Q);break;default:if(!q)for(z=1,q=Array(X-1);z<X;z++)q[z-1]=arguments[z];$[K].fn.apply($[K].context,q)}}}return!0};lT.prototype.on=function(A,C,P){return EV(this,A,C,P,!1)};lT.prototype.once=function(A,C,P){return EV(this,A,C,P,!0)};lT.prototype.removeListener=function(A,C,P,Q){var W=cT?cT+A:A;if(!this._events[W])return this;if(!C)return MC(this,W),this;var G=this._events[W];if(G.fn){if(G.fn===C&&(!Q||G.once)&&(!P||G.context===P))MC(this,W)}else{for(var U=0,$=[],X=G.length;U<X;U++)if(G[U].fn!==C||Q&&!G[U].once||P&&G[U].context!==P)$.push(G[U]);if($.length)this._events[W]=$.length===1?$[0]:$;else MC(this,W)}return this};lT.prototype.removeAllListeners=function(A){var C;if(A){if(C=cT?cT+A:A,this._events[C])MC(this,C)}else this._events=new l2,this._eventsCount=0;return this};lT.prototype.off=lT.prototype.removeListener;lT.prototype.addListener=lT.prototype.on;lT.prefixed=cT;lT.EventEmitter=lT;if(typeof ZW<"u")ZW.exports=lT});var EY=V0((wY)=>{Object.defineProperty(wY,"__esModule",{value:!0});var vC;function sI(T){{let A=Buffer.from(T);A.reverse();let C=A.toString("hex");if(C.length===0)return BigInt(0);return BigInt(`0x${C}`)}return vC.toBigInt(T,!1)}wY.toBigIntLE=sI;function tI(T){{let A=T.toString("hex");if(A.length===0)return BigInt(0);return BigInt(`0x${A}`)}return vC.toBigInt(T,!0)}wY.toBigIntBE=tI;function eI(T,A){{let C=T.toString(16),P=Buffer.from(C.padStart(A*2,"0").slice(0,A*2),"hex");return P.reverse(),P}return vC.fromBigInt(T,Buffer.allocUnsafe(A),!1)}wY.toBufferLE=eI;function TN(T,A){{let C=T.toString(16);return Buffer.from(C.padStart(A*2,"0").slice(0,A*2),"hex")}return vC.fromBigInt(T,Buffer.allocUnsafe(A),!0)}wY.toBufferBE=TN});/*!
2
2
  * The buffer module from node.js, for the browser.
3
3
  *
4
4
  * @author Feross Aboukhadijeh <https://feross.org>
5
5
  * @license MIT
6
- */var C4=VG(),RA=jG(),RG=typeof Symbol==="function"&&typeof Symbol.for==="function"?Symbol.for("nodejs.util.inspect.custom"):null;var F4=m;var hG=50;var H4=2147483647;m.TYPED_ARRAY_SUPPORT=hq();if(!m.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 hq(){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(m.prototype,"parent",{enumerable:!0,get:function(){if(!m.isBuffer(this))return;return this.buffer}});Object.defineProperty(m.prototype,"offset",{enumerable:!0,get:function(){if(!m.isBuffer(this))return;return this.byteOffset}});function dT(T){if(T>H4)throw RangeError('The value "'+T+'" is invalid for option "size"');let A=new Uint8Array(T);return Object.setPrototypeOf(A,m.prototype),A}function m(T,A,Q){if(typeof T==="number"){if(typeof A==="string")throw TypeError('The "string" argument must be of type string. Received type number');return D4(T)}return zG(T,A,Q)}m.poolSize=8192;function zG(T,A,Q){if(typeof T==="string")return mq(T,A);if(ArrayBuffer.isView(T))return vq(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(IT(T,ArrayBuffer)||T&&IT(T.buffer,ArrayBuffer))return j4(T,A,Q);if(typeof SharedArrayBuffer<"u"&&(IT(T,SharedArrayBuffer)||T&&IT(T.buffer,SharedArrayBuffer)))return j4(T,A,Q);if(typeof T==="number")throw TypeError('The "value" argument must not be of type number. Received type number');let J=T.valueOf&&T.valueOf();if(J!=null&&J!==T)return m.from(J,A,Q);let $=yq(T);if($)return $;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof T[Symbol.toPrimitive]==="function")return m.from(T[Symbol.toPrimitive]("string"),A,Q);throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof T)}m.from=function(T,A,Q){return zG(T,A,Q)};Object.setPrototypeOf(m.prototype,Uint8Array.prototype);Object.setPrototypeOf(m,Uint8Array);function FG(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 gq(T,A,Q){if(FG(T),T<=0)return dT(T);if(A!==void 0)return typeof Q==="string"?dT(T).fill(A,Q):dT(T).fill(A);return dT(T)}m.alloc=function(T,A,Q){return gq(T,A,Q)};function D4(T){return FG(T),dT(T<0?0:M4(T)|0)}m.allocUnsafe=function(T){return D4(T)};m.allocUnsafeSlow=function(T){return D4(T)};function mq(T,A){if(typeof A!=="string"||A==="")A="utf8";if(!m.isEncoding(A))throw TypeError("Unknown encoding: "+A);let Q=NG(T,A)|0,J=dT(Q),$=J.write(T,A);if($!==Q)J=J.slice(0,$);return J}function V4(T){let A=T.length<0?0:M4(T.length)|0,Q=dT(A);for(let J=0;J<A;J+=1)Q[J]=T[J]&255;return Q}function vq(T){if(IT(T,Uint8Array)){let A=new Uint8Array(T);return j4(A.buffer,A.byteOffset,A.byteLength)}return V4(T)}function j4(T,A,Q){if(A<0||T.byteLength<A)throw RangeError('"offset" is outside of buffer bounds');if(T.byteLength<A+(Q||0))throw RangeError('"length" is outside of buffer bounds');let J;if(A===void 0&&Q===void 0)J=new Uint8Array(T);else if(Q===void 0)J=new Uint8Array(T,A);else J=new Uint8Array(T,A,Q);return Object.setPrototypeOf(J,m.prototype),J}function yq(T){if(m.isBuffer(T)){let A=M4(T.length)|0,Q=dT(A);if(Q.length===0)return Q;return T.copy(Q,0,0,A),Q}if(T.length!==void 0){if(typeof T.length!=="number"||z4(T.length))return dT(0);return V4(T)}if(T.type==="Buffer"&&Array.isArray(T.data))return V4(T.data)}function M4(T){if(T>=H4)throw RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+H4.toString(16)+" bytes");return T|0}m.isBuffer=function(A){return A!=null&&A._isBuffer===!0&&A!==m.prototype};m.compare=function(A,Q){if(IT(A,Uint8Array))A=m.from(A,A.offset,A.byteLength);if(IT(Q,Uint8Array))Q=m.from(Q,Q.offset,Q.byteLength);if(!m.isBuffer(A)||!m.isBuffer(Q))throw TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(A===Q)return 0;let J=A.length,$=Q.length;for(let W=0,G=Math.min(J,$);W<G;++W)if(A[W]!==Q[W]){J=A[W],$=Q[W];break}if(J<$)return-1;if($<J)return 1;return 0};m.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}};m.concat=function(A,Q){if(!Array.isArray(A))throw TypeError('"list" argument must be an Array of Buffers');if(A.length===0)return m.alloc(0);let J;if(Q===void 0){Q=0;for(J=0;J<A.length;++J)Q+=A[J].length}let $=m.allocUnsafe(Q),W=0;for(J=0;J<A.length;++J){let G=A[J];if(IT(G,Uint8Array))if(W+G.length>$.length){if(!m.isBuffer(G))G=m.from(G);G.copy($,W)}else Uint8Array.prototype.set.call($,G,W);else if(!m.isBuffer(G))throw TypeError('"list" argument must be an Array of Buffers');else G.copy($,W);W+=G.length}return $};function NG(T,A){if(m.isBuffer(T))return T.length;if(ArrayBuffer.isView(T)||IT(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 Q=T.length,J=arguments.length>2&&arguments[2]===!0;if(!J&&Q===0)return 0;let $=!1;for(;;)switch(A){case"ascii":case"latin1":case"binary":return Q;case"utf8":case"utf-8":return R4(T).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Q*2;case"hex":return Q>>>1;case"base64":return xG(T).length;default:if($)return J?-1:R4(T).length;A=(""+A).toLowerCase(),$=!0}}m.byteLength=NG;function bq(T,A,Q){let J=!1;if(A===void 0||A<0)A=0;if(A>this.length)return"";if(Q===void 0||Q>this.length)Q=this.length;if(Q<=0)return"";if(Q>>>=0,A>>>=0,Q<=A)return"";if(!T)T="utf8";while(!0)switch(T){case"hex":return oq(this,A,Q);case"utf8":case"utf-8":return SG(this,A,Q);case"ascii":return nq(this,A,Q);case"latin1":case"binary":return iq(this,A,Q);case"base64":return fq(this,A,Q);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return aq(this,A,Q);default:if(J)throw TypeError("Unknown encoding: "+T);T=(T+"").toLowerCase(),J=!0}}m.prototype._isBuffer=!0;function p8(T,A,Q){let J=T[A];T[A]=T[Q],T[Q]=J}m.prototype.swap16=function(){let A=this.length;if(A%2!==0)throw RangeError("Buffer size must be a multiple of 16-bits");for(let Q=0;Q<A;Q+=2)p8(this,Q,Q+1);return this};m.prototype.swap32=function(){let A=this.length;if(A%4!==0)throw RangeError("Buffer size must be a multiple of 32-bits");for(let Q=0;Q<A;Q+=4)p8(this,Q,Q+3),p8(this,Q+1,Q+2);return this};m.prototype.swap64=function(){let A=this.length;if(A%8!==0)throw RangeError("Buffer size must be a multiple of 64-bits");for(let Q=0;Q<A;Q+=8)p8(this,Q,Q+7),p8(this,Q+1,Q+6),p8(this,Q+2,Q+5),p8(this,Q+3,Q+4);return this};m.prototype.toString=function(){let A=this.length;if(A===0)return"";if(arguments.length===0)return SG(this,0,A);return bq.apply(this,arguments)};m.prototype.toLocaleString=m.prototype.toString;m.prototype.equals=function(A){if(!m.isBuffer(A))throw TypeError("Argument must be a Buffer");if(this===A)return!0;return m.compare(this,A)===0};m.prototype.inspect=function(){let A="",Q=hG;if(A=this.toString("hex",0,Q).replace(/(.{2})/g,"$1 ").trim(),this.length>Q)A+=" ... ";return"<Buffer "+A+">"};if(RG)m.prototype[RG]=m.prototype.inspect;m.prototype.compare=function(A,Q,J,$,W){if(IT(A,Uint8Array))A=m.from(A,A.offset,A.byteLength);if(!m.isBuffer(A))throw TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof A);if(Q===void 0)Q=0;if(J===void 0)J=A?A.length:0;if($===void 0)$=0;if(W===void 0)W=this.length;if(Q<0||J>A.length||$<0||W>this.length)throw RangeError("out of range index");if($>=W&&Q>=J)return 0;if($>=W)return-1;if(Q>=J)return 1;if(Q>>>=0,J>>>=0,$>>>=0,W>>>=0,this===A)return 0;let G=W-$,Y=J-Q,Z=Math.min(G,Y),C=this.slice($,W),K=A.slice(Q,J);for(let j=0;j<Z;++j)if(C[j]!==K[j]){G=C[j],Y=K[j];break}if(G<Y)return-1;if(Y<G)return 1;return 0};function IG(T,A,Q,J,$){if(T.length===0)return-1;if(typeof Q==="string")J=Q,Q=0;else if(Q>2147483647)Q=2147483647;else if(Q<-2147483648)Q=-2147483648;if(Q=+Q,z4(Q))Q=$?0:T.length-1;if(Q<0)Q=T.length+Q;if(Q>=T.length)if($)return-1;else Q=T.length-1;else if(Q<0)if($)Q=0;else return-1;if(typeof A==="string")A=m.from(A,J);if(m.isBuffer(A)){if(A.length===0)return-1;return DG(T,A,Q,J,$)}else if(typeof A==="number"){if(A=A&255,typeof Uint8Array.prototype.indexOf==="function")if($)return Uint8Array.prototype.indexOf.call(T,A,Q);else return Uint8Array.prototype.lastIndexOf.call(T,A,Q);return DG(T,[A],Q,J,$)}throw TypeError("val must be string, number or Buffer")}function DG(T,A,Q,J,$){let W=1,G=T.length,Y=A.length;if(J!==void 0){if(J=String(J).toLowerCase(),J==="ucs2"||J==="ucs-2"||J==="utf16le"||J==="utf-16le"){if(T.length<2||A.length<2)return-1;W=2,G/=2,Y/=2,Q/=2}}function Z(K,j){if(W===1)return K[j];else return K.readUInt16BE(j*W)}let C;if($){let K=-1;for(C=Q;C<G;C++)if(Z(T,C)===Z(A,K===-1?0:C-K)){if(K===-1)K=C;if(C-K+1===Y)return K*W}else{if(K!==-1)C-=C-K;K=-1}}else{if(Q+Y>G)Q=G-Y;for(C=Q;C>=0;C--){let K=!0;for(let j=0;j<Y;j++)if(Z(T,C+j)!==Z(A,j)){K=!1;break}if(K)return C}}return-1}m.prototype.includes=function(A,Q,J){return this.indexOf(A,Q,J)!==-1};m.prototype.indexOf=function(A,Q,J){return IG(this,A,Q,J,!0)};m.prototype.lastIndexOf=function(A,Q,J){return IG(this,A,Q,J,!1)};function pq(T,A,Q,J){Q=Number(Q)||0;let $=T.length-Q;if(!J)J=$;else if(J=Number(J),J>$)J=$;let W=A.length;if(J>W/2)J=W/2;let G;for(G=0;G<J;++G){let Y=parseInt(A.substr(G*2,2),16);if(z4(Y))return G;T[Q+G]=Y}return G}function lq(T,A,Q,J){return s2(R4(A,T.length-Q),T,Q,J)}function uq(T,A,Q,J){return s2(TK(A),T,Q,J)}function dq(T,A,Q,J){return s2(xG(A),T,Q,J)}function cq(T,A,Q,J){return s2(AK(A,T.length-Q),T,Q,J)}m.prototype.write=function(A,Q,J,$){if(Q===void 0)$="utf8",J=this.length,Q=0;else if(J===void 0&&typeof Q==="string")$=Q,J=this.length,Q=0;else if(isFinite(Q))if(Q=Q>>>0,isFinite(J)){if(J=J>>>0,$===void 0)$="utf8"}else $=J,J=void 0;else throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let W=this.length-Q;if(J===void 0||J>W)J=W;if(A.length>0&&(J<0||Q<0)||Q>this.length)throw RangeError("Attempt to write outside buffer bounds");if(!$)$="utf8";let G=!1;for(;;)switch($){case"hex":return pq(this,A,Q,J);case"utf8":case"utf-8":return lq(this,A,Q,J);case"ascii":case"latin1":case"binary":return uq(this,A,Q,J);case"base64":return dq(this,A,Q,J);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return cq(this,A,Q,J);default:if(G)throw TypeError("Unknown encoding: "+$);$=(""+$).toLowerCase(),G=!0}};m.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function fq(T,A,Q){if(A===0&&Q===T.length)return C4.fromByteArray(T);else return C4.fromByteArray(T.slice(A,Q))}function SG(T,A,Q){Q=Math.min(T.length,Q);let J=[],$=A;while($<Q){let W=T[$],G=null,Y=W>239?4:W>223?3:W>191?2:1;if($+Y<=Q){let Z,C,K,j;switch(Y){case 1:if(W<128)G=W;break;case 2:if(Z=T[$+1],(Z&192)===128){if(j=(W&31)<<6|Z&63,j>127)G=j}break;case 3:if(Z=T[$+1],C=T[$+2],(Z&192)===128&&(C&192)===128){if(j=(W&15)<<12|(Z&63)<<6|C&63,j>2047&&(j<55296||j>57343))G=j}break;case 4:if(Z=T[$+1],C=T[$+2],K=T[$+3],(Z&192)===128&&(C&192)===128&&(K&192)===128){if(j=(W&15)<<18|(Z&63)<<12|(C&63)<<6|K&63,j>65535&&j<1114112)G=j}}}if(G===null)G=65533,Y=1;else if(G>65535)G-=65536,J.push(G>>>10&1023|55296),G=56320|G&1023;J.push(G),$+=Y}return rq(J)}var MG=4096;function rq(T){let A=T.length;if(A<=MG)return String.fromCharCode.apply(String,T);let Q="",J=0;while(J<A)Q+=String.fromCharCode.apply(String,T.slice(J,J+=MG));return Q}function nq(T,A,Q){let J="";Q=Math.min(T.length,Q);for(let $=A;$<Q;++$)J+=String.fromCharCode(T[$]&127);return J}function iq(T,A,Q){let J="";Q=Math.min(T.length,Q);for(let $=A;$<Q;++$)J+=String.fromCharCode(T[$]);return J}function oq(T,A,Q){let J=T.length;if(!A||A<0)A=0;if(!Q||Q<0||Q>J)Q=J;let $="";for(let W=A;W<Q;++W)$+=QK[T[W]];return $}function aq(T,A,Q){let J=T.slice(A,Q),$="";for(let W=0;W<J.length-1;W+=2)$+=String.fromCharCode(J[W]+J[W+1]*256);return $}m.prototype.slice=function(A,Q){let J=this.length;if(A=~~A,Q=Q===void 0?J:~~Q,A<0){if(A+=J,A<0)A=0}else if(A>J)A=J;if(Q<0){if(Q+=J,Q<0)Q=0}else if(Q>J)Q=J;if(Q<A)Q=A;let $=this.subarray(A,Q);return Object.setPrototypeOf($,m.prototype),$};function D0(T,A,Q){if(T%1!==0||T<0)throw RangeError("offset is not uint");if(T+A>Q)throw RangeError("Trying to access beyond buffer length")}m.prototype.readUintLE=m.prototype.readUIntLE=function(A,Q,J){if(A=A>>>0,Q=Q>>>0,!J)D0(A,Q,this.length);let $=this[A],W=1,G=0;while(++G<Q&&(W*=256))$+=this[A+G]*W;return $};m.prototype.readUintBE=m.prototype.readUIntBE=function(A,Q,J){if(A=A>>>0,Q=Q>>>0,!J)D0(A,Q,this.length);let $=this[A+--Q],W=1;while(Q>0&&(W*=256))$+=this[A+--Q]*W;return $};m.prototype.readUint8=m.prototype.readUInt8=function(A,Q){if(A=A>>>0,!Q)D0(A,1,this.length);return this[A]};m.prototype.readUint16LE=m.prototype.readUInt16LE=function(A,Q){if(A=A>>>0,!Q)D0(A,2,this.length);return this[A]|this[A+1]<<8};m.prototype.readUint16BE=m.prototype.readUInt16BE=function(A,Q){if(A=A>>>0,!Q)D0(A,2,this.length);return this[A]<<8|this[A+1]};m.prototype.readUint32LE=m.prototype.readUInt32LE=function(A,Q){if(A=A>>>0,!Q)D0(A,4,this.length);return(this[A]|this[A+1]<<8|this[A+2]<<16)+this[A+3]*16777216};m.prototype.readUint32BE=m.prototype.readUInt32BE=function(A,Q){if(A=A>>>0,!Q)D0(A,4,this.length);return this[A]*16777216+(this[A+1]<<16|this[A+2]<<8|this[A+3])};m.prototype.readBigUInt64LE=K8(function(A){A=A>>>0,DA(A,"offset");let Q=this[A],J=this[A+7];if(Q===void 0||J===void 0)Q2(A,this.length-8);let $=Q+this[++A]*256+this[++A]*65536+this[++A]*16777216,W=this[++A]+this[++A]*256+this[++A]*65536+J*16777216;return BigInt($)+(BigInt(W)<<BigInt(32))});m.prototype.readBigUInt64BE=K8(function(A){A=A>>>0,DA(A,"offset");let Q=this[A],J=this[A+7];if(Q===void 0||J===void 0)Q2(A,this.length-8);let $=Q*16777216+this[++A]*65536+this[++A]*256+this[++A],W=this[++A]*16777216+this[++A]*65536+this[++A]*256+J;return(BigInt($)<<BigInt(32))+BigInt(W)});m.prototype.readIntLE=function(A,Q,J){if(A=A>>>0,Q=Q>>>0,!J)D0(A,Q,this.length);let $=this[A],W=1,G=0;while(++G<Q&&(W*=256))$+=this[A+G]*W;if(W*=128,$>=W)$-=Math.pow(2,8*Q);return $};m.prototype.readIntBE=function(A,Q,J){if(A=A>>>0,Q=Q>>>0,!J)D0(A,Q,this.length);let $=Q,W=1,G=this[A+--$];while($>0&&(W*=256))G+=this[A+--$]*W;if(W*=128,G>=W)G-=Math.pow(2,8*Q);return G};m.prototype.readInt8=function(A,Q){if(A=A>>>0,!Q)D0(A,1,this.length);if(!(this[A]&128))return this[A];return(255-this[A]+1)*-1};m.prototype.readInt16LE=function(A,Q){if(A=A>>>0,!Q)D0(A,2,this.length);let J=this[A]|this[A+1]<<8;return J&32768?J|4294901760:J};m.prototype.readInt16BE=function(A,Q){if(A=A>>>0,!Q)D0(A,2,this.length);let J=this[A+1]|this[A]<<8;return J&32768?J|4294901760:J};m.prototype.readInt32LE=function(A,Q){if(A=A>>>0,!Q)D0(A,4,this.length);return this[A]|this[A+1]<<8|this[A+2]<<16|this[A+3]<<24};m.prototype.readInt32BE=function(A,Q){if(A=A>>>0,!Q)D0(A,4,this.length);return this[A]<<24|this[A+1]<<16|this[A+2]<<8|this[A+3]};m.prototype.readBigInt64LE=K8(function(A){A=A>>>0,DA(A,"offset");let Q=this[A],J=this[A+7];if(Q===void 0||J===void 0)Q2(A,this.length-8);let $=this[A+4]+this[A+5]*256+this[A+6]*65536+(J<<24);return(BigInt($)<<BigInt(32))+BigInt(Q+this[++A]*256+this[++A]*65536+this[++A]*16777216)});m.prototype.readBigInt64BE=K8(function(A){A=A>>>0,DA(A,"offset");let Q=this[A],J=this[A+7];if(Q===void 0||J===void 0)Q2(A,this.length-8);let $=(Q<<24)+this[++A]*65536+this[++A]*256+this[++A];return(BigInt($)<<BigInt(32))+BigInt(this[++A]*16777216+this[++A]*65536+this[++A]*256+J)});m.prototype.readFloatLE=function(A,Q){if(A=A>>>0,!Q)D0(A,4,this.length);return RA.read(this,A,!0,23,4)};m.prototype.readFloatBE=function(A,Q){if(A=A>>>0,!Q)D0(A,4,this.length);return RA.read(this,A,!1,23,4)};m.prototype.readDoubleLE=function(A,Q){if(A=A>>>0,!Q)D0(A,8,this.length);return RA.read(this,A,!0,52,8)};m.prototype.readDoubleBE=function(A,Q){if(A=A>>>0,!Q)D0(A,8,this.length);return RA.read(this,A,!1,52,8)};function i0(T,A,Q,J,$,W){if(!m.isBuffer(T))throw TypeError('"buffer" argument must be a Buffer instance');if(A>$||A<W)throw RangeError('"value" argument is out of bounds');if(Q+J>T.length)throw RangeError("Index out of range")}m.prototype.writeUintLE=m.prototype.writeUIntLE=function(A,Q,J,$){if(A=+A,Q=Q>>>0,J=J>>>0,!$){let Y=Math.pow(2,8*J)-1;i0(this,A,Q,J,Y,0)}let W=1,G=0;this[Q]=A&255;while(++G<J&&(W*=256))this[Q+G]=A/W&255;return Q+J};m.prototype.writeUintBE=m.prototype.writeUIntBE=function(A,Q,J,$){if(A=+A,Q=Q>>>0,J=J>>>0,!$){let Y=Math.pow(2,8*J)-1;i0(this,A,Q,J,Y,0)}let W=J-1,G=1;this[Q+W]=A&255;while(--W>=0&&(G*=256))this[Q+W]=A/G&255;return Q+J};m.prototype.writeUint8=m.prototype.writeUInt8=function(A,Q,J){if(A=+A,Q=Q>>>0,!J)i0(this,A,Q,1,255,0);return this[Q]=A&255,Q+1};m.prototype.writeUint16LE=m.prototype.writeUInt16LE=function(A,Q,J){if(A=+A,Q=Q>>>0,!J)i0(this,A,Q,2,65535,0);return this[Q]=A&255,this[Q+1]=A>>>8,Q+2};m.prototype.writeUint16BE=m.prototype.writeUInt16BE=function(A,Q,J){if(A=+A,Q=Q>>>0,!J)i0(this,A,Q,2,65535,0);return this[Q]=A>>>8,this[Q+1]=A&255,Q+2};m.prototype.writeUint32LE=m.prototype.writeUInt32LE=function(A,Q,J){if(A=+A,Q=Q>>>0,!J)i0(this,A,Q,4,4294967295,0);return this[Q+3]=A>>>24,this[Q+2]=A>>>16,this[Q+1]=A>>>8,this[Q]=A&255,Q+4};m.prototype.writeUint32BE=m.prototype.writeUInt32BE=function(A,Q,J){if(A=+A,Q=Q>>>0,!J)i0(this,A,Q,4,4294967295,0);return this[Q]=A>>>24,this[Q+1]=A>>>16,this[Q+2]=A>>>8,this[Q+3]=A&255,Q+4};function LG(T,A,Q,J,$){_G(A,J,$,T,Q,7);let W=Number(A&BigInt(4294967295));T[Q++]=W,W=W>>8,T[Q++]=W,W=W>>8,T[Q++]=W,W=W>>8,T[Q++]=W;let G=Number(A>>BigInt(32)&BigInt(4294967295));return T[Q++]=G,G=G>>8,T[Q++]=G,G=G>>8,T[Q++]=G,G=G>>8,T[Q++]=G,Q}function wG(T,A,Q,J,$){_G(A,J,$,T,Q,7);let W=Number(A&BigInt(4294967295));T[Q+7]=W,W=W>>8,T[Q+6]=W,W=W>>8,T[Q+5]=W,W=W>>8,T[Q+4]=W;let G=Number(A>>BigInt(32)&BigInt(4294967295));return T[Q+3]=G,G=G>>8,T[Q+2]=G,G=G>>8,T[Q+1]=G,G=G>>8,T[Q]=G,Q+8}m.prototype.writeBigUInt64LE=K8(function(A,Q=0){return LG(this,A,Q,BigInt(0),BigInt("0xffffffffffffffff"))});m.prototype.writeBigUInt64BE=K8(function(A,Q=0){return wG(this,A,Q,BigInt(0),BigInt("0xffffffffffffffff"))});m.prototype.writeIntLE=function(A,Q,J,$){if(A=+A,Q=Q>>>0,!$){let Z=Math.pow(2,8*J-1);i0(this,A,Q,J,Z-1,-Z)}let W=0,G=1,Y=0;this[Q]=A&255;while(++W<J&&(G*=256)){if(A<0&&Y===0&&this[Q+W-1]!==0)Y=1;this[Q+W]=(A/G>>0)-Y&255}return Q+J};m.prototype.writeIntBE=function(A,Q,J,$){if(A=+A,Q=Q>>>0,!$){let Z=Math.pow(2,8*J-1);i0(this,A,Q,J,Z-1,-Z)}let W=J-1,G=1,Y=0;this[Q+W]=A&255;while(--W>=0&&(G*=256)){if(A<0&&Y===0&&this[Q+W+1]!==0)Y=1;this[Q+W]=(A/G>>0)-Y&255}return Q+J};m.prototype.writeInt8=function(A,Q,J){if(A=+A,Q=Q>>>0,!J)i0(this,A,Q,1,127,-128);if(A<0)A=255+A+1;return this[Q]=A&255,Q+1};m.prototype.writeInt16LE=function(A,Q,J){if(A=+A,Q=Q>>>0,!J)i0(this,A,Q,2,32767,-32768);return this[Q]=A&255,this[Q+1]=A>>>8,Q+2};m.prototype.writeInt16BE=function(A,Q,J){if(A=+A,Q=Q>>>0,!J)i0(this,A,Q,2,32767,-32768);return this[Q]=A>>>8,this[Q+1]=A&255,Q+2};m.prototype.writeInt32LE=function(A,Q,J){if(A=+A,Q=Q>>>0,!J)i0(this,A,Q,4,2147483647,-2147483648);return this[Q]=A&255,this[Q+1]=A>>>8,this[Q+2]=A>>>16,this[Q+3]=A>>>24,Q+4};m.prototype.writeInt32BE=function(A,Q,J){if(A=+A,Q=Q>>>0,!J)i0(this,A,Q,4,2147483647,-2147483648);if(A<0)A=4294967295+A+1;return this[Q]=A>>>24,this[Q+1]=A>>>16,this[Q+2]=A>>>8,this[Q+3]=A&255,Q+4};m.prototype.writeBigInt64LE=K8(function(A,Q=0){return LG(this,A,Q,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});m.prototype.writeBigInt64BE=K8(function(A,Q=0){return wG(this,A,Q,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function EG(T,A,Q,J,$,W){if(Q+J>T.length)throw RangeError("Index out of range");if(Q<0)throw RangeError("Index out of range")}function OG(T,A,Q,J,$){if(A=+A,Q=Q>>>0,!$)EG(T,A,Q,4,340282346638528860000000000000000000000,-340282346638528860000000000000000000000);return RA.write(T,A,Q,J,23,4),Q+4}m.prototype.writeFloatLE=function(A,Q,J){return OG(this,A,Q,!0,J)};m.prototype.writeFloatBE=function(A,Q,J){return OG(this,A,Q,!1,J)};function BG(T,A,Q,J,$){if(A=+A,Q=Q>>>0,!$)EG(T,A,Q,8,179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,-179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000);return RA.write(T,A,Q,J,52,8),Q+8}m.prototype.writeDoubleLE=function(A,Q,J){return BG(this,A,Q,!0,J)};m.prototype.writeDoubleBE=function(A,Q,J){return BG(this,A,Q,!1,J)};m.prototype.copy=function(A,Q,J,$){if(!m.isBuffer(A))throw TypeError("argument should be a Buffer");if(!J)J=0;if(!$&&$!==0)$=this.length;if(Q>=A.length)Q=A.length;if(!Q)Q=0;if($>0&&$<J)$=J;if($===J)return 0;if(A.length===0||this.length===0)return 0;if(Q<0)throw RangeError("targetStart out of bounds");if(J<0||J>=this.length)throw RangeError("Index out of range");if($<0)throw RangeError("sourceEnd out of bounds");if($>this.length)$=this.length;if(A.length-Q<$-J)$=A.length-Q+J;let W=$-J;if(this===A&&typeof Uint8Array.prototype.copyWithin==="function")this.copyWithin(Q,J,$);else Uint8Array.prototype.set.call(A,this.subarray(J,$),Q);return W};m.prototype.fill=function(A,Q,J,$){if(typeof A==="string"){if(typeof Q==="string")$=Q,Q=0,J=this.length;else if(typeof J==="string")$=J,J=this.length;if($!==void 0&&typeof $!=="string")throw TypeError("encoding must be a string");if(typeof $==="string"&&!m.isEncoding($))throw TypeError("Unknown encoding: "+$);if(A.length===1){let G=A.charCodeAt(0);if($==="utf8"&&G<128||$==="latin1")A=G}}else if(typeof A==="number")A=A&255;else if(typeof A==="boolean")A=Number(A);if(Q<0||this.length<Q||this.length<J)throw RangeError("Out of range index");if(J<=Q)return this;if(Q=Q>>>0,J=J===void 0?this.length:J>>>0,!A)A=0;let W;if(typeof A==="number")for(W=Q;W<J;++W)this[W]=A;else{let G=m.isBuffer(A)?A:m.from(A,$),Y=G.length;if(Y===0)throw TypeError('The value "'+A+'" is invalid for argument "value"');for(W=0;W<J-Q;++W)this[W+Q]=G[W%Y]}return this};var jA={};function k4(T,A,Q){jA[T]=class extends Q{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($){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:$,writable:!0})}toString(){return`${this.name} [${T}]: ${this.message}`}}}k4("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);k4("ERR_INVALID_ARG_TYPE",function(T,A){return`The "${T}" argument must be of type number. Received type ${typeof A}`},TypeError);k4("ERR_OUT_OF_RANGE",function(T,A,Q){let J=`The value of "${T}" is out of range.`,$=Q;if(Number.isInteger(Q)&&Math.abs(Q)>4294967296)$=kG(String(Q));else if(typeof Q==="bigint"){if($=String(Q),Q>BigInt(2)**BigInt(32)||Q<-(BigInt(2)**BigInt(32)))$=kG($);$+="n"}return J+=` It must be ${A}. Received ${$}`,J},RangeError);function kG(T){let A="",Q=T.length,J=T[0]==="-"?1:0;for(;Q>=J+4;Q-=3)A=`_${T.slice(Q-3,Q)}${A}`;return`${T.slice(0,Q)}${A}`}function sq(T,A,Q){if(DA(A,"offset"),T[A]===void 0||T[A+Q]===void 0)Q2(A,T.length-(Q+1))}function _G(T,A,Q,J,$,W){if(T>Q||T<A){let G=typeof A==="bigint"?"n":"",Y;if(W>3)if(A===0||A===BigInt(0))Y=`>= 0${G} and < 2${G} ** ${(W+1)*8}${G}`;else Y=`>= -(2${G} ** ${(W+1)*8-1}${G}) and < 2 ** ${(W+1)*8-1}${G}`;else Y=`>= ${A}${G} and <= ${Q}${G}`;throw new jA.ERR_OUT_OF_RANGE("value",Y,T)}sq(J,$,W)}function DA(T,A){if(typeof T!=="number")throw new jA.ERR_INVALID_ARG_TYPE(A,"number",T)}function Q2(T,A,Q){if(Math.floor(T)!==T)throw DA(T,Q),new jA.ERR_OUT_OF_RANGE(Q||"offset","an integer",T);if(A<0)throw new jA.ERR_BUFFER_OUT_OF_BOUNDS;throw new jA.ERR_OUT_OF_RANGE(Q||"offset",`>= ${Q?1:0} and <= ${A}`,T)}var tq=/[^+/0-9A-Za-z-_]/g;function eq(T){if(T=T.split("=")[0],T=T.trim().replace(tq,""),T.length<2)return"";while(T.length%4!==0)T=T+"=";return T}function R4(T,A){A=A||1/0;let Q,J=T.length,$=null,W=[];for(let G=0;G<J;++G){if(Q=T.charCodeAt(G),Q>55295&&Q<57344){if(!$){if(Q>56319){if((A-=3)>-1)W.push(239,191,189);continue}else if(G+1===J){if((A-=3)>-1)W.push(239,191,189);continue}$=Q;continue}if(Q<56320){if((A-=3)>-1)W.push(239,191,189);$=Q;continue}Q=($-55296<<10|Q-56320)+65536}else if($){if((A-=3)>-1)W.push(239,191,189)}if($=null,Q<128){if((A-=1)<0)break;W.push(Q)}else if(Q<2048){if((A-=2)<0)break;W.push(Q>>6|192,Q&63|128)}else if(Q<65536){if((A-=3)<0)break;W.push(Q>>12|224,Q>>6&63|128,Q&63|128)}else if(Q<1114112){if((A-=4)<0)break;W.push(Q>>18|240,Q>>12&63|128,Q>>6&63|128,Q&63|128)}else throw Error("Invalid code point")}return W}function TK(T){let A=[];for(let Q=0;Q<T.length;++Q)A.push(T.charCodeAt(Q)&255);return A}function AK(T,A){let Q,J,$,W=[];for(let G=0;G<T.length;++G){if((A-=2)<0)break;Q=T.charCodeAt(G),J=Q>>8,$=Q%256,W.push($),W.push(J)}return W}function xG(T){return C4.toByteArray(eq(T))}function s2(T,A,Q,J){let $;for($=0;$<J;++$){if($+Q>=A.length||$>=T.length)break;A[$+Q]=T[$]}return $}function IT(T,A){return T instanceof A||T!=null&&T.constructor!=null&&T.constructor.name!=null&&T.constructor.name===A.name}function z4(T){return T!==T}var QK=function(){let A=Array(256);for(let Q=0;Q<16;++Q){let J=Q*16;for(let $=0;$<16;++$)A[J+$]="0123456789abcdef"[Q]+"0123456789abcdef"[$]}return A}();function K8(T){return typeof BigInt>"u"?JK:T}function JK(){throw Error("BigInt not supported")}if(typeof globalThis.Buffer>"u")globalThis.Buffer=F4;var N4=1,gG=2,mG=3,vG=4,yG=5,bG=6,pG=7,lG=8,uG=9,$K=10,WK=-32700,GK=-32603,UK=-32602,YK=-32601,ZK=-32600,XK=-32019,PK=-32018,qK=-32017,KK=-32016,CK=-32015,HK=-32014,VK=-32013,jK=-32012,RK=-32011,DK=-32010,MK=-32009,kK=-32008,zK=-32007,FK=-32006,NK=-32005,IK=-32004,SK=-32003,LK=-32002,wK=-32001,t2=2800000,e2=2800001,EK=2800002,I4=2800003,dG=2800004,cG=2800005,S4=2800006,L4=2800007,T6=2800008,w4=2800009,fG=2800010,rG=2800011,E4=3230000,nG=32300001,O4=3230002,iG=3230003,oG=3230004,B4=3610000,_4=3610001,x4=3610002,h4=3610003,g4=3610004,m4=3610005,aG=3610006,OK=3610007,sG=3611000,BK=3704000,_K=3704001,xK=3704002,hK=3704003,gK=3704004,mK=4128000,vK=4128001,yK=4128002,tG=4615000,bK=4615001,pK=4615002,lK=4615003,uK=4615004,dK=4615005,cK=4615006,fK=4615007,rK=4615008,nK=4615009,iK=4615010,oK=4615011,aK=4615012,sK=4615013,tK=4615014,eK=4615015,TC=4615016,AC=4615017,QC=4615018,JC=4615019,$C=4615020,WC=4615021,GC=4615022,UC=4615023,YC=4615024,ZC=4615025,eG=4615026,XC=4615027,PC=4615028,qC=4615029,KC=4615030,CC=4615031,HC=4615032,VC=4615033,jC=4615034,RC=4615035,DC=4615036,MC=4615037,kC=4615038,zC=4615039,FC=4615040,NC=4615041,IC=4615042,SC=4615043,LC=4615044,wC=4615045,EC=4615046,OC=4615047,BC=4615048,_C=4615049,xC=4615050,hC=4615051,gC=4615052,mC=4615053,vC=4615054,v4=5508000,TU=5508001,AU=5508002,QU=5508003,JU=5508004,$U=5508005,WU=5508006,GU=5508007,UU=5508008,YU=5508009,ZU=5508010,yC=5508011,bC=5607000,pC=5607001,lC=5607002,uC=5607003,dC=5607004,cC=5607005,fC=5607006,rC=5607007,nC=5607008,iC=5607009,oC=5607010,aC=5607011,sC=5607012,tC=5607013,eC=5607014,TH=5607015,AH=5607016,QH=5607017,y4=5663000,A6=5663001,b4=5663002,p4=5663003,l4=5663004,XU=5663005,PU=5663006,qU=5663007,KU=5663008,u4=5663009,JH=5663010,$H=5663011,d4=5663012,WH=5663013,GH=5663014,c4=5663015,f4=5663016,CU=5663017,UH=5663018,YH=5663019,HU=5663020,J2=5663021,VU=5663022,r4=5663023,jU=7050000,ZH=7050001,XH=7050002,PH=7050003,qH=7050004,KH=7050005,CH=7050006,HH=7050007,VH=7050008,jH=7050009,RH=7050010,DH=7050011,MH=7050012,kH=7050013,zH=7050014,FH=7050015,NH=7050016,IH=7050017,SH=7050018,LH=7050019,wH=7050020,EH=7050021,OH=7050022,BH=7050023,_H=7050024,xH=7050025,hH=7050026,gH=7050027,mH=7050028,vH=7050029,RU=7050030,DU=7050031,yH=7050032,bH=7050033,pH=7050034,MU=7050035,lH=7050036,uH=7618000,dH=7618001,cH=7618002,fH=7618003,rH=7618004,nH=7618005,iH=7618006,oH=7618007,aH=7618008,sH=7618009,Q6=8078000,$2=8078001,n4=8078002,i4=8078003,J6=8078004,$6=8078005,W6=8078006,l8=8078007,G6=8078008,U6=8078009,Y6=8078010,u8=8078011,C8=8078012,o4=8078013,a4=8078014,Z6=8078015,X6=8078016,MA=8078017,P6=8078018,tH=8078019,s4=8078020,t4=8078021,q6=8078022,e4=8078023,eH=8100000,T7=8100001,A7=8100002,Q7=8100003,J7=8190000,$7=8190001,W7=8190002,G7=8190003,U7=8190004,Y7=8500000,Z7=8500001,X7=8500002,P7=8500003,q7=8500004,K7=8500005,C7=8500006,H7=9900000,V7=9900001,j7=9900002,TJ=9900003,R7=9900004,D7=9900005,M7=9900006;var k7={[E4]:"Account not found at address: $address",[oG]:"Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",[iG]:"Expected decoded account at address: $address",[O4]:"Failed to decode account data at address: $address",[nG]:"Accounts not found at addresses: $addresses",[w4]:"Unable to find a viable program address bump seed.",[EK]:"$putativeAddress is not a base58-encoded address.",[t2]:"Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",[I4]:"The `CryptoKey` must be an `Ed25519` public key.",[rG]:"$putativeOffCurveAddress is not a base58-encoded off-curve address.",[T6]:"Invalid seeds; point must fall off the Ed25519 curve.",[dG]:"Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",[S4]:"A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",[L4]:"The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",[cG]:"Expected program derived address bump to be in the range [0, 255], got: $bump.",[fG]:"Program address cannot end with PDA marker.",[e2]:"Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",[vG]:"Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",[N4]:"The network has progressed past the last block for which this transaction could have been committed.",[Q6]:"Codec [$codecDescription] cannot decode empty byte arrays.",[q6]:"Enum codec cannot use lexical values [$stringValues] as discriminators. Either remove all lexical values or set `useValuesAsDiscriminators` to `false`.",[s4]:"Sentinel [$hexSentinel] must not be present in encoded bytes [$hexEncodedBytes].",[$6]:"Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",[W6]:"Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",[J6]:"Encoder and decoder must either both be fixed-size or variable-size.",[G6]:"Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",[n4]:"Expected a fixed-size codec, got a variable-size one.",[o4]:"Codec [$codecDescription] expected a positive byte length, got $bytesLength.",[i4]:"Expected a variable-size codec, got a fixed-size one.",[tH]:"Codec [$codecDescription] expected zero-value [$hexZeroValue] to have the same size as the provided fixed-size item [$expectedSize bytes].",[$2]:"Codec [$codecDescription] expected $expected bytes, got $bytesLength.",[P6]:"Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",[U6]:"Invalid discriminated union variant. Expected one of [$variants], got $value.",[Y6]:"Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",[Z6]:"Invalid literal union variant. Expected one of [$variants], got $value.",[l8]:"Expected [$codecDescription] to have $expected items, got $actual.",[C8]:"Invalid value $value for base $base with alphabet $alphabet.",[X6]:"Literal union discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",[u8]:"Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",[a4]:"Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",[t4]:"Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",[MA]:"Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",[e4]:"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?",[sG]:"No random values implementation could be found.",[nK]:"instruction requires an uninitialized account",[UC]:"instruction tries to borrow reference for an account which is already borrowed",[YC]:"instruction left account with an outstanding borrowed reference",[WC]:"program other than the account's owner changed the size of the account data",[dK]:"account data too small for instruction",[GC]:"instruction expected an executable account",[EC]:"An account does not have enough lamports to be rent-exempt",[BC]:"Program arithmetic overflowed",[wC]:"Failed to serialize or deserialize account data: $encodedData",[vC]:"Builtin programs must consume compute units",[HC]:"Cross-program invocation call depth too deep",[kC]:"Computational budget exceeded",[eG]:"custom program error: #$code",[AC]:"instruction contains duplicate accounts",[ZC]:"instruction modifications of multiply-passed account differ",[KC]:"executable accounts must be rent exempt",[PC]:"instruction changed executable accounts data",[qC]:"instruction changed the balance of an executable account",[QC]:"instruction changed executable bit of an account",[tK]:"instruction modified data of an account it does not own",[sK]:"instruction spent from the balance of an account it does not own",[bK]:"generic instruction error",[xC]:"Provided owner is not allowed",[SC]:"Account is immutable",[LC]:"Incorrect authority provided",[fK]:"incorrect program id for instruction",[cK]:"insufficient funds for instruction",[uK]:"invalid account data for instruction",[OC]:"Invalid account owner",[pK]:"invalid program argument",[XC]:"program returned invalid error code",[lK]:"invalid instruction data",[MC]:"Failed to reallocate account data",[DC]:"Provided seeds do not result in a valid address",[hC]:"Accounts data allocations exceeded the maximum allowed per transaction",[gC]:"Max accounts exceeded",[mC]:"Max instruction trace length exceeded",[RC]:"Length of the seed is too long for address generation",[VC]:"An account required by the instruction is missing",[rK]:"missing required signature for instruction",[aK]:"instruction illegally modified the program id of an account",[$C]:"insufficient account keys for instruction",[zC]:"Cross-program invocation with unauthorized signer or writable account",[FC]:"Failed to create program execution environment",[IC]:"Program failed to compile",[NC]:"Program failed to complete",[TC]:"instruction modified data of a read-only account",[eK]:"instruction changed the balance of a read-only account",[jC]:"Cross-program invocation reentrancy not allowed for this instruction",[JC]:"instruction modified rent epoch of an account",[oK]:"sum of account balances before and after instruction do not match",[iK]:"instruction requires an initialized account",[tG]:"",[CC]:"Unsupported program id",[_C]:"Unsupported sysvar",[D7]:"Invalid instruction plan kind: $kind.",[cH]:"The provided instruction plan is empty.",[nH]:"No failed transaction plan result was found in the provided transaction plan result.",[rH]:"This transaction plan executor does not support non-divisible sequential plans. To support them, you may create your own executor such that multi-transaction atomicity is preserved — e.g. by targetting RPCs that support transaction bundles.",[fH]:"The provided transaction plan failed to execute. See the `transactionPlanResult` attribute for more details. Note that the `cause` property is deprecated, and a future version will not set it.",[uH]:"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).",[M7]:"Invalid transaction plan kind: $kind.",[dH]:"No more instructions to pack; the message packer has completed the instruction plan.",[iH]:"Unexpected instruction plan. Expected $expectedKind plan, got $actualKind plan.",[oH]:"Unexpected transaction plan. Expected $expectedKind plan, got $actualKind plan.",[aH]:"Unexpected transaction plan result. Expected $expectedKind plan, got $actualKind plan.",[sH]:"Expected a successful transaction plan result. I.e. there is at least one failed or cancelled transaction in the plan.",[mK]:"The instruction does not have any accounts.",[vK]:"The instruction does not have any data.",[yK]:"Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",[yG]:"Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",[gG]:"The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",[j7]:"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",[R7]:"Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",[V7]:"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",[H7]:"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",[TJ]:"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",[GK]:"JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",[UK]:"JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",[ZK]:"JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",[YK]:"JSON-RPC error: The method does not exist / is not available ($__serverMessage)",[WK]:"JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",[jK]:"$__serverMessage",[wK]:"$__serverMessage",[IK]:"$__serverMessage",[HK]:"$__serverMessage",[qK]:"Epoch rewards period still active at slot $slot",[DK]:"$__serverMessage",[MK]:"$__serverMessage",[XK]:"Failed to query long-term storage; please try again",[KK]:"Minimum context slot has not been reached",[NK]:"Node is unhealthy; behind by $numSlotsBehind slots",[kK]:"No snapshot",[LK]:"Transaction simulation failed",[PK]:"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",[zK]:"$__serverMessage",[RK]:"Transaction history is not available from this node",[FK]:"$__serverMessage",[VK]:"Transaction signature length mismatch",[SK]:"Transaction signature verification failure",[CK]:"$__serverMessage",[BK]:"Key pair bytes must be of length 64, got $byteLength.",[_K]:"Expected private key bytes with length 32. Actual length: $actualLength.",[xK]:"Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",[gK]:"The provided private key does not match the provided public key.",[hK]:"Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",[bG]:"Lamports value must be in the range [0, 2e64-1]",[pG]:"`$value` cannot be parsed as a `BigInt`",[$K]:"$message",[lG]:"`$value` cannot be parsed as a `Number`",[mG]:"No nonce account could be found at address `$nonceAccountAddress`",[uC]:"Expected base58 encoded application domain to decode to a byte array of length 32. Actual length: $actualLength.",[tC]:"Attempted to sign an offchain message with an address that is not a signer for it",[lC]:"Expected base58-encoded application domain string of length in the range [32, 44]. Actual length: $actualLength.",[sC]:"The signer addresses in this offchain message envelope do not match the list of required signers in the message preamble. These unexpected signers were present in the envelope: `[$unexpectedSigners]`. These required signers were missing from the envelope `[$missingSigners]`.",[bC]:"The message body provided has a byte-length of $actualBytes. The maximum allowable byte-length is $maxBytes",[rC]:"Expected message format $expectedMessageFormat, got $actualMessageFormat",[nC]:"The message length specified in the message preamble is $specifiedLength bytes. The actual length of the message is $actualLength bytes.",[iC]:"Offchain message content must be non-empty",[cC]:"Offchain message must specify the address of at least one required signer",[oC]:"Offchain message envelope must reserve space for at least one signature",[dC]:"The offchain message preamble specifies $numRequiredSignatures required signature(s), got $signaturesLength.",[TH]:"The signatories of this offchain message must be listed in lexicographical order",[AH]:"An address must be listed no more than once among the signatories of an offchain message",[aC]:"Offchain message is missing signatures for addresses: $addresses.",[QH]:"Offchain message signature verification failed. Signature mismatch for required signatories [$signatoriesWithInvalidSignatures]. Missing signatures for signatories [$signatoriesWithMissingSignatures]",[pC]:"The message body provided contains characters whose codes fall outside the allowed range. In order to ensure clear-signing compatiblity with hardware wallets, the message may only contain line feeds and characters in the range [\\x20-\\x7e].",[eC]:"Expected offchain message version $expectedVersion. Got $actualVersion.",[fC]:"This version of Kit does not support decoding offchain messages with version $unsupportedVersion. The current max supported version is 0.",[C7]:"The provided account could not be identified as an account from the $programName program.",[X7]:"The provided instruction could not be identified as an instruction from the $programName program.",[Y7]:"The provided instruction is missing some accounts. Expected at least $expectedAccountMetas account(s), got $actualAccountMetas.",[q7]:"Expected resolved instruction input '$inputName' to be non-null.",[P7]:"Expected resolved instruction input '$inputName' to be of type `$expectedType`.",[K7]:"Unrecognized account type '$accountType' for the $programName program.",[Z7]:"Unrecognized instruction type '$instructionType' for the $programName program.",[J7]:"The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",[W7]:"WebSocket was closed before payload could be added to the send buffer",[G7]:"WebSocket connection closed",[U7]:"WebSocket failed to connect",[$7]:"Failed to obtain a subscription id from the server",[Q7]:"Could not find an API plan for RPC method: `$method`",[eH]:"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`.",[A7]:"HTTP error ($statusCode): $message",[T7]:"HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",[v4]:"Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",[TU]:"The provided value does not implement the `KeyPairSigner` interface",[QU]:"The provided value does not implement the `MessageModifyingSigner` interface",[JU]:"The provided value does not implement the `MessagePartialSigner` interface",[AU]:"The provided value does not implement any of the `MessageSigner` interfaces",[WU]:"The provided value does not implement the `TransactionModifyingSigner` interface",[GU]:"The provided value does not implement the `TransactionPartialSigner` interface",[UU]:"The provided value does not implement the `TransactionSendingSigner` interface",[$U]:"The provided value does not implement any of the `TransactionSigner` interfaces",[YU]:"More than one `TransactionSendingSigner` was identified.",[ZU]:"No `TransactionSendingSigner` was identified. Please provide a valid `TransactionWithSingleSendingSigner` transaction.",[yC]:"Wallet account signers do not support signing multiple messages/transactions in a single operation",[OK]:"Cannot export a non-extractable key.",[_4]:"No digest implementation could be found.",[B4]:"Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",[x4]:`This runtime does not support the generation of Ed25519 key pairs.
6
+ */var F4=RG(),D8=FG(),DG=typeof Symbol==="function"&&typeof Symbol.for==="function"?Symbol.for("nodejs.util.inspect.custom"):null;var E4=g;var vG=50;var D4=2147483647;g.TYPED_ARRAY_SUPPORT=yZ();if(!g.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 yZ(){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(g.prototype,"parent",{enumerable:!0,get:function(){if(!g.isBuffer(this))return;return this.buffer}});Object.defineProperty(g.prototype,"offset",{enumerable:!0,get:function(){if(!g.isBuffer(this))return;return this.byteOffset}});function f0(T){if(T>D4)throw RangeError('The value "'+T+'" is invalid for option "size"');let A=new Uint8Array(T);return Object.setPrototypeOf(A,g.prototype),A}function g(T,A,C){if(typeof T==="number"){if(typeof A==="string")throw TypeError('The "string" argument must be of type string. Received type number');return I4(T)}return IG(T,A,C)}g.poolSize=8192;function IG(T,A,C){if(typeof T==="string")return lZ(T,A);if(ArrayBuffer.isView(T))return pZ(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(L0(T,ArrayBuffer)||T&&L0(T.buffer,ArrayBuffer))return S4(T,A,C);if(typeof SharedArrayBuffer<"u"&&(L0(T,SharedArrayBuffer)||T&&L0(T.buffer,SharedArrayBuffer)))return S4(T,A,C);if(typeof T==="number")throw TypeError('The "value" argument must not be of type number. Received type number');let P=T.valueOf&&T.valueOf();if(P!=null&&P!==T)return g.from(P,A,C);let Q=uZ(T);if(Q)return Q;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof T[Symbol.toPrimitive]==="function")return g.from(T[Symbol.toPrimitive]("string"),A,C);throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof T)}g.from=function(T,A,C){return IG(T,A,C)};Object.setPrototypeOf(g.prototype,Uint8Array.prototype);Object.setPrototypeOf(g,Uint8Array);function NG(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 bZ(T,A,C){if(NG(T),T<=0)return f0(T);if(A!==void 0)return typeof C==="string"?f0(T).fill(A,C):f0(T).fill(A);return f0(T)}g.alloc=function(T,A,C){return bZ(T,A,C)};function I4(T){return NG(T),f0(T<0?0:N4(T)|0)}g.allocUnsafe=function(T){return I4(T)};g.allocUnsafeSlow=function(T){return I4(T)};function lZ(T,A){if(typeof A!=="string"||A==="")A="utf8";if(!g.isEncoding(A))throw TypeError("Unknown encoding: "+A);let C=LG(T,A)|0,P=f0(C),Q=P.write(T,A);if(Q!==C)P=P.slice(0,Q);return P}function z4(T){let A=T.length<0?0:N4(T.length)|0,C=f0(A);for(let P=0;P<A;P+=1)C[P]=T[P]&255;return C}function pZ(T){if(L0(T,Uint8Array)){let A=new Uint8Array(T);return S4(A.buffer,A.byteOffset,A.byteLength)}return z4(T)}function S4(T,A,C){if(A<0||T.byteLength<A)throw RangeError('"offset" is outside of buffer bounds');if(T.byteLength<A+(C||0))throw RangeError('"length" is outside of buffer bounds');let P;if(A===void 0&&C===void 0)P=new Uint8Array(T);else if(C===void 0)P=new Uint8Array(T,A);else P=new Uint8Array(T,A,C);return Object.setPrototypeOf(P,g.prototype),P}function uZ(T){if(g.isBuffer(T)){let A=N4(T.length)|0,C=f0(A);if(C.length===0)return C;return T.copy(C,0,0,A),C}if(T.length!==void 0){if(typeof T.length!=="number"||w4(T.length))return f0(0);return z4(T)}if(T.type==="Buffer"&&Array.isArray(T.data))return z4(T.data)}function N4(T){if(T>=D4)throw RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+D4.toString(16)+" bytes");return T|0}g.isBuffer=function(A){return A!=null&&A._isBuffer===!0&&A!==g.prototype};g.compare=function(A,C){if(L0(A,Uint8Array))A=g.from(A,A.offset,A.byteLength);if(L0(C,Uint8Array))C=g.from(C,C.offset,C.byteLength);if(!g.isBuffer(A)||!g.isBuffer(C))throw TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(A===C)return 0;let P=A.length,Q=C.length;for(let W=0,G=Math.min(P,Q);W<G;++W)if(A[W]!==C[W]){P=A[W],Q=C[W];break}if(P<Q)return-1;if(Q<P)return 1;return 0};g.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}};g.concat=function(A,C){if(!Array.isArray(A))throw TypeError('"list" argument must be an Array of Buffers');if(A.length===0)return g.alloc(0);let P;if(C===void 0){C=0;for(P=0;P<A.length;++P)C+=A[P].length}let Q=g.allocUnsafe(C),W=0;for(P=0;P<A.length;++P){let G=A[P];if(L0(G,Uint8Array))if(W+G.length>Q.length){if(!g.isBuffer(G))G=g.from(G);G.copy(Q,W)}else Uint8Array.prototype.set.call(Q,G,W);else if(!g.isBuffer(G))throw TypeError('"list" argument must be an Array of Buffers');else G.copy(Q,W);W+=G.length}return Q};function LG(T,A){if(g.isBuffer(T))return T.length;if(ArrayBuffer.isView(T)||L0(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 C=T.length,P=arguments.length>2&&arguments[2]===!0;if(!P&&C===0)return 0;let Q=!1;for(;;)switch(A){case"ascii":case"latin1":case"binary":return C;case"utf8":case"utf-8":return M4(T).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C*2;case"hex":return C>>>1;case"base64":return gG(T).length;default:if(Q)return P?-1:M4(T).length;A=(""+A).toLowerCase(),Q=!0}}g.byteLength=LG;function dZ(T,A,C){let P=!1;if(A===void 0||A<0)A=0;if(A>this.length)return"";if(C===void 0||C>this.length)C=this.length;if(C<=0)return"";if(C>>>=0,A>>>=0,C<=A)return"";if(!T)T="utf8";while(!0)switch(T){case"hex":return eZ(this,A,C);case"utf8":case"utf-8":return EG(this,A,C);case"ascii":return sZ(this,A,C);case"latin1":case"binary":return tZ(this,A,C);case"base64":return nZ(this,A,C);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Tq(this,A,C);default:if(P)throw TypeError("Unknown encoding: "+T);T=(T+"").toLowerCase(),P=!0}}g.prototype._isBuffer=!0;function uA(T,A,C){let P=T[A];T[A]=T[C],T[C]=P}g.prototype.swap16=function(){let A=this.length;if(A%2!==0)throw RangeError("Buffer size must be a multiple of 16-bits");for(let C=0;C<A;C+=2)uA(this,C,C+1);return this};g.prototype.swap32=function(){let A=this.length;if(A%4!==0)throw RangeError("Buffer size must be a multiple of 32-bits");for(let C=0;C<A;C+=4)uA(this,C,C+3),uA(this,C+1,C+2);return this};g.prototype.swap64=function(){let A=this.length;if(A%8!==0)throw RangeError("Buffer size must be a multiple of 64-bits");for(let C=0;C<A;C+=8)uA(this,C,C+7),uA(this,C+1,C+6),uA(this,C+2,C+5),uA(this,C+3,C+4);return this};g.prototype.toString=function(){let A=this.length;if(A===0)return"";if(arguments.length===0)return EG(this,0,A);return dZ.apply(this,arguments)};g.prototype.toLocaleString=g.prototype.toString;g.prototype.equals=function(A){if(!g.isBuffer(A))throw TypeError("Argument must be a Buffer");if(this===A)return!0;return g.compare(this,A)===0};g.prototype.inspect=function(){let A="",C=vG;if(A=this.toString("hex",0,C).replace(/(.{2})/g,"$1 ").trim(),this.length>C)A+=" ... ";return"<Buffer "+A+">"};if(DG)g.prototype[DG]=g.prototype.inspect;g.prototype.compare=function(A,C,P,Q,W){if(L0(A,Uint8Array))A=g.from(A,A.offset,A.byteLength);if(!g.isBuffer(A))throw TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof A);if(C===void 0)C=0;if(P===void 0)P=A?A.length:0;if(Q===void 0)Q=0;if(W===void 0)W=this.length;if(C<0||P>A.length||Q<0||W>this.length)throw RangeError("out of range index");if(Q>=W&&C>=P)return 0;if(Q>=W)return-1;if(C>=P)return 1;if(C>>>=0,P>>>=0,Q>>>=0,W>>>=0,this===A)return 0;let G=W-Q,U=P-C,$=Math.min(G,U),X=this.slice(Q,W),q=A.slice(C,P);for(let K=0;K<$;++K)if(X[K]!==q[K]){G=X[K],U=q[K];break}if(G<U)return-1;if(U<G)return 1;return 0};function wG(T,A,C,P,Q){if(T.length===0)return-1;if(typeof C==="string")P=C,C=0;else if(C>2147483647)C=2147483647;else if(C<-2147483648)C=-2147483648;if(C=+C,w4(C))C=Q?0:T.length-1;if(C<0)C=T.length+C;if(C>=T.length)if(Q)return-1;else C=T.length-1;else if(C<0)if(Q)C=0;else return-1;if(typeof A==="string")A=g.from(A,P);if(g.isBuffer(A)){if(A.length===0)return-1;return zG(T,A,C,P,Q)}else if(typeof A==="number"){if(A=A&255,typeof Uint8Array.prototype.indexOf==="function")if(Q)return Uint8Array.prototype.indexOf.call(T,A,C);else return Uint8Array.prototype.lastIndexOf.call(T,A,C);return zG(T,[A],C,P,Q)}throw TypeError("val must be string, number or Buffer")}function zG(T,A,C,P,Q){let W=1,G=T.length,U=A.length;if(P!==void 0){if(P=String(P).toLowerCase(),P==="ucs2"||P==="ucs-2"||P==="utf16le"||P==="utf-16le"){if(T.length<2||A.length<2)return-1;W=2,G/=2,U/=2,C/=2}}function $(q,K){if(W===1)return q[K];else return q.readUInt16BE(K*W)}let X;if(Q){let q=-1;for(X=C;X<G;X++)if($(T,X)===$(A,q===-1?0:X-q)){if(q===-1)q=X;if(X-q+1===U)return q*W}else{if(q!==-1)X-=X-q;q=-1}}else{if(C+U>G)C=G-U;for(X=C;X>=0;X--){let q=!0;for(let K=0;K<U;K++)if($(T,X+K)!==$(A,K)){q=!1;break}if(q)return X}}return-1}g.prototype.includes=function(A,C,P){return this.indexOf(A,C,P)!==-1};g.prototype.indexOf=function(A,C,P){return wG(this,A,C,P,!0)};g.prototype.lastIndexOf=function(A,C,P){return wG(this,A,C,P,!1)};function rZ(T,A,C,P){C=Number(C)||0;let Q=T.length-C;if(!P)P=Q;else if(P=Number(P),P>Q)P=Q;let W=A.length;if(P>W/2)P=W/2;let G;for(G=0;G<P;++G){let U=parseInt(A.substr(G*2,2),16);if(w4(U))return G;T[C+G]=U}return G}function fZ(T,A,C,P){return A6(M4(A,T.length-C),T,C,P)}function iZ(T,A,C,P){return A6(Qq(A),T,C,P)}function cZ(T,A,C,P){return A6(gG(A),T,C,P)}function oZ(T,A,C,P){return A6(Wq(A,T.length-C),T,C,P)}g.prototype.write=function(A,C,P,Q){if(C===void 0)Q="utf8",P=this.length,C=0;else if(P===void 0&&typeof C==="string")Q=C,P=this.length,C=0;else if(isFinite(C))if(C=C>>>0,isFinite(P)){if(P=P>>>0,Q===void 0)Q="utf8"}else Q=P,P=void 0;else throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let W=this.length-C;if(P===void 0||P>W)P=W;if(A.length>0&&(P<0||C<0)||C>this.length)throw RangeError("Attempt to write outside buffer bounds");if(!Q)Q="utf8";let G=!1;for(;;)switch(Q){case"hex":return rZ(this,A,C,P);case"utf8":case"utf-8":return fZ(this,A,C,P);case"ascii":case"latin1":case"binary":return iZ(this,A,C,P);case"base64":return cZ(this,A,C,P);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return oZ(this,A,C,P);default:if(G)throw TypeError("Unknown encoding: "+Q);Q=(""+Q).toLowerCase(),G=!0}};g.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function nZ(T,A,C){if(A===0&&C===T.length)return F4.fromByteArray(T);else return F4.fromByteArray(T.slice(A,C))}function EG(T,A,C){C=Math.min(T.length,C);let P=[],Q=A;while(Q<C){let W=T[Q],G=null,U=W>239?4:W>223?3:W>191?2:1;if(Q+U<=C){let $,X,q,K;switch(U){case 1:if(W<128)G=W;break;case 2:if($=T[Q+1],($&192)===128){if(K=(W&31)<<6|$&63,K>127)G=K}break;case 3:if($=T[Q+1],X=T[Q+2],($&192)===128&&(X&192)===128){if(K=(W&15)<<12|($&63)<<6|X&63,K>2047&&(K<55296||K>57343))G=K}break;case 4:if($=T[Q+1],X=T[Q+2],q=T[Q+3],($&192)===128&&(X&192)===128&&(q&192)===128){if(K=(W&15)<<18|($&63)<<12|(X&63)<<6|q&63,K>65535&&K<1114112)G=K}}}if(G===null)G=65533,U=1;else if(G>65535)G-=65536,P.push(G>>>10&1023|55296),G=56320|G&1023;P.push(G),Q+=U}return aZ(P)}var SG=4096;function aZ(T){let A=T.length;if(A<=SG)return String.fromCharCode.apply(String,T);let C="",P=0;while(P<A)C+=String.fromCharCode.apply(String,T.slice(P,P+=SG));return C}function sZ(T,A,C){let P="";C=Math.min(T.length,C);for(let Q=A;Q<C;++Q)P+=String.fromCharCode(T[Q]&127);return P}function tZ(T,A,C){let P="";C=Math.min(T.length,C);for(let Q=A;Q<C;++Q)P+=String.fromCharCode(T[Q]);return P}function eZ(T,A,C){let P=T.length;if(!A||A<0)A=0;if(!C||C<0||C>P)C=P;let Q="";for(let W=A;W<C;++W)Q+=Gq[T[W]];return Q}function Tq(T,A,C){let P=T.slice(A,C),Q="";for(let W=0;W<P.length-1;W+=2)Q+=String.fromCharCode(P[W]+P[W+1]*256);return Q}g.prototype.slice=function(A,C){let P=this.length;if(A=~~A,C=C===void 0?P:~~C,A<0){if(A+=P,A<0)A=0}else if(A>P)A=P;if(C<0){if(C+=P,C<0)C=0}else if(C>P)C=P;if(C<A)C=A;let Q=this.subarray(A,C);return Object.setPrototypeOf(Q,g.prototype),Q};function zT(T,A,C){if(T%1!==0||T<0)throw RangeError("offset is not uint");if(T+A>C)throw RangeError("Trying to access beyond buffer length")}g.prototype.readUintLE=g.prototype.readUIntLE=function(A,C,P){if(A=A>>>0,C=C>>>0,!P)zT(A,C,this.length);let Q=this[A],W=1,G=0;while(++G<C&&(W*=256))Q+=this[A+G]*W;return Q};g.prototype.readUintBE=g.prototype.readUIntBE=function(A,C,P){if(A=A>>>0,C=C>>>0,!P)zT(A,C,this.length);let Q=this[A+--C],W=1;while(C>0&&(W*=256))Q+=this[A+--C]*W;return Q};g.prototype.readUint8=g.prototype.readUInt8=function(A,C){if(A=A>>>0,!C)zT(A,1,this.length);return this[A]};g.prototype.readUint16LE=g.prototype.readUInt16LE=function(A,C){if(A=A>>>0,!C)zT(A,2,this.length);return this[A]|this[A+1]<<8};g.prototype.readUint16BE=g.prototype.readUInt16BE=function(A,C){if(A=A>>>0,!C)zT(A,2,this.length);return this[A]<<8|this[A+1]};g.prototype.readUint32LE=g.prototype.readUInt32LE=function(A,C){if(A=A>>>0,!C)zT(A,4,this.length);return(this[A]|this[A+1]<<8|this[A+2]<<16)+this[A+3]*16777216};g.prototype.readUint32BE=g.prototype.readUInt32BE=function(A,C){if(A=A>>>0,!C)zT(A,4,this.length);return this[A]*16777216+(this[A+1]<<16|this[A+2]<<8|this[A+3])};g.prototype.readBigUInt64LE=HA(function(A){A=A>>>0,z8(A,"offset");let C=this[A],P=this[A+7];if(C===void 0||P===void 0)W2(A,this.length-8);let Q=C+this[++A]*256+this[++A]*65536+this[++A]*16777216,W=this[++A]+this[++A]*256+this[++A]*65536+P*16777216;return BigInt(Q)+(BigInt(W)<<BigInt(32))});g.prototype.readBigUInt64BE=HA(function(A){A=A>>>0,z8(A,"offset");let C=this[A],P=this[A+7];if(C===void 0||P===void 0)W2(A,this.length-8);let Q=C*16777216+this[++A]*65536+this[++A]*256+this[++A],W=this[++A]*16777216+this[++A]*65536+this[++A]*256+P;return(BigInt(Q)<<BigInt(32))+BigInt(W)});g.prototype.readIntLE=function(A,C,P){if(A=A>>>0,C=C>>>0,!P)zT(A,C,this.length);let Q=this[A],W=1,G=0;while(++G<C&&(W*=256))Q+=this[A+G]*W;if(W*=128,Q>=W)Q-=Math.pow(2,8*C);return Q};g.prototype.readIntBE=function(A,C,P){if(A=A>>>0,C=C>>>0,!P)zT(A,C,this.length);let Q=C,W=1,G=this[A+--Q];while(Q>0&&(W*=256))G+=this[A+--Q]*W;if(W*=128,G>=W)G-=Math.pow(2,8*C);return G};g.prototype.readInt8=function(A,C){if(A=A>>>0,!C)zT(A,1,this.length);if(!(this[A]&128))return this[A];return(255-this[A]+1)*-1};g.prototype.readInt16LE=function(A,C){if(A=A>>>0,!C)zT(A,2,this.length);let P=this[A]|this[A+1]<<8;return P&32768?P|4294901760:P};g.prototype.readInt16BE=function(A,C){if(A=A>>>0,!C)zT(A,2,this.length);let P=this[A+1]|this[A]<<8;return P&32768?P|4294901760:P};g.prototype.readInt32LE=function(A,C){if(A=A>>>0,!C)zT(A,4,this.length);return this[A]|this[A+1]<<8|this[A+2]<<16|this[A+3]<<24};g.prototype.readInt32BE=function(A,C){if(A=A>>>0,!C)zT(A,4,this.length);return this[A]<<24|this[A+1]<<16|this[A+2]<<8|this[A+3]};g.prototype.readBigInt64LE=HA(function(A){A=A>>>0,z8(A,"offset");let C=this[A],P=this[A+7];if(C===void 0||P===void 0)W2(A,this.length-8);let Q=this[A+4]+this[A+5]*256+this[A+6]*65536+(P<<24);return(BigInt(Q)<<BigInt(32))+BigInt(C+this[++A]*256+this[++A]*65536+this[++A]*16777216)});g.prototype.readBigInt64BE=HA(function(A){A=A>>>0,z8(A,"offset");let C=this[A],P=this[A+7];if(C===void 0||P===void 0)W2(A,this.length-8);let Q=(C<<24)+this[++A]*65536+this[++A]*256+this[++A];return(BigInt(Q)<<BigInt(32))+BigInt(this[++A]*16777216+this[++A]*65536+this[++A]*256+P)});g.prototype.readFloatLE=function(A,C){if(A=A>>>0,!C)zT(A,4,this.length);return D8.read(this,A,!0,23,4)};g.prototype.readFloatBE=function(A,C){if(A=A>>>0,!C)zT(A,4,this.length);return D8.read(this,A,!1,23,4)};g.prototype.readDoubleLE=function(A,C){if(A=A>>>0,!C)zT(A,8,this.length);return D8.read(this,A,!0,52,8)};g.prototype.readDoubleBE=function(A,C){if(A=A>>>0,!C)zT(A,8,this.length);return D8.read(this,A,!1,52,8)};function aT(T,A,C,P,Q,W){if(!g.isBuffer(T))throw TypeError('"buffer" argument must be a Buffer instance');if(A>Q||A<W)throw RangeError('"value" argument is out of bounds');if(C+P>T.length)throw RangeError("Index out of range")}g.prototype.writeUintLE=g.prototype.writeUIntLE=function(A,C,P,Q){if(A=+A,C=C>>>0,P=P>>>0,!Q){let U=Math.pow(2,8*P)-1;aT(this,A,C,P,U,0)}let W=1,G=0;this[C]=A&255;while(++G<P&&(W*=256))this[C+G]=A/W&255;return C+P};g.prototype.writeUintBE=g.prototype.writeUIntBE=function(A,C,P,Q){if(A=+A,C=C>>>0,P=P>>>0,!Q){let U=Math.pow(2,8*P)-1;aT(this,A,C,P,U,0)}let W=P-1,G=1;this[C+W]=A&255;while(--W>=0&&(G*=256))this[C+W]=A/G&255;return C+P};g.prototype.writeUint8=g.prototype.writeUInt8=function(A,C,P){if(A=+A,C=C>>>0,!P)aT(this,A,C,1,255,0);return this[C]=A&255,C+1};g.prototype.writeUint16LE=g.prototype.writeUInt16LE=function(A,C,P){if(A=+A,C=C>>>0,!P)aT(this,A,C,2,65535,0);return this[C]=A&255,this[C+1]=A>>>8,C+2};g.prototype.writeUint16BE=g.prototype.writeUInt16BE=function(A,C,P){if(A=+A,C=C>>>0,!P)aT(this,A,C,2,65535,0);return this[C]=A>>>8,this[C+1]=A&255,C+2};g.prototype.writeUint32LE=g.prototype.writeUInt32LE=function(A,C,P){if(A=+A,C=C>>>0,!P)aT(this,A,C,4,4294967295,0);return this[C+3]=A>>>24,this[C+2]=A>>>16,this[C+1]=A>>>8,this[C]=A&255,C+4};g.prototype.writeUint32BE=g.prototype.writeUInt32BE=function(A,C,P){if(A=+A,C=C>>>0,!P)aT(this,A,C,4,4294967295,0);return this[C]=A>>>24,this[C+1]=A>>>16,this[C+2]=A>>>8,this[C+3]=A&255,C+4};function BG(T,A,C,P,Q){mG(A,P,Q,T,C,7);let W=Number(A&BigInt(4294967295));T[C++]=W,W=W>>8,T[C++]=W,W=W>>8,T[C++]=W,W=W>>8,T[C++]=W;let G=Number(A>>BigInt(32)&BigInt(4294967295));return T[C++]=G,G=G>>8,T[C++]=G,G=G>>8,T[C++]=G,G=G>>8,T[C++]=G,C}function OG(T,A,C,P,Q){mG(A,P,Q,T,C,7);let W=Number(A&BigInt(4294967295));T[C+7]=W,W=W>>8,T[C+6]=W,W=W>>8,T[C+5]=W,W=W>>8,T[C+4]=W;let G=Number(A>>BigInt(32)&BigInt(4294967295));return T[C+3]=G,G=G>>8,T[C+2]=G,G=G>>8,T[C+1]=G,G=G>>8,T[C]=G,C+8}g.prototype.writeBigUInt64LE=HA(function(A,C=0){return BG(this,A,C,BigInt(0),BigInt("0xffffffffffffffff"))});g.prototype.writeBigUInt64BE=HA(function(A,C=0){return OG(this,A,C,BigInt(0),BigInt("0xffffffffffffffff"))});g.prototype.writeIntLE=function(A,C,P,Q){if(A=+A,C=C>>>0,!Q){let $=Math.pow(2,8*P-1);aT(this,A,C,P,$-1,-$)}let W=0,G=1,U=0;this[C]=A&255;while(++W<P&&(G*=256)){if(A<0&&U===0&&this[C+W-1]!==0)U=1;this[C+W]=(A/G>>0)-U&255}return C+P};g.prototype.writeIntBE=function(A,C,P,Q){if(A=+A,C=C>>>0,!Q){let $=Math.pow(2,8*P-1);aT(this,A,C,P,$-1,-$)}let W=P-1,G=1,U=0;this[C+W]=A&255;while(--W>=0&&(G*=256)){if(A<0&&U===0&&this[C+W+1]!==0)U=1;this[C+W]=(A/G>>0)-U&255}return C+P};g.prototype.writeInt8=function(A,C,P){if(A=+A,C=C>>>0,!P)aT(this,A,C,1,127,-128);if(A<0)A=255+A+1;return this[C]=A&255,C+1};g.prototype.writeInt16LE=function(A,C,P){if(A=+A,C=C>>>0,!P)aT(this,A,C,2,32767,-32768);return this[C]=A&255,this[C+1]=A>>>8,C+2};g.prototype.writeInt16BE=function(A,C,P){if(A=+A,C=C>>>0,!P)aT(this,A,C,2,32767,-32768);return this[C]=A>>>8,this[C+1]=A&255,C+2};g.prototype.writeInt32LE=function(A,C,P){if(A=+A,C=C>>>0,!P)aT(this,A,C,4,2147483647,-2147483648);return this[C]=A&255,this[C+1]=A>>>8,this[C+2]=A>>>16,this[C+3]=A>>>24,C+4};g.prototype.writeInt32BE=function(A,C,P){if(A=+A,C=C>>>0,!P)aT(this,A,C,4,2147483647,-2147483648);if(A<0)A=4294967295+A+1;return this[C]=A>>>24,this[C+1]=A>>>16,this[C+2]=A>>>8,this[C+3]=A&255,C+4};g.prototype.writeBigInt64LE=HA(function(A,C=0){return BG(this,A,C,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});g.prototype.writeBigInt64BE=HA(function(A,C=0){return OG(this,A,C,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function _G(T,A,C,P,Q,W){if(C+P>T.length)throw RangeError("Index out of range");if(C<0)throw RangeError("Index out of range")}function xG(T,A,C,P,Q){if(A=+A,C=C>>>0,!Q)_G(T,A,C,4,340282346638528860000000000000000000000,-340282346638528860000000000000000000000);return D8.write(T,A,C,P,23,4),C+4}g.prototype.writeFloatLE=function(A,C,P){return xG(this,A,C,!0,P)};g.prototype.writeFloatBE=function(A,C,P){return xG(this,A,C,!1,P)};function hG(T,A,C,P,Q){if(A=+A,C=C>>>0,!Q)_G(T,A,C,8,179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,-179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000);return D8.write(T,A,C,P,52,8),C+8}g.prototype.writeDoubleLE=function(A,C,P){return hG(this,A,C,!0,P)};g.prototype.writeDoubleBE=function(A,C,P){return hG(this,A,C,!1,P)};g.prototype.copy=function(A,C,P,Q){if(!g.isBuffer(A))throw TypeError("argument should be a Buffer");if(!P)P=0;if(!Q&&Q!==0)Q=this.length;if(C>=A.length)C=A.length;if(!C)C=0;if(Q>0&&Q<P)Q=P;if(Q===P)return 0;if(A.length===0||this.length===0)return 0;if(C<0)throw RangeError("targetStart out of bounds");if(P<0||P>=this.length)throw RangeError("Index out of range");if(Q<0)throw RangeError("sourceEnd out of bounds");if(Q>this.length)Q=this.length;if(A.length-C<Q-P)Q=A.length-C+P;let W=Q-P;if(this===A&&typeof Uint8Array.prototype.copyWithin==="function")this.copyWithin(C,P,Q);else Uint8Array.prototype.set.call(A,this.subarray(P,Q),C);return W};g.prototype.fill=function(A,C,P,Q){if(typeof A==="string"){if(typeof C==="string")Q=C,C=0,P=this.length;else if(typeof P==="string")Q=P,P=this.length;if(Q!==void 0&&typeof Q!=="string")throw TypeError("encoding must be a string");if(typeof Q==="string"&&!g.isEncoding(Q))throw TypeError("Unknown encoding: "+Q);if(A.length===1){let G=A.charCodeAt(0);if(Q==="utf8"&&G<128||Q==="latin1")A=G}}else if(typeof A==="number")A=A&255;else if(typeof A==="boolean")A=Number(A);if(C<0||this.length<C||this.length<P)throw RangeError("Out of range index");if(P<=C)return this;if(C=C>>>0,P=P===void 0?this.length:P>>>0,!A)A=0;let W;if(typeof A==="number")for(W=C;W<P;++W)this[W]=A;else{let G=g.isBuffer(A)?A:g.from(A,Q),U=G.length;if(U===0)throw TypeError('The value "'+A+'" is invalid for argument "value"');for(W=0;W<P-C;++W)this[W+C]=G[W%U]}return this};var F8={};function L4(T,A,C){F8[T]=class extends C{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(Q){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:Q,writable:!0})}toString(){return`${this.name} [${T}]: ${this.message}`}}}L4("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);L4("ERR_INVALID_ARG_TYPE",function(T,A){return`The "${T}" argument must be of type number. Received type ${typeof A}`},TypeError);L4("ERR_OUT_OF_RANGE",function(T,A,C){let P=`The value of "${T}" is out of range.`,Q=C;if(Number.isInteger(C)&&Math.abs(C)>4294967296)Q=MG(String(C));else if(typeof C==="bigint"){if(Q=String(C),C>BigInt(2)**BigInt(32)||C<-(BigInt(2)**BigInt(32)))Q=MG(Q);Q+="n"}return P+=` It must be ${A}. Received ${Q}`,P},RangeError);function MG(T){let A="",C=T.length,P=T[0]==="-"?1:0;for(;C>=P+4;C-=3)A=`_${T.slice(C-3,C)}${A}`;return`${T.slice(0,C)}${A}`}function Aq(T,A,C){if(z8(A,"offset"),T[A]===void 0||T[A+C]===void 0)W2(A,T.length-(C+1))}function mG(T,A,C,P,Q,W){if(T>C||T<A){let G=typeof A==="bigint"?"n":"",U;if(W>3)if(A===0||A===BigInt(0))U=`>= 0${G} and < 2${G} ** ${(W+1)*8}${G}`;else U=`>= -(2${G} ** ${(W+1)*8-1}${G}) and < 2 ** ${(W+1)*8-1}${G}`;else U=`>= ${A}${G} and <= ${C}${G}`;throw new F8.ERR_OUT_OF_RANGE("value",U,T)}Aq(P,Q,W)}function z8(T,A){if(typeof T!=="number")throw new F8.ERR_INVALID_ARG_TYPE(A,"number",T)}function W2(T,A,C){if(Math.floor(T)!==T)throw z8(T,C),new F8.ERR_OUT_OF_RANGE(C||"offset","an integer",T);if(A<0)throw new F8.ERR_BUFFER_OUT_OF_BOUNDS;throw new F8.ERR_OUT_OF_RANGE(C||"offset",`>= ${C?1:0} and <= ${A}`,T)}var Cq=/[^+/0-9A-Za-z-_]/g;function Pq(T){if(T=T.split("=")[0],T=T.trim().replace(Cq,""),T.length<2)return"";while(T.length%4!==0)T=T+"=";return T}function M4(T,A){A=A||1/0;let C,P=T.length,Q=null,W=[];for(let G=0;G<P;++G){if(C=T.charCodeAt(G),C>55295&&C<57344){if(!Q){if(C>56319){if((A-=3)>-1)W.push(239,191,189);continue}else if(G+1===P){if((A-=3)>-1)W.push(239,191,189);continue}Q=C;continue}if(C<56320){if((A-=3)>-1)W.push(239,191,189);Q=C;continue}C=(Q-55296<<10|C-56320)+65536}else if(Q){if((A-=3)>-1)W.push(239,191,189)}if(Q=null,C<128){if((A-=1)<0)break;W.push(C)}else if(C<2048){if((A-=2)<0)break;W.push(C>>6|192,C&63|128)}else if(C<65536){if((A-=3)<0)break;W.push(C>>12|224,C>>6&63|128,C&63|128)}else if(C<1114112){if((A-=4)<0)break;W.push(C>>18|240,C>>12&63|128,C>>6&63|128,C&63|128)}else throw Error("Invalid code point")}return W}function Qq(T){let A=[];for(let C=0;C<T.length;++C)A.push(T.charCodeAt(C)&255);return A}function Wq(T,A){let C,P,Q,W=[];for(let G=0;G<T.length;++G){if((A-=2)<0)break;C=T.charCodeAt(G),P=C>>8,Q=C%256,W.push(Q),W.push(P)}return W}function gG(T){return F4.toByteArray(Pq(T))}function A6(T,A,C,P){let Q;for(Q=0;Q<P;++Q){if(Q+C>=A.length||Q>=T.length)break;A[Q+C]=T[Q]}return Q}function L0(T,A){return T instanceof A||T!=null&&T.constructor!=null&&T.constructor.name!=null&&T.constructor.name===A.name}function w4(T){return T!==T}var Gq=function(){let A=Array(256);for(let C=0;C<16;++C){let P=C*16;for(let Q=0;Q<16;++Q)A[P+Q]="0123456789abcdef"[C]+"0123456789abcdef"[Q]}return A}();function HA(T){return typeof BigInt>"u"?Jq:T}function Jq(){throw Error("BigInt not supported")}if(typeof globalThis.Buffer>"u")globalThis.Buffer=E4;var B4=1,yG=2,bG=3,lG=4,pG=5,uG=6,dG=7,rG=8,fG=9,Uq=10,$q=-32700,Vq=-32603,Yq=-32602,Zq=-32601,qq=-32600,Xq=-32019,Hq=-32018,Kq=-32017,kq=-32016,jq=-32015,Rq=-32014,Fq=-32013,Dq=-32012,zq=-32011,Sq=-32010,Mq=-32009,Iq=-32008,Nq=-32007,Lq=-32006,wq=-32005,Eq=-32004,Bq=-32003,Oq=-32002,_q=-32001,C6=2800000,P6=2800001,xq=2800002,O4=2800003,iG=2800004,cG=2800005,_4=2800006,x4=2800007,Q6=2800008,h4=2800009,oG=2800010,nG=2800011,m4=3230000,aG=32300001,g4=3230002,sG=3230003,tG=3230004,v4=3610000,y4=3610001,b4=3610002,l4=3610003,p4=3610004,u4=3610005,eG=3610006,hq=3610007,TJ=3611000,mq=3704000,gq=3704001,vq=3704002,yq=3704003,bq=3704004,lq=4128000,pq=4128001,uq=4128002,AJ=4615000,dq=4615001,rq=4615002,fq=4615003,iq=4615004,cq=4615005,oq=4615006,nq=4615007,aq=4615008,sq=4615009,tq=4615010,eq=4615011,TX=4615012,AX=4615013,CX=4615014,PX=4615015,QX=4615016,WX=4615017,GX=4615018,JX=4615019,UX=4615020,$X=4615021,VX=4615022,YX=4615023,ZX=4615024,qX=4615025,CJ=4615026,XX=4615027,HX=4615028,KX=4615029,kX=4615030,jX=4615031,RX=4615032,FX=4615033,DX=4615034,zX=4615035,SX=4615036,MX=4615037,IX=4615038,NX=4615039,LX=4615040,wX=4615041,EX=4615042,BX=4615043,OX=4615044,_X=4615045,xX=4615046,hX=4615047,mX=4615048,gX=4615049,vX=4615050,yX=4615051,bX=4615052,lX=4615053,pX=4615054,d4=5508000,PJ=5508001,QJ=5508002,WJ=5508003,GJ=5508004,JJ=5508005,UJ=5508006,$J=5508007,VJ=5508008,YJ=5508009,ZJ=5508010,uX=5508011,dX=5607000,rX=5607001,fX=5607002,iX=5607003,cX=5607004,oX=5607005,nX=5607006,aX=5607007,sX=5607008,tX=5607009,eX=5607010,TH=5607011,AH=5607012,CH=5607013,PH=5607014,QH=5607015,WH=5607016,GH=5607017,r4=5663000,W6=5663001,f4=5663002,i4=5663003,c4=5663004,qJ=5663005,XJ=5663006,HJ=5663007,KJ=5663008,o4=5663009,JH=5663010,UH=5663011,n4=5663012,$H=5663013,VH=5663014,a4=5663015,s4=5663016,kJ=5663017,YH=5663018,ZH=5663019,jJ=5663020,G2=5663021,RJ=5663022,t4=5663023,FJ=7050000,qH=7050001,XH=7050002,HH=7050003,KH=7050004,kH=7050005,jH=7050006,RH=7050007,FH=7050008,DH=7050009,zH=7050010,SH=7050011,MH=7050012,IH=7050013,NH=7050014,LH=7050015,wH=7050016,EH=7050017,BH=7050018,OH=7050019,_H=7050020,xH=7050021,hH=7050022,mH=7050023,gH=7050024,vH=7050025,yH=7050026,bH=7050027,lH=7050028,pH=7050029,DJ=7050030,zJ=7050031,uH=7050032,dH=7050033,rH=7050034,SJ=7050035,fH=7050036,iH=7618000,cH=7618001,oH=7618002,nH=7618003,aH=7618004,sH=7618005,tH=7618006,eH=7618007,TK=7618008,AK=7618009,G6=8078000,J2=8078001,e4=8078002,TP=8078003,J6=8078004,U6=8078005,$6=8078006,dA=8078007,V6=8078008,Y6=8078009,Z6=8078010,rA=8078011,KA=8078012,AP=8078013,CP=8078014,q6=8078015,X6=8078016,S8=8078017,H6=8078018,CK=8078019,PP=8078020,QP=8078021,K6=8078022,WP=8078023,PK=8100000,QK=8100001,WK=8100002,GK=8100003,JK=8190000,UK=8190001,$K=8190002,VK=8190003,YK=8190004,ZK=8500000,qK=8500001,XK=8500002,HK=8500003,KK=8500004,kK=8500005,jK=8500006,RK=9900000,FK=9900001,DK=9900002,GP=9900003,zK=9900004,SK=9900005,MK=9900006;var IK={[m4]:"Account not found at address: $address",[tG]:"Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",[sG]:"Expected decoded account at address: $address",[g4]:"Failed to decode account data at address: $address",[aG]:"Accounts not found at addresses: $addresses",[h4]:"Unable to find a viable program address bump seed.",[xq]:"$putativeAddress is not a base58-encoded address.",[C6]:"Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",[O4]:"The `CryptoKey` must be an `Ed25519` public key.",[nG]:"$putativeOffCurveAddress is not a base58-encoded off-curve address.",[Q6]:"Invalid seeds; point must fall off the Ed25519 curve.",[iG]:"Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",[_4]:"A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",[x4]:"The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",[cG]:"Expected program derived address bump to be in the range [0, 255], got: $bump.",[oG]:"Program address cannot end with PDA marker.",[P6]:"Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",[lG]:"Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",[B4]:"The network has progressed past the last block for which this transaction could have been committed.",[G6]:"Codec [$codecDescription] cannot decode empty byte arrays.",[K6]:"Enum codec cannot use lexical values [$stringValues] as discriminators. Either remove all lexical values or set `useValuesAsDiscriminators` to `false`.",[PP]:"Sentinel [$hexSentinel] must not be present in encoded bytes [$hexEncodedBytes].",[U6]:"Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",[$6]:"Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",[J6]:"Encoder and decoder must either both be fixed-size or variable-size.",[V6]:"Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",[e4]:"Expected a fixed-size codec, got a variable-size one.",[AP]:"Codec [$codecDescription] expected a positive byte length, got $bytesLength.",[TP]:"Expected a variable-size codec, got a fixed-size one.",[CK]:"Codec [$codecDescription] expected zero-value [$hexZeroValue] to have the same size as the provided fixed-size item [$expectedSize bytes].",[J2]:"Codec [$codecDescription] expected $expected bytes, got $bytesLength.",[H6]:"Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",[Y6]:"Invalid discriminated union variant. Expected one of [$variants], got $value.",[Z6]:"Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",[q6]:"Invalid literal union variant. Expected one of [$variants], got $value.",[dA]:"Expected [$codecDescription] to have $expected items, got $actual.",[KA]:"Invalid value $value for base $base with alphabet $alphabet.",[X6]:"Literal union discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",[rA]:"Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",[CP]:"Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",[QP]:"Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",[S8]:"Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",[WP]:"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?",[TJ]:"No random values implementation could be found.",[sq]:"instruction requires an uninitialized account",[YX]:"instruction tries to borrow reference for an account which is already borrowed",[ZX]:"instruction left account with an outstanding borrowed reference",[$X]:"program other than the account's owner changed the size of the account data",[cq]:"account data too small for instruction",[VX]:"instruction expected an executable account",[xX]:"An account does not have enough lamports to be rent-exempt",[mX]:"Program arithmetic overflowed",[_X]:"Failed to serialize or deserialize account data: $encodedData",[pX]:"Builtin programs must consume compute units",[RX]:"Cross-program invocation call depth too deep",[IX]:"Computational budget exceeded",[CJ]:"custom program error: #$code",[WX]:"instruction contains duplicate accounts",[qX]:"instruction modifications of multiply-passed account differ",[kX]:"executable accounts must be rent exempt",[HX]:"instruction changed executable accounts data",[KX]:"instruction changed the balance of an executable account",[GX]:"instruction changed executable bit of an account",[CX]:"instruction modified data of an account it does not own",[AX]:"instruction spent from the balance of an account it does not own",[dq]:"generic instruction error",[vX]:"Provided owner is not allowed",[BX]:"Account is immutable",[OX]:"Incorrect authority provided",[nq]:"incorrect program id for instruction",[oq]:"insufficient funds for instruction",[iq]:"invalid account data for instruction",[hX]:"Invalid account owner",[rq]:"invalid program argument",[XX]:"program returned invalid error code",[fq]:"invalid instruction data",[MX]:"Failed to reallocate account data",[SX]:"Provided seeds do not result in a valid address",[yX]:"Accounts data allocations exceeded the maximum allowed per transaction",[bX]:"Max accounts exceeded",[lX]:"Max instruction trace length exceeded",[zX]:"Length of the seed is too long for address generation",[FX]:"An account required by the instruction is missing",[aq]:"missing required signature for instruction",[TX]:"instruction illegally modified the program id of an account",[UX]:"insufficient account keys for instruction",[NX]:"Cross-program invocation with unauthorized signer or writable account",[LX]:"Failed to create program execution environment",[EX]:"Program failed to compile",[wX]:"Program failed to complete",[QX]:"instruction modified data of a read-only account",[PX]:"instruction changed the balance of a read-only account",[DX]:"Cross-program invocation reentrancy not allowed for this instruction",[JX]:"instruction modified rent epoch of an account",[eq]:"sum of account balances before and after instruction do not match",[tq]:"instruction requires an initialized account",[AJ]:"",[jX]:"Unsupported program id",[gX]:"Unsupported sysvar",[SK]:"Invalid instruction plan kind: $kind.",[oH]:"The provided instruction plan is empty.",[sH]:"No failed transaction plan result was found in the provided transaction plan result.",[aH]:"This transaction plan executor does not support non-divisible sequential plans. To support them, you may create your own executor such that multi-transaction atomicity is preserved — e.g. by targetting RPCs that support transaction bundles.",[nH]:"The provided transaction plan failed to execute. See the `transactionPlanResult` attribute for more details. Note that the `cause` property is deprecated, and a future version will not set it.",[iH]:"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).",[MK]:"Invalid transaction plan kind: $kind.",[cH]:"No more instructions to pack; the message packer has completed the instruction plan.",[tH]:"Unexpected instruction plan. Expected $expectedKind plan, got $actualKind plan.",[eH]:"Unexpected transaction plan. Expected $expectedKind plan, got $actualKind plan.",[TK]:"Unexpected transaction plan result. Expected $expectedKind plan, got $actualKind plan.",[AK]:"Expected a successful transaction plan result. I.e. there is at least one failed or cancelled transaction in the plan.",[lq]:"The instruction does not have any accounts.",[pq]:"The instruction does not have any data.",[uq]:"Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",[pG]:"Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",[yG]:"The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",[DK]:"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",[zK]:"Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",[FK]:"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",[RK]:"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",[GP]:"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",[Vq]:"JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",[Yq]:"JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",[qq]:"JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",[Zq]:"JSON-RPC error: The method does not exist / is not available ($__serverMessage)",[$q]:"JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",[Dq]:"$__serverMessage",[_q]:"$__serverMessage",[Eq]:"$__serverMessage",[Rq]:"$__serverMessage",[Kq]:"Epoch rewards period still active at slot $slot",[Sq]:"$__serverMessage",[Mq]:"$__serverMessage",[Xq]:"Failed to query long-term storage; please try again",[kq]:"Minimum context slot has not been reached",[wq]:"Node is unhealthy; behind by $numSlotsBehind slots",[Iq]:"No snapshot",[Oq]:"Transaction simulation failed",[Hq]:"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",[Nq]:"$__serverMessage",[zq]:"Transaction history is not available from this node",[Lq]:"$__serverMessage",[Fq]:"Transaction signature length mismatch",[Bq]:"Transaction signature verification failure",[jq]:"$__serverMessage",[mq]:"Key pair bytes must be of length 64, got $byteLength.",[gq]:"Expected private key bytes with length 32. Actual length: $actualLength.",[vq]:"Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",[bq]:"The provided private key does not match the provided public key.",[yq]:"Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",[uG]:"Lamports value must be in the range [0, 2e64-1]",[dG]:"`$value` cannot be parsed as a `BigInt`",[Uq]:"$message",[rG]:"`$value` cannot be parsed as a `Number`",[bG]:"No nonce account could be found at address `$nonceAccountAddress`",[iX]:"Expected base58 encoded application domain to decode to a byte array of length 32. Actual length: $actualLength.",[CH]:"Attempted to sign an offchain message with an address that is not a signer for it",[fX]:"Expected base58-encoded application domain string of length in the range [32, 44]. Actual length: $actualLength.",[AH]:"The signer addresses in this offchain message envelope do not match the list of required signers in the message preamble. These unexpected signers were present in the envelope: `[$unexpectedSigners]`. These required signers were missing from the envelope `[$missingSigners]`.",[dX]:"The message body provided has a byte-length of $actualBytes. The maximum allowable byte-length is $maxBytes",[aX]:"Expected message format $expectedMessageFormat, got $actualMessageFormat",[sX]:"The message length specified in the message preamble is $specifiedLength bytes. The actual length of the message is $actualLength bytes.",[tX]:"Offchain message content must be non-empty",[oX]:"Offchain message must specify the address of at least one required signer",[eX]:"Offchain message envelope must reserve space for at least one signature",[cX]:"The offchain message preamble specifies $numRequiredSignatures required signature(s), got $signaturesLength.",[QH]:"The signatories of this offchain message must be listed in lexicographical order",[WH]:"An address must be listed no more than once among the signatories of an offchain message",[TH]:"Offchain message is missing signatures for addresses: $addresses.",[GH]:"Offchain message signature verification failed. Signature mismatch for required signatories [$signatoriesWithInvalidSignatures]. Missing signatures for signatories [$signatoriesWithMissingSignatures]",[rX]:"The message body provided contains characters whose codes fall outside the allowed range. In order to ensure clear-signing compatiblity with hardware wallets, the message may only contain line feeds and characters in the range [\\x20-\\x7e].",[PH]:"Expected offchain message version $expectedVersion. Got $actualVersion.",[nX]:"This version of Kit does not support decoding offchain messages with version $unsupportedVersion. The current max supported version is 0.",[jK]:"The provided account could not be identified as an account from the $programName program.",[XK]:"The provided instruction could not be identified as an instruction from the $programName program.",[ZK]:"The provided instruction is missing some accounts. Expected at least $expectedAccountMetas account(s), got $actualAccountMetas.",[KK]:"Expected resolved instruction input '$inputName' to be non-null.",[HK]:"Expected resolved instruction input '$inputName' to be of type `$expectedType`.",[kK]:"Unrecognized account type '$accountType' for the $programName program.",[qK]:"Unrecognized instruction type '$instructionType' for the $programName program.",[JK]:"The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",[$K]:"WebSocket was closed before payload could be added to the send buffer",[VK]:"WebSocket connection closed",[YK]:"WebSocket failed to connect",[UK]:"Failed to obtain a subscription id from the server",[GK]:"Could not find an API plan for RPC method: `$method`",[PK]:"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`.",[WK]:"HTTP error ($statusCode): $message",[QK]:"HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",[d4]:"Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",[PJ]:"The provided value does not implement the `KeyPairSigner` interface",[WJ]:"The provided value does not implement the `MessageModifyingSigner` interface",[GJ]:"The provided value does not implement the `MessagePartialSigner` interface",[QJ]:"The provided value does not implement any of the `MessageSigner` interfaces",[UJ]:"The provided value does not implement the `TransactionModifyingSigner` interface",[$J]:"The provided value does not implement the `TransactionPartialSigner` interface",[VJ]:"The provided value does not implement the `TransactionSendingSigner` interface",[JJ]:"The provided value does not implement any of the `TransactionSigner` interfaces",[YJ]:"More than one `TransactionSendingSigner` was identified.",[ZJ]:"No `TransactionSendingSigner` was identified. Please provide a valid `TransactionWithSingleSendingSigner` transaction.",[uX]:"Wallet account signers do not support signing multiple messages/transactions in a single operation",[hq]:"Cannot export a non-extractable key.",[y4]:"No digest implementation could be found.",[v4]:"Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",[b4]:`This runtime does not support the generation of Ed25519 key pairs.
7
7
 
8
8
  Install @solana/webcrypto-ed25519-polyfill and call its \`install\` function before generating keys in environments that do not support Ed25519.
9
9
 
10
- For a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20.`,[h4]:"No signature verification implementation could be found.",[g4]:"No key generation implementation could be found.",[m4]:"No signing implementation could be found.",[aG]:"No key export implementation could be found.",[uG]:"Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",[NH]:"Transaction processing left an account with an outstanding borrowed reference",[ZH]:"Account in use",[XH]:"Account loaded twice",[PH]:"Attempt to debit an account but found no record of a prior credit.",[BH]:"Transaction loads an address table account that doesn't exist",[HH]:"This transaction has already been processed",[VH]:"Blockhash not found",[jH]:"Loader call chain is too deep",[FH]:"Transactions are currently disabled due to cluster maintenance",[RU]:"Transaction contains a duplicate instruction ($index) that is not allowed",[KH]:"Insufficient funds for fee",[DU]:"Transaction results in an account ($accountIndex) with insufficient funds for rent",[CH]:"This account may not be used to pay transaction fees",[DH]:"Transaction contains an invalid account reference",[xH]:"Transaction loads an address table account with invalid data",[hH]:"Transaction address table lookup uses an invalid index",[_H]:"Transaction loads an address table account with an invalid owner",[bH]:"LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",[kH]:"This program may not be used for executing instructions",[gH]:"Transaction leaves an account with a lower balance than rent-exempt minimum",[LH]:"Transaction loads a writable account that cannot be written",[yH]:"Transaction exceeded max loaded accounts data size cap",[RH]:"Transaction requires a fee but has no signature present",[qH]:"Attempt to load a program that does not exist",[MU]:"Execution of the program referenced by account at index $accountIndex is temporarily restricted.",[pH]:"ResanitizationNeeded",[zH]:"Transaction failed to sanitize accounts offsets correctly",[MH]:"Transaction did not pass signature verification",[OH]:"Transaction locked too many accounts",[lH]:"Sum of account balances before and after transaction do not match",[jU]:"The transaction failed with the error `$errorName`",[SH]:"Transaction version is unsupported",[EH]:"Transaction would exceed account data limit within the block",[vH]:"Transaction would exceed total account data limit",[wH]:"Transaction would exceed max account limit within the block",[IH]:"Transaction would exceed max Block Cost Limit",[mH]:"Transaction would exceed max Vote Cost Limit",[c4]:"Attempted to sign a transaction with an address that is not a signer for it",[JH]:"Transaction is missing an address at index: $index.",[f4]:"Transaction has no expected signers therefore it cannot be encoded",[HU]:"Transaction size $transactionSize exceeds limit of $transactionSizeLimit bytes",[b4]:"Transaction does not have a blockhash lifetime",[p4]:"Transaction is not a durable nonce transaction",[XU]:"Contents of these address lookup tables unknown: $lookupTableAddresses",[PU]:"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",[KU]:"No fee payer set in CompiledTransaction",[qU]:"Could not find program address at index $index",[UH]:"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",[YH]:"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",[$H]:"Transaction is missing a fee payer.",[d4]:"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",[GH]:"Transaction first instruction is not advance nonce account instruction.",[WH]:"Transaction with no instructions cannot be durable nonce transaction.",[y4]:"This transaction includes an address (`$programAddress`) which is both invoked and set as the fee payer. Program addresses may not pay fees",[A6]:"This transaction includes an address (`$programAddress`) which is both invoked and marked writable. Program addresses may not be writable",[CU]:"The transaction message expected the transaction to have $numRequiredSignatures signatures, got $signaturesLength.",[u4]:"Transaction is missing signatures for addresses: $addresses.",[l4]:"Transaction version must be in the range [0, 127]. `$actualVersion` given",[J2]:"This version of Kit does not support decoding transactions with version $unsupportedVersion. The current max supported version is 0.",[VU]:"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.",[r4]:"Transaction message bytes are malformed: $messageBytes"},cT="i",ST="t";function z7(T,A={}){let Q=k7[T];if(Q.length===0)return"";let J;function $(G){if(J[ST]===2){let Y=Q.slice(J[cT]+1,G);W.push(Y in A?`${A[Y]}`:`$${Y}`)}else if(J[ST]===1)W.push(Q.slice(J[cT],G))}let W=[];return Q.split("").forEach((G,Y)=>{if(Y===0){J={[cT]:0,[ST]:Q[0]==="\\"?0:Q[0]==="$"?2:1};return}let Z;switch(J[ST]){case 0:Z={[cT]:Y,[ST]:1};break;case 1:if(G==="\\")Z={[cT]:Y,[ST]:0};else if(G==="$")Z={[cT]:Y,[ST]:2};break;case 2:if(G==="\\")Z={[cT]:Y,[ST]:0};else if(G==="$")Z={[cT]:Y,[ST]:2};else if(!G.match(/\w/))Z={[cT]:Y,[ST]:1};break}if(Z){if(J!==Z)$(Y);J=Z}}),$(),W.join("")}function F7(T,A={}){return z7(T,A)}function AJ(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 Q,J;if(A)Object.entries(Object.getOwnPropertyDescriptors(A)).forEach(([W,G])=>{if(W==="cause")J={cause:G.value};else{if(Q===void 0)Q={__code:T};Object.defineProperty(Q,W,G)}});let $=F7(T,Q);super($,J);this.context=Object.freeze(Q===void 0?{__code:T}:Q),this.name="SolanaError"}};function N7(...T){if("captureStackTrace"in Error&&typeof Error.captureStackTrace==="function")Error.captureStackTrace(...T)}function kU({errorCodeBaseOffset:T,getErrorContext:A,orderedErrorNames:Q,rpcEnumError:J},$){let W,G;if(typeof J==="string")W=J;else W=Object.keys(J)[0],G=J[W];let Y=Q.indexOf(W),Z=T+Y,C=A(Z,W,G),K=new e(Z,C);return N7(K,$),K}var I7=["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 zU(T,A){let Q=Number(T);return kU({errorCodeBaseOffset:4615001,getErrorContext(J,$,W){if(J===tG)return{errorName:$,index:Q,...W!==void 0?{instructionErrorContext:W}:null};else if(J===eG)return{code:Number(W),index:Q};return{index:Q}},orderedErrorNames:I7,rpcEnumError:A},zU)}var S7=["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 K6(T){if(typeof T==="object"&&"InstructionError"in T)return zU(...T.InstructionError);return kU({errorCodeBaseOffset:7050001,getErrorContext(A,Q,J){if(A===jU)return{errorName:Q,...J!==void 0?{transactionErrorContext:J}:null};else if(A===RU)return{index:Number(J)};else if(A===DU||A===MU)return{accountIndex:Number(J.account_index)}},orderedErrorNames:S7,rpcEnumError:T},K6)}function L7(T,A){return"fixedSize"in A?A.fixedSize:A.getSizeFromValue(T)}function FU(T){return Object.freeze({...T,encode:(A)=>{let Q=new Uint8Array(L7(A,T));return T.write(A,Q,0),Q}})}var NU="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",IU=()=>{return FU({getSizeFromValue:(T)=>{try{return atob(T).length}catch{throw new e(C8,{alphabet:NU,base:64,value:T})}},write(T,A,Q){try{let J=atob(T).split("").map(($)=>$.charCodeAt(0));return A.set(J,Q),J.length+Q}catch{throw new e(C8,{alphabet:NU,base:64,value:T})}}})};var{TextDecoder:C3,TextEncoder:H3}=globalThis;function H8(T,A){try{if("exists"in T&&!T.exists)return T;return Object.freeze({...T,data:A.decode(T.data)})}catch{throw new e(O4,{address:T.address})}}function w7(T,A){if(!A)return Object.freeze({address:T,exists:!1});let Q=IU().encode(A.data[0]);return Object.freeze({...E7(A),address:T,data:Q,exists:!0})}function E7(T){return Object.freeze({executable:T.executable,lamports:T.lamports,programAddress:T.owner,space:T.space})}async function V8(T,A,Q={}){let{abortSignal:J,...$}=Q,W=await T.getAccountInfo(A,{...$,encoding:"base64"}).send({abortSignal:J});return w7(A,W.value)}function j8(T){if(!T.exists)throw new e(E4,{address:T.address})}function O7(T,A){if(T.length>=A)return T;let Q=new Uint8Array(A).fill(0);return Q.set(T),Q}var B7=(T,A)=>O7(T.length<=A?T:T.slice(0,A),A);function _7(T,A){return"fixedSize"in A?A.fixedSize:A.getSizeFromValue(T)}function C6(T){return Object.freeze({...T,encode:(A)=>{let Q=new Uint8Array(_7(A,T));return T.write(A,Q,0),Q}})}function QJ(T){return Object.freeze({...T,decode:(A,Q=0)=>T.read(A,Q)[0]})}function R8(T){return"fixedSize"in T&&typeof T.fixedSize==="number"}function x7(T){return!R8(T)}function JJ(T,A){if(R8(T)!==R8(A))throw new e(J6);if(R8(T)&&R8(A)&&T.fixedSize!==A.fixedSize)throw new e($6,{decoderFixedSize:A.fixedSize,encoderFixedSize:T.fixedSize});if(!R8(T)&&!R8(A)&&T.maxSize!==A.maxSize)throw new e(W6,{decoderMaxSize:A.maxSize,encoderMaxSize:T.maxSize});return{...A,...T,decode:A.decode,encode:T.encode,read:A.read,write:T.write}}function h7(T,A,Q,J=0){let $=Q.length-J;if($<A)throw new e($2,{bytesLength:$,codecDescription:T,expected:A})}function SU(T,A){return C6({fixedSize:A,write:(Q,J,$)=>{let W=T.encode(Q),G=W.length>A?W.slice(0,A):W;return J.set(G,$),$+A}})}function LU(T,A){return QJ({fixedSize:A,read:(Q,J)=>{if(h7("fixCodecSize",A,Q,J),J>0||Q.length>A)Q=Q.slice(J,J+A);if(R8(T))Q=B7(Q,T.fixedSize);let[$]=T.read(Q,0);return[$,J+A]}})}function wU(T,A){return C6({...x7(T)?{...T,getSizeFromValue:(Q)=>T.getSizeFromValue(A(Q))}:T,write:(Q,J,$)=>T.write(A(Q),J,$)})}function g7(T,A,Q=A){if(!A.match(new RegExp(`^[${T}]*$`)))throw new e(C8,{alphabet:T,base:T.length,value:Q})}var m7=(T)=>{return C6({getSizeFromValue:(A)=>{let[Q,J]=EU(A,T[0]);if(!J)return A.length;let $=OU(J,T);return Q.length+Math.ceil($.toString(16).length/2)},write(A,Q,J){if(g7(T,A),A==="")return J;let[$,W]=EU(A,T[0]);if(!W)return Q.set(new Uint8Array($.length).fill(0),J),J+$.length;let G=OU(W,T),Y=[];while(G>0n)Y.unshift(Number(G%256n)),G/=256n;let Z=[...Array($.length).fill(0),...Y];return Q.set(Z,J),J+Z.length}})},v7=(T)=>{return QJ({read(A,Q){let J=Q===0?A:A.slice(Q);if(J.length===0)return["",0];let $=J.findIndex((Z)=>Z!==0);$=$===-1?J.length:$;let W=T[0].repeat($);if($===J.length)return[W,A.length];let G=J.slice($).reduce((Z,C)=>Z*256n+BigInt(C),0n),Y=y7(G,T);return[W+Y,A.length]}})};function EU(T,A){let[Q,J]=T.split(new RegExp(`((?!${A}).*)`));return[Q,J]}function OU(T,A){let Q=BigInt(A.length),J=0n;for(let $ of T)J*=Q,J+=BigInt(A.indexOf($));return J}function y7(T,A){let Q=BigInt(A.length),J=[];while(T>0n)J.unshift(A[Number(T%Q)]),T/=Q;return J.join("")}var BU="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",_U=()=>m7(BU),xU=()=>v7(BU);var{TextDecoder:I3,TextEncoder:S3}=globalThis;function H6(){if(!globalThis.isSecureContext)throw new e(B4)}var d8;async function b7(T){if(d8===void 0)d8=new Promise((A)=>{T.generateKey("Ed25519",!1,["sign","verify"]).then(()=>{A(d8=!0)}).catch(()=>{A(d8=!1)})});if(typeof d8==="boolean")return d8;else return await d8}function hU(){if(H6(),typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.digest!=="function")throw new e(_4)}async function gU(){if(H6(),typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.generateKey!=="function")throw new e(g4);if(!await b7(globalThis.crypto.subtle))throw new e(x4)}function $J(){if(H6(),typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.exportKey!=="function")throw new e(h4)}function mU(){if(H6(),typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.sign!=="function")throw new e(m4)}var WJ,GJ;function UJ(){if(!WJ)WJ=_U();return WJ}function p7(){if(!GJ)GJ=xU();return GJ}function V6(T){if(T.length<32||T.length>44)return!1;let A=UJ();try{return A.encode(T).byteLength===32}catch{return!1}}function YJ(T){if(T.length<32||T.length>44)throw new e(e2,{actualLength:T.length});let J=UJ().encode(T).byteLength;if(J!==32)throw new e(t2,{actualLength:J})}function _(T){return YJ(T),T}function C0(){return wU(SU(UJ(),32),(T)=>_(T))}function Y0(){return LU(p7(),32)}function l7(){return JJ(C0(),Y0())}function j6(){return new Intl.Collator("en",{caseFirst:"lower",ignorePunctuation:!1,localeMatcher:"best fit",numeric:!1,sensitivity:"variant",usage:"sort"}).compare}var u7=37095705934669439343138083508754565189542113879843219016388785533085940283555n,y0=57896044618658097711785492504343953926634992332820282019728792003956564819949n,vU=19681161376707505956807079304988542015446066515923890162744021073123829784752n;function PT(T){let A=T%y0;return A>=0n?A:y0+A}function LT(T,A){let Q=T;while(A-- >0n)Q*=Q,Q%=y0;return Q}function d7(T){let Q=T*T%y0*T%y0,J=LT(Q,2n)*Q%y0,$=LT(J,1n)*T%y0,W=LT($,5n)*$%y0,G=LT(W,10n)*W%y0,Y=LT(G,20n)*G%y0,Z=LT(Y,40n)*Y%y0,C=LT(Z,80n)*Z%y0,K=LT(C,80n)*Z%y0,j=LT(K,10n)*W%y0;return LT(j,2n)*T%y0}function c7(T,A){let Q=PT(A*A*A),J=PT(Q*Q*A),$=d7(T*J),W=PT(T*Q*$),G=PT(A*W*W),Y=W,Z=PT(W*vU),C=G===T,K=G===PT(-T),j=G===PT(-T*vU);if(C)W=Y;if(K||j)W=Z;if((PT(W)&1n)===1n)W=PT(-W);if(!C&&!K)return null;return W}function f7(T,A){let Q=PT(T*T),J=PT(Q-1n),$=PT(u7*Q+1n),W=c7(J,$);if(W===null)return!1;let G=(A&128)!==0;if(W===0n&&G)return!1;return!0}function r7(T){let A=T.toString(16);if(A.length===1)return`0${A}`;else return A}function n7(T){let Q=`0x${T.reduce((J,$,W)=>`${r7(W===31?$&-129:$)}${J}`,"")}`;return BigInt(Q)}function i7(T){if(T.byteLength!==32)return!1;let A=n7(T);return f7(A,T[31])}var yU=32,bU=16,o7=[80,114,111,103,114,97,109,68,101,114,105,118,101,100,65,100,100,114,101,115,115];async function a7({programAddress:T,seeds:A}){if(hU(),A.length>bU)throw new e(S4,{actual:A.length,maxSeeds:bU});let Q,J=A.reduce((Z,C,K)=>{let j=typeof C==="string"?(Q||=new TextEncoder).encode(C):C;if(j.byteLength>yU)throw new e(L4,{actual:j.byteLength,index:K,maxSeedLength:yU});return Z.push(...j),Z},[]),$=l7(),W=$.encode(T),G=await crypto.subtle.digest("SHA-256",new Uint8Array([...J,...W,...o7])),Y=new Uint8Array(G);if(i7(Y))throw new e(T6);return $.decode(Y)}async function R1({programAddress:T,seeds:A}){let Q=255;while(Q>0)try{return[await a7({programAddress:T,seeds:[...A,new Uint8Array([Q])]}),Q]}catch(J){if(AJ(J,T6))Q--;else throw J}throw new e(w4)}async function R6(T){if($J(),T.type!=="public"||T.algorithm.name!=="Ed25519")throw new e(I4);let A=await crypto.subtle.exportKey("raw",T);return Y0().decode(new Uint8Array(A))}function s7(T,A){if(T.length>=A)return T;let Q=new Uint8Array(A).fill(0);return Q.set(T),Q}var t7=(T,A)=>s7(T.length<=A?T:T.slice(0,A),A);function kA(T,A){return"fixedSize"in A?A.fixedSize:A.getSizeFromValue(T)}function qT(T){return Object.freeze({...T,encode:(A)=>{let Q=new Uint8Array(kA(A,T));return T.write(A,Q,0),Q}})}function rT(T){return Object.freeze({...T,decode:(A,Q=0)=>T.read(A,Q)[0]})}function fT(T){return"fixedSize"in T&&typeof T.fixedSize==="number"}function e7(T){return!fT(T)}function pU(T,A,Q=0){if(A.length-Q<=0)throw new e(Q6,{codecDescription:T})}function D6(T,A,Q,J=0){let $=Q.length-J;if($<A)throw new e($2,{bytesLength:$,codecDescription:T,expected:A})}function M6(T,A){let Q=(G,Y,Z)=>{let C=T.encode(G);return Z=A.write(C.length,Y,Z),Y.set(C,Z),Z+C.length};if(fT(A)&&fT(T))return qT({...T,fixedSize:A.fixedSize+T.fixedSize,write:Q});let J=fT(A)?A.fixedSize:A.maxSize??null,$=fT(T)?T.fixedSize:T.maxSize??null,W=J!==null&&$!==null?J+$:null;return qT({...T,...W!==null?{maxSize:W}:{},getSizeFromValue:(G)=>{let Y=kA(G,T);return kA(Y,A)+Y},write:Q})}function lU(T,A,Q){let J=T.byteOffset+(A??0),$=Q??T.byteLength,W;if(typeof SharedArrayBuffer>"u")W=T.buffer;else if(T.buffer instanceof SharedArrayBuffer)W=new ArrayBuffer(T.length),new Uint8Array(W).set(new Uint8Array(T));else W=T.buffer;return(J===0||J===-T.byteLength)&&$===T.byteLength?W:W.slice(J,J+$)}function H0(T,A){return qT({fixedSize:A,write:(Q,J,$)=>{let W=T.encode(Q),G=W.length>A?W.slice(0,A):W;return J.set(G,$),$+A}})}function E0(T,A){return rT({fixedSize:A,read:(Q,J)=>{if(D6("fixCodecSize",A,Q,J),J>0||Q.length>A)Q=Q.slice(J,J+A);if(fT(T))Q=t7(Q,T.fixedSize);let[$]=T.read(Q,0);return[$,J+A]}})}function Z0(T,A){return qT({...e7(T)?{...T,getSizeFromValue:(Q)=>T.getSizeFromValue(A(Q))}:T,write:(Q,J,$)=>T.write(A(Q),J,$)})}function uU(T,A){return rT({...T,read:(Q,J)=>{let[$,W]=T.read(Q,J);return[A($,Q,J),W]}})}function TV(T,A,Q,J){if(J<A||J>Q)throw new e(u8,{codecDescription:T,max:Q,min:A,value:J})}function dU(T){return T?.endian===1?!1:!0}function ZJ(T){return qT({fixedSize:T.size,write(A,Q,J){if(T.range)TV(T.name,T.range[0],T.range[1],A);let $=new ArrayBuffer(T.size);return T.set(new DataView($),A,dU(T.config)),Q.set(new Uint8Array($),J),J+T.size}})}function W2(T){return rT({fixedSize:T.size,read(A,Q=0){pU(T.name,A,Q),D6(T.name,T.size,A,Q);let J=new DataView(lU(A,Q,T.size));return[T.get(J,dU(T.config)),Q+T.size]}})}var cU=(T={})=>W2({config:T,get:(A,Q)=>{let J=Q?8:0,$=Q?0:8,W=A.getBigUint64(J,Q),G=A.getBigUint64($,Q);return(W<<64n)+G},name:"u128",size:16});var fU=(T={})=>W2({config:T,get:(A,Q)=>A.getUint16(0,Q),name:"u16",size:2});var G2=(T={})=>ZJ({config:T,name:"u32",range:[0,Number("0xffffffff")],set:(A,Q,J)=>A.setUint32(0,Number(Q),J),size:4}),XJ=(T={})=>W2({config:T,get:(A,Q)=>A.getUint32(0,Q),name:"u32",size:4});var D1=(T={})=>ZJ({config:T,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(A,Q,J)=>A.setBigUint64(0,BigInt(Q),J),size:8}),L1=(T={})=>W2({config:T,get:(A,Q)=>A.getBigUint64(0,Q),name:"u64",size:8});var U2=()=>ZJ({name:"u8",range:[0,Number("0xff")],set:(T,A)=>T.setUint8(0,Number(A)),size:1}),D8=()=>W2({get:(T)=>T.getUint8(0),name:"u8",size:1});function AV(T,A,Q){if(A!==Q)throw new e(l8,{actual:Q,codecDescription:T,expected:A})}function zA(T){return T.reduce((A,Q)=>A===null||Q===null?null:A+Q,0)}function k6(T){return fT(T)?T.fixedSize:null}function z6(T){return fT(T)?T.fixedSize:T.maxSize??null}function F6(T,A={}){let Q=A.size??XJ(),J=k6(T),$=rU(Q,J),W=rU(Q,z6(T))??void 0;return rT({...$!==null?{fixedSize:$}:{maxSize:W},read:(G,Y)=>{let Z=[];if(typeof Q==="object"&&G.slice(Y).length===0)return[Z,Y];if(Q==="remainder"){while(Y<G.length){let[j,M]=T.read(G,Y);Y=M,Z.push(j)}return[Z,Y]}let[C,K]=typeof Q==="number"?[Q,Y]:Q.read(G,Y);Y=K;for(let j=0;j<C;j+=1){let[M,z]=T.read(G,Y);Y=z,Z.push(M)}return[Z,Y]}})}function rU(T,A){if(typeof T!=="number")return null;if(T===0)return 0;return A===null?null:A*T}function PJ(T={}){return Z0(T.size??U2(),(A)=>A?1:0)}function qJ(T={}){return uU(T.size??D8(),(A)=>Number(A)===1)}function M0(){return qT({getSizeFromValue:(T)=>T.length,write:(T,A,Q)=>{return A.set(T,Q),Q+T.length}})}function b0(){return rT({read:(T,A)=>{let Q=T.slice(A);return[Q,A+Q.length]}})}function nU(T,A){let Q=zA(T.map(k6)),J=zA(T.map(z6))??void 0;return qT({...Q===null?{getSizeFromValue:($)=>T.map((W,G)=>kA($[G],W)).reduce((W,G)=>W+G,0),maxSize:J}:{fixedSize:Q},write:($,W,G)=>{return AV(A?.description??"tuple",T.length,$.length),T.forEach((Y,Z)=>{G=Y.write($[Z],W,G)}),G}})}function X0(T){let A=T.map(([,$])=>$),Q=zA(A.map(k6)),J=zA(A.map(z6))??void 0;return qT({...Q===null?{getSizeFromValue:($)=>T.map(([W,G])=>kA($[W],G)).reduce((W,G)=>W+G,0),maxSize:J}:{fixedSize:Q},write:($,W,G)=>{return T.forEach(([Y,Z])=>{G=Z.write($[Y],W,G)}),G}})}function V0(T){let A=T.map(([,$])=>$),Q=zA(A.map(k6)),J=zA(A.map(z6))??void 0;return rT({...Q===null?{maxSize:J}:{fixedSize:Q},read:($,W)=>{let G={};return T.forEach(([Y,Z])=>{let[C,K]=Z.read($,W);W=K,G[Y]=C}),[G,W]}})}var{TextDecoder:i3,TextEncoder:iU}=globalThis,N6=()=>{let T;return qT({getSizeFromValue:(A)=>(T||=new iU).encode(A).length,write:(A,Q,J)=>{let $=(T||=new iU).encode(A);return Q.set($,J),J+$.length}})};var $1=((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})($1||{}),QV=2,JV=1;function nT(T){return T>=2}function FA(T){return(T&JV)!==0}function KJ(T,A){return T|A}function I6(T){return T|QV}function aU(T){return V6(T)}function oU(T){switch(T){case"finalized":return 2;case"confirmed":return 1;case"processed":return 0;default:throw new e(TJ,{unexpectedValue:T})}}function S6(T,A){if(T===A)return 0;return oU(T)<oU(A)?-1:1}var e3=-9223372036854775808n;function M8(T,A){return"fixedSize"in A?A.fixedSize:A.getSizeFromValue(T)}function k0(T){return Object.freeze({...T,encode:(A)=>{let Q=new Uint8Array(M8(A,T));return T.write(A,Q,0),Q}})}function wT(T){return"fixedSize"in T&&typeof T.fixedSize==="number"}function $V(T){return!wT(T)}function sU(T,A){let Q=(G,Y,Z)=>{let C=T.encode(G);return Z=A.write(C.length,Y,Z),Y.set(C,Z),Z+C.length};if(wT(A)&&wT(T))return k0({...T,fixedSize:A.fixedSize+T.fixedSize,write:Q});let J=wT(A)?A.fixedSize:A.maxSize??null,$=wT(T)?T.fixedSize:T.maxSize??null,W=J!==null&&$!==null?J+$:null;return k0({...T,...W!==null?{maxSize:W}:{},getSizeFromValue:(G)=>{let Y=M8(G,T);return M8(Y,A)+Y},write:Q})}function CJ(T,A){return k0({fixedSize:A,write:(Q,J,$)=>{let W=T.encode(Q),G=W.length>A?W.slice(0,A):W;return J.set(G,$),$+A}})}function L6(T,A){return k0({...$V(T)?{...T,getSizeFromValue:(Q)=>T.getSizeFromValue(A(Q))}:T,write:(Q,J,$)=>T.write(A(Q),J,$)})}function TY(T,A,Q,J){if(J<A||J>Q)throw new e(u8,{codecDescription:T,max:Q,min:A,value:J})}function GV(T){return T?.endian===1?!1:!0}function AY(T){return k0({fixedSize:T.size,write(A,Q,J){if(T.range)TY(T.name,T.range[0],T.range[1],A);let $=new ArrayBuffer(T.size);return T.set(new DataView($),A,GV(T.config)),Q.set(new Uint8Array($),J),J+T.size}})}var c8=()=>k0({getSizeFromValue:(T)=>{if(T<=127)return 1;if(T<=16383)return 2;return 3},maxSize:3,write:(T,A,Q)=>{TY("shortU16",0,65535,T);let J=[0];for(let $=0;;$+=1){let W=Number(T)>>$*7;if(W===0)break;let G=127&W;if(J[$]=G,$>0)J[$-1]|=128}return A.set(J,Q),Q+J.length}});var QY=(T={})=>AY({config:T,name:"u32",range:[0,Number("0xffffffff")],set:(A,Q,J)=>A.setUint32(0,Number(Q),J),size:4});var NA=()=>AY({name:"u8",range:[0,Number("0xff")],set:(T,A)=>T.setUint8(0,Number(A)),size:1});function XV(T,A,Q){if(A!==Q)throw new e(l8,{actual:Q,codecDescription:T,expected:A})}function PV(T){return T.reduce((A,Q)=>A===null||Q===null?null:Math.max(A,Q),0)}function JY(T){return T.reduce((A,Q)=>A===null||Q===null?null:A+Q,0)}function GY(T){return wT(T)?T.fixedSize:null}function HJ(T){return wT(T)?T.fixedSize:T.maxSize??null}function IA(T,A={}){let Q=A.size??QY(),J=$Y(Q,GY(T)),$=$Y(Q,HJ(T))??void 0;return k0({...J!==null?{fixedSize:J}:{getSizeFromValue:(W)=>{return(typeof Q==="object"?M8(W.length,Q):0)+[...W].reduce((Y,Z)=>Y+M8(Z,T),0)},maxSize:$},write:(W,G,Y)=>{if(typeof Q==="number")XV(A.description??"array",Q,W.length);if(typeof Q==="object")Y=Q.write(W.length,G,Y);return W.forEach((Z)=>{Y=T.write(Z,G,Y)}),Y}})}function $Y(T,A){if(typeof T!=="number")return null;if(T===0)return 0;return A===null?null:A*T}function UY(){return k0({getSizeFromValue:(T)=>T.length,write:(T,A,Q)=>{return A.set(T,Q),Q+T.length}})}function YY(T){return k0({fixedSize:T.length,write:(A,Q,J)=>{return Q.set(T,J),J+T.length}})}function ZY(T,A){let Q=qV(T),J=(W,G,Y)=>{let Z=A(W);return WY(T,Z),T[Z].write(W,G,Y)};if(Q!==null)return k0({fixedSize:Q,write:J});let $=KV(T);return k0({...$!==null?{maxSize:$}:{},getSizeFromValue:(W)=>{let G=A(W);return WY(T,G),M8(W,T[G])},write:J})}function WY(T,A){if(typeof T[A]>"u")throw new e(MA,{maxRange:T.length-1,minRange:0,variant:A})}function qV(T){if(T.length===0)return 0;if(!wT(T[0]))return null;let A=T[0].fixedSize;return T.every((J)=>wT(J)&&J.fixedSize===A)?A:null}function KV(T){return PV(T.map((A)=>HJ(A)))}function SA(T){let A=T.map(([,$])=>$),Q=JY(A.map(GY)),J=JY(A.map(HJ))??void 0;return k0({...Q===null?{getSizeFromValue:($)=>T.map(([W,G])=>M8($[W],G)).reduce((W,G)=>W+G,0),maxSize:J}:{fixedSize:Q},write:($,W,G)=>{return T.forEach(([Y,Z])=>{G=Z.write($[Y],W,G)}),G}})}function HY(T){return"lifetimeConstraint"in T&&typeof T.lifetimeConstraint.blockhash==="string"&&typeof T.lifetimeConstraint.lastValidBlockHeight==="bigint"&&aU(T.lifetimeConstraint.blockhash)}function VY(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 CV(T,A,Q=A){if(!A.match(new RegExp(`^[${T}]*$`)))throw new e(C8,{alphabet:T,base:T.length,value:Q})}var HV=(T)=>{return k0({getSizeFromValue:(A)=>{let[Q,J]=XY(A,T[0]);if(!J)return A.length;let $=PY(J,T);return Q.length+Math.ceil($.toString(16).length/2)},write(A,Q,J){if(CV(T,A),A==="")return J;let[$,W]=XY(A,T[0]);if(!W)return Q.set(new Uint8Array($.length).fill(0),J),J+$.length;let G=PY(W,T),Y=[];while(G>0n)Y.unshift(Number(G%256n)),G/=256n;let Z=[...Array($.length).fill(0),...Y];return Q.set(Z,J),J+Z.length}})};function XY(T,A){let[Q,J]=T.split(new RegExp(`((?!${A}).*)`));return[Q,J]}function PY(T,A){let Q=BigInt(A.length),J=0n;for(let $ of T)J*=Q,J+=BigInt(A.indexOf($));return J}var VV="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",jV=()=>HV(VV);var VJ;function RV(){if(!VJ){let T=IA(NA(),{size:c8()});VJ=SA([["lookupTableAddress",C0()],["writableIndexes",T],["readonlyIndexes",T]])}return VJ}var jJ;function RJ(){if(!jJ)jJ=NA();return jJ}function DV(){return SA([["numSignerAccounts",RJ()],["numReadonlySignerAccounts",RJ()],["numReadonlyNonSignerAccounts",RJ()]])}var DJ;function MV(){if(!DJ)DJ=L6(SA([["programAddressIndex",NA()],["accountIndices",IA(NA(),{size:c8()})],["data",sU(UY(),c8())]]),(T)=>{if(T.accountIndices!==void 0&&T.data!==void 0)return T;return{...T,accountIndices:T.accountIndices??[],data:T.data??new Uint8Array(0)}});return DJ}var kV=0,zV=128;function FV(){return k0({getSizeFromValue:(T)=>T==="legacy"?0:1,maxSize:1,write:(T,A,Q)=>{if(T==="legacy")return Q;if(T<0||T>127)throw new e(l4,{actualVersion:T});if(T>kV)throw new e(J2,{unsupportedVersion:T});return A.set([T|zV],Q),Q+1}})}function qY(){return SA(jY())}function KY(){return L6(SA([...jY(),["addressTableLookups",NV()]]),(T)=>{if(T.version==="legacy")return T;return{...T,addressTableLookups:T.addressTableLookups??[]}})}function jY(){let T=ZY([YY(new Uint8Array(32)),CJ(jV(),32)],(A)=>A===void 0?0:1);return[["version",FV()],["header",DV()],["staticAccounts",IA(C0(),{size:c8()})],["lifetimeToken",T],["instructions",IA(MV(),{size:c8()})]]}function NV(){return IA(RV(),{size:c8()})}function RY(){return k0({getSizeFromValue:(T)=>{if(T.version==="legacy")return qY().getSizeFromValue(T);else return KY().getSizeFromValue(T)},write:(T,A,Q)=>{if(T.version==="legacy")return qY().write(T,A,Q);else return KY().write(T,A,Q)}})}function CY(T,A,Q){T[A]=Q(T[A]??{role:$1.READONLY})}var P0=Symbol("AddressMapTypeProperty");function IV(T,A){let Q={[T]:{[P0]:0,role:$1.WRITABLE_SIGNER}},J=new Set;for(let $ of A){CY(Q,$.programAddress,(G)=>{if(J.add($.programAddress),P0 in G){if(FA(G.role))switch(G[P0]){case 0:throw new e(y4,{programAddress:$.programAddress});default:throw new e(A6,{programAddress:$.programAddress})}if(G[P0]===2)return G}return{[P0]:2,role:$1.READONLY}});let W;if(!$.accounts)continue;for(let G of $.accounts)CY(Q,G.address,(Y)=>{let{address:Z,...C}=G;if(P0 in Y)switch(Y[P0]){case 0:return Y;case 1:{let K=KJ(Y.role,C.role);if("lookupTableAddress"in C){if(Y.lookupTableAddress!==C.lookupTableAddress&&(W||=j6())(C.lookupTableAddress,Y.lookupTableAddress)<0)return{[P0]:1,...C,role:K}}else if(nT(C.role))return{[P0]:2,role:K};if(Y.role!==K)return{...Y,role:K};else return Y}case 2:{let K=KJ(Y.role,C.role);if(J.has(G.address)){if(FA(C.role))throw new e(A6,{programAddress:G.address});if(Y.role!==K)return{...Y,role:K};else return Y}else if("lookupTableAddress"in C&&!nT(Y.role))return{...C,[P0]:1,role:K};else if(Y.role!==K)return{...Y,role:K};else return Y}}if("lookupTableAddress"in C)return{...C,[P0]:1};else return{...C,[P0]:2}})}return Q}function SV(T){let A;return Object.entries(T).sort(([J,$],[W,G])=>{if($[P0]!==G[P0]){if($[P0]===0)return-1;else if(G[P0]===0)return 1;else if($[P0]===2)return-1;else if(G[P0]===2)return 1}let Y=nT($.role);if(Y!==nT(G.role))return Y?-1:1;let Z=FA($.role);if(Z!==FA(G.role))return Z?-1:1;if(A||=j6(),$[P0]===1&&G[P0]===1&&$.lookupTableAddress!==G.lookupTableAddress)return A($.lookupTableAddress,G.lookupTableAddress);else return A(J,W)}).map(([J,$])=>({address:J,...$}))}function LV(T){let A={};for(let Q of T){if(!("lookupTableAddress"in Q))continue;let J=A[Q.lookupTableAddress]||={readonlyIndexes:[],writableIndexes:[]};if(Q.role===$1.WRITABLE)J.writableIndexes.push(Q.addressIndex);else J.readonlyIndexes.push(Q.addressIndex)}return Object.keys(A).sort(j6()).map((Q)=>({lookupTableAddress:Q,...A[Q]}))}function wV(T){let A=0,Q=0,J=0;for(let $ of T){if("lookupTableAddress"in $)break;let W=FA($.role);if(nT($.role)){if(J++,!W)Q++}else if(!W)A++}return{numReadonlyNonSignerAccounts:A,numReadonlySignerAccounts:Q,numSignerAccounts:J}}function EV(T){let A={};for(let[Q,J]of T.entries())A[J.address]=Q;return A}function OV(T,A){let Q=EV(A);return T.map(({accounts:J,data:$,programAddress:W})=>{return{programAddressIndex:Q[W],...J?{accountIndices:J.map(({address:G})=>Q[G])}:null,...$?{data:$}:null}})}function BV(T){if("nonce"in T)return T.nonce;return T.blockhash}function _V(T){let A=T.findIndex((J)=>("lookupTableAddress"in J));return(A===-1?T:T.slice(0,A)).map(({address:J})=>J)}function DY(T){let A=IV(T.feePayer.address,T.instructions),Q=SV(A),J=T.lifetimeConstraint;return{...T.version!=="legacy"?{addressTableLookups:LV(Q)}:null,...J?{lifetimeToken:BV(J)}:null,header:wV(Q),instructions:OV(T.instructions,Q),staticAccounts:_V(Q),version:T.version}}function MY(T){return Object.freeze({instructions:Object.freeze([]),version:T.version})}var xV="SysvarRecentB1ockHashes11111111111111111111",hV="11111111111111111111111111111111";function gV(T){return T.programAddress===hV&&T.data!=null&&mV(T.data)&&T.accounts?.length===3&&T.accounts[0].address!=null&&T.accounts[0].role===$1.WRITABLE&&T.accounts[1].address===xV&&T.accounts[1].role===$1.READONLY&&T.accounts[2].address!=null&&nT(T.accounts[2].role)}function mV(T){return T.byteLength===4&&T[0]===4&&T[1]===0&&T[2]===0&&T[3]===0}function kY(T){return"lifetimeConstraint"in T&&typeof T.lifetimeConstraint.nonce==="string"&&T.instructions[0]!=null&&gV(T.instructions[0])}function zY(T,A){if("feePayer"in A&&T===A.feePayer?.address&&vV(A.feePayer))return A;let Q={...A,feePayer:Object.freeze({address:T})};return Object.freeze(Q),Q}function vV(T){return!!T&&"address"in T&&typeof T.address==="string"&&Object.keys(T).length===1}function FY(T,A){return yV([T],A)}function yV(T,A){return Object.freeze({...A,instructions:Object.freeze([...A.instructions,...T])})}function NY(T,A){return T.length===A.length&&T.every((Q,J)=>Q===A[J])}function LA(T,A){return"fixedSize"in A?A.fixedSize:A.getSizeFromValue(T)}function o0(T){return Object.freeze({...T,encode:(A)=>{let Q=new Uint8Array(LA(A,T));return T.write(A,Q,0),Q}})}function Y2(T){return Object.freeze({...T,decode:(A,Q=0)=>T.read(A,Q)[0]})}function wA(T){return"fixedSize"in T&&typeof T.fixedSize==="number"}function bV(T){return!wA(T)}function w6(T,A){return o0({fixedSize:A,write:(Q,J,$)=>{let W=T.encode(Q),G=W.length>A?W.slice(0,A):W;return J.set(G,$),$+A}})}function E6(T,A){return o0({...bV(T)?{...T,getSizeFromValue:(Q)=>T.getSizeFromValue(A(Q))}:T,write:(Q,J,$)=>T.write(A(Q),J,$)})}function IY(T,A,Q,J){if(J<A||J>Q)throw new e(u8,{codecDescription:T,max:Q,min:A,value:J})}function lV(T){return T?.endian===1?!1:!0}function uV(T){return o0({fixedSize:T.size,write(A,Q,J){if(T.range)IY(T.name,T.range[0],T.range[1],A);let $=new ArrayBuffer(T.size);return T.set(new DataView($),A,lV(T.config)),Q.set(new Uint8Array($),J),J+T.size}})}var SY=()=>o0({getSizeFromValue:(T)=>{if(T<=127)return 1;if(T<=16383)return 2;return 3},maxSize:3,write:(T,A,Q)=>{IY("shortU16",0,65535,T);let J=[0];for(let $=0;;$+=1){let W=Number(T)>>$*7;if(W===0)break;let G=127&W;if(J[$]=G,$>0)J[$-1]|=128}return A.set(J,Q),Q+J.length}});var LY=(T={})=>uV({config:T,name:"u32",range:[0,Number("0xffffffff")],set:(A,Q,J)=>A.setUint32(0,Number(Q),J),size:4});function rV(T,A,Q){if(A!==Q)throw new e(l8,{actual:Q,codecDescription:T,expected:A})}function nV(T){return T.reduce((A,Q)=>A===null||Q===null?null:Math.max(A,Q),0)}function wY(T){return T.reduce((A,Q)=>A===null||Q===null?null:A+Q,0)}function BY(T){return wA(T)?T.fixedSize:null}function kJ(T){return wA(T)?T.fixedSize:T.maxSize??null}function zJ(T,A={}){let Q=A.size??LY(),J=EY(Q,BY(T)),$=EY(Q,kJ(T))??void 0;return o0({...J!==null?{fixedSize:J}:{getSizeFromValue:(W)=>{return(typeof Q==="object"?LA(W.length,Q):0)+[...W].reduce((Y,Z)=>Y+LA(Z,T),0)},maxSize:$},write:(W,G,Y)=>{if(typeof Q==="number")rV(A.description??"array",Q,W.length);if(typeof Q==="object")Y=Q.write(W.length,G,Y);return W.forEach((Z)=>{Y=T.write(Z,G,Y)}),Y}})}function EY(T,A){if(typeof T!=="number")return null;if(T===0)return 0;return A===null?null:A*T}function Z2(){return o0({getSizeFromValue:(T)=>T.length,write:(T,A,Q)=>{return A.set(T,Q),Q+T.length}})}function iV(T,A){let Q=oV(T),J=(W,G,Y)=>{let Z=A(W);return OY(T,Z),T[Z].write(W,G,Y)};if(Q!==null)return o0({fixedSize:Q,write:J});let $=aV(T);return o0({...$!==null?{maxSize:$}:{},getSizeFromValue:(W)=>{let G=A(W);return OY(T,G),LA(W,T[G])},write:J})}function OY(T,A){if(typeof T[A]>"u")throw new e(MA,{maxRange:T.length-1,minRange:0,variant:A})}function oV(T){if(T.length===0)return 0;if(!wA(T[0]))return null;let A=T[0].fixedSize;return T.every((J)=>wA(J)&&J.fixedSize===A)?A:null}function aV(T){return nV(T.map((A)=>kJ(A)))}function _Y(T,A,Q){return iV([A,Q],(J)=>T(J)?0:1)}function xY(T){let A=T.map(([,$])=>$),Q=wY(A.map(BY)),J=wY(A.map(kJ))??void 0;return o0({...Q===null?{getSizeFromValue:($)=>T.map(([W,G])=>LA($[W],G)).reduce((W,G)=>W+G,0),maxSize:J}:{fixedSize:Q},write:($,W,G)=>{return T.forEach(([Y,Z])=>{G=Z.write($[Y],W,G)}),G}})}var sV=(T)=>{return Y2({read(A,Q){let J=Q===0?A:A.slice(Q);if(J.length===0)return["",0];let $=J.findIndex((Z)=>Z!==0);$=$===-1?J.length:$;let W=T[0].repeat($);if($===J.length)return[W,A.length];let G=J.slice($).reduce((Z,C)=>Z*256n+BigInt(C),0n),Y=tV(G,T);return[W+Y,A.length]}})};function tV(T,A){let Q=BigInt(A.length),J=[];while(T>0n)J.unshift(A[Number(T%Q)]),T/=Q;return J.join("")}var eV="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";var hY=()=>sV(eV);var gY=()=>{return Y2({read(T,A=0){let Q=T.slice(A);return[btoa(String.fromCharCode(...Q)),T.length]}})};var{TextDecoder:uL,TextEncoder:dL}=globalThis;function mY(T,A,Q){let J=T.byteOffset+(A??0),$=Q??T.byteLength,W;if(typeof SharedArrayBuffer>"u")W=T.buffer;else if(T.buffer instanceof SharedArrayBuffer)W=new ArrayBuffer(T.length),new Uint8Array(W).set(new Uint8Array(T));else W=T.buffer;return(J===0||J===-T.byteLength)&&$===T.byteLength?W:W.slice(J,J+$)}var vY=Object.freeze({name:"Ed25519"});async function O6(T,A){mU();let Q=await crypto.subtle.sign(vY,T,mY(A));return new Uint8Array(Q)}async function yY(){return await gU(),await crypto.subtle.generateKey(vY,!1,["sign","verify"])}function pY(T){let A=Object.values(T);if(A.length===0)throw new e(f4);return A.map((Q)=>{if(!Q)return new Uint8Array(64).fill(0);return Q})}function T5(){return E6(zJ(w6(Z2(),64),{size:SY()}),pY)}function A5(T){return E6(zJ(w6(Z2(),64),{description:"signatures",size:T}),pY)}var Q5=128,J5=127;function $5(T){let A=T[0];if((A&Q5)===0)return"signaturesFirst";let Q=A&J5;if(Q===0)return"signaturesFirst";if(Q===1)return"messageFirst";throw new e(J2,{unsupportedVersion:Q})}function W5(){return _Y((T)=>$5(T.messageBytes)==="signaturesFirst",G5(),U5())}function G5(){return xY([["signatures",T5()],["messageBytes",Z2()]])}function bY(T){if(T.length<2)throw new e(r4,{messageBytes:T});return T[1]}function U5(){let T=Z2();return o0({getSizeFromValue:(A)=>{let Q=bY(A.messageBytes);return A.messageBytes.length+Q*64},write:(A,Q,J)=>{J=T.write(A.messageBytes,Q,J);let $=bY(A.messageBytes);return J=A5($).write(A.signatures,Q,J),J}})}function lY(T){let A=DY(T),Q=RY().encode(A),J=A.staticAccounts.slice(0,A.header.numSignerAccounts),$={};for(let G of J)$[G]=null;let W;if(HY(T))W={blockhash:T.lifetimeConstraint.blockhash,lastValidBlockHeight:T.lifetimeConstraint.lastValidBlockHeight};else if(kY(T))W={nonce:T.lifetimeConstraint.nonce,nonceAccountAddress:T.instructions[0].accounts[0].address};return Object.freeze({...W?{lifetimeConstraint:W}:void 0,messageBytes:Q,signatures:Object.freeze($)})}var FJ;function X2(T){if(!FJ)FJ=hY();let A=Object.values(T.signatures)[0];if(!A)throw new e(d4);return FJ.decode(A)}async function uY(T,A){let Q,J;if(await Promise.all(T.map(async($)=>{let W=await R6($.publicKey),G=A.signatures[W];if(G===void 0){J||=new Set,J.add(W);return}if(J)return;let Y=await O6($.privateKey,A.messageBytes);if(G!==null&&NY(Y,G))return;Q||={},Q[W]=Y})),J&&J.size>0){let $=Object.keys(A.signatures);throw new e(c4,{expectedAddresses:$,unexpectedAddresses:[...J]})}if(!Q)return A;return Object.freeze({...A,signatures:Object.freeze({...A.signatures,...Q})})}function dY(T){let A=[];if(Object.entries(T.signatures).forEach(([Q,J])=>{if(!J)A.push(Q)}),A.length>0)throw new e(u4,{addresses:A})}function B6(T){let A=W5().encode(T);return gY().decode(A)}var Y5=1280,Z5=48,qw=Y5-Z5;function cY(T){return T!==null&&(typeof T==="object"||typeof T==="function")}function X5(T){let A=new Set,Q={deferreds:A,settled:!1};return Promise.resolve(T).then((J)=>{for(let{resolve:$}of A)$(J);A.clear(),Q.settled=!0},(J)=>{for(let{reject:$}of A)$(J);A.clear(),Q.settled=!0}),Q}var NJ=new WeakMap;async function IJ(T){let A;return await new Promise((J,$)=>{A={reject:$,resolve:J};for(let W of T){if(!cY(W)){Promise.resolve(W).then(J,$);continue}let G=NJ.get(W);if(G===void 0)G=X5(W),G.deferreds.add(A),NJ.set(W,G);else if(G.settled)Promise.resolve(W).then(J,$);else G.deferreds.add(A)}}).finally(()=>{for(let J of T)if(cY(J))NJ.get(J).deferreds.delete(A)})}function _6(T){let A={};return T.forEach((Q)=>{if(!A[Q.address])A[Q.address]=Q;else if(A[Q.address]!==Q)throw new e(v4,{address:Q.address})}),Object.values(A)}function x6(T){return"modifyAndSignTransactions"in T&&typeof T.modifyAndSignTransactions==="function"}function P2(T){return"signTransactions"in T&&typeof T.signTransactions==="function"}function fY(T){return"signAndSendTransactions"in T&&typeof T.signAndSendTransactions==="function"}function ET(T){return P2(T)||x6(T)||fY(T)}function P5(T){return _6((T.accounts??[]).flatMap((A)=>("signer"in A)?A.signer:[]))}function q5(T){return _6([...T.feePayer&&ET(T.feePayer)?[T.feePayer]:[],...T.instructions.flatMap(P5)])}function K5(T,A){if(!A.accounts||A.accounts.length===0)return A;let Q=new Map(_6(T).map((J)=>[J.address,J]));return Object.freeze({...A,accounts:A.accounts.map((J)=>{let $=Q.get(J.address);if(!nT(J.role)||"signer"in J||!$)return J;return Object.freeze({...J,signer:$})})})}function rY(T,A){let Q=C5(A)?T.find((J)=>J.address===A.feePayer.address):void 0;if(!Q&&A.instructions.length===0)return A;return Object.freeze({...A,...Q?{feePayer:Q}:null,instructions:A.instructions.map((J)=>K5(T,J))})}function C5(T){return!!T&&"feePayer"in T&&!!T.feePayer&&typeof T.feePayer.address==="string"&&!ET(T.feePayer)}function nY(T,A){Object.freeze(T);let Q={...A,feePayer:T};return Object.freeze(Q),Q}async function H5(T){let A=await R6(T.publicKey);return Object.freeze({address:A,keyPair:T,signMessages:(J)=>Promise.all(J.map(async($)=>Object.freeze({[A]:await O6(T.privateKey,$.content)}))),signTransactions:(J)=>Promise.all(J.map(async($)=>{let W=await uY([T],$);return Object.freeze({[A]:W.signatures[A]})}))})}async function iY(){return await H5(await yY())}async function V5(T,A){let{partialSigners:Q,modifyingSigners:J}=j5(_6(q5(T).filter(ET)),{identifySendingSigner:!1});return await M5(T,J,Q,A)}async function SJ(T,A){let Q=await V5(T,A);return dY(Q),Q}function j5(T,A={}){let J=A.identifySendingSigner??!0?R5(T):null,$=T.filter((Y)=>Y!==J&&(x6(Y)||P2(Y))),W=D5($),G=$.filter(P2).filter((Y)=>!W.includes(Y));return Object.freeze({modifyingSigners:W,partialSigners:G,sendingSigner:J})}function R5(T){let A=T.filter(fY);if(A.length===0)return null;let Q=A.filter((J)=>!x6(J)&&!P2(J));if(Q.length>0)return Q[0];return A[0]}function D5(T){let A=T.filter(x6);if(A.length===0)return[];let Q=A.filter((J)=>!P2(J));if(Q.length>0)return Q;return[A[0]]}async function M5(T,A=[],Q=[],J){let $=lY(T),W=await A.reduce(async(Y,Z)=>{J?.abortSignal?.throwIfAborted();let[C]=await Z.modifyAndSignTransactions([await Y],J);return Object.freeze(C)},Promise.resolve($));J?.abortSignal?.throwIfAborted();let G=await Promise.all(Q.map(async(Y)=>{let[Z]=await Y.signTransactions([W],J);return Z}));return Object.freeze({...W,signatures:Object.freeze(G.reduce((Y,Z)=>{return{...Y,...Z}},W.signatures??{}))})}var zw=globalThis.TextEncoder;var LJ=globalThis.AbortController;function oY({rpc:T,rpcSubscriptions:A}){return async function({abortSignal:J,commitment:$,lastValidBlockHeight:W}){J.throwIfAborted();let G=new LJ,Y=()=>{G.abort()};J.addEventListener("abort",Y,{signal:G.signal});async function Z(){let{absoluteSlot:C,blockHeight:K}=await T.getEpochInfo({commitment:$}).send({abortSignal:G.signal});return{blockHeight:K,differenceBetweenSlotHeightAndBlockHeight:C-K}}try{let[C,{blockHeight:K,differenceBetweenSlotHeightAndBlockHeight:j}]=await Promise.all([A.slotNotifications().subscribe({abortSignal:G.signal}),Z()]);J.throwIfAborted();let M=K;if(M<=W){let z=j;for await(let N of C){let{slot:E}=N;if(E-z>W){let{blockHeight:L,differenceBetweenSlotHeightAndBlockHeight:O}=await Z();if(M=L,M>W)break;else z=O}}}throw J.throwIfAborted(),new e(N4,{currentBlockHeight:M,lastValidBlockHeight:W})}finally{G.abort()}}}function aY({rpc:T,rpcSubscriptions:A}){return async function({abortSignal:J,commitment:$,signature:W}){let G=new LJ;function Y(){G.abort()}J.addEventListener("abort",Y,{signal:G.signal});let Z=await A.signatureNotifications(W,{commitment:$}).subscribe({abortSignal:G.signal}),C=(async()=>{for await(let j of Z)if(j.value.err)throw K6(j.value.err);else return})(),K=(async()=>{let{value:j}=await T.getSignatureStatuses([W]).send({abortSignal:G.signal}),M=j[0];if(M?.err)throw K6(M.err);else if(M?.confirmationStatus&&S6(M.confirmationStatus,$)>=0)return;else await new Promise(()=>{})})();try{return await IJ([C,K])}finally{G.abort()}}}async function k5(T,A,Q){let{abortSignal:J,commitment:$,getRecentSignatureConfirmationPromise:W}=A;J?.throwIfAborted();let G=new LJ;if(J){let Y=()=>{G.abort()};J.addEventListener("abort",Y,{signal:G.signal})}try{let Y=Q({...A,abortSignal:G.signal});return await IJ([W({abortSignal:G.signal,commitment:$,signature:T}),...Y])}finally{G.abort()}}async function sY(T){await k5(X2(T.transaction),T,function({abortSignal:Q,commitment:J,getBlockHeightExceedencePromise:$,transaction:W}){return[$({abortSignal:Q,commitment:J,lastValidBlockHeight:W.lifetimeConstraint.lastValidBlockHeight})]})}function z5(T,A){if(!A?.preflightCommitment&&S6(T,"finalized")<0)return{...A,preflightCommitment:T};return A}async function F5({abortSignal:T,commitment:A,rpc:Q,transaction:J,...$}){let W=B6(J);return await Q.sendTransaction(W,{...z5(A,$),encoding:"base64"}).send({abortSignal:T})}async function N5({abortSignal:T,commitment:A,confirmRecentTransaction:Q,rpc:J,transaction:$,...W}){let G=await F5({...W,abortSignal:T,commitment:A,rpc:J,transaction:$});return await Q({abortSignal:T,commitment:A,transaction:$}),G}function tY({rpc:T,rpcSubscriptions:A}){let Q=oY({rpc:T,rpcSubscriptions:A}),J=aY({rpc:T,rpcSubscriptions:A});async function $(W){await sY({...W,getBlockHeightExceedencePromise:Q,getRecentSignatureConfirmationPromise:J})}return async function(G,Y){await N5({...Y,confirmRecentTransaction:$,rpc:T,transaction:G})}}var eY="confirmed";function I5(T){eY=T}function M1(){return eY}var a0="6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P",q0="pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA",f8="11111111111111111111111111111111",j0="TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",q2="TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb",K2="ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";var OT="pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ";var wJ=C0(),TZ=K2;async function H1({owner:T,mint:A,tokenProgram:Q=j0,associatedTokenProgram:J=TZ}){return await R1({programAddress:_(J),seeds:[wJ.encode(_(T)),wJ.encode(_(Q)),wJ.encode(_(A))]})}async function AZ(T){return await H1({...T,tokenProgram:T.tokenProgram??q2,associatedTokenProgram:T.associatedTokenProgram??TZ})}var r8=new TextEncoder,h6=C0();async function g6(){let[T]=await R1({programAddress:_(a0),seeds:[r8.encode("global")]});return T}async function BT(T){let[A]=await R1({programAddress:_(a0),seeds:[r8.encode("bonding-curve"),h6.encode(_(T))]});return A}async function m6(T,A){let[Q]=await H1({owner:_(T),mint:_(A),tokenProgram:_(j0)});return Q}async function EJ(T){let[A]=await R1({programAddress:_(a0),seeds:[r8.encode("creator-vault"),h6.encode(_(T))]});return A}async function QZ(){let[T]=await R1({programAddress:_(a0),seeds:[r8.encode("global_volume_accumulator")]});return T}async function JZ(T){let[A]=await R1({programAddress:_(a0),seeds:[r8.encode("user_volume_accumulator"),h6.encode(_(T))]});return A}async function v6(){let[T]=await R1({programAddress:_(a0),seeds:[r8.encode("__event_authority")]});return T}async function C2(){let[T]=await R1({programAddress:_(OT),seeds:[r8.encode("fee_config"),h6.encode(_(a0))]});return T}var F1="6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P";function p0(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 N1(T,A){return(Q)=>{if(!Q.value){if(A==="omitted")return;return Object.freeze({address:T,role:$1.READONLY})}let J=Q.isWritable?$1.WRITABLE:$1.READONLY;return Object.freeze({address:p0(Q.value),role:$Z(Q.value)?I6(J):J,...$Z(Q.value)?{signer:Q.value}:{}})}}function $Z(T){return!!T&&typeof T==="object"&&"address"in T&&ET(T)}var jE=new Uint8Array([69,25,171,142,57,239,13,4]);var kE=new Uint8Array([8,217,96,231,144,104,192,5]);var IE=new Uint8Array([209,11,115,87,213,23,124,204]);function y6(){return V0([["lpFeeBps",L1()],["protocolFeeBps",L1()],["creatorFeeBps",L1()]])}function WZ(){return V0([["marketCapLamportsThreshold",cU()],["fees",y6()]])}function OJ(){return nU([PJ()])}var E5=new Uint8Array([102,6,61,18,1,218,235,234]);function O5(){return Z0(X0([["discriminator",H0(M0(),8)],["amount",D1()],["maxSolCost",D1()],["trackVolume",OJ()]]),(T)=>({...T,discriminator:E5}))}function GZ(T,A){let Q=A?.programAddress??F1,$={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(!$.systemProgram.value)$.systemProgram.value="11111111111111111111111111111111";if(!$.tokenProgram.value)$.tokenProgram.value="TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";if(!$.program.value)$.program.value="6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P";if(!$.feeProgram.value)$.feeProgram.value="pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ";let G=N1(Q,"programId");return Object.freeze({accounts:[G($.global),G($.feeRecipient),G($.mint),G($.bondingCurve),G($.associatedBondingCurve),G($.associatedUser),G($.user),G($.systemProgram),G($.tokenProgram),G($.creatorVault),G($.eventAuthority),G($.program),G($.globalVolumeAccumulator),G($.userVolumeAccumulator),G($.feeConfig),G($.feeProgram)],data:O5().encode(W),programAddress:Q})}var wO=new Uint8Array([56,252,116,8,158,223,205,95]);var _O=new Uint8Array([16,4,71,28,204,1,40,27]);var mO=new Uint8Array([249,69,164,218,150,103,84,138]);var pO=new Uint8Array([20,22,86,123,198,28,219,132]);var B5=new Uint8Array([24,30,200,40,5,28,7,119]);function _5(){return Z0(X0([["discriminator",H0(M0(),8)],["name",M6(N6(),G2())],["symbol",M6(N6(),G2())],["uri",M6(N6(),G2())],["creator",C0()]]),(T)=>({...T,discriminator:B5}))}function UZ(T,A){let Q=A?.programAddress??F1,$={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(!$.mplTokenMetadata.value)$.mplTokenMetadata.value="metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s";if(!$.systemProgram.value)$.systemProgram.value="11111111111111111111111111111111";if(!$.tokenProgram.value)$.tokenProgram.value="TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";if(!$.associatedTokenProgram.value)$.associatedTokenProgram.value="ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";if(!$.rent.value)$.rent.value="SysvarRent111111111111111111111111111111111";let G=N1(Q,"programId");return Object.freeze({accounts:[G($.mint),G($.mintAuthority),G($.bondingCurve),G($.associatedBondingCurve),G($.global),G($.mplTokenMetadata),G($.metadata),G($.user),G($.systemProgram),G($.tokenProgram),G($.associatedTokenProgram),G($.rent),G($.eventAuthority),G($.program)],data:_5().encode(W),programAddress:Q})}var aO=new Uint8Array([234,102,194,203,150,72,62,229]);var TB=new Uint8Array([175,175,109,31,13,152,155,237]);var $B=new Uint8Array([94,6,202,115,255,96,232,183]);var YB=new Uint8Array([155,234,231,146,236,158,162,30]);var x5=new Uint8Array([51,230,133,164,1,127,131,173]);function h5(){return Z0(X0([["discriminator",H0(M0(),8)],["amount",D1()],["minSolOutput",D1()]]),(T)=>({...T,discriminator:x5}))}function YZ(T,A){let Q=A?.programAddress??F1,$={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(!$.systemProgram.value)$.systemProgram.value="11111111111111111111111111111111";if(!$.tokenProgram.value)$.tokenProgram.value="TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";if(!$.program.value)$.program.value="6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P";if(!$.feeProgram.value)$.feeProgram.value="pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ";let G=N1(Q,"programId");return Object.freeze({accounts:[G($.global),G($.feeRecipient),G($.mint),G($.bondingCurve),G($.associatedBondingCurve),G($.associatedUser),G($.user),G($.systemProgram),G($.creatorVault),G($.tokenProgram),G($.eventAuthority),G($.program),G($.feeConfig),G($.feeProgram)],data:h5().encode(W),programAddress:Q})}var VB=new Uint8Array([254,148,255,112,207,142,170,165]);var MB=new Uint8Array([138,96,174,217,48,85,197,246]);var NB=new Uint8Array([27,234,178,52,147,2,187,141]);var wB=new Uint8Array([86,31,192,87,163,87,79,238]);var _B=new Uint8Array([227,181,74,196,208,21,97,213]);var A_=new Uint8Array([23,183,248,55,96,216,172,96]);function g5(){return V0([["discriminator",E0(b0(),8)],["virtualTokenReserves",L1()],["virtualSolReserves",L1()],["realTokenReserves",L1()],["realSolReserves",L1()],["tokenTotalSupply",L1()],["complete",qJ()],["creator",Y0()]])}function m5(T){return H8(T,g5())}async function k8(T,A,Q){let J=await v5(T,A,Q);return j8(J),J}async function v5(T,A,Q){let J=await V8(T,A,Q);return m5(J)}async function H2(T){let{user:A,mint:Q,tokenAmount:J,maxSolCostLamports:$,feeRecipient:W,trackVolume:G=!0,bondingCurveCreator:Y,rpc:Z,commitment:C=M1()}=T,K=_(Q),j=A.address,M=await BT(K),z=C2(),N=g6(),E=v6(),L=QZ(),O=JZ(j),g=m6(M,K),v=H1({owner:j,mint:K,tokenProgram:_(j0)}),p=await XZ({bondingCurve:M,providedCreator:Y,rpc:Z,commitment:C}),[c,u,[i],d,h,o,n,x]=await Promise.all([N,g,v,EJ(p),E,L,O,z]);return GZ({global:c,feeRecipient:_(W),mint:K,bondingCurve:M,associatedBondingCurve:u,associatedUser:i,user:A,systemProgram:_(f8),tokenProgram:_(j0),creatorVault:d,eventAuthority:h,program:_(a0),globalVolumeAccumulator:o,userVolumeAccumulator:n,feeConfig:x,feeProgram:_(OT),amount:J,maxSolCost:$,trackVolume:[G]})}async function xJ(T){let{user:A,mint:Q,tokenAmount:J,minSolOutputLamports:$,feeRecipient:W,bondingCurveCreator:G,rpc:Y,commitment:Z=M1()}=T,C=_(Q),K=A.address,j=await BT(C),M=g6(),z=m6(j,C),N=H1({owner:K,mint:C,tokenProgram:_(j0)}),E=C2(),L=v6(),O=await XZ({bondingCurve:j,providedCreator:G,rpc:Y,commitment:Z}),[g,v,[p],c,u,i]=await Promise.all([M,z,N,EJ(O),L,E]);return YZ({global:g,feeRecipient:_(W),mint:C,bondingCurve:j,associatedBondingCurve:v,associatedUser:p,user:A,systemProgram:_(f8),creatorVault:c,tokenProgram:_(j0),eventAuthority:u,program:_(a0),feeConfig:i,feeProgram:_(OT),amount:J,minSolOutput:$})}async function ZZ(T){let{user:A,mint:Q,mintAuthority:J,name:$,symbol:W,uri:G,creator:Y}=T,Z=Q.address,C=Y?_(Y):A.address,K=await g6(),j=await BT(Z),M=await m6(j,Z),[z]=await R1({programAddress:_("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),seeds:[new TextEncoder().encode("metadata"),_("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),Z]}),N=await v6();return UZ({mint:Q,mintAuthority:_(J),bondingCurve:j,associatedBondingCurve:M,global:K,mplTokenMetadata:_("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),metadata:z,user:A,systemProgram:_(f8),tokenProgram:_(j0),associatedTokenProgram:_("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"),rent:_("SysvarRent111111111111111111111111111111111"),eventAuthority:N,program:_(a0),name:$,symbol:W,uri:G,creator:C})}async function XZ(T){let{bondingCurve:A,providedCreator:Q,rpc:J,commitment:$}=T;if(Q)return _(Q);try{return(await k8(J,A,{commitment:$})).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 _T="CebN5WGQ4jvEPvsVU4EoHEpgzq1VV7AbicfhtW4xC9iM";var $T=50,iT=(T,A=50)=>T+T*BigInt(A)/10000n,n8=(T,A=50)=>T-T*BigInt(A)/10000n;function WT(T){if(T<0)throw Error("Slippage cannot be negative");if(T>1e4)throw Error("Slippage cannot exceed 100%")}function y5(T){if(T<0||T>100)throw Error("Percent must be between 0 and 100");return Math.round(T*100)}function b5(T){return T/100}var p5=1000000000n;function xT(T){if(!Number.isFinite(T)||T<0)throw Error("SOL value must be a non-negative finite number");return BigInt(Math.round(T*Number(p5)))}function i8(T,A){if(!Number.isInteger(A)||A<0)throw Error("Token decimals must be a non-negative integer");return BigInt(Math.round(T*10**A))}async function l5(T){let{user:A,mint:Q,tokenAmount:J,estimatedSolCostSol:$,slippageBps:W=$T,feeRecipient:G=_T,bondingCurveCreator:Y,trackVolume:Z=!0,rpc:C,commitment:K=M1()}=T;if(WT(W),J<=0n)throw Error("Token amount must be positive");if(!Number.isFinite($)||$<=0)throw Error("Estimated SOL cost must be a positive number");let j=xT($),M=iT(j,W);return await H2({user:A,mint:Q,tokenAmount:J,maxSolCostLamports:M,feeRecipient:G,trackVolume:Z,bondingCurveCreator:Y,rpc:C,commitment:K})}async function hJ(T){let{user:A,mint:Q,tokenAmount:J,maxSolCostSol:$,maxSolCostLamports:W,feeRecipient:G=_T,trackVolume:Y=!0,bondingCurveCreator:Z,rpc:C,commitment:K=M1()}=T;if(J<=0n)throw Error("Token amount must be positive");let j=null;if(W!==void 0){if(W<=0n)throw Error("Max SOL cost lamports must be positive");j=W}else if($!==void 0){if(!Number.isFinite($)||$<=0)throw Error("Max SOL cost must be a positive number");j=xT($)}if(j===null)throw Error("Provide either maxSolCostLamports or maxSolCostSol when calling buySimple");return await H2({user:A,mint:Q,tokenAmount:J,maxSolCostLamports:j,feeRecipient:G,trackVolume:Y,bondingCurveCreator:Z,rpc:C,commitment:K})}var PZ=6;async function u5(T){let{user:A,mint:Q,tokenAmount:J,estimatedSolOutSol:$,slippageBps:W=$T,feeRecipient:G=_T,bondingCurveCreator:Y,rpc:Z,commitment:C}=T;if(WT(W),!Number.isFinite(J)||J<=0)throw Error("Token amount must be a positive number");if(!Number.isFinite($)||$<0)throw Error("Estimated SOL output cannot be negative");let K=i8(J,PZ),j=xT($),M=n8(j,W);return await xJ({user:A,mint:Q,tokenAmount:K,minSolOutputLamports:M,feeRecipient:G,bondingCurveCreator:Y,rpc:Z,commitment:C})}async function gJ(T){let{user:A,mint:Q,tokenAmount:J,tokenAmountRaw:$,minSolOutputSol:W,minSolOutputLamports:G,feeRecipient:Y=_T,bondingCurveCreator:Z,rpc:C,commitment:K}=T,j=null;if($!==void 0){if($<=0n)throw Error("Token amount lamports must be positive");j=$}else if(J!==void 0){if(!Number.isFinite(J)||J<=0)throw Error("Token amount must be a positive number");j=i8(J,PZ)}if(j===null)throw Error("Provide either tokenAmountRaw or tokenAmount when calling sellSimple");let M=null;if(G!==void 0){if(G<0n)throw Error("Min SOL output lamports cannot be negative");M=G}else if(W!==void 0){if(!Number.isFinite(W)||W<0)throw Error("Min SOL output cannot be negative");M=xT(W)}if(M===null)throw Error("Provide either minSolOutputLamports or minSolOutputSol when calling sellSimple");return await xJ({user:A,mint:Q,tokenAmount:j,minSolOutputLamports:M,feeRecipient:Y,bondingCurveCreator:Z,rpc:C,commitment:K})}OA();var s8=typeof globalThis==="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function sT(T){return T instanceof Uint8Array||ArrayBuffer.isView(T)&&T.constructor.name==="Uint8Array"}function F8(T){if(!Number.isSafeInteger(T)||T<0)throw Error("positive integer expected, got "+T)}function I0(T,...A){if(!sT(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 u6(T){if(typeof T!=="function"||typeof T.create!=="function")throw Error("Hash should be wrapped by utils.createHasher");F8(T.outputLen),F8(T.blockLen)}function tT(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 d6(T,A){I0(T);let Q=A.outputLen;if(T.length<Q)throw Error("digestInto() expects output buffer of length at least "+Q)}function hZ(T){return new Uint32Array(T.buffer,T.byteOffset,Math.floor(T.byteLength/4))}function CT(...T){for(let A=0;A<T.length;A++)T[A].fill(0)}function c6(T){return new DataView(T.buffer,T.byteOffset,T.byteLength)}function DT(T,A){return T<<32-A|T>>>A}var Ej=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function Oj(T){return T<<24&4278190080|T<<8&16711680|T>>>8&65280|T>>>24&255}function Bj(T){for(let A=0;A<T.length;A++)T[A]=Oj(T[A]);return T}var fJ=Ej?(T)=>T:Bj,gZ=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),_j=Array.from({length:256},(T,A)=>A.toString(16).padStart(2,"0"));function HT(T){if(I0(T),gZ)return T.toHex();let A="";for(let Q=0;Q<T.length;Q++)A+=_j[T[Q]];return A}var aT={_0:48,_9:57,A:65,F:70,a:97,f:102};function xZ(T){if(T>=aT._0&&T<=aT._9)return T-aT._0;if(T>=aT.A&&T<=aT.F)return T-(aT.A-10);if(T>=aT.a&&T<=aT.f)return T-(aT.a-10);return}function t8(T){if(typeof T!=="string")throw Error("hex string expected, got "+typeof T);if(gZ)return Uint8Array.fromHex(T);let A=T.length,Q=A/2;if(A%2)throw Error("hex string expected, got unpadded hex of length "+A);let J=new Uint8Array(Q);for(let $=0,W=0;$<Q;$++,W+=2){let G=xZ(T.charCodeAt(W)),Y=xZ(T.charCodeAt(W+1));if(G===void 0||Y===void 0){let Z=T[W]+T[W+1];throw Error('hex string expected, got non-hex character "'+Z+'" at index '+W)}J[$]=G*16+Y}return J}function rJ(T){if(typeof T!=="string")throw Error("string expected");return new Uint8Array(new TextEncoder().encode(T))}function e8(T){if(typeof T==="string")T=rJ(T);return I0(T),T}function l0(...T){let A=0;for(let J=0;J<T.length;J++){let $=T[J];I0($),A+=$.length}let Q=new Uint8Array(A);for(let J=0,$=0;J<T.length;J++){let W=T[J];Q.set(W,$),$+=W.length}return Q}class TA{}function R2(T){let A=(J)=>T().update(e8(J)).digest(),Q=T();return A.outputLen=Q.outputLen,A.blockLen=Q.blockLen,A.create=()=>T(),A}function BA(T=32){if(s8&&typeof s8.getRandomValues==="function")return s8.getRandomValues(new Uint8Array(T));if(s8&&typeof s8.randomBytes==="function")return Uint8Array.from(s8.randomBytes(T));throw Error("crypto.getRandomValues must be defined")}function xj(T,A,Q,J){if(typeof T.setBigUint64==="function")return T.setBigUint64(A,Q,J);let $=BigInt(32),W=BigInt(4294967295),G=Number(Q>>$&W),Y=Number(Q&W),Z=J?4:0,C=J?0:4;T.setUint32(A+Z,G,J),T.setUint32(A+C,Y,J)}function mZ(T,A,Q){return T&A^~T&Q}function vZ(T,A,Q){return T&A^T&Q^A&Q}class f6 extends TA{constructor(T,A,Q,J){super();this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=T,this.outputLen=A,this.padOffset=Q,this.isLE=J,this.buffer=new Uint8Array(T),this.view=c6(this.buffer)}update(T){tT(this),T=e8(T),I0(T);let{view:A,buffer:Q,blockLen:J}=this,$=T.length;for(let W=0;W<$;){let G=Math.min(J-this.pos,$-W);if(G===J){let Y=c6(T);for(;J<=$-W;W+=J)this.process(Y,W);continue}if(Q.set(T.subarray(W,W+G),this.pos),this.pos+=G,W+=G,this.pos===J)this.process(A,0),this.pos=0}return this.length+=T.length,this.roundClean(),this}digestInto(T){tT(this),d6(T,this),this.finished=!0;let{buffer:A,view:Q,blockLen:J,isLE:$}=this,{pos:W}=this;if(A[W++]=128,CT(this.buffer.subarray(W)),this.padOffset>J-W)this.process(Q,0),W=0;for(let K=W;K<J;K++)A[K]=0;xj(Q,J-8,BigInt(this.length*8),$),this.process(Q,0);let G=c6(T),Y=this.outputLen;if(Y%4)throw Error("_sha2: outputLen should be aligned to 32bit");let Z=Y/4,C=this.get();if(Z>C.length)throw Error("_sha2: outputLen bigger than state");for(let K=0;K<Z;K++)G.setUint32(4*K,C[K],$)}digest(){let{buffer:T,outputLen:A}=this;this.digestInto(T);let Q=T.slice(0,A);return this.destroy(),Q}_cloneInto(T){T||(T=new this.constructor),T.set(...this.get());let{blockLen:A,buffer:Q,length:J,finished:$,destroyed:W,pos:G}=this;if(T.destroyed=W,T.finished=$,T.length=J,T.pos=G,J%A)T.buffer.set(Q);return T}clone(){return this._cloneInto()}}var eT=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var S0=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var r6=BigInt(4294967295),yZ=BigInt(32);function hj(T,A=!1){if(A)return{h:Number(T&r6),l:Number(T>>yZ&r6)};return{h:Number(T>>yZ&r6)|0,l:Number(T&r6)|0}}function n6(T,A=!1){let Q=T.length,J=new Uint32Array(Q),$=new Uint32Array(Q);for(let W=0;W<Q;W++){let{h:G,l:Y}=hj(T[W],A);[J[W],$[W]]=[G,Y]}return[J,$]}var nJ=(T,A,Q)=>T>>>Q,iJ=(T,A,Q)=>T<<32-Q|A>>>Q,AA=(T,A,Q)=>T>>>Q|A<<32-Q,QA=(T,A,Q)=>T<<32-Q|A>>>Q,D2=(T,A,Q)=>T<<64-Q|A>>>Q-32,M2=(T,A,Q)=>T>>>Q-32|A<<64-Q;var bZ=(T,A,Q)=>T<<Q|A>>>32-Q,pZ=(T,A,Q)=>A<<Q|T>>>32-Q,lZ=(T,A,Q)=>A<<Q-32|T>>>64-Q,uZ=(T,A,Q)=>T<<Q-32|A>>>64-Q;function mT(T,A,Q,J){let $=(A>>>0)+(J>>>0);return{h:T+Q+($/4294967296|0)|0,l:$|0}}var dZ=(T,A,Q)=>(T>>>0)+(A>>>0)+(Q>>>0),cZ=(T,A,Q,J)=>A+Q+J+(T/4294967296|0)|0,fZ=(T,A,Q,J)=>(T>>>0)+(A>>>0)+(Q>>>0)+(J>>>0),rZ=(T,A,Q,J,$)=>A+Q+J+$+(T/4294967296|0)|0,nZ=(T,A,Q,J,$)=>(T>>>0)+(A>>>0)+(Q>>>0)+(J>>>0)+($>>>0),iZ=(T,A,Q,J,$,W)=>A+Q+J+$+W+(T/4294967296|0)|0;var mj=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]),N8=new Uint32Array(64);class oJ extends f6{constructor(T=32){super(64,T,8,!1);this.A=eT[0]|0,this.B=eT[1]|0,this.C=eT[2]|0,this.D=eT[3]|0,this.E=eT[4]|0,this.F=eT[5]|0,this.G=eT[6]|0,this.H=eT[7]|0}get(){let{A:T,B:A,C:Q,D:J,E:$,F:W,G,H:Y}=this;return[T,A,Q,J,$,W,G,Y]}set(T,A,Q,J,$,W,G,Y){this.A=T|0,this.B=A|0,this.C=Q|0,this.D=J|0,this.E=$|0,this.F=W|0,this.G=G|0,this.H=Y|0}process(T,A){for(let K=0;K<16;K++,A+=4)N8[K]=T.getUint32(A,!1);for(let K=16;K<64;K++){let j=N8[K-15],M=N8[K-2],z=DT(j,7)^DT(j,18)^j>>>3,N=DT(M,17)^DT(M,19)^M>>>10;N8[K]=N+N8[K-7]+z+N8[K-16]|0}let{A:Q,B:J,C:$,D:W,E:G,F:Y,G:Z,H:C}=this;for(let K=0;K<64;K++){let j=DT(G,6)^DT(G,11)^DT(G,25),M=C+j+mZ(G,Y,Z)+mj[K]+N8[K]|0,N=(DT(Q,2)^DT(Q,13)^DT(Q,22))+vZ(Q,J,$)|0;C=Z,Z=Y,Y=G,G=W+M|0,W=$,$=J,J=Q,Q=M+N|0}Q=Q+this.A|0,J=J+this.B|0,$=$+this.C|0,W=W+this.D|0,G=G+this.E|0,Y=Y+this.F|0,Z=Z+this.G|0,C=C+this.H|0,this.set(Q,J,$,W,G,Y,Z,C)}roundClean(){CT(N8)}destroy(){this.set(0,0,0,0,0,0,0,0),CT(this.buffer)}}var oZ=(()=>n6(["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))))(),vj=(()=>oZ[0])(),yj=(()=>oZ[1])(),I8=new Uint32Array(80),S8=new Uint32Array(80);class aZ extends f6{constructor(T=64){super(128,T,16,!1);this.Ah=S0[0]|0,this.Al=S0[1]|0,this.Bh=S0[2]|0,this.Bl=S0[3]|0,this.Ch=S0[4]|0,this.Cl=S0[5]|0,this.Dh=S0[6]|0,this.Dl=S0[7]|0,this.Eh=S0[8]|0,this.El=S0[9]|0,this.Fh=S0[10]|0,this.Fl=S0[11]|0,this.Gh=S0[12]|0,this.Gl=S0[13]|0,this.Hh=S0[14]|0,this.Hl=S0[15]|0}get(){let{Ah:T,Al:A,Bh:Q,Bl:J,Ch:$,Cl:W,Dh:G,Dl:Y,Eh:Z,El:C,Fh:K,Fl:j,Gh:M,Gl:z,Hh:N,Hl:E}=this;return[T,A,Q,J,$,W,G,Y,Z,C,K,j,M,z,N,E]}set(T,A,Q,J,$,W,G,Y,Z,C,K,j,M,z,N,E){this.Ah=T|0,this.Al=A|0,this.Bh=Q|0,this.Bl=J|0,this.Ch=$|0,this.Cl=W|0,this.Dh=G|0,this.Dl=Y|0,this.Eh=Z|0,this.El=C|0,this.Fh=K|0,this.Fl=j|0,this.Gh=M|0,this.Gl=z|0,this.Hh=N|0,this.Hl=E|0}process(T,A){for(let g=0;g<16;g++,A+=4)I8[g]=T.getUint32(A),S8[g]=T.getUint32(A+=4);for(let g=16;g<80;g++){let v=I8[g-15]|0,p=S8[g-15]|0,c=AA(v,p,1)^AA(v,p,8)^nJ(v,p,7),u=QA(v,p,1)^QA(v,p,8)^iJ(v,p,7),i=I8[g-2]|0,d=S8[g-2]|0,h=AA(i,d,19)^D2(i,d,61)^nJ(i,d,6),o=QA(i,d,19)^M2(i,d,61)^iJ(i,d,6),n=fZ(u,o,S8[g-7],S8[g-16]),x=rZ(n,c,h,I8[g-7],I8[g-16]);I8[g]=x|0,S8[g]=n|0}let{Ah:Q,Al:J,Bh:$,Bl:W,Ch:G,Cl:Y,Dh:Z,Dl:C,Eh:K,El:j,Fh:M,Fl:z,Gh:N,Gl:E,Hh:L,Hl:O}=this;for(let g=0;g<80;g++){let v=AA(K,j,14)^AA(K,j,18)^D2(K,j,41),p=QA(K,j,14)^QA(K,j,18)^M2(K,j,41),c=K&M^~K&N,u=j&z^~j&E,i=nZ(O,p,u,yj[g],S8[g]),d=iZ(i,L,v,c,vj[g],I8[g]),h=i|0,o=AA(Q,J,28)^D2(Q,J,34)^D2(Q,J,39),n=QA(Q,J,28)^M2(Q,J,34)^M2(Q,J,39),x=Q&$^Q&G^$&G,R=J&W^J&Y^W&Y;L=N|0,O=E|0,N=M|0,E=z|0,M=K|0,z=j|0,{h:K,l:j}=mT(Z|0,C|0,d|0,h|0),Z=G|0,C=Y|0,G=$|0,Y=W|0,$=Q|0,W=J|0;let U=dZ(h,n,R);Q=cZ(U,d,o,x),J=U|0}({h:Q,l:J}=mT(this.Ah|0,this.Al|0,Q|0,J|0)),{h:$,l:W}=mT(this.Bh|0,this.Bl|0,$|0,W|0),{h:G,l:Y}=mT(this.Ch|0,this.Cl|0,G|0,Y|0),{h:Z,l:C}=mT(this.Dh|0,this.Dl|0,Z|0,C|0),{h:K,l:j}=mT(this.Eh|0,this.El|0,K|0,j|0),{h:M,l:z}=mT(this.Fh|0,this.Fl|0,M|0,z|0),{h:N,l:E}=mT(this.Gh|0,this.Gl|0,N|0,E|0),{h:L,l:O}=mT(this.Hh|0,this.Hl|0,L|0,O|0),this.set(Q,J,$,W,G,Y,Z,C,K,j,M,z,N,E,L,O)}roundClean(){CT(I8,S8)}destroy(){CT(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}var i6=R2(()=>new oJ);var sZ=R2(()=>new aZ);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var tJ=BigInt(0),sJ=BigInt(1);function T8(T,A=""){if(typeof T!=="boolean"){let Q=A&&`"${A}"`;throw Error(Q+"expected boolean, got type="+typeof T)}return T}function GT(T,A,Q=""){let J=sT(T),$=T?.length,W=A!==void 0;if(!J||W&&$!==A){let G=Q&&`"${Q}" `,Y=W?` of length ${A}`:"",Z=J?`length=${$}`:`type=${typeof T}`;throw Error(G+"expected Uint8Array"+Y+", got "+Z)}return T}function k2(T){let A=T.toString(16);return A.length&1?"0"+A:A}function tZ(T){if(typeof T!=="string")throw Error("hex string expected, got "+typeof T);return T===""?tJ:BigInt("0x"+T)}function _A(T){return tZ(HT(T))}function A8(T){return I0(T),tZ(HT(Uint8Array.from(T).reverse()))}function o6(T,A){return t8(T.toString(16).padStart(A*2,"0"))}function eJ(T,A){return o6(T,A).reverse()}function q1(T,A,Q){let J;if(typeof A==="string")try{J=t8(A)}catch(W){throw Error(T+" must be hex string or Uint8Array, cause: "+W)}else if(sT(A))J=Uint8Array.from(A);else throw Error(T+" must be hex string or Uint8Array");let $=J.length;if(typeof Q==="number"&&$!==Q)throw Error(T+" of length "+Q+" expected, got "+$);return J}function eZ(T,A){if(T.length!==A.length)return!1;let Q=0;for(let J=0;J<T.length;J++)Q|=T[J]^A[J];return Q===0}function T$(T){return Uint8Array.from(T)}var aJ=(T)=>typeof T==="bigint"&&tJ<=T;function T9(T,A,Q){return aJ(T)&&aJ(A)&&aJ(Q)&&A<=T&&T<Q}function z2(T,A,Q,J){if(!T9(A,Q,J))throw Error("expected valid "+T+": "+Q+" <= n < "+J+", got "+A)}function a6(T){let A;for(A=0;T>tJ;T>>=sJ,A+=1);return A}var L8=(T)=>(sJ<<BigInt(T))-sJ;function A9(T,A,Q){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 Q!=="function")throw Error("hmacFn must be a function");let J=(z)=>new Uint8Array(z),$=(z)=>Uint8Array.of(z),W=J(T),G=J(T),Y=0,Z=()=>{W.fill(1),G.fill(0),Y=0},C=(...z)=>Q(G,W,...z),K=(z=J(0))=>{if(G=C($(0),z),W=C(),z.length===0)return;G=C($(1),z),W=C()},j=()=>{if(Y++>=1000)throw Error("drbg: tried 1000 values");let z=0,N=[];while(z<A){W=C();let E=W.slice();N.push(E),z+=W.length}return l0(...N)};return(z,N)=>{Z(),K(z);let E=void 0;while(!(E=N(j())))K();return Z(),E}}function w8(T,A,Q={}){if(!T||typeof T!=="object")throw Error("expected valid options object");function J($,W,G){let Y=T[$];if(G&&Y===void 0)return;let Z=typeof Y;if(Z!==W||Y===null)throw Error(`param "${$}" is invalid: expected ${W}, got ${Z}`)}Object.entries(A).forEach(([$,W])=>J($,W,!1)),Object.entries(Q).forEach(([$,W])=>J($,W,!0))}var A$=()=>{throw Error("not implemented")};function xA(T){let A=new WeakMap;return(Q,...J)=>{let $=A.get(Q);if($!==void 0)return $;let W=T(Q,...J);return A.set(Q,W),W}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var u0=BigInt(0),F0=BigInt(1),JA=BigInt(2),$9=BigInt(3),W9=BigInt(4),G9=BigInt(5),bj=BigInt(7),U9=BigInt(8),pj=BigInt(9),Y9=BigInt(16);function I1(T,A){let Q=T%A;return Q>=u0?Q:A+Q}function k1(T,A,Q){let J=T;while(A-- >u0)J*=J,J%=Q;return J}function Q9(T,A){if(T===u0)throw Error("invert: expected non-zero number");if(A<=u0)throw Error("invert: expected positive modulus, got "+A);let Q=I1(T,A),J=A,$=u0,W=F0,G=F0,Y=u0;while(Q!==u0){let C=J/Q,K=J%Q,j=$-G*C,M=W-Y*C;J=Q,Q=K,$=G,W=Y,G=j,Y=M}if(J!==F0)throw Error("invert: does not exist");return I1($,A)}function Q$(T,A,Q){if(!T.eql(T.sqr(A),Q))throw Error("Cannot find square root")}function Z9(T,A){let Q=(T.ORDER+F0)/W9,J=T.pow(A,Q);return Q$(T,J,A),J}function lj(T,A){let Q=(T.ORDER-G9)/U9,J=T.mul(A,JA),$=T.pow(J,Q),W=T.mul(A,$),G=T.mul(T.mul(W,JA),$),Y=T.mul(W,T.sub(G,T.ONE));return Q$(T,Y,A),Y}function uj(T){let A=UT(T),Q=X9(T),J=Q(A,A.neg(A.ONE)),$=Q(A,J),W=Q(A,A.neg(J)),G=(T+bj)/Y9;return(Y,Z)=>{let C=Y.pow(Z,G),K=Y.mul(C,J),j=Y.mul(C,$),M=Y.mul(C,W),z=Y.eql(Y.sqr(K),Z),N=Y.eql(Y.sqr(j),Z);C=Y.cmov(C,K,z),K=Y.cmov(M,j,N);let E=Y.eql(Y.sqr(K),Z),L=Y.cmov(C,K,E);return Q$(Y,L,Z),L}}function X9(T){if(T<$9)throw Error("sqrt is not defined for small field");let A=T-F0,Q=0;while(A%JA===u0)A/=JA,Q++;let J=JA,$=UT(T);while(J9($,J)===1)if(J++>1000)throw Error("Cannot find square root: probably non-prime P");if(Q===1)return Z9;let W=$.pow(J,A),G=(A+F0)/JA;return function(Z,C){if(Z.is0(C))return C;if(J9(Z,C)!==1)throw Error("Cannot find square root");let K=Q,j=Z.mul(Z.ONE,W),M=Z.pow(C,A),z=Z.pow(C,G);while(!Z.eql(M,Z.ONE)){if(Z.is0(M))return Z.ZERO;let N=1,E=Z.sqr(M);while(!Z.eql(E,Z.ONE))if(N++,E=Z.sqr(E),N===K)throw Error("Cannot find square root");let L=F0<<BigInt(K-N-1),O=Z.pow(j,L);K=N,j=Z.sqr(O),M=Z.mul(M,j),z=Z.mul(z,O)}return z}}function dj(T){if(T%W9===$9)return Z9;if(T%U9===G9)return lj;if(T%Y9===pj)return uj(T);return X9(T)}var Q8=(T,A)=>(I1(T,A)&F0)===F0,cj=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function J$(T){let A={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},Q=cj.reduce((J,$)=>{return J[$]="function",J},A);return w8(T,Q),T}function fj(T,A,Q){if(Q<u0)throw Error("invalid exponent, negatives unsupported");if(Q===u0)return T.ONE;if(Q===F0)return A;let J=T.ONE,$=A;while(Q>u0){if(Q&F0)J=T.mul(J,$);$=T.sqr($),Q>>=F0}return J}function F2(T,A,Q=!1){let J=Array(A.length).fill(Q?T.ZERO:void 0),$=A.reduce((G,Y,Z)=>{if(T.is0(Y))return G;return J[Z]=G,T.mul(G,Y)},T.ONE),W=T.inv($);return A.reduceRight((G,Y,Z)=>{if(T.is0(Y))return G;return J[Z]=T.mul(G,J[Z]),T.mul(G,Y)},W),J}function J9(T,A){let Q=(T.ORDER-F0)/JA,J=T.pow(A,Q),$=T.eql(J,T.ONE),W=T.eql(J,T.ZERO),G=T.eql(J,T.neg(T.ONE));if(!$&&!W&&!G)throw Error("invalid Legendre symbol result");return $?1:W?0:-1}function s6(T,A){if(A!==void 0)F8(A);let Q=A!==void 0?A:T.toString(2).length,J=Math.ceil(Q/8);return{nBitLength:Q,nByteLength:J}}function UT(T,A,Q=!1,J={}){if(T<=u0)throw Error("invalid field: expected ORDER > 0, got "+T);let $=void 0,W=void 0,G=!1,Y=void 0;if(typeof A==="object"&&A!=null){if(J.sqrt||Q)throw Error("cannot specify opts in two arguments");let M=A;if(M.BITS)$=M.BITS;if(M.sqrt)W=M.sqrt;if(typeof M.isLE==="boolean")Q=M.isLE;if(typeof M.modFromBytes==="boolean")G=M.modFromBytes;Y=M.allowedLengths}else{if(typeof A==="number")$=A;if(J.sqrt)W=J.sqrt}let{nBitLength:Z,nByteLength:C}=s6(T,$);if(C>2048)throw Error("invalid field: expected ORDER of <= 2048 bytes");let K,j=Object.freeze({ORDER:T,isLE:Q,BITS:Z,BYTES:C,MASK:L8(Z),ZERO:u0,ONE:F0,allowedLengths:Y,create:(M)=>I1(M,T),isValid:(M)=>{if(typeof M!=="bigint")throw Error("invalid field element: expected bigint, got "+typeof M);return u0<=M&&M<T},is0:(M)=>M===u0,isValidNot0:(M)=>!j.is0(M)&&j.isValid(M),isOdd:(M)=>(M&F0)===F0,neg:(M)=>I1(-M,T),eql:(M,z)=>M===z,sqr:(M)=>I1(M*M,T),add:(M,z)=>I1(M+z,T),sub:(M,z)=>I1(M-z,T),mul:(M,z)=>I1(M*z,T),pow:(M,z)=>fj(j,M,z),div:(M,z)=>I1(M*Q9(z,T),T),sqrN:(M)=>M*M,addN:(M,z)=>M+z,subN:(M,z)=>M-z,mulN:(M,z)=>M*z,inv:(M)=>Q9(M,T),sqrt:W||((M)=>{if(!K)K=dj(T);return K(j,M)}),toBytes:(M)=>Q?eJ(M,C):o6(M,C),fromBytes:(M,z=!0)=>{if(Y){if(!Y.includes(M.length)||M.length>C)throw Error("Field.fromBytes: expected "+Y+" bytes, got "+M.length);let E=new Uint8Array(C);E.set(M,Q?0:E.length-M.length),M=E}if(M.length!==C)throw Error("Field.fromBytes: expected "+C+" bytes, got "+M.length);let N=Q?A8(M):_A(M);if(G)N=I1(N,T);if(!z){if(!j.isValid(N))throw Error("invalid field element: outside of range 0..ORDER")}return N},invertBatch:(M)=>F2(j,M),cmov:(M,z,N)=>N?z:M});return Object.freeze(j)}function P9(T){if(typeof T!=="bigint")throw Error("field order must be bigint");let A=T.toString(2).length;return Math.ceil(A/8)}function $$(T){let A=P9(T);return A+Math.ceil(A/2)}function W$(T,A,Q=!1){let J=T.length,$=P9(A),W=$$(A);if(J<16||J<W||J>1024)throw Error("expected "+W+"-1024 bytes of input, got "+J);let G=Q?A8(T):_A(T),Y=I1(G,A-F0)+F0;return Q?eJ(Y,$):o6(Y,$)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var hA=BigInt(0),$A=BigInt(1);function N2(T,A){let Q=A.negate();return T?Q:A}function J8(T,A){let Q=F2(T.Fp,A.map((J)=>J.Z));return A.map((J,$)=>T.fromAffine(J.toAffine(Q[$])))}function H9(T,A){if(!Number.isSafeInteger(T)||T<=0||T>A)throw Error("invalid window size, expected [1.."+A+"], got W="+T)}function G$(T,A){H9(T,A);let Q=Math.ceil(A/T)+1,J=2**(T-1),$=2**T,W=L8(T),G=BigInt(T);return{windows:Q,windowSize:J,mask:W,maxNumber:$,shiftBy:G}}function q9(T,A,Q){let{windowSize:J,mask:$,maxNumber:W,shiftBy:G}=Q,Y=Number(T&$),Z=T>>G;if(Y>J)Y-=W,Z+=$A;let C=A*J,K=C+Math.abs(Y)-1,j=Y===0,M=Y<0,z=A%2!==0;return{nextN:Z,offset:K,isZero:j,isNeg:M,isNegF:z,offsetF:C}}function rj(T,A){if(!Array.isArray(T))throw Error("array expected");T.forEach((Q,J)=>{if(!(Q instanceof A))throw Error("invalid point at index "+J)})}function nj(T,A){if(!Array.isArray(T))throw Error("array of scalars expected");T.forEach((Q,J)=>{if(!A.isValid(Q))throw Error("invalid scalar at index "+J)})}var U$=new WeakMap,V9=new WeakMap;function Y$(T){return V9.get(T)||1}function K9(T){if(T!==hA)throw Error("invalid wNAF")}class I2{constructor(T,A){this.BASE=T.BASE,this.ZERO=T.ZERO,this.Fn=T.Fn,this.bits=A}_unsafeLadder(T,A,Q=this.ZERO){let J=T;while(A>hA){if(A&$A)Q=Q.add(J);J=J.double(),A>>=$A}return Q}precomputeWindow(T,A){let{windows:Q,windowSize:J}=G$(A,this.bits),$=[],W=T,G=W;for(let Y=0;Y<Q;Y++){G=W,$.push(G);for(let Z=1;Z<J;Z++)G=G.add(W),$.push(G);W=G.double()}return $}wNAF(T,A,Q){if(!this.Fn.isValid(Q))throw Error("invalid scalar");let J=this.ZERO,$=this.BASE,W=G$(T,this.bits);for(let G=0;G<W.windows;G++){let{nextN:Y,offset:Z,isZero:C,isNeg:K,isNegF:j,offsetF:M}=q9(Q,G,W);if(Q=Y,C)$=$.add(N2(j,A[M]));else J=J.add(N2(K,A[Z]))}return K9(Q),{p:J,f:$}}wNAFUnsafe(T,A,Q,J=this.ZERO){let $=G$(T,this.bits);for(let W=0;W<$.windows;W++){if(Q===hA)break;let{nextN:G,offset:Y,isZero:Z,isNeg:C}=q9(Q,W,$);if(Q=G,Z)continue;else{let K=A[Y];J=J.add(C?K.negate():K)}}return K9(Q),J}getPrecomputes(T,A,Q){let J=U$.get(A);if(!J){if(J=this.precomputeWindow(A,T),T!==1){if(typeof Q==="function")J=Q(J);U$.set(A,J)}}return J}cached(T,A,Q){let J=Y$(T);return this.wNAF(J,this.getPrecomputes(J,T,Q),A)}unsafe(T,A,Q,J){let $=Y$(T);if($===1)return this._unsafeLadder(T,A,J);return this.wNAFUnsafe($,this.getPrecomputes($,T,Q),A,J)}createCache(T,A){H9(A,this.bits),V9.set(T,A),U$.delete(T)}hasCache(T){return Y$(T)!==1}}function j9(T,A,Q,J){let $=A,W=T.ZERO,G=T.ZERO;while(Q>hA||J>hA){if(Q&$A)W=W.add($);if(J&$A)G=G.add($);$=$.double(),Q>>=$A,J>>=$A}return{p1:W,p2:G}}function gA(T,A,Q,J){rj(Q,T),nj(J,A);let $=Q.length,W=J.length;if($!==W)throw Error("arrays of points and scalars must have equal length");let G=T.ZERO,Y=a6(BigInt($)),Z=1;if(Y>12)Z=Y-3;else if(Y>4)Z=Y-2;else if(Y>0)Z=2;let C=L8(Z),K=Array(Number(C)+1).fill(G),j=Math.floor((A.BITS-1)/Z)*Z,M=G;for(let z=j;z>=0;z-=Z){K.fill(G);for(let E=0;E<W;E++){let L=J[E],O=Number(L>>BigInt(z)&C);K[O]=K[O].add(Q[E])}let N=G;for(let E=K.length-1,L=G;E>0;E--)L=L.add(K[E]),N=N.add(L);if(M=M.add(N),z!==0)for(let E=0;E<Z;E++)M=M.double()}return M}function C9(T,A,Q){if(A){if(A.ORDER!==T)throw Error("Field.ORDER must match order: Fp == p, Fn == n");return J$(A),A}else return UT(T,{isLE:Q})}function t6(T,A,Q={},J){if(J===void 0)J=T==="edwards";if(!A||typeof A!=="object")throw Error(`expected valid ${T} CURVE object`);for(let Z of["p","n","h"]){let C=A[Z];if(!(typeof C==="bigint"&&C>hA))throw Error(`CURVE.${Z} must be positive bigint`)}let $=C9(A.p,Q.Fp,J),W=C9(A.n,Q.Fn,J),Y=["Gx","Gy","a",T==="weierstrass"?"b":"d"];for(let Z of Y)if(!$.isValid(A[Z]))throw Error(`CURVE.${Z} must be valid field element of CURVE.Fp`);return A=Object.freeze(Object.assign({},A)),{CURVE:A,Fp:$,Fn:W}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var E8=BigInt(0),N0=BigInt(1),Z$=BigInt(2),ij=BigInt(8);function oj(T,A,Q,J){let $=T.sqr(Q),W=T.sqr(J),G=T.add(T.mul(A.a,$),W),Y=T.add(T.ONE,T.mul(A.d,T.mul($,W)));return T.eql(G,Y)}function aj(T,A={}){let Q=t6("edwards",T,A,A.FpFnLE),{Fp:J,Fn:$}=Q,W=Q.CURVE,{h:G}=W;w8(A,{},{uvRatio:"function"});let Y=Z$<<BigInt($.BYTES*8)-N0,Z=(L)=>J.create(L),C=A.uvRatio||((L,O)=>{try{return{isValid:!0,value:J.sqrt(J.div(L,O))}}catch(g){return{isValid:!1,value:E8}}});if(!oj(J,W,W.Gx,W.Gy))throw Error("bad curve params: generator point");function K(L,O,g=!1){let v=g?N0:E8;return z2("coordinate "+L,O,v,Y),O}function j(L){if(!(L instanceof N))throw Error("ExtendedPoint expected")}let M=xA((L,O)=>{let{X:g,Y:v,Z:p}=L,c=L.is0();if(O==null)O=c?ij:J.inv(p);let u=Z(g*O),i=Z(v*O),d=J.mul(p,O);if(c)return{x:E8,y:N0};if(d!==N0)throw Error("invZ was invalid");return{x:u,y:i}}),z=xA((L)=>{let{a:O,d:g}=W;if(L.is0())throw Error("bad point: ZERO");let{X:v,Y:p,Z:c,T:u}=L,i=Z(v*v),d=Z(p*p),h=Z(c*c),o=Z(h*h),n=Z(i*O),x=Z(h*Z(n+d)),R=Z(o+Z(g*Z(i*d)));if(x!==R)throw Error("bad point: equation left != right (1)");let U=Z(v*p),X=Z(c*u);if(U!==X)throw Error("bad point: equation left != right (2)");return!0});class N{constructor(L,O,g,v){this.X=K("x",L),this.Y=K("y",O),this.Z=K("z",g,!0),this.T=K("t",v),Object.freeze(this)}static CURVE(){return W}static fromAffine(L){if(L instanceof N)throw Error("extended point not allowed");let{x:O,y:g}=L||{};return K("x",O),K("y",g),new N(O,g,N0,Z(O*g))}static fromBytes(L,O=!1){let g=J.BYTES,{a:v,d:p}=W;L=T$(GT(L,g,"point")),T8(O,"zip215");let c=T$(L),u=L[g-1];c[g-1]=u&-129;let i=A8(c),d=O?Y:J.ORDER;z2("point.y",i,E8,d);let h=Z(i*i),o=Z(h-N0),n=Z(p*h-v),{isValid:x,value:R}=C(o,n);if(!x)throw Error("bad point: invalid y coordinate");let U=(R&N0)===N0,X=(u&128)!==0;if(!O&&R===E8&&X)throw Error("bad point: x=0 and x_0=1");if(X!==U)R=Z(-R);return N.fromAffine({x:R,y:i})}static fromHex(L,O=!1){return N.fromBytes(q1("point",L),O)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(L=8,O=!0){if(E.createCache(this,L),!O)this.multiply(Z$);return this}assertValidity(){z(this)}equals(L){j(L);let{X:O,Y:g,Z:v}=this,{X:p,Y:c,Z:u}=L,i=Z(O*u),d=Z(p*v),h=Z(g*u),o=Z(c*v);return i===d&&h===o}is0(){return this.equals(N.ZERO)}negate(){return new N(Z(-this.X),this.Y,this.Z,Z(-this.T))}double(){let{a:L}=W,{X:O,Y:g,Z:v}=this,p=Z(O*O),c=Z(g*g),u=Z(Z$*Z(v*v)),i=Z(L*p),d=O+g,h=Z(Z(d*d)-p-c),o=i+c,n=o-u,x=i-c,R=Z(h*n),U=Z(o*x),X=Z(h*x),q=Z(n*o);return new N(R,U,q,X)}add(L){j(L);let{a:O,d:g}=W,{X:v,Y:p,Z:c,T:u}=this,{X:i,Y:d,Z:h,T:o}=L,n=Z(v*i),x=Z(p*d),R=Z(u*g*o),U=Z(c*h),X=Z((v+p)*(i+d)-n-x),q=U-R,H=U+R,V=Z(x-O*n),F=Z(X*q),I=Z(H*V),D=Z(X*V),P=Z(q*H);return new N(F,I,P,D)}subtract(L){return this.add(L.negate())}multiply(L){if(!$.isValidNot0(L))throw Error("invalid scalar: expected 1 <= sc < curve.n");let{p:O,f:g}=E.cached(this,L,(v)=>J8(N,v));return J8(N,[O,g])[0]}multiplyUnsafe(L,O=N.ZERO){if(!$.isValid(L))throw Error("invalid scalar: expected 0 <= sc < curve.n");if(L===E8)return N.ZERO;if(this.is0()||L===N0)return this;return E.unsafe(this,L,(g)=>J8(N,g),O)}isSmallOrder(){return this.multiplyUnsafe(G).is0()}isTorsionFree(){return E.unsafe(this,W.n).is0()}toAffine(L){return M(this,L)}clearCofactor(){if(G===N0)return this;return this.multiplyUnsafe(G)}toBytes(){let{x:L,y:O}=this.toAffine(),g=J.toBytes(O);return g[g.length-1]|=L&N0?128:0,g}toHex(){return HT(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(L){return J8(N,L)}static msm(L,O){return gA(N,$,L,O)}_setWindowSize(L){this.precompute(L)}toRawBytes(){return this.toBytes()}}N.BASE=new N(W.Gx,W.Gy,N0,Z(W.Gx*W.Gy)),N.ZERO=new N(E8,N0,N0,E8),N.Fp=J,N.Fn=$;let E=new I2(N,$.BITS);return N.BASE.precompute(8),N}class X${constructor(T){this.ep=T}static fromBytes(T){A$()}static fromHex(T){A$()}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 HT(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 sj(T,A,Q={}){if(typeof A!=="function")throw Error('"hash" function param is required');w8(Q,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});let{prehash:J}=Q,{BASE:$,Fp:W,Fn:G}=T,Y=Q.randomBytes||BA,Z=Q.adjustScalarBytes||((h)=>h),C=Q.domain||((h,o,n)=>{if(T8(n,"phflag"),o.length||n)throw Error("Contexts/pre-hash are not supported");return h});function K(h){return G.create(A8(h))}function j(h){let o=v.secretKey;h=q1("private key",h,o);let n=q1("hashed private key",A(h),2*o),x=Z(n.slice(0,o)),R=n.slice(o,2*o),U=K(x);return{head:x,prefix:R,scalar:U}}function M(h){let{head:o,prefix:n,scalar:x}=j(h),R=$.multiply(x),U=R.toBytes();return{head:o,prefix:n,scalar:x,point:R,pointBytes:U}}function z(h){return M(h).pointBytes}function N(h=Uint8Array.of(),...o){let n=l0(...o);return K(A(C(n,q1("context",h),!!J)))}function E(h,o,n={}){if(h=q1("message",h),J)h=J(h);let{prefix:x,scalar:R,pointBytes:U}=M(o),X=N(n.context,x,h),q=$.multiply(X).toBytes(),H=N(n.context,q,U,h),V=G.create(X+H*R);if(!G.isValid(V))throw Error("sign failed: invalid s");let F=l0(q,G.toBytes(V));return GT(F,v.signature,"result")}let L={zip215:!0};function O(h,o,n,x=L){let{context:R,zip215:U}=x,X=v.signature;if(h=q1("signature",h,X),o=q1("message",o),n=q1("publicKey",n,v.publicKey),U!==void 0)T8(U,"zip215");if(J)o=J(o);let q=X/2,H=h.subarray(0,q),V=A8(h.subarray(q,X)),F,I,D;try{F=T.fromBytes(n,U),I=T.fromBytes(H,U),D=$.multiplyUnsafe(V)}catch(b){return!1}if(!U&&F.isSmallOrder())return!1;let P=N(R,I.toBytes(),F.toBytes(),o);return I.add(F.multiplyUnsafe(P)).subtract(D).clearCofactor().is0()}let g=W.BYTES,v={secretKey:g,publicKey:g,signature:2*g,seed:g};function p(h=Y(v.seed)){return GT(h,v.seed,"seed")}function c(h){let o=d.randomSecretKey(h);return{secretKey:o,publicKey:z(o)}}function u(h){return sT(h)&&h.length===G.BYTES}function i(h,o){try{return!!T.fromBytes(h,o)}catch(n){return!1}}let d={getExtendedPublicKey:M,randomSecretKey:p,isValidSecretKey:u,isValidPublicKey:i,toMontgomery(h){let{y:o}=T.fromBytes(h),n=v.publicKey,x=n===32;if(!x&&n!==57)throw Error("only defined for 25519 and 448");let R=x?W.div(N0+o,N0-o):W.div(o-N0,o+N0);return W.toBytes(R)},toMontgomerySecret(h){let o=v.secretKey;GT(h,o);let n=A(h.subarray(0,o));return Z(n).subarray(0,o)},randomPrivateKey:p,precompute(h=8,o=T.BASE){return o.precompute(h,!1)}};return Object.freeze({keygen:c,getPublicKey:z,sign:E,verify:O,utils:d,Point:T,lengths:v})}function tj(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},Q=T.Fp,J=UT(A.n,T.nBitLength,!0),$={Fp:Q,Fn:J,uvRatio:T.uvRatio},W={randomBytes:T.randomBytes,adjustScalarBytes:T.adjustScalarBytes,domain:T.domain,prehash:T.prehash,mapToCurve:T.mapToCurve};return{CURVE:A,curveOpts:$,hash:T.hash,eddsaOpts:W}}function ej(T,A){let Q=A.Point;return Object.assign({},A,{ExtendedPoint:Q,CURVE:T,nBitLength:Q.Fn.BITS,nByteLength:Q.Fn.BYTES})}function R9(T){let{CURVE:A,curveOpts:Q,hash:J,eddsaOpts:$}=tj(T),W=aj(A,Q),G=sj(W,J,$);return ej(T,G)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var TR=BigInt(0),$8=BigInt(1),D9=BigInt(2),$x=BigInt(3),AR=BigInt(5),QR=BigInt(8),mA=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),S2=(()=>({p:mA,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:QR,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")}))();function JR(T){let A=BigInt(10),Q=BigInt(20),J=BigInt(40),$=BigInt(80),W=mA,Y=T*T%W*T%W,Z=k1(Y,D9,W)*Y%W,C=k1(Z,$8,W)*T%W,K=k1(C,AR,W)*C%W,j=k1(K,A,W)*K%W,M=k1(j,Q,W)*j%W,z=k1(M,J,W)*M%W,N=k1(z,$,W)*z%W,E=k1(N,$,W)*z%W,L=k1(E,A,W)*K%W;return{pow_p_5_8:k1(L,D9,W)*T%W,b2:Y}}function $R(T){return T[0]&=248,T[31]&=127,T[31]|=64,T}var P$=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function C$(T,A){let Q=mA,J=I1(A*A*A,Q),$=I1(J*J*A,Q),W=JR(T*$).pow_p_5_8,G=I1(T*J*W,Q),Y=I1(A*G*G,Q),Z=G,C=I1(G*P$,Q),K=Y===T,j=Y===I1(-T,Q),M=Y===I1(-T*P$,Q);if(K)G=Z;if(j||M)G=C;if(Q8(G,Q))G=I1(-G,Q);return{isValid:K||j,value:G}}var O8=(()=>UT(S2.p,{isLE:!0}))(),WR=(()=>UT(S2.n,{isLE:!0}))(),GR=(()=>({...S2,Fp:O8,hash:sZ,adjustScalarBytes:$R,uvRatio:C$}))(),t0=(()=>R9(GR))();var q$=P$,UR=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),YR=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),ZR=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),XR=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),M9=(T)=>C$($8,T),PR=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),K$=(T)=>t0.Point.Fp.create(A8(T)&PR);function k9(T){let{d:A}=S2,Q=mA,J=(O)=>O8.create(O),$=J(q$*T*T),W=J(($+$8)*ZR),G=BigInt(-1),Y=J((G-A*$)*J($+A)),{isValid:Z,value:C}=C$(W,Y),K=J(C*T);if(!Q8(K,Q))K=J(-K);if(!Z)C=K;if(!Z)G=$;let j=J(G*($-$8)*XR-Y),M=C*C,z=J((C+C)*Y),N=J(j*UR),E=J($8-M),L=J($8+M);return new t0.Point(J(z*L),J(E*N),J(N*L),J(z*E))}function qR(T){I0(T,64);let A=K$(T.subarray(0,32)),Q=k9(A),J=K$(T.subarray(32,64)),$=k9(J);return new d0(Q.add($))}class d0 extends X${constructor(T){super(T)}static fromAffine(T){return new d0(t0.Point.fromAffine(T))}assertSame(T){if(!(T instanceof d0))throw Error("RistrettoPoint expected")}init(T){return new d0(T)}static hashToCurve(T){return qR(q1("ristrettoHash",T,64))}static fromBytes(T){I0(T,32);let{a:A,d:Q}=S2,J=mA,$=(v)=>O8.create(v),W=K$(T);if(!eZ(O8.toBytes(W),T)||Q8(W,J))throw Error("invalid ristretto255 encoding 1");let G=$(W*W),Y=$($8+A*G),Z=$($8-A*G),C=$(Y*Y),K=$(Z*Z),j=$(A*Q*C-K),{isValid:M,value:z}=M9($(j*K)),N=$(z*Z),E=$(z*N*j),L=$((W+W)*N);if(Q8(L,J))L=$(-L);let O=$(Y*E),g=$(L*O);if(!M||Q8(g,J)||O===TR)throw Error("invalid ristretto255 encoding 2");return new d0(new t0.Point(L,O,$8,g))}static fromHex(T){return d0.fromBytes(q1("ristrettoHex",T,32))}static msm(T,A){return gA(d0,t0.Point.Fn,T,A)}toBytes(){let{X:T,Y:A,Z:Q,T:J}=this.ep,$=mA,W=(E)=>O8.create(E),G=W(W(Q+A)*W(Q-A)),Y=W(T*A),Z=W(Y*Y),{value:C}=M9(W(G*Z)),K=W(C*G),j=W(C*Y),M=W(K*j*J),z;if(Q8(J*M,$)){let E=W(A*q$),L=W(T*q$);T=E,A=L,z=W(K*YR)}else z=j;if(Q8(T*M,$))A=W(-A);let N=W((Q-A)*z);if(Q8(N,$))N=W(-N);return O8.toBytes(N)}equals(T){this.assertSame(T);let{X:A,Y:Q}=this.ep,{X:J,Y:$}=T.ep,W=(Z)=>O8.create(Z),G=W(A*$)===W(Q*J),Y=W(Q*$)===W(A*J);return G||Y}is0(){return this.equals(d0.ZERO)}}d0.BASE=(()=>new d0(t0.Point.BASE))();d0.ZERO=(()=>new d0(t0.Point.ZERO))();d0.Fp=(()=>O8)();d0.Fn=(()=>WR)();var zW=n0(V$(),1),TT=n0(R$(),1);var D$=i6;var nA=n0(g9(),1),S=n0(G8(),1),AP=n0(G8(),1);var tD=1,eD=2,TM=3,AM=4,QM=5,JM=6,$M=7,WM=8,GM=9,UM=10,YM=-32700,ZM=-32603,XM=-32602,PM=-32601,qM=-32600,KM=-32016,CM=-32015,HM=-32014,VM=-32013,jM=-32012,RM=-32011,DM=-32010,MM=-32009,kM=-32008,zM=-32007,FM=-32006,NM=-32005,IM=-32004,SM=-32003,LM=-32002,wM=-32001,EM=2800000,OM=2800001,BM=2800002,_M=2800003,xM=2800004,hM=2800005,gM=2800006,mM=2800007,vM=2800008,yM=2800009,bM=2800010,pM=2800011,lM=3230000,uM=32300001,dM=3230002,cM=3230003,fM=3230004,rM=3610000,nM=3610001,iM=3610002,oM=3610003,aM=3610004,sM=3610005,tM=3610006,eM=3610007,Tk=3611000,Ak=3704000,Qk=3704001,Jk=3704002,$k=3704003,Wk=3704004,Gk=4128000,Uk=4128001,Yk=4128002,Zk=4615000,Xk=4615001,Pk=4615002,qk=4615003,Kk=4615004,Ck=4615005,Hk=4615006,Vk=4615007,jk=4615008,Rk=4615009,Dk=4615010,Mk=4615011,kk=4615012,zk=4615013,Fk=4615014,Nk=4615015,Ik=4615016,Sk=4615017,Lk=4615018,wk=4615019,Ek=4615020,Ok=4615021,Bk=4615022,_k=4615023,xk=4615024,hk=4615025,gk=4615026,mk=4615027,vk=4615028,yk=4615029,bk=4615030,pk=4615031,lk=4615032,uk=4615033,dk=4615034,ck=4615035,fk=4615036,rk=4615037,nk=4615038,ik=4615039,ok=4615040,ak=4615041,sk=4615042,tk=4615043,ek=4615044,Tz=4615045,Az=4615046,Qz=4615047,Jz=4615048,$z=4615049,Wz=4615050,Gz=4615051,Uz=4615052,Yz=4615053,Zz=4615054,Xz=5508000,Pz=5508001,qz=5508002,Kz=5508003,Cz=5508004,Hz=5508005,Vz=5508006,jz=5508007,Rz=5508008,Dz=5508009,Mz=5508010,kz=5508011,zz=5663000,Fz=5663001,Nz=5663002,Iz=5663003,Sz=5663004,Lz=5663005,wz=5663006,Ez=5663007,Oz=5663008,Bz=5663009,_z=5663010,xz=5663011,hz=5663012,gz=5663013,mz=5663014,vz=5663015,yz=5663016,bz=5663017,pz=5663018,lz=5663019,uz=5663020,dz=7050000,cz=7050001,fz=7050002,rz=7050003,nz=7050004,iz=7050005,oz=7050006,az=7050007,sz=7050008,tz=7050009,ez=7050010,TF=7050011,AF=7050012,QF=7050013,JF=7050014,$F=7050015,WF=7050016,GF=7050017,UF=7050018,YF=7050019,ZF=7050020,XF=7050021,PF=7050022,qF=7050023,KF=7050024,CF=7050025,HF=7050026,VF=7050027,jF=7050028,RF=7050029,DF=7050030,MF=7050031,kF=7050032,zF=7050033,FF=7050034,NF=7050035,IF=7050036,f$=8078000,r$=8078001,b9=8078002,p9=8078003,n$=8078004,i$=8078005,o$=8078006,SF=8078007,LF=8078008,wF=8078009,EF=8078010,a$=8078011,OF=8078012,l9=8078013,u9=8078014,BF=8078015,_F=8078016,xF=8078017,hF=8078018,gF=8078019,d9=8078020,c9=8078021,mF=8078022,vF=8100000,yF=8100001,bF=8100002,pF=8100003,lF=8190000,uF=8190001,dF=8190002,cF=8190003,fF=8190004,rF=9900000,nF=9900001,iF=9900002,oF=9900003,aF=9900004;var sF={[lM]:"Account not found at address: $address",[fM]:"Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",[cM]:"Expected decoded account at address: $address",[dM]:"Failed to decode account data at address: $address",[uM]:"Accounts not found at addresses: $addresses",[yM]:"Unable to find a viable program address bump seed.",[BM]:"$putativeAddress is not a base58-encoded address.",[EM]:"Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",[_M]:"The `CryptoKey` must be an `Ed25519` public key.",[pM]:"$putativeOffCurveAddress is not a base58-encoded off-curve address.",[vM]:"Invalid seeds; point must fall off the Ed25519 curve.",[xM]:"Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",[gM]:"A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",[mM]:"The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",[hM]:"Expected program derived address bump to be in the range [0, 255], got: $bump.",[bM]:"Program address cannot end with PDA marker.",[OM]:"Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",[AM]:"Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",[tD]:"The network has progressed past the last block for which this transaction could have been committed.",[f$]:"Codec [$codecDescription] cannot decode empty byte arrays.",[mF]:"Enum codec cannot use lexical values [$stringValues] as discriminators. Either remove all lexical values or set `useValuesAsDiscriminators` to `false`.",[d9]:"Sentinel [$hexSentinel] must not be present in encoded bytes [$hexEncodedBytes].",[i$]:"Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",[o$]:"Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",[n$]:"Encoder and decoder must either both be fixed-size or variable-size.",[LF]:"Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",[b9]:"Expected a fixed-size codec, got a variable-size one.",[l9]:"Codec [$codecDescription] expected a positive byte length, got $bytesLength.",[p9]:"Expected a variable-size codec, got a fixed-size one.",[gF]:"Codec [$codecDescription] expected zero-value [$hexZeroValue] to have the same size as the provided fixed-size item [$expectedSize bytes].",[r$]:"Codec [$codecDescription] expected $expected bytes, got $bytesLength.",[hF]:"Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",[wF]:"Invalid discriminated union variant. Expected one of [$variants], got $value.",[EF]:"Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",[BF]:"Invalid literal union variant. Expected one of [$variants], got $value.",[SF]:"Expected [$codecDescription] to have $expected items, got $actual.",[OF]:"Invalid value $value for base $base with alphabet $alphabet.",[_F]:"Literal union discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",[a$]:"Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",[u9]:"Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",[c9]:"Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",[xF]:"Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",[Tk]:"No random values implementation could be found.",[Rk]:"instruction requires an uninitialized account",[_k]:"instruction tries to borrow reference for an account which is already borrowed",[xk]:"instruction left account with an outstanding borrowed reference",[Ok]:"program other than the account's owner changed the size of the account data",[Ck]:"account data too small for instruction",[Bk]:"instruction expected an executable account",[Az]:"An account does not have enough lamports to be rent-exempt",[Jz]:"Program arithmetic overflowed",[Tz]:"Failed to serialize or deserialize account data: $encodedData",[Zz]:"Builtin programs must consume compute units",[lk]:"Cross-program invocation call depth too deep",[nk]:"Computational budget exceeded",[gk]:"custom program error: #$code",[Sk]:"instruction contains duplicate accounts",[hk]:"instruction modifications of multiply-passed account differ",[bk]:"executable accounts must be rent exempt",[vk]:"instruction changed executable accounts data",[yk]:"instruction changed the balance of an executable account",[Lk]:"instruction changed executable bit of an account",[Fk]:"instruction modified data of an account it does not own",[zk]:"instruction spent from the balance of an account it does not own",[Xk]:"generic instruction error",[Wz]:"Provided owner is not allowed",[tk]:"Account is immutable",[ek]:"Incorrect authority provided",[Vk]:"incorrect program id for instruction",[Hk]:"insufficient funds for instruction",[Kk]:"invalid account data for instruction",[Qz]:"Invalid account owner",[Pk]:"invalid program argument",[mk]:"program returned invalid error code",[qk]:"invalid instruction data",[rk]:"Failed to reallocate account data",[fk]:"Provided seeds do not result in a valid address",[Gz]:"Accounts data allocations exceeded the maximum allowed per transaction",[Uz]:"Max accounts exceeded",[Yz]:"Max instruction trace length exceeded",[ck]:"Length of the seed is too long for address generation",[uk]:"An account required by the instruction is missing",[jk]:"missing required signature for instruction",[kk]:"instruction illegally modified the program id of an account",[Ek]:"insufficient account keys for instruction",[ik]:"Cross-program invocation with unauthorized signer or writable account",[ok]:"Failed to create program execution environment",[sk]:"Program failed to compile",[ak]:"Program failed to complete",[Ik]:"instruction modified data of a read-only account",[Nk]:"instruction changed the balance of a read-only account",[dk]:"Cross-program invocation reentrancy not allowed for this instruction",[wk]:"instruction modified rent epoch of an account",[Mk]:"sum of account balances before and after instruction do not match",[Dk]:"instruction requires an initialized account",[Zk]:"",[pk]:"Unsupported program id",[$z]:"Unsupported sysvar",[Gk]:"The instruction does not have any accounts.",[Uk]:"The instruction does not have any data.",[Yk]:"Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",[QM]:"Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",[eD]:"The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",[iF]:"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",[aF]:"Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",[nF]:"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",[rF]:"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",[oF]:"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",[ZM]:"JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",[XM]:"JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",[qM]:"JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",[PM]:"JSON-RPC error: The method does not exist / is not available ($__serverMessage)",[YM]:"JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",[jM]:"$__serverMessage",[wM]:"$__serverMessage",[IM]:"$__serverMessage",[HM]:"$__serverMessage",[DM]:"$__serverMessage",[MM]:"$__serverMessage",[KM]:"Minimum context slot has not been reached",[NM]:"Node is unhealthy; behind by $numSlotsBehind slots",[kM]:"No snapshot",[LM]:"Transaction simulation failed",[zM]:"$__serverMessage",[RM]:"Transaction history is not available from this node",[FM]:"$__serverMessage",[VM]:"Transaction signature length mismatch",[SM]:"Transaction signature verification failure",[CM]:"$__serverMessage",[Ak]:"Key pair bytes must be of length 64, got $byteLength.",[Qk]:"Expected private key bytes with length 32. Actual length: $actualLength.",[Jk]:"Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",[Wk]:"The provided private key does not match the provided public key.",[$k]:"Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",[JM]:"Lamports value must be in the range [0, 2e64-1]",[$M]:"`$value` cannot be parsed as a `BigInt`",[UM]:"$message",[WM]:"`$value` cannot be parsed as a `Number`",[TM]:"No nonce account could be found at address `$nonceAccountAddress`",[lF]:"The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",[dF]:"WebSocket was closed before payload could be added to the send buffer",[cF]:"WebSocket connection closed",[fF]:"WebSocket failed to connect",[uF]:"Failed to obtain a subscription id from the server",[pF]:"Could not find an API plan for RPC method: `$method`",[vF]:"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`.",[bF]:"HTTP error ($statusCode): $message",[yF]:"HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",[Xz]:"Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",[Pz]:"The provided value does not implement the `KeyPairSigner` interface",[Kz]:"The provided value does not implement the `MessageModifyingSigner` interface",[Cz]:"The provided value does not implement the `MessagePartialSigner` interface",[qz]:"The provided value does not implement any of the `MessageSigner` interfaces",[Vz]:"The provided value does not implement the `TransactionModifyingSigner` interface",[jz]:"The provided value does not implement the `TransactionPartialSigner` interface",[Rz]:"The provided value does not implement the `TransactionSendingSigner` interface",[Hz]:"The provided value does not implement any of the `TransactionSigner` interfaces",[Dz]:"More than one `TransactionSendingSigner` was identified.",[Mz]:"No `TransactionSendingSigner` was identified. Please provide a valid `TransactionWithSingleSendingSigner` transaction.",[kz]:"Wallet account signers do not support signing multiple messages/transactions in a single operation",[eM]:"Cannot export a non-extractable key.",[nM]:"No digest implementation could be found.",[rM]:"Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",[iM]:`This runtime does not support the generation of Ed25519 key pairs.
10
+ For a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20.`,[l4]:"No signature verification implementation could be found.",[p4]:"No key generation implementation could be found.",[u4]:"No signing implementation could be found.",[eG]:"No key export implementation could be found.",[fG]:"Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",[wH]:"Transaction processing left an account with an outstanding borrowed reference",[qH]:"Account in use",[XH]:"Account loaded twice",[HH]:"Attempt to debit an account but found no record of a prior credit.",[mH]:"Transaction loads an address table account that doesn't exist",[RH]:"This transaction has already been processed",[FH]:"Blockhash not found",[DH]:"Loader call chain is too deep",[LH]:"Transactions are currently disabled due to cluster maintenance",[DJ]:"Transaction contains a duplicate instruction ($index) that is not allowed",[kH]:"Insufficient funds for fee",[zJ]:"Transaction results in an account ($accountIndex) with insufficient funds for rent",[jH]:"This account may not be used to pay transaction fees",[SH]:"Transaction contains an invalid account reference",[vH]:"Transaction loads an address table account with invalid data",[yH]:"Transaction address table lookup uses an invalid index",[gH]:"Transaction loads an address table account with an invalid owner",[dH]:"LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",[IH]:"This program may not be used for executing instructions",[bH]:"Transaction leaves an account with a lower balance than rent-exempt minimum",[OH]:"Transaction loads a writable account that cannot be written",[uH]:"Transaction exceeded max loaded accounts data size cap",[zH]:"Transaction requires a fee but has no signature present",[KH]:"Attempt to load a program that does not exist",[SJ]:"Execution of the program referenced by account at index $accountIndex is temporarily restricted.",[rH]:"ResanitizationNeeded",[NH]:"Transaction failed to sanitize accounts offsets correctly",[MH]:"Transaction did not pass signature verification",[hH]:"Transaction locked too many accounts",[fH]:"Sum of account balances before and after transaction do not match",[FJ]:"The transaction failed with the error `$errorName`",[BH]:"Transaction version is unsupported",[xH]:"Transaction would exceed account data limit within the block",[pH]:"Transaction would exceed total account data limit",[_H]:"Transaction would exceed max account limit within the block",[EH]:"Transaction would exceed max Block Cost Limit",[lH]:"Transaction would exceed max Vote Cost Limit",[a4]:"Attempted to sign a transaction with an address that is not a signer for it",[JH]:"Transaction is missing an address at index: $index.",[s4]:"Transaction has no expected signers therefore it cannot be encoded",[jJ]:"Transaction size $transactionSize exceeds limit of $transactionSizeLimit bytes",[f4]:"Transaction does not have a blockhash lifetime",[i4]:"Transaction is not a durable nonce transaction",[qJ]:"Contents of these address lookup tables unknown: $lookupTableAddresses",[XJ]:"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",[KJ]:"No fee payer set in CompiledTransaction",[HJ]:"Could not find program address at index $index",[YH]:"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",[ZH]:"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",[UH]:"Transaction is missing a fee payer.",[n4]:"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",[VH]:"Transaction first instruction is not advance nonce account instruction.",[$H]:"Transaction with no instructions cannot be durable nonce transaction.",[r4]:"This transaction includes an address (`$programAddress`) which is both invoked and set as the fee payer. Program addresses may not pay fees",[W6]:"This transaction includes an address (`$programAddress`) which is both invoked and marked writable. Program addresses may not be writable",[kJ]:"The transaction message expected the transaction to have $numRequiredSignatures signatures, got $signaturesLength.",[o4]:"Transaction is missing signatures for addresses: $addresses.",[c4]:"Transaction version must be in the range [0, 127]. `$actualVersion` given",[G2]:"This version of Kit does not support decoding transactions with version $unsupportedVersion. The current max supported version is 0.",[RJ]:"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.",[t4]:"Transaction message bytes are malformed: $messageBytes"},i0="i",w0="t";function NK(T,A={}){let C=IK[T];if(C.length===0)return"";let P;function Q(G){if(P[w0]===2){let U=C.slice(P[i0]+1,G);W.push(U in A?`${A[U]}`:`$${U}`)}else if(P[w0]===1)W.push(C.slice(P[i0],G))}let W=[];return C.split("").forEach((G,U)=>{if(U===0){P={[i0]:0,[w0]:C[0]==="\\"?0:C[0]==="$"?2:1};return}let $;switch(P[w0]){case 0:$={[i0]:U,[w0]:1};break;case 1:if(G==="\\")$={[i0]:U,[w0]:0};else if(G==="$")$={[i0]:U,[w0]:2};break;case 2:if(G==="\\")$={[i0]:U,[w0]:0};else if(G==="$")$={[i0]:U,[w0]:2};else if(!G.match(/\w/))$={[i0]:U,[w0]:1};break}if($){if(P!==$)Q(U);P=$}}),Q(),W.join("")}function LK(T,A={}){return NK(T,A)}function JP(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 C,P;if(A)Object.entries(Object.getOwnPropertyDescriptors(A)).forEach(([W,G])=>{if(W==="cause")P={cause:G.value};else{if(C===void 0)C={__code:T};Object.defineProperty(C,W,G)}});let Q=LK(T,C);super(Q,P);this.context=Object.freeze(C===void 0?{__code:T}:C),this.name="SolanaError"}};function wK(...T){if("captureStackTrace"in Error&&typeof Error.captureStackTrace==="function")Error.captureStackTrace(...T)}function MJ({errorCodeBaseOffset:T,getErrorContext:A,orderedErrorNames:C,rpcEnumError:P},Q){let W,G;if(typeof P==="string")W=P;else W=Object.keys(P)[0],G=P[W];let U=C.indexOf(W),$=T+U,X=A($,W,G),q=new e($,X);return wK(q,Q),q}var EK=["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 IJ(T,A){let C=Number(T);return MJ({errorCodeBaseOffset:4615001,getErrorContext(P,Q,W){if(P===AJ)return{errorName:Q,index:C,...W!==void 0?{instructionErrorContext:W}:null};else if(P===CJ)return{code:Number(W),index:C};return{index:C}},orderedErrorNames:EK,rpcEnumError:A},IJ)}var BK=["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 k6(T){if(typeof T==="object"&&"InstructionError"in T)return IJ(...T.InstructionError);return MJ({errorCodeBaseOffset:7050001,getErrorContext(A,C,P){if(A===FJ)return{errorName:C,...P!==void 0?{transactionErrorContext:P}:null};else if(A===DJ)return{index:Number(P)};else if(A===zJ||A===SJ)return{accountIndex:Number(P.account_index)}},orderedErrorNames:BK,rpcEnumError:T},k6)}function OK(T,A){return"fixedSize"in A?A.fixedSize:A.getSizeFromValue(T)}function NJ(T){return Object.freeze({...T,encode:(A)=>{let C=new Uint8Array(OK(A,T));return T.write(A,C,0),C}})}var LJ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",wJ=()=>{return NJ({getSizeFromValue:(T)=>{try{return atob(T).length}catch{throw new e(KA,{alphabet:LJ,base:64,value:T})}},write(T,A,C){try{let P=atob(T).split("").map((Q)=>Q.charCodeAt(0));return A.set(P,C),P.length+C}catch{throw new e(KA,{alphabet:LJ,base:64,value:T})}}})};var{TextDecoder:k3,TextEncoder:j3}=globalThis;function kA(T,A){try{if("exists"in T&&!T.exists)return T;return Object.freeze({...T,data:A.decode(T.data)})}catch{throw new e(g4,{address:T.address})}}function _K(T,A){if(!A)return Object.freeze({address:T,exists:!1});let C=wJ().encode(A.data[0]);return Object.freeze({...xK(A),address:T,data:C,exists:!0})}function xK(T){return Object.freeze({executable:T.executable,lamports:T.lamports,programAddress:T.owner,space:T.space})}async function jA(T,A,C={}){let{abortSignal:P,...Q}=C,W=await T.getAccountInfo(A,{...Q,encoding:"base64"}).send({abortSignal:P});return _K(A,W.value)}function RA(T){if(!T.exists)throw new e(m4,{address:T.address})}function hK(T,A){if(T.length>=A)return T;let C=new Uint8Array(A).fill(0);return C.set(T),C}var mK=(T,A)=>hK(T.length<=A?T:T.slice(0,A),A);function gK(T,A){return"fixedSize"in A?A.fixedSize:A.getSizeFromValue(T)}function j6(T){return Object.freeze({...T,encode:(A)=>{let C=new Uint8Array(gK(A,T));return T.write(A,C,0),C}})}function UP(T){return Object.freeze({...T,decode:(A,C=0)=>T.read(A,C)[0]})}function FA(T){return"fixedSize"in T&&typeof T.fixedSize==="number"}function vK(T){return!FA(T)}function $P(T,A){if(FA(T)!==FA(A))throw new e(J6);if(FA(T)&&FA(A)&&T.fixedSize!==A.fixedSize)throw new e(U6,{decoderFixedSize:A.fixedSize,encoderFixedSize:T.fixedSize});if(!FA(T)&&!FA(A)&&T.maxSize!==A.maxSize)throw new e($6,{decoderMaxSize:A.maxSize,encoderMaxSize:T.maxSize});return{...A,...T,decode:A.decode,encode:T.encode,read:A.read,write:T.write}}function yK(T,A,C,P=0){let Q=C.length-P;if(Q<A)throw new e(J2,{bytesLength:Q,codecDescription:T,expected:A})}function EJ(T,A){return j6({fixedSize:A,write:(C,P,Q)=>{let W=T.encode(C),G=W.length>A?W.slice(0,A):W;return P.set(G,Q),Q+A}})}function BJ(T,A){return UP({fixedSize:A,read:(C,P)=>{if(yK("fixCodecSize",A,C,P),P>0||C.length>A)C=C.slice(P,P+A);if(FA(T))C=mK(C,T.fixedSize);let[Q]=T.read(C,0);return[Q,P+A]}})}function OJ(T,A){return j6({...vK(T)?{...T,getSizeFromValue:(C)=>T.getSizeFromValue(A(C))}:T,write:(C,P,Q)=>T.write(A(C),P,Q)})}function bK(T,A,C=A){if(!A.match(new RegExp(`^[${T}]*$`)))throw new e(KA,{alphabet:T,base:T.length,value:C})}var lK=(T)=>{return j6({getSizeFromValue:(A)=>{let[C,P]=_J(A,T[0]);if(!P)return A.length;let Q=xJ(P,T);return C.length+Math.ceil(Q.toString(16).length/2)},write(A,C,P){if(bK(T,A),A==="")return P;let[Q,W]=_J(A,T[0]);if(!W)return C.set(new Uint8Array(Q.length).fill(0),P),P+Q.length;let G=xJ(W,T),U=[];while(G>0n)U.unshift(Number(G%256n)),G/=256n;let $=[...Array(Q.length).fill(0),...U];return C.set($,P),P+$.length}})},pK=(T)=>{return UP({read(A,C){let P=C===0?A:A.slice(C);if(P.length===0)return["",0];let Q=P.findIndex(($)=>$!==0);Q=Q===-1?P.length:Q;let W=T[0].repeat(Q);if(Q===P.length)return[W,A.length];let G=P.slice(Q).reduce(($,X)=>$*256n+BigInt(X),0n),U=uK(G,T);return[W+U,A.length]}})};function _J(T,A){let[C,P]=T.split(new RegExp(`((?!${A}).*)`));return[C,P]}function xJ(T,A){let C=BigInt(A.length),P=0n;for(let Q of T)P*=C,P+=BigInt(A.indexOf(Q));return P}function uK(T,A){let C=BigInt(A.length),P=[];while(T>0n)P.unshift(A[Number(T%C)]),T/=C;return P.join("")}var hJ="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",mJ=()=>lK(hJ),gJ=()=>pK(hJ);var{TextDecoder:w3,TextEncoder:E3}=globalThis;function R6(){if(!globalThis.isSecureContext)throw new e(v4)}var fA;async function dK(T){if(fA===void 0)fA=new Promise((A)=>{T.generateKey("Ed25519",!1,["sign","verify"]).then(()=>{A(fA=!0)}).catch(()=>{A(fA=!1)})});if(typeof fA==="boolean")return fA;else return await fA}function vJ(){if(R6(),typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.digest!=="function")throw new e(y4)}async function yJ(){if(R6(),typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.generateKey!=="function")throw new e(p4);if(!await dK(globalThis.crypto.subtle))throw new e(b4)}function VP(){if(R6(),typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.exportKey!=="function")throw new e(l4)}function bJ(){if(R6(),typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.sign!=="function")throw new e(u4)}var YP,ZP;function qP(){if(!YP)YP=mJ();return YP}function rK(){if(!ZP)ZP=gJ();return ZP}function F6(T){if(T.length<32||T.length>44)return!1;let A=qP();try{return A.encode(T).byteLength===32}catch{return!1}}function XP(T){if(T.length<32||T.length>44)throw new e(P6,{actualLength:T.length});let P=qP().encode(T).byteLength;if(P!==32)throw new e(C6,{actualLength:P})}function _(T){return XP(T),T}function O1(){return OJ(EJ(qP(),32),(T)=>_(T))}function z1(){return BJ(rK(),32)}function fK(){return $P(O1(),z1())}function D6(){return new Intl.Collator("en",{caseFirst:"lower",ignorePunctuation:!1,localeMatcher:"best fit",numeric:!1,sensitivity:"variant",usage:"sort"}).compare}var iK=37095705934669439343138083508754565189542113879843219016388785533085940283555n,pT=57896044618658097711785492504343953926634992332820282019728792003956564819949n,lJ=19681161376707505956807079304988542015446066515923890162744021073123829784752n;function Z0(T){let A=T%pT;return A>=0n?A:pT+A}function E0(T,A){let C=T;while(A-- >0n)C*=C,C%=pT;return C}function cK(T){let C=T*T%pT*T%pT,P=E0(C,2n)*C%pT,Q=E0(P,1n)*T%pT,W=E0(Q,5n)*Q%pT,G=E0(W,10n)*W%pT,U=E0(G,20n)*G%pT,$=E0(U,40n)*U%pT,X=E0($,80n)*$%pT,q=E0(X,80n)*$%pT,K=E0(q,10n)*W%pT;return E0(K,2n)*T%pT}function oK(T,A){let C=Z0(A*A*A),P=Z0(C*C*A),Q=cK(T*P),W=Z0(T*C*Q),G=Z0(A*W*W),U=W,$=Z0(W*lJ),X=G===T,q=G===Z0(-T),K=G===Z0(-T*lJ);if(X)W=U;if(q||K)W=$;if((Z0(W)&1n)===1n)W=Z0(-W);if(!X&&!q)return null;return W}function nK(T,A){let C=Z0(T*T),P=Z0(C-1n),Q=Z0(iK*C+1n),W=oK(P,Q);if(W===null)return!1;let G=(A&128)!==0;if(W===0n&&G)return!1;return!0}function aK(T){let A=T.toString(16);if(A.length===1)return`0${A}`;else return A}function sK(T){let C=`0x${T.reduce((P,Q,W)=>`${aK(W===31?Q&-129:Q)}${P}`,"")}`;return BigInt(C)}function tK(T){if(T.byteLength!==32)return!1;let A=sK(T);return nK(A,T[31])}var pJ=32,uJ=16,eK=[80,114,111,103,114,97,109,68,101,114,105,118,101,100,65,100,100,114,101,115,115];async function Tk({programAddress:T,seeds:A}){if(vJ(),A.length>uJ)throw new e(_4,{actual:A.length,maxSeeds:uJ});let C,P=A.reduce(($,X,q)=>{let K=typeof X==="string"?(C||=new TextEncoder).encode(X):X;if(K.byteLength>pJ)throw new e(x4,{actual:K.byteLength,index:q,maxSeedLength:pJ});return $.push(...K),$},[]),Q=fK(),W=Q.encode(T),G=await crypto.subtle.digest("SHA-256",new Uint8Array([...P,...W,...eK])),U=new Uint8Array(G);if(tK(U))throw new e(Q6);return Q.decode(U)}async function H1({programAddress:T,seeds:A}){let C=255;while(C>0)try{return[await Tk({programAddress:T,seeds:[...A,new Uint8Array([C])]}),C]}catch(P){if(JP(P,Q6))C--;else throw P}throw new e(h4)}async function z6(T){if(VP(),T.type!=="public"||T.algorithm.name!=="Ed25519")throw new e(O4);let A=await crypto.subtle.exportKey("raw",T);return z1().decode(new Uint8Array(A))}function Ak(T,A){if(T.length>=A)return T;let C=new Uint8Array(A).fill(0);return C.set(T),C}var Ck=(T,A)=>Ak(T.length<=A?T:T.slice(0,A),A);function M8(T,A){return"fixedSize"in A?A.fixedSize:A.getSizeFromValue(T)}function q0(T){return Object.freeze({...T,encode:(A)=>{let C=new Uint8Array(M8(A,T));return T.write(A,C,0),C}})}function o0(T){return Object.freeze({...T,decode:(A,C=0)=>T.read(A,C)[0]})}function c0(T){return"fixedSize"in T&&typeof T.fixedSize==="number"}function Pk(T){return!c0(T)}function dJ(T,A,C=0){if(A.length-C<=0)throw new e(G6,{codecDescription:T})}function S6(T,A,C,P=0){let Q=C.length-P;if(Q<A)throw new e(J2,{bytesLength:Q,codecDescription:T,expected:A})}function M6(T,A){let C=(G,U,$)=>{let X=T.encode(G);return $=A.write(X.length,U,$),U.set(X,$),$+X.length};if(c0(A)&&c0(T))return q0({...T,fixedSize:A.fixedSize+T.fixedSize,write:C});let P=c0(A)?A.fixedSize:A.maxSize??null,Q=c0(T)?T.fixedSize:T.maxSize??null,W=P!==null&&Q!==null?P+Q:null;return q0({...T,...W!==null?{maxSize:W}:{},getSizeFromValue:(G)=>{let U=M8(G,T);return M8(U,A)+U},write:C})}function rJ(T,A,C){let P=T.byteOffset+(A??0),Q=C??T.byteLength,W;if(typeof SharedArrayBuffer>"u")W=T.buffer;else if(T.buffer instanceof SharedArrayBuffer)W=new ArrayBuffer(T.length),new Uint8Array(W).set(new Uint8Array(T));else W=T.buffer;return(P===0||P===-T.byteLength)&&Q===T.byteLength?W:W.slice(P,P+Q)}function jT(T,A){return q0({fixedSize:A,write:(C,P,Q)=>{let W=T.encode(C),G=W.length>A?W.slice(0,A):W;return P.set(G,Q),Q+A}})}function xT(T,A){return o0({fixedSize:A,read:(C,P)=>{if(S6("fixCodecSize",A,C,P),P>0||C.length>A)C=C.slice(P,P+A);if(c0(T))C=Ck(C,T.fixedSize);let[Q]=T.read(C,0);return[Q,P+A]}})}function qT(T,A){return q0({...Pk(T)?{...T,getSizeFromValue:(C)=>T.getSizeFromValue(A(C))}:T,write:(C,P,Q)=>T.write(A(C),P,Q)})}function fJ(T,A){return o0({...T,read:(C,P)=>{let[Q,W]=T.read(C,P);return[A(Q,C,P),W]}})}function Qk(T,A,C,P){if(P<A||P>C)throw new e(rA,{codecDescription:T,max:C,min:A,value:P})}function iJ(T){return T?.endian===1?!1:!0}function HP(T){return q0({fixedSize:T.size,write(A,C,P){if(T.range)Qk(T.name,T.range[0],T.range[1],A);let Q=new ArrayBuffer(T.size);return T.set(new DataView(Q),A,iJ(T.config)),C.set(new Uint8Array(Q),P),P+T.size}})}function U2(T){return o0({fixedSize:T.size,read(A,C=0){dJ(T.name,A,C),S6(T.name,T.size,A,C);let P=new DataView(rJ(A,C,T.size));return[T.get(P,iJ(T.config)),C+T.size]}})}var cJ=(T={})=>U2({config:T,get:(A,C)=>{let P=C?8:0,Q=C?0:8,W=A.getBigUint64(P,C),G=A.getBigUint64(Q,C);return(W<<64n)+G},name:"u128",size:16});var oJ=(T={})=>U2({config:T,get:(A,C)=>A.getUint16(0,C),name:"u16",size:2});var $2=(T={})=>HP({config:T,name:"u32",range:[0,Number("0xffffffff")],set:(A,C,P)=>A.setUint32(0,Number(C),P),size:4}),KP=(T={})=>U2({config:T,get:(A,C)=>A.getUint32(0,C),name:"u32",size:4});var M1=(T={})=>HP({config:T,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(A,C,P)=>A.setBigUint64(0,BigInt(C),P),size:8}),w1=(T={})=>U2({config:T,get:(A,C)=>A.getBigUint64(0,C),name:"u64",size:8});var V2=()=>HP({name:"u8",range:[0,Number("0xff")],set:(T,A)=>T.setUint8(0,Number(A)),size:1}),DA=()=>U2({get:(T)=>T.getUint8(0),name:"u8",size:1});function Wk(T,A,C){if(A!==C)throw new e(dA,{actual:C,codecDescription:T,expected:A})}function I8(T){return T.reduce((A,C)=>A===null||C===null?null:A+C,0)}function I6(T){return c0(T)?T.fixedSize:null}function N6(T){return c0(T)?T.fixedSize:T.maxSize??null}function Y2(T,A={}){let C=A.size??KP(),P=I6(T),Q=nJ(C,P),W=nJ(C,N6(T))??void 0;return o0({...Q!==null?{fixedSize:Q}:{maxSize:W},read:(G,U)=>{let $=[];if(typeof C==="object"&&G.slice(U).length===0)return[$,U];if(C==="remainder"){while(U<G.length){let[K,F]=T.read(G,U);U=F,$.push(K)}return[$,U]}let[X,q]=typeof C==="number"?[C,U]:C.read(G,U);U=q;for(let K=0;K<X;K+=1){let[F,z]=T.read(G,U);U=z,$.push(F)}return[$,U]}})}function nJ(T,A){if(typeof T!=="number")return null;if(T===0)return 0;return A===null?null:A*T}function iA(T={}){return qT(T.size??V2(),(A)=>A?1:0)}function X0(T={}){return fJ(T.size??DA(),(A)=>Number(A)===1)}function ST(){return q0({getSizeFromValue:(T)=>T.length,write:(T,A,C)=>{return A.set(T,C),C+T.length}})}function uT(){return o0({read:(T,A)=>{let C=T.slice(A);return[C,A+C.length]}})}function L6(T,A){let C=I8(T.map(I6)),P=I8(T.map(N6))??void 0;return q0({...C===null?{getSizeFromValue:(Q)=>T.map((W,G)=>M8(Q[G],W)).reduce((W,G)=>W+G,0),maxSize:P}:{fixedSize:C},write:(Q,W,G)=>{return Wk(A?.description??"tuple",T.length,Q.length),T.forEach((U,$)=>{G=U.write(Q[$],W,G)}),G}})}function XT(T){let A=T.map(([,Q])=>Q),C=I8(A.map(I6)),P=I8(A.map(N6))??void 0;return q0({...C===null?{getSizeFromValue:(Q)=>T.map(([W,G])=>M8(Q[W],G)).reduce((W,G)=>W+G,0),maxSize:P}:{fixedSize:C},write:(Q,W,G)=>{return T.forEach(([U,$])=>{G=$.write(Q[U],W,G)}),G}})}function RT(T){let A=T.map(([,Q])=>Q),C=I8(A.map(I6)),P=I8(A.map(N6))??void 0;return o0({...C===null?{maxSize:P}:{fixedSize:C},read:(Q,W)=>{let G={};return T.forEach(([U,$])=>{let[X,q]=$.read(Q,W);W=q,G[U]=X}),[G,W]}})}var{TextDecoder:s3,TextEncoder:aJ}=globalThis,w6=()=>{let T;return q0({getSizeFromValue:(A)=>(T||=new aJ).encode(A).length,write:(A,C,P)=>{let Q=(T||=new aJ).encode(A);return C.set(Q,P),P+Q.length}})};var R1=((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})(R1||{}),Gk=2,Jk=1;function n0(T){return T>=2}function N8(T){return(T&Jk)!==0}function kP(T,A){return T|A}function E6(T){return T|Gk}function tJ(T){return F6(T)}function sJ(T){switch(T){case"finalized":return 2;case"confirmed":return 1;case"processed":return 0;default:throw new e(GP,{unexpectedValue:T})}}function B6(T,A){if(T===A)return 0;return sJ(T)<sJ(A)?-1:1}var CL=-9223372036854775808n;function zA(T,A){return"fixedSize"in A?A.fixedSize:A.getSizeFromValue(T)}function MT(T){return Object.freeze({...T,encode:(A)=>{let C=new Uint8Array(zA(A,T));return T.write(A,C,0),C}})}function B0(T){return"fixedSize"in T&&typeof T.fixedSize==="number"}function Uk(T){return!B0(T)}function eJ(T,A){let C=(G,U,$)=>{let X=T.encode(G);return $=A.write(X.length,U,$),U.set(X,$),$+X.length};if(B0(A)&&B0(T))return MT({...T,fixedSize:A.fixedSize+T.fixedSize,write:C});let P=B0(A)?A.fixedSize:A.maxSize??null,Q=B0(T)?T.fixedSize:T.maxSize??null,W=P!==null&&Q!==null?P+Q:null;return MT({...T,...W!==null?{maxSize:W}:{},getSizeFromValue:(G)=>{let U=zA(G,T);return zA(U,A)+U},write:C})}function jP(T,A){return MT({fixedSize:A,write:(C,P,Q)=>{let W=T.encode(C),G=W.length>A?W.slice(0,A):W;return P.set(G,Q),Q+A}})}function O6(T,A){return MT({...Uk(T)?{...T,getSizeFromValue:(C)=>T.getSizeFromValue(A(C))}:T,write:(C,P,Q)=>T.write(A(C),P,Q)})}function CU(T,A,C,P){if(P<A||P>C)throw new e(rA,{codecDescription:T,max:C,min:A,value:P})}function Vk(T){return T?.endian===1?!1:!0}function PU(T){return MT({fixedSize:T.size,write(A,C,P){if(T.range)CU(T.name,T.range[0],T.range[1],A);let Q=new ArrayBuffer(T.size);return T.set(new DataView(Q),A,Vk(T.config)),C.set(new Uint8Array(Q),P),P+T.size}})}var cA=()=>MT({getSizeFromValue:(T)=>{if(T<=127)return 1;if(T<=16383)return 2;return 3},maxSize:3,write:(T,A,C)=>{CU("shortU16",0,65535,T);let P=[0];for(let Q=0;;Q+=1){let W=Number(T)>>Q*7;if(W===0)break;let G=127&W;if(P[Q]=G,Q>0)P[Q-1]|=128}return A.set(P,C),C+P.length}});var QU=(T={})=>PU({config:T,name:"u32",range:[0,Number("0xffffffff")],set:(A,C,P)=>A.setUint32(0,Number(C),P),size:4});var L8=()=>PU({name:"u8",range:[0,Number("0xff")],set:(T,A)=>T.setUint8(0,Number(A)),size:1});function Xk(T,A,C){if(A!==C)throw new e(dA,{actual:C,codecDescription:T,expected:A})}function Hk(T){return T.reduce((A,C)=>A===null||C===null?null:Math.max(A,C),0)}function WU(T){return T.reduce((A,C)=>A===null||C===null?null:A+C,0)}function UU(T){return B0(T)?T.fixedSize:null}function RP(T){return B0(T)?T.fixedSize:T.maxSize??null}function w8(T,A={}){let C=A.size??QU(),P=GU(C,UU(T)),Q=GU(C,RP(T))??void 0;return MT({...P!==null?{fixedSize:P}:{getSizeFromValue:(W)=>{return(typeof C==="object"?zA(W.length,C):0)+[...W].reduce((U,$)=>U+zA($,T),0)},maxSize:Q},write:(W,G,U)=>{if(typeof C==="number")Xk(A.description??"array",C,W.length);if(typeof C==="object")U=C.write(W.length,G,U);return W.forEach(($)=>{U=T.write($,G,U)}),U}})}function GU(T,A){if(typeof T!=="number")return null;if(T===0)return 0;return A===null?null:A*T}function $U(){return MT({getSizeFromValue:(T)=>T.length,write:(T,A,C)=>{return A.set(T,C),C+T.length}})}function VU(T){return MT({fixedSize:T.length,write:(A,C,P)=>{return C.set(T,P),P+T.length}})}function YU(T,A){let C=Kk(T),P=(W,G,U)=>{let $=A(W);return JU(T,$),T[$].write(W,G,U)};if(C!==null)return MT({fixedSize:C,write:P});let Q=kk(T);return MT({...Q!==null?{maxSize:Q}:{},getSizeFromValue:(W)=>{let G=A(W);return JU(T,G),zA(W,T[G])},write:P})}function JU(T,A){if(typeof T[A]>"u")throw new e(S8,{maxRange:T.length-1,minRange:0,variant:A})}function Kk(T){if(T.length===0)return 0;if(!B0(T[0]))return null;let A=T[0].fixedSize;return T.every((P)=>B0(P)&&P.fixedSize===A)?A:null}function kk(T){return Hk(T.map((A)=>RP(A)))}function E8(T){let A=T.map(([,Q])=>Q),C=WU(A.map(UU)),P=WU(A.map(RP))??void 0;return MT({...C===null?{getSizeFromValue:(Q)=>T.map(([W,G])=>zA(Q[W],G)).reduce((W,G)=>W+G,0),maxSize:P}:{fixedSize:C},write:(Q,W,G)=>{return T.forEach(([U,$])=>{G=$.write(Q[U],W,G)}),G}})}function kU(T){return"lifetimeConstraint"in T&&typeof T.lifetimeConstraint.blockhash==="string"&&typeof T.lifetimeConstraint.lastValidBlockHeight==="bigint"&&tJ(T.lifetimeConstraint.blockhash)}function jU(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 jk(T,A,C=A){if(!A.match(new RegExp(`^[${T}]*$`)))throw new e(KA,{alphabet:T,base:T.length,value:C})}var Rk=(T)=>{return MT({getSizeFromValue:(A)=>{let[C,P]=ZU(A,T[0]);if(!P)return A.length;let Q=qU(P,T);return C.length+Math.ceil(Q.toString(16).length/2)},write(A,C,P){if(jk(T,A),A==="")return P;let[Q,W]=ZU(A,T[0]);if(!W)return C.set(new Uint8Array(Q.length).fill(0),P),P+Q.length;let G=qU(W,T),U=[];while(G>0n)U.unshift(Number(G%256n)),G/=256n;let $=[...Array(Q.length).fill(0),...U];return C.set($,P),P+$.length}})};function ZU(T,A){let[C,P]=T.split(new RegExp(`((?!${A}).*)`));return[C,P]}function qU(T,A){let C=BigInt(A.length),P=0n;for(let Q of T)P*=C,P+=BigInt(A.indexOf(Q));return P}var Fk="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",Dk=()=>Rk(Fk);var FP;function zk(){if(!FP){let T=w8(L8(),{size:cA()});FP=E8([["lookupTableAddress",O1()],["writableIndexes",T],["readonlyIndexes",T]])}return FP}var DP;function zP(){if(!DP)DP=L8();return DP}function Sk(){return E8([["numSignerAccounts",zP()],["numReadonlySignerAccounts",zP()],["numReadonlyNonSignerAccounts",zP()]])}var SP;function Mk(){if(!SP)SP=O6(E8([["programAddressIndex",L8()],["accountIndices",w8(L8(),{size:cA()})],["data",eJ($U(),cA())]]),(T)=>{if(T.accountIndices!==void 0&&T.data!==void 0)return T;return{...T,accountIndices:T.accountIndices??[],data:T.data??new Uint8Array(0)}});return SP}var Ik=0,Nk=128;function Lk(){return MT({getSizeFromValue:(T)=>T==="legacy"?0:1,maxSize:1,write:(T,A,C)=>{if(T==="legacy")return C;if(T<0||T>127)throw new e(c4,{actualVersion:T});if(T>Ik)throw new e(G2,{unsupportedVersion:T});return A.set([T|Nk],C),C+1}})}function XU(){return E8(RU())}function HU(){return O6(E8([...RU(),["addressTableLookups",wk()]]),(T)=>{if(T.version==="legacy")return T;return{...T,addressTableLookups:T.addressTableLookups??[]}})}function RU(){let T=YU([VU(new Uint8Array(32)),jP(Dk(),32)],(A)=>A===void 0?0:1);return[["version",Lk()],["header",Sk()],["staticAccounts",w8(O1(),{size:cA()})],["lifetimeToken",T],["instructions",w8(Mk(),{size:cA()})]]}function wk(){return w8(zk(),{size:cA()})}function FU(){return MT({getSizeFromValue:(T)=>{if(T.version==="legacy")return XU().getSizeFromValue(T);else return HU().getSizeFromValue(T)},write:(T,A,C)=>{if(T.version==="legacy")return XU().write(T,A,C);else return HU().write(T,A,C)}})}function KU(T,A,C){T[A]=C(T[A]??{role:R1.READONLY})}var HT=Symbol("AddressMapTypeProperty");function Ek(T,A){let C={[T]:{[HT]:0,role:R1.WRITABLE_SIGNER}},P=new Set;for(let Q of A){KU(C,Q.programAddress,(G)=>{if(P.add(Q.programAddress),HT in G){if(N8(G.role))switch(G[HT]){case 0:throw new e(r4,{programAddress:Q.programAddress});default:throw new e(W6,{programAddress:Q.programAddress})}if(G[HT]===2)return G}return{[HT]:2,role:R1.READONLY}});let W;if(!Q.accounts)continue;for(let G of Q.accounts)KU(C,G.address,(U)=>{let{address:$,...X}=G;if(HT in U)switch(U[HT]){case 0:return U;case 1:{let q=kP(U.role,X.role);if("lookupTableAddress"in X){if(U.lookupTableAddress!==X.lookupTableAddress&&(W||=D6())(X.lookupTableAddress,U.lookupTableAddress)<0)return{[HT]:1,...X,role:q}}else if(n0(X.role))return{[HT]:2,role:q};if(U.role!==q)return{...U,role:q};else return U}case 2:{let q=kP(U.role,X.role);if(P.has(G.address)){if(N8(X.role))throw new e(W6,{programAddress:G.address});if(U.role!==q)return{...U,role:q};else return U}else if("lookupTableAddress"in X&&!n0(U.role))return{...X,[HT]:1,role:q};else if(U.role!==q)return{...U,role:q};else return U}}if("lookupTableAddress"in X)return{...X,[HT]:1};else return{...X,[HT]:2}})}return C}function Bk(T){let A;return Object.entries(T).sort(([P,Q],[W,G])=>{if(Q[HT]!==G[HT]){if(Q[HT]===0)return-1;else if(G[HT]===0)return 1;else if(Q[HT]===2)return-1;else if(G[HT]===2)return 1}let U=n0(Q.role);if(U!==n0(G.role))return U?-1:1;let $=N8(Q.role);if($!==N8(G.role))return $?-1:1;if(A||=D6(),Q[HT]===1&&G[HT]===1&&Q.lookupTableAddress!==G.lookupTableAddress)return A(Q.lookupTableAddress,G.lookupTableAddress);else return A(P,W)}).map(([P,Q])=>({address:P,...Q}))}function Ok(T){let A={};for(let C of T){if(!("lookupTableAddress"in C))continue;let P=A[C.lookupTableAddress]||={readonlyIndexes:[],writableIndexes:[]};if(C.role===R1.WRITABLE)P.writableIndexes.push(C.addressIndex);else P.readonlyIndexes.push(C.addressIndex)}return Object.keys(A).sort(D6()).map((C)=>({lookupTableAddress:C,...A[C]}))}function _k(T){let A=0,C=0,P=0;for(let Q of T){if("lookupTableAddress"in Q)break;let W=N8(Q.role);if(n0(Q.role)){if(P++,!W)C++}else if(!W)A++}return{numReadonlyNonSignerAccounts:A,numReadonlySignerAccounts:C,numSignerAccounts:P}}function xk(T){let A={};for(let[C,P]of T.entries())A[P.address]=C;return A}function hk(T,A){let C=xk(A);return T.map(({accounts:P,data:Q,programAddress:W})=>{return{programAddressIndex:C[W],...P?{accountIndices:P.map(({address:G})=>C[G])}:null,...Q?{data:Q}:null}})}function mk(T){if("nonce"in T)return T.nonce;return T.blockhash}function gk(T){let A=T.findIndex((P)=>("lookupTableAddress"in P));return(A===-1?T:T.slice(0,A)).map(({address:P})=>P)}function DU(T){let A=Ek(T.feePayer.address,T.instructions),C=Bk(A),P=T.lifetimeConstraint;return{...T.version!=="legacy"?{addressTableLookups:Ok(C)}:null,...P?{lifetimeToken:mk(P)}:null,header:_k(C),instructions:hk(T.instructions,C),staticAccounts:gk(C),version:T.version}}function zU(T){return Object.freeze({instructions:Object.freeze([]),version:T.version})}var vk="SysvarRecentB1ockHashes11111111111111111111",yk="11111111111111111111111111111111";function bk(T){return T.programAddress===yk&&T.data!=null&&lk(T.data)&&T.accounts?.length===3&&T.accounts[0].address!=null&&T.accounts[0].role===R1.WRITABLE&&T.accounts[1].address===vk&&T.accounts[1].role===R1.READONLY&&T.accounts[2].address!=null&&n0(T.accounts[2].role)}function lk(T){return T.byteLength===4&&T[0]===4&&T[1]===0&&T[2]===0&&T[3]===0}function SU(T){return"lifetimeConstraint"in T&&typeof T.lifetimeConstraint.nonce==="string"&&T.instructions[0]!=null&&bk(T.instructions[0])}function MU(T,A){if("feePayer"in A&&T===A.feePayer?.address&&pk(A.feePayer))return A;let C={...A,feePayer:Object.freeze({address:T})};return Object.freeze(C),C}function pk(T){return!!T&&"address"in T&&typeof T.address==="string"&&Object.keys(T).length===1}function IU(T,A){return uk([T],A)}function uk(T,A){return Object.freeze({...A,instructions:Object.freeze([...A.instructions,...T])})}function NU(T,A){return T.length===A.length&&T.every((C,P)=>C===A[P])}function B8(T,A){return"fixedSize"in A?A.fixedSize:A.getSizeFromValue(T)}function sT(T){return Object.freeze({...T,encode:(A)=>{let C=new Uint8Array(B8(A,T));return T.write(A,C,0),C}})}function Z2(T){return Object.freeze({...T,decode:(A,C=0)=>T.read(A,C)[0]})}function O8(T){return"fixedSize"in T&&typeof T.fixedSize==="number"}function dk(T){return!O8(T)}function _6(T,A){return sT({fixedSize:A,write:(C,P,Q)=>{let W=T.encode(C),G=W.length>A?W.slice(0,A):W;return P.set(G,Q),Q+A}})}function x6(T,A){return sT({...dk(T)?{...T,getSizeFromValue:(C)=>T.getSizeFromValue(A(C))}:T,write:(C,P,Q)=>T.write(A(C),P,Q)})}function LU(T,A,C,P){if(P<A||P>C)throw new e(rA,{codecDescription:T,max:C,min:A,value:P})}function fk(T){return T?.endian===1?!1:!0}function ik(T){return sT({fixedSize:T.size,write(A,C,P){if(T.range)LU(T.name,T.range[0],T.range[1],A);let Q=new ArrayBuffer(T.size);return T.set(new DataView(Q),A,fk(T.config)),C.set(new Uint8Array(Q),P),P+T.size}})}var wU=()=>sT({getSizeFromValue:(T)=>{if(T<=127)return 1;if(T<=16383)return 2;return 3},maxSize:3,write:(T,A,C)=>{LU("shortU16",0,65535,T);let P=[0];for(let Q=0;;Q+=1){let W=Number(T)>>Q*7;if(W===0)break;let G=127&W;if(P[Q]=G,Q>0)P[Q-1]|=128}return A.set(P,C),C+P.length}});var EU=(T={})=>ik({config:T,name:"u32",range:[0,Number("0xffffffff")],set:(A,C,P)=>A.setUint32(0,Number(C),P),size:4});function ak(T,A,C){if(A!==C)throw new e(dA,{actual:C,codecDescription:T,expected:A})}function sk(T){return T.reduce((A,C)=>A===null||C===null?null:Math.max(A,C),0)}function BU(T){return T.reduce((A,C)=>A===null||C===null?null:A+C,0)}function xU(T){return O8(T)?T.fixedSize:null}function IP(T){return O8(T)?T.fixedSize:T.maxSize??null}function NP(T,A={}){let C=A.size??EU(),P=OU(C,xU(T)),Q=OU(C,IP(T))??void 0;return sT({...P!==null?{fixedSize:P}:{getSizeFromValue:(W)=>{return(typeof C==="object"?B8(W.length,C):0)+[...W].reduce((U,$)=>U+B8($,T),0)},maxSize:Q},write:(W,G,U)=>{if(typeof C==="number")ak(A.description??"array",C,W.length);if(typeof C==="object")U=C.write(W.length,G,U);return W.forEach(($)=>{U=T.write($,G,U)}),U}})}function OU(T,A){if(typeof T!=="number")return null;if(T===0)return 0;return A===null?null:A*T}function q2(){return sT({getSizeFromValue:(T)=>T.length,write:(T,A,C)=>{return A.set(T,C),C+T.length}})}function tk(T,A){let C=ek(T),P=(W,G,U)=>{let $=A(W);return _U(T,$),T[$].write(W,G,U)};if(C!==null)return sT({fixedSize:C,write:P});let Q=Tj(T);return sT({...Q!==null?{maxSize:Q}:{},getSizeFromValue:(W)=>{let G=A(W);return _U(T,G),B8(W,T[G])},write:P})}function _U(T,A){if(typeof T[A]>"u")throw new e(S8,{maxRange:T.length-1,minRange:0,variant:A})}function ek(T){if(T.length===0)return 0;if(!O8(T[0]))return null;let A=T[0].fixedSize;return T.every((P)=>O8(P)&&P.fixedSize===A)?A:null}function Tj(T){return sk(T.map((A)=>IP(A)))}function hU(T,A,C){return tk([A,C],(P)=>T(P)?0:1)}function mU(T){let A=T.map(([,Q])=>Q),C=BU(A.map(xU)),P=BU(A.map(IP))??void 0;return sT({...C===null?{getSizeFromValue:(Q)=>T.map(([W,G])=>B8(Q[W],G)).reduce((W,G)=>W+G,0),maxSize:P}:{fixedSize:C},write:(Q,W,G)=>{return T.forEach(([U,$])=>{G=$.write(Q[U],W,G)}),G}})}var Aj=(T)=>{return Z2({read(A,C){let P=C===0?A:A.slice(C);if(P.length===0)return["",0];let Q=P.findIndex(($)=>$!==0);Q=Q===-1?P.length:Q;let W=T[0].repeat(Q);if(Q===P.length)return[W,A.length];let G=P.slice(Q).reduce(($,X)=>$*256n+BigInt(X),0n),U=Cj(G,T);return[W+U,A.length]}})};function Cj(T,A){let C=BigInt(A.length),P=[];while(T>0n)P.unshift(A[Number(T%C)]),T/=C;return P.join("")}var Pj="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";var gU=()=>Aj(Pj);var vU=()=>{return Z2({read(T,A=0){let C=T.slice(A);return[btoa(String.fromCharCode(...C)),T.length]}})};var{TextDecoder:fL,TextEncoder:iL}=globalThis;function yU(T,A,C){let P=T.byteOffset+(A??0),Q=C??T.byteLength,W;if(typeof SharedArrayBuffer>"u")W=T.buffer;else if(T.buffer instanceof SharedArrayBuffer)W=new ArrayBuffer(T.length),new Uint8Array(W).set(new Uint8Array(T));else W=T.buffer;return(P===0||P===-T.byteLength)&&Q===T.byteLength?W:W.slice(P,P+Q)}var bU=Object.freeze({name:"Ed25519"});async function h6(T,A){bJ();let C=await crypto.subtle.sign(bU,T,yU(A));return new Uint8Array(C)}async function lU(){return await yJ(),await crypto.subtle.generateKey(bU,!1,["sign","verify"])}function uU(T){let A=Object.values(T);if(A.length===0)throw new e(s4);return A.map((C)=>{if(!C)return new Uint8Array(64).fill(0);return C})}function Qj(){return x6(NP(_6(q2(),64),{size:wU()}),uU)}function Wj(T){return x6(NP(_6(q2(),64),{description:"signatures",size:T}),uU)}var Gj=128,Jj=127;function Uj(T){let A=T[0];if((A&Gj)===0)return"signaturesFirst";let C=A&Jj;if(C===0)return"signaturesFirst";if(C===1)return"messageFirst";throw new e(G2,{unsupportedVersion:C})}function $j(){return hU((T)=>Uj(T.messageBytes)==="signaturesFirst",Vj(),Yj())}function Vj(){return mU([["signatures",Qj()],["messageBytes",q2()]])}function pU(T){if(T.length<2)throw new e(t4,{messageBytes:T});return T[1]}function Yj(){let T=q2();return sT({getSizeFromValue:(A)=>{let C=pU(A.messageBytes);return A.messageBytes.length+C*64},write:(A,C,P)=>{P=T.write(A.messageBytes,C,P);let Q=pU(A.messageBytes);return P=Wj(Q).write(A.signatures,C,P),P}})}function dU(T){let A=DU(T),C=FU().encode(A),P=A.staticAccounts.slice(0,A.header.numSignerAccounts),Q={};for(let G of P)Q[G]=null;let W;if(kU(T))W={blockhash:T.lifetimeConstraint.blockhash,lastValidBlockHeight:T.lifetimeConstraint.lastValidBlockHeight};else if(SU(T))W={nonce:T.lifetimeConstraint.nonce,nonceAccountAddress:T.instructions[0].accounts[0].address};return Object.freeze({...W?{lifetimeConstraint:W}:void 0,messageBytes:C,signatures:Object.freeze(Q)})}var LP;function X2(T){if(!LP)LP=gU();let A=Object.values(T.signatures)[0];if(!A)throw new e(n4);return LP.decode(A)}async function rU(T,A){let C,P;if(await Promise.all(T.map(async(Q)=>{let W=await z6(Q.publicKey),G=A.signatures[W];if(G===void 0){P||=new Set,P.add(W);return}if(P)return;let U=await h6(Q.privateKey,A.messageBytes);if(G!==null&&NU(U,G))return;C||={},C[W]=U})),P&&P.size>0){let Q=Object.keys(A.signatures);throw new e(a4,{expectedAddresses:Q,unexpectedAddresses:[...P]})}if(!C)return A;return Object.freeze({...A,signatures:Object.freeze({...A.signatures,...C})})}function fU(T){let A=[];if(Object.entries(T.signatures).forEach(([C,P])=>{if(!P)A.push(C)}),A.length>0)throw new e(o4,{addresses:A})}function m6(T){let A=$j().encode(T);return vU().decode(A)}var Zj=1280,qj=48,Hw=Zj-qj;function iU(T){return T!==null&&(typeof T==="object"||typeof T==="function")}function Xj(T){let A=new Set,C={deferreds:A,settled:!1};return Promise.resolve(T).then((P)=>{for(let{resolve:Q}of A)Q(P);A.clear(),C.settled=!0},(P)=>{for(let{reject:Q}of A)Q(P);A.clear(),C.settled=!0}),C}var wP=new WeakMap;async function EP(T){let A;return await new Promise((P,Q)=>{A={reject:Q,resolve:P};for(let W of T){if(!iU(W)){Promise.resolve(W).then(P,Q);continue}let G=wP.get(W);if(G===void 0)G=Xj(W),G.deferreds.add(A),wP.set(W,G);else if(G.settled)Promise.resolve(W).then(P,Q);else G.deferreds.add(A)}}).finally(()=>{for(let P of T)if(iU(P))wP.get(P).deferreds.delete(A)})}function g6(T){let A={};return T.forEach((C)=>{if(!A[C.address])A[C.address]=C;else if(A[C.address]!==C)throw new e(d4,{address:C.address})}),Object.values(A)}function v6(T){return"modifyAndSignTransactions"in T&&typeof T.modifyAndSignTransactions==="function"}function H2(T){return"signTransactions"in T&&typeof T.signTransactions==="function"}function cU(T){return"signAndSendTransactions"in T&&typeof T.signAndSendTransactions==="function"}function O0(T){return H2(T)||v6(T)||cU(T)}function Hj(T){return g6((T.accounts??[]).flatMap((A)=>("signer"in A)?A.signer:[]))}function Kj(T){return g6([...T.feePayer&&O0(T.feePayer)?[T.feePayer]:[],...T.instructions.flatMap(Hj)])}function kj(T,A){if(!A.accounts||A.accounts.length===0)return A;let C=new Map(g6(T).map((P)=>[P.address,P]));return Object.freeze({...A,accounts:A.accounts.map((P)=>{let Q=C.get(P.address);if(!n0(P.role)||"signer"in P||!Q)return P;return Object.freeze({...P,signer:Q})})})}function oU(T,A){let C=jj(A)?T.find((P)=>P.address===A.feePayer.address):void 0;if(!C&&A.instructions.length===0)return A;return Object.freeze({...A,...C?{feePayer:C}:null,instructions:A.instructions.map((P)=>kj(T,P))})}function jj(T){return!!T&&"feePayer"in T&&!!T.feePayer&&typeof T.feePayer.address==="string"&&!O0(T.feePayer)}function nU(T,A){Object.freeze(T);let C={...A,feePayer:T};return Object.freeze(C),C}async function Rj(T){let A=await z6(T.publicKey);return Object.freeze({address:A,keyPair:T,signMessages:(P)=>Promise.all(P.map(async(Q)=>Object.freeze({[A]:await h6(T.privateKey,Q.content)}))),signTransactions:(P)=>Promise.all(P.map(async(Q)=>{let W=await rU([T],Q);return Object.freeze({[A]:W.signatures[A]})}))})}async function aU(){return await Rj(await lU())}async function Fj(T,A){let{partialSigners:C,modifyingSigners:P}=Dj(g6(Kj(T).filter(O0)),{identifySendingSigner:!1});return await Mj(T,P,C,A)}async function BP(T,A){let C=await Fj(T,A);return fU(C),C}function Dj(T,A={}){let P=A.identifySendingSigner??!0?zj(T):null,Q=T.filter((U)=>U!==P&&(v6(U)||H2(U))),W=Sj(Q),G=Q.filter(H2).filter((U)=>!W.includes(U));return Object.freeze({modifyingSigners:W,partialSigners:G,sendingSigner:P})}function zj(T){let A=T.filter(cU);if(A.length===0)return null;let C=A.filter((P)=>!v6(P)&&!H2(P));if(C.length>0)return C[0];return A[0]}function Sj(T){let A=T.filter(v6);if(A.length===0)return[];let C=A.filter((P)=>!H2(P));if(C.length>0)return C;return[A[0]]}async function Mj(T,A=[],C=[],P){let Q=dU(T),W=await A.reduce(async(U,$)=>{P?.abortSignal?.throwIfAborted();let[X]=await $.modifyAndSignTransactions([await U],P);return Object.freeze(X)},Promise.resolve(Q));P?.abortSignal?.throwIfAborted();let G=await Promise.all(C.map(async(U)=>{let[$]=await U.signTransactions([W],P);return $}));return Object.freeze({...W,signatures:Object.freeze(G.reduce((U,$)=>{return{...U,...$}},W.signatures??{}))})}var Iw=globalThis.TextEncoder;var OP=globalThis.AbortController;function sU({rpc:T,rpcSubscriptions:A}){return async function({abortSignal:P,commitment:Q,lastValidBlockHeight:W}){P.throwIfAborted();let G=new OP,U=()=>{G.abort()};P.addEventListener("abort",U,{signal:G.signal});async function $(){let{absoluteSlot:X,blockHeight:q}=await T.getEpochInfo({commitment:Q}).send({abortSignal:G.signal});return{blockHeight:q,differenceBetweenSlotHeightAndBlockHeight:X-q}}try{let[X,{blockHeight:q,differenceBetweenSlotHeightAndBlockHeight:K}]=await Promise.all([A.slotNotifications().subscribe({abortSignal:G.signal}),$()]);P.throwIfAborted();let F=q;if(F<=W){let z=K;for await(let M of X){let{slot:E}=M;if(E-z>W){let{blockHeight:L,differenceBetweenSlotHeightAndBlockHeight:B}=await $();if(F=L,F>W)break;else z=B}}}throw P.throwIfAborted(),new e(B4,{currentBlockHeight:F,lastValidBlockHeight:W})}finally{G.abort()}}}function tU({rpc:T,rpcSubscriptions:A}){return async function({abortSignal:P,commitment:Q,signature:W}){let G=new OP;function U(){G.abort()}P.addEventListener("abort",U,{signal:G.signal});let $=await A.signatureNotifications(W,{commitment:Q}).subscribe({abortSignal:G.signal}),X=(async()=>{for await(let K of $)if(K.value.err)throw k6(K.value.err);else return})(),q=(async()=>{let{value:K}=await T.getSignatureStatuses([W]).send({abortSignal:G.signal}),F=K[0];if(F?.err)throw k6(F.err);else if(F?.confirmationStatus&&B6(F.confirmationStatus,Q)>=0)return;else await new Promise(()=>{})})();try{return await EP([X,q])}finally{G.abort()}}}async function Ij(T,A,C){let{abortSignal:P,commitment:Q,getRecentSignatureConfirmationPromise:W}=A;P?.throwIfAborted();let G=new OP;if(P){let U=()=>{G.abort()};P.addEventListener("abort",U,{signal:G.signal})}try{let U=C({...A,abortSignal:G.signal});return await EP([W({abortSignal:G.signal,commitment:Q,signature:T}),...U])}finally{G.abort()}}async function eU(T){await Ij(X2(T.transaction),T,function({abortSignal:C,commitment:P,getBlockHeightExceedencePromise:Q,transaction:W}){return[Q({abortSignal:C,commitment:P,lastValidBlockHeight:W.lifetimeConstraint.lastValidBlockHeight})]})}function Nj(T,A){if(!A?.preflightCommitment&&B6(T,"finalized")<0)return{...A,preflightCommitment:T};return A}async function Lj({abortSignal:T,commitment:A,rpc:C,transaction:P,...Q}){let W=m6(P);return await C.sendTransaction(W,{...Nj(A,Q),encoding:"base64"}).send({abortSignal:T})}async function wj({abortSignal:T,commitment:A,confirmRecentTransaction:C,rpc:P,transaction:Q,...W}){let G=await Lj({...W,abortSignal:T,commitment:A,rpc:P,transaction:Q});return await C({abortSignal:T,commitment:A,transaction:Q}),G}function T$({rpc:T,rpcSubscriptions:A}){let C=sU({rpc:T,rpcSubscriptions:A}),P=tU({rpc:T,rpcSubscriptions:A});async function Q(W){await eU({...W,getBlockHeightExceedencePromise:C,getRecentSignatureConfirmationPromise:P})}return async function(G,U){await wj({...U,confirmRecentTransaction:Q,rpc:T,transaction:G})}}var A$="confirmed";function Ej(T){A$=T}function I1(){return A$}var tT="6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P",KT="pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA",oA="11111111111111111111111111111111",FT="TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",K2="TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb",k2="ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";var _0="pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ";var _P=O1(),C$=k2;async function F1({owner:T,mint:A,tokenProgram:C=FT,associatedTokenProgram:P=C$}){return await H1({programAddress:_(P),seeds:[_P.encode(_(T)),_P.encode(_(C)),_P.encode(_(A))]})}async function P$(T){return await F1({...T,tokenProgram:T.tokenProgram??K2,associatedTokenProgram:T.associatedTokenProgram??C$})}var nA=new TextEncoder,y6=O1();async function b6(){let[T]=await H1({programAddress:_(tT),seeds:[nA.encode("global")]});return T}async function x0(T){let[A]=await H1({programAddress:_(tT),seeds:[nA.encode("bonding-curve"),y6.encode(_(T))]});return A}async function l6(T,A){let[C]=await F1({owner:_(T),mint:_(A),tokenProgram:_(FT)});return C}async function xP(T){let[A]=await H1({programAddress:_(tT),seeds:[nA.encode("creator-vault"),y6.encode(_(T))]});return A}async function Q$(){let[T]=await H1({programAddress:_(tT),seeds:[nA.encode("global_volume_accumulator")]});return T}async function W$(T){let[A]=await H1({programAddress:_(tT),seeds:[nA.encode("user_volume_accumulator"),y6.encode(_(T))]});return A}async function p6(){let[T]=await H1({programAddress:_(tT),seeds:[nA.encode("__event_authority")]});return T}async function j2(){let[T]=await H1({programAddress:_(_0),seeds:[nA.encode("fee_config"),y6.encode(_(tT))]});return T}var G1="6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P";function _1(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 J1(T,A){return(C)=>{if(!C.value){if(A==="omitted")return;return Object.freeze({address:T,role:R1.READONLY})}let P=C.isWritable?R1.WRITABLE:R1.READONLY;return Object.freeze({address:_1(C.value),role:G$(C.value)?E6(P):P,...G$(C.value)?{signer:C.value}:{}})}}function G$(T){return!!T&&typeof T==="object"&&"address"in T&&O0(T)}var FE=new Uint8Array([69,25,171,142,57,239,13,4]);var ME=new Uint8Array([8,217,96,231,144,104,192,5]);var wE=new Uint8Array([209,11,115,87,213,23,124,204]);function u6(){return RT([["lpFeeBps",w1()],["protocolFeeBps",w1()],["creatorFeeBps",w1()]])}function J$(){return RT([["marketCapLamportsThreshold",cJ()],["fees",u6()]])}function d6(){return L6([iA()])}var xj=new Uint8Array([102,6,61,18,1,218,235,234]);function hj(){return qT(XT([["discriminator",jT(ST(),8)],["amount",M1()],["maxSolCost",M1()],["trackVolume",d6()]]),(T)=>({...T,discriminator:xj}))}function $$(T,A){let C=A?.programAddress??G1,Q={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:!1},userVolumeAccumulator:{value:T.userVolumeAccumulator??null,isWritable:!0},feeConfig:{value:T.feeConfig??null,isWritable:!1},feeProgram:{value:T.feeProgram??null,isWritable:!1}},W={...T};if(!Q.tokenProgram.value)Q.tokenProgram.value="TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";if(!Q.systemProgram.value)Q.systemProgram.value="11111111111111111111111111111111";if(!Q.program.value)Q.program.value="6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P";if(!Q.feeProgram.value)Q.feeProgram.value="pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ";let G=J1(C,"programId");return Object.freeze({accounts:[G(Q.global),G(Q.feeRecipient),G(Q.mint),G(Q.bondingCurve),G(Q.associatedBondingCurve),G(Q.associatedUser),G(Q.user),G(Q.systemProgram),G(Q.tokenProgram),G(Q.creatorVault),G(Q.eventAuthority),G(Q.program),G(Q.globalVolumeAccumulator),G(Q.userVolumeAccumulator),G(Q.feeConfig),G(Q.feeProgram)],data:hj().encode(W),programAddress:C})}var nB=new Uint8Array([56,252,116,8,158,223,205,95]);var eB=new Uint8Array([37,58,35,126,190,53,228,197]);var PO=new Uint8Array([16,4,71,28,204,1,40,27]);var JO=new Uint8Array([249,69,164,218,150,103,84,138]);var YO=new Uint8Array([20,22,86,123,198,28,219,132]);var mj=new Uint8Array([24,30,200,40,5,28,7,119]);function gj(){return qT(XT([["discriminator",jT(ST(),8)],["name",M6(w6(),$2())],["symbol",M6(w6(),$2())],["uri",M6(w6(),$2())],["creator",O1()]]),(T)=>({...T,discriminator:mj}))}function V$(T,A){let C=A?.programAddress??G1,Q={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(!Q.mplTokenMetadata.value)Q.mplTokenMetadata.value="metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s";if(!Q.systemProgram.value)Q.systemProgram.value="11111111111111111111111111111111";if(!Q.tokenProgram.value)Q.tokenProgram.value="TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";if(!Q.associatedTokenProgram.value)Q.associatedTokenProgram.value="ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";if(!Q.rent.value)Q.rent.value="SysvarRent111111111111111111111111111111111";let G=J1(C,"programId");return Object.freeze({accounts:[G(Q.mint),G(Q.mintAuthority),G(Q.bondingCurve),G(Q.associatedBondingCurve),G(Q.global),G(Q.mplTokenMetadata),G(Q.metadata),G(Q.user),G(Q.systemProgram),G(Q.tokenProgram),G(Q.associatedTokenProgram),G(Q.rent),G(Q.eventAuthority),G(Q.program)],data:gj().encode(W),programAddress:C})}var zO=new Uint8Array([214,144,76,236,95,139,49,180]);var NO=new Uint8Array([165,114,103,0,121,206,247,81]);var BO=new Uint8Array([234,102,194,203,150,72,62,229]);var hO=new Uint8Array([117,225,127,202,134,95,68,35]);var yO=new Uint8Array([175,175,109,31,13,152,155,237]);var uO=new Uint8Array([94,6,202,115,255,96,232,183]);var iO=new Uint8Array([155,234,231,146,236,158,162,30]);var aO=new Uint8Array([87,124,52,191,52,38,214,232]);var vj=new Uint8Array([51,230,133,164,1,127,131,173]);function yj(){return qT(XT([["discriminator",jT(ST(),8)],["amount",M1()],["minSolOutput",M1()]]),(T)=>({...T,discriminator:vj}))}function Y$(T,A){let C=A?.programAddress??G1,Q={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(!Q.tokenProgram.value)Q.tokenProgram.value="TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";if(!Q.systemProgram.value)Q.systemProgram.value="11111111111111111111111111111111";if(!Q.program.value)Q.program.value="6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P";if(!Q.feeProgram.value)Q.feeProgram.value="pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ";let G=J1(C,"programId");return Object.freeze({accounts:[G(Q.global),G(Q.feeRecipient),G(Q.mint),G(Q.bondingCurve),G(Q.associatedBondingCurve),G(Q.associatedUser),G(Q.user),G(Q.systemProgram),G(Q.creatorVault),G(Q.tokenProgram),G(Q.eventAuthority),G(Q.program),G(Q.feeConfig),G(Q.feeProgram)],data:yj().encode(W),programAddress:C})}var Q_=new Uint8Array([254,148,255,112,207,142,170,165]);var U_=new Uint8Array([61,169,188,191,153,149,42,97]);var Z_=new Uint8Array([138,96,174,217,48,85,197,246]);var K_=new Uint8Array([27,234,178,52,147,2,187,141]);var F_=new Uint8Array([111,172,162,232,114,89,213,142]);var M_=new Uint8Array([86,31,192,87,163,87,79,238]);var w_=new Uint8Array([115,103,224,255,189,89,86,195]);var __=new Uint8Array([28,255,230,240,172,107,203,171]);var g_=new Uint8Array([1,9,111,208,100,31,255,163]);var l_=new Uint8Array([227,181,74,196,208,21,97,213]);var Rx=new Uint8Array([23,183,248,55,96,216,172,96]);function bj(){return RT([["discriminator",xT(uT(),8)],["virtualTokenReserves",w1()],["virtualSolReserves",w1()],["realTokenReserves",w1()],["realSolReserves",w1()],["tokenTotalSupply",w1()],["complete",X0()],["creator",z1()],["isMayhemMode",X0()],["isCashbackCoin",X0()]])}function lj(T){return kA(T,bj())}async function SA(T,A,C){let P=await pj(T,A,C);return RA(P),P}async function pj(T,A,C){let P=await jA(T,A,C);return lj(P)}async function R2(T){let{user:A,mint:C,tokenAmount:P,maxSolCostLamports:Q,feeRecipient:W,trackVolume:G=!0,bondingCurveCreator:U,rpc:$,commitment:X=I1()}=T,q=_(C),K=A.address,F=await x0(q),z=j2(),M=b6(),E=p6(),L=Q$(),B=W$(K),m=l6(F,q),v=F1({owner:K,mint:q,tokenProgram:_(FT)}),l=await q$({bondingCurve:F,providedCreator:U,rpc:$,commitment:X}),[f,u,[a],d,h,o,c,x]=await Promise.all([M,m,v,xP(l),E,L,B,z]);return $$({global:f,feeRecipient:_(W),mint:q,bondingCurve:F,associatedBondingCurve:u,associatedUser:a,user:A,systemProgram:_(oA),tokenProgram:_(FT),creatorVault:d,eventAuthority:h,program:_(tT),globalVolumeAccumulator:o,userVolumeAccumulator:c,feeConfig:x,feeProgram:_(_0),amount:P,maxSolCost:Q,trackVolume:[G]})}async function gP(T){let{user:A,mint:C,tokenAmount:P,minSolOutputLamports:Q,feeRecipient:W,bondingCurveCreator:G,rpc:U,commitment:$=I1()}=T,X=_(C),q=A.address,K=await x0(X),F=b6(),z=l6(K,X),M=F1({owner:q,mint:X,tokenProgram:_(FT)}),E=j2(),L=p6(),B=await q$({bondingCurve:K,providedCreator:G,rpc:U,commitment:$}),[m,v,[l],f,u,a]=await Promise.all([F,z,M,xP(B),L,E]);return Y$({global:m,feeRecipient:_(W),mint:X,bondingCurve:K,associatedBondingCurve:v,associatedUser:l,user:A,systemProgram:_(oA),creatorVault:f,tokenProgram:_(FT),eventAuthority:u,program:_(tT),feeConfig:a,feeProgram:_(_0),amount:P,minSolOutput:Q})}async function Z$(T){let{user:A,mint:C,mintAuthority:P,name:Q,symbol:W,uri:G,creator:U}=T,$=C.address,X=U?_(U):A.address,q=await b6(),K=await x0($),F=await l6(K,$),[z]=await H1({programAddress:_("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),seeds:[new TextEncoder().encode("metadata"),_("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),$]}),M=await p6();return V$({mint:C,mintAuthority:_(P),bondingCurve:K,associatedBondingCurve:F,global:q,mplTokenMetadata:_("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),metadata:z,user:A,systemProgram:_(oA),tokenProgram:_(FT),associatedTokenProgram:_("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"),rent:_("SysvarRent111111111111111111111111111111111"),eventAuthority:M,program:_(tT),name:Q,symbol:W,uri:G,creator:X})}async function q$(T){let{bondingCurve:A,providedCreator:C,rpc:P,commitment:Q}=T;if(C)return _(C);try{return(await SA(P,A,{commitment:Q})).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 h0="CebN5WGQ4jvEPvsVU4EoHEpgzq1VV7AbicfhtW4xC9iM";var Q0=50,a0=(T,A=50)=>T+T*BigInt(A)/10000n,aA=(T,A=50)=>T-T*BigInt(A)/10000n;function W0(T){if(T<0)throw Error("Slippage cannot be negative");if(T>1e4)throw Error("Slippage cannot exceed 100%")}function uj(T){if(T<0||T>100)throw Error("Percent must be between 0 and 100");return Math.round(T*100)}function dj(T){return T/100}var rj=1000000000n;function m0(T){if(!Number.isFinite(T)||T<0)throw Error("SOL value must be a non-negative finite number");return BigInt(Math.round(T*Number(rj)))}function sA(T,A){if(!Number.isInteger(A)||A<0)throw Error("Token decimals must be a non-negative integer");return BigInt(Math.round(T*10**A))}async function fj(T){let{user:A,mint:C,tokenAmount:P,estimatedSolCostSol:Q,slippageBps:W=Q0,feeRecipient:G=h0,bondingCurveCreator:U,trackVolume:$=!0,rpc:X,commitment:q=I1()}=T;if(W0(W),P<=0n)throw Error("Token amount must be positive");if(!Number.isFinite(Q)||Q<=0)throw Error("Estimated SOL cost must be a positive number");let K=m0(Q),F=a0(K,W);return await R2({user:A,mint:C,tokenAmount:P,maxSolCostLamports:F,feeRecipient:G,trackVolume:$,bondingCurveCreator:U,rpc:X,commitment:q})}async function vP(T){let{user:A,mint:C,tokenAmount:P,maxSolCostSol:Q,maxSolCostLamports:W,feeRecipient:G=h0,trackVolume:U=!0,bondingCurveCreator:$,rpc:X,commitment:q=I1()}=T;if(P<=0n)throw Error("Token amount must be positive");let K=null;if(W!==void 0){if(W<=0n)throw Error("Max SOL cost lamports must be positive");K=W}else if(Q!==void 0){if(!Number.isFinite(Q)||Q<=0)throw Error("Max SOL cost must be a positive number");K=m0(Q)}if(K===null)throw Error("Provide either maxSolCostLamports or maxSolCostSol when calling buySimple");return await R2({user:A,mint:C,tokenAmount:P,maxSolCostLamports:K,feeRecipient:G,trackVolume:U,bondingCurveCreator:$,rpc:X,commitment:q})}var X$=6;async function ij(T){let{user:A,mint:C,tokenAmount:P,estimatedSolOutSol:Q,slippageBps:W=Q0,feeRecipient:G=h0,bondingCurveCreator:U,rpc:$,commitment:X}=T;if(W0(W),!Number.isFinite(P)||P<=0)throw Error("Token amount must be a positive number");if(!Number.isFinite(Q)||Q<0)throw Error("Estimated SOL output cannot be negative");let q=sA(P,X$),K=m0(Q),F=aA(K,W);return await gP({user:A,mint:C,tokenAmount:q,minSolOutputLamports:F,feeRecipient:G,bondingCurveCreator:U,rpc:$,commitment:X})}async function yP(T){let{user:A,mint:C,tokenAmount:P,tokenAmountRaw:Q,minSolOutputSol:W,minSolOutputLamports:G,feeRecipient:U=h0,bondingCurveCreator:$,rpc:X,commitment:q}=T,K=null;if(Q!==void 0){if(Q<=0n)throw Error("Token amount lamports must be positive");K=Q}else if(P!==void 0){if(!Number.isFinite(P)||P<=0)throw Error("Token amount must be a positive number");K=sA(P,X$)}if(K===null)throw Error("Provide either tokenAmountRaw or tokenAmount when calling sellSimple");let F=null;if(G!==void 0){if(G<0n)throw Error("Min SOL output lamports cannot be negative");F=G}else if(W!==void 0){if(!Number.isFinite(W)||W<0)throw Error("Min SOL output cannot be negative");F=m0(W)}if(F===null)throw Error("Provide either minSolOutputLamports or minSolOutputSol when calling sellSimple");return await gP({user:A,mint:C,tokenAmount:K,minSolOutputLamports:F,feeRecipient:U,bondingCurveCreator:$,rpc:X,commitment:q})}x8();var T8=typeof globalThis==="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function e0(T){return T instanceof Uint8Array||ArrayBuffer.isView(T)&&T.constructor.name==="Uint8Array"}function IA(T){if(!Number.isSafeInteger(T)||T<0)throw Error("positive integer expected, got "+T)}function ET(T,...A){if(!e0(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 c6(T){if(typeof T!=="function"||typeof T.create!=="function")throw Error("Hash should be wrapped by utils.createHasher");IA(T.outputLen),IA(T.blockLen)}function TA(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 o6(T,A){ET(T);let C=A.outputLen;if(T.length<C)throw Error("digestInto() expects output buffer of length at least "+C)}function v$(T){return new Uint32Array(T.buffer,T.byteOffset,Math.floor(T.byteLength/4))}function K0(...T){for(let A=0;A<T.length;A++)T[A].fill(0)}function n6(T){return new DataView(T.buffer,T.byteOffset,T.byteLength)}function D0(T,A){return T<<32-A|T>>>A}var xR=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function hR(T){return T<<24&4278190080|T<<8&16711680|T>>>8&65280|T>>>24&255}function mR(T){for(let A=0;A<T.length;A++)T[A]=hR(T[A]);return T}var oP=xR?(T)=>T:mR,y$=(()=>typeof Uint8Array.from([]).toHex==="function"&&typeof Uint8Array.fromHex==="function")(),gR=Array.from({length:256},(T,A)=>A.toString(16).padStart(2,"0"));function k0(T){if(ET(T),y$)return T.toHex();let A="";for(let C=0;C<T.length;C++)A+=gR[T[C]];return A}var t0={_0:48,_9:57,A:65,F:70,a:97,f:102};function g$(T){if(T>=t0._0&&T<=t0._9)return T-t0._0;if(T>=t0.A&&T<=t0.F)return T-(t0.A-10);if(T>=t0.a&&T<=t0.f)return T-(t0.a-10);return}function A8(T){if(typeof T!=="string")throw Error("hex string expected, got "+typeof T);if(y$)return Uint8Array.fromHex(T);let A=T.length,C=A/2;if(A%2)throw Error("hex string expected, got unpadded hex of length "+A);let P=new Uint8Array(C);for(let Q=0,W=0;Q<C;Q++,W+=2){let G=g$(T.charCodeAt(W)),U=g$(T.charCodeAt(W+1));if(G===void 0||U===void 0){let $=T[W]+T[W+1];throw Error('hex string expected, got non-hex character "'+$+'" at index '+W)}P[Q]=G*16+U}return P}function nP(T){if(typeof T!=="string")throw Error("string expected");return new Uint8Array(new TextEncoder().encode(T))}function C8(T){if(typeof T==="string")T=nP(T);return ET(T),T}function dT(...T){let A=0;for(let P=0;P<T.length;P++){let Q=T[P];ET(Q),A+=Q.length}let C=new Uint8Array(A);for(let P=0,Q=0;P<T.length;P++){let W=T[P];C.set(W,Q),Q+=W.length}return C}class P8{}function z2(T){let A=(P)=>T().update(C8(P)).digest(),C=T();return A.outputLen=C.outputLen,A.blockLen=C.blockLen,A.create=()=>T(),A}function h8(T=32){if(T8&&typeof T8.getRandomValues==="function")return T8.getRandomValues(new Uint8Array(T));if(T8&&typeof T8.randomBytes==="function")return Uint8Array.from(T8.randomBytes(T));throw Error("crypto.getRandomValues must be defined")}function vR(T,A,C,P){if(typeof T.setBigUint64==="function")return T.setBigUint64(A,C,P);let Q=BigInt(32),W=BigInt(4294967295),G=Number(C>>Q&W),U=Number(C&W),$=P?4:0,X=P?0:4;T.setUint32(A+$,G,P),T.setUint32(A+X,U,P)}function b$(T,A,C){return T&A^~T&C}function l$(T,A,C){return T&A^T&C^A&C}class a6 extends P8{constructor(T,A,C,P){super();this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=T,this.outputLen=A,this.padOffset=C,this.isLE=P,this.buffer=new Uint8Array(T),this.view=n6(this.buffer)}update(T){TA(this),T=C8(T),ET(T);let{view:A,buffer:C,blockLen:P}=this,Q=T.length;for(let W=0;W<Q;){let G=Math.min(P-this.pos,Q-W);if(G===P){let U=n6(T);for(;P<=Q-W;W+=P)this.process(U,W);continue}if(C.set(T.subarray(W,W+G),this.pos),this.pos+=G,W+=G,this.pos===P)this.process(A,0),this.pos=0}return this.length+=T.length,this.roundClean(),this}digestInto(T){TA(this),o6(T,this),this.finished=!0;let{buffer:A,view:C,blockLen:P,isLE:Q}=this,{pos:W}=this;if(A[W++]=128,K0(this.buffer.subarray(W)),this.padOffset>P-W)this.process(C,0),W=0;for(let q=W;q<P;q++)A[q]=0;vR(C,P-8,BigInt(this.length*8),Q),this.process(C,0);let G=n6(T),U=this.outputLen;if(U%4)throw Error("_sha2: outputLen should be aligned to 32bit");let $=U/4,X=this.get();if($>X.length)throw Error("_sha2: outputLen bigger than state");for(let q=0;q<$;q++)G.setUint32(4*q,X[q],Q)}digest(){let{buffer:T,outputLen:A}=this;this.digestInto(T);let C=T.slice(0,A);return this.destroy(),C}_cloneInto(T){T||(T=new this.constructor),T.set(...this.get());let{blockLen:A,buffer:C,length:P,finished:Q,destroyed:W,pos:G}=this;if(T.destroyed=W,T.finished=Q,T.length=P,T.pos=G,P%A)T.buffer.set(C);return T}clone(){return this._cloneInto()}}var AA=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var BT=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var s6=BigInt(4294967295),p$=BigInt(32);function yR(T,A=!1){if(A)return{h:Number(T&s6),l:Number(T>>p$&s6)};return{h:Number(T>>p$&s6)|0,l:Number(T&s6)|0}}function t6(T,A=!1){let C=T.length,P=new Uint32Array(C),Q=new Uint32Array(C);for(let W=0;W<C;W++){let{h:G,l:U}=yR(T[W],A);[P[W],Q[W]]=[G,U]}return[P,Q]}var aP=(T,A,C)=>T>>>C,sP=(T,A,C)=>T<<32-C|A>>>C,Q8=(T,A,C)=>T>>>C|A<<32-C,W8=(T,A,C)=>T<<32-C|A>>>C,S2=(T,A,C)=>T<<64-C|A>>>C-32,M2=(T,A,C)=>T>>>C-32|A<<64-C;var u$=(T,A,C)=>T<<C|A>>>32-C,d$=(T,A,C)=>A<<C|T>>>32-C,r$=(T,A,C)=>A<<C-32|T>>>64-C,f$=(T,A,C)=>T<<C-32|A>>>64-C;function y0(T,A,C,P){let Q=(A>>>0)+(P>>>0);return{h:T+C+(Q/4294967296|0)|0,l:Q|0}}var i$=(T,A,C)=>(T>>>0)+(A>>>0)+(C>>>0),c$=(T,A,C,P)=>A+C+P+(T/4294967296|0)|0,o$=(T,A,C,P)=>(T>>>0)+(A>>>0)+(C>>>0)+(P>>>0),n$=(T,A,C,P,Q)=>A+C+P+Q+(T/4294967296|0)|0,a$=(T,A,C,P,Q)=>(T>>>0)+(A>>>0)+(C>>>0)+(P>>>0)+(Q>>>0),s$=(T,A,C,P,Q,W)=>A+C+P+Q+W+(T/4294967296|0)|0;var lR=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]),NA=new Uint32Array(64);class tP extends a6{constructor(T=32){super(64,T,8,!1);this.A=AA[0]|0,this.B=AA[1]|0,this.C=AA[2]|0,this.D=AA[3]|0,this.E=AA[4]|0,this.F=AA[5]|0,this.G=AA[6]|0,this.H=AA[7]|0}get(){let{A:T,B:A,C,D:P,E:Q,F:W,G,H:U}=this;return[T,A,C,P,Q,W,G,U]}set(T,A,C,P,Q,W,G,U){this.A=T|0,this.B=A|0,this.C=C|0,this.D=P|0,this.E=Q|0,this.F=W|0,this.G=G|0,this.H=U|0}process(T,A){for(let q=0;q<16;q++,A+=4)NA[q]=T.getUint32(A,!1);for(let q=16;q<64;q++){let K=NA[q-15],F=NA[q-2],z=D0(K,7)^D0(K,18)^K>>>3,M=D0(F,17)^D0(F,19)^F>>>10;NA[q]=M+NA[q-7]+z+NA[q-16]|0}let{A:C,B:P,C:Q,D:W,E:G,F:U,G:$,H:X}=this;for(let q=0;q<64;q++){let K=D0(G,6)^D0(G,11)^D0(G,25),F=X+K+b$(G,U,$)+lR[q]+NA[q]|0,M=(D0(C,2)^D0(C,13)^D0(C,22))+l$(C,P,Q)|0;X=$,$=U,U=G,G=W+F|0,W=Q,Q=P,P=C,C=F+M|0}C=C+this.A|0,P=P+this.B|0,Q=Q+this.C|0,W=W+this.D|0,G=G+this.E|0,U=U+this.F|0,$=$+this.G|0,X=X+this.H|0,this.set(C,P,Q,W,G,U,$,X)}roundClean(){K0(NA)}destroy(){this.set(0,0,0,0,0,0,0,0),K0(this.buffer)}}var t$=(()=>t6(["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))))(),pR=(()=>t$[0])(),uR=(()=>t$[1])(),LA=new Uint32Array(80),wA=new Uint32Array(80);class e$ extends a6{constructor(T=64){super(128,T,16,!1);this.Ah=BT[0]|0,this.Al=BT[1]|0,this.Bh=BT[2]|0,this.Bl=BT[3]|0,this.Ch=BT[4]|0,this.Cl=BT[5]|0,this.Dh=BT[6]|0,this.Dl=BT[7]|0,this.Eh=BT[8]|0,this.El=BT[9]|0,this.Fh=BT[10]|0,this.Fl=BT[11]|0,this.Gh=BT[12]|0,this.Gl=BT[13]|0,this.Hh=BT[14]|0,this.Hl=BT[15]|0}get(){let{Ah:T,Al:A,Bh:C,Bl:P,Ch:Q,Cl:W,Dh:G,Dl:U,Eh:$,El:X,Fh:q,Fl:K,Gh:F,Gl:z,Hh:M,Hl:E}=this;return[T,A,C,P,Q,W,G,U,$,X,q,K,F,z,M,E]}set(T,A,C,P,Q,W,G,U,$,X,q,K,F,z,M,E){this.Ah=T|0,this.Al=A|0,this.Bh=C|0,this.Bl=P|0,this.Ch=Q|0,this.Cl=W|0,this.Dh=G|0,this.Dl=U|0,this.Eh=$|0,this.El=X|0,this.Fh=q|0,this.Fl=K|0,this.Gh=F|0,this.Gl=z|0,this.Hh=M|0,this.Hl=E|0}process(T,A){for(let m=0;m<16;m++,A+=4)LA[m]=T.getUint32(A),wA[m]=T.getUint32(A+=4);for(let m=16;m<80;m++){let v=LA[m-15]|0,l=wA[m-15]|0,f=Q8(v,l,1)^Q8(v,l,8)^aP(v,l,7),u=W8(v,l,1)^W8(v,l,8)^sP(v,l,7),a=LA[m-2]|0,d=wA[m-2]|0,h=Q8(a,d,19)^S2(a,d,61)^aP(a,d,6),o=W8(a,d,19)^M2(a,d,61)^sP(a,d,6),c=o$(u,o,wA[m-7],wA[m-16]),x=n$(c,f,h,LA[m-7],LA[m-16]);LA[m]=x|0,wA[m]=c|0}let{Ah:C,Al:P,Bh:Q,Bl:W,Ch:G,Cl:U,Dh:$,Dl:X,Eh:q,El:K,Fh:F,Fl:z,Gh:M,Gl:E,Hh:L,Hl:B}=this;for(let m=0;m<80;m++){let v=Q8(q,K,14)^Q8(q,K,18)^S2(q,K,41),l=W8(q,K,14)^W8(q,K,18)^M2(q,K,41),f=q&F^~q&M,u=K&z^~K&E,a=a$(B,l,u,uR[m],wA[m]),d=s$(a,L,v,f,pR[m],LA[m]),h=a|0,o=Q8(C,P,28)^S2(C,P,34)^S2(C,P,39),c=W8(C,P,28)^M2(C,P,34)^M2(C,P,39),x=C&Q^C&G^Q&G,j=P&W^P&U^W&U;L=M|0,B=E|0,M=F|0,E=z|0,F=q|0,z=K|0,{h:q,l:K}=y0($|0,X|0,d|0,h|0),$=G|0,X=U|0,G=Q|0,U=W|0,Q=C|0,W=P|0;let J=i$(h,c,j);C=c$(J,d,o,x),P=J|0}({h:C,l:P}=y0(this.Ah|0,this.Al|0,C|0,P|0)),{h:Q,l:W}=y0(this.Bh|0,this.Bl|0,Q|0,W|0),{h:G,l:U}=y0(this.Ch|0,this.Cl|0,G|0,U|0),{h:$,l:X}=y0(this.Dh|0,this.Dl|0,$|0,X|0),{h:q,l:K}=y0(this.Eh|0,this.El|0,q|0,K|0),{h:F,l:z}=y0(this.Fh|0,this.Fl|0,F|0,z|0),{h:M,l:E}=y0(this.Gh|0,this.Gl|0,M|0,E|0),{h:L,l:B}=y0(this.Hh|0,this.Hl|0,L|0,B|0),this.set(C,P,Q,W,G,U,$,X,q,K,F,z,M,E,L,B)}roundClean(){K0(LA,wA)}destroy(){K0(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}var e6=z2(()=>new tP);var T9=z2(()=>new e$);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var AQ=BigInt(0),TQ=BigInt(1);function CA(T,A=""){if(typeof T!=="boolean"){let C=A&&`"${A}"`;throw Error(C+"expected boolean, got type="+typeof T)}return T}function G0(T,A,C=""){let P=e0(T),Q=T?.length,W=A!==void 0;if(!P||W&&Q!==A){let G=C&&`"${C}" `,U=W?` of length ${A}`:"",$=P?`length=${Q}`:`type=${typeof T}`;throw Error(G+"expected Uint8Array"+U+", got "+$)}return T}function I2(T){let A=T.toString(16);return A.length&1?"0"+A:A}function A9(T){if(typeof T!=="string")throw Error("hex string expected, got "+typeof T);return T===""?AQ:BigInt("0x"+T)}function m8(T){return A9(k0(T))}function PA(T){return ET(T),A9(k0(Uint8Array.from(T).reverse()))}function TC(T,A){return A8(T.toString(16).padStart(A*2,"0"))}function CQ(T,A){return TC(T,A).reverse()}function K1(T,A,C){let P;if(typeof A==="string")try{P=A8(A)}catch(W){throw Error(T+" must be hex string or Uint8Array, cause: "+W)}else if(e0(A))P=Uint8Array.from(A);else throw Error(T+" must be hex string or Uint8Array");let Q=P.length;if(typeof C==="number"&&Q!==C)throw Error(T+" of length "+C+" expected, got "+Q);return P}function C9(T,A){if(T.length!==A.length)return!1;let C=0;for(let P=0;P<T.length;P++)C|=T[P]^A[P];return C===0}function PQ(T){return Uint8Array.from(T)}var eP=(T)=>typeof T==="bigint"&&AQ<=T;function P9(T,A,C){return eP(T)&&eP(A)&&eP(C)&&A<=T&&T<C}function N2(T,A,C,P){if(!P9(A,C,P))throw Error("expected valid "+T+": "+C+" <= n < "+P+", got "+A)}function AC(T){let A;for(A=0;T>AQ;T>>=TQ,A+=1);return A}var EA=(T)=>(TQ<<BigInt(T))-TQ;function Q9(T,A,C){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 C!=="function")throw Error("hmacFn must be a function");let P=(z)=>new Uint8Array(z),Q=(z)=>Uint8Array.of(z),W=P(T),G=P(T),U=0,$=()=>{W.fill(1),G.fill(0),U=0},X=(...z)=>C(G,W,...z),q=(z=P(0))=>{if(G=X(Q(0),z),W=X(),z.length===0)return;G=X(Q(1),z),W=X()},K=()=>{if(U++>=1000)throw Error("drbg: tried 1000 values");let z=0,M=[];while(z<A){W=X();let E=W.slice();M.push(E),z+=W.length}return dT(...M)};return(z,M)=>{$(),q(z);let E=void 0;while(!(E=M(K())))q();return $(),E}}function BA(T,A,C={}){if(!T||typeof T!=="object")throw Error("expected valid options object");function P(Q,W,G){let U=T[Q];if(G&&U===void 0)return;let $=typeof U;if($!==W||U===null)throw Error(`param "${Q}" is invalid: expected ${W}, got ${$}`)}Object.entries(A).forEach(([Q,W])=>P(Q,W,!1)),Object.entries(C).forEach(([Q,W])=>P(Q,W,!0))}var QQ=()=>{throw Error("not implemented")};function g8(T){let A=new WeakMap;return(C,...P)=>{let Q=A.get(C);if(Q!==void 0)return Q;let W=T(C,...P);return A.set(C,W),W}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var rT=BigInt(0),NT=BigInt(1),G8=BigInt(2),J9=BigInt(3),U9=BigInt(4),$9=BigInt(5),dR=BigInt(7),V9=BigInt(8),rR=BigInt(9),Y9=BigInt(16);function E1(T,A){let C=T%A;return C>=rT?C:A+C}function N1(T,A,C){let P=T;while(A-- >rT)P*=P,P%=C;return P}function W9(T,A){if(T===rT)throw Error("invert: expected non-zero number");if(A<=rT)throw Error("invert: expected positive modulus, got "+A);let C=E1(T,A),P=A,Q=rT,W=NT,G=NT,U=rT;while(C!==rT){let X=P/C,q=P%C,K=Q-G*X,F=W-U*X;P=C,C=q,Q=G,W=U,G=K,U=F}if(P!==NT)throw Error("invert: does not exist");return E1(Q,A)}function WQ(T,A,C){if(!T.eql(T.sqr(A),C))throw Error("Cannot find square root")}function Z9(T,A){let C=(T.ORDER+NT)/U9,P=T.pow(A,C);return WQ(T,P,A),P}function fR(T,A){let C=(T.ORDER-$9)/V9,P=T.mul(A,G8),Q=T.pow(P,C),W=T.mul(A,Q),G=T.mul(T.mul(W,G8),Q),U=T.mul(W,T.sub(G,T.ONE));return WQ(T,U,A),U}function iR(T){let A=J0(T),C=q9(T),P=C(A,A.neg(A.ONE)),Q=C(A,P),W=C(A,A.neg(P)),G=(T+dR)/Y9;return(U,$)=>{let X=U.pow($,G),q=U.mul(X,P),K=U.mul(X,Q),F=U.mul(X,W),z=U.eql(U.sqr(q),$),M=U.eql(U.sqr(K),$);X=U.cmov(X,q,z),q=U.cmov(F,K,M);let E=U.eql(U.sqr(q),$),L=U.cmov(X,q,E);return WQ(U,L,$),L}}function q9(T){if(T<J9)throw Error("sqrt is not defined for small field");let A=T-NT,C=0;while(A%G8===rT)A/=G8,C++;let P=G8,Q=J0(T);while(G9(Q,P)===1)if(P++>1000)throw Error("Cannot find square root: probably non-prime P");if(C===1)return Z9;let W=Q.pow(P,A),G=(A+NT)/G8;return function($,X){if($.is0(X))return X;if(G9($,X)!==1)throw Error("Cannot find square root");let q=C,K=$.mul($.ONE,W),F=$.pow(X,A),z=$.pow(X,G);while(!$.eql(F,$.ONE)){if($.is0(F))return $.ZERO;let M=1,E=$.sqr(F);while(!$.eql(E,$.ONE))if(M++,E=$.sqr(E),M===q)throw Error("Cannot find square root");let L=NT<<BigInt(q-M-1),B=$.pow(K,L);q=M,K=$.sqr(B),F=$.mul(F,K),z=$.mul(z,B)}return z}}function cR(T){if(T%U9===J9)return Z9;if(T%V9===$9)return fR;if(T%Y9===rR)return iR(T);return q9(T)}var QA=(T,A)=>(E1(T,A)&NT)===NT,oR=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function GQ(T){let A={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},C=oR.reduce((P,Q)=>{return P[Q]="function",P},A);return BA(T,C),T}function nR(T,A,C){if(C<rT)throw Error("invalid exponent, negatives unsupported");if(C===rT)return T.ONE;if(C===NT)return A;let P=T.ONE,Q=A;while(C>rT){if(C&NT)P=T.mul(P,Q);Q=T.sqr(Q),C>>=NT}return P}function L2(T,A,C=!1){let P=Array(A.length).fill(C?T.ZERO:void 0),Q=A.reduce((G,U,$)=>{if(T.is0(U))return G;return P[$]=G,T.mul(G,U)},T.ONE),W=T.inv(Q);return A.reduceRight((G,U,$)=>{if(T.is0(U))return G;return P[$]=T.mul(G,P[$]),T.mul(G,U)},W),P}function G9(T,A){let C=(T.ORDER-NT)/G8,P=T.pow(A,C),Q=T.eql(P,T.ONE),W=T.eql(P,T.ZERO),G=T.eql(P,T.neg(T.ONE));if(!Q&&!W&&!G)throw Error("invalid Legendre symbol result");return Q?1:W?0:-1}function CC(T,A){if(A!==void 0)IA(A);let C=A!==void 0?A:T.toString(2).length,P=Math.ceil(C/8);return{nBitLength:C,nByteLength:P}}function J0(T,A,C=!1,P={}){if(T<=rT)throw Error("invalid field: expected ORDER > 0, got "+T);let Q=void 0,W=void 0,G=!1,U=void 0;if(typeof A==="object"&&A!=null){if(P.sqrt||C)throw Error("cannot specify opts in two arguments");let F=A;if(F.BITS)Q=F.BITS;if(F.sqrt)W=F.sqrt;if(typeof F.isLE==="boolean")C=F.isLE;if(typeof F.modFromBytes==="boolean")G=F.modFromBytes;U=F.allowedLengths}else{if(typeof A==="number")Q=A;if(P.sqrt)W=P.sqrt}let{nBitLength:$,nByteLength:X}=CC(T,Q);if(X>2048)throw Error("invalid field: expected ORDER of <= 2048 bytes");let q,K=Object.freeze({ORDER:T,isLE:C,BITS:$,BYTES:X,MASK:EA($),ZERO:rT,ONE:NT,allowedLengths:U,create:(F)=>E1(F,T),isValid:(F)=>{if(typeof F!=="bigint")throw Error("invalid field element: expected bigint, got "+typeof F);return rT<=F&&F<T},is0:(F)=>F===rT,isValidNot0:(F)=>!K.is0(F)&&K.isValid(F),isOdd:(F)=>(F&NT)===NT,neg:(F)=>E1(-F,T),eql:(F,z)=>F===z,sqr:(F)=>E1(F*F,T),add:(F,z)=>E1(F+z,T),sub:(F,z)=>E1(F-z,T),mul:(F,z)=>E1(F*z,T),pow:(F,z)=>nR(K,F,z),div:(F,z)=>E1(F*W9(z,T),T),sqrN:(F)=>F*F,addN:(F,z)=>F+z,subN:(F,z)=>F-z,mulN:(F,z)=>F*z,inv:(F)=>W9(F,T),sqrt:W||((F)=>{if(!q)q=cR(T);return q(K,F)}),toBytes:(F)=>C?CQ(F,X):TC(F,X),fromBytes:(F,z=!0)=>{if(U){if(!U.includes(F.length)||F.length>X)throw Error("Field.fromBytes: expected "+U+" bytes, got "+F.length);let E=new Uint8Array(X);E.set(F,C?0:E.length-F.length),F=E}if(F.length!==X)throw Error("Field.fromBytes: expected "+X+" bytes, got "+F.length);let M=C?PA(F):m8(F);if(G)M=E1(M,T);if(!z){if(!K.isValid(M))throw Error("invalid field element: outside of range 0..ORDER")}return M},invertBatch:(F)=>L2(K,F),cmov:(F,z,M)=>M?z:F});return Object.freeze(K)}function X9(T){if(typeof T!=="bigint")throw Error("field order must be bigint");let A=T.toString(2).length;return Math.ceil(A/8)}function JQ(T){let A=X9(T);return A+Math.ceil(A/2)}function UQ(T,A,C=!1){let P=T.length,Q=X9(A),W=JQ(A);if(P<16||P<W||P>1024)throw Error("expected "+W+"-1024 bytes of input, got "+P);let G=C?PA(T):m8(T),U=E1(G,A-NT)+NT;return C?CQ(U,Q):TC(U,Q)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var v8=BigInt(0),J8=BigInt(1);function w2(T,A){let C=A.negate();return T?C:A}function WA(T,A){let C=L2(T.Fp,A.map((P)=>P.Z));return A.map((P,Q)=>T.fromAffine(P.toAffine(C[Q])))}function j9(T,A){if(!Number.isSafeInteger(T)||T<=0||T>A)throw Error("invalid window size, expected [1.."+A+"], got W="+T)}function $Q(T,A){j9(T,A);let C=Math.ceil(A/T)+1,P=2**(T-1),Q=2**T,W=EA(T),G=BigInt(T);return{windows:C,windowSize:P,mask:W,maxNumber:Q,shiftBy:G}}function H9(T,A,C){let{windowSize:P,mask:Q,maxNumber:W,shiftBy:G}=C,U=Number(T&Q),$=T>>G;if(U>P)U-=W,$+=J8;let X=A*P,q=X+Math.abs(U)-1,K=U===0,F=U<0,z=A%2!==0;return{nextN:$,offset:q,isZero:K,isNeg:F,isNegF:z,offsetF:X}}function aR(T,A){if(!Array.isArray(T))throw Error("array expected");T.forEach((C,P)=>{if(!(C instanceof A))throw Error("invalid point at index "+P)})}function sR(T,A){if(!Array.isArray(T))throw Error("array of scalars expected");T.forEach((C,P)=>{if(!A.isValid(C))throw Error("invalid scalar at index "+P)})}var VQ=new WeakMap,R9=new WeakMap;function YQ(T){return R9.get(T)||1}function K9(T){if(T!==v8)throw Error("invalid wNAF")}class E2{constructor(T,A){this.BASE=T.BASE,this.ZERO=T.ZERO,this.Fn=T.Fn,this.bits=A}_unsafeLadder(T,A,C=this.ZERO){let P=T;while(A>v8){if(A&J8)C=C.add(P);P=P.double(),A>>=J8}return C}precomputeWindow(T,A){let{windows:C,windowSize:P}=$Q(A,this.bits),Q=[],W=T,G=W;for(let U=0;U<C;U++){G=W,Q.push(G);for(let $=1;$<P;$++)G=G.add(W),Q.push(G);W=G.double()}return Q}wNAF(T,A,C){if(!this.Fn.isValid(C))throw Error("invalid scalar");let P=this.ZERO,Q=this.BASE,W=$Q(T,this.bits);for(let G=0;G<W.windows;G++){let{nextN:U,offset:$,isZero:X,isNeg:q,isNegF:K,offsetF:F}=H9(C,G,W);if(C=U,X)Q=Q.add(w2(K,A[F]));else P=P.add(w2(q,A[$]))}return K9(C),{p:P,f:Q}}wNAFUnsafe(T,A,C,P=this.ZERO){let Q=$Q(T,this.bits);for(let W=0;W<Q.windows;W++){if(C===v8)break;let{nextN:G,offset:U,isZero:$,isNeg:X}=H9(C,W,Q);if(C=G,$)continue;else{let q=A[U];P=P.add(X?q.negate():q)}}return K9(C),P}getPrecomputes(T,A,C){let P=VQ.get(A);if(!P){if(P=this.precomputeWindow(A,T),T!==1){if(typeof C==="function")P=C(P);VQ.set(A,P)}}return P}cached(T,A,C){let P=YQ(T);return this.wNAF(P,this.getPrecomputes(P,T,C),A)}unsafe(T,A,C,P){let Q=YQ(T);if(Q===1)return this._unsafeLadder(T,A,P);return this.wNAFUnsafe(Q,this.getPrecomputes(Q,T,C),A,P)}createCache(T,A){j9(A,this.bits),R9.set(T,A),VQ.delete(T)}hasCache(T){return YQ(T)!==1}}function F9(T,A,C,P){let Q=A,W=T.ZERO,G=T.ZERO;while(C>v8||P>v8){if(C&J8)W=W.add(Q);if(P&J8)G=G.add(Q);Q=Q.double(),C>>=J8,P>>=J8}return{p1:W,p2:G}}function y8(T,A,C,P){aR(C,T),sR(P,A);let Q=C.length,W=P.length;if(Q!==W)throw Error("arrays of points and scalars must have equal length");let G=T.ZERO,U=AC(BigInt(Q)),$=1;if(U>12)$=U-3;else if(U>4)$=U-2;else if(U>0)$=2;let X=EA($),q=Array(Number(X)+1).fill(G),K=Math.floor((A.BITS-1)/$)*$,F=G;for(let z=K;z>=0;z-=$){q.fill(G);for(let E=0;E<W;E++){let L=P[E],B=Number(L>>BigInt(z)&X);q[B]=q[B].add(C[E])}let M=G;for(let E=q.length-1,L=G;E>0;E--)L=L.add(q[E]),M=M.add(L);if(F=F.add(M),z!==0)for(let E=0;E<$;E++)F=F.double()}return F}function k9(T,A,C){if(A){if(A.ORDER!==T)throw Error("Field.ORDER must match order: Fp == p, Fn == n");return GQ(A),A}else return J0(T,{isLE:C})}function PC(T,A,C={},P){if(P===void 0)P=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>v8))throw Error(`CURVE.${$} must be positive bigint`)}let Q=k9(A.p,C.Fp,P),W=k9(A.n,C.Fn,P),U=["Gx","Gy","a",T==="weierstrass"?"b":"d"];for(let $ of U)if(!Q.isValid(A[$]))throw Error(`CURVE.${$} must be valid field element of CURVE.Fp`);return A=Object.freeze(Object.assign({},A)),{CURVE:A,Fp:Q,Fn:W}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var OA=BigInt(0),LT=BigInt(1),ZQ=BigInt(2),tR=BigInt(8);function eR(T,A,C,P){let Q=T.sqr(C),W=T.sqr(P),G=T.add(T.mul(A.a,Q),W),U=T.add(T.ONE,T.mul(A.d,T.mul(Q,W)));return T.eql(G,U)}function TF(T,A={}){let C=PC("edwards",T,A,A.FpFnLE),{Fp:P,Fn:Q}=C,W=C.CURVE,{h:G}=W;BA(A,{},{uvRatio:"function"});let U=ZQ<<BigInt(Q.BYTES*8)-LT,$=(L)=>P.create(L),X=A.uvRatio||((L,B)=>{try{return{isValid:!0,value:P.sqrt(P.div(L,B))}}catch(m){return{isValid:!1,value:OA}}});if(!eR(P,W,W.Gx,W.Gy))throw Error("bad curve params: generator point");function q(L,B,m=!1){let v=m?LT:OA;return N2("coordinate "+L,B,v,U),B}function K(L){if(!(L instanceof M))throw Error("ExtendedPoint expected")}let F=g8((L,B)=>{let{X:m,Y:v,Z:l}=L,f=L.is0();if(B==null)B=f?tR:P.inv(l);let u=$(m*B),a=$(v*B),d=P.mul(l,B);if(f)return{x:OA,y:LT};if(d!==LT)throw Error("invZ was invalid");return{x:u,y:a}}),z=g8((L)=>{let{a:B,d:m}=W;if(L.is0())throw Error("bad point: ZERO");let{X:v,Y:l,Z:f,T:u}=L,a=$(v*v),d=$(l*l),h=$(f*f),o=$(h*h),c=$(a*B),x=$(h*$(c+d)),j=$(o+$(m*$(a*d)));if(x!==j)throw Error("bad point: equation left != right (1)");let J=$(v*l),V=$(f*u);if(J!==V)throw Error("bad point: equation left != right (2)");return!0});class M{constructor(L,B,m,v){this.X=q("x",L),this.Y=q("y",B),this.Z=q("z",m,!0),this.T=q("t",v),Object.freeze(this)}static CURVE(){return W}static fromAffine(L){if(L instanceof M)throw Error("extended point not allowed");let{x:B,y:m}=L||{};return q("x",B),q("y",m),new M(B,m,LT,$(B*m))}static fromBytes(L,B=!1){let m=P.BYTES,{a:v,d:l}=W;L=PQ(G0(L,m,"point")),CA(B,"zip215");let f=PQ(L),u=L[m-1];f[m-1]=u&-129;let a=PA(f),d=B?U:P.ORDER;N2("point.y",a,OA,d);let h=$(a*a),o=$(h-LT),c=$(l*h-v),{isValid:x,value:j}=X(o,c);if(!x)throw Error("bad point: invalid y coordinate");let J=(j&LT)===LT,V=(u&128)!==0;if(!B&&j===OA&&V)throw Error("bad point: x=0 and x_0=1");if(V!==J)j=$(-j);return M.fromAffine({x:j,y:a})}static fromHex(L,B=!1){return M.fromBytes(K1("point",L),B)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(L=8,B=!0){if(E.createCache(this,L),!B)this.multiply(ZQ);return this}assertValidity(){z(this)}equals(L){K(L);let{X:B,Y:m,Z:v}=this,{X:l,Y:f,Z:u}=L,a=$(B*u),d=$(l*v),h=$(m*u),o=$(f*v);return a===d&&h===o}is0(){return this.equals(M.ZERO)}negate(){return new M($(-this.X),this.Y,this.Z,$(-this.T))}double(){let{a:L}=W,{X:B,Y:m,Z:v}=this,l=$(B*B),f=$(m*m),u=$(ZQ*$(v*v)),a=$(L*l),d=B+m,h=$($(d*d)-l-f),o=a+f,c=o-u,x=a-f,j=$(h*c),J=$(o*x),V=$(h*x),Z=$(c*o);return new M(j,J,Z,V)}add(L){K(L);let{a:B,d:m}=W,{X:v,Y:l,Z:f,T:u}=this,{X:a,Y:d,Z:h,T:o}=L,c=$(v*a),x=$(l*d),j=$(u*m*o),J=$(f*h),V=$((v+l)*(a+d)-c-x),Z=J-j,H=J+j,k=$(x-B*c),S=$(V*Z),I=$(H*k),R=$(V*k),Y=$(Z*H);return new M(S,I,Y,R)}subtract(L){return this.add(L.negate())}multiply(L){if(!Q.isValidNot0(L))throw Error("invalid scalar: expected 1 <= sc < curve.n");let{p:B,f:m}=E.cached(this,L,(v)=>WA(M,v));return WA(M,[B,m])[0]}multiplyUnsafe(L,B=M.ZERO){if(!Q.isValid(L))throw Error("invalid scalar: expected 0 <= sc < curve.n");if(L===OA)return M.ZERO;if(this.is0()||L===LT)return this;return E.unsafe(this,L,(m)=>WA(M,m),B)}isSmallOrder(){return this.multiplyUnsafe(G).is0()}isTorsionFree(){return E.unsafe(this,W.n).is0()}toAffine(L){return F(this,L)}clearCofactor(){if(G===LT)return this;return this.multiplyUnsafe(G)}toBytes(){let{x:L,y:B}=this.toAffine(),m=P.toBytes(B);return m[m.length-1]|=L&LT?128:0,m}toHex(){return k0(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(L){return WA(M,L)}static msm(L,B){return y8(M,Q,L,B)}_setWindowSize(L){this.precompute(L)}toRawBytes(){return this.toBytes()}}M.BASE=new M(W.Gx,W.Gy,LT,$(W.Gx*W.Gy)),M.ZERO=new M(OA,LT,LT,OA),M.Fp=P,M.Fn=Q;let E=new E2(M,Q.BITS);return M.BASE.precompute(8),M}class qQ{constructor(T){this.ep=T}static fromBytes(T){QQ()}static fromHex(T){QQ()}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 k0(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 AF(T,A,C={}){if(typeof A!=="function")throw Error('"hash" function param is required');BA(C,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});let{prehash:P}=C,{BASE:Q,Fp:W,Fn:G}=T,U=C.randomBytes||h8,$=C.adjustScalarBytes||((h)=>h),X=C.domain||((h,o,c)=>{if(CA(c,"phflag"),o.length||c)throw Error("Contexts/pre-hash are not supported");return h});function q(h){return G.create(PA(h))}function K(h){let o=v.secretKey;h=K1("private key",h,o);let c=K1("hashed private key",A(h),2*o),x=$(c.slice(0,o)),j=c.slice(o,2*o),J=q(x);return{head:x,prefix:j,scalar:J}}function F(h){let{head:o,prefix:c,scalar:x}=K(h),j=Q.multiply(x),J=j.toBytes();return{head:o,prefix:c,scalar:x,point:j,pointBytes:J}}function z(h){return F(h).pointBytes}function M(h=Uint8Array.of(),...o){let c=dT(...o);return q(A(X(c,K1("context",h),!!P)))}function E(h,o,c={}){if(h=K1("message",h),P)h=P(h);let{prefix:x,scalar:j,pointBytes:J}=F(o),V=M(c.context,x,h),Z=Q.multiply(V).toBytes(),H=M(c.context,Z,J,h),k=G.create(V+H*j);if(!G.isValid(k))throw Error("sign failed: invalid s");let S=dT(Z,G.toBytes(k));return G0(S,v.signature,"result")}let L={zip215:!0};function B(h,o,c,x=L){let{context:j,zip215:J}=x,V=v.signature;if(h=K1("signature",h,V),o=K1("message",o),c=K1("publicKey",c,v.publicKey),J!==void 0)CA(J,"zip215");if(P)o=P(o);let Z=V/2,H=h.subarray(0,Z),k=PA(h.subarray(Z,V)),S,I,R;try{S=T.fromBytes(c,J),I=T.fromBytes(H,J),R=Q.multiplyUnsafe(k)}catch(b){return!1}if(!J&&S.isSmallOrder())return!1;let Y=M(j,I.toBytes(),S.toBytes(),o);return I.add(S.multiplyUnsafe(Y)).subtract(R).clearCofactor().is0()}let m=W.BYTES,v={secretKey:m,publicKey:m,signature:2*m,seed:m};function l(h=U(v.seed)){return G0(h,v.seed,"seed")}function f(h){let o=d.randomSecretKey(h);return{secretKey:o,publicKey:z(o)}}function u(h){return e0(h)&&h.length===G.BYTES}function a(h,o){try{return!!T.fromBytes(h,o)}catch(c){return!1}}let d={getExtendedPublicKey:F,randomSecretKey:l,isValidSecretKey:u,isValidPublicKey:a,toMontgomery(h){let{y:o}=T.fromBytes(h),c=v.publicKey,x=c===32;if(!x&&c!==57)throw Error("only defined for 25519 and 448");let j=x?W.div(LT+o,LT-o):W.div(o-LT,o+LT);return W.toBytes(j)},toMontgomerySecret(h){let o=v.secretKey;G0(h,o);let c=A(h.subarray(0,o));return $(c).subarray(0,o)},randomPrivateKey:l,precompute(h=8,o=T.BASE){return o.precompute(h,!1)}};return Object.freeze({keygen:f,getPublicKey:z,sign:E,verify:B,utils:d,Point:T,lengths:v})}function CF(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},C=T.Fp,P=J0(A.n,T.nBitLength,!0),Q={Fp:C,Fn:P,uvRatio:T.uvRatio},W={randomBytes:T.randomBytes,adjustScalarBytes:T.adjustScalarBytes,domain:T.domain,prehash:T.prehash,mapToCurve:T.mapToCurve};return{CURVE:A,curveOpts:Q,hash:T.hash,eddsaOpts:W}}function PF(T,A){let C=A.Point;return Object.assign({},A,{ExtendedPoint:C,CURVE:T,nBitLength:C.Fn.BITS,nByteLength:C.Fn.BYTES})}function D9(T){let{CURVE:A,curveOpts:C,hash:P,eddsaOpts:Q}=CF(T),W=TF(A,C),G=AF(W,P,Q);return PF(T,G)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var QF=BigInt(0),GA=BigInt(1),z9=BigInt(2),zh=BigInt(3),WF=BigInt(5),GF=BigInt(8),b8=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),B2=(()=>({p:b8,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:GF,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")}))();function JF(T){let A=BigInt(10),C=BigInt(20),P=BigInt(40),Q=BigInt(80),W=b8,U=T*T%W*T%W,$=N1(U,z9,W)*U%W,X=N1($,GA,W)*T%W,q=N1(X,WF,W)*X%W,K=N1(q,A,W)*q%W,F=N1(K,C,W)*K%W,z=N1(F,P,W)*F%W,M=N1(z,Q,W)*z%W,E=N1(M,Q,W)*z%W,L=N1(E,A,W)*q%W;return{pow_p_5_8:N1(L,z9,W)*T%W,b2:U}}function UF(T){return T[0]&=248,T[31]&=127,T[31]|=64,T}var XQ=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function kQ(T,A){let C=b8,P=E1(A*A*A,C),Q=E1(P*P*A,C),W=JF(T*Q).pow_p_5_8,G=E1(T*P*W,C),U=E1(A*G*G,C),$=G,X=E1(G*XQ,C),q=U===T,K=U===E1(-T,C),F=U===E1(-T*XQ,C);if(q)G=$;if(K||F)G=X;if(QA(G,C))G=E1(-G,C);return{isValid:q||K,value:G}}var _A=(()=>J0(B2.p,{isLE:!0}))(),$F=(()=>J0(B2.n,{isLE:!0}))(),VF=(()=>({...B2,Fp:_A,hash:T9,adjustScalarBytes:UF,uvRatio:kQ}))(),T0=(()=>D9(VF))();var HQ=XQ,YF=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),ZF=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),qF=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),XF=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),S9=(T)=>kQ(GA,T),HF=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),KQ=(T)=>T0.Point.Fp.create(PA(T)&HF);function M9(T){let{d:A}=B2,C=b8,P=(B)=>_A.create(B),Q=P(HQ*T*T),W=P((Q+GA)*qF),G=BigInt(-1),U=P((G-A*Q)*P(Q+A)),{isValid:$,value:X}=kQ(W,U),q=P(X*T);if(!QA(q,C))q=P(-q);if(!$)X=q;if(!$)G=Q;let K=P(G*(Q-GA)*XF-U),F=X*X,z=P((X+X)*U),M=P(K*YF),E=P(GA-F),L=P(GA+F);return new T0.Point(P(z*L),P(E*M),P(M*L),P(z*E))}function KF(T){ET(T,64);let A=KQ(T.subarray(0,32)),C=M9(A),P=KQ(T.subarray(32,64)),Q=M9(P);return new fT(C.add(Q))}class fT extends qQ{constructor(T){super(T)}static fromAffine(T){return new fT(T0.Point.fromAffine(T))}assertSame(T){if(!(T instanceof fT))throw Error("RistrettoPoint expected")}init(T){return new fT(T)}static hashToCurve(T){return KF(K1("ristrettoHash",T,64))}static fromBytes(T){ET(T,32);let{a:A,d:C}=B2,P=b8,Q=(v)=>_A.create(v),W=KQ(T);if(!C9(_A.toBytes(W),T)||QA(W,P))throw Error("invalid ristretto255 encoding 1");let G=Q(W*W),U=Q(GA+A*G),$=Q(GA-A*G),X=Q(U*U),q=Q($*$),K=Q(A*C*X-q),{isValid:F,value:z}=S9(Q(K*q)),M=Q(z*$),E=Q(z*M*K),L=Q((W+W)*M);if(QA(L,P))L=Q(-L);let B=Q(U*E),m=Q(L*B);if(!F||QA(m,P)||B===QF)throw Error("invalid ristretto255 encoding 2");return new fT(new T0.Point(L,B,GA,m))}static fromHex(T){return fT.fromBytes(K1("ristrettoHex",T,32))}static msm(T,A){return y8(fT,T0.Point.Fn,T,A)}toBytes(){let{X:T,Y:A,Z:C,T:P}=this.ep,Q=b8,W=(E)=>_A.create(E),G=W(W(C+A)*W(C-A)),U=W(T*A),$=W(U*U),{value:X}=S9(W(G*$)),q=W(X*G),K=W(X*U),F=W(q*K*P),z;if(QA(P*F,Q)){let E=W(A*HQ),L=W(T*HQ);T=E,A=L,z=W(q*ZF)}else z=K;if(QA(T*F,Q))A=W(-A);let M=W((C-A)*z);if(QA(M,Q))M=W(-M);return _A.toBytes(M)}equals(T){this.assertSame(T);let{X:A,Y:C}=this.ep,{X:P,Y:Q}=T.ep,W=($)=>_A.create($),G=W(A*Q)===W(C*P),U=W(C*Q)===W(A*P);return G||U}is0(){return this.equals(fT.ZERO)}}fT.BASE=(()=>new fT(T0.Point.BASE))();fT.ZERO=(()=>new fT(T0.Point.ZERO))();fT.Fp=(()=>_A)();fT.Fn=(()=>$F)();var IW=nT(RQ(),1),C0=nT(DQ(),1);var zQ=e6;var a8=nT(y9(),1),N=nT(UA(),1),QY=nT(UA(),1);var CD=1,PD=2,QD=3,WD=4,GD=5,JD=6,UD=7,$D=8,VD=9,YD=10,ZD=-32700,qD=-32603,XD=-32602,HD=-32601,KD=-32600,kD=-32016,jD=-32015,RD=-32014,FD=-32013,DD=-32012,zD=-32011,SD=-32010,MD=-32009,ID=-32008,ND=-32007,LD=-32006,wD=-32005,ED=-32004,BD=-32003,OD=-32002,_D=-32001,xD=2800000,hD=2800001,mD=2800002,gD=2800003,vD=2800004,yD=2800005,bD=2800006,lD=2800007,pD=2800008,uD=2800009,dD=2800010,rD=2800011,fD=3230000,iD=32300001,cD=3230002,oD=3230003,nD=3230004,aD=3610000,sD=3610001,tD=3610002,eD=3610003,T7=3610004,A7=3610005,C7=3610006,P7=3610007,Q7=3611000,W7=3704000,G7=3704001,J7=3704002,U7=3704003,$7=3704004,V7=4128000,Y7=4128001,Z7=4128002,q7=4615000,X7=4615001,H7=4615002,K7=4615003,k7=4615004,j7=4615005,R7=4615006,F7=4615007,D7=4615008,z7=4615009,S7=4615010,M7=4615011,I7=4615012,N7=4615013,L7=4615014,w7=4615015,E7=4615016,B7=4615017,O7=4615018,_7=4615019,x7=4615020,h7=4615021,m7=4615022,g7=4615023,v7=4615024,y7=4615025,b7=4615026,l7=4615027,p7=4615028,u7=4615029,d7=4615030,r7=4615031,f7=4615032,i7=4615033,c7=4615034,o7=4615035,n7=4615036,a7=4615037,s7=4615038,t7=4615039,e7=4615040,Tz=4615041,Az=4615042,Cz=4615043,Pz=4615044,Qz=4615045,Wz=4615046,Gz=4615047,Jz=4615048,Uz=4615049,$z=4615050,Vz=4615051,Yz=4615052,Zz=4615053,qz=4615054,Xz=5508000,Hz=5508001,Kz=5508002,kz=5508003,jz=5508004,Rz=5508005,Fz=5508006,Dz=5508007,zz=5508008,Sz=5508009,Mz=5508010,Iz=5508011,Nz=5663000,Lz=5663001,wz=5663002,Ez=5663003,Bz=5663004,Oz=5663005,_z=5663006,xz=5663007,hz=5663008,mz=5663009,gz=5663010,vz=5663011,yz=5663012,bz=5663013,lz=5663014,pz=5663015,uz=5663016,dz=5663017,rz=5663018,fz=5663019,iz=5663020,cz=7050000,oz=7050001,nz=7050002,az=7050003,sz=7050004,tz=7050005,ez=7050006,TS=7050007,AS=7050008,CS=7050009,PS=7050010,QS=7050011,WS=7050012,GS=7050013,JS=7050014,US=7050015,$S=7050016,VS=7050017,YS=7050018,ZS=7050019,qS=7050020,XS=7050021,HS=7050022,KS=7050023,kS=7050024,jS=7050025,RS=7050026,FS=7050027,DS=7050028,zS=7050029,SS=7050030,MS=7050031,IS=7050032,NS=7050033,LS=7050034,wS=7050035,ES=7050036,oQ=8078000,nQ=8078001,u9=8078002,d9=8078003,aQ=8078004,sQ=8078005,tQ=8078006,BS=8078007,OS=8078008,_S=8078009,xS=8078010,eQ=8078011,hS=8078012,r9=8078013,f9=8078014,mS=8078015,gS=8078016,vS=8078017,yS=8078018,bS=8078019,i9=8078020,c9=8078021,lS=8078022,pS=8100000,uS=8100001,dS=8100002,rS=8100003,fS=8190000,iS=8190001,cS=8190002,oS=8190003,nS=8190004,aS=9900000,sS=9900001,tS=9900002,eS=9900003,TM=9900004;var AM={[fD]:"Account not found at address: $address",[nD]:"Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",[oD]:"Expected decoded account at address: $address",[cD]:"Failed to decode account data at address: $address",[iD]:"Accounts not found at addresses: $addresses",[uD]:"Unable to find a viable program address bump seed.",[mD]:"$putativeAddress is not a base58-encoded address.",[xD]:"Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",[gD]:"The `CryptoKey` must be an `Ed25519` public key.",[rD]:"$putativeOffCurveAddress is not a base58-encoded off-curve address.",[pD]:"Invalid seeds; point must fall off the Ed25519 curve.",[vD]:"Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",[bD]:"A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",[lD]:"The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",[yD]:"Expected program derived address bump to be in the range [0, 255], got: $bump.",[dD]:"Program address cannot end with PDA marker.",[hD]:"Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",[WD]:"Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",[CD]:"The network has progressed past the last block for which this transaction could have been committed.",[oQ]:"Codec [$codecDescription] cannot decode empty byte arrays.",[lS]:"Enum codec cannot use lexical values [$stringValues] as discriminators. Either remove all lexical values or set `useValuesAsDiscriminators` to `false`.",[i9]:"Sentinel [$hexSentinel] must not be present in encoded bytes [$hexEncodedBytes].",[sQ]:"Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",[tQ]:"Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",[aQ]:"Encoder and decoder must either both be fixed-size or variable-size.",[OS]:"Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",[u9]:"Expected a fixed-size codec, got a variable-size one.",[r9]:"Codec [$codecDescription] expected a positive byte length, got $bytesLength.",[d9]:"Expected a variable-size codec, got a fixed-size one.",[bS]:"Codec [$codecDescription] expected zero-value [$hexZeroValue] to have the same size as the provided fixed-size item [$expectedSize bytes].",[nQ]:"Codec [$codecDescription] expected $expected bytes, got $bytesLength.",[yS]:"Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",[_S]:"Invalid discriminated union variant. Expected one of [$variants], got $value.",[xS]:"Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",[mS]:"Invalid literal union variant. Expected one of [$variants], got $value.",[BS]:"Expected [$codecDescription] to have $expected items, got $actual.",[hS]:"Invalid value $value for base $base with alphabet $alphabet.",[gS]:"Literal union discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",[eQ]:"Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",[f9]:"Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",[c9]:"Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",[vS]:"Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",[Q7]:"No random values implementation could be found.",[z7]:"instruction requires an uninitialized account",[g7]:"instruction tries to borrow reference for an account which is already borrowed",[v7]:"instruction left account with an outstanding borrowed reference",[h7]:"program other than the account's owner changed the size of the account data",[j7]:"account data too small for instruction",[m7]:"instruction expected an executable account",[Wz]:"An account does not have enough lamports to be rent-exempt",[Jz]:"Program arithmetic overflowed",[Qz]:"Failed to serialize or deserialize account data: $encodedData",[qz]:"Builtin programs must consume compute units",[f7]:"Cross-program invocation call depth too deep",[s7]:"Computational budget exceeded",[b7]:"custom program error: #$code",[B7]:"instruction contains duplicate accounts",[y7]:"instruction modifications of multiply-passed account differ",[d7]:"executable accounts must be rent exempt",[p7]:"instruction changed executable accounts data",[u7]:"instruction changed the balance of an executable account",[O7]:"instruction changed executable bit of an account",[L7]:"instruction modified data of an account it does not own",[N7]:"instruction spent from the balance of an account it does not own",[X7]:"generic instruction error",[$z]:"Provided owner is not allowed",[Cz]:"Account is immutable",[Pz]:"Incorrect authority provided",[F7]:"incorrect program id for instruction",[R7]:"insufficient funds for instruction",[k7]:"invalid account data for instruction",[Gz]:"Invalid account owner",[H7]:"invalid program argument",[l7]:"program returned invalid error code",[K7]:"invalid instruction data",[a7]:"Failed to reallocate account data",[n7]:"Provided seeds do not result in a valid address",[Vz]:"Accounts data allocations exceeded the maximum allowed per transaction",[Yz]:"Max accounts exceeded",[Zz]:"Max instruction trace length exceeded",[o7]:"Length of the seed is too long for address generation",[i7]:"An account required by the instruction is missing",[D7]:"missing required signature for instruction",[I7]:"instruction illegally modified the program id of an account",[x7]:"insufficient account keys for instruction",[t7]:"Cross-program invocation with unauthorized signer or writable account",[e7]:"Failed to create program execution environment",[Az]:"Program failed to compile",[Tz]:"Program failed to complete",[E7]:"instruction modified data of a read-only account",[w7]:"instruction changed the balance of a read-only account",[c7]:"Cross-program invocation reentrancy not allowed for this instruction",[_7]:"instruction modified rent epoch of an account",[M7]:"sum of account balances before and after instruction do not match",[S7]:"instruction requires an initialized account",[q7]:"",[r7]:"Unsupported program id",[Uz]:"Unsupported sysvar",[V7]:"The instruction does not have any accounts.",[Y7]:"The instruction does not have any data.",[Z7]:"Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",[GD]:"Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",[PD]:"The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",[tS]:"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",[TM]:"Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",[sS]:"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",[aS]:"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",[eS]:"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",[qD]:"JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",[XD]:"JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",[KD]:"JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",[HD]:"JSON-RPC error: The method does not exist / is not available ($__serverMessage)",[ZD]:"JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",[DD]:"$__serverMessage",[_D]:"$__serverMessage",[ED]:"$__serverMessage",[RD]:"$__serverMessage",[SD]:"$__serverMessage",[MD]:"$__serverMessage",[kD]:"Minimum context slot has not been reached",[wD]:"Node is unhealthy; behind by $numSlotsBehind slots",[ID]:"No snapshot",[OD]:"Transaction simulation failed",[ND]:"$__serverMessage",[zD]:"Transaction history is not available from this node",[LD]:"$__serverMessage",[FD]:"Transaction signature length mismatch",[BD]:"Transaction signature verification failure",[jD]:"$__serverMessage",[W7]:"Key pair bytes must be of length 64, got $byteLength.",[G7]:"Expected private key bytes with length 32. Actual length: $actualLength.",[J7]:"Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",[$7]:"The provided private key does not match the provided public key.",[U7]:"Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",[JD]:"Lamports value must be in the range [0, 2e64-1]",[UD]:"`$value` cannot be parsed as a `BigInt`",[YD]:"$message",[$D]:"`$value` cannot be parsed as a `Number`",[QD]:"No nonce account could be found at address `$nonceAccountAddress`",[fS]:"The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",[cS]:"WebSocket was closed before payload could be added to the send buffer",[oS]:"WebSocket connection closed",[nS]:"WebSocket failed to connect",[iS]:"Failed to obtain a subscription id from the server",[rS]:"Could not find an API plan for RPC method: `$method`",[pS]:"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`.",[dS]:"HTTP error ($statusCode): $message",[uS]:"HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",[Xz]:"Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",[Hz]:"The provided value does not implement the `KeyPairSigner` interface",[kz]:"The provided value does not implement the `MessageModifyingSigner` interface",[jz]:"The provided value does not implement the `MessagePartialSigner` interface",[Kz]:"The provided value does not implement any of the `MessageSigner` interfaces",[Fz]:"The provided value does not implement the `TransactionModifyingSigner` interface",[Dz]:"The provided value does not implement the `TransactionPartialSigner` interface",[zz]:"The provided value does not implement the `TransactionSendingSigner` interface",[Rz]:"The provided value does not implement any of the `TransactionSigner` interfaces",[Sz]:"More than one `TransactionSendingSigner` was identified.",[Mz]:"No `TransactionSendingSigner` was identified. Please provide a valid `TransactionWithSingleSendingSigner` transaction.",[Iz]:"Wallet account signers do not support signing multiple messages/transactions in a single operation",[P7]:"Cannot export a non-extractable key.",[sD]:"No digest implementation could be found.",[aD]:"Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",[tD]:`This runtime does not support the generation of Ed25519 key pairs.
11
11
 
12
12
  Install @solana/webcrypto-ed25519-polyfill and call its \`install\` function before generating keys in environments that do not support Ed25519.
13
13
 
14
- For a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20.`,[oM]:"No signature verification implementation could be found.",[aM]:"No key generation implementation could be found.",[sM]:"No signing implementation could be found.",[tM]:"No key export implementation could be found.",[GM]:"Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",[WF]:"Transaction processing left an account with an outstanding borrowed reference",[cz]:"Account in use",[fz]:"Account loaded twice",[rz]:"Attempt to debit an account but found no record of a prior credit.",[qF]:"Transaction loads an address table account that doesn't exist",[az]:"This transaction has already been processed",[sz]:"Blockhash not found",[tz]:"Loader call chain is too deep",[$F]:"Transactions are currently disabled due to cluster maintenance",[DF]:"Transaction contains a duplicate instruction ($index) that is not allowed",[iz]:"Insufficient funds for fee",[MF]:"Transaction results in an account ($accountIndex) with insufficient funds for rent",[oz]:"This account may not be used to pay transaction fees",[TF]:"Transaction contains an invalid account reference",[CF]:"Transaction loads an address table account with invalid data",[HF]:"Transaction address table lookup uses an invalid index",[KF]:"Transaction loads an address table account with an invalid owner",[zF]:"LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",[QF]:"This program may not be used for executing instructions",[VF]:"Transaction leaves an account with a lower balance than rent-exempt minimum",[YF]:"Transaction loads a writable account that cannot be written",[kF]:"Transaction exceeded max loaded accounts data size cap",[ez]:"Transaction requires a fee but has no signature present",[nz]:"Attempt to load a program that does not exist",[NF]:"Execution of the program referenced by account at index $accountIndex is temporarily restricted.",[FF]:"ResanitizationNeeded",[JF]:"Transaction failed to sanitize accounts offsets correctly",[AF]:"Transaction did not pass signature verification",[PF]:"Transaction locked too many accounts",[IF]:"Sum of account balances before and after transaction do not match",[dz]:"The transaction failed with the error `$errorName`",[UF]:"Transaction version is unsupported",[XF]:"Transaction would exceed account data limit within the block",[RF]:"Transaction would exceed total account data limit",[ZF]:"Transaction would exceed max account limit within the block",[GF]:"Transaction would exceed max Block Cost Limit",[jF]:"Transaction would exceed max Vote Cost Limit",[vz]:"Attempted to sign a transaction with an address that is not a signer for it",[_z]:"Transaction is missing an address at index: $index.",[yz]:"Transaction has no expected signers therefore it cannot be encoded",[uz]:"Transaction size $transactionSize exceeds limit of $transactionSizeLimit bytes",[Nz]:"Transaction does not have a blockhash lifetime",[Iz]:"Transaction is not a durable nonce transaction",[Lz]:"Contents of these address lookup tables unknown: $lookupTableAddresses",[wz]:"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",[Oz]:"No fee payer set in CompiledTransaction",[Ez]:"Could not find program address at index $index",[pz]:"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",[lz]:"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",[xz]:"Transaction is missing a fee payer.",[hz]:"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",[mz]:"Transaction first instruction is not advance nonce account instruction.",[gz]:"Transaction with no instructions cannot be durable nonce transaction.",[zz]:"This transaction includes an address (`$programAddress`) which is both invoked and set as the fee payer. Program addresses may not pay fees",[Fz]:"This transaction includes an address (`$programAddress`) which is both invoked and marked writable. Program addresses may not be writable",[bz]:"The transaction message expected the transaction to have $signerAddressesLength signatures, got $signaturesLength.",[Bz]:"Transaction is missing signatures for addresses: $addresses.",[Sz]:"Transaction version must be in the range [0, 127]. `$actualVersion` given"},U8="i",pT="t";function tF(T,A={}){let Q=sF[T];if(Q.length===0)return"";let J;function $(G){if(J[pT]===2){let Y=Q.slice(J[U8]+1,G);W.push(Y in A?`${A[Y]}`:`$${Y}`)}else if(J[pT]===1)W.push(Q.slice(J[U8],G))}let W=[];return Q.split("").forEach((G,Y)=>{if(Y===0){J={[U8]:0,[pT]:Q[0]==="\\"?0:Q[0]==="$"?2:1};return}let Z;switch(J[pT]){case 0:Z={[U8]:Y,[pT]:1};break;case 1:if(G==="\\")Z={[U8]:Y,[pT]:0};else if(G==="$")Z={[U8]:Y,[pT]:2};break;case 2:if(G==="\\")Z={[U8]:Y,[pT]:0};else if(G==="$")Z={[U8]:Y,[pT]:2};else if(!G.match(/\w/))Z={[U8]:Y,[pT]:1};break}if(Z){if(J!==Z)$(Y);J=Z}}),$(),W.join("")}function eF(T,A={}){return tF(T,A)}var x8=class extends Error{cause=this.cause;context;constructor(...[T,A]){let Q,J;if(A){let{cause:W,...G}=A;if(W)J={cause:W};if(Object.keys(G).length>0)Q=G}let $=eF(T,Q);super($,J);this.context={__code:T,...Q},this.name="SolanaError"}};function TN(T,A){return"fixedSize"in A?A.fixedSize:A.getSizeFromValue(T)}function f9(T){return Object.freeze({...T,encode:(A)=>{let Q=new Uint8Array(TN(A,T));return T.write(A,Q,0),Q}})}function r9(T){return Object.freeze({...T,decode:(A,Q=0)=>T.read(A,Q)[0]})}function pA(T){return"fixedSize"in T&&typeof T.fixedSize==="number"}function n9(T,A){if(pA(T)!==pA(A))throw new x8(n$);if(pA(T)&&pA(A)&&T.fixedSize!==A.fixedSize)throw new x8(i$,{decoderFixedSize:A.fixedSize,encoderFixedSize:T.fixedSize});if(!pA(T)&&!pA(A)&&T.maxSize!==A.maxSize)throw new x8(o$,{decoderMaxSize:A.maxSize,encoderMaxSize:T.maxSize});return{...A,...T,decode:A.decode,encode:T.encode,read:A.read,write:T.write}}function i9(T,A,Q=0){if(A.length-Q<=0)throw new x8(f$,{codecDescription:T})}function o9(T,A,Q,J=0){let $=Q.length-J;if($<A)throw new x8(r$,{bytesLength:$,codecDescription:T,expected:A})}function AN(T,A,Q,J){if(J<A||J>Q)throw new x8(a$,{codecDescription:T,max:Q,min:A,value:J})}function a9(T){return T?.endian===1?!1:!0}function QN(T){return f9({fixedSize:T.size,write(A,Q,J){if(T.range)AN(T.name,T.range[0],T.range[1],A);let $=new ArrayBuffer(T.size);return T.set(new DataView($),A,a9(T.config)),Q.set(new Uint8Array($),J),J+T.size}})}function JN(T){return r9({fixedSize:T.size,read(A,Q=0){i9(T.name,A,Q),o9(T.name,T.size,A,Q);let J=new DataView($N(A,Q,T.size));return[T.get(J,a9(T.config)),Q+T.size]}})}function $N(T,A,Q){let J=T.byteOffset+(A??0),$=Q??T.byteLength;return T.buffer.slice(J,J+$)}var s$=(T={})=>QN({config:T,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(A,Q,J)=>A.setBigUint64(0,BigInt(Q),J),size:8}),WN=(T={})=>JN({config:T,get:(A,Q)=>A.getBigUint64(0,Q),name:"u64",size:8}),s9=(T={})=>n9(s$(T),WN(T));class e9 extends TypeError{constructor(T,A){let Q,{message:J,explanation:$,...W}=T,{path:G}=T,Y=G.length===0?J:`At path: ${G.join(".")} -- ${J}`;super($??Y);if($!=null)this.cause=Y;Object.assign(this,W),this.name=this.constructor.name,this.failures=()=>{return Q??(Q=[T,...A()])}}}function GN(T){return w2(T)&&typeof T[Symbol.iterator]==="function"}function w2(T){return typeof T==="object"&&T!=null}function KQ(T){return w2(T)&&!Array.isArray(T)}function MT(T){if(typeof T==="symbol")return T.toString();return typeof T==="string"?JSON.stringify(T):`${T}`}function UN(T){let{done:A,value:Q}=T.next();return A?void 0:Q}function YN(T,A,Q,J){if(T===!0)return;else if(T===!1)T={};else if(typeof T==="string")T={message:T};let{path:$,branch:W}=A,{type:G}=Q,{refinement:Y,message:Z=`Expected a value of type \`${G}\`${Y?` with refinement \`${Y}\``:""}, but received: \`${MT(J)}\``}=T;return{value:J,type:G,refinement:Y,key:$[$.length-1],path:$,branch:W,...T,message:Z}}function*t9(T,A,Q,J){if(!GN(T))T=[T];for(let $ of T){let W=YN($,A,Q,J);if(W)yield W}}function*t$(T,A,Q={}){let{path:J=[],branch:$=[T],coerce:W=!1,mask:G=!1}=Q,Y={path:J,branch:$,mask:G};if(W)T=A.coercer(T,Y);let Z="valid";for(let C of A.validator(T,Y))C.explanation=Q.message,Z="not_valid",yield[C,void 0];for(let[C,K,j]of A.entries(T,Y)){let M=t$(K,j,{path:C===void 0?J:[...J,C],branch:C===void 0?$:[...$,K],coerce:W,mask:G,message:Q.message});for(let z of M)if(z[0])Z=z[0].refinement!=null?"not_refined":"not_valid",yield[z[0],void 0];else if(W){if(K=z[1],C===void 0)T=K;else if(T instanceof Map)T.set(C,K);else if(T instanceof Set)T.add(K);else if(w2(T)){if(K!==void 0||C in T)T[C]=K}}}if(Z!=="not_valid")for(let C of A.refiner(T,Y))C.explanation=Q.message,Z="not_refined",yield[C,void 0];if(Z==="valid")yield[void 0,T]}class kT{constructor(T){let{type:A,schema:Q,validator:J,refiner:$,coercer:W=(Y)=>Y,entries:G=function*(){}}=T;if(this.type=A,this.schema=Q,this.entries=G,this.coercer=W,J)this.validator=(Y,Z)=>{let C=J(Y,Z);return t9(C,Z,this,Y)};else this.validator=()=>[];if($)this.refiner=(Y,Z)=>{let C=$(Y,Z);return t9(C,Z,this,Y)};else this.refiner=()=>[]}assert(T,A){return TX(T,this,A)}create(T,A){return lA(T,this,A)}is(T){return AX(T,this)}mask(T,A){return ZN(T,this,A)}validate(T,A={}){return E2(T,this,A)}}function TX(T,A,Q){let J=E2(T,A,{message:Q});if(J[0])throw J[0]}function lA(T,A,Q){let J=E2(T,A,{coerce:!0,message:Q});if(J[0])throw J[0];else return J[1]}function ZN(T,A,Q){let J=E2(T,A,{coerce:!0,mask:!0,message:Q});if(J[0])throw J[0];else return J[1]}function AX(T,A){return!E2(T,A)[0]}function E2(T,A,Q={}){let J=t$(T,A,Q),$=UN(J);if($[0])return[new e9($[0],function*(){for(let G of J)if(G[0])yield G[0]}),void 0];else return[void 0,$[1]]}function ZA(T,A){return new kT({type:T,schema:null,validator:A})}function QX(){return ZA("any",()=>!0)}function s(T){return new kT({type:"array",schema:T,*entries(A){if(T&&Array.isArray(A))for(let[Q,J]of A.entries())yield[Q,J,T]},coercer(A){return Array.isArray(A)?A.slice():A},validator(A){return Array.isArray(A)||`Expected an array value, but received: ${MT(A)}`}})}function zT(){return ZA("boolean",(T)=>{return typeof T==="boolean"})}function CQ(T){return ZA("instance",(A)=>{return A instanceof T||`Expected a \`${T.name}\` instance, but received: ${MT(A)}`})}function z1(T){let A=MT(T),Q=typeof T;return new kT({type:"literal",schema:Q==="string"||Q==="number"||Q==="boolean"?T:null,validator(J){return J===T||`Expected the literal \`${A}\`, but received: ${MT(J)}`}})}function XN(){return ZA("never",()=>!1)}function t(T){return new kT({...T,validator:(A,Q)=>A===null||T.validator(A,Q),refiner:(A,Q)=>A===null||T.refiner(A,Q)})}function B(){return ZA("number",(T)=>{return typeof T==="number"&&!isNaN(T)||`Expected a number, but received: ${MT(T)}`})}function A1(T){return new kT({...T,validator:(A,Q)=>A===void 0||T.validator(A,Q),refiner:(A,Q)=>A===void 0||T.refiner(A,Q)})}function e$(T,A){return new kT({type:"record",schema:null,*entries(Q){if(w2(Q))for(let J in Q){let $=Q[J];yield[J,J,T],yield[J,$,A]}},validator(Q){return KQ(Q)||`Expected an object, but received: ${MT(Q)}`},coercer(Q){return KQ(Q)?{...Q}:Q}})}function l(){return ZA("string",(T)=>{return typeof T==="string"||`Expected a string, but received: ${MT(T)}`})}function HQ(T){let A=XN();return new kT({type:"tuple",schema:null,*entries(Q){if(Array.isArray(Q)){let J=Math.max(T.length,Q.length);for(let $=0;$<J;$++)yield[$,Q[$],T[$]||A]}},validator(Q){return Array.isArray(Q)||`Expected an array, but received: ${MT(Q)}`},coercer(Q){return Array.isArray(Q)?Q.slice():Q}})}function y(T){let A=Object.keys(T);return new kT({type:"type",schema:T,*entries(Q){if(w2(Q))for(let J of A)yield[J,Q[J],T[J]]},validator(Q){return KQ(Q)||`Expected an object, but received: ${MT(Q)}`},coercer(Q){return KQ(Q)?{...Q}:Q}})}function _0(T){let A=T.map((Q)=>Q.type).join(" | ");return new kT({type:"union",schema:null,coercer(Q,J){for(let $ of T){let[W,G]=$.validate(Q,{coerce:!0,mask:J.mask});if(!W)return G}return Q},validator(Q,J){let $=[];for(let W of T){let[...G]=t$(Q,W,J),[Y]=G;if(!Y[0])return[];else for(let[Z]of G)if(Z)$.push(Z)}return[`Expected the value to satisfy a union of \`${A}\`, but received: ${MT(Q)}`,...$]}})}function XA(){return ZA("unknown",()=>!0)}function uA(T,A,Q){return new kT({...T,coercer:(J,$)=>{return AX(J,A)?T.coercer(Q(J,$),$):T.coercer(J,$)}})}var QI=n0(IX(),1);OA();var wX=n0(LX(),1);var vN=BigInt(0),v2=BigInt(1),yN=BigInt(2),bN=BigInt(7),pN=BigInt(256),lN=BigInt(113),BX=[],_X=[],xX=[];for(let T=0,A=v2,Q=1,J=0;T<24;T++){[Q,J]=[J,(2*Q+3*J)%5],BX.push(2*(5*J+Q)),_X.push((T+1)*(T+2)/2%64);let $=vN;for(let W=0;W<7;W++)if(A=(A<<v2^(A>>bN)*lN)%pN,A&yN)$^=v2<<(v2<<BigInt(W))-v2;xX.push($)}var hX=n6(xX,!0),uN=hX[0],dN=hX[1],EX=(T,A,Q)=>Q>32?lZ(T,A,Q):bZ(T,A,Q),OX=(T,A,Q)=>Q>32?uZ(T,A,Q):pZ(T,A,Q);function cN(T,A=24){let Q=new Uint32Array(10);for(let J=24-A;J<24;J++){for(let G=0;G<10;G++)Q[G]=T[G]^T[G+10]^T[G+20]^T[G+30]^T[G+40];for(let G=0;G<10;G+=2){let Y=(G+8)%10,Z=(G+2)%10,C=Q[Z],K=Q[Z+1],j=EX(C,K,1)^Q[Y],M=OX(C,K,1)^Q[Y+1];for(let z=0;z<50;z+=10)T[G+z]^=j,T[G+z+1]^=M}let $=T[2],W=T[3];for(let G=0;G<24;G++){let Y=_X[G],Z=EX($,W,Y),C=OX($,W,Y),K=BX[G];$=T[K],W=T[K+1],T[K]=Z,T[K+1]=C}for(let G=0;G<50;G+=10){for(let Y=0;Y<10;Y++)Q[Y]=T[G+Y];for(let Y=0;Y<10;Y++)T[G+Y]^=~Q[(Y+2)%10]&Q[(Y+4)%10]}T[0]^=uN[J],T[1]^=dN[J]}CT(Q)}class XW extends TA{constructor(T,A,Q,J=!1,$=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=Q,this.enableXOF=J,this.rounds=$,F8(Q),!(0<T&&T<200))throw Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=hZ(this.state)}clone(){return this._cloneInto()}keccak(){fJ(this.state32),cN(this.state32,this.rounds),fJ(this.state32),this.posOut=0,this.pos=0}update(T){tT(this),T=e8(T),I0(T);let{blockLen:A,state:Q}=this,J=T.length;for(let $=0;$<J;){let W=Math.min(A-this.pos,J-$);for(let G=0;G<W;G++)Q[this.pos++]^=T[$++];if(this.pos===A)this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:T,suffix:A,pos:Q,blockLen:J}=this;if(T[Q]^=A,(A&128)!==0&&Q===J-1)this.keccak();T[J-1]^=128,this.keccak()}writeInto(T){tT(this,!1),I0(T),this.finish();let A=this.state,{blockLen:Q}=this;for(let J=0,$=T.length;J<$;){if(this.posOut>=Q)this.keccak();let W=Math.min(Q-this.posOut,$-J);T.set(A.subarray(this.posOut,this.posOut+W),J),this.posOut+=W,J+=W}return T}xofInto(T){if(!this.enableXOF)throw Error("XOF is not possible for this instance");return this.writeInto(T)}xof(T){return F8(T),this.xofInto(new Uint8Array(T))}digestInto(T){if(d6(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,CT(this.state)}_cloneInto(T){let{blockLen:A,suffix:Q,outputLen:J,rounds:$,enableXOF:W}=this;return T||(T=new XW(A,Q,J,W,$)),T.state32.set(this.state32),T.pos=this.pos,T.posOut=this.posOut,T.finished=this.finished,T.rounds=$,T.suffix=Q,T.outputLen=J,T.enableXOF=W,T.destroyed=this.destroyed,T}}var fN=(T,A,Q)=>R2(()=>new XW(A,T,Q));var PW=(()=>fN(1,136,32))();class qW extends TA{constructor(T,A){super();this.finished=!1,this.destroyed=!1,u6(T);let Q=e8(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 J=this.blockLen,$=new Uint8Array(J);$.set(Q.length>J?T.create().update(Q).digest():Q);for(let W=0;W<$.length;W++)$[W]^=54;this.iHash.update($),this.oHash=T.create();for(let W=0;W<$.length;W++)$[W]^=106;this.oHash.update($),CT($)}update(T){return tT(this),this.iHash.update(T),this}digestInto(T){tT(this),I0(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:Q,finished:J,destroyed:$,blockLen:W,outputLen:G}=this;return T=T,T.finished=J,T.destroyed=$,T.blockLen=W,T.outputLen=G,T.oHash=A._cloneInto(T.oHash),T.iHash=Q._cloneInto(T.iHash),T}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}var KW=(T,A,Q)=>new qW(T,A).update(Q).digest();KW.create=(T,A)=>new qW(T,A);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var gX=(T,A)=>(T+(T>=0?A:-A)/vX)/A;function rN(T,A,Q){let[[J,$],[W,G]]=A,Y=gX(G*T,Q),Z=gX(-$*T,Q),C=T-Y*J-Z*W,K=-Y*$-Z*G,j=C<Z8,M=K<Z8;if(j)C=-C;if(M)K=-K;let z=L8(Math.ceil(a6(Q)/2))+cA;if(C<Z8||C>=z||K<Z8||K>=z)throw Error("splitScalar (endomorphism): failed, k="+T);return{k1neg:j,k1:C,k2neg:M,k2:K}}function HW(T){if(!["compact","recovered","der"].includes(T))throw Error('Signature format must be "compact", "recovered", or "der"');return T}function CW(T,A){let Q={};for(let J of Object.keys(A))Q[J]=T[J]===void 0?A[J]:T[J];if(T8(Q.lowS,"lowS"),T8(Q.prehash,"prehash"),Q.format!==void 0)HW(Q.format);return Q}class mX extends Error{constructor(T=""){super(T)}}var Y8={Err:mX,_tlv:{encode:(T,A)=>{let{Err:Q}=Y8;if(T<0||T>256)throw new Q("tlv.encode: wrong tag");if(A.length&1)throw new Q("tlv.encode: unpadded data");let J=A.length/2,$=k2(J);if($.length/2&128)throw new Q("tlv.encode: long form length too big");let W=J>127?k2($.length/2|128):"";return k2(T)+W+$+A},decode(T,A){let{Err:Q}=Y8,J=0;if(T<0||T>256)throw new Q("tlv.encode: wrong tag");if(A.length<2||A[J++]!==T)throw new Q("tlv.decode: wrong tlv");let $=A[J++],W=!!($&128),G=0;if(!W)G=$;else{let Z=$&127;if(!Z)throw new Q("tlv.decode(long): indefinite length not supported");if(Z>4)throw new Q("tlv.decode(long): byte length is too big");let C=A.subarray(J,J+Z);if(C.length!==Z)throw new Q("tlv.decode: length bytes not complete");if(C[0]===0)throw new Q("tlv.decode(long): zero leftmost byte");for(let K of C)G=G<<8|K;if(J+=Z,G<128)throw new Q("tlv.decode(long): not minimal encoding")}let Y=A.subarray(J,J+G);if(Y.length!==G)throw new Q("tlv.decode: wrong value length");return{v:Y,l:A.subarray(J+G)}}},_int:{encode(T){let{Err:A}=Y8;if(T<Z8)throw new A("integer: negative integers are not allowed");let Q=k2(T);if(Number.parseInt(Q[0],16)&8)Q="00"+Q;if(Q.length&1)throw new A("unexpected DER parsing assertion: unpadded hex");return Q},decode(T){let{Err:A}=Y8;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 _A(T)}},toSig(T){let{Err:A,_int:Q,_tlv:J}=Y8,$=q1("signature",T),{v:W,l:G}=J.decode(48,$);if(G.length)throw new A("invalid signature: left bytes after parsing");let{v:Y,l:Z}=J.decode(2,W),{v:C,l:K}=J.decode(2,Z);if(K.length)throw new A("invalid signature: left bytes after parsing");return{r:Q.decode(Y),s:Q.decode(C)}},hexFromSig(T){let{_tlv:A,_int:Q}=Y8,J=A.encode(2,Q.encode(T.r)),$=A.encode(2,Q.encode(T.s)),W=J+$;return A.encode(48,W)}},Z8=BigInt(0),cA=BigInt(1),vX=BigInt(2),MQ=BigInt(3),nN=BigInt(4);function dA(T,A){let{BYTES:Q}=T,J;if(typeof A==="bigint")J=A;else{let $=q1("private key",A);try{J=T.fromBytes($)}catch(W){throw Error(`invalid private key: expected ui8a of size ${Q}, got ${typeof A}`)}}if(!T.isValidNot0(J))throw Error("invalid private key: out of range [1..N-1]");return J}function iN(T,A={}){let Q=t6("weierstrass",T,A),{Fp:J,Fn:$}=Q,W=Q.CURVE,{h:G,n:Y}=W;w8(A,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});let{endo:Z}=A;if(Z){if(!J.is0(W.a)||typeof Z.beta!=="bigint"||!Array.isArray(Z.basises))throw Error('invalid endo: expected "beta": bigint and "basises": array')}let C=bX(J,$);function K(){if(!J.isOdd)throw Error("compression is not supported: Field does not have .isOdd()")}function j(x,R,U){let{x:X,y:q}=R.toAffine(),H=J.toBytes(X);if(T8(U,"isCompressed"),U){K();let V=!J.isOdd(q);return l0(yX(V),H)}else return l0(Uint8Array.of(4),H,J.toBytes(q))}function M(x){GT(x,void 0,"Point");let{publicKey:R,publicKeyUncompressed:U}=C,X=x.length,q=x[0],H=x.subarray(1);if(X===R&&(q===2||q===3)){let V=J.fromBytes(H);if(!J.isValid(V))throw Error("bad point: is not on curve, wrong x");let F=E(V),I;try{I=J.sqrt(F)}catch(k){let b=k instanceof Error?": "+k.message:"";throw Error("bad point: is not on curve, sqrt error"+b)}K();let D=J.isOdd(I);if((q&1)===1!==D)I=J.neg(I);return{x:V,y:I}}else if(X===U&&q===4){let V=J.BYTES,F=J.fromBytes(H.subarray(0,V)),I=J.fromBytes(H.subarray(V,V*2));if(!L(F,I))throw Error("bad point: is not on curve");return{x:F,y:I}}else throw Error(`bad point: got length ${X}, expected compressed=${R} or uncompressed=${U}`)}let z=A.toBytes||j,N=A.fromBytes||M;function E(x){let R=J.sqr(x),U=J.mul(R,x);return J.add(J.add(U,J.mul(x,W.a)),W.b)}function L(x,R){let U=J.sqr(R),X=E(x);return J.eql(U,X)}if(!L(W.Gx,W.Gy))throw Error("bad curve params: generator point");let O=J.mul(J.pow(W.a,MQ),nN),g=J.mul(J.sqr(W.b),BigInt(27));if(J.is0(J.add(O,g)))throw Error("bad curve params: a or b");function v(x,R,U=!1){if(!J.isValid(R)||U&&J.is0(R))throw Error(`bad point coordinate ${x}`);return R}function p(x){if(!(x instanceof h))throw Error("ProjectivePoint expected")}function c(x){if(!Z||!Z.basises)throw Error("no endo");return rN(x,Z.basises,$.ORDER)}let u=xA((x,R)=>{let{X:U,Y:X,Z:q}=x;if(J.eql(q,J.ONE))return{x:U,y:X};let H=x.is0();if(R==null)R=H?J.ONE:J.inv(q);let V=J.mul(U,R),F=J.mul(X,R),I=J.mul(q,R);if(H)return{x:J.ZERO,y:J.ZERO};if(!J.eql(I,J.ONE))throw Error("invZ was invalid");return{x:V,y:F}}),i=xA((x)=>{if(x.is0()){if(A.allowInfinityPoint&&!J.is0(x.Y))return;throw Error("bad point: ZERO")}let{x:R,y:U}=x.toAffine();if(!J.isValid(R)||!J.isValid(U))throw Error("bad point: x or y not field elements");if(!L(R,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,R,U,X,q){return U=new h(J.mul(U.X,x),U.Y,U.Z),R=N2(X,R),U=N2(q,U),R.add(U)}class h{constructor(x,R,U){this.X=v("x",x),this.Y=v("y",R,!0),this.Z=v("z",U),Object.freeze(this)}static CURVE(){return W}static fromAffine(x){let{x:R,y:U}=x||{};if(!x||!J.isValid(R)||!J.isValid(U))throw Error("invalid affine point");if(x instanceof h)throw Error("projective point not allowed");if(J.is0(R)&&J.is0(U))return h.ZERO;return new h(R,U,J.ONE)}static fromBytes(x){let R=h.fromAffine(N(GT(x,void 0,"point")));return R.assertValidity(),R}static fromHex(x){return h.fromBytes(q1("pointHex",x))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(x=8,R=!0){if(n.createCache(this,x),!R)this.multiply(MQ);return this}assertValidity(){i(this)}hasEvenY(){let{y:x}=this.toAffine();if(!J.isOdd)throw Error("Field doesn't support isOdd");return!J.isOdd(x)}equals(x){p(x);let{X:R,Y:U,Z:X}=this,{X:q,Y:H,Z:V}=x,F=J.eql(J.mul(R,V),J.mul(q,X)),I=J.eql(J.mul(U,V),J.mul(H,X));return F&&I}negate(){return new h(this.X,J.neg(this.Y),this.Z)}double(){let{a:x,b:R}=W,U=J.mul(R,MQ),{X,Y:q,Z:H}=this,V=J.ZERO,F=J.ZERO,I=J.ZERO,D=J.mul(X,X),P=J.mul(q,q),k=J.mul(H,H),b=J.mul(X,q);return b=J.add(b,b),I=J.mul(X,H),I=J.add(I,I),V=J.mul(x,I),F=J.mul(U,k),F=J.add(V,F),V=J.sub(P,F),F=J.add(P,F),F=J.mul(V,F),V=J.mul(b,V),I=J.mul(U,I),k=J.mul(x,k),b=J.sub(D,k),b=J.mul(x,b),b=J.add(b,I),I=J.add(D,D),D=J.add(I,D),D=J.add(D,k),D=J.mul(D,b),F=J.add(F,D),k=J.mul(q,H),k=J.add(k,k),D=J.mul(k,b),V=J.sub(V,D),I=J.mul(k,P),I=J.add(I,I),I=J.add(I,I),new h(V,F,I)}add(x){p(x);let{X:R,Y:U,Z:X}=this,{X:q,Y:H,Z:V}=x,F=J.ZERO,I=J.ZERO,D=J.ZERO,P=W.a,k=J.mul(W.b,MQ),b=J.mul(R,q),r=J.mul(U,H),f=J.mul(X,V),T1=J.add(R,U),Q1=J.add(q,H);T1=J.mul(T1,Q1),Q1=J.add(b,r),T1=J.sub(T1,Q1),Q1=J.add(R,X);let J1=J.add(q,V);return Q1=J.mul(Q1,J1),J1=J.add(b,f),Q1=J.sub(Q1,J1),J1=J.add(U,X),F=J.add(H,V),J1=J.mul(J1,F),F=J.add(r,f),J1=J.sub(J1,F),D=J.mul(P,Q1),F=J.mul(k,f),D=J.add(F,D),F=J.sub(r,D),D=J.add(r,D),I=J.mul(F,D),r=J.add(b,b),r=J.add(r,b),f=J.mul(P,f),Q1=J.mul(k,Q1),r=J.add(r,f),f=J.sub(b,f),f=J.mul(P,f),Q1=J.add(Q1,f),b=J.mul(r,Q1),I=J.add(I,b),b=J.mul(J1,Q1),F=J.mul(T1,F),F=J.sub(F,b),b=J.mul(T1,r),D=J.mul(J1,D),D=J.add(D,b),new h(F,I,D)}subtract(x){return this.add(x.negate())}is0(){return this.equals(h.ZERO)}multiply(x){let{endo:R}=A;if(!$.isValidNot0(x))throw Error("invalid scalar: out of range");let U,X,q=(H)=>n.cached(this,H,(V)=>J8(h,V));if(R){let{k1neg:H,k1:V,k2neg:F,k2:I}=c(x),{p:D,f:P}=q(V),{p:k,f:b}=q(I);X=P.add(b),U=d(R.beta,D,k,H,F)}else{let{p:H,f:V}=q(x);U=H,X=V}return J8(h,[U,X])[0]}multiplyUnsafe(x){let{endo:R}=A,U=this;if(!$.isValid(x))throw Error("invalid scalar: out of range");if(x===Z8||U.is0())return h.ZERO;if(x===cA)return U;if(n.hasCache(this))return this.multiply(x);if(R){let{k1neg:X,k1:q,k2neg:H,k2:V}=c(x),{p1:F,p2:I}=j9(h,U,q,V);return d(R.beta,F,I,X,H)}else return n.unsafe(U,x)}multiplyAndAddUnsafe(x,R,U){let X=this.multiplyUnsafe(R).add(x.multiplyUnsafe(U));return X.is0()?void 0:X}toAffine(x){return u(this,x)}isTorsionFree(){let{isTorsionFree:x}=A;if(G===cA)return!0;if(x)return x(h,this);return n.unsafe(this,Y).is0()}clearCofactor(){let{clearCofactor:x}=A;if(G===cA)return this;if(x)return x(h,this);return this.multiplyUnsafe(G)}isSmallOrder(){return this.multiplyUnsafe(G).is0()}toBytes(x=!0){return T8(x,"isCompressed"),this.assertValidity(),z(h,this,x)}toHex(x=!0){return HT(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 J8(h,x)}static msm(x,R){return gA(h,$,x,R)}static fromPrivateKey(x){return h.BASE.multiply(dA($,x))}}h.BASE=new h(W.Gx,W.Gy,J.ONE),h.ZERO=new h(J.ZERO,J.ONE,J.ZERO),h.Fp=J,h.Fn=$;let o=$.BITS,n=new I2(h,A.endo?Math.ceil(o/2):o);return h.BASE.precompute(8),h}function yX(T){return Uint8Array.of(T?2:3)}function bX(T,A){return{secretKey:A.BYTES,publicKey:1+T.BYTES,publicKeyUncompressed:1+2*T.BYTES,publicKeyHasPrefix:!0,signature:2*A.BYTES}}function oN(T,A={}){let{Fn:Q}=T,J=A.randomBytes||BA,$=Object.assign(bX(T.Fp,Q),{seed:$$(Q.ORDER)});function W(z){try{return!!dA(Q,z)}catch(N){return!1}}function G(z,N){let{publicKey:E,publicKeyUncompressed:L}=$;try{let O=z.length;if(N===!0&&O!==E)return!1;if(N===!1&&O!==L)return!1;return!!T.fromBytes(z)}catch(O){return!1}}function Y(z=J($.seed)){return W$(GT(z,$.seed,"seed"),Q.ORDER)}function Z(z,N=!0){return T.BASE.multiply(dA(Q,z)).toBytes(N)}function C(z){let N=Y(z);return{secretKey:N,publicKey:Z(N)}}function K(z){if(typeof z==="bigint")return!1;if(z instanceof T)return!0;let{secretKey:N,publicKey:E,publicKeyUncompressed:L}=$;if(Q.allowedLengths||N===E)return;let O=q1("key",z).length;return O===E||O===L}function j(z,N,E=!0){if(K(z)===!0)throw Error("first arg must be private key");if(K(N)===!1)throw Error("second arg must be public key");let L=dA(Q,z);return T.fromHex(N).multiply(L).toBytes(E)}return Object.freeze({getPublicKey:Z,getSharedSecret:j,keygen:C,Point:T,utils:{isValidSecretKey:W,isValidPublicKey:G,randomSecretKey:Y,isValidPrivateKey:W,randomPrivateKey:Y,normPrivateKeyToScalar:(z)=>dA(Q,z),precompute(z=8,N=T.BASE){return N.precompute(z,!1)}},lengths:$})}function aN(T,A,Q={}){u6(A),w8(Q,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let J=Q.randomBytes||BA,$=Q.hmac||((U,...X)=>KW(A,U,l0(...X))),{Fp:W,Fn:G}=T,{ORDER:Y,BITS:Z}=G,{keygen:C,getPublicKey:K,getSharedSecret:j,utils:M,lengths:z}=oN(T,Q),N={prehash:!1,lowS:typeof Q.lowS==="boolean"?Q.lowS:!1,format:void 0,extraEntropy:!1},E="compact";function L(U){let X=Y>>cA;return U>X}function O(U,X){if(!G.isValidNot0(X))throw Error(`invalid signature ${U}: out of range 1..Point.Fn.ORDER`);return X}function g(U,X){HW(X);let q=z.signature,H=X==="compact"?q:X==="recovered"?q+1:void 0;return GT(U,H,`${X} signature`)}class v{constructor(U,X,q){if(this.r=O("r",U),this.s=O("s",X),q!=null)this.recovery=q;Object.freeze(this)}static fromBytes(U,X=E){g(U,X);let q;if(X==="der"){let{r:I,s:D}=Y8.toSig(GT(U));return new v(I,D)}if(X==="recovered")q=U[0],X="compact",U=U.subarray(1);let H=G.BYTES,V=U.subarray(0,H),F=U.subarray(H,H*2);return new v(G.fromBytes(V),G.fromBytes(F),q)}static fromHex(U,X){return this.fromBytes(t8(U),X)}addRecoveryBit(U){return new v(this.r,this.s,U)}recoverPublicKey(U){let X=W.ORDER,{r:q,s:H,recovery:V}=this;if(V==null||![0,1,2,3].includes(V))throw Error("recovery id invalid");if(Y*vX<X&&V>1)throw Error("recovery id is ambiguous for h>1 curve");let I=V===2||V===3?q+Y:q;if(!W.isValid(I))throw Error("recovery id 2 or 3 invalid");let D=W.toBytes(I),P=T.fromBytes(l0(yX((V&1)===0),D)),k=G.inv(I),b=c(q1("msgHash",U)),r=G.create(-b*k),f=G.create(H*k),T1=T.BASE.multiplyUnsafe(r).add(P.multiplyUnsafe(f));if(T1.is0())throw Error("point at infinify");return T1.assertValidity(),T1}hasHighS(){return L(this.s)}toBytes(U=E){if(HW(U),U==="der")return t8(Y8.hexFromSig(this));let X=G.toBytes(this.r),q=G.toBytes(this.s);if(U==="recovered"){if(this.recovery==null)throw Error("recovery bit must be present");return l0(Uint8Array.of(this.recovery),X,q)}return l0(X,q)}toHex(U){return HT(this.toBytes(U))}assertValidity(){}static fromCompact(U){return v.fromBytes(q1("sig",U),"compact")}static fromDER(U){return v.fromBytes(q1("sig",U),"der")}normalizeS(){return this.hasHighS()?new v(this.r,G.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return HT(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return HT(this.toBytes("compact"))}}let p=Q.bits2int||function(X){if(X.length>8192)throw Error("input is too large");let q=_A(X),H=X.length*8-Z;return H>0?q>>BigInt(H):q},c=Q.bits2int_modN||function(X){return G.create(p(X))},u=L8(Z);function i(U){return z2("num < 2^"+Z,U,Z8,u),G.toBytes(U)}function d(U,X){return GT(U,void 0,"message"),X?GT(A(U),void 0,"prehashed message"):U}function h(U,X,q){if(["recovered","canonical"].some((f)=>(f in q)))throw Error("sign() legacy options not supported");let{lowS:H,prehash:V,extraEntropy:F}=CW(q,N);U=d(U,V);let I=c(U),D=dA(G,X),P=[i(D),i(I)];if(F!=null&&F!==!1){let f=F===!0?J(z.secretKey):F;P.push(q1("extraEntropy",f))}let k=l0(...P),b=I;function r(f){let T1=p(f);if(!G.isValidNot0(T1))return;let Q1=G.inv(T1),J1=T.BASE.multiply(T1).toAffine(),r0=G.create(J1.x);if(r0===Z8)return;let X1=G.create(Q1*G.create(b+r0*D));if(X1===Z8)return;let C1=(J1.x===r0?0:2)|Number(J1.y&cA),T2=X1;if(H&&L(X1))T2=G.neg(X1),C1^=1;return new v(r0,T2,C1)}return{seed:k,k2sig:r}}function o(U,X,q={}){U=q1("message",U);let{seed:H,k2sig:V}=h(U,X,q);return A9(A.outputLen,G.BYTES,$)(H,V)}function n(U){let X=void 0,q=typeof U==="string"||sT(U),H=!q&&U!==null&&typeof U==="object"&&typeof U.r==="bigint"&&typeof U.s==="bigint";if(!q&&!H)throw Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(H)X=new v(U.r,U.s);else if(q){try{X=v.fromBytes(q1("sig",U),"der")}catch(V){if(!(V instanceof Y8.Err))throw V}if(!X)try{X=v.fromBytes(q1("sig",U),"compact")}catch(V){return!1}}if(!X)return!1;return X}function x(U,X,q,H={}){let{lowS:V,prehash:F,format:I}=CW(H,N);if(q=q1("publicKey",q),X=d(q1("message",X),F),"strict"in H)throw Error("options.strict was renamed to lowS");let D=I===void 0?n(U):v.fromBytes(q1("sig",U),I);if(D===!1)return!1;try{let P=T.fromBytes(q);if(V&&D.hasHighS())return!1;let{r:k,s:b}=D,r=c(X),f=G.inv(b),T1=G.create(r*f),Q1=G.create(k*f),J1=T.BASE.multiplyUnsafe(T1).add(P.multiplyUnsafe(Q1));if(J1.is0())return!1;return G.create(J1.x)===k}catch(P){return!1}}function R(U,X,q={}){let{prehash:H}=CW(q,N);return X=d(X,H),v.fromBytes(U,"recovered").recoverPublicKey(X).toBytes()}return Object.freeze({keygen:C,getPublicKey:K,getSharedSecret:j,utils:M,lengths:z,Point:T,sign:o,verify:x,recoverPublicKey:R,Signature:v,hash:A})}function sN(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},Q=T.Fp,J=T.allowedPrivateKeyLengths?Array.from(new Set(T.allowedPrivateKeyLengths.map((G)=>Math.ceil(G/2)))):void 0,$=UT(A.n,{BITS:T.nBitLength,allowedLengths:J,modFromBytes:T.wrapPrivateKey}),W={Fp:Q,Fn:$,allowInfinityPoint:T.allowInfinityPoint,endo:T.endo,isTorsionFree:T.isTorsionFree,clearCofactor:T.clearCofactor,fromBytes:T.fromBytes,toBytes:T.toBytes};return{CURVE:A,curveOpts:W}}function tN(T){let{CURVE:A,curveOpts:Q}=sN(T),J={hmac:T.hmac,randomBytes:T.randomBytes,lowS:T.lowS,bits2int:T.bits2int,bits2int_modN:T.bits2int_modN};return{CURVE:A,curveOpts:Q,hash:T.hash,ecdsaOpts:J}}function eN(T,A){let Q=A.Point;return Object.assign({},A,{ProjectivePoint:Q,CURVE:Object.assign({},T,s6(Q.Fn.ORDER,Q.Fn.BITS))})}function pX(T){let{CURVE:A,curveOpts:Q,hash:J,ecdsaOpts:$}=tN(T),W=iN(A,Q),G=aN(W,J,$);return eN(T,G)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function lX(T,A){let Q=(J)=>pX({...T,hash:J});return{...Q(A),create:Q}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var jW={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},TI={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var uX=BigInt(2);function AI(T){let A=jW.p,Q=BigInt(3),J=BigInt(6),$=BigInt(11),W=BigInt(22),G=BigInt(23),Y=BigInt(44),Z=BigInt(88),C=T*T*T%A,K=C*C*T%A,j=k1(K,Q,A)*K%A,M=k1(j,Q,A)*K%A,z=k1(M,uX,A)*C%A,N=k1(z,$,A)*z%A,E=k1(N,W,A)*N%A,L=k1(E,Y,A)*E%A,O=k1(L,Z,A)*L%A,g=k1(O,Y,A)*E%A,v=k1(g,Q,A)*K%A,p=k1(v,G,A)*N%A,c=k1(p,J,A)*C%A,u=k1(c,uX,A);if(!VW.eql(VW.sqr(u),T))throw Error("Cannot find square root");return u}var VW=UT(jW.p,{sqrt:AI}),kQ=lX({...jW,Fp:VW,lowS:!0,endo:TI},i6);var ph=t0.utils.randomPrivateKey,dX=()=>{let T=t0.utils.randomPrivateKey(),A=FW(T),Q=new Uint8Array(64);return Q.set(T),Q.set(A,32),{publicKey:A,secretKey:Q}},FW=t0.getPublicKey;function cX(T){try{return t0.ExtendedPoint.fromHex(T),!0}catch{return!1}}var QP=(T,A)=>t0.sign(T,A.slice(0,32)),JI=t0.verify,Y1=(T)=>{if(w.isBuffer(T))return T;else if(T instanceof Uint8Array)return w.from(T.buffer,T.byteOffset,T.byteLength);else return w.from(T)};class JP{constructor(T){Object.assign(this,T)}encode(){return w.from(nA.serialize(NQ,this))}static decode(T){return nA.deserialize(NQ,this,T)}static decodeUnchecked(T){return nA.deserializeUnchecked(NQ,this,T)}}var NQ=new Map,$P,$I=32,d2=32;function WI(T){return T._bn!==void 0}var fX=1;class a extends JP{constructor(T){super({});if(this._bn=void 0,WI(T))this._bn=T._bn;else{if(typeof T==="string"){let A=TT.default.decode(T);if(A.length!=d2)throw Error("Invalid public key input");this._bn=new zW.default(A)}else this._bn=new zW.default(T);if(this._bn.byteLength()>d2)throw Error("Invalid public key input")}}static unique(){let T=new a(fX);return fX+=1,new a(T.toBuffer())}equals(T){return this._bn.eq(T._bn)}toBase58(){return TT.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(w);if(T.length===d2)return T;let A=w.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,Q){let J=w.concat([T.toBuffer(),w.from(A),Q.toBuffer()]),$=D$(J);return new a($)}static createProgramAddressSync(T,A){let Q=w.alloc(0);T.forEach(function($){if($.length>$I)throw TypeError("Max seed length exceeded");Q=w.concat([Q,Y1($)])}),Q=w.concat([Q,A.toBuffer(),w.from("ProgramDerivedAddress")]);let J=D$(Q);if(cX(J))throw Error("Invalid seeds, address must fall off the curve");return new a(J)}static async createProgramAddress(T,A){return this.createProgramAddressSync(T,A)}static findProgramAddressSync(T,A){let Q=255,J;while(Q!=0){try{let $=T.concat(w.from([Q]));J=this.createProgramAddressSync($,A)}catch($){if($ instanceof TypeError)throw $;Q--;continue}return[J,Q]}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 a(T);return cX(A.toBytes())}}$P=a;a.default=new $P("11111111111111111111111111111111");NQ.set(a,{kind:"struct",fields:[["_bn","u256"]]});var lh=new a("BPFLoader1111111111111111111111111111111111"),IQ=1232,GI=127,WP=64;class GP extends Error{constructor(T){super(`Signature ${T} has expired: block height exceeded.`);this.signature=void 0,this.signature=T}}Object.defineProperty(GP.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});class UP 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(UP.prototype,"name",{value:"TransactionExpiredTimeoutError"});class YP extends Error{constructor(T){super(`Signature ${T} has expired: the nonce is no longer valid.`);this.signature=void 0,this.signature=T}}Object.defineProperty(YP.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});class NW{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 Q=new Map;this.keySegments().flat().forEach(($,W)=>{Q.set($.toBase58(),W)});let J=($)=>{let W=Q.get($.toBase58());if(W===void 0)throw Error("Encountered an unknown instruction account key during compilation");return W};return T.map(($)=>{return{programIdIndex:J($.programId),accountKeyIndexes:$.keys.map((W)=>J(W.pubkey)),data:$.data}})}}var G1=(T="publicKey")=>{return S.blob(32,T)};var fA=(T="string")=>{let A=S.struct([S.u32("length"),S.u32("lengthPadding"),S.blob(S.offset(S.u32(),-8),"chars")],T),Q=A.decode.bind(A),J=A.encode.bind(A),$=A;return $.decode=(W,G)=>{return Q(W,G).chars.toString()},$.encode=(W,G,Y)=>{let Z={chars:w.from(W,"utf8")};return J(Z,G,Y)},$.alloc=(W)=>{return S.u32().span+S.u32().span+w.from(W,"utf8").length},$},UI=(T="authorized")=>{return S.struct([G1("staker"),G1("withdrawer")],T)},YI=(T="lockup")=>{return S.struct([S.ns64("unixTimestamp"),S.ns64("epoch"),G1("custodian")],T)},ZI=(T="voteInit")=>{return S.struct([G1("nodePubkey"),G1("authorizedVoter"),G1("authorizedWithdrawer"),S.u8("commission")],T)},XI=(T="voteAuthorizeWithSeedArgs")=>{return S.struct([S.u32("voteAuthorizationType"),G1("currentAuthorityDerivedKeyOwnerPubkey"),fA("currentAuthorityDerivedKeySeed"),G1("newAuthorized")],T)};function ZP(T,A){let Q=($)=>{if($.span>=0)return $.span;else if(typeof $.alloc==="function")return $.alloc(A[$.property]);else if("count"in $&&"elementLayout"in $){let W=A[$.property];if(Array.isArray(W))return W.length*Q($.elementLayout)}else if("fields"in $)return ZP({layout:$},A[$.property]);return 0},J=0;return T.layout.fields.forEach(($)=>{J+=Q($)}),J}function p2(T){let A=0,Q=0;for(;;){let J=T.shift();if(A|=(J&127)<<Q*7,Q+=1,(J&128)===0)break}return A}function l2(T,A){let Q=A;for(;;){let J=Q&127;if(Q>>=7,Q==0){T.push(J);break}else J|=128,T.push(J)}}function R0(T,A){if(!T)throw Error(A||"Assertion failed")}class SW{constructor(T,A){this.payer=void 0,this.keyMetaMap=void 0,this.payer=T,this.keyMetaMap=A}static compile(T,A){let Q=new Map,J=(W)=>{let G=W.toBase58(),Y=Q.get(G);if(Y===void 0)Y={isSigner:!1,isWritable:!1,isInvoked:!1},Q.set(G,Y);return Y},$=J(A);$.isSigner=!0,$.isWritable=!0;for(let W of T){J(W.programId).isInvoked=!0;for(let G of W.keys){let Y=J(G.pubkey);Y.isSigner||=G.isSigner,Y.isWritable||=G.isWritable}}return new SW(A,Q)}getMessageComponents(){let T=[...this.keyMetaMap.entries()];R0(T.length<=256,"Max static account keys length exceeded");let A=T.filter(([,Y])=>Y.isSigner&&Y.isWritable),Q=T.filter(([,Y])=>Y.isSigner&&!Y.isWritable),J=T.filter(([,Y])=>!Y.isSigner&&Y.isWritable),$=T.filter(([,Y])=>!Y.isSigner&&!Y.isWritable),W={numRequiredSignatures:A.length+Q.length,numReadonlySignedAccounts:Q.length,numReadonlyUnsignedAccounts:$.length};{R0(A.length>0,"Expected at least one writable signer key");let[Y]=A[0];R0(Y===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}let G=[...A.map(([Y])=>new a(Y)),...Q.map(([Y])=>new a(Y)),...J.map(([Y])=>new a(Y)),...$.map(([Y])=>new a(Y))];return[W,G]}extractTableLookup(T){let[A,Q]=this.drainKeysFoundInLookupTable(T.state.addresses,(W)=>!W.isSigner&&!W.isInvoked&&W.isWritable),[J,$]=this.drainKeysFoundInLookupTable(T.state.addresses,(W)=>!W.isSigner&&!W.isInvoked&&!W.isWritable);if(A.length===0&&J.length===0)return;return[{accountKey:T.key,writableIndexes:A,readonlyIndexes:J},{writable:Q,readonly:$}]}drainKeysFoundInLookupTable(T,A){let Q=[],J=[];for(let[$,W]of this.keyMetaMap.entries())if(A(W)){let G=new a($),Y=T.findIndex((Z)=>Z.equals(G));if(Y>=0)R0(Y<256,"Max lookup table index exceeded"),Q.push(Y),J.push(G),this.keyMetaMap.delete($)}return[Q,J]}}var XP="Reached end of buffer unexpectedly";function zQ(T){if(T.length===0)throw Error(XP);return T.shift()}function u2(T,...A){let[Q]=A;if(A.length===2?Q+(A[1]??0)>T.length:Q>=T.length)throw Error(XP);return T.splice(...A)}class r2{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 a(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:TT.default.decode(T.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new NW(this.staticAccountKeys)}static compile(T){let A=SW.compile(T.instructions,T.payerKey),[Q,J]=A.getMessageComponents(),W=new NW(J).compileInstructions(T.instructions).map((G)=>({programIdIndex:G.programIdIndex,accounts:G.accountKeyIndexes,data:TT.default.encode(G.data)}));return new r2({header:Q,accountKeys:J,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 Q=T-A,$=this.accountKeys.length-A-this.header.numReadonlyUnsignedAccounts;return Q<$}else{let Q=A-this.header.numReadonlySignedAccounts;return T<Q}}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=[];l2(A,T);let Q=this.instructions.map((K)=>{let{accounts:j,programIdIndex:M}=K,z=Array.from(TT.default.decode(K.data)),N=[];l2(N,j.length);let E=[];return l2(E,z.length),{programIdIndex:M,keyIndicesCount:w.from(N),keyIndices:j,dataLength:w.from(E),data:z}}),J=[];l2(J,Q.length);let $=w.alloc(IQ);w.from(J).copy($);let W=J.length;Q.forEach((K)=>{let M=S.struct([S.u8("programIdIndex"),S.blob(K.keyIndicesCount.length,"keyIndicesCount"),S.seq(S.u8("keyIndex"),K.keyIndices.length,"keyIndices"),S.blob(K.dataLength.length,"dataLength"),S.seq(S.u8("userdatum"),K.data.length,"data")]).encode(K,$,W);W+=M}),$=$.slice(0,W);let G=S.struct([S.blob(1,"numRequiredSignatures"),S.blob(1,"numReadonlySignedAccounts"),S.blob(1,"numReadonlyUnsignedAccounts"),S.blob(A.length,"keyCount"),S.seq(G1("key"),T,"keys"),G1("recentBlockhash")]),Y={numRequiredSignatures:w.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:w.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:w.from([this.header.numReadonlyUnsignedAccounts]),keyCount:w.from(A),keys:this.accountKeys.map((K)=>Y1(K.toBytes())),recentBlockhash:TT.default.decode(this.recentBlockhash)},Z=w.alloc(2048),C=G.encode(Y,Z);return $.copy(Z,C),Z.slice(0,C+$.length)}static from(T){let A=[...T],Q=zQ(A);if(Q!==(Q&GI))throw Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");let J=zQ(A),$=zQ(A),W=p2(A),G=[];for(let j=0;j<W;j++){let M=u2(A,0,d2);G.push(new a(w.from(M)))}let Y=u2(A,0,d2),Z=p2(A),C=[];for(let j=0;j<Z;j++){let M=zQ(A),z=p2(A),N=u2(A,0,z),E=p2(A),L=u2(A,0,E),O=TT.default.encode(w.from(L));C.push({programIdIndex:M,accounts:N,data:O})}let K={header:{numRequiredSignatures:Q,numReadonlySignedAccounts:J,numReadonlyUnsignedAccounts:$},recentBlockhash:TT.default.encode(w.from(Y)),accountKeys:G,instructions:C};return new r2(K)}}var PI=w.alloc(WP).fill(0);class Z1{constructor(T){if(this.keys=void 0,this.programId=void 0,this.data=w.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:Q})=>({pubkey:T.toJSON(),isSigner:A,isWritable:Q})),programId:this.programId.toJSON(),data:[...this.data]}}}class j1{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:Q}=T;this.minNonceContextSlot=A,this.nonceInfo=Q}else if(Object.prototype.hasOwnProperty.call(T,"lastValidBlockHeight")){let{blockhash:A,lastValidBlockHeight:Q}=T;this.recentBlockhash=A,this.lastValidBlockHeight=Q}else{let{recentBlockhash:A,nonceInfo:Q}=T;if(Q)this.nonceInfo=Q;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 Z1(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 Q;if(this.feePayer)Q=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)Q=this.signatures[0].publicKey;else throw Error("Transaction fee payer required");for(let N=0;N<A.length;N++)if(A[N].programId===void 0)throw Error(`Transaction instruction index ${N} has undefined program id`);let J=[],$=[];A.forEach((N)=>{N.keys.forEach((L)=>{$.push({...L})});let E=N.programId.toString();if(!J.includes(E))J.push(E)}),J.forEach((N)=>{$.push({pubkey:new a(N),isSigner:!1,isWritable:!1})});let W=[];$.forEach((N)=>{let E=N.pubkey.toString(),L=W.findIndex((O)=>{return O.pubkey.toString()===E});if(L>-1)W[L].isWritable=W[L].isWritable||N.isWritable,W[L].isSigner=W[L].isSigner||N.isSigner;else W.push(N)}),W.sort(function(N,E){if(N.isSigner!==E.isSigner)return N.isSigner?-1:1;if(N.isWritable!==E.isWritable)return N.isWritable?-1:1;let L={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return N.pubkey.toBase58().localeCompare(E.pubkey.toBase58(),"en",L)});let G=W.findIndex((N)=>{return N.pubkey.equals(Q)});if(G>-1){let[N]=W.splice(G,1);N.isSigner=!0,N.isWritable=!0,W.unshift(N)}else W.unshift({pubkey:Q,isSigner:!0,isWritable:!0});for(let N of this.signatures){let E=W.findIndex((L)=>{return L.pubkey.equals(N.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: ${N.publicKey.toString()}`)}let Y=0,Z=0,C=0,K=[],j=[];W.forEach(({pubkey:N,isSigner:E,isWritable:L})=>{if(E){if(K.push(N.toString()),Y+=1,!L)Z+=1}else if(j.push(N.toString()),!L)C+=1});let M=K.concat(j),z=A.map((N)=>{let{data:E,programId:L}=N;return{programIdIndex:M.indexOf(L.toString()),accounts:N.keys.map((O)=>M.indexOf(O.pubkey.toString())),data:TT.default.encode(E)}});return z.forEach((N)=>{R0(N.programIdIndex>=0),N.accounts.forEach((E)=>R0(E>=0))}),new r2({header:{numRequiredSignatures:Y,numReadonlySignedAccounts:Z,numReadonlyUnsignedAccounts:C},accountKeys:M,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((J,$)=>{return A[$].equals(J.publicKey)}))return T}return this.signatures=A.map((Q)=>({signature:null,publicKey:Q})),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((Q)=>{let J=Q.toString();if(A.has(J))return!1;else return A.add(J),!0}).map((Q)=>({signature:null,publicKey:Q}))}sign(...T){if(T.length===0)throw Error("No signers");let A=new Set,Q=[];for(let $ of T){let W=$.publicKey.toString();if(A.has(W))continue;else A.add(W),Q.push($)}this.signatures=Q.map(($)=>({signature:null,publicKey:$.publicKey}));let J=this._compile();this._partialSign(J,...Q)}partialSign(...T){if(T.length===0)throw Error("No signers");let A=new Set,Q=[];for(let $ of T){let W=$.publicKey.toString();if(A.has(W))continue;else A.add(W),Q.push($)}let J=this._compile();this._partialSign(J,...Q)}_partialSign(T,...A){let Q=T.serialize();A.forEach((J)=>{let $=QP(Q,J.secretKey);this._addSignature(J.publicKey,Y1($))})}addSignature(T,A){this._compile(),this._addSignature(T,A)}_addSignature(T,A){R0(A.length===64);let Q=this.signatures.findIndex((J)=>T.equals(J.publicKey));if(Q<0)throw Error(`unknown signer: ${T.toString()}`);this.signatures[Q].signature=w.from(A)}verifySignatures(T=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),T)}_getMessageSignednessErrors(T,A){let Q={};for(let{signature:J,publicKey:$}of this.signatures)if(J===null){if(A)(Q.missing||=[]).push($)}else if(!JI(J,T,$.toBytes()))(Q.invalid||=[]).push($);return Q.invalid||Q.missing?Q:void 0}serialize(T){let{requireAllSignatures:A,verifySignatures:Q}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},T),J=this.serializeMessage();if(Q){let $=this._getMessageSignednessErrors(J,A);if($){let W="Signature verification failed.";if($.invalid)W+=`
15
- Invalid signature for public key${$.invalid.length===1?"":"(s)"} [\`${$.invalid.map((G)=>G.toBase58()).join("`, `")}\`].`;if($.missing)W+=`
16
- Missing signature for public key${$.missing.length===1?"":"(s)"} [\`${$.missing.map((G)=>G.toBase58()).join("`, `")}\`].`;throw Error(W)}}return this._serialize(J)}_serialize(T){let{signatures:A}=this,Q=[];l2(Q,A.length);let J=Q.length+A.length*64+T.length,$=w.alloc(J);return R0(A.length<256),w.from(Q).copy($,0),A.forEach(({signature:W},G)=>{if(W!==null)R0(W.length===64,"signature has invalid length"),w.from(W).copy($,Q.length+G*64)}),T.copy($,Q.length+A.length*64),R0($.length<=IQ,`Transaction too large: ${$.length} > ${IQ}`),$}get keys(){return R0(this.instructions.length===1),this.instructions[0].keys.map((T)=>T.pubkey)}get programId(){return R0(this.instructions.length===1),this.instructions[0].programId}get data(){return R0(this.instructions.length===1),this.instructions[0].data}static from(T){let A=[...T],Q=p2(A),J=[];for(let $=0;$<Q;$++){let W=u2(A,0,WP);J.push(TT.default.encode(w.from(W)))}return j1.populate(r2.from(A),J)}static populate(T,A=[]){let Q=new j1;if(Q.recentBlockhash=T.recentBlockhash,T.header.numRequiredSignatures>0)Q.feePayer=T.accountKeys[0];return A.forEach((J,$)=>{let W={signature:J==TT.default.encode(PI)?null:TT.default.decode(J),publicKey:T.accountKeys[$]};Q.signatures.push(W)}),T.instructions.forEach((J)=>{let $=J.accounts.map((W)=>{let G=T.accountKeys[W];return{pubkey:G,isSigner:Q.signatures.some((Y)=>Y.publicKey.toString()===G.toString())||T.isAccountSigner(W),isWritable:T.isAccountWritable(W)}});Q.instructions.push(new Z1({keys:$,programId:T.accountKeys[J.programIdIndex],data:TT.default.decode(J.data)}))}),Q._message=T,Q._json=Q.toJSON(),Q}}var qI=160,KI=64,CI=qI/KI,HI=1000/CI,X8=new a("SysvarC1ock11111111111111111111111111111111"),uh=new a("SysvarEpochSchedu1e111111111111111111111111"),dh=new a("Sysvar1nstructions1111111111111111111111111"),RW=new a("SysvarRecentB1ockHashes11111111111111111111"),n2=new a("SysvarRent111111111111111111111111111111111"),ch=new a("SysvarRewards111111111111111111111111111111"),fh=new a("SysvarS1otHashes111111111111111111111111111"),rh=new a("SysvarS1otHistory11111111111111111111111111"),DW=new a("SysvarStakeHistory1111111111111111111111111");class PP extends Error{constructor({action:T,signature:A,transactionMessage:Q,logs:J}){let $=J?`Logs:
17
- ${JSON.stringify(J.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
- ${Q}. `+$+"\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.";break;case"simulate":G=`Simulation failed.
19
- Message: ${Q}.
20
- `+$+"\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.";break;default:G=`Unknown action '${((Y)=>Y)(T)}'`}super(G);this.signature=void 0,this.transactionMessage=void 0,this.transactionLogs=void 0,this.signature=A,this.transactionMessage=Q,this.transactionLogs=J?J: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,Q)=>{T.getTransaction(this.signature).then((J)=>{if(J&&J.meta&&J.meta.logMessages){let $=J.meta.logMessages;this.transactionLogs=$,A($)}else Q(Error("Log messages not found"))}).catch(Q)});return await this.transactionLogs}}async function rX(T,A,Q,J){let $=J&&{skipPreflight:J.skipPreflight,preflightCommitment:J.preflightCommitment||J.commitment,maxRetries:J.maxRetries,minContextSlot:J.minContextSlot},W=await T.sendTransaction(A,Q,$),G;if(A.recentBlockhash!=null&&A.lastValidBlockHeight!=null)G=(await T.confirmTransaction({abortSignal:J?.abortSignal,signature:W,blockhash:A.recentBlockhash,lastValidBlockHeight:A.lastValidBlockHeight},J&&J.commitment)).value;else if(A.minNonceContextSlot!=null&&A.nonceInfo!=null){let{nonceInstruction:Y}=A.nonceInfo,Z=Y.keys[0].pubkey;G=(await T.confirmTransaction({abortSignal:J?.abortSignal,minContextSlot:A.minNonceContextSlot,nonceAccountPubkey:Z,nonceValue:A.nonceInfo.nonce,signature:W},J&&J.commitment)).value}else{if(J?.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,J&&J.commitment)).value}if(G.err){if(W!=null)throw new PP({action:"send",signature:W,transactionMessage:`Status: (${JSON.stringify(G)})`});throw Error(`Transaction ${W} failed (${JSON.stringify(G)})`)}return W}function VI(T){return new Promise((A)=>setTimeout(A,T))}function W1(T,A){let Q=T.layout.span>=0?T.layout.span:ZP(T,A),J=w.alloc(Q),$=Object.assign({instruction:T.index},A);return T.layout.encode($,J),J}var jI=S.nu64("lamportsPerSignature"),RI=S.struct([S.u32("version"),S.u32("state"),G1("authorizedPubkey"),G1("nonce"),S.struct([jI],"feeCalculator")]),nX=RI.span;function rA(T){let A=AP.blob(8,T),Q=A.decode.bind(A),J=A.encode.bind(A),$=A,W=s9();return $.decode=(G,Y)=>{let Z=Q(G,Y);return W.decode(Z)},$.encode=(G,Y,Z)=>{let C=W.encode(G);return J(C,Y,Z)},$}var jT=Object.freeze({Create:{index:0,layout:S.struct([S.u32("instruction"),S.ns64("lamports"),S.ns64("space"),G1("programId")])},Assign:{index:1,layout:S.struct([S.u32("instruction"),G1("programId")])},Transfer:{index:2,layout:S.struct([S.u32("instruction"),rA("lamports")])},CreateWithSeed:{index:3,layout:S.struct([S.u32("instruction"),G1("base"),fA("seed"),S.ns64("lamports"),S.ns64("space"),G1("programId")])},AdvanceNonceAccount:{index:4,layout:S.struct([S.u32("instruction")])},WithdrawNonceAccount:{index:5,layout:S.struct([S.u32("instruction"),S.ns64("lamports")])},InitializeNonceAccount:{index:6,layout:S.struct([S.u32("instruction"),G1("authorized")])},AuthorizeNonceAccount:{index:7,layout:S.struct([S.u32("instruction"),G1("authorized")])},Allocate:{index:8,layout:S.struct([S.u32("instruction"),S.ns64("space")])},AllocateWithSeed:{index:9,layout:S.struct([S.u32("instruction"),G1("base"),fA("seed"),S.ns64("space"),G1("programId")])},AssignWithSeed:{index:10,layout:S.struct([S.u32("instruction"),G1("base"),fA("seed"),G1("programId")])},TransferWithSeed:{index:11,layout:S.struct([S.u32("instruction"),rA("lamports"),fA("seed"),G1("programId")])},UpgradeNonceAccount:{index:12,layout:S.struct([S.u32("instruction")])}});class K0{constructor(){}static createAccount(T){let A=jT.Create,Q=W1(A,{lamports:T.lamports,space:T.space,programId:Y1(T.programId.toBuffer())});return new Z1({keys:[{pubkey:T.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:T.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:Q})}static transfer(T){let A,Q;if("basePubkey"in T){let J=jT.TransferWithSeed;A=W1(J,{lamports:BigInt(T.lamports),seed:T.seed,programId:Y1(T.programId.toBuffer())}),Q=[{pubkey:T.fromPubkey,isSigner:!1,isWritable:!0},{pubkey:T.basePubkey,isSigner:!0,isWritable:!1},{pubkey:T.toPubkey,isSigner:!1,isWritable:!0}]}else{let J=jT.Transfer;A=W1(J,{lamports:BigInt(T.lamports)}),Q=[{pubkey:T.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:T.toPubkey,isSigner:!1,isWritable:!0}]}return new Z1({keys:Q,programId:this.programId,data:A})}static assign(T){let A,Q;if("basePubkey"in T){let J=jT.AssignWithSeed;A=W1(J,{base:Y1(T.basePubkey.toBuffer()),seed:T.seed,programId:Y1(T.programId.toBuffer())}),Q=[{pubkey:T.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:T.basePubkey,isSigner:!0,isWritable:!1}]}else{let J=jT.Assign;A=W1(J,{programId:Y1(T.programId.toBuffer())}),Q=[{pubkey:T.accountPubkey,isSigner:!0,isWritable:!0}]}return new Z1({keys:Q,programId:this.programId,data:A})}static createAccountWithSeed(T){let A=jT.CreateWithSeed,Q=W1(A,{base:Y1(T.basePubkey.toBuffer()),seed:T.seed,lamports:T.lamports,space:T.space,programId:Y1(T.programId.toBuffer())}),J=[{pubkey:T.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:T.newAccountPubkey,isSigner:!1,isWritable:!0}];if(!T.basePubkey.equals(T.fromPubkey))J.push({pubkey:T.basePubkey,isSigner:!0,isWritable:!1});return new Z1({keys:J,programId:this.programId,data:Q})}static createNonceAccount(T){let A=new j1;if("basePubkey"in T&&"seed"in T)A.add(K0.createAccountWithSeed({fromPubkey:T.fromPubkey,newAccountPubkey:T.noncePubkey,basePubkey:T.basePubkey,seed:T.seed,lamports:T.lamports,space:nX,programId:this.programId}));else A.add(K0.createAccount({fromPubkey:T.fromPubkey,newAccountPubkey:T.noncePubkey,lamports:T.lamports,space:nX,programId:this.programId}));let Q={noncePubkey:T.noncePubkey,authorizedPubkey:T.authorizedPubkey};return A.add(this.nonceInitialize(Q)),A}static nonceInitialize(T){let A=jT.InitializeNonceAccount,Q=W1(A,{authorized:Y1(T.authorizedPubkey.toBuffer())}),J={keys:[{pubkey:T.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:RW,isSigner:!1,isWritable:!1},{pubkey:n2,isSigner:!1,isWritable:!1}],programId:this.programId,data:Q};return new Z1(J)}static nonceAdvance(T){let A=jT.AdvanceNonceAccount,Q=W1(A),J={keys:[{pubkey:T.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:RW,isSigner:!1,isWritable:!1},{pubkey:T.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:Q};return new Z1(J)}static nonceWithdraw(T){let A=jT.WithdrawNonceAccount,Q=W1(A,{lamports:T.lamports});return new Z1({keys:[{pubkey:T.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:T.toPubkey,isSigner:!1,isWritable:!0},{pubkey:RW,isSigner:!1,isWritable:!1},{pubkey:n2,isSigner:!1,isWritable:!1},{pubkey:T.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:Q})}static nonceAuthorize(T){let A=jT.AuthorizeNonceAccount,Q=W1(A,{authorized:Y1(T.newAuthorizedPubkey.toBuffer())});return new Z1({keys:[{pubkey:T.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:T.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:Q})}static allocate(T){let A,Q;if("basePubkey"in T){let J=jT.AllocateWithSeed;A=W1(J,{base:Y1(T.basePubkey.toBuffer()),seed:T.seed,space:T.space,programId:Y1(T.programId.toBuffer())}),Q=[{pubkey:T.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:T.basePubkey,isSigner:!0,isWritable:!1}]}else{let J=jT.Allocate;A=W1(J,{space:T.space}),Q=[{pubkey:T.accountPubkey,isSigner:!0,isWritable:!0}]}return new Z1({keys:Q,programId:this.programId,data:A})}}K0.programId=new a("11111111111111111111111111111111");var DI=IQ-300;class SQ{constructor(){}static getMinNumSignatures(T){return 2*(Math.ceil(T/SQ.chunkSize)+1+1)}static async load(T,A,Q,J,$){{let K=await T.getMinimumBalanceForRentExemption($.length),j=await T.getAccountInfo(Q.publicKey,"confirmed"),M=null;if(j!==null){if(j.executable)return console.error("Program load failed, account is already executable"),!1;if(j.data.length!==$.length)M=M||new j1,M.add(K0.allocate({accountPubkey:Q.publicKey,space:$.length}));if(!j.owner.equals(J))M=M||new j1,M.add(K0.assign({accountPubkey:Q.publicKey,programId:J}));if(j.lamports<K)M=M||new j1,M.add(K0.transfer({fromPubkey:A.publicKey,toPubkey:Q.publicKey,lamports:K-j.lamports}))}else M=new j1().add(K0.createAccount({fromPubkey:A.publicKey,newAccountPubkey:Q.publicKey,lamports:K>0?K:1,space:$.length,programId:J}));if(M!==null)await rX(T,M,[A,Q],{commitment:"confirmed"})}let W=S.struct([S.u32("instruction"),S.u32("offset"),S.u32("bytesLength"),S.u32("bytesLengthPadding"),S.seq(S.u8("byte"),S.offset(S.u32(),-8),"bytes")]),G=SQ.chunkSize,Y=0,Z=$,C=[];while(Z.length>0){let K=Z.slice(0,G),j=w.alloc(G+16);W.encode({instruction:0,offset:Y,bytes:K,bytesLength:0,bytesLengthPadding:0},j);let M=new j1().add({keys:[{pubkey:Q.publicKey,isSigner:!0,isWritable:!0}],programId:J,data:j});if(C.push(rX(T,M,[A,Q],{commitment:"confirmed"})),T._rpcEndpoint.includes("solana.com"))await VI(250);Y+=G,Z=Z.slice(G)}await Promise.all(C);{let K=S.struct([S.u32("instruction")]),j=w.alloc(K.span);K.encode({instruction:1},j);let M=new j1().add({keys:[{pubkey:Q.publicKey,isSigner:!0,isWritable:!0},{pubkey:n2,isSigner:!1,isWritable:!1}],programId:J,data:j}),z="processed",N=await T.sendTransaction(M,[A,Q],{preflightCommitment:z}),{context:E,value:L}=await T.confirmTransaction({signature:N,lastValidBlockHeight:M.lastValidBlockHeight,blockhash:M.recentBlockhash},z);if(L.err)throw Error(`Transaction ${N} failed (${JSON.stringify(L)})`);while(!0){try{if(await T.getSlot({commitment:z})>E.slot)break}catch{}await new Promise((O)=>setTimeout(O,Math.round(HI/2)))}}return!0}}SQ.chunkSize=DI;var nh=new a("BPFLoader2111111111111111111111111111111111");var ih=globalThis.fetch;var oh={index:1,layout:S.struct([S.u32("typeIndex"),rA("deactivationSlot"),S.nu64("lastExtendedSlot"),S.u8("lastExtendedStartIndex"),S.u8(),S.seq(G1(),S.offset(S.u8(),-1),"authority")])};var S1=uA(CQ(a),l(),(T)=>new a(T)),qP=HQ([l(),z1("base64")]),LW=uA(CQ(w),qP,(T)=>w.from(T[0],"base64"));function KP(T){return _0([y({jsonrpc:z1("2.0"),id:l(),result:T}),y({jsonrpc:z1("2.0"),id:l(),error:y({code:XA(),message:l(),data:A1(QX())})})])}var MI=KP(XA());function V1(T){return uA(KP(T),MI,(A)=>{if("error"in A)return A;else return{...A,result:lA(A.result,T)}})}function FT(T){return V1(y({context:y({slot:B()}),value:T}))}function wQ(T){return y({context:y({slot:B()}),value:T})}var kI=y({foundation:B(),foundationTerm:B(),initial:B(),taper:B(),terminal:B()}),ah=V1(s(t(y({epoch:B(),effectiveSlot:B(),amount:B(),postBalance:B(),commission:A1(t(B()))})))),zI=s(y({slot:B(),prioritizationFee:B()})),FI=y({total:B(),validator:B(),foundation:B(),epoch:B()}),NI=y({epoch:B(),slotIndex:B(),slotsInEpoch:B(),absoluteSlot:B(),blockHeight:A1(B()),transactionCount:A1(B())}),II=y({slotsPerEpoch:B(),leaderScheduleSlotOffset:B(),warmup:zT(),firstNormalEpoch:B(),firstNormalSlot:B()}),SI=e$(l(),s(B())),PA=t(_0([y({}),l()])),LI=y({err:PA}),wI=z1("receivedSignature"),sh=y({"solana-core":l(),"feature-set":A1(B())}),EI=y({program:l(),programId:S1,parsed:XA()}),OI=y({programId:S1,accounts:s(S1),data:l()}),th=FT(y({err:t(_0([y({}),l()])),logs:t(s(l())),accounts:A1(t(s(t(y({executable:zT(),owner:l(),lamports:B(),data:s(l()),rentEpoch:A1(B())}))))),unitsConsumed:A1(B()),returnData:A1(t(y({programId:l(),data:HQ([l(),z1("base64")])}))),innerInstructions:A1(t(s(y({index:B(),instructions:s(_0([EI,OI]))}))))})),eh=FT(y({byIdentity:e$(l(),s(B())),range:y({firstSlot:B(),lastSlot:B()})}));var Tg=V1(kI),Ag=V1(FI),Qg=V1(zI),Jg=V1(NI),$g=V1(II),Wg=V1(SI),Gg=V1(B()),Ug=FT(y({total:B(),circulating:B(),nonCirculating:B(),nonCirculatingAccounts:s(S1)})),BI=y({amount:l(),uiAmount:t(B()),decimals:B(),uiAmountString:A1(l())}),Yg=FT(s(y({address:S1,amount:l(),uiAmount:t(B()),decimals:B(),uiAmountString:A1(l())}))),Zg=FT(s(y({pubkey:S1,account:y({executable:zT(),owner:S1,lamports:B(),data:LW,rentEpoch:B()})}))),IW=y({program:l(),parsed:XA(),space:B()}),Xg=FT(s(y({pubkey:S1,account:y({executable:zT(),owner:S1,lamports:B(),data:IW,rentEpoch:B()})}))),Pg=FT(s(y({lamports:B(),address:S1}))),wW=y({executable:zT(),owner:S1,lamports:B(),data:LW,rentEpoch:B()}),qg=y({pubkey:S1,account:wW}),_I=uA(_0([CQ(w),IW]),_0([qP,IW]),(T)=>{if(Array.isArray(T))return lA(T,LW);else return T}),xI=y({executable:zT(),owner:S1,lamports:B(),data:_I,rentEpoch:B()}),Kg=y({pubkey:S1,account:xI}),Cg=y({state:_0([z1("active"),z1("inactive"),z1("activating"),z1("deactivating")]),active:B(),inactive:B()}),Hg=V1(s(y({signature:l(),slot:B(),err:PA,memo:t(l()),blockTime:A1(t(B()))}))),Vg=V1(s(y({signature:l(),slot:B(),err:PA,memo:t(l()),blockTime:A1(t(B()))}))),jg=y({subscription:B(),result:wQ(wW)}),hI=y({pubkey:S1,account:wW}),Rg=y({subscription:B(),result:wQ(hI)}),gI=y({parent:B(),slot:B(),root:B()}),Dg=y({subscription:B(),result:gI}),mI=_0([y({type:_0([z1("firstShredReceived"),z1("completed"),z1("optimisticConfirmation"),z1("root")]),slot:B(),timestamp:B()}),y({type:z1("createdBank"),parent:B(),slot:B(),timestamp:B()}),y({type:z1("frozen"),slot:B(),timestamp:B(),stats:y({numTransactionEntries:B(),numSuccessfulTransactions:B(),numFailedTransactions:B(),maxTransactionsPerEntry:B()})}),y({type:z1("dead"),slot:B(),timestamp:B(),err:l()})]),Mg=y({subscription:B(),result:mI}),kg=y({subscription:B(),result:wQ(_0([LI,wI]))}),zg=y({subscription:B(),result:B()}),Fg=y({pubkey:l(),gossip:t(l()),tpu:t(l()),rpc:t(l()),version:t(l())}),iX=y({votePubkey:l(),nodePubkey:l(),activatedStake:B(),epochVoteAccount:zT(),epochCredits:s(HQ([B(),B(),B()])),commission:B(),lastVote:B(),rootSlot:t(B())}),Ng=V1(y({current:s(iX),delinquent:s(iX)})),vI=_0([z1("processed"),z1("confirmed"),z1("finalized")]),yI=y({slot:B(),confirmations:t(B()),err:PA,confirmationStatus:A1(vI)}),Ig=FT(s(t(yI))),Sg=V1(B()),CP=y({accountKey:S1,writableIndexes:s(B()),readonlyIndexes:s(B())}),EW=y({signatures:s(l()),message:y({accountKeys:s(l()),header:y({numRequiredSignatures:B(),numReadonlySignedAccounts:B(),numReadonlyUnsignedAccounts:B()}),instructions:s(y({accounts:s(B()),data:l(),programIdIndex:B()})),recentBlockhash:l(),addressTableLookups:A1(s(CP))})}),HP=y({pubkey:S1,signer:zT(),writable:zT(),source:A1(_0([z1("transaction"),z1("lookupTable")]))}),VP=y({accountKeys:s(HP),signatures:s(l())}),jP=y({parsed:XA(),program:l(),programId:S1}),RP=y({accounts:s(S1),data:l(),programId:S1}),bI=_0([RP,jP]),pI=_0([y({parsed:XA(),program:l(),programId:l()}),y({accounts:s(l()),data:l(),programId:l()})]),DP=uA(bI,pI,(T)=>{if("accounts"in T)return lA(T,RP);else return lA(T,jP)}),MP=y({signatures:s(l()),message:y({accountKeys:s(HP),instructions:s(DP),recentBlockhash:l(),addressTableLookups:A1(t(s(CP)))})}),LQ=y({accountIndex:B(),mint:l(),owner:A1(l()),programId:A1(l()),uiTokenAmount:BI}),kP=y({writable:s(S1),readonly:s(S1)}),EQ=y({err:PA,fee:B(),innerInstructions:A1(t(s(y({index:B(),instructions:s(y({accounts:s(B()),data:l(),programIdIndex:B()}))})))),preBalances:s(B()),postBalances:s(B()),logMessages:A1(t(s(l()))),preTokenBalances:A1(t(s(LQ))),postTokenBalances:A1(t(s(LQ))),loadedAddresses:A1(kP),computeUnitsConsumed:A1(B()),costUnits:A1(B())}),OW=y({err:PA,fee:B(),innerInstructions:A1(t(s(y({index:B(),instructions:s(DP)})))),preBalances:s(B()),postBalances:s(B()),logMessages:A1(t(s(l()))),preTokenBalances:A1(t(s(LQ))),postTokenBalances:A1(t(s(LQ))),loadedAddresses:A1(kP),computeUnitsConsumed:A1(B()),costUnits:A1(B())}),iA=_0([z1(0),z1("legacy")]),qA=y({pubkey:l(),lamports:B(),postBalance:t(B()),rewardType:t(l()),commission:A1(t(B()))}),Lg=V1(t(y({blockhash:l(),previousBlockhash:l(),parentSlot:B(),transactions:s(y({transaction:EW,meta:t(EQ),version:A1(iA)})),rewards:A1(s(qA)),blockTime:t(B()),blockHeight:t(B())}))),wg=V1(t(y({blockhash:l(),previousBlockhash:l(),parentSlot:B(),rewards:A1(s(qA)),blockTime:t(B()),blockHeight:t(B())}))),Eg=V1(t(y({blockhash:l(),previousBlockhash:l(),parentSlot:B(),transactions:s(y({transaction:VP,meta:t(EQ),version:A1(iA)})),rewards:A1(s(qA)),blockTime:t(B()),blockHeight:t(B())}))),Og=V1(t(y({blockhash:l(),previousBlockhash:l(),parentSlot:B(),transactions:s(y({transaction:MP,meta:t(OW),version:A1(iA)})),rewards:A1(s(qA)),blockTime:t(B()),blockHeight:t(B())}))),Bg=V1(t(y({blockhash:l(),previousBlockhash:l(),parentSlot:B(),transactions:s(y({transaction:VP,meta:t(OW),version:A1(iA)})),rewards:A1(s(qA)),blockTime:t(B()),blockHeight:t(B())}))),_g=V1(t(y({blockhash:l(),previousBlockhash:l(),parentSlot:B(),rewards:A1(s(qA)),blockTime:t(B()),blockHeight:t(B())}))),xg=V1(t(y({blockhash:l(),previousBlockhash:l(),parentSlot:B(),transactions:s(y({transaction:EW,meta:t(EQ)})),rewards:A1(s(qA)),blockTime:t(B())}))),hg=V1(t(y({blockhash:l(),previousBlockhash:l(),parentSlot:B(),signatures:s(l()),blockTime:t(B())}))),gg=V1(t(y({slot:B(),meta:t(EQ),blockTime:A1(t(B())),transaction:EW,version:A1(iA)}))),mg=V1(t(y({slot:B(),transaction:MP,meta:t(OW),blockTime:A1(t(B())),version:A1(iA)}))),vg=FT(y({blockhash:l(),lastValidBlockHeight:B()})),yg=FT(zT()),lI=y({slot:B(),numTransactions:B(),numSlots:B(),samplePeriodSecs:B()}),bg=V1(s(lI)),pg=FT(t(y({feeCalculator:y({lamportsPerSignature:B()})}))),lg=V1(l()),ug=V1(l()),uI=y({err:PA,logs:s(l()),signature:l()}),dg=y({result:wQ(uI),subscription:B()});class c2{constructor(T){this._keypair=void 0,this._keypair=T??dX()}static generate(){return new c2(dX())}static fromSecretKey(T,A){if(T.byteLength!==64)throw Error("bad secret key size");let Q=T.slice(32,64);if(!A||!A.skipValidation){let J=T.slice(0,32),$=FW(J);for(let W=0;W<32;W++)if(Q[W]!==$[W])throw Error("provided secretKey is invalid")}return new c2({publicKey:Q,secretKey:T})}static fromSeed(T){let A=FW(T),Q=new Uint8Array(64);return Q.set(T),Q.set(A,32),new c2({publicKey:A,secretKey:Q})}get publicKey(){return new a(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}}var y2=Object.freeze({CreateLookupTable:{index:0,layout:S.struct([S.u32("instruction"),rA("recentSlot"),S.u8("bumpSeed")])},FreezeLookupTable:{index:1,layout:S.struct([S.u32("instruction")])},ExtendLookupTable:{index:2,layout:S.struct([S.u32("instruction"),rA(),S.seq(G1(),S.offset(S.u32(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:S.struct([S.u32("instruction")])},CloseLookupTable:{index:4,layout:S.struct([S.u32("instruction")])}});class zP{constructor(){}static createLookupTable(T){let[A,Q]=a.findProgramAddressSync([T.authority.toBuffer(),s$().encode(T.recentSlot)],this.programId),J=y2.CreateLookupTable,$=W1(J,{recentSlot:BigInt(T.recentSlot),bumpSeed:Q}),W=[{pubkey:A,isSigner:!1,isWritable:!0},{pubkey:T.authority,isSigner:!0,isWritable:!1},{pubkey:T.payer,isSigner:!0,isWritable:!0},{pubkey:K0.programId,isSigner:!1,isWritable:!1}];return[new Z1({programId:this.programId,keys:W,data:$}),A]}static freezeLookupTable(T){let A=y2.FreezeLookupTable,Q=W1(A),J=[{pubkey:T.lookupTable,isSigner:!1,isWritable:!0},{pubkey:T.authority,isSigner:!0,isWritable:!1}];return new Z1({programId:this.programId,keys:J,data:Q})}static extendLookupTable(T){let A=y2.ExtendLookupTable,Q=W1(A,{addresses:T.addresses.map(($)=>$.toBytes())}),J=[{pubkey:T.lookupTable,isSigner:!1,isWritable:!0},{pubkey:T.authority,isSigner:!0,isWritable:!1}];if(T.payer)J.push({pubkey:T.payer,isSigner:!0,isWritable:!0},{pubkey:K0.programId,isSigner:!1,isWritable:!1});return new Z1({programId:this.programId,keys:J,data:Q})}static deactivateLookupTable(T){let A=y2.DeactivateLookupTable,Q=W1(A),J=[{pubkey:T.lookupTable,isSigner:!1,isWritable:!0},{pubkey:T.authority,isSigner:!0,isWritable:!1}];return new Z1({programId:this.programId,keys:J,data:Q})}static closeLookupTable(T){let A=y2.CloseLookupTable,Q=W1(A),J=[{pubkey:T.lookupTable,isSigner:!1,isWritable:!0},{pubkey:T.authority,isSigner:!0,isWritable:!1},{pubkey:T.recipient,isSigner:!1,isWritable:!0}];return new Z1({programId:this.programId,keys:J,data:Q})}}zP.programId=new a("AddressLookupTab1e1111111111111111111111111");var FQ=Object.freeze({RequestUnits:{index:0,layout:S.struct([S.u8("instruction"),S.u32("units"),S.u32("additionalFee")])},RequestHeapFrame:{index:1,layout:S.struct([S.u8("instruction"),S.u32("bytes")])},SetComputeUnitLimit:{index:2,layout:S.struct([S.u8("instruction"),S.u32("units")])},SetComputeUnitPrice:{index:3,layout:S.struct([S.u8("instruction"),rA("microLamports")])}});class FP{constructor(){}static requestUnits(T){let A=FQ.RequestUnits,Q=W1(A,T);return new Z1({keys:[],programId:this.programId,data:Q})}static requestHeapFrame(T){let A=FQ.RequestHeapFrame,Q=W1(A,T);return new Z1({keys:[],programId:this.programId,data:Q})}static setComputeUnitLimit(T){let A=FQ.SetComputeUnitLimit,Q=W1(A,T);return new Z1({keys:[],programId:this.programId,data:Q})}static setComputeUnitPrice(T){let A=FQ.SetComputeUnitPrice,Q=W1(A,{microLamports:BigInt(T.microLamports)});return new Z1({keys:[],programId:this.programId,data:Q})}}FP.programId=new a("ComputeBudget111111111111111111111111111111");var oX=64,aX=32,sX=64,tX=S.struct([S.u8("numSignatures"),S.u8("padding"),S.u16("signatureOffset"),S.u16("signatureInstructionIndex"),S.u16("publicKeyOffset"),S.u16("publicKeyInstructionIndex"),S.u16("messageDataOffset"),S.u16("messageDataSize"),S.u16("messageInstructionIndex")]);class BW{constructor(){}static createInstructionWithPublicKey(T){let{publicKey:A,message:Q,signature:J,instructionIndex:$}=T;R0(A.length===aX,`Public Key must be ${aX} bytes but received ${A.length} bytes`),R0(J.length===sX,`Signature must be ${sX} bytes but received ${J.length} bytes`);let W=tX.span,G=W+A.length,Y=G+J.length,Z=1,C=w.alloc(Y+Q.length),K=$==null?65535:$;return tX.encode({numSignatures:Z,padding:0,signatureOffset:G,signatureInstructionIndex:K,publicKeyOffset:W,publicKeyInstructionIndex:K,messageDataOffset:Y,messageDataSize:Q.length,messageInstructionIndex:K},C),C.fill(A,W),C.fill(J,G),C.fill(Q,Y),new Z1({keys:[],programId:BW.programId,data:C})}static createInstructionWithPrivateKey(T){let{privateKey:A,message:Q,instructionIndex:J}=T;R0(A.length===oX,`Private key must be ${oX} bytes but received ${A.length} bytes`);try{let $=c2.fromSecretKey(A),W=$.publicKey.toBytes(),G=QP(Q,$.secretKey);return this.createInstructionWithPublicKey({publicKey:W,message:Q,signature:G,instructionIndex:J})}catch($){throw Error(`Error creating instruction; ${$}`)}}}BW.programId=new a("Ed25519SigVerify111111111111111111111111111");var dI=(T,A)=>{let Q=kQ.sign(T,A);return[Q.toCompactRawBytes(),Q.recovery]};kQ.utils.isValidPrivateKey;var cI=kQ.getPublicKey,eX=32,MW=20,TP=64,fI=11,kW=S.struct([S.u8("numSignatures"),S.u16("signatureOffset"),S.u8("signatureInstructionIndex"),S.u16("ethAddressOffset"),S.u8("ethAddressInstructionIndex"),S.u16("messageDataOffset"),S.u16("messageDataSize"),S.u8("messageInstructionIndex"),S.blob(20,"ethAddress"),S.blob(64,"signature"),S.u8("recoveryId")]);class f2{constructor(){}static publicKeyToEthAddress(T){R0(T.length===TP,`Public key must be ${TP} bytes but received ${T.length} bytes`);try{return w.from(PW(Y1(T))).slice(-MW)}catch(A){throw Error(`Error constructing Ethereum address: ${A}`)}}static createInstructionWithPublicKey(T){let{publicKey:A,message:Q,signature:J,recoveryId:$,instructionIndex:W}=T;return f2.createInstructionWithEthAddress({ethAddress:f2.publicKeyToEthAddress(A),message:Q,signature:J,recoveryId:$,instructionIndex:W})}static createInstructionWithEthAddress(T){let{ethAddress:A,message:Q,signature:J,recoveryId:$,instructionIndex:W=0}=T,G;if(typeof A==="string")if(A.startsWith("0x"))G=w.from(A.substr(2),"hex");else G=w.from(A,"hex");else G=A;R0(G.length===MW,`Address must be ${MW} bytes but received ${G.length} bytes`);let Y=1+fI,Z=Y,C=Y+G.length,K=C+J.length+1,j=1,M=w.alloc(kW.span+Q.length);return kW.encode({numSignatures:j,signatureOffset:C,signatureInstructionIndex:W,ethAddressOffset:Z,ethAddressInstructionIndex:W,messageDataOffset:K,messageDataSize:Q.length,messageInstructionIndex:W,signature:Y1(J),ethAddress:Y1(G),recoveryId:$},M),M.fill(Y1(Q),kW.span),new Z1({keys:[],programId:f2.programId,data:M})}static createInstructionWithPrivateKey(T){let{privateKey:A,message:Q,instructionIndex:J}=T;R0(A.length===eX,`Private key must be ${eX} bytes but received ${A.length} bytes`);try{let $=Y1(A),W=cI($,!1).slice(1),G=w.from(PW(Y1(Q))),[Y,Z]=dI(G,$);return this.createInstructionWithPublicKey({publicKey:W,message:Q,signature:Y,recoveryId:Z,instructionIndex:J})}catch($){throw Error(`Error creating instruction; ${$}`)}}}f2.programId=new a("KeccakSecp256k11111111111111111111111111111");var NP,rI=new a("StakeConfig11111111111111111111111111111111");class OQ{constructor(T,A,Q){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=T,this.epoch=A,this.custodian=Q}}NP=OQ;OQ.default=new NP(0,0,a.default);var v8=Object.freeze({Initialize:{index:0,layout:S.struct([S.u32("instruction"),UI(),YI()])},Authorize:{index:1,layout:S.struct([S.u32("instruction"),G1("newAuthorized"),S.u32("stakeAuthorizationType")])},Delegate:{index:2,layout:S.struct([S.u32("instruction")])},Split:{index:3,layout:S.struct([S.u32("instruction"),S.ns64("lamports")])},Withdraw:{index:4,layout:S.struct([S.u32("instruction"),S.ns64("lamports")])},Deactivate:{index:5,layout:S.struct([S.u32("instruction")])},Merge:{index:7,layout:S.struct([S.u32("instruction")])},AuthorizeWithSeed:{index:8,layout:S.struct([S.u32("instruction"),G1("newAuthorized"),S.u32("stakeAuthorizationType"),fA("authoritySeed"),G1("authorityOwner")])}}),cg=Object.freeze({Staker:{index:0},Withdrawer:{index:1}});class _W{constructor(){}static initialize(T){let{stakePubkey:A,authorized:Q,lockup:J}=T,$=J||OQ.default,W=v8.Initialize,G=W1(W,{authorized:{staker:Y1(Q.staker.toBuffer()),withdrawer:Y1(Q.withdrawer.toBuffer())},lockup:{unixTimestamp:$.unixTimestamp,epoch:$.epoch,custodian:Y1($.custodian.toBuffer())}}),Y={keys:[{pubkey:A,isSigner:!1,isWritable:!0},{pubkey:n2,isSigner:!1,isWritable:!1}],programId:this.programId,data:G};return new Z1(Y)}static createAccountWithSeed(T){let A=new j1;A.add(K0.createAccountWithSeed({fromPubkey:T.fromPubkey,newAccountPubkey:T.stakePubkey,basePubkey:T.basePubkey,seed:T.seed,lamports:T.lamports,space:this.space,programId:this.programId}));let{stakePubkey:Q,authorized:J,lockup:$}=T;return A.add(this.initialize({stakePubkey:Q,authorized:J,lockup:$}))}static createAccount(T){let A=new j1;A.add(K0.createAccount({fromPubkey:T.fromPubkey,newAccountPubkey:T.stakePubkey,lamports:T.lamports,space:this.space,programId:this.programId}));let{stakePubkey:Q,authorized:J,lockup:$}=T;return A.add(this.initialize({stakePubkey:Q,authorized:J,lockup:$}))}static delegate(T){let{stakePubkey:A,authorizedPubkey:Q,votePubkey:J}=T,$=v8.Delegate,W=W1($);return new j1().add({keys:[{pubkey:A,isSigner:!1,isWritable:!0},{pubkey:J,isSigner:!1,isWritable:!1},{pubkey:X8,isSigner:!1,isWritable:!1},{pubkey:DW,isSigner:!1,isWritable:!1},{pubkey:rI,isSigner:!1,isWritable:!1},{pubkey:Q,isSigner:!0,isWritable:!1}],programId:this.programId,data:W})}static authorize(T){let{stakePubkey:A,authorizedPubkey:Q,newAuthorizedPubkey:J,stakeAuthorizationType:$,custodianPubkey:W}=T,G=v8.Authorize,Y=W1(G,{newAuthorized:Y1(J.toBuffer()),stakeAuthorizationType:$.index}),Z=[{pubkey:A,isSigner:!1,isWritable:!0},{pubkey:X8,isSigner:!1,isWritable:!0},{pubkey:Q,isSigner:!0,isWritable:!1}];if(W)Z.push({pubkey:W,isSigner:!0,isWritable:!1});return new j1().add({keys:Z,programId:this.programId,data:Y})}static authorizeWithSeed(T){let{stakePubkey:A,authorityBase:Q,authoritySeed:J,authorityOwner:$,newAuthorizedPubkey:W,stakeAuthorizationType:G,custodianPubkey:Y}=T,Z=v8.AuthorizeWithSeed,C=W1(Z,{newAuthorized:Y1(W.toBuffer()),stakeAuthorizationType:G.index,authoritySeed:J,authorityOwner:Y1($.toBuffer())}),K=[{pubkey:A,isSigner:!1,isWritable:!0},{pubkey:Q,isSigner:!0,isWritable:!1},{pubkey:X8,isSigner:!1,isWritable:!1}];if(Y)K.push({pubkey:Y,isSigner:!0,isWritable:!1});return new j1().add({keys:K,programId:this.programId,data:C})}static splitInstruction(T){let{stakePubkey:A,authorizedPubkey:Q,splitStakePubkey:J,lamports:$}=T,W=v8.Split,G=W1(W,{lamports:$});return new Z1({keys:[{pubkey:A,isSigner:!1,isWritable:!0},{pubkey:J,isSigner:!1,isWritable:!0},{pubkey:Q,isSigner:!0,isWritable:!1}],programId:this.programId,data:G})}static split(T,A){let Q=new j1;return Q.add(K0.createAccount({fromPubkey:T.authorizedPubkey,newAccountPubkey:T.splitStakePubkey,lamports:A,space:this.space,programId:this.programId})),Q.add(this.splitInstruction(T))}static splitWithSeed(T,A){let{stakePubkey:Q,authorizedPubkey:J,splitStakePubkey:$,basePubkey:W,seed:G,lamports:Y}=T,Z=new j1;if(Z.add(K0.allocate({accountPubkey:$,basePubkey:W,seed:G,space:this.space,programId:this.programId})),A&&A>0)Z.add(K0.transfer({fromPubkey:T.authorizedPubkey,toPubkey:$,lamports:A}));return Z.add(this.splitInstruction({stakePubkey:Q,authorizedPubkey:J,splitStakePubkey:$,lamports:Y}))}static merge(T){let{stakePubkey:A,sourceStakePubKey:Q,authorizedPubkey:J}=T,$=v8.Merge,W=W1($);return new j1().add({keys:[{pubkey:A,isSigner:!1,isWritable:!0},{pubkey:Q,isSigner:!1,isWritable:!0},{pubkey:X8,isSigner:!1,isWritable:!1},{pubkey:DW,isSigner:!1,isWritable:!1},{pubkey:J,isSigner:!0,isWritable:!1}],programId:this.programId,data:W})}static withdraw(T){let{stakePubkey:A,authorizedPubkey:Q,toPubkey:J,lamports:$,custodianPubkey:W}=T,G=v8.Withdraw,Y=W1(G,{lamports:$}),Z=[{pubkey:A,isSigner:!1,isWritable:!0},{pubkey:J,isSigner:!1,isWritable:!0},{pubkey:X8,isSigner:!1,isWritable:!1},{pubkey:DW,isSigner:!1,isWritable:!1},{pubkey:Q,isSigner:!0,isWritable:!1}];if(W)Z.push({pubkey:W,isSigner:!0,isWritable:!1});return new j1().add({keys:Z,programId:this.programId,data:Y})}static deactivate(T){let{stakePubkey:A,authorizedPubkey:Q}=T,J=v8.Deactivate,$=W1(J);return new j1().add({keys:[{pubkey:A,isSigner:!1,isWritable:!0},{pubkey:X8,isSigner:!1,isWritable:!1},{pubkey:Q,isSigner:!0,isWritable:!1}],programId:this.programId,data:$})}}_W.programId=new a("Stake11111111111111111111111111111111111111");_W.space=200;var b2=Object.freeze({InitializeAccount:{index:0,layout:S.struct([S.u32("instruction"),ZI()])},Authorize:{index:1,layout:S.struct([S.u32("instruction"),G1("newAuthorized"),S.u32("voteAuthorizationType")])},Withdraw:{index:3,layout:S.struct([S.u32("instruction"),S.ns64("lamports")])},UpdateValidatorIdentity:{index:4,layout:S.struct([S.u32("instruction")])},AuthorizeWithSeed:{index:10,layout:S.struct([S.u32("instruction"),XI()])}}),fg=Object.freeze({Voter:{index:0},Withdrawer:{index:1}});class BQ{constructor(){}static initializeAccount(T){let{votePubkey:A,nodePubkey:Q,voteInit:J}=T,$=b2.InitializeAccount,W=W1($,{voteInit:{nodePubkey:Y1(J.nodePubkey.toBuffer()),authorizedVoter:Y1(J.authorizedVoter.toBuffer()),authorizedWithdrawer:Y1(J.authorizedWithdrawer.toBuffer()),commission:J.commission}}),G={keys:[{pubkey:A,isSigner:!1,isWritable:!0},{pubkey:n2,isSigner:!1,isWritable:!1},{pubkey:X8,isSigner:!1,isWritable:!1},{pubkey:Q,isSigner:!0,isWritable:!1}],programId:this.programId,data:W};return new Z1(G)}static createAccount(T){let A=new j1;return A.add(K0.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:Q,newAuthorizedPubkey:J,voteAuthorizationType:$}=T,W=b2.Authorize,G=W1(W,{newAuthorized:Y1(J.toBuffer()),voteAuthorizationType:$.index}),Y=[{pubkey:A,isSigner:!1,isWritable:!0},{pubkey:X8,isSigner:!1,isWritable:!1},{pubkey:Q,isSigner:!0,isWritable:!1}];return new j1().add({keys:Y,programId:this.programId,data:G})}static authorizeWithSeed(T){let{currentAuthorityDerivedKeyBasePubkey:A,currentAuthorityDerivedKeyOwnerPubkey:Q,currentAuthorityDerivedKeySeed:J,newAuthorizedPubkey:$,voteAuthorizationType:W,votePubkey:G}=T,Y=b2.AuthorizeWithSeed,Z=W1(Y,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:Y1(Q.toBuffer()),currentAuthorityDerivedKeySeed:J,newAuthorized:Y1($.toBuffer()),voteAuthorizationType:W.index}}),C=[{pubkey:G,isSigner:!1,isWritable:!0},{pubkey:X8,isSigner:!1,isWritable:!1},{pubkey:A,isSigner:!0,isWritable:!1}];return new j1().add({keys:C,programId:this.programId,data:Z})}static withdraw(T){let{votePubkey:A,authorizedWithdrawerPubkey:Q,lamports:J,toPubkey:$}=T,W=b2.Withdraw,G=W1(W,{lamports:J}),Y=[{pubkey:A,isSigner:!1,isWritable:!0},{pubkey:$,isSigner:!1,isWritable:!0},{pubkey:Q,isSigner:!0,isWritable:!1}];return new j1().add({keys:Y,programId:this.programId,data:G})}static safeWithdraw(T,A,Q){if(T.lamports>A-Q)throw Error("Withdraw will leave vote account with insufficient funds.");return BQ.withdraw(T)}static updateValidatorIdentity(T){let{votePubkey:A,authorizedWithdrawerPubkey:Q,nodePubkey:J}=T,$=b2.UpdateValidatorIdentity,W=W1($),G=[{pubkey:A,isSigner:!1,isWritable:!0},{pubkey:J,isSigner:!0,isWritable:!1},{pubkey:Q,isSigner:!0,isWritable:!1}];return new j1().add({keys:G,programId:this.programId,data:W})}}BQ.programId=new a("Vote111111111111111111111111111111111111111");BQ.space=3762;var rg=new a("Va1idator1nfo111111111111111111111111111111"),ng=y({name:l(),website:A1(l()),details:A1(l()),iconUrl:A1(l()),keybaseUsername:A1(l())});var ig=new a("Vote111111111111111111111111111111111111111"),og=S.struct([G1("nodePubkey"),G1("authorizedWithdrawer"),S.u8("commission"),S.nu64(),S.seq(S.struct([S.nu64("slot"),S.u32("confirmationCount")]),S.offset(S.u32(),-8),"votes"),S.u8("rootSlotValid"),S.nu64("rootSlot"),S.nu64(),S.seq(S.struct([S.nu64("epoch"),G1("authorizedVoter")]),S.offset(S.u32(),-8),"authorizedVoters"),S.struct([S.seq(S.struct([G1("authorizedPubkey"),S.nu64("epochOfLastAuthorizedSwitch"),S.nu64("targetEpoch")]),32,"buf"),S.nu64("idx"),S.u8("isEmpty")],"priorVoters"),S.nu64(),S.seq(S.struct([S.nu64("epoch"),S.nu64("credits"),S.nu64("prevCredits")]),S.offset(S.u32(),-8),"epochCredits"),S.struct([S.nu64("slot"),S.nu64("timestamp")],"lastTimestamp")]);var AT=new a("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"),tg=new a("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"),lT=new a("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"),eg=new a("So11111111111111111111111111111111111111112"),Tm=new a("9pan9bMn5HatX4EJdBwg9VgCa7Uz5HL8N1m5D3NdXejP");var KA=(T)=>{let A=T.decode.bind(T),Q=T.encode.bind(T);return{decode:A,encode:Q}};var xW=n0(G8(),1),y8=n0(SP(),1);var xQ=(T)=>(A)=>{let Q=xW.blob(T,A),{encode:J,decode:$}=KA(Q),W=Q;return W.decode=(G,Y)=>{let Z=$(G,Y);return y8.toBigIntLE(Buffer.from(Z))},W.encode=(G,Y,Z)=>{let C=y8.toBufferLE(G,T);return J(C,Y,Z)},W},hQ=(T)=>(A)=>{let Q=xW.blob(T,A),{encode:J,decode:$}=KA(Q),W=Q;return W.decode=(G,Y)=>{let Z=$(G,Y);return y8.toBigIntBE(Buffer.from(Z))},W.encode=(G,Y,Z)=>{let C=y8.toBufferBE(G,T);return J(C,Y,Z)},W},LP=xQ(8),Wm=hQ(8),Gm=xQ(16),Um=hQ(16),Ym=xQ(24),Zm=hQ(24),Xm=xQ(32),Pm=hQ(32);var wP=n0(G8(),1);var EP=(T)=>{let A=wP.u8(T),{encode:Q,decode:J}=KA(A),$=A;return $.decode=(W,G)=>{return!!J(W,G)},$.encode=(W,G,Y)=>{let Z=Number(W);return Q(Z,G,Y)},$};var OP=n0(G8(),1);var hW=(T)=>{let A=OP.blob(32,T),{encode:Q,decode:J}=KA(A),$=A;return $.decode=(W,G)=>{let Y=J(W,G);return new a(Y)},$.encode=(W,G,Y)=>{let Z=W.toBuffer();return Q(Z,G,Y)},$};class BP extends Error{constructor(T){super(T)}}class gW extends BP{constructor(){super(...arguments);this.name="TokenOwnerOffCurveError"}}var oA;(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"})(oA||(oA={}));var CA=n0(G8(),1);function _P(T,A,Q){if(Q.length){T.push({pubkey:A,isSigner:!1,isWritable:!1});for(let J of Q)T.push({pubkey:J instanceof a?J:J.publicKey,isSigner:!0,isWritable:!1})}else T.push({pubkey:A,isSigner:!0,isWritable:!1});return T}var AS=CA.struct([CA.u32("mintAuthorityOption"),hW("mintAuthority"),LP("supply"),CA.u8("decimals"),EP("isInitialized"),CA.u32("freezeAuthorityOption"),hW("freezeAuthority")]),Om=AS.span;function i2(T,A,Q=!1,J=AT,$=lT){if(!Q&&!a.isOnCurve(A.toBuffer()))throw new gW;let[W]=a.findProgramAddressSync([A.toBuffer(),J.toBuffer(),T.toBuffer()],$);return W}var gQ=n0(G8(),1);var xP=gQ.struct([gQ.u8("instruction")]);function mW(T,A,Q,J=[],$=AT){let W=_P([{pubkey:T,isSigner:!1,isWritable:!0},{pubkey:A,isSigner:!1,isWritable:!0}],Q,J),G=Buffer.alloc(xP.span);return xP.encode({instruction:oA.CloseAccount},G),new Z1({keys:W,programId:$,data:G})}function mQ(T,A,Q,J,$=AT,W=lT){return QS(T,A,Q,J,Buffer.alloc(0),$,W)}function QS(T,A,Q,J,$,W=AT,G=lT){let Y=[{pubkey:T,isSigner:!0,isWritable:!0},{pubkey:A,isSigner:!1,isWritable:!0},{pubkey:Q,isSigner:!1,isWritable:!1},{pubkey:J,isSigner:!1,isWritable:!1},{pubkey:K0.programId,isSigner:!1,isWritable:!1},{pubkey:W,isSigner:!1,isWritable:!1}];return new Z1({keys:Y,programId:G,data:$})}var vQ=n0(G8(),1);var hP=vQ.struct([vQ.u8("instruction")]);function gP(T,A=AT){let Q=[{pubkey:T,isSigner:!1,isWritable:!0}],J=Buffer.alloc(hP.span);return hP.encode({instruction:oA.SyncNative},J),new Z1({keys:Q,programId:A,data:J})}function yQ(T){if(typeof T==="string")return new a(T);if(typeof T==="object"&&"address"in T)return new a(T.address);return new a(T)}function mP(T){if(T instanceof a)return T;return yQ(T)}function JS(T){return{programAddress:_(T.programId.toBase58()),accounts:T.keys.map((A)=>({address:_(A.pubkey.toBase58()),role:A.isSigner?A.isWritable?$1.WRITABLE_SIGNER:$1.READONLY_SIGNER:A.isWritable?$1.WRITABLE:$1.READONLY})),data:T.data}}function aA(T){let{payer:A,owner:Q,mint:J,tokenProgram:$=AT,associatedTokenProgram:W=lT}=T,G=yQ(A),Y=yQ(Q),Z=yQ(J),C=mP($),K=mP(W),j=i2(Z,Y,!1,C,K);return JS(mQ(G,j,Y,Z,C,K))}var em=new Uint8Array([143,52,146,187,219,123,76,155]);function WS(){return V0([["discriminator",E0(b0(),8)],["bump",D8()],["admin",Y0()],["flatFees",y6()],["feeTiers",F6(WZ())]])}function GS(T){return H8(T,WS())}async function vP(T,A,Q){let J=await US(T,A,Q);return j8(J),J}async function US(T,A,Q){let J=await V8(T,A,Q);return GS(J)}var P8=10000n,sA=(T,A,Q)=>{if(Q<=0n)throw Error("Division by zero (floor)");return T*A/Q},YS=(T,A,Q)=>{if(Q<=0n)throw Error("Division by zero (ceil)");let J=T*A,$=J/Q;return J%Q===0n?$:$+1n},vW=(T)=>{let A=BigInt(T.lpFeeBps),Q=BigInt(T.protocolFeeBps),J=BigInt(T.creatorFeeBps),$=A+Q,W=$+J;if(W>=P8)throw Error("Total fee basis points must be less than 10_000");return{totalFeeBps:W,combinedFeeBps:$}},yW=(T)=>{let A=T.virtualTokenReserves+T.realTokenReserves,Q=T.virtualSolReserves+T.realSolReserves;return A*Q};function yP(T,A,Q){if(Q<=0n)throw Error("Total SOL cost must be positive");let{combinedFeeBps:J}=vW(A),$=sA(Q,J,P8),W=sA(Q,BigInt(A.creatorFeeBps),P8),G=Q-$-W;if(G<=0n)throw Error("Net SOL after fees must be positive");let Y=yW(T),Z=T.virtualSolReserves+T.realSolReserves,C=T.virtualTokenReserves+T.realTokenReserves,K=Z+G,j=Y/K,M=C-j,z=M>T.realTokenReserves?T.realTokenReserves:M;if(z<=0n)throw Error("SOL amount is too small to purchase any tokens");let N=bQ(T,A,z);while(N.totalSolCostLamports>Q&&z>0n)z-=1n,N=bQ(T,A,z);if(N.totalSolCostLamports>Q)throw Error("Insufficient SOL to purchase any tokens with fees applied");return{tokenAmount:z,totalSolCostLamports:N.totalSolCostLamports,effectiveSolInLamports:N.effectiveSolInLamports,feeLamports:N.feeLamports,creatorFeeLamports:N.creatorFeeLamports}}function bQ(T,A,Q){if(Q<=0n)throw Error("Token amount must be positive");if(Q>T.realTokenReserves)throw Error("Token amount exceeds available reserves");let{combinedFeeBps:J,totalFeeBps:$}=vW(A),W=yW(T),G=T.virtualSolReserves+T.realSolReserves,Z=T.virtualTokenReserves+T.realTokenReserves-Q;if(Z<=0n)throw Error("Purchase would exhaust token reserves");let K=W/Z-G;if(K<=0n)throw Error("Resolved SOL input must be positive");let j=P8-$,M=YS(K,P8,j),z=sA(M,J,P8),N=sA(M,BigInt(A.creatorFeeBps),P8);return{tokenAmount:Q,totalSolCostLamports:M,effectiveSolInLamports:K,feeLamports:z,creatorFeeLamports:N}}function bP(T,A,Q){if(Q<=0n)throw Error("Token amount must be positive");let J=yW(T),$=T.virtualSolReserves+T.realSolReserves,G=T.virtualTokenReserves+T.realTokenReserves+Q,Y=J/G,Z=$-Y;if(Z<=0n)throw Error("No SOL output available for the given token amount");let{combinedFeeBps:C}=vW(A),K=sA(Z,C,P8),j=sA(Z,BigInt(A.creatorFeeBps),P8),M=Z-K-j;if(M<=0n)throw Error("SOL output after fees is non-positive");return{solOutputLamports:M,preFeeSolOutputLamports:Z,feeLamports:K,creatorFeeLamports:j}}var pP=_T,ZS=1e4,lP=(T,A)=>{if(!Number.isFinite(T)||T<=0)throw Error(`${A} must be a positive number`)},XS=(T)=>({lpFeeBps:T.lpFeeBps,protocolFeeBps:T.protocolFeeBps,creatorFeeBps:T.creatorFeeBps});async function uP(T,A,Q,J){let $=J?.curve?Promise.resolve(J.curve):(async()=>{let G=await BT(T);return(await k8(A,G,{commitment:Q})).data})(),W=J?.fees?Promise.resolve(J.fees):(async()=>{let G=await C2(),Y=await vP(A,G,{commitment:Q});return XS(Y.data.flatFees)})();try{let[G,Y]=await Promise.all([$,W]);return{curve:G,fees:Y}}catch(G){throw Error("Failed to load bonding curve state. Provide overrides or ensure the RPC endpoint can access Pump accounts.",{cause:G})}}function PS(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 pQ(T){lP(T.solAmount,"solAmount");let A=T.slippageBps??$T;WT(A);let Q=T.feeRecipient??pP,J=T.rpc,$=T.commitment??M1(),{curve:W,fees:G}=await uP(T.mint,J,$,{curve:T.curveStateOverride,fees:T.feeStructureOverride});if(W.complete)throw Error("Token has migrated to the AMM. Use ammBuy instead of curveBuy.");let Y=T.bondingCurveCreator?_(T.bondingCurveCreator):W.creator,Z=xT(T.solAmount),K=yP(W,G,Z).tokenAmount,j=bQ(W,G,K),z=iT(j.totalSolCostLamports,A)*2n,N=_(T.mint),[E]=await H1({owner:T.user.address,mint:N}),L;if(T.allowAtaCreation!==!1)try{if(!(await T.rpc.getAccountInfo(E,{encoding:"base64"}).send()).value)L=aA({payer:T.user,owner:T.user,mint:N})}catch(g){console.warn("[curveBuy] getAccountInfo failed for user ATA, defaulting to create",g),L=aA({payer:T.user,owner:T.user,mint:N})}let O=await hJ({user:T.user,mint:T.mint,tokenAmount:K,maxSolCostLamports:z,feeRecipient:Q,trackVolume:T.trackVolume,bondingCurveCreator:Y,rpc:J,commitment:$});if(L){let g=Object.assign({},O);return g.prepend=[L,...g.prepend??[]],g}return O}async function lQ(T){let A=T.slippageBps??$T;WT(A);let Q=T.feeRecipient??pP,J=T.rpc,$=T.commitment??M1(),{curve:W,fees:G}=await uP(T.mint,J,$,{curve:T.curveStateOverride,fees:T.feeStructureOverride});if(W.complete)throw Error("Token has migrated to the AMM. Use ammSell instead of curveSell.");let Y=T.bondingCurveCreator?_(T.bondingCurveCreator):W.creator,Z=T.useWalletPercentage??!1,C=_(T.mint),K;if(Z){let z=T.walletPercentage??100,N=PS(z),[E]=await H1({owner:_(T.user.address),mint:C,tokenProgram:_(j0)}),L=await J.getTokenAccountBalance(E).send(),O=BigInt(L.value.amount);if(O===0n)throw Error("Wallet token balance is zero; nothing to sell");if(K=O*N/BigInt(ZS),K<=0n)K=1n}else{if(T.tokenAmount===void 0)throw Error("tokenAmount is required when useWalletPercentage is false");lP(T.tokenAmount,"tokenAmount");let z=T.tokenDecimals??6;K=i8(T.tokenAmount,z)}let j=bP(W,G,K),M=n8(j.solOutputLamports,A);if(M<=0n)throw Error("Slippage settings would result in zero SOL output");return gJ({user:T.user,mint:T.mint,tokenAmountRaw:K,minSolOutputLamports:M,feeRecipient:Q,bondingCurveCreator:Y,rpc:J,commitment:$})}var b8=new TextEncoder,HA=C0();async function tA(T,A,Q,J){let $=new Uint8Array(2);$[0]=T&255,$[1]=T>>8&255;let[W]=await R1({programAddress:_(q0),seeds:[b8.encode("pool"),$,HA.encode(_(A)),HA.encode(_(Q)),HA.encode(_(J))]});return W}async function bW(T){let[A]=await R1({programAddress:_(q0),seeds:[b8.encode("pool_lp_mint"),HA.encode(_(T))]});return A}async function pW(T,A){let[Q]=await AZ({owner:T,mint:A});return Q}async function RT(T,A,Q){let[J]=await H1({owner:T,mint:A,tokenProgram:Q});return J}async function eA(){let[T]=await R1({programAddress:_(q0),seeds:[b8.encode("global_config")]});return T}async function dP(){let[T]=await R1({programAddress:_(q0),seeds:[b8.encode("global_volume_accumulator")]});return T}async function cP(T){let[A]=await R1({programAddress:_(q0),seeds:[b8.encode("user_volume_accumulator"),HA.encode(_(T))]});return A}async function o2(){let[T]=await R1({programAddress:_(q0),seeds:[b8.encode("__event_authority")]});return T}async function lW(){let[T]=await R1({programAddress:_(OT),seeds:[b8.encode("fee_config"),HA.encode(_(q0))]});return T}async function uW(T){let[A]=await R1({programAddress:_(q0),seeds:[b8.encode("creator_vault"),HA.encode(_(T))]});return A}async function dW(T,A,Q){let[J]=await H1({owner:T,mint:A,tokenProgram:Q});return J}var QT="";function qS(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 JT(T,A){return(Q)=>{if(!Q.value){if(A==="omitted")return;return Object.freeze({address:T,role:$1.READONLY})}let J=Q.isWritable?$1.WRITABLE:$1.READONLY;return Object.freeze({address:qS(Q.value),role:fP(Q.value)?I6(J):J,...fP(Q.value)?{signer:Q.value}:{}})}}function fP(T){return!!T&&typeof T==="object"&&"address"in T&&ET(T)}var KS=new Uint8Array([102,6,61,18,1,218,235,234]);function CS(){return Z0(X0([["discriminator",H0(M0(),8)],["baseAmountOut",D1()],["maxQuoteAmountIn",D1()]]),(T)=>({...T,discriminator:KS}))}function rP(T,A){let Q=A?.programAddress??QT,$={pool:{value:T.pool??null,isWritable:!1},user:{value:T.user??null,isWritable:!1},globalConfig:{value:T.globalConfig??null,isWritable:!1},baseMint:{value:T.baseMint??null,isWritable:!1},quoteMint:{value:T.quoteMint??null,isWritable:!1},userBaseTokenAccount:{value:T.userBaseTokenAccount??null,isWritable:!1},userQuoteTokenAccount:{value:T.userQuoteTokenAccount??null,isWritable:!1},poolBaseTokenAccount:{value:T.poolBaseTokenAccount??null,isWritable:!1},poolQuoteTokenAccount:{value:T.poolQuoteTokenAccount??null,isWritable:!1},protocolFeeRecipient:{value:T.protocolFeeRecipient??null,isWritable:!1},protocolFeeRecipientTokenAccount:{value:T.protocolFeeRecipientTokenAccount??null,isWritable:!1},baseTokenProgram:{value:T.baseTokenProgram??null,isWritable:!1},quoteTokenProgram:{value:T.quoteTokenProgram??null,isWritable:!1},systemProgram:{value:T.systemProgram??null,isWritable:!1},associatedTokenProgram:{value:T.associatedTokenProgram??null,isWritable:!1},eventAuthority:{value:T.eventAuthority??null,isWritable:!1},program:{value:T.program??null,isWritable:!1}},W={...T};if(!$.systemProgram.value)$.systemProgram.value="11111111111111111111111111111111";let G=JT(Q,"programId");return Object.freeze({accounts:[G($.pool),G($.user),G($.globalConfig),G($.baseMint),G($.quoteMint),G($.userBaseTokenAccount),G($.userQuoteTokenAccount),G($.poolBaseTokenAccount),G($.poolQuoteTokenAccount),G($.protocolFeeRecipient),G($.protocolFeeRecipientTokenAccount),G($.baseTokenProgram),G($.quoteTokenProgram),G($.systemProgram),G($.associatedTokenProgram),G($.eventAuthority),G($.program)],data:CS().encode(W),programAddress:Q})}var _v=new Uint8Array([201,207,243,114,75,111,47,189]);var mv=new Uint8Array([233,146,209,142,207,104,64,188]);var HS=new Uint8Array([242,35,198,137,82,225,242,182]);function VS(){return Z0(X0([["discriminator",H0(M0(),8)],["lpTokenAmountOut",D1()],["maxBaseAmountIn",D1()],["maxQuoteAmountIn",D1()]]),(T)=>({...T,discriminator:HS}))}function nP(T,A){let Q=A?.programAddress??QT,$={pool:{value:T.pool??null,isWritable:!1},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:!1},userBaseTokenAccount:{value:T.userBaseTokenAccount??null,isWritable:!1},userQuoteTokenAccount:{value:T.userQuoteTokenAccount??null,isWritable:!1},userPoolTokenAccount:{value:T.userPoolTokenAccount??null,isWritable:!1},poolBaseTokenAccount:{value:T.poolBaseTokenAccount??null,isWritable:!1},poolQuoteTokenAccount:{value:T.poolQuoteTokenAccount??null,isWritable:!1},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(!$.tokenProgram.value)$.tokenProgram.value="TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";let G=JT(Q,"programId");return Object.freeze({accounts:[G($.pool),G($.globalConfig),G($.user),G($.baseMint),G($.quoteMint),G($.lpMint),G($.userBaseTokenAccount),G($.userQuoteTokenAccount),G($.userPoolTokenAccount),G($.poolBaseTokenAccount),G($.poolQuoteTokenAccount),G($.tokenProgram),G($.token2022Program),G($.eventAuthority),G($.program)],data:VS().encode(W),programAddress:Q})}var cv=new Uint8Array([185,173,187,90,216,15,238,233]);var iv=new Uint8Array([234,102,194,203,150,72,62,229]);var jS=new Uint8Array([51,230,133,164,1,127,131,173]);function RS(){return Z0(X0([["discriminator",H0(M0(),8)],["baseAmountIn",D1()],["minQuoteAmountOut",D1()]]),(T)=>({...T,discriminator:jS}))}function iP(T,A){let Q=A?.programAddress??QT,$={pool:{value:T.pool??null,isWritable:!1},user:{value:T.user??null,isWritable:!1},globalConfig:{value:T.globalConfig??null,isWritable:!1},baseMint:{value:T.baseMint??null,isWritable:!1},quoteMint:{value:T.quoteMint??null,isWritable:!1},userBaseTokenAccount:{value:T.userBaseTokenAccount??null,isWritable:!1},userQuoteTokenAccount:{value:T.userQuoteTokenAccount??null,isWritable:!1},poolBaseTokenAccount:{value:T.poolBaseTokenAccount??null,isWritable:!1},poolQuoteTokenAccount:{value:T.poolQuoteTokenAccount??null,isWritable:!1},protocolFeeRecipient:{value:T.protocolFeeRecipient??null,isWritable:!1},protocolFeeRecipientTokenAccount:{value:T.protocolFeeRecipientTokenAccount??null,isWritable:!1},baseTokenProgram:{value:T.baseTokenProgram??null,isWritable:!1},quoteTokenProgram:{value:T.quoteTokenProgram??null,isWritable:!1},systemProgram:{value:T.systemProgram??null,isWritable:!1},associatedTokenProgram:{value:T.associatedTokenProgram??null,isWritable:!1},eventAuthority:{value:T.eventAuthority??null,isWritable:!1},program:{value:T.program??null,isWritable:!1}},W={...T};if(!$.systemProgram.value)$.systemProgram.value="11111111111111111111111111111111";let G=JT(Q,"programId");return Object.freeze({accounts:[G($.pool),G($.user),G($.globalConfig),G($.baseMint),G($.quoteMint),G($.userBaseTokenAccount),G($.userQuoteTokenAccount),G($.poolBaseTokenAccount),G($.poolQuoteTokenAccount),G($.protocolFeeRecipient),G($.protocolFeeRecipientTokenAccount),G($.baseTokenProgram),G($.quoteTokenProgram),G($.systemProgram),G($.associatedTokenProgram),G($.eventAuthority),G($.program)],data:RS().encode(W),programAddress:Q})}var Qy=new Uint8Array([161,176,40,213,60,184,179,228]);var Gy=new Uint8Array([104,184,103,242,88,151,107,20]);var DS=new Uint8Array([183,18,70,156,148,109,161,34]);function MS(){return Z0(X0([["discriminator",H0(M0(),8)],["lpTokenAmountIn",D1()],["minBaseAmountOut",D1()],["minQuoteAmountOut",D1()]]),(T)=>({...T,discriminator:DS}))}function oP(T,A){let Q=A?.programAddress??QT,$={pool:{value:T.pool??null,isWritable:!1},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:!1},userBaseTokenAccount:{value:T.userBaseTokenAccount??null,isWritable:!1},userQuoteTokenAccount:{value:T.userQuoteTokenAccount??null,isWritable:!1},userPoolTokenAccount:{value:T.userPoolTokenAccount??null,isWritable:!1},poolBaseTokenAccount:{value:T.poolBaseTokenAccount??null,isWritable:!1},poolQuoteTokenAccount:{value:T.poolQuoteTokenAccount??null,isWritable:!1},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(!$.tokenProgram.value)$.tokenProgram.value="TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";let G=JT(Q,"programId");return Object.freeze({accounts:[G($.pool),G($.globalConfig),G($.user),G($.baseMint),G($.quoteMint),G($.lpMint),G($.userBaseTokenAccount),G($.userQuoteTokenAccount),G($.userPoolTokenAccount),G($.poolBaseTokenAccount),G($.poolQuoteTokenAccount),G($.tokenProgram),G($.token2022Program),G($.eventAuthority),G($.program)],data:MS().encode(W),programAddress:Q})}var Iy=new Uint8Array([241,154,109,4,17,177,109,188]);function kS(){return V0([["discriminator",E0(b0(),8)],["poolBump",D8()],["index",fU()],["creator",Y0()],["baseMint",Y0()],["quoteMint",Y0()],["lpMint",Y0()],["poolBaseTokenAccount",Y0()],["poolQuoteTokenAccount",Y0()],["lpSupply",L1()]])}function zS(T){return H8(T,kS())}async function uQ(T,A,Q){let J=await FS(T,A,Q);return j8(J),J}async function FS(T,A,Q){let J=await V8(T,A,Q);return zS(J)}var wy=new Uint8Array([149,8,156,202,160,252,176,217]);function NS(){return V0([["discriminator",E0(b0(),8)],["admin",Y0()],["lpFeeBasisPoints",L1()],["protocolFeeBasisPoints",L1()],["disableFlags",D8()],["protocolFeeRecipients",F6(Y0(),{size:8})]])}function IS(T){return H8(T,NS())}async function dQ(T,A,Q){let J=await SS(T,A,Q);return j8(J),J}async function SS(T,A,Q){let J=await V8(T,A,Q);return IS(J)}var cW=0;async function aP(T){let{user:A,baseMint:Q,quoteMint:J,index:$=cW,poolAddress:W,poolCreator:G,maxBaseIn:Y,maxQuoteIn:Z,minLpOut:C=0n,tokenProgram:K=j0,token2022Program:j=q2}=T;if(Y<=0n)throw Error("maxBaseIn must be positive");if(Z<=0n)throw Error("maxQuoteIn must be positive");if(C<0n)throw Error("minLpOut cannot be negative");let M=_(A.address),z=_(Q),N=_(J),E=_(K),L=_(j),O=W?_(W):await tA($,_(G??M),z,N),g=await eA(),v=await bW(O),p=await pW(M,v),[c]=await H1({owner:M,tokenProgram:E,mint:z}),[u]=await H1({owner:M,tokenProgram:E,mint:N}),i=await RT(O,z,E),d=await RT(O,N,E),h=await o2();return nP({pool:O,globalConfig:g,user:A,baseMint:z,quoteMint:N,lpMint:v,userBaseTokenAccount:c,userQuoteTokenAccount:u,userPoolTokenAccount:p,poolBaseTokenAccount:i,poolQuoteTokenAccount:d,tokenProgram:E,token2022Program:L,eventAuthority:h,program:_(q0),lpTokenAmountOut:C,maxBaseAmountIn:Y,maxQuoteAmountIn:Z},{programAddress:_(q0)})}async function sP(T){let{user:A,baseMint:Q,quoteMint:J,index:$=cW,poolAddress:W,poolCreator:G,lpAmountIn:Y,minBaseOut:Z=0n,minQuoteOut:C=0n,tokenProgram:K=j0,token2022Program:j=q2}=T;if(Y<=0n)throw Error("lpAmountIn must be positive");if(Z<0n)throw Error("minBaseOut cannot be negative");if(C<0n)throw Error("minQuoteOut cannot be negative");let M=_(A.address),z=_(Q),N=_(J),E=_(K),L=_(j),O=W?_(W):await tA($,_(G??M),z,N),g=await eA(),v=await bW(O),p=await pW(M,v),[c]=await H1({owner:M,tokenProgram:E,mint:z}),[u]=await H1({owner:M,tokenProgram:E,mint:N}),i=await RT(O,z,E),d=await RT(O,N,E),h=await o2();return oP({pool:O,globalConfig:g,user:A,baseMint:z,quoteMint:N,lpMint:v,userBaseTokenAccount:c,userQuoteTokenAccount:u,userPoolTokenAccount:p,poolBaseTokenAccount:i,poolQuoteTokenAccount:d,tokenProgram:E,token2022Program:L,eventAuthority:h,program:_(q0),lpTokenAmountIn:Y,minBaseAmountOut:Z,minQuoteAmountOut:C},{programAddress:_(q0)})}async function tP(T){let{user:A,baseMint:Q,quoteMint:J,tokenAmountOut:$,maxQuoteIn:W,rpc:G,allowTrackVolume:Y=!0,commitment:Z}=T;if($<=0n)throw Error("tokenAmountOut must be positive");if(W<=0n)throw Error("maxQuoteIn must be positive");let C=Z??M1(),K=_(A.address),j=_(Q),M=_(J),z=_(j0),N=await Tq(T,K),{poolData:E,globalConfigData:L,globalConfigAddress:O,coinCreator:g}=await Aq(G,N,C),v=Qq(L.protocolFeeRecipients);if(!v)throw Error("Global config does not define a protocol fee recipient");let[p]=await H1({owner:K,tokenProgram:z,mint:j}),[c]=await H1({owner:K,tokenProgram:z,mint:M}),u=await RT(N,j,z),i=await RT(N,M,z),[d]=await H1({owner:v,tokenProgram:z,mint:M}),h=await o2(),o=g?_(g):E.creator,n=await uW(o),x=await dW(n,M,z),[R,U]=Y?await Promise.all([dP(),cP(K)]):[void 0,void 0],X=await lW(),q=rP({pool:N,user:A,globalConfig:O,baseMint:j,quoteMint:M,userBaseTokenAccount:p,userQuoteTokenAccount:c,poolBaseTokenAccount:u,poolQuoteTokenAccount:i,protocolFeeRecipient:v,protocolFeeRecipientTokenAccount:d,baseTokenProgram:z,quoteTokenProgram:z,systemProgram:_(f8),associatedTokenProgram:_(K2),eventAuthority:h,program:_(q0),baseAmountOut:$,maxQuoteAmountIn:W},{programAddress:_(q0)}),H=new Set([N,p,c,u,i,d].map((I)=>_(I))),V=q.accounts.map((I)=>H.has(_(I.address))?{...I,role:$1.WRITABLE}:I),F=[{address:x,role:$1.WRITABLE},{address:n,role:$1.READONLY},...Y&&R&&U?[{address:R,role:$1.WRITABLE},{address:U,role:$1.WRITABLE}]:[],{address:X,role:$1.READONLY},{address:_(OT),role:$1.READONLY}];return{programAddress:q.programAddress,accounts:[...V,...F],data:q.data}}async function eP(T){let{user:A,baseMint:Q,quoteMint:J,tokenAmountIn:$,minQuoteOut:W,rpc:G,commitment:Y}=T;if($<=0n)throw Error("tokenAmountIn must be positive");if(W<=0n)throw Error("minQuoteOut must be positive");let Z=Y??M1(),C=_(A.address),K=_(Q),j=_(J),M=_(j0),z=await Tq(T,C),{poolData:N,globalConfigData:E,globalConfigAddress:L,coinCreator:O}=await Aq(G,z,Z),g=Qq(E.protocolFeeRecipients);if(!g)throw Error("Global config does not define a protocol fee recipient");let[v]=await H1({owner:C,tokenProgram:M,mint:K}),[p]=await H1({owner:C,tokenProgram:M,mint:j}),c=await RT(z,K,M),u=await RT(z,j,M),[i]=await H1({owner:g,tokenProgram:M,mint:j}),d=await o2(),h=O?_(O):N.creator,o=await uW(h),n=await dW(o,j,M),x=await lW(),R=iP({pool:z,user:A,globalConfig:L,baseMint:K,quoteMint:j,userBaseTokenAccount:v,userQuoteTokenAccount:p,poolBaseTokenAccount:c,poolQuoteTokenAccount:u,protocolFeeRecipient:g,protocolFeeRecipientTokenAccount:i,baseTokenProgram:M,quoteTokenProgram:M,systemProgram:_(f8),associatedTokenProgram:_(K2),eventAuthority:d,program:_(q0),baseAmountIn:$,minQuoteAmountOut:W},{programAddress:_(q0)}),U=new Set([z,v,p,c,u,i].map((H)=>_(H))),X=R.accounts.map((H)=>U.has(_(H.address))?{...H,role:$1.WRITABLE}:H),q=[{address:n,role:$1.WRITABLE},{address:o,role:$1.READONLY},{address:x,role:$1.READONLY},{address:_(OT),role:$1.READONLY}];return{programAddress:R.programAddress,accounts:[...X,...q],data:R.data}}async function Tq(T,A){if(T.poolAddress)return _(T.poolAddress);let Q=T.index??cW,J=_(T.poolCreator??A);return await tA(Q,J,_(T.baseMint),_(T.quoteMint))}async function Aq(T,A,Q){let J=await eA(),[$,W]=await Promise.all([uQ(T,A,{commitment:Q}),dQ(T,J,{commitment:Q})]),G;try{let Y=await BT($.data.baseMint);G=(await k8(T,Y,{commitment:Q})).data.creator}catch{G=void 0}return{poolData:$.data,globalConfigData:W.data,globalConfigAddress:J,coinCreator:G}}function Qq(T){let A=T.filter(Boolean);return A.length>0?_(A[0]):null}function LS(T){let{owner:A,amount:Q,payer:J=A,associatedTokenAddress:$,createAta:W=!0,autoClose:G=!1}=T;if(Q<=0n)throw Error("Amount must be positive when wrapping SOL");let Y=fW(A),Z=fW(J),C=$?new a($):i2(new a(uT),Y,!1,AT,lT),K=[],j=[];if(W)K.push(a2(mQ(Z,C,Y,new a(uT))));if(K.push(a2(K0.transfer({fromPubkey:Z,toPubkey:C,lamports:Number(Q)}))),K.push(a2(gP(C))),G)j.push(a2(mW(C,Z,Y)));return{prepend:K,append:j,associatedTokenAddress:_(C.toBase58())}}function wS(T,A){let Q=fW(T),J=A?new a(A):i2(new a(uT),Q,!1,AT,lT);return[a2(mW(J,Q,Q))]}function fW(T){if(typeof T==="string")return new a(T);if(typeof T==="object"&&"address"in T)return new a(T.address);return new a(T)}function a2(T){return{programAddress:_(T.programId.toBase58()),accounts:T.keys.map((A)=>({address:_(A.pubkey.toBase58()),role:A.isSigner?A.isWritable?$1.WRITABLE_SIGNER:$1.READONLY_SIGNER:A.isWritable?$1.WRITABLE:$1.READONLY})),data:T.data}}var uT="So11111111111111111111111111111111111111112";var cQ=_(j0),fQ=10000n,ES=10000n,Wq=(T,A)=>{if(!Number.isFinite(T)||T<=0)throw Error(`${A} must be a positive number`)},Gq=(T)=>_(T??uT);async function Uq(T){Wq(T.solAmount,"solAmount");let A=T.slippageBps??$T;WT(A);let Q=T.commitment??M1(),J=Gq(T.quoteMint),$=_(T.mint),W=xT(T.solAmount),G=await Zq({rpc:T.rpc,mint:$,quoteMint:J,commitment:Q,poolAddress:T.poolAddress,poolCreator:T.poolCreator,poolIndex:T.poolIndex}),Y=Pq(G.globalConfigData),Z=qq(W,Y);if(Z<=0n)throw Error("Effective quote input after fees is zero");let C=gS(Z,G.baseReserve,G.quoteReserve);if(C<=0n)throw Error("SOL amount is too small to purchase any tokens from the AMM");if(C>=G.baseReserve)C=G.baseReserve-1n;if(C<=0n)throw Error("AMM pool does not have enough base liquidity for this trade");let K=$q(C,G.quoteReserve,G.baseReserve,Y);while(K>W&&C>0n)C-=1n,K=$q(C,G.quoteReserve,G.baseReserve,Y);if(C<=0n||K<=0n)throw Error("Unable to satisfy AMM buy with the provided SOL budget");let j=iT(K,A),{createInstruction:M}=await vS({rpc:T.rpc,owner:T.user,mint:$}),z=await tP({user:T.user,baseMint:$,quoteMint:J,tokenAmountOut:C,maxQuoteIn:j,poolAddress:G.poolAddress,poolCreator:G.poolCreator,index:Number(G.poolData.index),allowTrackVolume:T.allowTrackVolume,rpc:T.rpc,commitment:Q});if(M){let N=Object.assign({},z);return N.prepend=[M,...N.prepend??[]],N}return z}async function Yq(T){let A=T.slippageBps??$T;WT(A);let Q=T.commitment??M1(),J=Gq(T.quoteMint),$=_(T.mint),W=await Zq({rpc:T.rpc,mint:$,quoteMint:J,commitment:Q,poolAddress:T.poolAddress,poolCreator:T.poolCreator,poolIndex:T.poolIndex}),G=await yS({params:T,rpc:T.rpc,mint:$});if(G<=0n)throw Error("Token amount must be positive");if(G>=W.baseReserve)throw Error("Token amount exceeds available AMM base liquidity");let Y=Pq(W.globalConfigData),Z=qq(G,Y);if(Z<=0n)throw Error("Effective base input after fees is zero");let C=mS(Z,W.baseReserve,W.quoteReserve);if(C<=0n)throw Error("AMM pool produced zero quote output");let K=n8(C,A);if(K<=0n)throw Error("Slippage settings would result in zero SOL output");return eP({user:T.user,baseMint:$,quoteMint:J,tokenAmountIn:G,minQuoteOut:K,poolAddress:W.poolAddress,poolCreator:W.poolCreator,index:Number(W.poolData.index),allowTrackVolume:T.allowTrackVolume,rpc:T.rpc,commitment:Q})}var OS=8;async function Zq(T){let{poolAccount:A,globalConfigAccount:Q,poolAddress:J,poolCreator:$,coinCreator:W}=await _S(T),[G,Y]=await Promise.all([RT(J,T.mint,cQ),RT(J,T.quoteMint,cQ)]),Z=await hS(T.rpc,G,Y);return{poolAddress:J,poolCreator:$,coinCreator:W,poolData:A.data,globalConfigData:Q.data,baseReserve:Z.baseReserve,quoteReserve:Z.quoteReserve}}var Xq=43,BS=Xq+32,Jq=(T)=>_(T);async function _S(T){let{rpc:A,mint:Q,quoteMint:J,commitment:$,poolAddress:W,poolCreator:G,poolIndex:Y}=T,Z=W?_(W):void 0,C=G?_(G):void 0,K;try{let E=await BT(Q);K=(await k8(A,E,{commitment:$})).data.creator}catch{K=void 0}let j=await eA(),M=async(E)=>{try{return await uQ(A,E,{commitment:$})}catch(L){if(xS(L))return null;throw L}},z=null;if(Z)z=await M(Z);if(!z&&C){let E=Y!==void 0?[Y]:Array.from({length:OS},(L,O)=>O);for(let L of E){let O=await tA(L,C,Q,J),g=await M(O);if(g){Z=O,z=g;break}}}if(!z){let E=[{memcmp:{offset:BigInt(Xq),bytes:Jq(Q),encoding:"base58"}},{memcmp:{offset:BigInt(BS),bytes:Jq(J),encoding:"base58"}}],O=await A.getProgramAccounts(_(q0),{commitment:$,encoding:"base64",filters:E}).send()??[];for(let g of O){let v=_(g.pubkey),p=await M(v);if(!p)continue;Z=v,C=p.data.creator,z=p;break}}if(!z||!Z)throw Error(`Unable to locate AMM pool for mint ${Q}. Provide poolAddress or poolIndex explicitly.`);let N=await dQ(A,j,{commitment:$});if(!C)C=z.data.creator;if(!K)K=z.data.creator;return{poolAccount:z,globalConfigAccount:N,poolAddress:Z,poolCreator:C,coinCreator:K}}function xS(T){if(!(T instanceof Error))return!1;if(T.message.toLowerCase().includes("account not found"))return!0;return T?.context?.__code===4100}async function hS(T,A,Q){let[J,$]=await Promise.all([T.getTokenAccountBalance(A).send(),T.getTokenAccountBalance(Q).send()]);return{baseReserve:BigInt(J.value.amount),quoteReserve:BigInt($.value.amount)}}function Pq(T){return BigInt(T.lpFeeBasisPoints??0n)+BigInt(T.protocolFeeBasisPoints??0n)}function qq(T,A){let Q=fQ-A;if(Q<=0n)return 0n;return T*Q/fQ}function gS(T,A,Q){let J=Q+T;if(J<=0n)throw Error("Invalid AMM reserves (denominator is zero)");return T*A/J}function $q(T,A,Q,J){if(T<=0n)return 0n;if(T>=Q)throw Error("Requested token amount exceeds pool reserves");let $=T*A/(Q-T);if($<=0n)return 0n;let W=fQ-J;if(W<=0n)throw Error("Invalid AMM fee configuration");return($*fQ+(W-1n))/W}function mS(T,A,Q){let J=A+T;if(J<=0n)throw Error("Invalid AMM reserves (denominator is zero)");return T*Q/J}async function vS({rpc:T,owner:A,mint:Q}){let[J]=await H1({owner:_(A.address),mint:Q,tokenProgram:cQ}),$;try{if(!(await T.getAccountInfo(J,{encoding:"base64"}).send()).value)$=aA({payer:A,owner:A,mint:Q})}catch{$=aA({payer:A,owner:A,mint:Q})}return{userAta:J,createInstruction:$}}async function yS({params:T,rpc:A,mint:Q}){let J=T.useWalletPercentage??!1,$=T.tokenDecimals??6;if(J){let W=T.walletPercentage??100,G=pS(W),Y=await bS(A,T.user,Q);if(Y===0n)throw Error("Wallet token balance is zero; nothing to sell");let Z=Y*G/ES;if(Z<=0n)Z=1n;return Z}if(T.tokenAmount===void 0)throw Error("tokenAmount is required when useWalletPercentage is false");return Wq(T.tokenAmount,"tokenAmount"),i8(T.tokenAmount,$)}async function bS(T,A,Q){let[J]=await H1({owner:_(A.address),mint:Q,tokenProgram:cQ}),$=await T.getTokenAccountBalance(J).send();return BigInt($.value.amount)}function pS(T){if(!Number.isFinite(T)||T<=0||T>100)throw Error("walletPercentage must be between 0 and 100");return BigInt(Math.round(T*100))}var lS=pQ,uS=lQ;async function rW(T){let{user:A,mint:Q,mintAuthority:J,name:$,symbol:W,uri:G,firstBuyTokenAmount:Y,estimatedFirstBuyCost:Z,slippageBps:C=$T,feeRecipient:K=_T,bondingCurveCreator:j,trackVolume:M,rpc:z,commitment:N=M1()}=T;if(WT(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(Y<=0n)throw Error("First buy token amount must be positive");if(Z<=0n)throw Error("Estimated first buy cost must be positive");let E=await ZZ({user:A,mint:Q,mintAuthority:J,name:$,symbol:W,uri:G}),L=iT(Z,C),O=await H2({user:A,mint:Q.address,tokenAmount:Y,maxSolCostLamports:L,feeRecipient:K,trackVolume:M??!0,bondingCurveCreator:j??A.address,rpc:z,commitment:N});return{createInstruction:E,buyInstruction:O}}function dS(T){let{name:A,symbol:Q,uri:J}=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(!Q||Q.length===0)throw Error("Token symbol is required");if(Q.length>10)throw Error("Token symbol too long (max 10 characters)");if(!J||J.length===0)throw Error("Metadata URI is required");if(!J.startsWith("http://")&&!J.startsWith("https://")&&!J.startsWith("ipfs://"))throw Error("Metadata URI must be a valid URL or IPFS link")}var Kq=_("ComputeBudget111111111111111111111111111111");async function nW({instructions:T,payer:A,additionalSigners:Q=[],latestBlockhash:J,lastValidBlockHeight:$,version:W="legacy",rpc:G,commitment:Y=M1(),prependInstructions:Z=[],appendInstructions:C=[],priorityFees:K}){let j=typeof A==="string"?_(A):A.address,M=MY({version:W}),z=Cq(K),N=[],E=[];for(let d of T)if("prepend"in d&&Array.isArray(d.prepend)){N.push(...d.prepend);let{prepend:h,...o}=d;E.push(o)}else E.push(d);let L=[...z,...N,...Z??[],...E,...C??[]],O=new Map;for(let d of L)if(M=FY(d,M),d.accounts){for(let h of d.accounts)if("signer"in h&&h.signer&&typeof h.signer==="object"&&"address"in h.signer){let o=h.signer;O.set(o.address,o)}}let g=zY(j,M),v=[];if(fS(A))g=nY(A,g),v.push(A);for(let d of O.values())if(!v.some((h)=>h.address===d.address))v.push(d);if(Q.length>0){for(let d of Q)if(ET(d)&&!v.some((h)=>h.address===d.address))v.push(d)}let p=v.length>0?rY(v,g):g,c=J,u=$!==void 0?BigInt($):void 0;if(!c||u===void 0){let{value:d}=await G.getLatestBlockhash({commitment:Y}).send();if(c=c??d.blockhash,u===void 0)u=BigInt(d.lastValidBlockHeight)}return{transactionMessage:VY({blockhash:c,lastValidBlockHeight:u},p),latestBlockhash:c,lastValidBlockHeight:u}}async function iW({instructions:T,payer:A,additionalSigners:Q=[],latestBlockhash:J,lastValidBlockHeight:$,version:W,prependInstructions:G,appendInstructions:Y,priorityFees:Z,rpc:C,rpcSubscriptions:K,commitment:j=M1(),sendOptions:M={}}){let z=await nW({instructions:T,payer:A,additionalSigners:Q,latestBlockhash:J,lastValidBlockHeight:$,version:W,prependInstructions:G,appendInstructions:Y,priorityFees:Z,rpc:C,commitment:j}),N=await SJ(z.transactionMessage),E=X2(N),L=tY({rpc:C,rpcSubscriptions:K}),O={commitment:j};if(M.abortSignal)O.abortSignal=M.abortSignal;if(M.skipPreflight!==void 0)O.skipPreflight=M.skipPreflight;if(M.minContextSlot!==void 0)O.minContextSlot=BigInt(M.minContextSlot);if(M.maxRetries!==void 0)O.maxRetries=M.maxRetries;if(M.preflightCommitment)O.preflightCommitment=M.preflightCommitment;await L(N,O);let v=(await C.getSignatureStatuses([E],{searchTransactionHistory:!1}).send()).value?.[0]??null;if(v?.err)try{let c=await C.getTransaction(E,{commitment:j,encoding:"json",maxSupportedTransactionVersion:0}).send(),u="Transaction failed";if(v.err)u=`Transaction failed: ${typeof v.err==="object"?JSON.stringify(v.err,(d,h)=>typeof h==="bigint"?h.toString():h):String(v.err)}`;if(c?.meta?.err)u=`Transaction failed: ${typeof c.meta.err==="object"?JSON.stringify(c.meta.err,(d,h)=>typeof h==="bigint"?h.toString():h):String(c.meta.err)}`;if(c?.meta?.logMessages){let i=c.meta.logMessages.filter((d)=>d.toLowerCase().includes("error")||d.includes("Program log:"));if(i.length>0)u+=`
14
+ For a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20.`,[eD]:"No signature verification implementation could be found.",[T7]:"No key generation implementation could be found.",[A7]:"No signing implementation could be found.",[C7]:"No key export implementation could be found.",[VD]:"Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",[$S]:"Transaction processing left an account with an outstanding borrowed reference",[oz]:"Account in use",[nz]:"Account loaded twice",[az]:"Attempt to debit an account but found no record of a prior credit.",[KS]:"Transaction loads an address table account that doesn't exist",[TS]:"This transaction has already been processed",[AS]:"Blockhash not found",[CS]:"Loader call chain is too deep",[US]:"Transactions are currently disabled due to cluster maintenance",[SS]:"Transaction contains a duplicate instruction ($index) that is not allowed",[tz]:"Insufficient funds for fee",[MS]:"Transaction results in an account ($accountIndex) with insufficient funds for rent",[ez]:"This account may not be used to pay transaction fees",[QS]:"Transaction contains an invalid account reference",[jS]:"Transaction loads an address table account with invalid data",[RS]:"Transaction address table lookup uses an invalid index",[kS]:"Transaction loads an address table account with an invalid owner",[NS]:"LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",[GS]:"This program may not be used for executing instructions",[FS]:"Transaction leaves an account with a lower balance than rent-exempt minimum",[ZS]:"Transaction loads a writable account that cannot be written",[IS]:"Transaction exceeded max loaded accounts data size cap",[PS]:"Transaction requires a fee but has no signature present",[sz]:"Attempt to load a program that does not exist",[wS]:"Execution of the program referenced by account at index $accountIndex is temporarily restricted.",[LS]:"ResanitizationNeeded",[JS]:"Transaction failed to sanitize accounts offsets correctly",[WS]:"Transaction did not pass signature verification",[HS]:"Transaction locked too many accounts",[ES]:"Sum of account balances before and after transaction do not match",[cz]:"The transaction failed with the error `$errorName`",[YS]:"Transaction version is unsupported",[XS]:"Transaction would exceed account data limit within the block",[zS]:"Transaction would exceed total account data limit",[qS]:"Transaction would exceed max account limit within the block",[VS]:"Transaction would exceed max Block Cost Limit",[DS]:"Transaction would exceed max Vote Cost Limit",[pz]:"Attempted to sign a transaction with an address that is not a signer for it",[gz]:"Transaction is missing an address at index: $index.",[uz]:"Transaction has no expected signers therefore it cannot be encoded",[iz]:"Transaction size $transactionSize exceeds limit of $transactionSizeLimit bytes",[wz]:"Transaction does not have a blockhash lifetime",[Ez]:"Transaction is not a durable nonce transaction",[Oz]:"Contents of these address lookup tables unknown: $lookupTableAddresses",[_z]:"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",[hz]:"No fee payer set in CompiledTransaction",[xz]:"Could not find program address at index $index",[rz]:"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",[fz]:"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",[vz]:"Transaction is missing a fee payer.",[yz]:"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",[lz]:"Transaction first instruction is not advance nonce account instruction.",[bz]:"Transaction with no instructions cannot be durable nonce transaction.",[Nz]:"This transaction includes an address (`$programAddress`) which is both invoked and set as the fee payer. Program addresses may not pay fees",[Lz]:"This transaction includes an address (`$programAddress`) which is both invoked and marked writable. Program addresses may not be writable",[dz]:"The transaction message expected the transaction to have $signerAddressesLength signatures, got $signaturesLength.",[mz]:"Transaction is missing signatures for addresses: $addresses.",[Bz]:"Transaction version must be in the range [0, 127]. `$actualVersion` given"},$A="i",u0="t";function CM(T,A={}){let C=AM[T];if(C.length===0)return"";let P;function Q(G){if(P[u0]===2){let U=C.slice(P[$A]+1,G);W.push(U in A?`${A[U]}`:`$${U}`)}else if(P[u0]===1)W.push(C.slice(P[$A],G))}let W=[];return C.split("").forEach((G,U)=>{if(U===0){P={[$A]:0,[u0]:C[0]==="\\"?0:C[0]==="$"?2:1};return}let $;switch(P[u0]){case 0:$={[$A]:U,[u0]:1};break;case 1:if(G==="\\")$={[$A]:U,[u0]:0};else if(G==="$")$={[$A]:U,[u0]:2};break;case 2:if(G==="\\")$={[$A]:U,[u0]:0};else if(G==="$")$={[$A]:U,[u0]:2};else if(!G.match(/\w/))$={[$A]:U,[u0]:1};break}if($){if(P!==$)Q(U);P=$}}),Q(),W.join("")}function PM(T,A={}){return CM(T,A)}var mA=class extends Error{cause=this.cause;context;constructor(...[T,A]){let C,P;if(A){let{cause:W,...G}=A;if(W)P={cause:W};if(Object.keys(G).length>0)C=G}let Q=PM(T,C);super(Q,P);this.context={__code:T,...C},this.name="SolanaError"}};function QM(T,A){return"fixedSize"in A?A.fixedSize:A.getSizeFromValue(T)}function o9(T){return Object.freeze({...T,encode:(A)=>{let C=new Uint8Array(QM(A,T));return T.write(A,C,0),C}})}function n9(T){return Object.freeze({...T,decode:(A,C=0)=>T.read(A,C)[0]})}function d8(T){return"fixedSize"in T&&typeof T.fixedSize==="number"}function a9(T,A){if(d8(T)!==d8(A))throw new mA(aQ);if(d8(T)&&d8(A)&&T.fixedSize!==A.fixedSize)throw new mA(sQ,{decoderFixedSize:A.fixedSize,encoderFixedSize:T.fixedSize});if(!d8(T)&&!d8(A)&&T.maxSize!==A.maxSize)throw new mA(tQ,{decoderMaxSize:A.maxSize,encoderMaxSize:T.maxSize});return{...A,...T,decode:A.decode,encode:T.encode,read:A.read,write:T.write}}function s9(T,A,C=0){if(A.length-C<=0)throw new mA(oQ,{codecDescription:T})}function t9(T,A,C,P=0){let Q=C.length-P;if(Q<A)throw new mA(nQ,{bytesLength:Q,codecDescription:T,expected:A})}function WM(T,A,C,P){if(P<A||P>C)throw new mA(eQ,{codecDescription:T,max:C,min:A,value:P})}function e9(T){return T?.endian===1?!1:!0}function GM(T){return o9({fixedSize:T.size,write(A,C,P){if(T.range)WM(T.name,T.range[0],T.range[1],A);let Q=new ArrayBuffer(T.size);return T.set(new DataView(Q),A,e9(T.config)),C.set(new Uint8Array(Q),P),P+T.size}})}function JM(T){return n9({fixedSize:T.size,read(A,C=0){s9(T.name,A,C),t9(T.name,T.size,A,C);let P=new DataView(UM(A,C,T.size));return[T.get(P,e9(T.config)),C+T.size]}})}function UM(T,A,C){let P=T.byteOffset+(A??0),Q=C??T.byteLength;return T.buffer.slice(P,P+Q)}var TW=(T={})=>GM({config:T,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(A,C,P)=>A.setBigUint64(0,BigInt(C),P),size:8}),$M=(T={})=>JM({config:T,get:(A,C)=>A.getBigUint64(0,C),name:"u64",size:8}),TV=(T={})=>a9(TW(T),$M(T));class CV extends TypeError{constructor(T,A){let C,{message:P,explanation:Q,...W}=T,{path:G}=T,U=G.length===0?P:`At path: ${G.join(".")} -- ${P}`;super(Q??U);if(Q!=null)this.cause=U;Object.assign(this,W),this.name=this.constructor.name,this.failures=()=>{return C??(C=[T,...A()])}}}function VM(T){return _2(T)&&typeof T[Symbol.iterator]==="function"}function _2(T){return typeof T==="object"&&T!=null}function jC(T){return _2(T)&&!Array.isArray(T)}function z0(T){if(typeof T==="symbol")return T.toString();return typeof T==="string"?JSON.stringify(T):`${T}`}function YM(T){let{done:A,value:C}=T.next();return A?void 0:C}function ZM(T,A,C,P){if(T===!0)return;else if(T===!1)T={};else if(typeof T==="string")T={message:T};let{path:Q,branch:W}=A,{type:G}=C,{refinement:U,message:$=`Expected a value of type \`${G}\`${U?` with refinement \`${U}\``:""}, but received: \`${z0(P)}\``}=T;return{value:P,type:G,refinement:U,key:Q[Q.length-1],path:Q,branch:W,...T,message:$}}function*AV(T,A,C,P){if(!VM(T))T=[T];for(let Q of T){let W=ZM(Q,A,C,P);if(W)yield W}}function*AW(T,A,C={}){let{path:P=[],branch:Q=[T],coerce:W=!1,mask:G=!1}=C,U={path:P,branch:Q,mask:G};if(W)T=A.coercer(T,U);let $="valid";for(let X of A.validator(T,U))X.explanation=C.message,$="not_valid",yield[X,void 0];for(let[X,q,K]of A.entries(T,U)){let F=AW(q,K,{path:X===void 0?P:[...P,X],branch:X===void 0?Q:[...Q,q],coerce:W,mask:G,message:C.message});for(let z of F)if(z[0])$=z[0].refinement!=null?"not_refined":"not_valid",yield[z[0],void 0];else if(W){if(q=z[1],X===void 0)T=q;else if(T instanceof Map)T.set(X,q);else if(T instanceof Set)T.add(q);else if(_2(T)){if(q!==void 0||X in T)T[X]=q}}}if($!=="not_valid")for(let X of A.refiner(T,U))X.explanation=C.message,$="not_refined",yield[X,void 0];if($==="valid")yield[void 0,T]}class S0{constructor(T){let{type:A,schema:C,validator:P,refiner:Q,coercer:W=(U)=>U,entries:G=function*(){}}=T;if(this.type=A,this.schema=C,this.entries=G,this.coercer=W,P)this.validator=(U,$)=>{let X=P(U,$);return AV(X,$,this,U)};else this.validator=()=>[];if(Q)this.refiner=(U,$)=>{let X=Q(U,$);return AV(X,$,this,U)};else this.refiner=()=>[]}assert(T,A){return PV(T,this,A)}create(T,A){return r8(T,this,A)}is(T){return QV(T,this)}mask(T,A){return qM(T,this,A)}validate(T,A={}){return x2(T,this,A)}}function PV(T,A,C){let P=x2(T,A,{message:C});if(P[0])throw P[0]}function r8(T,A,C){let P=x2(T,A,{coerce:!0,message:C});if(P[0])throw P[0];else return P[1]}function qM(T,A,C){let P=x2(T,A,{coerce:!0,mask:!0,message:C});if(P[0])throw P[0];else return P[1]}function QV(T,A){return!x2(T,A)[0]}function x2(T,A,C={}){let P=AW(T,A,C),Q=YM(P);if(Q[0])return[new CV(Q[0],function*(){for(let G of P)if(G[0])yield G[0]}),void 0];else return[void 0,Q[1]]}function Z8(T,A){return new S0({type:T,schema:null,validator:A})}function WV(){return Z8("any",()=>!0)}function s(T){return new S0({type:"array",schema:T,*entries(A){if(T&&Array.isArray(A))for(let[C,P]of A.entries())yield[C,P,T]},coercer(A){return Array.isArray(A)?A.slice():A},validator(A){return Array.isArray(A)||`Expected an array value, but received: ${z0(A)}`}})}function M0(){return Z8("boolean",(T)=>{return typeof T==="boolean"})}function RC(T){return Z8("instance",(A)=>{return A instanceof T||`Expected a \`${T.name}\` instance, but received: ${z0(A)}`})}function L1(T){let A=z0(T),C=typeof T;return new S0({type:"literal",schema:C==="string"||C==="number"||C==="boolean"?T:null,validator(P){return P===T||`Expected the literal \`${A}\`, but received: ${z0(P)}`}})}function XM(){return Z8("never",()=>!1)}function t(T){return new S0({...T,validator:(A,C)=>A===null||T.validator(A,C),refiner:(A,C)=>A===null||T.refiner(A,C)})}function O(){return Z8("number",(T)=>{return typeof T==="number"&&!isNaN(T)||`Expected a number, but received: ${z0(T)}`})}function A1(T){return new S0({...T,validator:(A,C)=>A===void 0||T.validator(A,C),refiner:(A,C)=>A===void 0||T.refiner(A,C)})}function CW(T,A){return new S0({type:"record",schema:null,*entries(C){if(_2(C))for(let P in C){let Q=C[P];yield[P,P,T],yield[P,Q,A]}},validator(C){return jC(C)||`Expected an object, but received: ${z0(C)}`},coercer(C){return jC(C)?{...C}:C}})}function p(){return Z8("string",(T)=>{return typeof T==="string"||`Expected a string, but received: ${z0(T)}`})}function FC(T){let A=XM();return new S0({type:"tuple",schema:null,*entries(C){if(Array.isArray(C)){let P=Math.max(T.length,C.length);for(let Q=0;Q<P;Q++)yield[Q,C[Q],T[Q]||A]}},validator(C){return Array.isArray(C)||`Expected an array, but received: ${z0(C)}`},coercer(C){return Array.isArray(C)?C.slice():C}})}function y(T){let A=Object.keys(T);return new S0({type:"type",schema:T,*entries(C){if(_2(C))for(let P of A)yield[P,C[P],T[P]]},validator(C){return jC(C)||`Expected an object, but received: ${z0(C)}`},coercer(C){return jC(C)?{...C}:C}})}function mT(T){let A=T.map((C)=>C.type).join(" | ");return new S0({type:"union",schema:null,coercer(C,P){for(let Q of T){let[W,G]=Q.validate(C,{coerce:!0,mask:P.mask});if(!W)return G}return C},validator(C,P){let Q=[];for(let W of T){let[...G]=AW(C,W,P),[U]=G;if(!U[0])return[];else for(let[$]of G)if($)Q.push($)}return[`Expected the value to satisfy a union of \`${A}\`, but received: ${z0(C)}`,...Q]}})}function q8(){return Z8("unknown",()=>!0)}function f8(T,A,C){return new S0({...T,coercer:(P,Q)=>{return QV(P,A)?T.coercer(C(P,Q),Q):T.coercer(P,Q)}})}var GI=nT(wV(),1);x8();var OV=nT(BV(),1);var pM=BigInt(0),p2=BigInt(1),uM=BigInt(2),dM=BigInt(7),rM=BigInt(256),fM=BigInt(113),hV=[],mV=[],gV=[];for(let T=0,A=p2,C=1,P=0;T<24;T++){[C,P]=[P,(2*C+3*P)%5],hV.push(2*(5*P+C)),mV.push((T+1)*(T+2)/2%64);let Q=pM;for(let W=0;W<7;W++)if(A=(A<<p2^(A>>dM)*fM)%rM,A&uM)Q^=p2<<(p2<<BigInt(W))-p2;gV.push(Q)}var vV=t6(gV,!0),iM=vV[0],cM=vV[1],_V=(T,A,C)=>C>32?r$(T,A,C):u$(T,A,C),xV=(T,A,C)=>C>32?f$(T,A,C):d$(T,A,C);function oM(T,A=24){let C=new Uint32Array(10);for(let P=24-A;P<24;P++){for(let G=0;G<10;G++)C[G]=T[G]^T[G+10]^T[G+20]^T[G+30]^T[G+40];for(let G=0;G<10;G+=2){let U=(G+8)%10,$=(G+2)%10,X=C[$],q=C[$+1],K=_V(X,q,1)^C[U],F=xV(X,q,1)^C[U+1];for(let z=0;z<50;z+=10)T[G+z]^=K,T[G+z+1]^=F}let Q=T[2],W=T[3];for(let G=0;G<24;G++){let U=mV[G],$=_V(Q,W,U),X=xV(Q,W,U),q=hV[G];Q=T[q],W=T[q+1],T[q]=$,T[q+1]=X}for(let G=0;G<50;G+=10){for(let U=0;U<10;U++)C[U]=T[G+U];for(let U=0;U<10;U++)T[G+U]^=~C[(U+2)%10]&C[(U+4)%10]}T[0]^=iM[P],T[1]^=cM[P]}K0(C)}class qW extends P8{constructor(T,A,C,P=!1,Q=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=C,this.enableXOF=P,this.rounds=Q,IA(C),!(0<T&&T<200))throw Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=v$(this.state)}clone(){return this._cloneInto()}keccak(){oP(this.state32),oM(this.state32,this.rounds),oP(this.state32),this.posOut=0,this.pos=0}update(T){TA(this),T=C8(T),ET(T);let{blockLen:A,state:C}=this,P=T.length;for(let Q=0;Q<P;){let W=Math.min(A-this.pos,P-Q);for(let G=0;G<W;G++)C[this.pos++]^=T[Q++];if(this.pos===A)this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:T,suffix:A,pos:C,blockLen:P}=this;if(T[C]^=A,(A&128)!==0&&C===P-1)this.keccak();T[P-1]^=128,this.keccak()}writeInto(T){TA(this,!1),ET(T),this.finish();let A=this.state,{blockLen:C}=this;for(let P=0,Q=T.length;P<Q;){if(this.posOut>=C)this.keccak();let W=Math.min(C-this.posOut,Q-P);T.set(A.subarray(this.posOut,this.posOut+W),P),this.posOut+=W,P+=W}return T}xofInto(T){if(!this.enableXOF)throw Error("XOF is not possible for this instance");return this.writeInto(T)}xof(T){return IA(T),this.xofInto(new Uint8Array(T))}digestInto(T){if(o6(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,K0(this.state)}_cloneInto(T){let{blockLen:A,suffix:C,outputLen:P,rounds:Q,enableXOF:W}=this;return T||(T=new qW(A,C,P,W,Q)),T.state32.set(this.state32),T.pos=this.pos,T.posOut=this.posOut,T.finished=this.finished,T.rounds=Q,T.suffix=C,T.outputLen=P,T.enableXOF=W,T.destroyed=this.destroyed,T}}var nM=(T,A,C)=>z2(()=>new qW(A,T,C));var XW=(()=>nM(1,136,32))();class HW extends P8{constructor(T,A){super();this.finished=!1,this.destroyed=!1,c6(T);let C=C8(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 P=this.blockLen,Q=new Uint8Array(P);Q.set(C.length>P?T.create().update(C).digest():C);for(let W=0;W<Q.length;W++)Q[W]^=54;this.iHash.update(Q),this.oHash=T.create();for(let W=0;W<Q.length;W++)Q[W]^=106;this.oHash.update(Q),K0(Q)}update(T){return TA(this),this.iHash.update(T),this}digestInto(T){TA(this),ET(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:C,finished:P,destroyed:Q,blockLen:W,outputLen:G}=this;return T=T,T.finished=P,T.destroyed=Q,T.blockLen=W,T.outputLen=G,T.oHash=A._cloneInto(T.oHash),T.iHash=C._cloneInto(T.iHash),T}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}var KW=(T,A,C)=>new HW(T,A).update(C).digest();KW.create=(T,A)=>new HW(T,A);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var yV=(T,A)=>(T+(T>=0?A:-A)/lV)/A;function aM(T,A,C){let[[P,Q],[W,G]]=A,U=yV(G*T,C),$=yV(-Q*T,C),X=T-U*P-$*W,q=-U*Q-$*G,K=X<YA,F=q<YA;if(K)X=-X;if(F)q=-q;let z=EA(Math.ceil(AC(C)/2))+c8;if(X<YA||X>=z||q<YA||q>=z)throw Error("splitScalar (endomorphism): failed, k="+T);return{k1neg:K,k1:X,k2neg:F,k2:q}}function jW(T){if(!["compact","recovered","der"].includes(T))throw Error('Signature format must be "compact", "recovered", or "der"');return T}function kW(T,A){let C={};for(let P of Object.keys(A))C[P]=T[P]===void 0?A[P]:T[P];if(CA(C.lowS,"lowS"),CA(C.prehash,"prehash"),C.format!==void 0)jW(C.format);return C}class bV extends Error{constructor(T=""){super(T)}}var VA={Err:bV,_tlv:{encode:(T,A)=>{let{Err:C}=VA;if(T<0||T>256)throw new C("tlv.encode: wrong tag");if(A.length&1)throw new C("tlv.encode: unpadded data");let P=A.length/2,Q=I2(P);if(Q.length/2&128)throw new C("tlv.encode: long form length too big");let W=P>127?I2(Q.length/2|128):"";return I2(T)+W+Q+A},decode(T,A){let{Err:C}=VA,P=0;if(T<0||T>256)throw new C("tlv.encode: wrong tag");if(A.length<2||A[P++]!==T)throw new C("tlv.decode: wrong tlv");let Q=A[P++],W=!!(Q&128),G=0;if(!W)G=Q;else{let $=Q&127;if(!$)throw new C("tlv.decode(long): indefinite length not supported");if($>4)throw new C("tlv.decode(long): byte length is too big");let X=A.subarray(P,P+$);if(X.length!==$)throw new C("tlv.decode: length bytes not complete");if(X[0]===0)throw new C("tlv.decode(long): zero leftmost byte");for(let q of X)G=G<<8|q;if(P+=$,G<128)throw new C("tlv.decode(long): not minimal encoding")}let U=A.subarray(P,P+G);if(U.length!==G)throw new C("tlv.decode: wrong value length");return{v:U,l:A.subarray(P+G)}}},_int:{encode(T){let{Err:A}=VA;if(T<YA)throw new A("integer: negative integers are not allowed");let C=I2(T);if(Number.parseInt(C[0],16)&8)C="00"+C;if(C.length&1)throw new A("unexpected DER parsing assertion: unpadded hex");return C},decode(T){let{Err:A}=VA;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 m8(T)}},toSig(T){let{Err:A,_int:C,_tlv:P}=VA,Q=K1("signature",T),{v:W,l:G}=P.decode(48,Q);if(G.length)throw new A("invalid signature: left bytes after parsing");let{v:U,l:$}=P.decode(2,W),{v:X,l:q}=P.decode(2,$);if(q.length)throw new A("invalid signature: left bytes after parsing");return{r:C.decode(U),s:C.decode(X)}},hexFromSig(T){let{_tlv:A,_int:C}=VA,P=A.encode(2,C.encode(T.r)),Q=A.encode(2,C.encode(T.s)),W=P+Q;return A.encode(48,W)}},YA=BigInt(0),c8=BigInt(1),lV=BigInt(2),IC=BigInt(3),sM=BigInt(4);function i8(T,A){let{BYTES:C}=T,P;if(typeof A==="bigint")P=A;else{let Q=K1("private key",A);try{P=T.fromBytes(Q)}catch(W){throw Error(`invalid private key: expected ui8a of size ${C}, got ${typeof A}`)}}if(!T.isValidNot0(P))throw Error("invalid private key: out of range [1..N-1]");return P}function tM(T,A={}){let C=PC("weierstrass",T,A),{Fp:P,Fn:Q}=C,W=C.CURVE,{h:G,n:U}=W;BA(A,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});let{endo:$}=A;if($){if(!P.is0(W.a)||typeof $.beta!=="bigint"||!Array.isArray($.basises))throw Error('invalid endo: expected "beta": bigint and "basises": array')}let X=uV(P,Q);function q(){if(!P.isOdd)throw Error("compression is not supported: Field does not have .isOdd()")}function K(x,j,J){let{x:V,y:Z}=j.toAffine(),H=P.toBytes(V);if(CA(J,"isCompressed"),J){q();let k=!P.isOdd(Z);return dT(pV(k),H)}else return dT(Uint8Array.of(4),H,P.toBytes(Z))}function F(x){G0(x,void 0,"Point");let{publicKey:j,publicKeyUncompressed:J}=X,V=x.length,Z=x[0],H=x.subarray(1);if(V===j&&(Z===2||Z===3)){let k=P.fromBytes(H);if(!P.isValid(k))throw Error("bad point: is not on curve, wrong x");let S=E(k),I;try{I=P.sqrt(S)}catch(D){let b=D instanceof Error?": "+D.message:"";throw Error("bad point: is not on curve, sqrt error"+b)}q();let R=P.isOdd(I);if((Z&1)===1!==R)I=P.neg(I);return{x:k,y:I}}else if(V===J&&Z===4){let k=P.BYTES,S=P.fromBytes(H.subarray(0,k)),I=P.fromBytes(H.subarray(k,k*2));if(!L(S,I))throw Error("bad point: is not on curve");return{x:S,y:I}}else throw Error(`bad point: got length ${V}, expected compressed=${j} or uncompressed=${J}`)}let z=A.toBytes||K,M=A.fromBytes||F;function E(x){let j=P.sqr(x),J=P.mul(j,x);return P.add(P.add(J,P.mul(x,W.a)),W.b)}function L(x,j){let J=P.sqr(j),V=E(x);return P.eql(J,V)}if(!L(W.Gx,W.Gy))throw Error("bad curve params: generator point");let B=P.mul(P.pow(W.a,IC),sM),m=P.mul(P.sqr(W.b),BigInt(27));if(P.is0(P.add(B,m)))throw Error("bad curve params: a or b");function v(x,j,J=!1){if(!P.isValid(j)||J&&P.is0(j))throw Error(`bad point coordinate ${x}`);return j}function l(x){if(!(x instanceof h))throw Error("ProjectivePoint expected")}function f(x){if(!$||!$.basises)throw Error("no endo");return aM(x,$.basises,Q.ORDER)}let u=g8((x,j)=>{let{X:J,Y:V,Z}=x;if(P.eql(Z,P.ONE))return{x:J,y:V};let H=x.is0();if(j==null)j=H?P.ONE:P.inv(Z);let k=P.mul(J,j),S=P.mul(V,j),I=P.mul(Z,j);if(H)return{x:P.ZERO,y:P.ZERO};if(!P.eql(I,P.ONE))throw Error("invZ was invalid");return{x:k,y:S}}),a=g8((x)=>{if(x.is0()){if(A.allowInfinityPoint&&!P.is0(x.Y))return;throw Error("bad point: ZERO")}let{x:j,y:J}=x.toAffine();if(!P.isValid(j)||!P.isValid(J))throw Error("bad point: x or y not field elements");if(!L(j,J))throw Error("bad point: equation left != right");if(!x.isTorsionFree())throw Error("bad point: not in prime-order subgroup");return!0});function d(x,j,J,V,Z){return J=new h(P.mul(J.X,x),J.Y,J.Z),j=w2(V,j),J=w2(Z,J),j.add(J)}class h{constructor(x,j,J){this.X=v("x",x),this.Y=v("y",j,!0),this.Z=v("z",J),Object.freeze(this)}static CURVE(){return W}static fromAffine(x){let{x:j,y:J}=x||{};if(!x||!P.isValid(j)||!P.isValid(J))throw Error("invalid affine point");if(x instanceof h)throw Error("projective point not allowed");if(P.is0(j)&&P.is0(J))return h.ZERO;return new h(j,J,P.ONE)}static fromBytes(x){let j=h.fromAffine(M(G0(x,void 0,"point")));return j.assertValidity(),j}static fromHex(x){return h.fromBytes(K1("pointHex",x))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(x=8,j=!0){if(c.createCache(this,x),!j)this.multiply(IC);return this}assertValidity(){a(this)}hasEvenY(){let{y:x}=this.toAffine();if(!P.isOdd)throw Error("Field doesn't support isOdd");return!P.isOdd(x)}equals(x){l(x);let{X:j,Y:J,Z:V}=this,{X:Z,Y:H,Z:k}=x,S=P.eql(P.mul(j,k),P.mul(Z,V)),I=P.eql(P.mul(J,k),P.mul(H,V));return S&&I}negate(){return new h(this.X,P.neg(this.Y),this.Z)}double(){let{a:x,b:j}=W,J=P.mul(j,IC),{X:V,Y:Z,Z:H}=this,k=P.ZERO,S=P.ZERO,I=P.ZERO,R=P.mul(V,V),Y=P.mul(Z,Z),D=P.mul(H,H),b=P.mul(V,Z);return b=P.add(b,b),I=P.mul(V,H),I=P.add(I,I),k=P.mul(x,I),S=P.mul(J,D),S=P.add(k,S),k=P.sub(Y,S),S=P.add(Y,S),S=P.mul(k,S),k=P.mul(b,k),I=P.mul(J,I),D=P.mul(x,D),b=P.sub(R,D),b=P.mul(x,b),b=P.add(b,I),I=P.add(R,R),R=P.add(I,R),R=P.add(R,D),R=P.mul(R,b),S=P.add(S,R),D=P.mul(Z,H),D=P.add(D,D),R=P.mul(D,b),k=P.sub(k,R),I=P.mul(D,Y),I=P.add(I,I),I=P.add(I,I),new h(k,S,I)}add(x){l(x);let{X:j,Y:J,Z:V}=this,{X:Z,Y:H,Z:k}=x,S=P.ZERO,I=P.ZERO,R=P.ZERO,Y=W.a,D=P.mul(W.b,IC),b=P.mul(j,Z),i=P.mul(J,H),r=P.mul(V,k),T1=P.add(j,J),C1=P.add(Z,H);T1=P.mul(T1,C1),C1=P.add(b,i),T1=P.sub(T1,C1),C1=P.add(j,V);let P1=P.add(Z,k);return C1=P.mul(C1,P1),P1=P.add(b,r),C1=P.sub(C1,P1),P1=P.add(J,V),S=P.add(H,k),P1=P.mul(P1,S),S=P.add(i,r),P1=P.sub(P1,S),R=P.mul(Y,C1),S=P.mul(D,r),R=P.add(S,R),S=P.sub(i,R),R=P.add(i,R),I=P.mul(S,R),i=P.add(b,b),i=P.add(i,b),r=P.mul(Y,r),C1=P.mul(D,C1),i=P.add(i,r),r=P.sub(b,r),r=P.mul(Y,r),C1=P.add(C1,r),b=P.mul(i,C1),I=P.add(I,b),b=P.mul(P1,C1),S=P.mul(T1,S),S=P.sub(S,b),b=P.mul(T1,i),R=P.mul(P1,R),R=P.add(R,b),new h(S,I,R)}subtract(x){return this.add(x.negate())}is0(){return this.equals(h.ZERO)}multiply(x){let{endo:j}=A;if(!Q.isValidNot0(x))throw Error("invalid scalar: out of range");let J,V,Z=(H)=>c.cached(this,H,(k)=>WA(h,k));if(j){let{k1neg:H,k1:k,k2neg:S,k2:I}=f(x),{p:R,f:Y}=Z(k),{p:D,f:b}=Z(I);V=Y.add(b),J=d(j.beta,R,D,H,S)}else{let{p:H,f:k}=Z(x);J=H,V=k}return WA(h,[J,V])[0]}multiplyUnsafe(x){let{endo:j}=A,J=this;if(!Q.isValid(x))throw Error("invalid scalar: out of range");if(x===YA||J.is0())return h.ZERO;if(x===c8)return J;if(c.hasCache(this))return this.multiply(x);if(j){let{k1neg:V,k1:Z,k2neg:H,k2:k}=f(x),{p1:S,p2:I}=F9(h,J,Z,k);return d(j.beta,S,I,V,H)}else return c.unsafe(J,x)}multiplyAndAddUnsafe(x,j,J){let V=this.multiplyUnsafe(j).add(x.multiplyUnsafe(J));return V.is0()?void 0:V}toAffine(x){return u(this,x)}isTorsionFree(){let{isTorsionFree:x}=A;if(G===c8)return!0;if(x)return x(h,this);return c.unsafe(this,U).is0()}clearCofactor(){let{clearCofactor:x}=A;if(G===c8)return this;if(x)return x(h,this);return this.multiplyUnsafe(G)}isSmallOrder(){return this.multiplyUnsafe(G).is0()}toBytes(x=!0){return CA(x,"isCompressed"),this.assertValidity(),z(h,this,x)}toHex(x=!0){return k0(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 WA(h,x)}static msm(x,j){return y8(h,Q,x,j)}static fromPrivateKey(x){return h.BASE.multiply(i8(Q,x))}}h.BASE=new h(W.Gx,W.Gy,P.ONE),h.ZERO=new h(P.ZERO,P.ONE,P.ZERO),h.Fp=P,h.Fn=Q;let o=Q.BITS,c=new E2(h,A.endo?Math.ceil(o/2):o);return h.BASE.precompute(8),h}function pV(T){return Uint8Array.of(T?2:3)}function uV(T,A){return{secretKey:A.BYTES,publicKey:1+T.BYTES,publicKeyUncompressed:1+2*T.BYTES,publicKeyHasPrefix:!0,signature:2*A.BYTES}}function eM(T,A={}){let{Fn:C}=T,P=A.randomBytes||h8,Q=Object.assign(uV(T.Fp,C),{seed:JQ(C.ORDER)});function W(z){try{return!!i8(C,z)}catch(M){return!1}}function G(z,M){let{publicKey:E,publicKeyUncompressed:L}=Q;try{let B=z.length;if(M===!0&&B!==E)return!1;if(M===!1&&B!==L)return!1;return!!T.fromBytes(z)}catch(B){return!1}}function U(z=P(Q.seed)){return UQ(G0(z,Q.seed,"seed"),C.ORDER)}function $(z,M=!0){return T.BASE.multiply(i8(C,z)).toBytes(M)}function X(z){let M=U(z);return{secretKey:M,publicKey:$(M)}}function q(z){if(typeof z==="bigint")return!1;if(z instanceof T)return!0;let{secretKey:M,publicKey:E,publicKeyUncompressed:L}=Q;if(C.allowedLengths||M===E)return;let B=K1("key",z).length;return B===E||B===L}function K(z,M,E=!0){if(q(z)===!0)throw Error("first arg must be private key");if(q(M)===!1)throw Error("second arg must be public key");let L=i8(C,z);return T.fromHex(M).multiply(L).toBytes(E)}return Object.freeze({getPublicKey:$,getSharedSecret:K,keygen:X,Point:T,utils:{isValidSecretKey:W,isValidPublicKey:G,randomSecretKey:U,isValidPrivateKey:W,randomPrivateKey:U,normPrivateKeyToScalar:(z)=>i8(C,z),precompute(z=8,M=T.BASE){return M.precompute(z,!1)}},lengths:Q})}function TI(T,A,C={}){c6(A),BA(C,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let P=C.randomBytes||h8,Q=C.hmac||((J,...V)=>KW(A,J,dT(...V))),{Fp:W,Fn:G}=T,{ORDER:U,BITS:$}=G,{keygen:X,getPublicKey:q,getSharedSecret:K,utils:F,lengths:z}=eM(T,C),M={prehash:!1,lowS:typeof C.lowS==="boolean"?C.lowS:!1,format:void 0,extraEntropy:!1},E="compact";function L(J){let V=U>>c8;return J>V}function B(J,V){if(!G.isValidNot0(V))throw Error(`invalid signature ${J}: out of range 1..Point.Fn.ORDER`);return V}function m(J,V){jW(V);let Z=z.signature,H=V==="compact"?Z:V==="recovered"?Z+1:void 0;return G0(J,H,`${V} signature`)}class v{constructor(J,V,Z){if(this.r=B("r",J),this.s=B("s",V),Z!=null)this.recovery=Z;Object.freeze(this)}static fromBytes(J,V=E){m(J,V);let Z;if(V==="der"){let{r:I,s:R}=VA.toSig(G0(J));return new v(I,R)}if(V==="recovered")Z=J[0],V="compact",J=J.subarray(1);let H=G.BYTES,k=J.subarray(0,H),S=J.subarray(H,H*2);return new v(G.fromBytes(k),G.fromBytes(S),Z)}static fromHex(J,V){return this.fromBytes(A8(J),V)}addRecoveryBit(J){return new v(this.r,this.s,J)}recoverPublicKey(J){let V=W.ORDER,{r:Z,s:H,recovery:k}=this;if(k==null||![0,1,2,3].includes(k))throw Error("recovery id invalid");if(U*lV<V&&k>1)throw Error("recovery id is ambiguous for h>1 curve");let I=k===2||k===3?Z+U:Z;if(!W.isValid(I))throw Error("recovery id 2 or 3 invalid");let R=W.toBytes(I),Y=T.fromBytes(dT(pV((k&1)===0),R)),D=G.inv(I),b=f(K1("msgHash",J)),i=G.create(-b*D),r=G.create(H*D),T1=T.BASE.multiplyUnsafe(i).add(Y.multiplyUnsafe(r));if(T1.is0())throw Error("point at infinify");return T1.assertValidity(),T1}hasHighS(){return L(this.s)}toBytes(J=E){if(jW(J),J==="der")return A8(VA.hexFromSig(this));let V=G.toBytes(this.r),Z=G.toBytes(this.s);if(J==="recovered"){if(this.recovery==null)throw Error("recovery bit must be present");return dT(Uint8Array.of(this.recovery),V,Z)}return dT(V,Z)}toHex(J){return k0(this.toBytes(J))}assertValidity(){}static fromCompact(J){return v.fromBytes(K1("sig",J),"compact")}static fromDER(J){return v.fromBytes(K1("sig",J),"der")}normalizeS(){return this.hasHighS()?new v(this.r,G.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return k0(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return k0(this.toBytes("compact"))}}let l=C.bits2int||function(V){if(V.length>8192)throw Error("input is too large");let Z=m8(V),H=V.length*8-$;return H>0?Z>>BigInt(H):Z},f=C.bits2int_modN||function(V){return G.create(l(V))},u=EA($);function a(J){return N2("num < 2^"+$,J,YA,u),G.toBytes(J)}function d(J,V){return G0(J,void 0,"message"),V?G0(A(J),void 0,"prehashed message"):J}function h(J,V,Z){if(["recovered","canonical"].some((r)=>(r in Z)))throw Error("sign() legacy options not supported");let{lowS:H,prehash:k,extraEntropy:S}=kW(Z,M);J=d(J,k);let I=f(J),R=i8(G,V),Y=[a(R),a(I)];if(S!=null&&S!==!1){let r=S===!0?P(z.secretKey):S;Y.push(K1("extraEntropy",r))}let D=dT(...Y),b=I;function i(r){let T1=l(r);if(!G.isValidNot0(T1))return;let C1=G.inv(T1),P1=T.BASE.multiply(T1).toAffine(),oT=G.create(P1.x);if(oT===YA)return;let Y1=G.create(C1*G.create(b+oT*R));if(Y1===YA)return;let j1=(P1.x===oT?0:2)|Number(P1.y&c8),P2=Y1;if(H&&L(Y1))P2=G.neg(Y1),j1^=1;return new v(oT,P2,j1)}return{seed:D,k2sig:i}}function o(J,V,Z={}){J=K1("message",J);let{seed:H,k2sig:k}=h(J,V,Z);return Q9(A.outputLen,G.BYTES,Q)(H,k)}function c(J){let V=void 0,Z=typeof J==="string"||e0(J),H=!Z&&J!==null&&typeof J==="object"&&typeof J.r==="bigint"&&typeof J.s==="bigint";if(!Z&&!H)throw Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(H)V=new v(J.r,J.s);else if(Z){try{V=v.fromBytes(K1("sig",J),"der")}catch(k){if(!(k instanceof VA.Err))throw k}if(!V)try{V=v.fromBytes(K1("sig",J),"compact")}catch(k){return!1}}if(!V)return!1;return V}function x(J,V,Z,H={}){let{lowS:k,prehash:S,format:I}=kW(H,M);if(Z=K1("publicKey",Z),V=d(K1("message",V),S),"strict"in H)throw Error("options.strict was renamed to lowS");let R=I===void 0?c(J):v.fromBytes(K1("sig",J),I);if(R===!1)return!1;try{let Y=T.fromBytes(Z);if(k&&R.hasHighS())return!1;let{r:D,s:b}=R,i=f(V),r=G.inv(b),T1=G.create(i*r),C1=G.create(D*r),P1=T.BASE.multiplyUnsafe(T1).add(Y.multiplyUnsafe(C1));if(P1.is0())return!1;return G.create(P1.x)===D}catch(Y){return!1}}function j(J,V,Z={}){let{prehash:H}=kW(Z,M);return V=d(V,H),v.fromBytes(J,"recovered").recoverPublicKey(V).toBytes()}return Object.freeze({keygen:X,getPublicKey:q,getSharedSecret:K,utils:F,lengths:z,Point:T,sign:o,verify:x,recoverPublicKey:j,Signature:v,hash:A})}function AI(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},C=T.Fp,P=T.allowedPrivateKeyLengths?Array.from(new Set(T.allowedPrivateKeyLengths.map((G)=>Math.ceil(G/2)))):void 0,Q=J0(A.n,{BITS:T.nBitLength,allowedLengths:P,modFromBytes:T.wrapPrivateKey}),W={Fp:C,Fn:Q,allowInfinityPoint:T.allowInfinityPoint,endo:T.endo,isTorsionFree:T.isTorsionFree,clearCofactor:T.clearCofactor,fromBytes:T.fromBytes,toBytes:T.toBytes};return{CURVE:A,curveOpts:W}}function CI(T){let{CURVE:A,curveOpts:C}=AI(T),P={hmac:T.hmac,randomBytes:T.randomBytes,lowS:T.lowS,bits2int:T.bits2int,bits2int_modN:T.bits2int_modN};return{CURVE:A,curveOpts:C,hash:T.hash,ecdsaOpts:P}}function PI(T,A){let C=A.Point;return Object.assign({},A,{ProjectivePoint:C,CURVE:Object.assign({},T,CC(C.Fn.ORDER,C.Fn.BITS))})}function dV(T){let{CURVE:A,curveOpts:C,hash:P,ecdsaOpts:Q}=CI(T),W=tM(A,C),G=TI(W,P,Q);return PI(T,G)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function rV(T,A){let C=(P)=>dV({...T,hash:P});return{...C(A),create:C}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */var FW={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},QI={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var fV=BigInt(2);function WI(T){let A=FW.p,C=BigInt(3),P=BigInt(6),Q=BigInt(11),W=BigInt(22),G=BigInt(23),U=BigInt(44),$=BigInt(88),X=T*T*T%A,q=X*X*T%A,K=N1(q,C,A)*q%A,F=N1(K,C,A)*q%A,z=N1(F,fV,A)*X%A,M=N1(z,Q,A)*z%A,E=N1(M,W,A)*M%A,L=N1(E,U,A)*E%A,B=N1(L,$,A)*L%A,m=N1(B,U,A)*E%A,v=N1(m,C,A)*q%A,l=N1(v,G,A)*M%A,f=N1(l,P,A)*X%A,u=N1(f,fV,A);if(!RW.eql(RW.sqr(u),T))throw Error("Cannot find square root");return u}var RW=J0(FW.p,{sqrt:WI}),NC=rV({...FW,Fp:RW,lowS:!0,endo:QI},e6);var Qg=T0.utils.randomPrivateKey,iV=()=>{let T=T0.utils.randomPrivateKey(),A=NW(T),C=new Uint8Array(64);return C.set(T),C.set(A,32),{publicKey:A,secretKey:C}},NW=T0.getPublicKey;function cV(T){try{return T0.ExtendedPoint.fromHex(T),!0}catch{return!1}}var WY=(T,A)=>T0.sign(T,A.slice(0,32)),JI=T0.verify,$1=(T)=>{if(w.isBuffer(T))return T;else if(T instanceof Uint8Array)return w.from(T.buffer,T.byteOffset,T.byteLength);else return w.from(T)};class GY{constructor(T){Object.assign(this,T)}encode(){return w.from(a8.serialize(EC,this))}static decode(T){return a8.deserialize(EC,this,T)}static decodeUnchecked(T){return a8.deserializeUnchecked(EC,this,T)}}var EC=new Map,JY,UI=32,c2=32;function $I(T){return T._bn!==void 0}var oV=1;class n extends GY{constructor(T){super({});if(this._bn=void 0,$I(T))this._bn=T._bn;else{if(typeof T==="string"){let A=C0.default.decode(T);if(A.length!=c2)throw Error("Invalid public key input");this._bn=new IW.default(A)}else this._bn=new IW.default(T);if(this._bn.byteLength()>c2)throw Error("Invalid public key input")}}static unique(){let T=new n(oV);return oV+=1,new n(T.toBuffer())}equals(T){return this._bn.eq(T._bn)}toBase58(){return C0.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(w);if(T.length===c2)return T;let A=w.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,C){let P=w.concat([T.toBuffer(),w.from(A),C.toBuffer()]),Q=zQ(P);return new n(Q)}static createProgramAddressSync(T,A){let C=w.alloc(0);T.forEach(function(Q){if(Q.length>UI)throw TypeError("Max seed length exceeded");C=w.concat([C,$1(Q)])}),C=w.concat([C,A.toBuffer(),w.from("ProgramDerivedAddress")]);let P=zQ(C);if(cV(P))throw Error("Invalid seeds, address must fall off the curve");return new n(P)}static async createProgramAddress(T,A){return this.createProgramAddressSync(T,A)}static findProgramAddressSync(T,A){let C=255,P;while(C!=0){try{let Q=T.concat(w.from([C]));P=this.createProgramAddressSync(Q,A)}catch(Q){if(Q instanceof TypeError)throw Q;C--;continue}return[P,C]}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 cV(A.toBytes())}}JY=n;n.default=new JY("11111111111111111111111111111111");EC.set(n,{kind:"struct",fields:[["_bn","u256"]]});var Wg=new n("BPFLoader1111111111111111111111111111111111"),BC=1232,VI=127,UY=64;class $Y extends Error{constructor(T){super(`Signature ${T} has expired: block height exceeded.`);this.signature=void 0,this.signature=T}}Object.defineProperty($Y.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});class VY 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(VY.prototype,"name",{value:"TransactionExpiredTimeoutError"});class YY extends Error{constructor(T){super(`Signature ${T} has expired: the nonce is no longer valid.`);this.signature=void 0,this.signature=T}}Object.defineProperty(YY.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});class LW{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 C=new Map;this.keySegments().flat().forEach((Q,W)=>{C.set(Q.toBase58(),W)});let P=(Q)=>{let W=C.get(Q.toBase58());if(W===void 0)throw Error("Encountered an unknown instruction account key during compilation");return W};return T.map((Q)=>{return{programIdIndex:P(Q.programId),accountKeyIndexes:Q.keys.map((W)=>P(W.pubkey)),data:Q.data}})}}var W1=(T="publicKey")=>{return N.blob(32,T)};var o8=(T="string")=>{let A=N.struct([N.u32("length"),N.u32("lengthPadding"),N.blob(N.offset(N.u32(),-8),"chars")],T),C=A.decode.bind(A),P=A.encode.bind(A),Q=A;return Q.decode=(W,G)=>{return C(W,G).chars.toString()},Q.encode=(W,G,U)=>{let $={chars:w.from(W,"utf8")};return P($,G,U)},Q.alloc=(W)=>{return N.u32().span+N.u32().span+w.from(W,"utf8").length},Q},YI=(T="authorized")=>{return N.struct([W1("staker"),W1("withdrawer")],T)},ZI=(T="lockup")=>{return N.struct([N.ns64("unixTimestamp"),N.ns64("epoch"),W1("custodian")],T)},qI=(T="voteInit")=>{return N.struct([W1("nodePubkey"),W1("authorizedVoter"),W1("authorizedWithdrawer"),N.u8("commission")],T)},XI=(T="voteAuthorizeWithSeedArgs")=>{return N.struct([N.u32("voteAuthorizationType"),W1("currentAuthorityDerivedKeyOwnerPubkey"),o8("currentAuthorityDerivedKeySeed"),W1("newAuthorized")],T)};function ZY(T,A){let C=(Q)=>{if(Q.span>=0)return Q.span;else if(typeof Q.alloc==="function")return Q.alloc(A[Q.property]);else if("count"in Q&&"elementLayout"in Q){let W=A[Q.property];if(Array.isArray(W))return W.length*C(Q.elementLayout)}else if("fields"in Q)return ZY({layout:Q},A[Q.property]);return 0},P=0;return T.layout.fields.forEach((Q)=>{P+=C(Q)}),P}function r2(T){let A=0,C=0;for(;;){let P=T.shift();if(A|=(P&127)<<C*7,C+=1,(P&128)===0)break}return A}function f2(T,A){let C=A;for(;;){let P=C&127;if(C>>=7,C==0){T.push(P);break}else P|=128,T.push(P)}}function DT(T,A){if(!T)throw Error(A||"Assertion failed")}class EW{constructor(T,A){this.payer=void 0,this.keyMetaMap=void 0,this.payer=T,this.keyMetaMap=A}static compile(T,A){let C=new Map,P=(W)=>{let G=W.toBase58(),U=C.get(G);if(U===void 0)U={isSigner:!1,isWritable:!1,isInvoked:!1},C.set(G,U);return U},Q=P(A);Q.isSigner=!0,Q.isWritable=!0;for(let W of T){P(W.programId).isInvoked=!0;for(let G of W.keys){let U=P(G.pubkey);U.isSigner||=G.isSigner,U.isWritable||=G.isWritable}}return new EW(A,C)}getMessageComponents(){let T=[...this.keyMetaMap.entries()];DT(T.length<=256,"Max static account keys length exceeded");let A=T.filter(([,U])=>U.isSigner&&U.isWritable),C=T.filter(([,U])=>U.isSigner&&!U.isWritable),P=T.filter(([,U])=>!U.isSigner&&U.isWritable),Q=T.filter(([,U])=>!U.isSigner&&!U.isWritable),W={numRequiredSignatures:A.length+C.length,numReadonlySignedAccounts:C.length,numReadonlyUnsignedAccounts:Q.length};{DT(A.length>0,"Expected at least one writable signer key");let[U]=A[0];DT(U===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}let G=[...A.map(([U])=>new n(U)),...C.map(([U])=>new n(U)),...P.map(([U])=>new n(U)),...Q.map(([U])=>new n(U))];return[W,G]}extractTableLookup(T){let[A,C]=this.drainKeysFoundInLookupTable(T.state.addresses,(W)=>!W.isSigner&&!W.isInvoked&&W.isWritable),[P,Q]=this.drainKeysFoundInLookupTable(T.state.addresses,(W)=>!W.isSigner&&!W.isInvoked&&!W.isWritable);if(A.length===0&&P.length===0)return;return[{accountKey:T.key,writableIndexes:A,readonlyIndexes:P},{writable:C,readonly:Q}]}drainKeysFoundInLookupTable(T,A){let C=[],P=[];for(let[Q,W]of this.keyMetaMap.entries())if(A(W)){let G=new n(Q),U=T.findIndex(($)=>$.equals(G));if(U>=0)DT(U<256,"Max lookup table index exceeded"),C.push(U),P.push(G),this.keyMetaMap.delete(Q)}return[C,P]}}var qY="Reached end of buffer unexpectedly";function LC(T){if(T.length===0)throw Error(qY);return T.shift()}function i2(T,...A){let[C]=A;if(A.length===2?C+(A[1]??0)>T.length:C>=T.length)throw Error(qY);return T.splice(...A)}class a2{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:C0.default.decode(T.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new LW(this.staticAccountKeys)}static compile(T){let A=EW.compile(T.instructions,T.payerKey),[C,P]=A.getMessageComponents(),W=new LW(P).compileInstructions(T.instructions).map((G)=>({programIdIndex:G.programIdIndex,accounts:G.accountKeyIndexes,data:C0.default.encode(G.data)}));return new a2({header:C,accountKeys:P,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 C=T-A,Q=this.accountKeys.length-A-this.header.numReadonlyUnsignedAccounts;return C<Q}else{let C=A-this.header.numReadonlySignedAccounts;return T<C}}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=[];f2(A,T);let C=this.instructions.map((q)=>{let{accounts:K,programIdIndex:F}=q,z=Array.from(C0.default.decode(q.data)),M=[];f2(M,K.length);let E=[];return f2(E,z.length),{programIdIndex:F,keyIndicesCount:w.from(M),keyIndices:K,dataLength:w.from(E),data:z}}),P=[];f2(P,C.length);let Q=w.alloc(BC);w.from(P).copy(Q);let W=P.length;C.forEach((q)=>{let F=N.struct([N.u8("programIdIndex"),N.blob(q.keyIndicesCount.length,"keyIndicesCount"),N.seq(N.u8("keyIndex"),q.keyIndices.length,"keyIndices"),N.blob(q.dataLength.length,"dataLength"),N.seq(N.u8("userdatum"),q.data.length,"data")]).encode(q,Q,W);W+=F}),Q=Q.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")]),U={numRequiredSignatures:w.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:w.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:w.from([this.header.numReadonlyUnsignedAccounts]),keyCount:w.from(A),keys:this.accountKeys.map((q)=>$1(q.toBytes())),recentBlockhash:C0.default.decode(this.recentBlockhash)},$=w.alloc(2048),X=G.encode(U,$);return Q.copy($,X),$.slice(0,X+Q.length)}static from(T){let A=[...T],C=LC(A);if(C!==(C&VI))throw Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");let P=LC(A),Q=LC(A),W=r2(A),G=[];for(let K=0;K<W;K++){let F=i2(A,0,c2);G.push(new n(w.from(F)))}let U=i2(A,0,c2),$=r2(A),X=[];for(let K=0;K<$;K++){let F=LC(A),z=r2(A),M=i2(A,0,z),E=r2(A),L=i2(A,0,E),B=C0.default.encode(w.from(L));X.push({programIdIndex:F,accounts:M,data:B})}let q={header:{numRequiredSignatures:C,numReadonlySignedAccounts:P,numReadonlyUnsignedAccounts:Q},recentBlockhash:C0.default.encode(w.from(U)),accountKeys:G,instructions:X};return new a2(q)}}var HI=w.alloc(UY).fill(0);class V1{constructor(T){if(this.keys=void 0,this.programId=void 0,this.data=w.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:C})=>({pubkey:T.toJSON(),isSigner:A,isWritable:C})),programId:this.programId.toJSON(),data:[...this.data]}}}class S1{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:C}=T;this.minNonceContextSlot=A,this.nonceInfo=C}else if(Object.prototype.hasOwnProperty.call(T,"lastValidBlockHeight")){let{blockhash:A,lastValidBlockHeight:C}=T;this.recentBlockhash=A,this.lastValidBlockHeight=C}else{let{recentBlockhash:A,nonceInfo:C}=T;if(C)this.nonceInfo=C;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 V1(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 C;if(this.feePayer)C=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)C=this.signatures[0].publicKey;else throw Error("Transaction fee payer required");for(let M=0;M<A.length;M++)if(A[M].programId===void 0)throw Error(`Transaction instruction index ${M} has undefined program id`);let P=[],Q=[];A.forEach((M)=>{M.keys.forEach((L)=>{Q.push({...L})});let E=M.programId.toString();if(!P.includes(E))P.push(E)}),P.forEach((M)=>{Q.push({pubkey:new n(M),isSigner:!1,isWritable:!1})});let W=[];Q.forEach((M)=>{let E=M.pubkey.toString(),L=W.findIndex((B)=>{return B.pubkey.toString()===E});if(L>-1)W[L].isWritable=W[L].isWritable||M.isWritable,W[L].isSigner=W[L].isSigner||M.isSigner;else W.push(M)}),W.sort(function(M,E){if(M.isSigner!==E.isSigner)return M.isSigner?-1:1;if(M.isWritable!==E.isWritable)return M.isWritable?-1:1;let L={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return M.pubkey.toBase58().localeCompare(E.pubkey.toBase58(),"en",L)});let G=W.findIndex((M)=>{return M.pubkey.equals(C)});if(G>-1){let[M]=W.splice(G,1);M.isSigner=!0,M.isWritable=!0,W.unshift(M)}else W.unshift({pubkey:C,isSigner:!0,isWritable:!0});for(let M of this.signatures){let E=W.findIndex((L)=>{return L.pubkey.equals(M.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: ${M.publicKey.toString()}`)}let U=0,$=0,X=0,q=[],K=[];W.forEach(({pubkey:M,isSigner:E,isWritable:L})=>{if(E){if(q.push(M.toString()),U+=1,!L)$+=1}else if(K.push(M.toString()),!L)X+=1});let F=q.concat(K),z=A.map((M)=>{let{data:E,programId:L}=M;return{programIdIndex:F.indexOf(L.toString()),accounts:M.keys.map((B)=>F.indexOf(B.pubkey.toString())),data:C0.default.encode(E)}});return z.forEach((M)=>{DT(M.programIdIndex>=0),M.accounts.forEach((E)=>DT(E>=0))}),new a2({header:{numRequiredSignatures:U,numReadonlySignedAccounts:$,numReadonlyUnsignedAccounts:X},accountKeys:F,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((P,Q)=>{return A[Q].equals(P.publicKey)}))return T}return this.signatures=A.map((C)=>({signature:null,publicKey:C})),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((C)=>{let P=C.toString();if(A.has(P))return!1;else return A.add(P),!0}).map((C)=>({signature:null,publicKey:C}))}sign(...T){if(T.length===0)throw Error("No signers");let A=new Set,C=[];for(let Q of T){let W=Q.publicKey.toString();if(A.has(W))continue;else A.add(W),C.push(Q)}this.signatures=C.map((Q)=>({signature:null,publicKey:Q.publicKey}));let P=this._compile();this._partialSign(P,...C)}partialSign(...T){if(T.length===0)throw Error("No signers");let A=new Set,C=[];for(let Q of T){let W=Q.publicKey.toString();if(A.has(W))continue;else A.add(W),C.push(Q)}let P=this._compile();this._partialSign(P,...C)}_partialSign(T,...A){let C=T.serialize();A.forEach((P)=>{let Q=WY(C,P.secretKey);this._addSignature(P.publicKey,$1(Q))})}addSignature(T,A){this._compile(),this._addSignature(T,A)}_addSignature(T,A){DT(A.length===64);let C=this.signatures.findIndex((P)=>T.equals(P.publicKey));if(C<0)throw Error(`unknown signer: ${T.toString()}`);this.signatures[C].signature=w.from(A)}verifySignatures(T=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),T)}_getMessageSignednessErrors(T,A){let C={};for(let{signature:P,publicKey:Q}of this.signatures)if(P===null){if(A)(C.missing||=[]).push(Q)}else if(!JI(P,T,Q.toBytes()))(C.invalid||=[]).push(Q);return C.invalid||C.missing?C:void 0}serialize(T){let{requireAllSignatures:A,verifySignatures:C}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},T),P=this.serializeMessage();if(C){let Q=this._getMessageSignednessErrors(P,A);if(Q){let W="Signature verification failed.";if(Q.invalid)W+=`
15
+ Invalid signature for public key${Q.invalid.length===1?"":"(s)"} [\`${Q.invalid.map((G)=>G.toBase58()).join("`, `")}\`].`;if(Q.missing)W+=`
16
+ Missing signature for public key${Q.missing.length===1?"":"(s)"} [\`${Q.missing.map((G)=>G.toBase58()).join("`, `")}\`].`;throw Error(W)}}return this._serialize(P)}_serialize(T){let{signatures:A}=this,C=[];f2(C,A.length);let P=C.length+A.length*64+T.length,Q=w.alloc(P);return DT(A.length<256),w.from(C).copy(Q,0),A.forEach(({signature:W},G)=>{if(W!==null)DT(W.length===64,"signature has invalid length"),w.from(W).copy(Q,C.length+G*64)}),T.copy(Q,C.length+A.length*64),DT(Q.length<=BC,`Transaction too large: ${Q.length} > ${BC}`),Q}get keys(){return DT(this.instructions.length===1),this.instructions[0].keys.map((T)=>T.pubkey)}get programId(){return DT(this.instructions.length===1),this.instructions[0].programId}get data(){return DT(this.instructions.length===1),this.instructions[0].data}static from(T){let A=[...T],C=r2(A),P=[];for(let Q=0;Q<C;Q++){let W=i2(A,0,UY);P.push(C0.default.encode(w.from(W)))}return S1.populate(a2.from(A),P)}static populate(T,A=[]){let C=new S1;if(C.recentBlockhash=T.recentBlockhash,T.header.numRequiredSignatures>0)C.feePayer=T.accountKeys[0];return A.forEach((P,Q)=>{let W={signature:P==C0.default.encode(HI)?null:C0.default.decode(P),publicKey:T.accountKeys[Q]};C.signatures.push(W)}),T.instructions.forEach((P)=>{let Q=P.accounts.map((W)=>{let G=T.accountKeys[W];return{pubkey:G,isSigner:C.signatures.some((U)=>U.publicKey.toString()===G.toString())||T.isAccountSigner(W),isWritable:T.isAccountWritable(W)}});C.instructions.push(new V1({keys:Q,programId:T.accountKeys[P.programIdIndex],data:C0.default.decode(P.data)}))}),C._message=T,C._json=C.toJSON(),C}}var KI=160,kI=64,jI=KI/kI,RI=1000/jI,ZA=new n("SysvarC1ock11111111111111111111111111111111"),Gg=new n("SysvarEpochSchedu1e111111111111111111111111"),Jg=new n("Sysvar1nstructions1111111111111111111111111"),DW=new n("SysvarRecentB1ockHashes11111111111111111111"),s2=new n("SysvarRent111111111111111111111111111111111"),Ug=new n("SysvarRewards111111111111111111111111111111"),$g=new n("SysvarS1otHashes111111111111111111111111111"),Vg=new n("SysvarS1otHistory11111111111111111111111111"),zW=new n("SysvarStakeHistory1111111111111111111111111");class XY extends Error{constructor({action:T,signature:A,transactionMessage:C,logs:P}){let Q=P?`Logs:
17
+ ${JSON.stringify(P.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
+ ${C}. `+Q+"\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.";break;case"simulate":G=`Simulation failed.
19
+ Message: ${C}.
20
+ `+Q+"\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.";break;default:G=`Unknown action '${((U)=>U)(T)}'`}super(G);this.signature=void 0,this.transactionMessage=void 0,this.transactionLogs=void 0,this.signature=A,this.transactionMessage=C,this.transactionLogs=P?P: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,C)=>{T.getTransaction(this.signature).then((P)=>{if(P&&P.meta&&P.meta.logMessages){let Q=P.meta.logMessages;this.transactionLogs=Q,A(Q)}else C(Error("Log messages not found"))}).catch(C)});return await this.transactionLogs}}async function nV(T,A,C,P){let Q=P&&{skipPreflight:P.skipPreflight,preflightCommitment:P.preflightCommitment||P.commitment,maxRetries:P.maxRetries,minContextSlot:P.minContextSlot},W=await T.sendTransaction(A,C,Q),G;if(A.recentBlockhash!=null&&A.lastValidBlockHeight!=null)G=(await T.confirmTransaction({abortSignal:P?.abortSignal,signature:W,blockhash:A.recentBlockhash,lastValidBlockHeight:A.lastValidBlockHeight},P&&P.commitment)).value;else if(A.minNonceContextSlot!=null&&A.nonceInfo!=null){let{nonceInstruction:U}=A.nonceInfo,$=U.keys[0].pubkey;G=(await T.confirmTransaction({abortSignal:P?.abortSignal,minContextSlot:A.minNonceContextSlot,nonceAccountPubkey:$,nonceValue:A.nonceInfo.nonce,signature:W},P&&P.commitment)).value}else{if(P?.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,P&&P.commitment)).value}if(G.err){if(W!=null)throw new XY({action:"send",signature:W,transactionMessage:`Status: (${JSON.stringify(G)})`});throw Error(`Transaction ${W} failed (${JSON.stringify(G)})`)}return W}function FI(T){return new Promise((A)=>setTimeout(A,T))}function Q1(T,A){let C=T.layout.span>=0?T.layout.span:ZY(T,A),P=w.alloc(C),Q=Object.assign({instruction:T.index},A);return T.layout.encode(Q,P),P}var DI=N.nu64("lamportsPerSignature"),zI=N.struct([N.u32("version"),N.u32("state"),W1("authorizedPubkey"),W1("nonce"),N.struct([DI],"feeCalculator")]),aV=zI.span;function n8(T){let A=QY.blob(8,T),C=A.decode.bind(A),P=A.encode.bind(A),Q=A,W=TV();return Q.decode=(G,U)=>{let $=C(G,U);return W.decode($)},Q.encode=(G,U,$)=>{let X=W.encode(G);return P(X,U,$)},Q}var R0=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"),n8("lamports")])},CreateWithSeed:{index:3,layout:N.struct([N.u32("instruction"),W1("base"),o8("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"),o8("seed"),N.ns64("space"),W1("programId")])},AssignWithSeed:{index:10,layout:N.struct([N.u32("instruction"),W1("base"),o8("seed"),W1("programId")])},TransferWithSeed:{index:11,layout:N.struct([N.u32("instruction"),n8("lamports"),o8("seed"),W1("programId")])},UpgradeNonceAccount:{index:12,layout:N.struct([N.u32("instruction")])}});class kT{constructor(){}static createAccount(T){let A=R0.Create,C=Q1(A,{lamports:T.lamports,space:T.space,programId:$1(T.programId.toBuffer())});return new V1({keys:[{pubkey:T.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:T.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:C})}static transfer(T){let A,C;if("basePubkey"in T){let P=R0.TransferWithSeed;A=Q1(P,{lamports:BigInt(T.lamports),seed:T.seed,programId:$1(T.programId.toBuffer())}),C=[{pubkey:T.fromPubkey,isSigner:!1,isWritable:!0},{pubkey:T.basePubkey,isSigner:!0,isWritable:!1},{pubkey:T.toPubkey,isSigner:!1,isWritable:!0}]}else{let P=R0.Transfer;A=Q1(P,{lamports:BigInt(T.lamports)}),C=[{pubkey:T.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:T.toPubkey,isSigner:!1,isWritable:!0}]}return new V1({keys:C,programId:this.programId,data:A})}static assign(T){let A,C;if("basePubkey"in T){let P=R0.AssignWithSeed;A=Q1(P,{base:$1(T.basePubkey.toBuffer()),seed:T.seed,programId:$1(T.programId.toBuffer())}),C=[{pubkey:T.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:T.basePubkey,isSigner:!0,isWritable:!1}]}else{let P=R0.Assign;A=Q1(P,{programId:$1(T.programId.toBuffer())}),C=[{pubkey:T.accountPubkey,isSigner:!0,isWritable:!0}]}return new V1({keys:C,programId:this.programId,data:A})}static createAccountWithSeed(T){let A=R0.CreateWithSeed,C=Q1(A,{base:$1(T.basePubkey.toBuffer()),seed:T.seed,lamports:T.lamports,space:T.space,programId:$1(T.programId.toBuffer())}),P=[{pubkey:T.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:T.newAccountPubkey,isSigner:!1,isWritable:!0}];if(!T.basePubkey.equals(T.fromPubkey))P.push({pubkey:T.basePubkey,isSigner:!0,isWritable:!1});return new V1({keys:P,programId:this.programId,data:C})}static createNonceAccount(T){let A=new S1;if("basePubkey"in T&&"seed"in T)A.add(kT.createAccountWithSeed({fromPubkey:T.fromPubkey,newAccountPubkey:T.noncePubkey,basePubkey:T.basePubkey,seed:T.seed,lamports:T.lamports,space:aV,programId:this.programId}));else A.add(kT.createAccount({fromPubkey:T.fromPubkey,newAccountPubkey:T.noncePubkey,lamports:T.lamports,space:aV,programId:this.programId}));let C={noncePubkey:T.noncePubkey,authorizedPubkey:T.authorizedPubkey};return A.add(this.nonceInitialize(C)),A}static nonceInitialize(T){let A=R0.InitializeNonceAccount,C=Q1(A,{authorized:$1(T.authorizedPubkey.toBuffer())}),P={keys:[{pubkey:T.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:DW,isSigner:!1,isWritable:!1},{pubkey:s2,isSigner:!1,isWritable:!1}],programId:this.programId,data:C};return new V1(P)}static nonceAdvance(T){let A=R0.AdvanceNonceAccount,C=Q1(A),P={keys:[{pubkey:T.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:DW,isSigner:!1,isWritable:!1},{pubkey:T.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:C};return new V1(P)}static nonceWithdraw(T){let A=R0.WithdrawNonceAccount,C=Q1(A,{lamports:T.lamports});return new V1({keys:[{pubkey:T.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:T.toPubkey,isSigner:!1,isWritable:!0},{pubkey:DW,isSigner:!1,isWritable:!1},{pubkey:s2,isSigner:!1,isWritable:!1},{pubkey:T.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:C})}static nonceAuthorize(T){let A=R0.AuthorizeNonceAccount,C=Q1(A,{authorized:$1(T.newAuthorizedPubkey.toBuffer())});return new V1({keys:[{pubkey:T.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:T.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:C})}static allocate(T){let A,C;if("basePubkey"in T){let P=R0.AllocateWithSeed;A=Q1(P,{base:$1(T.basePubkey.toBuffer()),seed:T.seed,space:T.space,programId:$1(T.programId.toBuffer())}),C=[{pubkey:T.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:T.basePubkey,isSigner:!0,isWritable:!1}]}else{let P=R0.Allocate;A=Q1(P,{space:T.space}),C=[{pubkey:T.accountPubkey,isSigner:!0,isWritable:!0}]}return new V1({keys:C,programId:this.programId,data:A})}}kT.programId=new n("11111111111111111111111111111111");var SI=BC-300;class OC{constructor(){}static getMinNumSignatures(T){return 2*(Math.ceil(T/OC.chunkSize)+1+1)}static async load(T,A,C,P,Q){{let q=await T.getMinimumBalanceForRentExemption(Q.length),K=await T.getAccountInfo(C.publicKey,"confirmed"),F=null;if(K!==null){if(K.executable)return console.error("Program load failed, account is already executable"),!1;if(K.data.length!==Q.length)F=F||new S1,F.add(kT.allocate({accountPubkey:C.publicKey,space:Q.length}));if(!K.owner.equals(P))F=F||new S1,F.add(kT.assign({accountPubkey:C.publicKey,programId:P}));if(K.lamports<q)F=F||new S1,F.add(kT.transfer({fromPubkey:A.publicKey,toPubkey:C.publicKey,lamports:q-K.lamports}))}else F=new S1().add(kT.createAccount({fromPubkey:A.publicKey,newAccountPubkey:C.publicKey,lamports:q>0?q:1,space:Q.length,programId:P}));if(F!==null)await nV(T,F,[A,C],{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=OC.chunkSize,U=0,$=Q,X=[];while($.length>0){let q=$.slice(0,G),K=w.alloc(G+16);W.encode({instruction:0,offset:U,bytes:q,bytesLength:0,bytesLengthPadding:0},K);let F=new S1().add({keys:[{pubkey:C.publicKey,isSigner:!0,isWritable:!0}],programId:P,data:K});if(X.push(nV(T,F,[A,C],{commitment:"confirmed"})),T._rpcEndpoint.includes("solana.com"))await FI(250);U+=G,$=$.slice(G)}await Promise.all(X);{let q=N.struct([N.u32("instruction")]),K=w.alloc(q.span);q.encode({instruction:1},K);let F=new S1().add({keys:[{pubkey:C.publicKey,isSigner:!0,isWritable:!0},{pubkey:s2,isSigner:!1,isWritable:!1}],programId:P,data:K}),z="processed",M=await T.sendTransaction(F,[A,C],{preflightCommitment:z}),{context:E,value:L}=await T.confirmTransaction({signature:M,lastValidBlockHeight:F.lastValidBlockHeight,blockhash:F.recentBlockhash},z);if(L.err)throw Error(`Transaction ${M} failed (${JSON.stringify(L)})`);while(!0){try{if(await T.getSlot({commitment:z})>E.slot)break}catch{}await new Promise((B)=>setTimeout(B,Math.round(RI/2)))}}return!0}}OC.chunkSize=SI;var Yg=new n("BPFLoader2111111111111111111111111111111111");var Zg=globalThis.fetch;var qg={index:1,layout:N.struct([N.u32("typeIndex"),n8("deactivationSlot"),N.nu64("lastExtendedSlot"),N.u8("lastExtendedStartIndex"),N.u8(),N.seq(W1(),N.offset(N.u8(),-1),"authority")])};var B1=f8(RC(n),p(),(T)=>new n(T)),HY=FC([p(),L1("base64")]),BW=f8(RC(w),HY,(T)=>w.from(T[0],"base64"));function KY(T){return mT([y({jsonrpc:L1("2.0"),id:p(),result:T}),y({jsonrpc:L1("2.0"),id:p(),error:y({code:q8(),message:p(),data:A1(WV())})})])}var MI=KY(q8());function D1(T){return f8(KY(T),MI,(A)=>{if("error"in A)return A;else return{...A,result:r8(A.result,T)}})}function I0(T){return D1(y({context:y({slot:O()}),value:T}))}function xC(T){return y({context:y({slot:O()}),value:T})}var II=y({foundation:O(),foundationTerm:O(),initial:O(),taper:O(),terminal:O()}),Xg=D1(s(t(y({epoch:O(),effectiveSlot:O(),amount:O(),postBalance:O(),commission:A1(t(O()))})))),NI=s(y({slot:O(),prioritizationFee:O()})),LI=y({total:O(),validator:O(),foundation:O(),epoch:O()}),wI=y({epoch:O(),slotIndex:O(),slotsInEpoch:O(),absoluteSlot:O(),blockHeight:A1(O()),transactionCount:A1(O())}),EI=y({slotsPerEpoch:O(),leaderScheduleSlotOffset:O(),warmup:M0(),firstNormalEpoch:O(),firstNormalSlot:O()}),BI=CW(p(),s(O())),X8=t(mT([y({}),p()])),OI=y({err:X8}),_I=L1("receivedSignature"),Hg=y({"solana-core":p(),"feature-set":A1(O())}),xI=y({program:p(),programId:B1,parsed:q8()}),hI=y({programId:B1,accounts:s(B1),data:p()}),Kg=I0(y({err:t(mT([y({}),p()])),logs:t(s(p())),accounts:A1(t(s(t(y({executable:M0(),owner:p(),lamports:O(),data:s(p()),rentEpoch:A1(O())}))))),unitsConsumed:A1(O()),returnData:A1(t(y({programId:p(),data:FC([p(),L1("base64")])}))),innerInstructions:A1(t(s(y({index:O(),instructions:s(mT([xI,hI]))}))))})),kg=I0(y({byIdentity:CW(p(),s(O())),range:y({firstSlot:O(),lastSlot:O()})}));var jg=D1(II),Rg=D1(LI),Fg=D1(NI),Dg=D1(wI),zg=D1(EI),Sg=D1(BI),Mg=D1(O()),Ig=I0(y({total:O(),circulating:O(),nonCirculating:O(),nonCirculatingAccounts:s(B1)})),mI=y({amount:p(),uiAmount:t(O()),decimals:O(),uiAmountString:A1(p())}),Ng=I0(s(y({address:B1,amount:p(),uiAmount:t(O()),decimals:O(),uiAmountString:A1(p())}))),Lg=I0(s(y({pubkey:B1,account:y({executable:M0(),owner:B1,lamports:O(),data:BW,rentEpoch:O()})}))),wW=y({program:p(),parsed:q8(),space:O()}),wg=I0(s(y({pubkey:B1,account:y({executable:M0(),owner:B1,lamports:O(),data:wW,rentEpoch:O()})}))),Eg=I0(s(y({lamports:O(),address:B1}))),OW=y({executable:M0(),owner:B1,lamports:O(),data:BW,rentEpoch:O()}),Bg=y({pubkey:B1,account:OW}),gI=f8(mT([RC(w),wW]),mT([HY,wW]),(T)=>{if(Array.isArray(T))return r8(T,BW);else return T}),vI=y({executable:M0(),owner:B1,lamports:O(),data:gI,rentEpoch:O()}),Og=y({pubkey:B1,account:vI}),_g=y({state:mT([L1("active"),L1("inactive"),L1("activating"),L1("deactivating")]),active:O(),inactive:O()}),xg=D1(s(y({signature:p(),slot:O(),err:X8,memo:t(p()),blockTime:A1(t(O()))}))),hg=D1(s(y({signature:p(),slot:O(),err:X8,memo:t(p()),blockTime:A1(t(O()))}))),mg=y({subscription:O(),result:xC(OW)}),yI=y({pubkey:B1,account:OW}),gg=y({subscription:O(),result:xC(yI)}),bI=y({parent:O(),slot:O(),root:O()}),vg=y({subscription:O(),result:bI}),lI=mT([y({type:mT([L1("firstShredReceived"),L1("completed"),L1("optimisticConfirmation"),L1("root")]),slot:O(),timestamp:O()}),y({type:L1("createdBank"),parent:O(),slot:O(),timestamp:O()}),y({type:L1("frozen"),slot:O(),timestamp:O(),stats:y({numTransactionEntries:O(),numSuccessfulTransactions:O(),numFailedTransactions:O(),maxTransactionsPerEntry:O()})}),y({type:L1("dead"),slot:O(),timestamp:O(),err:p()})]),yg=y({subscription:O(),result:lI}),bg=y({subscription:O(),result:xC(mT([OI,_I]))}),lg=y({subscription:O(),result:O()}),pg=y({pubkey:p(),gossip:t(p()),tpu:t(p()),rpc:t(p()),version:t(p())}),sV=y({votePubkey:p(),nodePubkey:p(),activatedStake:O(),epochVoteAccount:M0(),epochCredits:s(FC([O(),O(),O()])),commission:O(),lastVote:O(),rootSlot:t(O())}),ug=D1(y({current:s(sV),delinquent:s(sV)})),pI=mT([L1("processed"),L1("confirmed"),L1("finalized")]),uI=y({slot:O(),confirmations:t(O()),err:X8,confirmationStatus:A1(pI)}),dg=I0(s(t(uI))),rg=D1(O()),kY=y({accountKey:B1,writableIndexes:s(O()),readonlyIndexes:s(O())}),_W=y({signatures:s(p()),message:y({accountKeys:s(p()),header:y({numRequiredSignatures:O(),numReadonlySignedAccounts:O(),numReadonlyUnsignedAccounts:O()}),instructions:s(y({accounts:s(O()),data:p(),programIdIndex:O()})),recentBlockhash:p(),addressTableLookups:A1(s(kY))})}),jY=y({pubkey:B1,signer:M0(),writable:M0(),source:A1(mT([L1("transaction"),L1("lookupTable")]))}),RY=y({accountKeys:s(jY),signatures:s(p())}),FY=y({parsed:q8(),program:p(),programId:B1}),DY=y({accounts:s(B1),data:p(),programId:B1}),dI=mT([DY,FY]),rI=mT([y({parsed:q8(),program:p(),programId:p()}),y({accounts:s(p()),data:p(),programId:p()})]),zY=f8(dI,rI,(T)=>{if("accounts"in T)return r8(T,DY);else return r8(T,FY)}),SY=y({signatures:s(p()),message:y({accountKeys:s(jY),instructions:s(zY),recentBlockhash:p(),addressTableLookups:A1(t(s(kY)))})}),_C=y({accountIndex:O(),mint:p(),owner:A1(p()),programId:A1(p()),uiTokenAmount:mI}),MY=y({writable:s(B1),readonly:s(B1)}),hC=y({err:X8,fee:O(),innerInstructions:A1(t(s(y({index:O(),instructions:s(y({accounts:s(O()),data:p(),programIdIndex:O()}))})))),preBalances:s(O()),postBalances:s(O()),logMessages:A1(t(s(p()))),preTokenBalances:A1(t(s(_C))),postTokenBalances:A1(t(s(_C))),loadedAddresses:A1(MY),computeUnitsConsumed:A1(O()),costUnits:A1(O())}),xW=y({err:X8,fee:O(),innerInstructions:A1(t(s(y({index:O(),instructions:s(zY)})))),preBalances:s(O()),postBalances:s(O()),logMessages:A1(t(s(p()))),preTokenBalances:A1(t(s(_C))),postTokenBalances:A1(t(s(_C))),loadedAddresses:A1(MY),computeUnitsConsumed:A1(O()),costUnits:A1(O())}),s8=mT([L1(0),L1("legacy")]),H8=y({pubkey:p(),lamports:O(),postBalance:t(O()),rewardType:t(p()),commission:A1(t(O()))}),fg=D1(t(y({blockhash:p(),previousBlockhash:p(),parentSlot:O(),transactions:s(y({transaction:_W,meta:t(hC),version:A1(s8)})),rewards:A1(s(H8)),blockTime:t(O()),blockHeight:t(O())}))),ig=D1(t(y({blockhash:p(),previousBlockhash:p(),parentSlot:O(),rewards:A1(s(H8)),blockTime:t(O()),blockHeight:t(O())}))),cg=D1(t(y({blockhash:p(),previousBlockhash:p(),parentSlot:O(),transactions:s(y({transaction:RY,meta:t(hC),version:A1(s8)})),rewards:A1(s(H8)),blockTime:t(O()),blockHeight:t(O())}))),og=D1(t(y({blockhash:p(),previousBlockhash:p(),parentSlot:O(),transactions:s(y({transaction:SY,meta:t(xW),version:A1(s8)})),rewards:A1(s(H8)),blockTime:t(O()),blockHeight:t(O())}))),ng=D1(t(y({blockhash:p(),previousBlockhash:p(),parentSlot:O(),transactions:s(y({transaction:RY,meta:t(xW),version:A1(s8)})),rewards:A1(s(H8)),blockTime:t(O()),blockHeight:t(O())}))),ag=D1(t(y({blockhash:p(),previousBlockhash:p(),parentSlot:O(),rewards:A1(s(H8)),blockTime:t(O()),blockHeight:t(O())}))),sg=D1(t(y({blockhash:p(),previousBlockhash:p(),parentSlot:O(),transactions:s(y({transaction:_W,meta:t(hC)})),rewards:A1(s(H8)),blockTime:t(O())}))),tg=D1(t(y({blockhash:p(),previousBlockhash:p(),parentSlot:O(),signatures:s(p()),blockTime:t(O())}))),eg=D1(t(y({slot:O(),meta:t(hC),blockTime:A1(t(O())),transaction:_W,version:A1(s8)}))),Tv=D1(t(y({slot:O(),transaction:SY,meta:t(xW),blockTime:A1(t(O())),version:A1(s8)}))),Av=I0(y({blockhash:p(),lastValidBlockHeight:O()})),Cv=I0(M0()),fI=y({slot:O(),numTransactions:O(),numSlots:O(),samplePeriodSecs:O()}),Pv=D1(s(fI)),Qv=I0(t(y({feeCalculator:y({lamportsPerSignature:O()})}))),Wv=D1(p()),Gv=D1(p()),iI=y({err:X8,logs:s(p()),signature:p()}),Jv=y({result:xC(iI),subscription:O()});class o2{constructor(T){this._keypair=void 0,this._keypair=T??iV()}static generate(){return new o2(iV())}static fromSecretKey(T,A){if(T.byteLength!==64)throw Error("bad secret key size");let C=T.slice(32,64);if(!A||!A.skipValidation){let P=T.slice(0,32),Q=NW(P);for(let W=0;W<32;W++)if(C[W]!==Q[W])throw Error("provided secretKey is invalid")}return new o2({publicKey:C,secretKey:T})}static fromSeed(T){let A=NW(T),C=new Uint8Array(64);return C.set(T),C.set(A,32),new o2({publicKey:A,secretKey:C})}get publicKey(){return new n(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}}var u2=Object.freeze({CreateLookupTable:{index:0,layout:N.struct([N.u32("instruction"),n8("recentSlot"),N.u8("bumpSeed")])},FreezeLookupTable:{index:1,layout:N.struct([N.u32("instruction")])},ExtendLookupTable:{index:2,layout:N.struct([N.u32("instruction"),n8(),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 IY{constructor(){}static createLookupTable(T){let[A,C]=n.findProgramAddressSync([T.authority.toBuffer(),TW().encode(T.recentSlot)],this.programId),P=u2.CreateLookupTable,Q=Q1(P,{recentSlot:BigInt(T.recentSlot),bumpSeed:C}),W=[{pubkey:A,isSigner:!1,isWritable:!0},{pubkey:T.authority,isSigner:!0,isWritable:!1},{pubkey:T.payer,isSigner:!0,isWritable:!0},{pubkey:kT.programId,isSigner:!1,isWritable:!1}];return[new V1({programId:this.programId,keys:W,data:Q}),A]}static freezeLookupTable(T){let A=u2.FreezeLookupTable,C=Q1(A),P=[{pubkey:T.lookupTable,isSigner:!1,isWritable:!0},{pubkey:T.authority,isSigner:!0,isWritable:!1}];return new V1({programId:this.programId,keys:P,data:C})}static extendLookupTable(T){let A=u2.ExtendLookupTable,C=Q1(A,{addresses:T.addresses.map((Q)=>Q.toBytes())}),P=[{pubkey:T.lookupTable,isSigner:!1,isWritable:!0},{pubkey:T.authority,isSigner:!0,isWritable:!1}];if(T.payer)P.push({pubkey:T.payer,isSigner:!0,isWritable:!0},{pubkey:kT.programId,isSigner:!1,isWritable:!1});return new V1({programId:this.programId,keys:P,data:C})}static deactivateLookupTable(T){let A=u2.DeactivateLookupTable,C=Q1(A),P=[{pubkey:T.lookupTable,isSigner:!1,isWritable:!0},{pubkey:T.authority,isSigner:!0,isWritable:!1}];return new V1({programId:this.programId,keys:P,data:C})}static closeLookupTable(T){let A=u2.CloseLookupTable,C=Q1(A),P=[{pubkey:T.lookupTable,isSigner:!1,isWritable:!0},{pubkey:T.authority,isSigner:!0,isWritable:!1},{pubkey:T.recipient,isSigner:!1,isWritable:!0}];return new V1({programId:this.programId,keys:P,data:C})}}IY.programId=new n("AddressLookupTab1e1111111111111111111111111");var wC=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"),n8("microLamports")])}});class NY{constructor(){}static requestUnits(T){let A=wC.RequestUnits,C=Q1(A,T);return new V1({keys:[],programId:this.programId,data:C})}static requestHeapFrame(T){let A=wC.RequestHeapFrame,C=Q1(A,T);return new V1({keys:[],programId:this.programId,data:C})}static setComputeUnitLimit(T){let A=wC.SetComputeUnitLimit,C=Q1(A,T);return new V1({keys:[],programId:this.programId,data:C})}static setComputeUnitPrice(T){let A=wC.SetComputeUnitPrice,C=Q1(A,{microLamports:BigInt(T.microLamports)});return new V1({keys:[],programId:this.programId,data:C})}}NY.programId=new n("ComputeBudget111111111111111111111111111111");var tV=64,eV=32,TY=64,AY=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 hW{constructor(){}static createInstructionWithPublicKey(T){let{publicKey:A,message:C,signature:P,instructionIndex:Q}=T;DT(A.length===eV,`Public Key must be ${eV} bytes but received ${A.length} bytes`),DT(P.length===TY,`Signature must be ${TY} bytes but received ${P.length} bytes`);let W=AY.span,G=W+A.length,U=G+P.length,$=1,X=w.alloc(U+C.length),q=Q==null?65535:Q;return AY.encode({numSignatures:$,padding:0,signatureOffset:G,signatureInstructionIndex:q,publicKeyOffset:W,publicKeyInstructionIndex:q,messageDataOffset:U,messageDataSize:C.length,messageInstructionIndex:q},X),X.fill(A,W),X.fill(P,G),X.fill(C,U),new V1({keys:[],programId:hW.programId,data:X})}static createInstructionWithPrivateKey(T){let{privateKey:A,message:C,instructionIndex:P}=T;DT(A.length===tV,`Private key must be ${tV} bytes but received ${A.length} bytes`);try{let Q=o2.fromSecretKey(A),W=Q.publicKey.toBytes(),G=WY(C,Q.secretKey);return this.createInstructionWithPublicKey({publicKey:W,message:C,signature:G,instructionIndex:P})}catch(Q){throw Error(`Error creating instruction; ${Q}`)}}}hW.programId=new n("Ed25519SigVerify111111111111111111111111111");var cI=(T,A)=>{let C=NC.sign(T,A);return[C.toCompactRawBytes(),C.recovery]};NC.utils.isValidPrivateKey;var oI=NC.getPublicKey,CY=32,SW=20,PY=64,nI=11,MW=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 n2{constructor(){}static publicKeyToEthAddress(T){DT(T.length===PY,`Public key must be ${PY} bytes but received ${T.length} bytes`);try{return w.from(XW($1(T))).slice(-SW)}catch(A){throw Error(`Error constructing Ethereum address: ${A}`)}}static createInstructionWithPublicKey(T){let{publicKey:A,message:C,signature:P,recoveryId:Q,instructionIndex:W}=T;return n2.createInstructionWithEthAddress({ethAddress:n2.publicKeyToEthAddress(A),message:C,signature:P,recoveryId:Q,instructionIndex:W})}static createInstructionWithEthAddress(T){let{ethAddress:A,message:C,signature:P,recoveryId:Q,instructionIndex:W=0}=T,G;if(typeof A==="string")if(A.startsWith("0x"))G=w.from(A.substr(2),"hex");else G=w.from(A,"hex");else G=A;DT(G.length===SW,`Address must be ${SW} bytes but received ${G.length} bytes`);let U=1+nI,$=U,X=U+G.length,q=X+P.length+1,K=1,F=w.alloc(MW.span+C.length);return MW.encode({numSignatures:K,signatureOffset:X,signatureInstructionIndex:W,ethAddressOffset:$,ethAddressInstructionIndex:W,messageDataOffset:q,messageDataSize:C.length,messageInstructionIndex:W,signature:$1(P),ethAddress:$1(G),recoveryId:Q},F),F.fill($1(C),MW.span),new V1({keys:[],programId:n2.programId,data:F})}static createInstructionWithPrivateKey(T){let{privateKey:A,message:C,instructionIndex:P}=T;DT(A.length===CY,`Private key must be ${CY} bytes but received ${A.length} bytes`);try{let Q=$1(A),W=oI(Q,!1).slice(1),G=w.from(XW($1(C))),[U,$]=cI(G,Q);return this.createInstructionWithPublicKey({publicKey:W,message:C,signature:U,recoveryId:$,instructionIndex:P})}catch(Q){throw Error(`Error creating instruction; ${Q}`)}}}n2.programId=new n("KeccakSecp256k11111111111111111111111111111");var LY,aI=new n("StakeConfig11111111111111111111111111111111");class mC{constructor(T,A,C){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=T,this.epoch=A,this.custodian=C}}LY=mC;mC.default=new LY(0,0,n.default);var bA=Object.freeze({Initialize:{index:0,layout:N.struct([N.u32("instruction"),YI(),ZI()])},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"),o8("authoritySeed"),W1("authorityOwner")])}}),Uv=Object.freeze({Staker:{index:0},Withdrawer:{index:1}});class mW{constructor(){}static initialize(T){let{stakePubkey:A,authorized:C,lockup:P}=T,Q=P||mC.default,W=bA.Initialize,G=Q1(W,{authorized:{staker:$1(C.staker.toBuffer()),withdrawer:$1(C.withdrawer.toBuffer())},lockup:{unixTimestamp:Q.unixTimestamp,epoch:Q.epoch,custodian:$1(Q.custodian.toBuffer())}}),U={keys:[{pubkey:A,isSigner:!1,isWritable:!0},{pubkey:s2,isSigner:!1,isWritable:!1}],programId:this.programId,data:G};return new V1(U)}static createAccountWithSeed(T){let A=new S1;A.add(kT.createAccountWithSeed({fromPubkey:T.fromPubkey,newAccountPubkey:T.stakePubkey,basePubkey:T.basePubkey,seed:T.seed,lamports:T.lamports,space:this.space,programId:this.programId}));let{stakePubkey:C,authorized:P,lockup:Q}=T;return A.add(this.initialize({stakePubkey:C,authorized:P,lockup:Q}))}static createAccount(T){let A=new S1;A.add(kT.createAccount({fromPubkey:T.fromPubkey,newAccountPubkey:T.stakePubkey,lamports:T.lamports,space:this.space,programId:this.programId}));let{stakePubkey:C,authorized:P,lockup:Q}=T;return A.add(this.initialize({stakePubkey:C,authorized:P,lockup:Q}))}static delegate(T){let{stakePubkey:A,authorizedPubkey:C,votePubkey:P}=T,Q=bA.Delegate,W=Q1(Q);return new S1().add({keys:[{pubkey:A,isSigner:!1,isWritable:!0},{pubkey:P,isSigner:!1,isWritable:!1},{pubkey:ZA,isSigner:!1,isWritable:!1},{pubkey:zW,isSigner:!1,isWritable:!1},{pubkey:aI,isSigner:!1,isWritable:!1},{pubkey:C,isSigner:!0,isWritable:!1}],programId:this.programId,data:W})}static authorize(T){let{stakePubkey:A,authorizedPubkey:C,newAuthorizedPubkey:P,stakeAuthorizationType:Q,custodianPubkey:W}=T,G=bA.Authorize,U=Q1(G,{newAuthorized:$1(P.toBuffer()),stakeAuthorizationType:Q.index}),$=[{pubkey:A,isSigner:!1,isWritable:!0},{pubkey:ZA,isSigner:!1,isWritable:!0},{pubkey:C,isSigner:!0,isWritable:!1}];if(W)$.push({pubkey:W,isSigner:!0,isWritable:!1});return new S1().add({keys:$,programId:this.programId,data:U})}static authorizeWithSeed(T){let{stakePubkey:A,authorityBase:C,authoritySeed:P,authorityOwner:Q,newAuthorizedPubkey:W,stakeAuthorizationType:G,custodianPubkey:U}=T,$=bA.AuthorizeWithSeed,X=Q1($,{newAuthorized:$1(W.toBuffer()),stakeAuthorizationType:G.index,authoritySeed:P,authorityOwner:$1(Q.toBuffer())}),q=[{pubkey:A,isSigner:!1,isWritable:!0},{pubkey:C,isSigner:!0,isWritable:!1},{pubkey:ZA,isSigner:!1,isWritable:!1}];if(U)q.push({pubkey:U,isSigner:!0,isWritable:!1});return new S1().add({keys:q,programId:this.programId,data:X})}static splitInstruction(T){let{stakePubkey:A,authorizedPubkey:C,splitStakePubkey:P,lamports:Q}=T,W=bA.Split,G=Q1(W,{lamports:Q});return new V1({keys:[{pubkey:A,isSigner:!1,isWritable:!0},{pubkey:P,isSigner:!1,isWritable:!0},{pubkey:C,isSigner:!0,isWritable:!1}],programId:this.programId,data:G})}static split(T,A){let C=new S1;return C.add(kT.createAccount({fromPubkey:T.authorizedPubkey,newAccountPubkey:T.splitStakePubkey,lamports:A,space:this.space,programId:this.programId})),C.add(this.splitInstruction(T))}static splitWithSeed(T,A){let{stakePubkey:C,authorizedPubkey:P,splitStakePubkey:Q,basePubkey:W,seed:G,lamports:U}=T,$=new S1;if($.add(kT.allocate({accountPubkey:Q,basePubkey:W,seed:G,space:this.space,programId:this.programId})),A&&A>0)$.add(kT.transfer({fromPubkey:T.authorizedPubkey,toPubkey:Q,lamports:A}));return $.add(this.splitInstruction({stakePubkey:C,authorizedPubkey:P,splitStakePubkey:Q,lamports:U}))}static merge(T){let{stakePubkey:A,sourceStakePubKey:C,authorizedPubkey:P}=T,Q=bA.Merge,W=Q1(Q);return new S1().add({keys:[{pubkey:A,isSigner:!1,isWritable:!0},{pubkey:C,isSigner:!1,isWritable:!0},{pubkey:ZA,isSigner:!1,isWritable:!1},{pubkey:zW,isSigner:!1,isWritable:!1},{pubkey:P,isSigner:!0,isWritable:!1}],programId:this.programId,data:W})}static withdraw(T){let{stakePubkey:A,authorizedPubkey:C,toPubkey:P,lamports:Q,custodianPubkey:W}=T,G=bA.Withdraw,U=Q1(G,{lamports:Q}),$=[{pubkey:A,isSigner:!1,isWritable:!0},{pubkey:P,isSigner:!1,isWritable:!0},{pubkey:ZA,isSigner:!1,isWritable:!1},{pubkey:zW,isSigner:!1,isWritable:!1},{pubkey:C,isSigner:!0,isWritable:!1}];if(W)$.push({pubkey:W,isSigner:!0,isWritable:!1});return new S1().add({keys:$,programId:this.programId,data:U})}static deactivate(T){let{stakePubkey:A,authorizedPubkey:C}=T,P=bA.Deactivate,Q=Q1(P);return new S1().add({keys:[{pubkey:A,isSigner:!1,isWritable:!0},{pubkey:ZA,isSigner:!1,isWritable:!1},{pubkey:C,isSigner:!0,isWritable:!1}],programId:this.programId,data:Q})}}mW.programId=new n("Stake11111111111111111111111111111111111111");mW.space=200;var d2=Object.freeze({InitializeAccount:{index:0,layout:N.struct([N.u32("instruction"),qI()])},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"),XI()])}}),$v=Object.freeze({Voter:{index:0},Withdrawer:{index:1}});class gC{constructor(){}static initializeAccount(T){let{votePubkey:A,nodePubkey:C,voteInit:P}=T,Q=d2.InitializeAccount,W=Q1(Q,{voteInit:{nodePubkey:$1(P.nodePubkey.toBuffer()),authorizedVoter:$1(P.authorizedVoter.toBuffer()),authorizedWithdrawer:$1(P.authorizedWithdrawer.toBuffer()),commission:P.commission}}),G={keys:[{pubkey:A,isSigner:!1,isWritable:!0},{pubkey:s2,isSigner:!1,isWritable:!1},{pubkey:ZA,isSigner:!1,isWritable:!1},{pubkey:C,isSigner:!0,isWritable:!1}],programId:this.programId,data:W};return new V1(G)}static createAccount(T){let A=new S1;return A.add(kT.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:C,newAuthorizedPubkey:P,voteAuthorizationType:Q}=T,W=d2.Authorize,G=Q1(W,{newAuthorized:$1(P.toBuffer()),voteAuthorizationType:Q.index}),U=[{pubkey:A,isSigner:!1,isWritable:!0},{pubkey:ZA,isSigner:!1,isWritable:!1},{pubkey:C,isSigner:!0,isWritable:!1}];return new S1().add({keys:U,programId:this.programId,data:G})}static authorizeWithSeed(T){let{currentAuthorityDerivedKeyBasePubkey:A,currentAuthorityDerivedKeyOwnerPubkey:C,currentAuthorityDerivedKeySeed:P,newAuthorizedPubkey:Q,voteAuthorizationType:W,votePubkey:G}=T,U=d2.AuthorizeWithSeed,$=Q1(U,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:$1(C.toBuffer()),currentAuthorityDerivedKeySeed:P,newAuthorized:$1(Q.toBuffer()),voteAuthorizationType:W.index}}),X=[{pubkey:G,isSigner:!1,isWritable:!0},{pubkey:ZA,isSigner:!1,isWritable:!1},{pubkey:A,isSigner:!0,isWritable:!1}];return new S1().add({keys:X,programId:this.programId,data:$})}static withdraw(T){let{votePubkey:A,authorizedWithdrawerPubkey:C,lamports:P,toPubkey:Q}=T,W=d2.Withdraw,G=Q1(W,{lamports:P}),U=[{pubkey:A,isSigner:!1,isWritable:!0},{pubkey:Q,isSigner:!1,isWritable:!0},{pubkey:C,isSigner:!0,isWritable:!1}];return new S1().add({keys:U,programId:this.programId,data:G})}static safeWithdraw(T,A,C){if(T.lamports>A-C)throw Error("Withdraw will leave vote account with insufficient funds.");return gC.withdraw(T)}static updateValidatorIdentity(T){let{votePubkey:A,authorizedWithdrawerPubkey:C,nodePubkey:P}=T,Q=d2.UpdateValidatorIdentity,W=Q1(Q),G=[{pubkey:A,isSigner:!1,isWritable:!0},{pubkey:P,isSigner:!0,isWritable:!1},{pubkey:C,isSigner:!0,isWritable:!1}];return new S1().add({keys:G,programId:this.programId,data:W})}}gC.programId=new n("Vote111111111111111111111111111111111111111");gC.space=3762;var Vv=new n("Va1idator1nfo111111111111111111111111111111"),Yv=y({name:p(),website:A1(p()),details:A1(p()),iconUrl:A1(p()),keybaseUsername:A1(p())});var Zv=new n("Vote111111111111111111111111111111111111111"),qv=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 P0=new n("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"),Kv=new n("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"),d0=new n("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"),kv=new n("So11111111111111111111111111111111111111112"),jv=new n("9pan9bMn5HatX4EJdBwg9VgCa7Uz5HL8N1m5D3NdXejP");var K8=(T)=>{let A=T.decode.bind(T),C=T.encode.bind(T);return{decode:A,encode:C}};var gW=nT(UA(),1),lA=nT(EY(),1);var yC=(T)=>(A)=>{let C=gW.blob(T,A),{encode:P,decode:Q}=K8(C),W=C;return W.decode=(G,U)=>{let $=Q(G,U);return lA.toBigIntLE(Buffer.from($))},W.encode=(G,U,$)=>{let X=lA.toBufferLE(G,T);return P(X,U,$)},W},bC=(T)=>(A)=>{let C=gW.blob(T,A),{encode:P,decode:Q}=K8(C),W=C;return W.decode=(G,U)=>{let $=Q(G,U);return lA.toBigIntBE(Buffer.from($))},W.encode=(G,U,$)=>{let X=lA.toBufferBE(G,T);return P(X,U,$)},W},BY=yC(8),Sv=bC(8),Mv=yC(16),Iv=bC(16),Nv=yC(24),Lv=bC(24),wv=yC(32),Ev=bC(32);var OY=nT(UA(),1);var _Y=(T)=>{let A=OY.u8(T),{encode:C,decode:P}=K8(A),Q=A;return Q.decode=(W,G)=>{return!!P(W,G)},Q.encode=(W,G,U)=>{let $=Number(W);return C($,G,U)},Q};var xY=nT(UA(),1);var vW=(T)=>{let A=xY.blob(32,T),{encode:C,decode:P}=K8(A),Q=A;return Q.decode=(W,G)=>{let U=P(W,G);return new n(U)},Q.encode=(W,G,U)=>{let $=W.toBuffer();return C($,G,U)},Q};class hY extends Error{constructor(T){super(T)}}class yW extends hY{constructor(){super(...arguments);this.name="TokenOwnerOffCurveError"}}var t8;(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"})(t8||(t8={}));var k8=nT(UA(),1);function mY(T,A,C){if(C.length){T.push({pubkey:A,isSigner:!1,isWritable:!1});for(let P of C)T.push({pubkey:P instanceof n?P:P.publicKey,isSigner:!0,isWritable:!1})}else T.push({pubkey:A,isSigner:!0,isWritable:!1});return T}var WN=k8.struct([k8.u32("mintAuthorityOption"),vW("mintAuthority"),BY("supply"),k8.u8("decimals"),_Y("isInitialized"),k8.u32("freezeAuthorityOption"),vW("freezeAuthority")]),ov=WN.span;function t2(T,A,C=!1,P=P0,Q=d0){if(!C&&!n.isOnCurve(A.toBuffer()))throw new yW;let[W]=n.findProgramAddressSync([A.toBuffer(),P.toBuffer(),T.toBuffer()],Q);return W}var lC=nT(UA(),1);var gY=lC.struct([lC.u8("instruction")]);function bW(T,A,C,P=[],Q=P0){let W=mY([{pubkey:T,isSigner:!1,isWritable:!0},{pubkey:A,isSigner:!1,isWritable:!0}],C,P),G=Buffer.alloc(gY.span);return gY.encode({instruction:t8.CloseAccount},G),new V1({keys:W,programId:Q,data:G})}function pC(T,A,C,P,Q=P0,W=d0){return GN(T,A,C,P,Buffer.alloc(0),Q,W)}function GN(T,A,C,P,Q,W=P0,G=d0){let U=[{pubkey:T,isSigner:!0,isWritable:!0},{pubkey:A,isSigner:!1,isWritable:!0},{pubkey:C,isSigner:!1,isWritable:!1},{pubkey:P,isSigner:!1,isWritable:!1},{pubkey:kT.programId,isSigner:!1,isWritable:!1},{pubkey:W,isSigner:!1,isWritable:!1}];return new V1({keys:U,programId:G,data:Q})}var uC=nT(UA(),1);var vY=uC.struct([uC.u8("instruction")]);function yY(T,A=P0){let C=[{pubkey:T,isSigner:!1,isWritable:!0}],P=Buffer.alloc(vY.span);return vY.encode({instruction:t8.SyncNative},P),new V1({keys:C,programId:A,data:P})}function dC(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 bY(T){if(T instanceof n)return T;return dC(T)}function JN(T){return{programAddress:_(T.programId.toBase58()),accounts:T.keys.map((A)=>({address:_(A.pubkey.toBase58()),role:A.isSigner?A.isWritable?R1.WRITABLE_SIGNER:R1.READONLY_SIGNER:A.isWritable?R1.WRITABLE:R1.READONLY})),data:T.data}}function e8(T){let{payer:A,owner:C,mint:P,tokenProgram:Q=P0,associatedTokenProgram:W=d0}=T,G=dC(A),U=dC(C),$=dC(P),X=bY(Q),q=bY(W),K=t2($,U,!1,X,q);return JN(pC(G,K,U,$,X,q))}var ky=new Uint8Array([143,52,146,187,219,123,76,155]);function $N(){return RT([["discriminator",xT(uT(),8)],["bump",DA()],["admin",z1()],["flatFees",u6()],["feeTiers",Y2(J$())]])}function VN(T){return kA(T,$N())}async function lY(T,A,C){let P=await YN(T,A,C);return RA(P),P}async function YN(T,A,C){let P=await jA(T,A,C);return VN(P)}var qA=10000n,T2=(T,A,C)=>{if(C<=0n)throw Error("Division by zero (floor)");return T*A/C},ZN=(T,A,C)=>{if(C<=0n)throw Error("Division by zero (ceil)");let P=T*A,Q=P/C;return P%C===0n?Q:Q+1n},lW=(T)=>{let A=BigInt(T.lpFeeBps),C=BigInt(T.protocolFeeBps),P=BigInt(T.creatorFeeBps),Q=A+C,W=Q+P;if(W>=qA)throw Error("Total fee basis points must be less than 10_000");return{totalFeeBps:W,combinedFeeBps:Q}},pW=(T)=>{let A=T.virtualTokenReserves+T.realTokenReserves,C=T.virtualSolReserves+T.realSolReserves;return A*C};function pY(T,A,C){if(C<=0n)throw Error("Total SOL cost must be positive");let{combinedFeeBps:P}=lW(A),Q=T2(C,P,qA),W=T2(C,BigInt(A.creatorFeeBps),qA),G=C-Q-W;if(G<=0n)throw Error("Net SOL after fees must be positive");let U=pW(T),$=T.virtualSolReserves+T.realSolReserves,X=T.virtualTokenReserves+T.realTokenReserves,q=$+G,K=U/q,F=X-K,z=F>T.realTokenReserves?T.realTokenReserves:F;if(z<=0n)throw Error("SOL amount is too small to purchase any tokens");let M=rC(T,A,z);while(M.totalSolCostLamports>C&&z>0n)z-=1n,M=rC(T,A,z);if(M.totalSolCostLamports>C)throw Error("Insufficient SOL to purchase any tokens with fees applied");return{tokenAmount:z,totalSolCostLamports:M.totalSolCostLamports,effectiveSolInLamports:M.effectiveSolInLamports,feeLamports:M.feeLamports,creatorFeeLamports:M.creatorFeeLamports}}function rC(T,A,C){if(C<=0n)throw Error("Token amount must be positive");if(C>T.realTokenReserves)throw Error("Token amount exceeds available reserves");let{combinedFeeBps:P,totalFeeBps:Q}=lW(A),W=pW(T),G=T.virtualSolReserves+T.realSolReserves,$=T.virtualTokenReserves+T.realTokenReserves-C;if($<=0n)throw Error("Purchase would exhaust token reserves");let q=W/$-G;if(q<=0n)throw Error("Resolved SOL input must be positive");let K=qA-Q,F=ZN(q,qA,K),z=T2(F,P,qA),M=T2(F,BigInt(A.creatorFeeBps),qA);return{tokenAmount:C,totalSolCostLamports:F,effectiveSolInLamports:q,feeLamports:z,creatorFeeLamports:M}}function uY(T,A,C){if(C<=0n)throw Error("Token amount must be positive");let P=pW(T),Q=T.virtualSolReserves+T.realSolReserves,G=T.virtualTokenReserves+T.realTokenReserves+C,U=P/G,$=Q-U;if($<=0n)throw Error("No SOL output available for the given token amount");let{combinedFeeBps:X}=lW(A),q=T2($,X,qA),K=T2($,BigInt(A.creatorFeeBps),qA),F=$-q-K;if(F<=0n)throw Error("SOL output after fees is non-positive");return{solOutputLamports:F,preFeeSolOutputLamports:$,feeLamports:q,creatorFeeLamports:K}}var dY=h0,qN=1e4,rY=(T,A)=>{if(!Number.isFinite(T)||T<=0)throw Error(`${A} must be a positive number`)},XN=(T)=>({lpFeeBps:T.lpFeeBps,protocolFeeBps:T.protocolFeeBps,creatorFeeBps:T.creatorFeeBps});async function fY(T,A,C,P){let Q=P?.curve?Promise.resolve(P.curve):(async()=>{let G=await x0(T);return(await SA(A,G,{commitment:C})).data})(),W=P?.fees?Promise.resolve(P.fees):(async()=>{let G=await j2(),U=await lY(A,G,{commitment:C});return XN(U.data.flatFees)})();try{let[G,U]=await Promise.all([Q,W]);return{curve:G,fees:U}}catch(G){throw Error("Failed to load bonding curve state. Provide overrides or ensure the RPC endpoint can access Pump accounts.",{cause:G})}}function HN(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 fC(T){rY(T.solAmount,"solAmount");let A=T.slippageBps??Q0;W0(A);let C=T.feeRecipient??dY,P=T.rpc,Q=T.commitment??I1(),{curve:W,fees:G}=await fY(T.mint,P,Q,{curve:T.curveStateOverride,fees:T.feeStructureOverride});if(W.complete)throw Error("Token has migrated to the AMM. Use ammBuy instead of curveBuy.");let U=T.bondingCurveCreator?_(T.bondingCurveCreator):W.creator,$=m0(T.solAmount),q=pY(W,G,$).tokenAmount,K=rC(W,G,q),z=a0(K.totalSolCostLamports,A)*2n,M=_(T.mint),[E]=await F1({owner:T.user.address,mint:M}),L;if(T.allowAtaCreation!==!1)try{if(!(await T.rpc.getAccountInfo(E,{encoding:"base64"}).send()).value)L=e8({payer:T.user,owner:T.user,mint:M})}catch(m){console.warn("[curveBuy] getAccountInfo failed for user ATA, defaulting to create",m),L=e8({payer:T.user,owner:T.user,mint:M})}let B=await vP({user:T.user,mint:T.mint,tokenAmount:q,maxSolCostLamports:z,feeRecipient:C,trackVolume:T.trackVolume,bondingCurveCreator:U,rpc:P,commitment:Q});if(L){let m=Object.assign({},B);return m.prepend=[L,...m.prepend??[]],m}return B}async function iC(T){let A=T.slippageBps??Q0;W0(A);let C=T.feeRecipient??dY,P=T.rpc,Q=T.commitment??I1(),{curve:W,fees:G}=await fY(T.mint,P,Q,{curve:T.curveStateOverride,fees:T.feeStructureOverride});if(W.complete)throw Error("Token has migrated to the AMM. Use ammSell instead of curveSell.");let U=T.bondingCurveCreator?_(T.bondingCurveCreator):W.creator,$=T.useWalletPercentage??!1,X=_(T.mint),q;if($){let z=T.walletPercentage??100,M=HN(z),[E]=await F1({owner:_(T.user.address),mint:X,tokenProgram:_(FT)}),L=await P.getTokenAccountBalance(E).send(),B=BigInt(L.value.amount);if(B===0n)throw Error("Wallet token balance is zero; nothing to sell");if(q=B*M/BigInt(qN),q<=0n)q=1n}else{if(T.tokenAmount===void 0)throw Error("tokenAmount is required when useWalletPercentage is false");rY(T.tokenAmount,"tokenAmount");let z=T.tokenDecimals??6;q=sA(T.tokenAmount,z)}let K=uY(W,G,q),F=aA(K.solOutputLamports,A);if(F<=0n)throw Error("Slippage settings would result in zero SOL output");return yP({user:T.user,mint:T.mint,tokenAmountRaw:q,minSolOutputLamports:F,feeRecipient:C,bondingCurveCreator:U,rpc:P,commitment:Q})}var pA=new TextEncoder,j8=O1();async function A2(T,A,C,P){let Q=new Uint8Array(2);Q[0]=T&255,Q[1]=T>>8&255;let[W]=await H1({programAddress:_(KT),seeds:[pA.encode("pool"),Q,j8.encode(_(A)),j8.encode(_(C)),j8.encode(_(P))]});return W}async function uW(T){let[A]=await H1({programAddress:_(KT),seeds:[pA.encode("pool_lp_mint"),j8.encode(_(T))]});return A}async function dW(T,A){let[C]=await P$({owner:T,mint:A});return C}async function F0(T,A,C){let[P]=await F1({owner:T,mint:A,tokenProgram:C});return P}async function C2(){let[T]=await H1({programAddress:_(KT),seeds:[pA.encode("global_config")]});return T}async function iY(){let[T]=await H1({programAddress:_(KT),seeds:[pA.encode("global_volume_accumulator")]});return T}async function cY(T){let[A]=await H1({programAddress:_(KT),seeds:[pA.encode("user_volume_accumulator"),j8.encode(_(T))]});return A}async function e2(){let[T]=await H1({programAddress:_(KT),seeds:[pA.encode("__event_authority")]});return T}async function rW(){let[T]=await H1({programAddress:_(_0),seeds:[pA.encode("fee_config"),j8.encode(_(KT))]});return T}async function fW(T){let[A]=await H1({programAddress:_(KT),seeds:[pA.encode("creator_vault"),j8.encode(_(T))]});return A}async function iW(T,A,C){let[P]=await F1({owner:T,mint:A,tokenProgram:C});return P}var q1="pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA";function $0(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 X1(T,A){return(C)=>{if(!C.value){if(A==="omitted")return;return Object.freeze({address:T,role:R1.READONLY})}let P=C.isWritable?R1.WRITABLE:R1.READONLY;return Object.freeze({address:$0(C.value),role:oY(C.value)?E6(P):P,...oY(C.value)?{signer:C.value}:{}})}}function oY(T){return!!T&&typeof T==="object"&&"address"in T&&O0(T)}var iy=new Uint8Array([242,40,117,145,73,96,105,104]);var ay=new Uint8Array([209,11,115,87,213,23,124,204]);function cC(){return L6([iA()])}var KN=new Uint8Array([102,6,61,18,1,218,235,234]);function kN(){return qT(XT([["discriminator",jT(ST(),8)],["baseAmountOut",M1()],["maxQuoteAmountIn",M1()],["trackVolume",cC()]]),(T)=>({...T,discriminator:KN}))}function aY(T,A){let C=A?.programAddress??q1,Q={pool:{value:T.pool??null,isWritable:!0},user:{value:T.user??null,isWritable:!0},globalConfig:{value:T.globalConfig??null,isWritable:!1},baseMint:{value:T.baseMint??null,isWritable:!1},quoteMint:{value:T.quoteMint??null,isWritable:!1},userBaseTokenAccount:{value:T.userBaseTokenAccount??null,isWritable:!0},userQuoteTokenAccount:{value:T.userQuoteTokenAccount??null,isWritable:!0},poolBaseTokenAccount:{value:T.poolBaseTokenAccount??null,isWritable:!0},poolQuoteTokenAccount:{value:T.poolQuoteTokenAccount??null,isWritable:!0},protocolFeeRecipient:{value:T.protocolFeeRecipient??null,isWritable:!1},protocolFeeRecipientTokenAccount:{value:T.protocolFeeRecipientTokenAccount??null,isWritable:!0},baseTokenProgram:{value:T.baseTokenProgram??null,isWritable:!1},quoteTokenProgram:{value:T.quoteTokenProgram??null,isWritable:!1},systemProgram:{value:T.systemProgram??null,isWritable:!1},associatedTokenProgram:{value:T.associatedTokenProgram??null,isWritable:!1},eventAuthority:{value:T.eventAuthority??null,isWritable:!1},program:{value:T.program??null,isWritable:!1},coinCreatorVaultAta:{value:T.coinCreatorVaultAta??null,isWritable:!0},coinCreatorVaultAuthority:{value:T.coinCreatorVaultAuthority??null,isWritable:!1},globalVolumeAccumulator:{value:T.globalVolumeAccumulator??null,isWritable:!1},userVolumeAccumulator:{value:T.userVolumeAccumulator??null,isWritable:!0},feeConfig:{value:T.feeConfig??null,isWritable:!1},feeProgram:{value:T.feeProgram??null,isWritable:!1}},W={...T};if(!Q.systemProgram.value)Q.systemProgram.value="11111111111111111111111111111111";if(!Q.associatedTokenProgram.value)Q.associatedTokenProgram.value="ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";if(!Q.program.value)Q.program.value="pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA";if(!Q.feeProgram.value)Q.feeProgram.value="pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ";let G=X1(C,"programId");return Object.freeze({accounts:[G(Q.pool),G(Q.user),G(Q.globalConfig),G(Q.baseMint),G(Q.quoteMint),G(Q.userBaseTokenAccount),G(Q.userQuoteTokenAccount),G(Q.poolBaseTokenAccount),G(Q.poolQuoteTokenAccount),G(Q.protocolFeeRecipient),G(Q.protocolFeeRecipientTokenAccount),G(Q.baseTokenProgram),G(Q.quoteTokenProgram),G(Q.systemProgram),G(Q.associatedTokenProgram),G(Q.eventAuthority),G(Q.program),G(Q.coinCreatorVaultAta),G(Q.coinCreatorVaultAuthority),G(Q.globalVolumeAccumulator),G(Q.userVolumeAccumulator),G(Q.feeConfig),G(Q.feeProgram)],data:kN().encode(W),programAddress:C})}var Yl=new Uint8Array([198,46,21,82,180,217,232,112]);var Hl=new Uint8Array([37,58,35,126,190,53,228,197]);var Rl=new Uint8Array([16,4,71,28,204,1,40,27]);var Sl=new Uint8Array([249,69,164,218,150,103,84,138]);var Ll=new Uint8Array([160,57,89,42,181,139,43,66]);var Ol=new Uint8Array([201,207,243,114,75,111,47,189]);var vl=new Uint8Array([233,146,209,142,207,104,64,188]);var jN=new Uint8Array([242,35,198,137,82,225,242,182]);function RN(){return qT(XT([["discriminator",jT(ST(),8)],["lpTokenAmountOut",M1()],["maxBaseAmountIn",M1()],["maxQuoteAmountIn",M1()]]),(T)=>({...T,discriminator:jN}))}function sY(T,A){let C=A?.programAddress??q1,Q={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(!Q.tokenProgram.value)Q.tokenProgram.value="TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";if(!Q.token2022Program.value)Q.token2022Program.value="TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";let G=X1(C,"programId");return Object.freeze({accounts:[G(Q.pool),G(Q.globalConfig),G(Q.user),G(Q.baseMint),G(Q.quoteMint),G(Q.lpMint),G(Q.userBaseTokenAccount),G(Q.userQuoteTokenAccount),G(Q.userPoolTokenAccount),G(Q.poolBaseTokenAccount),G(Q.poolQuoteTokenAccount),G(Q.tokenProgram),G(Q.token2022Program),G(Q.eventAuthority),G(Q.program)],data:RN().encode(W),programAddress:C})}var fl=new Uint8Array([185,173,187,90,216,15,238,233]);var nl=new Uint8Array([234,102,194,203,150,72,62,229]);var el=new Uint8Array([94,6,202,115,255,96,232,183]);var Pp=new Uint8Array([208,8,159,4,74,175,16,58]);var FN=new Uint8Array([51,230,133,164,1,127,131,173]);function DN(){return qT(XT([["discriminator",jT(ST(),8)],["baseAmountIn",M1()],["minQuoteAmountOut",M1()]]),(T)=>({...T,discriminator:FN}))}function tY(T,A){let C=A?.programAddress??q1,Q={pool:{value:T.pool??null,isWritable:!0},user:{value:T.user??null,isWritable:!0},globalConfig:{value:T.globalConfig??null,isWritable:!1},baseMint:{value:T.baseMint??null,isWritable:!1},quoteMint:{value:T.quoteMint??null,isWritable:!1},userBaseTokenAccount:{value:T.userBaseTokenAccount??null,isWritable:!0},userQuoteTokenAccount:{value:T.userQuoteTokenAccount??null,isWritable:!0},poolBaseTokenAccount:{value:T.poolBaseTokenAccount??null,isWritable:!0},poolQuoteTokenAccount:{value:T.poolQuoteTokenAccount??null,isWritable:!0},protocolFeeRecipient:{value:T.protocolFeeRecipient??null,isWritable:!1},protocolFeeRecipientTokenAccount:{value:T.protocolFeeRecipientTokenAccount??null,isWritable:!0},baseTokenProgram:{value:T.baseTokenProgram??null,isWritable:!1},quoteTokenProgram:{value:T.quoteTokenProgram??null,isWritable:!1},systemProgram:{value:T.systemProgram??null,isWritable:!1},associatedTokenProgram:{value:T.associatedTokenProgram??null,isWritable:!1},eventAuthority:{value:T.eventAuthority??null,isWritable:!1},program:{value:T.program??null,isWritable:!1},coinCreatorVaultAta:{value:T.coinCreatorVaultAta??null,isWritable:!0},coinCreatorVaultAuthority:{value:T.coinCreatorVaultAuthority??null,isWritable:!1},feeConfig:{value:T.feeConfig??null,isWritable:!1},feeProgram:{value:T.feeProgram??null,isWritable:!1}},W={...T};if(!Q.systemProgram.value)Q.systemProgram.value="11111111111111111111111111111111";if(!Q.associatedTokenProgram.value)Q.associatedTokenProgram.value="ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";if(!Q.program.value)Q.program.value="pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA";if(!Q.feeProgram.value)Q.feeProgram.value="pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ";let G=X1(C,"programId");return Object.freeze({accounts:[G(Q.pool),G(Q.user),G(Q.globalConfig),G(Q.baseMint),G(Q.quoteMint),G(Q.userBaseTokenAccount),G(Q.userQuoteTokenAccount),G(Q.poolBaseTokenAccount),G(Q.poolQuoteTokenAccount),G(Q.protocolFeeRecipient),G(Q.protocolFeeRecipientTokenAccount),G(Q.baseTokenProgram),G(Q.quoteTokenProgram),G(Q.systemProgram),G(Q.associatedTokenProgram),G(Q.eventAuthority),G(Q.program),G(Q.coinCreatorVaultAta),G(Q.coinCreatorVaultAuthority),G(Q.feeConfig),G(Q.feeProgram)],data:DN().encode(W),programAddress:C})}var Yp=new Uint8Array([210,149,128,45,188,58,78,175]);var Hp=new Uint8Array([111,172,162,232,114,89,213,142]);var Rp=new Uint8Array([86,31,192,87,163,87,79,238]);var Sp=new Uint8Array([115,103,224,255,189,89,86,195]);var Lp=new Uint8Array([1,9,111,208,100,31,255,163]);var Op=new Uint8Array([139,52,134,85,228,229,108,241]);var mp=new Uint8Array([161,176,40,213,60,184,179,228]);var bp=new Uint8Array([104,184,103,242,88,151,107,20]);var zN=new Uint8Array([183,18,70,156,148,109,161,34]);function SN(){return qT(XT([["discriminator",jT(ST(),8)],["lpTokenAmountIn",M1()],["minBaseAmountOut",M1()],["minQuoteAmountOut",M1()]]),(T)=>({...T,discriminator:zN}))}function eY(T,A){let C=A?.programAddress??q1,Q={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(!Q.tokenProgram.value)Q.tokenProgram.value="TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";if(!Q.token2022Program.value)Q.token2022Program.value="TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";let G=X1(C,"programId");return Object.freeze({accounts:[G(Q.pool),G(Q.globalConfig),G(Q.user),G(Q.baseMint),G(Q.quoteMint),G(Q.lpMint),G(Q.userBaseTokenAccount),G(Q.userQuoteTokenAccount),G(Q.userPoolTokenAccount),G(Q.poolBaseTokenAccount),G(Q.poolQuoteTokenAccount),G(Q.tokenProgram),G(Q.token2022Program),G(Q.eventAuthority),G(Q.program)],data:SN().encode(W),programAddress:C})}var Ru=new Uint8Array([241,154,109,4,17,177,109,188]);function MN(){return RT([["discriminator",xT(uT(),8)],["poolBump",DA()],["index",oJ()],["creator",z1()],["baseMint",z1()],["quoteMint",z1()],["lpMint",z1()],["poolBaseTokenAccount",z1()],["poolQuoteTokenAccount",z1()],["lpSupply",w1()],["coinCreator",z1()],["isMayhemMode",X0()],["isCashbackCoin",X0()]])}function IN(T){return kA(T,MN())}async function oC(T,A,C){let P=await NN(T,A,C);return RA(P),P}async function NN(T,A,C){let P=await jA(T,A,C);return IN(P)}var zu=new Uint8Array([149,8,156,202,160,252,176,217]);function LN(){return RT([["discriminator",xT(uT(),8)],["admin",z1()],["lpFeeBasisPoints",w1()],["protocolFeeBasisPoints",w1()],["disableFlags",DA()],["protocolFeeRecipients",Y2(z1(),{size:8})],["coinCreatorFeeBasisPoints",w1()],["adminSetCoinCreatorAuthority",z1()],["whitelistPda",z1()],["reservedFeeRecipient",z1()],["mayhemModeEnabled",X0()],["reservedFeeRecipients",Y2(z1(),{size:7})],["isCashbackEnabled",X0()]])}function wN(T){return kA(T,LN())}async function nC(T,A,C){let P=await EN(T,A,C);return RA(P),P}async function EN(T,A,C){let P=await jA(T,A,C);return wN(P)}var cW=0;async function TZ(T){let{user:A,baseMint:C,quoteMint:P,index:Q=cW,poolAddress:W,poolCreator:G,maxBaseIn:U,maxQuoteIn:$,minLpOut:X=0n,tokenProgram:q=FT,token2022Program:K=K2}=T;if(U<=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 F=_(A.address),z=_(C),M=_(P),E=_(q),L=_(K),B=W?_(W):await A2(Q,_(G??F),z,M),m=await C2(),v=await uW(B),l=await dW(F,v),[f]=await F1({owner:F,tokenProgram:E,mint:z}),[u]=await F1({owner:F,tokenProgram:E,mint:M}),a=await F0(B,z,E),d=await F0(B,M,E),h=await e2();return sY({pool:B,globalConfig:m,user:A,baseMint:z,quoteMint:M,lpMint:v,userBaseTokenAccount:f,userQuoteTokenAccount:u,userPoolTokenAccount:l,poolBaseTokenAccount:a,poolQuoteTokenAccount:d,tokenProgram:E,token2022Program:L,eventAuthority:h,program:_(KT),lpTokenAmountOut:X,maxBaseAmountIn:U,maxQuoteAmountIn:$},{programAddress:_(KT)})}async function AZ(T){let{user:A,baseMint:C,quoteMint:P,index:Q=cW,poolAddress:W,poolCreator:G,lpAmountIn:U,minBaseOut:$=0n,minQuoteOut:X=0n,tokenProgram:q=FT,token2022Program:K=K2}=T;if(U<=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 F=_(A.address),z=_(C),M=_(P),E=_(q),L=_(K),B=W?_(W):await A2(Q,_(G??F),z,M),m=await C2(),v=await uW(B),l=await dW(F,v),[f]=await F1({owner:F,tokenProgram:E,mint:z}),[u]=await F1({owner:F,tokenProgram:E,mint:M}),a=await F0(B,z,E),d=await F0(B,M,E),h=await e2();return eY({pool:B,globalConfig:m,user:A,baseMint:z,quoteMint:M,lpMint:v,userBaseTokenAccount:f,userQuoteTokenAccount:u,userPoolTokenAccount:l,poolBaseTokenAccount:a,poolQuoteTokenAccount:d,tokenProgram:E,token2022Program:L,eventAuthority:h,program:_(KT),lpTokenAmountIn:U,minBaseAmountOut:$,minQuoteAmountOut:X},{programAddress:_(KT)})}async function CZ(T){let{user:A,baseMint:C,quoteMint:P,tokenAmountOut:Q,maxQuoteIn:W,rpc:G,allowTrackVolume:U=!0,commitment:$}=T;if(Q<=0n)throw Error("tokenAmountOut must be positive");if(W<=0n)throw Error("maxQuoteIn must be positive");let X=$??I1(),q=_(A.address),K=_(C),F=_(P),z=_(FT),M=await QZ(T,q),{poolData:E,globalConfigData:L,globalConfigAddress:B,coinCreator:m}=await WZ(G,M,X),v=GZ(L.protocolFeeRecipients);if(!v)throw Error("Global config does not define a protocol fee recipient");let[l]=await F1({owner:q,tokenProgram:z,mint:K}),[f]=await F1({owner:q,tokenProgram:z,mint:F}),u=await F0(M,K,z),a=await F0(M,F,z),[d]=await F1({owner:v,tokenProgram:z,mint:F}),h=await e2(),o=m?_(m):E.creator,c=await fW(o),x=await iW(c,F,z),[j,J]=await Promise.all([iY(),cY(q)]),V=await rW();return aY({pool:M,user:A,globalConfig:B,baseMint:K,quoteMint:F,userBaseTokenAccount:l,userQuoteTokenAccount:f,poolBaseTokenAccount:u,poolQuoteTokenAccount:a,protocolFeeRecipient:v,protocolFeeRecipientTokenAccount:d,baseTokenProgram:z,quoteTokenProgram:z,systemProgram:_(oA),associatedTokenProgram:_(k2),eventAuthority:h,program:_(KT),coinCreatorVaultAta:x,coinCreatorVaultAuthority:c,globalVolumeAccumulator:j,userVolumeAccumulator:J,feeConfig:V,feeProgram:_(_0),baseAmountOut:Q,maxQuoteAmountIn:W,trackVolume:[U]},{programAddress:_(KT)})}async function PZ(T){let{user:A,baseMint:C,quoteMint:P,tokenAmountIn:Q,minQuoteOut:W,rpc:G,commitment:U}=T;if(Q<=0n)throw Error("tokenAmountIn must be positive");if(W<=0n)throw Error("minQuoteOut must be positive");let $=U??I1(),X=_(A.address),q=_(C),K=_(P),F=_(FT),z=await QZ(T,X),{poolData:M,globalConfigData:E,globalConfigAddress:L,coinCreator:B}=await WZ(G,z,$),m=GZ(E.protocolFeeRecipients);if(!m)throw Error("Global config does not define a protocol fee recipient");let[v]=await F1({owner:X,tokenProgram:F,mint:q}),[l]=await F1({owner:X,tokenProgram:F,mint:K}),f=await F0(z,q,F),u=await F0(z,K,F),[a]=await F1({owner:m,tokenProgram:F,mint:K}),d=await e2(),h=B?_(B):M.creator,o=await fW(h),c=await iW(o,K,F),x=await rW();return tY({pool:z,user:A,globalConfig:L,baseMint:q,quoteMint:K,userBaseTokenAccount:v,userQuoteTokenAccount:l,poolBaseTokenAccount:f,poolQuoteTokenAccount:u,protocolFeeRecipient:m,protocolFeeRecipientTokenAccount:a,baseTokenProgram:F,quoteTokenProgram:F,systemProgram:_(oA),associatedTokenProgram:_(k2),eventAuthority:d,program:_(KT),coinCreatorVaultAta:c,coinCreatorVaultAuthority:o,feeConfig:x,feeProgram:_(_0),baseAmountIn:Q,minQuoteAmountOut:W},{programAddress:_(KT)})}async function QZ(T,A){if(T.poolAddress)return _(T.poolAddress);let C=T.index??cW,P=_(T.poolCreator??A);return await A2(C,P,_(T.baseMint),_(T.quoteMint))}async function WZ(T,A,C){let P=await C2(),[Q,W]=await Promise.all([oC(T,A,{commitment:C}),nC(T,P,{commitment:C})]),G;try{let U=await x0(Q.data.baseMint);G=(await SA(T,U,{commitment:C})).data.creator}catch{G=void 0}return{poolData:Q.data,globalConfigData:W.data,globalConfigAddress:P,coinCreator:G}}function GZ(T){let A=T.filter(Boolean);return A.length>0?_(A[0]):null}function BN(T){let{owner:A,amount:C,payer:P=A,associatedTokenAddress:Q,createAta:W=!0,autoClose:G=!1}=T;if(C<=0n)throw Error("Amount must be positive when wrapping SOL");let U=oW(A),$=oW(P),X=Q?new n(Q):t2(new n(r0),U,!1,P0,d0),q=[],K=[];if(W)q.push(T6(pC($,X,U,new n(r0))));if(q.push(T6(kT.transfer({fromPubkey:$,toPubkey:X,lamports:Number(C)}))),q.push(T6(yY(X))),G)K.push(T6(bW(X,$,U)));return{prepend:q,append:K,associatedTokenAddress:_(X.toBase58())}}function ON(T,A){let C=oW(T),P=A?new n(A):t2(new n(r0),C,!1,P0,d0);return[T6(bW(P,C,C))]}function oW(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 T6(T){return{programAddress:_(T.programId.toBase58()),accounts:T.keys.map((A)=>({address:_(A.pubkey.toBase58()),role:A.isSigner?A.isWritable?R1.WRITABLE_SIGNER:R1.READONLY_SIGNER:A.isWritable?R1.WRITABLE:R1.READONLY})),data:T.data}}var r0="So11111111111111111111111111111111111111112";var aC=_(FT),sC=10000n,_N=10000n,$Z=(T,A)=>{if(!Number.isFinite(T)||T<=0)throw Error(`${A} must be a positive number`)},VZ=(T)=>_(T??r0);async function YZ(T){$Z(T.solAmount,"solAmount");let A=T.slippageBps??Q0;W0(A);let C=T.commitment??I1(),P=VZ(T.quoteMint),Q=_(T.mint),W=m0(T.solAmount),G=await qZ({rpc:T.rpc,mint:Q,quoteMint:P,commitment:C,poolAddress:T.poolAddress,poolCreator:T.poolCreator,poolIndex:T.poolIndex}),U=HZ(G.globalConfigData),$=KZ(W,U);if($<=0n)throw Error("Effective quote input after fees is zero");let X=yN($,G.baseReserve,G.quoteReserve);if(X<=0n)throw Error("SOL amount is too small to purchase any tokens from the AMM");if(X>=G.baseReserve)X=G.baseReserve-1n;if(X<=0n)throw Error("AMM pool does not have enough base liquidity for this trade");let q=UZ(X,G.quoteReserve,G.baseReserve,U);while(q>W&&X>0n)X-=1n,q=UZ(X,G.quoteReserve,G.baseReserve,U);if(X<=0n||q<=0n)throw Error("Unable to satisfy AMM buy with the provided SOL budget");let K=a0(q,A),{createInstruction:F}=await lN({rpc:T.rpc,owner:T.user,mint:Q}),z=await CZ({user:T.user,baseMint:Q,quoteMint:P,tokenAmountOut:X,maxQuoteIn:K,poolAddress:G.poolAddress,poolCreator:G.poolCreator,index:Number(G.poolData.index),allowTrackVolume:T.allowTrackVolume,rpc:T.rpc,commitment:C});if(F){let M=Object.assign({},z);return M.prepend=[F,...M.prepend??[]],M}return z}async function ZZ(T){let A=T.slippageBps??Q0;W0(A);let C=T.commitment??I1(),P=VZ(T.quoteMint),Q=_(T.mint),W=await qZ({rpc:T.rpc,mint:Q,quoteMint:P,commitment:C,poolAddress:T.poolAddress,poolCreator:T.poolCreator,poolIndex:T.poolIndex}),G=await pN({params:T,rpc:T.rpc,mint:Q});if(G<=0n)throw Error("Token amount must be positive");if(G>=W.baseReserve)throw Error("Token amount exceeds available AMM base liquidity");let U=HZ(W.globalConfigData),$=KZ(G,U);if($<=0n)throw Error("Effective base input after fees is zero");let X=bN($,W.baseReserve,W.quoteReserve);if(X<=0n)throw Error("AMM pool produced zero quote output");let q=aA(X,A);if(q<=0n)throw Error("Slippage settings would result in zero SOL output");return PZ({user:T.user,baseMint:Q,quoteMint:P,tokenAmountIn:G,minQuoteOut:q,poolAddress:W.poolAddress,poolCreator:W.poolCreator,index:Number(W.poolData.index),allowTrackVolume:T.allowTrackVolume,rpc:T.rpc,commitment:C})}var xN=8;async function qZ(T){let{poolAccount:A,globalConfigAccount:C,poolAddress:P,poolCreator:Q,coinCreator:W}=await mN(T),[G,U]=await Promise.all([F0(P,T.mint,aC),F0(P,T.quoteMint,aC)]),$=await vN(T.rpc,G,U);return{poolAddress:P,poolCreator:Q,coinCreator:W,poolData:A.data,globalConfigData:C.data,baseReserve:$.baseReserve,quoteReserve:$.quoteReserve}}var XZ=43,hN=XZ+32,JZ=(T)=>_(T);async function mN(T){let{rpc:A,mint:C,quoteMint:P,commitment:Q,poolAddress:W,poolCreator:G,poolIndex:U}=T,$=W?_(W):void 0,X=G?_(G):void 0,q;try{let E=await x0(C);q=(await SA(A,E,{commitment:Q})).data.creator}catch{q=void 0}let K=await C2(),F=async(E)=>{try{return await oC(A,E,{commitment:Q})}catch(L){if(gN(L))return null;throw L}},z=null;if($)z=await F($);if(!z&&X){let E=U!==void 0?[U]:Array.from({length:xN},(L,B)=>B);for(let L of E){let B=await A2(L,X,C,P),m=await F(B);if(m){$=B,z=m;break}}}if(!z){let E=[{memcmp:{offset:BigInt(XZ),bytes:JZ(C),encoding:"base58"}},{memcmp:{offset:BigInt(hN),bytes:JZ(P),encoding:"base58"}}],B=await A.getProgramAccounts(_(KT),{commitment:Q,encoding:"base64",filters:E}).send()??[];for(let m of B){let v=_(m.pubkey),l=await F(v);if(!l)continue;$=v,X=l.data.creator,z=l;break}}if(!z||!$)throw Error(`Unable to locate AMM pool for mint ${C}. Provide poolAddress or poolIndex explicitly.`);let M=await nC(A,K,{commitment:Q});if(!X)X=z.data.creator;if(!q)q=z.data.creator;return{poolAccount:z,globalConfigAccount:M,poolAddress:$,poolCreator:X,coinCreator:q}}function gN(T){if(!(T instanceof Error))return!1;if(T.message.toLowerCase().includes("account not found"))return!0;return T?.context?.__code===4100}async function vN(T,A,C){let[P,Q]=await Promise.all([T.getTokenAccountBalance(A).send(),T.getTokenAccountBalance(C).send()]);return{baseReserve:BigInt(P.value.amount),quoteReserve:BigInt(Q.value.amount)}}function HZ(T){return BigInt(T.lpFeeBasisPoints??0n)+BigInt(T.protocolFeeBasisPoints??0n)}function KZ(T,A){let C=sC-A;if(C<=0n)return 0n;return T*C/sC}function yN(T,A,C){let P=C+T;if(P<=0n)throw Error("Invalid AMM reserves (denominator is zero)");return T*A/P}function UZ(T,A,C,P){if(T<=0n)return 0n;if(T>=C)throw Error("Requested token amount exceeds pool reserves");let Q=T*A/(C-T);if(Q<=0n)return 0n;let W=sC-P;if(W<=0n)throw Error("Invalid AMM fee configuration");return(Q*sC+(W-1n))/W}function bN(T,A,C){let P=A+T;if(P<=0n)throw Error("Invalid AMM reserves (denominator is zero)");return T*C/P}async function lN({rpc:T,owner:A,mint:C}){let[P]=await F1({owner:_(A.address),mint:C,tokenProgram:aC}),Q;try{if(!(await T.getAccountInfo(P,{encoding:"base64"}).send()).value)Q=e8({payer:A,owner:A,mint:C})}catch{Q=e8({payer:A,owner:A,mint:C})}return{userAta:P,createInstruction:Q}}async function pN({params:T,rpc:A,mint:C}){let P=T.useWalletPercentage??!1,Q=T.tokenDecimals??6;if(P){let W=T.walletPercentage??100,G=dN(W),U=await uN(A,T.user,C);if(U===0n)throw Error("Wallet token balance is zero; nothing to sell");let $=U*G/_N;if($<=0n)$=1n;return $}if(T.tokenAmount===void 0)throw Error("tokenAmount is required when useWalletPercentage is false");return $Z(T.tokenAmount,"tokenAmount"),sA(T.tokenAmount,Q)}async function uN(T,A,C){let[P]=await F1({owner:_(A.address),mint:C,tokenProgram:aC}),Q=await T.getTokenAccountBalance(P).send();return BigInt(Q.value.amount)}function dN(T){if(!Number.isFinite(T)||T<=0||T>100)throw Error("walletPercentage must be between 0 and 100");return BigInt(Math.round(T*100))}var rN=fC,fN=iC;async function nW(T){let{user:A,mint:C,mintAuthority:P,name:Q,symbol:W,uri:G,firstBuyTokenAmount:U,estimatedFirstBuyCost:$,slippageBps:X=Q0,feeRecipient:q=h0,bondingCurveCreator:K,trackVolume:F,rpc:z,commitment:M=I1()}=T;if(W0(X),!Q||Q.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(U<=0n)throw Error("First buy token amount must be positive");if($<=0n)throw Error("Estimated first buy cost must be positive");let E=await Z$({user:A,mint:C,mintAuthority:P,name:Q,symbol:W,uri:G}),L=a0($,X),B=await R2({user:A,mint:C.address,tokenAmount:U,maxSolCostLamports:L,feeRecipient:q,trackVolume:F??!0,bondingCurveCreator:K??A.address,rpc:z,commitment:M});return{createInstruction:E,buyInstruction:B}}function iN(T){let{name:A,symbol:C,uri:P}=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(!C||C.length===0)throw Error("Token symbol is required");if(C.length>10)throw Error("Token symbol too long (max 10 characters)");if(!P||P.length===0)throw Error("Metadata URI is required");if(!P.startsWith("http://")&&!P.startsWith("https://")&&!P.startsWith("ipfs://"))throw Error("Metadata URI must be a valid URL or IPFS link")}var kZ=_("ComputeBudget111111111111111111111111111111");async function aW({instructions:T,payer:A,additionalSigners:C=[],latestBlockhash:P,lastValidBlockHeight:Q,version:W="legacy",rpc:G,commitment:U=I1(),prependInstructions:$=[],appendInstructions:X=[],priorityFees:q}){let K=typeof A==="string"?_(A):A.address,F=zU({version:W}),z=jZ(q),M=[],E=[];for(let d of T)if("prepend"in d&&Array.isArray(d.prepend)){M.push(...d.prepend);let{prepend:h,...o}=d;E.push(o)}else E.push(d);let L=[...z,...M,...$??[],...E,...X??[]],B=new Map;for(let d of L)if(F=IU(d,F),d.accounts){for(let h of d.accounts)if("signer"in h&&h.signer&&typeof h.signer==="object"&&"address"in h.signer){let o=h.signer;B.set(o.address,o)}}let m=MU(K,F),v=[];if(oN(A))m=nU(A,m),v.push(A);for(let d of B.values())if(!v.some((h)=>h.address===d.address))v.push(d);if(C.length>0){for(let d of C)if(O0(d)&&!v.some((h)=>h.address===d.address))v.push(d)}let l=v.length>0?oU(v,m):m,f=P,u=Q!==void 0?BigInt(Q):void 0;if(!f||u===void 0){let{value:d}=await G.getLatestBlockhash({commitment:U}).send();if(f=f??d.blockhash,u===void 0)u=BigInt(d.lastValidBlockHeight)}return{transactionMessage:jU({blockhash:f,lastValidBlockHeight:u},l),latestBlockhash:f,lastValidBlockHeight:u}}async function sW({instructions:T,payer:A,additionalSigners:C=[],latestBlockhash:P,lastValidBlockHeight:Q,version:W,prependInstructions:G,appendInstructions:U,priorityFees:$,rpc:X,rpcSubscriptions:q,commitment:K=I1(),sendOptions:F={}}){let z=await aW({instructions:T,payer:A,additionalSigners:C,latestBlockhash:P,lastValidBlockHeight:Q,version:W,prependInstructions:G,appendInstructions:U,priorityFees:$,rpc:X,commitment:K}),M=await BP(z.transactionMessage),E=X2(M),L=T$({rpc:X,rpcSubscriptions:q}),B={commitment:K};if(F.abortSignal)B.abortSignal=F.abortSignal;if(F.skipPreflight!==void 0)B.skipPreflight=F.skipPreflight;if(F.minContextSlot!==void 0)B.minContextSlot=BigInt(F.minContextSlot);if(F.maxRetries!==void 0)B.maxRetries=F.maxRetries;if(F.preflightCommitment)B.preflightCommitment=F.preflightCommitment;await L(M,B);let v=(await X.getSignatureStatuses([E],{searchTransactionHistory:!1}).send()).value?.[0]??null;if(v?.err)try{let f=await X.getTransaction(E,{commitment:K,encoding:"json",maxSupportedTransactionVersion:0}).send(),u="Transaction failed";if(v.err)u=`Transaction failed: ${typeof v.err==="object"?JSON.stringify(v.err,(d,h)=>typeof h==="bigint"?h.toString():h):String(v.err)}`;if(f?.meta?.err)u=`Transaction failed: ${typeof f.meta.err==="object"?JSON.stringify(f.meta.err,(d,h)=>typeof h==="bigint"?h.toString():h):String(f.meta.err)}`;if(f?.meta?.logMessages){let a=f.meta.logMessages.filter((d)=>d.toLowerCase().includes("error")||d.includes("Program log:"));if(a.length>0)u+=`
21
21
  Program logs:
22
- ${i.slice(0,10).join(`
23
- `)}`}throw Error(u)}catch{let p=v.err&&typeof v.err==="object"?JSON.stringify(v.err,(c,u)=>typeof u==="bigint"?u.toString():u):String(v.err);throw Error(`Transaction failed: ${p}`)}return{signature:E,slot:v?.slot??null}}async function cS({instructions:T,payer:A,additionalSigners:Q=[],latestBlockhash:J,lastValidBlockHeight:$,version:W,prependInstructions:G,appendInstructions:Y,priorityFees:Z,rpc:C,commitment:K=M1(),options:j={}}){let M=await nW({instructions:T,payer:A,additionalSigners:Q,latestBlockhash:J,lastValidBlockHeight:$,version:W,prependInstructions:G,appendInstructions:Y,priorityFees:Z,rpc:C,commitment:K}),z=await SJ(M.transactionMessage),N=B6(z),E={commitment:j.commitment??K};if(j.minContextSlot!==void 0)E.minContextSlot=BigInt(j.minContextSlot);if(j.sigVerify!==void 0)E.sigVerify=j.sigVerify;if(j.replaceRecentBlockhash!==void 0){if(j.sigVerify)throw Error("replaceRecentBlockhash cannot be true when sigVerify is enabled.");E.replaceRecentBlockhash=j.replaceRecentBlockhash}if(j.accounts)E.accounts=j.accounts;let L=await C.simulateTransaction(N,E).send();return{context:{slot:Number(L.context.slot)},value:{err:L.value.err,logs:L.value.logs,unitsConsumed:L.value.unitsConsumed!==void 0?Number(L.value.unitsConsumed):void 0,accounts:L.value.accounts,returnData:L.value.returnData??void 0}}}function fS(T){return typeof T!=="string"&&ET(T)}function Cq(T){if(!T)return[];let A=[];if(T.computeUnitLimit!==void 0&&T.computeUnitLimit>0)A.push(rS(T.computeUnitLimit));if(T.computeUnitPriceMicroLamports!==void 0&&BigInt(T.computeUnitPriceMicroLamports)>0n)A.push(nS(BigInt(T.computeUnitPriceMicroLamports)));return A}function rS(T){let A=new Uint8Array(5);return A[0]=0,new DataView(A.buffer).setUint32(1,T,!0),{programAddress:Kq,accounts:[],data:A}}function nS(T){let A=new Uint8Array(9);return A[0]=3,new DataView(A.buffer).setBigUint64(1,T,!0),{programAddress:Kq,accounts:[],data:A}}async function iS(T){let{creator:A,metadata:Q,firstBuyTokenAmount:J,estimatedFirstBuyCost:$,slippageBps:W,feeRecipient:G,bondingCurveCreator:Y,mintAuthority:Z,mint:C,priorityFees:K,prependInstructions:j,appendInstructions:M,additionalSigners:z,sendOptions:N,commitment:E=M1(),rpc:L,rpcSubscriptions:O}=T,g=C??await iY(),v={user:A,mint:g,mintAuthority:Z??A.address,name:Q.name,symbol:Q.symbol,uri:Q.uri,firstBuyTokenAmount:J,estimatedFirstBuyCost:$,slippageBps:W,feeRecipient:G,bondingCurveCreator:Y??A.address,rpc:L,commitment:E},{createInstruction:p,buyInstruction:c}=await rW(v);return{...await iW({instructions:[p,c],payer:A,commitment:E,priorityFees:K,prependInstructions:j,appendInstructions:M,additionalSigners:oS([g,...z??[]]),sendOptions:N,rpc:L,rpcSubscriptions:O}),mint:g,createInstruction:p,buyInstruction:c}}function oS(T){let A=new Set,Q=[];for(let J of T){let $=J.address;if(!A.has($))A.add($),Q.push(J)}return Q}var aS=uT;async function Hq(T){let{user:A,baseMint:Q,quoteMint:J=uT,poolIndex:$,poolAddress:W,poolCreator:G,maxBaseAmountIn:Y,maxQuoteAmountIn:Z,minLpTokensOut:C,tokenProgram:K,token2022Program:j}=T;if(Y<=0n)throw Error("maxBaseAmountIn must be positive");if(Z<=0n)throw Error("maxQuoteAmountIn must be positive");return await aP({user:A,baseMint:Q,quoteMint:J,index:$,poolAddress:W,poolCreator:G,maxBaseIn:Y,maxQuoteIn:Z,minLpOut:C??0n,tokenProgram:K,token2022Program:j})}async function Vq(T){let{user:A,baseMint:Q,quoteMint:J=uT,poolIndex:$,poolAddress:W,poolCreator:G,lpAmountIn:Y,minBaseAmountOut:Z,minQuoteAmountOut:C,tokenProgram:K,token2022Program:j}=T;if(Y<=0n)throw Error("lpAmountIn must be positive");return await sP({user:A,baseMint:Q,quoteMint:J,index:$,poolAddress:W,poolCreator:G,lpAmountIn:Y,minBaseOut:Z??0n,minQuoteOut:C??0n,tokenProgram:K,token2022Program:j})}async function sS(T,A,Q,J,$={}){return Hq({user:T,baseMint:A,maxBaseAmountIn:Q,maxQuoteAmountIn:J,...$})}async function tS(T,A,Q,J={}){return Vq({user:T,baseMint:A,lpAmountIn:Q,...J})}class oW{connection;programId;commitment;listeners=new Map;nextListenerId=1;subscriptionId=null;constructor(T,A={}){this.connection=T,this.programId=new a(A.programId??a0),this.commitment=A.commitment??"confirmed"}addEventListener(T,A){let Q=this.nextListenerId++;return this.listeners.set(Q,{id:Q,type:T,callback:A}),this.ensureSubscription(),Q}removeEventListener(T){if(this.listeners.delete(T),this.listeners.size===0)this.teardownSubscription()}ensureSubscription(){if(this.subscriptionId!==null)return;let T=(A,Q)=>{this.dispatch(A,Q.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 Q=T.signature??"";for(let J of T.logs){let $=T3(J,A,Q);for(let W of this.listeners.values())if(W.type==="raw"||W.type===$.type)W.callback($)}}}var eS={create:["createEvent","create_event"],trade:["tradeEvent","trade_event"],complete:["completeEvent","complete_event"],raw:[]};function T3(T,A,Q){let J="raw";for(let[G,Y]of Object.entries(eS)){if(G==="raw")continue;if(Y.some((Z)=>T.includes(Z))){J=G;break}}let $,W=T.indexOf("{");if(W!==-1){let G=T.slice(W);try{$=JSON.parse(G)}catch{$=void 0}}return{type:J,slot:A,signature:Q,rawLog:T,parsed:$}}function A3(T,A={}){return new oW(T,A)}export{WT as validateSlippage,dS as validateMintParams,n8 as subSlippage,cS as simulateTransaction,I5 as setDefaultCommitment,iW as sendAndConfirmTransaction,u5 as sellWithSlippage,gJ as sellSimple,uS as sell,Vq as removeLiquidity,tS as quickRemoveLiquidity,sS as quickAddLiquidity,y5 as percentToBps,rW as mintWithFirstBuy,M1 as getDefaultCommitment,lQ as curveSell,pQ as curveBuy,A3 as createPumpEventManager,iS as createAndBuy,l5 as buyWithSlippage,hJ as buySimple,lS as buy,LS as buildWrapSolInstructions,wS as buildUnwrapSolInstructions,nW as buildTransaction,Cq as buildPriorityFeeInstructions,b5 as bpsToPercent,Yq as ammSell,Uq as ammBuy,iT as addSlippage,Hq as addLiquidity,uT as WSOL_ADDRESS,aS as WSOL,oW as PumpEventManager,$T as DEFAULT_SLIPPAGE_BPS};
22
+ ${a.slice(0,10).join(`
23
+ `)}`}throw Error(u)}catch{let l=v.err&&typeof v.err==="object"?JSON.stringify(v.err,(f,u)=>typeof u==="bigint"?u.toString():u):String(v.err);throw Error(`Transaction failed: ${l}`)}return{signature:E,slot:v?.slot??null}}async function cN({instructions:T,payer:A,additionalSigners:C=[],latestBlockhash:P,lastValidBlockHeight:Q,version:W,prependInstructions:G,appendInstructions:U,priorityFees:$,rpc:X,commitment:q=I1(),options:K={}}){let F=await aW({instructions:T,payer:A,additionalSigners:C,latestBlockhash:P,lastValidBlockHeight:Q,version:W,prependInstructions:G,appendInstructions:U,priorityFees:$,rpc:X,commitment:q}),z=await BP(F.transactionMessage),M=m6(z),E={commitment:K.commitment??q};if(K.minContextSlot!==void 0)E.minContextSlot=BigInt(K.minContextSlot);if(K.sigVerify!==void 0)E.sigVerify=K.sigVerify;if(K.replaceRecentBlockhash!==void 0){if(K.sigVerify)throw Error("replaceRecentBlockhash cannot be true when sigVerify is enabled.");E.replaceRecentBlockhash=K.replaceRecentBlockhash}if(K.accounts)E.accounts=K.accounts;let L=await X.simulateTransaction(M,E).send();return{context:{slot:Number(L.context.slot)},value:{err:L.value.err,logs:L.value.logs,unitsConsumed:L.value.unitsConsumed!==void 0?Number(L.value.unitsConsumed):void 0,accounts:L.value.accounts,returnData:L.value.returnData??void 0}}}function oN(T){return typeof T!=="string"&&O0(T)}function jZ(T){if(!T)return[];let A=[];if(T.computeUnitLimit!==void 0&&T.computeUnitLimit>0)A.push(nN(T.computeUnitLimit));if(T.computeUnitPriceMicroLamports!==void 0&&BigInt(T.computeUnitPriceMicroLamports)>0n)A.push(aN(BigInt(T.computeUnitPriceMicroLamports)));return A}function nN(T){let A=new Uint8Array(5);return A[0]=0,new DataView(A.buffer).setUint32(1,T,!0),{programAddress:kZ,accounts:[],data:A}}function aN(T){let A=new Uint8Array(9);return A[0]=3,new DataView(A.buffer).setBigUint64(1,T,!0),{programAddress:kZ,accounts:[],data:A}}async function sN(T){let{creator:A,metadata:C,firstBuyTokenAmount:P,estimatedFirstBuyCost:Q,slippageBps:W,feeRecipient:G,bondingCurveCreator:U,mintAuthority:$,mint:X,priorityFees:q,prependInstructions:K,appendInstructions:F,additionalSigners:z,sendOptions:M,commitment:E=I1(),rpc:L,rpcSubscriptions:B}=T,m=X??await aU(),v={user:A,mint:m,mintAuthority:$??A.address,name:C.name,symbol:C.symbol,uri:C.uri,firstBuyTokenAmount:P,estimatedFirstBuyCost:Q,slippageBps:W,feeRecipient:G,bondingCurveCreator:U??A.address,rpc:L,commitment:E},{createInstruction:l,buyInstruction:f}=await nW(v);return{...await sW({instructions:[l,f],payer:A,commitment:E,priorityFees:q,prependInstructions:K,appendInstructions:F,additionalSigners:tN([m,...z??[]]),sendOptions:M,rpc:L,rpcSubscriptions:B}),mint:m,createInstruction:l,buyInstruction:f}}function tN(T){let A=new Set,C=[];for(let P of T){let Q=P.address;if(!A.has(Q))A.add(Q),C.push(P)}return C}var eN=r0;async function RZ(T){let{user:A,baseMint:C,quoteMint:P=r0,poolIndex:Q,poolAddress:W,poolCreator:G,maxBaseAmountIn:U,maxQuoteAmountIn:$,minLpTokensOut:X,tokenProgram:q,token2022Program:K}=T;if(U<=0n)throw Error("maxBaseAmountIn must be positive");if($<=0n)throw Error("maxQuoteAmountIn must be positive");return await TZ({user:A,baseMint:C,quoteMint:P,index:Q,poolAddress:W,poolCreator:G,maxBaseIn:U,maxQuoteIn:$,minLpOut:X??0n,tokenProgram:q,token2022Program:K})}async function FZ(T){let{user:A,baseMint:C,quoteMint:P=r0,poolIndex:Q,poolAddress:W,poolCreator:G,lpAmountIn:U,minBaseAmountOut:$,minQuoteAmountOut:X,tokenProgram:q,token2022Program:K}=T;if(U<=0n)throw Error("lpAmountIn must be positive");return await AZ({user:A,baseMint:C,quoteMint:P,index:Q,poolAddress:W,poolCreator:G,lpAmountIn:U,minBaseOut:$??0n,minQuoteOut:X??0n,tokenProgram:q,token2022Program:K})}async function T3(T,A,C,P,Q={}){return RZ({user:T,baseMint:A,maxBaseAmountIn:C,maxQuoteAmountIn:P,...Q})}async function A3(T,A,C,P={}){return FZ({user:T,baseMint:A,lpAmountIn:C,...P})}class tW{connection;programId;commitment;listeners=new Map;nextListenerId=1;subscriptionId=null;constructor(T,A={}){this.connection=T,this.programId=new n(A.programId??tT),this.commitment=A.commitment??"confirmed"}addEventListener(T,A){let C=this.nextListenerId++;return this.listeners.set(C,{id:C,type:T,callback:A}),this.ensureSubscription(),C}removeEventListener(T){if(this.listeners.delete(T),this.listeners.size===0)this.teardownSubscription()}ensureSubscription(){if(this.subscriptionId!==null)return;let T=(A,C)=>{this.dispatch(A,C.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 C=T.signature??"";for(let P of T.logs){let Q=P3(P,A,C);for(let W of this.listeners.values())if(W.type==="raw"||W.type===Q.type)W.callback(Q)}}}var C3={create:["createEvent","create_event"],trade:["tradeEvent","trade_event"],complete:["completeEvent","complete_event"],raw:[]};function P3(T,A,C){let P="raw";for(let[G,U]of Object.entries(C3)){if(G==="raw")continue;if(U.some(($)=>T.includes($))){P=G;break}}let Q,W=T.indexOf("{");if(W!==-1){let G=T.slice(W);try{Q=JSON.parse(G)}catch{Q=void 0}}return{type:P,slot:A,signature:C,rawLog:T,parsed:Q}}function Q3(T,A={}){return new tW(T,A)}export{W0 as validateSlippage,iN as validateMintParams,aA as subSlippage,cN as simulateTransaction,Ej as setDefaultCommitment,sW as sendAndConfirmTransaction,ij as sellWithSlippage,yP as sellSimple,fN as sell,FZ as removeLiquidity,A3 as quickRemoveLiquidity,T3 as quickAddLiquidity,uj as percentToBps,nW as mintWithFirstBuy,I1 as getDefaultCommitment,iC as curveSell,fC as curveBuy,Q3 as createPumpEventManager,sN as createAndBuy,fj as buyWithSlippage,vP as buySimple,rN as buy,BN as buildWrapSolInstructions,ON as buildUnwrapSolInstructions,aW as buildTransaction,jZ as buildPriorityFeeInstructions,dj as bpsToPercent,ZZ as ammSell,YZ as ammBuy,a0 as addSlippage,RZ as addLiquidity,r0 as WSOL_ADDRESS,eN as WSOL,tW as PumpEventManager,Q0 as DEFAULT_SLIPPAGE_BPS};