{"version":3,"file":"types.mjs","sources":["../../../src/lib/utils/types.ts"],"sourcesContent":["/**\n * @file Common Type Utilities\n * @description Shared type definitions and type helpers\n *\n * This module provides common utility types. Many core types are now\n * centralized in shared/type-utils.ts - prefer importing from there.\n */\n\n// Re-export canonical types from shared utilities\n// Note: Some types are commented out to avoid conflicts\n// export type { DeepPartial, DeepReadonly } from '../shared/type-utils';\nexport type { Result } from '../shared/type-utils';\n// export type { Brand, Milliseconds, Seconds, Pixels, Percentage } from '../shared/type-utils';\nexport { ok, err, isOk, isErr } from '../shared/type-utils';\n\n/**\n * Make all properties required recursively\n */\nexport type DeepRequired<T> = T extends object\n  ? { [P in keyof T]-?: DeepRequired<T[P]> }\n  : T;\n\n/**\n * Make all properties readonly recursively\n */\nexport type DeepReadonly<T> = T extends object\n  ? { readonly [P in keyof T]: DeepReadonly<T[P]> }\n  : T;\n\n/**\n * Make specific keys optional\n */\nexport type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;\n\n/**\n * Make specific keys required\n */\nexport type RequiredBy<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;\n\n/**\n * Extract keys of a certain type\n */\nexport type KeysOfType<T, U> = {\n  [K in keyof T]: T[K] extends U ? K : never;\n}[keyof T];\n\n/**\n * Omit keys of a certain type\n */\nexport type OmitByType<T, U> = Pick<T, { [K in keyof T]: T[K] extends U ? never : K }[keyof T]>;\n\n/**\n * Pick keys of a certain type\n */\nexport type PickByType<T, U> = Pick<T, KeysOfType<T, U>>;\n\n/**\n * Nullable type\n */\nexport type Nullable<T> = T | null;\n\n/**\n * Maybe type (null or undefined)\n */\nexport type Maybe<T> = T | null | undefined;\n\n/**\n * Non-nullable nested type\n */\nexport type NonNullableDeep<T> = T extends object\n  ? { [K in keyof T]: NonNullableDeep<NonNullable<T[K]>> }\n  : NonNullable<T>;\n\n/**\n * Union to intersection\n */\nexport type UnionToIntersection<U> = (\n  U extends unknown ? (x: U) => void : never\n) extends (x: infer I) => void\n  ? I\n  : never;\n\n/**\n * String literal type\n */\nexport type StringLiteral<T> = T extends string\n  ? string extends T\n    ? never\n    : T\n  : never;\n\n/**\n * Branded type for nominal typing\n */\nexport type Brand<T, B extends string> = T & { readonly __brand: B };\n\n/**\n * ID type\n */\nexport type Id<T extends string = string> = Brand<string, T>;\n\n/**\n * Create branded type helper\n */\nexport function brand<T, B extends string>(value: T): Brand<T, B> {\n  return value as Brand<T, B>;\n}\n\n/**\n * Unwrap Promise type\n */\nexport type Awaited<T> = T extends Promise<infer U> ? Awaited<U> : T;\n\n/**\n * Function type\n */\nexport type Fn<Args extends unknown[] = unknown[], Return = unknown> = (\n  ...args: Args\n) => Return;\n\n/**\n * Async function type\n */\nexport type AsyncFn<Args extends unknown[] = unknown[], Return = unknown> = (\n  ...args: Args\n) => Promise<Return>;\n\n/**\n * Class constructor type\n */\nexport type Constructor<T = object> = new (...args: unknown[]) => T;\n\n/**\n * Get return type of constructor\n */\nexport type InstanceOf<T extends Constructor> = T extends Constructor<infer I>\n  ? I\n  : never;\n\n/**\n * Tuple type\n */\nexport type Tuple<T, N extends number> = N extends N\n  ? number extends N\n    ? T[]\n    : TupleOfHelper<T, N, []>\n  : never;\n\ntype TupleOfHelper<T, N extends number, R extends unknown[]> = R['length'] extends N\n  ? R\n  : TupleOfHelper<T, N, [T, ...R]>;\n\n/**\n * Record with string keys\n */\nexport type Dictionary<T = unknown> = Record<string, T>;\n\n/**\n * Entries type\n */\nexport type Entries<T> = [keyof T, T[keyof T]][];\n\n/**\n * Values type\n */\nexport type ValueOf<T> = T[keyof T];\n\n/**\n * Flatten type\n */\nexport type Flatten<T> = T extends (infer U)[] ? U : T;\n\n/**\n * Element type of array\n */\nexport type ElementOf<T> = T extends readonly (infer E)[] ? E : never;\n\n/**\n * Path keys of nested object\n */\nexport type PathKeys<T, D extends number = 5> = [D] extends [never]\n  ? never\n  : T extends object\n  ? {\n      [K in keyof T]-?: K extends string | number\n        ? `${K}` | `${K}.${PathKeys<T[K], Prev[D]>}`\n        : never;\n    }[keyof T]\n  : never;\n\ntype Prev = [never, 0, 1, 2, 3, 4, ...0[]];\n\n/**\n * Make all properties optional recursively\n */\nexport type DeepPartial<T> = T extends object\n  ? { [P in keyof T]?: DeepPartial<T[P]> }\n  : T;\n\n/**\n * Mutable type (remove readonly)\n */\nexport type Mutable<T> = {\n  -readonly [P in keyof T]: T[P];\n};\n\n/**\n * Deep mutable type\n */\nexport type DeepMutable<T> = {\n  -readonly [P in keyof T]: T[P] extends object ? DeepMutable<T[P]> : T[P];\n};\n\n/**\n * Exact type (no excess properties)\n */\nexport type Exact<T, Shape> = T extends Shape\n  ? Exclude<keyof T, keyof Shape> extends never\n    ? T\n    : never\n  : never;\n\n/**\n * JSON-serializable type\n */\nexport type JsonValue =\n  | string\n  | number\n  | boolean\n  | null\n  | JsonValue[]\n  | { [key: string]: JsonValue };\n\n/**\n * JSON object type\n */\nexport type JsonObject = { [key: string]: JsonValue };\n\n/**\n * Error with code\n */\nexport interface CodedError extends Error {\n  code: string;\n}\n\n// Result type and related functions are re-exported from shared/type-utils at the top of this file.\n// See: ok, err, isOk, isErr, Result\n"],"names":["brand","value"],"mappings":"AAwGO,SAASA,EAA2BC,GAAuB;AAChE,SAAOA;AACT;"}