import { NonPlainObject } from "../_internal/NonPlainObject.js"; //#region src/types/ToKebabCaseKeys.d.ts type SnakeToKebab = S extends `${infer P1}_${infer P2}` ? Lowercase<`${P1}-${SnakeToKebab}`> : Lowercase; type CamelToKebab = S extends `${infer P1}${infer P2}` ? P2 extends Uncapitalize ? `${Lowercase}${CamelToKebab}` : `${Lowercase}-${CamelToKebab>}` : S; type KebabCase = S extends `${string}_${string}` ? SnakeToKebab : S extends Uppercase ? Lowercase : CamelToKebab; /** * Converts the keys of `T` to kebab-case recursively. * * This is the return type of the `toKebabCaseKeys` function. Recurses into * plain objects and arrays; built-in objects like `Date`, `Map`, and functions * pass through unchanged. * * @template T - The type whose keys are converted. * * @example * type Response = { userId: number; firstName: string }; * type Converted = ToKebabCaseKeys; * // => { 'user-id': number; 'first-name': string } */ type ToKebabCaseKeys = T extends NonPlainObject ? T : T extends any[] ? Array> : T extends Record ? { [K in keyof T as KebabCase]: ToKebabCaseKeys } : T; //#endregion export { ToKebabCaseKeys };