/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ /** * Overlaps (#1198): two events on one resource at once — what the Plan's * builder flags (`Plan Builder Spec.md` PB51–PB53), and the Calendar's built-in * conflict (`Calendar Spec.md` B43–B45, #1155), which shares the kinds. * * Events pair within a GROUP the caller gives: on a Plan, each kind that warns * of its overlaps is a group of its own, as two events of a kind are a pair * (PB51); on a Calendar, every event is in one. Within a group, per resource — * its kind and its key together — sorted by start, a sweep keeps the events * still running, and each event pairs with every one of them whose end is past * its start. Spans are half-open, `[start, end)`, as the lanes' are * (`../time/lanes.ts`): two events that only meet do not overlap, and an * instant, which spans nothing, overlaps nothing. An event with no time (in the * backlog) or on no resource never overlaps. * * The pairs come earliest first, as the Calendar's mock picks its first pair: * by the earlier event's start, then the later's, each tie broken by the * events' keys. Every time is compared as East compares a DateTime, a resource * as East compares its ref, and a key as East compares a String. * * @packageDocumentation */ import { type ValueTypeOf } from "@elaraai/east"; import { Schedule } from "@elaraai/e3-ui/internal"; /** One event as every view draws it — `Schedule.Types.Item`, decoded. */ export type ScheduleItemValue = ValueTypeOf; /** Two events on one resource whose times overlap. */ export interface ScheduleOverlapPair { /** The one that starts first — the one whose key sorts first, when they start together. */ readonly first: I; /** The other. */ readonly second: I; /** When they begin to overlap: the later start. */ readonly from: Date; /** When they stop: the earlier end. */ readonly to: Date; } /** The overlaps among some events. */ export interface ScheduleOverlaps { /** Every pair, earliest first. */ readonly pairs: readonly ScheduleOverlapPair[]; /** * Each event in a pair — by its element's key, the text East prints of its * `Schedule.Types.EventRef` — and the events it overlaps, earliest first. */ readonly peers: ReadonlyMap; } /** * The element key of an event: East's print of its `Schedule.Types.EventRef`, * which every element it draws carries. * * @param item - The event * @returns Its key */ export declare function scheduleEventKey(item: ScheduleItemValue): string; /** * The overlaps among events — see the module docs. * * @typeParam I - The events' type: `Schedule.Types.Item`'s, or a view's own with its fields (the Plan's `PlanItem`) * @param groups - The events, in the groups whose events may pair: each kind that warns of its overlaps on a Plan, all of them on a Calendar * @returns The pairs, earliest first, and each event's peers */ export declare function scheduleOverlaps(groups: Iterable): ScheduleOverlaps; //# sourceMappingURL=overlaps.d.ts.map