import { t as CalendarDate } from "./calendar-date-CNNsHVof.js"; import { t as SelectionMode } from "./selection-types-DhmKlruR.js"; import { r as DateRuleEngine, s as CalendarRange } from "./date-rule-engine-CNfIfs0F.js"; //#region src/core/preset-engine.d.ts /** * Preset engine — turns named shortcuts ("Today", "Last 7 days", "This month") * into candidate selection values. * * Careful boundary (the `mode`/flow concern from the v3 doc): a preset is a * pure resolver to a *candidate value*. It never changes the selection mode, * never bypasses a selection strategy, and never drives reducer behavior. * `mode` appears here only as an explicit display/validation filter — "should * this preset be offered, and is its value usable right now?" — passed in by * the caller. Applying a chosen preset goes through the same strategy as a * manual pick, so all invariants (disabled, min/max, range limits) hold. */ type PresetContext = { today: CalendarDate; firstDayOfWeek: number; }; type PresetResult = { kind: "date"; date: CalendarDate; } | { kind: "dates"; dates: CalendarDate[]; } | { kind: "range"; range: CalendarRange; }; /** * A display label: a plain string, or a locale-aware function (v2 parity) — * resolve with {@link resolvePresetLabel} at render time. */ type PresetLabel = string | ((locale: string) => string); type Preset = { /** Stable identity — used as React key and for telemetry; never the label. */ id: string; /** Optional display label — plain string or `(locale) => string`. */ label?: PresetLabel; /** Optional grouping for sectioned preset lists. */ group?: string; /** Pure resolver. Returns `null` when the preset does not apply in context. */ resolve: (ctx: PresetContext) => PresetResult | null; /** * Modes this preset is offered in. Defaults are inferred from the result kind * (date → single/multiple, dates → multiple, range → range/multi-range). */ modes?: SelectionMode[]; }; type PresetStatus = "ok" | "incompatible" | "disabled" | "empty"; type EvaluatedPreset = { preset: Preset; result: PresetResult | null; status: PresetStatus; }; type PresetValidationContext = { mode: SelectionMode; /** Compiled disabled engine (NOT exclude) — blocks selection. */ rules?: DateRuleEngine; min?: CalendarDate; max?: CalendarDate; }; type PresetEngine = { /** Deduped, order-preserving preset list. */ presets: Preset[]; resolve(id: string, ctx: PresetContext): PresetResult | null; /** Status of every preset for the given context (pure, no side effects). */ evaluate(ctx: PresetContext, vctx: PresetValidationContext): EvaluatedPreset[]; /** Presets grouped by `group`, preserving first-seen order. */ groups(): { group?: string; presets: Preset[]; }[]; }; /** * Compile presets into a queryable engine. Defensive by contract: `null`/ * malformed entries are skipped and duplicate ids dropped (first wins), each * with a dev warning — user-supplied preset lists never crash the render. */ declare function compilePresets(input?: readonly Preset[]): PresetEngine; /** Resolve a {@link PresetLabel} for display; falls back to the preset id. */ declare function resolvePresetLabel(preset: Preset, locale?: string): string; declare const presetToday: Preset; declare const presetLast7Days: Preset; declare const presetThisWeek: Preset; declare const presetThisMonth: Preset; declare const presetYesterday: Preset; declare const presetTomorrow: Preset; declare const presetLastWeek: Preset; declare const presetNextWeek: Preset; declare const presetLastMonth: Preset; declare const presetNextMonth: Preset; declare const presetLastYear: Preset; declare const presetNextYear: Preset; /** Convenience bundle of the common (range-ish) presets, in display order. */ declare const commonPresets: Preset[]; /** * Relative single-date quick-picks, past → future (the v2 `basicPresets` pack): * last year / month / week, yesterday, today, tomorrow, next week / month / year. */ declare const relativePresets: Preset[]; /** Declarative preset spec — compiled to a {@link Preset} by {@link definePreset}. */ type PresetInput = { id?: string; /** Display label — plain string or `(locale) => string` (v2 parity). */ label: PresetLabel; group?: string; modes?: SelectionMode[]; /** Day offset from today (number, ± = future/past) OR a fixed wall-clock Date. */ value?: number | Date; /** Span length in days after `value` — turns the pick into a range. */ range?: number; /** Full form: return a `Date`, a `{ from, to }` span, or `null` to hide. */ getValue?: (ctx: { now: Date; }) => Date | { from: Date; to: Date; } | null; }; /** * Compile a declarative {@link PresetInput} into a {@link Preset}. Defensive: * malformed entries degrade to an inert preset with a dev warning, and NaN * dates from `value`/`getValue` resolve to `null` — presets never throw. */ declare function definePreset(input: PresetInput): Preset; //#endregion export { presetYesterday as C, presetTomorrow as S, resolvePresetLabel as T, presetNextWeek as _, type PresetLabel as a, presetThisWeek as b, type PresetValidationContext as c, definePreset as d, presetLast7Days as f, presetNextMonth as g, presetLastYear as h, type PresetInput as i, commonPresets as l, presetLastWeek as m, type Preset as n, type PresetResult as o, presetLastMonth as p, type PresetContext as r, type PresetStatus as s, type EvaluatedPreset as t, compilePresets as u, presetNextYear as v, relativePresets as w, presetToday as x, presetThisMonth as y };