/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ /** Calendar's UTC windows and projected data; no UI or record writes. */ import { type ValueTypeOf } from "@elaraai/east"; import { CalendarPayloadType, ScheduleEventRefType, ScheduleResourceRefType } from "@elaraai/e3-ui/internal"; import type { Formatters } from "@elaraai/east-ui-components"; import { type ScheduleItemValue } from "../shared/schedule/overlaps.js"; /** Calendar's closed payload, decoded. */ export type CalendarValue = ValueTypeOf; /** A bound event kind. */ export type CalendarKind = CalendarValue["events"][number]; /** An event's shared projection. */ export type CalendarItem = ScheduleItemValue; /** The resource an event is on. */ export type CalendarResource = ValueTypeOf; /** An event's identity, independent of its position or record's key type. */ export type CalendarRef = ValueTypeOf; /** One template, as its record mapping projected it. */ export type CalendarTemplate = CalendarKind["templates"][number]; /** A persisted view uses an epoch, since local storage serializes JSON. */ export interface CalendarView { layout: CalendarValue["settings"]["layout"]["type"]; period: CalendarValue["settings"]["period"]["type"]; date: number; } /** The rendered period and its days. */ export interface CalendarRange { from: Date; to: Date; days: readonly Date[]; } /** A resource column/row. Unassigned has no resource ref. */ export interface CalendarRow { key: string; label: string; meta: string; group: string; icon?: string; resource: CalendarItem["resource"]; } /** * What the Calendar's figures leave out (#1424): the kinds past the cap, none of whose events is drawn but their drafts * — their names, as running text writes them — and the resource kinds they are placed on, whose resources' figures * count none of them. A figure that would count them says they are not counted, never 0. */ export interface CalendarUncounted { /** The kinds' names, as running text writes them: `print job`. */ readonly names: readonly string[]; /** Whether every kind is among them: a figure then counts no event at all, and says no number. */ readonly all: boolean; /** The resource kinds they are placed on, by slot. */ readonly resources: ReadonlySet; } /** No kind past the cap: every figure counts every kind. */ export declare const NOTHING_UNCOUNTED: CalendarUncounted; /** A slot recipe's styles. */ export type CalendarStyles = Record>; export { DAY, NARROW_WIDTH, dayStart, weekStart } from "../shared/schedule/window.js"; /** A calendar gesture's smallest span. */ export declare const QUARTER: number; /** Canonical ids avoid collisions across record kinds and arbitrary keys: the shared print of an event's reference. */ export declare const eventKey: (value: { readonly kind: string; readonly key: string; }, ctx?: { refs: Map; currentPath: string[]; }) => string; /** Resource ids use the shared East codec, not delimiter concatenation. */ export declare const resourceKey: (value: { readonly kind: string; readonly key: string; }, ctx?: { refs: Map; currentPath: string[]; }) => string; /** Reads an event id as its shared East type: the shared parser of an event's reference. */ export declare const parseEventKey: (x: string) => { success: true; value: { readonly kind: string; readonly key: string; }; position: number; } | { success: false; error: string; position: number; }; /** Reads a resource id as its shared East type. */ export declare const parseResourceKey: (x: string) => { success: true; value: { readonly kind: string; readonly key: string; }; position: number; } | { success: false; error: string; position: number; }; /** Drag coordinates use East's DateTime representation. */ export declare const timeKey: (value: Date, ctx?: { refs: Map; currentPath: string[]; }) => string; /** Reads a drag coordinate. */ export declare const parseTimeKey: (x: string) => { success: true; value: Date; position: number; } | { success: false; error: string; position: number; }; /** Resource equality is the record contract's equality. */ export declare const sameResource: (x: { readonly kind: string; readonly key: string; }, y: { readonly kind: string; readonly key: string; }) => boolean; /** * The period a view shows: its own on every layout but Resources, which shows a day whatever its period — what its * window spans, a step moves it by, the toolbar names and an optimiser is asked of. * * @param view - The view: its layout and its period * @returns The period it shows */ export declare function viewPeriod(view: Pick): CalendarView["period"]; /** Calendar days including the surrounding weeks of a month. */ export declare function calendarRange(view: CalendarView, settings: CalendarValue["settings"]): CalendarRange; /** * The periods either side of the view, read ahead once its window lands * (#1398, CL7): the ranges a step to the next and the previous period reads, * on every layout — the timeline's among them, which shows its period as the * others do (ruled 9 Nov 2026). * * @param view - The view * @param settings - The Calendar's settings: its week's first day and its weekends * @returns The next period's range, then the previous one's */ export declare function calendarAhead(view: CalendarView, settings: CalendarValue["settings"]): readonly CalendarRange[]; /** * The period a window is, as the footer's loading line names it (#1398, CL3): * where the window is the view's own period, a day's name or a month's — * `Tue, Nov 3, 2026`, `November 2026` — else its days, from its first to its * last: a week, or a range the slice holds. * * @param view - The view * @param range - The window read * @param settings - The Calendar's settings: its week's first day and its weekends * @param format - The locale's formatters * @returns The period's words */ export declare function periodWords(view: CalendarView, range: CalendarRange, settings: CalendarValue["settings"], format: Pick): string; /** Previous/next period, with resource columns retaining one day. */ export declare function navigate(view: CalendarView, step: number): CalendarView; /** Whether a scheduled event — one with a start and an end — meets a half-open window ({@link meetsWindow}). */ export declare function inWindow(item: CalendarItem, from: Date, to: Date): boolean; /** Stable chronological order, including a tie-break across record kinds. */ export declare function chronological(items: readonly CalendarItem[]): CalendarItem[]; /** * What a resource Chooser offers (#1343): each kind's rows the rail shows and, * whatever it hides, the rows `keep` names — an event's own resource stays * choosable, in the kind's order. * * @param all - Every resource kind, every row * @param shown - Each kind's rows the rail shows * @param keep - The rows to offer whatever the rail shows * @returns Each kind with the rows its Chooser offers */ export declare function resourceChoices(all: CalendarValue["resources"], shown: CalendarValue["resources"], keep: readonly CalendarResource[]): CalendarValue["resources"]; /** Whether an event is on a row, including the unassigned row. */ export declare function onResource(item: CalendarItem, row: CalendarRow): boolean; /** * The resource an event is on, by name, wherever the Calendar names it — the views and a Backlog card: its row's label; * a resource no row the frame holds names — a paged kind's whose window is not read (#1424) — by its key, never * "Unassigned", which is an event on no resource's. * * @param item - The event * @param rows - Every resource row the frame holds: each kind's, a paged kind's of the windows held, and the unassigned one * @returns Its resource's name */ export declare function resourceLabel(item: CalendarItem, rows: readonly CalendarRow[]): string; /** A UTC time, used in fixed-size grid labels and editable time fields. */ export declare function clockText(date: Date): string; /** A UTC date, used in date fields. */ export declare function dateText(date: Date): string; /** Parses only a complete valid UTC date/time from an action form. */ export declare function inputInstant(date: string, time: string): Date | undefined; //# sourceMappingURL=model.d.ts.map