@d3plus/core 4.0.0 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/README.md +947 -921
  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/index.js +2 -1
  11. package/es/src/charts/Geomap/index.js.map +1 -1
  12. package/es/src/charts/LinePlot/index.js +2 -1
  13. package/es/src/charts/LinePlot/index.js.map +1 -1
  14. package/es/src/charts/Matrix/index.js +1 -0
  15. package/es/src/charts/Matrix/index.js.map +1 -1
  16. package/es/src/charts/Network/index.js +2 -1
  17. package/es/src/charts/Network/index.js.map +1 -1
  18. package/es/src/charts/Pack/index.js +1 -0
  19. package/es/src/charts/Pack/index.js.map +1 -1
  20. package/es/src/charts/Pie/index.js +1 -0
  21. package/es/src/charts/Pie/index.js.map +1 -1
  22. package/es/src/charts/Plot/index.js +22 -12
  23. package/es/src/charts/Plot/index.js.map +1 -1
  24. package/es/src/charts/Plot/pipelineDomains.js +3 -3
  25. package/es/src/charts/Plot/pipelineDomains.js.map +1 -1
  26. package/es/src/charts/Plot/stackHelpers.js +128 -9
  27. package/es/src/charts/Plot/stackHelpers.js.map +1 -1
  28. package/es/src/charts/Radar/index.js +2 -1
  29. package/es/src/charts/Radar/index.js.map +1 -1
  30. package/es/src/charts/RadialMatrix/index.js +1 -0
  31. package/es/src/charts/RadialMatrix/index.js.map +1 -1
  32. package/es/src/charts/Rings/index.js +2 -1
  33. package/es/src/charts/Rings/index.js.map +1 -1
  34. package/es/src/charts/Sankey/index.js +2 -1
  35. package/es/src/charts/Sankey/index.js.map +1 -1
  36. package/es/src/charts/Tree/index.js +2 -1
  37. package/es/src/charts/Tree/index.js.map +1 -1
  38. package/es/src/charts/Treemap/index.js +1 -0
  39. package/es/src/charts/Treemap/index.js.map +1 -1
  40. package/es/src/charts/events/click.legend.js +1 -1
  41. package/es/src/charts/events/click.legend.js.map +1 -1
  42. package/es/src/charts/events/mousemove.legend.js +1 -1
  43. package/es/src/charts/events/mousemove.legend.js.map +1 -1
  44. package/es/src/charts/features/features.js +3 -3
  45. package/es/src/charts/features/features.js.map +1 -1
  46. package/es/src/charts/features/featuresLegend.js +1 -1
  47. package/es/src/charts/features/featuresLegend.js.map +1 -1
  48. package/es/src/charts/viz/VizBase.js.map +1 -1
  49. package/es/src/charts/viz/VizBaseConfig.js.map +1 -1
  50. package/es/src/components/TextBox.js +21 -5
  51. package/es/src/components/TextBox.js.map +1 -1
  52. package/es/src/shapes/Circle.js +12 -4
  53. package/es/src/shapes/Circle.js.map +1 -1
  54. package/es/src/shapes/Image.js +2 -3
  55. package/es/src/shapes/Image.js.map +1 -1
  56. package/es/src/shapes/Shape.js +35 -36
  57. package/es/src/shapes/Shape.js.map +1 -1
  58. package/es/src/shapes/buildLabelData.js +59 -4
  59. package/es/src/shapes/buildLabelData.js.map +1 -1
  60. package/es/src/shapes/sceneSort.js +304 -24
  61. package/es/src/shapes/sceneSort.js.map +1 -1
  62. package/es/src/shapes/shapeConfig.js.map +1 -1
  63. package/es/src/utils/D3plusConfig.js.map +1 -1
  64. package/package.json +10 -10
  65. package/types/src/charts/Plot/index.d.ts +22 -6
  66. package/types/src/charts/Plot/stackHelpers.d.ts +62 -4
  67. package/types/src/charts/viz/VizBase.d.ts +4 -4
  68. package/types/src/charts/viz/VizBaseConfig.d.ts +4 -3
  69. package/types/src/shapes/Image.d.ts +2 -3
  70. package/types/src/shapes/Shape.d.ts +0 -2
  71. package/types/src/shapes/sceneSort.d.ts +83 -8
  72. package/types/src/shapes/shapeConfig.d.ts +7 -0
  73. package/types/src/utils/D3plusConfig.d.ts +59 -14
  74. package/umd/d3plus-core.full.js +1911 -640
  75. package/umd/d3plus-core.full.js.map +1 -1
  76. package/umd/d3plus-core.full.min.js +1192 -942
  77. package/umd/d3plus-core.js +585 -239
  78. package/umd/d3plus-core.js.map +1 -1
  79. package/umd/d3plus-core.min.js +495 -367
@@ -1,5 +1,5 @@
1
1
  /*
2
- @d3plus/core v4.0.0
2
+ @d3plus/core v4.2.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
@@ -1343,7 +1343,7 @@
1343
1343
  return Array.from(events, (event)=>pointer(event, node));
1344
1344
  }
1345
1345
 
1346
- function _type_of$3(obj) {
1346
+ function _type_of$4(obj) {
1347
1347
  "@swc/helpers - typeof";
1348
1348
  return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
1349
1349
  }
@@ -1351,7 +1351,7 @@
1351
1351
  Returns true/false whether the argument provided to the function should be loaded using an internal XHR request. Valid data can either be a string URL or an Object with "url" and "headers" keys.
1352
1352
  @param dataItem The value to be tested
1353
1353
  */ function isData(dataItem) {
1354
- return typeof dataItem === "string" || (typeof dataItem === "undefined" ? "undefined" : _type_of$3(dataItem)) === "object" && dataItem !== null && !!dataItem.url;
1354
+ return typeof dataItem === "string" || (typeof dataItem === "undefined" ? "undefined" : _type_of$4(dataItem)) === "object" && dataItem !== null && !!dataItem.url;
1355
1355
  }
1356
1356
 
1357
1357
  var EOL = {}, EOF = {}, QUOTE = 34, NEWLINE = 10, RETURN = 13;
@@ -1518,7 +1518,7 @@
1518
1518
  return left instanceof right;
1519
1519
  }
1520
1520
  }
1521
- function _type_of$2(obj) {
1521
+ function _type_of$3(obj) {
1522
1522
  "@swc/helpers - typeof";
1523
1523
  return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
1524
1524
  }
@@ -1526,7 +1526,7 @@
1526
1526
  Detects if a variable is a javascript Object.
1527
1527
  @param item The value to test.
1528
1528
  */ function isObject(item) {
1529
- return item && (typeof item === "undefined" ? "undefined" : _type_of$2(item)) === "object" && (typeof window === "undefined" || item !== window && item !== window.document && !_instanceof$c(item, Element)) && !Array.isArray(item) ? true : false;
1529
+ return item && (typeof item === "undefined" ? "undefined" : _type_of$3(item)) === "object" && (typeof window === "undefined" || item !== window && item !== window.document && !_instanceof$c(item, Element)) && !Array.isArray(item) ? true : false;
1530
1530
  }
1531
1531
 
1532
1532
  /**
@@ -9386,7 +9386,7 @@
9386
9386
  return left instanceof right;
9387
9387
  }
9388
9388
  }
9389
- function _type_of$1(obj) {
9389
+ function _type_of$2(obj) {
9390
9390
  "@swc/helpers - typeof";
9391
9391
  return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
9392
9392
  }
@@ -9482,7 +9482,7 @@
9482
9482
  toLoad.forEach(function(dataItem) {
9483
9483
  var url = dataItem;
9484
9484
  var init = {};
9485
- if ((typeof dataItem === "undefined" ? "undefined" : _type_of$1(dataItem)) === "object" && dataItem.url) {
9485
+ if ((typeof dataItem === "undefined" ? "undefined" : _type_of$2(dataItem)) === "object" && dataItem.url) {
9486
9486
  url = dataItem.url;
9487
9487
  init = dataItem;
9488
9488
  }
@@ -9651,16 +9651,16 @@
9651
9651
  return newObject;
9652
9652
  }
9653
9653
 
9654
- function _array_like_to_array$f(arr, len) {
9654
+ function _array_like_to_array$i(arr, len) {
9655
9655
  if (len == null || len > arr.length) len = arr.length;
9656
9656
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
9657
9657
  return arr2;
9658
9658
  }
9659
- function _array_with_holes$d(arr) {
9659
+ function _array_with_holes$f(arr) {
9660
9660
  if (Array.isArray(arr)) return arr;
9661
9661
  }
9662
- function _array_without_holes$6(arr) {
9663
- if (Array.isArray(arr)) return _array_like_to_array$f(arr);
9662
+ function _array_without_holes$8(arr) {
9663
+ if (Array.isArray(arr)) return _array_like_to_array$i(arr);
9664
9664
  }
9665
9665
  function _instanceof$4(left, right) {
9666
9666
  "@swc/helpers - instanceof";
@@ -9670,10 +9670,10 @@
9670
9670
  return left instanceof right;
9671
9671
  }
9672
9672
  }
9673
- function _iterable_to_array$6(iter) {
9673
+ function _iterable_to_array$8(iter) {
9674
9674
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
9675
9675
  }
9676
- function _iterable_to_array_limit$d(arr, i) {
9676
+ function _iterable_to_array_limit$f(arr, i) {
9677
9677
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
9678
9678
  if (_i == null) return;
9679
9679
  var _arr = [];
@@ -9697,25 +9697,25 @@
9697
9697
  }
9698
9698
  return _arr;
9699
9699
  }
9700
- function _non_iterable_rest$d() {
9700
+ function _non_iterable_rest$f() {
9701
9701
  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
9702
  }
9703
- function _non_iterable_spread$6() {
9703
+ function _non_iterable_spread$8() {
9704
9704
  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
9705
  }
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$f(arr, i) || _non_iterable_rest$d();
9706
+ function _sliced_to_array$f(arr, i) {
9707
+ return _array_with_holes$f(arr) || _iterable_to_array_limit$f(arr, i) || _unsupported_iterable_to_array$i(arr, i) || _non_iterable_rest$f();
9708
9708
  }
9709
- function _to_consumable_array$6(arr) {
9710
- return _array_without_holes$6(arr) || _iterable_to_array$6(arr) || _unsupported_iterable_to_array$f(arr) || _non_iterable_spread$6();
9709
+ function _to_consumable_array$8(arr) {
9710
+ return _array_without_holes$8(arr) || _iterable_to_array$8(arr) || _unsupported_iterable_to_array$i(arr) || _non_iterable_spread$8();
9711
9711
  }
9712
- function _unsupported_iterable_to_array$f(o, minLen) {
9712
+ function _unsupported_iterable_to_array$i(o, minLen) {
9713
9713
  if (!o) return;
9714
- if (typeof o === "string") return _array_like_to_array$f(o, minLen);
9714
+ if (typeof o === "string") return _array_like_to_array$i(o, minLen);
9715
9715
  var n = Object.prototype.toString.call(o).slice(8, -1);
9716
9716
  if (n === "Object" && o.constructor) n = o.constructor.name;
9717
9717
  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$f(o, minLen);
9718
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$i(o, minLen);
9719
9719
  }
9720
9720
  /**
9721
9721
  @summary Extends the base behavior of d3.nest to allow for multiple depth levels.
@@ -9734,8 +9734,8 @@
9734
9734
  @param fns An array of key accessor functions, one per nesting level.
9735
9735
  */ function nestGroups(data, fns) {
9736
9736
  if (!fns.length) return data;
9737
- return _to_consumable_array$6(group(data, fns[0])).map(function(param) {
9738
- var _param = _sliced_to_array$d(param, 2), key = _param[0], values = _param[1];
9737
+ return _to_consumable_array$8(group(data, fns[0])).map(function(param) {
9738
+ var _param = _sliced_to_array$f(param, 2), key = _param[0], values = _param[1];
9739
9739
  return {
9740
9740
  key: key,
9741
9741
  values: nestGroups(values, fns.slice(1))
@@ -20540,7 +20540,7 @@
20540
20540
  }
20541
20541
  };
20542
20542
 
20543
- function _define_property$6(obj, key, value) {
20543
+ function _define_property$8(obj, key, value) {
20544
20544
  if (key in obj) {
20545
20545
  Object.defineProperty(obj, key, {
20546
20546
  value: value,
@@ -20562,7 +20562,7 @@
20562
20562
  });
20563
20563
  if (locale.location && isoLanguage) {
20564
20564
  var _obj;
20565
- locales.push((_obj = {}, _define_property$6(_obj, "name", locale.language), _define_property$6(_obj, "location", locale.location), _define_property$6(_obj, "tag", locale.tag), _define_property$6(_obj, "lcid", locale.id), _define_property$6(_obj, "iso639-2", isoCodes[isoLanguage]["iso639-2"]), _define_property$6(_obj, "iso639-1", isoCodes[isoLanguage]["iso639-1"]), _obj));
20565
+ locales.push((_obj = {}, _define_property$8(_obj, "name", locale.language), _define_property$8(_obj, "location", locale.location), _define_property$8(_obj, "tag", locale.tag), _define_property$8(_obj, "lcid", locale.id), _define_property$8(_obj, "iso639-2", isoCodes[isoLanguage]["iso639-2"]), _define_property$8(_obj, "iso639-1", isoCodes[isoLanguage]["iso639-1"]), _obj));
20566
20566
  }
20567
20567
  });
20568
20568
  var defaultLocales = {
@@ -21116,7 +21116,7 @@
21116
21116
  };
21117
21117
  return $;
21118
21118
  }
21119
- function paths() {
21119
+ function paths$1() {
21120
21120
  var width = 1;
21121
21121
  var height = 1;
21122
21122
  var size = 20;
@@ -21219,10 +21219,10 @@
21219
21219
  /* eslint import/no-anonymous-default-export: [2, {"allowObject": true}] */ var main = {
21220
21220
  circles: circles,
21221
21221
  lines: lines$1,
21222
- paths: paths
21222
+ paths: paths$1
21223
21223
  };
21224
21224
 
21225
- function ownKeys$3(object, enumerableOnly) {
21225
+ function ownKeys$4(object, enumerableOnly) {
21226
21226
  var keys = Object.keys(object);
21227
21227
  if (Object.getOwnPropertySymbols) {
21228
21228
  var symbols = Object.getOwnPropertySymbols(object);
@@ -21239,13 +21239,13 @@
21239
21239
  for(var i = 1; i < arguments.length; i++){
21240
21240
  var source = arguments[i] != null ? arguments[i] : {};
21241
21241
  if (i % 2) {
21242
- ownKeys$3(Object(source), true).forEach(function(key) {
21242
+ ownKeys$4(Object(source), true).forEach(function(key) {
21243
21243
  _defineProperty(target, key, source[key]);
21244
21244
  });
21245
21245
  } else if (Object.getOwnPropertyDescriptors) {
21246
21246
  Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
21247
21247
  } else {
21248
- ownKeys$3(Object(source)).forEach(function(key) {
21248
+ ownKeys$4(Object(source)).forEach(function(key) {
21249
21249
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
21250
21250
  });
21251
21251
  }
@@ -21894,15 +21894,15 @@
21894
21894
  };
21895
21895
  }
21896
21896
 
21897
- function _array_like_to_array$e(arr, len) {
21897
+ function _array_like_to_array$h(arr, len) {
21898
21898
  if (len == null || len > arr.length) len = arr.length;
21899
21899
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
21900
21900
  return arr2;
21901
21901
  }
21902
- function _array_with_holes$c(arr) {
21902
+ function _array_with_holes$e(arr) {
21903
21903
  if (Array.isArray(arr)) return arr;
21904
21904
  }
21905
- function _define_property$5(obj, key, value) {
21905
+ function _define_property$7(obj, key, value) {
21906
21906
  if (key in obj) {
21907
21907
  Object.defineProperty(obj, key, {
21908
21908
  value: value,
@@ -21915,7 +21915,7 @@
21915
21915
  }
21916
21916
  return obj;
21917
21917
  }
21918
- function _iterable_to_array_limit$c(arr, i) {
21918
+ function _iterable_to_array_limit$e(arr, i) {
21919
21919
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
21920
21920
  if (_i == null) return;
21921
21921
  var _arr = [];
@@ -21939,10 +21939,10 @@
21939
21939
  }
21940
21940
  return _arr;
21941
21941
  }
21942
- function _non_iterable_rest$c() {
21942
+ function _non_iterable_rest$e() {
21943
21943
  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
21944
  }
21945
- function _object_spread$2(target) {
21945
+ function _object_spread$3(target) {
21946
21946
  for(var i = 1; i < arguments.length; i++){
21947
21947
  var source = arguments[i] != null ? arguments[i] : {};
21948
21948
  var ownKeys = Object.keys(source);
@@ -21952,12 +21952,12 @@
21952
21952
  }));
21953
21953
  }
21954
21954
  ownKeys.forEach(function(key) {
21955
- _define_property$5(target, key, source[key]);
21955
+ _define_property$7(target, key, source[key]);
21956
21956
  });
21957
21957
  }
21958
21958
  return target;
21959
21959
  }
21960
- function ownKeys$2(object, enumerableOnly) {
21960
+ function ownKeys$3(object, enumerableOnly) {
21961
21961
  var keys = Object.keys(object);
21962
21962
  if (Object.getOwnPropertySymbols) {
21963
21963
  var symbols = Object.getOwnPropertySymbols(object);
@@ -21965,27 +21965,27 @@
21965
21965
  }
21966
21966
  return keys;
21967
21967
  }
21968
- function _object_spread_props$2(target, source) {
21968
+ function _object_spread_props$3(target, source) {
21969
21969
  source = source != null ? source : {};
21970
21970
  if (Object.getOwnPropertyDescriptors) {
21971
21971
  Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
21972
21972
  } else {
21973
- ownKeys$2(Object(source)).forEach(function(key) {
21973
+ ownKeys$3(Object(source)).forEach(function(key) {
21974
21974
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
21975
21975
  });
21976
21976
  }
21977
21977
  return target;
21978
21978
  }
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$e(arr, i) || _non_iterable_rest$c();
21979
+ function _sliced_to_array$e(arr, i) {
21980
+ return _array_with_holes$e(arr) || _iterable_to_array_limit$e(arr, i) || _unsupported_iterable_to_array$h(arr, i) || _non_iterable_rest$e();
21981
21981
  }
21982
- function _unsupported_iterable_to_array$e(o, minLen) {
21982
+ function _unsupported_iterable_to_array$h(o, minLen) {
21983
21983
  if (!o) return;
21984
- if (typeof o === "string") return _array_like_to_array$e(o, minLen);
21984
+ if (typeof o === "string") return _array_like_to_array$h(o, minLen);
21985
21985
  var n = Object.prototype.toString.call(o).slice(8, -1);
21986
21986
  if (n === "Object" && o.constructor) n = o.constructor.name;
21987
21987
  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$e(o, minLen);
21988
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$h(o, minLen);
21989
21989
  }
21990
21990
  /**
21991
21991
  The default easing curve, identical to d3-transition's default (cubic in-out),
@@ -22043,7 +22043,7 @@
22043
22043
  // collapse()'s opacity:0 fades a node fully in on enter and fully out on exit.
22044
22044
  var opacity = a.opacity === undefined && b.opacity === undefined ? null : lerpNum((_a_opacity = a.opacity) !== null && _a_opacity !== void 0 ? _a_opacity : 1, (_b_opacity = b.opacity) !== null && _b_opacity !== void 0 ? _b_opacity : 1);
22045
22045
  return function(t) {
22046
- return _object_spread$2(_object_spread_props$2(_object_spread$2({}, b), {
22046
+ return _object_spread$3(_object_spread_props$3(_object_spread$3({}, b), {
22047
22047
  fill: fill(t),
22048
22048
  stroke: stroke(t)
22049
22049
  }), fillOpacity ? {
@@ -22065,7 +22065,7 @@
22065
22065
  var scale = lerpNum((_a_scale = a.scale) !== null && _a_scale !== void 0 ? _a_scale : 1, (_b_scale = b.scale) !== null && _b_scale !== void 0 ? _b_scale : 1);
22066
22066
  var rotate = lerpNum((_a_rotate = a.rotate) !== null && _a_rotate !== void 0 ? _a_rotate : 0, (_b_rotate = b.rotate) !== null && _b_rotate !== void 0 ? _b_rotate : 0);
22067
22067
  return function(t) {
22068
- return _object_spread_props$2(_object_spread$2({}, b), {
22068
+ return _object_spread_props$3(_object_spread$3({}, b), {
22069
22069
  x: x(t),
22070
22070
  y: y(t),
22071
22071
  scale: scale(t),
@@ -22087,7 +22087,7 @@
22087
22087
  var hasTransform = Boolean(from.transform || to.transform);
22088
22088
  var transform = hasTransform ? interpTransform(from.transform, to.transform) : null;
22089
22089
  var base = function base(t) {
22090
- return _object_spread$2(_object_spread_props$2(_object_spread$2({}, to), {
22090
+ return _object_spread$3(_object_spread_props$3(_object_spread$3({}, to), {
22091
22091
  paint: paint(t)
22092
22092
  }), transform ? {
22093
22093
  transform: transform(t)
@@ -22100,7 +22100,7 @@
22100
22100
  var x = lerpNum(f.x, to.x), y = lerpNum(f.y, to.y);
22101
22101
  var w = lerpNum(f.width, to.width), h = lerpNum(f.height, to.height);
22102
22102
  return function(t) {
22103
- return _object_spread_props$2(_object_spread$2({}, base(t)), {
22103
+ return _object_spread_props$3(_object_spread$3({}, base(t)), {
22104
22104
  x: x(t),
22105
22105
  y: y(t),
22106
22106
  width: w(t),
@@ -22113,7 +22113,7 @@
22113
22113
  var f1 = from;
22114
22114
  var cx = lerpNum(f1.cx, to.cx), cy = lerpNum(f1.cy, to.cy), r = lerpNum(f1.r, to.r);
22115
22115
  return function(t) {
22116
- return _object_spread_props$2(_object_spread$2({}, base(t)), {
22116
+ return _object_spread_props$3(_object_spread$3({}, base(t)), {
22117
22117
  cx: cx(t),
22118
22118
  cy: cy(t),
22119
22119
  r: r(t)
@@ -22125,7 +22125,7 @@
22125
22125
  var f2 = from;
22126
22126
  var pts = lerpPoints(f2.points, to.points);
22127
22127
  return function(t) {
22128
- return _object_spread_props$2(_object_spread$2({}, base(t)), {
22128
+ return _object_spread_props$3(_object_spread$3({}, base(t)), {
22129
22129
  points: pts(t)
22130
22130
  });
22131
22131
  };
@@ -22136,7 +22136,7 @@
22136
22136
  var top = lerpPoints(f3.topline, to.topline);
22137
22137
  var bot = lerpPoints(f3.baseline, to.baseline);
22138
22138
  return function(t) {
22139
- return _object_spread_props$2(_object_spread$2({}, base(t)), {
22139
+ return _object_spread_props$3(_object_spread$3({}, base(t)), {
22140
22140
  topline: top(t),
22141
22141
  baseline: bot(t)
22142
22142
  });
@@ -22147,7 +22147,7 @@
22147
22147
  var f4 = from;
22148
22148
  var d = interpolatePath(f4.d, to.d);
22149
22149
  return function(t) {
22150
- return _object_spread_props$2(_object_spread$2({}, base(t)), {
22150
+ return _object_spread_props$3(_object_spread$3({}, base(t)), {
22151
22151
  d: d(t)
22152
22152
  });
22153
22153
  };
@@ -22167,8 +22167,8 @@
22167
22167
  var _ref, _ref1, _ref2, _ref3, _ref4;
22168
22168
  var _to_transform, _f_transform, _n_transform, _f_transform1, _n_transform1;
22169
22169
  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];
22170
+ var _textVisualCenter = _sliced_to_array$e(textVisualCenter(n), 2), nvcx = _textVisualCenter[0], nvcy = _textVisualCenter[1];
22171
+ var _textVisualCenter1 = _sliced_to_array$e(textVisualCenter(f5), 2), ovcx = _textVisualCenter1[0], ovcy = _textVisualCenter1[1];
22172
22172
  var si = lerpNum(fromSize / toSize, 1);
22173
22173
  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
22174
  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);
@@ -22177,8 +22177,8 @@
22177
22177
  var b = base(t);
22178
22178
  var tr = (_ref = (_b_transform = b.transform) !== null && _b_transform !== void 0 ? _b_transform : to.transform) !== null && _ref !== void 0 ? _ref : {};
22179
22179
  var scale = baseScale * si(t);
22180
- return _object_spread_props$2(_object_spread$2({}, b), {
22181
- transform: _object_spread_props$2(_object_spread$2({}, tr), {
22180
+ return _object_spread_props$3(_object_spread$3({}, b), {
22181
+ transform: _object_spread_props$3(_object_spread$3({}, tr), {
22182
22182
  scale: scale,
22183
22183
  x: pxI(t) - scale * nvcx,
22184
22184
  y: pyI(t) - scale * nvcy
@@ -22200,7 +22200,7 @@
22200
22200
  the enter/exit conventions of the SVG Shape classes.
22201
22201
  @param node The node to collapse.
22202
22202
  */ function collapse(node) {
22203
- var paint = _object_spread_props$2(_object_spread$2({}, node.paint), {
22203
+ var paint = _object_spread_props$3(_object_spread$3({}, node.paint), {
22204
22204
  opacity: 0
22205
22205
  });
22206
22206
  switch(node.type){
@@ -22212,18 +22212,18 @@
22212
22212
  // Collapse only the measure dimension and keep the bar's full breadth.
22213
22213
  // Plain rects (Treemap cells, etc.) collapse toward their center.
22214
22214
  if (node.shapeType === "Bar") {
22215
- if (node.y === 0 || node.y + node.height === 0) return _object_spread_props$2(_object_spread$2({}, node), {
22215
+ if (node.y === 0 || node.y + node.height === 0) return _object_spread_props$3(_object_spread$3({}, node), {
22216
22216
  paint: paint,
22217
22217
  y: 0,
22218
22218
  height: 0
22219
22219
  });
22220
- if (node.x === 0 || node.x + node.width === 0) return _object_spread_props$2(_object_spread$2({}, node), {
22220
+ if (node.x === 0 || node.x + node.width === 0) return _object_spread_props$3(_object_spread$3({}, node), {
22221
22221
  paint: paint,
22222
22222
  x: 0,
22223
22223
  width: 0
22224
22224
  });
22225
22225
  }
22226
- return _object_spread_props$2(_object_spread$2({}, node), {
22226
+ return _object_spread_props$3(_object_spread$3({}, node), {
22227
22227
  paint: paint,
22228
22228
  x: node.x + node.width / 2,
22229
22229
  y: node.y + node.height / 2,
@@ -22232,7 +22232,7 @@
22232
22232
  });
22233
22233
  }
22234
22234
  case "circle":
22235
- return _object_spread_props$2(_object_spread$2({}, node), {
22235
+ return _object_spread_props$3(_object_spread$3({}, node), {
22236
22236
  paint: paint,
22237
22237
  r: 0
22238
22238
  });
@@ -22240,40 +22240,40 @@
22240
22240
  // A Sankey link encodes its flow magnitude as stroke-width, so it grows
22241
22241
  // that thickness in on enter (and drains it on exit) from 0, keeping its
22242
22242
  // own opacity — rather than the default opacity fade other paths use.
22243
- if (node.shapeType === "Link") return _object_spread_props$2(_object_spread$2({}, node), {
22244
- paint: _object_spread_props$2(_object_spread$2({}, node.paint), {
22243
+ if (node.shapeType === "Link") return _object_spread_props$3(_object_spread$3({}, node), {
22244
+ paint: _object_spread_props$3(_object_spread$3({}, node.paint), {
22245
22245
  strokeWidth: 0
22246
22246
  })
22247
22247
  });
22248
- return _object_spread_props$2(_object_spread$2({}, node), {
22248
+ return _object_spread_props$3(_object_spread$3({}, node), {
22249
22249
  paint: paint
22250
22250
  });
22251
22251
  case "group":
22252
- return _object_spread_props$2(_object_spread$2({}, node), {
22252
+ return _object_spread_props$3(_object_spread$3({}, node), {
22253
22253
  paint: paint
22254
22254
  });
22255
22255
  default:
22256
- return _object_spread_props$2(_object_spread$2({}, node), {
22256
+ return _object_spread_props$3(_object_spread$3({}, node), {
22257
22257
  paint: paint
22258
22258
  });
22259
22259
  }
22260
22260
  }
22261
22261
 
22262
- function _array_like_to_array$d(arr, len) {
22262
+ function _array_like_to_array$g(arr, len) {
22263
22263
  if (len == null || len > arr.length) len = arr.length;
22264
22264
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
22265
22265
  return arr2;
22266
22266
  }
22267
- function _array_with_holes$b(arr) {
22267
+ function _array_with_holes$d(arr) {
22268
22268
  if (Array.isArray(arr)) return arr;
22269
22269
  }
22270
- function _array_without_holes$5(arr) {
22271
- if (Array.isArray(arr)) return _array_like_to_array$d(arr);
22270
+ function _array_without_holes$7(arr) {
22271
+ if (Array.isArray(arr)) return _array_like_to_array$g(arr);
22272
22272
  }
22273
- function _iterable_to_array$5(iter) {
22273
+ function _iterable_to_array$7(iter) {
22274
22274
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
22275
22275
  }
22276
- function _iterable_to_array_limit$b(arr, i) {
22276
+ function _iterable_to_array_limit$d(arr, i) {
22277
22277
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
22278
22278
  if (_i == null) return;
22279
22279
  var _arr = [];
@@ -22297,25 +22297,25 @@
22297
22297
  }
22298
22298
  return _arr;
22299
22299
  }
22300
- function _non_iterable_rest$b() {
22300
+ function _non_iterable_rest$d() {
22301
22301
  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
22302
  }
22303
- function _non_iterable_spread$5() {
22303
+ function _non_iterable_spread$7() {
22304
22304
  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
22305
  }
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$d(arr, i) || _non_iterable_rest$b();
22306
+ function _sliced_to_array$d(arr, i) {
22307
+ return _array_with_holes$d(arr) || _iterable_to_array_limit$d(arr, i) || _unsupported_iterable_to_array$g(arr, i) || _non_iterable_rest$d();
22308
22308
  }
22309
- function _to_consumable_array$5(arr) {
22310
- return _array_without_holes$5(arr) || _iterable_to_array$5(arr) || _unsupported_iterable_to_array$d(arr) || _non_iterable_spread$5();
22309
+ function _to_consumable_array$7(arr) {
22310
+ return _array_without_holes$7(arr) || _iterable_to_array$7(arr) || _unsupported_iterable_to_array$g(arr) || _non_iterable_spread$7();
22311
22311
  }
22312
- function _unsupported_iterable_to_array$d(o, minLen) {
22312
+ function _unsupported_iterable_to_array$g(o, minLen) {
22313
22313
  if (!o) return;
22314
- if (typeof o === "string") return _array_like_to_array$d(o, minLen);
22314
+ if (typeof o === "string") return _array_like_to_array$g(o, minLen);
22315
22315
  var n = Object.prototype.toString.call(o).slice(8, -1);
22316
22316
  if (n === "Object" && o.constructor) n = o.constructor.name;
22317
22317
  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$d(o, minLen);
22318
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$g(o, minLen);
22319
22319
  }
22320
22320
  /**
22321
22321
  Motion-trail geometry shared by both backends. A trail is a tapering "cone"
@@ -22360,8 +22360,8 @@
22360
22360
  }), ys = pts.map(function(p) {
22361
22361
  return p[1];
22362
22362
  });
22363
- var minX = (_Math = Math).min.apply(_Math, _to_consumable_array$5(xs)), maxX = (_Math1 = Math).max.apply(_Math1, _to_consumable_array$5(xs));
22364
- var minY = (_Math2 = Math).min.apply(_Math2, _to_consumable_array$5(ys)), maxY = (_Math3 = Math).max.apply(_Math3, _to_consumable_array$5(ys));
22363
+ var minX = (_Math = Math).min.apply(_Math, _to_consumable_array$7(xs)), maxX = (_Math1 = Math).max.apply(_Math1, _to_consumable_array$7(xs));
22364
+ var minY = (_Math2 = Math).min.apply(_Math2, _to_consumable_array$7(ys)), maxY = (_Math3 = Math).max.apply(_Math3, _to_consumable_array$7(ys));
22365
22365
  return {
22366
22366
  x: minX,
22367
22367
  y: minY,
@@ -22395,7 +22395,7 @@
22395
22395
  hh
22396
22396
  ]
22397
22397
  ].map(function(param) {
22398
- var _param = _sliced_to_array$b(param, 2), x = _param[0], y = _param[1];
22398
+ var _param = _sliced_to_array$d(param, 2), x = _param[0], y = _param[1];
22399
22399
  return [
22400
22400
  cx + x * c - y * s,
22401
22401
  cy + x * s + y * c
@@ -22491,7 +22491,7 @@
22491
22491
  ])
22492
22492
  };
22493
22493
  }
22494
- return pathBox(convexHull(_to_consumable_array$5(rectCorners(A[0], A[1], aDims[0], aDims[1], rotate)).concat(_to_consumable_array$5(rectCorners(hx, hy, hDims[0], hDims[1], rotate)))));
22494
+ return pathBox(convexHull(_to_consumable_array$7(rectCorners(A[0], A[1], aDims[0], aDims[1], rotate)).concat(_to_consumable_array$7(rectCorners(hx, hy, hDims[0], hDims[1], rotate)))));
22495
22495
  }
22496
22496
  /**
22497
22497
  The trail's fill: a gradient (objectBoundingBox units) along the travel
@@ -22583,20 +22583,20 @@
22583
22583
  };
22584
22584
  }
22585
22585
 
22586
- function _array_like_to_array$c(arr, len) {
22586
+ function _array_like_to_array$f(arr, len) {
22587
22587
  if (len == null || len > arr.length) len = arr.length;
22588
22588
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
22589
22589
  return arr2;
22590
22590
  }
22591
- function _array_without_holes$4(arr) {
22592
- if (Array.isArray(arr)) return _array_like_to_array$c(arr);
22591
+ function _array_without_holes$6(arr) {
22592
+ if (Array.isArray(arr)) return _array_like_to_array$f(arr);
22593
22593
  }
22594
- function _class_call_check$3(instance, Constructor) {
22594
+ function _class_call_check$4(instance, Constructor) {
22595
22595
  if (!(instance instanceof Constructor)) {
22596
22596
  throw new TypeError("Cannot call a class as a function");
22597
22597
  }
22598
22598
  }
22599
- function _defineProperties$3(target, props) {
22599
+ function _defineProperties$4(target, props) {
22600
22600
  for(var i = 0; i < props.length; i++){
22601
22601
  var descriptor = props[i];
22602
22602
  descriptor.enumerable = descriptor.enumerable || false;
@@ -22605,11 +22605,11 @@
22605
22605
  Object.defineProperty(target, descriptor.key, descriptor);
22606
22606
  }
22607
22607
  }
22608
- function _create_class$3(Constructor, protoProps, staticProps) {
22609
- if (protoProps) _defineProperties$3(Constructor.prototype, protoProps);
22608
+ function _create_class$4(Constructor, protoProps, staticProps) {
22609
+ if (protoProps) _defineProperties$4(Constructor.prototype, protoProps);
22610
22610
  return Constructor;
22611
22611
  }
22612
- function _define_property$4(obj, key, value) {
22612
+ function _define_property$6(obj, key, value) {
22613
22613
  if (key in obj) {
22614
22614
  Object.defineProperty(obj, key, {
22615
22615
  value: value,
@@ -22622,13 +22622,13 @@
22622
22622
  }
22623
22623
  return obj;
22624
22624
  }
22625
- function _iterable_to_array$4(iter) {
22625
+ function _iterable_to_array$6(iter) {
22626
22626
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
22627
22627
  }
22628
- function _non_iterable_spread$4() {
22628
+ function _non_iterable_spread$6() {
22629
22629
  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
22630
  }
22631
- function _object_spread$1(target) {
22631
+ function _object_spread$2(target) {
22632
22632
  for(var i = 1; i < arguments.length; i++){
22633
22633
  var source = arguments[i] != null ? arguments[i] : {};
22634
22634
  var ownKeys = Object.keys(source);
@@ -22638,12 +22638,12 @@
22638
22638
  }));
22639
22639
  }
22640
22640
  ownKeys.forEach(function(key) {
22641
- _define_property$4(target, key, source[key]);
22641
+ _define_property$6(target, key, source[key]);
22642
22642
  });
22643
22643
  }
22644
22644
  return target;
22645
22645
  }
22646
- function ownKeys$1(object, enumerableOnly) {
22646
+ function ownKeys$2(object, enumerableOnly) {
22647
22647
  var keys = Object.keys(object);
22648
22648
  if (Object.getOwnPropertySymbols) {
22649
22649
  var symbols = Object.getOwnPropertySymbols(object);
@@ -22651,34 +22651,34 @@
22651
22651
  }
22652
22652
  return keys;
22653
22653
  }
22654
- function _object_spread_props$1(target, source) {
22654
+ function _object_spread_props$2(target, source) {
22655
22655
  source = source != null ? source : {};
22656
22656
  if (Object.getOwnPropertyDescriptors) {
22657
22657
  Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
22658
22658
  } else {
22659
- ownKeys$1(Object(source)).forEach(function(key) {
22659
+ ownKeys$2(Object(source)).forEach(function(key) {
22660
22660
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
22661
22661
  });
22662
22662
  }
22663
22663
  return target;
22664
22664
  }
22665
- function _to_consumable_array$4(arr) {
22666
- return _array_without_holes$4(arr) || _iterable_to_array$4(arr) || _unsupported_iterable_to_array$c(arr) || _non_iterable_spread$4();
22665
+ function _to_consumable_array$6(arr) {
22666
+ return _array_without_holes$6(arr) || _iterable_to_array$6(arr) || _unsupported_iterable_to_array$f(arr) || _non_iterable_spread$6();
22667
22667
  }
22668
- function _unsupported_iterable_to_array$c(o, minLen) {
22668
+ function _unsupported_iterable_to_array$f(o, minLen) {
22669
22669
  if (!o) return;
22670
- if (typeof o === "string") return _array_like_to_array$c(o, minLen);
22670
+ if (typeof o === "string") return _array_like_to_array$f(o, minLen);
22671
22671
  var n = Object.prototype.toString.call(o).slice(8, -1);
22672
22672
  if (n === "Object" && o.constructor) n = o.constructor.name;
22673
22673
  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$c(o, minLen);
22674
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$f(o, minLen);
22675
22675
  }
22676
22676
  var TrailLog = /*#__PURE__*/ function() {
22677
22677
  function TrailLog() {
22678
- _class_call_check$3(this, TrailLog);
22679
- _define_property$4(this, "map", new Map());
22678
+ _class_call_check$4(this, TrailLog);
22679
+ _define_property$6(this, "map", new Map());
22680
22680
  }
22681
- _create_class$3(TrailLog, [
22681
+ _create_class$4(TrailLog, [
22682
22682
  {
22683
22683
  /**
22684
22684
  Fold a mark's current geometry into its history, keyed by the timeline value
@@ -22750,7 +22750,7 @@
22750
22750
  // instead of retracting the whole jump and detaching.
22751
22751
  var forwardInFlight = ((_e_animating1 = e.animating) === null || _e_animating1 === void 0 ? void 0 : _e_animating1.dir) === 1 ? e.animating.seg : null;
22752
22752
  e.animating = null;
22753
- var all = forwardInFlight ? _to_consumable_array$4(e.committed).concat([
22753
+ var all = forwardInFlight ? _to_consumable_array$6(e.committed).concat([
22754
22754
  forwardInFlight
22755
22755
  ]) : e.committed;
22756
22756
  e.committed = [];
@@ -22779,7 +22779,7 @@
22779
22779
  }
22780
22780
  }
22781
22781
  if (spanning) {
22782
- e.committed.push(_object_spread_props$1(_object_spread$1({}, spanning), {
22782
+ e.committed.push(_object_spread_props$2(_object_spread$2({}, spanning), {
22783
22783
  B: pos,
22784
22784
  bDims: dims,
22785
22785
  seq: seq
@@ -23051,7 +23051,7 @@
23051
23051
  var _step_value1 = _step1.value, key = _step_value1.key, x = _step_value1.x, y = _step_value1.y;
23052
23052
  var node = byKey.get(key);
23053
23053
  var base = node && trailPartsFromNode(node);
23054
- if (base) log.commit(key, _object_spread_props$1(_object_spread$1({}, base), {
23054
+ if (base) log.commit(key, _object_spread_props$2(_object_spread$2({}, base), {
23055
23055
  x: x,
23056
23056
  y: y
23057
23057
  }), node.trailPersist, sequence);
@@ -24984,7 +24984,7 @@
24984
24984
  return none(series).reverse();
24985
24985
  }
24986
24986
 
24987
- var d3Shape = /*#__PURE__*/Object.freeze({
24987
+ var paths = /*#__PURE__*/Object.freeze({
24988
24988
  __proto__: null,
24989
24989
  arc: arc,
24990
24990
  area: d3area,
@@ -25100,15 +25100,15 @@
25100
25100
  }))) !== null && _gen !== void 0 ? _gen : "";
25101
25101
  }
25102
25102
 
25103
- function _array_like_to_array$b(arr, len) {
25103
+ function _array_like_to_array$e(arr, len) {
25104
25104
  if (len == null || len > arr.length) len = arr.length;
25105
25105
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
25106
25106
  return arr2;
25107
25107
  }
25108
- function _array_with_holes$a(arr) {
25108
+ function _array_with_holes$c(arr) {
25109
25109
  if (Array.isArray(arr)) return arr;
25110
25110
  }
25111
- function _iterable_to_array_limit$a(arr, i) {
25111
+ function _iterable_to_array_limit$c(arr, i) {
25112
25112
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
25113
25113
  if (_i == null) return;
25114
25114
  var _arr = [];
@@ -25132,19 +25132,19 @@
25132
25132
  }
25133
25133
  return _arr;
25134
25134
  }
25135
- function _non_iterable_rest$a() {
25135
+ function _non_iterable_rest$c() {
25136
25136
  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
25137
  }
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$b(arr, i) || _non_iterable_rest$a();
25138
+ function _sliced_to_array$c(arr, i) {
25139
+ return _array_with_holes$c(arr) || _iterable_to_array_limit$c(arr, i) || _unsupported_iterable_to_array$e(arr, i) || _non_iterable_rest$c();
25140
25140
  }
25141
- function _unsupported_iterable_to_array$b(o, minLen) {
25141
+ function _unsupported_iterable_to_array$e(o, minLen) {
25142
25142
  if (!o) return;
25143
- if (typeof o === "string") return _array_like_to_array$b(o, minLen);
25143
+ if (typeof o === "string") return _array_like_to_array$e(o, minLen);
25144
25144
  var n = Object.prototype.toString.call(o).slice(8, -1);
25145
25145
  if (n === "Object" && o.constructor) n = o.constructor.name;
25146
25146
  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$b(o, minLen);
25147
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$e(o, minLen);
25148
25148
  }
25149
25149
  var SVG_NS$1 = "http://www.w3.org/2000/svg";
25150
25150
  var XLINK_NS = "http://www.w3.org/1999/xlink";
@@ -25204,8 +25204,8 @@
25204
25204
  var pt = prev.transform || {};
25205
25205
  var nt = node.transform || {};
25206
25206
  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];
25207
+ var _textVisualCenter = _sliced_to_array$c(textVisualCenter(node), 2), nvcx = _textVisualCenter[0], nvcy = _textVisualCenter[1];
25208
+ var _textVisualCenter1 = _sliced_to_array$c(textVisualCenter(prev), 2), ovcx = _textVisualCenter1[0], ovcy = _textVisualCenter1[1];
25209
25209
  // Visual-center positions in the parent frame (origin + visual center).
25210
25210
  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
25211
  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 +25341,8 @@
25341
25341
  setPath(target, node.d, animated);
25342
25342
  break;
25343
25343
  case "image":
25344
- target.attr("x", node.x).attr("y", node.y).attr("width", node.width).attr("height", node.height);
25344
+ var _node_preserveAspectRatio;
25345
+ 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
25346
  break;
25346
25347
  case "text":
25347
25348
  target.attr("x", node.x).attr("y", node.y);
@@ -25351,12 +25352,12 @@
25351
25352
  target.attr("transform", transformStr(node));
25352
25353
  }
25353
25354
 
25354
- function _class_call_check$2(instance, Constructor) {
25355
+ function _class_call_check$3(instance, Constructor) {
25355
25356
  if (!(instance instanceof Constructor)) {
25356
25357
  throw new TypeError("Cannot call a class as a function");
25357
25358
  }
25358
25359
  }
25359
- function _defineProperties$2(target, props) {
25360
+ function _defineProperties$3(target, props) {
25360
25361
  for(var i = 0; i < props.length; i++){
25361
25362
  var descriptor = props[i];
25362
25363
  descriptor.enumerable = descriptor.enumerable || false;
@@ -25365,11 +25366,11 @@
25365
25366
  Object.defineProperty(target, descriptor.key, descriptor);
25366
25367
  }
25367
25368
  }
25368
- function _create_class$2(Constructor, protoProps, staticProps) {
25369
- if (protoProps) _defineProperties$2(Constructor.prototype, protoProps);
25369
+ function _create_class$3(Constructor, protoProps, staticProps) {
25370
+ if (protoProps) _defineProperties$3(Constructor.prototype, protoProps);
25370
25371
  return Constructor;
25371
25372
  }
25372
- function _define_property$3(obj, key, value) {
25373
+ function _define_property$5(obj, key, value) {
25373
25374
  if (key in obj) {
25374
25375
  Object.defineProperty(obj, key, {
25375
25376
  value: value,
@@ -25492,17 +25493,17 @@
25492
25493
  renderer's (possibly not-yet-mounted) state.
25493
25494
  */ var TrailGradients = /*#__PURE__*/ function() {
25494
25495
  function TrailGradients(defs, uid) {
25495
- _class_call_check$2(this, TrailGradients);
25496
- _define_property$3(this, "defs", void 0);
25497
- _define_property$3(this, "uid", void 0);
25498
- _define_property$3(this, "map", void 0);
25499
- _define_property$3(this, "seq", void 0);
25496
+ _class_call_check$3(this, TrailGradients);
25497
+ _define_property$5(this, "defs", void 0);
25498
+ _define_property$5(this, "uid", void 0);
25499
+ _define_property$5(this, "map", void 0);
25500
+ _define_property$5(this, "seq", void 0);
25500
25501
  this.defs = defs;
25501
25502
  this.uid = uid;
25502
25503
  this.map = new Map();
25503
25504
  this.seq = 0;
25504
25505
  }
25505
- _create_class$2(TrailGradients, [
25506
+ _create_class$3(TrailGradients, [
25506
25507
  {
25507
25508
  /** Create/update this mark's gradient from a `gradient:<json>` token; returns its url. */ key: "apply",
25508
25509
  value: function apply(key, fill) {
@@ -25866,23 +25867,23 @@
25866
25867
  }
25867
25868
  }
25868
25869
 
25869
- function _array_like_to_array$a(arr, len) {
25870
+ function _array_like_to_array$d(arr, len) {
25870
25871
  if (len == null || len > arr.length) len = arr.length;
25871
25872
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
25872
25873
  return arr2;
25873
25874
  }
25874
- function _array_with_holes$9(arr) {
25875
+ function _array_with_holes$b(arr) {
25875
25876
  if (Array.isArray(arr)) return arr;
25876
25877
  }
25877
- function _array_without_holes$3(arr) {
25878
- if (Array.isArray(arr)) return _array_like_to_array$a(arr);
25878
+ function _array_without_holes$5(arr) {
25879
+ if (Array.isArray(arr)) return _array_like_to_array$d(arr);
25879
25880
  }
25880
- function _class_call_check$1(instance, Constructor) {
25881
+ function _class_call_check$2(instance, Constructor) {
25881
25882
  if (!(instance instanceof Constructor)) {
25882
25883
  throw new TypeError("Cannot call a class as a function");
25883
25884
  }
25884
25885
  }
25885
- function _defineProperties$1(target, props) {
25886
+ function _defineProperties$2(target, props) {
25886
25887
  for(var i = 0; i < props.length; i++){
25887
25888
  var descriptor = props[i];
25888
25889
  descriptor.enumerable = descriptor.enumerable || false;
@@ -25891,11 +25892,11 @@
25891
25892
  Object.defineProperty(target, descriptor.key, descriptor);
25892
25893
  }
25893
25894
  }
25894
- function _create_class$1(Constructor, protoProps, staticProps) {
25895
- if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
25895
+ function _create_class$2(Constructor, protoProps, staticProps) {
25896
+ if (protoProps) _defineProperties$2(Constructor.prototype, protoProps);
25896
25897
  return Constructor;
25897
25898
  }
25898
- function _define_property$2(obj, key, value) {
25899
+ function _define_property$4(obj, key, value) {
25899
25900
  if (key in obj) {
25900
25901
  Object.defineProperty(obj, key, {
25901
25902
  value: value,
@@ -25908,10 +25909,10 @@
25908
25909
  }
25909
25910
  return obj;
25910
25911
  }
25911
- function _iterable_to_array$3(iter) {
25912
+ function _iterable_to_array$5(iter) {
25912
25913
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
25913
25914
  }
25914
- function _iterable_to_array_limit$9(arr, i) {
25915
+ function _iterable_to_array_limit$b(arr, i) {
25915
25916
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
25916
25917
  if (_i == null) return;
25917
25918
  var _arr = [];
@@ -25935,25 +25936,25 @@
25935
25936
  }
25936
25937
  return _arr;
25937
25938
  }
25938
- function _non_iterable_rest$9() {
25939
+ function _non_iterable_rest$b() {
25939
25940
  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
25941
  }
25941
- function _non_iterable_spread$3() {
25942
+ function _non_iterable_spread$5() {
25942
25943
  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
25944
  }
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$a(arr, i) || _non_iterable_rest$9();
25945
+ function _sliced_to_array$b(arr, i) {
25946
+ return _array_with_holes$b(arr) || _iterable_to_array_limit$b(arr, i) || _unsupported_iterable_to_array$d(arr, i) || _non_iterable_rest$b();
25946
25947
  }
25947
- function _to_consumable_array$3(arr) {
25948
- return _array_without_holes$3(arr) || _iterable_to_array$3(arr) || _unsupported_iterable_to_array$a(arr) || _non_iterable_spread$3();
25948
+ function _to_consumable_array$5(arr) {
25949
+ return _array_without_holes$5(arr) || _iterable_to_array$5(arr) || _unsupported_iterable_to_array$d(arr) || _non_iterable_spread$5();
25949
25950
  }
25950
- function _unsupported_iterable_to_array$a(o, minLen) {
25951
+ function _unsupported_iterable_to_array$d(o, minLen) {
25951
25952
  if (!o) return;
25952
- if (typeof o === "string") return _array_like_to_array$a(o, minLen);
25953
+ if (typeof o === "string") return _array_like_to_array$d(o, minLen);
25953
25954
  var n = Object.prototype.toString.call(o).slice(8, -1);
25954
25955
  if (n === "Object" && o.constructor) n = o.constructor.name;
25955
25956
  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$a(o, minLen);
25957
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$d(o, minLen);
25957
25958
  }
25958
25959
  /**
25959
25960
  A Renderer backend that realizes a Scene as SVG, using a keyed enter/update/exit
@@ -25971,39 +25972,39 @@
25971
25972
  var SvgRenderer = /*#__PURE__*/ function() {
25972
25973
  function SvgRenderer() {
25973
25974
  var _this = this;
25974
- _class_call_check$1(this, SvgRenderer);
25975
- _define_property$2(this, "kind", "svg");
25976
- /** Unique per-instance prefix for this renderer's document-scoped def ids. */ _define_property$2(this, "_uid", ++rendererInstanceSeq);
25977
- _define_property$2(this, "_target", void 0);
25978
- _define_property$2(this, "_svg", void 0);
25979
- _define_property$2(this, "_root", void 0);
25980
- /** Per-mark position history for persistent motion trails. */ _define_property$2(this, "_trailLog", new TrailLog());
25981
- /** Whether persistent trails are active this draw (single-period timeline). */ _define_property$2(this, "_trailActive", false);
25982
- /** Lazy <defs> for clipPaths / patterns. Created on first use. */ _define_property$2(this, "_defs", void 0);
25983
- /** Stable id counter so each GroupNode clip gets a unique <clipPath>. */ _define_property$2(this, "_clipIds", new Map());
25984
- _define_property$2(this, "_clipSeq", 0);
25985
- /** Sibling host for HtmlOverlayNode mounts. Positioned absolutely over the svg. */ _define_property$2(this, "_overlayHost", void 0);
25986
- _define_property$2(this, "_scene", void 0);
25987
- _define_property$2(this, "_index", new Map());
25988
- _define_property$2(this, "_textureDefs", new Map());
25989
- /** Cache of `gradient:<json>` token → `url(#id)`, materialized in <defs>. */ _define_property$2(this, "_gradientDefs", new Map());
25990
- _define_property$2(this, "_gradientSeq", 0);
25991
- /** Reused per-mark userSpaceOnUse gradients for persistent trails. */ _define_property$2(this, "_trailGrads", new TrailGradients(function() {
25975
+ _class_call_check$2(this, SvgRenderer);
25976
+ _define_property$4(this, "kind", "svg");
25977
+ /** Unique per-instance prefix for this renderer's document-scoped def ids. */ _define_property$4(this, "_uid", ++rendererInstanceSeq);
25978
+ _define_property$4(this, "_target", void 0);
25979
+ _define_property$4(this, "_svg", void 0);
25980
+ _define_property$4(this, "_root", void 0);
25981
+ /** Per-mark position history for persistent motion trails. */ _define_property$4(this, "_trailLog", new TrailLog());
25982
+ /** Whether persistent trails are active this draw (single-period timeline). */ _define_property$4(this, "_trailActive", false);
25983
+ /** Lazy <defs> for clipPaths / patterns. Created on first use. */ _define_property$4(this, "_defs", void 0);
25984
+ /** Stable id counter so each GroupNode clip gets a unique <clipPath>. */ _define_property$4(this, "_clipIds", new Map());
25985
+ _define_property$4(this, "_clipSeq", 0);
25986
+ /** Sibling host for HtmlOverlayNode mounts. Positioned absolutely over the svg. */ _define_property$4(this, "_overlayHost", void 0);
25987
+ _define_property$4(this, "_scene", void 0);
25988
+ _define_property$4(this, "_index", new Map());
25989
+ _define_property$4(this, "_textureDefs", new Map());
25990
+ /** Cache of `gradient:<json>` token → `url(#id)`, materialized in <defs>. */ _define_property$4(this, "_gradientDefs", new Map());
25991
+ _define_property$4(this, "_gradientSeq", 0);
25992
+ /** Reused per-mark userSpaceOnUse gradients for persistent trails. */ _define_property$4(this, "_trailGrads", new TrailGradients(function() {
25992
25993
  return _this._ensureDefs();
25993
25994
  }, function() {
25994
25995
  return _this._uid;
25995
25996
  }));
25996
- _define_property$2(this, "_handlers", new Set());
25997
- _define_property$2(this, "_domListeners", {});
25998
- _define_property$2(this, "_listening", false);
25999
- _define_property$2(this, "_hoverKey", null);
26000
- _define_property$2(this, "_timers", new Set());
26001
- _define_property$2(this, "_invalidatePointerRect", null);
26002
- _define_property$2(this, "_removePointerRectListeners", null);
26003
- /** Cancel handle for the latest drawScene transition; flipped on overlap. */ _define_property$2(this, "_cancelDraw", null);
26004
- /** Marks `_index` as needing a rebuild before the next external read. */ _define_property$2(this, "_indexDirty", true);
26005
- }
26006
- _create_class$1(SvgRenderer, [
25997
+ _define_property$4(this, "_handlers", new Set());
25998
+ _define_property$4(this, "_domListeners", {});
25999
+ _define_property$4(this, "_listening", false);
26000
+ _define_property$4(this, "_hoverKey", null);
26001
+ _define_property$4(this, "_timers", new Set());
26002
+ _define_property$4(this, "_invalidatePointerRect", null);
26003
+ _define_property$4(this, "_removePointerRectListeners", null);
26004
+ /** Cancel handle for the latest drawScene transition; flipped on overlap. */ _define_property$4(this, "_cancelDraw", null);
26005
+ /** Marks `_index` as needing a rebuild before the next external read. */ _define_property$4(this, "_indexDirty", true);
26006
+ }
26007
+ _create_class$2(SvgRenderer, [
26007
26008
  {
26008
26009
  key: "mount",
26009
26010
  value: function mount(target) {
@@ -26194,7 +26195,7 @@
26194
26195
  if (k in t) {
26195
26196
  var _t;
26196
26197
  var v = config[k];
26197
- if (Array.isArray(v)) (_t = t)[k].apply(_t, _to_consumable_array$3(v));
26198
+ if (Array.isArray(v)) (_t = t)[k].apply(_t, _to_consumable_array$5(v));
26198
26199
  else t[k](v);
26199
26200
  }
26200
26201
  }
@@ -26232,7 +26233,7 @@
26232
26233
  break;
26233
26234
  }
26234
26235
  }
26235
- var ordered = needsSort ? _to_consumable_array$3(svgChildren).sort(function(a, b) {
26236
+ var ordered = needsSort ? _to_consumable_array$5(svgChildren).sort(function(a, b) {
26236
26237
  var _a_z, _b_z;
26237
26238
  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
26239
  }) : svgChildren;
@@ -26570,7 +26571,7 @@
26570
26571
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
26571
26572
  try {
26572
26573
  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];
26574
+ var _step_value = _sliced_to_array$b(_step.value, 2), k = _step_value[0], fn = _step_value[1];
26574
26575
  svg.addEventListener(k, fn);
26575
26576
  }
26576
26577
  } catch (err) {
@@ -26648,7 +26649,7 @@
26648
26649
  var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
26649
26650
  try {
26650
26651
  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];
26652
+ var _step_value = _sliced_to_array$b(_step1.value, 2), k = _step_value[0], fn = _step_value[1];
26652
26653
  this._svg.removeEventListener(k, fn);
26653
26654
  }
26654
26655
  } catch (err) {
@@ -26697,15 +26698,15 @@
26697
26698
  return SvgRenderer;
26698
26699
  }();
26699
26700
 
26700
- function _array_like_to_array$9(arr, len) {
26701
+ function _array_like_to_array$c(arr, len) {
26701
26702
  if (len == null || len > arr.length) len = arr.length;
26702
26703
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
26703
26704
  return arr2;
26704
26705
  }
26705
- function _array_with_holes$8(arr) {
26706
+ function _array_with_holes$a(arr) {
26706
26707
  if (Array.isArray(arr)) return arr;
26707
26708
  }
26708
- function _define_property$1(obj, key, value) {
26709
+ function _define_property$3(obj, key, value) {
26709
26710
  if (key in obj) {
26710
26711
  Object.defineProperty(obj, key, {
26711
26712
  value: value,
@@ -26718,7 +26719,7 @@
26718
26719
  }
26719
26720
  return obj;
26720
26721
  }
26721
- function _iterable_to_array_limit$8(arr, i) {
26722
+ function _iterable_to_array_limit$a(arr, i) {
26722
26723
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
26723
26724
  if (_i == null) return;
26724
26725
  var _arr = [];
@@ -26742,10 +26743,10 @@
26742
26743
  }
26743
26744
  return _arr;
26744
26745
  }
26745
- function _non_iterable_rest$8() {
26746
+ function _non_iterable_rest$a() {
26746
26747
  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
26748
  }
26748
- function _object_spread(target) {
26749
+ function _object_spread$1(target) {
26749
26750
  for(var i = 1; i < arguments.length; i++){
26750
26751
  var source = arguments[i] != null ? arguments[i] : {};
26751
26752
  var ownKeys = Object.keys(source);
@@ -26755,12 +26756,12 @@
26755
26756
  }));
26756
26757
  }
26757
26758
  ownKeys.forEach(function(key) {
26758
- _define_property$1(target, key, source[key]);
26759
+ _define_property$3(target, key, source[key]);
26759
26760
  });
26760
26761
  }
26761
26762
  return target;
26762
26763
  }
26763
- function ownKeys(object, enumerableOnly) {
26764
+ function ownKeys$1(object, enumerableOnly) {
26764
26765
  var keys = Object.keys(object);
26765
26766
  if (Object.getOwnPropertySymbols) {
26766
26767
  var symbols = Object.getOwnPropertySymbols(object);
@@ -26768,27 +26769,27 @@
26768
26769
  }
26769
26770
  return keys;
26770
26771
  }
26771
- function _object_spread_props(target, source) {
26772
+ function _object_spread_props$1(target, source) {
26772
26773
  source = source != null ? source : {};
26773
26774
  if (Object.getOwnPropertyDescriptors) {
26774
26775
  Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
26775
26776
  } else {
26776
- ownKeys(Object(source)).forEach(function(key) {
26777
+ ownKeys$1(Object(source)).forEach(function(key) {
26777
26778
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
26778
26779
  });
26779
26780
  }
26780
26781
  return target;
26781
26782
  }
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$9(arr, i) || _non_iterable_rest$8();
26783
+ function _sliced_to_array$a(arr, i) {
26784
+ return _array_with_holes$a(arr) || _iterable_to_array_limit$a(arr, i) || _unsupported_iterable_to_array$c(arr, i) || _non_iterable_rest$a();
26784
26785
  }
26785
- function _unsupported_iterable_to_array$9(o, minLen) {
26786
+ function _unsupported_iterable_to_array$c(o, minLen) {
26786
26787
  if (!o) return;
26787
- if (typeof o === "string") return _array_like_to_array$9(o, minLen);
26788
+ if (typeof o === "string") return _array_like_to_array$c(o, minLen);
26788
26789
  var n = Object.prototype.toString.call(o).slice(8, -1);
26789
26790
  if (n === "Object" && o.constructor) n = o.constructor.name;
26790
26791
  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$9(o, minLen);
26792
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$c(o, minLen);
26792
26793
  }
26793
26794
  /**
26794
26795
  Reads a motion-trail spec off a moving update-pair of trailed mark nodes,
@@ -26877,7 +26878,7 @@
26877
26878
  var _diffChildren = diffChildren(prev, next), enter = _diffChildren.enter, update = _diffChildren.update, exit = _diffChildren.exit;
26878
26879
  var wrapGroup = function wrapGroup(nodeInterp, childInterp) {
26879
26880
  return function(t) {
26880
- return _object_spread_props(_object_spread({}, nodeInterp(t)), {
26881
+ return _object_spread_props$1(_object_spread$1({}, nodeInterp(t)), {
26881
26882
  children: childInterp(t)
26882
26883
  });
26883
26884
  };
@@ -26885,7 +26886,7 @@
26885
26886
  var trailSpecs = [];
26886
26887
  var persist = [];
26887
26888
  var updaters = update.map(function(param) {
26888
- var _param = _sliced_to_array$8(param, 2), a = _param[0], b = _param[1];
26889
+ var _param = _sliced_to_array$a(param, 2), a = _param[0], b = _param[1];
26889
26890
  if (a.type === "group" && b.type === "group") {
26890
26891
  return wrapGroup(interpolateNode(a, b), interpolateChildren(a.children, b.children, log));
26891
26892
  }
@@ -27037,23 +27038,23 @@
27037
27038
  */ function interpolateScene(prev, next, log) {
27038
27039
  var rootInterp = interpolateChildren(prev ? prev.root.children : [], next.root.children, log);
27039
27040
  return function(t) {
27040
- return _object_spread_props(_object_spread({}, next), {
27041
- root: _object_spread_props(_object_spread({}, next.root), {
27041
+ return _object_spread_props$1(_object_spread$1({}, next), {
27042
+ root: _object_spread_props$1(_object_spread$1({}, next.root), {
27042
27043
  children: rootInterp(t)
27043
27044
  })
27044
27045
  });
27045
27046
  };
27046
27047
  }
27047
27048
 
27048
- function _array_like_to_array$8(arr, len) {
27049
+ function _array_like_to_array$b(arr, len) {
27049
27050
  if (len == null || len > arr.length) len = arr.length;
27050
27051
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
27051
27052
  return arr2;
27052
27053
  }
27053
- function _array_with_holes$7(arr) {
27054
+ function _array_with_holes$9(arr) {
27054
27055
  if (Array.isArray(arr)) return arr;
27055
27056
  }
27056
- function _iterable_to_array_limit$7(arr, i) {
27057
+ function _iterable_to_array_limit$9(arr, i) {
27057
27058
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
27058
27059
  if (_i == null) return;
27059
27060
  var _arr = [];
@@ -27077,19 +27078,19 @@
27077
27078
  }
27078
27079
  return _arr;
27079
27080
  }
27080
- function _non_iterable_rest$7() {
27081
+ function _non_iterable_rest$9() {
27081
27082
  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
27083
  }
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$8(arr, i) || _non_iterable_rest$7();
27084
+ function _sliced_to_array$9(arr, i) {
27085
+ return _array_with_holes$9(arr) || _iterable_to_array_limit$9(arr, i) || _unsupported_iterable_to_array$b(arr, i) || _non_iterable_rest$9();
27085
27086
  }
27086
- function _unsupported_iterable_to_array$8(o, minLen) {
27087
+ function _unsupported_iterable_to_array$b(o, minLen) {
27087
27088
  if (!o) return;
27088
- if (typeof o === "string") return _array_like_to_array$8(o, minLen);
27089
+ if (typeof o === "string") return _array_like_to_array$b(o, minLen);
27089
27090
  var n = Object.prototype.toString.call(o).slice(8, -1);
27090
27091
  if (n === "Object" && o.constructor) n = o.constructor.name;
27091
27092
  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$8(o, minLen);
27093
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$b(o, minLen);
27093
27094
  }
27094
27095
  var identity$7 = [
27095
27096
  1,
@@ -27164,7 +27165,7 @@
27164
27165
  0
27165
27166
  ];
27166
27167
  if (tr.rotateAnchor) {
27167
- var _tr_rotateAnchor = _sliced_to_array$7(tr.rotateAnchor, 2), ax = _tr_rotateAnchor[0], ay = _tr_rotateAnchor[1];
27168
+ var _tr_rotateAnchor = _sliced_to_array$9(tr.rotateAnchor, 2), ax = _tr_rotateAnchor[0], ay = _tr_rotateAnchor[1];
27168
27169
  m = multiply$1(m, multiply$1([
27169
27170
  1,
27170
27171
  0,
@@ -27381,30 +27382,30 @@
27381
27382
  }
27382
27383
  }
27383
27384
 
27384
- function _array_like_to_array$7(arr, len) {
27385
+ function _array_like_to_array$a(arr, len) {
27385
27386
  if (len == null || len > arr.length) len = arr.length;
27386
27387
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
27387
27388
  return arr2;
27388
27389
  }
27389
- function _array_without_holes$2(arr) {
27390
- if (Array.isArray(arr)) return _array_like_to_array$7(arr);
27390
+ function _array_without_holes$4(arr) {
27391
+ if (Array.isArray(arr)) return _array_like_to_array$a(arr);
27391
27392
  }
27392
- function _iterable_to_array$2(iter) {
27393
+ function _iterable_to_array$4(iter) {
27393
27394
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
27394
27395
  }
27395
- function _non_iterable_spread$2() {
27396
+ function _non_iterable_spread$4() {
27396
27397
  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
27398
  }
27398
- function _to_consumable_array$2(arr) {
27399
- return _array_without_holes$2(arr) || _iterable_to_array$2(arr) || _unsupported_iterable_to_array$7(arr) || _non_iterable_spread$2();
27399
+ function _to_consumable_array$4(arr) {
27400
+ return _array_without_holes$4(arr) || _iterable_to_array$4(arr) || _unsupported_iterable_to_array$a(arr) || _non_iterable_spread$4();
27400
27401
  }
27401
- function _unsupported_iterable_to_array$7(o, minLen) {
27402
+ function _unsupported_iterable_to_array$a(o, minLen) {
27402
27403
  if (!o) return;
27403
- if (typeof o === "string") return _array_like_to_array$7(o, minLen);
27404
+ if (typeof o === "string") return _array_like_to_array$a(o, minLen);
27404
27405
  var n = Object.prototype.toString.call(o).slice(8, -1);
27405
27406
  if (n === "Object" && o.constructor) n = o.constructor.name;
27406
27407
  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$7(o, minLen);
27408
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$a(o, minLen);
27408
27409
  }
27409
27410
  var SVG_NS = "http://www.w3.org/2000/svg";
27410
27411
  /**
@@ -27442,7 +27443,7 @@
27442
27443
  if (k in t) {
27443
27444
  var _t;
27444
27445
  var v = config[k];
27445
- if (Array.isArray(v)) (_t = t)[k].apply(_t, _to_consumable_array$2(v));
27446
+ if (Array.isArray(v)) (_t = t)[k].apply(_t, _to_consumable_array$4(v));
27446
27447
  else t[k](v);
27447
27448
  }
27448
27449
  }
@@ -27469,23 +27470,23 @@
27469
27470
  };
27470
27471
  }
27471
27472
 
27472
- function _array_like_to_array$6(arr, len) {
27473
+ function _array_like_to_array$9(arr, len) {
27473
27474
  if (len == null || len > arr.length) len = arr.length;
27474
27475
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
27475
27476
  return arr2;
27476
27477
  }
27477
- function _array_with_holes$6(arr) {
27478
+ function _array_with_holes$8(arr) {
27478
27479
  if (Array.isArray(arr)) return arr;
27479
27480
  }
27480
- function _array_without_holes$1(arr) {
27481
- if (Array.isArray(arr)) return _array_like_to_array$6(arr);
27481
+ function _array_without_holes$3(arr) {
27482
+ if (Array.isArray(arr)) return _array_like_to_array$9(arr);
27482
27483
  }
27483
- function _class_call_check(instance, Constructor) {
27484
+ function _class_call_check$1(instance, Constructor) {
27484
27485
  if (!(instance instanceof Constructor)) {
27485
27486
  throw new TypeError("Cannot call a class as a function");
27486
27487
  }
27487
27488
  }
27488
- function _defineProperties(target, props) {
27489
+ function _defineProperties$1(target, props) {
27489
27490
  for(var i = 0; i < props.length; i++){
27490
27491
  var descriptor = props[i];
27491
27492
  descriptor.enumerable = descriptor.enumerable || false;
@@ -27494,11 +27495,11 @@
27494
27495
  Object.defineProperty(target, descriptor.key, descriptor);
27495
27496
  }
27496
27497
  }
27497
- function _create_class(Constructor, protoProps, staticProps) {
27498
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
27498
+ function _create_class$1(Constructor, protoProps, staticProps) {
27499
+ if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
27499
27500
  return Constructor;
27500
27501
  }
27501
- function _define_property(obj, key, value) {
27502
+ function _define_property$2(obj, key, value) {
27502
27503
  if (key in obj) {
27503
27504
  Object.defineProperty(obj, key, {
27504
27505
  value: value,
@@ -27511,10 +27512,10 @@
27511
27512
  }
27512
27513
  return obj;
27513
27514
  }
27514
- function _iterable_to_array$1(iter) {
27515
+ function _iterable_to_array$3(iter) {
27515
27516
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
27516
27517
  }
27517
- function _iterable_to_array_limit$6(arr, i) {
27518
+ function _iterable_to_array_limit$8(arr, i) {
27518
27519
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
27519
27520
  if (_i == null) return;
27520
27521
  var _arr = [];
@@ -27538,25 +27539,25 @@
27538
27539
  }
27539
27540
  return _arr;
27540
27541
  }
27541
- function _non_iterable_rest$6() {
27542
+ function _non_iterable_rest$8() {
27542
27543
  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
27544
  }
27544
- function _non_iterable_spread$1() {
27545
+ function _non_iterable_spread$3() {
27545
27546
  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
27547
  }
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$6(arr, i) || _non_iterable_rest$6();
27548
+ function _sliced_to_array$8(arr, i) {
27549
+ 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
27550
  }
27550
- function _to_consumable_array$1(arr) {
27551
- return _array_without_holes$1(arr) || _iterable_to_array$1(arr) || _unsupported_iterable_to_array$6(arr) || _non_iterable_spread$1();
27551
+ function _to_consumable_array$3(arr) {
27552
+ return _array_without_holes$3(arr) || _iterable_to_array$3(arr) || _unsupported_iterable_to_array$9(arr) || _non_iterable_spread$3();
27552
27553
  }
27553
- function _unsupported_iterable_to_array$6(o, minLen) {
27554
+ function _unsupported_iterable_to_array$9(o, minLen) {
27554
27555
  if (!o) return;
27555
- if (typeof o === "string") return _array_like_to_array$6(o, minLen);
27556
+ if (typeof o === "string") return _array_like_to_array$9(o, minLen);
27556
27557
  var n = Object.prototype.toString.call(o).slice(8, -1);
27557
27558
  if (n === "Object" && o.constructor) n = o.constructor.name;
27558
27559
  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$6(o, minLen);
27560
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$9(o, minLen);
27560
27561
  }
27561
27562
  var raf = typeof requestAnimationFrame === "function" ? function(cb) {
27562
27563
  return requestAnimationFrame(function() {
@@ -27573,47 +27574,47 @@
27573
27574
  var CanvasRenderer = /*#__PURE__*/ function() {
27574
27575
  function CanvasRenderer() {
27575
27576
  var _this = this;
27576
- _class_call_check(this, CanvasRenderer);
27577
- _define_property(this, "kind", "canvas");
27578
- _define_property(this, "_target", void 0);
27579
- _define_property(this, "_canvas", void 0);
27580
- _define_property(this, "_ctx", void 0);
27581
- /** Sibling host for HtmlOverlayNode mounts (same approach as SvgRenderer). */ _define_property(this, "_overlayHost", void 0);
27577
+ _class_call_check$1(this, CanvasRenderer);
27578
+ _define_property$2(this, "kind", "canvas");
27579
+ _define_property$2(this, "_target", void 0);
27580
+ _define_property$2(this, "_canvas", void 0);
27581
+ _define_property$2(this, "_ctx", void 0);
27582
+ /** Sibling host for HtmlOverlayNode mounts (same approach as SvgRenderer). */ _define_property$2(this, "_overlayHost", void 0);
27582
27583
  /**
27583
27584
  * Cached key→element map for HtmlOverlay reconcile. Mutated as overlays
27584
27585
  * enter/exit so the hot path (every draw, including 60Hz zoom ticks)
27585
27586
  * doesn't pay for `host.querySelectorAll(':scope > .d3plus-render-overlay')`.
27586
- */ _define_property(this, "_overlayMap", new Map());
27587
- _define_property(this, "_ratio", 1);
27588
- _define_property(this, "_width", 0);
27589
- _define_property(this, "_height", 0);
27590
- _define_property(this, "_scene", null);
27591
- /** Per-mark position history for persistent motion trails. */ _define_property(this, "_trailLog", new TrailLog());
27592
- _define_property(this, "_pickIndex", []);
27593
- _define_property(this, "_images", new Map());
27587
+ */ _define_property$2(this, "_overlayMap", new Map());
27588
+ _define_property$2(this, "_ratio", 1);
27589
+ _define_property$2(this, "_width", 0);
27590
+ _define_property$2(this, "_height", 0);
27591
+ _define_property$2(this, "_scene", null);
27592
+ /** Per-mark position history for persistent motion trails. */ _define_property$2(this, "_trailLog", new TrailLog());
27593
+ _define_property$2(this, "_pickIndex", []);
27594
+ _define_property$2(this, "_images", new Map());
27594
27595
  // Token → tiled CanvasPattern (rasterized from the texture's SVG tile), plus
27595
27596
  // the set of tokens whose rasterization is in flight. `_patternResolver` is a
27596
27597
  // pre-bound view passed into the paint path so no closure is allocated per
27597
27598
  // node per frame.
27598
- _define_property(this, "_patterns", new Map());
27599
- _define_property(this, "_patternsPending", new Set());
27600
- _define_property(this, "_patternResolver", function(token) {
27599
+ _define_property$2(this, "_patterns", new Map());
27600
+ _define_property$2(this, "_patternsPending", new Set());
27601
+ _define_property$2(this, "_patternResolver", function(token) {
27601
27602
  return _this._resolvePattern(token);
27602
27603
  });
27603
- _define_property(this, "_handlers", new Set());
27604
- _define_property(this, "_domListeners", {});
27605
- _define_property(this, "_listening", false);
27606
- _define_property(this, "_hoverKey", null);
27607
- _define_property(this, "_frame", 0);
27604
+ _define_property$2(this, "_handlers", new Set());
27605
+ _define_property$2(this, "_domListeners", {});
27606
+ _define_property$2(this, "_listening", false);
27607
+ _define_property$2(this, "_hoverKey", null);
27608
+ _define_property$2(this, "_frame", 0);
27608
27609
  /**
27609
27610
  * `_cancelAnim(soft?)` — call with `soft=true` to stop the tick loop
27610
27611
  * without snap-painting the target scene; `false`/omitted snaps + paints
27611
27612
  * (so external `handle.cancel()` matches what resize/toSVGString see).
27612
- */ _define_property(this, "_cancelAnim", null);
27613
- _define_property(this, "_invalidatePointerRect", null);
27614
- _define_property(this, "_removePointerRectListeners", null);
27613
+ */ _define_property$2(this, "_cancelAnim", null);
27614
+ _define_property$2(this, "_invalidatePointerRect", null);
27615
+ _define_property$2(this, "_removePointerRectListeners", null);
27615
27616
  }
27616
- _create_class(CanvasRenderer, [
27617
+ _create_class$1(CanvasRenderer, [
27617
27618
  {
27618
27619
  key: "mount",
27619
27620
  value: function mount(target) {
@@ -27779,7 +27780,7 @@
27779
27780
  break;
27780
27781
  }
27781
27782
  }
27782
- var ordered = needsSort ? _to_consumable_array$1(children).sort(function(a, b) {
27783
+ var ordered = needsSort ? _to_consumable_array$3(children).sort(function(a, b) {
27783
27784
  var _a_z, _b_z;
27784
27785
  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
27786
  }) : children;
@@ -27912,7 +27913,7 @@
27912
27913
  var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
27913
27914
  try {
27914
27915
  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];
27916
+ var _step_value = _sliced_to_array$8(_step1.value, 2), key1 = _step_value[0], el1 = _step_value[1];
27916
27917
  if (!seen.has(key1)) {
27917
27918
  el1.remove();
27918
27919
  existing.delete(key1);
@@ -28064,7 +28065,22 @@
28064
28065
  }
28065
28066
  if (img.complete && img.naturalWidth) {
28066
28067
  ctx.globalAlpha = alpha;
28067
- ctx.drawImage(img, node.x, node.y, node.width, node.height);
28068
+ var par = node.preserveAspectRatio;
28069
+ var iw = img.naturalWidth, ih = img.naturalHeight;
28070
+ if (par && par.includes("slice")) {
28071
+ // CSS `cover`: scale the image to fill the box, cropping the overflow
28072
+ // (centered), via drawImage's source-rect crop.
28073
+ var scale = Math.max(node.width / iw, node.height / ih);
28074
+ var sw = node.width / scale, sh = node.height / scale;
28075
+ ctx.drawImage(img, (iw - sw) / 2, (ih - sh) / 2, sw, sh, node.x, node.y, node.width, node.height);
28076
+ } else if (par && par !== "none" && par.includes("meet")) {
28077
+ // CSS `contain`: fit the whole image inside the box (centered).
28078
+ var scale1 = Math.min(node.width / iw, node.height / ih);
28079
+ var dw = iw * scale1, dh = ih * scale1;
28080
+ ctx.drawImage(img, node.x + (node.width - dw) / 2, node.y + (node.height - dh) / 2, dw, dh);
28081
+ } else {
28082
+ ctx.drawImage(img, node.x, node.y, node.width, node.height);
28083
+ }
28068
28084
  }
28069
28085
  }
28070
28086
  },
@@ -28074,7 +28090,7 @@
28074
28090
  // Topmost wins: entries are in paint order, so search from the end.
28075
28091
  for(var i = this._pickIndex.length - 1; i >= 0; i--){
28076
28092
  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, [
28093
+ var _apply = _sliced_to_array$8(apply(inverse, [
28078
28094
  point[0] * this._ratio,
28079
28095
  point[1] * this._ratio
28080
28096
  ]), 2), lx = _apply[0], ly = _apply[1];
@@ -28120,8 +28136,8 @@
28120
28136
  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
28137
  var pts = node.points;
28122
28138
  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];
28139
+ var _pts_ = _sliced_to_array$8(pts[i - 1], 2), x1 = _pts_[0], y1 = _pts_[1];
28140
+ var _pts_i = _sliced_to_array$8(pts[i], 2), x2 = _pts_i[0], y2 = _pts_i[1];
28125
28141
  var dx = x2 - x1;
28126
28142
  var dy = y2 - y1;
28127
28143
  var len2 = dx * dx + dy * dy;
@@ -28272,7 +28288,7 @@
28272
28288
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
28273
28289
  try {
28274
28290
  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];
28291
+ var _step_value = _sliced_to_array$8(_step.value, 2), k = _step_value[0], fn = _step_value[1];
28276
28292
  canvas.addEventListener(k, fn);
28277
28293
  }
28278
28294
  } catch (err) {
@@ -28347,7 +28363,7 @@
28347
28363
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
28348
28364
  try {
28349
28365
  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];
28366
+ var _step_value = _sliced_to_array$8(_step.value, 2), k = _step_value[0], fn = _step_value[1];
28351
28367
  this._canvas.removeEventListener(k, fn);
28352
28368
  }
28353
28369
  } catch (err) {
@@ -28504,7 +28520,7 @@
28504
28520
  "top",
28505
28521
  "bottom"
28506
28522
  ].includes(position);
28507
- const padding = viz.schema.legendPadding() ? viz._padding : {
28523
+ const padding = viz.schema.legendPadding(viz) ? viz._padding : {
28508
28524
  top: 0,
28509
28525
  right: 0,
28510
28526
  bottom: 0,
@@ -28674,7 +28690,7 @@
28674
28690
  panel: null,
28675
28691
  margin: {}
28676
28692
  };
28677
- const usesPadding = viz.schema[opts.paddingMethod]();
28693
+ const usesPadding = viz.schema[opts.paddingMethod](viz);
28678
28694
  const padding = usesPadding ? viz._padding : {
28679
28695
  right: 0,
28680
28696
  left: 0
@@ -28870,7 +28886,7 @@
28870
28886
  let timelinePossible = viz.schema.time && viz.schema.timeline;
28871
28887
  const ticks = timelinePossible ? unique(viz._data.map(viz.schema.time)).map((d)=>date$2(d)) : [];
28872
28888
  timelinePossible = timelinePossible && ticks.length > 1;
28873
- const padding = viz.schema.timelinePadding() ? viz._padding : {
28889
+ const padding = viz.schema.timelinePadding(viz) ? viz._padding : {
28874
28890
  right: 0,
28875
28891
  left: 0
28876
28892
  };
@@ -28953,7 +28969,7 @@
28953
28969
  "bottom"
28954
28970
  ].includes(position);
28955
28971
  const showColorScale = viz.schema.colorScale && position;
28956
- const padding = viz.schema.colorScalePadding() ? viz._padding : {
28972
+ const padding = viz.schema.colorScalePadding(viz) ? viz._padding : {
28957
28973
  top: 0,
28958
28974
  right: 0,
28959
28975
  bottom: 0,
@@ -34827,21 +34843,21 @@
34827
34843
 
34828
34844
  var hyphenatedExports = requireHyphenated();
34829
34845
 
34830
- function _array_like_to_array$5(arr, len) {
34846
+ function _array_like_to_array$8(arr, len) {
34831
34847
  if (len == null || len > arr.length) len = arr.length;
34832
34848
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
34833
34849
  return arr2;
34834
34850
  }
34835
- function _array_with_holes$5(arr) {
34851
+ function _array_with_holes$7(arr) {
34836
34852
  if (Array.isArray(arr)) return arr;
34837
34853
  }
34838
- function _array_without_holes(arr) {
34839
- if (Array.isArray(arr)) return _array_like_to_array$5(arr);
34854
+ function _array_without_holes$2(arr) {
34855
+ if (Array.isArray(arr)) return _array_like_to_array$8(arr);
34840
34856
  }
34841
- function _iterable_to_array(iter) {
34857
+ function _iterable_to_array$2(iter) {
34842
34858
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
34843
34859
  }
34844
- function _iterable_to_array_limit$5(arr, i) {
34860
+ function _iterable_to_array_limit$7(arr, i) {
34845
34861
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
34846
34862
  if (_i == null) return;
34847
34863
  var _arr = [];
@@ -34865,25 +34881,25 @@
34865
34881
  }
34866
34882
  return _arr;
34867
34883
  }
34868
- function _non_iterable_rest$5() {
34884
+ function _non_iterable_rest$7() {
34869
34885
  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
34886
  }
34871
- function _non_iterable_spread() {
34887
+ function _non_iterable_spread$2() {
34872
34888
  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
34889
  }
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$5(arr, i) || _non_iterable_rest$5();
34890
+ function _sliced_to_array$7(arr, i) {
34891
+ 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
34892
  }
34877
- function _to_consumable_array(arr) {
34878
- return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array$5(arr) || _non_iterable_spread();
34893
+ function _to_consumable_array$2(arr) {
34894
+ return _array_without_holes$2(arr) || _iterable_to_array$2(arr) || _unsupported_iterable_to_array$8(arr) || _non_iterable_spread$2();
34879
34895
  }
34880
- function _unsupported_iterable_to_array$5(o, minLen) {
34896
+ function _unsupported_iterable_to_array$8(o, minLen) {
34881
34897
  if (!o) return;
34882
- if (typeof o === "string") return _array_like_to_array$5(o, minLen);
34898
+ if (typeof o === "string") return _array_like_to_array$8(o, minLen);
34883
34899
  var n = Object.prototype.toString.call(o).slice(8, -1);
34884
34900
  if (n === "Object" && o.constructor) n = o.constructor.name;
34885
34901
  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$5(o, minLen);
34902
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$8(o, minLen);
34887
34903
  }
34888
34904
  var cjkRange = /[\u3000-\u9FFF\uF900-\uFAFF]/;
34889
34905
  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 +34920,7 @@
34904
34920
  if (!match) return [
34905
34921
  word
34906
34922
  ];
34907
- var _match = _sliced_to_array$5(match, 3), text = _match[1], trailing = _match[2];
34923
+ var _match = _sliced_to_array$7(match, 3), text = _match[1], trailing = _match[2];
34908
34924
  if (text.length < minHyphenLength) return [
34909
34925
  word
34910
34926
  ];
@@ -34950,7 +34966,7 @@
34950
34966
  var word = _step.value;
34951
34967
  var _result;
34952
34968
  var syllables = hyphenate(word);
34953
- (_result = result).push.apply(_result, _to_consumable_array(syllables));
34969
+ (_result = result).push.apply(_result, _to_consumable_array$2(syllables));
34954
34970
  }
34955
34971
  } catch (err) {
34956
34972
  _didIteratorError = true;
@@ -34969,6 +34985,27 @@
34969
34985
  return result;
34970
34986
  }
34971
34987
 
34988
+ function _array_like_to_array$7(arr, len) {
34989
+ if (len == null || len > arr.length) len = arr.length;
34990
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
34991
+ return arr2;
34992
+ }
34993
+ function _array_without_holes$1(arr) {
34994
+ if (Array.isArray(arr)) return _array_like_to_array$7(arr);
34995
+ }
34996
+ function _define_property$1(obj, key, value) {
34997
+ if (key in obj) {
34998
+ Object.defineProperty(obj, key, {
34999
+ value: value,
35000
+ enumerable: true,
35001
+ configurable: true,
35002
+ writable: true
35003
+ });
35004
+ } else {
35005
+ obj[key] = value;
35006
+ }
35007
+ return obj;
35008
+ }
34972
35009
  function _instanceof$2(left, right) {
34973
35010
  "@swc/helpers - instanceof";
34974
35011
  if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
@@ -34977,6 +35014,61 @@
34977
35014
  return left instanceof right;
34978
35015
  }
34979
35016
  }
35017
+ function _iterable_to_array$1(iter) {
35018
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
35019
+ }
35020
+ function _non_iterable_spread$1() {
35021
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
35022
+ }
35023
+ function _object_spread(target) {
35024
+ for(var i = 1; i < arguments.length; i++){
35025
+ var source = arguments[i] != null ? arguments[i] : {};
35026
+ var ownKeys = Object.keys(source);
35027
+ if (typeof Object.getOwnPropertySymbols === "function") {
35028
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
35029
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
35030
+ }));
35031
+ }
35032
+ ownKeys.forEach(function(key) {
35033
+ _define_property$1(target, key, source[key]);
35034
+ });
35035
+ }
35036
+ return target;
35037
+ }
35038
+ function ownKeys(object, enumerableOnly) {
35039
+ var keys = Object.keys(object);
35040
+ if (Object.getOwnPropertySymbols) {
35041
+ var symbols = Object.getOwnPropertySymbols(object);
35042
+ keys.push.apply(keys, symbols);
35043
+ }
35044
+ return keys;
35045
+ }
35046
+ function _object_spread_props(target, source) {
35047
+ source = source != null ? source : {};
35048
+ if (Object.getOwnPropertyDescriptors) {
35049
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
35050
+ } else {
35051
+ ownKeys(Object(source)).forEach(function(key) {
35052
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
35053
+ });
35054
+ }
35055
+ return target;
35056
+ }
35057
+ function _to_consumable_array$1(arr) {
35058
+ return _array_without_holes$1(arr) || _iterable_to_array$1(arr) || _unsupported_iterable_to_array$7(arr) || _non_iterable_spread$1();
35059
+ }
35060
+ function _type_of$1(obj) {
35061
+ "@swc/helpers - typeof";
35062
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
35063
+ }
35064
+ function _unsupported_iterable_to_array$7(o, minLen) {
35065
+ if (!o) return;
35066
+ if (typeof o === "string") return _array_like_to_array$7(o, minLen);
35067
+ var n = Object.prototype.toString.call(o).slice(8, -1);
35068
+ if (n === "Object" && o.constructor) n = o.constructor.name;
35069
+ if (n === "Map" || n === "Set") return Array.from(n);
35070
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$7(o, minLen);
35071
+ }
34980
35072
  var softHyphen = "\u00AD";
34981
35073
  /**
34982
35074
  Coerces value into a String.
@@ -34988,46 +35080,54 @@
34988
35080
  return JSON.stringify(value);
34989
35081
  }
34990
35082
  /**
34991
- Breaks a single sentence into wrapped lines using the resolved style config.
35083
+ Runs the word-flow loop once. `lineWidth(line)` receives the 1-based line
35084
+ number and returns the width allowed for that line, so callers can vary the
35085
+ available width per line — a constant for a rectangle, or the circle's chord
35086
+ at that line's height for a circle.
34992
35087
  @private
34993
- */ function wrapSentence(phrase, config) {
34994
- var fontFamily = config.fontFamily, fontSize = config.fontSize, fontWeight = config.fontWeight, height = config.height, lineHeight = config.lineHeight, maxLines = config.maxLines, overflow = config.overflow, split = config.split, width = config.width;
34995
- var sentence = stringify(phrase);
34996
- var words = split(sentence);
34997
- var style = {
34998
- "font-family": fontFamily,
34999
- "font-size": fontSize,
35000
- "font-weight": fontWeight,
35001
- "line-height": lineHeight
35002
- };
35088
+ */ function flowWords(words, sizes, config, lineWidth) {
35089
+ var height = config.height, lineHeight = config.lineHeight, maxLines = config.maxLines, overflow = config.overflow;
35003
35090
  var line = 1, textProg = "", truncated = false, widthProg = 0;
35004
- var lineData = [], // of the per-word widths the break logic actually compared against
35005
- // `width`, which can differ from re-measuring the finished line as a
35006
- // single string (e.g. a soft hyphen counts toward the break decision but
35007
- // is stripped from the rendered line, and trailing spaces measure as 0).
35008
- lineWidths = [], sizes = d3plusTextWidth(words, style);
35091
+ var lineData = [], // of the per-word widths the break logic actually compared against the
35092
+ // line's allowed width, which can differ from re-measuring the finished
35093
+ // line as a single string (e.g. a soft hyphen counts toward the break
35094
+ // decision but is stripped from the rendered line, and trailing spaces
35095
+ // measure as 0).
35096
+ lineWidths = [];
35009
35097
  for(var i = 0; i < words.length; i++){
35010
35098
  var word = words[i];
35011
- var wordWidth = sizes[words.indexOf(word)];
35099
+ // `sizes` is built parallel to `words`, so index directly — `indexOf`
35100
+ // would rescan the array for every word (O(n²)), and the circle path runs
35101
+ // this loop once per candidate line count.
35102
+ var wordWidth = sizes[i];
35103
+ var width = lineWidth(line);
35012
35104
  // newline if breaking character or not enough width
35013
35105
  if (textProg.slice(-1) === "\n" || widthProg + wordWidth > width) {
35014
35106
  if (!i && !overflow) {
35015
35107
  truncated = true;
35016
35108
  break;
35017
35109
  }
35018
- if (lineData.length >= line) {
35019
- var lineText = lineData[line - 1].trimEnd();
35020
- // Convert trailing soft hyphen to visible hyphen at line breaks
35021
- if (lineText.endsWith(softHyphen)) lineText = lineText.slice(0, -1) + "-";
35022
- lineData[line - 1] = lineText;
35023
- }
35024
- line++;
35025
- if (lineHeight * line > height || wordWidth > width && !overflow || maxLines && line > maxLines) {
35026
- truncated = true;
35027
- break;
35110
+ if (!i) {
35111
+ // The very first word is wider than its line and overflow is allowed:
35112
+ // keep it on the first line instead of breaking. There is no prior line
35113
+ // to leave, and advancing `line` past the empty `lineData` here would
35114
+ // desync the two so later lines read `lineData[line - 1]` as undefined.
35115
+ lineData[0] = word;
35116
+ } else {
35117
+ if (lineData.length >= line) {
35118
+ var lineText = lineData[line - 1].trimEnd();
35119
+ // Convert trailing soft hyphen to visible hyphen at line breaks
35120
+ if (lineText.endsWith(softHyphen)) lineText = lineText.slice(0, -1) + "-";
35121
+ lineData[line - 1] = lineText;
35122
+ }
35123
+ line++;
35124
+ if (lineHeight * line > height || wordWidth > lineWidth(line) && !overflow || maxLines && line > maxLines) {
35125
+ truncated = true;
35126
+ break;
35127
+ }
35128
+ widthProg = 0;
35129
+ lineData.push(word);
35028
35130
  }
35029
- widthProg = 0;
35030
- lineData.push(word);
35031
35131
  } else if (!i) lineData[0] = word;
35032
35132
  else {
35033
35133
  // Strip soft hyphen when syllables stay on the same line
@@ -35040,6 +35140,133 @@
35040
35140
  widthProg += wordWidth;
35041
35141
  lineWidths[line - 1] = widthProg;
35042
35142
  }
35143
+ return {
35144
+ lineData: lineData,
35145
+ lineWidths: lineWidths,
35146
+ truncated: truncated
35147
+ };
35148
+ }
35149
+ /**
35150
+ Builds a per-line width function for `total` vertically-centered lines
35151
+ inside a circle of the given radius. Each line is measured at whichever of
35152
+ its glyph-box edges sits farther from the center (glyphs span roughly the
35153
+ font size, centered in the line box), so the returned chord keeps the whole
35154
+ line within the circle. Lines through the middle get the full diameter;
35155
+ lines near the top and bottom get progressively less.
35156
+
35157
+ The block is assumed to be vertically centered on the circle — which is how
35158
+ TextBox positions circle labels (verticalAlign "middle"). Pairing
35159
+ `shape: "circle"` with a top/bottom alignment would measure lines against
35160
+ chords for a position they aren't rendered at.
35161
+ @private
35162
+ */ function circleLineWidth(radius, total, lineHeight, fontSize) {
35163
+ var blockHeight = total * lineHeight;
35164
+ return function(line) {
35165
+ // Center of this line's box, measured from the circle's center.
35166
+ var center = -blockHeight / 2 + (line - 0.5) * lineHeight;
35167
+ var edge = Math.abs(center) + fontSize / 2;
35168
+ if (edge >= radius) return 0;
35169
+ return 2 * Math.sqrt(radius * radius - edge * edge);
35170
+ };
35171
+ }
35172
+ /**
35173
+ Measures each finished line as it will actually render (soft hyphens
35174
+ stripped). The per-word widths the flow loop compares against exclude
35175
+ trailing spaces, so a line can measure wider than the running total the
35176
+ break decisions used once inter-word spaces are counted.
35177
+ @private
35178
+ */ function measureLines(lineData, style) {
35179
+ return d3plusTextWidth(lineData.map(function(l) {
35180
+ return l.replaceAll(softHyphen, "");
35181
+ }), style);
35182
+ }
35183
+ /**
35184
+ Wraps text to fit inside a circle by giving each line its own width — the
35185
+ chord of the circle at that line's vertical position. The block is kept
35186
+ vertically centered, so the number of lines feeds back into every line's
35187
+ width; this searches upward from a single line for the fewest lines whose
35188
+ real rendered widths all fit inside the circle. If no line count fits (the
35189
+ text is simply too big), it returns the attempt that spills the least and
35190
+ reports truncation, so a resizing caller shrinks the font and tries again.
35191
+ @private
35192
+ */ function flowCircle(words, sizes, config, style) {
35193
+ var _loop = function(n) {
35194
+ var _Math;
35195
+ var pass = flowWords(words, sizes, _object_spread_props(_object_spread({}, config), {
35196
+ maxLines: n
35197
+ }), circleLineWidth(radius, n, lineHeight, fontSize));
35198
+ if (pass.truncated) return "continue";
35199
+ // Validate the real rendered widths against the chords for the ACTUAL line
35200
+ // count: flowWords can settle on fewer lines than the search `n`, and the
35201
+ // block is re-centered to that count at render time, so the chords that
35202
+ // matter belong to `pass.lineData.length`, not `n`.
35203
+ var visibleWidths = measureLines(pass.lineData, style);
35204
+ var chord = circleLineWidth(radius, pass.lineData.length, lineHeight, fontSize);
35205
+ var over = (_Math = Math).max.apply(_Math, [
35206
+ 0
35207
+ ].concat(_to_consumable_array$1(visibleWidths.map(function(w, i) {
35208
+ return w - chord(i + 1);
35209
+ }))));
35210
+ // `overflow` opts out of containment — let the text spill, as the flag asks.
35211
+ if (overflow || over <= 0) return {
35212
+ v: _object_spread_props(_object_spread({}, pass), {
35213
+ visibleWidths: visibleWidths
35214
+ })
35215
+ };
35216
+ if (over < bestOverflow) {
35217
+ bestOverflow = over;
35218
+ best = _object_spread_props(_object_spread({}, pass), {
35219
+ visibleWidths: visibleWidths
35220
+ });
35221
+ }
35222
+ };
35223
+ var fontSize = config.fontSize, height = config.height, lineHeight = config.lineHeight, maxLines = config.maxLines, overflow = config.overflow, width = config.width;
35224
+ var radius = Math.min(width, height) / 2;
35225
+ // The most lines that can stack vertically within the circle. Bounded by the
35226
+ // token count too — a line holds at least one word, so more passes than there
35227
+ // are words can never fit more text — which also keeps the search finite when
35228
+ // lineHeight is 0 (`verticalMax` would otherwise be Infinity and never end).
35229
+ var verticalMax = Math.max(1, Math.floor(2 * radius / lineHeight));
35230
+ var cap = maxLines ? Math.min(verticalMax, maxLines) : verticalMax;
35231
+ cap = Math.min(cap, words.length);
35232
+ var best = null;
35233
+ var bestOverflow = Infinity;
35234
+ for(var n = 1; n <= cap; n++){
35235
+ var _ret = _loop(n);
35236
+ if (_type_of$1(_ret) === "object") return _ret.v;
35237
+ }
35238
+ if (best) return _object_spread_props(_object_spread({}, best), {
35239
+ truncated: true
35240
+ });
35241
+ // No line count produced even an untruncated layout. Fall back to a plain
35242
+ // full-width flow, and flag truncation so a resizing TextBox drops the font
35243
+ // size and re-wraps into something that fits — returning a non-truncated
35244
+ // result would claim the text fit and leave it overflowing the circle. Empty
35245
+ // input (no words) is genuinely not truncated, so leave that flag alone.
35246
+ var fallback = flowWords(words, sizes, config, function() {
35247
+ return 2 * radius;
35248
+ });
35249
+ return words.length ? _object_spread_props(_object_spread({}, fallback), {
35250
+ truncated: true
35251
+ }) : fallback;
35252
+ }
35253
+ /**
35254
+ Breaks a single sentence into wrapped lines using the resolved style config.
35255
+ @private
35256
+ */ function wrapSentence(phrase, config) {
35257
+ var fontFamily = config.fontFamily, fontSize = config.fontSize, fontWeight = config.fontWeight, shape = config.shape, split = config.split, width = config.width;
35258
+ var sentence = stringify(phrase);
35259
+ var words = split(sentence);
35260
+ var style = {
35261
+ "font-family": fontFamily,
35262
+ "font-size": fontSize,
35263
+ "font-weight": fontWeight,
35264
+ "line-height": config.lineHeight
35265
+ };
35266
+ var sizes = d3plusTextWidth(words, style);
35267
+ var _ref = shape === "circle" ? flowCircle(words, sizes, config, style) : flowWords(words, sizes, config, function() {
35268
+ return width;
35269
+ }), lineData = _ref.lineData, lineWidths = _ref.lineWidths, truncated = _ref.truncated, visibleWidths = _ref.visibleWidths;
35043
35270
  // Clean remaining soft hyphens from all lines
35044
35271
  var lines = lineData.map(function(l) {
35045
35272
  return l.replaceAll(softHyphen, "");
@@ -35047,7 +35274,9 @@
35047
35274
  // Report each line's width as at least the width the break logic consumed,
35048
35275
  // so that re-wrapping the same text at the reported width is stable (a
35049
35276
  // consumer that sizes a box to `max(widths)` won't trigger another break).
35050
- var lineWidthsVisible = d3plusTextWidth(lines, style);
35277
+ // The circle path already measured the finished lines while checking chord
35278
+ // fit, so reuse that instead of measuring the same strings again.
35279
+ var lineWidthsVisible = visibleWidths !== null && visibleWidths !== void 0 ? visibleWidths : d3plusTextWidth(lines, style);
35051
35280
  return {
35052
35281
  lines: lines,
35053
35282
  sentence: sentence,
@@ -35061,7 +35290,7 @@
35061
35290
  /**
35062
35291
  Based on the defined styles and dimensions, breaks a string into an array of strings for each line of text.
35063
35292
  */ function textWrap() {
35064
- var fontFamily = "sans-serif", fontSize = 10, fontWeight = 400, height = 200, lineHeight, maxLines = null, overflow = false, split = textSplit, width = 200;
35293
+ var fontFamily = "sans-serif", fontSize = 10, fontWeight = 400, height = 200, lineHeight, maxLines = null, overflow = false, shape = "square", split = textSplit, width = 200;
35065
35294
  /**
35066
35295
  The inner return object and wraps the text and returns the line data array.
35067
35296
  @private
@@ -35075,6 +35304,7 @@
35075
35304
  lineHeight: lineHeight,
35076
35305
  maxLines: maxLines,
35077
35306
  overflow: overflow,
35307
+ shape: shape,
35078
35308
  split: split,
35079
35309
  width: width
35080
35310
  });
@@ -35114,6 +35344,14 @@
35114
35344
  */ textWrap.overflow = function(_) {
35115
35345
  return arguments.length ? (overflow = _, textWrap) : overflow;
35116
35346
  };
35347
+ /**
35348
+ The bounding shape used when wrapping. `"square"` (default) fills the full
35349
+ [width](#textWrap.width) on every line; `"circle"` treats
35350
+ [width](#textWrap.width)/[height](#textWrap.height) as the diameter and
35351
+ shortens lines near the top and bottom so the text stays inside the circle.
35352
+ */ textWrap.shape = function(_) {
35353
+ return arguments.length ? (shape = _, textWrap) : shape;
35354
+ };
35117
35355
  /**
35118
35356
  The function used to split text into words.
35119
35357
  */ textWrap.split = function(_) {
@@ -39572,15 +39810,15 @@
39572
39810
  }
39573
39811
  }
39574
39812
 
39575
- function _array_like_to_array$4(arr, len) {
39813
+ function _array_like_to_array$6(arr, len) {
39576
39814
  if (len == null || len > arr.length) len = arr.length;
39577
39815
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
39578
39816
  return arr2;
39579
39817
  }
39580
- function _array_with_holes$4(arr) {
39818
+ function _array_with_holes$6(arr) {
39581
39819
  if (Array.isArray(arr)) return arr;
39582
39820
  }
39583
- function _iterable_to_array_limit$4(arr, i) {
39821
+ function _iterable_to_array_limit$6(arr, i) {
39584
39822
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
39585
39823
  if (_i == null) return;
39586
39824
  var _arr = [];
@@ -39604,19 +39842,19 @@
39604
39842
  }
39605
39843
  return _arr;
39606
39844
  }
39607
- function _non_iterable_rest$4() {
39845
+ function _non_iterable_rest$6() {
39608
39846
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
39609
39847
  }
39610
- function _sliced_to_array$4(arr, i) {
39611
- return _array_with_holes$4(arr) || _iterable_to_array_limit$4(arr, i) || _unsupported_iterable_to_array$4(arr, i) || _non_iterable_rest$4();
39848
+ function _sliced_to_array$6(arr, i) {
39849
+ return _array_with_holes$6(arr) || _iterable_to_array_limit$6(arr, i) || _unsupported_iterable_to_array$6(arr, i) || _non_iterable_rest$6();
39612
39850
  }
39613
- function _unsupported_iterable_to_array$4(o, minLen) {
39851
+ function _unsupported_iterable_to_array$6(o, minLen) {
39614
39852
  if (!o) return;
39615
- if (typeof o === "string") return _array_like_to_array$4(o, minLen);
39853
+ if (typeof o === "string") return _array_like_to_array$6(o, minLen);
39616
39854
  var n = Object.prototype.toString.call(o).slice(8, -1);
39617
39855
  if (n === "Object" && o.constructor) n = o.constructor.name;
39618
39856
  if (n === "Map" || n === "Set") return Array.from(n);
39619
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$4(o, minLen);
39857
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$6(o, minLen);
39620
39858
  }
39621
39859
  var s2lin = function s2lin(c) {
39622
39860
  return c <= 0.04045 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
@@ -39637,7 +39875,7 @@
39637
39875
  Converts a CSS color string to OKLab.
39638
39876
  @param c A valid CSS color string.
39639
39877
  */ function colorToOklab(c) {
39640
- var _linearRGB = _sliced_to_array$4(linearRGB(c), 3), r = _linearRGB[0], g = _linearRGB[1], b = _linearRGB[2];
39878
+ var _linearRGB = _sliced_to_array$6(linearRGB(c), 3), r = _linearRGB[0], g = _linearRGB[1], b = _linearRGB[2];
39641
39879
  var l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);
39642
39880
  var m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);
39643
39881
  var s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);
@@ -39688,7 +39926,7 @@
39688
39926
  The WCAG 2.x relative luminance of a color (0 = black, 1 = white).
39689
39927
  @param c A valid CSS color string.
39690
39928
  */ function relativeLuminance(c) {
39691
- var _linearRGB = _sliced_to_array$4(linearRGB(c), 3), r = _linearRGB[0], g = _linearRGB[1], b = _linearRGB[2];
39929
+ var _linearRGB = _sliced_to_array$6(linearRGB(c), 3), r = _linearRGB[0], g = _linearRGB[1], b = _linearRGB[2];
39692
39930
  return 0.2126 * r + 0.7152 * g + 0.0722 * b;
39693
39931
  }
39694
39932
  /**
@@ -39696,7 +39934,7 @@
39696
39934
  @param a A valid CSS color string.
39697
39935
  @param b A valid CSS color string.
39698
39936
  */ function contrastRatio(a, b) {
39699
- var _sort = _sliced_to_array$4([
39937
+ var _sort = _sliced_to_array$6([
39700
39938
  relativeLuminance(a),
39701
39939
  relativeLuminance(b)
39702
39940
  ].sort(function(x, y) {
@@ -39864,15 +40102,15 @@
39864
40102
  .replace(/\.[0]*$/g, ""); // removes any trailing decimal point
39865
40103
  }
39866
40104
 
39867
- function _array_like_to_array$3(arr, len) {
40105
+ function _array_like_to_array$5(arr, len) {
39868
40106
  if (len == null || len > arr.length) len = arr.length;
39869
40107
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
39870
40108
  return arr2;
39871
40109
  }
39872
- function _array_with_holes$3(arr) {
40110
+ function _array_with_holes$5(arr) {
39873
40111
  if (Array.isArray(arr)) return arr;
39874
40112
  }
39875
- function _iterable_to_array_limit$3(arr, i) {
40113
+ function _iterable_to_array_limit$5(arr, i) {
39876
40114
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
39877
40115
  if (_i == null) return;
39878
40116
  var _arr = [];
@@ -39896,19 +40134,19 @@
39896
40134
  }
39897
40135
  return _arr;
39898
40136
  }
39899
- function _non_iterable_rest$3() {
40137
+ function _non_iterable_rest$5() {
39900
40138
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
39901
40139
  }
39902
- function _sliced_to_array$3(arr, i) {
39903
- return _array_with_holes$3(arr) || _iterable_to_array_limit$3(arr, i) || _unsupported_iterable_to_array$3(arr, i) || _non_iterable_rest$3();
40140
+ function _sliced_to_array$5(arr, i) {
40141
+ return _array_with_holes$5(arr) || _iterable_to_array_limit$5(arr, i) || _unsupported_iterable_to_array$5(arr, i) || _non_iterable_rest$5();
39904
40142
  }
39905
- function _unsupported_iterable_to_array$3(o, minLen) {
40143
+ function _unsupported_iterable_to_array$5(o, minLen) {
39906
40144
  if (!o) return;
39907
- if (typeof o === "string") return _array_like_to_array$3(o, minLen);
40145
+ if (typeof o === "string") return _array_like_to_array$5(o, minLen);
39908
40146
  var n = Object.prototype.toString.call(o).slice(8, -1);
39909
40147
  if (n === "Object" && o.constructor) n = o.constructor.name;
39910
40148
  if (n === "Map" || n === "Set") return Array.from(n);
39911
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$3(o, minLen);
40149
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$5(o, minLen);
39912
40150
  }
39913
40151
  /**
39914
40152
  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.
@@ -39923,7 +40161,7 @@
39923
40161
  });
39924
40162
  var firstOrLast = labelIndex === 0 || labelIndex === dataArray.length - 1;
39925
40163
  var smallArray = dataArray.length <= 5;
39926
- var _dataArray_reduce = _sliced_to_array$3(dataArray.reduce(function(arr, d, i) {
40164
+ var _dataArray_reduce = _sliced_to_array$5(dataArray.reduce(function(arr, d, i) {
39927
40165
  if (i) {
39928
40166
  arr[0].push(d.getFullYear() - dataArray[i - 1].getFullYear());
39929
40167
  arr[1].push(monthDiff(dataArray[i - 1], d));
@@ -40418,15 +40656,15 @@
40418
40656
  ];
40419
40657
  }
40420
40658
 
40421
- function _array_like_to_array$2(arr, len) {
40659
+ function _array_like_to_array$4(arr, len) {
40422
40660
  if (len == null || len > arr.length) len = arr.length;
40423
40661
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
40424
40662
  return arr2;
40425
40663
  }
40426
- function _array_with_holes$2(arr) {
40664
+ function _array_with_holes$4(arr) {
40427
40665
  if (Array.isArray(arr)) return arr;
40428
40666
  }
40429
- function _iterable_to_array_limit$2(arr, i) {
40667
+ function _iterable_to_array_limit$4(arr, i) {
40430
40668
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
40431
40669
  if (_i == null) return;
40432
40670
  var _arr = [];
@@ -40450,19 +40688,19 @@
40450
40688
  }
40451
40689
  return _arr;
40452
40690
  }
40453
- function _non_iterable_rest$2() {
40691
+ function _non_iterable_rest$4() {
40454
40692
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
40455
40693
  }
40456
- function _sliced_to_array$2(arr, i) {
40457
- return _array_with_holes$2(arr) || _iterable_to_array_limit$2(arr, i) || _unsupported_iterable_to_array$2(arr, i) || _non_iterable_rest$2();
40694
+ function _sliced_to_array$4(arr, i) {
40695
+ return _array_with_holes$4(arr) || _iterable_to_array_limit$4(arr, i) || _unsupported_iterable_to_array$4(arr, i) || _non_iterable_rest$4();
40458
40696
  }
40459
- function _unsupported_iterable_to_array$2(o, minLen) {
40697
+ function _unsupported_iterable_to_array$4(o, minLen) {
40460
40698
  if (!o) return;
40461
- if (typeof o === "string") return _array_like_to_array$2(o, minLen);
40699
+ if (typeof o === "string") return _array_like_to_array$4(o, minLen);
40462
40700
  var n = Object.prototype.toString.call(o).slice(8, -1);
40463
40701
  if (n === "Object" && o.constructor) n = o.constructor.name;
40464
40702
  if (n === "Map" || n === "Set") return Array.from(n);
40465
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$2(o, minLen);
40703
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$4(o, minLen);
40466
40704
  }
40467
40705
  /**
40468
40706
  Checks whether a point is inside the bounding box of a line segment.
@@ -40470,7 +40708,7 @@
40470
40708
  @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.
40471
40709
  @param p The point to be checked, which should always be an `[x, y]` formatted Array.
40472
40710
  */ function segmentBoxContains(s1, s2, p) {
40473
- var eps = 1e-9, _p = _sliced_to_array$2(p, 2), px = _p[0], py = _p[1];
40711
+ var eps = 1e-9, _p = _sliced_to_array$4(p, 2), px = _p[0], py = _p[1];
40474
40712
  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);
40475
40713
  }
40476
40714
 
@@ -40518,15 +40756,15 @@
40518
40756
  return dx * dx + dy * dy;
40519
40757
  }
40520
40758
 
40521
- function _array_like_to_array$1(arr, len) {
40759
+ function _array_like_to_array$3(arr, len) {
40522
40760
  if (len == null || len > arr.length) len = arr.length;
40523
40761
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
40524
40762
  return arr2;
40525
40763
  }
40526
- function _array_with_holes$1(arr) {
40764
+ function _array_with_holes$3(arr) {
40527
40765
  if (Array.isArray(arr)) return arr;
40528
40766
  }
40529
- function _iterable_to_array_limit$1(arr, i) {
40767
+ function _iterable_to_array_limit$3(arr, i) {
40530
40768
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
40531
40769
  if (_i == null) return;
40532
40770
  var _arr = [];
@@ -40550,19 +40788,19 @@
40550
40788
  }
40551
40789
  return _arr;
40552
40790
  }
40553
- function _non_iterable_rest$1() {
40791
+ function _non_iterable_rest$3() {
40554
40792
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
40555
40793
  }
40556
- function _sliced_to_array$1(arr, i) {
40557
- return _array_with_holes$1(arr) || _iterable_to_array_limit$1(arr, i) || _unsupported_iterable_to_array$1(arr, i) || _non_iterable_rest$1();
40794
+ function _sliced_to_array$3(arr, i) {
40795
+ return _array_with_holes$3(arr) || _iterable_to_array_limit$3(arr, i) || _unsupported_iterable_to_array$3(arr, i) || _non_iterable_rest$3();
40558
40796
  }
40559
- function _unsupported_iterable_to_array$1(o, minLen) {
40797
+ function _unsupported_iterable_to_array$3(o, minLen) {
40560
40798
  if (!o) return;
40561
- if (typeof o === "string") return _array_like_to_array$1(o, minLen);
40799
+ if (typeof o === "string") return _array_like_to_array$3(o, minLen);
40562
40800
  var n = Object.prototype.toString.call(o).slice(8, -1);
40563
40801
  if (n === "Object" && o.constructor) n = o.constructor.name;
40564
40802
  if (n === "Map" || n === "Set") return Array.from(n);
40565
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$1(o, minLen);
40803
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$3(o, minLen);
40566
40804
  }
40567
40805
  /**
40568
40806
  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.
@@ -40577,7 +40815,7 @@
40577
40815
  origin[0] + eps * Math.cos(alpha),
40578
40816
  origin[1] + eps * Math.sin(alpha)
40579
40817
  ];
40580
- var _origin = _sliced_to_array$1(origin, 2), x0 = _origin[0], y0 = _origin[1];
40818
+ var _origin = _sliced_to_array$3(origin, 2), x0 = _origin[0], y0 = _origin[1];
40581
40819
  var shiftedOrigin = [
40582
40820
  x0 + Math.cos(alpha),
40583
40821
  y0 + Math.sin(alpha)
@@ -40735,12 +40973,12 @@
40735
40973
  return poly;
40736
40974
  }
40737
40975
 
40738
- function _array_like_to_array(arr, len) {
40976
+ function _array_like_to_array$2(arr, len) {
40739
40977
  if (len == null || len > arr.length) len = arr.length;
40740
40978
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
40741
40979
  return arr2;
40742
40980
  }
40743
- function _array_with_holes(arr) {
40981
+ function _array_with_holes$2(arr) {
40744
40982
  if (Array.isArray(arr)) return arr;
40745
40983
  }
40746
40984
  function _instanceof(left, right) {
@@ -40751,7 +40989,7 @@
40751
40989
  return left instanceof right;
40752
40990
  }
40753
40991
  }
40754
- function _iterable_to_array_limit(arr, i) {
40992
+ function _iterable_to_array_limit$2(arr, i) {
40755
40993
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
40756
40994
  if (_i == null) return;
40757
40995
  var _arr = [];
@@ -40775,19 +41013,19 @@
40775
41013
  }
40776
41014
  return _arr;
40777
41015
  }
40778
- function _non_iterable_rest() {
41016
+ function _non_iterable_rest$2() {
40779
41017
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
40780
41018
  }
40781
- function _sliced_to_array(arr, i) {
40782
- return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
41019
+ function _sliced_to_array$2(arr, i) {
41020
+ return _array_with_holes$2(arr) || _iterable_to_array_limit$2(arr, i) || _unsupported_iterable_to_array$2(arr, i) || _non_iterable_rest$2();
40783
41021
  }
40784
- function _unsupported_iterable_to_array(o, minLen) {
41022
+ function _unsupported_iterable_to_array$2(o, minLen) {
40785
41023
  if (!o) return;
40786
- if (typeof o === "string") return _array_like_to_array(o, minLen);
41024
+ if (typeof o === "string") return _array_like_to_array$2(o, minLen);
40787
41025
  var n = Object.prototype.toString.call(o).slice(8, -1);
40788
41026
  if (n === "Object" && o.constructor) n = o.constructor.name;
40789
41027
  if (n === "Map" || n === "Set") return Array.from(n);
40790
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
41028
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$2(o, minLen);
40791
41029
  }
40792
41030
  // Algorithm constants
40793
41031
  var aspectRatioStep = 0.5; // step size for the aspect ratio
@@ -40846,8 +41084,8 @@
40846
41084
  Improves a candidate origin by averaging the polygon ray-cast intersections
40847
41085
  along the width and height axes, returning the refined center points.
40848
41086
  */ function refineOrigins(poly, origOrigin, angleRad, idx, events) {
40849
- var _polygonRayCast = _sliced_to_array(polygonRayCast(poly, origOrigin, angleRad), 2), p1W = _polygonRayCast[0], p2W = _polygonRayCast[1];
40850
- var _polygonRayCast1 = _sliced_to_array(polygonRayCast(poly, origOrigin, angleRad + Math.PI / 2), 2), p1H = _polygonRayCast1[0], p2H = _polygonRayCast1[1];
41087
+ var _polygonRayCast = _sliced_to_array$2(polygonRayCast(poly, origOrigin, angleRad), 2), p1W = _polygonRayCast[0], p2W = _polygonRayCast[1];
41088
+ var _polygonRayCast1 = _sliced_to_array$2(polygonRayCast(poly, origOrigin, angleRad + Math.PI / 2), 2), p1H = _polygonRayCast1[0], p2H = _polygonRayCast1[1];
40851
41089
  var modifOrigins = [];
40852
41090
  if (p1W && p2W) modifOrigins.push([
40853
41091
  (p1W[0] + p2W[0]) / 2,
@@ -40879,14 +41117,14 @@
40879
41117
  cx: origin[0],
40880
41118
  cy: origin[1]
40881
41119
  });
40882
- var _polygonRayCast = _sliced_to_array(polygonRayCast(poly, origin, angleRad), 2), p1W = _polygonRayCast[0], p2W = _polygonRayCast[1];
41120
+ var _polygonRayCast = _sliced_to_array$2(polygonRayCast(poly, origin, angleRad), 2), p1W = _polygonRayCast[0], p2W = _polygonRayCast[1];
40883
41121
  if (p1W === null || p2W === null) return {
40884
41122
  maxArea: maxArea,
40885
41123
  maxRect: maxRect
40886
41124
  };
40887
41125
  var minSqDistW = Math.min(pointDistanceSquared(origin, p1W), pointDistanceSquared(origin, p2W));
40888
41126
  var maxWidth = 2 * Math.sqrt(minSqDistW);
40889
- var _polygonRayCast1 = _sliced_to_array(polygonRayCast(poly, origin, angleRad + Math.PI / 2), 2), p1H = _polygonRayCast1[0], p2H = _polygonRayCast1[1];
41127
+ var _polygonRayCast1 = _sliced_to_array$2(polygonRayCast(poly, origin, angleRad + Math.PI / 2), 2), p1H = _polygonRayCast1[0], p2H = _polygonRayCast1[1];
40890
41128
  if (p1H === null || p2H === null) return {
40891
41129
  maxArea: maxArea,
40892
41130
  maxRect: maxRect
@@ -40916,7 +41154,7 @@
40916
41154
  while(right - left >= widthStep){
40917
41155
  var width = (left + right) / 2;
40918
41156
  var height = width / aRatio;
40919
- var _origin = _sliced_to_array(origin, 2), cx = _origin[0], cy = _origin[1];
41157
+ var _origin = _sliced_to_array$2(origin, 2), cx = _origin[0], cy = _origin[1];
40920
41158
  var rectPoly = [
40921
41159
  [
40922
41160
  cx - width / 2,
@@ -41031,10 +41269,10 @@
41031
41269
  return null;
41032
41270
  }
41033
41271
  // get the width of the bounding box of the original polygon to determine tolerance
41034
- var _extent = _sliced_to_array(extent$1(poly, function(d) {
41272
+ var _extent = _sliced_to_array$2(extent$1(poly, function(d) {
41035
41273
  return d[0];
41036
41274
  }), 2), minx = _extent[0], maxx = _extent[1];
41037
- var _extent1 = _sliced_to_array(extent$1(poly, function(d) {
41275
+ var _extent1 = _sliced_to_array$2(extent$1(poly, function(d) {
41038
41276
  return d[1];
41039
41277
  }), 2), miny = _extent1[0], maxy = _extent1[1];
41040
41278
  // simplify polygon
@@ -41046,11 +41284,11 @@
41046
41284
  });
41047
41285
  var ref;
41048
41286
  // get the width of the bounding box of the simplified polygon
41049
- ref = _sliced_to_array(extent$1(poly, function(d) {
41287
+ ref = _sliced_to_array$2(extent$1(poly, function(d) {
41050
41288
  return d[0];
41051
41289
  }), 2), minx = ref[0], maxx = ref[1];
41052
41290
  var ref1;
41053
- ref1 = _sliced_to_array(extent$1(poly, function(d) {
41291
+ ref1 = _sliced_to_array$2(extent$1(poly, function(d) {
41054
41292
  return d[1];
41055
41293
  }), 2), miny = ref1[0], maxy = ref1[1];
41056
41294
  var _ref = [
@@ -41102,28 +41340,715 @@
41102
41340
  }) : maxRect;
41103
41341
  }
41104
41342
 
41343
+ function _class_call_check(instance, Constructor) {
41344
+ if (!(instance instanceof Constructor)) {
41345
+ throw new TypeError("Cannot call a class as a function");
41346
+ }
41347
+ }
41348
+ function _defineProperties(target, props) {
41349
+ for(var i = 0; i < props.length; i++){
41350
+ var descriptor = props[i];
41351
+ descriptor.enumerable = descriptor.enumerable || false;
41352
+ descriptor.configurable = true;
41353
+ if ("value" in descriptor) descriptor.writable = true;
41354
+ Object.defineProperty(target, descriptor.key, descriptor);
41355
+ }
41356
+ }
41357
+ function _create_class(Constructor, protoProps, staticProps) {
41358
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
41359
+ return Constructor;
41360
+ }
41361
+ function _define_property(obj, key, value) {
41362
+ if (key in obj) {
41363
+ Object.defineProperty(obj, key, {
41364
+ value: value,
41365
+ enumerable: true,
41366
+ configurable: true,
41367
+ writable: true
41368
+ });
41369
+ } else {
41370
+ obj[key] = value;
41371
+ }
41372
+ return obj;
41373
+ }
41374
+ var WS = new Set([
41375
+ " ",
41376
+ "\t",
41377
+ "\n",
41378
+ "\r",
41379
+ "\f",
41380
+ ","
41381
+ ]);
41382
+ /**
41383
+ A pointer-driven scanner over an SVG path `d` string. Kept command-aware so
41384
+ it can read arc flags (`large-arc`/`sweep`) as single `0`/`1` characters even
41385
+ when they are glued to the next number (the classic `a5 5 0 0150 0` case a
41386
+ plain number regex mis-tokenizes).
41387
+ @private
41388
+ */ var Scanner = /*#__PURE__*/ function() {
41389
+ function Scanner(s) {
41390
+ _class_call_check(this, Scanner);
41391
+ _define_property(this, "s", void 0);
41392
+ _define_property(this, "i", 0);
41393
+ this.s = s;
41394
+ }
41395
+ _create_class(Scanner, [
41396
+ {
41397
+ key: "eof",
41398
+ value: function eof() {
41399
+ return this.i >= this.s.length;
41400
+ }
41401
+ },
41402
+ {
41403
+ key: "skipSep",
41404
+ value: function skipSep() {
41405
+ while(this.i < this.s.length && WS.has(this.s[this.i]))this.i++;
41406
+ }
41407
+ },
41408
+ {
41409
+ /** Reads a number token (handles `.5`, `1.`, `1e3`, signs, exponents). */ key: "readNumber",
41410
+ value: function readNumber() {
41411
+ this.skipSep();
41412
+ var start = this.i;
41413
+ var s = this.s;
41414
+ if (s[this.i] === "+" || s[this.i] === "-") this.i++;
41415
+ while(this.i < s.length && s[this.i] >= "0" && s[this.i] <= "9")this.i++;
41416
+ if (s[this.i] === ".") {
41417
+ this.i++;
41418
+ while(this.i < s.length && s[this.i] >= "0" && s[this.i] <= "9")this.i++;
41419
+ }
41420
+ if (s[this.i] === "e" || s[this.i] === "E") {
41421
+ this.i++;
41422
+ if (s[this.i] === "+" || s[this.i] === "-") this.i++;
41423
+ while(this.i < s.length && s[this.i] >= "0" && s[this.i] <= "9")this.i++;
41424
+ }
41425
+ return parseFloat(s.slice(start, this.i));
41426
+ }
41427
+ },
41428
+ {
41429
+ /** Reads a single `0`/`1` arc flag, which may be glued to the next number. */ key: "readFlag",
41430
+ value: function readFlag() {
41431
+ this.skipSep();
41432
+ var c = this.s[this.i];
41433
+ this.i++;
41434
+ return c === "1" ? 1 : 0;
41435
+ }
41436
+ },
41437
+ {
41438
+ /** True when the next non-separator char begins a new number (implicit repeat). */ key: "moreArgs",
41439
+ value: function moreArgs() {
41440
+ this.skipSep();
41441
+ var c = this.s[this.i];
41442
+ return c !== undefined && (c === "+" || c === "-" || c === "." || c >= "0" && c <= "9");
41443
+ }
41444
+ },
41445
+ {
41446
+ key: "nextCommand",
41447
+ value: function nextCommand() {
41448
+ this.skipSep();
41449
+ var c = this.s[this.i];
41450
+ if (c !== undefined && (c >= "a" && c <= "z" || c >= "A" && c <= "Z")) {
41451
+ this.i++;
41452
+ return c;
41453
+ }
41454
+ return null;
41455
+ }
41456
+ }
41457
+ ]);
41458
+ return Scanner;
41459
+ }();
41460
+ /**
41461
+ Parses an SVG path `d` string into a flat list of absolute {@link PathSegment}s,
41462
+ with no DOM involved. Every relative command is resolved against the running
41463
+ point, `H`/`V` become `L`, and `S`/`T` expand into `C`/`Q` using the reflected
41464
+ previous control point.
41465
+ @param d An SVG path string (the `d` attribute of a `<path>`).
41466
+ */ function parsePath(d) {
41467
+ var out = [];
41468
+ if (!d) return out;
41469
+ var sc = new Scanner(d);
41470
+ var cmd = null;
41471
+ var cx = 0, cy = 0; // current point
41472
+ var sx = 0, sy = 0; // subpath start (for Z)
41473
+ // Reflected control point of the previous C/S (cubic) or Q/T (quadratic).
41474
+ var px = 0, py = 0;
41475
+ var prevType = "";
41476
+ while(!sc.eof()){
41477
+ var next = sc.nextCommand();
41478
+ if (next) cmd = next;
41479
+ else if (cmd === null) break;
41480
+ else if (cmd === "M") cmd = "L";
41481
+ else if (cmd === "m") cmd = "l";
41482
+ var rel = cmd === cmd.toLowerCase();
41483
+ var C = cmd.toUpperCase();
41484
+ var bx = rel ? cx : 0;
41485
+ var by = rel ? cy : 0;
41486
+ if (C === "M") {
41487
+ cx = sc.readNumber() + bx;
41488
+ cy = sc.readNumber() + by;
41489
+ sx = cx;
41490
+ sy = cy;
41491
+ out.push({
41492
+ type: "M",
41493
+ x: cx,
41494
+ y: cy
41495
+ });
41496
+ } else if (C === "L") {
41497
+ cx = sc.readNumber() + bx;
41498
+ cy = sc.readNumber() + by;
41499
+ out.push({
41500
+ type: "L",
41501
+ x: cx,
41502
+ y: cy
41503
+ });
41504
+ } else if (C === "H") {
41505
+ cx = sc.readNumber() + bx;
41506
+ out.push({
41507
+ type: "L",
41508
+ x: cx,
41509
+ y: cy
41510
+ });
41511
+ } else if (C === "V") {
41512
+ cy = sc.readNumber() + by;
41513
+ out.push({
41514
+ type: "L",
41515
+ x: cx,
41516
+ y: cy
41517
+ });
41518
+ } else if (C === "C") {
41519
+ var x1 = sc.readNumber() + bx, y1 = sc.readNumber() + by;
41520
+ var x2 = sc.readNumber() + bx, y2 = sc.readNumber() + by;
41521
+ cx = sc.readNumber() + bx;
41522
+ cy = sc.readNumber() + by;
41523
+ out.push({
41524
+ type: "C",
41525
+ x1: x1,
41526
+ y1: y1,
41527
+ x2: x2,
41528
+ y2: y2,
41529
+ x: cx,
41530
+ y: cy
41531
+ });
41532
+ px = x2;
41533
+ py = y2;
41534
+ } else if (C === "S") {
41535
+ var ref = prevType === "C" || prevType === "S";
41536
+ var x11 = ref ? 2 * cx - px : cx, y11 = ref ? 2 * cy - py : cy;
41537
+ var x21 = sc.readNumber() + bx, y21 = sc.readNumber() + by;
41538
+ cx = sc.readNumber() + bx;
41539
+ cy = sc.readNumber() + by;
41540
+ out.push({
41541
+ type: "C",
41542
+ x1: x11,
41543
+ y1: y11,
41544
+ x2: x21,
41545
+ y2: y21,
41546
+ x: cx,
41547
+ y: cy
41548
+ });
41549
+ px = x21;
41550
+ py = y21;
41551
+ } else if (C === "Q") {
41552
+ var x12 = sc.readNumber() + bx, y12 = sc.readNumber() + by;
41553
+ cx = sc.readNumber() + bx;
41554
+ cy = sc.readNumber() + by;
41555
+ out.push({
41556
+ type: "Q",
41557
+ x1: x12,
41558
+ y1: y12,
41559
+ x: cx,
41560
+ y: cy
41561
+ });
41562
+ px = x12;
41563
+ py = y12;
41564
+ } else if (C === "T") {
41565
+ var ref1 = prevType === "Q" || prevType === "T";
41566
+ var x13 = ref1 ? 2 * cx - px : cx, y13 = ref1 ? 2 * cy - py : cy;
41567
+ cx = sc.readNumber() + bx;
41568
+ cy = sc.readNumber() + by;
41569
+ out.push({
41570
+ type: "Q",
41571
+ x1: x13,
41572
+ y1: y13,
41573
+ x: cx,
41574
+ y: cy
41575
+ });
41576
+ px = x13;
41577
+ py = y13;
41578
+ } else if (C === "A") {
41579
+ var rx = sc.readNumber(), ry = sc.readNumber(), rot = sc.readNumber();
41580
+ var large = sc.readFlag(), sweep = sc.readFlag();
41581
+ cx = sc.readNumber() + bx;
41582
+ cy = sc.readNumber() + by;
41583
+ out.push({
41584
+ type: "A",
41585
+ rx: rx,
41586
+ ry: ry,
41587
+ rot: rot,
41588
+ large: large,
41589
+ sweep: sweep,
41590
+ x: cx,
41591
+ y: cy
41592
+ });
41593
+ } else if (C === "Z") {
41594
+ out.push({
41595
+ type: "Z"
41596
+ });
41597
+ cx = sx;
41598
+ cy = sy;
41599
+ } else {
41600
+ break;
41601
+ }
41602
+ prevType = C;
41603
+ // Stop repeating this command once its arguments are exhausted.
41604
+ if (C !== "Z" && !sc.moreArgs()) ;
41605
+ }
41606
+ return out;
41607
+ }
41608
+ /**
41609
+ Converts an SVG endpoint-parameterized arc to its center parameterization
41610
+ (SVG spec F.6.5), returning the ellipse center, corrected radii, x-axis
41611
+ rotation (radians), start angle and signed sweep. Returns null for a
41612
+ degenerate arc (zero radius), which callers treat as a straight line.
41613
+ @private
41614
+ */ function arcToCenter(x1, y1, rx, ry, rotDeg, large, sweep, x2, y2) {
41615
+ rx = Math.abs(rx);
41616
+ ry = Math.abs(ry);
41617
+ if (rx === 0 || ry === 0) return null;
41618
+ var phi = rotDeg * Math.PI / 180;
41619
+ var cosP = Math.cos(phi), sinP = Math.sin(phi);
41620
+ var dx = (x1 - x2) / 2, dy = (y1 - y2) / 2;
41621
+ var x1p = cosP * dx + sinP * dy;
41622
+ var y1p = -sinP * dx + cosP * dy;
41623
+ // Scale radii up if they are too small to span the endpoints.
41624
+ var lambda = x1p * x1p / (rx * rx) + y1p * y1p / (ry * ry);
41625
+ if (lambda > 1) {
41626
+ var s = Math.sqrt(lambda);
41627
+ rx *= s;
41628
+ ry *= s;
41629
+ }
41630
+ var sign = large !== sweep ? 1 : -1;
41631
+ var num = rx * rx * ry * ry - rx * rx * y1p * y1p - ry * ry * x1p * x1p;
41632
+ var den = rx * rx * y1p * y1p + ry * ry * x1p * x1p;
41633
+ var co = sign * Math.sqrt(Math.max(0, num / den));
41634
+ var cxp = co * rx * y1p / ry;
41635
+ var cyp = -co * ry * x1p / rx;
41636
+ var cx = cosP * cxp - sinP * cyp + (x1 + x2) / 2;
41637
+ var cy = sinP * cxp + cosP * cyp + (y1 + y2) / 2;
41638
+ var ang = function ang(ux, uy, vx, vy) {
41639
+ var dot = ux * vx + uy * vy;
41640
+ var len = Math.sqrt((ux * ux + uy * uy) * (vx * vx + vy * vy));
41641
+ var a = Math.acos(Math.min(1, Math.max(-1, dot / len)));
41642
+ if (ux * vy - uy * vx < 0) a = -a;
41643
+ return a;
41644
+ };
41645
+ var theta1 = ang(1, 0, (x1p - cxp) / rx, (y1p - cyp) / ry);
41646
+ var dtheta = ang((x1p - cxp) / rx, (y1p - cyp) / ry, (-x1p - cxp) / rx, (-y1p - cyp) / ry);
41647
+ if (!sweep && dtheta > 0) dtheta -= 2 * Math.PI;
41648
+ else if (sweep && dtheta < 0) dtheta += 2 * Math.PI;
41649
+ return {
41650
+ cx: cx,
41651
+ cy: cy,
41652
+ rx: rx,
41653
+ ry: ry,
41654
+ phi: phi,
41655
+ theta1: theta1,
41656
+ dtheta: dtheta
41657
+ };
41658
+ }
41659
+ /** A point on a center-parameterized arc at absolute ellipse angle `theta`. */ function arcPoint(arc, theta) {
41660
+ var cosP = Math.cos(arc.phi), sinP = Math.sin(arc.phi);
41661
+ var ct = Math.cos(theta), st = Math.sin(theta);
41662
+ return [
41663
+ arc.cx + arc.rx * ct * cosP - arc.ry * st * sinP,
41664
+ arc.cy + arc.rx * ct * sinP + arc.ry * st * cosP
41665
+ ];
41666
+ }
41667
+
41668
+ function _array_like_to_array$1(arr, len) {
41669
+ if (len == null || len > arr.length) len = arr.length;
41670
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
41671
+ return arr2;
41672
+ }
41673
+ function _array_with_holes$1(arr) {
41674
+ if (Array.isArray(arr)) return arr;
41675
+ }
41676
+ function _iterable_to_array_limit$1(arr, i) {
41677
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
41678
+ if (_i == null) return;
41679
+ var _arr = [];
41680
+ var _n = true;
41681
+ var _d = false;
41682
+ var _s, _e;
41683
+ try {
41684
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
41685
+ _arr.push(_s.value);
41686
+ if (i && _arr.length === i) break;
41687
+ }
41688
+ } catch (err) {
41689
+ _d = true;
41690
+ _e = err;
41691
+ } finally{
41692
+ try {
41693
+ if (!_n && _i["return"] != null) _i["return"]();
41694
+ } finally{
41695
+ if (_d) throw _e;
41696
+ }
41697
+ }
41698
+ return _arr;
41699
+ }
41700
+ function _non_iterable_rest$1() {
41701
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
41702
+ }
41703
+ function _sliced_to_array$1(arr, i) {
41704
+ return _array_with_holes$1(arr) || _iterable_to_array_limit$1(arr, i) || _unsupported_iterable_to_array$1(arr, i) || _non_iterable_rest$1();
41705
+ }
41706
+ function _unsupported_iterable_to_array$1(o, minLen) {
41707
+ if (!o) return;
41708
+ if (typeof o === "string") return _array_like_to_array$1(o, minLen);
41709
+ var n = Object.prototype.toString.call(o).slice(8, -1);
41710
+ if (n === "Object" && o.constructor) n = o.constructor.name;
41711
+ if (n === "Map" || n === "Set") return Array.from(n);
41712
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$1(o, minLen);
41713
+ }
41714
+ /** 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) {
41715
+ return Math.hypot(x1 - x0, y1 - y0) + Math.hypot(x2 - x1, y2 - y1) + Math.hypot(x3 - x2, y3 - y2);
41716
+ }
41105
41717
  /**
41106
- Transforms a path string into an Array of points.
41718
+ Transforms a path string into an Array of points, with no DOM involved.
41719
+ Straight segments contribute their endpoints; curves and arcs are flattened
41720
+ into line segments no longer than `segmentLength`. Higher `segmentLength`
41721
+ values lower computation time but yield more rigid curves.
41107
41722
  @param path An SVG string path, commonly the "d" property of a <path> element.
41108
- @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.
41723
+ @param segmentLength The maximum length of line segments when flattening curves.
41109
41724
  */ function path2polygon(path) {
41110
41725
  var segmentLength = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 50;
41111
- if (typeof document === "undefined") return [];
41112
- var svgPath = document.createElementNS("http://www.w3.org/2000/svg", "path");
41113
- svgPath.setAttribute("d", path);
41114
- var len = svgPath.getTotalLength();
41115
- var NUM_POINTS = len / segmentLength < 10 ? len / 10 : len / segmentLength;
41116
41726
  var points = [];
41117
- for(var i = 0; i < NUM_POINTS; i++){
41118
- var pt = svgPath.getPointAtLength(i * len / (NUM_POINTS - 1));
41119
- points.push([
41120
- pt.x,
41121
- pt.y
41727
+ var step = Math.max(1, segmentLength);
41728
+ var cx = 0, cy = 0;
41729
+ var push = function push(x, y) {
41730
+ var last = points[points.length - 1];
41731
+ // Skip exact duplicates (e.g. a curve start == the previous endpoint).
41732
+ if (!last || last[0] !== x || last[1] !== y) points.push([
41733
+ x,
41734
+ y
41122
41735
  ]);
41736
+ };
41737
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
41738
+ try {
41739
+ for(var _iterator = parsePath(path)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
41740
+ var seg = _step.value;
41741
+ if (seg.type === "M" || seg.type === "L") {
41742
+ push(seg.x, seg.y);
41743
+ cx = seg.x;
41744
+ cy = seg.y;
41745
+ } else if (seg.type === "C") {
41746
+ var len = cubicPolyLen(cx, cy, seg.x1, seg.y1, seg.x2, seg.y2, seg.x, seg.y);
41747
+ var n = Math.max(2, Math.ceil(len / step));
41748
+ for(var i = 1; i <= n; i++){
41749
+ var t = i / n, u = 1 - t;
41750
+ 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);
41751
+ }
41752
+ cx = seg.x;
41753
+ cy = seg.y;
41754
+ } else if (seg.type === "Q") {
41755
+ var len1 = Math.hypot(seg.x1 - cx, seg.y1 - cy) + Math.hypot(seg.x - seg.x1, seg.y - seg.y1);
41756
+ var n1 = Math.max(2, Math.ceil(len1 / step));
41757
+ for(var i1 = 1; i1 <= n1; i1++){
41758
+ var t1 = i1 / n1, u1 = 1 - t1;
41759
+ 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);
41760
+ }
41761
+ cx = seg.x;
41762
+ cy = seg.y;
41763
+ } else if (seg.type === "A") {
41764
+ var arc = arcToCenter(cx, cy, seg.rx, seg.ry, seg.rot, seg.large, seg.sweep, seg.x, seg.y);
41765
+ if (!arc) {
41766
+ push(seg.x, seg.y);
41767
+ } else {
41768
+ // Estimate length from the average radius × swept angle.
41769
+ var len2 = (arc.rx + arc.ry) / 2 * Math.abs(arc.dtheta);
41770
+ var n2 = Math.max(2, Math.ceil(len2 / step));
41771
+ for(var i2 = 1; i2 <= n2; i2++){
41772
+ var _arcPoint = _sliced_to_array$1(arcPoint(arc, arc.theta1 + arc.dtheta * i2 / n2), 2), px = _arcPoint[0], py = _arcPoint[1];
41773
+ push(px, py);
41774
+ }
41775
+ }
41776
+ cx = seg.x;
41777
+ cy = seg.y;
41778
+ }
41779
+ // Z contributes no new vertex — the subpath start is already in `points`.
41780
+ }
41781
+ } catch (err) {
41782
+ _didIteratorError = true;
41783
+ _iteratorError = err;
41784
+ } finally{
41785
+ try {
41786
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
41787
+ _iterator.return();
41788
+ }
41789
+ } finally{
41790
+ if (_didIteratorError) {
41791
+ throw _iteratorError;
41792
+ }
41793
+ }
41123
41794
  }
41124
41795
  return points;
41125
41796
  }
41126
41797
 
41798
+ function _array_like_to_array(arr, len) {
41799
+ if (len == null || len > arr.length) len = arr.length;
41800
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
41801
+ return arr2;
41802
+ }
41803
+ function _array_with_holes(arr) {
41804
+ if (Array.isArray(arr)) return arr;
41805
+ }
41806
+ function _array_without_holes(arr) {
41807
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
41808
+ }
41809
+ function _iterable_to_array(iter) {
41810
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
41811
+ }
41812
+ function _iterable_to_array_limit(arr, i) {
41813
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
41814
+ if (_i == null) return;
41815
+ var _arr = [];
41816
+ var _n = true;
41817
+ var _d = false;
41818
+ var _s, _e;
41819
+ try {
41820
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
41821
+ _arr.push(_s.value);
41822
+ if (i && _arr.length === i) break;
41823
+ }
41824
+ } catch (err) {
41825
+ _d = true;
41826
+ _e = err;
41827
+ } finally{
41828
+ try {
41829
+ if (!_n && _i["return"] != null) _i["return"]();
41830
+ } finally{
41831
+ if (_d) throw _e;
41832
+ }
41833
+ }
41834
+ return _arr;
41835
+ }
41836
+ function _non_iterable_rest() {
41837
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
41838
+ }
41839
+ function _non_iterable_spread() {
41840
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
41841
+ }
41842
+ function _sliced_to_array(arr, i) {
41843
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
41844
+ }
41845
+ function _to_consumable_array(arr) {
41846
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
41847
+ }
41848
+ function _unsupported_iterable_to_array(o, minLen) {
41849
+ if (!o) return;
41850
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
41851
+ var n = Object.prototype.toString.call(o).slice(8, -1);
41852
+ if (n === "Object" && o.constructor) n = o.constructor.name;
41853
+ if (n === "Map" || n === "Set") return Array.from(n);
41854
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
41855
+ }
41856
+ /** Value of a cubic Bézier on one axis at parameter t. */ function cubicAt(p0, p1, p2, p3, t) {
41857
+ var u = 1 - t;
41858
+ return u * u * u * p0 + 3 * u * u * t * p1 + 3 * u * t * t * p2 + t * t * t * p3;
41859
+ }
41860
+ /** Value of a quadratic Bézier on one axis at parameter t. */ function quadAt(p0, p1, p2, t) {
41861
+ var u = 1 - t;
41862
+ return u * u * p0 + 2 * u * t * p1 + t * t * p2;
41863
+ }
41864
+ /** Parameters in (0,1) where a cubic Bézier's derivative is zero on one axis. */ function cubicExtrema(p0, p1, p2, p3) {
41865
+ var a = p3 - 3 * p2 + 3 * p1 - p0;
41866
+ var b = 2 * (p2 - 2 * p1 + p0);
41867
+ var c = p1 - p0;
41868
+ var ts = [];
41869
+ if (Math.abs(a) < 1e-12) {
41870
+ if (Math.abs(b) > 1e-12) ts.push(-c / b);
41871
+ } else {
41872
+ var disc = b * b - 4 * a * c;
41873
+ if (disc >= 0) {
41874
+ var s = Math.sqrt(disc);
41875
+ ts.push((-b + s) / (2 * a), (-b - s) / (2 * a));
41876
+ }
41877
+ }
41878
+ return ts.filter(function(t) {
41879
+ return t > 0 && t < 1;
41880
+ });
41881
+ }
41882
+ /** Parameter in (0,1) where a quadratic Bézier's derivative is zero on one axis. */ function quadExtremum(p0, p1, p2) {
41883
+ var den = p0 - 2 * p1 + p2;
41884
+ if (Math.abs(den) < 1e-12) return [];
41885
+ var t = (p0 - p1) / den;
41886
+ return t > 0 && t < 1 ? [
41887
+ t
41888
+ ] : [];
41889
+ }
41890
+ /** True when absolute ellipse angle `theta` falls inside the arc's signed sweep. */ function angleInArc(theta, theta1, dtheta) {
41891
+ var TAU = 2 * Math.PI;
41892
+ var d = theta - theta1;
41893
+ if (dtheta >= 0) {
41894
+ while(d < 0)d += TAU;
41895
+ while(d > TAU)d -= TAU;
41896
+ return d <= dtheta + 1e-9;
41897
+ }
41898
+ while(d > 0)d -= TAU;
41899
+ while(d < -TAU)d += TAU;
41900
+ return d >= dtheta - 1e-9;
41901
+ }
41902
+ /**
41903
+ Computes the exact bounding box of an SVG path string with no DOM involved,
41904
+ evaluating the true extrema of each Bézier and arc segment (not a sampled
41905
+ approximation). Returns `{x, y, width, height}`, or a zero-size box at the
41906
+ origin for an empty/unparseable path.
41907
+ @param d An SVG path string (the `d` attribute of a `<path>`).
41908
+ */ function pathBounds(d) {
41909
+ var minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
41910
+ var add = function add(x, y) {
41911
+ if (x < minX) minX = x;
41912
+ if (y < minY) minY = y;
41913
+ if (x > maxX) maxX = x;
41914
+ if (y > maxY) maxY = y;
41915
+ };
41916
+ var cx = 0, cy = 0;
41917
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
41918
+ try {
41919
+ for(var _iterator = parsePath(d)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
41920
+ var seg = _step.value;
41921
+ if (seg.type === "M" || seg.type === "L") {
41922
+ add(seg.x, seg.y);
41923
+ cx = seg.x;
41924
+ cy = seg.y;
41925
+ } else if (seg.type === "C") {
41926
+ add(cx, cy);
41927
+ add(seg.x, seg.y);
41928
+ // At each axis extremum, include the full point on the curve — only the
41929
+ // extreme axis grows the box, the other coordinate is a real point on it.
41930
+ 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)));
41931
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
41932
+ try {
41933
+ for(var _iterator1 = ts[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
41934
+ var t = _step1.value;
41935
+ add(cubicAt(cx, seg.x1, seg.x2, seg.x, t), cubicAt(cy, seg.y1, seg.y2, seg.y, t));
41936
+ }
41937
+ } catch (err) {
41938
+ _didIteratorError1 = true;
41939
+ _iteratorError1 = err;
41940
+ } finally{
41941
+ try {
41942
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
41943
+ _iterator1.return();
41944
+ }
41945
+ } finally{
41946
+ if (_didIteratorError1) {
41947
+ throw _iteratorError1;
41948
+ }
41949
+ }
41950
+ }
41951
+ cx = seg.x;
41952
+ cy = seg.y;
41953
+ } else if (seg.type === "Q") {
41954
+ add(cx, cy);
41955
+ add(seg.x, seg.y);
41956
+ var ts1 = _to_consumable_array(quadExtremum(cx, seg.x1, seg.x)).concat(_to_consumable_array(quadExtremum(cy, seg.y1, seg.y)));
41957
+ var _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = undefined;
41958
+ try {
41959
+ for(var _iterator2 = ts1[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true){
41960
+ var t1 = _step2.value;
41961
+ add(quadAt(cx, seg.x1, seg.x, t1), quadAt(cy, seg.y1, seg.y, t1));
41962
+ }
41963
+ } catch (err) {
41964
+ _didIteratorError2 = true;
41965
+ _iteratorError2 = err;
41966
+ } finally{
41967
+ try {
41968
+ if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
41969
+ _iterator2.return();
41970
+ }
41971
+ } finally{
41972
+ if (_didIteratorError2) {
41973
+ throw _iteratorError2;
41974
+ }
41975
+ }
41976
+ }
41977
+ cx = seg.x;
41978
+ cy = seg.y;
41979
+ } else if (seg.type === "A") {
41980
+ add(cx, cy);
41981
+ add(seg.x, seg.y);
41982
+ var arc = arcToCenter(cx, cy, seg.rx, seg.ry, seg.rot, seg.large, seg.sweep, seg.x, seg.y);
41983
+ if (arc) {
41984
+ var phi = arc.phi, rx = arc.rx, ry = arc.ry, theta1 = arc.theta1, dtheta = arc.dtheta;
41985
+ // Ellipse-angle candidates where dX/dθ = 0 and dY/dθ = 0.
41986
+ var cands = [
41987
+ Math.atan2(-ry * Math.sin(phi), rx * Math.cos(phi)),
41988
+ Math.atan2(ry * Math.cos(phi), rx * Math.sin(phi))
41989
+ ];
41990
+ var _iteratorNormalCompletion3 = true, _didIteratorError3 = false, _iteratorError3 = undefined;
41991
+ try {
41992
+ for(var _iterator3 = cands[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true){
41993
+ var base = _step3.value;
41994
+ for(var _i = 0, _iter = [
41995
+ base,
41996
+ base + Math.PI
41997
+ ]; _i < _iter.length; _i++){
41998
+ var theta = _iter[_i];
41999
+ if (angleInArc(theta, theta1, dtheta)) {
42000
+ var _arcPoint = _sliced_to_array(arcPoint(arc, theta), 2), px = _arcPoint[0], py = _arcPoint[1];
42001
+ add(px, py);
42002
+ }
42003
+ }
42004
+ }
42005
+ } catch (err) {
42006
+ _didIteratorError3 = true;
42007
+ _iteratorError3 = err;
42008
+ } finally{
42009
+ try {
42010
+ if (!_iteratorNormalCompletion3 && _iterator3.return != null) {
42011
+ _iterator3.return();
42012
+ }
42013
+ } finally{
42014
+ if (_didIteratorError3) {
42015
+ throw _iteratorError3;
42016
+ }
42017
+ }
42018
+ }
42019
+ }
42020
+ cx = seg.x;
42021
+ cy = seg.y;
42022
+ }
42023
+ }
42024
+ } catch (err) {
42025
+ _didIteratorError = true;
42026
+ _iteratorError = err;
42027
+ } finally{
42028
+ try {
42029
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
42030
+ _iterator.return();
42031
+ }
42032
+ } finally{
42033
+ if (_didIteratorError) {
42034
+ throw _iteratorError;
42035
+ }
42036
+ }
42037
+ }
42038
+ if (!Number.isFinite(minX)) return {
42039
+ x: 0,
42040
+ y: 0,
42041
+ width: 0,
42042
+ height: 0
42043
+ };
42044
+ return {
42045
+ x: minX,
42046
+ y: minY,
42047
+ width: maxX - minX,
42048
+ height: maxY - minY
42049
+ };
42050
+ }
42051
+
41127
42052
  /**
41128
42053
  Calculates the pixel distance between two points.
41129
42054
  @param p1 The first point, which should always be an `[x, y]` formatted Array.
@@ -41555,6 +42480,14 @@
41555
42480
  id: `${id(d, i)}_${l}`,
41556
42481
  r,
41557
42482
  rotateAnchor,
42483
+ // Wrapping shape rides on the bounds so it stays paired with them:
42484
+ // a shape whose `labelBounds` returns `shape: "circle"` wraps to the
42485
+ // circle, while a chart that supplies its own rectangular bounds
42486
+ // (no `shape`) wraps normally. Stamped under a namespaced key so it
42487
+ // can't collide with a `shape` field a caller's own data might carry.
42488
+ ...b.shape ? {
42489
+ __d3plusWrapShape__: b.shape
42490
+ } : {},
41558
42491
  text: labels[l],
41559
42492
  width: b.width,
41560
42493
  x: xPos + b.x,
@@ -41602,153 +42535,6 @@
41602
42535
  };
41603
42536
  }
41604
42537
 
41605
- /** Image's fluent accessor schema. Config storage lives on `this.schema.<key>`. */ const imageSchema = [
41606
- {
41607
- key: "duration",
41608
- coerce: "identity",
41609
- default: 600
41610
- },
41611
- {
41612
- key: "height",
41613
- coerce: "accessor",
41614
- default: accessor("height")
41615
- },
41616
- {
41617
- key: "id",
41618
- coerce: "identity",
41619
- default: accessor("id")
41620
- },
41621
- {
41622
- key: "opacity",
41623
- coerce: "const",
41624
- default: constant$b(1)
41625
- },
41626
- {
41627
- key: "pointerEvents",
41628
- coerce: "const",
41629
- default: constant$b("auto")
41630
- },
41631
- {
41632
- key: "renderMode",
41633
- coerce: "identity",
41634
- default: "full"
41635
- },
41636
- {
41637
- key: "url",
41638
- coerce: "identity",
41639
- default: accessor("url")
41640
- },
41641
- {
41642
- key: "width",
41643
- coerce: "accessor",
41644
- default: accessor("width")
41645
- },
41646
- {
41647
- key: "x",
41648
- coerce: "const",
41649
- default: accessor("x", 0)
41650
- },
41651
- {
41652
- key: "y",
41653
- coerce: "const",
41654
- default: accessor("y", 0)
41655
- }
41656
- ];
41657
- let Image$1 = class Image {
41658
- config(_) {
41659
- if (!arguments.length) return {
41660
- ...this.schema,
41661
- data: this._data,
41662
- select: this._select
41663
- };
41664
- const patch = _;
41665
- for(const k in patch){
41666
- if (!Object.prototype.hasOwnProperty.call(patch, k)) continue;
41667
- // `this[k]` resolves the fluent accessor via the index signature.
41668
- if (typeof this[k] === "function") this[k](patch[k]);
41669
- else this.schema[k] = patch[k];
41670
- }
41671
- return this;
41672
- }
41673
- /**
41674
- Renders the current Image to the page. If a *callback* is specified, it will be called once the images are done drawing.
41675
- @param callback Optional callback invoked after rendering completes.
41676
- */ render(callback) {
41677
- // Compute mode is a no-op for DOM emission — the caller will read
41678
- // `toScene()` to get a SceneNode tree, no need to mount.
41679
- if (this.schema.renderMode === "compute") {
41680
- if (callback) setTimeout(callback, 0);
41681
- return this;
41682
- }
41683
- 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());
41684
- const images = this._select.selectAll(".d3plus-Image").data(this._data, this.schema.id);
41685
- 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);
41686
- const t = transition().duration(this.schema.duration), that = this, update = enter.merge(images);
41687
- 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) {
41688
- const image = select(this), link = that.schema.url(d, i);
41689
- const fullAddress = link.indexOf("http://") === 0 || link.indexOf("https://") === 0;
41690
- if (!fullAddress || link.indexOf(window.location.hostname) === 0) {
41691
- const img = new window.Image();
41692
- img.src = link;
41693
- img.crossOrigin = "Anonymous";
41694
- img.onload = function() {
41695
- const canvas = document.createElement("canvas");
41696
- canvas.width = img.width;
41697
- canvas.height = img.height;
41698
- const context = canvas.getContext("2d");
41699
- context.drawImage(img, 0, 0);
41700
- image.attr("xlink:href", canvas.toDataURL("image/png"));
41701
- };
41702
- }
41703
- });
41704
- 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();
41705
- if (callback) setTimeout(callback, this.schema.duration + 100);
41706
- return this;
41707
- }
41708
- data(_) {
41709
- return arguments.length ? (this._data = _, this) : this._data;
41710
- }
41711
- /**
41712
- Compute-mode scene emission. Mirrors Shape.toScene's shape — a
41713
- keyed GroupNode wrapping per-datum ImageNodes. Used by chart
41714
- compositors (Shape._backgroundImageClass, plotPaint) that need
41715
- Image to participate in the scene graph rather than emit
41716
- d3-selection DOM.
41717
- */ toScene() {
41718
- const children = (this._data || []).map((d, i)=>{
41719
- const node = {
41720
- type: "image",
41721
- key: `${this.schema.id(d, i)}`,
41722
- x: this.schema.x(d, i),
41723
- y: this.schema.y(d, i),
41724
- width: this.schema.width(d, i),
41725
- height: this.schema.height(d, i),
41726
- href: this.schema.url(d, i),
41727
- paint: {
41728
- opacity: this.schema.opacity(d, i)
41729
- },
41730
- datum: d,
41731
- index: i
41732
- };
41733
- return node;
41734
- });
41735
- return {
41736
- type: "group",
41737
- key: "d3plus-Image",
41738
- children
41739
- };
41740
- }
41741
- select(_) {
41742
- return arguments.length ? (this._select = select(_), this) : this._select;
41743
- }
41744
- /**
41745
- Invoked when creating a new class instance, and sets any default parameters.
41746
- @private
41747
- */ constructor(){
41748
- installFluent(this, imageSchema);
41749
- }
41750
- };
41751
-
41752
42538
  /** Follows the chart (`__d3plus__`) and shape (`__d3plusShape__`) wrappers back
41753
42539
  to the source datum, so a `sort` comparator sees the same object the other
41754
42540
  per-datum accessors receive. */ function unwrap(d) {
@@ -41771,18 +42557,219 @@
41771
42557
  order.forEach((origIdx, pos)=>rank[origIdx] = pos);
41772
42558
  return rank;
41773
42559
  }
42560
+ /** Bounding box of a list of polygon points, or null when degenerate. */ function pointsBox(points) {
42561
+ if (!points.length) return null;
42562
+ let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
42563
+ for (const [px, py] of points){
42564
+ if (px < minX) minX = px;
42565
+ if (py < minY) minY = py;
42566
+ if (px > maxX) maxX = px;
42567
+ if (py > maxY) maxY = py;
42568
+ }
42569
+ if (!Number.isFinite(minX) || maxX <= minX || maxY <= minY) return null;
42570
+ return {
42571
+ x: minX,
42572
+ y: minY,
42573
+ width: maxX - minX,
42574
+ height: maxY - minY
42575
+ };
42576
+ }
41774
42577
  /**
41775
- Renders the per-datum background images collected during `Shape.toScene` as
41776
- flat sibling nodes. When `rank` is set (a `sort` comparator is active) every
41777
- returned node needs a `z` — otherwise the backend sort would collapse the
41778
- images to 0 and interleave them among the geometry — so they are placed
41779
- above all geometry (ranks span `0..dataLen-1`) while keeping their own order.
41780
- */ function emitBackgroundImages(bgClass, imageData, rank, dataLen) {
41781
- 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");
41782
- const imgScene = bgClass.toScene();
41783
- if (!imgScene || !Array.isArray(imgScene.children)) return [];
41784
- if (rank) imgScene.children.forEach((c, k)=>c.z = dataLen + k);
41785
- return imgScene.children;
42578
+ The local-space bounding box `{x, y, width, height}` a backgroundImage fills,
42579
+ derived from a datum's scene geometry. Rect/Bar geometry is already a box;
42580
+ Circle is centered at (cx, cy) with radius r; a `path` uses the exact
42581
+ (DOM-free) bounds of its `d`; Area/Line fall back to their polygon `points`.
42582
+ Returns null when no finite extent can be determined.
42583
+ */ function backgroundImageBox(g, points) {
42584
+ if (typeof g.width === "number" && typeof g.height === "number") {
42585
+ const x = typeof g.x === "number" ? g.x : -g.width / 2;
42586
+ const y = typeof g.y === "number" ? g.y : -g.height / 2;
42587
+ return {
42588
+ x,
42589
+ y,
42590
+ width: g.width,
42591
+ height: g.height
42592
+ };
42593
+ }
42594
+ if (typeof g.r === "number") {
42595
+ const cx = typeof g.cx === "number" ? g.cx : 0;
42596
+ const cy = typeof g.cy === "number" ? g.cy : 0;
42597
+ return {
42598
+ x: cx - g.r,
42599
+ y: cy - g.r,
42600
+ width: g.r * 2,
42601
+ height: g.r * 2
42602
+ };
42603
+ }
42604
+ if (typeof g.d === "string") {
42605
+ const b = pathBounds(g.d);
42606
+ return b.width > 0 && b.height > 0 ? b : null;
42607
+ }
42608
+ return pointsBox(points);
42609
+ }
42610
+ /** Rounded-rectangle path `d` (falls back to a plain rect when radii are 0). */ function roundedRectPath(x, y, w, h, rx, ry) {
42611
+ rx = Math.min(rx, w / 2);
42612
+ ry = Math.min(ry, h / 2);
42613
+ 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`;
42614
+ }
42615
+ /**
42616
+ The shape's own geometry expressed as a clip region in its LOCAL coordinate
42617
+ space, so a background image can be clipped to the shape itself (a Path image
42618
+ is clipped to the path, a Circle image to the circle, etc.). Returns
42619
+ undefined when the geometry has no usable outline.
42620
+ */ function backgroundImageClip(g, points) {
42621
+ if (typeof g.d === "string") return {
42622
+ type: "path",
42623
+ d: g.d
42624
+ };
42625
+ if (typeof g.width === "number" && typeof g.height === "number") {
42626
+ const x = typeof g.x === "number" ? g.x : -g.width / 2;
42627
+ const y = typeof g.y === "number" ? g.y : -g.height / 2;
42628
+ const rx = typeof g.rx === "number" ? g.rx : 0;
42629
+ const ry = typeof g.ry === "number" ? g.ry : 0;
42630
+ return rx > 0 || ry > 0 ? {
42631
+ type: "path",
42632
+ d: roundedRectPath(x, y, g.width, g.height, rx || ry, ry || rx)
42633
+ } : {
42634
+ type: "rect",
42635
+ x,
42636
+ y,
42637
+ width: g.width,
42638
+ height: g.height
42639
+ };
42640
+ }
42641
+ if (typeof g.r === "number") {
42642
+ const cx = typeof g.cx === "number" ? g.cx : 0;
42643
+ const cy = typeof g.cy === "number" ? g.cy : 0;
42644
+ const r = g.r;
42645
+ return {
42646
+ type: "path",
42647
+ d: `M${cx - r},${cy}a${r},${r} 0 1,0 ${2 * r},0a${r},${r} 0 1,0 ${ -2 * r},0Z`
42648
+ };
42649
+ }
42650
+ if (points.length > 2) {
42651
+ const d = `M${points.map(([x, y])=>`${x},${y}`).join("L")}Z`;
42652
+ return {
42653
+ type: "path",
42654
+ d
42655
+ };
42656
+ }
42657
+ return undefined;
42658
+ }
42659
+ /** A polygon (local coords) approximating the shape outline, for `largestRect`. */ function shapePolygon(g, points) {
42660
+ if (typeof g.d === "string") return path2polygon(g.d);
42661
+ return points;
42662
+ }
42663
+ /**
42664
+ Resolves a backgroundImage's box + clip + `preserveAspectRatio` for a datum's
42665
+ geometry, honoring the fit mode:
42666
+
42667
+ - `cover` — the image fills the shape's bounding box and is cropped
42668
+ (`xMidYMid slice`), clipped to the shape's own outline.
42669
+ - `contain` — the whole image is centered and fully visible inside the shape:
42670
+ it is fit (`xMidYMid meet`) into the shape's largest inscribed axis-aligned
42671
+ rectangle (a Rect uses itself; a Circle its inscribed square; a Path/Area
42672
+ uses `largestRect` of its polygon). No clip is needed since the box already
42673
+ sits inside the shape.
42674
+
42675
+ Returns null when no usable box can be derived.
42676
+ */ function backgroundImageLayout(g, points, fit) {
42677
+ if (fit !== "contain") {
42678
+ const box = backgroundImageBox(g, points);
42679
+ if (!box) return null;
42680
+ return {
42681
+ box,
42682
+ clip: backgroundImageClip(g, points),
42683
+ preserveAspectRatio: "xMidYMid slice"
42684
+ };
42685
+ }
42686
+ // contain: fit inside the largest inscribed rectangle, fully visible.
42687
+ let box = null;
42688
+ if (typeof g.width === "number" && typeof g.height === "number") {
42689
+ box = backgroundImageBox(g, points); // a rect contains itself
42690
+ } else if (typeof g.r === "number") {
42691
+ // Inscribed square of a circle: side = r·√2, centered on (cx, cy).
42692
+ const cx = typeof g.cx === "number" ? g.cx : 0;
42693
+ const cy = typeof g.cy === "number" ? g.cy : 0;
42694
+ const half = g.r / Math.SQRT2;
42695
+ box = {
42696
+ x: cx - half,
42697
+ y: cy - half,
42698
+ width: half * 2,
42699
+ height: half * 2
42700
+ };
42701
+ } else {
42702
+ const poly = shapePolygon(g, points);
42703
+ const r = poly.length > 2 ? largestRect(poly, {
42704
+ angle: 0
42705
+ }) : null;
42706
+ box = r ? {
42707
+ x: r.cx - r.width / 2,
42708
+ y: r.cy - r.height / 2,
42709
+ width: r.width,
42710
+ height: r.height
42711
+ } : backgroundImageBox(g, points);
42712
+ }
42713
+ return box ? {
42714
+ box,
42715
+ preserveAspectRatio: "xMidYMid meet"
42716
+ } : null;
42717
+ }
42718
+ /**
42719
+ Emits the per-datum background images collected during `Shape.toScene`. Each
42720
+ image is wrapped in its own group carrying the shape's datum + transform, so
42721
+ it is clipped to the shape's outline, positioned in local space, and dims/
42722
+ raises together with its shape on hover. The image is non-interactive (and
42723
+ keyed apart from the shape) so pointer events pass through to the shape below.
42724
+ When `rank` is set (a `sort` comparator is active) every group needs a `z`
42725
+ so the backend sort keeps images above the geometry in their own order.
42726
+ */ function emitBackgroundImages(specs, rank, dataLen) {
42727
+ return specs.map((spec, k)=>{
42728
+ const image = {
42729
+ type: "image",
42730
+ // Keyed apart from the shape (which uses `spec.key`): sharing the key would
42731
+ // let this non-interactive image overwrite the shape in the hit-test index.
42732
+ key: `${spec.key}-bgimage-img`,
42733
+ x: spec.box.x,
42734
+ y: spec.box.y,
42735
+ width: spec.box.width,
42736
+ height: spec.box.height,
42737
+ href: spec.url,
42738
+ preserveAspectRatio: spec.preserveAspectRatio,
42739
+ // Decorative: pointer events fall through to the shape underneath.
42740
+ interactive: false
42741
+ };
42742
+ const group = {
42743
+ type: "group",
42744
+ key: `${spec.key}-bgimage`,
42745
+ children: [
42746
+ image
42747
+ ],
42748
+ // Carry the shape's datum/index so hover/active dimming treats the image
42749
+ // like its shape — dimming and hover-raising the two together (the group
42750
+ // is emitted after the geometry, so at equal `z` the image stays on top).
42751
+ datum: spec.datum,
42752
+ index: spec.index,
42753
+ interactive: false,
42754
+ // A group-level opacity gives the enter/exit animation a target to fade
42755
+ // to/from (matching the shape): the animate layer collapses it to 0 on
42756
+ // enter and eases up to this. It also cascades to the image, so hover
42757
+ // dimming applied here fades the picture with its shape.
42758
+ paint: {
42759
+ opacity: spec.opacity ?? 1
42760
+ },
42761
+ ...spec.transform ? {
42762
+ transform: spec.transform
42763
+ } : {},
42764
+ ...spec.clip ? {
42765
+ clip: spec.clip
42766
+ } : {},
42767
+ ...rank ? {
42768
+ z: dataLen + k
42769
+ } : {}
42770
+ };
42771
+ return group;
42772
+ });
41786
42773
  }
41787
42774
 
41788
42775
  /** Coerces a value to a finite number, or undefined. @private */ function numOrUndef(v) {
@@ -41816,6 +42803,11 @@
41816
42803
  coerce: "const",
41817
42804
  default: constant$b(false)
41818
42805
  },
42806
+ {
42807
+ key: "backgroundImageFit",
42808
+ coerce: "const",
42809
+ default: constant$b("cover")
42810
+ },
41819
42811
  {
41820
42812
  key: "discrete",
41821
42813
  coerce: "identity"
@@ -42128,10 +43120,10 @@
42128
43120
  let data = this._data;
42129
43121
  if (this._dataFilter) data = this._dataFilter(data);
42130
43122
  const children = [];
42131
- // Build the backgroundImage data for emission below. Each datum that
42132
- // resolves to a non-false `backgroundImage(d, i)` becomes an
42133
- // ImageNode positioned at the shape's geometry.
42134
- const imageData = [];
43123
+ // Collected background images, emitted below (after the geometry) as clipped,
43124
+ // transformed groups. Each datum whose `backgroundImage(d, i)` resolves to a
43125
+ // truthy URL contributes one spec.
43126
+ const bgSpecs = [];
42135
43127
  // A `sort` comparator becomes per-datum `z` ranks rather than a reorder of
42136
43128
  // `data`: the render backends sort each group's children ascending by `z`
42137
43129
  // (stably), so a lower rank paints first (behind) and a higher rank paints
@@ -42170,41 +43162,37 @@
42170
43162
  z: rank[i]
42171
43163
  } : {}
42172
43164
  });
42173
- // backgroundImage: collect a per-datum image when the accessor
42174
- // returns a truthy URL. The image is sized to the shape's
42175
- // geometry (preferring width/height fields when present).
43165
+ // backgroundImage: collect a per-datum image (see backgroundImageLayout for
43166
+ // the cover/contain fit). The wrapping group carries the shape transform,
43167
+ // so the image box + clip stay in local space.
42176
43168
  const bg = this._nestWrapper(this.schema.backgroundImage)(d, i);
42177
43169
  if (bg) {
42178
43170
  const g = geom;
42179
- // Shape geometry is origin-centered; its on-screen position lives in
42180
- // the node transform. The background image is emitted as a flat sibling
42181
- // (no transform), so bake the shape's translate into the image x/y —
42182
- // otherwise every image lands at the origin (top-left).
42183
- const t = this._sceneTransform(d, i);
42184
- const w = typeof g.width === "number" ? g.width : undefined;
42185
- const h = typeof g.height === "number" ? g.height : undefined;
42186
- const cx = typeof g.cx === "number" ? g.cx : typeof g.x === "number" ? g.x : 0;
42187
- const cy = typeof g.cy === "number" ? g.cy : typeof g.y === "number" ? g.y : 0;
42188
- const r = typeof g.r === "number" ? g.r : undefined;
42189
- const iw = w ?? (r != null ? r * 2 : 0);
42190
- const ih = h ?? (r != null ? r * 2 : 0);
42191
- imageData.push({
42192
- __d3plus__: true,
42193
- data: d,
42194
- i,
42195
- id: this._nestWrapper(this.schema.id)(d, i),
42196
- url: bg,
42197
- x: (t.x ?? 0) + cx - iw / 2,
42198
- y: (t.y ?? 0) + cy - ih / 2,
42199
- width: iw,
42200
- height: ih
42201
- });
43171
+ // Only Area/Line lack a `d`/box and need polygon points; Path/Rect/Circle
43172
+ // derive their layout from `d`/width/r directly.
43173
+ const needsPoints = typeof g.d !== "string" && typeof g.width !== "number" && typeof g.r !== "number";
43174
+ const points = needsPoints ? this._aes(d, i).points ?? [] : [];
43175
+ const fit = this._nestWrapper(this.schema.backgroundImageFit)(d, i);
43176
+ const layout = backgroundImageLayout(g, points, fit === "contain" ? "contain" : "cover");
43177
+ if (layout) {
43178
+ bgSpecs.push({
43179
+ key,
43180
+ index: i,
43181
+ datum,
43182
+ url: bg,
43183
+ box: layout.box,
43184
+ clip: layout.clip,
43185
+ preserveAspectRatio: layout.preserveAspectRatio,
43186
+ opacity: numOrUndef(this._nestWrapper(this.schema.opacity)(d, i)),
43187
+ transform
43188
+ });
43189
+ }
42202
43190
  }
42203
43191
  });
42204
43192
  // Emit background images AFTER shape children so they paint above the
42205
43193
  // shape's fill — matches the DOM order where the <image> was
42206
43194
  // appended as a sibling of the shape.
42207
- if (imageData.length) children.push(...emitBackgroundImages(this._backgroundImageClass, imageData, rank, data.length));
43195
+ if (bgSpecs.length) children.push(...emitBackgroundImages(bgSpecs, rank, data.length));
42208
43196
  // NOTE: Labels are NOT pushed here. The canonical aggregation point is
42209
43197
  // `emitHelpers.collectComputed(shape)`, which appends `shape.toScene()`
42210
43198
  // AND `shape._labelClass.toScene()` independently. Pushing labels here
@@ -42367,7 +43355,6 @@
42367
43355
  */ constructor(tagName = "g"){
42368
43356
  super();
42369
43357
  installFluent(this, shapeSchema);
42370
- this._backgroundImageClass = new Image$1();
42371
43358
  this._data = [];
42372
43359
  this._labelClass = new TextBox();
42373
43360
  this._name = "Shape";
@@ -42456,7 +43443,7 @@
42456
43443
  const cx = Number(d.x);
42457
43444
  const cy = Number(d.y);
42458
43445
  const userCurve = String(this.schema.curve.bind(this)(this.config()));
42459
- const curve = d3Shape[`curve${userCurve.charAt(0).toUpperCase()}${userCurve.slice(1)}`];
43446
+ const curve = paths[`curve${userCurve.charAt(0).toUpperCase()}${userCurve.slice(1)}`];
42460
43447
  const offX = (fn)=>(v, z)=>fn(v, z) - cx;
42461
43448
  const offY = (fn)=>(v, z)=>fn(v, z) - cy;
42462
43449
  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));
@@ -42795,11 +43782,19 @@
42795
43782
  super("circle");
42796
43783
  installFluent(this, circleSchema);
42797
43784
  this._name = "Circle";
43785
+ // Bound the label to the full circle (diameter box) and tag it
43786
+ // `shape: "circle"`, so the label TextBox flows text as circle chords —
43787
+ // lines fill the interior, shorter near the top and bottom and full width
43788
+ // through the middle — rather than being capped to a square inscribed in
43789
+ // the circle. The `shape` hint rides on the bounds (not `labelConfig`) so a
43790
+ // chart that repositions the label with its own `labelBounds` (e.g. Tree's
43791
+ // external node labels) gets ordinary rectangular wrapping.
42798
43792
  this.schema.labelBounds = (_d, _i, s)=>({
42799
- width: s.r * 1.5,
42800
- height: s.r * 1.5,
42801
- x: -s.r * 0.75,
42802
- y: -s.r * 0.75
43793
+ width: s.r * 2,
43794
+ height: s.r * 2,
43795
+ x: -s.r,
43796
+ y: -s.r,
43797
+ shape: "circle"
42803
43798
  });
42804
43799
  this.schema.labelConfig = assign(this.schema.labelConfig, {
42805
43800
  textAnchor: "middle",
@@ -42957,7 +43952,7 @@
42957
43952
  const cx = Number(d.x);
42958
43953
  const cy = Number(d.y);
42959
43954
  const userCurve = String(this.schema.curve.bind(this)(this.config()));
42960
- const curve = d3Shape[`curve${userCurve.charAt(0).toUpperCase()}${userCurve.slice(1)}`];
43955
+ const curve = paths[`curve${userCurve.charAt(0).toUpperCase()}${userCurve.slice(1)}`];
42961
43956
  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);
42962
43957
  return {
42963
43958
  type: "path",
@@ -43487,6 +44482,152 @@
43487
44482
  }
43488
44483
  }
43489
44484
 
44485
+ /** Image's fluent accessor schema. Config storage lives on `this.schema.<key>`. */ const imageSchema = [
44486
+ {
44487
+ key: "duration",
44488
+ coerce: "identity",
44489
+ default: 600
44490
+ },
44491
+ {
44492
+ key: "height",
44493
+ coerce: "accessor",
44494
+ default: accessor("height")
44495
+ },
44496
+ {
44497
+ key: "id",
44498
+ coerce: "identity",
44499
+ default: accessor("id")
44500
+ },
44501
+ {
44502
+ key: "opacity",
44503
+ coerce: "const",
44504
+ default: constant$b(1)
44505
+ },
44506
+ {
44507
+ key: "pointerEvents",
44508
+ coerce: "const",
44509
+ default: constant$b("auto")
44510
+ },
44511
+ {
44512
+ key: "renderMode",
44513
+ coerce: "identity",
44514
+ default: "full"
44515
+ },
44516
+ {
44517
+ key: "url",
44518
+ coerce: "identity",
44519
+ default: accessor("url")
44520
+ },
44521
+ {
44522
+ key: "width",
44523
+ coerce: "accessor",
44524
+ default: accessor("width")
44525
+ },
44526
+ {
44527
+ key: "x",
44528
+ coerce: "const",
44529
+ default: accessor("x", 0)
44530
+ },
44531
+ {
44532
+ key: "y",
44533
+ coerce: "const",
44534
+ default: accessor("y", 0)
44535
+ }
44536
+ ];
44537
+ let Image$1 = class Image {
44538
+ config(_) {
44539
+ if (!arguments.length) return {
44540
+ ...this.schema,
44541
+ data: this._data,
44542
+ select: this._select
44543
+ };
44544
+ const patch = _;
44545
+ for(const k in patch){
44546
+ if (!Object.prototype.hasOwnProperty.call(patch, k)) continue;
44547
+ // `this[k]` resolves the fluent accessor via the index signature.
44548
+ if (typeof this[k] === "function") this[k](patch[k]);
44549
+ else this.schema[k] = patch[k];
44550
+ }
44551
+ return this;
44552
+ }
44553
+ /**
44554
+ Renders the current Image to the page. If a *callback* is specified, it will be called once the images are done drawing.
44555
+ @param callback Optional callback invoked after rendering completes.
44556
+ */ render(callback) {
44557
+ // Compute mode is a no-op for DOM emission — the caller will read
44558
+ // `toScene()` to get a SceneNode tree, no need to mount.
44559
+ if (this.schema.renderMode === "compute") {
44560
+ if (callback) setTimeout(callback, 0);
44561
+ return this;
44562
+ }
44563
+ 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());
44564
+ const images = this._select.selectAll(".d3plus-Image").data(this._data, this.schema.id);
44565
+ 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);
44566
+ const t = transition().duration(this.schema.duration), that = this, update = enter.merge(images);
44567
+ 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) {
44568
+ const image = select(this), link = that.schema.url(d, i);
44569
+ const fullAddress = link.indexOf("http://") === 0 || link.indexOf("https://") === 0;
44570
+ if (!fullAddress || link.indexOf(window.location.hostname) === 0) {
44571
+ const img = new window.Image();
44572
+ img.src = link;
44573
+ img.crossOrigin = "Anonymous";
44574
+ img.onload = function() {
44575
+ const canvas = document.createElement("canvas");
44576
+ canvas.width = img.width;
44577
+ canvas.height = img.height;
44578
+ const context = canvas.getContext("2d");
44579
+ context.drawImage(img, 0, 0);
44580
+ image.attr("xlink:href", canvas.toDataURL("image/png"));
44581
+ };
44582
+ }
44583
+ });
44584
+ 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();
44585
+ if (callback) setTimeout(callback, this.schema.duration + 100);
44586
+ return this;
44587
+ }
44588
+ data(_) {
44589
+ return arguments.length ? (this._data = _, this) : this._data;
44590
+ }
44591
+ /**
44592
+ Compute-mode scene emission. Mirrors Shape.toScene's shape — a
44593
+ keyed GroupNode wrapping per-datum ImageNodes. Used by chart
44594
+ compositors (e.g. plotPaint) that need Image to participate in the
44595
+ scene graph rather than emit d3-selection DOM.
44596
+ */ toScene() {
44597
+ const children = (this._data || []).map((d, i)=>{
44598
+ const node = {
44599
+ type: "image",
44600
+ key: `${this.schema.id(d, i)}`,
44601
+ x: this.schema.x(d, i),
44602
+ y: this.schema.y(d, i),
44603
+ width: this.schema.width(d, i),
44604
+ height: this.schema.height(d, i),
44605
+ href: this.schema.url(d, i),
44606
+ paint: {
44607
+ opacity: this.schema.opacity(d, i)
44608
+ },
44609
+ datum: d,
44610
+ index: i
44611
+ };
44612
+ return node;
44613
+ });
44614
+ return {
44615
+ type: "group",
44616
+ key: "d3plus-Image",
44617
+ children
44618
+ };
44619
+ }
44620
+ select(_) {
44621
+ return arguments.length ? (this._select = select(_), this) : this._select;
44622
+ }
44623
+ /**
44624
+ Invoked when creating a new class instance, and sets any default parameters.
44625
+ @private
44626
+ */ constructor(){
44627
+ installFluent(this, imageSchema);
44628
+ }
44629
+ };
44630
+
43490
44631
  /** Path's own fluent accessor schema, layered on top of Shape's. */ const pathSchema = [
43491
44632
  {
43492
44633
  key: "d",
@@ -45902,9 +47043,11 @@
45902
47043
  }
45903
47044
  return lineRuns;
45904
47045
  }
45905
- /** Pre-scales the font size to fit the box area before wrapping (resize mode). */ function resizeFontSize(fS, w, h, lH, words, style) {
47046
+ /** Pre-scales the font size to fit the box area before wrapping (resize mode). */ function resizeFontSize(fS, w, h, lH, words, style, shape) {
45906
47047
  const sizes = d3plusTextWidth(words, style);
45907
- const areaMod = 1.165 + w / h * 0.1, boxArea = w * h, maxWidth = max$5(sizes), textArea = sum$2(sizes, (d)=>d * lH) * areaMod;
47048
+ const areaMod = 1.165 + w / h * 0.1, // A circle fills only ~π/4 of its bounding box, so scale the usable area
47049
+ // down to keep the initial font-size guess from overshooting.
47050
+ boxArea = w * h * (shape === "circle" ? Math.PI / 4 : 1), maxWidth = max$5(sizes), textArea = sum$2(sizes, (d)=>d * lH) * areaMod;
45908
47051
  if (maxWidth > w || textArea > boxArea) {
45909
47052
  const areaRatio = Math.sqrt(boxArea / textArea), widthRatio = w / maxWidth;
45910
47053
  const sizeRatio = min$5([
@@ -45974,8 +47117,8 @@
45974
47117
  "line-height": lH
45975
47118
  };
45976
47119
  const padding = parseSides(box.schema.padding(d, i));
45977
- const h = box.schema.height(d, i) - (padding.top + padding.bottom), w = box.schema.width(d, i) - (padding.left + padding.right);
45978
- const wrapper = textWrap().fontFamily(style["font-family"]).fontSize(fS).fontWeight(style["font-weight"]).lineHeight(lH).maxLines(box.schema.maxLines(d, i)).height(h).overflow(box.schema.overflow(d, i)).width(w).split(box.schema.split);
47120
+ const h = box.schema.height(d, i) - (padding.top + padding.bottom), w = box.schema.width(d, i) - (padding.left + padding.right), shape = box.schema.shape(d, i);
47121
+ const wrapper = textWrap().fontFamily(style["font-family"]).fontSize(fS).fontWeight(style["font-weight"]).lineHeight(lH).maxLines(box.schema.maxLines(d, i)).height(h).overflow(box.schema.overflow(d, i)).shape(shape).width(w).split(box.schema.split);
45979
47122
  const fMax = box.schema.fontMax(d, i), fMin = box.schema.fontMin(d, i), vA = box.schema.verticalAlign(d, i), words = box.schema.split(t, i);
45980
47123
  /**
45981
47124
  Figures out the lineData to be used for wrapping.
@@ -46017,7 +47160,7 @@
46017
47160
  }
46018
47161
  }
46019
47162
  if (w > fMin && (h > lH || resize && h > fMin * lHRatio)) {
46020
- if (resize) fS = resizeFontSize(fS, w, h, lH, words, style);
47163
+ if (resize) fS = resizeFontSize(fS, w, h, lH, words, style, shape);
46021
47164
  checkSize();
46022
47165
  }
46023
47166
  if (!lineData.length) return null;
@@ -46157,6 +47300,17 @@
46157
47300
  d.h / 2
46158
47301
  ]
46159
47302
  },
47303
+ // Bounding shape for wrapping: "square" (default) fills the full width on
47304
+ // every line; "circle" treats width/height as the diameter and shortens
47305
+ // lines near the top and bottom to keep text inside the circle. Defaults to
47306
+ // the label record's namespaced `__d3plusWrapShape__` (stamped from a shape's
47307
+ // `labelBounds`) so Circle labels wrap to the circle without callers
47308
+ // configuring anything, while a caller's own `shape` data field is ignored.
47309
+ {
47310
+ key: "shape",
47311
+ coerce: "const",
47312
+ default: (d)=>d.__d3plusWrapShape__ ?? "square"
47313
+ },
46160
47314
  {
46161
47315
  key: "split",
46162
47316
  coerce: "identity",
@@ -48836,7 +49990,7 @@
48836
49990
  ];
48837
49991
  return id;
48838
49992
  })).length;
48839
- const inverted = this.schema.legendFilterInvert.bind(this)();
49993
+ const inverted = this.schema.legendFilterInvert.bind(this)(this);
48840
49994
  if (inverted) {
48841
49995
  if (event.shiftKey) {
48842
49996
  if (hiddenIndex < 0 && !this._solo.length) {
@@ -48994,7 +50148,7 @@
48994
50148
  const hasDeeperLevel = this._drawDepth < this.schema.groupBy.length - 1;
48995
50149
  // only show the hand cursor when the shape has a click event
48996
50150
  this._select.style("cursor", hasUserClick || hasDefaultClick && hasDeeperLevel ? "pointer" : "auto");
48997
- const invertedBehavior = this.schema.legendFilterInvert.bind(this)();
50151
+ const invertedBehavior = this.schema.legendFilterInvert.bind(this)(this);
48998
50152
  const solo = this._solo.includes(id);
48999
50153
  const hidden = this._hidden.includes(id);
49000
50154
  this._tooltipClass.data([
@@ -51255,8 +52409,10 @@
51255
52409
  data.sort((a, b)=>a[viz.schema.discrete] - b[viz.schema.discrete]);
51256
52410
  }
51257
52411
  const order = viz._stackOrder;
52412
+ // An explicit key array orders `stackKeys` directly (then d3-stack keeps
52413
+ // that order via `stackOrderNone`); every other order is a comparator that
52414
+ // reranks the series d3-stack builds, so `stackKeys` is left in input order.
51258
52415
  if (Array.isArray(order)) stackKeys.sort((a, b)=>order.indexOf(a) - order.indexOf(b));
51259
- else if (order === none) stackKeys.sort((a, b)=>`${a}`.localeCompare(`${b}`));
51260
52416
  // d3-stack's generics don't model d3plus's dynamically-keyed rows; the
51261
52417
  // order/offset/value accessors are cast (`as never`) at the boundary, and
51262
52418
  // the configured stack is invoked as a `Row[][] -> number[][][]` function.
@@ -52798,6 +53954,13 @@
52798
53954
  };
52799
53955
  }
52800
53956
 
53957
+ /** Marks a comparator as an already-resolved d3plus stack order. */ function tagOrder(fn) {
53958
+ fn.__d3plusStackOrder = true;
53959
+ return fn;
53960
+ }
53961
+ // @types/d3-shape types the order accessors' param as a single `Series`,
53962
+ // though d3 passes the full stack array; this cast satisfies the signature.
53963
+ const asStack = (series)=>series;
52801
53964
  /**
52802
53965
  Sums a single stack series, ignoring non-numeric segments.
52803
53966
  */ function stackSum(series) {
@@ -52807,18 +53970,80 @@
52807
53970
  return s;
52808
53971
  }
52809
53972
  /**
52810
- Stack order: ascending by series key, tie-broken by summed value.
52811
- */ function stackOrderAscending(series) {
53973
+ Stack order: series with the smallest summed value on the bottom of the
53974
+ stack (matches d3's `stackOrderAscending`).
53975
+ */ const stackOrderTotalAscending = tagOrder((series)=>ascending(asStack(series)));
53976
+ /**
53977
+ Stack order: series with the largest summed value on the bottom of the
53978
+ stack (matches d3's `stackOrderDescending`). Plot's default.
53979
+ */ const stackOrderTotalDescending = tagOrder((series)=>descending(asStack(series)));
53980
+ /**
53981
+ Stack order: ascending by series key (A→Z from the bottom), tie-broken by
53982
+ ascending summed value.
53983
+ */ const stackOrderKey = tagOrder((series)=>{
52812
53984
  const sums = series.map(stackSum);
52813
53985
  const keys = series.map((d)=>d.key.split("_")[0]);
52814
- // @types/d3-shape types the order accessors' param as a single `Series`,
52815
- // though d3 passes the full stack array; cast to satisfy the signature.
52816
- return none(series).sort((a, b)=>keys[b].localeCompare(keys[a]) || sums[a] - sums[b]);
53986
+ return none(asStack(series)).sort((a, b)=>keys[a].localeCompare(keys[b]) || sums[a] - sums[b]);
53987
+ });
53988
+ /**
53989
+ Stack order: the reverse of {@link stackOrderKey} (Z→A from the bottom).
53990
+ */ const stackOrderKeyReverse = tagOrder((series)=>stackOrderKey(series).reverse());
53991
+ /**
53992
+ Builds a stack order that ranks each series by an aggregate (sum) of a
53993
+ data field, letting users order stacks by any value in their data rather
53994
+ than only the plotted one. `value` receives each series' original datum.
53995
+ */ function stackOrderField(value, order = "descending") {
53996
+ return tagOrder((series)=>{
53997
+ const totals = series.map((s)=>{
53998
+ let total = 0;
53999
+ for(let i = 0; i < s.length; i++){
54000
+ // Each stacked point carries `.data` = the discrete group's rows;
54001
+ // pick the row for this series and read the field off its datum.
54002
+ const group = s[i].data || [];
54003
+ const row = group.find((g)=>g.id === s.key);
54004
+ if (row && row.data) {
54005
+ const v = +value(row.data);
54006
+ if (!isNaN(v)) total += v;
54007
+ }
54008
+ }
54009
+ return total;
54010
+ });
54011
+ return none(asStack(series)).sort((a, b)=>order === "ascending" ? totals[a] - totals[b] : totals[b] - totals[a]);
54012
+ });
52817
54013
  }
54014
+ /** Named stack orders accepted by `Plot.stackOrder`. */ const NAMED_ORDERS = {
54015
+ ascending: stackOrderTotalAscending,
54016
+ descending: stackOrderTotalDescending,
54017
+ key: stackOrderKey,
54018
+ keyReverse: stackOrderKeyReverse,
54019
+ none: tagOrder((series)=>none(asStack(series))),
54020
+ data: tagOrder((series)=>none(asStack(series))),
54021
+ insideOut: tagOrder((series)=>insideOut(asStack(series))),
54022
+ appearance: tagOrder((series)=>appearance(asStack(series))),
54023
+ reverse: tagOrder((series)=>reverse$1(asStack(series)))
54024
+ };
54025
+ /** The named orders accepted by `Plot.stackOrder`, for docs/validation. */ const stackOrderNames = Object.keys(NAMED_ORDERS);
52818
54026
  /**
52819
- Stack order: the reverse of {@link stackOrderAscending}.
52820
- */ function stackOrderDescending(series) {
52821
- return stackOrderAscending(series).reverse();
54027
+ Normalizes any `stackOrder` input into a value Plot's pipeline can apply:
54028
+ a tagged comparator, or an explicit array of series keys. Warns and falls
54029
+ back to the default on an unrecognized name.
54030
+ */ function resolveStackOrder(input) {
54031
+ if (typeof input === "function") {
54032
+ // Already-resolved order (constructor default / config() reset) passes
54033
+ // through; a bare user function is treated as a value accessor.
54034
+ return input.__d3plusStackOrder ? input : stackOrderField(input);
54035
+ }
54036
+ if (Array.isArray(input)) return input;
54037
+ if (input && typeof input === "object") {
54038
+ const { value, order } = input;
54039
+ return stackOrderField(typeof value === "function" ? value : accessor(value), order);
54040
+ }
54041
+ if (typeof input === "string") {
54042
+ if (input in NAMED_ORDERS) return NAMED_ORDERS[input];
54043
+ 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".`);
54044
+ return stackOrderTotalDescending;
54045
+ }
54046
+ return stackOrderTotalDescending;
52822
54047
  }
52823
54048
  /**
52824
54049
  Diverging stack offset: positive segments stack upward from zero,
@@ -52840,6 +54065,23 @@
52840
54065
  }
52841
54066
  }
52842
54067
  }
54068
+ /** Named stack offsets accepted by `Plot.stackOffset`. */ const NAMED_OFFSETS = {
54069
+ diverging: stackOffsetDiverging,
54070
+ none: none$1,
54071
+ expand: expand,
54072
+ silhouette: silhouette,
54073
+ wiggle: wiggle
54074
+ };
54075
+ /** The named offsets accepted by `Plot.stackOffset`, for docs/validation. */ const stackOffsetNames = Object.keys(NAMED_OFFSETS);
54076
+ /**
54077
+ Normalizes a `stackOffset` input into an offset function. Warns and falls
54078
+ back to the diverging default on an unrecognized name.
54079
+ */ function resolveStackOffset(input) {
54080
+ if (typeof input === "function") return input;
54081
+ if (typeof input === "string" && input in NAMED_OFFSETS) return NAMED_OFFSETS[input];
54082
+ console.warn(`[d3plus] Unknown stackOffset "${input}". Expected one of: ${stackOffsetNames.join(", ")}; or an offset function. Falling back to "diverging".`);
54083
+ return stackOffsetDiverging;
54084
+ }
52843
54085
 
52844
54086
  /**
52845
54087
  Clone the base shape config and, for stacked Area/Bar, inject the
@@ -53579,6 +54821,7 @@
53579
54821
  ];
53580
54822
  }
53581
54823
 
54824
+ /* eslint no-cond-assign: 0*/ // @ts-ignore
53582
54825
  const { theme: openColor } = pkg;
53583
54826
  // E4: Plot's identity-coerce accessor schema (18 keys). installFluent's
53584
54827
  // per-key idempotence lets this co-exist with vizSchema on the parent
@@ -53877,18 +55120,29 @@
53877
55120
  return arguments.length ? (this._size = typeof _ === "function" || !_ ? _ : accessor(_), this) : this._size;
53878
55121
  }
53879
55122
  /**
53880
- Sets the stack offset. If *value* is not specified, returns the current stack offset function.
55123
+ Sets the vertical offset applied to stacked series. Accepts a named
55124
+ offset — `"diverging"` (default), `"none"`, `"expand"`, `"silhouette"`,
55125
+ or `"wiggle"` — or a custom offset function. Unknown names warn and fall
55126
+ back to `"diverging"`. If *value* is not specified, returns the current
55127
+ stack offset function.
53881
55128
  */ stackOffset(_) {
53882
- return arguments.length ? (this._stackOffset = typeof _ === "function" ? _ : d3Shape[`stackOffset${_.charAt(0).toUpperCase() + _.slice(1)}`], this) : this._stackOffset;
55129
+ return arguments.length ? (this._stackOffset = resolveStackOffset(_), this) : this._stackOffset;
53883
55130
  }
53884
55131
  /**
53885
- Sets the stack order. If *value* is not specified, returns the current stack order function.
55132
+ Sets the order of stacked series, from the bottom of the stack upward.
55133
+ Accepts:
55134
+ - a named order: `"descending"` (default) / `"ascending"` by summed
55135
+ value, `"key"` / `"keyReverse"` alphabetically by series key,
55136
+ `"none"` / `"data"` for input order, or d3's `"insideOut"`,
55137
+ `"appearance"`, `"reverse"`;
55138
+ - an Array of series keys for an explicit order;
55139
+ - a value accessor, or a `{value, order}` config, to rank series by an
55140
+ aggregate of any data field.
55141
+
55142
+ Unknown named strings warn and fall back to `"descending"`. If *value*
55143
+ is not specified, returns the current stack order.
53886
55144
  */ stackOrder(_) {
53887
- if (arguments.length) {
53888
- if (typeof _ === "string") this._stackOrder = _ === "ascending" ? stackOrderAscending : _ === "descending" ? stackOrderDescending : d3Shape[`stackOrder${_.charAt(0).toUpperCase() + _.slice(1)}`];
53889
- else this._stackOrder = _;
53890
- return this;
53891
- } else return this._stackOrder;
55145
+ return arguments.length ? (this._stackOrder = resolveStackOrder(_), this) : this._stackOrder;
53892
55146
  }
53893
55147
  /**
53894
55148
  Accessor function or string key for the x-axis value of each data point.
@@ -54033,7 +55287,7 @@
54033
55287
  this.schema.sizeMin = 5;
54034
55288
  this.schema.sizeScale = "sqrt";
54035
55289
  this._stackOffset = stackOffsetDiverging;
54036
- this._stackOrder = stackOrderDescending;
55290
+ this._stackOrder = stackOrderTotalDescending;
54037
55291
  this.schema.timelineConfig = assign(this.schema.timelineConfig, {
54038
55292
  brushMin: ()=>this._xTime || this._yTime || this._x2Time || this._y2Time ? 2 : 1
54039
55293
  });
@@ -54109,7 +55363,8 @@
54109
55363
  },
54110
55364
  {
54111
55365
  key: "shape",
54112
- default: constant$b("Area")
55366
+ default: constant$b("Area"),
55367
+ coerce: "const"
54113
55368
  }
54114
55369
  ]
54115
55370
  };
@@ -54138,10 +55393,12 @@
54138
55393
  },
54139
55394
  {
54140
55395
  key: "shape",
54141
- default: constant$b("Bar")
55396
+ default: constant$b("Bar"),
55397
+ coerce: "const"
54142
55398
  },
54143
55399
  {
54144
55400
  key: "legend",
55401
+ coerce: "const",
54145
55402
  factory: (viz)=>{
54146
55403
  const base = viz.schema.legend;
54147
55404
  return (config, arr)=>{
@@ -54175,7 +55432,8 @@
54175
55432
  },
54176
55433
  {
54177
55434
  key: "shape",
54178
- default: constant$b("Box")
55435
+ default: constant$b("Box"),
55436
+ coerce: "const"
54179
55437
  },
54180
55438
  {
54181
55439
  key: "tooltipConfig",
@@ -54241,7 +55499,8 @@
54241
55499
  },
54242
55500
  {
54243
55501
  key: "shape",
54244
- default: constant$b("Line")
55502
+ default: constant$b("Line"),
55503
+ coerce: "const"
54245
55504
  }
54246
55505
  ]
54247
55506
  };
@@ -54476,6 +55735,7 @@
54476
55735
  },
54477
55736
  {
54478
55737
  key: "legend",
55738
+ coerce: "const",
54479
55739
  factory: (viz)=>{
54480
55740
  const base = viz.schema.legend;
54481
55741
  return (config, arr)=>{
@@ -67717,7 +68977,8 @@
67717
68977
  },
67718
68978
  {
67719
68979
  key: "shape",
67720
- default: constant$b("Circle")
68980
+ default: constant$b("Circle"),
68981
+ coerce: "const"
67721
68982
  },
67722
68983
  {
67723
68984
  key: "topojson",
@@ -67815,7 +69076,8 @@
67815
69076
  },
67816
69077
  {
67817
69078
  key: "shape",
67818
- default: constant$b("Line")
69079
+ default: constant$b("Line"),
69080
+ coerce: "const"
67819
69081
  }
67820
69082
  ]
67821
69083
  };
@@ -68079,6 +69341,7 @@
68079
69341
  },
68080
69342
  {
68081
69343
  key: "label",
69344
+ coerce: "const",
68082
69345
  factory: (viz)=>(d, i)=>`${getProp.bind(viz)("row", d, i)} / ${getProp.bind(viz)("column", d, i)}`
68083
69346
  }
68084
69347
  ]
@@ -69393,7 +70656,8 @@
69393
70656
  },
69394
70657
  {
69395
70658
  key: "shape",
69396
- default: constant$b("Circle")
70659
+ default: constant$b("Circle"),
70660
+ coerce: "const"
69397
70661
  },
69398
70662
  {
69399
70663
  key: "shapeConfig",
@@ -70521,6 +71785,7 @@
70521
71785
  },
70522
71786
  {
70523
71787
  key: "legend",
71788
+ coerce: "const",
70524
71789
  factory: (viz)=>{
70525
71790
  const base = viz.schema.legend;
70526
71791
  return (config, arr)=>{
@@ -71080,7 +72345,8 @@
71080
72345
  },
71081
72346
  {
71082
72347
  key: "shape",
71083
- default: constant$b("Path")
72348
+ default: constant$b("Path"),
72349
+ coerce: "const"
71084
72350
  },
71085
72351
  {
71086
72352
  key: "value",
@@ -71324,6 +72590,7 @@
71324
72590
  },
71325
72591
  {
71326
72592
  key: "label",
72593
+ coerce: "const",
71327
72594
  factory: (viz)=>(d, i)=>`${getProp.bind(viz)("row", d, i)} / ${getProp.bind(viz)("column", d, i)}`
71328
72595
  }
71329
72596
  ]
@@ -72042,7 +73309,8 @@
72042
73309
  },
72043
73310
  {
72044
73311
  key: "shape",
72045
- default: constant$b("Circle")
73312
+ default: constant$b("Circle"),
73313
+ coerce: "const"
72046
73314
  },
72047
73315
  {
72048
73316
  key: "shapeConfig",
@@ -72936,7 +74204,8 @@
72936
74204
  },
72937
74205
  {
72938
74206
  key: "shape",
72939
- default: constant$b("Rect")
74207
+ default: constant$b("Rect"),
74208
+ coerce: "const"
72940
74209
  },
72941
74210
  {
72942
74211
  key: "shapeConfig",
@@ -73320,7 +74589,8 @@
73320
74589
  },
73321
74590
  {
73322
74591
  key: "shape",
73323
- default: constant$b("Circle")
74592
+ default: constant$b("Circle"),
74593
+ coerce: "const"
73324
74594
  },
73325
74595
  {
73326
74596
  key: "shapeConfig",
@@ -73694,6 +74964,7 @@
73694
74964
  },
73695
74965
  {
73696
74966
  key: "legend",
74967
+ coerce: "const",
73697
74968
  factory: (viz)=>{
73698
74969
  const base = viz.schema.legend;
73699
74970
  return (config, arr)=>{