import { S as Substract } from './CM89_aaq.js'; import { p as IsZero } from './DZEfmVOc.js'; import { DefaultValue } from '../DefaultValue.js'; /** * Default the properties of an object by the properties of another object. * Meaning that if the first object has a property that is undefined or null, * the second object's property will be used instead. * * @template T1 The object to default * @template T2 The object to default with * @template N The depth to apply the defaults * @returns The defaulted object */ type DefaultObject = { [P in (keyof T1 | keyof T2)]-?: P extends keyof T1 ? P extends keyof T2 ? IsZero extends true ? DefaultValue : Default> : T1[P] : P extends keyof T2 ? DefaultValue : never; }; /** * Default a value or collection by another value or collection. Meaning that if * the first value is undefined or null, the second value will be used instead. * * You can also apply defaults to nested objects by setting the `N` template to * a positive number. * * @template T1 The value or collection to default * @template T2 The value or collection to default with * @template N The depth to apply the defaults * @template C If `true`, arrays will be concatenated instead of replaced * @returns The defaulted value or collection * @example Default // number | string */ type Default = ([T1, T2] extends [infer V1 extends readonly any[], infer V2 extends readonly any[]] ? C extends true ? [...V2, ...V1] : DefaultValue : [T1, T2] extends [infer V1 extends object, infer V2 extends object] ? DefaultObject : DefaultValue) extends infer R ? { -readonly [K in keyof R]: R[K]; } : never; export type { Default as D, DefaultObject as a };