vizmatic 0.1.41 → 0.2.0

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.cjs CHANGED
@@ -37,6 +37,7 @@ __export(index_exports, {
37
37
  BadgePill: () => BadgePill,
38
38
  BarChart: () => BarChart,
39
39
  Box: () => Box,
40
+ CHECK_DIAGNOSTIC_CODES: () => CHECK_DIAGNOSTIC_CODES,
40
41
  CalloutCard: () => CalloutCard,
41
42
  Canvas: () => Canvas,
42
43
  CanvasOverflowError: () => CanvasOverflowError,
@@ -104,6 +105,7 @@ __export(index_exports, {
104
105
  WindowFrame: () => WindowFrame,
105
106
  analyzeAnimationCadence: () => analyzeAnimationCadence,
106
107
  canvas: () => canvas,
108
+ checkFrame: () => checkFrame,
107
109
  colors: () => colors,
108
110
  createPlotArea: () => createPlotArea,
109
111
  cropPixels: () => cropPixels,
@@ -130,6 +132,8 @@ __export(index_exports, {
130
132
  gradients: () => gradients,
131
133
  heatColor: () => heatColor,
132
134
  hold: () => hold,
135
+ importD2Graph: () => importD2Graph,
136
+ importMermaidGraph: () => importMermaidGraph,
133
137
  keyframe: () => keyframe,
134
138
  loadAdditionalAsset: () => loadAdditionalAsset,
135
139
  normalizeWatermark: () => normalizeWatermark,
@@ -353,7 +357,7 @@ function getToneColor(tone, c) {
353
357
  dark: c.textSecondary
354
358
  }[tone];
355
359
  }
356
- function getReadableToneColor(tone, c, background = c.bgCard) {
360
+ function getReadableToneColor(tone, c, background = c.bgCard, backdrop = c.bgCard) {
357
361
  const semanticColor = {
358
362
  blue: "secondary",
359
363
  purple: "primary",
@@ -369,7 +373,7 @@ function getReadableToneColor(tone, c, background = c.bgCard) {
369
373
  dark: "neutral"
370
374
  };
371
375
  const color = getReadableColor(semanticColor[tone], c);
372
- return colorContrast(color, background, c.bgCard) >= 4.5 ? color : getReadableTextColor(background, c);
376
+ return colorContrast(color, background, backdrop) >= 4.5 ? color : getReadableTextColor(background, c, backdrop);
373
377
  }
374
378
  function getToneFill(tone, c) {
375
379
  if (c.preset !== "engineering") return `${getToneColor(tone, c)}16`;
@@ -532,12 +536,12 @@ function colorContrast(left, right, rightBackdrop) {
532
536
  if (leftLuminance == null || rightLuminance == null) return 0;
533
537
  return (Math.max(leftLuminance, rightLuminance) + 0.05) / (Math.min(leftLuminance, rightLuminance) + 0.05);
534
538
  }
535
- function getReadableTextColor(background, c) {
536
- if (colorLuminance(background, c.bgCard) == null) return c.textPrimary;
539
+ function getReadableTextColor(background, c, backdrop = c.bgCard) {
540
+ if (colorLuminance(background, backdrop) == null) return c.textPrimary;
537
541
  const candidates = [c.textPrimary, c.textOnColor, c.bg, "#000000"];
538
- const readable = candidates.find((candidate) => colorContrast(candidate, background, c.bgCard) >= 4.5);
542
+ const readable = candidates.find((candidate) => colorContrast(candidate, background, backdrop) >= 4.5);
539
543
  if (readable) return readable;
540
- return candidates.reduce((best, candidate) => colorContrast(candidate, background, c.bgCard) > colorContrast(best, background, c.bgCard) ? candidate : best);
544
+ return candidates.reduce((best, candidate) => colorContrast(candidate, background, backdrop) > colorContrast(best, background, backdrop) ? candidate : best);
541
545
  }
542
546
  function getGradient(name) {
543
547
  const map = {
@@ -579,6 +583,89 @@ function lerpColor(a, b, t) {
579
583
  return `#${(rr << 16 | rg << 8 | rb).toString(16).padStart(6, "0")}`;
580
584
  }
581
585
 
586
+ // src/primitives.ts
587
+ var primitives_exports = {};
588
+ __export(primitives_exports, {
589
+ Arrow: () => Arrow,
590
+ ArrowMarkerDef: () => ArrowMarkerDef,
591
+ AxisPlot: () => AxisPlot,
592
+ Badge: () => Badge,
593
+ BadgePill: () => BadgePill,
594
+ BarChart: () => BarChart,
595
+ Box: () => Box,
596
+ CalloutCard: () => CalloutCard,
597
+ Canvas: () => Canvas,
598
+ Card: () => Card,
599
+ ChartFrame: () => ChartFrame,
600
+ CodeBlock: () => CodeBlock,
601
+ Column: () => Column,
602
+ Comparison: () => Comparison,
603
+ Connector: () => Connector,
604
+ DashedLine: () => DashedLine,
605
+ DataTable: () => DataTable,
606
+ DataflowDiagram: () => DataflowDiagram,
607
+ DeploymentDiagram: () => DeploymentDiagram,
608
+ DetailList: () => DetailList,
609
+ DonutChart: () => DonutChart,
610
+ DotPoint: () => DotPoint,
611
+ EquationCard: () => EquationCard,
612
+ Flow: () => Flow,
613
+ FlowArrow: () => FlowArrow,
614
+ GradientChip: () => GradientChip,
615
+ GraphDiagram: () => GraphDiagram,
616
+ Grid: () => Grid,
617
+ Heatmap: () => Heatmap,
618
+ Icon: () => Icon,
619
+ IntervalPlot: () => IntervalPlot,
620
+ KeyValueList: () => KeyValueList,
621
+ LayeredNetwork: () => LayeredNetwork,
622
+ Legend: () => Legend,
623
+ LineChart: () => LineChart,
624
+ MathText: () => MathText,
625
+ Matrix: () => Matrix,
626
+ MetricCard: () => MetricCard,
627
+ MiniBarChart: () => MiniBarChart,
628
+ Panel: () => Panel,
629
+ ParetoChart: () => ParetoChart,
630
+ Pipeline: () => Pipeline,
631
+ ProgressList: () => ProgressList,
632
+ ProgressRow: () => ProgressRow,
633
+ QuadrantChart: () => QuadrantChart,
634
+ Row: () => Row,
635
+ ScatterPlot: () => ScatterPlot,
636
+ Scene: () => Scene,
637
+ SequenceDiagram: () => SequenceDiagram,
638
+ Stack: () => Stack,
639
+ StackedBar: () => StackedBar,
640
+ StatusList: () => StatusList,
641
+ StatusRow: () => StatusRow,
642
+ StepCard: () => StepCard,
643
+ SvgFrame: () => SvgFrame,
644
+ SvgMathText: () => SvgMathText,
645
+ SvgPoint: () => SvgPoint,
646
+ TextLabel: () => TextLabel,
647
+ Tile: () => Tile,
648
+ TileGrid: () => TileGrid,
649
+ TiledMatrix: () => TiledMatrix,
650
+ Timeline: () => Timeline,
651
+ TitleBar: () => TitleBar,
652
+ ToneStrip: () => ToneStrip,
653
+ TransformerTopology: () => TransformerTopology,
654
+ TreeDiagram: () => TreeDiagram,
655
+ ValuePill: () => ValuePill,
656
+ VectorArrow: () => VectorArrow,
657
+ VectorSegment: () => VectorSegment,
658
+ WindowFrame: () => WindowFrame,
659
+ createPlotArea: () => createPlotArea,
660
+ defineDiagramIcon: () => defineDiagramIcon,
661
+ defineIconRegistry: () => defineIconRegistry,
662
+ defineIllustration: () => defineIllustration,
663
+ formatMathText: () => formatMathText,
664
+ formatTensorShape: () => formatTensorShape,
665
+ getToneColor: () => getToneColor,
666
+ getToneGradient: () => getToneGradient
667
+ });
668
+
582
669
  // src/primitives/layout.ts
583
670
  var import_react = __toESM(require("react"), 1);
584
671
 
@@ -2265,6 +2352,7 @@ function MiniBarChart({
2265
2352
  ...compactChildren([
2266
2353
  showValues && import_react4.default.createElement("div", {
2267
2354
  style: {
2355
+ display: "flex",
2268
2356
  color: getReadableToneColor(tone, c),
2269
2357
  fontFamily: "JetBrains Mono",
2270
2358
  fontSize,
@@ -2284,6 +2372,7 @@ function MiniBarChart({
2284
2372
  }),
2285
2373
  import_react4.default.createElement("div", {
2286
2374
  style: {
2375
+ display: "flex",
2287
2376
  color: c.textMuted,
2288
2377
  fontFamily: "JetBrains Mono",
2289
2378
  fontSize,
@@ -2930,7 +3019,11 @@ function StatusRow({
2930
3019
  }) {
2931
3020
  const resolvedTone = tone ?? statusTones[status];
2932
3021
  const accent = getToneColor(resolvedTone, c);
2933
- const accentText = getReadableToneColor(resolvedTone, c);
3022
+ const markerAlpha = 38 / 255;
3023
+ const rowAlpha = boxed ? 18 / 255 : 0;
3024
+ const markerBackgroundAlpha = Math.round((rowAlpha + markerAlpha * (1 - rowAlpha)) * 255);
3025
+ const markerBackground = `${accent}${markerBackgroundAlpha.toString(16).padStart(2, "0")}`;
3026
+ const accentText = getReadableToneColor(resolvedTone, c, markerBackground, c.bgCard);
2934
3027
  const glyph = statusGlyphs[status];
2935
3028
  const marker = import_react5.default.createElement("div", {
2936
3029
  style: {
@@ -3350,8 +3443,202 @@ function Flow({
3350
3443
  }
3351
3444
 
3352
3445
  // src/primitives/diagrams.ts
3353
- var import_react6 = __toESM(require("react"), 1);
3446
+ var import_react7 = __toESM(require("react"), 1);
3354
3447
  var import_dagre = __toESM(require("@dagrejs/dagre"), 1);
3448
+
3449
+ // src/svg-accessibility.ts
3450
+ var import_react6 = require("react");
3451
+ var SVG_ACCESSIBILITY_COMPONENT = /* @__PURE__ */ Symbol.for("vizmatic.svgAccessibilityComponent");
3452
+ function componentHasSvgMetadata(type) {
3453
+ return typeof type === "function" && type[SVG_ACCESSIBILITY_COMPONENT] === true;
3454
+ }
3455
+ function svgToken(value) {
3456
+ if (value.length === 0) return "empty";
3457
+ return Array.from(value, (character) => {
3458
+ const codePoint = character.codePointAt(0) ?? 0;
3459
+ return /^[A-Za-z0-9.-]$/.test(character) ? character : `_u${codePoint.toString(16)}_`;
3460
+ }).join("");
3461
+ }
3462
+ function textProperty(props, name) {
3463
+ const value = props[name];
3464
+ return typeof value === "string" ? value : "";
3465
+ }
3466
+ function encodedTextProperty(props, name) {
3467
+ const value = textProperty(props, name);
3468
+ try {
3469
+ return decodeURIComponent(value);
3470
+ } catch {
3471
+ return value;
3472
+ }
3473
+ }
3474
+ function prepareAccessibleSvg(element) {
3475
+ const graphs = [];
3476
+ const explicitIds = /* @__PURE__ */ new Set();
3477
+ const visit = (node, graph) => {
3478
+ if (Array.isArray(node)) return node.map((child) => visit(child, graph));
3479
+ if (!(0, import_react6.isValidElement)(node)) return node;
3480
+ const component = node.type;
3481
+ if (componentHasSvgMetadata(component)) {
3482
+ return visit(component(node.props), graph);
3483
+ }
3484
+ const props = node.props;
3485
+ const title = textProperty(props, "data-vizmatic-svg-title");
3486
+ const isGraphRoot = title.length > 0;
3487
+ let activeGraph = graph;
3488
+ let elementKey = node.key;
3489
+ if (isGraphRoot) {
3490
+ const explicitId = textProperty(props, "data-vizmatic-svg-id");
3491
+ if (explicitId) {
3492
+ if (explicitIds.has(explicitId)) {
3493
+ throw new Error(`GraphDiagram SVG id "${explicitId}" must be unique in one exported SVG.`);
3494
+ }
3495
+ explicitIds.add(explicitId);
3496
+ }
3497
+ const index = graphs.length;
3498
+ const token = explicitId ? `id-${svgToken(explicitId)}` : `index-${index}`;
3499
+ activeGraph = {
3500
+ index,
3501
+ token,
3502
+ detectionKey: `vizmatic-graph-${index}`,
3503
+ title,
3504
+ description: textProperty(props, "data-vizmatic-svg-description"),
3505
+ nodes: [],
3506
+ edges: []
3507
+ };
3508
+ graphs.push(activeGraph);
3509
+ elementKey = activeGraph.detectionKey;
3510
+ }
3511
+ let nextProps;
3512
+ if (activeGraph && Object.hasOwn(props, "data-vizmatic-graph-node-id")) {
3513
+ const id = textProperty(props, "data-vizmatic-graph-node-id");
3514
+ const label = textProperty(props, "data-vizmatic-graph-node-label") || id;
3515
+ const detail = textProperty(props, "data-vizmatic-graph-node-detail");
3516
+ activeGraph.nodes.push({
3517
+ id,
3518
+ label,
3519
+ detail,
3520
+ title: textProperty(props, "data-vizmatic-graph-node-title") || label,
3521
+ href: textProperty(props, "data-vizmatic-graph-node-href") || void 0
3522
+ });
3523
+ elementKey = `${activeGraph.detectionKey}-node-${svgToken(id)}`;
3524
+ } else if (activeGraph && textProperty(props, "data-vizmatic-graph-edge-id")) {
3525
+ const id = encodedTextProperty(props, "data-vizmatic-graph-edge-id");
3526
+ activeGraph.edges.push({
3527
+ id,
3528
+ from: encodedTextProperty(props, "data-vizmatic-graph-edge-from"),
3529
+ to: encodedTextProperty(props, "data-vizmatic-graph-edge-to"),
3530
+ label: encodedTextProperty(props, "data-vizmatic-graph-edge-label"),
3531
+ title: encodedTextProperty(props, "data-vizmatic-graph-edge-title"),
3532
+ path: textProperty(props, "d"),
3533
+ href: encodedTextProperty(props, "data-vizmatic-graph-edge-href") || void 0
3534
+ });
3535
+ elementKey = `${activeGraph.detectionKey}-edge-${svgToken(id)}`;
3536
+ }
3537
+ const children = props.children;
3538
+ if (children === void 0) {
3539
+ if (isGraphRoot) {
3540
+ nextProps = { ...props, "data-vizmatic-svg-instance": activeGraph?.token };
3541
+ return (0, import_react6.cloneElement)(node, { ...nextProps, key: elementKey });
3542
+ }
3543
+ return node;
3544
+ }
3545
+ const preparedChildren = visit(children, activeGraph);
3546
+ nextProps = isGraphRoot ? { ...props, "data-vizmatic-svg-instance": activeGraph?.token } : { ...props };
3547
+ return (0, import_react6.cloneElement)(
3548
+ node,
3549
+ { ...nextProps, key: elementKey },
3550
+ preparedChildren
3551
+ );
3552
+ };
3553
+ return { element: visit(element), graphs };
3554
+ }
3555
+ function escapeXml(value) {
3556
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
3557
+ }
3558
+ function attribute(name, value) {
3559
+ return `${name}="${escapeXml(value)}"`;
3560
+ }
3561
+ function graphBaseId(graph) {
3562
+ return `vizmatic-graph-${graph.token}`;
3563
+ }
3564
+ function nodeId(graph, node) {
3565
+ return `${graphBaseId(graph)}-node-${svgToken(node.id)}`;
3566
+ }
3567
+ function edgeId(graph, edge) {
3568
+ return `${graphBaseId(graph)}-edge-${svgToken(edge.id)}`;
3569
+ }
3570
+ function labelForEdge(graph, edge) {
3571
+ const nodes = new Map(graph.nodes.map((node) => [node.id, node.label]));
3572
+ const from = nodes.get(edge.from) ?? edge.from;
3573
+ const to = nodes.get(edge.to) ?? edge.to;
3574
+ return edge.title || (edge.label ? `${from} to ${to}: ${edge.label}` : `${from} to ${to}`);
3575
+ }
3576
+ function descriptionForEdge(graph, edge) {
3577
+ const nodes = new Map(graph.nodes.map((node) => [node.id, node.label]));
3578
+ const from = nodes.get(edge.from) ?? edge.from;
3579
+ const to = nodes.get(edge.to) ?? edge.to;
3580
+ return `Relationship from ${from} to ${to}${edge.label ? `, labeled ${edge.label}` : ""}.`;
3581
+ }
3582
+ function nodeGroup(graph, node, layout) {
3583
+ const id = nodeId(graph, node);
3584
+ const label = node.detail ? `${node.label}: ${node.detail}` : node.label;
3585
+ const description = node.detail || node.label;
3586
+ const titleId = `${id}-title`;
3587
+ const descriptionId = `${id}-description`;
3588
+ const accessible = `<g ${attribute("id", id)} role="group" aria-labelledby="${titleId}" aria-describedby="${descriptionId}"><title id="${titleId}">${escapeXml(node.title || node.label)}</title><desc id="${descriptionId}">${escapeXml(description)}</desc>`;
3589
+ if (!layout) return `${accessible}</g>`;
3590
+ const rect = `<rect x="${layout.left}" y="${layout.top}" width="${layout.width}" height="${layout.height}" fill="transparent" pointer-events="all"/>`;
3591
+ const hitTarget = node.href ? `<a ${attribute("href", node.href)} role="link" tabindex="0" ${attribute("aria-label", label)}>${rect}</a>` : rect;
3592
+ return `${accessible}${hitTarget}</g>`;
3593
+ }
3594
+ function edgeGroup(graph, edge, root) {
3595
+ const id = edgeId(graph, edge);
3596
+ const title = labelForEdge(graph, edge);
3597
+ const titleId = `${id}-title`;
3598
+ const descriptionId = `${id}-description`;
3599
+ const accessible = `<g ${attribute("id", id)} role="group" aria-labelledby="${titleId}" aria-describedby="${descriptionId}"><title id="${titleId}">${escapeXml(title)}</title><desc id="${descriptionId}">${escapeXml(descriptionForEdge(graph, edge))}</desc>`;
3600
+ if (!root || !edge.path) return `${accessible}</g>`;
3601
+ const path = `<path d="${escapeXml(edge.path)}" transform="translate(${root.left} ${root.top})" fill="none" stroke="transparent" stroke-width="14" stroke-linecap="round" pointer-events="stroke"/>`;
3602
+ const hitTarget = edge.href ? `<a ${attribute("href", edge.href)} role="link" tabindex="0" ${attribute("aria-label", title)}>${path}</a>` : path;
3603
+ return `${accessible}${hitTarget}</g>`;
3604
+ }
3605
+ function addSvgAccessibility(svg, graphs, layoutNodes) {
3606
+ if (graphs.length === 0) return svg;
3607
+ const title = graphs.map((graph) => graph.title).join(". ");
3608
+ const description = graphs.map((graph) => `${graph.title}. ${graph.description}`).join(" ");
3609
+ const hasLinks = graphs.some(
3610
+ (graph) => graph.nodes.some((node) => node.href) || graph.edges.some((edge) => edge.href)
3611
+ );
3612
+ const rootTitleId = "vizmatic-svg-title";
3613
+ const rootDescriptionId = "vizmatic-svg-description";
3614
+ const groupMarkup = graphs.map((graph) => {
3615
+ const baseId = graphBaseId(graph);
3616
+ const titleId = `${baseId}-title`;
3617
+ const descriptionId = `${baseId}-description`;
3618
+ const root = layoutNodes.find((node) => node.key === graph.detectionKey);
3619
+ const nodes = graph.nodes.map((item) => {
3620
+ const layout = layoutNodes.find((node) => node.key === `${graph.detectionKey}-node-${svgToken(item.id)}`);
3621
+ if (item.href && !layout) {
3622
+ throw new Error(`Could not resolve GraphDiagram node "${item.id}" bounds for SVG link export.`);
3623
+ }
3624
+ return nodeGroup(graph, item, layout);
3625
+ }).join("");
3626
+ const edges = graph.edges.map((item) => {
3627
+ if (item.href && !root) {
3628
+ throw new Error(`Could not resolve GraphDiagram bounds for SVG edge link export: "${item.id}".`);
3629
+ }
3630
+ return edgeGroup(graph, item, root);
3631
+ }).join("");
3632
+ return `<g ${attribute("id", baseId)} role="group" aria-labelledby="${titleId}" aria-describedby="${descriptionId}"><title id="${titleId}">${escapeXml(graph.title)}</title><desc id="${descriptionId}">${escapeXml(graph.description)}</desc>${nodes}${edges}</g>`;
3633
+ }).join("");
3634
+ const metadata = `<title id="${rootTitleId}">${escapeXml(title)}</title><desc id="${rootDescriptionId}">${escapeXml(description)}</desc>`;
3635
+ return svg.replace(
3636
+ /^<svg\b([^>]*)>/,
3637
+ (_match, attrs) => `<svg${attrs} role="${hasLinks ? "group" : "img"}" aria-labelledby="${rootTitleId}" aria-describedby="${rootDescriptionId}">${metadata}`
3638
+ ).replace(/<\/svg>\s*$/, `${groupMarkup}</svg>`);
3639
+ }
3640
+
3641
+ // src/primitives/diagrams.ts
3355
3642
  function distributeValues(count, start, end) {
3356
3643
  if (count <= 0) return [];
3357
3644
  if (count === 1) return [(start + end) / 2];
@@ -3386,7 +3673,7 @@ function LayeredNetwork({
3386
3673
  return from.ys.flatMap(
3387
3674
  (fromY, fromIndex) => to.ys.map((toY, toIndex) => {
3388
3675
  const active = activePath[layerIndex] === fromIndex && activePath[layerIndex + 1] === toIndex;
3389
- return import_react6.default.createElement("line", {
3676
+ return import_react7.default.createElement("line", {
3390
3677
  key: `connection-${layerIndex}-${fromIndex}-${toIndex}`,
3391
3678
  x1: from.x + radius + 4,
3392
3679
  y1: fromY,
@@ -3400,7 +3687,7 @@ function LayeredNetwork({
3400
3687
  })
3401
3688
  );
3402
3689
  });
3403
- const label = (key, text, x, y, labelWidth, color, fontSize = 13, fontWeight = 800, fontFamily = "Inter") => import_react6.default.createElement("div", {
3690
+ const label = (key, text, x, y, labelWidth, color, fontSize = 13, fontWeight = 800, fontFamily = "Inter") => import_react7.default.createElement("div", {
3404
3691
  key,
3405
3692
  style: {
3406
3693
  position: "absolute",
@@ -3425,7 +3712,7 @@ function LayeredNetwork({
3425
3712
  const active = activePath[layerIndex] === nodeIndex;
3426
3713
  const color = getToneColor(layer.tone, c);
3427
3714
  return [
3428
- active && import_react6.default.createElement("div", {
3715
+ active && import_react7.default.createElement("div", {
3429
3716
  key: `halo-${layerIndex}-${nodeIndex}`,
3430
3717
  style: {
3431
3718
  position: "absolute",
@@ -3440,7 +3727,7 @@ function LayeredNetwork({
3440
3727
  boxShadow: `0 0 18px ${c.warningLight}66`
3441
3728
  }
3442
3729
  }),
3443
- import_react6.default.createElement("div", {
3730
+ import_react7.default.createElement("div", {
3444
3731
  key: `node-${layerIndex}-${nodeIndex}`,
3445
3732
  style: {
3446
3733
  position: "absolute",
@@ -3480,7 +3767,7 @@ function LayeredNetwork({
3480
3767
  "JetBrains Mono"
3481
3768
  )
3482
3769
  );
3483
- const formulaElement = (showFormula || formula) && formula ? import_react6.default.createElement("div", {
3770
+ const formulaElement = (showFormula || formula) && formula ? import_react7.default.createElement("div", {
3484
3771
  key: "formula-wrap",
3485
3772
  style: {
3486
3773
  position: "absolute",
@@ -3501,7 +3788,7 @@ function LayeredNetwork({
3501
3788
  boxShadow: `0 8px 18px ${c.shadow}`
3502
3789
  }
3503
3790
  }, formatMathText(formula)) : null;
3504
- const legendElement = (showFormula || formula) && formula ? import_react6.default.createElement(
3791
+ const legendElement = (showFormula || formula) && formula ? import_react7.default.createElement(
3505
3792
  "div",
3506
3793
  {
3507
3794
  key: "legend-wrap",
@@ -3519,7 +3806,7 @@ function LayeredNetwork({
3519
3806
  fontWeight: 800
3520
3807
  }
3521
3808
  },
3522
- import_react6.default.createElement("div", {
3809
+ import_react7.default.createElement("div", {
3523
3810
  style: {
3524
3811
  width: 42,
3525
3812
  height: 5,
@@ -3529,7 +3816,7 @@ function LayeredNetwork({
3529
3816
  }),
3530
3817
  legend
3531
3818
  ) : null;
3532
- return import_react6.default.createElement(
3819
+ return import_react7.default.createElement(
3533
3820
  "div",
3534
3821
  {
3535
3822
  role: "img",
@@ -3544,7 +3831,7 @@ function LayeredNetwork({
3544
3831
  flexShrink: 0
3545
3832
  }
3546
3833
  },
3547
- import_react6.default.createElement("svg", {
3834
+ import_react7.default.createElement("svg", {
3548
3835
  width,
3549
3836
  height,
3550
3837
  viewBox: `0 0 ${width} ${height}`,
@@ -3721,15 +4008,53 @@ function validateGraphDiagramSpec(nodes, edges, groups, layoutMode) {
3721
4008
  for (const group of groups) {
3722
4009
  if (!occupiedGroups.has(group.id)) throw new Error(`GraphDiagram group "${group.id}" contains no nodes.`);
3723
4010
  }
4011
+ const edgeIds = /* @__PURE__ */ new Set();
3724
4012
  for (const edge of edges) {
3725
4013
  if (!nodeIds.has(edge.from) || !nodeIds.has(edge.to)) {
3726
4014
  throw new Error(`GraphDiagram edge "${edge.from}" -> "${edge.to}" references a missing node.`);
3727
4015
  }
4016
+ if (edge.id != null) {
4017
+ if (edgeIds.has(edge.id)) throw new Error(`GraphDiagram received duplicate edge id "${edge.id}".`);
4018
+ edgeIds.add(edge.id);
4019
+ }
4020
+ validateDiagramHref(edge.href, `edge "${edge.id ?? `${edge.from}" -> "${edge.to}`}"`);
4021
+ }
4022
+ for (const node of nodes) {
4023
+ validateDiagramHref(node.href, `node "${node.id}"`);
3728
4024
  }
3729
4025
  if (groups.length > 0 && layoutMode === "manual") {
3730
4026
  throw new Error('GraphDiagram groups require automatic layout; omit node coordinates and layout="manual".');
3731
4027
  }
3732
4028
  }
4029
+ function validateDiagramHref(href, owner) {
4030
+ if (href == null) return;
4031
+ const normalized = href.trim().replace(/[\u0000-\u0020\u007f]/g, "");
4032
+ const scheme = /^([a-z][a-z\d+.-]*):/i.exec(normalized)?.[1]?.toLowerCase();
4033
+ if (scheme && !["http", "https", "mailto", "tel"].includes(scheme)) {
4034
+ throw new Error(`GraphDiagram ${owner} has an unsupported link scheme "${scheme}:".`);
4035
+ }
4036
+ }
4037
+ function graphAccessibleText(value) {
4038
+ if (typeof value === "string" || typeof value === "number") return String(value).trim();
4039
+ if (Array.isArray(value)) return value.map(graphAccessibleText).filter(Boolean).join(" ");
4040
+ if (import_react7.default.isValidElement(value)) {
4041
+ const props = value.props;
4042
+ return graphAccessibleText(props.children);
4043
+ }
4044
+ return "";
4045
+ }
4046
+ function graphDescription(nodes, edges) {
4047
+ const labels = new Map(nodes.map((node) => [node.id, graphAccessibleText(node.label) || node.id]));
4048
+ const parts = [`${nodes.length} nodes and ${edges.length} relationships.`];
4049
+ const relationships = edges.slice(0, 8).map((edge) => {
4050
+ const from = labels.get(edge.from) ?? edge.from;
4051
+ const to = labels.get(edge.to) ?? edge.to;
4052
+ return edge.label ? `${from} ${edge.label} ${to}` : `${from} to ${to}`;
4053
+ });
4054
+ if (relationships.length) parts.push(relationships.join("; "));
4055
+ if (edges.length > relationships.length) parts.push(`${edges.length - relationships.length} more relationships`);
4056
+ return parts.join(" ");
4057
+ }
3733
4058
  function graphGroupDepth(group, groupsById) {
3734
4059
  let depth = 0;
3735
4060
  let parent = group.parent;
@@ -3769,8 +4094,12 @@ function GraphDiagram({
3769
4094
  edgeGap = 14,
3770
4095
  sizing = "content",
3771
4096
  iconSize = 20,
3772
- ariaLabel
4097
+ id,
4098
+ ariaLabel,
4099
+ title,
4100
+ description
3773
4101
  }) {
4102
+ if (id != null && id.trim().length === 0) throw new Error("GraphDiagram id must not be empty.");
3774
4103
  const fullyPositioned = nodes.filter((node) => node.x != null && node.y != null).length;
3775
4104
  const partiallyPositioned = nodes.some((node) => node.x == null !== (node.y == null));
3776
4105
  if (partiallyPositioned || fullyPositioned > 0 && fullyPositioned < nodes.length) {
@@ -3781,6 +4110,19 @@ function GraphDiagram({
3781
4110
  throw new Error('GraphDiagram layout="manual" requires x and y on every node.');
3782
4111
  }
3783
4112
  validateGraphDiagramSpec(nodes, edges, groups, layoutMode);
4113
+ const edgeOccurrences = /* @__PURE__ */ new Map();
4114
+ const stableEdgeIds = edges.map((edge) => {
4115
+ if (edge.id != null) return `custom-${edge.id}`;
4116
+ const route = `${edge.from}\0${edge.to}`;
4117
+ const occurrence = edgeOccurrences.get(route) ?? 0;
4118
+ edgeOccurrences.set(route, occurrence + 1);
4119
+ return `route-${edge.from}-to-${edge.to}-${occurrence}`;
4120
+ });
4121
+ if (new Set(stableEdgeIds).size !== stableEdgeIds.length) {
4122
+ throw new Error("GraphDiagram edge ids must not collide with generated relationship ids.");
4123
+ }
4124
+ const svgTitle = title?.trim() || ariaLabel?.trim() || "Graph diagram";
4125
+ const svgDescription = description ?? graphDescription(nodes, edges);
3784
4126
  let resolvedWidth = width ?? 520;
3785
4127
  let resolvedHeight = height ?? 420;
3786
4128
  let layout;
@@ -3892,6 +4234,7 @@ function GraphDiagram({
3892
4234
  return [{
3893
4235
  ...edge,
3894
4236
  index,
4237
+ stableId: stableEdgeIds[index],
3895
4238
  color,
3896
4239
  markerId,
3897
4240
  points,
@@ -3905,7 +4248,7 @@ function GraphDiagram({
3905
4248
  const parallelGroups = parallelConnectorGroups(edgeLayouts);
3906
4249
  const groupElements = groupLayout.map((group) => {
3907
4250
  const accent = group.muted ? c.textMuted : getToneColor(group.tone ?? "blue", c);
3908
- return import_react6.default.createElement("div", {
4251
+ return import_react7.default.createElement("div", {
3909
4252
  key: `graph-group-${group.id}`,
3910
4253
  "data-vizmatic-graph-group": group.id,
3911
4254
  style: {
@@ -3921,7 +4264,7 @@ function GraphDiagram({
3921
4264
  backgroundColor: `${accent}${c.preset === "engineering" ? "08" : "0d"}`,
3922
4265
  opacity: group.muted ? 0.68 : 1
3923
4266
  }
3924
- }, import_react6.default.createElement(
4267
+ }, import_react7.default.createElement(
3925
4268
  "div",
3926
4269
  {
3927
4270
  style: {
@@ -3939,10 +4282,10 @@ function GraphDiagram({
3939
4282
  whiteSpace: "nowrap"
3940
4283
  }
3941
4284
  },
3942
- import_react6.default.createElement("div", {
4285
+ import_react7.default.createElement("div", {
3943
4286
  style: { minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", fontSize: 12, fontWeight: 800 }
3944
4287
  }, group.label),
3945
- group.detail && import_react6.default.createElement("div", {
4288
+ group.detail && import_react7.default.createElement("div", {
3946
4289
  style: {
3947
4290
  minWidth: 0,
3948
4291
  overflow: "hidden",
@@ -3955,11 +4298,15 @@ function GraphDiagram({
3955
4298
  }, group.detail)
3956
4299
  ));
3957
4300
  });
3958
- return import_react6.default.createElement(
4301
+ return import_react7.default.createElement(
3959
4302
  "div",
3960
4303
  {
4304
+ key: "vizmatic-graph-root",
3961
4305
  role: "img",
3962
- "aria-label": ariaLabel ?? "Graph diagram",
4306
+ "aria-label": ariaLabel ?? svgTitle,
4307
+ "data-vizmatic-svg-title": svgTitle,
4308
+ "data-vizmatic-svg-description": svgDescription,
4309
+ "data-vizmatic-svg-id": id,
3963
4310
  "data-vizmatic-connector-crossings": crossings,
3964
4311
  "data-vizmatic-connector-label-collisions": labelCollisions,
3965
4312
  "data-vizmatic-crowded-connector-endpoints": crowdedEndpoints,
@@ -3974,7 +4321,7 @@ function GraphDiagram({
3974
4321
  }
3975
4322
  },
3976
4323
  ...groupElements,
3977
- import_react6.default.createElement(
4324
+ import_react7.default.createElement(
3978
4325
  "svg",
3979
4326
  {
3980
4327
  width: resolvedWidth,
@@ -3982,7 +4329,7 @@ function GraphDiagram({
3982
4329
  viewBox: `0 0 ${resolvedWidth} ${resolvedHeight}`,
3983
4330
  style: { position: "absolute", inset: 0, overflow: "visible" }
3984
4331
  },
3985
- import_react6.default.createElement(
4332
+ import_react7.default.createElement(
3986
4333
  "defs",
3987
4334
  {},
3988
4335
  ...edgeLayouts.map((edge) => ArrowMarkerDef({
@@ -3991,8 +4338,14 @@ function GraphDiagram({
3991
4338
  size: arrowSize
3992
4339
  }))
3993
4340
  ),
3994
- ...edgeLayouts.map((edge) => import_react6.default.createElement("path", {
4341
+ ...edgeLayouts.map((edge) => import_react7.default.createElement("path", {
3995
4342
  key: `graph-edge-${edge.index}`,
4343
+ "data-vizmatic-graph-edge-id": encodeURIComponent(edge.stableId),
4344
+ "data-vizmatic-graph-edge-from": encodeURIComponent(edge.from),
4345
+ "data-vizmatic-graph-edge-to": encodeURIComponent(edge.to),
4346
+ "data-vizmatic-graph-edge-label": encodeURIComponent(edge.label ?? ""),
4347
+ "data-vizmatic-graph-edge-title": encodeURIComponent(edge.title ?? ""),
4348
+ "data-vizmatic-graph-edge-href": edge.href == null ? void 0 : encodeURIComponent(edge.href),
3996
4349
  d: edgePath(edge.points),
3997
4350
  fill: "none",
3998
4351
  stroke: edge.color,
@@ -4005,7 +4358,7 @@ function GraphDiagram({
4005
4358
  }))
4006
4359
  ),
4007
4360
  ...edgeLayouts.flatMap((edge) => edge.label ? [
4008
- import_react6.default.createElement("div", {
4361
+ import_react7.default.createElement("div", {
4009
4362
  key: `graph-edge-label-${edge.index}`,
4010
4363
  style: {
4011
4364
  position: "absolute",
@@ -4031,15 +4384,16 @@ function GraphDiagram({
4031
4384
  ] : []),
4032
4385
  ...Array.from(layout.values()).map((node) => {
4033
4386
  const accent = node.muted ? c.textMuted : getToneColor(node.tone ?? "blue", c);
4034
- const accentText = node.muted ? c.textMuted : getReadableToneColor(node.tone ?? "blue", c);
4387
+ const fill = getToneFill(node.tone ?? "blue", c);
4388
+ const accentText = node.muted ? c.textMuted : getReadableToneColor(node.tone ?? "blue", c, fill, c.bg);
4035
4389
  const resolvedIconSize = clamp(
4036
4390
  node.iconSize ?? iconSize,
4037
4391
  8,
4038
4392
  Math.max(8, Math.min(node.width, node.height) - 16)
4039
4393
  );
4040
4394
  const iconLabel = typeof node.label === "string" ? `${node.label} icon` : void 0;
4041
- const iconElement = typeof node.icon === "string" ? Icon({ c, name: node.icon, color: accent, size: resolvedIconSize, label: iconLabel, muted: node.muted }) : import_react6.default.isValidElement(node.icon) ? node.icon : node.icon?.render({ c, color: accent, size: resolvedIconSize, label: iconLabel });
4042
- const icon = iconElement && import_react6.default.createElement("div", {
4395
+ const iconElement = typeof node.icon === "string" ? Icon({ c, name: node.icon, color: accent, size: resolvedIconSize, label: iconLabel, muted: node.muted }) : import_react7.default.isValidElement(node.icon) ? node.icon : node.icon?.render({ c, color: accent, size: resolvedIconSize, label: iconLabel });
4396
+ const icon = iconElement && import_react7.default.createElement("div", {
4043
4397
  "data-vizmatic-graph-icon": node.id,
4044
4398
  style: {
4045
4399
  width: resolvedIconSize,
@@ -4051,10 +4405,15 @@ function GraphDiagram({
4051
4405
  overflow: "hidden"
4052
4406
  }
4053
4407
  }, iconElement);
4054
- return import_react6.default.createElement(
4408
+ return import_react7.default.createElement(
4055
4409
  "div",
4056
4410
  {
4057
4411
  key: `graph-node-${node.id}`,
4412
+ "data-vizmatic-graph-node-id": node.id,
4413
+ "data-vizmatic-graph-node-label": graphAccessibleText(node.label) || node.id,
4414
+ "data-vizmatic-graph-node-detail": graphAccessibleText(node.detail),
4415
+ "data-vizmatic-graph-node-title": node.title ?? "",
4416
+ "data-vizmatic-graph-node-href": node.href,
4058
4417
  style: {
4059
4418
  position: "absolute",
4060
4419
  left: node.cx - node.width / 2,
@@ -4069,7 +4428,7 @@ function GraphDiagram({
4069
4428
  padding: "8px 10px",
4070
4429
  boxSizing: "border-box",
4071
4430
  borderRadius: c.preset === "engineering" ? 5 : 10,
4072
- backgroundColor: node.muted ? c.bgSubtle : getToneFill(node.tone ?? "blue", c),
4431
+ backgroundColor: node.muted ? c.bgSubtle : fill,
4073
4432
  border: `${c.preset === "engineering" ? 1.25 : 1.5}px solid ${node.muted ? c.borderLight : `${accent}${c.preset === "engineering" ? "" : "88"}`}`,
4074
4433
  ...!node.muted && c.preset !== "engineering" ? { boxShadow: `0 8px 18px ${c.shadow}` } : {},
4075
4434
  opacity: node.muted ? 0.62 : 1,
@@ -4078,7 +4437,7 @@ function GraphDiagram({
4078
4437
  }
4079
4438
  },
4080
4439
  icon,
4081
- import_react6.default.createElement(
4440
+ import_react7.default.createElement(
4082
4441
  "div",
4083
4442
  {
4084
4443
  style: {
@@ -4089,7 +4448,7 @@ function GraphDiagram({
4089
4448
  minWidth: 0
4090
4449
  }
4091
4450
  },
4092
- import_react6.default.createElement("div", {
4451
+ import_react7.default.createElement("div", {
4093
4452
  style: {
4094
4453
  fontFamily: c.fontSans,
4095
4454
  fontSize: labelFontSize,
@@ -4097,7 +4456,7 @@ function GraphDiagram({
4097
4456
  lineHeight: 1.15
4098
4457
  }
4099
4458
  }, node.label),
4100
- node.detail && import_react6.default.createElement("div", {
4459
+ node.detail && import_react7.default.createElement("div", {
4101
4460
  style: {
4102
4461
  color: c.textMuted,
4103
4462
  fontFamily: c.fontMono,
@@ -4111,6 +4470,7 @@ function GraphDiagram({
4111
4470
  })
4112
4471
  );
4113
4472
  }
4473
+ Object.defineProperty(GraphDiagram, SVG_ACCESSIBILITY_COMPONENT, { value: true });
4114
4474
  function countTreeLeaves(node) {
4115
4475
  if (!node.children?.length) return 1;
4116
4476
  return node.children.reduce((sum, child) => sum + countTreeLeaves(child), 0);
@@ -4187,7 +4547,7 @@ function TreeDiagram({
4187
4547
  return centerIndex;
4188
4548
  };
4189
4549
  placeWithEdges(root, 0, "root");
4190
- const header = (title != null || subtitle != null) && import_react6.default.createElement(
4550
+ const header = (title != null || subtitle != null) && import_react7.default.createElement(
4191
4551
  "div",
4192
4552
  {
4193
4553
  style: {
@@ -4199,7 +4559,7 @@ function TreeDiagram({
4199
4559
  }
4200
4560
  },
4201
4561
  ...compactChildren([
4202
- title != null && import_react6.default.createElement("div", {
4562
+ title != null && import_react7.default.createElement("div", {
4203
4563
  style: {
4204
4564
  display: "flex",
4205
4565
  alignItems: "center",
@@ -4211,7 +4571,7 @@ function TreeDiagram({
4211
4571
  lineHeight: 1.2
4212
4572
  }
4213
4573
  }, ToneStrip({ tone: root.tone ?? "blue" }), renderMaybeMath(title, math)),
4214
- subtitle != null && import_react6.default.createElement("div", {
4574
+ subtitle != null && import_react7.default.createElement("div", {
4215
4575
  style: {
4216
4576
  display: "flex",
4217
4577
  color: c.textSecondary,
@@ -4223,7 +4583,7 @@ function TreeDiagram({
4223
4583
  }, renderMaybeMath(subtitle, math))
4224
4584
  ])
4225
4585
  );
4226
- return import_react6.default.createElement(
4586
+ return import_react7.default.createElement(
4227
4587
  "div",
4228
4588
  {
4229
4589
  style: {
@@ -4236,7 +4596,7 @@ function TreeDiagram({
4236
4596
  },
4237
4597
  ...compactChildren([
4238
4598
  header,
4239
- import_react6.default.createElement(
4599
+ import_react7.default.createElement(
4240
4600
  "div",
4241
4601
  {
4242
4602
  role: "img",
@@ -4250,7 +4610,7 @@ function TreeDiagram({
4250
4610
  flexShrink: 0
4251
4611
  }
4252
4612
  },
4253
- import_react6.default.createElement("svg", {
4613
+ import_react7.default.createElement("svg", {
4254
4614
  width: resolvedWidth,
4255
4615
  height: resolvedHeight,
4256
4616
  viewBox: `0 0 ${resolvedWidth} ${resolvedHeight}`,
@@ -4261,7 +4621,7 @@ function TreeDiagram({
4261
4621
  const startY = edge.from.cy + nodeHeight / 2;
4262
4622
  const endY = edge.to.cy - nodeHeight / 2;
4263
4623
  const midY = startY + (endY - startY) / 2;
4264
- return import_react6.default.createElement("path", {
4624
+ return import_react7.default.createElement("path", {
4265
4625
  key: `tree-edge-${edge.key}`,
4266
4626
  d: `M ${edge.from.cx} ${startY} C ${edge.from.cx} ${midY}, ${edge.to.cx} ${midY}, ${edge.to.cx} ${endY}`,
4267
4627
  fill: "none",
@@ -4274,7 +4634,7 @@ function TreeDiagram({
4274
4634
  ...positioned.map((node) => {
4275
4635
  const accent = node.muted ? c.textMuted : getToneColor(node.tone ?? "blue", c);
4276
4636
  const accentText = node.muted ? c.textMuted : getReadableToneColor(node.tone ?? "blue", c);
4277
- return import_react6.default.createElement(
4637
+ return import_react7.default.createElement(
4278
4638
  "div",
4279
4639
  {
4280
4640
  key: `tree-node-${node.key}`,
@@ -4300,7 +4660,7 @@ function TreeDiagram({
4300
4660
  textAlign: "center"
4301
4661
  }
4302
4662
  },
4303
- import_react6.default.createElement("div", {
4663
+ import_react7.default.createElement("div", {
4304
4664
  style: {
4305
4665
  color: accentText,
4306
4666
  fontFamily: "Inter",
@@ -4310,7 +4670,7 @@ function TreeDiagram({
4310
4670
  ...textFitStyle("center")
4311
4671
  }
4312
4672
  }, renderMaybeMath(node.label, math)),
4313
- node.detail != null && import_react6.default.createElement("div", {
4673
+ node.detail != null && import_react7.default.createElement("div", {
4314
4674
  style: {
4315
4675
  color: c.textMuted,
4316
4676
  fontFamily: "JetBrains Mono",
@@ -4344,7 +4704,7 @@ function CalloutCard({
4344
4704
  const accentText = getReadableToneColor(tone, c);
4345
4705
  const engineering = c.preset === "engineering";
4346
4706
  const textAlign = align;
4347
- return import_react6.default.createElement(
4707
+ return import_react7.default.createElement(
4348
4708
  "div",
4349
4709
  {
4350
4710
  style: {
@@ -4364,7 +4724,7 @@ function CalloutCard({
4364
4724
  }
4365
4725
  },
4366
4726
  ...compactChildren([
4367
- title && import_react6.default.createElement("div", {
4727
+ title && import_react7.default.createElement("div", {
4368
4728
  style: {
4369
4729
  ...typography.small,
4370
4730
  ...titleFontSize != null ? { fontSize: titleFontSize } : {},
@@ -4375,7 +4735,7 @@ function CalloutCard({
4375
4735
  textAlign
4376
4736
  }
4377
4737
  }, title),
4378
- detail && import_react6.default.createElement("div", {
4738
+ detail && import_react7.default.createElement("div", {
4379
4739
  style: {
4380
4740
  ...typography.tiny,
4381
4741
  ...detailFontSize != null ? { fontSize: detailFontSize } : {},
@@ -4385,7 +4745,7 @@ function CalloutCard({
4385
4745
  textAlign
4386
4746
  }
4387
4747
  }, detail),
4388
- children && import_react6.default.createElement("div", {
4748
+ children && import_react7.default.createElement("div", {
4389
4749
  style: {
4390
4750
  display: "flex",
4391
4751
  flexDirection: "column",
@@ -4400,7 +4760,7 @@ function CalloutCard({
4400
4760
  );
4401
4761
  }
4402
4762
  function Pipeline({ stages, c, title }) {
4403
- return import_react6.default.createElement(
4763
+ return import_react7.default.createElement(
4404
4764
  "div",
4405
4765
  {
4406
4766
  style: {
@@ -4410,10 +4770,10 @@ function Pipeline({ stages, c, title }) {
4410
4770
  gap: 20
4411
4771
  }
4412
4772
  },
4413
- title && import_react6.default.createElement("div", {
4773
+ title && import_react7.default.createElement("div", {
4414
4774
  style: { ...typography.label, color: c.textPrimary }
4415
4775
  }, title),
4416
- import_react6.default.createElement(
4776
+ import_react7.default.createElement(
4417
4777
  "div",
4418
4778
  {
4419
4779
  style: {
@@ -4447,7 +4807,7 @@ function Pipeline({ stages, c, title }) {
4447
4807
  }
4448
4808
 
4449
4809
  // src/primitives/sequence.ts
4450
- var import_react7 = __toESM(require("react"), 1);
4810
+ var import_react8 = __toESM(require("react"), 1);
4451
4811
  var sequenceFragmentKinds = ["alt", "loop", "parallel"];
4452
4812
  var sequenceMessageKinds = ["sync", "async", "return"];
4453
4813
  function isFragment(item) {
@@ -4686,7 +5046,7 @@ function SequenceDiagram({
4686
5046
  const spanHeight = Math.max(rowHeight - 8, (span.end - span.start + 1) * rowHeight - 8);
4687
5047
  const left = padding + span.depth * fragmentIndent;
4688
5048
  const fragmentWidth = Math.max(0, resolvedWidth - left - padding - span.depth * fragmentIndent);
4689
- return import_react7.default.createElement(
5049
+ return import_react8.default.createElement(
4690
5050
  "div",
4691
5051
  {
4692
5052
  key: `sequence-fragment-${span.id}`,
@@ -4705,7 +5065,7 @@ function SequenceDiagram({
4705
5065
  pointerEvents: "none"
4706
5066
  }
4707
5067
  },
4708
- import_react7.default.createElement("div", {
5068
+ import_react8.default.createElement("div", {
4709
5069
  style: {
4710
5070
  position: "absolute",
4711
5071
  left: 8,
@@ -4723,7 +5083,7 @@ function SequenceDiagram({
4723
5083
  textTransform: "uppercase"
4724
5084
  }
4725
5085
  }, span.fragment.kind, span.fragment.label),
4726
- ...span.branchStarts.map((branch) => import_react7.default.createElement("div", {
5086
+ ...span.branchStarts.map((branch) => import_react8.default.createElement("div", {
4727
5087
  key: `sequence-branch-${span.id}-${branch.row}`,
4728
5088
  style: {
4729
5089
  position: "absolute",
@@ -4742,7 +5102,7 @@ function SequenceDiagram({
4742
5102
  });
4743
5103
  const lifelineElements = participants.map((participant) => {
4744
5104
  const x = participantXs.get(participant.id) ?? resolvedWidth / 2;
4745
- return import_react7.default.createElement("line", {
5105
+ return import_react8.default.createElement("line", {
4746
5106
  key: `sequence-lifeline-${participant.id}`,
4747
5107
  x1: x,
4748
5108
  y1: bodyTop - 14,
@@ -4766,7 +5126,7 @@ function SequenceDiagram({
4766
5126
  const accent = activation.muted ? c.textMuted : getToneColor(activation.tone ?? "blue", c);
4767
5127
  const top = rowCenter(start) - rowHeight / 2 + 5;
4768
5128
  const activationHeight = Math.max(14, (end - start + 1) * rowHeight - 10);
4769
- return import_react7.default.createElement("div", {
5129
+ return import_react8.default.createElement("div", {
4770
5130
  key: `sequence-activation-${activation.id ?? index}`,
4771
5131
  "data-vizmatic-sequence-activation": activation.participant,
4772
5132
  style: {
@@ -4795,10 +5155,10 @@ function SequenceDiagram({
4795
5155
  const markerId = `sequence-arrow-${participants.findIndex((participant) => participant.id === message.to)}-${kind}`;
4796
5156
  const y = rowCenter(rowIndex);
4797
5157
  const selfLoop = message.from === message.to;
4798
- return import_react7.default.createElement(
4799
- import_react7.default.Fragment,
5158
+ return import_react8.default.createElement(
5159
+ import_react8.default.Fragment,
4800
5160
  { key: `sequence-message-${message.id ?? row.key}` },
4801
- import_react7.default.createElement("path", {
5161
+ import_react8.default.createElement("path", {
4802
5162
  d: sequenceMarkerPath(fromX, toX, y, rowHeight, selfLoop),
4803
5163
  fill: "none",
4804
5164
  stroke: color,
@@ -4808,7 +5168,7 @@ function SequenceDiagram({
4808
5168
  opacity: message.muted ? 0.48 : 0.9,
4809
5169
  markerEnd: `url(#${markerId})`
4810
5170
  }),
4811
- message.label != null && import_react7.default.createElement("div", {
5171
+ message.label != null && import_react8.default.createElement("div", {
4812
5172
  style: {
4813
5173
  position: "absolute",
4814
5174
  left: selfLoop ? fromX + 34 : (fromX + toX) / 2,
@@ -4834,7 +5194,7 @@ function SequenceDiagram({
4834
5194
  const bounds = sequenceNoteBounds(note, participantXs, resolvedWidth, noteWidth, padding);
4835
5195
  const tone = note.tone ?? "warm";
4836
5196
  const accent = note.muted ? c.textMuted : getToneColor(tone, c);
4837
- return import_react7.default.createElement("div", {
5197
+ return import_react8.default.createElement("div", {
4838
5198
  key: `sequence-note-${note.id ?? row.key}`,
4839
5199
  "data-vizmatic-sequence-note": note.id ?? row.key,
4840
5200
  style: {
@@ -4873,7 +5233,7 @@ function SequenceDiagram({
4873
5233
  muted: participant.muted,
4874
5234
  label: readableNodeText(participant.label) ? `${readableNodeText(participant.label)} icon` : void 0
4875
5235
  });
4876
- return import_react7.default.createElement(
5236
+ return import_react8.default.createElement(
4877
5237
  "div",
4878
5238
  {
4879
5239
  key: `sequence-participant-${participant.id}`,
@@ -4900,7 +5260,7 @@ function SequenceDiagram({
4900
5260
  }
4901
5261
  },
4902
5262
  icon,
4903
- import_react7.default.createElement(
5263
+ import_react8.default.createElement(
4904
5264
  "div",
4905
5265
  {
4906
5266
  style: {
@@ -4911,7 +5271,7 @@ function SequenceDiagram({
4911
5271
  gap: participant.detail ? 3 : 0
4912
5272
  }
4913
5273
  },
4914
- import_react7.default.createElement("div", {
5274
+ import_react8.default.createElement("div", {
4915
5275
  style: {
4916
5276
  fontFamily: c.fontSans,
4917
5277
  fontSize: 12,
@@ -4920,7 +5280,7 @@ function SequenceDiagram({
4920
5280
  ...textFitStyle(icon ? "left" : "center")
4921
5281
  }
4922
5282
  }, participant.label),
4923
- participant.detail != null && import_react7.default.createElement("div", {
5283
+ participant.detail != null && import_react8.default.createElement("div", {
4924
5284
  style: {
4925
5285
  color: c.textMuted,
4926
5286
  fontFamily: c.fontMono,
@@ -4933,7 +5293,7 @@ function SequenceDiagram({
4933
5293
  )
4934
5294
  );
4935
5295
  });
4936
- return import_react7.default.createElement(
5296
+ return import_react8.default.createElement(
4937
5297
  "div",
4938
5298
  {
4939
5299
  role: "img",
@@ -4949,7 +5309,7 @@ function SequenceDiagram({
4949
5309
  }
4950
5310
  },
4951
5311
  ...fragmentElements,
4952
- import_react7.default.createElement(
5312
+ import_react8.default.createElement(
4953
5313
  "svg",
4954
5314
  {
4955
5315
  width: resolvedWidth,
@@ -4957,14 +5317,14 @@ function SequenceDiagram({
4957
5317
  viewBox: `0 0 ${resolvedWidth} ${resolvedHeight}`,
4958
5318
  style: { position: "absolute", inset: 0, overflow: "visible" }
4959
5319
  },
4960
- import_react7.default.createElement("defs", {}, ...markerDefinitions),
5320
+ import_react8.default.createElement("defs", {}, ...markerDefinitions),
4961
5321
  ...lifelineElements,
4962
5322
  ...messageElements
4963
5323
  ),
4964
5324
  ...activationElements,
4965
5325
  ...noteElements,
4966
5326
  ...participantElements,
4967
- title != null && import_react7.default.createElement("div", {
5327
+ title != null && import_react8.default.createElement("div", {
4968
5328
  style: {
4969
5329
  position: "absolute",
4970
5330
  left: padding,
@@ -4975,7 +5335,7 @@ function SequenceDiagram({
4975
5335
  fontWeight: 850
4976
5336
  }
4977
5337
  }, title),
4978
- subtitle != null && import_react7.default.createElement("div", {
5338
+ subtitle != null && import_react8.default.createElement("div", {
4979
5339
  style: {
4980
5340
  position: "absolute",
4981
5341
  left: padding,
@@ -5006,7 +5366,7 @@ function sequenceMessageKindsForMarkers(items) {
5006
5366
  }
5007
5367
 
5008
5368
  // src/primitives/dataflow.ts
5009
- var import_react8 = __toESM(require("react"), 1);
5369
+ var import_react9 = __toESM(require("react"), 1);
5010
5370
  var nodeKinds = ["source", "transform", "store", "sink"];
5011
5371
  var edgeModes = ["batch", "stream"];
5012
5372
  var defaultNodeTones = {
@@ -5058,7 +5418,7 @@ function detailWithSchema(detail, schema) {
5058
5418
  if (!renderedSchema) return detail;
5059
5419
  if (detail == null) return renderedSchema;
5060
5420
  if (typeof detail === "string" || typeof detail === "number") return `${detail} \xB7 ${renderedSchema}`;
5061
- return import_react8.default.createElement(
5421
+ return import_react9.default.createElement(
5062
5422
  "div",
5063
5423
  {
5064
5424
  style: {
@@ -5068,8 +5428,8 @@ function detailWithSchema(detail, schema) {
5068
5428
  minWidth: 0
5069
5429
  }
5070
5430
  },
5071
- import_react8.default.createElement("div", null, detail),
5072
- import_react8.default.createElement("div", {
5431
+ import_react9.default.createElement("div", null, detail),
5432
+ import_react9.default.createElement("div", {
5073
5433
  style: {
5074
5434
  fontFamily: "inherit",
5075
5435
  fontSize: "inherit",
@@ -5153,6 +5513,8 @@ function compileDataflow(spec) {
5153
5513
  id: node.id,
5154
5514
  label: node.label,
5155
5515
  detail: detailWithSchema(node.detail, node.schema),
5516
+ href: node.href,
5517
+ title: node.title,
5156
5518
  tone: node.tone ?? defaultNodeTones[kind],
5157
5519
  icon: node.icon ?? defaultNodeIcons[kind],
5158
5520
  muted: node.muted,
@@ -5165,9 +5527,12 @@ function compileDataflow(spec) {
5165
5527
  const mode = edgeMode(edge);
5166
5528
  const schema = schemaLabel(edge.schema);
5167
5529
  return {
5530
+ id: edge.id,
5168
5531
  from: edge.from,
5169
5532
  to: edge.to,
5170
5533
  label: edge.label ?? schema ?? mode,
5534
+ href: edge.href,
5535
+ title: edge.title,
5171
5536
  tone: edge.tone ?? (mode === "stream" ? "cyan" : "blue"),
5172
5537
  muted: edge.muted,
5173
5538
  kind: mode === "stream" ? "async" : "data",
@@ -5188,6 +5553,9 @@ function DataflowDiagram({
5188
5553
  edges,
5189
5554
  boundaries,
5190
5555
  ariaLabel,
5556
+ id,
5557
+ title,
5558
+ description,
5191
5559
  width,
5192
5560
  height,
5193
5561
  nodeWidth = 158,
@@ -5210,6 +5578,9 @@ function DataflowDiagram({
5210
5578
  edges: compiled.edges,
5211
5579
  groups: compiled.groups,
5212
5580
  ariaLabel: compiled.ariaLabel,
5581
+ id,
5582
+ title,
5583
+ description,
5213
5584
  width,
5214
5585
  height,
5215
5586
  nodeWidth,
@@ -5226,6 +5597,7 @@ function DataflowDiagram({
5226
5597
  iconSize
5227
5598
  });
5228
5599
  }
5600
+ Object.defineProperty(DataflowDiagram, SVG_ACCESSIBILITY_COMPONENT, { value: true });
5229
5601
 
5230
5602
  // src/primitives/deployment.ts
5231
5603
  var boundaryKindLabels = {
@@ -5438,10 +5810,10 @@ function validateDeploymentSpec(boundaries, nodes, connections) {
5438
5810
  for (const side of ["from", "to"]) {
5439
5811
  const reference = connectionPortReference(connection, side);
5440
5812
  if (reference == null) continue;
5441
- const nodeId = side === "from" ? connection.from : connection.to;
5442
- const ports = portsByNode.get(nodeId);
5813
+ const nodeId2 = side === "from" ? connection.from : connection.to;
5814
+ const ports = portsByNode.get(nodeId2);
5443
5815
  if (ports != null && ports.size > 0 && !ports.has(String(reference))) {
5444
- throw new Error(`DeploymentDiagram connection "${connection.from}" -> "${connection.to}" references missing ${side} port "${reference}" on node "${nodeId}".`);
5816
+ throw new Error(`DeploymentDiagram connection "${connection.from}" -> "${connection.to}" references missing ${side} port "${reference}" on node "${nodeId2}".`);
5445
5817
  }
5446
5818
  }
5447
5819
  }
@@ -5476,6 +5848,8 @@ function compileDeployment(spec) {
5476
5848
  id: node.id,
5477
5849
  label: node.label,
5478
5850
  detail: node.detail ?? generatedDetail,
5851
+ href: node.href,
5852
+ title: node.title,
5479
5853
  x: node.x,
5480
5854
  y: node.y,
5481
5855
  tone: node.tone,
@@ -5498,6 +5872,7 @@ function compileDeployment(spec) {
5498
5872
  const fallbackFromPort = fromReference != null && !sourceNode?.ports?.length ? fromReference : void 0;
5499
5873
  const fallbackToPort = toReference != null && !targetNode?.ports?.length ? toReference : void 0;
5500
5874
  return {
5875
+ id: connection.id,
5501
5876
  from: connection.from,
5502
5877
  to: connection.to,
5503
5878
  tone: connection.tone ?? connectionTones[kind],
@@ -5505,7 +5880,9 @@ function compileDeployment(spec) {
5505
5880
  kind: graphConnectionKind(kind),
5506
5881
  style: connection.style ?? graphConnectionStyle(kind),
5507
5882
  arrow: connection.arrow ?? "forward",
5508
- label: connectionLabel(connection, sourcePort ?? fallbackFromPort, targetPort ?? fallbackToPort)
5883
+ label: connectionLabel(connection, sourcePort ?? fallbackFromPort, targetPort ?? fallbackToPort),
5884
+ href: connection.href,
5885
+ title: connection.title
5509
5886
  };
5510
5887
  });
5511
5888
  return {
@@ -5533,6 +5910,7 @@ function DeploymentDiagram({
5533
5910
  ariaLabel: compiled.ariaLabel
5534
5911
  });
5535
5912
  }
5913
+ Object.defineProperty(DeploymentDiagram, SVG_ACCESSIBILITY_COMPONENT, { value: true });
5536
5914
 
5537
5915
  // src/primitives/transformer.ts
5538
5916
  var blockLabels = {
@@ -5731,6 +6109,8 @@ function compileTransformer(spec) {
5731
6109
  id,
5732
6110
  label,
5733
6111
  detail: repetitionDetail,
6112
+ href: block.href,
6113
+ title: block.title,
5734
6114
  x: block.x,
5735
6115
  y: block.y,
5736
6116
  tone: block.tone ?? blockTones[kind],
@@ -5745,8 +6125,10 @@ function compileTransformer(spec) {
5745
6125
  const edges = [];
5746
6126
  for (const route of routes) {
5747
6127
  const kind = resolveRouteKind(route);
5748
- for (const endpoint of expandedRouteEndpoints(route, repeatCounts, expandRepeats)) {
6128
+ const endpoints = expandedRouteEndpoints(route, repeatCounts, expandRepeats);
6129
+ for (const [index, endpoint] of endpoints.entries()) {
5749
6130
  edges.push({
6131
+ id: route.id == null ? void 0 : endpoints.length === 1 ? route.id : `${route.id}-${index + 1}`,
5750
6132
  from: endpoint.from,
5751
6133
  to: endpoint.to,
5752
6134
  tone: route.tone ?? routeTones[kind],
@@ -5754,7 +6136,9 @@ function compileTransformer(spec) {
5754
6136
  kind: graphRouteKind(kind),
5755
6137
  style: route.style ?? graphRouteStyle(kind),
5756
6138
  arrow: route.arrow ?? (kind === "residual" ? "both" : "forward"),
5757
- label: routeLabel(route, kind)
6139
+ label: routeLabel(route, kind),
6140
+ href: route.href,
6141
+ title: route.title
5758
6142
  });
5759
6143
  }
5760
6144
  }
@@ -5786,9 +6170,10 @@ function TransformerTopology({
5786
6170
  ariaLabel: compiled.ariaLabel
5787
6171
  });
5788
6172
  }
6173
+ Object.defineProperty(TransformerTopology, SVG_ACCESSIBILITY_COMPONENT, { value: true });
5789
6174
 
5790
6175
  // src/primitives/data.ts
5791
- var import_react9 = __toESM(require("react"), 1);
6176
+ var import_react10 = __toESM(require("react"), 1);
5792
6177
  function Matrix({
5793
6178
  data,
5794
6179
  c,
@@ -5818,7 +6203,7 @@ function Matrix({
5818
6203
  if (value < 0.67) return c.infoDark;
5819
6204
  return c.positiveDark;
5820
6205
  };
5821
- return import_react9.default.createElement(
6206
+ return import_react10.default.createElement(
5822
6207
  "div",
5823
6208
  {
5824
6209
  style: {
@@ -5828,10 +6213,10 @@ function Matrix({
5828
6213
  gap: 12
5829
6214
  }
5830
6215
  },
5831
- title && import_react9.default.createElement("div", {
6216
+ title && import_react10.default.createElement("div", {
5832
6217
  style: { ...typography.label, color: c.textPrimary }
5833
6218
  }, title),
5834
- import_react9.default.createElement(
6219
+ import_react10.default.createElement(
5835
6220
  "div",
5836
6221
  {
5837
6222
  style: {
@@ -5841,7 +6226,7 @@ function Matrix({
5841
6226
  }
5842
6227
  },
5843
6228
  // Column labels
5844
- colLabels && import_react9.default.createElement(
6229
+ colLabels && import_react10.default.createElement(
5845
6230
  "div",
5846
6231
  {
5847
6232
  style: {
@@ -5851,7 +6236,7 @@ function Matrix({
5851
6236
  }
5852
6237
  },
5853
6238
  ...colLabels.map(
5854
- (label, i) => import_react9.default.createElement("div", {
6239
+ (label, i) => import_react10.default.createElement("div", {
5855
6240
  key: `col-${i}`,
5856
6241
  style: {
5857
6242
  width: resolvedCellWidth,
@@ -5865,7 +6250,7 @@ function Matrix({
5865
6250
  )
5866
6251
  ),
5867
6252
  ...data.map(
5868
- (row, ri) => import_react9.default.createElement(
6253
+ (row, ri) => import_react10.default.createElement(
5869
6254
  "div",
5870
6255
  {
5871
6256
  key: `row-${ri}`,
@@ -5875,7 +6260,7 @@ function Matrix({
5875
6260
  alignItems: "center"
5876
6261
  }
5877
6262
  },
5878
- rowLabels && import_react9.default.createElement("div", {
6263
+ rowLabels && import_react10.default.createElement("div", {
5879
6264
  style: {
5880
6265
  width: resolvedRowLabelWidth,
5881
6266
  textAlign: "right",
@@ -5888,7 +6273,7 @@ function Matrix({
5888
6273
  }, rowLabels[ri]),
5889
6274
  ...row.map((value, ci) => {
5890
6275
  const backgroundColor = colorize ? cellColor(value) : c.bgCard;
5891
- return import_react9.default.createElement("div", {
6276
+ return import_react10.default.createElement("div", {
5892
6277
  key: `cell-${ri}-${ci}`,
5893
6278
  style: {
5894
6279
  width: resolvedCellWidth,
@@ -5957,7 +6342,7 @@ function TiledMatrix({
5957
6342
  const baseAccent = getToneColor(tone, c);
5958
6343
  const cellRows = Array.from(
5959
6344
  { length: safeRows },
5960
- (_, row) => import_react9.default.createElement(
6345
+ (_, row) => import_react10.default.createElement(
5961
6346
  "div",
5962
6347
  {
5963
6348
  key: `tiled-matrix-row-${row}`,
@@ -5972,7 +6357,7 @@ function TiledMatrix({
5972
6357
  );
5973
6358
  const region = regionIndex >= 0 ? regions[regionIndex] : void 0;
5974
6359
  const accent = getToneColor(region?.tone ?? tone, c);
5975
- return import_react9.default.createElement("div", {
6360
+ return import_react10.default.createElement("div", {
5976
6361
  key: `tiled-matrix-cell-${row}-${col}`,
5977
6362
  "data-region": regionIndex >= 0 ? regionIndex : void 0,
5978
6363
  style: {
@@ -5988,7 +6373,7 @@ function TiledMatrix({
5988
6373
  })
5989
6374
  )
5990
6375
  );
5991
- const grid = import_react9.default.createElement(
6376
+ const grid = import_react10.default.createElement(
5992
6377
  "div",
5993
6378
  {
5994
6379
  "data-crossed-out": crossedOut ? "true" : void 0,
@@ -6007,7 +6392,7 @@ function TiledMatrix({
6007
6392
  },
6008
6393
  ...cellRows,
6009
6394
  ...crossedOut ? [
6010
- import_react9.default.createElement("div", {
6395
+ import_react10.default.createElement("div", {
6011
6396
  key: "cross-forward",
6012
6397
  style: {
6013
6398
  position: "absolute",
@@ -6022,7 +6407,7 @@ function TiledMatrix({
6022
6407
  boxShadow: `0 0 0 1px ${c.bgCard}`
6023
6408
  }
6024
6409
  }),
6025
- import_react9.default.createElement("div", {
6410
+ import_react10.default.createElement("div", {
6026
6411
  key: "cross-backward",
6027
6412
  style: {
6028
6413
  position: "absolute",
@@ -6039,7 +6424,7 @@ function TiledMatrix({
6039
6424
  })
6040
6425
  ] : []
6041
6426
  );
6042
- return import_react9.default.createElement(
6427
+ return import_react10.default.createElement(
6043
6428
  "div",
6044
6429
  {
6045
6430
  role: "img",
@@ -6052,7 +6437,7 @@ function TiledMatrix({
6052
6437
  }
6053
6438
  },
6054
6439
  ...compactChildren([
6055
- title && import_react9.default.createElement("div", {
6440
+ title && import_react10.default.createElement("div", {
6056
6441
  style: {
6057
6442
  color: muted ? c.textMuted : getReadableToneColor(tone, c),
6058
6443
  fontFamily: "Inter",
@@ -6062,7 +6447,7 @@ function TiledMatrix({
6062
6447
  textAlign: "center"
6063
6448
  }
6064
6449
  }, title),
6065
- subtitle && import_react9.default.createElement("div", {
6450
+ subtitle && import_react10.default.createElement("div", {
6066
6451
  style: {
6067
6452
  color: c.textMuted,
6068
6453
  fontFamily: "JetBrains Mono",
@@ -6089,7 +6474,7 @@ function DataTable({
6089
6474
  math = false
6090
6475
  }) {
6091
6476
  const renderCell = (cell) => math && typeof cell === "string" ? formatMathText(cell) : cell;
6092
- return import_react9.default.createElement(
6477
+ return import_react10.default.createElement(
6093
6478
  "div",
6094
6479
  {
6095
6480
  style: {
@@ -6099,7 +6484,7 @@ function DataTable({
6099
6484
  alignItems: "center"
6100
6485
  }
6101
6486
  },
6102
- ...rows.map((row, rowIndex) => import_react9.default.createElement(
6487
+ ...rows.map((row, rowIndex) => import_react10.default.createElement(
6103
6488
  "div",
6104
6489
  {
6105
6490
  key: `${rowIndex}-${row.map(String).join("|")}`,
@@ -6111,7 +6496,7 @@ function DataTable({
6111
6496
  ...row.map((cell, colIndex) => {
6112
6497
  const isHeaderRow = rowIndex < headerRows;
6113
6498
  const isHeaderCol = colIndex < headerCols;
6114
- return import_react9.default.createElement("div", {
6499
+ return import_react10.default.createElement("div", {
6115
6500
  key: `${rowIndex}-${colIndex}-${String(cell)}`,
6116
6501
  style: {
6117
6502
  width: colIndex === 0 ? firstColWidth : cellWidth,
@@ -6134,7 +6519,7 @@ function DataTable({
6134
6519
  );
6135
6520
  }
6136
6521
  function isGridCell(cell) {
6137
- return typeof cell === "object" && cell !== null && !import_react9.default.isValidElement(cell) && ("label" in cell || "tone" in cell || "color" in cell || "backgroundColor" in cell || "borderColor" in cell || "opacity" in cell);
6522
+ return typeof cell === "object" && cell !== null && !import_react10.default.isValidElement(cell) && ("label" in cell || "tone" in cell || "color" in cell || "backgroundColor" in cell || "borderColor" in cell || "opacity" in cell);
6138
6523
  }
6139
6524
  function Grid({
6140
6525
  rows,
@@ -6155,8 +6540,9 @@ function Grid({
6155
6540
  const cellStyle = (cell, rowIndex, colIndex) => {
6156
6541
  const config = isGridCell(cell) ? cell : {};
6157
6542
  const toneColor = config.tone ? getToneColor(config.tone, c) : void 0;
6158
- const toneTextColor = config.tone ? getReadableToneColor(config.tone, c) : void 0;
6159
6543
  const isHeader = rowIndex < headerRows || colIndex < headerCols;
6544
+ const backgroundColor = config.backgroundColor ?? (toneColor ? `${toneColor}22` : isHeader ? c.bgSubtle : c.bgHover);
6545
+ const toneTextColor = config.tone ? getReadableToneColor(config.tone, c, backgroundColor, c.bgHover) : void 0;
6160
6546
  return {
6161
6547
  width: cellWidth,
6162
6548
  height: cellHeight,
@@ -6164,7 +6550,7 @@ function Grid({
6164
6550
  alignItems: "center",
6165
6551
  justifyContent: "center",
6166
6552
  borderRadius: radius,
6167
- backgroundColor: config.backgroundColor ?? (toneColor ? `${toneColor}22` : isHeader ? c.bgSubtle : c.bgHover),
6553
+ backgroundColor,
6168
6554
  border: `1px solid ${config.borderColor ?? (toneColor ? `${toneColor}55` : c.borderSubtle)}`,
6169
6555
  color: config.color ?? (toneTextColor ?? (isHeader ? c.textPrimary : c.textSecondary)),
6170
6556
  ...config.opacity !== void 0 ? { opacity: config.opacity } : {},
@@ -6175,7 +6561,7 @@ function Grid({
6175
6561
  ...textFitStyle("center")
6176
6562
  };
6177
6563
  };
6178
- return import_react9.default.createElement(
6564
+ return import_react10.default.createElement(
6179
6565
  "div",
6180
6566
  {
6181
6567
  style: {
@@ -6185,7 +6571,7 @@ function Grid({
6185
6571
  alignItems: "center"
6186
6572
  }
6187
6573
  },
6188
- ...rows.map((row, rowIndex) => import_react9.default.createElement(
6574
+ ...rows.map((row, rowIndex) => import_react10.default.createElement(
6189
6575
  "div",
6190
6576
  {
6191
6577
  key: `grid-row-${rowIndex}`,
@@ -6194,7 +6580,7 @@ function Grid({
6194
6580
  gap
6195
6581
  }
6196
6582
  },
6197
- ...row.map((cell, colIndex) => import_react9.default.createElement("div", {
6583
+ ...row.map((cell, colIndex) => import_react10.default.createElement("div", {
6198
6584
  key: `grid-cell-${rowIndex}-${colIndex}`,
6199
6585
  style: cellStyle(cell, rowIndex, colIndex)
6200
6586
  }, renderCellLabel(cell)))
@@ -6254,7 +6640,7 @@ function AxisPlot({
6254
6640
  const x = padding + innerWidth * index / (gridCount + 1);
6255
6641
  const y = padding + innerHeight * index / (gridCount + 1);
6256
6642
  return [
6257
- import_react9.default.createElement("line", {
6643
+ import_react10.default.createElement("line", {
6258
6644
  key: `axis-grid-x-${index}`,
6259
6645
  x1: x,
6260
6646
  y1: padding,
@@ -6264,7 +6650,7 @@ function AxisPlot({
6264
6650
  strokeWidth: 1,
6265
6651
  opacity: 0.75
6266
6652
  }),
6267
- import_react9.default.createElement("line", {
6653
+ import_react10.default.createElement("line", {
6268
6654
  key: `axis-grid-y-${index}`,
6269
6655
  x1: padding,
6270
6656
  y1: y,
@@ -6279,7 +6665,7 @@ function AxisPlot({
6279
6665
  }
6280
6666
  if (showAxes) {
6281
6667
  elements.push(
6282
- import_react9.default.createElement("line", {
6668
+ import_react10.default.createElement("line", {
6283
6669
  key: "axis-x",
6284
6670
  x1: padding,
6285
6671
  y1: xAxisY,
@@ -6289,7 +6675,7 @@ function AxisPlot({
6289
6675
  strokeWidth: 1.6,
6290
6676
  opacity: 0.85
6291
6677
  }),
6292
- import_react9.default.createElement("line", {
6678
+ import_react10.default.createElement("line", {
6293
6679
  key: "axis-y",
6294
6680
  x1: yAxisX,
6295
6681
  y1: padding,
@@ -6312,7 +6698,7 @@ function AxisPlot({
6312
6698
  commands.push(`L ${sx(point.x)} ${sy(point.y)}`);
6313
6699
  }
6314
6700
  }
6315
- return [import_react9.default.createElement("path", {
6701
+ return [import_react10.default.createElement("path", {
6316
6702
  key: `axis-path-${index}`,
6317
6703
  d: commands.join(" "),
6318
6704
  fill: "none",
@@ -6367,14 +6753,14 @@ function AxisPlot({
6367
6753
  strokeWidth: point.strokeWidth,
6368
6754
  opacity: point.opacity
6369
6755
  })));
6370
- elements.push(...import_react9.default.Children.toArray(children).filter(import_react9.default.isValidElement));
6371
- const svg = import_react9.default.createElement("svg", {
6756
+ elements.push(...import_react10.default.Children.toArray(children).filter(import_react10.default.isValidElement));
6757
+ const svg = import_react10.default.createElement("svg", {
6372
6758
  width,
6373
6759
  height,
6374
6760
  viewBox: `0 0 ${width} ${height}`
6375
6761
  }, ...elements);
6376
6762
  if (!xAxisLabel && !yAxisLabel) return svg;
6377
- return import_react9.default.createElement(
6763
+ return import_react10.default.createElement(
6378
6764
  "div",
6379
6765
  {
6380
6766
  style: {
@@ -6385,7 +6771,7 @@ function AxisPlot({
6385
6771
  }
6386
6772
  },
6387
6773
  svg,
6388
- xAxisLabel && import_react9.default.createElement("div", {
6774
+ xAxisLabel && import_react10.default.createElement("div", {
6389
6775
  key: "axis-x-label",
6390
6776
  style: {
6391
6777
  position: "absolute",
@@ -6400,7 +6786,7 @@ function AxisPlot({
6400
6786
  fontWeight: 750
6401
6787
  }
6402
6788
  }, xAxisLabel),
6403
- yAxisLabel && import_react9.default.createElement("div", {
6789
+ yAxisLabel && import_react10.default.createElement("div", {
6404
6790
  key: "axis-y-label",
6405
6791
  style: {
6406
6792
  position: "absolute",
@@ -6419,7 +6805,7 @@ function AxisPlot({
6419
6805
  }
6420
6806
 
6421
6807
  // src/primitives/charts.ts
6422
- var import_react10 = __toESM(require("react"), 1);
6808
+ var import_react11 = __toESM(require("react"), 1);
6423
6809
  var chartPalette = ["primary", "secondary", "positive", "warning", "info", "accent", "critical"];
6424
6810
  function isColorName(value) {
6425
6811
  return chartPalette.includes(value) || value === "neutral";
@@ -6509,7 +6895,7 @@ function chartLabel(key, text, x, y, c, options = {}) {
6509
6895
  );
6510
6896
  transform = void 0;
6511
6897
  }
6512
- return import_react10.default.createElement("div", {
6898
+ return import_react11.default.createElement("div", {
6513
6899
  key,
6514
6900
  style: {
6515
6901
  position: "absolute",
@@ -6562,7 +6948,7 @@ function ChartFrame({
6562
6948
  height,
6563
6949
  padding = 16
6564
6950
  }) {
6565
- return import_react10.default.createElement(
6951
+ return import_react11.default.createElement(
6566
6952
  "div",
6567
6953
  {
6568
6954
  style: {
@@ -6579,20 +6965,20 @@ function ChartFrame({
6579
6965
  boxShadow: `0 9px 24px ${c.shadow}`
6580
6966
  }
6581
6967
  },
6582
- (title || subtitle) && import_react10.default.createElement(
6968
+ (title || subtitle) && import_react11.default.createElement(
6583
6969
  "div",
6584
6970
  {
6585
6971
  style: { display: "flex", flexDirection: "column", gap: 4, minWidth: 0, maxWidth: "100%" }
6586
6972
  },
6587
- title && import_react10.default.createElement("div", {
6973
+ title && import_react11.default.createElement("div", {
6588
6974
  style: { ...typography.small, ...textFitStyle(), color: c.textPrimary, fontWeight: 900 }
6589
6975
  }, title),
6590
- subtitle && import_react10.default.createElement("div", {
6976
+ subtitle && import_react11.default.createElement("div", {
6591
6977
  style: { ...typography.tiny, ...textFitStyle(), color: c.textSecondary, lineHeight: 1.35 }
6592
6978
  }, subtitle)
6593
6979
  ),
6594
6980
  children,
6595
- (legend || footer) && import_react10.default.createElement(
6981
+ (legend || footer) && import_react11.default.createElement(
6596
6982
  "div",
6597
6983
  {
6598
6984
  style: {
@@ -6603,18 +6989,18 @@ function ChartFrame({
6603
6989
  minHeight: 18
6604
6990
  }
6605
6991
  },
6606
- legend && import_react10.default.createElement(
6992
+ legend && import_react11.default.createElement(
6607
6993
  "div",
6608
6994
  {
6609
6995
  style: { display: "flex", alignItems: "center", gap: 12, flexWrap: "wrap", minWidth: 0 }
6610
6996
  },
6611
- ...legend.map((item, index) => import_react10.default.createElement(
6997
+ ...legend.map((item, index) => import_react11.default.createElement(
6612
6998
  "div",
6613
6999
  {
6614
7000
  key: `${item.label}-${index}`,
6615
7001
  style: { display: "flex", alignItems: "center", gap: 6, minWidth: 0 }
6616
7002
  },
6617
- import_react10.default.createElement("span", {
7003
+ import_react11.default.createElement("span", {
6618
7004
  style: {
6619
7005
  width: 14,
6620
7006
  height: 3,
@@ -6623,12 +7009,12 @@ function ChartFrame({
6623
7009
  display: "flex"
6624
7010
  }
6625
7011
  }),
6626
- import_react10.default.createElement("span", {
7012
+ import_react11.default.createElement("span", {
6627
7013
  style: { ...typography.tiny, ...textFitStyle(), color: c.textSecondary }
6628
7014
  }, item.label)
6629
7015
  ))
6630
7016
  ),
6631
- footer && import_react10.default.createElement("div", {
7017
+ footer && import_react11.default.createElement("div", {
6632
7018
  style: { ...typography.tiny, ...textFitStyle("right"), color: c.textMuted }
6633
7019
  }, footer)
6634
7020
  )
@@ -6689,13 +7075,13 @@ function DonutChart({
6689
7075
  const end = cursor + rawSpan - gap / 2;
6690
7076
  cursor += rawSpan;
6691
7077
  if (end <= start) return null;
6692
- return import_react10.default.createElement("path", {
7078
+ return import_react11.default.createElement("path", {
6693
7079
  key: `donut-segment-${segment.label}-${index}`,
6694
7080
  d: donutArcPath(cx, cy, outerRadius, innerRadius, start, end),
6695
7081
  fill: chartColor(segment.color, c, index)
6696
7082
  });
6697
7083
  }).filter(Boolean);
6698
- const legend = showLegend && positiveSegments.length > 0 && import_react10.default.createElement("div", {
7084
+ const legend = showLegend && positiveSegments.length > 0 && import_react11.default.createElement("div", {
6699
7085
  style: {
6700
7086
  display: "flex",
6701
7087
  flexDirection: "column",
@@ -6703,7 +7089,7 @@ function DonutChart({
6703
7089
  flex: 1,
6704
7090
  minWidth: 112
6705
7091
  }
6706
- }, ...positiveSegments.map((segment, index) => import_react10.default.createElement(
7092
+ }, ...positiveSegments.map((segment, index) => import_react11.default.createElement(
6707
7093
  "div",
6708
7094
  {
6709
7095
  key: `donut-legend-${segment.label}-${index}`,
@@ -6714,7 +7100,7 @@ function DonutChart({
6714
7100
  minWidth: 0
6715
7101
  }
6716
7102
  },
6717
- import_react10.default.createElement("span", {
7103
+ import_react11.default.createElement("span", {
6718
7104
  style: {
6719
7105
  display: "flex",
6720
7106
  width: 10,
@@ -6724,7 +7110,7 @@ function DonutChart({
6724
7110
  flexShrink: 0
6725
7111
  }
6726
7112
  }),
6727
- import_react10.default.createElement("span", {
7113
+ import_react11.default.createElement("span", {
6728
7114
  style: {
6729
7115
  ...typography.tiny,
6730
7116
  ...textFitStyle(),
@@ -6732,7 +7118,7 @@ function DonutChart({
6732
7118
  flex: 1
6733
7119
  }
6734
7120
  }, segment.label),
6735
- import_react10.default.createElement("span", {
7121
+ import_react11.default.createElement("span", {
6736
7122
  style: {
6737
7123
  ...typography.tiny,
6738
7124
  color: c.textPrimary,
@@ -6750,7 +7136,7 @@ function DonutChart({
6750
7136
  width,
6751
7137
  height,
6752
7138
  padding: 16,
6753
- children: import_react10.default.createElement(
7139
+ children: import_react11.default.createElement(
6754
7140
  "div",
6755
7141
  {
6756
7142
  style: {
@@ -6762,7 +7148,7 @@ function DonutChart({
6762
7148
  width: "100%"
6763
7149
  }
6764
7150
  },
6765
- import_react10.default.createElement(
7151
+ import_react11.default.createElement(
6766
7152
  "div",
6767
7153
  {
6768
7154
  style: {
@@ -6773,14 +7159,14 @@ function DonutChart({
6773
7159
  flexShrink: 0
6774
7160
  }
6775
7161
  },
6776
- import_react10.default.createElement(
7162
+ import_react11.default.createElement(
6777
7163
  "svg",
6778
7164
  {
6779
7165
  width: resolvedSize,
6780
7166
  height: resolvedSize,
6781
7167
  viewBox: `0 0 ${resolvedSize} ${resolvedSize}`
6782
7168
  },
6783
- positiveSegments.length === 0 ? import_react10.default.createElement("circle", {
7169
+ positiveSegments.length === 0 ? import_react11.default.createElement("circle", {
6784
7170
  cx,
6785
7171
  cy,
6786
7172
  r: (outerRadius + innerRadius) / 2,
@@ -6789,7 +7175,7 @@ function DonutChart({
6789
7175
  strokeWidth: resolvedThickness
6790
7176
  }) : paths
6791
7177
  ),
6792
- (centerLabel != null || resolvedCenterValue != null) && import_react10.default.createElement(
7178
+ (centerLabel != null || resolvedCenterValue != null) && import_react11.default.createElement(
6793
7179
  "div",
6794
7180
  {
6795
7181
  style: {
@@ -6808,7 +7194,7 @@ function DonutChart({
6808
7194
  textAlign: "center"
6809
7195
  }
6810
7196
  },
6811
- resolvedCenterValue != null && import_react10.default.createElement("div", {
7197
+ resolvedCenterValue != null && import_react11.default.createElement("div", {
6812
7198
  style: {
6813
7199
  ...typography.small,
6814
7200
  color: c.textPrimary,
@@ -6819,7 +7205,7 @@ function DonutChart({
6819
7205
  ...textFitStyle("center")
6820
7206
  }
6821
7207
  }, resolvedCenterValue),
6822
- centerLabel != null && import_react10.default.createElement("div", {
7208
+ centerLabel != null && import_react11.default.createElement("div", {
6823
7209
  style: {
6824
7210
  ...typography.tiny,
6825
7211
  color: c.textMuted,
@@ -6844,7 +7230,7 @@ function StackedBar({
6844
7230
  }) {
6845
7231
  const positiveSegments = segments.filter((segment) => segment.value > 0);
6846
7232
  const total = positiveSegments.reduce((sum, segment) => sum + segment.value, 0);
6847
- return import_react10.default.createElement(
7233
+ return import_react11.default.createElement(
6848
7234
  "div",
6849
7235
  {
6850
7236
  style: {
@@ -6854,7 +7240,7 @@ function StackedBar({
6854
7240
  gap: 10
6855
7241
  }
6856
7242
  },
6857
- (title || subtitle) && import_react10.default.createElement(
7243
+ (title || subtitle) && import_react11.default.createElement(
6858
7244
  "div",
6859
7245
  {
6860
7246
  style: {
@@ -6863,14 +7249,14 @@ function StackedBar({
6863
7249
  gap: 3
6864
7250
  }
6865
7251
  },
6866
- title && import_react10.default.createElement("div", {
7252
+ title && import_react11.default.createElement("div", {
6867
7253
  style: { ...typography.label, color: c.textPrimary, fontWeight: 850 }
6868
7254
  }, title),
6869
- subtitle && import_react10.default.createElement("div", {
7255
+ subtitle && import_react11.default.createElement("div", {
6870
7256
  style: { ...typography.tiny, color: c.textSecondary }
6871
7257
  }, subtitle)
6872
7258
  ),
6873
- import_react10.default.createElement(
7259
+ import_react11.default.createElement(
6874
7260
  "div",
6875
7261
  {
6876
7262
  style: {
@@ -6888,7 +7274,7 @@ function StackedBar({
6888
7274
  const share = total > 0 ? segment.value / total : 0;
6889
7275
  const segmentWidth = width * share;
6890
7276
  const color = chartColor(segment.color, c, index);
6891
- return import_react10.default.createElement(
7277
+ return import_react11.default.createElement(
6892
7278
  "div",
6893
7279
  {
6894
7280
  key: `${segment.label}-${index}`,
@@ -6902,7 +7288,7 @@ function StackedBar({
6902
7288
  ...index < positiveSegments.length - 1 ? { borderRight: `2px solid ${c.bgSubtle}` } : {}
6903
7289
  }
6904
7290
  },
6905
- segmentWidth >= 64 && import_react10.default.createElement("span", {
7291
+ segmentWidth >= 64 && import_react11.default.createElement("span", {
6906
7292
  style: {
6907
7293
  ...typography.small,
6908
7294
  color: getReadableTextColor(color, c),
@@ -6913,7 +7299,7 @@ function StackedBar({
6913
7299
  );
6914
7300
  })
6915
7301
  ),
6916
- showLegend && import_react10.default.createElement(
7302
+ showLegend && import_react11.default.createElement(
6917
7303
  "div",
6918
7304
  {
6919
7305
  style: {
@@ -6925,13 +7311,13 @@ function StackedBar({
6925
7311
  },
6926
7312
  ...positiveSegments.map((segment, index) => {
6927
7313
  const share = total > 0 ? segment.value / total : 0;
6928
- return import_react10.default.createElement(
7314
+ return import_react11.default.createElement(
6929
7315
  "div",
6930
7316
  {
6931
7317
  key: `legend-${segment.label}-${index}`,
6932
7318
  style: { display: "flex", alignItems: "center", gap: 7 }
6933
7319
  },
6934
- import_react10.default.createElement("span", {
7320
+ import_react11.default.createElement("span", {
6935
7321
  style: {
6936
7322
  width: 12,
6937
7323
  height: 12,
@@ -6940,7 +7326,7 @@ function StackedBar({
6940
7326
  backgroundColor: chartColor(segment.color, c, index)
6941
7327
  }
6942
7328
  }),
6943
- import_react10.default.createElement("span", {
7329
+ import_react11.default.createElement("span", {
6944
7330
  style: { ...typography.tiny, color: c.textSecondary }
6945
7331
  }, `${segment.label} ${segment.valueLabel ?? formatChartValue(share, "percent")}`)
6946
7332
  );
@@ -6986,18 +7372,18 @@ function BarChart({
6986
7372
  subtitle,
6987
7373
  width,
6988
7374
  footer,
6989
- children: import_react10.default.createElement(
7375
+ children: import_react11.default.createElement(
6990
7376
  "div",
6991
7377
  { style: { position: "relative", width, height, display: "flex" } },
6992
- import_react10.default.createElement(
7378
+ import_react11.default.createElement(
6993
7379
  "svg",
6994
7380
  { width, height, viewBox: `0 0 ${width} ${height}` },
6995
- showGrid && import_react10.default.createElement(
7381
+ showGrid && import_react11.default.createElement(
6996
7382
  "g",
6997
7383
  {},
6998
7384
  ...ticks.map((tick) => {
6999
7385
  const y = yInPlot(tick, domain, plot);
7000
- return import_react10.default.createElement("line", {
7386
+ return import_react11.default.createElement("line", {
7001
7387
  key: `tick-${tick}`,
7002
7388
  x1: plot.x,
7003
7389
  y1: y,
@@ -7008,10 +7394,10 @@ function BarChart({
7008
7394
  });
7009
7395
  })
7010
7396
  ),
7011
- import_react10.default.createElement("line", { x1: plot.x, y1: plot.y, x2: plot.x, y2: plot.bottom, stroke: c.borderLight, strokeWidth: 1.2 }),
7012
- import_react10.default.createElement("line", { x1: plot.x, y1: baselineY, x2: plot.right, y2: baselineY, stroke: c.borderLight, strokeWidth: 1.2 }),
7397
+ import_react11.default.createElement("line", { x1: plot.x, y1: plot.y, x2: plot.x, y2: plot.bottom, stroke: c.borderLight, strokeWidth: 1.2 }),
7398
+ import_react11.default.createElement("line", { x1: plot.x, y1: baselineY, x2: plot.right, y2: baselineY, stroke: c.borderLight, strokeWidth: 1.2 }),
7013
7399
  ...barGeometries.map(
7014
- ({ item, index, x, y, barHeight, color }) => import_react10.default.createElement("rect", {
7400
+ ({ item, index, x, y, barHeight, color }) => import_react11.default.createElement("rect", {
7015
7401
  key: `${item.label}-${index}`,
7016
7402
  x,
7017
7403
  y,
@@ -7090,18 +7476,18 @@ function LineChart({
7090
7476
  width,
7091
7477
  footer,
7092
7478
  legend: series.map((item, index) => ({ label: item.name, color: item.color ?? chartPalette[index % chartPalette.length] })),
7093
- children: import_react10.default.createElement(
7479
+ children: import_react11.default.createElement(
7094
7480
  "div",
7095
7481
  { style: { position: "relative", width, height, display: "flex" } },
7096
- import_react10.default.createElement(
7482
+ import_react11.default.createElement(
7097
7483
  "svg",
7098
7484
  { width, height, viewBox: `0 0 ${width} ${height}` },
7099
- showGrid && import_react10.default.createElement(
7485
+ showGrid && import_react11.default.createElement(
7100
7486
  "g",
7101
7487
  {},
7102
7488
  ...ticks.map((tick) => {
7103
7489
  const y = yInPlot(tick, domain, plot);
7104
- return import_react10.default.createElement("line", {
7490
+ return import_react11.default.createElement("line", {
7105
7491
  key: `line-tick-${tick}`,
7106
7492
  x1: plot.x,
7107
7493
  y1: y,
@@ -7112,8 +7498,8 @@ function LineChart({
7112
7498
  });
7113
7499
  })
7114
7500
  ),
7115
- import_react10.default.createElement("line", { x1: plot.x, y1: plot.y, x2: plot.x, y2: plot.bottom, stroke: c.borderLight, strokeWidth: 1.2 }),
7116
- import_react10.default.createElement("line", { x1: plot.x, y1: plot.bottom, x2: plot.right, y2: plot.bottom, stroke: c.borderLight, strokeWidth: 1.2 }),
7501
+ import_react11.default.createElement("line", { x1: plot.x, y1: plot.y, x2: plot.x, y2: plot.bottom, stroke: c.borderLight, strokeWidth: 1.2 }),
7502
+ import_react11.default.createElement("line", { x1: plot.x, y1: plot.bottom, x2: plot.right, y2: plot.bottom, stroke: c.borderLight, strokeWidth: 1.2 }),
7117
7503
  ...series.flatMap((item, seriesIndex) => {
7118
7504
  if (item.points.length === 0) return [];
7119
7505
  const color = chartColor(item.color, c, seriesIndex);
@@ -7126,9 +7512,9 @@ function LineChart({
7126
7512
  }
7127
7513
  const elements = [];
7128
7514
  if (areaPath) {
7129
- elements.push(import_react10.default.createElement("path", { key: `${item.name}-area`, d: areaPath, fill: color, opacity: 0.12 }));
7515
+ elements.push(import_react11.default.createElement("path", { key: `${item.name}-area`, d: areaPath, fill: color, opacity: 0.12 }));
7130
7516
  }
7131
- elements.push(import_react10.default.createElement("path", {
7517
+ elements.push(import_react11.default.createElement("path", {
7132
7518
  key: `${item.name}-line`,
7133
7519
  d: linePath,
7134
7520
  fill: "none",
@@ -7140,7 +7526,7 @@ function LineChart({
7140
7526
  if (showPoints) {
7141
7527
  elements.push(...item.points.map((value, index) => {
7142
7528
  const point = pointFor(value, index);
7143
- return import_react10.default.createElement("circle", {
7529
+ return import_react11.default.createElement("circle", {
7144
7530
  key: `${item.name}-point-${index}`,
7145
7531
  cx: point.x,
7146
7532
  cy: point.y,
@@ -7173,7 +7559,7 @@ function LineChart({
7173
7559
  }
7174
7560
 
7175
7561
  // src/primitives/plots.ts
7176
- var import_react11 = __toESM(require("react"), 1);
7562
+ var import_react12 = __toESM(require("react"), 1);
7177
7563
  function xTickLabelAlign(index, count) {
7178
7564
  if (index === 0) return "left";
7179
7565
  if (index === count - 1) return "right";
@@ -7217,18 +7603,18 @@ function ScatterPlot({
7217
7603
  subtitle,
7218
7604
  width,
7219
7605
  footer,
7220
- children: import_react11.default.createElement(
7606
+ children: import_react12.default.createElement(
7221
7607
  "div",
7222
7608
  { style: { position: "relative", width, height, display: "flex" } },
7223
- import_react11.default.createElement(
7609
+ import_react12.default.createElement(
7224
7610
  "svg",
7225
7611
  { width, height, viewBox: `0 0 ${width} ${height}` },
7226
- showGrid && import_react11.default.createElement(
7612
+ showGrid && import_react12.default.createElement(
7227
7613
  "g",
7228
7614
  {},
7229
7615
  ...xTicks.map((tick) => {
7230
7616
  const x = xInPlot(tick, xDomain, plot);
7231
- return import_react11.default.createElement("line", {
7617
+ return import_react12.default.createElement("line", {
7232
7618
  key: `x-tick-${tick}`,
7233
7619
  x1: x,
7234
7620
  y1: plot.y,
@@ -7240,7 +7626,7 @@ function ScatterPlot({
7240
7626
  }),
7241
7627
  ...yTicks.map((tick) => {
7242
7628
  const y = yInPlot(tick, yDomain, plot);
7243
- return import_react11.default.createElement("line", {
7629
+ return import_react12.default.createElement("line", {
7244
7630
  key: `y-tick-${tick}`,
7245
7631
  x1: plot.x,
7246
7632
  y1: y,
@@ -7251,9 +7637,9 @@ function ScatterPlot({
7251
7637
  });
7252
7638
  })
7253
7639
  ),
7254
- import_react11.default.createElement("rect", { x: plot.x, y: plot.y, width: plot.innerWidth, height: plot.innerHeight, fill: "transparent", stroke: c.borderLight, strokeWidth: 1.2, rx: 6 }),
7640
+ import_react12.default.createElement("rect", { x: plot.x, y: plot.y, width: plot.innerWidth, height: plot.innerHeight, fill: "transparent", stroke: c.borderLight, strokeWidth: 1.2, rx: 6 }),
7255
7641
  ...pointGeometries.map(
7256
- ({ item, index, point, color }) => import_react11.default.createElement("circle", {
7642
+ ({ item, index, point, color }) => import_react12.default.createElement("circle", {
7257
7643
  key: `${item.label ?? "point"}-${index}`,
7258
7644
  cx: point.x,
7259
7645
  cy: point.y,
@@ -7404,18 +7790,18 @@ function ParetoChart({
7404
7790
  { label: "Pareto frontier", color: frontier },
7405
7791
  { label: "dominated", color: "neutral" }
7406
7792
  ],
7407
- children: import_react11.default.createElement(
7793
+ children: import_react12.default.createElement(
7408
7794
  "div",
7409
7795
  { style: { position: "relative", width, height, display: "flex" } },
7410
- import_react11.default.createElement(
7796
+ import_react12.default.createElement(
7411
7797
  "svg",
7412
7798
  { width, height, viewBox: `0 0 ${width} ${height}` },
7413
- showGrid && import_react11.default.createElement(
7799
+ showGrid && import_react12.default.createElement(
7414
7800
  "g",
7415
7801
  {},
7416
7802
  ...xTicks.map((tick) => {
7417
7803
  const x = pointFor(tick, yDomain.min).x;
7418
- return import_react11.default.createElement("line", {
7804
+ return import_react12.default.createElement("line", {
7419
7805
  key: `pareto-x-grid-${tick}`,
7420
7806
  x1: x,
7421
7807
  y1: plot.y,
@@ -7427,7 +7813,7 @@ function ParetoChart({
7427
7813
  }),
7428
7814
  ...yTicks.map((tick) => {
7429
7815
  const y = yInPlot(tick, yDomain, plot);
7430
- return import_react11.default.createElement("line", {
7816
+ return import_react12.default.createElement("line", {
7431
7817
  key: `pareto-y-grid-${tick}`,
7432
7818
  x1: plot.x,
7433
7819
  y1: y,
@@ -7438,7 +7824,7 @@ function ParetoChart({
7438
7824
  });
7439
7825
  })
7440
7826
  ),
7441
- import_react11.default.createElement("rect", {
7827
+ import_react12.default.createElement("rect", {
7442
7828
  x: plot.x,
7443
7829
  y: plot.y,
7444
7830
  width: plot.innerWidth,
@@ -7448,17 +7834,17 @@ function ParetoChart({
7448
7834
  strokeWidth: 1.2,
7449
7835
  rx: 6
7450
7836
  }),
7451
- showGoal && import_react11.default.createElement(
7837
+ showGoal && import_react12.default.createElement(
7452
7838
  "g",
7453
7839
  { "data-pareto-goal": true, stroke: frontier, fill: "none", strokeWidth: 2, strokeLinecap: "round" },
7454
- import_react11.default.createElement("line", { x1: goalXStart, y1: goalY, x2: goalXEnd, y2: goalY }),
7455
- import_react11.default.createElement("line", { x1: goalXEnd, y1: goalY, x2: goalXEnd + (xObjective === "minimize" ? arrowSize : -arrowSize), y2: goalY - arrowSize }),
7456
- import_react11.default.createElement("line", { x1: goalXEnd, y1: goalY, x2: goalXEnd + (xObjective === "minimize" ? arrowSize : -arrowSize), y2: goalY + arrowSize }),
7457
- import_react11.default.createElement("line", { x1: goalXStart, y1: goalYStart, x2: goalXStart, y2: goalYEnd }),
7458
- import_react11.default.createElement("line", { x1: goalXStart, y1: goalYEnd, x2: goalXStart - arrowSize, y2: goalYEnd + (yObjective === "maximize" ? arrowSize : -arrowSize) }),
7459
- import_react11.default.createElement("line", { x1: goalXStart, y1: goalYEnd, x2: goalXStart + arrowSize, y2: goalYEnd + (yObjective === "maximize" ? arrowSize : -arrowSize) })
7840
+ import_react12.default.createElement("line", { x1: goalXStart, y1: goalY, x2: goalXEnd, y2: goalY }),
7841
+ import_react12.default.createElement("line", { x1: goalXEnd, y1: goalY, x2: goalXEnd + (xObjective === "minimize" ? arrowSize : -arrowSize), y2: goalY - arrowSize }),
7842
+ import_react12.default.createElement("line", { x1: goalXEnd, y1: goalY, x2: goalXEnd + (xObjective === "minimize" ? arrowSize : -arrowSize), y2: goalY + arrowSize }),
7843
+ import_react12.default.createElement("line", { x1: goalXStart, y1: goalYStart, x2: goalXStart, y2: goalYEnd }),
7844
+ import_react12.default.createElement("line", { x1: goalXStart, y1: goalYEnd, x2: goalXStart - arrowSize, y2: goalYEnd + (yObjective === "maximize" ? arrowSize : -arrowSize) }),
7845
+ import_react12.default.createElement("line", { x1: goalXStart, y1: goalYEnd, x2: goalXStart + arrowSize, y2: goalYEnd + (yObjective === "maximize" ? arrowSize : -arrowSize) })
7460
7846
  ),
7461
- frontierPath && import_react11.default.createElement("path", {
7847
+ frontierPath && import_react12.default.createElement("path", {
7462
7848
  "data-pareto-frontier": true,
7463
7849
  d: frontierPath,
7464
7850
  fill: "none",
@@ -7467,7 +7853,7 @@ function ParetoChart({
7467
7853
  strokeLinecap: "round",
7468
7854
  strokeLinejoin: "round"
7469
7855
  }),
7470
- ...pointGeometries.filter((geometry) => !geometry.frontier).concat(pointGeometries.filter((geometry) => geometry.frontier)).map(({ point, index, x, y, color, frontier: isFrontier }) => import_react11.default.createElement("circle", {
7856
+ ...pointGeometries.filter((geometry) => !geometry.frontier).concat(pointGeometries.filter((geometry) => geometry.frontier)).map(({ point, index, x, y, color, frontier: isFrontier }) => import_react12.default.createElement("circle", {
7471
7857
  key: `pareto-point-${point.label ?? "point"}-${index}`,
7472
7858
  "data-pareto-status": isFrontier ? "frontier" : "dominated",
7473
7859
  cx: x,
@@ -7579,18 +7965,18 @@ function QuadrantChart({
7579
7965
  subtitle,
7580
7966
  width,
7581
7967
  footer,
7582
- children: import_react11.default.createElement(
7968
+ children: import_react12.default.createElement(
7583
7969
  "div",
7584
7970
  {
7585
7971
  style: { position: "relative", width, height, display: "flex" }
7586
7972
  },
7587
- import_react11.default.createElement(
7973
+ import_react12.default.createElement(
7588
7974
  "svg",
7589
7975
  { width, height, viewBox: `0 0 ${width} ${height}` },
7590
7976
  ...regionEntries.map(({ key, region, x, y, width: regionWidth, height: regionHeight }, index) => {
7591
7977
  const color = chartColor(region.color, c, index);
7592
7978
  const emphasized = region.emphasis === true;
7593
- return import_react11.default.createElement("rect", {
7979
+ return import_react12.default.createElement("rect", {
7594
7980
  key: `quadrant-${key}`,
7595
7981
  x,
7596
7982
  y,
@@ -7602,12 +7988,12 @@ function QuadrantChart({
7602
7988
  strokeWidth: emphasized ? 2 : 0
7603
7989
  });
7604
7990
  }),
7605
- showGrid && import_react11.default.createElement(
7991
+ showGrid && import_react12.default.createElement(
7606
7992
  "g",
7607
7993
  {},
7608
7994
  ...xTicks.map((tick) => {
7609
7995
  const x = xInPlot(tick, xDomain, plot);
7610
- return import_react11.default.createElement("line", {
7996
+ return import_react12.default.createElement("line", {
7611
7997
  key: `quadrant-x-grid-${tick}`,
7612
7998
  x1: x,
7613
7999
  y1: plot.y,
@@ -7619,7 +8005,7 @@ function QuadrantChart({
7619
8005
  }),
7620
8006
  ...yTicks.map((tick) => {
7621
8007
  const y = yInPlot(tick, yDomain, plot);
7622
- return import_react11.default.createElement("line", {
8008
+ return import_react12.default.createElement("line", {
7623
8009
  key: `quadrant-y-grid-${tick}`,
7624
8010
  x1: plot.x,
7625
8011
  y1: y,
@@ -7630,7 +8016,7 @@ function QuadrantChart({
7630
8016
  });
7631
8017
  })
7632
8018
  ),
7633
- import_react11.default.createElement("rect", {
8019
+ import_react12.default.createElement("rect", {
7634
8020
  x: plot.x,
7635
8021
  y: plot.y,
7636
8022
  width: plot.innerWidth,
@@ -7640,7 +8026,7 @@ function QuadrantChart({
7640
8026
  strokeWidth: 1.2,
7641
8027
  rx: 8
7642
8028
  }),
7643
- import_react11.default.createElement("line", {
8029
+ import_react12.default.createElement("line", {
7644
8030
  x1: midX,
7645
8031
  y1: plot.y,
7646
8032
  x2: midX,
@@ -7648,7 +8034,7 @@ function QuadrantChart({
7648
8034
  stroke: c.borderLight,
7649
8035
  strokeWidth: 1.4
7650
8036
  }),
7651
- import_react11.default.createElement("line", {
8037
+ import_react12.default.createElement("line", {
7652
8038
  x1: plot.x,
7653
8039
  y1: midY,
7654
8040
  x2: plot.right,
@@ -7658,7 +8044,7 @@ function QuadrantChart({
7658
8044
  }),
7659
8045
  ...(showTicks ? xTicks : []).map((tick) => {
7660
8046
  const x = xInPlot(tick, xDomain, plot);
7661
- return import_react11.default.createElement("line", {
8047
+ return import_react12.default.createElement("line", {
7662
8048
  key: `quadrant-x-tick-${tick}`,
7663
8049
  x1: x,
7664
8050
  y1: plot.bottom,
@@ -7670,7 +8056,7 @@ function QuadrantChart({
7670
8056
  }),
7671
8057
  ...(showTicks ? yTicks : []).map((tick) => {
7672
8058
  const y = yInPlot(tick, yDomain, plot);
7673
- return import_react11.default.createElement("line", {
8059
+ return import_react12.default.createElement("line", {
7674
8060
  key: `quadrant-y-tick-${tick}`,
7675
8061
  x1: plot.x - 5,
7676
8062
  y1: y,
@@ -7680,7 +8066,7 @@ function QuadrantChart({
7680
8066
  strokeWidth: 1.2
7681
8067
  });
7682
8068
  }),
7683
- ...pointGeometries.map(({ point, index, x, y, color }) => import_react11.default.createElement("circle", {
8069
+ ...pointGeometries.map(({ point, index, x, y, color }) => import_react12.default.createElement("circle", {
7684
8070
  key: `quadrant-point-${point.label ?? index}`,
7685
8071
  cx: x,
7686
8072
  cy: y,
@@ -7782,15 +8168,15 @@ function IntervalPlot({
7782
8168
  subtitle,
7783
8169
  width,
7784
8170
  footer,
7785
- children: import_react11.default.createElement(
8171
+ children: import_react12.default.createElement(
7786
8172
  "div",
7787
8173
  { style: { position: "relative", width, height, display: "flex" } },
7788
- import_react11.default.createElement(
8174
+ import_react12.default.createElement(
7789
8175
  "svg",
7790
8176
  { width, height, viewBox: `0 0 ${width} ${height}` },
7791
8177
  ...ticks.map((tick) => {
7792
8178
  const x = scaleX(tick);
7793
- return import_react11.default.createElement("line", {
8179
+ return import_react12.default.createElement("line", {
7794
8180
  key: `interval-tick-${tick}`,
7795
8181
  x1: x,
7796
8182
  y1: plot.y,
@@ -7800,10 +8186,10 @@ function IntervalPlot({
7800
8186
  strokeWidth: 1
7801
8187
  });
7802
8188
  }),
7803
- import_react11.default.createElement("line", { x1: plot.x, y1: plot.bottom, x2: plot.right, y2: plot.bottom, stroke: c.borderLight, strokeWidth: 1.2 }),
8189
+ import_react12.default.createElement("line", { x1: plot.x, y1: plot.bottom, x2: plot.right, y2: plot.bottom, stroke: c.borderLight, strokeWidth: 1.2 }),
7804
8190
  ...rows.flatMap(({ item, index, y, color, lowX, midX, highX }) => [
7805
- import_react11.default.createElement("line", { key: `${item.label}-range-${index}`, x1: lowX, y1: y, x2: highX, y2: y, stroke: color, strokeWidth: 9, strokeLinecap: "round", opacity: 0.9 }),
7806
- import_react11.default.createElement("circle", { key: `${item.label}-mid-${index}`, cx: midX, cy: y, r: 10, fill: c.bgCard, stroke: color, strokeWidth: 4 })
8191
+ import_react12.default.createElement("line", { key: `${item.label}-range-${index}`, x1: lowX, y1: y, x2: highX, y2: y, stroke: color, strokeWidth: 9, strokeLinecap: "round", opacity: 0.9 }),
8192
+ import_react12.default.createElement("circle", { key: `${item.label}-mid-${index}`, cx: midX, cy: y, r: 10, fill: c.bgCard, stroke: color, strokeWidth: 4 })
7807
8193
  ])
7808
8194
  ),
7809
8195
  ...ticks.map((tick, index) => {
@@ -7840,7 +8226,7 @@ function IntervalPlot({
7840
8226
  }
7841
8227
  function Badge({ label, c, color = "primary" }) {
7842
8228
  const solidColor = getReadableColor(color, c);
7843
- return import_react11.default.createElement("div", {
8229
+ return import_react12.default.createElement("div", {
7844
8230
  style: {
7845
8231
  display: "flex",
7846
8232
  alignItems: "center",
@@ -7861,7 +8247,7 @@ function DotPoint({ x, y, label, color, c, size = 12, labelOffset }) {
7861
8247
  const offY = labelOffset?.y ?? -22;
7862
8248
  return [
7863
8249
  // Dot
7864
- import_react11.default.createElement("div", {
8250
+ import_react12.default.createElement("div", {
7865
8251
  key: `dot-${label}`,
7866
8252
  style: {
7867
8253
  position: "absolute",
@@ -7876,7 +8262,7 @@ function DotPoint({ x, y, label, color, c, size = 12, labelOffset }) {
7876
8262
  }
7877
8263
  }),
7878
8264
  // Label
7879
- import_react11.default.createElement("div", {
8265
+ import_react12.default.createElement("div", {
7880
8266
  key: `label-${label}`,
7881
8267
  style: {
7882
8268
  position: "absolute",
@@ -7902,7 +8288,7 @@ function DashedLine({ x1, y1, x2, y2, color, dotSpacing = 8, dotSize = 2 }) {
7902
8288
  if (i % 2 === 1) continue;
7903
8289
  const t = i / numDots;
7904
8290
  dots.push(
7905
- import_react11.default.createElement("div", {
8291
+ import_react12.default.createElement("div", {
7906
8292
  key: `dash-${i}`,
7907
8293
  style: {
7908
8294
  position: "absolute",
@@ -7919,7 +8305,7 @@ function DashedLine({ x1, y1, x2, y2, color, dotSpacing = 8, dotSize = 2 }) {
7919
8305
  return dots;
7920
8306
  }
7921
8307
  function Legend({ items, c, title }) {
7922
- return import_react11.default.createElement(
8308
+ return import_react12.default.createElement(
7923
8309
  "div",
7924
8310
  {
7925
8311
  style: {
@@ -7932,7 +8318,7 @@ function Legend({ items, c, title }) {
7932
8318
  padding: "14px 16px"
7933
8319
  }
7934
8320
  },
7935
- title && import_react11.default.createElement("div", {
8321
+ title && import_react12.default.createElement("div", {
7936
8322
  style: {
7937
8323
  fontSize: 11,
7938
8324
  fontWeight: 700,
@@ -7943,13 +8329,13 @@ function Legend({ items, c, title }) {
7943
8329
  }
7944
8330
  }, title),
7945
8331
  ...items.map(
7946
- (item, i) => import_react11.default.createElement(
8332
+ (item, i) => import_react12.default.createElement(
7947
8333
  "div",
7948
8334
  {
7949
8335
  key: `legend-${i}`,
7950
8336
  style: { display: "flex", alignItems: "center", gap: 8 }
7951
8337
  },
7952
- import_react11.default.createElement("div", {
8338
+ import_react12.default.createElement("div", {
7953
8339
  style: {
7954
8340
  width: 16,
7955
8341
  height: item.style === "dashed" ? 0 : 2,
@@ -7959,7 +8345,7 @@ function Legend({ items, c, title }) {
7959
8345
  } : {}
7960
8346
  }
7961
8347
  }),
7962
- import_react11.default.createElement("div", {
8348
+ import_react12.default.createElement("div", {
7963
8349
  style: {
7964
8350
  fontSize: 11,
7965
8351
  color: c.textMuted,
@@ -7981,12 +8367,12 @@ var import_url = require("url");
7981
8367
  var import_zlib = require("zlib");
7982
8368
 
7983
8369
  // src/brand.ts
7984
- var import_react12 = __toESM(require("react"), 1);
8370
+ var import_react13 = __toESM(require("react"), 1);
7985
8371
  var DEFAULT_WATERMARK_TEXT = "Vizmatic";
7986
8372
  var WATERMARK_COLOR_DARK = "#a78bfa";
7987
8373
  var WATERMARK_COLOR_LIGHT = "#7c3aed";
7988
8374
  function VizmaticIcon({ size = 14, color }) {
7989
- return import_react12.default.createElement(
8375
+ return import_react13.default.createElement(
7990
8376
  "svg",
7991
8377
  {
7992
8378
  xmlns: "http://www.w3.org/2000/svg",
@@ -7995,19 +8381,19 @@ function VizmaticIcon({ size = 14, color }) {
7995
8381
  viewBox: "0 0 28 28",
7996
8382
  fill: "none"
7997
8383
  },
7998
- import_react12.default.createElement("rect", { x: 2.5, y: 2.5, width: 23, height: 23, rx: 6.5, stroke: color, strokeWidth: 2, opacity: 0.54 }),
7999
- import_react12.default.createElement("rect", { x: 7, y: 7, width: 5.5, height: 5.5, rx: 1.8, fill: color, opacity: 0.35 }),
8000
- import_react12.default.createElement("rect", { x: 15.5, y: 7, width: 5.5, height: 5.5, rx: 1.8, fill: color }),
8001
- import_react12.default.createElement("rect", { x: 7, y: 15.5, width: 5.5, height: 5.5, rx: 1.8, fill: color, opacity: 0.82 }),
8002
- import_react12.default.createElement("rect", { x: 15.5, y: 15.5, width: 5.5, height: 5.5, rx: 1.8, stroke: color, strokeWidth: 1.5, opacity: 0.72 }),
8003
- import_react12.default.createElement("path", { d: "M9.75 9.75h8.5M9.75 18.25h8.5M9.75 9.75v8.5M18.25 9.75v8.5", stroke: color, strokeWidth: 1.6, strokeLinecap: "round", opacity: 0.88 })
8384
+ import_react13.default.createElement("rect", { x: 2.5, y: 2.5, width: 23, height: 23, rx: 6.5, stroke: color, strokeWidth: 2, opacity: 0.54 }),
8385
+ import_react13.default.createElement("rect", { x: 7, y: 7, width: 5.5, height: 5.5, rx: 1.8, fill: color, opacity: 0.35 }),
8386
+ import_react13.default.createElement("rect", { x: 15.5, y: 7, width: 5.5, height: 5.5, rx: 1.8, fill: color }),
8387
+ import_react13.default.createElement("rect", { x: 7, y: 15.5, width: 5.5, height: 5.5, rx: 1.8, fill: color, opacity: 0.82 }),
8388
+ import_react13.default.createElement("rect", { x: 15.5, y: 15.5, width: 5.5, height: 5.5, rx: 1.8, stroke: color, strokeWidth: 1.5, opacity: 0.72 }),
8389
+ import_react13.default.createElement("path", { d: "M9.75 9.75h8.5M9.75 18.25h8.5M9.75 9.75v8.5M18.25 9.75v8.5", stroke: color, strokeWidth: 1.6, strokeLinecap: "round", opacity: 0.88 })
8004
8390
  );
8005
8391
  }
8006
8392
  function normalizeWatermark(watermark) {
8007
8393
  if (watermark == null || watermark === false) return void 0;
8008
8394
  if (watermark === true) return {};
8009
8395
  if (typeof watermark === "string") return { text: watermark };
8010
- if (import_react12.default.isValidElement(watermark)) {
8396
+ if (import_react13.default.isValidElement(watermark)) {
8011
8397
  if (watermark.type !== Watermark) return { element: watermark };
8012
8398
  const { children, ...props } = watermark.props;
8013
8399
  return {
@@ -8036,7 +8422,7 @@ function positionStyle(position) {
8036
8422
  function imageNode(image) {
8037
8423
  if (!image) return void 0;
8038
8424
  const imageOptions = typeof image === "string" ? { src: image } : image;
8039
- return import_react12.default.createElement("img", {
8425
+ return import_react13.default.createElement("img", {
8040
8426
  src: imageOptions.src,
8041
8427
  alt: imageOptions.alt ?? "",
8042
8428
  width: imageOptions.width ?? 14,
@@ -8051,9 +8437,9 @@ function imageNode(image) {
8051
8437
  }
8052
8438
  function iconNode(icon, color) {
8053
8439
  if (icon === false) return void 0;
8054
- if (icon == null) return import_react12.default.createElement(VizmaticIcon, { size: 13, color });
8440
+ if (icon == null) return import_react13.default.createElement(VizmaticIcon, { size: 13, color });
8055
8441
  if (typeof icon !== "string") return icon;
8056
- return import_react12.default.createElement("div", {
8442
+ return import_react13.default.createElement("div", {
8057
8443
  style: {
8058
8444
  minWidth: 13,
8059
8445
  height: 13,
@@ -8078,7 +8464,7 @@ function wrapWithWatermark(element, width, height, theme = "dark", watermark = t
8078
8464
  const text = options?.text ?? DEFAULT_WATERMARK_TEXT;
8079
8465
  const content = options?.element ?? [
8080
8466
  icon,
8081
- text !== false && text && import_react12.default.createElement("div", {
8467
+ text !== false && text && import_react13.default.createElement("div", {
8082
8468
  key: "text",
8083
8469
  style: {
8084
8470
  fontSize: 11,
@@ -8089,7 +8475,7 @@ function wrapWithWatermark(element, width, height, theme = "dark", watermark = t
8089
8475
  }
8090
8476
  }, text)
8091
8477
  ];
8092
- return import_react12.default.createElement(
8478
+ return import_react13.default.createElement(
8093
8479
  "div",
8094
8480
  {
8095
8481
  style: {
@@ -8100,7 +8486,7 @@ function wrapWithWatermark(element, width, height, theme = "dark", watermark = t
8100
8486
  }
8101
8487
  },
8102
8488
  element,
8103
- options && import_react12.default.createElement(
8489
+ options && import_react13.default.createElement(
8104
8490
  "div",
8105
8491
  {
8106
8492
  style: {
@@ -8223,13 +8609,13 @@ function detectOverflow(pixels, width, height, bgColor, edgeTolerance = 3, minDe
8223
8609
  const right = checkEdge((i, off) => [width - 1 - off, i], height);
8224
8610
  const top = checkEdge((i, off) => [i, off], width);
8225
8611
  const left = checkEdge((i, off) => [off, i], height);
8226
- const overflowEdges = [];
8227
- if (top) overflowEdges.push("top");
8228
- if (right) overflowEdges.push("right");
8229
- if (bottom) overflowEdges.push("bottom");
8230
- if (left) overflowEdges.push("left");
8231
- const overflows = overflowEdges.length > 0;
8232
- const message = overflows ? `Content overflows canvas at: ${overflowEdges.join(", ")}. Increase the illustration dimensions.` : "";
8612
+ const overflowEdges2 = [];
8613
+ if (top) overflowEdges2.push("top");
8614
+ if (right) overflowEdges2.push("right");
8615
+ if (bottom) overflowEdges2.push("bottom");
8616
+ if (left) overflowEdges2.push("left");
8617
+ const overflows = overflowEdges2.length > 0;
8618
+ const message = overflows ? `Content overflows canvas at: ${overflowEdges2.join(", ")}. Increase the illustration dimensions.` : "";
8233
8619
  return {
8234
8620
  overflows,
8235
8621
  edges: { top, right, bottom, left },
@@ -8698,14 +9084,19 @@ async function renderToSvgInContext(element, width, height, options) {
8698
9084
  options.theme ?? "dark",
8699
9085
  watermark
8700
9086
  ) : element;
8701
- const svg = await satori(outputElement, {
9087
+ const prepared = prepareAccessibleSvg(outputElement);
9088
+ const layoutNodes = [];
9089
+ const svg = await satori(prepared.element, {
8702
9090
  width,
8703
9091
  height,
8704
9092
  fonts,
8705
9093
  loadAdditionalAsset,
8706
- onNodeDetected: options.onNodeDetected
9094
+ onNodeDetected: (node) => {
9095
+ layoutNodes.push(node);
9096
+ options.onNodeDetected?.(node);
9097
+ }
8707
9098
  });
8708
- return sanitizeSvg(svg);
9099
+ return addSvgAccessibility(sanitizeSvg(svg), prepared.graphs, layoutNodes);
8709
9100
  }
8710
9101
 
8711
9102
  // src/animate.ts
@@ -9486,6 +9877,1318 @@ async function renderAnimationGifWithOutput(animation, options) {
9486
9877
  bytes: bytes.length
9487
9878
  };
9488
9879
  }
9880
+
9881
+ // src/import-types.ts
9882
+ function graphImportResult(source, graph, diagnostics) {
9883
+ if (graph.nodes.length === 0 && diagnostics.every(({ severity }) => severity !== "error")) {
9884
+ diagnostics.push({
9885
+ code: "import.empty",
9886
+ severity: "error",
9887
+ message: "The source contains no graph nodes to import.",
9888
+ line: 1,
9889
+ column: 1,
9890
+ excerpt: ""
9891
+ });
9892
+ }
9893
+ const ok = diagnostics.every(({ severity }) => severity !== "error");
9894
+ return ok ? { source, ok, graph, diagnostics } : { source, ok, diagnostics };
9895
+ }
9896
+ function addImportDiagnostic(diagnostics, sourceLines, line, code, severity, message, column = 1) {
9897
+ diagnostics.push({
9898
+ code,
9899
+ severity,
9900
+ message,
9901
+ line,
9902
+ column,
9903
+ excerpt: (sourceLines[line - 1] ?? "").trim().slice(0, 180)
9904
+ });
9905
+ }
9906
+
9907
+ // src/import-mermaid.ts
9908
+ var ID_PATTERN = /^[A-Za-z_][A-Za-z0-9_-]*/;
9909
+ var CONNECTORS = ["-.->", "-->", "---"];
9910
+ function skipWhitespace(line, index) {
9911
+ while (index < line.length && /\s/.test(line[index] ?? "")) index++;
9912
+ return index;
9913
+ }
9914
+ function readDelimited(line, start, close) {
9915
+ let inDoubleQuote = false;
9916
+ let escaped = false;
9917
+ for (let index = start; index < line.length; index++) {
9918
+ const character = line[index];
9919
+ if (inDoubleQuote) {
9920
+ if (escaped) escaped = false;
9921
+ else if (character === "\\") escaped = true;
9922
+ else if (character === '"') inDoubleQuote = false;
9923
+ continue;
9924
+ }
9925
+ if (character === '"') {
9926
+ inDoubleQuote = true;
9927
+ continue;
9928
+ }
9929
+ if (line.startsWith(close, index)) {
9930
+ return { value: line.slice(start, index), next: index + close.length };
9931
+ }
9932
+ }
9933
+ return void 0;
9934
+ }
9935
+ function decodeLabel(raw) {
9936
+ const value = raw.trim();
9937
+ if (!value.startsWith('"')) return value;
9938
+ if (!value.endsWith('"')) return void 0;
9939
+ try {
9940
+ const decoded = JSON.parse(value);
9941
+ return typeof decoded === "string" ? decoded : void 0;
9942
+ } catch {
9943
+ return void 0;
9944
+ }
9945
+ }
9946
+ function labelHasUnsupportedMarkup(label) {
9947
+ return /<[^>]*>|`|\*\*|__|~~|(^|\s)\*[^*]|\b_[^_]+_\b|\n|\r/.test(label);
9948
+ }
9949
+ function readEndpoint(line, from) {
9950
+ let index = skipWhitespace(line, from);
9951
+ const id = line.slice(index).match(ID_PATTERN)?.[0];
9952
+ if (!id) return void 0;
9953
+ index += id.length;
9954
+ const afterId = skipWhitespace(line, index);
9955
+ if (afterId >= line.length) return { id, label: id, shape: "rectangle", next: afterId };
9956
+ const rest = line.slice(afterId);
9957
+ const delimiters = [
9958
+ { open: "[(", close: ")]", lossy: true },
9959
+ { open: "([", close: "])", lossy: true },
9960
+ { open: "((", close: "))", lossy: true },
9961
+ { open: "{{", close: "}}", lossy: true },
9962
+ { open: "[", close: "]", lossy: false },
9963
+ { open: "(", close: ")", lossy: true },
9964
+ { open: "{", close: "}", lossy: true }
9965
+ ];
9966
+ const delimiter = delimiters.find(({ open }) => rest.startsWith(open));
9967
+ if (!delimiter) return { id, label: id, shape: "rectangle", next: index };
9968
+ const content = readDelimited(line, afterId + delimiter.open.length, delimiter.close);
9969
+ if (!content) return void 0;
9970
+ const label = decodeLabel(content.value);
9971
+ if (label === void 0) return void 0;
9972
+ return {
9973
+ id,
9974
+ label,
9975
+ shape: delimiter.lossy ? "lossy" : "rectangle",
9976
+ next: content.next
9977
+ };
9978
+ }
9979
+ function addNode(state, endpoint, groupId, line, sourceLines, diagnostics, explicitlyDeclared) {
9980
+ if (state.groupIds.has(endpoint.id)) {
9981
+ addImportDiagnostic(
9982
+ diagnostics,
9983
+ sourceLines,
9984
+ line,
9985
+ "import.unsupported_semantics",
9986
+ "error",
9987
+ `Mermaid id "${endpoint.id}" is already used by a subgraph and cannot also be a node.`
9988
+ );
9989
+ return false;
9990
+ }
9991
+ if (labelHasUnsupportedMarkup(endpoint.label)) {
9992
+ addImportDiagnostic(
9993
+ diagnostics,
9994
+ sourceLines,
9995
+ line,
9996
+ "import.unsupported_semantics",
9997
+ "error",
9998
+ `Mermaid label for node "${endpoint.id}" uses HTML or Markdown formatting that GraphDiagram cannot preserve.`
9999
+ );
10000
+ return false;
10001
+ }
10002
+ const existingIndex = state.nodeIndexes.get(endpoint.id);
10003
+ if (existingIndex !== void 0) {
10004
+ const existing = state.nodes[existingIndex];
10005
+ if (!existing) return false;
10006
+ if (groupId && existing.group && existing.group !== groupId) {
10007
+ addImportDiagnostic(
10008
+ diagnostics,
10009
+ sourceLines,
10010
+ line,
10011
+ "import.unsupported_semantics",
10012
+ "error",
10013
+ `Mermaid node "${endpoint.id}" is assigned to more than one subgraph; GraphDiagram nodes support one group.`
10014
+ );
10015
+ return false;
10016
+ }
10017
+ if (groupId && !existing.group) {
10018
+ addImportDiagnostic(
10019
+ diagnostics,
10020
+ sourceLines,
10021
+ line,
10022
+ "import.unsupported_semantics",
10023
+ "error",
10024
+ `Mermaid node "${endpoint.id}" is referenced both inside and outside a subgraph; its group membership is ambiguous.`
10025
+ );
10026
+ return false;
10027
+ }
10028
+ if (explicitlyDeclared) existing.label = endpoint.label;
10029
+ } else {
10030
+ state.nodeIndexes.set(endpoint.id, state.nodes.length);
10031
+ state.nodes.push({
10032
+ id: endpoint.id,
10033
+ label: endpoint.label,
10034
+ ...groupId ? { group: groupId } : {}
10035
+ });
10036
+ }
10037
+ if (endpoint.shape === "lossy" && !state.warnedShapes.has(endpoint.id)) {
10038
+ state.warnedShapes.add(endpoint.id);
10039
+ addImportDiagnostic(
10040
+ diagnostics,
10041
+ sourceLines,
10042
+ line,
10043
+ "import.lossy_semantics",
10044
+ "warning",
10045
+ `Mermaid node "${endpoint.id}" uses a non-rectangular shape; it will render as a generic GraphDiagram node.`
10046
+ );
10047
+ }
10048
+ return true;
10049
+ }
10050
+ function parseNodeOrEdgeLine(line, groupId, lineNumber, sourceLines, state, diagnostics) {
10051
+ const first = readEndpoint(line, 0);
10052
+ if (!first) {
10053
+ addImportDiagnostic(diagnostics, sourceLines, lineNumber, "import.parse_error", "error", "Could not parse this Mermaid node or edge statement.");
10054
+ return;
10055
+ }
10056
+ const connectorStart = skipWhitespace(line, first.next);
10057
+ const hasConnector = CONNECTORS.some((connector) => line.startsWith(connector, connectorStart));
10058
+ if (!addNode(state, first, groupId, lineNumber, sourceLines, diagnostics, !hasConnector)) return;
10059
+ let previous = first;
10060
+ let cursor = first.next;
10061
+ while (true) {
10062
+ cursor = skipWhitespace(line, cursor);
10063
+ if (cursor >= line.length) return;
10064
+ const connector = CONNECTORS.find((candidate) => line.startsWith(candidate, cursor));
10065
+ if (!connector) {
10066
+ addImportDiagnostic(
10067
+ diagnostics,
10068
+ sourceLines,
10069
+ lineNumber,
10070
+ "import.unsupported_syntax",
10071
+ "error",
10072
+ "Only Mermaid -->, ---, and -.-> connections are supported; chained or styled statements must be split or simplified.",
10073
+ cursor + 1
10074
+ );
10075
+ return;
10076
+ }
10077
+ cursor += connector.length;
10078
+ cursor = skipWhitespace(line, cursor);
10079
+ let edgeLabel;
10080
+ if (line[cursor] === "|") {
10081
+ const end = line.indexOf("|", cursor + 1);
10082
+ if (end < 0) {
10083
+ addImportDiagnostic(diagnostics, sourceLines, lineNumber, "import.parse_error", "error", "Mermaid edge label is missing its closing |.", cursor + 1);
10084
+ return;
10085
+ }
10086
+ edgeLabel = line.slice(cursor + 1, end).trim();
10087
+ cursor = skipWhitespace(line, end + 1);
10088
+ if (labelHasUnsupportedMarkup(edgeLabel)) {
10089
+ addImportDiagnostic(
10090
+ diagnostics,
10091
+ sourceLines,
10092
+ lineNumber,
10093
+ "import.unsupported_semantics",
10094
+ "error",
10095
+ "Mermaid edge labels with HTML or Markdown formatting cannot be represented as plain GraphDiagram labels.",
10096
+ cursor + 1
10097
+ );
10098
+ return;
10099
+ }
10100
+ }
10101
+ const next = readEndpoint(line, cursor);
10102
+ if (!next) {
10103
+ addImportDiagnostic(diagnostics, sourceLines, lineNumber, "import.parse_error", "error", "Mermaid connection has no supported target node.", cursor + 1);
10104
+ return;
10105
+ }
10106
+ if (!addNode(state, next, groupId, lineNumber, sourceLines, diagnostics, false)) return;
10107
+ const edge = {
10108
+ from: previous.id,
10109
+ to: next.id,
10110
+ ...edgeLabel !== void 0 ? { label: edgeLabel } : {},
10111
+ ...connector === "---" ? { arrow: "none" } : connector === "-.->" ? { arrow: "forward", style: "dotted" } : { arrow: "forward" }
10112
+ };
10113
+ state.edges.push(edge);
10114
+ state.edgeReferences.push({ id: previous.id, line: lineNumber }, { id: next.id, line: lineNumber });
10115
+ previous = next;
10116
+ cursor = next.next;
10117
+ }
10118
+ }
10119
+ function importMermaidGraph(source) {
10120
+ const sourceLines = source.split(/\r?\n/);
10121
+ const diagnostics = [];
10122
+ const state = {
10123
+ nodes: [],
10124
+ nodeIndexes: /* @__PURE__ */ new Map(),
10125
+ groups: [],
10126
+ groupIds: /* @__PURE__ */ new Set(),
10127
+ edges: [],
10128
+ edgeReferences: [],
10129
+ warnedShapes: /* @__PURE__ */ new Set()
10130
+ };
10131
+ let direction = "TB";
10132
+ let currentGroup;
10133
+ let sawHeader = false;
10134
+ for (let index = 0; index < sourceLines.length; index++) {
10135
+ const lineNumber = index + 1;
10136
+ const rawLine = sourceLines[index] ?? "";
10137
+ const line = rawLine.trim();
10138
+ if (!line) continue;
10139
+ if (line.startsWith("%%{")) {
10140
+ addImportDiagnostic(diagnostics, sourceLines, lineNumber, "import.unsupported_semantics", "error", "Mermaid directives and embedded configuration are not imported.");
10141
+ continue;
10142
+ }
10143
+ if (line.startsWith("%%")) continue;
10144
+ if (!sawHeader) {
10145
+ const header = line.match(/^(?:flowchart|graph)(?:\s+(LR|RL|TB|TD|BT))?$/i);
10146
+ if (!header) {
10147
+ addImportDiagnostic(diagnostics, sourceLines, lineNumber, "import.parse_error", "error", 'Expected a Mermaid flowchart or graph header such as "flowchart LR".');
10148
+ sawHeader = true;
10149
+ continue;
10150
+ }
10151
+ sawHeader = true;
10152
+ const sourceDirection = header[1]?.toUpperCase();
10153
+ direction = sourceDirection === "TD" ? "TB" : sourceDirection ?? "TB";
10154
+ continue;
10155
+ }
10156
+ const subgraph = line.match(/^subgraph\s+([A-Za-z_][A-Za-z0-9_-]*)(?:\s+\[([^\]]*)\])?\s*$/i);
10157
+ if (subgraph) {
10158
+ if (currentGroup) {
10159
+ addImportDiagnostic(diagnostics, sourceLines, lineNumber, "import.unsupported_semantics", "error", "Nested Mermaid subgraphs are not imported.");
10160
+ continue;
10161
+ }
10162
+ const id = subgraph[1];
10163
+ if (!id) continue;
10164
+ if (state.groupIds.has(id) || state.nodeIndexes.has(id)) {
10165
+ addImportDiagnostic(diagnostics, sourceLines, lineNumber, "import.unsupported_semantics", "error", `Mermaid subgraph id "${id}" conflicts with an existing group or node.`);
10166
+ continue;
10167
+ }
10168
+ const rawLabel = subgraph[2];
10169
+ const label = rawLabel === void 0 ? id : decodeLabel(rawLabel);
10170
+ if (label === void 0 || labelHasUnsupportedMarkup(label)) {
10171
+ addImportDiagnostic(diagnostics, sourceLines, lineNumber, "import.unsupported_semantics", "error", `Mermaid subgraph "${id}" uses a label format that cannot be preserved.`);
10172
+ continue;
10173
+ }
10174
+ currentGroup = id;
10175
+ state.groupIds.add(id);
10176
+ state.groups.push({ id, label });
10177
+ continue;
10178
+ }
10179
+ if (/^subgraph\b/i.test(line)) {
10180
+ addImportDiagnostic(diagnostics, sourceLines, lineNumber, "import.unsupported_syntax", "error", "Use a simple Mermaid subgraph declaration with an identifier and optional bracketed label.");
10181
+ continue;
10182
+ }
10183
+ if (/^end\s*$/i.test(line)) {
10184
+ if (!currentGroup) addImportDiagnostic(diagnostics, sourceLines, lineNumber, "import.parse_error", "error", "Mermaid end has no matching subgraph.");
10185
+ else currentGroup = void 0;
10186
+ continue;
10187
+ }
10188
+ if (/^direction\b/i.test(line)) {
10189
+ addImportDiagnostic(
10190
+ diagnostics,
10191
+ sourceLines,
10192
+ lineNumber,
10193
+ currentGroup ? "import.unsupported_semantics" : "import.parse_error",
10194
+ "error",
10195
+ currentGroup ? "Per-subgraph Mermaid direction cannot be represented by GraphDiagram." : "Set Mermaid graph direction in the flowchart or graph header."
10196
+ );
10197
+ continue;
10198
+ }
10199
+ if (/^(?:click|class|classDef|style|linkStyle|accTitle|accDescr)\b/i.test(line)) {
10200
+ addImportDiagnostic(diagnostics, sourceLines, lineNumber, "import.unsupported_semantics", "error", "Mermaid classes, styling, accessibility directives, and click actions are not imported.");
10201
+ continue;
10202
+ }
10203
+ parseNodeOrEdgeLine(line, currentGroup, lineNumber, sourceLines, state, diagnostics);
10204
+ }
10205
+ if (!sawHeader) {
10206
+ addImportDiagnostic(diagnostics, sourceLines, 1, "import.parse_error", "error", "Missing Mermaid flowchart or graph header.");
10207
+ }
10208
+ if (currentGroup) {
10209
+ addImportDiagnostic(diagnostics, sourceLines, sourceLines.length, "import.parse_error", "error", `Mermaid subgraph "${currentGroup}" has no matching end.`);
10210
+ }
10211
+ for (const reference of state.edgeReferences) {
10212
+ if (state.groupIds.has(reference.id)) {
10213
+ addImportDiagnostic(
10214
+ diagnostics,
10215
+ sourceLines,
10216
+ reference.line,
10217
+ "import.unsupported_semantics",
10218
+ "error",
10219
+ `Mermaid edges to or from subgraph "${reference.id}" cannot be represented as GraphDiagram node edges.`
10220
+ );
10221
+ }
10222
+ }
10223
+ const graph = {
10224
+ nodes: state.nodes,
10225
+ edges: state.edges,
10226
+ groups: state.groups,
10227
+ direction
10228
+ };
10229
+ return graphImportResult("mermaid", graph, diagnostics);
10230
+ }
10231
+
10232
+ // src/import-d2.ts
10233
+ function decodeD2Label(raw) {
10234
+ const value = raw.trim();
10235
+ if (value.startsWith('"')) {
10236
+ if (!value.endsWith('"')) return void 0;
10237
+ try {
10238
+ const decoded = JSON.parse(value);
10239
+ return typeof decoded === "string" ? decoded : void 0;
10240
+ } catch {
10241
+ return void 0;
10242
+ }
10243
+ }
10244
+ if (value.startsWith("'")) {
10245
+ if (!value.endsWith("'")) return void 0;
10246
+ return value.slice(1, -1).replace(/\\(['\\])/g, "$1");
10247
+ }
10248
+ return value;
10249
+ }
10250
+ function hasMarkdownFormatting(label) {
10251
+ return /<[^>]*>|`|\*\*|__|~~|(^|\s)\*[^*]|\b_[^_]+_\b|\[[^\]]+\]\(|(^|\n)\s{0,3}(?:#{1,6}\s|[-*+]\s|\d+\.\s)/.test(label);
10252
+ }
10253
+ function hasUnquotedHash(line) {
10254
+ let quote;
10255
+ let escaped = false;
10256
+ for (const character of line) {
10257
+ if (quote) {
10258
+ if (escaped) escaped = false;
10259
+ else if (character === "\\") escaped = true;
10260
+ else if (character === quote) quote = void 0;
10261
+ continue;
10262
+ }
10263
+ if (character === '"' || character === "'") quote = character;
10264
+ else if (character === "#") return true;
10265
+ }
10266
+ return false;
10267
+ }
10268
+ function addNode2(nodes, id, label, line, sourceLines, diagnostics, explicitLabel) {
10269
+ if (hasMarkdownFormatting(label)) {
10270
+ addImportDiagnostic(
10271
+ diagnostics,
10272
+ sourceLines,
10273
+ line,
10274
+ "import.unsupported_semantics",
10275
+ "error",
10276
+ `D2 label for "${id}" uses Markdown or HTML formatting that GraphDiagram cannot preserve.`
10277
+ );
10278
+ return false;
10279
+ }
10280
+ const existing = nodes.get(id);
10281
+ if (existing) {
10282
+ if (explicitLabel) {
10283
+ existing.node.label = label;
10284
+ }
10285
+ } else {
10286
+ nodes.set(id, { node: { id, label } });
10287
+ }
10288
+ return true;
10289
+ }
10290
+ function reportUnsupported(diagnostics, sourceLines, line, message, code = "import.unsupported_syntax", column = 1) {
10291
+ addImportDiagnostic(diagnostics, sourceLines, line, code, "error", message, column);
10292
+ }
10293
+ function importD2Graph(source) {
10294
+ const sourceLines = source.split(/\r?\n/);
10295
+ const diagnostics = [];
10296
+ const nodesById = /* @__PURE__ */ new Map();
10297
+ const edges = [];
10298
+ const shapes = /* @__PURE__ */ new Map();
10299
+ let direction = "TB";
10300
+ let containerDepth = 0;
10301
+ for (let index = 0; index < sourceLines.length; index++) {
10302
+ const lineNumber = index + 1;
10303
+ const rawLine = sourceLines[index] ?? "";
10304
+ const line = rawLine.trim();
10305
+ if (!line) continue;
10306
+ if (containerDepth > 0) {
10307
+ const opens = (rawLine.match(/\{/g) ?? []).length;
10308
+ const closes = (rawLine.match(/\}/g) ?? []).length;
10309
+ containerDepth = Math.max(0, containerDepth + opens - closes);
10310
+ continue;
10311
+ }
10312
+ if (line.startsWith("#")) continue;
10313
+ if (hasUnquotedHash(line)) {
10314
+ reportUnsupported(diagnostics, sourceLines, lineNumber, "D2 inline comments and unquoted # text are not supported; use a comment line or quote the label.");
10315
+ continue;
10316
+ }
10317
+ if (line.includes(";")) {
10318
+ reportUnsupported(diagnostics, sourceLines, lineNumber, "D2 semicolon-separated statements are not supported; place one statement on each line.");
10319
+ continue;
10320
+ }
10321
+ if (line.includes("{") || line.includes("}")) {
10322
+ reportUnsupported(
10323
+ diagnostics,
10324
+ sourceLines,
10325
+ lineNumber,
10326
+ "D2 containers and object-property blocks are not imported. Their contents are skipped to avoid treating nested shapes as top-level nodes.",
10327
+ "import.unsupported_semantics"
10328
+ );
10329
+ const opens = (rawLine.match(/\{/g) ?? []).length;
10330
+ const closes = (rawLine.match(/\}/g) ?? []).length;
10331
+ containerDepth = Math.max(0, opens - closes);
10332
+ continue;
10333
+ }
10334
+ const directionMatch = line.match(/^direction\s*:\s*(right|left|down|up)\s*$/i);
10335
+ if (directionMatch) {
10336
+ const value = directionMatch[1]?.toLowerCase();
10337
+ direction = value === "left" ? "RL" : value === "down" ? "TB" : value === "up" ? "BT" : "LR";
10338
+ continue;
10339
+ }
10340
+ if (/^direction\b/i.test(line)) {
10341
+ reportUnsupported(diagnostics, sourceLines, lineNumber, "D2 direction must be right, left, down, or up.", "import.parse_error");
10342
+ continue;
10343
+ }
10344
+ const shapeMatch = line.match(/^([A-Za-z_][A-Za-z0-9_-]*)\.shape\s*:\s*(.*?)\s*$/);
10345
+ if (shapeMatch) {
10346
+ const id = shapeMatch[1];
10347
+ const shape = decodeD2Label(shapeMatch[2] ?? "");
10348
+ if (!id || shape === void 0 || shape === "") {
10349
+ reportUnsupported(diagnostics, sourceLines, lineNumber, "D2 shape declaration needs a simple identifier and a shape value.", "import.parse_error");
10350
+ continue;
10351
+ }
10352
+ if (!nodesById.has(id)) addNode2(nodesById, id, id, lineNumber, sourceLines, diagnostics, false);
10353
+ shapes.set(id, { value: shape, line: lineNumber });
10354
+ continue;
10355
+ }
10356
+ const edgeMatch = line.match(/^([A-Za-z_][A-Za-z0-9_-]*?)\s*(<->|->|<-|--)\s*([A-Za-z_][A-Za-z0-9_-]*?)(?:\s*:\s*(.*))?\s*$/);
10357
+ if (edgeMatch) {
10358
+ const from = edgeMatch[1];
10359
+ const connector = edgeMatch[2];
10360
+ const to = edgeMatch[3];
10361
+ const rawLabel = edgeMatch[4];
10362
+ if (!from || !connector || !to) continue;
10363
+ let label;
10364
+ if (rawLabel !== void 0) {
10365
+ label = decodeD2Label(rawLabel);
10366
+ if (label === void 0) {
10367
+ reportUnsupported(diagnostics, sourceLines, lineNumber, "D2 connection label has invalid quotes.", "import.parse_error");
10368
+ continue;
10369
+ }
10370
+ if (hasMarkdownFormatting(label)) {
10371
+ reportUnsupported(diagnostics, sourceLines, lineNumber, "D2 connection labels with Markdown or HTML formatting cannot be represented as plain GraphDiagram labels.", "import.unsupported_semantics");
10372
+ continue;
10373
+ }
10374
+ }
10375
+ addNode2(nodesById, from, from, lineNumber, sourceLines, diagnostics, false);
10376
+ addNode2(nodesById, to, to, lineNumber, sourceLines, diagnostics, false);
10377
+ edges.push({
10378
+ from,
10379
+ to,
10380
+ ...label !== void 0 ? { label } : {},
10381
+ arrow: connector === "<->" ? "both" : connector === "<-" ? "backward" : connector === "--" ? "none" : "forward"
10382
+ });
10383
+ continue;
10384
+ }
10385
+ const nodeMatch = line.match(/^([A-Za-z_][A-Za-z0-9_-]*)(?:\s*:\s*(.*))?$/);
10386
+ if (nodeMatch) {
10387
+ const id = nodeMatch[1];
10388
+ const rawLabel = nodeMatch[2];
10389
+ if (!id) continue;
10390
+ let label = id;
10391
+ let explicitLabel = false;
10392
+ if (rawLabel !== void 0) {
10393
+ const decoded = decodeD2Label(rawLabel);
10394
+ if (decoded === void 0) {
10395
+ reportUnsupported(diagnostics, sourceLines, lineNumber, `D2 label for "${id}" has invalid quotes.`, "import.parse_error");
10396
+ continue;
10397
+ }
10398
+ label = decoded;
10399
+ explicitLabel = true;
10400
+ }
10401
+ addNode2(nodesById, id, label, lineNumber, sourceLines, diagnostics, explicitLabel);
10402
+ continue;
10403
+ }
10404
+ if (line.includes(".style") || line.includes(".width") || line.includes(".height") || line.includes(".near")) {
10405
+ reportUnsupported(diagnostics, sourceLines, lineNumber, "D2 styling, sizing, and positioning fields are not imported.", "import.unsupported_semantics");
10406
+ } else if (/^[A-Za-z_][A-Za-z0-9_-]*\./.test(line)) {
10407
+ reportUnsupported(diagnostics, sourceLines, lineNumber, "D2 dotted paths and shape properties are not supported outside the simple `.shape` declaration.");
10408
+ } else if (/(?:<->|->|<-|--)/.test(line)) {
10409
+ reportUnsupported(diagnostics, sourceLines, lineNumber, "Only one D2 connection between two simple identifiers per line is supported; chaining and connection properties are not imported.");
10410
+ } else {
10411
+ reportUnsupported(diagnostics, sourceLines, lineNumber, "Could not parse this D2 statement in the supported subset.", "import.parse_error");
10412
+ }
10413
+ }
10414
+ if (containerDepth > 0) {
10415
+ reportUnsupported(diagnostics, sourceLines, sourceLines.length, "D2 object-property block has no matching closing brace.", "import.parse_error");
10416
+ }
10417
+ for (const [id, { value, line }] of shapes) {
10418
+ if (value.toLowerCase() === "rectangle") continue;
10419
+ addImportDiagnostic(
10420
+ diagnostics,
10421
+ sourceLines,
10422
+ line,
10423
+ "import.lossy_semantics",
10424
+ "warning",
10425
+ `D2 shape "${value}" on "${id}" is reduced to a generic GraphDiagram node.`
10426
+ );
10427
+ }
10428
+ return graphImportResult("d2", {
10429
+ nodes: [...nodesById.values()].map(({ node }) => node),
10430
+ edges,
10431
+ groups: [],
10432
+ direction
10433
+ }, diagnostics);
10434
+ }
10435
+
10436
+ // src/check.ts
10437
+ var import_promises3 = require("fs/promises");
10438
+ var import_async_hooks2 = require("async_hooks");
10439
+ var import_os2 = require("os");
10440
+ var import_path3 = require("path");
10441
+
10442
+ // src/diagnostics.ts
10443
+ var import_parse_css_color3 = __toESM(require("parse-css-color"), 1);
10444
+ var import_react14 = require("react");
10445
+ var CHECK_DIAGNOSTIC_CODES = [
10446
+ "accessibility.low_contrast",
10447
+ "api.unsupported_prop",
10448
+ "asset.warning",
10449
+ "frame.load_error",
10450
+ "frame.unknown_preset",
10451
+ "layout.auto_size",
10452
+ "layout.connector_congestion",
10453
+ "layout.overflow",
10454
+ "layout.text_overlap",
10455
+ "layout.whitespace_imbalance",
10456
+ "readability.small_text",
10457
+ "render.error",
10458
+ "render.warning",
10459
+ "style.unsupported"
10460
+ ];
10461
+ var MAX_CONTRAST_NODES = 5e3;
10462
+ var MAX_DIAGNOSTICS_PER_RULE = 12;
10463
+ var MIN_TEXT_SIZE = 11;
10464
+ function hslToRgb2(hue, saturation, lightness) {
10465
+ const h = (hue % 360 + 360) % 360;
10466
+ const s = saturation / 100;
10467
+ const l = lightness / 100;
10468
+ const chroma = (1 - Math.abs(2 * l - 1)) * s;
10469
+ const segment = h / 60;
10470
+ const intermediate = chroma * (1 - Math.abs(segment % 2 - 1));
10471
+ let channels;
10472
+ if (segment < 1) channels = [chroma, intermediate, 0];
10473
+ else if (segment < 2) channels = [intermediate, chroma, 0];
10474
+ else if (segment < 3) channels = [0, chroma, intermediate];
10475
+ else if (segment < 4) channels = [0, intermediate, chroma];
10476
+ else if (segment < 5) channels = [intermediate, 0, chroma];
10477
+ else channels = [chroma, 0, intermediate];
10478
+ const offset = l - chroma / 2;
10479
+ return channels.map((channel) => Math.round((channel + offset) * 255));
10480
+ }
10481
+ function colorFromCss(value) {
10482
+ if (typeof value !== "string") return void 0;
10483
+ const parsed = (0, import_parse_css_color3.default)(value);
10484
+ if (!parsed || parsed.values.length < 3) return void 0;
10485
+ const [r, g, b] = parsed.type === "hsl" ? hslToRgb2(parsed.values[0] ?? 0, parsed.values[1] ?? 0, parsed.values[2] ?? 0) : [parsed.values[0] ?? 0, parsed.values[1] ?? 0, parsed.values[2] ?? 0];
10486
+ return {
10487
+ r,
10488
+ g,
10489
+ b,
10490
+ alpha: parsed.alpha
10491
+ };
10492
+ }
10493
+ function compositeOver(foreground, background) {
10494
+ if (foreground.alpha >= 1 || !background) return foreground;
10495
+ const alpha = foreground.alpha + background.alpha * (1 - foreground.alpha);
10496
+ if (alpha <= 0) return { r: 0, g: 0, b: 0, alpha: 0 };
10497
+ return {
10498
+ r: (foreground.r * foreground.alpha + background.r * background.alpha * (1 - foreground.alpha)) / alpha,
10499
+ g: (foreground.g * foreground.alpha + background.g * background.alpha * (1 - foreground.alpha)) / alpha,
10500
+ b: (foreground.b * foreground.alpha + background.b * background.alpha * (1 - foreground.alpha)) / alpha,
10501
+ alpha
10502
+ };
10503
+ }
10504
+ function isUnresolvedColor(value) {
10505
+ if (typeof value !== "string" || value.trim() === "" || colorFromCss(value)) return false;
10506
+ return !["inherit", "initial", "revert", "unset"].includes(value.trim().toLowerCase());
10507
+ }
10508
+ function channelLuminance(value) {
10509
+ const normalized = value / 255;
10510
+ return normalized <= 0.04045 ? normalized / 12.92 : ((normalized + 0.055) / 1.055) ** 2.4;
10511
+ }
10512
+ function relativeLuminance(color) {
10513
+ return 0.2126 * channelLuminance(color.r) + 0.7152 * channelLuminance(color.g) + 0.0722 * channelLuminance(color.b);
10514
+ }
10515
+ function contrastRatio(foreground, background) {
10516
+ const lighter = Math.max(relativeLuminance(foreground), relativeLuminance(background));
10517
+ const darker = Math.min(relativeLuminance(foreground), relativeLuminance(background));
10518
+ return (lighter + 0.05) / (darker + 0.05);
10519
+ }
10520
+ function numericFontWeight(value) {
10521
+ if (typeof value === "number") return value;
10522
+ if (value === "bold") return 700;
10523
+ if (typeof value === "string" && /^\d+$/.test(value)) return Number(value);
10524
+ return void 0;
10525
+ }
10526
+ function fontSizePixels(value, inherited) {
10527
+ if (typeof value === "number") return value;
10528
+ if (typeof value !== "string") return inherited;
10529
+ const match = value.trim().match(/^(\d+(?:\.\d+)?|\.\d+)(px|pt|rem|em|%)?$/);
10530
+ if (!match?.[1]) return inherited;
10531
+ const amount = Number(match[1]);
10532
+ const unit = match[2] ?? "px";
10533
+ if (unit === "pt") return amount * 4 / 3;
10534
+ if (unit === "rem") return amount * 16;
10535
+ if (unit === "em") return amount * (inherited ?? 16);
10536
+ if (unit === "%") return amount / 100 * (inherited ?? 16);
10537
+ return amount;
10538
+ }
10539
+ function requiredContrast(context) {
10540
+ const large = (context.fontSize ?? 16) >= 24 || (context.fontSize ?? 16) >= 18.66 && (context.fontWeight ?? 400) >= 700;
10541
+ return large ? 3 : 4.5;
10542
+ }
10543
+ function styleRecord(value) {
10544
+ if (!value || typeof value !== "object" || Array.isArray(value)) return {};
10545
+ return value;
10546
+ }
10547
+ function hasDirectText(children) {
10548
+ return import_react14.Children.toArray(children).some((child) => typeof child === "string" || typeof child === "number");
10549
+ }
10550
+ function elementId(props) {
10551
+ const value = props.id ?? props["data-vizmatic-id"];
10552
+ return typeof value === "string" && value.trim() !== "" ? value.trim() : void 0;
10553
+ }
10554
+ function resolveFunctionComponent(node, trustedComponents) {
10555
+ if (!(0, import_react14.isValidElement)(node) || typeof node.type !== "function" || trustedComponents.has(node.type)) return void 0;
10556
+ const component = node.type;
10557
+ if (component.__vizmaticPrimitive) return void 0;
10558
+ if (component.prototype?.isReactComponent) return void 0;
10559
+ try {
10560
+ return component(node.props);
10561
+ } catch {
10562
+ return void 0;
10563
+ }
10564
+ }
10565
+ function analyzeContrast(element, theme, trustedComponents = /* @__PURE__ */ new Set(), rootBackground2) {
10566
+ const diagnostics = [];
10567
+ const seen = /* @__PURE__ */ new Set();
10568
+ let visited = 0;
10569
+ function visit(node, inherited, path) {
10570
+ if (visited++ >= MAX_CONTRAST_NODES || !(0, import_react14.isValidElement)(node)) return;
10571
+ const resolved = resolveFunctionComponent(node, trustedComponents);
10572
+ if (resolved !== void 0) {
10573
+ visit(resolved, inherited, path);
10574
+ return;
10575
+ }
10576
+ const props = node.props;
10577
+ const style = typeof node.type === "string" ? styleRecord(props.style) : {};
10578
+ const backgroundImage = typeof style.backgroundImage === "string" ? style.backgroundImage.trim().toLowerCase() : "";
10579
+ const backgroundShorthand = typeof style.background === "string" ? style.background.trim() : "";
10580
+ const isBackgroundWrapper = typeof node.type === "function" && (trustedComponents.has(node.type) || Boolean(node.type.__vizmaticPrimitive));
10581
+ const wrapperBackground = isBackgroundWrapper ? props.background : void 0;
10582
+ const hasUnresolvedBackground = backgroundImage !== "" && backgroundImage !== "none" || isUnresolvedColor(style.backgroundColor) || backgroundShorthand !== "" && backgroundShorthand.toLowerCase() !== "none" && !colorFromCss(backgroundShorthand) || isUnresolvedColor(wrapperBackground);
10583
+ const ownBackground = colorFromCss(style.backgroundColor) ?? colorFromCss(style.background) ?? colorFromCss(wrapperBackground);
10584
+ const baseBackground = path === "root" && isBackgroundWrapper && colorFromCss(wrapperBackground) ? void 0 : inherited.background;
10585
+ const background = hasUnresolvedBackground ? void 0 : ownBackground ? compositeOver(ownBackground, baseBackground) : baseBackground;
10586
+ const color = typeof style.color === "string" && style.color.trim().toLowerCase() === "currentcolor" ? inherited.color : isUnresolvedColor(style.color) ? void 0 : colorFromCss(style.color) ?? inherited.color;
10587
+ const fontSize = fontSizePixels(style.fontSize, inherited.fontSize);
10588
+ const fontWeight = numericFontWeight(style.fontWeight) ?? inherited.fontWeight;
10589
+ const context = { background, color, fontSize, fontWeight };
10590
+ if (typeof node.type === "string" && hasDirectText(props.children) && color && background !== void 0 && background.alpha >= 1) {
10591
+ const renderedColor = compositeOver(color, background);
10592
+ const ratio = contrastRatio(renderedColor, background);
10593
+ const required = requiredContrast(context);
10594
+ if (ratio < required) {
10595
+ const rounded = Math.round(ratio * 100) / 100;
10596
+ const key = `${rounded}:${required}:${path}`;
10597
+ if (!seen.has(key)) {
10598
+ seen.add(key);
10599
+ diagnostics.push({
10600
+ code: "accessibility.low_contrast",
10601
+ severity: "warning",
10602
+ theme,
10603
+ message: `Text contrast is ${rounded}:1 at ${path}; ${required}:1 is recommended.`,
10604
+ suggestion: "Use a stronger text or background color token.",
10605
+ elementId: elementId(props),
10606
+ location: { path }
10607
+ });
10608
+ }
10609
+ }
10610
+ }
10611
+ import_react14.Children.forEach(props.children, (child, index) => visit(child, context, `${path}.${index}`));
10612
+ }
10613
+ visit(element, { background: colorFromCss(rootBackground2) }, "root");
10614
+ return diagnostics;
10615
+ }
10616
+ function containsLayoutNode(parent, child) {
10617
+ const epsilon = 0.5;
10618
+ return child.left >= parent.left - epsilon && child.top >= parent.top - epsilon && child.left + child.width <= parent.left + parent.width + epsilon && child.top + child.height <= parent.top + parent.height + epsilon;
10619
+ }
10620
+ function textUnits(text) {
10621
+ return Array.from(text.normalize("NFC")).reduce((sum, character) => sum + ((character.codePointAt(0) ?? 0) > 255 ? 1.7 : 1), 0);
10622
+ }
10623
+ function renderedTextNodes(nodes) {
10624
+ const textNodes = [];
10625
+ const ancestors = [];
10626
+ for (const node of nodes) {
10627
+ while (ancestors.length > 0 && !containsLayoutNode(ancestors[ancestors.length - 1].node, node)) {
10628
+ ancestors.pop();
10629
+ }
10630
+ const inherited = ancestors[ancestors.length - 1];
10631
+ const style = styleRecord(node.props.style);
10632
+ const fontSize = fontSizePixels(style.fontSize, inherited?.fontSize) ?? 16;
10633
+ const textAlign = typeof style.textAlign === "string" ? style.textAlign : inherited?.textAlign ?? "left";
10634
+ const text = node.textContent?.trim();
10635
+ if (text && node.width > 0 && node.height > 0) {
10636
+ const estimatedLines = Math.max(1, Math.round(node.height / Math.max(fontSize * 1.5, 1)));
10637
+ const paintHeight = Math.min(
10638
+ node.height,
10639
+ fontSize * 0.9 + (estimatedLines - 1) * fontSize * 1.25
10640
+ );
10641
+ const unwrappedWidth = textUnits(text) * fontSize * 0.56;
10642
+ const paintWidth = Math.min(node.width, unwrappedWidth);
10643
+ const horizontalInset = textAlign === "center" ? (node.width - paintWidth) / 2 : textAlign === "right" || textAlign === "end" ? node.width - paintWidth : 0;
10644
+ textNodes.push({
10645
+ text,
10646
+ elementId: elementId(node.props),
10647
+ left: node.left,
10648
+ top: node.top,
10649
+ width: node.width,
10650
+ height: node.height,
10651
+ paintLeft: node.left + horizontalInset,
10652
+ paintTop: node.top + (node.height - paintHeight) / 2,
10653
+ paintWidth,
10654
+ paintHeight,
10655
+ fontSize
10656
+ });
10657
+ } else if (node.width > 0 && node.height > 0) {
10658
+ ancestors.push({ node, fontSize, textAlign });
10659
+ }
10660
+ }
10661
+ return textNodes;
10662
+ }
10663
+ function textExcerpt(text) {
10664
+ const normalized = text.replace(/\s+/g, " ").trim();
10665
+ return normalized.length > 40 ? `${normalized.slice(0, 37)}...` : normalized;
10666
+ }
10667
+ function meaningfulOverlap(a, b) {
10668
+ const width = Math.min(a.paintLeft + a.paintWidth, b.paintLeft + b.paintWidth) - Math.max(a.paintLeft, b.paintLeft);
10669
+ const height = Math.min(a.paintTop + a.paintHeight, b.paintTop + b.paintHeight) - Math.max(a.paintTop, b.paintTop);
10670
+ if (width < 2 || height < 2) return false;
10671
+ if (a.text === b.text && a.left === b.left && a.top === b.top && a.width === b.width && a.height === b.height) return false;
10672
+ const overlapArea = width * height;
10673
+ const smallerArea = Math.min(a.paintWidth * a.paintHeight, b.paintWidth * b.paintHeight);
10674
+ return overlapArea / smallerArea >= 0.08;
10675
+ }
10676
+ function overlapCandidates(nodes) {
10677
+ const cellSize = 96;
10678
+ const buckets = /* @__PURE__ */ new Map();
10679
+ const pairs = [];
10680
+ for (let index = 0; index < nodes.length && pairs.length < MAX_DIAGNOSTICS_PER_RULE; index += 1) {
10681
+ const node = nodes[index];
10682
+ const minX = Math.floor(node.paintLeft / cellSize);
10683
+ const maxX = Math.floor((node.paintLeft + node.paintWidth) / cellSize);
10684
+ const minY = Math.floor(node.paintTop / cellSize);
10685
+ const maxY = Math.floor((node.paintTop + node.paintHeight) / cellSize);
10686
+ const candidates = /* @__PURE__ */ new Set();
10687
+ for (let x = minX; x <= maxX; x += 1) {
10688
+ for (let y = minY; y <= maxY; y += 1) {
10689
+ const bucket = buckets.get(`${x}:${y}`);
10690
+ bucket?.forEach((candidate) => candidates.add(candidate));
10691
+ }
10692
+ }
10693
+ for (const candidate of candidates) {
10694
+ if (meaningfulOverlap(nodes[candidate], node)) pairs.push([nodes[candidate], node]);
10695
+ if (pairs.length >= MAX_DIAGNOSTICS_PER_RULE) break;
10696
+ }
10697
+ for (let x = minX; x <= maxX; x += 1) {
10698
+ for (let y = minY; y <= maxY; y += 1) {
10699
+ const key = `${x}:${y}`;
10700
+ const bucket = buckets.get(key) ?? [];
10701
+ bucket.push(index);
10702
+ buckets.set(key, bucket);
10703
+ }
10704
+ }
10705
+ }
10706
+ return pairs;
10707
+ }
10708
+ function analyzeRenderedLayout(nodes, theme) {
10709
+ const diagnostics = [];
10710
+ const textNodes = renderedTextNodes(nodes);
10711
+ const seenSmallText = /* @__PURE__ */ new Set();
10712
+ let smallTextCount = 0;
10713
+ for (const node of textNodes) {
10714
+ if (node.fontSize >= MIN_TEXT_SIZE) continue;
10715
+ const excerpt = textExcerpt(node.text);
10716
+ const key = `${excerpt}:${node.fontSize}`;
10717
+ if (seenSmallText.has(key)) continue;
10718
+ seenSmallText.add(key);
10719
+ diagnostics.push({
10720
+ code: "readability.small_text",
10721
+ severity: "warning",
10722
+ theme,
10723
+ message: `Text "${excerpt}" renders at ${node.fontSize}px.`,
10724
+ suggestion: `Use at least ${MIN_TEXT_SIZE}px for details that must remain readable when embedded.`,
10725
+ elementId: node.elementId,
10726
+ location: { x: node.left, y: node.top, width: node.width, height: node.height }
10727
+ });
10728
+ smallTextCount += 1;
10729
+ if (smallTextCount >= MAX_DIAGNOSTICS_PER_RULE) break;
10730
+ }
10731
+ for (const [left, right] of overlapCandidates(textNodes)) {
10732
+ diagnostics.push({
10733
+ code: "layout.text_overlap",
10734
+ severity: "warning",
10735
+ theme,
10736
+ message: `Text "${textExcerpt(left.text)}" overlaps "${textExcerpt(right.text)}".`,
10737
+ suggestion: "Increase spacing or canvas size, shorten labels, or move one label.",
10738
+ elementId: left.elementId,
10739
+ relatedElementIds: right.elementId ? [right.elementId] : void 0,
10740
+ location: { x: left.left, y: left.top, width: left.width, height: left.height }
10741
+ });
10742
+ }
10743
+ const maxDataNumber = (attribute2) => Math.max(0, ...nodes.map((node) => {
10744
+ const value = node.props[attribute2];
10745
+ return typeof value === "number" ? value : Number(value) || 0;
10746
+ }));
10747
+ const connectorCrossings2 = maxDataNumber("data-vizmatic-connector-crossings");
10748
+ if (connectorCrossings2 > 0) {
10749
+ const source = nodes.find((node) => Number(node.props["data-vizmatic-connector-crossings"]) > 0);
10750
+ diagnostics.push({
10751
+ code: "layout.connector_congestion",
10752
+ severity: "warning",
10753
+ theme,
10754
+ message: `${connectorCrossings2} connector crossing${connectorCrossings2 === 1 ? "" : "s"} detected.`,
10755
+ suggestion: "Use automatic layout, change graph direction, or simplify the edge set.",
10756
+ elementId: source ? elementId(source.props) : void 0,
10757
+ location: source ? { x: source.left, y: source.top, width: source.width, height: source.height } : void 0
10758
+ });
10759
+ }
10760
+ const labelCollisions = maxDataNumber("data-vizmatic-connector-label-collisions");
10761
+ if (labelCollisions > 0) {
10762
+ const source = nodes.find((node) => Number(node.props["data-vizmatic-connector-label-collisions"]) > 0);
10763
+ diagnostics.push({
10764
+ code: "layout.connector_congestion",
10765
+ severity: "warning",
10766
+ theme,
10767
+ message: `${labelCollisions} connector label collision${labelCollisions === 1 ? "" : "s"} detected.`,
10768
+ suggestion: "Change graph direction or spacing, shorten edge labels, or remove nonessential labels.",
10769
+ elementId: source ? elementId(source.props) : void 0,
10770
+ location: source ? { x: source.left, y: source.top, width: source.width, height: source.height } : void 0
10771
+ });
10772
+ }
10773
+ const crowdedEndpoints = maxDataNumber("data-vizmatic-crowded-connector-endpoints");
10774
+ if (crowdedEndpoints > 0) {
10775
+ const source = nodes.find((node) => Number(node.props["data-vizmatic-crowded-connector-endpoints"]) > 0);
10776
+ diagnostics.push({
10777
+ code: "layout.connector_congestion",
10778
+ severity: "warning",
10779
+ theme,
10780
+ message: `${crowdedEndpoints} node${crowdedEndpoints === 1 ? "" : "s"} connect more than four edges.`,
10781
+ suggestion: "Group related branches, add an intermediate hub, or change graph direction.",
10782
+ elementId: source ? elementId(source.props) : void 0,
10783
+ location: source ? { x: source.left, y: source.top, width: source.width, height: source.height } : void 0
10784
+ });
10785
+ }
10786
+ const parallelGroups = maxDataNumber("data-vizmatic-parallel-connector-groups");
10787
+ if (parallelGroups > 0) {
10788
+ const source = nodes.find((node) => Number(node.props["data-vizmatic-parallel-connector-groups"]) > 0);
10789
+ diagnostics.push({
10790
+ code: "layout.connector_congestion",
10791
+ severity: "warning",
10792
+ theme,
10793
+ message: `${parallelGroups} connector route${parallelGroups === 1 ? "" : "s"} contain parallel edges.`,
10794
+ suggestion: "Merge duplicate relationships, label one combined edge, or separate the routes.",
10795
+ elementId: source ? elementId(source.props) : void 0,
10796
+ location: source ? { x: source.left, y: source.top, width: source.width, height: source.height } : void 0
10797
+ });
10798
+ }
10799
+ let whitespaceCount = 0;
10800
+ for (const container of nodes.filter((node) => node.props["data-vizmatic-layout-container"] === "panel")) {
10801
+ const contentNodes = nodes.filter(
10802
+ (node) => node.props["data-vizmatic-layout-content"] === "panel" && node.width > 0 && node.height > 0 && node.left >= container.left && node.top >= container.top && node.left + node.width <= container.left + container.width && node.top + node.height <= container.top + container.height
10803
+ );
10804
+ if (contentNodes.length === 0) continue;
10805
+ const contentTop = Math.min(...contentNodes.map((node) => node.top));
10806
+ const contentBottom = Math.max(...contentNodes.map((node) => node.top + node.height));
10807
+ const topGutter = contentTop - container.top;
10808
+ const bottomGutter = container.top + container.height - contentBottom;
10809
+ const difference = Math.abs(bottomGutter - topGutter);
10810
+ if (difference <= 48 || difference / container.height <= 0.18) continue;
10811
+ const largerSide = bottomGutter > topGutter ? "below" : "above";
10812
+ const smallerSide = largerSide === "below" ? "above" : "below";
10813
+ diagnostics.push({
10814
+ code: "layout.whitespace_imbalance",
10815
+ severity: "warning",
10816
+ theme,
10817
+ message: `Panel has ${Math.round(difference)}px more whitespace ${largerSide} its content than ${smallerSide} it.`,
10818
+ suggestion: "Reduce the panel height, distribute its contents, or avoid stretching it beside taller content.",
10819
+ elementId: elementId(container.props),
10820
+ location: { x: container.left, y: container.top, width: container.width, height: container.height }
10821
+ });
10822
+ whitespaceCount += 1;
10823
+ if (whitespaceCount >= MAX_DIAGNOSTICS_PER_RULE) break;
10824
+ }
10825
+ return diagnostics;
10826
+ }
10827
+ function analyzeWhitespaceBalance(bounds, width, height, theme) {
10828
+ const gutters = {
10829
+ left: bounds.x,
10830
+ right: width - bounds.x - bounds.width,
10831
+ top: bounds.y,
10832
+ bottom: height - bounds.y - bounds.height
10833
+ };
10834
+ const diagnostics = [];
10835
+ const horizontalDifference = Math.abs(gutters.left - gutters.right);
10836
+ const verticalDifference = Math.abs(gutters.top - gutters.bottom);
10837
+ if (horizontalDifference > 48 && horizontalDifference / width > 0.12) {
10838
+ diagnostics.push({
10839
+ code: "layout.whitespace_imbalance",
10840
+ severity: "warning",
10841
+ theme,
10842
+ message: `Horizontal gutters differ by ${Math.round(horizontalDifference)}px (${Math.round(gutters.left)}px left, ${Math.round(gutters.right)}px right).`,
10843
+ suggestion: "Recenter the composition, crop the canvas, or use the open space intentionally.",
10844
+ location: { x: bounds.x, y: bounds.y, width: bounds.width, height: bounds.height }
10845
+ });
10846
+ }
10847
+ if (verticalDifference > 48 && verticalDifference / height > 0.12) {
10848
+ diagnostics.push({
10849
+ code: "layout.whitespace_imbalance",
10850
+ severity: "warning",
10851
+ theme,
10852
+ message: `Vertical gutters differ by ${Math.round(verticalDifference)}px (${Math.round(gutters.top)}px top, ${Math.round(gutters.bottom)}px bottom).`,
10853
+ suggestion: "Recenter the composition, crop the canvas, or use the open space intentionally.",
10854
+ location: { x: bounds.x, y: bounds.y, width: bounds.width, height: bounds.height }
10855
+ });
10856
+ }
10857
+ return diagnostics;
10858
+ }
10859
+ function diagnosticFromMessage(message, severity, theme) {
10860
+ if (/unknown preset/i.test(message)) {
10861
+ return {
10862
+ code: "frame.unknown_preset",
10863
+ severity,
10864
+ theme,
10865
+ message,
10866
+ suggestion: 'Use "default" or "engineering".'
10867
+ };
10868
+ }
10869
+ if (/unsupported prop|unknown prop|does not recognize (?:the )?.* prop/i.test(message)) {
10870
+ return {
10871
+ code: "api.unsupported_prop",
10872
+ severity,
10873
+ theme,
10874
+ message,
10875
+ suggestion: "Remove the prop or use one documented for this Vizmatic primitive."
10876
+ };
10877
+ }
10878
+ if (/invalid value for css property|unsupported (?:css|style)|not supported.*css/i.test(message)) {
10879
+ return {
10880
+ code: "style.unsupported",
10881
+ severity,
10882
+ theme,
10883
+ message,
10884
+ suggestion: "Use CSS supported by Satori or a Vizmatic primitive."
10885
+ };
10886
+ }
10887
+ if (/font|emoji|image asset|failed to (?:download|fetch)|asset .*not found/i.test(message)) {
10888
+ return {
10889
+ code: "asset.warning",
10890
+ severity,
10891
+ theme,
10892
+ message,
10893
+ suggestion: "Use a reachable asset or install it locally before rendering offline."
10894
+ };
10895
+ }
10896
+ return {
10897
+ code: severity === "error" ? "render.error" : "render.warning",
10898
+ severity,
10899
+ theme,
10900
+ message
10901
+ };
10902
+ }
10903
+
10904
+ // src/check.ts
10905
+ var DEFAULT_WIDTH = 960;
10906
+ var DEFAULT_HEIGHT = 540;
10907
+ var MAX_WIDTH = 1920;
10908
+ var MAX_HEIGHT = 1440;
10909
+ var GROWTH = 1.25;
10910
+ var MAX_AUTO_SIZE_ATTEMPTS = 6;
10911
+ var TRUSTED_COMPONENTS = new Set(Object.values(primitives_exports));
10912
+ var consoleCaptureContext = new import_async_hooks2.AsyncLocalStorage();
10913
+ var activeConsoleCaptures = 0;
10914
+ var originalConsoleMethods;
10915
+ function formatConsoleArgs(args) {
10916
+ return args.map((value) => {
10917
+ if (value instanceof Error) return value.message;
10918
+ if (typeof value === "string") return value;
10919
+ try {
10920
+ return JSON.stringify(value);
10921
+ } catch {
10922
+ return String(value);
10923
+ }
10924
+ }).join(" ");
10925
+ }
10926
+ function installConsoleCapture() {
10927
+ if (activeConsoleCaptures === 0) {
10928
+ originalConsoleMethods = {
10929
+ debug: console.debug,
10930
+ error: console.error,
10931
+ info: console.info,
10932
+ log: console.log,
10933
+ warn: console.warn
10934
+ };
10935
+ const original = originalConsoleMethods;
10936
+ const intercept = (method, severity) => (...args) => {
10937
+ const messages = consoleCaptureContext.getStore();
10938
+ if (messages) {
10939
+ if (severity) messages.push({ severity, message: formatConsoleArgs(args) });
10940
+ return;
10941
+ }
10942
+ Reflect.apply(original[method], console, args);
10943
+ };
10944
+ console.debug = intercept("debug");
10945
+ console.error = intercept("error", "error");
10946
+ console.info = intercept("info");
10947
+ console.log = intercept("log");
10948
+ console.warn = intercept("warn", "warning");
10949
+ }
10950
+ activeConsoleCaptures += 1;
10951
+ let restored = false;
10952
+ return () => {
10953
+ if (restored) return;
10954
+ restored = true;
10955
+ activeConsoleCaptures -= 1;
10956
+ if (activeConsoleCaptures === 0 && originalConsoleMethods) {
10957
+ console.debug = originalConsoleMethods.debug;
10958
+ console.error = originalConsoleMethods.error;
10959
+ console.info = originalConsoleMethods.info;
10960
+ console.log = originalConsoleMethods.log;
10961
+ console.warn = originalConsoleMethods.warn;
10962
+ originalConsoleMethods = void 0;
10963
+ }
10964
+ };
10965
+ }
10966
+ async function captureConsole(run) {
10967
+ const messages = [];
10968
+ const uninstall = installConsoleCapture();
10969
+ try {
10970
+ const value = await consoleCaptureContext.run(messages, run);
10971
+ return { value, messages };
10972
+ } catch (error) {
10973
+ return { error, messages };
10974
+ } finally {
10975
+ uninstall();
10976
+ }
10977
+ }
10978
+ function normalizeAutoSize(value, defaults) {
10979
+ if (value === true) return { width: true, height: true };
10980
+ if (value === false) return { width: false, height: false };
10981
+ if (value) return { width: value.width ?? defaults.width, height: value.height ?? defaults.height };
10982
+ return defaults;
10983
+ }
10984
+ function overflowEdges(error) {
10985
+ if (!(error instanceof CanvasOverflowError)) return void 0;
10986
+ return Object.entries(error.overflow.edges).filter(([, overflows]) => overflows).map(([edge]) => edge);
10987
+ }
10988
+ function nextDimension(value, maximum) {
10989
+ return Math.min(maximum, Math.ceil(value * GROWTH / 10) * 10);
10990
+ }
10991
+ function nextAutoSize(width, height, autoSize, edges) {
10992
+ const growWidth = autoSize.width && (edges.includes("left") || edges.includes("right"));
10993
+ const growHeight = autoSize.height && (edges.includes("top") || edges.includes("bottom"));
10994
+ const nextWidth = growWidth ? nextDimension(width, MAX_WIDTH) : width;
10995
+ const nextHeight = growHeight ? nextDimension(height, MAX_HEIGHT) : height;
10996
+ if (nextWidth === width && nextHeight === height) return void 0;
10997
+ return { width: nextWidth, height: nextHeight };
10998
+ }
10999
+ async function renderFrame(create, theme, options) {
11000
+ let width = options.width;
11001
+ let height = options.height;
11002
+ for (let attempt = 0; attempt < MAX_AUTO_SIZE_ATTEMPTS; attempt += 1) {
11003
+ try {
11004
+ const layoutNodes = [];
11005
+ const output = await renderToPngWithOutput(create(theme), {
11006
+ width,
11007
+ height,
11008
+ outputPath: options.outputPath,
11009
+ crop: true,
11010
+ scale: 1,
11011
+ background: options.background,
11012
+ onNodeDetected: (node) => layoutNodes.push(node)
11013
+ }, create, theme);
11014
+ return {
11015
+ width,
11016
+ height,
11017
+ outputWidth: output.pixelWidth,
11018
+ outputHeight: output.pixelHeight,
11019
+ logicalOutputWidth: output.width,
11020
+ logicalOutputHeight: output.height,
11021
+ contentBounds: output.contentBounds,
11022
+ layoutNodes
11023
+ };
11024
+ } catch (error) {
11025
+ const edges = overflowEdges(error);
11026
+ const next = edges ? nextAutoSize(width, height, options.autoSize, edges) : void 0;
11027
+ if (!next || attempt === MAX_AUTO_SIZE_ATTEMPTS - 1) throw error;
11028
+ width = next.width;
11029
+ height = next.height;
11030
+ }
11031
+ }
11032
+ return {
11033
+ width,
11034
+ height,
11035
+ outputWidth: width,
11036
+ outputHeight: height,
11037
+ logicalOutputWidth: width,
11038
+ logicalOutputHeight: height,
11039
+ layoutNodes: []
11040
+ };
11041
+ }
11042
+ function counts(themes) {
11043
+ const diagnostics = themes.flatMap(({ diagnostics: themeDiagnostics }) => themeDiagnostics);
11044
+ return {
11045
+ errors: diagnostics.filter(({ severity }) => severity === "error").length,
11046
+ warnings: diagnostics.filter(({ severity }) => severity === "warning").length,
11047
+ info: diagnostics.filter(({ severity }) => severity === "info").length
11048
+ };
11049
+ }
11050
+ function fails(diagnostics, policy) {
11051
+ if (policy === "never") return false;
11052
+ const threshold = { error: 0, warning: 1, info: 2 }[policy];
11053
+ const levels = { error: 0, warning: 1, info: 2 };
11054
+ return diagnostics.some(({ severity }) => levels[severity] <= threshold);
11055
+ }
11056
+ function messageDiagnostics(messages, theme) {
11057
+ return messages.map(({ message, severity }) => diagnosticFromMessage(message, severity, theme));
11058
+ }
11059
+ function rootBackground(background, theme) {
11060
+ if (background === "theme") return getThemeColors(theme).bg;
11061
+ if (background === "transparent" || background === void 0) return void 0;
11062
+ return background;
11063
+ }
11064
+ async function checkFrame(input, options = {}) {
11065
+ const themes = options.themes ?? ["dark", "light"];
11066
+ if (themes.length === 0) throw new TypeError("checkFrame requires at least one theme");
11067
+ const width = input.width ?? DEFAULT_WIDTH;
11068
+ const height = input.height ?? DEFAULT_HEIGHT;
11069
+ if (!Number.isFinite(width) || width <= 0 || !Number.isFinite(height) || height <= 0) {
11070
+ throw new TypeError("checkFrame width and height must be positive finite numbers");
11071
+ }
11072
+ const autoSize = normalizeAutoSize(input.autoSize, {
11073
+ width: input.width == null,
11074
+ height: input.height == null
11075
+ });
11076
+ const create = input.create ?? (() => input.scene);
11077
+ const failOn = options.failOn ?? "error";
11078
+ const tempDir = await (0, import_promises3.mkdtemp)((0, import_path3.join)((0, import_os2.tmpdir)(), "vizmatic-check-"));
11079
+ const reports = [];
11080
+ try {
11081
+ for (const [themeIndex, theme] of themes.entries()) {
11082
+ const inputDimensions = { width, height };
11083
+ const diagnostics2 = [];
11084
+ const prepared = await captureConsole(async () => {
11085
+ const element = create(theme);
11086
+ const background = rootBackground(options.background, theme);
11087
+ return analyzeContrast(element, theme, TRUSTED_COMPONENTS, background);
11088
+ });
11089
+ diagnostics2.push(...messageDiagnostics(prepared.messages, theme));
11090
+ if (!prepared.value) {
11091
+ diagnostics2.push(diagnosticFromMessage(
11092
+ prepared.error instanceof Error ? prepared.error.message : String(prepared.error),
11093
+ "error",
11094
+ theme
11095
+ ));
11096
+ reports.push({
11097
+ theme,
11098
+ ok: !fails(diagnostics2, failOn),
11099
+ dimensions: { input: inputDimensions },
11100
+ diagnostics: diagnostics2
11101
+ });
11102
+ continue;
11103
+ }
11104
+ diagnostics2.push(...prepared.value);
11105
+ const rendered = await captureConsole(() => renderFrame(create, theme, {
11106
+ width,
11107
+ height,
11108
+ autoSize,
11109
+ background: options.background,
11110
+ outputPath: (0, import_path3.join)(tempDir, `${themeIndex}.png`)
11111
+ }));
11112
+ diagnostics2.push(...messageDiagnostics(rendered.messages, theme));
11113
+ if (rendered.value) {
11114
+ diagnostics2.push(...analyzeRenderedLayout(rendered.value.layoutNodes, theme));
11115
+ if (rendered.value.contentBounds) {
11116
+ diagnostics2.push(...analyzeWhitespaceBalance(
11117
+ rendered.value.contentBounds,
11118
+ rendered.value.logicalOutputWidth,
11119
+ rendered.value.logicalOutputHeight,
11120
+ theme
11121
+ ));
11122
+ }
11123
+ if (rendered.value.width !== width || rendered.value.height !== height) {
11124
+ diagnostics2.push({
11125
+ code: "layout.auto_size",
11126
+ severity: "info",
11127
+ theme,
11128
+ message: `Canvas auto-sized from ${width}\xD7${height} to ${rendered.value.width}\xD7${rendered.value.height}.`,
11129
+ suggestedDimensions: { width: rendered.value.width, height: rendered.value.height }
11130
+ });
11131
+ }
11132
+ reports.push({
11133
+ theme,
11134
+ ok: !fails(diagnostics2, failOn),
11135
+ dimensions: {
11136
+ input: inputDimensions,
11137
+ resolved: { width: rendered.value.width, height: rendered.value.height },
11138
+ output: { width: rendered.value.outputWidth, height: rendered.value.outputHeight }
11139
+ },
11140
+ diagnostics: diagnostics2
11141
+ });
11142
+ continue;
11143
+ }
11144
+ const edges = overflowEdges(rendered.error);
11145
+ if (edges) {
11146
+ const suggestion = await captureConsole(() => renderFrame(create, theme, {
11147
+ width,
11148
+ height,
11149
+ autoSize: { width: true, height: true },
11150
+ background: options.background,
11151
+ outputPath: (0, import_path3.join)(tempDir, `${themeIndex}-suggestion.png`)
11152
+ }));
11153
+ const suggestedDimensions = suggestion.value ? { width: suggestion.value.width, height: suggestion.value.height } : void 0;
11154
+ diagnostics2.push({
11155
+ code: "layout.overflow",
11156
+ severity: "error",
11157
+ theme,
11158
+ edges,
11159
+ message: rendered.error instanceof Error ? rendered.error.message : String(rendered.error),
11160
+ suggestion: suggestedDimensions ? `Increase the canvas to at least ${suggestedDimensions.width}\xD7${suggestedDimensions.height}, or remove fixed dimensions to enable auto-sizing.` : "Increase the canvas dimensions or remove fixed dimensions to enable auto-sizing.",
11161
+ suggestedDimensions
11162
+ });
11163
+ } else {
11164
+ diagnostics2.push(diagnosticFromMessage(
11165
+ rendered.error instanceof Error ? rendered.error.message : String(rendered.error),
11166
+ "error",
11167
+ theme
11168
+ ));
11169
+ }
11170
+ reports.push({
11171
+ theme,
11172
+ ok: !fails(diagnostics2, failOn),
11173
+ dimensions: { input: inputDimensions },
11174
+ diagnostics: diagnostics2
11175
+ });
11176
+ }
11177
+ } finally {
11178
+ await (0, import_promises3.rm)(tempDir, { recursive: true, force: true });
11179
+ }
11180
+ const summary = counts(reports);
11181
+ const diagnostics = reports.flatMap(({ diagnostics: themeDiagnostics }) => themeDiagnostics);
11182
+ return {
11183
+ schemaVersion: 1,
11184
+ source: input.source,
11185
+ ok: !fails(diagnostics, failOn),
11186
+ rendered: reports.every(({ dimensions }) => dimensions.resolved !== void 0),
11187
+ autoSize,
11188
+ themes: reports,
11189
+ summary
11190
+ };
11191
+ }
9489
11192
  // Annotate the CommonJS export names for ESM import in node:
9490
11193
  0 && (module.exports = {
9491
11194
  Arrow,
@@ -9495,6 +11198,7 @@ async function renderAnimationGifWithOutput(animation, options) {
9495
11198
  BadgePill,
9496
11199
  BarChart,
9497
11200
  Box,
11201
+ CHECK_DIAGNOSTIC_CODES,
9498
11202
  CalloutCard,
9499
11203
  Canvas,
9500
11204
  CanvasOverflowError,
@@ -9562,6 +11266,7 @@ async function renderAnimationGifWithOutput(animation, options) {
9562
11266
  WindowFrame,
9563
11267
  analyzeAnimationCadence,
9564
11268
  canvas,
11269
+ checkFrame,
9565
11270
  colors,
9566
11271
  createPlotArea,
9567
11272
  cropPixels,
@@ -9588,6 +11293,8 @@ async function renderAnimationGifWithOutput(animation, options) {
9588
11293
  gradients,
9589
11294
  heatColor,
9590
11295
  hold,
11296
+ importD2Graph,
11297
+ importMermaidGraph,
9591
11298
  keyframe,
9592
11299
  loadAdditionalAsset,
9593
11300
  normalizeWatermark,