@lightprotocol/compressed-token 0.22.1-alpha.3 → 0.22.1-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("./types-DZs1jl_2.cjs");require("@solana/web3.js"),require("@lightprotocol/stateless.js");var t=require("@solana/spl-token");require("@coral-xyz/borsh"),exports.ADD_TOKEN_POOL_DISCRIMINATOR=e.ADD_TOKEN_POOL_DISCRIMINATOR,exports.APPROVE_DISCRIMINATOR=e.APPROVE_DISCRIMINATOR,Object.defineProperty(exports,"Action",{enumerable:1,get:function(){return e.Action}}),exports.BATCH_COMPRESS_DISCRIMINATOR=e.BATCH_COMPRESS_DISCRIMINATOR,exports.COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR=e.COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR,exports.CPI_AUTHORITY_SEED=e.CPI_AUTHORITY_SEED,exports.CREATE_TOKEN_POOL_DISCRIMINATOR=e.CREATE_TOKEN_POOL_DISCRIMINATOR,exports.CompressedTokenInstructionDataApproveLayout=e.CompressedTokenInstructionDataApproveLayout,exports.CompressedTokenInstructionDataRevokeLayout=e.CompressedTokenInstructionDataRevokeLayout,exports.CompressedTokenInstructionDataTransferLayout=e.CompressedTokenInstructionDataTransferLayout,exports.CompressedTokenProgram=e.CompressedTokenProgram,exports.CpiContextLayout=e.CpiContextLayout,exports.DECOMPRESS_ACCOUNTS_IDEMPOTENT_DISCRIMINATOR=e.DECOMPRESS_ACCOUNTS_IDEMPOTENT_DISCRIMINATOR,exports.DelegatedTransferLayout=e.DelegatedTransferLayout,exports.ERROR_NO_ACCOUNTS_FOUND=e.ERROR_NO_ACCOUNTS_FOUND,Object.defineProperty(exports,"ExtensionType",{enumerable:1,get:function(){return e.ExtensionType}}),exports.IDL=e.IDL,exports.MINT_TO_DISCRIMINATOR=e.MINT_TO_DISCRIMINATOR,exports.POOL_SEED=e.POOL_SEED,exports.REVOKE_DISCRIMINATOR=e.REVOKE_DISCRIMINATOR,exports.SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE=e.SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE,exports.TRANSFER_DISCRIMINATOR=e.TRANSFER_DISCRIMINATOR,Object.defineProperty(exports,"TokenDataVersion",{enumerable:1,get:function(){return e.TokenDataVersion}}),exports.addSplInterfaces=e.addSplInterfaces,exports.addTokenPoolAccountsLayout=e.addTokenPoolAccountsLayout,exports.addTokenPools=e.addTokenPools,exports.approve=e.approve,exports.approveAccountsLayout=e.approveAccountsLayout,exports.approveAndMintTo=e.approveAndMintTo,exports.batchCompressLayout=e.batchCompressLayout,exports.calculateCompressibleLoadComputeUnits=e.calculateCompressibleLoadComputeUnits,exports.checkMint=e.checkMint,exports.checkSplInterfaceInfo=e.checkSplInterfaceInfo,exports.checkTokenPoolInfo=e.checkTokenPoolInfo,exports.compress=e.compress,exports.compressSplTokenAccount=e.compressSplTokenAccount,exports.compressSplTokenAccountInstructionDataLayout=e.compressSplTokenAccountInstructionDataLayout,exports.convertTokenDataToAccount=e.convertTokenDataToAccount,exports.createAssociatedCTokenAccountIdempotentInstruction=e.createAssociatedCTokenAccountIdempotentInstruction,exports.createAssociatedCTokenAccountInstruction=e.createAssociatedCTokenAccountInstruction,exports.createAssociatedTokenAccountInterfaceIdempotentInstruction=e.createAssociatedTokenAccountInterfaceIdempotentInstruction,exports.createAssociatedTokenAccountInterfaceInstruction=e.createAssociatedTokenAccountInterfaceInstruction,exports.createAtaInterface=e.createAtaInterface,exports.createAtaInterfaceIdempotent=e.createAtaInterfaceIdempotent,exports.createAtaInterfaceIdempotentInstruction=e.createAtaInterfaceIdempotentInstruction,exports.createCTokenTransferInstruction=e.createCTokenTransferInstruction,exports.createDecompressInterfaceInstruction=e.createDecompressInterfaceInstruction,exports.createDecompressOutputState=e.createDecompressOutputState,exports.createLoadAccountsParams=e.createLoadAccountsParams,exports.createLoadAtaInstructionsFromInterface=e.createLoadAtaInstructionsFromInterface,exports.createMint=e.createMint,exports.createMintInstruction=e.createMintInstruction,exports.createMintInterface=e.createMintInterface,exports.createMintToCompressedInstruction=e.createMintToCompressedInstruction,exports.createMintToInstruction=e.createMintToInstruction,exports.createMintToInterfaceInstruction=e.createMintToInterfaceInstruction,exports.createRemoveMetadataKeyInstruction=e.createRemoveMetadataKeyInstruction,exports.createSplInterface=e.createSplInterface,exports.createTokenMetadata=e.createTokenMetadata,exports.createTokenPool=e.createTokenPool,exports.createTokenPoolAccountsLayout=e.createTokenPoolAccountsLayout,exports.createTokenProgramLookupTable=e.createTokenProgramLookupTable,exports.createTransferInterfaceInstruction=e.createTransferInterfaceInstruction,exports.createTransferOutputState=e.createTransferOutputState,exports.createUpdateFreezeAuthorityInstruction=e.createUpdateFreezeAuthorityInstruction,exports.createUpdateMetadataAuthorityInstruction=e.createUpdateMetadataAuthorityInstruction,exports.createUpdateMetadataFieldInstruction=e.createUpdateMetadataFieldInstruction,exports.createUpdateMintAuthorityInstruction=e.createUpdateMintAuthorityInstruction,exports.createWrapInstruction=e.createWrapInstruction,exports.decodeApproveInstructionData=e.decodeApproveInstructionData,exports.decodeBatchCompressInstructionData=e.decodeBatchCompressInstructionData,exports.decodeCompressSplTokenAccountInstructionData=e.decodeCompressSplTokenAccountInstructionData,exports.decodeMintToInstructionData=e.decodeMintToInstructionData,exports.decodeRevokeInstructionData=e.decodeRevokeInstructionData,exports.decodeTokenMetadata=e.decodeTokenMetadata,exports.decodeTransferInstructionData=e.decodeTransferInstructionData,exports.decompress=e.decompress,exports.decompressDelegated=e.decompressDelegated,exports.decompressInterface=e.decompressInterface,exports.deriveSplInterfaceInfo=e.deriveSplInterfaceInfo,exports.deriveTokenPoolInfo=e.deriveTokenPoolInfo,exports.deserializeMint=e.deserializeMint,exports.encodeApproveInstructionData=e.encodeApproveInstructionData,exports.encodeBatchCompressInstructionData=e.encodeBatchCompressInstructionData,exports.encodeCompressSplTokenAccountInstructionData=e.encodeCompressSplTokenAccountInstructionData,exports.encodeMintToInstructionData=e.encodeMintToInstructionData,exports.encodeRevokeInstructionData=e.encodeRevokeInstructionData,exports.encodeTokenMetadata=e.encodeTokenMetadata,exports.encodeTransferInstructionData=e.encodeTransferInstructionData,exports.extractTokenMetadata=e.extractTokenMetadata,exports.freezeAccountsLayout=e.freezeAccountsLayout,exports.getAccountInterface=e.getAccountInterface,exports.getAssociatedTokenAddressInterface=e.getAssociatedTokenAddressInterface,exports.getMintInterface=e.getMintInterface,exports.getOrCreateAtaInterface=e.getOrCreateAtaInterface,exports.getSplInterfaceInfos=e.getSplInterfaceInfos,exports.getTokenPoolInfos=e.getTokenPoolInfos,exports.isSingleSplInterfaceInfo=e.isSingleSplInterfaceInfo,exports.isSingleTokenPoolInfo=e.isSingleTokenPoolInfo,exports.mergeTokenAccounts=e.mergeTokenAccounts,exports.mintTo=e.mintTo$1,exports.mintToAccountsLayout=e.mintToAccountsLayout,exports.mintToCToken=e.mintTo,exports.mintToCompressed=e.mintToCompressed,exports.mintToInterface=e.mintToInterface,exports.mintToLayout=e.mintToLayout,exports.packCompressedTokenAccounts=e.packCompressedTokenAccounts,exports.parseCTokenCold=e.parseCTokenCold,exports.parseCTokenHot=e.parseCTokenHot,exports.parseMaybeDelegatedTransfer=e.parseMaybeDelegatedTransfer,exports.parseTokenData=e.parseTokenData,exports.removeMetadataKey=e.removeMetadataKey,exports.revoke=e.revoke,exports.revokeAccountsLayout=e.revokeAccountsLayout,exports.selectMinCompressedTokenAccountsForDecompression=e.selectMinCompressedTokenAccountsForDecompression,exports.selectMinCompressedTokenAccountsForTransfer=e.selectMinCompressedTokenAccountsForTransfer,exports.selectMinCompressedTokenAccountsForTransferOrPartial=e.selectMinCompressedTokenAccountsForTransferOrPartial,exports.selectSmartCompressedTokenAccountsForTransfer=e.selectSmartCompressedTokenAccountsForTransfer,exports.selectSmartCompressedTokenAccountsForTransferOrPartial=e.selectSmartCompressedTokenAccountsForTransferOrPartial,exports.selectSplInterfaceInfo=e.selectSplInterfaceInfo,exports.selectSplInterfaceInfosForDecompression=e.selectSplInterfaceInfosForDecompression,exports.selectTokenAccountsForApprove=e.selectTokenAccountsForApprove,exports.selectTokenPoolInfo=e.selectTokenPoolInfo,exports.selectTokenPoolInfosForDecompression=e.selectTokenPoolInfosForDecompression,exports.serializeMint=e.serializeMint,exports.sumUpTokenAmount=e.sumUpTokenAmount,exports.thawAccountsLayout=e.thawAccountsLayout,exports.toAccountInfo=e.toAccountInfo,exports.toOffChainMetadataJson=e.toOffChainMetadataJson,exports.toTokenPoolInfo=e.toTokenPoolInfo,exports.transfer=e.transfer,exports.transferAccountsLayout=e.transferAccountsLayout,exports.transferDelegated=e.transferDelegated,exports.transferInterface=e.transferInterface,exports.unpackMintData=e.unpackMintData,exports.unpackMintInterface=e.unpackMintInterface,exports.updateFreezeAuthority=e.updateFreezeAuthority,exports.updateMetadataAuthority=e.updateMetadataAuthority,exports.updateMetadataField=e.updateMetadataField,exports.updateMintAuthority=e.updateMintAuthority,exports.validateSameTokenOwner=e.validateSameTokenOwner,exports.wrap=e.wrap,Object.defineProperty(exports,"AccountState",{enumerable:1,get:function(){return t.AccountState}}),exports.createLoadAtaInstructions=async function(t,o,r,n,s,a){return e.createLoadAtaInstructions(t,o,r,n,s,a,0)},exports.getAtaInterface=async function(t,o,r,n,s,a){return e.getAtaInterface(t,o,r,n,s,a)},exports.loadAta=async function(t,o,r,n,s,a,c){return e.loadAta(t,o,r,n,s,a,c,0)};
1
+ "use strict";var e=require("./types-CJcjpvYl.cjs");require("@solana/web3.js"),require("@lightprotocol/stateless.js");var t=require("@solana/spl-token");require("@coral-xyz/borsh"),exports.ADD_TOKEN_POOL_DISCRIMINATOR=e.ADD_TOKEN_POOL_DISCRIMINATOR,exports.APPROVE_DISCRIMINATOR=e.APPROVE_DISCRIMINATOR,Object.defineProperty(exports,"Action",{enumerable:1,get:function(){return e.Action}}),exports.BATCH_COMPRESS_DISCRIMINATOR=e.BATCH_COMPRESS_DISCRIMINATOR,exports.COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR=e.COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR,exports.CPI_AUTHORITY_SEED=e.CPI_AUTHORITY_SEED,exports.CREATE_TOKEN_POOL_DISCRIMINATOR=e.CREATE_TOKEN_POOL_DISCRIMINATOR,exports.CompressedTokenInstructionDataApproveLayout=e.CompressedTokenInstructionDataApproveLayout,exports.CompressedTokenInstructionDataRevokeLayout=e.CompressedTokenInstructionDataRevokeLayout,exports.CompressedTokenInstructionDataTransferLayout=e.CompressedTokenInstructionDataTransferLayout,exports.CompressedTokenProgram=e.CompressedTokenProgram,exports.CpiContextLayout=e.CpiContextLayout,exports.DECOMPRESS_ACCOUNTS_IDEMPOTENT_DISCRIMINATOR=e.DECOMPRESS_ACCOUNTS_IDEMPOTENT_DISCRIMINATOR,exports.DelegatedTransferLayout=e.DelegatedTransferLayout,exports.ERROR_NO_ACCOUNTS_FOUND=e.ERROR_NO_ACCOUNTS_FOUND,Object.defineProperty(exports,"ExtensionType",{enumerable:1,get:function(){return e.ExtensionType}}),exports.IDL=e.IDL,exports.MINT_TO_DISCRIMINATOR=e.MINT_TO_DISCRIMINATOR,exports.POOL_SEED=e.POOL_SEED,exports.REVOKE_DISCRIMINATOR=e.REVOKE_DISCRIMINATOR,exports.SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE=e.SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE,exports.TRANSFER_DISCRIMINATOR=e.TRANSFER_DISCRIMINATOR,Object.defineProperty(exports,"TokenDataVersion",{enumerable:1,get:function(){return e.TokenDataVersion}}),exports.addSplInterfaces=e.addSplInterfaces,exports.addTokenPoolAccountsLayout=e.addTokenPoolAccountsLayout,exports.addTokenPools=e.addTokenPools,exports.approve=e.approve,exports.approveAccountsLayout=e.approveAccountsLayout,exports.approveAndMintTo=e.approveAndMintTo,exports.batchCompressLayout=e.batchCompressLayout,exports.calculateCompressibleLoadComputeUnits=e.calculateCompressibleLoadComputeUnits,exports.checkMint=e.checkMint,exports.checkSplInterfaceInfo=e.checkSplInterfaceInfo,exports.checkTokenPoolInfo=e.checkTokenPoolInfo,exports.compress=e.compress,exports.compressSplTokenAccount=e.compressSplTokenAccount,exports.compressSplTokenAccountInstructionDataLayout=e.compressSplTokenAccountInstructionDataLayout,exports.convertTokenDataToAccount=e.convertTokenDataToAccount,exports.createAssociatedCTokenAccountIdempotentInstruction=e.createAssociatedCTokenAccountIdempotentInstruction,exports.createAssociatedCTokenAccountInstruction=e.createAssociatedCTokenAccountInstruction,exports.createAssociatedTokenAccountInterfaceIdempotentInstruction=e.createAssociatedTokenAccountInterfaceIdempotentInstruction,exports.createAssociatedTokenAccountInterfaceInstruction=e.createAssociatedTokenAccountInterfaceInstruction,exports.createAtaInterface=e.createAtaInterface,exports.createAtaInterfaceIdempotent=e.createAtaInterfaceIdempotent,exports.createAtaInterfaceIdempotentInstruction=e.createAtaInterfaceIdempotentInstruction,exports.createCTokenTransferInstruction=e.createCTokenTransferInstruction,exports.createDecompressInterfaceInstruction=e.createDecompressInterfaceInstruction,exports.createDecompressOutputState=e.createDecompressOutputState,exports.createLoadAccountsParams=e.createLoadAccountsParams,exports.createLoadAtaInstructionsFromInterface=e.createLoadAtaInstructionsFromInterface,exports.createMint=e.createMint,exports.createMintInstruction=e.createMintInstruction,exports.createMintInterface=e.createMintInterface,exports.createMintToCompressedInstruction=e.createMintToCompressedInstruction,exports.createMintToInstruction=e.createMintToInstruction,exports.createMintToInterfaceInstruction=e.createMintToInterfaceInstruction,exports.createRemoveMetadataKeyInstruction=e.createRemoveMetadataKeyInstruction,exports.createSplInterface=e.createSplInterface,exports.createTokenMetadata=e.createTokenMetadata,exports.createTokenPool=e.createTokenPool,exports.createTokenPoolAccountsLayout=e.createTokenPoolAccountsLayout,exports.createTokenProgramLookupTable=e.createTokenProgramLookupTable,exports.createTransferInterfaceInstruction=e.createTransferInterfaceInstruction,exports.createTransferOutputState=e.createTransferOutputState,exports.createUpdateFreezeAuthorityInstruction=e.createUpdateFreezeAuthorityInstruction,exports.createUpdateMetadataAuthorityInstruction=e.createUpdateMetadataAuthorityInstruction,exports.createUpdateMetadataFieldInstruction=e.createUpdateMetadataFieldInstruction,exports.createUpdateMintAuthorityInstruction=e.createUpdateMintAuthorityInstruction,exports.createWrapInstruction=e.createWrapInstruction,exports.decodeApproveInstructionData=e.decodeApproveInstructionData,exports.decodeBatchCompressInstructionData=e.decodeBatchCompressInstructionData,exports.decodeCompressSplTokenAccountInstructionData=e.decodeCompressSplTokenAccountInstructionData,exports.decodeMintToInstructionData=e.decodeMintToInstructionData,exports.decodeRevokeInstructionData=e.decodeRevokeInstructionData,exports.decodeTokenMetadata=e.decodeTokenMetadata,exports.decodeTransferInstructionData=e.decodeTransferInstructionData,exports.decompress=e.decompress,exports.decompressDelegated=e.decompressDelegated,exports.decompressInterface=e.decompressInterface,exports.deriveSplInterfaceInfo=e.deriveSplInterfaceInfo,exports.deriveTokenPoolInfo=e.deriveTokenPoolInfo,exports.deserializeMint=e.deserializeMint,exports.encodeApproveInstructionData=e.encodeApproveInstructionData,exports.encodeBatchCompressInstructionData=e.encodeBatchCompressInstructionData,exports.encodeCompressSplTokenAccountInstructionData=e.encodeCompressSplTokenAccountInstructionData,exports.encodeMintToInstructionData=e.encodeMintToInstructionData,exports.encodeRevokeInstructionData=e.encodeRevokeInstructionData,exports.encodeTokenMetadata=e.encodeTokenMetadata,exports.encodeTransferInstructionData=e.encodeTransferInstructionData,exports.extractTokenMetadata=e.extractTokenMetadata,exports.freezeAccountsLayout=e.freezeAccountsLayout,exports.getAccountInterface=e.getAccountInterface,exports.getAssociatedTokenAddressInterface=e.getAssociatedTokenAddressInterface,exports.getMintInterface=e.getMintInterface,exports.getOrCreateAtaInterface=e.getOrCreateAtaInterface,exports.getSplInterfaceInfos=e.getSplInterfaceInfos,exports.getTokenPoolInfos=e.getTokenPoolInfos,exports.isSingleSplInterfaceInfo=e.isSingleSplInterfaceInfo,exports.isSingleTokenPoolInfo=e.isSingleTokenPoolInfo,exports.mergeTokenAccounts=e.mergeTokenAccounts,exports.mintTo=e.mintTo$1,exports.mintToAccountsLayout=e.mintToAccountsLayout,exports.mintToCToken=e.mintTo,exports.mintToCompressed=e.mintToCompressed,exports.mintToInterface=e.mintToInterface,exports.mintToLayout=e.mintToLayout,exports.packCompressedTokenAccounts=e.packCompressedTokenAccounts,exports.parseCTokenCold=e.parseCTokenCold,exports.parseCTokenHot=e.parseCTokenHot,exports.parseMaybeDelegatedTransfer=e.parseMaybeDelegatedTransfer,exports.parseTokenData=e.parseTokenData,exports.removeMetadataKey=e.removeMetadataKey,exports.revoke=e.revoke,exports.revokeAccountsLayout=e.revokeAccountsLayout,exports.selectMinCompressedTokenAccountsForDecompression=e.selectMinCompressedTokenAccountsForDecompression,exports.selectMinCompressedTokenAccountsForTransfer=e.selectMinCompressedTokenAccountsForTransfer,exports.selectMinCompressedTokenAccountsForTransferOrPartial=e.selectMinCompressedTokenAccountsForTransferOrPartial,exports.selectSmartCompressedTokenAccountsForTransfer=e.selectSmartCompressedTokenAccountsForTransfer,exports.selectSmartCompressedTokenAccountsForTransferOrPartial=e.selectSmartCompressedTokenAccountsForTransferOrPartial,exports.selectSplInterfaceInfo=e.selectSplInterfaceInfo,exports.selectSplInterfaceInfosForDecompression=e.selectSplInterfaceInfosForDecompression,exports.selectTokenAccountsForApprove=e.selectTokenAccountsForApprove,exports.selectTokenPoolInfo=e.selectTokenPoolInfo,exports.selectTokenPoolInfosForDecompression=e.selectTokenPoolInfosForDecompression,exports.serializeMint=e.serializeMint,exports.sumUpTokenAmount=e.sumUpTokenAmount,exports.thawAccountsLayout=e.thawAccountsLayout,exports.toAccountInfo=e.toAccountInfo,exports.toOffChainMetadataJson=e.toOffChainMetadataJson,exports.toTokenPoolInfo=e.toTokenPoolInfo,exports.transfer=e.transfer,exports.transferAccountsLayout=e.transferAccountsLayout,exports.transferDelegated=e.transferDelegated,exports.transferInterface=e.transferInterface,exports.unpackMintData=e.unpackMintData,exports.unpackMintInterface=e.unpackMintInterface,exports.updateFreezeAuthority=e.updateFreezeAuthority,exports.updateMetadataAuthority=e.updateMetadataAuthority,exports.updateMetadataField=e.updateMetadataField,exports.updateMintAuthority=e.updateMintAuthority,exports.validateSameTokenOwner=e.validateSameTokenOwner,exports.wrap=e.wrap,Object.defineProperty(exports,"AccountState",{enumerable:1,get:function(){return t.AccountState}}),exports.createLoadAtaInstructions=async function(t,o,r,n,s,a){return e.createLoadAtaInstructions(t,o,r,n,s,a,0)},exports.getAtaInterface=async function(t,o,r,n,s,a){return e.getAtaInterface(t,o,r,n,s,a)},exports.loadAta=async function(t,o,r,n,s,a,c){return e.loadAta(t,o,r,n,s,a,c,0)};
2
2
  //# sourceMappingURL=index.cjs.map
@@ -0,0 +1,2 @@
1
+ "use strict";var e=require("@lightprotocol/stateless.js"),t=require("@solana/web3.js"),n=require("@solana/spl-token"),r=require("@coral-xyz/borsh"),o="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},i=[],s=[],a="undefined"!=typeof Uint8Array?Uint8Array:Array,u=0;function c(){u=1;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)i[t]=e[t],s[e.charCodeAt(t)]=t;s["-".charCodeAt(0)]=62,s["_".charCodeAt(0)]=63}function l(e,t,n){for(var r,o,s=[],a=t;a<n;a+=3)r=(e[a]<<16)+(e[a+1]<<8)+e[a+2],s.push(i[(o=r)>>18&63]+i[o>>12&63]+i[o>>6&63]+i[63&o]);return s.join("")}function d(e){var t;u||c();for(var n=e.length,r=n%3,o="",s=[],a=16383,d=0,p=n-r;d<p;d+=a)s.push(l(e,d,d+a>p?p:d+a));return 1===r?(t=e[n-1],o+=i[t>>2],o+=i[t<<4&63],o+="=="):2===r&&(t=(e[n-2]<<8)+e[n-1],o+=i[t>>10],o+=i[t>>4&63],o+=i[t<<2&63],o+="="),s.push(o),s.join("")}function p(e,t,n,r,o){var i,s,a=8*o-r-1,u=(1<<a)-1,c=u>>1,l=-7,d=n?o-1:0,p=n?-1:1,m=e[t+d];for(d+=p,i=m&(1<<-l)-1,m>>=-l,l+=a;l>0;i=256*i+e[t+d],d+=p,l-=8);for(s=i&(1<<-l)-1,i>>=-l,l+=r;l>0;s=256*s+e[t+d],d+=p,l-=8);if(0===i)i=1-c;else{if(i===u)return s?NaN:Infinity*(m?-1:1);s+=Math.pow(2,r),i-=c}return(m?-1:1)*s*Math.pow(2,i-r)}function m(e,t,n,r,o,i){var s,a,u,c=8*i-o-1,l=(1<<c)-1,d=l>>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,m=r?0:i-1,h=r?1:-1,f=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||Infinity===t?(a=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+d>=1?p/u:p*Math.pow(2,1-d))*u>=2&&(s++,u/=2),s+d>=l?(a=0,s=l):s+d>=1?(a=(t*u-1)*Math.pow(2,o),s+=d):(a=t*Math.pow(2,d-1)*Math.pow(2,o),s=0));o>=8;e[n+m]=255&a,m+=h,a/=256,o-=8);for(s=s<<o|a,c+=o;c>0;e[n+m]=255&s,m+=h,s/=256,c-=8);e[n+m-h]|=128*f}var h={}.toString,f=Array.isArray||function(e){return"[object Array]"==h.call(e)};w.TYPED_ARRAY_SUPPORT=void 0!==o.TYPED_ARRAY_SUPPORT?o.TYPED_ARRAY_SUPPORT:1;var g=y();function y(){return w.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function b(e,t){if(y()<t)throw new RangeError("Invalid typed array length");return w.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=w.prototype:(null===e&&(e=new w(t)),e.length=t),e}function w(e,t,n){if(!(w.TYPED_ARRAY_SUPPORT||this instanceof w))return new w(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return k(this,e)}return I(this,e,t,n)}function I(e,t,n,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");return t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r),w.TYPED_ARRAY_SUPPORT?(e=t).__proto__=w.prototype:e=v(e,t),e}(e,t,n,r):"string"==typeof t?function(e,t,n){if("string"==typeof n&&""!==n||(n="utf8"),!w.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|x(t,n),o=(e=b(e,r)).write(t,n);return o!==r&&(e=e.slice(0,o)),e}(e,t,n):function(e,t){if(P(t)){var n=0|M(t.length);return 0===(e=b(e,n)).length||t.copy(e,0,0,n),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?b(e,0):v(e,t);if("Buffer"===t.type&&f(t.data))return v(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function A(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function k(e,t){if(A(t),e=b(e,t<0?0:0|M(t)),!w.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function v(e,t){var n=t.length<0?0:0|M(t.length);e=b(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function M(e){if(e>=y())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+y().toString(16)+" bytes");return 0|e}function P(e){return!(null==e||!e._isBuffer)}function x(e,t){if(P(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=0;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return J(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return X(e).length;default:if(r)return J(e).length;t=(""+t).toLowerCase(),r=1}}function T(e,t,n){var r=0;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return G(this,t,n);case"utf8":case"utf-8":return N(this,t,n);case"ascii":return W(this,t,n);case"latin1":case"binary":return q(this,t,n);case"base64":return L(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return V(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=1}}function S(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function C(e,t,n,r,o){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=o?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(o)return-1;n=e.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof t&&(t=w.from(t,r)),P(t))return 0===t.length?-1:E(e,t,n,r,o);if("number"==typeof t)return t&=255,w.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):E(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function E(e,t,n,r,o){var i,s=1,a=e.length,u=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,n/=2}function c(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(o){var l=-1;for(i=n;i<a;i++)if(c(e,i)===c(t,-1===l?0:i-l)){if(-1===l&&(l=i),i-l+1===u)return l*s}else-1!==l&&(i-=i-l),l=-1}else for(n+u>a&&(n=a-u),i=n;i>=0;i--){for(var d=1,p=0;p<u;p++)if(c(e,i+p)!==c(t,p)){d=0;break}if(d)return i}return-1}function _(e,t,n,r){n=Number(n)||0;var o=e.length-n;r?(r=Number(r))>o&&(r=o):r=o;var i=t.length;if(i%2!=0)throw new TypeError("Invalid hex string");r>i/2&&(r=i/2);for(var s=0;s<r;++s){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))return s;e[n+s]=a}return s}function O(e,t,n,r){return ee(J(t,e.length-n),e,n,r)}function R(e,t,n,r){return ee(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function D(e,t,n,r){return R(e,t,n,r)}function B(e,t,n,r){return ee(X(t),e,n,r)}function K(e,t,n,r){return ee(function(e,t){for(var n,r,o,i=[],s=0;s<e.length&&!((t-=2)<0);++s)r=(n=e.charCodeAt(s))>>8,o=n%256,i.push(o),i.push(r);return i}(t,e.length-n),e,n,r)}function L(e,t,n){return 0===t&&n===e.length?d(e):d(e.slice(t,n))}function N(e,t,n){n=Math.min(e.length,n);for(var r=[],o=t;o<n;){var i,s,a,u,c=e[o],l=null,d=c>239?4:c>223?3:c>191?2:1;if(o+d<=n)switch(d){case 1:c<128&&(l=c);break;case 2:128==(192&(i=e[o+1]))&&(u=(31&c)<<6|63&i)>127&&(l=u);break;case 3:i=e[o+1],s=e[o+2],128==(192&i)&&128==(192&s)&&(u=(15&c)<<12|(63&i)<<6|63&s)>2047&&(u<55296||u>57343)&&(l=u);break;case 4:i=e[o+1],s=e[o+2],a=e[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(l=u)}null===l?(l=65533,d=1):l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|1023&l),r.push(l),o+=d}return function(e){var t=e.length;if(t<=U)return String.fromCharCode.apply(String,e);for(var n="",r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=U));return n}(r)}w.poolSize=8192,w._augment=function(e){return e.__proto__=w.prototype,e},w.from=function(e,t,n){return I(null,e,t,n)},w.TYPED_ARRAY_SUPPORT&&(w.prototype.__proto__=Uint8Array.prototype,w.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&w[Symbol.species]),w.alloc=function(e,t,n){return function(e,t,n,r){return A(t),t<=0?b(e,t):void 0!==n?"string"==typeof r?b(e,t).fill(n,r):b(e,t).fill(n):b(e,t)}(null,e,t,n)},w.allocUnsafe=function(e){return k(null,e)},w.allocUnsafeSlow=function(e){return k(null,e)},w.isBuffer=te,w.compare=function(e,t){if(!P(e)||!P(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,o=0,i=Math.min(n,r);o<i;++o)if(e[o]!==t[o]){n=e[o],r=t[o];break}return n<r?-1:r<n?1:0},w.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 1;default:return 0}},w.concat=function(e,t){if(!f(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return w.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=w.allocUnsafe(t),o=0;for(n=0;n<e.length;++n){var i=e[n];if(!P(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(r,o),o+=i.length}return r},w.byteLength=x,w.prototype._isBuffer=1,w.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)S(this,t,t+1);return this},w.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)S(this,t,t+3),S(this,t+1,t+2);return this},w.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)S(this,t,t+7),S(this,t+1,t+6),S(this,t+2,t+5),S(this,t+3,t+4);return this},w.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?N(this,0,e):T.apply(this,arguments)},w.prototype.equals=function(e){if(!P(e))throw new TypeError("Argument must be a Buffer");return this===e?1:0===w.compare(this,e)},w.prototype.inspect=function(){var e="";return this.length>0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),"<Buffer "+e+">"},w.prototype.compare=function(e,t,n,r,o){if(!P(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),t<0||n>e.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&t>=n)return 0;if(r>=o)return-1;if(t>=n)return 1;if(this===e)return 0;for(var i=(o>>>=0)-(r>>>=0),s=(n>>>=0)-(t>>>=0),a=Math.min(i,s),u=this.slice(r,o),c=e.slice(t,n),l=0;l<a;++l)if(u[l]!==c[l]){i=u[l],s=c[l];break}return i<s?-1:s<i?1:0},w.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},w.prototype.indexOf=function(e,t,n){return C(this,e,t,n,1)},w.prototype.lastIndexOf=function(e,t,n){return C(this,e,t,n,0)},w.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var o=this.length-t;if((void 0===n||n>o)&&(n=o),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=0;;)switch(r){case"hex":return _(this,e,t,n);case"utf8":case"utf-8":return O(this,e,t,n);case"ascii":return R(this,e,t,n);case"latin1":case"binary":return D(this,e,t,n);case"base64":return B(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return K(this,e,t,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=1}},w.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var U=4096;function W(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;o<n;++o)r+=String.fromCharCode(127&e[o]);return r}function q(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;o<n;++o)r+=String.fromCharCode(e[o]);return r}function G(e,t,n){var r,o=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>o)&&(n=o);for(var i="",s=t;s<n;++s)i+=(r=e[s])<16?"0"+r.toString(16):r.toString(16);return i}function V(e,t,n){for(var r=e.slice(t,n),o="",i=0;i<r.length;i+=2)o+=String.fromCharCode(r[i]+256*r[i+1]);return o}function F(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function z(e,t,n,r,o,i){if(!P(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||t<i)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function j(e,t,n,r){t<0&&(t=65535+t+1);for(var o=0,i=Math.min(e.length-n,2);o<i;++o)e[n+o]=(t&255<<8*(r?o:1-o))>>>8*(r?o:1-o)}function $(e,t,n,r){t<0&&(t=4294967295+t+1);for(var o=0,i=Math.min(e.length-n,4);o<i;++o)e[n+o]=t>>>8*(r?o:3-o)&255}function Y(e,t,n,r){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function Z(e,t,n,r,o){return o||Y(e,0,n,4),m(e,t,n,r,23,4),n+4}function H(e,t,n,r,o){return o||Y(e,0,n,8),m(e,t,n,r,52,8),n+8}w.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),w.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=w.prototype;else{var o=t-e;n=new w(o,void 0);for(var i=0;i<o;++i)n[i]=this[i+e]}return n},w.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||F(e,t,this.length);for(var r=this[e],o=1,i=0;++i<t&&(o*=256);)r+=this[e+i]*o;return r},w.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||F(e,t,this.length);for(var r=this[e+--t],o=1;t>0&&(o*=256);)r+=this[e+--t]*o;return r},w.prototype.readUInt8=function(e,t){return t||F(e,1,this.length),this[e]},w.prototype.readUInt16LE=function(e,t){return t||F(e,2,this.length),this[e]|this[e+1]<<8},w.prototype.readUInt16BE=function(e,t){return t||F(e,2,this.length),this[e]<<8|this[e+1]},w.prototype.readUInt32LE=function(e,t){return t||F(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},w.prototype.readUInt32BE=function(e,t){return t||F(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},w.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||F(e,t,this.length);for(var r=this[e],o=1,i=0;++i<t&&(o*=256);)r+=this[e+i]*o;return r>=(o*=128)&&(r-=Math.pow(2,8*t)),r},w.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||F(e,t,this.length);for(var r=t,o=1,i=this[e+--r];r>0&&(o*=256);)i+=this[e+--r]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*t)),i},w.prototype.readInt8=function(e,t){return t||F(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},w.prototype.readInt16LE=function(e,t){t||F(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},w.prototype.readInt16BE=function(e,t){t||F(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},w.prototype.readInt32LE=function(e,t){return t||F(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},w.prototype.readInt32BE=function(e,t){return t||F(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},w.prototype.readFloatLE=function(e,t){return t||F(e,4,this.length),p(this,e,1,23,4)},w.prototype.readFloatBE=function(e,t){return t||F(e,4,this.length),p(this,e,0,23,4)},w.prototype.readDoubleLE=function(e,t){return t||F(e,8,this.length),p(this,e,1,52,8)},w.prototype.readDoubleBE=function(e,t){return t||F(e,8,this.length),p(this,e,0,52,8)},w.prototype.writeUIntLE=function(e,t,n,r){e=+e,t|=0,n|=0,r||z(this,e,t,n,Math.pow(2,8*n)-1,0);var o=1,i=0;for(this[t]=255&e;++i<n&&(o*=256);)this[t+i]=e/o&255;return t+n},w.prototype.writeUIntBE=function(e,t,n,r){e=+e,t|=0,n|=0,r||z(this,e,t,n,Math.pow(2,8*n)-1,0);var o=n-1,i=1;for(this[t+o]=255&e;--o>=0&&(i*=256);)this[t+o]=e/i&255;return t+n},w.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||z(this,e,t,1,255,0),w.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},w.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||z(this,e,t,2,65535,0),w.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):j(this,e,t,1),t+2},w.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||z(this,e,t,2,65535,0),w.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):j(this,e,t,0),t+2},w.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||z(this,e,t,4,4294967295,0),w.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):$(this,e,t,1),t+4},w.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||z(this,e,t,4,4294967295,0),w.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):$(this,e,t,0),t+4},w.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);z(this,e,t,n,o-1,-o)}var i=0,s=1,a=0;for(this[t]=255&e;++i<n&&(s*=256);)e<0&&0===a&&0!==this[t+i-1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+n},w.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var o=Math.pow(2,8*n-1);z(this,e,t,n,o-1,-o)}var i=n-1,s=1,a=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===a&&0!==this[t+i+1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+n},w.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||z(this,e,t,1,127,-128),w.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},w.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||z(this,e,t,2,32767,-32768),w.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):j(this,e,t,1),t+2},w.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||z(this,e,t,2,32767,-32768),w.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):j(this,e,t,0),t+2},w.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||z(this,e,t,4,2147483647,-2147483648),w.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):$(this,e,t,1),t+4},w.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||z(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),w.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):$(this,e,t,0),t+4},w.prototype.writeFloatLE=function(e,t,n){return Z(this,e,t,1,n)},w.prototype.writeFloatBE=function(e,t,n){return Z(this,e,t,0,n)},w.prototype.writeDoubleLE=function(e,t,n){return H(this,e,t,1,n)},w.prototype.writeDoubleBE=function(e,t,n){return H(this,e,t,0,n)},w.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var o,i=r-n;if(this===e&&n<t&&t<r)for(o=i-1;o>=0;--o)e[o+t]=this[o+n];else if(i<1e3||!w.TYPED_ARRAY_SUPPORT)for(o=0;o<i;++o)e[o+t]=this[o+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+i),t);return i},w.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var o=e.charCodeAt(0);o<256&&(e=o)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!w.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var i;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(i=t;i<n;++i)this[i]=e;else{var s=P(e)?e:J(new w(e,r).toString()),a=s.length;for(i=0;i<n-t;++i)this[i+t]=s[i%a]}return this};var Q=/[^+\/0-9A-Za-z-_]/g;function J(e,t){var n;t=t||Infinity;for(var r=e.length,o=null,i=[],s=0;s<r;++s){if((n=e.charCodeAt(s))>55295&&n<57344){if(!o){if(n>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(t-=3)>-1&&i.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((t-=1)<0)break;i.push(n)}else if(n<2048){if((t-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function X(e){return function(e){var t,n,r,o,i,l;u||c();var d=e.length;if(d%4>0)throw new Error("Invalid string. Length must be a multiple of 4");i="="===e[d-2]?2:"="===e[d-1]?1:0,l=new a(3*d/4-i),r=i>0?d-4:d;var p=0;for(t=0,n=0;t<r;t+=4,n+=3)o=s[e.charCodeAt(t)]<<18|s[e.charCodeAt(t+1)]<<12|s[e.charCodeAt(t+2)]<<6|s[e.charCodeAt(t+3)],l[p++]=o>>16&255,l[p++]=o>>8&255,l[p++]=255&o;return 2===i?(o=s[e.charCodeAt(t)]<<2|s[e.charCodeAt(t+1)]>>4,l[p++]=255&o):1===i&&(o=s[e.charCodeAt(t)]<<10|s[e.charCodeAt(t+1)]<<4|s[e.charCodeAt(t+2)]>>2,l[p++]=o>>8&255,l[p++]=255&o),l}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Q,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function ee(e,t,n,r){for(var o=0;o<r&&!(o+n>=t.length||o>=e.length);++o)t[o+n]=e[o];return o}function te(e){return null!=e&&(!!e._isBuffer||ne(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&ne(e.slice(0,0))}(e))}function ne(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}var re,oe=Object.freeze({__proto__:null,Buffer:w,INSPECT_MAX_BYTES:50,SlowBuffer:function(e){return+e!=e&&(e=0),w.alloc(+e)},isBuffer:te,kMaxLength:g});exports.TokenDataVersion=void 0,(re=exports.TokenDataVersion||(exports.TokenDataVersion={}))[re.V1=1]="V1",re[re.V2=2]="V2",re[re.ShaFlat=3]="ShaFlat";const ie=w.from("pool"),se=w.from("cpi_authority"),ae=w.from([23,169,27,122,147,169,209,152]),ue=w.from([241,34,48,186,37,179,123,192]),ce=w.from([65,206,101,37,147,42,221,144]),le=w.from([163,52,200,231,140,3,69,186]),de=w.from([112,230,105,101,145,202,157,97]),pe=w.from([69,74,217,36,115,117,97,76]),me=w.from([170,23,31,34,133,173,93,242]),he=w.from([114,143,210,73,96,115,1,228]),fe=w.from([107]);function ge(e){return{mint:e.mint,tokenPoolPda:e.splInterfacePda,splInterfacePda:e.splInterfacePda,tokenProgram:e.tokenProgram,activity:e.activity,isInitialized:e.isInitialized,balance:e.balance,poolIndex:e.poolIndex,bump:e.bump}}function ye(e){var t;return{mint:e.mint,splInterfacePda:null!==(t=e.tokenPoolPda)&&void 0!==t?t:e.splInterfacePda,tokenProgram:e.tokenProgram,activity:e.activity,isInitialized:e.isInitialized,balance:e.balance,poolIndex:e.poolIndex,bump:e.bump}}function be(t,n,r=0){const[o,i]=pt.deriveSplInterfacePdaWithIndex(t,r);return{mint:t,splInterfacePda:o,tokenProgram:n,activity:void 0,balance:e.bn(0),isInitialized:1,poolIndex:r,bump:i}}function we(e,t){const n="tokenPoolPda"in e?ye(e):e;if(!n.mint.equals(t))throw new Error("SplInterface mint does not match the provided mint.");if(!n.isInitialized)throw new Error(`SplInterface is not initialized. Please create an SPL interface for mint: ${t.toBase58()} via createSplInterface().`);return 1}async function Ie(t,r,o){const i=Array.from({length:5},((e,t)=>pt.deriveSplInterfacePdaWithIndex(r,t))),s=await t.getMultipleAccountsInfo(i.map((e=>e[0])),o);if(null===s[0])throw new Error(`SplInterface not found. Please create an SPL interface for mint: ${r.toBase58()} via createSplInterface().`);const a=i.map(((e,t)=>s[t]?n.unpackAccount(e[0],s[t],s[t].owner):null)),u=s[0].owner;return a.map(((t,n)=>t?{mint:r,splInterfacePda:t.address,tokenProgram:u,activity:void 0,balance:e.bn(t.amount.toString()),isInitialized:1,poolIndex:n,bump:i[n][1]}:{mint:r,splInterfacePda:i[n][0],tokenProgram:u,activity:void 0,balance:e.bn(0),isInitialized:0,poolIndex:n,bump:i[n][1]}))}var Ae;exports.Action=void 0,(Ae=exports.Action||(exports.Action={}))[Ae.Compress=1]="Compress",Ae[Ae.Decompress=2]="Decompress",Ae[Ae.Transfer=3]="Transfer";const ke=e=>{for(let t=e.length-1;t>0;t--){const n=Math.floor(Math.random()*(t+1));[e[t],e[n]]=[e[n],e[t]]}return e};function ve(e){const t=ke(e).filter((e=>e.isInitialized));if(0===t.length)throw new Error("Please pass at least one initialized SPL interface info.");return t[0]}function Me(t,n){if(0===t.length)throw new Error("Please pass at least one SPL interface info.");const r=(t=ke(t)).find((t=>t.balance.gte(e.bn(n).mul(e.bn(10)))));if((t=t.filter((e=>e.isInitialized)).sort(((e,t)=>e.poolIndex-t.poolIndex))).every((e=>e.balance.isZero())))throw new Error("All provided SPL interface balances are zero. Please pass recent SPL interface infos.");return r?[r]:t}const Pe="Could not find accounts to select for transfer.";function xe(e,t,n=4){const r=e.find((e=>e.parsed.amount.eq(t)));return r?[[r],r.parsed.amount,r.compressedAccount.lamports,r.parsed.amount]:Te(e,t,n)}function Te(t,n,r=4){const[o,i,s,a]=Se(t,n,r);if(i.lt(e.bn(n))){const i=t.reduce(((e,t)=>e.add(t.parsed.amount)),e.bn(0));throw o.length>=r?new Error(`Account limit exceeded: max ${a.toString()} (${r} accounts) per transaction. Total balance: ${i.toString()} (${t.length} accounts). Consider multiple transfers to spend full balance.`):new Error(`Insufficient balance for transfer. Required: ${n.toString()}, available: ${i.toString()}.`)}if(0===o.length)throw new Error(Pe);return[o,i,s,a]}function Se(t,n,r=4){if(0===t.length)throw new Error(Pe);let o=e.bn(0),i=e.bn(0),s=e.bn(0);const a=[];t.sort(((e,t)=>t.parsed.amount.cmp(e.parsed.amount)));for(const s of t){if(a.length>=r)break;if(o.gte(e.bn(n)))break;s.parsed.amount.isZero()&&s.compressedAccount.lamports.isZero()||(o=o.add(s.parsed.amount),i=i.add(s.compressedAccount.lamports),a.push(s))}if(s=t.slice(0,r).reduce(((e,t)=>e.add(t.parsed.amount)),e.bn(0)),o.lt(e.bn(n))&&console.log(`Insufficient balance for transfer. Requested: ${n.toString()}, Returns max available: ${s.toString()}.`),0===a.length)throw new Error(Pe);return[a,o,i,s]}function Ce(t,n,r=4){if(0===t.length)throw new Error(Pe);let o=e.bn(0),i=e.bn(0);const s=[],a=t.filter((e=>!e.parsed.amount.isZero()||!e.compressedAccount.lamports.isZero()));a.sort(((e,t)=>t.parsed.amount.cmp(e.parsed.amount)));for(const t of a){if(s.length>=r)break;if(o=o.add(t.parsed.amount),i=i.add(t.compressedAccount.lamports),s.push(t),o.gte(e.bn(n))){const e=a.slice(s.length);if(e.length>0){const t=e.reduce(((e,t)=>t.parsed.amount.lt(e.parsed.amount)?t:e));s.length<r&&(s.push(t),o=o.add(t.parsed.amount),i=i.add(t.compressedAccount.lamports))}break}}const u=a.slice(0,r).reduce(((e,t)=>e.add(t.parsed.amount)),e.bn(0));if(0===s.length)throw new Error(Pe);return[s,o,i,u]}function Ee(t){const{inputCompressedTokenAccounts:n,outputStateTreeInfo:r,remainingAccounts:o=[],rootIndices:i,tokenTransferOutputs:s}=t,a=o.slice();let u=null;n.length>0&&n[0].parsed.delegate&&(u=e.getIndexOrAdd(a,n[0].parsed.delegate));const c=[];if(n.forEach(((t,n)=>{const r=e.getIndexOrAdd(a,t.compressedAccount.treeInfo.tree),o=e.getIndexOrAdd(a,t.compressedAccount.treeInfo.queue);c.push({amount:t.parsed.amount,delegateIndex:u,merkleContext:{merkleTreePubkeyIndex:r,queuePubkeyIndex:o,leafIndex:t.compressedAccount.leafIndex,proveByIndex:t.compressedAccount.proveByIndex},rootIndex:i[n],lamports:t.compressedAccount.lamports.eq(e.bn(0))?null:t.compressedAccount.lamports,tlv:null})})),n.length>0&&r)throw new Error("Cannot specify both input accounts and outputStateTreeInfo");let l;if(n.length>0)l=n[0].compressedAccount.treeInfo;else{if(!r)throw new Error("Neither input accounts nor outputStateTreeInfo are available");l=r}const d=l.nextTreeInfo||l;let p=d.tree;if(d.treeType===e.TreeType.StateV2){if(!e.featureFlags.isV2())throw new Error("V2 trees are not supported yet");p=d.queue}const m=e.padOutputStateMerkleTrees(p,s.length),h=[];m.forEach(((t,n)=>{var r;const o=e.getIndexOrAdd(a,t);h.push({owner:s[n].owner,amount:s[n].amount,lamports:(null===(r=s[n].lamports)||void 0===r?void 0:r.eq(e.bn(0)))?null:s[n].lamports,merkleTreeIndex:o,tlv:null})}));const f=a.map((e=>({pubkey:e,isWritable:1,isSigner:0})));return{inputTokenDataWithContext:c,remainingAccountMetas:f,packedOutputTokenData:h}}function _e(e,t){if(!e.every((e=>e.parsed.mint.equals(t))))throw new Error("All input accounts must belong to the same mint");return 1}const Oe=r.struct([r.array(r.u8(),32,"a"),r.array(r.u8(),64,"b"),r.array(r.u8(),32,"c")]),Re=r.struct([r.publicKey("owner"),r.u64("amount"),r.option(r.u64(),"lamports"),r.u8("merkleTreeIndex"),r.option(r.vecU8(),"tlv")]),De=r.struct([r.u64("amount"),r.option(r.u8(),"delegateIndex"),r.struct([r.u8("merkleTreePubkeyIndex"),r.u8("queuePubkeyIndex"),r.u32("leafIndex"),r.bool("proveByIndex")],"merkleContext"),r.u16("rootIndex"),r.option(r.u64(),"lamports"),r.option(r.vecU8(),"tlv")]),Be=r.struct([r.publicKey("owner"),r.option(r.u8(),"delegateChangeAccountIndex")]),Ke=r.struct([r.bool("setContext"),r.bool("firstSetContext"),r.u8("cpiContextAccountIndex")]),Le=r.struct([r.option(Oe,"proof"),r.publicKey("mint"),r.option(Be,"delegatedTransfer"),r.vec(De,"inputTokenDataWithContext"),r.vec(Re,"outputCompressedAccounts"),r.bool("isCompress"),r.option(r.u64(),"compressOrDecompressAmount"),r.option(Ke,"cpiContext"),r.option(r.u8(),"lamportsChangeAccountMerkleTreeIndex")]),Ne=r.struct([r.vec(r.publicKey(),"recipients"),r.vec(r.u64(),"amounts"),r.option(r.u64(),"lamports")]),Ue=r.struct([r.vec(r.publicKey(),"pubkeys"),r.option(r.vec(r.u64(),"amounts"),"amounts"),r.option(r.u64(),"lamports"),r.option(r.u64(),"amount"),r.u8("index"),r.u8("bump")]),We=r.struct([r.publicKey("owner"),r.option(r.u64(),"remainingAmount"),r.option(Ke,"cpiContext")]);function qe(e){const t=w.alloc(1e3),n=Ne.encode({recipients:e.recipients,amounts:e.amounts,lamports:e.lamports},t);return w.concat([new Uint8Array(ue),new Uint8Array(t.subarray(0,n))])}function Ge(e){const t=w.alloc(1e3),n=Ue.encode(e,t),r=w.alloc(4);r.writeUInt32LE(n,0);const o=t.subarray(0,n);return w.concat([new Uint8Array(ce),new Uint8Array(r),new Uint8Array(o)])}function Ve(e){const t=w.alloc(1e3),n=We.encode({owner:e.owner,remainingAmount:e.remainingAmount,cpiContext:e.cpiContext},t);return w.concat([new Uint8Array(de),new Uint8Array(t.subarray(0,n))])}function Fe(e){const t=w.alloc(1e3),n=Le.encode(e,t),r=w.alloc(4);r.writeUInt32LE(n,0);const o=t.subarray(0,n);return w.concat([new Uint8Array(le),new Uint8Array(r),new Uint8Array(o)])}const ze=e=>{const{feePayer:t,tokenPoolPda:n,systemProgram:r,mint:o,tokenProgram:i,cpiAuthorityPda:s}=e;return[{pubkey:t,isSigner:1,isWritable:1},{pubkey:n,isSigner:0,isWritable:1},{pubkey:r,isSigner:0,isWritable:0},{pubkey:o,isSigner:0,isWritable:1},{pubkey:i,isSigner:0,isWritable:0},{pubkey:s,isSigner:0,isWritable:0}]},je=e=>{const{feePayer:t,tokenPoolPda:n,systemProgram:r,mint:o,tokenProgram:i,cpiAuthorityPda:s,existingTokenPoolPda:a}=e;return[{pubkey:t,isSigner:1,isWritable:1},{pubkey:n,isSigner:0,isWritable:1},{pubkey:a,isSigner:0,isWritable:0},{pubkey:r,isSigner:0,isWritable:0},{pubkey:o,isSigner:0,isWritable:1},{pubkey:i,isSigner:0,isWritable:0},{pubkey:s,isSigner:0,isWritable:0}]},$e=e=>{const t=pt.programId,{feePayer:n,authority:r,cpiAuthorityPda:o,mint:i,tokenPoolPda:s,tokenProgram:a,lightSystemProgram:u,registeredProgramPda:c,noopProgram:l,accountCompressionAuthority:d,accountCompressionProgram:p,merkleTree:m,selfProgram:h,systemProgram:f,solPoolPda:g}=e;return[{pubkey:n,isSigner:1,isWritable:1},{pubkey:r,isSigner:1,isWritable:0},{pubkey:o,isSigner:0,isWritable:0},{pubkey:i,isSigner:0,isWritable:1},{pubkey:s,isSigner:0,isWritable:1},{pubkey:a,isSigner:0,isWritable:0},{pubkey:u,isSigner:0,isWritable:0},{pubkey:c,isSigner:0,isWritable:0},{pubkey:l,isSigner:0,isWritable:0},{pubkey:d,isSigner:0,isWritable:0},{pubkey:p,isSigner:0,isWritable:0},{pubkey:m,isSigner:0,isWritable:1},{pubkey:h,isSigner:0,isWritable:0},{pubkey:f,isSigner:0,isWritable:0},{pubkey:null!=g?g:t,isSigner:0,isWritable:1}]},Ye=e=>{const t=pt.programId,{feePayer:n,authority:r,cpiAuthorityPda:o,lightSystemProgram:i,registeredProgramPda:s,noopProgram:a,accountCompressionAuthority:u,accountCompressionProgram:c,selfProgram:l,tokenPoolPda:d,compressOrDecompressTokenAccount:p,tokenProgram:m,systemProgram:h}=e;return[{pubkey:n,isSigner:1,isWritable:1},{pubkey:r,isSigner:1,isWritable:0},{pubkey:o,isSigner:0,isWritable:0},{pubkey:i,isSigner:0,isWritable:0},{pubkey:s,isSigner:0,isWritable:0},{pubkey:a,isSigner:0,isWritable:0},{pubkey:u,isSigner:0,isWritable:0},{pubkey:c,isSigner:0,isWritable:0},{pubkey:l,isSigner:0,isWritable:0},{pubkey:null!=d?d:t,isSigner:0,isWritable:1},{pubkey:null!=p?p:t,isSigner:0,isWritable:1},{pubkey:null!=m?m:t,isSigner:0,isWritable:0},{pubkey:h,isSigner:0,isWritable:0}]},Ze=e=>{const{feePayer:t,authority:n,cpiAuthorityPda:r,lightSystemProgram:o,registeredProgramPda:i,noopProgram:s,accountCompressionAuthority:a,accountCompressionProgram:u,selfProgram:c,systemProgram:l}=e;return[{pubkey:t,isSigner:1,isWritable:1},{pubkey:n,isSigner:1,isWritable:0},{pubkey:r,isSigner:0,isWritable:0},{pubkey:o,isSigner:0,isWritable:0},{pubkey:i,isSigner:0,isWritable:0},{pubkey:s,isSigner:0,isWritable:0},{pubkey:a,isSigner:0,isWritable:0},{pubkey:u,isSigner:0,isWritable:0},{pubkey:c,isSigner:0,isWritable:0},{pubkey:l,isSigner:0,isWritable:0}]},He=Ze,Qe=e=>{const{feePayer:t,authority:n,cpiAuthorityPda:r,lightSystemProgram:o,registeredProgramPda:i,noopProgram:s,accountCompressionAuthority:a,accountCompressionProgram:u,selfProgram:c,systemProgram:l,mint:d}=e;return[{pubkey:t,isSigner:1,isWritable:1},{pubkey:n,isSigner:1,isWritable:0},{pubkey:r,isSigner:0,isWritable:0},{pubkey:o,isSigner:0,isWritable:0},{pubkey:i,isSigner:0,isWritable:0},{pubkey:s,isSigner:0,isWritable:0},{pubkey:a,isSigner:0,isWritable:0},{pubkey:u,isSigner:0,isWritable:0},{pubkey:c,isSigner:0,isWritable:0},{pubkey:l,isSigner:0,isWritable:0},{pubkey:d,isSigner:0,isWritable:0}]},Je=Qe,Xe=r.struct([r.struct([r.array(r.u8(),32,"a"),r.array(r.u8(),64,"b"),r.array(r.u8(),32,"c")],"proof"),r.publicKey("mint"),r.vec(De,"inputTokenDataWithContext"),r.option(Ke,"cpiContext"),r.publicKey("delegate"),r.u64("delegatedAmount"),r.u8("delegateMerkleTreeIndex"),r.u8("changeAccountMerkleTreeIndex"),r.option(r.u64(),"delegateLamports")]),et=r.struct([r.struct([r.array(r.u8(),32,"a"),r.array(r.u8(),64,"b"),r.array(r.u8(),32,"c")],"proof"),r.publicKey("mint"),r.vec(De,"inputTokenDataWithContext"),r.option(Ke,"cpiContext"),r.u8("outputAccountMerkleTreeIndex")]),tt={a:new Array(32).fill(0),b:new Array(64).fill(0),c:new Array(32).fill(0)};function nt(e){return e.a.every((e=>0===e))&&e.b.every((e=>0===e))&&e.c.every((e=>0===e))}function rt(e){var t;const n=w.alloc(1e3),r=null!==(t=e.proof)&&void 0!==t?t:tt,o=Xe.encode(Object.assign(Object.assign({},e),{proof:r}),n),i=w.alloc(4);i.writeUInt32LE(o,0);const s=n.subarray(0,o);return w.concat([new Uint8Array(pe),new Uint8Array(i),new Uint8Array(s)])}function ot(e){var t;const n=w.alloc(1e3),r=null!==(t=e.proof)&&void 0!==t?t:tt,o=et.encode(Object.assign(Object.assign({},e),{proof:r}),n),i=w.alloc(4);i.writeUInt32LE(o,0);const s=n.subarray(0,o);return w.concat([new Uint8Array(me),new Uint8Array(i),new Uint8Array(s)])}function it(e){var t;return"tokenPoolPda"in e&&null!==(t=e.tokenPoolPda)&&void 0!==t?t:e.splInterfacePda}const st=t=>t.reduce(((e,t)=>e.add(t.parsed.amount)),e.bn(0)),at=e=>{const t=e[0].parsed.owner;e.forEach((e=>{if(!e.parsed.owner.equals(t))throw new Error("Token accounts must be owned by the same owner")}))},ut=e=>({mint:e[0].parsed.mint,currentOwner:e[0].parsed.owner,delegate:e[0].parsed.delegate}),ct=(e,t)=>{if(e.length<1)throw new Error("Must supply at least one input token account.");const n=e[0].parsed.owner,r=e.findIndex((e=>e.parsed.delegate));if(-1===r)return{delegatedTransfer:null,authority:n};const o=e[r].parsed.delegate;return{delegatedTransfer:{owner:n,delegateChangeAccountIndex:t.length<=1?null:0},authority:o}};function lt(t,n,r){r=e.bn(r);const o=st(t),i=e.sumUpLamports(t.map((e=>e.compressedAccount))),s=o.sub(r);return e.validateSufficientBalance(s),s.eq(e.bn(0))&&i.eq(e.bn(0))?[{owner:n,amount:r,lamports:i,tlv:null}]:(e.validateSameOwner(t.map((e=>e.compressedAccount))),at(t),[{owner:t[0].parsed.owner,amount:s,lamports:i,tlv:null},{owner:n,amount:r,lamports:e.bn(0),tlv:null}])}function dt(t,n){n=e.bn(n);const r=e.sumUpLamports(t.map((e=>e.compressedAccount))),o=st(t).sub(n);return e.validateSufficientBalance(o),o.eq(e.bn(0))&&r.eq(e.bn(0))?[]:(e.validateSameOwner(t.map((e=>e.compressedAccount))),at(t),[{owner:t[0].parsed.owner,amount:o,lamports:r,tlv:null}])}class pt{constructor(){}static setProgramId(e){this.programId="string"==typeof e?new t.PublicKey(e):e}static deriveSplInterfacePda(e){const n=[ie,e.toBuffer()],[r,o]=t.PublicKey.findProgramAddressSync(n,this.programId);return r}static deriveTokenPoolPda(e){return this.deriveSplInterfacePda(e)}static findSplInterfaceIndexAndBump(e,t){for(let n=0;n<5;n++){const r=pt.deriveSplInterfacePdaWithIndex(t,n);if(r[0].equals(e))return[n,r[1]]}throw new Error("SPL interface not found")}static findTokenPoolIndexAndBump(e,t){return this.findSplInterfaceIndexAndBump(e,t)}static deriveSplInterfacePdaWithIndex(e,n){let r=[];r=0===n?[w.from("pool"),e.toBuffer(),w.from([])]:[w.from("pool"),e.toBuffer(),w.from([n])];const[o,i]=t.PublicKey.findProgramAddressSync(r,this.programId);return[o,i]}static deriveTokenPoolPdaWithIndex(e,t){return this.deriveSplInterfacePdaWithIndex(e,t)}static get deriveCpiAuthorityPda(){const[e,n]=t.PublicKey.findProgramAddressSync([se],this.programId);return e}static async createMint({feePayer:e,mint:r,authority:o,freezeAuthority:i,decimals:s,rentExemptBalance:a,tokenProgramId:u,mintSize:c}){const l=null!=u?u:n.TOKEN_PROGRAM_ID;return[t.SystemProgram.createAccount({fromPubkey:e,lamports:a,newAccountPubkey:r,programId:l,space:null!=c?c:n.MINT_SIZE}),n.createInitializeMint2Instruction(r,s,o,i,l),await this.createTokenPool({feePayer:e,mint:r,tokenProgramId:l})]}static async createTokenPool({feePayer:e,mint:r,tokenProgramId:o}){const i=null!=o?o:n.TOKEN_PROGRAM_ID,s=this.deriveSplInterfacePdaWithIndex(r,0),a=ze({mint:r,feePayer:e,tokenPoolPda:s[0],tokenProgram:i,cpiAuthorityPda:this.deriveCpiAuthorityPda,systemProgram:t.SystemProgram.programId});return new t.TransactionInstruction({programId:this.programId,keys:a,data:ae})}static async addTokenPool({feePayer:e,mint:r,poolIndex:o,tokenProgramId:i}){if(o<=0)throw new Error("Pool index must be greater than 0. For 0, use CreateTokenPool instead.");if(o>3)throw new Error(`Invalid poolIndex ${o}. Max 4 pools per mint.`);const s=null!=i?i:n.TOKEN_PROGRAM_ID,a=this.deriveSplInterfacePdaWithIndex(r,o-1),u=this.deriveSplInterfacePdaWithIndex(r,o),c=je({mint:r,feePayer:e,tokenPoolPda:u[0],existingTokenPoolPda:a[0],tokenProgram:s,cpiAuthorityPda:this.deriveCpiAuthorityPda,systemProgram:t.SystemProgram.programId});return new t.TransactionInstruction({programId:this.programId,keys:c,data:w.concat([new Uint8Array(he),new Uint8Array(w.from([o]))])})}static async mintTo({feePayer:n,mint:r,authority:o,toPubkey:i,amount:s,outputStateTreeInfo:a,tokenPoolInfo:u}){const c=e.defaultStaticAccountsStruct(),l=u.tokenProgram;we(u,r);const d=e.toArray(s).map((t=>e.bn(t))),p=e.toArray(i);if(d.length!==p.length)throw new Error("Amount and toPubkey arrays must have the same length");const m=$e({mint:r,feePayer:n,authority:o,cpiAuthorityPda:this.deriveCpiAuthorityPda,tokenProgram:l,tokenPoolPda:it(u),lightSystemProgram:e.LightSystemProgram.programId,registeredProgramPda:c.registeredProgramPda,noopProgram:c.noopProgram,accountCompressionAuthority:c.accountCompressionAuthority,accountCompressionProgram:c.accountCompressionProgram,merkleTree:a.treeType===e.TreeType.StateV2?a.queue:a.tree,selfProgram:this.programId,systemProgram:t.SystemProgram.programId,solPoolPda:null}),h=qe({recipients:p,amounts:d,lamports:null});return new t.TransactionInstruction({programId:this.programId,keys:m,data:h})}static async approveAndMintTo({feePayer:e,mint:t,authority:r,authorityTokenAccount:o,toPubkey:i,amount:s,outputStateTreeInfo:a,tokenPoolInfo:u}){const c=BigInt(s.toString());return[n.createMintToInstruction(t,o,r,c,[],u.tokenProgram),await this.compress({payer:e,owner:r,source:o,toAddress:i,mint:t,amount:s,outputStateTreeInfo:a,tokenPoolInfo:u})]}static async transfer({payer:n,inputCompressedTokenAccounts:r,toAddress:o,amount:i,recentValidityProof:s,recentInputStateRootIndices:a}){const u=lt(r,o,i),{inputTokenDataWithContext:c,packedOutputTokenData:l,remainingAccountMetas:d}=Ee({inputCompressedTokenAccounts:r,rootIndices:a,tokenTransferOutputs:u}),{mint:p}=ut(r),{delegatedTransfer:m,authority:h}=ct(r,u),f=Fe({proof:s,mint:p,delegatedTransfer:m,inputTokenDataWithContext:c,outputCompressedAccounts:l,compressOrDecompressAmount:null,isCompress:0,cpiContext:null,lamportsChangeAccountMerkleTreeIndex:null}),{accountCompressionAuthority:g,noopProgram:y,registeredProgramPda:b,accountCompressionProgram:w}=e.defaultStaticAccountsStruct(),I=Ye({feePayer:n,authority:h,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:e.LightSystemProgram.programId,registeredProgramPda:b,noopProgram:y,accountCompressionAuthority:g,accountCompressionProgram:w,selfProgram:this.programId,tokenPoolPda:void 0,compressOrDecompressTokenAccount:void 0,tokenProgram:void 0,systemProgram:t.SystemProgram.programId});return I.push(...d),new t.TransactionInstruction({programId:this.programId,keys:I,data:f})}static async createTokenProgramLookupTable({payer:r,authority:o,mints:i,recentSlot:s,remainingAccounts:a}){const[u,c]=t.AddressLookupTableProgram.createLookupTable({authority:o,payer:o,recentSlot:s});let l=[];i&&(l=[...i,...i.map((e=>this.deriveSplInterfacePda(e)))]);const d=[u,t.AddressLookupTableProgram.extendLookupTable({payer:r,authority:o,lookupTable:c,addresses:[t.SystemProgram.programId,t.ComputeBudgetProgram.programId,this.deriveCpiAuthorityPda,e.LightSystemProgram.programId,pt.programId,e.defaultStaticAccountsStruct().registeredProgramPda,e.defaultStaticAccountsStruct().noopProgram,e.defaultStaticAccountsStruct().accountCompressionAuthority,e.defaultStaticAccountsStruct().accountCompressionProgram,e.defaultTestStateTreeAccounts().merkleTree,e.defaultTestStateTreeAccounts().nullifierQueue,e.defaultTestStateTreeAccounts().addressTree,e.defaultTestStateTreeAccounts().addressQueue,this.programId,n.TOKEN_PROGRAM_ID,n.TOKEN_2022_PROGRAM_ID,o,...l]})];if(a&&a.length>0)for(let e=0;e<a.length;e+=25){const n=a.slice(e,e+25),i=t.AddressLookupTableProgram.extendLookupTable({payer:r,authority:o,lookupTable:c,addresses:n});d.push(i)}return{instructions:d,address:c}}static async compress({payer:n,owner:r,source:o,toAddress:i,amount:s,mint:a,outputStateTreeInfo:u,tokenPoolInfo:c}){let l;const d=e.toArray(s),p=e.toArray(i);if(we(c,a),d.length!==p.length)throw new Error("Amount and toAddress arrays must have the same length");if(e.featureFlags.isV2()){const[i,s]=this.findSplInterfaceIndexAndBump(it(c),a),l=Ge({pubkeys:p,amounts:d.length>1?d.map((t=>e.bn(t))):null,lamports:null,amount:1===d.length?e.bn(d[0]):null,index:i,bump:s}),m=$e(Object.assign(Object.assign({mint:a,feePayer:n,authority:r,cpiAuthorityPda:this.deriveCpiAuthorityPda,tokenProgram:c.tokenProgram,tokenPoolPda:it(c),lightSystemProgram:e.LightSystemProgram.programId},e.defaultStaticAccountsStruct()),{merkleTree:u.queue,selfProgram:this.programId,systemProgram:t.SystemProgram.programId,solPoolPda:null}));return m.push({pubkey:o,isWritable:1,isSigner:0}),new t.TransactionInstruction({programId:this.programId,keys:m,data:l})}{l=d.map(((t,n)=>{const r=e.bn(t);return{owner:p[n],amount:r,lamports:null,tlv:null}}));const{inputTokenDataWithContext:i,packedOutputTokenData:m,remainingAccountMetas:h}=Ee({inputCompressedTokenAccounts:[],outputStateTreeInfo:u,rootIndices:[],tokenTransferOutputs:l}),f=Fe({proof:null,mint:a,delegatedTransfer:null,inputTokenDataWithContext:i,outputCompressedAccounts:m,compressOrDecompressAmount:Array.isArray(s)?s.map((t=>e.bn(t))).reduce(((e,t)=>e.add(t)),e.bn(0)):e.bn(s),isCompress:1,cpiContext:null,lamportsChangeAccountMerkleTreeIndex:null}),g=Ye(Object.assign(Object.assign({},e.defaultStaticAccountsStruct()),{feePayer:n,authority:r,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:e.LightSystemProgram.programId,selfProgram:this.programId,systemProgram:t.SystemProgram.programId,tokenPoolPda:it(c),compressOrDecompressTokenAccount:o,tokenProgram:c.tokenProgram}));return g.push(...h),new t.TransactionInstruction({programId:this.programId,keys:g,data:f})}}static async decompress({payer:n,inputCompressedTokenAccounts:r,toAddress:o,amount:i,recentValidityProof:s,recentInputStateRootIndices:a,tokenPoolInfos:u}){const c=e.bn(i),l=e.toArray(u),d=dt(r,c),{inputTokenDataWithContext:p,packedOutputTokenData:m,remainingAccountMetas:h}=Ee({inputCompressedTokenAccounts:r,rootIndices:a,tokenTransferOutputs:d,remainingAccounts:l.slice(1).map((e=>it(e)))}),{mint:f}=ut(r),{delegatedTransfer:g,authority:y}=ct(r,d),b=Fe({proof:s,mint:f,delegatedTransfer:g,inputTokenDataWithContext:p,outputCompressedAccounts:m,compressOrDecompressAmount:c,isCompress:0,cpiContext:null,lamportsChangeAccountMerkleTreeIndex:null}),w=l[0].tokenProgram,{accountCompressionAuthority:I,noopProgram:A,registeredProgramPda:k,accountCompressionProgram:v}=e.defaultStaticAccountsStruct(),M=Ye({feePayer:n,authority:y,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:e.LightSystemProgram.programId,registeredProgramPda:k,noopProgram:A,accountCompressionAuthority:I,accountCompressionProgram:v,selfProgram:this.programId,tokenPoolPda:it(l[0]),compressOrDecompressTokenAccount:o,tokenProgram:w,systemProgram:t.SystemProgram.programId});return M.push(...h),new t.TransactionInstruction({programId:this.programId,keys:M,data:b})}static async mergeTokenAccounts({payer:t,owner:n,inputCompressedTokenAccounts:r,mint:o,recentValidityProof:i,recentInputStateRootIndices:s}){const a=e.featureFlags.isV2()?8:4;if(r.length>a)throw new Error(`Cannot merge more than ${a} token accounts at once`);return _e(r,o),[await this.transfer({payer:t,inputCompressedTokenAccounts:r,toAddress:n,amount:r.reduce(((e,t)=>e.add(t.parsed.amount)),e.bn(0)),recentInputStateRootIndices:s,recentValidityProof:i})]}static async compressSplTokenAccount({feePayer:n,authority:r,tokenAccount:o,mint:i,remainingAmount:s,outputStateTreeInfo:a,tokenPoolInfo:u}){we(u,i);const c=[{pubkey:a.treeType===e.TreeType.StateV2?a.queue:a.tree,isSigner:0,isWritable:1}],l=Ve({owner:r,remainingAmount:null!=s?s:null,cpiContext:null}),{accountCompressionAuthority:d,noopProgram:p,registeredProgramPda:m,accountCompressionProgram:h}=e.defaultStaticAccountsStruct(),f=Ye({feePayer:n,authority:r,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:e.LightSystemProgram.programId,registeredProgramPda:m,noopProgram:p,accountCompressionAuthority:d,accountCompressionProgram:h,selfProgram:this.programId,tokenPoolPda:it(u),compressOrDecompressTokenAccount:o,tokenProgram:u.tokenProgram,systemProgram:t.SystemProgram.programId});return f.push(...c),new t.TransactionInstruction({programId:this.programId,keys:f,data:l})}static async getMintProgramId(e,t){var n;return null===(n=await t.getAccountInfo(e))||void 0===n?void 0:n.owner}static async approve({payer:n,inputCompressedTokenAccounts:r,toAddress:o,amount:i,recentValidityProof:s,recentInputStateRootIndices:a}){const{inputTokenDataWithContext:u,remainingAccountMetas:c}=Ee({inputCompressedTokenAccounts:r,rootIndices:a,tokenTransferOutputs:[]}),{mint:l,currentOwner:d}=ut(r),p=r[0].compressedAccount.treeInfo.treeType===e.TreeType.StateV2?1:0,m=rt({proof:s,mint:l,inputTokenDataWithContext:u,cpiContext:null,delegate:o,delegatedAmount:e.bn(i),delegateMerkleTreeIndex:p,changeAccountMerkleTreeIndex:p,delegateLamports:null}),{accountCompressionAuthority:h,noopProgram:f,registeredProgramPda:g,accountCompressionProgram:y}=e.defaultStaticAccountsStruct(),b=Ze({feePayer:n,authority:d,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:e.LightSystemProgram.programId,registeredProgramPda:g,noopProgram:f,accountCompressionAuthority:h,accountCompressionProgram:y,selfProgram:this.programId,systemProgram:t.SystemProgram.programId});return b.push(...c),new t.TransactionInstruction({programId:this.programId,keys:b,data:m})}static async revoke({payer:n,inputCompressedTokenAccounts:r,recentValidityProof:o,recentInputStateRootIndices:i}){at(r);const{inputTokenDataWithContext:s,remainingAccountMetas:a}=Ee({inputCompressedTokenAccounts:r,rootIndices:i,tokenTransferOutputs:[]}),{mint:u,currentOwner:c}=ut(r),l=ot({proof:o,mint:u,inputTokenDataWithContext:s,cpiContext:null,outputAccountMerkleTreeIndex:r[0].compressedAccount.treeInfo.treeType===e.TreeType.StateV2?2:1}),{accountCompressionAuthority:d,noopProgram:p,registeredProgramPda:m,accountCompressionProgram:h}=e.defaultStaticAccountsStruct(),f=He({feePayer:n,authority:c,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:e.LightSystemProgram.programId,registeredProgramPda:m,noopProgram:p,accountCompressionAuthority:d,accountCompressionProgram:h,selfProgram:this.programId,systemProgram:t.SystemProgram.programId});return f.push(...a),new t.TransactionInstruction({programId:this.programId,keys:f,data:l})}}function mt(t,n){const r=e.deriveAddressV2(ft(t)[0].toBytes(),n.tree,e.CTOKEN_PROGRAM_ID);return Array.from(r.toBytes())}pt.programId=new t.PublicKey("cTokenmWW8bLPjZEBAUgYy3zKxQZW6VKi7bqNFEVv3m");const ht=w.from([99,111,109,112,114,101,115,115,101,100,95,109,105,110,116]);function ft(n){const[r,o]=t.PublicKey.findProgramAddressSync([ht,n.toBuffer()],e.CTOKEN_PROGRAM_ID);return[r,o]}const gt=w.from([103]),yt=r.struct([r.publicKey("recipient"),r.u64("amount")]),bt=r.struct([r.u8("tokenAccountVersion"),r.vec(yt,"recipients")]),wt=r.struct([r.option(r.publicKey(),"newAuthority")]),It=r.struct([r.u8("mintBump")]),At=r.struct([r.u8("accountIndex"),r.u64("amount")]),kt=r.struct([r.u8("extensionIndex"),r.u8("fieldType"),r.vecU8("key"),r.vecU8("value")]),vt=r.struct([r.u8("extensionIndex"),r.publicKey("newAuthority")]),Mt=r.struct([r.u8("extensionIndex"),r.vecU8("key"),r.u8("idempotent")]),Pt=r.struct([r.u8("cmintBump"),r.u8("rentPayment"),r.u32("writeTopUp")]),xt=r.struct([r.u8("idempotent")]),Tt=r.rustEnum([bt.replicate("mintToCompressed"),wt.replicate("updateMintAuthority"),wt.replicate("updateFreezeAuthority"),It.replicate("createSplMint"),At.replicate("mintToCToken"),kt.replicate("updateMetadataField"),vt.replicate("updateMetadataAuthority"),Mt.replicate("removeMetadataKey"),Pt.replicate("decompressMint"),xt.replicate("compressAndCloseCMint")]),St=r.struct([r.array(r.u8(),32,"a"),r.array(r.u8(),64,"b"),r.array(r.u8(),32,"c")]),Ct=r.struct([r.bool("setContext"),r.bool("firstSetContext"),r.u8("inTreeIndex"),r.u8("inQueueIndex"),r.u8("outQueueIndex"),r.u8("tokenOutQueueIndex"),r.u8("assignedAccountIndex"),r.array(r.u8(),4,"readOnlyAddressTrees"),r.array(r.u8(),32,"addressTreePubkey")]),Et=r.struct([r.array(r.u8(),4,"readOnlyAddressTrees"),r.array(r.u16(),4,"readOnlyAddressTreeRootIndices")]),_t=r.struct([r.vecU8("key"),r.vecU8("value")]),Ot=r.struct([r.option(r.publicKey(),"updateAuthority"),r.vecU8("name"),r.vecU8("symbol"),r.vecU8("uri"),r.option(r.vec(_t),"additionalMetadata")]),Rt=r.struct([]),Dt=r.rustEnum([Rt.replicate("placeholder0"),Rt.replicate("placeholder1"),Rt.replicate("placeholder2"),Rt.replicate("placeholder3"),Rt.replicate("placeholder4"),Rt.replicate("placeholder5"),Rt.replicate("placeholder6"),Rt.replicate("placeholder7"),Rt.replicate("placeholder8"),Rt.replicate("placeholder9"),Rt.replicate("placeholder10"),Rt.replicate("placeholder11"),Rt.replicate("placeholder12"),Rt.replicate("placeholder13"),Rt.replicate("placeholder14"),Rt.replicate("placeholder15"),Rt.replicate("placeholder16"),Rt.replicate("placeholder17"),Rt.replicate("placeholder18"),Ot.replicate("tokenMetadata")]),Bt=r.struct([r.u8("version"),r.bool("cmintDecompressed"),r.publicKey("mint")]),Kt=r.struct([r.u64("supply"),r.u8("decimals"),Bt.replicate("metadata"),r.option(r.publicKey(),"mintAuthority"),r.option(r.publicKey(),"freezeAuthority"),r.option(r.vec(Dt),"extensions")]),Lt=r.struct([r.u32("leafIndex"),r.bool("proveByIndex"),r.u16("rootIndex"),r.array(r.u8(),32,"compressedAddress"),r.u8("tokenPoolBump"),r.u8("tokenPoolIndex"),r.u16("maxTopUp"),r.option(Et,"createMint"),r.vec(Tt,"actions"),r.option(St,"proof"),r.option(Ct,"cpiContext"),r.option(Kt,"mint")]);function Nt(t){const n=Object.assign(Object.assign({},t),{mint:t.mint?Object.assign(Object.assign({},t.mint),{supply:e.bn(t.mint.supply.toString())}):null,actions:t.actions.map((t=>"mintToCompressed"in t&&t.mintToCompressed?{mintToCompressed:Object.assign(Object.assign({},t.mintToCompressed),{recipients:t.mintToCompressed.recipients.map((t=>Object.assign(Object.assign({},t),{amount:e.bn(t.amount.toString())})))})}:"mintToCToken"in t&&t.mintToCToken?{mintToCToken:Object.assign(Object.assign({},t.mintToCToken),{amount:e.bn(t.mintToCToken.amount.toString())})}:t))}),r=w.alloc(1e4),o=Lt.encode(n,r);return w.concat([gt,r.subarray(0,o)])}function Ut(n,r,o,i,s,a,u,c,l){const d=function(t){var n;const[r]=ft(t.mintSigner),o=e.deriveAddressV2(r.toBytes(),t.addressTree,e.CTOKEN_PROGRAM_ID);let i=null;t.metadata&&(i=[{tokenMetadata:{updateAuthority:null!==(n=t.metadata.updateAuthority)&&void 0!==n?n:null,name:w.from(t.metadata.name),symbol:w.from(t.metadata.symbol),uri:w.from(t.metadata.uri),additionalMetadata:t.metadata.additionalMetadata}}]);const s=function(e){if(!e)return null;if(32!==e.a.length)throw new Error(`Invalid proof.a length: expected 32, got ${e.a.length}`);if(64!==e.b.length)throw new Error(`Invalid proof.b length: expected 64, got ${e.b.length}`);if(32!==e.c.length)throw new Error(`Invalid proof.c length: expected 32, got ${e.c.length}`);return e}(t.proof);return Nt({leafIndex:0,proveByIndex:0,rootIndex:t.rootIndex,compressedAddress:Array.from(o.toBytes()),tokenPoolBump:0,tokenPoolIndex:0,maxTopUp:0,createMint:{readOnlyAddressTrees:[0,0,0,0],readOnlyAddressTreeRootIndices:[0,0,0,0]},actions:[],proof:s,cpiContext:null,mint:{supply:BigInt(0),decimals:t.decimals,metadata:{version:exports.TokenDataVersion.ShaFlat,cmintDecompressed:0,mint:r},mintAuthority:t.mintAuthority,freezeAuthority:t.freezeAuthority,extensions:i}})}({mintSigner:n,mintAuthority:o,freezeAuthority:i,decimals:r,addressTree:u.tree,outputQueue:c.queue,rootIndex:a.rootIndices[0],proof:a.compressedProof,metadata:l}),p=e.defaultStaticAccountsStruct(),m=[{pubkey:e.LightSystemProgram.programId,isSigner:0,isWritable:0},{pubkey:n,isSigner:1,isWritable:0},{pubkey:o,isSigner:1,isWritable:0},{pubkey:s,isSigner:1,isWritable:1},{pubkey:pt.deriveCpiAuthorityPda,isSigner:0,isWritable:0},{pubkey:p.registeredProgramPda,isSigner:0,isWritable:0},{pubkey:p.accountCompressionAuthority,isSigner:0,isWritable:0},{pubkey:p.accountCompressionProgram,isSigner:0,isWritable:0},{pubkey:t.SystemProgram.programId,isSigner:0,isWritable:0},{pubkey:c.queue,isSigner:0,isWritable:1},{pubkey:u.tree,isSigner:0,isWritable:1}];return new t.TransactionInstruction({programId:e.CTOKEN_PROGRAM_ID,keys:m,data:d})}function Wt(t){var n;const r=e.deriveAddressV2(t.splMint.toBytes(),t.addressTree,e.CTOKEN_PROGRAM_ID),o="mintAuthority"===t.actionType?{updateMintAuthority:{newAuthority:t.newAuthority}}:{updateFreezeAuthority:{newAuthority:t.newAuthority}};let i=null;return t.mintInterface.tokenMetadata&&(i=[{tokenMetadata:{updateAuthority:null!==(n=t.mintInterface.tokenMetadata.updateAuthority)&&void 0!==n?n:null,name:w.from(t.mintInterface.tokenMetadata.name),symbol:w.from(t.mintInterface.tokenMetadata.symbol),uri:w.from(t.mintInterface.tokenMetadata.uri),additionalMetadata:null}}]),Nt({leafIndex:t.leafIndex,proveByIndex:t.proveByIndex,rootIndex:t.rootIndex,compressedAddress:Array.from(r.toBytes()),tokenPoolBump:0,tokenPoolIndex:0,maxTopUp:0,createMint:null,actions:[o],proof:t.proof,cpiContext:null,mint:{supply:t.mintInterface.mint.supply,decimals:t.mintInterface.mint.decimals,metadata:{version:t.mintInterface.mintContext.version,cmintDecompressed:t.mintInterface.mintContext.cmintDecompressed,mint:t.mintInterface.mintContext.splMint},mintAuthority:t.mintInterface.mint.mintAuthority,freezeAuthority:t.mintInterface.mint.freezeAuthority,extensions:i}})}function qt(n,r,o,i,s){if(!n.merkleContext)throw new Error("MintInterface must have merkleContext for compressed mint operations");if(!n.mintContext)throw new Error("MintInterface must have mintContext for compressed mint operations");const a=n.merkleContext,u=e.getOutputQueue(a),c=e.getDefaultAddressTreeInfo(),l=Wt({splMint:n.mintContext.splMint,addressTree:c.tree,leafIndex:a.leafIndex,proveByIndex:1,rootIndex:s.rootIndices[0],proof:s.compressedProof,mintInterface:n,newAuthority:o,actionType:"mintAuthority"}),d=e.defaultStaticAccountsStruct(),p=[{pubkey:e.LightSystemProgram.programId,isSigner:0,isWritable:0},{pubkey:r,isSigner:1,isWritable:0},{pubkey:i,isSigner:1,isWritable:1},{pubkey:pt.deriveCpiAuthorityPda,isSigner:0,isWritable:0},{pubkey:d.registeredProgramPda,isSigner:0,isWritable:0},{pubkey:d.accountCompressionAuthority,isSigner:0,isWritable:0},{pubkey:d.accountCompressionProgram,isSigner:0,isWritable:0},{pubkey:t.SystemProgram.programId,isSigner:0,isWritable:0},{pubkey:u,isSigner:0,isWritable:1},{pubkey:a.treeInfo.tree,isSigner:0,isWritable:1},{pubkey:a.treeInfo.queue,isSigner:0,isWritable:1}];return new t.TransactionInstruction({programId:e.CTOKEN_PROGRAM_ID,keys:p,data:l})}function Gt(n,r,o,i,s){if(!n.merkleContext)throw new Error("MintInterface must have merkleContext for compressed mint operations");if(!n.mintContext)throw new Error("MintInterface must have mintContext for compressed mint operations");const a=n.merkleContext,u=e.getOutputQueue(a),c=e.getDefaultAddressTreeInfo(),l=Wt({splMint:n.mintContext.splMint,addressTree:c.tree,leafIndex:a.leafIndex,proveByIndex:1,rootIndex:s.rootIndices[0],proof:s.compressedProof,mintInterface:n,newAuthority:o,actionType:"freezeAuthority"}),d=e.defaultStaticAccountsStruct(),p=[{pubkey:e.LightSystemProgram.programId,isSigner:0,isWritable:0},{pubkey:r,isSigner:1,isWritable:0},{pubkey:i,isSigner:1,isWritable:1},{pubkey:pt.deriveCpiAuthorityPda,isSigner:0,isWritable:0},{pubkey:d.registeredProgramPda,isSigner:0,isWritable:0},{pubkey:d.accountCompressionAuthority,isSigner:0,isWritable:0},{pubkey:d.accountCompressionProgram,isSigner:0,isWritable:0},{pubkey:t.SystemProgram.programId,isSigner:0,isWritable:0},{pubkey:u,isSigner:0,isWritable:1},{pubkey:a.treeInfo.tree,isSigner:0,isWritable:1},{pubkey:a.treeInfo.queue,isSigner:0,isWritable:1}];return new t.TransactionInstruction({programId:e.CTOKEN_PROGRAM_ID,keys:p,data:l})}function Vt(n,r,o,i,s){if(!n.merkleContext)throw new Error("MintInterface must have merkleContext for compressed mint operations");if(!n.mintContext)throw new Error("MintInterface must have mintContext for compressed mint operations");if(!n.tokenMetadata)throw new Error("MintInterface must have tokenMetadata for metadata operations");const a=n.merkleContext,u=e.getOutputQueue(a),c=e.getDefaultAddressTreeInfo(),l=function(t){var n;const r=e.deriveAddressV2(t.splMint.toBytes(),t.addressTree,e.CTOKEN_PROGRAM_ID),o=t.mintInterface;if(!o.tokenMetadata)throw new Error("MintInterface must have tokenMetadata for metadata operations");var i;return Nt({leafIndex:t.leafIndex,proveByIndex:null===t.proof,rootIndex:t.rootIndex,compressedAddress:Array.from(r.toBytes()),tokenPoolBump:0,tokenPoolIndex:0,maxTopUp:0,createMint:null,actions:[(i=t.action,"updateField"===i.type?{updateMetadataField:{extensionIndex:i.extensionIndex,fieldType:i.fieldType,key:w.from(i.key),value:w.from(i.value)}}:"updateAuthority"===i.type?{updateMetadataAuthority:{extensionIndex:i.extensionIndex,newAuthority:i.newAuthority}}:{removeMetadataKey:{extensionIndex:i.extensionIndex,key:w.from(i.key),idempotent:i.idempotent?1:0}})],proof:t.proof,cpiContext:null,mint:{supply:o.mint.supply,decimals:o.mint.decimals,metadata:{version:o.mintContext.version,cmintDecompressed:o.mintContext.cmintDecompressed,mint:o.mintContext.splMint},mintAuthority:o.mint.mintAuthority,freezeAuthority:o.mint.freezeAuthority,extensions:[{tokenMetadata:{updateAuthority:null!==(n=o.tokenMetadata.updateAuthority)&&void 0!==n?n:null,name:w.from(o.tokenMetadata.name),symbol:w.from(o.tokenMetadata.symbol),uri:w.from(o.tokenMetadata.uri),additionalMetadata:null}}]}})}({splMint:n.mintContext.splMint,addressTree:c.tree,leafIndex:a.leafIndex,rootIndex:i.rootIndices[0],proof:i.compressedProof,mintInterface:n,action:s}),d=e.defaultStaticAccountsStruct(),p=[{pubkey:e.LightSystemProgram.programId,isSigner:0,isWritable:0},{pubkey:r,isSigner:1,isWritable:0},{pubkey:o,isSigner:1,isWritable:1},{pubkey:pt.deriveCpiAuthorityPda,isSigner:0,isWritable:0},{pubkey:d.registeredProgramPda,isSigner:0,isWritable:0},{pubkey:d.accountCompressionAuthority,isSigner:0,isWritable:0},{pubkey:d.accountCompressionProgram,isSigner:0,isWritable:0},{pubkey:t.SystemProgram.programId,isSigner:0,isWritable:0},{pubkey:u,isSigner:0,isWritable:1},{pubkey:a.treeInfo.tree,isSigner:0,isWritable:1},{pubkey:a.treeInfo.queue,isSigner:0,isWritable:1}];return new t.TransactionInstruction({programId:e.CTOKEN_PROGRAM_ID,keys:p,data:l})}function Ft(e,t,n,r,o,i,s,a=0){return Vt(e,t,n,r,{type:"updateField",extensionIndex:a,fieldType:"name"===o?0:"symbol"===o?1:"uri"===o?2:3,key:s||"",value:i})}function zt(e,t,n,r,o,i=0){return Vt(e,t,r,o,{type:"updateAuthority",extensionIndex:i,newAuthority:n})}function jt(e,t,n,r,o,i=0,s=0){return Vt(e,t,n,r,{type:"removeKey",extensionIndex:s,key:o,idempotent:i})}const $t=w.from([100]),Yt=w.from([102]),Zt=r.struct([r.u8("bump"),r.array(r.u8(),32,"programId"),r.vec(r.vec(r.u8()),"seeds")]),Ht=r.struct([r.u8("tokenAccountVersion"),r.u8("rentPayment"),r.u8("hasTopUp"),r.u8("compressionOnly"),r.u32("writeTopUp"),r.option(Zt,"compressToAccountPubkey")]),Qt=r.struct([r.u8("bump"),r.option(Ht,"compressibleConfig")]);function Jt(n,r){return t.PublicKey.findProgramAddressSync([n.toBuffer(),e.CTOKEN_PROGRAM_ID.toBuffer(),r.toBuffer()],e.CTOKEN_PROGRAM_ID)}function Xt(e,t){const n=w.alloc(2e3),r=Qt.encode({bump:e.bump,compressibleConfig:e.compressibleConfig||null},n),o=t?Yt:$t;return w.concat([o,n.subarray(0,r)])}function en(n,r,o,i,s,a){const[u,c]=Jt(r,o),l=Xt({bump:c,compressibleConfig:i},0),d=[{pubkey:r,isSigner:0,isWritable:0},{pubkey:o,isSigner:0,isWritable:0},{pubkey:n,isSigner:1,isWritable:1},{pubkey:u,isSigner:0,isWritable:1},{pubkey:t.SystemProgram.programId,isSigner:0,isWritable:0}];return i&&s&&a&&d.push({pubkey:s,isSigner:0,isWritable:0},{pubkey:a,isSigner:0,isWritable:1}),new t.TransactionInstruction({programId:e.CTOKEN_PROGRAM_ID,keys:d,data:l})}function tn(n,r,o,i,s,a){const[u,c]=Jt(r,o),l=Xt({bump:c,compressibleConfig:i},1),d=[{pubkey:r,isSigner:0,isWritable:0},{pubkey:o,isSigner:0,isWritable:0},{pubkey:n,isSigner:1,isWritable:1},{pubkey:u,isSigner:0,isWritable:1},{pubkey:t.SystemProgram.programId,isSigner:0,isWritable:0}];return i&&s&&a&&d.push({pubkey:s,isSigner:0,isWritable:0},{pubkey:a,isSigner:0,isWritable:1}),new t.TransactionInstruction({programId:e.CTOKEN_PROGRAM_ID,keys:d,data:l})}function nn(t){return t.equals(e.CTOKEN_PROGRAM_ID)?e.CTOKEN_PROGRAM_ID:n.ASSOCIATED_TOKEN_PROGRAM_ID}function rn(t,r,o,i,s=0){if(i){const e=n.getAssociatedTokenAddressSync(r,o,s,i,nn(i));if(t.equals(e))return{valid:1,type:on(i),programId:i};throw new Error(`ATA address mismatch for ${i.toBase58()}. Expected: ${e.toBase58()}, got: ${t.toBase58()}`)}let a,u,c;if(a=n.getAssociatedTokenAddressSync(r,o,s,e.CTOKEN_PROGRAM_ID,nn(e.CTOKEN_PROGRAM_ID)),t.equals(a))return{valid:1,type:"ctoken",programId:e.CTOKEN_PROGRAM_ID};if(u=n.getAssociatedTokenAddressSync(r,o,s,n.TOKEN_PROGRAM_ID,nn(n.TOKEN_PROGRAM_ID)),t.equals(u))return{valid:1,type:"spl",programId:n.TOKEN_PROGRAM_ID};if(c=n.getAssociatedTokenAddressSync(r,o,s,n.TOKEN_2022_PROGRAM_ID,nn(n.TOKEN_2022_PROGRAM_ID)),t.equals(c))return{valid:1,type:"token2022",programId:n.TOKEN_2022_PROGRAM_ID};throw new Error(`ATA address does not match any valid derivation from mint+owner. Got: ${t.toBase58()}, expected one of: c-token=${a.toBase58()}, SPL=${u.toBase58()}, T22=${c.toBase58()}`)}function on(t){if(t.equals(e.CTOKEN_PROGRAM_ID))return"ctoken";if(t.equals(n.TOKEN_PROGRAM_ID))return"spl";if(t.equals(n.TOKEN_2022_PROGRAM_ID))return"token2022";throw new Error(`Unknown program ID: ${t.toBase58()}`)}function sn(t,r,o,i,s=n.TOKEN_PROGRAM_ID,a,u){const c=null!=a?a:nn(s);return s.equals(e.CTOKEN_PROGRAM_ID)?en(t,o,i,null==u?void 0:u.compressibleConfig,null==u?void 0:u.configAccount,null==u?void 0:u.rentPayerPda):n.createAssociatedTokenAccountInstruction(t,r,o,i,s,c)}function an(t,r,o,i,s=n.TOKEN_PROGRAM_ID,a,u){const c=null!=a?a:nn(s);return s.equals(e.CTOKEN_PROGRAM_ID)?tn(t,o,i,null==u?void 0:u.compressibleConfig,null==u?void 0:u.configAccount,null==u?void 0:u.rentPayerPda):n.createAssociatedTokenAccountIdempotentInstruction(t,r,o,i,s,c)}const un=an;function cn(n,r,o,i,s,a,u,c){const l=function(t){const n=e.deriveAddressV2(t.mintData.splMint.toBytes(),t.addressTree,e.CTOKEN_PROGRAM_ID);if(t.mintData.metadata)throw new Error("TokenMetadata extension not supported in mintTo instruction");return Nt({leafIndex:t.leafIndex,proveByIndex:1,rootIndex:t.rootIndex,compressedAddress:Array.from(n.toBytes()),tokenPoolBump:0,tokenPoolIndex:0,maxTopUp:0,createMint:null,actions:[{mintToCToken:{accountIndex:t.recipientAccountIndex,amount:BigInt(t.amount.toString())}}],proof:t.proof,cpiContext:null,mint:{supply:t.mintData.supply,decimals:t.mintData.decimals,metadata:{version:t.mintData.version,cmintDecompressed:t.mintData.cmintDecompressed,mint:t.mintData.splMint},mintAuthority:t.mintData.mintAuthority,freezeAuthority:t.mintData.freezeAuthority,extensions:null}})}({addressTree:e.getDefaultAddressTreeInfo().tree,leafIndex:i.leafIndex,rootIndex:o.rootIndices[0],proof:o.compressedProof,mintData:s,recipientAccountIndex:0,amount:c}),d=e.defaultStaticAccountsStruct(),p=[{pubkey:e.LightSystemProgram.programId,isSigner:0,isWritable:0},{pubkey:n,isSigner:1,isWritable:0},{pubkey:r,isSigner:1,isWritable:1},{pubkey:pt.deriveCpiAuthorityPda,isSigner:0,isWritable:0},{pubkey:d.registeredProgramPda,isSigner:0,isWritable:0},{pubkey:d.accountCompressionAuthority,isSigner:0,isWritable:0},{pubkey:d.accountCompressionProgram,isSigner:0,isWritable:0},{pubkey:t.SystemProgram.programId,isSigner:0,isWritable:0},{pubkey:a.queue,isSigner:0,isWritable:1},{pubkey:i.treeInfo.tree,isSigner:0,isWritable:1},{pubkey:i.treeInfo.queue,isSigner:0,isWritable:1}];return p.push({pubkey:u,isSigner:0,isWritable:1}),new t.TransactionInstruction({programId:e.CTOKEN_PROGRAM_ID,keys:p,data:l})}function ln(n,r,o,i,s,a,u,c=exports.TokenDataVersion.ShaFlat){var l;const d=function(t){const n=e.deriveAddressV2(t.mintData.splMint.toBytes(),t.addressTree,e.CTOKEN_PROGRAM_ID);if(t.mintData.metadata)throw new Error("TokenMetadata extension not supported in mintTo instruction");return Nt({leafIndex:t.leafIndex,proveByIndex:1,rootIndex:t.rootIndex,compressedAddress:Array.from(n.toBytes()),tokenPoolBump:0,tokenPoolIndex:0,maxTopUp:0,createMint:null,actions:[{mintToCompressed:{tokenAccountVersion:t.tokenAccountVersion,recipients:t.recipients.map((e=>({recipient:e.recipient,amount:BigInt(e.amount.toString())})))}}],proof:t.proof,cpiContext:null,mint:{supply:t.mintData.supply,decimals:t.mintData.decimals,metadata:{version:t.mintData.version,cmintDecompressed:t.mintData.cmintDecompressed,mint:t.mintData.splMint},mintAuthority:t.mintData.mintAuthority,freezeAuthority:t.mintData.freezeAuthority,extensions:null}})}({addressTree:e.getDefaultAddressTreeInfo().tree,leafIndex:i.leafIndex,rootIndex:o.rootIndices[0],proof:o.compressedProof,mintData:s,recipients:a,tokenAccountVersion:c}),p=null!==(l=null==u?void 0:u.queue)&&void 0!==l?l:e.getOutputQueue(i),m=e.defaultStaticAccountsStruct(),h=[{pubkey:e.LightSystemProgram.programId,isSigner:0,isWritable:0},{pubkey:n,isSigner:1,isWritable:0},{pubkey:r,isSigner:1,isWritable:1},{pubkey:pt.deriveCpiAuthorityPda,isSigner:0,isWritable:0},{pubkey:m.registeredProgramPda,isSigner:0,isWritable:0},{pubkey:m.accountCompressionAuthority,isSigner:0,isWritable:0},{pubkey:m.accountCompressionProgram,isSigner:0,isWritable:0},{pubkey:t.SystemProgram.programId,isSigner:0,isWritable:0},{pubkey:p,isSigner:0,isWritable:1},{pubkey:i.treeInfo.tree,isSigner:0,isWritable:1},{pubkey:i.treeInfo.queue,isSigner:0,isWritable:1},{pubkey:p,isSigner:0,isWritable:1}];return new t.TransactionInstruction({programId:e.CTOKEN_PROGRAM_ID,keys:h,data:d})}function dn(t,r,o,i,s,a,u=[]){const c=t.mint.address,l=t.programId;if(!t.merkleContext)return n.createMintToInstruction(c,r,o,BigInt(s.toString()),u,l);if(!a)throw new Error("Validity proof required for c-token mint-to");if(!t.mintContext)throw new Error("mintContext required for c-token mint-to");const d={supply:t.mint.supply,decimals:t.mint.decimals,mintAuthority:t.mint.mintAuthority,freezeAuthority:t.mint.freezeAuthority,splMint:t.mintContext.splMint,cmintDecompressed:t.mintContext.cmintDecompressed,version:t.mintContext.version,metadata:t.tokenMetadata?{updateAuthority:t.tokenMetadata.updateAuthority||null,name:t.tokenMetadata.name,symbol:t.tokenMetadata.symbol,uri:t.tokenMetadata.uri}:void 0};return cn(o,i,a,t.merkleContext,d,e.getOutputTreeInfo(t.merkleContext),r,s)}const pn=3;function mn(n,r,o,i){const s=Buffer.alloc(9);s.writeUInt8(pn,0),s.writeBigUInt64LE(BigInt(i),1);const a=[{pubkey:n,isSigner:0,isWritable:1},{pubkey:r,isSigner:0,isWritable:1},{pubkey:o,isSigner:1,isWritable:1}];return new t.TransactionInstruction({programId:e.CTOKEN_PROGRAM_ID,keys:a,data:s})}function hn(r,o,i,s,a=[],u=e.CTOKEN_PROGRAM_ID){if(u.equals(e.CTOKEN_PROGRAM_ID)){if(a.length>0)throw new Error("c-token transfer does not support multi-signers. Use a single owner.");return mn(r,o,i,s)}if(u.equals(n.TOKEN_PROGRAM_ID)||u.equals(n.TOKEN_2022_PROGRAM_ID))return n.createTransferInstruction(r,o,i,s,a.map((e=>e instanceof t.PublicKey?e:e.publicKey)),u);throw new Error(`Unsupported program ID: ${u.toBase58()}`)}const fn=w.from([101]),gn=0,yn=1,bn=r.struct([r.u8("mode"),r.u64("amount"),r.u8("mint"),r.u8("sourceOrRecipient"),r.u8("authority"),r.u8("poolAccountIndex"),r.u8("poolIndex"),r.u8("bump"),r.u8("decimals")]),wn=r.struct([r.u8("merkleTreePubkeyIndex"),r.u8("queuePubkeyIndex"),r.u32("leafIndex"),r.bool("proveByIndex")]),In=r.struct([r.u8("owner"),r.u64("amount"),r.bool("hasDelegate"),r.u8("delegate"),r.u8("mint"),r.u8("version"),wn.replicate("merkleContext"),r.u16("rootIndex")]),An=r.struct([r.u8("owner"),r.u64("amount"),r.bool("hasDelegate"),r.u8("delegate"),r.u8("mint"),r.u8("version")]),kn=r.struct([r.bool("setContext"),r.bool("firstSetContext"),r.u8("cpiContextAccountIndex")]),vn=r.struct([r.array(r.u8(),32,"a"),r.array(r.u8(),64,"b"),r.array(r.u8(),32,"c")]),Mn=r.struct([r.bool("withTransactionHash"),r.bool("withLamportsChangeAccountMerkleTreeIndex"),r.u8("lamportsChangeAccountMerkleTreeIndex"),r.u8("lamportsChangeAccountOwnerIndex"),r.u8("outputQueue"),r.u16("maxTopUp"),r.option(kn,"cpiContext"),r.option(r.vec(bn),"compressions"),r.option(vn,"proof"),r.vec(In,"inTokenData"),r.vec(An,"outTokenData"),r.option(r.vec(r.u64()),"inLamports"),r.option(r.vec(r.u64()),"outLamports"),r.option(r.vec(r.vec(r.u8())),"inTlv"),r.option(r.vec(r.vec(r.u8())),"outTlv")]);function Pn(t){var n,r,o,i,s,a;const u=Object.assign(Object.assign({},t),{compressions:null!==(r=null===(n=t.compressions)||void 0===n?void 0:n.map((t=>Object.assign(Object.assign({},t),{amount:e.bn(t.amount.toString())}))))&&void 0!==r?r:null,inTokenData:t.inTokenData.map((t=>Object.assign(Object.assign({},t),{amount:e.bn(t.amount.toString())}))),outTokenData:t.outTokenData.map((t=>Object.assign(Object.assign({},t),{amount:e.bn(t.amount.toString())}))),inLamports:null!==(i=null===(o=t.inLamports)||void 0===o?void 0:o.map((t=>e.bn(t.toString()))))&&void 0!==i?i:null,outLamports:null!==(a=null===(s=t.outLamports)||void 0===s?void 0:s.map((t=>e.bn(t.toString()))))&&void 0!==a?a:null}),c=w.alloc(2e3),l=Mn.encode(u,c);return w.concat([fn,c.subarray(0,l)])}function xn(e,t,n,r,o,i,s){return{mode:gn,amount:e,mint:t,sourceOrRecipient:n,authority:r,poolAccountIndex:o,poolIndex:i,bump:s,decimals:0}}function Tn(e,t,n,r){return{mode:yn,amount:e,mint:t,sourceOrRecipient:n,authority:0,poolAccountIndex:r,poolIndex:0,bump:0,decimals:0}}function Sn(e){return!e||e.length<8?exports.TokenDataVersion.ShaFlat:2===e[0]?exports.TokenDataVersion.V1:3===e[7]?exports.TokenDataVersion.V2:exports.TokenDataVersion.ShaFlat}function Cn(n,r,o,i,s,a){var u;if(0===r.length)throw new Error("No input compressed token accounts provided");const c=r[0].parsed.mint,l=r[0].parsed.owner,d=new Map,p=[],m=new Set,h=new Set;for(const e of r)m.add(e.compressedAccount.treeInfo.tree.toBase58()),h.add(e.compressedAccount.treeInfo.queue.toBase58());for(const e of m)d.set(e,p.length),p.push(new t.PublicKey(e));let f=0,g=1;for(const e of h)g&&(f=p.length,g=0),d.set(e,p.length),p.push(new t.PublicKey(e));const y=p.length;d.set(c.toBase58(),y),p.push(c);const b=p.length;d.set(l.toBase58(),b),p.push(l);const w=p.length;d.set(o.toBase58(),w),p.push(o);let I=0,A=0,k=0,v=0;a&&(I=p.length,d.set(a.splInterfacePda.toBase58(),I),p.push(a.splInterfacePda),v=p.length,d.set(a.tokenProgram.toBase58(),v),p.push(a.tokenProgram),A=a.poolIndex,k=a.bump);const M=function(e,t,n){return e.map(((e,r)=>{var o,i;const s=e.parsed.owner.toBase58(),a=e.parsed.mint.toBase58(),u=Sn(null===(o=e.compressedAccount.data)||void 0===o?void 0:o.discriminator);return{owner:n.get(s),amount:BigInt(e.parsed.amount.toString()),hasDelegate:null!==e.parsed.delegate,delegate:e.parsed.delegate&&null!==(i=n.get(e.parsed.delegate.toBase58()))&&void 0!==i?i:0,mint:n.get(a),version:u,merkleContext:{merkleTreePubkeyIndex:n.get(e.compressedAccount.treeInfo.tree.toBase58()),queuePubkeyIndex:n.get(e.compressedAccount.treeInfo.queue.toBase58()),leafIndex:e.compressedAccount.leafIndex,proveByIndex:e.compressedAccount.proveByIndex},rootIndex:t[r]}}))}(r,s.rootIndices,d),P=r.reduce(((e,t)=>e+BigInt(t.parsed.amount.toString())),BigInt(0))-i,x=[];if(P>0){const e=Sn(null===(u=r[0].compressedAccount.data)||void 0===u?void 0:u.discriminator);x.push({owner:b,amount:P,hasDelegate:0,delegate:0,mint:y,version:e})}const T=Pn({withTransactionHash:0,withLamportsChangeAccountMerkleTreeIndex:0,lamportsChangeAccountMerkleTreeIndex:0,lamportsChangeAccountOwnerIndex:0,outputQueue:f,maxTopUp:0,cpiContext:null,compressions:[{mode:yn,amount:i,mint:y,sourceOrRecipient:w,authority:0,poolAccountIndex:a?I:0,poolIndex:a?A:0,bump:a?k:0,decimals:0}],proof:s.compressedProof?{a:Array.from(s.compressedProof.a),b:Array.from(s.compressedProof.b),c:Array.from(s.compressedProof.c)}:null,inTokenData:M,outTokenData:x,inLamports:null,outLamports:null,inTlv:null,outTlv:null}),{accountCompressionAuthority:S,registeredProgramPda:C,accountCompressionProgram:E}=e.defaultStaticAccountsStruct(),_=[{pubkey:e.LightSystemProgram.programId,isSigner:0,isWritable:0},{pubkey:n,isSigner:1,isWritable:1},{pubkey:pt.deriveCpiAuthorityPda,isSigner:0,isWritable:0},{pubkey:C,isSigner:0,isWritable:0},{pubkey:S,isSigner:0,isWritable:0},{pubkey:E,isSigner:0,isWritable:0},{pubkey:t.SystemProgram.programId,isSigner:0,isWritable:0},...p.map(((e,t)=>{const n=t<m.size+h.size,r=e.equals(o),i=void 0!==a&&e.equals(a.splInterfacePda);return{pubkey:e,isSigner:t===b,isWritable:n||r||i}}))];return new t.TransactionInstruction({programId:pt.programId,keys:_,data:T})}var En="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function _n(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function On(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:1}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:1,get:function(){return e[t]}})})),n}var Rn={exports:{}},Dn=On(oe);!function(e,t){function n(e,t){if(!e)throw new Error(t||"Assertion failed")}function r(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}function o(e,t,n){if(o.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(n=t,t=10),this._init(e||0,t||10,n||"be"))}var i;"object"==typeof Rn?Rn.exports=o:t.BN=o,o.BN=o,o.wordSize=26;try{i="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:Dn.Buffer}catch(e){}function s(e,t){var r=e.charCodeAt(t);return r>=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:void n(0,"Invalid character in "+e)}function a(e,t,n){var r=s(e,n);return n-1>=t&&(r|=s(e,n-1)<<4),r}function u(e,t,r,o){for(var i=0,s=0,a=Math.min(e.length,r),u=t;u<a;u++){var c=e.charCodeAt(u)-48;i*=o,s=c>=49?c-49+10:c>=17?c-17+10:c,n(c>=0&&s<o,"Invalid character"),i+=s}return i}function c(e,t){e.words=t.words,e.length=t.length,e.negative=t.negative,e.red=t.red}if(o.isBN=function(e){return e instanceof o?1:null!==e&&"object"==typeof e&&e.constructor.wordSize===o.wordSize&&Array.isArray(e.words)},o.max=function(e,t){return e.cmp(t)>0?e:t},o.min=function(e,t){return e.cmp(t)<0?e:t},o.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var o=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&(o++,this.negative=1),o<e.length&&(16===t?this._parseHex(e,o,r):(this._parseBase(e,t,o),"le"===r&&this._initArray(this.toArray(),t,r)))},o.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(n(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initArray=function(e,t,r){if(n("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var o=0;o<this.length;o++)this.words[o]=0;var i,s,a=0;if("be"===r)for(o=e.length-1,i=0;o>=0;o-=3)s=e[o]|e[o-1]<<8|e[o-2]<<16,this.words[i]|=s<<a&67108863,this.words[i+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,i++);else if("le"===r)for(o=0,i=0;o<e.length;o+=3)s=e[o]|e[o+1]<<8|e[o+2]<<16,this.words[i]|=s<<a&67108863,this.words[i+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,i++);return this._strip()},o.prototype._parseHex=function(e,t,n){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r<this.length;r++)this.words[r]=0;var o,i=0,s=0;if("be"===n)for(r=e.length-1;r>=t;r-=2)o=a(e,t,r)<<i,this.words[s]|=67108863&o,i>=18?(i-=18,s+=1,this.words[s]|=o>>>26):i+=8;else for(r=(e.length-t)%2==0?t+1:t;r<e.length;r+=2)o=a(e,t,r)<<i,this.words[s]|=67108863&o,i>=18?(i-=18,s+=1,this.words[s]|=o>>>26):i+=8;this._strip()},o.prototype._parseBase=function(e,t,n){this.words=[0],this.length=1;for(var r=0,o=1;o<=67108863;o*=t)r++;r--,o=o/t|0;for(var i=e.length-n,s=i%r,a=Math.min(i,i-s)+n,c=0,l=n;l<a;l+=r)c=u(e,l,l+r,t),this.imuln(o),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(0!==s){var d=1;for(c=u(e,l,e.length,t),l=0;l<s;l++)d*=t;this.imuln(d),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}this._strip()},o.prototype.copy=function(e){e.words=new Array(this.length);for(var t=0;t<this.length;t++)e.words[t]=this.words[t];e.length=this.length,e.negative=this.negative,e.red=this.red},o.prototype._move=function(e){c(e,this)},o.prototype.clone=function(){var e=new o(null);return this.copy(e),e},o.prototype._expand=function(e){for(;this.length<e;)this.words[this.length++]=0;return this},o.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{o.prototype[Symbol.for("nodejs.util.inspect.custom")]=l}catch(e){o.prototype.inspect=l}else o.prototype.inspect=l;function l(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var d=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],p=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],m=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function h(e,t,n){n.negative=t.negative^e.negative;var r=e.length+t.length|0;n.length=r,r=r-1|0;var o=0|e.words[0],i=0|t.words[0],s=o*i,a=67108863&s,u=s/67108864|0;n.words[0]=a;for(var c=1;c<r;c++){for(var l=u>>>26,d=67108863&u,p=Math.min(c,t.length-1),m=Math.max(0,c-e.length+1);m<=p;m++){var h=c-m|0;l+=(s=(o=0|e.words[h])*(i=0|t.words[m])+d)/67108864|0,d=67108863&s}n.words[c]=0|d,u=0|l}return 0!==u?n.words[c]=0|u:n.length--,n._strip()}o.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var o=0,i=0,s=0;s<this.length;s++){var a=this.words[s],u=(16777215&(a<<o|i)).toString(16);i=a>>>24-o&16777215,(o+=2)>=26&&(o-=26,s--),r=0!==i||s!==this.length-1?d[6-u.length]+u+r:u+r}for(0!==i&&(r=i.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var c=p[e],l=m[e];r="";var h=this.clone();for(h.negative=0;!h.isZero();){var f=h.modrn(l).toString(e);r=(h=h.idivn(l)).isZero()?f+r:d[c-f.length]+f+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(0,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(0,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},o.prototype.toJSON=function(){return this.toString(16,2)},i&&(o.prototype.toBuffer=function(e,t){return this.toArrayLike(i,e,t)}),o.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},o.prototype.toArrayLike=function(e,t,r){this._strip();var o=this.byteLength(),i=r||Math.max(1,o);n(o<=i,"byte array longer than desired length"),n(i>0,"Requested array length <= 0");var s=function(e,t){return e.allocUnsafe?e.allocUnsafe(t):new e(t)}(e,i);return this["_toArrayLike"+("le"===t?"LE":"BE")](s,o),s},o.prototype._toArrayLikeLE=function(e){for(var t=0,n=0,r=0,o=0;r<this.length;r++){var i=this.words[r]<<o|n;e[t++]=255&i,t<e.length&&(e[t++]=i>>8&255),t<e.length&&(e[t++]=i>>16&255),6===o?(t<e.length&&(e[t++]=i>>24&255),n=0,o=0):(n=i>>>24,o+=2)}if(t<e.length)for(e[t++]=n;t<e.length;)e[t++]=0},o.prototype._toArrayLikeBE=function(e){for(var t=e.length-1,n=0,r=0,o=0;r<this.length;r++){var i=this.words[r]<<o|n;e[t--]=255&i,t>=0&&(e[t--]=i>>8&255),t>=0&&(e[t--]=i>>16&255),6===o?(t>=0&&(e[t--]=i>>24&255),n=0,o=0):(n=i>>>24,o+=2)}if(t>=0)for(e[t--]=n;t>=0;)e[t--]=0},Math.clz32?o.prototype._countBits=function(e){return 32-Math.clz32(e)}:o.prototype._countBits=function(e){var t=e,n=0;return t>=4096&&(n+=13,t>>>=13),t>=64&&(n+=7,t>>>=7),t>=8&&(n+=4,t>>>=4),t>=2&&(n+=2,t>>>=2),n+t},o.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,n=0;return 0==(8191&t)&&(n+=13,t>>>=13),0==(127&t)&&(n+=7,t>>>=7),0==(15&t)&&(n+=4,t>>>=4),0==(3&t)&&(n+=2,t>>>=2),0==(1&t)&&n++,n},o.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;t<this.length;t++){var n=this._zeroBits(this.words[t]);if(e+=n,26!==n)break}return e},o.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},o.prototype.toTwos=function(e){return 0!==this.negative?this.abs().inotn(e).iaddn(1):this.clone()},o.prototype.fromTwos=function(e){return this.testn(e-1)?this.notn(e).iaddn(1).ineg():this.clone()},o.prototype.isNeg=function(){return 0!==this.negative},o.prototype.neg=function(){return this.clone().ineg()},o.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},o.prototype.iuor=function(e){for(;this.length<e.length;)this.words[this.length++]=0;for(var t=0;t<e.length;t++)this.words[t]=this.words[t]|e.words[t];return this._strip()},o.prototype.ior=function(e){return n(0==(this.negative|e.negative)),this.iuor(e)},o.prototype.or=function(e){return this.length>e.length?this.clone().ior(e):e.clone().ior(this)},o.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},o.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var n=0;n<t.length;n++)this.words[n]=this.words[n]&e.words[n];return this.length=t.length,this._strip()},o.prototype.iand=function(e){return n(0==(this.negative|e.negative)),this.iuand(e)},o.prototype.and=function(e){return this.length>e.length?this.clone().iand(e):e.clone().iand(this)},o.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},o.prototype.iuxor=function(e){var t,n;this.length>e.length?(t=this,n=e):(t=e,n=this);for(var r=0;r<n.length;r++)this.words[r]=t.words[r]^n.words[r];if(this!==t)for(;r<t.length;r++)this.words[r]=t.words[r];return this.length=t.length,this._strip()},o.prototype.ixor=function(e){return n(0==(this.negative|e.negative)),this.iuxor(e)},o.prototype.xor=function(e){return this.length>e.length?this.clone().ixor(e):e.clone().ixor(this)},o.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},o.prototype.inotn=function(e){n("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var o=0;o<t;o++)this.words[o]=67108863&~this.words[o];return r>0&&(this.words[o]=~this.words[o]&67108863>>26-r),this._strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,t){n("number"==typeof e&&e>=0);var r=e/26|0,o=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<<o:this.words[r]&~(1<<o),this._strip()},o.prototype.iadd=function(e){var t,n,r;if(0!==this.negative&&0===e.negative)return this.negative=0,t=this.isub(e),this.negative^=1,this._normSign();if(0===this.negative&&0!==e.negative)return e.negative=0,t=this.isub(e),e.negative=1,t._normSign();this.length>e.length?(n=this,r=e):(n=e,r=this);for(var o=0,i=0;i<r.length;i++)t=(0|n.words[i])+(0|r.words[i])+o,this.words[i]=67108863&t,o=t>>>26;for(;0!==o&&i<n.length;i++)t=(0|n.words[i])+o,this.words[i]=67108863&t,o=t>>>26;if(this.length=n.length,0!==o)this.words[this.length]=o,this.length++;else if(n!==this)for(;i<n.length;i++)this.words[i]=n.words[i];return this},o.prototype.add=function(e){var t;return 0!==e.negative&&0===this.negative?(e.negative=0,t=this.sub(e),e.negative^=1,t):0===e.negative&&0!==this.negative?(this.negative=0,t=e.sub(this),this.negative=1,t):this.length>e.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var n,r,o=this.cmp(e);if(0===o)return this.negative=0,this.length=1,this.words[0]=0,this;o>0?(n=this,r=e):(n=e,r=this);for(var i=0,s=0;s<r.length;s++)i=(t=(0|n.words[s])-(0|r.words[s])+i)>>26,this.words[s]=67108863&t;for(;0!==i&&s<n.length;s++)i=(t=(0|n.words[s])+i)>>26,this.words[s]=67108863&t;if(0===i&&s<n.length&&n!==this)for(;s<n.length;s++)this.words[s]=n.words[s];return this.length=Math.max(this.length,s),n!==this&&(this.negative=1),this._strip()},o.prototype.sub=function(e){return this.clone().isub(e)};var f=function(e,t,n){var r,o,i,s=e.words,a=t.words,u=n.words,c=0,l=0|s[0],d=8191&l,p=l>>>13,m=0|s[1],h=8191&m,f=m>>>13,g=0|s[2],y=8191&g,b=g>>>13,w=0|s[3],I=8191&w,A=w>>>13,k=0|s[4],v=8191&k,M=k>>>13,P=0|s[5],x=8191&P,T=P>>>13,S=0|s[6],C=8191&S,E=S>>>13,_=0|s[7],O=8191&_,R=_>>>13,D=0|s[8],B=8191&D,K=D>>>13,L=0|s[9],N=8191&L,U=L>>>13,W=0|a[0],q=8191&W,G=W>>>13,V=0|a[1],F=8191&V,z=V>>>13,j=0|a[2],$=8191&j,Y=j>>>13,Z=0|a[3],H=8191&Z,Q=Z>>>13,J=0|a[4],X=8191&J,ee=J>>>13,te=0|a[5],ne=8191&te,re=te>>>13,oe=0|a[6],ie=8191&oe,se=oe>>>13,ae=0|a[7],ue=8191&ae,ce=ae>>>13,le=0|a[8],de=8191&le,pe=le>>>13,me=0|a[9],he=8191&me,fe=me>>>13;n.negative=e.negative^t.negative,n.length=19;var ge=(c+(r=Math.imul(d,q))|0)+((8191&(o=(o=Math.imul(d,G))+Math.imul(p,q)|0))<<13)|0;c=((i=Math.imul(p,G))+(o>>>13)|0)+(ge>>>26)|0,ge&=67108863,r=Math.imul(h,q),o=(o=Math.imul(h,G))+Math.imul(f,q)|0,i=Math.imul(f,G);var ye=(c+(r=r+Math.imul(d,F)|0)|0)+((8191&(o=(o=o+Math.imul(d,z)|0)+Math.imul(p,F)|0))<<13)|0;c=((i=i+Math.imul(p,z)|0)+(o>>>13)|0)+(ye>>>26)|0,ye&=67108863,r=Math.imul(y,q),o=(o=Math.imul(y,G))+Math.imul(b,q)|0,i=Math.imul(b,G),r=r+Math.imul(h,F)|0,o=(o=o+Math.imul(h,z)|0)+Math.imul(f,F)|0,i=i+Math.imul(f,z)|0;var be=(c+(r=r+Math.imul(d,$)|0)|0)+((8191&(o=(o=o+Math.imul(d,Y)|0)+Math.imul(p,$)|0))<<13)|0;c=((i=i+Math.imul(p,Y)|0)+(o>>>13)|0)+(be>>>26)|0,be&=67108863,r=Math.imul(I,q),o=(o=Math.imul(I,G))+Math.imul(A,q)|0,i=Math.imul(A,G),r=r+Math.imul(y,F)|0,o=(o=o+Math.imul(y,z)|0)+Math.imul(b,F)|0,i=i+Math.imul(b,z)|0,r=r+Math.imul(h,$)|0,o=(o=o+Math.imul(h,Y)|0)+Math.imul(f,$)|0,i=i+Math.imul(f,Y)|0;var we=(c+(r=r+Math.imul(d,H)|0)|0)+((8191&(o=(o=o+Math.imul(d,Q)|0)+Math.imul(p,H)|0))<<13)|0;c=((i=i+Math.imul(p,Q)|0)+(o>>>13)|0)+(we>>>26)|0,we&=67108863,r=Math.imul(v,q),o=(o=Math.imul(v,G))+Math.imul(M,q)|0,i=Math.imul(M,G),r=r+Math.imul(I,F)|0,o=(o=o+Math.imul(I,z)|0)+Math.imul(A,F)|0,i=i+Math.imul(A,z)|0,r=r+Math.imul(y,$)|0,o=(o=o+Math.imul(y,Y)|0)+Math.imul(b,$)|0,i=i+Math.imul(b,Y)|0,r=r+Math.imul(h,H)|0,o=(o=o+Math.imul(h,Q)|0)+Math.imul(f,H)|0,i=i+Math.imul(f,Q)|0;var Ie=(c+(r=r+Math.imul(d,X)|0)|0)+((8191&(o=(o=o+Math.imul(d,ee)|0)+Math.imul(p,X)|0))<<13)|0;c=((i=i+Math.imul(p,ee)|0)+(o>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,r=Math.imul(x,q),o=(o=Math.imul(x,G))+Math.imul(T,q)|0,i=Math.imul(T,G),r=r+Math.imul(v,F)|0,o=(o=o+Math.imul(v,z)|0)+Math.imul(M,F)|0,i=i+Math.imul(M,z)|0,r=r+Math.imul(I,$)|0,o=(o=o+Math.imul(I,Y)|0)+Math.imul(A,$)|0,i=i+Math.imul(A,Y)|0,r=r+Math.imul(y,H)|0,o=(o=o+Math.imul(y,Q)|0)+Math.imul(b,H)|0,i=i+Math.imul(b,Q)|0,r=r+Math.imul(h,X)|0,o=(o=o+Math.imul(h,ee)|0)+Math.imul(f,X)|0,i=i+Math.imul(f,ee)|0;var Ae=(c+(r=r+Math.imul(d,ne)|0)|0)+((8191&(o=(o=o+Math.imul(d,re)|0)+Math.imul(p,ne)|0))<<13)|0;c=((i=i+Math.imul(p,re)|0)+(o>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,r=Math.imul(C,q),o=(o=Math.imul(C,G))+Math.imul(E,q)|0,i=Math.imul(E,G),r=r+Math.imul(x,F)|0,o=(o=o+Math.imul(x,z)|0)+Math.imul(T,F)|0,i=i+Math.imul(T,z)|0,r=r+Math.imul(v,$)|0,o=(o=o+Math.imul(v,Y)|0)+Math.imul(M,$)|0,i=i+Math.imul(M,Y)|0,r=r+Math.imul(I,H)|0,o=(o=o+Math.imul(I,Q)|0)+Math.imul(A,H)|0,i=i+Math.imul(A,Q)|0,r=r+Math.imul(y,X)|0,o=(o=o+Math.imul(y,ee)|0)+Math.imul(b,X)|0,i=i+Math.imul(b,ee)|0,r=r+Math.imul(h,ne)|0,o=(o=o+Math.imul(h,re)|0)+Math.imul(f,ne)|0,i=i+Math.imul(f,re)|0;var ke=(c+(r=r+Math.imul(d,ie)|0)|0)+((8191&(o=(o=o+Math.imul(d,se)|0)+Math.imul(p,ie)|0))<<13)|0;c=((i=i+Math.imul(p,se)|0)+(o>>>13)|0)+(ke>>>26)|0,ke&=67108863,r=Math.imul(O,q),o=(o=Math.imul(O,G))+Math.imul(R,q)|0,i=Math.imul(R,G),r=r+Math.imul(C,F)|0,o=(o=o+Math.imul(C,z)|0)+Math.imul(E,F)|0,i=i+Math.imul(E,z)|0,r=r+Math.imul(x,$)|0,o=(o=o+Math.imul(x,Y)|0)+Math.imul(T,$)|0,i=i+Math.imul(T,Y)|0,r=r+Math.imul(v,H)|0,o=(o=o+Math.imul(v,Q)|0)+Math.imul(M,H)|0,i=i+Math.imul(M,Q)|0,r=r+Math.imul(I,X)|0,o=(o=o+Math.imul(I,ee)|0)+Math.imul(A,X)|0,i=i+Math.imul(A,ee)|0,r=r+Math.imul(y,ne)|0,o=(o=o+Math.imul(y,re)|0)+Math.imul(b,ne)|0,i=i+Math.imul(b,re)|0,r=r+Math.imul(h,ie)|0,o=(o=o+Math.imul(h,se)|0)+Math.imul(f,ie)|0,i=i+Math.imul(f,se)|0;var ve=(c+(r=r+Math.imul(d,ue)|0)|0)+((8191&(o=(o=o+Math.imul(d,ce)|0)+Math.imul(p,ue)|0))<<13)|0;c=((i=i+Math.imul(p,ce)|0)+(o>>>13)|0)+(ve>>>26)|0,ve&=67108863,r=Math.imul(B,q),o=(o=Math.imul(B,G))+Math.imul(K,q)|0,i=Math.imul(K,G),r=r+Math.imul(O,F)|0,o=(o=o+Math.imul(O,z)|0)+Math.imul(R,F)|0,i=i+Math.imul(R,z)|0,r=r+Math.imul(C,$)|0,o=(o=o+Math.imul(C,Y)|0)+Math.imul(E,$)|0,i=i+Math.imul(E,Y)|0,r=r+Math.imul(x,H)|0,o=(o=o+Math.imul(x,Q)|0)+Math.imul(T,H)|0,i=i+Math.imul(T,Q)|0,r=r+Math.imul(v,X)|0,o=(o=o+Math.imul(v,ee)|0)+Math.imul(M,X)|0,i=i+Math.imul(M,ee)|0,r=r+Math.imul(I,ne)|0,o=(o=o+Math.imul(I,re)|0)+Math.imul(A,ne)|0,i=i+Math.imul(A,re)|0,r=r+Math.imul(y,ie)|0,o=(o=o+Math.imul(y,se)|0)+Math.imul(b,ie)|0,i=i+Math.imul(b,se)|0,r=r+Math.imul(h,ue)|0,o=(o=o+Math.imul(h,ce)|0)+Math.imul(f,ue)|0,i=i+Math.imul(f,ce)|0;var Me=(c+(r=r+Math.imul(d,de)|0)|0)+((8191&(o=(o=o+Math.imul(d,pe)|0)+Math.imul(p,de)|0))<<13)|0;c=((i=i+Math.imul(p,pe)|0)+(o>>>13)|0)+(Me>>>26)|0,Me&=67108863,r=Math.imul(N,q),o=(o=Math.imul(N,G))+Math.imul(U,q)|0,i=Math.imul(U,G),r=r+Math.imul(B,F)|0,o=(o=o+Math.imul(B,z)|0)+Math.imul(K,F)|0,i=i+Math.imul(K,z)|0,r=r+Math.imul(O,$)|0,o=(o=o+Math.imul(O,Y)|0)+Math.imul(R,$)|0,i=i+Math.imul(R,Y)|0,r=r+Math.imul(C,H)|0,o=(o=o+Math.imul(C,Q)|0)+Math.imul(E,H)|0,i=i+Math.imul(E,Q)|0,r=r+Math.imul(x,X)|0,o=(o=o+Math.imul(x,ee)|0)+Math.imul(T,X)|0,i=i+Math.imul(T,ee)|0,r=r+Math.imul(v,ne)|0,o=(o=o+Math.imul(v,re)|0)+Math.imul(M,ne)|0,i=i+Math.imul(M,re)|0,r=r+Math.imul(I,ie)|0,o=(o=o+Math.imul(I,se)|0)+Math.imul(A,ie)|0,i=i+Math.imul(A,se)|0,r=r+Math.imul(y,ue)|0,o=(o=o+Math.imul(y,ce)|0)+Math.imul(b,ue)|0,i=i+Math.imul(b,ce)|0,r=r+Math.imul(h,de)|0,o=(o=o+Math.imul(h,pe)|0)+Math.imul(f,de)|0,i=i+Math.imul(f,pe)|0;var Pe=(c+(r=r+Math.imul(d,he)|0)|0)+((8191&(o=(o=o+Math.imul(d,fe)|0)+Math.imul(p,he)|0))<<13)|0;c=((i=i+Math.imul(p,fe)|0)+(o>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,r=Math.imul(N,F),o=(o=Math.imul(N,z))+Math.imul(U,F)|0,i=Math.imul(U,z),r=r+Math.imul(B,$)|0,o=(o=o+Math.imul(B,Y)|0)+Math.imul(K,$)|0,i=i+Math.imul(K,Y)|0,r=r+Math.imul(O,H)|0,o=(o=o+Math.imul(O,Q)|0)+Math.imul(R,H)|0,i=i+Math.imul(R,Q)|0,r=r+Math.imul(C,X)|0,o=(o=o+Math.imul(C,ee)|0)+Math.imul(E,X)|0,i=i+Math.imul(E,ee)|0,r=r+Math.imul(x,ne)|0,o=(o=o+Math.imul(x,re)|0)+Math.imul(T,ne)|0,i=i+Math.imul(T,re)|0,r=r+Math.imul(v,ie)|0,o=(o=o+Math.imul(v,se)|0)+Math.imul(M,ie)|0,i=i+Math.imul(M,se)|0,r=r+Math.imul(I,ue)|0,o=(o=o+Math.imul(I,ce)|0)+Math.imul(A,ue)|0,i=i+Math.imul(A,ce)|0,r=r+Math.imul(y,de)|0,o=(o=o+Math.imul(y,pe)|0)+Math.imul(b,de)|0,i=i+Math.imul(b,pe)|0;var xe=(c+(r=r+Math.imul(h,he)|0)|0)+((8191&(o=(o=o+Math.imul(h,fe)|0)+Math.imul(f,he)|0))<<13)|0;c=((i=i+Math.imul(f,fe)|0)+(o>>>13)|0)+(xe>>>26)|0,xe&=67108863,r=Math.imul(N,$),o=(o=Math.imul(N,Y))+Math.imul(U,$)|0,i=Math.imul(U,Y),r=r+Math.imul(B,H)|0,o=(o=o+Math.imul(B,Q)|0)+Math.imul(K,H)|0,i=i+Math.imul(K,Q)|0,r=r+Math.imul(O,X)|0,o=(o=o+Math.imul(O,ee)|0)+Math.imul(R,X)|0,i=i+Math.imul(R,ee)|0,r=r+Math.imul(C,ne)|0,o=(o=o+Math.imul(C,re)|0)+Math.imul(E,ne)|0,i=i+Math.imul(E,re)|0,r=r+Math.imul(x,ie)|0,o=(o=o+Math.imul(x,se)|0)+Math.imul(T,ie)|0,i=i+Math.imul(T,se)|0,r=r+Math.imul(v,ue)|0,o=(o=o+Math.imul(v,ce)|0)+Math.imul(M,ue)|0,i=i+Math.imul(M,ce)|0,r=r+Math.imul(I,de)|0,o=(o=o+Math.imul(I,pe)|0)+Math.imul(A,de)|0,i=i+Math.imul(A,pe)|0;var Te=(c+(r=r+Math.imul(y,he)|0)|0)+((8191&(o=(o=o+Math.imul(y,fe)|0)+Math.imul(b,he)|0))<<13)|0;c=((i=i+Math.imul(b,fe)|0)+(o>>>13)|0)+(Te>>>26)|0,Te&=67108863,r=Math.imul(N,H),o=(o=Math.imul(N,Q))+Math.imul(U,H)|0,i=Math.imul(U,Q),r=r+Math.imul(B,X)|0,o=(o=o+Math.imul(B,ee)|0)+Math.imul(K,X)|0,i=i+Math.imul(K,ee)|0,r=r+Math.imul(O,ne)|0,o=(o=o+Math.imul(O,re)|0)+Math.imul(R,ne)|0,i=i+Math.imul(R,re)|0,r=r+Math.imul(C,ie)|0,o=(o=o+Math.imul(C,se)|0)+Math.imul(E,ie)|0,i=i+Math.imul(E,se)|0,r=r+Math.imul(x,ue)|0,o=(o=o+Math.imul(x,ce)|0)+Math.imul(T,ue)|0,i=i+Math.imul(T,ce)|0,r=r+Math.imul(v,de)|0,o=(o=o+Math.imul(v,pe)|0)+Math.imul(M,de)|0,i=i+Math.imul(M,pe)|0;var Se=(c+(r=r+Math.imul(I,he)|0)|0)+((8191&(o=(o=o+Math.imul(I,fe)|0)+Math.imul(A,he)|0))<<13)|0;c=((i=i+Math.imul(A,fe)|0)+(o>>>13)|0)+(Se>>>26)|0,Se&=67108863,r=Math.imul(N,X),o=(o=Math.imul(N,ee))+Math.imul(U,X)|0,i=Math.imul(U,ee),r=r+Math.imul(B,ne)|0,o=(o=o+Math.imul(B,re)|0)+Math.imul(K,ne)|0,i=i+Math.imul(K,re)|0,r=r+Math.imul(O,ie)|0,o=(o=o+Math.imul(O,se)|0)+Math.imul(R,ie)|0,i=i+Math.imul(R,se)|0,r=r+Math.imul(C,ue)|0,o=(o=o+Math.imul(C,ce)|0)+Math.imul(E,ue)|0,i=i+Math.imul(E,ce)|0,r=r+Math.imul(x,de)|0,o=(o=o+Math.imul(x,pe)|0)+Math.imul(T,de)|0,i=i+Math.imul(T,pe)|0;var Ce=(c+(r=r+Math.imul(v,he)|0)|0)+((8191&(o=(o=o+Math.imul(v,fe)|0)+Math.imul(M,he)|0))<<13)|0;c=((i=i+Math.imul(M,fe)|0)+(o>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,r=Math.imul(N,ne),o=(o=Math.imul(N,re))+Math.imul(U,ne)|0,i=Math.imul(U,re),r=r+Math.imul(B,ie)|0,o=(o=o+Math.imul(B,se)|0)+Math.imul(K,ie)|0,i=i+Math.imul(K,se)|0,r=r+Math.imul(O,ue)|0,o=(o=o+Math.imul(O,ce)|0)+Math.imul(R,ue)|0,i=i+Math.imul(R,ce)|0,r=r+Math.imul(C,de)|0,o=(o=o+Math.imul(C,pe)|0)+Math.imul(E,de)|0,i=i+Math.imul(E,pe)|0;var Ee=(c+(r=r+Math.imul(x,he)|0)|0)+((8191&(o=(o=o+Math.imul(x,fe)|0)+Math.imul(T,he)|0))<<13)|0;c=((i=i+Math.imul(T,fe)|0)+(o>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,r=Math.imul(N,ie),o=(o=Math.imul(N,se))+Math.imul(U,ie)|0,i=Math.imul(U,se),r=r+Math.imul(B,ue)|0,o=(o=o+Math.imul(B,ce)|0)+Math.imul(K,ue)|0,i=i+Math.imul(K,ce)|0,r=r+Math.imul(O,de)|0,o=(o=o+Math.imul(O,pe)|0)+Math.imul(R,de)|0,i=i+Math.imul(R,pe)|0;var _e=(c+(r=r+Math.imul(C,he)|0)|0)+((8191&(o=(o=o+Math.imul(C,fe)|0)+Math.imul(E,he)|0))<<13)|0;c=((i=i+Math.imul(E,fe)|0)+(o>>>13)|0)+(_e>>>26)|0,_e&=67108863,r=Math.imul(N,ue),o=(o=Math.imul(N,ce))+Math.imul(U,ue)|0,i=Math.imul(U,ce),r=r+Math.imul(B,de)|0,o=(o=o+Math.imul(B,pe)|0)+Math.imul(K,de)|0,i=i+Math.imul(K,pe)|0;var Oe=(c+(r=r+Math.imul(O,he)|0)|0)+((8191&(o=(o=o+Math.imul(O,fe)|0)+Math.imul(R,he)|0))<<13)|0;c=((i=i+Math.imul(R,fe)|0)+(o>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,r=Math.imul(N,de),o=(o=Math.imul(N,pe))+Math.imul(U,de)|0,i=Math.imul(U,pe);var Re=(c+(r=r+Math.imul(B,he)|0)|0)+((8191&(o=(o=o+Math.imul(B,fe)|0)+Math.imul(K,he)|0))<<13)|0;c=((i=i+Math.imul(K,fe)|0)+(o>>>13)|0)+(Re>>>26)|0,Re&=67108863;var De=(c+(r=Math.imul(N,he))|0)+((8191&(o=(o=Math.imul(N,fe))+Math.imul(U,he)|0))<<13)|0;return c=((i=Math.imul(U,fe))+(o>>>13)|0)+(De>>>26)|0,De&=67108863,u[0]=ge,u[1]=ye,u[2]=be,u[3]=we,u[4]=Ie,u[5]=Ae,u[6]=ke,u[7]=ve,u[8]=Me,u[9]=Pe,u[10]=xe,u[11]=Te,u[12]=Se,u[13]=Ce,u[14]=Ee,u[15]=_e,u[16]=Oe,u[17]=Re,u[18]=De,0!==c&&(u[19]=c,n.length++),n};function g(e,t,n){n.negative=t.negative^e.negative,n.length=e.length+t.length;for(var r=0,o=0,i=0;i<n.length-1;i++){var s=o;o=0;for(var a=67108863&r,u=Math.min(i,t.length-1),c=Math.max(0,i-e.length+1);c<=u;c++){var l=i-c,d=(0|e.words[l])*(0|t.words[c]),p=67108863&d;a=67108863&(p=p+a|0),o+=(s=(s=s+(d/67108864|0)|0)+(p>>>26)|0)>>>26,s&=67108863}n.words[i]=a,r=s,s=o}return 0!==r?n.words[i]=r:n.length--,n._strip()}function y(e,t,n){return g(e,t,n)}Math.imul||(f=h),o.prototype.mulTo=function(e,t){var n=this.length+e.length;return 10===this.length&&10===e.length?f(this,e,t):n<63?h(this,e,t):n<1024?g(this,e,t):y(this,e,t)},o.prototype.mul=function(e){var t=new o(null);return t.words=new Array(this.length+e.length),this.mulTo(e,t)},o.prototype.mulf=function(e){var t=new o(null);return t.words=new Array(this.length+e.length),y(this,e,t)},o.prototype.imul=function(e){return this.clone().mulTo(e,this)},o.prototype.imuln=function(e){var t=e<0;t&&(e=-e),n("number"==typeof e),n(e<67108864);for(var r=0,o=0;o<this.length;o++){var i=(0|this.words[o])*e,s=(67108863&i)+(67108863&r);r>>=26,r+=i/67108864|0,r+=s>>>26,this.words[o]=67108863&s}return 0!==r&&(this.words[o]=r,this.length++),t?this.ineg():this},o.prototype.muln=function(e){return this.clone().imuln(e)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),n=0;n<t.length;n++){var r=n/26|0,o=n%26;t[n]=e.words[r]>>>o&1}return t}(e);if(0===t.length)return new o(1);for(var n=this,r=0;r<t.length&&0===t[r];r++,n=n.sqr());if(++r<t.length)for(var i=n.sqr();r<t.length;r++,i=i.sqr())0!==t[r]&&(n=n.mul(i));return n},o.prototype.iushln=function(e){n("number"==typeof e&&e>=0);var t,r=e%26,o=(e-r)/26,i=67108863>>>26-r<<26-r;if(0!==r){var s=0;for(t=0;t<this.length;t++){var a=this.words[t]&i,u=(0|this.words[t])-a<<r;this.words[t]=u|s,s=a>>>26-r}s&&(this.words[t]=s,this.length++)}if(0!==o){for(t=this.length-1;t>=0;t--)this.words[t+o]=this.words[t];for(t=0;t<o;t++)this.words[t]=0;this.length+=o}return this._strip()},o.prototype.ishln=function(e){return n(0===this.negative),this.iushln(e)},o.prototype.iushrn=function(e,t,r){var o;n("number"==typeof e&&e>=0),o=t?(t-t%26)/26:0;var i=e%26,s=Math.min((e-i)/26,this.length),a=67108863^67108863>>>i<<i,u=r;if(o-=s,o=Math.max(0,o),u){for(var c=0;c<s;c++)u.words[c]=this.words[c];u.length=s}if(0===s);else if(this.length>s)for(this.length-=s,c=0;c<this.length;c++)this.words[c]=this.words[c+s];else this.words[0]=0,this.length=1;var l=0;for(c=this.length-1;c>=0&&(0!==l||c>=o);c--){var d=0|this.words[c];this.words[c]=l<<26-i|d>>>i,l=d&a}return u&&0!==l&&(u.words[u.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},o.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},o.prototype.shln=function(e){return this.clone().ishln(e)},o.prototype.ushln=function(e){return this.clone().iushln(e)},o.prototype.shrn=function(e){return this.clone().ishrn(e)},o.prototype.ushrn=function(e){return this.clone().iushrn(e)},o.prototype.testn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,o=1<<t;return this.length<=r?0:!!(this.words[r]&o)},o.prototype.imaskn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var o=67108863^67108863>>>t<<t;this.words[this.length-1]&=o}return this._strip()},o.prototype.maskn=function(e){return this.clone().imaskn(e)},o.prototype.iaddn=function(e){return n("number"==typeof e),n(e<67108864),e<0?this.isubn(-e):0!==this.negative?1===this.length&&(0|this.words[0])<=e?(this.words[0]=e-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(e),this.negative=1,this):this._iaddn(e)},o.prototype._iaddn=function(e){this.words[0]+=e;for(var t=0;t<this.length&&this.words[t]>=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},o.prototype.isubn=function(e){if(n("number"==typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t<this.length&&this.words[t]<0;t++)this.words[t]+=67108864,this.words[t+1]-=1;return this._strip()},o.prototype.addn=function(e){return this.clone().iaddn(e)},o.prototype.subn=function(e){return this.clone().isubn(e)},o.prototype.iabs=function(){return this.negative=0,this},o.prototype.abs=function(){return this.clone().iabs()},o.prototype._ishlnsubmul=function(e,t,r){var o,i,s=e.length+r;this._expand(s);var a=0;for(o=0;o<e.length;o++){i=(0|this.words[o+r])+a;var u=(0|e.words[o])*t;a=((i-=67108863&u)>>26)-(u/67108864|0),this.words[o+r]=67108863&i}for(;o<this.length-r;o++)a=(i=(0|this.words[o+r])+a)>>26,this.words[o+r]=67108863&i;if(0===a)return this._strip();for(n(-1===a),a=0,o=0;o<this.length;o++)a=(i=-(0|this.words[o])+a)>>26,this.words[o]=67108863&i;return this.negative=1,this._strip()},o.prototype._wordDiv=function(e,t){var n=(this.length,e.length),r=this.clone(),i=e,s=0|i.words[i.length-1];0!=(n=26-this._countBits(s))&&(i=i.ushln(n),r.iushln(n),s=0|i.words[i.length-1]);var a,u=r.length-i.length;if("mod"!==t){(a=new o(null)).length=u+1,a.words=new Array(a.length);for(var c=0;c<a.length;c++)a.words[c]=0}var l=r.clone()._ishlnsubmul(i,1,u);0===l.negative&&(r=l,a&&(a.words[u]=1));for(var d=u-1;d>=0;d--){var p=67108864*(0|r.words[i.length+d])+(0|r.words[i.length+d-1]);for(p=Math.min(p/s|0,67108863),r._ishlnsubmul(i,p,d);0!==r.negative;)p--,r.negative=0,r._ishlnsubmul(i,1,d),r.isZero()||(r.negative^=1);a&&(a.words[d]=p)}return a&&a._strip(),r._strip(),"div"!==t&&0!==n&&r.iushrn(n),{div:a||null,mod:r}},o.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===e.negative?(a=this.neg().divmod(e,t),"mod"!==t&&(i=a.div.neg()),"div"!==t&&(s=a.mod.neg(),r&&0!==s.negative&&s.iadd(e)),{div:i,mod:s}):0===this.negative&&0!==e.negative?(a=this.divmod(e.neg(),t),"mod"!==t&&(i=a.div.neg()),{div:i,mod:a.mod}):0!=(this.negative&e.negative)?(a=this.neg().divmod(e.neg(),t),"div"!==t&&(s=a.mod.neg(),r&&0!==s.negative&&s.isub(e)),{div:a.div,mod:s}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new o(this.modrn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new o(this.modrn(e.words[0]))}:this._wordDiv(e,t);var i,s,a},o.prototype.div=function(e){return this.divmod(e,"div",0).div},o.prototype.mod=function(e){return this.divmod(e,"mod",0).mod},o.prototype.umod=function(e){return this.divmod(e,"mod",1).mod},o.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var n=0!==t.div.negative?t.mod.isub(e):t.mod,r=e.ushrn(1),o=e.andln(1),i=n.cmp(r);return i<0||1===o&&0===i?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},o.prototype.modrn=function(e){var t=e<0;t&&(e=-e),n(e<=67108863);for(var r=(1<<26)%e,o=0,i=this.length-1;i>=0;i--)o=(r*o+(0|this.words[i]))%e;return t?-o:o},o.prototype.modn=function(e){return this.modrn(e)},o.prototype.idivn=function(e){var t=e<0;t&&(e=-e),n(e<=67108863);for(var r=0,o=this.length-1;o>=0;o--){var i=(0|this.words[o])+67108864*r;this.words[o]=i/e|0,r=i%e}return this._strip(),t?this.ineg():this},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new o(1),s=new o(0),a=new o(0),u=new o(1),c=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++c;for(var l=r.clone(),d=t.clone();!t.isZero();){for(var p=0,m=1;0==(t.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(t.iushrn(p);p-- >0;)(i.isOdd()||s.isOdd())&&(i.iadd(l),s.isub(d)),i.iushrn(1),s.iushrn(1);for(var h=0,f=1;0==(r.words[0]&f)&&h<26;++h,f<<=1);if(h>0)for(r.iushrn(h);h-- >0;)(a.isOdd()||u.isOdd())&&(a.iadd(l),u.isub(d)),a.iushrn(1),u.iushrn(1);t.cmp(r)>=0?(t.isub(r),i.isub(a),s.isub(u)):(r.isub(t),a.isub(i),u.isub(s))}return{a:a,b:u,gcd:r.iushln(c)}},o.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i,s=new o(1),a=new o(0),u=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,l=1;0==(t.words[0]&l)&&c<26;++c,l<<=1);if(c>0)for(t.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);for(var d=0,p=1;0==(r.words[0]&p)&&d<26;++d,p<<=1);if(d>0)for(r.iushrn(d);d-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);t.cmp(r)>=0?(t.isub(r),s.isub(a)):(r.isub(t),a.isub(s))}return(i=0===t.cmpn(1)?s:a).cmpn(0)<0&&i.iadd(e),i},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),n=e.clone();t.negative=0,n.negative=0;for(var r=0;t.isEven()&&n.isEven();r++)t.iushrn(1),n.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;n.isEven();)n.iushrn(1);var o=t.cmp(n);if(o<0){var i=t;t=n,n=i}else if(0===o||0===n.cmpn(1))break;t.isub(n)}return n.iushln(r)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){n("number"==typeof e);var t=e%26,r=(e-t)/26,o=1<<t;if(this.length<=r)return this._expand(r+1),this.words[r]|=o,this;for(var i=o,s=r;0!==i&&s<this.length;s++){var a=0|this.words[s];i=(a+=i)>>>26,a&=67108863,this.words[s]=a}return 0!==i&&(this.words[s]=i,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this._strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,"Number is too big");var o=0|this.words[0];t=o===e?0:o<e?-1:1}return 0!==this.negative?0|-t:t},o.prototype.cmp=function(e){if(0!==this.negative&&0===e.negative)return-1;if(0===this.negative&&0!==e.negative)return 1;var t=this.ucmp(e);return 0!==this.negative?0|-t:t},o.prototype.ucmp=function(e){if(this.length>e.length)return 1;if(this.length<e.length)return-1;for(var t=0,n=this.length-1;n>=0;n--){var r=0|this.words[n],o=0|e.words[n];if(r!==o){r<o?t=-1:r>o&&(t=1);break}}return t},o.prototype.gtn=function(e){return 1===this.cmpn(e)},o.prototype.gt=function(e){return 1===this.cmp(e)},o.prototype.gten=function(e){return this.cmpn(e)>=0},o.prototype.gte=function(e){return this.cmp(e)>=0},o.prototype.ltn=function(e){return-1===this.cmpn(e)},o.prototype.lt=function(e){return-1===this.cmp(e)},o.prototype.lten=function(e){return this.cmpn(e)<=0},o.prototype.lte=function(e){return this.cmp(e)<=0},o.prototype.eqn=function(e){return 0===this.cmpn(e)},o.prototype.eq=function(e){return 0===this.cmp(e)},o.red=function(e){return new M(e)},o.prototype.toRed=function(e){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(e){return this.red=e,this},o.prototype.forceRed=function(e){return n(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return n(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var b={k256:null,p224:null,p192:null,p25519:null};function w(e,t){this.name=e,this.p=new o(t,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function I(){w.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function A(){w.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function k(){w.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function v(){w.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function M(e){if("string"==typeof e){var t=o._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function P(e){M.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}w.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},w.prototype.ireduce=function(e){var t,n=e;do{this.split(n,this.tmp),t=(n=(n=this.imulK(n)).iadd(this.tmp)).bitLength()}while(t>this.n);var r=t<this.n?-1:n.ucmp(this.p);return 0===r?(n.words[0]=0,n.length=1):r>0?n.isub(this.p):void 0!==n.strip?n.strip():n._strip(),n},w.prototype.split=function(e,t){e.iushrn(this.n,0,t)},w.prototype.imulK=function(e){return e.imul(this.k)},r(I,w),I.prototype.split=function(e,t){for(var n=4194303,r=Math.min(e.length,9),o=0;o<r;o++)t.words[o]=e.words[o];if(t.length=r,e.length<=9)return e.words[0]=0,void(e.length=1);var i=e.words[9];for(t.words[t.length++]=i&n,o=10;o<e.length;o++){var s=0|e.words[o];e.words[o-10]=(s&n)<<4|i>>>22,i=s}i>>>=22,e.words[o-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},I.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,n=0;n<e.length;n++){var r=0|e.words[n];t+=977*r,e.words[n]=67108863&t,t=64*r+(t/67108864|0)}return 0===e.words[e.length-1]&&(e.length--,0===e.words[e.length-1]&&e.length--),e},r(A,w),r(k,w),r(v,w),v.prototype.imulK=function(e){for(var t=0,n=0;n<e.length;n++){var r=19*(0|e.words[n])+t,o=67108863&r;r>>>=26,e.words[n]=o,t=r}return 0!==t&&(e.words[e.length++]=t),e},o._prime=function(e){if(b[e])return b[e];var t;if("k256"===e)t=new I;else if("p224"===e)t=new A;else if("p192"===e)t=new k;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new v}return b[e]=t,t},M.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},M.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),"red works only with positives"),n(e.red&&e.red===t.red,"red works only with red numbers")},M.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):(c(e,e.umod(this.m)._forceRed(this)),e)},M.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},M.prototype.add=function(e,t){this._verify2(e,t);var n=e.add(t);return n.cmp(this.m)>=0&&n.isub(this.m),n._forceRed(this)},M.prototype.iadd=function(e,t){this._verify2(e,t);var n=e.iadd(t);return n.cmp(this.m)>=0&&n.isub(this.m),n},M.prototype.sub=function(e,t){this._verify2(e,t);var n=e.sub(t);return n.cmpn(0)<0&&n.iadd(this.m),n._forceRed(this)},M.prototype.isub=function(e,t){this._verify2(e,t);var n=e.isub(t);return n.cmpn(0)<0&&n.iadd(this.m),n},M.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},M.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},M.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},M.prototype.isqr=function(e){return this.imul(e,e.clone())},M.prototype.sqr=function(e){return this.mul(e,e)},M.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new o(1)).iushrn(2);return this.pow(e,r)}for(var i=this.m.subn(1),s=0;!i.isZero()&&0===i.andln(1);)s++,i.iushrn(1);n(!i.isZero());var a=new o(1).toRed(this),u=a.redNeg(),c=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new o(2*l*l).toRed(this);0!==this.pow(l,c).cmp(u);)l.redIAdd(u);for(var d=this.pow(l,i),p=this.pow(e,i.addn(1).iushrn(1)),m=this.pow(e,i),h=s;0!==m.cmp(a);){for(var f=m,g=0;0!==f.cmp(a);g++)f=f.redSqr();n(g<h);var y=this.pow(d,new o(1).iushln(h-g-1));p=p.redMul(y),d=y.redSqr(),m=m.redMul(d),h=g}return p},M.prototype.invm=function(e){var t=e._invmp(this.m);return 0!==t.negative?(t.negative=0,this.imod(t).redNeg()):this.imod(t)},M.prototype.pow=function(e,t){if(t.isZero())return new o(1).toRed(this);if(0===t.cmpn(1))return e.clone();var n=new Array(16);n[0]=new o(1).toRed(this),n[1]=e;for(var r=2;r<n.length;r++)n[r]=this.mul(n[r-1],e);var i=n[0],s=0,a=0,u=t.bitLength()%26;for(0===u&&(u=26),r=t.length-1;r>=0;r--){for(var c=t.words[r],l=u-1;l>=0;l--){var d=c>>l&1;i!==n[0]&&(i=this.sqr(i)),0!==d||0!==s?(s<<=1,s|=d,(4==++a||0===r&&0===l)&&(i=this.mul(i,n[s]),a=0,s=0)):a=0}u=26}return i},M.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},M.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new P(e)},r(P,M),P.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},P.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},P.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var n=e.imul(t),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=n.isub(r).iushrn(this.shift),i=o;return o.cmp(this.m)>=0?i=o.isub(this.m):o.cmpn(0)<0&&(i=o.iadd(this.m)),i._forceRed(this)},P.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new o(0)._forceRed(this);var n=e.mul(t),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=n.isub(r).iushrn(this.shift),s=i;return i.cmp(this.m)>=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},P.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(0,En);var Bn=_n(Rn.exports);const Kn={Spl:"spl",Token2022:"token2022",SplCold:"spl-cold",Token2022Cold:"token2022-cold",CTokenHot:"ctoken-hot",CTokenCold:"ctoken-cold"};function Ln(e){if(!e||0===e.length)return null;try{let n=0;const r=new t.PublicKey(e.slice(n,n+32));n+=32;const o=new t.PublicKey(e.slice(n,n+32));n+=32;const i=new Bn(e.slice(n,n+8),"le");n+=8;const s=e[n];n+=1;const a=s?new t.PublicKey(e.slice(n,n+32)):null;n+=32;const u=e[n];n+=1;const c=e[n];return n+=1,{mint:r,owner:o,amount:i,delegate:a,state:u,tlv:c?e.slice(n):null}}catch(e){return console.error("Token data parsing error:",e),null}}function Nn(e,t){return{address:e,mint:t.mint,owner:t.owner,amount:BigInt(t.amount.toString()),delegate:t.delegate,delegatedAmount:BigInt(0),isInitialized:t.state!==n.AccountState.Uninitialized,isFrozen:t.state===n.AccountState.Frozen,isNative:0,rentExemptReserve:null,closeAuthority:null,tlvData:t.tlv?w.from(t.tlv):w.alloc(0)}}function Un(e){const t=w.from(e.data.discriminator),n=w.from(e.data.data),r=w.concat([t,n]);return{executable:0,owner:e.owner,lamports:e.lamports.toNumber(),data:r,rentEpoch:void 0}}function Wn(e,t){const n=Ln(t.data);if(!n)throw new Error("Invalid token data");return{accountInfo:t,loadContext:void 0,parsed:Nn(e,n),isCold:0}}function qn(e,t){const n=Ln(t.data.data);if(!n)throw new Error("Invalid token data");return{accountInfo:Un(t),loadContext:{treeInfo:t.treeInfo,hash:t.hash,leafIndex:t.leafIndex,proveByIndex:t.proveByIndex},parsed:Nn(e,n),isCold:1}}async function Gn(e,t,n,r){return Fn(e,t,n,r,void 0)}async function Vn(e,t,n,r,o,i,s=0,a=0){const u=rn(t,r,n,i,a);if(s&&"ctoken"!==u.type)throw new Error(`For wrap=true, ata must be the c-token ATA. Got ${u.type} ATA instead.`);const c=await Fn(e,t,o,i,{owner:n,mint:r},s);return c._isAta=1,c._owner=n,c._mint=r,c}async function Fn(t,r,o,i,s,a=0){if(!r&&!s)throw new Error("One of address or fetchByOwner is required");if(!i)return async function(t,r,o,i,s){const a=null!=r?r:n.getAssociatedTokenAddressSync(i.mint,i.owner,0,e.CTOKEN_PROGRAM_ID,nn(e.CTOKEN_PROGRAM_ID)),u=[],c=[],l=[];if(u.push(async function(t,n,r){const o=await t.getAccountInfo(n,r);if(!o||!o.owner.equals(e.CTOKEN_PROGRAM_ID))throw new Error("Not a CTOKEN onchain account");return Wn(n,o)}(t,a,o)),c.push(Kn.CTokenHot),l.push(a),u.push(i?async function(t,n,r,o){var i;const s=await t.getCompressedTokenAccountsByOwner(n,{mint:r}),a=s.items.length>0?s.items[0].compressedAccount:null;if(!(null===(i=null==a?void 0:a.data)||void 0===i?void 0:i.data.length))throw new Error("Not a compressed token account");if(!a.owner.equals(e.CTOKEN_PROGRAM_ID))throw new Error("Invalid owner for compressed token");return qn(o,a)}(t,i.owner,i.mint,a):async function(t,n){var r;const o=e.getDefaultAddressTreeInfo().tree,i=e.deriveAddressV2(n.toBytes(),o,e.CTOKEN_PROGRAM_ID),s=await t.getCompressedAccount(e.bn(i.toBytes()));if(!(null===(r=null==s?void 0:s.data)||void 0===r?void 0:r.data.length))throw new Error("Compressed token account not found at derived address. Note: getAccountInterface only finds compressed accounts that were compressed from on-chain (via compress_accounts_idempotent). For tokens minted compressed (via mintTo), use getAtaInterface with owner+mint.");if(!s.owner.equals(e.CTOKEN_PROGRAM_ID))throw new Error("Invalid owner for compressed token");return qn(n,s)}(t,r)),c.push(Kn.CTokenCold),l.push(a),s){if(!i)throw new Error("fetchByOwner is required for wrap=true to derive SPL/T22 addresses");const e=n.getAssociatedTokenAddressSync(i.mint,i.owner,0,n.TOKEN_PROGRAM_ID,nn(n.TOKEN_PROGRAM_ID)),r=n.getAssociatedTokenAddressSync(i.mint,i.owner,0,n.TOKEN_2022_PROGRAM_ID,nn(n.TOKEN_2022_PROGRAM_ID));u.push(async function(e,t,r){const o=await e.getAccountInfo(t,r);if(!o||!o.owner.equals(n.TOKEN_PROGRAM_ID))throw new Error("Not a TOKEN_PROGRAM_ID account");return{accountInfo:o,parsed:n.unpackAccount(t,o,n.TOKEN_PROGRAM_ID),isCold:0,loadContext:void 0}}(t,e,o)),c.push(Kn.Spl),l.push(e),u.push(async function(e,t,r){const o=await e.getAccountInfo(t,r);if(!o||!o.owner.equals(n.TOKEN_2022_PROGRAM_ID))throw new Error("Not a TOKEN_2022_PROGRAM_ID account");return{accountInfo:o,parsed:n.unpackAccount(t,o,n.TOKEN_2022_PROGRAM_ID),isCold:0,loadContext:void 0}}(t,r,o)),c.push(Kn.Token2022),l.push(r)}const d=await Promise.allSettled(u),p=[];for(let e=0;e<d.length;e++){const t=d[e];if("fulfilled"===t.status){const n=t.value;p.push({type:c[e],address:l[e],amount:n.parsed.amount,accountInfo:n.accountInfo,loadContext:n.loadContext,parsed:n.parsed})}}if(0===p.length)throw new n.TokenAccountNotFoundError;const m=[Kn.CTokenHot,Kn.CTokenCold,Kn.Spl,Kn.Token2022];return p.sort(((e,t)=>m.indexOf(e.type)-m.indexOf(t.type))),zn(p,a)}(t,r,o,s,a);if(i.equals(e.CTOKEN_PROGRAM_ID))return async function(t,r,o,i){if(!r){if(!i)throw new Error("fetchByOwner is required");r=n.getAssociatedTokenAddressSync(i.mint,i.owner,0,e.CTOKEN_PROGRAM_ID,nn(e.CTOKEN_PROGRAM_ID))}const[s,a]=await Promise.allSettled([t.getAccountInfo(r,o),i?t.getCompressedTokenAccountsByOwner(i.owner,{mint:i.mint}):t.getCompressedTokenAccountsByOwner(r)]),u="fulfilled"===s.status?s.value:null,c="fulfilled"===a.status?a.value.items.map((e=>e.compressedAccount)):[],l=[];if(u&&u.owner.equals(e.CTOKEN_PROGRAM_ID)){const e=Wn(r,u);l.push({type:Kn.CTokenHot,address:r,amount:e.parsed.amount,accountInfo:u,parsed:e.parsed})}for(const t of c)if(t&&t.data&&t.data.data.length>0&&t.owner.equals(e.CTOKEN_PROGRAM_ID)){const e=qn(r,t);l.push({type:Kn.CTokenCold,address:r,amount:e.parsed.amount,accountInfo:e.accountInfo,loadContext:e.loadContext,parsed:e.parsed})}if(0===l.length)throw new n.TokenAccountNotFoundError;return l.sort(((e,t)=>"ctoken-hot"===e.type&&"ctoken-cold"===t.type?-1:"ctoken-cold"===e.type&&"ctoken-hot"===t.type?1:0)),zn(l,r)}(t,r,o,s);if(i.equals(n.TOKEN_PROGRAM_ID)||i.equals(n.TOKEN_2022_PROGRAM_ID))return async function(t,r,o,i,s){if(!r){if(!s)throw new Error("fetchByOwner is required");r=n.getAssociatedTokenAddressSync(s.mint,s.owner,0,i,nn(i))}const a=await t.getAccountInfo(r,o);if(!a)throw new n.TokenAccountNotFoundError;const u=n.unpackAccount(r,a,i),c=[{type:i.equals(n.TOKEN_PROGRAM_ID)?Kn.Spl:Kn.Token2022,address:r,amount:u.amount,accountInfo:a,parsed:u}];if(s){const o=(await t.getCompressedTokenAccountsByOwner(s.owner,{mint:s.mint})).items.map((e=>e.compressedAccount)),a=i.equals(n.TOKEN_PROGRAM_ID)?Kn.SplCold:Kn.Token2022Cold;for(const t of o)if(t&&t.data&&t.data.data.length>0&&t.owner.equals(e.CTOKEN_PROGRAM_ID)){const e=qn(r,t);c.push({type:a,address:r,amount:e.parsed.amount,accountInfo:e.accountInfo,loadContext:e.loadContext,parsed:e.parsed})}}return zn(c,r)}(t,r,o,i,s);throw new Error(`Unsupported program ID: ${i.toBase58()}`)}function zn(e,t){const n=e.reduce(((e,t)=>e+t.amount),BigInt(0)),r=e[0],o=e.some((e=>null!==e.parsed.delegate)),i=e.some((e=>e.parsed.isFrozen)),s=e.length>1,a=Object.assign(Object.assign({},r.parsed),{address:t,amount:n});return{accountInfo:r.accountInfo,parsed:a,isCold:["ctoken-cold","spl-cold","token2022-cold"].includes(r.type),loadContext:r.loadContext,_sources:e,_needsConsolidation:s,_hasDelegate:o,_anyFrozen:i}}function jn(t,r,o=0,i=e.CTOKEN_PROGRAM_ID,s){const a=null!=s?s:nn(i);return n.getAssociatedTokenAddressSync(t,r,o,i,a)}function $n(n,r,o,i,s,a,u=o){const c=Pn({withTransactionHash:0,withLamportsChangeAccountMerkleTreeIndex:0,lamportsChangeAccountMerkleTreeIndex:0,lamportsChangeAccountOwnerIndex:0,outputQueue:0,maxTopUp:0,cpiContext:null,compressions:[xn(s,0,2,1,4,a.poolIndex,a.bump),Tn(s,0,3,6)],proof:null,inTokenData:[],outTokenData:[],inLamports:null,outLamports:null,inTlv:null,outTlv:null}),l=[{pubkey:pt.deriveCpiAuthorityPda,isSigner:0,isWritable:0},{pubkey:u,isSigner:1,isWritable:1},{pubkey:i,isSigner:0,isWritable:0},{pubkey:o,isSigner:1,isWritable:0},{pubkey:n,isSigner:0,isWritable:1},{pubkey:r,isSigner:0,isWritable:1},{pubkey:a.splInterfacePda,isSigner:0,isWritable:1},{pubkey:a.tokenProgram,isSigner:0,isWritable:0},{pubkey:e.CTOKEN_PROGRAM_ID,isSigner:0,isWritable:0}];return new t.TransactionInstruction({programId:pt.programId,keys:l,data:c})}function Yn(t){const n=new Set([Kn.CTokenCold,Kn.SplCold,Kn.Token2022Cold]);return t.filter((e=>void 0!==e.loadContext)).filter((e=>n.has(e.type))).map((t=>{const n=t.accountInfo.data,r=n.subarray(0,Math.min(8,n.length)),o=n.length>8?n.subarray(8):Buffer.alloc(0),i={treeInfo:t.loadContext.treeInfo,hash:t.loadContext.hash,leafIndex:t.loadContext.leafIndex,proveByIndex:t.loadContext.proveByIndex,owner:t.accountInfo.owner,lamports:e.bn(t.accountInfo.lamports),address:null,data:0===n.length?null:{discriminator:Array.from(r),data:Buffer.from(o),dataHash:new Array(32).fill(0)},readOnly:0},s=t.parsed.isInitialized?t.parsed.isFrozen?2:1:0;return{compressedAccount:i,parsed:{mint:t.parsed.mint,owner:t.parsed.owner,amount:e.bn(t.parsed.amount.toString()),delegate:t.parsed.delegate,state:s,tlv:t.parsed.tlvData.length>0?t.parsed.tlvData:null}}}))}async function Zn(e,t,r,o,i,s,a=0){null!=i||(i=r);try{return Hn(e,i,await Vn(e,t,r,o,void 0,void 0,a),s,a,t)}catch(e){if(e instanceof n.TokenAccountNotFoundError)return[];throw e}}async function Hn(t,r,o,i,s=0,a){var u,c,l,d,p;if(!o._isAta||!o._owner||!o._mint)throw new Error("AccountInterface must be from getAtaInterface (requires _isAta, _owner, _mint)");const m=[],h=o._owner,f=o._mint,g=null!==(u=o._sources)&&void 0!==u?u:[],y=jn(f,h),b=n.getAssociatedTokenAddressSync(f,h,0,n.TOKEN_PROGRAM_ID,nn(n.TOKEN_PROGRAM_ID)),w=n.getAssociatedTokenAddressSync(f,h,0,n.TOKEN_2022_PROGRAM_ID,nn(n.TOKEN_2022_PROGRAM_ID));let I="ctoken";if(a&&(I=rn(a,f,h).type,s&&"ctoken"!==I))throw new Error(`For wrap=true, targetAta must be c-token ATA. Got ${I} ATA.`);const A=g.find((e=>"spl"===e.type)),k=g.find((e=>"token2022"===e.type)),v=g.find((e=>"ctoken-hot"===e.type)),M=g.find((e=>"ctoken-cold"===e.type)),P=null!==(c=null==A?void 0:A.amount)&&void 0!==c?c:BigInt(0),x=null!==(l=null==k?void 0:k.amount)&&void 0!==l?l:BigInt(0),T=null!==(d=null==M?void 0:M.amount)&&void 0!==d?d:BigInt(0);if(P===BigInt(0)&&x===BigInt(0)&&T===BigInt(0))return[];let S;if(s||"spl"===I||"token2022"===I||P>BigInt(0)||x>BigInt(0))try{S=(null!==(p=null==i?void 0:i.splInterfaceInfos)&&void 0!==p?p:await Ie(t,f)).find((e=>e.isInitialized))}catch(e){}if(s){if(v||m.push(an(r,y,h,f,e.CTOKEN_PROGRAM_ID)),P>BigInt(0)&&S&&m.push($n(b,y,h,f,P,S,r)),x>BigInt(0)&&S&&m.push($n(w,y,h,f,x,S,r)),T>BigInt(0)&&M){const e=Yn(g);if(e.length>0){const n=await t.getValidityProofV0(e.map((e=>({hash:e.compressedAccount.hash,tree:e.compressedAccount.treeInfo.tree,queue:e.compressedAccount.treeInfo.queue}))));m.push(Cn(r,e,y,T,n))}}}else if(T>BigInt(0)&&M){const o=Yn(g);if(o.length>0){const i=await t.getValidityProofV0(o.map((e=>({hash:e.compressedAccount.hash,tree:e.compressedAccount.treeInfo.tree,queue:e.compressedAccount.treeInfo.queue}))));"ctoken"===I?(v||m.push(an(r,y,h,f,e.CTOKEN_PROGRAM_ID)),m.push(Cn(r,o,y,T,i))):"spl"===I&&S?(A||m.push(n.createAssociatedTokenAccountIdempotentInstruction(r,b,h,f,n.TOKEN_PROGRAM_ID)),m.push(Cn(r,o,b,T,i,S))):"token2022"===I&&S&&(k||m.push(n.createAssociatedTokenAccountIdempotentInstruction(r,w,h,f,n.TOKEN_2022_PROGRAM_ID)),m.push(Cn(r,o,w,T,i,S)))}}return m}async function Qn(n,r,o,i,s,a,u,c=0){null!=s||(s=o);const l=await Zn(n,r,o.publicKey,i,s.publicKey,u,c);if(0===l.length)return null;const{blockhash:d}=await n.getLatestBlockhash(),p=e.dedupeSigner(s,[o]),m=e.buildAndSignTx([t.ComputeBudgetProgram.setComputeUnitLimit({units:5e5}),...l],s,d,p);return e.sendAndConfirmTx(n,m,a)}async function Jn(r,o,i,s,a=t.Keypair.generate(),u,c,l){const d=await r.getMinimumBalanceForRentExemption(n.MINT_SIZE),p=1==c?n.TOKEN_2022_PROGRAM_ID:c||n.TOKEN_PROGRAM_ID,m=await pt.createMint({feePayer:o.publicKey,mint:a.publicKey,decimals:s,authority:"secretKey"in i?i.publicKey:i,freezeAuthority:l&&"secretKey"in l?l.publicKey:null!=l?l:null,rentExemptBalance:d,tokenProgramId:p}),{blockhash:h}=await r.getLatestBlockhash(),f=e.dedupeSigner(o,[i,null!=l?l:null].filter((e=>null!=e&&"secretKey"in e))),g=e.buildAndSignTx(m,o,h,[...f,a]),y=await e.sendAndConfirmTx(r,g,u);return{mint:a.publicKey,transactionSignature:y}}var Xn={};Object.defineProperty(Xn,"__esModule",{value:1}),Xn.s16=Xn.s8=Xn.nu64be=Xn.u48be=Xn.u40be=Xn.u32be=Xn.u24be=Xn.u16be=Xn.nu64=Xn.u48=Xn.u40=Xn.u32=Xn.u24=Xn.u16=Lr=Xn.u8=Xn.offset=Xn.greedy=Xn.Constant=Xn.UTF8=Xn.CString=Xn.Blob=Xn.Boolean=Xn.BitField=Xn.BitStructure=Xn.VariantLayout=Xn.Union=Xn.UnionLayoutDiscriminator=Xn.UnionDiscriminator=Xn.Structure=Xn.Sequence=Xn.DoubleBE=Xn.Double=Xn.FloatBE=Xn.Float=Xn.NearInt64BE=Xn.NearInt64=Xn.NearUInt64BE=Xn.NearUInt64=Xn.IntBE=Xn.Int=Xn.UIntBE=Xn.UInt=Xn.OffsetLayout=Xn.GreedyCount=Xn.ExternalLayout=Xn.bindConstructorLayout=Xn.nameWithProperty=Xn.Layout=Xn.uint8ArrayToBuffer=Xn.checkUint8Array=void 0,Xn.constant=Xn.utf8=Xn.cstr=Ur=Xn.blob=Xn.unionLayoutDiscriminator=Xn.union=Xn.seq=Xn.bits=Nr=Xn.struct=Xn.f64be=Xn.f64=Xn.f32be=Xn.f32=Xn.ns64be=Xn.s48be=Xn.s40be=Xn.s32be=Xn.s24be=Xn.s16be=Xn.ns64=Xn.s48=Xn.s40=Xn.s32=Xn.s24=void 0;const er=Dn;function tr(e){if(!(e instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}function nr(e){return tr(e),er.Buffer.from(e.buffer,e.byteOffset,e.length)}Xn.checkUint8Array=tr,Xn.uint8ArrayToBuffer=nr;class rr{constructor(e,t){if(!Number.isInteger(e))throw new TypeError("span must be an integer");this.span=e,this.property=t}makeDestinationObject(){return{}}getSpan(e,t){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(e){const t=Object.create(this.constructor.prototype);return Object.assign(t,this),t.property=e,t}fromArray(e){}}function or(e,t){return t.property?e+"["+t.property+"]":e}Xn.Layout=rr,Xn.nameWithProperty=or,Xn.bindConstructorLayout=function(e,t){if("function"!=typeof e)throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(e,"layout_"))throw new Error("Class is already bound to a layout");if(!(t&&t instanceof rr))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(t,"boundConstructor_"))throw new Error("layout is already bound to a constructor");e.layout_=t,t.boundConstructor_=e,t.makeDestinationObject=()=>new e,Object.defineProperty(e.prototype,"encode",{value(e,n){return t.encode(this,e,n)},writable:1}),Object.defineProperty(e,"decode",{value:(e,n)=>t.decode(e,n),writable:1})};class ir extends rr{isCount(){throw new Error("ExternalLayout is abstract")}}Xn.ExternalLayout=ir;class sr extends ir{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 1}decode(e,t=0){tr(e);const n=e.length-t;return Math.floor(n/this.elementSpan)}encode(e,t,n){return 0}}Xn.GreedyCount=sr;class ar extends ir{constructor(e,t=0,n){if(!(e instanceof rr))throw new TypeError("layout must be a Layout");if(!Number.isInteger(t))throw new TypeError("offset must be integer or undefined");super(e.span,n||e.property),this.layout=e,this.offset=t}isCount(){return this.layout instanceof ur||this.layout instanceof cr}decode(e,t=0){return this.layout.decode(e,t+this.offset)}encode(e,t,n=0){return this.layout.encode(e,t,n+this.offset)}}Xn.OffsetLayout=ar;class ur extends rr{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t=0){return nr(e).readUIntLE(t,this.span)}encode(e,t,n=0){return nr(t).writeUIntLE(e,n,this.span),this.span}}Xn.UInt=ur;class cr extends rr{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t=0){return nr(e).readUIntBE(t,this.span)}encode(e,t,n=0){return nr(t).writeUIntBE(e,n,this.span),this.span}}Xn.UIntBE=cr;class lr extends rr{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t=0){return nr(e).readIntLE(t,this.span)}encode(e,t,n=0){return nr(t).writeIntLE(e,n,this.span),this.span}}Xn.Int=lr;class dr extends rr{constructor(e,t){if(super(e,t),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(e,t=0){return nr(e).readIntBE(t,this.span)}encode(e,t,n=0){return nr(t).writeIntBE(e,n,this.span),this.span}}Xn.IntBE=dr;const pr=Math.pow(2,32);function mr(e){const t=Math.floor(e/pr);return{hi32:t,lo32:e-t*pr}}function hr(e,t){return e*pr+t}class fr extends rr{constructor(e){super(8,e)}decode(e,t=0){const n=nr(e),r=n.readUInt32LE(t);return hr(n.readUInt32LE(t+4),r)}encode(e,t,n=0){const r=mr(e),o=nr(t);return o.writeUInt32LE(r.lo32,n),o.writeUInt32LE(r.hi32,n+4),8}}Xn.NearUInt64=fr;class gr extends rr{constructor(e){super(8,e)}decode(e,t=0){const n=nr(e);return hr(n.readUInt32BE(t),n.readUInt32BE(t+4))}encode(e,t,n=0){const r=mr(e),o=nr(t);return o.writeUInt32BE(r.hi32,n),o.writeUInt32BE(r.lo32,n+4),8}}Xn.NearUInt64BE=gr;class yr extends rr{constructor(e){super(8,e)}decode(e,t=0){const n=nr(e),r=n.readUInt32LE(t);return hr(n.readInt32LE(t+4),r)}encode(e,t,n=0){const r=mr(e),o=nr(t);return o.writeUInt32LE(r.lo32,n),o.writeInt32LE(r.hi32,n+4),8}}Xn.NearInt64=yr;class br extends rr{constructor(e){super(8,e)}decode(e,t=0){const n=nr(e);return hr(n.readInt32BE(t),n.readUInt32BE(t+4))}encode(e,t,n=0){const r=mr(e),o=nr(t);return o.writeInt32BE(r.hi32,n),o.writeUInt32BE(r.lo32,n+4),8}}Xn.NearInt64BE=br;class wr extends rr{constructor(e){super(4,e)}decode(e,t=0){return nr(e).readFloatLE(t)}encode(e,t,n=0){return nr(t).writeFloatLE(e,n),4}}Xn.Float=wr;class Ir extends rr{constructor(e){super(4,e)}decode(e,t=0){return nr(e).readFloatBE(t)}encode(e,t,n=0){return nr(t).writeFloatBE(e,n),4}}Xn.FloatBE=Ir;class Ar extends rr{constructor(e){super(8,e)}decode(e,t=0){return nr(e).readDoubleLE(t)}encode(e,t,n=0){return nr(t).writeDoubleLE(e,n),8}}Xn.Double=Ar;class kr extends rr{constructor(e){super(8,e)}decode(e,t=0){return nr(e).readDoubleBE(t)}encode(e,t,n=0){return nr(t).writeDoubleBE(e,n),8}}Xn.DoubleBE=kr;class vr extends rr{constructor(e,t,n){if(!(e instanceof rr))throw new TypeError("elementLayout must be a Layout");if(!(t instanceof ir&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let r=-1;!(t instanceof ir)&&0<e.span&&(r=t*e.span),super(r,n),this.elementLayout=e,this.count=t}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0,r=this.count;if(r instanceof ir&&(r=r.decode(e,t)),0<this.elementLayout.span)n=r*this.elementLayout.span;else{let o=0;for(;o<r;)n+=this.elementLayout.getSpan(e,t+n),++o}return n}decode(e,t=0){const n=[];let r=0,o=this.count;for(o instanceof ir&&(o=o.decode(e,t));r<o;)n.push(this.elementLayout.decode(e,t)),t+=this.elementLayout.getSpan(e,t),r+=1;return n}encode(e,t,n=0){const r=this.elementLayout,o=e.reduce(((e,o)=>e+r.encode(o,t,n+e)),0);return this.count instanceof ir&&this.count.encode(e.length,t,n),o}}Xn.Sequence=vr;class Mr extends rr{constructor(e,t,n){if(!Array.isArray(e)||!e.reduce(((e,t)=>e&&t instanceof rr),1))throw new TypeError("fields must be array of Layout instances");"boolean"==typeof t&&void 0===n&&(n=t,t=void 0);for(const t of e)if(0>t.span&&void 0===t.property)throw new Error("fields cannot contain unnamed variable-length layout");let r=-1;try{r=e.reduce(((e,t)=>e+t.getSpan()),0)}catch(e){}super(r,t),this.fields=e,this.decodePrefixes=!!n}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0;try{n=this.fields.reduce(((n,r)=>{const o=r.getSpan(e,t);return t+=o,n+o}),0)}catch(e){throw new RangeError("indeterminate span")}return n}decode(e,t=0){tr(e);const n=this.makeDestinationObject();for(const r of this.fields)if(void 0!==r.property&&(n[r.property]=r.decode(e,t)),t+=r.getSpan(e,t),this.decodePrefixes&&e.length===t)break;return n}encode(e,t,n=0){const r=n;let o=0,i=0;for(const r of this.fields){let s=r.span;if(i=0<s?s:0,void 0!==r.property){const o=e[r.property];void 0!==o&&(i=r.encode(o,t,n),0>s&&(s=r.getSpan(t,n)))}o=n,n+=s}return o+i-r}fromArray(e){const t=this.makeDestinationObject();for(const n of this.fields)void 0!==n.property&&0<e.length&&(t[n.property]=e.shift());return t}layoutFor(e){if("string"!=typeof e)throw new TypeError("property must be string");for(const t of this.fields)if(t.property===e)return t}offsetOf(e){if("string"!=typeof e)throw new TypeError("property must be string");let t=0;for(const n of this.fields){if(n.property===e)return t;0>n.span?t=-1:0<=t&&(t+=n.span)}}}Xn.Structure=Mr;class Pr{constructor(e){this.property=e}decode(e,t){throw new Error("UnionDiscriminator is abstract")}encode(e,t,n){throw new Error("UnionDiscriminator is abstract")}}Xn.UnionDiscriminator=Pr;class xr extends Pr{constructor(e,t){if(!(e instanceof ir&&e.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(t||e.property||"variant"),this.layout=e}decode(e,t){return this.layout.decode(e,t)}encode(e,t,n){return this.layout.encode(e,t,n)}}Xn.UnionLayoutDiscriminator=xr;class Tr extends rr{constructor(e,t,n){let r;if(e instanceof ur||e instanceof cr)r=new xr(new ar(e));else if(e instanceof ir&&e.isCount())r=new xr(e);else{if(!(e instanceof Pr))throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");r=e}if(void 0===t&&(t=null),!(null===t||t instanceof rr))throw new TypeError("defaultLayout must be null or a Layout");if(null!==t){if(0>t.span)throw new Error("defaultLayout must have constant span");void 0===t.property&&(t=t.replicate("content"))}let o=-1;t&&(o=t.span,0<=o&&(e instanceof ur||e instanceof cr)&&(o+=r.layout.span)),super(o,n),this.discriminator=r,this.usesPrefixDiscriminator=e instanceof ur||e instanceof cr,this.defaultLayout=t,this.registry={};let i=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(e){return i(e)},this.configGetSourceVariant=function(e){i=e.bind(this)}}getSpan(e,t=0){if(0<=this.span)return this.span;const n=this.getVariant(e,t);if(!n)throw new Error("unable to determine span for unrecognized variant");return n.getSpan(e,t)}defaultGetSourceVariant(e){if(Object.prototype.hasOwnProperty.call(e,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(e,this.defaultLayout.property))return;const t=this.registry[e[this.discriminator.property]];if(t&&(!t.layout||t.property&&Object.prototype.hasOwnProperty.call(e,t.property)))return t}else for(const t in this.registry){const n=this.registry[t];if(n.property&&Object.prototype.hasOwnProperty.call(e,n.property))return n}throw new Error("unable to infer src variant")}decode(e,t=0){let n;const r=this.discriminator,o=r.decode(e,t),i=this.registry[o];if(void 0===i){const i=this.defaultLayout;let s=0;this.usesPrefixDiscriminator&&(s=r.layout.span),n=this.makeDestinationObject(),n[r.property]=o,n[i.property]=i.decode(e,t+s)}else n=i.decode(e,t);return n}encode(e,t,n=0){const r=this.getSourceVariant(e);if(void 0===r){const r=this.discriminator,o=this.defaultLayout;let i=0;return this.usesPrefixDiscriminator&&(i=r.layout.span),r.encode(e[r.property],t,n),i+o.encode(e[o.property],t,n+i)}return r.encode(e,t,n)}addVariant(e,t,n){const r=new Sr(this,e,t,n);return this.registry[e]=r,r}getVariant(e,t=0){let n;return n=e instanceof Uint8Array?this.discriminator.decode(e,t):e,this.registry[n]}}Xn.Union=Tr;class Sr extends rr{constructor(e,t,n,r){if(!(e instanceof Tr))throw new TypeError("union must be a Union");if(!Number.isInteger(t)||0>t)throw new TypeError("variant must be a (non-negative) integer");if("string"==typeof n&&void 0===r&&(r=n,n=null),n){if(!(n instanceof rr))throw new TypeError("layout must be a Layout");if(null!==e.defaultLayout&&0<=n.span&&n.span>e.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if("string"!=typeof r)throw new TypeError("variant must have a String property")}let o=e.span;0>e.span&&(o=n?n.span:0,0<=o&&e.usesPrefixDiscriminator&&(o+=e.discriminator.layout.span)),super(o,r),this.union=e,this.variant=t,this.layout=n||null}getSpan(e,t=0){if(0<=this.span)return this.span;let n=0;this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span);let r=0;return this.layout&&(r=this.layout.getSpan(e,t+n)),n+r}decode(e,t=0){const n=this.makeDestinationObject();if(this!==this.union.getVariant(e,t))throw new Error("variant mismatch");let r=0;return this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span),this.layout?n[this.property]=this.layout.decode(e,t+r):this.property?n[this.property]=1:this.union.usesPrefixDiscriminator&&(n[this.union.discriminator.property]=this.variant),n}encode(e,t,n=0){let r=0;if(this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(e,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,t,n);let o=r;if(this.layout&&(this.layout.encode(e[this.property],t,n+r),o+=this.layout.getSpan(t,n+r),0<=this.union.span&&o>this.union.span))throw new Error("encoded variant overruns containing union");return o}fromArray(e){if(this.layout)return this.layout.fromArray(e)}}function Cr(e){return 0>e&&(e+=4294967296),e}Xn.VariantLayout=Sr;class Er extends rr{constructor(e,t,n){if(!(e instanceof ur||e instanceof cr))throw new TypeError("word must be a UInt or UIntBE layout");if("string"==typeof t&&void 0===n&&(n=t,t=0),4<e.span)throw new RangeError("word cannot exceed 32 bits");super(e.span,n),this.word=e,this.msb=!!t,this.fields=[];let r=0;this._packedSetValue=function(e){return r=Cr(e),this},this._packedGetValue=function(){return r}}decode(e,t=0){const n=this.makeDestinationObject(),r=this.word.decode(e,t);this._packedSetValue(r);for(const t of this.fields)void 0!==t.property&&(n[t.property]=t.decode(e));return n}encode(e,t,n=0){const r=this.word.decode(t,n);this._packedSetValue(r);for(const t of this.fields)if(void 0!==t.property){const n=e[t.property];void 0!==n&&t.encode(n)}return this.word.encode(this._packedGetValue(),t,n)}addField(e,t){const n=new _r(this,e,t);return this.fields.push(n),n}addBoolean(e){const t=new Or(this,e);return this.fields.push(t),t}fieldFor(e){if("string"!=typeof e)throw new TypeError("property must be string");for(const t of this.fields)if(t.property===e)return t}}Xn.BitStructure=Er;class _r{constructor(e,t,n){if(!(e instanceof Er))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(t)||0>=t)throw new TypeError("bits must be positive integer");const r=8*e.span,o=e.fields.reduce(((e,t)=>e+t.bits),0);if(t+o>r)throw new Error("bits too long for span remainder ("+(r-o)+" of "+r+" remain)");this.container=e,this.bits=t,this.valueMask=(1<<t)-1,32===t&&(this.valueMask=4294967295),this.start=o,this.container.msb&&(this.start=r-o-t),this.wordMask=Cr(this.valueMask<<this.start),this.property=n}decode(e,t){return Cr(this.container._packedGetValue()&this.wordMask)>>>this.start}encode(e){if("number"!=typeof e||!Number.isInteger(e)||e!==Cr(e&this.valueMask))throw new TypeError(or("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const t=this.container._packedGetValue(),n=Cr(e<<this.start);this.container._packedSetValue(Cr(t&~this.wordMask)|n)}}Xn.BitField=_r;class Or extends _r{constructor(e,t){super(e,1,t)}decode(e,t){return!!super.decode(e,t)}encode(e){"boolean"==typeof e&&(e=+e),super.encode(e)}}Xn.Boolean=Or;class Rr extends rr{constructor(e,t){if(!(e instanceof ir&&e.isCount()||Number.isInteger(e)&&0<=e))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let n=-1;e instanceof ir||(n=e),super(n,t),this.length=e}getSpan(e,t){let n=this.span;return 0>n&&(n=this.length.decode(e,t)),n}decode(e,t=0){let n=this.span;return 0>n&&(n=this.length.decode(e,t)),nr(e).slice(t,t+n)}encode(e,t,n){let r=this.length;if(this.length instanceof ir&&(r=e.length),!(e instanceof Uint8Array&&r===e.length))throw new TypeError(or("Blob.encode",this)+" requires (length "+r+") Uint8Array as src");if(n+r>t.length)throw new RangeError("encoding overruns Uint8Array");const o=nr(e);return nr(t).write(o.toString("hex"),n,r,"hex"),this.length instanceof ir&&this.length.encode(r,t,n),r}}Xn.Blob=Rr;class Dr extends rr{constructor(e){super(-1,e)}getSpan(e,t=0){tr(e);let n=t;for(;n<e.length&&0!==e[n];)n+=1;return 1+n-t}decode(e,t=0){const n=this.getSpan(e,t);return nr(e).slice(t,t+n-1).toString("utf-8")}encode(e,t,n=0){"string"!=typeof e&&(e=String(e));const r=er.Buffer.from(e,"utf8"),o=r.length;if(n+o>t.length)throw new RangeError("encoding overruns Buffer");const i=nr(t);return r.copy(i,n),i[n+o]=0,o+1}}Xn.CString=Dr;class Br extends rr{constructor(e,t){if("string"==typeof e&&void 0===t&&(t=e,e=void 0),void 0===e)e=-1;else if(!Number.isInteger(e))throw new TypeError("maxSpan must be an integer");super(-1,t),this.maxSpan=e}getSpan(e,t=0){return tr(e),e.length-t}decode(e,t=0){const n=this.getSpan(e,t);if(0<=this.maxSpan&&this.maxSpan<n)throw new RangeError("text length exceeds maxSpan");return nr(e).slice(t,t+n).toString("utf-8")}encode(e,t,n=0){"string"!=typeof e&&(e=String(e));const r=er.Buffer.from(e,"utf8"),o=r.length;if(0<=this.maxSpan&&this.maxSpan<o)throw new RangeError("text length exceeds maxSpan");if(n+o>t.length)throw new RangeError("encoding overruns Buffer");return r.copy(nr(t),n),o}}Xn.UTF8=Br;class Kr extends rr{constructor(e,t){super(0,t),this.value=e}decode(e,t){return this.value}encode(e,t,n){return 0}}Xn.Constant=Kr,Xn.greedy=(e,t)=>new sr(e,t),Xn.offset=(e,t,n)=>new ar(e,t,n);var Lr=Xn.u8=e=>new ur(1,e);Xn.u16=e=>new ur(2,e),Xn.u24=e=>new ur(3,e),Xn.u32=e=>new ur(4,e),Xn.u40=e=>new ur(5,e),Xn.u48=e=>new ur(6,e),Xn.nu64=e=>new fr(e),Xn.u16be=e=>new cr(2,e),Xn.u24be=e=>new cr(3,e),Xn.u32be=e=>new cr(4,e),Xn.u40be=e=>new cr(5,e),Xn.u48be=e=>new cr(6,e),Xn.nu64be=e=>new gr(e),Xn.s8=e=>new lr(1,e),Xn.s16=e=>new lr(2,e),Xn.s24=e=>new lr(3,e),Xn.s32=e=>new lr(4,e),Xn.s40=e=>new lr(5,e),Xn.s48=e=>new lr(6,e),Xn.ns64=e=>new yr(e),Xn.s16be=e=>new dr(2,e),Xn.s24be=e=>new dr(3,e),Xn.s32be=e=>new dr(4,e),Xn.s40be=e=>new dr(5,e),Xn.s48be=e=>new dr(6,e),Xn.ns64be=e=>new br(e),Xn.f32=e=>new wr(e),Xn.f32be=e=>new Ir(e),Xn.f64=e=>new Ar(e),Xn.f64be=e=>new kr(e);var Nr=Xn.struct=(e,t,n)=>new Mr(e,t,n);Xn.bits=(e,t,n)=>new Er(e,t,n),Xn.seq=(e,t,n)=>new vr(e,t,n),Xn.union=(e,t,n)=>new Tr(e,t,n),Xn.unionLayoutDiscriminator=(e,t)=>new xr(e,t);var Ur=Xn.blob=(e,t)=>new Rr(e,t);Xn.cstr=e=>new Dr(e),Xn.utf8=(e,t)=>new Br(e,t),Xn.constant=(e,t)=>new Kr(e,t);const Wr=r.struct([r.publicKey("updateAuthority"),r.publicKey("mint"),r.vecU8("name"),r.vecU8("symbol"),r.vecU8("uri"),r.vec(r.struct([r.vecU8("key"),r.vecU8("value")]),"additionalMetadata")]),qr=Nr([Lr("version"),Lr("cmintDecompressed"),(()=>{const e=Ur(32,"splMint"),{encode:n,decode:r}=(e=>({decode:e.decode.bind(e),encode:e.encode.bind(e)}))(e),o=e;return o.decode=(e,n)=>{const o=r(e,n);return new t.PublicKey(o)},o.encode=(e,t,r)=>{const o=e.toBuffer();return n(o,t,r)},o})()]),Gr=qr.span;function Vr(e,t,n){return e===exports.ExtensionType.TokenMetadata?function(e,t){let n=t;n+=32,n+=32,n+=4+e.readUInt32LE(n),n+=4+e.readUInt32LE(n),n+=4+e.readUInt32LE(n);const r=e.readUInt32LE(n);n+=4;for(let t=0;t<r;t++)n+=4+e.readUInt32LE(n),n+=4+e.readUInt32LE(n);return n-t}(t,n):t.length-n}function Fr(e){const t=e instanceof w?e:w.from(e);let r=0;const o=n.MintLayout.decode(t.slice(r,r+n.MINT_SIZE));r+=n.MINT_SIZE;const i=qr.decode(t.slice(r,r+Gr));r+=Gr;const s=1===t.readUInt8(r);r+=1;let a=null;if(s){const e=t.readUInt32LE(r);r+=4,a=[];for(let n=0;n<e;n++){const e=t.readUInt8(r);r+=1;const n=Vr(e,t,r),o=t.slice(r,r+n);r+=n,a.push({extensionType:e,data:o})}}return{base:{mintAuthority:1===o.mintAuthorityOption?o.mintAuthority:null,supply:o.supply,decimals:o.decimals,isInitialized:o.isInitialized,freezeAuthority:1===o.freezeAuthorityOption?o.freezeAuthority:null},mintContext:{version:i.version,cmintDecompressed:0!==i.cmintDecompressed,splMint:i.splMint},extensions:a}}var zr;function jr(e){try{const t=w.from(e);if(t.length<80)return null;const n=Wr.decode(t),r=n.updateAuthority.toBuffer().every((e=>0===e))?void 0:n.updateAuthority,o=w.from(n.name).toString("utf-8"),i=w.from(n.symbol).toString("utf-8"),s=w.from(n.uri).toString("utf-8");let a;return n.additionalMetadata&&n.additionalMetadata.length>0&&(a=n.additionalMetadata.map((e=>({key:w.from(e.key).toString("utf-8"),value:w.from(e.value).toString("utf-8")})))),{updateAuthority:r,mint:n.mint,name:o,symbol:i,uri:s,additionalMetadata:a}}catch(e){return console.error("Failed to decode TokenMetadata:",e),null}}exports.ExtensionType=void 0,(zr=exports.ExtensionType||(exports.ExtensionType={}))[zr.TokenMetadata=19]="TokenMetadata";const $r=jr;function Yr(e){if(!e)return null;const t=e.find((e=>e.extensionType===exports.ExtensionType.TokenMetadata));return t?$r(t.data):null}async function Zr(t,r,o,i){var s;if(!i){const[i,s,a]=await Promise.allSettled([Zr(t,r,o,n.TOKEN_PROGRAM_ID),Zr(t,r,o,n.TOKEN_2022_PROGRAM_ID),Zr(t,r,o,e.CTOKEN_PROGRAM_ID)]);if("fulfilled"===i.status)return i.value;if("fulfilled"===s.status)return s.value;if("fulfilled"===a.status)return a.value;throw new Error(`Mint not found: ${r.toString()}. Tried TOKEN_PROGRAM_ID, TOKEN_2022_PROGRAM_ID, and CTOKEN_PROGRAM_ID.`)}if(i.equals(e.CTOKEN_PROGRAM_ID)){const n=e.getDefaultAddressTreeInfo().tree,o=e.deriveAddressV2(r.toBytes(),n,e.CTOKEN_PROGRAM_ID),a=await t.getCompressedAccount(e.bn(o.toBytes()));if(!(null===(s=null==a?void 0:a.data)||void 0===s?void 0:s.data))throw new Error(`Compressed mint not found for ${r.toString()}`);const u=Fr(w.from(a.data.data)),c={address:r,mintAuthority:u.base.mintAuthority,supply:u.base.supply,decimals:u.base.decimals,isInitialized:u.base.isInitialized,freezeAuthority:u.base.freezeAuthority,tlvData:w.alloc(0)},l={treeInfo:a.treeInfo,hash:a.hash,leafIndex:a.leafIndex,proveByIndex:a.proveByIndex},d=Yr(u.extensions),p={mint:c,programId:i,merkleContext:l,mintContext:u.mintContext,tokenMetadata:d||void 0,extensions:u.extensions||void 0};if(i.equals(e.CTOKEN_PROGRAM_ID)){if(!p.merkleContext)throw new Error("Invalid compressed mint: merkleContext is required for CTOKEN_PROGRAM_ID");if(!p.mintContext)throw new Error("Invalid compressed mint: mintContext is required for CTOKEN_PROGRAM_ID")}return p}return{mint:await n.getMint(t,r,o,i),programId:i}}function Hr(e){if(!("publicKey"in e)||!("secretKey"in e))return 0;const t=e;return t.secretKey instanceof Uint8Array&&t.secretKey.length>0}function Qr(e){return Hr(e)?e.publicKey:e}async function Jr(r,o,i,s,a,u,c,l,d,p){const m=Qr(s),h=n.getAssociatedTokenAddressSync(i,m,a,l,d);return l.equals(e.CTOKEN_PROGRAM_ID)?async function(t,r,o,i,s,a,u,c=0,l=0){var d,p,m;const h=Qr(i);let f;Hr(i);let g=0;try{f=await Vn(t,s,h,o,a,e.CTOKEN_PROGRAM_ID,c,l),g=null!==(p=null===(d=f._sources)||void 0===d?void 0:d.some((e=>e.type===Kn.CTokenHot)))&&void 0!==p?p:0}catch(i){if(!(i instanceof n.TokenAccountNotFoundError||i instanceof n.TokenInvalidAccountOwnerError))throw i;await Xr(t,r,o,h,s,u),f=await Vn(t,s,h,o,a,e.CTOKEN_PROGRAM_ID,c,l),g=1}if(g||await Xr(t,r,o,h,s,u),Hr(i)){const n=null!==(m=f._sources)&&void 0!==m?m:[],d=n.some((e=>e.type===Kn.CTokenCold&&e.amount>BigInt(0))),p=c&&n.some((e=>(e.type===Kn.Spl||e.type===Kn.Token2022)&&e.amount>BigInt(0)));if(d||p){if(!(i.secretKey instanceof Uint8Array)||0===i.secretKey.length)throw new Error("Owner must be a valid Signer with secretKey to auto-load");await Qn(t,s,i,o,r,u,void 0,c),f=await Vn(t,s,h,o,a,e.CTOKEN_PROGRAM_ID,c,l)}}const y=f.parsed;if(!y.mint.equals(o))throw new n.TokenInvalidMintError;if(!y.owner.equals(h))throw new n.TokenInvalidOwnerError;return f}(r,o,i,s,h,u,c,p,a):async function(e,r,o,i,s,a,u,c,l){let d;try{d=await Gn(e,s,c,a)}catch(p){if(!(p instanceof n.TokenAccountNotFoundError||p instanceof n.TokenInvalidAccountOwnerError))throw p;try{const n=(new t.Transaction).add(sn(r.publicKey,s,i,o,a,u));await t.sendAndConfirmTransaction(e,n,[r],l)}catch(e){}d=await Gn(e,s,c,a)}const p=d.parsed;if(!p.mint.equals(o))throw new n.TokenInvalidMintError;if(!p.owner.equals(i))throw new n.TokenInvalidOwnerError;return d}(r,o,i,m,h,l,d,u,c)}async function Xr(n,r,o,i,s,a){try{const u=an(r.publicKey,s,i,o,e.CTOKEN_PROGRAM_ID),{blockhash:c}=await n.getLatestBlockhash(),l=e.buildAndSignTx([t.ComputeBudgetProgram.setComputeUnitLimit({units:2e5}),u],r,c,[]);await e.sendAndConfirmTx(n,l,a)}catch(e){}}r.struct([r.array(r.u8(),32,"a"),r.array(r.u8(),64,"b"),r.array(r.u8(),32,"c")]);const eo=r.struct([r.u16("rootIndex"),r.bool("proveByIndex"),r.u8("merkleTreePubkeyIndex"),r.u8("queuePubkeyIndex"),r.u32("leafIndex")]);async function to(t,n,r,o,i){i=i||await pt.getMintProgramId(r,t);const s=await pt.createTokenPool({feePayer:n.publicKey,mint:r,tokenProgramId:i}),{blockhash:a}=await t.getLatestBlockhash(),u=e.buildAndSignTx([s],n,a);return await e.sendAndConfirmTx(t,u,o)}r.struct([eo.replicate("treeInfo"),r.option(r.array(r.u8(),32),"address"),r.option(r.u64(),"lamports"),r.u8("outputStateTreeIndex")]);const no=to;async function ro(t,n,r,o,i,s){s=s||await pt.getMintProgramId(r,t);const a=[],u=(await Ie(t,r)).slice(0,4),c=[];for(let e=0;e<u.length;e++)u[e].isInitialized||c.push(e);for(let e=0;e<o&&!(e>=c.length);e++)a.push(await pt.addTokenPool({mint:r,feePayer:n.publicKey,tokenProgramId:s,poolIndex:c[e]}));const{blockhash:l}=await t.getLatestBlockhash(),d=e.buildAndSignTx(a,n,l);return await e.sendAndConfirmTx(t,d,i)}const oo=ro;function io(e){return!Array.isArray(e)}const so=io;exports.ADD_TOKEN_POOL_DISCRIMINATOR=he,exports.APPROVE_DISCRIMINATOR=pe,exports.BATCH_COMPRESS_DISCRIMINATOR=ce,exports.COMPRESSED_MINT_SEED=ht,exports.COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR=de,exports.CPI_AUTHORITY_SEED=se,exports.CREATE_TOKEN_POOL_DISCRIMINATOR=ae,exports.CompressedTokenInstructionDataApproveLayout=Xe,exports.CompressedTokenInstructionDataRevokeLayout=et,exports.CompressedTokenInstructionDataTransferLayout=Le,exports.CompressedTokenProgram=pt,exports.CpiContextLayout=Ke,exports.DECOMPRESS_ACCOUNTS_IDEMPOTENT_DISCRIMINATOR=fe,exports.DelegatedTransferLayout=Be,exports.ERROR_NO_ACCOUNTS_FOUND=Pe,exports.IDL={version:"1.2.0",name:"light_compressed_token",instructions:[{name:"createTokenPool",docs:["This instruction creates a token pool for a given mint. Every spl mint","can have one token pool. When a token is compressed the tokens are","transferrred to the token pool, and their compressed equivalent is","minted into a Merkle tree."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"tokenPoolPda",isMut:1,isSigner:0},{name:"systemProgram",isMut:0,isSigner:0},{name:"mint",isMut:1,isSigner:0},{name:"tokenProgram",isMut:0,isSigner:0},{name:"cpiAuthorityPda",isMut:0,isSigner:0}],args:[]},{name:"addTokenPool",docs:["This instruction creates an additional token pool for a given mint.","The maximum number of token pools per mint is 5."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"tokenPoolPda",isMut:1,isSigner:0},{name:"existingTokenPoolPda",isMut:0,isSigner:0},{name:"systemProgram",isMut:0,isSigner:0},{name:"mint",isMut:1,isSigner:0},{name:"tokenProgram",isMut:0,isSigner:0},{name:"cpiAuthorityPda",isMut:0,isSigner:0}],args:[{name:"tokenPoolIndex",type:"u8"}]},{name:"mintTo",docs:["Mints tokens from an spl token mint to a list of compressed accounts.","Minted tokens are transferred to a pool account owned by the compressed","token program. The instruction creates one compressed output account for","every amount and pubkey input pair. A constant amount of lamports can be","transferred to each output account to enable. A use case to add lamports","to a compressed token account is to prevent spam. This is the only way","to add lamports to a compressed token account."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"authority",isMut:0,isSigner:1},{name:"cpiAuthorityPda",isMut:0,isSigner:0},{name:"mint",isMut:1,isSigner:0},{name:"tokenPoolPda",isMut:1,isSigner:0},{name:"tokenProgram",isMut:0,isSigner:0},{name:"lightSystemProgram",isMut:0,isSigner:0},{name:"registeredProgramPda",isMut:0,isSigner:0},{name:"noopProgram",isMut:0,isSigner:0,docs:["programs"]},{name:"accountCompressionAuthority",isMut:0,isSigner:0},{name:"accountCompressionProgram",isMut:0,isSigner:0},{name:"merkleTree",isMut:1,isSigner:0},{name:"selfProgram",isMut:0,isSigner:0},{name:"systemProgram",isMut:0,isSigner:0},{name:"solPoolPda",isMut:1,isSigner:0,isOptional:1}],args:[{name:"publicKeys",type:{vec:"publicKey"}},{name:"amounts",type:{vec:"u64"}},{name:"lamports",type:{option:"u64"}}]},{name:"compressSplTokenAccount",docs:["Compresses the balance of an spl token account sub an optional remaining","amount. This instruction does not close the spl token account. To close","the account bundle a close spl account instruction in your transaction."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"authority",isMut:0,isSigner:1,docs:["Authority is verified through proof since both owner and delegate","are included in the token data hash, which is a public input to the","validity proof."]},{name:"cpiAuthorityPda",isMut:0,isSigner:0},{name:"lightSystemProgram",isMut:0,isSigner:0},{name:"registeredProgramPda",isMut:0,isSigner:0},{name:"noopProgram",isMut:0,isSigner:0},{name:"accountCompressionAuthority",isMut:0,isSigner:0},{name:"accountCompressionProgram",isMut:0,isSigner:0},{name:"selfProgram",isMut:0,isSigner:0,docs:["this program is the signer of the cpi."]},{name:"tokenPoolPda",isMut:1,isSigner:0,isOptional:1},{name:"compressOrDecompressTokenAccount",isMut:1,isSigner:0,isOptional:1},{name:"tokenProgram",isMut:0,isSigner:0,isOptional:1},{name:"systemProgram",isMut:0,isSigner:0}],args:[{name:"owner",type:"publicKey"},{name:"remainingAmount",type:{option:"u64"}},{name:"cpiContext",type:{option:{defined:"CompressedCpiContext"}}}]},{name:"transfer",docs:["Transfers compressed tokens from one account to another. All accounts","must be of the same mint. Additional spl tokens can be compressed or","decompressed. In one transaction only compression or decompression is","possible. Lamports can be transferred alongside tokens. If output token","accounts specify less lamports than inputs the remaining lamports are","transferred to an output compressed account. Signer must be owner or","delegate. If a delegated token account is transferred the delegate is","not preserved."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"authority",isMut:0,isSigner:1,docs:["Authority is verified through proof since both owner and delegate","are included in the token data hash, which is a public input to the","validity proof."]},{name:"cpiAuthorityPda",isMut:0,isSigner:0},{name:"lightSystemProgram",isMut:0,isSigner:0},{name:"registeredProgramPda",isMut:0,isSigner:0},{name:"noopProgram",isMut:0,isSigner:0},{name:"accountCompressionAuthority",isMut:0,isSigner:0},{name:"accountCompressionProgram",isMut:0,isSigner:0},{name:"selfProgram",isMut:0,isSigner:0,docs:["this program is the signer of the cpi."]},{name:"tokenPoolPda",isMut:1,isSigner:0,isOptional:1},{name:"compressOrDecompressTokenAccount",isMut:1,isSigner:0,isOptional:1},{name:"tokenProgram",isMut:0,isSigner:0,isOptional:1},{name:"systemProgram",isMut:0,isSigner:0}],args:[{name:"inputs",type:"bytes"}]},{name:"approve",docs:["Delegates an amount to a delegate. A compressed token account is either","completely delegated or not. Prior delegates are not preserved. Cannot","be called by a delegate.","The instruction creates two output accounts:","1. one account with delegated amount","2. one account with remaining(change) amount"],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"authority",isMut:0,isSigner:1,docs:["Authority is verified through proof since both owner and delegate","are included in the token data hash, which is a public input to the","validity proof."]},{name:"cpiAuthorityPda",isMut:0,isSigner:0},{name:"lightSystemProgram",isMut:0,isSigner:0},{name:"registeredProgramPda",isMut:0,isSigner:0},{name:"noopProgram",isMut:0,isSigner:0},{name:"accountCompressionAuthority",isMut:0,isSigner:0},{name:"accountCompressionProgram",isMut:0,isSigner:0},{name:"selfProgram",isMut:0,isSigner:0,docs:["this program is the signer of the cpi."]},{name:"systemProgram",isMut:0,isSigner:0}],args:[{name:"inputs",type:"bytes"}]},{name:"revoke",docs:["Revokes a delegation. The instruction merges all inputs into one output","account. Cannot be called by a delegate. Delegates are not preserved."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"authority",isMut:0,isSigner:1,docs:["Authority is verified through proof since both owner and delegate","are included in the token data hash, which is a public input to the","validity proof."]},{name:"cpiAuthorityPda",isMut:0,isSigner:0},{name:"lightSystemProgram",isMut:0,isSigner:0},{name:"registeredProgramPda",isMut:0,isSigner:0},{name:"noopProgram",isMut:0,isSigner:0},{name:"accountCompressionAuthority",isMut:0,isSigner:0},{name:"accountCompressionProgram",isMut:0,isSigner:0},{name:"selfProgram",isMut:0,isSigner:0,docs:["this program is the signer of the cpi."]},{name:"systemProgram",isMut:0,isSigner:0}],args:[{name:"inputs",type:"bytes"}]},{name:"freeze",docs:["Freezes compressed token accounts. Inputs must not be frozen. Creates as","many outputs as inputs. Balances and delegates are preserved."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"authority",isMut:0,isSigner:1},{name:"cpiAuthorityPda",isMut:0,isSigner:0},{name:"lightSystemProgram",isMut:0,isSigner:0},{name:"registeredProgramPda",isMut:0,isSigner:0},{name:"noopProgram",isMut:0,isSigner:0},{name:"accountCompressionAuthority",isMut:0,isSigner:0},{name:"accountCompressionProgram",isMut:0,isSigner:0},{name:"selfProgram",isMut:0,isSigner:0,docs:["that this program is the signer of the cpi."]},{name:"systemProgram",isMut:0,isSigner:0},{name:"mint",isMut:0,isSigner:0}],args:[{name:"inputs",type:"bytes"}]},{name:"thaw",docs:["Thaws frozen compressed token accounts. Inputs must be frozen. Creates","as many outputs as inputs. Balances and delegates are preserved."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"authority",isMut:0,isSigner:1},{name:"cpiAuthorityPda",isMut:0,isSigner:0},{name:"lightSystemProgram",isMut:0,isSigner:0},{name:"registeredProgramPda",isMut:0,isSigner:0},{name:"noopProgram",isMut:0,isSigner:0},{name:"accountCompressionAuthority",isMut:0,isSigner:0},{name:"accountCompressionProgram",isMut:0,isSigner:0},{name:"selfProgram",isMut:0,isSigner:0,docs:["that this program is the signer of the cpi."]},{name:"systemProgram",isMut:0,isSigner:0},{name:"mint",isMut:0,isSigner:0}],args:[{name:"inputs",type:"bytes"}]},{name:"burn",docs:["Burns compressed tokens and spl tokens from the pool account. Delegates","can burn tokens. The output compressed token account remains delegated.","Creates one output compressed token account."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"authority",isMut:0,isSigner:1,docs:["Authority is verified through proof since both owner and delegate","are included in the token data hash, which is a public input to the","validity proof."]},{name:"cpiAuthorityPda",isMut:0,isSigner:0},{name:"mint",isMut:1,isSigner:0},{name:"tokenPoolPda",isMut:1,isSigner:0},{name:"tokenProgram",isMut:0,isSigner:0},{name:"lightSystemProgram",isMut:0,isSigner:0},{name:"registeredProgramPda",isMut:0,isSigner:0},{name:"noopProgram",isMut:0,isSigner:0},{name:"accountCompressionAuthority",isMut:0,isSigner:0},{name:"accountCompressionProgram",isMut:0,isSigner:0},{name:"selfProgram",isMut:0,isSigner:0},{name:"systemProgram",isMut:0,isSigner:0}],args:[{name:"inputs",type:"bytes"}]},{name:"stubIdlBuild",docs:["This function is a stub to allow Anchor to include the input types in","the IDL. It should not be included in production builds nor be called in","practice."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"authority",isMut:0,isSigner:1,docs:["Authority is verified through proof since both owner and delegate","are included in the token data hash, which is a public input to the","validity proof."]},{name:"cpiAuthorityPda",isMut:0,isSigner:0},{name:"lightSystemProgram",isMut:0,isSigner:0},{name:"registeredProgramPda",isMut:0,isSigner:0},{name:"noopProgram",isMut:0,isSigner:0},{name:"accountCompressionAuthority",isMut:0,isSigner:0},{name:"accountCompressionProgram",isMut:0,isSigner:0},{name:"selfProgram",isMut:0,isSigner:0,docs:["this program is the signer of the cpi."]},{name:"tokenPoolPda",isMut:1,isSigner:0,isOptional:1},{name:"compressOrDecompressTokenAccount",isMut:1,isSigner:0,isOptional:1},{name:"tokenProgram",isMut:0,isSigner:0,isOptional:1},{name:"systemProgram",isMut:0,isSigner:0}],args:[{name:"inputs1",type:{defined:"CompressedTokenInstructionDataTransfer"}},{name:"inputs2",type:{defined:"TokenData"}}]}],types:[{name:"AccountState",type:{kind:"enum",variants:[{name:"Initialized"},{name:"Frozen"}]}},{name:"CompressedAccount",type:{kind:"struct",fields:[{name:"owner",type:"publicKey"},{name:"lamports",type:"u64"},{name:"address",type:{option:{array:["u8",32]}}},{name:"data",type:{option:{defined:"CompressedAccountData"}}}]}},{name:"CompressedAccountData",type:{kind:"struct",fields:[{name:"discriminator",type:{array:["u8",8]}},{name:"data",type:"bytes"},{name:"dataHash",type:{array:["u8",32]}}]}},{name:"CompressedCpiContext",type:{kind:"struct",fields:[{name:"setContext",docs:["Is set by the program that is invoking the CPI to signal that is should","set the cpi context."],type:"bool"},{name:"firstSetContext",docs:["Is set to wipe the cpi context since someone could have set it before","with unrelated data."],type:"bool"},{name:"cpiContextAccountIndex",docs:["Index of cpi context account in remaining accounts."],type:"u8"}]}},{name:"CompressedProof",type:{kind:"struct",fields:[{name:"a",type:{array:["u8",32]}},{name:"b",type:{array:["u8",64]}},{name:"c",type:{array:["u8",32]}}]}},{name:"CompressedTokenInstructionDataTransfer",type:{kind:"struct",fields:[{name:"proof",type:{option:{defined:"CompressedProof"}}},{name:"mint",type:"publicKey"},{name:"delegatedTransfer",docs:["Is required if the signer is delegate,","-> delegate is authority account,","owner = Some(owner) is the owner of the token account."],type:{option:{defined:"DelegatedTransfer"}}},{name:"inputTokenDataWithContext",type:{vec:{defined:"InputTokenDataWithContext"}}},{name:"outputCompressedAccounts",type:{vec:{defined:"PackedTokenTransferOutputData"}}},{name:"isCompress",type:"bool"},{name:"compressOrDecompressAmount",type:{option:"u64"}},{name:"cpiContext",type:{option:{defined:"CompressedCpiContext"}}},{name:"lamportsChangeAccountMerkleTreeIndex",type:{option:"u8"}}]}},{name:"CompressedTokenInstructionDataRevoke",type:{kind:"struct",fields:[{name:"proof",type:{option:{defined:"CompressedProof"}}},{name:"mint",type:"publicKey"},{name:"inputTokenDataWithContext",type:{vec:{defined:"InputTokenDataWithContext"}}},{name:"cpiContext",type:{option:{defined:"CompressedCpiContext"}}},{name:"outputAccountMerkleTreeIndex",type:"u8"}]}},{name:"CompressedTokenInstructionDataApprove",type:{kind:"struct",fields:[{name:"proof",type:{option:{defined:"CompressedProof"}}},{name:"mint",type:"publicKey"},{name:"inputTokenDataWithContext",type:{vec:{defined:"InputTokenDataWithContext"}}},{name:"cpiContext",type:{option:{defined:"CompressedCpiContext"}}},{name:"delegate",type:"publicKey"},{name:"delegatedAmount",type:"u64"},{name:"delegateMerkleTreeIndex",type:"u8"},{name:"changeAccountMerkleTreeIndex",type:"u8"},{name:"delegateLamports",type:{option:"u64"}}]}},{name:"DelegatedTransfer",docs:["Struct to provide the owner when the delegate is signer of the transaction."],type:{kind:"struct",fields:[{name:"owner",type:"publicKey"},{name:"delegateChangeAccountIndex",docs:["Index of change compressed account in output compressed accounts. In","case that the delegate didn't spend the complete delegated compressed","account balance the change compressed account will be delegated to her","as well."],type:{option:"u8"}}]}},{name:"InputTokenDataWithContext",type:{kind:"struct",fields:[{name:"amount",type:"u64"},{name:"delegateIndex",type:{option:"u8"}},{name:"merkleContext",type:{defined:"PackedMerkleContext"}},{name:"rootIndex",type:"u16"},{name:"lamports",type:{option:"u64"}},{name:"tlv",docs:["Placeholder for TokenExtension tlv data (unimplemented)"],type:{option:"bytes"}}]}},{name:"InstructionDataInvoke",type:{kind:"struct",fields:[{name:"proof",type:{option:{defined:"CompressedProof"}}},{name:"inputCompressedAccountsWithMerkleContext",type:{vec:{defined:"PackedCompressedAccountWithMerkleContext"}}},{name:"outputCompressedAccounts",type:{vec:{defined:"OutputCompressedAccountWithPackedContext"}}},{name:"relayFee",type:{option:"u64"}},{name:"newAddressParams",type:{vec:{defined:"NewAddressParamsPacked"}}},{name:"compressOrDecompressLamports",type:{option:"u64"}},{name:"isCompress",type:"bool"}]}},{name:"InstructionDataInvokeCpi",type:{kind:"struct",fields:[{name:"proof",type:{option:{defined:"CompressedProof"}}},{name:"newAddressParams",type:{vec:{defined:"NewAddressParamsPacked"}}},{name:"inputCompressedAccountsWithMerkleContext",type:{vec:{defined:"PackedCompressedAccountWithMerkleContext"}}},{name:"outputCompressedAccounts",type:{vec:{defined:"OutputCompressedAccountWithPackedContext"}}},{name:"relayFee",type:{option:"u64"}},{name:"compressOrDecompressLamports",type:{option:"u64"}},{name:"isCompress",type:"bool"},{name:"cpiContext",type:{option:{defined:"CompressedCpiContext"}}}]}},{name:"MerkleTreeSequenceNumber",type:{kind:"struct",fields:[{name:"pubkey",type:"publicKey"},{name:"seq",type:"u64"}]}},{name:"NewAddressParamsPacked",type:{kind:"struct",fields:[{name:"seed",type:{array:["u8",32]}},{name:"addressQueueAccountIndex",type:"u8"},{name:"addressMerkleTreeAccountIndex",type:"u8"},{name:"addressMerkleTreeRootIndex",type:"u16"}]}},{name:"OutputCompressedAccountWithPackedContext",type:{kind:"struct",fields:[{name:"compressedAccount",type:{defined:"CompressedAccount"}},{name:"merkleTreeIndex",type:"u8"}]}},{name:"PackedCompressedAccountWithMerkleContext",type:{kind:"struct",fields:[{name:"compressedAccount",type:{defined:"CompressedAccount"}},{name:"merkleContext",type:{defined:"PackedMerkleContext"}},{name:"rootIndex",docs:["Index of root used in inclusion validity proof."],type:"u16"},{name:"readOnly",docs:["Placeholder to mark accounts read-only unimplemented set to false."],type:"bool"}]}},{name:"PackedMerkleContext",type:{kind:"struct",fields:[{name:"merkleTreePubkeyIndex",type:"u8"},{name:"queuePubkeyIndex",type:"u8"},{name:"leafIndex",type:"u32"},{name:"proveByIndex",type:"bool"}]}},{name:"PackedTokenTransferOutputData",type:{kind:"struct",fields:[{name:"owner",type:"publicKey"},{name:"amount",type:"u64"},{name:"lamports",type:{option:"u64"}},{name:"merkleTreeIndex",type:"u8"},{name:"tlv",docs:["Placeholder for TokenExtension tlv data (unimplemented)"],type:{option:"bytes"}}]}},{name:"PublicTransactionEvent",type:{kind:"struct",fields:[{name:"inputCompressedAccountHashes",type:{vec:{array:["u8",32]}}},{name:"outputCompressedAccountHashes",type:{vec:{array:["u8",32]}}},{name:"outputCompressedAccounts",type:{vec:{defined:"OutputCompressedAccountWithPackedContext"}}},{name:"outputLeafIndices",type:{vec:"u32"}},{name:"sequenceNumbers",type:{vec:{defined:"MerkleTreeSequenceNumber"}}},{name:"relayFee",type:{option:"u64"}},{name:"isCompress",type:"bool"},{name:"compressOrDecompressLamports",type:{option:"u64"}},{name:"pubkeyArray",type:{vec:"publicKey"}},{name:"message",type:{option:"bytes"}}]}},{name:"QueueIndex",type:{kind:"struct",fields:[{name:"queueId",docs:["Id of queue in queue account."],type:"u8"},{name:"index",docs:["Index of compressed account hash in queue."],type:"u16"}]}},{name:"TokenData",type:{kind:"struct",fields:[{name:"mint",docs:["The mint associated with this account"],type:"publicKey"},{name:"owner",docs:["The owner of this account."],type:"publicKey"},{name:"amount",docs:["The amount of tokens this account holds."],type:"u64"},{name:"delegate",docs:["If `delegate` is `Some` then `delegated_amount` represents","the amount authorized by the delegate"],type:{option:"publicKey"}},{name:"state",docs:["The account's state"],type:{defined:"AccountState"}},{name:"tlv",docs:["Placeholder for TokenExtension tlv data (unimplemented)"],type:{option:"bytes"}}]}}],errors:[{code:6e3,name:"PublicKeyAmountMissmatch",msg:"public keys and amounts must be of same length"},{code:6001,name:"ComputeInputSumFailed",msg:"ComputeInputSumFailed"},{code:6002,name:"ComputeOutputSumFailed",msg:"ComputeOutputSumFailed"},{code:6003,name:"ComputeCompressSumFailed",msg:"ComputeCompressSumFailed"},{code:6004,name:"ComputeDecompressSumFailed",msg:"ComputeDecompressSumFailed"},{code:6005,name:"SumCheckFailed",msg:"SumCheckFailed"},{code:6006,name:"DecompressRecipientUndefinedForDecompress",msg:"DecompressRecipientUndefinedForDecompress"},{code:6007,name:"CompressedPdaUndefinedForDecompress",msg:"CompressedPdaUndefinedForDecompress"},{code:6008,name:"DeCompressAmountUndefinedForDecompress",msg:"DeCompressAmountUndefinedForDecompress"},{code:6009,name:"CompressedPdaUndefinedForCompress",msg:"CompressedPdaUndefinedForCompress"},{code:6010,name:"DeCompressAmountUndefinedForCompress",msg:"DeCompressAmountUndefinedForCompress"},{code:6011,name:"DelegateSignerCheckFailed",msg:"DelegateSignerCheckFailed"},{code:6012,name:"MintTooLarge",msg:"Minted amount greater than u64::MAX"},{code:6013,name:"SplTokenSupplyMismatch",msg:"SplTokenSupplyMismatch"},{code:6014,name:"HeapMemoryCheckFailed",msg:"HeapMemoryCheckFailed"},{code:6015,name:"InstructionNotCallable",msg:"The instruction is not callable"},{code:6016,name:"ArithmeticUnderflow",msg:"ArithmeticUnderflow"},{code:6017,name:"HashToFieldError",msg:"HashToFieldError"},{code:6018,name:"InvalidAuthorityMint",msg:"Expected the authority to be also a mint authority"},{code:6019,name:"InvalidFreezeAuthority",msg:"Provided authority is not the freeze authority"},{code:6020,name:"InvalidDelegateIndex"},{code:6021,name:"TokenPoolPdaUndefined"},{code:6022,name:"IsTokenPoolPda",msg:"Compress or decompress recipient is the same account as the token pool pda."},{code:6023,name:"InvalidTokenPoolPda"},{code:6024,name:"NoInputTokenAccountsProvided"},{code:6025,name:"NoInputsProvided"},{code:6026,name:"MintHasNoFreezeAuthority"},{code:6027,name:"MintWithInvalidExtension"},{code:6028,name:"InsufficientTokenAccountBalance",msg:"The token account balance is less than the remaining amount."},{code:6029,name:"InvalidTokenPoolBump",msg:"Max number of token pools reached."},{code:6030,name:"FailedToDecompress"},{code:6031,name:"FailedToBurnSplTokensFromTokenPool"},{code:6032,name:"NoMatchingBumpFound"}]},exports.MINT_TO_DISCRIMINATOR=ue,exports.POOL_SEED=ie,exports.REVOKE_DISCRIMINATOR=me,exports.SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE=1461600,exports.TRANSFER_DISCRIMINATOR=le,exports._getOrCreateAtaInterface=Jr,exports.addSplInterfaces=ro,exports.addTokenPoolAccountsLayout=je,exports.addTokenPools=oo,exports.approve=async function(n,r,o,i,s,a,u){i=e.bn(i);const c=await n.getCompressedTokenAccountsByOwner(s.publicKey,{mint:o}),[l]=xe(c.items,i),d=await n.getValidityProofV0(l.map((e=>({hash:e.compressedAccount.hash,tree:e.compressedAccount.treeInfo.tree,queue:e.compressedAccount.treeInfo.queue})))),p=await pt.approve({payer:r.publicKey,inputCompressedTokenAccounts:l,toAddress:a,amount:i,recentInputStateRootIndices:d.rootIndices,recentValidityProof:d.compressedProof}),{blockhash:m}=await n.getLatestBlockhash(),h=e.dedupeSigner(r,[s]),f=e.buildAndSignTx([t.ComputeBudgetProgram.setComputeUnitLimit({units:35e4}),p],r,m,h);return e.sendAndConfirmTx(n,f,u)},exports.approveAccountsLayout=Ze,exports.approveAndMintTo=async function(r,o,i,s,a,u,c,l,d){c=null!=c?c:e.selectStateTreeInfo(await r.getStateTreeInfos()),l=null!=l?l:ve(await Ie(r,i));const p=await n.getOrCreateAssociatedTokenAccount(r,o,i,a.publicKey,void 0,void 0,d,l.tokenProgram),m=await pt.approveAndMintTo({feePayer:o.publicKey,mint:i,authority:a.publicKey,authorityTokenAccount:p.address,amount:u,toPubkey:s,outputStateTreeInfo:c,tokenPoolInfo:l}),{blockhash:h}=await r.getLatestBlockhash(),f=e.dedupeSigner(o,[a]),g=e.buildAndSignTx([t.ComputeBudgetProgram.setComputeUnitLimit({units:15e4+2e4*e.toArray(u).length}),...m],o,h,f);return await e.sendAndConfirmTx(r,g,d)},exports.batchCompressLayout=Ue,exports.calculateCompressibleLoadComputeUnits=function(e,t){let n=5e4;return t&&(n+=1e5),n+=3e4*e,n},exports.checkMint=_e,exports.checkSplInterfaceInfo=we,exports.checkTokenPoolInfo=function(e,t){return we(ye(e),t)},exports.compress=async function(n,r,o,i,s,a,u,c,l,d){c=null!=c?c:e.selectStateTreeInfo(await n.getStateTreeInfos()),l=null!=l?l:ve(await Ie(n,o));const p=await pt.compress({payer:r.publicKey,owner:s.publicKey,source:a,toAddress:u,amount:i,mint:o,outputStateTreeInfo:c,tokenPoolInfo:l}),m=await n.getLatestBlockhash(),h=e.dedupeSigner(r,[s]),f=e.buildAndSignTx([t.ComputeBudgetProgram.setComputeUnitLimit({units:13e4+2e4*e.toArray(i).length}),p],r,m.blockhash,h);return await e.sendAndConfirmTx(n,f,d,m)},exports.compressSplTokenAccount=async function(n,r,o,i,s,a,u,c,l){u=null!=u?u:e.selectStateTreeInfo(await n.getStateTreeInfos()),c=null!=c?c:ve(await Ie(n,o));const d=await pt.compressSplTokenAccount({feePayer:r.publicKey,authority:i.publicKey,tokenAccount:s,mint:o,remainingAmount:a,outputStateTreeInfo:u,tokenPoolInfo:c}),p=await n.getLatestBlockhash(),m=e.dedupeSigner(r,[i]),h=e.buildAndSignTx([t.ComputeBudgetProgram.setComputeUnitLimit({units:15e4}),d],r,p.blockhash,m);return await e.sendAndConfirmTx(n,h,l,p)},exports.compressSplTokenAccountInstructionDataLayout=We,exports.convertTokenDataToAccount=Nn,exports.createAssociatedCTokenAccountIdempotentInstruction=tn,exports.createAssociatedCTokenAccountInstruction=en,exports.createAssociatedTokenAccountInterfaceIdempotentInstruction=an,exports.createAssociatedTokenAccountInterfaceInstruction=sn,exports.createAtaInterface=async function(n,r,o,i,s=0,a,u=e.CTOKEN_PROGRAM_ID,c,l){const d=null!=c?c:nn(u),p=jn(o,i,s,u,d),m=sn(r.publicKey,p,i,o,u,d,l);if(u.equals(e.CTOKEN_PROGRAM_ID)){const{blockhash:o}=await n.getLatestBlockhash(),i=e.buildAndSignTx([t.ComputeBudgetProgram.setComputeUnitLimit({units:3e4}),m],r,o,[]);await e.sendAndConfirmTx(n,i,a)}else{const e=(new t.Transaction).add(m);await t.sendAndConfirmTransaction(n,e,[r],a)}return p},exports.createAtaInterfaceIdempotent=async function(n,r,o,i,s=0,a,u=e.CTOKEN_PROGRAM_ID,c,l){const d=null!=c?c:nn(u),p=jn(o,i,s,u,d),m=an(r.publicKey,p,i,o,u,d,l);if(u.equals(e.CTOKEN_PROGRAM_ID)){const{blockhash:o}=await n.getLatestBlockhash(),i=e.buildAndSignTx([t.ComputeBudgetProgram.setComputeUnitLimit({units:3e4}),m],r,o,[]);await e.sendAndConfirmTx(n,i,a)}else{const e=(new t.Transaction).add(m);await t.sendAndConfirmTransaction(n,e,[r],a)}return p},exports.createAtaInterfaceIdempotentInstruction=un,exports.createCTokenTransferInstruction=mn,exports.createCompressCtoken=function(e,t,n,r,o){return{mode:gn,amount:e,mint:t,sourceOrRecipient:n,authority:r,poolAccountIndex:o,poolIndex:0,bump:0,decimals:0}},exports.createDecompressInterfaceInstruction=Cn,exports.createDecompressOutputState=dt,exports.createDecompressSpl=function(e,t,n,r,o,i){return{mode:yn,amount:e,mint:t,sourceOrRecipient:n,authority:0,poolAccountIndex:r,poolIndex:o,bump:i,decimals:0}},exports.createLoadAccountsParams=async function(t,n,r,o=[],i=[],s){let a=null;const u=o.filter((e=>void 0!==e.info.loadContext));if(u.length>0){const n=u.map((e=>({hash:e.info.loadContext.hash,tree:e.info.loadContext.treeInfo.tree,queue:e.info.loadContext.treeInfo.queue}))),o=await t.getValidityProofV0(n,[]),i=u.map((e=>{if("cTokenData"===e.accountType){if(!e.tokenVariant)throw new Error('tokenVariant is required when accountType is "cTokenData"');return{key:"cTokenData",data:{variant:{[e.tokenVariant]:{}},tokenData:e.info.parsed},treeInfo:e.info.loadContext.treeInfo}}return{key:e.accountType,data:e.info.parsed,treeInfo:e.info.loadContext.treeInfo}})),s=u.map((e=>e.address)),c=u.map((e=>e.info.loadContext.treeInfo)),l=await e.packDecompressAccountsIdempotent(r,{compressedProof:o.compressedProof,treeInfos:c},i,s);a={proofOption:l.proofOption,compressedAccounts:l.compressedAccounts,systemAccountsOffset:l.systemAccountsOffset,remainingAccounts:l.remainingAccounts}}const c=[];for(const e of i){const r=await Hn(t,n,e,s);c.push(...r)}return{decompressParams:a,ataInstructions:c}},exports.createLoadAtaInstructions=Zn,exports.createLoadAtaInstructionsFromInterface=Hn,exports.createMint=Jn,exports.createMintInstruction=Ut,exports.createMintInterface=async function(r,o,i,s,a,u=t.Keypair.generate(),c,l=e.CTOKEN_PROGRAM_ID,d,p,m){if(l.equals(n.TOKEN_PROGRAM_ID)||l.equals(n.TOKEN_2022_PROGRAM_ID))return Jn(r,o,i,a,u,c,l,s);if(!("secretKey"in i))throw new Error("mintAuthority must be a Signer for compressed token mints");if(m&&!m.tree.equals(e.getDefaultAddressTreeInfo().tree))throw new Error(`addressTreeInfo ${null==m?void 0:m.tree.toString()} must be the default address tree info: ${e.getDefaultAddressTreeInfo().tree.toString()}`);const h=s&&"secretKey"in s?s.publicKey:s;m=null!=m?m:e.getBatchAddressTreeInfo(),p=null!=p?p:e.selectStateTreeInfo(await r.getStateTreeInfos());const f=mt(u.publicKey,m),g=await r.getValidityProofV2([],[{address:Uint8Array.from(f),treeInfo:m}],e.DerivationMode.standard),y=Ut(u.publicKey,a,i.publicKey,h,o.publicKey,g,m,p,d),b=e.dedupeSigner(o,[u,i]),{blockhash:w}=await r.getLatestBlockhash(),I=e.buildAndSignTx([t.ComputeBudgetProgram.setComputeUnitLimit({units:5e5}),y],o,w,b),A=await e.sendAndConfirmTx(r,I);return console.log("txId",A),{mint:ft(u.publicKey)[0],transactionSignature:A}},exports.createMintToCompressedInstruction=ln,exports.createMintToInstruction=cn,exports.createMintToInterfaceInstruction=dn,exports.createRemoveMetadataKeyInstruction=jt,exports.createSplInterface=to,exports.createTokenMetadata=function(e,t,n,r,o=null){return{name:e,symbol:t,uri:n,updateAuthority:null!=r?r:null,additionalMetadata:null!=o?o:null}},exports.createTokenPool=no,exports.createTokenPoolAccountsLayout=ze,exports.createTokenProgramLookupTable=async function(t,n,r,o,i){const s=await t.getSlot("finalized"),{instructions:a,address:u}=await pt.createTokenProgramLookupTable({payer:n.publicKey,authority:r.publicKey,mints:o,remainingAccounts:i,recentSlot:s}),c=e.dedupeSigner(n,[r]),l=[];for(const r of a){const o=await t.getLatestBlockhash(),i=e.buildAndSignTx([r],n,o.blockhash,c),s=await e.sendAndConfirmTx(t,i,{commitment:"finalized"},o);l.push(s)}return{txIds:l,address:u}},exports.createTransferInterfaceInstruction=hn,exports.createTransferOutputState=lt,exports.createUpdateFreezeAuthorityInstruction=Gt,exports.createUpdateMetadataAuthorityInstruction=zt,exports.createUpdateMetadataFieldInstruction=Ft,exports.createUpdateMintAuthorityInstruction=qt,exports.createWrapInstruction=$n,exports.decodeApproveInstructionData=function(e){const t=Xe.decode(e.subarray(pe.length));return Object.assign(Object.assign({},t),{proof:nt(t.proof)?null:t.proof})},exports.decodeBatchCompressInstructionData=function(e){return Ue.decode(e.subarray(ce.length+4))},exports.decodeCompressSplTokenAccountInstructionData=function(e){const t=We.decode(e.subarray(de.length));return{owner:t.owner,remainingAmount:t.remainingAmount,cpiContext:t.cpiContext}},exports.decodeMintToInstructionData=function(e){return Ne.decode(e.subarray(ue.length))},exports.decodeRevokeInstructionData=function(e){const t=et.decode(e.subarray(me.length));return Object.assign(Object.assign({},t),{proof:nt(t.proof)?null:t.proof})},exports.decodeTokenMetadata=jr,exports.decodeTransferInstructionData=function(e){return Le.decode(e.slice(le.length+4))},exports.decompress=async function(n,r,o,i,s,a,u,c){i=e.bn(i);const l=await n.getCompressedTokenAccountsByOwner(s.publicKey,{mint:o}),[d]=Te(l.items,i),p=await n.getValidityProofV0(d.map((e=>({hash:e.compressedAccount.hash,tree:e.compressedAccount.treeInfo.tree,queue:e.compressedAccount.treeInfo.queue})))),m=Me(u=null!=u?u:await Ie(n,o),i),h=await pt.decompress({payer:r.publicKey,inputCompressedTokenAccounts:d,toAddress:a,amount:i,tokenPoolInfos:m,recentInputStateRootIndices:p.rootIndices,recentValidityProof:p.compressedProof}),{blockhash:f}=await n.getLatestBlockhash(),g=e.dedupeSigner(r,[s]),y=e.buildAndSignTx([t.ComputeBudgetProgram.setComputeUnitLimit({units:35e4}),h],r,f,g);return await e.sendAndConfirmTx(n,y,c)},exports.decompressDelegated=async function(n,r,o,i,s,a,u,c){i=e.bn(i);const l=await n.getCompressedTokenAccountsByDelegate(s.publicKey,{mint:o}),[d]=Te(l.items,i),p=await n.getValidityProofV0(d.map((e=>({hash:e.compressedAccount.hash,tree:e.compressedAccount.treeInfo.tree,queue:e.compressedAccount.treeInfo.queue})))),m=null!=u?u:Me(await Ie(n,o),i),h=await pt.decompress({payer:r.publicKey,inputCompressedTokenAccounts:d,toAddress:a,amount:i,recentInputStateRootIndices:p.rootIndices,recentValidityProof:p.compressedProof,tokenPoolInfos:m}),{blockhash:f}=await n.getLatestBlockhash(),g=e.dedupeSigner(r,[s]),y=e.buildAndSignTx([t.ComputeBudgetProgram.setComputeUnitLimit({units:35e4}),h],r,f,g);return e.sendAndConfirmTx(n,y,c)},exports.decompressInterface=async function(r,o,i,s,a,u,c,l,d){var p;const m=void 0!==l,h=(await r.getCompressedTokenAccountsByOwner(i.publicKey,{mint:s})).items;if(0===h.length)return null;const f=h.reduce(((e,t)=>e+BigInt(t.parsed.amount.toString())),BigInt(0)),g=a?BigInt(a.toString()):f;if(g>f)throw new Error(`Insufficient compressed balance. Requested: ${g}, Available: ${f}`);const y=[];let b=BigInt(0);for(const e of h){if(b>=g)break;y.push(e),b+=BigInt(e.parsed.amount.toString())}const w=await r.getValidityProofV0(y.map((e=>({hash:e.compressedAccount.hash,tree:e.compressedAccount.treeInfo.tree,queue:e.compressedAccount.treeInfo.queue})))),I=null!=c?c:i.publicKey;let A;A=m?null!=u?u:await n.getAssociatedTokenAddress(s,I,0,l.tokenProgram):null!=u?u:jn(s,I);const k=[];await r.getAccountInfo(A)||(m?k.push(n.createAssociatedTokenAccountIdempotentInstruction(o.publicKey,A,I,s,l.tokenProgram)):k.push(an(o.publicKey,A,I,s,e.CTOKEN_PROGRAM_ID)));let v=5e4;null!==w.compressedProof&&(v+=1e5);for(const e of y)v+=null!==(p=e.compressedAccount.proveByIndex)&&void 0!==p&&p?1e4:3e4;m&&(v+=5e4),k.push(Cn(o.publicKey,y,A,g,w,l));const{blockhash:M}=await r.getLatestBlockhash(),P=e.dedupeSigner(o,[i]),x=e.buildAndSignTx([t.ComputeBudgetProgram.setComputeUnitLimit({units:v}),...k],o,M,P);return e.sendAndConfirmTx(r,x,d)},exports.deriveCMintAddress=mt,exports.deriveSplInterfaceInfo=be,exports.deriveTokenPoolInfo=function(e,t,n=0){return ge(be(e,t,n))},exports.deserializeMint=Fr,exports.encodeApproveInstructionData=rt,exports.encodeBatchCompressInstructionData=Ge,exports.encodeCompressSplTokenAccountInstructionData=Ve,exports.encodeMintToInstructionData=qe,exports.encodeRevokeInstructionData=ot,exports.encodeTokenMetadata=function(e){const n=w.alloc(2e3),r=e.updateAuthority||new t.PublicKey(0),o=Wr.encode({updateAuthority:r,mint:e.mint,name:w.from(e.name),symbol:w.from(e.symbol),uri:w.from(e.uri),additionalMetadata:e.additionalMetadata?e.additionalMetadata.map((e=>({key:w.from(e.key),value:w.from(e.value)}))):[]},n);return n.subarray(0,o)},exports.encodeTransfer2InstructionData=Pn,exports.encodeTransferInstructionData=Fe,exports.extractTokenMetadata=Yr,exports.findMintAddress=ft,exports.freezeAccountsLayout=Qe,exports.getAccountInterface=Gn,exports.getAssociatedCTokenAddress=function(n,r){return t.PublicKey.findProgramAddressSync([n.toBuffer(),e.CTOKEN_PROGRAM_ID.toBuffer(),r.toBuffer()],e.CTOKEN_PROGRAM_ID)[0]},exports.getAssociatedCTokenAddressAndBump=function(n,r){return t.PublicKey.findProgramAddressSync([n.toBuffer(),e.CTOKEN_PROGRAM_ID.toBuffer(),r.toBuffer()],e.CTOKEN_PROGRAM_ID)},exports.getAssociatedTokenAddressInterface=jn,exports.getAtaInterface=Vn,exports.getAtaProgramId=nn,exports.getMintInterface=Zr,exports.getOrCreateAtaInterface=async function(t,n,r,o,i=0,s,a,u=e.CTOKEN_PROGRAM_ID,c=nn(u)){return Jr(t,n,r,o,i,s,a,u,c,0)},exports.getSplInterfaceInfos=Ie,exports.getTokenPoolInfos=async function(e,t,n){return(await Ie(e,t,n)).map(ge)},exports.isSingleSplInterfaceInfo=io,exports.isSingleTokenPoolInfo=so,exports.loadAta=Qn,exports.mergeTokenAccounts=async function(n,r,o,i,s){const a=await n.getCompressedTokenAccountsByOwner(i.publicKey,{mint:o});if(0===a.items.length)throw new Error(`No compressed token accounts found for mint ${o.toBase58()}`);if(1===a.items.length)throw new Error("Only one token account exists, nothing to merge");const u=a.items.slice(0,4),c=await n.getValidityProof(u.map((t=>e.bn(t.compressedAccount.hash)))),l=await pt.mergeTokenAccounts({payer:r.publicKey,owner:i.publicKey,inputCompressedTokenAccounts:u,mint:o,recentValidityProof:c.compressedProof,recentInputStateRootIndices:c.rootIndices}),d=[t.ComputeBudgetProgram.setComputeUnitLimit({units:1e6}),...l],{blockhash:p}=await n.getLatestBlockhash(),m=e.dedupeSigner(r,[i]),h=e.buildAndSignTx(d,r,p,m);return e.sendAndConfirmTx(n,h,s)},exports.mintTo=async function(n,r,o,i,s,a,u,c){const l=await Zr(n,o,null==c?void 0:c.commitment,e.CTOKEN_PROGRAM_ID);if(!l.merkleContext)throw new Error("Mint does not have MerkleContext");let d;if(u){if(d=(await n.getStateTreeInfos()).find((e=>e.queue.equals(u)||e.tree.equals(u))),!d)throw new Error("Could not find TreeInfo for provided outputQueue")}else{const t=await n.getStateTreeInfos();d=e.selectStateTreeInfo(t)}const p=await n.getValidityProofV2([{hash:e.bn(l.merkleContext.hash),leafIndex:l.merkleContext.leafIndex,treeInfo:l.merkleContext.treeInfo,proveByIndex:l.merkleContext.proveByIndex}],[],e.DerivationMode.compressible),m=cn(s.publicKey,r.publicKey,p,l.merkleContext,{supply:l.mint.supply,decimals:l.mint.decimals,mintAuthority:l.mint.mintAuthority,freezeAuthority:l.mint.freezeAuthority,splMint:l.mintContext.splMint,cmintDecompressed:l.mintContext.cmintDecompressed,version:l.mintContext.version,metadata:l.tokenMetadata?{updateAuthority:l.tokenMetadata.updateAuthority||null,name:l.tokenMetadata.name,symbol:l.tokenMetadata.symbol,uri:l.tokenMetadata.uri}:void 0},d,i,a),h=s.publicKey.equals(r.publicKey)?[]:[s],{blockhash:f}=await n.getLatestBlockhash(),g=e.buildAndSignTx([t.ComputeBudgetProgram.setComputeUnitLimit({units:5e5}),m],r,f,h);return await e.sendAndConfirmTx(n,g,c)},exports.mintTo$1=async function(n,r,o,i,s,a,u,c,l){u=null!=u?u:e.selectStateTreeInfo(await n.getStateTreeInfos()),c=null!=c?c:ve(await Ie(n,o));const d=await pt.mintTo({feePayer:r.publicKey,mint:o,authority:s.publicKey,amount:a,toPubkey:i,outputStateTreeInfo:u,tokenPoolInfo:c}),{blockhash:p}=await n.getLatestBlockhash(),m=e.dedupeSigner(r,[s]),h=e.buildAndSignTx([t.ComputeBudgetProgram.setComputeUnitLimit({units:1e6}),d],r,p,m);return e.sendAndConfirmTx(n,h,l)},exports.mintToAccountsLayout=$e,exports.mintToCompressed=async function(n,r,o,i,s,a,u=3,c){const l=await Zr(n,o,null==c?void 0:c.commitment,e.CTOKEN_PROGRAM_ID);if(!l.merkleContext)throw new Error("Mint does not have MerkleContext");if(!a){const t=await n.getStateTreeInfos();a=e.selectStateTreeInfo(t)}const d=await n.getValidityProofV2([{hash:e.bn(l.merkleContext.hash),leafIndex:l.merkleContext.leafIndex,treeInfo:l.merkleContext.treeInfo,proveByIndex:l.merkleContext.proveByIndex}],[],e.DerivationMode.compressible),p=ln(i.publicKey,r.publicKey,d,l.merkleContext,{supply:l.mint.supply,decimals:l.mint.decimals,mintAuthority:l.mint.mintAuthority,freezeAuthority:l.mint.freezeAuthority,splMint:l.mintContext.splMint,cmintDecompressed:l.mintContext.cmintDecompressed,version:l.mintContext.version,metadata:l.tokenMetadata?{updateAuthority:l.tokenMetadata.updateAuthority||null,name:l.tokenMetadata.name,symbol:l.tokenMetadata.symbol,uri:l.tokenMetadata.uri}:void 0},s,a,u),m=i.publicKey.equals(r.publicKey)?[]:[i],{blockhash:h}=await n.getLatestBlockhash(),f=e.buildAndSignTx([t.ComputeBudgetProgram.setComputeUnitLimit({units:5e5}),p],r,h,m);return await e.sendAndConfirmTx(n,f,c)},exports.mintToInterface=async function(n,r,o,i,s,a,u=[],c,l){const d=await Zr(n,o,null==c?void 0:c.commitment,l);let p;d.merkleContext&&(p=await n.getValidityProofV2([{hash:e.bn(d.merkleContext.hash),leafIndex:d.merkleContext.leafIndex,treeInfo:d.merkleContext.treeInfo,proveByIndex:d.merkleContext.proveByIndex}],[],e.DerivationMode.compressible));const m=s instanceof t.PublicKey?s:s.publicKey,h=u.map((e=>e.publicKey)),f=dn(d,i,m,r.publicKey,a,p,h),g=[];s instanceof t.PublicKey||s.publicKey.equals(r.publicKey)||g.push(s),g.push(...u);const{blockhash:y}=await n.getLatestBlockhash(),b=e.buildAndSignTx([t.ComputeBudgetProgram.setComputeUnitLimit({units:5e5}),f],r,y,g);return await e.sendAndConfirmTx(n,b,c)},exports.mintToLayout=Ne,exports.packCompressedTokenAccounts=Ee,exports.parseCTokenCold=qn,exports.parseCTokenHot=Wn,exports.parseMaybeDelegatedTransfer=ct,exports.parseTokenData=ut,exports.removeMetadataKey=async function(n,r,o,i,s,a=0,u=0,c){const l=await Zr(n,o,null==c?void 0:c.commitment,e.CTOKEN_PROGRAM_ID);if(!l.tokenMetadata||!l.merkleContext)throw new Error("Mint does not have TokenMetadata extension");const d=await n.getValidityProofV2([{hash:e.bn(l.merkleContext.hash),leafIndex:l.merkleContext.leafIndex,treeInfo:l.merkleContext.treeInfo,proveByIndex:l.merkleContext.proveByIndex}],[],e.DerivationMode.compressible),p=jt(l,i.publicKey,r.publicKey,d,s,a,u),m=i.publicKey.equals(r.publicKey)?[]:[i],{blockhash:h}=await n.getLatestBlockhash(),f=e.buildAndSignTx([t.ComputeBudgetProgram.setComputeUnitLimit({units:5e5}),p],r,h,m);return await e.sendAndConfirmTx(n,f,c)},exports.revoke=async function(n,r,o,i,s){const a=await n.getValidityProofV0(o.map((e=>({hash:e.compressedAccount.hash,tree:e.compressedAccount.treeInfo.tree,queue:e.compressedAccount.treeInfo.queue}))));!function(e,t){if(!e.publicKey.equals(t[0].parsed.owner))throw new Error(`Owner ${e.publicKey.toBase58()} does not match account ${t[0].parsed.owner.toBase58()}`)}(i,o),function(e){if(e.some((e=>null===e.parsed.delegate)))throw new Error("Account is not delegated")}(o);const u=await pt.revoke({payer:r.publicKey,inputCompressedTokenAccounts:o,recentInputStateRootIndices:a.rootIndices,recentValidityProof:a.compressedProof}),{blockhash:c}=await n.getLatestBlockhash(),l=e.dedupeSigner(r,[i]),d=e.buildAndSignTx([t.ComputeBudgetProgram.setComputeUnitLimit({units:5e5}),u],r,c,l);return e.sendAndConfirmTx(n,d,s)},exports.revokeAccountsLayout=He,exports.selectMinCompressedTokenAccountsForDecompression=function(e,t,n=4){const[r,o,i,s]=Te(e,t,n);return{selectedAccounts:r,total:o,totalLamports:i,maxPossibleAmount:s}},exports.selectMinCompressedTokenAccountsForTransfer=Te,exports.selectMinCompressedTokenAccountsForTransferOrPartial=Se,exports.selectSmartCompressedTokenAccountsForTransfer=function(t,n,r=4){const[o,i,s,a]=Ce(t,n,r);if(i.lt(e.bn(n))){const i=t.reduce(((e,t)=>e.add(t.parsed.amount)),e.bn(0));throw o.length>=r?new Error(`Account limit exceeded: max ${a.toString()} (${r} accounts) per transaction. Total balance: ${i.toString()} (${t.length} accounts). Consider multiple transfers to spend full balance.`):new Error(`Insufficient balance. Required: ${n.toString()}, available: ${i.toString()}.`)}if(0===o.length)throw new Error(Pe);return[o,i,s,a]},exports.selectSmartCompressedTokenAccountsForTransferOrPartial=Ce,exports.selectSplInterfaceInfo=ve,exports.selectSplInterfaceInfosForDecompression=Me,exports.selectTokenAccountsForApprove=xe,exports.selectTokenPoolInfo=function(e){return ge(ve(e.map(ye)))},exports.selectTokenPoolInfosForDecompression=function(e,t){return Me(e.map(ye),t).map(ge)},exports.serializeMint=function(e){const r=[],o=w.alloc(n.MINT_SIZE);n.MintLayout.encode({mintAuthorityOption:e.base.mintAuthority?1:0,mintAuthority:e.base.mintAuthority||new t.PublicKey(0),supply:e.base.supply,decimals:e.base.decimals,isInitialized:e.base.isInitialized,freezeAuthorityOption:e.base.freezeAuthority?1:0,freezeAuthority:e.base.freezeAuthority||new t.PublicKey(0)},o),r.push(o);const i=w.alloc(Gr);if(qr.encode({version:e.mintContext.version,cmintDecompressed:e.mintContext.cmintDecompressed?1:0,splMint:e.mintContext.splMint},i),r.push(i),e.extensions&&e.extensions.length>0){r.push(w.from([1]));const t=w.alloc(4);t.writeUInt32LE(e.extensions.length),r.push(t);for(const t of e.extensions)r.push(w.from([t.extensionType])),r.push(w.from(t.data))}else r.push(w.from([0]));return w.concat(r)},exports.sumUpTokenAmount=st,exports.thawAccountsLayout=Je,exports.toAccountInfo=Un,exports.toOffChainMetadataJson=function(e){const t={name:e.name,symbol:e.symbol};return void 0!==e.description&&(t.description=e.description),void 0!==e.image&&(t.image=e.image),void 0!==e.additionalMetadata&&e.additionalMetadata.length>0&&(t.additionalMetadata=e.additionalMetadata),t},exports.toTokenPoolInfo=ge,exports.transfer=async function(n,r,o,i,s,a,u){i=e.bn(i);const c=await n.getCompressedTokenAccountsByOwner(s.publicKey,{mint:o}),[l]=Te(c.items,i),d=await n.getValidityProofV0(l.map((e=>({hash:e.compressedAccount.hash,tree:e.compressedAccount.treeInfo.tree,queue:e.compressedAccount.treeInfo.queue})))),p=await pt.transfer({payer:r.publicKey,inputCompressedTokenAccounts:l,toAddress:a,amount:i,recentInputStateRootIndices:d.rootIndices,recentValidityProof:d.compressedProof}),{blockhash:m}=await n.getLatestBlockhash(),h=e.dedupeSigner(r,[s]),f=e.buildAndSignTx([t.ComputeBudgetProgram.setComputeUnitLimit({units:5e5}),p],r,m,h);return e.sendAndConfirmTx(n,f,u)},exports.transferAccountsLayout=Ye,exports.transferDelegated=async function(n,r,o,i,s,a,u){i=e.bn(i);const c=await n.getCompressedTokenAccountsByDelegate(s.publicKey,{mint:o}),[l]=Te(c.items,i),d=await n.getValidityProofV0(l.map((e=>({hash:e.compressedAccount.hash,tree:e.compressedAccount.treeInfo.tree,queue:e.compressedAccount.treeInfo.queue})))),p=await pt.transfer({payer:r.publicKey,inputCompressedTokenAccounts:l,toAddress:a,amount:i,recentInputStateRootIndices:d.rootIndices,recentValidityProof:d.compressedProof}),{blockhash:m}=await n.getLatestBlockhash(),h=e.dedupeSigner(r,[s]),f=e.buildAndSignTx([t.ComputeBudgetProgram.setComputeUnitLimit({units:5e5}),p],r,m,h);return e.sendAndConfirmTx(n,f,u)},exports.transferInterface=async function(r,o,i,s,a,u,c,l=e.CTOKEN_PROGRAM_ID,d,p,m=0){const h=BigInt(c.toString()),{splInterfaceInfos:f}=null!=p?p:{},g=[];if(!l.equals(e.CTOKEN_PROGRAM_ID)){const c=n.getAssociatedTokenAddressSync(s,u.publicKey,0,l,nn(l));if(!i.equals(c))throw new Error(`Source mismatch. Expected ${c.toBase58()}, got ${i.toBase58()}`);g.push(hn(i,a,u.publicKey,h,[],l));const{blockhash:p}=await r.getLatestBlockhash(),m=e.buildAndSignTx([t.ComputeBudgetProgram.setComputeUnitLimit({units:1e4}),...g],o,p,[u]);return e.sendAndConfirmTx(r,m,d)}const y=jn(s,u.publicKey);if(!i.equals(y))throw new Error(`Source mismatch. Expected ${y.toBase58()}, got ${i.toBase58()}`);const b=jn(s,u.publicKey);let w,I;m&&(w=n.getAssociatedTokenAddressSync(s,u.publicKey,0,n.TOKEN_PROGRAM_ID,nn(n.TOKEN_PROGRAM_ID)),I=n.getAssociatedTokenAddressSync(s,u.publicKey,0,n.TOKEN_2022_PROGRAM_ID,nn(n.TOKEN_2022_PROGRAM_ID)));const A=[r.getAccountInfo(b),r.getCompressedTokenAccountsByOwner(u.publicKey,{mint:s})];m&&w&&I&&(A.push(r.getAccountInfo(w)),A.push(r.getAccountInfo(I)));const k=await Promise.all(A),v=k[0],M=k[1],P=m?k[2]:null,x=m?k[3]:null,T=M.items,S=v&&v.data.length>=72?v.data.readBigUInt64LE(64):BigInt(0),C=m&&P&&P.data.length>=72?P.data.readBigUInt64LE(64):BigInt(0),E=m&&x&&x.data.length>=72?x.data.readBigUInt64LE(64):BigInt(0),_=T.reduce(((e,t)=>e+BigInt(t.parsed.amount.toString())),BigInt(0)),O=S+C+E+_;if(O<h)throw new Error(`Insufficient balance. Required: ${h}, Available: ${O}`);let R=[];v||g.push(an(o.publicKey,b,u.publicKey,s,e.CTOKEN_PROGRAM_ID));const D=(C>BigInt(0)||E>BigInt(0)||_>BigInt(0)?null!=f?f:await Ie(r,s):[]).find((e=>e.isInitialized));if(m&&w&&C>BigInt(0)&&D&&g.push($n(w,b,u.publicKey,s,C,D,o.publicKey)),m&&I&&E>BigInt(0)&&D&&g.push($n(I,b,u.publicKey,s,E,D,o.publicKey)),_>BigInt(0)&&T.length>0){const e=await r.getValidityProofV0(T.map((e=>({hash:e.compressedAccount.hash,tree:e.compressedAccount.treeInfo.tree,queue:e.compressedAccount.treeInfo.queue}))));e.compressedProof,R=T,g.push(Cn(o.publicKey,T,b,_,e))}g.push(mn(i,a,u.publicKey,h));const B=function(e){if(e.length>0)for(const t of e)t.compressedAccount.proveByIndex;return 2e5}(R),{blockhash:K}=await r.getLatestBlockhash(),L=e.dedupeSigner(o,[u]),N=e.buildAndSignTx([t.ComputeBudgetProgram.setComputeUnitLimit({units:B}),...g],o,K,L);return e.sendAndConfirmTx(r,N,d)},exports.unpackMintData=function(e){const t=Fr(e instanceof w?e:w.from(e)),n=Yr(t.extensions);return{mintContext:t.mintContext,tokenMetadata:n||void 0,extensions:t.extensions||void 0}},exports.unpackMintInterface=function(t,r,o=n.TOKEN_PROGRAM_ID){const i=r instanceof w?r:r instanceof Uint8Array?w.from(r):r.data;if(o.equals(e.CTOKEN_PROGRAM_ID)){const n=Fr(i),r={address:t,mintAuthority:n.base.mintAuthority,supply:n.base.supply,decimals:n.base.decimals,isInitialized:n.base.isInitialized,freezeAuthority:n.base.freezeAuthority,tlvData:w.alloc(0)},s=Yr(n.extensions),a={mint:r,programId:o,mintContext:n.mintContext,tokenMetadata:s||void 0,extensions:n.extensions||void 0};if(o.equals(e.CTOKEN_PROGRAM_ID)&&!a.mintContext)throw new Error("Invalid compressed mint: mintContext is required for CTOKEN_PROGRAM_ID");return a}const s=r;return{mint:n.unpackMint(t,s,o),programId:o}},exports.updateFreezeAuthority=async function(n,r,o,i,s,a){const u=await Zr(n,o,null==a?void 0:a.commitment,e.CTOKEN_PROGRAM_ID);if(!u.merkleContext)throw new Error("Mint does not have MerkleContext");const c=await n.getValidityProofV2([{hash:e.bn(u.merkleContext.hash),leafIndex:u.merkleContext.leafIndex,treeInfo:u.merkleContext.treeInfo,proveByIndex:u.merkleContext.proveByIndex}],[],e.DerivationMode.compressible),l=Gt(u,i.publicKey,s,r.publicKey,c),d=i.publicKey.equals(r.publicKey)?[]:[i],{blockhash:p}=await n.getLatestBlockhash(),m=e.buildAndSignTx([t.ComputeBudgetProgram.setComputeUnitLimit({units:5e5}),l],r,p,d);return await e.sendAndConfirmTx(n,m,a)},exports.updateMetadataAuthority=async function(n,r,o,i,s,a=0,u){const c=await Zr(n,o,null==u?void 0:u.commitment,e.CTOKEN_PROGRAM_ID);if(!c.tokenMetadata||!c.merkleContext)throw new Error("Mint does not have TokenMetadata extension");const l=await n.getValidityProofV2([{hash:e.bn(c.merkleContext.hash),leafIndex:c.merkleContext.leafIndex,treeInfo:c.merkleContext.treeInfo,proveByIndex:c.merkleContext.proveByIndex}],[],e.DerivationMode.compressible),d=zt(c,i.publicKey,s,r.publicKey,l,a),p=i.publicKey.equals(r.publicKey)?[]:[i],{blockhash:m}=await n.getLatestBlockhash(),h=e.buildAndSignTx([t.ComputeBudgetProgram.setComputeUnitLimit({units:5e5}),d],r,m,p);return await e.sendAndConfirmTx(n,h,u)},exports.updateMetadataField=async function(n,r,o,i,s,a,u,c=0,l){const d=await Zr(n,o,null==l?void 0:l.commitment,e.CTOKEN_PROGRAM_ID);if(!d.tokenMetadata||!d.merkleContext)throw new Error("Mint does not have TokenMetadata extension");const p=await n.getValidityProofV2([{hash:e.bn(d.merkleContext.hash),leafIndex:d.merkleContext.leafIndex,treeInfo:d.merkleContext.treeInfo,proveByIndex:d.merkleContext.proveByIndex}],[],e.DerivationMode.compressible),m=Ft(d,i.publicKey,r.publicKey,p,s,a,u,c),h=i.publicKey.equals(r.publicKey)?[]:[i],{blockhash:f}=await n.getLatestBlockhash(),g=e.buildAndSignTx([t.ComputeBudgetProgram.setComputeUnitLimit({units:5e5}),m],r,f,h);return await e.sendAndConfirmTx(n,g,l)},exports.updateMintAuthority=async function(n,r,o,i,s,a){const u=await Zr(n,o,null==a?void 0:a.commitment,e.CTOKEN_PROGRAM_ID);if(!u.merkleContext)throw new Error("Mint does not have MerkleContext");const c=await n.getValidityProofV2([{hash:e.bn(u.merkleContext.hash),leafIndex:u.merkleContext.leafIndex,treeInfo:u.merkleContext.treeInfo,proveByIndex:u.merkleContext.proveByIndex}],[],e.DerivationMode.compressible),l=qt(u,i.publicKey,s,r.publicKey,c),d=i.publicKey.equals(r.publicKey)?[]:[i],{blockhash:p}=await n.getLatestBlockhash(),m=e.buildAndSignTx([t.ComputeBudgetProgram.setComputeUnitLimit({units:5e5}),l],r,p,d);return await e.sendAndConfirmTx(n,m,a)},exports.validateSameTokenOwner=at,exports.wrap=async function(n,r,o,i,s,a,u,c,l){let d=c;if(!d&&(d=(await Ie(n,a)).find((e=>e.isInitialized)),!d))throw new Error(`No initialized SPL interface found for mint: ${a.toBase58()}. Please create an SPL interface via createSplInterface().`);const p=$n(o,i,s.publicKey,a,u,d,r.publicKey),{blockhash:m}=await n.getLatestBlockhash(),h=e.dedupeSigner(r,[s]),f=e.buildAndSignTx([t.ComputeBudgetProgram.setComputeUnitLimit({units:2e5}),p],r,m,h);return await e.sendAndConfirmTx(n,f,l)};
2
+ //# sourceMappingURL=types-CJcjpvYl.cjs.map