import type { Message } from "../opaque.ts"; /** * An intermediary builder for constructing a branch message, such as `plural`. * * @since 0.2.1 (`@hi18n/core`) */ export type BranchBuilder = { branch: >>( ...branches: Branches ) => Message< Branches extends BranchesBase> ? { [K in keyof T]: T[K] } : never >; }; /** * @since 0.2.1 (`@hi18n/core`) */ export type BranchesBase = [ ...When[], Otherwise, ]; /** * @since 0.2.1 (`@hi18n/core`) */ export type When = { type: "When"; when: Condition; message: M; }; /** * A DSL function used as part of a branch message, such as `plural`. * * @since 0.2.1 (`@hi18n/core`) */ export function when( when: Condition, message: M, ): When { return { type: "When", when, message }; } /** * @since 0.2.1 (`@hi18n/core`) */ export type Otherwise = { type: "Otherwise"; message: M; }; /** * A DSL function used as part of a branch message, such as `plural`. * * @since 0.2.1 (`@hi18n/core`) */ export function otherwise(message: M): Otherwise { return { type: "Otherwise", message }; }