/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. * * What the Plan's footer counts of its event kinds (#1193, PB23): the events * in the window, the backlog, and when a kind's record was last saved — read * from the kinds' own seams, every kind's drafts in * place, and read again when a record they read commits. The inspector shows * them too when nothing is selected, with how long the events run (#1197, * PB41). * * The same read finds the overlaps among the window's events (#1198, PB51): * two events of a kind that warns of them, on one resource at once — what the * toolbar's chip counts, the inspector's banner lists, and each event in a * pair wears a warn ring for. A kind whose overlaps are allowed is never in a * pair. It reads the backlog the library's Backlog tab lists, too (#1196). * * The read runs in a component of its own, {@link PlanKindsReader}, beside * what the rail hides of the backlog (#1344): a kind narrowed through an * interval index lands some fifty-five key searches a window, and each would * otherwise render the whole frame. It hands the frame what it read only when * that moves. * * The backlog never blinks (#1398, ruled 25 Oct 2026): its last complete read * and what the rail hides of it, counted with it, are held as one, as the * Calendar's are. While a narrowing's, a window's or a revision's read of * either is in flight they stand in, retained (CL8), and once both have landed * they are swapped whole — never a count dropped, never a count shown over * another read's cards. Every figure of the backlog is the held read's: the * Backlog tab's cards and count, the rail's badge, the footer's and the * inspector's. * * A kind the viewer hides in the Series tab is no part of what the canvas * shows: it is in none of the window's figures — its events, their hours, * their overlaps — and nothing says so; its backlog is the Backlog tab's * still, which lists it. * * @packageDocumentation */ import { type ValueTypeOf } from "@elaraai/east"; import { type PlanEventDraftsType, type PlanPayloadType } from "@elaraai/e3-ui/internal"; import { type BacklogNarrowing } from "../../shared/schedule/backlog.js"; import { type ScheduleCellsRead } from "../../shared/schedule/cells.js"; import { type ScheduleOverlaps } from "../../shared/schedule/overlaps.js"; import type { PlanEventPart } from "../root/sources.js"; import type { PlanScale } from "../scale.js"; /** One event kind, as the Plan's payload carries it (#1190). */ export type PlanEventKindValue = ValueTypeOf["events"][number]; /** One event as Plan draws it, as a kind's `planItems` reads it. */ export type PlanEventItemValue = Extract, { type: "some"; }>["value"][number]; /** The overlaps among the window's events (#1198). */ export type PlanOverlaps = ScheduleOverlaps; /** One unscheduled event, with the kind it is of: a card of the Backlog tab. */ export interface PlanBacklogEntry { readonly kind: PlanEventKindValue; readonly item: PlanEventItemValue; } /** What the footer counts of the event kinds. */ export interface PlanEventCounts { /** * The events in the window of every kind the viewer shows but those not counted (`uncounted`) — a kind given cells * counted exactly, from its source, as the rail counts it, or in memory, its record read whole (#1039); `undefined` * where no kind's are counted: every kind shown among `uncounted`, or none shown. */ readonly events: number | undefined; /** * The kinds shown whose events in the window are not counted (#1039): past the cap, and counted only by the days * its events run on — a day index's — which is no number of them. None of their events is read, and none is in * `events` or `minutes`. */ readonly uncounted: readonly PlanEventKindValue[]; /** * The kinds shown whose events in the window are counted, but not their hours (#1039): past the cap, counted * exactly — through their source, or in memory — and none of their events read, so none of their hours is in * `minutes`. */ readonly hoursNotCounted: readonly PlanEventKindValue[]; /** * How long the events read run, in minutes — a month counting 30 days, as a kind counts it; `undefined` where no * kind's hours are read, every kind shown past the cap or none shown. */ readonly minutes: number | undefined; /** * Whether a kind read by its cells counts its hours and its overlaps over the rows drawn (#1039): it reads only the * events of the resources around the rows in view, so the inspector says its hours are those in view. */ readonly drawn: boolean; /** The unscheduled events — every backlog kind's; `undefined` when no kind has a backlog. */ readonly backlog: number | undefined; /** The newest commit to any kind's record; `undefined` while there is none. */ readonly saved: Date | undefined; /** The overlaps among the events in the window: two events of a kind that warns of them, on one resource at once (#1198, PB51). */ readonly overlaps: PlanOverlaps; /** The unscheduled events, every backlog kind's, in the kinds' order: the Backlog tab's cards (#1196). */ readonly unscheduled: readonly PlanBacklogEntry[]; } /** The event kinds' counts as {@link usePlanEventCounts} reads them, and whether a read of them is in flight. */ export interface PlanEventCountsRead { /** The counts — the last read's while a read is in flight or failed; `undefined` for a Plan without event kinds, or before the first read answers. */ readonly counts: PlanEventCounts | undefined; /** Whether a read is in flight: `counts` stands in for it meanwhile. */ readonly reading: boolean; } /** Every kind's drafts, by kind then by entry id. */ type EventDrafts = ValueTypeOf; /** * The event kinds' counts over the window the canvas shows, every kind's * drafts in place (#1194). A kind read by its cells (#1039) never reads the * window: its events are counted exactly from its source, as the rail counts * them, its hours and its overlaps over the events its cells hold, and its * backlog read alone. A kind past the cap draws none, and none of its events * is read: it is counted exactly — through its source, or in memory, its record * read whole — but not its hours (`hoursNotCounted`), and one counted through * its day index, whose count is the days its events run on, no number of them, * is not counted at all (`uncounted`). Every other kind — each is counted * before it is read — is read over the window only once its count over the * range the canvas reads — the count the cells' reader decides by — is within * the cap; past it the last counts stand until the reader gives it no cells, * so no event of a range past the cap is read. A kind the viewer hides is in * no figure of the window, and its window is not read for them; its backlog * and its last save are counted still. * * @param kinds - The Plan's event kinds; `undefined` or none for a Plan without them * @param scale - The shared scale: the window the events are counted over * @param drafts - Every kind's drafts, by kind then by entry id — the same object while they hold; none for a Plan whose kinds hold none * @param cells - The kinds' cells and counts, when the reader decides a kind: what it draws from, its drafts as the seams take them, which counted kinds are read over the window, and which are past the cap * @param parts - Each event kind narrowed through its source of the slice: what a kind given cells is counted through * @param hidden - The ids the viewer hides in the Series tab: a kind hidden there is in no figure of the window * @returns The counts — the last read's while a read is in flight or fails; `undefined` for a Plan without event kinds, or before the first read answers — and whether a read is in flight */ export declare function usePlanEventCounts(kinds: readonly PlanEventKindValue[] | undefined, scale: PlanScale | undefined, drafts?: EventDrafts, cells?: ScheduleCellsRead | undefined, parts?: readonly PlanEventPart[], hidden?: readonly string[]): PlanEventCountsRead; /** What {@link PlanKindsReader} reads: the counts, and what the rail hides of the backlog — the backlog's held as one. */ export interface PlanKindsRead { /** * The event kinds' counts over the window; `undefined` before the first read answers. Their backlog — its cards * and how many there are — is the held read's, swapped together with what the rail hides of it (`backlog`). */ readonly counts: PlanEventCounts | undefined; /** What the rail hides of the backlog (#1344): the held read's, counted with its cards. */ readonly backlog: BacklogNarrowing; /** Whether the backlog stands in for a read in flight (#1398, CL8) — its cards' or its count's: retained. */ readonly retained: boolean; } /** Props of {@link PlanKindsReader}. */ export interface PlanKindsReaderProps { /** The Plan's event kinds. */ kinds: readonly PlanEventKindValue[]; /** The shared scale: the window the events are counted over. */ scale: PlanScale | undefined; /** Every kind's drafts. */ drafts: EventDrafts | undefined; /** Each event kind narrowed through its source of the slice. */ parts: readonly PlanEventPart[]; /** The kinds' cells and counts (#1039), when the reader decides a kind. */ cells: ScheduleCellsRead | undefined; /** The ids the viewer hides in the Series tab: a kind hidden there is in no figure of the window. */ hidden: readonly string[]; /** Where what it read goes: called only when that moves. */ onRead: (read: PlanKindsRead) => void; } /** * The event kinds' counts, and what the rail hides of the backlog, read in a * component of its own (see the module docs). * * @param props - What is read, over what, and where it goes * @returns Nothing: it reads */ export declare function PlanKindsReader({ kinds, scale, drafts, parts, cells, hidden, onRead }: PlanKindsReaderProps): null; export {}; //# sourceMappingURL=counts.d.ts.map