/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ import { type ValueTypeOf, type option } from "@elaraai/east"; import type { Flowchart } from "@elaraai/e3-ui/internal"; import type { RecordSliceBindType } from "@elaraai/east-ui/internal"; import { type Formatters } from "@elaraai/east-ui-components"; import { type KindKeys } from "../shared/schedule/kind-keys.js"; import type { FlowchartModel, FlowchartValue } from "./model.js"; /** A kind's details, decoded: each read described, and its rows' values. */ export type FlowchartDetailsValue = ValueTypeOf; /** One read, described. */ export type FlowchartReadValue = ValueTypeOf; /** A details row's values: one a read, in the reads' order. */ export type FlowchartDetailRowValue = ValueTypeOf; /** A histogram's value in a row: its counts, each at the lower edge of the bin it counts. */ type HistogramValue = Extract["value"]; /** A list's value in a row: its items, by name. */ type ListValue = Extract["value"]; /** A tags read's looks: each a tag's, first defined, first shown. */ export type FlowchartTagColors = Extract["value"]["colors"]; /** How the rail's picks weigh a kind's details, as the payload gives it (#1522). */ export type FlowchartWeighedValue = ValueTypeOf; /** A source's part of the rail: its record Slice's controls, as the payload's chrome carries them. */ export type FlowchartSlicePart = ValueTypeOf; /** The kinds that carry details. */ export type FlowchartDetailsSort = "states" | "transitions"; /** A kind carrying details, as the payload gives it. */ export interface FlowchartDetailsKind { /** Its name: what Issues names its refused bins by. */ readonly name: string; /** Its details. */ readonly details: FlowchartDetailsValue; /** Its keys (#1549): the details, keyed as the kind is, are asked by each key's text read back at its key type; String's by default. */ readonly keys?: KindKeys | undefined; /** The rail's part whose picks weigh them (#1522); `undefined` for details none weighs. */ readonly weighing?: FlowchartSlicePart | undefined; } /** The kinds carrying details: `undefined` for a kind with none. */ export interface FlowchartDetailsKinds { /** The states'. */ readonly states: FlowchartDetailsKind | undefined; /** The transitions'. */ readonly transitions: FlowchartDetailsKind | undefined; } /** * The kinds carrying details, from the payload. * * @param value - The payload * @returns Each kind's name, details and keys, where it has some */ export declare function detailsKindsOf(value: FlowchartValue): FlowchartDetailsKinds; /** The keys of the rows the canvas draws, by kind, each in their keys' order at its key type: what the details are matched to, and asked by. */ export interface FlowchartDrawnKeys { /** The states drawn: a ghost stands for no row, so none of them. */ readonly states: readonly string[]; /** The transitions drawn: those routed, and those in place, drawn as their state's `↻ n`. */ readonly transitions: readonly string[]; } /** * The keys of the rows a model draws (R19): what the details are asked by. * * @param model - What the canvas draws, the drafts in place * @returns Each kind's keys, in their keys' order at its key type (#1549) */ export declare function drawnKeysOf(model: FlowchartModel): FlowchartDrawnKeys; /** * The keys of the rows a model draws, the same object while they are the same: * a draft or a page landing moves the model, and seldom the keys it draws. * * @param model - What the canvas draws * @returns Each kind's keys */ export declare function useDrawnKeys(model: FlowchartModel): FlowchartDrawnKeys; /** Each key's row, as bytes at the details' row type — `null` for a key the details hold no row of. */ export type FlowchartDetailBytes = ReadonlyMap; /** * How the details are read by key, beside a kind read through its source * (R19): the rows of the keys asked, every key in one request, each key's text * read back at the kind's key type (#1549) — `none` while in flight. Throws * the read's failure. */ export type FlowchartPagedRows = (paged: string, keys: readonly string[], keyed: KindKeys) => option; /** * The details read by key through the paged read named (R19): * `defaultPagedRuntime.rowsAll` over the keys asked, one request and one * channel, each row encoded back at the Dict's row type, as the details' * `values` reads it. * * @param paged - The paged read's handle id * @param keys - The keys of the rows drawn, as their texts * @param keyed - The kind's keys, which the details are keyed as: a text no key prints as holds no row * @returns Each key's row's bytes — `null` for none — once every one is known; `none` while in flight * @throws {Error} Naming the read, where `Data.bindPaged` has bound no handle of its id; the read's failure, until a read * after the retry gap asks again */ export declare const pagedDetailRows: FlowchartPagedRows; /** * A weighed kind's rows, as one read found them (#1522): each drawn key's row * as bytes — `null` for a key the details hold no row of — the rows * themselves, which the source's other fields are asked of, and each row's * picked entries as bytes, each an entry's value, in the entries' key order. */ export interface FlowchartWeighedBytes { /** Each drawn key's lean row's bytes: the row with the Dict field the entries index files emptied. */ readonly rows: FlowchartDetailBytes; /** Each drawn key's lean row, by key: what a membership read asks of the source's other fields. */ readonly lean: ReadonlyMap; /** Each drawn row's picked entries' bytes, by key — a row holding none of the picks absent. */ readonly entries: ReadonlyMap; } /** * How weighed details are read by key (#1522, R44): the drawn rows through * their entries index's lean rows, each key's text read back at the kind's key * type (#1549), and the picked keys' ranges of the index, each kept to the rows * drawn — `none` while in flight. Throws the read's failure. */ export type FlowchartWeighedRows = (paged: string, weighed: FlowchartWeighedValue, picks: readonly string[], keys: readonly string[], keyed: KindKeys) => option; /** * The weighed details read through the binding they name (#1522, R44): the * drawn keys searched in the entries index's lean rows and the picked keys in * the index, in one request each, then the rows found and the picked keys' * ranges read, in one request each — so a pick reads its ranges, and the rows * by key, and never the record's own rows. Each entry is kept to the rows * drawn, a row's in the entries' key order. * * @param paged - The binding's id * @param weighed - How the picks weigh the details * @param picks - The picked keys, as `.east` literals of the Dict's keys * @param keys - The keys of the rows drawn, as their texts, in their keys' order * @param keyed - The kind's keys, which the details are keyed as: a text no key prints as holds no row * @returns The rows, and their picked entries, once every one is known; `none` while in flight * @throws {Error} Naming the read, where `Data.bindPaged` has bound no binding of its id, or one listing no such entries * index; the read's failure, until a read after the retry gap asks again */ export declare const weighedDetailRows: FlowchartWeighedRows; /** * A Retry of the details (R34): each kind's paged read asked again what failed * of it, at once — not after the retry gap a read alone waits — as a Retry * asks a source of the rail (`defaultPagedRuntime.askAgain`). A kind read * whole is read again as the read's attempt moves; one weighed by the rail's * picks asks its binding's record again (#1522). * * @param kinds - The kinds carrying details */ export declare function askDetailsAgain(kinds: FlowchartDetailsKinds): void; /** * How the rail's picks weigh one kind's details (#1522): the picks as they * stand, and the rows holding them as the last settled read found them. */ export interface FlowchartWeighedRead { /** The picks, as `.east` literals of the Dict's keys: none, and every read draws the row's own. */ readonly picks: readonly string[]; /** The drawn rows holding a pick, as the last settled read found them: a row holding none says *no data* in the reads the picks weigh. */ readonly holding: ReadonlySet; /** Whether the rail's source narrows another record than the details read: Issues lists it, and every read draws the row's own. */ readonly apart: boolean; /** Whether the picks moved since the last settled read and their ranges are in flight: the reads they weigh draw their placeholder (R44). */ readonly pending: boolean; } /** What the details read holds of one kind. */ export interface FlowchartDetailsRead { /** * Each drawn row's values the last settled read holds, by key — `null` for a key the details hold no row of, which * draws *no data* (R33). A key no settled read asked of is absent: its card draws a placeholder (R34). */ readonly rows: ReadonlyMap; /** Whether a read is in flight, the last settled one standing in meanwhile. */ readonly reading: boolean; /** Why the latest read failed, said once in the canvas's box (R34); what the last settled read held stands. */ readonly error: string | undefined; /** How the rail's picks weigh them, as the last settled read found it (#1522); `undefined` for details none weighs. */ readonly weighed?: FlowchartWeighedRead | undefined; } /** What the details read holds, by kind: `undefined` for a kind with no details. */ export interface FlowchartDetailsData { /** The states' details. */ readonly states: FlowchartDetailsRead | undefined; /** The transitions' details. */ readonly transitions: FlowchartDetailsRead | undefined; } /** The frame's details before the reader first reports: every kind's in flight. */ export declare const NO_DETAILS: FlowchartDetailsData; /** * Reads the details (see the module docs): each kind's beside its kind, by the * rows drawn. * * @param kinds - The kinds carrying details * @param drawn - The keys of the rows drawn * @param attempt - Moves to read every kind afresh: a Retry * @param paged - How a paged read answers keys: `pagedDetailRows`, unless a test gives its own * @param weighedRows - How weighed details are read by key: `weighedDetailRows`, unless a test gives its own * @returns What the details read holds */ export declare function useFlowchartDetails(kinds: FlowchartDetailsKinds, drawn: FlowchartDrawnKeys, attempt?: number, paged?: FlowchartPagedRows, weighedRows?: FlowchartWeighedRows): FlowchartDetailsData; /** * The details' reads, in a component of their own, as the records' are * (`read.ts`): each read that lands renders it again alone, and it hands the * frame what it read only when that moves. * * @param props - The kinds carrying details, the keys of the rows drawn, the read's attempt, and where the details go * @returns Nothing: it reads */ export declare function FlowchartDetailsReader({ kinds, drawn, attempt, onDetails }: { kinds: FlowchartDetailsKinds; drawn: FlowchartDrawnKeys; attempt: number; onDetails: (details: FlowchartDetailsData) => void; }): null; /** A histogram read's bins, shared by every card that draws it (R26). */ export interface FlowchartBins { /** * Its edges, ascending and finite: the app's, else every drawn row's edges merged — none while no row counts * anything. Each bin reaches from its edge to the next; the last is open. */ readonly edges: readonly number[]; /** How its bars space them. */ readonly scale: "band" | "linear"; } /** A histogram's counts in the flowchart's bins (R27). */ export interface FlowchartBinCounts { /** Each bin's count, in the bins' order. */ readonly counts: readonly number[]; /** What they count, together. */ readonly total: number; /** Whether a count fell in no bin: one at no edge, or one that is no count — negative, or not finite. */ readonly unheld: boolean; } /** Why the bins the app binds are refused (R27), as found. */ export type FlowchartBinsRefusal = { readonly why: "empty"; } | { readonly why: "number"; readonly edge: number; } | { readonly why: "order"; readonly before: number; readonly after: number; }; /** Why, in the app's locale: what Issues says. */ export type FlowchartBinsRefusalWord = { readonly why: "empty"; } | { readonly why: "number"; readonly edge: string; } | { readonly why: "order"; readonly before: string; readonly after: string; }; /** * The bins the app binds, checked as they land (R27) — as a literal's are * when built. * * @param edges - The edges * @returns Why they are refused — none given, an edge that is no finite number, or the first two that do not ascend; `undefined` for none */ export declare function binsRefusal(edges: readonly number[]): FlowchartBinsRefusal | undefined; /** * A row's histogram counted into the flowchart's bins (R27): each count in the * bin that holds its edge, one under the first edge in the first — an Array's * each at its own bin's edge, so a bin each. * * @param value - The row's histogram: its counts, each at an edge * @param edges - The flowchart's bins' edges, ascending * @returns Each bin's count, their total, and whether a count fell in no bin */ export declare function countIntoBins(value: HistogramValue, edges: readonly number[]): FlowchartBinCounts; /** One bar, across its axis: where it starts and ends, and how tall it is — each a share of the axis and of the card's tallest bar. */ export interface FlowchartBar { /** Where it starts, from 0 at the axis's start to 1 at its end. */ readonly from: number; /** Where it ends. */ readonly to: number; /** How tall it is, the card's tallest 1. */ readonly height: number; /** What it counts. */ readonly count: number; } /** * A card's bars over the flowchart's bins (R26): on a band axis a bar a bin, * equal widths, as tall as its count; on a linear axis each as wide as its span * and as tall as its count over it, so its area is its count, the open last * bin as wide as the one before it. Scaled to the card's tallest. * * @param bins - The flowchart's bins * @param counts - The card's count in each * @returns Each bin's bar, in order */ export declare function barsOf(bins: FlowchartBins, counts: readonly number[]): FlowchartBar[]; /** * Where a duration sits across the axis (R26, R28): on a band axis, as far * across its bin as it is across its span — the open last bin as wide as the * one before it; on a linear axis, to scale. Under the first edge, the axis's * start; past the end, the end. * * @param bins - The flowchart's bins * @param at - The duration * @returns Its place, from 0 at the axis's start to 1 at its end */ export declare function axisAt(bins: FlowchartBins, at: number): number; /** One row's details: its values, one a read, and each histogram's counts in the flowchart's bins. */ export interface FlowchartRowDetails { /** Its values, one a read, in the reads' order. */ readonly values: FlowchartDetailRowValue; /** Each read's counts, by its place: a histogram's in its bins; `undefined` where its bins are refused, and for every other read. */ readonly counts: readonly (FlowchartBinCounts | undefined)[]; /** Whether each read says *no data*, by its place: one the rail's picks weigh, of a row holding none of them (#1522, R45). */ readonly noData: readonly boolean[]; /** Whether each read draws its placeholder, by its place: one the rail's picks weigh, while the ranges of picks that moved are in flight (#1522, R44). */ readonly pending: readonly boolean[]; } /** * A row's value at a read, as the canvas, a label and the inspector draw it: * `undefined` where it says *no data* — a read the rail's picks weigh, of a * row holding none of them (#1522, R45) — and where it waits on picks that * moved (R44). * * @param row - The row's details * @param index - The read's place * @returns Its value; `undefined` for *no data*, and while it waits */ export declare function valueAt(row: FlowchartRowDetails | undefined, index: number): FlowchartDetailRowValue[number] | undefined; /** * Whether a row's read draws its placeholder: its row not landed (R34), or a * read the rail's picks weigh while the ranges of picks that moved are in * flight (#1522, R44). * * @param row - The row's details; `undefined` while it lands * @param index - The read's place * @returns Whether it waits */ export declare function waitsAt(row: FlowchartRowDetails | undefined, index: number): boolean; /** The line the inspector names the rail's picks in (#1522, R46): the field, as the rail names it, and the picks. */ export interface FlowchartWeighedLine { /** The field, as the rail labels it — `Service`. */ readonly label: string; /** The picks, as the rail names them — `Standard, Priority`. */ readonly picks: string; } /** One kind's details, as the canvas, the inspector and Issues draw them. */ export interface FlowchartKindDetails { /** Its reads, in the details' order: each described, and where it shows. */ readonly reads: FlowchartDetailsValue["reads"]; /** Whether a read shows on the canvas: a state's card is then 272 wide, its reads under its head (R22). */ readonly onCanvas: boolean; /** Each read's bins, by its place: a histogram's; `undefined` for one whose bins the app binds are refused, and for every other read. */ readonly bins: readonly (FlowchartBins | undefined)[]; /** Each drawn row's details, by key: `null` for a key the details hold no row of; a key absent has not landed. */ readonly rows: ReadonlyMap; /** Whether a read is in flight. */ readonly reading: boolean; /** Why the latest read failed. */ readonly error: string | undefined; /** The rail's picks that weigh them, as the inspector names them (#1522, R46); `undefined` with no pick, and for details none weighs. */ readonly weighedBy: FlowchartWeighedLine | undefined; } /** What Issues lists of the details (R38). */ export type FlowchartDetailsFinding = /** A row's histogram holding counts no bin holds, by the row's kind and key and the read's label. */ { readonly finding: "counts"; readonly sort: FlowchartDetailsSort; readonly key: string; readonly read: string; } /** A histogram's bins, as the app binds them, refused: by the kind's name and the read's label, and why. */ | { readonly finding: "bins"; readonly sort: FlowchartDetailsSort; readonly kind: string; readonly read: string; readonly refusal: FlowchartBinsRefusalWord; } /** The rail's source whose picks weigh a kind's details narrowing another record than they read (#1522): by the kind's name and the source. */ | { readonly finding: "weighed"; readonly sort: FlowchartDetailsSort; readonly kind: string; readonly source: string; }; /** The details model: each kind's, and what Issues lists. */ export interface FlowchartDetailsModel { /** The states' details; `undefined` for states with none. */ readonly states: FlowchartKindDetails | undefined; /** The transitions' details. */ readonly transitions: FlowchartKindDetails | undefined; /** What Issues lists: each kind's refused bins, in the reads' order, then its rows' counts no bin holds, in key order. */ readonly findings: readonly FlowchartDetailsFinding[]; } /** * The details model (see the module docs): each kind's reads, its * histograms' bins, each drawn row's values counted into them, and what Issues * lists. Pure. * * @param kinds - The kinds carrying details * @param data - What the details read holds * @param drawn - The keys of the rows drawn * @param words - The formatters: Issues' numbers in the app's locale * @returns The model */ export declare function flowchartDetailsModel(kinds: FlowchartDetailsKinds, data: FlowchartDetailsData, drawn: FlowchartDrawnKeys, words: Formatters): FlowchartDetailsModel; /** A card's width where its details draw on it (R22): 116 without. */ export declare const DETAILS_CARD_W = 272; /** What the reads draw across: the card inside its edges and its padding — a card's bars and their axis span it. */ export declare const DETAILS_INNER_W: number; /** The card's head with its top edge and the rule under it: where an editor renaming the state sits. */ export declare const DETAILS_HEAD_H: number; /** How wide a card's words draw, in px: a read's label in a tag list's label column, and a tag — its padding and rule in. */ export interface FlowchartTextMeasure { /** A read's label, as the label column draws it. */ readonly label: (text: string) => number; /** A tag, as a card draws it — and the +n that ends a list cut short. */ readonly tag: (text: string) => number; } /** The estimate where nothing measures — a test's, or a layout before the card draws: the visual spec's type, a character at a time. */ export declare const ESTIMATED_TEXT: FlowchartTextMeasure; /** One line of a card's list (R29): an item, its share of the list's total, and its note. */ export interface FlowchartListLine { /** The item's name. */ readonly name: string; /** Its value. */ readonly value: number; /** Its share of the list's total, 0 to 1. */ readonly share: number; /** Its note, from its draw. */ readonly note: string | undefined; } /** What a card draws of one read. */ export type FlowchartCardDraws = /** Its row has not landed: a placeholder (R34). */ { readonly kind: "placeholder"; } /** No row, or nothing to show: *no data* (R33, R41). */ | { readonly kind: "noData"; } /** A figure's value. */ | { readonly kind: "figure"; readonly value: number; } /** A tag list's lines — none: *none* — and the tags past its third, behind +n. */ | { readonly kind: "tags"; readonly lines: readonly (readonly string[])[]; readonly rest: readonly string[]; } /** A histogram's bars. */ | { readonly kind: "bars"; readonly bars: readonly FlowchartBar[]; } /** A list's top lines — none: *none*. */ | { readonly kind: "list"; readonly lines: readonly FlowchartListLine[]; }; /** One read a card shows, in its block. */ export interface FlowchartCardRead { /** Its place in the details' order. */ readonly index: number; /** Its block's top, from the card's. */ readonly top: number; /** Its block's height. */ readonly height: number; /** A tag list's label column, the widest label of the tag lists it stands among; `undefined` for any other read. */ readonly column: number | undefined; /** What it draws. */ readonly draws: FlowchartCardDraws; } /** A state's card where its details draw (R22): its size, and each read it shows in its block. */ export interface FlowchartCard { /** Its width. */ readonly width: number; /** Its height: its head, a rule, then its reads 12 apart inside 12 of padding. */ readonly height: number; /** The reads it shows, in the details' order. */ readonly reads: readonly FlowchartCardRead[]; } /** * A list's lines on the canvas, as its read gives them (R29): 1 to 3. * * @param read - The list read * @returns How many lines it draws on a card or a label */ export declare function listTopOf(read: Extract["value"]): number; /** * A list's top lines by value (R29): its items by value, highest first — ties * in the row's order — each with its share of the list's total. * * @param items - The row's items * @param top - How many lines * @returns The lines */ export declare function listLines(items: ListValue, top: number): FlowchartListLine[]; /** * A row's tags in the order their looks are defined, then the rest in the * row's order (R30): each once — as a card, the inspector and the legend show * them. * * @param colors - The read's looks * @param tags - The row's tags * @returns The tags, in that order */ export declare function orderedTags(colors: FlowchartTagColors, tags: readonly string[]): string[]; /** * A state's card where its details draw (R22, §4): each read it shows, in the * details' order, in its block — a placeholder while its row lands, drawn as * full, *no data* for no row — and its size from them: 272 wide; its head, a * rule, then the blocks 12 apart inside 12 of padding. * * @param kind - The states' details * @param key - The state's key * @param measure - How wide its words draw: measured where the card draws, else {@link ESTIMATED_TEXT} * @returns The card; `undefined` where no read shows on the canvas, and the card is today's */ export declare function detailsCardOf(kind: FlowchartKindDetails, key: string, measure?: FlowchartTextMeasure): FlowchartCard | undefined; /** One line under a transition label's evidence (R32). */ export type FlowchartLabelLine = /** Its row has not landed: a placeholder, a line high (R34). */ { readonly kind: "placeholder"; } /** A figure: its label, its value — `undefined` where the row lacks it, *no data* — and its unit (R25). */ | { readonly kind: "figure"; readonly label: string; readonly value: number | undefined; readonly unit: string | undefined; } /** One of a list's top items: its name, and its share of the list's total (R29). */ | { readonly kind: "item"; readonly name: string; readonly share: number; } /** A list with no items: *none*. */ | { readonly kind: "none"; } /** A list the rail's picks weigh, of a row holding none of them: its label, and *no data* (#1522, R45). */ | { readonly kind: "noData"; readonly label: string; }; /** * A transition label's lines under its evidence (R32): each read it shows on * the canvas, in the details' order — a figure a line, a list its top items by * value, or *none* — no line for a row there is none of, which keeps its * evidence line alone (R33), and while the row lands each read's lines as * placeholders, so the label is as tall as it will be (R34). The build refuses * tags and histograms on a label, and lines past three (R21). * * @param kind - The transitions' details * @param key - The transition's key * @returns Its lines, in order; none where no read shows on the canvas */ export declare function detailsLabelOf(kind: FlowchartKindDetails, key: string): FlowchartLabelLine[]; export {}; //# sourceMappingURL=details.d.ts.map