@opendata-ai/openchart-core 9.0.0 → 9.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.js CHANGED
@@ -152,7 +152,8 @@ var MARK_ENCODING_RULES = {
152
152
  opacity: optional("quantitative"),
153
153
  tooltip: optional(),
154
154
  description: optional(),
155
- detail: optional("nominal")
155
+ detail: optional("nominal"),
156
+ time: optional("temporal", "ordinal", "quantitative")
156
157
  },
157
158
  line: {
158
159
  x: required("temporal", "ordinal"),
@@ -186,7 +187,8 @@ var MARK_ENCODING_RULES = {
186
187
  opacity: optional("quantitative"),
187
188
  tooltip: optional(),
188
189
  description: optional(),
189
- detail: optional("nominal")
190
+ detail: optional("nominal"),
191
+ time: optional("temporal", "ordinal", "quantitative")
190
192
  },
191
193
  circle: {
192
194
  x: required("quantitative"),
@@ -196,7 +198,8 @@ var MARK_ENCODING_RULES = {
196
198
  opacity: optional("quantitative"),
197
199
  tooltip: optional(),
198
200
  description: optional(),
199
- detail: optional("nominal")
201
+ detail: optional("nominal"),
202
+ time: optional("temporal", "ordinal", "quantitative")
200
203
  },
201
204
  lollipop: {
202
205
  x: required("quantitative"),
@@ -443,7 +446,7 @@ function resolveMarkDef(mark) {
443
446
  return typeof mark === "string" ? { type: mark } : mark;
444
447
  }
445
448
  function isChartSpec(spec) {
446
- return "mark" in spec && !("layer" in spec);
449
+ return "mark" in spec && !("layer" in spec) && spec.type !== "race";
447
450
  }
448
451
  function isLayerSpec(spec) {
449
452
  return "layer" in spec && Array.isArray(spec.layer);
@@ -463,6 +466,9 @@ function isTileMapSpec(spec) {
463
466
  function isBarListSpec(spec) {
464
467
  return "type" in spec && spec.type === "barlist";
465
468
  }
469
+ function isRaceSpec(spec) {
470
+ return typeof spec === "object" && spec !== null && !Array.isArray(spec) && "type" in spec && spec.type === "race";
471
+ }
466
472
  function isGeoMapSpec(spec) {
467
473
  return "type" in spec && spec.type === "map";
468
474
  }
@@ -624,6 +630,283 @@ function findAccessibleColor(baseColor, bg, targetRatio = 4.5) {
624
630
  return baseColor;
625
631
  }
626
632
 
633
+ // src/motion/curves.ts
634
+ var SNAP = [
635
+ { t: 0, value: 0 },
636
+ { t: 0.02, value: 0.1876 },
637
+ { t: 0.04, value: 0.3469 },
638
+ { t: 0.06, value: 0.4773 },
639
+ { t: 0.08, value: 0.582 },
640
+ { t: 0.1, value: 0.6656 },
641
+ { t: 0.12, value: 0.7325 },
642
+ { t: 0.14, value: 0.7862 },
643
+ { t: 0.16, value: 0.8296 },
644
+ { t: 0.18, value: 0.8647 },
645
+ { t: 0.2, value: 0.8931 },
646
+ { t: 0.22, value: 0.9161 },
647
+ { t: 0.24, value: 0.9346 },
648
+ { t: 0.26, value: 0.9494 },
649
+ { t: 0.28, value: 0.961 },
650
+ { t: 0.3, value: 0.97 },
651
+ { t: 0.35, value: 0.9768 },
652
+ { t: 0.4, value: 0.9825 },
653
+ { t: 0.45, value: 0.987 },
654
+ { t: 0.5, value: 0.9906 },
655
+ { t: 0.55, value: 0.9934 },
656
+ { t: 0.6, value: 0.9956 },
657
+ { t: 0.65, value: 0.9971 },
658
+ { t: 0.7, value: 0.9983 },
659
+ { t: 0.75, value: 0.999 },
660
+ { t: 0.8, value: 0.9995 },
661
+ { t: 0.85, value: 0.9998 },
662
+ { t: 0.9, value: 0.9999 },
663
+ { t: 0.95, value: 1 },
664
+ { t: 1, value: 1 }
665
+ ];
666
+ var GLIDE = [
667
+ { t: 0, value: 0 },
668
+ { t: 0.025, value: 6e-3 },
669
+ { t: 0.05, value: 0.0285 },
670
+ { t: 0.075, value: 0.0764 },
671
+ { t: 0.1, value: 0.1562 },
672
+ { t: 0.125, value: 0.2556 },
673
+ { t: 0.15, value: 0.3506 },
674
+ { t: 0.175, value: 0.4318 },
675
+ { t: 0.2, value: 0.5 },
676
+ { t: 0.225, value: 0.5577 },
677
+ { t: 0.25, value: 0.6072 },
678
+ { t: 0.275, value: 0.6503 },
679
+ { t: 0.3, value: 0.6881 },
680
+ { t: 0.325, value: 0.7216 },
681
+ { t: 0.35, value: 0.7514 },
682
+ { t: 0.375, value: 0.7782 },
683
+ { t: 0.4, value: 0.8023 },
684
+ { t: 0.425, value: 0.824 },
685
+ { t: 0.45, value: 0.8438 },
686
+ { t: 0.475, value: 0.8616 },
687
+ { t: 0.5, value: 0.8778 },
688
+ { t: 0.55, value: 0.9059 },
689
+ { t: 0.6, value: 0.9291 },
690
+ { t: 0.65, value: 0.948 },
691
+ { t: 0.7, value: 0.9633 },
692
+ { t: 0.75, value: 0.9755 },
693
+ { t: 0.8, value: 0.9849 },
694
+ { t: 0.85, value: 0.9918 },
695
+ { t: 0.9, value: 0.9965 },
696
+ { t: 0.95, value: 0.9991 },
697
+ { t: 1, value: 1 }
698
+ ];
699
+ var CURVE_INPUTS = {
700
+ /** Decks snap: a fast attack for quick fades and short accents. */
701
+ snap: SNAP,
702
+ /** Soft ease-out with a gentle start. The sampled source of the default `smooth`. */
703
+ glide: GLIDE,
704
+ /** The default ease: an alias of `glide`, so the default improves with no spec change. */
705
+ smooth: GLIDE,
706
+ /** Today's old `smooth` (a gentle ease-out), kept under its own name. */
707
+ gentle: [0, 0.157, 0.438, 0.64, 0.766, 0.85, 0.906, 0.941, 0.964, 0.978, 0.988, 0.994, 0.998, 1],
708
+ /**
709
+ * Monotone, non-overshooting ease-out, faster than `snap`. Sampled from
710
+ * `M0,0 C0.04,0.75 0.12,0.97 0.3,0.995 C0.4,1 0.5,1 0.6,1` then held at 1: it is
711
+ * ~0.78 at t=0.1 (snap: ~0.67), 0.951 at 0.2, reaches 0.999 by t~0.45 and
712
+ * is exactly 1 from t=0.55, so it settles sooner than `snap` or `smooth`.
713
+ */
714
+ snappy: [
715
+ { t: 0, value: 0 },
716
+ { t: 0.02, value: 0.2926 },
717
+ { t: 0.04, value: 0.4806 },
718
+ { t: 0.06, value: 0.6111 },
719
+ { t: 0.08, value: 0.7061 },
720
+ { t: 0.1, value: 0.7772 },
721
+ { t: 0.12, value: 0.8315 },
722
+ { t: 0.14, value: 0.8735 },
723
+ { t: 0.16, value: 0.9061 },
724
+ { t: 0.18, value: 0.9314 },
725
+ { t: 0.2, value: 0.951 },
726
+ { t: 0.22, value: 0.966 },
727
+ { t: 0.24, value: 0.9773 },
728
+ { t: 0.26, value: 0.9855 },
729
+ { t: 0.28, value: 0.9913 },
730
+ { t: 0.3, value: 0.995 },
731
+ { t: 0.35, value: 0.9971 },
732
+ { t: 0.4, value: 0.9985 },
733
+ { t: 0.45, value: 0.9994 },
734
+ { t: 0.5, value: 0.9998 },
735
+ { t: 0.55, value: 1 },
736
+ { t: 0.6, value: 1 },
737
+ { t: 0.8, value: 1 },
738
+ { t: 1, value: 1 }
739
+ ],
740
+ /**
741
+ * Accent only (annotation markers and the like): Decks
742
+ * `M0,0 C0.1,0.7 0.18,1.13 0.4,1.06 C0.58,0.99 0.8,1 1,1` overshoots to ~1.067
743
+ * near t=0.35 and settles by ~0.8. NOT monotone, so it is never an authored
744
+ * ease and never used for value-encoding geometry (use evalValueCurve there).
745
+ */
746
+ punch: [
747
+ { t: 0, value: 0 },
748
+ { t: 0.025, value: 0.1714 },
749
+ { t: 0.05, value: 0.3321 },
750
+ { t: 0.075, value: 0.4776 },
751
+ { t: 0.1, value: 0.605 },
752
+ { t: 0.125, value: 0.7132 },
753
+ { t: 0.15, value: 0.8029 },
754
+ { t: 0.175, value: 0.8757 },
755
+ { t: 0.2, value: 0.9336 },
756
+ { t: 0.225, value: 0.9787 },
757
+ { t: 0.25, value: 1.0127 },
758
+ { t: 0.275, value: 1.0373 },
759
+ { t: 0.3, value: 1.0539 },
760
+ { t: 0.325, value: 1.0636 },
761
+ { t: 0.35, value: 1.0673 },
762
+ { t: 0.375, value: 1.0659 },
763
+ { t: 0.4, value: 1.06 },
764
+ { t: 0.425, value: 1.0509 },
765
+ { t: 0.45, value: 1.0428 },
766
+ { t: 0.475, value: 1.0358 },
767
+ { t: 0.5, value: 1.0296 },
768
+ { t: 0.55, value: 1.0196 },
769
+ { t: 0.6, value: 1.0122 },
770
+ { t: 0.65, value: 1.0069 },
771
+ { t: 0.7, value: 1.0033 },
772
+ { t: 0.75, value: 1.0011 },
773
+ { t: 0.8, value: 0.9999 },
774
+ { t: 0.85, value: 0.9995 },
775
+ { t: 0.9, value: 0.9996 },
776
+ { t: 0.95, value: 0.9998 },
777
+ { t: 1, value: 1 }
778
+ ]
779
+ };
780
+ function buildCurve(name, input) {
781
+ if (input.length < 2) throw new Error(`Curve "${name}" needs at least two stops`);
782
+ const evenlySpaced = typeof input[0] === "number";
783
+ const stops = evenlySpaced ? input.map((value, i, all) => ({ t: i / (all.length - 1), value })) : input.map((s) => ({ t: s.t, value: s.value }));
784
+ if (stops[0].t !== 0 || stops[stops.length - 1].t !== 1) {
785
+ throw new Error(`Curve "${name}" must start at t=0 and end at t=1`);
786
+ }
787
+ for (let i = 1; i < stops.length; i++) {
788
+ if (!(stops[i].t > stops[i - 1].t)) {
789
+ throw new Error(`Curve "${name}" stops must have strictly increasing t`);
790
+ }
791
+ }
792
+ let monotone = stops[0].value === 0 && stops[stops.length - 1].value === 1;
793
+ const envelope = [];
794
+ let runningMax = 0;
795
+ for (let i = 0; i < stops.length; i++) {
796
+ if (i > 0 && stops[i].value < stops[i - 1].value) monotone = false;
797
+ runningMax = Math.max(runningMax, clamp01(stops[i].value));
798
+ envelope.push(runningMax);
799
+ }
800
+ return { stops, evenlySpaced, monotone, envelope };
801
+ }
802
+ var CURVES = Object.fromEntries(
803
+ Object.entries(CURVE_INPUTS).map(([name, input]) => [name, buildCurve(name, input)])
804
+ );
805
+ var CURVE_NAMES = Object.keys(CURVE_INPUTS);
806
+ function clamp01(v) {
807
+ return v < 0 ? 0 : v > 1 ? 1 : v;
808
+ }
809
+ function getCurve(name) {
810
+ const curve = CURVES[name];
811
+ if (!curve) throw new Error(`Unknown curve "${name}"`);
812
+ return curve;
813
+ }
814
+ function segmentIndex(stops, t) {
815
+ let lo = 0;
816
+ let hi = stops.length - 1;
817
+ while (hi - lo > 1) {
818
+ const mid = lo + hi >> 1;
819
+ if (stops[mid].t <= t) lo = mid;
820
+ else hi = mid;
821
+ }
822
+ return lo;
823
+ }
824
+ function curveStops(name) {
825
+ return getCurve(name).stops;
826
+ }
827
+ function isMonotoneCurve(name) {
828
+ return getCurve(name).monotone;
829
+ }
830
+ function evalCurve(name, t) {
831
+ const { stops } = getCurve(name);
832
+ const x = Number.isNaN(t) ? 0 : clamp01(t);
833
+ const i = segmentIndex(stops, x);
834
+ const a = stops[i];
835
+ const b = stops[Math.min(i + 1, stops.length - 1)];
836
+ if (b.t === a.t) return a.value;
837
+ return a.value + (b.value - a.value) * (x - a.t) / (b.t - a.t);
838
+ }
839
+ function evalValueCurve(name, t) {
840
+ const curve = getCurve(name);
841
+ const x = Number.isNaN(t) ? 0 : clamp01(t);
842
+ const i = segmentIndex(curve.stops, x);
843
+ return Math.max(curve.envelope[i], clamp01(evalCurve(name, x)));
844
+ }
845
+ function invertCurve(name, p) {
846
+ const curve = getCurve(name);
847
+ if (!curve.monotone) throw new Error(`Curve "${name}" is not monotone and cannot be inverted`);
848
+ const { stops } = curve;
849
+ const target = clamp01(p);
850
+ if (target <= stops[0].value) return 0;
851
+ for (let i = 1; i < stops.length; i++) {
852
+ const b = stops[i];
853
+ if (b.value >= target) {
854
+ const a = stops[i - 1];
855
+ if (b.value === a.value) return a.t;
856
+ return a.t + (target - a.value) * (b.t - a.t) / (b.value - a.value);
857
+ }
858
+ }
859
+ return 1;
860
+ }
861
+ function formatPercent(t) {
862
+ return `${Number((t * 100).toFixed(4))}%`;
863
+ }
864
+ function curveToCSSLinear(name, options) {
865
+ const curve = getCurve(name);
866
+ const items = curve.stops.map(
867
+ (s) => curve.evenlySpaced ? String(s.value) : `${s.value} ${formatPercent(s.t)}`
868
+ );
869
+ const indent = options?.indent;
870
+ if (indent === void 0) return `linear(${items.join(", ")})`;
871
+ const inner = `${indent} `;
872
+ return `linear(
873
+ ${inner}${items.join(`,
874
+ ${inner}`)}
875
+ ${indent})`;
876
+ }
877
+ function evalCubicBezier(bezier, t) {
878
+ const [x1, y1, x2, y2] = bezier;
879
+ const x = t < 0 ? 0 : t > 1 ? 1 : t;
880
+ if (x1 === y1 && x2 === y2) return x;
881
+ const cx = 3 * x1;
882
+ const bx = 3 * (x2 - x1) - cx;
883
+ const ax = 1 - cx - bx;
884
+ const cy = 3 * y1;
885
+ const by = 3 * (y2 - y1) - cy;
886
+ const ay = 1 - cy - by;
887
+ const sampleX = (s2) => ((ax * s2 + bx) * s2 + cx) * s2;
888
+ const slopeX = (s2) => (3 * ax * s2 + 2 * bx) * s2 + cx;
889
+ let s = x;
890
+ for (let i = 0; i < 8; i++) {
891
+ const err = sampleX(s) - x;
892
+ if (Math.abs(err) < 1e-7) return ((ay * s + by) * s + cy) * s;
893
+ const d = slopeX(s);
894
+ if (Math.abs(d) < 1e-6) break;
895
+ s -= err / d;
896
+ }
897
+ let lo = 0;
898
+ let hi = 1;
899
+ s = x;
900
+ for (let i = 0; i < 40; i++) {
901
+ const v = sampleX(s);
902
+ if (Math.abs(v - x) < 1e-7) break;
903
+ if (v < x) lo = s;
904
+ else hi = s;
905
+ s = (lo + hi) / 2;
906
+ }
907
+ return ((ay * s + by) * s + cy) * s;
908
+ }
909
+
627
910
  // src/styles/token-definitions.ts
628
911
  var CSS_TOKEN_ROOT_SELECTORS = [
629
912
  ".oc-root",
@@ -649,15 +932,35 @@ var CSS_TOKENS = [
649
932
  {
650
933
  section: "Animation easing presets via CSS linear()",
651
934
  name: "--oc-ease-smooth",
652
- light: "linear(\n 0,\n 0.157,\n 0.438,\n 0.64,\n 0.766,\n 0.85,\n 0.906,\n 0.941,\n 0.964,\n 0.978,\n 0.988,\n 0.994,\n 0.998,\n 1\n )"
935
+ light: curveToCSSLinear("smooth", { indent: " " })
653
936
  },
654
937
  {
655
938
  name: "--oc-ease-snappy",
656
- light: "linear(\n 0,\n 0.012,\n 0.048,\n 0.108,\n 0.194,\n 0.302,\n 0.426,\n 0.559,\n 0.69,\n 0.808,\n 0.905,\n 0.973,\n 1.013,\n 1.028,\n 1.023,\n 1.006,\n 0.984,\n 0.966,\n 0.957,\n 0.957,\n 0.964,\n 0.975,\n 0.986,\n 0.995,\n 1,\n 1.003,\n 1.002,\n 1,\n 0.998,\n 0.998,\n 0.999,\n 1\n )",
939
+ light: curveToCSSLinear("snappy", { indent: " " }),
940
+ consumers: "EASE_VAR_MAP in vanilla renderers"
941
+ },
942
+ {
943
+ name: "--oc-ease-gentle",
944
+ light: curveToCSSLinear("gentle", { indent: " " }),
657
945
  consumers: "EASE_VAR_MAP in vanilla renderers"
658
946
  },
659
- { section: "Animation timing defaults", name: "--oc-animation-duration", light: "450ms" },
660
- { name: "--oc-animation-stagger", light: "30ms" },
947
+ {
948
+ name: "--oc-ease-snap",
949
+ light: curveToCSSLinear("snap", { indent: " " }),
950
+ consumers: "FADE_CURVE and curve-timed roles in the generated animation CSS"
951
+ },
952
+ {
953
+ name: "--oc-ease-punch",
954
+ light: curveToCSSLinear("punch", { indent: " " }),
955
+ consumers: "Curve-timed accent roles in the generated animation CSS"
956
+ },
957
+ {
958
+ name: "--oc-ease-glide",
959
+ light: curveToCSSLinear("glide", { indent: " " }),
960
+ consumers: "Curve-timed roles in the generated animation CSS"
961
+ },
962
+ { section: "Animation timing defaults", name: "--oc-animation-duration", light: "800ms" },
963
+ { name: "--oc-animation-stagger", light: "80ms" },
661
964
  { name: "--oc-annotation-delay", light: "150ms" },
662
965
  { section: "Typography scale (editorial design system)", name: "--oc-title-size", light: "26px" },
663
966
  {
@@ -1394,11 +1697,11 @@ var RESOLVED_TABLE_700_DEFAULT = {
1394
1697
  scale: 1
1395
1698
  };
1396
1699
  var RESOLVED_TABLE_CACHE = /* @__PURE__ */ new Map();
1397
- for (const [weightStr, scale] of Object.entries(WEIGHT_ADJUSTMENT)) {
1700
+ for (const [weightStr, scale2] of Object.entries(WEIGHT_ADJUSTMENT)) {
1398
1701
  const weight = Number(weightStr);
1399
1702
  RESOLVED_TABLE_CACHE.set(
1400
1703
  weight,
1401
- weight >= 650 ? { table: CHAR_WIDTHS_700, avg: AVG_CHAR_WIDTH_700, scale } : { table: CHAR_WIDTHS_400, avg: AVG_CHAR_WIDTH_400, scale }
1704
+ weight >= 650 ? { table: CHAR_WIDTHS_700, avg: AVG_CHAR_WIDTH_700, scale: scale2 } : { table: CHAR_WIDTHS_400, avg: AVG_CHAR_WIDTH_400, scale: scale2 }
1402
1705
  );
1403
1706
  }
1404
1707
  function resolveTable(fontWeight) {
@@ -1416,27 +1719,27 @@ function charWidthRatio(ch, table, avg) {
1416
1719
  return avg;
1417
1720
  }
1418
1721
  function estimateCharWidth(fontSize, fontWeight = 400) {
1419
- const { avg, scale } = resolveTable(fontWeight);
1420
- return fontSize * avg * scale;
1722
+ const { avg, scale: scale2 } = resolveTable(fontWeight);
1723
+ return fontSize * avg * scale2;
1421
1724
  }
1422
- function measureLine(line, table, avg, scale, fontSize) {
1725
+ function measureLine(line, table, avg, scale2, fontSize) {
1423
1726
  let sum = 0;
1424
1727
  for (const ch of line) {
1425
1728
  sum += charWidthRatio(ch, table, avg);
1426
1729
  }
1427
- return sum * fontSize * scale;
1730
+ return sum * fontSize * scale2;
1428
1731
  }
1429
1732
  function estimateTextWidth(text, fontSize, fontWeight = 400) {
1430
- const { table, avg, scale } = resolveTable(fontWeight);
1733
+ const { table, avg, scale: scale2 } = resolveTable(fontWeight);
1431
1734
  if (text.includes("\n")) {
1432
1735
  let maxWidth = 0;
1433
1736
  for (const line of text.split("\n")) {
1434
- const w = measureLine(line, table, avg, scale, fontSize);
1737
+ const w = measureLine(line, table, avg, scale2, fontSize);
1435
1738
  if (w > maxWidth) maxWidth = w;
1436
1739
  }
1437
1740
  return maxWidth;
1438
1741
  }
1439
- return measureLine(text, table, avg, scale, fontSize);
1742
+ return measureLine(text, table, avg, scale2, fontSize);
1440
1743
  }
1441
1744
  var BRAND_RESERVE_WIDTH = 130;
1442
1745
  var BRAND_FONT_SIZE = 12;
@@ -1522,8 +1825,8 @@ function applyHeightConstraints(strategy, heightClass) {
1522
1825
  };
1523
1826
  }
1524
1827
  function getLayoutStrategy(breakpoint, heightClass = "normal") {
1525
- const base = getWidthStrategy(breakpoint);
1526
- return applyHeightConstraints(base, heightClass);
1828
+ const base2 = getWidthStrategy(breakpoint);
1829
+ return applyHeightConstraints(base2, heightClass);
1527
1830
  }
1528
1831
  var HEIGHT_NO_GRID_MAX = 150;
1529
1832
  var COMPACT_MAX_X_TICKS = 3;
@@ -1602,18 +1905,19 @@ function truncateToWidth(label, budget, fontSize, fontWeight, measure = estimate
1602
1905
  if (!Number.isFinite(budget)) return label;
1603
1906
  if (measure(label, fontSize, fontWeight) <= budget) return label;
1604
1907
  const ELLIPSIS = "\u2026";
1908
+ const characters = Array.from(label);
1605
1909
  let lo = 0;
1606
- let hi = label.length;
1910
+ let hi = characters.length;
1607
1911
  while (lo < hi) {
1608
1912
  const mid = Math.ceil((lo + hi) / 2);
1609
- const candidate = label.slice(0, mid) + ELLIPSIS;
1913
+ const candidate = characters.slice(0, mid).join("") + ELLIPSIS;
1610
1914
  if (measure(candidate, fontSize, fontWeight) <= budget) {
1611
1915
  lo = mid;
1612
1916
  } else {
1613
1917
  hi = mid - 1;
1614
1918
  }
1615
1919
  }
1616
- return lo > 0 ? label.slice(0, lo).trimEnd() + ELLIPSIS : ELLIPSIS;
1920
+ return characters.slice(0, lo).join("").trimEnd() + ELLIPSIS;
1617
1921
  }
1618
1922
  function truncateRotatedLabel(label, tickAngle, tickFontSize, tickFontWeight, measure = estimateTextWidth) {
1619
1923
  const budget = maxRotatedLabelWidth(tickAngle, tickFontSize);
@@ -1892,9 +2196,9 @@ function adaptForLightLineStroke(color) {
1892
2196
  function isRecord(value) {
1893
2197
  return value !== null && typeof value === "object" && !Array.isArray(value);
1894
2198
  }
1895
- function mergeThemeObjects(base, override) {
2199
+ function mergeThemeObjects(base2, override) {
1896
2200
  if (!isRecord(override) || "light" in override || "dark" in override) return override;
1897
- const result = isRecord(base) ? { ...base } : {};
2201
+ const result = isRecord(base2) ? { ...base2 } : {};
1898
2202
  for (const [key, value] of Object.entries(override)) {
1899
2203
  if (value !== void 0) result[key] = mergeThemeObjects(result[key], value);
1900
2204
  }
@@ -1903,9 +2207,9 @@ function mergeThemeObjects(base, override) {
1903
2207
  function normalize(config) {
1904
2208
  return Array.isArray(config.colors) ? { ...config, colors: { categorical: config.colors } } : config;
1905
2209
  }
1906
- function mergeThemeConfig(base, override) {
1907
- if (!override) return base;
1908
- return mergeThemeObjects(base ? normalize(base) : {}, normalize(override));
2210
+ function mergeThemeConfig(base2, override) {
2211
+ if (!override) return base2;
2212
+ return mergeThemeObjects(base2 ? normalize(base2) : {}, normalize(override));
1909
2213
  }
1910
2214
 
1911
2215
  // src/theme/presets.ts
@@ -1959,16 +2263,30 @@ var wire = {
1959
2263
  };
1960
2264
  var broadsheet = {
1961
2265
  colors: {
1962
- categorical: ["#1d5f8a", "#e3120b", "#7fb0d3", "#e0a63b", "#3a8a6e", "#8c8680"],
1963
- categoricalFill: ["#3b7097", "#ee493a", "#97c2e2", "#efbb64", "#579a81", "#9e9893"],
1964
- background: { light: "#fffdf9", dark: "#171513" },
1965
- text: { light: "#1a1714", dark: "#f4f1ea" },
1966
- gridline: { light: "rgba(26,23,20,0.08)", dark: "rgba(244,241,234,0.07)" },
2266
+ categorical: [
2267
+ { light: "#1d5f8a", dark: "#5e9fd6" },
2268
+ { light: "#e3120b", dark: "#f4655a" },
2269
+ { light: "#7fb0d3", dark: "#93c2e2" },
2270
+ { light: "#e0a63b", dark: "#e0b267" },
2271
+ { light: "#3a8a6e", dark: "#4fb093" },
2272
+ { light: "#8c8680", dark: "#9aa1a8" }
2273
+ ],
2274
+ categoricalFill: [
2275
+ { light: "#3b7097", dark: "#80b5e3" },
2276
+ { light: "#ee493a", dark: "#ec5b50" },
2277
+ { light: "#97c2e2", dark: "#acd3eb" },
2278
+ { light: "#efbb64", dark: "#c6ad55" },
2279
+ { light: "#579a81", dark: "#5bd2ac" },
2280
+ { light: "#9e9893", dark: "#b4b9bf" }
2281
+ ],
2282
+ background: { light: "#fffdf9", dark: "#12181f" },
2283
+ text: { light: "#1a1714", dark: "#e9ebe6" },
2284
+ gridline: { light: "rgba(26,23,20,0.08)", dark: "rgba(233,235,230,0.07)" },
1967
2285
  // Heavier than the default 0.14: newsprint rules are drawn to be seen.
1968
- hairline: { light: "rgba(26,23,20,0.28)", dark: "rgba(244,241,234,0.28)" },
1969
- axis: { light: "#6b645c", dark: "#a8a099" },
1970
- annotationFill: { light: "rgba(26,23,20,0.05)", dark: "rgba(244,241,234,0.07)" },
1971
- annotationText: { light: "#6b645c", dark: "#a8a099" }
2286
+ hairline: { light: "rgba(26,23,20,0.28)", dark: "rgba(233,235,230,0.28)" },
2287
+ axis: { light: "#6b645c", dark: "#9aa4ad" },
2288
+ annotationFill: { light: "rgba(26,23,20,0.05)", dark: "rgba(233,235,230,0.07)" },
2289
+ annotationText: { light: "#6b645c", dark: "#9aa4ad" }
1972
2290
  },
1973
2291
  fonts: {
1974
2292
  sizes: { title: 24, subtitle: 14, body: 13, small: 11 }
@@ -2040,7 +2358,7 @@ var legacyEditorial = {
2040
2358
  function resolveTokenLight(v) {
2041
2359
  return typeof v === "string" ? v : v.light;
2042
2360
  }
2043
- function themeConfigToPartial(config, base) {
2361
+ function themeConfigToPartial(config, base2) {
2044
2362
  const partial = {};
2045
2363
  if (config.colors) {
2046
2364
  const colors = {};
@@ -2143,10 +2461,10 @@ function themeConfigToPartial(config, base) {
2143
2461
  if (config.rule) {
2144
2462
  partial.rule = {
2145
2463
  color: resolveTokenLight(
2146
- config.rule.color ?? base.rule?.color ?? (config.colors && !Array.isArray(config.colors) ? config.colors.text : void 0) ?? DEFAULT_THEME.colors.text
2464
+ config.rule.color ?? base2.rule?.color ?? (config.colors && !Array.isArray(config.colors) ? config.colors.text : void 0) ?? DEFAULT_THEME.colors.text
2147
2465
  ),
2148
- width: config.rule.width ?? base.rule?.width ?? 40,
2149
- thickness: config.rule.thickness ?? base.rule?.thickness ?? 3
2466
+ width: config.rule.width ?? base2.rule?.width ?? 40,
2467
+ thickness: config.rule.thickness ?? base2.rule?.thickness ?? 3
2150
2468
  };
2151
2469
  }
2152
2470
  if (config.rule === null) partial.rule = null;
@@ -2259,8 +2577,8 @@ function adjustOpacity(hex, opacity) {
2259
2577
  const toHex = (n) => n.toString(16).padStart(2, "0");
2260
2578
  return `#${toHex(mix2(r))}${toHex(mix2(g))}${toHex(mix2(b))}`;
2261
2579
  }
2262
- function resolveTheme(userTheme, base = DEFAULT_THEME) {
2263
- let merged = userTheme ? mergeThemeObjects(base, themeConfigToPartial(userTheme, base)) : { ...base };
2580
+ function resolveTheme(userTheme, base2 = DEFAULT_THEME) {
2581
+ let merged = userTheme ? mergeThemeObjects(base2, themeConfigToPartial(userTheme, base2)) : { ...base2 };
2264
2582
  for (const [element, size] of Object.entries({
2265
2583
  title: "title",
2266
2584
  subtitle: "subtitle",
@@ -2938,7 +3256,7 @@ function buildD3Formatter(formatStr) {
2938
3256
  }
2939
3257
  return null;
2940
3258
  }
2941
- function formatPercent(value, options) {
3259
+ function formatPercent2(value, options) {
2942
3260
  const fraction = options?.fraction ?? true;
2943
3261
  const percent = fraction ? value * 100 : value;
2944
3262
  if (Number.isFinite(percent) && percent !== 0 && Math.abs(percent) < 0.1) {
@@ -3001,7 +3319,7 @@ function resolveNumberFormatter(formatStr, ctx) {
3001
3319
  }
3002
3320
  if (formatStr === "percent") {
3003
3321
  const fraction = ctx?.extent ? Math.max(Math.abs(ctx.extent[0]), Math.abs(ctx.extent[1])) <= 1 : true;
3004
- return (v) => formatPercent(v, { fraction });
3322
+ return (v) => formatPercent2(v, { fraction });
3005
3323
  }
3006
3324
  if (formatStr === "currency") {
3007
3325
  const isTable = ctx?.surface === "table";
@@ -3305,8 +3623,8 @@ function inferFieldType(data, field) {
3305
3623
  continue;
3306
3624
  }
3307
3625
  if (typeof value === "string") {
3308
- const num = Number(value);
3309
- if (!Number.isNaN(num) && Number.isFinite(num) && value.trim() !== "") {
3626
+ const num2 = Number(value);
3627
+ if (!Number.isNaN(num2) && Number.isFinite(num2) && value.trim() !== "") {
3310
3628
  numericCount++;
3311
3629
  continue;
3312
3630
  }
@@ -3547,23 +3865,953 @@ function springDuration(config) {
3547
3865
  }
3548
3866
  return MAX_SPRING_DURATION;
3549
3867
  }
3868
+ var VELOCITY_STEP = 1e-4;
3550
3869
  function sampleMotion(phase, elapsedMs) {
3551
3870
  if (phase.duration <= 0 || elapsedMs >= phase.duration) {
3552
3871
  return { position: 1, velocity: 0, settled: true };
3553
3872
  }
3554
3873
  if (elapsedMs <= 0) return { position: 0, velocity: 0, settled: false };
3555
3874
  if (phase.spring) return springState(elapsedMs, phase.spring);
3875
+ const ease = phase.ease ?? "smooth";
3556
3876
  const t = elapsedMs / phase.duration;
3557
- const power = phase.ease === "snappy" ? 5 : 3;
3877
+ const lo = Math.max(0, t - VELOCITY_STEP);
3878
+ const hi = Math.min(1, t + VELOCITY_STEP);
3879
+ const slope = (evalValueCurve(ease, hi) - evalValueCurve(ease, lo)) / (hi - lo);
3558
3880
  return {
3559
- position: 1 - (1 - t) ** power,
3560
- velocity: power * (1 - t) ** (power - 1) * 1e3 / phase.duration,
3881
+ position: evalValueCurve(ease, t),
3882
+ velocity: slope * 1e3 / phase.duration,
3561
3883
  settled: false
3562
3884
  };
3563
3885
  }
3564
3886
  function motionCSS(phase) {
3565
3887
  return `linear(${Array.from({ length: 101 }, (_, i) => sampleMotion(phase, i * phase.duration / 100).position.toFixed(6)).join(",")})`;
3566
3888
  }
3889
+
3890
+ // src/motion/stagger.ts
3891
+ var MAX_TOTAL_STAGGER_MS = 450;
3892
+ function clampStaggerDelay(delay, elementCount) {
3893
+ if (elementCount <= 1 || !(delay > 0)) return 0;
3894
+ return Math.min(delay, MAX_TOTAL_STAGGER_MS / (elementCount - 1));
3895
+ }
3896
+ var CELL_SWEEP_BUDGET_MS = 600;
3897
+ function shuffledSweepDelays(count, budgetMs, seed) {
3898
+ if (count <= 0) return [];
3899
+ if (count === 1) return [0];
3900
+ const last = count - 1;
3901
+ const delays = Array.from({ length: count }, (_, i) => i / last * budgetMs);
3902
+ let state = 2654435769 ^ seed * 2654435761;
3903
+ for (let i = last; i > 0; i--) {
3904
+ state = state + 1831565813 | 0;
3905
+ let t = state ^ state >>> 15;
3906
+ t = Math.imul(t, t | 1);
3907
+ t ^= t + Math.imul(t ^ t >>> 7, t | 61);
3908
+ const r = ((t ^ t >>> 14) >>> 0) % (i + 1);
3909
+ [delays[i], delays[r]] = [delays[r], delays[i]];
3910
+ }
3911
+ return delays;
3912
+ }
3913
+ var MAP_POINT_STAGGER_FALLBACK_MS = 60;
3914
+ var MAP_FEATURE_MAX_DURATION_MS = 500;
3915
+ var MAP_SWEEP_BUDGET_MS = 540;
3916
+ function mapFeatureDuration(durationMs) {
3917
+ return Math.min(durationMs, MAP_FEATURE_MAX_DURATION_MS);
3918
+ }
3919
+ function mapSweepTiming(durationMs, featureCount, bulk) {
3920
+ const featureDurationMs = mapFeatureDuration(durationMs);
3921
+ const budgetMs = bulk ? 0 : MAP_SWEEP_BUDGET_MS;
3922
+ const n = Math.max(featureCount, 1);
3923
+ const staggerMs2 = !bulk && n > 1 ? budgetMs / (n - 1) : 0;
3924
+ return { featureDurationMs, budgetMs, staggerMs: staggerMs2 };
3925
+ }
3926
+ function tilemapTileDelays(animationIndices) {
3927
+ const baseStagger = 800 / Math.max(animationIndices.length, 1);
3928
+ const delays = [];
3929
+ let seed = 17;
3930
+ for (const idx of animationIndices) {
3931
+ seed = seed * 1103515245 + 12345 & 2147483647;
3932
+ const jitter = (seed % 1e3 / 1e3 - 0.5) * 0.8;
3933
+ delays.push(Math.max(0, Math.round(idx * baseStagger * (1 + jitter))));
3934
+ }
3935
+ return delays;
3936
+ }
3937
+
3938
+ // src/motion/choreography.ts
3939
+ var num = (value) => ({ type: "number", value });
3940
+ var inset = (top, right, bottom, left) => ({
3941
+ type: "inset",
3942
+ top,
3943
+ right,
3944
+ bottom,
3945
+ left
3946
+ });
3947
+ var translateY = (value, unit = "px") => ({
3948
+ type: "translateY",
3949
+ value,
3950
+ unit
3951
+ });
3952
+ var translate = (x, y) => ({ type: "translate", x, y });
3953
+ var scale = (value) => ({ type: "scale", value });
3954
+ var css = (value) => ({ type: "css", css: value });
3955
+ var KEYFRAMES = {
3956
+ "oc-enter-bar": {
3957
+ comment: "Bar entrance: clip-path reveal from the baseline (vertical columns), no fade:\na value mark is solid from its first frame. Grows bottom-to-top unless the\nrenderer stamps --oc-bar-from (a negative column grows top-to-bottom).",
3958
+ stops: [
3959
+ { offset: 0, values: { "clip-path": css("inset(var(--oc-bar-from, 100% 0 0 0))") } },
3960
+ { offset: 1, values: { "clip-path": inset(0, 0, 0, 0) } }
3961
+ ]
3962
+ },
3963
+ "oc-enter-bar-h": {
3964
+ comment: "Bar entrance: clip-path reveal from the baseline (horizontal bars), no fade.\nGrows left-to-right unless --oc-bar-from is stamped (negative bars).",
3965
+ stops: [
3966
+ { offset: 0, values: { "clip-path": css("inset(var(--oc-bar-from, 0 100% 0 0))") } },
3967
+ { offset: 1, values: { "clip-path": inset(0, 0, 0, 0) } }
3968
+ ]
3969
+ },
3970
+ "oc-enter-stack": {
3971
+ comment: "Stack entrance: one clip over the whole stack, no fade. Grows bottom-to-top\nfrom --oc-stack-from, which the renderer stamps when the baseline is not the\nbottom edge, so the clip starts collapsed on the baseline and grows both\nways from it.",
3972
+ stops: [
3973
+ { offset: 0, values: { "clip-path": css("inset(var(--oc-stack-from, 100% 0 0 0))") } },
3974
+ { offset: 1, values: { "clip-path": inset(0, 0, 0, 0) } }
3975
+ ]
3976
+ },
3977
+ "oc-enter-stack-h": {
3978
+ comment: "Horizontal stack entrance: grows left-to-right, or both ways from the\nbaseline when --oc-stack-from is stamped.",
3979
+ stops: [
3980
+ { offset: 0, values: { "clip-path": css("inset(var(--oc-stack-from, 0 100% 0 0))") } },
3981
+ { offset: 1, values: { "clip-path": inset(0, 0, 0, 0) } }
3982
+ ]
3983
+ },
3984
+ "oc-enter-line": {
3985
+ comment: "Line/area entrance: clip-path reveal left-to-right + fade in.\nLines draw in following reading direction with a soft lead-in.",
3986
+ stops: [
3987
+ { offset: 0, values: { "clip-path": inset(0, 100, 0, 0), opacity: num(0) } },
3988
+ { offset: 0.15, values: { opacity: num(1) } },
3989
+ { offset: 1, values: { "clip-path": inset(0, 0, 0, 0), opacity: num(1) } }
3990
+ ]
3991
+ },
3992
+ "oc-enter-point": {
3993
+ comment: "Point/arc entrance: scale up + fade in from center",
3994
+ stops: [
3995
+ { offset: 0, values: { opacity: num(0), transform: scale(0.3) } },
3996
+ { offset: 1, values: { opacity: num(1), transform: scale(1) } }
3997
+ ]
3998
+ },
3999
+ "oc-enter-map-fill": {
4000
+ comment: "Map feature entrance: fade in while transitioning fill from a neutral base\nto the data-driven color stored in --oc-feature-fill. The target opacity is\n--oc-feature-target-opacity (default 1) so features under a focus dim\nanimate straight to their dimmed rest opacity instead of hitting 1 and then\nsnapping down when the dim is applied post-animation.\nNon-interpolable fills (the url(#pattern) hatch on no-data features) do not\ntransition: the browser holds the neutral and flips to the pattern when the\neased progress passes 50%, so those features fade in rather than\ncross-fade.",
4001
+ stops: [
4002
+ { offset: 0, values: { fill: css("var(--oc-secondary)"), opacity: num(0) } },
4003
+ {
4004
+ offset: 1,
4005
+ values: {
4006
+ fill: css("var(--oc-feature-fill)"),
4007
+ opacity: css("var(--oc-feature-target-opacity, 1)")
4008
+ }
4009
+ }
4010
+ ]
4011
+ },
4012
+ "oc-enter-map-point": {
4013
+ comment: "Map point pop-in: gentle scale from 0.75 + fade. Uses transform-origin to\nscale from the circle's own center (cx/cy) rather than the SVG origin.",
4014
+ stops: [
4015
+ { offset: 0, values: { opacity: num(0), transform: scale(0.75) } },
4016
+ { offset: 1, values: { opacity: num(1), transform: scale(1) } }
4017
+ ]
4018
+ },
4019
+ "oc-enter-pop": {
4020
+ comment: "Line point pop: fade in while scaling up from 0.4. The renderer stamps an\ninline px transform-origin at the point centre, so it grows in place\n(and in GIF frames, which carry no animation CSS).",
4021
+ stops: [
4022
+ { offset: 0, values: { opacity: num(0), transform: scale(0.4) } },
4023
+ { offset: 1, values: { opacity: num(1), transform: scale(1) } }
4024
+ ]
4025
+ },
4026
+ "oc-enter-cell": {
4027
+ comment: "Grid cell pop: fade in while scaling up from 0.85 about the cell centre\n(inline px transform-origin stamped by the renderer).",
4028
+ stops: [
4029
+ { offset: 0, values: { opacity: num(0), transform: scale(0.85) } },
4030
+ { offset: 1, values: { opacity: num(1), transform: scale(1) } }
4031
+ ]
4032
+ },
4033
+ "oc-enter-arc": {
4034
+ comment: "Slice growth: fade in while scaling up from 0.94. The slice path is drawn\naround its group's local origin (the group carries translate(cx, cy)), so\nthe default transform-origin of 0 0 is the pie centre.",
4035
+ stops: [
4036
+ { offset: 0, values: { opacity: num(0), transform: scale(0.94) } },
4037
+ { offset: 1, values: { opacity: num(1), transform: scale(1) } }
4038
+ ]
4039
+ },
4040
+ "oc-enter-fade-only": {
4041
+ comment: "Pure opacity fade (no transform). Safe for elements with existing transforms\nlike arc groups that use translate() for positioning.",
4042
+ stops: [
4043
+ { offset: 0, values: { opacity: num(0) } },
4044
+ { offset: 1, values: { opacity: num(1) } }
4045
+ ]
4046
+ },
4047
+ "oc-enter-fade": {
4048
+ comment: "Fade + subtle slide up (table chrome)",
4049
+ stops: [
4050
+ { offset: 0, values: { opacity: num(0), transform: translateY(4) } },
4051
+ { offset: 1, values: { opacity: num(1), transform: translateY(0) } }
4052
+ ]
4053
+ },
4054
+ "oc-enter-rise": {
4055
+ comment: "Text rise: 0.6em up to rest. Its opacity runs as a separate quick fade.",
4056
+ stops: [
4057
+ { offset: 0, values: { transform: translateY(0.6, "em") } },
4058
+ { offset: 1, values: { transform: translateY(0) } }
4059
+ ]
4060
+ },
4061
+ "oc-enter-slide": {
4062
+ comment: "Row slide: 4px up to rest. Its opacity runs as a separate quick fade.",
4063
+ stops: [
4064
+ { offset: 0, values: { transform: translateY(4) } },
4065
+ { offset: 1, values: { transform: translateY(0) } }
4066
+ ]
4067
+ },
4068
+ "oc-table-enter-row": {
4069
+ comment: "Table row entrance: slide up only, no opacity (cells fade independently\nto avoid opacity compounding between row and cell animations)",
4070
+ stops: [
4071
+ { offset: 0, values: { transform: translateY(6) } },
4072
+ { offset: 1, values: { transform: translateY(0) } }
4073
+ ]
4074
+ },
4075
+ "oc-table-enter-bar-fill": {
4076
+ comment: "Table bar fill entrance: clip-path grow only, no opacity\n(preserves resting opacity: 0.15 from table.css)",
4077
+ stops: [
4078
+ { offset: 0, values: { "clip-path": inset(0, 100, 0, 0) } },
4079
+ { offset: 1, values: { "clip-path": inset(0, 0, 0, 0) } }
4080
+ ]
4081
+ },
4082
+ "oc-pulse": {
4083
+ comment: "Live-tile pulse: the terminator dot of a sparkline swells once when new\ndata lands, so a glance at a wall of tiles catches which one just moved.\n`r` is animated as a presentation attribute (SVG geometry properties are\nanimatable in CSS); the fallback is simply no swell.",
4084
+ stops: [
4085
+ { offset: 0, values: { r: css("var(--oc-pulse-r, 4px)"), "fill-opacity": num(1) } },
4086
+ {
4087
+ offset: 0.45,
4088
+ values: { r: css("calc(var(--oc-pulse-r, 4px) * 1.8)"), "fill-opacity": num(0.5) }
4089
+ },
4090
+ { offset: 1, values: { r: css("var(--oc-pulse-r, 4px)"), "fill-opacity": num(1) } }
4091
+ ]
4092
+ },
4093
+ "oc-tooltip-in": {
4094
+ comment: "Tooltip entrance",
4095
+ stops: [
4096
+ { offset: 0, values: { opacity: num(0), transform: translateY(2) } },
4097
+ { offset: 1, values: { opacity: num(1), transform: translateY(0) } }
4098
+ ]
4099
+ }
4100
+ };
4101
+ function pct(v) {
4102
+ return v === 0 ? "0" : `${v}%`;
4103
+ }
4104
+ function keyframeValueToCSS(value) {
4105
+ switch (value.type) {
4106
+ case "number":
4107
+ return String(value.value);
4108
+ case "inset":
4109
+ return `inset(${pct(value.top)} ${pct(value.right)} ${pct(value.bottom)} ${pct(value.left)})`;
4110
+ case "translateY":
4111
+ return value.value === 0 ? "translateY(0)" : `translateY(${value.value}${value.unit})`;
4112
+ case "translate":
4113
+ return `translate(${value.x}px, ${value.y}px)`;
4114
+ case "scale":
4115
+ return `scale(${value.value})`;
4116
+ case "css":
4117
+ return value.css;
4118
+ default:
4119
+ return value;
4120
+ }
4121
+ }
4122
+ function lerp(a, b, e) {
4123
+ return a + (b - a) * e;
4124
+ }
4125
+ function interpolateValue(a, b, e) {
4126
+ if (a.type === "number" && b.type === "number") return num(lerp(a.value, b.value, e));
4127
+ if (a.type === "inset" && b.type === "inset") {
4128
+ return inset(
4129
+ lerp(a.top, b.top, e),
4130
+ lerp(a.right, b.right, e),
4131
+ lerp(a.bottom, b.bottom, e),
4132
+ lerp(a.left, b.left, e)
4133
+ );
4134
+ }
4135
+ if (a.type === "translateY" && b.type === "translateY") {
4136
+ const unit = a.value === 0 ? b.unit : a.unit;
4137
+ return translateY(lerp(a.value, b.value, e), unit);
4138
+ }
4139
+ if (a.type === "translate" && b.type === "translate") {
4140
+ return translate(lerp(a.x, b.x, e), lerp(a.y, b.y, e));
4141
+ }
4142
+ if (a.type === "scale" && b.type === "scale") return scale(lerp(a.value, b.value, e));
4143
+ return e < 0.5 ? a : b;
4144
+ }
4145
+ function evalKeyframes(name, t, ease) {
4146
+ const x = t < 0 ? 0 : t > 1 ? 1 : t;
4147
+ const stops = KEYFRAMES[name].stops;
4148
+ const out = {};
4149
+ for (const prop of keyframeProperties(name)) {
4150
+ const own = stops.filter((s) => s.values[prop] !== void 0);
4151
+ let i = 0;
4152
+ while (i < own.length - 2 && own[i + 1].offset <= x) i++;
4153
+ const a = own[i];
4154
+ const b = own[i + 1] ?? a;
4155
+ const span = b.offset - a.offset;
4156
+ const local = span > 0 ? Math.min(1, Math.max(0, (x - a.offset) / span)) : 1;
4157
+ out[prop] = interpolateValue(a.values[prop], b.values[prop], ease(local));
4158
+ }
4159
+ return out;
4160
+ }
4161
+ function keyframeProperties(name) {
4162
+ const seen = [];
4163
+ for (const stop of KEYFRAMES[name].stops) {
4164
+ for (const prop of Object.keys(stop.values)) {
4165
+ if (!seen.includes(prop)) seen.push(prop);
4166
+ }
4167
+ }
4168
+ return seen;
4169
+ }
4170
+ function settleOffset(name, props) {
4171
+ let end = 0;
4172
+ const stops = KEYFRAMES[name].stops;
4173
+ for (const prop of props) {
4174
+ const own = stops.filter((s) => s.values[prop] !== void 0);
4175
+ for (let i = 1; i < own.length; i++) {
4176
+ const changed = keyframeValueToCSS(own[i].values[prop]) !== keyframeValueToCSS(own[i - 1].values[prop]);
4177
+ if (changed) end = Math.max(end, own[i].offset);
4178
+ }
4179
+ }
4180
+ return end;
4181
+ }
4182
+ var FADE_CURVE = "snap";
4183
+ var TEXT_FADE_MS = 140;
4184
+ var LABEL_FADE_MS = 260;
4185
+ var POINT_FADE_MS = 300;
4186
+ var CELL_POP_MS = 400;
4187
+ var ARC_GROW_MS = 450;
4188
+ var LINE_POINT_POP_MS = 320;
4189
+ var LINE_POINT_CASCADE_MS = 240;
4190
+ var AUTHOR = { kind: "author" };
4191
+ var EASE_IN = { kind: "css", css: "ease-in", bezier: [0.42, 0, 1, 1] };
4192
+ var base = (factor) => ({ kind: "base", factor });
4193
+ var fixed = (ms) => ({ kind: "fixed", ms });
4194
+ var when = (of, progress) => ({
4195
+ kind: "progress",
4196
+ progress,
4197
+ of
4198
+ });
4199
+ var ROLE_DEFS = [
4200
+ {
4201
+ name: "bar",
4202
+ scope: "chart",
4203
+ comment: "Vertical bars (default): the author curve over the full duration, no fade.\noc-mark-bar is reserved for future mark type aliases.\nA bar with a value-end radius draws as <path> rather than <rect>\n(SVG rx rounds all four corners or none), so both shapes match.",
4204
+ selectors: [".oc-mark-rect :is(rect, path)", ".oc-mark-bar :is(rect, path)"],
4205
+ emit: "shorthand",
4206
+ keyframe: "oc-enter-bar",
4207
+ horizontalKeyframe: "oc-enter-bar-h",
4208
+ timing: AUTHOR,
4209
+ durationBasis: "phase",
4210
+ duration: base(1),
4211
+ delay: { stagger: "mark" }
4212
+ },
4213
+ {
4214
+ name: "bar-h",
4215
+ scope: "chart",
4216
+ comment: "Horizontal bars (data-orient is on the mark group, not the SVG root)",
4217
+ selectors: [
4218
+ '.oc-mark-rect[data-orient="horizontal"] :is(rect, path)',
4219
+ '.oc-mark-bar[data-orient="horizontal"] :is(rect, path)'
4220
+ ],
4221
+ emit: ["name"],
4222
+ keyframe: "oc-enter-bar-h",
4223
+ timing: AUTHOR,
4224
+ durationBasis: "phase",
4225
+ duration: base(1),
4226
+ delay: { stagger: "mark" }
4227
+ },
4228
+ {
4229
+ name: "cell",
4230
+ scope: "chart",
4231
+ comment: "Grid cells (heatmap, waffle, calendar) have no baseline to grow from:\neach pops in on its own scattered start. The renderer stamps\n--oc-cell-delay from a seeded shuffle over CELL_SWEEP_BUDGET_MS, so the\ngrid fills in no particular pattern.",
4232
+ selectors: [".oc-mark-rect[data-cell] :is(rect, path)"],
4233
+ emit: "shorthand",
4234
+ keyframe: "oc-enter-cell",
4235
+ timing: AUTHOR,
4236
+ durationBasis: "phase",
4237
+ duration: fixed(CELL_POP_MS),
4238
+ delay: { stagger: "mark" }
4239
+ },
4240
+ {
4241
+ name: "stack-reveal",
4242
+ scope: "chart",
4243
+ comment: "Stacked bars reveal as one group per stack, each on its own stagger slot;\ntheir segments do not animate. A stack that crosses zero grows both ways\nfrom the baseline (--oc-stack-from).",
4244
+ selectors: [".oc-stack-reveal"],
4245
+ emit: "shorthand",
4246
+ keyframe: "oc-enter-stack",
4247
+ horizontalKeyframe: "oc-enter-stack-h",
4248
+ timing: AUTHOR,
4249
+ durationBasis: "phase",
4250
+ duration: base(1),
4251
+ delay: { stagger: "mark" },
4252
+ suppress: [".oc-stack-reveal .oc-mark-rect :is(rect, path)"]
4253
+ },
4254
+ {
4255
+ name: "stack-reveal-h",
4256
+ scope: "chart",
4257
+ selectors: ['.oc-stack-reveal[data-orient="horizontal"]'],
4258
+ emit: ["name"],
4259
+ keyframe: "oc-enter-stack-h",
4260
+ timing: AUTHOR,
4261
+ durationBasis: "phase",
4262
+ duration: base(1),
4263
+ delay: { stagger: "mark" }
4264
+ },
4265
+ {
4266
+ name: "line-area",
4267
+ scope: "chart",
4268
+ comment: "Line and area marks: entire group clips left-to-right + fades in",
4269
+ selectors: [".oc-mark-line", ".oc-mark-area"],
4270
+ emit: "shorthand",
4271
+ keyframe: "oc-enter-line",
4272
+ timing: AUTHOR,
4273
+ durationBasis: "phase",
4274
+ duration: base(1),
4275
+ delay: { stagger: "mark" }
4276
+ },
4277
+ {
4278
+ name: "arc",
4279
+ scope: "chart",
4280
+ comment: "Arc marks (pie/donut slices): each slice path fades and grows from the pie\ncentre. The transform goes on the path, never the group, whose translate()\nattribute positions the slice.",
4281
+ selectors: [".oc-mark-arc > path"],
4282
+ emit: "shorthand",
4283
+ keyframe: "oc-enter-arc",
4284
+ timing: AUTHOR,
4285
+ durationBasis: "phase",
4286
+ duration: fixed(ARC_GROW_MS),
4287
+ delay: { stagger: "mark" }
4288
+ },
4289
+ {
4290
+ name: "point",
4291
+ scope: "chart",
4292
+ comment: "Point marks (scatter, dot): a quick fade on the author curve, no scale.\nPoints render as bare <circle> elements with class oc-mark-point directly,\nnot wrapped in a group, so we target circle.oc-mark-point (not descendant).",
4293
+ selectors: ["circle.oc-mark-point", "circle.oc-mark-circle"],
4294
+ emit: "shorthand",
4295
+ keyframe: "oc-enter-fade-only",
4296
+ timing: AUTHOR,
4297
+ durationBasis: "phase",
4298
+ duration: fixed(POINT_FADE_MS),
4299
+ delay: { stagger: "mark" }
4300
+ },
4301
+ {
4302
+ name: "line-point",
4303
+ scope: "chart",
4304
+ comment: "Points on line/area charts pop in once their own line has drawn (0.97),\ncascading left to right over LINE_POINT_CASCADE_MS. The renderer stamps\neach point's delay and marks it data-line-point (a scatter's trendline also\nprecedes its circles, so position can't select these). Points hidden under an endpoint marker stay hidden.",
4305
+ selectors: ["circle.oc-mark-point[data-line-point]"],
4306
+ emit: "shorthand",
4307
+ keyframe: "oc-enter-pop",
4308
+ timing: { kind: "curve", curve: "punch" },
4309
+ accent: true,
4310
+ durationBasis: "phase",
4311
+ duration: fixed(LINE_POINT_POP_MS),
4312
+ delay: { after: when("line-area", 0.97), stagger: "mark" },
4313
+ suppress: ['circle.oc-mark-point[opacity="0"]']
4314
+ },
4315
+ {
4316
+ name: "text",
4317
+ scope: "chart",
4318
+ comment: "Text marks: rise 0.6em on the author curve, with a quick fade",
4319
+ selectors: [".oc-mark-text text"],
4320
+ emit: "shorthand",
4321
+ keyframe: "oc-enter-rise",
4322
+ timing: AUTHOR,
4323
+ durationBasis: "phase",
4324
+ duration: base(1),
4325
+ fade: { ms: TEXT_FADE_MS },
4326
+ delay: { stagger: "mark" }
4327
+ },
4328
+ {
4329
+ name: "rule",
4330
+ scope: "chart",
4331
+ comment: "Rule marks: fade in place, never translate (a moving rule reads a wrong value)",
4332
+ selectors: [".oc-mark-rule line"],
4333
+ emit: "shorthand",
4334
+ keyframe: "oc-enter-fade-only",
4335
+ timing: AUTHOR,
4336
+ durationBasis: "phase",
4337
+ duration: base(0.5),
4338
+ delay: { stagger: "mark" }
4339
+ },
4340
+ {
4341
+ name: "tick",
4342
+ scope: "chart",
4343
+ comment: "Tick marks: fade in place",
4344
+ selectors: [".oc-mark-tick line"],
4345
+ emit: "shorthand",
4346
+ keyframe: "oc-enter-fade-only",
4347
+ timing: AUTHOR,
4348
+ durationBasis: "phase",
4349
+ duration: base(0.5),
4350
+ delay: { stagger: "mark" }
4351
+ },
4352
+ {
4353
+ name: "label",
4354
+ scope: "chart",
4355
+ comment: "Data labels (bar values, line end labels) fade in place once their mark has\nlanded: when the bar at the label's --oc-mark-index reaches 0.97. Lines\nshare the bar's duration and curve, so the bar anchor stands in for them.\nLabels never move during the entrance.",
4356
+ selectors: [".oc-mark-label"],
4357
+ emit: "shorthand",
4358
+ keyframe: "oc-enter-fade-only",
4359
+ timing: AUTHOR,
4360
+ durationBasis: "phase",
4361
+ duration: fixed(LABEL_FADE_MS),
4362
+ delay: { after: when("bar", 0.97), stagger: "mark" }
4363
+ },
4364
+ {
4365
+ name: "arc-label",
4366
+ scope: "chart",
4367
+ comment: "Pie/donut slice labels fade in place once their own slice reaches 0.97.",
4368
+ selectors: [".oc-mark-arc > .oc-mark-label"],
4369
+ emit: "shorthand",
4370
+ keyframe: "oc-enter-fade-only",
4371
+ timing: AUTHOR,
4372
+ durationBasis: "phase",
4373
+ duration: fixed(LABEL_FADE_MS),
4374
+ delay: { after: when("arc", 0.97), stagger: "mark" }
4375
+ },
4376
+ {
4377
+ name: "endpoint-label",
4378
+ scope: "chart",
4379
+ comment: "Trailing endpoint labels (marker, name, value) and area interior labels:\nfade in as their own series' line reaches the end, never before it. The\nrenderer stamps each entry with its series' --oc-mark-index.",
4380
+ selectors: [
4381
+ '.oc-endpoint-label-entry[data-endpoint-side="trailing"]',
4382
+ ".oc-area-interior-label"
4383
+ ],
4384
+ emit: "shorthand",
4385
+ keyframe: "oc-enter-fade-only",
4386
+ timing: AUTHOR,
4387
+ durationBasis: "phase",
4388
+ duration: fixed(POINT_FADE_MS),
4389
+ delay: { after: when("line-area", 0.95), stagger: "mark" }
4390
+ },
4391
+ {
4392
+ name: "annotation",
4393
+ scope: "chart",
4394
+ comment: "Annotations: fade in once the last mark is 90% of the way there",
4395
+ selectors: [".oc-annotation"],
4396
+ emit: "shorthand",
4397
+ keyframe: "oc-enter-fade-only",
4398
+ timing: { kind: "curve", curve: "glide" },
4399
+ durationBasis: "phase",
4400
+ duration: fixed(300),
4401
+ delay: {
4402
+ after: { kind: "progress", progress: 0.9, of: "bar", ofLast: true },
4403
+ plusAnnotationDelay: true,
4404
+ stagger: "none"
4405
+ }
4406
+ },
4407
+ {
4408
+ name: "tilemap-tile",
4409
+ scope: "chart",
4410
+ comment: "Tilemap tiles: fade in with jittered stagger for organic feel.\nPer-tile delay is computed in the renderer with pseudo-random variation.",
4411
+ selectors: [".oc-tilemap-tile"],
4412
+ emit: "shorthand",
4413
+ keyframe: "oc-enter-fade-only",
4414
+ timing: EASE_IN,
4415
+ durationBasis: "phase",
4416
+ duration: base(0.35),
4417
+ delay: { stagger: "tilemap-tile" }
4418
+ },
4419
+ {
4420
+ name: "map-feature",
4421
+ scope: "chart",
4422
+ comment: "Map features: fill color reveal with shuffled stagger.\nPer-feature --oc-map-delay is computed in the renderer via a seeded\nFisher-Yates shuffle so features pop in organically.",
4423
+ selectors: [".oc-map-feature"],
4424
+ emit: "shorthand",
4425
+ keyframe: "oc-enter-map-fill",
4426
+ timing: AUTHOR,
4427
+ durationBasis: "map",
4428
+ duration: base(1),
4429
+ delay: { stagger: "map-sweep" }
4430
+ },
4431
+ {
4432
+ name: "map-bulk",
4433
+ scope: "chart",
4434
+ comment: "Bulk mode: high feature counts (counties, ~3k+) get a single group\nfade instead of per-feature fill animations. opacity is GPU-compositable\nso this stays smooth regardless of child count.",
4435
+ selectors: [".oc-map-features[data-bulk-animate]"],
4436
+ emit: "shorthand",
4437
+ keyframe: "oc-enter-fade-only",
4438
+ timing: AUTHOR,
4439
+ durationBasis: "map",
4440
+ duration: base(1),
4441
+ delay: { stagger: "none" },
4442
+ suppress: [".oc-map-features[data-bulk-animate] .oc-map-feature"]
4443
+ },
4444
+ {
4445
+ name: "map-border",
4446
+ scope: "chart",
4447
+ comment: "Map borders: fade in once most of the feature sweep has started",
4448
+ selectors: [".oc-map-borders path"],
4449
+ emit: "shorthand",
4450
+ keyframe: "oc-enter-fade-only",
4451
+ timing: EASE_IN,
4452
+ durationBasis: "map",
4453
+ duration: base(0.4),
4454
+ delay: { after: { kind: "sweep", progress: 0.6 }, stagger: "none" }
4455
+ },
4456
+ {
4457
+ name: "map-point",
4458
+ scope: "chart",
4459
+ comment: "Map points: gentle scale (0.75->1) + fade pop-in just after the borders.\ntransform-origin set per-circle in the renderer so scale happens\naround each circle's own center, not the SVG origin.",
4460
+ selectors: [".oc-map-point"],
4461
+ emit: "shorthand",
4462
+ keyframe: "oc-enter-map-point",
4463
+ timing: AUTHOR,
4464
+ durationBasis: "map",
4465
+ duration: base(0.4),
4466
+ delay: { after: { kind: "sweep", progress: 0.65 }, stagger: "map-point" }
4467
+ },
4468
+ {
4469
+ name: "sankey-node",
4470
+ scope: "chart",
4471
+ comment: "Sankey nodes: fade in with stagger by column depth (left-to-right)",
4472
+ selectors: [".oc-sankey-node rect"],
4473
+ emit: "shorthand",
4474
+ keyframe: "oc-enter-fade-only",
4475
+ timing: AUTHOR,
4476
+ durationBasis: "phase",
4477
+ duration: base(1),
4478
+ delay: { stagger: "mark" }
4479
+ },
4480
+ {
4481
+ name: "sankey-link",
4482
+ scope: "chart",
4483
+ comment: "Sankey links: fade in when their source node is halfway in. Each link\ncarries its source node's --oc-mark-index.",
4484
+ selectors: [".oc-sankey-link path"],
4485
+ emit: "shorthand",
4486
+ keyframe: "oc-enter-fade-only",
4487
+ timing: AUTHOR,
4488
+ durationBasis: "phase",
4489
+ duration: base(1),
4490
+ delay: { after: when("sankey-node", 0.5), stagger: "mark" }
4491
+ },
4492
+ {
4493
+ name: "barlist-row",
4494
+ scope: "chart",
4495
+ comment: "Barlist rows: slide up with a quick fade per row; bars grow left-to-right",
4496
+ selectors: [".oc-barlist-row"],
4497
+ emit: "shorthand",
4498
+ keyframe: "oc-enter-slide",
4499
+ timing: AUTHOR,
4500
+ durationBasis: "phase",
4501
+ duration: base(0.6),
4502
+ fade: { ms: TEXT_FADE_MS },
4503
+ delay: { stagger: "mark" }
4504
+ },
4505
+ {
4506
+ name: "barlist-bar",
4507
+ scope: "chart",
4508
+ selectors: [".oc-barlist-bar"],
4509
+ emit: "shorthand",
4510
+ keyframe: "oc-enter-bar-h",
4511
+ timing: AUTHOR,
4512
+ durationBasis: "phase",
4513
+ duration: base(1),
4514
+ delay: { stagger: "mark" }
4515
+ },
4516
+ {
4517
+ name: "table-chrome",
4518
+ scope: "table",
4519
+ comment: "Chrome (title/subtitle): fade + slide up",
4520
+ selectors: ["> .oc-chrome"],
4521
+ emit: "shorthand",
4522
+ keyframe: "oc-enter-fade",
4523
+ timing: AUTHOR,
4524
+ durationBasis: "phase",
4525
+ duration: base(0.6),
4526
+ delay: { stagger: "none" }
4527
+ },
4528
+ {
4529
+ name: "table-thead",
4530
+ scope: "table",
4531
+ comment: "Table header: quick fade before rows start",
4532
+ selectors: ["thead"],
4533
+ emit: "shorthand",
4534
+ keyframe: "oc-enter-fade-only",
4535
+ timing: AUTHOR,
4536
+ durationBasis: "phase",
4537
+ duration: base(0.4),
4538
+ delay: { stagger: "none" }
4539
+ },
4540
+ {
4541
+ name: "table-row",
4542
+ scope: "table",
4543
+ comment: "Row entrance: slide up only, no opacity (cells handle their own fading\nto avoid opacity compounding between row and cell animations)",
4544
+ selectors: ["tbody tr"],
4545
+ emit: "shorthand",
4546
+ keyframe: "oc-table-enter-row",
4547
+ timing: AUTHOR,
4548
+ durationBasis: "phase",
4549
+ duration: base(1),
4550
+ delay: { stagger: "row" }
4551
+ },
4552
+ {
4553
+ name: "table-cell",
4554
+ scope: "table",
4555
+ comment: "Cell text: fade in synced with row slide",
4556
+ selectors: ["tbody td"],
4557
+ emit: "shorthand",
4558
+ keyframe: "oc-enter-fade-only",
4559
+ timing: AUTHOR,
4560
+ durationBasis: "phase",
4561
+ duration: base(0.5),
4562
+ delay: { stagger: "row" }
4563
+ },
4564
+ {
4565
+ name: "table-heatmap-cell",
4566
+ scope: "table",
4567
+ comment: "Heatmap/category cell backgrounds: longer fade, once the row is halfway in",
4568
+ selectors: ["td.oc-table-heatmap", "td.oc-table-category"],
4569
+ emit: "shorthand",
4570
+ keyframe: "oc-enter-fade-only",
4571
+ timing: AUTHOR,
4572
+ durationBasis: "phase",
4573
+ duration: base(0.7),
4574
+ delay: { after: when("table-row", 0.5), stagger: "row" }
4575
+ },
4576
+ {
4577
+ name: "table-bar-fill",
4578
+ scope: "table",
4579
+ comment: "Bar fill: clip-path grow only (no opacity change to preserve resting\nopacity: 0.15 from table.css), once the row is halfway in",
4580
+ selectors: [".oc-table-bar-fill"],
4581
+ emit: "shorthand",
4582
+ keyframe: "oc-table-enter-bar-fill",
4583
+ timing: AUTHOR,
4584
+ durationBasis: "phase",
4585
+ duration: base(1),
4586
+ delay: { after: when("table-row", 0.5), stagger: "row" }
4587
+ },
4588
+ {
4589
+ name: "table-sparkline",
4590
+ scope: "table",
4591
+ comment: "Sparkline SVG: clip-path reveal left-to-right once the row is mostly in.\nTargets the SVG directly (not the wrapper) to avoid clipping\nabsolutely-positioned dots and labels.",
4592
+ selectors: [".oc-table-sparkline > svg"],
4593
+ emit: "shorthand",
4594
+ keyframe: "oc-enter-line",
4595
+ timing: AUTHOR,
4596
+ durationBasis: "phase",
4597
+ duration: base(0.8),
4598
+ delay: { after: when("table-row", 0.7), stagger: "row" }
4599
+ },
4600
+ {
4601
+ name: "table-sparkline-dot",
4602
+ scope: "table",
4603
+ comment: "Sparkline dots and labels: fade in as the line draws through the end",
4604
+ selectors: [".oc-table-sparkline-dot", ".oc-table-sparkline-labels"],
4605
+ emit: "shorthand",
4606
+ keyframe: "oc-enter-fade-only",
4607
+ timing: AUTHOR,
4608
+ durationBasis: "phase",
4609
+ duration: base(0.3),
4610
+ delay: { after: when("table-sparkline", 0.95), stagger: "row" }
4611
+ },
4612
+ {
4613
+ name: "table-search-pagination",
4614
+ scope: "table",
4615
+ comment: "Search and pagination: quick fade on mount",
4616
+ selectors: [".oc-table-search", ".oc-table-pagination"],
4617
+ emit: "shorthand",
4618
+ keyframe: "oc-enter-fade-only",
4619
+ timing: AUTHOR,
4620
+ durationBasis: "phase",
4621
+ duration: base(0.5),
4622
+ delay: { stagger: "none" }
4623
+ }
4624
+ ];
4625
+ var ROLE_VAR_OVERRIDES = {
4626
+ annotation: { delay: "--oc-annotation-enter-delay" }
4627
+ };
4628
+ function roleVars(role) {
4629
+ const override = ROLE_VAR_OVERRIDES[role];
4630
+ return {
4631
+ delay: override?.delay ?? `--oc-${role}-delay`,
4632
+ duration: override?.duration ?? `--oc-${role}-dur`,
4633
+ after: override?.after ?? `--oc-${role}-after`
4634
+ };
4635
+ }
4636
+ var NON_OPACITY = ["clip-path", "transform", "fill", "r", "fill-opacity"];
4637
+ var ENTRANCE_ROLES = ROLE_DEFS.map((def) => ({
4638
+ ...def,
4639
+ geometryFraction: settleOffset(def.keyframe, NON_OPACITY),
4640
+ opacityFraction: settleOffset(def.keyframe, ["opacity"]),
4641
+ vars: roleVars(def.name)
4642
+ }));
4643
+ var ROLE_BY_NAME = new Map(ENTRANCE_ROLES.map((row) => [row.name, row]));
4644
+ function entranceRole(role) {
4645
+ const row = ROLE_BY_NAME.get(role);
4646
+ if (!row) throw new Error(`Unknown entrance role "${role}"`);
4647
+ return row;
4648
+ }
4649
+ var DEFAULT_STAGGER_MS = 80;
4650
+ var DEFAULT_ANNOTATION_DELAY_MS = 150;
4651
+ function clean(ms) {
4652
+ return Math.round(ms * 1e6) / 1e6;
4653
+ }
4654
+ function roleBaseDuration(role, phase) {
4655
+ return entranceRole(role).durationBasis === "map" ? mapFeatureDuration(phase.duration) : phase.duration;
4656
+ }
4657
+ function roleDurationMs(role, phase) {
4658
+ const row = entranceRole(role);
4659
+ return row.duration.kind === "base" ? roleBaseDuration(role, phase) * row.duration.factor : row.duration.ms;
4660
+ }
4661
+ function staggerMs(rule, index, ctx) {
4662
+ switch (rule) {
4663
+ case "none":
4664
+ return 0;
4665
+ case "mark":
4666
+ case "row":
4667
+ return index * (ctx.staggerMs ?? DEFAULT_STAGGER_MS);
4668
+ case "map-point":
4669
+ return index * (ctx.pointStaggerMs ?? MAP_POINT_STAGGER_FALLBACK_MS);
4670
+ case "map-sweep":
4671
+ return index * (ctx.staggerMs ?? 0);
4672
+ case "tilemap-tile":
4673
+ return ctx.delayMs ?? 0;
4674
+ default:
4675
+ return rule;
4676
+ }
4677
+ }
4678
+ function parentContext(ctx) {
4679
+ return {
4680
+ staggerMs: ctx.staggerMs,
4681
+ annotationDelayMs: ctx.annotationDelayMs,
4682
+ pointStaggerMs: ctx.pointStaggerMs,
4683
+ afterMs: ctx.afterMs,
4684
+ lastMarkIndex: ctx.lastMarkIndex
4685
+ };
4686
+ }
4687
+ function progressTimeMs(role, index, phase, context, progress) {
4688
+ const { delayMs, durationMs } = entranceTiming(role, index, phase, context);
4689
+ return clean(delayMs + invertRoleEase(role, phase, progress) * durationMs);
4690
+ }
4691
+ function anchorMs(role, phase, context = {}) {
4692
+ const anchor = entranceRole(role).delay.after;
4693
+ if (!anchor) return 0;
4694
+ const stamped = context.afterMs?.[role];
4695
+ if (stamped !== void 0) return stamped;
4696
+ if (anchor.kind === "sweep") return clean(anchor.progress * MAP_SWEEP_BUDGET_MS);
4697
+ const index = anchor.ofLast ? context.lastMarkIndex ?? 0 : 0;
4698
+ return progressTimeMs(anchor.of, index, phase, parentContext(context), anchor.progress);
4699
+ }
4700
+ function entranceAnchorVars(phase, context = {}, scope = "chart") {
4701
+ const vars = {};
4702
+ for (const row of ENTRANCE_ROLES) {
4703
+ if (row.scope !== scope || !row.delay.after) continue;
4704
+ vars[row.vars.after] = `${anchorMs(row.name, phase, context)}ms`;
4705
+ }
4706
+ return vars;
4707
+ }
4708
+ function entranceTiming(role, index, phase, context = {}) {
4709
+ const row = entranceRole(role);
4710
+ const durationMs = roleDurationMs(role, phase);
4711
+ let delayMs;
4712
+ if (context.stampedDelayMs !== void 0) {
4713
+ delayMs = context.stampedDelayMs;
4714
+ } else {
4715
+ delayMs = staggerMs(row.delay.stagger, index, context) + anchorMs(role, phase, context);
4716
+ if (row.delay.plusAnnotationDelay) {
4717
+ delayMs += context.annotationDelayMs ?? DEFAULT_ANNOTATION_DELAY_MS;
4718
+ }
4719
+ }
4720
+ const fadeMs = row.fade?.ms ?? 0;
4721
+ return {
4722
+ delayMs: clean(delayMs),
4723
+ durationMs: clean(durationMs),
4724
+ geometryMs: clean(durationMs * row.geometryFraction),
4725
+ opacityMs: clean(row.fade ? fadeMs : durationMs * row.opacityFraction),
4726
+ fadeMs
4727
+ };
4728
+ }
4729
+ function entranceEndMs(context) {
4730
+ const { phase, roles, ...timing } = context;
4731
+ let end = 0;
4732
+ for (const [role, value] of Object.entries(roles)) {
4733
+ const extent = typeof value === "number" ? { count: value } : value;
4734
+ if (!(extent.count > 0)) continue;
4735
+ const index = extent.maxIndex ?? extent.count - 1;
4736
+ const endOf = (stampedDelayMs) => {
4737
+ const t = entranceTiming(role, index, phase, {
4738
+ ...timing,
4739
+ delayMs: extent.maxDelayMs,
4740
+ stampedDelayMs
4741
+ });
4742
+ return t.delayMs + Math.max(t.durationMs, t.fadeMs);
4743
+ };
4744
+ const stamped = extent.stampedCount ?? 0;
4745
+ if (stamped > 0 && extent.maxStampedDelayMs !== void 0) {
4746
+ end = Math.max(end, endOf(extent.maxStampedDelayMs));
4747
+ }
4748
+ if (extent.count > stamped) end = Math.max(end, endOf());
4749
+ }
4750
+ return clean(end);
4751
+ }
4752
+ function evalRoleEase(role, phase, t) {
4753
+ const { timing } = entranceRole(role);
4754
+ switch (timing.kind) {
4755
+ case "author": {
4756
+ if (phase.spring) {
4757
+ const d = roleBaseDuration(role, phase);
4758
+ const x = t < 0 ? 0 : t > 1 ? 1 : t;
4759
+ return sampleMotion({ duration: d, spring: phase.spring }, x * d).position;
4760
+ }
4761
+ return evalCurve(phase.ease ?? "smooth", t);
4762
+ }
4763
+ case "curve":
4764
+ return evalCurve(timing.curve, t);
4765
+ case "css":
4766
+ return evalCubicBezier(timing.bezier, t);
4767
+ default:
4768
+ return timing;
4769
+ }
4770
+ }
4771
+ function firstReach(f, p) {
4772
+ if (f(0) >= p) return 0;
4773
+ const steps = 256;
4774
+ let prev = 0;
4775
+ for (let i = 1; i <= steps; i++) {
4776
+ const t = i / steps;
4777
+ if (f(t) >= p) {
4778
+ let lo = prev;
4779
+ let hi = t;
4780
+ for (let k = 0; k < 40; k++) {
4781
+ const mid = (lo + hi) / 2;
4782
+ if (f(mid) >= p) hi = mid;
4783
+ else lo = mid;
4784
+ }
4785
+ return hi;
4786
+ }
4787
+ prev = t;
4788
+ }
4789
+ return 1;
4790
+ }
4791
+ function invertRoleEase(role, phase, p) {
4792
+ const { timing } = entranceRole(role);
4793
+ if (timing.kind === "author" && !phase.spring) {
4794
+ return invertCurve(phase.ease ?? "smooth", p);
4795
+ }
4796
+ if (timing.kind === "curve" && isMonotoneCurve(timing.curve)) {
4797
+ return invertCurve(timing.curve, p);
4798
+ }
4799
+ return firstReach((t) => evalRoleEase(role, phase, t), p);
4800
+ }
4801
+ var EXIT_FADE_MS = 120;
4802
+ var EXIT_CURVE = "gentle";
4803
+ var UPDATE_ENTER_START = 0.4;
4804
+ function updateTimeline(update, exit, hasRemovals) {
4805
+ const updateDelayMs = hasRemovals ? Math.max(0, exit.duration) : 0;
4806
+ const enterLead = UPDATE_ENTER_START * update.duration;
4807
+ return {
4808
+ exitMs: exit.duration,
4809
+ updateDelayMs,
4810
+ enterDelayMs: updateDelayMs + enterLead,
4811
+ enterMs: update.duration - enterLead,
4812
+ totalMs: Math.max(updateDelayMs + update.duration, exit.duration)
4813
+ };
4814
+ }
3567
4815
  export {
3568
4816
  ACHROMATIC_RAMP,
3569
4817
  AXIS_TITLE_GAP,
@@ -3580,13 +4828,19 @@ export {
3580
4828
  CATEGORICAL_FILL_PALETTE_DARK,
3581
4829
  CATEGORICAL_PALETTE,
3582
4830
  CATEGORICAL_PALETTE_DARK,
4831
+ CELL_SWEEP_BUDGET_MS,
3583
4832
  COMPACT_MAX_X_TICKS,
3584
4833
  COMPACT_WIDTH,
3585
4834
  CSS_TOKENS,
3586
4835
  CSS_TOKEN_ROOT_SELECTORS,
4836
+ CURVE_NAMES,
3587
4837
  DEFAULT_THEME,
3588
4838
  DIVERGING_PALETTES,
4839
+ ENTRANCE_ROLES,
4840
+ EXIT_CURVE,
4841
+ EXIT_FADE_MS,
3589
4842
  EXTENDED_OFFSET_STRATEGIES,
4843
+ FADE_CURVE,
3590
4844
  FLUID_SPRING,
3591
4845
  FOOTNOTE_LINE_HEIGHT,
3592
4846
  GRAPH_ENCODING_RULES,
@@ -3596,8 +4850,13 @@ export {
3596
4850
  HEIGHT_SHORT_MAX,
3597
4851
  HPAD_COMPACT_FRACTION,
3598
4852
  HPAD_COMPACT_MIN,
4853
+ KEYFRAMES,
3599
4854
  LABEL_GAP_COMPACT,
3600
4855
  LABEL_GAP_DEFAULT,
4856
+ LINE_POINT_CASCADE_MS,
4857
+ MAP_FEATURE_MAX_DURATION_MS,
4858
+ MAP_POINT_STAGGER_FALLBACK_MS,
4859
+ MAP_SWEEP_BUDGET_MS,
3601
4860
  MARK_DISPLAY_NAMES,
3602
4861
  MARK_ENCODING_RULES,
3603
4862
  MARK_TYPES,
@@ -3607,6 +4866,7 @@ export {
3607
4866
  MAX_LEFT_LABEL_FRACTION_MEDIUM_MAX,
3608
4867
  MAX_SPRING_DURATION,
3609
4868
  MAX_SR_TABLE_ROWS,
4869
+ MAX_TOTAL_STAGGER_MS,
3610
4870
  MOTION_REST_THRESHOLD,
3611
4871
  NARROW_VIEWPORT_MAX,
3612
4872
  OFFSET_STRATEGIES,
@@ -3615,6 +4875,7 @@ export {
3615
4875
  TICK_LABEL_OFFSET,
3616
4876
  TICK_LINE_HEIGHT_FACTOR,
3617
4877
  TOP_PAD_EXTRA_NARROW,
4878
+ UPDATE_ENTER_START,
3618
4879
  X_AXIS_BAND_HEIGHT,
3619
4880
  X_AXIS_ROTATED_EXTENT_CAP,
3620
4881
  X_AXIS_TITLE_BAND,
@@ -3623,6 +4884,7 @@ export {
3623
4884
  adaptColorForDarkMode,
3624
4885
  adaptForLightLineStroke,
3625
4886
  adaptTheme,
4887
+ anchorMs,
3626
4888
  annotationSource,
3627
4889
  applyEditTransaction,
3628
4890
  areaChart,
@@ -3633,6 +4895,7 @@ export {
3633
4895
  buildD3Formatter,
3634
4896
  buildTemporalFormatter,
3635
4897
  checkPaletteDistinguishability,
4898
+ clampStaggerDelay,
3636
4899
  clarity,
3637
4900
  columnChart,
3638
4901
  computeChrome,
@@ -3642,6 +4905,8 @@ export {
3642
4905
  computeXAxisExtentFromLabels,
3643
4906
  contrastRatio,
3644
4907
  cssTokenDefault,
4908
+ curveStops,
4909
+ curveToCSSLinear,
3645
4910
  dataTable,
3646
4911
  deepMergeSpec,
3647
4912
  defaultNumberFormatter,
@@ -3651,14 +4916,23 @@ export {
3651
4916
  dotChart,
3652
4917
  elementRef,
3653
4918
  encodePointerToken,
4919
+ entranceAnchorVars,
4920
+ entranceEndMs,
4921
+ entranceRole,
4922
+ entranceTiming,
3654
4923
  essay,
3655
4924
  estimateTextWidth,
4925
+ evalCubicBezier,
4926
+ evalCurve,
4927
+ evalKeyframes,
4928
+ evalRoleEase,
4929
+ evalValueCurve,
3656
4930
  findAccessibleColor,
3657
4931
  formatCurrency,
3658
4932
  formatDate,
3659
4933
  formatNumber,
3660
4934
  formatOrdinal,
3661
- formatPercent,
4935
+ formatPercent2 as formatPercent,
3662
4936
  generateAltText,
3663
4937
  generateAriaLabels,
3664
4938
  generateDataTable,
@@ -3669,6 +4943,8 @@ export {
3669
4943
  getRepresentativeColor,
3670
4944
  heuristicMeasure,
3671
4945
  inferFieldType,
4946
+ invertCurve,
4947
+ invertRoleEase,
3672
4948
  isAxislessMark,
3673
4949
  isBarListSpec,
3674
4950
  isChartSpec,
@@ -3678,7 +4954,9 @@ export {
3678
4954
  isGradientDef,
3679
4955
  isGraphSpec,
3680
4956
  isLayerSpec,
4957
+ isMonotoneCurve,
3681
4958
  isOpaqueColor,
4959
+ isRaceSpec,
3682
4960
  isRangeAnnotation,
3683
4961
  isRefLineAnnotation,
3684
4962
  isSankeySpec,
@@ -3688,8 +4966,12 @@ export {
3688
4966
  isValueDef,
3689
4967
  isYearContext,
3690
4968
  jsonPointer,
4969
+ keyframeProperties,
4970
+ keyframeValueToCSS,
3691
4971
  legacyEditorial,
3692
4972
  lineChart,
4973
+ mapFeatureDuration,
4974
+ mapSweepTiming,
3693
4975
  maxRotatedLabelWidth,
3694
4976
  meetsAA,
3695
4977
  mergeThemeConfig,
@@ -3697,6 +4979,7 @@ export {
3697
4979
  overlapArea,
3698
4980
  pickLabelColor,
3699
4981
  pieChart,
4982
+ progressTimeMs,
3700
4983
  resolveChromeEconomy,
3701
4984
  resolveCollisions,
3702
4985
  resolveMarkDef,
@@ -3705,15 +4988,20 @@ export {
3705
4988
  resolveNumberFormatter,
3706
4989
  resolveSchemeName,
3707
4990
  resolveTheme,
4991
+ roleBaseDuration,
4992
+ roleVars,
3708
4993
  sampleMotion,
3709
4994
  scatterChart,
4995
+ shuffledSweepDelays,
3710
4996
  simulateColorBlindness,
3711
4997
  springDuration,
3712
4998
  terminal,
3713
4999
  textAscent,
3714
5000
  tileMap,
5001
+ tilemapTileDelays,
3715
5002
  truncateRotatedLabel,
3716
5003
  truncateToWidth,
5004
+ updateTimeline,
3717
5005
  wire,
3718
5006
  wrapText
3719
5007
  };