@sentio/sdk 2.57.12-rc.1 → 2.57.12-rc.aaa
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/aptos/ext/token.d.ts.map +1 -1
- package/lib/aptos/ext/token.js +4 -6
- package/lib/aptos/ext/token.js.map +1 -1
- package/lib/chunk-24EEMT46.js +3 -0
- package/lib/chunk-24EEMT46.js.map +1 -0
- package/lib/chunk-2R7O6UGY.js +3 -0
- package/lib/chunk-2R7O6UGY.js.map +1 -0
- package/lib/chunk-4JXRK4YH.js +29 -0
- package/lib/chunk-4JXRK4YH.js.map +1 -0
- package/lib/chunk-7QZC3R57.js +3 -0
- package/lib/chunk-7QZC3R57.js.map +1 -0
- package/lib/chunk-AK5E6DKD.js +6 -0
- package/lib/chunk-AK5E6DKD.js.map +1 -0
- package/lib/chunk-ATZBHPQN.js +3 -0
- package/lib/chunk-ATZBHPQN.js.map +1 -0
- package/lib/chunk-B6U7F4GY.js +29 -0
- package/lib/chunk-B6U7F4GY.js.map +1 -0
- package/lib/chunk-DGKULIPW.js +3 -0
- package/lib/chunk-DGKULIPW.js.map +1 -0
- package/lib/chunk-DS2LOABN.js +3 -0
- package/lib/chunk-DS2LOABN.js.map +1 -0
- package/lib/chunk-FMBGZMT4.js +6 -0
- package/lib/chunk-FMBGZMT4.js.map +1 -0
- package/lib/chunk-FMZDKD72.js +8 -0
- package/lib/chunk-FMZDKD72.js.map +1 -0
- package/lib/chunk-G5BIPHMS.js +3 -0
- package/lib/chunk-G5BIPHMS.js.map +1 -0
- package/lib/chunk-G6XPDWDE.js +3 -0
- package/lib/chunk-G6XPDWDE.js.map +1 -0
- package/lib/chunk-GJX3DL4J.js +499 -0
- package/lib/chunk-GJX3DL4J.js.map +1 -0
- package/lib/chunk-GTITFWMU.js +259 -0
- package/lib/chunk-GTITFWMU.js.map +1 -0
- package/lib/chunk-J7Z2TKQE.js +33 -0
- package/lib/chunk-J7Z2TKQE.js.map +1 -0
- package/lib/chunk-JQ4LTUIX.js +995 -0
- package/lib/chunk-JQ4LTUIX.js.map +1 -0
- package/lib/chunk-LG2TF5WR.js +8 -0
- package/lib/chunk-LG2TF5WR.js.map +1 -0
- package/lib/chunk-LVWOFGF2.js +3 -0
- package/lib/chunk-LVWOFGF2.js.map +1 -0
- package/lib/chunk-O564J2U6.js +11 -0
- package/lib/chunk-O564J2U6.js.map +1 -0
- package/lib/chunk-QGIFUSFI.js +84 -0
- package/lib/chunk-QGIFUSFI.js.map +1 -0
- package/lib/chunk-QGPJOTWP.js +3 -0
- package/lib/chunk-QGPJOTWP.js.map +1 -0
- package/lib/chunk-RA75ESSD.js +3 -0
- package/lib/chunk-RA75ESSD.js.map +1 -0
- package/lib/chunk-RVAYZJ7X.js +5 -0
- package/lib/chunk-RVAYZJ7X.js.map +1 -0
- package/lib/chunk-SPY3PKUB.js +3 -0
- package/lib/chunk-SPY3PKUB.js.map +1 -0
- package/lib/chunk-SUCYR7EB.js +3 -0
- package/lib/chunk-SUCYR7EB.js.map +1 -0
- package/lib/chunk-TGIXVAHB.js +7 -0
- package/lib/chunk-TGIXVAHB.js.map +1 -0
- package/lib/chunk-TSEQGMTN.js +5 -0
- package/lib/chunk-TSEQGMTN.js.map +1 -0
- package/lib/chunk-ZHI6ULD5.js +3 -0
- package/lib/chunk-ZHI6ULD5.js.map +1 -0
- package/lib/multipart-parser-J6QPYJHT.js +4 -0
- package/lib/multipart-parser-J6QPYJHT.js.map +1 -0
- package/package.json +4 -4
- package/src/aptos/builtin/0x1.d.ts +6451 -0
- package/src/aptos/builtin/0x1.d.ts.map +1 -0
- package/src/aptos/builtin/0x1.js +7138 -0
- package/src/aptos/builtin/0x1.js.map +1 -0
- package/src/aptos/builtin/0x3.d.ts +1122 -0
- package/src/aptos/builtin/0x3.d.ts.map +1 -0
- package/src/aptos/builtin/0x3.js +937 -0
- package/src/aptos/builtin/0x3.js.map +1 -0
- package/src/aptos/builtin/0x4.d.ts +551 -0
- package/src/aptos/builtin/0x4.d.ts.map +1 -0
- package/src/aptos/builtin/0x4.js +529 -0
- package/src/aptos/builtin/0x4.js.map +1 -0
- package/src/aptos/builtin/index.d.ts +4 -0
- package/src/aptos/builtin/index.d.ts.map +1 -0
- package/src/aptos/builtin/index.js +7 -0
- package/src/aptos/builtin/index.js.map +1 -0
- package/src/aptos/ext/token.ts +4 -6
- package/src/eth/builtin/eacaggregatorproxy.d.ts +5 -0
- package/src/eth/builtin/eacaggregatorproxy.d.ts.map +1 -0
- package/src/eth/builtin/eacaggregatorproxy.js +8 -0
- package/src/eth/builtin/eacaggregatorproxy.js.map +1 -0
- package/src/eth/builtin/erc1155.d.ts +5 -0
- package/src/eth/builtin/erc1155.d.ts.map +1 -0
- package/src/eth/builtin/erc1155.js +8 -0
- package/src/eth/builtin/erc1155.js.map +1 -0
- package/src/eth/builtin/erc20.d.ts +5 -0
- package/src/eth/builtin/erc20.d.ts.map +1 -0
- package/src/eth/builtin/erc20.js +8 -0
- package/src/eth/builtin/erc20.js.map +1 -0
- package/src/eth/builtin/erc20bytes.d.ts +5 -0
- package/src/eth/builtin/erc20bytes.d.ts.map +1 -0
- package/src/eth/builtin/erc20bytes.js +8 -0
- package/src/eth/builtin/erc20bytes.js.map +1 -0
- package/src/eth/builtin/erc721.d.ts +5 -0
- package/src/eth/builtin/erc721.d.ts.map +1 -0
- package/src/eth/builtin/erc721.js +8 -0
- package/src/eth/builtin/erc721.js.map +1 -0
- package/src/eth/builtin/index.d.ts +13 -0
- package/src/eth/builtin/index.d.ts.map +1 -0
- package/src/eth/builtin/index.js +16 -0
- package/src/eth/builtin/index.js.map +1 -0
- package/src/eth/builtin/internal/EACAggregatorProxy.d.ts +50 -0
- package/src/eth/builtin/internal/EACAggregatorProxy.d.ts.map +1 -0
- package/src/eth/builtin/internal/EACAggregatorProxy.js +2 -0
- package/src/eth/builtin/internal/EACAggregatorProxy.js.map +1 -0
- package/src/eth/builtin/internal/ERC1155.d.ts +57 -0
- package/src/eth/builtin/internal/ERC1155.d.ts.map +1 -0
- package/src/eth/builtin/internal/ERC1155.js +2 -0
- package/src/eth/builtin/internal/ERC1155.js.map +1 -0
- package/src/eth/builtin/internal/ERC20.d.ts +41 -0
- package/src/eth/builtin/internal/ERC20.d.ts.map +1 -0
- package/src/eth/builtin/internal/ERC20.js +2 -0
- package/src/eth/builtin/internal/ERC20.js.map +1 -0
- package/src/eth/builtin/internal/ERC20Bytes.d.ts +32 -0
- package/src/eth/builtin/internal/ERC20Bytes.d.ts.map +1 -0
- package/src/eth/builtin/internal/ERC20Bytes.js +2 -0
- package/src/eth/builtin/internal/ERC20Bytes.js.map +1 -0
- package/src/eth/builtin/internal/ERC721.d.ts +43 -0
- package/src/eth/builtin/internal/ERC721.d.ts.map +1 -0
- package/src/eth/builtin/internal/ERC721.js +2 -0
- package/src/eth/builtin/internal/ERC721.js.map +1 -0
- package/src/eth/builtin/internal/WETH9.d.ts +47 -0
- package/src/eth/builtin/internal/WETH9.d.ts.map +1 -0
- package/src/eth/builtin/internal/WETH9.js +2 -0
- package/src/eth/builtin/internal/WETH9.js.map +1 -0
- package/src/eth/builtin/internal/common.d.ts +3 -0
- package/src/eth/builtin/internal/common.d.ts.map +1 -0
- package/src/eth/builtin/internal/common.js +8 -0
- package/src/eth/builtin/internal/common.js.map +1 -0
- package/src/eth/builtin/internal/eacaggregatorproxy-processor.d.ts +373 -0
- package/src/eth/builtin/internal/eacaggregatorproxy-processor.d.ts.map +1 -0
- package/src/eth/builtin/internal/eacaggregatorproxy-processor.js +1355 -0
- package/src/eth/builtin/internal/eacaggregatorproxy-processor.js.map +1 -0
- package/src/eth/builtin/internal/eacaggregatorproxy-test-utils.d.ts +7 -0
- package/src/eth/builtin/internal/eacaggregatorproxy-test-utils.d.ts.map +1 -0
- package/src/eth/builtin/internal/eacaggregatorproxy-test-utils.js +55 -0
- package/src/eth/builtin/internal/eacaggregatorproxy-test-utils.js.map +1 -0
- package/src/eth/builtin/internal/erc1155-processor.d.ts +173 -0
- package/src/eth/builtin/internal/erc1155-processor.d.ts.map +1 -0
- package/src/eth/builtin/internal/erc1155-processor.js +596 -0
- package/src/eth/builtin/internal/erc1155-processor.js.map +1 -0
- package/src/eth/builtin/internal/erc1155-test-utils.d.ts +7 -0
- package/src/eth/builtin/internal/erc1155-test-utils.d.ts.map +1 -0
- package/src/eth/builtin/internal/erc1155-test-utils.js +55 -0
- package/src/eth/builtin/internal/erc1155-test-utils.js.map +1 -0
- package/src/eth/builtin/internal/erc20-processor.d.ts +244 -0
- package/src/eth/builtin/internal/erc20-processor.d.ts.map +1 -0
- package/src/eth/builtin/internal/erc20-processor.js +1109 -0
- package/src/eth/builtin/internal/erc20-processor.js.map +1 -0
- package/src/eth/builtin/internal/erc20-test-utils.d.ts +6 -0
- package/src/eth/builtin/internal/erc20-test-utils.d.ts.map +1 -0
- package/src/eth/builtin/internal/erc20-test-utils.js +44 -0
- package/src/eth/builtin/internal/erc20-test-utils.js.map +1 -0
- package/src/eth/builtin/internal/erc20bytes-processor.d.ts +144 -0
- package/src/eth/builtin/internal/erc20bytes-processor.d.ts.map +1 -0
- package/src/eth/builtin/internal/erc20bytes-processor.js +594 -0
- package/src/eth/builtin/internal/erc20bytes-processor.js.map +1 -0
- package/src/eth/builtin/internal/erc20bytes-test-utils.d.ts +5 -0
- package/src/eth/builtin/internal/erc20bytes-test-utils.d.ts.map +1 -0
- package/src/eth/builtin/internal/erc20bytes-test-utils.js +33 -0
- package/src/eth/builtin/internal/erc20bytes-test-utils.js.map +1 -0
- package/src/eth/builtin/internal/erc721-processor.d.ts +215 -0
- package/src/eth/builtin/internal/erc721-processor.d.ts.map +1 -0
- package/src/eth/builtin/internal/erc721-processor.js +895 -0
- package/src/eth/builtin/internal/erc721-processor.js.map +1 -0
- package/src/eth/builtin/internal/erc721-test-utils.d.ts +6 -0
- package/src/eth/builtin/internal/erc721-test-utils.d.ts.map +1 -0
- package/src/eth/builtin/internal/erc721-test-utils.js +44 -0
- package/src/eth/builtin/internal/erc721-test-utils.js.map +1 -0
- package/src/eth/builtin/internal/factories/EACAggregatorProxy__factory.d.ts +400 -0
- package/src/eth/builtin/internal/factories/EACAggregatorProxy__factory.d.ts.map +1 -0
- package/src/eth/builtin/internal/factories/EACAggregatorProxy__factory.js +524 -0
- package/src/eth/builtin/internal/factories/EACAggregatorProxy__factory.js.map +1 -0
- package/src/eth/builtin/internal/factories/ERC1155__factory.d.ts +251 -0
- package/src/eth/builtin/internal/factories/ERC1155__factory.d.ts.map +1 -0
- package/src/eth/builtin/internal/factories/ERC1155__factory.js +329 -0
- package/src/eth/builtin/internal/factories/ERC1155__factory.js.map +1 -0
- package/src/eth/builtin/internal/factories/ERC20Bytes__factory.d.ts +185 -0
- package/src/eth/builtin/internal/factories/ERC20Bytes__factory.d.ts.map +1 -0
- package/src/eth/builtin/internal/factories/ERC20Bytes__factory.js +251 -0
- package/src/eth/builtin/internal/factories/ERC20Bytes__factory.js.map +1 -0
- package/src/eth/builtin/internal/factories/ERC20__factory.d.ts +303 -0
- package/src/eth/builtin/internal/factories/ERC20__factory.d.ts.map +1 -0
- package/src/eth/builtin/internal/factories/ERC20__factory.js +401 -0
- package/src/eth/builtin/internal/factories/ERC20__factory.js.map +1 -0
- package/src/eth/builtin/internal/factories/ERC721__factory.d.ts +273 -0
- package/src/eth/builtin/internal/factories/ERC721__factory.d.ts.map +1 -0
- package/src/eth/builtin/internal/factories/ERC721__factory.js +361 -0
- package/src/eth/builtin/internal/factories/ERC721__factory.js.map +1 -0
- package/src/eth/builtin/internal/factories/WETH9__factory.d.ts +220 -0
- package/src/eth/builtin/internal/factories/WETH9__factory.d.ts.map +1 -0
- package/src/eth/builtin/internal/factories/WETH9__factory.js +294 -0
- package/src/eth/builtin/internal/factories/WETH9__factory.js.map +1 -0
- package/src/eth/builtin/internal/factories/index.d.ts +7 -0
- package/src/eth/builtin/internal/factories/index.d.ts.map +1 -0
- package/src/eth/builtin/internal/factories/index.js +10 -0
- package/src/eth/builtin/internal/factories/index.js.map +1 -0
- package/src/eth/builtin/internal/index.d.ts +14 -0
- package/src/eth/builtin/internal/index.d.ts.map +1 -0
- package/src/eth/builtin/internal/index.js +8 -0
- package/src/eth/builtin/internal/index.js.map +1 -0
- package/src/eth/builtin/internal/weth9-processor.d.ts +172 -0
- package/src/eth/builtin/internal/weth9-processor.d.ts.map +1 -0
- package/src/eth/builtin/internal/weth9-processor.js +729 -0
- package/src/eth/builtin/internal/weth9-processor.js.map +1 -0
- package/src/eth/builtin/internal/weth9-test-utils.d.ts +7 -0
- package/src/eth/builtin/internal/weth9-test-utils.d.ts.map +1 -0
- package/src/eth/builtin/internal/weth9-test-utils.js +55 -0
- package/src/eth/builtin/internal/weth9-test-utils.js.map +1 -0
- package/src/eth/builtin/weth9.d.ts +5 -0
- package/src/eth/builtin/weth9.d.ts.map +1 -0
- package/src/eth/builtin/weth9.js +8 -0
- package/src/eth/builtin/weth9.js.map +1 -0
- package/src/solana/builtin/index.d.ts +2 -0
- package/src/solana/builtin/index.d.ts.map +1 -0
- package/src/solana/builtin/index.js +2 -0
- package/src/solana/builtin/index.js.map +1 -0
- package/src/solana/builtin/spl-token-processor.d.ts +40 -0
- package/src/solana/builtin/spl-token-processor.d.ts.map +1 -0
- package/src/solana/builtin/spl-token-processor.js +254 -0
- package/src/solana/builtin/spl-token-processor.js.map +1 -0
- package/src/solana/builtin/types.d.ts +428 -0
- package/src/solana/builtin/types.d.ts.map +1 -0
- package/src/solana/builtin/types.js +201 -0
- package/src/solana/builtin/types.js.map +1 -0
- package/src/sui/builtin/0x1.d.ts +114 -0
- package/src/sui/builtin/0x1.d.ts.map +1 -0
- package/src/sui/builtin/0x1.js +159 -0
- package/src/sui/builtin/0x1.js.map +1 -0
- package/src/sui/builtin/0x2.d.ts +1250 -0
- package/src/sui/builtin/0x2.d.ts.map +1 -0
- package/src/sui/builtin/0x2.js +1511 -0
- package/src/sui/builtin/0x2.js.map +1 -0
- package/src/sui/builtin/0x3.d.ts +774 -0
- package/src/sui/builtin/0x3.d.ts.map +1 -0
- package/src/sui/builtin/0x3.js +720 -0
- package/src/sui/builtin/0x3.js.map +1 -0
- package/src/sui/builtin/index.d.ts +4 -0
- package/src/sui/builtin/index.d.ts.map +1 -0
- package/src/sui/builtin/index.js +7 -0
- package/src/sui/builtin/index.js.map +1 -0
@@ -0,0 +1,259 @@
|
|
1
|
+
import { createRequire as createRequireSdkShim } from 'module'; const require = createRequireSdkShim(import.meta.url);
|
2
|
+
import{b as kl}from"./chunk-FMZDKD72.js";import{c as Sr,d as vm,e as Al,g as Tm}from"./chunk-O564J2U6.js";import{Ac as Em,Cd as Ys,Dd as km,E as ia,Nd as El,Rc as Rl,Tc as Sm,Uc as Am,Y as wl,Zb as Er,de as Sl,nd as Gs,sc as aa,tc as Rm,zc as ca}from"./chunk-JQ4LTUIX.js";import{b as Im}from"./chunk-QGIFUSFI.js";import{a,b as ae,c as Pe,d as ce,e as Cn,f as fe,g as xn}from"./chunk-G5BIPHMS.js";var Cl=ce((la,Nl)=>{"use strict";var Js=ae("buffer"),Ot=Js.Buffer;function Ol(n,e){for(var t in n)e[t]=n[t]}a(Ol,"copyProps");Ot.from&&Ot.alloc&&Ot.allocUnsafe&&Ot.allocUnsafeSlow?Nl.exports=Js:(Ol(Js,la),la.Buffer=Ar);function Ar(n,e,t){return Ot(n,e,t)}a(Ar,"SafeBuffer");Ar.prototype=Object.create(Ot.prototype);Ol(Ot,Ar);Ar.from=function(n,e,t){if(typeof n=="number")throw new TypeError("Argument must not be a number");return Ot(n,e,t)};Ar.alloc=function(n,e,t){if(typeof n!="number")throw new TypeError("Argument must be a number");var r=Ot(n);return e!==void 0?typeof t=="string"?r.fill(e,t):r.fill(e):r.fill(0),r};Ar.allocUnsafe=function(n){if(typeof n!="number")throw new TypeError("Argument must be a number");return Ot(n)};Ar.allocUnsafeSlow=function(n){if(typeof n!="number")throw new TypeError("Argument must be a number");return Js.SlowBuffer(n)}});var Ll=ce((rE,xl)=>{"use strict";var Zs=Cl().Buffer;function Um(n){if(n.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),t=0;t<e.length;t++)e[t]=255;for(var r=0;r<n.length;r++){var o=n.charAt(r),s=o.charCodeAt(0);if(e[s]!==255)throw new TypeError(o+" is ambiguous");e[s]=r}var i=n.length,u=n.charAt(0),f=Math.log(i)/Math.log(256),y=Math.log(256)/Math.log(i);function d(R){if((Array.isArray(R)||R instanceof Uint8Array)&&(R=Zs.from(R)),!Zs.isBuffer(R))throw new TypeError("Expected Buffer");if(R.length===0)return"";for(var S=0,A=0,C=0,x=R.length;C!==x&&R[C]===0;)C++,S++;for(var w=(x-C)*y+1>>>0,L=new Uint8Array(w);C!==x;){for(var z=R[C],Y=0,ne=w-1;(z!==0||Y<A)&&ne!==-1;ne--,Y++)z+=256*L[ne]>>>0,L[ne]=z%i>>>0,z=z/i>>>0;if(z!==0)throw new Error("Non-zero carry");A=Y,C++}for(var re=w-A;re!==w&&L[re]===0;)re++;for(var Se=u.repeat(S);re<w;++re)Se+=n.charAt(L[re]);return Se}a(d,"encode");function _(R){if(typeof R!="string")throw new TypeError("Expected String");if(R.length===0)return Zs.alloc(0);for(var S=0,A=0,C=0;R[S]===u;)A++,S++;for(var x=(R.length-S)*f+1>>>0,w=new Uint8Array(x);R[S];){var L=e[R.charCodeAt(S)];if(L===255)return;for(var z=0,Y=x-1;(L!==0||z<C)&&Y!==-1;Y--,z++)L+=i*w[Y]>>>0,w[Y]=L%256>>>0,L=L/256>>>0;if(L!==0)throw new Error("Non-zero carry");C=z,S++}for(var ne=x-C;ne!==x&&w[ne]===0;)ne++;var re=Zs.allocUnsafe(A+(x-ne));re.fill(0,0,A);for(var Se=A;ne!==x;)re[Se++]=w[ne++];return re}a(_,"decodeUnsafe");function E(R){var S=_(R);if(S)return S;throw new Error("Non-base"+i+" character")}return a(E,"decode"),{encode:d,decodeUnsafe:_,decode:E}}a(Um,"base");xl.exports=Um});var Gr=ce((sE,Pl)=>{"use strict";var Dm=Ll(),Mm="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";Pl.exports=Dm(Mm)});var Bl=ce(ha=>{"use strict";function Ft(n,e,t){return e<=n&&n<=t}a(Ft,"inRange");function no(n){if(n===void 0)return{};if(n===Object(n))return n;throw TypeError("Could not convert argument to dictionary")}a(no,"ToDictionary");function $m(n){for(var e=String(n),t=e.length,r=0,o=[];r<t;){var s=e.charCodeAt(r);if(s<55296||s>57343)o.push(s);else if(56320<=s&&s<=57343)o.push(65533);else if(55296<=s&&s<=56319)if(r===t-1)o.push(65533);else{var i=n.charCodeAt(r+1);if(56320<=i&&i<=57343){var u=s&1023,f=i&1023;o.push(65536+(u<<10)+f),r+=1}else o.push(65533)}r+=1}return o}a($m,"stringToCodePoints");function Hm(n){for(var e="",t=0;t<n.length;++t){var r=n[t];r<=65535?e+=String.fromCharCode(r):(r-=65536,e+=String.fromCharCode((r>>10)+55296,(r&1023)+56320))}return e}a(Hm,"codePointsToString");var Qs=-1;function da(n){this.tokens=[].slice.call(n)}a(da,"Stream");da.prototype={endOfStream:a(function(){return!this.tokens.length},"endOfStream"),read:a(function(){return this.tokens.length?this.tokens.shift():Qs},"read"),prepend:a(function(n){if(Array.isArray(n))for(var e=n;e.length;)this.tokens.unshift(e.pop());else this.tokens.unshift(n)},"prepend"),push:a(function(n){if(Array.isArray(n))for(var e=n;e.length;)this.tokens.push(e.shift());else this.tokens.push(n)},"push")};var Yr=-1;function fa(n,e){if(n)throw TypeError("Decoder error");return e||65533}a(fa,"decoderError");var eo="utf-8";function to(n,e){if(!(this instanceof to))return new to(n,e);if(n=n!==void 0?String(n).toLowerCase():eo,n!==eo)throw new Error("Encoding not supported. Only utf-8 is supported");e=no(e),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=!!e.fatal,this._ignoreBOM=!!e.ignoreBOM,Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}a(to,"TextDecoder");to.prototype={decode:a(function(e,t){var r;typeof e=="object"&&e instanceof ArrayBuffer?r=new Uint8Array(e):typeof e=="object"&&"buffer"in e&&e.buffer instanceof ArrayBuffer?r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):r=new Uint8Array(0),t=no(t),this._streaming||(this._decoder=new zm({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!t.stream;for(var o=new da(r),s=[],i;!o.endOfStream()&&(i=this._decoder.handler(o,o.read()),i!==Yr);)i!==null&&(Array.isArray(i)?s.push.apply(s,i):s.push(i));if(!this._streaming){do{if(i=this._decoder.handler(o,o.read()),i===Yr)break;i!==null&&(Array.isArray(i)?s.push.apply(s,i):s.push(i))}while(!o.endOfStream());this._decoder=null}return s.length&&["utf-8"].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(s[0]===65279?(this._BOMseen=!0,s.shift()):this._BOMseen=!0),Hm(s)},"decode")};function ro(n,e){if(!(this instanceof ro))return new ro(n,e);if(n=n!==void 0?String(n).toLowerCase():eo,n!==eo)throw new Error("Encoding not supported. Only utf-8 is supported");e=no(e),this._streaming=!1,this._encoder=null,this._options={fatal:!!e.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}a(ro,"TextEncoder");ro.prototype={encode:a(function(e,t){e=e?String(e):"",t=no(t),this._streaming||(this._encoder=new Fm(this._options)),this._streaming=!!t.stream;for(var r=[],o=new da($m(e)),s;!o.endOfStream()&&(s=this._encoder.handler(o,o.read()),s!==Yr);)Array.isArray(s)?r.push.apply(r,s):r.push(s);if(!this._streaming){for(;s=this._encoder.handler(o,o.read()),s!==Yr;)Array.isArray(s)?r.push.apply(r,s):r.push(s);this._encoder=null}return new Uint8Array(r)},"encode")};function zm(n){var e=n.fatal,t=0,r=0,o=0,s=128,i=191;this.handler=function(u,f){if(f===Qs&&o!==0)return o=0,fa(e);if(f===Qs)return Yr;if(o===0){if(Ft(f,0,127))return f;if(Ft(f,194,223))o=1,t=f-192;else if(Ft(f,224,239))f===224&&(s=160),f===237&&(i=159),o=2,t=f-224;else if(Ft(f,240,244))f===240&&(s=144),f===244&&(i=143),o=3,t=f-240;else return fa(e);return t=t<<6*o,null}if(!Ft(f,s,i))return t=o=r=0,s=128,i=191,u.prepend(f),fa(e);if(s=128,i=191,r+=1,t+=f-128<<6*(o-r),r!==o)return null;var y=t;return t=o=r=0,y}}a(zm,"UTF8Decoder");function Fm(n){var e=n.fatal;this.handler=function(t,r){if(r===Qs)return Yr;if(Ft(r,0,127))return r;var o,s;Ft(r,128,2047)?(o=1,s=192):Ft(r,2048,65535)?(o=2,s=224):Ft(r,65536,1114111)&&(o=3,s=240);for(var i=[(r>>6*o)+s];o>0;){var u=r>>6*(o-1);i.push(128|u&63),o-=1}return i}}a(Fm,"UTF8Encoder");ha.TextEncoder=ro;ha.TextDecoder=to});var Hl=ce(Ee=>{"use strict";var Wm=Ee&&Ee.__createBinding||(Object.create?function(n,e,t,r){r===void 0&&(r=t),Object.defineProperty(n,r,{enumerable:!0,get:a(function(){return e[t]},"get")})}:function(n,e,t,r){r===void 0&&(r=t),n[r]=e[t]}),Km=Ee&&Ee.__setModuleDefault||(Object.create?function(n,e){Object.defineProperty(n,"default",{enumerable:!0,value:e})}:function(n,e){n.default=e}),Nt=Ee&&Ee.__decorate||function(n,e,t,r){var o=arguments.length,s=o<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(n,e,t,r);else for(var u=n.length-1;u>=0;u--)(i=n[u])&&(s=(o<3?i(s):o>3?i(e,t,s):i(e,t))||s);return o>3&&s&&Object.defineProperty(e,t,s),s},qm=Ee&&Ee.__importStar||function(n){if(n&&n.__esModule)return n;var e={};if(n!=null)for(var t in n)t!=="default"&&Object.hasOwnProperty.call(n,t)&&Wm(e,n,t);return Km(e,n),e},Ul=Ee&&Ee.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(Ee,"__esModule",{value:!0});Ee.deserializeUnchecked=Ee.deserialize=Ee.serialize=Ee.BinaryReader=Ee.BinaryWriter=Ee.BorshError=Ee.baseDecode=Ee.baseEncode=void 0;var nr=Ul(Er()),Dl=Ul(Gr()),jm=qm(Bl()),Vm=typeof TextDecoder!="function"?jm.TextDecoder:TextDecoder,Gm=new Vm("utf-8",{fatal:!0});function Ym(n){return typeof n=="string"&&(n=Buffer.from(n,"utf8")),Dl.default.encode(Buffer.from(n))}a(Ym,"baseEncode");Ee.baseEncode=Ym;function Xm(n){return Buffer.from(Dl.default.decode(n))}a(Xm,"baseDecode");Ee.baseDecode=Xm;var pa=1024,Ke=class extends Error{static{a(this,"BorshError")}constructor(e){super(e),this.fieldPath=[],this.originalMessage=e}addToFieldPath(e){this.fieldPath.splice(0,0,e),this.message=this.originalMessage+": "+this.fieldPath.join(".")}};Ee.BorshError=Ke;var so=class{static{a(this,"BinaryWriter")}constructor(){this.buf=Buffer.alloc(pa),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(pa)]))}writeU8(e){this.maybeResize(),this.buf.writeUInt8(e,this.length),this.length+=1}writeU16(e){this.maybeResize(),this.buf.writeUInt16LE(e,this.length),this.length+=2}writeU32(e){this.maybeResize(),this.buf.writeUInt32LE(e,this.length),this.length+=4}writeU64(e){this.maybeResize(),this.writeBuffer(Buffer.from(new nr.default(e).toArray("le",8)))}writeU128(e){this.maybeResize(),this.writeBuffer(Buffer.from(new nr.default(e).toArray("le",16)))}writeU256(e){this.maybeResize(),this.writeBuffer(Buffer.from(new nr.default(e).toArray("le",32)))}writeU512(e){this.maybeResize(),this.writeBuffer(Buffer.from(new nr.default(e).toArray("le",64)))}writeBuffer(e){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),e,Buffer.alloc(pa)]),this.length+=e.length}writeString(e){this.maybeResize();let t=Buffer.from(e,"utf8");this.writeU32(t.length),this.writeBuffer(t)}writeFixedArray(e){this.writeBuffer(Buffer.from(e))}writeArray(e,t){this.maybeResize(),this.writeU32(e.length);for(let r of e)this.maybeResize(),t(r)}toArray(){return this.buf.subarray(0,this.length)}};Ee.BinaryWriter=so;function Ct(n,e,t){let r=t.value;t.value=function(...o){try{return r.apply(this,o)}catch(s){if(s instanceof RangeError){let i=s.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(i)>=0)throw new Ke("Reached the end of buffer when deserializing")}throw s}}}a(Ct,"handlingRangeError");var Qe=class{static{a(this,"BinaryReader")}constructor(e){this.buf=e,this.offset=0}readU8(){let e=this.buf.readUInt8(this.offset);return this.offset+=1,e}readU16(){let e=this.buf.readUInt16LE(this.offset);return this.offset+=2,e}readU32(){let e=this.buf.readUInt32LE(this.offset);return this.offset+=4,e}readU64(){let e=this.readBuffer(8);return new nr.default(e,"le")}readU128(){let e=this.readBuffer(16);return new nr.default(e,"le")}readU256(){let e=this.readBuffer(32);return new nr.default(e,"le")}readU512(){let e=this.readBuffer(64);return new nr.default(e,"le")}readBuffer(e){if(this.offset+e>this.buf.length)throw new Ke(`Expected buffer length ${e} isn't within bounds`);let t=this.buf.slice(this.offset,this.offset+e);return this.offset+=e,t}readString(){let e=this.readU32(),t=this.readBuffer(e);try{return Gm.decode(t)}catch(r){throw new Ke(`Error decoding UTF-8 string: ${r}`)}}readFixedArray(e){return new Uint8Array(this.readBuffer(e))}readArray(e){let t=this.readU32(),r=Array();for(let o=0;o<t;++o)r.push(e());return r}};Nt([Ct],Qe.prototype,"readU8",null);Nt([Ct],Qe.prototype,"readU16",null);Nt([Ct],Qe.prototype,"readU32",null);Nt([Ct],Qe.prototype,"readU64",null);Nt([Ct],Qe.prototype,"readU128",null);Nt([Ct],Qe.prototype,"readU256",null);Nt([Ct],Qe.prototype,"readU512",null);Nt([Ct],Qe.prototype,"readString",null);Nt([Ct],Qe.prototype,"readFixedArray",null);Nt([Ct],Qe.prototype,"readArray",null);Ee.BinaryReader=Qe;function Ml(n){return n.charAt(0).toUpperCase()+n.slice(1)}a(Ml,"capitalizeFirstLetter");function kr(n,e,t,r,o){try{if(typeof r=="string")o[`write${Ml(r)}`](t);else if(r instanceof Array)if(typeof r[0]=="number"){if(t.length!==r[0])throw new Ke(`Expecting byte array of length ${r[0]}, but got ${t.length} bytes`);o.writeFixedArray(t)}else if(r.length===2&&typeof r[1]=="number"){if(t.length!==r[1])throw new Ke(`Expecting byte array of length ${r[1]}, but got ${t.length} bytes`);for(let s=0;s<r[1];s++)kr(n,null,t[s],r[0],o)}else o.writeArray(t,s=>{kr(n,e,s,r[0],o)});else if(r.kind!==void 0)switch(r.kind){case"option":{t==null?o.writeU8(0):(o.writeU8(1),kr(n,e,t,r.type,o));break}case"map":{o.writeU32(t.size),t.forEach((s,i)=>{kr(n,e,i,r.key,o),kr(n,e,s,r.value,o)});break}default:throw new Ke(`FieldType ${r} unrecognized`)}else $l(n,t,o)}catch(s){throw s instanceof Ke&&s.addToFieldPath(e),s}}a(kr,"serializeField");function $l(n,e,t){if(typeof e.borshSerialize=="function"){e.borshSerialize(t);return}let r=n.get(e.constructor);if(!r)throw new Ke(`Class ${e.constructor.name} is missing in schema`);if(r.kind==="struct")r.fields.map(([o,s])=>{kr(n,o,e[o],s,t)});else if(r.kind==="enum"){let o=e[r.field];for(let s=0;s<r.values.length;++s){let[i,u]=r.values[s];if(i===o){t.writeU8(s),kr(n,i,e[i],u,t);break}}}else throw new Ke(`Unexpected schema kind: ${r.kind} for ${e.constructor.name}`)}a($l,"serializeStruct");function Jm(n,e,t=so){let r=new t;return $l(n,e,r),r.toArray()}a(Jm,"serialize");Ee.serialize=Jm;function Ir(n,e,t,r){try{if(typeof t=="string")return r[`read${Ml(t)}`]();if(t instanceof Array){if(typeof t[0]=="number")return r.readFixedArray(t[0]);if(typeof t[1]=="number"){let o=[];for(let s=0;s<t[1];s++)o.push(Ir(n,null,t[0],r));return o}else return r.readArray(()=>Ir(n,e,t[0],r))}if(t.kind==="option")return r.readU8()?Ir(n,e,t.type,r):void 0;if(t.kind==="map"){let o=new Map,s=r.readU32();for(let i=0;i<s;i++){let u=Ir(n,e,t.key,r),f=Ir(n,e,t.value,r);o.set(u,f)}return o}return ya(n,t,r)}catch(o){throw o instanceof Ke&&o.addToFieldPath(e),o}}a(Ir,"deserializeField");function ya(n,e,t){if(typeof e.borshDeserialize=="function")return e.borshDeserialize(t);let r=n.get(e);if(!r)throw new Ke(`Class ${e.name} is missing in schema`);if(r.kind==="struct"){let o={};for(let[s,i]of n.get(e).fields)o[s]=Ir(n,s,i,t);return new e(o)}if(r.kind==="enum"){let o=t.readU8();if(o>=r.values.length)throw new Ke(`Enum index: ${o} is out of range`);let[s,i]=r.values[o],u=Ir(n,s,i,t);return new e({[s]:u})}throw new Ke(`Unexpected schema kind: ${r.kind} for ${e.constructor.name}`)}a(ya,"deserializeStruct");function Zm(n,e,t,r=Qe){let o=new r(t),s=ya(n,e,o);if(o.offset<t.length)throw new Ke(`Unexpected ${t.length-o.offset} bytes after deserialized data`);return s}a(Zm,"deserialize");Ee.deserialize=Zm;function Qm(n,e,t,r=Qe){let o=new r(t);return ya(n,e,o)}a(Qm,"deserializeUnchecked");Ee.deserializeUnchecked=Qm});var ba=ce(O=>{"use strict";Object.defineProperty(O,"__esModule",{value:!0});O.s16=O.s8=O.nu64be=O.u48be=O.u40be=O.u32be=O.u24be=O.u16be=O.nu64=O.u48=O.u40=O.u32=O.u24=O.u16=O.u8=O.offset=O.greedy=O.Constant=O.UTF8=O.CString=O.Blob=O.Boolean=O.BitField=O.BitStructure=O.VariantLayout=O.Union=O.UnionLayoutDiscriminator=O.UnionDiscriminator=O.Structure=O.Sequence=O.DoubleBE=O.Double=O.FloatBE=O.Float=O.NearInt64BE=O.NearInt64=O.NearUInt64BE=O.NearUInt64=O.IntBE=O.Int=O.UIntBE=O.UInt=O.OffsetLayout=O.GreedyCount=O.ExternalLayout=O.bindConstructorLayout=O.nameWithProperty=O.Layout=O.uint8ArrayToBuffer=O.checkUint8Array=void 0;O.constant=O.utf8=O.cstr=O.blob=O.unionLayoutDiscriminator=O.union=O.seq=O.bits=O.struct=O.f64be=O.f64=O.f32be=O.f32=O.ns64be=O.s48be=O.s40be=O.s32be=O.s24be=O.s16be=O.ns64=O.s48=O.s40=O.s32=O.s24=void 0;var ga=ae("buffer");function Zr(n){if(!(n instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}a(Zr,"checkUint8Array");O.checkUint8Array=Zr;function pe(n){return Zr(n),ga.Buffer.from(n.buffer,n.byteOffset,n.length)}a(pe,"uint8ArrayToBuffer");O.uint8ArrayToBuffer=pe;var ge=class{static{a(this,"Layout")}constructor(e,t){if(!Number.isInteger(e))throw new TypeError("span must be an integer");this.span=e,this.property=t}makeDestinationObject(){return{}}getSpan(e,t){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(e){let t=Object.create(this.constructor.prototype);return Object.assign(t,this),t.property=e,t}fromArray(e){}};O.Layout=ge;function _a(n,e){return e.property?n+"["+e.property+"]":n}a(_a,"nameWithProperty");O.nameWithProperty=_a;function eg(n,e){if(typeof n!="function")throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(n,"layout_"))throw new Error("Class is already bound to a layout");if(!(e&&e instanceof ge))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(e,"boundConstructor_"))throw new Error("layout is already bound to a constructor");n.layout_=e,e.boundConstructor_=n,e.makeDestinationObject=()=>new n,Object.defineProperty(n.prototype,"encode",{value(t,r){return e.encode(this,t,r)},writable:!0}),Object.defineProperty(n,"decode",{value(t,r){return e.decode(t,r)},writable:!0})}a(eg,"bindConstructorLayout");O.bindConstructorLayout=eg;var Ve=class extends ge{static{a(this,"ExternalLayout")}isCount(){throw new Error("ExternalLayout is abstract")}};O.ExternalLayout=Ve;var oo=class extends Ve{static{a(this,"GreedyCount")}constructor(e=1,t){if(!Number.isInteger(e)||0>=e)throw new TypeError("elementSpan must be a (positive) integer");super(-1,t),this.elementSpan=e}isCount(){return!0}decode(e,t=0){Zr(e);let r=e.length-t;return Math.floor(r/this.elementSpan)}encode(e,t,r){return 0}};O.GreedyCount=oo;var Ln=class extends Ve{static{a(this,"OffsetLayout")}constructor(e,t=0,r){if(!(e instanceof ge))throw new TypeError("layout must be a Layout");if(!Number.isInteger(t))throw new TypeError("offset must be integer or undefined");super(e.span,r||e.property),this.layout=e,this.offset=t}isCount(){return this.layout instanceof tt||this.layout instanceof ct}decode(e,t=0){return this.layout.decode(e,t+this.offset)}encode(e,t,r=0){return this.layout.encode(e,t,r+this.offset)}};O.OffsetLayout=Ln;var tt=class extends ge{static{a(this,"UInt")}constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t=0){return pe(e).readUIntLE(t,this.span)}encode(e,t,r=0){return pe(t).writeUIntLE(e,r,this.span),this.span}};O.UInt=tt;var ct=class extends ge{static{a(this,"UIntBE")}constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t=0){return pe(e).readUIntBE(t,this.span)}encode(e,t,r=0){return pe(t).writeUIntBE(e,r,this.span),this.span}};O.UIntBE=ct;var Wt=class extends ge{static{a(this,"Int")}constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t=0){return pe(e).readIntLE(t,this.span)}encode(e,t,r=0){return pe(t).writeIntLE(e,r,this.span),this.span}};O.Int=Wt;var sr=class extends ge{static{a(this,"IntBE")}constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t=0){return pe(e).readIntBE(t,this.span)}encode(e,t,r=0){return pe(t).writeIntBE(e,r,this.span),this.span}};O.IntBE=sr;var ma=Math.pow(2,32);function So(n){let e=Math.floor(n/ma),t=n-e*ma;return{hi32:e,lo32:t}}a(So,"divmodInt64");function Ao(n,e){return n*ma+e}a(Ao,"roundedInt64");var io=class extends ge{static{a(this,"NearUInt64")}constructor(e){super(8,e)}decode(e,t=0){let r=pe(e),o=r.readUInt32LE(t),s=r.readUInt32LE(t+4);return Ao(s,o)}encode(e,t,r=0){let o=So(e),s=pe(t);return s.writeUInt32LE(o.lo32,r),s.writeUInt32LE(o.hi32,r+4),8}};O.NearUInt64=io;var ao=class extends ge{static{a(this,"NearUInt64BE")}constructor(e){super(8,e)}decode(e,t=0){let r=pe(e),o=r.readUInt32BE(t),s=r.readUInt32BE(t+4);return Ao(o,s)}encode(e,t,r=0){let o=So(e),s=pe(t);return s.writeUInt32BE(o.hi32,r),s.writeUInt32BE(o.lo32,r+4),8}};O.NearUInt64BE=ao;var co=class extends ge{static{a(this,"NearInt64")}constructor(e){super(8,e)}decode(e,t=0){let r=pe(e),o=r.readUInt32LE(t),s=r.readInt32LE(t+4);return Ao(s,o)}encode(e,t,r=0){let o=So(e),s=pe(t);return s.writeUInt32LE(o.lo32,r),s.writeInt32LE(o.hi32,r+4),8}};O.NearInt64=co;var uo=class extends ge{static{a(this,"NearInt64BE")}constructor(e){super(8,e)}decode(e,t=0){let r=pe(e),o=r.readInt32BE(t),s=r.readUInt32BE(t+4);return Ao(o,s)}encode(e,t,r=0){let o=So(e),s=pe(t);return s.writeInt32BE(o.hi32,r),s.writeUInt32BE(o.lo32,r+4),8}};O.NearInt64BE=uo;var lo=class extends ge{static{a(this,"Float")}constructor(e){super(4,e)}decode(e,t=0){return pe(e).readFloatLE(t)}encode(e,t,r=0){return pe(t).writeFloatLE(e,r),4}};O.Float=lo;var fo=class extends ge{static{a(this,"FloatBE")}constructor(e){super(4,e)}decode(e,t=0){return pe(e).readFloatBE(t)}encode(e,t,r=0){return pe(t).writeFloatBE(e,r),4}};O.FloatBE=fo;var ho=class extends ge{static{a(this,"Double")}constructor(e){super(8,e)}decode(e,t=0){return pe(e).readDoubleLE(t)}encode(e,t,r=0){return pe(t).writeDoubleLE(e,r),8}};O.Double=ho;var po=class extends ge{static{a(this,"DoubleBE")}constructor(e){super(8,e)}decode(e,t=0){return pe(e).readDoubleBE(t)}encode(e,t,r=0){return pe(t).writeDoubleBE(e,r),8}};O.DoubleBE=po;var yo=class extends ge{static{a(this,"Sequence")}constructor(e,t,r){if(!(e instanceof ge))throw new TypeError("elementLayout must be a Layout");if(!(t instanceof Ve&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let o=-1;!(t instanceof Ve)&&0<e.span&&(o=t*e.span),super(o,r),this.elementLayout=e,this.count=t}getSpan(e,t=0){if(0<=this.span)return this.span;let r=0,o=this.count;if(o instanceof Ve&&(o=o.decode(e,t)),0<this.elementLayout.span)r=o*this.elementLayout.span;else{let s=0;for(;s<o;)r+=this.elementLayout.getSpan(e,t+r),++s}return r}decode(e,t=0){let r=[],o=0,s=this.count;for(s instanceof Ve&&(s=s.decode(e,t));o<s;)r.push(this.elementLayout.decode(e,t)),t+=this.elementLayout.getSpan(e,t),o+=1;return r}encode(e,t,r=0){let o=this.elementLayout,s=e.reduce((i,u)=>i+o.encode(u,t,r+i),0);return this.count instanceof Ve&&this.count.encode(e.length,t,r),s}};O.Sequence=yo;var mo=class extends ge{static{a(this,"Structure")}constructor(e,t,r){if(!(Array.isArray(e)&&e.reduce((s,i)=>s&&i instanceof ge,!0)))throw new TypeError("fields must be array of Layout instances");typeof t=="boolean"&&r===void 0&&(r=t,t=void 0);for(let s of e)if(0>s.span&&s.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let o=-1;try{o=e.reduce((s,i)=>s+i.getSpan(),0)}catch{}super(o,t),this.fields=e,this.decodePrefixes=!!r}getSpan(e,t=0){if(0<=this.span)return this.span;let r=0;try{r=this.fields.reduce((o,s)=>{let i=s.getSpan(e,t);return t+=i,o+i},0)}catch{throw new RangeError("indeterminate span")}return r}decode(e,t=0){Zr(e);let r=this.makeDestinationObject();for(let o of this.fields)if(o.property!==void 0&&(r[o.property]=o.decode(e,t)),t+=o.getSpan(e,t),this.decodePrefixes&&e.length===t)break;return r}encode(e,t,r=0){let o=r,s=0,i=0;for(let u of this.fields){let f=u.span;if(i=0<f?f:0,u.property!==void 0){let y=e[u.property];y!==void 0&&(i=u.encode(y,t,r),0>f&&(f=u.getSpan(t,r)))}s=r,r+=f}return s+i-o}fromArray(e){let t=this.makeDestinationObject();for(let r of this.fields)r.property!==void 0&&0<e.length&&(t[r.property]=e.shift());return t}layoutFor(e){if(typeof e!="string")throw new TypeError("property must be string");for(let t of this.fields)if(t.property===e)return t}offsetOf(e){if(typeof e!="string")throw new TypeError("property must be string");let t=0;for(let r of this.fields){if(r.property===e)return t;0>r.span?t=-1:0<=t&&(t+=r.span)}}};O.Structure=mo;var Pn=class{static{a(this,"UnionDiscriminator")}constructor(e){this.property=e}decode(e,t){throw new Error("UnionDiscriminator is abstract")}encode(e,t,r){throw new Error("UnionDiscriminator is abstract")}};O.UnionDiscriminator=Pn;var Jr=class extends Pn{static{a(this,"UnionLayoutDiscriminator")}constructor(e,t){if(!(e instanceof Ve&&e.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(t||e.property||"variant"),this.layout=e}decode(e,t){return this.layout.decode(e,t)}encode(e,t,r){return this.layout.encode(e,t,r)}};O.UnionLayoutDiscriminator=Jr;var Bn=class extends ge{static{a(this,"Union")}constructor(e,t,r){let o;if(e instanceof tt||e instanceof ct)o=new Jr(new Ln(e));else if(e instanceof Ve&&e.isCount())o=new Jr(e);else if(e instanceof Pn)o=e;else throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(t===void 0&&(t=null),!(t===null||t instanceof ge))throw new TypeError("defaultLayout must be null or a Layout");if(t!==null){if(0>t.span)throw new Error("defaultLayout must have constant span");t.property===void 0&&(t=t.replicate("content"))}let s=-1;t&&(s=t.span,0<=s&&(e instanceof tt||e instanceof ct)&&(s+=o.layout.span)),super(s,r),this.discriminator=o,this.usesPrefixDiscriminator=e instanceof tt||e instanceof ct,this.defaultLayout=t,this.registry={};let i=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(u){return i(u)},this.configGetSourceVariant=function(u){i=u.bind(this)}}getSpan(e,t=0){if(0<=this.span)return this.span;let r=this.getVariant(e,t);if(!r)throw new Error("unable to determine span for unrecognized variant");return r.getSpan(e,t)}defaultGetSourceVariant(e){if(Object.prototype.hasOwnProperty.call(e,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(e,this.defaultLayout.property))return;let t=this.registry[e[this.discriminator.property]];if(t&&(!t.layout||t.property&&Object.prototype.hasOwnProperty.call(e,t.property)))return t}else for(let t in this.registry){let r=this.registry[t];if(r.property&&Object.prototype.hasOwnProperty.call(e,r.property))return r}throw new Error("unable to infer src variant")}decode(e,t=0){let r,o=this.discriminator,s=o.decode(e,t),i=this.registry[s];if(i===void 0){let u=this.defaultLayout,f=0;this.usesPrefixDiscriminator&&(f=o.layout.span),r=this.makeDestinationObject(),r[o.property]=s,r[u.property]=u.decode(e,t+f)}else r=i.decode(e,t);return r}encode(e,t,r=0){let o=this.getSourceVariant(e);if(o===void 0){let s=this.discriminator,i=this.defaultLayout,u=0;return this.usesPrefixDiscriminator&&(u=s.layout.span),s.encode(e[s.property],t,r),u+i.encode(e[i.property],t,r+u)}return o.encode(e,t,r)}addVariant(e,t,r){let o=new go(this,e,t,r);return this.registry[e]=o,o}getVariant(e,t=0){let r;return e instanceof Uint8Array?r=this.discriminator.decode(e,t):r=e,this.registry[r]}};O.Union=Bn;var go=class extends ge{static{a(this,"VariantLayout")}constructor(e,t,r,o){if(!(e instanceof Bn))throw new TypeError("union must be a Union");if(!Number.isInteger(t)||0>t)throw new TypeError("variant must be a (non-negative) integer");if(typeof r=="string"&&o===void 0&&(o=r,r=null),r){if(!(r instanceof ge))throw new TypeError("layout must be a Layout");if(e.defaultLayout!==null&&0<=r.span&&r.span>e.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof o!="string")throw new TypeError("variant must have a String property")}let s=e.span;0>e.span&&(s=r?r.span:0,0<=s&&e.usesPrefixDiscriminator&&(s+=e.discriminator.layout.span)),super(s,o),this.union=e,this.variant=t,this.layout=r||null}getSpan(e,t=0){if(0<=this.span)return this.span;let r=0;this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span);let o=0;return this.layout&&(o=this.layout.getSpan(e,t+r)),r+o}decode(e,t=0){let r=this.makeDestinationObject();if(this!==this.union.getVariant(e,t))throw new Error("variant mismatch");let o=0;return this.union.usesPrefixDiscriminator&&(o=this.union.discriminator.layout.span),this.layout?r[this.property]=this.layout.decode(e,t+o):this.property?r[this.property]=!0:this.union.usesPrefixDiscriminator&&(r[this.union.discriminator.property]=this.variant),r}encode(e,t,r=0){let o=0;if(this.union.usesPrefixDiscriminator&&(o=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(e,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,t,r);let s=o;if(this.layout&&(this.layout.encode(e[this.property],t,r+o),s+=this.layout.getSpan(t,r+o),0<=this.union.span&&s>this.union.span))throw new Error("encoded variant overruns containing union");return s}fromArray(e){if(this.layout)return this.layout.fromArray(e)}};O.VariantLayout=go;function Xr(n){return 0>n&&(n+=4294967296),n}a(Xr,"fixBitwiseResult");var Un=class extends ge{static{a(this,"BitStructure")}constructor(e,t,r){if(!(e instanceof tt||e instanceof ct))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof t=="string"&&r===void 0&&(r=t,t=!1),4<e.span)throw new RangeError("word cannot exceed 32 bits");super(e.span,r),this.word=e,this.msb=!!t,this.fields=[];let o=0;this._packedSetValue=function(s){return o=Xr(s),this},this._packedGetValue=function(){return o}}decode(e,t=0){let r=this.makeDestinationObject(),o=this.word.decode(e,t);this._packedSetValue(o);for(let s of this.fields)s.property!==void 0&&(r[s.property]=s.decode(e));return r}encode(e,t,r=0){let o=this.word.decode(t,r);this._packedSetValue(o);for(let s of this.fields)if(s.property!==void 0){let i=e[s.property];i!==void 0&&s.encode(i)}return this.word.encode(this._packedGetValue(),t,r)}addField(e,t){let r=new Dn(this,e,t);return this.fields.push(r),r}addBoolean(e){let t=new _o(this,e);return this.fields.push(t),t}fieldFor(e){if(typeof e!="string")throw new TypeError("property must be string");for(let t of this.fields)if(t.property===e)return t}};O.BitStructure=Un;var Dn=class{static{a(this,"BitField")}constructor(e,t,r){if(!(e instanceof Un))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(t)||0>=t)throw new TypeError("bits must be positive integer");let o=8*e.span,s=e.fields.reduce((i,u)=>i+u.bits,0);if(t+s>o)throw new Error("bits too long for span remainder ("+(o-s)+" of "+o+" remain)");this.container=e,this.bits=t,this.valueMask=(1<<t)-1,t===32&&(this.valueMask=4294967295),this.start=s,this.container.msb&&(this.start=o-s-t),this.wordMask=Xr(this.valueMask<<this.start),this.property=r}decode(e,t){let r=this.container._packedGetValue();return Xr(r&this.wordMask)>>>this.start}encode(e){if(typeof e!="number"||!Number.isInteger(e)||e!==Xr(e&this.valueMask))throw new TypeError(_a("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);let t=this.container._packedGetValue(),r=Xr(e<<this.start);this.container._packedSetValue(Xr(t&~this.wordMask)|r)}};O.BitField=Dn;var _o=class extends Dn{static{a(this,"Boolean")}constructor(e,t){super(e,1,t)}decode(e,t){return!!super.decode(e,t)}encode(e){typeof e=="boolean"&&(e=+e),super.encode(e)}};O.Boolean=_o;var bo=class extends ge{static{a(this,"Blob")}constructor(e,t){if(!(e instanceof Ve&&e.isCount()||Number.isInteger(e)&&0<=e))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let r=-1;e instanceof Ve||(r=e),super(r,t),this.length=e}getSpan(e,t){let r=this.span;return 0>r&&(r=this.length.decode(e,t)),r}decode(e,t=0){let r=this.span;return 0>r&&(r=this.length.decode(e,t)),pe(e).slice(t,t+r)}encode(e,t,r){let o=this.length;if(this.length instanceof Ve&&(o=e.length),!(e instanceof Uint8Array&&o===e.length))throw new TypeError(_a("Blob.encode",this)+" requires (length "+o+") Uint8Array as src");if(r+o>t.length)throw new RangeError("encoding overruns Uint8Array");let s=pe(e);return pe(t).write(s.toString("hex"),r,o,"hex"),this.length instanceof Ve&&this.length.encode(o,t,r),o}};O.Blob=bo;var wo=class extends ge{static{a(this,"CString")}constructor(e){super(-1,e)}getSpan(e,t=0){Zr(e);let r=t;for(;r<e.length&&e[r]!==0;)r+=1;return 1+r-t}decode(e,t=0){let r=this.getSpan(e,t);return pe(e).slice(t,t+r-1).toString("utf-8")}encode(e,t,r=0){typeof e!="string"&&(e=String(e));let o=ga.Buffer.from(e,"utf8"),s=o.length;if(r+s>t.length)throw new RangeError("encoding overruns Buffer");let i=pe(t);return o.copy(i,r),i[r+s]=0,s+1}};O.CString=wo;var Ro=class extends ge{static{a(this,"UTF8")}constructor(e,t){if(typeof e=="string"&&t===void 0&&(t=e,e=void 0),e===void 0)e=-1;else if(!Number.isInteger(e))throw new TypeError("maxSpan must be an integer");super(-1,t),this.maxSpan=e}getSpan(e,t=0){return Zr(e),e.length-t}decode(e,t=0){let r=this.getSpan(e,t);if(0<=this.maxSpan&&this.maxSpan<r)throw new RangeError("text length exceeds maxSpan");return pe(e).slice(t,t+r).toString("utf-8")}encode(e,t,r=0){typeof e!="string"&&(e=String(e));let o=ga.Buffer.from(e,"utf8"),s=o.length;if(0<=this.maxSpan&&this.maxSpan<s)throw new RangeError("text length exceeds maxSpan");if(r+s>t.length)throw new RangeError("encoding overruns Buffer");return o.copy(pe(t),r),s}};O.UTF8=Ro;var Eo=class extends ge{static{a(this,"Constant")}constructor(e,t){super(0,t),this.value=e}decode(e,t){return this.value}encode(e,t,r){return 0}};O.Constant=Eo;O.greedy=(n,e)=>new oo(n,e);O.offset=(n,e,t)=>new Ln(n,e,t);O.u8=n=>new tt(1,n);O.u16=n=>new tt(2,n);O.u24=n=>new tt(3,n);O.u32=n=>new tt(4,n);O.u40=n=>new tt(5,n);O.u48=n=>new tt(6,n);O.nu64=n=>new io(n);O.u16be=n=>new ct(2,n);O.u24be=n=>new ct(3,n);O.u32be=n=>new ct(4,n);O.u40be=n=>new ct(5,n);O.u48be=n=>new ct(6,n);O.nu64be=n=>new ao(n);O.s8=n=>new Wt(1,n);O.s16=n=>new Wt(2,n);O.s24=n=>new Wt(3,n);O.s32=n=>new Wt(4,n);O.s40=n=>new Wt(5,n);O.s48=n=>new Wt(6,n);O.ns64=n=>new co(n);O.s16be=n=>new sr(2,n);O.s24be=n=>new sr(3,n);O.s32be=n=>new sr(4,n);O.s40be=n=>new sr(5,n);O.s48be=n=>new sr(6,n);O.ns64be=n=>new uo(n);O.f32=n=>new lo(n);O.f32be=n=>new fo(n);O.f64=n=>new ho(n);O.f64be=n=>new po(n);O.struct=(n,e,t)=>new mo(n,e,t);O.bits=(n,e,t)=>new Un(n,e,t);O.seq=(n,e,t)=>new yo(n,e,t);O.union=(n,e,t)=>new Bn(n,e,t);O.unionLayoutDiscriminator=(n,e)=>new Jr(n,e);O.blob=(n,e)=>new bo(n,e);O.cstr=n=>new wo(n);O.utf8=(n,e)=>new Ro(n,e);O.constant=(n,e)=>new Eo(n,e)});var Fl=ce((fE,zl)=>{"use strict";var ko=ae("path").sep||"/";zl.exports=tg;function tg(n){if(typeof n!="string"||n.length<=7||n.substring(0,7)!="file://")throw new TypeError("must pass in a file:// URI to convert to a file path");var e=decodeURI(n.substring(7)),t=e.indexOf("/"),r=e.substring(0,t),o=e.substring(t+1);return r=="localhost"&&(r=""),r&&(r=ko+ko+r),o=o.replace(/^(.+)\|/,"$1:"),ko=="\\"&&(o=o.replace(/\//g,"\\")),/^.+\:/.test(o)||(o=ko+o),r+o}a(tg,"fileUriToPath")});var jl=ce((Qr,ql)=>{"use strict";var wa=ae("fs"),vo=ae("path"),rg=Fl(),Io=vo.join,ng=vo.dirname,Wl=wa.accessSync&&function(n){try{wa.accessSync(n)}catch{return!1}return!0}||wa.existsSync||vo.existsSync,Kl={arrow:process.env.NODE_BINDINGS_ARROW||" \u2192 ",compiled:process.env.NODE_BINDINGS_COMPILED_DIR||"compiled",platform:process.platform,arch:process.arch,nodePreGyp:"node-v"+process.versions.modules+"-"+process.platform+"-"+process.arch,version:process.versions.node,bindings:"bindings.node",try:[["module_root","build","bindings"],["module_root","build","Debug","bindings"],["module_root","build","Release","bindings"],["module_root","out","Debug","bindings"],["module_root","Debug","bindings"],["module_root","out","Release","bindings"],["module_root","Release","bindings"],["module_root","build","default","bindings"],["module_root","compiled","version","platform","arch","bindings"],["module_root","addon-build","release","install-root","bindings"],["module_root","addon-build","debug","install-root","bindings"],["module_root","addon-build","default","install-root","bindings"],["module_root","lib","binding","nodePreGyp","bindings"]]};function sg(n){typeof n=="string"?n={bindings:n}:n||(n={}),Object.keys(Kl).map(function(f){f in n||(n[f]=Kl[f])}),n.module_root||(n.module_root=Qr.getRoot(Qr.getFileName())),vo.extname(n.bindings)!=".node"&&(n.bindings+=".node");for(var e=typeof __webpack_require__=="function"?__non_webpack_require__:ae,t=[],r=0,o=n.try.length,s,i,u;r<o;r++){s=Io.apply(null,n.try[r].map(function(f){return n[f]||f})),t.push(s);try{return i=n.path?e.resolve(s):e(s),n.path||(i.path=s),i}catch(f){if(f.code!=="MODULE_NOT_FOUND"&&f.code!=="QUALIFIED_PATH_RESOLUTION_FAILED"&&!/not find/i.test(f.message))throw f}}throw u=new Error(`Could not locate the bindings file. Tried:
|
3
|
+
`+t.map(function(f){return n.arrow+f}).join(`
|
4
|
+
`)),u.tries=t,u}a(sg,"bindings");ql.exports=Qr=sg;Qr.getFileName=a(function(e){var t=Error.prepareStackTrace,r=Error.stackTraceLimit,o={},s;Error.stackTraceLimit=10,Error.prepareStackTrace=function(u,f){for(var y=0,d=f.length;y<d;y++)if(s=f[y].getFileName(),s!==__filename)if(e){if(s!==e)return}else return},Error.captureStackTrace(o),o.stack,Error.prepareStackTrace=t,Error.stackTraceLimit=r;var i="file://";return s.indexOf(i)===0&&(s=rg(s)),s},"getFileName");Qr.getRoot=a(function(e){for(var t=ng(e),r;;){if(t==="."&&(t=process.cwd()),Wl(Io(t,"package.json"))||Wl(Io(t,"node_modules")))return t;if(r===t)throw new Error('Could not find module root given file: "'+e+'". Do you have a `package.json` file? ');r=t,t=Io(t,"..")}},"getRoot")});var Vl=ce(en=>{"use strict";Object.defineProperty(en,"__esModule",{value:!0});var Kt;try{Kt=jl()("bigint_buffer")}catch{console.warn("bigint: Failed to load bindings, pure JS will be used (try npm run rebuild?)")}function og(n){if(Kt===void 0){let e=Buffer.from(n);e.reverse();let t=e.toString("hex");return t.length===0?BigInt(0):BigInt(`0x${t}`)}return Kt.toBigInt(n,!1)}a(og,"toBigIntLE");en.toBigIntLE=og;function ig(n){if(Kt===void 0){let e=n.toString("hex");return e.length===0?BigInt(0):BigInt(`0x${e}`)}return Kt.toBigInt(n,!0)}a(ig,"toBigIntBE");en.toBigIntBE=ig;function ag(n,e){if(Kt===void 0){let t=n.toString(16),r=Buffer.from(t.padStart(e*2,"0").slice(0,e*2),"hex");return r.reverse(),r}return Kt.fromBigInt(n,Buffer.allocUnsafe(e),!1)}a(ag,"toBufferLE");en.toBufferLE=ag;function cg(n,e){if(Kt===void 0){let t=n.toString(16);return Buffer.from(t.padStart(e*2,"0").slice(0,e*2),"hex")}return Kt.fromBigInt(n,Buffer.allocUnsafe(e),!0)}a(cg,"toBufferBE");en.toBufferBE=cg});function ug(n){return Mn(n)&&typeof n[Symbol.iterator]=="function"}function Mn(n){return typeof n=="object"&&n!=null}function To(n){return Mn(n)&&!Array.isArray(n)}function At(n){return typeof n=="symbol"?n.toString():typeof n=="string"?JSON.stringify(n):`${n}`}function lg(n){let{done:e,value:t}=n.next();return e?void 0:t}function fg(n,e,t,r){if(n===!0)return;n===!1?n={}:typeof n=="string"&&(n={message:n});let{path:o,branch:s}=e,{type:i}=t,{refinement:u,message:f=`Expected a value of type \`${i}\`${u?` with refinement \`${u}\``:""}, but received: \`${At(r)}\``}=n;return{value:r,type:i,refinement:u,key:o[o.length-1],path:o,branch:s,...n,message:f}}function*Gl(n,e,t,r){ug(n)||(n=[n]);for(let o of n){let s=fg(o,e,t,r);s&&(yield s)}}function*Ea(n,e,t={}){let{path:r=[],branch:o=[n],coerce:s=!1,mask:i=!1}=t,u={path:r,branch:o,mask:i};s&&(n=e.coercer(n,u));let f="valid";for(let y of e.validator(n,u))y.explanation=t.message,f="not_valid",yield[y,void 0];for(let[y,d,_]of e.entries(n,u)){let E=Ea(d,_,{path:y===void 0?r:[...r,y],branch:y===void 0?o:[...o,d],coerce:s,mask:i,message:t.message});for(let R of E)R[0]?(f=R[0].refinement!=null?"not_refined":"not_valid",yield[R[0],void 0]):s&&(d=R[1],y===void 0?n=d:n instanceof Map?n.set(y,d):n instanceof Set?n.add(d):Mn(n)&&(d!==void 0||y in n)&&(n[y]=d))}if(f!=="not_valid")for(let y of e.refiner(n,u))y.explanation=t.message,f="not_refined",yield[y,void 0];f==="valid"&&(yield[void 0,n])}function Sa(n,e,t){let r=$n(n,e,{message:t});if(r[0])throw r[0]}function H(n,e,t){let r=$n(n,e,{coerce:!0,message:t});if(r[0])throw r[0];return r[1]}function dg(n,e,t){let r=$n(n,e,{coerce:!0,mask:!0,message:t});if(r[0])throw r[0];return r[1]}function Yl(n,e){return!$n(n,e)[0]}function $n(n,e,t={}){let r=Ea(n,e,t),o=lg(r);return o[0]?[new Ra(o[0],function*(){for(let i of r)i[0]&&(yield i[0])}),void 0]:[void 0,o[1]]}function vr(n,e){return new mt({type:n,schema:null,validator:e})}function Xl(){return vr("any",()=>!0)}function W(n){return new mt({type:"array",schema:n,*entries(e){if(n&&Array.isArray(e))for(let[t,r]of e.entries())yield[t,r,n]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||`Expected an array value, but received: ${At(e)}`}})}function kt(){return vr("boolean",n=>typeof n=="boolean")}function Oo(n){return vr("instance",e=>e instanceof n||`Expected a \`${n.name}\` instance, but received: ${At(e)}`)}function Te(n){let e=At(n),t=typeof n;return new mt({type:"literal",schema:t==="string"||t==="number"||t==="boolean"?n:null,validator(r){return r===n||`Expected the literal \`${e}\`, but received: ${At(r)}`}})}function hg(){return vr("never",()=>!1)}function K(n){return new mt({...n,validator:a((e,t)=>e===null||n.validator(e,t),"validator"),refiner:a((e,t)=>e===null||n.refiner(e,t),"refiner")})}function k(){return vr("number",n=>typeof n=="number"&&!isNaN(n)||`Expected a number, but received: ${At(n)}`)}function Z(n){return new mt({...n,validator:a((e,t)=>e===void 0||n.validator(e,t),"validator"),refiner:a((e,t)=>e===void 0||n.refiner(e,t),"refiner")})}function Aa(n,e){return new mt({type:"record",schema:null,*entries(t){if(Mn(t))for(let r in t){let o=t[r];yield[r,r,n],yield[r,o,e]}},validator(t){return To(t)||`Expected an object, but received: ${At(t)}`},coercer(t){return To(t)?{...t}:t}})}function $(){return vr("string",n=>typeof n=="string"||`Expected a string, but received: ${At(n)}`)}function No(n){let e=hg();return new mt({type:"tuple",schema:null,*entries(t){if(Array.isArray(t)){let r=Math.max(n.length,t.length);for(let o=0;o<r;o++)yield[o,t[o],n[o]||e]}},validator(t){return Array.isArray(t)||`Expected an array, but received: ${At(t)}`},coercer(t){return Array.isArray(t)?t.slice():t}})}function B(n){let e=Object.keys(n);return new mt({type:"type",schema:n,*entries(t){if(Mn(t))for(let r of e)yield[r,t[r],n[r]]},validator(t){return To(t)||`Expected an object, but received: ${At(t)}`},coercer(t){return To(t)?{...t}:t}})}function Ge(n){let e=n.map(t=>t.type).join(" | ");return new mt({type:"union",schema:null,coercer(t,r){for(let o of n){let[s,i]=o.validate(t,{coerce:!0,mask:r.mask});if(!s)return i}return t},validator(t,r){let o=[];for(let s of n){let[...i]=Ea(t,s,r),[u]=i;if(u[0])for(let[f]of i)f&&o.push(f);else return[]}return[`Expected the value to satisfy a union of \`${e}\`, but received: ${At(t)}`,...o]}})}function Tr(){return vr("unknown",()=>!0)}function tn(n,e,t){return new mt({...n,coercer:a((r,o)=>Yl(r,e)?n.coercer(t(r,o),o):n.coercer(r,o),"coercer")})}var Ra,mt,Jl=Pe(()=>{"use strict";Ra=class extends TypeError{static{a(this,"StructError")}constructor(e,t){let r,{message:o,explanation:s,...i}=e,{path:u}=e,f=u.length===0?o:`At path: ${u.join(".")} -- ${o}`;super(s??f),s!=null&&(this.cause=f),Object.assign(this,i),this.name=this.constructor.name,this.failures=()=>r??(r=[e,...t()])}};a(ug,"isIterable");a(Mn,"isObject");a(To,"isNonArrayObject");a(At,"print");a(lg,"shiftIterator");a(fg,"toFailure");a(Gl,"toFailures");a(Ea,"run");mt=class{static{a(this,"Struct")}constructor(e){let{type:t,schema:r,validator:o,refiner:s,coercer:i=a(f=>f,"coercer"),entries:u=a(function*(){},"entries")}=e;this.type=t,this.schema=r,this.entries=u,this.coercer=i,o?this.validator=(f,y)=>{let d=o(f,y);return Gl(d,y,this,f)}:this.validator=()=>[],s?this.refiner=(f,y)=>{let d=s(f,y);return Gl(d,y,this,f)}:this.refiner=()=>[]}assert(e,t){return Sa(e,this,t)}create(e,t){return H(e,this,t)}is(e){return Yl(e,this)}mask(e,t){return dg(e,this,t)}validate(e,t={}){return $n(e,this,t)}};a(Sa,"assert");a(H,"create");a(dg,"mask");a(Yl,"is");a($n,"validate");a(vr,"define");a(Xl,"any");a(W,"array");a(kt,"boolean");a(Oo,"instance");a(Te,"literal");a(hg,"never");a(K,"nullable");a(k,"number");a(Z,"optional");a(Aa,"record");a($,"string");a(No,"tuple");a(B,"type");a(Ge,"union");a(Tr,"unknown");a(tn,"coerce")});import pg from"crypto";function Hn(){return Co>xo.length-16&&(pg.randomFillSync(xo),Co=0),xo.slice(Co,Co+=16)}var xo,Co,ka=Pe(()=>{"use strict";xo=new Uint8Array(256),Co=xo.length;a(Hn,"rng")});var Zl,Ql=Pe(()=>{"use strict";Zl=/^(?:[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 yg(n){return typeof n=="string"&&Zl.test(n)}var or,zn=Pe(()=>{"use strict";Ql();a(yg,"validate");or=yg});function mg(n,e=0){let t=(qe[n[e+0]]+qe[n[e+1]]+qe[n[e+2]]+qe[n[e+3]]+"-"+qe[n[e+4]]+qe[n[e+5]]+"-"+qe[n[e+6]]+qe[n[e+7]]+"-"+qe[n[e+8]]+qe[n[e+9]]+"-"+qe[n[e+10]]+qe[n[e+11]]+qe[n[e+12]]+qe[n[e+13]]+qe[n[e+14]]+qe[n[e+15]]).toLowerCase();if(!or(t))throw TypeError("Stringified UUID is invalid");return t}var qe,ir,Fn=Pe(()=>{"use strict";zn();qe=[];for(let n=0;n<256;++n)qe.push((n+256).toString(16).substr(1));a(mg,"stringify");ir=mg});function gg(n,e,t){let r=e&&t||0,o=e||new Array(16);n=n||{};let s=n.node||ef,i=n.clockseq!==void 0?n.clockseq:Ia;if(s==null||i==null){let E=n.random||(n.rng||Hn)();s==null&&(s=ef=[E[0]|1,E[1],E[2],E[3],E[4],E[5]]),i==null&&(i=Ia=(E[6]<<8|E[7])&16383)}let u=n.msecs!==void 0?n.msecs:Date.now(),f=n.nsecs!==void 0?n.nsecs:Ta+1,y=u-va+(f-Ta)/1e4;if(y<0&&n.clockseq===void 0&&(i=i+1&16383),(y<0||u>va)&&n.nsecs===void 0&&(f=0),f>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");va=u,Ta=f,Ia=i,u+=122192928e5;let d=((u&268435455)*1e4+f)%4294967296;o[r++]=d>>>24&255,o[r++]=d>>>16&255,o[r++]=d>>>8&255,o[r++]=d&255;let _=u/4294967296*1e4&268435455;o[r++]=_>>>8&255,o[r++]=_&255,o[r++]=_>>>24&15|16,o[r++]=_>>>16&255,o[r++]=i>>>8|128,o[r++]=i&255;for(let E=0;E<6;++E)o[r+E]=s[E];return e||ir(o)}var ef,Ia,va,Ta,tf,rf=Pe(()=>{"use strict";ka();Fn();va=0,Ta=0;a(gg,"v1");tf=gg});function _g(n){if(!or(n))throw TypeError("Invalid UUID");let e,t=new Uint8Array(16);return t[0]=(e=parseInt(n.slice(0,8),16))>>>24,t[1]=e>>>16&255,t[2]=e>>>8&255,t[3]=e&255,t[4]=(e=parseInt(n.slice(9,13),16))>>>8,t[5]=e&255,t[6]=(e=parseInt(n.slice(14,18),16))>>>8,t[7]=e&255,t[8]=(e=parseInt(n.slice(19,23),16))>>>8,t[9]=e&255,t[10]=(e=parseInt(n.slice(24,36),16))/1099511627776&255,t[11]=e/4294967296&255,t[12]=e>>>24&255,t[13]=e>>>16&255,t[14]=e>>>8&255,t[15]=e&255,t}var Lo,Oa=Pe(()=>{"use strict";zn();a(_g,"parse");Lo=_g});function bg(n){n=unescape(encodeURIComponent(n));let e=[];for(let t=0;t<n.length;++t)e.push(n.charCodeAt(t));return e}function Wn(n,e,t){function r(o,s,i,u){if(typeof o=="string"&&(o=bg(o)),typeof s=="string"&&(s=Lo(s)),s.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let f=new Uint8Array(16+o.length);if(f.set(s),f.set(o,s.length),f=t(f),f[6]=f[6]&15|e,f[8]=f[8]&63|128,i){u=u||0;for(let y=0;y<16;++y)i[u+y]=f[y];return i}return ir(f)}a(r,"generateUUID");try{r.name=n}catch{}return r.DNS=wg,r.URL=Rg,r}var wg,Rg,Na=Pe(()=>{"use strict";Fn();Oa();a(bg,"stringToBytes");wg="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Rg="6ba7b811-9dad-11d1-80b4-00c04fd430c8";a(Wn,"default")});import Eg from"crypto";function Sg(n){return Array.isArray(n)?n=Buffer.from(n):typeof n=="string"&&(n=Buffer.from(n,"utf8")),Eg.createHash("md5").update(n).digest()}var nf,sf=Pe(()=>{"use strict";a(Sg,"md5");nf=Sg});var Ag,of,af=Pe(()=>{"use strict";Na();sf();Ag=Wn("v3",48,nf),of=Ag});function kg(n,e,t){n=n||{};let r=n.random||(n.rng||Hn)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,e){t=t||0;for(let o=0;o<16;++o)e[t+o]=r[o];return e}return ir(r)}var cf,uf=Pe(()=>{"use strict";ka();Fn();a(kg,"v4");cf=kg});import Ig from"crypto";function vg(n){return Array.isArray(n)?n=Buffer.from(n):typeof n=="string"&&(n=Buffer.from(n,"utf8")),Ig.createHash("sha1").update(n).digest()}var lf,ff=Pe(()=>{"use strict";a(vg,"sha1");lf=vg});var Tg,df,hf=Pe(()=>{"use strict";Na();ff();Tg=Wn("v5",80,lf),df=Tg});var pf,yf=Pe(()=>{"use strict";pf="00000000-0000-0000-0000-000000000000"});function Og(n){if(!or(n))throw TypeError("Invalid UUID");return parseInt(n.substr(14,1),16)}var mf,gf=Pe(()=>{"use strict";zn();a(Og,"version");mf=Og});var Ca={};Cn(Ca,{NIL:()=>pf,parse:()=>Lo,stringify:()=>ir,v1:()=>tf,v3:()=>of,v4:()=>cf,v5:()=>df,validate:()=>or,version:()=>mf});var xa=Pe(()=>{"use strict";rf();af();uf();hf();yf();gf();zn();Fn();Oa()});var bf=ce((pS,_f)=>{"use strict";var Ng=(xa(),xn(Ca)).v4,Cg=a(function(n,e,t,r){if(typeof n!="string")throw new TypeError(n+" must be a string");r=r||{};let o=typeof r.version=="number"?r.version:2;if(o!==1&&o!==2)throw new TypeError(o+" must be 1 or 2");let s={method:n};if(o===2&&(s.jsonrpc="2.0"),e){if(typeof e!="object"&&!Array.isArray(e))throw new TypeError(e+" must be an object, array or omitted");s.params=e}if(typeof t>"u"){let i=typeof r.generator=="function"?r.generator:function(){return Ng()};s.id=i(s,r)}else o===2&&t===null?r.notificationIdNull&&(s.id=null):s.id=t;return s},"generateRequest");_f.exports=Cg});var Rf=ce((mS,wf)=>{"use strict";var xg=(xa(),xn(Ca)).v4,Lg=bf(),Kn=a(function(n,e){if(!(this instanceof Kn))return new Kn(n,e);e||(e={}),this.options={reviver:typeof e.reviver<"u"?e.reviver:null,replacer:typeof e.replacer<"u"?e.replacer:null,generator:typeof e.generator<"u"?e.generator:function(){return xg()},version:typeof e.version<"u"?e.version:2,notificationIdNull:typeof e.notificationIdNull=="boolean"?e.notificationIdNull:!1},this.callServer=n},"ClientBrowser");wf.exports=Kn;Kn.prototype.request=function(n,e,t,r){let o=this,s=null,i=Array.isArray(n)&&typeof e=="function";if(this.options.version===1&&i)throw new TypeError("JSON-RPC 1.0 does not support batching");if(i||!i&&n&&typeof n=="object"&&typeof e=="function")r=e,s=n;else{typeof t=="function"&&(r=t,t=void 0);let y=typeof r=="function";try{s=Lg(n,e,t,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(d){if(y)return r(d);throw d}if(!y)return s}let f;try{f=JSON.stringify(s,this.options.replacer)}catch(y){return r(y)}return this.callServer(f,function(y,d){o._parseResponse(y,d,r)}),s};Kn.prototype._parseResponse=function(n,e,t){if(n){t(n);return}if(!e)return t();let r;try{r=JSON.parse(e,this.options.reviver)}catch(o){return t(o)}if(t.length===3)if(Array.isArray(r)){let o=a(function(i){return typeof i.error<"u"},"isError"),s=a(function(i){return!o(i)},"isNotError");return t(null,r.filter(o),r.filter(s))}else return t(null,r.error,r.result);t(null,r)}});var kf=ce((_S,Af)=>{"use strict";var{Duplex:Pg}=ae("stream");function Ef(n){n.emit("close")}a(Ef,"emitClose");function Bg(){!this.destroyed&&this._writableState.finished&&this.destroy()}a(Bg,"duplexOnEnd");function Sf(n){this.removeListener("error",Sf),this.destroy(),this.listenerCount("error")===0&&this.emit("error",n)}a(Sf,"duplexOnError");function Ug(n,e){let t=!0,r=new Pg({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return n.on("message",a(function(s,i){let u=!i&&r._readableState.objectMode?s.toString():s;r.push(u)||n.pause()},"message")),n.once("error",a(function(s){r.destroyed||(t=!1,r.destroy(s))},"error")),n.once("close",a(function(){r.destroyed||r.push(null)},"close")),r._destroy=function(o,s){if(n.readyState===n.CLOSED){s(o),process.nextTick(Ef,r);return}let i=!1;n.once("error",a(function(f){i=!0,s(f)},"error")),n.once("close",a(function(){i||s(o),process.nextTick(Ef,r)},"close")),t&&n.terminate()},r._final=function(o){if(n.readyState===n.CONNECTING){n.once("open",a(function(){r._final(o)},"open"));return}n._socket!==null&&(n._socket._writableState.finished?(o(),r._readableState.endEmitted&&r.destroy()):(n._socket.once("finish",a(function(){o()},"finish")),n.close()))},r._read=function(){n.isPaused&&n.resume()},r._write=function(o,s,i){if(n.readyState===n.CONNECTING){n.once("open",a(function(){r._write(o,s,i)},"open"));return}n.send(o,i)},r.on("end",Bg),r.on("error",Sf),r}a(Ug,"createWebSocketStream");Af.exports=Ug});var ar=ce((wS,If)=>{"use strict";If.exports={BINARY_TYPES:["nodebuffer","arraybuffer","fragments"],EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:a(()=>{},"NOOP")}});var Ff=ce((ES,zf)=>{"use strict";var Nf=ae("fs"),qt=ae("path"),Cf=ae("os"),xf=typeof __webpack_require__=="function"?__non_webpack_require__:ae,Dg=process.config&&process.config.variables||{},Mg=!!process.env.PREBUILDS_ONLY,vf=process.versions.modules,La=zg()?"electron":Hg()?"node-webkit":"node",Pa=process.env.npm_config_arch||Cf.arch(),Ba=process.env.npm_config_platform||Cf.platform(),Lf=process.env.LIBC||(Fg(Ba)?"musl":"glibc"),Ua=process.env.ARM_VERSION||(Pa==="arm64"?"8":Dg.arm_version)||"",Pf=(process.versions.uv||"").split(".")[0];zf.exports=xt;function xt(n){return xf(xt.resolve(n))}a(xt,"load");xt.resolve=xt.path=function(n){n=qt.resolve(n||".");try{var e=xf(qt.join(n,"package.json")).name.toUpperCase().replace(/-/g,"_");process.env[e+"_PREBUILD"]&&(n=process.env[e+"_PREBUILD"])}catch{}if(!Mg){var t=Tf(qt.join(n,"build/Release"),Of);if(t)return t;var r=Tf(qt.join(n,"build/Debug"),Of);if(r)return r}var o=u(n);if(o)return o;var s=u(qt.dirname(process.execPath));if(s)return s;var i=["platform="+Ba,"arch="+Pa,"runtime="+La,"abi="+vf,"uv="+Pf,Ua?"armv="+Ua:"","libc="+Lf,"node="+process.versions.node,process.versions.electron?"electron="+process.versions.electron:"",typeof __webpack_require__=="function"?"webpack=true":""].filter(Boolean).join(" ");throw new Error("No native build was found for "+i+`
|
5
|
+
loaded from: `+n+`
|
6
|
+
`);function u(f){var y=Da(qt.join(f,"prebuilds")).map(Bf),d=y.filter(Uf(Ba,Pa)).sort(Df)[0];if(d){var _=qt.join(f,"prebuilds",d.name),E=Da(_).map(Mf),R=E.filter($f(La,vf)),S=R.sort(Hf(La))[0];if(S)return qt.join(_,S.file)}}};function Da(n){try{return Nf.readdirSync(n)}catch{return[]}}a(Da,"readdirSync");function Tf(n,e){var t=Da(n).filter(e);return t[0]&&qt.join(n,t[0])}a(Tf,"getFirst");function Of(n){return/\.node$/.test(n)}a(Of,"matchBuild");function Bf(n){var e=n.split("-");if(e.length===2){var t=e[0],r=e[1].split("+");if(t&&r.length&&r.every(Boolean))return{name:n,platform:t,architectures:r}}}a(Bf,"parseTuple");function Uf(n,e){return function(t){return t==null||t.platform!==n?!1:t.architectures.includes(e)}}a(Uf,"matchTuple");function Df(n,e){return n.architectures.length-e.architectures.length}a(Df,"compareTuples");function Mf(n){var e=n.split("."),t=e.pop(),r={file:n,specificity:0};if(t==="node"){for(var o=0;o<e.length;o++){var s=e[o];if(s==="node"||s==="electron"||s==="node-webkit")r.runtime=s;else if(s==="napi")r.napi=!0;else if(s.slice(0,3)==="abi")r.abi=s.slice(3);else if(s.slice(0,2)==="uv")r.uv=s.slice(2);else if(s.slice(0,4)==="armv")r.armv=s.slice(4);else if(s==="glibc"||s==="musl")r.libc=s;else continue;r.specificity++}return r}}a(Mf,"parseTags");function $f(n,e){return function(t){return!(t==null||t.runtime&&t.runtime!==n&&!$g(t)||t.abi&&t.abi!==e&&!t.napi||t.uv&&t.uv!==Pf||t.armv&&t.armv!==Ua||t.libc&&t.libc!==Lf)}}a($f,"matchTags");function $g(n){return n.runtime==="node"&&n.napi}a($g,"runtimeAgnostic");function Hf(n){return function(e,t){return e.runtime!==t.runtime?e.runtime===n?-1:1:e.abi!==t.abi?e.abi?-1:1:e.specificity!==t.specificity?e.specificity>t.specificity?-1:1:0}}a(Hf,"compareTags");function Hg(){return!!(process.versions&&process.versions.nw)}a(Hg,"isNwjs");function zg(){return process.versions&&process.versions.electron||process.env.ELECTRON_RUN_AS_NODE?!0:typeof window<"u"&&window.process&&window.process.type==="renderer"}a(zg,"isElectron");function Fg(n){return n==="linux"&&Nf.existsSync("/etc/alpine-release")}a(Fg,"isAlpine");xt.parseTags=Mf;xt.matchTags=$f;xt.compareTags=Hf;xt.parseTuple=Bf;xt.matchTuple=Uf;xt.compareTuples=Df});var Ha=ce((AS,$a)=>{"use strict";var Ma=typeof __webpack_require__=="function"?__non_webpack_require__:ae;typeof Ma.addon=="function"?$a.exports=Ma.addon.bind(Ma):$a.exports=Ff()});var Kf=ce((IS,Wf)=>{"use strict";var Wg=a((n,e,t,r,o)=>{for(var s=0;s<o;s++)t[r+s]=n[s]^e[s&3]},"mask"),Kg=a((n,e)=>{let t=n.length;for(var r=0;r<t;r++)n[r]^=e[r&3]},"unmask");Wf.exports={mask:Wg,unmask:Kg}});var qf=ce((TS,za)=>{"use strict";try{za.exports=Ha()(__dirname)}catch{za.exports=Kf()}});var qn=ce((OS,Po)=>{"use strict";var{EMPTY_BUFFER:qg}=ar(),Fa=Buffer[Symbol.species];function jg(n,e){if(n.length===0)return qg;if(n.length===1)return n[0];let t=Buffer.allocUnsafe(e),r=0;for(let o=0;o<n.length;o++){let s=n[o];t.set(s,r),r+=s.length}return r<e?new Fa(t.buffer,t.byteOffset,r):t}a(jg,"concat");function jf(n,e,t,r,o){for(let s=0;s<o;s++)t[r+s]=n[s]^e[s&3]}a(jf,"_mask");function Vf(n,e){for(let t=0;t<n.length;t++)n[t]^=e[t&3]}a(Vf,"_unmask");function Vg(n){return n.length===n.buffer.byteLength?n.buffer:n.buffer.slice(n.byteOffset,n.byteOffset+n.length)}a(Vg,"toArrayBuffer");function Wa(n){if(Wa.readOnly=!0,Buffer.isBuffer(n))return n;let e;return n instanceof ArrayBuffer?e=new Fa(n):ArrayBuffer.isView(n)?e=new Fa(n.buffer,n.byteOffset,n.byteLength):(e=Buffer.from(n),Wa.readOnly=!1),e}a(Wa,"toBuffer");Po.exports={concat:jg,mask:jf,toArrayBuffer:Vg,toBuffer:Wa,unmask:Vf};if(!process.env.WS_NO_BUFFER_UTIL)try{let n=qf();Po.exports.mask=function(e,t,r,o,s){s<48?jf(e,t,r,o,s):n.mask(e,t,r,o,s)},Po.exports.unmask=function(e,t){e.length<32?Vf(e,t):n.unmask(e,t)}}catch{}});var Xf=ce((CS,Yf)=>{"use strict";var Gf=Symbol("kDone"),Ka=Symbol("kRun"),qa=class{static{a(this,"Limiter")}constructor(e){this[Gf]=()=>{this.pending--,this[Ka]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Ka]()}[Ka](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[Gf])}}};Yf.exports=qa});var Gn=ce((LS,ed)=>{"use strict";var jn=ae("zlib"),Jf=qn(),Gg=Xf(),{kStatusCode:Zf}=ar(),Yg=Buffer[Symbol.species],Xg=Buffer.from([0,0,255,255]),Do=Symbol("permessage-deflate"),jt=Symbol("total-length"),Vn=Symbol("callback"),cr=Symbol("buffers"),Uo=Symbol("error"),Bo,ja=class{static{a(this,"PerMessageDeflate")}constructor(e,t,r){if(this._maxPayload=r|0,this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!t,this._deflate=null,this._inflate=null,this.params=null,!Bo){let o=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Bo=new Gg(o)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[Vn];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let t=this._options,r=e.find(o=>!(t.serverNoContextTakeover===!1&&o.server_no_context_takeover||o.server_max_window_bits&&(t.serverMaxWindowBits===!1||typeof t.serverMaxWindowBits=="number"&&t.serverMaxWindowBits>o.server_max_window_bits)||typeof t.clientMaxWindowBits=="number"&&!o.client_max_window_bits));if(!r)throw new Error("None of the extension offers can be accepted");return t.serverNoContextTakeover&&(r.server_no_context_takeover=!0),t.clientNoContextTakeover&&(r.client_no_context_takeover=!0),typeof t.serverMaxWindowBits=="number"&&(r.server_max_window_bits=t.serverMaxWindowBits),typeof t.clientMaxWindowBits=="number"?r.client_max_window_bits=t.clientMaxWindowBits:(r.client_max_window_bits===!0||t.clientMaxWindowBits===!1)&&delete r.client_max_window_bits,r}acceptAsClient(e){let t=e[0];if(this._options.clientNoContextTakeover===!1&&t.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!t.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(t.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return t}normalizeParams(e){return e.forEach(t=>{Object.keys(t).forEach(r=>{let o=t[r];if(o.length>1)throw new Error(`Parameter "${r}" must have only a single value`);if(o=o[0],r==="client_max_window_bits"){if(o!==!0){let s=+o;if(!Number.isInteger(s)||s<8||s>15)throw new TypeError(`Invalid value for parameter "${r}": ${o}`);o=s}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${r}": ${o}`)}else if(r==="server_max_window_bits"){let s=+o;if(!Number.isInteger(s)||s<8||s>15)throw new TypeError(`Invalid value for parameter "${r}": ${o}`);o=s}else if(r==="client_no_context_takeover"||r==="server_no_context_takeover"){if(o!==!0)throw new TypeError(`Invalid value for parameter "${r}": ${o}`)}else throw new Error(`Unknown parameter "${r}"`);t[r]=o})}),e}decompress(e,t,r){Bo.add(o=>{this._decompress(e,t,(s,i)=>{o(),r(s,i)})})}compress(e,t,r){Bo.add(o=>{this._compress(e,t,(s,i)=>{o(),r(s,i)})})}_decompress(e,t,r){let o=this._isServer?"client":"server";if(!this._inflate){let s=`${o}_max_window_bits`,i=typeof this.params[s]!="number"?jn.Z_DEFAULT_WINDOWBITS:this.params[s];this._inflate=jn.createInflateRaw({...this._options.zlibInflateOptions,windowBits:i}),this._inflate[Do]=this,this._inflate[jt]=0,this._inflate[cr]=[],this._inflate.on("error",Zg),this._inflate.on("data",Qf)}this._inflate[Vn]=r,this._inflate.write(e),t&&this._inflate.write(Xg),this._inflate.flush(()=>{let s=this._inflate[Uo];if(s){this._inflate.close(),this._inflate=null,r(s);return}let i=Jf.concat(this._inflate[cr],this._inflate[jt]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[jt]=0,this._inflate[cr]=[],t&&this.params[`${o}_no_context_takeover`]&&this._inflate.reset()),r(null,i)})}_compress(e,t,r){let o=this._isServer?"server":"client";if(!this._deflate){let s=`${o}_max_window_bits`,i=typeof this.params[s]!="number"?jn.Z_DEFAULT_WINDOWBITS:this.params[s];this._deflate=jn.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:i}),this._deflate[jt]=0,this._deflate[cr]=[],this._deflate.on("data",Jg)}this._deflate[Vn]=r,this._deflate.write(e),this._deflate.flush(jn.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let s=Jf.concat(this._deflate[cr],this._deflate[jt]);t&&(s=new Yg(s.buffer,s.byteOffset,s.length-4)),this._deflate[Vn]=null,this._deflate[jt]=0,this._deflate[cr]=[],t&&this.params[`${o}_no_context_takeover`]&&this._deflate.reset(),r(null,s)})}};ed.exports=ja;function Jg(n){this[cr].push(n),this[jt]+=n.length}a(Jg,"deflateOnData");function Qf(n){if(this[jt]+=n.length,this[Do]._maxPayload<1||this[jt]<=this[Do]._maxPayload){this[cr].push(n);return}this[Uo]=new RangeError("Max payload size exceeded"),this[Uo].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Uo][Zf]=1009,this.removeListener("data",Qf),this.reset()}a(Qf,"inflateOnData");function Zg(n){this[Do]._inflate=null,n[Zf]=1007,this[Vn](n)}a(Zg,"inflateOnError")});var rd=ce((BS,td)=>{"use strict";function Qg(n){let e=n.length,t=0;for(;t<e;)if(!(n[t]&128))t++;else if((n[t]&224)===192){if(t+1===e||(n[t+1]&192)!==128||(n[t]&254)===192)return!1;t+=2}else if((n[t]&240)===224){if(t+2>=e||(n[t+1]&192)!==128||(n[t+2]&192)!==128||n[t]===224&&(n[t+1]&224)===128||n[t]===237&&(n[t+1]&224)===160)return!1;t+=3}else if((n[t]&248)===240){if(t+3>=e||(n[t+1]&192)!==128||(n[t+2]&192)!==128||(n[t+3]&192)!==128||n[t]===240&&(n[t+1]&240)===128||n[t]===244&&n[t+1]>143||n[t]>244)return!1;t+=4}else return!1;return!0}a(Qg,"isValidUTF8");td.exports=Qg});var nd=ce((DS,Va)=>{"use strict";try{Va.exports=Ha()(__dirname)}catch{Va.exports=rd()}});var Yn=ce((MS,Mo)=>{"use strict";var{isUtf8:sd}=ae("buffer"),e_=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function t_(n){return n>=1e3&&n<=1014&&n!==1004&&n!==1005&&n!==1006||n>=3e3&&n<=4999}a(t_,"isValidStatusCode");function Ga(n){let e=n.length,t=0;for(;t<e;)if(!(n[t]&128))t++;else if((n[t]&224)===192){if(t+1===e||(n[t+1]&192)!==128||(n[t]&254)===192)return!1;t+=2}else if((n[t]&240)===224){if(t+2>=e||(n[t+1]&192)!==128||(n[t+2]&192)!==128||n[t]===224&&(n[t+1]&224)===128||n[t]===237&&(n[t+1]&224)===160)return!1;t+=3}else if((n[t]&248)===240){if(t+3>=e||(n[t+1]&192)!==128||(n[t+2]&192)!==128||(n[t+3]&192)!==128||n[t]===240&&(n[t+1]&240)===128||n[t]===244&&n[t+1]>143||n[t]>244)return!1;t+=4}else return!1;return!0}a(Ga,"_isValidUTF8");Mo.exports={isValidStatusCode:t_,isValidUTF8:Ga,tokenChars:e_};if(sd)Mo.exports.isValidUTF8=function(n){return n.length<24?Ga(n):sd(n)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let n=nd();Mo.exports.isValidUTF8=function(e){return e.length<32?Ga(e):n(e)}}catch{}});var Qa=ce((HS,fd)=>{"use strict";var{Writable:r_}=ae("stream"),od=Gn(),{BINARY_TYPES:n_,EMPTY_BUFFER:id,kStatusCode:s_,kWebSocket:o_}=ar(),{concat:Ya,toArrayBuffer:i_,unmask:a_}=qn(),{isValidStatusCode:c_,isValidUTF8:ad}=Yn(),$o=Buffer[Symbol.species],gt=0,cd=1,ud=2,ld=3,Xa=4,Ja=5,Ho=6,Za=class extends r_{static{a(this,"Receiver")}constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||n_[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[o_]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=gt}_write(e,t,r){if(this._opcode===8&&this._state==gt)return r();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(r)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let r=this._buffers[0];return this._buffers[0]=new $o(r.buffer,r.byteOffset+e,r.length-e),new $o(r.buffer,r.byteOffset,e)}let t=Buffer.allocUnsafe(e);do{let r=this._buffers[0],o=t.length-e;e>=r.length?t.set(this._buffers.shift(),o):(t.set(new Uint8Array(r.buffer,r.byteOffset,e),o),this._buffers[0]=new $o(r.buffer,r.byteOffset+e,r.length-e)),e-=r.length}while(e>0);return t}startLoop(e){this._loop=!0;do switch(this._state){case gt:this.getInfo(e);break;case cd:this.getPayloadLength16(e);break;case ud:this.getPayloadLength64(e);break;case ld:this.getMask();break;case Xa:this.getData(e);break;case Ja:case Ho:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let t=this.consume(2);if(t[0]&48){let o=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(o);return}let r=(t[0]&64)===64;if(r&&!this._extensions[od.extensionName]){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(o);return}if(this._fin=(t[0]&128)===128,this._opcode=t[0]&15,this._payloadLength=t[1]&127,this._opcode===0){if(r){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(o);return}if(!this._fragmented){let o=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(o);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let o=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(o);return}this._compressed=r}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let o=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(o);return}if(r){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(o);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let o=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(o);return}}else{let o=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(o);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(t[1]&128)===128,this._isServer){if(!this._masked){let o=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(o);return}}else if(this._masked){let o=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(o);return}this._payloadLength===126?this._state=cd:this._payloadLength===127?this._state=ud:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let t=this.consume(8),r=t.readUInt32BE(0);if(r>Math.pow(2,21)-1){let o=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(o);return}this._payloadLength=r*Math.pow(2,32)+t.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let t=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(t);return}this._masked?this._state=ld:this._state=Xa}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Xa}getData(e){let t=id;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}t=this.consume(this._payloadLength),this._masked&&this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3]&&a_(t,this._mask)}if(this._opcode>7){this.controlMessage(t,e);return}if(this._compressed){this._state=Ja,this.decompress(t,e);return}t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage(e)}decompress(e,t){this._extensions[od.extensionName].decompress(e,this._fin,(o,s)=>{if(o)return t(o);if(s.length){if(this._messageLength+=s.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let i=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");t(i);return}this._fragments.push(s)}this.dataMessage(t),this._state===gt&&this.startLoop(t)})}dataMessage(e){if(!this._fin){this._state=gt;return}let t=this._messageLength,r=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let o;this._binaryType==="nodebuffer"?o=Ya(r,t):this._binaryType==="arraybuffer"?o=i_(Ya(r,t)):o=r,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=gt):(this._state=Ho,setImmediate(()=>{this.emit("message",o,!0),this._state=gt,this.startLoop(e)}))}else{let o=Ya(r,t);if(!this._skipUTF8Validation&&!ad(o)){let s=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(s);return}this._state===Ja||this._allowSynchronousEvents?(this.emit("message",o,!1),this._state=gt):(this._state=Ho,setImmediate(()=>{this.emit("message",o,!1),this._state=gt,this.startLoop(e)}))}}controlMessage(e,t){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,id),this.end();else{let r=e.readUInt16BE(0);if(!c_(r)){let s=this.createError(RangeError,`invalid status code ${r}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");t(s);return}let o=new $o(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!ad(o)){let s=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");t(s);return}this._loop=!1,this.emit("conclude",r,o),this.end()}this._state=gt;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=gt):(this._state=Ho,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=gt,this.startLoop(t)}))}createError(e,t,r,o,s){this._loop=!1,this._errored=!0;let i=new e(r?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(i,this.createError),i.code=s,i[s_]=o,i}};fd.exports=Za});var tc=ce((WS,pd)=>{"use strict";var{Duplex:FS}=ae("stream"),{randomFillSync:u_}=ae("crypto"),dd=Gn(),{EMPTY_BUFFER:l_}=ar(),{isValidStatusCode:f_}=Yn(),{mask:hd,toBuffer:rn}=qn(),It=Symbol("kByteLength"),d_=Buffer.alloc(4),zo=8*1024,Or,nn=zo,ec=class n{static{a(this,"Sender")}constructor(e,t,r){this._extensions=t||{},r&&(this._generateMask=r,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._deflating=!1,this._queue=[]}static frame(e,t){let r,o=!1,s=2,i=!1;t.mask&&(r=t.maskBuffer||d_,t.generateMask?t.generateMask(r):(nn===zo&&(Or===void 0&&(Or=Buffer.alloc(zo)),u_(Or,0,zo),nn=0),r[0]=Or[nn++],r[1]=Or[nn++],r[2]=Or[nn++],r[3]=Or[nn++]),i=(r[0]|r[1]|r[2]|r[3])===0,s=6);let u;typeof e=="string"?(!t.mask||i)&&t[It]!==void 0?u=t[It]:(e=Buffer.from(e),u=e.length):(u=e.length,o=t.mask&&t.readOnly&&!i);let f=u;u>=65536?(s+=8,f=127):u>125&&(s+=2,f=126);let y=Buffer.allocUnsafe(o?u+s:s);return y[0]=t.fin?t.opcode|128:t.opcode,t.rsv1&&(y[0]|=64),y[1]=f,f===126?y.writeUInt16BE(u,2):f===127&&(y[2]=y[3]=0,y.writeUIntBE(u,4,6)),t.mask?(y[1]|=128,y[s-4]=r[0],y[s-3]=r[1],y[s-2]=r[2],y[s-1]=r[3],i?[y,e]:o?(hd(e,r,y,s,u),[y]):(hd(e,r,e,0,u),[y,e])):[y,e]}close(e,t,r,o){let s;if(e===void 0)s=l_;else{if(typeof e!="number"||!f_(e))throw new TypeError("First argument must be a valid error code number");if(t===void 0||!t.length)s=Buffer.allocUnsafe(2),s.writeUInt16BE(e,0);else{let u=Buffer.byteLength(t);if(u>123)throw new RangeError("The message must not be greater than 123 bytes");s=Buffer.allocUnsafe(2+u),s.writeUInt16BE(e,0),typeof t=="string"?s.write(t,2):s.set(t,2)}}let i={[It]:s.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._deflating?this.enqueue([this.dispatch,s,!1,i,o]):this.sendFrame(n.frame(s,i),o)}ping(e,t,r){let o,s;if(typeof e=="string"?(o=Buffer.byteLength(e),s=!1):(e=rn(e),o=e.length,s=rn.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let i={[It]:o,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:s,rsv1:!1};this._deflating?this.enqueue([this.dispatch,e,!1,i,r]):this.sendFrame(n.frame(e,i),r)}pong(e,t,r){let o,s;if(typeof e=="string"?(o=Buffer.byteLength(e),s=!1):(e=rn(e),o=e.length,s=rn.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let i={[It]:o,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:s,rsv1:!1};this._deflating?this.enqueue([this.dispatch,e,!1,i,r]):this.sendFrame(n.frame(e,i),r)}send(e,t,r){let o=this._extensions[dd.extensionName],s=t.binary?2:1,i=t.compress,u,f;if(typeof e=="string"?(u=Buffer.byteLength(e),f=!1):(e=rn(e),u=e.length,f=rn.readOnly),this._firstFragment?(this._firstFragment=!1,i&&o&&o.params[o._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(i=u>=o._threshold),this._compress=i):(i=!1,s=0),t.fin&&(this._firstFragment=!0),o){let y={[It]:u,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:s,readOnly:f,rsv1:i};this._deflating?this.enqueue([this.dispatch,e,this._compress,y,r]):this.dispatch(e,this._compress,y,r)}else this.sendFrame(n.frame(e,{[It]:u,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:s,readOnly:f,rsv1:!1}),r)}dispatch(e,t,r,o){if(!t){this.sendFrame(n.frame(e,r),o);return}let s=this._extensions[dd.extensionName];this._bufferedBytes+=r[It],this._deflating=!0,s.compress(e,r.fin,(i,u)=>{if(this._socket.destroyed){let f=new Error("The socket was closed while data was being compressed");typeof o=="function"&&o(f);for(let y=0;y<this._queue.length;y++){let d=this._queue[y],_=d[d.length-1];typeof _=="function"&&_(f)}return}this._bufferedBytes-=r[It],this._deflating=!1,r.readOnly=!1,this.sendFrame(n.frame(u,r),o),this.dequeue()})}dequeue(){for(;!this._deflating&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][It],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][It],this._queue.push(e)}sendFrame(e,t){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],t),this._socket.uncork()):this._socket.write(e[0],t)}};pd.exports=ec});var Sd=ce((qS,Ed)=>{"use strict";var{kForOnEventAttribute:Xn,kListener:rc}=ar(),yd=Symbol("kCode"),md=Symbol("kData"),gd=Symbol("kError"),_d=Symbol("kMessage"),bd=Symbol("kReason"),sn=Symbol("kTarget"),wd=Symbol("kType"),Rd=Symbol("kWasClean"),Vt=class{static{a(this,"Event")}constructor(e){this[sn]=null,this[wd]=e}get target(){return this[sn]}get type(){return this[wd]}};Object.defineProperty(Vt.prototype,"target",{enumerable:!0});Object.defineProperty(Vt.prototype,"type",{enumerable:!0});var Nr=class extends Vt{static{a(this,"CloseEvent")}constructor(e,t={}){super(e),this[yd]=t.code===void 0?0:t.code,this[bd]=t.reason===void 0?"":t.reason,this[Rd]=t.wasClean===void 0?!1:t.wasClean}get code(){return this[yd]}get reason(){return this[bd]}get wasClean(){return this[Rd]}};Object.defineProperty(Nr.prototype,"code",{enumerable:!0});Object.defineProperty(Nr.prototype,"reason",{enumerable:!0});Object.defineProperty(Nr.prototype,"wasClean",{enumerable:!0});var on=class extends Vt{static{a(this,"ErrorEvent")}constructor(e,t={}){super(e),this[gd]=t.error===void 0?null:t.error,this[_d]=t.message===void 0?"":t.message}get error(){return this[gd]}get message(){return this[_d]}};Object.defineProperty(on.prototype,"error",{enumerable:!0});Object.defineProperty(on.prototype,"message",{enumerable:!0});var Jn=class extends Vt{static{a(this,"MessageEvent")}constructor(e,t={}){super(e),this[md]=t.data===void 0?null:t.data}get data(){return this[md]}};Object.defineProperty(Jn.prototype,"data",{enumerable:!0});var h_={addEventListener(n,e,t={}){for(let o of this.listeners(n))if(!t[Xn]&&o[rc]===e&&!o[Xn])return;let r;if(n==="message")r=a(function(s,i){let u=new Jn("message",{data:i?s:s.toString()});u[sn]=this,Fo(e,this,u)},"onMessage");else if(n==="close")r=a(function(s,i){let u=new Nr("close",{code:s,reason:i.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});u[sn]=this,Fo(e,this,u)},"onClose");else if(n==="error")r=a(function(s){let i=new on("error",{error:s,message:s.message});i[sn]=this,Fo(e,this,i)},"onError");else if(n==="open")r=a(function(){let s=new Vt("open");s[sn]=this,Fo(e,this,s)},"onOpen");else return;r[Xn]=!!t[Xn],r[rc]=e,t.once?this.once(n,r):this.on(n,r)},removeEventListener(n,e){for(let t of this.listeners(n))if(t[rc]===e&&!t[Xn]){this.removeListener(n,t);break}}};Ed.exports={CloseEvent:Nr,ErrorEvent:on,Event:Vt,EventTarget:h_,MessageEvent:Jn};function Fo(n,e,t){typeof n=="object"&&n.handleEvent?n.handleEvent.call(n,t):n.call(e,t)}a(Fo,"callListener")});var nc=ce((VS,Ad)=>{"use strict";var{tokenChars:Zn}=Yn();function Lt(n,e,t){n[e]===void 0?n[e]=[t]:n[e].push(t)}a(Lt,"push");function p_(n){let e=Object.create(null),t=Object.create(null),r=!1,o=!1,s=!1,i,u,f=-1,y=-1,d=-1,_=0;for(;_<n.length;_++)if(y=n.charCodeAt(_),i===void 0)if(d===-1&&Zn[y]===1)f===-1&&(f=_);else if(_!==0&&(y===32||y===9))d===-1&&f!==-1&&(d=_);else if(y===59||y===44){if(f===-1)throw new SyntaxError(`Unexpected character at index ${_}`);d===-1&&(d=_);let R=n.slice(f,d);y===44?(Lt(e,R,t),t=Object.create(null)):i=R,f=d=-1}else throw new SyntaxError(`Unexpected character at index ${_}`);else if(u===void 0)if(d===-1&&Zn[y]===1)f===-1&&(f=_);else if(y===32||y===9)d===-1&&f!==-1&&(d=_);else if(y===59||y===44){if(f===-1)throw new SyntaxError(`Unexpected character at index ${_}`);d===-1&&(d=_),Lt(t,n.slice(f,d),!0),y===44&&(Lt(e,i,t),t=Object.create(null),i=void 0),f=d=-1}else if(y===61&&f!==-1&&d===-1)u=n.slice(f,_),f=d=-1;else throw new SyntaxError(`Unexpected character at index ${_}`);else if(o){if(Zn[y]!==1)throw new SyntaxError(`Unexpected character at index ${_}`);f===-1?f=_:r||(r=!0),o=!1}else if(s)if(Zn[y]===1)f===-1&&(f=_);else if(y===34&&f!==-1)s=!1,d=_;else if(y===92)o=!0;else throw new SyntaxError(`Unexpected character at index ${_}`);else if(y===34&&n.charCodeAt(_-1)===61)s=!0;else if(d===-1&&Zn[y]===1)f===-1&&(f=_);else if(f!==-1&&(y===32||y===9))d===-1&&(d=_);else if(y===59||y===44){if(f===-1)throw new SyntaxError(`Unexpected character at index ${_}`);d===-1&&(d=_);let R=n.slice(f,d);r&&(R=R.replace(/\\/g,""),r=!1),Lt(t,u,R),y===44&&(Lt(e,i,t),t=Object.create(null),i=void 0),u=void 0,f=d=-1}else throw new SyntaxError(`Unexpected character at index ${_}`);if(f===-1||s||y===32||y===9)throw new SyntaxError("Unexpected end of input");d===-1&&(d=_);let E=n.slice(f,d);return i===void 0?Lt(e,E,t):(u===void 0?Lt(t,E,!0):r?Lt(t,u,E.replace(/\\/g,"")):Lt(t,u,E),Lt(e,i,t)),e}a(p_,"parse");function y_(n){return Object.keys(n).map(e=>{let t=n[e];return Array.isArray(t)||(t=[t]),t.map(r=>[e].concat(Object.keys(r).map(o=>{let s=r[o];return Array.isArray(s)||(s=[s]),s.map(i=>i===!0?o:`${o}=${i}`).join("; ")})).join("; ")).join(", ")}).join(", ")}a(y_,"format");Ad.exports={format:y_,parse:p_}});var cc=ce((JS,Bd)=>{"use strict";var m_=ae("events"),g_=ae("https"),__=ae("http"),vd=ae("net"),b_=ae("tls"),{randomBytes:w_,createHash:R_}=ae("crypto"),{Duplex:YS,Readable:XS}=ae("stream"),{URL:sc}=ae("url"),ur=Gn(),E_=Qa(),S_=tc(),{BINARY_TYPES:kd,EMPTY_BUFFER:Wo,GUID:A_,kForOnEventAttribute:oc,kListener:k_,kStatusCode:I_,kWebSocket:Ye,NOOP:Td}=ar(),{EventTarget:{addEventListener:v_,removeEventListener:T_}}=Sd(),{format:O_,parse:N_}=nc(),{toBuffer:C_}=qn(),x_=30*1e3,Od=Symbol("kAborted"),ic=[8,13],Gt=["CONNECTING","OPEN","CLOSING","CLOSED"],L_=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,Be=class n extends m_{static{a(this,"WebSocket")}constructor(e,t,r){super(),this._binaryType=kd[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Wo,this._closeTimer=null,this._extensions={},this._paused=!1,this._protocol="",this._readyState=n.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,t===void 0?t=[]:Array.isArray(t)||(typeof t=="object"&&t!==null?(r=t,t=[]):t=[t]),Nd(this,e,t,r)):(this._autoPong=r.autoPong,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){kd.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,t,r){let o=new E_({allowSynchronousEvents:r.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation});this._sender=new S_(e,this._extensions,r.generateMask),this._receiver=o,this._socket=e,o[Ye]=this,e[Ye]=this,o.on("conclude",U_),o.on("drain",D_),o.on("error",M_),o.on("message",$_),o.on("ping",H_),o.on("pong",z_),e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),t.length>0&&e.unshift(t),e.on("close",xd),e.on("data",qo),e.on("end",Ld),e.on("error",Pd),this._readyState=n.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=n.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[ur.extensionName]&&this._extensions[ur.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=n.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,t){if(this.readyState!==n.CLOSED){if(this.readyState===n.CONNECTING){ut(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===n.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=n.CLOSING,this._sender.close(e,t,!this._isServer,r=>{r||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),this._closeTimer=setTimeout(this._socket.destroy.bind(this._socket),x_)}}pause(){this.readyState===n.CONNECTING||this.readyState===n.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,t,r){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(r=e,e=t=void 0):typeof t=="function"&&(r=t,t=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){ac(this,e,r);return}t===void 0&&(t=!this._isServer),this._sender.ping(e||Wo,t,r)}pong(e,t,r){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(r=e,e=t=void 0):typeof t=="function"&&(r=t,t=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){ac(this,e,r);return}t===void 0&&(t=!this._isServer),this._sender.pong(e||Wo,t,r)}resume(){this.readyState===n.CONNECTING||this.readyState===n.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,t,r){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"&&(r=t,t={}),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){ac(this,e,r);return}let o={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...t};this._extensions[ur.extensionName]||(o.compress=!1),this._sender.send(e||Wo,o,r)}terminate(){if(this.readyState!==n.CLOSED){if(this.readyState===n.CONNECTING){ut(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=n.CLOSING,this._socket.destroy())}}};Object.defineProperty(Be,"CONNECTING",{enumerable:!0,value:Gt.indexOf("CONNECTING")});Object.defineProperty(Be.prototype,"CONNECTING",{enumerable:!0,value:Gt.indexOf("CONNECTING")});Object.defineProperty(Be,"OPEN",{enumerable:!0,value:Gt.indexOf("OPEN")});Object.defineProperty(Be.prototype,"OPEN",{enumerable:!0,value:Gt.indexOf("OPEN")});Object.defineProperty(Be,"CLOSING",{enumerable:!0,value:Gt.indexOf("CLOSING")});Object.defineProperty(Be.prototype,"CLOSING",{enumerable:!0,value:Gt.indexOf("CLOSING")});Object.defineProperty(Be,"CLOSED",{enumerable:!0,value:Gt.indexOf("CLOSED")});Object.defineProperty(Be.prototype,"CLOSED",{enumerable:!0,value:Gt.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(n=>{Object.defineProperty(Be.prototype,n,{enumerable:!0})});["open","error","close","message"].forEach(n=>{Object.defineProperty(Be.prototype,`on${n}`,{enumerable:!0,get(){for(let e of this.listeners(n))if(e[oc])return e[k_];return null},set(e){for(let t of this.listeners(n))if(t[oc]){this.removeListener(n,t);break}typeof e=="function"&&this.addEventListener(n,e,{[oc]:!0})}})});Be.prototype.addEventListener=v_;Be.prototype.removeEventListener=T_;Bd.exports=Be;function Nd(n,e,t,r){let o={allowSynchronousEvents:!0,autoPong:!0,protocolVersion:ic[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...r,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(n._autoPong=o.autoPong,!ic.includes(o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${ic.join(", ")})`);let s;if(e instanceof sc)s=e;else try{s=new sc(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}s.protocol==="http:"?s.protocol="ws:":s.protocol==="https:"&&(s.protocol="wss:"),n._url=s.href;let i=s.protocol==="wss:",u=s.protocol==="ws+unix:",f;if(s.protocol!=="ws:"&&!i&&!u?f=`The URL's protocol must be one of "ws:", "wss:", "http:", "https", or "ws+unix:"`:u&&!s.pathname?f="The URL's pathname is empty":s.hash&&(f="The URL contains a fragment identifier"),f){let A=new SyntaxError(f);if(n._redirects===0)throw A;Ko(n,A);return}let y=i?443:80,d=w_(16).toString("base64"),_=i?g_.request:__.request,E=new Set,R;if(o.createConnection=o.createConnection||(i?B_:P_),o.defaultPort=o.defaultPort||y,o.port=s.port||y,o.host=s.hostname.startsWith("[")?s.hostname.slice(1,-1):s.hostname,o.headers={...o.headers,"Sec-WebSocket-Version":o.protocolVersion,"Sec-WebSocket-Key":d,Connection:"Upgrade",Upgrade:"websocket"},o.path=s.pathname+s.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&(R=new ur(o.perMessageDeflate!==!0?o.perMessageDeflate:{},!1,o.maxPayload),o.headers["Sec-WebSocket-Extensions"]=O_({[ur.extensionName]:R.offer()})),t.length){for(let A of t){if(typeof A!="string"||!L_.test(A)||E.has(A))throw new SyntaxError("An invalid or duplicated subprotocol was specified");E.add(A)}o.headers["Sec-WebSocket-Protocol"]=t.join(",")}if(o.origin&&(o.protocolVersion<13?o.headers["Sec-WebSocket-Origin"]=o.origin:o.headers.Origin=o.origin),(s.username||s.password)&&(o.auth=`${s.username}:${s.password}`),u){let A=o.path.split(":");o.socketPath=A[0],o.path=A[1]}let S;if(o.followRedirects){if(n._redirects===0){n._originalIpc=u,n._originalSecure=i,n._originalHostOrSocketPath=u?o.socketPath:s.host;let A=r&&r.headers;if(r={...r,headers:{}},A)for(let[C,x]of Object.entries(A))r.headers[C.toLowerCase()]=x}else if(n.listenerCount("redirect")===0){let A=u?n._originalIpc?o.socketPath===n._originalHostOrSocketPath:!1:n._originalIpc?!1:s.host===n._originalHostOrSocketPath;(!A||n._originalSecure&&!i)&&(delete o.headers.authorization,delete o.headers.cookie,A||delete o.headers.host,o.auth=void 0)}o.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(o.auth).toString("base64")),S=n._req=_(o),n._redirects&&n.emit("redirect",n.url,S)}else S=n._req=_(o);o.timeout&&S.on("timeout",()=>{ut(n,S,"Opening handshake has timed out")}),S.on("error",A=>{S===null||S[Od]||(S=n._req=null,Ko(n,A))}),S.on("response",A=>{let C=A.headers.location,x=A.statusCode;if(C&&o.followRedirects&&x>=300&&x<400){if(++n._redirects>o.maxRedirects){ut(n,S,"Maximum redirects exceeded");return}S.abort();let w;try{w=new sc(C,e)}catch{let z=new SyntaxError(`Invalid URL: ${C}`);Ko(n,z);return}Nd(n,w,t,r)}else n.emit("unexpected-response",S,A)||ut(n,S,`Unexpected server response: ${A.statusCode}`)}),S.on("upgrade",(A,C,x)=>{if(n.emit("upgrade",A),n.readyState!==Be.CONNECTING)return;S=n._req=null;let w=A.headers.upgrade;if(w===void 0||w.toLowerCase()!=="websocket"){ut(n,C,"Invalid Upgrade header");return}let L=R_("sha1").update(d+A_).digest("base64");if(A.headers["sec-websocket-accept"]!==L){ut(n,C,"Invalid Sec-WebSocket-Accept header");return}let z=A.headers["sec-websocket-protocol"],Y;if(z!==void 0?E.size?E.has(z)||(Y="Server sent an invalid subprotocol"):Y="Server sent a subprotocol but none was requested":E.size&&(Y="Server sent no subprotocol"),Y){ut(n,C,Y);return}z&&(n._protocol=z);let ne=A.headers["sec-websocket-extensions"];if(ne!==void 0){if(!R){ut(n,C,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let re;try{re=N_(ne)}catch{ut(n,C,"Invalid Sec-WebSocket-Extensions header");return}let Se=Object.keys(re);if(Se.length!==1||Se[0]!==ur.extensionName){ut(n,C,"Server indicated an extension that was not requested");return}try{R.accept(re[ur.extensionName])}catch{ut(n,C,"Invalid Sec-WebSocket-Extensions header");return}n._extensions[ur.extensionName]=R}n.setSocket(C,x,{allowSynchronousEvents:o.allowSynchronousEvents,generateMask:o.generateMask,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(S,n):S.end()}a(Nd,"initAsClient");function Ko(n,e){n._readyState=Be.CLOSING,n.emit("error",e),n.emitClose()}a(Ko,"emitErrorAndClose");function P_(n){return n.path=n.socketPath,vd.connect(n)}a(P_,"netConnect");function B_(n){return n.path=void 0,!n.servername&&n.servername!==""&&(n.servername=vd.isIP(n.host)?"":n.host),b_.connect(n)}a(B_,"tlsConnect");function ut(n,e,t){n._readyState=Be.CLOSING;let r=new Error(t);Error.captureStackTrace(r,ut),e.setHeader?(e[Od]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(Ko,n,r)):(e.destroy(r),e.once("error",n.emit.bind(n,"error")),e.once("close",n.emitClose.bind(n)))}a(ut,"abortHandshake");function ac(n,e,t){if(e){let r=C_(e).length;n._socket?n._sender._bufferedBytes+=r:n._bufferedAmount+=r}if(t){let r=new Error(`WebSocket is not open: readyState ${n.readyState} (${Gt[n.readyState]})`);process.nextTick(t,r)}}a(ac,"sendAfterClose");function U_(n,e){let t=this[Ye];t._closeFrameReceived=!0,t._closeMessage=e,t._closeCode=n,t._socket[Ye]!==void 0&&(t._socket.removeListener("data",qo),process.nextTick(Cd,t._socket),n===1005?t.close():t.close(n,e))}a(U_,"receiverOnConclude");function D_(){let n=this[Ye];n.isPaused||n._socket.resume()}a(D_,"receiverOnDrain");function M_(n){let e=this[Ye];e._socket[Ye]!==void 0&&(e._socket.removeListener("data",qo),process.nextTick(Cd,e._socket),e.close(n[I_])),e.emit("error",n)}a(M_,"receiverOnError");function Id(){this[Ye].emitClose()}a(Id,"receiverOnFinish");function $_(n,e){this[Ye].emit("message",n,e)}a($_,"receiverOnMessage");function H_(n){let e=this[Ye];e._autoPong&&e.pong(n,!this._isServer,Td),e.emit("ping",n)}a(H_,"receiverOnPing");function z_(n){this[Ye].emit("pong",n)}a(z_,"receiverOnPong");function Cd(n){n.resume()}a(Cd,"resume");function xd(){let n=this[Ye];this.removeListener("close",xd),this.removeListener("data",qo),this.removeListener("end",Ld),n._readyState=Be.CLOSING;let e;!this._readableState.endEmitted&&!n._closeFrameReceived&&!n._receiver._writableState.errorEmitted&&(e=n._socket.read())!==null&&n._receiver.write(e),n._receiver.end(),this[Ye]=void 0,clearTimeout(n._closeTimer),n._receiver._writableState.finished||n._receiver._writableState.errorEmitted?n.emitClose():(n._receiver.on("error",Id),n._receiver.on("finish",Id))}a(xd,"socketOnClose");function qo(n){this[Ye]._receiver.write(n)||this.pause()}a(qo,"socketOnData");function Ld(){let n=this[Ye];n._readyState=Be.CLOSING,n._receiver.end(),this.end()}a(Ld,"socketOnEnd");function Pd(){let n=this[Ye];this.removeListener("error",Pd),this.on("error",Td),n&&(n._readyState=Be.CLOSING,this.destroy())}a(Pd,"socketOnError")});var Dd=ce((QS,Ud)=>{"use strict";var{tokenChars:F_}=Yn();function W_(n){let e=new Set,t=-1,r=-1,o=0;for(o;o<n.length;o++){let i=n.charCodeAt(o);if(r===-1&&F_[i]===1)t===-1&&(t=o);else if(o!==0&&(i===32||i===9))r===-1&&t!==-1&&(r=o);else if(i===44){if(t===-1)throw new SyntaxError(`Unexpected character at index ${o}`);r===-1&&(r=o);let u=n.slice(t,r);if(e.has(u))throw new SyntaxError(`The "${u}" subprotocol is duplicated`);e.add(u),t=r=-1}else throw new SyntaxError(`Unexpected character at index ${o}`)}if(t===-1||r!==-1)throw new SyntaxError("Unexpected end of input");let s=n.slice(t,o);if(e.has(s))throw new SyntaxError(`The "${s}" subprotocol is duplicated`);return e.add(s),e}a(W_,"parse");Ud.exports={parse:W_}});var Kd=ce((rA,Wd)=>{"use strict";var K_=ae("events"),jo=ae("http"),{Duplex:tA}=ae("stream"),{createHash:q_}=ae("crypto"),Md=nc(),Cr=Gn(),j_=Dd(),V_=cc(),{GUID:G_,kWebSocket:Y_}=ar(),X_=/^[+/0-9A-Za-z]{22}==$/,$d=0,Hd=1,Fd=2,uc=class extends K_{static{a(this,"WebSocketServer")}constructor(e,t){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:V_,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(e.port!=null?(this._server=jo.createServer((r,o)=>{let s=jo.STATUS_CODES[426];o.writeHead(426,{"Content-Length":s.length,"Content-Type":"text/plain"}),o.end(s)}),this._server.listen(e.port,e.host,e.backlog,t)):e.server&&(this._server=e.server),this._server){let r=this.emit.bind(this,"connection");this._removeListeners=J_(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:a((o,s,i)=>{this.handleUpgrade(o,s,i,r)},"upgrade")})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=$d}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(this._state===Fd){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(Qn,this);return}if(e&&this.once("close",e),this._state!==Hd)if(this._state=Hd,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(Qn,this):process.nextTick(Qn,this);else{let t=this._server;this._removeListeners(),this._removeListeners=this._server=null,t.close(()=>{Qn(this)})}}shouldHandle(e){if(this.options.path){let t=e.url.indexOf("?");if((t!==-1?e.url.slice(0,t):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,t,r,o){t.on("error",zd);let s=e.headers["sec-websocket-key"],i=e.headers.upgrade,u=+e.headers["sec-websocket-version"];if(e.method!=="GET"){xr(this,e,t,405,"Invalid HTTP method");return}if(i===void 0||i.toLowerCase()!=="websocket"){xr(this,e,t,400,"Invalid Upgrade header");return}if(s===void 0||!X_.test(s)){xr(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header");return}if(u!==8&&u!==13){xr(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header");return}if(!this.shouldHandle(e)){es(t,400);return}let f=e.headers["sec-websocket-protocol"],y=new Set;if(f!==void 0)try{y=j_.parse(f)}catch{xr(this,e,t,400,"Invalid Sec-WebSocket-Protocol header");return}let d=e.headers["sec-websocket-extensions"],_={};if(this.options.perMessageDeflate&&d!==void 0){let E=new Cr(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let R=Md.parse(d);R[Cr.extensionName]&&(E.accept(R[Cr.extensionName]),_[Cr.extensionName]=E)}catch{xr(this,e,t,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let E={origin:e.headers[`${u===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(E,(R,S,A,C)=>{if(!R)return es(t,S||401,A,C);this.completeUpgrade(_,s,y,e,t,r,o)});return}if(!this.options.verifyClient(E))return es(t,401)}this.completeUpgrade(_,s,y,e,t,r,o)}completeUpgrade(e,t,r,o,s,i,u){if(!s.readable||!s.writable)return s.destroy();if(s[Y_])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>$d)return es(s,503);let y=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${q_("sha1").update(t+G_).digest("base64")}`],d=new this.options.WebSocket(null,void 0,this.options);if(r.size){let _=this.options.handleProtocols?this.options.handleProtocols(r,o):r.values().next().value;_&&(y.push(`Sec-WebSocket-Protocol: ${_}`),d._protocol=_)}if(e[Cr.extensionName]){let _=e[Cr.extensionName].params,E=Md.format({[Cr.extensionName]:[_]});y.push(`Sec-WebSocket-Extensions: ${E}`),d._extensions=e}this.emit("headers",y,o),s.write(y.concat(`\r
|
7
|
+
`).join(`\r
|
8
|
+
`)),s.removeListener("error",zd),d.setSocket(s,i,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(d),d.on("close",()=>{this.clients.delete(d),this._shouldEmitClose&&!this.clients.size&&process.nextTick(Qn,this)})),u(d,o)}};Wd.exports=uc;function J_(n,e){for(let t of Object.keys(e))n.on(t,e[t]);return a(function(){for(let r of Object.keys(e))n.removeListener(r,e[r])},"removeListeners")}a(J_,"addListeners");function Qn(n){n._state=Fd,n.emit("close")}a(Qn,"emitClose");function zd(){this.destroy()}a(zd,"socketOnError");function es(n,e,t,r){t=t||jo.STATUS_CODES[e],r={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(t),...r},n.once("finish",n.destroy),n.end(`HTTP/1.1 ${e} ${jo.STATUS_CODES[e]}\r
|
9
|
+
`+Object.keys(r).map(o=>`${o}: ${r[o]}`).join(`\r
|
10
|
+
`)+`\r
|
11
|
+
\r
|
12
|
+
`+t)}a(es,"abortHandshake");function xr(n,e,t,r,o){if(n.listenerCount("wsClientError")){let s=new Error(o);Error.captureStackTrace(s,xr),n.emit("wsClientError",s,t,e)}else es(t,r,o)}a(xr,"abortHandshakeOrEmitwsClientError")});var Z_,Q_,eb,qd,jd,Vd,Gd=Pe(()=>{"use strict";Z_=fe(kf(),1),Q_=fe(Qa(),1),eb=fe(tc(),1),qd=fe(cc(),1),jd=fe(Kd(),1),Vd=qd.default});function Yd(n,e){return new Vd(n,e)}var tb,Xd,Jd=Pe(()=>{"use strict";Gd();Tm();a(Yd,"WebSocket");tb=class{static{a(this,"DefaultDataPack")}encode(n){return JSON.stringify(n)}decode(n){return JSON.parse(n)}},Xd=class extends Al.default{static{a(this,"CommonClient")}address;rpc_id;queue;options;autoconnect;ready;reconnect;reconnect_timer_id;reconnect_interval;max_reconnects;rest_options;current_reconnects;generate_request_id;socket;webSocketFactory;dataPack;constructor(n,e="ws://localhost:8080",{autoconnect:t=!0,reconnect:r=!0,reconnect_interval:o=1e3,max_reconnects:s=5,...i}={},u,f){super(),this.webSocketFactory=n,this.queue={},this.rpc_id=0,this.address=e,this.autoconnect=t,this.ready=!1,this.reconnect=r,this.reconnect_timer_id=void 0,this.reconnect_interval=o,this.max_reconnects=s,this.rest_options=i,this.current_reconnects=0,this.generate_request_id=u||(()=>++this.rpc_id),f?this.dataPack=f:this.dataPack=new tb,this.autoconnect&&this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}connect(){this.socket||this._connect(this.address,{autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects,...this.rest_options})}call(n,e,t,r){return!r&&typeof t=="object"&&(r=t,t=null),new Promise((o,s)=>{if(!this.ready)return s(new Error("socket not ready"));let i=this.generate_request_id(n,e),u={jsonrpc:"2.0",method:n,params:e||void 0,id:i};this.socket.send(this.dataPack.encode(u),r,f=>{if(f)return s(f);this.queue[i]={promise:[o,s]},t&&(this.queue[i].timeout=setTimeout(()=>{delete this.queue[i],s(new Error("reply timeout"))},t))})})}async login(n){let e=await this.call("rpc.login",n);if(!e)throw new Error("authentication failed");return e}async listMethods(){return await this.call("__listMethods")}notify(n,e){return new Promise((t,r)=>{if(!this.ready)return r(new Error("socket not ready"));let o={jsonrpc:"2.0",method:n,params:e};this.socket.send(this.dataPack.encode(o),s=>{if(s)return r(s);t()})})}async subscribe(n){typeof n=="string"&&(n=[n]);let e=await this.call("rpc.on",n);if(typeof n=="string"&&e[n]!=="ok")throw new Error("Failed subscribing to an event '"+n+"' with: "+e[n]);return e}async unsubscribe(n){typeof n=="string"&&(n=[n]);let e=await this.call("rpc.off",n);if(typeof n=="string"&&e[n]!=="ok")throw new Error("Failed unsubscribing from an event with: "+e);return e}close(n,e){this.socket.close(n||1e3,e)}setAutoReconnect(n){this.reconnect=n}setReconnectInterval(n){this.reconnect_interval=n}setMaxReconnects(n){this.max_reconnects=n}_connect(n,e){clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(n,e),this.socket.addEventListener("open",()=>{this.ready=!0,this.emit("open"),this.current_reconnects=0}),this.socket.addEventListener("message",({data:t})=>{t instanceof ArrayBuffer&&(t=Buffer.from(t).toString());try{t=this.dataPack.decode(t)}catch{return}if(t.notification&&this.listeners(t.notification).length){if(!Object.keys(t.params).length)return this.emit(t.notification);let r=[t.notification];if(t.params.constructor===Object)r.push(t.params);else for(let o=0;o<t.params.length;o++)r.push(t.params[o]);return Promise.resolve().then(()=>{this.emit.apply(this,r)})}if(!this.queue[t.id])return t.method?Promise.resolve().then(()=>{this.emit(t.method,t?.params)}):void 0;"error"in t=="result"in t&&this.queue[t.id].promise[1](new Error('Server response malformed. Response must include either "result" or "error", but not both.')),this.queue[t.id].timeout&&clearTimeout(this.queue[t.id].timeout),t.error?this.queue[t.id].promise[1](t.error):this.queue[t.id].promise[0](t.result),delete this.queue[t.id]}),this.socket.addEventListener("error",t=>this.emit("error",t)),this.socket.addEventListener("close",({code:t,reason:r})=>{this.ready&&setTimeout(()=>this.emit("close",t,r),0),this.ready=!1,this.socket=void 0,t!==1e3&&(this.current_reconnects++,this.reconnect&&(this.max_reconnects>this.current_reconnects||this.max_reconnects===0)&&(this.reconnect_timer_id=setTimeout(()=>this._connect(n,e),this.reconnect_interval)))})}}});var qc={};Cn(qc,{Account:()=>Sc,AddressLookupTableAccount:()=>cs,AddressLookupTableInstruction:()=>Lc,AddressLookupTableProgram:()=>ls,Authorized:()=>si,BLOCKHASH_CACHE_TIMEOUT_MS:()=>Dh,BPF_LOADER_DEPRECATED_PROGRAM_ID:()=>ab,BPF_LOADER_PROGRAM_ID:()=>Ib,BpfLoader:()=>Tc,COMPUTE_BUDGET_INSTRUCTION_LAYOUTS:()=>Ut,ComputeBudgetInstruction:()=>Pc,ComputeBudgetProgram:()=>fs,Connection:()=>fn,Ed25519Program:()=>ri,Enum:()=>Ec,EpochSchedule:()=>ei,FeeCalculatorLayout:()=>Ch,Keypair:()=>dn,LAMPORTS_PER_SOL:()=>y0,LOOKUP_TABLE_INSTRUCTION_LAYOUTS:()=>Xt,Loader:()=>ln,Lockup:()=>Ur,MAX_SEED_LENGTH:()=>vh,Message:()=>$t,MessageAccountKeys:()=>Br,MessageV0:()=>an,NONCE_ACCOUNT_LENGTH:()=>Zo,NonceAccount:()=>Qo,PACKET_DATA_SIZE:()=>fr,PUBLIC_KEY_LENGTH:()=>Mt,PublicKey:()=>U,SIGNATURE_LENGTH_IN_BYTES:()=>os,SOLANA_SCHEMA:()=>ns,STAKE_CONFIG_ID:()=>Gh,STAKE_INSTRUCTION_LAYOUTS:()=>De,SYSTEM_INSTRUCTION_LAYOUTS:()=>ke,SYSVAR_CLOCK_PUBKEY:()=>Pt,SYSVAR_EPOCH_SCHEDULE_PUBKEY:()=>gb,SYSVAR_INSTRUCTIONS_PUBKEY:()=>_b,SYSVAR_RECENT_BLOCKHASHES_PUBKEY:()=>Go,SYSVAR_RENT_PUBKEY:()=>cn,SYSVAR_REWARDS_PUBKEY:()=>bb,SYSVAR_SLOT_HASHES_PUBKEY:()=>wb,SYSVAR_SLOT_HISTORY_PUBKEY:()=>Rb,SYSVAR_STAKE_HISTORY_PUBKEY:()=>Yo,Secp256k1Program:()=>ni,SendTransactionError:()=>_t,SolanaJSONRPCError:()=>X,SolanaJSONRPCErrorCode:()=>Eb,StakeAuthorizationLayout:()=>i0,StakeInstruction:()=>Bc,StakeProgram:()=>hn,Struct:()=>ss,SystemInstruction:()=>vc,SystemProgram:()=>Ue,Transaction:()=>de,TransactionExpiredBlockheightExceededError:()=>is,TransactionExpiredNonceInvalidError:()=>lr,TransactionExpiredTimeoutError:()=>as,TransactionInstruction:()=>me,TransactionMessage:()=>Ac,TransactionStatus:()=>Yt,VALIDATOR_INFO_KEY:()=>Yh,VERSION_PREFIX_MASK:()=>ii,VOTE_PROGRAM_ID:()=>u0,ValidatorInfo:()=>Dc,VersionedMessage:()=>Hc,VersionedTransaction:()=>kc,VoteAccount:()=>Mc,VoteAuthorizationLayout:()=>a0,VoteInit:()=>oi,VoteInstruction:()=>Uc,VoteProgram:()=>pn,clusterApiUrl:()=>h0,sendAndConfirmRawTransaction:()=>p0,sendAndConfirmTransaction:()=>Ic});import{Buffer as Q}from"buffer";import Ah from"util";import rb from"http";import nb,{Agent as Zd}from"https";function eh(n){try{return Sr.ExtendedPoint.fromHex(n),!0}catch{return!1}}function ib(n){return n._bn!==void 0}function Th(n,e){let t=a(o=>{if(o.span>=0)return o.span;if(typeof o.alloc=="function")return o.alloc(e[o.property]);if("count"in o&&"elementLayout"in o){let s=e[o.property];if(Array.isArray(s))return s.length*t(o.elementLayout)}else if("fields"in o)return Th({layout:o},e[o.property]);return 0},"getItemAlloc"),r=0;return n.layout.fields.forEach(o=>{r+=t(o)}),r}function rt(n){let e=0,t=0;for(;;){let r=n.shift();if(e|=(r&127)<<t*7,t+=1,!(r&128))break}return e}function lt(n,e){let t=e;for(;;){let r=t&127;if(t>>=7,t==0){n.push(r);break}else r|=128,n.push(r)}}function ye(n,e){if(!n)throw new Error(e||"Assertion failed")}function Bt(n){if(n.length===0)throw new Error(Oh);return n.shift()}function nt(n,...e){let[t]=e;if(e.length===2?t+(e[1]??0)>n.length:t>=n.length)throw new Error(Oh);return n.splice(...e)}async function Ic(n,e,t,r){let o=r&&{skipPreflight:r.skipPreflight,preflightCommitment:r.preflightCommitment||r.commitment,maxRetries:r.maxRetries,minContextSlot:r.minContextSlot},s=await n.sendTransaction(e,t,o),i;if(e.recentBlockhash!=null&&e.lastValidBlockHeight!=null)i=(await n.confirmTransaction({abortSignal:r?.abortSignal,signature:s,blockhash:e.recentBlockhash,lastValidBlockHeight:e.lastValidBlockHeight},r&&r.commitment)).value;else if(e.minNonceContextSlot!=null&&e.nonceInfo!=null){let{nonceInstruction:u}=e.nonceInfo,f=u.keys[0].pubkey;i=(await n.confirmTransaction({abortSignal:r?.abortSignal,minContextSlot:e.minNonceContextSlot,nonceAccountPubkey:f,nonceValue:e.nonceInfo.nonce,signature:s},r&&r.commitment)).value}else r?.abortSignal!=null&&console.warn("sendAndConfirmTransaction(): A transaction with a deprecated confirmation strategy was supplied along with an `abortSignal`. Only transactions having `lastValidBlockHeight` or a combination of `nonceInfo` and `minNonceContextSlot` are abortable."),i=(await n.confirmTransaction(s,r&&r.commitment)).value;if(i.err)throw s!=null?new _t({action:"send",signature:s,transactionMessage:`Status: (${JSON.stringify(i)})`}):new Error(`Transaction ${s} failed (${JSON.stringify(i)})`);return s}function Lr(n){return new Promise(e=>setTimeout(e,n))}function le(n,e){let t=n.layout.span>=0?n.layout.span:Th(n,e),r=Q.alloc(t),o=Object.assign({instruction:n.index},e);return n.layout.encode(o,r),r}function we(n,e){let t;try{t=n.layout.decode(e)}catch(r){throw new Error("invalid instruction; "+r)}if(t.instruction!==n.index)throw new Error(`invalid instruction; instruction index mismatch ${t.instruction} != ${n.index}`);return t}function Lh(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function vb(){if(rh)return lc;rh=1;var n=1e3,e=n*60,t=e*60,r=t*24,o=r*7,s=r*365.25;lc=a(function(d,_){_=_||{};var E=typeof d;if(E==="string"&&d.length>0)return i(d);if(E==="number"&&isFinite(d))return _.long?f(d):u(d);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(d))},"ms");function i(d){if(d=String(d),!(d.length>100)){var _=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(d);if(_){var E=parseFloat(_[1]),R=(_[2]||"ms").toLowerCase();switch(R){case"years":case"year":case"yrs":case"yr":case"y":return E*s;case"weeks":case"week":case"w":return E*o;case"days":case"day":case"d":return E*r;case"hours":case"hour":case"hrs":case"hr":case"h":return E*t;case"minutes":case"minute":case"mins":case"min":case"m":return E*e;case"seconds":case"second":case"secs":case"sec":case"s":return E*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return E;default:return}}}}a(i,"parse");function u(d){var _=Math.abs(d);return _>=r?Math.round(d/r)+"d":_>=t?Math.round(d/t)+"h":_>=e?Math.round(d/e)+"m":_>=n?Math.round(d/n)+"s":d+"ms"}a(u,"fmtShort");function f(d){var _=Math.abs(d);return _>=r?y(d,_,r,"day"):_>=t?y(d,_,t,"hour"):_>=e?y(d,_,e,"minute"):_>=n?y(d,_,n,"second"):d+" ms"}a(f,"fmtLong");function y(d,_,E,R){var S=_>=E*1.5;return Math.round(d/E)+" "+R+(S?"s":"")}return a(y,"plural"),lc}function Tb(){if(nh)return fc;nh=1;var n=Ah,e=vb();return fc=a(function(t){if(typeof t=="number")return t;var r=e(t);if(r===void 0){var o=new Error(n.format("humanize-ms(%j) result undefined",t));console.warn(o.stack)}return r},"humanizeMs"),fc}function zc(){return sh||(sh=1,dc={CURRENT_ID:Symbol("agentkeepalive#currentId"),CREATE_ID:Symbol("agentkeepalive#createId"),INIT_SOCKET:Symbol("agentkeepalive#initSocket"),CREATE_HTTPS_CONNECTION:Symbol("agentkeepalive#createHttpsConnection"),SOCKET_CREATED_TIME:Symbol("agentkeepalive#socketCreatedTime"),SOCKET_NAME:Symbol("agentkeepalive#socketName"),SOCKET_REQUEST_COUNT:Symbol("agentkeepalive#socketRequestCount"),SOCKET_REQUEST_FINISHED_COUNT:Symbol("agentkeepalive#socketRequestFinishedCount")}),dc}function Ph(){if(oh)return hc;oh=1;let n=rb.Agent,e=Tb(),t=Ah.debuglog("agentkeepalive"),{INIT_SOCKET:r,CURRENT_ID:o,CREATE_ID:s,SOCKET_CREATED_TIME:i,SOCKET_NAME:u,SOCKET_REQUEST_COUNT:f,SOCKET_REQUEST_FINISHED_COUNT:y}=zc(),d=1,_=parseInt(process.version.split(".",1)[0].substring(1));_>=11&&_<=12?d=2:_>=13&&(d=3);function E(x){console.log("[agentkeepalive:deprecated] %s",x)}a(E,"deprecate");class R extends n{static{a(this,"Agent")}constructor(w){w=w||{},w.keepAlive=w.keepAlive!==!1,w.freeSocketTimeout===void 0&&(w.freeSocketTimeout=4e3),w.keepAliveTimeout&&(E("options.keepAliveTimeout is deprecated, please use options.freeSocketTimeout instead"),w.freeSocketTimeout=w.keepAliveTimeout,delete w.keepAliveTimeout),w.freeSocketKeepAliveTimeout&&(E("options.freeSocketKeepAliveTimeout is deprecated, please use options.freeSocketTimeout instead"),w.freeSocketTimeout=w.freeSocketKeepAliveTimeout,delete w.freeSocketKeepAliveTimeout),w.timeout===void 0&&(w.timeout=Math.max(w.freeSocketTimeout*2,8e3)),w.timeout=e(w.timeout),w.freeSocketTimeout=e(w.freeSocketTimeout),w.socketActiveTTL=w.socketActiveTTL?e(w.socketActiveTTL):0,super(w),this[o]=0,this.createSocketCount=0,this.createSocketCountLastCheck=0,this.createSocketErrorCount=0,this.createSocketErrorCountLastCheck=0,this.closeSocketCount=0,this.closeSocketCountLastCheck=0,this.errorSocketCount=0,this.errorSocketCountLastCheck=0,this.requestCount=0,this.requestCountLastCheck=0,this.timeoutSocketCount=0,this.timeoutSocketCountLastCheck=0,this.on("free",L=>{let z=this.calcSocketTimeout(L);z>0&&L.timeout!==z&&L.setTimeout(z)})}get freeSocketKeepAliveTimeout(){return E("agent.freeSocketKeepAliveTimeout is deprecated, please use agent.options.freeSocketTimeout instead"),this.options.freeSocketTimeout}get timeout(){return E("agent.timeout is deprecated, please use agent.options.timeout instead"),this.options.timeout}get socketActiveTTL(){return E("agent.socketActiveTTL is deprecated, please use agent.options.socketActiveTTL instead"),this.options.socketActiveTTL}calcSocketTimeout(w){let L=this.options.freeSocketTimeout,z=this.options.socketActiveTTL;if(z){let Y=Date.now()-w[i],ne=z-Y;if(ne<=0)return ne;L&&ne<L&&(L=ne)}if(L)return w.freeSocketTimeout||w.freeSocketKeepAliveTimeout||L}keepSocketAlive(w){let L=super.keepSocketAlive(w);if(!L)return L;let z=this.calcSocketTimeout(w);return typeof z>"u"?!0:z<=0?(t("%s(requests: %s, finished: %s) free but need to destroy by TTL, request count %s, diff is %s",w[u],w[f],w[y],z),!1):(w.timeout!==z&&w.setTimeout(z),!0)}reuseSocket(...w){super.reuseSocket(...w);let L=w[0],z=w[1];z.reusedSocket=!0;let Y=this.options.timeout;S(L)!==Y&&(L.setTimeout(Y),t("%s reset timeout to %sms",L[u],Y)),L[f]++,t("%s(requests: %s, finished: %s) reuse on addRequest, timeout %sms",L[u],L[f],L[y],S(L))}[s](){let w=this[o]++;return this[o]===Number.MAX_SAFE_INTEGER&&(this[o]=0),w}[r](w,L){L.timeout&&(S(w)||w.setTimeout(L.timeout)),this.options.keepAlive&&w.setNoDelay(!0),this.createSocketCount++,this.options.socketActiveTTL&&(w[i]=Date.now()),w[u]=`sock[${this[s]()}#${L._agentKey}]`.split("-----BEGIN",1)[0],w[f]=1,w[y]=0,A(this,w,L)}createConnection(w,L){let z=!1,Y=a((re,Se)=>{if(!z){if(z=!0,re)return this.createSocketErrorCount++,L(re);this[r](Se,w),L(re,Se)}},"onNewCreate"),ne=super.createConnection(w,Y);return ne&&Y(null,ne),ne}get statusChanged(){let w=this.createSocketCount!==this.createSocketCountLastCheck||this.createSocketErrorCount!==this.createSocketErrorCountLastCheck||this.closeSocketCount!==this.closeSocketCountLastCheck||this.errorSocketCount!==this.errorSocketCountLastCheck||this.timeoutSocketCount!==this.timeoutSocketCountLastCheck||this.requestCount!==this.requestCountLastCheck;return w&&(this.createSocketCountLastCheck=this.createSocketCount,this.createSocketErrorCountLastCheck=this.createSocketErrorCount,this.closeSocketCountLastCheck=this.closeSocketCount,this.errorSocketCountLastCheck=this.errorSocketCount,this.timeoutSocketCountLastCheck=this.timeoutSocketCount,this.requestCountLastCheck=this.requestCount),w}getCurrentStatus(){return{createSocketCount:this.createSocketCount,createSocketErrorCount:this.createSocketErrorCount,closeSocketCount:this.closeSocketCount,errorSocketCount:this.errorSocketCount,timeoutSocketCount:this.timeoutSocketCount,requestCount:this.requestCount,freeSockets:C(this.freeSockets),sockets:C(this.sockets),requests:C(this.requests)}}}function S(x){return x.timeout||x._idleTimeout}a(S,"getSocketTimeout");function A(x,w,L){t("%s create, timeout %sms",w[u],S(w));function z(){if(!w._httpMessage&&w[f]===1)return;w[y]++,x.requestCount++,t("%s(requests: %s, finished: %s) free",w[u],w[f],w[y]);let Ce=x.getName(L);w.writable&&x.requests[Ce]&&x.requests[Ce].length&&(w[f]++,t("%s(requests: %s, finished: %s) will be reuse on agent free event",w[u],w[f],w[y]))}a(z,"onFree"),w.on("free",z);function Y(Ce){t("%s(requests: %s, finished: %s) close, isError: %s",w[u],w[f],w[y],Ce),x.closeSocketCount++}a(Y,"onClose"),w.on("close",Y);function ne(){let Ce=w.listeners("timeout").length,ve=S(w),Ze=w._httpMessage,St=Ze&&Ze.listeners("timeout").length||0;t("%s(requests: %s, finished: %s) timeout after %sms, listeners %s, defaultTimeoutListenerCount %s, hasHttpRequest %s, HttpRequest timeoutListenerCount %s",w[u],w[f],w[y],ve,Ce,d,!!Ze,St),t.enabled&&t("timeout listeners: %s",w.listeners("timeout").map(tr=>tr.name).join(", ")),x.timeoutSocketCount++;let zs=x.getName(L);if(x.freeSockets[zs]&&x.freeSockets[zs].indexOf(w)!==-1)w.destroy(),x.removeSocket(w,L),t("%s is free, destroy quietly",w[u]);else if(St===0){let tr=new Error("Socket timeout");tr.code="ERR_SOCKET_TIMEOUT",tr.timeout=ve,w.destroy(tr),x.removeSocket(w,L),t("%s destroy with timeout error",w[u])}}a(ne,"onTimeout"),w.on("timeout",ne);function re(Ce){let ve=w.listeners("error").length;t("%s(requests: %s, finished: %s) error: %s, listenerCount: %s",w[u],w[f],w[y],Ce,ve),x.errorSocketCount++,ve===1&&(t("%s emit uncaught error event",w[u]),w.removeListener("error",re),w.emit("error",Ce))}a(re,"onError"),w.on("error",re);function Se(){t("%s(requests: %s, finished: %s) agentRemove",w[u],w[f],w[y]),w.removeListener("close",Y),w.removeListener("error",re),w.removeListener("free",z),w.removeListener("timeout",ne),w.removeListener("agentRemove",Se)}a(Se,"onRemove"),w.on("agentRemove",Se)}a(A,"installListeners"),hc=R;function C(x){let w={};for(let L in x)w[L]=x[L].length;return w}return a(C,"inspect"),hc}function Ob(){if(ih)return pc;ih=1;let n=nb.Agent,e=Ph(),{INIT_SOCKET:t,CREATE_HTTPS_CONNECTION:r}=zc();class o extends e{static{a(this,"HttpsAgent")}constructor(i){super(i),this.defaultPort=443,this.protocol="https:",this.maxCachedSessions=this.options.maxCachedSessions,this.maxCachedSessions===void 0&&(this.maxCachedSessions=100),this._sessionCache={map:{},list:[]}}createConnection(i,u){let f=this[r](i,u);return this[t](f,i),f}}return o.prototype[r]=n.prototype.createConnection,["getName","_getSession","_cacheSession","_evictSession"].forEach(function(s){typeof n.prototype[s]=="function"&&(o.prototype[s]=n.prototype[s])}),pc=o,pc}function Nb(){return ah||(ah=1,ts.exports=Ph(),ts.exports.HttpsAgent=Ob(),ts.exports.constants=zc()),ts.exports}function xb(){if(ch)return yc;ch=1;var n=Object.prototype.toString,e=Object.keys||function(r){var o=[];for(var s in r)o.push(s);return o};function t(r,o){var s,i,u,f,y,d,_;if(r===!0)return"true";if(r===!1)return"false";switch(typeof r){case"object":if(r===null)return null;if(r.toJSON&&typeof r.toJSON=="function")return t(r.toJSON(),o);if(_=n.call(r),_==="[object Array]"){for(u="[",i=r.length-1,s=0;s<i;s++)u+=t(r[s],!0)+",";return i>-1&&(u+=t(r[s],!0)),u+"]"}else if(_==="[object Object]"){for(f=e(r).sort(),i=f.length,u="",s=0;s<i;)y=f[s],d=t(r[y],!1),d!==void 0&&(u&&(u+=","),u+=JSON.stringify(y)+":"+d),s++;return"{"+u+"}"}else return JSON.stringify(r);case"function":case"undefined":return o?null:void 0;case"string":return JSON.stringify(r);default:return isFinite(r)?r:null}}return a(t,"stringify"),yc=a(function(r){var o=t(r,!1);if(o!==void 0)return""+o},"fastStableStringify$1"),yc}function mc(n){let e=0;for(;n>1;)n/=2,e++;return e}function Pb(n){return n===0?1:(n--,n|=n>>1,n|=n>>2,n|=n>>4,n|=n>>8,n|=n>>16,n|=n>>32,n+1)}function Ub(n,e){let t;try{t=n.layout.decode(e)}catch(r){throw new Error("invalid instruction; "+r)}if(t.typeIndex!==n.index)throw new Error(`invalid account data; account type mismatch ${t.typeIndex} != ${n.index}`);return t}function $b(n){let e=n.match(Mb);if(e==null)throw TypeError(`Failed to validate endpoint URL \`${n}\``);let[t,r,o,s]=e,i=n.startsWith("https:")?"wss:":"ws:",u=o==null?null:parseInt(o.slice(1),10),f=u==null?"":`:${u+1}`;return`${i}//${r}${f}${s}`}function Hb(n){if(/^https?:/.test(n)===!1)throw new TypeError("Endpoint URL must start with `http:` or `https:`.");return n}function Ae(n){let e,t;if(typeof n=="string")e=n;else if(n){let{commitment:r,...o}=n;e=r,t=o}return{commitment:e,config:t}}function fh(n){return n.map(e=>"memcmp"in e?{...e,memcmp:{...e.memcmp,encoding:e.memcmp.encoding??"base58"}}:e)}function Mh(n){return Ge([B({jsonrpc:Te("2.0"),id:$(),result:n}),B({jsonrpc:Te("2.0"),id:$(),error:B({code:Tr(),message:$(),data:Z(Xl())})})])}function se(n){return tn(Mh(n),zb,e=>"error"in e?e:{...e,result:H(e.result,n)})}function xe(n){return se(B({context:B({slot:k()}),value:n}))}function ai(n){return B({context:B({slot:k()}),value:n})}function gc(n,e){return n===0?new an({header:e.header,staticAccountKeys:e.accountKeys.map(t=>new U(t)),recentBlockhash:e.recentBlockhash,compiledInstructions:e.instructions.map(t=>({programIdIndex:t.programIdIndex,accountKeyIndexes:t.accounts,data:Me.default.decode(t.data)})),addressTableLookups:e.addressTableLookups}):new $t(e)}function tw(n,e,t,r,o,s){let i=t||Bb,u;if(s==null){let d={freeSocketTimeout:19e3,keepAlive:!0,maxSockets:25};n.startsWith("https:")?u=new Bh.HttpsAgent(d):u=new Cb(d)}else if(s!==!1){let d=n.startsWith("https:");if(d&&!(s instanceof Zd))throw new Error("The endpoint `"+n+"` can only be paired with an `https.Agent`. You have, instead, supplied an `http.Agent` through `httpAgent`.");if(!d&&s instanceof Zd)throw new Error("The endpoint `"+n+"` can only be paired with an `http.Agent`. You have, instead, supplied an `https.Agent` through `httpAgent`.");u=s}let f;return r&&(f=a(async(d,_)=>{let E=await new Promise((R,S)=>{try{r(d,_,(A,C)=>R([A,C]))}catch(A){S(A)}});return await i(...E)},"fetchWithMiddleware")),new kh.default(async(d,_)=>{let E={method:"POST",body:d,agent:u,headers:Object.assign({"Content-Type":"application/json"},e||{},r0)};try{let R=5,S,A=500;for(;f?S=await f(n,E):S=await i(n,E),!(S.status!==429||o===!0||(R-=1,R===0));)console.error(`Server responded with ${S.status} ${S.statusText}. Retrying after ${A}ms delay...`),await Lr(A),A*=2;let C=await S.text();S.ok?_(null,C):_(new Error(`${S.status} ${S.statusText}: ${C}`))}catch(R){R instanceof Error&&_(R)}},{})}function rw(n){return(e,t)=>new Promise((r,o)=>{n.request(e,t,(s,i)=>{if(s){o(s);return}r(i)})})}function nw(n){return e=>new Promise((t,r)=>{e.length===0&&t([]);let o=e.map(s=>n.request(s.methodName,s.args));n.request(o,(s,i)=>{if(s){r(s);return}t(i)})})}function f0({authorizedVoter:n,epoch:e}){return{epoch:e,authorizedVoter:new U(n)}}function Rh({authorizedPubkey:n,epochOfLastAuthorizedSwitch:e,targetEpoch:t}){return{authorizedPubkey:new U(n),epochOfLastAuthorizedSwitch:e,targetEpoch:t}}function d0({buf:n,idx:e,isEmpty:t}){return t?[]:[...n.slice(e+1).map(Rh),...n.slice(0,e).map(Rh)]}function h0(n,e){let t=e===!1?"http":"https";if(!n)return Eh[t].devnet;let r=Eh[t][n];if(!r)throw new Error(`Unknown ${t} cluster: ${n}`);return r}async function p0(n,e,t,r){let o,s;t&&Object.prototype.hasOwnProperty.call(t,"lastValidBlockHeight")||t&&Object.prototype.hasOwnProperty.call(t,"nonceValue")?(o=t,s=r):s=t;let i=s&&{skipPreflight:s.skipPreflight,preflightCommitment:s.preflightCommitment||s.commitment,minContextSlot:s.minContextSlot},u=await n.sendRawTransaction(e,i),f=s&&s.commitment,d=(await(o?n.confirmTransaction(o,f):n.confirmTransaction(u,f))).value;if(d.err)throw u!=null?new _t({action:i?.skipPreflight?"send":"simulate",signature:u,transactionMessage:`Status: (${JSON.stringify(d)})`}):new Error(`Raw transaction ${u} failed (${JSON.stringify(d)})`);return u}var Rc,Me,yn,g,Sh,ds,kh,sb,Qd,Xo,$c,ob,oe,ss,Ec,ns,Ih,vh,Mt,th,U,Sc,ab,fr,ii,os,is,as,lr,Br,ue,cb,Pr,ub,lb,fb,db,Jo,Oh,$t,an,Hc,Yt,hb,me,de,Ac,kc,pb,yb,mb,Nh,Pt,gb,_b,Go,cn,bb,wb,Rb,Yo,_t,Eb,X,Ch,xh,Zo,Qo,Sb,Ab,un,vc,ke,Ue,kb,ln,Ib,Tc,ts,lc,rh,fc,nh,dc,sh,hc,oh,pc,ih,ah,Bh,Cb,yc,ch,Lb,uh,rs,ei,Bb,Oc,lh,cs,Db,Mb,Ne,Uh,Fc,Dh,zb,Fb,Wb,Kb,qb,jb,Vb,Gb,Dr,Yb,Xb,Jb,Zb,Qb,dh,ew,sw,ow,iw,aw,cw,uw,lw,fw,Nc,dw,hw,Cc,pw,yw,us,mw,gw,xc,_w,bw,ww,Rw,Ew,Sw,Aw,kw,Iw,vw,Tw,Ow,Nw,Cw,hh,xw,Lw,Pw,Bw,Uw,$h,Wc,Hh,zh,Fh,Wh,Dw,Mw,Kh,qh,ti,jh,ci,Kc,mn,Mr,$w,Hw,zw,Fw,Ww,Kw,qw,ph,_c,Vo,jw,Vw,Gw,Yw,Xw,Jw,Zw,Qw,e0,t0,r0,fn,dn,Xt,Lc,ls,Pc,Ut,fs,yh,mh,gh,_h,ri,n0,s0,bh,bc,wh,o0,wc,ni,Vh,Gh,si,Ur,Bc,De,i0,hn,oi,Uc,Dt,a0,pn,Yh,c0,Dc,u0,l0,Mc,Eh,y0,$e=Pe(()=>{"use strict";vm();Rc=fe(Er()),Me=fe(Gr());Rm();yn=fe(Hl()),g=fe(ba()),Sh=fe(ba()),ds=fe(Vl());Jl();kh=fe(Rf());Sm();Jd();Em();km();sb=Sr.utils.randomPrivateKey,Qd=a(()=>{let n=Sr.utils.randomPrivateKey(),e=Xo(n),t=new Uint8Array(64);return t.set(n),t.set(e,32),{publicKey:e,secretKey:t}},"generateKeypair"),Xo=Sr.getPublicKey;a(eh,"isOnCurve");$c=a((n,e)=>Sr.sign(n,e.slice(0,32)),"sign"),ob=Sr.verify,oe=a(n=>Q.isBuffer(n)?n:n instanceof Uint8Array?Q.from(n.buffer,n.byteOffset,n.byteLength):Q.from(n),"toBuffer"),ss=class{static{a(this,"Struct")}constructor(e){Object.assign(this,e)}encode(){return Q.from((0,yn.serialize)(ns,this))}static decode(e){return(0,yn.deserialize)(ns,this,e)}static decodeUnchecked(e){return(0,yn.deserializeUnchecked)(ns,this,e)}},Ec=class extends ss{static{a(this,"Enum")}constructor(e){if(super(e),this.enum="",Object.keys(e).length!==1)throw new Error("Enum can only take single value");Object.keys(e).map(t=>{this.enum=t})}},ns=new Map,vh=32,Mt=32;a(ib,"isPublicKeyData");th=1,U=class n extends ss{static{a(this,"PublicKey")}constructor(e){if(super({}),this._bn=void 0,ib(e))this._bn=e._bn;else{if(typeof e=="string"){let t=Me.default.decode(e);if(t.length!=Mt)throw new Error("Invalid public key input");this._bn=new Rc.default(t)}else this._bn=new Rc.default(e);if(this._bn.byteLength()>Mt)throw new Error("Invalid public key input")}}static unique(){let e=new n(th);return th+=1,new n(e.toBuffer())}equals(e){return this._bn.eq(e._bn)}toBase58(){return Me.default.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){let e=this.toBuffer();return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}toBuffer(){let e=this._bn.toArrayLike(Q);if(e.length===Mt)return e;let t=Q.alloc(32);return e.copy(t,32-e.length),t}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(e,t,r){let o=Q.concat([e.toBuffer(),Q.from(t),r.toBuffer()]),s=aa(o);return new n(s)}static createProgramAddressSync(e,t){let r=Q.alloc(0);e.forEach(function(s){if(s.length>vh)throw new TypeError("Max seed length exceeded");r=Q.concat([r,oe(s)])}),r=Q.concat([r,t.toBuffer(),Q.from("ProgramDerivedAddress")]);let o=aa(r);if(eh(o))throw new Error("Invalid seeds, address must fall off the curve");return new n(o)}static async createProgramAddress(e,t){return this.createProgramAddressSync(e,t)}static findProgramAddressSync(e,t){let r=255,o;for(;r!=0;){try{let s=e.concat(Q.from([r]));o=this.createProgramAddressSync(s,t)}catch(s){if(s instanceof TypeError)throw s;r--;continue}return[o,r]}throw new Error("Unable to find a viable program address nonce")}static async findProgramAddress(e,t){return this.findProgramAddressSync(e,t)}static isOnCurve(e){let t=new n(e);return eh(t.toBytes())}};Ih=U;U.default=new Ih("11111111111111111111111111111111");ns.set(U,{kind:"struct",fields:[["_bn","u256"]]});Sc=class{static{a(this,"Account")}constructor(e){if(this._publicKey=void 0,this._secretKey=void 0,e){let t=oe(e);if(e.length!==64)throw new Error("bad secret key size");this._publicKey=t.slice(32,64),this._secretKey=t.slice(0,32)}else this._secretKey=oe(sb()),this._publicKey=oe(Xo(this._secretKey))}get publicKey(){return new U(this._publicKey)}get secretKey(){return Q.concat([this._secretKey,this._publicKey],64)}},ab=new U("BPFLoader1111111111111111111111111111111111"),fr=1232,ii=127,os=64,is=class extends Error{static{a(this,"TransactionExpiredBlockheightExceededError")}constructor(e){super(`Signature ${e} has expired: block height exceeded.`),this.signature=void 0,this.signature=e}};Object.defineProperty(is.prototype,"name",{value:"TransactionExpiredBlockheightExceededError"});as=class extends Error{static{a(this,"TransactionExpiredTimeoutError")}constructor(e,t){super(`Transaction was not confirmed in ${t.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${e} using the Solana Explorer or CLI tools.`),this.signature=void 0,this.signature=e}};Object.defineProperty(as.prototype,"name",{value:"TransactionExpiredTimeoutError"});lr=class extends Error{static{a(this,"TransactionExpiredNonceInvalidError")}constructor(e){super(`Signature ${e} has expired: the nonce is no longer valid.`),this.signature=void 0,this.signature=e}};Object.defineProperty(lr.prototype,"name",{value:"TransactionExpiredNonceInvalidError"});Br=class{static{a(this,"MessageAccountKeys")}constructor(e,t){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=e,this.accountKeysFromLookups=t}keySegments(){let e=[this.staticAccountKeys];return this.accountKeysFromLookups&&(e.push(this.accountKeysFromLookups.writable),e.push(this.accountKeysFromLookups.readonly)),e}get(e){for(let t of this.keySegments()){if(e<t.length)return t[e];e-=t.length}}get length(){return this.keySegments().flat().length}compileInstructions(e){if(this.length>256)throw new Error("Account index overflow encountered during compilation");let r=new Map;this.keySegments().flat().forEach((s,i)=>{r.set(s.toBase58(),i)});let o=a(s=>{let i=r.get(s.toBase58());if(i===void 0)throw new Error("Encountered an unknown instruction account key during compilation");return i},"findKeyIndex");return e.map(s=>({programIdIndex:o(s.programId),accountKeyIndexes:s.keys.map(i=>o(i.pubkey)),data:s.data}))}},ue=a((n="publicKey")=>g.blob(32,n),"publicKey"),cb=a((n="signature")=>g.blob(64,n),"signature"),Pr=a((n="string")=>{let e=g.struct([g.u32("length"),g.u32("lengthPadding"),g.blob(g.offset(g.u32(),-8),"chars")],n),t=e.decode.bind(e),r=e.encode.bind(e),o=e;return o.decode=(s,i)=>t(s,i).chars.toString(),o.encode=(s,i,u)=>{let f={chars:Q.from(s,"utf8")};return r(f,i,u)},o.alloc=s=>g.u32().span+g.u32().span+Q.from(s,"utf8").length,o},"rustString"),ub=a((n="authorized")=>g.struct([ue("staker"),ue("withdrawer")],n),"authorized"),lb=a((n="lockup")=>g.struct([g.ns64("unixTimestamp"),g.ns64("epoch"),ue("custodian")],n),"lockup"),fb=a((n="voteInit")=>g.struct([ue("nodePubkey"),ue("authorizedVoter"),ue("authorizedWithdrawer"),g.u8("commission")],n),"voteInit"),db=a((n="voteAuthorizeWithSeedArgs")=>g.struct([g.u32("voteAuthorizationType"),ue("currentAuthorityDerivedKeyOwnerPubkey"),Pr("currentAuthorityDerivedKeySeed"),ue("newAuthorized")],n),"voteAuthorizeWithSeedArgs");a(Th,"getAlloc");a(rt,"decodeLength");a(lt,"encodeLength");a(ye,"assert");Jo=class n{static{a(this,"CompiledKeys")}constructor(e,t){this.payer=void 0,this.keyMetaMap=void 0,this.payer=e,this.keyMetaMap=t}static compile(e,t){let r=new Map,o=a(i=>{let u=i.toBase58(),f=r.get(u);return f===void 0&&(f={isSigner:!1,isWritable:!1,isInvoked:!1},r.set(u,f)),f},"getOrInsertDefault"),s=o(t);s.isSigner=!0,s.isWritable=!0;for(let i of e){o(i.programId).isInvoked=!0;for(let u of i.keys){let f=o(u.pubkey);f.isSigner||=u.isSigner,f.isWritable||=u.isWritable}}return new n(t,r)}getMessageComponents(){let e=[...this.keyMetaMap.entries()];ye(e.length<=256,"Max static account keys length exceeded");let t=e.filter(([,f])=>f.isSigner&&f.isWritable),r=e.filter(([,f])=>f.isSigner&&!f.isWritable),o=e.filter(([,f])=>!f.isSigner&&f.isWritable),s=e.filter(([,f])=>!f.isSigner&&!f.isWritable),i={numRequiredSignatures:t.length+r.length,numReadonlySignedAccounts:r.length,numReadonlyUnsignedAccounts:s.length};{ye(t.length>0,"Expected at least one writable signer key");let[f]=t[0];ye(f===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}let u=[...t.map(([f])=>new U(f)),...r.map(([f])=>new U(f)),...o.map(([f])=>new U(f)),...s.map(([f])=>new U(f))];return[i,u]}extractTableLookup(e){let[t,r]=this.drainKeysFoundInLookupTable(e.state.addresses,i=>!i.isSigner&&!i.isInvoked&&i.isWritable),[o,s]=this.drainKeysFoundInLookupTable(e.state.addresses,i=>!i.isSigner&&!i.isInvoked&&!i.isWritable);if(!(t.length===0&&o.length===0))return[{accountKey:e.key,writableIndexes:t,readonlyIndexes:o},{writable:r,readonly:s}]}drainKeysFoundInLookupTable(e,t){let r=new Array,o=new Array;for(let[s,i]of this.keyMetaMap.entries())if(t(i)){let u=new U(s),f=e.findIndex(y=>y.equals(u));f>=0&&(ye(f<256,"Max lookup table index exceeded"),r.push(f),o.push(u),this.keyMetaMap.delete(s))}return[r,o]}},Oh="Reached end of buffer unexpectedly";a(Bt,"guardedShift");a(nt,"guardedSplice");$t=class n{static{a(this,"Message")}constructor(e){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=e.header,this.accountKeys=e.accountKeys.map(t=>new U(t)),this.recentBlockhash=e.recentBlockhash,this.instructions=e.instructions,this.instructions.forEach(t=>this.indexToProgramIds.set(t.programIdIndex,this.accountKeys[t.programIdIndex]))}get version(){return"legacy"}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:Me.default.decode(e.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new Br(this.staticAccountKeys)}static compile(e){let t=Jo.compile(e.instructions,e.payerKey),[r,o]=t.getMessageComponents(),i=new Br(o).compileInstructions(e.instructions).map(u=>({programIdIndex:u.programIdIndex,accounts:u.accountKeyIndexes,data:Me.default.encode(u.data)}));return new n({header:r,accountKeys:o,recentBlockhash:e.recentBlockhash,instructions:i})}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){let t=this.header.numRequiredSignatures;if(e>=this.header.numRequiredSignatures){let r=e-t,s=this.accountKeys.length-t-this.header.numReadonlyUnsignedAccounts;return r<s}else{let r=t-this.header.numReadonlySignedAccounts;return e<r}}isProgramId(e){return this.indexToProgramIds.has(e)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter((e,t)=>!this.isProgramId(t))}serialize(){let e=this.accountKeys.length,t=[];lt(t,e);let r=this.instructions.map(_=>{let{accounts:E,programIdIndex:R}=_,S=Array.from(Me.default.decode(_.data)),A=[];lt(A,E.length);let C=[];return lt(C,S.length),{programIdIndex:R,keyIndicesCount:Q.from(A),keyIndices:E,dataLength:Q.from(C),data:S}}),o=[];lt(o,r.length);let s=Q.alloc(fr);Q.from(o).copy(s);let i=o.length;r.forEach(_=>{let R=g.struct([g.u8("programIdIndex"),g.blob(_.keyIndicesCount.length,"keyIndicesCount"),g.seq(g.u8("keyIndex"),_.keyIndices.length,"keyIndices"),g.blob(_.dataLength.length,"dataLength"),g.seq(g.u8("userdatum"),_.data.length,"data")]).encode(_,s,i);i+=R}),s=s.slice(0,i);let u=g.struct([g.blob(1,"numRequiredSignatures"),g.blob(1,"numReadonlySignedAccounts"),g.blob(1,"numReadonlyUnsignedAccounts"),g.blob(t.length,"keyCount"),g.seq(ue("key"),e,"keys"),ue("recentBlockhash")]),f={numRequiredSignatures:Q.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:Q.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:Q.from([this.header.numReadonlyUnsignedAccounts]),keyCount:Q.from(t),keys:this.accountKeys.map(_=>oe(_.toBytes())),recentBlockhash:Me.default.decode(this.recentBlockhash)},y=Q.alloc(2048),d=u.encode(f,y);return s.copy(y,d),y.slice(0,d+s.length)}static from(e){let t=[...e],r=Bt(t);if(r!==(r&ii))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");let o=Bt(t),s=Bt(t),i=rt(t),u=[];for(let E=0;E<i;E++){let R=nt(t,0,Mt);u.push(new U(Q.from(R)))}let f=nt(t,0,Mt),y=rt(t),d=[];for(let E=0;E<y;E++){let R=Bt(t),S=rt(t),A=nt(t,0,S),C=rt(t),x=nt(t,0,C),w=Me.default.encode(Q.from(x));d.push({programIdIndex:R,accounts:A,data:w})}let _={header:{numRequiredSignatures:r,numReadonlySignedAccounts:o,numReadonlyUnsignedAccounts:s},recentBlockhash:Me.default.encode(Q.from(f)),accountKeys:u,instructions:d};return new n(_)}},an=class n{static{a(this,"MessageV0")}constructor(e){this.header=void 0,this.staticAccountKeys=void 0,this.recentBlockhash=void 0,this.compiledInstructions=void 0,this.addressTableLookups=void 0,this.header=e.header,this.staticAccountKeys=e.staticAccountKeys,this.recentBlockhash=e.recentBlockhash,this.compiledInstructions=e.compiledInstructions,this.addressTableLookups=e.addressTableLookups}get version(){return 0}get numAccountKeysFromLookups(){let e=0;for(let t of this.addressTableLookups)e+=t.readonlyIndexes.length+t.writableIndexes.length;return e}getAccountKeys(e){let t;if(e&&"accountKeysFromLookups"in e&&e.accountKeysFromLookups){if(this.numAccountKeysFromLookups!=e.accountKeysFromLookups.writable.length+e.accountKeysFromLookups.readonly.length)throw new Error("Failed to get account keys because of a mismatch in the number of account keys from lookups");t=e.accountKeysFromLookups}else if(e&&"addressLookupTableAccounts"in e&&e.addressLookupTableAccounts)t=this.resolveAddressTableLookups(e.addressLookupTableAccounts);else if(this.addressTableLookups.length>0)throw new Error("Failed to get account keys because address table lookups were not resolved");return new Br(this.staticAccountKeys,t)}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){let t=this.header.numRequiredSignatures,r=this.staticAccountKeys.length;if(e>=r){let o=e-r,s=this.addressTableLookups.reduce((i,u)=>i+u.writableIndexes.length,0);return o<s}else if(e>=this.header.numRequiredSignatures){let o=e-t,i=r-t-this.header.numReadonlyUnsignedAccounts;return o<i}else{let o=t-this.header.numReadonlySignedAccounts;return e<o}}resolveAddressTableLookups(e){let t={writable:[],readonly:[]};for(let r of this.addressTableLookups){let o=e.find(s=>s.key.equals(r.accountKey));if(!o)throw new Error(`Failed to find address lookup table account for table key ${r.accountKey.toBase58()}`);for(let s of r.writableIndexes)if(s<o.state.addresses.length)t.writable.push(o.state.addresses[s]);else throw new Error(`Failed to find address for index ${s} in address lookup table ${r.accountKey.toBase58()}`);for(let s of r.readonlyIndexes)if(s<o.state.addresses.length)t.readonly.push(o.state.addresses[s]);else throw new Error(`Failed to find address for index ${s} in address lookup table ${r.accountKey.toBase58()}`)}return t}static compile(e){let t=Jo.compile(e.instructions,e.payerKey),r=new Array,o={writable:new Array,readonly:new Array},s=e.addressLookupTableAccounts||[];for(let d of s){let _=t.extractTableLookup(d);if(_!==void 0){let[E,{writable:R,readonly:S}]=_;r.push(E),o.writable.push(...R),o.readonly.push(...S)}}let[i,u]=t.getMessageComponents(),y=new Br(u,o).compileInstructions(e.instructions);return new n({header:i,staticAccountKeys:u,recentBlockhash:e.recentBlockhash,compiledInstructions:y,addressTableLookups:r})}serialize(){let e=Array();lt(e,this.staticAccountKeys.length);let t=this.serializeInstructions(),r=Array();lt(r,this.compiledInstructions.length);let o=this.serializeAddressTableLookups(),s=Array();lt(s,this.addressTableLookups.length);let i=g.struct([g.u8("prefix"),g.struct([g.u8("numRequiredSignatures"),g.u8("numReadonlySignedAccounts"),g.u8("numReadonlyUnsignedAccounts")],"header"),g.blob(e.length,"staticAccountKeysLength"),g.seq(ue(),this.staticAccountKeys.length,"staticAccountKeys"),ue("recentBlockhash"),g.blob(r.length,"instructionsLength"),g.blob(t.length,"serializedInstructions"),g.blob(s.length,"addressTableLookupsLength"),g.blob(o.length,"serializedAddressTableLookups")]),u=new Uint8Array(fr),y=i.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(e),staticAccountKeys:this.staticAccountKeys.map(d=>d.toBytes()),recentBlockhash:Me.default.decode(this.recentBlockhash),instructionsLength:new Uint8Array(r),serializedInstructions:t,addressTableLookupsLength:new Uint8Array(s),serializedAddressTableLookups:o},u);return u.slice(0,y)}serializeInstructions(){let e=0,t=new Uint8Array(fr);for(let r of this.compiledInstructions){let o=Array();lt(o,r.accountKeyIndexes.length);let s=Array();lt(s,r.data.length);let i=g.struct([g.u8("programIdIndex"),g.blob(o.length,"encodedAccountKeyIndexesLength"),g.seq(g.u8(),r.accountKeyIndexes.length,"accountKeyIndexes"),g.blob(s.length,"encodedDataLength"),g.blob(r.data.length,"data")]);e+=i.encode({programIdIndex:r.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(o),accountKeyIndexes:r.accountKeyIndexes,encodedDataLength:new Uint8Array(s),data:r.data},t,e)}return t.slice(0,e)}serializeAddressTableLookups(){let e=0,t=new Uint8Array(fr);for(let r of this.addressTableLookups){let o=Array();lt(o,r.writableIndexes.length);let s=Array();lt(s,r.readonlyIndexes.length);let i=g.struct([ue("accountKey"),g.blob(o.length,"encodedWritableIndexesLength"),g.seq(g.u8(),r.writableIndexes.length,"writableIndexes"),g.blob(s.length,"encodedReadonlyIndexesLength"),g.seq(g.u8(),r.readonlyIndexes.length,"readonlyIndexes")]);e+=i.encode({accountKey:r.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(o),writableIndexes:r.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(s),readonlyIndexes:r.readonlyIndexes},t,e)}return t.slice(0,e)}static deserialize(e){let t=[...e],r=Bt(t),o=rⅈye(r!==o,"Expected versioned message but received legacy message");let s=o;ye(s===0,`Expected versioned message with version 0 but found version ${s}`);let i={numRequiredSignatures:Bt(t),numReadonlySignedAccounts:Bt(t),numReadonlyUnsignedAccounts:Bt(t)},u=[],f=rt(t);for(let S=0;S<f;S++)u.push(new U(nt(t,0,Mt)));let y=Me.default.encode(nt(t,0,Mt)),d=rt(t),_=[];for(let S=0;S<d;S++){let A=Bt(t),C=rt(t),x=nt(t,0,C),w=rt(t),L=new Uint8Array(nt(t,0,w));_.push({programIdIndex:A,accountKeyIndexes:x,data:L})}let E=rt(t),R=[];for(let S=0;S<E;S++){let A=new U(nt(t,0,Mt)),C=rt(t),x=nt(t,0,C),w=rt(t),L=nt(t,0,w);R.push({accountKey:A,writableIndexes:x,readonlyIndexes:L})}return new n({header:i,staticAccountKeys:u,recentBlockhash:y,compiledInstructions:_,addressTableLookups:R})}},Hc={deserializeMessageVersion(n){let e=n[0],t=eⅈreturn t===e?"legacy":t},deserialize:a(n=>{let e=Hc.deserializeMessageVersion(n);if(e==="legacy")return $t.from(n);if(e===0)return an.deserialize(n);throw new Error(`Transaction message version ${e} deserialization is not supported`)},"deserialize")},Yt=function(n){return n[n.BLOCKHEIGHT_EXCEEDED=0]="BLOCKHEIGHT_EXCEEDED",n[n.PROCESSED=1]="PROCESSED",n[n.TIMED_OUT=2]="TIMED_OUT",n[n.NONCE_INVALID=3]="NONCE_INVALID",n}({}),hb=Q.alloc(os).fill(0),me=class{static{a(this,"TransactionInstruction")}constructor(e){this.keys=void 0,this.programId=void 0,this.data=Q.alloc(0),this.programId=e.programId,this.keys=e.keys,e.data&&(this.data=e.data)}toJSON(){return{keys:this.keys.map(({pubkey:e,isSigner:t,isWritable:r})=>({pubkey:e.toJSON(),isSigner:t,isWritable:r})),programId:this.programId.toJSON(),data:[...this.data]}}},de=class n{static{a(this,"Transaction")}get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(e){if(this.signatures=[],this.feePayer=void 0,this.instructions=[],this.recentBlockhash=void 0,this.lastValidBlockHeight=void 0,this.nonceInfo=void 0,this.minNonceContextSlot=void 0,this._message=void 0,this._json=void 0,!!e)if(e.feePayer&&(this.feePayer=e.feePayer),e.signatures&&(this.signatures=e.signatures),Object.prototype.hasOwnProperty.call(e,"nonceInfo")){let{minContextSlot:t,nonceInfo:r}=e;this.minNonceContextSlot=t,this.nonceInfo=r}else if(Object.prototype.hasOwnProperty.call(e,"lastValidBlockHeight")){let{blockhash:t,lastValidBlockHeight:r}=e;this.recentBlockhash=t,this.lastValidBlockHeight=r}else{let{recentBlockhash:t,nonceInfo:r}=e;r&&(this.nonceInfo=r),this.recentBlockhash=t}}toJSON(){return{recentBlockhash:this.recentBlockhash||null,feePayer:this.feePayer?this.feePayer.toJSON():null,nonceInfo:this.nonceInfo?{nonce:this.nonceInfo.nonce,nonceInstruction:this.nonceInfo.nonceInstruction.toJSON()}:null,instructions:this.instructions.map(e=>e.toJSON()),signers:this.signatures.map(({publicKey:e})=>e.toJSON())}}add(...e){if(e.length===0)throw new Error("No instructions");return e.forEach(t=>{"instructions"in t?this.instructions=this.instructions.concat(t.instructions):"data"in t&&"programId"in t&&"keys"in t?this.instructions.push(t):this.instructions.push(new me(t))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let e,t;if(this.nonceInfo?(e=this.nonceInfo.nonce,this.instructions[0]!=this.nonceInfo.nonceInstruction?t=[this.nonceInfo.nonceInstruction,...this.instructions]:t=this.instructions):(e=this.recentBlockhash,t=this.instructions),!e)throw new Error("Transaction recentBlockhash required");t.length<1&&console.warn("No instructions provided");let r;if(this.feePayer)r=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)r=this.signatures[0].publicKey;else throw new Error("Transaction fee payer required");for(let A=0;A<t.length;A++)if(t[A].programId===void 0)throw new Error(`Transaction instruction index ${A} has undefined program id`);let o=[],s=[];t.forEach(A=>{A.keys.forEach(x=>{s.push({...x})});let C=A.programId.toString();o.includes(C)||o.push(C)}),o.forEach(A=>{s.push({pubkey:new U(A),isSigner:!1,isWritable:!1})});let i=[];s.forEach(A=>{let C=A.pubkey.toString(),x=i.findIndex(w=>w.pubkey.toString()===C);x>-1?(i[x].isWritable=i[x].isWritable||A.isWritable,i[x].isSigner=i[x].isSigner||A.isSigner):i.push(A)}),i.sort(function(A,C){if(A.isSigner!==C.isSigner)return A.isSigner?-1:1;if(A.isWritable!==C.isWritable)return A.isWritable?-1:1;let x={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return A.pubkey.toBase58().localeCompare(C.pubkey.toBase58(),"en",x)});let u=i.findIndex(A=>A.pubkey.equals(r));if(u>-1){let[A]=i.splice(u,1);A.isSigner=!0,A.isWritable=!0,i.unshift(A)}else i.unshift({pubkey:r,isSigner:!0,isWritable:!0});for(let A of this.signatures){let C=i.findIndex(x=>x.pubkey.equals(A.publicKey));if(C>-1)i[C].isSigner||(i[C].isSigner=!0,console.warn("Transaction references a signature that is unnecessary, only the fee payer and instruction signer accounts should sign a transaction. This behavior is deprecated and will throw an error in the next major version release."));else throw new Error(`unknown signer: ${A.publicKey.toString()}`)}let f=0,y=0,d=0,_=[],E=[];i.forEach(({pubkey:A,isSigner:C,isWritable:x})=>{C?(_.push(A.toString()),f+=1,x||(y+=1)):(E.push(A.toString()),x||(d+=1))});let R=_.concat(E),S=t.map(A=>{let{data:C,programId:x}=A;return{programIdIndex:R.indexOf(x.toString()),accounts:A.keys.map(w=>R.indexOf(w.pubkey.toString())),data:Me.default.encode(C)}});return S.forEach(A=>{ye(A.programIdIndex>=0),A.accounts.forEach(C=>ye(C>=0))}),new $t({header:{numRequiredSignatures:f,numReadonlySignedAccounts:y,numReadonlyUnsignedAccounts:d},accountKeys:R,recentBlockhash:e,instructions:S})}_compile(){let e=this.compileMessage(),t=e.accountKeys.slice(0,e.header.numRequiredSignatures);return this.signatures.length===t.length&&this.signatures.every((o,s)=>t[s].equals(o.publicKey))||(this.signatures=t.map(r=>({signature:null,publicKey:r}))),e}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(e){return(await e.getFeeForMessage(this.compileMessage())).value}setSigners(...e){if(e.length===0)throw new Error("No signers");let t=new Set;this.signatures=e.filter(r=>{let o=r.toString();return t.has(o)?!1:(t.add(o),!0)}).map(r=>({signature:null,publicKey:r}))}sign(...e){if(e.length===0)throw new Error("No signers");let t=new Set,r=[];for(let s of e){let i=s.publicKey.toString();t.has(i)||(t.add(i),r.push(s))}this.signatures=r.map(s=>({signature:null,publicKey:s.publicKey}));let o=this._compile();this._partialSign(o,...r)}partialSign(...e){if(e.length===0)throw new Error("No signers");let t=new Set,r=[];for(let s of e){let i=s.publicKey.toString();t.has(i)||(t.add(i),r.push(s))}let o=this._compile();this._partialSign(o,...r)}_partialSign(e,...t){let r=e.serialize();t.forEach(o=>{let s=$c(r,o.secretKey);this._addSignature(o.publicKey,oe(s))})}addSignature(e,t){this._compile(),this._addSignature(e,t)}_addSignature(e,t){ye(t.length===64);let r=this.signatures.findIndex(o=>e.equals(o.publicKey));if(r<0)throw new Error(`unknown signer: ${e.toString()}`);this.signatures[r].signature=Q.from(t)}verifySignatures(e=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),e)}_getMessageSignednessErrors(e,t){let r={};for(let{signature:o,publicKey:s}of this.signatures)o===null?t&&(r.missing||=[]).push(s):ob(o,e,s.toBytes())||(r.invalid||=[]).push(s);return r.invalid||r.missing?r:void 0}serialize(e){let{requireAllSignatures:t,verifySignatures:r}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},e),o=this.serializeMessage();if(r){let s=this._getMessageSignednessErrors(o,t);if(s){let i="Signature verification failed.";throw s.invalid&&(i+=`
|
13
|
+
Invalid signature for public key${s.invalid.length===1?"":"(s)"} [\`${s.invalid.map(u=>u.toBase58()).join("`, `")}\`].`),s.missing&&(i+=`
|
14
|
+
Missing signature for public key${s.missing.length===1?"":"(s)"} [\`${s.missing.map(u=>u.toBase58()).join("`, `")}\`].`),new Error(i)}}return this._serialize(o)}_serialize(e){let{signatures:t}=this,r=[];lt(r,t.length);let o=r.length+t.length*64+e.length,s=Q.alloc(o);return ye(t.length<256),Q.from(r).copy(s,0),t.forEach(({signature:i},u)=>{i!==null&&(ye(i.length===64,"signature has invalid length"),Q.from(i).copy(s,r.length+u*64))}),e.copy(s,r.length+t.length*64),ye(s.length<=fr,`Transaction too large: ${s.length} > ${fr}`),s}get keys(){return ye(this.instructions.length===1),this.instructions[0].keys.map(e=>e.pubkey)}get programId(){return ye(this.instructions.length===1),this.instructions[0].programId}get data(){return ye(this.instructions.length===1),this.instructions[0].data}static from(e){let t=[...e],r=rt(t),o=[];for(let s=0;s<r;s++){let i=nt(t,0,os);o.push(Me.default.encode(Q.from(i)))}return n.populate($t.from(t),o)}static populate(e,t=[]){let r=new n;return r.recentBlockhash=e.recentBlockhash,e.header.numRequiredSignatures>0&&(r.feePayer=e.accountKeys[0]),t.forEach((o,s)=>{let i={signature:o==Me.default.encode(hb)?null:Me.default.decode(o),publicKey:e.accountKeys[s]};r.signatures.push(i)}),e.instructions.forEach(o=>{let s=o.accounts.map(i=>{let u=e.accountKeys[i];return{pubkey:u,isSigner:r.signatures.some(f=>f.publicKey.toString()===u.toString())||e.isAccountSigner(i),isWritable:e.isAccountWritable(i)}});r.instructions.push(new me({keys:s,programId:e.accountKeys[o.programIdIndex],data:Me.default.decode(o.data)}))}),r._message=e,r._json=r.toJSON(),r}},Ac=class n{static{a(this,"TransactionMessage")}constructor(e){this.payerKey=void 0,this.instructions=void 0,this.recentBlockhash=void 0,this.payerKey=e.payerKey,this.instructions=e.instructions,this.recentBlockhash=e.recentBlockhash}static decompile(e,t){let{header:r,compiledInstructions:o,recentBlockhash:s}=e,{numRequiredSignatures:i,numReadonlySignedAccounts:u,numReadonlyUnsignedAccounts:f}=r,y=i-u;ye(y>0,"Message header is invalid");let d=e.staticAccountKeys.length-i-f;ye(d>=0,"Message header is invalid");let _=e.getAccountKeys(t),E=_.get(0);if(E===void 0)throw new Error("Failed to decompile message because no account keys were found");let R=[];for(let S of o){let A=[];for(let x of S.accountKeyIndexes){let w=_.get(x);if(w===void 0)throw new Error(`Failed to find key for account key index ${x}`);let L=x<i,z;L?z=x<y:x<_.staticAccountKeys.length?z=x-i<d:z=x-_.staticAccountKeys.length<_.accountKeysFromLookups.writable.length,A.push({pubkey:w,isSigner:x<r.numRequiredSignatures,isWritable:z})}let C=_.get(S.programIdIndex);if(C===void 0)throw new Error(`Failed to find program id for program id index ${S.programIdIndex}`);R.push(new me({programId:C,data:oe(S.data),keys:A}))}return new n({payerKey:E,instructions:R,recentBlockhash:s})}compileToLegacyMessage(){return $t.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions})}compileToV0Message(e){return an.compile({payerKey:this.payerKey,recentBlockhash:this.recentBlockhash,instructions:this.instructions,addressLookupTableAccounts:e})}},kc=class n{static{a(this,"VersionedTransaction")}get version(){return this.message.version}constructor(e,t){if(this.signatures=void 0,this.message=void 0,t!==void 0)ye(t.length===e.header.numRequiredSignatures,"Expected signatures length to be equal to the number of required signatures"),this.signatures=t;else{let r=[];for(let o=0;o<e.header.numRequiredSignatures;o++)r.push(new Uint8Array(os));this.signatures=r}this.message=e}serialize(){let e=this.message.serialize(),t=Array();lt(t,this.signatures.length);let r=g.struct([g.blob(t.length,"encodedSignaturesLength"),g.seq(cb(),this.signatures.length,"signatures"),g.blob(e.length,"serializedMessage")]),o=new Uint8Array(2048),s=r.encode({encodedSignaturesLength:new Uint8Array(t),signatures:this.signatures,serializedMessage:e},o);return o.slice(0,s)}static deserialize(e){let t=[...e],r=[],o=rt(t);for(let i=0;i<o;i++)r.push(new Uint8Array(nt(t,0,os)));let s=Hc.deserialize(new Uint8Array(t));return new n(s,r)}sign(e){let t=this.message.serialize(),r=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures);for(let o of e){let s=r.findIndex(i=>i.equals(o.publicKey));ye(s>=0,`Cannot sign with non signer key ${o.publicKey.toBase58()}`),this.signatures[s]=$c(t,o.secretKey)}}addSignature(e,t){ye(t.byteLength===64,"Signature must be 64 bytes long");let o=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex(s=>s.equals(e));ye(o>=0,`Can not add signature; \`${e.toBase58()}\` is not required to sign this transaction`),this.signatures[o]=t}},pb=160,yb=64,mb=pb/yb,Nh=1e3/mb,Pt=new U("SysvarC1ock11111111111111111111111111111111"),gb=new U("SysvarEpochSchedu1e111111111111111111111111"),_b=new U("Sysvar1nstructions1111111111111111111111111"),Go=new U("SysvarRecentB1ockHashes11111111111111111111"),cn=new U("SysvarRent111111111111111111111111111111111"),bb=new U("SysvarRewards111111111111111111111111111111"),wb=new U("SysvarS1otHashes111111111111111111111111111"),Rb=new U("SysvarS1otHistory11111111111111111111111111"),Yo=new U("SysvarStakeHistory1111111111111111111111111"),_t=class extends Error{static{a(this,"SendTransactionError")}constructor({action:e,signature:t,transactionMessage:r,logs:o}){let s=o?`Logs:
|
15
|
+
${JSON.stringify(o.slice(-10),null,2)}. `:"",i="\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.",u;switch(e){case"send":u=`Transaction ${t} resulted in an error.
|
16
|
+
${r}. `+s+i;break;case"simulate":u=`Simulation failed.
|
17
|
+
Message: ${r}.
|
18
|
+
`+s+i;break;default:u=`Unknown action '${(f=>f)(e)}'`}super(u),this.signature=void 0,this.transactionMessage=void 0,this.transactionLogs=void 0,this.signature=t,this.transactionMessage=r,this.transactionLogs=o||void 0}get transactionError(){return{message:this.transactionMessage,logs:Array.isArray(this.transactionLogs)?this.transactionLogs:void 0}}get logs(){let e=this.transactionLogs;if(!(e!=null&&typeof e=="object"&&"then"in e))return e}async getLogs(e){return Array.isArray(this.transactionLogs)||(this.transactionLogs=new Promise((t,r)=>{e.getTransaction(this.signature).then(o=>{if(o&&o.meta&&o.meta.logMessages){let s=o.meta.logMessages;this.transactionLogs=s,t(s)}else r(new Error("Log messages not found"))}).catch(r)})),await this.transactionLogs}},Eb={JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP:-32001,JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE:-32002,JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE:-32003,JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE:-32004,JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY:-32005,JSON_RPC_SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE:-32006,JSON_RPC_SERVER_ERROR_SLOT_SKIPPED:-32007,JSON_RPC_SERVER_ERROR_NO_SNAPSHOT:-32008,JSON_RPC_SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED:-32009,JSON_RPC_SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX:-32010,JSON_RPC_SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE:-32011,JSON_RPC_SCAN_ERROR:-32012,JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH:-32013,JSON_RPC_SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET:-32014,JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION:-32015,JSON_RPC_SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED:-32016},X=class extends Error{static{a(this,"SolanaJSONRPCError")}constructor({code:e,message:t,data:r},o){super(o!=null?`${o}: ${t}`:t),this.code=void 0,this.data=void 0,this.code=e,this.data=r,this.name="SolanaJSONRPCError"}};a(Ic,"sendAndConfirmTransaction");a(Lr,"sleep");a(le,"encodeData");a(we,"decodeData$1");Ch=g.nu64("lamportsPerSignature"),xh=g.struct([g.u32("version"),g.u32("state"),ue("authorizedPubkey"),ue("nonce"),g.struct([Ch],"feeCalculator")]),Zo=xh.span,Qo=class n{static{a(this,"NonceAccount")}constructor(e){this.authorizedPubkey=void 0,this.nonce=void 0,this.feeCalculator=void 0,this.authorizedPubkey=e.authorizedPubkey,this.nonce=e.nonce,this.feeCalculator=e.feeCalculator}static fromAccountData(e){let t=xh.decode(oe(e),0);return new n({authorizedPubkey:new U(t.authorizedPubkey),nonce:new U(t.nonce).toString(),feeCalculator:t.feeCalculator})}},Sb=a(n=>{let e=n.decode.bind(n),t=n.encode.bind(n);return{decode:e,encode:t}},"encodeDecode"),Ab=a(n=>e=>{let t=(0,Sh.blob)(n,e),{encode:r,decode:o}=Sb(t),s=t;return s.decode=(i,u)=>{let f=o(i,u);return(0,ds.toBigIntLE)(Q.from(f))},s.encode=(i,u,f)=>{let y=(0,ds.toBufferLE)(i,n);return r(y,u,f)},s},"bigInt"),un=Ab(8),vc=class{static{a(this,"SystemInstruction")}constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);let r=g.u32("instruction").decode(e.data),o;for(let[s,i]of Object.entries(ke))if(i.index==r){o=s;break}if(!o)throw new Error("Instruction type incorrect; not a SystemInstruction");return o}static decodeCreateAccount(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);let{lamports:t,space:r,programId:o}=we(ke.Create,e.data);return{fromPubkey:e.keys[0].pubkey,newAccountPubkey:e.keys[1].pubkey,lamports:t,space:r,programId:new U(o)}}static decodeTransfer(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);let{lamports:t}=we(ke.Transfer,e.data);return{fromPubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,lamports:t}}static decodeTransferWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);let{lamports:t,seed:r,programId:o}=we(ke.TransferWithSeed,e.data);return{fromPubkey:e.keys[0].pubkey,basePubkey:e.keys[1].pubkey,toPubkey:e.keys[2].pubkey,lamports:t,seed:r,programId:new U(o)}}static decodeAllocate(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);let{space:t}=we(ke.Allocate,e.data);return{accountPubkey:e.keys[0].pubkey,space:t}}static decodeAllocateWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);let{base:t,seed:r,space:o,programId:s}=we(ke.AllocateWithSeed,e.data);return{accountPubkey:e.keys[0].pubkey,basePubkey:new U(t),seed:r,space:o,programId:new U(s)}}static decodeAssign(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);let{programId:t}=we(ke.Assign,e.data);return{accountPubkey:e.keys[0].pubkey,programId:new U(t)}}static decodeAssignWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,1);let{base:t,seed:r,programId:o}=we(ke.AssignWithSeed,e.data);return{accountPubkey:e.keys[0].pubkey,basePubkey:new U(t),seed:r,programId:new U(o)}}static decodeCreateWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);let{base:t,seed:r,lamports:o,space:s,programId:i}=we(ke.CreateWithSeed,e.data);return{fromPubkey:e.keys[0].pubkey,newAccountPubkey:e.keys[1].pubkey,basePubkey:new U(t),seed:r,lamports:o,space:s,programId:new U(i)}}static decodeNonceInitialize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);let{authorized:t}=we(ke.InitializeNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,authorizedPubkey:new U(t)}}static decodeNonceAdvance(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3),we(ke.AdvanceNonceAccount,e.data),{noncePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey}}static decodeNonceWithdraw(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,5);let{lamports:t}=we(ke.WithdrawNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[4].pubkey,lamports:t}}static decodeNonceAuthorize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);let{authorized:t}=we(ke.AuthorizeNonceAccount,e.data);return{noncePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[1].pubkey,newAuthorizedPubkey:new U(t)}}static checkProgramId(e){if(!e.equals(Ue.programId))throw new Error("invalid instruction; programId is not SystemProgram")}static checkKeyLength(e,t){if(e.length<t)throw new Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}},ke=Object.freeze({Create:{index:0,layout:g.struct([g.u32("instruction"),g.ns64("lamports"),g.ns64("space"),ue("programId")])},Assign:{index:1,layout:g.struct([g.u32("instruction"),ue("programId")])},Transfer:{index:2,layout:g.struct([g.u32("instruction"),un("lamports")])},CreateWithSeed:{index:3,layout:g.struct([g.u32("instruction"),ue("base"),Pr("seed"),g.ns64("lamports"),g.ns64("space"),ue("programId")])},AdvanceNonceAccount:{index:4,layout:g.struct([g.u32("instruction")])},WithdrawNonceAccount:{index:5,layout:g.struct([g.u32("instruction"),g.ns64("lamports")])},InitializeNonceAccount:{index:6,layout:g.struct([g.u32("instruction"),ue("authorized")])},AuthorizeNonceAccount:{index:7,layout:g.struct([g.u32("instruction"),ue("authorized")])},Allocate:{index:8,layout:g.struct([g.u32("instruction"),g.ns64("space")])},AllocateWithSeed:{index:9,layout:g.struct([g.u32("instruction"),ue("base"),Pr("seed"),g.ns64("space"),ue("programId")])},AssignWithSeed:{index:10,layout:g.struct([g.u32("instruction"),ue("base"),Pr("seed"),ue("programId")])},TransferWithSeed:{index:11,layout:g.struct([g.u32("instruction"),un("lamports"),Pr("seed"),ue("programId")])},UpgradeNonceAccount:{index:12,layout:g.struct([g.u32("instruction")])}}),Ue=class n{static{a(this,"SystemProgram")}constructor(){}static createAccount(e){let t=ke.Create,r=le(t,{lamports:e.lamports,space:e.space,programId:oe(e.programId.toBuffer())});return new me({keys:[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!0,isWritable:!0}],programId:this.programId,data:r})}static transfer(e){let t,r;if("basePubkey"in e){let o=ke.TransferWithSeed;t=le(o,{lamports:BigInt(e.lamports),seed:e.seed,programId:oe(e.programId.toBuffer())}),r=[{pubkey:e.fromPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}else{let o=ke.Transfer;t=le(o,{lamports:BigInt(e.lamports)}),r=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0}]}return new me({keys:r,programId:this.programId,data:t})}static assign(e){let t,r;if("basePubkey"in e){let o=ke.AssignWithSeed;t=le(o,{base:oe(e.basePubkey.toBuffer()),seed:e.seed,programId:oe(e.programId.toBuffer())}),r=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{let o=ke.Assign;t=le(o,{programId:oe(e.programId.toBuffer())}),r=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new me({keys:r,programId:this.programId,data:t})}static createAccountWithSeed(e){let t=ke.CreateWithSeed,r=le(t,{base:oe(e.basePubkey.toBuffer()),seed:e.seed,lamports:e.lamports,space:e.space,programId:oe(e.programId.toBuffer())}),o=[{pubkey:e.fromPubkey,isSigner:!0,isWritable:!0},{pubkey:e.newAccountPubkey,isSigner:!1,isWritable:!0}];return e.basePubkey.equals(e.fromPubkey)||o.push({pubkey:e.basePubkey,isSigner:!0,isWritable:!1}),new me({keys:o,programId:this.programId,data:r})}static createNonceAccount(e){let t=new de;"basePubkey"in e&&"seed"in e?t.add(n.createAccountWithSeed({fromPubkey:e.fromPubkey,newAccountPubkey:e.noncePubkey,basePubkey:e.basePubkey,seed:e.seed,lamports:e.lamports,space:Zo,programId:this.programId})):t.add(n.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.noncePubkey,lamports:e.lamports,space:Zo,programId:this.programId}));let r={noncePubkey:e.noncePubkey,authorizedPubkey:e.authorizedPubkey};return t.add(this.nonceInitialize(r)),t}static nonceInitialize(e){let t=ke.InitializeNonceAccount,r=le(t,{authorized:oe(e.authorizedPubkey.toBuffer())}),o={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:Go,isSigner:!1,isWritable:!1},{pubkey:cn,isSigner:!1,isWritable:!1}],programId:this.programId,data:r};return new me(o)}static nonceAdvance(e){let t=ke.AdvanceNonceAccount,r=le(t),o={keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:Go,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r};return new me(o)}static nonceWithdraw(e){let t=ke.WithdrawNonceAccount,r=le(t,{lamports:e.lamports});return new me({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.toPubkey,isSigner:!1,isWritable:!0},{pubkey:Go,isSigner:!1,isWritable:!1},{pubkey:cn,isSigner:!1,isWritable:!1},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r})}static nonceAuthorize(e){let t=ke.AuthorizeNonceAccount,r=le(t,{authorized:oe(e.newAuthorizedPubkey.toBuffer())});return new me({keys:[{pubkey:e.noncePubkey,isSigner:!1,isWritable:!0},{pubkey:e.authorizedPubkey,isSigner:!0,isWritable:!1}],programId:this.programId,data:r})}static allocate(e){let t,r;if("basePubkey"in e){let o=ke.AllocateWithSeed;t=le(o,{base:oe(e.basePubkey.toBuffer()),seed:e.seed,space:e.space,programId:oe(e.programId.toBuffer())}),r=[{pubkey:e.accountPubkey,isSigner:!1,isWritable:!0},{pubkey:e.basePubkey,isSigner:!0,isWritable:!1}]}else{let o=ke.Allocate;t=le(o,{space:e.space}),r=[{pubkey:e.accountPubkey,isSigner:!0,isWritable:!0}]}return new me({keys:r,programId:this.programId,data:t})}};Ue.programId=new U("11111111111111111111111111111111");kb=fr-300,ln=class n{static{a(this,"Loader")}constructor(){}static getMinNumSignatures(e){return 2*(Math.ceil(e/n.chunkSize)+1+1)}static async load(e,t,r,o,s){{let _=await e.getMinimumBalanceForRentExemption(s.length),E=await e.getAccountInfo(r.publicKey,"confirmed"),R=null;if(E!==null){if(E.executable)return console.error("Program load failed, account is already executable"),!1;E.data.length!==s.length&&(R=R||new de,R.add(Ue.allocate({accountPubkey:r.publicKey,space:s.length}))),E.owner.equals(o)||(R=R||new de,R.add(Ue.assign({accountPubkey:r.publicKey,programId:o}))),E.lamports<_&&(R=R||new de,R.add(Ue.transfer({fromPubkey:t.publicKey,toPubkey:r.publicKey,lamports:_-E.lamports})))}else R=new de().add(Ue.createAccount({fromPubkey:t.publicKey,newAccountPubkey:r.publicKey,lamports:_>0?_:1,space:s.length,programId:o}));R!==null&&await Ic(e,R,[t,r],{commitment:"confirmed"})}let i=g.struct([g.u32("instruction"),g.u32("offset"),g.u32("bytesLength"),g.u32("bytesLengthPadding"),g.seq(g.u8("byte"),g.offset(g.u32(),-8),"bytes")]),u=n.chunkSize,f=0,y=s,d=[];for(;y.length>0;){let _=y.slice(0,u),E=Q.alloc(u+16);i.encode({instruction:0,offset:f,bytes:_,bytesLength:0,bytesLengthPadding:0},E);let R=new de().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0}],programId:o,data:E});d.push(Ic(e,R,[t,r],{commitment:"confirmed"})),e._rpcEndpoint.includes("solana.com")&&await Lr(1e3/4),f+=u,y=y.slice(u)}await Promise.all(d);{let _=g.struct([g.u32("instruction")]),E=Q.alloc(_.span);_.encode({instruction:1},E);let R=new de().add({keys:[{pubkey:r.publicKey,isSigner:!0,isWritable:!0},{pubkey:cn,isSigner:!1,isWritable:!1}],programId:o,data:E}),S="processed",A=await e.sendTransaction(R,[t,r],{preflightCommitment:S}),{context:C,value:x}=await e.confirmTransaction({signature:A,lastValidBlockHeight:R.lastValidBlockHeight,blockhash:R.recentBlockhash},S);if(x.err)throw new Error(`Transaction ${A} failed (${JSON.stringify(x)})`);for(;;){try{if(await e.getSlot({commitment:S})>C.slot)break}catch{}await new Promise(w=>setTimeout(w,Math.round(Nh/2)))}}return!0}};ln.chunkSize=kb;Ib=new U("BPFLoader2111111111111111111111111111111111"),Tc=class{static{a(this,"BpfLoader")}static getMinNumSignatures(e){return ln.getMinNumSignatures(e)}static load(e,t,r,o,s){return ln.load(e,t,r,s,o)}};a(Lh,"getDefaultExportFromCjs");ts={exports:{}};a(vb,"requireMs");a(Tb,"requireHumanizeMs");a(zc,"requireConstants");a(Ph,"requireAgent");a(Ob,"requireHttps_agent");a(Nb,"requireAgentkeepalive");Bh=Nb(),Cb=Lh(Bh);a(xb,"requireFastStableStringify");Lb=xb(),uh=Lh(Lb),rs=32;a(mc,"trailingZeros");a(Pb,"nextPowerOfTwo");ei=class{static{a(this,"EpochSchedule")}constructor(e,t,r,o,s){this.slotsPerEpoch=void 0,this.leaderScheduleSlotOffset=void 0,this.warmup=void 0,this.firstNormalEpoch=void 0,this.firstNormalSlot=void 0,this.slotsPerEpoch=e,this.leaderScheduleSlotOffset=t,this.warmup=r,this.firstNormalEpoch=o,this.firstNormalSlot=s}getEpoch(e){return this.getEpochAndSlotIndex(e)[0]}getEpochAndSlotIndex(e){if(e<this.firstNormalSlot){let t=mc(Pb(e+rs+1))-mc(rs)-1,r=this.getSlotsInEpoch(t),o=e-(r-rs);return[t,o]}else{let t=e-this.firstNormalSlot,r=Math.floor(t/this.slotsPerEpoch),o=this.firstNormalEpoch+r,s=t%this.slotsPerEpoch;return[o,s]}}getFirstSlotInEpoch(e){return e<=this.firstNormalEpoch?(Math.pow(2,e)-1)*rs:(e-this.firstNormalEpoch)*this.slotsPerEpoch+this.firstNormalSlot}getLastSlotInEpoch(e){return this.getFirstSlotInEpoch(e)+this.getSlotsInEpoch(e)-1}getSlotsInEpoch(e){return e<this.firstNormalEpoch?Math.pow(2,e+mc(rs)):this.slotsPerEpoch}},Bb=typeof globalThis.fetch=="function"?globalThis.fetch:async function(n,e){let t=typeof n=="string"&&n.slice(0,2)==="//"?"https:"+n:n;return await Rl(t,e)},Oc=class extends Xd{static{a(this,"RpcWebSocketClient")}constructor(e,t,r){let o=a(s=>{let i=Yd(s,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...t});return"socket"in i?this.underlyingSocket=i.socket:this.underlyingSocket=i,i},"webSocketFactory");super(o,e,t,r),this.underlyingSocket=void 0}call(...e){let t=this.underlyingSocket?.readyState;return t===1?super.call(...e):Promise.reject(new Error("Tried to call a JSON-RPC method `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+")"))}notify(...e){let t=this.underlyingSocket?.readyState;return t===1?super.notify(...e):Promise.reject(new Error("Tried to send a JSON-RPC notification `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+t+")"))}};a(Ub,"decodeData");lh=56,cs=class{static{a(this,"AddressLookupTableAccount")}constructor(e){this.key=void 0,this.state=void 0,this.key=e.key,this.state=e.state}isActive(){let e=BigInt("0xffffffffffffffff");return this.state.deactivationSlot===e}static deserialize(e){let t=Ub(Db,e),r=e.length-lh;ye(r>=0,"lookup table is invalid"),ye(r%32===0,"lookup table is invalid");let o=r/32,{addresses:s}=g.struct([g.seq(ue(),o,"addresses")]).decode(e.slice(lh));return{deactivationSlot:t.deactivationSlot,lastExtendedSlot:t.lastExtendedSlot,lastExtendedSlotStartIndex:t.lastExtendedStartIndex,authority:t.authority.length!==0?new U(t.authority[0]):void 0,addresses:s.map(i=>new U(i))}}},Db={index:1,layout:g.struct([g.u32("typeIndex"),un("deactivationSlot"),g.nu64("lastExtendedSlot"),g.u8("lastExtendedStartIndex"),g.u8(),g.seq(ue(),g.offset(g.u8(),-1),"authority")])},Mb=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;a($b,"makeWebsocketUrl");Ne=tn(Oo(U),$(),n=>new U(n)),Uh=No([$(),Te("base64")]),Fc=tn(Oo(Q),Uh,n=>Q.from(n[0],"base64")),Dh=30*1e3;a(Hb,"assertEndpointUrl");a(Ae,"extractCommitmentFromConfig");a(fh,"applyDefaultMemcmpEncodingToFilters");a(Mh,"createRpcResult");zb=Mh(Tr());a(se,"jsonRpcResult");a(xe,"jsonRpcResultAndContext");a(ai,"notificationResultAndContext");a(gc,"versionedMessageFromResponse");Fb=B({foundation:k(),foundationTerm:k(),initial:k(),taper:k(),terminal:k()}),Wb=se(W(K(B({epoch:k(),effectiveSlot:k(),amount:k(),postBalance:k(),commission:Z(K(k()))})))),Kb=W(B({slot:k(),prioritizationFee:k()})),qb=B({total:k(),validator:k(),foundation:k(),epoch:k()}),jb=B({epoch:k(),slotIndex:k(),slotsInEpoch:k(),absoluteSlot:k(),blockHeight:Z(k()),transactionCount:Z(k())}),Vb=B({slotsPerEpoch:k(),leaderScheduleSlotOffset:k(),warmup:kt(),firstNormalEpoch:k(),firstNormalSlot:k()}),Gb=Aa($(),W(k())),Dr=K(Ge([B({}),$()])),Yb=B({err:Dr}),Xb=Te("receivedSignature"),Jb=B({"solana-core":$(),"feature-set":Z(k())}),Zb=B({program:$(),programId:Ne,parsed:Tr()}),Qb=B({programId:Ne,accounts:W(Ne),data:$()}),dh=xe(B({err:K(Ge([B({}),$()])),logs:K(W($())),accounts:Z(K(W(K(B({executable:kt(),owner:$(),lamports:k(),data:W($()),rentEpoch:Z(k())}))))),unitsConsumed:Z(k()),returnData:Z(K(B({programId:$(),data:No([$(),Te("base64")])}))),innerInstructions:Z(K(W(B({index:k(),instructions:W(Ge([Zb,Qb]))}))))})),ew=xe(B({byIdentity:Aa($(),W(k())),range:B({firstSlot:k(),lastSlot:k()})}));a(tw,"createRpcClient");a(rw,"createRpcRequest");a(nw,"createRpcBatchRequest");sw=se(Fb),ow=se(qb),iw=se(Kb),aw=se(jb),cw=se(Vb),uw=se(Gb),lw=se(k()),fw=xe(B({total:k(),circulating:k(),nonCirculating:k(),nonCirculatingAccounts:W(Ne)})),Nc=B({amount:$(),uiAmount:K(k()),decimals:k(),uiAmountString:Z($())}),dw=xe(W(B({address:Ne,amount:$(),uiAmount:K(k()),decimals:k(),uiAmountString:Z($())}))),hw=xe(W(B({pubkey:Ne,account:B({executable:kt(),owner:Ne,lamports:k(),data:Fc,rentEpoch:k()})}))),Cc=B({program:$(),parsed:Tr(),space:k()}),pw=xe(W(B({pubkey:Ne,account:B({executable:kt(),owner:Ne,lamports:k(),data:Cc,rentEpoch:k()})}))),yw=xe(W(B({lamports:k(),address:Ne}))),us=B({executable:kt(),owner:Ne,lamports:k(),data:Fc,rentEpoch:k()}),mw=B({pubkey:Ne,account:us}),gw=tn(Ge([Oo(Q),Cc]),Ge([Uh,Cc]),n=>Array.isArray(n)?H(n,Fc):n),xc=B({executable:kt(),owner:Ne,lamports:k(),data:gw,rentEpoch:k()}),_w=B({pubkey:Ne,account:xc}),bw=B({state:Ge([Te("active"),Te("inactive"),Te("activating"),Te("deactivating")]),active:k(),inactive:k()}),ww=se(W(B({signature:$(),slot:k(),err:Dr,memo:K($()),blockTime:Z(K(k()))}))),Rw=se(W(B({signature:$(),slot:k(),err:Dr,memo:K($()),blockTime:Z(K(k()))}))),Ew=B({subscription:k(),result:ai(us)}),Sw=B({pubkey:Ne,account:us}),Aw=B({subscription:k(),result:ai(Sw)}),kw=B({parent:k(),slot:k(),root:k()}),Iw=B({subscription:k(),result:kw}),vw=Ge([B({type:Ge([Te("firstShredReceived"),Te("completed"),Te("optimisticConfirmation"),Te("root")]),slot:k(),timestamp:k()}),B({type:Te("createdBank"),parent:k(),slot:k(),timestamp:k()}),B({type:Te("frozen"),slot:k(),timestamp:k(),stats:B({numTransactionEntries:k(),numSuccessfulTransactions:k(),numFailedTransactions:k(),maxTransactionsPerEntry:k()})}),B({type:Te("dead"),slot:k(),timestamp:k(),err:$()})]),Tw=B({subscription:k(),result:vw}),Ow=B({subscription:k(),result:ai(Ge([Yb,Xb]))}),Nw=B({subscription:k(),result:k()}),Cw=B({pubkey:$(),gossip:K($()),tpu:K($()),rpc:K($()),version:K($())}),hh=B({votePubkey:$(),nodePubkey:$(),activatedStake:k(),epochVoteAccount:kt(),epochCredits:W(No([k(),k(),k()])),commission:k(),lastVote:k(),rootSlot:K(k())}),xw=se(B({current:W(hh),delinquent:W(hh)})),Lw=Ge([Te("processed"),Te("confirmed"),Te("finalized")]),Pw=B({slot:k(),confirmations:K(k()),err:Dr,confirmationStatus:Z(Lw)}),Bw=xe(W(K(Pw))),Uw=se(k()),$h=B({accountKey:Ne,writableIndexes:W(k()),readonlyIndexes:W(k())}),Wc=B({signatures:W($()),message:B({accountKeys:W($()),header:B({numRequiredSignatures:k(),numReadonlySignedAccounts:k(),numReadonlyUnsignedAccounts:k()}),instructions:W(B({accounts:W(k()),data:$(),programIdIndex:k()})),recentBlockhash:$(),addressTableLookups:Z(W($h))})}),Hh=B({pubkey:Ne,signer:kt(),writable:kt(),source:Z(Ge([Te("transaction"),Te("lookupTable")]))}),zh=B({accountKeys:W(Hh),signatures:W($())}),Fh=B({parsed:Tr(),program:$(),programId:Ne}),Wh=B({accounts:W(Ne),data:$(),programId:Ne}),Dw=Ge([Wh,Fh]),Mw=Ge([B({parsed:Tr(),program:$(),programId:$()}),B({accounts:W($()),data:$(),programId:$()})]),Kh=tn(Dw,Mw,n=>"accounts"in n?H(n,Wh):H(n,Fh)),qh=B({signatures:W($()),message:B({accountKeys:W(Hh),instructions:W(Kh),recentBlockhash:$(),addressTableLookups:Z(K(W($h)))})}),ti=B({accountIndex:k(),mint:$(),owner:Z($()),programId:Z($()),uiTokenAmount:Nc}),jh=B({writable:W(Ne),readonly:W(Ne)}),ci=B({err:Dr,fee:k(),innerInstructions:Z(K(W(B({index:k(),instructions:W(B({accounts:W(k()),data:$(),programIdIndex:k()}))})))),preBalances:W(k()),postBalances:W(k()),logMessages:Z(K(W($()))),preTokenBalances:Z(K(W(ti))),postTokenBalances:Z(K(W(ti))),loadedAddresses:Z(jh),computeUnitsConsumed:Z(k())}),Kc=B({err:Dr,fee:k(),innerInstructions:Z(K(W(B({index:k(),instructions:W(Kh)})))),preBalances:W(k()),postBalances:W(k()),logMessages:Z(K(W($()))),preTokenBalances:Z(K(W(ti))),postTokenBalances:Z(K(W(ti))),loadedAddresses:Z(jh),computeUnitsConsumed:Z(k())}),mn=Ge([Te(0),Te("legacy")]),Mr=B({pubkey:$(),lamports:k(),postBalance:K(k()),rewardType:K($()),commission:Z(K(k()))}),$w=se(K(B({blockhash:$(),previousBlockhash:$(),parentSlot:k(),transactions:W(B({transaction:Wc,meta:K(ci),version:Z(mn)})),rewards:Z(W(Mr)),blockTime:K(k()),blockHeight:K(k())}))),Hw=se(K(B({blockhash:$(),previousBlockhash:$(),parentSlot:k(),rewards:Z(W(Mr)),blockTime:K(k()),blockHeight:K(k())}))),zw=se(K(B({blockhash:$(),previousBlockhash:$(),parentSlot:k(),transactions:W(B({transaction:zh,meta:K(ci),version:Z(mn)})),rewards:Z(W(Mr)),blockTime:K(k()),blockHeight:K(k())}))),Fw=se(K(B({blockhash:$(),previousBlockhash:$(),parentSlot:k(),transactions:W(B({transaction:qh,meta:K(Kc),version:Z(mn)})),rewards:Z(W(Mr)),blockTime:K(k()),blockHeight:K(k())}))),Ww=se(K(B({blockhash:$(),previousBlockhash:$(),parentSlot:k(),transactions:W(B({transaction:zh,meta:K(Kc),version:Z(mn)})),rewards:Z(W(Mr)),blockTime:K(k()),blockHeight:K(k())}))),Kw=se(K(B({blockhash:$(),previousBlockhash:$(),parentSlot:k(),rewards:Z(W(Mr)),blockTime:K(k()),blockHeight:K(k())}))),qw=se(K(B({blockhash:$(),previousBlockhash:$(),parentSlot:k(),transactions:W(B({transaction:Wc,meta:K(ci)})),rewards:Z(W(Mr)),blockTime:K(k())}))),ph=se(K(B({blockhash:$(),previousBlockhash:$(),parentSlot:k(),signatures:W($()),blockTime:K(k())}))),_c=se(K(B({slot:k(),meta:K(ci),blockTime:Z(K(k())),transaction:Wc,version:Z(mn)}))),Vo=se(K(B({slot:k(),transaction:qh,meta:K(Kc),blockTime:Z(K(k())),version:Z(mn)}))),jw=xe(B({blockhash:$(),feeCalculator:B({lamportsPerSignature:k()})})),Vw=xe(B({blockhash:$(),lastValidBlockHeight:k()})),Gw=xe(kt()),Yw=B({slot:k(),numTransactions:k(),numSlots:k(),samplePeriodSecs:k()}),Xw=se(W(Yw)),Jw=xe(K(B({feeCalculator:B({lamportsPerSignature:k()})}))),Zw=se($()),Qw=se($()),e0=B({err:Dr,logs:W($()),signature:$()}),t0=B({result:ai(e0),subscription:k()}),r0={"solana-client":"js/1.95.8"},fn=class{static{a(this,"Connection")}constructor(e,t){this._commitment=void 0,this._confirmTransactionInitialTimeout=void 0,this._rpcEndpoint=void 0,this._rpcWsEndpoint=void 0,this._rpcClient=void 0,this._rpcRequest=void 0,this._rpcBatchRequest=void 0,this._rpcWebSocket=void 0,this._rpcWebSocketConnected=!1,this._rpcWebSocketHeartbeat=null,this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketGeneration=0,this._disableBlockhashCaching=!1,this._pollingBlockhash=!1,this._blockhashInfo={latestBlockhash:null,lastFetch:0,transactionSignatures:[],simulatedSignatures:[]},this._nextClientSubscriptionId=0,this._subscriptionDisposeFunctionsByClientSubscriptionId={},this._subscriptionHashByClientSubscriptionId={},this._subscriptionStateChangeCallbacksByHash={},this._subscriptionCallbacksByServerSubscriptionId={},this._subscriptionsByHash={},this._subscriptionsAutoDisposedByRpc=new Set,this.getBlockHeight=(()=>{let y={};return async d=>{let{commitment:_,config:E}=Ae(d),R=this._buildArgs([],_,void 0,E),S=uh(R);return y[S]=y[S]??(async()=>{try{let A=await this._rpcRequest("getBlockHeight",R),C=H(A,se(k()));if("error"in C)throw new X(C.error,"failed to get block height information");return C.result}finally{delete y[S]}})(),await y[S]}})();let r,o,s,i,u,f;t&&typeof t=="string"?this._commitment=t:t&&(this._commitment=t.commitment,this._confirmTransactionInitialTimeout=t.confirmTransactionInitialTimeout,r=t.wsEndpoint,o=t.httpHeaders,s=t.fetch,i=t.fetchMiddleware,u=t.disableRetryOnRateLimit,f=t.httpAgent),this._rpcEndpoint=Hb(e),this._rpcWsEndpoint=r||$b(e),this._rpcClient=tw(e,o,s,i,u,f),this._rpcRequest=rw(this._rpcClient),this._rpcBatchRequest=nw(this._rpcClient),this._rpcWebSocket=new Oc(this._rpcWsEndpoint,{autoconnect:!1,max_reconnects:1/0}),this._rpcWebSocket.on("open",this._wsOnOpen.bind(this)),this._rpcWebSocket.on("error",this._wsOnError.bind(this)),this._rpcWebSocket.on("close",this._wsOnClose.bind(this)),this._rpcWebSocket.on("accountNotification",this._wsOnAccountNotification.bind(this)),this._rpcWebSocket.on("programNotification",this._wsOnProgramAccountNotification.bind(this)),this._rpcWebSocket.on("slotNotification",this._wsOnSlotNotification.bind(this)),this._rpcWebSocket.on("slotsUpdatesNotification",this._wsOnSlotUpdatesNotification.bind(this)),this._rpcWebSocket.on("signatureNotification",this._wsOnSignatureNotification.bind(this)),this._rpcWebSocket.on("rootNotification",this._wsOnRootNotification.bind(this)),this._rpcWebSocket.on("logsNotification",this._wsOnLogsNotification.bind(this))}get commitment(){return this._commitment}get rpcEndpoint(){return this._rpcEndpoint}async getBalanceAndContext(e,t){let{commitment:r,config:o}=Ae(t),s=this._buildArgs([e.toBase58()],r,void 0,o),i=await this._rpcRequest("getBalance",s),u=H(i,xe(k()));if("error"in u)throw new X(u.error,`failed to get balance for ${e.toBase58()}`);return u.result}async getBalance(e,t){return await this.getBalanceAndContext(e,t).then(r=>r.value).catch(r=>{throw new Error("failed to get balance of account "+e.toBase58()+": "+r)})}async getBlockTime(e){let t=await this._rpcRequest("getBlockTime",[e]),r=H(t,se(K(k())));if("error"in r)throw new X(r.error,`failed to get block time for slot ${e}`);return r.result}async getMinimumLedgerSlot(){let e=await this._rpcRequest("minimumLedgerSlot",[]),t=H(e,se(k()));if("error"in t)throw new X(t.error,"failed to get minimum ledger slot");return t.result}async getFirstAvailableBlock(){let e=await this._rpcRequest("getFirstAvailableBlock",[]),t=H(e,lw);if("error"in t)throw new X(t.error,"failed to get first available block");return t.result}async getSupply(e){let t={};typeof e=="string"?t={commitment:e}:e?t={...e,commitment:e&&e.commitment||this.commitment}:t={commitment:this.commitment};let r=await this._rpcRequest("getSupply",[t]),o=H(r,fw);if("error"in o)throw new X(o.error,"failed to get supply");return o.result}async getTokenSupply(e,t){let r=this._buildArgs([e.toBase58()],t),o=await this._rpcRequest("getTokenSupply",r),s=H(o,xe(Nc));if("error"in s)throw new X(s.error,"failed to get token supply");return s.result}async getTokenAccountBalance(e,t){let r=this._buildArgs([e.toBase58()],t),o=await this._rpcRequest("getTokenAccountBalance",r),s=H(o,xe(Nc));if("error"in s)throw new X(s.error,"failed to get token account balance");return s.result}async getTokenAccountsByOwner(e,t,r){let{commitment:o,config:s}=Ae(r),i=[e.toBase58()];"mint"in t?i.push({mint:t.mint.toBase58()}):i.push({programId:t.programId.toBase58()});let u=this._buildArgs(i,o,"base64",s),f=await this._rpcRequest("getTokenAccountsByOwner",u),y=H(f,hw);if("error"in y)throw new X(y.error,`failed to get token accounts owned by account ${e.toBase58()}`);return y.result}async getParsedTokenAccountsByOwner(e,t,r){let o=[e.toBase58()];"mint"in t?o.push({mint:t.mint.toBase58()}):o.push({programId:t.programId.toBase58()});let s=this._buildArgs(o,r,"jsonParsed"),i=await this._rpcRequest("getTokenAccountsByOwner",s),u=H(i,pw);if("error"in u)throw new X(u.error,`failed to get token accounts owned by account ${e.toBase58()}`);return u.result}async getLargestAccounts(e){let t={...e,commitment:e&&e.commitment||this.commitment},r=t.filter||t.commitment?[t]:[],o=await this._rpcRequest("getLargestAccounts",r),s=H(o,yw);if("error"in s)throw new X(s.error,"failed to get largest accounts");return s.result}async getTokenLargestAccounts(e,t){let r=this._buildArgs([e.toBase58()],t),o=await this._rpcRequest("getTokenLargestAccounts",r),s=H(o,dw);if("error"in s)throw new X(s.error,"failed to get token largest accounts");return s.result}async getAccountInfoAndContext(e,t){let{commitment:r,config:o}=Ae(t),s=this._buildArgs([e.toBase58()],r,"base64",o),i=await this._rpcRequest("getAccountInfo",s),u=H(i,xe(K(us)));if("error"in u)throw new X(u.error,`failed to get info about account ${e.toBase58()}`);return u.result}async getParsedAccountInfo(e,t){let{commitment:r,config:o}=Ae(t),s=this._buildArgs([e.toBase58()],r,"jsonParsed",o),i=await this._rpcRequest("getAccountInfo",s),u=H(i,xe(K(xc)));if("error"in u)throw new X(u.error,`failed to get info about account ${e.toBase58()}`);return u.result}async getAccountInfo(e,t){try{return(await this.getAccountInfoAndContext(e,t)).value}catch(r){throw new Error("failed to get info about account "+e.toBase58()+": "+r)}}async getMultipleParsedAccounts(e,t){let{commitment:r,config:o}=Ae(t),s=e.map(y=>y.toBase58()),i=this._buildArgs([s],r,"jsonParsed",o),u=await this._rpcRequest("getMultipleAccounts",i),f=H(u,xe(W(K(xc))));if("error"in f)throw new X(f.error,`failed to get info for accounts ${s}`);return f.result}async getMultipleAccountsInfoAndContext(e,t){let{commitment:r,config:o}=Ae(t),s=e.map(y=>y.toBase58()),i=this._buildArgs([s],r,"base64",o),u=await this._rpcRequest("getMultipleAccounts",i),f=H(u,xe(W(K(us))));if("error"in f)throw new X(f.error,`failed to get info for accounts ${s}`);return f.result}async getMultipleAccountsInfo(e,t){return(await this.getMultipleAccountsInfoAndContext(e,t)).value}async getStakeActivation(e,t,r){let{commitment:o,config:s}=Ae(t),i=this._buildArgs([e.toBase58()],o,void 0,{...s,epoch:r??s?.epoch}),u=await this._rpcRequest("getStakeActivation",i),f=H(u,se(bw));if("error"in f)throw new X(f.error,`failed to get Stake Activation ${e.toBase58()}`);return f.result}async getProgramAccounts(e,t){let{commitment:r,config:o}=Ae(t),{encoding:s,...i}=o||{},u=this._buildArgs([e.toBase58()],r,s||"base64",{...i,...i.filters?{filters:fh(i.filters)}:null}),f=await this._rpcRequest("getProgramAccounts",u),y=W(mw),d=i.withContext===!0?H(f,xe(y)):H(f,se(y));if("error"in d)throw new X(d.error,`failed to get accounts owned by program ${e.toBase58()}`);return d.result}async getParsedProgramAccounts(e,t){let{commitment:r,config:o}=Ae(t),s=this._buildArgs([e.toBase58()],r,"jsonParsed",o),i=await this._rpcRequest("getProgramAccounts",s),u=H(i,se(W(_w)));if("error"in u)throw new X(u.error,`failed to get accounts owned by program ${e.toBase58()}`);return u.result}async confirmTransaction(e,t){let r;if(typeof e=="string")r=e;else{let s=e;if(s.abortSignal?.aborted)return Promise.reject(s.abortSignal.reason);r=s.signature}let o;try{o=Me.default.decode(r)}catch{throw new Error("signature must be base58 encoded: "+r)}return ye(o.length===64,"signature has invalid length"),typeof e=="string"?await this.confirmTransactionUsingLegacyTimeoutStrategy({commitment:t||this.commitment,signature:r}):"lastValidBlockHeight"in e?await this.confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:t||this.commitment,strategy:e}):await this.confirmTransactionUsingDurableNonceStrategy({commitment:t||this.commitment,strategy:e})}getCancellationPromise(e){return new Promise((t,r)=>{e!=null&&(e.aborted?r(e.reason):e.addEventListener("abort",()=>{r(e.reason)}))})}getTransactionConfirmationPromise({commitment:e,signature:t}){let r,o,s=!1,i=new Promise((f,y)=>{try{r=this.onSignature(t,(_,E)=>{r=void 0;let R={context:E,value:_};f({__type:Yt.PROCESSED,response:R})},e);let d=new Promise(_=>{r==null?_():o=this._onSubscriptionStateChange(r,E=>{E==="subscribed"&&_()})});(async()=>{if(await d,s)return;let _=await this.getSignatureStatus(t);if(s||_==null)return;let{context:E,value:R}=_;if(R!=null)if(R?.err)y(R.err);else{switch(e){case"confirmed":case"single":case"singleGossip":{if(R.confirmationStatus==="processed")return;break}case"finalized":case"max":case"root":{if(R.confirmationStatus==="processed"||R.confirmationStatus==="confirmed")return;break}case"processed":case"recent":}s=!0,f({__type:Yt.PROCESSED,response:{context:E,value:R}})}})()}catch(d){y(d)}});return{abortConfirmation:a(()=>{o&&(o(),o=void 0),r!=null&&(this.removeSignatureListener(r),r=void 0)},"abortConfirmation"),confirmationPromise:i}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:e,strategy:{abortSignal:t,lastValidBlockHeight:r,signature:o}}){let s=!1,i=new Promise(_=>{let E=a(async()=>{try{return await this.getBlockHeight(e)}catch{return-1}},"checkBlockHeight");(async()=>{let R=await E();if(!s){for(;R<=r;)if(await Lr(1e3),s||(R=await E(),s))return;_({__type:Yt.BLOCKHEIGHT_EXCEEDED})}})()}),{abortConfirmation:u,confirmationPromise:f}=this.getTransactionConfirmationPromise({commitment:e,signature:o}),y=this.getCancellationPromise(t),d;try{let _=await Promise.race([y,f,i]);if(_.__type===Yt.PROCESSED)d=_.response;else throw new is(o)}finally{s=!0,u()}return d}async confirmTransactionUsingDurableNonceStrategy({commitment:e,strategy:{abortSignal:t,minContextSlot:r,nonceAccountPubkey:o,nonceValue:s,signature:i}}){let u=!1,f=new Promise(R=>{let S=s,A=null,C=a(async()=>{try{let{context:x,value:w}=await this.getNonceAndContext(o,{commitment:e,minContextSlot:r});return A=x.slot,w?.nonce}catch{return S}},"getCurrentNonceValue");(async()=>{if(S=await C(),!u)for(;;){if(s!==S){R({__type:Yt.NONCE_INVALID,slotInWhichNonceDidAdvance:A});return}if(await Lr(2e3),u||(S=await C(),u))return}})()}),{abortConfirmation:y,confirmationPromise:d}=this.getTransactionConfirmationPromise({commitment:e,signature:i}),_=this.getCancellationPromise(t),E;try{let R=await Promise.race([_,d,f]);if(R.__type===Yt.PROCESSED)E=R.response;else{let S;for(;;){let A=await this.getSignatureStatus(i);if(A==null)break;if(A.context.slot<(R.slotInWhichNonceDidAdvance??r)){await Lr(400);continue}S=A;break}if(S?.value){let A=e||"finalized",{confirmationStatus:C}=S.value;switch(A){case"processed":case"recent":if(C!=="processed"&&C!=="confirmed"&&C!=="finalized")throw new lr(i);break;case"confirmed":case"single":case"singleGossip":if(C!=="confirmed"&&C!=="finalized")throw new lr(i);break;case"finalized":case"max":case"root":if(C!=="finalized")throw new lr(i);break;default:}E={context:S.context,value:{err:S.value.err}}}else throw new lr(i)}}finally{u=!0,y()}return E}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:e,signature:t}){let r,o=new Promise(f=>{let y=this._confirmTransactionInitialTimeout||6e4;switch(e){case"processed":case"recent":case"single":case"confirmed":case"singleGossip":{y=this._confirmTransactionInitialTimeout||3e4;break}}r=setTimeout(()=>f({__type:Yt.TIMED_OUT,timeoutMs:y}),y)}),{abortConfirmation:s,confirmationPromise:i}=this.getTransactionConfirmationPromise({commitment:e,signature:t}),u;try{let f=await Promise.race([i,o]);if(f.__type===Yt.PROCESSED)u=f.response;else throw new as(t,f.timeoutMs/1e3)}finally{clearTimeout(r),s()}return u}async getClusterNodes(){let e=await this._rpcRequest("getClusterNodes",[]),t=H(e,se(W(Cw)));if("error"in t)throw new X(t.error,"failed to get cluster nodes");return t.result}async getVoteAccounts(e){let t=this._buildArgs([],e),r=await this._rpcRequest("getVoteAccounts",t),o=H(r,xw);if("error"in o)throw new X(o.error,"failed to get vote accounts");return o.result}async getSlot(e){let{commitment:t,config:r}=Ae(e),o=this._buildArgs([],t,void 0,r),s=await this._rpcRequest("getSlot",o),i=H(s,se(k()));if("error"in i)throw new X(i.error,"failed to get slot");return i.result}async getSlotLeader(e){let{commitment:t,config:r}=Ae(e),o=this._buildArgs([],t,void 0,r),s=await this._rpcRequest("getSlotLeader",o),i=H(s,se($()));if("error"in i)throw new X(i.error,"failed to get slot leader");return i.result}async getSlotLeaders(e,t){let r=[e,t],o=await this._rpcRequest("getSlotLeaders",r),s=H(o,se(W(Ne)));if("error"in s)throw new X(s.error,"failed to get slot leaders");return s.result}async getSignatureStatus(e,t){let{context:r,value:o}=await this.getSignatureStatuses([e],t);ye(o.length===1);let s=o[0];return{context:r,value:s}}async getSignatureStatuses(e,t){let r=[e];t&&r.push(t);let o=await this._rpcRequest("getSignatureStatuses",r),s=H(o,Bw);if("error"in s)throw new X(s.error,"failed to get signature status");return s.result}async getTransactionCount(e){let{commitment:t,config:r}=Ae(e),o=this._buildArgs([],t,void 0,r),s=await this._rpcRequest("getTransactionCount",o),i=H(s,se(k()));if("error"in i)throw new X(i.error,"failed to get transaction count");return i.result}async getTotalSupply(e){return(await this.getSupply({commitment:e,excludeNonCirculatingAccountsList:!0})).value.total}async getInflationGovernor(e){let t=this._buildArgs([],e),r=await this._rpcRequest("getInflationGovernor",t),o=H(r,sw);if("error"in o)throw new X(o.error,"failed to get inflation");return o.result}async getInflationReward(e,t,r){let{commitment:o,config:s}=Ae(r),i=this._buildArgs([e.map(y=>y.toBase58())],o,void 0,{...s,epoch:t??s?.epoch}),u=await this._rpcRequest("getInflationReward",i),f=H(u,Wb);if("error"in f)throw new X(f.error,"failed to get inflation reward");return f.result}async getInflationRate(){let e=await this._rpcRequest("getInflationRate",[]),t=H(e,ow);if("error"in t)throw new X(t.error,"failed to get inflation rate");return t.result}async getEpochInfo(e){let{commitment:t,config:r}=Ae(e),o=this._buildArgs([],t,void 0,r),s=await this._rpcRequest("getEpochInfo",o),i=H(s,aw);if("error"in i)throw new X(i.error,"failed to get epoch info");return i.result}async getEpochSchedule(){let e=await this._rpcRequest("getEpochSchedule",[]),t=H(e,cw);if("error"in t)throw new X(t.error,"failed to get epoch schedule");let r=t.result;return new ei(r.slotsPerEpoch,r.leaderScheduleSlotOffset,r.warmup,r.firstNormalEpoch,r.firstNormalSlot)}async getLeaderSchedule(){let e=await this._rpcRequest("getLeaderSchedule",[]),t=H(e,uw);if("error"in t)throw new X(t.error,"failed to get leader schedule");return t.result}async getMinimumBalanceForRentExemption(e,t){let r=this._buildArgs([e],t),o=await this._rpcRequest("getMinimumBalanceForRentExemption",r),s=H(o,Uw);return"error"in s?(console.warn("Unable to fetch minimum balance for rent exemption"),0):s.result}async getRecentBlockhashAndContext(e){let t=this._buildArgs([],e),r=await this._rpcRequest("getRecentBlockhash",t),o=H(r,jw);if("error"in o)throw new X(o.error,"failed to get recent blockhash");return o.result}async getRecentPerformanceSamples(e){let t=await this._rpcRequest("getRecentPerformanceSamples",e?[e]:[]),r=H(t,Xw);if("error"in r)throw new X(r.error,"failed to get recent performance samples");return r.result}async getFeeCalculatorForBlockhash(e,t){let r=this._buildArgs([e],t),o=await this._rpcRequest("getFeeCalculatorForBlockhash",r),s=H(o,Jw);if("error"in s)throw new X(s.error,"failed to get fee calculator");let{context:i,value:u}=s.result;return{context:i,value:u!==null?u.feeCalculator:null}}async getFeeForMessage(e,t){let r=oe(e.serialize()).toString("base64"),o=this._buildArgs([r],t),s=await this._rpcRequest("getFeeForMessage",o),i=H(s,xe(K(k())));if("error"in i)throw new X(i.error,"failed to get fee for message");if(i.result===null)throw new Error("invalid blockhash");return i.result}async getRecentPrioritizationFees(e){let t=e?.lockedWritableAccounts?.map(i=>i.toBase58()),r=t?.length?[t]:[],o=await this._rpcRequest("getRecentPrioritizationFees",r),s=H(o,iw);if("error"in s)throw new X(s.error,"failed to get recent prioritization fees");return s.result}async getRecentBlockhash(e){try{return(await this.getRecentBlockhashAndContext(e)).value}catch(t){throw new Error("failed to get recent blockhash: "+t)}}async getLatestBlockhash(e){try{return(await this.getLatestBlockhashAndContext(e)).value}catch(t){throw new Error("failed to get recent blockhash: "+t)}}async getLatestBlockhashAndContext(e){let{commitment:t,config:r}=Ae(e),o=this._buildArgs([],t,void 0,r),s=await this._rpcRequest("getLatestBlockhash",o),i=H(s,Vw);if("error"in i)throw new X(i.error,"failed to get latest blockhash");return i.result}async isBlockhashValid(e,t){let{commitment:r,config:o}=Ae(t),s=this._buildArgs([e],r,void 0,o),i=await this._rpcRequest("isBlockhashValid",s),u=H(i,Gw);if("error"in u)throw new X(u.error,"failed to determine if the blockhash `"+e+"`is valid");return u.result}async getVersion(){let e=await this._rpcRequest("getVersion",[]),t=H(e,se(Jb));if("error"in t)throw new X(t.error,"failed to get version");return t.result}async getGenesisHash(){let e=await this._rpcRequest("getGenesisHash",[]),t=H(e,se($()));if("error"in t)throw new X(t.error,"failed to get genesis hash");return t.result}async getBlock(e,t){let{commitment:r,config:o}=Ae(t),s=this._buildArgsAtLeastConfirmed([e],r,void 0,o),i=await this._rpcRequest("getBlock",s);try{switch(o?.transactionDetails){case"accounts":{let u=H(i,zw);if("error"in u)throw u.error;return u.result}case"none":{let u=H(i,Hw);if("error"in u)throw u.error;return u.result}default:{let u=H(i,$w);if("error"in u)throw u.error;let{result:f}=u;return f?{...f,transactions:f.transactions.map(({transaction:y,meta:d,version:_})=>({meta:d,transaction:{...y,message:gc(_,y.message)},version:_}))}:null}}}catch(u){throw new X(u,"failed to get confirmed block")}}async getParsedBlock(e,t){let{commitment:r,config:o}=Ae(t),s=this._buildArgsAtLeastConfirmed([e],r,"jsonParsed",o),i=await this._rpcRequest("getBlock",s);try{switch(o?.transactionDetails){case"accounts":{let u=H(i,Ww);if("error"in u)throw u.error;return u.result}case"none":{let u=H(i,Kw);if("error"in u)throw u.error;return u.result}default:{let u=H(i,Fw);if("error"in u)throw u.error;return u.result}}}catch(u){throw new X(u,"failed to get block")}}async getBlockProduction(e){let t,r;if(typeof e=="string")r=e;else if(e){let{commitment:u,...f}=e;r=u,t=f}let o=this._buildArgs([],r,"base64",t),s=await this._rpcRequest("getBlockProduction",o),i=H(s,ew);if("error"in i)throw new X(i.error,"failed to get block production information");return i.result}async getTransaction(e,t){let{commitment:r,config:o}=Ae(t),s=this._buildArgsAtLeastConfirmed([e],r,void 0,o),i=await this._rpcRequest("getTransaction",s),u=H(i,_c);if("error"in u)throw new X(u.error,"failed to get transaction");let f=u.result;return f&&{...f,transaction:{...f.transaction,message:gc(f.version,f.transaction.message)}}}async getParsedTransaction(e,t){let{commitment:r,config:o}=Ae(t),s=this._buildArgsAtLeastConfirmed([e],r,"jsonParsed",o),i=await this._rpcRequest("getTransaction",s),u=H(i,Vo);if("error"in u)throw new X(u.error,"failed to get transaction");return u.result}async getParsedTransactions(e,t){let{commitment:r,config:o}=Ae(t),s=e.map(f=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([f],r,"jsonParsed",o)}));return(await this._rpcBatchRequest(s)).map(f=>{let y=H(f,Vo);if("error"in y)throw new X(y.error,"failed to get transactions");return y.result})}async getTransactions(e,t){let{commitment:r,config:o}=Ae(t),s=e.map(f=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([f],r,void 0,o)}));return(await this._rpcBatchRequest(s)).map(f=>{let y=H(f,_c);if("error"in y)throw new X(y.error,"failed to get transactions");let d=y.result;return d&&{...d,transaction:{...d.transaction,message:gc(d.version,d.transaction.message)}}})}async getConfirmedBlock(e,t){let r=this._buildArgsAtLeastConfirmed([e],t),o=await this._rpcRequest("getConfirmedBlock",r),s=H(o,qw);if("error"in s)throw new X(s.error,"failed to get confirmed block");let i=s.result;if(!i)throw new Error("Confirmed block "+e+" not found");let u={...i,transactions:i.transactions.map(({transaction:f,meta:y})=>{let d=new $t(f.message);return{meta:y,transaction:{...f,message:d}}})};return{...u,transactions:u.transactions.map(({transaction:f,meta:y})=>({meta:y,transaction:de.populate(f.message,f.signatures)}))}}async getBlocks(e,t,r){let o=this._buildArgsAtLeastConfirmed(t!==void 0?[e,t]:[e],r),s=await this._rpcRequest("getBlocks",o),i=H(s,se(W(k())));if("error"in i)throw new X(i.error,"failed to get blocks");return i.result}async getBlockSignatures(e,t){let r=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:"signatures",rewards:!1}),o=await this._rpcRequest("getBlock",r),s=H(o,ph);if("error"in s)throw new X(s.error,"failed to get block");let i=s.result;if(!i)throw new Error("Block "+e+" not found");return i}async getConfirmedBlockSignatures(e,t){let r=this._buildArgsAtLeastConfirmed([e],t,void 0,{transactionDetails:"signatures",rewards:!1}),o=await this._rpcRequest("getConfirmedBlock",r),s=H(o,ph);if("error"in s)throw new X(s.error,"failed to get confirmed block");let i=s.result;if(!i)throw new Error("Confirmed block "+e+" not found");return i}async getConfirmedTransaction(e,t){let r=this._buildArgsAtLeastConfirmed([e],t),o=await this._rpcRequest("getConfirmedTransaction",r),s=H(o,_c);if("error"in s)throw new X(s.error,"failed to get transaction");let i=s.result;if(!i)return i;let u=new $t(i.transaction.message),f=i.transaction.signatures;return{...i,transaction:de.populate(u,f)}}async getParsedConfirmedTransaction(e,t){let r=this._buildArgsAtLeastConfirmed([e],t,"jsonParsed"),o=await this._rpcRequest("getConfirmedTransaction",r),s=H(o,Vo);if("error"in s)throw new X(s.error,"failed to get confirmed transaction");return s.result}async getParsedConfirmedTransactions(e,t){let r=e.map(i=>({methodName:"getConfirmedTransaction",args:this._buildArgsAtLeastConfirmed([i],t,"jsonParsed")}));return(await this._rpcBatchRequest(r)).map(i=>{let u=H(i,Vo);if("error"in u)throw new X(u.error,"failed to get confirmed transactions");return u.result})}async getConfirmedSignaturesForAddress(e,t,r){let o={},s=await this.getFirstAvailableBlock();for(;!("until"in o)&&(t--,!(t<=0||t<s));)try{let f=await this.getConfirmedBlockSignatures(t,"finalized");f.signatures.length>0&&(o.until=f.signatures[f.signatures.length-1].toString())}catch(f){if(f instanceof Error&&f.message.includes("skipped"))continue;throw f}let i=await this.getSlot("finalized");for(;!("before"in o)&&(r++,!(r>i));)try{let f=await this.getConfirmedBlockSignatures(r);f.signatures.length>0&&(o.before=f.signatures[f.signatures.length-1].toString())}catch(f){if(f instanceof Error&&f.message.includes("skipped"))continue;throw f}return(await this.getConfirmedSignaturesForAddress2(e,o)).map(f=>f.signature)}async getConfirmedSignaturesForAddress2(e,t,r){let o=this._buildArgsAtLeastConfirmed([e.toBase58()],r,void 0,t),s=await this._rpcRequest("getConfirmedSignaturesForAddress2",o),i=H(s,ww);if("error"in i)throw new X(i.error,"failed to get confirmed signatures for address");return i.result}async getSignaturesForAddress(e,t,r){let o=this._buildArgsAtLeastConfirmed([e.toBase58()],r,void 0,t),s=await this._rpcRequest("getSignaturesForAddress",o),i=H(s,Rw);if("error"in i)throw new X(i.error,"failed to get signatures for address");return i.result}async getAddressLookupTable(e,t){let{context:r,value:o}=await this.getAccountInfoAndContext(e,t),s=null;return o!==null&&(s=new cs({key:e,state:cs.deserialize(o.data)})),{context:r,value:s}}async getNonceAndContext(e,t){let{context:r,value:o}=await this.getAccountInfoAndContext(e,t),s=null;return o!==null&&(s=Qo.fromAccountData(o.data)),{context:r,value:s}}async getNonce(e,t){return await this.getNonceAndContext(e,t).then(r=>r.value).catch(r=>{throw new Error("failed to get nonce for account "+e.toBase58()+": "+r)})}async requestAirdrop(e,t){let r=await this._rpcRequest("requestAirdrop",[e.toBase58(),t]),o=H(r,Zw);if("error"in o)throw new X(o.error,`airdrop to ${e.toBase58()} failed`);return o.result}async _blockhashWithExpiryBlockHeight(e){if(!e){for(;this._pollingBlockhash;)await Lr(100);let r=Date.now()-this._blockhashInfo.lastFetch>=Dh;if(this._blockhashInfo.latestBlockhash!==null&&!r)return this._blockhashInfo.latestBlockhash}return await this._pollNewBlockhash()}async _pollNewBlockhash(){this._pollingBlockhash=!0;try{let e=Date.now(),t=this._blockhashInfo.latestBlockhash,r=t?t.blockhash:null;for(let o=0;o<50;o++){let s=await this.getLatestBlockhash("finalized");if(r!==s.blockhash)return this._blockhashInfo={latestBlockhash:s,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},s;await Lr(Nh/2)}throw new Error(`Unable to obtain a new blockhash after ${Date.now()-e}ms`)}finally{this._pollingBlockhash=!1}}async getStakeMinimumDelegation(e){let{commitment:t,config:r}=Ae(e),o=this._buildArgs([],t,"base64",r),s=await this._rpcRequest("getStakeMinimumDelegation",o),i=H(s,xe(k()));if("error"in i)throw new X(i.error,"failed to get stake minimum delegation");return i.result}async simulateTransaction(e,t,r){if("message"in e){let A=e.serialize(),C=Q.from(A).toString("base64");if(Array.isArray(t)||r!==void 0)throw new Error("Invalid arguments");let x=t||{};x.encoding="base64","commitment"in x||(x.commitment=this.commitment),t&&typeof t=="object"&&"innerInstructions"in t&&(x.innerInstructions=t.innerInstructions);let w=[C,x],L=await this._rpcRequest("simulateTransaction",w),z=H(L,dh);if("error"in z)throw new Error("failed to simulate transaction: "+z.error.message);return z.result}let o;if(e instanceof de){let S=e;o=new de,o.feePayer=S.feePayer,o.instructions=e.instructions,o.nonceInfo=S.nonceInfo,o.signatures=S.signatures}else o=de.populate(e),o._message=o._json=void 0;if(t!==void 0&&!Array.isArray(t))throw new Error("Invalid arguments");let s=t;if(o.nonceInfo&&s)o.sign(...s);else{let S=this._disableBlockhashCaching;for(;;){let A=await this._blockhashWithExpiryBlockHeight(S);if(o.lastValidBlockHeight=A.lastValidBlockHeight,o.recentBlockhash=A.blockhash,!s)break;if(o.sign(...s),!o.signature)throw new Error("!signature");let C=o.signature.toString("base64");if(!this._blockhashInfo.simulatedSignatures.includes(C)&&!this._blockhashInfo.transactionSignatures.includes(C)){this._blockhashInfo.simulatedSignatures.push(C);break}else S=!0}}let i=o._compile(),u=i.serialize(),y=o._serialize(u).toString("base64"),d={encoding:"base64",commitment:this.commitment};if(r){let S=(Array.isArray(r)?r:i.nonProgramIds()).map(A=>A.toBase58());d.accounts={encoding:"base64",addresses:S}}s&&(d.sigVerify=!0),t&&typeof t=="object"&&"innerInstructions"in t&&(d.innerInstructions=t.innerInstructions);let _=[y,d],E=await this._rpcRequest("simulateTransaction",_),R=H(E,dh);if("error"in R){let S;if("data"in R.error&&(S=R.error.data.logs,S&&Array.isArray(S))){let A=`
|
19
|
+
`,C=A+S.join(A);console.error(R.error.message,C)}throw new _t({action:"simulate",signature:"",transactionMessage:R.error.message,logs:S})}return R.result}async sendTransaction(e,t,r){if("version"in e){if(t&&Array.isArray(t))throw new Error("Invalid arguments");let i=e.serialize();return await this.sendRawTransaction(i,t)}if(t===void 0||!Array.isArray(t))throw new Error("Invalid arguments");let o=t;if(e.nonceInfo)e.sign(...o);else{let i=this._disableBlockhashCaching;for(;;){let u=await this._blockhashWithExpiryBlockHeight(i);if(e.lastValidBlockHeight=u.lastValidBlockHeight,e.recentBlockhash=u.blockhash,e.sign(...o),!e.signature)throw new Error("!signature");let f=e.signature.toString("base64");if(this._blockhashInfo.transactionSignatures.includes(f))i=!0;else{this._blockhashInfo.transactionSignatures.push(f);break}}}let s=e.serialize();return await this.sendRawTransaction(s,r)}async sendRawTransaction(e,t){let r=oe(e).toString("base64");return await this.sendEncodedTransaction(r,t)}async sendEncodedTransaction(e,t){let r={encoding:"base64"},o=t&&t.skipPreflight,s=o===!0?"processed":t&&t.preflightCommitment||this.commitment;t&&t.maxRetries!=null&&(r.maxRetries=t.maxRetries),t&&t.minContextSlot!=null&&(r.minContextSlot=t.minContextSlot),o&&(r.skipPreflight=o),s&&(r.preflightCommitment=s);let i=[e,r],u=await this._rpcRequest("sendTransaction",i),f=H(u,Qw);if("error"in f){let y;throw"data"in f.error&&(y=f.error.data.logs),new _t({action:o?"send":"simulate",signature:"",transactionMessage:f.error.message,logs:y})}return f.result}_wsOnOpen(){this._rpcWebSocketConnected=!0,this._rpcWebSocketHeartbeat=setInterval(()=>{(async()=>{try{await this._rpcWebSocket.notify("ping")}catch{}})()},5e3),this._updateSubscriptions()}_wsOnError(e){this._rpcWebSocketConnected=!1,console.error("ws error:",e.message)}_wsOnClose(e){if(this._rpcWebSocketConnected=!1,this._rpcWebSocketGeneration=(this._rpcWebSocketGeneration+1)%Number.MAX_SAFE_INTEGER,this._rpcWebSocketIdleTimeout&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null),this._rpcWebSocketHeartbeat&&(clearInterval(this._rpcWebSocketHeartbeat),this._rpcWebSocketHeartbeat=null),e===1e3){this._updateSubscriptions();return}this._subscriptionCallbacksByServerSubscriptionId={},Object.entries(this._subscriptionsByHash).forEach(([t,r])=>{this._setSubscription(t,{...r,state:"pending"})})}_setSubscription(e,t){let r=this._subscriptionsByHash[e]?.state;if(this._subscriptionsByHash[e]=t,r!==t.state){let o=this._subscriptionStateChangeCallbacksByHash[e];o&&o.forEach(s=>{try{s(t.state)}catch{}})}}_onSubscriptionStateChange(e,t){let r=this._subscriptionHashByClientSubscriptionId[e];if(r==null)return()=>{};let o=this._subscriptionStateChangeCallbacksByHash[r]||=new Set;return o.add(t),()=>{o.delete(t),o.size===0&&delete this._subscriptionStateChangeCallbacksByHash[r]}}async _updateSubscriptions(){if(Object.keys(this._subscriptionsByHash).length===0){this._rpcWebSocketConnected&&(this._rpcWebSocketConnected=!1,this._rpcWebSocketIdleTimeout=setTimeout(()=>{this._rpcWebSocketIdleTimeout=null;try{this._rpcWebSocket.close()}catch(r){r instanceof Error&&console.log(`Error when closing socket connection: ${r.message}`)}},500));return}if(this._rpcWebSocketIdleTimeout!==null&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketConnected=!0),!this._rpcWebSocketConnected){this._rpcWebSocket.connect();return}let e=this._rpcWebSocketGeneration,t=a(()=>e===this._rpcWebSocketGeneration,"isCurrentConnectionStillActive");await Promise.all(Object.keys(this._subscriptionsByHash).map(async r=>{let o=this._subscriptionsByHash[r];if(o!==void 0)switch(o.state){case"pending":case"unsubscribed":if(o.callbacks.size===0){delete this._subscriptionsByHash[r],o.state==="unsubscribed"&&delete this._subscriptionCallbacksByServerSubscriptionId[o.serverSubscriptionId],await this._updateSubscriptions();return}await(async()=>{let{args:s,method:i}=o;try{this._setSubscription(r,{...o,state:"subscribing"});let u=await this._rpcWebSocket.call(i,s);this._setSubscription(r,{...o,serverSubscriptionId:u,state:"subscribed"}),this._subscriptionCallbacksByServerSubscriptionId[u]=o.callbacks,await this._updateSubscriptions()}catch(u){if(console.error(`Received ${u instanceof Error?"":"JSON-RPC "}error calling \`${i}\``,{args:s,error:u}),!t())return;this._setSubscription(r,{...o,state:"pending"}),await this._updateSubscriptions()}})();break;case"subscribed":o.callbacks.size===0&&await(async()=>{let{serverSubscriptionId:s,unsubscribeMethod:i}=o;if(this._subscriptionsAutoDisposedByRpc.has(s))this._subscriptionsAutoDisposedByRpc.delete(s);else{this._setSubscription(r,{...o,state:"unsubscribing"}),this._setSubscription(r,{...o,state:"unsubscribing"});try{await this._rpcWebSocket.call(i,[s])}catch(u){if(u instanceof Error&&console.error(`${i} error:`,u.message),!t())return;this._setSubscription(r,{...o,state:"subscribed"}),await this._updateSubscriptions();return}}this._setSubscription(r,{...o,state:"unsubscribed"}),await this._updateSubscriptions()})();break}}))}_handleServerNotification(e,t){let r=this._subscriptionCallbacksByServerSubscriptionId[e];r!==void 0&&r.forEach(o=>{try{o(...t)}catch(s){console.error(s)}})}_wsOnAccountNotification(e){let{result:t,subscription:r}=H(e,Ew);this._handleServerNotification(r,[t.value,t.context])}_makeSubscription(e,t){let r=this._nextClientSubscriptionId++,o=uh([e.method,t]),s=this._subscriptionsByHash[o];return s===void 0?this._subscriptionsByHash[o]={...e,args:t,callbacks:new Set([e.callback]),state:"pending"}:s.callbacks.add(e.callback),this._subscriptionHashByClientSubscriptionId[r]=o,this._subscriptionDisposeFunctionsByClientSubscriptionId[r]=async()=>{delete this._subscriptionDisposeFunctionsByClientSubscriptionId[r],delete this._subscriptionHashByClientSubscriptionId[r];let i=this._subscriptionsByHash[o];ye(i!==void 0,`Could not find a \`Subscription\` when tearing down client subscription #${r}`),i.callbacks.delete(e.callback),await this._updateSubscriptions()},this._updateSubscriptions(),r}onAccountChange(e,t,r){let{commitment:o,config:s}=Ae(r),i=this._buildArgs([e.toBase58()],o||this._commitment||"finalized","base64",s);return this._makeSubscription({callback:t,method:"accountSubscribe",unsubscribeMethod:"accountUnsubscribe"},i)}async removeAccountChangeListener(e){await this._unsubscribeClientSubscription(e,"account change")}_wsOnProgramAccountNotification(e){let{result:t,subscription:r}=H(e,Aw);this._handleServerNotification(r,[{accountId:t.value.pubkey,accountInfo:t.value.account},t.context])}onProgramAccountChange(e,t,r,o){let{commitment:s,config:i}=Ae(r),u=this._buildArgs([e.toBase58()],s||this._commitment||"finalized","base64",i||(o?{filters:fh(o)}:void 0));return this._makeSubscription({callback:t,method:"programSubscribe",unsubscribeMethod:"programUnsubscribe"},u)}async removeProgramAccountChangeListener(e){await this._unsubscribeClientSubscription(e,"program account change")}onLogs(e,t,r){let o=this._buildArgs([typeof e=="object"?{mentions:[e.toString()]}:e],r||this._commitment||"finalized");return this._makeSubscription({callback:t,method:"logsSubscribe",unsubscribeMethod:"logsUnsubscribe"},o)}async removeOnLogsListener(e){await this._unsubscribeClientSubscription(e,"logs")}_wsOnLogsNotification(e){let{result:t,subscription:r}=H(e,t0);this._handleServerNotification(r,[t.value,t.context])}_wsOnSlotNotification(e){let{result:t,subscription:r}=H(e,Iw);this._handleServerNotification(r,[t])}onSlotChange(e){return this._makeSubscription({callback:e,method:"slotSubscribe",unsubscribeMethod:"slotUnsubscribe"},[])}async removeSlotChangeListener(e){await this._unsubscribeClientSubscription(e,"slot change")}_wsOnSlotUpdatesNotification(e){let{result:t,subscription:r}=H(e,Tw);this._handleServerNotification(r,[t])}onSlotUpdate(e){return this._makeSubscription({callback:e,method:"slotsUpdatesSubscribe",unsubscribeMethod:"slotsUpdatesUnsubscribe"},[])}async removeSlotUpdateListener(e){await this._unsubscribeClientSubscription(e,"slot update")}async _unsubscribeClientSubscription(e,t){let r=this._subscriptionDisposeFunctionsByClientSubscriptionId[e];r?await r():console.warn(`Ignored unsubscribe request because an active subscription with id \`${e}\` for '${t}' events could not be found.`)}_buildArgs(e,t,r,o){let s=t||this._commitment;if(s||r||o){let i={};r&&(i.encoding=r),s&&(i.commitment=s),o&&(i=Object.assign(i,o)),e.push(i)}return e}_buildArgsAtLeastConfirmed(e,t,r,o){let s=t||this._commitment;if(s&&!["confirmed","finalized"].includes(s))throw new Error("Using Connection with default commitment: `"+this._commitment+"`, but method requires at least `confirmed`");return this._buildArgs(e,t,r,o)}_wsOnSignatureNotification(e){let{result:t,subscription:r}=H(e,Ow);t.value!=="receivedSignature"&&this._subscriptionsAutoDisposedByRpc.add(r),this._handleServerNotification(r,t.value==="receivedSignature"?[{type:"received"},t.context]:[{type:"status",result:t.value},t.context])}onSignature(e,t,r){let o=this._buildArgs([e],r||this._commitment||"finalized"),s=this._makeSubscription({callback:a((i,u)=>{if(i.type==="status"){t(i.result,u);try{this.removeSignatureListener(s)}catch{}}},"callback"),method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},o);return s}onSignatureWithOptions(e,t,r){let{commitment:o,...s}={...r,commitment:r&&r.commitment||this._commitment||"finalized"},i=this._buildArgs([e],o,void 0,s),u=this._makeSubscription({callback:a((f,y)=>{t(f,y);try{this.removeSignatureListener(u)}catch{}},"callback"),method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},i);return u}async removeSignatureListener(e){await this._unsubscribeClientSubscription(e,"signature result")}_wsOnRootNotification(e){let{result:t,subscription:r}=H(e,Nw);this._handleServerNotification(r,[t])}onRootChange(e){return this._makeSubscription({callback:e,method:"rootSubscribe",unsubscribeMethod:"rootUnsubscribe"},[])}async removeRootChangeListener(e){await this._unsubscribeClientSubscription(e,"root change")}},dn=class n{static{a(this,"Keypair")}constructor(e){this._keypair=void 0,this._keypair=e??Qd()}static generate(){return new n(Qd())}static fromSecretKey(e,t){if(e.byteLength!==64)throw new Error("bad secret key size");let r=e.slice(32,64);if(!t||!t.skipValidation){let o=e.slice(0,32),s=Xo(o);for(let i=0;i<32;i++)if(r[i]!==s[i])throw new Error("provided secretKey is invalid")}return new n({publicKey:r,secretKey:e})}static fromSeed(e){let t=Xo(e),r=new Uint8Array(64);return r.set(e),r.set(t,32),new n({publicKey:t,secretKey:r})}get publicKey(){return new U(this._keypair.publicKey)}get secretKey(){return new Uint8Array(this._keypair.secretKey)}},Xt=Object.freeze({CreateLookupTable:{index:0,layout:g.struct([g.u32("instruction"),un("recentSlot"),g.u8("bumpSeed")])},FreezeLookupTable:{index:1,layout:g.struct([g.u32("instruction")])},ExtendLookupTable:{index:2,layout:g.struct([g.u32("instruction"),un(),g.seq(ue(),g.offset(g.u32(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:g.struct([g.u32("instruction")])},CloseLookupTable:{index:4,layout:g.struct([g.u32("instruction")])}}),Lc=class{static{a(this,"AddressLookupTableInstruction")}constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);let r=g.u32("instruction").decode(e.data),o;for(let[s,i]of Object.entries(Xt))if(i.index==r){o=s;break}if(!o)throw new Error("Invalid Instruction. Should be a LookupTable Instruction");return o}static decodeCreateLookupTable(e){this.checkProgramId(e.programId),this.checkKeysLength(e.keys,4);let{recentSlot:t}=we(Xt.CreateLookupTable,e.data);return{authority:e.keys[1].pubkey,payer:e.keys[2].pubkey,recentSlot:Number(t)}}static decodeExtendLookupTable(e){if(this.checkProgramId(e.programId),e.keys.length<2)throw new Error(`invalid instruction; found ${e.keys.length} keys, expected at least 2`);let{addresses:t}=we(Xt.ExtendLookupTable,e.data);return{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey,payer:e.keys.length>2?e.keys[2].pubkey:void 0,addresses:t.map(r=>new U(r))}}static decodeCloseLookupTable(e){return this.checkProgramId(e.programId),this.checkKeysLength(e.keys,3),{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey,recipient:e.keys[2].pubkey}}static decodeFreezeLookupTable(e){return this.checkProgramId(e.programId),this.checkKeysLength(e.keys,2),{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey}}static decodeDeactivateLookupTable(e){return this.checkProgramId(e.programId),this.checkKeysLength(e.keys,2),{lookupTable:e.keys[0].pubkey,authority:e.keys[1].pubkey}}static checkProgramId(e){if(!e.equals(ls.programId))throw new Error("invalid instruction; programId is not AddressLookupTable Program")}static checkKeysLength(e,t){if(e.length<t)throw new Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}},ls=class{static{a(this,"AddressLookupTableProgram")}constructor(){}static createLookupTable(e){let[t,r]=U.findProgramAddressSync([e.authority.toBuffer(),(0,ds.toBufferLE)(BigInt(e.recentSlot),8)],this.programId),o=Xt.CreateLookupTable,s=le(o,{recentSlot:BigInt(e.recentSlot),bumpSeed:r}),i=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1},{pubkey:e.payer,isSigner:!0,isWritable:!0},{pubkey:Ue.programId,isSigner:!1,isWritable:!1}];return[new me({programId:this.programId,keys:i,data:s}),t]}static freezeLookupTable(e){let t=Xt.FreezeLookupTable,r=le(t),o=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new me({programId:this.programId,keys:o,data:r})}static extendLookupTable(e){let t=Xt.ExtendLookupTable,r=le(t,{addresses:e.addresses.map(s=>s.toBytes())}),o=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return e.payer&&o.push({pubkey:e.payer,isSigner:!0,isWritable:!0},{pubkey:Ue.programId,isSigner:!1,isWritable:!1}),new me({programId:this.programId,keys:o,data:r})}static deactivateLookupTable(e){let t=Xt.DeactivateLookupTable,r=le(t),o=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1}];return new me({programId:this.programId,keys:o,data:r})}static closeLookupTable(e){let t=Xt.CloseLookupTable,r=le(t),o=[{pubkey:e.lookupTable,isSigner:!1,isWritable:!0},{pubkey:e.authority,isSigner:!0,isWritable:!1},{pubkey:e.recipient,isSigner:!1,isWritable:!0}];return new me({programId:this.programId,keys:o,data:r})}};ls.programId=new U("AddressLookupTab1e1111111111111111111111111");Pc=class{static{a(this,"ComputeBudgetInstruction")}constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);let r=g.u8("instruction").decode(e.data),o;for(let[s,i]of Object.entries(Ut))if(i.index==r){o=s;break}if(!o)throw new Error("Instruction type incorrect; not a ComputeBudgetInstruction");return o}static decodeRequestUnits(e){this.checkProgramId(e.programId);let{units:t,additionalFee:r}=we(Ut.RequestUnits,e.data);return{units:t,additionalFee:r}}static decodeRequestHeapFrame(e){this.checkProgramId(e.programId);let{bytes:t}=we(Ut.RequestHeapFrame,e.data);return{bytes:t}}static decodeSetComputeUnitLimit(e){this.checkProgramId(e.programId);let{units:t}=we(Ut.SetComputeUnitLimit,e.data);return{units:t}}static decodeSetComputeUnitPrice(e){this.checkProgramId(e.programId);let{microLamports:t}=we(Ut.SetComputeUnitPrice,e.data);return{microLamports:t}}static checkProgramId(e){if(!e.equals(fs.programId))throw new Error("invalid instruction; programId is not ComputeBudgetProgram")}},Ut=Object.freeze({RequestUnits:{index:0,layout:g.struct([g.u8("instruction"),g.u32("units"),g.u32("additionalFee")])},RequestHeapFrame:{index:1,layout:g.struct([g.u8("instruction"),g.u32("bytes")])},SetComputeUnitLimit:{index:2,layout:g.struct([g.u8("instruction"),g.u32("units")])},SetComputeUnitPrice:{index:3,layout:g.struct([g.u8("instruction"),un("microLamports")])}}),fs=class{static{a(this,"ComputeBudgetProgram")}constructor(){}static requestUnits(e){let t=Ut.RequestUnits,r=le(t,e);return new me({keys:[],programId:this.programId,data:r})}static requestHeapFrame(e){let t=Ut.RequestHeapFrame,r=le(t,e);return new me({keys:[],programId:this.programId,data:r})}static setComputeUnitLimit(e){let t=Ut.SetComputeUnitLimit,r=le(t,e);return new me({keys:[],programId:this.programId,data:r})}static setComputeUnitPrice(e){let t=Ut.SetComputeUnitPrice,r=le(t,{microLamports:BigInt(e.microLamports)});return new me({keys:[],programId:this.programId,data:r})}};fs.programId=new U("ComputeBudget111111111111111111111111111111");yh=64,mh=32,gh=64,_h=g.struct([g.u8("numSignatures"),g.u8("padding"),g.u16("signatureOffset"),g.u16("signatureInstructionIndex"),g.u16("publicKeyOffset"),g.u16("publicKeyInstructionIndex"),g.u16("messageDataOffset"),g.u16("messageDataSize"),g.u16("messageInstructionIndex")]),ri=class n{static{a(this,"Ed25519Program")}constructor(){}static createInstructionWithPublicKey(e){let{publicKey:t,message:r,signature:o,instructionIndex:s}=e;ye(t.length===mh,`Public Key must be ${mh} bytes but received ${t.length} bytes`),ye(o.length===gh,`Signature must be ${gh} bytes but received ${o.length} bytes`);let i=_h.span,u=i+t.length,f=u+o.length,y=1,d=Q.alloc(f+r.length),_=s??65535;return _h.encode({numSignatures:y,padding:0,signatureOffset:u,signatureInstructionIndex:_,publicKeyOffset:i,publicKeyInstructionIndex:_,messageDataOffset:f,messageDataSize:r.length,messageInstructionIndex:_},d),d.fill(t,i),d.fill(o,u),d.fill(r,f),new me({keys:[],programId:n.programId,data:d})}static createInstructionWithPrivateKey(e){let{privateKey:t,message:r,instructionIndex:o}=e;ye(t.length===yh,`Private key must be ${yh} bytes but received ${t.length} bytes`);try{let s=dn.fromSecretKey(t),i=s.publicKey.toBytes(),u=$c(r,s.secretKey);return this.createInstructionWithPublicKey({publicKey:i,message:r,signature:u,instructionIndex:o})}catch(s){throw new Error(`Error creating instruction; ${s}`)}}};ri.programId=new U("Ed25519SigVerify111111111111111111111111111");n0=a((n,e)=>{let t=Ys.sign(n,e);return[t.toCompactRawBytes(),t.recovery]},"ecdsaSign");Ys.utils.isValidPrivateKey;s0=Ys.getPublicKey,bh=32,bc=20,wh=64,o0=11,wc=g.struct([g.u8("numSignatures"),g.u16("signatureOffset"),g.u8("signatureInstructionIndex"),g.u16("ethAddressOffset"),g.u8("ethAddressInstructionIndex"),g.u16("messageDataOffset"),g.u16("messageDataSize"),g.u8("messageInstructionIndex"),g.blob(20,"ethAddress"),g.blob(64,"signature"),g.u8("recoveryId")]),ni=class n{static{a(this,"Secp256k1Program")}constructor(){}static publicKeyToEthAddress(e){ye(e.length===wh,`Public key must be ${wh} bytes but received ${e.length} bytes`);try{return Q.from(ca(oe(e))).slice(-bc)}catch(t){throw new Error(`Error constructing Ethereum address: ${t}`)}}static createInstructionWithPublicKey(e){let{publicKey:t,message:r,signature:o,recoveryId:s,instructionIndex:i}=e;return n.createInstructionWithEthAddress({ethAddress:n.publicKeyToEthAddress(t),message:r,signature:o,recoveryId:s,instructionIndex:i})}static createInstructionWithEthAddress(e){let{ethAddress:t,message:r,signature:o,recoveryId:s,instructionIndex:i=0}=e,u;typeof t=="string"?t.startsWith("0x")?u=Q.from(t.substr(2),"hex"):u=Q.from(t,"hex"):u=t,ye(u.length===bc,`Address must be ${bc} bytes but received ${u.length} bytes`);let f=1+o0,y=f,d=f+u.length,_=d+o.length+1,E=1,R=Q.alloc(wc.span+r.length);return wc.encode({numSignatures:E,signatureOffset:d,signatureInstructionIndex:i,ethAddressOffset:y,ethAddressInstructionIndex:i,messageDataOffset:_,messageDataSize:r.length,messageInstructionIndex:i,signature:oe(o),ethAddress:oe(u),recoveryId:s},R),R.fill(oe(r),wc.span),new me({keys:[],programId:n.programId,data:R})}static createInstructionWithPrivateKey(e){let{privateKey:t,message:r,instructionIndex:o}=e;ye(t.length===bh,`Private key must be ${bh} bytes but received ${t.length} bytes`);try{let s=oe(t),i=s0(s,!1).slice(1),u=Q.from(ca(oe(r))),[f,y]=n0(u,s);return this.createInstructionWithPublicKey({publicKey:i,message:r,signature:f,recoveryId:y,instructionIndex:o})}catch(s){throw new Error(`Error creating instruction; ${s}`)}}};ni.programId=new U("KeccakSecp256k11111111111111111111111111111");Gh=new U("StakeConfig11111111111111111111111111111111"),si=class{static{a(this,"Authorized")}constructor(e,t){this.staker=void 0,this.withdrawer=void 0,this.staker=e,this.withdrawer=t}},Ur=class{static{a(this,"Lockup")}constructor(e,t,r){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=e,this.epoch=t,this.custodian=r}};Vh=Ur;Ur.default=new Vh(0,0,U.default);Bc=class{static{a(this,"StakeInstruction")}constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);let r=g.u32("instruction").decode(e.data),o;for(let[s,i]of Object.entries(De))if(i.index==r){o=s;break}if(!o)throw new Error("Instruction type incorrect; not a StakeInstruction");return o}static decodeInitialize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);let{authorized:t,lockup:r}=we(De.Initialize,e.data);return{stakePubkey:e.keys[0].pubkey,authorized:new si(new U(t.staker),new U(t.withdrawer)),lockup:new Ur(r.unixTimestamp,r.epoch,new U(r.custodian))}}static decodeDelegate(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,6),we(De.Delegate,e.data),{stakePubkey:e.keys[0].pubkey,votePubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[5].pubkey}}static decodeAuthorize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);let{newAuthorized:t,stakeAuthorizationType:r}=we(De.Authorize,e.data),o={stakePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey,newAuthorizedPubkey:new U(t),stakeAuthorizationType:{index:r}};return e.keys.length>3&&(o.custodianPubkey=e.keys[3].pubkey),o}static decodeAuthorizeWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,2);let{newAuthorized:t,stakeAuthorizationType:r,authoritySeed:o,authorityOwner:s}=we(De.AuthorizeWithSeed,e.data),i={stakePubkey:e.keys[0].pubkey,authorityBase:e.keys[1].pubkey,authoritySeed:o,authorityOwner:new U(s),newAuthorizedPubkey:new U(t),stakeAuthorizationType:{index:r}};return e.keys.length>3&&(i.custodianPubkey=e.keys[3].pubkey),i}static decodeSplit(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);let{lamports:t}=we(De.Split,e.data);return{stakePubkey:e.keys[0].pubkey,splitStakePubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[2].pubkey,lamports:t}}static decodeMerge(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3),we(De.Merge,e.data),{stakePubkey:e.keys[0].pubkey,sourceStakePubKey:e.keys[1].pubkey,authorizedPubkey:e.keys[4].pubkey}}static decodeWithdraw(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,5);let{lamports:t}=we(De.Withdraw,e.data),r={stakePubkey:e.keys[0].pubkey,toPubkey:e.keys[1].pubkey,authorizedPubkey:e.keys[4].pubkey,lamports:t};return e.keys.length>5&&(r.custodianPubkey=e.keys[5].pubkey),r}static decodeDeactivate(e){return this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3),we(De.Deactivate,e.data),{stakePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey}}static checkProgramId(e){if(!e.equals(hn.programId))throw new Error("invalid instruction; programId is not StakeProgram")}static checkKeyLength(e,t){if(e.length<t)throw new Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}},De=Object.freeze({Initialize:{index:0,layout:g.struct([g.u32("instruction"),ub(),lb()])},Authorize:{index:1,layout:g.struct([g.u32("instruction"),ue("newAuthorized"),g.u32("stakeAuthorizationType")])},Delegate:{index:2,layout:g.struct([g.u32("instruction")])},Split:{index:3,layout:g.struct([g.u32("instruction"),g.ns64("lamports")])},Withdraw:{index:4,layout:g.struct([g.u32("instruction"),g.ns64("lamports")])},Deactivate:{index:5,layout:g.struct([g.u32("instruction")])},Merge:{index:7,layout:g.struct([g.u32("instruction")])},AuthorizeWithSeed:{index:8,layout:g.struct([g.u32("instruction"),ue("newAuthorized"),g.u32("stakeAuthorizationType"),Pr("authoritySeed"),ue("authorityOwner")])}}),i0=Object.freeze({Staker:{index:0},Withdrawer:{index:1}}),hn=class{static{a(this,"StakeProgram")}constructor(){}static initialize(e){let{stakePubkey:t,authorized:r,lockup:o}=e,s=o||Ur.default,i=De.Initialize,u=le(i,{authorized:{staker:oe(r.staker.toBuffer()),withdrawer:oe(r.withdrawer.toBuffer())},lockup:{unixTimestamp:s.unixTimestamp,epoch:s.epoch,custodian:oe(s.custodian.toBuffer())}}),f={keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:cn,isSigner:!1,isWritable:!1}],programId:this.programId,data:u};return new me(f)}static createAccountWithSeed(e){let t=new de;t.add(Ue.createAccountWithSeed({fromPubkey:e.fromPubkey,newAccountPubkey:e.stakePubkey,basePubkey:e.basePubkey,seed:e.seed,lamports:e.lamports,space:this.space,programId:this.programId}));let{stakePubkey:r,authorized:o,lockup:s}=e;return t.add(this.initialize({stakePubkey:r,authorized:o,lockup:s}))}static createAccount(e){let t=new de;t.add(Ue.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.stakePubkey,lamports:e.lamports,space:this.space,programId:this.programId}));let{stakePubkey:r,authorized:o,lockup:s}=e;return t.add(this.initialize({stakePubkey:r,authorized:o,lockup:s}))}static delegate(e){let{stakePubkey:t,authorizedPubkey:r,votePubkey:o}=e,s=De.Delegate,i=le(s);return new de().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:o,isSigner:!1,isWritable:!1},{pubkey:Pt,isSigner:!1,isWritable:!1},{pubkey:Yo,isSigner:!1,isWritable:!1},{pubkey:Gh,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:i})}static authorize(e){let{stakePubkey:t,authorizedPubkey:r,newAuthorizedPubkey:o,stakeAuthorizationType:s,custodianPubkey:i}=e,u=De.Authorize,f=le(u,{newAuthorized:oe(o.toBuffer()),stakeAuthorizationType:s.index}),y=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Pt,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}];return i&&y.push({pubkey:i,isSigner:!0,isWritable:!1}),new de().add({keys:y,programId:this.programId,data:f})}static authorizeWithSeed(e){let{stakePubkey:t,authorityBase:r,authoritySeed:o,authorityOwner:s,newAuthorizedPubkey:i,stakeAuthorizationType:u,custodianPubkey:f}=e,y=De.AuthorizeWithSeed,d=le(y,{newAuthorized:oe(i.toBuffer()),stakeAuthorizationType:u.index,authoritySeed:o,authorityOwner:oe(s.toBuffer())}),_=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1},{pubkey:Pt,isSigner:!1,isWritable:!1}];return f&&_.push({pubkey:f,isSigner:!0,isWritable:!1}),new de().add({keys:_,programId:this.programId,data:d})}static splitInstruction(e){let{stakePubkey:t,authorizedPubkey:r,splitStakePubkey:o,lamports:s}=e,i=De.Split,u=le(i,{lamports:s});return new me({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:o,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:u})}static split(e,t){let r=new de;return r.add(Ue.createAccount({fromPubkey:e.authorizedPubkey,newAccountPubkey:e.splitStakePubkey,lamports:t,space:this.space,programId:this.programId})),r.add(this.splitInstruction(e))}static splitWithSeed(e,t){let{stakePubkey:r,authorizedPubkey:o,splitStakePubkey:s,basePubkey:i,seed:u,lamports:f}=e,y=new de;return y.add(Ue.allocate({accountPubkey:s,basePubkey:i,seed:u,space:this.space,programId:this.programId})),t&&t>0&&y.add(Ue.transfer({fromPubkey:e.authorizedPubkey,toPubkey:s,lamports:t})),y.add(this.splitInstruction({stakePubkey:r,authorizedPubkey:o,splitStakePubkey:s,lamports:f}))}static merge(e){let{stakePubkey:t,sourceStakePubKey:r,authorizedPubkey:o}=e,s=De.Merge,i=le(s);return new de().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!1,isWritable:!0},{pubkey:Pt,isSigner:!1,isWritable:!1},{pubkey:Yo,isSigner:!1,isWritable:!1},{pubkey:o,isSigner:!0,isWritable:!1}],programId:this.programId,data:i})}static withdraw(e){let{stakePubkey:t,authorizedPubkey:r,toPubkey:o,lamports:s,custodianPubkey:i}=e,u=De.Withdraw,f=le(u,{lamports:s}),y=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:o,isSigner:!1,isWritable:!0},{pubkey:Pt,isSigner:!1,isWritable:!1},{pubkey:Yo,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return i&&y.push({pubkey:i,isSigner:!0,isWritable:!1}),new de().add({keys:y,programId:this.programId,data:f})}static deactivate(e){let{stakePubkey:t,authorizedPubkey:r}=e,o=De.Deactivate,s=le(o);return new de().add({keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Pt,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:s})}};hn.programId=new U("Stake11111111111111111111111111111111111111");hn.space=200;oi=class{static{a(this,"VoteInit")}constructor(e,t,r,o){this.nodePubkey=void 0,this.authorizedVoter=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.nodePubkey=e,this.authorizedVoter=t,this.authorizedWithdrawer=r,this.commission=o}},Uc=class{static{a(this,"VoteInstruction")}constructor(){}static decodeInstructionType(e){this.checkProgramId(e.programId);let r=g.u32("instruction").decode(e.data),o;for(let[s,i]of Object.entries(Dt))if(i.index==r){o=s;break}if(!o)throw new Error("Instruction type incorrect; not a VoteInstruction");return o}static decodeInitializeAccount(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,4);let{voteInit:t}=we(Dt.InitializeAccount,e.data);return{votePubkey:e.keys[0].pubkey,nodePubkey:e.keys[3].pubkey,voteInit:new oi(new U(t.nodePubkey),new U(t.authorizedVoter),new U(t.authorizedWithdrawer),t.commission)}}static decodeAuthorize(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);let{newAuthorized:t,voteAuthorizationType:r}=we(Dt.Authorize,e.data);return{votePubkey:e.keys[0].pubkey,authorizedPubkey:e.keys[2].pubkey,newAuthorizedPubkey:new U(t),voteAuthorizationType:{index:r}}}static decodeAuthorizeWithSeed(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);let{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:t,currentAuthorityDerivedKeySeed:r,newAuthorized:o,voteAuthorizationType:s}}=we(Dt.AuthorizeWithSeed,e.data);return{currentAuthorityDerivedKeyBasePubkey:e.keys[2].pubkey,currentAuthorityDerivedKeyOwnerPubkey:new U(t),currentAuthorityDerivedKeySeed:r,newAuthorizedPubkey:new U(o),voteAuthorizationType:{index:s},votePubkey:e.keys[0].pubkey}}static decodeWithdraw(e){this.checkProgramId(e.programId),this.checkKeyLength(e.keys,3);let{lamports:t}=we(Dt.Withdraw,e.data);return{votePubkey:e.keys[0].pubkey,authorizedWithdrawerPubkey:e.keys[2].pubkey,lamports:t,toPubkey:e.keys[1].pubkey}}static checkProgramId(e){if(!e.equals(pn.programId))throw new Error("invalid instruction; programId is not VoteProgram")}static checkKeyLength(e,t){if(e.length<t)throw new Error(`invalid instruction; found ${e.length} keys, expected at least ${t}`)}},Dt=Object.freeze({InitializeAccount:{index:0,layout:g.struct([g.u32("instruction"),fb()])},Authorize:{index:1,layout:g.struct([g.u32("instruction"),ue("newAuthorized"),g.u32("voteAuthorizationType")])},Withdraw:{index:3,layout:g.struct([g.u32("instruction"),g.ns64("lamports")])},UpdateValidatorIdentity:{index:4,layout:g.struct([g.u32("instruction")])},AuthorizeWithSeed:{index:10,layout:g.struct([g.u32("instruction"),db()])}}),a0=Object.freeze({Voter:{index:0},Withdrawer:{index:1}}),pn=class n{static{a(this,"VoteProgram")}constructor(){}static initializeAccount(e){let{votePubkey:t,nodePubkey:r,voteInit:o}=e,s=Dt.InitializeAccount,i=le(s,{voteInit:{nodePubkey:oe(o.nodePubkey.toBuffer()),authorizedVoter:oe(o.authorizedVoter.toBuffer()),authorizedWithdrawer:oe(o.authorizedWithdrawer.toBuffer()),commission:o.commission}}),u={keys:[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:cn,isSigner:!1,isWritable:!1},{pubkey:Pt,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}],programId:this.programId,data:i};return new me(u)}static createAccount(e){let t=new de;return t.add(Ue.createAccount({fromPubkey:e.fromPubkey,newAccountPubkey:e.votePubkey,lamports:e.lamports,space:this.space,programId:this.programId})),t.add(this.initializeAccount({votePubkey:e.votePubkey,nodePubkey:e.voteInit.nodePubkey,voteInit:e.voteInit}))}static authorize(e){let{votePubkey:t,authorizedPubkey:r,newAuthorizedPubkey:o,voteAuthorizationType:s}=e,i=Dt.Authorize,u=le(i,{newAuthorized:oe(o.toBuffer()),voteAuthorizationType:s.index}),f=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:Pt,isSigner:!1,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return new de().add({keys:f,programId:this.programId,data:u})}static authorizeWithSeed(e){let{currentAuthorityDerivedKeyBasePubkey:t,currentAuthorityDerivedKeyOwnerPubkey:r,currentAuthorityDerivedKeySeed:o,newAuthorizedPubkey:s,voteAuthorizationType:i,votePubkey:u}=e,f=Dt.AuthorizeWithSeed,y=le(f,{voteAuthorizeWithSeedArgs:{currentAuthorityDerivedKeyOwnerPubkey:oe(r.toBuffer()),currentAuthorityDerivedKeySeed:o,newAuthorized:oe(s.toBuffer()),voteAuthorizationType:i.index}}),d=[{pubkey:u,isSigner:!1,isWritable:!0},{pubkey:Pt,isSigner:!1,isWritable:!1},{pubkey:t,isSigner:!0,isWritable:!1}];return new de().add({keys:d,programId:this.programId,data:y})}static withdraw(e){let{votePubkey:t,authorizedWithdrawerPubkey:r,lamports:o,toPubkey:s}=e,i=Dt.Withdraw,u=le(i,{lamports:o}),f=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:s,isSigner:!1,isWritable:!0},{pubkey:r,isSigner:!0,isWritable:!1}];return new de().add({keys:f,programId:this.programId,data:u})}static safeWithdraw(e,t,r){if(e.lamports>t-r)throw new Error("Withdraw will leave vote account with insufficient funds.");return n.withdraw(e)}static updateValidatorIdentity(e){let{votePubkey:t,authorizedWithdrawerPubkey:r,nodePubkey:o}=e,s=Dt.UpdateValidatorIdentity,i=le(s),u=[{pubkey:t,isSigner:!1,isWritable:!0},{pubkey:o,isSigner:!0,isWritable:!1},{pubkey:r,isSigner:!0,isWritable:!1}];return new de().add({keys:u,programId:this.programId,data:i})}};pn.programId=new U("Vote111111111111111111111111111111111111111");pn.space=3762;Yh=new U("Va1idator1nfo111111111111111111111111111111"),c0=B({name:$(),website:Z($()),details:Z($()),iconUrl:Z($()),keybaseUsername:Z($())}),Dc=class n{static{a(this,"ValidatorInfo")}constructor(e,t){this.key=void 0,this.info=void 0,this.key=e,this.info=t}static fromConfigData(e){let t=[...e];if(rt(t)!==2)return null;let o=[];for(let s=0;s<2;s++){let i=new U(nt(t,0,Mt)),u=Bt(t)===1;o.push({publicKey:i,isSigner:u})}if(o[0].publicKey.equals(Yh)&&o[1].isSigner){let s=Pr().decode(Q.from(t)),i=JSON.parse(s);return Sa(i,c0),new n(o[1].publicKey,i)}return null}},u0=new U("Vote111111111111111111111111111111111111111"),l0=g.struct([ue("nodePubkey"),ue("authorizedWithdrawer"),g.u8("commission"),g.nu64(),g.seq(g.struct([g.nu64("slot"),g.u32("confirmationCount")]),g.offset(g.u32(),-8),"votes"),g.u8("rootSlotValid"),g.nu64("rootSlot"),g.nu64(),g.seq(g.struct([g.nu64("epoch"),ue("authorizedVoter")]),g.offset(g.u32(),-8),"authorizedVoters"),g.struct([g.seq(g.struct([ue("authorizedPubkey"),g.nu64("epochOfLastAuthorizedSwitch"),g.nu64("targetEpoch")]),32,"buf"),g.nu64("idx"),g.u8("isEmpty")],"priorVoters"),g.nu64(),g.seq(g.struct([g.nu64("epoch"),g.nu64("credits"),g.nu64("prevCredits")]),g.offset(g.u32(),-8),"epochCredits"),g.struct([g.nu64("slot"),g.nu64("timestamp")],"lastTimestamp")]),Mc=class n{static{a(this,"VoteAccount")}constructor(e){this.nodePubkey=void 0,this.authorizedWithdrawer=void 0,this.commission=void 0,this.rootSlot=void 0,this.votes=void 0,this.authorizedVoters=void 0,this.priorVoters=void 0,this.epochCredits=void 0,this.lastTimestamp=void 0,this.nodePubkey=e.nodePubkey,this.authorizedWithdrawer=e.authorizedWithdrawer,this.commission=e.commission,this.rootSlot=e.rootSlot,this.votes=e.votes,this.authorizedVoters=e.authorizedVoters,this.priorVoters=e.priorVoters,this.epochCredits=e.epochCredits,this.lastTimestamp=e.lastTimestamp}static fromAccountData(e){let r=l0.decode(oe(e),4),o=r.rootSlot;return r.rootSlotValid||(o=null),new n({nodePubkey:new U(r.nodePubkey),authorizedWithdrawer:new U(r.authorizedWithdrawer),commission:r.commission,votes:r.votes,rootSlot:o,authorizedVoters:r.authorizedVoters.map(f0),priorVoters:d0(r.priorVoters),epochCredits:r.epochCredits,lastTimestamp:r.lastTimestamp})}};a(f0,"parseAuthorizedVoter");a(Rh,"parsePriorVoters");a(d0,"getPriorVoters");Eh={http:{devnet:"http://api.devnet.solana.com",testnet:"http://api.testnet.solana.com","mainnet-beta":"http://api.mainnet-beta.solana.com/"},https:{devnet:"https://api.devnet.solana.com",testnet:"https://api.testnet.solana.com","mainnet-beta":"https://api.mainnet-beta.solana.com/"}};a(h0,"clusterApiUrl");a(p0,"sendAndConfirmRawTransaction");y0=1e9});function Xh(n,e){return Array.apply(0,new Array(Math.ceil(n.length/e))).map((t,r)=>n.slice(r*e,(r+1)*e))}var jc,dr,vt,$r=Pe(()=>{"use strict";dr=process.env.ANCHOR_BROWSER||typeof window<"u"&&!(!((jc=window.process)===null||jc===void 0)&&jc.hasOwnProperty("type"));a(Xh,"chunks");vt=a(n=>"version"in n,"isVersionedTransaction")});var Vc={};Cn(Vc,{default:()=>hs});import{Buffer as m0}from"buffer";var hs,ps=Pe(()=>{"use strict";$e();$r();hs=class n{static{a(this,"NodeWallet")}constructor(e){this.payer=e}static local(){let e=ae("process");if(!e.env.ANCHOR_WALLET||e.env.ANCHOR_WALLET==="")throw new Error("expected environment variable `ANCHOR_WALLET` is not set.");let t=dn.fromSecretKey(m0.from(JSON.parse(ae("fs").readFileSync(e.env.ANCHOR_WALLET,{encoding:"utf-8"}))));return new n(t)}async signTransaction(e){return vt(e)?e.sign([this.payer]):e.partialSign(this.payer),e}async signAllTransactions(e){return e.map(t=>(vt(t)?t.sign([this.payer]):t.partialSign(this.payer),t))}get publicKey(){return this.payer.publicKey}}});var sp=ce((BA,Xc)=>{"use strict";var A0=/[\p{Lu}]/u,k0=/[\p{Ll}]/u,Zh=/^[\p{Lu}](?![\p{Lu}])/gu,tp=/([\p{Alpha}\p{N}_]|$)/u,rp=/[_.\- ]+/,I0=new RegExp("^"+rp.source),Qh=new RegExp(rp.source+tp.source,"gu"),ep=new RegExp("\\d+"+tp.source,"gu"),v0=a((n,e,t)=>{let r=!1,o=!1,s=!1;for(let i=0;i<n.length;i++){let u=n[i];r&&A0.test(u)?(n=n.slice(0,i)+"-"+n.slice(i),r=!1,s=o,o=!0,i++):o&&s&&k0.test(u)?(n=n.slice(0,i-1)+"-"+n.slice(i-1),s=o,o=!1,r=!0):(r=e(u)===u&&t(u)!==u,s=o,o=t(u)===u&&e(u)!==u)}return n},"preserveCamelCase"),T0=a((n,e)=>(Zh.lastIndex=0,n.replace(Zh,t=>e(t))),"preserveConsecutiveUppercase"),O0=a((n,e)=>(Qh.lastIndex=0,ep.lastIndex=0,n.replace(Qh,(t,r)=>e(r)).replace(ep,t=>e(t))),"postProcess"),np=a((n,e)=>{if(!(typeof n=="string"||Array.isArray(n)))throw new TypeError("Expected the input to be `string | string[]`");if(e={pascalCase:!1,preserveConsecutiveUppercase:!1,...e},Array.isArray(n)?n=n.map(s=>s.trim()).filter(s=>s.length).join("-"):n=n.trim(),n.length===0)return"";let t=e.locale===!1?s=>s.toLowerCase():s=>s.toLocaleLowerCase(e.locale),r=e.locale===!1?s=>s.toUpperCase():s=>s.toLocaleUpperCase(e.locale);return n.length===1?e.pascalCase?r(n):t(n):(n!==t(n)&&(n=v0(n,t,r)),n=n.replace(I0,""),e.preserveConsecutiveUppercase?n=T0(n,t):n=t(n),e.pascalCase&&(n=r(n.charAt(0))+n.slice(1)),O0(n,r))},"camelCase");Xc.exports=np;Xc.exports.default=np});var zr=ce(j=>{"use strict";var _e=class{static{a(this,"Layout")}constructor(e,t){if(!Number.isInteger(e))throw new TypeError("span must be an integer");this.span=e,this.property=t}makeDestinationObject(){return{}}decode(e,t){throw new Error("Layout is abstract")}encode(e,t,r){throw new Error("Layout is abstract")}getSpan(e,t){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(e){let t=Object.create(this.constructor.prototype);return Object.assign(t,this),t.property=e,t}fromArray(e){}};j.Layout=_e;function ru(n,e){return e.property?n+"["+e.property+"]":n}a(ru,"nameWithProperty");j.nameWithProperty=ru;function N0(n,e){if(typeof n!="function")throw new TypeError("Class must be constructor");if(n.hasOwnProperty("layout_"))throw new Error("Class is already bound to a layout");if(!(e&&e instanceof _e))throw new TypeError("layout must be a Layout");if(e.hasOwnProperty("boundConstructor_"))throw new Error("layout is already bound to a constructor");n.layout_=e,e.boundConstructor_=n,e.makeDestinationObject=()=>new n,Object.defineProperty(n.prototype,"encode",{value:a(function(t,r){return e.encode(this,t,r)},"value"),writable:!0}),Object.defineProperty(n,"decode",{value:a(function(t,r){return e.decode(t,r)},"value"),writable:!0})}a(N0,"bindConstructorLayout");j.bindConstructorLayout=N0;var Xe=class extends _e{static{a(this,"ExternalLayout")}isCount(){throw new Error("ExternalLayout is abstract")}},fi=class extends Xe{static{a(this,"GreedyCount")}constructor(e,t){if(e===void 0&&(e=1),!Number.isInteger(e)||0>=e)throw new TypeError("elementSpan must be a (positive) integer");super(-1,t),this.elementSpan=e}isCount(){return!0}decode(e,t){t===void 0&&(t=0);let r=e.length-t;return Math.floor(r/this.elementSpan)}encode(e,t,r){return 0}},ms=class extends Xe{static{a(this,"OffsetLayout")}constructor(e,t,r){if(!(e instanceof _e))throw new TypeError("layout must be a Layout");if(t===void 0)t=0;else if(!Number.isInteger(t))throw new TypeError("offset must be integer or undefined");super(e.span,r||e.property),this.layout=e,this.offset=t}isCount(){return this.layout instanceof bt||this.layout instanceof Tt}decode(e,t){return t===void 0&&(t=0),this.layout.decode(e,t+this.offset)}encode(e,t,r){return r===void 0&&(r=0),this.layout.encode(e,t,r+this.offset)}},bt=class extends _e{static{a(this,"UInt")}constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t){return t===void 0&&(t=0),e.readUIntLE(t,this.span)}encode(e,t,r){return r===void 0&&(r=0),t.writeUIntLE(e,r,this.span),this.span}},Tt=class extends _e{static{a(this,"UIntBE")}constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t){return t===void 0&&(t=0),e.readUIntBE(t,this.span)}encode(e,t,r){return r===void 0&&(r=0),t.writeUIntBE(e,r,this.span),this.span}},Jt=class extends _e{static{a(this,"Int")}constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t){return t===void 0&&(t=0),e.readIntLE(t,this.span)}encode(e,t,r){return r===void 0&&(r=0),t.writeIntLE(e,r,this.span),this.span}},hr=class extends _e{static{a(this,"IntBE")}constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t){return t===void 0&&(t=0),e.readIntBE(t,this.span)}encode(e,t,r){return r===void 0&&(r=0),t.writeIntBE(e,r,this.span),this.span}},Jc=Math.pow(2,32);function Ai(n){let e=Math.floor(n/Jc),t=n-e*Jc;return{hi32:e,lo32:t}}a(Ai,"divmodInt64");function ki(n,e){return n*Jc+e}a(ki,"roundedInt64");var Zc=class extends _e{static{a(this,"NearUInt64")}constructor(e){super(8,e)}decode(e,t){t===void 0&&(t=0);let r=e.readUInt32LE(t),o=e.readUInt32LE(t+4);return ki(o,r)}encode(e,t,r){r===void 0&&(r=0);let o=Ai(e);return t.writeUInt32LE(o.lo32,r),t.writeUInt32LE(o.hi32,r+4),8}},Qc=class extends _e{static{a(this,"NearUInt64BE")}constructor(e){super(8,e)}decode(e,t){t===void 0&&(t=0);let r=e.readUInt32BE(t),o=e.readUInt32BE(t+4);return ki(r,o)}encode(e,t,r){r===void 0&&(r=0);let o=Ai(e);return t.writeUInt32BE(o.hi32,r),t.writeUInt32BE(o.lo32,r+4),8}},eu=class extends _e{static{a(this,"NearInt64")}constructor(e){super(8,e)}decode(e,t){t===void 0&&(t=0);let r=e.readUInt32LE(t),o=e.readInt32LE(t+4);return ki(o,r)}encode(e,t,r){r===void 0&&(r=0);let o=Ai(e);return t.writeUInt32LE(o.lo32,r),t.writeInt32LE(o.hi32,r+4),8}},tu=class extends _e{static{a(this,"NearInt64BE")}constructor(e){super(8,e)}decode(e,t){t===void 0&&(t=0);let r=e.readInt32BE(t),o=e.readUInt32BE(t+4);return ki(r,o)}encode(e,t,r){r===void 0&&(r=0);let o=Ai(e);return t.writeInt32BE(o.hi32,r),t.writeUInt32BE(o.lo32,r+4),8}},di=class extends _e{static{a(this,"Float")}constructor(e){super(4,e)}decode(e,t){return t===void 0&&(t=0),e.readFloatLE(t)}encode(e,t,r){return r===void 0&&(r=0),t.writeFloatLE(e,r),4}},hi=class extends _e{static{a(this,"FloatBE")}constructor(e){super(4,e)}decode(e,t){return t===void 0&&(t=0),e.readFloatBE(t)}encode(e,t,r){return r===void 0&&(r=0),t.writeFloatBE(e,r),4}},pi=class extends _e{static{a(this,"Double")}constructor(e){super(8,e)}decode(e,t){return t===void 0&&(t=0),e.readDoubleLE(t)}encode(e,t,r){return r===void 0&&(r=0),t.writeDoubleLE(e,r),8}},yi=class extends _e{static{a(this,"DoubleBE")}constructor(e){super(8,e)}decode(e,t){return t===void 0&&(t=0),e.readDoubleBE(t)}encode(e,t,r){return r===void 0&&(r=0),t.writeDoubleBE(e,r),8}},mi=class extends _e{static{a(this,"Sequence")}constructor(e,t,r){if(!(e instanceof _e))throw new TypeError("elementLayout must be a Layout");if(!(t instanceof Xe&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let o=-1;!(t instanceof Xe)&&0<e.span&&(o=t*e.span),super(o,r),this.elementLayout=e,this.count=t}getSpan(e,t){if(0<=this.span)return this.span;t===void 0&&(t=0);let r=0,o=this.count;if(o instanceof Xe&&(o=o.decode(e,t)),0<this.elementLayout.span)r=o*this.elementLayout.span;else{let s=0;for(;s<o;)r+=this.elementLayout.getSpan(e,t+r),++s}return r}decode(e,t){t===void 0&&(t=0);let r=[],o=0,s=this.count;for(s instanceof Xe&&(s=s.decode(e,t));o<s;)r.push(this.elementLayout.decode(e,t)),t+=this.elementLayout.getSpan(e,t),o+=1;return r}encode(e,t,r){r===void 0&&(r=0);let o=this.elementLayout,s=e.reduce((i,u)=>i+o.encode(u,t,r+i),0);return this.count instanceof Xe&&this.count.encode(e.length,t,r),s}},gi=class extends _e{static{a(this,"Structure")}constructor(e,t,r){if(!(Array.isArray(e)&&e.reduce((s,i)=>s&&i instanceof _e,!0)))throw new TypeError("fields must be array of Layout instances");typeof t=="boolean"&&r===void 0&&(r=t,t=void 0);for(let s of e)if(0>s.span&&s.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let o=-1;try{o=e.reduce((s,i)=>s+i.getSpan(),0)}catch{}super(o,t),this.fields=e,this.decodePrefixes=!!r}getSpan(e,t){if(0<=this.span)return this.span;t===void 0&&(t=0);let r=0;try{r=this.fields.reduce((o,s)=>{let i=s.getSpan(e,t);return t+=i,o+i},0)}catch{throw new RangeError("indeterminate span")}return r}decode(e,t){t===void 0&&(t=0);let r=this.makeDestinationObject();for(let o of this.fields)if(o.property!==void 0&&(r[o.property]=o.decode(e,t)),t+=o.getSpan(e,t),this.decodePrefixes&&e.length===t)break;return r}encode(e,t,r){r===void 0&&(r=0);let o=r,s=0,i=0;for(let u of this.fields){let f=u.span;if(i=0<f?f:0,u.property!==void 0){let y=e[u.property];y!==void 0&&(i=u.encode(y,t,r),0>f&&(f=u.getSpan(t,r)))}s=r,r+=f}return s+i-o}fromArray(e){let t=this.makeDestinationObject();for(let r of this.fields)r.property!==void 0&&0<e.length&&(t[r.property]=e.shift());return t}layoutFor(e){if(typeof e!="string")throw new TypeError("property must be string");for(let t of this.fields)if(t.property===e)return t}offsetOf(e){if(typeof e!="string")throw new TypeError("property must be string");let t=0;for(let r of this.fields){if(r.property===e)return t;0>r.span?t=-1:0<=t&&(t+=r.span)}}},gs=class{static{a(this,"UnionDiscriminator")}constructor(e){this.property=e}decode(){throw new Error("UnionDiscriminator is abstract")}encode(){throw new Error("UnionDiscriminator is abstract")}},_n=class extends gs{static{a(this,"UnionLayoutDiscriminator")}constructor(e,t){if(!(e instanceof Xe&&e.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(t||e.property||"variant"),this.layout=e}decode(e,t){return this.layout.decode(e,t)}encode(e,t,r){return this.layout.encode(e,t,r)}},_s=class extends _e{static{a(this,"Union")}constructor(e,t,r){let o=e instanceof bt||e instanceof Tt;if(o)e=new _n(new ms(e));else if(e instanceof Xe&&e.isCount())e=new _n(e);else if(!(e instanceof gs))throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(t===void 0&&(t=null),!(t===null||t instanceof _e))throw new TypeError("defaultLayout must be null or a Layout");if(t!==null){if(0>t.span)throw new Error("defaultLayout must have constant span");t.property===void 0&&(t=t.replicate("content"))}let s=-1;t&&(s=t.span,0<=s&&o&&(s+=e.layout.span)),super(s,r),this.discriminator=e,this.usesPrefixDiscriminator=o,this.defaultLayout=t,this.registry={};let i=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(u){return i(u)},this.configGetSourceVariant=function(u){i=u.bind(this)}}getSpan(e,t){if(0<=this.span)return this.span;t===void 0&&(t=0);let r=this.getVariant(e,t);if(!r)throw new Error("unable to determine span for unrecognized variant");return r.getSpan(e,t)}defaultGetSourceVariant(e){if(e.hasOwnProperty(this.discriminator.property)){if(this.defaultLayout&&e.hasOwnProperty(this.defaultLayout.property))return;let t=this.registry[e[this.discriminator.property]];if(t&&(!t.layout||e.hasOwnProperty(t.property)))return t}else for(let t in this.registry){let r=this.registry[t];if(e.hasOwnProperty(r.property))return r}throw new Error("unable to infer src variant")}decode(e,t){t===void 0&&(t=0);let r,o=this.discriminator,s=o.decode(e,t),i=this.registry[s];if(i===void 0){let u=0;i=this.defaultLayout,this.usesPrefixDiscriminator&&(u=o.layout.span),r=this.makeDestinationObject(),r[o.property]=s,r[i.property]=this.defaultLayout.decode(e,t+u)}else r=i.decode(e,t);return r}encode(e,t,r){r===void 0&&(r=0);let o=this.getSourceVariant(e);if(o===void 0){let s=this.discriminator,i=this.defaultLayout,u=0;return this.usesPrefixDiscriminator&&(u=s.layout.span),s.encode(e[s.property],t,r),u+i.encode(e[i.property],t,r+u)}return o.encode(e,t,r)}addVariant(e,t,r){let o=new _i(this,e,t,r);return this.registry[e]=o,o}getVariant(e,t){let r=e;return Buffer.isBuffer(e)&&(t===void 0&&(t=0),r=this.discriminator.decode(e,t)),this.registry[r]}},_i=class extends _e{static{a(this,"VariantLayout")}constructor(e,t,r,o){if(!(e instanceof _s))throw new TypeError("union must be a Union");if(!Number.isInteger(t)||0>t)throw new TypeError("variant must be a (non-negative) integer");if(typeof r=="string"&&o===void 0&&(o=r,r=null),r){if(!(r instanceof _e))throw new TypeError("layout must be a Layout");if(e.defaultLayout!==null&&0<=r.span&&r.span>e.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof o!="string")throw new TypeError("variant must have a String property")}let s=e.span;0>e.span&&(s=r?r.span:0,0<=s&&e.usesPrefixDiscriminator&&(s+=e.discriminator.layout.span)),super(s,o),this.union=e,this.variant=t,this.layout=r||null}getSpan(e,t){if(0<=this.span)return this.span;t===void 0&&(t=0);let r=0;return this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span),r+this.layout.getSpan(e,t+r)}decode(e,t){let r=this.makeDestinationObject();if(t===void 0&&(t=0),this!==this.union.getVariant(e,t))throw new Error("variant mismatch");let o=0;return this.union.usesPrefixDiscriminator&&(o=this.union.discriminator.layout.span),this.layout?r[this.property]=this.layout.decode(e,t+o):this.property?r[this.property]=!0:this.union.usesPrefixDiscriminator&&(r[this.union.discriminator.property]=this.variant),r}encode(e,t,r){r===void 0&&(r=0);let o=0;if(this.union.usesPrefixDiscriminator&&(o=this.union.discriminator.layout.span),this.layout&&!e.hasOwnProperty(this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,t,r);let s=o;if(this.layout&&(this.layout.encode(e[this.property],t,r+o),s+=this.layout.getSpan(t,r+o),0<=this.union.span&&s>this.union.span))throw new Error("encoded variant overruns containing union");return s}fromArray(e){if(this.layout)return this.layout.fromArray(e)}};function gn(n){return 0>n&&(n+=4294967296),n}a(gn,"fixBitwiseResult");var bs=class extends _e{static{a(this,"BitStructure")}constructor(e,t,r){if(!(e instanceof bt||e instanceof Tt))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof t=="string"&&r===void 0&&(r=t,t=void 0),4<e.span)throw new RangeError("word cannot exceed 32 bits");super(e.span,r),this.word=e,this.msb=!!t,this.fields=[];let o=0;this._packedSetValue=function(s){return o=gn(s),this},this._packedGetValue=function(){return o}}decode(e,t){let r=this.makeDestinationObject();t===void 0&&(t=0);let o=this.word.decode(e,t);this._packedSetValue(o);for(let s of this.fields)s.property!==void 0&&(r[s.property]=s.decode(o));return r}encode(e,t,r){r===void 0&&(r=0);let o=this.word.decode(t,r);this._packedSetValue(o);for(let s of this.fields)if(s.property!==void 0){let i=e[s.property];i!==void 0&&s.encode(i)}return this.word.encode(this._packedGetValue(),t,r)}addField(e,t){let r=new Hr(this,e,t);return this.fields.push(r),r}addBoolean(e){let t=new bi(this,e);return this.fields.push(t),t}fieldFor(e){if(typeof e!="string")throw new TypeError("property must be string");for(let t of this.fields)if(t.property===e)return t}},Hr=class{static{a(this,"BitField")}constructor(e,t,r){if(!(e instanceof bs))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(t)||0>=t)throw new TypeError("bits must be positive integer");let o=8*e.span,s=e.fields.reduce((i,u)=>i+u.bits,0);if(t+s>o)throw new Error("bits too long for span remainder ("+(o-s)+" of "+o+" remain)");this.container=e,this.bits=t,this.valueMask=(1<<t)-1,t===32&&(this.valueMask=4294967295),this.start=s,this.container.msb&&(this.start=o-s-t),this.wordMask=gn(this.valueMask<<this.start),this.property=r}decode(){let e=this.container._packedGetValue();return gn(e&this.wordMask)>>>this.start}encode(e){if(!Number.isInteger(e)||e!==gn(e&this.valueMask))throw new TypeError(ru("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);let t=this.container._packedGetValue(),r=gn(e<<this.start);this.container._packedSetValue(gn(t&~this.wordMask)|r)}},bi=class extends Hr{static{a(this,"Boolean")}constructor(e,t){super(e,1,t)}decode(e,t){return!!Hr.prototype.decode.call(this,e,t)}encode(e){return typeof e=="boolean"&&(e=+e),Hr.prototype.encode.call(this,e)}},wi=class extends _e{static{a(this,"Blob")}constructor(e,t){if(!(e instanceof Xe&&e.isCount()||Number.isInteger(e)&&0<=e))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let r=-1;e instanceof Xe||(r=e),super(r,t),this.length=e}getSpan(e,t){let r=this.span;return 0>r&&(r=this.length.decode(e,t)),r}decode(e,t){t===void 0&&(t=0);let r=this.span;return 0>r&&(r=this.length.decode(e,t)),e.slice(t,t+r)}encode(e,t,r){let o=this.length;if(this.length instanceof Xe&&(o=e.length),!(Buffer.isBuffer(e)&&o===e.length))throw new TypeError(ru("Blob.encode",this)+" requires (length "+o+") Buffer as src");if(r+o>t.length)throw new RangeError("encoding overruns Buffer");return t.write(e.toString("hex"),r,o,"hex"),this.length instanceof Xe&&this.length.encode(o,t,r),o}},Ri=class extends _e{static{a(this,"CString")}constructor(e){super(-1,e)}getSpan(e,t){if(!Buffer.isBuffer(e))throw new TypeError("b must be a Buffer");t===void 0&&(t=0);let r=t;for(;r<e.length&&e[r]!==0;)r+=1;return 1+r-t}decode(e,t,r){t===void 0&&(t=0);let o=this.getSpan(e,t);return e.slice(t,t+o-1).toString("utf-8")}encode(e,t,r){r===void 0&&(r=0),typeof e!="string"&&(e=e.toString());let o=new Buffer(e,"utf8"),s=o.length;if(r+s>t.length)throw new RangeError("encoding overruns Buffer");return o.copy(t,r),t[r+s]=0,s+1}},Ei=class extends _e{static{a(this,"UTF8")}constructor(e,t){if(typeof e=="string"&&t===void 0&&(t=e,e=void 0),e===void 0)e=-1;else if(!Number.isInteger(e))throw new TypeError("maxSpan must be an integer");super(-1,t),this.maxSpan=e}getSpan(e,t){if(!Buffer.isBuffer(e))throw new TypeError("b must be a Buffer");return t===void 0&&(t=0),e.length-t}decode(e,t,r){t===void 0&&(t=0);let o=this.getSpan(e,t);if(0<=this.maxSpan&&this.maxSpan<o)throw new RangeError("text length exceeds maxSpan");return e.slice(t,t+o).toString("utf-8")}encode(e,t,r){r===void 0&&(r=0),typeof e!="string"&&(e=e.toString());let o=new Buffer(e,"utf8"),s=o.length;if(0<=this.maxSpan&&this.maxSpan<s)throw new RangeError("text length exceeds maxSpan");if(r+s>t.length)throw new RangeError("encoding overruns Buffer");return o.copy(t,r),s}},Si=class extends _e{static{a(this,"Constant")}constructor(e,t){super(0,t),this.value=e}decode(e,t,r){return this.value}encode(e,t,r){return 0}};j.ExternalLayout=Xe;j.GreedyCount=fi;j.OffsetLayout=ms;j.UInt=bt;j.UIntBE=Tt;j.Int=Jt;j.IntBE=hr;j.Float=di;j.FloatBE=hi;j.Double=pi;j.DoubleBE=yi;j.Sequence=mi;j.Structure=gi;j.UnionDiscriminator=gs;j.UnionLayoutDiscriminator=_n;j.Union=_s;j.VariantLayout=_i;j.BitStructure=bs;j.BitField=Hr;j.Boolean=bi;j.Blob=wi;j.CString=Ri;j.UTF8=Ei;j.Constant=Si;j.greedy=(n,e)=>new fi(n,e);j.offset=(n,e,t)=>new ms(n,e,t);j.u8=n=>new bt(1,n);j.u16=n=>new bt(2,n);j.u24=n=>new bt(3,n);j.u32=n=>new bt(4,n);j.u40=n=>new bt(5,n);j.u48=n=>new bt(6,n);j.nu64=n=>new Zc(n);j.u16be=n=>new Tt(2,n);j.u24be=n=>new Tt(3,n);j.u32be=n=>new Tt(4,n);j.u40be=n=>new Tt(5,n);j.u48be=n=>new Tt(6,n);j.nu64be=n=>new Qc(n);j.s8=n=>new Jt(1,n);j.s16=n=>new Jt(2,n);j.s24=n=>new Jt(3,n);j.s32=n=>new Jt(4,n);j.s40=n=>new Jt(5,n);j.s48=n=>new Jt(6,n);j.ns64=n=>new eu(n);j.s16be=n=>new hr(2,n);j.s24be=n=>new hr(3,n);j.s32be=n=>new hr(4,n);j.s40be=n=>new hr(5,n);j.s48be=n=>new hr(6,n);j.ns64be=n=>new tu(n);j.f32=n=>new di(n);j.f32be=n=>new hi(n);j.f64=n=>new pi(n);j.f64be=n=>new yi(n);j.struct=(n,e,t)=>new gi(n,e,t);j.bits=(n,e,t)=>new bs(n,e,t);j.seq=(n,e,t)=>new mi(n,e,t);j.union=(n,e,t)=>new _s(n,e,t);j.unionLayoutDiscriminator=(n,e)=>new _n(n,e);j.blob=(n,e)=>new wi(n,e);j.cstr=n=>new Ri(n);j.utf8=(n,e)=>new Ei(n,e);j.const=(n,e)=>new Si(n,e)});var ws=ce(J=>{"use strict";var C0=J&&J.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(J,"__esModule",{value:!0});J.map=J.array=J.rustEnum=J.str=J.vecU8=J.tagged=J.vec=J.bool=J.option=J.publicKey=J.i256=J.u256=J.i128=J.u128=J.i64=J.u64=J.struct=J.f64=J.f32=J.i32=J.u32=J.i16=J.u16=J.i8=J.u8=void 0;var Ie=zr(),x0=($e(),xn(qc)),L0=C0(Er()),Zt=zr();Object.defineProperty(J,"u8",{enumerable:!0,get:a(function(){return Zt.u8},"get")});Object.defineProperty(J,"i8",{enumerable:!0,get:a(function(){return Zt.s8},"get")});Object.defineProperty(J,"u16",{enumerable:!0,get:a(function(){return Zt.u16},"get")});Object.defineProperty(J,"i16",{enumerable:!0,get:a(function(){return Zt.s16},"get")});Object.defineProperty(J,"u32",{enumerable:!0,get:a(function(){return Zt.u32},"get")});Object.defineProperty(J,"i32",{enumerable:!0,get:a(function(){return Zt.s32},"get")});Object.defineProperty(J,"f32",{enumerable:!0,get:a(function(){return Zt.f32},"get")});Object.defineProperty(J,"f64",{enumerable:!0,get:a(function(){return Zt.f64},"get")});Object.defineProperty(J,"struct",{enumerable:!0,get:a(function(){return Zt.struct},"get")});var pr=class extends Ie.Layout{static{a(this,"BNLayout")}constructor(e,t,r){super(e,r),this.blob=(0,Ie.blob)(e),this.signed=t}decode(e,t=0){let r=new L0.default(this.blob.decode(e,t),10,"le");return this.signed?r.fromTwos(this.span*8).clone():r}encode(e,t,r=0){return this.signed&&(e=e.toTwos(this.span*8)),this.blob.encode(e.toArrayLike(Buffer,"le",this.span),t,r)}};function op(n){return new pr(8,!1,n)}a(op,"u64");J.u64=op;function P0(n){return new pr(8,!0,n)}a(P0,"i64");J.i64=P0;function B0(n){return new pr(16,!1,n)}a(B0,"u128");J.u128=B0;function U0(n){return new pr(16,!0,n)}a(U0,"i128");J.i128=U0;function D0(n){return new pr(32,!1,n)}a(D0,"u256");J.u256=D0;function M0(n){return new pr(32,!0,n)}a(M0,"i256");J.i256=M0;var Ht=class extends Ie.Layout{static{a(this,"WrappedLayout")}constructor(e,t,r,o){super(e.span,o),this.layout=e,this.decoder=t,this.encoder=r}decode(e,t){return this.decoder(this.layout.decode(e,t))}encode(e,t,r){return this.layout.encode(this.encoder(e),t,r)}getSpan(e,t){return this.layout.getSpan(e,t)}};function $0(n){return new Ht((0,Ie.blob)(32),e=>new x0.PublicKey(e),e=>e.toBuffer(),n)}a($0,"publicKey");J.publicKey=$0;var nu=class extends Ie.Layout{static{a(this,"OptionLayout")}constructor(e,t){super(-1,t),this.layout=e,this.discriminator=(0,Ie.u8)()}encode(e,t,r=0){return e==null?this.discriminator.encode(0,t,r):(this.discriminator.encode(1,t,r),this.layout.encode(e,t,r+1)+1)}decode(e,t=0){let r=this.discriminator.decode(e,t);if(r===0)return null;if(r===1)return this.layout.decode(e,t+1);throw new Error("Invalid option "+this.property)}getSpan(e,t=0){let r=this.discriminator.decode(e,t);if(r===0)return 1;if(r===1)return this.layout.getSpan(e,t+1)+1;throw new Error("Invalid option "+this.property)}};function H0(n,e){return new nu(n,e)}a(H0,"option");J.option=H0;function z0(n){return new Ht((0,Ie.u8)(),F0,W0,n)}a(z0,"bool");J.bool=z0;function F0(n){if(n===0)return!1;if(n===1)return!0;throw new Error("Invalid bool: "+n)}a(F0,"decodeBool");function W0(n){return n?1:0}a(W0,"encodeBool");function K0(n,e){let t=(0,Ie.u32)("length"),r=(0,Ie.struct)([t,(0,Ie.seq)(n,(0,Ie.offset)(t,-t.span),"values")]);return new Ht(r,({values:o})=>o,o=>({values:o}),e)}a(K0,"vec");J.vec=K0;function q0(n,e,t){let r=(0,Ie.struct)([op("tag"),e.replicate("data")]);function o({tag:s,data:i}){if(!s.eq(n))throw new Error("Invalid tag, expected: "+n.toString("hex")+", got: "+s.toString("hex"));return i}return a(o,"decodeTag"),new Ht(r,o,s=>({tag:n,data:s}),t)}a(q0,"tagged");J.tagged=q0;function ip(n){let e=(0,Ie.u32)("length"),t=(0,Ie.struct)([e,(0,Ie.blob)((0,Ie.offset)(e,-e.span),"data")]);return new Ht(t,({data:r})=>r,r=>({data:r}),n)}a(ip,"vecU8");J.vecU8=ip;function j0(n){return new Ht(ip(),e=>e.toString("utf-8"),e=>Buffer.from(e,"utf-8"),n)}a(j0,"str");J.str=j0;function V0(n,e,t){let r=(0,Ie.union)(t??(0,Ie.u8)(),e);return n.forEach((o,s)=>r.addVariant(s,o,o.property)),r}a(V0,"rustEnum");J.rustEnum=V0;function G0(n,e,t){let r=(0,Ie.struct)([(0,Ie.seq)(n,e,"values")]);return new Ht(r,({values:o})=>o,o=>({values:o}),t)}a(G0,"array");J.array=G0;var su=class extends Ie.Layout{static{a(this,"MapEntryLayout")}constructor(e,t,r){super(e.span+t.span,r),this.keyLayout=e,this.valueLayout=t}decode(e,t){t=t||0;let r=this.keyLayout.decode(e,t),o=this.valueLayout.decode(e,t+this.keyLayout.getSpan(e,t));return[r,o]}encode(e,t,r){r=r||0;let o=this.keyLayout.encode(e[0],t,r),s=this.valueLayout.encode(e[1],t,r+o);return o+s}getSpan(e,t){return this.keyLayout.getSpan(e,t)+this.valueLayout.getSpan(e,t)}};function Y0(n,e,t){let r=(0,Ie.u32)("length"),o=(0,Ie.struct)([r,(0,Ie.seq)(new su(n,e),(0,Ie.offset)(r,-r.span),"values")]);return new Ht(o,({values:s})=>new Map(s),s=>({values:Array.from(s.entries())}),t)}a(Y0,"map");J.map=Y0});var Ip=ce(v=>{"use strict";Object.defineProperty(v,"__esModule",{value:!0});v.ANCHOR_ERROR__REQUIRE_EQ_VIOLATED=v.ANCHOR_ERROR__REQUIRE_VIOLATED=v.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_PROGRAM_ID=v.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_AUTHORITY=v.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION=v.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION_DELEGATE=v.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION=v.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION_AUTHORITY=v.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION=v.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_METADATA_ADDRESS=v.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_AUTHORITY=v.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION=v.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_MEMBER_ADDRESS=v.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_AUTHORITY=v.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION=v.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_GROUP_ADDRESS=v.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_AUTHORITY=v.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION=v.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_TOKEN_TOKEN_PROGRAM=v.ANCHOR_ERROR__CONSTRAINT_MINT_TOKEN_PROGRAM=v.ANCHOR_ERROR__CONSTRAINT_TOKEN_TOKEN_PROGRAM=v.ANCHOR_ERROR__CONSTRAINT_ACCOUNT_IS_NONE=v.ANCHOR_ERROR__CONSTRAINT_SPACE=v.ANCHOR_ERROR__CONSTRAINT_MINT_DECIMALS=v.ANCHOR_ERROR__CONSTRAINT_MINT_FREEZE_AUTHORITY=v.ANCHOR_ERROR__CONSTRAINT_MINT_MINT_AUTHORITY=v.ANCHOR_ERROR__CONSTRAINT_TOKEN_OWNER=v.ANCHOR_ERROR__CONSTRAINT_TOKEN_MINT=v.ANCHOR_ERROR__CONSTRAINT_ZERO=v.ANCHOR_ERROR__CONSTRAINT_ADDRESS=v.ANCHOR_ERROR__CONSTRAINT_CLOSE=v.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_INIT=v.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED=v.ANCHOR_ERROR__CONSTRAINT_STATE=v.ANCHOR_ERROR__CONSTRAINT_EXECUTABLE=v.ANCHOR_ERROR__CONSTRAINT_SEEDS=v.ANCHOR_ERROR__CONSTRAINT_RENT_EXEMPT=v.ANCHOR_ERROR__CONSTRAINT_OWNER=v.ANCHOR_ERROR__CONSTRAINT_RAW=v.ANCHOR_ERROR__CONSTRAINT_SIGNER=v.ANCHOR_ERROR__CONSTRAINT_HAS_ONE=v.ANCHOR_ERROR__CONSTRAINT_MUT=v.ANCHOR_ERROR__EVENT_INSTRUCTION_STUB=v.ANCHOR_ERROR__IDL_ACCOUNT_NOT_EMPTY=v.ANCHOR_ERROR__IDL_INSTRUCTION_INVALID_PROGRAM=v.ANCHOR_ERROR__IDL_INSTRUCTION_STUB=v.ANCHOR_ERROR__INSTRUCTION_DID_NOT_SERIALIZE=v.ANCHOR_ERROR__INSTRUCTION_DID_NOT_DESERIALIZE=v.ANCHOR_ERROR__INSTRUCTION_FALLBACK_NOT_FOUND=v.ANCHOR_ERROR__INSTRUCTION_MISSING=void 0;v.ANCHOR_ERROR__DEPRECATED=v.ANCHOR_ERROR__INVALID_NUMERIC_CONVERSION=v.ANCHOR_ERROR__TRYING_TO_INIT_PAYER_AS_PROGRAM_ACCOUNT=v.ANCHOR_ERROR__DECLARED_PROGRAM_ID_MISMATCH=v.ANCHOR_ERROR__ACCOUNT_DUPLICATE_REALLOCS=v.ANCHOR_ERROR__ACCOUNT_REALLOC_EXCEEDS_LIMIT=v.ANCHOR_ERROR__ACCOUNT_SYSVAR_MISMATCH=v.ANCHOR_ERROR__ACCOUNT_NOT_ASSOCIATED_TOKEN_ACCOUNT=v.ANCHOR_ERROR__ACCOUNT_NOT_PROGRAM_DATA=v.ANCHOR_ERROR__ACCOUNT_NOT_INITIALIZED=v.ANCHOR_ERROR__ACCOUNT_NOT_SYSTEM_OWNED=v.ANCHOR_ERROR__ACCOUNT_NOT_SIGNER=v.ANCHOR_ERROR__INVALID_PROGRAM_EXECUTABLE=v.ANCHOR_ERROR__INVALID_PROGRAM_ID=v.ANCHOR_ERROR__ACCOUNT_OWNED_BY_WRONG_PROGRAM=v.ANCHOR_ERROR__ACCOUNT_NOT_MUTABLE=v.ANCHOR_ERROR__ACCOUNT_NOT_ENOUGH_KEYS=v.ANCHOR_ERROR__ACCOUNT_DID_NOT_SERIALIZE=v.ANCHOR_ERROR__ACCOUNT_DID_NOT_DESERIALIZE=v.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_MISMATCH=v.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_NOT_FOUND=v.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_ALREADY_SET=v.ANCHOR_ERROR__REQUIRE_GTE_VIOLATED=v.ANCHOR_ERROR__REQUIRE_GT_VIOLATED=v.ANCHOR_ERROR__REQUIRE_KEYS_NEQ_VIOLATED=v.ANCHOR_ERROR__REQUIRE_NEQ_VIOLATED=v.ANCHOR_ERROR__REQUIRE_KEYS_EQ_VIOLATED=void 0;v.ANCHOR_ERROR__INSTRUCTION_MISSING=100;v.ANCHOR_ERROR__INSTRUCTION_FALLBACK_NOT_FOUND=101;v.ANCHOR_ERROR__INSTRUCTION_DID_NOT_DESERIALIZE=102;v.ANCHOR_ERROR__INSTRUCTION_DID_NOT_SERIALIZE=103;v.ANCHOR_ERROR__IDL_INSTRUCTION_STUB=1e3;v.ANCHOR_ERROR__IDL_INSTRUCTION_INVALID_PROGRAM=1001;v.ANCHOR_ERROR__IDL_ACCOUNT_NOT_EMPTY=1002;v.ANCHOR_ERROR__EVENT_INSTRUCTION_STUB=1500;v.ANCHOR_ERROR__CONSTRAINT_MUT=2e3;v.ANCHOR_ERROR__CONSTRAINT_HAS_ONE=2001;v.ANCHOR_ERROR__CONSTRAINT_SIGNER=2002;v.ANCHOR_ERROR__CONSTRAINT_RAW=2003;v.ANCHOR_ERROR__CONSTRAINT_OWNER=2004;v.ANCHOR_ERROR__CONSTRAINT_RENT_EXEMPT=2005;v.ANCHOR_ERROR__CONSTRAINT_SEEDS=2006;v.ANCHOR_ERROR__CONSTRAINT_EXECUTABLE=2007;v.ANCHOR_ERROR__CONSTRAINT_STATE=2008;v.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED=2009;v.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_INIT=2010;v.ANCHOR_ERROR__CONSTRAINT_CLOSE=2011;v.ANCHOR_ERROR__CONSTRAINT_ADDRESS=2012;v.ANCHOR_ERROR__CONSTRAINT_ZERO=2013;v.ANCHOR_ERROR__CONSTRAINT_TOKEN_MINT=2014;v.ANCHOR_ERROR__CONSTRAINT_TOKEN_OWNER=2015;v.ANCHOR_ERROR__CONSTRAINT_MINT_MINT_AUTHORITY=2016;v.ANCHOR_ERROR__CONSTRAINT_MINT_FREEZE_AUTHORITY=2017;v.ANCHOR_ERROR__CONSTRAINT_MINT_DECIMALS=2018;v.ANCHOR_ERROR__CONSTRAINT_SPACE=2019;v.ANCHOR_ERROR__CONSTRAINT_ACCOUNT_IS_NONE=2020;v.ANCHOR_ERROR__CONSTRAINT_TOKEN_TOKEN_PROGRAM=2021;v.ANCHOR_ERROR__CONSTRAINT_MINT_TOKEN_PROGRAM=2022;v.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_TOKEN_TOKEN_PROGRAM=2023;v.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION=2024;v.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_AUTHORITY=2025;v.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_GROUP_ADDRESS=2026;v.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION=2027;v.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_AUTHORITY=2028;v.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_MEMBER_ADDRESS=2029;v.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION=2030;v.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_AUTHORITY=2031;v.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_METADATA_ADDRESS=2032;v.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION=2033;v.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION_AUTHORITY=2034;v.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION=2035;v.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION_DELEGATE=2036;v.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION=2037;v.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_AUTHORITY=2038;v.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_PROGRAM_ID=2039;v.ANCHOR_ERROR__REQUIRE_VIOLATED=2500;v.ANCHOR_ERROR__REQUIRE_EQ_VIOLATED=2501;v.ANCHOR_ERROR__REQUIRE_KEYS_EQ_VIOLATED=2502;v.ANCHOR_ERROR__REQUIRE_NEQ_VIOLATED=2503;v.ANCHOR_ERROR__REQUIRE_KEYS_NEQ_VIOLATED=2504;v.ANCHOR_ERROR__REQUIRE_GT_VIOLATED=2505;v.ANCHOR_ERROR__REQUIRE_GTE_VIOLATED=2506;v.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_ALREADY_SET=3e3;v.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_NOT_FOUND=3001;v.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_MISMATCH=3002;v.ANCHOR_ERROR__ACCOUNT_DID_NOT_DESERIALIZE=3003;v.ANCHOR_ERROR__ACCOUNT_DID_NOT_SERIALIZE=3004;v.ANCHOR_ERROR__ACCOUNT_NOT_ENOUGH_KEYS=3005;v.ANCHOR_ERROR__ACCOUNT_NOT_MUTABLE=3006;v.ANCHOR_ERROR__ACCOUNT_OWNED_BY_WRONG_PROGRAM=3007;v.ANCHOR_ERROR__INVALID_PROGRAM_ID=3008;v.ANCHOR_ERROR__INVALID_PROGRAM_EXECUTABLE=3009;v.ANCHOR_ERROR__ACCOUNT_NOT_SIGNER=3010;v.ANCHOR_ERROR__ACCOUNT_NOT_SYSTEM_OWNED=3011;v.ANCHOR_ERROR__ACCOUNT_NOT_INITIALIZED=3012;v.ANCHOR_ERROR__ACCOUNT_NOT_PROGRAM_DATA=3013;v.ANCHOR_ERROR__ACCOUNT_NOT_ASSOCIATED_TOKEN_ACCOUNT=3014;v.ANCHOR_ERROR__ACCOUNT_SYSVAR_MISMATCH=3015;v.ANCHOR_ERROR__ACCOUNT_REALLOC_EXCEEDS_LIMIT=3016;v.ANCHOR_ERROR__ACCOUNT_DUPLICATE_REALLOCS=3017;v.ANCHOR_ERROR__DECLARED_PROGRAM_ID_MISMATCH=4100;v.ANCHOR_ERROR__TRYING_TO_INIT_PAYER_AS_PROGRAM_ACCOUNT=4101;v.ANCHOR_ERROR__INVALID_NUMERIC_CONVERSION=4102;v.ANCHOR_ERROR__DEPRECATED=5e3});var xp=ce((KI,gu)=>{"use strict";var bR=Object.prototype.hasOwnProperty,et="~";function Ls(){}a(Ls,"Events");Object.create&&(Ls.prototype=Object.create(null),new Ls().__proto__||(et=!1));function wR(n,e,t){this.fn=n,this.context=e,this.once=t||!1}a(wR,"EE");function Cp(n,e,t,r,o){if(typeof t!="function")throw new TypeError("The listener must be a function");var s=new wR(t,r||n,o),i=et?et+e:e;return n._events[i]?n._events[i].fn?n._events[i]=[n._events[i],s]:n._events[i].push(s):(n._events[i]=s,n._eventsCount++),n}a(Cp,"addListener");function Di(n,e){--n._eventsCount===0?n._events=new Ls:delete n._events[e]}a(Di,"clearEvent");function Je(){this._events=new Ls,this._eventsCount=0}a(Je,"EventEmitter");Je.prototype.eventNames=a(function(){var e=[],t,r;if(this._eventsCount===0)return e;for(r in t=this._events)bR.call(t,r)&&e.push(et?r.slice(1):r);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e},"eventNames");Je.prototype.listeners=a(function(e){var t=et?et+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,i=new Array(s);o<s;o++)i[o]=r[o].fn;return i},"listeners");Je.prototype.listenerCount=a(function(e){var t=et?et+e:e,r=this._events[t];return r?r.fn?1:r.length:0},"listenerCount");Je.prototype.emit=a(function(e,t,r,o,s,i){var u=et?et+e:e;if(!this._events[u])return!1;var f=this._events[u],y=arguments.length,d,_;if(f.fn){switch(f.once&&this.removeListener(e,f.fn,void 0,!0),y){case 1:return f.fn.call(f.context),!0;case 2:return f.fn.call(f.context,t),!0;case 3:return f.fn.call(f.context,t,r),!0;case 4:return f.fn.call(f.context,t,r,o),!0;case 5:return f.fn.call(f.context,t,r,o,s),!0;case 6:return f.fn.call(f.context,t,r,o,s,i),!0}for(_=1,d=new Array(y-1);_<y;_++)d[_-1]=arguments[_];f.fn.apply(f.context,d)}else{var E=f.length,R;for(_=0;_<E;_++)switch(f[_].once&&this.removeListener(e,f[_].fn,void 0,!0),y){case 1:f[_].fn.call(f[_].context);break;case 2:f[_].fn.call(f[_].context,t);break;case 3:f[_].fn.call(f[_].context,t,r);break;case 4:f[_].fn.call(f[_].context,t,r,o);break;default:if(!d)for(R=1,d=new Array(y-1);R<y;R++)d[R-1]=arguments[R];f[_].fn.apply(f[_].context,d)}}return!0},"emit");Je.prototype.on=a(function(e,t,r){return Cp(this,e,t,r,!1)},"on");Je.prototype.once=a(function(e,t,r){return Cp(this,e,t,r,!0)},"once");Je.prototype.removeListener=a(function(e,t,r,o){var s=et?et+e:e;if(!this._events[s])return this;if(!t)return Di(this,s),this;var i=this._events[s];if(i.fn)i.fn===t&&(!o||i.once)&&(!r||i.context===r)&&Di(this,s);else{for(var u=0,f=[],y=i.length;u<y;u++)(i[u].fn!==t||o&&!i[u].once||r&&i[u].context!==r)&&f.push(i[u]);f.length?this._events[s]=f.length===1?f[0]:f:Di(this,s)}return this},"removeListener");Je.prototype.removeAllListeners=a(function(e){var t;return e?(t=et?et+e:e,this._events[t]&&Di(this,t)):(this._events=new Ls,this._eventsCount=0),this},"removeAllListeners");Je.prototype.off=Je.prototype.removeListener;Je.prototype.addListener=Je.prototype.on;Je.prefixed=et;Je.EventEmitter=Je;typeof gu<"u"&&(gu.exports=Je)});var Mp=ce((i1,Dp)=>{"use strict";Dp.exports=function(){function n(r,o){function s(){this.constructor=r}a(s,"ctor"),s.prototype=o.prototype,r.prototype=new s}a(n,"peg$subclass");function e(r,o,s,i,u,f){this.message=r,this.expected=o,this.found=s,this.offset=i,this.line=u,this.column=f,this.name="SyntaxError"}a(e,"SyntaxError"),n(e,Error);function t(r){var o=arguments.length>1?arguments[1]:{},s={},i={start:Qu},u=Qu,f=[],y=a(function(){return _l},"peg$c1"),d=s,_="#",E={type:"literal",value:"#",description:'"#"'},R=void 0,S={type:"any",description:"any character"},A="[",C={type:"literal",value:"[",description:'"["'},x="]",w={type:"literal",value:"]",description:'"]"'},L=a(function(c){sa(We("ObjectPath",c,ze,Fe))},"peg$c11"),z=a(function(c){sa(We("ArrayPath",c,ze,Fe))},"peg$c12"),Y=a(function(c,h){return c.concat(h)},"peg$c13"),ne=a(function(c){return[c]},"peg$c14"),re=a(function(c){return c},"peg$c15"),Se=".",Ce={type:"literal",value:".",description:'"."'},ve="=",Ze={type:"literal",value:"=",description:'"="'},St=a(function(c,h){sa(We("Assign",h,ze,Fe,c))},"peg$c20"),zs=a(function(c){return c.join("")},"peg$c21"),tr=a(function(c){return c.value},"peg$c22"),Wr='"""',Wi={type:"literal",value:'"""',description:'"\\"\\"\\""'},Rr=null,Fs=a(function(c){return We("String",c.join(""),ze,Fe)},"peg$c26"),Ki='"',qi={type:"literal",value:'"',description:'"\\""'},Kr="'''",ji={type:"literal",value:"'''",description:`"'''"`},Vi="'",Gi={type:"literal",value:"'",description:`"'"`},Yi=a(function(c){return c},"peg$c33"),Yp=a(function(c){return c},"peg$c34"),Xp="\\",Jp={type:"literal",value:"\\",description:'"\\\\"'},Zp=a(function(){return""},"peg$c37"),Qp="e",ey={type:"literal",value:"e",description:'"e"'},ty="E",ry={type:"literal",value:"E",description:'"E"'},ny=a(function(c,h){return We("Float",parseFloat(c+"e"+h),ze,Fe)},"peg$c42"),sy=a(function(c){return We("Float",parseFloat(c),ze,Fe)},"peg$c43"),Xi="+",Ji={type:"literal",value:"+",description:'"+"'},Nu=a(function(c){return c.join("")},"peg$c46"),An="-",kn={type:"literal",value:"-",description:'"-"'},Cu=a(function(c){return"-"+c.join("")},"peg$c49"),oy=a(function(c){return We("Integer",parseInt(c,10),ze,Fe)},"peg$c50"),xu="true",iy={type:"literal",value:"true",description:'"true"'},ay=a(function(){return We("Boolean",!0,ze,Fe)},"peg$c53"),Lu="false",cy={type:"literal",value:"false",description:'"false"'},uy=a(function(){return We("Boolean",!1,ze,Fe)},"peg$c56"),ly=a(function(){return We("Array",[],ze,Fe)},"peg$c57"),fy=a(function(c){return We("Array",c?[c]:[],ze,Fe)},"peg$c58"),dy=a(function(c){return We("Array",c,ze,Fe)},"peg$c59"),hy=a(function(c,h){return We("Array",c.concat(h),ze,Fe)},"peg$c60"),Pu=a(function(c){return c},"peg$c61"),Bu=",",Uu={type:"literal",value:",",description:'","'},py="{",yy={type:"literal",value:"{",description:'"{"'},my="}",gy={type:"literal",value:"}",description:'"}"'},_y=a(function(c){return We("InlineTable",c,ze,Fe)},"peg$c68"),Du=a(function(c,h){return We("InlineTableValue",h,ze,Fe,c)},"peg$c69"),by=a(function(c){return"."+c},"peg$c70"),wy=a(function(c){return c.join("")},"peg$c71"),In=":",vn={type:"literal",value:":",description:'":"'},Mu=a(function(c){return c.join("")},"peg$c74"),$u="T",Hu={type:"literal",value:"T",description:'"T"'},Ry="Z",Ey={type:"literal",value:"Z",description:'"Z"'},Sy=a(function(c,h){return We("Date",new Date(c+"T"+h+"Z"),ze,Fe)},"peg$c79"),Ay=a(function(c,h){return We("Date",new Date(c+"T"+h),ze,Fe)},"peg$c80"),ky=/^[ \t]/,Iy={type:"class",value:"[ \\t]",description:"[ \\t]"},zu=`
|
20
|
+
`,Fu={type:"literal",value:`
|
21
|
+
`,description:'"\\n"'},vy="\r",Ty={type:"literal",value:"\r",description:'"\\r"'},Oy=/^[0-9a-f]/i,Ny={type:"class",value:"[0-9a-f]i",description:"[0-9a-f]i"},Cy=/^[0-9]/,xy={type:"class",value:"[0-9]",description:"[0-9]"},Ly="_",Py={type:"literal",value:"_",description:'"_"'},By=a(function(){return""},"peg$c93"),Uy=/^[A-Za-z0-9_\-]/,Dy={type:"class",value:"[A-Za-z0-9_\\-]",description:"[A-Za-z0-9_\\-]"},My=a(function(c){return c.join("")},"peg$c96"),Wu='\\"',$y={type:"literal",value:'\\"',description:'"\\\\\\""'},Hy=a(function(){return'"'},"peg$c99"),Ku="\\\\",zy={type:"literal",value:"\\\\",description:'"\\\\\\\\"'},Fy=a(function(){return"\\"},"peg$c102"),qu="\\b",Wy={type:"literal",value:"\\b",description:'"\\\\b"'},Ky=a(function(){return"\b"},"peg$c105"),ju="\\t",qy={type:"literal",value:"\\t",description:'"\\\\t"'},jy=a(function(){return" "},"peg$c108"),Vu="\\n",Vy={type:"literal",value:"\\n",description:'"\\\\n"'},Gy=a(function(){return`
|
22
|
+
`},"peg$c111"),Gu="\\f",Yy={type:"literal",value:"\\f",description:'"\\\\f"'},Xy=a(function(){return"\f"},"peg$c114"),Yu="\\r",Jy={type:"literal",value:"\\r",description:'"\\\\r"'},Zy=a(function(){return"\r"},"peg$c117"),Xu="\\U",Qy={type:"literal",value:"\\U",description:'"\\\\U"'},Ju=a(function(c){return bm(c.join(""))},"peg$c120"),Zu="\\u",em={type:"literal",value:"\\u",description:'"\\\\u"'},l=0,V=0,Tn=0,Zi={line:1,column:1,seenCR:!1},Ws=0,Qi=[],P=0,D={},Ks;if("startRule"in o){if(!(o.startRule in i))throw new Error(`Can't start parsing from rule "`+o.startRule+'".');u=i[o.startRule]}function NR(){return r.substring(V,l)}a(NR,"text");function CR(){return V}a(CR,"offset");function ze(){return ea(V).line}a(ze,"line");function Fe(){return ea(V).column}a(Fe,"column");function xR(c){throw ta(null,[{type:"other",description:c}],V)}a(xR,"expected");function LR(c){throw ta(c,null,V)}a(LR,"error");function ea(c){function h(p,m,b){var I,N;for(I=m;I<b;I++)N=r.charAt(I),N===`
|
23
|
+
`?(p.seenCR||p.line++,p.column=1,p.seenCR=!1):N==="\r"||N==="\u2028"||N==="\u2029"?(p.line++,p.column=1,p.seenCR=!0):(p.column++,p.seenCR=!1)}return a(h,"advance"),Tn!==c&&(Tn>c&&(Tn=0,Zi={line:1,column:1,seenCR:!1}),h(Zi,Tn,c),Tn=c),Zi}a(ea,"peg$computePosDetails");function M(c){l<Ws||(l>Ws&&(Ws=l,Qi=[]),Qi.push(c))}a(M,"peg$fail");function ta(c,h,p){function m(q){var te=1;for(q.sort(function(Re,he){return Re.description<he.description?-1:Re.description>he.description?1:0});te<q.length;)q[te-1]===q[te]?q.splice(te,1):te++}a(m,"cleanupExpected");function b(q,te){function Re(jr){function rr(at){return at.charCodeAt(0).toString(16).toUpperCase()}return a(rr,"hex"),jr.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E\x0F]/g,function(at){return"\\x0"+rr(at)}).replace(/[\x10-\x1F\x80-\xFF]/g,function(at){return"\\x"+rr(at)}).replace(/[\u0180-\u0FFF]/g,function(at){return"\\u0"+rr(at)}).replace(/[\u1080-\uFFFF]/g,function(at){return"\\u"+rr(at)})}a(Re,"stringEscape");var he=new Array(q.length),Oe,Le,it;for(it=0;it<q.length;it++)he[it]=q[it].description;return Oe=q.length>1?he.slice(0,-1).join(", ")+" or "+he[q.length-1]:he[0],Le=te?'"'+Re(te)+'"':"end of input","Expected "+Oe+" but "+Le+" found."}a(b,"buildMessage");var I=ea(p),N=p<r.length?r.charAt(p):null;return h!==null&&m(h),new e(c!==null?c:b(h,N),h,N,p,I.line,I.column)}a(ta,"peg$buildException");function Qu(){var c,h,p,m=l*49+0,b=D[m];if(b)return l=b.nextPos,b.result;for(c=l,h=[],p=el();p!==s;)h.push(p),p=el();return h!==s&&(V=c,h=y()),c=h,D[m]={nextPos:l,result:c},c}a(Qu,"peg$parsestart");function el(){var c,h,p,m,b,I,N,q=l*49+1,te=D[q];if(te)return l=te.nextPos,te.result;for(c=l,h=[],p=G();p!==s;)h.push(p),p=G();if(h!==s)if(p=tm(),p!==s){for(m=[],b=G();b!==s;)m.push(b),b=G();if(m!==s){for(b=[],I=qs();I!==s;)b.push(I),I=qs();if(b!==s){if(I=[],N=ht(),N!==s)for(;N!==s;)I.push(N),N=ht();else I=d;I===s&&(I=Vs()),I!==s?(h=[h,p,m,b,I],c=h):(l=c,c=d)}else l=c,c=d}else l=c,c=d}else l=c,c=d;else l=c,c=d;if(c===s){if(c=l,h=[],p=G(),p!==s)for(;p!==s;)h.push(p),p=G();else h=d;if(h!==s){if(p=[],m=ht(),m!==s)for(;m!==s;)p.push(m),m=ht();else p=d;p===s&&(p=Vs()),p!==s?(h=[h,p],c=h):(l=c,c=d)}else l=c,c=d;c===s&&(c=ht())}return D[q]={nextPos:l,result:c},c}a(el,"peg$parseline");function tm(){var c,h=l*49+2,p=D[h];return p?(l=p.nextPos,p.result):(c=qs(),c===s&&(c=rm(),c===s&&(c=nm(),c===s&&(c=sm()))),D[h]={nextPos:l,result:c},c)}a(tm,"peg$parseexpression");function qs(){var c,h,p,m,b,I,N=l*49+3,q=D[N];if(q)return l=q.nextPos,q.result;if(c=l,r.charCodeAt(l)===35?(h=_,l++):(h=s,P===0&&M(E)),h!==s){for(p=[],m=l,b=l,P++,I=ht(),I===s&&(I=Vs()),P--,I===s?b=R:(l=b,b=d),b!==s?(r.length>l?(I=r.charAt(l),l++):(I=s,P===0&&M(S)),I!==s?(b=[b,I],m=b):(l=m,m=d)):(l=m,m=d);m!==s;)p.push(m),m=l,b=l,P++,I=ht(),I===s&&(I=Vs()),P--,I===s?b=R:(l=b,b=d),b!==s?(r.length>l?(I=r.charAt(l),l++):(I=s,P===0&&M(S)),I!==s?(b=[b,I],m=b):(l=m,m=d)):(l=m,m=d);p!==s?(h=[h,p],c=h):(l=c,c=d)}else l=c,c=d;return D[N]={nextPos:l,result:c},c}a(qs,"peg$parsecomment");function rm(){var c,h,p,m,b,I,N=l*49+4,q=D[N];if(q)return l=q.nextPos,q.result;if(c=l,r.charCodeAt(l)===91?(h=A,l++):(h=s,P===0&&M(C)),h!==s){for(p=[],m=G();m!==s;)p.push(m),m=G();if(p!==s)if(m=tl(),m!==s){for(b=[],I=G();I!==s;)b.push(I),I=G();b!==s?(r.charCodeAt(l)===93?(I=x,l++):(I=s,P===0&&M(w)),I!==s?(V=c,h=L(m),c=h):(l=c,c=d)):(l=c,c=d)}else l=c,c=d;else l=c,c=d}else l=c,c=d;return D[N]={nextPos:l,result:c},c}a(rm,"peg$parsepath");function nm(){var c,h,p,m,b,I,N,q,te=l*49+5,Re=D[te];if(Re)return l=Re.nextPos,Re.result;if(c=l,r.charCodeAt(l)===91?(h=A,l++):(h=s,P===0&&M(C)),h!==s)if(r.charCodeAt(l)===91?(p=A,l++):(p=s,P===0&&M(C)),p!==s){for(m=[],b=G();b!==s;)m.push(b),b=G();if(m!==s)if(b=tl(),b!==s){for(I=[],N=G();N!==s;)I.push(N),N=G();I!==s?(r.charCodeAt(l)===93?(N=x,l++):(N=s,P===0&&M(w)),N!==s?(r.charCodeAt(l)===93?(q=x,l++):(q=s,P===0&&M(w)),q!==s?(V=c,h=z(b),c=h):(l=c,c=d)):(l=c,c=d)):(l=c,c=d)}else l=c,c=d;else l=c,c=d}else l=c,c=d;else l=c,c=d;return D[te]={nextPos:l,result:c},c}a(nm,"peg$parsetablearray");function tl(){var c,h,p,m=l*49+6,b=D[m];if(b)return l=b.nextPos,b.result;if(c=l,h=[],p=nl(),p!==s)for(;p!==s;)h.push(p),p=nl();else h=d;return h!==s?(p=rl(),p!==s?(V=c,h=Y(h,p),c=h):(l=c,c=d)):(l=c,c=d),c===s&&(c=l,h=rl(),h!==s&&(V=c,h=ne(h)),c=h),D[m]={nextPos:l,result:c},c}a(tl,"peg$parsetable_key");function rl(){var c,h,p,m,b,I=l*49+7,N=D[I];if(N)return l=N.nextPos,N.result;for(c=l,h=[],p=G();p!==s;)h.push(p),p=G();if(h!==s)if(p=On(),p!==s){for(m=[],b=G();b!==s;)m.push(b),b=G();m!==s?(V=c,h=re(p),c=h):(l=c,c=d)}else l=c,c=d;else l=c,c=d;if(c===s){for(c=l,h=[],p=G();p!==s;)h.push(p),p=G();if(h!==s)if(p=ra(),p!==s){for(m=[],b=G();b!==s;)m.push(b),b=G();m!==s?(V=c,h=re(p),c=h):(l=c,c=d)}else l=c,c=d;else l=c,c=d}return D[I]={nextPos:l,result:c},c}a(rl,"peg$parsetable_key_part");function nl(){var c,h,p,m,b,I,N,q=l*49+8,te=D[q];if(te)return l=te.nextPos,te.result;for(c=l,h=[],p=G();p!==s;)h.push(p),p=G();if(h!==s)if(p=On(),p!==s){for(m=[],b=G();b!==s;)m.push(b),b=G();if(m!==s)if(r.charCodeAt(l)===46?(b=Se,l++):(b=s,P===0&&M(Ce)),b!==s){for(I=[],N=G();N!==s;)I.push(N),N=G();I!==s?(V=c,h=re(p),c=h):(l=c,c=d)}else l=c,c=d;else l=c,c=d}else l=c,c=d;else l=c,c=d;if(c===s){for(c=l,h=[],p=G();p!==s;)h.push(p),p=G();if(h!==s)if(p=ra(),p!==s){for(m=[],b=G();b!==s;)m.push(b),b=G();if(m!==s)if(r.charCodeAt(l)===46?(b=Se,l++):(b=s,P===0&&M(Ce)),b!==s){for(I=[],N=G();N!==s;)I.push(N),N=G();I!==s?(V=c,h=re(p),c=h):(l=c,c=d)}else l=c,c=d;else l=c,c=d}else l=c,c=d;else l=c,c=d}return D[q]={nextPos:l,result:c},c}a(nl,"peg$parsedot_ended_table_key_part");function sm(){var c,h,p,m,b,I,N=l*49+9,q=D[N];if(q)return l=q.nextPos,q.result;if(c=l,h=On(),h!==s){for(p=[],m=G();m!==s;)p.push(m),m=G();if(p!==s)if(r.charCodeAt(l)===61?(m=ve,l++):(m=s,P===0&&M(Ze)),m!==s){for(b=[],I=G();I!==s;)b.push(I),I=G();b!==s?(I=qr(),I!==s?(V=c,h=St(h,I),c=h):(l=c,c=d)):(l=c,c=d)}else l=c,c=d;else l=c,c=d}else l=c,c=d;if(c===s)if(c=l,h=ra(),h!==s){for(p=[],m=G();m!==s;)p.push(m),m=G();if(p!==s)if(r.charCodeAt(l)===61?(m=ve,l++):(m=s,P===0&&M(Ze)),m!==s){for(b=[],I=G();I!==s;)b.push(I),I=G();b!==s?(I=qr(),I!==s?(V=c,h=St(h,I),c=h):(l=c,c=d)):(l=c,c=d)}else l=c,c=d;else l=c,c=d}else l=c,c=d;return D[N]={nextPos:l,result:c},c}a(sm,"peg$parseassignment");function On(){var c,h,p,m=l*49+10,b=D[m];if(b)return l=b.nextPos,b.result;if(c=l,h=[],p=ml(),p!==s)for(;p!==s;)h.push(p),p=ml();else h=d;return h!==s&&(V=c,h=zs(h)),c=h,D[m]={nextPos:l,result:c},c}a(On,"peg$parsekey");function ra(){var c,h,p=l*49+11,m=D[p];return m?(l=m.nextPos,m.result):(c=l,h=sl(),h!==s&&(V=c,h=tr(h)),c=h,c===s&&(c=l,h=ol(),h!==s&&(V=c,h=tr(h)),c=h),D[p]={nextPos:l,result:c},c)}a(ra,"peg$parsequoted_key");function qr(){var c,h=l*49+12,p=D[h];return p?(l=p.nextPos,p.result):(c=om(),c===s&&(c=mm(),c===s&&(c=um(),c===s&&(c=lm(),c===s&&(c=fm(),c===s&&(c=dm(),c===s&&(c=hm())))))),D[h]={nextPos:l,result:c},c)}a(qr,"peg$parsevalue");function om(){var c,h=l*49+13,p=D[h];return p?(l=p.nextPos,p.result):(c=im(),c===s&&(c=sl(),c===s&&(c=am(),c===s&&(c=ol()))),D[h]={nextPos:l,result:c},c)}a(om,"peg$parsestring");function im(){var c,h,p,m,b,I=l*49+14,N=D[I];if(N)return l=N.nextPos,N.result;if(c=l,r.substr(l,3)===Wr?(h=Wr,l+=3):(h=s,P===0&&M(Wi)),h!==s)if(p=ht(),p===s&&(p=Rr),p!==s){for(m=[],b=cl();b!==s;)m.push(b),b=cl();m!==s?(r.substr(l,3)===Wr?(b=Wr,l+=3):(b=s,P===0&&M(Wi)),b!==s?(V=c,h=Fs(m),c=h):(l=c,c=d)):(l=c,c=d)}else l=c,c=d;else l=c,c=d;return D[I]={nextPos:l,result:c},c}a(im,"peg$parsedouble_quoted_multiline_string");function sl(){var c,h,p,m,b=l*49+15,I=D[b];if(I)return l=I.nextPos,I.result;if(c=l,r.charCodeAt(l)===34?(h=Ki,l++):(h=s,P===0&&M(qi)),h!==s){for(p=[],m=il();m!==s;)p.push(m),m=il();p!==s?(r.charCodeAt(l)===34?(m=Ki,l++):(m=s,P===0&&M(qi)),m!==s?(V=c,h=Fs(p),c=h):(l=c,c=d)):(l=c,c=d)}else l=c,c=d;return D[b]={nextPos:l,result:c},c}a(sl,"peg$parsedouble_quoted_single_line_string");function am(){var c,h,p,m,b,I=l*49+16,N=D[I];if(N)return l=N.nextPos,N.result;if(c=l,r.substr(l,3)===Kr?(h=Kr,l+=3):(h=s,P===0&&M(ji)),h!==s)if(p=ht(),p===s&&(p=Rr),p!==s){for(m=[],b=ul();b!==s;)m.push(b),b=ul();m!==s?(r.substr(l,3)===Kr?(b=Kr,l+=3):(b=s,P===0&&M(ji)),b!==s?(V=c,h=Fs(m),c=h):(l=c,c=d)):(l=c,c=d)}else l=c,c=d;else l=c,c=d;return D[I]={nextPos:l,result:c},c}a(am,"peg$parsesingle_quoted_multiline_string");function ol(){var c,h,p,m,b=l*49+17,I=D[b];if(I)return l=I.nextPos,I.result;if(c=l,r.charCodeAt(l)===39?(h=Vi,l++):(h=s,P===0&&M(Gi)),h!==s){for(p=[],m=al();m!==s;)p.push(m),m=al();p!==s?(r.charCodeAt(l)===39?(m=Vi,l++):(m=s,P===0&&M(Gi)),m!==s?(V=c,h=Fs(p),c=h):(l=c,c=d)):(l=c,c=d)}else l=c,c=d;return D[b]={nextPos:l,result:c},c}a(ol,"peg$parsesingle_quoted_single_line_string");function il(){var c,h,p,m=l*49+18,b=D[m];return b?(l=b.nextPos,b.result):(c=gl(),c===s&&(c=l,h=l,P++,r.charCodeAt(l)===34?(p=Ki,l++):(p=s,P===0&&M(qi)),P--,p===s?h=R:(l=h,h=d),h!==s?(r.length>l?(p=r.charAt(l),l++):(p=s,P===0&&M(S)),p!==s?(V=c,h=Yi(p),c=h):(l=c,c=d)):(l=c,c=d)),D[m]={nextPos:l,result:c},c)}a(il,"peg$parsestring_char");function al(){var c,h,p,m=l*49+19,b=D[m];return b?(l=b.nextPos,b.result):(c=l,h=l,P++,r.charCodeAt(l)===39?(p=Vi,l++):(p=s,P===0&&M(Gi)),P--,p===s?h=R:(l=h,h=d),h!==s?(r.length>l?(p=r.charAt(l),l++):(p=s,P===0&&M(S)),p!==s?(V=c,h=Yi(p),c=h):(l=c,c=d)):(l=c,c=d),D[m]={nextPos:l,result:c},c)}a(al,"peg$parseliteral_char");function cl(){var c,h,p,m=l*49+20,b=D[m];return b?(l=b.nextPos,b.result):(c=gl(),c===s&&(c=cm(),c===s&&(c=l,h=l,P++,r.substr(l,3)===Wr?(p=Wr,l+=3):(p=s,P===0&&M(Wi)),P--,p===s?h=R:(l=h,h=d),h!==s?(r.length>l?(p=r.charAt(l),l++):(p=s,P===0&&M(S)),p!==s?(V=c,h=Yp(p),c=h):(l=c,c=d)):(l=c,c=d))),D[m]={nextPos:l,result:c},c)}a(cl,"peg$parsemultiline_string_char");function cm(){var c,h,p,m,b,I=l*49+21,N=D[I];if(N)return l=N.nextPos,N.result;if(c=l,r.charCodeAt(l)===92?(h=Xp,l++):(h=s,P===0&&M(Jp)),h!==s)if(p=ht(),p!==s){for(m=[],b=yl();b!==s;)m.push(b),b=yl();m!==s?(V=c,h=Zp(),c=h):(l=c,c=d)}else l=c,c=d;else l=c,c=d;return D[I]={nextPos:l,result:c},c}a(cm,"peg$parsemultiline_string_delim");function ul(){var c,h,p,m=l*49+22,b=D[m];return b?(l=b.nextPos,b.result):(c=l,h=l,P++,r.substr(l,3)===Kr?(p=Kr,l+=3):(p=s,P===0&&M(ji)),P--,p===s?h=R:(l=h,h=d),h!==s?(r.length>l?(p=r.charAt(l),l++):(p=s,P===0&&M(S)),p!==s?(V=c,h=Yi(p),c=h):(l=c,c=d)):(l=c,c=d),D[m]={nextPos:l,result:c},c)}a(ul,"peg$parsemultiline_literal_char");function um(){var c,h,p,m,b=l*49+23,I=D[b];return I?(l=I.nextPos,I.result):(c=l,h=ll(),h===s&&(h=na()),h!==s?(r.charCodeAt(l)===101?(p=Qp,l++):(p=s,P===0&&M(ey)),p===s&&(r.charCodeAt(l)===69?(p=ty,l++):(p=s,P===0&&M(ry))),p!==s?(m=na(),m!==s?(V=c,h=ny(h,m),c=h):(l=c,c=d)):(l=c,c=d)):(l=c,c=d),c===s&&(c=l,h=ll(),h!==s&&(V=c,h=sy(h)),c=h),D[b]={nextPos:l,result:c},c)}a(um,"peg$parsefloat");function ll(){var c,h,p,m,b,I,N=l*49+24,q=D[N];return q?(l=q.nextPos,q.result):(c=l,r.charCodeAt(l)===43?(h=Xi,l++):(h=s,P===0&&M(Ji)),h===s&&(h=Rr),h!==s?(p=l,m=Nn(),m!==s?(r.charCodeAt(l)===46?(b=Se,l++):(b=s,P===0&&M(Ce)),b!==s?(I=Nn(),I!==s?(m=[m,b,I],p=m):(l=p,p=d)):(l=p,p=d)):(l=p,p=d),p!==s?(V=c,h=Nu(p),c=h):(l=c,c=d)):(l=c,c=d),c===s&&(c=l,r.charCodeAt(l)===45?(h=An,l++):(h=s,P===0&&M(kn)),h!==s?(p=l,m=Nn(),m!==s?(r.charCodeAt(l)===46?(b=Se,l++):(b=s,P===0&&M(Ce)),b!==s?(I=Nn(),I!==s?(m=[m,b,I],p=m):(l=p,p=d)):(l=p,p=d)):(l=p,p=d),p!==s?(V=c,h=Cu(p),c=h):(l=c,c=d)):(l=c,c=d)),D[N]={nextPos:l,result:c},c)}a(ll,"peg$parsefloat_text");function lm(){var c,h,p=l*49+25,m=D[p];return m?(l=m.nextPos,m.result):(c=l,h=na(),h!==s&&(V=c,h=oy(h)),c=h,D[p]={nextPos:l,result:c},c)}a(lm,"peg$parseinteger");function na(){var c,h,p,m,b,I=l*49+26,N=D[I];if(N)return l=N.nextPos,N.result;if(c=l,r.charCodeAt(l)===43?(h=Xi,l++):(h=s,P===0&&M(Ji)),h===s&&(h=Rr),h!==s){if(p=[],m=be(),m!==s)for(;m!==s;)p.push(m),m=be();else p=d;p!==s?(m=l,P++,r.charCodeAt(l)===46?(b=Se,l++):(b=s,P===0&&M(Ce)),P--,b===s?m=R:(l=m,m=d),m!==s?(V=c,h=Nu(p),c=h):(l=c,c=d)):(l=c,c=d)}else l=c,c=d;if(c===s)if(c=l,r.charCodeAt(l)===45?(h=An,l++):(h=s,P===0&&M(kn)),h!==s){if(p=[],m=be(),m!==s)for(;m!==s;)p.push(m),m=be();else p=d;p!==s?(m=l,P++,r.charCodeAt(l)===46?(b=Se,l++):(b=s,P===0&&M(Ce)),P--,b===s?m=R:(l=m,m=d),m!==s?(V=c,h=Cu(p),c=h):(l=c,c=d)):(l=c,c=d)}else l=c,c=d;return D[I]={nextPos:l,result:c},c}a(na,"peg$parseinteger_text");function fm(){var c,h,p=l*49+27,m=D[p];return m?(l=m.nextPos,m.result):(c=l,r.substr(l,4)===xu?(h=xu,l+=4):(h=s,P===0&&M(iy)),h!==s&&(V=c,h=ay()),c=h,c===s&&(c=l,r.substr(l,5)===Lu?(h=Lu,l+=5):(h=s,P===0&&M(cy)),h!==s&&(V=c,h=uy()),c=h),D[p]={nextPos:l,result:c},c)}a(fm,"peg$parseboolean");function dm(){var c,h,p,m,b,I=l*49+28,N=D[I];if(N)return l=N.nextPos,N.result;if(c=l,r.charCodeAt(l)===91?(h=A,l++):(h=s,P===0&&M(C)),h!==s){for(p=[],m=dt();m!==s;)p.push(m),m=dt();p!==s?(r.charCodeAt(l)===93?(m=x,l++):(m=s,P===0&&M(w)),m!==s?(V=c,h=ly(),c=h):(l=c,c=d)):(l=c,c=d)}else l=c,c=d;if(c===s&&(c=l,r.charCodeAt(l)===91?(h=A,l++):(h=s,P===0&&M(C)),h!==s?(p=fl(),p===s&&(p=Rr),p!==s?(r.charCodeAt(l)===93?(m=x,l++):(m=s,P===0&&M(w)),m!==s?(V=c,h=fy(p),c=h):(l=c,c=d)):(l=c,c=d)):(l=c,c=d),c===s)){if(c=l,r.charCodeAt(l)===91?(h=A,l++):(h=s,P===0&&M(C)),h!==s){if(p=[],m=js(),m!==s)for(;m!==s;)p.push(m),m=js();else p=d;p!==s?(r.charCodeAt(l)===93?(m=x,l++):(m=s,P===0&&M(w)),m!==s?(V=c,h=dy(p),c=h):(l=c,c=d)):(l=c,c=d)}else l=c,c=d;if(c===s)if(c=l,r.charCodeAt(l)===91?(h=A,l++):(h=s,P===0&&M(C)),h!==s){if(p=[],m=js(),m!==s)for(;m!==s;)p.push(m),m=js();else p=d;p!==s?(m=fl(),m!==s?(r.charCodeAt(l)===93?(b=x,l++):(b=s,P===0&&M(w)),b!==s?(V=c,h=hy(p,m),c=h):(l=c,c=d)):(l=c,c=d)):(l=c,c=d)}else l=c,c=d}return D[I]={nextPos:l,result:c},c}a(dm,"peg$parsearray");function fl(){var c,h,p,m,b,I=l*49+29,N=D[I];if(N)return l=N.nextPos,N.result;for(c=l,h=[],p=dt();p!==s;)h.push(p),p=dt();if(h!==s)if(p=qr(),p!==s){for(m=[],b=dt();b!==s;)m.push(b),b=dt();m!==s?(V=c,h=Pu(p),c=h):(l=c,c=d)}else l=c,c=d;else l=c,c=d;return D[I]={nextPos:l,result:c},c}a(fl,"peg$parsearray_value");function js(){var c,h,p,m,b,I,N,q=l*49+30,te=D[q];if(te)return l=te.nextPos,te.result;for(c=l,h=[],p=dt();p!==s;)h.push(p),p=dt();if(h!==s)if(p=qr(),p!==s){for(m=[],b=dt();b!==s;)m.push(b),b=dt();if(m!==s)if(r.charCodeAt(l)===44?(b=Bu,l++):(b=s,P===0&&M(Uu)),b!==s){for(I=[],N=dt();N!==s;)I.push(N),N=dt();I!==s?(V=c,h=Pu(p),c=h):(l=c,c=d)}else l=c,c=d;else l=c,c=d}else l=c,c=d;else l=c,c=d;return D[q]={nextPos:l,result:c},c}a(js,"peg$parsearray_value_list");function dt(){var c,h=l*49+31,p=D[h];return p?(l=p.nextPos,p.result):(c=G(),c===s&&(c=ht(),c===s&&(c=qs())),D[h]={nextPos:l,result:c},c)}a(dt,"peg$parsearray_sep");function hm(){var c,h,p,m,b,I,N=l*49+32,q=D[N];if(q)return l=q.nextPos,q.result;if(c=l,r.charCodeAt(l)===123?(h=py,l++):(h=s,P===0&&M(yy)),h!==s){for(p=[],m=G();m!==s;)p.push(m),m=G();if(p!==s){for(m=[],b=dl();b!==s;)m.push(b),b=dl();if(m!==s){for(b=[],I=G();I!==s;)b.push(I),I=G();b!==s?(r.charCodeAt(l)===125?(I=my,l++):(I=s,P===0&&M(gy)),I!==s?(V=c,h=_y(m),c=h):(l=c,c=d)):(l=c,c=d)}else l=c,c=d}else l=c,c=d}else l=c,c=d;return D[N]={nextPos:l,result:c},c}a(hm,"peg$parseinline_table");function dl(){var c,h,p,m,b,I,N,q,te,Re,he,Oe=l*49+33,Le=D[Oe];if(Le)return l=Le.nextPos,Le.result;for(c=l,h=[],p=G();p!==s;)h.push(p),p=G();if(h!==s)if(p=On(),p!==s){for(m=[],b=G();b!==s;)m.push(b),b=G();if(m!==s)if(r.charCodeAt(l)===61?(b=ve,l++):(b=s,P===0&&M(Ze)),b!==s){for(I=[],N=G();N!==s;)I.push(N),N=G();if(I!==s)if(N=qr(),N!==s){for(q=[],te=G();te!==s;)q.push(te),te=G();if(q!==s)if(r.charCodeAt(l)===44?(te=Bu,l++):(te=s,P===0&&M(Uu)),te!==s){for(Re=[],he=G();he!==s;)Re.push(he),he=G();Re!==s?(V=c,h=Du(p,N),c=h):(l=c,c=d)}else l=c,c=d;else l=c,c=d}else l=c,c=d;else l=c,c=d}else l=c,c=d;else l=c,c=d}else l=c,c=d;else l=c,c=d;if(c===s){for(c=l,h=[],p=G();p!==s;)h.push(p),p=G();if(h!==s)if(p=On(),p!==s){for(m=[],b=G();b!==s;)m.push(b),b=G();if(m!==s)if(r.charCodeAt(l)===61?(b=ve,l++):(b=s,P===0&&M(Ze)),b!==s){for(I=[],N=G();N!==s;)I.push(N),N=G();I!==s?(N=qr(),N!==s?(V=c,h=Du(p,N),c=h):(l=c,c=d)):(l=c,c=d)}else l=c,c=d;else l=c,c=d}else l=c,c=d;else l=c,c=d}return D[Oe]={nextPos:l,result:c},c}a(dl,"peg$parseinline_table_assignment");function hl(){var c,h,p,m=l*49+34,b=D[m];return b?(l=b.nextPos,b.result):(c=l,r.charCodeAt(l)===46?(h=Se,l++):(h=s,P===0&&M(Ce)),h!==s?(p=Nn(),p!==s?(V=c,h=by(p),c=h):(l=c,c=d)):(l=c,c=d),D[m]={nextPos:l,result:c},c)}a(hl,"peg$parsesecfragment");function pl(){var c,h,p,m,b,I,N,q,te,Re,he,Oe,Le=l*49+35,it=D[Le];return it?(l=it.nextPos,it.result):(c=l,h=l,p=be(),p!==s?(m=be(),m!==s?(b=be(),b!==s?(I=be(),I!==s?(r.charCodeAt(l)===45?(N=An,l++):(N=s,P===0&&M(kn)),N!==s?(q=be(),q!==s?(te=be(),te!==s?(r.charCodeAt(l)===45?(Re=An,l++):(Re=s,P===0&&M(kn)),Re!==s?(he=be(),he!==s?(Oe=be(),Oe!==s?(p=[p,m,b,I,N,q,te,Re,he,Oe],h=p):(l=h,h=d)):(l=h,h=d)):(l=h,h=d)):(l=h,h=d)):(l=h,h=d)):(l=h,h=d)):(l=h,h=d)):(l=h,h=d)):(l=h,h=d)):(l=h,h=d),h!==s&&(V=c,h=wy(h)),c=h,D[Le]={nextPos:l,result:c},c)}a(pl,"peg$parsedate");function pm(){var c,h,p,m,b,I,N,q,te,Re,he,Oe=l*49+36,Le=D[Oe];return Le?(l=Le.nextPos,Le.result):(c=l,h=l,p=be(),p!==s?(m=be(),m!==s?(r.charCodeAt(l)===58?(b=In,l++):(b=s,P===0&&M(vn)),b!==s?(I=be(),I!==s?(N=be(),N!==s?(r.charCodeAt(l)===58?(q=In,l++):(q=s,P===0&&M(vn)),q!==s?(te=be(),te!==s?(Re=be(),Re!==s?(he=hl(),he===s&&(he=Rr),he!==s?(p=[p,m,b,I,N,q,te,Re,he],h=p):(l=h,h=d)):(l=h,h=d)):(l=h,h=d)):(l=h,h=d)):(l=h,h=d)):(l=h,h=d)):(l=h,h=d)):(l=h,h=d)):(l=h,h=d),h!==s&&(V=c,h=Mu(h)),c=h,D[Oe]={nextPos:l,result:c},c)}a(pm,"peg$parsetime");function ym(){var c,h,p,m,b,I,N,q,te,Re,he,Oe,Le,it,jr,rr,at,bl=l*49+37,oa=D[bl];return oa?(l=oa.nextPos,oa.result):(c=l,h=l,p=be(),p!==s?(m=be(),m!==s?(r.charCodeAt(l)===58?(b=In,l++):(b=s,P===0&&M(vn)),b!==s?(I=be(),I!==s?(N=be(),N!==s?(r.charCodeAt(l)===58?(q=In,l++):(q=s,P===0&&M(vn)),q!==s?(te=be(),te!==s?(Re=be(),Re!==s?(he=hl(),he===s&&(he=Rr),he!==s?(r.charCodeAt(l)===45?(Oe=An,l++):(Oe=s,P===0&&M(kn)),Oe===s&&(r.charCodeAt(l)===43?(Oe=Xi,l++):(Oe=s,P===0&&M(Ji))),Oe!==s?(Le=be(),Le!==s?(it=be(),it!==s?(r.charCodeAt(l)===58?(jr=In,l++):(jr=s,P===0&&M(vn)),jr!==s?(rr=be(),rr!==s?(at=be(),at!==s?(p=[p,m,b,I,N,q,te,Re,he,Oe,Le,it,jr,rr,at],h=p):(l=h,h=d)):(l=h,h=d)):(l=h,h=d)):(l=h,h=d)):(l=h,h=d)):(l=h,h=d)):(l=h,h=d)):(l=h,h=d)):(l=h,h=d)):(l=h,h=d)):(l=h,h=d)):(l=h,h=d)):(l=h,h=d)):(l=h,h=d)):(l=h,h=d),h!==s&&(V=c,h=Mu(h)),c=h,D[bl]={nextPos:l,result:c},c)}a(ym,"peg$parsetime_with_offset");function mm(){var c,h,p,m,b,I=l*49+38,N=D[I];return N?(l=N.nextPos,N.result):(c=l,h=pl(),h!==s?(r.charCodeAt(l)===84?(p=$u,l++):(p=s,P===0&&M(Hu)),p!==s?(m=pm(),m!==s?(r.charCodeAt(l)===90?(b=Ry,l++):(b=s,P===0&&M(Ey)),b!==s?(V=c,h=Sy(h,m),c=h):(l=c,c=d)):(l=c,c=d)):(l=c,c=d)):(l=c,c=d),c===s&&(c=l,h=pl(),h!==s?(r.charCodeAt(l)===84?(p=$u,l++):(p=s,P===0&&M(Hu)),p!==s?(m=ym(),m!==s?(V=c,h=Ay(h,m),c=h):(l=c,c=d)):(l=c,c=d)):(l=c,c=d)),D[I]={nextPos:l,result:c},c)}a(mm,"peg$parsedatetime");function G(){var c,h=l*49+39,p=D[h];return p?(l=p.nextPos,p.result):(ky.test(r.charAt(l))?(c=r.charAt(l),l++):(c=s,P===0&&M(Iy)),D[h]={nextPos:l,result:c},c)}a(G,"peg$parseS");function ht(){var c,h,p,m=l*49+40,b=D[m];return b?(l=b.nextPos,b.result):(r.charCodeAt(l)===10?(c=zu,l++):(c=s,P===0&&M(Fu)),c===s&&(c=l,r.charCodeAt(l)===13?(h=vy,l++):(h=s,P===0&&M(Ty)),h!==s?(r.charCodeAt(l)===10?(p=zu,l++):(p=s,P===0&&M(Fu)),p!==s?(h=[h,p],c=h):(l=c,c=d)):(l=c,c=d)),D[m]={nextPos:l,result:c},c)}a(ht,"peg$parseNL");function yl(){var c,h=l*49+41,p=D[h];return p?(l=p.nextPos,p.result):(c=ht(),c===s&&(c=G()),D[h]={nextPos:l,result:c},c)}a(yl,"peg$parseNLS");function Vs(){var c,h,p=l*49+42,m=D[p];return m?(l=m.nextPos,m.result):(c=l,P++,r.length>l?(h=r.charAt(l),l++):(h=s,P===0&&M(S)),P--,h===s?c=R:(l=c,c=d),D[p]={nextPos:l,result:c},c)}a(Vs,"peg$parseEOF");function pt(){var c,h=l*49+43,p=D[h];return p?(l=p.nextPos,p.result):(Oy.test(r.charAt(l))?(c=r.charAt(l),l++):(c=s,P===0&&M(Ny)),D[h]={nextPos:l,result:c},c)}a(pt,"peg$parseHEX");function be(){var c,h,p=l*49+44,m=D[p];return m?(l=m.nextPos,m.result):(Cy.test(r.charAt(l))?(c=r.charAt(l),l++):(c=s,P===0&&M(xy)),c===s&&(c=l,r.charCodeAt(l)===95?(h=Ly,l++):(h=s,P===0&&M(Py)),h!==s&&(V=c,h=By()),c=h),D[p]={nextPos:l,result:c},c)}a(be,"peg$parseDIGIT_OR_UNDER");function ml(){var c,h=l*49+45,p=D[h];return p?(l=p.nextPos,p.result):(Uy.test(r.charAt(l))?(c=r.charAt(l),l++):(c=s,P===0&&M(Dy)),D[h]={nextPos:l,result:c},c)}a(ml,"peg$parseASCII_BASIC");function Nn(){var c,h,p,m=l*49+46,b=D[m];if(b)return l=b.nextPos,b.result;if(c=l,h=[],p=be(),p!==s)for(;p!==s;)h.push(p),p=be();else h=d;return h!==s&&(V=c,h=My(h)),c=h,D[m]={nextPos:l,result:c},c}a(Nn,"peg$parseDIGITS");function gl(){var c,h,p=l*49+47,m=D[p];return m?(l=m.nextPos,m.result):(c=l,r.substr(l,2)===Wu?(h=Wu,l+=2):(h=s,P===0&&M($y)),h!==s&&(V=c,h=Hy()),c=h,c===s&&(c=l,r.substr(l,2)===Ku?(h=Ku,l+=2):(h=s,P===0&&M(zy)),h!==s&&(V=c,h=Fy()),c=h,c===s&&(c=l,r.substr(l,2)===qu?(h=qu,l+=2):(h=s,P===0&&M(Wy)),h!==s&&(V=c,h=Ky()),c=h,c===s&&(c=l,r.substr(l,2)===ju?(h=ju,l+=2):(h=s,P===0&&M(qy)),h!==s&&(V=c,h=jy()),c=h,c===s&&(c=l,r.substr(l,2)===Vu?(h=Vu,l+=2):(h=s,P===0&&M(Vy)),h!==s&&(V=c,h=Gy()),c=h,c===s&&(c=l,r.substr(l,2)===Gu?(h=Gu,l+=2):(h=s,P===0&&M(Yy)),h!==s&&(V=c,h=Xy()),c=h,c===s&&(c=l,r.substr(l,2)===Yu?(h=Yu,l+=2):(h=s,P===0&&M(Jy)),h!==s&&(V=c,h=Zy()),c=h,c===s&&(c=gm()))))))),D[p]={nextPos:l,result:c},c)}a(gl,"peg$parseESCAPED");function gm(){var c,h,p,m,b,I,N,q,te,Re,he,Oe=l*49+48,Le=D[Oe];return Le?(l=Le.nextPos,Le.result):(c=l,r.substr(l,2)===Xu?(h=Xu,l+=2):(h=s,P===0&&M(Qy)),h!==s?(p=l,m=pt(),m!==s?(b=pt(),b!==s?(I=pt(),I!==s?(N=pt(),N!==s?(q=pt(),q!==s?(te=pt(),te!==s?(Re=pt(),Re!==s?(he=pt(),he!==s?(m=[m,b,I,N,q,te,Re,he],p=m):(l=p,p=d)):(l=p,p=d)):(l=p,p=d)):(l=p,p=d)):(l=p,p=d)):(l=p,p=d)):(l=p,p=d)):(l=p,p=d),p!==s?(V=c,h=Ju(p),c=h):(l=c,c=d)):(l=c,c=d),c===s&&(c=l,r.substr(l,2)===Zu?(h=Zu,l+=2):(h=s,P===0&&M(em)),h!==s?(p=l,m=pt(),m!==s?(b=pt(),b!==s?(I=pt(),I!==s?(N=pt(),N!==s?(m=[m,b,I,N],p=m):(l=p,p=d)):(l=p,p=d)):(l=p,p=d)):(l=p,p=d),p!==s?(V=c,h=Ju(p),c=h):(l=c,c=d)):(l=c,c=d)),D[Oe]={nextPos:l,result:c},c)}a(gm,"peg$parseESCAPED_UNICODE");var _l=[];function _m(c,h,p){var m=new Error(c);throw m.line=h,m.column=p,m}a(_m,"genError");function sa(c){_l.push(c)}a(sa,"addNode");function We(c,h,p,m,b){var I={type:c,value:h,line:p(),column:m()};return b&&(I.key=b),I}a(We,"node");function bm(c,h,p){var m=parseInt("0x"+c);if(!isFinite(m)||Math.floor(m)!=m||m<0||m>1114111||m>55295&&m<57344)_m("Invalid Unicode escape code: "+c,h,p);else return wm(m)}a(bm,"convertCodePoint");function wm(){var c=16384,h=[],p,m,b=-1,I=arguments.length;if(!I)return"";for(var N="";++b<I;){var q=Number(arguments[b]);q<=65535?h.push(q):(q-=65536,p=(q>>10)+55296,m=q%1024+56320,h.push(p,m)),(b+1==I||h.length>c)&&(N+=String.fromCharCode.apply(null,h),h.length=0)}return N}if(a(wm,"fromCodePoint"),Ks=u(),Ks!==s&&l===r.length)return Ks;throw Ks!==s&&l<r.length&&M({type:"end",description:"end of input"}),ta(null,Qi,Ws)}return a(t,"parse"),{SyntaxError:e,parse:t}}()});var Hp=ce((c1,$p)=>{"use strict";function AR(n){var e=[],t=[],r="",o=Object.create(null),s=o,i=!1;return u(n);function u(w){for(var L,z=0;z<w.length;z++)switch(L=w[z],L.type){case"Assign":y(L);break;case"ObjectPath":R(L);break;case"ArrayPath":S(L);break}return o}function f(w,L,z){var Y=new Error(w);throw Y.line=L,Y.column=z,Y}function y(w){var L=w.key,z=w.value,Y=w.line,ne=w.column,re;r?re=r+"."+L:re=L,typeof s[L]<"u"&&f("Cannot redefine existing key '"+re+"'.",Y,ne),s[L]=_(z),d(re)||(e.push(re),t.push(re))}function d(w){return e.indexOf(w)!==-1}function _(w){return w.type==="Array"?C(w.value):w.type==="InlineTable"?E(w.value):w.value}function E(w){for(var L=Object.create(null),z=0;z<w.length;z++){var Y=w[z];Y.value.type==="InlineTable"?L[Y.key]=E(Y.value.value):Y.type==="InlineTableValue"&&(L[Y.key]=_(Y.value))}return L}function R(w){var L=w.value,z=L.map(x).join("."),Y=w.line,ne=w.column;d(z)&&f("Cannot redefine existing key '"+L+"'.",Y,ne),e.push(z),s=A(o,L,Object.create(null),Y,ne),r=L}function S(w){var L=w.value,z=L.map(x).join("."),Y=w.line,ne=w.column;if(d(z)||e.push(z),e=e.filter(function(Se){return Se.indexOf(z)!==0}),e.push(z),s=A(o,L,[],Y,ne),r=z,s instanceof Array){var re=Object.create(null);s.push(re),s=re}else f("Cannot redefine existing key '"+L+"'.",Y,ne)}function A(w,L,z,Y,ne){for(var re=[],Se="",Ce=L.join("."),ve=w,Ze=0;Ze<L.length;Ze++){var St=L[Ze];re.push(St),Se=re.join("."),typeof ve[St]>"u"?Ze===L.length-1?ve[St]=z:ve[St]=Object.create(null):Ze!==L.length-1&&t.indexOf(Se)>-1&&f("Cannot redefine existing key '"+Se+"'.",Y,ne),ve=ve[St],ve instanceof Array&&ve.length&&Ze<L.length-1&&(ve=ve[ve.length-1])}return ve}function C(w){for(var L=null,z=0;z<w.length;z++){var Y=w[z];L===null?L=Y.type:Y.type!==L&&f("Cannot add value of type "+Y.type+" to array of type "+L+".",Y.line,Y.column)}return w.map(_)}function x(w){return w.indexOf(".")>-1?'"'+w+'"':w}}a(AR,"compile");$p.exports={compile:AR}});var Fp=ce((l1,zp)=>{"use strict";var kR=Mp(),IR=Hp();zp.exports={parse:a(function(n){var e=kR.parse(n.toString());return IR.compile(e)},"parse")}});import{errorString as vl,mergeProcessResults as xm,Plugin as Lm,PluginManager as Pm,USER_PROCESSOR as Bm}from"@sentio/runtime";var yt=fe(Im(),1);import{SolanaChainId as Om}from"@sentio/chain";var Xs=class extends Sl{static{a(this,"SolanaContext")}network;address;programName;blockNumber;constructor(e,t,r,o,s){super(s),this.network=t||Om.SOLANA_MAINNET,this.programName=e,this.address=r,this.blockNumber=o}getChainId(){return this.network}getMetaDataInternal(e,t){return{address:this.address,contractName:this.programName,blockNumber:this.blockNumber,transactionIndex:0,transactionHash:"",logIndex:0,chainId:this.getChainId(),name:e,labels:El(t)}}};import("node:process").then(n=>n.stdout.write(""));import{ListStateStorage as Nm}from"@sentio/runtime";import{SolanaChainId as Cm}from"@sentio/chain";var Vr=class n extends Nm{static{a(this,"SolanaProcessorState")}static INSTANCE=new n},Il=class{static{a(this,"SolanaBaseProcessor")}instructionHandlerMap=new Map;address;endpoint;contractName;baseLabels;network;processInnerInstruction;config={startSlot:0n};instructionCoder;decodeInstruction(e){return this.instructionCoder?this.instructionCoder.decode(e,"base58"):null}fromParsedInstruction;constructor(e){this.address=e.address,this.contractName=e.name||"",this.processInnerInstruction=e.processInnerInstruction||!1,this.network=e.network||Cm.SOLANA_MAINNET,e.instructionCoder&&(this.instructionCoder=e.instructionCoder),e.startBlock&&this.startSlot(e.startBlock),e.endBlock&&this.endBlock(e.endBlock),this.endpoint=e.network||"https://api.mainnet-beta.solana.com",this.baseLabels=e.baseLabels,Vr.INSTANCE.addValue(this)}onInstruction(e,t){return this.instructionHandlerMap.set(e,t),this}getParsedInstruction(e){if(e){if(e.info)return this.fromParsedInstruction?this.fromParsedInstruction(e):null;if(this.decodeInstruction!=null)return this.decodeInstruction(e)}return null}getInstructionHandler(e){return this.instructionHandlerMap.get(e.name)}async handleInstruction(e,t,r,o){let s=new Xs(this.contractName,this.network,this.address,o,this.baseLabels);return await r(e,s,t),s.stopAndGetResult()}startSlot(e){return this.config.startSlot=BigInt(e),this}endBlock(e){return this.config.endSlot=BigInt(e),this}};import("node:process").then(n=>n.stdout.write(""));var ua=class extends Lm{static{a(this,"SolanaPlugin")}name="SolanaPlugin";async configure(e){for(let t of Vr.INSTANCE.getValues()){let r=wl.fromPartial({processorType:Bm,contract:{name:t.contractName,chainId:t.network,address:t.address,abi:""},startBlock:t.config.startSlot,instructionConfig:{innerInstruction:t.processInnerInstruction,parsedInstruction:t.fromParsedInstruction!==null,rawDataInstruction:t.decodeInstruction!==null}});e.contractConfigs.push(r)}}supportedHandlers=[ia.SOL_INSTRUCTION];processBinding(e){switch(e.handlerType){case ia.SOL_INSTRUCTION:return this.processSolInstruction(e);default:throw new yt.ServerError(yt.Status.INVALID_ARGUMENT,"No handle type registered "+e.handlerType)}}async processSolInstruction(e){if(!e.data)throw new yt.ServerError(yt.Status.INVALID_ARGUMENT,"instruction data cannot be empty");if(!e.data.solInstruction)throw new yt.ServerError(yt.Status.INVALID_ARGUMENT,"instruction data cannot be empty");let t=e.data.solInstruction,r=[];for(let o of Vr.INSTANCE.getValues())if(o.address===t.programAccountId){let s=null;try{t.parsed?s=o.getParsedInstruction(t.parsed):t.instructionData&&(s=o.getParsedInstruction(t.instructionData))}catch(f){throw new yt.ServerError(yt.Status.INTERNAL,"Failed to decode instruction: "+JSON.stringify(t)+vl(f))}if(s==null)continue;let i=o.getInstructionHandler(s);if(i==null)continue;let u=o.handleInstruction(s,t.accounts,i,t.slot).catch(f=>{throw new yt.ServerError(yt.Status.INTERNAL,"Error processing instruction: "+JSON.stringify(t)+`
|
24
|
+
`+vl(f))});r.push(u)}return xm(await Promise.all(r))}};Pm.INSTANCE.register(new ua);import("node:process").then(n=>n.stdout.write(""));var Tl=class{static{a(this,"SolanaBindOptions")}address;network;name;startBlock;endBlock;processInnerInstruction;instructionCoder;baseLabels};import("node:process").then(n=>n.stdout.write(""));ps();$r();var OR=fe(Er());$e();$e();var ui={};Cn(ui,{decode:()=>_0,encode:()=>b0});$r();function _0(n){return(dr?new TextDecoder("utf-8"):new(ae("util")).TextDecoder("utf-8")).decode(n)}a(_0,"decode");function b0(n){return(dr?new TextEncoder:new(ae("util")).TextEncoder("utf-8")).encode(n)}a(b0,"encode");var ys={};Cn(ys,{decode:()=>R0,encode:()=>w0});var Gc=fe(Gr());function w0(n){return Gc.default.encode(n)}a(w0,"encode");function R0(n){return Gc.default.decode(n)}a(R0,"decode");import{Buffer as E0}from"buffer";function Yc(n){return n.toString("base64")}a(Yc,"encode");function li(n){return E0.from(n,"base64")}a(li,"decode");$r();$e();$r();$e();var ap=fe(sp());$e();var bn=fe(ws());function Qt(n){return"accounts"in n}a(Qt,"isCompositeAccounts");async function cp(n){let e=(await U.findProgramAddress([],n))[0];return await U.createWithSeed(e,X0(),n)}a(cp,"idlAddress");function X0(){return"anchor:idl"}a(X0,"seed");var J0=bn.struct([bn.publicKey("authority"),bn.vecU8("data")]);function up(n){return J0.decode(n)}a(up,"decodeIdlAccount");function lp(n){let e=["name","path","account","relations","generic"],t=a(s=>s.split(".").map(ap.default).join("."),"toCamelCase"),r=a(s=>{for(let i in s){let u=s[i];e.includes(i)?s[i]=Array.isArray(u)?u.map(t):t(u):typeof u=="object"&&r(u)}},"recursivelyConvertNamesToCamelCase"),o=structuredClone(n);return r(o),o}a(lp,"convertIdlToCamelCase");function yr(n,e,t,r){return n?.length?n[0].name?t(n):r(n):e()}a(yr,"handleDefinedFields");function fp(n){let e=new Map;return n.errors&&n.errors.forEach(t=>{var r;let o=(r=t.msg)!==null&&r!==void 0?r:t.name;e.set(t.code,o)}),e}a(fp,"parseIdlErrors");function dp(n,...e){if(n.args.length!=e.length)throw new Error("Invalid argument length");let t={},r=0;return n.args.forEach(o=>{t[o.name]=e[r],r+=1}),t}a(dp,"toInstruction");function ou(n,e={}){n.forEach(t=>{if(Qt(t))ou(t.accounts,e[t.name]);else if(!e[t.name])throw new Error(`Account \`${t.name}\` not provided.`)})}a(ou,"validateAccounts");function je(n){return n instanceof U?n:new U(n)}a(je,"translateAddress");var iu=class extends TypeError{static{a(this,"StructError")}constructor(e,t){let r,{message:o,...s}=e,{path:i}=e,u=i.length===0?o:"At path: "+i.join(".")+" -- "+o;super(u),this.value=void 0,this.key=void 0,this.type=void 0,this.refinement=void 0,this.path=void 0,this.branch=void 0,this.failures=void 0,Object.assign(this,s),this.name=this.constructor.name,this.failures=()=>{var f;return(f=r)!=null?f:r=[e,...t()]}}};function Z0(n){return wn(n)&&typeof n[Symbol.iterator]=="function"}a(Z0,"isIterable");function wn(n){return typeof n=="object"&&n!=null}a(wn,"isObject");function mr(n){return typeof n=="string"?JSON.stringify(n):""+n}a(mr,"print");function Q0(n){let{done:e,value:t}=n.next();return e?void 0:t}a(Q0,"shiftIterator");function eR(n,e,t,r){if(n===!0)return;n===!1?n={}:typeof n=="string"&&(n={message:n});let{path:o,branch:s}=e,{type:i}=t,{refinement:u,message:f="Expected a value of type `"+i+"`"+(u?" with refinement `"+u+"`":"")+", but received: `"+mr(r)+"`"}=n;return{value:r,type:i,refinement:u,key:o[o.length-1],path:o,branch:s,...n,message:f}}a(eR,"toFailure");function*hp(n,e,t,r){Z0(n)||(n=[n]);for(let o of n){let s=eR(o,e,t,r);s&&(yield s)}}a(hp,"toFailures");function*au(n,e,t){t===void 0&&(t={});let{path:r=[],branch:o=[n],coerce:s=!1,mask:i=!1}=t,u={path:r,branch:o};if(s&&(n=e.coercer(n,u),i&&e.type!=="type"&&wn(e.schema)&&wn(n)&&!Array.isArray(n)))for(let y in n)e.schema[y]===void 0&&delete n[y];let f=!0;for(let y of e.validator(n,u))f=!1,yield[y,void 0];for(let[y,d,_]of e.entries(n,u)){let E=au(d,_,{path:y===void 0?r:[...r,y],branch:y===void 0?o:[...o,d],coerce:s,mask:i});for(let R of E)R[0]?(f=!1,yield[R[0],void 0]):s&&(d=R[1],y===void 0?n=d:n instanceof Map?n.set(y,d):n instanceof Set?n.add(d):wn(n)&&(n[y]=d))}if(f)for(let y of e.refiner(n,u))f=!1,yield[y,void 0];f&&(yield[void 0,n])}a(au,"run");var zt=class{static{a(this,"Struct")}constructor(e){this.TYPE=void 0,this.type=void 0,this.schema=void 0,this.coercer=void 0,this.validator=void 0,this.refiner=void 0,this.entries=void 0;let{type:t,schema:r,validator:o,refiner:s,coercer:i=a(f=>f,"coercer"),entries:u=a(function*(){},"entries")}=e;this.type=t,this.schema=r,this.entries=u,this.coercer=i,o?this.validator=(f,y)=>{let d=o(f,y);return hp(d,y,this,f)}:this.validator=()=>[],s?this.refiner=(f,y)=>{let d=s(f,y);return hp(d,y,this,f)}:this.refiner=()=>[]}assert(e){return tR(e,this)}create(e){return Ii(e,this)}is(e){return pp(e,this)}mask(e){return rR(e,this)}validate(e,t){return t===void 0&&(t={}),Rs(e,this,t)}};function tR(n,e){let t=Rs(n,e);if(t[0])throw t[0]}a(tR,"assert");function Ii(n,e){let t=Rs(n,e,{coerce:!0});if(t[0])throw t[0];return t[1]}a(Ii,"create");function rR(n,e){let t=Rs(n,e,{coerce:!0,mask:!0});if(t[0])throw t[0];return t[1]}a(rR,"mask");function pp(n,e){return!Rs(n,e)[0]}a(pp,"is");function Rs(n,e,t){t===void 0&&(t={});let r=au(n,e,t),o=Q0(r);return o[0]?[new iu(o[0],function*(){for(let i of r)i[0]&&(yield i[0])}),void 0]:[void 0,o[1]]}a(Rs,"validate");function Es(n,e){return new zt({type:n,schema:null,validator:e})}a(Es,"define");function yp(){return Es("any",()=>!0)}a(yp,"any");function vi(n){return new zt({type:"array",schema:n,*entries(e){if(n&&Array.isArray(e))for(let[t,r]of e.entries())yield[t,r,n]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||"Expected an array value, but received: "+mr(e)}})}a(vi,"array");function mp(){return Es("boolean",n=>typeof n=="boolean")}a(mp,"boolean");function cu(n){let e=mr(n),t=typeof n;return new zt({type:"literal",schema:t==="string"||t==="number"||t==="boolean"?n:null,validator(r){return r===n||"Expected the literal `"+e+"`, but received: "+mr(r)}})}a(cu,"literal");function Ss(n){return new zt({...n,validator:a((e,t)=>e===null||n.validator(e,t),"validator"),refiner:a((e,t)=>e===null||n.refiner(e,t),"refiner")})}a(Ss,"nullable");function As(){return Es("number",n=>typeof n=="number"&&!isNaN(n)||"Expected a number, but received: "+mr(n))}a(As,"number");function ks(n){return new zt({...n,validator:a((e,t)=>e===void 0||n.validator(e,t),"validator"),refiner:a((e,t)=>e===void 0||n.refiner(e,t),"refiner")})}a(ks,"optional");function gr(){return Es("string",n=>typeof n=="string"||"Expected a string, but received: "+mr(n))}a(gr,"string");function er(n){let e=Object.keys(n);return new zt({type:"type",schema:n,*entries(t){if(wn(t))for(let r of e)yield[r,t[r],n[r]]},validator(t){return wn(t)||"Expected an object, but received: "+mr(t)}})}a(er,"type");function uu(n){let e=n.map(t=>t.type).join(" | ");return new zt({type:"union",schema:null,coercer(t,r){return(n.find(s=>{let[i]=s.validate(t,{coerce:!0});return!i})||Ti()).coercer(t,r)},validator(t,r){let o=[];for(let s of n){let[...i]=au(t,s,r),[u]=i;if(u[0])for(let[f]of i)f&&o.push(f);else return[]}return["Expected the value to satisfy a union of `"+e+"`, but received: "+mr(t),...o]}})}a(uu,"union");function Ti(){return Es("unknown",()=>!0)}a(Ti,"unknown");function gp(n,e,t){return new zt({...n,coercer:a((r,o)=>pp(r,e)?n.coercer(t(r,o),o):n.coercer(r,o),"coercer")})}a(gp,"coerce");var _p=99;async function wp(n,e,t){if(e.length<=_p)return await bp(n,e,t);{let r=Xh(e,_p);return(await Promise.all(r.map(s=>bp(n,s,t)))).flat()}}a(wp,"getMultipleAccountsAndContext");async function bp(n,e,t){let r=t??n.commitment,{value:o,context:s}=await n.getMultipleAccountsInfoAndContext(e,r);return o.map((u,f)=>u===null?null:{publicKey:e[f],account:u,context:s})}a(bp,"getMultipleAccountsAndContextCore");async function Rp(n,e,t,r,o){var s;t&&t.length>0&&e.sign(...t);let i=e._compile(),u=i.serialize(),y=e._serialize(u).toString("base64"),d={encoding:"base64",commitment:r??n.commitment};if(o){let S=(Array.isArray(o)?o:i.nonProgramIds()).map(A=>A.toBase58());d.accounts={encoding:"base64",addresses:S}}t&&t.length>0&&(d.sigVerify=!0);let _=[y,d],E=await n._rpcRequest("simulateTransaction",_),R=Ii(E,iR);if("error"in R){let S;if("data"in R.error&&(S=(s=R.error.data)===null||s===void 0?void 0:s.logs,S&&Array.isArray(S))){let A=`
|
25
|
+
`,C=A+S.join(A);console.error(R.error.message,C)}throw new _t("failed to simulate transaction: "+R.error.message,S)}return R.result}a(Rp,"simulateTransaction");function nR(n){return gp(Ep(n),sR,e=>"error"in e?e:{...e,result:Ii(e.result,n)})}a(nR,"jsonRpcResult");var sR=Ep(Ti());function Ep(n){return uu([er({jsonrpc:cu("2.0"),id:gr(),result:n}),er({jsonrpc:cu("2.0"),id:gr(),error:er({code:Ti(),message:gr(),data:ks(yp())})})])}a(Ep,"createRpcResult");function oR(n){return nR(er({context:er({slot:As()}),value:n}))}a(oR,"jsonRpcResultAndContext");var iR=oR(er({err:Ss(uu([er({}),gr()])),logs:Ss(vi(gr())),accounts:ks(Ss(vi(Ss(er({executable:mp(),owner:gr(),lamports:As(),data:vi(gr()),rentEpoch:ks(As())}))))),unitsConsumed:ks(As())}));var Oi=class n{static{a(this,"AnchorProvider")}constructor(e,t,r=n.defaultOptions()){this.connection=e,this.wallet=t,this.opts=r,this.publicKey=t?.publicKey}static defaultOptions(){return{preflightCommitment:"processed",commitment:"processed"}}static local(e,t=n.defaultOptions()){if(dr)throw new Error("Provider local is not available on browser.");let r=new fn(e??"http://127.0.0.1:8899",t.preflightCommitment),s=(ps(),xn(Vc)).default.local();return new n(r,s,t)}static env(){if(dr)throw new Error("Provider env is not available on browser.");let t=ae("process").env.ANCHOR_PROVIDER_URL;if(t===void 0)throw new Error("ANCHOR_PROVIDER_URL is not defined");let r=n.defaultOptions(),o=new fn(t,r.commitment),i=(ps(),xn(Vc)).default.local();return new n(o,i,r)}async sendAndConfirm(e,t,r){var o,s,i,u;if(r===void 0&&(r=this.opts),vt(e))t&&e.sign(t);else if(e.feePayer=(o=e.feePayer)!==null&&o!==void 0?o:this.wallet.publicKey,e.recentBlockhash=(await this.connection.getLatestBlockhash(r.preflightCommitment)).blockhash,t)for(let y of t)e.partialSign(y);e=await this.wallet.signTransaction(e);let f=e.serialize();try{return await Ap(this.connection,f,r)}catch(y){if(y instanceof Is){let d=ys.encode(vt(e)?((s=e.signatures)===null||s===void 0?void 0:s[0])||new Uint8Array:(i=e.signature)!==null&&i!==void 0?i:new Uint8Array),_=vt(e)?0:void 0,E=await this.connection.getTransaction(d,{commitment:"confirmed",maxSupportedTransactionVersion:_});if(E){let R=(u=E.meta)===null||u===void 0?void 0:u.logMessages;throw R?new _t(y.message,R):y}else throw y}else throw y}}async sendAll(e,t){var r,o,s;t===void 0&&(t=this.opts);let i=(await this.connection.getLatestBlockhash(t.preflightCommitment)).blockhash,u=e.map(d=>{var _,E;if(vt(d.tx)){let R=d.tx;return d.signers&&R.sign(d.signers),R}else{let R=d.tx,S=(_=d.signers)!==null&&_!==void 0?_:[];return R.feePayer=(E=R.feePayer)!==null&&E!==void 0?E:this.wallet.publicKey,R.recentBlockhash=i,S.forEach(A=>{R.partialSign(A)}),R}}),f=await this.wallet.signAllTransactions(u),y=[];for(let d=0;d<u.length;d+=1){let _=f[d],E=_.serialize();try{y.push(await Ap(this.connection,E,t))}catch(R){if(R instanceof Is){let S=ys.encode(vt(_)?((r=_.signatures)===null||r===void 0?void 0:r[0])||new Uint8Array:(o=_.signature)!==null&&o!==void 0?o:new Uint8Array),A=vt(_)?0:void 0,C=await this.connection.getTransaction(S,{commitment:"confirmed",maxSupportedTransactionVersion:A});if(C){let x=(s=C.meta)===null||s===void 0?void 0:s.logMessages;throw x?new _t(R.message,x):R}else throw R}else throw R}}return y}async simulate(e,t,r,o){let s=(await this.connection.getLatestBlockhash(r??this.connection.commitment)).blockhash,i;if(vt(e)?(t&&t.length>0&&(e.sign(t),e=await this.wallet.signTransaction(e)),i=await this.connection.simulateTransaction(e,{commitment:r})):(e.feePayer=e.feePayer||this.wallet.publicKey,e.recentBlockhash=s,t&&t.length>0&&(e=await this.wallet.signTransaction(e)),i=await Rp(this.connection,e,t,r,o)),i.value.err)throw new lu(i.value);return i.value}},lu=class extends Error{static{a(this,"SimulateError")}constructor(e,t){super(t),this.simulationResponse=e}};async function Ap(n,e,t){let r=t&&{skipPreflight:t.skipPreflight,preflightCommitment:t.preflightCommitment||t.commitment},o=await n.sendRawTransaction(e,r),s=(await n.confirmTransaction(o,t&&t.commitment)).value;if(s.err)throw new Is(`Raw transaction ${o} failed (${JSON.stringify(s)})`);return o}a(Ap,"sendAndConfirmRawTransaction");var Is=class extends Error{static{a(this,"ConfirmError")}constructor(e){super(e)}};function Fr(){return kp===null?Oi.local():kp}a(Fr,"getProvider");var kp=null;$e();var T=fe(Ip());var aR=new Map;function Ni(n){return aR.get(n)!==void 0}a(Ni,"isSet");var wt=class extends Error{static{a(this,"IdlError")}constructor(e){super(e),this.name="IdlError"}},vs=class n{static{a(this,"ProgramErrorStack")}constructor(e){this.stack=e}static parse(e){var t;let r=/^Program (\w*) invoke/,o=/^Program \w* success/,s=[];for(let i=0;i<e.length;i++){if(o.exec(e[i])){s.pop();continue}let u=(t=r.exec(e[i]))===null||t===void 0?void 0:t[1];u&&s.push(new U(u))}return new n(s)}},du=class n extends Error{static{a(this,"AnchorError")}constructor(e,t,r,o,s,i){super(r.join(`
|
26
|
+
`).replace("Program log: ","")),this.errorLogs=r,this.logs=o,this.error={errorCode:e,errorMessage:t,comparedValues:i,origin:s},this._programErrorStack=vs.parse(o)}static parse(e){if(!e)return null;let t=e.findIndex(E=>E.startsWith("Program log: AnchorError"));if(t===-1)return null;let r=e[t],o=[r],s;if(t+1<e.length){if(e[t+1]==="Program log: Left:"){let E=/^Program log: (.*)$/,R=E.exec(e[t+2])[1],S=E.exec(e[t+4])[1];s=[new U(R),new U(S)],o.push(...e.slice(t+1,t+5))}else if(e[t+1].startsWith("Program log: Left:")){let E=/^Program log: (Left|Right): (.*)$/,R=E.exec(e[t+1])[2],S=E.exec(e[t+2])[2];o.push(...e.slice(t+1,t+3)),s=[R,S]}}let u=/^Program log: AnchorError occurred\. Error Code: (.*)\. Error Number: (\d*)\. Error Message: (.*)\./.exec(r),y=/^Program log: AnchorError thrown in (.*):(\d*)\. Error Code: (.*)\. Error Number: (\d*)\. Error Message: (.*)\./.exec(r),_=/^Program log: AnchorError caused by account: (.*)\. Error Code: (.*)\. Error Number: (\d*)\. Error Message: (.*)\./.exec(r);if(u){let[E,R,S]=u.slice(1,4),A={code:E,number:parseInt(R)};return new n(A,S,o,e,void 0,s)}else if(y){let[E,R,S,A,C]=y.slice(1,6),x={code:S,number:parseInt(A)},w={file:E,line:parseInt(R)};return new n(x,C,o,e,w,s)}else if(_){let[E,R,S,A]=_.slice(1,5),C=E,x={code:R,number:parseInt(S)};return new n(x,A,o,e,C,s)}else return null}get program(){return this._programErrorStack.stack[this._programErrorStack.stack.length-1]}get programErrorStack(){return this._programErrorStack.stack}toString(){return this.message}},hu=class n extends Error{static{a(this,"ProgramError")}constructor(e,t,r){super(),this.code=e,this.msg=t,this.logs=r,r&&(this._programErrorStack=vs.parse(r))}static parse(e,t){let r=e.toString(),o;if(r.includes("custom program error:")){let u=r.split("custom program error: ");if(u.length!==2)return null;o=u[1]}else{let u=r.match(/"Custom":([0-9]+)}/g);if(!u||u.length>1)return null;o=u[0].match(/([0-9]+)/g)[0]}let s;try{s=parseInt(o)}catch{return null}let i=t.get(s);return i!==void 0?new n(s,i,e.logs):(i=cR.get(s),i!==void 0?new n(s,i,e.logs):null)}get program(){var e;return(e=this._programErrorStack)===null||e===void 0?void 0:e.stack[this._programErrorStack.stack.length-1]}get programErrorStack(){var e;return(e=this._programErrorStack)===null||e===void 0?void 0:e.stack}toString(){return this.msg}};function Ci(n,e){Ni("debug-logs")&&console.log("Translating error:",n);let t=du.parse(n.logs);if(t)return t;let r=hu.parse(n,e);if(r)return r;if(n.logs){let o={get:a(function(s,i){return i==="programErrorStack"?s.programErrorStack.stack:i==="program"?s.programErrorStack.stack[n.programErrorStack.stack.length-1]:Reflect.get(...arguments)},"get")};return n.programErrorStack=vs.parse(n.logs),new Proxy(n,o)}return n}a(Ci,"translateError");var F={InstructionMissing:T.ANCHOR_ERROR__INSTRUCTION_MISSING,InstructionFallbackNotFound:T.ANCHOR_ERROR__INSTRUCTION_FALLBACK_NOT_FOUND,InstructionDidNotDeserialize:T.ANCHOR_ERROR__INSTRUCTION_DID_NOT_DESERIALIZE,InstructionDidNotSerialize:T.ANCHOR_ERROR__INSTRUCTION_DID_NOT_SERIALIZE,IdlInstructionStub:T.ANCHOR_ERROR__IDL_INSTRUCTION_STUB,IdlInstructionInvalidProgram:T.ANCHOR_ERROR__IDL_INSTRUCTION_INVALID_PROGRAM,IdlAccountNotEmpty:T.ANCHOR_ERROR__IDL_ACCOUNT_NOT_EMPTY,EventInstructionStub:T.ANCHOR_ERROR__EVENT_INSTRUCTION_STUB,ConstraintMut:T.ANCHOR_ERROR__CONSTRAINT_MUT,ConstraintHasOne:T.ANCHOR_ERROR__CONSTRAINT_HAS_ONE,ConstraintSigner:T.ANCHOR_ERROR__CONSTRAINT_SIGNER,ConstraintRaw:T.ANCHOR_ERROR__CONSTRAINT_RAW,ConstraintOwner:T.ANCHOR_ERROR__CONSTRAINT_OWNER,ConstraintRentExempt:T.ANCHOR_ERROR__CONSTRAINT_RENT_EXEMPT,ConstraintSeeds:T.ANCHOR_ERROR__CONSTRAINT_SEEDS,ConstraintExecutable:T.ANCHOR_ERROR__CONSTRAINT_EXECUTABLE,ConstraintState:T.ANCHOR_ERROR__CONSTRAINT_STATE,ConstraintAssociated:T.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED,ConstraintAssociatedInit:T.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_INIT,ConstraintClose:T.ANCHOR_ERROR__CONSTRAINT_CLOSE,ConstraintAddress:T.ANCHOR_ERROR__CONSTRAINT_ADDRESS,ConstraintZero:T.ANCHOR_ERROR__CONSTRAINT_ZERO,ConstraintTokenMint:T.ANCHOR_ERROR__CONSTRAINT_TOKEN_MINT,ConstraintTokenOwner:T.ANCHOR_ERROR__CONSTRAINT_TOKEN_OWNER,ConstraintMintMintAuthority:T.ANCHOR_ERROR__CONSTRAINT_MINT_MINT_AUTHORITY,ConstraintMintFreezeAuthority:T.ANCHOR_ERROR__CONSTRAINT_MINT_FREEZE_AUTHORITY,ConstraintMintDecimals:T.ANCHOR_ERROR__CONSTRAINT_MINT_DECIMALS,ConstraintSpace:T.ANCHOR_ERROR__CONSTRAINT_SPACE,ConstraintAccountIsNone:T.ANCHOR_ERROR__CONSTRAINT_ACCOUNT_IS_NONE,ConstraintTokenTokenProgram:T.ANCHOR_ERROR__CONSTRAINT_TOKEN_TOKEN_PROGRAM,ConstraintMintTokenProgram:T.ANCHOR_ERROR__CONSTRAINT_MINT_TOKEN_PROGRAM,ConstraintAssociatedTokenTokenProgram:T.ANCHOR_ERROR__CONSTRAINT_ASSOCIATED_TOKEN_TOKEN_PROGRAM,ConstraintMintGroupPointerExtension:T.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION,ConstraintMintGroupPointerExtensionAuthority:T.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_AUTHORITY,ConstraintMintGroupPointerExtensionGroupAddress:T.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_POINTER_EXTENSION_GROUP_ADDRESS,ConstraintMintGroupMemberPointerExtension:T.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION,ConstraintMintGroupMemberPointerExtensionAuthority:T.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_AUTHORITY,ConstraintMintGroupMemberPointerExtensionMemberAddress:T.ANCHOR_ERROR__CONSTRAINT_MINT_GROUP_MEMBER_POINTER_EXTENSION_MEMBER_ADDRESS,ConstraintMintMetadataPointerExtension:T.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION,ConstraintMintMetadataPointerExtensionAuthority:T.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_AUTHORITY,ConstraintMintMetadataPointerExtensionMetadataAddress:T.ANCHOR_ERROR__CONSTRAINT_MINT_METADATA_POINTER_EXTENSION_METADATA_ADDRESS,ConstraintMintCloseAuthorityExtension:T.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION,ConstraintMintCloseAuthorityExtensionAuthority:T.ANCHOR_ERROR__CONSTRAINT_MINT_CLOSE_AUTHORITY_EXTENSION_AUTHORITY,ConstraintMintPermanentDelegateExtension:T.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION,ConstraintMintPermanentDelegateExtensionDelegate:T.ANCHOR_ERROR__CONSTRAINT_MINT_PERMANENT_DELEGATE_EXTENSION_DELEGATE,ConstraintMintTransferHookExtension:T.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION,ConstraintMintTransferHookExtensionAuthority:T.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_AUTHORITY,ConstraintMintTransferHookExtensionProgramId:T.ANCHOR_ERROR__CONSTRAINT_MINT_TRANSFER_HOOK_EXTENSION_PROGRAM_ID,RequireViolated:T.ANCHOR_ERROR__REQUIRE_VIOLATED,RequireEqViolated:T.ANCHOR_ERROR__REQUIRE_EQ_VIOLATED,RequireKeysEqViolated:T.ANCHOR_ERROR__REQUIRE_KEYS_EQ_VIOLATED,RequireNeqViolated:T.ANCHOR_ERROR__REQUIRE_NEQ_VIOLATED,RequireKeysNeqViolated:T.ANCHOR_ERROR__REQUIRE_KEYS_NEQ_VIOLATED,RequireGtViolated:T.ANCHOR_ERROR__REQUIRE_GT_VIOLATED,RequireGteViolated:T.ANCHOR_ERROR__REQUIRE_GTE_VIOLATED,AccountDiscriminatorAlreadySet:T.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_ALREADY_SET,AccountDiscriminatorNotFound:T.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_NOT_FOUND,AccountDiscriminatorMismatch:T.ANCHOR_ERROR__ACCOUNT_DISCRIMINATOR_MISMATCH,AccountDidNotDeserialize:T.ANCHOR_ERROR__ACCOUNT_DID_NOT_DESERIALIZE,AccountDidNotSerialize:T.ANCHOR_ERROR__ACCOUNT_DID_NOT_SERIALIZE,AccountNotEnoughKeys:T.ANCHOR_ERROR__ACCOUNT_NOT_ENOUGH_KEYS,AccountNotMutable:T.ANCHOR_ERROR__ACCOUNT_NOT_MUTABLE,AccountOwnedByWrongProgram:T.ANCHOR_ERROR__ACCOUNT_OWNED_BY_WRONG_PROGRAM,InvalidProgramId:T.ANCHOR_ERROR__INVALID_PROGRAM_ID,InvalidProgramExecutable:T.ANCHOR_ERROR__INVALID_PROGRAM_EXECUTABLE,AccountNotSigner:T.ANCHOR_ERROR__ACCOUNT_NOT_SIGNER,AccountNotSystemOwned:T.ANCHOR_ERROR__ACCOUNT_NOT_SYSTEM_OWNED,AccountNotInitialized:T.ANCHOR_ERROR__ACCOUNT_NOT_INITIALIZED,AccountNotProgramData:T.ANCHOR_ERROR__ACCOUNT_NOT_PROGRAM_DATA,AccountNotAssociatedTokenAccount:T.ANCHOR_ERROR__ACCOUNT_NOT_ASSOCIATED_TOKEN_ACCOUNT,AccountSysvarMismatch:T.ANCHOR_ERROR__ACCOUNT_SYSVAR_MISMATCH,AccountReallocExceedsLimit:T.ANCHOR_ERROR__ACCOUNT_REALLOC_EXCEEDS_LIMIT,AccountDuplicateReallocs:T.ANCHOR_ERROR__ACCOUNT_DUPLICATE_REALLOCS,DeclaredProgramIdMismatch:T.ANCHOR_ERROR__DECLARED_PROGRAM_ID_MISMATCH,TryingToInitPayerAsProgramAccount:T.ANCHOR_ERROR__TRYING_TO_INIT_PAYER_AS_PROGRAM_ACCOUNT,InvalidNumericConversion:T.ANCHOR_ERROR__INVALID_NUMERIC_CONVERSION,Deprecated:T.ANCHOR_ERROR__DEPRECATED},cR=new Map([[F.InstructionMissing,"8 byte instruction identifier not provided"],[F.InstructionFallbackNotFound,"Fallback functions are not supported"],[F.InstructionDidNotDeserialize,"The program could not deserialize the given instruction"],[F.InstructionDidNotSerialize,"The program could not serialize the given instruction"],[F.IdlInstructionStub,"The program was compiled without idl instructions"],[F.IdlInstructionInvalidProgram,"The transaction was given an invalid program for the IDL instruction"],[F.IdlAccountNotEmpty,"IDL account must be empty in order to resize, try closing first"],[F.EventInstructionStub,"The program was compiled without `event-cpi` feature"],[F.ConstraintMut,"A mut constraint was violated"],[F.ConstraintHasOne,"A has one constraint was violated"],[F.ConstraintSigner,"A signer constraint was violated"],[F.ConstraintRaw,"A raw constraint was violated"],[F.ConstraintOwner,"An owner constraint was violated"],[F.ConstraintRentExempt,"A rent exemption constraint was violated"],[F.ConstraintSeeds,"A seeds constraint was violated"],[F.ConstraintExecutable,"An executable constraint was violated"],[F.ConstraintState,"Deprecated Error, feel free to replace with something else"],[F.ConstraintAssociated,"An associated constraint was violated"],[F.ConstraintAssociatedInit,"An associated init constraint was violated"],[F.ConstraintClose,"A close constraint was violated"],[F.ConstraintAddress,"An address constraint was violated"],[F.ConstraintZero,"Expected zero account discriminant"],[F.ConstraintTokenMint,"A token mint constraint was violated"],[F.ConstraintTokenOwner,"A token owner constraint was violated"],[F.ConstraintMintMintAuthority,"A mint mint authority constraint was violated"],[F.ConstraintMintFreezeAuthority,"A mint freeze authority constraint was violated"],[F.ConstraintMintDecimals,"A mint decimals constraint was violated"],[F.ConstraintSpace,"A space constraint was violated"],[F.ConstraintAccountIsNone,"A required account for the constraint is None"],[F.ConstraintTokenTokenProgram,"A token account token program constraint was violated"],[F.ConstraintMintTokenProgram,"A mint token program constraint was violated"],[F.ConstraintAssociatedTokenTokenProgram,"An associated token account token program constraint was violated"],[F.ConstraintMintGroupPointerExtension,"A group pointer extension constraint was violated"],[F.ConstraintMintGroupPointerExtensionAuthority,"A group pointer extension authority constraint was violated"],[F.ConstraintMintGroupPointerExtensionGroupAddress,"A group pointer extension group address constraint was violated"],[F.ConstraintMintGroupMemberPointerExtension,"A group member pointer extension constraint was violated"],[F.ConstraintMintGroupMemberPointerExtensionAuthority,"A group member pointer extension authority constraint was violated"],[F.ConstraintMintGroupMemberPointerExtensionMemberAddress,"A group member pointer extension group address constraint was violated"],[F.ConstraintMintMetadataPointerExtension,"A metadata pointer extension constraint was violated"],[F.ConstraintMintMetadataPointerExtensionAuthority,"A metadata pointer extension authority constraint was violated"],[F.ConstraintMintMetadataPointerExtensionMetadataAddress,"A metadata pointer extension metadata address constraint was violated"],[F.ConstraintMintCloseAuthorityExtension,"A close authority constraint was violated"],[F.ConstraintMintCloseAuthorityExtensionAuthority,"A close authority extension authority constraint was violated"],[F.ConstraintMintPermanentDelegateExtension,"A permanent delegate extension constraint was violated"],[F.ConstraintMintPermanentDelegateExtensionDelegate,"A permanent delegate extension delegate constraint was violated"],[F.ConstraintMintTransferHookExtension,"A transfer hook extension constraint was violated"],[F.ConstraintMintTransferHookExtensionAuthority,"A transfer hook extension authority constraint was violated"],[F.ConstraintMintTransferHookExtensionProgramId,"A transfer hook extension transfer hook program id constraint was violated"],[F.RequireViolated,"A require expression was violated"],[F.RequireEqViolated,"A require_eq expression was violated"],[F.RequireKeysEqViolated,"A require_keys_eq expression was violated"],[F.RequireNeqViolated,"A require_neq expression was violated"],[F.RequireKeysNeqViolated,"A require_keys_neq expression was violated"],[F.RequireGtViolated,"A require_gt expression was violated"],[F.RequireGteViolated,"A require_gte expression was violated"],[F.AccountDiscriminatorAlreadySet,"The account discriminator was already set on this account"],[F.AccountDiscriminatorNotFound,"No 8 byte discriminator was found on the account"],[F.AccountDiscriminatorMismatch,"8 byte discriminator did not match what was expected"],[F.AccountDidNotDeserialize,"Failed to deserialize the account"],[F.AccountDidNotSerialize,"Failed to serialize the account"],[F.AccountNotEnoughKeys,"Not enough account keys given to the instruction"],[F.AccountNotMutable,"The given account is not mutable"],[F.AccountOwnedByWrongProgram,"The given account is owned by a different program than expected"],[F.InvalidProgramId,"Program ID was not as expected"],[F.InvalidProgramExecutable,"Program account is not executable"],[F.AccountNotSigner,"The given account did not sign"],[F.AccountNotSystemOwned,"The given account is not owned by the system program"],[F.AccountNotInitialized,"The program expected this account to be already initialized"],[F.AccountNotProgramData,"The given account is not a program data account"],[F.AccountNotAssociatedTokenAccount,"The given account is not the associated token account"],[F.AccountSysvarMismatch,"The given public key does not match the required sysvar"],[F.AccountReallocExceedsLimit,"The account reallocation exceeds the MAX_PERMITTED_DATA_INCREASE limit"],[F.AccountDuplicateReallocs,"The account was duplicated for more than one reallocation"],[F.DeclaredProgramIdMismatch,"The declared program id does not match the actual program id"],[F.TryingToInitPayerAsProgramAccount,"You cannot/should not initialize the payer account as a program account"],[F.InvalidNumericConversion,"The program could not perform the numeric conversion, out of range integral type conversion attempted"],[F.Deprecated,"The API being used is deprecated and should no longer be used"]]);var Li=fe(Gr()),vp=fe(ws());import{Buffer as xi}from"buffer";var ee=fe(ws());var st=class n{static{a(this,"IdlCoder")}static fieldLayout(e,t=[],r){let o=e.name;switch(e.type){case"bool":return ee.bool(o);case"u8":return ee.u8(o);case"i8":return ee.i8(o);case"u16":return ee.u16(o);case"i16":return ee.i16(o);case"u32":return ee.u32(o);case"i32":return ee.i32(o);case"f32":return ee.f32(o);case"u64":return ee.u64(o);case"i64":return ee.i64(o);case"f64":return ee.f64(o);case"u128":return ee.u128(o);case"i128":return ee.i128(o);case"u256":return ee.u256(o);case"i256":return ee.i256(o);case"bytes":return ee.vecU8(o);case"string":return ee.str(o);case"pubkey":return ee.publicKey(o);default:{if("option"in e.type)return ee.option(n.fieldLayout({type:e.type.option},t,r),o);if("vec"in e.type)return ee.vec(n.fieldLayout({type:e.type.vec},t,r),o);if("array"in e.type){let[s,i]=e.type.array;return i=n.resolveArrayLen(i,r),ee.array(n.fieldLayout({type:s},t,r),i,o)}if("defined"in e.type){if(!t)throw new wt("User defined types not provided");let s=e.type.defined.name,i=t.find(u=>u.name===s);if(!i)throw new wt(`Type not found: ${e.name}`);return n.typeDefLayout({typeDef:i,types:t,genericArgs:r??e.type.defined.generics,name:o})}if("generic"in e.type){let s=r?.at(0);if(s?.kind!=="type")throw new wt(`Invalid generic field: ${e.name}`);return n.fieldLayout({...e,type:s.type},t)}throw new wt(`Not yet implemented: ${JSON.stringify(e.type)}`)}}}static typeDefLayout({typeDef:e,types:t,name:r,genericArgs:o}){switch(e.type.kind){case"struct":{let s=yr(e.type.fields,()=>[],i=>i.map(u=>{let f=o&&n.resolveGenericArgs({type:u.type,typeDef:e,genericArgs:o});return n.fieldLayout(u,t,f)}),i=>i.map((u,f)=>{let y=o&&n.resolveGenericArgs({type:u,typeDef:e,genericArgs:o});return n.fieldLayout({name:f.toString(),type:u},t,y)}));return ee.struct(s,r)}case"enum":{let s=e.type.variants.map(i=>{let u=yr(i.fields,()=>[],f=>f.map(y=>{let d=o&&n.resolveGenericArgs({type:y.type,typeDef:e,genericArgs:o});return n.fieldLayout(y,t,d)}),f=>f.map((y,d)=>{let _=o&&n.resolveGenericArgs({type:y,typeDef:e,genericArgs:o});return n.fieldLayout({name:d.toString(),type:y},t,_)}));return ee.struct(u,i.name)});return r!==void 0?ee.rustEnum(s).replicate(r):ee.rustEnum(s,r)}case"type":return n.fieldLayout({type:e.type.alias,name:r},t)}}static typeSize(e,t,r){var o;switch(e){case"bool":return 1;case"u8":return 1;case"i8":return 1;case"i16":return 2;case"u16":return 2;case"u32":return 4;case"i32":return 4;case"f32":return 4;case"u64":return 8;case"i64":return 8;case"f64":return 8;case"u128":return 16;case"i128":return 16;case"u256":return 32;case"i256":return 32;case"bytes":return 1;case"string":return 1;case"pubkey":return 32;default:if("option"in e)return 1+n.typeSize(e.option,t,r);if("coption"in e)return 4+n.typeSize(e.coption,t,r);if("vec"in e)return 1;if("array"in e){let[s,i]=e.array;return i=n.resolveArrayLen(i,r),n.typeSize(s,t,r)*i}if("defined"in e){let s=(o=t.types)===null||o===void 0?void 0:o.find(u=>u.name===e.defined.name);if(!s)throw new wt(`Type not found: ${JSON.stringify(e)}`);let i=a(u=>{let f=r??e.defined.generics,y=f&&n.resolveGenericArgs({type:u,typeDef:s,genericArgs:f});return n.typeSize(u,t,y)},"typeSize");switch(s.type.kind){case"struct":return yr(s.type.fields,()=>[0],u=>u.map(f=>i(f.type)),u=>u.map(f=>i(f))).reduce((u,f)=>u+f,0);case"enum":{let u=s.type.variants.map(f=>yr(f.fields,()=>[0],y=>y.map(d=>i(d.type)),y=>y.map(d=>i(d))).reduce((y,d)=>y+d,0));return Math.max(...u)+1}case"type":return n.typeSize(s.type.alias,t,r)}}if("generic"in e){let s=r?.at(0);if(s?.kind!=="type")throw new wt(`Invalid generic: ${e.generic}`);return n.typeSize(s.type,t,r)}throw new Error(`Invalid type ${JSON.stringify(e)}`)}}static resolveArrayLen(e,t){if(typeof e=="number")return e;if(t){let r=t.find(o=>o.kind==="const");r?.kind==="const"&&(e=+r.value)}if(typeof e!="number")throw new wt("Generic array length did not resolve");return e}static resolveGenericArgs({type:e,typeDef:t,genericArgs:r,isDefined:o}){if(typeof e!="object")return null;for(let s in t.generics){let i=t.generics[s];if("generic"in e&&i.name===e.generic)return[r[s]];if("option"in e){let u=n.resolveGenericArgs({type:e.option,typeDef:t,genericArgs:r,isDefined:o});if(!u||!o)return u;if(u[0].kind==="type")return[{kind:"type",type:{option:u[0].type}}]}if("vec"in e){let u=n.resolveGenericArgs({type:e.vec,typeDef:t,genericArgs:r,isDefined:o});if(!u||!o)return u;if(u[0].kind==="type")return[{kind:"type",type:{vec:u[0].type}}]}if("array"in e){let[u,f]=e.array,y=typeof f=="object",d=n.resolveGenericArgs({type:u,typeDef:t,genericArgs:r,isDefined:o});if(d){for(let _ in t.generics.slice(+s)){let E=+s+ +_;y&&t.generics[E].name===f.generic&&d.push(r[E])}if(!o)return d;if(d[0].kind==="type"&&d[1].kind==="const")return[{kind:"type",type:{array:[d[0].type,+d[1].value]}}]}if(y&&i.name===f.generic){let _=r[s];return o?[{kind:"type",type:{array:[u,+_.value]}}]:[_]}return null}if("defined"in e)return e.defined.generics?e.defined.generics.flatMap(u=>{switch(u.kind){case"type":return n.resolveGenericArgs({type:u.type,typeDef:t,genericArgs:r,isDefined:!0});case"const":return[u]}}).filter(u=>u!==null):null}return null}};var Rn=class{static{a(this,"BorshInstructionCoder")}constructor(e){this.idl=e;let t=e.instructions.map(o=>{let s=o.name,i=o.args.map(f=>st.fieldLayout(f,e.types)),u=vp.struct(i,s);return[s,{discriminator:o.discriminator,layout:u}]});this.ixLayouts=new Map(t);let r=t.map(([o,{discriminator:s,layout:i}])=>[Li.default.encode(s),{name:o,layout:i}]);this.sighashLayouts=new Map(r)}encode(e,t){let r=xi.alloc(1e3),o=this.ixLayouts.get(e);if(!o)throw new Error(`Unknown method: ${e}`);let s=o.layout.encode(t,r),i=r.slice(0,s);return xi.concat([xi.from(o.discriminator),i])}decode(e,t="hex"){typeof e=="string"&&(e=t==="hex"?xi.from(e,"hex"):Li.default.decode(e));let r=e.slice(0,8),o=e.slice(8),s=this.sighashLayouts.get(Li.default.encode(r));return s?{name:s.name,data:s.layout.decode(o)}:null}format(e,t){return pu.format(e,t,this.idl)}},pu=class n{static{a(this,"InstructionFormatter")}static format(e,t,r){let o=r.instructions.find(f=>e.name===f.name);if(!o)return console.error("Invalid instruction given"),null;let s=o.args.map(f=>({name:f.name,type:n.formatIdlType(f.type),data:n.formatIdlData(f,e.data[f.name],r.types)})),i=n.flattenIdlAccounts(o.accounts),u=t.map((f,y)=>y<i.length?{name:i[y].name,...f}:{name:void 0,...f});return{args:s,accounts:u}}static formatIdlType(e){if(typeof e=="string")return e;if("option"in e)return`Option<${this.formatIdlType(e.option)}>`;if("coption"in e)return`COption<${this.formatIdlType(e.coption)}>`;if("vec"in e)return`Vec<${this.formatIdlType(e.vec)}>`;if("array"in e)return`Array<${e.array[0]}; ${e.array[1]}>`;if("defined"in e){let t=e.defined.name;if(e.defined.generics){let r=e.defined.generics.map(o=>{switch(o.kind){case"type":return n.formatIdlType(o.type);case"const":return o.value}}).join(", ");return`${t}<${r}>`}return t}throw new Error(`Unknown IDL type: ${e}`)}static formatIdlData(e,t,r){if(typeof e.type=="string")return t.toString();if("vec"in e.type)return"["+t.map(o=>this.formatIdlData({name:"",type:e.type.vec},o,r)).join(", ")+"]";if("option"in e.type)return t===null?"null":this.formatIdlData({name:"",type:e.type.option},t,r);if("defined"in e.type){if(!r)throw new Error("User defined types not provided");let o=e.type.defined.name,s=r.find(i=>i.name===o);if(!s)throw new Error(`Type not found: ${o}`);return n.formatIdlDataDefined(s,t,r)}return"unknown"}static formatIdlDataDefined(e,t,r){switch(e.type.kind){case"struct":return"{ "+yr(e.type.fields,()=>"",o=>Object.entries(t).map(([s,i])=>{let u=o.find(f=>f.name===s);if(!u)throw new Error(`Field not found: ${s}`);return s+": "+n.formatIdlData(u,i,r)}).join(", "),o=>Object.entries(t).map(([s,i])=>s+": "+n.formatIdlData({name:"",type:o[s]},i,r)).join(", "))+" }";case"enum":{let o=Object.keys(t)[0],s=e.type.variants.find(u=>u.name===o);if(!s)throw new Error(`Unable to find variant: ${o}`);let i=t[o];return yr(s.fields,()=>o,u=>{let f=Object.keys(i).map(y=>{let d=i[y],_=u.find(E=>E.name===y);if(!_)throw new Error(`Field not found: ${y}`);return y+": "+n.formatIdlData(_,d,r)}).join(", ");return`${o} { ${f} }`},u=>{let f=Object.entries(i).map(([y,d])=>y+": "+n.formatIdlData({name:"",type:u[y]},d,r)).join(", ");return`${o} { ${f} }`})}case"type":return n.formatIdlType(e.type.alias)}}static flattenIdlAccounts(e,t){return e.map(r=>{let o=uR(r.name);if(r.hasOwnProperty("accounts")){let s=t?`${t} > ${o}`:o;return n.flattenIdlAccounts(r.accounts,s)}else return{...r,name:t?`${t} > ${o}`:o}}).flat()}};function uR(n){let e=n.replace(/([A-Z])/g," $1");return e.charAt(0).toUpperCase()+e.slice(1)}a(uR,"sentenceCase");var Tp=fe(Gr());import{Buffer as Pi}from"buffer";var Ts=class{static{a(this,"BorshAccountsCoder")}constructor(e){if(this.idl=e,!e.accounts){this.accountLayouts=new Map;return}let t=e.types;if(!t)throw new Error("Accounts require `idl.types`");let r=e.accounts.map(o=>{let s=t.find(i=>i.name===o.name);if(!s)throw new Error(`Account not found: ${o.name}`);return[o.name,st.typeDefLayout({typeDef:s,types:t})]});this.accountLayouts=new Map(r)}async encode(e,t){let r=Pi.alloc(1e3),o=this.accountLayouts.get(e);if(!o)throw new Error(`Unknown account: ${e}`);let s=o.encode(t,r),i=r.slice(0,s),u=this.accountDiscriminator(e);return Pi.concat([u,i])}decode(e,t){if(this.accountDiscriminator(e).compare(t.slice(0,8)))throw new Error("Invalid account discriminator");return this.decodeUnchecked(e,t)}decodeAny(e){let t=e.slice(0,8),r=Array.from(this.accountLayouts.keys()).find(o=>this.accountDiscriminator(o).equals(t));if(!r)throw new Error("Account not found");return this.decodeUnchecked(r,e)}decodeUnchecked(e,t){let r=t.subarray(8),o=this.accountLayouts.get(e);if(!o)throw new Error(`Unknown account: ${e}`);return o.decode(r)}memcmp(e,t){let r=this.accountDiscriminator(e);return{offset:0,bytes:Tp.default.encode(t?Pi.concat([r,t]):r)}}size(e){return 8+st.typeSize({defined:{name:e}},this.idl)}accountDiscriminator(e){var t;let r=(t=this.idl.accounts)===null||t===void 0?void 0:t.find(o=>o.name===e);if(!r)throw new Error(`Account not found: ${e}`);return Pi.from(r.discriminator)}};import{Buffer as lR}from"buffer";var Os=class{static{a(this,"BorshEventCoder")}constructor(e){var t;if(!e.events){this.layouts=new Map;return}let r=e.types;if(!r)throw new Error("Events require `idl.types`");let o=e.events.map(s=>{let i=r.find(u=>u.name===s.name);if(!i)throw new Error(`Event not found: ${s.name}`);return[s.name,st.typeDefLayout({typeDef:i,types:r})]});this.layouts=new Map(o),this.discriminators=new Map(((t=e.events)!==null&&t!==void 0?t:[]).map(s=>[Yc(lR.from(s.discriminator)),s.name]))}decode(e){let t;try{t=li(e)}catch{return null}let r=Yc(t.slice(0,8)),o=this.discriminators.get(r);if(!o)return null;let s=this.layouts.get(o);if(!s)throw new Error(`Unknown event: ${o}`);return{data:s.decode(t.slice(8)),name:o}}};import{Buffer as fR}from"buffer";var Bi=class{static{a(this,"BorshTypesCoder")}constructor(e){let t=e.types;if(!t){this.typeLayouts=new Map;return}let r=t.filter(o=>!o.generics).map(o=>[o.name,st.typeDefLayout({typeDef:o,types:t})]);this.typeLayouts=new Map(r)}encode(e,t){let r=fR.alloc(1e3),o=this.typeLayouts.get(e);if(!o)throw new Error(`Unknown type: ${e}`);let s=o.encode(t,r);return r.slice(0,s)}decode(e,t){let r=this.typeLayouts.get(e);if(!r)throw new Error(`Unknown type: ${e}`);return r.decode(t)}};var En=class{static{a(this,"BorshCoder")}constructor(e){this.instruction=new Rn(e),this.accounts=new Ts(e),this.events=new Os(e),this.types=new Bi(e)}};var Op=fe(Er()),ie=fe(zr());var yu=class extends ie.Layout{static{a(this,"RustStringLayout")}constructor(e){super(-1,e),this.property=e,this.layout=ie.struct([ie.u32("length"),ie.u32("lengthPadding"),ie.blob(ie.offset(ie.u32(),-8),"chars")],this.property)}encode(e,t,r=0){if(e==null)return this.layout.span;let o={chars:Buffer.from(e,"utf8")};return this.layout.encode(o,t,r)}decode(e,t=0){return this.layout.decode(e,t).chars.toString()}getSpan(e,t=0){return ie.u32().span+ie.u32().span+new Op.default(new Uint8Array(e).slice(t,t+4),10,"le").toNumber()}};function Ui(n){return new yu(n)}a(Ui,"rustStringLayout");function Rt(n){return ie.blob(32,n)}a(Rt,"publicKey");var ft=ie.union(ie.u32("instruction"));ft.addVariant(0,ie.struct([ie.ns64("lamports"),ie.ns64("space"),Rt("owner")]),"createAccount");ft.addVariant(1,ie.struct([Rt("owner")]),"assign");ft.addVariant(2,ie.struct([ie.ns64("lamports")]),"transfer");ft.addVariant(3,ie.struct([Rt("base"),Ui("seed"),ie.ns64("lamports"),ie.ns64("space"),Rt("owner")]),"createAccountWithSeed");ft.addVariant(4,ie.struct([Rt("authorized")]),"advanceNonceAccount");ft.addVariant(5,ie.struct([ie.ns64("lamports")]),"withdrawNonceAccount");ft.addVariant(6,ie.struct([Rt("authorized")]),"initializeNonceAccount");ft.addVariant(7,ie.struct([Rt("authorized")]),"authorizeNonceAccount");ft.addVariant(8,ie.struct([ie.ns64("space")]),"allocate");ft.addVariant(9,ie.struct([Rt("base"),Ui("seed"),ie.ns64("space"),Rt("owner")]),"allocateWithSeed");ft.addVariant(10,ie.struct([Rt("base"),Ui("seed"),Rt("owner")]),"assignWithSeed");ft.addVariant(11,ie.struct([ie.ns64("lamports"),Ui("seed"),Rt("owner")]),"transferWithSeed");var Vk=Math.max(...Object.values(ft.registry).map(n=>n.span));var Et=fe(zr());$e();var mu=class extends Et.Layout{static{a(this,"WrappedLayout")}constructor(e,t,r,o){super(e.span,o),this.layout=e,this.decoder=t,this.encoder=r}decode(e,t){return this.decoder(this.layout.decode(e,t))}encode(e,t,r){return this.layout.encode(this.encoder(e),t,r)}getSpan(e,t){return this.layout.getSpan(e,t)}};function Np(n){return new mu(Et.blob(32),e=>new U(e),e=>e.toBuffer(),n)}a(Np,"publicKey");var Zk=Et.struct([Et.u32("version"),Et.u32("state"),Np("authorizedPubkey"),Np("nonce"),Et.struct([Et.nu64("lamportsPerSignature")],"feeCalculator")]);$e();$e();var EI=new U("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"),SI=new U("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");var yR=fe(Am()),He=fe(ws());var kI=He.rustEnum([He.struct([],"uninitialized"),He.struct([He.option(He.publicKey(),"authorityAddress")],"buffer"),He.struct([He.publicKey("programdataAddress")],"program"),He.struct([He.u64("slot"),He.option(He.publicKey(),"upgradeAuthorityAddress")],"programData")],void 0,He.u32());$e();function br(n,e){var t,r;let o={},s=n.args?n.args.length:0;if(e.length>s){if(e.length!==s+1)throw new Error(`provided too many arguments ${e} to instruction ${n?.name} expecting: ${(r=(t=n.args)===null||t===void 0?void 0:t.map(i=>i.name))!==null&&r!==void 0?r:[]}`);o=e.pop()}return[e,o]}a(br,"splitArgsAndCtx");var Ns=class n{static{a(this,"InstructionNamespaceFactory")}static build(e,t,r){if(e.name==="_inner")throw new wt("the _inner name is reserved");let o=a((...s)=>{let[i,u]=br(e,[...s]);ou(e.accounts,u.accounts),_R(e,...s);let f=o.accounts(u.accounts);return u.remainingAccounts!==void 0&&f.push(...u.remainingAccounts),Ni("debug-logs")&&console.log("Outgoing account metas:",f),new me({keys:f,programId:r,data:t(e.name,dp(e,...i))})},"ix");return o.accounts=s=>n.accountsArray(s,e.accounts,r,e.name),o}static accountsArray(e,t,r,o){return e?t.map(s=>{if(Qt(s)){let d=e[s.name];return n.accountsArray(d,s.accounts,r,o).flat()}let i;try{i=je(e[s.name])}catch{throw new Error(`Wrong input type for account "${s.name}" in the instruction accounts object${o!==void 0?' for instruction "'+o+'"':""}. Expected PublicKey or string.`)}let u=s.optional&&i.equals(r),f=!!(s.writable&&!u),y=!!(s.signer&&!u);return{pubkey:i,isWritable:f,isSigner:y}}).flat():[]}};function _R(n,...e){}a(_R,"validateInstruction");$e();var Cs=class{static{a(this,"TransactionFactory")}static build(e,t){return a((...o)=>{var s,i,u;let[,f]=br(e,[...o]),y=new de;if(f.preInstructions&&f.instructions)throw new Error("instructions is deprecated, use preInstructions");return(s=f.preInstructions)===null||s===void 0||s.forEach(d=>y.add(d)),(i=f.instructions)===null||i===void 0||i.forEach(d=>y.add(d)),y.add(t(...o)),(u=f.postInstructions)===null||u===void 0||u.forEach(d=>y.add(d)),y},"txFn")}};var xs=class{static{a(this,"RpcFactory")}static build(e,t,r,o){return a(async(...i)=>{var u;let f=t(...i),[,y]=br(e,[...i]);if(o.sendAndConfirm===void 0)throw new Error("This function requires 'Provider.sendAndConfirm' to be implemented.");try{return await o.sendAndConfirm(f,(u=y.signers)!==null&&u!==void 0?u:[],y.options)}catch(d){throw Ci(d,r)}},"rpc")}};var Lp=fe(xp());$e();var Bs=class{static{a(this,"AccountFactory")}static build(e,t,r,o){var s;return((s=e.accounts)!==null&&s!==void 0?s:[]).reduce((i,u)=>(i[u.name]=new Mi(e,u,r,o,t),i),{})}},Mi=class{static{a(this,"AccountClient")}get size(){return this._size}get programId(){return this._programId}get provider(){return this._provider}get coder(){return this._coder}constructor(e,t,r,o,s){this._idlAccount=t,this._programId=r,this._provider=o??Fr(),this._coder=s??new En(e),this._size=this._coder.accounts.size(t.name)}async fetchNullable(e,t){let{data:r}=await this.fetchNullableAndContext(e,t);return r}async fetchNullableAndContext(e,t){let r=await this.getAccountInfoAndContext(e,t),{value:o,context:s}=r;return{data:o&&o.data.length!==0?this._coder.accounts.decode(this._idlAccount.name,o.data):null,context:s}}async fetch(e,t){let{data:r}=await this.fetchNullableAndContext(e,t);if(r===null)throw new Error(`Account does not exist or has no data ${e.toString()}`);return r}async fetchAndContext(e,t){let{data:r,context:o}=await this.fetchNullableAndContext(e,t);if(r===null)throw new Error(`Account does not exist ${e.toString()}`);return{data:r,context:o}}async fetchMultiple(e,t){return(await this.fetchMultipleAndContext(e,t)).map(o=>o?o.data:null)}async fetchMultipleAndContext(e,t){return(await wp(this._provider.connection,e.map(o=>je(o)),t)).map(o=>{if(o==null)return null;let{account:s,context:i}=o;return{data:this._coder.accounts.decode(this._idlAccount.name,s.data),context:i}})}async all(e){let t=this.coder.accounts.memcmp(this._idlAccount.name,e instanceof Buffer?e:void 0),r=[];return t?.offset!=null&&t?.bytes!=null&&r.push({memcmp:{offset:t.offset,bytes:t.bytes}}),t?.dataSize!=null&&r.push({dataSize:t.dataSize}),(await this._provider.connection.getProgramAccounts(this._programId,{commitment:this._provider.connection.commitment,filters:[...r,...Array.isArray(e)?e:[]]})).map(({pubkey:s,account:i})=>({publicKey:s,account:this._coder.accounts.decode(this._idlAccount.name,i.data)}))}subscribe(e,t){let r=Ps.get(e.toString());if(r)return r.ee;let o=new Lp.default;e=je(e);let s=this._provider.connection.onAccountChange(e,i=>{let u=this._coder.accounts.decode(this._idlAccount.name,i.data);o.emit("change",u)},t);return Ps.set(e.toString(),{ee:o,listener:s}),o}async unsubscribe(e){let t=Ps.get(e.toString());if(!t){console.warn("Address is not subscribed");return}Ps&&await this._provider.connection.removeAccountChangeListener(t.listener).then(()=>{Ps.delete(e.toString())}).catch(console.error)}async createInstruction(e,t){let r=this.size;if(this._provider.publicKey===void 0)throw new Error("This function requires the Provider interface implementor to have a 'publicKey' field.");return Ue.createAccount({fromPubkey:this._provider.publicKey,newAccountPubkey:e.publicKey,space:t??r,lamports:await this._provider.connection.getMinimumBalanceForRentExemption(t??r),programId:this._programId})}async getAccountInfo(e,t){return await this._provider.connection.getAccountInfo(je(e),t)}async getAccountInfoAndContext(e,t){return await this._provider.connection.getAccountInfoAndContext(je(e),t)}},Ps=new Map;var _u="Program log: ",Pp="Program data: ",RR=_u.length,ER=Pp.length,$i=class{static{a(this,"EventManager")}constructor(e,t,r){this._programId=e,this._provider=t,this._eventParser=new Us(e,r),this._eventCallbacks=new Map,this._eventListeners=new Map,this._listenerIdCount=0}addEventListener(e,t){var r;let o=this._listenerIdCount;return this._listenerIdCount+=1,this._eventListeners.has(e)||this._eventListeners.set(e,[]),this._eventListeners.set(e,((r=this._eventListeners.get(e))!==null&&r!==void 0?r:[]).concat(o)),this._eventCallbacks.set(o,[e,t]),this._onLogsSubscriptionId!==void 0||(this._onLogsSubscriptionId=this._provider.connection.onLogs(this._programId,(s,i)=>{if(!s.err)for(let u of this._eventParser.parseLogs(s.logs)){let f=this._eventListeners.get(u.name);f&&f.forEach(y=>{let d=this._eventCallbacks.get(y);if(d){let[,_]=d;_(u.data,i.slot,s.signature)}})}})),o}async removeEventListener(e){let t=this._eventCallbacks.get(e);if(!t)throw new Error(`Event listener ${e} doesn't exist!`);let[r]=t,o=this._eventListeners.get(r);if(!o)throw new Error(`Event listeners don't exist for ${r}!`);if(this._eventCallbacks.delete(e),o=o.filter(s=>s!==e),this._eventListeners.set(r,o),o.length===0&&this._eventListeners.delete(r),this._eventCallbacks.size===0){if(this._eventListeners.size!==0)throw new Error(`Expected event listeners size to be 0 but got ${this._eventListeners.size}`);this._onLogsSubscriptionId!==void 0&&(await this._provider.connection.removeOnLogsListener(this._onLogsSubscriptionId),this._onLogsSubscriptionId=void 0)}}},Us=class{static{a(this,"EventParser")}constructor(e,t){this.coder=t,this.programId=e}*parseLogs(e,t=!1){let r=new wu(e),o=new bu,s=r.next();for(;s!==null;){let[i,u,f]=this.handleLog(o,s,t);i&&(yield i),u&&o.push(u),f&&o.pop(),s=r.next()}}handleLog(e,t,r){return e.stack.length>0&&e.program()===this.programId.toString()?this.handleProgramLog(t,r):[null,...this.handleSystemLog(t)]}handleProgramLog(e,t){if(e.startsWith(_u)||e.startsWith(Pp)){let r=e.startsWith(_u)?e.slice(RR):e.slice(ER),o=this.coder.events.decode(r);if(t&&o===null)throw new Error(`Unable to decode event ${r}`);return[o,null,!1]}else return[null,...this.handleSystemLog(e)]}handleSystemLog(e){let t=e.split(":")[0];return t.match(/^Program (.*) success/g)!==null?[null,!0]:t.startsWith(`Program ${this.programId.toString()} invoke`)?[this.programId.toString(),!1]:t.includes("invoke")?["cpi",!1]:[null,!1]}},bu=class{static{a(this,"ExecutionContext")}constructor(){this.stack=[]}program(){if(!this.stack.length)throw new Error("Expected the stack to have elements");return this.stack[this.stack.length-1]}push(e){this.stack.push(e)}pop(){if(!this.stack.length)throw new Error("Expected the stack to have elements");this.stack.pop()}},wu=class{static{a(this,"LogScanner")}constructor(e){this.logs=e}next(){if(this.logs.length===0)return null;let e=this.logs[0];return this.logs=this.logs.slice(1),e}};var Ds=class{static{a(this,"SimulateFactory")}static build(e,t,r,o,s,i,u){return a(async(...y)=>{var d;let _=t(...y),[,E]=br(e,[...y]),R;if(o.simulate===void 0)throw new Error("This function requires 'Provider.simulate' to be implemented.");try{R=await o.simulate(_,E.signers,(d=E.options)===null||d===void 0?void 0:d.commitment)}catch(C){throw Ci(C,r)}if(R===void 0)throw new Error("Unable to simulate transaction");let S=R.logs;if(!S)throw new Error("Simulated logs not found");let A=[];if(u.events){let C=new Us(i,s);for(let x of C.parseLogs(S))A.push(x)}return{events:A,raw:S}},"simulate")}};var Sn=fe(Er());$e();var Bp=fe(Er()),ot=fe(zr()),ku=fe(zr());$e();function Ru(n){return new zi(ot.blob(8),e=>Au.fromBuffer(e),e=>e.toBuffer(),n)}a(Ru,"uint64");function Hi(n){return new zi(ot.blob(32),e=>new U(e),e=>e.toBuffer(),n)}a(Hi,"publicKey");function Eu(n,e){return new Su(n,e)}a(Eu,"coption");var zi=class extends ku.Layout{static{a(this,"WrappedLayout")}constructor(e,t,r,o){super(e.span,o),this.layout=e,this.decoder=t,this.encoder=r}decode(e,t){return this.decoder(this.layout.decode(e,t))}encode(e,t,r){return this.layout.encode(this.encoder(e),t,r)}getSpan(e,t){return this.layout.getSpan(e,t)}},Su=class extends ku.Layout{static{a(this,"COptionLayout")}constructor(e,t){super(-1,t),this.layout=e,this.discriminator=ot.u32()}encode(e,t,r=0){return e==null?this.layout.span+this.discriminator.encode(0,t,r):(this.discriminator.encode(1,t,r),this.layout.encode(e,t,r+4)+4)}decode(e,t=0){let r=this.discriminator.decode(e,t);if(r===0)return null;if(r===1)return this.layout.decode(e,t+4);throw new Error("Invalid coption "+this.layout.property)}getSpan(e,t=0){return this.layout.getSpan(e,t+4)+4}},Au=class n extends Bp.default{static{a(this,"u64")}toBuffer(){let e=super.toArray().reverse(),t=Buffer.from(e);if(t.length===8)return t;if(t.length>=8)throw new Error("u64 too large");let r=Buffer.alloc(8);return t.copy(r),r}static fromBuffer(e){if(e.length!==8)throw new Error(`Invalid buffer length: ${e.length}`);return new n([...e].reverse().map(t=>`00${t.toString(16)}`.slice(-2)).join(""),16)}},SR=ot.struct([Hi("mint"),Hi("owner"),Ru("amount"),Eu(Hi(),"delegate"),(n=>{let e=ot.union(ot.u8("discriminator"),null,n);return e.addVariant(0,ot.struct([]),"uninitialized"),e.addVariant(1,ot.struct([]),"initialized"),e.addVariant(2,ot.struct([]),"frozen"),e})("state"),Eu(Ru(),"isNative"),Ru("delegatedAmount"),Eu(Hi(),"closeAuthority")]);function Up(n){return SR.decode(n)}a(Up,"decodeTokenAccount");var Fi=class{static{a(this,"AccountsResolver")}constructor(e,t,r,o,s,i,u,f){this._args=e,this._accounts=t,this._provider=r,this._programId=o,this._idlIx=s,this._idlTypes=u,this._customResolver=f,this._accountStore=new Iu(r,i,o)}args(e){this._args=e}async resolve(){this.resolveEventCpi(this._idlIx.accounts),this.resolveConst(this._idlIx.accounts);let e=0;for(;await this.resolvePdasAndRelations(this._idlIx.accounts)+await this.resolveCustom()>0;)if(e++,e===16)throw new Error("Reached maximum depth for account resolution")}resolveOptionals(e){Object.assign(this._accounts,this.resolveOptionalsHelper(e,this._idlIx.accounts))}get(e){let t=e.reduce((r,o)=>r&&r[o],this._accounts);if(t&&t.toBase58)return t}set(e,t){let r=this._accounts;e.forEach((o,s)=>{var i;s===e.length-1&&(r[o]=t),r[o]=(i=r[o])!==null&&i!==void 0?i:{},r=r[o]})}resolveOptionalsHelper(e,t){let r={};for(let o of t){let s=o.name,i=e[s];i!==void 0&&(vu(i)?Qt(o)?r[s]=this.resolveOptionalsHelper(i,o.accounts):r[s]=Tu(i,!0):i!==null?r[s]=je(i):o.optional&&(r[s]=this._programId))}return r}async resolveCustom(){if(this._customResolver){let{accounts:e,resolved:t}=await this._customResolver({args:this._args,accounts:this._accounts,provider:this._provider,programId:this._programId,idlIx:this._idlIx});return this._accounts=e,t}return 0}resolveEventCpi(e,t=[]){for(let r in e){let o=e[r];Qt(o)&&this.resolveEventCpi(o.accounts,[...t,o.name]);let s=+r+1;if(s===e.length)return;let i=e[r].name,u=e[s].name;if(i==="eventAuthority"&&u==="program"){let f=[...t,i],y=[...t,u];this.get(f)||this.set(f,U.findProgramAddressSync([Buffer.from("__event_authority")],this._programId)[0]),this.get(y)||this.set(y,this._programId);return}}}resolveConst(e,t=[]){for(let r of e){let o=r.name;if(Qt(r))this.resolveConst(r.accounts,[...t,o]);else{let s=r;if((s.signer||s.address)&&!this.get([...t,o])){if(s.signer){if(!this._provider.wallet)throw new Error("This function requires the `Provider` interface implementor to have a `wallet` field.");this.set([...t,o],this._provider.wallet.publicKey)}s.address&&this.set([...t,o],je(s.address))}}}}async resolvePdasAndRelations(e,t=[]){let r=0;for(let o of e){let s=o.name;if(Qt(o))r+=await this.resolvePdasAndRelations(o.accounts,[...t,s]);else{let i=o;if((i.pda||i.relations)&&!this.get([...t,s])){r++;try{if(i.pda){let u=await Promise.all(i.pda.seeds.map(d=>this.toBuffer(d,t)));if(u.some(d=>!d))continue;let f=await this.parseProgramId(i,t),[y]=U.findProgramAddressSync(u,f);this.set([...t,s],y)}}catch{}try{if(i.relations){let u=this.get([...t,i.relations[0]]);if(u){let f=await this._accountStore.fetchAccount({publicKey:u});this.set([...t,s],f[s])}}}catch{}}}}return r}async parseProgramId(e,t=[]){var r;if(!(!((r=e.pda)===null||r===void 0)&&r.program))return this._programId;let o=await this.toBuffer(e.pda.program,t);if(!o)throw new Error(`Program seed not resolved: ${e.name}`);return new U(o)}async toBuffer(e,t=[]){switch(e.kind){case"const":return this.toBufferConst(e);case"arg":return await this.toBufferArg(e);case"account":return await this.toBufferAccount(e,t);default:throw new Error(`Unexpected seed: ${e}`)}}toBufferConst(e){return this.toBufferValue("bytes",e.value)}async toBufferArg(e){let[t,...r]=e.path.split("."),o=this._idlIx.args.findIndex(u=>u.name===t);if(o===-1)throw new Error(`Unable to find argument for seed: ${t}`);let s=r.reduce((u,f)=>(u??{})[f],this._args[o]);if(s===void 0)return;let i=this.getType(this._idlIx.args[o].type,r);return this.toBufferValue(i,s)}async toBufferAccount(e,t=[]){let[r,...o]=e.path.split("."),s=this.get([...t,r]);if(!s)return;if(!o.length)return this.toBufferValue("pubkey",s);if(!e.account)throw new Error(`Seed account is required in order to resolve type: ${e.path}`);let u=await this._accountStore.fetchAccount({publicKey:s,name:e.account}),f=o;for(;f.length>0;)u=u[f[0]],f=f.slice(1);if(u===void 0)return;let y=this.getType({defined:{name:e.account}},o);return this.toBufferValue(y,u)}toBufferValue(e,t){switch(e){case"u8":case"i8":return Buffer.from([t]);case"u16":case"i16":return new Sn.default(t).toArrayLike(Buffer,"le",2);case"u32":case"i32":return new Sn.default(t).toArrayLike(Buffer,"le",4);case"u64":case"i64":return new Sn.default(t).toArrayLike(Buffer,"le",8);case"u128":case"i128":return new Sn.default(t).toArrayLike(Buffer,"le",16);case"u256":case"i256":return new Sn.default(t).toArrayLike(Buffer,"le",32);case"string":return Buffer.from(t);case"pubkey":return t.toBuffer();case"bytes":return Buffer.from(t);default:if(e?.array)return Buffer.from(t);throw new Error(`Unexpected seed type: ${e}`)}}getType(e,t=[]){var r;let o=(r=e?.defined)===null||r===void 0?void 0:r.name;if(o){if(o==="tokenAccount")switch(t.at(0)){case"mint":case"owner":return"pubkey";case"amount":case"delagatedAmount":return"u64";default:throw new Error(`Unknown token account path: ${t}`)}let s=this._idlTypes.find(d=>d.name===o);if(!s)throw new Error(`Type not found: ${o}`);let[i,...u]=t,y=s.type.fields.find(d=>d.name===i);if(!y)throw new Error(`Field not found: ${i}`);return this.getType(y.type,u)}return e}},Iu=class{static{a(this,"AccountStore")}constructor(e,t,r){this._provider=e,this._cache=new Map,this._idls={},this._idls[r.toBase58()]=t}async fetchAccount({publicKey:e,name:t}){let r=e.toBase58();if(!this._cache.has(r)){let o=await this._provider.connection.getAccountInfo(e);if(o===null)throw new Error(`Account not found: ${r}`);if(t==="tokenAccount"){let s=Up(o.data);this._cache.set(r,s)}else{let s=await this.getAccountsNs(o.owner);if(s){let i=Object.values(s)[0];if(i){let u=i.coder.accounts.decodeAny(o.data);this._cache.set(r,u)}}}}return this._cache.get(r)}async getAccountsNs(e){let t=e.toBase58();if(!this._idls[t]){let r=await wr.fetchIdl(e,this._provider);if(r){let o=new wr(r,this._provider);this._idls[t]=o.account}}return this._idls[t]}};var Ms=class{static{a(this,"MethodsBuilderFactory")}static build(e,t,r,o,s,i,u,f,y,d,_){return(...E)=>new Ou(E,o,s,i,u,f,e,t,r,y,d,_)}};function vu(n){return typeof n=="object"&&n!==null&&!("_bn"in n)}a(vu,"isPartialAccounts");function Tu(n,e){let t={};for(let r in n){let o=n[r];if(o===null){if(e)throw new Error("Failed to resolve optionals due to IDL type mismatch with input accounts!");continue}t[r]=vu(o)?Tu(o,!0):je(o)}return t}a(Tu,"flattenPartialAccounts");var Ou=class{static{a(this,"MethodsBuilder")}constructor(e,t,r,o,s,i,u,f,y,d,_,E){this._args=e,this._ixFn=t,this._txFn=r,this._rpcFn=o,this._simulateFn=s,this._viewFn=i,this._accounts={},this._remainingAccounts=[],this._signers=[],this._preInstructions=[],this._postInstructions=[],this._resolveAccounts=!0,this._accountsResolver=new Fi(e,this._accounts,u,f,y,d,_,E)}args(e){this._args=e,this._accountsResolver.args(e)}accounts(e){return this.accountsPartial(e)}accountsPartial(e){return this._resolveAccounts=!0,this._accountsResolver.resolveOptionals(e),this}accountsStrict(e){return this._resolveAccounts=!1,this._accountsResolver.resolveOptionals(e),this}signers(e){return this._signers=this._signers.concat(e),this}remainingAccounts(e){return this._remainingAccounts=this._remainingAccounts.concat(e),this}preInstructions(e,t=!1){return t?this._preInstructions=e.concat(this._preInstructions):this._preInstructions=this._preInstructions.concat(e),this}postInstructions(e){return this._postInstructions=this._postInstructions.concat(e),this}async pubkeys(){return this._resolveAccounts&&await this._accountsResolver.resolve(),this._accounts}async rpc(e){return this._resolveAccounts&&await this._accountsResolver.resolve(),this._rpcFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions,options:e})}async rpcAndKeys(e){return{pubkeys:await this.pubkeys(),signature:await this.rpc(e)}}async view(e){if(this._resolveAccounts&&await this._accountsResolver.resolve(),!this._viewFn)throw new Error("Method does not support views");return this._viewFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions,options:e})}async simulate(e){return this._resolveAccounts&&await this._accountsResolver.resolve(),this._simulateFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions,options:e})}async instruction(){return this._resolveAccounts&&await this._accountsResolver.resolve(),this._ixFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions})}async prepare(){return{instruction:await this.instruction(),pubkeys:await this.pubkeys(),signers:this._signers}}async transaction(){return this._resolveAccounts&&await this._accountsResolver.resolve(),this._txFn(...this._args,{accounts:this._accounts,signers:this._signers,remainingAccounts:this._remainingAccounts,preInstructions:this._preInstructions,postInstructions:this._postInstructions})}};var $s=class{static{a(this,"ViewFactory")}static build(e,t,r,o){let s=t.accounts.find(f=>f.writable),i=!!t.returns;return s||!i?void 0:a(async(...f)=>{let y=await r(...f),d=`Program return: ${e} `,_=y.raw.find(A=>A.startsWith(d));if(!_)throw new Error("View expected return log");let E=li(_.slice(d.length)),R=t.returns;if(!R)throw new Error("View expected return type");return st.fieldLayout({type:R},o.types).decode(E)},"view")}};var Hs=class{static{a(this,"NamespaceFactory")}static build(e,t,r,o,s){let i={},u={},f={},y={},d={},_={},E=fp(e),R=e.accounts?Bs.build(e,t,r,o):{};return e.instructions.forEach(S=>{let A=Ns.build(S,(ne,re)=>t.instruction.encode(ne,re),r),C=Cs.build(S,A),x=xs.build(S,C,E,o),w=Ds.build(S,C,E,o,t,r,e),L=$s.build(r,S,w,e),z=Ms.build(o,r,S,A,C,x,w,L,R,e.types||[],s?.(S)),Y=S.name;u[Y]=A,f[Y]=C,i[Y]=x,y[Y]=w,d[Y]=z,L&&(_[Y]=L)}),[i,u,f,R,y,d,_]}};var wr=class n{static{a(this,"Program")}get programId(){return this._programId}get idl(){return this._idl}get rawIdl(){return this._rawIdl}get coder(){return this._coder}get provider(){return this._provider}constructor(e,t=Fr(),r,o){let s=lp(e);this._idl=s,this._rawIdl=e,this._provider=t,this._programId=je(e.address),this._coder=r??new En(s),this._events=new $i(this._programId,t,this._coder);let[i,u,f,y,d,_,E]=Hs.build(s,this._coder,this._programId,t,o);this.rpc=i,this.instruction=u,this.transaction=f,this.account=y,this.simulate=d,this.methods=_,this.views=E}static async at(e,t){let r=je(e),o=await n.fetchIdl(r,t);if(!o)throw new Error(`IDL not found for program: ${e.toString()}`);return new n(o,t)}static async fetchIdl(e,t){t=t??Fr();let r=je(e),o=await cp(r),s=await t.connection.getAccountInfo(o);if(!s)return null;let i=up(s.data.slice(8)),u=kl(i.data);return JSON.parse(ui.decode(u))}addEventListener(e,t){return this._events.addEventListener(e,t)}async removeEventListener(e){return await this._events.removeEventListener(e)}};$e();var Qv=new U("11111111111111111111111111111111");var Gp=fe(Fp());function Wp(n){return n.toLowerCase()}a(Wp,"lowerCase");var vR=[/([a-z0-9])([A-Z])/g,/([A-Z])([A-Z][a-z])/g],TR=/[^A-Z0-9]+/gi;function qp(n,e){e===void 0&&(e={});for(var t=e.splitRegexp,r=t===void 0?vR:t,o=e.stripRegexp,s=o===void 0?TR:o,i=e.transform,u=i===void 0?Wp:i,f=e.delimiter,y=f===void 0?" ":f,d=Kp(Kp(n,r,"$1\0$2"),s,"\0"),_=0,E=d.length;d.charAt(_)==="\0";)_++;for(;d.charAt(E-1)==="\0";)E--;return d.slice(_,E).split("\0").map(u).join(y)}a(qp,"noCase");function Kp(n,e,t){return e instanceof RegExp?n.replace(e,t):e.reduce(function(r,o){return r.replace(o,t)},n)}a(Kp,"replace");function jp(n,e){return e===void 0&&(e={}),qp(n,Gs({delimiter:"."},e))}a(jp,"dotCase");function Vp(n,e){return e===void 0&&(e={}),jp(n,Gs({delimiter:"_"},e))}a(Vp,"snakeCase");$r();var T1=new Proxy({},{get(n,e){var t,r;if(dr)throw new Error("Workspaces aren't available in the browser");if(e=Vp(e),/\d/.test(e)&&(e=e.replace(/\d+/g,E=>"_"+E).replace("__","_")),n[e])return n[e];let o=ae("fs"),s=ae("path"),i=Gp.parse(o.readFileSync("Anchor.toml")),u=i.provider.cluster,f=(r=(t=i.programs)===null||t===void 0?void 0:t[u])===null||r===void 0?void 0:r[e],y,d;if(typeof f=="object"&&f.idl?(y=f.idl,d=f.address):y=s.join("target","idl",`${e}.json`),!o.existsSync(y))throw new Error(`${y} doesn't exist. Did you run \`anchor build\`?`);let _=JSON.parse(o.readFileSync(y));return d&&(_.address=d),n[e]=new wr(_),n[e]}});ps();import("node:process").then(n=>n.stdout.write(""));export{Xs as a,Vr as b,Il as c,ua as d,Tl as e,Rn as f};
|
27
|
+
/*! Bundled license information:
|
28
|
+
|
29
|
+
safe-buffer/index.js:
|
30
|
+
(*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
31
|
+
|
32
|
+
@solana/buffer-layout/lib/Layout.js:
|
33
|
+
(**
|
34
|
+
* Support for translating between Uint8Array instances and JavaScript
|
35
|
+
* native types.
|
36
|
+
*
|
37
|
+
* {@link module:Layout~Layout|Layout} is the basis of a class
|
38
|
+
* hierarchy that associates property names with sequences of encoded
|
39
|
+
* bytes.
|
40
|
+
*
|
41
|
+
* Layouts are supported for these scalar (numeric) types:
|
42
|
+
* * {@link module:Layout~UInt|Unsigned integers in little-endian
|
43
|
+
* format} with {@link module:Layout.u8|8-bit}, {@link
|
44
|
+
* module:Layout.u16|16-bit}, {@link module:Layout.u24|24-bit},
|
45
|
+
* {@link module:Layout.u32|32-bit}, {@link
|
46
|
+
* module:Layout.u40|40-bit}, and {@link module:Layout.u48|48-bit}
|
47
|
+
* representation ranges;
|
48
|
+
* * {@link module:Layout~UIntBE|Unsigned integers in big-endian
|
49
|
+
* format} with {@link module:Layout.u16be|16-bit}, {@link
|
50
|
+
* module:Layout.u24be|24-bit}, {@link module:Layout.u32be|32-bit},
|
51
|
+
* {@link module:Layout.u40be|40-bit}, and {@link
|
52
|
+
* module:Layout.u48be|48-bit} representation ranges;
|
53
|
+
* * {@link module:Layout~Int|Signed integers in little-endian
|
54
|
+
* format} with {@link module:Layout.s8|8-bit}, {@link
|
55
|
+
* module:Layout.s16|16-bit}, {@link module:Layout.s24|24-bit},
|
56
|
+
* {@link module:Layout.s32|32-bit}, {@link
|
57
|
+
* module:Layout.s40|40-bit}, and {@link module:Layout.s48|48-bit}
|
58
|
+
* representation ranges;
|
59
|
+
* * {@link module:Layout~IntBE|Signed integers in big-endian format}
|
60
|
+
* with {@link module:Layout.s16be|16-bit}, {@link
|
61
|
+
* module:Layout.s24be|24-bit}, {@link module:Layout.s32be|32-bit},
|
62
|
+
* {@link module:Layout.s40be|40-bit}, and {@link
|
63
|
+
* module:Layout.s48be|48-bit} representation ranges;
|
64
|
+
* * 64-bit integral values that decode to an exact (if magnitude is
|
65
|
+
* less than 2^53) or nearby integral Number in {@link
|
66
|
+
* module:Layout.nu64|unsigned little-endian}, {@link
|
67
|
+
* module:Layout.nu64be|unsigned big-endian}, {@link
|
68
|
+
* module:Layout.ns64|signed little-endian}, and {@link
|
69
|
+
* module:Layout.ns64be|unsigned big-endian} encodings;
|
70
|
+
* * 32-bit floating point values with {@link
|
71
|
+
* module:Layout.f32|little-endian} and {@link
|
72
|
+
* module:Layout.f32be|big-endian} representations;
|
73
|
+
* * 64-bit floating point values with {@link
|
74
|
+
* module:Layout.f64|little-endian} and {@link
|
75
|
+
* module:Layout.f64be|big-endian} representations;
|
76
|
+
* * {@link module:Layout.const|Constants} that take no space in the
|
77
|
+
* encoded expression.
|
78
|
+
*
|
79
|
+
* and for these aggregate types:
|
80
|
+
* * {@link module:Layout.seq|Sequence}s of instances of a {@link
|
81
|
+
* module:Layout~Layout|Layout}, with JavaScript representation as
|
82
|
+
* an Array and constant or data-dependent {@link
|
83
|
+
* module:Layout~Sequence#count|length};
|
84
|
+
* * {@link module:Layout.struct|Structure}s that aggregate a
|
85
|
+
* heterogeneous sequence of {@link module:Layout~Layout|Layout}
|
86
|
+
* instances, with JavaScript representation as an Object;
|
87
|
+
* * {@link module:Layout.union|Union}s that support multiple {@link
|
88
|
+
* module:Layout~VariantLayout|variant layouts} over a fixed
|
89
|
+
* (padded) or variable (not padded) span of bytes, using an
|
90
|
+
* unsigned integer at the start of the data or a separate {@link
|
91
|
+
* module:Layout.unionLayoutDiscriminator|layout element} to
|
92
|
+
* determine which layout to use when interpreting the buffer
|
93
|
+
* contents;
|
94
|
+
* * {@link module:Layout.bits|BitStructure}s that contain a sequence
|
95
|
+
* of individual {@link
|
96
|
+
* module:Layout~BitStructure#addField|BitField}s packed into an 8,
|
97
|
+
* 16, 24, or 32-bit unsigned integer starting at the least- or
|
98
|
+
* most-significant bit;
|
99
|
+
* * {@link module:Layout.cstr|C strings} of varying length;
|
100
|
+
* * {@link module:Layout.blob|Blobs} of fixed- or variable-{@link
|
101
|
+
* module:Layout~Blob#length|length} raw data.
|
102
|
+
*
|
103
|
+
* All {@link module:Layout~Layout|Layout} instances are immutable
|
104
|
+
* after construction, to prevent internal state from becoming
|
105
|
+
* inconsistent.
|
106
|
+
*
|
107
|
+
* @local Layout
|
108
|
+
* @local ExternalLayout
|
109
|
+
* @local GreedyCount
|
110
|
+
* @local OffsetLayout
|
111
|
+
* @local UInt
|
112
|
+
* @local UIntBE
|
113
|
+
* @local Int
|
114
|
+
* @local IntBE
|
115
|
+
* @local NearUInt64
|
116
|
+
* @local NearUInt64BE
|
117
|
+
* @local NearInt64
|
118
|
+
* @local NearInt64BE
|
119
|
+
* @local Float
|
120
|
+
* @local FloatBE
|
121
|
+
* @local Double
|
122
|
+
* @local DoubleBE
|
123
|
+
* @local Sequence
|
124
|
+
* @local Structure
|
125
|
+
* @local UnionDiscriminator
|
126
|
+
* @local UnionLayoutDiscriminator
|
127
|
+
* @local Union
|
128
|
+
* @local VariantLayout
|
129
|
+
* @local BitStructure
|
130
|
+
* @local BitField
|
131
|
+
* @local Boolean
|
132
|
+
* @local Blob
|
133
|
+
* @local CString
|
134
|
+
* @local Constant
|
135
|
+
* @local bindConstructorLayout
|
136
|
+
* @module Layout
|
137
|
+
* @license MIT
|
138
|
+
* @author Peter A. Bigot
|
139
|
+
* @see {@link https://github.com/pabigot/buffer-layout|buffer-layout on GitHub}
|
140
|
+
*)
|
141
|
+
|
142
|
+
@solana/web3.js/lib/index.esm.js:
|
143
|
+
(*!
|
144
|
+
* humanize-ms - index.js
|
145
|
+
* Copyright(c) 2014 dead_horse <dead_horse@qq.com>
|
146
|
+
* MIT Licensed
|
147
|
+
*)
|
148
|
+
|
149
|
+
buffer-layout/lib/Layout.js:
|
150
|
+
(**
|
151
|
+
* Support for translating between Buffer instances and JavaScript
|
152
|
+
* native types.
|
153
|
+
*
|
154
|
+
* {@link module:Layout~Layout|Layout} is the basis of a class
|
155
|
+
* hierarchy that associates property names with sequences of encoded
|
156
|
+
* bytes.
|
157
|
+
*
|
158
|
+
* Layouts are supported for these scalar (numeric) types:
|
159
|
+
* * {@link module:Layout~UInt|Unsigned integers in little-endian
|
160
|
+
* format} with {@link module:Layout.u8|8-bit}, {@link
|
161
|
+
* module:Layout.u16|16-bit}, {@link module:Layout.u24|24-bit},
|
162
|
+
* {@link module:Layout.u32|32-bit}, {@link
|
163
|
+
* module:Layout.u40|40-bit}, and {@link module:Layout.u48|48-bit}
|
164
|
+
* representation ranges;
|
165
|
+
* * {@link module:Layout~UIntBE|Unsigned integers in big-endian
|
166
|
+
* format} with {@link module:Layout.u16be|16-bit}, {@link
|
167
|
+
* module:Layout.u24be|24-bit}, {@link module:Layout.u32be|32-bit},
|
168
|
+
* {@link module:Layout.u40be|40-bit}, and {@link
|
169
|
+
* module:Layout.u48be|48-bit} representation ranges;
|
170
|
+
* * {@link module:Layout~Int|Signed integers in little-endian
|
171
|
+
* format} with {@link module:Layout.s8|8-bit}, {@link
|
172
|
+
* module:Layout.s16|16-bit}, {@link module:Layout.s24|24-bit},
|
173
|
+
* {@link module:Layout.s32|32-bit}, {@link
|
174
|
+
* module:Layout.s40|40-bit}, and {@link module:Layout.s48|48-bit}
|
175
|
+
* representation ranges;
|
176
|
+
* * {@link module:Layout~IntBE|Signed integers in big-endian format}
|
177
|
+
* with {@link module:Layout.s16be|16-bit}, {@link
|
178
|
+
* module:Layout.s24be|24-bit}, {@link module:Layout.s32be|32-bit},
|
179
|
+
* {@link module:Layout.s40be|40-bit}, and {@link
|
180
|
+
* module:Layout.s48be|48-bit} representation ranges;
|
181
|
+
* * 64-bit integral values that decode to an exact (if magnitude is
|
182
|
+
* less than 2^53) or nearby integral Number in {@link
|
183
|
+
* module:Layout.nu64|unsigned little-endian}, {@link
|
184
|
+
* module:Layout.nu64be|unsigned big-endian}, {@link
|
185
|
+
* module:Layout.ns64|signed little-endian}, and {@link
|
186
|
+
* module:Layout.ns64be|unsigned big-endian} encodings;
|
187
|
+
* * 32-bit floating point values with {@link
|
188
|
+
* module:Layout.f32|little-endian} and {@link
|
189
|
+
* module:Layout.f32be|big-endian} representations;
|
190
|
+
* * 64-bit floating point values with {@link
|
191
|
+
* module:Layout.f64|little-endian} and {@link
|
192
|
+
* module:Layout.f64be|big-endian} representations;
|
193
|
+
* * {@link module:Layout.const|Constants} that take no space in the
|
194
|
+
* encoded expression.
|
195
|
+
*
|
196
|
+
* and for these aggregate types:
|
197
|
+
* * {@link module:Layout.seq|Sequence}s of instances of a {@link
|
198
|
+
* module:Layout~Layout|Layout}, with JavaScript representation as
|
199
|
+
* an Array and constant or data-dependent {@link
|
200
|
+
* module:Layout~Sequence#count|length};
|
201
|
+
* * {@link module:Layout.struct|Structure}s that aggregate a
|
202
|
+
* heterogeneous sequence of {@link module:Layout~Layout|Layout}
|
203
|
+
* instances, with JavaScript representation as an Object;
|
204
|
+
* * {@link module:Layout.union|Union}s that support multiple {@link
|
205
|
+
* module:Layout~VariantLayout|variant layouts} over a fixed
|
206
|
+
* (padded) or variable (not padded) span of bytes, using an
|
207
|
+
* unsigned integer at the start of the data or a separate {@link
|
208
|
+
* module:Layout.unionLayoutDiscriminator|layout element} to
|
209
|
+
* determine which layout to use when interpreting the buffer
|
210
|
+
* contents;
|
211
|
+
* * {@link module:Layout.bits|BitStructure}s that contain a sequence
|
212
|
+
* of individual {@link
|
213
|
+
* module:Layout~BitStructure#addField|BitField}s packed into an 8,
|
214
|
+
* 16, 24, or 32-bit unsigned integer starting at the least- or
|
215
|
+
* most-significant bit;
|
216
|
+
* * {@link module:Layout.cstr|C strings} of varying length;
|
217
|
+
* * {@link module:Layout.blob|Blobs} of fixed- or variable-{@link
|
218
|
+
* module:Layout~Blob#length|length} raw data.
|
219
|
+
*
|
220
|
+
* All {@link module:Layout~Layout|Layout} instances are immutable
|
221
|
+
* after construction, to prevent internal state from becoming
|
222
|
+
* inconsistent.
|
223
|
+
*
|
224
|
+
* @local Layout
|
225
|
+
* @local ExternalLayout
|
226
|
+
* @local GreedyCount
|
227
|
+
* @local OffsetLayout
|
228
|
+
* @local UInt
|
229
|
+
* @local UIntBE
|
230
|
+
* @local Int
|
231
|
+
* @local IntBE
|
232
|
+
* @local NearUInt64
|
233
|
+
* @local NearUInt64BE
|
234
|
+
* @local NearInt64
|
235
|
+
* @local NearInt64BE
|
236
|
+
* @local Float
|
237
|
+
* @local FloatBE
|
238
|
+
* @local Double
|
239
|
+
* @local DoubleBE
|
240
|
+
* @local Sequence
|
241
|
+
* @local Structure
|
242
|
+
* @local UnionDiscriminator
|
243
|
+
* @local UnionLayoutDiscriminator
|
244
|
+
* @local Union
|
245
|
+
* @local VariantLayout
|
246
|
+
* @local BitStructure
|
247
|
+
* @local BitField
|
248
|
+
* @local Boolean
|
249
|
+
* @local Blob
|
250
|
+
* @local CString
|
251
|
+
* @local Constant
|
252
|
+
* @local bindConstructorLayout
|
253
|
+
* @module Layout
|
254
|
+
* @license MIT
|
255
|
+
* @author Peter A. Bigot
|
256
|
+
* @see {@link https://github.com/pabigot/buffer-layout|buffer-layout on GitHub}
|
257
|
+
*)
|
258
|
+
*/
|
259
|
+
//# sourceMappingURL=chunk-GTITFWMU.js.map
|