import type { ParsePath, Path as PathArray, PathItem } from 'pathington'; import type { DefaultMemoizeFields } from 'reselect'; export type AnyFn = (...args: any[]) => any; export interface PathObject { argIndex?: number; path: PathingtonPath; } export type PathingtonPath = PathArray | PathItem; export type Path = ManualSelectInput | PathingtonPath | PathObject; export type PathStructured = Record>; export interface Options { deepEqual?: boolean; isEqual?: (a: Value, b: Value) => boolean; memoizer?: AnyFn; memoizerParams?: any[]; } export type IsAny = 0 extends 1 & NoInfer ? true : false; export type IsNever = [T] extends [never] ? true : false; export type IsNull = [T] extends [null] ? true : false; export type IsKnown = IsAny extends false ? (IsUnknown extends false ? true : false) : false; export type IsUnknown = unknown extends T ? (IsNull extends false ? true : false) : false; type PickArray = Value[Index]; type PickObject = Value[Key]; type WidenUnknown = T extends [infer Head, ...infer Tail] ? IsUnknown extends true ? WidenUnknown : WidenUnknown : Result; type PickDeepInternal = IsUnknown extends true ? unknown : Property extends [infer Next, ...infer Rest] ? Value extends object ? Next extends keyof Value ? PickDeepInternal, Rest> : undefined : Value extends unknown[] ? Next extends number ? PickDeepInternal, Rest> : undefined : undefined : Value; export type PickDeepInternalNormalized = Property extends unknown[] ? PickDeepInternal : Property extends readonly unknown[] ? PickDeepInternal : any; export type PickDeep = PickDeepInternalNormalized>; export type ManualSelectInput = (...params: WidenUnknown) => any; type SelectInputs = Paths extends [ infer Property, ...infer Remaining ] ? Property extends PathingtonPath ? SelectInputs]> : Property extends PathObject ? Property['argIndex'] extends number ? SelectInputs]> : SelectInputs]> : Property extends ManualSelectInput ? SelectInputs]> : SelectInputs : Values; export type UnionToIntersection = (Union extends unknown ? (distributedUnion: Union) => void : never) extends (mergedIntersection: infer Intersection) => void ? Intersection & Union : never; type Push = [...T, V]; type LastOf = UnionToIntersection T : never> extends () => infer R ? R : never; export type TuplifyUnion, N = [T] extends [never] ? true : false> = true extends N ? [] : Push>, L>; export type ObjectValuesToTuple, R extends any[] = []> = KS extends [ infer K, ...infer KT ] ? ObjectValuesToTuple : R; export type SelectStructuredInputs> = { [Property in keyof Paths]: Paths[Property] extends PathingtonPath ? PickDeep : Paths[Property] extends PathObject ? Paths[Property]['argIndex'] extends number ? Paths[Property]['argIndex'] : PickDeep : Paths[Property] extends ManualSelectInput ? ReturnType : never; }; export type ComputeValue = (...values: SelectInputs, Paths>) => Result; export type StructuredValues> = ObjectValuesToTuple>; export type ComputeStructuredValue, Result> = (...values: StructuredValues) => Result; export type IdentitySelectorFn = (...params: Params) => SelectInputs, Paths>[0]; export type IdentitySelector = IdentitySelectorFn & DefaultMemoizeFields; export type IdentityStructuredSelectorFn> = (...params: Params) => SelectStructuredInputs, Paths>; export type IdentityStructuredSelector> = IdentityStructuredSelectorFn & DefaultMemoizeFields; export type StandardSelectorFn = (...params: Params) => Result; export type StandardSelector = StandardSelectorFn & DefaultMemoizeFields; export {};