import { type AnyFunction, type ComputedTypeError, type FixDeepFunctionInfer, type IsEqual, type Unwrap } from "../../../common"; import { type GetPropsWithValueExtends } from "../../../object"; import { type OnlyLiteralPrimitiveNumber } from "../../../clean/types/onlyLiteral"; import { type Primitive } from "../base"; type ComputeMatcher> = { [Prop in Unwrap]?: (value: GenericInput & Primitive) => unknown; }; type ForbiddenMoreKey, GenericMatcher extends ComputeMatcher> = Exclude> extends infer InferredKey ? IsEqual extends true ? unknown : ComputedTypeError<`Key "${Extract}" is forbidden.`> : never; type HandledKeys = Extract, number>; type OtherwiseValue, GenericMatcher extends object> = Extract, HandledKeys>>, any>; /** Performs partial pattern matching on a Clean number primitive and delegates unhandled values to an `otherwise` callback. /** /** **Supported call styles:** /** - Classic: `matchWithNumberOtherwise(input, matcher, otherwise)` -> runs a matching handler or the fallback /** - Curried: `matchWithNumberOtherwise(matcher, otherwise)` -> returns a function waiting for the primitive /** /** Raw number values are used as matcher keys. Handlers receive the original primitive narrowed to their key, and `otherwise` receives the same original primitive narrowed to all remaining values. /** /** ```ts /** const status = C.Number.createOrThrow( /** 200 as 200 | 404 | 500, /** ); /** /** C.matchWithNumberOtherwise( /** status, /** { /** 200: () => "success", /** }, /** () => "error", /** ); // string /** /** pipe( /** status, /** C.matchWithNumberOtherwise( /** { /** 404: () => "missing", /** }, /** (value) => value, /** ), /** ); // "missing" | C.Primitive<200 | 500> /** /** const result = C.matchWithNumberOtherwise( /** status, /** { /** 200: (value) => value, /** 404: undefined, /** }, /** (value) => value, /** ); // C.Primitive<200 | 404 | 500> /** ``` /** /** @remarks Constraints and `NewType` metadata remain attached to the primitive passed to every callback. /** /** @see https://utils.duplojs.dev/en/v1/api/clean/primitives/operators/matchWithNumberOtherwise /** @see [`C.matchWithNumber`](https://utils.duplojs.dev/en/v1/api/clean/primitives/operators/matchWithNumber) /** /** @namespace C /** */ export declare function matchWithNumberOtherwise, GenericMatcher extends ComputeMatcher, GenericOutput>(matcher: FixDeepFunctionInfer>, GenericMatcher> & ForbiddenMoreKey, GenericMatcher>, otherwise: (value: OtherwiseValue) => GenericOutput): (input: GenericInput & OnlyLiteralPrimitiveNumber) => (ReturnType[keyof GenericMatcher], AnyFunction>> | GenericOutput); export declare function matchWithNumberOtherwise, GenericMatcher extends ComputeMatcher, GenericOutput>(input: GenericInput & OnlyLiteralPrimitiveNumber, matcher: FixDeepFunctionInfer, GenericMatcher> & ForbiddenMoreKey, otherwise: (value: OtherwiseValue) => GenericOutput): (ReturnType> | GenericOutput); export {};