import type { ReactNode } from "react"; /** * The data layer for `Matrix` — axis types + the cross-tab aggregation. Its own * module so it unit-tests directly, and so a consumer can drive a KPI off the * same `matrixTotals` the grid shows. */ export interface MatrixAxisItem { key: string; label: string; /** An identity mark before the label. ROWS ONLY — a column is a period or a * category and has no identity to carry, so `Matrix.Header` ignores this. The * mark is drawn INSIDE `rowLabelWidth`. */ leading?: ReactNode; } /** The inspected cell — host renders its detail (a filtered list) underneath. */ export interface MatrixCellRef { row: string; col: string; } export interface MatrixTotalsResult { rowTotals: Map; colTotals: Map; grandTotal: number; /** The largest single cell — the heat scale's upper bound. */ max: number; } /** How a cell's value becomes ink. See `matrixHeatScale`. */ export type MatrixHeatScale = "linear" | "rank"; export interface MatrixHeatScaleResult { /** The alpha this scale paints a cell with. Zero (and below) paints nothing. */ alpha: (value: number) => number; /** The legend's swatches — the SAME alphas, sampled across the painted set. */ legend: number[]; } /** * Value → ink, and the legend that explains it, from ONE expression. * * `linear` maps a cell onto the band by its share of the largest cell, which is * honest only when the values are spread. `rank` maps a cell by its POSITION * among the DISTINCT values painted, so the smallest always lands on `lo`, the * largest on `hi`, and equal cells keep equal ink. * * The legend is SAMPLED from that same function rather than restated, so it can * never paint a shade the grid cannot reach. */ export declare function matrixHeatScale(values: number[], scale: MatrixHeatScale, band: [number, number]): MatrixHeatScaleResult; /** * Row sums, column sums, grand total, and the max single cell — computed in one * pass. The single source of truth for the matrix's totals. */ export declare function matrixTotals(rows: MatrixAxisItem[], cols: MatrixAxisItem[], value: (row: string, col: string) => number): MatrixTotalsResult;