/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ /** * Pure derived-model helpers for the Schematic renderer (#183 WS3): the * navigator tree (zones nest by containment, items live in their smallest * outline host), the semantic-zoom LOD machinery (per-item tier sizing — * no card or pin wider than {@link SCHEMATIC_CARD_MAX_PX} — the centre * R-tree, and the symmetric neighbour-fit declutter) and the box the * narrowing's matches span (#1392). React-free data-in / data-out — * unit-tested in `model.test.ts`. */ import RBush from "rbush"; import { type DrawnItem as SchematicItemValue, type DrawnZone as SchematicZoneValue, type SchematicDrawn } from "./drawn"; export interface NavZone { zone: SchematicZoneValue; children: NavZone[]; items: SchematicItemValue[]; } /** * Labels in natural order — `A2` before `A10`, `Cage 2` before `Cage 10` — as * the Index lists zones and items and the steps walk them. * * @param a - One labelled entity * @param b - Another * @returns Below zero where `a`'s label comes first, above where `b`'s does, else zero */ export declare function byLabel(a: { readonly label: string; }, b: { readonly label: string; }): number; /** * The zones that host items, smallest first: the outline zones — a hatched * one is an annotation (an aisle, an exclusion zone), never a container. * * @param zones - The zones * @returns The hosts, by their boxes' areas, smallest first */ export declare function hostZones(zones: readonly SchematicZoneValue[]): SchematicZoneValue[]; /** * The zone an item at a world point is filed under: the smallest host whose * box holds the point — the Index's, and the zone a drop's words say a card * lands in (#1390). * * @param hosts - The hosts, smallest first ({@link hostZones}) * @param x - The point's world x * @param y - The point's world y * @returns The zone, or `undefined` for a point no host holds */ export declare function zoneHolding(hosts: readonly SchematicZoneValue[], x: number, y: number): SchematicZoneValue | undefined; /** Nest zones by smallest-containing-rect and place items into their * smallest containing zone — the drawing IS the hierarchy. Hatch zones * are annotations (aisles, exclusion zones), not containers: they * never host items. */ export declare function buildNavTree(zones: readonly SchematicZoneValue[], items: readonly SchematicItemValue[]): { roots: NavZone[]; floor: SchematicItemValue[]; zoneOf: Map; parentOf: Map; }; export type LodTier = "card" | "label" | "dot"; /** * The widest an item's card or labelled pin draws, in screen px, whatever its * words (#1393): a longer label, sublabel or figure ends in an ellipsis. A card * drawn at its item's own width — its `width` role, a box in the world — is * held to that instead. Past the viewport a card reaches no more than half of * it, which is what a kind read by area pads its window by (`area.ts`). */ export declare const SCHEMATIC_CARD_MAX_PX = 200; /** A labelled pin's parts, in screen px (#1393): its inline padding, its dot's width, the gap after the dot, and its height. */ export declare const PIN_PAD_X = 6, PIN_DOT_W = 7, PIN_GAP = 4, PIN_H = 16; /** How far a labelled pin starts before its item's point, in screen px: its dot stands on the point, the words after it (#1393). */ export declare const PIN_LEAD_PX: number; /** * The width a card takes for its words, in screen px (#1393): its label with * its icon and its dot beside it, or its sublabel, whichever is wider — no * narrower than a card's least and no wider than * {@link SCHEMATIC_CARD_MAX_PX}. * * @param item - The item * @returns Its card's width for its words */ export declare function cardContentWidth(item: SchematicItemValue): number; /** * Whether an item's card draws whole at a zoom (#1393): a card held to its * item's own width — a box in the world — draws whole once that width holds * its words; any other card is as wide as its words. A zoom worked out to draw * it whole — the zoom's limit, a fly to it — draws it whole, its float error * among it. * * @param item - The item * @param ppu - The zoom, in px per world unit * @returns Whether its card draws whole */ export declare function cardWhole(item: SchematicItemValue, ppu: number): boolean; /** Screen-px footprint of an item rendered at `tier` — a card or a labelled pin, no wider than * {@link SCHEMATIC_CARD_MAX_PX}, but a card at its item's own width. A card is centred on its item; a pin's dot stands * on it, its words after ({@link PIN_LEAD_PX}). Translation-invariant, so collisions depend on ppu alone. */ export declare function tierSize(item: SchematicItemValue, tier: LodTier, ppu: number): { w: number; h: number; }; /** An item by its centre in the world: what the declutter searches an item's neighbours in. */ export type CenterBox = { minX: number; minY: number; maxX: number; maxY: number; item: SchematicItemValue; }; /** World-coordinate R-tree over item centres — built over every item drawn, so an item's neighbours past the viewport * count too; zooming only changes the (1/ppu-scaled) query boxes. */ export declare function buildCenterTree(items: readonly SchematicItemValue[]): RBush; /** * Each visible item's tier at the zoom (#1393): a card, a labelled pin or a * dot. The zoom's band picks the richest form an item may take, and it takes * it only where it draws whole and clear of the items about it — decided from * where every item drawn stands, never from the order they come in nor which * of them the viewport holds, so a pan never changes what an item draws as, * and a uniformly dense row draws as one block rather than checkerboarding: * * - **a card** where the band is the card's and it draws whole * ({@link cardWhole}), clear of every other item's dot and of every other * card that could draw; * - **else a pin** where the band reaches the pin's, clear of every other * item's mark — the card it draws as, or its dot — and of every other pin * that could draw: no pin covers another item's status; * - **else a dot.** * * A selected item is an explicit pointer: it takes the richest form the band * gives that draws whole, whatever it covers. * * @param items - The items to decide: the viewport's * @param tree - Every item drawn, by its centre ({@link buildCenterTree}): what an item keeps clear of * @param baseLod - The zoom's band * @param ppu - The zoom, in px per world unit * @param selected - What is selected, by id * @returns Each item's tier, by its id */ export declare function declutterTiers(items: readonly SchematicItemValue[], tree: RBush, baseLod: LodTier, ppu: number, selected: ReadonlySet): Map; /** A world box: its least and its greatest corner. */ export interface WorldBox { minX: number; minY: number; maxX: number; maxY: number; } /** * The world box the narrowing's matches span (#1392, §10.3): each matched * item drawn — by its centre grown by `reach`, and by its footprint about it * (D22) — each matched zone's box and its shape about the box's centre, and * each matched link's or net's members drawn and its bends. What the frame * boxes, and what fit flies to. * * @param drawn - What the canvas draws: its items where a Move's preview has them, a hidden layer's left out * @param matches - The matches, by id * @param hidden - What a hidden layer holds, by id: never drawn, so spanning nothing * @param centers - Each item drawn's centre, by id * @param reach - An item's half-extent about its centre, in world units * @returns The box, and how many matches it spans; `undefined` while none is drawn */ export declare function matchesExtent(drawn: SchematicDrawn, matches: ReadonlySet, hidden: ReadonlySet, centers: ReadonlyMap, reach: (item: SchematicItemValue) => { readonly w: number; readonly h: number; }): { box: WorldBox; count: number; } | undefined; //# sourceMappingURL=model.d.ts.map