/** * Copyright 2026 - present Nazmul Hassan * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { D as NumericString, T as Nullable } from "./index-Dx3yeNwR.mjs"; import { _ as UUIDVersion, g as UUIDOptions, h as UUID, l as DecodedUUID, p as SupportedVersion } from "./hash-Bm0RgeVs.mjs"; //#region src/guards/specials.d.ts /** * * Type guard to check if a value is a valid email string. * @param value - The value to check. * @returns `true` if the value is a valid email, otherwise `false`. */ declare function isEmail(value: unknown): value is string; /** * * Type guard to check if a value is an array of valid email strings. * @param value - The value to check. * @returns `true` if the value is an array of valid email strings, otherwise `false`. */ declare function isEmailArray(value: unknown): value is string[]; /** * * Type guard to check if a value is a valid date string. * @param value - The value to check. * @returns `true` if the value is a valid date string, otherwise `false`. */ declare function isDateString(value: unknown): value is string; /** * * Type guard to check if a value is a valid UUID (`RFC4122` `v1`-`v8`). * @param value - The value to check. * @returns `true` if the value matches standard UUID pattern, otherwise `false`. */ declare function isUUID(value: unknown): value is UUID; /** * * Type guard to check if the code is running in a browser environment. * @returns `true` if the code is running in a browser, otherwise `false`. */ declare function isBrowser(): boolean; /** * * Type guard to check if the code is running in a Node.js environment. * @returns `true` if the code is running in Node.js, otherwise `false`. */ declare function isNode(): boolean; /** * * Type guard to check if a value is a valid URL. * @param value - The value to check. * @returns `true` if the value is a valid URL, otherwise `false`. */ declare function isURL(value: unknown): value is string; /** * * Type guard to check if a value is a valid Base64 encoded string. * @param value - The value to check. * @returns `true` if the value is a valid Base64 string, otherwise `false`. */ declare function isBase64(value: unknown): value is string; /** * * Type guard to check if a value is a valid hexadecimal byte sequence. * @param value - The value to check, spaced between bytes or un-spaced. * @returns `true` if the value is a valid hexadecimal byte sequence, otherwise `false`. */ declare function isHexString(value: unknown): value is string; /** * * Type guard to check if a value is a valid binary byte sequence. * @param value - The value to check, spaced between bytes or un-spaced. * @returns `true` if the value is a valid binary byte sequence, otherwise `false`. */ declare function isBinaryString(value: unknown): value is string; /** * * Type guard to check if a value is a valid phone number. * @param value - The value to check. * @returns `true` if the value is a valid phone number, otherwise `false`. */ declare function isPhoneNumber(value: unknown): value is string; /** * * Type guard to check if a value is a valid IP address (IPv4 or IPv6). * @param value - The value to check. * @returns `true` if the value is a valid IP address, otherwise `false`. */ declare function isIPAddress(value: unknown): value is string; /** * * Type guard to check if the current environment matches a given string. * @param env - The expected environment (e.g., "production", "development"). * @returns `true` if the value equals to `process.env.NODE_ENV`, otherwise `false`. */ declare function isEnvironment(env: string): boolean; /** * * Type guard to check if a value is a string representing a finite number. * * @remarks * - Accepts strings like: `"42"`, `" -5.5 "`, `"0.123"`, `"-0"`, `"1e5"`. * - Rejects strings like: `"NaN"`, `"Infinity"`, `"-Infinity"`, `"abc"`, `""`, `"42abc"`. * * @param value - The value to test. * @returns `true` if the value is a string that fully represents a finite number. */ declare function isNumericString(value: unknown): value is NumericString; //#endregion //#region src/hash/uuid.d.ts /** * * Generates UUIDs across all major RFC-compliant versions (1, 3, 4, 5, 6, 7, 8), following standards from `RFC4122`. Default version is `v4`. * * - **Version behavior:** * - `v1` → Timestamp & node-identifier–based * - `v3` → MD5(namespace + name) * - `v4` → Pure random (correct variant + version injection) * - `v5` → SHA-1(namespace + name) * - `v6` → Re-ordered timestamp variant of `v1` (lexicographically sortable) * - `v7` → Unix-time–based, monotonic-friendly * - `v8` → Custom layout, '“Future'` variant (timestamp + randomness) * * @param options Controls version, formatting, and required fields for `v3` and `v5`. * @returns A 5-parts UUID string formatted with correct version/variant bits. * * @example * // Generate a random UUID v4 * const id = uuid(); * * @example * // Generate uppercase v7 * const id = uuid({ version: 'v7', uppercase: true }); * * @example * // Generate v5 UUID * const id = uuid({ * version: 'v5', * namespace: '6ba7b810-9dad-11d1-80b4-00c04fd430c8', * name: 'example' * }); * * @remarks * - This utility provides a complete, engine-agnostic UUID generator with full RFC compliance, predictable formatting, and reliable uniqueness characteristics, suitable for browsers, Node.js, and restricted JavaScript runtimes. * - **Notes** * - `v1` and `v6` use a generated pseudo-node identifier. * - `v4` and `v8` uses {@link Math.random} when {@link crypto.getRandomValues} is unavailable, ensuring broad compatibility. * - `v3` and `v5` use internal `MD5`/`SHA-1` implementations and remain fully deterministic. * - `v7` **do not rely on crypto APIs**, preserving engine-agnostic behavior. * * - **Limitations** * - `v1`/`v6`: Node identifier is pseudo-random, not derived from real MAC addresses (for privacy). * - `v3`/`v5`: Hash algorithms (`MD5`/`SHA-1`) follow RFC specs but are not cryptographically secure. * - `v7`: Millisecond precision; extremely high throughput may still cause rare collisions. * - `v8`: Uses a simple timestamp + randomness layout; custom layouts are not supported here. * * - Use {@link https://toolbox-x.vercel.app/docs/utils/string/generate-random-id generateRandomID} for customized id generation or {@link https://toolbox-x.vercel.app/docs/utils/hash/random-hex randomHex} for hex-only random string with custom length. */ declare function uuid(options?: UUIDOptions): UUID; /** * * Decodes a UUID into its internal components, including version, variant, timestamps for time-based UUIDs and other metadata. * - Supports `RFC4122` UUID versions: 1-8. * * @param uuid The UUID string to decode. * @returns A structured `DecodedUUID` object, or `null` for invalid UUIDs. * * @example * const info = decodeUUID("f47ac10b-58cc-4372-a567-0e02b2c3d479"); * * @example * const info = decodeUUID(uuid({ version: "v1" })); * * @remarks * - Provides a cross-runtime UUID decoder covering essential metadata and timestamp interpretation for time-ordered UUID versions. * - **Notes** * - `v1/v6` timestamps are converted from the UUID epoch (1582-10-15) to standard Unix milliseconds. * - `v6` timestamps are lexicographically sortable and decoded accordingly. * - `v7` timestamps map directly to Unix time (48-bit millisecond precision). * - `v8` decoding is minimal because layouts are intentionally user-defined. * * - **Limitations** * - `v2` decoding is not implemented specifically. * - `v8` decoding only returns timestamp if it matches a known layout. * - `v3/v5` hash UUIDs contain no timestamp information. */ declare function decodeUUID(uuid: string): Nullable; /** Check if a value is UUID version 1 */ declare function isUUIDv1(value: unknown): value is UUID<'v1'>; /** Check if a value is UUID version 2 */ declare function isUUIDv2(value: unknown): value is UUID<'v2'>; /** Check if a value is UUID version 3 */ declare function isUUIDv3(value: unknown): value is UUID<'v3'>; /** Check if a value is UUID version 4 */ declare function isUUIDv4(value: unknown): value is UUID<'v4'>; /** Check if a value is UUID version 5 */ declare function isUUIDv5(value: unknown): value is UUID<'v5'>; /** Check if a value is UUID version 6 */ declare function isUUIDv6(value: unknown): value is UUID<'v6'>; /** Check if a value is UUID version 7 */ declare function isUUIDv7(value: unknown): value is UUID<'v7'>; /** Check if a value is UUID version 8 */ declare function isUUIDv8(value: unknown): value is UUID<'v8'>; //#endregion export { isURL as C, isPhoneNumber as S, isEnvironment as _, isUUIDv4 as a, isNode as b, isUUIDv7 as c, isBase64 as d, isBinaryString as f, isEmailArray as g, isEmail as h, isUUIDv3 as i, isUUIDv8 as l, isDateString as m, isUUIDv1 as n, isUUIDv5 as o, isBrowser as p, isUUIDv2 as r, isUUIDv6 as s, decodeUUID as t, uuid as u, isHexString as v, isUUID as w, isNumericString as x, isIPAddress as y };