@d3plus/core 4.1.0 → 4.3.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.
Files changed (85) hide show
  1. package/README.md +781 -688
  2. package/es/src/charts/AreaPlot/index.js +2 -1
  3. package/es/src/charts/AreaPlot/index.js.map +1 -1
  4. package/es/src/charts/BarChart/index.js +3 -1
  5. package/es/src/charts/BarChart/index.js.map +1 -1
  6. package/es/src/charts/BoxWhisker/index.js +2 -1
  7. package/es/src/charts/BoxWhisker/index.js.map +1 -1
  8. package/es/src/charts/BumpChart/index.js +2 -1
  9. package/es/src/charts/BumpChart/index.js.map +1 -1
  10. package/es/src/charts/Geomap/emit.js +44 -4
  11. package/es/src/charts/Geomap/emit.js.map +1 -1
  12. package/es/src/charts/Geomap/index.js +32 -2
  13. package/es/src/charts/Geomap/index.js.map +1 -1
  14. package/es/src/charts/LinePlot/index.js +2 -1
  15. package/es/src/charts/LinePlot/index.js.map +1 -1
  16. package/es/src/charts/Matrix/index.js +1 -0
  17. package/es/src/charts/Matrix/index.js.map +1 -1
  18. package/es/src/charts/Network/index.js +2 -1
  19. package/es/src/charts/Network/index.js.map +1 -1
  20. package/es/src/charts/Pack/index.js +1 -0
  21. package/es/src/charts/Pack/index.js.map +1 -1
  22. package/es/src/charts/Pie/index.js +1 -0
  23. package/es/src/charts/Pie/index.js.map +1 -1
  24. package/es/src/charts/Plot/index.js +99 -14
  25. package/es/src/charts/Plot/index.js.map +1 -1
  26. package/es/src/charts/Plot/pipeline.js +24 -3
  27. package/es/src/charts/Plot/pipeline.js.map +1 -1
  28. package/es/src/charts/Plot/pipelineDomains.js +3 -3
  29. package/es/src/charts/Plot/pipelineDomains.js.map +1 -1
  30. package/es/src/charts/Plot/stackHelpers.js +128 -9
  31. package/es/src/charts/Plot/stackHelpers.js.map +1 -1
  32. package/es/src/charts/Radar/index.js +2 -1
  33. package/es/src/charts/Radar/index.js.map +1 -1
  34. package/es/src/charts/RadialMatrix/index.js +1 -0
  35. package/es/src/charts/RadialMatrix/index.js.map +1 -1
  36. package/es/src/charts/Rings/index.js +2 -1
  37. package/es/src/charts/Rings/index.js.map +1 -1
  38. package/es/src/charts/Sankey/index.js +2 -1
  39. package/es/src/charts/Sankey/index.js.map +1 -1
  40. package/es/src/charts/Tree/index.js +2 -1
  41. package/es/src/charts/Tree/index.js.map +1 -1
  42. package/es/src/charts/Treemap/index.js +1 -0
  43. package/es/src/charts/Treemap/index.js.map +1 -1
  44. package/es/src/charts/features/shapeEmit.js +3 -1
  45. package/es/src/charts/features/shapeEmit.js.map +1 -1
  46. package/es/src/charts/viz/Viz.js +63 -10
  47. package/es/src/charts/viz/Viz.js.map +1 -1
  48. package/es/src/charts/viz/interactionOpacity.js +4 -1
  49. package/es/src/charts/viz/interactionOpacity.js.map +1 -1
  50. package/es/src/charts/viz/vizDefaults.js +4 -1
  51. package/es/src/charts/viz/vizDefaults.js.map +1 -1
  52. package/es/src/charts/viz/vizRender.js +7 -3
  53. package/es/src/charts/viz/vizRender.js.map +1 -1
  54. package/es/src/charts/viz/vizTypes.js.map +1 -1
  55. package/es/src/shapes/Image.js +2 -3
  56. package/es/src/shapes/Image.js.map +1 -1
  57. package/es/src/shapes/Shape.js +47 -46
  58. package/es/src/shapes/Shape.js.map +1 -1
  59. package/es/src/shapes/hitAreaNode.js +31 -5
  60. package/es/src/shapes/hitAreaNode.js.map +1 -1
  61. package/es/src/shapes/interactionPoints.js +30 -0
  62. package/es/src/shapes/interactionPoints.js.map +1 -0
  63. package/es/src/shapes/sceneSort.js +304 -24
  64. package/es/src/shapes/sceneSort.js.map +1 -1
  65. package/es/src/shapes/shapeConfig.js.map +1 -1
  66. package/es/src/utils/D3plusConfig.js.map +1 -1
  67. package/package.json +9 -9
  68. package/types/src/charts/Plot/index.d.ts +44 -7
  69. package/types/src/charts/Plot/pipeline.d.ts +2 -1
  70. package/types/src/charts/Plot/stackHelpers.d.ts +62 -4
  71. package/types/src/charts/viz/Viz.d.ts +31 -1
  72. package/types/src/charts/viz/vizTypes.d.ts +18 -0
  73. package/types/src/shapes/Image.d.ts +2 -3
  74. package/types/src/shapes/Shape.d.ts +2 -4
  75. package/types/src/shapes/hitAreaNode.d.ts +5 -4
  76. package/types/src/shapes/interactionPoints.d.ts +15 -0
  77. package/types/src/shapes/sceneSort.d.ts +83 -8
  78. package/types/src/shapes/shapeConfig.d.ts +7 -0
  79. package/types/src/utils/D3plusConfig.d.ts +19 -2
  80. package/umd/d3plus-core.full.js +2371 -672
  81. package/umd/d3plus-core.full.js.map +1 -1
  82. package/umd/d3plus-core.full.min.js +1506 -1156
  83. package/umd/d3plus-core.js +804 -259
  84. package/umd/d3plus-core.js.map +1 -1
  85. package/umd/d3plus-core.min.js +591 -390
@@ -1,5 +1,5 @@
1
1
  /*
2
- @d3plus/core v4.1.0
2
+ @d3plus/core v4.3.0
3
3
  Data visualization made easy. A javascript library that extends the popular D3.js to enable fast and beautiful visualizations.
4
4
  Copyright (c) 2026 D3plus - https://d3plus.org
5
5
  @license MIT
@@ -9142,13 +9142,69 @@
9142
9142
  return left instanceof right;
9143
9143
  }
9144
9144
  }
9145
+ /** Common named HTML entities for the DOM-free decode fallback. */ var NAMED_ENTITIES = {
9146
+ amp: "&",
9147
+ lt: "<",
9148
+ gt: ">",
9149
+ quot: '"',
9150
+ apos: "'",
9151
+ nbsp: " ",
9152
+ ndash: "–",
9153
+ mdash: "—",
9154
+ hellip: "…",
9155
+ copy: "©",
9156
+ reg: "®",
9157
+ trade: "™",
9158
+ deg: "°",
9159
+ middot: "·",
9160
+ bull: "•",
9161
+ laquo: "«",
9162
+ raquo: "»",
9163
+ times: "×",
9164
+ divide: "÷",
9165
+ lsquo: "‘",
9166
+ rsquo: "’",
9167
+ ldquo: "“",
9168
+ rdquo: "”",
9169
+ euro: "€",
9170
+ pound: "£",
9171
+ cent: "¢",
9172
+ yen: "¥",
9173
+ sect: "§",
9174
+ para: "¶",
9175
+ plusmn: "±"
9176
+ };
9177
+ /**
9178
+ * Decodes HTML entities without a DOM, for headless/server-side rendering where
9179
+ * `DOMParser` may be absent. Handles numeric (`&#160;`/`&#xA0;`) and the common
9180
+ * named entities above; unknown or out-of-range entities are left as-is.
9181
+ * Exported for testing; not part of the package's public API.
9182
+ * @param {String} input tag-stripped text
9183
+ */ function decodeEntities(input) {
9184
+ return input.replace(/&(#x[0-9a-fA-F]+|#[0-9]+|[a-zA-Z][a-zA-Z0-9]*);/g, function(match, code) {
9185
+ if (code[0] === "#") {
9186
+ var cp = code[1] === "x" ? parseInt(code.slice(2), 16) : parseInt(code.slice(1), 10);
9187
+ // Reject code points outside the Unicode range — String.fromCodePoint
9188
+ // throws on them; leave the raw entity in place instead.
9189
+ return cp <= 0x10ffff ? String.fromCodePoint(cp) : match;
9190
+ }
9191
+ var named = NAMED_ENTITIES[code];
9192
+ return named !== undefined ? named : match;
9193
+ });
9194
+ }
9145
9195
  /**
9146
- * Strips HTML and "un-escapes" escape characters.
9196
+ * Strips HTML and "un-escapes" escape characters. Uses `DOMParser` when present
9197
+ * (browser / jsdom) for full entity coverage, falling back to a DOM-free decode
9198
+ * so text measurement works in any headless environment.
9147
9199
  * @param {String} input
9148
9200
  */ function htmlDecode(input) {
9149
9201
  if (input.replace(/\s+/g, "") === "") return input;
9150
- var doc = new DOMParser().parseFromString(input.replace(/<[^>]+>/g, ""), "text/html");
9151
- return doc.documentElement ? doc.documentElement.textContent : input;
9202
+ var stripped = input.replace(/<[^>]+>/g, "");
9203
+ if (typeof DOMParser !== "undefined") {
9204
+ var doc = new DOMParser().parseFromString(stripped, "text/html");
9205
+ return doc.documentElement ? doc.documentElement.textContent : input;
9206
+ }
9207
+ return decodeEntities(stripped);
9152
9208
  }
9153
9209
  /**
9154
9210
  * Builds a CSS font shorthand string from a style object.
@@ -9651,16 +9707,16 @@
9651
9707
  return newObject;
9652
9708
  }
9653
9709
 
9654
- function _array_like_to_array$g(arr, len) {
9710
+ function _array_like_to_array$j(arr, len) {
9655
9711
  if (len == null || len > arr.length) len = arr.length;
9656
9712
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
9657
9713
  return arr2;
9658
9714
  }
9659
- function _array_with_holes$d(arr) {
9715
+ function _array_with_holes$f(arr) {
9660
9716
  if (Array.isArray(arr)) return arr;
9661
9717
  }
9662
- function _array_without_holes$7(arr) {
9663
- if (Array.isArray(arr)) return _array_like_to_array$g(arr);
9718
+ function _array_without_holes$9(arr) {
9719
+ if (Array.isArray(arr)) return _array_like_to_array$j(arr);
9664
9720
  }
9665
9721
  function _instanceof$4(left, right) {
9666
9722
  "@swc/helpers - instanceof";
@@ -9670,10 +9726,10 @@
9670
9726
  return left instanceof right;
9671
9727
  }
9672
9728
  }
9673
- function _iterable_to_array$7(iter) {
9729
+ function _iterable_to_array$9(iter) {
9674
9730
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
9675
9731
  }
9676
- function _iterable_to_array_limit$d(arr, i) {
9732
+ function _iterable_to_array_limit$f(arr, i) {
9677
9733
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
9678
9734
  if (_i == null) return;
9679
9735
  var _arr = [];
@@ -9697,25 +9753,25 @@
9697
9753
  }
9698
9754
  return _arr;
9699
9755
  }
9700
- function _non_iterable_rest$d() {
9756
+ function _non_iterable_rest$f() {
9701
9757
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
9702
9758
  }
9703
- function _non_iterable_spread$7() {
9759
+ function _non_iterable_spread$9() {
9704
9760
  throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
9705
9761
  }
9706
- function _sliced_to_array$d(arr, i) {
9707
- return _array_with_holes$d(arr) || _iterable_to_array_limit$d(arr, i) || _unsupported_iterable_to_array$g(arr, i) || _non_iterable_rest$d();
9762
+ function _sliced_to_array$f(arr, i) {
9763
+ return _array_with_holes$f(arr) || _iterable_to_array_limit$f(arr, i) || _unsupported_iterable_to_array$j(arr, i) || _non_iterable_rest$f();
9708
9764
  }
9709
- function _to_consumable_array$7(arr) {
9710
- return _array_without_holes$7(arr) || _iterable_to_array$7(arr) || _unsupported_iterable_to_array$g(arr) || _non_iterable_spread$7();
9765
+ function _to_consumable_array$9(arr) {
9766
+ return _array_without_holes$9(arr) || _iterable_to_array$9(arr) || _unsupported_iterable_to_array$j(arr) || _non_iterable_spread$9();
9711
9767
  }
9712
- function _unsupported_iterable_to_array$g(o, minLen) {
9768
+ function _unsupported_iterable_to_array$j(o, minLen) {
9713
9769
  if (!o) return;
9714
- if (typeof o === "string") return _array_like_to_array$g(o, minLen);
9770
+ if (typeof o === "string") return _array_like_to_array$j(o, minLen);
9715
9771
  var n = Object.prototype.toString.call(o).slice(8, -1);
9716
9772
  if (n === "Object" && o.constructor) n = o.constructor.name;
9717
9773
  if (n === "Map" || n === "Set") return Array.from(n);
9718
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$g(o, minLen);
9774
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$j(o, minLen);
9719
9775
  }
9720
9776
  /**
9721
9777
  @summary Extends the base behavior of d3.nest to allow for multiple depth levels.
@@ -9734,8 +9790,8 @@
9734
9790
  @param fns An array of key accessor functions, one per nesting level.
9735
9791
  */ function nestGroups(data, fns) {
9736
9792
  if (!fns.length) return data;
9737
- return _to_consumable_array$7(group(data, fns[0])).map(function(param) {
9738
- var _param = _sliced_to_array$d(param, 2), key = _param[0], values = _param[1];
9793
+ return _to_consumable_array$9(group(data, fns[0])).map(function(param) {
9794
+ var _param = _sliced_to_array$f(param, 2), key = _param[0], values = _param[1];
9739
9795
  return {
9740
9796
  key: key,
9741
9797
  values: nestGroups(values, fns.slice(1))
@@ -20540,7 +20596,7 @@
20540
20596
  }
20541
20597
  };
20542
20598
 
20543
- function _define_property$7(obj, key, value) {
20599
+ function _define_property$9(obj, key, value) {
20544
20600
  if (key in obj) {
20545
20601
  Object.defineProperty(obj, key, {
20546
20602
  value: value,
@@ -20562,7 +20618,7 @@
20562
20618
  });
20563
20619
  if (locale.location && isoLanguage) {
20564
20620
  var _obj;
20565
- locales.push((_obj = {}, _define_property$7(_obj, "name", locale.language), _define_property$7(_obj, "location", locale.location), _define_property$7(_obj, "tag", locale.tag), _define_property$7(_obj, "lcid", locale.id), _define_property$7(_obj, "iso639-2", isoCodes[isoLanguage]["iso639-2"]), _define_property$7(_obj, "iso639-1", isoCodes[isoLanguage]["iso639-1"]), _obj));
20621
+ locales.push((_obj = {}, _define_property$9(_obj, "name", locale.language), _define_property$9(_obj, "location", locale.location), _define_property$9(_obj, "tag", locale.tag), _define_property$9(_obj, "lcid", locale.id), _define_property$9(_obj, "iso639-2", isoCodes[isoLanguage]["iso639-2"]), _define_property$9(_obj, "iso639-1", isoCodes[isoLanguage]["iso639-1"]), _obj));
20566
20622
  }
20567
20623
  });
20568
20624
  var defaultLocales = {
@@ -21116,7 +21172,7 @@
21116
21172
  };
21117
21173
  return $;
21118
21174
  }
21119
- function paths() {
21175
+ function paths$1() {
21120
21176
  var width = 1;
21121
21177
  var height = 1;
21122
21178
  var size = 20;
@@ -21219,7 +21275,7 @@
21219
21275
  /* eslint import/no-anonymous-default-export: [2, {"allowObject": true}] */ var main = {
21220
21276
  circles: circles,
21221
21277
  lines: lines$1,
21222
- paths: paths
21278
+ paths: paths$1
21223
21279
  };
21224
21280
 
21225
21281
  function ownKeys$4(object, enumerableOnly) {
@@ -21894,15 +21950,15 @@
21894
21950
  };
21895
21951
  }
21896
21952
 
21897
- function _array_like_to_array$f(arr, len) {
21953
+ function _array_like_to_array$i(arr, len) {
21898
21954
  if (len == null || len > arr.length) len = arr.length;
21899
21955
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
21900
21956
  return arr2;
21901
21957
  }
21902
- function _array_with_holes$c(arr) {
21958
+ function _array_with_holes$e(arr) {
21903
21959
  if (Array.isArray(arr)) return arr;
21904
21960
  }
21905
- function _define_property$6(obj, key, value) {
21961
+ function _define_property$8(obj, key, value) {
21906
21962
  if (key in obj) {
21907
21963
  Object.defineProperty(obj, key, {
21908
21964
  value: value,
@@ -21915,7 +21971,7 @@
21915
21971
  }
21916
21972
  return obj;
21917
21973
  }
21918
- function _iterable_to_array_limit$c(arr, i) {
21974
+ function _iterable_to_array_limit$e(arr, i) {
21919
21975
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
21920
21976
  if (_i == null) return;
21921
21977
  var _arr = [];
@@ -21939,7 +21995,7 @@
21939
21995
  }
21940
21996
  return _arr;
21941
21997
  }
21942
- function _non_iterable_rest$c() {
21998
+ function _non_iterable_rest$e() {
21943
21999
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
21944
22000
  }
21945
22001
  function _object_spread$3(target) {
@@ -21952,7 +22008,7 @@
21952
22008
  }));
21953
22009
  }
21954
22010
  ownKeys.forEach(function(key) {
21955
- _define_property$6(target, key, source[key]);
22011
+ _define_property$8(target, key, source[key]);
21956
22012
  });
21957
22013
  }
21958
22014
  return target;
@@ -21976,16 +22032,16 @@
21976
22032
  }
21977
22033
  return target;
21978
22034
  }
21979
- function _sliced_to_array$c(arr, i) {
21980
- return _array_with_holes$c(arr) || _iterable_to_array_limit$c(arr, i) || _unsupported_iterable_to_array$f(arr, i) || _non_iterable_rest$c();
22035
+ function _sliced_to_array$e(arr, i) {
22036
+ return _array_with_holes$e(arr) || _iterable_to_array_limit$e(arr, i) || _unsupported_iterable_to_array$i(arr, i) || _non_iterable_rest$e();
21981
22037
  }
21982
- function _unsupported_iterable_to_array$f(o, minLen) {
22038
+ function _unsupported_iterable_to_array$i(o, minLen) {
21983
22039
  if (!o) return;
21984
- if (typeof o === "string") return _array_like_to_array$f(o, minLen);
22040
+ if (typeof o === "string") return _array_like_to_array$i(o, minLen);
21985
22041
  var n = Object.prototype.toString.call(o).slice(8, -1);
21986
22042
  if (n === "Object" && o.constructor) n = o.constructor.name;
21987
22043
  if (n === "Map" || n === "Set") return Array.from(n);
21988
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$f(o, minLen);
22044
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$i(o, minLen);
21989
22045
  }
21990
22046
  /**
21991
22047
  The default easing curve, identical to d3-transition's default (cubic in-out),
@@ -22167,8 +22223,8 @@
22167
22223
  var _ref, _ref1, _ref2, _ref3, _ref4;
22168
22224
  var _to_transform, _f_transform, _n_transform, _f_transform1, _n_transform1;
22169
22225
  var baseScale = (_ref = (_to_transform = to.transform) === null || _to_transform === void 0 ? void 0 : _to_transform.scale) !== null && _ref !== void 0 ? _ref : 1;
22170
- var _textVisualCenter = _sliced_to_array$c(textVisualCenter(n), 2), nvcx = _textVisualCenter[0], nvcy = _textVisualCenter[1];
22171
- var _textVisualCenter1 = _sliced_to_array$c(textVisualCenter(f5), 2), ovcx = _textVisualCenter1[0], ovcy = _textVisualCenter1[1];
22226
+ var _textVisualCenter = _sliced_to_array$e(textVisualCenter(n), 2), nvcx = _textVisualCenter[0], nvcy = _textVisualCenter[1];
22227
+ var _textVisualCenter1 = _sliced_to_array$e(textVisualCenter(f5), 2), ovcx = _textVisualCenter1[0], ovcy = _textVisualCenter1[1];
22172
22228
  var si = lerpNum(fromSize / toSize, 1);
22173
22229
  var pxI = lerpNum(((_ref1 = (_f_transform = f5.transform) === null || _f_transform === void 0 ? void 0 : _f_transform.x) !== null && _ref1 !== void 0 ? _ref1 : 0) + ovcx, ((_ref2 = (_n_transform = n.transform) === null || _n_transform === void 0 ? void 0 : _n_transform.x) !== null && _ref2 !== void 0 ? _ref2 : 0) + nvcx);
22174
22230
  var pyI = lerpNum(((_ref3 = (_f_transform1 = f5.transform) === null || _f_transform1 === void 0 ? void 0 : _f_transform1.y) !== null && _ref3 !== void 0 ? _ref3 : 0) + ovcy, ((_ref4 = (_n_transform1 = n.transform) === null || _n_transform1 === void 0 ? void 0 : _n_transform1.y) !== null && _ref4 !== void 0 ? _ref4 : 0) + nvcy);
@@ -22259,21 +22315,21 @@
22259
22315
  }
22260
22316
  }
22261
22317
 
22262
- function _array_like_to_array$e(arr, len) {
22318
+ function _array_like_to_array$h(arr, len) {
22263
22319
  if (len == null || len > arr.length) len = arr.length;
22264
22320
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
22265
22321
  return arr2;
22266
22322
  }
22267
- function _array_with_holes$b(arr) {
22323
+ function _array_with_holes$d(arr) {
22268
22324
  if (Array.isArray(arr)) return arr;
22269
22325
  }
22270
- function _array_without_holes$6(arr) {
22271
- if (Array.isArray(arr)) return _array_like_to_array$e(arr);
22326
+ function _array_without_holes$8(arr) {
22327
+ if (Array.isArray(arr)) return _array_like_to_array$h(arr);
22272
22328
  }
22273
- function _iterable_to_array$6(iter) {
22329
+ function _iterable_to_array$8(iter) {
22274
22330
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
22275
22331
  }
22276
- function _iterable_to_array_limit$b(arr, i) {
22332
+ function _iterable_to_array_limit$d(arr, i) {
22277
22333
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
22278
22334
  if (_i == null) return;
22279
22335
  var _arr = [];
@@ -22297,25 +22353,25 @@
22297
22353
  }
22298
22354
  return _arr;
22299
22355
  }
22300
- function _non_iterable_rest$b() {
22356
+ function _non_iterable_rest$d() {
22301
22357
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
22302
22358
  }
22303
- function _non_iterable_spread$6() {
22359
+ function _non_iterable_spread$8() {
22304
22360
  throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
22305
22361
  }
22306
- function _sliced_to_array$b(arr, i) {
22307
- return _array_with_holes$b(arr) || _iterable_to_array_limit$b(arr, i) || _unsupported_iterable_to_array$e(arr, i) || _non_iterable_rest$b();
22362
+ function _sliced_to_array$d(arr, i) {
22363
+ return _array_with_holes$d(arr) || _iterable_to_array_limit$d(arr, i) || _unsupported_iterable_to_array$h(arr, i) || _non_iterable_rest$d();
22308
22364
  }
22309
- function _to_consumable_array$6(arr) {
22310
- return _array_without_holes$6(arr) || _iterable_to_array$6(arr) || _unsupported_iterable_to_array$e(arr) || _non_iterable_spread$6();
22365
+ function _to_consumable_array$8(arr) {
22366
+ return _array_without_holes$8(arr) || _iterable_to_array$8(arr) || _unsupported_iterable_to_array$h(arr) || _non_iterable_spread$8();
22311
22367
  }
22312
- function _unsupported_iterable_to_array$e(o, minLen) {
22368
+ function _unsupported_iterable_to_array$h(o, minLen) {
22313
22369
  if (!o) return;
22314
- if (typeof o === "string") return _array_like_to_array$e(o, minLen);
22370
+ if (typeof o === "string") return _array_like_to_array$h(o, minLen);
22315
22371
  var n = Object.prototype.toString.call(o).slice(8, -1);
22316
22372
  if (n === "Object" && o.constructor) n = o.constructor.name;
22317
22373
  if (n === "Map" || n === "Set") return Array.from(n);
22318
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$e(o, minLen);
22374
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$h(o, minLen);
22319
22375
  }
22320
22376
  /**
22321
22377
  Motion-trail geometry shared by both backends. A trail is a tapering "cone"
@@ -22360,8 +22416,8 @@
22360
22416
  }), ys = pts.map(function(p) {
22361
22417
  return p[1];
22362
22418
  });
22363
- var minX = (_Math = Math).min.apply(_Math, _to_consumable_array$6(xs)), maxX = (_Math1 = Math).max.apply(_Math1, _to_consumable_array$6(xs));
22364
- var minY = (_Math2 = Math).min.apply(_Math2, _to_consumable_array$6(ys)), maxY = (_Math3 = Math).max.apply(_Math3, _to_consumable_array$6(ys));
22419
+ var minX = (_Math = Math).min.apply(_Math, _to_consumable_array$8(xs)), maxX = (_Math1 = Math).max.apply(_Math1, _to_consumable_array$8(xs));
22420
+ var minY = (_Math2 = Math).min.apply(_Math2, _to_consumable_array$8(ys)), maxY = (_Math3 = Math).max.apply(_Math3, _to_consumable_array$8(ys));
22365
22421
  return {
22366
22422
  x: minX,
22367
22423
  y: minY,
@@ -22395,7 +22451,7 @@
22395
22451
  hh
22396
22452
  ]
22397
22453
  ].map(function(param) {
22398
- var _param = _sliced_to_array$b(param, 2), x = _param[0], y = _param[1];
22454
+ var _param = _sliced_to_array$d(param, 2), x = _param[0], y = _param[1];
22399
22455
  return [
22400
22456
  cx + x * c - y * s,
22401
22457
  cy + x * s + y * c
@@ -22491,7 +22547,7 @@
22491
22547
  ])
22492
22548
  };
22493
22549
  }
22494
- return pathBox(convexHull(_to_consumable_array$6(rectCorners(A[0], A[1], aDims[0], aDims[1], rotate)).concat(_to_consumable_array$6(rectCorners(hx, hy, hDims[0], hDims[1], rotate)))));
22550
+ return pathBox(convexHull(_to_consumable_array$8(rectCorners(A[0], A[1], aDims[0], aDims[1], rotate)).concat(_to_consumable_array$8(rectCorners(hx, hy, hDims[0], hDims[1], rotate)))));
22495
22551
  }
22496
22552
  /**
22497
22553
  The trail's fill: a gradient (objectBoundingBox units) along the travel
@@ -22583,20 +22639,20 @@
22583
22639
  };
22584
22640
  }
22585
22641
 
22586
- function _array_like_to_array$d(arr, len) {
22642
+ function _array_like_to_array$g(arr, len) {
22587
22643
  if (len == null || len > arr.length) len = arr.length;
22588
22644
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
22589
22645
  return arr2;
22590
22646
  }
22591
- function _array_without_holes$5(arr) {
22592
- if (Array.isArray(arr)) return _array_like_to_array$d(arr);
22647
+ function _array_without_holes$7(arr) {
22648
+ if (Array.isArray(arr)) return _array_like_to_array$g(arr);
22593
22649
  }
22594
- function _class_call_check$3(instance, Constructor) {
22650
+ function _class_call_check$5(instance, Constructor) {
22595
22651
  if (!(instance instanceof Constructor)) {
22596
22652
  throw new TypeError("Cannot call a class as a function");
22597
22653
  }
22598
22654
  }
22599
- function _defineProperties$3(target, props) {
22655
+ function _defineProperties$5(target, props) {
22600
22656
  for(var i = 0; i < props.length; i++){
22601
22657
  var descriptor = props[i];
22602
22658
  descriptor.enumerable = descriptor.enumerable || false;
@@ -22605,11 +22661,11 @@
22605
22661
  Object.defineProperty(target, descriptor.key, descriptor);
22606
22662
  }
22607
22663
  }
22608
- function _create_class$3(Constructor, protoProps, staticProps) {
22609
- if (protoProps) _defineProperties$3(Constructor.prototype, protoProps);
22664
+ function _create_class$5(Constructor, protoProps, staticProps) {
22665
+ if (protoProps) _defineProperties$5(Constructor.prototype, protoProps);
22610
22666
  return Constructor;
22611
22667
  }
22612
- function _define_property$5(obj, key, value) {
22668
+ function _define_property$7(obj, key, value) {
22613
22669
  if (key in obj) {
22614
22670
  Object.defineProperty(obj, key, {
22615
22671
  value: value,
@@ -22622,10 +22678,10 @@
22622
22678
  }
22623
22679
  return obj;
22624
22680
  }
22625
- function _iterable_to_array$5(iter) {
22681
+ function _iterable_to_array$7(iter) {
22626
22682
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
22627
22683
  }
22628
- function _non_iterable_spread$5() {
22684
+ function _non_iterable_spread$7() {
22629
22685
  throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
22630
22686
  }
22631
22687
  function _object_spread$2(target) {
@@ -22638,7 +22694,7 @@
22638
22694
  }));
22639
22695
  }
22640
22696
  ownKeys.forEach(function(key) {
22641
- _define_property$5(target, key, source[key]);
22697
+ _define_property$7(target, key, source[key]);
22642
22698
  });
22643
22699
  }
22644
22700
  return target;
@@ -22662,23 +22718,23 @@
22662
22718
  }
22663
22719
  return target;
22664
22720
  }
22665
- function _to_consumable_array$5(arr) {
22666
- return _array_without_holes$5(arr) || _iterable_to_array$5(arr) || _unsupported_iterable_to_array$d(arr) || _non_iterable_spread$5();
22721
+ function _to_consumable_array$7(arr) {
22722
+ return _array_without_holes$7(arr) || _iterable_to_array$7(arr) || _unsupported_iterable_to_array$g(arr) || _non_iterable_spread$7();
22667
22723
  }
22668
- function _unsupported_iterable_to_array$d(o, minLen) {
22724
+ function _unsupported_iterable_to_array$g(o, minLen) {
22669
22725
  if (!o) return;
22670
- if (typeof o === "string") return _array_like_to_array$d(o, minLen);
22726
+ if (typeof o === "string") return _array_like_to_array$g(o, minLen);
22671
22727
  var n = Object.prototype.toString.call(o).slice(8, -1);
22672
22728
  if (n === "Object" && o.constructor) n = o.constructor.name;
22673
22729
  if (n === "Map" || n === "Set") return Array.from(n);
22674
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$d(o, minLen);
22730
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$g(o, minLen);
22675
22731
  }
22676
22732
  var TrailLog = /*#__PURE__*/ function() {
22677
22733
  function TrailLog() {
22678
- _class_call_check$3(this, TrailLog);
22679
- _define_property$5(this, "map", new Map());
22734
+ _class_call_check$5(this, TrailLog);
22735
+ _define_property$7(this, "map", new Map());
22680
22736
  }
22681
- _create_class$3(TrailLog, [
22737
+ _create_class$5(TrailLog, [
22682
22738
  {
22683
22739
  /**
22684
22740
  Fold a mark's current geometry into its history, keyed by the timeline value
@@ -22750,7 +22806,7 @@
22750
22806
  // instead of retracting the whole jump and detaching.
22751
22807
  var forwardInFlight = ((_e_animating1 = e.animating) === null || _e_animating1 === void 0 ? void 0 : _e_animating1.dir) === 1 ? e.animating.seg : null;
22752
22808
  e.animating = null;
22753
- var all = forwardInFlight ? _to_consumable_array$5(e.committed).concat([
22809
+ var all = forwardInFlight ? _to_consumable_array$7(e.committed).concat([
22754
22810
  forwardInFlight
22755
22811
  ]) : e.committed;
22756
22812
  e.committed = [];
@@ -24984,7 +25040,7 @@
24984
25040
  return none(series).reverse();
24985
25041
  }
24986
25042
 
24987
- var d3Shape = /*#__PURE__*/Object.freeze({
25043
+ var paths = /*#__PURE__*/Object.freeze({
24988
25044
  __proto__: null,
24989
25045
  arc: arc,
24990
25046
  area: d3area,
@@ -25100,15 +25156,15 @@
25100
25156
  }))) !== null && _gen !== void 0 ? _gen : "";
25101
25157
  }
25102
25158
 
25103
- function _array_like_to_array$c(arr, len) {
25159
+ function _array_like_to_array$f(arr, len) {
25104
25160
  if (len == null || len > arr.length) len = arr.length;
25105
25161
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
25106
25162
  return arr2;
25107
25163
  }
25108
- function _array_with_holes$a(arr) {
25164
+ function _array_with_holes$c(arr) {
25109
25165
  if (Array.isArray(arr)) return arr;
25110
25166
  }
25111
- function _iterable_to_array_limit$a(arr, i) {
25167
+ function _iterable_to_array_limit$c(arr, i) {
25112
25168
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
25113
25169
  if (_i == null) return;
25114
25170
  var _arr = [];
@@ -25132,19 +25188,19 @@
25132
25188
  }
25133
25189
  return _arr;
25134
25190
  }
25135
- function _non_iterable_rest$a() {
25191
+ function _non_iterable_rest$c() {
25136
25192
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
25137
25193
  }
25138
- function _sliced_to_array$a(arr, i) {
25139
- return _array_with_holes$a(arr) || _iterable_to_array_limit$a(arr, i) || _unsupported_iterable_to_array$c(arr, i) || _non_iterable_rest$a();
25194
+ function _sliced_to_array$c(arr, i) {
25195
+ return _array_with_holes$c(arr) || _iterable_to_array_limit$c(arr, i) || _unsupported_iterable_to_array$f(arr, i) || _non_iterable_rest$c();
25140
25196
  }
25141
- function _unsupported_iterable_to_array$c(o, minLen) {
25197
+ function _unsupported_iterable_to_array$f(o, minLen) {
25142
25198
  if (!o) return;
25143
- if (typeof o === "string") return _array_like_to_array$c(o, minLen);
25199
+ if (typeof o === "string") return _array_like_to_array$f(o, minLen);
25144
25200
  var n = Object.prototype.toString.call(o).slice(8, -1);
25145
25201
  if (n === "Object" && o.constructor) n = o.constructor.name;
25146
25202
  if (n === "Map" || n === "Set") return Array.from(n);
25147
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$c(o, minLen);
25203
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$f(o, minLen);
25148
25204
  }
25149
25205
  var SVG_NS$1 = "http://www.w3.org/2000/svg";
25150
25206
  var XLINK_NS = "http://www.w3.org/1999/xlink";
@@ -25204,8 +25260,8 @@
25204
25260
  var pt = prev.transform || {};
25205
25261
  var nt = node.transform || {};
25206
25262
  var orot = (_pt_rotate = pt.rotate) !== null && _pt_rotate !== void 0 ? _pt_rotate : 0, nrot = (_nt_rotate = nt.rotate) !== null && _nt_rotate !== void 0 ? _nt_rotate : 0;
25207
- var _textVisualCenter = _sliced_to_array$a(textVisualCenter(node), 2), nvcx = _textVisualCenter[0], nvcy = _textVisualCenter[1];
25208
- var _textVisualCenter1 = _sliced_to_array$a(textVisualCenter(prev), 2), ovcx = _textVisualCenter1[0], ovcy = _textVisualCenter1[1];
25263
+ var _textVisualCenter = _sliced_to_array$c(textVisualCenter(node), 2), nvcx = _textVisualCenter[0], nvcy = _textVisualCenter[1];
25264
+ var _textVisualCenter1 = _sliced_to_array$c(textVisualCenter(prev), 2), ovcx = _textVisualCenter1[0], ovcy = _textVisualCenter1[1];
25209
25265
  // Visual-center positions in the parent frame (origin + visual center).
25210
25266
  var oldCx = ((_pt_x = pt.x) !== null && _pt_x !== void 0 ? _pt_x : 0) + ovcx, oldCy = ((_pt_y = pt.y) !== null && _pt_y !== void 0 ? _pt_y : 0) + ovcy;
25211
25267
  var newCx = ((_nt_x = nt.x) !== null && _nt_x !== void 0 ? _nt_x : 0) + nvcx, newCy = ((_nt_y = nt.y) !== null && _nt_y !== void 0 ? _nt_y : 0) + nvcy;
@@ -25341,7 +25397,8 @@
25341
25397
  setPath(target, node.d, animated);
25342
25398
  break;
25343
25399
  case "image":
25344
- target.attr("x", node.x).attr("y", node.y).attr("width", node.width).attr("height", node.height);
25400
+ var _node_preserveAspectRatio;
25401
+ target.attr("x", node.x).attr("y", node.y).attr("width", node.width).attr("height", node.height).attr("preserveAspectRatio", (_node_preserveAspectRatio = node.preserveAspectRatio) !== null && _node_preserveAspectRatio !== void 0 ? _node_preserveAspectRatio : null);
25345
25402
  break;
25346
25403
  case "text":
25347
25404
  target.attr("x", node.x).attr("y", node.y);
@@ -25351,12 +25408,12 @@
25351
25408
  target.attr("transform", transformStr(node));
25352
25409
  }
25353
25410
 
25354
- function _class_call_check$2(instance, Constructor) {
25411
+ function _class_call_check$4(instance, Constructor) {
25355
25412
  if (!(instance instanceof Constructor)) {
25356
25413
  throw new TypeError("Cannot call a class as a function");
25357
25414
  }
25358
25415
  }
25359
- function _defineProperties$2(target, props) {
25416
+ function _defineProperties$4(target, props) {
25360
25417
  for(var i = 0; i < props.length; i++){
25361
25418
  var descriptor = props[i];
25362
25419
  descriptor.enumerable = descriptor.enumerable || false;
@@ -25365,11 +25422,11 @@
25365
25422
  Object.defineProperty(target, descriptor.key, descriptor);
25366
25423
  }
25367
25424
  }
25368
- function _create_class$2(Constructor, protoProps, staticProps) {
25369
- if (protoProps) _defineProperties$2(Constructor.prototype, protoProps);
25425
+ function _create_class$4(Constructor, protoProps, staticProps) {
25426
+ if (protoProps) _defineProperties$4(Constructor.prototype, protoProps);
25370
25427
  return Constructor;
25371
25428
  }
25372
- function _define_property$4(obj, key, value) {
25429
+ function _define_property$6(obj, key, value) {
25373
25430
  if (key in obj) {
25374
25431
  Object.defineProperty(obj, key, {
25375
25432
  value: value,
@@ -25492,17 +25549,17 @@
25492
25549
  renderer's (possibly not-yet-mounted) state.
25493
25550
  */ var TrailGradients = /*#__PURE__*/ function() {
25494
25551
  function TrailGradients(defs, uid) {
25495
- _class_call_check$2(this, TrailGradients);
25496
- _define_property$4(this, "defs", void 0);
25497
- _define_property$4(this, "uid", void 0);
25498
- _define_property$4(this, "map", void 0);
25499
- _define_property$4(this, "seq", void 0);
25552
+ _class_call_check$4(this, TrailGradients);
25553
+ _define_property$6(this, "defs", void 0);
25554
+ _define_property$6(this, "uid", void 0);
25555
+ _define_property$6(this, "map", void 0);
25556
+ _define_property$6(this, "seq", void 0);
25500
25557
  this.defs = defs;
25501
25558
  this.uid = uid;
25502
25559
  this.map = new Map();
25503
25560
  this.seq = 0;
25504
25561
  }
25505
- _create_class$2(TrailGradients, [
25562
+ _create_class$4(TrailGradients, [
25506
25563
  {
25507
25564
  /** Create/update this mark's gradient from a `gradient:<json>` token; returns its url. */ key: "apply",
25508
25565
  value: function apply(key, fill) {
@@ -25866,23 +25923,23 @@
25866
25923
  }
25867
25924
  }
25868
25925
 
25869
- function _array_like_to_array$b(arr, len) {
25926
+ function _array_like_to_array$e(arr, len) {
25870
25927
  if (len == null || len > arr.length) len = arr.length;
25871
25928
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
25872
25929
  return arr2;
25873
25930
  }
25874
- function _array_with_holes$9(arr) {
25931
+ function _array_with_holes$b(arr) {
25875
25932
  if (Array.isArray(arr)) return arr;
25876
25933
  }
25877
- function _array_without_holes$4(arr) {
25878
- if (Array.isArray(arr)) return _array_like_to_array$b(arr);
25934
+ function _array_without_holes$6(arr) {
25935
+ if (Array.isArray(arr)) return _array_like_to_array$e(arr);
25879
25936
  }
25880
- function _class_call_check$1(instance, Constructor) {
25937
+ function _class_call_check$3(instance, Constructor) {
25881
25938
  if (!(instance instanceof Constructor)) {
25882
25939
  throw new TypeError("Cannot call a class as a function");
25883
25940
  }
25884
25941
  }
25885
- function _defineProperties$1(target, props) {
25942
+ function _defineProperties$3(target, props) {
25886
25943
  for(var i = 0; i < props.length; i++){
25887
25944
  var descriptor = props[i];
25888
25945
  descriptor.enumerable = descriptor.enumerable || false;
@@ -25891,11 +25948,11 @@
25891
25948
  Object.defineProperty(target, descriptor.key, descriptor);
25892
25949
  }
25893
25950
  }
25894
- function _create_class$1(Constructor, protoProps, staticProps) {
25895
- if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
25951
+ function _create_class$3(Constructor, protoProps, staticProps) {
25952
+ if (protoProps) _defineProperties$3(Constructor.prototype, protoProps);
25896
25953
  return Constructor;
25897
25954
  }
25898
- function _define_property$3(obj, key, value) {
25955
+ function _define_property$5(obj, key, value) {
25899
25956
  if (key in obj) {
25900
25957
  Object.defineProperty(obj, key, {
25901
25958
  value: value,
@@ -25908,10 +25965,10 @@
25908
25965
  }
25909
25966
  return obj;
25910
25967
  }
25911
- function _iterable_to_array$4(iter) {
25968
+ function _iterable_to_array$6(iter) {
25912
25969
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
25913
25970
  }
25914
- function _iterable_to_array_limit$9(arr, i) {
25971
+ function _iterable_to_array_limit$b(arr, i) {
25915
25972
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
25916
25973
  if (_i == null) return;
25917
25974
  var _arr = [];
@@ -25935,25 +25992,25 @@
25935
25992
  }
25936
25993
  return _arr;
25937
25994
  }
25938
- function _non_iterable_rest$9() {
25995
+ function _non_iterable_rest$b() {
25939
25996
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
25940
25997
  }
25941
- function _non_iterable_spread$4() {
25998
+ function _non_iterable_spread$6() {
25942
25999
  throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
25943
26000
  }
25944
- function _sliced_to_array$9(arr, i) {
25945
- return _array_with_holes$9(arr) || _iterable_to_array_limit$9(arr, i) || _unsupported_iterable_to_array$b(arr, i) || _non_iterable_rest$9();
26001
+ function _sliced_to_array$b(arr, i) {
26002
+ return _array_with_holes$b(arr) || _iterable_to_array_limit$b(arr, i) || _unsupported_iterable_to_array$e(arr, i) || _non_iterable_rest$b();
25946
26003
  }
25947
- function _to_consumable_array$4(arr) {
25948
- return _array_without_holes$4(arr) || _iterable_to_array$4(arr) || _unsupported_iterable_to_array$b(arr) || _non_iterable_spread$4();
26004
+ function _to_consumable_array$6(arr) {
26005
+ return _array_without_holes$6(arr) || _iterable_to_array$6(arr) || _unsupported_iterable_to_array$e(arr) || _non_iterable_spread$6();
25949
26006
  }
25950
- function _unsupported_iterable_to_array$b(o, minLen) {
26007
+ function _unsupported_iterable_to_array$e(o, minLen) {
25951
26008
  if (!o) return;
25952
- if (typeof o === "string") return _array_like_to_array$b(o, minLen);
26009
+ if (typeof o === "string") return _array_like_to_array$e(o, minLen);
25953
26010
  var n = Object.prototype.toString.call(o).slice(8, -1);
25954
26011
  if (n === "Object" && o.constructor) n = o.constructor.name;
25955
26012
  if (n === "Map" || n === "Set") return Array.from(n);
25956
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$b(o, minLen);
26013
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$e(o, minLen);
25957
26014
  }
25958
26015
  /**
25959
26016
  A Renderer backend that realizes a Scene as SVG, using a keyed enter/update/exit
@@ -25971,45 +26028,49 @@
25971
26028
  var SvgRenderer = /*#__PURE__*/ function() {
25972
26029
  function SvgRenderer() {
25973
26030
  var _this = this;
25974
- _class_call_check$1(this, SvgRenderer);
25975
- _define_property$3(this, "kind", "svg");
25976
- /** Unique per-instance prefix for this renderer's document-scoped def ids. */ _define_property$3(this, "_uid", ++rendererInstanceSeq);
25977
- _define_property$3(this, "_target", void 0);
25978
- _define_property$3(this, "_svg", void 0);
25979
- _define_property$3(this, "_root", void 0);
25980
- /** Per-mark position history for persistent motion trails. */ _define_property$3(this, "_trailLog", new TrailLog());
25981
- /** Whether persistent trails are active this draw (single-period timeline). */ _define_property$3(this, "_trailActive", false);
25982
- /** Lazy <defs> for clipPaths / patterns. Created on first use. */ _define_property$3(this, "_defs", void 0);
25983
- /** Stable id counter so each GroupNode clip gets a unique <clipPath>. */ _define_property$3(this, "_clipIds", new Map());
25984
- _define_property$3(this, "_clipSeq", 0);
25985
- /** Sibling host for HtmlOverlayNode mounts. Positioned absolutely over the svg. */ _define_property$3(this, "_overlayHost", void 0);
25986
- _define_property$3(this, "_scene", void 0);
25987
- _define_property$3(this, "_index", new Map());
25988
- _define_property$3(this, "_textureDefs", new Map());
25989
- /** Cache of `gradient:<json>` token → `url(#id)`, materialized in <defs>. */ _define_property$3(this, "_gradientDefs", new Map());
25990
- _define_property$3(this, "_gradientSeq", 0);
25991
- /** Reused per-mark userSpaceOnUse gradients for persistent trails. */ _define_property$3(this, "_trailGrads", new TrailGradients(function() {
26031
+ _class_call_check$3(this, SvgRenderer);
26032
+ _define_property$5(this, "kind", "svg");
26033
+ /** Unique per-instance prefix for this renderer's document-scoped def ids. */ _define_property$5(this, "_uid", ++rendererInstanceSeq);
26034
+ _define_property$5(this, "_target", void 0);
26035
+ _define_property$5(this, "_svg", void 0);
26036
+ _define_property$5(this, "_root", void 0);
26037
+ /** Per-mark position history for persistent motion trails. */ _define_property$5(this, "_trailLog", new TrailLog());
26038
+ /** Whether persistent trails are active this draw (single-period timeline). */ _define_property$5(this, "_trailActive", false);
26039
+ /** Lazy <defs> for clipPaths / patterns. Created on first use. */ _define_property$5(this, "_defs", void 0);
26040
+ /** Stable id counter so each GroupNode clip gets a unique <clipPath>. */ _define_property$5(this, "_clipIds", new Map());
26041
+ _define_property$5(this, "_clipSeq", 0);
26042
+ /** Sibling host for HtmlOverlayNode mounts. Positioned absolutely over the svg. */ _define_property$5(this, "_overlayHost", void 0);
26043
+ _define_property$5(this, "_scene", void 0);
26044
+ _define_property$5(this, "_index", new Map());
26045
+ _define_property$5(this, "_textureDefs", new Map());
26046
+ /** Cache of `gradient:<json>` token → `url(#id)`, materialized in <defs>. */ _define_property$5(this, "_gradientDefs", new Map());
26047
+ _define_property$5(this, "_gradientSeq", 0);
26048
+ /** Reused per-mark userSpaceOnUse gradients for persistent trails. */ _define_property$5(this, "_trailGrads", new TrailGradients(function() {
25992
26049
  return _this._ensureDefs();
25993
26050
  }, function() {
25994
26051
  return _this._uid;
25995
26052
  }));
25996
- _define_property$3(this, "_handlers", new Set());
25997
- _define_property$3(this, "_domListeners", {});
25998
- _define_property$3(this, "_listening", false);
25999
- _define_property$3(this, "_hoverKey", null);
26000
- _define_property$3(this, "_timers", new Set());
26001
- _define_property$3(this, "_invalidatePointerRect", null);
26002
- _define_property$3(this, "_removePointerRectListeners", null);
26003
- /** Cancel handle for the latest drawScene transition; flipped on overlap. */ _define_property$3(this, "_cancelDraw", null);
26004
- /** Marks `_index` as needing a rebuild before the next external read. */ _define_property$3(this, "_indexDirty", true);
26005
- }
26006
- _create_class$1(SvgRenderer, [
26053
+ _define_property$5(this, "_handlers", new Set());
26054
+ _define_property$5(this, "_domListeners", {});
26055
+ _define_property$5(this, "_listening", false);
26056
+ _define_property$5(this, "_hoverKey", null);
26057
+ _define_property$5(this, "_timers", new Set());
26058
+ _define_property$5(this, "_invalidatePointerRect", null);
26059
+ _define_property$5(this, "_removePointerRectListeners", null);
26060
+ /** Cancel handle for the latest drawScene transition; flipped on overlap. */ _define_property$5(this, "_cancelDraw", null);
26061
+ /** Marks `_index` as needing a rebuild before the next external read. */ _define_property$5(this, "_indexDirty", true);
26062
+ }
26063
+ _create_class$3(SvgRenderer, [
26007
26064
  {
26008
26065
  key: "mount",
26009
26066
  value: function mount(target) {
26010
26067
  this._target = target;
26011
26068
  var svg = document.createElementNS(SVG_NS$1, "svg");
26012
26069
  svg.setAttribute("class", "d3plus-render-svg");
26070
+ // Explicit namespace so the serialized output (toSVGString → outerHTML) is a
26071
+ // valid standalone SVG. Browsers infer it from the DOM namespace, but the
26072
+ // HTML serializer doesn't always emit it; a redundant attribute is harmless.
26073
+ svg.setAttribute("xmlns", SVG_NS$1);
26013
26074
  svg.style.display = "block";
26014
26075
  // Transparent background — without this, default UA stylesheet may
26015
26076
  // give the svg a white background, which briefly bleeds through
@@ -26194,7 +26255,7 @@
26194
26255
  if (k in t) {
26195
26256
  var _t;
26196
26257
  var v = config[k];
26197
- if (Array.isArray(v)) (_t = t)[k].apply(_t, _to_consumable_array$4(v));
26258
+ if (Array.isArray(v)) (_t = t)[k].apply(_t, _to_consumable_array$6(v));
26198
26259
  else t[k](v);
26199
26260
  }
26200
26261
  }
@@ -26232,7 +26293,7 @@
26232
26293
  break;
26233
26294
  }
26234
26295
  }
26235
- var ordered = needsSort ? _to_consumable_array$4(svgChildren).sort(function(a, b) {
26296
+ var ordered = needsSort ? _to_consumable_array$6(svgChildren).sort(function(a, b) {
26236
26297
  var _a_z, _b_z;
26237
26298
  return ((_a_z = a.z) !== null && _a_z !== void 0 ? _a_z : 0) - ((_b_z = b.z) !== null && _b_z !== void 0 ? _b_z : 0);
26238
26299
  }) : svgChildren;
@@ -26570,7 +26631,7 @@
26570
26631
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
26571
26632
  try {
26572
26633
  for(var _iterator = Object.entries(this._domListeners)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
26573
- var _step_value = _sliced_to_array$9(_step.value, 2), k = _step_value[0], fn = _step_value[1];
26634
+ var _step_value = _sliced_to_array$b(_step.value, 2), k = _step_value[0], fn = _step_value[1];
26574
26635
  svg.addEventListener(k, fn);
26575
26636
  }
26576
26637
  } catch (err) {
@@ -26648,7 +26709,7 @@
26648
26709
  var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
26649
26710
  try {
26650
26711
  for(var _iterator1 = Object.entries(this._domListeners)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
26651
- var _step_value = _sliced_to_array$9(_step1.value, 2), k = _step_value[0], fn = _step_value[1];
26712
+ var _step_value = _sliced_to_array$b(_step1.value, 2), k = _step_value[0], fn = _step_value[1];
26652
26713
  this._svg.removeEventListener(k, fn);
26653
26714
  }
26654
26715
  } catch (err) {
@@ -26697,15 +26758,15 @@
26697
26758
  return SvgRenderer;
26698
26759
  }();
26699
26760
 
26700
- function _array_like_to_array$a(arr, len) {
26761
+ function _array_like_to_array$d(arr, len) {
26701
26762
  if (len == null || len > arr.length) len = arr.length;
26702
26763
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
26703
26764
  return arr2;
26704
26765
  }
26705
- function _array_with_holes$8(arr) {
26766
+ function _array_with_holes$a(arr) {
26706
26767
  if (Array.isArray(arr)) return arr;
26707
26768
  }
26708
- function _define_property$2(obj, key, value) {
26769
+ function _define_property$4(obj, key, value) {
26709
26770
  if (key in obj) {
26710
26771
  Object.defineProperty(obj, key, {
26711
26772
  value: value,
@@ -26718,7 +26779,7 @@
26718
26779
  }
26719
26780
  return obj;
26720
26781
  }
26721
- function _iterable_to_array_limit$8(arr, i) {
26782
+ function _iterable_to_array_limit$a(arr, i) {
26722
26783
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
26723
26784
  if (_i == null) return;
26724
26785
  var _arr = [];
@@ -26742,7 +26803,7 @@
26742
26803
  }
26743
26804
  return _arr;
26744
26805
  }
26745
- function _non_iterable_rest$8() {
26806
+ function _non_iterable_rest$a() {
26746
26807
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
26747
26808
  }
26748
26809
  function _object_spread$1(target) {
@@ -26755,7 +26816,7 @@
26755
26816
  }));
26756
26817
  }
26757
26818
  ownKeys.forEach(function(key) {
26758
- _define_property$2(target, key, source[key]);
26819
+ _define_property$4(target, key, source[key]);
26759
26820
  });
26760
26821
  }
26761
26822
  return target;
@@ -26779,16 +26840,16 @@
26779
26840
  }
26780
26841
  return target;
26781
26842
  }
26782
- function _sliced_to_array$8(arr, i) {
26783
- return _array_with_holes$8(arr) || _iterable_to_array_limit$8(arr, i) || _unsupported_iterable_to_array$a(arr, i) || _non_iterable_rest$8();
26843
+ function _sliced_to_array$a(arr, i) {
26844
+ return _array_with_holes$a(arr) || _iterable_to_array_limit$a(arr, i) || _unsupported_iterable_to_array$d(arr, i) || _non_iterable_rest$a();
26784
26845
  }
26785
- function _unsupported_iterable_to_array$a(o, minLen) {
26846
+ function _unsupported_iterable_to_array$d(o, minLen) {
26786
26847
  if (!o) return;
26787
- if (typeof o === "string") return _array_like_to_array$a(o, minLen);
26848
+ if (typeof o === "string") return _array_like_to_array$d(o, minLen);
26788
26849
  var n = Object.prototype.toString.call(o).slice(8, -1);
26789
26850
  if (n === "Object" && o.constructor) n = o.constructor.name;
26790
26851
  if (n === "Map" || n === "Set") return Array.from(n);
26791
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$a(o, minLen);
26852
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$d(o, minLen);
26792
26853
  }
26793
26854
  /**
26794
26855
  Reads a motion-trail spec off a moving update-pair of trailed mark nodes,
@@ -26885,7 +26946,7 @@
26885
26946
  var trailSpecs = [];
26886
26947
  var persist = [];
26887
26948
  var updaters = update.map(function(param) {
26888
- var _param = _sliced_to_array$8(param, 2), a = _param[0], b = _param[1];
26949
+ var _param = _sliced_to_array$a(param, 2), a = _param[0], b = _param[1];
26889
26950
  if (a.type === "group" && b.type === "group") {
26890
26951
  return wrapGroup(interpolateNode(a, b), interpolateChildren(a.children, b.children, log));
26891
26952
  }
@@ -27045,15 +27106,15 @@
27045
27106
  };
27046
27107
  }
27047
27108
 
27048
- function _array_like_to_array$9(arr, len) {
27109
+ function _array_like_to_array$c(arr, len) {
27049
27110
  if (len == null || len > arr.length) len = arr.length;
27050
27111
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
27051
27112
  return arr2;
27052
27113
  }
27053
- function _array_with_holes$7(arr) {
27114
+ function _array_with_holes$9(arr) {
27054
27115
  if (Array.isArray(arr)) return arr;
27055
27116
  }
27056
- function _iterable_to_array_limit$7(arr, i) {
27117
+ function _iterable_to_array_limit$9(arr, i) {
27057
27118
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
27058
27119
  if (_i == null) return;
27059
27120
  var _arr = [];
@@ -27077,19 +27138,19 @@
27077
27138
  }
27078
27139
  return _arr;
27079
27140
  }
27080
- function _non_iterable_rest$7() {
27141
+ function _non_iterable_rest$9() {
27081
27142
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
27082
27143
  }
27083
- function _sliced_to_array$7(arr, i) {
27084
- return _array_with_holes$7(arr) || _iterable_to_array_limit$7(arr, i) || _unsupported_iterable_to_array$9(arr, i) || _non_iterable_rest$7();
27144
+ function _sliced_to_array$9(arr, i) {
27145
+ return _array_with_holes$9(arr) || _iterable_to_array_limit$9(arr, i) || _unsupported_iterable_to_array$c(arr, i) || _non_iterable_rest$9();
27085
27146
  }
27086
- function _unsupported_iterable_to_array$9(o, minLen) {
27147
+ function _unsupported_iterable_to_array$c(o, minLen) {
27087
27148
  if (!o) return;
27088
- if (typeof o === "string") return _array_like_to_array$9(o, minLen);
27149
+ if (typeof o === "string") return _array_like_to_array$c(o, minLen);
27089
27150
  var n = Object.prototype.toString.call(o).slice(8, -1);
27090
27151
  if (n === "Object" && o.constructor) n = o.constructor.name;
27091
27152
  if (n === "Map" || n === "Set") return Array.from(n);
27092
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$9(o, minLen);
27153
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$c(o, minLen);
27093
27154
  }
27094
27155
  var identity$7 = [
27095
27156
  1,
@@ -27164,7 +27225,7 @@
27164
27225
  0
27165
27226
  ];
27166
27227
  if (tr.rotateAnchor) {
27167
- var _tr_rotateAnchor = _sliced_to_array$7(tr.rotateAnchor, 2), ax = _tr_rotateAnchor[0], ay = _tr_rotateAnchor[1];
27228
+ var _tr_rotateAnchor = _sliced_to_array$9(tr.rotateAnchor, 2), ax = _tr_rotateAnchor[0], ay = _tr_rotateAnchor[1];
27168
27229
  m = multiply$1(m, multiply$1([
27169
27230
  1,
27170
27231
  0,
@@ -27187,7 +27248,21 @@
27187
27248
  return m;
27188
27249
  }
27189
27250
 
27190
- /** Issues the current-path commands for a node's geometry into the context. */ function pathFor(ctx, node) {
27251
+ /** Issues the current-path commands for a node's geometry into the context. */ /**
27252
+ Hit-tests a `path` node: its fill region first, then — for a stroked/unfilled
27253
+ path (a Line, or its fat transparent hit area) — the stroke at the node's
27254
+ width. Assumes an identity CTM (as at pick time), so `lineWidth` shares the
27255
+ path's local units.
27256
+ */ function pathHit(ctx, node, lx, ly) {
27257
+ var _node_paint;
27258
+ var p = new Path2D(node.d);
27259
+ if (ctx.isPointInPath(p, lx, ly)) return true;
27260
+ var sw = (_node_paint = node.paint) === null || _node_paint === void 0 ? void 0 : _node_paint.strokeWidth;
27261
+ if (!sw) return false;
27262
+ ctx.lineWidth = sw;
27263
+ return ctx.isPointInStroke(p, lx, ly);
27264
+ }
27265
+ function pathFor(ctx, node) {
27191
27266
  switch(node.type){
27192
27267
  case "rect":
27193
27268
  ctx.beginPath();
@@ -27358,7 +27433,38 @@
27358
27433
  used to honor `vector-effect: non-scaling-stroke`, which holds a stroke at a
27359
27434
  constant screen width regardless of an ancestor zoom/scale. It's 1 when
27360
27435
  nothing above the node scales, so unzoomed output is unchanged.
27361
- */ function paint(ctx, node, alpha, path, resolvePattern) {
27436
+ */ /**
27437
+ Returns a dash array safe to pass to `setLineDash`, or `[]` (solid) for a
27438
+ degenerate one. Browsers ignore an all-zero/non-finite dash and draw solid;
27439
+ Skia-backed canvases (`@napi-rs/canvas`) instead throw "Make line dash path
27440
+ effect failed", so normalize here for backend parity.
27441
+ */ function validDash(dash) {
27442
+ if (!dash || !dash.length) return [];
27443
+ var sum = 0;
27444
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
27445
+ try {
27446
+ for(var _iterator = dash[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
27447
+ var v = _step.value;
27448
+ if (!isFinite(v) || v < 0) return [];
27449
+ sum += v;
27450
+ }
27451
+ } catch (err) {
27452
+ _didIteratorError = true;
27453
+ _iteratorError = err;
27454
+ } finally{
27455
+ try {
27456
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
27457
+ _iterator.return();
27458
+ }
27459
+ } finally{
27460
+ if (_didIteratorError) {
27461
+ throw _iteratorError;
27462
+ }
27463
+ }
27464
+ }
27465
+ return sum > 0 ? dash : [];
27466
+ }
27467
+ function paint(ctx, node, alpha, path, resolvePattern) {
27362
27468
  var cssScale = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : 1;
27363
27469
  var _p_strokeWidth;
27364
27470
  var p = node.paint || {};
@@ -27370,41 +27476,78 @@
27370
27476
  else ctx.fill();
27371
27477
  }
27372
27478
  if (p.stroke && p.stroke !== "none" && ((_p_strokeWidth = p.strokeWidth) !== null && _p_strokeWidth !== void 0 ? _p_strokeWidth : 0) > 0) {
27373
- var _p_strokeOpacity, _p_strokeDasharray;
27479
+ var _p_strokeOpacity;
27374
27480
  ctx.globalAlpha = alpha * ((_p_strokeOpacity = p.strokeOpacity) !== null && _p_strokeOpacity !== void 0 ? _p_strokeOpacity : 1);
27375
27481
  ctx.strokeStyle = p.stroke;
27376
27482
  ctx.lineWidth = p.vectorEffect === "non-scaling-stroke" && cssScale ? p.strokeWidth / cssScale : p.strokeWidth;
27377
- ctx.setLineDash((_p_strokeDasharray = p.strokeDasharray) !== null && _p_strokeDasharray !== void 0 ? _p_strokeDasharray : []);
27483
+ ctx.setLineDash(validDash(p.strokeDasharray));
27378
27484
  if (p.strokeLinecap) ctx.lineCap = p.strokeLinecap;
27379
27485
  if (path) ctx.stroke(path);
27380
27486
  else ctx.stroke();
27381
27487
  }
27382
27488
  }
27383
27489
 
27384
- function _array_like_to_array$8(arr, len) {
27490
+ /**
27491
+ @module canvas/backend
27492
+ A small injection seam so the Canvas backend can run outside a browser.
27493
+
27494
+ In the browser the surface is a real `<canvas>` element and images decode
27495
+ via `new Image()`. On a server there is no DOM `<canvas>`; a native canvas
27496
+ implementation (e.g. `@napi-rs/canvas`) supplies a structurally-compatible
27497
+ canvas + an async image loader. `CanvasRenderer` obtains both through the
27498
+ active backend rather than touching `document`/`Image` directly, so the same
27499
+ paint code runs in both places. The default backend is the browser one, so
27500
+ nothing changes unless a caller installs a different backend.
27501
+ */ /**
27502
+ The canvas surface `CanvasRenderer` paints into. A browser `HTMLCanvasElement`
27503
+ and a native canvas both satisfy this; server backends return a native canvas
27504
+ cast to `HTMLCanvasElement` (the renderer only touches DOM-specific members —
27505
+ `style`, `className`, `remove`, listeners — behind the `dom` flag below).
27506
+ */ /** The browser backend: a real `<canvas>` and `Image`-based decoding. */ var domBackend = {
27507
+ dom: true,
27508
+ createCanvas: function createCanvas() {
27509
+ return document.createElement("canvas");
27510
+ },
27511
+ loadImage: function loadImage(src) {
27512
+ return new Promise(function(resolve, reject) {
27513
+ var img = new Image();
27514
+ img.onload = function() {
27515
+ return resolve(img);
27516
+ };
27517
+ img.onerror = reject;
27518
+ img.src = src;
27519
+ });
27520
+ }
27521
+ };
27522
+ var current = domBackend;
27523
+ /** The currently-active canvas backend. */ function getCanvasBackend() {
27524
+ return current;
27525
+ }
27526
+
27527
+ function _array_like_to_array$b(arr, len) {
27385
27528
  if (len == null || len > arr.length) len = arr.length;
27386
27529
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
27387
27530
  return arr2;
27388
27531
  }
27389
- function _array_without_holes$3(arr) {
27390
- if (Array.isArray(arr)) return _array_like_to_array$8(arr);
27532
+ function _array_without_holes$5(arr) {
27533
+ if (Array.isArray(arr)) return _array_like_to_array$b(arr);
27391
27534
  }
27392
- function _iterable_to_array$3(iter) {
27535
+ function _iterable_to_array$5(iter) {
27393
27536
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
27394
27537
  }
27395
- function _non_iterable_spread$3() {
27538
+ function _non_iterable_spread$5() {
27396
27539
  throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
27397
27540
  }
27398
- function _to_consumable_array$3(arr) {
27399
- return _array_without_holes$3(arr) || _iterable_to_array$3(arr) || _unsupported_iterable_to_array$8(arr) || _non_iterable_spread$3();
27541
+ function _to_consumable_array$5(arr) {
27542
+ return _array_without_holes$5(arr) || _iterable_to_array$5(arr) || _unsupported_iterable_to_array$b(arr) || _non_iterable_spread$5();
27400
27543
  }
27401
- function _unsupported_iterable_to_array$8(o, minLen) {
27544
+ function _unsupported_iterable_to_array$b(o, minLen) {
27402
27545
  if (!o) return;
27403
- if (typeof o === "string") return _array_like_to_array$8(o, minLen);
27546
+ if (typeof o === "string") return _array_like_to_array$b(o, minLen);
27404
27547
  var n = Object.prototype.toString.call(o).slice(8, -1);
27405
27548
  if (n === "Object" && o.constructor) n = o.constructor.name;
27406
27549
  if (n === "Map" || n === "Set") return Array.from(n);
27407
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$8(o, minLen);
27550
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$b(o, minLen);
27408
27551
  }
27409
27552
  var SVG_NS = "http://www.w3.org/2000/svg";
27410
27553
  /**
@@ -27442,7 +27585,7 @@
27442
27585
  if (k in t) {
27443
27586
  var _t;
27444
27587
  var v = config[k];
27445
- if (Array.isArray(v)) (_t = t)[k].apply(_t, _to_consumable_array$3(v));
27588
+ if (Array.isArray(v)) (_t = t)[k].apply(_t, _to_consumable_array$5(v));
27446
27589
  else t[k](v);
27447
27590
  }
27448
27591
  }
@@ -27469,23 +27612,359 @@
27469
27612
  };
27470
27613
  }
27471
27614
 
27472
- function _array_like_to_array$7(arr, len) {
27615
+ function _array_like_to_array$a(arr, len) {
27473
27616
  if (len == null || len > arr.length) len = arr.length;
27474
27617
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
27475
27618
  return arr2;
27476
27619
  }
27477
- function _array_with_holes$6(arr) {
27620
+ function _array_without_holes$4(arr) {
27621
+ if (Array.isArray(arr)) return _array_like_to_array$a(arr);
27622
+ }
27623
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
27624
+ try {
27625
+ var info = gen[key](arg);
27626
+ var value = info.value;
27627
+ } catch (error) {
27628
+ reject(error);
27629
+ return;
27630
+ }
27631
+ if (info.done) {
27632
+ resolve(value);
27633
+ } else {
27634
+ Promise.resolve(value).then(_next, _throw);
27635
+ }
27636
+ }
27637
+ function _async_to_generator(fn) {
27638
+ return function() {
27639
+ var self = this, args = arguments;
27640
+ return new Promise(function(resolve, reject) {
27641
+ var gen = fn.apply(self, args);
27642
+ function _next(value) {
27643
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
27644
+ }
27645
+ function _throw(err) {
27646
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
27647
+ }
27648
+ _next(undefined);
27649
+ });
27650
+ };
27651
+ }
27652
+ function _class_call_check$2(instance, Constructor) {
27653
+ if (!(instance instanceof Constructor)) {
27654
+ throw new TypeError("Cannot call a class as a function");
27655
+ }
27656
+ }
27657
+ function _defineProperties$2(target, props) {
27658
+ for(var i = 0; i < props.length; i++){
27659
+ var descriptor = props[i];
27660
+ descriptor.enumerable = descriptor.enumerable || false;
27661
+ descriptor.configurable = true;
27662
+ if ("value" in descriptor) descriptor.writable = true;
27663
+ Object.defineProperty(target, descriptor.key, descriptor);
27664
+ }
27665
+ }
27666
+ function _create_class$2(Constructor, protoProps, staticProps) {
27667
+ if (protoProps) _defineProperties$2(Constructor.prototype, protoProps);
27668
+ return Constructor;
27669
+ }
27670
+ function _define_property$3(obj, key, value) {
27671
+ if (key in obj) {
27672
+ Object.defineProperty(obj, key, {
27673
+ value: value,
27674
+ enumerable: true,
27675
+ configurable: true,
27676
+ writable: true
27677
+ });
27678
+ } else {
27679
+ obj[key] = value;
27680
+ }
27681
+ return obj;
27682
+ }
27683
+ function _iterable_to_array$4(iter) {
27684
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
27685
+ }
27686
+ function _non_iterable_spread$4() {
27687
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
27688
+ }
27689
+ function _to_consumable_array$4(arr) {
27690
+ return _array_without_holes$4(arr) || _iterable_to_array$4(arr) || _unsupported_iterable_to_array$a(arr) || _non_iterable_spread$4();
27691
+ }
27692
+ function _unsupported_iterable_to_array$a(o, minLen) {
27693
+ if (!o) return;
27694
+ if (typeof o === "string") return _array_like_to_array$a(o, minLen);
27695
+ var n = Object.prototype.toString.call(o).slice(8, -1);
27696
+ if (n === "Object" && o.constructor) n = o.constructor.name;
27697
+ if (n === "Map" || n === "Set") return Array.from(n);
27698
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$a(o, minLen);
27699
+ }
27700
+ function _ts_generator(thisArg, body) {
27701
+ var f, y, t, _ = {
27702
+ label: 0,
27703
+ sent: function() {
27704
+ if (t[0] & 1) throw t[1];
27705
+ return t[1];
27706
+ },
27707
+ trys: [],
27708
+ ops: []
27709
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
27710
+ return d(g, "next", {
27711
+ value: verb(0)
27712
+ }), d(g, "throw", {
27713
+ value: verb(1)
27714
+ }), d(g, "return", {
27715
+ value: verb(2)
27716
+ }), typeof Symbol === "function" && d(g, Symbol.iterator, {
27717
+ value: function() {
27718
+ return this;
27719
+ }
27720
+ }), g;
27721
+ function verb(n) {
27722
+ return function(v) {
27723
+ return step([
27724
+ n,
27725
+ v
27726
+ ]);
27727
+ };
27728
+ }
27729
+ function step(op) {
27730
+ if (f) throw new TypeError("Generator is already executing.");
27731
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
27732
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
27733
+ if (y = 0, t) op = [
27734
+ op[0] & 2,
27735
+ t.value
27736
+ ];
27737
+ switch(op[0]){
27738
+ case 0:
27739
+ case 1:
27740
+ t = op;
27741
+ break;
27742
+ case 4:
27743
+ _.label++;
27744
+ return {
27745
+ value: op[1],
27746
+ done: false
27747
+ };
27748
+ case 5:
27749
+ _.label++;
27750
+ y = op[1];
27751
+ op = [
27752
+ 0
27753
+ ];
27754
+ continue;
27755
+ case 7:
27756
+ op = _.ops.pop();
27757
+ _.trys.pop();
27758
+ continue;
27759
+ default:
27760
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
27761
+ _ = 0;
27762
+ continue;
27763
+ }
27764
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
27765
+ _.label = op[1];
27766
+ break;
27767
+ }
27768
+ if (op[0] === 6 && _.label < t[1]) {
27769
+ _.label = t[1];
27770
+ t = op;
27771
+ break;
27772
+ }
27773
+ if (t && _.label < t[2]) {
27774
+ _.label = t[2];
27775
+ _.ops.push(op);
27776
+ break;
27777
+ }
27778
+ if (t[2]) _.ops.pop();
27779
+ _.trys.pop();
27780
+ continue;
27781
+ }
27782
+ op = body.call(thisArg, _);
27783
+ } catch (e) {
27784
+ op = [
27785
+ 6,
27786
+ e
27787
+ ];
27788
+ y = 0;
27789
+ } finally{
27790
+ f = t = 0;
27791
+ }
27792
+ if (op[0] & 5) throw op[1];
27793
+ return {
27794
+ value: op[0] ? op[1] : void 0,
27795
+ done: true
27796
+ };
27797
+ }
27798
+ }
27799
+ /**
27800
+ @class CanvasResources
27801
+ Owns the Canvas backend's async resources — decoded `<image>` bitmaps and
27802
+ tiled texture `CanvasPattern`s — plus the machinery to wait for them.
27803
+
27804
+ Both decode asynchronously: the first paint that needs a resource kicks off
27805
+ its load and paints a fallback (nothing for images, the texture's solid color
27806
+ for patterns); a repaint follows once the resource is ready. That live
27807
+ warm-up-then-repaint model is invisible in the browser. A server render, which
27808
+ reads pixels once and stops, instead awaits {@link whenSettled} so every
27809
+ resource is present before encoding.
27810
+ */ var CanvasResources = /*#__PURE__*/ function() {
27811
+ function CanvasResources(ctx, repaint) {
27812
+ _class_call_check$2(this, CanvasResources);
27813
+ _define_property$3(this, "ctx", void 0);
27814
+ _define_property$3(this, "repaint", void 0);
27815
+ /** href → decoded image (present only once fully loaded). */ _define_property$3(this, "images", void 0);
27816
+ /** token → tiled pattern (present only once rasterized). */ _define_property$3(this, "patterns", void 0);
27817
+ _define_property$3(this, "imagesPending", void 0);
27818
+ _define_property$3(this, "patternsPending", void 0);
27819
+ _define_property$3(this, "pending", void 0);
27820
+ this.ctx = ctx;
27821
+ this.repaint = repaint;
27822
+ this.images = new Map();
27823
+ this.patterns = new Map();
27824
+ this.imagesPending = new Set();
27825
+ this.patternsPending = new Set();
27826
+ this.pending = new Set();
27827
+ }
27828
+ _create_class$2(CanvasResources, [
27829
+ {
27830
+ key: "track",
27831
+ value: /** Tracks an in-flight decode so {@link whenSettled} can await it. */ function track(p) {
27832
+ var _this = this;
27833
+ this.pending.add(p);
27834
+ var done = function done() {
27835
+ _this.pending.delete(p);
27836
+ };
27837
+ p.then(done, done);
27838
+ }
27839
+ },
27840
+ {
27841
+ key: "whenSettled",
27842
+ value: /**
27843
+ Resolves once every in-flight decode has settled and a final frame has
27844
+ repainted. A resolution repaints, which can enqueue further decodes, so
27845
+ this drains until the queue empties (guarded against pathological loops).
27846
+ */ function whenSettled() {
27847
+ return _async_to_generator(function() {
27848
+ var guard;
27849
+ return _ts_generator(this, function(_state) {
27850
+ switch(_state.label){
27851
+ case 0:
27852
+ guard = 0;
27853
+ _state.label = 1;
27854
+ case 1:
27855
+ if (!(this.pending.size && guard++ < 1000)) return [
27856
+ 3,
27857
+ 3
27858
+ ];
27859
+ return [
27860
+ 4,
27861
+ Promise.allSettled(_to_consumable_array$4(this.pending))
27862
+ ];
27863
+ case 2:
27864
+ _state.sent();
27865
+ return [
27866
+ 3,
27867
+ 1
27868
+ ];
27869
+ case 3:
27870
+ this.repaint();
27871
+ return [
27872
+ 2
27873
+ ];
27874
+ }
27875
+ });
27876
+ }).call(this);
27877
+ }
27878
+ },
27879
+ {
27880
+ /**
27881
+ Returns the decoded image for `href`, or `null` if it isn't ready yet
27882
+ (kicking off the load on first request). Callers draw only when non-null.
27883
+ */ key: "imageFor",
27884
+ value: function imageFor(href) {
27885
+ var _this = this;
27886
+ var img = this.images.get(href);
27887
+ if (img) return img;
27888
+ if (!this.imagesPending.has(href)) {
27889
+ this.imagesPending.add(href);
27890
+ this.track(getCanvasBackend().loadImage(href).then(function(loaded) {
27891
+ _this.images.set(href, loaded);
27892
+ }, function() {
27893
+ /* broken image — never enters the ready map */ }).finally(function() {
27894
+ _this.imagesPending.delete(href);
27895
+ _this.repaint();
27896
+ }));
27897
+ }
27898
+ return null;
27899
+ }
27900
+ },
27901
+ {
27902
+ /**
27903
+ Resolves a `pattern:<json>` texture token to a tiled `CanvasPattern`, or
27904
+ `null` until it rasterizes. textures.js emits SVG a 2D context can't
27905
+ consume, so the tile's standalone SVG ({@link patternTileSvg}) is decoded
27906
+ onto an offscreen canvas and tiled with `createPattern(…, "repeat")`.
27907
+ */ key: "resolvePattern",
27908
+ value: function resolvePattern(token) {
27909
+ var _this = this;
27910
+ var cached = this.patterns.get(token);
27911
+ if (cached) return cached;
27912
+ if (this.patternsPending.has(token)) return null;
27913
+ var tile = patternTileSvg(token);
27914
+ if (!tile) return null;
27915
+ var backend = getCanvasBackend();
27916
+ this.patternsPending.add(token);
27917
+ var src = "data:image/svg+xml;charset=utf-8,".concat(encodeURIComponent(tile.svg));
27918
+ this.track(backend.loadImage(src).then(function(img) {
27919
+ var off = backend.createCanvas(tile.width, tile.height);
27920
+ off.width = tile.width;
27921
+ off.height = tile.height;
27922
+ var octx = off.getContext("2d");
27923
+ if (octx) {
27924
+ var _this_ctx;
27925
+ octx.drawImage(img, 0, 0, tile.width, tile.height);
27926
+ var pat = (_this_ctx = _this.ctx()) === null || _this_ctx === void 0 ? void 0 : _this_ctx.createPattern(off, "repeat");
27927
+ if (pat) _this.patterns.set(token, pat);
27928
+ }
27929
+ }, function() {
27930
+ /* decode failed — the solid fallback stays */ }).finally(function() {
27931
+ _this.patternsPending.delete(token);
27932
+ _this.repaint();
27933
+ }));
27934
+ return null;
27935
+ }
27936
+ },
27937
+ {
27938
+ /** Drops all cached + pending resources (CanvasPatterns are context-bound). */ key: "clear",
27939
+ value: function clear() {
27940
+ this.images.clear();
27941
+ this.imagesPending.clear();
27942
+ this.patterns.clear();
27943
+ this.patternsPending.clear();
27944
+ this.pending.clear();
27945
+ }
27946
+ }
27947
+ ]);
27948
+ return CanvasResources;
27949
+ }();
27950
+
27951
+ function _array_like_to_array$9(arr, len) {
27952
+ if (len == null || len > arr.length) len = arr.length;
27953
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
27954
+ return arr2;
27955
+ }
27956
+ function _array_with_holes$8(arr) {
27478
27957
  if (Array.isArray(arr)) return arr;
27479
27958
  }
27480
- function _array_without_holes$2(arr) {
27481
- if (Array.isArray(arr)) return _array_like_to_array$7(arr);
27959
+ function _array_without_holes$3(arr) {
27960
+ if (Array.isArray(arr)) return _array_like_to_array$9(arr);
27482
27961
  }
27483
- function _class_call_check(instance, Constructor) {
27962
+ function _class_call_check$1(instance, Constructor) {
27484
27963
  if (!(instance instanceof Constructor)) {
27485
27964
  throw new TypeError("Cannot call a class as a function");
27486
27965
  }
27487
27966
  }
27488
- function _defineProperties(target, props) {
27967
+ function _defineProperties$1(target, props) {
27489
27968
  for(var i = 0; i < props.length; i++){
27490
27969
  var descriptor = props[i];
27491
27970
  descriptor.enumerable = descriptor.enumerable || false;
@@ -27494,11 +27973,11 @@
27494
27973
  Object.defineProperty(target, descriptor.key, descriptor);
27495
27974
  }
27496
27975
  }
27497
- function _create_class(Constructor, protoProps, staticProps) {
27498
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
27976
+ function _create_class$1(Constructor, protoProps, staticProps) {
27977
+ if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
27499
27978
  return Constructor;
27500
27979
  }
27501
- function _define_property$1(obj, key, value) {
27980
+ function _define_property$2(obj, key, value) {
27502
27981
  if (key in obj) {
27503
27982
  Object.defineProperty(obj, key, {
27504
27983
  value: value,
@@ -27511,10 +27990,10 @@
27511
27990
  }
27512
27991
  return obj;
27513
27992
  }
27514
- function _iterable_to_array$2(iter) {
27993
+ function _iterable_to_array$3(iter) {
27515
27994
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
27516
27995
  }
27517
- function _iterable_to_array_limit$6(arr, i) {
27996
+ function _iterable_to_array_limit$8(arr, i) {
27518
27997
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
27519
27998
  if (_i == null) return;
27520
27999
  var _arr = [];
@@ -27538,25 +28017,25 @@
27538
28017
  }
27539
28018
  return _arr;
27540
28019
  }
27541
- function _non_iterable_rest$6() {
28020
+ function _non_iterable_rest$8() {
27542
28021
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
27543
28022
  }
27544
- function _non_iterable_spread$2() {
28023
+ function _non_iterable_spread$3() {
27545
28024
  throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
27546
28025
  }
27547
- function _sliced_to_array$6(arr, i) {
27548
- return _array_with_holes$6(arr) || _iterable_to_array_limit$6(arr, i) || _unsupported_iterable_to_array$7(arr, i) || _non_iterable_rest$6();
28026
+ function _sliced_to_array$8(arr, i) {
28027
+ return _array_with_holes$8(arr) || _iterable_to_array_limit$8(arr, i) || _unsupported_iterable_to_array$9(arr, i) || _non_iterable_rest$8();
27549
28028
  }
27550
- function _to_consumable_array$2(arr) {
27551
- return _array_without_holes$2(arr) || _iterable_to_array$2(arr) || _unsupported_iterable_to_array$7(arr) || _non_iterable_spread$2();
28029
+ function _to_consumable_array$3(arr) {
28030
+ return _array_without_holes$3(arr) || _iterable_to_array$3(arr) || _unsupported_iterable_to_array$9(arr) || _non_iterable_spread$3();
27552
28031
  }
27553
- function _unsupported_iterable_to_array$7(o, minLen) {
28032
+ function _unsupported_iterable_to_array$9(o, minLen) {
27554
28033
  if (!o) return;
27555
- if (typeof o === "string") return _array_like_to_array$7(o, minLen);
28034
+ if (typeof o === "string") return _array_like_to_array$9(o, minLen);
27556
28035
  var n = Object.prototype.toString.call(o).slice(8, -1);
27557
28036
  if (n === "Object" && o.constructor) n = o.constructor.name;
27558
28037
  if (n === "Map" || n === "Set") return Array.from(n);
27559
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$7(o, minLen);
28038
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$9(o, minLen);
27560
28039
  }
27561
28040
  var raf = typeof requestAnimationFrame === "function" ? function(cb) {
27562
28041
  return requestAnimationFrame(function() {
@@ -27573,61 +28052,73 @@
27573
28052
  var CanvasRenderer = /*#__PURE__*/ function() {
27574
28053
  function CanvasRenderer() {
27575
28054
  var _this = this;
27576
- _class_call_check(this, CanvasRenderer);
27577
- _define_property$1(this, "kind", "canvas");
27578
- _define_property$1(this, "_target", void 0);
27579
- _define_property$1(this, "_canvas", void 0);
27580
- _define_property$1(this, "_ctx", void 0);
27581
- /** Sibling host for HtmlOverlayNode mounts (same approach as SvgRenderer). */ _define_property$1(this, "_overlayHost", void 0);
28055
+ _class_call_check$1(this, CanvasRenderer);
28056
+ _define_property$2(this, "kind", "canvas");
28057
+ _define_property$2(this, "_target", void 0);
28058
+ _define_property$2(this, "_canvas", void 0);
28059
+ _define_property$2(this, "_ctx", void 0);
28060
+ /** Sibling host for HtmlOverlayNode mounts (same approach as SvgRenderer). */ _define_property$2(this, "_overlayHost", void 0);
27582
28061
  /**
27583
28062
  * Cached key→element map for HtmlOverlay reconcile. Mutated as overlays
27584
28063
  * enter/exit so the hot path (every draw, including 60Hz zoom ticks)
27585
28064
  * doesn't pay for `host.querySelectorAll(':scope > .d3plus-render-overlay')`.
27586
- */ _define_property$1(this, "_overlayMap", new Map());
27587
- _define_property$1(this, "_ratio", 1);
27588
- _define_property$1(this, "_width", 0);
27589
- _define_property$1(this, "_height", 0);
27590
- _define_property$1(this, "_scene", null);
27591
- /** Per-mark position history for persistent motion trails. */ _define_property$1(this, "_trailLog", new TrailLog());
27592
- _define_property$1(this, "_pickIndex", []);
27593
- _define_property$1(this, "_images", new Map());
27594
- // Token → tiled CanvasPattern (rasterized from the texture's SVG tile), plus
27595
- // the set of tokens whose rasterization is in flight. `_patternResolver` is a
27596
- // pre-bound view passed into the paint path so no closure is allocated per
27597
- // node per frame.
27598
- _define_property$1(this, "_patterns", new Map());
27599
- _define_property$1(this, "_patternsPending", new Set());
27600
- _define_property$1(this, "_patternResolver", function(token) {
27601
- return _this._resolvePattern(token);
28065
+ */ _define_property$2(this, "_overlayMap", new Map());
28066
+ _define_property$2(this, "_ratio", 1);
28067
+ _define_property$2(this, "_width", 0);
28068
+ _define_property$2(this, "_height", 0);
28069
+ _define_property$2(this, "_scene", null);
28070
+ /** Per-mark position history for persistent motion trails. */ _define_property$2(this, "_trailLog", new TrailLog());
28071
+ _define_property$2(this, "_pickIndex", []);
28072
+ /**
28073
+ * Async image + texture-pattern resources and the settle machinery. See
28074
+ * {@link CanvasResources}. `_patternResolver` is a pre-bound view passed into
28075
+ * the paint path so no closure is allocated per node per frame.
28076
+ */ _define_property$2(this, "_res", new CanvasResources(function() {
28077
+ return _this._ctx;
28078
+ }, function() {
28079
+ if (_this._scene) _this._paint(_this._scene);
28080
+ }));
28081
+ /**
28082
+ * Whether the mounted surface is a real DOM canvas. False under a headless
28083
+ * backend (`@d3plus/ssr`), where DOM mounting + interaction wiring are skipped.
28084
+ */ _define_property$2(this, "_dom", true);
28085
+ _define_property$2(this, "_patternResolver", function(token) {
28086
+ return _this._res.resolvePattern(token);
27602
28087
  });
27603
- _define_property$1(this, "_handlers", new Set());
27604
- _define_property$1(this, "_domListeners", {});
27605
- _define_property$1(this, "_listening", false);
27606
- _define_property$1(this, "_hoverKey", null);
27607
- _define_property$1(this, "_frame", 0);
28088
+ _define_property$2(this, "_handlers", new Set());
28089
+ _define_property$2(this, "_domListeners", {});
28090
+ _define_property$2(this, "_listening", false);
28091
+ _define_property$2(this, "_hoverKey", null);
28092
+ _define_property$2(this, "_frame", 0);
27608
28093
  /**
27609
28094
  * `_cancelAnim(soft?)` — call with `soft=true` to stop the tick loop
27610
28095
  * without snap-painting the target scene; `false`/omitted snaps + paints
27611
28096
  * (so external `handle.cancel()` matches what resize/toSVGString see).
27612
- */ _define_property$1(this, "_cancelAnim", null);
27613
- _define_property$1(this, "_invalidatePointerRect", null);
27614
- _define_property$1(this, "_removePointerRectListeners", null);
28097
+ */ _define_property$2(this, "_cancelAnim", null);
28098
+ _define_property$2(this, "_invalidatePointerRect", null);
28099
+ _define_property$2(this, "_removePointerRectListeners", null);
27615
28100
  }
27616
- _create_class(CanvasRenderer, [
28101
+ _create_class$1(CanvasRenderer, [
27617
28102
  {
27618
28103
  key: "mount",
27619
28104
  value: function mount(target) {
27620
28105
  var _target_pixelRatio;
27621
28106
  this._target = target;
27622
28107
  this._ratio = (_target_pixelRatio = target.pixelRatio) !== null && _target_pixelRatio !== void 0 ? _target_pixelRatio : typeof devicePixelRatio !== "undefined" ? devicePixelRatio : 1;
27623
- var canvas = document.createElement("canvas");
27624
- canvas.className = "d3plus-render-canvas";
27625
- canvas.style.display = "block";
27626
- // `createOverlayHost` handles `position: relative` on container.
27627
- this._overlayHost = createOverlayHost(target);
27628
- target.container.insertBefore(canvas, this._overlayHost);
28108
+ var backend = getCanvasBackend();
28109
+ this._dom = backend.dom !== false;
28110
+ var canvas = backend.createCanvas(target.width, target.height);
27629
28111
  this._canvas = canvas;
27630
28112
  this._ctx = canvas.getContext("2d");
28113
+ // Headless backends (no DOM canvas) skip mounting + overlay hosting; they
28114
+ // only produce pixels. The browser backend inserts the canvas + overlay host.
28115
+ if (this._dom) {
28116
+ canvas.className = "d3plus-render-canvas";
28117
+ canvas.style.display = "block";
28118
+ // `createOverlayHost` handles `position: relative` on container.
28119
+ this._overlayHost = createOverlayHost(target);
28120
+ target.container.insertBefore(canvas, this._overlayHost);
28121
+ }
27631
28122
  this.resize(target.width, target.height);
27632
28123
  }
27633
28124
  },
@@ -27639,8 +28130,10 @@
27639
28130
  if (!this._canvas) return;
27640
28131
  this._canvas.width = Math.round(width * this._ratio);
27641
28132
  this._canvas.height = Math.round(height * this._ratio);
27642
- this._canvas.style.width = "".concat(width, "px");
27643
- this._canvas.style.height = "".concat(height, "px");
28133
+ if (this._dom) {
28134
+ this._canvas.style.width = "".concat(width, "px");
28135
+ this._canvas.style.height = "".concat(height, "px");
28136
+ }
27644
28137
  if (this._invalidatePointerRect) this._invalidatePointerRect();
27645
28138
  if (this._scene) this._paint(this._scene);
27646
28139
  }
@@ -27779,7 +28272,7 @@
27779
28272
  break;
27780
28273
  }
27781
28274
  }
27782
- var ordered = needsSort ? _to_consumable_array$2(children).sort(function(a, b) {
28275
+ var ordered = needsSort ? _to_consumable_array$3(children).sort(function(a, b) {
27783
28276
  var _a_z, _b_z;
27784
28277
  return ((_a_z = a.z) !== null && _a_z !== void 0 ? _a_z : 0) - ((_b_z = b.z) !== null && _b_z !== void 0 ? _b_z : 0);
27785
28278
  }) : children;
@@ -27912,7 +28405,7 @@
27912
28405
  var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
27913
28406
  try {
27914
28407
  for(var _iterator1 = existing[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
27915
- var _step_value = _sliced_to_array$6(_step1.value, 2), key1 = _step_value[0], el1 = _step_value[1];
28408
+ var _step_value = _sliced_to_array$8(_step1.value, 2), key1 = _step_value[0], el1 = _step_value[1];
27916
28409
  if (!seen.has(key1)) {
27917
28410
  el1.remove();
27918
28411
  existing.delete(key1);
@@ -28009,61 +28502,35 @@
28009
28502
  }
28010
28503
  },
28011
28504
  {
28012
- key: "_resolvePattern",
28013
- value: /**
28014
- Resolves a `pattern:<json>` texture token to a tiled CanvasPattern.
28015
-
28016
- textures.js emits SVG `<pattern>`s a 2D context can't consume, so the tile
28017
- is rasterized: its standalone SVG markup ({@link patternTileSvg}) is loaded
28018
- as an Image onto an offscreen canvas, then `createPattern(…, "repeat")`
28019
- tiles it. Loading is async, so the first paint returns null (the caller
28020
- paints the texture's solid fallback) and we repaint once the tile is ready
28021
- — the same warm-up-then-repaint model as {@link _drawImage}.
28022
- */ function _resolvePattern(token) {
28023
- var _this = this;
28024
- var cached = this._patterns.get(token);
28025
- if (cached) return cached;
28026
- if (this._patternsPending.has(token)) return null;
28027
- var tile = patternTileSvg(token);
28028
- if (!tile) return null;
28029
- this._patternsPending.add(token);
28030
- var img = new Image();
28031
- img.onload = function() {
28032
- try {
28033
- var _this__ctx;
28034
- var off = document.createElement("canvas");
28035
- off.width = tile.width;
28036
- off.height = tile.height;
28037
- var octx = off.getContext("2d");
28038
- var pat = octx && (octx.drawImage(img, 0, 0, tile.width, tile.height), (_this__ctx = _this._ctx) === null || _this__ctx === void 0 ? void 0 : _this__ctx.createPattern(off, "repeat"));
28039
- if (pat) _this._patterns.set(token, pat);
28040
- } finally{
28041
- _this._patternsPending.delete(token);
28042
- if (_this._scene) _this._paint(_this._scene);
28043
- }
28044
- };
28045
- img.onerror = function() {
28046
- _this._patternsPending.delete(token);
28047
- };
28048
- img.src = "data:image/svg+xml;charset=utf-8,".concat(encodeURIComponent(tile.svg));
28049
- return null;
28505
+ /**
28506
+ Resolves once all in-flight image/texture decodes settle and a final frame
28507
+ repaints. Server-side callers await this before reading pixels; the browser
28508
+ repaints live and never needs it. See {@link CanvasResources}.
28509
+ */ key: "whenSettled",
28510
+ value: function whenSettled() {
28511
+ return this._res.whenSettled();
28050
28512
  }
28051
28513
  },
28052
28514
  {
28053
28515
  key: "_drawImage",
28054
28516
  value: function _drawImage(ctx, node, alpha) {
28055
- var _this = this;
28056
- var img = this._images.get(node.href);
28057
- if (!img) {
28058
- img = new Image();
28059
- img.onload = function() {
28060
- if (_this._scene) _this._paint(_this._scene);
28061
- };
28062
- img.src = node.href;
28063
- this._images.set(node.href, img);
28064
- }
28065
- if (img.complete && img.naturalWidth) {
28066
- ctx.globalAlpha = alpha;
28517
+ var img = this._res.imageFor(node.href);
28518
+ if (!img) return;
28519
+ ctx.globalAlpha = alpha;
28520
+ var par = node.preserveAspectRatio;
28521
+ var iw = img.naturalWidth || img.width, ih = img.naturalHeight || img.height;
28522
+ if (par && par.includes("slice")) {
28523
+ // CSS `cover`: scale the image to fill the box, cropping the overflow
28524
+ // (centered), via drawImage's source-rect crop.
28525
+ var scale = Math.max(node.width / iw, node.height / ih);
28526
+ var sw = node.width / scale, sh = node.height / scale;
28527
+ ctx.drawImage(img, (iw - sw) / 2, (ih - sh) / 2, sw, sh, node.x, node.y, node.width, node.height);
28528
+ } else if (par && par !== "none" && par.includes("meet")) {
28529
+ // CSS `contain`: fit the whole image inside the box (centered).
28530
+ var scale1 = Math.min(node.width / iw, node.height / ih);
28531
+ var dw = iw * scale1, dh = ih * scale1;
28532
+ ctx.drawImage(img, node.x + (node.width - dw) / 2, node.y + (node.height - dh) / 2, dw, dh);
28533
+ } else {
28067
28534
  ctx.drawImage(img, node.x, node.y, node.width, node.height);
28068
28535
  }
28069
28536
  }
@@ -28074,7 +28541,7 @@
28074
28541
  // Topmost wins: entries are in paint order, so search from the end.
28075
28542
  for(var i = this._pickIndex.length - 1; i >= 0; i--){
28076
28543
  var _this__pickIndex_i = this._pickIndex[i], node = _this__pickIndex_i.node, inverse = _this__pickIndex_i.inverse;
28077
- var _apply = _sliced_to_array$6(apply(inverse, [
28544
+ var _apply = _sliced_to_array$8(apply(inverse, [
28078
28545
  point[0] * this._ratio,
28079
28546
  point[1] * this._ratio
28080
28547
  ]), 2), lx = _apply[0], ly = _apply[1];
@@ -28096,7 +28563,7 @@
28096
28563
  case "circle":
28097
28564
  return Math.pow(lx - node.cx, 2) + Math.pow(ly - node.cy, 2) <= Math.pow(node.r, 2);
28098
28565
  case "path":
28099
- return this._ctx ? this._ctx.isPointInPath(new Path2D(node.d), lx, ly) : false;
28566
+ return this._ctx ? pathHit(this._ctx, node, lx, ly) : false;
28100
28567
  case "area":
28101
28568
  if (!this._ctx) return false;
28102
28569
  pathFor(this._ctx, node);
@@ -28120,8 +28587,8 @@
28120
28587
  var tol = ((_ref = (_node_paint = node.paint) === null || _node_paint === void 0 ? void 0 : _node_paint.strokeWidth) !== null && _ref !== void 0 ? _ref : 1) / 2 + 2;
28121
28588
  var pts = node.points;
28122
28589
  for(var i = 1; i < pts.length; i++){
28123
- var _pts_ = _sliced_to_array$6(pts[i - 1], 2), x1 = _pts_[0], y1 = _pts_[1];
28124
- var _pts_i = _sliced_to_array$6(pts[i], 2), x2 = _pts_i[0], y2 = _pts_i[1];
28590
+ var _pts_ = _sliced_to_array$8(pts[i - 1], 2), x1 = _pts_[0], y1 = _pts_[1];
28591
+ var _pts_i = _sliced_to_array$8(pts[i], 2), x2 = _pts_i[0], y2 = _pts_i[1];
28125
28592
  var dx = x2 - x1;
28126
28593
  var dy = y2 - y1;
28127
28594
  var len2 = dx * dx + dy * dy;
@@ -28169,7 +28636,9 @@
28169
28636
  value: function on(handler) {
28170
28637
  var _this = this;
28171
28638
  this._handlers.add(handler);
28172
- if (!this._listening) this._attachListeners();
28639
+ // A headless backend (`@d3plus/ssr`) has no DOM canvas to bind pointer
28640
+ // listeners to; interaction is a no-op server-side.
28641
+ if (this._dom && !this._listening) this._attachListeners();
28173
28642
  return function() {
28174
28643
  _this._handlers.delete(handler);
28175
28644
  };
@@ -28272,7 +28741,7 @@
28272
28741
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
28273
28742
  try {
28274
28743
  for(var _iterator = Object.entries(this._domListeners)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
28275
- var _step_value = _sliced_to_array$6(_step.value, 2), k = _step_value[0], fn = _step_value[1];
28744
+ var _step_value = _sliced_to_array$8(_step.value, 2), k = _step_value[0], fn = _step_value[1];
28276
28745
  canvas.addEventListener(k, fn);
28277
28746
  }
28278
28747
  } catch (err) {
@@ -28343,11 +28812,11 @@
28343
28812
  key: "destroy",
28344
28813
  value: function destroy() {
28345
28814
  if (this._cancelAnim) this._cancelAnim();
28346
- if (this._canvas) {
28815
+ if (this._canvas && this._dom) {
28347
28816
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
28348
28817
  try {
28349
28818
  for(var _iterator = Object.entries(this._domListeners)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
28350
- var _step_value = _sliced_to_array$6(_step.value, 2), k = _step_value[0], fn = _step_value[1];
28819
+ var _step_value = _sliced_to_array$8(_step.value, 2), k = _step_value[0], fn = _step_value[1];
28351
28820
  this._canvas.removeEventListener(k, fn);
28352
28821
  }
28353
28822
  } catch (err) {
@@ -28379,10 +28848,8 @@
28379
28848
  this._handlers.clear();
28380
28849
  this._domListeners = {};
28381
28850
  this._listening = false;
28382
- this._images.clear();
28383
28851
  // CanvasPatterns are bound to the context being torn down.
28384
- this._patterns.clear();
28385
- this._patternsPending.clear();
28852
+ this._res.clear();
28386
28853
  this._canvas = undefined;
28387
28854
  this._ctx = undefined;
28388
28855
  this._scene = null;
@@ -34827,21 +35294,21 @@
34827
35294
 
34828
35295
  var hyphenatedExports = requireHyphenated();
34829
35296
 
34830
- function _array_like_to_array$6(arr, len) {
35297
+ function _array_like_to_array$8(arr, len) {
34831
35298
  if (len == null || len > arr.length) len = arr.length;
34832
35299
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
34833
35300
  return arr2;
34834
35301
  }
34835
- function _array_with_holes$5(arr) {
35302
+ function _array_with_holes$7(arr) {
34836
35303
  if (Array.isArray(arr)) return arr;
34837
35304
  }
34838
- function _array_without_holes$1(arr) {
34839
- if (Array.isArray(arr)) return _array_like_to_array$6(arr);
35305
+ function _array_without_holes$2(arr) {
35306
+ if (Array.isArray(arr)) return _array_like_to_array$8(arr);
34840
35307
  }
34841
- function _iterable_to_array$1(iter) {
35308
+ function _iterable_to_array$2(iter) {
34842
35309
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
34843
35310
  }
34844
- function _iterable_to_array_limit$5(arr, i) {
35311
+ function _iterable_to_array_limit$7(arr, i) {
34845
35312
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
34846
35313
  if (_i == null) return;
34847
35314
  var _arr = [];
@@ -34865,25 +35332,25 @@
34865
35332
  }
34866
35333
  return _arr;
34867
35334
  }
34868
- function _non_iterable_rest$5() {
35335
+ function _non_iterable_rest$7() {
34869
35336
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
34870
35337
  }
34871
- function _non_iterable_spread$1() {
35338
+ function _non_iterable_spread$2() {
34872
35339
  throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
34873
35340
  }
34874
- function _sliced_to_array$5(arr, i) {
34875
- return _array_with_holes$5(arr) || _iterable_to_array_limit$5(arr, i) || _unsupported_iterable_to_array$6(arr, i) || _non_iterable_rest$5();
35341
+ function _sliced_to_array$7(arr, i) {
35342
+ return _array_with_holes$7(arr) || _iterable_to_array_limit$7(arr, i) || _unsupported_iterable_to_array$8(arr, i) || _non_iterable_rest$7();
34876
35343
  }
34877
- function _to_consumable_array$1(arr) {
34878
- return _array_without_holes$1(arr) || _iterable_to_array$1(arr) || _unsupported_iterable_to_array$6(arr) || _non_iterable_spread$1();
35344
+ function _to_consumable_array$2(arr) {
35345
+ return _array_without_holes$2(arr) || _iterable_to_array$2(arr) || _unsupported_iterable_to_array$8(arr) || _non_iterable_spread$2();
34879
35346
  }
34880
- function _unsupported_iterable_to_array$6(o, minLen) {
35347
+ function _unsupported_iterable_to_array$8(o, minLen) {
34881
35348
  if (!o) return;
34882
- if (typeof o === "string") return _array_like_to_array$6(o, minLen);
35349
+ if (typeof o === "string") return _array_like_to_array$8(o, minLen);
34883
35350
  var n = Object.prototype.toString.call(o).slice(8, -1);
34884
35351
  if (n === "Object" && o.constructor) n = o.constructor.name;
34885
35352
  if (n === "Map" || n === "Set") return Array.from(n);
34886
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$6(o, minLen);
35353
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$8(o, minLen);
34887
35354
  }
34888
35355
  var cjkRange = /[\u3000-\u9FFF\uF900-\uFAFF]/;
34889
35356
  var emojiRange = RegExp("[\\u00A9\\u00AE\\u203C\\u2049\\u2122\\u2139\\u2194-\\u2199\\u21A9-\\u21AA\\u231A-\\u231B\\u2328\\u23CF\\u23E9-\\u23F3\\u23F8-\\u23FA\\u24C2\\u25AA-\\u25AB\\u25B6\\u25C0\\u25FB-\\u25FE\\u2600-\\u2604\\u260E\\u2611\\u2614-\\u2615\\u2618\\u261D\\u2620\\u2622-\\u2623\\u2626\\u262A\\u262E-\\u262F\\u2638-\\u263A\\u2640\\u2642\\u2648-\\u2653\\u265F-\\u2660\\u2663\\u2665-\\u2666\\u2668\\u267B\\u267E-\\u267F\\u2692-\\u2697\\u2699\\u269B-\\u269C\\u26A0-\\u26A1\\u26A7\\u26AA-\\u26AB\\u26B0-\\u26B1\\u26BD-\\u26BE\\u26C4-\\u26C5\\u26C8\\u26CE-\\u26CF\\u26D1\\u26D3-\\u26D4\\u26E9-\\u26EA\\u26F0-\\u26F5\\u26F7-\\u26FA\\u26FD\\u2702\\u2705\\u2708-\\u270D\\u270F\\u2712\\u2714\\u2716\\u271D\\u2721\\u2728\\u2733-\\u2734\\u2744\\u2747\\u274C\\u274E\\u2753-\\u2755\\u2757\\u2763-\\u2764\\u2795-\\u2797\\u27A1\\u27B0\\u27BF\\u2934-\\u2935\\u2B05-\\u2B07\\u2B1B-\\u2B1C\\u2B50\\u2B55\\u3030\\u303D\\u3297\\u3299\\u{1F004}\\u{1F02C}-\\u{1F02F}\\u{1F094}-\\u{1F09F}\\u{1F0AF}-\\u{1F0B0}\\u{1F0C0}\\u{1F0CF}-\\u{1F0D0}\\u{1F0F6}-\\u{1F0FF}\\u{1F170}-\\u{1F171}\\u{1F17E}-\\u{1F17F}\\u{1F18E}\\u{1F191}-\\u{1F19A}\\u{1F1AE}-\\u{1F1E5}\\u{1F201}-\\u{1F20F}\\u{1F21A}\\u{1F22F}\\u{1F232}-\\u{1F23A}\\u{1F23C}-\\u{1F23F}\\u{1F249}-\\u{1F25F}\\u{1F266}-\\u{1F321}\\u{1F324}-\\u{1F393}\\u{1F396}-\\u{1F397}\\u{1F399}-\\u{1F39B}\\u{1F39E}-\\u{1F3F0}\\u{1F3F3}-\\u{1F3F5}\\u{1F3F7}-\\u{1F3FA}\\u{1F400}-\\u{1F4FD}\\u{1F4FF}-\\u{1F53D}\\u{1F549}-\\u{1F54E}\\u{1F550}-\\u{1F567}\\u{1F56F}-\\u{1F570}\\u{1F573}-\\u{1F57A}\\u{1F587}\\u{1F58A}-\\u{1F58D}\\u{1F590}\\u{1F595}-\\u{1F596}\\u{1F5A4}-\\u{1F5A5}\\u{1F5A8}\\u{1F5B1}-\\u{1F5B2}\\u{1F5BC}\\u{1F5C2}-\\u{1F5C4}\\u{1F5D1}-\\u{1F5D3}\\u{1F5DC}-\\u{1F5DE}\\u{1F5E1}\\u{1F5E3}\\u{1F5E8}\\u{1F5EF}\\u{1F5F3}\\u{1F5FA}-\\u{1F64F}\\u{1F680}-\\u{1F6C5}\\u{1F6CB}-\\u{1F6D2}\\u{1F6D5}-\\u{1F6E5}\\u{1F6E9}\\u{1F6EB}-\\u{1F6F0}\\u{1F6F3}-\\u{1F6FF}\\u{1F7DA}-\\u{1F7FF}\\u{1F80C}-\\u{1F80F}\\u{1F848}-\\u{1F84F}\\u{1F85A}-\\u{1F85F}\\u{1F888}-\\u{1F88F}\\u{1F8AE}-\\u{1F8AF}\\u{1F8BC}-\\u{1F8BF}\\u{1F8C2}-\\u{1F8CF}\\u{1F8D9}-\\u{1F8FF}\\u{1F90C}-\\u{1F93A}\\u{1F93C}-\\u{1F945}\\u{1F947}-\\u{1F9FF}\\u{1FA58}-\\u{1FA5F}\\u{1FA6E}-\\u{1FAFF}\\u{1FC00}-\\u{1FFFD}]", "u");
@@ -34904,7 +35371,7 @@
34904
35371
  if (!match) return [
34905
35372
  word
34906
35373
  ];
34907
- var _match = _sliced_to_array$5(match, 3), text = _match[1], trailing = _match[2];
35374
+ var _match = _sliced_to_array$7(match, 3), text = _match[1], trailing = _match[2];
34908
35375
  if (text.length < minHyphenLength) return [
34909
35376
  word
34910
35377
  ];
@@ -34950,7 +35417,7 @@
34950
35417
  var word = _step.value;
34951
35418
  var _result;
34952
35419
  var syllables = hyphenate(word);
34953
- (_result = result).push.apply(_result, _to_consumable_array$1(syllables));
35420
+ (_result = result).push.apply(_result, _to_consumable_array$2(syllables));
34954
35421
  }
34955
35422
  } catch (err) {
34956
35423
  _didIteratorError = true;
@@ -34969,15 +35436,15 @@
34969
35436
  return result;
34970
35437
  }
34971
35438
 
34972
- function _array_like_to_array$5(arr, len) {
35439
+ function _array_like_to_array$7(arr, len) {
34973
35440
  if (len == null || len > arr.length) len = arr.length;
34974
35441
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
34975
35442
  return arr2;
34976
35443
  }
34977
- function _array_without_holes(arr) {
34978
- if (Array.isArray(arr)) return _array_like_to_array$5(arr);
35444
+ function _array_without_holes$1(arr) {
35445
+ if (Array.isArray(arr)) return _array_like_to_array$7(arr);
34979
35446
  }
34980
- function _define_property(obj, key, value) {
35447
+ function _define_property$1(obj, key, value) {
34981
35448
  if (key in obj) {
34982
35449
  Object.defineProperty(obj, key, {
34983
35450
  value: value,
@@ -34998,10 +35465,10 @@
34998
35465
  return left instanceof right;
34999
35466
  }
35000
35467
  }
35001
- function _iterable_to_array(iter) {
35468
+ function _iterable_to_array$1(iter) {
35002
35469
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
35003
35470
  }
35004
- function _non_iterable_spread() {
35471
+ function _non_iterable_spread$1() {
35005
35472
  throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
35006
35473
  }
35007
35474
  function _object_spread(target) {
@@ -35014,7 +35481,7 @@
35014
35481
  }));
35015
35482
  }
35016
35483
  ownKeys.forEach(function(key) {
35017
- _define_property(target, key, source[key]);
35484
+ _define_property$1(target, key, source[key]);
35018
35485
  });
35019
35486
  }
35020
35487
  return target;
@@ -35038,20 +35505,20 @@
35038
35505
  }
35039
35506
  return target;
35040
35507
  }
35041
- function _to_consumable_array(arr) {
35042
- return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array$5(arr) || _non_iterable_spread();
35508
+ function _to_consumable_array$1(arr) {
35509
+ return _array_without_holes$1(arr) || _iterable_to_array$1(arr) || _unsupported_iterable_to_array$7(arr) || _non_iterable_spread$1();
35043
35510
  }
35044
35511
  function _type_of$1(obj) {
35045
35512
  "@swc/helpers - typeof";
35046
35513
  return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
35047
35514
  }
35048
- function _unsupported_iterable_to_array$5(o, minLen) {
35515
+ function _unsupported_iterable_to_array$7(o, minLen) {
35049
35516
  if (!o) return;
35050
- if (typeof o === "string") return _array_like_to_array$5(o, minLen);
35517
+ if (typeof o === "string") return _array_like_to_array$7(o, minLen);
35051
35518
  var n = Object.prototype.toString.call(o).slice(8, -1);
35052
35519
  if (n === "Object" && o.constructor) n = o.constructor.name;
35053
35520
  if (n === "Map" || n === "Set") return Array.from(n);
35054
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$5(o, minLen);
35521
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$7(o, minLen);
35055
35522
  }
35056
35523
  var softHyphen = "\u00AD";
35057
35524
  /**
@@ -35188,7 +35655,7 @@
35188
35655
  var chord = circleLineWidth(radius, pass.lineData.length, lineHeight, fontSize);
35189
35656
  var over = (_Math = Math).max.apply(_Math, [
35190
35657
  0
35191
- ].concat(_to_consumable_array(visibleWidths.map(function(w, i) {
35658
+ ].concat(_to_consumable_array$1(visibleWidths.map(function(w, i) {
35192
35659
  return w - chord(i + 1);
35193
35660
  }))));
35194
35661
  // `overflow` opts out of containment — let the text spill, as the flag asks.
@@ -35996,7 +36463,10 @@
35996
36463
  };
35997
36464
  let base = typeof paint.fill === "string" ? paint.fill : undefined;
35998
36465
  if (!base || base === "transparent" || base === "none") base = typeof paint.stroke === "string" ? paint.stroke : undefined;
35999
- const c = base ? color(base) : null;
36466
+ // No visible paint to emphasize (e.g. an invisible hit-area node): leave it
36467
+ // untouched — darkening `transparent`/`none` would format to opaque black.
36468
+ if (!base || base === "transparent" || base === "none") return node;
36469
+ const c = color(base);
36000
36470
  if (c) paint.stroke = c.darker(darken).formatHex();
36001
36471
  const w = typeof paint.strokeWidth === "number" && paint.strokeWidth ? paint.strokeWidth : 1;
36002
36472
  paint.strokeWidth = w * widthMult;
@@ -39794,15 +40264,15 @@
39794
40264
  }
39795
40265
  }
39796
40266
 
39797
- function _array_like_to_array$4(arr, len) {
40267
+ function _array_like_to_array$6(arr, len) {
39798
40268
  if (len == null || len > arr.length) len = arr.length;
39799
40269
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
39800
40270
  return arr2;
39801
40271
  }
39802
- function _array_with_holes$4(arr) {
40272
+ function _array_with_holes$6(arr) {
39803
40273
  if (Array.isArray(arr)) return arr;
39804
40274
  }
39805
- function _iterable_to_array_limit$4(arr, i) {
40275
+ function _iterable_to_array_limit$6(arr, i) {
39806
40276
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
39807
40277
  if (_i == null) return;
39808
40278
  var _arr = [];
@@ -39826,19 +40296,19 @@
39826
40296
  }
39827
40297
  return _arr;
39828
40298
  }
39829
- function _non_iterable_rest$4() {
40299
+ function _non_iterable_rest$6() {
39830
40300
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
39831
40301
  }
39832
- function _sliced_to_array$4(arr, i) {
39833
- return _array_with_holes$4(arr) || _iterable_to_array_limit$4(arr, i) || _unsupported_iterable_to_array$4(arr, i) || _non_iterable_rest$4();
40302
+ function _sliced_to_array$6(arr, i) {
40303
+ return _array_with_holes$6(arr) || _iterable_to_array_limit$6(arr, i) || _unsupported_iterable_to_array$6(arr, i) || _non_iterable_rest$6();
39834
40304
  }
39835
- function _unsupported_iterable_to_array$4(o, minLen) {
40305
+ function _unsupported_iterable_to_array$6(o, minLen) {
39836
40306
  if (!o) return;
39837
- if (typeof o === "string") return _array_like_to_array$4(o, minLen);
40307
+ if (typeof o === "string") return _array_like_to_array$6(o, minLen);
39838
40308
  var n = Object.prototype.toString.call(o).slice(8, -1);
39839
40309
  if (n === "Object" && o.constructor) n = o.constructor.name;
39840
40310
  if (n === "Map" || n === "Set") return Array.from(n);
39841
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$4(o, minLen);
40311
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$6(o, minLen);
39842
40312
  }
39843
40313
  var s2lin = function s2lin(c) {
39844
40314
  return c <= 0.04045 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
@@ -39859,7 +40329,7 @@
39859
40329
  Converts a CSS color string to OKLab.
39860
40330
  @param c A valid CSS color string.
39861
40331
  */ function colorToOklab(c) {
39862
- var _linearRGB = _sliced_to_array$4(linearRGB(c), 3), r = _linearRGB[0], g = _linearRGB[1], b = _linearRGB[2];
40332
+ var _linearRGB = _sliced_to_array$6(linearRGB(c), 3), r = _linearRGB[0], g = _linearRGB[1], b = _linearRGB[2];
39863
40333
  var l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);
39864
40334
  var m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);
39865
40335
  var s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);
@@ -39910,7 +40380,7 @@
39910
40380
  The WCAG 2.x relative luminance of a color (0 = black, 1 = white).
39911
40381
  @param c A valid CSS color string.
39912
40382
  */ function relativeLuminance(c) {
39913
- var _linearRGB = _sliced_to_array$4(linearRGB(c), 3), r = _linearRGB[0], g = _linearRGB[1], b = _linearRGB[2];
40383
+ var _linearRGB = _sliced_to_array$6(linearRGB(c), 3), r = _linearRGB[0], g = _linearRGB[1], b = _linearRGB[2];
39914
40384
  return 0.2126 * r + 0.7152 * g + 0.0722 * b;
39915
40385
  }
39916
40386
  /**
@@ -39918,7 +40388,7 @@
39918
40388
  @param a A valid CSS color string.
39919
40389
  @param b A valid CSS color string.
39920
40390
  */ function contrastRatio(a, b) {
39921
- var _sort = _sliced_to_array$4([
40391
+ var _sort = _sliced_to_array$6([
39922
40392
  relativeLuminance(a),
39923
40393
  relativeLuminance(b)
39924
40394
  ].sort(function(x, y) {
@@ -40086,15 +40556,15 @@
40086
40556
  .replace(/\.[0]*$/g, ""); // removes any trailing decimal point
40087
40557
  }
40088
40558
 
40089
- function _array_like_to_array$3(arr, len) {
40559
+ function _array_like_to_array$5(arr, len) {
40090
40560
  if (len == null || len > arr.length) len = arr.length;
40091
40561
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
40092
40562
  return arr2;
40093
40563
  }
40094
- function _array_with_holes$3(arr) {
40564
+ function _array_with_holes$5(arr) {
40095
40565
  if (Array.isArray(arr)) return arr;
40096
40566
  }
40097
- function _iterable_to_array_limit$3(arr, i) {
40567
+ function _iterable_to_array_limit$5(arr, i) {
40098
40568
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
40099
40569
  if (_i == null) return;
40100
40570
  var _arr = [];
@@ -40118,19 +40588,19 @@
40118
40588
  }
40119
40589
  return _arr;
40120
40590
  }
40121
- function _non_iterable_rest$3() {
40591
+ function _non_iterable_rest$5() {
40122
40592
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
40123
40593
  }
40124
- function _sliced_to_array$3(arr, i) {
40125
- return _array_with_holes$3(arr) || _iterable_to_array_limit$3(arr, i) || _unsupported_iterable_to_array$3(arr, i) || _non_iterable_rest$3();
40594
+ function _sliced_to_array$5(arr, i) {
40595
+ return _array_with_holes$5(arr) || _iterable_to_array_limit$5(arr, i) || _unsupported_iterable_to_array$5(arr, i) || _non_iterable_rest$5();
40126
40596
  }
40127
- function _unsupported_iterable_to_array$3(o, minLen) {
40597
+ function _unsupported_iterable_to_array$5(o, minLen) {
40128
40598
  if (!o) return;
40129
- if (typeof o === "string") return _array_like_to_array$3(o, minLen);
40599
+ if (typeof o === "string") return _array_like_to_array$5(o, minLen);
40130
40600
  var n = Object.prototype.toString.call(o).slice(8, -1);
40131
40601
  if (n === "Object" && o.constructor) n = o.constructor.name;
40132
40602
  if (n === "Map" || n === "Set") return Array.from(n);
40133
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$3(o, minLen);
40603
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$5(o, minLen);
40134
40604
  }
40135
40605
  /**
40136
40606
  A default set of date formatters, which takes into account both the interval in between in each data point but also the start/end data points.
@@ -40145,7 +40615,7 @@
40145
40615
  });
40146
40616
  var firstOrLast = labelIndex === 0 || labelIndex === dataArray.length - 1;
40147
40617
  var smallArray = dataArray.length <= 5;
40148
- var _dataArray_reduce = _sliced_to_array$3(dataArray.reduce(function(arr, d, i) {
40618
+ var _dataArray_reduce = _sliced_to_array$5(dataArray.reduce(function(arr, d, i) {
40149
40619
  if (i) {
40150
40620
  arr[0].push(d.getFullYear() - dataArray[i - 1].getFullYear());
40151
40621
  arr[1].push(monthDiff(dataArray[i - 1], d));
@@ -40640,15 +41110,15 @@
40640
41110
  ];
40641
41111
  }
40642
41112
 
40643
- function _array_like_to_array$2(arr, len) {
41113
+ function _array_like_to_array$4(arr, len) {
40644
41114
  if (len == null || len > arr.length) len = arr.length;
40645
41115
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
40646
41116
  return arr2;
40647
41117
  }
40648
- function _array_with_holes$2(arr) {
41118
+ function _array_with_holes$4(arr) {
40649
41119
  if (Array.isArray(arr)) return arr;
40650
41120
  }
40651
- function _iterable_to_array_limit$2(arr, i) {
41121
+ function _iterable_to_array_limit$4(arr, i) {
40652
41122
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
40653
41123
  if (_i == null) return;
40654
41124
  var _arr = [];
@@ -40672,19 +41142,19 @@
40672
41142
  }
40673
41143
  return _arr;
40674
41144
  }
40675
- function _non_iterable_rest$2() {
41145
+ function _non_iterable_rest$4() {
40676
41146
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
40677
41147
  }
40678
- function _sliced_to_array$2(arr, i) {
40679
- return _array_with_holes$2(arr) || _iterable_to_array_limit$2(arr, i) || _unsupported_iterable_to_array$2(arr, i) || _non_iterable_rest$2();
41148
+ function _sliced_to_array$4(arr, i) {
41149
+ return _array_with_holes$4(arr) || _iterable_to_array_limit$4(arr, i) || _unsupported_iterable_to_array$4(arr, i) || _non_iterable_rest$4();
40680
41150
  }
40681
- function _unsupported_iterable_to_array$2(o, minLen) {
41151
+ function _unsupported_iterable_to_array$4(o, minLen) {
40682
41152
  if (!o) return;
40683
- if (typeof o === "string") return _array_like_to_array$2(o, minLen);
41153
+ if (typeof o === "string") return _array_like_to_array$4(o, minLen);
40684
41154
  var n = Object.prototype.toString.call(o).slice(8, -1);
40685
41155
  if (n === "Object" && o.constructor) n = o.constructor.name;
40686
41156
  if (n === "Map" || n === "Set") return Array.from(n);
40687
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$2(o, minLen);
41157
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$4(o, minLen);
40688
41158
  }
40689
41159
  /**
40690
41160
  Checks whether a point is inside the bounding box of a line segment.
@@ -40692,7 +41162,7 @@
40692
41162
  @param s2 The second point of the line segment to be used for the bounding box, which should always be an `[x, y]` formatted Array.
40693
41163
  @param p The point to be checked, which should always be an `[x, y]` formatted Array.
40694
41164
  */ function segmentBoxContains(s1, s2, p) {
40695
- var eps = 1e-9, _p = _sliced_to_array$2(p, 2), px = _p[0], py = _p[1];
41165
+ var eps = 1e-9, _p = _sliced_to_array$4(p, 2), px = _p[0], py = _p[1];
40696
41166
  return !(px < Math.min(s1[0], s2[0]) - eps || px > Math.max(s1[0], s2[0]) + eps || py < Math.min(s1[1], s2[1]) - eps || py > Math.max(s1[1], s2[1]) + eps);
40697
41167
  }
40698
41168
 
@@ -40740,15 +41210,15 @@
40740
41210
  return dx * dx + dy * dy;
40741
41211
  }
40742
41212
 
40743
- function _array_like_to_array$1(arr, len) {
41213
+ function _array_like_to_array$3(arr, len) {
40744
41214
  if (len == null || len > arr.length) len = arr.length;
40745
41215
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
40746
41216
  return arr2;
40747
41217
  }
40748
- function _array_with_holes$1(arr) {
41218
+ function _array_with_holes$3(arr) {
40749
41219
  if (Array.isArray(arr)) return arr;
40750
41220
  }
40751
- function _iterable_to_array_limit$1(arr, i) {
41221
+ function _iterable_to_array_limit$3(arr, i) {
40752
41222
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
40753
41223
  if (_i == null) return;
40754
41224
  var _arr = [];
@@ -40772,19 +41242,19 @@
40772
41242
  }
40773
41243
  return _arr;
40774
41244
  }
40775
- function _non_iterable_rest$1() {
41245
+ function _non_iterable_rest$3() {
40776
41246
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
40777
41247
  }
40778
- function _sliced_to_array$1(arr, i) {
40779
- return _array_with_holes$1(arr) || _iterable_to_array_limit$1(arr, i) || _unsupported_iterable_to_array$1(arr, i) || _non_iterable_rest$1();
41248
+ function _sliced_to_array$3(arr, i) {
41249
+ return _array_with_holes$3(arr) || _iterable_to_array_limit$3(arr, i) || _unsupported_iterable_to_array$3(arr, i) || _non_iterable_rest$3();
40780
41250
  }
40781
- function _unsupported_iterable_to_array$1(o, minLen) {
41251
+ function _unsupported_iterable_to_array$3(o, minLen) {
40782
41252
  if (!o) return;
40783
- if (typeof o === "string") return _array_like_to_array$1(o, minLen);
41253
+ if (typeof o === "string") return _array_like_to_array$3(o, minLen);
40784
41254
  var n = Object.prototype.toString.call(o).slice(8, -1);
40785
41255
  if (n === "Object" && o.constructor) n = o.constructor.name;
40786
41256
  if (n === "Map" || n === "Set") return Array.from(n);
40787
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$1(o, minLen);
41257
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$3(o, minLen);
40788
41258
  }
40789
41259
  /**
40790
41260
  Gives the two closest intersection points between a ray cast from a point inside a polygon. The two points should lie on opposite sides of the origin.
@@ -40799,7 +41269,7 @@
40799
41269
  origin[0] + eps * Math.cos(alpha),
40800
41270
  origin[1] + eps * Math.sin(alpha)
40801
41271
  ];
40802
- var _origin = _sliced_to_array$1(origin, 2), x0 = _origin[0], y0 = _origin[1];
41272
+ var _origin = _sliced_to_array$3(origin, 2), x0 = _origin[0], y0 = _origin[1];
40803
41273
  var shiftedOrigin = [
40804
41274
  x0 + Math.cos(alpha),
40805
41275
  y0 + Math.sin(alpha)
@@ -40957,12 +41427,12 @@
40957
41427
  return poly;
40958
41428
  }
40959
41429
 
40960
- function _array_like_to_array(arr, len) {
41430
+ function _array_like_to_array$2(arr, len) {
40961
41431
  if (len == null || len > arr.length) len = arr.length;
40962
41432
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
40963
41433
  return arr2;
40964
41434
  }
40965
- function _array_with_holes(arr) {
41435
+ function _array_with_holes$2(arr) {
40966
41436
  if (Array.isArray(arr)) return arr;
40967
41437
  }
40968
41438
  function _instanceof(left, right) {
@@ -40973,7 +41443,7 @@
40973
41443
  return left instanceof right;
40974
41444
  }
40975
41445
  }
40976
- function _iterable_to_array_limit(arr, i) {
41446
+ function _iterable_to_array_limit$2(arr, i) {
40977
41447
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
40978
41448
  if (_i == null) return;
40979
41449
  var _arr = [];
@@ -40997,19 +41467,19 @@
40997
41467
  }
40998
41468
  return _arr;
40999
41469
  }
41000
- function _non_iterable_rest() {
41470
+ function _non_iterable_rest$2() {
41001
41471
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
41002
41472
  }
41003
- function _sliced_to_array(arr, i) {
41004
- return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
41473
+ function _sliced_to_array$2(arr, i) {
41474
+ return _array_with_holes$2(arr) || _iterable_to_array_limit$2(arr, i) || _unsupported_iterable_to_array$2(arr, i) || _non_iterable_rest$2();
41005
41475
  }
41006
- function _unsupported_iterable_to_array(o, minLen) {
41476
+ function _unsupported_iterable_to_array$2(o, minLen) {
41007
41477
  if (!o) return;
41008
- if (typeof o === "string") return _array_like_to_array(o, minLen);
41478
+ if (typeof o === "string") return _array_like_to_array$2(o, minLen);
41009
41479
  var n = Object.prototype.toString.call(o).slice(8, -1);
41010
41480
  if (n === "Object" && o.constructor) n = o.constructor.name;
41011
41481
  if (n === "Map" || n === "Set") return Array.from(n);
41012
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
41482
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$2(o, minLen);
41013
41483
  }
41014
41484
  // Algorithm constants
41015
41485
  var aspectRatioStep = 0.5; // step size for the aspect ratio
@@ -41068,8 +41538,8 @@
41068
41538
  Improves a candidate origin by averaging the polygon ray-cast intersections
41069
41539
  along the width and height axes, returning the refined center points.
41070
41540
  */ function refineOrigins(poly, origOrigin, angleRad, idx, events) {
41071
- var _polygonRayCast = _sliced_to_array(polygonRayCast(poly, origOrigin, angleRad), 2), p1W = _polygonRayCast[0], p2W = _polygonRayCast[1];
41072
- var _polygonRayCast1 = _sliced_to_array(polygonRayCast(poly, origOrigin, angleRad + Math.PI / 2), 2), p1H = _polygonRayCast1[0], p2H = _polygonRayCast1[1];
41541
+ var _polygonRayCast = _sliced_to_array$2(polygonRayCast(poly, origOrigin, angleRad), 2), p1W = _polygonRayCast[0], p2W = _polygonRayCast[1];
41542
+ var _polygonRayCast1 = _sliced_to_array$2(polygonRayCast(poly, origOrigin, angleRad + Math.PI / 2), 2), p1H = _polygonRayCast1[0], p2H = _polygonRayCast1[1];
41073
41543
  var modifOrigins = [];
41074
41544
  if (p1W && p2W) modifOrigins.push([
41075
41545
  (p1W[0] + p2W[0]) / 2,
@@ -41101,14 +41571,14 @@
41101
41571
  cx: origin[0],
41102
41572
  cy: origin[1]
41103
41573
  });
41104
- var _polygonRayCast = _sliced_to_array(polygonRayCast(poly, origin, angleRad), 2), p1W = _polygonRayCast[0], p2W = _polygonRayCast[1];
41574
+ var _polygonRayCast = _sliced_to_array$2(polygonRayCast(poly, origin, angleRad), 2), p1W = _polygonRayCast[0], p2W = _polygonRayCast[1];
41105
41575
  if (p1W === null || p2W === null) return {
41106
41576
  maxArea: maxArea,
41107
41577
  maxRect: maxRect
41108
41578
  };
41109
41579
  var minSqDistW = Math.min(pointDistanceSquared(origin, p1W), pointDistanceSquared(origin, p2W));
41110
41580
  var maxWidth = 2 * Math.sqrt(minSqDistW);
41111
- var _polygonRayCast1 = _sliced_to_array(polygonRayCast(poly, origin, angleRad + Math.PI / 2), 2), p1H = _polygonRayCast1[0], p2H = _polygonRayCast1[1];
41581
+ var _polygonRayCast1 = _sliced_to_array$2(polygonRayCast(poly, origin, angleRad + Math.PI / 2), 2), p1H = _polygonRayCast1[0], p2H = _polygonRayCast1[1];
41112
41582
  if (p1H === null || p2H === null) return {
41113
41583
  maxArea: maxArea,
41114
41584
  maxRect: maxRect
@@ -41138,7 +41608,7 @@
41138
41608
  while(right - left >= widthStep){
41139
41609
  var width = (left + right) / 2;
41140
41610
  var height = width / aRatio;
41141
- var _origin = _sliced_to_array(origin, 2), cx = _origin[0], cy = _origin[1];
41611
+ var _origin = _sliced_to_array$2(origin, 2), cx = _origin[0], cy = _origin[1];
41142
41612
  var rectPoly = [
41143
41613
  [
41144
41614
  cx - width / 2,
@@ -41253,10 +41723,10 @@
41253
41723
  return null;
41254
41724
  }
41255
41725
  // get the width of the bounding box of the original polygon to determine tolerance
41256
- var _extent = _sliced_to_array(extent$1(poly, function(d) {
41726
+ var _extent = _sliced_to_array$2(extent$1(poly, function(d) {
41257
41727
  return d[0];
41258
41728
  }), 2), minx = _extent[0], maxx = _extent[1];
41259
- var _extent1 = _sliced_to_array(extent$1(poly, function(d) {
41729
+ var _extent1 = _sliced_to_array$2(extent$1(poly, function(d) {
41260
41730
  return d[1];
41261
41731
  }), 2), miny = _extent1[0], maxy = _extent1[1];
41262
41732
  // simplify polygon
@@ -41268,11 +41738,11 @@
41268
41738
  });
41269
41739
  var ref;
41270
41740
  // get the width of the bounding box of the simplified polygon
41271
- ref = _sliced_to_array(extent$1(poly, function(d) {
41741
+ ref = _sliced_to_array$2(extent$1(poly, function(d) {
41272
41742
  return d[0];
41273
41743
  }), 2), minx = ref[0], maxx = ref[1];
41274
41744
  var ref1;
41275
- ref1 = _sliced_to_array(extent$1(poly, function(d) {
41745
+ ref1 = _sliced_to_array$2(extent$1(poly, function(d) {
41276
41746
  return d[1];
41277
41747
  }), 2), miny = ref1[0], maxy = ref1[1];
41278
41748
  var _ref = [
@@ -41324,28 +41794,715 @@
41324
41794
  }) : maxRect;
41325
41795
  }
41326
41796
 
41797
+ function _class_call_check(instance, Constructor) {
41798
+ if (!(instance instanceof Constructor)) {
41799
+ throw new TypeError("Cannot call a class as a function");
41800
+ }
41801
+ }
41802
+ function _defineProperties(target, props) {
41803
+ for(var i = 0; i < props.length; i++){
41804
+ var descriptor = props[i];
41805
+ descriptor.enumerable = descriptor.enumerable || false;
41806
+ descriptor.configurable = true;
41807
+ if ("value" in descriptor) descriptor.writable = true;
41808
+ Object.defineProperty(target, descriptor.key, descriptor);
41809
+ }
41810
+ }
41811
+ function _create_class(Constructor, protoProps, staticProps) {
41812
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
41813
+ return Constructor;
41814
+ }
41815
+ function _define_property(obj, key, value) {
41816
+ if (key in obj) {
41817
+ Object.defineProperty(obj, key, {
41818
+ value: value,
41819
+ enumerable: true,
41820
+ configurable: true,
41821
+ writable: true
41822
+ });
41823
+ } else {
41824
+ obj[key] = value;
41825
+ }
41826
+ return obj;
41827
+ }
41828
+ var WS = new Set([
41829
+ " ",
41830
+ "\t",
41831
+ "\n",
41832
+ "\r",
41833
+ "\f",
41834
+ ","
41835
+ ]);
41327
41836
  /**
41328
- Transforms a path string into an Array of points.
41837
+ A pointer-driven scanner over an SVG path `d` string. Kept command-aware so
41838
+ it can read arc flags (`large-arc`/`sweep`) as single `0`/`1` characters even
41839
+ when they are glued to the next number (the classic `a5 5 0 0150 0` case a
41840
+ plain number regex mis-tokenizes).
41841
+ @private
41842
+ */ var Scanner = /*#__PURE__*/ function() {
41843
+ function Scanner(s) {
41844
+ _class_call_check(this, Scanner);
41845
+ _define_property(this, "s", void 0);
41846
+ _define_property(this, "i", 0);
41847
+ this.s = s;
41848
+ }
41849
+ _create_class(Scanner, [
41850
+ {
41851
+ key: "eof",
41852
+ value: function eof() {
41853
+ return this.i >= this.s.length;
41854
+ }
41855
+ },
41856
+ {
41857
+ key: "skipSep",
41858
+ value: function skipSep() {
41859
+ while(this.i < this.s.length && WS.has(this.s[this.i]))this.i++;
41860
+ }
41861
+ },
41862
+ {
41863
+ /** Reads a number token (handles `.5`, `1.`, `1e3`, signs, exponents). */ key: "readNumber",
41864
+ value: function readNumber() {
41865
+ this.skipSep();
41866
+ var start = this.i;
41867
+ var s = this.s;
41868
+ if (s[this.i] === "+" || s[this.i] === "-") this.i++;
41869
+ while(this.i < s.length && s[this.i] >= "0" && s[this.i] <= "9")this.i++;
41870
+ if (s[this.i] === ".") {
41871
+ this.i++;
41872
+ while(this.i < s.length && s[this.i] >= "0" && s[this.i] <= "9")this.i++;
41873
+ }
41874
+ if (s[this.i] === "e" || s[this.i] === "E") {
41875
+ this.i++;
41876
+ if (s[this.i] === "+" || s[this.i] === "-") this.i++;
41877
+ while(this.i < s.length && s[this.i] >= "0" && s[this.i] <= "9")this.i++;
41878
+ }
41879
+ return parseFloat(s.slice(start, this.i));
41880
+ }
41881
+ },
41882
+ {
41883
+ /** Reads a single `0`/`1` arc flag, which may be glued to the next number. */ key: "readFlag",
41884
+ value: function readFlag() {
41885
+ this.skipSep();
41886
+ var c = this.s[this.i];
41887
+ this.i++;
41888
+ return c === "1" ? 1 : 0;
41889
+ }
41890
+ },
41891
+ {
41892
+ /** True when the next non-separator char begins a new number (implicit repeat). */ key: "moreArgs",
41893
+ value: function moreArgs() {
41894
+ this.skipSep();
41895
+ var c = this.s[this.i];
41896
+ return c !== undefined && (c === "+" || c === "-" || c === "." || c >= "0" && c <= "9");
41897
+ }
41898
+ },
41899
+ {
41900
+ key: "nextCommand",
41901
+ value: function nextCommand() {
41902
+ this.skipSep();
41903
+ var c = this.s[this.i];
41904
+ if (c !== undefined && (c >= "a" && c <= "z" || c >= "A" && c <= "Z")) {
41905
+ this.i++;
41906
+ return c;
41907
+ }
41908
+ return null;
41909
+ }
41910
+ }
41911
+ ]);
41912
+ return Scanner;
41913
+ }();
41914
+ /**
41915
+ Parses an SVG path `d` string into a flat list of absolute {@link PathSegment}s,
41916
+ with no DOM involved. Every relative command is resolved against the running
41917
+ point, `H`/`V` become `L`, and `S`/`T` expand into `C`/`Q` using the reflected
41918
+ previous control point.
41919
+ @param d An SVG path string (the `d` attribute of a `<path>`).
41920
+ */ function parsePath(d) {
41921
+ var out = [];
41922
+ if (!d) return out;
41923
+ var sc = new Scanner(d);
41924
+ var cmd = null;
41925
+ var cx = 0, cy = 0; // current point
41926
+ var sx = 0, sy = 0; // subpath start (for Z)
41927
+ // Reflected control point of the previous C/S (cubic) or Q/T (quadratic).
41928
+ var px = 0, py = 0;
41929
+ var prevType = "";
41930
+ while(!sc.eof()){
41931
+ var next = sc.nextCommand();
41932
+ if (next) cmd = next;
41933
+ else if (cmd === null) break;
41934
+ else if (cmd === "M") cmd = "L";
41935
+ else if (cmd === "m") cmd = "l";
41936
+ var rel = cmd === cmd.toLowerCase();
41937
+ var C = cmd.toUpperCase();
41938
+ var bx = rel ? cx : 0;
41939
+ var by = rel ? cy : 0;
41940
+ if (C === "M") {
41941
+ cx = sc.readNumber() + bx;
41942
+ cy = sc.readNumber() + by;
41943
+ sx = cx;
41944
+ sy = cy;
41945
+ out.push({
41946
+ type: "M",
41947
+ x: cx,
41948
+ y: cy
41949
+ });
41950
+ } else if (C === "L") {
41951
+ cx = sc.readNumber() + bx;
41952
+ cy = sc.readNumber() + by;
41953
+ out.push({
41954
+ type: "L",
41955
+ x: cx,
41956
+ y: cy
41957
+ });
41958
+ } else if (C === "H") {
41959
+ cx = sc.readNumber() + bx;
41960
+ out.push({
41961
+ type: "L",
41962
+ x: cx,
41963
+ y: cy
41964
+ });
41965
+ } else if (C === "V") {
41966
+ cy = sc.readNumber() + by;
41967
+ out.push({
41968
+ type: "L",
41969
+ x: cx,
41970
+ y: cy
41971
+ });
41972
+ } else if (C === "C") {
41973
+ var x1 = sc.readNumber() + bx, y1 = sc.readNumber() + by;
41974
+ var x2 = sc.readNumber() + bx, y2 = sc.readNumber() + by;
41975
+ cx = sc.readNumber() + bx;
41976
+ cy = sc.readNumber() + by;
41977
+ out.push({
41978
+ type: "C",
41979
+ x1: x1,
41980
+ y1: y1,
41981
+ x2: x2,
41982
+ y2: y2,
41983
+ x: cx,
41984
+ y: cy
41985
+ });
41986
+ px = x2;
41987
+ py = y2;
41988
+ } else if (C === "S") {
41989
+ var ref = prevType === "C" || prevType === "S";
41990
+ var x11 = ref ? 2 * cx - px : cx, y11 = ref ? 2 * cy - py : cy;
41991
+ var x21 = sc.readNumber() + bx, y21 = sc.readNumber() + by;
41992
+ cx = sc.readNumber() + bx;
41993
+ cy = sc.readNumber() + by;
41994
+ out.push({
41995
+ type: "C",
41996
+ x1: x11,
41997
+ y1: y11,
41998
+ x2: x21,
41999
+ y2: y21,
42000
+ x: cx,
42001
+ y: cy
42002
+ });
42003
+ px = x21;
42004
+ py = y21;
42005
+ } else if (C === "Q") {
42006
+ var x12 = sc.readNumber() + bx, y12 = sc.readNumber() + by;
42007
+ cx = sc.readNumber() + bx;
42008
+ cy = sc.readNumber() + by;
42009
+ out.push({
42010
+ type: "Q",
42011
+ x1: x12,
42012
+ y1: y12,
42013
+ x: cx,
42014
+ y: cy
42015
+ });
42016
+ px = x12;
42017
+ py = y12;
42018
+ } else if (C === "T") {
42019
+ var ref1 = prevType === "Q" || prevType === "T";
42020
+ var x13 = ref1 ? 2 * cx - px : cx, y13 = ref1 ? 2 * cy - py : cy;
42021
+ cx = sc.readNumber() + bx;
42022
+ cy = sc.readNumber() + by;
42023
+ out.push({
42024
+ type: "Q",
42025
+ x1: x13,
42026
+ y1: y13,
42027
+ x: cx,
42028
+ y: cy
42029
+ });
42030
+ px = x13;
42031
+ py = y13;
42032
+ } else if (C === "A") {
42033
+ var rx = sc.readNumber(), ry = sc.readNumber(), rot = sc.readNumber();
42034
+ var large = sc.readFlag(), sweep = sc.readFlag();
42035
+ cx = sc.readNumber() + bx;
42036
+ cy = sc.readNumber() + by;
42037
+ out.push({
42038
+ type: "A",
42039
+ rx: rx,
42040
+ ry: ry,
42041
+ rot: rot,
42042
+ large: large,
42043
+ sweep: sweep,
42044
+ x: cx,
42045
+ y: cy
42046
+ });
42047
+ } else if (C === "Z") {
42048
+ out.push({
42049
+ type: "Z"
42050
+ });
42051
+ cx = sx;
42052
+ cy = sy;
42053
+ } else {
42054
+ break;
42055
+ }
42056
+ prevType = C;
42057
+ // Stop repeating this command once its arguments are exhausted.
42058
+ if (C !== "Z" && !sc.moreArgs()) ;
42059
+ }
42060
+ return out;
42061
+ }
42062
+ /**
42063
+ Converts an SVG endpoint-parameterized arc to its center parameterization
42064
+ (SVG spec F.6.5), returning the ellipse center, corrected radii, x-axis
42065
+ rotation (radians), start angle and signed sweep. Returns null for a
42066
+ degenerate arc (zero radius), which callers treat as a straight line.
42067
+ @private
42068
+ */ function arcToCenter(x1, y1, rx, ry, rotDeg, large, sweep, x2, y2) {
42069
+ rx = Math.abs(rx);
42070
+ ry = Math.abs(ry);
42071
+ if (rx === 0 || ry === 0) return null;
42072
+ var phi = rotDeg * Math.PI / 180;
42073
+ var cosP = Math.cos(phi), sinP = Math.sin(phi);
42074
+ var dx = (x1 - x2) / 2, dy = (y1 - y2) / 2;
42075
+ var x1p = cosP * dx + sinP * dy;
42076
+ var y1p = -sinP * dx + cosP * dy;
42077
+ // Scale radii up if they are too small to span the endpoints.
42078
+ var lambda = x1p * x1p / (rx * rx) + y1p * y1p / (ry * ry);
42079
+ if (lambda > 1) {
42080
+ var s = Math.sqrt(lambda);
42081
+ rx *= s;
42082
+ ry *= s;
42083
+ }
42084
+ var sign = large !== sweep ? 1 : -1;
42085
+ var num = rx * rx * ry * ry - rx * rx * y1p * y1p - ry * ry * x1p * x1p;
42086
+ var den = rx * rx * y1p * y1p + ry * ry * x1p * x1p;
42087
+ var co = sign * Math.sqrt(Math.max(0, num / den));
42088
+ var cxp = co * rx * y1p / ry;
42089
+ var cyp = -co * ry * x1p / rx;
42090
+ var cx = cosP * cxp - sinP * cyp + (x1 + x2) / 2;
42091
+ var cy = sinP * cxp + cosP * cyp + (y1 + y2) / 2;
42092
+ var ang = function ang(ux, uy, vx, vy) {
42093
+ var dot = ux * vx + uy * vy;
42094
+ var len = Math.sqrt((ux * ux + uy * uy) * (vx * vx + vy * vy));
42095
+ var a = Math.acos(Math.min(1, Math.max(-1, dot / len)));
42096
+ if (ux * vy - uy * vx < 0) a = -a;
42097
+ return a;
42098
+ };
42099
+ var theta1 = ang(1, 0, (x1p - cxp) / rx, (y1p - cyp) / ry);
42100
+ var dtheta = ang((x1p - cxp) / rx, (y1p - cyp) / ry, (-x1p - cxp) / rx, (-y1p - cyp) / ry);
42101
+ if (!sweep && dtheta > 0) dtheta -= 2 * Math.PI;
42102
+ else if (sweep && dtheta < 0) dtheta += 2 * Math.PI;
42103
+ return {
42104
+ cx: cx,
42105
+ cy: cy,
42106
+ rx: rx,
42107
+ ry: ry,
42108
+ phi: phi,
42109
+ theta1: theta1,
42110
+ dtheta: dtheta
42111
+ };
42112
+ }
42113
+ /** A point on a center-parameterized arc at absolute ellipse angle `theta`. */ function arcPoint(arc, theta) {
42114
+ var cosP = Math.cos(arc.phi), sinP = Math.sin(arc.phi);
42115
+ var ct = Math.cos(theta), st = Math.sin(theta);
42116
+ return [
42117
+ arc.cx + arc.rx * ct * cosP - arc.ry * st * sinP,
42118
+ arc.cy + arc.rx * ct * sinP + arc.ry * st * cosP
42119
+ ];
42120
+ }
42121
+
42122
+ function _array_like_to_array$1(arr, len) {
42123
+ if (len == null || len > arr.length) len = arr.length;
42124
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
42125
+ return arr2;
42126
+ }
42127
+ function _array_with_holes$1(arr) {
42128
+ if (Array.isArray(arr)) return arr;
42129
+ }
42130
+ function _iterable_to_array_limit$1(arr, i) {
42131
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
42132
+ if (_i == null) return;
42133
+ var _arr = [];
42134
+ var _n = true;
42135
+ var _d = false;
42136
+ var _s, _e;
42137
+ try {
42138
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
42139
+ _arr.push(_s.value);
42140
+ if (i && _arr.length === i) break;
42141
+ }
42142
+ } catch (err) {
42143
+ _d = true;
42144
+ _e = err;
42145
+ } finally{
42146
+ try {
42147
+ if (!_n && _i["return"] != null) _i["return"]();
42148
+ } finally{
42149
+ if (_d) throw _e;
42150
+ }
42151
+ }
42152
+ return _arr;
42153
+ }
42154
+ function _non_iterable_rest$1() {
42155
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
42156
+ }
42157
+ function _sliced_to_array$1(arr, i) {
42158
+ return _array_with_holes$1(arr) || _iterable_to_array_limit$1(arr, i) || _unsupported_iterable_to_array$1(arr, i) || _non_iterable_rest$1();
42159
+ }
42160
+ function _unsupported_iterable_to_array$1(o, minLen) {
42161
+ if (!o) return;
42162
+ if (typeof o === "string") return _array_like_to_array$1(o, minLen);
42163
+ var n = Object.prototype.toString.call(o).slice(8, -1);
42164
+ if (n === "Object" && o.constructor) n = o.constructor.name;
42165
+ if (n === "Map" || n === "Set") return Array.from(n);
42166
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$1(o, minLen);
42167
+ }
42168
+ /** Chord-length of a cubic Bézier's control polygon — an upper bound on its arc length. */ function cubicPolyLen(x0, y0, x1, y1, x2, y2, x3, y3) {
42169
+ return Math.hypot(x1 - x0, y1 - y0) + Math.hypot(x2 - x1, y2 - y1) + Math.hypot(x3 - x2, y3 - y2);
42170
+ }
42171
+ /**
42172
+ Transforms a path string into an Array of points, with no DOM involved.
42173
+ Straight segments contribute their endpoints; curves and arcs are flattened
42174
+ into line segments no longer than `segmentLength`. Higher `segmentLength`
42175
+ values lower computation time but yield more rigid curves.
41329
42176
  @param path An SVG string path, commonly the "d" property of a <path> element.
41330
- @param segmentLength The length of line segments when converting curves line segments. Higher values lower computation time, but will result in curves that are more rigid.
42177
+ @param segmentLength The maximum length of line segments when flattening curves.
41331
42178
  */ function path2polygon(path) {
41332
42179
  var segmentLength = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 50;
41333
- if (typeof document === "undefined") return [];
41334
- var svgPath = document.createElementNS("http://www.w3.org/2000/svg", "path");
41335
- svgPath.setAttribute("d", path);
41336
- var len = svgPath.getTotalLength();
41337
- var NUM_POINTS = len / segmentLength < 10 ? len / 10 : len / segmentLength;
41338
42180
  var points = [];
41339
- for(var i = 0; i < NUM_POINTS; i++){
41340
- var pt = svgPath.getPointAtLength(i * len / (NUM_POINTS - 1));
41341
- points.push([
41342
- pt.x,
41343
- pt.y
42181
+ var step = Math.max(1, segmentLength);
42182
+ var cx = 0, cy = 0;
42183
+ var push = function push(x, y) {
42184
+ var last = points[points.length - 1];
42185
+ // Skip exact duplicates (e.g. a curve start == the previous endpoint).
42186
+ if (!last || last[0] !== x || last[1] !== y) points.push([
42187
+ x,
42188
+ y
41344
42189
  ]);
42190
+ };
42191
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
42192
+ try {
42193
+ for(var _iterator = parsePath(path)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
42194
+ var seg = _step.value;
42195
+ if (seg.type === "M" || seg.type === "L") {
42196
+ push(seg.x, seg.y);
42197
+ cx = seg.x;
42198
+ cy = seg.y;
42199
+ } else if (seg.type === "C") {
42200
+ var len = cubicPolyLen(cx, cy, seg.x1, seg.y1, seg.x2, seg.y2, seg.x, seg.y);
42201
+ var n = Math.max(2, Math.ceil(len / step));
42202
+ for(var i = 1; i <= n; i++){
42203
+ var t = i / n, u = 1 - t;
42204
+ push(u * u * u * cx + 3 * u * u * t * seg.x1 + 3 * u * t * t * seg.x2 + t * t * t * seg.x, u * u * u * cy + 3 * u * u * t * seg.y1 + 3 * u * t * t * seg.y2 + t * t * t * seg.y);
42205
+ }
42206
+ cx = seg.x;
42207
+ cy = seg.y;
42208
+ } else if (seg.type === "Q") {
42209
+ var len1 = Math.hypot(seg.x1 - cx, seg.y1 - cy) + Math.hypot(seg.x - seg.x1, seg.y - seg.y1);
42210
+ var n1 = Math.max(2, Math.ceil(len1 / step));
42211
+ for(var i1 = 1; i1 <= n1; i1++){
42212
+ var t1 = i1 / n1, u1 = 1 - t1;
42213
+ push(u1 * u1 * cx + 2 * u1 * t1 * seg.x1 + t1 * t1 * seg.x, u1 * u1 * cy + 2 * u1 * t1 * seg.y1 + t1 * t1 * seg.y);
42214
+ }
42215
+ cx = seg.x;
42216
+ cy = seg.y;
42217
+ } else if (seg.type === "A") {
42218
+ var arc = arcToCenter(cx, cy, seg.rx, seg.ry, seg.rot, seg.large, seg.sweep, seg.x, seg.y);
42219
+ if (!arc) {
42220
+ push(seg.x, seg.y);
42221
+ } else {
42222
+ // Estimate length from the average radius × swept angle.
42223
+ var len2 = (arc.rx + arc.ry) / 2 * Math.abs(arc.dtheta);
42224
+ var n2 = Math.max(2, Math.ceil(len2 / step));
42225
+ for(var i2 = 1; i2 <= n2; i2++){
42226
+ var _arcPoint = _sliced_to_array$1(arcPoint(arc, arc.theta1 + arc.dtheta * i2 / n2), 2), px = _arcPoint[0], py = _arcPoint[1];
42227
+ push(px, py);
42228
+ }
42229
+ }
42230
+ cx = seg.x;
42231
+ cy = seg.y;
42232
+ }
42233
+ // Z contributes no new vertex — the subpath start is already in `points`.
42234
+ }
42235
+ } catch (err) {
42236
+ _didIteratorError = true;
42237
+ _iteratorError = err;
42238
+ } finally{
42239
+ try {
42240
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
42241
+ _iterator.return();
42242
+ }
42243
+ } finally{
42244
+ if (_didIteratorError) {
42245
+ throw _iteratorError;
42246
+ }
42247
+ }
41345
42248
  }
41346
42249
  return points;
41347
42250
  }
41348
42251
 
42252
+ function _array_like_to_array(arr, len) {
42253
+ if (len == null || len > arr.length) len = arr.length;
42254
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
42255
+ return arr2;
42256
+ }
42257
+ function _array_with_holes(arr) {
42258
+ if (Array.isArray(arr)) return arr;
42259
+ }
42260
+ function _array_without_holes(arr) {
42261
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
42262
+ }
42263
+ function _iterable_to_array(iter) {
42264
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
42265
+ }
42266
+ function _iterable_to_array_limit(arr, i) {
42267
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
42268
+ if (_i == null) return;
42269
+ var _arr = [];
42270
+ var _n = true;
42271
+ var _d = false;
42272
+ var _s, _e;
42273
+ try {
42274
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
42275
+ _arr.push(_s.value);
42276
+ if (i && _arr.length === i) break;
42277
+ }
42278
+ } catch (err) {
42279
+ _d = true;
42280
+ _e = err;
42281
+ } finally{
42282
+ try {
42283
+ if (!_n && _i["return"] != null) _i["return"]();
42284
+ } finally{
42285
+ if (_d) throw _e;
42286
+ }
42287
+ }
42288
+ return _arr;
42289
+ }
42290
+ function _non_iterable_rest() {
42291
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
42292
+ }
42293
+ function _non_iterable_spread() {
42294
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
42295
+ }
42296
+ function _sliced_to_array(arr, i) {
42297
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
42298
+ }
42299
+ function _to_consumable_array(arr) {
42300
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
42301
+ }
42302
+ function _unsupported_iterable_to_array(o, minLen) {
42303
+ if (!o) return;
42304
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
42305
+ var n = Object.prototype.toString.call(o).slice(8, -1);
42306
+ if (n === "Object" && o.constructor) n = o.constructor.name;
42307
+ if (n === "Map" || n === "Set") return Array.from(n);
42308
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
42309
+ }
42310
+ /** Value of a cubic Bézier on one axis at parameter t. */ function cubicAt(p0, p1, p2, p3, t) {
42311
+ var u = 1 - t;
42312
+ return u * u * u * p0 + 3 * u * u * t * p1 + 3 * u * t * t * p2 + t * t * t * p3;
42313
+ }
42314
+ /** Value of a quadratic Bézier on one axis at parameter t. */ function quadAt(p0, p1, p2, t) {
42315
+ var u = 1 - t;
42316
+ return u * u * p0 + 2 * u * t * p1 + t * t * p2;
42317
+ }
42318
+ /** Parameters in (0,1) where a cubic Bézier's derivative is zero on one axis. */ function cubicExtrema(p0, p1, p2, p3) {
42319
+ var a = p3 - 3 * p2 + 3 * p1 - p0;
42320
+ var b = 2 * (p2 - 2 * p1 + p0);
42321
+ var c = p1 - p0;
42322
+ var ts = [];
42323
+ if (Math.abs(a) < 1e-12) {
42324
+ if (Math.abs(b) > 1e-12) ts.push(-c / b);
42325
+ } else {
42326
+ var disc = b * b - 4 * a * c;
42327
+ if (disc >= 0) {
42328
+ var s = Math.sqrt(disc);
42329
+ ts.push((-b + s) / (2 * a), (-b - s) / (2 * a));
42330
+ }
42331
+ }
42332
+ return ts.filter(function(t) {
42333
+ return t > 0 && t < 1;
42334
+ });
42335
+ }
42336
+ /** Parameter in (0,1) where a quadratic Bézier's derivative is zero on one axis. */ function quadExtremum(p0, p1, p2) {
42337
+ var den = p0 - 2 * p1 + p2;
42338
+ if (Math.abs(den) < 1e-12) return [];
42339
+ var t = (p0 - p1) / den;
42340
+ return t > 0 && t < 1 ? [
42341
+ t
42342
+ ] : [];
42343
+ }
42344
+ /** True when absolute ellipse angle `theta` falls inside the arc's signed sweep. */ function angleInArc(theta, theta1, dtheta) {
42345
+ var TAU = 2 * Math.PI;
42346
+ var d = theta - theta1;
42347
+ if (dtheta >= 0) {
42348
+ while(d < 0)d += TAU;
42349
+ while(d > TAU)d -= TAU;
42350
+ return d <= dtheta + 1e-9;
42351
+ }
42352
+ while(d > 0)d -= TAU;
42353
+ while(d < -TAU)d += TAU;
42354
+ return d >= dtheta - 1e-9;
42355
+ }
42356
+ /**
42357
+ Computes the exact bounding box of an SVG path string with no DOM involved,
42358
+ evaluating the true extrema of each Bézier and arc segment (not a sampled
42359
+ approximation). Returns `{x, y, width, height}`, or a zero-size box at the
42360
+ origin for an empty/unparseable path.
42361
+ @param d An SVG path string (the `d` attribute of a `<path>`).
42362
+ */ function pathBounds(d) {
42363
+ var minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
42364
+ var add = function add(x, y) {
42365
+ if (x < minX) minX = x;
42366
+ if (y < minY) minY = y;
42367
+ if (x > maxX) maxX = x;
42368
+ if (y > maxY) maxY = y;
42369
+ };
42370
+ var cx = 0, cy = 0;
42371
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
42372
+ try {
42373
+ for(var _iterator = parsePath(d)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
42374
+ var seg = _step.value;
42375
+ if (seg.type === "M" || seg.type === "L") {
42376
+ add(seg.x, seg.y);
42377
+ cx = seg.x;
42378
+ cy = seg.y;
42379
+ } else if (seg.type === "C") {
42380
+ add(cx, cy);
42381
+ add(seg.x, seg.y);
42382
+ // At each axis extremum, include the full point on the curve — only the
42383
+ // extreme axis grows the box, the other coordinate is a real point on it.
42384
+ var ts = _to_consumable_array(cubicExtrema(cx, seg.x1, seg.x2, seg.x)).concat(_to_consumable_array(cubicExtrema(cy, seg.y1, seg.y2, seg.y)));
42385
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
42386
+ try {
42387
+ for(var _iterator1 = ts[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
42388
+ var t = _step1.value;
42389
+ add(cubicAt(cx, seg.x1, seg.x2, seg.x, t), cubicAt(cy, seg.y1, seg.y2, seg.y, t));
42390
+ }
42391
+ } catch (err) {
42392
+ _didIteratorError1 = true;
42393
+ _iteratorError1 = err;
42394
+ } finally{
42395
+ try {
42396
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
42397
+ _iterator1.return();
42398
+ }
42399
+ } finally{
42400
+ if (_didIteratorError1) {
42401
+ throw _iteratorError1;
42402
+ }
42403
+ }
42404
+ }
42405
+ cx = seg.x;
42406
+ cy = seg.y;
42407
+ } else if (seg.type === "Q") {
42408
+ add(cx, cy);
42409
+ add(seg.x, seg.y);
42410
+ var ts1 = _to_consumable_array(quadExtremum(cx, seg.x1, seg.x)).concat(_to_consumable_array(quadExtremum(cy, seg.y1, seg.y)));
42411
+ var _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = undefined;
42412
+ try {
42413
+ for(var _iterator2 = ts1[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true){
42414
+ var t1 = _step2.value;
42415
+ add(quadAt(cx, seg.x1, seg.x, t1), quadAt(cy, seg.y1, seg.y, t1));
42416
+ }
42417
+ } catch (err) {
42418
+ _didIteratorError2 = true;
42419
+ _iteratorError2 = err;
42420
+ } finally{
42421
+ try {
42422
+ if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
42423
+ _iterator2.return();
42424
+ }
42425
+ } finally{
42426
+ if (_didIteratorError2) {
42427
+ throw _iteratorError2;
42428
+ }
42429
+ }
42430
+ }
42431
+ cx = seg.x;
42432
+ cy = seg.y;
42433
+ } else if (seg.type === "A") {
42434
+ add(cx, cy);
42435
+ add(seg.x, seg.y);
42436
+ var arc = arcToCenter(cx, cy, seg.rx, seg.ry, seg.rot, seg.large, seg.sweep, seg.x, seg.y);
42437
+ if (arc) {
42438
+ var phi = arc.phi, rx = arc.rx, ry = arc.ry, theta1 = arc.theta1, dtheta = arc.dtheta;
42439
+ // Ellipse-angle candidates where dX/dθ = 0 and dY/dθ = 0.
42440
+ var cands = [
42441
+ Math.atan2(-ry * Math.sin(phi), rx * Math.cos(phi)),
42442
+ Math.atan2(ry * Math.cos(phi), rx * Math.sin(phi))
42443
+ ];
42444
+ var _iteratorNormalCompletion3 = true, _didIteratorError3 = false, _iteratorError3 = undefined;
42445
+ try {
42446
+ for(var _iterator3 = cands[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true){
42447
+ var base = _step3.value;
42448
+ for(var _i = 0, _iter = [
42449
+ base,
42450
+ base + Math.PI
42451
+ ]; _i < _iter.length; _i++){
42452
+ var theta = _iter[_i];
42453
+ if (angleInArc(theta, theta1, dtheta)) {
42454
+ var _arcPoint = _sliced_to_array(arcPoint(arc, theta), 2), px = _arcPoint[0], py = _arcPoint[1];
42455
+ add(px, py);
42456
+ }
42457
+ }
42458
+ }
42459
+ } catch (err) {
42460
+ _didIteratorError3 = true;
42461
+ _iteratorError3 = err;
42462
+ } finally{
42463
+ try {
42464
+ if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
42465
+ _iterator3.return();
42466
+ }
42467
+ } finally{
42468
+ if (_didIteratorError3) {
42469
+ throw _iteratorError3;
42470
+ }
42471
+ }
42472
+ }
42473
+ }
42474
+ cx = seg.x;
42475
+ cy = seg.y;
42476
+ }
42477
+ }
42478
+ } catch (err) {
42479
+ _didIteratorError = true;
42480
+ _iteratorError = err;
42481
+ } finally{
42482
+ try {
42483
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
42484
+ _iterator.return();
42485
+ }
42486
+ } finally{
42487
+ if (_didIteratorError) {
42488
+ throw _iteratorError;
42489
+ }
42490
+ }
42491
+ }
42492
+ if (!Number.isFinite(minX)) return {
42493
+ x: 0,
42494
+ y: 0,
42495
+ width: 0,
42496
+ height: 0
42497
+ };
42498
+ return {
42499
+ x: minX,
42500
+ y: minY,
42501
+ width: maxX - minX,
42502
+ height: maxY - minY
42503
+ };
42504
+ }
42505
+
41349
42506
  /**
41350
42507
  Calculates the pixel distance between two points.
41351
42508
  @param p1 The first point, which should always be an `[x, y]` formatted Array.
@@ -41806,12 +42963,38 @@
41806
42963
  the swatch↔hit-area crossing) but a DISTINCT `key`: the hit-area and the
41807
42964
  visible geometry are siblings, and the SVG keyed join can't hold two nodes
41808
42965
  under one key — sharing it made the geometry re-enter (collapse→grow) on every
41809
- redraw (a "pulse" on e.g. every timeline step). Returns null when no
41810
- rect-style hitArea is configured; Line's path-style hitArea is covered by its
41811
- own geometry.
41812
- */ function hitAreaNode(hitArea, d, i, aes, key, datum, name, transform) {
42966
+ redraw (a "pulse" on e.g. every timeline step). Returns null when no hitArea
42967
+ is configured. A path-style hitArea (Line: a fat, transparent stroke) reuses
42968
+ the resolved geometry `d`/`transform` so the hover target overlaps the
42969
+ visible line exactly while extending past its ~1px stroke.
42970
+ */ function hitAreaNode(hitArea, d, i, aes, key, datum, name, transform, geomD) {
41813
42971
  const bounds = typeof hitArea === "function" ? hitArea(d, i, aes) : hitArea;
41814
- if (!bounds || typeof bounds.width !== "number" || typeof bounds.height !== "number") return null;
42972
+ if (!bounds) return null;
42973
+ // Path-style hitArea (Line): widen the hover target to a fat transparent
42974
+ // stroke over the line's own geometry. `stroke: transparent` (not "none") is
42975
+ // painted, so it hit-tests across the full width on both backends.
42976
+ if (typeof bounds.width !== "number" && typeof geomD === "string") {
42977
+ const sw = typeof bounds["stroke-width"] === "number" ? bounds["stroke-width"] : 10;
42978
+ return {
42979
+ type: "path",
42980
+ d: geomD,
42981
+ key: `${key}::hit`,
42982
+ datum,
42983
+ index: i,
42984
+ shapeType: name,
42985
+ paint: {
42986
+ fill: "none",
42987
+ stroke: "transparent",
42988
+ strokeWidth: sw,
42989
+ vectorEffect: "non-scaling-stroke"
42990
+ },
42991
+ transform,
42992
+ aria: {
42993
+ hidden: true
42994
+ }
42995
+ };
42996
+ }
42997
+ if (typeof bounds.width !== "number" || typeof bounds.height !== "number") return null;
41815
42998
  return {
41816
42999
  type: "rect",
41817
43000
  x: typeof bounds.x === "number" ? bounds.x : -bounds.width / 2,
@@ -41832,152 +43015,34 @@
41832
43015
  };
41833
43016
  }
41834
43017
 
41835
- /** Image's fluent accessor schema. Config storage lives on `this.schema.<key>`. */ const imageSchema = [
41836
- {
41837
- key: "duration",
41838
- coerce: "identity",
41839
- default: 600
41840
- },
41841
- {
41842
- key: "height",
41843
- coerce: "accessor",
41844
- default: accessor("height")
41845
- },
41846
- {
41847
- key: "id",
41848
- coerce: "identity",
41849
- default: accessor("id")
41850
- },
41851
- {
41852
- key: "opacity",
41853
- coerce: "const",
41854
- default: constant$b(1)
41855
- },
41856
- {
41857
- key: "pointerEvents",
41858
- coerce: "const",
41859
- default: constant$b("auto")
41860
- },
41861
- {
41862
- key: "renderMode",
41863
- coerce: "identity",
41864
- default: "full"
41865
- },
41866
- {
41867
- key: "url",
41868
- coerce: "identity",
41869
- default: accessor("url")
41870
- },
41871
- {
41872
- key: "width",
41873
- coerce: "accessor",
41874
- default: accessor("width")
41875
- },
41876
- {
41877
- key: "x",
41878
- coerce: "const",
41879
- default: accessor("x", 0)
41880
- },
41881
- {
41882
- key: "y",
41883
- coerce: "const",
41884
- default: accessor("y", 0)
41885
- }
41886
- ];
41887
- let Image$1 = class Image {
41888
- config(_) {
41889
- if (!arguments.length) return {
41890
- ...this.schema,
41891
- data: this._data,
41892
- select: this._select
41893
- };
41894
- const patch = _;
41895
- for(const k in patch){
41896
- if (!Object.prototype.hasOwnProperty.call(patch, k)) continue;
41897
- // `this[k]` resolves the fluent accessor via the index signature.
41898
- if (typeof this[k] === "function") this[k](patch[k]);
41899
- else this.schema[k] = patch[k];
41900
- }
41901
- return this;
41902
- }
41903
- /**
41904
- Renders the current Image to the page. If a *callback* is specified, it will be called once the images are done drawing.
41905
- @param callback Optional callback invoked after rendering completes.
41906
- */ render(callback) {
41907
- // Compute mode is a no-op for DOM emission — the caller will read
41908
- // `toScene()` to get a SceneNode tree, no need to mount.
41909
- if (this.schema.renderMode === "compute") {
41910
- if (callback) setTimeout(callback, 0);
41911
- return this;
41912
- }
41913
- if (this._select === void 0) this.select(select("body").append("svg").style("width", `${window.innerWidth}px`).style("height", `${window.innerHeight}px`).style("display", "block").node());
41914
- const images = this._select.selectAll(".d3plus-Image").data(this._data, this.schema.id);
41915
- const enter = images.enter().append("image").attr("class", "d3plus-Image").attr("opacity", 0).attr("width", 0).attr("height", 0).attr("x", (d, i)=>this.schema.x(d, i) + this.schema.width(d, i) / 2).attr("y", (d, i)=>this.schema.y(d, i) + this.schema.height(d, i) / 2);
41916
- const t = transition().duration(this.schema.duration), that = this, update = enter.merge(images);
41917
- update.attr("xlink:href", this.schema.url).style("pointer-events", this.schema.pointerEvents).transition(t).attr("opacity", this.schema.opacity).attr("width", (d, i)=>this.schema.width(d, i)).attr("height", (d, i)=>this.schema.height(d, i)).attr("x", (d, i)=>this.schema.x(d, i)).attr("y", (d, i)=>this.schema.y(d, i)).each(function(d, i) {
41918
- const image = select(this), link = that.schema.url(d, i);
41919
- const fullAddress = link.indexOf("http://") === 0 || link.indexOf("https://") === 0;
41920
- if (!fullAddress || link.indexOf(window.location.hostname) === 0) {
41921
- const img = new window.Image();
41922
- img.src = link;
41923
- img.crossOrigin = "Anonymous";
41924
- img.onload = function() {
41925
- const canvas = document.createElement("canvas");
41926
- canvas.width = img.width;
41927
- canvas.height = img.height;
41928
- const context = canvas.getContext("2d");
41929
- context.drawImage(img, 0, 0);
41930
- image.attr("xlink:href", canvas.toDataURL("image/png"));
41931
- };
41932
- }
41933
- });
41934
- images.exit().transition(t).attr("width", (d, i)=>this.schema.width(d, i)).attr("height", (d, i)=>this.schema.height(d, i)).attr("x", (d, i)=>this.schema.x(d, i)).attr("y", (d, i)=>this.schema.y(d, i)).attr("opacity", 0).remove();
41935
- if (callback) setTimeout(callback, this.schema.duration + 100);
41936
- return this;
41937
- }
41938
- data(_) {
41939
- return arguments.length ? (this._data = _, this) : this._data;
41940
- }
41941
- /**
41942
- Compute-mode scene emission. Mirrors Shape.toScene's shape — a
41943
- keyed GroupNode wrapping per-datum ImageNodes. Used by chart
41944
- compositors (Shape._backgroundImageClass, plotPaint) that need
41945
- Image to participate in the scene graph rather than emit
41946
- d3-selection DOM.
41947
- */ toScene() {
41948
- const children = (this._data || []).map((d, i)=>{
41949
- const node = {
41950
- type: "image",
41951
- key: `${this.schema.id(d, i)}`,
41952
- x: this.schema.x(d, i),
41953
- y: this.schema.y(d, i),
41954
- width: this.schema.width(d, i),
41955
- height: this.schema.height(d, i),
41956
- href: this.schema.url(d, i),
41957
- paint: {
41958
- opacity: this.schema.opacity(d, i)
41959
- },
41960
- datum: d,
41961
- index: i
41962
- };
41963
- return node;
43018
+ /**
43019
+ For a nested shape datum (Line/Area, whose datum wraps many points) returns a
43020
+ spreadable scene-node fragment carrying each point's content-space position
43021
+ paired with its source datum, so the pointer bridge can report the point
43022
+ nearest the cursor rather than the whole-series aggregate. Points the
43023
+ `defined` accessor rejects, or whose position isn't finite (a missing value),
43024
+ are skipped — so the nearest match is always a real, defined point. Returns
43025
+ an empty object for non-nested data (spreads to nothing).
43026
+ */ function interactionPoints(d, x, y, defined) {
43027
+ if (!d.__d3plusShape__ || !Array.isArray(d.values)) return {};
43028
+ const values = d.values;
43029
+ const points = [];
43030
+ values.forEach((v, k)=>{
43031
+ if (typeof defined === "function" && defined(v, k) === false) return;
43032
+ const px = Number(x(v, k));
43033
+ const py = Number(y(v, k));
43034
+ if (!Number.isFinite(px) || !Number.isFinite(py)) return;
43035
+ points.push({
43036
+ x: px,
43037
+ y: py,
43038
+ datum: v,
43039
+ index: typeof v.i === "number" ? v.i : k
41964
43040
  });
41965
- return {
41966
- type: "group",
41967
- key: "d3plus-Image",
41968
- children
41969
- };
41970
- }
41971
- select(_) {
41972
- return arguments.length ? (this._select = select(_), this) : this._select;
41973
- }
41974
- /**
41975
- Invoked when creating a new class instance, and sets any default parameters.
41976
- @private
41977
- */ constructor(){
41978
- installFluent(this, imageSchema);
41979
- }
41980
- };
43041
+ });
43042
+ return points.length ? {
43043
+ interactionPoints: points
43044
+ } : {};
43045
+ }
41981
43046
 
41982
43047
  /** Follows the chart (`__d3plus__`) and shape (`__d3plusShape__`) wrappers back
41983
43048
  to the source datum, so a `sort` comparator sees the same object the other
@@ -42001,18 +43066,219 @@
42001
43066
  order.forEach((origIdx, pos)=>rank[origIdx] = pos);
42002
43067
  return rank;
42003
43068
  }
43069
+ /** Bounding box of a list of polygon points, or null when degenerate. */ function pointsBox(points) {
43070
+ if (!points.length) return null;
43071
+ let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
43072
+ for (const [px, py] of points){
43073
+ if (px < minX) minX = px;
43074
+ if (py < minY) minY = py;
43075
+ if (px > maxX) maxX = px;
43076
+ if (py > maxY) maxY = py;
43077
+ }
43078
+ if (!Number.isFinite(minX) || maxX <= minX || maxY <= minY) return null;
43079
+ return {
43080
+ x: minX,
43081
+ y: minY,
43082
+ width: maxX - minX,
43083
+ height: maxY - minY
43084
+ };
43085
+ }
43086
+ /**
43087
+ The local-space bounding box `{x, y, width, height}` a backgroundImage fills,
43088
+ derived from a datum's scene geometry. Rect/Bar geometry is already a box;
43089
+ Circle is centered at (cx, cy) with radius r; a `path` uses the exact
43090
+ (DOM-free) bounds of its `d`; Area/Line fall back to their polygon `points`.
43091
+ Returns null when no finite extent can be determined.
43092
+ */ function backgroundImageBox(g, points) {
43093
+ if (typeof g.width === "number" && typeof g.height === "number") {
43094
+ const x = typeof g.x === "number" ? g.x : -g.width / 2;
43095
+ const y = typeof g.y === "number" ? g.y : -g.height / 2;
43096
+ return {
43097
+ x,
43098
+ y,
43099
+ width: g.width,
43100
+ height: g.height
43101
+ };
43102
+ }
43103
+ if (typeof g.r === "number") {
43104
+ const cx = typeof g.cx === "number" ? g.cx : 0;
43105
+ const cy = typeof g.cy === "number" ? g.cy : 0;
43106
+ return {
43107
+ x: cx - g.r,
43108
+ y: cy - g.r,
43109
+ width: g.r * 2,
43110
+ height: g.r * 2
43111
+ };
43112
+ }
43113
+ if (typeof g.d === "string") {
43114
+ const b = pathBounds(g.d);
43115
+ return b.width > 0 && b.height > 0 ? b : null;
43116
+ }
43117
+ return pointsBox(points);
43118
+ }
43119
+ /** Rounded-rectangle path `d` (falls back to a plain rect when radii are 0). */ function roundedRectPath(x, y, w, h, rx, ry) {
43120
+ rx = Math.min(rx, w / 2);
43121
+ ry = Math.min(ry, h / 2);
43122
+ return `M${x + rx},${y}h${w - 2 * rx}a${rx},${ry} 0 0 1 ${rx},${ry}` + `v${h - 2 * ry}a${rx},${ry} 0 0 1 ${-rx},${ry}h${-(w - 2 * rx)}` + `a${rx},${ry} 0 0 1 ${-rx},${-ry}v${-(h - 2 * ry)}a${rx},${ry} 0 0 1 ${rx},${-ry}Z`;
43123
+ }
43124
+ /**
43125
+ The shape's own geometry expressed as a clip region in its LOCAL coordinate
43126
+ space, so a background image can be clipped to the shape itself (a Path image
43127
+ is clipped to the path, a Circle image to the circle, etc.). Returns
43128
+ undefined when the geometry has no usable outline.
43129
+ */ function backgroundImageClip(g, points) {
43130
+ if (typeof g.d === "string") return {
43131
+ type: "path",
43132
+ d: g.d
43133
+ };
43134
+ if (typeof g.width === "number" && typeof g.height === "number") {
43135
+ const x = typeof g.x === "number" ? g.x : -g.width / 2;
43136
+ const y = typeof g.y === "number" ? g.y : -g.height / 2;
43137
+ const rx = typeof g.rx === "number" ? g.rx : 0;
43138
+ const ry = typeof g.ry === "number" ? g.ry : 0;
43139
+ return rx > 0 || ry > 0 ? {
43140
+ type: "path",
43141
+ d: roundedRectPath(x, y, g.width, g.height, rx || ry, ry || rx)
43142
+ } : {
43143
+ type: "rect",
43144
+ x,
43145
+ y,
43146
+ width: g.width,
43147
+ height: g.height
43148
+ };
43149
+ }
43150
+ if (typeof g.r === "number") {
43151
+ const cx = typeof g.cx === "number" ? g.cx : 0;
43152
+ const cy = typeof g.cy === "number" ? g.cy : 0;
43153
+ const r = g.r;
43154
+ return {
43155
+ type: "path",
43156
+ d: `M${cx - r},${cy}a${r},${r} 0 1,0 ${2 * r},0a${r},${r} 0 1,0 ${ -2 * r},0Z`
43157
+ };
43158
+ }
43159
+ if (points.length > 2) {
43160
+ const d = `M${points.map(([x, y])=>`${x},${y}`).join("L")}Z`;
43161
+ return {
43162
+ type: "path",
43163
+ d
43164
+ };
43165
+ }
43166
+ return undefined;
43167
+ }
43168
+ /** A polygon (local coords) approximating the shape outline, for `largestRect`. */ function shapePolygon(g, points) {
43169
+ if (typeof g.d === "string") return path2polygon(g.d);
43170
+ return points;
43171
+ }
42004
43172
  /**
42005
- Renders the per-datum background images collected during `Shape.toScene` as
42006
- flat sibling nodes. When `rank` is set (a `sort` comparator is active) every
42007
- returned node needs a `z` — otherwise the backend sort would collapse the
42008
- images to 0 and interleave them among the geometry — so they are placed
42009
- above all geometry (ranks span `0..dataLen-1`) while keeping their own order.
42010
- */ function emitBackgroundImages(bgClass, imageData, rank, dataLen) {
42011
- bgClass.data(imageData).id((d)=>`${d.id}`).url((d)=>d.url).x((d)=>d.x).y((d)=>d.y).width((d)=>d.width).height((d)=>d.height).renderMode("compute");
42012
- const imgScene = bgClass.toScene();
42013
- if (!imgScene || !Array.isArray(imgScene.children)) return [];
42014
- if (rank) imgScene.children.forEach((c, k)=>c.z = dataLen + k);
42015
- return imgScene.children;
43173
+ Resolves a backgroundImage's box + clip + `preserveAspectRatio` for a datum's
43174
+ geometry, honoring the fit mode:
43175
+
43176
+ - `cover` — the image fills the shape's bounding box and is cropped
43177
+ (`xMidYMid slice`), clipped to the shape's own outline.
43178
+ - `contain` — the whole image is centered and fully visible inside the shape:
43179
+ it is fit (`xMidYMid meet`) into the shape's largest inscribed axis-aligned
43180
+ rectangle (a Rect uses itself; a Circle its inscribed square; a Path/Area
43181
+ uses `largestRect` of its polygon). No clip is needed since the box already
43182
+ sits inside the shape.
43183
+
43184
+ Returns null when no usable box can be derived.
43185
+ */ function backgroundImageLayout(g, points, fit) {
43186
+ if (fit !== "contain") {
43187
+ const box = backgroundImageBox(g, points);
43188
+ if (!box) return null;
43189
+ return {
43190
+ box,
43191
+ clip: backgroundImageClip(g, points),
43192
+ preserveAspectRatio: "xMidYMid slice"
43193
+ };
43194
+ }
43195
+ // contain: fit inside the largest inscribed rectangle, fully visible.
43196
+ let box = null;
43197
+ if (typeof g.width === "number" && typeof g.height === "number") {
43198
+ box = backgroundImageBox(g, points); // a rect contains itself
43199
+ } else if (typeof g.r === "number") {
43200
+ // Inscribed square of a circle: side = r·√2, centered on (cx, cy).
43201
+ const cx = typeof g.cx === "number" ? g.cx : 0;
43202
+ const cy = typeof g.cy === "number" ? g.cy : 0;
43203
+ const half = g.r / Math.SQRT2;
43204
+ box = {
43205
+ x: cx - half,
43206
+ y: cy - half,
43207
+ width: half * 2,
43208
+ height: half * 2
43209
+ };
43210
+ } else {
43211
+ const poly = shapePolygon(g, points);
43212
+ const r = poly.length > 2 ? largestRect(poly, {
43213
+ angle: 0
43214
+ }) : null;
43215
+ box = r ? {
43216
+ x: r.cx - r.width / 2,
43217
+ y: r.cy - r.height / 2,
43218
+ width: r.width,
43219
+ height: r.height
43220
+ } : backgroundImageBox(g, points);
43221
+ }
43222
+ return box ? {
43223
+ box,
43224
+ preserveAspectRatio: "xMidYMid meet"
43225
+ } : null;
43226
+ }
43227
+ /**
43228
+ Emits the per-datum background images collected during `Shape.toScene`. Each
43229
+ image is wrapped in its own group carrying the shape's datum + transform, so
43230
+ it is clipped to the shape's outline, positioned in local space, and dims/
43231
+ raises together with its shape on hover. The image is non-interactive (and
43232
+ keyed apart from the shape) so pointer events pass through to the shape below.
43233
+ When `rank` is set (a `sort` comparator is active) every group needs a `z`
43234
+ so the backend sort keeps images above the geometry in their own order.
43235
+ */ function emitBackgroundImages(specs, rank, dataLen) {
43236
+ return specs.map((spec, k)=>{
43237
+ const image = {
43238
+ type: "image",
43239
+ // Keyed apart from the shape (which uses `spec.key`): sharing the key would
43240
+ // let this non-interactive image overwrite the shape in the hit-test index.
43241
+ key: `${spec.key}-bgimage-img`,
43242
+ x: spec.box.x,
43243
+ y: spec.box.y,
43244
+ width: spec.box.width,
43245
+ height: spec.box.height,
43246
+ href: spec.url,
43247
+ preserveAspectRatio: spec.preserveAspectRatio,
43248
+ // Decorative: pointer events fall through to the shape underneath.
43249
+ interactive: false
43250
+ };
43251
+ const group = {
43252
+ type: "group",
43253
+ key: `${spec.key}-bgimage`,
43254
+ children: [
43255
+ image
43256
+ ],
43257
+ // Carry the shape's datum/index so hover/active dimming treats the image
43258
+ // like its shape — dimming and hover-raising the two together (the group
43259
+ // is emitted after the geometry, so at equal `z` the image stays on top).
43260
+ datum: spec.datum,
43261
+ index: spec.index,
43262
+ interactive: false,
43263
+ // A group-level opacity gives the enter/exit animation a target to fade
43264
+ // to/from (matching the shape): the animate layer collapses it to 0 on
43265
+ // enter and eases up to this. It also cascades to the image, so hover
43266
+ // dimming applied here fades the picture with its shape.
43267
+ paint: {
43268
+ opacity: spec.opacity ?? 1
43269
+ },
43270
+ ...spec.transform ? {
43271
+ transform: spec.transform
43272
+ } : {},
43273
+ ...spec.clip ? {
43274
+ clip: spec.clip
43275
+ } : {},
43276
+ ...rank ? {
43277
+ z: dataLen + k
43278
+ } : {}
43279
+ };
43280
+ return group;
43281
+ });
42016
43282
  }
42017
43283
 
42018
43284
  /** Coerces a value to a finite number, or undefined. @private */ function numOrUndef(v) {
@@ -42046,6 +43312,11 @@
42046
43312
  coerce: "const",
42047
43313
  default: constant$b(false)
42048
43314
  },
43315
+ {
43316
+ key: "backgroundImageFit",
43317
+ coerce: "const",
43318
+ default: constant$b("cover")
43319
+ },
42049
43320
  {
42050
43321
  key: "discrete",
42051
43322
  coerce: "identity"
@@ -42281,15 +43552,12 @@
42281
43552
  Renders the current Shape to the page. If a *callback* is specified, it will be called once the shapes are done drawing.
42282
43553
  @param callback Optional callback invoked after rendering completes.
42283
43554
  */ /**
42284
- Resolves a style accessor for a data point, mirroring the nested-data logic
42285
- of _applyStyle so scene output matches DOM rendering.
43555
+ Resolves a style accessor. For a nested shape (Line/Area) the accessor gets
43556
+ the merged aggregate `d.data`/`d.i` — matching `_nestWrapper` + scene datum.
42286
43557
  @private
42287
43558
  */ _styleVal(fn, d, i) {
42288
43559
  if (typeof fn !== "function") return fn;
42289
- if (d.nested && d.key && d.values) {
42290
- const first = d.values[0];
42291
- return fn(first, this._data.indexOf(first));
42292
- }
43560
+ if (d.nested && d.key && d.values) return fn(d.data, d.i);
42293
43561
  return fn(d, i);
42294
43562
  }
42295
43563
  /**
@@ -42358,10 +43626,10 @@
42358
43626
  let data = this._data;
42359
43627
  if (this._dataFilter) data = this._dataFilter(data);
42360
43628
  const children = [];
42361
- // Build the backgroundImage data for emission below. Each datum that
42362
- // resolves to a non-false `backgroundImage(d, i)` becomes an
42363
- // ImageNode positioned at the shape's geometry.
42364
- const imageData = [];
43629
+ // Collected background images, emitted below (after the geometry) as clipped,
43630
+ // transformed groups. Each datum whose `backgroundImage(d, i)` resolves to a
43631
+ // truthy URL contributes one spec.
43632
+ const bgSpecs = [];
42365
43633
  // A `sort` comparator becomes per-datum `z` ranks rather than a reorder of
42366
43634
  // `data`: the render backends sort each group's children ascending by `z`
42367
43635
  // (stably), so a lower rank paints first (behind) and a higher rank paints
@@ -42374,15 +43642,23 @@
42374
43642
  const key = this._nestWrapper(this.schema.id)(d, i);
42375
43643
  const datum = d.__d3plusShape__ ? d.data : d;
42376
43644
  const transform = this._sceneTransform(d, i);
43645
+ // Per-point positions (Line/Area) shared by the geometry and its hit area
43646
+ // so a hover anywhere on either resolves to the nearest point.
43647
+ const iPoints = interactionPoints(d, this.schema.x, this.schema.y, this.schema.defined);
42377
43648
  // Push the hit area (if any) before the geometry so it sits behind it.
43649
+ // Line's is a fat path built from the geometry `d`; Bar/legend etc. a rect.
42378
43650
  if (this.schema.hitArea) {
42379
- const ha = hitAreaNode(this.schema.hitArea, d, i, this._aes(d, i), key, datum, this._name, transform);
43651
+ const ha = hitAreaNode(this.schema.hitArea, d, i, this._aes(d, i), key, datum, this._name, transform, geom.d);
42380
43652
  // Share the datum's rank so the hit area stays paired just behind its
42381
43653
  // own geometry (equal `z`, kept in push order by the stable sort).
42382
43654
  if (ha) children.push(rank ? {
42383
43655
  ...ha,
43656
+ ...iPoints,
42384
43657
  z: rank[i]
42385
- } : ha);
43658
+ } : {
43659
+ ...ha,
43660
+ ...iPoints
43661
+ });
42386
43662
  }
42387
43663
  children.push({
42388
43664
  ...geom,
@@ -42396,45 +43672,42 @@
42396
43672
  role: strOrUndef(this._nestWrapper(this.schema.role)(d, i)),
42397
43673
  label: strOrUndef(this._nestWrapper(this.schema.ariaLabel)(d, i))
42398
43674
  },
43675
+ ...iPoints,
42399
43676
  ...rank ? {
42400
43677
  z: rank[i]
42401
43678
  } : {}
42402
43679
  });
42403
- // backgroundImage: collect a per-datum image when the accessor
42404
- // returns a truthy URL. The image is sized to the shape's
42405
- // geometry (preferring width/height fields when present).
43680
+ // backgroundImage: collect a per-datum image (see backgroundImageLayout for
43681
+ // the cover/contain fit). The wrapping group carries the shape transform,
43682
+ // so the image box + clip stay in local space.
42406
43683
  const bg = this._nestWrapper(this.schema.backgroundImage)(d, i);
42407
43684
  if (bg) {
42408
43685
  const g = geom;
42409
- // Shape geometry is origin-centered; its on-screen position lives in
42410
- // the node transform. The background image is emitted as a flat sibling
42411
- // (no transform), so bake the shape's translate into the image x/y —
42412
- // otherwise every image lands at the origin (top-left).
42413
- const t = this._sceneTransform(d, i);
42414
- const w = typeof g.width === "number" ? g.width : undefined;
42415
- const h = typeof g.height === "number" ? g.height : undefined;
42416
- const cx = typeof g.cx === "number" ? g.cx : typeof g.x === "number" ? g.x : 0;
42417
- const cy = typeof g.cy === "number" ? g.cy : typeof g.y === "number" ? g.y : 0;
42418
- const r = typeof g.r === "number" ? g.r : undefined;
42419
- const iw = w ?? (r != null ? r * 2 : 0);
42420
- const ih = h ?? (r != null ? r * 2 : 0);
42421
- imageData.push({
42422
- __d3plus__: true,
42423
- data: d,
42424
- i,
42425
- id: this._nestWrapper(this.schema.id)(d, i),
42426
- url: bg,
42427
- x: (t.x ?? 0) + cx - iw / 2,
42428
- y: (t.y ?? 0) + cy - ih / 2,
42429
- width: iw,
42430
- height: ih
42431
- });
43686
+ // Only Area/Line lack a `d`/box and need polygon points; Path/Rect/Circle
43687
+ // derive their layout from `d`/width/r directly.
43688
+ const needsPoints = typeof g.d !== "string" && typeof g.width !== "number" && typeof g.r !== "number";
43689
+ const points = needsPoints ? this._aes(d, i).points ?? [] : [];
43690
+ const fit = this._nestWrapper(this.schema.backgroundImageFit)(d, i);
43691
+ const layout = backgroundImageLayout(g, points, fit === "contain" ? "contain" : "cover");
43692
+ if (layout) {
43693
+ bgSpecs.push({
43694
+ key,
43695
+ index: i,
43696
+ datum,
43697
+ url: bg,
43698
+ box: layout.box,
43699
+ clip: layout.clip,
43700
+ preserveAspectRatio: layout.preserveAspectRatio,
43701
+ opacity: numOrUndef(this._nestWrapper(this.schema.opacity)(d, i)),
43702
+ transform
43703
+ });
43704
+ }
42432
43705
  }
42433
43706
  });
42434
43707
  // Emit background images AFTER shape children so they paint above the
42435
43708
  // shape's fill — matches the DOM order where the <image> was
42436
43709
  // appended as a sibling of the shape.
42437
- if (imageData.length) children.push(...emitBackgroundImages(this._backgroundImageClass, imageData, rank, data.length));
43710
+ if (bgSpecs.length) children.push(...emitBackgroundImages(bgSpecs, rank, data.length));
42438
43711
  // NOTE: Labels are NOT pushed here. The canonical aggregation point is
42439
43712
  // `emitHelpers.collectComputed(shape)`, which appends `shape.toScene()`
42440
43713
  // AND `shape._labelClass.toScene()` independently. Pushing labels here
@@ -42597,7 +43870,6 @@
42597
43870
  */ constructor(tagName = "g"){
42598
43871
  super();
42599
43872
  installFluent(this, shapeSchema);
42600
- this._backgroundImageClass = new Image$1();
42601
43873
  this._data = [];
42602
43874
  this._labelClass = new TextBox();
42603
43875
  this._name = "Shape";
@@ -42686,7 +43958,7 @@
42686
43958
  const cx = Number(d.x);
42687
43959
  const cy = Number(d.y);
42688
43960
  const userCurve = String(this.schema.curve.bind(this)(this.config()));
42689
- const curve = d3Shape[`curve${userCurve.charAt(0).toUpperCase()}${userCurve.slice(1)}`];
43961
+ const curve = paths[`curve${userCurve.charAt(0).toUpperCase()}${userCurve.slice(1)}`];
42690
43962
  const offX = (fn)=>(v, z)=>fn(v, z) - cx;
42691
43963
  const offY = (fn)=>(v, z)=>fn(v, z) - cy;
42692
43964
  const gen = d3area().defined(this.schema.defined).curve(curve).x(offX(this.schema.x)).x0(offX(this.schema.x0)).y(offY(this.schema.y)).y0(offY(this.schema.y0));
@@ -43195,7 +44467,7 @@
43195
44467
  const cx = Number(d.x);
43196
44468
  const cy = Number(d.y);
43197
44469
  const userCurve = String(this.schema.curve.bind(this)(this.config()));
43198
- const curve = d3Shape[`curve${userCurve.charAt(0).toUpperCase()}${userCurve.slice(1)}`];
44470
+ const curve = paths[`curve${userCurve.charAt(0).toUpperCase()}${userCurve.slice(1)}`];
43199
44471
  const gen = d3line().curve(curve).defined(this.schema.defined).x((v, z)=>this.schema.x(v, z) - cx).y((v, z)=>this.schema.y(v, z) - cy);
43200
44472
  return {
43201
44473
  type: "path",
@@ -43725,6 +44997,152 @@
43725
44997
  }
43726
44998
  }
43727
44999
 
45000
+ /** Image's fluent accessor schema. Config storage lives on `this.schema.<key>`. */ const imageSchema = [
45001
+ {
45002
+ key: "duration",
45003
+ coerce: "identity",
45004
+ default: 600
45005
+ },
45006
+ {
45007
+ key: "height",
45008
+ coerce: "accessor",
45009
+ default: accessor("height")
45010
+ },
45011
+ {
45012
+ key: "id",
45013
+ coerce: "identity",
45014
+ default: accessor("id")
45015
+ },
45016
+ {
45017
+ key: "opacity",
45018
+ coerce: "const",
45019
+ default: constant$b(1)
45020
+ },
45021
+ {
45022
+ key: "pointerEvents",
45023
+ coerce: "const",
45024
+ default: constant$b("auto")
45025
+ },
45026
+ {
45027
+ key: "renderMode",
45028
+ coerce: "identity",
45029
+ default: "full"
45030
+ },
45031
+ {
45032
+ key: "url",
45033
+ coerce: "identity",
45034
+ default: accessor("url")
45035
+ },
45036
+ {
45037
+ key: "width",
45038
+ coerce: "accessor",
45039
+ default: accessor("width")
45040
+ },
45041
+ {
45042
+ key: "x",
45043
+ coerce: "const",
45044
+ default: accessor("x", 0)
45045
+ },
45046
+ {
45047
+ key: "y",
45048
+ coerce: "const",
45049
+ default: accessor("y", 0)
45050
+ }
45051
+ ];
45052
+ let Image$1 = class Image {
45053
+ config(_) {
45054
+ if (!arguments.length) return {
45055
+ ...this.schema,
45056
+ data: this._data,
45057
+ select: this._select
45058
+ };
45059
+ const patch = _;
45060
+ for(const k in patch){
45061
+ if (!Object.prototype.hasOwnProperty.call(patch, k)) continue;
45062
+ // `this[k]` resolves the fluent accessor via the index signature.
45063
+ if (typeof this[k] === "function") this[k](patch[k]);
45064
+ else this.schema[k] = patch[k];
45065
+ }
45066
+ return this;
45067
+ }
45068
+ /**
45069
+ Renders the current Image to the page. If a *callback* is specified, it will be called once the images are done drawing.
45070
+ @param callback Optional callback invoked after rendering completes.
45071
+ */ render(callback) {
45072
+ // Compute mode is a no-op for DOM emission — the caller will read
45073
+ // `toScene()` to get a SceneNode tree, no need to mount.
45074
+ if (this.schema.renderMode === "compute") {
45075
+ if (callback) setTimeout(callback, 0);
45076
+ return this;
45077
+ }
45078
+ if (this._select === void 0) this.select(select("body").append("svg").style("width", `${window.innerWidth}px`).style("height", `${window.innerHeight}px`).style("display", "block").node());
45079
+ const images = this._select.selectAll(".d3plus-Image").data(this._data, this.schema.id);
45080
+ const enter = images.enter().append("image").attr("class", "d3plus-Image").attr("opacity", 0).attr("width", 0).attr("height", 0).attr("x", (d, i)=>this.schema.x(d, i) + this.schema.width(d, i) / 2).attr("y", (d, i)=>this.schema.y(d, i) + this.schema.height(d, i) / 2);
45081
+ const t = transition().duration(this.schema.duration), that = this, update = enter.merge(images);
45082
+ update.attr("xlink:href", this.schema.url).style("pointer-events", this.schema.pointerEvents).transition(t).attr("opacity", this.schema.opacity).attr("width", (d, i)=>this.schema.width(d, i)).attr("height", (d, i)=>this.schema.height(d, i)).attr("x", (d, i)=>this.schema.x(d, i)).attr("y", (d, i)=>this.schema.y(d, i)).each(function(d, i) {
45083
+ const image = select(this), link = that.schema.url(d, i);
45084
+ const fullAddress = link.indexOf("http://") === 0 || link.indexOf("https://") === 0;
45085
+ if (!fullAddress || link.indexOf(window.location.hostname) === 0) {
45086
+ const img = new window.Image();
45087
+ img.src = link;
45088
+ img.crossOrigin = "Anonymous";
45089
+ img.onload = function() {
45090
+ const canvas = document.createElement("canvas");
45091
+ canvas.width = img.width;
45092
+ canvas.height = img.height;
45093
+ const context = canvas.getContext("2d");
45094
+ context.drawImage(img, 0, 0);
45095
+ image.attr("xlink:href", canvas.toDataURL("image/png"));
45096
+ };
45097
+ }
45098
+ });
45099
+ images.exit().transition(t).attr("width", (d, i)=>this.schema.width(d, i)).attr("height", (d, i)=>this.schema.height(d, i)).attr("x", (d, i)=>this.schema.x(d, i)).attr("y", (d, i)=>this.schema.y(d, i)).attr("opacity", 0).remove();
45100
+ if (callback) setTimeout(callback, this.schema.duration + 100);
45101
+ return this;
45102
+ }
45103
+ data(_) {
45104
+ return arguments.length ? (this._data = _, this) : this._data;
45105
+ }
45106
+ /**
45107
+ Compute-mode scene emission. Mirrors Shape.toScene's shape — a
45108
+ keyed GroupNode wrapping per-datum ImageNodes. Used by chart
45109
+ compositors (e.g. plotPaint) that need Image to participate in the
45110
+ scene graph rather than emit d3-selection DOM.
45111
+ */ toScene() {
45112
+ const children = (this._data || []).map((d, i)=>{
45113
+ const node = {
45114
+ type: "image",
45115
+ key: `${this.schema.id(d, i)}`,
45116
+ x: this.schema.x(d, i),
45117
+ y: this.schema.y(d, i),
45118
+ width: this.schema.width(d, i),
45119
+ height: this.schema.height(d, i),
45120
+ href: this.schema.url(d, i),
45121
+ paint: {
45122
+ opacity: this.schema.opacity(d, i)
45123
+ },
45124
+ datum: d,
45125
+ index: i
45126
+ };
45127
+ return node;
45128
+ });
45129
+ return {
45130
+ type: "group",
45131
+ key: "d3plus-Image",
45132
+ children
45133
+ };
45134
+ }
45135
+ select(_) {
45136
+ return arguments.length ? (this._select = select(_), this) : this._select;
45137
+ }
45138
+ /**
45139
+ Invoked when creating a new class instance, and sets any default parameters.
45140
+ @private
45141
+ */ constructor(){
45142
+ installFluent(this, imageSchema);
45143
+ }
45144
+ };
45145
+
43728
45146
  /** Path's own fluent accessor schema, layered on top of Shape's. */ const pathSchema = [
43729
45147
  {
43730
45148
  key: "d",
@@ -49576,7 +50994,10 @@
49576
50994
  }
49577
50995
  };
49578
50996
  const debouncedResize = debounce(applyResize, viz.schema.detectResizeDelay);
49579
- viz._resizeObserver = new ResizeObserver((entries)=>{
50997
+ // Guarded so a chart can be constructed in an environment without a DOM (e.g.
50998
+ // before `@d3plus/ssr` installs one). Auto-resize is a browser-only feature;
50999
+ // when absent, `_resizeObserver` stays undefined and its call sites skip it.
51000
+ viz._resizeObserver = typeof ResizeObserver === "undefined" ? undefined : new ResizeObserver((entries)=>{
49580
51001
  // The first real-size notification after `observe()` reports the
49581
51002
  // container's settled layout size, which on an auto-sized chart often
49582
51003
  // differs from the size the chart just measured pre-layout (the
@@ -50191,7 +51612,9 @@
50191
51612
  viz._visiblePoll = clearInterval(viz._visiblePoll);
50192
51613
  viz._resizePoll = clearTimeout(viz._resizePoll);
50193
51614
  viz._scrollPoll = clearTimeout(viz._scrollPoll);
50194
- select(viz.schema.scrollContainer).on(`scroll.${viz._uuid}`, null);
51615
+ // scrollContainer is "" when constructed without a window (headless/SSR);
51616
+ // there is nothing to unbind and select("") throws on an invalid selector.
51617
+ if (viz.schema.scrollContainer) select(viz.schema.scrollContainer).on(`scroll.${viz._uuid}`, null);
50195
51618
  }
50196
51619
  /**
50197
51620
  Installs the visibility/scroll detection that defers rendering until the
@@ -50292,9 +51715,9 @@
50292
51715
  if (viz._select.attr("opacity") === "0") viz._select.transition().duration(viz.schema.duration).attr("opacity", 1);
50293
51716
  }
50294
51717
  if (viz.schema.detectResize && (viz._autoWidth || viz._autoHeight)) {
50295
- viz._resizeObserver.observe(viz._select.node().parentNode);
51718
+ viz._resizeObserver?.observe(viz._select.node().parentNode);
50296
51719
  } else {
50297
- viz._resizeObserver.unobserve(viz._select.node().parentNode);
51720
+ viz._resizeObserver?.unobserve(viz._select.node().parentNode);
50298
51721
  }
50299
51722
  if (callback) setTimeout(()=>{
50300
51723
  callback();
@@ -50993,6 +52416,23 @@
50993
52416
  */ render(callback) {
50994
52417
  return vizRender(this, callback);
50995
52418
  }
52419
+ /**
52420
+ Serializes the most recently rendered output to an SVG string. Returns
52421
+ `""` if the chart has not been rendered yet. Both backends support this:
52422
+ the SVG backend returns its live `<svg>`, the canvas backend re-renders the
52423
+ retained scene through a throwaway SVG backend. Primarily used for
52424
+ server-side rendering (see `@d3plus/ssr`).
52425
+ */ toSVGString() {
52426
+ return this._sceneRenderer?.toSVGString?.() ?? "";
52427
+ }
52428
+ /**
52429
+ Returns the underlying canvas element of the most recent render when the
52430
+ canvas backend is active (`renderer("canvas")`), or `undefined` otherwise.
52431
+ Server-side callers cast this to their native canvas to encode a raster
52432
+ (see `@d3plus/ssr`).
52433
+ */ toCanvas() {
52434
+ return this._renderer === "canvas" ? this._sceneRenderer?.toCanvas?.() : undefined;
52435
+ }
50996
52436
  renderer(_) {
50997
52437
  if (!arguments.length) return this._renderer;
50998
52438
  this._renderer = _ === "canvas" ? "canvas" : "svg";
@@ -51056,10 +52496,14 @@
51056
52496
  if (this._sceneRenderer && typeof this._sceneRenderer.destroy === "function") this._sceneRenderer.destroy();
51057
52497
  const Ctor = kind === "canvas" ? CanvasRenderer : SvgRenderer;
51058
52498
  this._sceneRenderer = new Ctor();
52499
+ // `_scenePixelRatio`, when set (e.g. by @d3plus/ssr for hi-res PNG output),
52500
+ // fixes the canvas backing-store scale; otherwise the renderer falls back
52501
+ // to `devicePixelRatio`.
51059
52502
  this._sceneRenderer.mount({
51060
52503
  container: mountTarget,
51061
52504
  width: w,
51062
- height: h
52505
+ height: h,
52506
+ pixelRatio: this._scenePixelRatio
51063
52507
  });
51064
52508
  // Bridge renderer pointer events → viz.schema.on handlers. Without this,
51065
52509
  // tooltips never fire on the v4 scene-rendered path because
@@ -51143,6 +52587,25 @@
51143
52587
  if (tlGroup) host.appendChild(tlGroup);
51144
52588
  }
51145
52589
  }
52590
+ /**
52591
+ Resolves the `(d, i, x)` a picked scene node reports to interaction
52592
+ handlers (tooltip, click, user `on` handlers). `pick.datum` is the raw
52593
+ scene datum; for a Plot shape that's the wrapped record `{data, i}`, which
52594
+ handlers expect unwrapped to `(d.data, d.i, wrapped)`. The base does that
52595
+ unwrap; Plot overrides this to report the point nearest the cursor for
52596
+ multi-point shapes (Line/Area) so a series tooltip reflects the hovered
52597
+ x rather than the whole-series aggregate.
52598
+ @private
52599
+ */ _interactionDatum(pick, _event) {
52600
+ const rawDatum = pick.datum;
52601
+ const sourceDatum = rawDatum && rawDatum.data ? rawDatum.data : rawDatum;
52602
+ const sourceIndex = rawDatum && typeof rawDatum.i === "number" ? rawDatum.i : pick.index ?? 0;
52603
+ return {
52604
+ d: sourceDatum,
52605
+ i: sourceIndex,
52606
+ x: rawDatum
52607
+ };
52608
+ }
51146
52609
  /**
51147
52610
  Routes a renderer pointer event to the matching `viz.schema.on` handlers.
51148
52611
  Bridges the v4 scene-rendered path (SvgRenderer/CanvasRenderer), where
@@ -51214,12 +52677,12 @@
51214
52677
  const isLegendNode = nodeAny.interactionGroup === "legend" || (target && typeof target.closest === "function" ? !!target.closest('[data-key="viz-legend"]') : false);
51215
52678
  const suffix = isLegendNode ? "legend" : "shape";
51216
52679
  const handlerKey = `${event.type}.${suffix}`;
51217
- // Resolve the source datum + index. `pick.datum` is the raw scene datum
51218
- // (which Shape._sceneXxx populated). For Plot shapes that's the wrapped
51219
- // record; the handlers expect `(d.data, d.i, x, event)`.
51220
- const rawDatum = pick.datum;
51221
- const sourceDatum = rawDatum && rawDatum.data ? rawDatum.data : rawDatum;
51222
- const sourceIndex = rawDatum && typeof rawDatum.i === "number" ? rawDatum.i : pick.index ?? 0;
52680
+ // Resolve the datum + index this pick reports to handlers, ONCE, and reuse
52681
+ // it for every handler fired below so tooltip/click/user handlers agree on
52682
+ // which datum the pointer is over. The base unwraps the node's raw datum to
52683
+ // its source row; Plot overrides `_interactionDatum` to report the point
52684
+ // nearest the cursor for multi-point shapes (Line/Area).
52685
+ const { d: sourceDatum, i: sourceIndex, x: rawDatum } = this._interactionDatum(pick, event);
51223
52686
  const shapeType = typeof nodeAny.shapeType === "string" ? nodeAny.shapeType : null;
51224
52687
  this._lastScenePick = {
51225
52688
  d: sourceDatum,
@@ -51265,7 +52728,7 @@
51265
52728
  /**
51266
52729
  Tears down the visualization: disconnects the ResizeObserver and removes DOM event listeners. Call this when unmounting to avoid memory leaks.
51267
52730
  */ destroy() {
51268
- this._resizeObserver.disconnect();
52731
+ this._resizeObserver?.disconnect();
51269
52732
  this._tooltipClass.data([]).render();
51270
52733
  select("body").on(`touchstart.${this._uuid}`, null);
51271
52734
  // Clear the visibility/resize/scroll poll timers + scroll listener
@@ -51286,7 +52749,7 @@
51286
52749
  if (typeof cancelAnimationFrame === "function") cancelAnimationFrame(this._sceneRepaintRAF);
51287
52750
  this._sceneRepaintRAF = undefined;
51288
52751
  }
51289
- select(this.schema.scrollContainer).on(`scroll.${this._uuid}`, null);
52752
+ if (this.schema.scrollContainer) select(this.schema.scrollContainer).on(`scroll.${this._uuid}`, null);
51290
52753
  // Destroy the active scene renderer (clears its own pointer-rect
51291
52754
  // listeners, overlay host, canvas/svg DOM, timers).
51292
52755
  if (this._sceneRenderer && typeof this._sceneRenderer.destroy === "function") {
@@ -51506,8 +52969,10 @@
51506
52969
  data.sort((a, b)=>a[viz.schema.discrete] - b[viz.schema.discrete]);
51507
52970
  }
51508
52971
  const order = viz._stackOrder;
52972
+ // An explicit key array orders `stackKeys` directly (then d3-stack keeps
52973
+ // that order via `stackOrderNone`); every other order is a comparator that
52974
+ // reranks the series d3-stack builds, so `stackKeys` is left in input order.
51509
52975
  if (Array.isArray(order)) stackKeys.sort((a, b)=>order.indexOf(a) - order.indexOf(b));
51510
- else if (order === none) stackKeys.sort((a, b)=>`${a}`.localeCompare(`${b}`));
51511
52976
  // d3-stack's generics don't model d3plus's dynamically-keyed rows; the
51512
52977
  // order/offset/value accessors are cast (`as never`) at the boundary, and
51513
52978
  // the configured stack is invoked as a `Row[][] -> number[][][]` function.
@@ -51696,11 +53161,28 @@
51696
53161
  };
51697
53162
 
51698
53163
  /** d3-scale's scale constructors, indexed by the dynamic `scale<Type>` name. */ const scaleConstructors = scales;
53164
+ /**
53165
+ A plotted axis value that can't be turned into a pixel coordinate: a
53166
+ non-finite number (`NaN`/`±Infinity`), `null`, or the empty-array sentinel
53167
+ `merge` yields when a numeric column aggregates to no usable value. Any of
53168
+ these poisons the shape's transform or path `d` downstream — e.g.
53169
+ `translate(NaN,…)` or `…L268.75,NaN` — which the browser rejects. A bare
53170
+ `undefined` is NOT bad: it's how an unused secondary axis (x2/y2) reports
53171
+ "no value on this row".
53172
+ */ const isBadAxisValue = (v)=>v === null || typeof v === "number" && !Number.isFinite(v) || Array.isArray(v) && v.length === 0;
53173
+ /**
53174
+ A formatted row is plottable when its x/y — and any *defined* x2/y2 — are
53175
+ real coordinates. Rows failing this are dropped in `formatPlotData` before
53176
+ domains, stacking, and paint ever read `_formattedData`, so a NaN measure
53177
+ no longer widens a domain, stacks as 0, or emits a broken coordinate.
53178
+ Resolves d3plus/d3plus#776.
53179
+ */ const isPlottableRow = (d)=>!isBadAxisValue(d.x) && !isBadAxisValue(d.y) && (d.x2 === undefined || !isBadAxisValue(d.x2)) && (d.y2 === undefined || !isBadAxisValue(d.y2));
51699
53180
  /**
51700
53181
  `formatPlotData` — first stage of Plot's chart-specific pipeline. Detects
51701
53182
  time axes (sets viz._xTime / _x2Time / _yTime / _y2Time), maps the
51702
53183
  filtered data through `prepData` to produce the per-row PlotDatum shape
51703
- (x/y/x2/y2 + id + group + shape + lci/hci + discrete), and constructs
53184
+ (x/y/x2/y2 + id + group + shape + lci/hci + discrete), drops rows whose
53185
+ axis values can't be plotted (`isPlottableRow` — see #776), and constructs
51704
53186
  the `_sizeScaleD3` if `_size` is set.
51705
53187
 
51706
53188
  Pure compute. Returns `{formattedData, axisData, x2Exists, y2Exists}`
@@ -51741,8 +53223,8 @@
51741
53223
  newD.id = newD.shape === "Bar" ? `${newD.id}_${newD[viz.schema.discrete]}` : newD.id;
51742
53224
  return newD;
51743
53225
  };
51744
- const formattedData = viz._formattedData = viz._filteredData.map(prepData);
51745
- const axisData = viz._axisPersist ? viz._data.map(prepData) : formattedData;
53226
+ const formattedData = viz._formattedData = viz._filteredData.map(prepData).filter(isPlottableRow);
53227
+ const axisData = viz._axisPersist ? viz._data.map(prepData).filter(isPlottableRow) : formattedData;
51746
53228
  if (viz._size) {
51747
53229
  const rExtent = extent$1(axisData, (d)=>viz._size(d.data));
51748
53230
  viz._sizeScaleD3 = scaleConstructors[`scale${viz.schema.sizeScale.charAt(0).toUpperCase()}${viz.schema.sizeScale.slice(1)}`]().domain(rExtent).range([
@@ -53049,6 +54531,13 @@
53049
54531
  };
53050
54532
  }
53051
54533
 
54534
+ /** Marks a comparator as an already-resolved d3plus stack order. */ function tagOrder(fn) {
54535
+ fn.__d3plusStackOrder = true;
54536
+ return fn;
54537
+ }
54538
+ // @types/d3-shape types the order accessors' param as a single `Series`,
54539
+ // though d3 passes the full stack array; this cast satisfies the signature.
54540
+ const asStack = (series)=>series;
53052
54541
  /**
53053
54542
  Sums a single stack series, ignoring non-numeric segments.
53054
54543
  */ function stackSum(series) {
@@ -53058,18 +54547,80 @@
53058
54547
  return s;
53059
54548
  }
53060
54549
  /**
53061
- Stack order: ascending by series key, tie-broken by summed value.
53062
- */ function stackOrderAscending(series) {
54550
+ Stack order: series with the smallest summed value on the bottom of the
54551
+ stack (matches d3's `stackOrderAscending`).
54552
+ */ const stackOrderTotalAscending = tagOrder((series)=>ascending(asStack(series)));
54553
+ /**
54554
+ Stack order: series with the largest summed value on the bottom of the
54555
+ stack (matches d3's `stackOrderDescending`). Plot's default.
54556
+ */ const stackOrderTotalDescending = tagOrder((series)=>descending(asStack(series)));
54557
+ /**
54558
+ Stack order: ascending by series key (A→Z from the bottom), tie-broken by
54559
+ ascending summed value.
54560
+ */ const stackOrderKey = tagOrder((series)=>{
53063
54561
  const sums = series.map(stackSum);
53064
54562
  const keys = series.map((d)=>d.key.split("_")[0]);
53065
- // @types/d3-shape types the order accessors' param as a single `Series`,
53066
- // though d3 passes the full stack array; cast to satisfy the signature.
53067
- return none(series).sort((a, b)=>keys[b].localeCompare(keys[a]) || sums[a] - sums[b]);
54563
+ return none(asStack(series)).sort((a, b)=>keys[a].localeCompare(keys[b]) || sums[a] - sums[b]);
54564
+ });
54565
+ /**
54566
+ Stack order: the reverse of {@link stackOrderKey} (Z→A from the bottom).
54567
+ */ const stackOrderKeyReverse = tagOrder((series)=>stackOrderKey(series).reverse());
54568
+ /**
54569
+ Builds a stack order that ranks each series by an aggregate (sum) of a
54570
+ data field, letting users order stacks by any value in their data rather
54571
+ than only the plotted one. `value` receives each series' original datum.
54572
+ */ function stackOrderField(value, order = "descending") {
54573
+ return tagOrder((series)=>{
54574
+ const totals = series.map((s)=>{
54575
+ let total = 0;
54576
+ for(let i = 0; i < s.length; i++){
54577
+ // Each stacked point carries `.data` = the discrete group's rows;
54578
+ // pick the row for this series and read the field off its datum.
54579
+ const group = s[i].data || [];
54580
+ const row = group.find((g)=>g.id === s.key);
54581
+ if (row && row.data) {
54582
+ const v = +value(row.data);
54583
+ if (!isNaN(v)) total += v;
54584
+ }
54585
+ }
54586
+ return total;
54587
+ });
54588
+ return none(asStack(series)).sort((a, b)=>order === "ascending" ? totals[a] - totals[b] : totals[b] - totals[a]);
54589
+ });
53068
54590
  }
54591
+ /** Named stack orders accepted by `Plot.stackOrder`. */ const NAMED_ORDERS = {
54592
+ ascending: stackOrderTotalAscending,
54593
+ descending: stackOrderTotalDescending,
54594
+ key: stackOrderKey,
54595
+ keyReverse: stackOrderKeyReverse,
54596
+ none: tagOrder((series)=>none(asStack(series))),
54597
+ data: tagOrder((series)=>none(asStack(series))),
54598
+ insideOut: tagOrder((series)=>insideOut(asStack(series))),
54599
+ appearance: tagOrder((series)=>appearance(asStack(series))),
54600
+ reverse: tagOrder((series)=>reverse$1(asStack(series)))
54601
+ };
54602
+ /** The named orders accepted by `Plot.stackOrder`, for docs/validation. */ const stackOrderNames = Object.keys(NAMED_ORDERS);
53069
54603
  /**
53070
- Stack order: the reverse of {@link stackOrderAscending}.
53071
- */ function stackOrderDescending(series) {
53072
- return stackOrderAscending(series).reverse();
54604
+ Normalizes any `stackOrder` input into a value Plot's pipeline can apply:
54605
+ a tagged comparator, or an explicit array of series keys. Warns and falls
54606
+ back to the default on an unrecognized name.
54607
+ */ function resolveStackOrder(input) {
54608
+ if (typeof input === "function") {
54609
+ // Already-resolved order (constructor default / config() reset) passes
54610
+ // through; a bare user function is treated as a value accessor.
54611
+ return input.__d3plusStackOrder ? input : stackOrderField(input);
54612
+ }
54613
+ if (Array.isArray(input)) return input;
54614
+ if (input && typeof input === "object") {
54615
+ const { value, order } = input;
54616
+ return stackOrderField(typeof value === "function" ? value : accessor(value), order);
54617
+ }
54618
+ if (typeof input === "string") {
54619
+ if (input in NAMED_ORDERS) return NAMED_ORDERS[input];
54620
+ console.warn(`[d3plus] Unknown stackOrder "${input}". Expected one of: ${stackOrderNames.join(", ")}; an array of series keys; a value accessor; or a {value, order} config. Falling back to "descending".`);
54621
+ return stackOrderTotalDescending;
54622
+ }
54623
+ return stackOrderTotalDescending;
53073
54624
  }
53074
54625
  /**
53075
54626
  Diverging stack offset: positive segments stack upward from zero,
@@ -53091,6 +54642,23 @@
53091
54642
  }
53092
54643
  }
53093
54644
  }
54645
+ /** Named stack offsets accepted by `Plot.stackOffset`. */ const NAMED_OFFSETS = {
54646
+ diverging: stackOffsetDiverging,
54647
+ none: none$1,
54648
+ expand: expand,
54649
+ silhouette: silhouette,
54650
+ wiggle: wiggle
54651
+ };
54652
+ /** The named offsets accepted by `Plot.stackOffset`, for docs/validation. */ const stackOffsetNames = Object.keys(NAMED_OFFSETS);
54653
+ /**
54654
+ Normalizes a `stackOffset` input into an offset function. Warns and falls
54655
+ back to the diverging default on an unrecognized name.
54656
+ */ function resolveStackOffset(input) {
54657
+ if (typeof input === "function") return input;
54658
+ if (typeof input === "string" && input in NAMED_OFFSETS) return NAMED_OFFSETS[input];
54659
+ console.warn(`[d3plus] Unknown stackOffset "${input}". Expected one of: ${stackOffsetNames.join(", ")}; or an offset function. Falling back to "diverging".`);
54660
+ return stackOffsetDiverging;
54661
+ }
53094
54662
 
53095
54663
  /**
53096
54664
  Clone the base shape config and, for stacked Area/Bar, inject the
@@ -53202,7 +54770,9 @@
53202
54770
  areaConfig[`${key}0`] = (d)=>scaleFunction(confidence[0] ? d.lci : d[key]);
53203
54771
  areaConfig[`${key}1`] = (d)=>scaleFunction(confidence[1] ? d.hci : d[key]);
53204
54772
  const area = makeShape("Area").renderMode("compute").config(areaConfig).data(values);
53205
- const confidenceConfig = Object.assign(viz.schema.shapeConfig, viz._confidenceConfig);
54773
+ // Fresh object — must NOT mutate the shared `shapeConfig`, or the confidence
54774
+ // fill/fillOpacity leak onto every other shape and every later render.
54775
+ const confidenceConfig = Object.assign({}, viz.schema.shapeConfig, viz._confidenceConfig);
53206
54776
  area.config(assign(shapeConfigFor(viz, "Line", confidenceConfig), shapeConfigFor(viz, "Area", confidenceConfig))).render();
53207
54777
  out.push(...collectComputed(area));
53208
54778
  }
@@ -53830,6 +55400,7 @@
53830
55400
  ];
53831
55401
  }
53832
55402
 
55403
+ /* eslint no-cond-assign: 0*/ // @ts-ignore
53833
55404
  const { theme: openColor } = pkg;
53834
55405
  // E4: Plot's identity-coerce accessor schema (18 keys). installFluent's
53835
55406
  // per-key idempotence lets this co-exist with vizSchema on the parent
@@ -54010,6 +55581,53 @@
54010
55581
  for (const evt of shapeEvents)shape.on(evt, forward(evt));
54011
55582
  for (const evt of classEvents)shape.on(evt, forward(evt));
54012
55583
  }
55584
+ /**
55585
+ For a multi-point shape (Line/Area) reports the point nearest the cursor
55586
+ along the discrete axis, so every mouse event (tooltip, click, user
55587
+ handlers) reflects the hovered x rather than the whole-series aggregate.
55588
+ Non-nested shapes and legend swatches fall through to the base (aggregate)
55589
+ behavior.
55590
+ @private
55591
+ */ _interactionDatum(pick, event) {
55592
+ const node = pick.node;
55593
+ const points = node && node.interactionPoints;
55594
+ if (node && node.interactionGroup !== "legend" && Array.isArray(points) && points.length && event && Array.isArray(event.point)) {
55595
+ const nearest = this._nearestInteractionPoint(points, event.point);
55596
+ if (nearest) {
55597
+ const wrapped = nearest.datum;
55598
+ return {
55599
+ d: wrapped && wrapped.data ? wrapped.data : wrapped,
55600
+ i: typeof wrapped.i === "number" ? wrapped.i : nearest.index,
55601
+ x: wrapped
55602
+ };
55603
+ }
55604
+ }
55605
+ return super._interactionDatum(pick, event);
55606
+ }
55607
+ /**
55608
+ Picks the interaction point closest to a surface-local cursor position
55609
+ along the discrete axis. `event.point` is post-zoom surface space while the
55610
+ points are in pre-zoom content space (they live under the `viz-zoom`
55611
+ group), so the cursor is un-zoomed by `_zoomTransform` before comparing.
55612
+ @private
55613
+ */ _nearestInteractionPoint(points, point) {
55614
+ const t = this._zoomTransform;
55615
+ const scale = t && t.scale ? t.scale : 1;
55616
+ const cx = (point[0] - (t ? t.x : 0)) / scale;
55617
+ const cy = (point[1] - (t ? t.y : 0)) / scale;
55618
+ const axis = this.schema.discrete === "y" ? "y" : "x";
55619
+ const target = axis === "y" ? cy : cx;
55620
+ let best = null;
55621
+ let bestDist = Infinity;
55622
+ for (const p of points){
55623
+ const dist = Math.abs(p[axis] - target);
55624
+ if (dist < bestDist) {
55625
+ bestDist = dist;
55626
+ best = p;
55627
+ }
55628
+ }
55629
+ return best;
55630
+ }
54013
55631
  /**
54014
55632
  Extends the draw behavior of the abstract Viz class.
54015
55633
  @private
@@ -54128,18 +55746,29 @@
54128
55746
  return arguments.length ? (this._size = typeof _ === "function" || !_ ? _ : accessor(_), this) : this._size;
54129
55747
  }
54130
55748
  /**
54131
- Sets the stack offset. If *value* is not specified, returns the current stack offset function.
55749
+ Sets the vertical offset applied to stacked series. Accepts a named
55750
+ offset — `"diverging"` (default), `"none"`, `"expand"`, `"silhouette"`,
55751
+ or `"wiggle"` — or a custom offset function. Unknown names warn and fall
55752
+ back to `"diverging"`. If *value* is not specified, returns the current
55753
+ stack offset function.
54132
55754
  */ stackOffset(_) {
54133
- return arguments.length ? (this._stackOffset = typeof _ === "function" ? _ : d3Shape[`stackOffset${_.charAt(0).toUpperCase() + _.slice(1)}`], this) : this._stackOffset;
55755
+ return arguments.length ? (this._stackOffset = resolveStackOffset(_), this) : this._stackOffset;
54134
55756
  }
54135
55757
  /**
54136
- Sets the stack order. If *value* is not specified, returns the current stack order function.
55758
+ Sets the order of stacked series, from the bottom of the stack upward.
55759
+ Accepts:
55760
+ - a named order: `"descending"` (default) / `"ascending"` by summed
55761
+ value, `"key"` / `"keyReverse"` alphabetically by series key,
55762
+ `"none"` / `"data"` for input order, or d3's `"insideOut"`,
55763
+ `"appearance"`, `"reverse"`;
55764
+ - an Array of series keys for an explicit order;
55765
+ - a value accessor, or a `{value, order}` config, to rank series by an
55766
+ aggregate of any data field.
55767
+
55768
+ Unknown named strings warn and fall back to `"descending"`. If *value*
55769
+ is not specified, returns the current stack order.
54137
55770
  */ stackOrder(_) {
54138
- if (arguments.length) {
54139
- if (typeof _ === "string") this._stackOrder = _ === "ascending" ? stackOrderAscending : _ === "descending" ? stackOrderDescending : d3Shape[`stackOrder${_.charAt(0).toUpperCase() + _.slice(1)}`];
54140
- else this._stackOrder = _;
54141
- return this;
54142
- } else return this._stackOrder;
55771
+ return arguments.length ? (this._stackOrder = resolveStackOrder(_), this) : this._stackOrder;
54143
55772
  }
54144
55773
  /**
54145
55774
  Accessor function or string key for the x-axis value of each data point.
@@ -54246,9 +55875,14 @@
54246
55875
  Line: false
54247
55876
  });
54248
55877
  this._confidenceConfig = {
55878
+ // A line's colour is its stroke, so the confidence band fills with that
55879
+ // same colour (at the reduced opacity below). Prefer a per-Line stroke
55880
+ // override, else the shared stroke accessor (the Line config itself sets
55881
+ // no `stroke` — the colour comes from the top-level `shapeConfig.stroke`).
54249
55882
  fill: (d, i)=>{
54250
- const c = typeof this.schema.shapeConfig.Line.stroke === "function" ? this.schema.shapeConfig.Line.stroke(d, i) : this.schema.shapeConfig.Line.stroke;
54251
- return c;
55883
+ const { Line, stroke } = this.schema.shapeConfig;
55884
+ const s = Line && Line.stroke !== undefined ? Line.stroke : stroke;
55885
+ return typeof s === "function" ? s(d, i) : s;
54252
55886
  },
54253
55887
  fillOpacity: constant$b(0.5)
54254
55888
  };
@@ -54284,7 +55918,7 @@
54284
55918
  this.schema.sizeMin = 5;
54285
55919
  this.schema.sizeScale = "sqrt";
54286
55920
  this._stackOffset = stackOffsetDiverging;
54287
- this._stackOrder = stackOrderDescending;
55921
+ this._stackOrder = stackOrderTotalDescending;
54288
55922
  this.schema.timelineConfig = assign(this.schema.timelineConfig, {
54289
55923
  brushMin: ()=>this._xTime || this._yTime || this._x2Time || this._y2Time ? 2 : 1
54290
55924
  });
@@ -54360,7 +55994,8 @@
54360
55994
  },
54361
55995
  {
54362
55996
  key: "shape",
54363
- default: constant$b("Area")
55997
+ default: constant$b("Area"),
55998
+ coerce: "const"
54364
55999
  }
54365
56000
  ]
54366
56001
  };
@@ -54389,10 +56024,12 @@
54389
56024
  },
54390
56025
  {
54391
56026
  key: "shape",
54392
- default: constant$b("Bar")
56027
+ default: constant$b("Bar"),
56028
+ coerce: "const"
54393
56029
  },
54394
56030
  {
54395
56031
  key: "legend",
56032
+ coerce: "const",
54396
56033
  factory: (viz)=>{
54397
56034
  const base = viz.schema.legend;
54398
56035
  return (config, arr)=>{
@@ -54426,7 +56063,8 @@
54426
56063
  },
54427
56064
  {
54428
56065
  key: "shape",
54429
- default: constant$b("Box")
56066
+ default: constant$b("Box"),
56067
+ coerce: "const"
54430
56068
  },
54431
56069
  {
54432
56070
  key: "tooltipConfig",
@@ -54492,7 +56130,8 @@
54492
56130
  },
54493
56131
  {
54494
56132
  key: "shape",
54495
- default: constant$b("Line")
56133
+ default: constant$b("Line"),
56134
+ coerce: "const"
54496
56135
  }
54497
56136
  ]
54498
56137
  };
@@ -54727,6 +56366,7 @@
54727
56366
  },
54728
56367
  {
54729
56368
  key: "legend",
56369
+ coerce: "const",
54730
56370
  factory: (viz)=>{
54731
56371
  const base = viz.schema.legend;
54732
56372
  return (config, arr)=>{
@@ -67561,10 +69201,12 @@
67561
69201
  const c = viz.ctx.geomapCtx;
67562
69202
  if (!c) return [];
67563
69203
  const out = [];
67564
- // Canvas backend: ensureZoomDom keeps its imperative ocean rect transparent
67565
- // (it lives in the overlaying compute <svg>), so paint the ocean into the
67566
- // scene here — first, beneath the geography — to match the SVG backend.
67567
- if (viz._renderer === "canvas") {
69204
+ // The ocean rect and basemap tiles normally live in the imperative geomap
69205
+ // <svg> (`_container`), outside the scene graph. That's fine on-screen, but a
69206
+ // server render serializes only the scene, so under SSR (`viz._ssr`) — and on
69207
+ // the canvas backend, whose compute <svg> keeps its ocean transparent — paint
69208
+ // them into the scene here, beneath the geography, so the output is complete.
69209
+ if (viz._renderer === "canvas" || viz._ssr) {
67568
69210
  const ocean = viz.schema.ocean;
67569
69211
  if (ocean && ocean !== "transparent") {
67570
69212
  const { width, height } = chartBounds(viz);
@@ -67581,6 +69223,27 @@
67581
69223
  });
67582
69224
  }
67583
69225
  }
69226
+ // Basemap tiles, pre-fetched + inlined as data URIs by @d3plus/ssr. Placed
69227
+ // above the ocean and below the geography, at the positions `_computeTileList`
69228
+ // derives from the fitted projection (same math as the live `_renderTiles`).
69229
+ const ssrTiles = viz._ssrTiles;
69230
+ if (ssrTiles && ssrTiles.size && typeof viz._computeTileList === "function") {
69231
+ for (const t of viz._computeTileList()){
69232
+ const href = ssrTiles.get(t.key);
69233
+ if (!href) continue;
69234
+ out.push({
69235
+ type: "image",
69236
+ key: `geomap-tile-${t.key}`,
69237
+ x: t.x,
69238
+ y: t.y,
69239
+ width: t.size,
69240
+ height: t.size,
69241
+ href,
69242
+ preserveAspectRatio: "none",
69243
+ interactive: false
69244
+ });
69245
+ }
69246
+ }
67584
69247
  if (c.topoData && c.topoData.length) {
67585
69248
  const pathConfig = shapeConfigFor(viz, "Path");
67586
69249
  for(let i = 0; i < c.topoData.length; i++){
@@ -67653,6 +69316,11 @@
67653
69316
  /** Installs `_renderTiles`, the per-instance method that mutates the tile group. */ function setupGeomapRenderTiles(viz) {
67654
69317
  // `_renderTiles` is a per-instance method that mutates the tile group.
67655
69318
  viz._renderTiles = function(transform = transform$2((this._zoomEventTarget || this._container).node()), duration = 0) {
69319
+ // Under SSR the basemap is composited into the scene graph (see geomapEmit +
69320
+ // `_computeTileList`), so skip the imperative <image> tile layer entirely.
69321
+ // It wouldn't be serialized anyway, and its transform transition relies on
69322
+ // SVGGElement.transform.baseVal, which headless DOMs don't implement.
69323
+ if (this._ssr) return;
67656
69324
  let tileData = [];
67657
69325
  if (this.schema.tiles) {
67658
69326
  tileData = this._tileGen.extent(this._zoomBehavior.translateExtent()).scale(this.schema.projection.scale() * (2 * Math.PI) * transform.k).translate(transform.apply(this.schema.projection.translate()))();
@@ -67669,6 +69337,23 @@
67669
69337
  "c"
67670
69338
  ][Math.random() * 3 | 0]).replace("{z}", `${z}`).replace("{x}", `${x}`).replace("{y}", `${y}`)).attr("x", ([x])=>x * scale + tileData.translate[0] * scale - transform.x / transform.k).attr("y", ([, y])=>y * scale + tileData.translate[1] * scale - transform.y / transform.k);
67671
69339
  };
69340
+ // Static (identity-transform) tile list for server-side rendering: the tile
69341
+ // URLs + their positions in projection pixel space, so @d3plus/ssr can fetch
69342
+ // them and geomapEmit can place them as scene image nodes (both SVG string and
69343
+ // canvas output then include the basemap, with no network at view time).
69344
+ // Deterministic `{s}` = "a" so tiles are cacheable across renders.
69345
+ viz._computeTileList = function() {
69346
+ if (!this.schema.tiles) return [];
69347
+ const tileData = this._tileGen.extent(this._zoomBehavior.translateExtent()).scale(this.schema.projection.scale() * (2 * Math.PI)).translate(this.schema.projection.translate())();
69348
+ const size = tileData.scale;
69349
+ return tileData.map(([x, y, z])=>({
69350
+ key: `${x}-${y}-${z}`,
69351
+ url: this.schema.tileUrl.replace("{s}", "a").replace("{z}", `${z}`).replace("{x}", `${x}`).replace("{y}", `${y}`),
69352
+ x: x * size + tileData.translate[0] * size,
69353
+ y: y * size + tileData.translate[1] * size,
69354
+ size
69355
+ }));
69356
+ };
67672
69357
  }
67673
69358
  /** Wraps `_draw` to ensure the DOM zoom group + zoom wiring exist before drawing. */ function setupGeomapDraw(viz) {
67674
69359
  // Wrap _draw to ensure DOM zoom group + zoom wiring.
@@ -67740,7 +69425,10 @@
67740
69425
  const supDrawScene = viz._drawSceneToTarget.bind(viz);
67741
69426
  viz._drawSceneToTarget = function(durationOverride) {
67742
69427
  supDrawScene(durationOverride);
67743
- if (viz._renderer === "canvas" && viz._sceneRenderer && typeof viz._sceneRenderer.toCanvas === "function") {
69428
+ if (viz._renderer === "canvas" && // Under SSR the canvas is a headless native surface with no
69429
+ // addEventListener; there is no interaction to wire, so skip the
69430
+ // pointer/zoom rebind entirely.
69431
+ !viz._ssr && viz._sceneRenderer && typeof viz._sceneRenderer.toCanvas === "function") {
67744
69432
  const canvasNode = viz._sceneRenderer.toCanvas();
67745
69433
  if (canvasNode) {
67746
69434
  // The compute svg is absolutely positioned over the canvas; an svg root
@@ -67968,7 +69656,8 @@
67968
69656
  },
67969
69657
  {
67970
69658
  key: "shape",
67971
- default: constant$b("Circle")
69659
+ default: constant$b("Circle"),
69660
+ coerce: "const"
67972
69661
  },
67973
69662
  {
67974
69663
  key: "topojson",
@@ -68066,7 +69755,8 @@
68066
69755
  },
68067
69756
  {
68068
69757
  key: "shape",
68069
- default: constant$b("Line")
69758
+ default: constant$b("Line"),
69759
+ coerce: "const"
68070
69760
  }
68071
69761
  ]
68072
69762
  };
@@ -68330,6 +70020,7 @@
68330
70020
  },
68331
70021
  {
68332
70022
  key: "label",
70023
+ coerce: "const",
68333
70024
  factory: (viz)=>(d, i)=>`${getProp.bind(viz)("row", d, i)} / ${getProp.bind(viz)("column", d, i)}`
68334
70025
  }
68335
70026
  ]
@@ -69644,7 +71335,8 @@
69644
71335
  },
69645
71336
  {
69646
71337
  key: "shape",
69647
- default: constant$b("Circle")
71338
+ default: constant$b("Circle"),
71339
+ coerce: "const"
69648
71340
  },
69649
71341
  {
69650
71342
  key: "shapeConfig",
@@ -70772,6 +72464,7 @@
70772
72464
  },
70773
72465
  {
70774
72466
  key: "legend",
72467
+ coerce: "const",
70775
72468
  factory: (viz)=>{
70776
72469
  const base = viz.schema.legend;
70777
72470
  return (config, arr)=>{
@@ -71331,7 +73024,8 @@
71331
73024
  },
71332
73025
  {
71333
73026
  key: "shape",
71334
- default: constant$b("Path")
73027
+ default: constant$b("Path"),
73028
+ coerce: "const"
71335
73029
  },
71336
73030
  {
71337
73031
  key: "value",
@@ -71575,6 +73269,7 @@
71575
73269
  },
71576
73270
  {
71577
73271
  key: "label",
73272
+ coerce: "const",
71578
73273
  factory: (viz)=>(d, i)=>`${getProp.bind(viz)("row", d, i)} / ${getProp.bind(viz)("column", d, i)}`
71579
73274
  }
71580
73275
  ]
@@ -72293,7 +73988,8 @@
72293
73988
  },
72294
73989
  {
72295
73990
  key: "shape",
72296
- default: constant$b("Circle")
73991
+ default: constant$b("Circle"),
73992
+ coerce: "const"
72297
73993
  },
72298
73994
  {
72299
73995
  key: "shapeConfig",
@@ -73187,7 +74883,8 @@
73187
74883
  },
73188
74884
  {
73189
74885
  key: "shape",
73190
- default: constant$b("Rect")
74886
+ default: constant$b("Rect"),
74887
+ coerce: "const"
73191
74888
  },
73192
74889
  {
73193
74890
  key: "shapeConfig",
@@ -73571,7 +75268,8 @@
73571
75268
  },
73572
75269
  {
73573
75270
  key: "shape",
73574
- default: constant$b("Circle")
75271
+ default: constant$b("Circle"),
75272
+ coerce: "const"
73575
75273
  },
73576
75274
  {
73577
75275
  key: "shapeConfig",
@@ -73945,6 +75643,7 @@
73945
75643
  },
73946
75644
  {
73947
75645
  key: "legend",
75646
+ coerce: "const",
73948
75647
  factory: (viz)=>{
73949
75648
  const base = viz.schema.legend;
73950
75649
  return (config, arr)=>{