/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ import { type RibbonEnd } from "../shared/links/geometry.js"; import type { LinkLine, LinkRibbon } from "../shared/links/layer.js"; import { type LaneCard } from "./timeline-layout.js"; import { type Day } from "./model.js"; /** * How a drag draws a link of its families (A65, A69): the link it moves, faded to its `was` line, or the target's verdict * on it; or how the highlight draws a link a run of the optimiser added or changed (#1409): outlined in the Elara tone. */ export type LinkLook = "was" | "fits" | "refused" | "elara"; /** One link of the family: a bin's part on a resource. */ export interface FamilyLink { /** Its identity in the layer: the same for the same link in a focus's family and a drag's (`linkIds`). */ id: number; bin: string; resource: string; /** Its quantity; `undefined` for a reservation's, which draws thin and has no caption. */ quantity: number | undefined; /** Whether the drafts changed it: its bin new, or this part not as the day holds it. */ draft: boolean; /** How a drag draws it; at rest, plain. */ look?: LinkLook | undefined; /** The family it is drawn in, by its resource: what its weight is a share of (A66). */ family: string; } /** Every link of the day, by its bin and then its resource: its identity in the layer. */ export type LinkIds = ReadonlyMap>; /** * Every link of the day, numbered once — its bins by time, each bin's parts * largest first — so a link keeps its identity in the layer, and the grip the * layer draws for it, whichever family it is drawn in: a drag that starts on a * focus's link goes on drawing it as the drag's (A69). * * @param plan - The day as drafted * @returns Each link's id, by its bin and its resource */ export declare function linkIds(plan: Day): LinkIds; /** * The focus's family (A65, A72): every bin with a part on the focus, by time, * and each of its parts — a split bin shows a link to each of its resources. * * @param plan - The day as drafted * @param held - The day as the record holds it * @param focus - The focus's resource * @param ids - Every link's identity: the day's own by default * @returns The links, in drawing order */ export declare function familyOf(plan: Day, held: Day | undefined, focus: string, ids?: LinkIds): FamilyLink[]; /** * The links the runs of the optimiser added or changed (#1409), for the * highlight: each bin's touched parts, the bins by time and each bin's parts * largest first, every one a draft in the Elara look, weighed in its * resource's family. * * @param plan - The day as drafted * @param touched - The parts the runs added or changed, by bin: the kilns * @param ids - Every link's identity * @returns The links, in drawing order; none of a bin the day no longer holds */ export declare function runLinks(plan: Day, touched: ReadonlyMap>, ids: LinkIds): FamilyLink[]; /** A link a drag moves: its bin's part on a resource. */ export interface MovedLink { bin: string; resource: string; } /** Where a drag rests, for its links: a resource other than the dragged bin's, and the drop's verdict there — `undefined` while the fit's answer is on its way. */ export interface DragTarget { resource: string; verdict: "fits" | "refused" | undefined; } /** * The links a drag draws in the focus's place (A65): the dragged bin's * resource's family, the link it moves faded to its `was` line (A69), and the * family of the resource the drag rests on, its links there in the drop's * verdict — ink-2 where it fits, warn where it refuses; a draft link keeps its * brand — as the mock draws them: the plain ones first, then the target's, the * `was` line over them all. A link in both families is drawn once. * * @param plan - The day as drafted * @param held - The day as the record holds it * @param ids - Every link's identity * @param current - The dragged bin's resource; `undefined` for a drag of no bin's (a Library card) * @param moved - The link the drag moves, if it moves one * @param target - The resource the drag rests on, if it is not `current`, and the verdict there * @returns The links, in drawing order */ export declare function dragFamilies(plan: Day, held: Day | undefined, ids: LinkIds, current: string | undefined, moved: MovedLink | undefined, target: DragTarget | undefined): FamilyLink[]; /** Where the links run: the layer's px, as the panes stand. */ export interface LinkView { /** The lane grid's left edge: where its hour column starts. */ gridLeft: number; /** The link channel's right edge: every resource row's leading edge. */ channelRight: number; /** The panes' view under their heads, its height. */ height: number; /** How far the lane grid and the resource rows have scrolled. */ laneTop: number; rowsTop: number; } /** A bin's card, in the layer's px, as its lane grid has scrolled. */ export declare function cardEnd(card: LaneCard, view: LinkView): RibbonEnd; /** * Routes the links (A66): each from its card to its row, weighted by its * share of its family's largest quantity, its caption its quantity; in a * drag's families (A65) the link it moves carries no tone of its own, a draft * keeps the brand's, and a link into the target takes the verdict's; a run's * link takes the Elara tone over its draft's (#1409). * * @param family - The links * @param cards - Each bin's card, by bin * @param rows - Each shown resource row's index, by key: a link to a row the narrowing hides is not drawn * @param view - Where the links run * @param label - A link's caption * @param selected - The selected link: drawn a px heavier, in the ink * @returns The routed links */ export declare function layoutLinks(family: readonly FamilyLink[], cards: ReadonlyMap, rows: ReadonlyMap, view: LinkView, label: (link: FamilyLink) => string | undefined, selected?: number | undefined): (LinkRibbon & { link: FamilyLink; })[]; /** * A link drag's new line (A69), as the mock draws it: out of its card's right * edge level with the card's middle, to the riser — the links' own, * `RIBBON_RISER` before the rows' edge, once the pointer is past it, else * halfway to the pointer — up or down to the pointer, and on into a head 9 * long and 12 across at the pointer. Nothing while the pointer is within 16px * of the card, or outside the panes under their head. * * @param from - The dragged bin's card, in the layer's px (`cardEnd`) * @param x - The pointer, across the layer * @param y - The pointer, down the layer * @param view - Where the links run * @returns The line, or `undefined` while it has nowhere to go */ export declare function dragLine(from: RibbonEnd, x: number, y: number, view: Pick): LinkLine | undefined; /** * The thin lines from the pointer into the three best fits' rows while an * arrival is dragged over the lane grid (A30): each Plan's metro-S out of the * pointer to its row's leading edge, 1.5 wide, or its stub toward a row out of * the rows' view; none once the pointer is within 12px of the riser or outside * the panes under their head, and none into a row the narrowing hides. * * @param x - The pointer, across the layer * @param y - The pointer, down the layer * @param ranks - The three best fits, best first * @param rows - Each shown resource row's index, by key * @param view - Where the links run * @returns The lines, best first */ export declare function guideLines(x: number, y: number, ranks: readonly string[], rows: ReadonlyMap, view: LinkView): LinkLine[]; //# sourceMappingURL=links.d.ts.map