{"version":3,"sources":["../src/pad.ts","../src/types.ts","../src/format.ts","../src/account.ts","../src/logger.ts","../src/deployment.ts","../src/path.ts","../src/assert.ts","../src/promise.ts","../src/array.ts","../src/enum.ts","../src/generic.ts","../src/findup.ts","../src/loader.ts","../src/memoize.ts","../src/combinatorial.ts","../src/index.ts"],"names":["path","IotaEd25519Keypair","logger","level","ethers","dirname","getStackTrace","getCaller","module","require"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAgCa,IAAA,2BAAA,GAAN,cAA0C,KAAM,CAAA;AAAA,EAEnD,WAAY,CAAA,EAAE,IAAM,EAAA,UAAA,EAAY,MAAqE,EAAA;AACjG,IAAA,KAAA;AAAA,MACI,GAAG,IAAK,CAAA,MAAA,CAAO,CAAC,CAAA,CAAE,aAAa,CAAA,EAAG,IAC7B,CAAA,KAAA,CAAM,CAAC,CACP,CAAA,WAAA,EAAa,CAAU,OAAA,EAAA,IAAI,2BAA2B,UAAU,CAAA,CAAA;AAAA,KACzE;AANJ,IAAA,IAAA,CAAS,IAAO,GAAA,6BAAA;AAAA;AAQpB;AAYO,SAAS,MAAA,CACZ,YACA,EAAE,GAAA,EAAK,OAAO,EAAG,EAAA,GAAgB,EACb,EAAA;AACpB,EAAI,IAAA,OAAO,eAAe,QAAU,EAAA;AAChC,IAAA,OAAO,MAAO,CAAA,UAAA,EAAY,EAAE,GAAA,EAAK,MAAM,CAAA;AAAA;AAE3C,EAAA,OAAO,QAAS,CAAA,UAAA,EAAY,EAAE,GAAA,EAAK,MAAM,CAAA;AAC7C;AAYA,SAAS,MAAA,CAAO,KAAU,EAAE,GAAA,EAAK,OAAO,EAAG,EAAA,GAAgB,EAAS,EAAA;AAChE,EAAI,IAAA,IAAA,KAAS,MAAa,OAAA,GAAA;AAC1B,EAAA,MAAM,KAAQ,GAAA,GAAA,CAAI,OAAQ,CAAA,IAAA,EAAM,EAAE,CAAA;AAClC,EAAI,IAAA,KAAA,CAAM,SAAS,IAAO,GAAA,CAAA;AACtB,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AA,MAAA;AAAA,IACjB,IAAA,EAAM,EAAE,MAAO,CAAA,IAAA;AAAA,IACf,IAAA,EAAM,EAAE,MAAO,CAAA;AAAA,GACnB;AACJ","file":"index.mjs","sourcesContent":["import { Bytes, Hex } from './types'\n\n/**\n * Interface representing the options for padding.\n */\ninterface PadOptions {\n    /**\n     * The direction of the padding. Defaults to undefined.\n     */\n    dir?: 'left' | 'right' | undefined\n\n    /**\n     * The size to pad to. Defaults to 32.\n     */\n    size?: number | null | undefined\n}\n\n/**\n * Type representing the return type of the padify function.\n */\nexport type PadReturnType<value extends Bytes | Hex> = value extends Hex ? Hex : Bytes\n\n/**\n * Type representing an error when the size exceeds the padding size.\n */\nexport type SizeExceedsPaddingSizeErrorType = SizeExceedsPaddingSizeError & {\n    name: 'SizeExceedsPaddingSizeError'\n}\n\n/**\n * Class representing an error when the size exceeds the padding size.\n */\nexport class SizeExceedsPaddingSizeError extends Error {\n    override name = 'SizeExceedsPaddingSizeError'\n    constructor({ size, targetSize, type }: { size: number; targetSize: number; type: 'hex' | 'bytes' }) {\n        super(\n            `${type.charAt(0).toUpperCase()}${type\n                .slice(1)\n                .toLowerCase()} size (${size}) exceeds padding size (${targetSize})`\n        )\n    }\n}\n\n/**\n * Pads a hexadecimal string or byte array to a specified size.\n *\n * @param {Bytes | Hex} hexOrBytes - The hexadecimal string or byte array to pad.\n * @param {PadOptions} [options] - The padding options.\n * @param {'left' | 'right'} [options.dir] - The direction of the padding. Defaults to undefined.\n * @param {number} [options.size=32] - The size to pad to. Defaults to 32.\n * @returns {PadReturnType<Bytes | Hex>} The padded hexadecimal string or byte array.\n * @throws {SizeExceedsPaddingSizeError} If the size exceeds the padding size.\n */\nexport function padify<value extends Bytes | Hex>(\n    hexOrBytes: value,\n    { dir, size = 32 }: PadOptions = {}\n): PadReturnType<value> {\n    if (typeof hexOrBytes === 'string') {\n        return padHex(hexOrBytes, { dir, size }) as PadReturnType<value>\n    }\n    return padBytes(hexOrBytes, { dir, size }) as PadReturnType<value>\n}\n\n/**\n * Pads a hexadecimal string to a specified size.\n *\n * @param {Hex} hex - The hexadecimal string to pad.\n * @param {PadOptions} [options] - The padding options.\n * @param {'left' | 'right'} [options.dir] - The direction of the padding. Defaults to undefined.\n * @param {number} [options.size=32] - The size to pad to. Defaults to 32.\n * @returns {Hex} The padded hexadecimal string.\n * @throws {SizeExceedsPaddingSizeError} If the size exceeds the padding size.\n */\nfunction padHex(hex: Hex, { dir, size = 32 }: PadOptions = {}): Hex {\n    if (size === null) return hex\n    const value = hex.replace('0x', '')\n    if (value.length > size * 2)\n        throw new SizeExceedsPaddingSizeError({\n            size: Math.ceil(value.length / 2),\n            targetSize: size,\n            type: 'hex',\n        })\n\n    return `0x${value[dir === 'right' ? 'padEnd' : 'padStart'](size * 2, '0')}`\n}\n\n/**\n * Pads a byte array to a specified size.\n *\n * @param {Bytes} bytes - The byte array to pad.\n * @param {PadOptions} [options] - The padding options.\n * @param {'left' | 'right'} [options.dir] - The direction of the padding. Defaults to undefined.\n * @param {number} [options.size=32] - The size to pad to. Defaults to 32.\n * @returns {Bytes} The padded byte array.\n * @throws {SizeExceedsPaddingSizeError} If the size exceeds the padding size.\n */\nfunction padBytes(bytes: Bytes, { dir, size = 32 }: PadOptions = {}): Bytes {\n    if (size === null) return bytes\n    if (bytes.length > size)\n        throw new SizeExceedsPaddingSizeError({\n            size: bytes.length,\n            targetSize: size,\n            type: 'bytes',\n        })\n    const paddedBytes = new Uint8Array(size)\n    for (let i = 0; i < size; i++) {\n        const padEnd = dir === 'right'\n        paddedBytes[padEnd ? i : size - i - 1] = bytes[padEnd ? i : bytes.length - i - 1]\n    }\n    return paddedBytes\n}\n","/**\n * Type representing a hexadecimal string prefixed with '0x'.\n */\nexport type Hex = `0x${string}`\n\n/**\n * Type representing a hash string prefixed with '0x'.\n */\nexport type Hash = `0x${string}`\n\n/**\n * Checks if a given string is a valid hexadecimal string.\n * @param value - The string to check.\n * @returns True if the string is a valid hexadecimal string, false otherwise.\n */\nexport function isHex(value: string): value is Hex {\n    return /^(0x)?[0-9A-F]+$/i.test(value)\n}\n\n/**\n * Checks if a given string is a valid hash string.\n * @param value - The string to check.\n * @returns True if the string is a valid hash string, false otherwise.\n */\nexport function isHash(value: string): value is Hash {\n    return /^(0x)?[0-9A-F]+/i.test(value)\n}\n\n/**\n * Represents a byte array.\n */\nexport type Bytes = Uint8Array\n","import { padify } from './pad'\nimport { Hex, isHex } from './types'\n\n/**\n * A function to convert Uint8Array to hex string.\n * @deprecated use `hexlify` instead.\n * @param {Uint8Array} bytes - The bytes to convert.\n * @returns {string} Hex string without 0x prefix, e.g., '0102030405'.\n */\nexport function bytesToHex(bytes: Uint8Array): string {\n    return trim0x(hexlify(bytes)).replace(/^0x/i, '')\n}\n\n/**\n * A function to convert hex string to Uint8Array.\n * @deprecated use `arrayify` instead.\n * @param {string} hex - Hex string, e.g., '0x0102030405' or '0102030405'.\n * @returns {Uint8Array} The converted Uint8Array.\n */\nexport function hexToBytes(hex: string): Uint8Array {\n    return arrayify(hex)\n}\n\n/**\n * A function to trim the prefix 0x from a hex string.\n * @param {string} hex - Hex string.\n * @returns {string} Hex string without 0x prefix.\n */\nexport function trim0x(hex: string): string {\n    return hex.replace(/^0x/i, '')\n}\n\n/**\n * A function to ensure the prefix 0x from a hex string.\n * @param {string} hex - Hex string.\n * @returns {Hex} Hex string with 0x prefix.\n * @throws {Error} If the input is not a valid hex string.\n */\nexport function ensure0x(hex: string): Hex {\n    if (!isHex(hex)) {\n        throw new Error('invalid hex string')\n    }\n    const value = trim0x(hex)\n    const retval = `0x${value}`\n    return retval as Hex\n}\n\n/**\n * A function to check if a string is a hex string.\n * @deprecated use `isHex` instead.\n * @param {string} value - The string to check.\n * @returns {boolean} True if the string is a hex string, false otherwise.\n */\nexport function isHexString(value: string): boolean {\n    return isHex(value)\n}\n\nfunction _arrayify(value: string | number | Uint8Array | Buffer | bigint): Uint8Array {\n    if (value instanceof Uint8Array) {\n        return value\n    }\n\n    if (typeof value === 'string') {\n        if (value.match(/^(0x)?[0-9A-F]*$/i)) {\n            const hex = value.replace(/^0x/i, '')\n            const len = hex.length + 1 - ((hex.length + 1) % 2)\n            return Uint8Array.from(Buffer.from(hex.padStart(len, '0'), 'hex'))\n        }\n        throw new Error('Invalid hex string')\n    }\n\n    if (typeof value === 'number') {\n        if (value < 0) {\n            throw new Error('Number must be non-negative')\n        }\n        const byteArray = []\n        while (value > 0) {\n            byteArray.push(value & 0xff)\n            value >>= 8\n        }\n        return new Uint8Array(byteArray.reverse())\n    }\n\n    if (typeof Buffer !== 'undefined' && Buffer.isBuffer(value)) {\n        return new Uint8Array(value)\n    }\n\n    if (typeof value === 'bigint') {\n        const hex = value.toString(16)\n        return _arrayify(hex)\n    }\n\n    throw new Error('unsupported type')\n}\n\n/**\n * A function to convert a string|number|Uint8Array|Buffer|BigInt to Uint8Array.\n * @param {string | number | Uint8Array | Buffer | bigint} value - The value to convert.\n * @param {number} [size] - The size of the Uint8Array to return, if not specified, the size of the input will be returned.\n * @returns {Uint8Array} The converted Uint8Array.\n * @throws {Error} If the input type is unsupported.\n */\nexport function arrayify(value: string | number | Uint8Array | Buffer | bigint, size?: number): Uint8Array {\n    const bytes = _arrayify(value)\n    if (size === undefined) {\n        return bytes\n    }\n    return padify(bytes, { size })\n}\n\n/**\n * A function to convert a string|number|Uint8Array|Buffer|BigInt to hex string.\n * @param {string | number | Uint8Array | Buffer | bigint} value - The value to convert.\n * @returns {Hex} The converted hex string.\n * @throws {Error} If the input type is unsupported.\n */\nexport function hexlify(value: string | number | Uint8Array | Buffer | bigint): Hex {\n    if (typeof value === 'string' && /^(0x)?[0-9A-F]*$/i.test(value)) {\n        const retval = '0x' + trim0x(value)\n        return retval as Hex\n    }\n\n    const bytes = arrayify(value)\n    const hex = Buffer.from(bytes).toString('hex')\n    return ensure0x(hex)\n}\n","import { INIT_COIN_TYPE, MnemonicKey } from '@initia/initia.js'\nimport { Ed25519Keypair as IotaEd25519Keypair } from '@iota/iota-sdk/keypairs/ed25519'\nimport { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519'\nimport { Keypair } from '@solana/web3.js'\nimport { KeyPair, deriveEd25519Path, keyPairFromSeed, mnemonicToHDSeed } from '@ton/crypto'\nimport { WalletContractV4 } from '@ton/ton'\nimport * as aptos from 'aptos'\nimport * as bip39 from 'bip39'\nimport * as ed25519HdKey from 'ed25519-hd-key'\nimport { ethers } from 'ethers'\n\nimport { ChainType } from '@layerzerolabs/lz-definitions'\n\nimport { hexlify, trim0x } from './format'\n\n/**\n * Interface representing an account mnemonic.\n */\nexport interface AccountMnemonic {\n    /**\n     * The mnemonic phrase.\n     */\n    mnemonic: string\n\n    /**\n     * The derivation path.\n     */\n    path: string\n\n    /**\n     * The private key (optional).\n     */\n    privateKey?: string\n\n    /**\n     * The address (optional).\n     */\n    address?: string\n}\n\n/**\n * Gets the BIP-0044 derivation path for a given chain type.\n *\n * @param {ChainType} chainType - The chain type.\n * @param {number} account - The account index.\n * @param {number} change - The change index.\n * @param {number} index - The address index.\n * @returns {string} The BIP-0044 derivation path.\n * @throws {Error} If the chain type is unsupported.\n */\nexport function getBIP044Path(chainType: ChainType, account: number, change: number, index: number): string {\n    // CAUTION: the path format is different for each chain\n    // https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki\n    //\n    // The \"m/44'/637'/0'/0'/0'\" path is known as a hardened derivation path, while the \"m/44'/637'/0'/0/0\" path is a non-hardened derivation path.\n    // The technical benefit of using a hardened derivation path is enhanced security.\n    // In BIP32, a hardened derivation is denoted by an apostrophe ('), which indicates that the child private key should be derived in a way\n    // that makes it computationally infeasible to derive the parent private key from it. This additional level of security\n    // protects the mnemonic phrase and its derived private keys even if one of the derived private keys is compromised.\n    // By using a hardened derivation path, like \"m/44'/637'/0'/0'/0'\", each level of the path requires a unique private key derivation,\n    // making it more difficult to infer the parent private key from the child private key. This is particularly important when dealing with\n    // hierarchical deterministic wallets, as it helps protect funds across multiple accounts or purposes.\n\n    switch (chainType) {\n        case ChainType.EVM:\n            // https://github.com/ethers-io/ethers.js/blob/main/src.ts/wallet/hdwallet.ts\n            return `m/44'/60'/${account}'/${change}/${index}`\n        case ChainType.APTOS:\n            // https://github.com/aptos-labs/aptos-core/blob/main/ecosystem/typescript/sdk/src/aptos_account.ts\n            return `m/44'/637'/${account}'/${change}'/${index}'`\n        case ChainType.SOLANA:\n            // https://github.com/solana-labs/solana/blob/master/sdk/src/derivation_path.rs\n            return `m/44'/501'/${account}'/${change}'`\n        case ChainType.TON:\n            // https://github.com/satoshilabs/slips/blob/master/slip-0044.md#registered-coin-types\n            return `m/44'/607'/${account}'/${change}/${index}`\n        default:\n            throw new Error(`Unsupported chain: ${chainType}`)\n    }\n}\n\n/**\n * Gets an EVM account from a mnemonic phrase.\n *\n * @param {string} mnemonic - The mnemonic phrase.\n * @param {string} [path=\"m/44'/60'/0'/0/0\"] - The derivation path.\n * @returns {AccountMnemonic} The EVM account mnemonic.\n */\nexport function getEvmAccountFromMnemonic(mnemonic: string, path = \"m/44'/60'/0'/0/0\"): AccountMnemonic {\n    const wallet = ethers.Wallet.fromMnemonic(mnemonic, path)\n    return {\n        mnemonic,\n        path,\n        privateKey: wallet.privateKey,\n        address: wallet.address,\n    }\n}\n\n/**\n * Gets an Aptos account from a mnemonic phrase.\n *\n * @param {string} mnemonic - The mnemonic phrase.\n * @param {string} [path=\"m/44'/637'/0'/0'/0'\"] - The derivation path.\n * @returns {AccountMnemonic} The Aptos account mnemonic.\n * @throws {Error} If the derivation path is invalid.\n */\nexport function getAptosAccountFromMnemonic(mnemonic: string, path = \"m/44'/637'/0'/0'/0'\"): AccountMnemonic {\n    //https://aptos.dev/guides/building-your-own-wallet/#creating-an-aptos-account\n    if (!aptos.AptosAccount.isValidPath(path)) {\n        throw new Error(`Invalid derivation path: ${path}`)\n    }\n    const normalizeMnemonics = mnemonic\n        .trim()\n        .split(/\\s+/)\n        .map((part) => part.toLowerCase())\n        .join(' ')\n    {\n        const { key } = aptos.derivePath(path, trim0x(hexlify(bip39.mnemonicToSeedSync(normalizeMnemonics))))\n        const account = new aptos.AptosAccount(new Uint8Array(key)).toPrivateKeyObject()\n        return {\n            mnemonic,\n            path,\n            privateKey: account.privateKeyHex,\n            address: account.address,\n        }\n    }\n}\n\n/**\n * Gets an Initia account from a mnemonic phrase.\n *\n * @param {string} mnemonic - The mnemonic phrase.\n * @param {string} [path=\"m/44'/118'/0'/0/0\"] - The derivation path.\n * @returns {AccountMnemonic} The Initia account mnemonic.\n */\nexport function getInitiaAccountFromMnemonic(mnemonic: string, path = \"m/44'/118'/0'/0/0\"): AccountMnemonic {\n    const [_, coinType, account, __, index] = path.match(/\\d+/g)?.map(Number) ?? [44, 118, 0, 0, 0]\n    const normalizeMnemonics = mnemonic\n        .trim()\n        .split(/\\s+/)\n        .map((part) => part.toLowerCase())\n        .join(' ')\n    const key = new MnemonicKey({\n        mnemonic: normalizeMnemonics,\n        coinType,\n        account,\n        index,\n        eth: coinType === INIT_COIN_TYPE,\n    })\n    {\n        return {\n            mnemonic,\n            path,\n            privateKey: key.privateKey.toString('hex'),\n            address: key.accAddress,\n        }\n    }\n}\n\n/**\n * Gets a Solana account from a mnemonic phrase.\n *\n * @param {string} mnemonic - The mnemonic phrase.\n * @param {string} [path=\"m/44'/501'/0'/0'\"] - The derivation path.\n * @returns {AccountMnemonic} The Solana account mnemonic.\n */\nexport function getSolanaAccountFromMnemonic(mnemonic: string, path = \"m/44'/501'/0'/0'\"): AccountMnemonic {\n    const seed = bip39.mnemonicToSeedSync(mnemonic, '') // (mnemonic, password)\n    const keyPair = Keypair.fromSeed(ed25519HdKey.derivePath(path, seed.toString('hex')).key)\n    return {\n        mnemonic,\n        path,\n        privateKey: ethers.utils.hexlify(keyPair.secretKey),\n        address: keyPair.publicKey.toBase58(),\n    }\n}\n\nexport function getSuiAccountFromMnemonic(mnemonic: string, path = \"m/44'/784'/0'/0'/0'\"): AccountMnemonic {\n    const signer = Ed25519Keypair.deriveKeypair(mnemonic, path)\n    return {\n        mnemonic,\n        path,\n        privateKey: signer.getSecretKey(),\n        address: signer.toSuiAddress(),\n    }\n}\n\nexport function getIotaL1AccountFromMnemonic(mnemonic: string, path = \"m/44'/4218'/0'/0'/0'\"): AccountMnemonic {\n    const signer = IotaEd25519Keypair.deriveKeypair(mnemonic, path)\n    return {\n        mnemonic,\n        path,\n        privateKey: signer.getSecretKey(),\n        address: signer.toIotaAddress(),\n    }\n}\n\n/**\n * Gets a TON account from a mnemonic phrase.\n *\n * @param {string} mnemonic - The mnemonic phrase.\n * @param {string} [path=\"m/44'/607'/0'/0'/0'\"] - The derivation path.\n * @param {number} [workchain=0] - The workChain ID.\n * @returns {Promise<AccountMnemonic>} A promise that resolves to the TON account mnemonic.\n */\nexport async function getTonAccountFromMnemonic(\n    mnemonic: string,\n    path = \"m/44'/607'/0'/0'/0'\",\n    workchain = 0\n): Promise<AccountMnemonic> {\n    const { wallet, keyPair } = await getTonWalletFromMnemonic(mnemonic, path, workchain)\n    return {\n        mnemonic,\n        path,\n        privateKey: ethers.utils.hexlify(keyPair.secretKey),\n        address: wallet.address.toString({ bounceable: false, urlSafe: true }),\n    }\n}\n\n/**\n * Gets a key pair from a mnemonic phrase for a given chain type.\n *\n * @param {ChainType} chainType - The chain type.\n * @param {string} mnemonic - The mnemonic phrase.\n * @param {string} [path] - The derivation path.\n * @returns {Promise<AccountMnemonic>} A promise that resolves to the account mnemonic.\n * @throws {Error} If the chain type is unsupported.\n */\nexport async function getKeypairFromMnemonic(\n    chainType: ChainType,\n    mnemonic: string,\n    path?: string\n): Promise<AccountMnemonic> {\n    switch (chainType) {\n        case ChainType.EVM:\n            return getEvmAccountFromMnemonic(mnemonic, path)\n        case ChainType.APTOS:\n            return getAptosAccountFromMnemonic(mnemonic, path)\n        case ChainType.INITIA:\n            return getInitiaAccountFromMnemonic(mnemonic, path)\n        case ChainType.SOLANA:\n            return getSolanaAccountFromMnemonic(mnemonic, path)\n        case ChainType.TON:\n            return getTonAccountFromMnemonic(mnemonic, path)\n        case ChainType.SUI:\n            return getSuiAccountFromMnemonic(mnemonic, path)\n        case ChainType.IOTAL1:\n            return getIotaL1AccountFromMnemonic(mnemonic, path)\n        default:\n            throw new Error(`Unsupported chain: ${chainType}`)\n    }\n}\n\n/**\n * Gets a TON wallet from a mnemonic phrase.\n *\n * @param {string} mnemonic - The mnemonic phrase.\n * @param {string} [path=\"m/44'/607'/0'/0'/0'\"] - The derivation path.\n * @param {number} [workchain=0] - The workChain ID.\n * @returns {Promise<{ wallet: WalletContractV4; keyPair: KeyPair }>} A promise that resolves to the TON wallet and key pair.\n */\nexport async function getTonWalletFromMnemonic(\n    mnemonic: string,\n    path = \"m/44'/607'/0'/0'/0'\",\n    workchain = 0\n): Promise<{ wallet: WalletContractV4; keyPair: KeyPair }> {\n    const seed: Buffer = await mnemonicToHDSeed(mnemonic.split(' '))\n    const indices: number[] = toPathArray(path)\n    const derivedSeed: Buffer = await deriveEd25519Path(seed, indices)\n    const keyPair: KeyPair = keyPairFromSeed(derivedSeed)\n    return {\n        wallet: WalletContractV4.create({ publicKey: keyPair.publicKey, workchain }),\n        keyPair,\n    }\n}\n\n/**\n * Converts a path string to an array of numbers.\n * TON currently supports hardened paths only: https://github.com/ton-org/ton-crypto/blob/master/src/hd/ed25519.ts#L32\n *\n * @param {string} path - The path string to convert.\n * @returns {number[]} An array of numbers representing the path.\n * @throws {Error} If the path is invalid.\n */\nfunction toPathArray(path: string): number[] {\n    if (!/^[mM]'?/.test(path)) {\n        throw new Error('Path must start with \"m\" or \"M\"')\n    }\n    const parts = path.replace(/^[mM]'?\\//, '').split('/')\n    const ret: number[] = Array<number>(parts.length)\n    for (let i = 0; i < parts.length; i++) {\n        const tmp = /(\\d+)[hH']/.exec(parts[i])\n        if (tmp === null) {\n            throw new Error('Invalid input')\n        }\n        ret[i] = parseInt(tmp[1], 10)\n\n        if (ret[i] >= 0x80000000) {\n            throw new Error('Invalid child index')\n        }\n    }\n    return ret\n}\n","import dayjs from 'dayjs'\nimport pc from 'picocolors'\nimport { pino } from 'pino'\n\nlet logger: pino.Logger | undefined = undefined\n\nexport type Logger = pino.Logger\n\n/**\n * Gets the current stack trace.\n *\n * @returns {string | undefined} The current stack trace.\n */\nfunction getStackTrace(): string | undefined {\n    const oldLimit = Error.stackTraceLimit\n    Error.stackTraceLimit = Infinity\n    const retval = new Error().stack\n    Error.stackTraceLimit = oldLimit\n    return retval\n}\n\n/**\n * Creates a replacer function for handling circular references in JSON.stringify.\n * details: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cyclic_object_value\n *\n * @returns {(key: string, value: unknown) => unknown} The replacer function.\n */\nexport function getCircularReplacer(): (key: string, value: unknown) => unknown {\n    const ancestors: unknown[] = []\n    return function (this: unknown, _key: string, value: unknown) {\n        if (typeof value !== 'object' || value === null) {\n            return value\n        }\n        // `this` is the object that value is contained in,\n        // i.e., its direct parent.\n        while (ancestors.length > 0 && ancestors.at(-1) !== this) {\n            ancestors.pop()\n        }\n        if (ancestors.includes(value)) {\n            return '[Circular]'\n        }\n        ancestors.push(value)\n        return value\n    }\n}\n\n/**\n * Extracts caller information from a stack trace line.\n *\n * @param {string} line - The stack trace line.\n * @returns {string} The extracted caller information.\n */\nfunction extractCallerInfo(line: string): string {\n    for (const pattern of [/\\((.*?:\\d+:\\d+)\\)$/, /at (.*?:\\d+:\\d+)$/]) {\n        const m = line.match(pattern)\n        if (m === null) {\n            continue\n        }\n        const [, fileInfoLine] = m\n        return fileInfoLine\n    }\n    return '<unknown>'\n}\n\nfunction getCaller(pattern: RegExp): string {\n    const stack = getStackTrace() ?? ''\n\n    const stackLines = stack.split('\\n')\n\n    const index =\n        stackLines.findIndex((line) => {\n            return line.match(pattern)\n        }) + 1\n\n    let fileInfo = '<unknown>'\n    if (stackLines.length > index) {\n        const line = stackLines[index]\n        fileInfo = extractCallerInfo(line)\n    }\n    return fileInfo\n}\n\n/**\n * Initializes the logger with the specified log level.\n *\n * @param {string} level - The log level.\n */\nexport function initLogger(level: string): void {\n    if (!logger) {\n        logger = createLogger(level)\n    }\n}\n\n// Define custom colors for log levels\nconst levelColors: { [key: string]: (msg: string) => string } = {\n    TRACE: pc.reset,\n    DEBUG: pc.reset,\n    INFO: pc.green,\n    WARN: pc.yellow,\n    ERROR: pc.red,\n    FATAL: pc.red,\n}\n\n// Create a custom stream for logging with colors\nconst customStream = {\n    write: (msg: string): void => {\n        try {\n            const customLogger = (output: string) => {\n                if (typeof process !== 'undefined') {\n                    process.stdout.write(output + '\\n') // Works in Node.js\n                } else {\n                    console.log(output) // Works in Browsers\n                }\n            }\n            const logObj = JSON.parse(msg) // Parse the log message\n            const { level, msg: message, time } = logObj\n\n            const newMsgs: string[] = message.split('#caller#')\n            // Format the time\n            const formattedTime = dayjs(time).format('YYYY-MM-DD HH:mm:ss')\n\n            // Get the appropriate color function (default to reset)\n            const colorFn = levelColors[level] || pc.reset\n\n            newMsgs.forEach((newMsg) => {\n                customLogger(colorFn(`[${formattedTime}] [${level}] ${newMsg}`))\n            })\n        } catch (error) {\n            console.error('Failed to process log:', msg)\n        }\n    },\n}\n\n/**\n * Creates a new logger with the specified log level.\n *\n * @param {string} level - The log level.\n * @returns {Logger} The created logger.\n */\nexport function createLogger(level: string): pino.Logger {\n    const logger = pino(\n        {\n            level,\n            base: undefined,\n            // customLevels: customLevels.levels,\n            // timestamp: () => `,\"time\":\"${formatTime(Date.now())}\"`,\n            formatters: {\n                level(levelLabel, levelNumber) {\n                    return { level: levelLabel.toUpperCase(), levelNumber: levelNumber } // 让日志级别大写\n                },\n            },\n            hooks: {\n                logMethod(inputArgs, method, level) {\n                    const [msg, ...args] = inputArgs\n                    let newMsg = msg\n                    let caller = ''\n                    if (level >= 50) {\n                        caller = getCaller(/lib\\/tools.js/)\n                        newMsg = `${caller}#caller#${msg} `\n                    }\n                    // eslint-disable-next-line @typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unsafe-assignment\n                    method.apply(this, [newMsg, ...args, caller])\n                    // method.apply(this, inputArgs)\n                },\n            },\n        },\n        customStream\n    )\n    return logger\n}\n\n/**\n * Gets the current logger instance.\n *\n * @returns {Logger} The current logger instance.\n * @throws {Error} If the logger is not initialized.\n */\nexport function getLogger(): Logger {\n    initLogger(process.env.LZ_LOG ?? 'info')\n    if (!logger) {\n        throw new Error('Logger is not initialized')\n    }\n    return logger\n}\n\nconst exportsObject: {\n    getCircularReplacer?: (key: unknown, value: unknown) => unknown\n} = {}\n\nif (process.env.NODE_ENV === 'test') {\n    exportsObject.getCircularReplacer = getCircularReplacer\n}\nexport default exportsObject\n","import { ethers } from 'ethers'\n\nimport {\n    Chain,\n    EndpointId,\n    EndpointVersion,\n    Network,\n    isNetworkEndpointIdSupported,\n    networkToChain,\n    networkToEndpointId,\n} from '@layerzerolabs/lz-definitions'\n\n/**\n * Interface representing a contract deployment.\n */\nexport interface Deployment {\n    /** Name of the contract deployment. */\n    name: string\n\n    /** Optional endpoint identifier. */\n    compatibleVersions: EndpointVersion[]\n\n    /** Network of deployment. */\n    network: Network\n\n    /** Optional contract source. */\n    source?: string\n\n    /** Address of deployed contract. */\n    address: string\n\n    /** Optional contract ABI. */\n    abi?: string\n\n    /** Optional contract bytecode. */\n    bytecode?: string\n}\n\n/**\n * Finds the matching deployment based on the given options.\n * @todo Use Partial<EndpointSpec> instead of options\n *\n * @param {Deployment[]} deployments - List of deployments.\n * @param {string} nameOrAddress - Contract name or address.\n * @param {object} options - Options to match against.\n * @param {Chain} [options.chain] - The chain to match.\n * @param {string} [options.source] - The source to match.\n * @param {Network} [options.network] - The network to match.\n * @param {EndpointId} [options.endpointId] - The endpoint ID to match.\n * @returns {Deployment} The matching deployment.\n * @throws {Error} If the deployment is not found.\n */\nexport function findDeployment(\n    deployments: Deployment[],\n    nameOrAddress: string,\n    options: { chain?: Chain; source?: string; network?: Network; endpointId?: EndpointId }\n): Deployment {\n    const retval = tryFindDeployment(deployments, nameOrAddress, options)\n    if (retval === undefined) {\n        throw new Error(`Deployment not found: ${nameOrAddress} options:${JSON.stringify(options)}`)\n    }\n    return retval\n}\n\n/**\n * Tries to find the matching deployment based on the given options.\n *\n * @param {Deployment[]} deployments - List of deployments.\n * @param {string} nameOrAddress - Contract name or address.\n * @param {object} options - Options to match against.\n * @param {Chain} [options.chain] - The chain to match.\n * @param {string} [options.source] - The source to match.\n * @param {Network} [options.network] - The network to match.\n * @param {EndpointId} [options.endpointId] - The endpoint ID to match.\n * @returns {Deployment | undefined} The matching deployment, or undefined if not found.\n */\nexport function tryFindDeployment(\n    deployments: Deployment[],\n    nameOrAddress: string,\n    options: { chain?: Chain; source?: string; network?: Network; endpointId?: EndpointId }\n): Deployment | undefined {\n    return deployments.find((deployment) => {\n        let hasMatchingNameOrAddress = deployment.name === nameOrAddress\n        if (!hasMatchingNameOrAddress && ethers.utils.isAddress(nameOrAddress)) {\n            if (ethers.utils.isAddress(deployment.address)) {\n                hasMatchingNameOrAddress =\n                    ethers.utils.getAddress(deployment.address) === ethers.utils.getAddress(nameOrAddress)\n            } else {\n                hasMatchingNameOrAddress = deployment.address === ethers.utils.getAddress(nameOrAddress)\n            }\n        }\n        const hasMatchingChain = options.chain == null || options.chain === networkToChain(deployment.network)\n        const hasMatchingNetwork = options.network === undefined || options.network === deployment.network\n        const hasMatchingSource = options.source === undefined || options.source === deployment.source\n        let hasMatchingEndpoint = true\n        if (options.endpointId != null) {\n            const compatibleEndpoints = deployment.compatibleVersions.map((v) => {\n                if (isNetworkEndpointIdSupported(deployment.network, v)) {\n                    return networkToEndpointId(deployment.network, v)\n                }\n                return undefined\n            })\n            hasMatchingEndpoint = compatibleEndpoints.includes(options.endpointId)\n        }\n        return (\n            hasMatchingNameOrAddress &&\n            hasMatchingChain &&\n            hasMatchingNetwork &&\n            hasMatchingEndpoint &&\n            hasMatchingSource\n        )\n    })\n}\n\n/**\n * Type representing a mapping of contract addresses to EVM contracts.\n */\ntype ContractType = { [key in string]: ethers.Contract }\n\n/**\n * Cache for storing EVM contracts by their network and address.\n */\nconst contractCache: ContractType = {}\n\n/**\n * Converts a deployment to an EVM contract.\n *\n * @param {Deployment} deployment - The deployment to convert.\n * @param {ethers.providers.Provider} [provider] - The provider to use.\n * @returns {T} The EVM contract.\n * @throws {Error} If the deployment does not have ABI or bytecode.\n */\nexport function deploymentToEvmContract<T extends ethers.Contract>(\n    deployment: Deployment,\n    provider?: ethers.providers.Provider\n): T {\n    const key = `${deployment.network}-${deployment.address}`\n    if (!(key in contractCache)) {\n        if (deployment.abi === undefined || deployment.bytecode === undefined) {\n            throw new Error('Deployment does not have ABI or bytecode')\n        }\n        const Contract = new ethers.ContractFactory(deployment.abi, deployment.bytecode)\n        contractCache[key] = Contract.attach(deployment.address)\n    }\n    if (!provider) {\n        return contractCache[key] as T\n    }\n    return contractCache[key].connect(provider) as T\n}\n\n/**\n * Finds a contract based on the given options.\n *\n * @param {ethers.providers.Provider | undefined} provider - The provider to use.\n * @param {Deployment[]} deployments - List of deployments.\n * @param {string} nameOrAddress - Contract name or address.\n * @param {object} options - Options to match against.\n * @param {Chain} [options.chain] - The chain to match.\n * @param {string} [options.source] - The source to match.\n * @param {Network} [options.network] - The network to match.\n * @param {EndpointId} [options.endpointId] - The endpoint ID to match.\n * @returns {T} The matching contract.\n * @throws {Error} If the deployment is not found.\n */\nexport function findContract<T extends ethers.Contract>(\n    provider: ethers.providers.Provider | undefined,\n    deployments: Deployment[],\n    nameOrAddress: string,\n    options: { chain?: Chain; source?: string; network?: Network; endpointId?: EndpointId }\n): T {\n    const deployment = findDeployment(deployments, nameOrAddress, options)\n    const retval = deploymentToEvmContract<T>(deployment, provider)\n    return retval\n}\n","import module from 'module'\n\n/**\n * Returns the directory name of a path.\n *\n * @param {string} path - The path to get the directory name from.\n * @returns {string} The directory name of the path.\n */\nexport function dirname(path: string): string {\n    const match = path.match(/(.*)([\\\\/][^\\\\/]+)[/\\\\]?$/)\n    const [, basePath] = match ?? []\n    const dirname = typeof basePath !== 'undefined' ? basePath : path\n    return dirname\n}\n\n/**\n * Gets the current stack trace.\n *\n * @param {number} [stackTraceLimit=Infinity] - The stack trace limit.\n * @returns {string | undefined} The current stack trace.\n */\nfunction getStackTrace(stackTraceLimit = Infinity): string | undefined {\n    const oldLimit = Error.stackTraceLimit\n    Error.stackTraceLimit = stackTraceLimit\n    const retval = new Error().stack\n    Error.stackTraceLimit = oldLimit\n    return retval\n}\n\n/**\n * Gets the caller of the current function.\n *\n * @returns {string | undefined} The caller of the current function.\n */\nfunction getCaller(): string | undefined {\n    const lines = (getStackTrace(10) ?? '').split('\\n')\n    // Error:\n    //     at getStackTrace\n    //     at getCaller\n    //     at <caller of getCaller>\n    //     at <expected caller>\n    if (lines.length > 1 + 1 + 1 + 1) {\n        const line = lines[4]\n        const m = line.match(/^.*\\(([^:]*)[^)]*\\)/)\n        if (m) {\n            return m[1]\n        }\n    }\n    return undefined\n}\n\n/**\n * Returns the root path of a package.\n *\n * @param {string} packageName - The name of the package.\n * @param {string} [relativeToPath] - The path to resolve the package root relative to.\n * @returns {string} The root path of the package.\n */\nexport function pkgroot(packageName: string, relativeToPath?: string): string {\n    if (relativeToPath === undefined) {\n        relativeToPath = getCaller()\n        if (relativeToPath === undefined) {\n            relativeToPath = __filename\n        }\n    }\n\n    const filepath = module.createRequire(relativeToPath).resolve(`${packageName}/package.json`)\n    const packagePath = dirname(filepath)\n    // https://github.com/yarnpkg/berry/blob/f67dda88fe9d0a892c44af923cbbc50bfe454e0e/packages/docusaurus/docs/advanced/03-pnp/pnp-spec.md\n    // In order to properly represent packages listing peer dependencies, Yarn relies on a concept\n    // called Virtual Packages. Their most notable property is that they all have different paths\n    // (so that Node.js instantiates them as many times as needed), while still being baked by the\n    // same concrete folder on disk.\n    return packagePath.replace(/.yarn\\/([^/]*\\/)?(__virtual__|\\$\\$virtual)\\/[^/]*\\/\\d*\\//, '')\n}\n","/**\n * Asserts that a condition is true. If the condition is false, throws an error with the provided message.\n *\n * @param {boolean} condition - The condition to assert.\n * @param {string} [message] - The error message to throw if the condition is false.\n * @throws {Error} If the condition is false.\n */\nexport function assert(condition: boolean, message?: string): asserts condition {\n    if (!condition) {\n        throw new Error(`Assertion Error:  ${message ?? 'condition is false'}`)\n    }\n}\n\ntype Constructor<T> = new (...args: any[]) => T\ntype TypeGuard<M> = (v: unknown) => v is M\n\n/**\n * Asserts that a value is of a certain type, using a type guard function.\n * assertType can be used to assert that a value is of a certain type, and without naming a new variable explicitly.\n *\n * @param {T} value - The value to assert the type of.\n * @param {(v: unknown) => v is M} fn - The type guard function.\n * @param {string} [message] - The error message to throw if the value is not of the expected type.\n * @throws {Error} If the value is not of the expected type.\n */\nexport function assertType<T, M>(\n    value: T,\n    typeOrGuard: TypeGuard<M> | Constructor<M>,\n    message?: string\n): asserts value is T & M {\n    // console.debug(typeOrGuard)\n    if (typeof typeOrGuard === 'function') {\n        if (typeOrGuard === (String as any) || typeOrGuard === (Number as any) || typeOrGuard === (Boolean as any)) {\n            if (typeof value !== typeOrGuard.name.toLowerCase()) {\n                throw new Error(`Expected value to be ${message ?? 'of correct type'}`)\n            }\n        } else if ('prototype' in typeOrGuard && typeOrGuard.prototype !== undefined) {\n            // It's a constructor\n            if (!(value instanceof typeOrGuard)) {\n                throw new Error(`Expected value to be ${message ?? 'of correct type'}`)\n            }\n        } else {\n            // It's a type guard function\n            if (!(typeOrGuard as TypeGuard<M>)(value)) {\n                throw new Error(`Expected value to be ${message ?? 'of correct type'}`)\n            }\n        }\n    }\n}\n\n/**\n * Asserts that a value is defined (not undefined or null).\n *\n * @param {T} [value] - The value to assert is defined.\n * @param {string} [message] - The error message to throw if the value is undefined or null.\n * @throws {Error} If the value is undefined or null.\n */\nexport function assertDefined<T>(value?: T, message?: string): asserts value is NonNullable<T> {\n    if (value === undefined || value === null) {\n        throw new Error(message ?? 'Value is undefined or null')\n    }\n}\n\n/**\n * Asserts that a value is of a certain type, using a type guard function, and returns the value.\n *\n * @param {T} value - The value to assert the type of.\n * @param {(v: unknown) => v is M} fn - The type guard function.\n * @param {string} [message] - The error message to throw if the value is not of the expected type.\n * @returns {M} The value, asserted to be of the expected type.\n * @throws {Error} If the value is not of the expected type.\n */\nexport function asType<T, M>(value: T, fn: (v: unknown) => v is M, message?: string): M {\n    if (!fn(value)) {\n        throw new Error(`Expected value to be ${message ?? 'of correct type'}`)\n    }\n    return value\n}\n\n/**\n * Assumes that a value is of a certain type. This function does not perform any runtime checks.\n *\n * @param {unknown} value - The value to assume the type of.\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nexport function assumeType<T>(value: unknown): asserts value is T {}\n","// This file copy from repo:devtools and is located in packages/devtools/src/common/promise.ts\n\nimport { assert } from './assert'\n\n/**\n * Generic type for a hybrid (sync / async) factory\n * that generates an instance of `TOutput` based on arguments of type `TInput`\n *\n * `TInput` represents the list of all function arguments that need to be passed to the factory:\n *\n * ```typescript\n * const mySyncFactory: Factory<[number, boolean], string> = (num: number, bool: boolean): string => \"hello\"\n *\n * const mySyncFactory: Factory<[], string> = async () => \"hello\"\n * ```\n *\n * The hybrid aspect just makes it easier for implementers - if the logic is synchronous,\n * this type will not force any extra `async`.\n */\nexport type Factory<TInput extends unknown[], TOutput> = (...input: TInput) => TOutput | Promise<TOutput>\n\n/**\n * Helper type for argumentless factories a.k.a. tasks\n */\ntype Task<T> = Factory<[], T>\n\n/**\n * Executes tasks in sequence, waiting for each one to finish before starting the next one\n *\n * Will resolve with the output of all tasks or reject with the first rejection.\n *\n * @param {Task<T>[]} tasks\n * @returns {Promise<T[]>}\n */\nexport const sequence = async <T>(tasks: Task<T>[]): Promise<T[]> => {\n    const collector: T[] = []\n\n    for (const task of tasks) {\n        collector.push(await task())\n    }\n\n    return collector\n}\n\n/**\n * Executes tasks in parallel\n *\n * Will resolve with the output of all tasks or reject with the any rejection.\n *\n * @param {Task<T>[]} tasks\n * @returns {Promise<T[]>}\n */\nexport const parallel = async <T>(tasks: Task<T>[]): Promise<T[]> => Promise.all(tasks.map(async (task) => task()))\n\n/**\n * Executes tasks in a sequence until one resolves.\n *\n * Will resolve with the output of the first task that resolves\n * or reject with the last rejection.\n *\n * Will reject immediatelly if no tasks have been passed\n *\n * @param {Task<T>[]} tasks\n * @returns {Promise<T>}\n */\nexport const first = async <T>(tasks: Task<T>[]): Promise<T> => {\n    assert(tasks.length !== 0, `Must have at least one task for first()`)\n\n    let lastError: unknown\n\n    for (const task of tasks) {\n        try {\n            return await task()\n        } catch (error) {\n            lastError = error\n        }\n    }\n\n    throw lastError\n}\n\n/**\n * Helper utility for currying first() - creating a function\n * that behaves like first() but accepts arguments that will be passed to the factory functions\n *\n * @param {Factory<TInput, TOutput>[]} factories\n * @returns {Factory<TInput, TOutput>}\n */\nexport const firstFactory =\n    <TInput extends unknown[], TOutput>(...factories: Factory<TInput, TOutput>[]): Factory<TInput, TOutput> =>\n    async (...input) =>\n        first(factories.map((factory) => async () => factory(...input)))\n\n/**\n * Represents a type that excludes promises.\n * If the input type is a promise, the resulting type is `never`.\n * Otherwise, it is the same as the input type.\n */\nexport type NonPromise<T> = T extends Promise<unknown> ? never : T\n","/**\n * Calls a defined callback function on each element of an array, and returns an array that contains the results.\n * If an error occurs during the execution of the callback function, the function returns the results up to that point and the error.\n *\n * @param {T[]} elements - The array to map over.\n * @param {(item: T, index: number) => R} callbackfn - A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.\n * @returns {[R[], Error | undefined]} A tuple containing the array of results and an optional error.\n */\nexport function safeMap<T, R>(elements: T[], callbackfn: (item: T, index: number) => R): [R[], Error | undefined] {\n    const result: R[] = []\n    try {\n        for (let i = 0; i < elements.length; i++) {\n            const rv = callbackfn(elements[i], i)\n            result.push(rv)\n        }\n        return [result, undefined]\n    } catch (e) {\n        return [result, e as Error]\n    }\n}\n","/**\n * Converts a string or number value to a corresponding enum value.\n *\n * @param {T} enumType - The enum object.\n * @param {string | number} value - The value to convert.\n * @returns {T[keyof T]} The converted enum value.\n * @throws {Error} If the value is not a valid enum value.\n * @example\n * // Usage\n * enum Color {\n *   Red = 'red',\n *   Green = 'green',\n *   Blue = 'blue'\n * }\n *\n * const color: Color = asEnum(Color, 'red');\n * expect(color).toBe(Color.Red);\n *\n * enum Direction {\n *  Up = 1,\n *  Down,\n * }\n *\n * const direction: Direction = asEnum(Direction, 1);\n * expect(direction).toBe(Direction.Up);\n */\nexport function asEnum<T extends object>(enumType: T, value: string | number): T[keyof T] {\n    const enumValues = Object.values(enumType)\n\n    if (enumValues.includes(value)) {\n        return value as T[keyof T]\n    } else {\n        throw new Error(`Invalid enum value: ${value}`)\n    }\n}\n","/**\n * Represents a type that allows partial modification of all properties in a given object type.\n * This type is similar to the built-in `Partial` type in TypeScript.\n * However, it supports deep partial modification, allowing partial modification of nested object properties.\n *\n * @typeparam T - The object type to be partially modified.\n */\nexport type DeepPartial<T> = {\n    [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P]\n}\n\n/**\n * Represents a type that makes all properties of the given type required deeply.\n *\n * This utility type recursively makes all properties of the given type required, including nested properties.\n * If a property is already required, it remains unchanged.\n *\n * @typeParam T - The type to make all properties required.\n * @returns A new type with all properties required.\n *\n * @example\n * ```typescript\n * type Person = {\n *     name?: string;\n *     age?: number;\n *     address?: {\n *         street?: string;\n *         city?: string;\n *     };\n * };\n *\n * type RequiredPerson = DeepRequired<Person>;\n * // Result: {\n * //     name: string;\n * //     age: number;\n * //     address: {\n * //         street: string;\n * //         city: string;\n * //     };\n * // }\n * ```\n */\nexport type DeepRequired<T> = {\n    [P in keyof T]-?: T[P] extends object ? DeepRequired<T[P]> : T[P]\n}\n\n/**\n * Checks if an object has all the required properties specified by the given paths.\n *\n * @template T - The type of the object.\n * @param {DeepPartial<T>} obj - The object to check.\n * @param {string[]} paths - The paths of the required properties.\n * @returns {boolean} - Returns true if the object has all the required properties, otherwise returns false.\n */\nexport function hasRequiredProperties<T>(obj: DeepPartial<T>, paths: string[]): boolean {\n    /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access */\n    return paths.every((path) => {\n        const keys = path.split('.')\n        let current: any = obj\n\n        for (const key of keys) {\n            if (current !== undefined && key in current) {\n                current = current[key]\n            } else {\n                return false\n            }\n        }\n\n        return true\n    })\n    /* eslint-enable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access */\n}\n\n/**\n * Retrieves the nested keys of an object type.\n *\n * @typeParam T - The object type.\n * @returns The union of all nested keys in the object type.\n *\n * @example\n * // Given the following object type:\n * type Person = {\n *   name: string;\n *   age: number;\n *   address: {\n *     street: string;\n *     city: string;\n *   };\n * };\n *\n * // The `NestedKeys` type will return the following union type:\n * // \"name\" | \"age\" | \"address\" | \"address.street\" | \"address.city\"\n * type AllKeys = NestedKeys<Person>;\n */\nexport type NestedKeys<T> = {\n    [K in keyof T]: T[K] extends object ? K | `${K & string}.${NestedKeys<T[K]> & string}` : K\n}[keyof T]\n\n/**\n * Creates a new type that includes only the properties from the input type `T` that are required and not nullable.\n *\n * @typeParam T - The input type.\n * @returns A new type that includes only the required and non-nullable properties from `T`.\n *\n * @example\n * // Define a type with optional and nullable properties\n * type Person = {\n *     name?: string;\n *     age?: number | null;\n *     email: string;\n * };\n *\n * // Create a new type with only the required and non-nullable properties from `Person`\n * type RequiredPerson = RequiredOnly<Person>;\n *\n * // `RequiredPerson` will be:\n * // {\n * //     email: string;\n * // }\n */\nexport type RequiredOnly<T> = {\n    [K in keyof T as Required<T>[K] extends NonNullable<Required<T>[K]> ? K : never]: T[K]\n}\n\n/**\n * `AtLeast` ensures that at least the specified keys `K` of the type `T` are required,\n * while the rest of the properties are optional.\n *\n * @template T - The original type.\n * @template K - The keys of `T` that should be required.\n *\n * @example\n * interface User {\n *   id: string;\n *   name: string;\n *   email?: string;\n *   age?: number;\n * }\n *\n * // At least 'id' and 'name' are required, the rest are optional\n * const user: AtLeast<User, 'email'> = {\n *   id: '123',\n *   name: 'Alice',\n *   email: 'alice@example.com'\n *   // age are optional\n * };\n */\nexport type AtLeast<T, K extends keyof T> = Partial<T> & RequiredOnly<T> & Required<Pick<T, K>>\n\n/**\n * RequireAtLeastOne helps create a type where at least one of the properties of an interface (can be any property) is required to exist.\n * https://learn.microsoft.com/en-us/javascript/api/@azure/keyvault-certificates/requireatleastone?view=azure-node-latest\n */\nexport type RequireAtLeastOne<T> = {\n    [K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>>\n}[keyof T]\n","import * as fs from 'fs'\nimport * as path from 'path'\n\ntype FindUpReturnType<T> = T extends string ? string | undefined : string[]\n\n/**\n * Finds files in the current directory and its parent directories.\n *\n * @param {string | string[]} expectations - The expected file names.\n * @param {object} options - Options for the search.\n * @param {string} [options.cwd] - The current working directory.\n * @returns {FindUpReturnType<T>} An array of file paths that match the expectations or a single file path or undefined.\n */\nexport function findUp<T extends string | string[]>(\n    expectations: T,\n    options: { cwd?: string } = {}\n): FindUpReturnType<T> {\n    const expectationSet = new Set(Array.isArray(expectations) ? expectations : [expectations])\n    if (expectationSet.size === 0) {\n        return (Array.isArray(expectations) ? [] : undefined) as FindUpReturnType<T>\n    }\n\n    const cwd = options.cwd ?? process.cwd()\n    let currentDir = cwd\n\n    while (currentDir !== '/') {\n        const dirFiles = fs.readdirSync(currentDir)\n        const foundFiles = dirFiles.filter((file) => expectationSet.has(file))\n        if (foundFiles.length > 0) {\n            if (!Array.isArray(expectations)) {\n                return path.join(currentDir, foundFiles[0]) as FindUpReturnType<T>\n            }\n            return foundFiles.map((file) => path.join(currentDir, file)) as FindUpReturnType<T>\n        }\n        currentDir = path.dirname(currentDir)\n    }\n    return (Array.isArray(expectations) ? [] : undefined) as FindUpReturnType<T>\n}\n","import module from 'module'\n\n/**\n * Enables TypeScript support for the specified file or module.\n *\n * @param relativeToPath - The path relative to which the TypeScript module should be resolved.\n * @returns void\n *\n * @remarks\n * This function enables TypeScript support by registering the 'ts-node' module and configuring it with the provided options.\n * The 'ts-node' module allows for on-the-fly TypeScript transpilation without the need for a separate build step.\n *\n * @example\n * enableTS(process.cwd());\n */\nexport function enableTS(relativeToPath: string): void {\n    // WARNING: require('ts-node') will cause '[ERROR] Unterminated template (867:31) [plugin commonjs]' in some cases\n    //   this error can be eliminated by assigning the name to a variable and require that variable\n    const moduleName = 'ts-node'\n    const require = module.createRequire(relativeToPath)\n    const modulePath = require.resolve(moduleName)\n\n    // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n    const tsnode = require(modulePath)\n\n    // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access\n    tsnode.register({\n        transpileOnly: true,\n        typeCheck: false,\n    })\n}\n\n/**\n * Loads a JavaScript or TypeScript module.\n *\n * @param fileName - The name of the file to load.\n * @param relativeToPath - The path relative to which the file should be resolved.\n * @returns The loaded module.\n *\n * @example\n * // Load a JavaScript module\n * const myModule = await loadJSorTS('myModule.js', '/path/to/file.js');\n *\n * // Load a TypeScript module\n * const myModule = await loadJSorTS('myModule.ts', '/path/to/file.js');\n */\nexport async function loadJSorTS(fileName: string, relativeToPath: string): Promise<any> {\n    /* eslint-disable @typescript-eslint/no-unsafe-return, @typescript-eslint/restrict-template-expressions */\n    const require = module.createRequire(relativeToPath)\n    const modulePath = require.resolve(fileName)\n\n    if (fileName.endsWith('.ts')) {\n        enableTS(relativeToPath)\n        return require(modulePath)\n    } else if (fileName.endsWith('.mjs')) {\n        return import(modulePath)\n    } else if (fileName.endsWith('.cjs')) {\n        return Promise.resolve(require(modulePath))\n    } else if (fileName.endsWith('.js')) {\n        try {\n            return await Promise.resolve(require(modulePath))\n        } catch (requireError) {\n            try {\n                return await import(modulePath)\n            } catch (importError) {\n                throw new Error(\n                    `Failed to load module: ${fileName}. Require error: ${requireError}. Import error: ${importError}`\n                )\n            }\n        }\n    } else {\n        throw new Error(`Unsupported file extension: ${fileName}`)\n    }\n    /* eslint-enable @typescript-eslint/no-unsafe-return, @typescript-eslint/restrict-template-expressions */\n}\n","import memoizee, { Options } from 'memoizee'\n\nexport function Memoizee<F extends (...args: any[]) => any>(options?: Options<F>): MethodDecorator {\n    return function (target: object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<F>): void {\n        const originalMethod = descriptor.value\n\n        if (typeof originalMethod !== 'function') {\n            throw new Error(`@Memoizee decorator can only be applied to methods.`)\n        }\n\n        const isAsyncFunction = originalMethod.constructor.name === 'AsyncFunction'\n        const memoizeOptions: Options<F> = {\n            ...options,\n            promise: options?.promise ?? isAsyncFunction,\n        }\n\n        if (!isAsyncFunction) {\n            // Check if the function uses a Node.js-style callback\n            const originalMethodStr = originalMethod.toString()\n            if (originalMethodStr.includes('callback') || originalMethodStr.includes('cb')) {\n                memoizeOptions.async = true\n            }\n        }\n\n        const memoizedFn = memoizee(originalMethod, memoizeOptions)\n        const fn = memoizedFn as F & { clear: () => void }\n        fn.clear = (): void => {\n            memoizedFn.clear()\n        }\n\n        descriptor.value = fn\n    } as MethodDecorator\n}\n","/**\n * Extracts the element type from an array type, or returns the type itself if not an array\n * @template T The input type to extract from\n * @example\n * type A = ElementOf<number[]> // number\n * type B = ElementOf<string> // string\n */\ntype ElementOf<T> = T extends (infer U)[] ? U : T\n\n/**\n * Takes multiple inputs and returns their cartesian product as an array of tuples.\n * Each input can be either a single value or an array of values.\n * @template T Array of input types\n * @param inputs Rest parameter of inputs, where each input can be a single value or array\n * @returns Array of tuples containing all possible combinations of input elements\n * @example\n * cartesianProduct(1, ['a', 'b'], [true])\n * // Returns: [[1, 'a', true], [1, 'b', true]]\n *\n * cartesianProduct(['x', 'y'], [1, 2])\n * // Returns: [['x', 1], ['x', 2], ['y', 1], ['y', 2]]\n *\n * cartesianProduct()\n * // Returns: []\n *\n * cartesianProduct([], [])\n * // Returns: []\n */\n\nexport function cartesianProduct<T extends readonly unknown[]>(...inputs: T): { [K in keyof T]: ElementOf<T[K]> }[] {\n    /* eslint-disable @typescript-eslint/no-unsafe-return */\n\n    if (inputs.length === 0) {\n        return [] as { [K in keyof T]: ElementOf<T[K]> }[]\n    }\n\n    // Convert single elements into single-element arrays\n    // e.g., [1, ['a', 'b'], true] → [[1], ['a', 'b'], [true]]\n    const normalizedArrays = inputs.map((input) => (Array.isArray(input) ? input : [input]))\n\n    // Build combinations progressively\n    // e.g., [[]] → [[1]] → [[1,'a'], [1,'b']] → [[1,'a',true], [1,'b',true]]\n    return normalizedArrays.reduce<unknown[][]>(\n        (combinations, currentArray) =>\n            combinations.flatMap((combination) => currentArray.map((element) => [...combination, element])),\n        [[]]\n    ) as { [K in keyof T]: ElementOf<T[K]> }[]\n\n    /* eslint-enable @typescript-eslint/no-unsafe-return */\n}\n","import http, { RequestOptions } from 'http'\nimport path from 'path'\n\nexport * from './account'\nexport * from './logger'\nexport * from './deployment'\nexport * from './path'\nexport * from './promise'\nexport * from './types'\nexport * from './assert'\nexport * from './array'\nexport * from './enum'\nexport * from './pad'\nexport * from './format'\nexport * from './generic'\nexport * from './findup'\nexport * from './loader'\nexport * from './memoize'\nexport * from './combinatorial'\n\nimport { findUp as findUpSync } from './findup'\nimport { getLogger } from './logger'\n\nexport const logger = getLogger()\n\n/**\n * Sleeps for the specified timeout.\n *\n * @param {number} timeout - The timeout in milliseconds.\n * @returns {Promise<void>} A promise that resolves after the timeout.\n */\nexport async function sleep(timeout: number): Promise<void> {\n    await new Promise((resolve) => setTimeout(resolve, timeout))\n}\n\n/**\n * Gets the package manager used in the project.\n *\n * @param {string} [cwd] - The current working directory.\n * @returns {'yarn' | 'npm' | 'pnpm'} The package manager used in the project.\n * @throws {Error} If no package manager is found.\n */\nexport function getProjectPackageManager(cwd?: string): 'yarn' | 'npm' | 'pnpm' {\n    const yarn = findUpSync('yarn.lock', { cwd })\n    if (yarn !== undefined) return 'yarn'\n\n    const npm = findUpSync('package-lock.json', { cwd })\n    if (npm !== undefined) return 'npm'\n\n    // pnpm\n    const pnpm = findUpSync('pnpm-lock.yaml', { cwd })\n    if (pnpm !== undefined) return 'pnpm'\n\n    throw new Error('Cannot find package.json or yarn.lock')\n}\n\n/**\n * Gets the root directory of the project.\n *\n * @param {string} [cwd] - The current working directory.\n * @returns {string} The root directory of the project.\n * @throws {Error} If no root directory is found.\n */\nexport function getProjectRootDir(cwd?: string): string {\n    const yarn = findUpSync('yarn.lock', { cwd })\n    if (yarn !== undefined) return path.dirname(yarn)\n\n    const npm = findUpSync('package-lock.json', { cwd })\n    if (npm !== undefined) return path.dirname(npm)\n\n    const pnpm = findUpSync('pnpm-lock.yaml', { cwd })\n    if (pnpm !== undefined) return path.dirname(pnpm)\n\n    throw new Error('Cannot find yarn.lock or package-lock.json or pnpm-lock.yaml')\n}\n\n/**\n * Checks if an HTTP service is reachable.\n *\n * @param {string} host - The host of the HTTP service.\n * @param {number} port - The port of the HTTP service.\n * @param {number} timeout - The timeout in milliseconds.\n * @param {string} [path] - The path to check.\n * @returns {Promise<boolean>} A promise that resolves to true if the service is reachable, false otherwise.\n */\nexport async function isHttpServiceReachable(\n    host: string,\n    port: number,\n    timeout: number,\n    path?: string\n): Promise<boolean> {\n    return new Promise((resolve, _reject) => {\n        const options: RequestOptions = {\n            host,\n            port,\n            timeout,\n            path,\n            method: 'HEAD',\n        }\n\n        const request = http.request(options, (_response) => {\n            resolve(true)\n        })\n\n        request.on('error', (_err) => {\n            resolve(false)\n        })\n\n        request.end()\n    })\n}\n\n/**\n * Extracts information from a URL.\n *\n * @param {string} url - The URL to extract information from.\n * @returns {{ schema: 'http' | 'https'; host: string; port: string }} An object containing the schema, host, and port.\n * @throws {Error} If the URL is invalid.\n */\nexport function extractUrlInfo(url: string): {\n    schema: 'http' | 'https'\n    host: string\n    port: string\n} {\n    //TODO: handle the default port for http and https(443, 80)\n    const m = url.match(/(?<schema>http|https):\\/\\/(?<host>.*):(?<port>\\d+)/)\n    if (m?.groups?.host === undefined) {\n        throw new Error(`Invalid url ${url}`)\n    }\n\n    return {\n        schema: m.groups.schema as 'http' | 'https',\n        host: m.groups.host,\n        port: m.groups.port,\n    }\n}\n"]}