vizmatic 0.1.21 → 0.1.23

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/cli.js CHANGED
@@ -35,6 +35,7 @@ __export(index_exports, {
35
35
  DashedLine: () => DashedLine,
36
36
  DataTable: () => DataTable,
37
37
  DetailList: () => DetailList,
38
+ DonutChart: () => DonutChart,
38
39
  DotPoint: () => DotPoint,
39
40
  EquationCard: () => EquationCard,
40
41
  Flow: () => Flow,
@@ -43,6 +44,7 @@ __export(index_exports, {
43
44
  GraphDiagram: () => GraphDiagram,
44
45
  Grid: () => Grid,
45
46
  Heatmap: () => Heatmap,
47
+ Icon: () => Icon,
46
48
  IntervalPlot: () => IntervalPlot,
47
49
  KeyValueList: () => KeyValueList,
48
50
  LayeredNetwork: () => LayeredNetwork,
@@ -72,8 +74,10 @@ __export(index_exports, {
72
74
  Tile: () => Tile,
73
75
  TileGrid: () => TileGrid,
74
76
  TiledMatrix: () => TiledMatrix,
77
+ Timeline: () => Timeline,
75
78
  TitleBar: () => TitleBar,
76
79
  ToneStrip: () => ToneStrip,
80
+ TreeDiagram: () => TreeDiagram,
77
81
  ValuePill: () => ValuePill,
78
82
  VectorArrow: () => VectorArrow,
79
83
  VectorSegment: () => VectorSegment,
@@ -544,6 +548,113 @@ function ToneStrip({ tone, width = 34, height = 4 }) {
544
548
  }
545
549
  }, "");
546
550
  }
551
+ var iconShapes = {
552
+ agent: [
553
+ { tag: "rect", attrs: { x: 5, y: 7, width: 14, height: 12, rx: 4 } },
554
+ { tag: "path", attrs: { d: "M12 7V4" } },
555
+ { tag: "circle", attrs: { cx: 12, cy: 3, r: 1 } },
556
+ { tag: "circle", attrs: { cx: 9, cy: 13, r: 1 } },
557
+ { tag: "circle", attrs: { cx: 15, cy: 13, r: 1 } },
558
+ { tag: "path", attrs: { d: "M9 17h6" } }
559
+ ],
560
+ chart: [
561
+ { tag: "path", attrs: { d: "M4 19V5" } },
562
+ { tag: "path", attrs: { d: "M4 19h16" } },
563
+ { tag: "polyline", attrs: { points: "7 15 11 11 14 13 19 7" } }
564
+ ],
565
+ check: [{ tag: "polyline", attrs: { points: "20 6 9 17 4 12" } }],
566
+ code: [
567
+ { tag: "polyline", attrs: { points: "8 9 4 12 8 15" } },
568
+ { tag: "polyline", attrs: { points: "16 9 20 12 16 15" } },
569
+ { tag: "path", attrs: { d: "M13 5l-2 14" } }
570
+ ],
571
+ database: [
572
+ { tag: "path", attrs: { d: "M4 7c0-2 16-2 16 0s-16 2-16 0Z" } },
573
+ { tag: "path", attrs: { d: "M4 7v5c0 2 16 2 16 0V7" } },
574
+ { tag: "path", attrs: { d: "M4 12v5c0 2 16 2 16 0v-5" } }
575
+ ],
576
+ file: [
577
+ { tag: "path", attrs: { d: "M6 3h8l4 4v14H6Z" } },
578
+ { tag: "path", attrs: { d: "M14 3v5h5" } },
579
+ { tag: "path", attrs: { d: "M9 13h6" } },
580
+ { tag: "path", attrs: { d: "M9 17h4" } }
581
+ ],
582
+ git: [
583
+ { tag: "circle", attrs: { cx: 6, cy: 6, r: 2 } },
584
+ { tag: "circle", attrs: { cx: 18, cy: 18, r: 2 } },
585
+ { tag: "circle", attrs: { cx: 6, cy: 18, r: 2 } },
586
+ { tag: "path", attrs: { d: "M8 6h3a5 5 0 0 1 5 5v5" } },
587
+ { tag: "path", attrs: { d: "M6 8v8" } }
588
+ ],
589
+ globe: [
590
+ { tag: "circle", attrs: { cx: 12, cy: 12, r: 9 } },
591
+ { tag: "path", attrs: { d: "M3 12h18" } },
592
+ { tag: "path", attrs: { d: "M12 3a14 14 0 0 1 0 18" } },
593
+ { tag: "path", attrs: { d: "M12 3a14 14 0 0 0 0 18" } }
594
+ ],
595
+ image: [
596
+ { tag: "rect", attrs: { x: 4, y: 5, width: 16, height: 14, rx: 3 } },
597
+ { tag: "circle", attrs: { cx: 9, cy: 10, r: 1.5 } },
598
+ { tag: "polyline", attrs: { points: "7 17 11 13 14 16 16 14 20 18" } }
599
+ ],
600
+ layers: [
601
+ { tag: "path", attrs: { d: "M12 3 3 8l9 5 9-5Z" } },
602
+ { tag: "path", attrs: { d: "m3 13 9 5 9-5" } },
603
+ { tag: "path", attrs: { d: "m3 18 9 5 9-5" } }
604
+ ],
605
+ lock: [
606
+ { tag: "rect", attrs: { x: 5, y: 10, width: 14, height: 10, rx: 2 } },
607
+ { tag: "path", attrs: { d: "M8 10V7a4 4 0 0 1 8 0v3" } }
608
+ ],
609
+ play: [{ tag: "path", attrs: { d: "M8 5v14l11-7Z" } }],
610
+ spark: [
611
+ { tag: "path", attrs: { d: "M12 3l1.8 5.2L19 10l-5.2 1.8L12 17l-1.8-5.2L5 10l5.2-1.8Z" } },
612
+ { tag: "path", attrs: { d: "M5 16l.8 2.2L8 19l-2.2.8L5 22l-.8-2.2L2 19l2.2-.8Z" } }
613
+ ],
614
+ terminal: [
615
+ { tag: "polyline", attrs: { points: "5 7 10 12 5 17" } },
616
+ { tag: "path", attrs: { d: "M12 17h7" } }
617
+ ],
618
+ tool: [
619
+ { tag: "path", attrs: { d: "M14 6a5 5 0 0 0 6 6L11 21l-6-6 9-9Z" } },
620
+ { tag: "path", attrs: { d: "M8 18l-2-2" } }
621
+ ],
622
+ warning: [
623
+ { tag: "path", attrs: { d: "M12 4 22 20H2Z" } },
624
+ { tag: "path", attrs: { d: "M12 9v5" } },
625
+ { tag: "path", attrs: { d: "M12 17h.01" } }
626
+ ]
627
+ };
628
+ function Icon({
629
+ c,
630
+ name,
631
+ tone = "blue",
632
+ color,
633
+ size = 24,
634
+ strokeWidth = 2,
635
+ label,
636
+ muted = false
637
+ }) {
638
+ const stroke = muted ? c.textMuted : color ?? getToneColor(tone, c);
639
+ const shapes = iconShapes[name];
640
+ return React.createElement("svg", {
641
+ width: size,
642
+ height: size,
643
+ viewBox: "0 0 24 24",
644
+ fill: "none",
645
+ stroke,
646
+ strokeWidth,
647
+ strokeLinecap: "round",
648
+ strokeLinejoin: "round",
649
+ role: label ? "img" : void 0,
650
+ "aria-hidden": label ? void 0 : "true",
651
+ "aria-label": label,
652
+ style: { flex: `0 0 ${size}px` }
653
+ }, shapes.map((shape, index) => React.createElement(shape.tag, {
654
+ key: `${name}-${index}`,
655
+ ...shape.attrs
656
+ })));
657
+ }
547
658
  function Panel({
548
659
  title,
549
660
  c,
@@ -2535,6 +2646,274 @@ function StatusList({
2535
2646
  ))
2536
2647
  });
2537
2648
  }
2649
+ function renderTimelineCard(event, c, math, width) {
2650
+ const accent = getToneColor(event.tone ?? statusTones[event.status ?? "dot"], c);
2651
+ const resolvedWidth = event.width ?? width;
2652
+ return React.createElement(
2653
+ "div",
2654
+ {
2655
+ style: {
2656
+ display: "flex",
2657
+ flexDirection: "column",
2658
+ gap: 5,
2659
+ ...resolvedWidth != null ? { width: resolvedWidth } : {},
2660
+ ...typeof resolvedWidth === "string" ? { minWidth: 0 } : {},
2661
+ padding: "10px 12px",
2662
+ borderRadius: 8,
2663
+ border: `1px solid ${accent}44`,
2664
+ backgroundColor: c.bgCard,
2665
+ boxShadow: `0 7px 18px ${c.shadow}`,
2666
+ boxSizing: "border-box"
2667
+ }
2668
+ },
2669
+ ...compactChildren([
2670
+ event.time != null && React.createElement("div", {
2671
+ style: {
2672
+ display: "flex",
2673
+ color: accent,
2674
+ fontFamily: "JetBrains Mono",
2675
+ fontSize: 9,
2676
+ fontWeight: 900,
2677
+ lineHeight: 1.15,
2678
+ textTransform: "uppercase",
2679
+ letterSpacing: "0.04em"
2680
+ }
2681
+ }, renderMaybeMath(event.time, math)),
2682
+ React.createElement("div", {
2683
+ style: {
2684
+ display: "flex",
2685
+ color: c.textPrimary,
2686
+ fontFamily: "Inter",
2687
+ fontSize: 14,
2688
+ fontWeight: 900,
2689
+ lineHeight: 1.18,
2690
+ ...textFitStyle()
2691
+ }
2692
+ }, renderMaybeMath(event.title, math)),
2693
+ event.detail != null && React.createElement("div", {
2694
+ style: {
2695
+ display: "flex",
2696
+ color: c.textSecondary,
2697
+ fontFamily: "Inter",
2698
+ fontSize: 11,
2699
+ fontWeight: 500,
2700
+ lineHeight: 1.35,
2701
+ ...textFitStyle()
2702
+ }
2703
+ }, renderMaybeMath(event.detail, math))
2704
+ ])
2705
+ );
2706
+ }
2707
+ function Timeline({
2708
+ events,
2709
+ c,
2710
+ title,
2711
+ subtitle,
2712
+ direction = "vertical",
2713
+ width,
2714
+ eventWidth,
2715
+ gap = 12,
2716
+ markerSize = 14,
2717
+ math = false
2718
+ }) {
2719
+ const header = (title != null || subtitle != null) && React.createElement(
2720
+ "div",
2721
+ {
2722
+ style: {
2723
+ display: "flex",
2724
+ flexDirection: "column",
2725
+ gap: subtitle != null ? 4 : 0,
2726
+ width: "100%"
2727
+ }
2728
+ },
2729
+ ...compactChildren([
2730
+ title != null && React.createElement("div", {
2731
+ style: {
2732
+ display: "flex",
2733
+ alignItems: "center",
2734
+ gap: 8,
2735
+ color: c.textPrimary,
2736
+ fontFamily: "Inter",
2737
+ fontSize: 16,
2738
+ fontWeight: 900,
2739
+ lineHeight: 1.2
2740
+ }
2741
+ }, ToneStrip({ tone: events[0]?.tone ?? "blue" }), renderMaybeMath(title, math)),
2742
+ subtitle != null && React.createElement("div", {
2743
+ style: {
2744
+ display: "flex",
2745
+ color: c.textSecondary,
2746
+ fontFamily: "Inter",
2747
+ fontSize: 11,
2748
+ fontWeight: 500,
2749
+ lineHeight: 1.35
2750
+ }
2751
+ }, renderMaybeMath(subtitle, math))
2752
+ ])
2753
+ );
2754
+ if (direction === "horizontal") {
2755
+ return React.createElement(
2756
+ "div",
2757
+ {
2758
+ style: {
2759
+ display: "flex",
2760
+ flexDirection: "column",
2761
+ gap,
2762
+ ...width != null ? { width } : {}
2763
+ }
2764
+ },
2765
+ ...compactChildren([
2766
+ header,
2767
+ React.createElement("div", {
2768
+ style: {
2769
+ display: "flex",
2770
+ alignItems: "stretch",
2771
+ gap: 0,
2772
+ width: "100%"
2773
+ }
2774
+ }, ...events.map((event, index) => {
2775
+ const accent = getToneColor(event.tone ?? statusTones[event.status ?? "dot"], c);
2776
+ return React.createElement(
2777
+ "div",
2778
+ {
2779
+ key: `timeline-h-${index}`,
2780
+ style: {
2781
+ display: "flex",
2782
+ flexDirection: "column",
2783
+ gap: 8,
2784
+ ...eventWidth == null ? { flex: 1 } : {},
2785
+ ...(event.width ?? eventWidth) != null ? { width: event.width ?? eventWidth } : {},
2786
+ minWidth: 0
2787
+ }
2788
+ },
2789
+ React.createElement(
2790
+ "div",
2791
+ {
2792
+ style: {
2793
+ display: "flex",
2794
+ alignItems: "center",
2795
+ width: "100%"
2796
+ }
2797
+ },
2798
+ React.createElement("div", {
2799
+ style: {
2800
+ display: "flex",
2801
+ flex: 1,
2802
+ height: 2,
2803
+ backgroundColor: c.borderLight,
2804
+ opacity: index === 0 ? 0 : 1
2805
+ }
2806
+ }),
2807
+ React.createElement("div", {
2808
+ style: {
2809
+ display: "flex",
2810
+ width: markerSize,
2811
+ height: markerSize,
2812
+ borderRadius: 999,
2813
+ backgroundColor: accent,
2814
+ border: `3px solid ${c.bg}`,
2815
+ boxShadow: `0 0 0 1px ${accent}`,
2816
+ flexShrink: 0
2817
+ }
2818
+ }),
2819
+ React.createElement("div", {
2820
+ style: {
2821
+ display: "flex",
2822
+ flex: 1,
2823
+ height: 2,
2824
+ backgroundColor: c.borderLight,
2825
+ opacity: index === events.length - 1 ? 0 : 1
2826
+ }
2827
+ })
2828
+ ),
2829
+ renderTimelineCard(event, c, math, eventWidth)
2830
+ );
2831
+ }))
2832
+ ])
2833
+ );
2834
+ }
2835
+ return React.createElement(
2836
+ "div",
2837
+ {
2838
+ style: {
2839
+ display: "flex",
2840
+ flexDirection: "column",
2841
+ gap,
2842
+ ...width != null ? { width } : {}
2843
+ }
2844
+ },
2845
+ ...compactChildren([
2846
+ header,
2847
+ React.createElement("div", {
2848
+ style: {
2849
+ display: "flex",
2850
+ flexDirection: "column",
2851
+ gap,
2852
+ width: "100%"
2853
+ }
2854
+ }, ...events.map((event, index) => {
2855
+ const accent = getToneColor(event.tone ?? statusTones[event.status ?? "dot"], c);
2856
+ return React.createElement(
2857
+ "div",
2858
+ {
2859
+ key: `timeline-v-${index}`,
2860
+ style: {
2861
+ display: "flex",
2862
+ alignItems: "stretch",
2863
+ gap: 11,
2864
+ width: "100%"
2865
+ }
2866
+ },
2867
+ React.createElement(
2868
+ "div",
2869
+ {
2870
+ style: {
2871
+ display: "flex",
2872
+ flexDirection: "column",
2873
+ alignItems: "center",
2874
+ width: markerSize + 8,
2875
+ flexShrink: 0
2876
+ }
2877
+ },
2878
+ React.createElement("div", {
2879
+ style: {
2880
+ display: "flex",
2881
+ flex: 1,
2882
+ minHeight: 4,
2883
+ width: 2,
2884
+ backgroundColor: c.borderLight,
2885
+ opacity: index === 0 ? 0 : 1
2886
+ }
2887
+ }),
2888
+ React.createElement("div", {
2889
+ style: {
2890
+ display: "flex",
2891
+ width: markerSize,
2892
+ height: markerSize,
2893
+ borderRadius: 999,
2894
+ backgroundColor: accent,
2895
+ border: `3px solid ${c.bg}`,
2896
+ boxShadow: `0 0 0 1px ${accent}`,
2897
+ flexShrink: 0
2898
+ }
2899
+ }),
2900
+ React.createElement("div", {
2901
+ style: {
2902
+ display: "flex",
2903
+ flex: 1,
2904
+ minHeight: 4,
2905
+ width: 2,
2906
+ backgroundColor: c.borderLight,
2907
+ opacity: index === events.length - 1 ? 0 : 1
2908
+ }
2909
+ })
2910
+ ),
2911
+ renderTimelineCard(event, c, math)
2912
+ );
2913
+ }))
2914
+ ])
2915
+ );
2916
+ }
2538
2917
  function renderFlowStage(stage, c, math) {
2539
2918
  const tone = stage.tone ?? "blue";
2540
2919
  const hasDetails = Boolean(stage.children || stage.lines?.length);
@@ -2971,6 +3350,209 @@ function GraphDiagram({
2971
3350
  })
2972
3351
  );
2973
3352
  }
3353
+ function countTreeLeaves(node) {
3354
+ if (!node.children?.length) return 1;
3355
+ return node.children.reduce((sum, child) => sum + countTreeLeaves(child), 0);
3356
+ }
3357
+ function maxTreeDepth(node) {
3358
+ if (!node.children?.length) return 0;
3359
+ return 1 + Math.max(...node.children.map(maxTreeDepth));
3360
+ }
3361
+ function TreeDiagram({
3362
+ root,
3363
+ c,
3364
+ title,
3365
+ subtitle,
3366
+ width,
3367
+ height,
3368
+ nodeWidth = 156,
3369
+ nodeHeight = 64,
3370
+ levelGap = 58,
3371
+ siblingGap = 24,
3372
+ padding = 28,
3373
+ math = false
3374
+ }) {
3375
+ const leafCount = Math.max(1, countTreeLeaves(root));
3376
+ const depthCount = maxTreeDepth(root);
3377
+ const resolvedWidth = width ?? Math.max(520, padding * 2 + leafCount * nodeWidth + Math.max(0, leafCount - 1) * siblingGap);
3378
+ const resolvedHeight = height ?? padding * 2 + (depthCount + 1) * nodeHeight + depthCount * levelGap;
3379
+ const levelStep = depthCount === 0 ? 0 : Math.max(nodeHeight + 18, (resolvedHeight - padding * 2 - nodeHeight) / depthCount);
3380
+ const usableWidth = Math.max(0, resolvedWidth - padding * 2 - nodeWidth);
3381
+ const leafStep = leafCount <= 1 ? 0 : usableWidth / (leafCount - 1);
3382
+ const positioned = [];
3383
+ const edges = [];
3384
+ let nextLeaf = 0;
3385
+ const placeWithEdges = (node, depth, path) => {
3386
+ const children = node.children ?? [];
3387
+ let centerIndex;
3388
+ const childPlacements = [];
3389
+ if (!children.length) {
3390
+ centerIndex = nextLeaf;
3391
+ nextLeaf += 1;
3392
+ } else {
3393
+ for (let index = 0; index < children.length; index += 1) {
3394
+ const child = children[index];
3395
+ childPlacements.push({
3396
+ node: child,
3397
+ index,
3398
+ center: placeWithEdges(child, depth + 1, `${path}-${index}`)
3399
+ });
3400
+ }
3401
+ centerIndex = childPlacements.reduce((sum, child) => sum + child.center, 0) / childPlacements.length;
3402
+ }
3403
+ const placed = {
3404
+ ...node,
3405
+ key: node.id ?? path,
3406
+ depth,
3407
+ cx: leafCount <= 1 ? resolvedWidth / 2 : padding + nodeWidth / 2 + centerIndex * leafStep,
3408
+ cy: padding + nodeHeight / 2 + depth * levelStep
3409
+ };
3410
+ positioned.push(placed);
3411
+ for (const childPlacement of childPlacements) {
3412
+ const childKey = childPlacement.node.id ?? `${path}-${childPlacement.index}`;
3413
+ const childNode = positioned.find((candidate) => candidate.key === childKey);
3414
+ if (childNode) edges.push({ key: `${placed.key}-${childNode.key}`, from: placed, to: childNode });
3415
+ }
3416
+ return centerIndex;
3417
+ };
3418
+ placeWithEdges(root, 0, "root");
3419
+ const header = (title != null || subtitle != null) && React.createElement(
3420
+ "div",
3421
+ {
3422
+ style: {
3423
+ display: "flex",
3424
+ flexDirection: "column",
3425
+ gap: subtitle != null ? 4 : 0,
3426
+ width: resolvedWidth,
3427
+ maxWidth: "100%"
3428
+ }
3429
+ },
3430
+ ...compactChildren([
3431
+ title != null && React.createElement("div", {
3432
+ style: {
3433
+ display: "flex",
3434
+ alignItems: "center",
3435
+ gap: 8,
3436
+ color: c.textPrimary,
3437
+ fontFamily: "Inter",
3438
+ fontSize: 16,
3439
+ fontWeight: 900,
3440
+ lineHeight: 1.2
3441
+ }
3442
+ }, ToneStrip({ tone: root.tone ?? "blue" }), renderMaybeMath(title, math)),
3443
+ subtitle != null && React.createElement("div", {
3444
+ style: {
3445
+ display: "flex",
3446
+ color: c.textSecondary,
3447
+ fontFamily: "Inter",
3448
+ fontSize: 11,
3449
+ fontWeight: 500,
3450
+ lineHeight: 1.35
3451
+ }
3452
+ }, renderMaybeMath(subtitle, math))
3453
+ ])
3454
+ );
3455
+ return React.createElement(
3456
+ "div",
3457
+ {
3458
+ style: {
3459
+ display: "flex",
3460
+ flexDirection: "column",
3461
+ gap: header ? 10 : 0,
3462
+ width: resolvedWidth,
3463
+ maxWidth: "100%"
3464
+ }
3465
+ },
3466
+ ...compactChildren([
3467
+ header,
3468
+ React.createElement(
3469
+ "div",
3470
+ {
3471
+ role: "img",
3472
+ style: {
3473
+ position: "relative",
3474
+ display: "flex",
3475
+ width: resolvedWidth,
3476
+ height: resolvedHeight,
3477
+ maxWidth: "100%",
3478
+ flexShrink: 0
3479
+ }
3480
+ },
3481
+ React.createElement("svg", {
3482
+ width: resolvedWidth,
3483
+ height: resolvedHeight,
3484
+ viewBox: `0 0 ${resolvedWidth} ${resolvedHeight}`,
3485
+ style: { position: "absolute", inset: 0, overflow: "visible" }
3486
+ }, ...edges.map((edge) => {
3487
+ const tone = edge.to.muted ? "neutral" : edge.to.tone ?? edge.from.tone ?? "blue";
3488
+ const color = edge.to.muted ? c.textMuted : getToneColor(tone, c);
3489
+ const startY = edge.from.cy + nodeHeight / 2;
3490
+ const endY = edge.to.cy - nodeHeight / 2;
3491
+ const midY = startY + (endY - startY) / 2;
3492
+ return React.createElement("path", {
3493
+ key: `tree-edge-${edge.key}`,
3494
+ d: `M ${edge.from.cx} ${startY} C ${edge.from.cx} ${midY}, ${edge.to.cx} ${midY}, ${edge.to.cx} ${endY}`,
3495
+ fill: "none",
3496
+ stroke: color,
3497
+ strokeWidth: edge.to.muted ? 1.4 : 2.4,
3498
+ strokeLinecap: "round",
3499
+ opacity: edge.to.muted ? 0.4 : 0.74
3500
+ });
3501
+ })),
3502
+ ...positioned.map((node) => {
3503
+ const accent = node.muted ? c.textMuted : getToneColor(node.tone ?? "blue", c);
3504
+ return React.createElement(
3505
+ "div",
3506
+ {
3507
+ key: `tree-node-${node.key}`,
3508
+ style: {
3509
+ position: "absolute",
3510
+ left: node.cx - nodeWidth / 2,
3511
+ top: node.cy - nodeHeight / 2,
3512
+ width: nodeWidth,
3513
+ height: nodeHeight,
3514
+ display: "flex",
3515
+ flexDirection: "column",
3516
+ alignItems: "center",
3517
+ justifyContent: "center",
3518
+ gap: node.detail ? 4 : 0,
3519
+ padding: "8px 10px",
3520
+ boxSizing: "border-box",
3521
+ borderRadius: 8,
3522
+ backgroundColor: node.muted ? c.bgSubtle : c.bgCard,
3523
+ border: `1.5px solid ${node.muted ? c.borderLight : `${accent}88`}`,
3524
+ ...!node.muted ? { boxShadow: `0 8px 18px ${c.shadow}` } : {},
3525
+ opacity: node.muted ? 0.62 : 1,
3526
+ color: accent,
3527
+ textAlign: "center"
3528
+ }
3529
+ },
3530
+ React.createElement("div", {
3531
+ style: {
3532
+ color: accent,
3533
+ fontFamily: "Inter",
3534
+ fontSize: 13,
3535
+ fontWeight: 900,
3536
+ lineHeight: 1.15,
3537
+ ...textFitStyle("center")
3538
+ }
3539
+ }, renderMaybeMath(node.label, math)),
3540
+ node.detail != null && React.createElement("div", {
3541
+ style: {
3542
+ color: c.textMuted,
3543
+ fontFamily: "JetBrains Mono",
3544
+ fontSize: 9,
3545
+ fontWeight: 650,
3546
+ lineHeight: 1.2,
3547
+ ...textFitStyle("center")
3548
+ }
3549
+ }, renderMaybeMath(node.detail, math))
3550
+ );
3551
+ })
3552
+ )
3553
+ ])
3554
+ );
3555
+ }
2974
3556
  function CalloutCard({
2975
3557
  c,
2976
3558
  children,
@@ -3920,6 +4502,200 @@ function ChartFrame({
3920
4502
  )
3921
4503
  );
3922
4504
  }
4505
+ function polarPoint(cx, cy, radius, angleDegrees) {
4506
+ const radians = angleDegrees * Math.PI / 180;
4507
+ return {
4508
+ x: cx + radius * Math.cos(radians),
4509
+ y: cy + radius * Math.sin(radians)
4510
+ };
4511
+ }
4512
+ function donutArcPath(cx, cy, outerRadius, innerRadius, startAngle, endAngle) {
4513
+ const span = Math.min(359.99, Math.max(0.01, endAngle - startAngle));
4514
+ const safeEnd = startAngle + span;
4515
+ const outerStart = polarPoint(cx, cy, outerRadius, startAngle);
4516
+ const outerEnd = polarPoint(cx, cy, outerRadius, safeEnd);
4517
+ const innerEnd = polarPoint(cx, cy, innerRadius, safeEnd);
4518
+ const innerStart = polarPoint(cx, cy, innerRadius, startAngle);
4519
+ const largeArc = span > 180 ? 1 : 0;
4520
+ return [
4521
+ `M ${outerStart.x} ${outerStart.y}`,
4522
+ `A ${outerRadius} ${outerRadius} 0 ${largeArc} 1 ${outerEnd.x} ${outerEnd.y}`,
4523
+ `L ${innerEnd.x} ${innerEnd.y}`,
4524
+ `A ${innerRadius} ${innerRadius} 0 ${largeArc} 0 ${innerStart.x} ${innerStart.y}`,
4525
+ "Z"
4526
+ ].join(" ");
4527
+ }
4528
+ function DonutChart({
4529
+ segments,
4530
+ c,
4531
+ title,
4532
+ subtitle,
4533
+ width = 360,
4534
+ height = 230,
4535
+ size,
4536
+ thickness,
4537
+ format = "decimal",
4538
+ centerLabel,
4539
+ centerValue,
4540
+ showLegend = true,
4541
+ footer
4542
+ }) {
4543
+ const positiveSegments = segments.filter((segment) => segment.value > 0);
4544
+ const total = positiveSegments.reduce((sum, segment) => sum + segment.value, 0);
4545
+ const resolvedSize = size ?? Math.min(162, Math.max(128, height - 44), Math.max(128, width * 0.48));
4546
+ const resolvedThickness = thickness ?? Math.max(20, Math.round(resolvedSize * 0.18));
4547
+ const outerRadius = resolvedSize / 2 - 2;
4548
+ const innerRadius = Math.max(18, outerRadius - resolvedThickness);
4549
+ const cx = resolvedSize / 2;
4550
+ const cy = resolvedSize / 2;
4551
+ let cursor = -90;
4552
+ const resolvedCenterValue = centerValue ?? (centerLabel != null ? formatChartValue(total, format) : void 0);
4553
+ const paths = positiveSegments.map((segment, index) => {
4554
+ const rawSpan = total > 0 ? segment.value / total * 360 : 0;
4555
+ const gap = positiveSegments.length > 1 ? Math.min(1.5, rawSpan * 0.28) : 0;
4556
+ const start = cursor + gap / 2;
4557
+ const end = cursor + rawSpan - gap / 2;
4558
+ cursor += rawSpan;
4559
+ if (end <= start) return null;
4560
+ return React.createElement("path", {
4561
+ key: `donut-segment-${segment.label}-${index}`,
4562
+ d: donutArcPath(cx, cy, outerRadius, innerRadius, start, end),
4563
+ fill: chartColor(segment.color, c, index)
4564
+ });
4565
+ }).filter(Boolean);
4566
+ const legend = showLegend && positiveSegments.length > 0 && React.createElement("div", {
4567
+ style: {
4568
+ display: "flex",
4569
+ flexDirection: "column",
4570
+ gap: 8,
4571
+ flex: 1,
4572
+ minWidth: 112
4573
+ }
4574
+ }, ...positiveSegments.map((segment, index) => React.createElement(
4575
+ "div",
4576
+ {
4577
+ key: `donut-legend-${segment.label}-${index}`,
4578
+ style: {
4579
+ display: "flex",
4580
+ alignItems: "center",
4581
+ gap: 8,
4582
+ minWidth: 0
4583
+ }
4584
+ },
4585
+ React.createElement("span", {
4586
+ style: {
4587
+ display: "flex",
4588
+ width: 10,
4589
+ height: 10,
4590
+ borderRadius: 3,
4591
+ backgroundColor: chartColor(segment.color, c, index),
4592
+ flexShrink: 0
4593
+ }
4594
+ }),
4595
+ React.createElement("span", {
4596
+ style: {
4597
+ ...typography.tiny,
4598
+ ...textFitStyle(),
4599
+ color: c.textSecondary,
4600
+ flex: 1
4601
+ }
4602
+ }, segment.label),
4603
+ React.createElement("span", {
4604
+ style: {
4605
+ ...typography.tiny,
4606
+ color: c.textPrimary,
4607
+ fontFamily: "JetBrains Mono",
4608
+ fontWeight: 850,
4609
+ flexShrink: 0
4610
+ }
4611
+ }, segment.valueLabel ?? formatChartValue(segment.value, format))
4612
+ )));
4613
+ return ChartFrame({
4614
+ c,
4615
+ title,
4616
+ subtitle,
4617
+ footer,
4618
+ width,
4619
+ height,
4620
+ padding: 16,
4621
+ children: React.createElement(
4622
+ "div",
4623
+ {
4624
+ style: {
4625
+ display: "flex",
4626
+ alignItems: "center",
4627
+ justifyContent: showLegend ? "space-between" : "center",
4628
+ gap: 18,
4629
+ minHeight: resolvedSize,
4630
+ width: "100%"
4631
+ }
4632
+ },
4633
+ React.createElement(
4634
+ "div",
4635
+ {
4636
+ style: {
4637
+ position: "relative",
4638
+ display: "flex",
4639
+ width: resolvedSize,
4640
+ height: resolvedSize,
4641
+ flexShrink: 0
4642
+ }
4643
+ },
4644
+ React.createElement(
4645
+ "svg",
4646
+ {
4647
+ width: resolvedSize,
4648
+ height: resolvedSize,
4649
+ viewBox: `0 0 ${resolvedSize} ${resolvedSize}`
4650
+ },
4651
+ positiveSegments.length === 0 ? React.createElement("circle", {
4652
+ cx,
4653
+ cy,
4654
+ r: (outerRadius + innerRadius) / 2,
4655
+ fill: "none",
4656
+ stroke: c.borderLight,
4657
+ strokeWidth: resolvedThickness
4658
+ }) : paths
4659
+ ),
4660
+ (centerLabel != null || resolvedCenterValue != null) && React.createElement(
4661
+ "div",
4662
+ {
4663
+ style: {
4664
+ position: "absolute",
4665
+ inset: resolvedThickness,
4666
+ display: "flex",
4667
+ flexDirection: "column",
4668
+ alignItems: "center",
4669
+ justifyContent: "center",
4670
+ gap: 3,
4671
+ textAlign: "center"
4672
+ }
4673
+ },
4674
+ resolvedCenterValue != null && React.createElement("div", {
4675
+ style: {
4676
+ ...typography.small,
4677
+ color: c.textPrimary,
4678
+ fontFamily: "JetBrains Mono",
4679
+ fontSize: 18,
4680
+ fontWeight: 900,
4681
+ lineHeight: 1.05,
4682
+ ...textFitStyle("center")
4683
+ }
4684
+ }, resolvedCenterValue),
4685
+ centerLabel != null && React.createElement("div", {
4686
+ style: {
4687
+ ...typography.tiny,
4688
+ color: c.textMuted,
4689
+ lineHeight: 1.2,
4690
+ ...textFitStyle("center")
4691
+ }
4692
+ }, centerLabel)
4693
+ )
4694
+ ),
4695
+ legend
4696
+ )
4697
+ });
4698
+ }
3923
4699
  function StackedBar({
3924
4700
  segments,
3925
4701
  c,