vizmatic 0.7.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  prepareScene,
9
9
  sceneSha256,
10
10
  validateResolvedSceneResources
11
- } from "./chunk-4XE64I2U.js";
11
+ } from "./chunk-DZHX76RS.js";
12
12
  import {
13
13
  CANVAS_CHART_COMPONENT,
14
14
  CHART_FRAME_COMPONENT,
@@ -18,6 +18,8 @@ import {
18
18
  Watermark,
19
19
  addSvgAccessibility,
20
20
  analyzeAnimationCadence,
21
+ chartAccessibilityAttributes,
22
+ chartDescription,
21
23
  convertIndexedToRgb,
22
24
  cropPixels,
23
25
  decodePng,
@@ -51,7 +53,7 @@ import {
51
53
  withRenderContext,
52
54
  wrapWithBrand,
53
55
  wrapWithWatermark
54
- } from "./chunk-CJOXWJQA.js";
56
+ } from "./chunk-DTD35LPT.js";
55
57
  import {
56
58
  DEFAULT_DENSITY,
57
59
  DENSITY_NAMES,
@@ -122,6 +124,7 @@ __export(primitives_exports, {
122
124
  DonutChart: () => DonutChart,
123
125
  DotPoint: () => DotPoint,
124
126
  ELEMENT_SYMBOLS: () => ELEMENT_SYMBOLS,
127
+ EntityRelationshipDiagram: () => EntityRelationshipDiagram,
125
128
  EquationCard: () => EquationCard,
126
129
  FactRows: () => FactRows,
127
130
  Flow: () => Flow,
@@ -1809,7 +1812,8 @@ function Sparkline({
1809
1812
  endDot = true,
1810
1813
  min,
1811
1814
  max,
1812
- strokeWidth
1815
+ strokeWidth,
1816
+ ...accessibility
1813
1817
  }) {
1814
1818
  const d = densityOf(c);
1815
1819
  const w = width ?? d.f(72);
@@ -1824,7 +1828,7 @@ function Sparkline({
1824
1828
  const y = (value) => inset + (1 - (value - low) / range) * (h - inset * 2);
1825
1829
  const path = values.map((value, index) => `${index === 0 ? "M" : "L"} ${x(index).toFixed(2)} ${y(value).toFixed(2)}`).join(" ");
1826
1830
  const last = values.length - 1;
1827
- return React4.createElement(
1831
+ const chart = React4.createElement(
1828
1832
  "svg",
1829
1833
  {
1830
1834
  width: w,
@@ -1857,6 +1861,15 @@ function Sparkline({
1857
1861
  })
1858
1862
  ])
1859
1863
  );
1864
+ if (!accessibility.ariaLabel && !accessibility.description) return chart;
1865
+ return React4.createElement("div", {
1866
+ ...chartAccessibilityAttributes({
1867
+ ...accessibility,
1868
+ ariaLabel: accessibility.ariaLabel ?? "Sparkline",
1869
+ description: chartDescription(accessibility.description, values.map((value, index) => `Point ${index + 1}: ${value}`))
1870
+ }),
1871
+ style: { display: "flex", width: w, height: h, flexShrink: 0 }
1872
+ }, chart);
1860
1873
  }
1861
1874
  function InlineBar({ value, c, width = "100%", height, tone, color, warnAt }) {
1862
1875
  const d = densityOf(c);
@@ -2185,7 +2198,8 @@ function MiniBarChart({
2185
2198
  gap: gapProp,
2186
2199
  radius: radiusProp,
2187
2200
  fontSize: fontSizeProp,
2188
- showValues = false
2201
+ showValues = false,
2202
+ ...accessibility
2189
2203
  }) {
2190
2204
  const gap = gapProp ?? densityOf(c).s(10);
2191
2205
  const radius = radiusProp ?? densityOf(c).r(3);
@@ -2197,6 +2211,15 @@ function MiniBarChart({
2197
2211
  return React5.createElement(
2198
2212
  "div",
2199
2213
  {
2214
+ ...chartAccessibilityAttributes({
2215
+ ...accessibility,
2216
+ ariaLabel: accessibility.ariaLabel ?? "Mini bar chart",
2217
+ description: chartDescription(accessibility.description, data.map((item, index) => {
2218
+ const label = typeof item.label === "string" || typeof item.label === "number" ? item.label : `Item ${index + 1}`;
2219
+ const value = typeof item.valueLabel === "string" || typeof item.valueLabel === "number" ? item.valueLabel : item.value;
2220
+ return `${label}: ${value}`;
2221
+ }))
2222
+ }),
2200
2223
  style: {
2201
2224
  display: "flex",
2202
2225
  alignItems: "flex-end",
@@ -6673,6 +6696,398 @@ function DeploymentDiagram({
6673
6696
  }
6674
6697
  Object.defineProperty(DeploymentDiagram, SVG_ACCESSIBILITY_COMPONENT, { value: true });
6675
6698
 
6699
+ // src/primitives/entity-relationship.ts
6700
+ import React10 from "react";
6701
+ import dagre2 from "@dagrejs/dagre";
6702
+ var cardinalityWords = {
6703
+ one: "exactly one",
6704
+ "zero-or-one": "zero or one",
6705
+ "one-or-many": "one or more",
6706
+ "zero-or-many": "zero or more"
6707
+ };
6708
+ var legendLines = [
6709
+ "PK primary key \xB7 FK foreign key \xB7 UQ unique \xB7 ? nullable",
6710
+ "|| one \xB7 o| zero or one \xB7 |< one or more \xB7 o< zero or more"
6711
+ ];
6712
+ function requiredText(value, label) {
6713
+ if (typeof value !== "string" || !value.trim()) throw new Error(`EntityRelationshipDiagram ${label} must be a non-empty string.`);
6714
+ }
6715
+ function positive(value, label, allowZero = false) {
6716
+ if (!Number.isFinite(value) || (allowZero ? value < 0 : value <= 0)) {
6717
+ throw new RangeError(`EntityRelationshipDiagram ${label} must be a finite ${allowZero ? "non-negative" : "positive"} number.`);
6718
+ }
6719
+ }
6720
+ function endpointAttributes(endpoint2) {
6721
+ return endpoint2.attribute === void 0 ? [] : typeof endpoint2.attribute === "string" ? [endpoint2.attribute] : endpoint2.attribute;
6722
+ }
6723
+ function attributeDescription(attribute) {
6724
+ const constraints = [attribute.primaryKey && "primary key", attribute.foreignKey && "foreign key", attribute.unique && "unique", attribute.nullable ? "nullable" : "not null"].filter(Boolean);
6725
+ return `${attribute.name} (${attribute.type}, ${constraints.join(", ")})`;
6726
+ }
6727
+ function endpointDescription(endpoint2, entities) {
6728
+ const entity = entities.get(endpoint2.entity);
6729
+ const attributes = endpointAttributes(endpoint2);
6730
+ return `${entity.label ?? entity.id}${attributes.length ? ` [${attributes.join(", ")}]` : ""}`;
6731
+ }
6732
+ function validate(entities, relationships) {
6733
+ if (!entities.length) throw new Error("EntityRelationshipDiagram requires at least one entity.");
6734
+ const byId = /* @__PURE__ */ new Map();
6735
+ for (const entity of entities) {
6736
+ requiredText(entity.id, "entity id");
6737
+ if (byId.has(entity.id)) throw new Error(`EntityRelationshipDiagram has duplicate entity id "${entity.id}".`);
6738
+ if (entity.label !== void 0) requiredText(entity.label, `entity "${entity.id}" label`);
6739
+ const names = /* @__PURE__ */ new Set();
6740
+ for (const attribute of entity.attributes) {
6741
+ requiredText(attribute.name, `entity "${entity.id}" attribute name`);
6742
+ requiredText(attribute.type, `attribute "${entity.id}.${attribute.name}" type`);
6743
+ if (names.has(attribute.name)) throw new Error(`EntityRelationshipDiagram has duplicate attribute "${entity.id}.${attribute.name}".`);
6744
+ if (attribute.primaryKey && attribute.nullable) throw new Error(`EntityRelationshipDiagram primary key "${entity.id}.${attribute.name}" cannot be nullable.`);
6745
+ names.add(attribute.name);
6746
+ }
6747
+ byId.set(entity.id, entity);
6748
+ }
6749
+ const ids = /* @__PURE__ */ new Set();
6750
+ for (const relationship of relationships) {
6751
+ requiredText(relationship.id, "relationship id");
6752
+ if (ids.has(relationship.id)) throw new Error(`EntityRelationshipDiagram has duplicate relationship id "${relationship.id}".`);
6753
+ ids.add(relationship.id);
6754
+ for (const endpoint2 of [relationship.from, relationship.to]) {
6755
+ const entity = byId.get(endpoint2.entity);
6756
+ if (!entity) throw new Error(`EntityRelationshipDiagram relationship "${relationship.id}" references missing entity "${endpoint2.entity}".`);
6757
+ if (!Object.hasOwn(cardinalityWords, endpoint2.cardinality)) throw new Error(`EntityRelationshipDiagram relationship "${relationship.id}" has invalid cardinality "${endpoint2.cardinality}".`);
6758
+ const attributes = endpointAttributes(endpoint2);
6759
+ if (endpoint2.attribute !== void 0 && attributes.length === 0) throw new Error(`EntityRelationshipDiagram relationship "${relationship.id}" needs at least one endpoint attribute.`);
6760
+ if (new Set(attributes).size !== attributes.length) throw new Error(`EntityRelationshipDiagram relationship "${relationship.id}" repeats an endpoint attribute.`);
6761
+ for (const name of attributes) {
6762
+ if (!entity.attributes.some((attribute) => attribute.name === name)) throw new Error(`EntityRelationshipDiagram relationship "${relationship.id}" references missing attribute "${entity.id}.${name}".`);
6763
+ }
6764
+ }
6765
+ const from = endpointAttributes(relationship.from), to = endpointAttributes(relationship.to);
6766
+ if (from.length && to.length && from.length !== to.length) throw new Error(`EntityRelationshipDiagram relationship "${relationship.id}" has mismatched composite attribute counts.`);
6767
+ }
6768
+ return byId;
6769
+ }
6770
+ function cardinalitySize(cardinality, scale) {
6771
+ const many = cardinality.endsWith("many"), optional = cardinality.startsWith("zero");
6772
+ return { length: ((optional ? many ? 25 : 19 : many ? 20 : 12) + 0.75) * scale, halfWidth: ((many ? 6 : 5) + 0.75) * scale };
6773
+ }
6774
+ function cardinalityBounds(cardinality, point, toward, scale) {
6775
+ const size = cardinalitySize(cardinality, scale);
6776
+ const horizontal = point.y === toward.y;
6777
+ const end = { x: point.x + Math.sign(toward.x - point.x) * size.length, y: point.y + Math.sign(toward.y - point.y) * size.length };
6778
+ return {
6779
+ left: Math.min(point.x, end.x) - (horizontal ? 0.75 * scale : size.halfWidth),
6780
+ right: Math.max(point.x, end.x) + (horizontal ? 0.75 * scale : size.halfWidth),
6781
+ top: Math.min(point.y, end.y) - (horizontal ? size.halfWidth : 0.75 * scale),
6782
+ bottom: Math.max(point.y, end.y) + (horizontal ? size.halfWidth : 0.75 * scale)
6783
+ };
6784
+ }
6785
+ function cardinalityGlyph(cardinality, point, toward, color, background, scale, key) {
6786
+ const length = Math.hypot(toward.x - point.x, toward.y - point.y);
6787
+ const ux = (toward.x - point.x) / length, uy = (toward.y - point.y) / length;
6788
+ const at = (along, across = 0) => ({ x: point.x + (ux * along - uy * across) * scale, y: point.y + (uy * along + ux * across) * scale });
6789
+ const bar = (along) => {
6790
+ const a = at(along, -5), b = at(along, 5);
6791
+ return `M ${a.x} ${a.y} L ${b.x} ${b.y}`;
6792
+ };
6793
+ const many = cardinality.endsWith("many");
6794
+ const optional = cardinality.startsWith("zero");
6795
+ const middle = at(13), top = at(0, -6), bottom = at(0, 6);
6796
+ const path = many ? `M ${top.x} ${top.y} L ${middle.x} ${middle.y} L ${bottom.x} ${bottom.y} M ${point.x} ${point.y} L ${middle.x} ${middle.y}` : bar(5);
6797
+ const circle = at(many ? 21 : 15);
6798
+ return React10.createElement(
6799
+ "g",
6800
+ { key, "data-er-cardinality": cardinality },
6801
+ React10.createElement("path", { d: `${path}${optional ? "" : ` ${bar(many ? 20 : 12)}`}`, fill: "none", stroke: color, strokeWidth: 1.5 * scale }),
6802
+ optional && React10.createElement("circle", { cx: circle.x, cy: circle.y, r: 4 * scale, fill: background, stroke: color, strokeWidth: 1.5 * scale })
6803
+ );
6804
+ }
6805
+ function EntityRelationshipDiagram({
6806
+ c: baseTheme,
6807
+ entities,
6808
+ relationships = [],
6809
+ title,
6810
+ description,
6811
+ id,
6812
+ direction = "LR",
6813
+ width,
6814
+ height,
6815
+ entityWidth,
6816
+ fontSize,
6817
+ padding: paddingProp,
6818
+ gap: gapProp,
6819
+ showLegend = true,
6820
+ density
6821
+ }) {
6822
+ const c = density === void 0 ? baseTheme : withDensity(baseTheme, density);
6823
+ const d = densityOf(c);
6824
+ const visibleTitle = title?.trim();
6825
+ const svgTitle = visibleTitle || "Entity relationship diagram";
6826
+ const textSize = fontSize ?? d.type.small;
6827
+ const headerSize = Math.max(textSize, d.type.label);
6828
+ const padding = paddingProp ?? d.s(32);
6829
+ const gap = gapProp ?? d.s(100);
6830
+ positive(textSize, "fontSize");
6831
+ positive(padding, "padding", true);
6832
+ positive(gap, "gap");
6833
+ if (width !== void 0) positive(width, "width");
6834
+ if (height !== void 0) positive(height, "height");
6835
+ if (entityWidth !== void 0) positive(entityWidth, "entityWidth");
6836
+ if (id !== void 0) requiredText(id, "id");
6837
+ if (!["LR", "RL", "TB", "BT"].includes(direction)) throw new Error("EntityRelationshipDiagram direction must be LR, RL, TB, or BT.");
6838
+ const byId = validate(entities, relationships);
6839
+ const lineScale = Math.max(0.8, textSize / 12);
6840
+ const markerSizes = relationships.flatMap((relationship) => [cardinalitySize(relationship.from.cardinality, lineScale), cardinalitySize(relationship.to.cardinality, lineScale)]);
6841
+ const markerLength = Math.max(0, ...markerSizes.map((size) => size.length));
6842
+ const markerPitch = Math.max(0, ...markerSizes.map((size) => size.halfWidth * 2)) + Math.max(d.s(4), lineScale * 1.5);
6843
+ const baseClearance = Math.max(28, d.s(28));
6844
+ const routingClearance = Math.max(baseClearance, markerLength + d.s(4) + Math.max(2, d.s(2)));
6845
+ const enlargedMarkers = routingClearance > baseClearance;
6846
+ const bodyPadding = enlargedMarkers && relationships.some((relationship) => relationship.from.entity === relationship.to.entity) ? Math.max(padding, routingClearance + d.s(4)) : padding;
6847
+ const anchorRow = (endpoint2) => {
6848
+ const entity = byId.get(endpoint2.entity), names = endpointAttributes(endpoint2);
6849
+ return names.length ? Math.round(names.reduce((sum, name) => sum + entity.attributes.findIndex((attribute) => attribute.name === name), 0) / names.length) : Math.floor(Math.max(0, entity.attributes.length - 1) / 2);
6850
+ };
6851
+ const rowEndpointCounts = new Map(entities.map((entity) => [entity.id, /* @__PURE__ */ new Map()]));
6852
+ const entityEndpointCounts = /* @__PURE__ */ new Map();
6853
+ for (const relationship of relationships) for (const endpoint2 of [relationship.from, relationship.to]) {
6854
+ const counts2 = rowEndpointCounts.get(endpoint2.entity), row = anchorRow(endpoint2);
6855
+ counts2.set(row, (counts2.get(row) ?? 0) + 1);
6856
+ entityEndpointCounts.set(endpoint2.entity, (entityEndpointCounts.get(endpoint2.entity) ?? 0) + 1);
6857
+ }
6858
+ const rowHeight = Math.ceil(Math.max(d.s(25), textSize * 1.7));
6859
+ const headerHeight = Math.ceil(Math.max(d.s(35), headerSize * 2));
6860
+ const inset = d.s(12);
6861
+ const keyWidth = Math.ceil(estimateTextWidth("PK FK UQ", textSize, { mono: true })) + inset;
6862
+ const titleHeight = visibleTitle ? Math.ceil(d.type.heading * 1.5 + d.s(12)) : 0;
6863
+ const legendHeight = showLegend ? Math.ceil(textSize * 3.2 + d.s(12)) : 0;
6864
+ const legendWidth = showLegend ? Math.max(480, ...legendLines.map((line) => estimateTextWidth(line, textSize) + padding * 2)) : 0;
6865
+ const labelPadding = relationships.some((relationship) => relationship.label) ? Math.ceil(textSize * 2 + d.s(8)) : 0;
6866
+ const graph = new dagre2.graphlib.Graph({ multigraph: true }).setGraph({
6867
+ rankdir: direction,
6868
+ nodesep: enlargedMarkers ? Math.max(gap * 0.75, routingClearance * 2 + markerPitch) : gap * 0.75,
6869
+ ranksep: Math.max(gap, 74, routingClearance * 2 + markerPitch),
6870
+ edgesep: d.s(26),
6871
+ marginx: 0,
6872
+ marginy: 0
6873
+ }).setDefaultEdgeLabel(() => ({}));
6874
+ const measures = new Map(entities.map((entity) => {
6875
+ const nameWidth = Math.max(30, ...entity.attributes.map((attribute) => estimateTextWidth(attribute.name, textSize, { mono: true })));
6876
+ const typeWidth = Math.max(24, ...entity.attributes.map((attribute) => estimateTextWidth(attribute.type + (attribute.nullable ? "?" : ""), textSize, { mono: true })));
6877
+ const rowHeights = Array.from({ length: Math.max(1, entity.attributes.length) }, (_, index) => Math.max(rowHeight, Math.ceil((rowEndpointCounts.get(entity.id).get(index) ?? 0) * markerPitch)));
6878
+ let rowY = headerHeight;
6879
+ const rowCenters = rowHeights.map((height2) => {
6880
+ const center2 = rowY + height2 / 2;
6881
+ rowY += height2;
6882
+ return center2;
6883
+ });
6884
+ const measured = {
6885
+ width: Math.ceil(Math.max(
6886
+ entityWidth ?? d.s(210),
6887
+ estimateTextWidth(entity.label ?? entity.id, headerSize, { weight: 600 }) + inset * 2,
6888
+ keyWidth + nameWidth + typeWidth + inset * 4,
6889
+ direction === "TB" || direction === "BT" ? markerPitch * ((entityEndpointCounts.get(entity.id) ?? 0) + 1) : 0
6890
+ )),
6891
+ height: rowY,
6892
+ rowHeights,
6893
+ rowCenters,
6894
+ typeWidth: Math.ceil(typeWidth)
6895
+ };
6896
+ graph.setNode(entity.id, { width: measured.width, height: measured.height });
6897
+ return [entity.id, measured];
6898
+ }));
6899
+ for (const relationship of relationships) graph.setEdge(relationship.from.entity, relationship.to.entity, {
6900
+ width: relationship.label ? estimateTextWidth(relationship.label, textSize) + d.s(64) : 0,
6901
+ height: relationship.label ? textSize * 2 : 0,
6902
+ labelpos: "c"
6903
+ }, relationship.id);
6904
+ dagre2.layout(graph);
6905
+ const graphWidth = graph.graph().width ?? 0, graphHeight = graph.graph().height ?? 0;
6906
+ const minWidth = Math.ceil(Math.max(graphWidth + (bodyPadding + labelPadding) * 2, legendWidth, visibleTitle ? estimateTextWidth(visibleTitle, d.type.heading, { weight: 600 }) + padding * 2 : 0));
6907
+ const minHeight = Math.ceil(graphHeight + (bodyPadding + labelPadding) * 2 + titleHeight + legendHeight);
6908
+ if (width !== void 0 && width < minWidth) throw new RangeError(`EntityRelationshipDiagram width needs at least ${minWidth}px to keep entity text readable.`);
6909
+ if (height !== void 0 && height < minHeight) throw new RangeError(`EntityRelationshipDiagram height needs at least ${minHeight}px to keep entity text readable.`);
6910
+ const resolvedWidth = width ?? minWidth, resolvedHeight = height ?? minHeight;
6911
+ const offsetX = (resolvedWidth - graphWidth) / 2;
6912
+ const offsetY = bodyPadding + titleHeight + labelPadding + (resolvedHeight - minHeight) / 2;
6913
+ const nodes = entities.map((entity) => {
6914
+ const node = graph.node(entity.id), measure = measures.get(entity.id);
6915
+ return { id: entity.id, cx: node.x + offsetX, cy: node.y + offsetY, width: measure.width, height: measure.height, ports: [] };
6916
+ });
6917
+ const nodeById = new Map(nodes.map((node) => [node.id, node]));
6918
+ const portRequests = [];
6919
+ const endpointPort = (endpoint2, other, port) => {
6920
+ const node = nodeById.get(endpoint2.entity), target = nodeById.get(other.entity);
6921
+ const horizontal = direction === "LR" || direction === "RL";
6922
+ const side = node === target ? "right" : horizontal ? target.cx >= node.cx ? "right" : "left" : target.cy >= node.cy ? "bottom" : "top";
6923
+ const desired = side === "top" || side === "bottom" ? node.width / 2 : measures.get(node.id).rowCenters[anchorRow(endpoint2)];
6924
+ portRequests.push({ node, id: port, side, desired });
6925
+ };
6926
+ const edges = relationships.map((relationship, index) => {
6927
+ const fromPort = `from-${index}`, toPort = `to-${index}`;
6928
+ endpointPort(relationship.from, relationship.to, fromPort);
6929
+ endpointPort(relationship.to, relationship.from, toPort);
6930
+ return { from: relationship.from.entity, to: relationship.to.entity, fromPort, toPort };
6931
+ });
6932
+ for (const node of nodes) for (const side of ["left", "right", "top", "bottom"]) {
6933
+ const requests = portRequests.filter((request) => request.node === node && request.side === side).sort((a, b) => a.desired - b.desired);
6934
+ const extent = side === "left" || side === "right" ? node.height : node.width;
6935
+ const positions = [];
6936
+ for (let start = 0; start < requests.length; ) {
6937
+ let end = start + 1;
6938
+ while (end < requests.length && requests[end].desired === requests[start].desired) end++;
6939
+ for (let index = start; index < end; index++) positions[index] = requests[index].desired + (index - start - (end - start - 1) / 2) * markerPitch;
6940
+ start = end;
6941
+ }
6942
+ for (let index = 0; index < positions.length; index++) positions[index] = Math.max(positions[index], index ? positions[index - 1] + markerPitch : markerPitch / 2);
6943
+ for (let index = positions.length - 1; index >= 0; index--) positions[index] = Math.min(positions[index], index === positions.length - 1 ? extent - markerPitch / 2 : positions[index + 1] - markerPitch);
6944
+ requests.forEach((request, index) => node.ports.push({ id: request.id, side, offset: positions[index] / extent }));
6945
+ }
6946
+ const routed = routeOrthogonalGraph(nodes, edges, resolvedWidth, resolvedHeight - legendHeight, routingClearance, Math.max(d.s(18), markerPitch));
6947
+ if (routed.failures.length) throw new Error(`EntityRelationshipDiagram could not route relationship "${relationships[routed.failures[0].index].id}": ${routed.failures[0].reason}`);
6948
+ const relationshipText = (relationship) => `${endpointDescription(relationship.from, byId)} (${cardinalityWords[relationship.from.cardinality]}) to ${endpointDescription(relationship.to, byId)} (${cardinalityWords[relationship.to.cardinality]})${relationship.label ? `: ${relationship.label}` : ""}${relationship.identifying ? ", identifying relationship" : ", non-identifying relationship"}.`;
6949
+ const schemaSummary = `${entities.length} entities and ${relationships.length} relationships. ${entities.map((entity) => `${entity.label ?? entity.id}: ${entity.attributes.map(attributeDescription).join("; ") || "no attributes shown"}.`).join(" ")} ${relationships.map(relationshipText).join(" ")}`;
6950
+ const lineColor = c.textSecondary;
6951
+ const labels = [];
6952
+ const placedLabels = [];
6953
+ const markerBoxes = relationships.flatMap((relationship, index) => {
6954
+ const points = routed.routes.get(index);
6955
+ return [cardinalityBounds(relationship.from.cardinality, points[0], points[1], lineScale), cardinalityBounds(relationship.to.cardinality, points.at(-1), points.at(-2), lineScale)];
6956
+ });
6957
+ const occupied = nodes.map((node) => ({ left: node.cx - node.width / 2 - 3, right: node.cx + node.width / 2 + 3, top: node.cy - node.height / 2 - 3, bottom: node.cy + node.height / 2 + 3 }));
6958
+ const paths = relationships.flatMap((relationship, index) => {
6959
+ const points = routed.routes.get(index);
6960
+ const path = roundedPolylinePath(points, d.s(4)).d;
6961
+ if (relationship.label) {
6962
+ const segments = points.slice(1).map((point, at) => ({ a: points[at], b: point, length: Math.hypot(point.x - points[at].x, point.y - points[at].y) }));
6963
+ const labelWidth = Math.ceil(estimateTextWidth(relationship.label, textSize)) + d.s(10);
6964
+ const labelHeight = Math.ceil(textSize * 1.4) + 4;
6965
+ const candidates = segments.sort((a, b) => b.length - a.length).flatMap((segment) => {
6966
+ return [0.5, 0.25, 0.75].flatMap((fraction) => [1, 2, 3].flatMap((distance) => [-1, 1].map((side) => {
6967
+ const x = segment.a.x + (segment.b.x - segment.a.x) * fraction;
6968
+ const y = segment.a.y + (segment.b.y - segment.a.y) * fraction;
6969
+ const horizontal = segment.a.y === segment.b.y;
6970
+ const cx = x + (horizontal ? 0 : side * (labelWidth / 2 + d.s(6)) * distance);
6971
+ const cy = y + (horizontal ? side * (labelHeight / 2 + d.s(6)) * distance : 0);
6972
+ return { left: cx - labelWidth / 2, right: cx + labelWidth / 2, top: cy - labelHeight / 2, bottom: cy + labelHeight / 2 };
6973
+ })));
6974
+ });
6975
+ const label = candidates.find((box2) => box2.left >= 0 && box2.right <= resolvedWidth && box2.top >= padding + titleHeight && box2.bottom <= resolvedHeight - padding - legendHeight && ![...occupied, ...markerBoxes, ...placedLabels].some((other) => box2.left < other.right && box2.right > other.left && box2.top < other.bottom && box2.bottom > other.top) && ![...routed.routes.values()].some((route) => samplesHitBox(route, box2)));
6976
+ if (!label) throw new Error(`EntityRelationshipDiagram could not place label for relationship "${relationship.id}" without covering the schema. Increase gap or canvas size.`);
6977
+ placedLabels.push(label);
6978
+ labels.push(React10.createElement("div", { key: `label-${relationship.id}`, style: {
6979
+ position: "absolute",
6980
+ left: label.left,
6981
+ top: label.top,
6982
+ width: labelWidth,
6983
+ height: labelHeight,
6984
+ display: "flex",
6985
+ alignItems: "center",
6986
+ justifyContent: "center",
6987
+ backgroundColor: c.bg,
6988
+ color: c.textSecondary,
6989
+ fontSize: textSize,
6990
+ fontFamily: c.fontSans,
6991
+ whiteSpace: "nowrap"
6992
+ } }, relationship.label));
6993
+ }
6994
+ return [
6995
+ React10.createElement("path", {
6996
+ key: `path-${relationship.id}`,
6997
+ d: path,
6998
+ fill: "none",
6999
+ stroke: lineColor,
7000
+ strokeWidth: d.w(1.5),
7001
+ strokeDasharray: relationship.identifying ? void 0 : `${d.s(5)} ${d.s(4)}`,
7002
+ "data-vizmatic-graph-edge-id": encodeURIComponent(relationship.id),
7003
+ "data-vizmatic-graph-edge-from": encodeURIComponent(relationship.from.entity),
7004
+ "data-vizmatic-graph-edge-to": encodeURIComponent(relationship.to.entity),
7005
+ "data-vizmatic-graph-edge-label": encodeURIComponent(relationship.label ?? ""),
7006
+ "data-vizmatic-graph-edge-title": encodeURIComponent(relationshipText(relationship))
7007
+ }),
7008
+ cardinalityGlyph(relationship.from.cardinality, points[0], points[1], lineColor, c.bg, lineScale, `from-${relationship.id}`),
7009
+ cardinalityGlyph(relationship.to.cardinality, points.at(-1), points.at(-2), lineColor, c.bg, lineScale, `to-${relationship.id}`)
7010
+ ];
7011
+ });
7012
+ return React10.createElement(
7013
+ "div",
7014
+ {
7015
+ role: "img",
7016
+ "aria-label": svgTitle,
7017
+ "data-vizmatic-svg-id": id,
7018
+ "data-vizmatic-svg-title": svgTitle,
7019
+ "data-vizmatic-svg-description": [description, schemaSummary].filter(Boolean).join(" "),
7020
+ style: { display: "flex", position: "relative", flexShrink: 0, width: resolvedWidth, height: resolvedHeight }
7021
+ },
7022
+ visibleTitle && React10.createElement("div", { style: { position: "absolute", left: padding, top: padding, fontFamily: c.fontSans, fontSize: d.type.heading, fontWeight: 600, color: c.textPrimary } }, visibleTitle),
7023
+ React10.createElement("svg", { width: resolvedWidth, height: resolvedHeight, viewBox: `0 0 ${resolvedWidth} ${resolvedHeight}`, style: { position: "absolute", left: 0, top: 0 } }, ...paths),
7024
+ ...labels,
7025
+ ...entities.map((entity) => {
7026
+ const node = nodeById.get(entity.id), measure = measures.get(entity.id);
7027
+ const keyColor = getReadableToneColor(entity.tone ?? "blue", c, c.bgCard, c.bgCard);
7028
+ return React10.createElement(
7029
+ "div",
7030
+ {
7031
+ key: entity.id,
7032
+ "data-vizmatic-graph-node-id": entity.id,
7033
+ "data-vizmatic-graph-node-label": entity.label ?? entity.id,
7034
+ "data-vizmatic-graph-node-detail": entity.attributes.map(attributeDescription).join("; "),
7035
+ style: {
7036
+ position: "absolute",
7037
+ left: node.cx - node.width / 2,
7038
+ top: node.cy - node.height / 2,
7039
+ display: "flex",
7040
+ flexDirection: "column",
7041
+ width: node.width,
7042
+ height: node.height,
7043
+ border: `1px solid ${c.borderLight}`,
7044
+ borderRadius: d.r(4),
7045
+ backgroundColor: c.bgCard,
7046
+ overflow: "hidden"
7047
+ }
7048
+ },
7049
+ React10.createElement("div", { style: {
7050
+ display: "flex",
7051
+ alignItems: "center",
7052
+ height: headerHeight,
7053
+ flexShrink: 0,
7054
+ padding: `0 ${inset}px`,
7055
+ fontFamily: c.fontSans,
7056
+ fontSize: headerSize,
7057
+ fontWeight: 600,
7058
+ color: keyColor,
7059
+ backgroundColor: c.bgCardAlt,
7060
+ borderBottom: `1px solid ${c.borderLight}`
7061
+ } }, entity.label ?? entity.id),
7062
+ ...entity.attributes.map((attribute, index) => React10.createElement(
7063
+ "div",
7064
+ { key: attribute.name, style: {
7065
+ display: "flex",
7066
+ alignItems: "center",
7067
+ height: measure.rowHeights[index],
7068
+ flexShrink: 0,
7069
+ padding: `0 ${inset}px`,
7070
+ gap: inset,
7071
+ fontFamily: c.fontMono,
7072
+ fontSize: textSize,
7073
+ color: c.textPrimary
7074
+ } },
7075
+ React10.createElement("span", { style: { width: keyWidth - inset, flexShrink: 0, color: keyColor } }, [attribute.primaryKey && "PK", attribute.foreignKey && "FK", attribute.unique && "UQ"].filter(Boolean).join(" ")),
7076
+ React10.createElement("span", { style: { flexGrow: 1, whiteSpace: "nowrap" } }, attribute.name),
7077
+ React10.createElement("span", { style: { width: measure.typeWidth, flexShrink: 0, textAlign: "right", color: c.textSecondary } }, attribute.type + (attribute.nullable ? "?" : ""))
7078
+ )),
7079
+ !entity.attributes.length && React10.createElement("div", { style: { display: "flex", alignItems: "center", padding: `0 ${inset}px`, height: measure.rowHeights[0], fontSize: textSize, color: c.textSecondary, fontFamily: c.fontSans } }, "No attributes shown")
7080
+ );
7081
+ }),
7082
+ showLegend && React10.createElement(
7083
+ "div",
7084
+ { style: { position: "absolute", left: padding, right: padding, bottom: padding, display: "flex", flexDirection: "column", gap: d.s(5), fontSize: textSize, lineHeight: 1.3, fontFamily: c.fontSans, color: c.textSecondary } },
7085
+ ...legendLines.map((line) => React10.createElement("div", { key: line, style: { display: "flex", whiteSpace: "nowrap", flexShrink: 0 } }, line))
7086
+ )
7087
+ );
7088
+ }
7089
+ Object.defineProperty(EntityRelationshipDiagram, SVG_ACCESSIBILITY_COMPONENT, { value: true });
7090
+
6676
7091
  // src/primitives/transformer.ts
6677
7092
  var blockLabels = {
6678
7093
  embedding: "Embedding",
@@ -6934,7 +7349,7 @@ function TransformerTopology({
6934
7349
  Object.defineProperty(TransformerTopology, SVG_ACCESSIBILITY_COMPONENT, { value: true });
6935
7350
 
6936
7351
  // src/primitives/data.ts
6937
- import React10 from "react";
7352
+ import React11 from "react";
6938
7353
  function Matrix({
6939
7354
  data,
6940
7355
  c,
@@ -6954,7 +7369,8 @@ function Matrix({
6954
7369
  highlightCol,
6955
7370
  highlightCell,
6956
7371
  highlightColor = c.info,
6957
- colorDomain
7372
+ colorDomain,
7373
+ ...accessibility
6958
7374
  }) {
6959
7375
  const cellSize = cellSizeProp ?? densityOf(c).f(38);
6960
7376
  const fontSize = fontSizeProp ?? densityOf(c).type.small;
@@ -7006,9 +7422,19 @@ function Matrix({
7006
7422
  if (colorValue2 < 0.67) return c.infoDark;
7007
7423
  return c.positiveDark;
7008
7424
  };
7009
- return React10.createElement(
7425
+ const cellDescriptions = data.flatMap((row, rowIndex) => row.map((value, columnIndex) => {
7426
+ const label = labels?.[rowIndex]?.[columnIndex];
7427
+ const text = typeof label === "string" || typeof label === "number" ? label : formatValue(value);
7428
+ return `${rowLabels?.[rowIndex] ?? `Row ${rowIndex + 1}`}, ${colLabels?.[columnIndex] ?? `column ${columnIndex + 1}`}: ${text}`;
7429
+ }));
7430
+ return React11.createElement(
7010
7431
  "div",
7011
7432
  {
7433
+ ...chartAccessibilityAttributes({
7434
+ ...accessibility,
7435
+ ariaLabel: accessibility.ariaLabel ?? title ?? "Matrix",
7436
+ description: chartDescription(accessibility.description, cellDescriptions)
7437
+ }),
7012
7438
  style: {
7013
7439
  display: "flex",
7014
7440
  flexDirection: "column",
@@ -7016,10 +7442,10 @@ function Matrix({
7016
7442
  gap: densityOf(c).s(8)
7017
7443
  }
7018
7444
  },
7019
- title && React10.createElement("div", {
7445
+ title && React11.createElement("div", {
7020
7446
  style: { ...typeOf(c, "label"), color: c.textPrimary }
7021
7447
  }, title),
7022
- React10.createElement(
7448
+ React11.createElement(
7023
7449
  "div",
7024
7450
  {
7025
7451
  style: {
@@ -7029,7 +7455,7 @@ function Matrix({
7029
7455
  }
7030
7456
  },
7031
7457
  // Column labels
7032
- colLabels && React10.createElement(
7458
+ colLabels && React11.createElement(
7033
7459
  "div",
7034
7460
  {
7035
7461
  style: {
@@ -7039,7 +7465,7 @@ function Matrix({
7039
7465
  }
7040
7466
  },
7041
7467
  ...colLabels.map(
7042
- (label, i) => React10.createElement("div", {
7468
+ (label, i) => React11.createElement("div", {
7043
7469
  key: `col-${i}`,
7044
7470
  style: {
7045
7471
  width: resolvedCellWidth,
@@ -7053,7 +7479,7 @@ function Matrix({
7053
7479
  )
7054
7480
  ),
7055
7481
  ...data.map(
7056
- (row, ri) => React10.createElement(
7482
+ (row, ri) => React11.createElement(
7057
7483
  "div",
7058
7484
  {
7059
7485
  key: `row-${ri}`,
@@ -7063,7 +7489,7 @@ function Matrix({
7063
7489
  alignItems: "center"
7064
7490
  }
7065
7491
  },
7066
- rowLabels && React10.createElement("div", {
7492
+ rowLabels && React11.createElement("div", {
7067
7493
  style: {
7068
7494
  width: resolvedRowLabelWidth,
7069
7495
  textAlign: "right",
@@ -7079,7 +7505,7 @@ function Matrix({
7079
7505
  const highlighted = ri === highlightRow || ci === highlightCol;
7080
7506
  const backgroundColor = highlighted ? compositeColor(withColorAlpha(highlightColor, 0.24), baseBackgroundColor) : baseBackgroundColor;
7081
7507
  const exactCell = ri === highlightCell?.row && ci === highlightCell?.col;
7082
- return React10.createElement("div", {
7508
+ return React11.createElement("div", {
7083
7509
  key: `cell-${ri}-${ci}`,
7084
7510
  style: {
7085
7511
  width: resolvedCellWidth,
@@ -7119,9 +7545,12 @@ function Heatmap({
7119
7545
  highlightCol,
7120
7546
  highlightCell,
7121
7547
  highlightColor,
7122
- colorDomain
7548
+ colorDomain,
7549
+ ...accessibility
7123
7550
  }) {
7124
7551
  return Matrix({
7552
+ ...accessibility,
7553
+ ariaLabel: accessibility.ariaLabel ?? title ?? "Heatmap",
7125
7554
  data,
7126
7555
  colLabels: xLabels,
7127
7556
  rowLabels: yLabels,
@@ -7154,7 +7583,9 @@ function TiledMatrix({
7154
7583
  gap: gapProp,
7155
7584
  tone = "blue",
7156
7585
  muted = false,
7157
- crossedOut = false
7586
+ crossedOut = false,
7587
+ id,
7588
+ description
7158
7589
  }) {
7159
7590
  const gap = gapProp ?? densityOf(c).s(3);
7160
7591
  const safeRows = Math.max(1, Math.floor(rows));
@@ -7162,7 +7593,7 @@ function TiledMatrix({
7162
7593
  const baseAccent = getToneColor(tone, c);
7163
7594
  const cellRows = Array.from(
7164
7595
  { length: safeRows },
7165
- (_, row) => React10.createElement(
7596
+ (_, row) => React11.createElement(
7166
7597
  "div",
7167
7598
  {
7168
7599
  key: `tiled-matrix-row-${row}`,
@@ -7177,7 +7608,7 @@ function TiledMatrix({
7177
7608
  );
7178
7609
  const region = regionIndex >= 0 ? regions[regionIndex] : void 0;
7179
7610
  const accent = getToneColor(region?.tone ?? tone, c);
7180
- return React10.createElement("div", {
7611
+ return React11.createElement("div", {
7181
7612
  key: `tiled-matrix-cell-${row}-${col}`,
7182
7613
  "data-region": regionIndex >= 0 ? regionIndex : void 0,
7183
7614
  style: {
@@ -7193,7 +7624,7 @@ function TiledMatrix({
7193
7624
  })
7194
7625
  )
7195
7626
  );
7196
- const grid = React10.createElement(
7627
+ const grid = React11.createElement(
7197
7628
  "div",
7198
7629
  {
7199
7630
  "data-crossed-out": crossedOut ? "true" : void 0,
@@ -7212,7 +7643,7 @@ function TiledMatrix({
7212
7643
  },
7213
7644
  ...cellRows,
7214
7645
  ...crossedOut ? [
7215
- React10.createElement("div", {
7646
+ React11.createElement("div", {
7216
7647
  key: "cross-forward",
7217
7648
  style: {
7218
7649
  position: "absolute",
@@ -7227,7 +7658,7 @@ function TiledMatrix({
7227
7658
  boxShadow: `0 0 0 1px ${c.bgCard}`
7228
7659
  }
7229
7660
  }),
7230
- React10.createElement("div", {
7661
+ React11.createElement("div", {
7231
7662
  key: "cross-backward",
7232
7663
  style: {
7233
7664
  position: "absolute",
@@ -7244,11 +7675,17 @@ function TiledMatrix({
7244
7675
  })
7245
7676
  ] : []
7246
7677
  );
7247
- return React10.createElement(
7678
+ return React11.createElement(
7248
7679
  "div",
7249
7680
  {
7250
- role: "img",
7251
- "aria-label": ariaLabel ?? (typeof title === "string" ? title : "Tiled matrix"),
7681
+ ...chartAccessibilityAttributes({
7682
+ id,
7683
+ ariaLabel: ariaLabel ?? (typeof title === "string" ? title : "Tiled matrix"),
7684
+ description: chartDescription(description, [
7685
+ `${safeRows} rows by ${safeCols} columns`,
7686
+ ...regions.map((region, index) => `Region ${index + 1}: rows ${region.rowStart + 1} to ${region.rowEnd + 1}, columns ${region.colStart + 1} to ${region.colEnd + 1}`)
7687
+ ])
7688
+ }),
7252
7689
  style: {
7253
7690
  display: "flex",
7254
7691
  flexDirection: "column",
@@ -7257,7 +7694,7 @@ function TiledMatrix({
7257
7694
  }
7258
7695
  },
7259
7696
  ...compactChildren([
7260
- title && React10.createElement("div", {
7697
+ title && React11.createElement("div", {
7261
7698
  style: {
7262
7699
  color: muted ? c.textMuted : getReadableToneColor(tone, c),
7263
7700
  fontFamily: "Inter",
@@ -7267,7 +7704,7 @@ function TiledMatrix({
7267
7704
  textAlign: "center"
7268
7705
  }
7269
7706
  }, title),
7270
- subtitle && React10.createElement("div", {
7707
+ subtitle && React11.createElement("div", {
7271
7708
  style: {
7272
7709
  color: c.textMuted,
7273
7710
  fontFamily: "JetBrains Mono",
@@ -7313,7 +7750,7 @@ function DataTable({
7313
7750
  };
7314
7751
  const widths = Array.from({ length: columnCount }, (_, index) => columnWidth(index));
7315
7752
  const alignmentOf = (colIndex) => align?.[colIndex] ?? (colIndex < headerCols ? "left" : "right");
7316
- return React10.createElement(
7753
+ return React11.createElement(
7317
7754
  "div",
7318
7755
  {
7319
7756
  style: {
@@ -7322,7 +7759,7 @@ function DataTable({
7322
7759
  ...width != null ? { width } : {}
7323
7760
  }
7324
7761
  },
7325
- ...rows.map((row, rowIndex) => React10.createElement(
7762
+ ...rows.map((row, rowIndex) => React11.createElement(
7326
7763
  "div",
7327
7764
  {
7328
7765
  key: `${rowIndex}-${row.map(String).join("|")}`,
@@ -7338,7 +7775,7 @@ function DataTable({
7338
7775
  const isHeaderRow = rowIndex < headerRows;
7339
7776
  const isHeaderCol = colIndex < headerCols;
7340
7777
  const alignment = alignmentOf(colIndex);
7341
- return React10.createElement("div", {
7778
+ return React11.createElement("div", {
7342
7779
  key: `${rowIndex}-${colIndex}-${String(cell)}`,
7343
7780
  style: {
7344
7781
  ...width != null && colIndex === 0 ? { flex: 1 } : { width: widths[colIndex] },
@@ -7358,7 +7795,7 @@ function DataTable({
7358
7795
  );
7359
7796
  }
7360
7797
  function isGridCell(cell) {
7361
- return typeof cell === "object" && cell !== null && !React10.isValidElement(cell) && ("label" in cell || "tone" in cell || "color" in cell || "backgroundColor" in cell || "borderColor" in cell || "opacity" in cell);
7798
+ return typeof cell === "object" && cell !== null && !React11.isValidElement(cell) && ("label" in cell || "tone" in cell || "color" in cell || "backgroundColor" in cell || "borderColor" in cell || "opacity" in cell);
7362
7799
  }
7363
7800
  function Grid({
7364
7801
  rows,
@@ -7405,7 +7842,7 @@ function Grid({
7405
7842
  ...textFitStyle("center")
7406
7843
  };
7407
7844
  };
7408
- return React10.createElement(
7845
+ return React11.createElement(
7409
7846
  "div",
7410
7847
  {
7411
7848
  style: {
@@ -7415,7 +7852,7 @@ function Grid({
7415
7852
  alignItems: "center"
7416
7853
  }
7417
7854
  },
7418
- ...rows.map((row, rowIndex) => React10.createElement(
7855
+ ...rows.map((row, rowIndex) => React11.createElement(
7419
7856
  "div",
7420
7857
  {
7421
7858
  key: `grid-row-${rowIndex}`,
@@ -7424,7 +7861,7 @@ function Grid({
7424
7861
  gap
7425
7862
  }
7426
7863
  },
7427
- ...row.map((cell, colIndex) => React10.createElement("div", {
7864
+ ...row.map((cell, colIndex) => React11.createElement("div", {
7428
7865
  key: `grid-cell-${rowIndex}-${colIndex}`,
7429
7866
  style: cellStyle(cell, rowIndex, colIndex)
7430
7867
  }, renderCellLabel(cell)))
@@ -7453,7 +7890,8 @@ function AxisPlot({
7453
7890
  paths = [],
7454
7891
  xAxisLabel,
7455
7892
  yAxisLabel,
7456
- children
7893
+ children,
7894
+ ...accessibility
7457
7895
  }) {
7458
7896
  const padding = paddingProp ?? densityOf(c).s(18);
7459
7897
  const innerWidth = Math.max(1, width - padding * 2);
@@ -7485,7 +7923,7 @@ function AxisPlot({
7485
7923
  const x = padding + innerWidth * index / (gridCount + 1);
7486
7924
  const y = padding + innerHeight * index / (gridCount + 1);
7487
7925
  return [
7488
- React10.createElement("line", {
7926
+ React11.createElement("line", {
7489
7927
  key: `axis-grid-x-${index}`,
7490
7928
  x1: x,
7491
7929
  y1: padding,
@@ -7495,7 +7933,7 @@ function AxisPlot({
7495
7933
  strokeWidth: 1,
7496
7934
  opacity: 0.75
7497
7935
  }),
7498
- React10.createElement("line", {
7936
+ React11.createElement("line", {
7499
7937
  key: `axis-grid-y-${index}`,
7500
7938
  x1: padding,
7501
7939
  y1: y,
@@ -7510,7 +7948,7 @@ function AxisPlot({
7510
7948
  }
7511
7949
  if (showAxes) {
7512
7950
  elements.push(
7513
- React10.createElement("line", {
7951
+ React11.createElement("line", {
7514
7952
  key: "axis-x",
7515
7953
  x1: padding,
7516
7954
  y1: xAxisY,
@@ -7520,7 +7958,7 @@ function AxisPlot({
7520
7958
  strokeWidth: 1.6,
7521
7959
  opacity: 0.85
7522
7960
  }),
7523
- React10.createElement("line", {
7961
+ React11.createElement("line", {
7524
7962
  key: "axis-y",
7525
7963
  x1: yAxisX,
7526
7964
  y1: padding,
@@ -7543,7 +7981,7 @@ function AxisPlot({
7543
7981
  commands.push(`L ${sx(point.x)} ${sy(point.y)}`);
7544
7982
  }
7545
7983
  }
7546
- return [React10.createElement("path", {
7984
+ return [React11.createElement("path", {
7547
7985
  key: `axis-path-${index}`,
7548
7986
  d: commands.join(" "),
7549
7987
  fill: "none",
@@ -7598,16 +8036,28 @@ function AxisPlot({
7598
8036
  strokeWidth: point.strokeWidth,
7599
8037
  opacity: point.opacity
7600
8038
  })));
7601
- elements.push(...React10.Children.toArray(children).filter(React10.isValidElement));
7602
- const svg = React10.createElement("svg", {
8039
+ elements.push(...React11.Children.toArray(children).filter(React11.isValidElement));
8040
+ const accessible = chartAccessibilityAttributes({
8041
+ ...accessibility,
8042
+ ariaLabel: accessibility.ariaLabel ?? "Axis plot",
8043
+ description: chartDescription(accessibility.description, [
8044
+ `${xAxisLabel ?? "x"} range ${xMin} to ${xMax}, ${yAxisLabel ?? "y"} range ${yMin} to ${yMax}`,
8045
+ ...points.map((point, index) => `Point ${index + 1}: x ${point.x}, y ${point.y}`),
8046
+ ...vectors.map((vector2, index) => `Vector ${index + 1}: (${vector2.x1}, ${vector2.y1}) to (${vector2.x2}, ${vector2.y2})`),
8047
+ ...paths.map((path, index) => `Path ${index + 1}: ${path.points.map((point) => `(${point.x}, ${point.y})`).join(", ")}`)
8048
+ ])
8049
+ });
8050
+ const svg = React11.createElement("svg", {
8051
+ ...!xAxisLabel && !yAxisLabel ? accessible : {},
7603
8052
  width,
7604
8053
  height,
7605
8054
  viewBox: `0 0 ${width} ${height}`
7606
8055
  }, ...elements);
7607
8056
  if (!xAxisLabel && !yAxisLabel) return svg;
7608
- return React10.createElement(
8057
+ return React11.createElement(
7609
8058
  "div",
7610
8059
  {
8060
+ ...accessible,
7611
8061
  style: {
7612
8062
  position: "relative",
7613
8063
  width,
@@ -7616,7 +8066,7 @@ function AxisPlot({
7616
8066
  }
7617
8067
  },
7618
8068
  svg,
7619
- xAxisLabel && React10.createElement("div", {
8069
+ xAxisLabel && React11.createElement("div", {
7620
8070
  key: "axis-x-label",
7621
8071
  style: {
7622
8072
  position: "absolute",
@@ -7631,7 +8081,7 @@ function AxisPlot({
7631
8081
  fontWeight: 750
7632
8082
  }
7633
8083
  }, xAxisLabel),
7634
- yAxisLabel && React10.createElement("div", {
8084
+ yAxisLabel && React11.createElement("div", {
7635
8085
  key: "axis-y-label",
7636
8086
  style: {
7637
8087
  position: "absolute",
@@ -7650,7 +8100,7 @@ function AxisPlot({
7650
8100
  }
7651
8101
 
7652
8102
  // src/primitives/charts.ts
7653
- import React11 from "react";
8103
+ import React12 from "react";
7654
8104
  var chartPalette = ["primary", "warning", "positive", "violet", "info", "accent", "critical"];
7655
8105
  function isColorName(value) {
7656
8106
  return chartPalette.includes(value) || value === "neutral" || value === "secondary";
@@ -7754,7 +8204,7 @@ function chartLabel(key, text, x, y, c, options = {}) {
7754
8204
  );
7755
8205
  transform = void 0;
7756
8206
  }
7757
- return React11.createElement("div", {
8207
+ return React12.createElement("div", {
7758
8208
  key,
7759
8209
  style: {
7760
8210
  position: "absolute",
@@ -7797,7 +8247,7 @@ function pointLabelPlacement(x, y, plot, index, width = 70) {
7797
8247
  };
7798
8248
  }
7799
8249
  function ChartFrame(props) {
7800
- return React11.createElement(ChartFrameContent, props);
8250
+ return React12.createElement(ChartFrameContent, props);
7801
8251
  }
7802
8252
  function ChartFrameContent({
7803
8253
  children,
@@ -7809,13 +8259,21 @@ function ChartFrameContent({
7809
8259
  width = "100%",
7810
8260
  height,
7811
8261
  padding: paddingProp,
7812
- framed = false
8262
+ framed = false,
8263
+ id,
8264
+ ariaLabel,
8265
+ description
7813
8266
  }) {
7814
8267
  const d = densityOf(c);
7815
8268
  const padding = paddingProp ?? (framed ? d.s(14) : 0);
7816
- return React11.createElement(
8269
+ return React12.createElement(
7817
8270
  "div",
7818
8271
  {
8272
+ ...chartAccessibilityAttributes({
8273
+ id,
8274
+ ariaLabel: ariaLabel ?? title ?? "Chart",
8275
+ description: [subtitle, description].filter(Boolean).join(" ")
8276
+ }),
7819
8277
  style: {
7820
8278
  width,
7821
8279
  ...height ? { height } : {},
@@ -7827,20 +8285,20 @@ function ChartFrameContent({
7827
8285
  ...framed ? { borderRadius: d.r(8), border: `1px solid ${c.borderSubtle}`, backgroundColor: c.bgCard } : {}
7828
8286
  }
7829
8287
  },
7830
- (title || subtitle) && React11.createElement(
8288
+ (title || subtitle) && React12.createElement(
7831
8289
  "div",
7832
8290
  {
7833
8291
  style: { display: "flex", flexDirection: "column", gap: d.s(2), minWidth: 0, maxWidth: "100%" }
7834
8292
  },
7835
- title && React11.createElement("div", {
8293
+ title && React12.createElement("div", {
7836
8294
  style: { ...typeOf(c, "label"), ...textFitStyle(), color: c.textPrimary, fontWeight: 600 }
7837
8295
  }, title),
7838
- subtitle && React11.createElement("div", {
8296
+ subtitle && React12.createElement("div", {
7839
8297
  style: { ...typeOf(c, "tiny"), ...textFitStyle(), color: c.textSecondary, lineHeight: 1.35 }
7840
8298
  }, subtitle)
7841
8299
  ),
7842
8300
  children,
7843
- (legend || footer) && React11.createElement(
8301
+ (legend || footer) && React12.createElement(
7844
8302
  "div",
7845
8303
  {
7846
8304
  style: {
@@ -7850,18 +8308,18 @@ function ChartFrameContent({
7850
8308
  gap: d.s(12)
7851
8309
  }
7852
8310
  },
7853
- legend && React11.createElement(
8311
+ legend && React12.createElement(
7854
8312
  "div",
7855
8313
  {
7856
8314
  style: { display: "flex", alignItems: "center", gap: d.s(12), flexWrap: "wrap", minWidth: 0 }
7857
8315
  },
7858
- ...legend.map((item, index) => React11.createElement(
8316
+ ...legend.map((item, index) => React12.createElement(
7859
8317
  "div",
7860
8318
  {
7861
8319
  key: `${item.label}-${index}`,
7862
8320
  style: { display: "flex", alignItems: "center", gap: d.s(6), minWidth: 0 }
7863
8321
  },
7864
- React11.createElement("span", {
8322
+ React12.createElement("span", {
7865
8323
  style: {
7866
8324
  width: d.f(12),
7867
8325
  height: Math.max(2, d.w(2)),
@@ -7869,12 +8327,12 @@ function ChartFrameContent({
7869
8327
  display: "flex"
7870
8328
  }
7871
8329
  }),
7872
- React11.createElement("span", {
8330
+ React12.createElement("span", {
7873
8331
  style: { ...typeOf(c, "tiny"), ...textFitStyle(), color: c.textSecondary }
7874
8332
  }, item.label)
7875
8333
  ))
7876
8334
  ),
7877
- footer && React11.createElement("div", {
8335
+ footer && React12.createElement("div", {
7878
8336
  style: { ...typeOf(c, "tiny"), ...textFitStyle("right"), color: c.textMuted }
7879
8337
  }, footer)
7880
8338
  )
@@ -7944,7 +8402,8 @@ function PieChart({
7944
8402
  size,
7945
8403
  format = "decimal",
7946
8404
  showLegend = true,
7947
- footer
8405
+ footer,
8406
+ ...accessibility
7948
8407
  }) {
7949
8408
  const total = validateNonNegativeSegments(segments, "PieChart");
7950
8409
  const positiveSegments = segments.filter((segment) => segment.value > 0);
@@ -7958,7 +8417,7 @@ function PieChart({
7958
8417
  const start = cursor;
7959
8418
  const end = index === positiveSegments.length - 1 ? 270 : cursor + span;
7960
8419
  cursor += span;
7961
- return React11.createElement("path", {
8420
+ return React12.createElement("path", {
7962
8421
  key: `pie-segment-${segment.label}-${index}`,
7963
8422
  d: pieSectorPath(cx, cy, radius, start, end),
7964
8423
  fill: chartColor(segment.color, c, index),
@@ -7969,7 +8428,7 @@ function PieChart({
7969
8428
  "data-pie-share": total > 0 ? segment.value / total : 0
7970
8429
  });
7971
8430
  });
7972
- const legend = showLegend && positiveSegments.length > 0 && React11.createElement("div", {
8431
+ const legend = showLegend && positiveSegments.length > 0 && React12.createElement("div", {
7973
8432
  style: {
7974
8433
  display: "flex",
7975
8434
  flexDirection: "column",
@@ -7981,13 +8440,13 @@ function PieChart({
7981
8440
  const formattedValue = formatChartValue(segment.value, format);
7982
8441
  const share = formatChartValue(segment.value / total, "percent");
7983
8442
  const label = segment.valueLabel ?? (format === "percent" ? formattedValue : `${formattedValue} \xB7 ${share}`);
7984
- return React11.createElement(
8443
+ return React12.createElement(
7985
8444
  "div",
7986
8445
  {
7987
8446
  key: `pie-legend-${segment.label}-${index}`,
7988
8447
  style: { display: "flex", alignItems: "center", gap: 8, minWidth: 0 }
7989
8448
  },
7990
- React11.createElement("span", {
8449
+ React12.createElement("span", {
7991
8450
  style: {
7992
8451
  display: "flex",
7993
8452
  width: 10,
@@ -7997,10 +8456,10 @@ function PieChart({
7997
8456
  flexShrink: 0
7998
8457
  }
7999
8458
  }),
8000
- React11.createElement("span", {
8459
+ React12.createElement("span", {
8001
8460
  style: { ...typeOf(c, "tiny"), ...textFitStyle(), color: c.textSecondary, flex: 1 }
8002
8461
  }, segment.label),
8003
- React11.createElement("span", {
8462
+ React12.createElement("span", {
8004
8463
  style: {
8005
8464
  ...typeOf(c, "tiny"),
8006
8465
  color: c.textPrimary,
@@ -8012,12 +8471,15 @@ function PieChart({
8012
8471
  );
8013
8472
  }));
8014
8473
  return ChartFrame({
8474
+ ...accessibility,
8475
+ ariaLabel: accessibility.ariaLabel ?? title ?? "Pie chart",
8476
+ description: chartDescription(accessibility.description, valueDescriptions(segments, format)),
8015
8477
  c,
8016
8478
  title,
8017
8479
  subtitle,
8018
8480
  footer,
8019
8481
  width,
8020
- children: React11.createElement(
8482
+ children: React12.createElement(
8021
8483
  "div",
8022
8484
  {
8023
8485
  style: {
@@ -8029,7 +8491,7 @@ function PieChart({
8029
8491
  width: "100%"
8030
8492
  }
8031
8493
  },
8032
- React11.createElement(
8494
+ React12.createElement(
8033
8495
  "svg",
8034
8496
  {
8035
8497
  width: resolvedSize,
@@ -8038,7 +8500,7 @@ function PieChart({
8038
8500
  role: "img",
8039
8501
  "aria-label": title ?? "Pie chart"
8040
8502
  },
8041
- positiveSegments.length === 0 ? React11.createElement("circle", {
8503
+ positiveSegments.length === 0 ? React12.createElement("circle", {
8042
8504
  cx,
8043
8505
  cy,
8044
8506
  r: radius,
@@ -8064,7 +8526,8 @@ function DonutChart({
8064
8526
  centerLabel,
8065
8527
  centerValue,
8066
8528
  showLegend = true,
8067
- footer
8529
+ footer,
8530
+ ...accessibility
8068
8531
  }) {
8069
8532
  const positiveSegments = segments.filter((segment) => segment.value > 0);
8070
8533
  const total = positiveSegments.reduce((sum, segment) => sum + segment.value, 0);
@@ -8083,13 +8546,13 @@ function DonutChart({
8083
8546
  const end = cursor + rawSpan - gap / 2;
8084
8547
  cursor += rawSpan;
8085
8548
  if (end <= start) return null;
8086
- return React11.createElement("path", {
8549
+ return React12.createElement("path", {
8087
8550
  key: `donut-segment-${segment.label}-${index}`,
8088
8551
  d: donutArcPath(cx, cy, outerRadius, innerRadius, start, end),
8089
8552
  fill: chartColor(segment.color, c, index)
8090
8553
  });
8091
8554
  }).filter(Boolean);
8092
- const legend = showLegend && positiveSegments.length > 0 && React11.createElement("div", {
8555
+ const legend = showLegend && positiveSegments.length > 0 && React12.createElement("div", {
8093
8556
  style: {
8094
8557
  display: "flex",
8095
8558
  flexDirection: "column",
@@ -8097,7 +8560,7 @@ function DonutChart({
8097
8560
  flex: 1,
8098
8561
  minWidth: 112
8099
8562
  }
8100
- }, ...positiveSegments.map((segment, index) => React11.createElement(
8563
+ }, ...positiveSegments.map((segment, index) => React12.createElement(
8101
8564
  "div",
8102
8565
  {
8103
8566
  key: `donut-legend-${segment.label}-${index}`,
@@ -8108,7 +8571,7 @@ function DonutChart({
8108
8571
  minWidth: 0
8109
8572
  }
8110
8573
  },
8111
- React11.createElement("span", {
8574
+ React12.createElement("span", {
8112
8575
  style: {
8113
8576
  display: "flex",
8114
8577
  width: 10,
@@ -8118,7 +8581,7 @@ function DonutChart({
8118
8581
  flexShrink: 0
8119
8582
  }
8120
8583
  }),
8121
- React11.createElement("span", {
8584
+ React12.createElement("span", {
8122
8585
  style: {
8123
8586
  ...typeOf(c, "tiny"),
8124
8587
  ...textFitStyle(),
@@ -8126,7 +8589,7 @@ function DonutChart({
8126
8589
  flex: 1
8127
8590
  }
8128
8591
  }, segment.label),
8129
- React11.createElement("span", {
8592
+ React12.createElement("span", {
8130
8593
  style: {
8131
8594
  ...typeOf(c, "tiny"),
8132
8595
  color: c.textPrimary,
@@ -8137,6 +8600,9 @@ function DonutChart({
8137
8600
  }, segment.valueLabel ?? formatChartValue(segment.value, format))
8138
8601
  )));
8139
8602
  return ChartFrame({
8603
+ ...accessibility,
8604
+ ariaLabel: accessibility.ariaLabel ?? title ?? "Donut chart",
8605
+ description: chartDescription(accessibility.description, valueDescriptions(positiveSegments, format)),
8140
8606
  c,
8141
8607
  title,
8142
8608
  subtitle,
@@ -8144,7 +8610,7 @@ function DonutChart({
8144
8610
  width,
8145
8611
  height,
8146
8612
  padding: densityOf(c).s(16),
8147
- children: React11.createElement(
8613
+ children: React12.createElement(
8148
8614
  "div",
8149
8615
  {
8150
8616
  style: {
@@ -8156,7 +8622,7 @@ function DonutChart({
8156
8622
  width: "100%"
8157
8623
  }
8158
8624
  },
8159
- React11.createElement(
8625
+ React12.createElement(
8160
8626
  "div",
8161
8627
  {
8162
8628
  style: {
@@ -8167,14 +8633,14 @@ function DonutChart({
8167
8633
  flexShrink: 0
8168
8634
  }
8169
8635
  },
8170
- React11.createElement(
8636
+ React12.createElement(
8171
8637
  "svg",
8172
8638
  {
8173
8639
  width: resolvedSize,
8174
8640
  height: resolvedSize,
8175
8641
  viewBox: `0 0 ${resolvedSize} ${resolvedSize}`
8176
8642
  },
8177
- positiveSegments.length === 0 ? React11.createElement("circle", {
8643
+ positiveSegments.length === 0 ? React12.createElement("circle", {
8178
8644
  cx,
8179
8645
  cy,
8180
8646
  r: (outerRadius + innerRadius) / 2,
@@ -8183,7 +8649,7 @@ function DonutChart({
8183
8649
  strokeWidth: resolvedThickness
8184
8650
  }) : paths
8185
8651
  ),
8186
- (centerLabel != null || resolvedCenterValue != null) && React11.createElement(
8652
+ (centerLabel != null || resolvedCenterValue != null) && React12.createElement(
8187
8653
  "div",
8188
8654
  {
8189
8655
  style: {
@@ -8202,7 +8668,7 @@ function DonutChart({
8202
8668
  textAlign: "center"
8203
8669
  }
8204
8670
  },
8205
- resolvedCenterValue != null && React11.createElement("div", {
8671
+ resolvedCenterValue != null && React12.createElement("div", {
8206
8672
  style: {
8207
8673
  ...typeOf(c, "small"),
8208
8674
  color: c.textPrimary,
@@ -8213,7 +8679,7 @@ function DonutChart({
8213
8679
  ...textFitStyle("center")
8214
8680
  }
8215
8681
  }, resolvedCenterValue),
8216
- centerLabel != null && React11.createElement("div", {
8682
+ centerLabel != null && React12.createElement("div", {
8217
8683
  style: {
8218
8684
  ...typeOf(c, "tiny"),
8219
8685
  color: c.textMuted,
@@ -8227,6 +8693,9 @@ function DonutChart({
8227
8693
  )
8228
8694
  });
8229
8695
  }
8696
+ function valueDescriptions(data, format = "decimal") {
8697
+ return data.map((item) => `${item.label}: ${item.valueLabel ?? formatChartValue(item.value, format)}`);
8698
+ }
8230
8699
  function StackedBar({
8231
8700
  segments,
8232
8701
  c,
@@ -8234,13 +8703,22 @@ function StackedBar({
8234
8703
  height = 68,
8235
8704
  title,
8236
8705
  subtitle,
8237
- showLegend = true
8706
+ showLegend = true,
8707
+ ...accessibility
8238
8708
  }) {
8239
8709
  const positiveSegments = segments.filter((segment) => segment.value > 0);
8240
8710
  const total = positiveSegments.reduce((sum, segment) => sum + segment.value, 0);
8241
- return React11.createElement(
8711
+ return React12.createElement(
8242
8712
  "div",
8243
8713
  {
8714
+ ...chartAccessibilityAttributes({
8715
+ ...accessibility,
8716
+ ariaLabel: accessibility.ariaLabel ?? title ?? "Stacked bar",
8717
+ description: chartDescription(
8718
+ [subtitle, accessibility.description].filter(Boolean).join(" "),
8719
+ valueDescriptions(positiveSegments)
8720
+ )
8721
+ }),
8244
8722
  style: {
8245
8723
  width,
8246
8724
  display: "flex",
@@ -8248,7 +8726,7 @@ function StackedBar({
8248
8726
  gap: densityOf(c).s(10)
8249
8727
  }
8250
8728
  },
8251
- (title || subtitle) && React11.createElement(
8729
+ (title || subtitle) && React12.createElement(
8252
8730
  "div",
8253
8731
  {
8254
8732
  style: {
@@ -8257,14 +8735,14 @@ function StackedBar({
8257
8735
  gap: densityOf(c).s(3)
8258
8736
  }
8259
8737
  },
8260
- title && React11.createElement("div", {
8738
+ title && React12.createElement("div", {
8261
8739
  style: { ...typeOf(c, "label"), color: c.textPrimary, fontWeight: 600 }
8262
8740
  }, title),
8263
- subtitle && React11.createElement("div", {
8741
+ subtitle && React12.createElement("div", {
8264
8742
  style: { ...typeOf(c, "tiny"), color: c.textSecondary }
8265
8743
  }, subtitle)
8266
8744
  ),
8267
- React11.createElement(
8745
+ React12.createElement(
8268
8746
  "div",
8269
8747
  {
8270
8748
  style: {
@@ -8282,7 +8760,7 @@ function StackedBar({
8282
8760
  const share = total > 0 ? segment.value / total : 0;
8283
8761
  const segmentWidth = width * share;
8284
8762
  const color = chartColor(segment.color, c, index);
8285
- return React11.createElement(
8763
+ return React12.createElement(
8286
8764
  "div",
8287
8765
  {
8288
8766
  key: `${segment.label}-${index}`,
@@ -8296,7 +8774,7 @@ function StackedBar({
8296
8774
  ...index < positiveSegments.length - 1 ? { borderRight: `2px solid ${c.bgSubtle}` } : {}
8297
8775
  }
8298
8776
  },
8299
- segmentWidth >= 64 && React11.createElement("span", {
8777
+ segmentWidth >= 64 && React12.createElement("span", {
8300
8778
  style: {
8301
8779
  ...typeOf(c, "small"),
8302
8780
  color: getReadableTextColor(color, c),
@@ -8307,7 +8785,7 @@ function StackedBar({
8307
8785
  );
8308
8786
  })
8309
8787
  ),
8310
- showLegend && React11.createElement(
8788
+ showLegend && React12.createElement(
8311
8789
  "div",
8312
8790
  {
8313
8791
  style: {
@@ -8319,13 +8797,13 @@ function StackedBar({
8319
8797
  },
8320
8798
  ...positiveSegments.map((segment, index) => {
8321
8799
  const share = total > 0 ? segment.value / total : 0;
8322
- return React11.createElement(
8800
+ return React12.createElement(
8323
8801
  "div",
8324
8802
  {
8325
8803
  key: `legend-${segment.label}-${index}`,
8326
8804
  style: { display: "flex", alignItems: "center", gap: 7 }
8327
8805
  },
8328
- React11.createElement("span", {
8806
+ React12.createElement("span", {
8329
8807
  style: {
8330
8808
  width: 12,
8331
8809
  height: 12,
@@ -8334,7 +8812,7 @@ function StackedBar({
8334
8812
  backgroundColor: chartColor(segment.color, c, index)
8335
8813
  }
8336
8814
  }),
8337
- React11.createElement("span", {
8815
+ React12.createElement("span", {
8338
8816
  style: { ...typeOf(c, "tiny"), color: c.textSecondary }
8339
8817
  }, `${segment.label} ${segment.valueLabel ?? formatChartValue(share, "percent")}`)
8340
8818
  );
@@ -8355,7 +8833,8 @@ function BarChart({
8355
8833
  showGrid = true,
8356
8834
  showValues = true,
8357
8835
  yAxisLabel,
8358
- footer
8836
+ footer,
8837
+ ...accessibility
8359
8838
  }) {
8360
8839
  const d = densityOf(c);
8361
8840
  const margin = { top: d.f(16), right: d.g(8), bottom: d.f(26), left: d.f(yAxisLabel ? 62 : 34) };
@@ -8375,23 +8854,26 @@ function BarChart({
8375
8854
  return { item, index, x, y, barHeight, valueY, color: chartColor(item.color, c, 0) };
8376
8855
  });
8377
8856
  return ChartFrame({
8857
+ ...accessibility,
8858
+ ariaLabel: accessibility.ariaLabel ?? title ?? "Bar chart",
8859
+ description: chartDescription(accessibility.description, valueDescriptions(data, format)),
8378
8860
  c,
8379
8861
  title,
8380
8862
  subtitle,
8381
8863
  width,
8382
8864
  footer,
8383
- children: React11.createElement(
8865
+ children: React12.createElement(
8384
8866
  "div",
8385
8867
  { style: { position: "relative", width, height, display: "flex" } },
8386
- React11.createElement(
8868
+ React12.createElement(
8387
8869
  "svg",
8388
8870
  { width, height, viewBox: `0 0 ${width} ${height}` },
8389
- showGrid && React11.createElement(
8871
+ showGrid && React12.createElement(
8390
8872
  "g",
8391
8873
  {},
8392
8874
  ...ticks.map((tick) => {
8393
8875
  const y = yInPlot(tick, domain, plot);
8394
- return React11.createElement("line", {
8876
+ return React12.createElement("line", {
8395
8877
  key: `tick-${tick}`,
8396
8878
  x1: plot.x,
8397
8879
  y1: y,
@@ -8402,9 +8884,9 @@ function BarChart({
8402
8884
  });
8403
8885
  })
8404
8886
  ),
8405
- React11.createElement("line", { x1: plot.x, y1: baselineY, x2: plot.right, y2: baselineY, stroke: c.borderLight, strokeWidth: d.stroke.hair }),
8887
+ React12.createElement("line", { x1: plot.x, y1: baselineY, x2: plot.right, y2: baselineY, stroke: c.borderLight, strokeWidth: d.stroke.hair }),
8406
8888
  ...barGeometries.map(
8407
- ({ item, index, x, y, barHeight, color }) => React11.createElement("rect", {
8889
+ ({ item, index, x, y, barHeight, color }) => React12.createElement("rect", {
8408
8890
  key: `${item.label}-${index}`,
8409
8891
  x,
8410
8892
  y,
@@ -8447,7 +8929,8 @@ function ParetoBarChart({
8447
8929
  format = "integer",
8448
8930
  showGrid = true,
8449
8931
  showValues = true,
8450
- footer
8932
+ footer,
8933
+ ...accessibility
8451
8934
  }) {
8452
8935
  let total = 0;
8453
8936
  for (const item of data) {
@@ -8492,17 +8975,22 @@ function ParetoBarChart({
8492
8975
  });
8493
8976
  const cumulativePath = bars.map(({ centerX, cumulativeY }, index) => `${index === 0 ? "M" : "L"} ${centerX.toFixed(1)} ${cumulativeY.toFixed(1)}`).join(" ");
8494
8977
  return ChartFrame({
8978
+ ...accessibility,
8979
+ ariaLabel: accessibility.ariaLabel ?? title ?? "Pareto bar chart",
8980
+ description: chartDescription(accessibility.description, bars.map(
8981
+ ({ item, cumulative }) => `${item.label}: ${item.valueLabel ?? formatChartValue(item.value, format)}, cumulative ${formatChartValue(cumulative, "percent")}`
8982
+ )),
8495
8983
  c,
8496
8984
  title,
8497
8985
  subtitle,
8498
8986
  width,
8499
8987
  footer,
8500
- children: React11.createElement(
8988
+ children: React12.createElement(
8501
8989
  "div",
8502
8990
  {
8503
8991
  style: { position: "relative", width, height, display: "flex" }
8504
8992
  },
8505
- React11.createElement(
8993
+ React12.createElement(
8506
8994
  "svg",
8507
8995
  {
8508
8996
  width,
@@ -8511,12 +8999,12 @@ function ParetoBarChart({
8511
8999
  role: "img",
8512
9000
  "aria-label": title ?? "Pareto bar chart"
8513
9001
  },
8514
- showGrid && React11.createElement(
9002
+ showGrid && React12.createElement(
8515
9003
  "g",
8516
9004
  {},
8517
9005
  ...countTicks.map((tick) => {
8518
9006
  const y = yInPlot(tick, valueDomain, plot);
8519
- return React11.createElement("line", {
9007
+ return React12.createElement("line", {
8520
9008
  key: `pareto-count-grid-${tick}`,
8521
9009
  x1: plot.x,
8522
9010
  y1: y,
@@ -8527,7 +9015,7 @@ function ParetoBarChart({
8527
9015
  });
8528
9016
  })
8529
9017
  ),
8530
- React11.createElement("line", {
9018
+ React12.createElement("line", {
8531
9019
  x1: plot.x,
8532
9020
  y1: plot.bottom,
8533
9021
  x2: plot.right,
@@ -8535,7 +9023,7 @@ function ParetoBarChart({
8535
9023
  stroke: c.borderLight,
8536
9024
  strokeWidth: d.stroke.hair
8537
9025
  }),
8538
- ...bars.map(({ item, order, x, y, height: barHeight, color }) => React11.createElement("rect", {
9026
+ ...bars.map(({ item, order, x, y, height: barHeight, color }) => React12.createElement("rect", {
8539
9027
  key: `pareto-bar-${item.label}-${order}`,
8540
9028
  x,
8541
9029
  y,
@@ -8547,7 +9035,7 @@ function ParetoBarChart({
8547
9035
  "data-pareto-value": item.value,
8548
9036
  "data-pareto-order": order
8549
9037
  })),
8550
- cumulativePath && React11.createElement("path", {
9038
+ cumulativePath && React12.createElement("path", {
8551
9039
  d: cumulativePath,
8552
9040
  fill: "none",
8553
9041
  stroke: chartColor("critical", c),
@@ -8556,7 +9044,7 @@ function ParetoBarChart({
8556
9044
  strokeLinejoin: "round",
8557
9045
  "data-pareto-cumulative-line": true
8558
9046
  }),
8559
- ...bars.map(({ item, sourceIndex, centerX, cumulativeY, cumulative, order }) => React11.createElement("circle", {
9047
+ ...bars.map(({ item, sourceIndex, centerX, cumulativeY, cumulative, order }) => React12.createElement("circle", {
8560
9048
  key: `pareto-cumulative-point-${order}`,
8561
9049
  cx: centerX,
8562
9050
  cy: cumulativeY,
@@ -8622,7 +9110,8 @@ function LineChart({
8622
9110
  showPoints = true,
8623
9111
  directLabels,
8624
9112
  yAxisLabel,
8625
- footer
9113
+ footer,
9114
+ ...accessibility
8626
9115
  }) {
8627
9116
  const d = densityOf(c);
8628
9117
  const direct = directLabels ?? series.length > 1;
@@ -8647,24 +9136,29 @@ function LineChart({
8647
9136
  return `${index === 0 ? "M" : "L"} ${point.x.toFixed(1)} ${point.y.toFixed(1)}`;
8648
9137
  }).join(" ");
8649
9138
  return ChartFrame({
9139
+ ...accessibility,
9140
+ ariaLabel: accessibility.ariaLabel ?? title ?? "Line chart",
9141
+ description: chartDescription(accessibility.description, series.map(
9142
+ (item) => `${item.name}: ${item.points.map((value, index) => `${labels?.[index] ?? `Point ${index + 1}`}: ${formatChartValue(value, format)}`).join(", ")}`
9143
+ )),
8650
9144
  c,
8651
9145
  title,
8652
9146
  subtitle,
8653
9147
  width,
8654
9148
  footer,
8655
9149
  ...direct ? {} : { legend: series.length > 1 ? series.map((item, index) => ({ label: item.name, color: item.color ?? chartPalette[index % chartPalette.length] })) : void 0 },
8656
- children: React11.createElement(
9150
+ children: React12.createElement(
8657
9151
  "div",
8658
9152
  { style: { position: "relative", width, height, display: "flex" } },
8659
- React11.createElement(
9153
+ React12.createElement(
8660
9154
  "svg",
8661
9155
  { width, height, viewBox: `0 0 ${width} ${height}` },
8662
- showGrid && React11.createElement(
9156
+ showGrid && React12.createElement(
8663
9157
  "g",
8664
9158
  {},
8665
9159
  ...ticks.map((tick) => {
8666
9160
  const y = yInPlot(tick, domain, plot);
8667
- return React11.createElement("line", {
9161
+ return React12.createElement("line", {
8668
9162
  key: `line-tick-${tick}`,
8669
9163
  x1: plot.x,
8670
9164
  y1: y,
@@ -8675,7 +9169,7 @@ function LineChart({
8675
9169
  });
8676
9170
  })
8677
9171
  ),
8678
- React11.createElement("line", { x1: plot.x, y1: plot.bottom, x2: plot.right, y2: plot.bottom, stroke: c.borderLight, strokeWidth: d.stroke.hair }),
9172
+ React12.createElement("line", { x1: plot.x, y1: plot.bottom, x2: plot.right, y2: plot.bottom, stroke: c.borderLight, strokeWidth: d.stroke.hair }),
8679
9173
  ...series.flatMap((item, seriesIndex) => {
8680
9174
  if (item.points.length === 0) return [];
8681
9175
  const color = chartColor(item.color, c, seriesIndex);
@@ -8688,9 +9182,9 @@ function LineChart({
8688
9182
  }
8689
9183
  const elements = [];
8690
9184
  if (areaPath) {
8691
- elements.push(React11.createElement("path", { key: `${item.name}-area`, d: areaPath, fill: color, opacity: 0.1 }));
9185
+ elements.push(React12.createElement("path", { key: `${item.name}-area`, d: areaPath, fill: color, opacity: 0.1 }));
8692
9186
  }
8693
- elements.push(React11.createElement("path", {
9187
+ elements.push(React12.createElement("path", {
8694
9188
  key: `${item.name}-line`,
8695
9189
  d: linePath,
8696
9190
  fill: "none",
@@ -8702,7 +9196,7 @@ function LineChart({
8702
9196
  if (showPoints) {
8703
9197
  elements.push(...item.points.map((value, index) => {
8704
9198
  const point = pointFor(value, index);
8705
- return React11.createElement("circle", {
9199
+ return React12.createElement("circle", {
8706
9200
  key: `${item.name}-point-${index}`,
8707
9201
  cx: point.x,
8708
9202
  cy: point.y,
@@ -8755,7 +9249,7 @@ for (const chart of [PieChart, DonutChart, StackedBar, BarChart, ParetoBarChart,
8755
9249
  }
8756
9250
 
8757
9251
  // src/primitives/plots.ts
8758
- import React12 from "react";
9252
+ import React13 from "react";
8759
9253
  for (const chart of [ScatterPlot, ParetoChart, QuadrantChart, IntervalPlot]) {
8760
9254
  Object.defineProperty(chart, CANVAS_CHART_COMPONENT, { value: true });
8761
9255
  }
@@ -8764,6 +9258,12 @@ function xTickLabelAlign(index, count) {
8764
9258
  if (index === count - 1) return "right";
8765
9259
  return "center";
8766
9260
  }
9261
+ function pointDescription(point, index, formatX, formatY, xLabel = "x", yLabel = "y") {
9262
+ return `${point.label ?? `Point ${index + 1}`}: ${xLabel} ${formatChartValue(point.x, formatX)}, ${yLabel} ${formatChartValue(point.y, formatY)}`;
9263
+ }
9264
+ function pointDescriptions(points, formatX, formatY, xLabel = "x", yLabel = "y") {
9265
+ return points.map((point, index) => pointDescription(point, index, formatX, formatY, xLabel, yLabel));
9266
+ }
8767
9267
  function ScatterPlot({
8768
9268
  points,
8769
9269
  c,
@@ -8780,7 +9280,8 @@ function ScatterPlot({
8780
9280
  formatX = "decimal",
8781
9281
  formatY = "decimal",
8782
9282
  showGrid = true,
8783
- footer
9283
+ footer,
9284
+ ...accessibility
8784
9285
  }) {
8785
9286
  const margin = { top: 20, right: 24, bottom: xAxisLabel ? 46 : 34, left: yAxisLabel ? 54 : 42 };
8786
9287
  const plot = createPlotArea(width, height, margin);
@@ -8797,23 +9298,26 @@ function ScatterPlot({
8797
9298
  return { item, index, point, color: chartColor(item.color, c, index) };
8798
9299
  });
8799
9300
  return ChartFrame({
9301
+ ...accessibility,
9302
+ ariaLabel: accessibility.ariaLabel ?? title ?? "Scatter plot",
9303
+ description: chartDescription(accessibility.description, pointDescriptions(points, formatX, formatY, xAxisLabel, yAxisLabel)),
8800
9304
  c,
8801
9305
  title,
8802
9306
  subtitle,
8803
9307
  width,
8804
9308
  footer,
8805
- children: React12.createElement(
9309
+ children: React13.createElement(
8806
9310
  "div",
8807
9311
  { style: { position: "relative", width, height, display: "flex" } },
8808
- React12.createElement(
9312
+ React13.createElement(
8809
9313
  "svg",
8810
9314
  { width, height, viewBox: `0 0 ${width} ${height}` },
8811
- showGrid && React12.createElement(
9315
+ showGrid && React13.createElement(
8812
9316
  "g",
8813
9317
  {},
8814
9318
  ...xTicks.map((tick) => {
8815
9319
  const x = xInPlot(tick, xDomain, plot);
8816
- return React12.createElement("line", {
9320
+ return React13.createElement("line", {
8817
9321
  key: `x-tick-${tick}`,
8818
9322
  x1: x,
8819
9323
  y1: plot.y,
@@ -8825,7 +9329,7 @@ function ScatterPlot({
8825
9329
  }),
8826
9330
  ...yTicks.map((tick) => {
8827
9331
  const y = yInPlot(tick, yDomain, plot);
8828
- return React12.createElement("line", {
9332
+ return React13.createElement("line", {
8829
9333
  key: `y-tick-${tick}`,
8830
9334
  x1: plot.x,
8831
9335
  y1: y,
@@ -8836,9 +9340,9 @@ function ScatterPlot({
8836
9340
  });
8837
9341
  })
8838
9342
  ),
8839
- React12.createElement("rect", { x: plot.x, y: plot.y, width: plot.innerWidth, height: plot.innerHeight, fill: "transparent", stroke: c.borderLight, strokeWidth: 1.2, rx: 6 }),
9343
+ React13.createElement("rect", { x: plot.x, y: plot.y, width: plot.innerWidth, height: plot.innerHeight, fill: "transparent", stroke: c.borderLight, strokeWidth: 1.2, rx: 6 }),
8840
9344
  ...pointGeometries.map(
8841
- ({ item, index, point, color }) => React12.createElement("circle", {
9345
+ ({ item, index, point, color }) => React13.createElement("circle", {
8842
9346
  key: `${item.label ?? "point"}-${index}`,
8843
9347
  cx: point.x,
8844
9348
  cy: point.y,
@@ -8940,7 +9444,8 @@ function ParetoChart({
8940
9444
  frontierColor,
8941
9445
  showGoal = true,
8942
9446
  goalLabel,
8943
- footer
9447
+ footer,
9448
+ ...accessibility
8944
9449
  }) {
8945
9450
  const margin = { top: 22, right: 26, bottom: xAxisLabel ? 48 : 36, left: yAxisLabel ? 56 : 44 };
8946
9451
  const plot = createPlotArea(width, height, margin);
@@ -8980,6 +9485,15 @@ function ParetoChart({
8980
9485
  const goalYEnd = yObjective === "maximize" ? goalYStart - 26 : goalYStart + 26;
8981
9486
  const arrowSize = 5;
8982
9487
  return ChartFrame({
9488
+ ...accessibility,
9489
+ ariaLabel: accessibility.ariaLabel ?? title ?? "Pareto frontier",
9490
+ description: chartDescription(accessibility.description, [
9491
+ `${xObjective} ${xAxisLabel ?? "x"}, ${yObjective} ${yAxisLabel ?? "y"}`,
9492
+ ...pointGeometries.map(
9493
+ ({ point, index, frontier: frontier2 }) => `${pointDescription(point, index, formatX, formatY, xAxisLabel, yAxisLabel)}, ${frontier2 ? "on the Pareto frontier" : "dominated"}`
9494
+ ),
9495
+ ...pointGeometries.length ? [] : ["No points"]
9496
+ ]),
8983
9497
  c,
8984
9498
  title,
8985
9499
  subtitle,
@@ -8989,18 +9503,18 @@ function ParetoChart({
8989
9503
  { label: "Pareto frontier", color: frontier },
8990
9504
  { label: "dominated", color: "neutral" }
8991
9505
  ],
8992
- children: React12.createElement(
9506
+ children: React13.createElement(
8993
9507
  "div",
8994
9508
  { style: { position: "relative", width, height, display: "flex" } },
8995
- React12.createElement(
9509
+ React13.createElement(
8996
9510
  "svg",
8997
9511
  { width, height, viewBox: `0 0 ${width} ${height}` },
8998
- showGrid && React12.createElement(
9512
+ showGrid && React13.createElement(
8999
9513
  "g",
9000
9514
  {},
9001
9515
  ...xTicks.map((tick) => {
9002
9516
  const x = pointFor(tick, yDomain.min).x;
9003
- return React12.createElement("line", {
9517
+ return React13.createElement("line", {
9004
9518
  key: `pareto-x-grid-${tick}`,
9005
9519
  x1: x,
9006
9520
  y1: plot.y,
@@ -9012,7 +9526,7 @@ function ParetoChart({
9012
9526
  }),
9013
9527
  ...yTicks.map((tick) => {
9014
9528
  const y = yInPlot(tick, yDomain, plot);
9015
- return React12.createElement("line", {
9529
+ return React13.createElement("line", {
9016
9530
  key: `pareto-y-grid-${tick}`,
9017
9531
  x1: plot.x,
9018
9532
  y1: y,
@@ -9023,7 +9537,7 @@ function ParetoChart({
9023
9537
  });
9024
9538
  })
9025
9539
  ),
9026
- React12.createElement("rect", {
9540
+ React13.createElement("rect", {
9027
9541
  x: plot.x,
9028
9542
  y: plot.y,
9029
9543
  width: plot.innerWidth,
@@ -9033,17 +9547,17 @@ function ParetoChart({
9033
9547
  strokeWidth: 1.2,
9034
9548
  rx: 6
9035
9549
  }),
9036
- showGoal && React12.createElement(
9550
+ showGoal && React13.createElement(
9037
9551
  "g",
9038
9552
  { "data-pareto-goal": true, stroke: frontier, fill: "none", strokeWidth: 2, strokeLinecap: "round" },
9039
- React12.createElement("line", { x1: goalXStart, y1: goalY, x2: goalXEnd, y2: goalY }),
9040
- React12.createElement("line", { x1: goalXEnd, y1: goalY, x2: goalXEnd + (xObjective === "minimize" ? arrowSize : -arrowSize), y2: goalY - arrowSize }),
9041
- React12.createElement("line", { x1: goalXEnd, y1: goalY, x2: goalXEnd + (xObjective === "minimize" ? arrowSize : -arrowSize), y2: goalY + arrowSize }),
9042
- React12.createElement("line", { x1: goalXStart, y1: goalYStart, x2: goalXStart, y2: goalYEnd }),
9043
- React12.createElement("line", { x1: goalXStart, y1: goalYEnd, x2: goalXStart - arrowSize, y2: goalYEnd + (yObjective === "maximize" ? arrowSize : -arrowSize) }),
9044
- React12.createElement("line", { x1: goalXStart, y1: goalYEnd, x2: goalXStart + arrowSize, y2: goalYEnd + (yObjective === "maximize" ? arrowSize : -arrowSize) })
9553
+ React13.createElement("line", { x1: goalXStart, y1: goalY, x2: goalXEnd, y2: goalY }),
9554
+ React13.createElement("line", { x1: goalXEnd, y1: goalY, x2: goalXEnd + (xObjective === "minimize" ? arrowSize : -arrowSize), y2: goalY - arrowSize }),
9555
+ React13.createElement("line", { x1: goalXEnd, y1: goalY, x2: goalXEnd + (xObjective === "minimize" ? arrowSize : -arrowSize), y2: goalY + arrowSize }),
9556
+ React13.createElement("line", { x1: goalXStart, y1: goalYStart, x2: goalXStart, y2: goalYEnd }),
9557
+ React13.createElement("line", { x1: goalXStart, y1: goalYEnd, x2: goalXStart - arrowSize, y2: goalYEnd + (yObjective === "maximize" ? arrowSize : -arrowSize) }),
9558
+ React13.createElement("line", { x1: goalXStart, y1: goalYEnd, x2: goalXStart + arrowSize, y2: goalYEnd + (yObjective === "maximize" ? arrowSize : -arrowSize) })
9045
9559
  ),
9046
- frontierPath && React12.createElement("path", {
9560
+ frontierPath && React13.createElement("path", {
9047
9561
  "data-pareto-frontier": true,
9048
9562
  d: frontierPath,
9049
9563
  fill: "none",
@@ -9052,7 +9566,7 @@ function ParetoChart({
9052
9566
  strokeLinecap: "round",
9053
9567
  strokeLinejoin: "round"
9054
9568
  }),
9055
- ...pointGeometries.filter((geometry) => !geometry.frontier).concat(pointGeometries.filter((geometry) => geometry.frontier)).map(({ point, index, x, y, color, frontier: isFrontier }) => React12.createElement("circle", {
9569
+ ...pointGeometries.filter((geometry) => !geometry.frontier).concat(pointGeometries.filter((geometry) => geometry.frontier)).map(({ point, index, x, y, color, frontier: isFrontier }) => React13.createElement("circle", {
9056
9570
  key: `pareto-point-${point.label ?? "point"}-${index}`,
9057
9571
  "data-pareto-status": isFrontier ? "frontier" : "dominated",
9058
9572
  cx: x,
@@ -9128,7 +9642,8 @@ function QuadrantChart({
9128
9642
  formatY = "decimal",
9129
9643
  showTicks = false,
9130
9644
  showGrid = false,
9131
- footer
9645
+ footer,
9646
+ ...accessibility
9132
9647
  }) {
9133
9648
  const margin = {
9134
9649
  top: 18,
@@ -9159,23 +9674,31 @@ function QuadrantChart({
9159
9674
  color: chartColor(point.color, c, index)
9160
9675
  }));
9161
9676
  return ChartFrame({
9677
+ ...accessibility,
9678
+ ariaLabel: accessibility.ariaLabel ?? title ?? "Quadrant chart",
9679
+ description: chartDescription(accessibility.description, [
9680
+ `Thresholds: ${xAxisLabel ?? "x"} ${formatChartValue(resolvedXThreshold, formatX)}, ${yAxisLabel ?? "y"} ${formatChartValue(resolvedYThreshold, formatY)}`,
9681
+ ...regionEntries.map(({ key, region }) => `${key}: ${region.label}`),
9682
+ ...pointDescriptions(points, formatX, formatY, xAxisLabel, yAxisLabel),
9683
+ ...points.length ? [] : ["No points"]
9684
+ ]),
9162
9685
  c,
9163
9686
  title,
9164
9687
  subtitle,
9165
9688
  width,
9166
9689
  footer,
9167
- children: React12.createElement(
9690
+ children: React13.createElement(
9168
9691
  "div",
9169
9692
  {
9170
9693
  style: { position: "relative", width, height, display: "flex" }
9171
9694
  },
9172
- React12.createElement(
9695
+ React13.createElement(
9173
9696
  "svg",
9174
9697
  { width, height, viewBox: `0 0 ${width} ${height}` },
9175
9698
  ...regionEntries.map(({ key, region, x, y, width: regionWidth, height: regionHeight }, index) => {
9176
9699
  const color = chartColor(region.color, c, index);
9177
9700
  const emphasized = region.emphasis === true;
9178
- return React12.createElement("rect", {
9701
+ return React13.createElement("rect", {
9179
9702
  key: `quadrant-${key}`,
9180
9703
  x,
9181
9704
  y,
@@ -9187,12 +9710,12 @@ function QuadrantChart({
9187
9710
  strokeWidth: emphasized ? 2 : 0
9188
9711
  });
9189
9712
  }),
9190
- showGrid && React12.createElement(
9713
+ showGrid && React13.createElement(
9191
9714
  "g",
9192
9715
  {},
9193
9716
  ...xTicks.map((tick) => {
9194
9717
  const x = xInPlot(tick, xDomain, plot);
9195
- return React12.createElement("line", {
9718
+ return React13.createElement("line", {
9196
9719
  key: `quadrant-x-grid-${tick}`,
9197
9720
  x1: x,
9198
9721
  y1: plot.y,
@@ -9204,7 +9727,7 @@ function QuadrantChart({
9204
9727
  }),
9205
9728
  ...yTicks.map((tick) => {
9206
9729
  const y = yInPlot(tick, yDomain, plot);
9207
- return React12.createElement("line", {
9730
+ return React13.createElement("line", {
9208
9731
  key: `quadrant-y-grid-${tick}`,
9209
9732
  x1: plot.x,
9210
9733
  y1: y,
@@ -9215,7 +9738,7 @@ function QuadrantChart({
9215
9738
  });
9216
9739
  })
9217
9740
  ),
9218
- React12.createElement("rect", {
9741
+ React13.createElement("rect", {
9219
9742
  x: plot.x,
9220
9743
  y: plot.y,
9221
9744
  width: plot.innerWidth,
@@ -9225,7 +9748,7 @@ function QuadrantChart({
9225
9748
  strokeWidth: 1.2,
9226
9749
  rx: 8
9227
9750
  }),
9228
- React12.createElement("line", {
9751
+ React13.createElement("line", {
9229
9752
  x1: midX,
9230
9753
  y1: plot.y,
9231
9754
  x2: midX,
@@ -9233,7 +9756,7 @@ function QuadrantChart({
9233
9756
  stroke: c.borderLight,
9234
9757
  strokeWidth: 1.4
9235
9758
  }),
9236
- React12.createElement("line", {
9759
+ React13.createElement("line", {
9237
9760
  x1: plot.x,
9238
9761
  y1: midY,
9239
9762
  x2: plot.right,
@@ -9243,7 +9766,7 @@ function QuadrantChart({
9243
9766
  }),
9244
9767
  ...(showTicks ? xTicks : []).map((tick) => {
9245
9768
  const x = xInPlot(tick, xDomain, plot);
9246
- return React12.createElement("line", {
9769
+ return React13.createElement("line", {
9247
9770
  key: `quadrant-x-tick-${tick}`,
9248
9771
  x1: x,
9249
9772
  y1: plot.bottom,
@@ -9255,7 +9778,7 @@ function QuadrantChart({
9255
9778
  }),
9256
9779
  ...(showTicks ? yTicks : []).map((tick) => {
9257
9780
  const y = yInPlot(tick, yDomain, plot);
9258
- return React12.createElement("line", {
9781
+ return React13.createElement("line", {
9259
9782
  key: `quadrant-y-tick-${tick}`,
9260
9783
  x1: plot.x - 5,
9261
9784
  y1: y,
@@ -9265,7 +9788,7 @@ function QuadrantChart({
9265
9788
  strokeWidth: 1.2
9266
9789
  });
9267
9790
  }),
9268
- ...pointGeometries.map(({ point, index, x, y, color }) => React12.createElement("circle", {
9791
+ ...pointGeometries.map(({ point, index, x, y, color }) => React13.createElement("circle", {
9269
9792
  key: `quadrant-point-${point.label ?? index}`,
9270
9793
  cx: x,
9271
9794
  cy: y,
@@ -9341,7 +9864,8 @@ function IntervalPlot({
9341
9864
  max,
9342
9865
  format = "decimal",
9343
9866
  axisLabel,
9344
- footer
9867
+ footer,
9868
+ ...accessibility
9345
9869
  }) {
9346
9870
  const margin = { top: 22, right: 28, bottom: axisLabel ? 44 : 30, left: 96 };
9347
9871
  const plot = createPlotArea(width, height, margin);
@@ -9362,20 +9886,25 @@ function IntervalPlot({
9362
9886
  };
9363
9887
  });
9364
9888
  return ChartFrame({
9889
+ ...accessibility,
9890
+ ariaLabel: accessibility.ariaLabel ?? title ?? "Interval plot",
9891
+ description: chartDescription(accessibility.description, data.map(
9892
+ (item) => `${item.label}: low ${item.lowLabel ?? formatChartValue(item.low, format)}, midpoint ${item.midLabel ?? formatChartValue(item.mid, format)}, high ${item.highLabel ?? formatChartValue(item.high, format)}`
9893
+ )),
9365
9894
  c,
9366
9895
  title,
9367
9896
  subtitle,
9368
9897
  width,
9369
9898
  footer,
9370
- children: React12.createElement(
9899
+ children: React13.createElement(
9371
9900
  "div",
9372
9901
  { style: { position: "relative", width, height, display: "flex" } },
9373
- React12.createElement(
9902
+ React13.createElement(
9374
9903
  "svg",
9375
9904
  { width, height, viewBox: `0 0 ${width} ${height}` },
9376
9905
  ...ticks.map((tick) => {
9377
9906
  const x = scaleX(tick);
9378
- return React12.createElement("line", {
9907
+ return React13.createElement("line", {
9379
9908
  key: `interval-tick-${tick}`,
9380
9909
  x1: x,
9381
9910
  y1: plot.y,
@@ -9385,10 +9914,10 @@ function IntervalPlot({
9385
9914
  strokeWidth: 1
9386
9915
  });
9387
9916
  }),
9388
- React12.createElement("line", { x1: plot.x, y1: plot.bottom, x2: plot.right, y2: plot.bottom, stroke: c.borderLight, strokeWidth: 1.2 }),
9917
+ React13.createElement("line", { x1: plot.x, y1: plot.bottom, x2: plot.right, y2: plot.bottom, stroke: c.borderLight, strokeWidth: 1.2 }),
9389
9918
  ...rows.flatMap(({ item, index, y, color, lowX, midX, highX }) => [
9390
- React12.createElement("line", { key: `${item.label}-range-${index}`, x1: lowX, y1: y, x2: highX, y2: y, stroke: color, strokeWidth: 9, strokeLinecap: "round", opacity: 0.9 }),
9391
- React12.createElement("circle", { key: `${item.label}-mid-${index}`, cx: midX, cy: y, r: 10, fill: c.bgCard, stroke: color, strokeWidth: 4 })
9919
+ React13.createElement("line", { key: `${item.label}-range-${index}`, x1: lowX, y1: y, x2: highX, y2: y, stroke: color, strokeWidth: 9, strokeLinecap: "round", opacity: 0.9 }),
9920
+ React13.createElement("circle", { key: `${item.label}-mid-${index}`, cx: midX, cy: y, r: 10, fill: c.bgCard, stroke: color, strokeWidth: 4 })
9392
9921
  ])
9393
9922
  ),
9394
9923
  ...ticks.map((tick, index) => {
@@ -9425,7 +9954,7 @@ function IntervalPlot({
9425
9954
  }
9426
9955
  function Badge({ label, c, color = "primary" }) {
9427
9956
  const solidColor = getReadableColor(color, c);
9428
- return React12.createElement("div", {
9957
+ return React13.createElement("div", {
9429
9958
  style: {
9430
9959
  display: "flex",
9431
9960
  alignItems: "center",
@@ -9446,7 +9975,7 @@ function DotPoint({ x, y, label, color, c, size = 12, labelOffset }) {
9446
9975
  const offY = labelOffset?.y ?? -22;
9447
9976
  return [
9448
9977
  // Dot
9449
- React12.createElement("div", {
9978
+ React13.createElement("div", {
9450
9979
  key: `dot-${label}`,
9451
9980
  style: {
9452
9981
  position: "absolute",
@@ -9461,7 +9990,7 @@ function DotPoint({ x, y, label, color, c, size = 12, labelOffset }) {
9461
9990
  }
9462
9991
  }),
9463
9992
  // Label
9464
- React12.createElement("div", {
9993
+ React13.createElement("div", {
9465
9994
  key: `label-${label}`,
9466
9995
  style: {
9467
9996
  position: "absolute",
@@ -9487,7 +10016,7 @@ function DashedLine({ x1, y1, x2, y2, color, dotSpacing = 8, dotSize = 2 }) {
9487
10016
  if (i % 2 === 1) continue;
9488
10017
  const t = i / numDots;
9489
10018
  dots.push(
9490
- React12.createElement("div", {
10019
+ React13.createElement("div", {
9491
10020
  key: `dash-${i}`,
9492
10021
  style: {
9493
10022
  position: "absolute",
@@ -9504,7 +10033,7 @@ function DashedLine({ x1, y1, x2, y2, color, dotSpacing = 8, dotSize = 2 }) {
9504
10033
  return dots;
9505
10034
  }
9506
10035
  function Legend({ items, c, title }) {
9507
- return React12.createElement(
10036
+ return React13.createElement(
9508
10037
  "div",
9509
10038
  {
9510
10039
  style: {
@@ -9517,7 +10046,7 @@ function Legend({ items, c, title }) {
9517
10046
  padding: `${densityOf(c).s(14)}px ${densityOf(c).s(16)}px`
9518
10047
  }
9519
10048
  },
9520
- title && React12.createElement("div", {
10049
+ title && React13.createElement("div", {
9521
10050
  style: {
9522
10051
  fontSize: densityOf(c).f(11),
9523
10052
  fontWeight: 700,
@@ -9528,13 +10057,13 @@ function Legend({ items, c, title }) {
9528
10057
  }
9529
10058
  }, title),
9530
10059
  ...items.map(
9531
- (item, i) => React12.createElement(
10060
+ (item, i) => React13.createElement(
9532
10061
  "div",
9533
10062
  {
9534
10063
  key: `legend-${i}`,
9535
10064
  style: { display: "flex", alignItems: "center", gap: 8 }
9536
10065
  },
9537
- React12.createElement("div", {
10066
+ React13.createElement("div", {
9538
10067
  style: {
9539
10068
  width: 16,
9540
10069
  height: item.style === "dashed" ? 0 : 2,
@@ -9544,7 +10073,7 @@ function Legend({ items, c, title }) {
9544
10073
  } : {}
9545
10074
  }
9546
10075
  }),
9547
- React12.createElement("div", {
10076
+ React13.createElement("div", {
9548
10077
  style: {
9549
10078
  fontSize: densityOf(c).f(11),
9550
10079
  color: c.textMuted,
@@ -9557,7 +10086,7 @@ function Legend({ items, c, title }) {
9557
10086
  }
9558
10087
 
9559
10088
  // src/primitives/board.ts
9560
- import React13 from "react";
10089
+ import React14 from "react";
9561
10090
  var CANVAS_ITEM_COMPONENT = /* @__PURE__ */ Symbol.for("vizmatic.canvas-item");
9562
10091
  function dimension(value, name) {
9563
10092
  if (value !== void 0 && (!Number.isFinite(value) || value <= 0 || value > 8192)) {
@@ -9566,7 +10095,7 @@ function dimension(value, name) {
9566
10095
  return value;
9567
10096
  }
9568
10097
  function Board({ children, c, width = 960, height = 540, background }) {
9569
- return React13.createElement("div", { style: {
10098
+ return React14.createElement("div", { style: {
9570
10099
  display: "flex",
9571
10100
  position: "relative",
9572
10101
  width: dimension(width, "Board width"),
@@ -9578,15 +10107,15 @@ function Board({ children, c, width = 960, height = 540, background }) {
9578
10107
  }
9579
10108
  function CanvasItem({ children, x, y, width, height }) {
9580
10109
  if (!Number.isFinite(x) || !Number.isFinite(y)) throw new Error("CanvasItem x and y must be finite numbers.");
9581
- const sizedChildren = React13.Children.map(children, (child) => {
9582
- if (!React13.isValidElement(child)) return child;
10110
+ const sizedChildren = React14.Children.map(children, (child) => {
10111
+ if (!React14.isValidElement(child)) return child;
9583
10112
  if (width !== void 0 && height !== void 0 && isCanvasChart(child.type)) {
9584
- const chart = React13.cloneElement(child, { width: child.props.width ?? width, height: child.props.height ?? height });
9585
- return React13.createElement(CanvasChartFit, { width, height, __vizmaticTextScope: child.props.__vizmaticTextScope }, chart);
10113
+ const chart = React14.cloneElement(child, { width: child.props.width ?? width, height: child.props.height ?? height });
10114
+ return React14.createElement(CanvasChartFit, { width, height, __vizmaticTextScope: child.props.__vizmaticTextScope }, chart);
9586
10115
  }
9587
- return React13.cloneElement(child, { ...width !== void 0 ? { width } : {}, ...height !== void 0 ? { height } : {} });
10116
+ return React14.cloneElement(child, { ...width !== void 0 ? { width } : {}, ...height !== void 0 ? { height } : {} });
9588
10117
  });
9589
- return React13.createElement("div", { style: {
10118
+ return React14.createElement("div", { style: {
9590
10119
  display: "flex",
9591
10120
  position: "absolute",
9592
10121
  left: x,
@@ -9599,14 +10128,14 @@ function CanvasItem({ children, x, y, width, height }) {
9599
10128
  Object.defineProperty(CanvasItem, CANVAS_ITEM_COMPONENT, { value: true });
9600
10129
 
9601
10130
  // src/primitives/science-math-physics.ts
9602
- import React14 from "react";
10131
+ import React15 from "react";
9603
10132
  var MAX_SVG_SIZE = 4096;
9604
10133
  var FONT_SIZE = 13;
9605
10134
  function finite(value, name) {
9606
10135
  if (!Number.isFinite(value)) throw new TypeError(`${name} must be finite.`);
9607
10136
  return value;
9608
10137
  }
9609
- function positive(value, name) {
10138
+ function positive2(value, name) {
9610
10139
  finite(value, name);
9611
10140
  if (value <= 0) throw new RangeError(`${name} must be greater than zero.`);
9612
10141
  return value;
@@ -9671,14 +10200,14 @@ function svgShell({ c, width, height, title, ariaLabel, description, children })
9671
10200
  const d = densityOf(c);
9672
10201
  const overlays = [];
9673
10202
  const svgChildren = [
9674
- React14.createElement("title", { key: "title" }, title),
9675
- React14.createElement("desc", { key: "description" }, description)
10203
+ React15.createElement("title", { key: "title" }, title),
10204
+ React15.createElement("desc", { key: "description" }, description)
9676
10205
  ];
9677
10206
  for (const [index, child] of children.entries()) {
9678
- if (React14.isValidElement(child) && child.type === "text") {
10207
+ if (React15.isValidElement(child) && child.type === "text") {
9679
10208
  const textProps = child.props;
9680
- const text = React14.Children.toArray(textProps.children).map((part) => String(part)).join("");
9681
- overlays.push(React14.createElement(SvgMathText, {
10209
+ const text = React15.Children.toArray(textProps.children).map((part) => String(part)).join("");
10210
+ overlays.push(React15.createElement(SvgMathText, {
9682
10211
  key: `label-${index}`,
9683
10212
  text,
9684
10213
  x: textProps.x,
@@ -9695,7 +10224,7 @@ function svgShell({ c, width, height, title, ariaLabel, description, children })
9695
10224
  }
9696
10225
  }
9697
10226
  if (!UNNAMED_TITLES.has(title)) {
9698
- overlays.unshift(React14.createElement(SvgMathText, {
10227
+ overlays.unshift(React15.createElement(SvgMathText, {
9699
10228
  key: "diagram-title",
9700
10229
  text: title,
9701
10230
  x: 0,
@@ -9708,7 +10237,7 @@ function svgShell({ c, width, height, title, ariaLabel, description, children })
9708
10237
  dominantBaseline: "auto"
9709
10238
  }));
9710
10239
  }
9711
- return React14.createElement(
10240
+ return React15.createElement(
9712
10241
  "div",
9713
10242
  {
9714
10243
  role: "img",
@@ -9716,7 +10245,7 @@ function svgShell({ c, width, height, title, ariaLabel, description, children })
9716
10245
  "aria-description": description,
9717
10246
  style: { position: "relative", width, height, display: "flex", flexShrink: 0 }
9718
10247
  },
9719
- React14.createElement("svg", {
10248
+ React15.createElement("svg", {
9720
10249
  width,
9721
10250
  height,
9722
10251
  viewBox: `0 0 ${width} ${height}`,
@@ -9737,7 +10266,7 @@ function mapNumberLine(value, min, max, width, padding = 56) {
9737
10266
  finite(width, "NumberLine width");
9738
10267
  finite(padding, "NumberLine padding");
9739
10268
  if (padding < 0) throw new RangeError("NumberLine padding cannot be negative.");
9740
- positive(width - padding * 2, "NumberLine drawable width");
10269
+ positive2(width - padding * 2, "NumberLine drawable width");
9741
10270
  if (value < min || value > max) throw new RangeError("NumberLine value must lie within its domain.");
9742
10271
  return padding + (value - min) / range * (width - padding * 2);
9743
10272
  }
@@ -9790,9 +10319,9 @@ function NumberLine({
9790
10319
  const x = (value) => mapNumberLine(value, min, max, width);
9791
10320
  const axisY = Math.round(height * (interval && height < 220 ? 0.45 : 0.56));
9792
10321
  const elements = [
9793
- React14.createElement("line", { key: "axis", x1: 56, y1: axisY, x2: width - 56, y2: axisY, stroke: c.textSecondary, strokeWidth: densityOf(c).w(2) }),
9794
- React14.createElement("path", { key: "left-arrow", d: `M 56 ${axisY} l 9 -5 v 10 z`, fill: c.textSecondary }),
9795
- React14.createElement("path", { key: "right-arrow", d: `M ${width - 56} ${axisY} l -9 -5 v 10 z`, fill: c.textSecondary })
10322
+ React15.createElement("line", { key: "axis", x1: 56, y1: axisY, x2: width - 56, y2: axisY, stroke: c.textSecondary, strokeWidth: densityOf(c).w(2) }),
10323
+ React15.createElement("path", { key: "left-arrow", d: `M 56 ${axisY} l 9 -5 v 10 z`, fill: c.textSecondary }),
10324
+ React15.createElement("path", { key: "right-arrow", d: `M ${width - 56} ${axisY} l -9 -5 v 10 z`, fill: c.textSecondary })
9796
10325
  ];
9797
10326
  if (interval) {
9798
10327
  const fromX = x(interval.from);
@@ -9802,21 +10331,21 @@ function NumberLine({
9802
10331
  const includeTo = interval.includeTo !== false;
9803
10332
  const intervalY = axisY + 52;
9804
10333
  elements.push(
9805
- React14.createElement("line", { key: "interval", x1: fromX, y1: intervalY, x2: toX, y2: intervalY, stroke: color, strokeWidth: densityOf(c).w(8), strokeLinecap: "round", opacity: 0.62 }),
9806
- React14.createElement("circle", { key: "interval-from", cx: fromX, cy: intervalY, r: 7, fill: includeFrom ? color : c.bgSubtle, stroke: color, strokeWidth: densityOf(c).w(3) }),
9807
- React14.createElement("circle", { key: "interval-to", cx: toX, cy: intervalY, r: 7, fill: includeTo ? color : c.bgSubtle, stroke: color, strokeWidth: densityOf(c).w(3) })
10334
+ React15.createElement("line", { key: "interval", x1: fromX, y1: intervalY, x2: toX, y2: intervalY, stroke: color, strokeWidth: densityOf(c).w(8), strokeLinecap: "round", opacity: 0.62 }),
10335
+ React15.createElement("circle", { key: "interval-from", cx: fromX, cy: intervalY, r: 7, fill: includeFrom ? color : c.bgSubtle, stroke: color, strokeWidth: densityOf(c).w(3) }),
10336
+ React15.createElement("circle", { key: "interval-to", cx: toX, cy: intervalY, r: 7, fill: includeTo ? color : c.bgSubtle, stroke: color, strokeWidth: densityOf(c).w(3) })
9808
10337
  );
9809
10338
  if (interval.label) {
9810
10339
  const label = interval.label;
9811
10340
  const labelX = clamp2((fromX + toX) / 2, 56 + textWidth(label) / 2, width - 56 - textWidth(label) / 2);
9812
- elements.push(React14.createElement("text", { key: "interval-label", x: labelX, y: axisY + 82, textAnchor: "middle", fill: c.textSecondary, fontFamily: c.fontSans, fontSize: FONT_SIZE }, label));
10341
+ elements.push(React15.createElement("text", { key: "interval-label", x: labelX, y: axisY + 82, textAnchor: "middle", fill: c.textSecondary, fontFamily: c.fontSans, fontSize: FONT_SIZE }, label));
9813
10342
  }
9814
10343
  }
9815
10344
  for (const [index, tick] of resolvedTicks.entries()) {
9816
10345
  const tickX = x(tick.value);
9817
10346
  elements.push(
9818
- React14.createElement("line", { key: `tick-${index}`, x1: tickX, y1: axisY - 9, x2: tickX, y2: axisY + 9, stroke: c.textSecondary, strokeWidth: densityOf(c).w(2) }),
9819
- React14.createElement("text", { key: `tick-label-${index}`, x: tickX, y: axisY + 34, textAnchor: "middle", fill: c.textSecondary, fontFamily: c.fontMono, fontSize: 12 }, tick.label ?? formatNumber(tick.value))
10347
+ React15.createElement("line", { key: `tick-${index}`, x1: tickX, y1: axisY - 9, x2: tickX, y2: axisY + 9, stroke: c.textSecondary, strokeWidth: densityOf(c).w(2) }),
10348
+ React15.createElement("text", { key: `tick-label-${index}`, x: tickX, y: axisY + 34, textAnchor: "middle", fill: c.textSecondary, fontFamily: c.fontMono, fontSize: 12 }, tick.label ?? formatNumber(tick.value))
9820
10349
  );
9821
10350
  }
9822
10351
  markers.forEach((marker, index) => {
@@ -9826,9 +10355,9 @@ function NumberLine({
9826
10355
  const labelY = Math.max(66, axisY - 54 - lane * 30);
9827
10356
  const labelX = clamp2(markerX, 56 + textWidth(marker.label, 12) / 2, width - 56 - textWidth(marker.label, 12) / 2);
9828
10357
  elements.push(
9829
- React14.createElement("line", { key: `marker-line-${marker.id}`, x1: markerX, y1: axisY - 4, x2: markerX, y2: labelY + 7, stroke: color, strokeWidth: densityOf(c).w(1.5), strokeDasharray: "4 4", opacity: 0.8 }),
9830
- React14.createElement("circle", { key: `marker-point-${marker.id}`, cx: markerX, cy: axisY, r: 7, fill: color, stroke: c.bgCard, strokeWidth: densityOf(c).w(2) }),
9831
- React14.createElement("text", { key: `marker-label-${marker.id}`, x: labelX, y: labelY, textAnchor: "middle", fill: c.textPrimary, fontFamily: c.fontSans, fontSize: 12, fontWeight: 650 }, marker.label)
10358
+ React15.createElement("line", { key: `marker-line-${marker.id}`, x1: markerX, y1: axisY - 4, x2: markerX, y2: labelY + 7, stroke: color, strokeWidth: densityOf(c).w(1.5), strokeDasharray: "4 4", opacity: 0.8 }),
10359
+ React15.createElement("circle", { key: `marker-point-${marker.id}`, cx: markerX, cy: axisY, r: 7, fill: color, stroke: c.bgCard, strokeWidth: densityOf(c).w(2) }),
10360
+ React15.createElement("text", { key: `marker-label-${marker.id}`, x: labelX, y: labelY, textAnchor: "middle", fill: c.textPrimary, fontFamily: c.fontSans, fontSize: 12, fontWeight: 650 }, marker.label)
9832
10361
  );
9833
10362
  });
9834
10363
  const intervalDescription = interval ? ` The highlighted interval is ${interval.includeFrom === false ? "(" : "["}${formatNumber(interval.from)}, ${formatNumber(interval.to)}${interval.includeTo === false ? ")" : "]"}${interval.label ? `, labeled ${interval.label}` : ""}.` : "";
@@ -9903,7 +10432,7 @@ function GeometryDiagram({
9903
10432
  }
9904
10433
  if (angle.label !== void 0) labelText(angle.label, `GeometryDiagram angle ${index} label`, 32);
9905
10434
  if (angle.radius !== void 0) {
9906
- positive(angle.radius, `GeometryDiagram angle ${index} radius`);
10435
+ positive2(angle.radius, `GeometryDiagram angle ${index} radius`);
9907
10436
  if (angle.radius > 120) throw new RangeError(`GeometryDiagram angle ${index} radius cannot exceed 120 pixels.`);
9908
10437
  }
9909
10438
  colorValue(angle.color, c.accent, `GeometryDiagram angle ${index} color`);
@@ -9933,7 +10462,7 @@ function GeometryDiagram({
9933
10462
  const from = map(pointById.get(segment.from));
9934
10463
  const to = map(pointById.get(segment.to));
9935
10464
  const color = colorValue(segment.color, c.secondary, `GeometryDiagram segment ${index} color`);
9936
- elements.push(React14.createElement("line", {
10465
+ elements.push(React15.createElement("line", {
9937
10466
  key: `segment-${index}`,
9938
10467
  x1: from.x,
9939
10468
  y1: from.y,
@@ -9956,7 +10485,7 @@ function GeometryDiagram({
9956
10485
  const clearance = 8 + Math.abs(normalX) * halfWidth + Math.abs(normalY) * FONT_SIZE * 0.45;
9957
10486
  const labelX = clamp2(midX + normalX * clearance, 24 + halfWidth, width - 24 - halfWidth);
9958
10487
  const labelY = clamp2(midY + normalY * clearance + FONT_SIZE * 0.35, 58, height - 22);
9959
- elements.push(React14.createElement("text", { key: `segment-label-${index}`, x: labelX, y: labelY, textAnchor: "middle", fill: c.textSecondary, fontFamily: c.fontSans, fontSize: FONT_SIZE }, segment.label));
10488
+ elements.push(React15.createElement("text", { key: `segment-label-${index}`, x: labelX, y: labelY, textAnchor: "middle", fill: c.textSecondary, fontFamily: c.fontSans, fontSize: FONT_SIZE }, segment.label));
9960
10489
  }
9961
10490
  });
9962
10491
  angles.forEach((angle, index) => {
@@ -9975,17 +10504,17 @@ function GeometryDiagram({
9975
10504
  });
9976
10505
  const path = arc.map((point, part) => `${part === 0 ? "M" : "L"} ${point.x.toFixed(2)} ${point.y.toFixed(2)}`).join(" ");
9977
10506
  const color = colorValue(angle.color, c.accent, `GeometryDiagram angle ${index} color`);
9978
- elements.push(React14.createElement("path", { key: `angle-${index}`, d: path, fill: "none", stroke: color, strokeWidth: densityOf(c).w(2.5), strokeLinecap: "round" }));
10507
+ elements.push(React15.createElement("path", { key: `angle-${index}`, d: path, fill: "none", stroke: color, strokeWidth: densityOf(c).w(2.5), strokeLinecap: "round" }));
9979
10508
  if (angle.label) {
9980
10509
  const middle = a1 + delta / 2;
9981
10510
  const labelX = clamp2(v.x + (radius + 18) * Math.cos(middle), 28 + textWidth(angle.label) / 2, width - 28 - textWidth(angle.label) / 2);
9982
10511
  const labelY = clamp2(v.y - (radius + 18) * Math.sin(middle) + 4, 58, height - 20);
9983
- elements.push(React14.createElement("text", { key: `angle-label-${index}`, x: labelX, y: labelY, textAnchor: "middle", fill: c.textPrimary, fontFamily: c.fontSans, fontSize: FONT_SIZE, fontWeight: 650 }, angle.label));
10512
+ elements.push(React15.createElement("text", { key: `angle-label-${index}`, x: labelX, y: labelY, textAnchor: "middle", fill: c.textPrimary, fontFamily: c.fontSans, fontSize: FONT_SIZE, fontWeight: 650 }, angle.label));
9984
10513
  }
9985
10514
  });
9986
10515
  points.forEach((point) => {
9987
10516
  const position2 = map(point);
9988
- elements.push(React14.createElement("circle", { key: `point-${point.id}`, cx: position2.x, cy: position2.y, r: 5.5, fill: c.primary, stroke: c.bgCard, strokeWidth: densityOf(c).w(2) }));
10517
+ elements.push(React15.createElement("circle", { key: `point-${point.id}`, cx: position2.x, cy: position2.y, r: 5.5, fill: c.primary, stroke: c.bgCard, strokeWidth: densityOf(c).w(2) }));
9989
10518
  if (point.label) {
9990
10519
  const label = point.label;
9991
10520
  const labelWidth = textWidth(label);
@@ -9994,7 +10523,7 @@ function GeometryDiagram({
9994
10523
  const baseX = position2.x + (placeRight ? 12 : -12);
9995
10524
  const labelX = boundedTextX(baseX, width, label, placeRight ? "start" : "end");
9996
10525
  const labelY = clamp2(awayY > 0 ? position2.y + FONT_SIZE + 6 : position2.y - 10, 58, height - 20);
9997
- elements.push(React14.createElement("text", {
10526
+ elements.push(React15.createElement("text", {
9998
10527
  key: `point-label-${point.id}`,
9999
10528
  x: labelX,
10000
10529
  y: labelY,
@@ -10054,9 +10583,9 @@ function FreeBodyDiagram({
10054
10583
  if (!Number.isFinite(scale) || scale <= 0) throw new RangeError("FreeBodyDiagram vector magnitudes cannot be mapped into the viewport.");
10055
10584
  const mapVector = (x, y) => ({ x: center2.x + x * scale, y: center2.y - y * scale });
10056
10585
  const elements = [
10057
- React14.createElement("line", { key: "x-axis", x1: center2.x - available - 28, y1: center2.y, x2: center2.x + available + 28, y2: center2.y, stroke: c.borderSubtle, strokeWidth: densityOf(c).w(1.3) }),
10058
- React14.createElement("line", { key: "y-axis", x1: center2.x, y1: center2.y - available - 28, x2: center2.x, y2: center2.y + available + 28, stroke: c.borderSubtle, strokeWidth: densityOf(c).w(1.3) }),
10059
- React14.createElement("circle", { key: "body", cx: center2.x, cy: center2.y, r: 6, fill: c.bgCard, stroke: c.textPrimary, strokeWidth: densityOf(c).w(2) })
10586
+ React15.createElement("line", { key: "x-axis", x1: center2.x - available - 28, y1: center2.y, x2: center2.x + available + 28, y2: center2.y, stroke: c.borderSubtle, strokeWidth: densityOf(c).w(1.3) }),
10587
+ React15.createElement("line", { key: "y-axis", x1: center2.x, y1: center2.y - available - 28, x2: center2.x, y2: center2.y + available + 28, stroke: c.borderSubtle, strokeWidth: densityOf(c).w(1.3) }),
10588
+ React15.createElement("circle", { key: "body", cx: center2.x, cy: center2.y, r: 6, fill: c.bgCard, stroke: c.textPrimary, strokeWidth: densityOf(c).w(2) })
10060
10589
  ];
10061
10590
  forces.forEach((force) => {
10062
10591
  const color = colorValue(force.color, c.secondary, `FreeBodyDiagram force "${force.id}" color`);
@@ -10064,15 +10593,15 @@ function FreeBodyDiagram({
10064
10593
  if (showComponents) {
10065
10594
  const xEnd = mapVector(force.x, 0);
10066
10595
  const yStart = mapVector(force.x, 0);
10067
- if (force.x !== 0) elements.push(React14.createElement("line", { key: `component-x-${force.id}`, x1: center2.x, y1: center2.y, x2: xEnd.x, y2: xEnd.y, stroke: color, strokeWidth: densityOf(c).w(1.6), strokeDasharray: "5 5", opacity: 0.56 }));
10068
- if (force.y !== 0) elements.push(React14.createElement("line", { key: `component-y-${force.id}`, x1: yStart.x, y1: yStart.y, x2: end.x, y2: end.y, stroke: color, strokeWidth: densityOf(c).w(1.6), strokeDasharray: "5 5", opacity: 0.56 }));
10596
+ if (force.x !== 0) elements.push(React15.createElement("line", { key: `component-x-${force.id}`, x1: center2.x, y1: center2.y, x2: xEnd.x, y2: xEnd.y, stroke: color, strokeWidth: densityOf(c).w(1.6), strokeDasharray: "5 5", opacity: 0.56 }));
10597
+ if (force.y !== 0) elements.push(React15.createElement("line", { key: `component-y-${force.id}`, x1: yStart.x, y1: yStart.y, x2: end.x, y2: end.y, stroke: color, strokeWidth: densityOf(c).w(1.6), strokeDasharray: "5 5", opacity: 0.56 }));
10069
10598
  }
10070
10599
  elements.push(arrow(center2, end, color, `force-${force.id}`, 3));
10071
10600
  const direction = Math.sign(end.x - center2.x) || 1;
10072
10601
  const anchor = direction > 0 ? "start" : "end";
10073
10602
  const labelX = boundedTextX(end.x + direction * 12, width, force.label, anchor, 20);
10074
10603
  const labelY = clamp2(end.y - 11, 60, height - 20);
10075
- elements.push(React14.createElement("text", { key: `force-label-${force.id}`, x: labelX, y: labelY, textAnchor: anchor, fill: c.textPrimary, fontFamily: c.fontSans, fontSize: FONT_SIZE, fontWeight: 650 }, force.label));
10604
+ elements.push(React15.createElement("text", { key: `force-label-${force.id}`, x: labelX, y: labelY, textAnchor: anchor, fill: c.textPrimary, fontFamily: c.fontSans, fontSize: FONT_SIZE, fontWeight: 650 }, force.label));
10076
10605
  });
10077
10606
  if (showResultant && (resultant.x !== 0 || resultant.y !== 0)) {
10078
10607
  const end = mapVector(resultant.x, resultant.y);
@@ -10080,7 +10609,7 @@ function FreeBodyDiagram({
10080
10609
  const label = `R = ${formatNumber(resultant.magnitude)}`;
10081
10610
  const direction = Math.sign(end.x - center2.x) || 1;
10082
10611
  const anchor = direction > 0 ? "start" : "end";
10083
- elements.push(React14.createElement("text", {
10612
+ elements.push(React15.createElement("text", {
10084
10613
  key: "resultant-label",
10085
10614
  x: boundedTextX(end.x + direction * 12, width, label, anchor, 20),
10086
10615
  y: clamp2(end.y + 20, 60, height - 20),
@@ -10091,11 +10620,11 @@ function FreeBodyDiagram({
10091
10620
  fontWeight: 700
10092
10621
  }, label));
10093
10622
  } else if (showResultant) {
10094
- elements.push(React14.createElement("text", { key: "zero-resultant", x: center2.x + 38, y: center2.y + 38, fill: c.textPrimary, fontFamily: c.fontSans, fontSize: FONT_SIZE, fontWeight: 700 }, "R = 0"));
10623
+ elements.push(React15.createElement("text", { key: "zero-resultant", x: center2.x + 38, y: center2.y + 38, fill: c.textPrimary, fontFamily: c.fontSans, fontSize: FONT_SIZE, fontWeight: 700 }, "R = 0"));
10095
10624
  }
10096
10625
  elements.push(
10097
- React14.createElement("text", { key: "positive-x", x: width - 42, y: center2.y - 8, textAnchor: "end", fill: c.textSecondary, fontFamily: c.fontMono, fontSize: 12 }, "+x"),
10098
- React14.createElement("text", { key: "positive-y", x: center2.x - 12, y: 72, textAnchor: "end", fill: c.textSecondary, fontFamily: c.fontMono, fontSize: 12 }, "+y")
10626
+ React15.createElement("text", { key: "positive-x", x: width - 42, y: center2.y - 8, textAnchor: "end", fill: c.textSecondary, fontFamily: c.fontMono, fontSize: 12 }, "+x"),
10627
+ React15.createElement("text", { key: "positive-y", x: center2.x - 12, y: 72, textAnchor: "end", fill: c.textSecondary, fontFamily: c.fontMono, fontSize: 12 }, "+y")
10099
10628
  );
10100
10629
  return svgShell({ c, width, height, title, ariaLabel, description: `${forces.length} physical force vectors use one scale. The resultant is the vector sum ${formatNumber(resultant.x)} x plus ${formatNumber(resultant.y)} y. The vertical axis points upward in physical coordinates.`, children: elements });
10101
10630
  }
@@ -10107,20 +10636,20 @@ function arrow(start, end, color, key, strokeWidth) {
10107
10636
  const angle = Math.atan2(dy, dx);
10108
10637
  const left = { x: end.x - head * Math.cos(angle - Math.PI / 6), y: end.y - head * Math.sin(angle - Math.PI / 6) };
10109
10638
  const right = { x: end.x - head * Math.cos(angle + Math.PI / 6), y: end.y - head * Math.sin(angle + Math.PI / 6) };
10110
- return React14.createElement(
10639
+ return React15.createElement(
10111
10640
  "g",
10112
10641
  {
10113
10642
  key,
10114
10643
  "data-vector-role": key === "resultant" ? "resultant" : "force",
10115
10644
  "data-vector-id": key.startsWith("force-") ? key.slice("force-".length) : void 0
10116
10645
  },
10117
- React14.createElement("line", { x1: start.x, y1: start.y, x2: end.x, y2: end.y, stroke: color, strokeWidth, strokeLinecap: "round" }),
10118
- React14.createElement("path", { d: `M ${left.x} ${left.y} L ${end.x} ${end.y} L ${right.x} ${right.y}`, fill: "none", stroke: color, strokeWidth, strokeLinecap: "round", strokeLinejoin: "round" })
10646
+ React15.createElement("line", { x1: start.x, y1: start.y, x2: end.x, y2: end.y, stroke: color, strokeWidth, strokeLinecap: "round" }),
10647
+ React15.createElement("path", { d: `M ${left.x} ${left.y} L ${end.x} ${end.y} L ${right.x} ${right.y}`, fill: "none", stroke: color, strokeWidth, strokeLinecap: "round", strokeLinejoin: "round" })
10119
10648
  );
10120
10649
  }
10121
10650
  function validateWave(wave, index, c) {
10122
- positive(wave.amplitude, `WaveDiagram wave ${index} amplitude`);
10123
- positive(wave.wavelength, `WaveDiagram wave ${index} wavelength`);
10651
+ positive2(wave.amplitude, `WaveDiagram wave ${index} amplitude`);
10652
+ positive2(wave.wavelength, `WaveDiagram wave ${index} wavelength`);
10124
10653
  finite(wave.phase ?? 0, `WaveDiagram wave ${index} phase`);
10125
10654
  finite(wave.speed ?? 0, `WaveDiagram wave ${index} speed`);
10126
10655
  if (wave.label !== void 0) labelText(wave.label, `WaveDiagram wave ${index} label`, 22);
@@ -10215,28 +10744,28 @@ function WaveDiagram({
10215
10744
  const gridX = sx(xValue);
10216
10745
  const gridY = sy(yValue);
10217
10746
  elements.push(
10218
- React14.createElement("line", { key: `grid-x-${index}`, x1: gridX, y1: plot.top, x2: gridX, y2: plot.bottom, stroke: c.borderSubtle, strokeWidth: densityOf(c).w(1) }),
10219
- React14.createElement("line", { key: `grid-y-${index}`, x1: plot.left, y1: gridY, x2: plot.right, y2: gridY, stroke: c.borderSubtle, strokeWidth: densityOf(c).w(1) }),
10220
- React14.createElement("text", { key: `x-label-${index}`, x: gridX, y: plot.bottom + 22, textAnchor: "middle", fill: c.textSecondary, fontFamily: c.fontMono, fontSize: 11 }, formatNumber(xValue)),
10221
- React14.createElement("text", { key: `y-label-${index}`, x: plot.left - 10, y: gridY + 4, textAnchor: "end", fill: c.textSecondary, fontFamily: c.fontMono, fontSize: 11 }, formatNumber(yValue))
10747
+ React15.createElement("line", { key: `grid-x-${index}`, x1: gridX, y1: plot.top, x2: gridX, y2: plot.bottom, stroke: c.borderSubtle, strokeWidth: densityOf(c).w(1) }),
10748
+ React15.createElement("line", { key: `grid-y-${index}`, x1: plot.left, y1: gridY, x2: plot.right, y2: gridY, stroke: c.borderSubtle, strokeWidth: densityOf(c).w(1) }),
10749
+ React15.createElement("text", { key: `x-label-${index}`, x: gridX, y: plot.bottom + 22, textAnchor: "middle", fill: c.textSecondary, fontFamily: c.fontMono, fontSize: 11 }, formatNumber(xValue)),
10750
+ React15.createElement("text", { key: `y-label-${index}`, x: plot.left - 10, y: gridY + 4, textAnchor: "end", fill: c.textSecondary, fontFamily: c.fontMono, fontSize: 11 }, formatNumber(yValue))
10222
10751
  );
10223
10752
  }
10224
10753
  elements.push(
10225
- React14.createElement("line", { key: "x-axis", x1: plot.left, y1: sy(0), x2: plot.right, y2: sy(0), stroke: c.textSecondary, strokeWidth: densityOf(c).w(1.7) }),
10226
- React14.createElement("line", { key: "y-axis", x1: plot.left, y1: plot.top, x2: plot.left, y2: plot.bottom, stroke: c.textSecondary, strokeWidth: densityOf(c).w(1.7) }),
10227
- React14.createElement("text", { key: "axis-x-label", x: plot.right, y: height - 18, textAnchor: "end", fill: c.textSecondary, fontFamily: c.fontSans, fontSize: 12 }, "position x"),
10228
- React14.createElement("text", { key: "axis-y-label", x: plot.left + 8, y: plot.top - 9, fill: c.textSecondary, fontFamily: c.fontSans, fontSize: 12 }, "displacement y"),
10229
- React14.createElement("text", { key: "time-label", x: 24, y: 60, fill: c.textSecondary, fontFamily: c.fontMono, fontSize: 12 }, `t = ${formatNumber(time)}`)
10754
+ React15.createElement("line", { key: "x-axis", x1: plot.left, y1: sy(0), x2: plot.right, y2: sy(0), stroke: c.textSecondary, strokeWidth: densityOf(c).w(1.7) }),
10755
+ React15.createElement("line", { key: "y-axis", x1: plot.left, y1: plot.top, x2: plot.left, y2: plot.bottom, stroke: c.textSecondary, strokeWidth: densityOf(c).w(1.7) }),
10756
+ React15.createElement("text", { key: "axis-x-label", x: plot.right, y: height - 18, textAnchor: "end", fill: c.textSecondary, fontFamily: c.fontSans, fontSize: 12 }, "position x"),
10757
+ React15.createElement("text", { key: "axis-y-label", x: plot.left + 8, y: plot.top - 9, fill: c.textSecondary, fontFamily: c.fontSans, fontSize: 12 }, "displacement y"),
10758
+ React15.createElement("text", { key: "time-label", x: 24, y: 60, fill: c.textSecondary, fontFamily: c.fontMono, fontSize: 12 }, `t = ${formatNumber(time)}`)
10230
10759
  );
10231
10760
  const pathFor = (points) => points.map((point, index) => `${index === 0 ? "M" : "L"} ${sx(point.x).toFixed(2)} ${sy(point.y).toFixed(2)}`).join(" ");
10232
10761
  if (showComponents) {
10233
10762
  samples.forEach((waveSamples, index) => {
10234
10763
  const wave = waves[index];
10235
10764
  const color = colorValue(wave.color, c.secondary, `WaveDiagram wave ${index} color`);
10236
- elements.push(React14.createElement("path", { key: `component-${index}`, d: pathFor(waveSamples), fill: "none", stroke: color, strokeWidth: densityOf(c).w(2), opacity: showSum ? 0.68 : 1, strokeLinecap: "round", strokeLinejoin: "round" }));
10765
+ elements.push(React15.createElement("path", { key: `component-${index}`, d: pathFor(waveSamples), fill: "none", stroke: color, strokeWidth: densityOf(c).w(2), opacity: showSum ? 0.68 : 1, strokeLinecap: "round", strokeLinejoin: "round" }));
10237
10766
  });
10238
10767
  }
10239
- if (showSum) elements.push(React14.createElement("path", { key: "sum", d: pathFor(sumSamples), fill: "none", stroke: c.textPrimary, strokeWidth: densityOf(c).w(3.5), strokeLinecap: "round", strokeLinejoin: "round" }));
10768
+ if (showSum) elements.push(React15.createElement("path", { key: "sum", d: pathFor(sumSamples), fill: "none", stroke: c.textPrimary, strokeWidth: densityOf(c).w(3.5), strokeLinecap: "round", strokeLinejoin: "round" }));
10240
10769
  waves.forEach((wave, index) => {
10241
10770
  const label = wave.label ?? `wave ${index + 1}`;
10242
10771
  const color = colorValue(wave.color, c.secondary, `WaveDiagram wave ${index} color`);
@@ -10244,7 +10773,7 @@ function WaveDiagram({
10244
10773
  const row = index % 4;
10245
10774
  const legendX = plot.left + column * (plot.right - plot.left) / 2;
10246
10775
  const legendY = plot.top - 58 + row * 14;
10247
- elements.push(React14.createElement("line", {
10776
+ elements.push(React15.createElement("line", {
10248
10777
  key: `legend-swatch-${index}`,
10249
10778
  x1: legendX,
10250
10779
  y1: legendY - 4,
@@ -10254,7 +10783,7 @@ function WaveDiagram({
10254
10783
  strokeWidth: densityOf(c).w(3),
10255
10784
  strokeLinecap: "round"
10256
10785
  }));
10257
- elements.push(React14.createElement("text", {
10786
+ elements.push(React15.createElement("text", {
10258
10787
  key: `legend-${index}`,
10259
10788
  x: boundedTextX(legendX + 16, width, label, "start", 20, 11),
10260
10789
  y: legendY,
@@ -10264,15 +10793,15 @@ function WaveDiagram({
10264
10793
  fontWeight: 650
10265
10794
  }, label));
10266
10795
  });
10267
- if (showSum) elements.push(React14.createElement("text", { key: "sum-legend", x: width - 24, y: 60, textAnchor: "end", fill: c.textPrimary, fontFamily: c.fontSans, fontSize: 12, fontWeight: 750 }, "sum"));
10796
+ if (showSum) elements.push(React15.createElement("text", { key: "sum-legend", x: width - 24, y: 60, textAnchor: "end", fill: c.textPrimary, fontFamily: c.fontSans, fontSize: 12, fontWeight: 750 }, "sum"));
10268
10797
  if (probeX !== void 0) {
10269
10798
  const probeY = waves.reduce((sum, wave) => sum + waveValue(wave, probeX, time), 0);
10270
10799
  const probePosition = { x: sx(probeX), y: sy(probeY) };
10271
10800
  const label = `\u03A3y = ${formatNumber(probeY)}`;
10272
10801
  elements.push(
10273
- React14.createElement("line", { key: "probe-line", x1: probePosition.x, y1: plot.top, x2: probePosition.x, y2: plot.bottom, stroke: c.warning, strokeWidth: densityOf(c).w(1.5), strokeDasharray: "5 5" }),
10274
- React14.createElement("circle", { key: "probe-point", cx: probePosition.x, cy: probePosition.y, r: 6, fill: c.warning, stroke: c.bgCard, strokeWidth: densityOf(c).w(2) }),
10275
- React14.createElement("text", { key: "probe-label", x: clamp2(probePosition.x + 10, plot.left + 8, plot.right - textWidth(label)), y: clamp2(probePosition.y - 12, plot.top + 40, plot.bottom - 10), fill: c.textPrimary, fontFamily: c.fontSans, fontSize: 12, fontWeight: 650 }, label)
10802
+ React15.createElement("line", { key: "probe-line", x1: probePosition.x, y1: plot.top, x2: probePosition.x, y2: plot.bottom, stroke: c.warning, strokeWidth: densityOf(c).w(1.5), strokeDasharray: "5 5" }),
10803
+ React15.createElement("circle", { key: "probe-point", cx: probePosition.x, cy: probePosition.y, r: 6, fill: c.warning, stroke: c.bgCard, strokeWidth: densityOf(c).w(2) }),
10804
+ React15.createElement("text", { key: "probe-label", x: clamp2(probePosition.x + 10, plot.left + 8, plot.right - textWidth(label)), y: clamp2(probePosition.y - 12, plot.top + 40, plot.bottom - 10), fill: c.textPrimary, fontFamily: c.fontSans, fontSize: 12, fontWeight: 650 }, label)
10276
10805
  );
10277
10806
  }
10278
10807
  const summary = waves.map((wave, index) => `${wave.label ?? `wave ${index + 1}`} (A=${formatNumber(wave.amplitude)}, \u03BB=${formatNumber(wave.wavelength)}, \u03C6=${formatNumber(wave.phase ?? 0)}, v=${formatNumber(wave.speed ?? 0)})`).join("; ");
@@ -10280,9 +10809,9 @@ function WaveDiagram({
10280
10809
  }
10281
10810
 
10282
10811
  // src/primitives/science-chemistry.ts
10283
- import React15 from "react";
10812
+ import React16 from "react";
10284
10813
  function overlayText(key, props) {
10285
- return React15.createElement(React15.Fragment, { key }, SvgMathText(props));
10814
+ return React16.createElement(React16.Fragment, { key }, SvgMathText(props));
10286
10815
  }
10287
10816
  var ELEMENTS = /* @__PURE__ */ new Set([
10288
10817
  "H",
@@ -10534,7 +11063,7 @@ function MoleculeDiagram({
10534
11063
  const bondNodes = bonds.flatMap((bond, bondIndex) => {
10535
11064
  const from = points.get(bond.from);
10536
11065
  const to = points.get(bond.to);
10537
- return bondSegments(from, to, bond.order).map((segment, segmentIndex) => React15.createElement("line", {
11066
+ return bondSegments(from, to, bond.order).map((segment, segmentIndex) => React16.createElement("line", {
10538
11067
  key: `bond-${bondIndex}-${segmentIndex}`,
10539
11068
  x1: segment.x1,
10540
11069
  y1: segment.y1,
@@ -10554,10 +11083,10 @@ function MoleculeDiagram({
10554
11083
  const atomNodes = atoms.map((atom) => {
10555
11084
  const point = points.get(atom.id);
10556
11085
  const accent = atomColor(atom.element, c);
10557
- return React15.createElement(
11086
+ return React16.createElement(
10558
11087
  "g",
10559
11088
  { key: atom.id, "data-atom-id": atom.id, "data-element": atom.element },
10560
- React15.createElement("circle", { cx: point.x, cy: point.y, r: 19, fill: c.bgCard, stroke: accent, strokeWidth: densityOf(c).w(2) })
11089
+ React16.createElement("circle", { cx: point.x, cy: point.y, r: 19, fill: c.bgCard, stroke: accent, strokeWidth: densityOf(c).w(2) })
10561
11090
  );
10562
11091
  });
10563
11092
  const textNodes = atoms.flatMap((atom) => {
@@ -10570,7 +11099,7 @@ function MoleculeDiagram({
10570
11099
  ...atom.label ? [overlayText(`atom-${atom.id}-label`, { text: atom.label, x: point.x, y: labelY, fill: c.textSecondary, fontSize: densityOf(c).f(10), fontFamily: c.fontSans, textAnchor: "middle" })] : []
10571
11100
  ];
10572
11101
  });
10573
- const geometry = React15.createElement(
11102
+ const geometry = React16.createElement(
10574
11103
  "svg",
10575
11104
  {
10576
11105
  width: svgWidth,
@@ -10579,11 +11108,11 @@ function MoleculeDiagram({
10579
11108
  "aria-hidden": true,
10580
11109
  style: { position: "absolute", left: 0, top: 0, display: "block" }
10581
11110
  },
10582
- React15.createElement("rect", { x: 0, y: 0, width: svgWidth, height: svgHeight, rx: 14, fill: c.bgCard, stroke: c.borderSubtle }),
11111
+ React16.createElement("rect", { x: 0, y: 0, width: svgWidth, height: svgHeight, rx: 14, fill: c.bgCard, stroke: c.borderSubtle }),
10583
11112
  ...bondNodes,
10584
11113
  ...atomNodes
10585
11114
  );
10586
- return React15.createElement(
11115
+ return React16.createElement(
10587
11116
  "div",
10588
11117
  {
10589
11118
  role: "img",
@@ -10672,7 +11201,7 @@ function reactionBalance(reactants, products) {
10672
11201
  return { status: balanced ? "balanced" : "unbalanced", balanced, elementDeltas: deltas, chargeDelta };
10673
11202
  }
10674
11203
  function equationTerm(term, index, c) {
10675
- return React15.createElement(
11204
+ return React16.createElement(
10676
11205
  "span",
10677
11206
  {
10678
11207
  key: `term-${index}-${term.formula}`,
@@ -10686,22 +11215,22 @@ function equationTerm(term, index, c) {
10686
11215
  color: c.textPrimary
10687
11216
  }
10688
11217
  },
10689
- term.coefficient && term.coefficient !== 1 ? React15.createElement("span", { style: { color: getReadableColor("primary", c), fontWeight: 700, marginRight: 5 } }, `${term.coefficient}`) : null,
10690
- React15.createElement("span", { style: { overflowWrap: "anywhere" } }, term.formula),
10691
- term.state ? React15.createElement("span", { style: { marginLeft: 5, color: c.textSecondary, fontSize: "0.9em" } }, `(${term.state})`) : null
11218
+ term.coefficient && term.coefficient !== 1 ? React16.createElement("span", { style: { color: getReadableColor("primary", c), fontWeight: 700, marginRight: 5 } }, `${term.coefficient}`) : null,
11219
+ React16.createElement("span", { style: { overflowWrap: "anywhere" } }, term.formula),
11220
+ term.state ? React16.createElement("span", { style: { marginLeft: 5, color: c.textSecondary, fontSize: "0.9em" } }, `(${term.state})`) : null
10692
11221
  );
10693
11222
  }
10694
11223
  function equationSide(terms, label, c) {
10695
11224
  const children = [];
10696
11225
  terms.forEach((term, index) => {
10697
- if (index > 0) children.push(React15.createElement("span", {
11226
+ if (index > 0) children.push(React16.createElement("span", {
10698
11227
  key: `plus-${index}`,
10699
11228
  style: { color: c.textSecondary, padding: "0 7px", flex: "0 0 auto" },
10700
11229
  "aria-hidden": true
10701
11230
  }, "+"));
10702
11231
  children.push(equationTerm(term, index, c));
10703
11232
  });
10704
- return React15.createElement("div", {
11233
+ return React16.createElement("div", {
10705
11234
  role: "group",
10706
11235
  "aria-label": label,
10707
11236
  style: {
@@ -10733,7 +11262,7 @@ function ReactionEquation({
10733
11262
  const balance = reactionBalance(reactants, products);
10734
11263
  const accessibleEquation = `${reactants.map((term) => `${term.coefficient && term.coefficient !== 1 ? `${term.coefficient} ` : ""}${term.formula}${term.state ? ` (${term.state})` : ""}`).join(" + ")} ${reversible ? "reversibly yields" : "yields"} ${products.map((term) => `${term.coefficient && term.coefficient !== 1 ? `${term.coefficient} ` : ""}${term.formula}${term.state ? ` (${term.state})` : ""}`).join(" + ")}`;
10735
11264
  const balanceText = balance.status === "unavailable" ? "Balance unavailable: provide a complete composition map for every term." : balance.balanced ? "Balanced by supplied composition and charge." : `Not balanced by supplied composition and charge: ${Object.entries(balance.elementDeltas).filter(([, delta]) => delta !== 0).map(([element, delta]) => `${element} ${delta > 0 ? "+" : ""}${delta}`).join(", ") || "elements conserved"}, charge ${balance.chargeDelta > 0 ? "+" : ""}${balance.chargeDelta}.`;
10736
- return React15.createElement(
11265
+ return React16.createElement(
10737
11266
  "div",
10738
11267
  {
10739
11268
  role: "img",
@@ -10754,20 +11283,20 @@ function ReactionEquation({
10754
11283
  fontFamily: c.fontSans
10755
11284
  }
10756
11285
  },
10757
- React15.createElement(
11286
+ React16.createElement(
10758
11287
  "div",
10759
11288
  {
10760
11289
  style: { display: "flex", alignItems: "center", gap: 12, minWidth: 0 }
10761
11290
  },
10762
11291
  equationSide(reactants, "Reactants", c),
10763
- React15.createElement("span", {
11292
+ React16.createElement("span", {
10764
11293
  style: { flex: "0 0 auto", color: c.primaryLight, fontSize: densityOf(c).f(26), fontWeight: 700, padding: "0 2px" },
10765
11294
  "aria-hidden": true
10766
11295
  }, reversible ? "\u21CC" : "\u2192"),
10767
11296
  equationSide(products, "Products", c)
10768
11297
  ),
10769
- conditions !== void 0 && conditions.length > 0 ? React15.createElement("div", { style: { color: c.textSecondary, fontSize: densityOf(c).f(13) } }, `Conditions: ${conditions}`) : null,
10770
- React15.createElement("div", {
11298
+ conditions !== void 0 && conditions.length > 0 ? React16.createElement("div", { style: { color: c.textSecondary, fontSize: densityOf(c).f(13) } }, `Conditions: ${conditions}`) : null,
11299
+ React16.createElement("div", {
10771
11300
  style: {
10772
11301
  paddingTop: 8,
10773
11302
  borderTop: `1px solid ${c.borderSubtle}`,
@@ -10803,12 +11332,12 @@ function measurement(x, y1, y2, color, key, label) {
10803
11332
  const top = Math.min(y1, y2);
10804
11333
  const bottom = Math.max(y1, y2);
10805
11334
  const cap = 5;
10806
- return React15.createElement(
11335
+ return React16.createElement(
10807
11336
  "g",
10808
11337
  { key, "data-measurement": label, "aria-hidden": true },
10809
- React15.createElement("line", { x1: x, y1: top, x2: x, y2: bottom, stroke: color, strokeWidth: densityOf().w(1.5), strokeDasharray: "3 3" }),
10810
- React15.createElement("line", { x1: x - cap, y1: top, x2: x + cap, y2: top, stroke: color, strokeWidth: densityOf().w(1.5) }),
10811
- React15.createElement("line", { x1: x - cap, y1: bottom, x2: x + cap, y2: bottom, stroke: color, strokeWidth: densityOf().w(1.5) })
11338
+ React16.createElement("line", { x1: x, y1: top, x2: x, y2: bottom, stroke: color, strokeWidth: densityOf().w(1.5), strokeDasharray: "3 3" }),
11339
+ React16.createElement("line", { x1: x - cap, y1: top, x2: x + cap, y2: top, stroke: color, strokeWidth: densityOf().w(1.5) }),
11340
+ React16.createElement("line", { x1: x - cap, y1: bottom, x2: x + cap, y2: bottom, stroke: color, strokeWidth: densityOf().w(1.5) })
10812
11341
  );
10813
11342
  }
10814
11343
  function ReactionEnergyDiagram({
@@ -10889,19 +11418,19 @@ function ReactionEnergyDiagram({
10889
11418
  const revealWidth = progress === 0 ? 0 : (x1 - x0) * progress + 8;
10890
11419
  const gridValues = [scaleMin, (scaleMin + scaleMax) / 2, scaleMax];
10891
11420
  const svgNodes = [
10892
- React15.createElement("rect", { key: "background", x: 0, y: 0, width: svgWidth, height: svgHeight, rx: 14, fill: c.bgCard, stroke: c.borderSubtle }),
10893
- React15.createElement(
11421
+ React16.createElement("rect", { key: "background", x: 0, y: 0, width: svgWidth, height: svgHeight, rx: 14, fill: c.bgCard, stroke: c.borderSubtle }),
11422
+ React16.createElement(
10894
11423
  "defs",
10895
11424
  { key: "reveal-defs" },
10896
- React15.createElement(
11425
+ React16.createElement(
10897
11426
  "clipPath",
10898
11427
  { id: revealClipId, clipPathUnits: "userSpaceOnUse" },
10899
- React15.createElement("rect", { x: x0 - 4, y: plotTop, width: revealWidth, height: plotBottom - plotTop })
11428
+ React16.createElement("rect", { x: x0 - 4, y: plotTop, width: revealWidth, height: plotBottom - plotTop })
10900
11429
  )
10901
11430
  ),
10902
- React15.createElement("line", { key: "y-axis", x1: plotLeft, y1: plotTop, x2: plotLeft, y2: plotBottom, stroke: c.borderLight, strokeWidth: densityOf(c).w(1.4) }),
10903
- React15.createElement("line", { key: "x-axis", x1: plotLeft, y1: plotBottom, x2: plotRight, y2: plotBottom, stroke: c.borderLight, strokeWidth: densityOf(c).w(1.4) }),
10904
- ...gridValues.map((value, index) => React15.createElement("line", {
11431
+ React16.createElement("line", { key: "y-axis", x1: plotLeft, y1: plotTop, x2: plotLeft, y2: plotBottom, stroke: c.borderLight, strokeWidth: densityOf(c).w(1.4) }),
11432
+ React16.createElement("line", { key: "x-axis", x1: plotLeft, y1: plotBottom, x2: plotRight, y2: plotBottom, stroke: c.borderLight, strokeWidth: densityOf(c).w(1.4) }),
11433
+ ...gridValues.map((value, index) => React16.createElement("line", {
10905
11434
  key: `grid-${index}`,
10906
11435
  x1: plotLeft,
10907
11436
  y1: yFor(value),
@@ -10911,7 +11440,7 @@ function ReactionEnergyDiagram({
10911
11440
  strokeWidth: densityOf(c).w(1),
10912
11441
  strokeDasharray: "3 5"
10913
11442
  })),
10914
- React15.createElement("path", {
11443
+ React16.createElement("path", {
10915
11444
  key: "uncatalyzed-path",
10916
11445
  d: path,
10917
11446
  fill: "none",
@@ -10923,7 +11452,7 @@ function ReactionEnergyDiagram({
10923
11452
  "data-energy-path": "uncatalyzed",
10924
11453
  "data-progress": progress
10925
11454
  }),
10926
- catalyzedPath === void 0 ? null : React15.createElement("path", {
11455
+ catalyzedPath === void 0 ? null : React16.createElement("path", {
10927
11456
  key: "catalyzed-path",
10928
11457
  d: catalyzedPath,
10929
11458
  fill: "none",
@@ -10941,7 +11470,7 @@ function ReactionEnergyDiagram({
10941
11470
  ];
10942
11471
  const overlayNodes = [
10943
11472
  overlayText("title", { text: `${chartTitle} \xB7 ${unit}`, x: svgWidth / 2, y: 24, fill: c.textPrimary, fontSize: densityOf(c).f(16), fontFamily: c.fontSans, fontWeight: 700 }),
10944
- React15.createElement("div", {
11473
+ React16.createElement("div", {
10945
11474
  key: "energy-label",
10946
11475
  style: {
10947
11476
  position: "absolute",
@@ -10963,7 +11492,7 @@ function ReactionEnergyDiagram({
10963
11492
  ...catalyzedActivation === void 0 ? [] : [overlayText("catalyzed-activation-value", { text: `Ea (catalyzed) = ${energyText(catalyzedActivation)} ${unit}`, x: svgWidth / 2, y: svgHeight - 39, fill: getReadableColor("positive", c), fontSize: densityOf(c).f(12), fontFamily: c.fontSans })],
10964
11493
  overlayText("delta-value", { text: `\u0394E = ${signedEnergyText(delta)} ${unit}`, x: svgWidth / 2, y: svgHeight - 21, fill: getReadableColor("secondary", c), fontSize: densityOf(c).f(12), fontFamily: c.fontSans })
10965
11494
  ];
10966
- const geometry = React15.createElement(
11495
+ const geometry = React16.createElement(
10967
11496
  "svg",
10968
11497
  {
10969
11498
  width: svgWidth,
@@ -10974,7 +11503,7 @@ function ReactionEnergyDiagram({
10974
11503
  },
10975
11504
  ...svgNodes
10976
11505
  );
10977
- return React15.createElement("div", {
11506
+ return React16.createElement("div", {
10978
11507
  role: "img",
10979
11508
  "aria-label": ariaLabel ?? `${chartTitle} (${unit})`,
10980
11509
  "aria-description": desc,
@@ -10985,7 +11514,7 @@ function ReactionEnergyDiagram({
10985
11514
  }
10986
11515
 
10987
11516
  // src/primitives/science-ai.ts
10988
- import React16 from "react";
11517
+ import React17 from "react";
10989
11518
 
10990
11519
  // src/teaching-math.ts
10991
11520
  function finite2(value, name) {
@@ -11200,11 +11729,11 @@ function AttentionMatrix({
11200
11729
  const text = (key, value, x, y, size = 14, fill = c.textPrimary, anchor = "middle", background) => {
11201
11730
  const label = SvgMathText({ text: value, x, y, fill, fontSize: size, fontFamily: c.fontSans, fontWeight: 500, textAnchor: anchor, dominantBaseline: "alphabetic" });
11202
11731
  const style = label.props.style;
11203
- return React16.cloneElement(label, { key, ...background ? { style: { ...style, backgroundColor: background } } : {} });
11732
+ return React17.cloneElement(label, { key, ...background ? { style: { ...style, backgroundColor: background } } : {} });
11204
11733
  };
11205
11734
  const marks = [
11206
- React16.createElement("title", { key: "title" }, title),
11207
- React16.createElement("desc", { key: "description" }, "Rows are queries and columns are keys. Visible rows sum to one. Crosses denote masked keys. Values are attention probabilities, not explanations of model reasoning."),
11735
+ React17.createElement("title", { key: "title" }, title),
11736
+ React17.createElement("desc", { key: "description" }, "Rows are queries and columns are keys. Visible rows sum to one. Crosses denote masked keys. Values are attention probabilities, not explanations of model reasoning."),
11208
11737
  text("heading", title, 22, 30, 20, c.textPrimary, "start"),
11209
11738
  text("keys", "KEYS", left + (width - left - right) / 2, 58, 12, c.textSecondary),
11210
11739
  text("query-heading", "QUERY", 22, 81, 12, c.textSecondary, "start"),
@@ -11219,7 +11748,7 @@ function AttentionMatrix({
11219
11748
  const masked = mask?.[i][j] === false;
11220
11749
  const selected = activeQuery === i && (activeKey === void 0 || activeKey === j);
11221
11750
  const fill = masked ? c.bgCardAlt : compositeColor(withColorAlpha(c.primary, 0.12 + 0.88 * weight), c.bg);
11222
- marks.push(React16.createElement("rect", {
11751
+ marks.push(React17.createElement("rect", {
11223
11752
  key: `cell-${i}-${j}`,
11224
11753
  x: x + 2,
11225
11754
  y: y + 2,
@@ -11232,7 +11761,7 @@ function AttentionMatrix({
11232
11761
  }));
11233
11762
  if (masked) {
11234
11763
  const centerX = x + cellWidth / 2, centerY = y + cellHeight / 2;
11235
- marks.push(React16.createElement("path", { key: `mask-${i}-${j}`, d: `M${centerX - 4},${centerY - 4}l8,8m-8,0l8,-8`, stroke: c.textMuted, strokeWidth: 1.4 }));
11764
+ marks.push(React17.createElement("path", { key: `mask-${i}-${j}`, d: `M${centerX - 4},${centerY - 4}l8,8m-8,0l8,-8`, stroke: c.textMuted, strokeWidth: 1.4 }));
11236
11765
  } else {
11237
11766
  const label = weight.toFixed(2);
11238
11767
  if (cellWidth >= 38 && cellHeight >= 24) marks.push(text(`value-${i}-${j}`, label, x + cellWidth / 2, y + cellHeight / 2 + 5, 14, getReadableTextColor(fill, c, c.bg), "middle", fill));
@@ -11242,11 +11771,11 @@ function AttentionMatrix({
11242
11771
  marks.push(text(`sum-${i}`, total.toFixed(0), width - 30, y + cellHeight / 2 + 5, 14, c.textSecondary));
11243
11772
  });
11244
11773
  marks.push(text("footer", "Probability per query \xB7 \xD7 masked \xB7 shared color scale 0\u20131", 22, height - 22, 13, c.textSecondary, "start"));
11245
- const isLabel = (node) => React16.isValidElement(node) && node.type === "div";
11246
- return React16.createElement(
11774
+ const isLabel = (node) => React17.isValidElement(node) && node.type === "div";
11775
+ return React17.createElement(
11247
11776
  "div",
11248
11777
  { role: "img", "aria-label": title, style: { position: "relative", display: "flex", width, height, backgroundColor: c.bg, flexShrink: 0 } },
11249
- React16.createElement("svg", { width, height, viewBox: `0 0 ${width} ${height}` }, ...marks.filter((node) => !isLabel(node))),
11778
+ React17.createElement("svg", { width, height, viewBox: `0 0 ${width} ${height}` }, ...marks.filter((node) => !isLabel(node))),
11250
11779
  ...marks.filter(isLabel)
11251
11780
  );
11252
11781
  }
@@ -11279,7 +11808,7 @@ function transposeMatrix(matrix) {
11279
11808
  }
11280
11809
 
11281
11810
  // src/primitives/image-tensor.ts
11282
- import React17 from "react";
11811
+ import React18 from "react";
11283
11812
  var MAX_IMAGE_AXIS = 128;
11284
11813
  var MAX_IMAGE_PIXELS = 1024;
11285
11814
  var MAX_COMPONENT_SIZE = 32768;
@@ -11388,7 +11917,7 @@ function PixelGrid({
11388
11917
  const rgb = channel === "red" ? [pixel[0], 0, 0] : channel === "green" ? [0, pixel[1], 0] : channel === "blue" ? [0, 0, pixel[2]] : pixel;
11389
11918
  return `rgb(${rgb[0]}, ${rgb[1]}, ${rgb[2]})`;
11390
11919
  };
11391
- const cells = pixels.flatMap((row, rowIndex) => row.map((pixel, columnIndex) => React17.createElement("rect", {
11920
+ const cells = pixels.flatMap((row, rowIndex) => row.map((pixel, columnIndex) => React18.createElement("rect", {
11392
11921
  key: `pixel-${rowIndex}-${columnIndex}`,
11393
11922
  x: offsetX + columnIndex * pixelSize,
11394
11923
  y: offsetY + rowIndex * pixelSize,
@@ -11399,7 +11928,7 @@ function PixelGrid({
11399
11928
  const strokeWidth = pixelSize * 0.16;
11400
11929
  const marks = [...cells];
11401
11930
  if (region) {
11402
- marks.push(React17.createElement("rect", {
11931
+ marks.push(React18.createElement("rect", {
11403
11932
  key: "region-highlight",
11404
11933
  x: offsetX + region.column * pixelSize + strokeWidth / 2,
11405
11934
  y: offsetY + region.row * pixelSize + strokeWidth / 2,
@@ -11412,7 +11941,7 @@ function PixelGrid({
11412
11941
  }));
11413
11942
  }
11414
11943
  if (activeCell) {
11415
- marks.push(React17.createElement("rect", {
11944
+ marks.push(React18.createElement("rect", {
11416
11945
  key: "active-cell-highlight",
11417
11946
  x: offsetX + activeCell.column * pixelSize + strokeWidth / 2,
11418
11947
  y: offsetY + activeCell.row * pixelSize + strokeWidth / 2,
@@ -11424,11 +11953,11 @@ function PixelGrid({
11424
11953
  }));
11425
11954
  }
11426
11955
  const channelLabel = channel === "rgb" ? "RGB" : `${channel} channel`;
11427
- return React17.createElement("div", {
11956
+ return React18.createElement("div", {
11428
11957
  role: "img",
11429
11958
  "aria-label": `${shape.rows} by ${shape.columns} pixel image, ${channelLabel}`,
11430
11959
  style: { position: "relative", display: "flex", width, height, backgroundColor: c.bgCard, flexShrink: 0 }
11431
- }, React17.createElement("svg", {
11960
+ }, React18.createElement("svg", {
11432
11961
  width,
11433
11962
  height,
11434
11963
  viewBox: `0 0 ${width} ${height}`,
@@ -12296,7 +12825,7 @@ function nonnegative(value, name) {
12296
12825
  finite3(value, name);
12297
12826
  if (value < 0) throw new Error(`${name} must be nonnegative`);
12298
12827
  }
12299
- function positive2(value, name) {
12828
+ function positive3(value, name) {
12300
12829
  finite3(value, name);
12301
12830
  if (value <= 0) throw new Error(`${name} must be positive`);
12302
12831
  }
@@ -12307,17 +12836,17 @@ function normalizedOpacity(value, name = "Canvas opacity") {
12307
12836
  function validateBounds(bounds4) {
12308
12837
  finite3(bounds4.x, "Canvas x");
12309
12838
  finite3(bounds4.y, "Canvas y");
12310
- positive2(bounds4.width, "Canvas width");
12311
- positive2(bounds4.height, "Canvas height");
12839
+ positive3(bounds4.width, "Canvas width");
12840
+ positive3(bounds4.height, "Canvas height");
12312
12841
  nonnegative(bounds4.radius ?? 14, "Canvas radius");
12313
12842
  }
12314
12843
  function layoutTokenRow(values, options = {}) {
12315
12844
  const { advance = 24, gap = 16, minWidth = 64, paddingX = 17, width } = options;
12316
12845
  nonnegative(advance, "Token advance");
12317
12846
  nonnegative(gap, "Token gap");
12318
- positive2(minWidth, "Token minimum width");
12847
+ positive3(minWidth, "Token minimum width");
12319
12848
  nonnegative(paddingX, "Token horizontal padding");
12320
- if (width !== void 0) positive2(width, "Token width");
12849
+ if (width !== void 0) positive3(width, "Token width");
12321
12850
  if (options.x !== void 0) finite3(options.x, "Token x");
12322
12851
  if (options.centerX !== void 0) finite3(options.centerX, "Token center x");
12323
12852
  const items = values.map((value) => {
@@ -12361,7 +12890,7 @@ function createCanvasComponents(painter) {
12361
12890
  }
12362
12891
  function card(options) {
12363
12892
  const { label, x, y, width, height, fontSize = 32, font = "sans", textColor, baselineOffset = fontSize * 0.34, labelOpacity = 1 } = options;
12364
- positive2(fontSize, "Canvas font size");
12893
+ positive3(fontSize, "Canvas font size");
12365
12894
  finite3(baselineOffset, "Canvas text baseline offset");
12366
12895
  const labelAlpha = normalizedOpacity(labelOpacity, "Canvas label opacity");
12367
12896
  return panel(options, () => {
@@ -12374,7 +12903,7 @@ function createCanvasComponents(painter) {
12374
12903
  const { values, x, y, cellSize = 112, gap = 8, inset = 0, format = String, style = {}, cellStyle } = options;
12375
12904
  finite3(x, "Matrix x");
12376
12905
  finite3(y, "Matrix y");
12377
- positive2(cellSize, "Matrix cell size");
12906
+ positive3(cellSize, "Matrix cell size");
12378
12907
  nonnegative(gap, "Matrix gap");
12379
12908
  finite3(inset, "Matrix inset");
12380
12909
  if (gap >= cellSize) throw new Error("Matrix gap must be smaller than cell size");
@@ -12405,7 +12934,7 @@ function createCanvasComponents(painter) {
12405
12934
  function tokenRow(options) {
12406
12935
  const { values, y, height = 68, reveal = 1, opacity = 1, ...style } = options;
12407
12936
  finite3(y, "Token row y");
12408
- positive2(height, "Token height");
12937
+ positive3(height, "Token height");
12409
12938
  finite3(reveal, "Token reveal");
12410
12939
  const alpha3 = normalizedOpacity(opacity);
12411
12940
  const items = layoutTokenRow(values, options);
@@ -12422,7 +12951,7 @@ function createCanvasComponents(painter) {
12422
12951
  function particle(options) {
12423
12952
  const { points, progress, radius = 9, fill, stroke, strokeWidth = 3 } = options;
12424
12953
  finite3(progress, "Particle progress");
12425
- positive2(radius, "Particle radius");
12954
+ positive3(radius, "Particle radius");
12426
12955
  nonnegative(strokeWidth, "Particle stroke width");
12427
12956
  if (progress <= 0 || progress >= 1) return null;
12428
12957
  const point = pointAlongPath(points, progress);
@@ -12517,14 +13046,14 @@ function createTeachingTransfer(painter) {
12517
13046
  }
12518
13047
 
12519
13048
  // src/teaching-grid.ts
12520
- function positive3(value, name) {
13049
+ function positive4(value, name) {
12521
13050
  if (!Number.isFinite(value) || value <= 0) throw new Error(`${name} must be finite and positive`);
12522
13051
  }
12523
13052
  function layoutCellGrid(options) {
12524
13053
  const { x, y, width, height, rows, columns } = options;
12525
13054
  if (![x, y, x + width, y + height].every(Number.isFinite)) throw new Error("Grid bounds must be finite");
12526
- positive3(width, "Grid width");
12527
- positive3(height, "Grid height");
13055
+ positive4(width, "Grid width");
13056
+ positive4(height, "Grid height");
12528
13057
  if (![rows, columns, rows * columns].every(Number.isSafeInteger) || rows <= 0 || columns <= 0) {
12529
13058
  throw new Error("Grid rows and columns must be positive safe integers");
12530
13059
  }
@@ -12566,9 +13095,9 @@ function createTeachingGrid(painter) {
12566
13095
  textColor = "#FFFFFF",
12567
13096
  padding = 4
12568
13097
  } = options;
12569
- positive3(lineWidth, "Grid line width");
13098
+ positive4(lineWidth, "Grid line width");
12570
13099
  if (lineWidth >= Math.min(width / columns, height / rows)) throw new Error("Grid line width must be smaller than a cell");
12571
- positive3(fontSize, "Grid font size");
13100
+ positive4(fontSize, "Grid font size");
12572
13101
  if (!Number.isFinite(padding) || padding < 0) throw new Error("Grid padding must be finite and nonnegative");
12573
13102
  if (labels && (labels.length !== rows || labels.some((row) => row.length !== columns))) {
12574
13103
  throw new Error("Grid labels must match rows and columns");
@@ -12995,14 +13524,14 @@ function weightedVectorState(options) {
12995
13524
  total: [...prefix2]
12996
13525
  };
12997
13526
  }
12998
- function positive4(value, name) {
13527
+ function positive5(value, name) {
12999
13528
  if (finite4(value, name) <= 0) throw new Error(`${name} must be positive`);
13000
13529
  }
13001
13530
  function bounds2(value, name) {
13002
13531
  finite4(value.x, `${name} x`);
13003
13532
  finite4(value.y, `${name} y`);
13004
- positive4(value.width, `${name} width`);
13005
- positive4(value.height, `${name} height`);
13533
+ positive5(value.width, `${name} width`);
13534
+ positive5(value.height, `${name} height`);
13006
13535
  }
13007
13536
  function createTeachingVectorAccumulation(painter) {
13008
13537
  return (options) => {
@@ -13023,9 +13552,9 @@ function createTeachingVectorAccumulation(painter) {
13023
13552
  } = options;
13024
13553
  bounds2(plot.bounds, "Vector plot");
13025
13554
  bounds2(ledger, "Vector ledger");
13026
- positive4(fontSize, "Vector font size");
13027
- positive4(width, "Vector stroke width");
13028
- positive4(endpointRadius, "Vector endpoint radius");
13555
+ positive5(fontSize, "Vector font size");
13556
+ positive5(width, "Vector stroke width");
13557
+ positive5(endpointRadius, "Vector endpoint radius");
13029
13558
  finite4(completedOpacity, "Completed vector opacity");
13030
13559
  if (completedOpacity < 0 || completedOpacity > 1) throw new Error("Completed vector opacity must lie between zero and one");
13031
13560
  const [x0, x1] = plot.xDomain, [y0, y1] = plot.yDomain;
@@ -13778,15 +14307,15 @@ var PANEL = "#18283B";
13778
14307
  function finite6(value, name) {
13779
14308
  if (!Number.isFinite(value)) throw new Error(`${name} must be finite`);
13780
14309
  }
13781
- function positive5(value, name) {
14310
+ function positive6(value, name) {
13782
14311
  finite6(value, name);
13783
14312
  if (value <= 0) throw new Error(`${name} must be positive`);
13784
14313
  }
13785
14314
  function boundsOf(options) {
13786
14315
  finite6(options.x, "Teaching x");
13787
14316
  finite6(options.y, "Teaching y");
13788
- positive5(options.width, "Teaching width");
13789
- positive5(options.height, "Teaching height");
14317
+ positive6(options.width, "Teaching width");
14318
+ positive6(options.height, "Teaching height");
13790
14319
  return { x: options.x, y: options.y, width: options.width, height: options.height };
13791
14320
  }
13792
14321
  function amount(value, name = "Teaching progress") {
@@ -13822,7 +14351,7 @@ function createTeachingCanvas(painter) {
13822
14351
  }
13823
14352
  const { x, y, width, height } = bounds4;
13824
14353
  const { color = INK, gridColor, fontSize = 28, xTicks = [], yTicks = [], formatX = String, formatY = String } = options;
13825
- positive5(fontSize, "Axis font size");
14354
+ positive6(fontSize, "Axis font size");
13826
14355
  xTicks.forEach((tick) => finite6(tick, "Axis x tick"));
13827
14356
  yTicks.forEach((tick) => finite6(tick, "Axis y tick"));
13828
14357
  const plot = {
@@ -13863,7 +14392,7 @@ function createTeachingCanvas(painter) {
13863
14392
  }
13864
14393
  function curve(options) {
13865
14394
  const { plot, points, color, width = 4, progress = 1 } = options;
13866
- positive5(width, "Curve width");
14395
+ positive6(width, "Curve width");
13867
14396
  const mapped = points.map((point) => plot.point(point.x, point.y));
13868
14397
  const visible = tracePolyline(mapped, progress);
13869
14398
  if (visible.length > 1) painter.path(visible, { color, width, clip: plot.bounds });
@@ -13871,10 +14400,10 @@ function createTeachingCanvas(painter) {
13871
14400
  }
13872
14401
  function scatter(options) {
13873
14402
  const { plot, points, color = ACCENT, radius = 7, opacity = 1 } = options;
13874
- positive5(radius, "Scatter radius");
14403
+ positive6(radius, "Scatter radius");
13875
14404
  const alpha3 = amount(opacity, "Scatter opacity");
13876
14405
  const projected = points.map((point) => {
13877
- positive5(point.radius ?? radius, "Scatter point radius");
14406
+ positive6(point.radius ?? radius, "Scatter point radius");
13878
14407
  return {
13879
14408
  ...plot.point(point.x, point.y),
13880
14409
  radius: point.radius ?? radius,
@@ -13896,7 +14425,7 @@ function createTeachingCanvas(painter) {
13896
14425
  const bounds4 = boundsOf(options);
13897
14426
  const { x, y, width, height } = bounds4;
13898
14427
  const { values, labels, colors: colors2, color = ACCENT, progress = 1, showValues = false, format = String, fontSize = 28, gap = 20 } = options;
13899
- positive5(fontSize, "Bar font size");
14428
+ positive6(fontSize, "Bar font size");
13900
14429
  finite6(gap, "Bar gap");
13901
14430
  if (gap < 0) throw new Error("Bar gap must be nonnegative");
13902
14431
  values.forEach((value) => {
@@ -13907,12 +14436,12 @@ function createTeachingCanvas(painter) {
13907
14436
  if (colors2 && colors2.length !== values.length) throw new Error("Bar colors must match values");
13908
14437
  const maximumValue = values.reduce((maximum2, value) => Math.max(maximum2, value), 0);
13909
14438
  const maximum = options.max ?? (maximumValue || 1);
13910
- positive5(maximum, "Bar maximum");
14439
+ positive6(maximum, "Bar maximum");
13911
14440
  if (maximum < maximumValue) throw new Error("Bar maximum must contain every value");
13912
14441
  const reveal = amount(progress);
13913
14442
  if (!values.length) return { bars: [], slots: [], bounds: bounds4 };
13914
14443
  const barWidth = (width - gap * (values.length - 1)) / values.length;
13915
- positive5(barWidth, "Bar width after gaps");
14444
+ positive6(barWidth, "Bar width after gaps");
13916
14445
  const shapes = [];
13917
14446
  const slots = [];
13918
14447
  values.forEach((value, index) => {
@@ -13933,7 +14462,7 @@ function createTeachingCanvas(painter) {
13933
14462
  for (const node of nodes) {
13934
14463
  if (!node.id || Object.hasOwn(descriptors, node.id)) throw new Error("Flow node IDs must be nonempty and unique");
13935
14464
  const bounds4 = boundsOf(node);
13936
- positive5(node.fontSize ?? 30, "Flow node font size");
14465
+ positive6(node.fontSize ?? 30, "Flow node font size");
13937
14466
  finite6(node.radius ?? 14, "Flow node radius");
13938
14467
  if ((node.radius ?? 14) < 0) throw new Error("Flow node radius must be nonnegative");
13939
14468
  descriptors[node.id] = { ...bounds4, radius: node.radius ?? 14 };
@@ -13942,7 +14471,7 @@ function createTeachingCanvas(painter) {
13942
14471
  if (!Object.hasOwn(descriptors, edge.from) || !Object.hasOwn(descriptors, edge.to)) throw new Error("Flow edge must reference existing nodes");
13943
14472
  if (edge.from === edge.to) throw new Error("Flow edges must connect distinct nodes");
13944
14473
  if (edge.progress !== void 0) amount(edge.progress);
13945
- if (edge.width !== void 0) positive5(edge.width, "Flow edge width");
14474
+ if (edge.width !== void 0) positive6(edge.width, "Flow edge width");
13946
14475
  for (const gap of [edge.gap, edge.fromGap, edge.toGap]) {
13947
14476
  if (gap !== void 0) finite6(gap, "Flow edge gap");
13948
14477
  }
@@ -14183,7 +14712,7 @@ function morphPolyline(from, to, progress, options = {}) {
14183
14712
  }
14184
14713
 
14185
14714
  // src/scene-renderer.ts
14186
- import React18 from "react";
14715
+ import React19 from "react";
14187
14716
  import { readFile, mkdir as mkdir2, open, rename, rm } from "fs/promises";
14188
14717
  import { createReadStream } from "fs";
14189
14718
  import { dirname as dirname2, join, resolve } from "path";
@@ -14287,11 +14816,11 @@ function serializeSvg(node, budget, depth = 0) {
14287
14816
  if (node === null || node === void 0 || typeof node === "boolean") return "";
14288
14817
  if (typeof node === "string" || typeof node === "number") return emit(xml(node));
14289
14818
  if (Array.isArray(node)) return node.map((child) => serializeSvg(child, budget, depth + 1)).join("");
14290
- if (!React18.isValidElement(node)) throw new Error("Invalid resolved SVG child.");
14291
- if (node.type === React18.Fragment) return serializeSvg(node.props.children, budget, depth + 1);
14819
+ if (!React19.isValidElement(node)) throw new Error("Invalid resolved SVG child.");
14820
+ if (node.type === React19.Fragment) return serializeSvg(node.props.children, budget, depth + 1);
14292
14821
  if (node.type === SvgMathText) {
14293
14822
  const { text, x, y, fill, fontSize = 13, fontFamily = "JetBrains Mono", fontWeight = 700, textAnchor = "middle", dominantBaseline = "middle", opacity = 1 } = node.props;
14294
- return serializeSvg(React18.createElement("text", { x, y, fill, fontSize, fontFamily, fontWeight, textAnchor, dominantBaseline, opacity }, String(text)), budget, depth + 1);
14823
+ return serializeSvg(React19.createElement("text", { x, y, fill, fontSize, fontFamily, fontWeight, textAnchor, dominantBaseline, opacity }, String(text)), budget, depth + 1);
14295
14824
  }
14296
14825
  if (typeof node.type === "function") {
14297
14826
  return serializeSvg(node.type(node.props), budget, depth + 1);
@@ -14320,10 +14849,10 @@ function graphToReact(value, theme) {
14320
14849
  const props = Object.fromEntries(Object.entries(value.props).map(([name, prop]) => [name, convertProp(prop)]));
14321
14850
  const component = trustedComponents[value.type];
14322
14851
  if (component) props.c ??= theme;
14323
- return React18.createElement(component ?? value.type, props, ...value.children.map((child) => graphToReact(child, theme)));
14852
+ return React19.createElement(component ?? value.type, props, ...value.children.map((child) => graphToReact(child, theme)));
14324
14853
  }
14325
14854
  function renderSvgImage(element, assets, width, height, budget, outputScale = 1, includePng = true) {
14326
- const root = React18.cloneElement(element, { xmlns: "http://www.w3.org/2000/svg", width, height });
14855
+ const root = React19.cloneElement(element, { xmlns: "http://www.w3.org/2000/svg", width, height });
14327
14856
  const svg = serializeSvg(root, budget);
14328
14857
  const image = new Resvg2(svg, {
14329
14858
  font: { loadSystemFonts: false, fontFiles: assets.fontFiles, defaultFontFamily: "Inter" },
@@ -14336,7 +14865,7 @@ function renderSvgImage(element, assets, width, height, budget, outputScale = 1,
14336
14865
  function rasterizeNestedSvg(node, assets, defaultWidth, defaultHeight, budget) {
14337
14866
  if (++budget.nodes > SCENE_LIMITS.nodes * 16) throw new Error("Resolved scene exceeds its host element budget.");
14338
14867
  if (Array.isArray(node)) return node.map((child) => rasterizeNestedSvg(child, assets, defaultWidth, defaultHeight, budget));
14339
- if (!React18.isValidElement(node)) return node;
14868
+ if (!React19.isValidElement(node)) return node;
14340
14869
  if (node.type === "svg") {
14341
14870
  const width = typeof node.props.width === "number" ? node.props.width : defaultWidth;
14342
14871
  const height = typeof node.props.height === "number" ? node.props.height : defaultHeight;
@@ -14349,7 +14878,7 @@ function rasterizeNestedSvg(node, assets, defaultWidth, defaultHeight, budget) {
14349
14878
  throw new Error("Nested SVG rasterization exceeds the per-frame pixel or image budget.");
14350
14879
  }
14351
14880
  const { png } = renderSvgImage(node, assets, width, height, budget);
14352
- return React18.createElement("img", {
14881
+ return React19.createElement("img", {
14353
14882
  width,
14354
14883
  height,
14355
14884
  src: `data:image/png;base64,${Buffer.from(png).toString("base64")}`,
@@ -14358,20 +14887,20 @@ function rasterizeNestedSvg(node, assets, defaultWidth, defaultHeight, budget) {
14358
14887
  }
14359
14888
  if (typeof node.type === "function") return rasterizeNestedSvg(node.type(node.props), assets, defaultWidth, defaultHeight, budget);
14360
14889
  validateResolvedSceneResources(node.props);
14361
- return React18.cloneElement(node, {}, rasterizeNestedSvg(node.props.children, assets, defaultWidth, defaultHeight, budget));
14890
+ return React19.cloneElement(node, {}, rasterizeNestedSvg(node.props.children, assets, defaultWidth, defaultHeight, budget));
14362
14891
  }
14363
14892
  async function renderPreparedFrame(prepared, assets, time, outputScale, includePng) {
14364
14893
  const evaluated = await prepared.evaluate(time);
14365
14894
  const { width, height, theme } = prepared.request;
14366
14895
  const c = getThemeColors(theme);
14367
14896
  let element = graphToReact(evaluated.graph, c);
14368
- if (React18.isValidElement(element) && element.type === "svg") {
14369
- const image = renderSvgImage(React18.cloneElement(element, {
14370
- children: [React18.createElement("rect", { key: "__scene_background", width, height, fill: c.bg }), element.props.children]
14897
+ if (React19.isValidElement(element) && element.type === "svg") {
14898
+ const image = renderSvgImage(React19.cloneElement(element, {
14899
+ children: [React19.createElement("rect", { key: "__scene_background", width, height, fill: c.bg }), element.props.children]
14371
14900
  }), assets, width, height, { pixels: 0, count: 0, nodes: 0, svgBytes: 0 }, outputScale, includePng);
14372
14901
  return image;
14373
14902
  }
14374
- element = React18.createElement("div", { style: { display: "flex", position: "relative", width, height, backgroundColor: c.bg, fontFamily: "Inter", color: c.textPrimary } }, element);
14903
+ element = React19.createElement("div", { style: { display: "flex", position: "relative", width, height, backgroundColor: c.bg, fontFamily: "Inter", color: c.textPrimary } }, element);
14375
14904
  return withRenderContext({ background: "theme" }, async () => {
14376
14905
  element = rasterizeNestedSvg(element, assets, width, height, { pixels: 0, count: 0, nodes: 0, svgBytes: 0 });
14377
14906
  const accessible = prepareAccessibleSvg(element);
@@ -15939,6 +16468,7 @@ export {
15939
16468
  DonutChart,
15940
16469
  DotPoint,
15941
16470
  ELEMENT_SYMBOLS,
16471
+ EntityRelationshipDiagram,
15942
16472
  EquationCard,
15943
16473
  FactRows,
15944
16474
  Flow,