coinley-checkout
Version:
A React SDK for Coinley cryptocurrency payment processing with multi-network support
1 lines • 1.76 MB
Source Map (JSON)
{"version":3,"file":"index-493501fe.mjs","sources":["../node_modules/ox/node_modules/@noble/hashes/esm/utils.js","../node_modules/ox/_esm/core/internal/bytes.js","../node_modules/ox/_esm/core/Bytes.js","../node_modules/viem/_esm/actions/ens/getEnsAddress.js","../node_modules/viem/_esm/actions/ens/getEnsResolver.js","../node_modules/viem/_esm/actions/public/createAccessList.js","../node_modules/viem/_esm/utils/filters/createFilterRequestScope.js","../node_modules/viem/_esm/actions/public/createBlockFilter.js","../node_modules/viem/_esm/errors/log.js","../node_modules/viem/_esm/utils/abi/encodeEventTopics.js","../node_modules/viem/_esm/actions/public/createContractEventFilter.js","../node_modules/viem/_esm/actions/public/createEventFilter.js","../node_modules/viem/_esm/actions/public/createPendingTransactionFilter.js","../node_modules/viem/_esm/actions/public/estimateContractGas.js","../node_modules/viem/_esm/actions/public/getBlobBaseFee.js","../node_modules/viem/_esm/utils/promise/withCache.js","../node_modules/viem/_esm/actions/public/getBlockNumber.js","../node_modules/viem/_esm/actions/public/getBlockTransactionCount.js","../node_modules/viem/_esm/actions/public/getCode.js","../node_modules/viem/_esm/utils/abi/decodeEventLog.js","../node_modules/viem/_esm/utils/abi/parseEventLogs.js","../node_modules/viem/_esm/actions/public/getLogs.js","../node_modules/viem/_esm/actions/public/getContractEvents.js","../node_modules/viem/_esm/errors/eip712.js","../node_modules/viem/_esm/actions/public/getEip712Domain.js","../node_modules/viem/_esm/utils/formatters/feeHistory.js","../node_modules/viem/_esm/actions/public/getFeeHistory.js","../node_modules/viem/_esm/actions/public/getFilterChanges.js","../node_modules/viem/_esm/actions/public/getFilterLogs.js","../node_modules/viem/_esm/actions/public/getStorageAt.js","../node_modules/viem/_esm/actions/public/getTransaction.js","../node_modules/viem/_esm/actions/public/getTransactionConfirmations.js","../node_modules/viem/_esm/actions/public/getTransactionReceipt.js","../node_modules/viem/_esm/actions/public/simulateBlocks.js","../node_modules/ox/node_modules/abitype/dist/esm/version.js","../node_modules/ox/node_modules/abitype/dist/esm/errors.js","../node_modules/ox/node_modules/abitype/dist/esm/regex.js","../node_modules/ox/node_modules/abitype/dist/esm/human-readable/formatAbiParameter.js","../node_modules/ox/node_modules/abitype/dist/esm/human-readable/formatAbiParameters.js","../node_modules/ox/node_modules/abitype/dist/esm/human-readable/formatAbiItem.js","../node_modules/ox/node_modules/abitype/dist/esm/human-readable/runtime/signatures.js","../node_modules/ox/node_modules/abitype/dist/esm/human-readable/errors/abiItem.js","../node_modules/ox/node_modules/abitype/dist/esm/human-readable/errors/abiParameter.js","../node_modules/ox/node_modules/abitype/dist/esm/human-readable/errors/signature.js","../node_modules/ox/node_modules/abitype/dist/esm/human-readable/errors/struct.js","../node_modules/ox/node_modules/abitype/dist/esm/human-readable/errors/splitParameters.js","../node_modules/ox/node_modules/abitype/dist/esm/human-readable/runtime/cache.js","../node_modules/ox/node_modules/abitype/dist/esm/human-readable/runtime/utils.js","../node_modules/ox/node_modules/abitype/dist/esm/human-readable/runtime/structs.js","../node_modules/ox/node_modules/abitype/dist/esm/human-readable/parseAbiItem.js","../node_modules/ox/node_modules/@noble/hashes/esm/_u64.js","../node_modules/ox/node_modules/@noble/hashes/esm/sha3.js","../node_modules/ox/_esm/core/Hash.js","../node_modules/ox/_esm/core/internal/lru.js","../node_modules/ox/_esm/core/Caches.js","../node_modules/ox/_esm/core/Address.js","../node_modules/ox/_esm/core/internal/abiItem.js","../node_modules/ox/_esm/core/AbiItem.js","../node_modules/ox/_esm/core/Solidity.js","../node_modules/ox/_esm/core/internal/abiParameters.js","../node_modules/ox/_esm/core/AbiParameters.js","../node_modules/ox/_esm/core/AbiConstructor.js","../node_modules/ox/_esm/core/AbiFunction.js","../node_modules/viem/_esm/constants/address.js","../node_modules/viem/_esm/utils/signature/hashTypedData.js","../node_modules/viem/_esm/utils/abi/encodePacked.js","../node_modules/viem/_esm/constants/strings.js","../node_modules/viem/_esm/utils/signature/toPrefixedMessage.js","../node_modules/viem/_esm/utils/signature/hashMessage.js","../node_modules/viem/_esm/constants/bytes.js","../node_modules/viem/_esm/utils/signature/isErc6492Signature.js","../node_modules/viem/_esm/utils/signature/serializeErc6492Signature.js","../node_modules/viem/_esm/utils/nonceManager.js","../node_modules/viem/_esm/actions/public/simulateCalls.js","../node_modules/viem/_esm/utils/observe.js","../node_modules/viem/_esm/utils/poll.js","../node_modules/viem/_esm/actions/public/watchBlocks.js","../node_modules/viem/_esm/actions/public/watchBlockNumber.js","../node_modules/viem/_esm/actions/public/uninstallFilter.js","../node_modules/viem/_esm/actions/public/watchEvent.js","../node_modules/viem/_esm/actions/public/watchPendingTransactions.js","../node_modules/viem/_esm/actions/wallet/sendCalls.js","../node_modules/viem/_esm/actions/wallet/getCallsStatus.js","../node_modules/viem/_esm/errors/calls.js","../node_modules/viem/_esm/actions/wallet/waitForCallsStatus.js","../node_modules/viem/_esm/utils/formatters/proof.js","../node_modules/viem/_esm/actions/public/getProof.js","../node_modules/viem/_esm/actions/public/waitForTransactionReceipt.js","../node_modules/viem/_esm/actions/wallet/prepareAuthorization.js","../node_modules/viem/_esm/actions/public/simulateContract.js","../node_modules/viem/_esm/utils/signature/serializeSignature.js","../node_modules/viem/_esm/actions/public/verifyHash.js","../node_modules/viem/_esm/actions/public/verifyMessage.js","../node_modules/viem/_esm/actions/public/verifyTypedData.js","../node_modules/viem/_esm/actions/public/watchContractEvent.js","../node_modules/viem/_esm/utils/siwe/parseSiweMessage.js","../node_modules/viem/_esm/utils/siwe/validateSiweMessage.js","../node_modules/viem/_esm/actions/siwe/verifySiweMessage.js","../node_modules/viem/_esm/clients/decorators/public.js","../node_modules/viem/_esm/clients/createPublicClient.js","../node_modules/viem/_esm/utils/signature/parseSignature.js","../node_modules/zustand/esm/middleware.mjs","../node_modules/zustand/esm/vanilla.mjs","../node_modules/viem/_esm/account-abstraction/constants/abis.js","../node_modules/viem/_esm/account-abstraction/utils/userOperation/getInitCode.js","../node_modules/viem/_esm/account-abstraction/utils/userOperation/toPackedUserOperation.js","../node_modules/viem/_esm/account-abstraction/utils/userOperation/getUserOperationTypedData.js","../node_modules/viem/_esm/account-abstraction/utils/userOperation/getUserOperationHash.js","../node_modules/viem/_esm/account-abstraction/accounts/toSmartAccount.js","../node_modules/viem/_esm/account-abstraction/errors/bundler.js","../node_modules/viem/_esm/account-abstraction/errors/userOperation.js","../node_modules/viem/_esm/account-abstraction/utils/errors/getBundlerError.js","../node_modules/viem/_esm/account-abstraction/utils/errors/getUserOperationError.js","../node_modules/viem/_esm/account-abstraction/utils/formatters/userOperationGas.js","../node_modules/viem/_esm/account-abstraction/utils/formatters/userOperationRequest.js","../node_modules/viem/_esm/account-abstraction/actions/paymaster/getPaymasterData.js","../node_modules/viem/_esm/account-abstraction/actions/paymaster/getPaymasterStubData.js","../node_modules/viem/_esm/account-abstraction/actions/bundler/prepareUserOperation.js","../node_modules/viem/_esm/account-abstraction/actions/bundler/estimateUserOperationGas.js","../node_modules/viem/_esm/account-abstraction/actions/bundler/getSupportedEntryPoints.js","../node_modules/viem/_esm/account-abstraction/utils/formatters/userOperation.js","../node_modules/viem/_esm/account-abstraction/actions/bundler/getUserOperation.js","../node_modules/viem/_esm/account-abstraction/utils/formatters/userOperationReceipt.js","../node_modules/viem/_esm/account-abstraction/actions/bundler/getUserOperationReceipt.js","../node_modules/viem/_esm/account-abstraction/actions/bundler/sendUserOperation.js","../node_modules/viem/_esm/account-abstraction/actions/bundler/waitForUserOperationReceipt.js","../node_modules/viem/_esm/account-abstraction/clients/decorators/bundler.js","../node_modules/viem/_esm/account-abstraction/clients/createBundlerClient.js","../node_modules/viem/_esm/account-abstraction/constants/address.js","../node_modules/@coinbase/wallet-sdk/dist/sdk-info.js","../node_modules/@coinbase/wallet-sdk/dist/store/store.js","../node_modules/@coinbase/wallet-sdk/dist/core/telemetry/telemetry-content.js","../node_modules/@coinbase/wallet-sdk/dist/core/telemetry/initCCA.js","../node_modules/@coinbase/wallet-sdk/dist/core/error/constants.js","../node_modules/@coinbase/wallet-sdk/dist/core/error/utils.js","../node_modules/@coinbase/wallet-sdk/dist/core/error/errors.js","../node_modules/@coinbase/wallet-sdk/dist/core/type/index.js","../node_modules/@coinbase/wallet-sdk/dist/core/type/util.js","../node_modules/@coinbase/wallet-sdk/dist/util/checkCrossOriginOpenerPolicy.js","../node_modules/@coinbase/wallet-sdk/dist/util/provider.js","../node_modules/@coinbase/wallet-sdk/dist/util/validatePreferences.js","../node_modules/@coinbase/wallet-sdk/dist/core/constants.js","../node_modules/@coinbase/wallet-sdk/dist/core/telemetry/logEvent.js","../node_modules/@coinbase/wallet-sdk/dist/core/telemetry/events/communicator.js","../node_modules/@coinbase/wallet-sdk/dist/core/telemetry/events/snackbar.js","../node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/relay/ui/components/cssReset/cssReset-css.js","../node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/relay/ui/components/cssReset/cssReset.js","../node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/relay/ui/components/util.js","../node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/relay/ui/components/Snackbar/Snackbar-css.js","../node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/relay/ui/components/Snackbar/Snackbar.js","../node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/relay/ui/WalletLinkRelayUI.js","../node_modules/@coinbase/wallet-sdk/dist/util/web.js","../node_modules/@coinbase/wallet-sdk/dist/core/communicator/Communicator.js","../node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/relay/type/Web3Response.js","../node_modules/@coinbase/wallet-sdk/dist/core/error/serialize.js","../node_modules/@coinbase/wallet-sdk/dist/core/provider/interface.js","../node_modules/@coinbase/wallet-sdk/dist/core/storage/ScopedLocalStorage.js","../node_modules/@coinbase/wallet-sdk/dist/core/telemetry/events/provider.js","../node_modules/@coinbase/wallet-sdk/dist/core/telemetry/events/signer-selection.js","../node_modules/@coinbase/wallet-sdk/dist/store/correlation-ids/store.js","../node_modules/@coinbase/wallet-sdk/dist/core/telemetry/events/scw-signer.js","../node_modules/@coinbase/wallet-sdk/dist/core/telemetry/events/scw-sub-account.js","../node_modules/@coinbase/wallet-sdk/dist/core/telemetry/utils.js","../node_modules/@coinbase/wallet-sdk/dist/store/chain-clients/store.js","../node_modules/@coinbase/wallet-sdk/dist/store/chain-clients/utils.js","../node_modules/@coinbase/wallet-sdk/dist/util/assertPresence.js","../node_modules/@coinbase/wallet-sdk/dist/util/assertSubAccount.js","../node_modules/@coinbase/wallet-sdk/dist/util/cipher.js","../node_modules/@coinbase/wallet-sdk/node_modules/ox/_esm/core/version.js","../node_modules/@coinbase/wallet-sdk/node_modules/ox/_esm/core/internal/errors.js","../node_modules/@coinbase/wallet-sdk/node_modules/ox/_esm/core/Errors.js","../node_modules/@coinbase/wallet-sdk/node_modules/ox/node_modules/@noble/hashes/esm/utils.js","../node_modules/@coinbase/wallet-sdk/node_modules/ox/node_modules/@noble/hashes/esm/_md.js","../node_modules/@coinbase/wallet-sdk/node_modules/ox/node_modules/@noble/hashes/esm/sha2.js","../node_modules/@coinbase/wallet-sdk/node_modules/ox/node_modules/@noble/hashes/esm/sha256.js","../node_modules/@coinbase/wallet-sdk/node_modules/@noble/curves/node_modules/@noble/hashes/esm/crypto.js","../node_modules/@coinbase/wallet-sdk/node_modules/@noble/curves/node_modules/@noble/hashes/esm/utils.js","../node_modules/@coinbase/wallet-sdk/node_modules/@noble/curves/esm/utils.js","../node_modules/@coinbase/wallet-sdk/node_modules/ox/_esm/core/Json.js","../node_modules/@coinbase/wallet-sdk/node_modules/ox/_esm/core/internal/bytes.js","../node_modules/@coinbase/wallet-sdk/node_modules/ox/_esm/core/internal/hex.js","../node_modules/@coinbase/wallet-sdk/node_modules/ox/_esm/core/Hex.js","../node_modules/@coinbase/wallet-sdk/node_modules/ox/_esm/core/Bytes.js","../node_modules/@coinbase/wallet-sdk/node_modules/ox/_esm/core/Hash.js","../node_modules/@coinbase/wallet-sdk/node_modules/ox/_esm/core/PublicKey.js","../node_modules/@coinbase/wallet-sdk/node_modules/ox/_esm/core/Solidity.js","../node_modules/@coinbase/wallet-sdk/node_modules/@noble/curves/node_modules/@noble/hashes/esm/_md.js","../node_modules/@coinbase/wallet-sdk/node_modules/@noble/curves/node_modules/@noble/hashes/esm/_u64.js","../node_modules/@coinbase/wallet-sdk/node_modules/@noble/curves/node_modules/@noble/hashes/esm/sha2.js","../node_modules/@coinbase/wallet-sdk/node_modules/@noble/curves/node_modules/@noble/hashes/esm/hmac.js","../node_modules/@coinbase/wallet-sdk/node_modules/@noble/curves/esm/abstract/modular.js","../node_modules/@coinbase/wallet-sdk/node_modules/@noble/curves/esm/abstract/curve.js","../node_modules/@coinbase/wallet-sdk/node_modules/@noble/curves/esm/abstract/weierstrass.js","../node_modules/@coinbase/wallet-sdk/node_modules/@noble/curves/esm/_shortw_utils.js","../node_modules/@coinbase/wallet-sdk/node_modules/ox/_esm/core/Signature.js","../node_modules/@coinbase/wallet-sdk/node_modules/ox/_esm/core/Base64.js","../node_modules/@coinbase/wallet-sdk/node_modules/@noble/curves/esm/nist.js","../node_modules/@coinbase/wallet-sdk/node_modules/@noble/curves/esm/p256.js","../node_modules/@coinbase/wallet-sdk/node_modules/ox/_esm/core/WebAuthnP256.js","../node_modules/@coinbase/wallet-sdk/node_modules/ox/_esm/core/WebCryptoP256.js","../node_modules/@coinbase/wallet-sdk/dist/kms/crypto-key/storage.js","../node_modules/@coinbase/wallet-sdk/dist/kms/crypto-key/index.js","../node_modules/@coinbase/wallet-sdk/dist/sign/scw/SCWKeyManager.js","../node_modules/@coinbase/wallet-sdk/dist/util/get.js","../node_modules/@coinbase/wallet-sdk/dist/sign/scw/utils/constants.js","../node_modules/@coinbase/wallet-sdk/dist/sign/scw/utils.js","../node_modules/@coinbase/wallet-sdk/dist/util/encoding.js","../node_modules/@coinbase/wallet-sdk/dist/sign/scw/utils/createSmartAccount.js","../node_modules/@coinbase/wallet-sdk/dist/sign/scw/utils/createSubAccountSigner.js","../node_modules/@coinbase/wallet-sdk/dist/sign/scw/utils/findOwnerIndex.js","../node_modules/@coinbase/wallet-sdk/dist/sign/scw/utils/presentAddOwnerDialog.js","../node_modules/@coinbase/wallet-sdk/dist/sign/scw/utils/handleAddSubAccountOwner.js","../node_modules/@coinbase/wallet-sdk/dist/sign/scw/utils/handleInsufficientBalance.js","../node_modules/@coinbase/wallet-sdk/dist/sign/scw/SCWSigner.js","../node_modules/@coinbase/wallet-sdk/dist/core/telemetry/events/walletlink-signer.js","../node_modules/@noble/hashes/_assert.js","../node_modules/@noble/hashes/_u64.js","../node_modules/@noble/hashes/esm/crypto.js","../node_modules/@noble/hashes/utils.js","../node_modules/@noble/hashes/sha3.js","../node_modules/@coinbase/wallet-sdk/dist/vendor-js/eth-eip712-util/util.cjs","../node_modules/@coinbase/wallet-sdk/dist/vendor-js/eth-eip712-util/abi.cjs","../node_modules/@coinbase/wallet-sdk/dist/vendor-js/eth-eip712-util/index.cjs","../node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/relay/constants.js","../node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/relay/connection/WalletLinkCipher.js","../node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/relay/connection/WalletLinkHTTP.js","../node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/relay/connection/WalletLinkWebSocket.js","../node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/relay/connection/WalletLinkConnection.js","../node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/relay/RelayEventManager.js","../node_modules/@noble/hashes/esm/_assert.js","../node_modules/@noble/hashes/esm/utils.js","../node_modules/@noble/hashes/esm/_md.js","../node_modules/@noble/hashes/esm/sha256.js","../node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/relay/type/WalletLinkSession.js","../node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/relay/ui/components/RedirectDialog/RedirectDialog-css.js","../node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/relay/ui/components/RedirectDialog/RedirectDialog.js","../node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/relay/ui/WLMobileRelayUI.js","../node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/relay/WalletLinkRelay.js","../node_modules/@coinbase/wallet-sdk/dist/sign/walletlink/WalletLinkSigner.js","../node_modules/@coinbase/wallet-sdk/dist/sign/util.js","../node_modules/@coinbase/wallet-sdk/dist/CoinbaseWalletProvider.js","../node_modules/@coinbase/wallet-sdk/dist/createCoinbaseWalletProvider.js","../node_modules/@coinbase/wallet-sdk/dist/createCoinbaseWalletSDK.js"],"sourcesContent":["/**\n * Utilities for hex, bytes, CSPRNG.\n * @module\n */\n/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */\n// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.\n// node.js versions earlier than v19 don't declare it in global scope.\n// For node.js, package.json#exports field mapping rewrites import\n// from `crypto` to `cryptoNode`, which imports native module.\n// Makes the utils un-importable in browsers without a bundler.\n// Once node.js 18 is deprecated (2025-04-30), we can just drop the import.\nimport { crypto } from '@noble/hashes/crypto';\n/** Checks if something is Uint8Array. Be careful: nodejs Buffer will return true. */\nexport function isBytes(a) {\n return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');\n}\n/** Asserts something is positive integer. */\nexport function anumber(n) {\n if (!Number.isSafeInteger(n) || n < 0)\n throw new Error('positive integer expected, got ' + n);\n}\n/** Asserts something is Uint8Array. */\nexport function abytes(b, ...lengths) {\n if (!isBytes(b))\n throw new Error('Uint8Array expected');\n if (lengths.length > 0 && !lengths.includes(b.length))\n throw new Error('Uint8Array expected of length ' + lengths + ', got length=' + b.length);\n}\n/** Asserts something is hash */\nexport function ahash(h) {\n if (typeof h !== 'function' || typeof h.create !== 'function')\n throw new Error('Hash should be wrapped by utils.createHasher');\n anumber(h.outputLen);\n anumber(h.blockLen);\n}\n/** Asserts a hash instance has not been destroyed / finished */\nexport function aexists(instance, checkFinished = true) {\n if (instance.destroyed)\n throw new Error('Hash instance has been destroyed');\n if (checkFinished && instance.finished)\n throw new Error('Hash#digest() has already been called');\n}\n/** Asserts output is properly-sized byte array */\nexport function aoutput(out, instance) {\n abytes(out);\n const min = instance.outputLen;\n if (out.length < min) {\n throw new Error('digestInto() expects output buffer of length at least ' + min);\n }\n}\n/** Cast u8 / u16 / u32 to u8. */\nexport function u8(arr) {\n return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);\n}\n/** Cast u8 / u16 / u32 to u32. */\nexport function u32(arr) {\n return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));\n}\n/** Zeroize a byte array. Warning: JS provides no guarantees. */\nexport function clean(...arrays) {\n for (let i = 0; i < arrays.length; i++) {\n arrays[i].fill(0);\n }\n}\n/** Create DataView of an array for easy byte-level manipulation. */\nexport function createView(arr) {\n return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);\n}\n/** The rotate right (circular right shift) operation for uint32 */\nexport function rotr(word, shift) {\n return (word << (32 - shift)) | (word >>> shift);\n}\n/** The rotate left (circular left shift) operation for uint32 */\nexport function rotl(word, shift) {\n return (word << shift) | ((word >>> (32 - shift)) >>> 0);\n}\n/** Is current platform little-endian? Most are. Big-Endian platform: IBM */\nexport const isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44)();\n/** The byte swap operation for uint32 */\nexport function byteSwap(word) {\n return (((word << 24) & 0xff000000) |\n ((word << 8) & 0xff0000) |\n ((word >>> 8) & 0xff00) |\n ((word >>> 24) & 0xff));\n}\n/** Conditionally byte swap if on a big-endian platform */\nexport const swap8IfBE = isLE\n ? (n) => n\n : (n) => byteSwap(n);\n/** @deprecated */\nexport const byteSwapIfBE = swap8IfBE;\n/** In place byte swap for Uint32Array */\nexport function byteSwap32(arr) {\n for (let i = 0; i < arr.length; i++) {\n arr[i] = byteSwap(arr[i]);\n }\n return arr;\n}\nexport const swap32IfBE = isLE\n ? (u) => u\n : byteSwap32;\n// Built-in hex conversion https://caniuse.com/mdn-javascript_builtins_uint8array_fromhex\nconst hasHexBuiltin = /* @__PURE__ */ (() => \n// @ts-ignore\ntypeof Uint8Array.from([]).toHex === 'function' && typeof Uint8Array.fromHex === 'function')();\n// Array where index 0xf0 (240) is mapped to string 'f0'\nconst hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0'));\n/**\n * Convert byte array to hex string. Uses built-in function, when available.\n * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'\n */\nexport function bytesToHex(bytes) {\n abytes(bytes);\n // @ts-ignore\n if (hasHexBuiltin)\n return bytes.toHex();\n // pre-caching improves the speed 6x\n let hex = '';\n for (let i = 0; i < bytes.length; i++) {\n hex += hexes[bytes[i]];\n }\n return hex;\n}\n// We use optimized technique to convert hex string to byte array\nconst asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };\nfunction asciiToBase16(ch) {\n if (ch >= asciis._0 && ch <= asciis._9)\n return ch - asciis._0; // '2' => 50-48\n if (ch >= asciis.A && ch <= asciis.F)\n return ch - (asciis.A - 10); // 'B' => 66-(65-10)\n if (ch >= asciis.a && ch <= asciis.f)\n return ch - (asciis.a - 10); // 'b' => 98-(97-10)\n return;\n}\n/**\n * Convert hex string to byte array. Uses built-in function, when available.\n * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])\n */\nexport function hexToBytes(hex) {\n if (typeof hex !== 'string')\n throw new Error('hex string expected, got ' + typeof hex);\n // @ts-ignore\n if (hasHexBuiltin)\n return Uint8Array.fromHex(hex);\n const hl = hex.length;\n const al = hl / 2;\n if (hl % 2)\n throw new Error('hex string expected, got unpadded hex of length ' + hl);\n const array = new Uint8Array(al);\n for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {\n const n1 = asciiToBase16(hex.charCodeAt(hi));\n const n2 = asciiToBase16(hex.charCodeAt(hi + 1));\n if (n1 === undefined || n2 === undefined) {\n const char = hex[hi] + hex[hi + 1];\n throw new Error('hex string expected, got non-hex character \"' + char + '\" at index ' + hi);\n }\n array[ai] = n1 * 16 + n2; // multiply first octet, e.g. 'a3' => 10*16+3 => 160 + 3 => 163\n }\n return array;\n}\n/**\n * There is no setImmediate in browser and setTimeout is slow.\n * Call of async fn will return Promise, which will be fullfiled only on\n * next scheduler queue processing step and this is exactly what we need.\n */\nexport const nextTick = async () => { };\n/** Returns control to thread each 'tick' ms to avoid blocking. */\nexport async function asyncLoop(iters, tick, cb) {\n let ts = Date.now();\n for (let i = 0; i < iters; i++) {\n cb(i);\n // Date.now() is not monotonic, so in case if clock goes backwards we return return control too\n const diff = Date.now() - ts;\n if (diff >= 0 && diff < tick)\n continue;\n await nextTick();\n ts += diff;\n }\n}\n/**\n * Converts string to bytes using UTF8 encoding.\n * @example utf8ToBytes('abc') // Uint8Array.from([97, 98, 99])\n */\nexport function utf8ToBytes(str) {\n if (typeof str !== 'string')\n throw new Error('string expected');\n return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809\n}\n/**\n * Converts bytes to string using UTF8 encoding.\n * @example bytesToUtf8(Uint8Array.from([97, 98, 99])) // 'abc'\n */\nexport function bytesToUtf8(bytes) {\n return new TextDecoder().decode(bytes);\n}\n/**\n * Normalizes (non-hex) string or Uint8Array to Uint8Array.\n * Warning: when Uint8Array is passed, it would NOT get copied.\n * Keep in mind for future mutable operations.\n */\nexport function toBytes(data) {\n if (typeof data === 'string')\n data = utf8ToBytes(data);\n abytes(data);\n return data;\n}\n/**\n * Helper for KDFs: consumes uint8array or string.\n * When string is passed, does utf8 decoding, using TextDecoder.\n */\nexport function kdfInputToBytes(data) {\n if (typeof data === 'string')\n data = utf8ToBytes(data);\n abytes(data);\n return data;\n}\n/** Copies several Uint8Arrays into one. */\nexport function concatBytes(...arrays) {\n let sum = 0;\n for (let i = 0; i < arrays.length; i++) {\n const a = arrays[i];\n abytes(a);\n sum += a.length;\n }\n const res = new Uint8Array(sum);\n for (let i = 0, pad = 0; i < arrays.length; i++) {\n const a = arrays[i];\n res.set(a, pad);\n pad += a.length;\n }\n return res;\n}\nexport function checkOpts(defaults, opts) {\n if (opts !== undefined && {}.toString.call(opts) !== '[object Object]')\n throw new Error('options should be object or undefined');\n const merged = Object.assign(defaults, opts);\n return merged;\n}\n/** For runtime check if class implements interface */\nexport class Hash {\n}\n/** Wraps hash function, creating an interface on top of it */\nexport function createHasher(hashCons) {\n const hashC = (msg) => hashCons().update(toBytes(msg)).digest();\n const tmp = hashCons();\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = () => hashCons();\n return hashC;\n}\nexport function createOptHasher(hashCons) {\n const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();\n const tmp = hashCons({});\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (opts) => hashCons(opts);\n return hashC;\n}\nexport function createXOFer(hashCons) {\n const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();\n const tmp = hashCons({});\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (opts) => hashCons(opts);\n return hashC;\n}\nexport const wrapConstructor = createHasher;\nexport const wrapConstructorWithOpts = createOptHasher;\nexport const wrapXOFConstructorWithOpts = createXOFer;\n/** Cryptographically secure PRNG. Uses internal OS-level `crypto.getRandomValues`. */\nexport function randomBytes(bytesLength = 32) {\n if (crypto && typeof crypto.getRandomValues === 'function') {\n return crypto.getRandomValues(new Uint8Array(bytesLength));\n }\n // Legacy Node.js compatibility\n if (crypto && typeof crypto.randomBytes === 'function') {\n return Uint8Array.from(crypto.randomBytes(bytesLength));\n }\n throw new Error('crypto.getRandomValues must be defined');\n}\n//# sourceMappingURL=utils.js.map","import * as Bytes from '../Bytes.js';\n/** @internal */\nexport function assertSize(bytes, size_) {\n if (Bytes.size(bytes) > size_)\n throw new Bytes.SizeOverflowError({\n givenSize: Bytes.size(bytes),\n maxSize: size_,\n });\n}\n/** @internal */\nexport function assertStartOffset(value, start) {\n if (typeof start === 'number' && start > 0 && start > Bytes.size(value) - 1)\n throw new Bytes.SliceOffsetOutOfBoundsError({\n offset: start,\n position: 'start',\n size: Bytes.size(value),\n });\n}\n/** @internal */\nexport function assertEndOffset(value, start, end) {\n if (typeof start === 'number' &&\n typeof end === 'number' &&\n Bytes.size(value) !== end - start) {\n throw new Bytes.SliceOffsetOutOfBoundsError({\n offset: end,\n position: 'end',\n size: Bytes.size(value),\n });\n }\n}\n/** @internal */\nexport const charCodeMap = {\n zero: 48,\n nine: 57,\n A: 65,\n F: 70,\n a: 97,\n f: 102,\n};\n/** @internal */\nexport function charCodeToBase16(char) {\n if (char >= charCodeMap.zero && char <= charCodeMap.nine)\n return char - charCodeMap.zero;\n if (char >= charCodeMap.A && char <= charCodeMap.F)\n return char - (charCodeMap.A - 10);\n if (char >= charCodeMap.a && char <= charCodeMap.f)\n return char - (charCodeMap.a - 10);\n return undefined;\n}\n/** @internal */\nexport function pad(bytes, options = {}) {\n const { dir, size = 32 } = options;\n if (size === 0)\n return bytes;\n if (bytes.length > size)\n throw new Bytes.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] =\n bytes[padEnd ? i : bytes.length - i - 1];\n }\n return paddedBytes;\n}\n/** @internal */\nexport function trim(value, options = {}) {\n const { dir = 'left' } = options;\n let data = value;\n let sliceLength = 0;\n for (let i = 0; i < data.length - 1; i++) {\n if (data[dir === 'left' ? i : data.length - i - 1].toString() === '0')\n sliceLength++;\n else\n break;\n }\n data =\n dir === 'left'\n ? data.slice(sliceLength)\n : data.slice(0, data.length - sliceLength);\n return data;\n}\n//# sourceMappingURL=bytes.js.map","import { equalBytes } from '@noble/curves/abstract/utils';\nimport * as Errors from './Errors.js';\nimport * as Hex from './Hex.js';\nimport * as Json from './Json.js';\nimport * as internal from './internal/bytes.js';\nimport * as internal_hex from './internal/hex.js';\nconst decoder = /*#__PURE__*/ new TextDecoder();\nconst encoder = /*#__PURE__*/ new TextEncoder();\n/**\n * Asserts if the given value is {@link ox#Bytes.Bytes}.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.assert('abc')\n * // @error: Bytes.InvalidBytesTypeError:\n * // @error: Value `\"abc\"` of type `string` is an invalid Bytes value.\n * // @error: Bytes values must be of type `Uint8Array`.\n * ```\n *\n * @param value - Value to assert.\n */\nexport function assert(value) {\n if (value instanceof Uint8Array)\n return;\n if (!value)\n throw new InvalidBytesTypeError(value);\n if (typeof value !== 'object')\n throw new InvalidBytesTypeError(value);\n if (!('BYTES_PER_ELEMENT' in value))\n throw new InvalidBytesTypeError(value);\n if (value.BYTES_PER_ELEMENT !== 1 || value.constructor.name !== 'Uint8Array')\n throw new InvalidBytesTypeError(value);\n}\n/**\n * Concatenates two or more {@link ox#Bytes.Bytes}.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * const bytes = Bytes.concat(\n * Bytes.from([1]),\n * Bytes.from([69]),\n * Bytes.from([420, 69]),\n * )\n * // @log: Uint8Array [ 1, 69, 420, 69 ]\n * ```\n *\n * @param values - Values to concatenate.\n * @returns Concatenated {@link ox#Bytes.Bytes}.\n */\nexport function concat(...values) {\n let length = 0;\n for (const arr of values) {\n length += arr.length;\n }\n const result = new Uint8Array(length);\n for (let i = 0, index = 0; i < values.length; i++) {\n const arr = values[i];\n result.set(arr, index);\n index += arr.length;\n }\n return result;\n}\n/**\n * Instantiates a {@link ox#Bytes.Bytes} value from a `Uint8Array`, a hex string, or an array of unsigned 8-bit integers.\n *\n * :::tip\n *\n * To instantiate from a **Boolean**, **String**, or **Number**, use one of the following:\n *\n * - `Bytes.fromBoolean`\n *\n * - `Bytes.fromString`\n *\n * - `Bytes.fromNumber`\n *\n * :::\n *\n * @example\n * ```ts twoslash\n * // @noErrors\n * import { Bytes } from 'ox'\n *\n * const data = Bytes.from([255, 124, 5, 4])\n * // @log: Uint8Array([255, 124, 5, 4])\n *\n * const data = Bytes.from('0xdeadbeef')\n * // @log: Uint8Array([222, 173, 190, 239])\n * ```\n *\n * @param value - Value to convert.\n * @returns A {@link ox#Bytes.Bytes} instance.\n */\nexport function from(value) {\n if (value instanceof Uint8Array)\n return value;\n if (typeof value === 'string')\n return fromHex(value);\n return fromArray(value);\n}\n/**\n * Converts an array of unsigned 8-bit integers into {@link ox#Bytes.Bytes}.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * const data = Bytes.fromArray([255, 124, 5, 4])\n * // @log: Uint8Array([255, 124, 5, 4])\n * ```\n *\n * @param value - Value to convert.\n * @returns A {@link ox#Bytes.Bytes} instance.\n */\nexport function fromArray(value) {\n return value instanceof Uint8Array ? value : new Uint8Array(value);\n}\n/**\n * Encodes a boolean value into {@link ox#Bytes.Bytes}.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * const data = Bytes.fromBoolean(true)\n * // @log: Uint8Array([1])\n * ```\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * const data = Bytes.fromBoolean(true, { size: 32 })\n * // @log: Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1])\n * ```\n *\n * @param value - Boolean value to encode.\n * @param options - Encoding options.\n * @returns Encoded {@link ox#Bytes.Bytes}.\n */\nexport function fromBoolean(value, options = {}) {\n const { size } = options;\n const bytes = new Uint8Array(1);\n bytes[0] = Number(value);\n if (typeof size === 'number') {\n internal.assertSize(bytes, size);\n return padLeft(bytes, size);\n }\n return bytes;\n}\n/**\n * Encodes a {@link ox#Hex.Hex} value into {@link ox#Bytes.Bytes}.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * const data = Bytes.fromHex('0x48656c6c6f20776f726c6421')\n * // @log: Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33])\n * ```\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * const data = Bytes.fromHex('0x48656c6c6f20776f726c6421', { size: 32 })\n * // @log: Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])\n * ```\n *\n * @param value - {@link ox#Hex.Hex} value to encode.\n * @param options - Encoding options.\n * @returns Encoded {@link ox#Bytes.Bytes}.\n */\nexport function fromHex(value, options = {}) {\n const { size } = options;\n let hex = value;\n if (size) {\n internal_hex.assertSize(value, size);\n hex = Hex.padRight(value, size);\n }\n let hexString = hex.slice(2);\n if (hexString.length % 2)\n hexString = `0${hexString}`;\n const length = hexString.length / 2;\n const bytes = new Uint8Array(length);\n for (let index = 0, j = 0; index < length; index++) {\n const nibbleLeft = internal.charCodeToBase16(hexString.charCodeAt(j++));\n const nibbleRight = internal.charCodeToBase16(hexString.charCodeAt(j++));\n if (nibbleLeft === undefined || nibbleRight === undefined) {\n throw new Errors.BaseError(`Invalid byte sequence (\"${hexString[j - 2]}${hexString[j - 1]}\" in \"${hexString}\").`);\n }\n bytes[index] = nibbleLeft * 16 + nibbleRight;\n }\n return bytes;\n}\n/**\n * Encodes a number value into {@link ox#Bytes.Bytes}.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * const data = Bytes.fromNumber(420)\n * // @log: Uint8Array([1, 164])\n * ```\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * const data = Bytes.fromNumber(420, { size: 4 })\n * // @log: Uint8Array([0, 0, 1, 164])\n * ```\n *\n * @param value - Number value to encode.\n * @param options - Encoding options.\n * @returns Encoded {@link ox#Bytes.Bytes}.\n */\nexport function fromNumber(value, options) {\n const hex = Hex.fromNumber(value, options);\n return fromHex(hex);\n}\n/**\n * Encodes a string into {@link ox#Bytes.Bytes}.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * const data = Bytes.fromString('Hello world!')\n * // @log: Uint8Array([72, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100, 33])\n * ```\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * const data = Bytes.fromString('Hello world!', { size: 32 })\n * // @log: Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])\n * ```\n *\n * @param value - String to encode.\n * @param options - Encoding options.\n * @returns Encoded {@link ox#Bytes.Bytes}.\n */\nexport function fromString(value, options = {}) {\n const { size } = options;\n const bytes = encoder.encode(value);\n if (typeof size === 'number') {\n internal.assertSize(bytes, size);\n return padRight(bytes, size);\n }\n return bytes;\n}\n/**\n * Checks if two {@link ox#Bytes.Bytes} values are equal.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.isEqual(Bytes.from([1]), Bytes.from([1]))\n * // @log: true\n *\n * Bytes.isEqual(Bytes.from([1]), Bytes.from([2]))\n * // @log: false\n * ```\n *\n * @param bytesA - First {@link ox#Bytes.Bytes} value.\n * @param bytesB - Second {@link ox#Bytes.Bytes} value.\n * @returns `true` if the two values are equal, otherwise `false`.\n */\nexport function isEqual(bytesA, bytesB) {\n return equalBytes(bytesA, bytesB);\n}\n/**\n * Pads a {@link ox#Bytes.Bytes} value to the left with zero bytes until it reaches the given `size` (default: 32 bytes).\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.padLeft(Bytes.from([1]), 4)\n * // @log: Uint8Array([0, 0, 0, 1])\n * ```\n *\n * @param value - {@link ox#Bytes.Bytes} value to pad.\n * @param size - Size to pad the {@link ox#Bytes.Bytes} value to.\n * @returns Padded {@link ox#Bytes.Bytes} value.\n */\nexport function padLeft(value, size) {\n return internal.pad(value, { dir: 'left', size });\n}\n/**\n * Pads a {@link ox#Bytes.Bytes} value to the right with zero bytes until it reaches the given `size` (default: 32 bytes).\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.padRight(Bytes.from([1]), 4)\n * // @log: Uint8Array([1, 0, 0, 0])\n * ```\n *\n * @param value - {@link ox#Bytes.Bytes} value to pad.\n * @param size - Size to pad the {@link ox#Bytes.Bytes} value to.\n * @returns Padded {@link ox#Bytes.Bytes} value.\n */\nexport function padRight(value, size) {\n return internal.pad(value, { dir: 'right', size });\n}\n/**\n * Generates random {@link ox#Bytes.Bytes} of the specified length.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * const bytes = Bytes.random(32)\n * // @log: Uint8Array([... x32])\n * ```\n *\n * @param length - Length of the random {@link ox#Bytes.Bytes} to generate.\n * @returns Random {@link ox#Bytes.Bytes} of the specified length.\n */\nexport function random(length) {\n return crypto.getRandomValues(new Uint8Array(length));\n}\n/**\n * Retrieves the size of a {@link ox#Bytes.Bytes} value.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.size(Bytes.from([1, 2, 3, 4]))\n * // @log: 4\n * ```\n *\n * @param value - {@link ox#Bytes.Bytes} value.\n * @returns Size of the {@link ox#Bytes.Bytes} value.\n */\nexport function size(value) {\n return value.length;\n}\n/**\n * Returns a section of a {@link ox#Bytes.Bytes} value given a start/end bytes offset.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.slice(\n * Bytes.from([1, 2, 3, 4, 5, 6, 7, 8, 9]),\n * 1,\n * 4,\n * )\n * // @log: Uint8Array([2, 3, 4])\n * ```\n *\n * @param value - The {@link ox#Bytes.Bytes} value.\n * @param start - Start offset.\n * @param end - End offset.\n * @param options - Slice options.\n * @returns Sliced {@link ox#Bytes.Bytes} value.\n */\nexport function slice(value, start, end, options = {}) {\n const { strict } = options;\n internal.assertStartOffset(value, start);\n const value_ = value.slice(start, end);\n if (strict)\n internal.assertEndOffset(value_, start, end);\n return value_;\n}\n/**\n * Decodes a {@link ox#Bytes.Bytes} into a bigint.\n *\n * @example\n * ```ts\n * import { Bytes } from 'ox'\n *\n * Bytes.toBigInt(Bytes.from([1, 164]))\n * // @log: 420n\n * ```\n *\n * @param bytes - The {@link ox#Bytes.Bytes} to decode.\n * @param options - Decoding options.\n * @returns Decoded bigint.\n */\nexport function toBigInt(bytes, options = {}) {\n const { size } = options;\n if (typeof size !== 'undefined')\n internal.assertSize(bytes, size);\n const hex = Hex.fromBytes(bytes, options);\n return Hex.toBigInt(hex, options);\n}\n/**\n * Decodes a {@link ox#Bytes.Bytes} into a boolean.\n *\n * @example\n * ```ts\n * import { Bytes } from 'ox'\n *\n * Bytes.toBoolean(Bytes.from([1]))\n * // @log: true\n * ```\n *\n * @param bytes - The {@link ox#Bytes.Bytes} to decode.\n * @param options - Decoding options.\n * @returns Decoded boolean.\n */\nexport function toBoolean(bytes, options = {}) {\n const { size } = options;\n let bytes_ = bytes;\n if (typeof size !== 'undefined') {\n internal.assertSize(bytes_, size);\n bytes_ = trimLeft(bytes_);\n }\n if (bytes_.length > 1 || bytes_[0] > 1)\n throw new InvalidBytesBooleanError(bytes_);\n return Boolean(bytes_[0]);\n}\n/**\n * Encodes a {@link ox#Bytes.Bytes} value into a {@link ox#Hex.Hex} value.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.toHex(Bytes.from([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33]))\n * // '0x48656c6c6f20576f726c6421'\n * ```\n *\n * @param value - The {@link ox#Bytes.Bytes} to decode.\n * @param options - Options.\n * @returns Decoded {@link ox#Hex.Hex} value.\n */\nexport function toHex(value, options = {}) {\n return Hex.fromBytes(value, options);\n}\n/**\n * Decodes a {@link ox#Bytes.Bytes} into a number.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.toNumber(Bytes.from([1, 164]))\n * // @log: 420\n * ```\n */\nexport function toNumber(bytes, options = {}) {\n const { size } = options;\n if (typeof size !== 'undefined')\n internal.assertSize(bytes, size);\n const hex = Hex.fromBytes(bytes, options);\n return Hex.toNumber(hex, options);\n}\n/**\n * Decodes a {@link ox#Bytes.Bytes} into a string.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * const data = Bytes.toString(Bytes.from([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33]))\n * // @log: 'Hello world'\n * ```\n *\n * @param bytes - The {@link ox#Bytes.Bytes} to decode.\n * @param options - Options.\n * @returns Decoded string.\n */\nexport function toString(bytes, options = {}) {\n const { size } = options;\n let bytes_ = bytes;\n if (typeof size !== 'undefined') {\n internal.assertSize(bytes_, size);\n bytes_ = trimRight(bytes_);\n }\n return decoder.decode(bytes_);\n}\n/**\n * Trims leading zeros from a {@link ox#Bytes.Bytes} value.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.trimLeft(Bytes.from([0, 0, 0, 0, 1, 2, 3]))\n * // @log: Uint8Array([1, 2, 3])\n * ```\n *\n * @param value - {@link ox#Bytes.Bytes} value.\n * @returns Trimmed {@link ox#Bytes.Bytes} value.\n */\nexport function trimLeft(value) {\n return internal.trim(value, { dir: 'left' });\n}\n/**\n * Trims trailing zeros from a {@link ox#Bytes.Bytes} value.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.trimRight(Bytes.from([1, 2, 3, 0, 0, 0, 0]))\n * // @log: Uint8Array([1, 2, 3])\n * ```\n *\n * @param value - {@link ox#Bytes.Bytes} value.\n * @returns Trimmed {@link ox#Bytes.Bytes} value.\n */\nexport function trimRight(value) {\n return internal.trim(value, { dir: 'right' });\n}\n/**\n * Checks if the given value is {@link ox#Bytes.Bytes}.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.validate('0x')\n * // @log: false\n *\n * Bytes.validate(Bytes.from([1, 2, 3]))\n * // @log: true\n * ```\n *\n * @param value - Value to check.\n * @returns `true` if the value is {@link ox#Bytes.Bytes}, otherwise `false`.\n */\nexport function validate(value) {\n try {\n assert(value);\n return true;\n }\n catch {\n return false;\n }\n}\n/**\n * Thrown when the bytes value cannot be represented as a boolean.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.toBoolean(Bytes.from([5]))\n * // @error: Bytes.InvalidBytesBooleanError: Bytes value `[5]` is not a valid boolean.\n * // @error: The bytes array must contain a single byte of either a `0` or `1` value.\n * ```\n */\nexport class InvalidBytesBooleanError extends Errors.BaseError {\n constructor(bytes) {\n super(`Bytes value \\`${bytes}\\` is not a valid boolean.`, {\n metaMessages: [\n 'The bytes array must contain a single byte of either a `0` or `1` value.',\n ],\n });\n Object.defineProperty(this, \"name\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: 'Bytes.InvalidBytesBooleanError'\n });\n }\n}\n/**\n * Thrown when a value cannot be converted to bytes.\n *\n * @example\n * ```ts twoslash\n * // @noErrors\n * import { Bytes } from 'ox'\n *\n * Bytes.from('foo')\n * // @error: Bytes.InvalidBytesTypeError: Value `foo` of type `string` is an invalid Bytes value.\n * ```\n */\nexport class InvalidBytesTypeError extends Errors.BaseError {\n constructor(value) {\n super(`Value \\`${typeof value === 'object' ? Json.stringify(value) : value}\\` of type \\`${typeof value}\\` is an invalid Bytes value.`, {\n metaMessages: ['Bytes values must be of type `Bytes`.'],\n });\n Object.defineProperty(this, \"name\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: 'Bytes.InvalidBytesTypeError'\n });\n }\n}\n/**\n * Thrown when a size exceeds the maximum allowed size.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.fromString('Hello World!', { size: 8 })\n * // @error: Bytes.SizeOverflowError: Size cannot exceed `8` bytes. Given size: `12` bytes.\n * ```\n */\nexport class SizeOverflowError extends Errors.BaseError {\n constructor({ givenSize, maxSize }) {\n super(`Size cannot exceed \\`${maxSize}\\` bytes. Given size: \\`${givenSize}\\` bytes.`);\n Object.defineProperty(this, \"name\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: 'Bytes.SizeOverflowError'\n });\n }\n}\n/**\n * Thrown when a slice offset is out-of-bounds.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.slice(Bytes.from([1, 2, 3]), 4)\n * // @error: Bytes.SliceOffsetOutOfBoundsError: Slice starting at offset `4` is out-of-bounds (size: `3`).\n * ```\n */\nexport class SliceOffsetOutOfBoundsError extends Errors.BaseError {\n constructor({ offset, position, size, }) {\n super(`Slice ${position === 'start' ? 'starting' : 'ending'} at offset \\`${offset}\\` is out-of-bounds (size: \\`${size}\\`).`);\n Object.defineProperty(this, \"name\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: 'Bytes.SliceOffsetOutOfBoundsError'\n });\n }\n}\n/**\n * Thrown when a the padding size exceeds the maximum allowed size.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.padLeft(Bytes.fromString('Hello World!'), 8)\n * // @error: [Bytes.SizeExceedsPaddingSizeError: Bytes size (`12`) exceeds padding size (`8`).\n * ```\n */\nexport class SizeExceedsPaddingSizeError extends Errors.BaseError {\n constructor({ size, targetSize, type, }) {\n super(`${type.charAt(0).toUpperCase()}${type\n .slice(1)\n .toLowerCase()} size (\\`${size}\\`) exceeds padding size (\\`${targetSize}\\`).`);\n Object.defineProperty(this, \"name\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: 'Bytes.SizeExceedsPaddingSizeError'\n });\n }\n}\n//# sourceMappingURL=Bytes.js.map","import { addressResolve