import { Transferable } from 'node:worker_threads';
import { ArrayOptions, Readable } from 'node:stream';

/**
 * A `Map` with a fixed maximum capacity.
 *
 * Entries are evicted in first-in-first-out (FIFO) order
 * when capacity is exceeded. This means the oldest entry
 * is removed to make space.
 *
 * @template K The type of keys.
 * @template V The type of values.
 *
 * @example
 * const map = new FIFOMap<string, number>(3);
 * map.set("a", 1); // { a: 1 }
 * map.set("b", 2); // { a: 1, b: 2 }
 * map.set("c", 3); // { a: 1, b: 2, c: 3 }
 * map.set("d", 4); // { b: 2, c: 3, d: 4 }
 */
declare class BoundedMap<K, V> implements Map<K, V> {
    private _capacity;
    private _map;
    /**
     * Creates a new instance with an optional capacity.
     *
     * @param capacity (Optional) The maximum number of entries the map can hold. Defaults to `Infinity`.
     */
    constructor(capacity?: number);
    /**
     * Creates a new instance with the entries from the given iterable and optional capacity.
     *
     * @param iterable (Optional) An iterable of key-value pairs to initialize the map with.
     * @param capacity (Optional) The maximum number of entries the map can hold. Defaults to `Infinity`.
     */
    constructor(iterable?: Iterable<[K, V]> | null, capacity?: number);
    /**
     * Creates a new instance from an existing `Map` and an optional capacity.
     *
     * @param map (Optional) A `Map` to initialize the instance with.
     * @param capacity (Optional) The maximum number of entries the map can hold. Defaults to `Infinity`.
     */
    constructor(map?: Map<K, V> | null, capacity?: number);
    /**
     * The maximum number of entries the map can hold.
     */
    get capacity(): number;
    /**
     *
     * Must be a nonnegative integer or `Infinity`.
     *
     * When reduced, the oldest entries are
     * evicted until the map is within capacity.
     *
     * @throws {RangeError} If an invalid capacity is given.
     */
    set capacity(value: number);
    /**
     * Removes all entries from the map.
     */
    clear(): void;
    /**
     * Removes a specified entry from the map.
     *
     * @param key The key of the entry to remove.
     *
     * @returns `true` if the entry was found and removed, `false` otherwise.
     */
    delete(key: K): boolean;
    /**
     * Returns an iterable of [key, value] pairs for every entry in the map.
     *
     * @returns An iterable of [key, value] pairs for every entry in the map.
     */
    entries(): MapIterator<[K, V]>;
    /**
     * Executes a provided function once for each entry in the map.
     *
     * @param callbackFn The function to execute.
     *
     * @param thisArg (Optional) The value to use as `this` when executing the function.
     */
    forEach(callbackFn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: unknown): void;
    /**
     * Gets the value associated with the given key.
     *
     * @param key The key to check.
     *
     * @returns The value if the key exists, otherwise `undefined`.
     */
    get(key: K): V | undefined;
    /**
     * Checks whether the given key exists in the map.
     *
     * @param key The key to check.
     *
     * @returns `true` if the key exists, otherwise `false`.
     */
    has(key: K): boolean;
    /**
     * Returns an iterable over the keys in the map.
     *
     * @returns An iterable over the keys in the map.
     */
    keys(): MapIterator<K>;
    /**
     * Adds a new key-value pair to the map.
     *
     * If a key already exists, it is re-inserted at the newest position.
     *
     * If capacity would be exceeded, the oldest entry is removed.
     *
     * @param key The key to set.
     * @param value The value associated with the key.
     *
     * @returns The map instance.
     */
    set(key: K, value: V): this;
    /**
     * Removes and returns the oldest entry in the map.
     *
     * @returns The removed key-value pair, or `undefined` if the map is empty.
     */
    shift(): [K, V] | undefined;
    /**
     * The number of entries in the map.
     */
    get size(): number;
    /**
     * Returns an iterable over the values in the map.
     *
     * @returns An iterable over the values in the map.
     */
    values(): MapIterator<V>;
    /**
     * Returns an iterable over the entries in the map.
     *
     * @returns An iterable over the entries in the map.
     */
    [Symbol.iterator](): MapIterator<[K, V]>;
    /**
     * The default string tag.
     */
    get [Symbol.toStringTag](): string;
}

/**
 * A `Set` with a fixed maximum capacity.
 *
 * Values are evicted in first-in-first-out (FIFO) order
 * when capacity is exceeded. This means the oldest value
 * is removed to make space.
 *
 * @template V The type of values.
 *
 * @example
 * const set = new FifoSet<number>(3);
 * set.add(1); // [ 1 ]
 * set.add(2); // [ 1, 2 ]
 * set.add(3); // [ 1, 2, 3 ]
 * set.add(4); // [ 2, 3, 4 ]
 */
declare class BoundedSet<V> implements Set<V> {
    private _capacity;
    private _set;
    /**
     * Creates a new instance with an optional capacity.
     *
     * @param capacity (Optional) The maximum number of values the set can hold. Defaults to `Infinity`.
     */
    constructor(capacity?: number);
    /**
     * Creates a new instance with values from the given iterable and an optional capacity.
     *
     * @param iterable (Optional) An iterable of values to initialize the set with.
     * @param capacity (Optional) The maximum number of values the set can hold. Defaults to `Infinity`.
     */
    constructor(iterable?: Iterable<V> | null, capacity?: number);
    /**
     * Creates a new instance from an existing `Set` and an optional capacity.
     *
     * @param set (Optional) A `Set` to initialize the instance with.
     * @param capacity (Optional) The maximum number of values the set can hold. Defaults to `Infinity`.
     */
    constructor(set?: Set<V> | null, capacity?: number);
    /**
     * Adds a new value to the set.
     *
     * If the value already exists, it is re-inserted at the newest position.
     *
     * If capacity would be exceeded, the oldest value is removed.
     *
     * @param value The value to add.
     *
     * @returns The set instance.
     */
    add(value: V): this;
    /**
     * The maximum number of values the set can hold.
     */
    get capacity(): number;
    /**
     * Must be a nonnegative integer or `Infinity`.
     *
     * When reduced, the oldest values are
     * evicted until the set is within capacity.
     *
     * @throws {RangeError} If an invalid capacity is given.
     */
    set capacity(value: number);
    /**
     * Removes all values from the set.
     */
    clear(): void;
    /**
     * Removes a specified value from the set.
     *
     * @param value The value to remove.
     *
     * @returns `true` if the value was found and removed, otherwise `false`.
     */
    delete(value: V): boolean;
    /**
     * @param other The other set.
     *
     * @param capacity (Optional) The capacity for the new set. Defaults to this set's capacity.
     *
     * @returns A new set containing the values that are in this set and not in `other`
     */
    difference<U>(other: ReadonlySetLike<U>, capacity?: number): BoundedSet<V>;
    /**
     * Returns an iterable of [value, value] pairs for every value in the set.
     *
     * @returns An iterable of [value, value] pairs for every value in the set.
     */
    entries(): SetIterator<[V, V]>;
    /**
     * Executes a provided function once for each value in the set.
     *
     * @param callbackFn The function to execute.
     *
     * @param thisArg (Optional) The value to use as `this` when executing the function.
     */
    forEach(callbackFn: (value: V, value2: V, set: BoundedSet<V>) => void, thisArg?: unknown): void;
    /**
     * Checks whether the given value exists in the set.
     *
     * @param value The value to check.
     *
     * @returns `true` if the value exists, otherwise `false`.
     */
    has(value: V): boolean;
    /**
     * @param other The other set.
     *
     * @param capacity (Optional) The capacity for the new set. Defaults to this set's capacity.
     *
     * @return A new set containing the values that are in both this set and `other`.
     */
    intersection<U>(other: ReadonlySetLike<U>, capacity?: number): BoundedSet<V & U>;
    /**
     * @param other The other set.
     *
     * @returns `true` if this set has no values in common with `other`, otherwise `false`.
     */
    isDisjointFrom(other: ReadonlySetLike<unknown>): boolean;
    /**
     * @param other The other set.
     *
     * @returns `true` if all values in this set are in `other`, otherwise `false`.
     */
    isSubsetOf(other: ReadonlySetLike<unknown>): boolean;
    /**
     * @param other The other set.
     *
     * @returns `true` if all values in `other` are in this set, otherwise `false`.
     */
    isSupersetOf(other: ReadonlySetLike<unknown>): boolean;
    /**
     * Returns an iterable over the values in the set.
     *
     * @returns An iterable over the values in the set.
     */
    keys(): SetIterator<V>;
    /**
     * Removes and returns the oldest value in the set.
     *
     * @returns The removed value, or `undefined` if the set is empty.
     */
    shift(): V | undefined;
    /**
     * @param other The other set.
     * @param capacity (Optional) The capacity for the new set. Defaults to this set's capacity.
     *
     * @returns A new set containing the values that are in either this set or `other`, but not both.
     */
    symmetricDifference<U>(other: ReadonlySetLike<U>, capacity?: number): BoundedSet<V | U>;
    /**
     * The number of values in the set.
     */
    get size(): number;
    /**
     * @param other The other set.
     * @param capacity (Optional) The capacity for the new set. Defaults to this set's capacity.
     *
     * @returns A new set containing all values in this set and `other`.
     */
    union<U>(other: ReadonlySetLike<U>, capacity?: number): BoundedSet<V | U>;
    /**
     * Returns an iterable over the values in the set.
     *
     * @returns An iterable over the values in the set.
     */
    values(): SetIterator<V>;
    /**
     * Returns an iterable over the values in the set.
     *
     * @returns An iterable over the values in the set.
     */
    [Symbol.iterator](): SetIterator<V>;
    /**
     * The default string tag.
     */
    get [Symbol.toStringTag](): string;
}

/**
 * Represents a chunked segment of a sequence of values.
 *
 * @template T - The type of values in the chunk.
 */
interface Chunk<T> {
    /**
     * The zero-based index of the chunk.
     */
    chunkIndex: number;
    /**
     * The zero-based index in the original
     * sequence of the first value in the chunk.
     */
    startIndex: number;
    /**
     * The values contained in the chunk.
     */
    values: T[];
}
/**
 * Asynchronously splits an iterable into fixed-size chunks.
 *
 * @template T - The type of values in the input iterable.
 *
 * @param size - The maximum number of items per chunk. Must be a positive integer or `Infinity`.
 * @param values - The source of values to be chunked.
 *
 * @yields {Chunk<T>} An object representing the next chunk in the sequence.
 *
 * @throws {RangeError} If `size` is less than 1 or not an integer (except for `Infinity`).
 *
 * @example
 * const data = [1, 2, 3, 4, 5];
 * for await (const chunk of chunkify(2, data)) {
 *   console.log(chunk);
 * }
 * // Output:
 * // { chunkIndex: 0, startIndex: 0, values: [1, 2] }
 * // { chunkIndex: 1, startIndex: 2, values: [3, 4] }
 * // { chunkIndex: 2, startIndex: 4, values: [5] }
 */
declare function asyncChunkify<T>(size: number, values: Iterable<T> | AsyncIterable<T>): AsyncGenerator<Chunk<T>>;
/**
 * Splits an iterable into fixed-size chunks.
 *
 * @template T - The type of values in the input iterable.
 *
 * @param size - The maximum number of items per chunk. Must be a positive integer or `Infinity`.
 * @param values - The source of values to be chunked.
 *
 * @yields {Chunk<T>} An object representing the next chunk in the sequence.
 *
 * @throws {RangeError} If `size` is less than 1 or not an integer (except for `Infinity`).
 *
 * @example
 * const data = [1, 2, 3, 4, 5];
 * for (const chunk of chunkify(2, data)) {
 *   console.log(chunk);
 * }
 * // Output:
 * // { chunkIndex: 0, startIndex: 0, values: [1, 2] }
 * // { chunkIndex: 1, startIndex: 2, values: [3, 4] }
 * // { chunkIndex: 2, startIndex: 4, values: [5] }
 */
declare function chunkify<T>(size: number, values: Iterable<T>): Generator<Chunk<T>>;

interface HeaderProvider {
    getHeaders(): Record<string, string> | Promise<Record<string, string>>;
}
interface IdentityProviderConfig {
    identityId: string;
}
declare class IdentityProvider implements HeaderProvider {
    identityId: string;
    constructor(config: IdentityProviderConfig);
    getHeaders(): Promise<Record<string, string>>;
}

/**
 * Checks if a value is a string containing
 * only alphabetic characters (a-z, case-insensitive)
 *
 * @param value - The value to check
 *
 * @returns `true` if the value is an alphabetic string, `false` otherwise
 */
declare function isAlpha(value: unknown): value is string;
/**
 * Checks if a value is a string containing
 * only alphanumeric characters (a-z, 0-9, case-insensitive).
 *
 * @param value - The value to check
 *
 * @returns `true` if the value is an alphanumeric string, `false` otherwise
 */
declare function isAlphaNumeric(value: unknown): value is string;
/**
 * Checks if a value is an array
 *
 * @template T - The expected type of array elements (defaults to `unknown`).
 *
 * @param value - The value to check
 *
 * @returns `true` if the value is an array, `false` otherwise
 */
declare function isArray<T>(value: unknown): value is T[];
/**
 * Checks if a value is an `AsyncIterable`
 *
 * @param value - The value to check
 *
 * @returns `true` if the value is an `AsyncIterable`, `false` otherwise
 */
declare function isAsyncIterable(value: unknown): value is AsyncIterable<unknown>;
/**
 * Checks if a value is a `bigint`
 *
 * @param value - The value to check
 *
 * @returns `true` if the value is a `bigint`, `false` otherwise
 */
declare function isBigInt(value: unknown): value is bigint;
/**
 * Checks if a value is a `boolean`
 *
 * @param value - The value to check
 *
 * @returns `true` if the value is a `boolean`, `false` otherwise
 */
declare function isBoolean(value: unknown): value is boolean;
/**
 * Checks if a value is a function
 *
 * @param value - The value to check
 *
 * @returns `true` if the value is a function, `false` otherwise
 */
declare function isFunction(value: unknown): value is Function;
/**
 * Checks if a value is an integer number
 *
 * @param value - The value to check
 *
 * @returns `true` if the value is an integer, `false` otherwise.
 */
declare function isInt(value: unknown): value is number;
/**
 * Checks if a value is an `Iterable`
 *
 * @param value - The value to check
 *
 * @returns `true` if the value is an `Iterable`, `false` otherwise
 */
declare function isIterable(value: unknown): value is Iterable<unknown>;
/**
 * Checks if a value is a `number`
 *
 * @param value - The value to check
 *
 * @returns `true` if the value is a `number`, `false` otherwise
 */
declare function isNumber(value: unknown): value is number;
/**
 * Checks if a value is an `object`. Excludes `null` and arrays.
 *
 * @param value - The value to check
 *
 * @returns `true` if the value is an `object`, `false` otherwise
 */
declare function isObject(value: unknown): value is object;
/**
 * Checks if a value is a `string`
 *
 * @param value - The value to check
 *
 * @returns `true` if the value is a `string`, `false` otherwise
 */
declare function isString(value: unknown): value is string;
/**
 * Checks if a value is a `Transferable` object
 *
 * @param value - The value to check
 *
 * @returns `True` if the value is `Transferable`, `false` otherwise
 *
 * @todo Add a reliable check for `FileHandle`
 */
declare function isTransferable(value: unknown): value is Transferable;

/**
 * A two-dimensional map implemented as a `Map` of `Map`s.
 *
 * Allows storing and retrieving values using a pair of keys.
 *
 * @template K1 - The type of the first-level (outer) key.
 * @template K2 - The type of the second-level (inner) key.
 * @template V - The type of the value.
 *
 * @example
 * const map = new Map2D<string, number, string>();
 * map.set(["a", 1], "b");
 * console.log(map.get(["a", 1])); // "b"
 */
declare class D2Map<K1, K2, V> implements Map<[K1, K2], V> {
    private _data;
    private _size;
    constructor(iterable?: Iterable<[[K1, K2], V]> | null);
    /**
     * Removes all entries from the map.
     */
    clear(): void;
    /**
     * Removes a specified entry from the map.
     *
     * @param keys The keys of the entry to remove.
     *
     * @returns `true` if the entry was found and removed, `false` otherwise.
     */
    delete(keys: [K1, K2]): boolean;
    /**
     * Returns an iterable of [keys, value] pairs for every entry in the map.
     *
     * @returns An iterable of [keys, value] pairs for every entry in the map.
     */
    entries(): MapIterator<[[K1, K2], V]>;
    /**
     * Executes a provided function once for each entry in the map.
     *
     * @param callbackFn The function to execute.
     *
     * @param thisArg (Optional) The value to use as `this` when executing the function.
     */
    forEach(callbackFn: (value: V, keys: [K1, K2], map: Map<[K1, K2], V>) => void, thisArg?: unknown): void;
    /**
     * Gets the value associated with the given keys.
     *
     * @param key The keys to check.
     *
     * @returns The value if the keys exist, otherwise `undefined`.
     */
    get(keys: [K1, K2]): V | undefined;
    /**
     * Checks whether the given keys exist in the map.
     *
     * @param key The keys to check.
     *
     * @returns `true` if the keys exist, otherwise `false`.
     */
    has(keys: [K1, K2]): boolean;
    /**
     * Returns an iterable over the keys in the map.
     *
     * @returns An iterable over the keys in the map.
     */
    keys(): MapIterator<[K1, K2]>;
    /**
     * Adds a new keys-value pair to the map.
     *
     * @param key The keys to set.
     * @param value The value associated with the keys.
     *
     * @returns The map instance.
     */
    set(keys: [K1, K2], value: V): this;
    /**
     * The number of entries in the map.
     */
    get size(): number;
    /**
     * Returns an iterable over the values in the map.
     *
     * @returns An iterable over the values in the map.
     */
    values(): MapIterator<V>;
    /**
     * Returns an iterable over the entries in the map.
     *
     * @returns An iterable over the entries in the map.
     */
    [Symbol.iterator](): MapIterator<[[K1, K2], V]>;
    /**
     * The default string tag.
     */
    get [Symbol.toStringTag](): string;
}
/**
 * Removes a specified entry from the map.
 *
 * @param key1 The key for the outer map.
 * @param key2 The key for the inner map.
 *
 * @returns `true` if the entry was found and removed, `false` otherwise.
 */
declare function d2MapDelete<K1, K2>(map2d: Map<K1, Map<K2, unknown>>, key1: K1, key2: K2): boolean;
/**
 * Gets the value associated with the given keys.
 *
 * @param key1 The key for the outer map.
 * @param key2 The key for the inner map.
 *
 * @returns The value if the keys exist, otherwise `undefined`.
 */
declare function d2MapGet<K1, K2, V>(map2d: Map<K1, Map<K2, V>>, key1: K1, key2: K2): V | undefined;
/**
 * Checks whether the given keys exist in the map.
 *
 * @param key1 The key for the outer map.
 * @param key2 The key for the inner map.
 *
 * @returns `true` if the keys exist, otherwise `false`.
 */
declare function d2MapHas<K1, K2, V>(map2d: Map<K1, Map<K2, V>>, key1: K1, key2: K2): boolean;
/**
 * Adds a new keys-value pair to the map.
 *
 * @param key1 The key for the outer map.
 * @param key2 The key for the inner map.
 *
 * @param value The value associated with the keys.
 */
declare function d2MapSet<K1, K2, V>(map2d: Map<K1, Map<K2, V>>, key1: K1, key2: K2, value: V): void;

/**
 * Converts camelCase to PascalCase
 *
 * @param str A string in camelCase
 *
 * @returns A string in PascalCase
 */
declare function camelToPascal(str: string): string;
/**
 * Converts camelCase to snake_case
 *
 * @param str A string in camelCase
 *
 * @returns A string in snake_case
 */
declare function camelToSnake(str: string): string;
/**
 * Capitalized the first character in the string
 *
 * @param str A string
 *
 * @return The given string with the first character capitalized
 */
declare function capitalize(str: string): string;
/**
 * Converts PascalCase to camelCase
 *
 * @param str A string in PascalCase
 *
 * @returns A string in camelCase
 */
declare function pascalToCamel(str: string): string;
/**
 * Converts PascalCase to snake_case
 *
 * @param str A string in PascalCase
 *
 * @returns A string in snake_case
 */
declare function pascalToSnake(str: string): string;
/**
 * Converts snake_case to camelCase
 *
 * @param str A string in snake_case
 *
 * @returns A string in camelCase
 */
declare function snakeToCamel(str: string): string;
/**
 * Converts snake_case to PascalCase
 *
 * @param str A string in snake_case
 *
 * @returns A string in PascalCase
 */
declare function snakeToPascal(str: string): string;
/**
 * Takes a string of space separated text
 * and converts to camelCase.
 *
 * @param str
 *
 * @returns A string in camelCase
 */
declare function toCamelCase(str: string): string;
/**
 * Takes a string of space separated text
 * and converts to PascalCase.
 *
 * @param str
 *
 * @returns A string in camelCase
 */
declare function toPascalCase(str: string): string;
/**
 * Takes a string of space separated text
 * and converts to snake_case.
 *
 * @param str
 *
 * @returns A string in snake_case
 */
declare function toSnakeCase(str: string): string;

/**
 * Waits the given amount of time.
 *
 * @param ms - Time to wait in milliseconds
 */
declare function wait(ms: number): Promise<void>;
/**
 * Waits until the given timestamp.
 *
 * @param ts - Unix timestamp in milliseconds (e.g. `Date.now()`)
 */
declare function waitUntil(ts: number): Promise<void>;

type ConstEnum<T> = T[keyof T];

/**
 * Represents the possible runtime environments
 */
declare enum Environment {
    /**
     * Development environment
     */
    Dev = "dev",
    /**
     * Production environment
     */
    Prod = "prod",
    /**
     * Quality assurance (QA) environment
     */
    QA = "qa",
    /**
     * Testing environment
     */
    Test = "test",
    /**
     * User acceptance testing (UAT) environment
     */
    UAT = "uat"
}

/**
 * Interface for a structured logger.
 *
 * Provides methods for logging messages at various severity levels,
 * with optional metadata for structured output.
 */
interface Logger {
    /**
     * Logs a debug-level message. Used for development and diagnostics.
     *
     * @param message - The log message
     * @param meta - Optional metadata
     */
    debug(message: string, ...meta: unknown[]): void;
    /**
     * Logs an error-level message. Used for failures and unexpected conditions.
     *
     * @param message - The log message
     * @param meta - Optional metadata
     */
    error(message: string, ...meta: unknown[]): void;
    /**
     * Logs an info-level message. Used for general events.
     *
     * @param message - The log message.
     * @param meta - Optional metadata
     */
    info(message: string, ...meta: unknown[]): void;
    /**
     * Logs a warning-level message. Used for recoverable issues and unexpected non-fatal events
     *
     * @param message - The log message.
     * @param meta - Optional metadata
     */
    warn(message: string, ...meta: unknown[]): void;
}

/**
 * Represents the severity level of a log message.
 *
 * These levels can be used to filter or control logging output.
 */
declare enum LogLevel {
    /**
     * Debug-level messages. Used for development and diagnostics.
     */
    Debug = "debug",
    /**
     * Error-level messages. Used for failures and unexpected conditions.
     */
    Error = "error",
    /**
     * Info-level messages. Used for general events.
     */
    Info = "info",
    /**
     * Disables logging
     */
    Off = "off",
    /**
     * Warning-level messages. Used for recoverable issues and unexpected non-fatal events.
     */
    Warning = "warning"
}

/**
 * Makes a subset of properties from a given type optional.
 *
 * @template T - The base object type.
 * @template K - The keys in `T` to make optional.
 *
 * This is useful when you want to partially override a type.
 *
 * @example
 * type Person = { name: string; age: number; email: string };
 * type PartialEmail = Optional<Person, "email">;
 * // PartialEmail = { name: string; age: number; email?: string }
 */
type Optional<T, K extends keyof T> = Omit<T, K> & {
    [P in K]?: T[P];
};

type CamelToSnake<T extends string> = T extends `${infer A}${infer B}` ? `${A extends Capitalize<A> ? "_" : ""}${Lowercase<A>}${CamelToSnake<B>}` : T;
type CamelToSnakeKeys<T extends object> = {
    [K in keyof T as K extends string ? CamelToSnake<K> : K]: T[K];
};
type CamelToSnakeKeysDeep<T extends object> = {
    [K in keyof T as K extends string ? CamelToSnake<K> : K]: T[K] extends object ? CamelToSnakeKeysDeep<T[K]> : T[K];
};
type LowercaseKeys<T> = {
    [K in keyof T as K extends string ? Lowercase<K> : K]: T[K];
};
type LowercaseKeysDeep<T extends object> = {
    [K in keyof T as K extends string ? Lowercase<K> : K]: T[K] extends object ? LowercaseKeysDeep<T[K]> : T[K];
};
type SnakeToCamel<T extends string> = T extends `${infer A}_${infer B}` ? `${A}${SnakeToCamel<Capitalize<B>>}` : T;
type SnakeToCamelKeys<T extends object> = {
    [K in keyof T as K extends string ? SnakeToCamel<K> : K]: T[K];
};
type SnakeToCamelKeysDeep<T extends object> = {
    [K in keyof T as K extends string ? SnakeToCamel<K> : K]: T[K] extends object ? SnakeToCamelKeysDeep<T[K]> : T[K];
};
type UppercaseKeys<T> = {
    [K in keyof T as K extends string ? Uppercase<K> : K]: T[K];
};
type UppercaseKeysDeep<T extends object> = {
    [K in keyof T as K extends string ? Uppercase<K> : K]: T[K] extends object ? UppercaseKeysDeep<T[K]> : T[K];
};

interface IteratorOptions {
    destroyOnReturn?: boolean;
}
interface PipeOptions {
    end?: boolean;
}
type SignalOption = Pick<ArrayOptions, "signal">;
/**
 * A strongly-typed extension of a `Readable` stream.
 *
 * Ensures that consumers of the stream can expect values of type `T`.
 *
 * @template T - The type of data emitted by the stream.
 */
interface TypedReadable<T> extends Readable {
    [Symbol.asyncIterator](): NodeJS.AsyncIterator<T>;
    asIndexedPairs(options?: SignalOption): TypedReadable<[number, T]>;
    drop(limit: number, options?: SignalOption): TypedReadable<T>;
    every(fn: (value: T, options?: SignalOption) => boolean | Promise<boolean>, options?: ArrayOptions): Promise<boolean>;
    filter(fn: (value: T, options?: SignalOption) => boolean | Promise<boolean>, options?: ArrayOptions): TypedReadable<T>;
    find(fn: (value: T, options?: SignalOption) => boolean | Promise<boolean>, options?: ArrayOptions): Promise<T | undefined>;
    flatMap<Q>(fn: (value: T, options?: SignalOption) => Q | Iterable<Q> | AsyncIterable<Q>, options?: ArrayOptions): TypedReadable<Q>;
    forEach(fn: (value: T, options?: SignalOption) => void | Promise<void>, options?: ArrayOptions): Promise<void>;
    iterator(options?: IteratorOptions): NodeJS.AsyncIterator<T>;
    map<Q>(fn: (value: T, options?: SignalOption) => Q | Promise<Q>, options?: ArrayOptions): TypedReadable<Q>;
    pipe<S extends NodeJS.WritableStream>(destination: S, options?: PipeOptions): S;
    reduce<Q>(fn: (previousValue: Q, currentValue: T, options?: SignalOption) => Q, initial?: Q, options?: SignalOption): Promise<Q>;
    some(fn: (value: T, options?: SignalOption) => boolean | Promise<boolean>, options?: ArrayOptions): Promise<boolean>;
    take(limit: number, options?: SignalOption): TypedReadable<T>;
    toArray(options?: SignalOption): Promise<T[]>;
}

/**
 * Creates a new object with the same values and
 * keys transformed from camelCase to snake_case.
 *
 * @typeParam T The type of the input object
 *
 * @param obj The object whose keys will be transformed
 *
 * @returns A new object with snake_case keys
 */
declare function camelToSnakeKeys<T extends object>(obj: T): CamelToSnakeKeys<T>;
/**
 * Creates a new object with the same
 * values and keys transformed to lowercase.
 *
 * @typeParam T The type of the input object
 *
 * @param obj The object whose keys will be transformed
 *
 * @returns A new object with lowercase keys
 */
declare function lowercaseKeys<T extends object>(obj: T): LowercaseKeys<T>;
/**
 * Creates a new object with the same values and
 * keys transformed from snake_case to camelCase.
 *
 * @typeParam T The type of the input object
 *
 * @param obj The object whose keys will be transformed
 *
 * @returns A new object with camelCase keys
 */
declare function snakeToCamelKeys<T extends object>(obj: T): SnakeToCamelKeys<T>;
/**
 * Converts a synchronous or asynchronous
 * iterator into an asynchronous generator.
 *
 * Allows consistent handling of iterators
 * regardless of whether they are synchronous
 * or asynchronous.
 *
 * @typeParam T The type of values yielded by the iterator
 *
 * @param iterator - A sync / async iterator
 *
 * @returns An async generator
 */
declare function toAsyncIterator<T>(iterator: AsyncIterator<T> | Iterator<T>): AsyncGenerator<T>;
/**
 * Creates a new object with the same
 * values and keys transformed to uppercase.
 *
 * @typeParam T The type of the input object
 *
 * @param obj The object whose keys will be transformed
 *
 * @returns A new object with uppercase keys
 */
declare function uppercaseKeys<T extends object>(obj: T): UppercaseKeys<T>;

/**
 * Represents a reusable source of values that supports both
 * on-demand generation via `next()` and iterable consumption.
 *
 * @template T - The type of values produced by the source.
 */
interface Source<T> extends Iterable<T> {
    /**
     * Returns the next value from the source.
     *
     * This method should return a new value each time it is called.
     */
    next(): T;
}
/**
 * A source of infinite UUIDv4 strings.
 *
 * Implements a `next()` method for generating a single UUID
 * and an infinite iterable that yields UUIDs on demand.
 */
declare class UuidSource implements Source<string> {
    /**
     * Returns a generated UUID string
     */
    next(): string;
    /**
     * Returns an infinite iterator of UUID strings
     *
     * @returns {Iterator<string>}
     */
    [Symbol.iterator](): Iterator<string>;
}

export { BoundedMap, BoundedSet, type CamelToSnake, type CamelToSnakeKeys, type CamelToSnakeKeysDeep, type Chunk, type ConstEnum, D2Map, Environment, type HeaderProvider, IdentityProvider, type IdentityProviderConfig, type IteratorOptions, LogLevel, type Logger, type LowercaseKeys, type LowercaseKeysDeep, type Optional, type PipeOptions, type SignalOption, type SnakeToCamel, type SnakeToCamelKeys, type SnakeToCamelKeysDeep, type Source, type TypedReadable, type UppercaseKeys, type UppercaseKeysDeep, UuidSource, asyncChunkify, camelToPascal, camelToSnake, camelToSnakeKeys, capitalize, chunkify, d2MapDelete, d2MapGet, d2MapHas, d2MapSet, isAlpha, isAlphaNumeric, isArray, isAsyncIterable, isBigInt, isBoolean, isFunction, isInt, isIterable, isNumber, isObject, isString, isTransferable, lowercaseKeys, pascalToCamel, pascalToSnake, snakeToCamel, snakeToCamelKeys, snakeToPascal, toAsyncIterator, toCamelCase, toPascalCase, toSnakeCase, uppercaseKeys, wait, waitUntil };
