@d3plus/core 4.6.0 → 4.7.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 (172) hide show
  1. package/README.md +728 -1454
  2. package/es/index.js.map +1 -1
  3. package/es/internal.js +5 -0
  4. package/es/internal.js.map +1 -1
  5. package/es/src/charts/Chord/index.js +2 -0
  6. package/es/src/charts/Chord/index.js.map +1 -1
  7. package/es/src/charts/Geomap/applyLayout.js +3 -1
  8. package/es/src/charts/Geomap/applyLayout.js.map +1 -1
  9. package/es/src/charts/Geomap/index.js +3 -1
  10. package/es/src/charts/Geomap/index.js.map +1 -1
  11. package/es/src/charts/Matrix/emit.js +5 -4
  12. package/es/src/charts/Matrix/emit.js.map +1 -1
  13. package/es/src/charts/Network/index.js +4 -0
  14. package/es/src/charts/Network/index.js.map +1 -1
  15. package/es/src/charts/Pack/emit.js +6 -6
  16. package/es/src/charts/Pack/emit.js.map +1 -1
  17. package/es/src/charts/Pack/index.js +2 -0
  18. package/es/src/charts/Pack/index.js.map +1 -1
  19. package/es/src/charts/Pie/emit.js +5 -6
  20. package/es/src/charts/Pie/emit.js.map +1 -1
  21. package/es/src/charts/Pie/index.js +2 -0
  22. package/es/src/charts/Pie/index.js.map +1 -1
  23. package/es/src/charts/Plot/index.js +15 -1
  24. package/es/src/charts/Plot/index.js.map +1 -1
  25. package/es/src/charts/Plot/insetRegion.js +21 -0
  26. package/es/src/charts/Plot/insetRegion.js.map +1 -0
  27. package/es/src/charts/Plot/sharedHover.js +117 -16
  28. package/es/src/charts/Plot/sharedHover.js.map +1 -1
  29. package/es/src/charts/Plot/sharedTooltip.js +35 -15
  30. package/es/src/charts/Plot/sharedTooltip.js.map +1 -1
  31. package/es/src/charts/Plot/trendLines.js +140 -38
  32. package/es/src/charts/Plot/trendLines.js.map +1 -1
  33. package/es/src/charts/Plot/trendProjection.js +120 -0
  34. package/es/src/charts/Plot/trendProjection.js.map +1 -0
  35. package/es/src/charts/Plot/trendScene.js +33 -19
  36. package/es/src/charts/Plot/trendScene.js.map +1 -1
  37. package/es/src/charts/Plot/trendTooltip.js +79 -17
  38. package/es/src/charts/Plot/trendTooltip.js.map +1 -1
  39. package/es/src/charts/Priestley/emit.js +3 -4
  40. package/es/src/charts/Priestley/emit.js.map +1 -1
  41. package/es/src/charts/RadialMatrix/emit.js +4 -4
  42. package/es/src/charts/RadialMatrix/emit.js.map +1 -1
  43. package/es/src/charts/Rings/index.js +5 -1
  44. package/es/src/charts/Rings/index.js.map +1 -1
  45. package/es/src/charts/Sankey/index.js +2 -0
  46. package/es/src/charts/Sankey/index.js.map +1 -1
  47. package/es/src/charts/Tree/index.js +2 -0
  48. package/es/src/charts/Tree/index.js.map +1 -1
  49. package/es/src/charts/Treemap/emit.js +3 -4
  50. package/es/src/charts/Treemap/emit.js.map +1 -1
  51. package/es/src/charts/definition/ChartDefinition.js.map +1 -1
  52. package/es/src/charts/definition/makeChart.js +8 -2
  53. package/es/src/charts/definition/makeChart.js.map +1 -1
  54. package/es/src/charts/drawSteps/bottomRightControls.js +3 -0
  55. package/es/src/charts/drawSteps/bottomRightControls.js.map +1 -1
  56. package/es/src/charts/drawSteps/bottomRightControlsMarkup.js +135 -4
  57. package/es/src/charts/drawSteps/bottomRightControlsMarkup.js.map +1 -1
  58. package/es/src/charts/drawSteps/searchControlsMarkup.js +15 -38
  59. package/es/src/charts/drawSteps/searchControlsMarkup.js.map +1 -1
  60. package/es/src/charts/events/click.legend.js +10 -5
  61. package/es/src/charts/events/click.legend.js.map +1 -1
  62. package/es/src/charts/events/mousemove.shape.js +8 -1
  63. package/es/src/charts/events/mousemove.shape.js.map +1 -1
  64. package/es/src/charts/features/emitHelpers.js +19 -5
  65. package/es/src/charts/features/emitHelpers.js.map +1 -1
  66. package/es/src/charts/features/features.js +3 -108
  67. package/es/src/charts/features/features.js.map +1 -1
  68. package/es/src/charts/features/featuresColorScale.js +161 -0
  69. package/es/src/charts/features/featuresColorScale.js.map +1 -0
  70. package/es/src/charts/features/featuresLegend.js +145 -32
  71. package/es/src/charts/features/featuresLegend.js.map +1 -1
  72. package/es/src/charts/features/insetState.js +174 -0
  73. package/es/src/charts/features/insetState.js.map +1 -0
  74. package/es/src/charts/features/sceneBounds.js +271 -0
  75. package/es/src/charts/features/sceneBounds.js.map +1 -0
  76. package/es/src/charts/features/tooltipSwatch.js +73 -0
  77. package/es/src/charts/features/tooltipSwatch.js.map +1 -0
  78. package/es/src/charts/pipeline/insetPlacement.js +406 -0
  79. package/es/src/charts/pipeline/insetPlacement.js.map +1 -0
  80. package/es/src/charts/pipeline/runVizPipeline.js +6 -2
  81. package/es/src/charts/pipeline/runVizPipeline.js.map +1 -1
  82. package/es/src/charts/viz/Viz.js +18 -3
  83. package/es/src/charts/viz/Viz.js.map +1 -1
  84. package/es/src/charts/viz/VizBaseConfig.js +20 -24
  85. package/es/src/charts/viz/VizBaseConfig.js.map +1 -1
  86. package/es/src/charts/viz/interactionOpacity.js +21 -13
  87. package/es/src/charts/viz/interactionOpacity.js.map +1 -1
  88. package/es/src/charts/viz/linkGroup.js +386 -0
  89. package/es/src/charts/viz/linkGroup.js.map +1 -0
  90. package/es/src/charts/viz/sceneRows.js +33 -0
  91. package/es/src/charts/viz/sceneRows.js.map +1 -0
  92. package/es/src/charts/viz/vizDefaults.js +13 -8
  93. package/es/src/charts/viz/vizDefaults.js.map +1 -1
  94. package/es/src/charts/viz/vizTypes.js.map +1 -1
  95. package/es/src/components/Axis/AxisBottom.js +1 -1
  96. package/es/src/components/Axis/AxisBottom.js.map +1 -1
  97. package/es/src/components/Axis/AxisLeft.js +1 -1
  98. package/es/src/components/Axis/AxisLeft.js.map +1 -1
  99. package/es/src/components/Axis/AxisRight.js +1 -1
  100. package/es/src/components/Axis/AxisRight.js.map +1 -1
  101. package/es/src/components/Axis/AxisTop.js +1 -1
  102. package/es/src/components/Axis/AxisTop.js.map +1 -1
  103. package/es/src/components/Axis/axisLayoutLabels.js +13 -1
  104. package/es/src/components/Axis/axisLayoutLabels.js.map +1 -1
  105. package/es/src/components/ColorScale/ColorScale.js.map +1 -1
  106. package/es/src/components/Legend/legendConfig.js +2 -1
  107. package/es/src/components/Legend/legendConfig.js.map +1 -1
  108. package/es/src/components/Legend/legendRender.js +42 -5
  109. package/es/src/components/Legend/legendRender.js.map +1 -1
  110. package/es/src/components/TextBox.js +1 -1
  111. package/es/src/components/TextBox.js.map +1 -1
  112. package/es/src/shapes/Bar.js +1 -1
  113. package/es/src/shapes/Bar.js.map +1 -1
  114. package/es/src/shapes/Box.js +1 -1
  115. package/es/src/shapes/Box.js.map +1 -1
  116. package/es/src/shapes/Rect.js +1 -1
  117. package/es/src/shapes/Rect.js.map +1 -1
  118. package/es/src/shapes/Shape.js +9 -36
  119. package/es/src/shapes/Shape.js.map +1 -1
  120. package/es/src/shapes/Whisker.js +1 -1
  121. package/es/src/shapes/Whisker.js.map +1 -1
  122. package/es/src/shapes/textureKey.js +104 -0
  123. package/es/src/shapes/textureKey.js.map +1 -0
  124. package/es/src/utils/D3plusConfig.js.map +1 -1
  125. package/package.json +10 -9
  126. package/types/index.d.ts +1 -0
  127. package/types/internal.d.ts +7 -0
  128. package/types/src/charts/Plot/index.d.ts +8 -0
  129. package/types/src/charts/Plot/insetRegion.d.ts +4 -0
  130. package/types/src/charts/Plot/sharedHover.d.ts +5 -0
  131. package/types/src/charts/Plot/sharedTooltip.d.ts +10 -0
  132. package/types/src/charts/Plot/trendLines.d.ts +23 -3
  133. package/types/src/charts/Plot/trendProjection.d.ts +28 -0
  134. package/types/src/charts/Plot/trendScene.d.ts +2 -1
  135. package/types/src/charts/Plot/trendTooltip.d.ts +16 -5
  136. package/types/src/charts/definition/ChartDefinition.d.ts +9 -0
  137. package/types/src/charts/definition/makeChart.d.ts +2 -2
  138. package/types/src/charts/drawSteps/bottomRightControlsMarkup.d.ts +2 -0
  139. package/types/src/charts/drawSteps/searchControlsMarkup.d.ts +7 -5
  140. package/types/src/charts/features/emitHelpers.d.ts +10 -4
  141. package/types/src/charts/features/features.d.ts +1 -8
  142. package/types/src/charts/features/featuresColorScale.d.ts +24 -0
  143. package/types/src/charts/features/featuresLegend.d.ts +15 -0
  144. package/types/src/charts/features/insetState.d.ts +95 -0
  145. package/types/src/charts/features/sceneBounds.d.ts +18 -0
  146. package/types/src/charts/features/tooltipSwatch.d.ts +31 -0
  147. package/types/src/charts/pipeline/insetPlacement.d.ts +45 -0
  148. package/types/src/charts/pipeline/runVizPipeline.d.ts +2 -1
  149. package/types/src/charts/viz/Viz.d.ts +9 -1
  150. package/types/src/charts/viz/VizBaseConfig.d.ts +8 -12
  151. package/types/src/charts/viz/linkGroup.d.ts +96 -0
  152. package/types/src/charts/viz/sceneRows.d.ts +13 -0
  153. package/types/src/charts/viz/vizTypes.d.ts +17 -0
  154. package/types/src/components/Axis/AxisBottom.d.ts +1 -1
  155. package/types/src/components/Axis/AxisLeft.d.ts +1 -1
  156. package/types/src/components/Axis/AxisRight.d.ts +1 -1
  157. package/types/src/components/Axis/AxisTop.d.ts +1 -1
  158. package/types/src/components/ColorScale/ColorScale.d.ts +4 -4
  159. package/types/src/components/Legend/legendRender.d.ts +1 -1
  160. package/types/src/components/TextBox.d.ts +1 -1
  161. package/types/src/shapes/Bar.d.ts +1 -1
  162. package/types/src/shapes/Box.d.ts +1 -1
  163. package/types/src/shapes/Rect.d.ts +1 -1
  164. package/types/src/shapes/Whisker.d.ts +1 -1
  165. package/types/src/shapes/textureKey.d.ts +9 -0
  166. package/types/src/utils/D3plusConfig.d.ts +42 -1
  167. package/umd/d3plus-core.full.js +2393 -594
  168. package/umd/d3plus-core.full.js.map +1 -1
  169. package/umd/d3plus-core.full.min.js +1945 -1601
  170. package/umd/d3plus-core.js +1744 -404
  171. package/umd/d3plus-core.js.map +1 -1
  172. package/umd/d3plus-core.min.js +1401 -1087
@@ -1,5 +1,6 @@
1
1
  import { configPrep } from "../../utils/index.js";
2
2
  import clickShape from "./click.shape.js";
3
+ import { nodeColor, tooltipSwatch, withSwatch } from "../features/tooltipSwatch.js";
3
4
  /**
4
5
  @module mouseMoveShape
5
6
  Tooltip logic for a specified data point.
@@ -8,6 +9,7 @@ import clickShape from "./click.shape.js";
8
9
  */ export default function(d, i, x, event) {
9
10
  var _this = this;
10
11
  if (d && this.schema.tooltip(d, i)) {
12
+ var _pick_shapeType;
11
13
  var defaultClick = clickShape.bind(this).toString();
12
14
  // does the shape have any user-defined click events?
13
15
  var hasUserClick = Object.keys(this.schema.on).some(function(e) {
@@ -41,9 +43,14 @@ import clickShape from "./click.shape.js";
41
43
  // wrapper whose `.data` chain leads back to the row).
42
44
  var tooltipDatum = x || d;
43
45
  while(tooltipDatum && tooltipDatum.__d3plus__ && tooltipDatum.data)tooltipDatum = tooltipDatum.data;
46
+ // The title leads with a swatch of the hovered mark, as in the legend.
47
+ var pick = this._lastScenePick;
48
+ var swatch = pick && !pick.isLegend ? tooltipSwatch(nodeColor(this, pick.node), (_pick_shapeType = pick.shapeType) !== null && _pick_shapeType !== void 0 ? _pick_shapeType : undefined) : "";
44
49
  this._tooltipClass.data([
45
50
  tooltipDatum
46
- ]).footer(hasDefaultClick && hasDeeperLevel ? this.schema.translate("Click to Expand") : false).title(this._drawLabel).position(position).config(configPrep.bind(this)(this.schema.tooltipConfig)).render();
51
+ ]).footer(hasDefaultClick && hasDeeperLevel ? this.schema.translate("Click to Expand") : false).title(function(dd, ii) {
52
+ return withSwatch(swatch, _this._drawLabel(dd, ii));
53
+ }).position(position).config(configPrep.bind(this)(this.schema.tooltipConfig)).render();
47
54
  }
48
55
  }
49
56
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/charts/events/mousemove.shape.ts"],"sourcesContent":["import type {DataPoint} from \"@d3plus/data\";\nimport {configPrep} from \"../../utils/index.js\";\nimport type {VizContext} from \"../../utils/configPrep.js\";\nimport clickShape from \"./click.shape.js\";\nimport type Viz from \"../viz/Viz.js\";\n\n/**\n @module mouseMoveShape\n Tooltip logic for a specified data point.\n @param config Optional configuration methods for the Tooltip class.\n @private\n*/\nexport default function (\n this: Viz,\n d: DataPoint,\n i: number,\n x: DataPoint,\n event: MouseEvent & TouchEvent,\n): void {\n if (d && this.schema.tooltip(d, i)) {\n const defaultClick = clickShape.bind(this).toString();\n\n // does the shape have any user-defined click events?\n const hasUserClick = Object.keys(this.schema.on).some(\n (e: string) =>\n // all valid click event keys,\n [\"click\", \"click.shape\"].includes(e) &&\n // truthy values (no nulls),\n this.schema.on[e] &&\n // and it is not our default click.shape function\n this.schema.on[e].toString() !== defaultClick,\n );\n\n // does the shape still have our default \"click.shape\" event?\n // (if the user only sets \"click\", both functions will fire)\n const hasDefaultClick =\n this.schema.on[\"click.shape\"] &&\n this.schema.on[\"click.shape\"].toString() === defaultClick;\n\n // can the viz show deeper data?\n const hasDeeperLevel = this._drawDepth < this.schema.groupBy.length - 1;\n\n // only show the hand cursor when the shape has a click event\n this._select.style(\n \"cursor\",\n hasUserClick || (hasDefaultClick && hasDeeperLevel) ? \"pointer\" : \"auto\",\n );\n\n // Plot's snapped hover (shared or single) owns the tooltip while active.\n if (this._sharedHoverActive) return;\n\n const position = event.touches\n ? [event.touches[0].clientX, event.touches[0].clientY]\n : [event.clientX, event.clientY];\n\n // Unwrap to the underlying source row so tooltip cell accessors (e.g.\n // the Treemap \"share\" column) resolve regardless of whether the hovered\n // scene node was the shape (datum = row) or its text label (datum = a\n // wrapper whose `.data` chain leads back to the row).\n let tooltipDatum = (x || d) as DataPoint & {__d3plus__?: boolean; data?: DataPoint};\n while (tooltipDatum && tooltipDatum.__d3plus__ && tooltipDatum.data)\n tooltipDatum = tooltipDatum.data as typeof tooltipDatum;\n\n this._tooltipClass\n .data([tooltipDatum])\n .footer(\n hasDefaultClick && hasDeeperLevel\n ? this.schema.translate(\"Click to Expand\")\n : false,\n )\n .title(this._drawLabel)\n .position(position)\n .config(configPrep.bind(this as unknown as VizContext)(this.schema.tooltipConfig))\n .render();\n }\n}\n"],"names":["configPrep","clickShape","d","i","x","event","schema","tooltip","defaultClick","bind","toString","hasUserClick","Object","keys","on","some","e","includes","hasDefaultClick","hasDeeperLevel","_drawDepth","groupBy","length","_select","style","_sharedHoverActive","position","touches","clientX","clientY","tooltipDatum","__d3plus__","data","_tooltipClass","footer","translate","title","_drawLabel","config","tooltipConfig","render"],"mappings":"AACA,SAAQA,UAAU,QAAO,uBAAuB;AAEhD,OAAOC,gBAAgB,mBAAmB;AAG1C;;;;;AAKA,GACA,eAAe,SAEbC,CAAY,EACZC,CAAS,EACTC,CAAY,EACZC,KAA8B;;IAE9B,IAAIH,KAAK,IAAI,CAACI,MAAM,CAACC,OAAO,CAACL,GAAGC,IAAI;QAClC,IAAMK,eAAeP,WAAWQ,IAAI,CAAC,IAAI,EAAEC,QAAQ;QAEnD,qDAAqD;QACrD,IAAMC,eAAeC,OAAOC,IAAI,CAAC,IAAI,CAACP,MAAM,CAACQ,EAAE,EAAEC,IAAI,CACnD,SAACC;mBACC,8BAA8B;YAC9B;gBAAC;gBAAS;aAAc,CAACC,QAAQ,CAACD,MAClC,4BAA4B;YAC5B,MAAKV,MAAM,CAACQ,EAAE,CAACE,EAAE,IACjB,iDAAiD;YACjD,MAAKV,MAAM,CAACQ,EAAE,CAACE,EAAE,CAACN,QAAQ,OAAOF;;QAGrC,6DAA6D;QAC7D,4DAA4D;QAC5D,IAAMU,kBACJ,IAAI,CAACZ,MAAM,CAACQ,EAAE,CAAC,cAAc,IAC7B,IAAI,CAACR,MAAM,CAACQ,EAAE,CAAC,cAAc,CAACJ,QAAQ,OAAOF;QAE/C,gCAAgC;QAChC,IAAMW,iBAAiB,IAAI,CAACC,UAAU,GAAG,IAAI,CAACd,MAAM,CAACe,OAAO,CAACC,MAAM,GAAG;QAEtE,6DAA6D;QAC7D,IAAI,CAACC,OAAO,CAACC,KAAK,CAChB,UACAb,gBAAiBO,mBAAmBC,iBAAkB,YAAY;QAGpE,yEAAyE;QACzE,IAAI,IAAI,CAACM,kBAAkB,EAAE;QAE7B,IAAMC,WAAWrB,MAAMsB,OAAO,GAC1B;YAACtB,MAAMsB,OAAO,CAAC,EAAE,CAACC,OAAO;YAAEvB,MAAMsB,OAAO,CAAC,EAAE,CAACE,OAAO;SAAC,GACpD;YAACxB,MAAMuB,OAAO;YAAEvB,MAAMwB,OAAO;SAAC;QAElC,sEAAsE;QACtE,wEAAwE;QACxE,sEAAsE;QACtE,sDAAsD;QACtD,IAAIC,eAAgB1B,KAAKF;QACzB,MAAO4B,gBAAgBA,aAAaC,UAAU,IAAID,aAAaE,IAAI,CACjEF,eAAeA,aAAaE,IAAI;QAElC,IAAI,CAACC,aAAa,CACfD,IAAI,CAAC;YAACF;SAAa,EACnBI,MAAM,CACLhB,mBAAmBC,iBACf,IAAI,CAACb,MAAM,CAAC6B,SAAS,CAAC,qBACtB,OAELC,KAAK,CAAC,IAAI,CAACC,UAAU,EACrBX,QAAQ,CAACA,UACTY,MAAM,CAACtC,WAAWS,IAAI,CAAC,IAAI,EAA2B,IAAI,CAACH,MAAM,CAACiC,aAAa,GAC/EC,MAAM;IACX;AACF"}
1
+ {"version":3,"sources":["../../../../src/charts/events/mousemove.shape.ts"],"sourcesContent":["import type {DataPoint} from \"@d3plus/data\";\nimport {configPrep} from \"../../utils/index.js\";\nimport type {VizContext} from \"../../utils/configPrep.js\";\nimport clickShape from \"./click.shape.js\";\nimport {nodeColor, tooltipSwatch, withSwatch} from \"../features/tooltipSwatch.js\";\nimport type Viz from \"../viz/Viz.js\";\nimport type {VizInstance} from \"../viz/vizTypes.js\";\n\n/**\n @module mouseMoveShape\n Tooltip logic for a specified data point.\n @param config Optional configuration methods for the Tooltip class.\n @private\n*/\nexport default function (\n this: Viz,\n d: DataPoint,\n i: number,\n x: DataPoint,\n event: MouseEvent & TouchEvent,\n): void {\n if (d && this.schema.tooltip(d, i)) {\n const defaultClick = clickShape.bind(this).toString();\n\n // does the shape have any user-defined click events?\n const hasUserClick = Object.keys(this.schema.on).some(\n (e: string) =>\n // all valid click event keys,\n [\"click\", \"click.shape\"].includes(e) &&\n // truthy values (no nulls),\n this.schema.on[e] &&\n // and it is not our default click.shape function\n this.schema.on[e].toString() !== defaultClick,\n );\n\n // does the shape still have our default \"click.shape\" event?\n // (if the user only sets \"click\", both functions will fire)\n const hasDefaultClick =\n this.schema.on[\"click.shape\"] &&\n this.schema.on[\"click.shape\"].toString() === defaultClick;\n\n // can the viz show deeper data?\n const hasDeeperLevel = this._drawDepth < this.schema.groupBy.length - 1;\n\n // only show the hand cursor when the shape has a click event\n this._select.style(\n \"cursor\",\n hasUserClick || (hasDefaultClick && hasDeeperLevel) ? \"pointer\" : \"auto\",\n );\n\n // Plot's snapped hover (shared or single) owns the tooltip while active.\n if (this._sharedHoverActive) return;\n\n const position = event.touches\n ? [event.touches[0].clientX, event.touches[0].clientY]\n : [event.clientX, event.clientY];\n\n // Unwrap to the underlying source row so tooltip cell accessors (e.g.\n // the Treemap \"share\" column) resolve regardless of whether the hovered\n // scene node was the shape (datum = row) or its text label (datum = a\n // wrapper whose `.data` chain leads back to the row).\n let tooltipDatum = (x || d) as DataPoint & {__d3plus__?: boolean; data?: DataPoint};\n while (tooltipDatum && tooltipDatum.__d3plus__ && tooltipDatum.data)\n tooltipDatum = tooltipDatum.data as typeof tooltipDatum;\n\n // The title leads with a swatch of the hovered mark, as in the legend.\n const pick = this._lastScenePick;\n const swatch = pick && !pick.isLegend\n ? tooltipSwatch(nodeColor(this as unknown as VizInstance, pick.node), pick.shapeType ?? undefined)\n : \"\";\n\n this._tooltipClass\n .data([tooltipDatum])\n .footer(\n hasDefaultClick && hasDeeperLevel\n ? this.schema.translate(\"Click to Expand\")\n : false,\n )\n .title((dd: DataPoint, ii: number) => withSwatch(swatch, this._drawLabel(dd, ii)))\n .position(position)\n .config(configPrep.bind(this as unknown as VizContext)(this.schema.tooltipConfig))\n .render();\n }\n}\n"],"names":["configPrep","clickShape","nodeColor","tooltipSwatch","withSwatch","d","i","x","event","schema","tooltip","pick","defaultClick","bind","toString","hasUserClick","Object","keys","on","some","e","includes","hasDefaultClick","hasDeeperLevel","_drawDepth","groupBy","length","_select","style","_sharedHoverActive","position","touches","clientX","clientY","tooltipDatum","__d3plus__","data","_lastScenePick","swatch","isLegend","node","shapeType","undefined","_tooltipClass","footer","translate","title","dd","ii","_drawLabel","config","tooltipConfig","render"],"mappings":"AACA,SAAQA,UAAU,QAAO,uBAAuB;AAEhD,OAAOC,gBAAgB,mBAAmB;AAC1C,SAAQC,SAAS,EAAEC,aAAa,EAAEC,UAAU,QAAO,+BAA+B;AAIlF;;;;;AAKA,GACA,eAAe,SAEbC,CAAY,EACZC,CAAS,EACTC,CAAY,EACZC,KAA8B;;IAE9B,IAAIH,KAAK,IAAI,CAACI,MAAM,CAACC,OAAO,CAACL,GAAGC,IAAI;YA+CsCK;QA9CxE,IAAMC,eAAeX,WAAWY,IAAI,CAAC,IAAI,EAAEC,QAAQ;QAEnD,qDAAqD;QACrD,IAAMC,eAAeC,OAAOC,IAAI,CAAC,IAAI,CAACR,MAAM,CAACS,EAAE,EAAEC,IAAI,CACnD,SAACC;mBACC,8BAA8B;YAC9B;gBAAC;gBAAS;aAAc,CAACC,QAAQ,CAACD,MAClC,4BAA4B;YAC5B,MAAKX,MAAM,CAACS,EAAE,CAACE,EAAE,IACjB,iDAAiD;YACjD,MAAKX,MAAM,CAACS,EAAE,CAACE,EAAE,CAACN,QAAQ,OAAOF;;QAGrC,6DAA6D;QAC7D,4DAA4D;QAC5D,IAAMU,kBACJ,IAAI,CAACb,MAAM,CAACS,EAAE,CAAC,cAAc,IAC7B,IAAI,CAACT,MAAM,CAACS,EAAE,CAAC,cAAc,CAACJ,QAAQ,OAAOF;QAE/C,gCAAgC;QAChC,IAAMW,iBAAiB,IAAI,CAACC,UAAU,GAAG,IAAI,CAACf,MAAM,CAACgB,OAAO,CAACC,MAAM,GAAG;QAEtE,6DAA6D;QAC7D,IAAI,CAACC,OAAO,CAACC,KAAK,CAChB,UACAb,gBAAiBO,mBAAmBC,iBAAkB,YAAY;QAGpE,yEAAyE;QACzE,IAAI,IAAI,CAACM,kBAAkB,EAAE;QAE7B,IAAMC,WAAWtB,MAAMuB,OAAO,GAC1B;YAACvB,MAAMuB,OAAO,CAAC,EAAE,CAACC,OAAO;YAAExB,MAAMuB,OAAO,CAAC,EAAE,CAACE,OAAO;SAAC,GACpD;YAACzB,MAAMwB,OAAO;YAAExB,MAAMyB,OAAO;SAAC;QAElC,sEAAsE;QACtE,wEAAwE;QACxE,sEAAsE;QACtE,sDAAsD;QACtD,IAAIC,eAAgB3B,KAAKF;QACzB,MAAO6B,gBAAgBA,aAAaC,UAAU,IAAID,aAAaE,IAAI,CACjEF,eAAeA,aAAaE,IAAI;QAElC,uEAAuE;QACvE,IAAMzB,OAAO,IAAI,CAAC0B,cAAc;QAChC,IAAMC,SAAS3B,QAAQ,CAACA,KAAK4B,QAAQ,GACjCpC,cAAcD,UAAU,IAAI,EAA4BS,KAAK6B,IAAI,IAAG7B,kBAAAA,KAAK8B,SAAS,cAAd9B,6BAAAA,kBAAkB+B,aACtF;QAEJ,IAAI,CAACC,aAAa,CACfP,IAAI,CAAC;YAACF;SAAa,EACnBU,MAAM,CACLtB,mBAAmBC,iBACf,IAAI,CAACd,MAAM,CAACoC,SAAS,CAAC,qBACtB,OAELC,KAAK,CAAC,SAACC,IAAeC;mBAAe5C,WAAWkC,QAAQ,MAAKW,UAAU,CAACF,IAAIC;WAC5ElB,QAAQ,CAACA,UACToB,MAAM,CAAClD,WAAWa,IAAI,CAAC,IAAI,EAA2B,IAAI,CAACJ,MAAM,CAAC0C,aAAa,GAC/EC,MAAM;IACX;AACF"}
@@ -102,6 +102,7 @@ function _unsupported_iterable_to_array(o, minLen) {
102
102
  */ import configPrep from "../../utils/configPrep.js";
103
103
  import { isDefault } from "../../utils/configDefault.js";
104
104
  import * as shapes from "../../shapes/index.js";
105
+ import { textureKey } from "../../shapes/textureKey.js";
105
106
  /** The shape registry indexed by key, typed as constructable classes. */ var shapeCtors = shapes;
106
107
  /** Construct a shape instance by its registry key (e.g. "Bar", "Line"). */ export var makeShape = function makeShape(key) {
107
108
  return new shapeCtors[key]();
@@ -116,13 +117,26 @@ import * as shapes from "../../shapes/index.js";
116
117
  }
117
118
  return val;
118
119
  }
120
+ /**
121
+ Resolve a datum's scene fill from a shape-config record: a
122
+ `pattern:<json>` token when `sc.texture` is set for the datum (the
123
+ renderer backends materialize it), otherwise the resolved `fill` when
124
+ it is a string. `fill` is the datum's already-resolved `sc.fill`.
125
+ */ export function textureFill(sc, d, i, fill) {
126
+ var key = textureKey(resolveAccessor(sc.texture, d, i), function() {
127
+ return fill;
128
+ }, function() {
129
+ return resolveAccessor(sc.stroke, d, i);
130
+ }, sc.textureDefault);
131
+ if (key) return "pattern:".concat(key);
132
+ return typeof fill === "string" ? fill : undefined;
133
+ }
119
134
  /**
120
135
  Resolve the standard paint properties (`fill`, `stroke`, `strokeWidth`,
121
136
  `opacity`) from a shape-config record for a single datum. Returns a
122
- `Paint`-shaped object compatible with `SceneNode.paint`. `fill` is
123
- forced to `string | undefined` to match `Paint.fill` (texture/object
124
- fills fall through to `undefined`; the existing flat-data emits already
125
- do this same coercion).
137
+ `Paint`-shaped object compatible with `SceneNode.paint`. `fill` resolves
138
+ through `textureFill`, so a texture becomes a `pattern:<json>` token and
139
+ a non-string fill becomes `undefined`.
126
140
  */ export function paintFromShapeConfig(sc, d, i) {
127
141
  var fill = resolveAccessor(sc.fill, d, i);
128
142
  var stroke = resolveAccessor(sc.stroke, d, i);
@@ -130,7 +144,7 @@ import * as shapes from "../../shapes/index.js";
130
144
  var opacity = resolveAccessor(sc.opacity, d, i);
131
145
  var ve = resolveAccessor(sc.vectorEffect, d, i);
132
146
  return {
133
- fill: typeof fill === "string" ? fill : undefined,
147
+ fill: textureFill(sc, d, i, fill),
134
148
  stroke: stroke,
135
149
  strokeWidth: strokeWidth,
136
150
  opacity: opacity,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/charts/features/emitHelpers.ts"],"sourcesContent":["/**\n Helpers for `ChartDefinition.emit` functions.\n\n Most chart-as-data emits follow the same shape-compute pattern:\n instantiate a Shape (Rect/Circle/Path/…) in `renderMode(\"compute\")`,\n feed it the laid-out data + per-emit config + viz-level shapeConfig,\n call `render()` (which short-circuits before DOM mutation in compute\n mode but populates internal state), then extract:\n\n - the shape's own scene via `shape.toScene().children`\n - its labels via `shape._labelClass.toScene().children`\n\n These two helpers reduce that boilerplate to a single call and\n centralize the `configPrep.bind(viz)(viz.schema.shapeConfig, \"shape\", key)`\n incantation. The helpers swallow exceptions (returning `[]`) to\n preserve the existing pure-Node fallback: tests that run without\n loading the shape registry continue to see an empty emit instead\n of crashing.\n\n @module\n*/\n\nimport configPrep from \"../../utils/configPrep.js\";\nimport type {VizContext} from \"../../utils/configPrep.js\";\nimport {isDefault} from \"../../utils/configDefault.js\";\n\nimport type {DataPoint} from \"@d3plus/data\";\nimport type {GroupNode, SceneNode} from \"@d3plus/render\";\n\nimport * as shapes from \"../../shapes/index.js\";\n\n/** The shape registry indexed by key, typed as constructable classes. */\nconst shapeCtors = shapes as unknown as Record<string, new () => shapes.Shape>;\n\n/** Construct a shape instance by its registry key (e.g. \"Bar\", \"Line\"). */\nexport const makeShape = (key: string): shapes.Shape => new shapeCtors[key]();\n\n/**\n Structural minimum a Shape (or shape-like component: TextBox, Axis)\n must satisfy for the helpers below to work with it. Captures only the\n members the helpers touch — `render()`, optional `toScene()`, and an\n optional inner `_labelClass` with its own `toScene()`.\n\n Replaces the previous `shape: any` parameter on `collectComputed` and\n `absorbShapeIntoChartScene` — both helpers consume the same surface\n regardless of whether the actual instance is a `Shape` subclass, a\n `TextBox`, an `Axis`, or anything else that exposes these members.\n*/\nexport interface ShapeLike {\n render(): unknown;\n toScene?: () => GroupNode | null | undefined;\n _labelClass?: {\n toScene?: () => GroupNode | null | undefined;\n };\n}\n\n/**\n Structural minimum a Viz instance must satisfy for these helpers to\n work. Each chart subclass has many more fields; the helpers only need\n `_chartScene` (mutated by `absorbShapeIntoChartScene`) and\n `schema.shapeConfig` (read by `shapeConfigFor`'s default-config branch).\n*/\nexport interface VizLike {\n _chartScene?: SceneNode[];\n schema: Record<string, unknown>;\n}\n\n/**\n Resolve a per-datum accessor — either a function `(d, i) => T` or a bare\n value. The pattern repeats in every flat-data emit (Treemap, Pack, Pie,\n Priestley, …). Centralized here so each emit doesn't need its own copy.\n*/\nexport function resolveAccessor<T>(\n val: unknown,\n d: DataPoint,\n i: number | undefined,\n): T | undefined {\n if (typeof val === \"function\") {\n return (val as (d: DataPoint, i: number | undefined) => T)(d, i);\n }\n return val as T | undefined;\n}\n\n/**\n Resolve the standard paint properties (`fill`, `stroke`, `strokeWidth`,\n `opacity`) from a shape-config record for a single datum. Returns a\n `Paint`-shaped object compatible with `SceneNode.paint`. `fill` is\n forced to `string | undefined` to match `Paint.fill` (texture/object\n fills fall through to `undefined`; the existing flat-data emits already\n do this same coercion).\n*/\nexport function paintFromShapeConfig(\n sc: Record<string, unknown>,\n d: DataPoint,\n i: number | undefined,\n): {\n fill?: string;\n stroke?: string;\n strokeWidth?: number;\n opacity?: number;\n vectorEffect?: \"none\" | \"non-scaling-stroke\";\n} {\n const fill = resolveAccessor<unknown>(sc.fill, d, i);\n const stroke = resolveAccessor<string>(sc.stroke, d, i);\n const strokeWidth = resolveAccessor<number>(sc.strokeWidth, d, i);\n const opacity = resolveAccessor<number>(sc.opacity, d, i);\n const ve = resolveAccessor<string>(sc.vectorEffect, d, i);\n return {\n fill: typeof fill === \"string\" ? fill : undefined,\n stroke,\n strokeWidth,\n opacity,\n vectorEffect: ve === \"none\" || ve === \"non-scaling-stroke\" ? ve : undefined,\n };\n}\n\n/**\n Resolve a layout node's `drawLabel` text, unwrapping the `{data, i}`\n wrapper the emit-side layout nodes carry (Network/Rings/Sankey/Tree\n convention — same unwrap `paintFromShapeConfig` callers already do).\n*/\nexport function drawNodeLabel(\n viz: {_drawLabel: (d: DataPoint, i: number) => string},\n d: DataPoint & {data?: DataPoint; i?: number},\n i: number,\n): string {\n return viz._drawLabel((d.data ?? d) as DataPoint, (d.i ?? i) as number);\n}\n\n/**\n Apply a shape-config object to a chart-specific shape key, returning the\n configPrep-massaged object suitable for `.config(...)`. Equivalent to\n `(configPrep as any).bind(viz)(config, \"shape\", key)`. When `config` is\n omitted it defaults to `viz.schema.shapeConfig` (the common case — 11 sites);\n callers that compose a transient config object (e.g. Plot's confidence\n bands) pass it explicitly.\n\n `kind` is the second `configPrep` argument (the property to filter by).\n Defaults to `\"shape\"` — the standard call shape. Network's link config\n uses `\"edge\"` instead.\n*/\nexport function shapeConfigFor(\n viz: VizLike,\n shapeKey: string,\n config?: Record<string, unknown>,\n kind: string = \"shape\",\n): Record<string, unknown> {\n // configPrep binds its `this` to a VizContext-shaped object; VizLike\n // satisfies that contract at runtime.\n return configPrep.bind(viz as unknown as VizContext)(\n (config ?? viz.schema.shapeConfig) as Parameters<typeof configPrep>[0],\n kind,\n shapeKey,\n );\n}\n\n/**\n The user's label config for one shape kind — `shapeConfig.labelConfig`\n overlaid with `shapeConfig[shapeKey].labelConfig`, data-wrapped the same\n way the Shape path wraps it. Spread it over a chart's own label defaults so\n user settings (including `fontFamily()`) win. Library-seeded defaults are\n left out so they don't override the chart's.\n*/\nexport function userLabelConfig(\n viz: VizLike,\n shapeKey: string,\n): Record<string, unknown> {\n const sc = (viz.schema.shapeConfig ?? {}) as Record<string, unknown>;\n const labelConfigOf = (cfg: unknown): Record<string, unknown> | undefined =>\n cfg && typeof cfg === \"object\"\n ? ((cfg as Record<string, unknown>).labelConfig as Record<string, unknown>)\n : undefined;\n const raw: Record<string, unknown> = {\n ...labelConfigOf(sc),\n ...labelConfigOf(sc[shapeKey]),\n };\n for (const key in raw) if (isDefault(raw[key])) delete raw[key];\n const {labelConfig} = shapeConfigFor(viz, shapeKey, {labelConfig: raw});\n return (labelConfig ?? {}) as Record<string, unknown>;\n}\n\n/**\n Run `shape.render()` in compute mode and collect the resulting scene\n nodes — shape children and/or label children — in a single flat array.\n Returns `[]` if `shape` is missing or rendering throws (pure-Node\n fallback for tests that don't load the shape registry).\n\n @param shape A shape instance already configured (data, accessors,\n config) and set to `renderMode(\"compute\")`.\n @param opts.shape Include `shape.toScene().children` (default true).\n @param opts.labels Include `shape._labelClass.toScene().children`\n (default true).\n*/\nexport function collectComputed(\n shape: ShapeLike | null | undefined,\n opts: {shape?: boolean; labels?: boolean} = {},\n): SceneNode[] {\n if (!shape) return [];\n const includeShape = opts.shape !== false;\n const includeLabels = opts.labels !== false;\n try {\n shape.render();\n const out: SceneNode[] = [];\n if (includeShape && typeof shape.toScene === \"function\") {\n const s = shape.toScene();\n if (s && Array.isArray(s.children)) out.push(...s.children);\n }\n if (includeLabels) {\n const lbl = shape._labelClass;\n if (lbl && typeof lbl.toScene === \"function\") {\n const ls = lbl.toScene();\n if (ls && Array.isArray(ls.children)) out.push(...ls.children);\n }\n }\n return out;\n } catch {\n return [];\n }\n}\n\n/**\n Push a compute-mode shape's scene nodes onto `viz._chartScene`. Used\n inside chart-specific layout stages that need to mount axis decorations,\n background rects, or other helper geometry alongside the main shape\n emit. The shape MUST already be in `renderMode(\"compute\")`; this helper\n calls `shape.render()` and then absorbs both the shape and label scenes.\n\n Lives here (not in Plot.ts) so any chart stage can call it. Optionally\n wraps the absorbed nodes in a group with the given key + transform,\n useful when the decoration needs its own coordinate system that's\n distinct from the chart-wide `_chartTransform`.\n*/\nexport function absorbShapeIntoChartScene(\n viz: VizLike,\n shape: ShapeLike | null | undefined,\n wrap?: {key: string; transform?: {x: number; y: number}},\n): void {\n if (!shape || typeof shape.toScene !== \"function\") return;\n if (!Array.isArray(viz._chartScene)) viz._chartScene = [];\n const children = collectComputed(shape);\n if (!children.length) return;\n if (wrap) {\n viz._chartScene!.push({type: \"group\", ...wrap, children});\n } else {\n viz._chartScene!.push(...children);\n }\n}\n"],"names":["configPrep","isDefault","shapes","shapeCtors","makeShape","key","resolveAccessor","val","d","i","paintFromShapeConfig","sc","fill","stroke","strokeWidth","opacity","ve","vectorEffect","undefined","drawNodeLabel","viz","_drawLabel","data","shapeConfigFor","shapeKey","config","kind","bind","schema","shapeConfig","userLabelConfig","labelConfigOf","cfg","labelConfig","raw","collectComputed","shape","opts","includeShape","includeLabels","labels","render","out","toScene","s","Array","isArray","children","push","lbl","_labelClass","ls","absorbShapeIntoChartScene","wrap","_chartScene","length","type"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;AAoBA,GAEA,OAAOA,gBAAgB,4BAA4B;AAEnD,SAAQC,SAAS,QAAO,+BAA+B;AAKvD,YAAYC,YAAY,wBAAwB;AAEhD,uEAAuE,GACvE,IAAMC,aAAaD;AAEnB,yEAAyE,GACzE,OAAO,IAAME,YAAY,mBAACC;WAA8B,IAAIF,UAAU,CAACE,IAAI;EAAG;AAgC9E;;;;AAIA,GACA,OAAO,SAASC,gBACdC,GAAY,EACZC,CAAY,EACZC,CAAqB;IAErB,IAAI,OAAOF,QAAQ,YAAY;QAC7B,OAAO,AAACA,IAAmDC,GAAGC;IAChE;IACA,OAAOF;AACT;AAEA;;;;;;;AAOA,GACA,OAAO,SAASG,qBACdC,EAA2B,EAC3BH,CAAY,EACZC,CAAqB;IAQrB,IAAMG,OAAON,gBAAyBK,GAAGC,IAAI,EAAEJ,GAAGC;IAClD,IAAMI,SAASP,gBAAwBK,GAAGE,MAAM,EAAEL,GAAGC;IACrD,IAAMK,cAAcR,gBAAwBK,GAAGG,WAAW,EAAEN,GAAGC;IAC/D,IAAMM,UAAUT,gBAAwBK,GAAGI,OAAO,EAAEP,GAAGC;IACvD,IAAMO,KAAKV,gBAAwBK,GAAGM,YAAY,EAAET,GAAGC;IACvD,OAAO;QACLG,MAAM,OAAOA,SAAS,WAAWA,OAAOM;QACxCL,QAAAA;QACAC,aAAAA;QACAC,SAAAA;QACAE,cAAcD,OAAO,UAAUA,OAAO,uB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sourcesContent":["/**\n Helpers for `ChartDefinition.emit` functions.\n\n Most chart-as-data emits follow the same shape-compute pattern:\n instantiate a Shape (Rect/Circle/Path/…) in `renderMode(\"compute\")`,\n feed it the laid-out data + per-emit config + viz-level shapeConfig,\n call `render()` (which short-circuits before DOM mutation in compute\n mode but populates internal state), then extract:\n\n - the shape's own scene via `shape.toScene().children`\n - its labels via `shape._labelClass.toScene().children`\n\n These two helpers reduce that boilerplate to a single call and\n centralize the `configPrep.bind(viz)(viz.schema.shapeConfig, \"shape\", key)`\n incantation. The helpers swallow exceptions (returning `[]`) to\n preserve the existing pure-Node fallback: tests that run without\n loading the shape registry continue to see an empty emit instead\n of crashing.\n\n @module\n*/\n\nimport configPrep from \"../../utils/configPrep.js\";\nimport type {VizContext} from \"../../utils/configPrep.js\";\nimport {isDefault} from \"../../utils/configDefault.js\";\n\nimport type {DataPoint} from \"@d3plus/data\";\nimport type {GroupNode, SceneNode} from \"@d3plus/render\";\n\nimport * as shapes from \"../../shapes/index.js\";\nimport {textureKey} from \"../../shapes/textureKey.js\";\n\n/** The shape registry indexed by key, typed as constructable classes. */\nconst shapeCtors = shapes as unknown as Record<string, new () => shapes.Shape>;\n\n/** Construct a shape instance by its registry key (e.g. \"Bar\", \"Line\"). */\nexport const makeShape = (key: string): shapes.Shape => new shapeCtors[key]();\n\n/**\n Structural minimum a Shape (or shape-like component: TextBox, Axis)\n must satisfy for the helpers below to work with it. Captures only the\n members the helpers touch — `render()`, optional `toScene()`, and an\n optional inner `_labelClass` with its own `toScene()`.\n\n Replaces the previous `shape: any` parameter on `collectComputed` and\n `absorbShapeIntoChartScene` — both helpers consume the same surface\n regardless of whether the actual instance is a `Shape` subclass, a\n `TextBox`, an `Axis`, or anything else that exposes these members.\n*/\nexport interface ShapeLike {\n render(): unknown;\n toScene?: () => GroupNode | null | undefined;\n _labelClass?: {\n toScene?: () => GroupNode | null | undefined;\n };\n}\n\n/**\n Structural minimum a Viz instance must satisfy for these helpers to\n work. Each chart subclass has many more fields; the helpers only need\n `_chartScene` (mutated by `absorbShapeIntoChartScene`) and\n `schema.shapeConfig` (read by `shapeConfigFor`'s default-config branch).\n*/\nexport interface VizLike {\n _chartScene?: SceneNode[];\n schema: Record<string, unknown>;\n}\n\n/**\n Resolve a per-datum accessor — either a function `(d, i) => T` or a bare\n value. The pattern repeats in every flat-data emit (Treemap, Pack, Pie,\n Priestley, …). Centralized here so each emit doesn't need its own copy.\n*/\nexport function resolveAccessor<T>(\n val: unknown,\n d: DataPoint,\n i: number | undefined,\n): T | undefined {\n if (typeof val === \"function\") {\n return (val as (d: DataPoint, i: number | undefined) => T)(d, i);\n }\n return val as T | undefined;\n}\n\n/**\n Resolve a datum's scene fill from a shape-config record: a\n `pattern:<json>` token when `sc.texture` is set for the datum (the\n renderer backends materialize it), otherwise the resolved `fill` when\n it is a string. `fill` is the datum's already-resolved `sc.fill`.\n*/\nexport function textureFill(\n sc: Record<string, unknown>,\n d: DataPoint,\n i: number | undefined,\n fill: unknown,\n): string | undefined {\n const key = textureKey(\n resolveAccessor<unknown>(sc.texture, d, i),\n () => fill,\n () => resolveAccessor<unknown>(sc.stroke, d, i),\n sc.textureDefault as Record<string, unknown> | undefined,\n );\n if (key) return `pattern:${key}`;\n return typeof fill === \"string\" ? fill : undefined;\n}\n\n/**\n Resolve the standard paint properties (`fill`, `stroke`, `strokeWidth`,\n `opacity`) from a shape-config record for a single datum. Returns a\n `Paint`-shaped object compatible with `SceneNode.paint`. `fill` resolves\n through `textureFill`, so a texture becomes a `pattern:<json>` token and\n a non-string fill becomes `undefined`.\n*/\nexport function paintFromShapeConfig(\n sc: Record<string, unknown>,\n d: DataPoint,\n i: number | undefined,\n): {\n fill?: string;\n stroke?: string;\n strokeWidth?: number;\n opacity?: number;\n vectorEffect?: \"none\" | \"non-scaling-stroke\";\n} {\n const fill = resolveAccessor<unknown>(sc.fill, d, i);\n const stroke = resolveAccessor<string>(sc.stroke, d, i);\n const strokeWidth = resolveAccessor<number>(sc.strokeWidth, d, i);\n const opacity = resolveAccessor<number>(sc.opacity, d, i);\n const ve = resolveAccessor<string>(sc.vectorEffect, d, i);\n return {\n fill: textureFill(sc, d, i, fill),\n stroke,\n strokeWidth,\n opacity,\n vectorEffect: ve === \"none\" || ve === \"non-scaling-stroke\" ? ve : undefined,\n };\n}\n\n/**\n Resolve a layout node's `drawLabel` text, unwrapping the `{data, i}`\n wrapper the emit-side layout nodes carry (Network/Rings/Sankey/Tree\n convention — same unwrap `paintFromShapeConfig` callers already do).\n*/\nexport function drawNodeLabel(\n viz: {_drawLabel: (d: DataPoint, i: number) => string},\n d: DataPoint & {data?: DataPoint; i?: number},\n i: number,\n): string {\n return viz._drawLabel((d.data ?? d) as DataPoint, (d.i ?? i) as number);\n}\n\n/**\n Apply a shape-config object to a chart-specific shape key, returning the\n configPrep-massaged object suitable for `.config(...)`. Equivalent to\n `(configPrep as any).bind(viz)(config, \"shape\", key)`. When `config` is\n omitted it defaults to `viz.schema.shapeConfig` (the common case — 11 sites);\n callers that compose a transient config object (e.g. Plot's confidence\n bands) pass it explicitly.\n\n `kind` is the second `configPrep` argument (the property to filter by).\n Defaults to `\"shape\"` — the standard call shape. Network's link config\n uses `\"edge\"` instead.\n*/\nexport function shapeConfigFor(\n viz: VizLike,\n shapeKey: string,\n config?: Record<string, unknown>,\n kind: string = \"shape\",\n): Record<string, unknown> {\n // configPrep binds its `this` to a VizContext-shaped object; VizLike\n // satisfies that contract at runtime.\n return configPrep.bind(viz as unknown as VizContext)(\n (config ?? viz.schema.shapeConfig) as Parameters<typeof configPrep>[0],\n kind,\n shapeKey,\n );\n}\n\n/**\n The user's label config for one shape kind — `shapeConfig.labelConfig`\n overlaid with `shapeConfig[shapeKey].labelConfig`, data-wrapped the same\n way the Shape path wraps it. Spread it over a chart's own label defaults so\n user settings (including `fontFamily()`) win. Library-seeded defaults are\n left out so they don't override the chart's.\n*/\nexport function userLabelConfig(\n viz: VizLike,\n shapeKey: string,\n): Record<string, unknown> {\n const sc = (viz.schema.shapeConfig ?? {}) as Record<string, unknown>;\n const labelConfigOf = (cfg: unknown): Record<string, unknown> | undefined =>\n cfg && typeof cfg === \"object\"\n ? ((cfg as Record<string, unknown>).labelConfig as Record<string, unknown>)\n : undefined;\n const raw: Record<string, unknown> = {\n ...labelConfigOf(sc),\n ...labelConfigOf(sc[shapeKey]),\n };\n for (const key in raw) if (isDefault(raw[key])) delete raw[key];\n const {labelConfig} = shapeConfigFor(viz, shapeKey, {labelConfig: raw});\n return (labelConfig ?? {}) as Record<string, unknown>;\n}\n\n/**\n Run `shape.render()` in compute mode and collect the resulting scene\n nodes — shape children and/or label children — in a single flat array.\n Returns `[]` if `shape` is missing or rendering throws (pure-Node\n fallback for tests that don't load the shape registry).\n\n @param shape A shape instance already configured (data, accessors,\n config) and set to `renderMode(\"compute\")`.\n @param opts.shape Include `shape.toScene().children` (default true).\n @param opts.labels Include `shape._labelClass.toScene().children`\n (default true).\n*/\nexport function collectComputed(\n shape: ShapeLike | null | undefined,\n opts: {shape?: boolean; labels?: boolean} = {},\n): SceneNode[] {\n if (!shape) return [];\n const includeShape = opts.shape !== false;\n const includeLabels = opts.labels !== false;\n try {\n shape.render();\n const out: SceneNode[] = [];\n if (includeShape && typeof shape.toScene === \"function\") {\n const s = shape.toScene();\n if (s && Array.isArray(s.children)) out.push(...s.children);\n }\n if (includeLabels) {\n const lbl = shape._labelClass;\n if (lbl && typeof lbl.toScene === \"function\") {\n const ls = lbl.toScene();\n if (ls && Array.isArray(ls.children)) out.push(...ls.children);\n }\n }\n return out;\n } catch {\n return [];\n }\n}\n\n/**\n Push a compute-mode shape's scene nodes onto `viz._chartScene`. Used\n inside chart-specific layout stages that need to mount axis decorations,\n background rects, or other helper geometry alongside the main shape\n emit. The shape MUST already be in `renderMode(\"compute\")`; this helper\n calls `shape.render()` and then absorbs both the shape and label scenes.\n\n Lives here (not in Plot.ts) so any chart stage can call it. Optionally\n wraps the absorbed nodes in a group with the given key + transform,\n useful when the decoration needs its own coordinate system that's\n distinct from the chart-wide `_chartTransform`.\n*/\nexport function absorbShapeIntoChartScene(\n viz: VizLike,\n shape: ShapeLike | null | undefined,\n wrap?: {key: string; transform?: {x: number; y: number}},\n): void {\n if (!shape || typeof shape.toScene !== \"function\") return;\n if (!Array.isArray(viz._chartScene)) viz._chartScene = [];\n const children = collectComputed(shape);\n if (!children.length) return;\n if (wrap) {\n viz._chartScene!.push({type: \"group\", ...wrap, children});\n } else {\n viz._chartScene!.push(...children);\n }\n}\n"],"names":["configPrep","isDefault","shapes","textureKey","shapeCtors","makeShape","key","resolveAccessor","val","d","i","textureFill","sc","fill","texture","stroke","textureDefault","undefined","paintFromShapeConfig","strokeWidth","opacity","ve","vectorEffect","drawNodeLabel","viz","_drawLabel","data","shapeConfigFor","shapeKey","config","kind","bind","schema","shapeConfig","userLabelConfig","labelConfigOf","cfg","labelConfig","raw","collectComputed","shape","opts","includeShape","includeLabels","labels","render","out","toScene","s","Array","isArray","children","push","lbl","_labelClass","ls","absorbShapeIntoChartScene","wrap","_chartScene","length","type"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;AAoBA,GAEA,OAAOA,gBAAgB,4BAA4B;AAEnD,SAAQC,SAAS,QAAO,+BAA+B;AAKvD,YAAYC,YAAY,wBAAwB;AAChD,SAAQC,UAAU,QAAO,6BAA6B;AAEtD,uEAAuE,GACvE,IAAMC,aAAaF;AAEnB,yEAAyE,GACzE,OAAO,IAAMG,YAAY,mBAACC;WAA8B,IAAIF,UAAU,CAACE,IAAI;EAAG;AAgC9E;;;;AAIA,GACA,OAAO,SAASC,gBACdC,GAAY,EACZC,CAAY,EACZC,CAAqB;IAErB,IAAI,OAAOF,QAAQ,YAAY;QAC7B,OAAO,AAACA,IAAmDC,GAAGC;IAChE;IACA,OAAOF;AACT;AAEA;;;;;AAKA,GACA,OAAO,S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,KAAK,YAAY;oBAEND;gBADtC,IAAMS,KAAKF,IAAIN,OAAO;gBACtB,IAAIQ,MAAMN,MAAMC,OAAO,CAACK,GAAGJ,QAAQ,GAAGL,CAAAA,QAAAA,KAAIM,IAAI,OAARN,OAAS,qBAAGS,GAAGJ,QAAQ;YAC/D;QACF;QACA,OAAOL;IACT,EAAE,eAAM;QACN,OAAO,EAAE;IACX;AACF;AAEA;;;;;;;;;;;AAWA,GACA,OAAO,SAASU,0BACdhC,GAAY,EACZgB,KAAmC,EACnCiB,IAAwD;IAExD,IAAI,CAACjB,SAAS,OAAOA,MAAMO,OAAO,KAAK,YAAY;IACnD,IAAI,CAACE,MAAMC,OAAO,CAAC1B,IAAIkC,WAAW,GAAGlC,IAAIkC,WAAW,GAAG,EAAE;IACzD,IAAMP,WAAWZ,gBAAgBC;IACjC,IAAI,CAACW,SAASQ,MAAM,EAAE;IACtB,IAAIF,MAAM;QACRjC,IAAIkC,WAAW,CAAEN,IAAI,CAAC;YAACQ,MAAM;WAAYH;YAAMN,UAAAA;;IACjD,OAAO;YACL3B;QAAAA,CAAAA,mBAAAA,IAAIkC,WAAW,EAAEN,IAAI,OAArB5B,kBAAsB,qBAAG2B;IAC3B;AACF"}
@@ -60,14 +60,12 @@ function _object_spread_props(target, source) {
60
60
 
61
61
  Every Plot-family + chart-shell feature here is wired into
62
62
  `vizDrawPure` via `runLayout(ctx, [...features])`.
63
- */ import { extent, min, rollup, sum } from "d3-array";
64
- import { merge, unique } from "@d3plus/data";
63
+ */ import { extent, sum } from "d3-array";
64
+ import { unique } from "@d3plus/data";
65
65
  import { date, elem } from "@d3plus/dom";
66
- import { resolveSpec } from "../pipeline/resolveSpec.js";
67
66
  import { zoomControlsBox } from "../drawSteps/zoomControlsMarkup.js";
68
67
  import { getTopLeftContributions } from "../drawSteps/topLeftControls.js";
69
68
  import { topLeftControlsInset as topLeftControlsInsetRaw } from "../drawSteps/topLeftControlsMarkup.js";
70
- import { bottomRightClearance } from "../drawSteps/bottomRightControlsMarkup.js";
71
69
  var VALID_POSITIONS = new Set([
72
70
  false,
73
71
  "top",
@@ -492,110 +490,7 @@ var VALID_POSITIONS = new Set([
492
490
  };
493
491
  }
494
492
  };
495
- /* ------------------------------- ColorScale ------------------------------ */ /**
496
- Converts `drawColorScale.ts` to a FeatureModule.
497
-
498
- Visible only when `_colorScale` is truthy and `_colorScalePosition` resolves
499
- to a side. Renders the chart's `_colorScaleClass` ColorScale instance and
500
- claims margin along its position side.
501
- */ export var colorScaleFeature = {
502
- name: "colorScale",
503
- configFields: [
504
- "colorScale",
505
- "colorScaleConfig",
506
- "colorScaleMaxSize",
507
- "colorScalePadding",
508
- "colorScalePosition"
509
- ],
510
- layout: function layout(param) {
511
- var viz = param.viz, layoutMargin = param.layoutMargin;
512
- var data = Array.from(rollup(viz._data, function(leaves) {
513
- return merge(leaves, viz.schema.aggs);
514
- }, function(d, i) {
515
- return "".concat(viz.schema.time ? viz.schema.time(d, i) : "all", "-").concat(viz._ids(d, i).join("_"));
516
- }).values());
517
- var position = sanitizePosition(viz.schema.colorScalePosition.bind(viz)(resolveSpec(viz)));
518
- var wide = [
519
- "top",
520
- "bottom"
521
- ].includes(position);
522
- var showColorScale = viz.schema.colorScale && position;
523
- var padding = viz.schema.colorScalePadding(viz) ? viz._padding : {
524
- top: 0,
525
- right: 0,
526
- bottom: 0,
527
- left: 0
528
- };
529
- // Share the bottom band with the bottom-right corner panel (size legend):
530
- // a bottom colorScale fits beside it, a side one ends above it.
531
- var corner = bottomRightClearance(viz, position, layoutMargin.bottom + padding.bottom, layoutMargin.right + padding.right);
532
- var availableWidth = viz.schema.width - (layoutMargin.left + layoutMargin.right + padding.left + padding.right) - corner.inset;
533
- var width = wide ? min([
534
- viz.schema.colorScaleMaxSize,
535
- availableWidth
536
- ]) : viz.schema.width - (layoutMargin.left + layoutMargin.right);
537
- var availableHeight = viz.schema.height - (layoutMargin.bottom + layoutMargin.top + padding.bottom + padding.top) - corner.drop;
538
- var height = !wide ? min([
539
- viz.schema.colorScaleMaxSize,
540
- availableHeight
541
- ]) : viz.schema.height - (layoutMargin.bottom + layoutMargin.top);
542
- var transform = {
543
- opacity: position ? 1 : 0,
544
- transform: "translate(".concat(wide ? layoutMargin.left + padding.left + (availableWidth - width) / 2 : layoutMargin.left, ", ").concat(wide ? layoutMargin.top : layoutMargin.top + padding.top + (availableHeight - height) / 2, ")")
545
- };
546
- var scaleGroup = elem("g.d3plus-viz-colorScale", {
547
- condition: showColorScale && !viz.schema.colorScaleConfig.select,
548
- enter: transform,
549
- parent: viz._select,
550
- duration: viz.schema.duration,
551
- update: transform
552
- }).node();
553
- if (!viz.schema.colorScale) return {
554
- panel: null,
555
- margin: {}
556
- };
557
- var scaleData = data.filter(function(d, i) {
558
- var c = viz.schema.colorScale(d, i);
559
- return c !== undefined && c !== null;
560
- });
561
- // Discrete (bucket/jenks/quantile) colorScales render their swatches via an
562
- // internal Legend, which composes cleanly through the Viz scene — so run
563
- // them in compute mode (like the legend) so the Viz's toScene owns them and
564
- // hover/active dimming applies. Without this they render full-mode, where
565
- // paintComponentScene paints a full-opacity copy that overlays and defeats
566
- // the dimming. The smooth-gradient variant stays full-mode: its gradient
567
- // fill is materialized through paintComponentScene, not the Viz scene.
568
- var csCfg = viz.schema.colorScaleConfig || {};
569
- var csDiscrete = !csCfg.bucketAxis && [
570
- "buckets",
571
- "jenks",
572
- "quantile"
573
- ].includes(typeof csCfg.scale === "string" ? csCfg.scale : "");
574
- viz._colorScaleClass.renderMode(csDiscrete ? "compute" : "full").align({
575
- bottom: "end",
576
- left: "start",
577
- right: "end",
578
- top: "start"
579
- }[position] || "bottom").duration(viz.schema.duration).data(scaleData).height(height).locale(viz.schema.locale).orient(position).select(scaleGroup).value(viz.schema.colorScale).width(width).config(viz.schema.colorScaleConfig).render();
580
- var margin = {};
581
- if (showColorScale) {
582
- var scaleBounds = viz._colorScaleClass.outerBounds();
583
- if (!viz.schema.colorScaleConfig.select && scaleBounds.height) {
584
- // Use the colorScale's OWN padding for its margin claim — not the
585
- // legend's, so a custom legendPadding doesn't shift the
586
- // colorScale's claim when the legend is hidden. The colorScale
587
- // class is the source of truth.
588
- var csPadding = typeof viz._colorScaleClass.padding === "function" ? viz._colorScaleClass.padding() : viz._legendClass.padding();
589
- if (wide) margin[position] = scaleBounds.height + csPadding * 2;
590
- else margin[position] = scaleBounds.width + csPadding * 2;
591
- }
592
- }
593
- return {
594
- panel: null,
595
- margin: margin
596
- };
597
- }
598
- };
493
+ /* ------------------------------- ColorScale ------------------------------ */ export { colorScaleFeature } from "./featuresColorScale.js";
599
494
  /* ------------------------------ Attribution ------------------------------ */ export { attributionFeature } from "./attributionFeature.js";
600
495
  /**
601
496
  Converts `drawTotal.ts` to a FeatureModule. Slightly different from title/
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/charts/features/features.ts"],"sourcesContent":["/**\n FeatureModule + layout engine. The chart-level features (title,\n subtitle, total, legend, timeline, colorScale, back) are\n `FeatureModule` values composed by `runLayout`, which performs\n **explicit margin negotiation** — each feature returns a `MarginClaim`\n + optional `panel` scene node + optional declarative `vizUpdate`\n writes, and the engine accumulates margins across features in order.\n\n Every Plot-family + chart-shell feature here is wired into\n `vizDrawPure` via `runLayout(ctx, [...features])`.\n*/\nimport {extent, min, rollup, sum} from \"d3-array\";\n\nimport {merge, unique} from \"@d3plus/data\";\nimport type {DataPoint, MergedDataPoint} from \"@d3plus/data\";\nimport {date, elem} from \"@d3plus/dom\";\n\nimport type {SceneNode} from \"@d3plus/render\";\n\nimport {resolveSpec} from \"../pipeline/resolveSpec.js\";\nimport type {VizContext} from \"../pipeline/stages.js\";\nimport type {VizInstance} from \"../viz/vizTypes.js\";\nimport {zoomControlsBox} from \"../drawSteps/zoomControlsMarkup.js\";\nimport {getTopLeftContributions} from \"../drawSteps/topLeftControls.js\";\nimport {topLeftControlsInset as topLeftControlsInsetRaw} from \"../drawSteps/topLeftControlsMarkup.js\";\nimport {bottomRightClearance} from \"../drawSteps/bottomRightControlsMarkup.js\";\n\n/** A margin claim, in pixels along each side. Unclaimed sides default to 0. */\nexport interface MarginClaim {\n top?: number;\n right?: number;\n bottom?: number;\n left?: number;\n}\n\n/** The shape a `layout` step returns: optional panel node + margin claim + optional viz writebacks. */\nexport interface FeatureLayout {\n panel: SceneNode | null;\n margin: MarginClaim;\n /**\n v4 purity: features that need to publish CROSS-FEATURE state — a\n write that a DIFFERENT feature or downstream stage will read — return\n those writes here as declarative key→value pairs. `runLayout`\n applies them to viz after the layout call so the next feature in\n the chain sees them.\n\n Key convention: keys are auto-prefixed with `_` to match viz's\n internal field convention. Return `{drawDepth: 2}` to write\n `viz._drawDepth`; explicitly-underscored keys (`{_drawDepth: 2}`)\n pass through unchanged for the rare case where the engine\n shouldn't prepend. This rule exists because a leading underscore\n is easy to forget and writing `viz.drawDepth` (no underscore) is\n almost never what callers want.\n\n Intra-feature local writes (a feature setting state that its OWN\n component instance reads inside the same `layout()` body) are\n legitimate direct mutations on viz — `vizUpdate` would defer the\n write past the local read. legendFeature's `_legendDepth` is an\n example of an intra-feature local; timelineFeature's\n `_timelineSelection` similarly mutates from its event handler\n context. The contract is about CROSS-feature mutation, not all\n mutation.\n */\n vizUpdate?: Record<string, unknown>;\n}\n\n/**\n @interface FeatureModule\n A chart-level component (title, subtitle, total, legend, timeline,\n colorScale, back, attribution) expressed as a pure value. Each feature:\n - contributes config keys to the chart's schema (`configFields`),\n - optionally derives extra fields onto the pipeline context (`derive`),\n - optionally claims a margin region + emits its panel scene (`layout`),\n - optionally registers event reducers (`events`).\n*/\nexport interface FeatureModule {\n name: string;\n /** Keys the chart's config inherits from this feature (used by E4 fluent gen). */\n configFields?: string[];\n /** Extra derivations to add into the pipeline context. */\n derive?: (ctx: VizContext) => Partial<VizContext>;\n /**\n Pure layout: read the (possibly updated-by-earlier-features) context and\n return the panel scene + margin this feature claims. The layoutEngine\n threads the margin claims through `ctx.layoutMargin` so a feature can\n read what earlier features already took.\n */\n layout?: (\n ctx: VizContext & {layoutMargin: Required<MarginClaim>},\n ) => FeatureLayout;\n /**\n Event reducers `(ctx, event) => Partial<VizConfig>`. Fire when a\n user interaction occurs on a node tagged with this feature's name.\n */\n events?: Record<string, (ctx: VizContext, event: unknown) => unknown>;\n}\n\n/**\n Result of running a list of features through the layout engine.\n*/\nexport interface LayoutResult {\n /** Panel nodes in feature order, ready to compose into the scene root. */\n panels: SceneNode[];\n /** Final margin after every feature claimed its space. */\n margin: Required<MarginClaim>;\n}\n\n/**\n The allowed values for `legendPosition` and `colorScalePosition`.\n `false` means \"hidden\" (the feature still runs to tear down DOM); the\n four strings are the four sides.\n*/\nexport type PanelPosition = false | \"top\" | \"right\" | \"bottom\" | \"left\";\n\nconst VALID_POSITIONS: ReadonlySet<PanelPosition | string> = new Set([\n false as unknown as string,\n \"top\",\n \"right\",\n \"bottom\",\n \"left\",\n]);\n\n/**\n Canonical sanitizer for `legendPosition` / `colorScalePosition`.\n Falls back to `\"bottom\"` when the user-supplied accessor returns\n something outside the allowed set. Single source of truth — used by\n `vizDrawPure` (for sanitized ctx publication) and by `legendFeature`\n + `colorScaleFeature` (for their internal positioning math).\n*/\nexport function sanitizePosition(raw: unknown): PanelPosition {\n return (VALID_POSITIONS.has(raw as string) ? raw : \"bottom\") as PanelPosition;\n}\n\n/**\n Runs each feature's `layout` in order, accumulating margin claims so that\n later features see the space already taken by earlier ones. The order of\n `features` is the layout order — this is how implicit `this._margin +=`\n side effects become *explicit* data flow.\n\n Today's order in `Viz._draw` (`drawTitle`, `drawSubtitle`, `drawTotal`,\n `drawBack`, `drawAttribution`, `drawColorScale`, `drawLegend`,\n `drawTimeline`) should be ported verbatim as the default sequence — port\n the math first, then improve.\n*/\nexport function runLayout(\n ctx: VizContext,\n features: FeatureModule[],\n baseMargin: Required<MarginClaim> = {top: 0, right: 0, bottom: 0, left: 0},\n): LayoutResult {\n // `claims` is this call's accumulated margin (the returned delta).\n // `layoutMargin` handed to each feature is the running TOTAL —\n // `baseMargin` (margin already taken by prior runLayout calls in the same\n // draw) plus the claims taken so far in this call — so a feature reads\n // the true current margin without touching viz._margin.\n const claims: Required<MarginClaim> = {top: 0, right: 0, bottom: 0, left: 0};\n const panels: SceneNode[] = [];\n for (const f of features) {\n if (!f.layout) continue;\n const layoutMargin: Required<MarginClaim> = {\n top: baseMargin.top + claims.top,\n right: baseMargin.right + claims.right,\n bottom: baseMargin.bottom + claims.bottom,\n left: baseMargin.left + claims.left,\n };\n const result = f.layout({...ctx, layoutMargin});\n const {panel, margin: claim, vizUpdate} = result;\n if (panel) panels.push(panel);\n claims.top += claim.top ?? 0;\n claims.right += claim.right ?? 0;\n claims.bottom += claim.bottom ?? 0;\n claims.left += claim.left ?? 0;\n // v4 purity: features publish cross-feature viz writes declaratively\n // via `vizUpdate`. The engine applies them — features don't mutate\n // viz directly from layout(). Skips own component-instance config\n // calls (those are local mutation, not cross-feature). Use\n // `Object.keys` (not `for...in`) so inherited enumerable properties\n // on a class-instance vizUpdate don't leak onto viz.\n //\n // Key convention: keys are auto-prefixed with `_` to land on the\n // viz's internal field convention (`viz._drawDepth`, `viz._legendDepth`).\n // Features should return UNPREFIXED keys (`{drawDepth: 2}`); the\n // engine normalizes — so feature authors can't accidentally write\n // `viz.drawDepth` (a different non-underscore property) instead of\n // `viz._drawDepth`. Keys that already start with `_` are passed\n // through unchanged so future explicit-internal writes still work.\n if (vizUpdate && ctx.viz) {\n const target = ctx.viz as Record<string, unknown>;\n for (const k of Object.keys(vizUpdate)) {\n const key = k.startsWith(\"_\") ? k : `_${k}`;\n target[key] = vizUpdate[k];\n }\n }\n }\n return {panels, margin: claims};\n}\n\n/* --------------------------- text-block features --------------------------- */\n\n/** A TextBox `_textData()` row, as the text-block features read it. */\ninterface TextDatum {\n lines: string[];\n lH: number;\n fS: number;\n fF: string;\n fC: string;\n fO: number;\n tA: string;\n widths: number[];\n}\n\n/**\n A little breathing room added to a NON-zero corner inset, on top of the\n exact pixel width the corner panel measured at. Without it, content\n insets to EXACTLY the corner box's edge — any tiny discrepancy between\n that hidden-probe measurement and the real rendered box (sub-pixel\n rounding, a font metric quirk) then reads as the text visibly, if\n slightly, running under the buttons.\n*/\nconst CORNER_INSET_GAP = 6;\n\n/**\n How far content starting `top` px down the chart, whose right edge sits\n `right` px in from the chart's right edge, must pull in its right edge to\n clear the zoom-control panel pinned to the chart's top-right corner. Zero\n when the chart shows no controls or the content starts below them.\n*/\nexport function zoomControlsInset(viz: VizInstance, top: number, right: number): number {\n const box = zoomControlsBox(viz as never);\n if (!box || top >= box.height) return 0;\n const inset = box.width - right;\n return inset > 0 ? inset + CORNER_INSET_GAP : 0;\n}\n\n/**\n The left-side mirror of `zoomControlsInset`: how far content starting\n `top` px down the chart, whose left edge sits `left` px in from the\n chart's left edge, must pull in to clear the shared top-left controls\n panel (back / table-view / search). Zero when nothing is showing there\n or content starts below the panel's height.\n*/\nexport function topLeftControlsInset(viz: VizInstance, top: number, left: number): number {\n const contributions = getTopLeftContributions(viz as never);\n const inset = topLeftControlsInsetRaw(viz as never, top, left, contributions);\n return inset > 0 ? inset + CORNER_INSET_GAP : 0;\n}\n\n/**\n The combined left+right corner-panel insets for content starting `top`\n px down the chart, plus the single symmetric amount CENTERED content\n should inset both sides by to stay centered on the full chart width even\n when only one corner has something to avoid (the larger of the two —\n see `textBlockLayout`'s doc comment for why). Shared by `textBlockLayout`\n (title/subtitle/total) and the legend's own top-position layout\n (`featuresLegend.ts`), which independently needed this exact same\n \"combine the two corners' insets\" math before this existed.\n*/\nexport function cornerInsets(\n viz: VizInstance,\n top: number,\n left: number,\n right: number,\n): {left: number; right: number; symmetric: number} {\n const leftInset = topLeftControlsInset(viz, top, left);\n const rightInset = zoomControlsInset(viz, top, right);\n return {left: leftInset, right: rightInset, symmetric: Math.max(leftInset, rightInset)};\n}\n\n/**\n Shared layout logic for any \"single line of text claiming margin.top\" feature\n (title, subtitle, total). Each feature passes the viz fields that source its\n text + TextBox + config; the helper computes the panel + margin claim using\n the TextBox's pure `_textData()` (no DOM).\n*/\nfunction textBlockLayout(\n ctx: VizContext & {layoutMargin: Required<MarginClaim>},\n opts: {\n panelKey: string;\n getText: (viz: VizInstance) => string | false;\n textClassKey: string; // e.g. \"_titleClass\"\n configKey: string; // schema key, e.g. \"titleConfig\"\n paddingMethod: string; // schema key, e.g. \"titlePadding\"\n },\n): FeatureLayout {\n const {viz, layoutMargin} = ctx;\n const text = opts.getText(viz);\n if (!text) return {panel: null, margin: {}};\n\n const usesPadding = (viz.schema[opts.paddingMethod] as (viz: VizInstance) => boolean)(viz);\n const padding = usesPadding\n ? viz._padding\n : {top: 0, right: 0, bottom: 0, left: 0};\n let width =\n viz.schema.width -\n (layoutMargin.left + layoutMargin.right + padding.left + padding.right);\n\n const textClass = viz[opts.textClassKey];\n textClass\n .data([{text}])\n .locale(viz.schema.locale)\n .width(width)\n .config(viz.schema[opts.configKey]);\n let boxes = textClass._textData() as TextDatum[];\n\n // Text alongside the zoom controls (right) and/or the shared top-left\n // controls panel (left — back/table-view/search) wraps short of them.\n // Centered text insets both sides by the SAME (larger) amount so it stays\n // centered on the full chart width, matching how it already behaved\n // relative to zoom alone; start/end-aligned text instead just narrows the\n // true available box (its unaffected edge stays exactly where it was).\n let x = layoutMargin.left + padding.left;\n const {left: leftInset, right: rightInset, symmetric} = cornerInsets(\n viz,\n layoutMargin.top,\n layoutMargin.left + padding.left,\n layoutMargin.right + padding.right,\n );\n if ((rightInset || leftInset) && boxes.length) {\n const centered = boxes[0].tA === \"middle\";\n if (centered) {\n x += symmetric;\n width -= symmetric * 2;\n } else {\n x += leftInset;\n width -= leftInset + rightInset;\n }\n textClass.width(width);\n boxes = textClass._textData() as TextDatum[];\n }\n if (!boxes.length) return {panel: null, margin: {}};\n const box = boxes[0];\n\n const lineHeight = box.lH;\n const blockPadding = (viz.schema[opts.configKey]?.padding as number) ?? 0;\n const height = box.lines.length * lineHeight + blockPadding * 2;\n // The claimed margin (below) already reserves `blockPadding` above AND\n // below the text — shifting the panel down by that same amount is what\n // actually centers the text within that reserved band, rather than\n // pinning it flush to the very top of it. Previously `blockPadding` only\n // grew/shrank the claimed space; it never moved the text within it,\n // which is why the default title padding (5px) had no visible effect —\n // the title sat at the top of its claim regardless, reading noticeably\n // higher than the same-row zoom/back/search buttons beside it.\n const y = layoutMargin.top + blockPadding;\n\n const lines = box.lines.map((str: string, i: number) => ({\n text: str,\n x:\n box.tA === \"middle\"\n ? width / 2\n : box.tA === \"end\"\n ? width\n : 0,\n y: (i + 1) * lineHeight - (lineHeight - box.fS),\n width: box.widths?.[i] ?? 0,\n }));\n\n const panel: SceneNode = {\n type: \"text\",\n key: opts.panelKey,\n x: 0,\n y: 0,\n lines,\n font: {\n family: box.fF,\n size: box.fS,\n anchor:\n box.tA === \"middle\" || box.tA === \"end\" || box.tA === \"start\"\n ? (box.tA as \"middle\" | \"end\" | \"start\")\n : \"start\",\n baseline: \"alphabetic\",\n },\n paint: {fill: box.fC, opacity: box.fO},\n transform: {x, y},\n };\n\n return {panel, margin: {top: height}};\n}\n\n/**\n Title as a FeatureModule. Uses `_titleClass._textData()` for height\n (pure compute, no DOM) and returns the margin claim explicitly.\n*/\nexport const titleFeature: FeatureModule = {\n name: \"title\",\n configFields: [\"title\", \"titleConfig\", \"titlePadding\"],\n layout: ctx =>\n textBlockLayout(ctx, {\n panelKey: \"viz-title\",\n getText: viz => (viz.schema.title ? viz.schema.title(viz._filteredData || []) : false),\n textClassKey: \"_titleClass\",\n configKey: \"titleConfig\",\n paddingMethod: \"titlePadding\",\n }),\n};\n\n/** Converts `drawSubtitle.ts` to a FeatureModule. Mirrors titleFeature. */\nexport const subtitleFeature: FeatureModule = {\n name: \"subtitle\",\n configFields: [\"subtitle\", \"subtitleConfig\", \"subtitlePadding\"],\n layout: ctx =>\n textBlockLayout(ctx, {\n panelKey: \"viz-subtitle\",\n getText: viz => (viz.schema.subtitle ? viz.schema.subtitle(viz._filteredData || []) : false),\n textClassKey: \"_subtitleClass\",\n configKey: \"subtitleConfig\",\n paddingMethod: \"subtitlePadding\",\n }),\n};\n\n/* -------------------------------- Legend --------------------------------- */\n\nexport {legendFeature} from \"./featuresLegend.js\";\n\n/* -------------------------------- Timeline ------------------------------- */\n\n/**\n Helper mirroring drawTimeline's `setTimeFilter`. Triggers a re-render when\n the brush selection changes — kept here so the feature owns its event flow.\n*/\nfunction setTimeFilter(viz: VizInstance, s: Date | Date[] | number[]): void {\n if (!Array.isArray(s)) s = [s, s] as Date[];\n if (JSON.stringify(s) !== JSON.stringify(viz._timelineSelection)) {\n viz._timelineSelection = s;\n const nums = (s as Array<Date | number>).map(Number) as number[];\n viz\n .timeFilter!((d: DataPoint) => {\n const ms = (date(viz.schema.time(d)) as Date).getTime();\n return ms >= nums[0] && ms <= nums[1];\n })\n .render!();\n }\n}\n\n/**\n Converts `drawTimeline.ts` to a FeatureModule.\n\n Visible only when `_time` is set, `_timeline` is truthy, and there is more\n than one distinct tick. Renders the chart's `_timelineClass` Timeline\n instance (compute mode — scene comes from Timeline.toScene via Viz.toScene's\n components collection) and claims `margin.bottom` from its outerBounds.\n*/\nexport const timelineFeature: FeatureModule = {\n name: \"timeline\",\n configFields: [\"timeline\", \"timelineConfig\", \"timelinePadding\"],\n layout: ({viz, layoutMargin}) => {\n let timelinePossible = viz.schema.time && viz.schema.timeline;\n const ticks = (\n timelinePossible\n ? unique(viz._data.map(viz.schema.time)).map(\n (d: unknown) => date(d as string | number),\n )\n : []\n ) as Date[];\n timelinePossible = timelinePossible && ticks.length > 1;\n const padding = viz.schema.timelinePadding(viz)\n ? viz._padding\n : {top: 0, right: 0, bottom: 0, left: 0};\n\n const transform = {\n transform: `translate(${layoutMargin.left + padding.left}, 0)`,\n };\n\n const timelineGroup = elem(\"g.d3plus-viz-timeline\", {\n condition: timelinePossible,\n enter: transform,\n parent: viz._select,\n duration: viz.schema.duration,\n update: transform,\n }).node();\n\n if (!timelinePossible) return {panel: null, margin: {}};\n\n const timeline = viz._timelineClass\n .renderMode(\"compute\")\n .domain(extent(ticks) as [Date, Date])\n .duration(viz.schema.duration)\n .height(viz.schema.height - layoutMargin.bottom)\n .locale(viz.schema.locale)\n .select(timelineGroup)\n .ticks(ticks.sort((a: Date, b: Date) => +a - +b))\n .width(\n viz.schema.width -\n (layoutMargin.left + layoutMargin.right + padding.left + padding.right),\n );\n\n // Clamp bound = the full time range (every tick); it never goes stale\n // mid-render. Clamping to `viz._filteredData`'s extent instead collapsed a\n // freshly-committed range down to the previous selection — the release\n // snap-back (e.g. [2017,2024] clamped to a stale [2022,2022]).\n const fullExtent = extent(ticks) as [Date, Date];\n if (!viz._timelineSelection) {\n // First render only: default to the *filtered* extent, which the\n // synthesized default timeFilter pins to the latest period (see\n // vizPreDraw) — the historical default. `timelineDefault` overrides it.\n const filtered = extent(\n (viz._filteredData || [])\n .map(viz.schema.time)\n .map((d: unknown) => date(d as string | number)) as Date[],\n ) as [Date, Date];\n viz._timelineSelection =\n viz.schema.timelineDefault || (filtered[0] ? filtered : fullExtent);\n } else {\n if (viz._timelineSelection[0] < fullExtent[0])\n viz._timelineSelection[0] = fullExtent[0];\n if (viz._timelineSelection[1] > fullExtent[1])\n viz._timelineSelection[1] = fullExtent[1];\n }\n timeline.selection(viz._timelineSelection);\n\n // Repaint the scene when playback toggles without moving the selection\n // (e.g. a manual pause), so the play/pause glyph refreshes immediately.\n timeline._onPlayToggle = () => viz._scheduleSceneRepaint();\n\n const config = viz.schema.timelineConfig;\n timeline\n .config(config)\n .on(\"brush\", (s: Date[]) => {\n // Filter on \"end\", not on every brush move. Re-rendering the whole Viz\n // mid-drag re-creates the d3-brush (and starts a brush transition),\n // which fights the active gesture and can make the selection snap back\n // on release — and it re-lays-out the chart on every pixel of the drag,\n // which is costly for large data. The brush still tracks the cursor\n // live; the chart updates when the drag finishes. User `on.brush`\n // callbacks still fire for custom live behavior.\n if (config.on && config.on.brush) config.on.brush(s);\n })\n .on(\"end\", (s: Date[]) => {\n setTimeFilter(viz, s);\n if (config.on && config.on.end) config.on.end(s);\n })\n .render();\n\n return {\n panel: null,\n margin: {bottom: timeline.outerBounds().height + timeline.padding() * 2},\n };\n },\n};\n\n/* ------------------------------- ColorScale ------------------------------ */\n\n/**\n Converts `drawColorScale.ts` to a FeatureModule.\n\n Visible only when `_colorScale` is truthy and `_colorScalePosition` resolves\n to a side. Renders the chart's `_colorScaleClass` ColorScale instance and\n claims margin along its position side.\n*/\nexport const colorScaleFeature: FeatureModule = {\n name: \"colorScale\",\n configFields: [\n \"colorScale\",\n \"colorScaleConfig\",\n \"colorScaleMaxSize\",\n \"colorScalePadding\",\n \"colorScalePosition\",\n ],\n layout: ({viz, layoutMargin}) => {\n const data = Array.from(\n rollup(\n viz._data,\n (leaves: DataPoint[]) => merge(leaves, viz.schema.aggs),\n (d: DataPoint, i: number) =>\n `${viz.schema.time ? viz.schema.time(d, i) : \"all\"}-${viz._ids(d, i).join(\"_\")}`,\n ).values(),\n );\n\n const position = sanitizePosition(viz.schema.colorScalePosition.bind(viz)(resolveSpec(viz)));\n const wide = [\"top\", \"bottom\"].includes(position as string);\n const showColorScale = viz.schema.colorScale && position;\n const padding = viz.schema.colorScalePadding(viz)\n ? viz._padding\n : {top: 0, right: 0, bottom: 0, left: 0};\n\n // Share the bottom band with the bottom-right corner panel (size legend):\n // a bottom colorScale fits beside it, a side one ends above it.\n const corner = bottomRightClearance(\n viz, position, layoutMargin.bottom + padding.bottom, layoutMargin.right + padding.right,\n );\n\n const availableWidth =\n viz.schema.width -\n (layoutMargin.left + layoutMargin.right + padding.left + padding.right) -\n corner.inset;\n const width = wide\n ? min([viz.schema.colorScaleMaxSize, availableWidth])!\n : viz.schema.width - (layoutMargin.left + layoutMargin.right);\n\n const availableHeight =\n viz.schema.height -\n (layoutMargin.bottom + layoutMargin.top + padding.bottom + padding.top) -\n corner.drop;\n const height = !wide\n ? min([viz.schema.colorScaleMaxSize, availableHeight])!\n : viz.schema.height - (layoutMargin.bottom + layoutMargin.top);\n\n const transform = {\n opacity: position ? 1 : 0,\n transform: `translate(${\n wide\n ? layoutMargin.left + padding.left + (availableWidth - width) / 2\n : layoutMargin.left\n }, ${\n wide\n ? layoutMargin.top\n : layoutMargin.top + padding.top + (availableHeight - height) / 2\n })`,\n };\n\n const scaleGroup = elem(\"g.d3plus-viz-colorScale\", {\n condition: showColorScale && !viz.schema.colorScaleConfig.select,\n enter: transform,\n parent: viz._select,\n duration: viz.schema.duration,\n update: transform,\n }).node();\n\n if (!viz.schema.colorScale) return {panel: null, margin: {}};\n\n const scaleData = data.filter((d: MergedDataPoint, i: number) => {\n const c = viz.schema.colorScale(d as unknown as DataPoint, i);\n return c !== undefined && c !== null;\n });\n\n // Discrete (bucket/jenks/quantile) colorScales render their swatches via an\n // internal Legend, which composes cleanly through the Viz scene — so run\n // them in compute mode (like the legend) so the Viz's toScene owns them and\n // hover/active dimming applies. Without this they render full-mode, where\n // paintComponentScene paints a full-opacity copy that overlays and defeats\n // the dimming. The smooth-gradient variant stays full-mode: its gradient\n // fill is materialized through paintComponentScene, not the Viz scene.\n const csCfg = (viz.schema.colorScaleConfig || {}) as {\n scale?: string;\n bucketAxis?: boolean;\n };\n const csDiscrete =\n !csCfg.bucketAxis &&\n [\"buckets\", \"jenks\", \"quantile\"].includes(\n typeof csCfg.scale === \"string\" ? csCfg.scale : \"\",\n );\n\n viz._colorScaleClass\n .renderMode(csDiscrete ? \"compute\" : \"full\")\n .align(\n ({bottom: \"end\", left: \"start\", right: \"end\", top: \"start\"} as Record<string, string>)[\n position as string\n ] || \"bottom\",\n )\n .duration(viz.schema.duration)\n .data(scaleData)\n .height(height)\n .locale(viz.schema.locale)\n .orient(position)\n .select(scaleGroup)\n .value(viz.schema.colorScale)\n .width(width)\n .config(viz.schema.colorScaleConfig)\n .render();\n\n const margin: Record<string, number> = {};\n if (showColorScale) {\n const scaleBounds = viz._colorScaleClass.outerBounds();\n if (!viz.schema.colorScaleConfig.select && scaleBounds.height) {\n // Use the colorScale's OWN padding for its margin claim — not the\n // legend's, so a custom legendPadding doesn't shift the\n // colorScale's claim when the legend is hidden. The colorScale\n // class is the source of truth.\n const csPadding =\n typeof viz._colorScaleClass.padding === \"function\"\n ? viz._colorScaleClass.padding()\n : viz._legendClass.padding();\n if (wide) margin[position] = scaleBounds.height + csPadding * 2;\n else margin[position] = scaleBounds.width + csPadding * 2;\n }\n }\n return {panel: null, margin};\n },\n};\n\n/* ------------------------------ Attribution ------------------------------ */\n\nexport {attributionFeature} from \"./attributionFeature.js\";\n\n/**\n Converts `drawTotal.ts` to a FeatureModule. Slightly different from title/\n subtitle: the text comes from `sum()` over the filtered data when `_total`\n is a function, or from `sum(data.map(_size))` when `_total === true`.\n*/\nexport const totalFeature: FeatureModule = {\n name: \"total\",\n configFields: [\"total\", \"totalConfig\", \"totalFormat\", \"totalPadding\"],\n layout: ctx =>\n textBlockLayout(ctx, {\n panelKey: \"viz-total\",\n getText: viz => {\n const data = viz._filteredData || [];\n const total =\n typeof viz.schema.total === \"function\"\n ? sum(data.map(viz.schema.total))\n : viz.schema.total === true && viz._size\n ? sum(data.map(viz._size))\n : false;\n return total ? viz.schema.totalFormat(total) : false;\n },\n textClassKey: \"_totalClass\",\n configKey: \"totalConfig\",\n paddingMethod: \"totalPadding\",\n }),\n};\n"],"names":["extent","min","rollup","sum","merge","unique","date","elem","resolveSpec","zoomControlsBox","getTopLeftContributions","topLeftControlsInset","topLeftControlsInsetRaw","bottomRightClearance","VALID_POSITIONS","Set","sanitizePosition","raw","has","runLayout","ctx","features","baseMargin","top","right","bottom","left","claims","panels","f","claim","layout","layoutMargin","result","panel","margin","vizUpdate","push","viz","target","Object","keys","k","key","startsWith","CORNER_INSET_GAP","zoomControlsInset","box","height","inset","width","contributions","cornerInsets","leftInset","rightInset","symmetric","Math","max","textBlockLayout","opts","text","getText","usesPadding","schema","paddingMethod","padding","_padding","textClass","textClassKey","data","locale","config","configKey","boxes","_textData","x","length","centered","tA","lineHeight","lH","blockPadding","lines","y","map","str","i","fS","widths","type","panelKey","font","family","fF","size","anchor","baseline","paint","fill","fC","opacity","fO","transform","titleFeature","name","configFields","title","_filteredData","subtitleFeature","subtitle","legendFeature","setTimeFilter","s","Array","isArray","JSON","stringify","_timelineSelection","nums","Number","timeFilter","d","ms","time","getTime","render","timelineFeature","timelinePossible","timeline","ticks","_data","timelinePadding","timelineGroup","condition","enter","parent","_select","duration","update","node","_timelineClass","renderMode","domain","select","sort","a","b","fullExtent","filtered","timelineDefault","selection","_onPlayToggle","_scheduleSceneRepaint","timelineConfig","on","brush","end","outerBounds","colorScaleFeature","from","leaves","aggs","_ids","join","values","position","colorScalePosition","bind","wide","includes","showColorScale","colorScale","colorScalePadding","corner","availableWidth","colorScaleMaxSize","availableHeight","drop","scaleGroup","colorScaleConfig","scaleData","filter","c","undefined","csCfg","csDiscrete","bucketAxis","scale","_colorScaleClass","align","orient","value","scaleBounds","csPadding","_legendClass","attributionFeature","totalFeature","total","_size","totalFormat"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;AAUA,GACA,SAAQA,MAAM,EAAEC,GAAG,EAAEC,MAAM,EAAEC,GAAG,QAAO,WAAW;AAElD,SAAQC,KAAK,EAAEC,MAAM,QAAO,eAAe;AAE3C,SAAQC,IAAI,EAAEC,IAAI,QAAO,cAAc;AAIvC,SAAQC,WAAW,QAAO,6BAA6B;AAGvD,SAAQC,eAAe,QAAO,qCAAqC;AACnE,SAAQC,uBAAuB,QAAO,kCAAkC;AACxE,SAAQC,wBAAwBC,uBAAuB,QAAO,wCAAwC;AACtG,SAAQC,oBAAoB,QAAO,4CAA4C;AAyF/E,IAAMC,kBAAuD,IAAIC,IAAI;IACnE;IACA;IACA;IACA;IACA;CACD;AAED;;;;;;AAMA,GACA,OAAO,SAASC,iBAAiBC,GAAY;IAC3C,OAAQH,gBAAgBI,GAAG,CAACD,OAAiBA,MAAM;AACrD;AAEA;;;;;;;;;;AAUA,GACA,OAAO,SAASE,UACdC,GAAe,EACfC,QAAyB;QACz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+D;gBAC/D,gCAAgC;gBAChC,IAAMiJ,YACJ,OAAO3J,IAAIsJ,gBAAgB,CAAC3H,OAAO,KAAK,aACpC3B,IAAIsJ,gBAAgB,CAAC3H,OAAO,KAC5B3B,IAAI4J,YAAY,CAACjI,OAAO;gBAC9B,IAAIuG,MAAMrI,MAAM,CAACkI,SAAS,GAAG2B,YAAYhJ,MAAM,GAAGiJ,YAAY;qBACzD9J,MAAM,CAACkI,SAAS,GAAG2B,YAAY9I,KAAK,GAAG+I,YAAY;YAC1D;QACF;QACA,OAAO;YAAC/J,OAAO;YAAMC,QAAAA;QAAM;IAC7B;AACF,EAAE;AAEF,6EAA6E,GAE7E,SAAQgK,kBAAkB,QAAO,0BAA0B;AAE3D;;;;AAIA,GACA,OAAO,IAAMC,eAA8B;IACzC5F,MAAM;IACNC,cAAc;QAAC;QAAS;QAAe;QAAe;KAAe;IACrE1E,QAAQX,SAARW,OAAQX;eACNsC,gBAAgBtC,KAAK;YACnBsE,UAAU;YACV7B,SAASvB,SAATuB,QAASvB;gBACP,IAAM+B,OAAO/B,IAAIqE,aAAa,IAAI,EAAE;gBACpC,IAAM0F,QACJ,OAAO/J,IAAIyB,MAAM,CAACsI,KAAK,KAAK,aACxBlM,IAAIkE,KAAKe,GAAG,CAAC9C,IAAIyB,MAAM,CAACsI,KAAK,KAC7B/J,IAAIyB,MAAM,CAACsI,KAAK,KAAK,QAAQ/J,IAAIgK,KAAK,GACpCnM,IAAIkE,KAAKe,GAAG,CAAC9C,IAAIgK,KAAK,KACtB;gBACR,OAAOD,QAAQ/J,IAAIyB,MAAM,CAACwI,WAAW,CAACF,SAAS;YACjD;YACAjI,cAAc;YACdI,WAAW;YACXR,eAAe;QACjB;;AACJ,EAAE"}
1
+ {"version":3,"sources":["../../../../src/charts/features/features.ts"],"sourcesContent":["/**\n FeatureModule + layout engine. The chart-level features (title,\n subtitle, total, legend, timeline, colorScale, back) are\n `FeatureModule` values composed by `runLayout`, which performs\n **explicit margin negotiation** — each feature returns a `MarginClaim`\n + optional `panel` scene node + optional declarative `vizUpdate`\n writes, and the engine accumulates margins across features in order.\n\n Every Plot-family + chart-shell feature here is wired into\n `vizDrawPure` via `runLayout(ctx, [...features])`.\n*/\nimport {extent, sum} from \"d3-array\";\n\nimport {unique} from \"@d3plus/data\";\nimport type {DataPoint} from \"@d3plus/data\";\nimport {date, elem} from \"@d3plus/dom\";\n\nimport type {SceneNode} from \"@d3plus/render\";\n\nimport type {VizContext} from \"../pipeline/stages.js\";\nimport type {VizInstance} from \"../viz/vizTypes.js\";\nimport {zoomControlsBox} from \"../drawSteps/zoomControlsMarkup.js\";\nimport {getTopLeftContributions} from \"../drawSteps/topLeftControls.js\";\nimport {topLeftControlsInset as topLeftControlsInsetRaw} from \"../drawSteps/topLeftControlsMarkup.js\";\n\n/** A margin claim, in pixels along each side. Unclaimed sides default to 0. */\nexport interface MarginClaim {\n top?: number;\n right?: number;\n bottom?: number;\n left?: number;\n}\n\n/** The shape a `layout` step returns: optional panel node + margin claim + optional viz writebacks. */\nexport interface FeatureLayout {\n panel: SceneNode | null;\n margin: MarginClaim;\n /**\n v4 purity: features that need to publish CROSS-FEATURE state — a\n write that a DIFFERENT feature or downstream stage will read — return\n those writes here as declarative key→value pairs. `runLayout`\n applies them to viz after the layout call so the next feature in\n the chain sees them.\n\n Key convention: keys are auto-prefixed with `_` to match viz's\n internal field convention. Return `{drawDepth: 2}` to write\n `viz._drawDepth`; explicitly-underscored keys (`{_drawDepth: 2}`)\n pass through unchanged for the rare case where the engine\n shouldn't prepend. This rule exists because a leading underscore\n is easy to forget and writing `viz.drawDepth` (no underscore) is\n almost never what callers want.\n\n Intra-feature local writes (a feature setting state that its OWN\n component instance reads inside the same `layout()` body) are\n legitimate direct mutations on viz — `vizUpdate` would defer the\n write past the local read. legendFeature's `_legendDepth` is an\n example of an intra-feature local; timelineFeature's\n `_timelineSelection` similarly mutates from its event handler\n context. The contract is about CROSS-feature mutation, not all\n mutation.\n */\n vizUpdate?: Record<string, unknown>;\n}\n\n/**\n @interface FeatureModule\n A chart-level component (title, subtitle, total, legend, timeline,\n colorScale, back, attribution) expressed as a pure value. Each feature:\n - contributes config keys to the chart's schema (`configFields`),\n - optionally derives extra fields onto the pipeline context (`derive`),\n - optionally claims a margin region + emits its panel scene (`layout`),\n - optionally registers event reducers (`events`).\n*/\nexport interface FeatureModule {\n name: string;\n /** Keys the chart's config inherits from this feature (used by E4 fluent gen). */\n configFields?: string[];\n /** Extra derivations to add into the pipeline context. */\n derive?: (ctx: VizContext) => Partial<VizContext>;\n /**\n Pure layout: read the (possibly updated-by-earlier-features) context and\n return the panel scene + margin this feature claims. The layoutEngine\n threads the margin claims through `ctx.layoutMargin` so a feature can\n read what earlier features already took.\n */\n layout?: (\n ctx: VizContext & {layoutMargin: Required<MarginClaim>},\n ) => FeatureLayout;\n /**\n Event reducers `(ctx, event) => Partial<VizConfig>`. Fire when a\n user interaction occurs on a node tagged with this feature's name.\n */\n events?: Record<string, (ctx: VizContext, event: unknown) => unknown>;\n}\n\n/**\n Result of running a list of features through the layout engine.\n*/\nexport interface LayoutResult {\n /** Panel nodes in feature order, ready to compose into the scene root. */\n panels: SceneNode[];\n /** Final margin after every feature claimed its space. */\n margin: Required<MarginClaim>;\n}\n\n/**\n The allowed values for `legendPosition` and `colorScalePosition`.\n `false` means \"hidden\" (the feature still runs to tear down DOM); the\n four strings are the four sides.\n*/\nexport type PanelPosition = false | \"top\" | \"right\" | \"bottom\" | \"left\";\n\nconst VALID_POSITIONS: ReadonlySet<PanelPosition | string> = new Set([\n false as unknown as string,\n \"top\",\n \"right\",\n \"bottom\",\n \"left\",\n]);\n\n/**\n Canonical sanitizer for `legendPosition` / `colorScalePosition`.\n Falls back to `\"bottom\"` when the user-supplied accessor returns\n something outside the allowed set. Single source of truth — used by\n `vizDrawPure` (for sanitized ctx publication) and by `legendFeature`\n + `colorScaleFeature` (for their internal positioning math).\n*/\nexport function sanitizePosition(raw: unknown): PanelPosition {\n return (VALID_POSITIONS.has(raw as string) ? raw : \"bottom\") as PanelPosition;\n}\n\n/**\n Runs each feature's `layout` in order, accumulating margin claims so that\n later features see the space already taken by earlier ones. The order of\n `features` is the layout order — this is how implicit `this._margin +=`\n side effects become *explicit* data flow.\n\n Today's order in `Viz._draw` (`drawTitle`, `drawSubtitle`, `drawTotal`,\n `drawBack`, `drawAttribution`, `drawColorScale`, `drawLegend`,\n `drawTimeline`) should be ported verbatim as the default sequence — port\n the math first, then improve.\n*/\nexport function runLayout(\n ctx: VizContext,\n features: FeatureModule[],\n baseMargin: Required<MarginClaim> = {top: 0, right: 0, bottom: 0, left: 0},\n): LayoutResult {\n // `claims` is this call's accumulated margin (the returned delta).\n // `layoutMargin` handed to each feature is the running TOTAL —\n // `baseMargin` (margin already taken by prior runLayout calls in the same\n // draw) plus the claims taken so far in this call — so a feature reads\n // the true current margin without touching viz._margin.\n const claims: Required<MarginClaim> = {top: 0, right: 0, bottom: 0, left: 0};\n const panels: SceneNode[] = [];\n for (const f of features) {\n if (!f.layout) continue;\n const layoutMargin: Required<MarginClaim> = {\n top: baseMargin.top + claims.top,\n right: baseMargin.right + claims.right,\n bottom: baseMargin.bottom + claims.bottom,\n left: baseMargin.left + claims.left,\n };\n const result = f.layout({...ctx, layoutMargin});\n const {panel, margin: claim, vizUpdate} = result;\n if (panel) panels.push(panel);\n claims.top += claim.top ?? 0;\n claims.right += claim.right ?? 0;\n claims.bottom += claim.bottom ?? 0;\n claims.left += claim.left ?? 0;\n // v4 purity: features publish cross-feature viz writes declaratively\n // via `vizUpdate`. The engine applies them — features don't mutate\n // viz directly from layout(). Skips own component-instance config\n // calls (those are local mutation, not cross-feature). Use\n // `Object.keys` (not `for...in`) so inherited enumerable properties\n // on a class-instance vizUpdate don't leak onto viz.\n //\n // Key convention: keys are auto-prefixed with `_` to land on the\n // viz's internal field convention (`viz._drawDepth`, `viz._legendDepth`).\n // Features should return UNPREFIXED keys (`{drawDepth: 2}`); the\n // engine normalizes — so feature authors can't accidentally write\n // `viz.drawDepth` (a different non-underscore property) instead of\n // `viz._drawDepth`. Keys that already start with `_` are passed\n // through unchanged so future explicit-internal writes still work.\n if (vizUpdate && ctx.viz) {\n const target = ctx.viz as Record<string, unknown>;\n for (const k of Object.keys(vizUpdate)) {\n const key = k.startsWith(\"_\") ? k : `_${k}`;\n target[key] = vizUpdate[k];\n }\n }\n }\n return {panels, margin: claims};\n}\n\n/* --------------------------- text-block features --------------------------- */\n\n/** A TextBox `_textData()` row, as the text-block features read it. */\ninterface TextDatum {\n lines: string[];\n lH: number;\n fS: number;\n fF: string;\n fC: string;\n fO: number;\n tA: string;\n widths: number[];\n}\n\n/**\n A little breathing room added to a NON-zero corner inset, on top of the\n exact pixel width the corner panel measured at. Without it, content\n insets to EXACTLY the corner box's edge — any tiny discrepancy between\n that hidden-probe measurement and the real rendered box (sub-pixel\n rounding, a font metric quirk) then reads as the text visibly, if\n slightly, running under the buttons.\n*/\nconst CORNER_INSET_GAP = 6;\n\n/**\n How far content starting `top` px down the chart, whose right edge sits\n `right` px in from the chart's right edge, must pull in its right edge to\n clear the zoom-control panel pinned to the chart's top-right corner. Zero\n when the chart shows no controls or the content starts below them.\n*/\nexport function zoomControlsInset(viz: VizInstance, top: number, right: number): number {\n const box = zoomControlsBox(viz as never);\n if (!box || top >= box.height) return 0;\n const inset = box.width - right;\n return inset > 0 ? inset + CORNER_INSET_GAP : 0;\n}\n\n/**\n The left-side mirror of `zoomControlsInset`: how far content starting\n `top` px down the chart, whose left edge sits `left` px in from the\n chart's left edge, must pull in to clear the shared top-left controls\n panel (back / table-view / search). Zero when nothing is showing there\n or content starts below the panel's height.\n*/\nexport function topLeftControlsInset(viz: VizInstance, top: number, left: number): number {\n const contributions = getTopLeftContributions(viz as never);\n const inset = topLeftControlsInsetRaw(viz as never, top, left, contributions);\n return inset > 0 ? inset + CORNER_INSET_GAP : 0;\n}\n\n/**\n The combined left+right corner-panel insets for content starting `top`\n px down the chart, plus the single symmetric amount CENTERED content\n should inset both sides by to stay centered on the full chart width even\n when only one corner has something to avoid (the larger of the two —\n see `textBlockLayout`'s doc comment for why). Shared by `textBlockLayout`\n (title/subtitle/total) and the legend's own top-position layout\n (`featuresLegend.ts`), which independently needed this exact same\n \"combine the two corners' insets\" math before this existed.\n*/\nexport function cornerInsets(\n viz: VizInstance,\n top: number,\n left: number,\n right: number,\n): {left: number; right: number; symmetric: number} {\n const leftInset = topLeftControlsInset(viz, top, left);\n const rightInset = zoomControlsInset(viz, top, right);\n return {left: leftInset, right: rightInset, symmetric: Math.max(leftInset, rightInset)};\n}\n\n/**\n Shared layout logic for any \"single line of text claiming margin.top\" feature\n (title, subtitle, total). Each feature passes the viz fields that source its\n text + TextBox + config; the helper computes the panel + margin claim using\n the TextBox's pure `_textData()` (no DOM).\n*/\nfunction textBlockLayout(\n ctx: VizContext & {layoutMargin: Required<MarginClaim>},\n opts: {\n panelKey: string;\n getText: (viz: VizInstance) => string | false;\n textClassKey: string; // e.g. \"_titleClass\"\n configKey: string; // schema key, e.g. \"titleConfig\"\n paddingMethod: string; // schema key, e.g. \"titlePadding\"\n },\n): FeatureLayout {\n const {viz, layoutMargin} = ctx;\n const text = opts.getText(viz);\n if (!text) return {panel: null, margin: {}};\n\n const usesPadding = (viz.schema[opts.paddingMethod] as (viz: VizInstance) => boolean)(viz);\n const padding = usesPadding\n ? viz._padding\n : {top: 0, right: 0, bottom: 0, left: 0};\n let width =\n viz.schema.width -\n (layoutMargin.left + layoutMargin.right + padding.left + padding.right);\n\n const textClass = viz[opts.textClassKey];\n textClass\n .data([{text}])\n .locale(viz.schema.locale)\n .width(width)\n .config(viz.schema[opts.configKey]);\n let boxes = textClass._textData() as TextDatum[];\n\n // Text alongside the zoom controls (right) and/or the shared top-left\n // controls panel (left — back/table-view/search) wraps short of them.\n // Centered text insets both sides by the SAME (larger) amount so it stays\n // centered on the full chart width, matching how it already behaved\n // relative to zoom alone; start/end-aligned text instead just narrows the\n // true available box (its unaffected edge stays exactly where it was).\n let x = layoutMargin.left + padding.left;\n const {left: leftInset, right: rightInset, symmetric} = cornerInsets(\n viz,\n layoutMargin.top,\n layoutMargin.left + padding.left,\n layoutMargin.right + padding.right,\n );\n if ((rightInset || leftInset) && boxes.length) {\n const centered = boxes[0].tA === \"middle\";\n if (centered) {\n x += symmetric;\n width -= symmetric * 2;\n } else {\n x += leftInset;\n width -= leftInset + rightInset;\n }\n textClass.width(width);\n boxes = textClass._textData() as TextDatum[];\n }\n if (!boxes.length) return {panel: null, margin: {}};\n const box = boxes[0];\n\n const lineHeight = box.lH;\n const blockPadding = (viz.schema[opts.configKey]?.padding as number) ?? 0;\n const height = box.lines.length * lineHeight + blockPadding * 2;\n // The claimed margin (below) already reserves `blockPadding` above AND\n // below the text — shifting the panel down by that same amount is what\n // actually centers the text within that reserved band, rather than\n // pinning it flush to the very top of it. Previously `blockPadding` only\n // grew/shrank the claimed space; it never moved the text within it,\n // which is why the default title padding (5px) had no visible effect —\n // the title sat at the top of its claim regardless, reading noticeably\n // higher than the same-row zoom/back/search buttons beside it.\n const y = layoutMargin.top + blockPadding;\n\n const lines = box.lines.map((str: string, i: number) => ({\n text: str,\n x:\n box.tA === \"middle\"\n ? width / 2\n : box.tA === \"end\"\n ? width\n : 0,\n y: (i + 1) * lineHeight - (lineHeight - box.fS),\n width: box.widths?.[i] ?? 0,\n }));\n\n const panel: SceneNode = {\n type: \"text\",\n key: opts.panelKey,\n x: 0,\n y: 0,\n lines,\n font: {\n family: box.fF,\n size: box.fS,\n anchor:\n box.tA === \"middle\" || box.tA === \"end\" || box.tA === \"start\"\n ? (box.tA as \"middle\" | \"end\" | \"start\")\n : \"start\",\n baseline: \"alphabetic\",\n },\n paint: {fill: box.fC, opacity: box.fO},\n transform: {x, y},\n };\n\n return {panel, margin: {top: height}};\n}\n\n/**\n Title as a FeatureModule. Uses `_titleClass._textData()` for height\n (pure compute, no DOM) and returns the margin claim explicitly.\n*/\nexport const titleFeature: FeatureModule = {\n name: \"title\",\n configFields: [\"title\", \"titleConfig\", \"titlePadding\"],\n layout: ctx =>\n textBlockLayout(ctx, {\n panelKey: \"viz-title\",\n getText: viz => (viz.schema.title ? viz.schema.title(viz._filteredData || []) : false),\n textClassKey: \"_titleClass\",\n configKey: \"titleConfig\",\n paddingMethod: \"titlePadding\",\n }),\n};\n\n/** Converts `drawSubtitle.ts` to a FeatureModule. Mirrors titleFeature. */\nexport const subtitleFeature: FeatureModule = {\n name: \"subtitle\",\n configFields: [\"subtitle\", \"subtitleConfig\", \"subtitlePadding\"],\n layout: ctx =>\n textBlockLayout(ctx, {\n panelKey: \"viz-subtitle\",\n getText: viz => (viz.schema.subtitle ? viz.schema.subtitle(viz._filteredData || []) : false),\n textClassKey: \"_subtitleClass\",\n configKey: \"subtitleConfig\",\n paddingMethod: \"subtitlePadding\",\n }),\n};\n\n/* -------------------------------- Legend --------------------------------- */\n\nexport {legendFeature} from \"./featuresLegend.js\";\n\n/* -------------------------------- Timeline ------------------------------- */\n\n/**\n Helper mirroring drawTimeline's `setTimeFilter`. Triggers a re-render when\n the brush selection changes — kept here so the feature owns its event flow.\n*/\nfunction setTimeFilter(viz: VizInstance, s: Date | Date[] | number[]): void {\n if (!Array.isArray(s)) s = [s, s] as Date[];\n if (JSON.stringify(s) !== JSON.stringify(viz._timelineSelection)) {\n viz._timelineSelection = s;\n const nums = (s as Array<Date | number>).map(Number) as number[];\n viz\n .timeFilter!((d: DataPoint) => {\n const ms = (date(viz.schema.time(d)) as Date).getTime();\n return ms >= nums[0] && ms <= nums[1];\n })\n .render!();\n }\n}\n\n/**\n Converts `drawTimeline.ts` to a FeatureModule.\n\n Visible only when `_time` is set, `_timeline` is truthy, and there is more\n than one distinct tick. Renders the chart's `_timelineClass` Timeline\n instance (compute mode — scene comes from Timeline.toScene via Viz.toScene's\n components collection) and claims `margin.bottom` from its outerBounds.\n*/\nexport const timelineFeature: FeatureModule = {\n name: \"timeline\",\n configFields: [\"timeline\", \"timelineConfig\", \"timelinePadding\"],\n layout: ({viz, layoutMargin}) => {\n let timelinePossible = viz.schema.time && viz.schema.timeline;\n const ticks = (\n timelinePossible\n ? unique(viz._data.map(viz.schema.time)).map(\n (d: unknown) => date(d as string | number),\n )\n : []\n ) as Date[];\n timelinePossible = timelinePossible && ticks.length > 1;\n const padding = viz.schema.timelinePadding(viz)\n ? viz._padding\n : {top: 0, right: 0, bottom: 0, left: 0};\n\n const transform = {\n transform: `translate(${layoutMargin.left + padding.left}, 0)`,\n };\n\n const timelineGroup = elem(\"g.d3plus-viz-timeline\", {\n condition: timelinePossible,\n enter: transform,\n parent: viz._select,\n duration: viz.schema.duration,\n update: transform,\n }).node();\n\n if (!timelinePossible) return {panel: null, margin: {}};\n\n const timeline = viz._timelineClass\n .renderMode(\"compute\")\n .domain(extent(ticks) as [Date, Date])\n .duration(viz.schema.duration)\n .height(viz.schema.height - layoutMargin.bottom)\n .locale(viz.schema.locale)\n .select(timelineGroup)\n .ticks(ticks.sort((a: Date, b: Date) => +a - +b))\n .width(\n viz.schema.width -\n (layoutMargin.left + layoutMargin.right + padding.left + padding.right),\n );\n\n // Clamp bound = the full time range (every tick); it never goes stale\n // mid-render. Clamping to `viz._filteredData`'s extent instead collapsed a\n // freshly-committed range down to the previous selection — the release\n // snap-back (e.g. [2017,2024] clamped to a stale [2022,2022]).\n const fullExtent = extent(ticks) as [Date, Date];\n if (!viz._timelineSelection) {\n // First render only: default to the *filtered* extent, which the\n // synthesized default timeFilter pins to the latest period (see\n // vizPreDraw) — the historical default. `timelineDefault` overrides it.\n const filtered = extent(\n (viz._filteredData || [])\n .map(viz.schema.time)\n .map((d: unknown) => date(d as string | number)) as Date[],\n ) as [Date, Date];\n viz._timelineSelection =\n viz.schema.timelineDefault || (filtered[0] ? filtered : fullExtent);\n } else {\n if (viz._timelineSelection[0] < fullExtent[0])\n viz._timelineSelection[0] = fullExtent[0];\n if (viz._timelineSelection[1] > fullExtent[1])\n viz._timelineSelection[1] = fullExtent[1];\n }\n timeline.selection(viz._timelineSelection);\n\n // Repaint the scene when playback toggles without moving the selection\n // (e.g. a manual pause), so the play/pause glyph refreshes immediately.\n timeline._onPlayToggle = () => viz._scheduleSceneRepaint();\n\n const config = viz.schema.timelineConfig;\n timeline\n .config(config)\n .on(\"brush\", (s: Date[]) => {\n // Filter on \"end\", not on every brush move. Re-rendering the whole Viz\n // mid-drag re-creates the d3-brush (and starts a brush transition),\n // which fights the active gesture and can make the selection snap back\n // on release — and it re-lays-out the chart on every pixel of the drag,\n // which is costly for large data. The brush still tracks the cursor\n // live; the chart updates when the drag finishes. User `on.brush`\n // callbacks still fire for custom live behavior.\n if (config.on && config.on.brush) config.on.brush(s);\n })\n .on(\"end\", (s: Date[]) => {\n setTimeFilter(viz, s);\n if (config.on && config.on.end) config.on.end(s);\n })\n .render();\n\n return {\n panel: null,\n margin: {bottom: timeline.outerBounds().height + timeline.padding() * 2},\n };\n },\n};\n\n/* ------------------------------- ColorScale ------------------------------ */\n\nexport {colorScaleFeature} from \"./featuresColorScale.js\";\n\n/* ------------------------------ Attribution ------------------------------ */\n\nexport {attributionFeature} from \"./attributionFeature.js\";\n\n/**\n Converts `drawTotal.ts` to a FeatureModule. Slightly different from title/\n subtitle: the text comes from `sum()` over the filtered data when `_total`\n is a function, or from `sum(data.map(_size))` when `_total === true`.\n*/\nexport const totalFeature: FeatureModule = {\n name: \"total\",\n configFields: [\"total\", \"totalConfig\", \"totalFormat\", \"totalPadding\"],\n layout: ctx =>\n textBlockLayout(ctx, {\n panelKey: \"viz-total\",\n getText: viz => {\n const data = viz._filteredData || [];\n const total =\n typeof viz.schema.total === \"function\"\n ? sum(data.map(viz.schema.total))\n : viz.schema.total === true && viz._size\n ? sum(data.map(viz._size))\n : false;\n return total ? viz.schema.totalFormat(total) : false;\n },\n textClassKey: \"_totalClass\",\n configKey: \"totalConfig\",\n paddingMethod: \"totalPadding\",\n }),\n};\n"],"names":["extent","sum","unique","date","elem","zoomControlsBox","getTopLeftContributions","topLeftControlsInset","topLeftControlsInsetRaw","VALID_POSITIONS","Set","sanitizePosition","raw","has","runLayout","ctx","features","baseMargin","top","right","bottom","left","claims","panels","f","claim","layout","layoutMargin","result","panel","margin","vizUpdate","push","viz","target","Object","keys","k","key","startsWith","CORNER_INSET_GAP","zoomControlsInset","box","height","inset","width","contributions","cornerInsets","leftInset","rightInset","symmetric","Math","max","textBlockLayout","opts","text","getText","usesPadding","schema","paddingMethod","padding","_padding","textClass","textClassKey","data","locale","config","configKey","boxes","_textData","x","length","centered","tA","lineHeight","lH","blockPadding","lines","y","map","str","i","fS","widths","type","panelKey","font","family","fF","size","anchor","baseline","paint","fill","fC","opacity","fO","transform","titleFeature","name","configFields","title","_filteredData","subtitleFeature","subtitle","legendFeature","setTimeFilter","s","Array","isArray","JSON","stringify","_timelineSelection","nums","Number","timeFilter","d","ms","time","getTime","render","timelineFeature","timelinePossible","timeline","ticks","_data","timelinePadding","timelineGroup","condition","enter","parent","_select","duration","update","node","_timelineClass","renderMode","domain","select","sort","a","b","fullExtent","filtered","timelineDefault","selection","_onPlayToggle","_scheduleSceneRepaint","timelineConfig","on","brush","end","outerBounds","colorScaleFeature","attributionFeature","totalFeature","total","_size","totalFormat"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;AAUA,GACA,SAAQA,MAAM,EAAEC,GAAG,QAAO,WAAW;AAErC,SAAQC,MAAM,QAAO,eAAe;AAEpC,SAAQC,IAAI,EAAEC,IAAI,QAAO,cAAc;AAMvC,SAAQC,eAAe,QAAO,qCAAqC;AACnE,SAAQC,uBAAuB,QAAO,kCAAkC;AACxE,SAAQC,wBAAwBC,uBAAuB,QAAO,wCAAwC;AAyFtG,IAAMC,kBAAuD,IAAIC,IAAI;IACnE;IACA;IACA;IACA;IACA;CACD;AAED;;;;;;AAMA,GACA,OAAO,SAASC,iBAAiBC,GAAY;IAC3C,OAAQH,gBAAgBI,GAAG,CAACD,OAAiBA,MAAM;AACrD;AAEA;;;;;;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